Skip to content

Commit 4ab8fdc

Browse files
authored
Merge pull request #6240 from Shopify/08-11-show_the_uid_in_the_deploy_prompt
Show the UID in the deploy prompt
2 parents 76086bc + 0372d4f commit 4ab8fdc

File tree

6 files changed

+93
-60
lines changed

6 files changed

+93
-60
lines changed

packages/app/src/cli/prompts/deploy-release.test.ts

Lines changed: 20 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ describe('deployOrReleaseConfirmationPrompt', () => {
125125
{
126126
header: 'Extensions:',
127127
items: [
128-
{bullet: '+', item: ['to create extension', {subdued: '(new)'}], color: 'green'},
128+
{bullet: '+', item: ['to create extension (uid: uid-create)', {subdued: '(new)'}], color: 'green'},
129129
{item: ['to update extension', {subdued: '(updated)'}], color: '#FF8800'},
130130
'unchanged extension',
131131
['from dashboard extension', {subdued: '(from Partner Dashboard)'}],
@@ -181,7 +181,7 @@ describe('deployOrReleaseConfirmationPrompt', () => {
181181
header: 'Extensions:',
182182
helperText: 'Removing extensions can permanently delete app user data',
183183
items: [
184-
{bullet: '+', item: ['to create extension', {subdued: '(new)'}], color: 'green'},
184+
{bullet: '+', item: ['to create extension (uid: uid-create)', {subdued: '(new)'}], color: 'green'},
185185
{
186186
bullet: '+',
187187
item: ['to create dashboard', {subdued: '(new, from Partner Dashboard)'}],
@@ -190,7 +190,7 @@ describe('deployOrReleaseConfirmationPrompt', () => {
190190
{item: ['to update extension', {subdued: '(updated)'}], color: '#FF8800'},
191191
'unchanged extension',
192192
['from dashboard extension', {subdued: '(from Partner Dashboard)'}],
193-
{bullet: '-', item: ['remote extension', {subdued: '(removed)'}], color: 'red'},
193+
{bullet: '-', item: ['remote extension (uid: uid-remove)', {subdued: '(removed)'}], color: 'red'},
194194
{bullet: '-', item: ['remote dashboard', {subdued: '(removed, from Partner Dashboard)'}], color: 'red'},
195195
],
196196
},
@@ -239,11 +239,11 @@ describe('deployOrReleaseConfirmationPrompt', () => {
239239
{
240240
header: 'Extensions:',
241241
items: [
242-
{bullet: '+', item: ['to create extension', {subdued: '(new)'}], color: 'green'},
242+
{bullet: '+', item: ['to create extension (uid: uid-create)', {subdued: '(new)'}], color: 'green'},
243243
{item: ['to update extension', {subdued: '(updated)'}], color: '#FF8800'},
244244
'unchanged extension',
245245
['from dashboard extension', {subdued: '(from Partner Dashboard)'}],
246-
{bullet: '-', item: ['remote extension', {subdued: '(removed)'}], color: 'red'},
246+
{bullet: '-', item: ['remote extension (uid: uid-remove)', {subdued: '(removed)'}], color: 'red'},
247247
],
248248
},
249249
],
@@ -284,11 +284,11 @@ describe('deployOrReleaseConfirmationPrompt', () => {
284284
{
285285
header: 'Extensions:',
286286
items: [
287-
{bullet: '+', item: ['to create extension', {subdued: '(new)'}], color: 'green'},
287+
{bullet: '+', item: ['to create extension (uid: uid-create)', {subdued: '(new)'}], color: 'green'},
288288
{item: ['to update extension', {subdued: '(updated)'}], color: '#FF8800'},
289289
'unchanged extension',
290290
['from dashboard extension', {subdued: '(from Partner Dashboard)'}],
291-
{bullet: '-', item: ['remote extension', {subdued: '(removed)'}], color: 'red'},
291+
{bullet: '-', item: ['remote extension (uid: uid-remove)', {subdued: '(removed)'}], color: 'red'},
292292
],
293293
},
294294
],
@@ -337,11 +337,11 @@ describe('deployOrReleaseConfirmationPrompt', () => {
337337
header: 'Extensions:',
338338
helperText: 'Removing extensions can permanently delete app user data',
339339
items: [
340-
{bullet: '+', item: ['to create extension', {subdued: '(new)'}], color: 'green'},
340+
{bullet: '+', item: ['to create extension (uid: uid-create)', {subdued: '(new)'}], color: 'green'},
341341
{item: ['to update extension', {subdued: '(updated)'}], color: '#FF8800'},
342342
'unchanged extension',
343343
['from dashboard extension', {subdued: '(from Partner Dashboard)'}],
344-
{bullet: '-', item: ['remote extension', {subdued: '(removed)'}], color: 'red'},
344+
{bullet: '-', item: ['remote extension (uid: uid-remove)', {subdued: '(removed)'}], color: 'red'},
345345
],
346346
},
347347
],
@@ -393,7 +393,7 @@ describe('deployOrReleaseConfirmationPrompt', () => {
393393
{
394394
header: 'Extensions:',
395395
items: [
396-
{bullet: '+', item: ['to create extension', {subdued: '(new)'}], color: 'green'},
396+
{bullet: '+', item: ['to create extension (uid: uid-create)', {subdued: '(new)'}], color: 'green'},
397397
{item: ['to update extension', {subdued: '(updated)'}], color: '#FF8800'},
398398
'unchanged extension',
399399
['from dashboard extension', {subdued: '(from Partner Dashboard)'}],
@@ -433,14 +433,20 @@ function renderConfirmationPromptContent(options: RenderConfirmationPromptConten
433433
function buildCompleteBreakdownInfo() {
434434
const emptyBreakdownInfo = buildEmptyBreakdownInfo()
435435

436-
emptyBreakdownInfo.extensionIdentifiersBreakdown.onlyRemote.push(buildExtensionBreakdownInfo('remote extension'))
437-
emptyBreakdownInfo.extensionIdentifiersBreakdown.toCreate.push(buildExtensionBreakdownInfo('to create extension'))
436+
emptyBreakdownInfo.extensionIdentifiersBreakdown.onlyRemote.push(
437+
buildExtensionBreakdownInfo('remote extension', 'uid-remove'),
438+
)
439+
emptyBreakdownInfo.extensionIdentifiersBreakdown.toCreate.push(
440+
buildExtensionBreakdownInfo('to create extension', 'uid-create'),
441+
)
438442
emptyBreakdownInfo.extensionIdentifiersBreakdown.unchanged.push(
439-
buildExtensionBreakdownInfo('unchanged extension'),
443+
buildExtensionBreakdownInfo('unchanged extension', undefined),
440444
buildDashboardBreakdownInfo('from dashboard extension'),
441445
)
442446

443-
emptyBreakdownInfo.extensionIdentifiersBreakdown.toUpdate.push(buildExtensionBreakdownInfo('to update extension'))
447+
emptyBreakdownInfo.extensionIdentifiersBreakdown.toUpdate.push(
448+
buildExtensionBreakdownInfo('to update extension', undefined),
449+
)
444450

445451
emptyBreakdownInfo.configExtensionIdentifiersBreakdown!.existingFieldNames.push('existing field name1')
446452
emptyBreakdownInfo.configExtensionIdentifiersBreakdown!.existingUpdatedFieldNames.push('updating field name1')

packages/app/src/cli/prompts/deploy-release.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,11 @@ async function buildExtensionsContentPrompt(extensionsContentBreakdown: Extensio
110110
case 'dashboard':
111111
return [extension.title, {subdued: `(${preffix}from Partner Dashboard)`}]
112112
case 'extension':
113-
return extension.title
113+
if (extension.uid && extension.uid.length > 0) {
114+
return `${extension.title} (uid: ${extension.uid})`
115+
} else {
116+
return extension.title
117+
}
114118
}
115119
}
116120
let extensionsInfoTable

packages/app/src/cli/services/context/breakdown-extensions.test.ts

Lines changed: 33 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -427,7 +427,10 @@ describe('extensionsIdentifiersDeployBreakdown', () => {
427427
extensionIdentifiersBreakdown: {
428428
onlyRemote: [],
429429
toCreate: [],
430-
unchanged: [buildExtensionBreakdownInfo('EXTENSION_A'), buildExtensionBreakdownInfo('extension-a-2')],
430+
unchanged: [
431+
buildExtensionBreakdownInfo('EXTENSION_A', undefined),
432+
buildExtensionBreakdownInfo('extension-a-2', undefined),
433+
],
431434
toUpdate: [],
432435
},
433436
extensionsToConfirm,
@@ -464,8 +467,8 @@ describe('extensionsIdentifiersDeployBreakdown', () => {
464467
extensionIdentifiersBreakdown: {
465468
onlyRemote: [],
466469
toCreate: [
467-
buildExtensionBreakdownInfo('EXTENSION_A'),
468-
buildExtensionBreakdownInfo('extension-a-2'),
470+
buildExtensionBreakdownInfo('EXTENSION_A', 'UUID_A'),
471+
buildExtensionBreakdownInfo('extension-a-2', 'test-ui-extension-uid'),
469472
buildDashboardBreakdownInfo('Dashboard A'),
470473
],
471474
toUpdate: [],
@@ -505,7 +508,10 @@ describe('extensionsIdentifiersDeployBreakdown', () => {
505508
expect(result).toEqual({
506509
extensionIdentifiersBreakdown: {
507510
onlyRemote: [],
508-
toCreate: [buildExtensionBreakdownInfo('EXTENSION_A'), buildExtensionBreakdownInfo('extension-a-2')],
511+
toCreate: [
512+
buildExtensionBreakdownInfo('EXTENSION_A', 'UUID_A'),
513+
buildExtensionBreakdownInfo('extension-a-2', 'test-ui-extension-uid'),
514+
],
509515
toUpdate: [],
510516
unchanged: [buildDashboardBreakdownInfo('Dashboard A')],
511517
},
@@ -551,9 +557,12 @@ describe('extensionsIdentifiersDeployBreakdown', () => {
551557
expect(result).toEqual({
552558
extensionIdentifiersBreakdown: {
553559
onlyRemote: [],
554-
toCreate: [buildExtensionBreakdownInfo('extension-a-2')],
560+
toCreate: [buildExtensionBreakdownInfo('extension-a-2', 'test-ui-extension-uid')],
555561
toUpdate: [],
556-
unchanged: [buildExtensionBreakdownInfo('EXTENSION_A'), buildDashboardBreakdownInfo('Dashboard A')],
562+
unchanged: [
563+
buildExtensionBreakdownInfo('EXTENSION_A', undefined),
564+
buildDashboardBreakdownInfo('Dashboard A'),
565+
],
557566
},
558567
extensionsToConfirm,
559568
remoteExtensionsRegistrations: remoteExtensionRegistrations.app,
@@ -598,11 +607,14 @@ describe('extensionsIdentifiersDeployBreakdown', () => {
598607
extensionIdentifiersBreakdown: {
599608
onlyRemote: [],
600609
toCreate: [
601-
buildExtensionBreakdownInfo('DASH_MIGRATED_EXTENSION_A'),
602-
buildExtensionBreakdownInfo('extension-a-2'),
610+
buildExtensionBreakdownInfo('DASH_MIGRATED_EXTENSION_A', 'UUID_DM_A'),
611+
buildExtensionBreakdownInfo('extension-a-2', 'test-ui-extension-uid'),
603612
],
604613
toUpdate: [],
605-
unchanged: [buildExtensionBreakdownInfo('EXTENSION_A'), buildDashboardBreakdownInfo('Dashboard A')],
614+
unchanged: [
615+
buildExtensionBreakdownInfo('EXTENSION_A', undefined),
616+
buildDashboardBreakdownInfo('Dashboard A'),
617+
],
606618
},
607619
extensionsToConfirm,
608620
remoteExtensionsRegistrations: remoteExtensionRegistrations.app,
@@ -650,16 +662,19 @@ describe('extensionsIdentifiersDeployBreakdown', () => {
650662
expect(result).toEqual({
651663
extensionIdentifiersBreakdown: {
652664
onlyRemote: [
653-
buildExtensionBreakdownInfo('Checkout post purchase Deleted B'),
665+
buildExtensionBreakdownInfo('Checkout post purchase Deleted B', 'B'),
654666
buildDashboardBreakdownInfo('Dashboard Deleted B'),
655667
],
656668
toCreate: [
657-
buildExtensionBreakdownInfo('DASH_MIGRATED_EXTENSION_A'),
658-
buildExtensionBreakdownInfo('extension-a-2'),
669+
buildExtensionBreakdownInfo('DASH_MIGRATED_EXTENSION_A', 'UUID_DM_A'),
670+
buildExtensionBreakdownInfo('extension-a-2', 'test-ui-extension-uid'),
659671
buildDashboardBreakdownInfo('Dashboard New'),
660672
],
661673
toUpdate: [],
662-
unchanged: [buildExtensionBreakdownInfo('EXTENSION_A'), buildDashboardBreakdownInfo('Dashboard A')],
674+
unchanged: [
675+
buildExtensionBreakdownInfo('EXTENSION_A', undefined),
676+
buildDashboardBreakdownInfo('Dashboard A'),
677+
],
663678
},
664679
extensionsToConfirm,
665680
remoteExtensionsRegistrations: remoteExtensionRegistrations.app,
@@ -704,8 +719,8 @@ describe('extensionsIdentifiersDeployBreakdown', () => {
704719
expect(result).toEqual({
705720
extensionIdentifiersBreakdown: {
706721
onlyRemote: [],
707-
toCreate: [buildExtensionBreakdownInfo('extension-a-2')],
708-
toUpdate: [buildExtensionBreakdownInfo('EXTENSION_A')],
722+
toCreate: [buildExtensionBreakdownInfo('extension-a-2', 'test-ui-extension-uid')],
723+
toUpdate: [buildExtensionBreakdownInfo('EXTENSION_A', undefined)],
709724
unchanged: [buildDashboardBreakdownInfo('Dashboard A')],
710725
},
711726
extensionsToConfirm,
@@ -775,8 +790,8 @@ describe('extensionsIdentifiersReleaseBreakdown', () => {
775790
// Then
776791
expect(result).toEqual({
777792
extensionIdentifiersBreakdown: {
778-
onlyRemote: [buildExtensionBreakdownInfo('Checkout post purchase Deleted B')],
779-
toCreate: [buildExtensionBreakdownInfo('Checkout post purchase')],
793+
onlyRemote: [buildExtensionBreakdownInfo('Checkout post purchase Deleted B', undefined)],
794+
toCreate: [buildExtensionBreakdownInfo('Checkout post purchase', undefined)],
780795
toUpdate: [],
781796
unchanged: [buildDashboardBreakdownInfo('Dashboard A')],
782797
},
@@ -811,7 +826,7 @@ describe('extensionsIdentifiersReleaseBreakdown', () => {
811826
extensionIdentifiersBreakdown: {
812827
toCreate: [],
813828
toUpdate: [],
814-
onlyRemote: [buildExtensionBreakdownInfo('Checkout post purchase Deleted B')],
829+
onlyRemote: [buildExtensionBreakdownInfo('Checkout post purchase Deleted B', undefined)],
815830
unchanged: [],
816831
},
817832
versionDetails: versionDiff.versionDetails,

packages/app/src/cli/services/context/breakdown-extensions.ts

Lines changed: 32 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -34,15 +34,16 @@ export interface ConfigExtensionIdentifiersBreakdown {
3434

3535
export interface ExtensionIdentifierBreakdownInfo {
3636
title: string
37+
uid: string | undefined
3738
experience: 'extension' | 'dashboard'
3839
}
3940

40-
export function buildExtensionBreakdownInfo(title: string): ExtensionIdentifierBreakdownInfo {
41-
return {title, experience: 'extension'}
41+
export function buildExtensionBreakdownInfo(title: string, uid: string | undefined): ExtensionIdentifierBreakdownInfo {
42+
return {title, uid, experience: 'extension'}
4243
}
4344

4445
export function buildDashboardBreakdownInfo(title: string): ExtensionIdentifierBreakdownInfo {
45-
return {title, experience: 'dashboard'}
46+
return {title, uid: undefined, experience: 'dashboard'}
4647
}
4748

4849
export interface ExtensionIdentifiersBreakdown {
@@ -125,7 +126,7 @@ export async function extensionsIdentifiersReleaseBreakdown(
125126
extension.specification.experience === 'extension' &&
126127
extension.specification.identifier !== 'webhook_subscription',
127128
)
128-
.map((extension) => buildExtensionBreakdownInfo(extension.registrationTitle))
129+
.map((extension) => buildExtensionBreakdownInfo(extension.registrationTitle, undefined))
129130
const mapIsDashboard = (extensions: AppVersionsDiffExtensionSchema[]) =>
130131
extensions
131132
.filter((extension) => extension.specification.options.managementExperience === 'dashboard')
@@ -337,8 +338,12 @@ function loadLocalExtensionsIdentifiersBreakdown({
337338
extensionsToCreate: LocalSource[]
338339
dashboardOnlyExtensions: RemoteSource[]
339340
}): ExtensionIdentifiersBreakdown {
340-
const identifiersToUpdate = Object.keys(localRegistration).map(buildExtensionBreakdownInfo)
341-
const identifiersToCreate = localSourceToCreate.map((source) => buildExtensionBreakdownInfo(source.localIdentifier))
341+
const identifiersToUpdate = Object.keys(localRegistration).map((identifier) =>
342+
buildExtensionBreakdownInfo(identifier, undefined),
343+
)
344+
const identifiersToCreate = localSourceToCreate.map((source) =>
345+
buildExtensionBreakdownInfo(source.localIdentifier, undefined),
346+
)
342347
const dashboardToUpdate = dashboardOnlyExtensions
343348
.filter((dashboard) => !Object.values(localRegistration).includes(dashboard.uuid))
344349
.map((dashboard) => buildDashboardBreakdownInfo(dashboard.title))
@@ -353,7 +358,7 @@ function loadLocalExtensionsIdentifiersBreakdown({
353358
async function resolveRemoteExtensionIdentifiersBreakdown(
354359
developerPlatformClient: DeveloperPlatformClient,
355360
remoteApp: MinimalOrganizationApp,
356-
localRegistration: IdentifiersExtensions,
361+
validMatches: IdentifiersExtensions,
357362
toCreate: LocalSource[],
358363
dashboardOnly: RemoteSource[],
359364
specs: ExtensionSpecification[],
@@ -364,15 +369,15 @@ async function resolveRemoteExtensionIdentifiersBreakdown(
364369

365370
const extensionIdentifiersBreakdown = loadExtensionsIdentifiersBreakdown(
366371
version,
367-
localRegistration,
372+
validMatches,
368373
toCreate,
369374
specs,
370375
developerPlatformClient,
371376
)
372377

373378
const dashboardOnlyFinal = dashboardOnly.filter(
374379
(dashboardOnly) =>
375-
!Object.values(localRegistration).includes(dashboardOnly.uuid) &&
380+
!Object.values(validMatches).includes(dashboardOnly.uuid) &&
376381
!toCreate.map((source) => source.localIdentifier).includes(dashboardOnly.uuid),
377382
)
378383
const dashboardIdentifiersBreakdown = loadDashboardIdentifiersBreakdown(dashboardOnlyFinal, version)
@@ -387,7 +392,7 @@ async function resolveRemoteExtensionIdentifiersBreakdown(
387392

388393
function loadExtensionsIdentifiersBreakdown(
389394
activeAppVersion: AppVersion,
390-
localRegistration: IdentifiersExtensions,
395+
validMatches: IdentifiersExtensions,
391396
toCreate: LocalSource[],
392397
specs: ExtensionSpecification[],
393398
developerPlatformClient: DeveloperPlatformClient,
@@ -410,39 +415,44 @@ function loadExtensionsIdentifiersBreakdown(
410415
}
411416
}
412417

413-
const allExistingExtensions = Object.entries(localRegistration)
418+
const allExistingExtensions = Object.entries(validMatches)
414419
.filter(([_identifier, uuid]) => extensionModules.some((module) => moduleHasUUIDorUID(module, uuid)))
415420
.map(([identifier, _uuid]) => identifier)
416421

417422
// If registationId is empty, it means the extension doesn't have a UID yet, so this deploy will create one.
418423
const extensionsBeingMigratedToDevDash = extensionModules.filter((module) => module.registrationId === '')
419424
const extensionsToUpdate = allExistingExtensions.filter((identifier) =>
420-
extensionsBeingMigratedToDevDash.some((module) => module.registrationUuid === localRegistration[identifier]),
425+
extensionsBeingMigratedToDevDash.some((module) => module.registrationUuid === validMatches[identifier]),
421426
)
422427

423428
const unchangedExtensions = allExistingExtensions.filter(
424429
(identifier) =>
425-
!extensionsBeingMigratedToDevDash.some((module) => module.registrationUuid === localRegistration[identifier]),
430+
!extensionsBeingMigratedToDevDash.some((module) => module.registrationUuid === validMatches[identifier]),
426431
)
427432

428-
let extensionsToCreate = Object.entries(localRegistration)
433+
const extensionsToCreate = Object.entries(validMatches)
429434
.filter(([_identifier, uuid]) => !extensionModules.some((module) => moduleHasUUIDorUID(module, uuid)))
430-
.map(([identifier, _uuid]) => identifier)
431-
extensionsToCreate = Array.from(new Set(extensionsToCreate.concat(toCreate.map((source) => source.localIdentifier))))
435+
.map(([identifier, uuid]) => ({title: identifier, uid: uuid}))
436+
const originalToCreate = toCreate.map((source) => ({title: source.localIdentifier, uid: source.uid}))
437+
438+
originalToCreate.forEach((source) => {
439+
const index = extensionsToCreate.findIndex((extension) => extension.title === source.title)
440+
index === -1 ? extensionsToCreate.push(source) : (extensionsToCreate[index] = source)
441+
})
432442

433443
const extensionsOnlyRemote = extensionModules
434444
.filter(
435445
(module) =>
436-
!Object.values(localRegistration).some((uuid) => moduleHasUUIDorUID(module, uuid)) &&
446+
!Object.values(validMatches).some((uuid) => moduleHasUUIDorUID(module, uuid)) &&
437447
!toCreate.map((source) => source.localIdentifier).some((identifier) => moduleHasUUIDorUID(module, identifier)),
438448
)
439-
.map((module) => module.registrationTitle)
449+
.map((module) => ({title: module.registrationTitle, uid: module.registrationId}))
440450

441451
return {
442-
onlyRemote: extensionsOnlyRemote.map(buildExtensionBreakdownInfo),
443-
toCreate: extensionsToCreate.map(buildExtensionBreakdownInfo),
444-
toUpdate: extensionsToUpdate.map(buildExtensionBreakdownInfo),
445-
unchanged: unchangedExtensions.map(buildExtensionBreakdownInfo),
452+
onlyRemote: extensionsOnlyRemote.map(({title, uid}) => buildExtensionBreakdownInfo(title, uid)),
453+
toCreate: extensionsToCreate.map(({title, uid}) => buildExtensionBreakdownInfo(title, uid)),
454+
toUpdate: extensionsToUpdate.map((title) => buildExtensionBreakdownInfo(title, undefined)),
455+
unchanged: unchangedExtensions.map((title) => buildExtensionBreakdownInfo(title, undefined)),
446456
}
447457
}
448458

0 commit comments

Comments
 (0)