Skip to content

Commit 2b8b4f8

Browse files
committed
feat: allow using app dev server
1 parent e28b4db commit 2b8b4f8

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

bin/index.js

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ program
2121
.option("--api-uri <apiUri>", "set API uri", `http://localhost:${API_PORT}`)
2222
.option("--api-prefix <apiPrefix>", "set API prefix", "api")
2323
.option("--app-uri <appUri>", "set APP uri", `http://localhost:${APP_PORT}`)
24+
.option("--use-dev-server <useDevServer>", "Use running APP dev server", null)
2425
.option("--host <host>", "set host address", "0.0.0.0")
2526
.option("--port <port>", "set port value", EMU_PORT)
2627
.option("--verbose", "show debug logs", false)
@@ -56,19 +57,23 @@ const envVarsObj = {
5657
SWA_EMU_AUTH_URI: program.authUri,
5758
SWA_EMU_API_URI: program.apiUri,
5859
SWA_EMU_API_PREFIX: program.apiPrefix,
59-
SWA_EMU_APP_URI: program.appUri,
60+
SWA_EMU_APP_URI: program.useDevServer || program.appUri,
6061
SWA_EMU_APP_LOCATION: app_artifact_location,
6162
SWA_EMU_HOST: program.host,
6263
SWA_EMU_PORT: program.port,
6364
};
6465

6566
const { command: hostCommand, args: hostArgs } = createRuntimeHost(appUriPort, program.host, program.port);
67+
let serveStaticContent = `${hostCommand} ${hostArgs.join(" ")}`;
68+
if (program.useDevServer) {
69+
serveStaticContent = `echo 'using dev server at ${program.useDevServer}'`;
70+
}
6671

6772
const startCommand = [
6873
// run concurrent commands
6974
concurrentlyBin,
7075
`--restart-tries 3`,
71-
`--names x,emulator,auth,hosting,functions`,
76+
`--names emulator,auth,hosting,functions`,
7277
`-c 'bgYellow.bold,bgMagenta.bold,bgCyan.bold,bgGreen.bold'`,
7378

7479
// start the reverse proxy
@@ -78,7 +83,7 @@ const startCommand = [
7883
`"(cd ./src/auth/; func start --cors=* --port=${authUriPort})"`,
7984

8085
// serve the app
81-
`"${hostCommand} ${hostArgs.join(" ")}"`,
86+
`"${serveStaticContent}"`,
8287

8388
// serve the api, if it's available
8489
`"[ -d '${api_location}' ] && (cd ${api_location}; func start --cors *) || echo 'No API found. Skipping.'"`,

0 commit comments

Comments
 (0)