Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/store-flag-id-gid.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@shopify/store': minor
---

`shopify store` commands now accept a numeric store ID or a Shop GID (`gid://shopify/Shop/<id>`) for `--store`, in addition to the myshopify.com domain. IDs and GIDs are resolved to the store's domain via the Business Platform. The `--store` value now also trims surrounding whitespace.
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export interface storeauth {
'--scopes <value>': string

/**
* The myshopify.com domain of the store.
* The store to operate on: its myshopify.com domain, numeric store ID, or Shop GID (gid://shopify/Shop/<id>).
* @environment SHOPIFY_FLAG_STORE
*/
'-s, --store <value>': string
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ export interface storeexecute {
'--query-file <value>'?: string

/**
* The myshopify.com domain of the store.
* The store to operate on: its myshopify.com domain, numeric store ID, or Shop GID (gid://shopify/Shop/<id>).
* @environment SHOPIFY_FLAG_STORE
*/
'-s, --store <value>': string
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ export interface storeinfo {
'--no-color'?: ''

/**
* The myshopify.com domain of the store.
* The store to operate on: its myshopify.com domain, numeric store ID, or Shop GID (gid://shopify/Shop/<id>).
* @environment SHOPIFY_FLAG_STORE
*/
'-s, --store <value>': string
Expand Down
12 changes: 6 additions & 6 deletions docs-shopify.dev/generated/generated_docs_data_v2.json
Original file line number Diff line number Diff line change
Expand Up @@ -4177,11 +4177,11 @@
"syntaxKind": "PropertySignature",
"name": "-s, --store <value>",
"value": "string",
"description": "The myshopify.com domain of the store.",
"description": "The store to operate on: its myshopify.com domain, numeric store ID, or Shop GID (gid://shopify/Shop/<id>).",
"environmentValue": "SHOPIFY_FLAG_STORE"
}
],
"value": "export interface storeauth {\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 * Comma-separated Admin API scopes to request for the app.\n * @environment SHOPIFY_FLAG_SCOPES\n */\n '--scopes <value>': string\n\n /**\n * The myshopify.com domain of the store.\n * @environment SHOPIFY_FLAG_STORE\n */\n '-s, --store <value>': string\n\n /**\n * Increase the verbosity of the output.\n * @environment SHOPIFY_FLAG_VERBOSE\n */\n '--verbose'?: ''\n}"
"value": "export interface storeauth {\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 * Comma-separated Admin API scopes to request for the app.\n * @environment SHOPIFY_FLAG_SCOPES\n */\n '--scopes <value>': string\n\n /**\n * The store to operate on: its myshopify.com domain, numeric store ID, or Shop GID (gid://shopify/Shop/<id>).\n * @environment SHOPIFY_FLAG_STORE\n */\n '-s, --store <value>': string\n\n /**\n * Increase the verbosity of the output.\n * @environment SHOPIFY_FLAG_VERBOSE\n */\n '--verbose'?: ''\n}"
}
},
"storeexecute": {
Expand Down Expand Up @@ -4277,7 +4277,7 @@
"syntaxKind": "PropertySignature",
"name": "-s, --store <value>",
"value": "string",
"description": "The myshopify.com domain of the store.",
"description": "The store to operate on: its myshopify.com domain, numeric store ID, or Shop GID (gid://shopify/Shop/<id>).",
"environmentValue": "SHOPIFY_FLAG_STORE"
},
{
Expand All @@ -4290,7 +4290,7 @@
"environmentValue": "SHOPIFY_FLAG_VARIABLES"
}
],
"value": "export interface storeexecute {\n /**\n * Allow GraphQL mutations to run against the target store.\n * @environment SHOPIFY_FLAG_ALLOW_MUTATIONS\n */\n '--allow-mutations'?: ''\n\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 file name where results should be written, instead of STDOUT.\n * @environment SHOPIFY_FLAG_OUTPUT_FILE\n */\n '--output-file <value>'?: string\n\n /**\n * The GraphQL query or mutation, as a string.\n * @environment SHOPIFY_FLAG_QUERY\n */\n '-q, --query <value>'?: string\n\n /**\n * Path to a file containing the GraphQL query or mutation. Can't be used with --query.\n * @environment SHOPIFY_FLAG_QUERY_FILE\n */\n '--query-file <value>'?: string\n\n /**\n * The myshopify.com domain of the store.\n * @environment SHOPIFY_FLAG_STORE\n */\n '-s, --store <value>': string\n\n /**\n * Path to a file containing GraphQL variables in JSON format. Can't be used with --variables.\n * @environment SHOPIFY_FLAG_VARIABLE_FILE\n */\n '--variable-file <value>'?: string\n\n /**\n * The values for any GraphQL variables in your query or mutation, in JSON format.\n * @environment SHOPIFY_FLAG_VARIABLES\n */\n '-v, --variables <value>'?: string\n\n /**\n * Increase the verbosity of the output.\n * @environment SHOPIFY_FLAG_VERBOSE\n */\n '--verbose'?: ''\n\n /**\n * The API version to use for the query or mutation. Defaults to the latest stable version.\n * @environment SHOPIFY_FLAG_VERSION\n */\n '--version <value>'?: string\n}"
"value": "export interface storeexecute {\n /**\n * Allow GraphQL mutations to run against the target store.\n * @environment SHOPIFY_FLAG_ALLOW_MUTATIONS\n */\n '--allow-mutations'?: ''\n\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 file name where results should be written, instead of STDOUT.\n * @environment SHOPIFY_FLAG_OUTPUT_FILE\n */\n '--output-file <value>'?: string\n\n /**\n * The GraphQL query or mutation, as a string.\n * @environment SHOPIFY_FLAG_QUERY\n */\n '-q, --query <value>'?: string\n\n /**\n * Path to a file containing the GraphQL query or mutation. Can't be used with --query.\n * @environment SHOPIFY_FLAG_QUERY_FILE\n */\n '--query-file <value>'?: string\n\n /**\n * The store to operate on: its myshopify.com domain, numeric store ID, or Shop GID (gid://shopify/Shop/<id>).\n * @environment SHOPIFY_FLAG_STORE\n */\n '-s, --store <value>': string\n\n /**\n * Path to a file containing GraphQL variables in JSON format. Can't be used with --variables.\n * @environment SHOPIFY_FLAG_VARIABLE_FILE\n */\n '--variable-file <value>'?: string\n\n /**\n * The values for any GraphQL variables in your query or mutation, in JSON format.\n * @environment SHOPIFY_FLAG_VARIABLES\n */\n '-v, --variables <value>'?: string\n\n /**\n * Increase the verbosity of the output.\n * @environment SHOPIFY_FLAG_VERBOSE\n */\n '--verbose'?: ''\n\n /**\n * The API version to use for the query or mutation. Defaults to the latest stable version.\n * @environment SHOPIFY_FLAG_VERSION\n */\n '--version <value>'?: string\n}"
}
},
"storeinfo": {
Expand Down Expand Up @@ -4332,11 +4332,11 @@
"syntaxKind": "PropertySignature",
"name": "-s, --store <value>",
"value": "string",
"description": "The myshopify.com domain of the store.",
"description": "The store to operate on: its myshopify.com domain, numeric store ID, or Shop GID (gid://shopify/Shop/<id>).",
"environmentValue": "SHOPIFY_FLAG_STORE"
}
],
"value": "export interface storeinfo {\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 myshopify.com domain of the store.\n * @environment SHOPIFY_FLAG_STORE\n */\n '-s, --store <value>': string\n\n /**\n * Increase the verbosity of the output.\n * @environment SHOPIFY_FLAG_VERBOSE\n */\n '--verbose'?: ''\n}"
"value": "export interface storeinfo {\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 store to operate on: its myshopify.com domain, numeric store ID, or Shop GID (gid://shopify/Shop/<id>).\n * @environment SHOPIFY_FLAG_STORE\n */\n '-s, --store <value>': string\n\n /**\n * Increase the verbosity of the output.\n * @environment SHOPIFY_FLAG_VERBOSE\n */\n '--verbose'?: ''\n}"
}
},
"themecheck": {
Expand Down
9 changes: 6 additions & 3 deletions packages/cli/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2112,7 +2112,8 @@ USAGE

FLAGS
-j, --json [env: SHOPIFY_FLAG_JSON] Output the result as JSON. Automatically disables color output.
-s, --store=<value> (required) [env: SHOPIFY_FLAG_STORE] The myshopify.com domain of the store.
-s, --store=<value> (required) [env: SHOPIFY_FLAG_STORE] The store to operate on: its myshopify.com domain, numeric
store ID, or Shop GID (gid://shopify/Shop/<id>).
--no-color [env: SHOPIFY_FLAG_NO_COLOR] Disable color output.
--scopes=<value> (required) [env: SHOPIFY_FLAG_SCOPES] Comma-separated Admin API scopes to request for the app.
--verbose [env: SHOPIFY_FLAG_VERBOSE] Increase the verbosity of the output.
Expand Down Expand Up @@ -2143,7 +2144,8 @@ USAGE
FLAGS
-j, --json [env: SHOPIFY_FLAG_JSON] Output the result as JSON. Automatically disables color output.
-q, --query=<value> [env: SHOPIFY_FLAG_QUERY] The GraphQL query or mutation, as a string.
-s, --store=<value> (required) [env: SHOPIFY_FLAG_STORE] The myshopify.com domain of the store.
-s, --store=<value> (required) [env: SHOPIFY_FLAG_STORE] The store to operate on: its myshopify.com domain,
numeric store ID, or Shop GID (gid://shopify/Shop/<id>).
-v, --variables=<value> [env: SHOPIFY_FLAG_VARIABLES] The values for any GraphQL variables in your query or
mutation, in JSON format.
--allow-mutations [env: SHOPIFY_FLAG_ALLOW_MUTATIONS] Allow GraphQL mutations to run against the target
Expand Down Expand Up @@ -2188,7 +2190,8 @@ USAGE

FLAGS
-j, --json [env: SHOPIFY_FLAG_JSON] Output the result as JSON. Automatically disables color output.
-s, --store=<value> (required) [env: SHOPIFY_FLAG_STORE] The myshopify.com domain of the store.
-s, --store=<value> (required) [env: SHOPIFY_FLAG_STORE] The store to operate on: its myshopify.com domain, numeric
store ID, or Shop GID (gid://shopify/Shop/<id>).
--no-color [env: SHOPIFY_FLAG_NO_COLOR] Disable color output.
--verbose [env: SHOPIFY_FLAG_VERBOSE] Increase the verbosity of the output.

Expand Down
6 changes: 3 additions & 3 deletions packages/cli/oclif.manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -5710,7 +5710,7 @@
},
"store": {
"char": "s",
"description": "The myshopify.com domain of the store.",
"description": "The store to operate on: its myshopify.com domain, numeric store ID, or Shop GID (gid://shopify/Shop/<id>).",
"env": "SHOPIFY_FLAG_STORE",
"hasDynamicHelp": false,
"multiple": false,
Expand Down Expand Up @@ -5804,7 +5804,7 @@
},
"store": {
"char": "s",
"description": "The myshopify.com domain of the store.",
"description": "The store to operate on: its myshopify.com domain, numeric store ID, or Shop GID (gid://shopify/Shop/<id>).",
"env": "SHOPIFY_FLAG_STORE",
"hasDynamicHelp": false,
"multiple": false,
Expand Down Expand Up @@ -5894,7 +5894,7 @@
},
"store": {
"char": "s",
"description": "The myshopify.com domain of the store.",
"description": "The store to operate on: its myshopify.com domain, numeric store ID, or Shop GID (gid://shopify/Shop/<id>).",
"env": "SHOPIFY_FLAG_STORE",
"hasDynamicHelp": false,
"multiple": false,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
/* eslint-disable @typescript-eslint/consistent-type-definitions */
import * as Types from './types.js'

import {TypedDocumentNode as DocumentNode} from '@graphql-typed-document-node/core'

export type ResolveStoreByIdQueryVariables = Types.Exact<{
id: Types.Scalars['DestinationPublicID']['input']
}>

export type ResolveStoreByIdQuery = {
currentUserAccount?: {destination?: {webUrl: string; primaryDomain?: string | null} | null} | null
}

export const ResolveStoreById = {
kind: 'Document',
definitions: [
{
kind: 'OperationDefinition',
operation: 'query',
name: {kind: 'Name', value: 'ResolveStoreById'},
variableDefinitions: [
{
kind: 'VariableDefinition',
variable: {kind: 'Variable', name: {kind: 'Name', value: 'id'}},
type: {kind: 'NonNullType', type: {kind: 'NamedType', name: {kind: 'Name', value: 'DestinationPublicID'}}},
},
],
selectionSet: {
kind: 'SelectionSet',
selections: [
{
kind: 'Field',
name: {kind: 'Name', value: 'currentUserAccount'},
selectionSet: {
kind: 'SelectionSet',
selections: [
{
kind: 'Field',
name: {kind: 'Name', value: 'destination'},
arguments: [
{
kind: 'Argument',
name: {kind: 'Name', value: 'id'},
value: {kind: 'Variable', name: {kind: 'Name', value: 'id'}},
},
],
selectionSet: {
kind: 'SelectionSet',
selections: [
{kind: 'Field', name: {kind: 'Name', value: 'webUrl'}},
{kind: 'Field', name: {kind: 'Name', value: 'primaryDomain'}},
{kind: 'Field', name: {kind: 'Name', value: '__typename'}},
],
},
},
{kind: 'Field', name: {kind: 'Name', value: '__typename'}},
],
},
},
],
},
},
],
} as unknown as DocumentNode<ResolveStoreByIdQuery, ResolveStoreByIdQueryVariables>
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
query ResolveStoreById($id: DestinationPublicID!) {
currentUserAccount {
destination(id: $id) {
webUrl
primaryDomain
}
}
}
5 changes: 2 additions & 3 deletions packages/store/src/cli/flags.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
import {normalizeStoreFqdn} from '@shopify/cli-kit/node/context/fqdn'
import {Flags} from '@oclif/core'

export const storeFlags = {
store: Flags.string({
char: 's',
description: 'The myshopify.com domain of the store.',
description:
'The store to operate on: its myshopify.com domain, numeric store ID, or Shop GID (gid://shopify/Shop/<id>).',
env: 'SHOPIFY_FLAG_STORE',
parse: async (input) => normalizeStoreFqdn(input),
required: true,
}),
}
24 changes: 23 additions & 1 deletion packages/store/src/cli/utilities/store-command.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,30 @@
import Command from '@shopify/cli-kit/node/base-command'
import {resolveStore} from './store-resolution.js'
import Command, {ArgOutput, FlagOutput} from '@shopify/cli-kit/node/base-command'
import {Input, ParserOutput} from '@oclif/core/parser'

/**
* Base class that includes shared behavior for all store commands.
*/
export default abstract class StoreCommand extends Command {
public abstract run(): Promise<void>

// Resolve `--store` AFTER oclif has parsed and validated every other flag. Doing the
// auth+network resolution here (rather than in the flag's `parse`) means unknown/required/
// exclusive flag errors are reported before we ever reach out to the Business Platform, so
// users don't get surprising auth prompts ahead of a plain flag-validation error.
protected async parse<
TFlags extends FlagOutput & {path?: string; verbose?: boolean},
TGlobalFlags extends FlagOutput,
TArgs extends ArgOutput,
>(
options?: Input<TFlags, TGlobalFlags, TArgs>,
argv?: string[],
): Promise<ParserOutput<TFlags, TGlobalFlags, TArgs> & {argv: string[]}> {
const result = await super.parse<TFlags, TGlobalFlags, TArgs>(options, argv)
const flags = result?.flags as {store?: unknown} | undefined
if (flags && typeof flags.store === 'string') {
flags.store = await resolveStore(flags.store)
}
return result
}
}
Loading
Loading