Skip to content

Commit 5c059bf

Browse files
dejmedusisaacroldan
authored andcommitted
Allow "one of" multi env flag requirements
Previously, the multi environment required flags array was flat and any missing flag would cause validation to fail. However, some commands provide a few different flags that will meet the same req. This commit updates validation logic to take in a nested array to account for this. Example: `['name', ['theme', 'live', 'development']]` To run with multiple environments, `name` flag and one of `theme`, `live`, or `development` are required
1 parent 930306b commit 5c059bf

File tree

3 files changed

+94
-2
lines changed

3 files changed

+94
-2
lines changed

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

Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -575,6 +575,98 @@ describe('ensureDeployContext', () => {
575575
})
576576
unsetAppConfigValueSpy.mockRestore()
577577
})
578+
579+
test('sets didMigrateExtensionsToDevDash to true when app modules are missing registration UUIDs', async () => {
580+
// Given
581+
const app = testAppWithConfig({config: {client_id: APP2.apiKey}})
582+
const identifiers = {
583+
app: APP2.apiKey,
584+
extensions: {},
585+
extensionIds: {},
586+
extensionsNonUuidManaged: {},
587+
}
588+
vi.mocked(ensureDeploymentIdsPresence).mockResolvedValue(identifiers)
589+
vi.mocked(getAppConfigurationFileName).mockReturnValue('shopify.app.toml')
590+
591+
const activeAppVersion = {
592+
appModuleVersions: [
593+
{registrationId: 'id-1', registrationUuid: 'uuid-1', type: 'app_access', registrationTitle: 'module-1'},
594+
{registrationId: '', registrationUuid: 'uuid-2', type: 'pos_ui_extension', registrationTitle: 'module-2'},
595+
{
596+
registrationId: 'id-3',
597+
registrationUuid: 'uuid-3',
598+
type: 'checkout_ui_extension',
599+
registrationTitle: 'module-3',
600+
},
601+
],
602+
}
603+
604+
const developerPlatformClient = buildDeveloperPlatformClient({
605+
supportsAtomicDeployments: true,
606+
activeAppVersion: () => Promise.resolve(activeAppVersion),
607+
})
608+
609+
// When
610+
const result = await ensureDeployContext({
611+
app,
612+
remoteApp: APP2,
613+
organization: ORG1,
614+
reset: false,
615+
force: false,
616+
noRelease: false,
617+
developerPlatformClient,
618+
skipBuild: false,
619+
})
620+
621+
// Then
622+
expect(result.didMigrateExtensionsToDevDash).toBe(true)
623+
})
624+
625+
test('sets didMigrateExtensionsToDevDash to false when all app modules have registration UUIDs', async () => {
626+
// Given
627+
const app = testAppWithConfig({config: {client_id: APP2.apiKey}})
628+
const identifiers = {
629+
app: APP2.apiKey,
630+
extensions: {},
631+
extensionIds: {},
632+
extensionsNonUuidManaged: {},
633+
}
634+
vi.mocked(ensureDeploymentIdsPresence).mockResolvedValue(identifiers)
635+
vi.mocked(getAppConfigurationFileName).mockReturnValue('shopify.app.toml')
636+
637+
const activeAppVersion = {
638+
appModuleVersions: [
639+
{registrationId: 'id-1', registrationUuid: 'uuid-1', type: 'app_access', registrationTitle: 'module-1'},
640+
{registrationId: 'id-2', registrationUuid: 'uuid-2', type: 'pos_ui_extension', registrationTitle: 'module-2'},
641+
{
642+
registrationId: 'id-3',
643+
registrationUuid: 'uuid-3',
644+
type: 'checkout_ui_extension',
645+
registrationTitle: 'module-3',
646+
},
647+
],
648+
}
649+
650+
const developerPlatformClient = buildDeveloperPlatformClient({
651+
supportsAtomicDeployments: true,
652+
activeAppVersion: () => Promise.resolve(activeAppVersion),
653+
})
654+
655+
// When
656+
const result = await ensureDeployContext({
657+
app,
658+
remoteApp: APP2,
659+
organization: ORG1,
660+
reset: false,
661+
force: false,
662+
noRelease: false,
663+
developerPlatformClient,
664+
skipBuild: false,
665+
})
666+
667+
// Then
668+
expect(result.didMigrateExtensionsToDevDash).toBe(false)
669+
})
578670
})
579671

580672
describe('ensureThemeExtensionDevContext', () => {

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,7 @@ export async function ensureDeployContext(options: DeployOptions): Promise<Ensur
168168
// if the current active app version is missing user_identifiers in some app module, then we are migrating to dev dash
169169
let didMigrateExtensionsToDevDash = false
170170
if (developerPlatformClient.supportsAtomicDeployments && activeAppVersion) {
171-
const missingUids = activeAppVersion.appModuleVersions.some((version) => !version.registrationUuid)
171+
const missingUids = activeAppVersion.appModuleVersions.some((version) => !version.registrationId)
172172
didMigrateExtensionsToDevDash = missingUids
173173
}
174174

packages/theme/src/cli/utilities/theme-command.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ export default abstract class ThemeCommand extends Command {
7373
>(_opts?: Input<TFlags, TGlobalFlags, TArgs>): Promise<void> {
7474
// Parse command flags using the current command class definitions
7575
const klass = this.constructor as unknown as Input<TFlags, TGlobalFlags, TArgs> & {
76-
multiEnvironmentsFlags: string[] | null
76+
multiEnvironmentsFlags: RequiredFlags
7777
flags: FlagOutput
7878
}
7979
const requiredFlags = klass.multiEnvironmentsFlags

0 commit comments

Comments
 (0)