Skip to content

Commit c40ae4f

Browse files
committed
Unify manifest generation for app-managament deploy
1 parent 04d70e5 commit c40ae4f

File tree

7 files changed

+151
-261
lines changed

7 files changed

+151
-261
lines changed

packages/app/src/cli/services/deploy.test.ts

Lines changed: 106 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,11 @@ describe('deploy', () => {
9595

9696
// Then
9797
expect(uploadExtensionsBundle).toHaveBeenCalledWith({
98+
appManifest: {
99+
name: 'App',
100+
handle: '',
101+
modules: [],
102+
},
98103
appId: 'app-id',
99104
apiKey: 'api-key',
100105
name: app.name,
@@ -153,6 +158,7 @@ describe('deploy', () => {
153158
test('deploys the app with no extensions', async () => {
154159
const app = testAppLinked({allExtensions: []})
155160
vi.mocked(renderTextPrompt).mockResolvedValueOnce('')
161+
const appManifest = await app.manifest(undefined)
156162

157163
// When
158164
await testDeployBundle({
@@ -163,6 +169,7 @@ describe('deploy', () => {
163169

164170
// Then
165171
expect(uploadExtensionsBundle).toHaveBeenCalledWith({
172+
appManifest,
166173
appId: 'app-id',
167174
apiKey: 'api-key',
168175
name: app.name,
@@ -186,6 +193,21 @@ describe('deploy', () => {
186193

187194
// Then
188195
expect(uploadExtensionsBundle).toHaveBeenCalledWith({
196+
appManifest: {
197+
name: 'App',
198+
handle: '',
199+
modules: [
200+
{
201+
type: 'web_pixel_extension_external',
202+
handle: 'test-ui-extension',
203+
uid: 'test-ui-extension-uid',
204+
uuid: 'test-ui-extension',
205+
assets: 'test-ui-extension-uid',
206+
target: '',
207+
config: expect.any(Object),
208+
},
209+
],
210+
},
189211
appId: 'app-id',
190212
apiKey: 'api-key',
191213
name: app.name,
@@ -219,6 +241,21 @@ describe('deploy', () => {
219241

220242
// Then
221243
expect(uploadExtensionsBundle).toHaveBeenCalledWith({
244+
appManifest: {
245+
name: 'App',
246+
handle: '',
247+
modules: [
248+
{
249+
type: 'theme_external',
250+
handle: 'theme-extension-name',
251+
uid: undefined,
252+
uuid: 'theme-extension-name',
253+
assets: undefined,
254+
target: '',
255+
config: expect.any(Object),
256+
},
257+
],
258+
},
222259
appId: 'app-id',
223260
apiKey: 'api-key',
224261
name: app.name,
@@ -270,6 +307,21 @@ describe('deploy', () => {
270307

271308
// Then
272309
expect(uploadExtensionsBundle).toHaveBeenCalledWith({
310+
appManifest: {
311+
name: 'App',
312+
handle: '',
313+
modules: [
314+
{
315+
type: 'function_external',
316+
handle: 'test-function-extension',
317+
uid: undefined,
318+
uuid: 'test-function-extension',
319+
assets: undefined,
320+
target: '',
321+
config: expect.any(Object),
322+
},
323+
],
324+
},
273325
appId: 'app-id',
274326
apiKey: 'api-key',
275327
name: app.name,
@@ -305,6 +357,30 @@ describe('deploy', () => {
305357

306358
// Then
307359
expect(uploadExtensionsBundle).toHaveBeenCalledWith({
360+
appManifest: {
361+
name: 'App',
362+
handle: '',
363+
modules: [
364+
{
365+
type: 'web_pixel_extension_external',
366+
handle: 'test-ui-extension',
367+
uid: 'test-ui-extension-uid',
368+
uuid: 'test-ui-extension',
369+
assets: 'test-ui-extension-uid',
370+
target: '',
371+
config: expect.any(Object),
372+
},
373+
{
374+
type: 'theme_external',
375+
handle: 'theme-extension-name',
376+
uid: undefined,
377+
uuid: 'theme-extension-name',
378+
assets: undefined,
379+
target: '',
380+
config: expect.any(Object),
381+
},
382+
],
383+
},
308384
appId: 'app-id',
309385
apiKey: 'api-key',
310386
name: app.name,
@@ -352,6 +428,21 @@ describe('deploy', () => {
352428

353429
// Then
354430
expect(uploadExtensionsBundle).toHaveBeenCalledWith({
431+
appManifest: {
432+
name: 'App',
433+
handle: '',
434+
modules: [
435+
{
436+
type: 'point_of_sale_external',
437+
handle: 'point_of_sale',
438+
uid: 'point_of_sale',
439+
uuid: undefined,
440+
assets: 'point_of_sale',
441+
target: '',
442+
config: expect.any(Object),
443+
},
444+
],
445+
},
355446
appId: 'app-id',
356447
apiKey: 'api-key',
357448
name: app.name,
@@ -390,6 +481,21 @@ describe('deploy', () => {
390481

391482
// Then
392483
expect(uploadExtensionsBundle).toHaveBeenCalledWith({
484+
appManifest: {
485+
name: 'App',
486+
handle: '',
487+
modules: [
488+
{
489+
type: 'point_of_sale_external',
490+
handle: 'point_of_sale',
491+
uid: 'point_of_sale',
492+
uuid: undefined,
493+
assets: 'point_of_sale',
494+
target: '',
495+
config: expect.any(Object),
496+
},
497+
],
498+
},
393499
appId: 'app-id',
394500
apiKey: 'api-key',
395501
name: app.name,

packages/app/src/cli/services/deploy.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -207,6 +207,8 @@ export async function deploy(options: DeployOptions) {
207207
await mkdir(dirname(bundlePath))
208208
}
209209

210+
const appManifest = await app.manifest(identifiers)
211+
210212
await bundleAndBuildExtensions({
211213
app,
212214
bundlePath,
@@ -240,6 +242,7 @@ export async function deploy(options: DeployOptions) {
240242
)
241243

242244
uploadExtensionsBundleResult = await uploadExtensionsBundle({
245+
appManifest,
243246
appId: remoteApp.id,
244247
apiKey,
245248
name: app.name,

packages/app/src/cli/services/deploy/upload.test.ts

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import {deploymentErrorsToCustomSections, uploadExtensionsBundle} from './upload.js'
2-
import {testDeveloperPlatformClient} from '../../models/app/app.test-data.js'
2+
import {testApp, testDeveloperPlatformClient} from '../../models/app/app.test-data.js'
33
import {AppDeploySchema, AppDeployVariables} from '../../api/graphql/app_deploy.js'
44
import {describe, expect, test, vi} from 'vitest'
55
import {inTemporaryDirectory, writeFile} from '@shopify/cli-kit/node/fs'
@@ -9,6 +9,9 @@ import {joinPath} from '@shopify/cli-kit/node/path'
99
vi.mock('@shopify/cli-kit/node/http')
1010
vi.mock('@shopify/cli-kit/node/crypto')
1111

12+
const app = testApp()
13+
const appManifest = await app.manifest(undefined)
14+
1215
describe('uploadExtensionsBundle', () => {
1316
test('calls a mutation on partners', async () => {
1417
await inTemporaryDirectory(async (tmpDir) => {
@@ -20,6 +23,7 @@ describe('uploadExtensionsBundle', () => {
2023
// When
2124
await writeFile(joinPath(tmpDir, 'test.zip'), '')
2225
await uploadExtensionsBundle({
26+
appManifest,
2327
appId: '1',
2428
apiKey: 'app-id',
2529
name: 'appName',
@@ -35,6 +39,7 @@ describe('uploadExtensionsBundle', () => {
3539

3640
// Then
3741
expect(developerPlatformClient.deploy).toHaveBeenCalledWith({
42+
appManifest,
3843
appId: '1',
3944
apiKey: 'app-id',
4045
name: 'appName',
@@ -64,6 +69,7 @@ describe('uploadExtensionsBundle', () => {
6469
// When
6570
await writeFile(joinPath(tmpDir, 'test.zip'), '')
6671
await uploadExtensionsBundle({
72+
appManifest,
6773
appId: '1',
6874
apiKey: 'app-id',
6975
name: 'appName',
@@ -81,6 +87,7 @@ describe('uploadExtensionsBundle', () => {
8187

8288
// Then
8389
expect(developerPlatformClient.deploy).toHaveBeenCalledWith({
90+
appManifest,
8491
appId: '1',
8592
apiKey: 'app-id',
8693
name: 'appName',
@@ -108,6 +115,7 @@ describe('uploadExtensionsBundle', () => {
108115
vi.mocked<any>(formData).mockReturnValue(mockedFormData)
109116
// When
110117
await uploadExtensionsBundle({
118+
appManifest,
111119
appId: '1',
112120
apiKey: 'app-id',
113121
name: 'appName',
@@ -121,6 +129,7 @@ describe('uploadExtensionsBundle', () => {
121129

122130
// Then
123131
expect(developerPlatformClient.deploy).toHaveBeenCalledWith({
132+
appManifest,
124133
appId: '1',
125134
apiKey: 'app-id',
126135
name: 'appName',
@@ -221,6 +230,7 @@ describe('uploadExtensionsBundle', () => {
221230
// Then
222231
try {
223232
await uploadExtensionsBundle({
233+
appManifest,
224234
appId: '1',
225235
apiKey: 'app-id',
226236
name: 'appName',
@@ -323,6 +333,7 @@ describe('uploadExtensionsBundle', () => {
323333

324334
// When
325335
const result = await uploadExtensionsBundle({
336+
appManifest,
326337
appId: '1',
327338
apiKey: 'app-id',
328339
name: 'appName',

packages/app/src/cli/services/deploy/upload.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,14 @@ import {AppDeploySchema, AppModuleSettings} from '../../api/graphql/app_deploy.j
33

44
import {AppDeployOptions, DeveloperPlatformClient} from '../../utilities/developer-platform-client.js'
55
import {getUploadURL, uploadToGCS} from '../bundle.js'
6+
import {AppManifest} from '../../models/app/app.js'
67
import {AbortError} from '@shopify/cli-kit/node/error'
78
import {AlertCustomSection, ListToken, TokenItem} from '@shopify/cli-kit/node/ui'
89
import {partition} from '@shopify/cli-kit/common/collection'
910

1011
interface UploadExtensionsBundleOptions {
12+
appManifest: AppManifest
13+
1114
/** The ID of the application */
1215
appId: string
1316

@@ -87,6 +90,7 @@ export async function uploadExtensionsBundle(
8790
}
8891

8992
const variables: AppDeployOptions = {
93+
appManifest: options.appManifest,
9094
appId: options.appId,
9195
apiKey: options.apiKey,
9296
name: options.name,

packages/app/src/cli/utilities/developer-platform-client.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,7 @@ export type AppVersionWithContext = AppVersion & {
144144
}
145145

146146
export type AppDeployOptions = AppDeployVariables & {
147+
appManifest: AppManifest
147148
appId: string
148149
organizationId: string
149150
name: string

0 commit comments

Comments
 (0)