-
Notifications
You must be signed in to change notification settings - Fork 274
Add store delete command #8035
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
Add store delete command #8035
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
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
69 changes: 69 additions & 0 deletions
69
...cli/api/graphql/business-platform-organizations/generated/delete_app_development_store.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,69 @@ | ||
| /* eslint-disable @typescript-eslint/consistent-type-definitions */ | ||
| import * as Types from './types.js' | ||
|
|
||
| import {TypedDocumentNode as DocumentNode} from '@graphql-typed-document-node/core' | ||
|
|
||
| export type DeleteAppDevelopmentStoreMutationVariables = Types.Exact<{ | ||
| storeFqdn: Types.Scalars['String']['input'] | ||
| }> | ||
|
|
||
| export type DeleteAppDevelopmentStoreMutation = { | ||
| deleteAppDevelopmentStore: { | ||
| success: boolean | ||
| userErrors: {code?: string | null; field: string[]; message: string}[] | ||
| } | ||
| } | ||
|
|
||
| export const DeleteAppDevelopmentStore = { | ||
| kind: 'Document', | ||
| definitions: [ | ||
| { | ||
| kind: 'OperationDefinition', | ||
| operation: 'mutation', | ||
| name: {kind: 'Name', value: 'DeleteAppDevelopmentStore'}, | ||
| variableDefinitions: [ | ||
| { | ||
| kind: 'VariableDefinition', | ||
| variable: {kind: 'Variable', name: {kind: 'Name', value: 'storeFqdn'}}, | ||
| type: {kind: 'NonNullType', type: {kind: 'NamedType', name: {kind: 'Name', value: 'String'}}}, | ||
| }, | ||
| ], | ||
| selectionSet: { | ||
| kind: 'SelectionSet', | ||
| selections: [ | ||
| { | ||
| kind: 'Field', | ||
| name: {kind: 'Name', value: 'deleteAppDevelopmentStore'}, | ||
| arguments: [ | ||
| { | ||
| kind: 'Argument', | ||
| name: {kind: 'Name', value: 'storeFqdn'}, | ||
| value: {kind: 'Variable', name: {kind: 'Name', value: 'storeFqdn'}}, | ||
| }, | ||
| ], | ||
| selectionSet: { | ||
| kind: 'SelectionSet', | ||
| selections: [ | ||
| {kind: 'Field', name: {kind: 'Name', value: 'success'}}, | ||
| { | ||
| kind: 'Field', | ||
| name: {kind: 'Name', value: 'userErrors'}, | ||
| selectionSet: { | ||
| kind: 'SelectionSet', | ||
| selections: [ | ||
| {kind: 'Field', name: {kind: 'Name', value: 'code'}}, | ||
| {kind: 'Field', name: {kind: 'Name', value: 'field'}}, | ||
| {kind: 'Field', name: {kind: 'Name', value: 'message'}}, | ||
| {kind: 'Field', name: {kind: 'Name', value: '__typename'}}, | ||
| ], | ||
| }, | ||
| }, | ||
| {kind: 'Field', name: {kind: 'Name', value: '__typename'}}, | ||
| ], | ||
| }, | ||
| }, | ||
| ], | ||
| }, | ||
| }, | ||
| ], | ||
| } as unknown as DocumentNode<DeleteAppDevelopmentStoreMutation, DeleteAppDevelopmentStoreMutationVariables> |
67 changes: 67 additions & 0 deletions
67
...cli/api/graphql/business-platform-organizations/generated/organization_accessible_shop.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,67 @@ | ||
| /* eslint-disable @typescript-eslint/consistent-type-definitions */ | ||
| import * as Types from './types.js' | ||
|
|
||
| import {TypedDocumentNode as DocumentNode} from '@graphql-typed-document-node/core' | ||
|
|
||
| export type OrganizationAccessibleShopQueryVariables = Types.Exact<{ | ||
| id: Types.Scalars['ShopifyShopID']['input'] | ||
| }> | ||
|
|
||
| export type OrganizationAccessibleShopQuery = { | ||
| organization?: { | ||
| accessibleShop?: {shopifyShopId?: string | null; planName?: string | null; storeType?: Types.Store | null} | null | ||
| } | null | ||
| } | ||
|
|
||
| export const OrganizationAccessibleShop = { | ||
| kind: 'Document', | ||
| definitions: [ | ||
| { | ||
| kind: 'OperationDefinition', | ||
| operation: 'query', | ||
| name: {kind: 'Name', value: 'OrganizationAccessibleShop'}, | ||
| variableDefinitions: [ | ||
| { | ||
| kind: 'VariableDefinition', | ||
| variable: {kind: 'Variable', name: {kind: 'Name', value: 'id'}}, | ||
| type: {kind: 'NonNullType', type: {kind: 'NamedType', name: {kind: 'Name', value: 'ShopifyShopID'}}}, | ||
| }, | ||
| ], | ||
| selectionSet: { | ||
| kind: 'SelectionSet', | ||
| selections: [ | ||
| { | ||
| kind: 'Field', | ||
| name: {kind: 'Name', value: 'organization'}, | ||
| selectionSet: { | ||
| kind: 'SelectionSet', | ||
| selections: [ | ||
| { | ||
| kind: 'Field', | ||
| name: {kind: 'Name', value: 'accessibleShop'}, | ||
| arguments: [ | ||
| { | ||
| kind: 'Argument', | ||
| name: {kind: 'Name', value: 'id'}, | ||
| value: {kind: 'Variable', name: {kind: 'Name', value: 'id'}}, | ||
| }, | ||
| ], | ||
| selectionSet: { | ||
| kind: 'SelectionSet', | ||
| selections: [ | ||
| {kind: 'Field', name: {kind: 'Name', value: 'shopifyShopId'}}, | ||
| {kind: 'Field', name: {kind: 'Name', value: 'planName'}}, | ||
| {kind: 'Field', name: {kind: 'Name', value: 'storeType'}}, | ||
| {kind: 'Field', name: {kind: 'Name', value: '__typename'}}, | ||
| ], | ||
| }, | ||
| }, | ||
| {kind: 'Field', name: {kind: 'Name', value: '__typename'}}, | ||
| ], | ||
| }, | ||
| }, | ||
| ], | ||
| }, | ||
| }, | ||
| ], | ||
| } as unknown as DocumentNode<OrganizationAccessibleShopQuery, OrganizationAccessibleShopQueryVariables> |
10 changes: 10 additions & 0 deletions
10
...pi/graphql/business-platform-organizations/mutations/delete_app_development_store.graphql
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,10 @@ | ||
| mutation DeleteAppDevelopmentStore($storeFqdn: String!) { | ||
| deleteAppDevelopmentStore(storeFqdn: $storeFqdn) { | ||
| success | ||
| userErrors { | ||
| code | ||
| field | ||
| message | ||
| } | ||
| } | ||
| } |
9 changes: 9 additions & 0 deletions
9
.../api/graphql/business-platform-organizations/queries/organization_accessible_shop.graphql
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,9 @@ | ||
| query OrganizationAccessibleShop($id: ShopifyShopID!) { | ||
| organization { | ||
| accessibleShop(id: $id) { | ||
| shopifyShopId | ||
| planName | ||
| storeType | ||
| } | ||
| } | ||
| } |
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,126 @@ | ||
| import StoreDelete from './delete.js' | ||
| import {deleteDevStore} from '../../services/store/delete/dev.js' | ||
| import {resolveOrganizationForStore} from '../../utilities/store-lookup/organization.js' | ||
| import {AbortError} from '@shopify/cli-kit/node/error' | ||
| import {outputResult} from '@shopify/cli-kit/node/output' | ||
| import {describe, expect, test, vi, beforeEach} from 'vitest' | ||
|
|
||
| vi.mock('../../services/store/delete/dev.js') | ||
| vi.mock('../../utilities/store-lookup/organization.js') | ||
|
|
||
| vi.mock('@shopify/cli-kit/node/output', async (importOriginal) => { | ||
| const actual: Record<string, unknown> = await importOriginal() | ||
| return { | ||
| ...actual, | ||
| outputResult: vi.fn(), | ||
| } | ||
| }) | ||
|
|
||
| const defaultOrg = {id: '12345', businessName: 'Test Org'} | ||
|
|
||
| beforeEach(() => { | ||
| vi.mocked(resolveOrganizationForStore).mockResolvedValue(defaultOrg) | ||
| }) | ||
|
|
||
| describe('store delete command', () => { | ||
| test('resolves the organization and passes parsed flags through to the service', async () => { | ||
| await StoreDelete.run(['--store', 'my-store.myshopify.com', '--organization-id', '12345']) | ||
|
|
||
| expect(resolveOrganizationForStore).toHaveBeenCalledWith('my-store.myshopify.com', '12345') | ||
| expect(deleteDevStore).toHaveBeenCalledWith({ | ||
| store: 'my-store.myshopify.com', | ||
| organization: defaultOrg, | ||
| json: false, | ||
| }) | ||
| }) | ||
|
|
||
| test('normalizes the store flag before passing it to the service', async () => { | ||
| await StoreDelete.run(['--store', 'my-store', '--organization-id', '12345']) | ||
|
|
||
| expect(deleteDevStore).toHaveBeenCalledWith(expect.objectContaining({store: 'my-store.myshopify.com'})) | ||
| }) | ||
|
|
||
| test('passes json flag through to the service', async () => { | ||
| await StoreDelete.run(['--store', 'my-store.myshopify.com', '--json', '--organization-id', '12345']) | ||
|
|
||
| expect(deleteDevStore).toHaveBeenCalledWith({ | ||
| store: 'my-store.myshopify.com', | ||
| organization: defaultOrg, | ||
| json: true, | ||
| }) | ||
| }) | ||
|
|
||
| test('resolves the organization without an ID when --organization-id is omitted', async () => { | ||
| await StoreDelete.run(['--store', 'my-store.myshopify.com']) | ||
|
|
||
| expect(resolveOrganizationForStore).toHaveBeenCalledWith('my-store.myshopify.com', undefined) | ||
| expect(deleteDevStore).toHaveBeenCalledWith(expect.objectContaining({organization: defaultOrg})) | ||
| }) | ||
|
|
||
| test('defines the expected flags', () => { | ||
| expect(StoreDelete.flags.store).toBeDefined() | ||
| expect(StoreDelete.flags['organization-id']).toBeDefined() | ||
| expect(StoreDelete.flags.json).toBeDefined() | ||
| }) | ||
|
|
||
| test('outputs structured JSON error when --json is active and service throws AbortError', async () => { | ||
| vi.mocked(deleteDevStore).mockRejectedValueOnce(new AbortError('Something went wrong')) | ||
| const mockExit = vi.spyOn(process, 'exit').mockImplementation((() => { | ||
| throw new Error('process.exit') | ||
| }) as never) | ||
|
|
||
| await expect( | ||
| StoreDelete.run(['--store', 'my-store.myshopify.com', '--organization-id', '12345', '--json']), | ||
| ).rejects.toThrow('process.exit') | ||
|
|
||
| const call = vi.mocked(outputResult).mock.calls[0]![0] as string | ||
| const parsed = JSON.parse(call) | ||
| expect(parsed).toEqual({ | ||
| error: true, | ||
| message: 'Something went wrong', | ||
| nextSteps: [], | ||
| exitCode: 1, | ||
| }) | ||
| expect(mockExit).toHaveBeenCalledWith(1) | ||
|
|
||
| mockExit.mockRestore() | ||
| }) | ||
|
|
||
| test('outputs structured JSON error when --json is active and organization resolution throws AbortError', async () => { | ||
| vi.mocked(resolveOrganizationForStore).mockRejectedValueOnce(new AbortError('Could not resolve organization')) | ||
| const mockExit = vi.spyOn(process, 'exit').mockImplementation((() => { | ||
| throw new Error('process.exit') | ||
| }) as never) | ||
|
|
||
| await expect(StoreDelete.run(['--store', 'my-store.myshopify.com', '--json'])).rejects.toThrow('process.exit') | ||
|
|
||
| const call = vi.mocked(outputResult).mock.calls[0]![0] as string | ||
| const parsed = JSON.parse(call) | ||
| expect(parsed).toEqual({ | ||
| error: true, | ||
| message: 'Could not resolve organization', | ||
| nextSteps: [], | ||
| exitCode: 1, | ||
| }) | ||
| expect(deleteDevStore).not.toHaveBeenCalled() | ||
| expect(mockExit).toHaveBeenCalledWith(1) | ||
|
|
||
| mockExit.mockRestore() | ||
| }) | ||
|
|
||
| test('does not output JSON for non-AbortError even when --json is active', async () => { | ||
| vi.mocked(deleteDevStore).mockRejectedValueOnce(new Error('unexpected')) | ||
|
|
||
| await expect( | ||
| StoreDelete.run(['--store', 'my-store.myshopify.com', '--organization-id', '12345', '--json']), | ||
| ).rejects.toThrow() | ||
| expect(vi.mocked(outputResult)).not.toHaveBeenCalled() | ||
| }) | ||
|
|
||
| test('does not output JSON for AbortError when --json is not active', async () => { | ||
| vi.mocked(deleteDevStore).mockRejectedValueOnce(new AbortError('Something went wrong')) | ||
|
|
||
| await expect(StoreDelete.run(['--store', 'my-store.myshopify.com', '--organization-id', '12345'])).rejects.toThrow() | ||
| expect(vi.mocked(outputResult)).not.toHaveBeenCalled() | ||
| }) | ||
| }) | ||
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.
Uh oh!
There was an error while loading. Please reload this page.