Skip to content

Commit 2214497

Browse files
Document non-interactive store command flags
1 parent 77aa551 commit 2214497

7 files changed

Lines changed: 56 additions & 28 deletions

File tree

docs-shopify.dev/generated/generated_docs_data_v2.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5344,7 +5344,7 @@
53445344
"syntaxKind": "PropertySignature",
53455345
"name": "--organization-id <value>",
53465346
"value": "string",
5347-
"description": "The numeric organization ID. Auto-selects if you belong to a single organization.",
5347+
"description": "The numeric organization ID. Auto-selects if you belong to a single organization. Required if non interactive when more than one organization is available.",
53485348
"isOptional": true,
53495349
"environmentValue": "SHOPIFY_FLAG_ORGANIZATION_ID"
53505350
},
@@ -5367,7 +5367,7 @@
53675367
"environmentValue": "SHOPIFY_FLAG_JSON"
53685368
}
53695369
],
5370-
"value": "export interface storelist {\n /**\n * Output the result as JSON. Automatically disables color output.\n * @environment SHOPIFY_FLAG_JSON\n */\n '-j, --json'?: ''\n\n /**\n * Disable color output.\n * @environment SHOPIFY_FLAG_NO_COLOR\n */\n '--no-color'?: ''\n\n /**\n * The numeric organization ID. Auto-selects if you belong to a single organization.\n * @environment SHOPIFY_FLAG_ORGANIZATION_ID\n */\n '--organization-id <value>'?: string\n\n /**\n * Increase the verbosity of the output. May include sensitive data.\n * @environment SHOPIFY_FLAG_VERBOSE\n */\n '--verbose'?: ''\n}"
5370+
"value": "export interface storelist {\n /**\n * Output the result as JSON. Automatically disables color output.\n * @environment SHOPIFY_FLAG_JSON\n */\n '-j, --json'?: ''\n\n /**\n * Disable color output.\n * @environment SHOPIFY_FLAG_NO_COLOR\n */\n '--no-color'?: ''\n\n /**\n * The numeric organization ID. Auto-selects if you belong to a single organization. Required if non interactive when more than one organization is available.\n * @environment SHOPIFY_FLAG_ORGANIZATION_ID\n */\n '--organization-id <value>'?: string\n\n /**\n * Increase the verbosity of the output. May include sensitive data.\n * @environment SHOPIFY_FLAG_VERBOSE\n */\n '--verbose'?: ''\n}"
53715371
}
53725372
},
53735373
"storeopen": {

packages/cli/README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3879,7 +3879,8 @@ FLAGS
38793879
[env: SHOPIFY_FLAG_NO_COLOR]
38803880
38813881
--organization-id=<value>
3882-
The numeric organization ID. Auto-selects if you belong to a single organization.
3882+
The numeric organization ID. Auto-selects if you belong to a single organization. Required if non interactive when
3883+
more than one organization is available.
38833884
[env: SHOPIFY_FLAG_ORGANIZATION_ID]
38843885
38853886
--verbose
@@ -3892,8 +3893,7 @@ DESCRIPTION
38923893
Lists stores in a Shopify organization available to the current CLI account.
38933894
38943895
When more than one organization is available, the command prompts you to pick one unless you provide
3895-
`--organization-id`.
3896-
In non-interactive environments, `--organization-id` is required.
3896+
`--organization-id`. In that case, `--organization-id` is required in non-interactive environments.
38973897
38983898
Run `shopify organization list` to find organization IDs.
38993899

packages/cli/oclif.manifest.json

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6710,7 +6710,7 @@
67106710
"type": "boolean"
67116711
},
67126712
"name": {
6713-
"description": "Name for the new development store.",
6713+
"description": "Name for the new development store. Required if non interactive.",
67146714
"env": "SHOPIFY_FLAG_STORE_NAME",
67156715
"hasDynamicHelp": false,
67166716
"multiple": false,
@@ -6726,15 +6726,15 @@
67266726
"type": "boolean"
67276727
},
67286728
"organization-id": {
6729-
"description": "The numeric organization ID. Auto-selects if you belong to a single organization.",
6729+
"description": "The numeric organization ID. Auto-selects if you belong to a single organization. Required if non interactive.",
67306730
"env": "SHOPIFY_FLAG_ORGANIZATION_ID",
67316731
"hasDynamicHelp": false,
67326732
"multiple": false,
67336733
"name": "organization-id",
67346734
"type": "option"
67356735
},
67366736
"plan": {
6737-
"description": "The Shopify plan to use for the new development store.",
6737+
"description": "The Shopify plan to use for the new development store. Required if non interactive.",
67386738
"env": "SHOPIFY_FLAG_STORE_PLAN",
67396739
"hasDynamicHelp": false,
67406740
"multiple": false,
@@ -6860,7 +6860,7 @@
68606860
"force": {
68616861
"allowNo": false,
68626862
"char": "f",
6863-
"description": "Skip confirmation.",
6863+
"description": "Skip confirmation. Required if non interactive.",
68646864
"env": "SHOPIFY_FLAG_FORCE",
68656865
"name": "force",
68666866
"type": "boolean"
@@ -7193,8 +7193,8 @@
71937193
"args": {
71947194
},
71957195
"customPluginName": "@shopify/store",
7196-
"description": "Lists stores in a Shopify organization available to the current CLI account.\n\nWhen more than one organization is available, the command prompts you to pick one unless you provide `--organization-id`.\nIn non-interactive environments, `--organization-id` is required.\n\nRun `<%= config.bin %> organization list` to find organization IDs.",
7197-
"descriptionWithMarkdown": "Lists stores in a Shopify organization available to the current CLI account.\n\nWhen more than one organization is available, the command prompts you to pick one unless you provide `--organization-id`.\nIn non-interactive environments, `--organization-id` is required.\n\nRun `<%= config.bin %> organization list` to find organization IDs.",
7196+
"description": "Lists stores in a Shopify organization available to the current CLI account.\n\nWhen more than one organization is available, the command prompts you to pick one unless you provide `--organization-id`. In that case, `--organization-id` is required in non-interactive environments.\n\nRun `<%= config.bin %> organization list` to find organization IDs.",
7197+
"descriptionWithMarkdown": "Lists stores in a Shopify organization available to the current CLI account.\n\nWhen more than one organization is available, the command prompts you to pick one unless you provide `--organization-id`. In that case, `--organization-id` is required in non-interactive environments.\n\nRun `<%= config.bin %> organization list` to find organization IDs.",
71987198
"examples": [
71997199
"<%= config.bin %> <%= command.id %>",
72007200
"<%= config.bin %> <%= command.id %> --organization-id 1234567",
@@ -7219,7 +7219,7 @@
72197219
"type": "boolean"
72207220
},
72217221
"organization-id": {
7222-
"description": "The numeric organization ID. Auto-selects if you belong to a single organization.",
7222+
"description": "The numeric organization ID. Auto-selects if you belong to a single organization. Required if non interactive when more than one organization is available.",
72237223
"env": "SHOPIFY_FLAG_ORGANIZATION_ID",
72247224
"hasDynamicHelp": false,
72257225
"multiple": false,

packages/store/src/cli/commands/store/create/dev.ts

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import {storeNamePrompt, storePlanPrompt} from '../../../prompts/store.js'
44
import {countryFlag, storeFlags} from '../../../flags.js'
55
import {selectOrg} from '@shopify/organizations'
66
import Command from '@shopify/cli-kit/node/base-command'
7-
import {globalFlags, jsonFlag} from '@shopify/cli-kit/node/cli'
7+
import {globalFlags, jsonFlag, requiredIfNonInteractive} from '@shopify/cli-kit/node/cli'
88
import {AbortError} from '@shopify/cli-kit/node/error'
99
import {outputResult} from '@shopify/cli-kit/node/output'
1010
import {Flags} from '@oclif/core'
@@ -21,16 +21,20 @@ export default class StoreCreateDev extends Command {
2121
static flags = {
2222
...globalFlags,
2323
...jsonFlag,
24-
name: Flags.string({
25-
description: 'Name for the new development store.',
26-
env: 'SHOPIFY_FLAG_STORE_NAME',
27-
}),
28-
'organization-id': storeFlags['organization-id'],
29-
plan: Flags.string({
30-
description: 'The Shopify plan to use for the new development store.',
31-
options: devStorePlanHandles,
32-
env: 'SHOPIFY_FLAG_STORE_PLAN',
33-
}),
24+
name: requiredIfNonInteractive(
25+
Flags.string({
26+
description: 'Name for the new development store.',
27+
env: 'SHOPIFY_FLAG_STORE_NAME',
28+
}),
29+
),
30+
'organization-id': requiredIfNonInteractive(storeFlags['organization-id']),
31+
plan: requiredIfNonInteractive(
32+
Flags.string({
33+
description: 'The Shopify plan to use for the new development store.',
34+
options: devStorePlanHandles,
35+
env: 'SHOPIFY_FLAG_STORE_PLAN',
36+
}),
37+
),
3438
'feature-preview': Flags.string({
3539
description: 'The handle of a feature preview to enable on the new development store.',
3640
env: 'SHOPIFY_FLAG_STORE_FEATURE_PREVIEW',
@@ -45,7 +49,6 @@ export default class StoreCreateDev extends Command {
4549

4650
async run(): Promise<void> {
4751
const {flags} = await this.parse(StoreCreateDev)
48-
this.failMissingNonTTYFlags(flags, ['name', 'organization-id', 'plan'])
4952

5053
const organization = await selectOrg(flags['organization-id']?.toString())
5154
const name = flags.name ?? (await storeNamePrompt())

packages/store/src/cli/commands/store/delete.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ export default class StoreDelete extends Command {
3030
'organization-id': storeFlags['organization-id'],
3131
force: Flags.boolean({
3232
char: 'f',
33-
description: 'Skip confirmation.',
33+
description: 'Skip confirmation. Required if non interactive.',
3434
env: 'SHOPIFY_FLAG_FORCE',
3535
default: false,
3636
}),

packages/store/src/cli/commands/store/list.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,14 @@ import {writeStoreListResult} from '../../services/store/list/result.js'
33
import {storeFlags} from '../../flags.js'
44
import StoreCommand from '../../utilities/store-command.js'
55
import {globalFlags, jsonFlag} from '@shopify/cli-kit/node/cli'
6+
import {Flags} from '@oclif/core'
67

78
export default class StoreList extends StoreCommand {
89
static summary = 'List stores in a Shopify organization.'
910

1011
static descriptionWithMarkdown = `Lists stores in a Shopify organization available to the current CLI account.
1112
12-
When more than one organization is available, the command prompts you to pick one unless you provide \`--organization-id\`.
13-
In non-interactive environments, \`--organization-id\` is required.
13+
When more than one organization is available, the command prompts you to pick one unless you provide \`--organization-id\`. In that case, \`--organization-id\` is required in non-interactive environments.
1414
1515
Run \`<%= config.bin %> organization list\` to find organization IDs.`
1616

@@ -25,7 +25,10 @@ Run \`<%= config.bin %> organization list\` to find organization IDs.`
2525
static flags = {
2626
...globalFlags,
2727
...jsonFlag,
28-
'organization-id': storeFlags['organization-id'],
28+
'organization-id': Flags.integer({
29+
description: `${storeFlags['organization-id'].description} Required if non interactive when more than one organization is available.`,
30+
env: 'SHOPIFY_FLAG_ORGANIZATION_ID',
31+
}),
2932
}
3033

3134
public async run(): Promise<void> {
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
import StoreCreateDev from './create/dev.js'
2+
import StoreDelete from './delete.js'
3+
import StoreList from './list.js'
4+
import {describe, expect, test} from 'vitest'
5+
6+
describe('non-interactive store command flags', () => {
7+
test.each([
8+
{command: StoreCreateDev, flag: 'name'},
9+
{command: StoreCreateDev, flag: 'organization-id'},
10+
{command: StoreCreateDev, flag: 'plan'},
11+
{command: StoreDelete, flag: 'force'},
12+
])('$command.name documents --$flag as required', ({command, flag}) => {
13+
const flags = command.flags as Record<string, {description?: string}>
14+
expect(flags[flag]!.description).toMatch(/Required if non interactive\.$/)
15+
})
16+
17+
test('store list documents its runtime-dependent organization requirement', () => {
18+
expect(StoreList.flags['organization-id'].description).toMatch(
19+
/Required if non interactive when more than one organization is available\.$/,
20+
)
21+
})
22+
})

0 commit comments

Comments
 (0)