hydrogen
hydrogen copied to clipboard
Clean up messaging around unlinked storefronts when running CLI commands
WHY are these changes introduced?
- Cleaning up Hydrogen CLI link command and messaging around linked storefront
WHAT is this pull request doing?
Changes:
- We will show a warning (not error) when you run a Hydrogen CLI command on a storefront that isn't linked to a storefront on Admin.
- If you don't have a storefront to link to on Admin, we will just ask you to create a storefront instead of displaying an option list of size 1.
- If you deleted a storefront on Admin, we will try to relink your storefront when running a Hydrogen CLI command.
HOW to test your changes?
- Checkout this repo and build it
npm cicd packages/cli && npm run build- If it doesn't build, you might also need to run
npm run buildinside the other packages
- Create a storefront using
h2 initand link it- You can run this command by navigating to the
packages/clidirectory of the project
- You can run this command by navigating to the
Testing deleted storefront && unlinked storefront banner
- Go to the directory of your newly created storefront
- Edit the
.shopify/project.jsonfile sostorefront: {}
- Edit the
- In hydrogen/packages/cli, run
h2 deploy --path=<path-to-project>- It should prompt you to link a storefront using the warning severity
- also try
h2 env list,h2 env pull,h2 env push__unstablecommands to see the banner
Testing no storefronts on Admin
- Ensure you have Hydrogen App installed on your shop, but no storefronts
- In hydrogen/packages/cli, run
h2 init- Try to link a storefront
- Instead of prompting you to select a storefront, it will assume you want to create the storefront and ask you its name
Post-merge steps
Checklist
- [x] I've read the Contributing Guidelines
- [x] I've considered possible cross-platform impacts (Mac, Linux, Windows)
- [x] I've added a changeset if this PR contains user-facing or noteworthy changes
- [x] I've added tests to cover my changes
- [x] I've added or updated the documentation
Oxygen deployed a preview of your cli-consistency-2 branch. Details:
| Storefront | Status | Preview link | Deployment details | Last update (UTC) |
|---|---|---|---|---|
| subscriptions | ✅ Successful (Logs) | Preview deployment | Inspect deployment | April 17, 2024 5:22 PM |
| custom-cart-method | ✅ Successful (Logs) | Preview deployment | Inspect deployment | April 17, 2024 5:22 PM |
| third-party-queries-caching | ✅ Successful (Logs) | Preview deployment | Inspect deployment | April 17, 2024 5:22 PM |
| optimistic-cart-ui | ✅ Successful (Logs) | Preview deployment | Inspect deployment | April 17, 2024 5:22 PM |
| skeleton | ✅ Successful (Logs) | Preview deployment | Inspect deployment | April 17, 2024 5:22 PM |
| vite | ✅ Successful (Logs) | Preview deployment | Inspect deployment | April 17, 2024 5:22 PM |
Learn more about Hydrogen's GitHub integration.
Force push
- If you run
h2 env push__unstable,h2 env pull,h2 env list, orh2 deploy, we will verify- you have linked your storefront on Admin
- if the existing storefront you've connected still exists on Admin (or has been deleted)
- moved
verify-linked-storefrontinto a separate file for consistency and so we can easily test it- other Hydrogen CLI commands will call this method to ensure we have linked a storefront
- As Fran recommended,
linkStorefrontnow takes an optional list ofstorefrontsso we don't have to fetch it 2x
Force push
- Removing user-confirmation on
h2 deploywhen user selects a preview environment, user passes in preview env handle, or user provides--previewflag
Force push
- Updated the "not linked" banner when running
env push,env pull,env list, ordeploycommand without linking a storefront on Admin - Remove the user-prompt to link a storefront if it isn't linked
Force Push
- Rebased with main