diff --git a/docs/www/docs/cli/swa-start.md b/docs/www/docs/cli/swa-start.md index 74cff95c..c30b588a 100644 --- a/docs/www/docs/cli/swa-start.md +++ b/docs/www/docs/cli/swa-start.md @@ -51,7 +51,7 @@ Here is a list of the default ports used by some popular dev servers: | [Next.js](https://nextjs.org/) | 3000 | `swa start http://localhost:3000` | | [React (Create React App)](https://reactjs.org/docs/create-a-new-react-app.html) | 3000 | `swa start http://localhost:3000` | | [Svelte (sirv-cli)](https://github.com/lukeed/sirv/tree/master/packages/sirv-cli/) | 5000 | `swa start http://localhost:5000` | -| [Vue](https://github.com/vuejs/create-vue) | 3000 | `swa start http://localhost:3000` | +| [Vue](https://github.com/vuejs/create-vue) | 3000 | `swa start http://localhost:3000` | Instead of starting a dev server separately, you can provide the startup command to the CLI. @@ -94,10 +94,10 @@ When developing your backend locally, sometimes it's useful to run Azure Functio To use the CLI with your local API backend dev server, follow these two steps: 1. Start your API using Azure Functions Core Tools: `func host start` or start debugging in VS Code. -2. In a separate terminal, run the SWA CLI with the `--api-location` flag and the URI of the local API server, in the following format: +2. In a separate terminal, run the SWA CLI with the `--api-devserver-url` flag and the URI of the local API server, in the following format: ```bash -swa start ./my-dist --api-location http://localhost:7071 +swa start ./my-dist --api-devserver-url http://localhost:7071 ``` ## Options @@ -108,7 +108,7 @@ Here are the options you can use with `swa start`: - `-i, --api-location `: the folder containing the source code of the API application - `-O, --output-location `: the folder containing the built source of the front-end application. The path is relative to `--app-location` (default: ".") - `-D, --app-devserver-url `: connect to the app dev server at this URL instead of using output location -- `-is, --api-devserver-url `: connect to the api server at this URL instead of using output location +- `-is, --api-devserver-url `: connect to the api server at this URL instead of using api location - `-j, --api-port `: the API server port passed to `func start` (default: 7071) - `-q, --host `: the host address to use for the CLI dev server (default: "localhost") - `-p, --port `: the port value to use for the CLI dev server (default: 4280) @@ -157,7 +157,7 @@ swa start http://localhost:3000 --run-build "npm start" Connect both front-end and the API to running development server ```bash -swa start http://localhost:3000 --api-location http://localhost:7071 +swa start http://localhost:3000 --api-devserver-url http://localhost:7071 ``` ## See Also diff --git a/docs/www/docs/use/3-api-server.md b/docs/www/docs/use/3-api-server.md index ed0a0cf2..e4383d9c 100644 --- a/docs/www/docs/use/3-api-server.md +++ b/docs/www/docs/use/3-api-server.md @@ -29,10 +29,10 @@ To use the SWA emulator services alongside the API server: func host start ``` -2. Start SWA CLI in a separate terminal and use the `--api-location` option to pass it the relevant local API Server URI. _For example:_ +2. Start SWA CLI in a separate terminal and use the `--api-devserver-url` option to pass it the relevant local API Server URI. _For example:_ ```bash -swa start ./my-dist --api-location http://localhost:7071 +swa start ./my-dist --api-devserver-url http://localhost:7071 ``` ## 4.3 Start API Server Automatically diff --git a/src/cli/commands/start.ts b/src/cli/commands/start.ts index 69e0be87..d43896f7 100644 --- a/src/cli/commands/start.ts +++ b/src/cli/commands/start.ts @@ -35,8 +35,12 @@ export default function registerCommand(program: Command) { .option("-a, --app-location ", "the folder containing the source code of the front-end application", DEFAULT_CONFIG.appLocation) .option("-i, --api-location ", "the folder containing the source code of the API application", DEFAULT_CONFIG.apiLocation) .option("-O, --output-location ", "the folder containing the built source of the front-end application", DEFAULT_CONFIG.outputLocation) - .option("-D, --app-devserver-url ", "connect to the app dev server at this URL instead of using output location", DEFAULT_CONFIG.appDevserverUrl) - .option("-is, --api-devserver-url ", "connect to the api server at this URL instead of using output location", DEFAULT_CONFIG.apiDevserverUrl) + .option( + "-D, --app-devserver-url ", + "connect to the app dev server at this URL instead of using output location", + DEFAULT_CONFIG.appDevserverUrl + ) + .option("-is, --api-devserver-url ", "connect to the api server at this URL instead of using api location", DEFAULT_CONFIG.apiDevserverUrl) .option("-j, --api-port ", "the API server port passed to `func start`", parsePort, DEFAULT_CONFIG.apiPort) .option("-q, --host ", "the host address to use for the CLI dev server", DEFAULT_CONFIG.host) .option("-p, --port ", "the port value to use for the CLI dev server", parsePort, DEFAULT_CONFIG.port) @@ -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 ` ); } @@ -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");