-
Notifications
You must be signed in to change notification settings - Fork 184
Update theme info command to support multiple environments #5392
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Coverage report
Show files with reduced coverage 🔻
Test suite run success2140 tests passing in 938 suites. Report generated by 🧪jest coverage report action from 70a9a02 |
d744382
to
1f4d53f
Compare
.map(([key, val]) => formatSection(key, `${val}`)) | ||
.join('\n\n') | ||
outputInfo(infoMessage) | ||
const formattedInfo = await formatThemeInfo(output, flags) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Moved the logic of the output into packages/theme/src/cli/services/info.ts
@@ -84,3 +101,54 @@ describe('info', () => { | |||
}) | |||
}) | |||
}) | |||
|
|||
describe('formatThemeInfo', () => { | |||
beforeEach(() => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Due to how our mocking works, we need to refresh when testing formatSection
. I followed the same principles from another test.
@@ -84,3 +85,26 @@ function tabularSection(title: string, data: InlineToken[][]): AlertCustomSectio | |||
body: {tabularData: data, firstColumnSubdued: true}, | |||
} | |||
} | |||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Originally, I was going to try using tabularData
but the main problem is the output is key : value
so if you have PREVIEW_URL : https://mystoremyshopify.com?preview_theme_id=130327216212
, it will wrap onto another line when within renderInfo
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We could adopt an approach similar to the shopify theme dev
command and use the LinkToken
with a truncated label :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agreed. I have taken this approach in the new commit.
], | ||
}) | ||
|
||
expect(formatSection).toHaveBeenCalledTimes(6) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How valuable of an assertion are you thinking this is? Can we skip mocking the function entirely?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for this PR, @EvilGenius13!
I've noticed that we are not displaying the environment when users run the info
command without passing the --theme
:
Aside from that minor detail, the changes are on the right track! :)
f718064
to
7165d29
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you, @EvilGenius13!
I've left only one minor comment we may apply in a different PR 🚀
title: `Theme information`, | ||
body: [{subdued: `Environment name: ${flags.environment}`}], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think it is ideal to show the environment name under the theme information because the environment is not actually related to any theme.
I believe we could instead always display the environment name (when available) and present it in a separate section from the theme.
We may apply that enhancement in a different PR tho 🙇
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll open another issue and tackle it there! - New issue opened
This commit refactors the theme info command to use multiple environment flags.
7165d29
to
70a9a02
Compare
Follow up from #5284
Allow
theme info
command to be called using multiple environmentsWHAT is this pull request doing?
These changes allow a user to pass multiple environment from their
shopify.theme.toml
file at once.Before:

After:

With terminal hyperlinks:
Without terminal hyperlinks:

How to test your changes?
shopify.theme.toml
fileNote: You will need to create an access token through your shop(s) to bypass the need to login during theme commands.
The most basic example of the structure needed would be this:
theme info -e env1 -e env2
or whatever you named your environments.Post-release steps
We will be converting more commands to support multiple environments.
Measuring impact
How do we know this change was effective? Please choose one:
Checklist