Skip to content

Commit e4ec92b

Browse files
committed
Show Local URL in dev info when no App URL is available
1 parent 83ba075 commit e4ec92b

5 files changed

Lines changed: 70 additions & 0 deletions

File tree

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@shopify/app': patch
3+
---
4+
5+
Show Local URL in dev info when no App URL is available

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -439,6 +439,7 @@ async function launchDevProcesses({
439439
appName: config.remoteApp.title,
440440
organizationName: config.commandOptions.organization.businessName,
441441
configPath: config.localApp.configPath,
442+
localURL: config.network.proxyUrl,
442443
})
443444
}
444445

packages/app/src/cli/services/dev/ui.tsx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,14 @@ export async function renderDev({
2121
appName,
2222
organizationName,
2323
configPath,
24+
localURL,
2425
}: DevProps & {
2526
devSessionStatusManager: DevSessionStatusManager
2627
appURL?: string
2728
appName?: string
2829
organizationName?: string
2930
configPath?: string
31+
localURL?: string
3032
}) {
3133
if (!terminalSupportsPrompting()) {
3234
await renderDevNonInteractive({processes, app, abortController, developerPreview, shopFqdn})
@@ -41,6 +43,7 @@ export async function renderDev({
4143
appName={appName}
4244
organizationName={organizationName}
4345
configPath={configPath}
46+
localURL={localURL}
4447
onAbort={async () => {
4548
await app.developerPlatformClient.devSessionDelete({appId: app.id, shopFqdn})
4649
}}

packages/app/src/cli/services/dev/ui/components/DevSessionUI.test.tsx

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -554,6 +554,64 @@ describe('DevSessionUI', () => {
554554
renderInstance.unmount()
555555
})
556556

557+
test('hides Local URL in app info when an app URL is available', async () => {
558+
// Given
559+
const renderInstance = render(
560+
<DevSessionUI
561+
processes={[]}
562+
abortController={new AbortController()}
563+
devSessionStatusManager={devSessionStatusManager}
564+
shopFqdn="mystore.myshopify.com"
565+
appURL="https://my-app.ngrok.io"
566+
localURL="http://localhost:3000"
567+
appName="My Test App"
568+
onAbort={onAbort}
569+
/>,
570+
)
571+
572+
await waitForInputsToBeReady()
573+
574+
// When
575+
await sendInputAndWait(renderInstance, 10, 'a')
576+
577+
// Then - only App URL is shown, Local URL is hidden
578+
const output = unstyled(renderInstance.lastFrame()!)
579+
expect(output).toContain('App URL:')
580+
expect(output).toContain('https://my-app.ngrok.io')
581+
expect(output).not.toContain('Local URL:')
582+
expect(output).not.toContain('http://localhost:3000')
583+
584+
renderInstance.unmount()
585+
})
586+
587+
test('shows Local URL in app info when no app URL is available', async () => {
588+
// Given
589+
const renderInstance = render(
590+
<DevSessionUI
591+
processes={[]}
592+
abortController={new AbortController()}
593+
devSessionStatusManager={devSessionStatusManager}
594+
shopFqdn="mystore.myshopify.com"
595+
localURL="http://localhost:3000"
596+
appName="My Test App"
597+
onAbort={onAbort}
598+
/>,
599+
)
600+
601+
await waitForInputsToBeReady()
602+
603+
// When
604+
await sendInputAndWait(renderInstance, 10, 'a')
605+
606+
// Then - Local URL is shown in place of App URL
607+
const output = unstyled(renderInstance.lastFrame()!)
608+
expect(output).toContain('Local URL:')
609+
expect(output).toContain('http://localhost:3000')
610+
expect(output).not.toContain('App URL:')
611+
612+
renderInstance.unmount()
613+
})
614+
557615
test('hides URL list when terminal supports hyperlinks', async () => {
558616
// Given
559617
mocks.terminalSupportsHyperlinks.mockReturnValue(true)

packages/app/src/cli/services/dev/ui/components/DevSessionUI.tsx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ interface DevSesionUIProps {
3737
appName?: string
3838
organizationName?: string
3939
configPath?: string
40+
localURL?: string
4041
onAbort: () => Promise<void>
4142
}
4243

@@ -49,6 +50,7 @@ const DevSessionUI: FunctionComponent<DevSesionUIProps> = ({
4950
appName,
5051
organizationName,
5152
configPath,
53+
localURL,
5254
onAbort,
5355
}) => {
5456
const {isRawModeSupported: canUseShortcuts} = useStdin()
@@ -230,6 +232,7 @@ const DevSessionUI: FunctionComponent<DevSesionUIProps> = ({
230232
tabularData={[
231233
['App:', appName ?? ''],
232234
['App URL:', appURL ?? ''],
235+
['Local URL:', appURL ? '' : (localURL ?? '')],
233236
['Config:', configPath?.split('/').pop() ?? ''],
234237
['Org:', organizationName ?? ''],
235238
].filter(([, value]) => value)}

0 commit comments

Comments
 (0)