Skip to content

Commit

Permalink
fix: --api-devserver-url not working if --api-location not set (#523, #…
Browse files Browse the repository at this point in the history
  • Loading branch information
sinedied committed Dec 15, 2022
1 parent 7ecbae2 commit d014fbd
Showing 1 changed file with 13 additions and 10 deletions.
23 changes: 13 additions & 10 deletions src/cli/commands/start.ts
Expand Up @@ -35,8 +35,12 @@ export default function registerCommand(program: Command) {
.option("-a, --app-location <path>", "the folder containing the source code of the front-end application", DEFAULT_CONFIG.appLocation)
.option("-i, --api-location <path>", "the folder containing the source code of the API application", DEFAULT_CONFIG.apiLocation)
.option("-O, --output-location <path>", "the folder containing the built source of the front-end application", DEFAULT_CONFIG.outputLocation)
.option("-D, --app-devserver-url <url>", "connect to the app dev server at this URL instead of using output location", DEFAULT_CONFIG.appDevserverUrl)
.option("-is, --api-devserver-url <url>", "connect to the api server at this URL instead of using output location", DEFAULT_CONFIG.apiDevserverUrl)
.option(
"-D, --app-devserver-url <url>",
"connect to the app dev server at this URL instead of using output location",
DEFAULT_CONFIG.appDevserverUrl
)
.option("-is, --api-devserver-url <url>", "connect to the api server at this URL instead of using api location", DEFAULT_CONFIG.apiDevserverUrl)
.option<number>("-j, --api-port <apiPort>", "the API server port passed to `func start`", parsePort, DEFAULT_CONFIG.apiPort)
.option("-q, --host <host>", "the host address to use for the CLI dev server", DEFAULT_CONFIG.host)
.option<number>("-p, --port <port>", "the port value to use for the CLI dev server", parsePort, DEFAULT_CONFIG.port)
Expand Down Expand Up @@ -107,7 +111,7 @@ Use a custom command to run framework development server at startup
swa start http://localhost:3000 --run-build "npm start"
Connect both front-end and the API to running development server
swa start http://localhost:3000 --api-location http://localhost:7071
swa start http://localhost:3000 --api-devserver-url http://localhost:7071
`
);
}
Expand Down Expand Up @@ -183,17 +187,16 @@ export async function start(options: SWACLIConfig) {
logger.silly(` ${outputLocation}`);
}

if (apiLocation) {
if (apiDevserverUrl) {
// TODO: properly refactor this after GA to send apiDevserverUrl to the server
useApiDevServer = apiDevserverUrl;
apiLocation = apiDevserverUrl;
} else if (apiLocation) {
// resolves to the absolute path of the apiLocation
let resolvedApiLocation = path.resolve(apiLocation);

if (apiDevserverUrl) {
// TODO: properly refactor this after GA to send apiDevserverUrl to the server
useApiDevServer = apiDevserverUrl;
apiLocation = apiDevserverUrl;
}
// make sure api folder exists
else if (fs.existsSync(resolvedApiLocation)) {
if (fs.existsSync(resolvedApiLocation)) {
apiLocation = resolvedApiLocation;
} else {
logger.info(`Skipping API because folder "${resolvedApiLocation}" is missing`, "swa");
Expand Down

0 comments on commit d014fbd

Please sign in to comment.