Skip to content
Open
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
69 changes: 0 additions & 69 deletions packages/app/src/cli/api/graphql/extension_create.ts

This file was deleted.

20 changes: 0 additions & 20 deletions packages/app/src/cli/models/app/app.test-data.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ import {
} from '../../utilities/developer-platform-client.js'
import {AllAppExtensionRegistrationsQuerySchema} from '../../api/graphql/all_app_extension_registrations.js'
import {AppDeploySchema, AppDeployVariables} from '../../api/graphql/app_deploy.js'
import {ExtensionCreateSchema, ExtensionCreateVariables} from '../../api/graphql/extension_create.js'
import {ConvertDevToTransferDisabledStoreVariables} from '../../api/graphql/convert_dev_to_transfer_disabled_store.js'
import {SendSampleWebhookSchema, SendSampleWebhookVariables} from '../../services/webhook/request-sample.js'
import {PublicApiVersionsSchema} from '../../services/webhook/request-api-versions.js'
Expand Down Expand Up @@ -1212,24 +1211,6 @@ const appVersionsDiffResponse: AppVersionsDiffSchema = {
},
}

export const extensionCreateResponse: ExtensionCreateSchema = {
extensionCreate: {
extensionRegistration: {
id: 'extension-id',
uuid: 'extension-uuid',
title: 'my extension',
type: 'other',
draftVersion: {
config: 'config',
registrationId: 'registration-id',
lastUserInteractionAt: '2024-01-01',
validationErrors: [],
},
},
userErrors: [],
},
}

const deployResponse: AppDeploySchema = {
appDeploy: {
appVersion: {
Expand Down Expand Up @@ -1356,7 +1337,6 @@ export function testDeveloperPlatformClient(stubs: Partial<DeveloperPlatformClie
activeAppVersion: (_app: MinimalAppIdentifiers) => Promise.resolve(emptyActiveAppVersion),
appVersionByTag: (_app: MinimalOrganizationApp, _tag: string) => Promise.resolve(appVersionByTagResponse),
appVersionsDiff: (_input: AppVersionsDiffVariables) => Promise.resolve(appVersionsDiffResponse),
createExtension: (_input: ExtensionCreateVariables) => Promise.resolve(extensionCreateResponse),
deploy: (_input: AppDeployVariables) => Promise.resolve(deployResponse),
release: (_input: {app: MinimalAppIdentifiers; version: AppVersionIdentifiers}) => Promise.resolve(releaseResponse),
generateSignedUploadUrl: (_app: MinimalAppIdentifiers) => Promise.resolve(generateSignedUploadUrlResponse),
Expand Down
77 changes: 2 additions & 75 deletions packages/app/src/cli/services/context.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,25 +2,17 @@ import {fetchOrganizations, fetchOrgFromId} from './dev/fetch.js'
import {selectOrCreateApp} from './dev/select-app.js'
import {selectStore} from './dev/select-store.js'
import {ensureDeploymentIdsPresence} from './context/identifiers.js'
import {appFromIdentifiers, ensureDeployContext, ensureThemeExtensionDevContext} from './context.js'
import {createExtension} from './dev/create-extension.js'
import {appFromIdentifiers, ensureDeployContext} from './context.js'
import {CachedAppInfo} from './local-storage.js'
import link from './app/config/link.js'
import {fetchSpecifications} from './generate/fetch-extension-specifications.js'
import {DeployOptions} from './deploy.js'
import {
MinimalAppIdentifiers,
Organization,
OrganizationApp,
OrganizationSource,
OrganizationStore,
} from '../models/organization.js'
import {Organization, OrganizationApp, OrganizationSource, OrganizationStore} from '../models/organization.js'
import {getAppIdentifiers} from '../models/app/identifiers.js'
import {
testDeveloperPlatformClient,
testAppWithConfig,
testOrganizationApp,
testThemeExtensions,
testProject,
} from '../models/app/app.test-data.js'
import {getAppConfigurationFileName, isWebType} from '../models/app/loader.js'
Expand Down Expand Up @@ -112,7 +104,6 @@ function buildDeveloperPlatformClient(extras?: Partial<DeveloperPlatformClient>)

vi.mock('./local-storage.js')
vi.mock('./dev/fetch')
vi.mock('./dev/create-extension')
vi.mock('./dev/select-app')
vi.mock('./dev/select-store')
vi.mock('../prompts/dev')
Expand Down Expand Up @@ -380,70 +371,6 @@ describe('ensureDeployContext', () => {
})
})

describe('ensureThemeExtensionDevContext', () => {
test('fetches theme extension when it exists', async () => {
// Given
const apiKey = 'apiKey'
const extension = await testThemeExtensions()

const mockedExtensionRegistrations = {
app: {
extensionRegistrations: [
{
id: 'other ID',
uuid: 'other UUID',
title: 'other extension',
type: 'other',
},
{
id: 'existing ID',
uuid: 'UUID',
title: 'theme app extension',
type: 'THEME_APP_EXTENSION',
},
],
configurationRegistrations: [],
dashboardManagedExtensionRegistrations: [],
},
}

const developerPlatformClient: DeveloperPlatformClient = testDeveloperPlatformClient({
appExtensionRegistrations: (_app: MinimalAppIdentifiers) => Promise.resolve(mockedExtensionRegistrations),
})

// When
const got = await ensureThemeExtensionDevContext(extension, apiKey, developerPlatformClient)

// Then
expect('existing ID').toEqual(got.id)
expect('UUID').toEqual(got.uuid)
expect('theme app extension').toEqual(got.title)
expect('THEME_APP_EXTENSION').toEqual(got.type)
})

test('creates theme extension when it does not exist', async () => {
// Given
const apiKey = 'apiKey'
const extension = await testThemeExtensions()

vi.mocked(createExtension).mockResolvedValue({
id: 'new ID',
uuid: 'UUID',
title: 'theme app extension',
type: 'THEME_APP_EXTENSION',
})

// When
const got = await ensureThemeExtensionDevContext(extension, apiKey, buildDeveloperPlatformClient())

// Then
expect('new ID').toEqual(got.id)
expect('UUID').toEqual(got.uuid)
expect('theme app extension').toEqual(got.title)
expect('THEME_APP_EXTENSION').toEqual(got.type)
})
})

describe('appFromIdentifiers', () => {
test('renders the org name when an app cannot be found and the account is a service account ', async () => {
vi.mocked(isServiceAccount).mockReturnValue(true)
Expand Down
27 changes: 0 additions & 27 deletions packages/app/src/cli/services/context.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import {selectOrCreateApp} from './dev/select-app.js'
import {fetchOrganizations, fetchOrgFromId} from './dev/fetch.js'
import {ensureDeploymentIdsPresence} from './context/identifiers.js'
import {createExtension} from './dev/create-extension.js'
import {CachedAppInfo} from './local-storage.js'
import {DeployOptions} from './deploy.js'
import {formatConfigInfoBody} from './format-config-info-body.js'
Expand All @@ -10,13 +9,10 @@ import {Identifiers, updateAppIdentifiers, getAppIdentifiers} from '../models/ap
import {Organization, OrganizationApp, OrganizationSource, OrganizationStore} from '../models/organization.js'
import metadata from '../metadata.js'
import {getAppConfigurationFileName} from '../models/app/loader.js'
import {ExtensionInstance} from '../models/extensions/extension-instance.js'

import {ExtensionRegistration} from '../api/graphql/all_app_extension_registrations.js'
import {
allDeveloperPlatformClients,
CreateAppOptions,
DeveloperPlatformClient,
selectDeveloperPlatformClient,
} from '../utilities/developer-platform-client.js'
import {selectOrganizationPrompt} from '@shopify/organizations'
Expand Down Expand Up @@ -104,29 +100,6 @@ export const appFromIdentifiers = async (options: AppFromIdOptions): Promise<Org
return app
}

export async function ensureThemeExtensionDevContext(
extension: ExtensionInstance,
apiKey: string,
developerPlatformClient: DeveloperPlatformClient,
): Promise<ExtensionRegistration> {
const remoteSpecifications = await developerPlatformClient.appExtensionRegistrations({
id: apiKey,
apiKey,
organizationId: '1',
})
const remoteRegistration = remoteSpecifications.app.extensionRegistrations.find((extension) => {
return extension.type === 'THEME_APP_EXTENSION'
})

if (remoteRegistration) {
return remoteRegistration
}

const registration = await createExtension(apiKey, extension.graphQLType, extension.handle, developerPlatformClient)

return registration
}

interface EnsureDeployContextResult {
identifiers: Identifiers
didMigrateExtensionsToDevDash: boolean
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
/* eslint-disable @shopify/prefer-module-scope-constants */
import {manualMatchIds, ManualMatchResult} from './id-manual-matching.js'
import {ExtensionRegistration} from '../dev/create-extension.js'
import {RemoteSource} from './identifiers.js'
import {testUIExtension} from '../../models/app/app.test-data.js'
import {ExtensionInstance} from '../../models/extensions/extension-instance.js'
import {describe, expect, vi, test, beforeAll} from 'vitest'
import {renderAutocompletePrompt} from '@shopify/cli-kit/node/ui'

vi.mock('@shopify/cli-kit/node/ui')

const REGISTRATION_A: ExtensionRegistration = {
const REGISTRATION_A: RemoteSource = {
uuid: 'UUID_A',
id: 'A',
title: 'A',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import {describe, expect, vi, test, beforeAll} from 'vitest'
import {outputInfo} from '@shopify/cli-kit/node/output'

vi.mock('../dev/fetch')
vi.mock('../dev/create-extension')
vi.mock('@shopify/cli-kit/node/output')

const REGISTRATION_A: RemoteSource = {
Expand Down
Loading
Loading