@@ -7,7 +7,7 @@ import {DeveloperPlatformClient} from '../../utilities/developer-platform-client
7
7
import { patchAppConfigurationFile } from '../app/patch-app-configuration-file.js'
8
8
import { AbortError , BugError } from '@shopify/cli-kit/node/error'
9
9
import { Config } from '@oclif/core'
10
- import { checkPortAvailability , getAvailableTCPPort } from '@shopify/cli-kit/node/tcp'
10
+ import { checkPortAvailability } from '@shopify/cli-kit/node/tcp'
11
11
import { isValidURL } from '@shopify/cli-kit/common/url'
12
12
import { appHost , appPort , fetchSpinPort , isSpin , spinFqdn , spinVariables } from '@shopify/cli-kit/node/context/spin'
13
13
import { codespaceURL , codespacePortForwardingDomain , gitpodURL } from '@shopify/cli-kit/node/context/local'
@@ -28,11 +28,19 @@ export interface ApplicationURLs {
28
28
appProxy ?: AppProxy
29
29
}
30
30
31
- export interface FrontendURLOptions {
32
- noTunnelUseLocalhost : boolean
31
+ export type FrontendURLOptions = UseLocalhostFrontendUrlOptions | UseTunnelFrontendUrlOptions
32
+
33
+ interface UseLocalhostFrontendUrlOptions {
34
+ noTunnelUseLocalhost : true
35
+ port : number
36
+ tunnelUrl ?: undefined
37
+ tunnelClient ?: undefined
38
+ }
39
+
40
+ interface UseTunnelFrontendUrlOptions {
41
+ noTunnelUseLocalhost : false
33
42
tunnelUrl ?: string
34
43
tunnelClient : TunnelClient | undefined
35
- port ?: number
36
44
}
37
45
38
46
interface FrontendURLResult {
@@ -43,7 +51,7 @@ interface FrontendURLResult {
43
51
44
52
/**
45
53
* The tunnel creation logic depends on 7 variables:
46
- * - If a Codespaces environment is deteced , then the URL is built using the codespaces hostname. No need for tunnel
54
+ * - If a Codespaces environment is detected , then the URL is built using the codespaces hostname. No need for tunnel
47
55
* - If a Gitpod environment is detected, then the URL is built using the gitpod hostname. No need for tunnel
48
56
* - If a Spin environment is detected, then the URL is built using the cli + fqdn hostname as configured in nginx.
49
57
* No need for tunnel. In case problems with that configuration, the flags Tunnel or Custom Tunnel url could be used
@@ -100,12 +108,11 @@ export async function generateFrontendURL(options: FrontendURLOptions): Promise<
100
108
}
101
109
102
110
if ( options . noTunnelUseLocalhost ) {
103
- frontendPort = options . port ?? ( await getAvailableTCPPort ( ) )
111
+ frontendPort = options . port
104
112
frontendUrl = 'https://localhost'
105
113
} else if ( options . tunnelClient ) {
106
- const url = await pollTunnelURL ( options . tunnelClient )
107
114
frontendPort = options . tunnelClient . port
108
- frontendUrl = url
115
+ frontendUrl = await pollTunnelURL ( options . tunnelClient )
109
116
}
110
117
111
118
return { frontendUrl, frontendPort, usingLocalhost}
0 commit comments