(program: Command)
| 7 | import { deploy } from "./deploy.js"; |
| 8 | |
| 9 | export default function registerCommand(program: Command) { |
| 10 | const deployCommand = program |
| 11 | .command("deploy [configName|outputLocation]") |
| 12 | .usage("[configName|outputLocation] [options]") |
| 13 | .description("deploy the current project to Azure Static Web Apps") |
| 14 | .option("-a, --app-location <path>", "the folder containing the source code of the front-end application", DEFAULT_CONFIG.appLocation) |
| 15 | .option("-i, --api-location <path>", "the folder containing the source code of the API application", DEFAULT_CONFIG.apiLocation) |
| 16 | .option("-da, --data-api-location <path>", "the folder containing the database connections configuration", DEFAULT_CONFIG.dataApiLocation) |
| 17 | .option("-O, --output-location <path>", "the folder containing the built source of the front-end application", DEFAULT_CONFIG.outputLocation) |
| 18 | .option("-al, --api-language <apiLanguage>", "the runtime language of the function/api", DEFAULT_CONFIG.apiLanguage) |
| 19 | .option("-av, --api-version <apiVersion>", "the version of the function runtime language", DEFAULT_CONFIG.apiVersion) |
| 20 | .option( |
| 21 | "-w, --swa-config-location <swaConfigLocation>", |
| 22 | "the directory where the staticwebapp.config.json file is located", |
| 23 | DEFAULT_CONFIG.swaConfigLocation |
| 24 | ) |
| 25 | .option("-d, --deployment-token <secret>", "the secret token used to authenticate with the Static Web Apps") |
| 26 | .option("-dr, --dry-run", "simulate a deploy process without actually running it", DEFAULT_CONFIG.dryRun) |
| 27 | .option("-pt, --print-token", "print the deployment token", false) |
| 28 | .option("--env [environment]", "the type of deployment environment where to deploy the project", DEFAULT_CONFIG.env) |
| 29 | .action(async (positionalArg: string | undefined, _options: SWACLIConfig, command: Command) => { |
| 30 | positionalArg = positionalArg?.trim(); |
| 31 | const options = await configureOptions(positionalArg, command.optsWithGlobals(), command, "deploy"); |
| 32 | if (positionalArg && !matchLoadedConfigName(positionalArg)) { |
| 33 | if (isUserOption("outputLocation")) { |
| 34 | logger.error(`swa deploy <outputLocation> cannot be used when --output-location option is also set.`); |
| 35 | logger.error(`You either have to use the positional argument or option, not both at the same time.`, true); |
| 36 | } |
| 37 | |
| 38 | // If it's not the config name, then it's the output location |
| 39 | options.outputLocation = positionalArg; |
| 40 | } |
| 41 | |
| 42 | await deploy(options); |
| 43 | }) |
| 44 | .addHelpText( |
| 45 | "after", |
| 46 | ` |
| 47 | Examples: |
| 48 | |
| 49 | Deploy using a deployment token |
| 50 | swa deploy ./dist/ --api-location ./api/ --deployment-token <token> |
| 51 | |
| 52 | Deploy using a deployment token from env |
| 53 | SWA_CLI_DEPLOYMENT_TOKEN=123 swa deploy ./dist/ --api-location ./api/ |
| 54 | |
| 55 | Provide function language and version |
| 56 | swa deploy ./my-dist --api-location ./api --api-language "node" --api-version "16" |
| 57 | |
| 58 | Deploy using swa-cli.config.json file |
| 59 | swa deploy |
| 60 | swa deploy myconfig |
| 61 | |
| 62 | Print the deployment token |
| 63 | swa deploy --print-token |
| 64 | |
| 65 | Deploy to a specific environment |
| 66 | swa deploy --env production |
nothing calls this directly
no test coverage detected
searching dependent graphs…