Skip to content
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

Update theme info command to support multiple environments #5392

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

EvilGenius13
Copy link
Contributor

@EvilGenius13 EvilGenius13 commented Feb 14, 2025

Follow up from #5284
Allow theme info command to be called using multiple environments

WHAT is this pull request doing?

These changes allow a user to pass multiple environment from their shopify.theme.toml file at once.

Before:
image

After:
With terminal hyperlinks:
image

Without terminal hyperlinks:
image

How to test your changes?

  • Pull down the branch
  • Build the branch
  • If you don't already have one, create a shopify.theme.toml file

Note: 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:

[environments.env1]
store = "myfirstshop.myshopify.com"
password = "access_token"
[environments.env2]
store = "mysecondshop.myshopify.com"
password = "access_token"
  • Run 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:

  • Existing analytics will cater for this addition

Checklist

  • I've considered possible cross-platform impacts (Mac, Linux, Windows)
  • [] I've considered possible documentation changes

Copy link
Contributor

github-actions bot commented Feb 14, 2025

Coverage report

St.
Category Percentage Covered / Total
🟡 Statements
76.42% (+0.01% 🔼)
9300/12169
🟡 Branches
71.66% (+0.02% 🔼)
4560/6363
🟡 Functions 76.05% 2419/3181
🟡 Lines
76.99% (+0.02% 🔼)
8789/11416
Show files with reduced coverage 🔻
St.
File Statements Branches Functions Lines
🟢
... / app-event-watcher.ts
96.39% (-1.2% 🔻)
88.57% (-2.86% 🔻)
95.45% 100%

Test suite run success

2111 tests passing in 930 suites.

Report generated by 🧪jest coverage report action from 7165d29

@EvilGenius13 EvilGenius13 force-pushed the add-info-to-multi-env branch 2 times, most recently from d744382 to 1f4d53f Compare February 14, 2025 17:59
.map(([key, val]) => formatSection(key, `${val}`))
.join('\n\n')
outputInfo(infoMessage)
const formattedInfo = await formatThemeInfo(output, flags)
Copy link
Contributor Author

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(() => {
Copy link
Contributor Author

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},
}
}

Copy link
Contributor Author

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.

Copy link
Contributor

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 :)

Copy link
Contributor Author

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.

@EvilGenius13 EvilGenius13 marked this pull request as ready for review February 14, 2025 20:44
@EvilGenius13 EvilGenius13 requested review from a team as code owners February 14, 2025 20:44
],
})

expect(formatSection).toHaveBeenCalledTimes(6)
Copy link
Contributor

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?

Copy link
Contributor

@karreiro karreiro left a 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:

image

Aside from that minor detail, the changes are on the right track! :)

@EvilGenius13 EvilGenius13 force-pushed the add-info-to-multi-env branch 2 times, most recently from 2bccea7 to f718064 Compare February 27, 2025 18:52
@EvilGenius13 EvilGenius13 force-pushed the add-info-to-multi-env branch from f718064 to 7165d29 Compare March 5, 2025 15:03
@EvilGenius13 EvilGenius13 requested a review from karreiro March 5, 2025 19:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants