Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/dev-local-url-fallback.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@shopify/app': patch
---

Show Local URL in dev info when no App URL is available
1 change: 1 addition & 0 deletions packages/app/src/cli/services/dev.ts
Original file line number Diff line number Diff line change
Expand Up @@ -439,6 +439,7 @@ async function launchDevProcesses({
appName: config.remoteApp.title,
organizationName: config.commandOptions.organization.businessName,
configPath: config.localApp.configPath,
localURL: config.network.proxyUrl,
})
}

Expand Down
3 changes: 3 additions & 0 deletions packages/app/src/cli/services/dev/ui.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,14 @@ export async function renderDev({
appName,
organizationName,
configPath,
localURL,
}: DevProps & {
devSessionStatusManager: DevSessionStatusManager
appURL?: string
appName?: string
organizationName?: string
configPath?: string
localURL?: string
}) {
if (!terminalSupportsPrompting()) {
await renderDevNonInteractive({processes, app, abortController, developerPreview, shopFqdn})
Expand All @@ -41,6 +43,7 @@ export async function renderDev({
appName={appName}
organizationName={organizationName}
configPath={configPath}
localURL={localURL}
onAbort={async () => {
await app.developerPlatformClient.devSessionDelete({appId: app.id, shopFqdn})
}}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -554,6 +554,64 @@ describe('DevSessionUI', () => {
renderInstance.unmount()
})

test('hides Local URL in app info when an app URL is available', async () => {
// Given
const renderInstance = render(
<DevSessionUI
processes={[]}
abortController={new AbortController()}
devSessionStatusManager={devSessionStatusManager}
shopFqdn="mystore.myshopify.com"
appURL="https://my-app.ngrok.io"
localURL="http://localhost:3000"
appName="My Test App"
onAbort={onAbort}
/>,
)

await waitForInputsToBeReady()

// When
await sendInputAndWait(renderInstance, 10, 'a')

// Then - only App URL is shown, Local URL is hidden
const output = unstyled(renderInstance.lastFrame()!)
expect(output).toContain('App URL:')
expect(output).toContain('https://my-app.ngrok.io')
expect(output).not.toContain('Local URL:')
expect(output).not.toContain('http://localhost:3000')

renderInstance.unmount()
})

test('shows Local URL in app info when no app URL is available', async () => {
// Given
const renderInstance = render(
<DevSessionUI
processes={[]}
abortController={new AbortController()}
devSessionStatusManager={devSessionStatusManager}
shopFqdn="mystore.myshopify.com"
localURL="http://localhost:3000"
appName="My Test App"
onAbort={onAbort}
/>,
)

await waitForInputsToBeReady()

// When
await sendInputAndWait(renderInstance, 10, 'a')

// Then - Local URL is shown in place of App URL
const output = unstyled(renderInstance.lastFrame()!)
expect(output).toContain('Local URL:')
expect(output).toContain('http://localhost:3000')
expect(output).not.toContain('App URL:')

renderInstance.unmount()
})

test('hides URL list when terminal supports hyperlinks', async () => {
// Given
mocks.terminalSupportsHyperlinks.mockReturnValue(true)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ interface DevSesionUIProps {
appName?: string
organizationName?: string
configPath?: string
localURL?: string
onAbort: () => Promise<void>
}

Expand All @@ -49,6 +50,7 @@ const DevSessionUI: FunctionComponent<DevSesionUIProps> = ({
appName,
organizationName,
configPath,
localURL,
onAbort,
}) => {
const {isRawModeSupported: canUseShortcuts} = useStdin()
Expand Down Expand Up @@ -230,6 +232,7 @@ const DevSessionUI: FunctionComponent<DevSesionUIProps> = ({
tabularData={[
['App:', appName ?? ''],
['App URL:', appURL ?? ''],
['Local URL:', appURL ? '' : (localURL ?? '')],
['Config:', configPath?.split('/').pop() ?? ''],
['Org:', organizationName ?? ''],
].filter(([, value]) => value)}
Expand Down
Loading