-
Notifications
You must be signed in to change notification settings - Fork 247
Add shopify store create trial command
#7346
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
Open
tizmagik
wants to merge
1
commit into
main
Choose a base branch
from
jg/store-create-trial
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
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
There are no files selected for viewing
1 change: 1 addition & 0 deletions
1
docs-shopify.dev/commands/examples/store-create-trial.example.sh
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 @@ | ||
| shopify store create trial [flags] |
42 changes: 42 additions & 0 deletions
42
docs-shopify.dev/commands/interfaces/store-create-trial.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,42 @@ | ||
| // This is an autogenerated file. Don't edit this file manually. | ||
| /** | ||
| * The following flags are available for the `store create trial` command: | ||
| * @publicDocs | ||
| */ | ||
| export interface storecreatetrial { | ||
| /** | ||
| * The country code for the store (e.g., US, CA, GB). | ||
| * @environment SHOPIFY_FLAG_STORE_COUNTRY | ||
| */ | ||
| '-c, --country <value>'?: string | ||
|
|
||
| /** | ||
| * Output the result as JSON. Automatically disables color output. | ||
| * @environment SHOPIFY_FLAG_JSON | ||
| */ | ||
| '-j, --json'?: '' | ||
|
|
||
| /** | ||
| * The name of the store. | ||
| * @environment SHOPIFY_FLAG_STORE_NAME | ||
| */ | ||
| '-n, --name <value>'?: string | ||
|
|
||
| /** | ||
| * Disable color output. | ||
| * @environment SHOPIFY_FLAG_NO_COLOR | ||
| */ | ||
| '--no-color'?: '' | ||
|
|
||
| /** | ||
| * The custom myshopify.com subdomain for the store. | ||
| * @environment SHOPIFY_FLAG_STORE_SUBDOMAIN | ||
| */ | ||
| '--subdomain <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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,34 @@ | ||
| // This is an autogenerated file. Don't edit this file manually. | ||
| import {ReferenceEntityTemplateSchema} from '@shopify/generate-docs' | ||
|
|
||
| const data: ReferenceEntityTemplateSchema = { | ||
| name: 'store create trial', | ||
| description: `Creates a new Shopify trial store associated with your account.`, | ||
| overviewPreviewDescription: `Create a new Shopify trial store.`, | ||
| type: 'command', | ||
| isVisualComponent: false, | ||
| defaultExample: { | ||
| codeblock: { | ||
| tabs: [ | ||
| { | ||
| title: 'store create trial', | ||
| code: './examples/store-create-trial.example.sh', | ||
| language: 'bash', | ||
| }, | ||
| ], | ||
| title: 'store create trial', | ||
| }, | ||
| }, | ||
| definitions: [ | ||
| { | ||
| title: 'Flags', | ||
| description: 'The following flags are available for the `store create trial` command:', | ||
| type: 'storecreatetrial', | ||
| }, | ||
| ], | ||
| category: 'store', | ||
| related: [ | ||
| ], | ||
| } | ||
|
|
||
| export default data |
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,60 @@ | ||
| import {signupsRequest} from './signups.js' | ||
| import {graphqlRequest} from './graphql.js' | ||
| import {handleDeprecations} from './partners.js' | ||
| import {signupsFqdn} from '../context/fqdn.js' | ||
| import {beforeEach, describe, expect, test, vi} from 'vitest' | ||
|
|
||
| vi.mock('./graphql.js') | ||
| vi.mock('../context/fqdn.js') | ||
|
|
||
| const signupsFqdnValue = 'shopify.com' | ||
| const url = `https://${signupsFqdnValue}/services/signups/graphql` | ||
| const mockedToken = 'identity-token' | ||
|
|
||
| beforeEach(() => { | ||
| vi.mocked(signupsFqdn).mockResolvedValue(signupsFqdnValue) | ||
| }) | ||
|
|
||
| describe('signupsRequest', () => { | ||
| test('calls graphqlRequest with correct parameters', async () => { | ||
| vi.mocked(graphqlRequest).mockResolvedValue({storeCreate: {shopPermanentDomain: 'test.myshopify.com'}}) | ||
| const query = 'mutation StoreCreate($signup: ShopInput!) { storeCreate(signup: $signup) { shopPermanentDomain } }' | ||
| const variables = {signup: {country: 'US'}} | ||
|
|
||
| await signupsRequest(query, mockedToken, variables) | ||
|
|
||
| expect(graphqlRequest).toHaveBeenCalledWith({ | ||
| query, | ||
| api: 'Signups', | ||
| url, | ||
| token: mockedToken, | ||
| variables, | ||
| responseOptions: {onResponse: handleDeprecations}, | ||
| }) | ||
| }) | ||
|
|
||
| test('calls graphqlRequest without variables when not provided', async () => { | ||
| vi.mocked(graphqlRequest).mockResolvedValue({}) | ||
| const query = 'query { __schema { types { name } } }' | ||
|
|
||
| await signupsRequest(query, mockedToken) | ||
|
|
||
| expect(graphqlRequest).toHaveBeenCalledWith({ | ||
| query, | ||
| api: 'Signups', | ||
| url, | ||
| token: mockedToken, | ||
| variables: undefined, | ||
| responseOptions: {onResponse: handleDeprecations}, | ||
| }) | ||
| }) | ||
|
|
||
| test('returns the response from graphqlRequest', async () => { | ||
| const expectedResponse = {storeCreate: {shopPermanentDomain: 'new-store.myshopify.com', polling: false}} | ||
| vi.mocked(graphqlRequest).mockResolvedValue(expectedResponse) | ||
|
|
||
| const result = await signupsRequest('query', mockedToken) | ||
|
|
||
| expect(result).toEqual(expectedResponse) | ||
| }) | ||
| }) |
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,32 @@ | ||
| import {GraphQLVariables, graphqlRequest} from './graphql.js' | ||
| import {handleDeprecations} from './partners.js' | ||
| import {signupsFqdn} from '../context/fqdn.js' | ||
|
|
||
| async function setupRequest(token: string) { | ||
| const api = 'Signups' | ||
| const fqdn = await signupsFqdn() | ||
| const url = `https://${fqdn}/services/signups/graphql` | ||
| return { | ||
| token, | ||
| api, | ||
| url, | ||
| responseOptions: {onResponse: handleDeprecations}, | ||
| } | ||
| } | ||
|
|
||
| /** | ||
| * Executes a GraphQL query against the Signups API. | ||
| * Uses the Identity bearer token directly (no application token exchange). | ||
| * | ||
| * @param query - GraphQL query to execute. | ||
| * @param token - Identity access token. | ||
| * @param variables - GraphQL variables to pass to the query. | ||
| * @returns The response of the query of generic type <T>. | ||
| */ | ||
| export async function signupsRequest<T>(query: string, token: string, variables?: GraphQLVariables): Promise<T> { | ||
| return graphqlRequest<T>({ | ||
| ...(await setupRequest(token)), | ||
| query, | ||
| variables, | ||
| }) | ||
| } |
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
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.
Add coverage for
signupsFqdn()infqdn.test.ts(local vs production), like the existing tests forpartnersFqdn,adminFqdn, etc. Without a direct test, regressions in the Signups FQDN routing (especially the local dev-server host mapping) may go unnoticed.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.
Added a
describe('signupsFqdn')block infqdn.test.tscovering local + production environments, matching the pattern used bypartnersFqdn/adminFqdn.