Skip to content

Commit e98534a

Browse files
authored
Merge pull request #8049 from Shopify/deploy-split/06-remove-legacy-matching
Remove the legacy extension identifier-matching code
2 parents 9bb80ee + 16d233f commit e98534a

23 files changed

Lines changed: 262 additions & 3610 deletions

‎packages/app/src/cli/api/graphql/current_account_info.ts‎

Lines changed: 0 additions & 32 deletions
This file was deleted.

‎packages/app/src/cli/models/app/app.test-data.ts‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ import {
5151
MigrateFlowExtensionVariables,
5252
} from '../../api/graphql/extension_migrate_flow_extension.js'
5353
import {UpdateURLsSchema, UpdateURLsVariables} from '../../api/graphql/update_urls.js'
54-
import {CurrentAccountInfoSchema} from '../../api/graphql/current_account_info.js'
54+
import {CurrentAccountInfoQuery} from '../../api/graphql/partners/generated/current-account-info.js'
5555
import {
5656
MigrateToUiExtensionSchema,
5757
MigrateToUiExtensionVariables,
@@ -1279,7 +1279,7 @@ const updateURLsResponse: UpdateURLsSchema = {
12791279
},
12801280
}
12811281

1282-
const currentAccountInfoResponse: CurrentAccountInfoSchema = {
1282+
const currentAccountInfoResponse: CurrentAccountInfoQuery = {
12831283
currentAccountInfo: {
12841284
__typename: 'UserAccount',
12851285
email: 'user@example.com',

‎packages/app/src/cli/models/app/identifiers.test.ts‎

Lines changed: 12 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,9 @@ describe('updateAppIdentifiers', () => {
1818
// When
1919
const gotApp = await updateAppIdentifiers({
2020
app,
21-
identifiers: {
22-
app: 'FOO',
23-
extensions: {
24-
my_extension: 'BAR',
25-
},
21+
appApiKey: 'FOO',
22+
extensionUuids: {
23+
my_extension: 'BAR',
2624
},
2725
command: 'deploy',
2826
})
@@ -51,11 +49,9 @@ describe('updateAppIdentifiers', () => {
5149
// When
5250
const gotApp = await updateAppIdentifiers({
5351
app,
54-
identifiers: {
55-
app: 'FOO',
56-
extensions: {
57-
my_extension: 'BAR',
58-
},
52+
appApiKey: 'FOO',
53+
extensionUuids: {
54+
my_extension: 'BAR',
5955
},
6056
command: 'deploy',
6157
})
@@ -85,11 +81,9 @@ describe('updateAppIdentifiers', () => {
8581
await updateAppIdentifiers(
8682
{
8783
app,
88-
identifiers: {
89-
app: 'FOO',
90-
extensions: {
91-
my_extension: 'BAR',
92-
},
84+
appApiKey: 'FOO',
85+
extensionUuids: {
86+
my_extension: 'BAR',
9387
},
9488
command: 'deploy',
9589
},
@@ -152,11 +146,9 @@ type = "ui_extension"`,
152146
await updateAppIdentifiers(
153147
{
154148
app,
155-
identifiers: {
156-
app: 'FOO',
157-
extensions: {
158-
my_extension: 'BAR',
159-
},
149+
appApiKey: 'FOO',
150+
extensionUuids: {
151+
my_extension: 'BAR',
160152
},
161153
command: 'deploy',
162154
},

‎packages/app/src/cli/models/app/identifiers.ts‎

Lines changed: 6 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -6,30 +6,6 @@ import {joinPath} from '@shopify/cli-kit/node/path'
66
import {fileExists, readFile, writeFile} from '@shopify/cli-kit/node/fs'
77
import type {AppInterface} from './app.js'
88

9-
export interface IdentifiersExtensions {
10-
[localIdentifier: string]: string
11-
}
12-
13-
interface Identifiers {
14-
/** Application's API Key */
15-
app: string
16-
17-
/**
18-
* The extensions' unique identifiers.
19-
*/
20-
extensions: IdentifiersExtensions
21-
22-
/**
23-
* The extensions' numeric identifiers (expressed as a string).
24-
*/
25-
extensionIds: IdentifiersExtensions
26-
27-
/**
28-
* The extensions' unique identifiers which uuid is not managed.
29-
*/
30-
extensionsNonUuidManaged: IdentifiersExtensions
31-
}
32-
339
export interface ExtensionUuidsByLocalIdentifier {
3410
[localIdentifier: string]: string
3511
}
@@ -39,11 +15,11 @@ export interface DeployIdentifiers {
3915
appModuleRegistrationIds: ExtensionUuidsByLocalIdentifier
4016
}
4117

42-
type UuidOnlyIdentifiers = Omit<Identifiers, 'extensionIds' | 'extensionsNonUuidManaged'>
4318
type UpdateAppIdentifiersCommand = 'dev' | 'deploy' | 'release' | 'import-extensions'
4419
interface UpdateAppIdentifiersOptions {
4520
app: AppInterface
46-
identifiers: UuidOnlyIdentifiers
21+
appApiKey: string
22+
extensionUuids: ExtensionUuidsByLocalIdentifier
4723
command: UpdateAppIdentifiersCommand
4824
}
4925

@@ -53,7 +29,7 @@ interface UpdateAppIdentifiersOptions {
5329
* @returns An copy of the app with the environment updated to reflect the updated identifiers.
5430
*/
5531
export async function updateAppIdentifiers(
56-
{app, identifiers, command}: UpdateAppIdentifiersOptions,
32+
{app, appApiKey, extensionUuids, command}: UpdateAppIdentifiersOptions,
5733
systemEnvironment = process.env,
5834
): Promise<AppInterface> {
5935
let dotenvFile = app.dotenv
@@ -64,12 +40,12 @@ export async function updateAppIdentifiers(
6440
}
6541
const updatedVariables: {[key: string]: string} = {...(app.dotenv?.variables ?? {})}
6642
if (!systemEnvironment[app.idEnvironmentVariableName]) {
67-
updatedVariables[app.idEnvironmentVariableName] = identifiers.app
43+
updatedVariables[app.idEnvironmentVariableName] = appApiKey
6844
}
69-
Object.keys(identifiers.extensions).forEach((identifier) => {
45+
Object.keys(extensionUuids).forEach((identifier) => {
7046
const envVariable = `SHOPIFY_${constantize(identifier)}_ID`
7147
if (!systemEnvironment[envVariable]) {
72-
updatedVariables[envVariable] = identifiers.extensions[identifier]!
48+
updatedVariables[envVariable] = extensionUuids[identifier]!
7349
}
7450
})
7551

‎packages/app/src/cli/services/app/write-app-configuration-file.ts‎

Lines changed: 0 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ import {reduceWebhooks} from '../../models/extensions/specifications/transform/a
33
import {removeTrailingSlash} from '../../models/extensions/specifications/validation/common.js'
44
import {TomlFile} from '@shopify/cli-kit/node/toml/toml-file'
55
import {JsonMapType} from '@shopify/cli-kit/node/toml'
6-
import {zod} from '@shopify/cli-kit/node/schema'
76
import {outputDebug} from '@shopify/cli-kit/node/output'
87

98
export async function writeAppConfigurationFile(configuration: CurrentAppConfiguration, configPath: string) {
@@ -46,53 +45,6 @@ export function stripEmptyObjects(obj: unknown): unknown {
4645
return obj
4746
}
4847

49-
/**
50-
* Rewrite a configuration object to match the structure of a Zod schema.
51-
*
52-
* Used by breakdown-extensions.ts to normalize configs before diffing.
53-
* Not used by writeAppConfigurationFile — that function uses stripEmptyObjects instead.
54-
*/
55-
export const rewriteConfiguration = <T extends zod.ZodTypeAny>(schema: T, config: unknown): unknown => {
56-
if (schema === null || schema === undefined) return null
57-
if (schema instanceof zod.ZodNullable || schema instanceof zod.ZodOptional)
58-
return rewriteConfiguration(schema.unwrap(), config)
59-
if (schema instanceof zod.ZodArray) {
60-
return (config as unknown[]).map((item) => rewriteConfiguration(schema.element, item))
61-
}
62-
if (schema instanceof zod.ZodEffects) {
63-
return rewriteConfiguration(schema._def.schema, config)
64-
}
65-
if (schema instanceof zod.ZodObject) {
66-
const entries = Object.entries(schema.shape)
67-
const confObj = config as {[key: string]: unknown}
68-
let result: {[key: string]: unknown} = {}
69-
entries.forEach(([key, subSchema]) => {
70-
if (confObj !== undefined && confObj[key] !== undefined) {
71-
let value = rewriteConfiguration(subSchema as T, confObj[key])
72-
if (!(value instanceof Array) && value instanceof Object && Object.keys(value as object).length === 0) {
73-
value = undefined
74-
}
75-
result = {...result, [key]: value}
76-
}
77-
})
78-
79-
// if dynamic config was enabled, its possible to have more keys in the file than the schema
80-
const blockedKeys = ['scopes']
81-
82-
Object.entries(confObj)
83-
.filter(([key]) => !blockedKeys.includes(key))
84-
.sort(([keyA], [keyB]) => keyA.localeCompare(keyB))
85-
.forEach(([key, value]) => {
86-
if (!entries.map(([key]) => key).includes(key)) {
87-
result = {...result, [key]: value}
88-
}
89-
})
90-
91-
return result
92-
}
93-
return config
94-
}
95-
9648
function addDefaultCommentsToToml(fileString: string) {
9749
const appTomlInitialComment = `# Learn more about configuring your app at https://shopify.dev/docs/apps/tools/cli/configuration\n`
9850
const appTomlScopesComment = `\n# Learn more at https://shopify.dev/docs/apps/tools/cli/configuration#access_scopes`

0 commit comments

Comments
 (0)