fix missing json output for theme info command when dev and theme flags are missing#6905
Open
fix missing json output for theme info command when dev and theme flags are missing#6905
Conversation
|
🤖 Code Review · #projects-dev-ai for questions ✅ Complete - No issues 📋 History✅ 1 findings → ✅ No issues |
070e0fa to
d198b78
Compare
|
These findings are in files not modified by this PR and cannot be posted as inline comments.
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
WHY are these changes introduced?
Fixes #1064 : Theme info not outputting json with the --json flag
I identified that when running
shopify theme info --jsonwithout a--themeor--developmentflag, execution goes to the else branch, which had no JSON handling. TheJSON.stringifylogic only existed in theifbranch (which requires--themeor--development)The
elsebranch had no--jsonhandling at all, so the flag was silently ignored.WHAT is this pull request doing?
I could have chosen to jsonify the existing info message, but this was formulated for the tabular data to output the formatted box in the terminal and looks messy and is more difficult to parse. It would have looked like this:
Click to expand
Output:
I chose to make a new, more easily parse-able json object (following the pattern of the if branch, where a clean object is also created specifically to be consumed by
JSON.stringify). I built a new Interface and function to populate the object inpackages/theme/src/cli/services/info.ts, then consumed it in theelsebranch inpackages/theme/src/cli/commands/theme/info.tsI wrote a new unittest to verify that the JSON conversion is working correctly.
All existing tests pass.
How to test your changes?
while on main, run
shopify theme info --json, should see no json and formulated tabular info like this:then pull down my branch locally,

p build,run
shopify-dev theme info --jsonsee the nice JSON formatting!
Measuring impact
How do we know this change was effective? Please choose one: