From 510e83aaab51942ff12b50bce0aec0dbda3cadca Mon Sep 17 00:00:00 2001 From: Donald Merand Date: Fri, 27 Mar 2026 12:10:45 -0400 Subject: [PATCH 1/2] Add shopify store execute / auth --- .changeset/store-auth-execute.md | 9 + packages/cli/README.md | 309 +- packages/cli/oclif.manifest.json | 11197 ++++++++-------- packages/cli/package.json | 3 + .../cli/src/cli/commands/store/auth.test.ts | 27 + packages/cli/src/cli/commands/store/auth.ts | 42 + .../src/cli/commands/store/execute.test.ts | 47 + .../cli/src/cli/commands/store/execute.ts | 89 + .../store/admin-graphql-context.test.ts | 161 + .../services/store/admin-graphql-context.ts | 168 + .../store/admin-graphql-transport.test.ts | 80 + .../services/store/admin-graphql-transport.ts | 53 + .../cli/src/cli/services/store/auth-config.ts | 16 + .../cli/src/cli/services/store/auth.test.ts | 407 + packages/cli/src/cli/services/store/auth.ts | 429 + .../services/store/execute-request.test.ts | 127 + .../src/cli/services/store/execute-request.ts | 152 + .../cli/services/store/execute-result.test.ts | 34 + .../src/cli/services/store/execute-result.ts | 18 + .../src/cli/services/store/execute.test.ts | 218 + .../cli/src/cli/services/store/execute.ts | 45 + .../services/store/graphql-targets.test.ts | 45 + .../src/cli/services/store/graphql-targets.ts | 50 + .../src/cli/services/store/session.test.ts | 117 + .../cli/src/cli/services/store/session.ts | 107 + packages/cli/src/index.ts | 4 + 26 files changed, 8159 insertions(+), 5795 deletions(-) create mode 100644 .changeset/store-auth-execute.md create mode 100644 packages/cli/src/cli/commands/store/auth.test.ts create mode 100644 packages/cli/src/cli/commands/store/auth.ts create mode 100644 packages/cli/src/cli/commands/store/execute.test.ts create mode 100644 packages/cli/src/cli/commands/store/execute.ts create mode 100644 packages/cli/src/cli/services/store/admin-graphql-context.test.ts create mode 100644 packages/cli/src/cli/services/store/admin-graphql-context.ts create mode 100644 packages/cli/src/cli/services/store/admin-graphql-transport.test.ts create mode 100644 packages/cli/src/cli/services/store/admin-graphql-transport.ts create mode 100644 packages/cli/src/cli/services/store/auth-config.ts create mode 100644 packages/cli/src/cli/services/store/auth.test.ts create mode 100644 packages/cli/src/cli/services/store/auth.ts create mode 100644 packages/cli/src/cli/services/store/execute-request.test.ts create mode 100644 packages/cli/src/cli/services/store/execute-request.ts create mode 100644 packages/cli/src/cli/services/store/execute-result.test.ts create mode 100644 packages/cli/src/cli/services/store/execute-result.ts create mode 100644 packages/cli/src/cli/services/store/execute.test.ts create mode 100644 packages/cli/src/cli/services/store/execute.ts create mode 100644 packages/cli/src/cli/services/store/graphql-targets.test.ts create mode 100644 packages/cli/src/cli/services/store/graphql-targets.ts create mode 100644 packages/cli/src/cli/services/store/session.test.ts create mode 100644 packages/cli/src/cli/services/store/session.ts diff --git a/.changeset/store-auth-execute.md b/.changeset/store-auth-execute.md new file mode 100644 index 00000000000..1637dbdc087 --- /dev/null +++ b/.changeset/store-auth-execute.md @@ -0,0 +1,9 @@ +--- +'@shopify/cli': minor +--- + +Add `shopify store auth` and `shopify store execute` + +`shopify store auth` authenticates an app against a store using PKCE and stores online per-user auth for later store commands. + +`shopify store execute` runs Admin API GraphQL against that stored auth, supports query and variables input similar to `shopify app execute`, and requires `--allow-mutations` for write operations. diff --git a/packages/cli/README.md b/packages/cli/README.md index d9c40dc4885..9ebf7a1e271 100644 --- a/packages/cli/README.md +++ b/packages/cli/README.md @@ -73,6 +73,8 @@ * [`shopify plugins unlink [PLUGIN]`](#shopify-plugins-unlink-plugin) * [`shopify plugins update`](#shopify-plugins-update) * [`shopify search [query]`](#shopify-search-query) +* [`shopify store auth`](#shopify-store-auth) +* [`shopify store execute`](#shopify-store-execute) * [`shopify theme check`](#shopify-theme-check) * [`shopify theme console`](#shopify-theme-console) * [`shopify theme delete`](#shopify-theme-delete) @@ -101,8 +103,8 @@ Build the app, including extensions. ``` USAGE - $ shopify app build [--client-id | -c ] [--no-color] [--path ] [--reset | ] - [--skip-dependencies-installation] [--verbose] + $ shopify app build [--no-color] [--verbose] [--path ] [--client-id | -c ] [--reset | ] + [--skip-dependencies-installation] FLAGS -c, --config= [env: SHOPIFY_FLAG_APP_CONFIG] The name of the app configuration. @@ -132,8 +134,8 @@ Cancel a bulk operation. ``` USAGE - $ shopify app bulk cancel --id [--client-id | -c ] [--no-color] [--path ] [--reset | - ] [-s ] [--verbose] + $ shopify app bulk cancel --id [--no-color] [--verbose] [--path ] [--client-id | -c ] + [--reset | ] [-s ] FLAGS -c, --config= [env: SHOPIFY_FLAG_APP_CONFIG] The name of the app configuration. @@ -157,9 +159,9 @@ Execute bulk operations. ``` USAGE - $ shopify app bulk execute [--client-id | -c ] [--no-color] [--output-file --watch] [--path - ] [-q ] [--query-file ] [--reset | ] [-s ] [--variable-file | -v ...] - [--verbose] [--version ] + $ shopify app bulk execute [--no-color] [--verbose] [--path ] [--client-id | -c ] [--reset | ] + [-q ] [--query-file ] [-v ... | --variable-file ] [-s ] [--output-file + --watch] [--version ] FLAGS -c, --config= [env: SHOPIFY_FLAG_APP_CONFIG] The name of the app configuration. @@ -203,8 +205,8 @@ Check the status of bulk operations. ``` USAGE - $ shopify app bulk status [--client-id | -c ] [--id ] [--no-color] [--path ] [--reset - | ] [-s ] [--verbose] + $ shopify app bulk status [--no-color] [--verbose] [--path ] [--client-id | -c ] [--reset | ] + [--id ] [-s ] FLAGS -c, --config= [env: SHOPIFY_FLAG_APP_CONFIG] The name of the app configuration. @@ -236,7 +238,7 @@ Fetch your app configuration from the Developer Dashboard. ``` USAGE - $ shopify app config link [--client-id | -c ] [--no-color] [--path ] [--reset | ] [--verbose] + $ shopify app config link [--no-color] [--verbose] [--path ] [--client-id | -c ] [--reset | ] FLAGS -c, --config= [env: SHOPIFY_FLAG_APP_CONFIG] The name of the app configuration. @@ -262,7 +264,7 @@ Refresh an already-linked app configuration without prompts. ``` USAGE - $ shopify app config pull [--client-id | -c ] [--no-color] [--path ] [--reset | ] [--verbose] + $ shopify app config pull [--no-color] [--verbose] [--path ] [--client-id | -c ] [--reset | ] FLAGS -c, --config= [env: SHOPIFY_FLAG_APP_CONFIG] The name of the app configuration. @@ -312,8 +314,8 @@ Validate your app configuration and extensions. ``` USAGE - $ shopify app config validate [--client-id | -c ] [-j] [--no-color] [--path ] [--reset | ] - [--verbose] + $ shopify app config validate [--no-color] [--verbose] [--path ] [--client-id | -c ] [--reset | ] + [-j] FLAGS -c, --config= [env: SHOPIFY_FLAG_APP_CONFIG] The name of the app configuration. @@ -337,9 +339,9 @@ Deploy your Shopify app. ``` USAGE - $ shopify app deploy [--client-id | -c ] [-f] [--message ] [--no-build] [--no-color] - [--no-release | --allow-updates | --allow-deletes] [--path ] [--reset | ] [--source-control-url ] - [--verbose] [--version ] + $ shopify app deploy [--no-color] [--verbose] [--path ] [--client-id | -c ] [--reset | ] + [-f] [--no-release | --allow-updates | --allow-deletes] [--no-build] [--message ] [--version ] + [--source-control-url ] FLAGS -c, --config= [env: SHOPIFY_FLAG_APP_CONFIG] The name of the app configuration. @@ -388,10 +390,10 @@ Run the app. ``` USAGE - $ shopify app dev [--checkout-cart-url ] [--client-id | -c ] [--localhost-port - ] [--no-color] [--no-update] [--notify ] [--path ] [--reset | ] - [--skip-dependencies-installation] [-s ] [--subscription-product-url ] [-t ] - [--theme-app-extension-port ] [--use-localhost | [--tunnel-url | ]] [--verbose] + $ shopify app dev [--no-color] [--verbose] [--path ] [--client-id | -c ] [--reset | ] + [-s ] [--skip-dependencies-installation] [--no-update] [--subscription-product-url ] + [--checkout-cart-url ] [--use-localhost | [--tunnel-url | ]] [--localhost-port ] [-t ] + [--theme-app-extension-port ] [--notify ] FLAGS -c, --config= [env: SHOPIFY_FLAG_APP_CONFIG] The name of the app configuration. @@ -437,8 +439,8 @@ Cleans up the dev preview from the selected store. ``` USAGE - $ shopify app dev clean [--client-id | -c ] [--no-color] [--path ] [--reset | ] [-s - ] [--verbose] + $ shopify app dev clean [--no-color] [--verbose] [--path ] [--client-id | -c ] [--reset | ] + [-s ] FLAGS -c, --config= [env: SHOPIFY_FLAG_APP_CONFIG] The name of the app configuration. @@ -463,8 +465,8 @@ Pull app and extensions environment variables. ``` USAGE - $ shopify app env pull [--client-id | -c ] [--env-file ] [--no-color] [--path ] - [--reset | ] [--verbose] + $ shopify app env pull [--no-color] [--verbose] [--path ] [--client-id | -c ] [--reset | ] + [--env-file ] FLAGS -c, --config= [env: SHOPIFY_FLAG_APP_CONFIG] The name of the app configuration. @@ -490,7 +492,7 @@ Display app and extensions environment variables. ``` USAGE - $ shopify app env show [--client-id | -c ] [--no-color] [--path ] [--reset | ] [--verbose] + $ shopify app env show [--no-color] [--verbose] [--path ] [--client-id | -c ] [--reset | ] FLAGS -c, --config= [env: SHOPIFY_FLAG_APP_CONFIG] The name of the app configuration. @@ -512,9 +514,9 @@ Execute GraphQL queries and mutations. ``` USAGE - $ shopify app execute [--client-id | -c ] [--no-color] [--output-file ] [--path ] - [-q ] [--query-file ] [--reset | ] [-s ] [--variable-file | -v ] [--verbose] - [--version ] + $ shopify app execute [--no-color] [--verbose] [--path ] [--client-id | -c ] [--reset | ] + [-q ] [--query-file ] [-v | --variable-file ] [-s ] [--version ] + [--output-file ] FLAGS -c, --config= [env: SHOPIFY_FLAG_APP_CONFIG] The name of the app configuration. @@ -553,7 +555,7 @@ Compile a function to wasm. ``` USAGE - $ shopify app function build [--client-id | -c ] [--no-color] [--path ] [--reset | ] [--verbose] + $ shopify app function build [--no-color] [--verbose] [--path ] [--client-id | -c ] [--reset | ] FLAGS -c, --config= [env: SHOPIFY_FLAG_APP_CONFIG] The name of the app configuration. @@ -575,8 +577,8 @@ Print basic information about your function. ``` USAGE - $ shopify app function info [--client-id | -c ] [-j] [--no-color] [--path ] [--reset | ] - [--verbose] + $ shopify app function info [--no-color] [--verbose] [--path ] [--client-id | -c ] [--reset | ] + [-j] FLAGS -c, --config= [env: SHOPIFY_FLAG_APP_CONFIG] The name of the app configuration. @@ -607,8 +609,8 @@ Replays a function run from an app log. ``` USAGE - $ shopify app function replay [--client-id | -c ] [-j] [-l ] [--no-color] [--path ] - [--reset | ] [--verbose] [-w] + $ shopify app function replay [--no-color] [--verbose] [--path ] [--client-id | -c ] [--reset | ] + [-j] [-l ] [-w] FLAGS -c, --config= [env: SHOPIFY_FLAG_APP_CONFIG] The name of the app configuration. @@ -637,8 +639,8 @@ Run a function locally for testing. ``` USAGE - $ shopify app function run [--client-id | -c ] [-e ] [-i ] [-j] [--no-color] [--path - ] [--reset | ] [--verbose] + $ shopify app function run [--no-color] [--verbose] [--path ] [--client-id | -c ] [--reset | ] + [-j] [-i ] [-e ] FLAGS -c, --config= [env: SHOPIFY_FLAG_APP_CONFIG] The name of the app configuration. @@ -666,8 +668,8 @@ Fetch the latest GraphQL schema for a function. ``` USAGE - $ shopify app function schema [--client-id | -c ] [--no-color] [--path ] [--reset | ] [--stdout] - [--verbose] + $ shopify app function schema [--no-color] [--verbose] [--path ] [--client-id | -c ] [--reset | ] + [--stdout] FLAGS -c, --config= [env: SHOPIFY_FLAG_APP_CONFIG] The name of the app configuration. @@ -694,8 +696,8 @@ Generate GraphQL types for a function. ``` USAGE - $ shopify app function typegen [--client-id | -c ] [--no-color] [--path ] [--reset | ] - [--verbose] + $ shopify app function typegen [--no-color] [--verbose] [--path ] [--client-id | -c ] [--reset | + ] FLAGS -c, --config= [env: SHOPIFY_FLAG_APP_CONFIG] The name of the app configuration. @@ -718,9 +720,8 @@ Generate a new app Extension. ``` USAGE - $ shopify app generate extension [--client-id | -c ] [--flavor - vanilla-js|react|typescript|typescript-react|wasm|rust] [-n ] [--no-color] [--path ] [--reset | ] [-t - ] [-t ] [--verbose] + $ shopify app generate extension [--no-color] [--verbose] [--path ] [--client-id | -c ] [--reset | ] + [-t ] [-t ] [-n ] [--flavor vanilla-js|react|typescript|typescript-react|wasm|rust] FLAGS -c, --config= [env: SHOPIFY_FLAG_APP_CONFIG] The name of the app configuration. @@ -753,8 +754,8 @@ Import metafield and metaobject definitions. ``` USAGE - $ shopify app import-custom-data-definitions [--client-id | -c ] [--include-existing] [--no-color] [--path ] - [--reset | ] [-s ] [--verbose] + $ shopify app import-custom-data-definitions [--no-color] [--verbose] [--path ] [--client-id | -c ] [--reset | ] + [-s ] [--include-existing] FLAGS -c, --config= [env: SHOPIFY_FLAG_APP_CONFIG] The name of the app configuration. @@ -780,8 +781,8 @@ Import dashboard-managed extensions into your app. ``` USAGE - $ shopify app import-extensions [--client-id | -c ] [--no-color] [--path ] [--reset | ] - [--verbose] + $ shopify app import-extensions [--no-color] [--verbose] [--path ] [--client-id | -c ] [--reset + | ] FLAGS -c, --config= [env: SHOPIFY_FLAG_APP_CONFIG] The name of the app configuration. @@ -801,8 +802,8 @@ Print basic information about your app and extensions. ``` USAGE - $ shopify app info [--client-id | -c ] [-j] [--no-color] [--path ] [--reset | ] - [--verbose] [--web-env] + $ shopify app info [--no-color] [--verbose] [--path ] [--client-id | -c ] [--reset | ] + [-j] [--web-env] FLAGS -c, --config= [env: SHOPIFY_FLAG_APP_CONFIG] The name of the app configuration. @@ -834,15 +835,16 @@ Create a new app project ``` USAGE - $ shopify app init [--flavor ] [-n ] [--no-color] [--organization-id | [--client-id - | ]] [-d npm|yarn|pnpm|bun] [-p ] [--template ] [--verbose] + $ shopify app init [--no-color] [--verbose] [-n ] [-p ] [--template ] [--flavor + ] [-d npm|yarn|pnpm|bun] [--organization-id | [--client-id | ]] FLAGS -d, --package-manager=