Skip to content
Open
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
2 changes: 0 additions & 2 deletions packages/cli/oclif.manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -5741,7 +5741,6 @@
},
"description": "Authenticates the app against the specified store for store commands and stores an online access token for later reuse.\n\nRe-run this command if the stored token is missing, expires, or no longer has the scopes you need.",
"descriptionWithMarkdown": "Authenticates the app against the specified store for store commands and stores an online access token for later reuse.\n\nRe-run this command if the stored token is missing, expires, or no longer has the scopes you need.",
"enableJsonFlag": false,
"examples": [
"<%= config.bin %> <%= command.id %> --store shop.myshopify.com --scopes read_products,write_products",
"<%= config.bin %> <%= command.id %> --store shop.myshopify.com --scopes read_products,write_products --json"
Expand Down Expand Up @@ -5809,7 +5808,6 @@
},
"description": "Executes an Admin API GraphQL query or mutation on the specified store using previously stored app authentication.\n\nRun `shopify store auth` first to create stored auth for the store.\n\nMutations are disabled by default. Re-run with `--allow-mutations` if you intend to modify store data.",
"descriptionWithMarkdown": "Executes an Admin API GraphQL query or mutation on the specified store using previously stored app authentication.\n\nRun `shopify store auth` first to create stored auth for the store.\n\nMutations are disabled by default. Re-run with `--allow-mutations` if you intend to modify store data.",
"enableJsonFlag": false,
"examples": [
"<%= config.bin %> <%= command.id %> --store shop.myshopify.com --query \"query { shop { name } }\"",
"<%= config.bin %> <%= command.id %> --store shop.myshopify.com --query-file ./operation.graphql --variables '{\"id\":\"gid://shopify/Product/1\"}'",
Expand Down
6 changes: 3 additions & 3 deletions packages/cli/src/cli/commands/store/auth.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import {authenticateStoreWithApp} from '../../services/store/auth/index.js'
import {createStoreAuthPresenter} from '../../services/store/auth/result.js'
import Command from '@shopify/cli-kit/node/base-command'
import StoreCommand from '../../utilities/store-command.js'
import {globalFlags, jsonFlag} from '@shopify/cli-kit/node/cli'
import {normalizeStoreFqdn} from '@shopify/cli-kit/node/context/fqdn'
import {Flags} from '@oclif/core'

export default class StoreAuth extends Command {
export default class StoreAuth extends StoreCommand {
static summary = 'Authenticate an app against a store for store commands.'

static descriptionWithMarkdown = `Authenticates the app against the specified store for store commands and stores an online access token for later reuse.
Expand Down Expand Up @@ -36,7 +36,7 @@ Re-run this command if the stored token is missing, expires, or no longer has th
}),
}

async run(): Promise<void> {
public async run(): Promise<void> {
const {flags} = await this.parse(StoreAuth)

await authenticateStoreWithApp(
Expand Down
6 changes: 3 additions & 3 deletions packages/cli/src/cli/commands/store/execute.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import {executeStoreOperation} from '../../services/store/execute/index.js'
import {writeOrOutputStoreExecuteResult} from '../../services/store/execute/result.js'
import Command from '@shopify/cli-kit/node/base-command'
import StoreCommand from '../../utilities/store-command.js'
import {globalFlags, jsonFlag} from '@shopify/cli-kit/node/cli'
import {normalizeStoreFqdn} from '@shopify/cli-kit/node/context/fqdn'
import {resolvePath} from '@shopify/cli-kit/node/path'
import {Flags} from '@oclif/core'

export default class StoreExecute extends Command {
export default class StoreExecute extends StoreCommand {
static summary = 'Execute GraphQL queries and mutations on a store.'

static descriptionWithMarkdown = `Executes an Admin API GraphQL query or mutation on the specified store using previously stored app authentication.
Expand Down Expand Up @@ -75,7 +75,7 @@ Mutations are disabled by default. Re-run with \`--allow-mutations\` if you inte
}),
}

async run(): Promise<void> {
public async run(): Promise<void> {
const {flags} = await this.parse(StoreExecute)

const result = await executeStoreOperation({
Expand Down
27 changes: 27 additions & 0 deletions packages/cli/src/cli/utilities/store-command.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import Command, {type ArgOutput, type FlagOutput} from '@shopify/cli-kit/node/base-command'
import {addSensitiveMetadata} from '@shopify/cli-kit/node/metadata'

import type {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>

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 storeFqdn = (result.flags as {store?: unknown}).store
if (typeof storeFqdn === 'string' && storeFqdn.length > 0) {
await addSensitiveMetadata(() => ({store_fqdn: storeFqdn}))
}
return result
}
}
Loading