Skip to content
Merged
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-info-command.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@shopify/cli': minor
---

Add `shopify store info --store <domain>` command to display metadata about a store. Supports `--json` for machine-readable output.
30 changes: 30 additions & 0 deletions docs-shopify.dev/commands/interfaces/store-info.interface.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
// This is an autogenerated file. Don't edit this file manually.
/**
* The following flags are available for the `store info` command:
* @publicDocs
*/
export interface storeinfo {
/**
* Output the result as JSON. Automatically disables color output.
* @environment SHOPIFY_FLAG_JSON
*/
'-j, --json'?: ''

/**
* Disable color output.
* @environment SHOPIFY_FLAG_NO_COLOR
*/
'--no-color'?: ''

/**
* The myshopify.com domain of the store.
* @environment SHOPIFY_FLAG_STORE
*/
'-s, --store <value>': string

/**
* Increase the verbosity of the output.
* @environment SHOPIFY_FLAG_VERBOSE
*/
'--verbose'?: ''
}
46 changes: 46 additions & 0 deletions docs-shopify.dev/generated/generated_docs_data_v2.json
Original file line number Diff line number Diff line change
Expand Up @@ -4293,6 +4293,52 @@
"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}"
}
},
"storeinfo": {
"docs-shopify.dev/commands/interfaces/store-info.interface.ts": {
"filePath": "docs-shopify.dev/commands/interfaces/store-info.interface.ts",
"name": "storeinfo",
"description": "The following flags are available for the `store info` command:",
"isPublicDocs": true,
"members": [
{
"filePath": "docs-shopify.dev/commands/interfaces/store-info.interface.ts",
"syntaxKind": "PropertySignature",
"name": "--no-color",
"value": "''",
"description": "Disable color output.",
"isOptional": true,
"environmentValue": "SHOPIFY_FLAG_NO_COLOR"
},
{
"filePath": "docs-shopify.dev/commands/interfaces/store-info.interface.ts",
"syntaxKind": "PropertySignature",
"name": "--verbose",
"value": "''",
"description": "Increase the verbosity of the output.",
"isOptional": true,
"environmentValue": "SHOPIFY_FLAG_VERBOSE"
},
{
"filePath": "docs-shopify.dev/commands/interfaces/store-info.interface.ts",
"syntaxKind": "PropertySignature",
"name": "-j, --json",
"value": "''",
"description": "Output the result as JSON. Automatically disables color output.",
"isOptional": true,
"environmentValue": "SHOPIFY_FLAG_JSON"
},
{
"filePath": "docs-shopify.dev/commands/interfaces/store-info.interface.ts",
"syntaxKind": "PropertySignature",
"name": "-s, --store <value>",
"value": "string",
"description": "The myshopify.com domain of the store.",
"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}"
}
},
"themecheck": {
"docs-shopify.dev/commands/interfaces/theme-check.interface.ts": {
"filePath": "docs-shopify.dev/commands/interfaces/theme-check.interface.ts",
Expand Down
29 changes: 29 additions & 0 deletions packages/cli/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@
* [`shopify search [query]`](#shopify-search-query)
* [`shopify store auth`](#shopify-store-auth)
* [`shopify store execute`](#shopify-store-execute)
* [`shopify store info`](#shopify-store-info)
* [`shopify theme check`](#shopify-theme-check)
* [`shopify theme console`](#shopify-theme-console)
* [`shopify theme delete`](#shopify-theme-delete)
Expand Down Expand Up @@ -2177,6 +2178,34 @@ EXAMPLES
$ shopify store execute --store shop.myshopify.com --query "query { shop { name } }" --json
```

## `shopify store info`

Surface metadata about a Shopify store.

```
USAGE
$ shopify store info -s <value> [-j] [--no-color] [--verbose]

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.
--no-color [env: SHOPIFY_FLAG_NO_COLOR] Disable color output.
--verbose [env: SHOPIFY_FLAG_VERBOSE] Increase the verbosity of the output.

DESCRIPTION
Surface metadata about a Shopify store.

Returns metadata about a store you have access to: id, display name, subdomain, organization, store owner, type, plan,
feature preview, and admin URL.

Use `--json` for machine-readable output.

EXAMPLES
$ shopify store info --store shop.myshopify.com

$ shopify store info --store shop.myshopify.com --json
```

## `shopify theme check`

Validate the theme.
Expand Down
59 changes: 59 additions & 0 deletions packages/cli/oclif.manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -5862,6 +5862,65 @@
"strict": true,
"summary": "Execute GraphQL queries and mutations on a store."
},
"store:info": {
"aliases": [
],
"args": {
},
"customPluginName": "@shopify/store",
"description": "Returns metadata about a store you have access to: id, display name, subdomain, organization, store owner, type, plan, feature preview, and admin URL.\n\nUse `--json` for machine-readable output.",
"descriptionWithMarkdown": "Returns metadata about a store you have access to: id, display name, subdomain, organization, store owner, type, plan, feature preview, and admin URL.\n\nUse `--json` for machine-readable output.",
"examples": [
"<%= config.bin %> <%= command.id %> --store shop.myshopify.com",
"<%= config.bin %> <%= command.id %> --store shop.myshopify.com --json"
],
"flags": {
"json": {
"allowNo": false,
"char": "j",
"description": "Output the result as JSON. Automatically disables color output.",
"env": "SHOPIFY_FLAG_JSON",
"hidden": false,
"name": "json",
"type": "boolean"
},
"no-color": {
"allowNo": false,
"description": "Disable color output.",
"env": "SHOPIFY_FLAG_NO_COLOR",
"hidden": false,
"name": "no-color",
"type": "boolean"
},
"store": {
"char": "s",
"description": "The myshopify.com domain of the store.",
"env": "SHOPIFY_FLAG_STORE",
"hasDynamicHelp": false,
"multiple": false,
"name": "store",
"required": true,
"type": "option"
},
"verbose": {
"allowNo": false,
"description": "Increase the verbosity of the output.",
"env": "SHOPIFY_FLAG_VERBOSE",
"hidden": false,
"name": "verbose",
"type": "boolean"
}
},
"hasDynamicHelp": false,
"hiddenAliases": [
],
"id": "store:info",
"pluginAlias": "@shopify/cli",
"pluginName": "@shopify/cli",
"pluginType": "core",
"strict": true,
"summary": "Surface metadata about a Shopify store."
},
"theme:check": {
"aliases": [
],
Expand Down
40 changes: 40 additions & 0 deletions packages/store/src/cli/commands/store/info.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
import StoreInfo from './info.js'
import {getStoreInfo} from '../../services/store/info/index.js'
import {renderStoreInfoResult} from '../../services/store/info/result.js'
import {beforeEach, describe, expect, test, vi} from 'vitest'

vi.mock('../../services/store/info/index.js')
vi.mock('../../services/store/info/result.js')
vi.mock('../../services/store/attribution.js')

describe('store info command', () => {
beforeEach(() => {
vi.mocked(getStoreInfo).mockResolvedValue({
subdomain: 'shop.myshopify.com',
displayName: 'My Shop',
})
})

test('passes the store flag through to the service', async () => {
await StoreInfo.run(['--store', 'shop.myshopify.com'])

expect(getStoreInfo).toHaveBeenCalledWith({
store: 'shop.myshopify.com',
})
expect(renderStoreInfoResult).toHaveBeenCalledWith(
expect.objectContaining({subdomain: 'shop.myshopify.com'}),
'text',
)
})

test('renders json format when --json flag is set', async () => {
await StoreInfo.run(['--store', 'shop.myshopify.com', '--json'])

expect(renderStoreInfoResult).toHaveBeenCalledWith(expect.anything(), 'json')
})

test('defines the expected flags', () => {
expect(StoreInfo.flags.store).toBeDefined()
expect(StoreInfo.flags.json).toBeDefined()
})
})
34 changes: 34 additions & 0 deletions packages/store/src/cli/commands/store/info.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import {getStoreInfo} from '../../services/store/info/index.js'
import {renderStoreInfoResult} from '../../services/store/info/result.js'
import StoreCommand from '../../utilities/store-command.js'
import {storeFlags} from '../../flags.js'
import {globalFlags, jsonFlag} from '@shopify/cli-kit/node/cli'

export default class StoreInfo extends StoreCommand {
static summary = 'Surface metadata about a Shopify store.'

static descriptionWithMarkdown = `Returns metadata about a store you have access to: id, display name, subdomain, organization, store owner, type, plan, feature preview, and admin URL.

Use \`--json\` for machine-readable output.`

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: should we note here that the JSON output is slightly more verbose e.g. includes IDs? Might be a nice breadcrumb for agents.


static description = this.descriptionWithoutMarkdown()

static examples = [
'<%= config.bin %> <%= command.id %> --store shop.myshopify.com',
'<%= config.bin %> <%= command.id %> --store shop.myshopify.com --json',
]

static flags = {
...globalFlags,
...jsonFlag,
store: storeFlags.store,
}

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

const result = await getStoreInfo({store: flags.store})

renderStoreInfoResult(result, flags.json ? 'json' : 'text')
}
}
Loading
Loading