hydrogen icon indicating copy to clipboard operation
hydrogen copied to clipboard

Clean up messaging around unlinked storefronts when running CLI commands

Open aswamy opened this issue 1 year ago • 5 comments

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 ci
    • cd packages/cli && npm run build
    • If it doesn't build, you might also need to run npm run build inside the other packages
  • Create a storefront using h2 init and link it
    • You can run this command by navigating to the packages/cli directory of the project

Testing deleted storefront && unlinked storefront banner

  • Go to the directory of your newly created storefront
    • Edit the .shopify/project.json file so storefront: {}
  • 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__unstable commands 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

image

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

aswamy avatar Apr 02 '24 22:04 aswamy

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.

shopify[bot] avatar Apr 02 '24 22:04 shopify[bot]

Force push

  • If you run h2 env push__unstable, h2 env pull, h2 env list, or h2 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-storefront into 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, linkStorefront now takes an optional list of storefronts so we don't have to fetch it 2x

aswamy avatar Apr 03 '24 20:04 aswamy

Force push

  • Removing user-confirmation on h2 deploy when user selects a preview environment, user passes in preview env handle, or user provides --preview flag

aswamy avatar Apr 04 '24 21:04 aswamy

Force push

  • Updated the "not linked" banner when running env push, env pull, env list, or deploy command without linking a storefront on Admin
  • Remove the user-prompt to link a storefront if it isn't linked

aswamy avatar Apr 05 '24 20:04 aswamy

Force Push

  • Rebased with main

aswamy avatar Apr 10 '24 15:04 aswamy