diff --git a/package.json b/package.json index 3ab986499..5101ae5c2 100644 --- a/package.json +++ b/package.json @@ -3,7 +3,7 @@ "version": "0.7.3-alpha", "description": "Azure Static Web Apps CLI", "scripts": { - "start": "node ./dist/cli/bin.js start ./cypress/fixtures/static --api=./cypress/fixtures/api --port 1234 --devserver-timeout 10000 --verbose silly", + "start": "node ./dist/cli/bin.js start ./cypress/fixtures/static --api-location=./cypress/fixtures/api --port 1234 --devserver-timeout 10000 --verbose silly", "start:config": "node ./dist/cli/bin.js --config ./cypress/fixtures/static/swa-cli.config.json start app", "prestart": "npm run build", "pretest": "npm run build", diff --git a/readme.md b/readme.md index 99d920894..c3f1a23cc 100644 --- a/readme.md +++ b/readme.md @@ -115,10 +115,10 @@ Run the CLI and provide the folder that contains the API backend (a valid Azure ```bash # static content plus API -swa start ./my-dist --api ./api-folder +swa start ./my-dist --api-location ./api-folder # frontend dev server plus API -swa start http://localhost:3000 --api ./api-folder +swa start http://localhost:3000 --api-location ./api-folder ``` #### Start API server manually @@ -128,9 +128,9 @@ 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` 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-location` flag and the URI of the local API server, in the following format: ```bash - swa start ./my-dist --api http://localhost:7071 + swa start ./my-dist --api-location http://localhost:7071 ``` ## Use a configuration file (staticwebapp.config.json) @@ -165,23 +165,23 @@ swa start http://localhost:3000 --swa-config-location ./my-app-source If you need to override the default values, provide the following options: -| Options | Description | Default | Example | -| -------------------------------- | ------------------------------------------------------- | ----------------------- | ---------------------------------------------------- | -| `--app-location` | set location for the static app source code | `./` | `--app-location="./my-project"` | -| `--app, --app-artifact-location` | set app artifact (dist) folder or dev server | `./` | `--app="./my-dist"` or `--app=http://localhost:4200` | -| `--api, --api-artifact-location` | set the API folder or dev server | | `--api="./api"` or `--api=http://localhost:8083` | -| `--swa-config-location` | set the directory of the staticwebapp.config.json file. | | `--swa-config-location=./my-project-folder` | -| `--api-port` | set the API server port | `7071` | `--api-port=8082` | -| `--host` | set the emulator host address | `0.0.0.0` | `--host=192.168.68.80` | -| `--port` | set the emulator port value | `4280` | `--port=8080` | -| `--ssl` | serving the app and API over HTTPS (default: false) | `false` | `--ssl` or `--ssl=true` | -| `--ssl-cert` | SSL certificate to use for serving HTTPS | | `--ssl-cert="/home/user/ssl/example.crt"` | -| `--ssl-key` | SSL key to use for serving HTTPS | | `--ssl-key="/home/user/ssl/example.key"` | -| `--run` | Run a command at startup | | `--run="cd app & npm start"` | -| `--devserver-timeout` | The time to wait(in ms) for the dev server to start | 30000 | `--devserver-timeout=60000` | -| `--func-args` | Additional arguments to pass to `func start` | | `--func-args="--javascript"` | -| `--config` | Path to swa-cli.config.json file to use. | `./swa-cli.config.json` | `--config ./config/swa-cli.config.json` | -| `--print-config` | Print all resolved options. Useful for debugging. | | `--print-config` or `--print-config=true` | +| Options | Description | Default | Example | +| ----------------------- | ------------------------------------------------------- | ----------------------- | ---------------------------------------------------------------------------- | +| `--app-location` | set location for the static app source code | `./` | `--app-location="./my-project"` | +| `--output-location` | set app artifact (dist) folder or dev server | `./` | `--output-location="./my-dist"` or `--output-location=http://localhost:4200` | +| `--api-location` | set the API folder or dev server | | `--api-location="./api"` or `--api-location=http://localhost:8083` | +| `--swa-config-location` | set the directory of the staticwebapp.config.json file. | | `--swa-config-location=./my-project-folder` | +| `--api-port` | set the API server port | `7071` | `--api-port=8082` | +| `--host` | set the emulator host address | `0.0.0.0` | `--host=192.168.68.80` | +| `--port` | set the emulator port value | `4280` | `--port=8080` | +| `--ssl` | serving the app and API over HTTPS (default: false) | `false` | `--ssl` or `--ssl=true` | +| `--ssl-cert` | SSL certificate to use for serving HTTPS | | `--ssl-cert="/home/user/ssl/example.crt"` | +| `--ssl-key` | SSL key to use for serving HTTPS | | `--ssl-key="/home/user/ssl/example.key"` | +| `--run` | Run a command at startup | | `--run="cd app & npm start"` | +| `--devserver-timeout` | The time to wait(in ms) for the dev server to start | 30000 | `--devserver-timeout=60000` | +| `--func-args` | Additional arguments to pass to `func start` | | `--func-args="--javascript"` | +| `--config` | Path to swa-cli.config.json file to use. | `./swa-cli.config.json` | `--config ./config/swa-cli.config.json` | +| `--print-config` | Print all resolved options. Useful for debugging. | | `--print-config` or `--print-config=true` | ## swa-cli.config.json file diff --git a/src/cli/index.ts b/src/cli/index.ts index 953027a34..b69f724fa 100755 --- a/src/cli/index.ts +++ b/src/cli/index.ts @@ -32,11 +32,11 @@ export async function run(argv?: string[]) { .description("start the emulator from a directory or bind to a dev server") .option("--app-location ", "set location for the static app source code", DEFAULT_CONFIG.appLocation) .option( - "--app, --app-artifact-location ", + "--output-location ", "set the location of the build output directory relative to the --app-location.", DEFAULT_CONFIG.outputLocation ) - .option("--api, --api-location ", "set the API folder or Azure Functions emulator address", DEFAULT_CONFIG.apiLocation) + .option("--api-location ", "set the API folder or Azure Functions emulator address", DEFAULT_CONFIG.apiLocation) .option( "--swa-config-location ", "set the directory where the staticwebapp.config.json file is found", @@ -107,7 +107,7 @@ Examples: swa start http://localhost:3000 --swa-config-location ./app-source Serve static content and run an API from another folder - swa start ./output-folder --api ./api + swa start ./output-folder --api-location ./api Use a custom command to run framework development server at startup swa start http://localhost:3000 --run "npm start"