Skip to content

Commit a63e3ab

Browse files
add option to bypass running service check if configured
1 parent 591e90e commit a63e3ab

File tree

4 files changed

+23
-10
lines changed

4 files changed

+23
-10
lines changed

packages/cli-kit/src/public/node/context/fqdn.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ export async function identityFqdn(): Promise<string> {
115115
const productionFqdn = 'accounts.shopify.com'
116116
switch (environment) {
117117
case 'local':
118-
return new DevServer('identity').host()
118+
return new DevServer('identity').host({useMockIfNotRunning: true})
119119
default:
120120
return productionFqdn
121121
}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
import {createServer} from './dev-server-2024.js'
2+
import {describe, expect, test} from 'vitest'
3+
4+
describe('createServer', () => {
5+
describe('host', () => {
6+
test('throws when dev server is not running and useMockIfNotRunning is not set', () => {
7+
const server = createServer('test-project')
8+
expect(() => server.host()).toThrow()
9+
})
10+
11+
test('does not throw when useMockIfNotRunning is true', () => {
12+
const server = createServer('test-project')
13+
expect(() => server.host({useMockIfNotRunning: true})).not.toThrow()
14+
})
15+
})
16+
})

packages/cli-kit/src/public/node/vendor/dev_server/dev-server-2024.ts

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,12 @@ export function createServer(projectName: string) {
1616
}
1717
}
1818

19-
function host(projectName: string, options: HostOptions = {}): string {
19+
function host(projectName: string, options: HostOptions = {useMockIfNotRunning: false}): string {
2020
assertCompatibleEnvironment()
21-
;(assertRunningOverride || assertRunning2024)(projectName)
21+
22+
if (!options.useMockIfNotRunning) {
23+
assertRunning2024(projectName)
24+
}
2225

2326
const prefix = (options.nonstandardHostPrefix || projectName).replace(/_/g, '-')
2427

@@ -80,10 +83,3 @@ function resolveBackendHost(name: string): string {
8083
return host
8184
}
8285
}
83-
84-
// Allow overrides for more concise test setup. Meh.
85-
let assertRunningOverride: typeof assertRunning2024 | undefined
86-
87-
export function setAssertRunning(override: typeof assertRunningOverride) {
88-
assertRunningOverride = override
89-
}

packages/cli-kit/src/public/node/vendor/dev_server/types.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,5 @@ export interface DevServer {
1010

1111
export interface HostOptions {
1212
nonstandardHostPrefix?: string
13+
useMockIfNotRunning?: boolean
1314
}

0 commit comments

Comments
 (0)