-
Notifications
You must be signed in to change notification settings - Fork 262
Add shopify store info --store <domain> command
#7660
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. Weβll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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
30
docs-shopify.dev/commands/interfaces/store-info.interface.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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'?: '' | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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() | ||
| }) | ||
| }) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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.` | ||
|
|
||
| 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') | ||
| } | ||
| } | ||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
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.