Skip to content

Commit

Permalink
Remove app prompt for both Partners and App Management apps
Browse files Browse the repository at this point in the history
  • Loading branch information
jamieguerrero committed Jan 13, 2025
1 parent 1547704 commit 55fe914
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 99 deletions.
4 changes: 2 additions & 2 deletions packages/app/src/cli/services/dev.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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
Expand Down
39 changes: 3 additions & 36 deletions packages/app/src/cli/services/dev/ui.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import {
testApp,
testDeveloperPlatformClient,
testFunctionExtension,
testOrganizationApp,
testThemeExtensions,
testUIExtension,
} from '../../models/app/app.test-data.js'
Expand Down Expand Up @@ -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('')
Expand All @@ -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(`
Expand All @@ -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(`
Expand Down
71 changes: 13 additions & 58 deletions packages/app/src/cli/services/dev/ui.tsx
Original file line number Diff line number Diff line change
@@ -1,67 +1,31 @@
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'
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}},
],
})
}
}
}

Expand Down Expand Up @@ -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},
Expand Down
6 changes: 3 additions & 3 deletions packages/app/src/cli/services/dev/urls.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import {updateURLsPrompt} from '../../prompts/dev.js'
import {
AppConfigurationInterface,
AppInterface,
AppLinkedInterface,
CurrentAppConfiguration,
isCurrentAppSchema,
} from '../../models/app/app.js'
Expand Down Expand Up @@ -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: {
Expand Down Expand Up @@ -243,7 +243,7 @@ interface ShouldOrPromptUpdateURLsOptions {
appDirectory: string
cachedUpdateURLs?: boolean
newApp?: boolean
localApp?: AppInterface
localApp?: AppLinkedInterface
apiKey: string
}

Expand Down

0 comments on commit 55fe914

Please sign in to comment.