-
Notifications
You must be signed in to change notification settings - Fork 248
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
Clean up messaging around unlinked storefronts when running CLI commands #1937
Conversation
eadf80b
to
f43f43a
Compare
Oxygen deployed a preview of your
Learn more about Hydrogen's GitHub integration. |
.changeset/breezy-jokes-pump.md
Outdated
|
||
Clean up messaging around unlinked storefronts when running CLI commands | ||
|
||
- 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. |
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.
Let's clarify here that it's only for Admin related links somehow? I.e. this doesn't affect dev/build commands.
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.
That's a good point, i'm going to update the code so it's for env push
, env pull
, env list
, deploy
. Do we not already show an error when we run h2 dev
on unlinked storefronts?
f43f43a
to
7b8d46a
Compare
Force push
|
6171756
to
30acde7
Compare
Force push
|
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.
🎩 went well, just a couple of questions
|
||
if (!configStorefront) return; | ||
config.storefront = linkedStorefront; |
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'm confused by the use of config.storefront = X
in this PR. Should we be using setStorefront
from shopify-config
?
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.
So setStorefront
sets your shopify project.json
file to have the linked storefront's data.
verifyLinkedStorefront
just checks the following:
- checks to make sure you have any storefront linked in your
project.json
file - talks to Admin and ensures that storefront still exists
- this prevents the yucky GraphQL error you would get if you deleted your storefront on Admin
@@ -284,6 +284,10 @@ export async function handleStorefrontSelection( | |||
})), | |||
]; | |||
|
|||
if (choices.length === 1) { |
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.
Is this clear enough that we're launching them into the creation flow? I wonder if we should be printing some text like "No storefronts found on . Create a new one to continue"
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.
Hmm yeah i think an extra message here saying that we're creating the storefront is fine.
@mynameisadamf any issues with that? I know your original design merged those two banners. However, the first banner message must appear before you choose to run h2 link
, where the latter message appear after.
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.
@aswamy We decided on the implicit approach, which if they were to run h2 deploy
we would put them in the link flow w/o prompting. Would be this:
user input: h2 deploy
Info banner:
You haven’t linked your project to a storefront yet.
Prompt: If existing storefronts
Select a Hydrogen storefront to link:
- Create a new storefront
- [storefront]
- [storefront]
Prompt: If no existing storefronts
Create a Hydrogen storefront
[input]
relates to env pull
https://github.com/Shopify/custom-storefronts/issues/352#issuecomment-2009983378
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 decided on the implicit approach, which if they were to run h2 deploy we would put them in the link flow w/o prompting.
Should this follow this for all other admin commands like env push
, env list
, env pull
?
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.
Yes. This pattern will apply anywhere being linked to a store is required.
2d3d8cb
to
4bd1e91
Compare
Force push
|
4bd1e91
to
e0e1045
Compare
Force Push
|
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.
🎩 went well and matched expected output.
I just have two questions around the use of !
let chosenEnvironment = findEnvironmentByBranchOrThrow( | ||
deploymentData!.environments!, | ||
config.environmentTag!, | ||
); |
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.
In this case, do we know definitively that these arguments will not be undefined
?
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.
Yep, had to scroll up but confirmed deploymentData
HAS to be defined or an early return would occur.
config.environmentTag
has to be defined if one of the items userProvidedEnvironmentTag
or userChosenEnvironmentTag
is defined.
const storefronts = await getStorefronts(session); | ||
|
||
let configuredStorefront = config.storefront?.id | ||
? storefronts.find(({id}) => id === config.storefront!.id) |
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.
Same here, can we guarantee that the config.storefront
exists?
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.
Yep, you can only get into this conditional statement if config.storefront
AND config.storefront.id
is truthy.
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.
Thanks Alok. Frustrating that typescript can't infer that the config.storefront.id
is defined inside of the find
method.
e0e1045
to
0463082
Compare
WHY are these changes introduced?
WHAT is this pull request doing?
Changes:
HOW to test your changes?
npm ci
cd packages/cli && npm run build
npm run build
inside the other packagesh2 init
and link itpackages/cli
directory of the projectTesting deleted storefront && unlinked storefront banner
.shopify/project.json
file sostorefront: {}
h2 deploy --path=<path-to-project>
h2 env list
,h2 env pull
,h2 env push__unstable
commands to see the bannerTesting no storefronts on Admin
h2 init
Post-merge steps
Checklist