From 8ae96774c7df4c6c85da3f2b9966316ad3897a20 Mon Sep 17 00:00:00 2001 From: gracejychang Date: Thu, 1 Aug 2024 15:24:09 -0700 Subject: [PATCH] use showDomainOnPrompts instead of passing down clientName, make clientName enum --- packages/app/src/cli/prompts/dev.ts | 4 ++-- packages/app/src/cli/services/dev/select-store.ts | 9 ++++----- .../app/src/cli/utilities/developer-platform-client.ts | 5 +++++ .../developer-platform-client/app-management-client.ts | 3 ++- .../developer-platform-client/partners-client.ts | 3 ++- 5 files changed, 15 insertions(+), 9 deletions(-) diff --git a/packages/app/src/cli/prompts/dev.ts b/packages/app/src/cli/prompts/dev.ts index b32a7485d7..f3383a7eac 100644 --- a/packages/app/src/cli/prompts/dev.ts +++ b/packages/app/src/cli/prompts/dev.ts @@ -59,7 +59,7 @@ export async function selectAppPrompt( export async function selectStorePrompt( stores: OrganizationStore[], - clientName: string, + showDomainOnPrompt: boolean, ): Promise { if (stores.length === 0) return undefined if (stores.length === 1) { @@ -69,7 +69,7 @@ export async function selectStorePrompt( const storeList = stores.map((store) => { let label = store.shopName - if (clientName === 'app-management') { + if (showDomainOnPrompt) { label = `${store.shopName} (${store.shopDomain})` } return {label, value: store.shopId} diff --git a/packages/app/src/cli/services/dev/select-store.ts b/packages/app/src/cli/services/dev/select-store.ts index 4c3b055162..11ba84730e 100644 --- a/packages/app/src/cli/services/dev/select-store.ts +++ b/packages/app/src/cli/services/dev/select-store.ts @@ -8,7 +8,7 @@ import { ConvertDevToTransferDisabledSchema, ConvertDevToTransferDisabledStoreVariables, } from '../../api/graphql/convert_dev_to_transfer_disabled_store.js' -import {DeveloperPlatformClient} from '../../utilities/developer-platform-client.js' +import {ClientName, DeveloperPlatformClient} from '../../utilities/developer-platform-client.js' import {sleep} from '@shopify/cli-kit/node/system' import {renderTasks} from '@shopify/cli-kit/node/ui' import {partnersFqdn} from '@shopify/cli-kit/node/context/fqdn' @@ -39,11 +39,10 @@ export async function selectStore( org: Organization, developerPlatformClient: DeveloperPlatformClient, ): Promise { - const clientName = developerPlatformClient.clientName - + const showDomainOnPrompt = developerPlatformClient.clientName === ClientName.AppManagement // If no stores, guide the developer through creating one // Then, with a store selected, make sure its transfer-disabled, prompting to convert if needed - let store = await selectStorePrompt(stores, clientName) + let store = await selectStorePrompt(stores, showDomainOnPrompt) if (!store) { outputInfo(`\n${await CreateStoreLink(org.id)}`) await sleep(5) @@ -65,7 +64,7 @@ export async function selectStore( ) while (!storeIsValid) { // eslint-disable-next-line no-await-in-loop - store = await selectStorePrompt(stores, clientName) + store = await selectStorePrompt(stores, showDomainOnPrompt) if (!store) { throw new CancelExecution() } diff --git a/packages/app/src/cli/utilities/developer-platform-client.ts b/packages/app/src/cli/utilities/developer-platform-client.ts index 6b07a0a811..1e0b86c4b6 100644 --- a/packages/app/src/cli/utilities/developer-platform-client.ts +++ b/packages/app/src/cli/utilities/developer-platform-client.ts @@ -58,6 +58,11 @@ import {DevSessionDeleteMutation} from '../api/graphql/app-dev/generated/dev-ses import {FunctionUploadUrlGenerateResponse} from '@shopify/cli-kit/node/api/partners' import {isTruthy} from '@shopify/cli-kit/node/context/utilities' +export enum ClientName { + AppManagement = 'app-management', + Partners = 'partners', +} + export type Paginateable = T & { hasMorePages: boolean } diff --git a/packages/app/src/cli/utilities/developer-platform-client/app-management-client.ts b/packages/app/src/cli/utilities/developer-platform-client/app-management-client.ts index e5debc6e63..3053d3c86a 100644 --- a/packages/app/src/cli/utilities/developer-platform-client/app-management-client.ts +++ b/packages/app/src/cli/utilities/developer-platform-client/app-management-client.ts @@ -48,6 +48,7 @@ import { AppVersionIdentifiers, DevSessionOptions, filterDisabledFlags, + ClientName, } from '../developer-platform-client.js' import {PartnersSession} from '../../services/context/partner-account-info.js' import { @@ -145,7 +146,7 @@ export interface GatedExtensionTemplate extends ExtensionTemplate { } export class AppManagementClient implements DeveloperPlatformClient { - public clientName = 'app-management' + public clientName = ClientName.AppManagement public webUiName = 'Developer Dashboard' public requiresOrganization = true public supportsAtomicDeployments = true diff --git a/packages/app/src/cli/utilities/developer-platform-client/partners-client.ts b/packages/app/src/cli/utilities/developer-platform-client/partners-client.ts index 73f83315f1..ee5800577b 100644 --- a/packages/app/src/cli/utilities/developer-platform-client/partners-client.ts +++ b/packages/app/src/cli/utilities/developer-platform-client/partners-client.ts @@ -13,6 +13,7 @@ import { Paginateable, DevSessionOptions, filterDisabledFlags, + ClientName, } from '../developer-platform-client.js' import {fetchCurrentAccountInformation, PartnersSession} from '../../../cli/services/context/partner-account-info.js' import { @@ -209,7 +210,7 @@ interface OrgAndAppsResponse { } export class PartnersClient implements DeveloperPlatformClient { - public clientName = 'partners' + public clientName = ClientName.Partners public webUiName = 'Partner Dashboard' public supportsAtomicDeployments = false public requiresOrganization = false