From 55fe91418842bd6569f947db00ee7977fc37cdd1 Mon Sep 17 00:00:00 2001 From: Jamie Guerrero Date: Fri, 10 Jan 2025 12:34:29 -0500 Subject: [PATCH] Remove app prompt for both Partners and App Management apps --- packages/app/src/cli/services/dev.ts | 4 +- packages/app/src/cli/services/dev/ui.test.tsx | 39 +--------- packages/app/src/cli/services/dev/ui.tsx | 71 ++++--------------- packages/app/src/cli/services/dev/urls.ts | 6 +- 4 files changed, 21 insertions(+), 99 deletions(-) diff --git a/packages/app/src/cli/services/dev.ts b/packages/app/src/cli/services/dev.ts index a3e788a3cfb..de0515c6cb7 100644 --- a/packages/app/src/cli/services/dev.ts +++ b/packages/app/src/cli/services/dev.ts @@ -264,7 +264,7 @@ async function handleUpdatingOfPartnerUrls( const newURLs = generatePartnersURLs( network.proxyUrl, webs.map(({configuration}) => configuration.auth_callback_path).find((path) => path), - isCurrentAppSchema(localApp.configuration) ? localApp.configuration.app_proxy : undefined, + localApp.configuration.app_proxy, ) shouldUpdateURLs = await shouldOrPromptUpdateURLs({ currentURLs: network.currentUrls, @@ -277,7 +277,7 @@ async function handleUpdatingOfPartnerUrls( // When running dev app urls are pushed directly to API Client config instead of creating a new app version // so current app version and API Client config will have diferent url values. if (shouldUpdateURLs) await updateURLs(newURLs, apiKey, developerPlatformClient, localApp) - await outputUpdateURLsResult(shouldUpdateURLs, newURLs, remoteApp, localApp, developerPlatformClient) + await outputUpdateURLsResult(shouldUpdateURLs, newURLs, localApp) } } return shouldUpdateURLs diff --git a/packages/app/src/cli/services/dev/ui.test.tsx b/packages/app/src/cli/services/dev/ui.test.tsx index 478ee53bde0..ad41ac63e4d 100644 --- a/packages/app/src/cli/services/dev/ui.test.tsx +++ b/packages/app/src/cli/services/dev/ui.test.tsx @@ -4,7 +4,6 @@ import { testApp, testDeveloperPlatformClient, testFunctionExtension, - testOrganizationApp, testThemeExtensions, testUIExtension, } from '../../models/app/app.test-data.js' @@ -39,41 +38,13 @@ describe('output', () => { redirectUrlWhitelist: ['https://lala.cloudflare.io/auth/callback'], } - test('shows info about tunnel URL and links to Partners Dashboard when app is brand new', async () => { - // Given - const outputMock = mockAndCaptureOutput() - const localApp = await mockApp() - - const remoteApp = testOrganizationApp({newApp: true}) - - // When - await outputUpdateURLsResult(true, urls, remoteApp, localApp) - - // Then - expect(outputMock.output()).toMatchInlineSnapshot(` - "╭─ info ───────────────────────────────────────────────────────────────────────╮ - │ │ - │ For your convenience, we've given your app a default URL: │ - │ https://lala.cloudflare.io/. │ - │ │ - │ You can update your app's URL anytime in the Partners Dashboard [1] But │ - │ once your app is live, updating its URL will disrupt user access. │ - │ │ - ╰──────────────────────────────────────────────────────────────────────────────╯ - [1] https://partners.shopify.com/1/apps/1/edit - " - `) - }) - test('shows nothing when urls were updated', async () => { // Given const outputMock = mockAndCaptureOutput() const localApp = await mockApp() - const remoteApp = testOrganizationApp({newApp: false}) - // When - await outputUpdateURLsResult(true, urls, remoteApp, localApp) + await outputUpdateURLsResult(true, urls, localApp) // Then expect(outputMock.output()).toEqual('') @@ -84,10 +55,8 @@ describe('output', () => { const outputMock = mockAndCaptureOutput() const localApp = await mockApp() - const remoteApp = testOrganizationApp({newApp: false}) - // When - await outputUpdateURLsResult(false, urls, remoteApp, localApp) + await outputUpdateURLsResult(false, urls, localApp) // Then expect(outputMock.output()).toMatchInlineSnapshot(` @@ -110,10 +79,8 @@ describe('output', () => { const outputMock = mockAndCaptureOutput() const localApp = await mockApp(true) - const remoteApp = testOrganizationApp({newApp: false}) - // When - await outputUpdateURLsResult(false, urls, remoteApp, localApp) + await outputUpdateURLsResult(false, urls, localApp) // Then expect(outputMock.output()).toMatchInlineSnapshot(` diff --git a/packages/app/src/cli/services/dev/ui.tsx b/packages/app/src/cli/services/dev/ui.tsx index bf3199170a6..bdd638f0bc7 100644 --- a/packages/app/src/cli/services/dev/ui.tsx +++ b/packages/app/src/cli/services/dev/ui.tsx @@ -1,11 +1,8 @@ import {PartnersURLs} from './urls.js' import {Dev, DevProps} from './ui/components/Dev.js' -import {AppInterface, isCurrentAppSchema} from '../../models/app/app.js' -import {OrganizationApp} from '../../models/organization.js' +import {AppInterface} from '../../models/app/app.js' import {getAppConfigurationShorthand} from '../../models/app/loader.js' -import {ClientName, DeveloperPlatformClient} from '../../utilities/developer-platform-client.js' import React from 'react' -import {partnersFqdn} from '@shopify/cli-kit/node/context/fqdn' import {render, renderInfo} from '@shopify/cli-kit/node/ui' import {basename} from '@shopify/cli-kit/node/path' import {formatPackageManagerCommand} from '@shopify/cli-kit/node/output' @@ -13,55 +10,22 @@ import {terminalSupportsPrompting} from '@shopify/cli-kit/node/system' import {isTruthy} from '@shopify/cli-kit/node/context/utilities' import {isUnitTest} from '@shopify/cli-kit/node/context/local' -export async function outputUpdateURLsResult( - updated: boolean, - urls: PartnersURLs, - remoteApp: OrganizationApp, - localApp: AppInterface, - developerPlatformClient?: DeveloperPlatformClient, -) { - const usingAppManagementClient = developerPlatformClient?.clientName === ClientName.AppManagement - const dashboardURL = await partnersURL(remoteApp.organizationId, remoteApp.id) - if (remoteApp.newApp && !usingAppManagementClient) { +export async function outputUpdateURLsResult(updated: boolean, urls: PartnersURLs, localApp: AppInterface) { + if (!updated) { + const fileName = basename(localApp.configuration.path) + const configName = getAppConfigurationShorthand(fileName) + const pushCommandArgs = configName ? [`--config=${configName}`] : [] + renderInfo({ - headline: `For your convenience, we've given your app a default URL: ${urls.applicationUrl}.`, body: [ - "You can update your app's URL anytime in the", - dashboardURL, - 'But once your app is live, updating its URL will disrupt user access.', + `To update URLs manually, add the following URLs to ${fileName} under auth > redirect_urls and run\n`, + { + command: formatPackageManagerCommand(localApp.packageManager, `shopify app config push`, ...pushCommandArgs), + }, + '\n\n', + {list: {items: urls.redirectUrlWhitelist}}, ], }) - } else if (!updated) { - if (isCurrentAppSchema(localApp.configuration)) { - const fileName = basename(localApp.configuration.path) - const configName = getAppConfigurationShorthand(fileName) - const pushCommandArgs = configName ? [`--config=${configName}`] : [] - - renderInfo({ - body: [ - `To update URLs manually, add the following URLs to ${fileName} under auth > redirect_urls and run\n`, - { - command: formatPackageManagerCommand( - localApp.packageManager, - `shopify app config push`, - ...pushCommandArgs, - ), - }, - '\n\n', - {list: {items: urls.redirectUrlWhitelist}}, - ], - }) - } else { - renderInfo({ - body: [ - 'To make URL updates manually, you can add the following URLs as redirects in your', - dashboardURL, - {char: ':'}, - '\n\n', - {list: {items: urls.redirectUrlWhitelist}}, - ], - }) - } } } @@ -97,15 +61,6 @@ export async function renderDev({ } } -async function partnersURL(organizationId: string, appId: string) { - return { - link: { - label: 'Partners Dashboard', - url: `https://${await partnersFqdn()}/${organizationId}/apps/${appId}/edit`, - }, - } -} - async function renderDevNonInteractive({ processes, app: {canEnablePreviewMode}, diff --git a/packages/app/src/cli/services/dev/urls.ts b/packages/app/src/cli/services/dev/urls.ts index 42d8564b776..082769edc4a 100644 --- a/packages/app/src/cli/services/dev/urls.ts +++ b/packages/app/src/cli/services/dev/urls.ts @@ -1,7 +1,7 @@ import {updateURLsPrompt} from '../../prompts/dev.js' import { AppConfigurationInterface, - AppInterface, + AppLinkedInterface, CurrentAppConfiguration, isCurrentAppSchema, } from '../../models/app/app.js' @@ -202,7 +202,7 @@ export async function updateURLs( throw new AbortError(errors) } - if (localApp && isCurrentAppSchema(localApp.configuration) && localApp.configuration.client_id === apiKey) { + if (localApp && localApp.configuration.client_id === apiKey) { const patch = { application_url: urls.applicationUrl, auth: { @@ -243,7 +243,7 @@ interface ShouldOrPromptUpdateURLsOptions { appDirectory: string cachedUpdateURLs?: boolean newApp?: boolean - localApp?: AppInterface + localApp?: AppLinkedInterface apiKey: string }