-
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
--- | ||
'@shopify/cli-hydrogen': patch | ||
--- | ||
|
||
Clean up messaging around unlinked storefronts when running CLI commands | ||
|
||
- When you run `env list`, `env pull`, or `deploy` against a storefront that isn't linked, it will show a warning message instead of an error message. | ||
- 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 `env list`, `env pull`, or `deploy`. |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +1,18 @@ | ||
import {Flags} from '@oclif/core'; | ||
import Command from '@shopify/cli-kit/node/base-command'; | ||
import {renderConfirmationPrompt} from '@shopify/cli-kit/node/ui'; | ||
import {pluralize} from '@shopify/cli-kit/common/string'; | ||
import colors from '@shopify/cli-kit/node/colors'; | ||
import { | ||
outputContent, | ||
outputInfo, | ||
outputNewline, | ||
} from '@shopify/cli-kit/node/output'; | ||
import {linkStorefront} from '../link.js'; | ||
import {commonFlags} from '../../../lib/flags.js'; | ||
import {getStorefrontEnvironments} from '../../../lib/graphql/admin/list-environments.js'; | ||
import {createEnvironmentCliChoiceLabel} from '../../../lib/common.js'; | ||
import { | ||
renderMissingLink, | ||
renderMissingStorefront, | ||
} from '../../../lib/render-errors.js'; | ||
import {renderMissingStorefront} from '../../../lib/render-errors.js'; | ||
import {login} from '../../../lib/auth.js'; | ||
import {getCliCommand} from '../../../lib/shell.js'; | ||
import {verifyLinkedStorefront} from '../../../lib/verify-linked-storefront.js'; | ||
|
||
export default class EnvList extends Command { | ||
static descriptionWithMarkdown = | ||
|
@@ -46,35 +41,26 @@ export async function runEnvList({path: root = process.cwd()}: Flags) { | |
getCliCommand(), | ||
]); | ||
|
||
let configStorefront = config.storefront; | ||
|
||
if (!configStorefront?.id) { | ||
renderMissingLink({session, cliCommand}); | ||
|
||
const runLink = await renderConfirmationPrompt({ | ||
message: ['Run', {command: `${cliCommand} link`}, '?'], | ||
}); | ||
|
||
if (!runLink) { | ||
return; | ||
} | ||
const linkedStorefront = await verifyLinkedStorefront({ | ||
root, | ||
session, | ||
config, | ||
cliCommand, | ||
}); | ||
|
||
configStorefront = await linkStorefront(root, session, config, { | ||
cliCommand, | ||
}); | ||
} | ||
if (!linkedStorefront) return; | ||
|
||
if (!configStorefront) return; | ||
config.storefront = linkedStorefront; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm confused by the use of There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. So
|
||
|
||
const storefront = await getStorefrontEnvironments( | ||
session, | ||
configStorefront.id, | ||
config.storefront.id, | ||
); | ||
|
||
if (!storefront) { | ||
renderMissingStorefront({ | ||
session, | ||
storefront: configStorefront, | ||
storefront: config.storefront, | ||
cliCommand, | ||
}); | ||
|
||
|
@@ -95,7 +81,7 @@ export async function runEnvList({path: root = process.cwd()}: Flags) { | |
outputInfo( | ||
pluralizedEnvironments({ | ||
environments: storefront.environments, | ||
storefrontTitle: configStorefront.title, | ||
storefrontTitle: config.storefront.title, | ||
}).toString(), | ||
); | ||
|
||
|
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 itemsuserProvidedEnvironmentTag
oruserChosenEnvironmentTag
is defined.