-
Notifications
You must be signed in to change notification settings - Fork 253
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
Add --env
& deprecate --env-branch
flag for Hydrogen CLI commands
#1841
Conversation
956e0bb
to
45a95e8
Compare
Oxygen deployed a preview of your
Learn more about Hydrogen's GitHub integration. |
2ca814c
to
f15297f
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.
Initial thoughts
--env-handle
& remove --env-branch
flag for deploy
& env pull
--env-handle
& deprecate --env-branch
flag for deploy
& env pull
--env-handle
& deprecate --env-branch
flag for deploy
& env pull
--env
& deprecate --env-branch
flag for Hydrogen CLI commands
f15297f
to
5fef655
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.
Looking good! Did a whole bunch of 🎩ing and commented on a couple of things that popped up for me.
environmentTag = findEnvironmentByBranchOrThrow( | ||
deploymentData?.environments || [], | ||
envBranch, | ||
).branch; |
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.
This is a change in behavior that I think makes sense but could also be considered a breaking change. This change would mean that you cannot use the --env-branch
flag in CI. Prefer to support the existing behavior and let envHandle
be the new flow.
Could tackle this a few different ways so you've got options!
(deploymentData?.environments
is always undefined
in CI so this will always throw)
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.
oh dang... this means that --env-handle
wouldn't work in CI as well... OxygenCLI only understands branch names (not handles).
Prefer to support the existing behavior and let envHandle be the new flow.
Does this mean that --env-handle
should exclusively be for non-CI?
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.
Does this mean that --env-handle should exclusively be for non-CI?
exactly!
packages/cli/src/lib/flags.ts
Outdated
env: 'SHOPIFY_HYDROGEN_ENVIRONMENT_BRANCH', | ||
deprecated: { | ||
to: 'env', | ||
message: 'Flag is deprecated. Use --env instead.', |
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.
This renders as:
› Warning: Flag is deprecated. Use --env instead.
with no indication as to which flag is deprecated. Maybe we could do:
message: 'Flag is deprecated. Use --env instead.', | |
message: '--env-branch is deprecated. Use --env instead.', |
Not sure if we want to mention that it'll be removed in a future version or of that's implied.
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 think that's implied. I also don't know if we will remember to remove it in the following major version. We need a TODO list of "these are items we need to update / remove before the next major version" before we promise what will be changed/removed in the following version of Hydrogen CLI.
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.
Nothing stands out to me, but still some ongoing things from Gray's feedback. I'll re-review when the dust settles! Great stuff here and improvements though.
5fef655
to
1dbd00e
Compare
Force push
|
(await getStorefrontEnvironments(session, config.storefront.id)) | ||
?.environments || []; | ||
if (envHandle) { | ||
findEnvironmentOrThrow(environments, envHandle); |
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.
Shouldn't this write to envHandle
or envBranch
variable? Or is just a code check?
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.
It's just to check and throw if the user provided bad envHandle
}), | ||
}, | ||
env: { | ||
env: Flags.string({ | ||
envBranch: { |
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.
Can you add some sort of /** @deprecated **/
comment around here so that we remember to deprecate this in the next major bump?
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.
Done!
Do we have a standard for this? I would love to group all of our breaking changes into a major bump. Unless this comment is our standard 😅
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 tend to do something like this for deprecated stuff, yeah.
'env-branch': Flags.string({ | ||
description: | ||
"Specifies an environment's name when using remote environment variables.", | ||
env: 'SHOPIFY_HYDROGEN_ENVIRONMENT_NAME', | ||
'Specifies the environment to perform the operation using its Git branch name.', | ||
env: 'SHOPIFY_HYDROGEN_ENVIRONMENT_BRANCH', | ||
deprecated: { | ||
to: 'env', | ||
message: '--env-branch is deprecated. Use --env instead.', | ||
}, | ||
}), |
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.
Maybe this one should be hidden: true
to avoid new uses?
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.
envBranch
is the old flag we want to deprecate
env
is the new flag we want users to start using right away. We will deprecate it in the following major bump.
1dbd00e
to
916caf4
Compare
916caf4
to
b2d5dfc
Compare
for Hydrogen CLI commands
b2d5dfc
to
a8a7768
Compare
WHY are these changes introduced?
--env
flag to standardize how we refer to environments in the CLIenv list
--env
flag which was used to identify environment by name (used only byenv push__unstable
)--env-branch
fromenv pull
,env push__unstable
,deploy
,preview
,dev-vite
,dev
WHAT is this pull request doing?
HOW to test your changes?
npm ci && cd packages/cli & npm run build
npx shopify hydrogen init
and connect it a repo on Adminpackages/cli
test the following commands:npx shopify hydrogen env list --path=/path/to/repo
npx shopify hydrogen deploy --path=/path/to/repo
npx shopify hydrogen deploy --path=/path/to/repo --env-handle=production
npx shopify hydrogen deploy --path=/path/to/repo --env-handle=fake
npx shopify hydrogen env pull --path=/path/to/repo
npx shopify hydrogen env pull --path=/path/to/repo --env-handle=production
npx shopify hydrogen env pull --path=/path/to/repo --env-handle=fake
.env
file in the storefront projectnpx shopify hydrogen env push__unstable --path=/path/to/repo
npx shopify hydrogen env push__unstable --path=/path/to/repo --env-handle=production
npx shopify hydrogen env push__unstable --path=/path/to/repo --env-handle=fake
Screenshots
env list
env pull
env push__unstable
deploy
Post-merge steps
Checklist