diff --git a/packages/app/src/cli/services/dev/ui.test.tsx b/packages/app/src/cli/services/dev/ui.test.tsx index 587d26a956..fceb2eebf7 100644 --- a/packages/app/src/cli/services/dev/ui.test.tsx +++ b/packages/app/src/cli/services/dev/ui.test.tsx @@ -73,6 +73,42 @@ describe('ui', () => { ) }) + test("shows preview and GraphiQL URLs when terminal doesn't support TTY", async () => { + vi.mocked(terminalSupportsPrompting).mockReturnValue(false) + const write = vi.spyOn(process.stdout, 'write').mockImplementation(() => true) + const concurrentProcess = { + prefix: 'prefix', + action: vi.fn(async (_stdout, _stderr, _signal) => {}), + } + + const abortController = new AbortController() + + await renderDev({ + processes: [concurrentProcess], + previewUrl: 'https://lala.cloudflare.io/', + graphiqlUrl: 'https://lala.cloudflare.io/graphiql', + graphiqlPort: 1234, + app: { + canEnablePreviewMode: true, + developmentStorePreviewEnabled: false, + apiKey: '123', + id: '123', + developerPlatformClient, + extensions: [], + }, + abortController, + developerPreview, + shopFqdn: 'mystore.shopify.io', + devSessionStatusManager, + }) + + const output = write.mock.calls.map(([message]) => message).join('') + expect(output).toContain('Preview URL: https://lala.cloudflare.io/') + expect(output).toContain('GraphiQL URL (Admin API): https://lala.cloudflare.io/graphiql') + + write.mockRestore() + }) + test("enable dev preview when terminal doesn't support TTY and the app supports it", async () => { vi.mocked(terminalSupportsPrompting).mockReturnValue(false) const concurrentProcess = { diff --git a/packages/app/src/cli/services/dev/ui.tsx b/packages/app/src/cli/services/dev/ui.tsx index 4d4a53f840..af9fa1e527 100644 --- a/packages/app/src/cli/services/dev/ui.tsx +++ b/packages/app/src/cli/services/dev/ui.tsx @@ -31,7 +31,15 @@ export async function renderDev({ localURL?: string }) { if (!terminalSupportsPrompting()) { - await renderDevNonInteractive({processes, app, abortController, developerPreview, shopFqdn}) + await renderDevNonInteractive({ + processes, + previewUrl, + graphiqlUrl, + app, + abortController, + developerPreview, + shopFqdn, + }) } else if (app.developerPlatformClient.supportsDevSessions) { return render( ) { +}: Omit) { if (canEnablePreviewMode) { await developerPreview.enable() abortController?.signal.addEventListener('abort', async () => { await developerPreview.disable() }) } + process.stdout.write(`\nPreview URL: ${previewUrl}\n`) + if (graphiqlUrl) { + process.stdout.write(`GraphiQL URL (Admin API): ${graphiqlUrl}\n`) + } + return Promise.all( processes.map(async (concurrentProcess) => { await concurrentProcess.action(process.stdout, process.stderr, abortController.signal)