Skip to content

Commit

Permalink
feat(cli): add more alias flags & update README
Browse files Browse the repository at this point in the history
  • Loading branch information
Devansu-Yadav authored and sinedied committed May 17, 2022
1 parent e3dad60 commit f5464db
Show file tree
Hide file tree
Showing 8 changed files with 91 additions and 77 deletions.
56 changes: 28 additions & 28 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -327,12 +327,12 @@ swa start http://localhost:3000 --swa-config-location ./my-app-source

If you need to override the default values for the `swa` command, you can provide the following options:

| Option | Description | Default | Example |
| ----------------------- | ------------------------------------------------------------------ | ----------------------- | ----------------------------------------- |
| `--verbose` | Enable verbose output. Values are: `silly, info, log, silent` | `log` | `--verbose=silly` |
| `--config` | Path to [`swa-cli.config.json`](#swa-cli.config.json) file to use | `./swa-cli.config.json` | `--config=./path/to/swa-cli.config.json` |
| `--print-config` | Print all resolved options | `false` | `--print-config` or `--print-config=true` |
| `--swa-config-location` | The directory where the `staticwebapp.config.json` file is located | `./` | `--swa-config-location=./app` |
| Option | Description | Default | Example |
| ----------------------------- | ------------------------------------------------------------------ | ----------------------- | ----------------------------------------- |
| `-V`, `--verbose` | Enable verbose output. Values are: `silly, info, log, silent` | `log` | `--verbose=silly` |
| `-c`, `--config` | Path to [`swa-cli.config.json`](#swa-cli.config.json) file to use | `./swa-cli.config.json` | `--config=./path/to/swa-cli.config.json` |
| `-g`, `--print-config` | Print all resolved options | `false` | `--print-config` or `--print-config=true` |
| `-w`, `--swa-config-location` | The directory where the `staticwebapp.config.json` file is located | `./` | `--swa-config-location=./app` |

### Subcommand `swa login` options

Expand All @@ -342,33 +342,33 @@ TODO

If you need to override the default values for the `swa start` subcommand, you can provide the following options:

| Option | Description | Default | Example |
| --------------------- | -------------------------------------------------------------------------------------------------------------- | --------- | ------------------------------------------------------------------ |
| `--app-location` | The folder containing the source code of the front-end application | `./` | `--app-location="./app"` |
| `--api-location` | The folder containing the source code of the API application. This could also be an URL to a `func` dev server | `./api` | `--api-location="./api"` or `--api-location=http://localhost:8083` |
| `--api-port` | The API server port passed to `func start` | `7071` | `--api-port=8082` |
| `--host` | The host address to use for the CLI dev server | `0.0.0.0` | `--host=192.168.68.80` |
| `--port` | The port value to use for the CLI dev server | `4280` | `--port=8080` |
| `--ssl` | Serve the front-end application and API over HTTPS | `false` | `--ssl` or `--ssl=true` |
| `--ssl-cert` | The SSL certificate (.crt) to use when enabling HTTPS | | `--ssl-cert="/home/user/ssl/example.crt"` |
| `--ssl-key` | The SSL key (.key) to use when enabling HTTPS | | `--ssl-key="/home/user/ssl/example.key"` |
| `--run` | Run a custon shell command or file at startup | | `--run="cd app & npm start"` |
| `--devserver-timeout` | The time (in seconds) to wait when connecting to a front-end application's dev server or api server | `60` | `--devserver-timeout=100` |
| `--func-args` | Pass additional arguments to the `func start` command | | `--func-args="--javascript"` |
| `--open` | Automatically open the CLI dev server in the default browser. | `false` | `--open` or `--open=true` |
| Option | Description | Default | Example |
| --------------------------- | -------------------------------------------------------------------------------------------------------------- | --------- | ------------------------------------------------------------------ |
| `-a`, `--app-location` | The folder containing the source code of the front-end application | `./` | `--app-location="./app"` |
| `-i`, `--api-location` | The folder containing the source code of the API application. This could also be an URL to a `func` dev server | `./api` | `--api-location="./api"` or `--api-location=http://localhost:8083` |
| `-j`, `--api-port` | The API server port passed to `func start` | `7071` | `--api-port=8082` |
| `-q`, `--host` | The host address to use for the CLI dev server | `0.0.0.0` | `--host=192.168.68.80` |
| `-p`, `--port` | The port value to use for the CLI dev server | `4280` | `--port=8080` |
| `-s`, `--ssl` | Serve the front-end application and API over HTTPS | `false` | `--ssl` or `--ssl=true` |
| `-e`, `--ssl-cert` | The SSL certificate (.crt) to use when enabling HTTPS | | `--ssl-cert="/home/user/ssl/example.crt"` |
| `-k`, `--ssl-key` | The SSL key (.key) to use when enabling HTTPS | | `--ssl-key="/home/user/ssl/example.key"` |
| `-r`, `--run` | Run a custon shell command or file at startup | | `--run="cd app & npm start"` |
| `-t`, `--devserver-timeout` | The time (in seconds) to wait when connecting to a front-end application's dev server or api server | `60` | `--devserver-timeout=100` |
| `-f`, `--func-args` | Pass additional arguments to the `func start` command | | `--func-args="--javascript"` |
| `-o`, `--open` | Automatically open the CLI dev server in the default browser. | `false` | `--open` or `--open=true` |

### Subcommand `swa deploy` options

If you need to override the default values for the `swa deploy` subcommand, you can provide the following options:

| Option | Description | Default | Example |
| -------------------- | ----------------------------------------------------------------------------------------------------------------------------------------- | --------- | ----------------------------------------- |
| `--api-location` | The folder containing the source code of the API application | `./api` | `--api-location="./api"` |
| `--deployment-token` | The secret toekn used to authenticate with the Static Web Apps | | `--deployment-token="123"` |
| `--dry-run` | Simulate a deploy process without actually running it | `false` | `--dry-run` |
| `--print-token` | print the deployment token | `false` | `--print-token` |
| `--env` | the type of deployment environment where to deploy the project | `preview` | `--env="production"` or `--env="preview"` |
| `--print-token` | Print the deployment token. Usefull when using `--deployment-token` on CI/CD <br> Note: this command does not run the deployment process. | `false` | `--print-token` |
| Option | Description | Default | Example |
| -------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------- | --------- | ----------------------------------------- |
| `-i`, `--api-location` | The folder containing the source code of the API application | `./api` | `--api-location="./api"` |
| `-d`, `--deployment-token` | The secret toekn used to authenticate with the Static Web Apps | | `--deployment-token="123"` |
| `-dr`, `--dry-run` | Simulate a deploy process without actually running it | `false` | `--dry-run` |
| `-pt`, `--print-token` | print the deployment token | `false` | `--print-token` |
| `--env` | the type of deployment environment where to deploy the project | `preview` | `--env="production"` or `--env="preview"` |
| `-pt`, `--print-token` | Print the deployment token. Usefull when using `--deployment-token` on CI/CD <br> Note: this command does not run the deployment process. | `false` | `--print-token` |

The deploy command does also support the same options as the `swa login` command.

Expand Down
10 changes: 5 additions & 5 deletions src/cli/commands/build.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,11 @@ export default function registerCommand(program: Command) {
.command("build [configName|appLocation]")
.usage("[configName|appLocation] [options]")
.description("build your project")
.option("--app-location <path>", "the folder containing the source code of the front-end application", DEFAULT_CONFIG.appLocation)
.option("--api-location <path>", "the folder containing the source code of the API application", DEFAULT_CONFIG.apiLocation)
.option("--output-location <path>", "the folder containing the built source of the front-end application", DEFAULT_CONFIG.outputLocation)
.option("--app-build-command <command>", "the command used to build your app", DEFAULT_CONFIG.appBuildCommand)
.option("--api-build-command <command>", "the command used to build your api", DEFAULT_CONFIG.apiBuildCommand)
.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("-A, --app-build-command <command>", "the command used to build your app", DEFAULT_CONFIG.appBuildCommand)
.option("-I, --api-build-command <command>", "the command used to build your api", DEFAULT_CONFIG.apiBuildCommand)
.option("--auto", "automatically detect how to build your app and api", false)
.action(async (positionalArg: string | undefined, _options: SWACLIConfig, command: Command) => {
const options = await configureOptions(positionalArg, command.optsWithGlobals(), command, "build");
Expand Down
14 changes: 7 additions & 7 deletions src/cli/commands/deploy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,17 +28,17 @@ export default function registerCommand(program: Command) {
.command("deploy [configName|outputLocation]")
.usage("[configName|outputLocation] [options]")
.description("deploy the current project to Azure Static Web Apps")
.option("--app-location <path>", "the folder containing the source code of the front-end application", DEFAULT_CONFIG.appLocation)
.option("--api-location <path>", "the folder containing the source code of the API application", DEFAULT_CONFIG.apiLocation)
.option("--output-location <path>", "the folder containing the built source of the front-end application", DEFAULT_CONFIG.outputLocation)
.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(
"--swa-config-location <swaConfigLocation>",
"-w, --swa-config-location <swaConfigLocation>",
"the directory where the staticwebapp.config.json file is located",
DEFAULT_CONFIG.swaConfigLocation
)
.option("--deployment-token <secret>", "the secret token used to authenticate with the Static Web Apps")
.option("--dry-run", "simulate a deploy process without actually running it", DEFAULT_CONFIG.dryRun)
.option("--print-token", "print the deployment token", false)
.option("-d, --deployment-token <secret>", "the secret token used to authenticate with the Static Web Apps")
.option("-dr, --dry-run", "simulate a deploy process without actually running it", DEFAULT_CONFIG.dryRun)
.option("-pt, --print-token", "print the deployment token", false)
.option("--env [environment]", "the type of deployment environment where to deploy the project", DEFAULT_CONFIG.env)
.action(async (positionalArg: string | undefined, _options: SWACLIConfig, command: Command) => {
const options = await configureOptions(positionalArg, command.optsWithGlobals(), command, "deploy");
Expand Down
2 changes: 1 addition & 1 deletion src/cli/commands/init.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ export default function registerCommand(program: Command) {
.command("init [configName]")
.usage("[configName] [options]")
.description("initialize a new static web app project")
.option("--yes", "answer yes to all prompts (disable interactive mode)", false)
.option("-y, --yes", "answer yes to all prompts (disable interactive mode)", false)
.action(async (configName: string | undefined, _options: SWACLIConfig, command: Command) => {
const options = await configureOptions(undefined, command.optsWithGlobals(), command, "init", false);
if (configName) {
Expand Down
20 changes: 10 additions & 10 deletions src/cli/commands/login.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,17 +14,17 @@ const { readFile, writeFile } = fsPromises;

export function addSharedLoginOptionsToCommand(command: Command) {
command
.option("--subscription-id <subscriptionId>", "Azure subscription ID used by this project", DEFAULT_CONFIG.subscriptionId)
.option("--resource-group <resourceGroupName>", "Azure resource group used by this project", DEFAULT_CONFIG.resourceGroupName)
.option("--tenant-id <tenantId>", "Azure tenant ID", DEFAULT_CONFIG.tenantId)
.option("--client-id <clientId>", "Azure client ID", DEFAULT_CONFIG.clientId)
.option("--client-secret <clientSecret>", "Azure client secret", DEFAULT_CONFIG.clientSecret)
.option("--app-name <appName>", "Azure Static Web App application name", DEFAULT_CONFIG.appName)
.option("--clear-credentials", "clear persisted credentials before login", DEFAULT_CONFIG.clearCredentials)

.option("--use-keychain", "enable using the operating system native keychain for persistent credentials", DEFAULT_CONFIG.useKeychain)
.option("-S, --subscription-id <subscriptionId>", "Azure subscription ID used by this project", DEFAULT_CONFIG.subscriptionId)
.option("-R, --resource-group <resourceGroupName>", "Azure resource group used by this project", DEFAULT_CONFIG.resourceGroupName)
.option("-T, --tenant-id <tenantId>", "Azure tenant ID", DEFAULT_CONFIG.tenantId)
.option("-C, --client-id <clientId>", "Azure client ID", DEFAULT_CONFIG.clientId)
.option("-CS, --client-secret <clientSecret>", "Azure client secret", DEFAULT_CONFIG.clientSecret)
.option("-n, --app-name <appName>", "Azure Static Web App application name", DEFAULT_CONFIG.appName)
.option("-cc, --clear-credentials", "clear persisted credentials before login", DEFAULT_CONFIG.clearCredentials)

.option("-u, --use-keychain", "enable using the operating system native keychain for persistent credentials", DEFAULT_CONFIG.useKeychain)
// Note: Commander does not automatically recognize the --no-* option, so we have to explicitly use --no-use-keychain- instead
.option("--no-use-keychain", "disable using the operating system native keychain", !DEFAULT_CONFIG.useKeychain);
.option("-nu, --no-use-keychain", "disable using the operating system native keychain", !DEFAULT_CONFIG.useKeychain);
}

export default function registerCommand(program: Command) {
Expand Down
Loading

0 comments on commit f5464db

Please sign in to comment.