Skip to content

Commit 11aa646

Browse files
committed
Simplify changes to dev.ts
1 parent 5d1a2ca commit 11aa646

File tree

1 file changed

+11
-14
lines changed
  • packages/app/src/cli/services

1 file changed

+11
-14
lines changed

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

Lines changed: 11 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
import {
2-
FrontendURLOptions,
32
ApplicationURLs,
4-
generateFrontendURL,
3+
FrontendURLOptions,
54
generateApplicationURLs,
5+
generateFrontendURL,
66
getURLs,
77
shouldOrPromptUpdateURLs,
88
startTunnelPlugin,
@@ -151,7 +151,7 @@ async function prepareForDev(commandOptions: DevOptions): Promise<DevConfig> {
151151
const previousAppId = getCachedAppInfo(commandOptions.directory)?.previousAppId
152152
const apiKey = remoteApp.apiKey
153153

154-
const {shouldUpdateURLs, newURLs} = await handleUpdatingOfPartnerUrls(
154+
const partnerUrlsUpdated = await handleUpdatingOfPartnerUrls(
155155
webs,
156156
commandOptions.update,
157157
network,
@@ -162,12 +162,6 @@ async function prepareForDev(commandOptions: DevOptions): Promise<DevConfig> {
162162
developerPlatformClient,
163163
)
164164

165-
// If the user chose to update the URLs automatically AND there are new URLs
166-
// Store them in the app so that the manifest can be patched with them
167-
if (shouldUpdateURLs && newURLs) {
168-
app.devApplicationURLs = newURLs
169-
}
170-
171165
return {
172166
storeFqdn: store.shopDomain,
173167
storeId: store.shopId,
@@ -177,7 +171,7 @@ async function prepareForDev(commandOptions: DevOptions): Promise<DevConfig> {
177171
developerPlatformClient,
178172
commandOptions,
179173
network,
180-
partnerUrlsUpdated: shouldUpdateURLs,
174+
partnerUrlsUpdated,
181175
graphiqlPort,
182176
graphiqlKey,
183177
}
@@ -266,10 +260,9 @@ async function handleUpdatingOfPartnerUrls(
266260
) {
267261
const {backendConfig, frontendConfig} = frontAndBackendConfig(webs)
268262
let shouldUpdateURLs = false
269-
let newURLs: ApplicationURLs | undefined
270263
if (frontendConfig ?? backendConfig) {
271264
if (commandSpecifiedToUpdate) {
272-
newURLs = generateApplicationURLs(
265+
const newURLs = generateApplicationURLs(
273266
network.proxyUrl,
274267
webs.map(({configuration}) => configuration.auth_callback_path).find((path) => path),
275268
localApp.configuration.app_proxy,
@@ -284,10 +277,14 @@ async function handleUpdatingOfPartnerUrls(
284277
})
285278
// When running dev app urls are pushed directly to API Client config instead of creating a new app version
286279
// so current app version and API Client config will have diferent url values.
287-
if (shouldUpdateURLs) await updateURLs(newURLs, apiKey, developerPlatformClient, localApp)
280+
if (shouldUpdateURLs) {
281+
await updateURLs(newURLs, apiKey, developerPlatformClient, localApp)
282+
// eslint-disable-next-line require-atomic-updates
283+
localApp.devApplicationURLs = newURLs
284+
}
288285
}
289286
}
290-
return {shouldUpdateURLs, newURLs}
287+
return shouldUpdateURLs
291288
}
292289

293290
async function setupNetworkingOptions(

0 commit comments

Comments
 (0)