thinkwork-cli 0.12.11 → 0.12.12

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/dist/cli.js +37 -13
  2. package/package.json +1 -1
package/dist/cli.js CHANGED
@@ -2082,28 +2082,26 @@ async function runDeployCommand(opts, deps = {}) {
2082
2082
  }
2083
2083
  async function runLocalTerraformDeploy(opts) {
2084
2084
  const startTime = Date.now();
2085
- const stage = await resolveStage({ flag: opts.stage });
2085
+ const initialStage = await resolveStage({ flag: opts.stage });
2086
2086
  const compCheck = validateComponent(opts.component);
2087
2087
  if (!compCheck.valid) {
2088
2088
  printError(compCheck.error);
2089
2089
  process.exit(1);
2090
2090
  }
2091
2091
  const identity = getAwsIdentity();
2092
- printHeader("deploy", stage, identity);
2092
+ printHeader("deploy", initialStage, identity);
2093
2093
  if (!identity) {
2094
2094
  printWarning("Could not resolve AWS identity. Is the AWS CLI configured?");
2095
2095
  }
2096
- if (isProdLike(stage) && !opts.yes) {
2097
- const ok = await confirm(` Stage "${stage}" is production-like. Deploy?`);
2098
- if (!ok) {
2099
- console.log(" Aborted.");
2100
- process.exit(0);
2101
- }
2102
- } else if (!opts.yes) {
2103
- const ok = await confirm(` Deploy to stage "${stage}"?`);
2104
- if (!ok) {
2105
- console.log(" Aborted.");
2106
- process.exit(0);
2096
+ const stage = await confirmLocalDeployStage(initialStage, opts);
2097
+ if (!stage) {
2098
+ console.log(" Aborted.");
2099
+ process.exit(0);
2100
+ }
2101
+ if (stage !== initialStage) {
2102
+ printHeader("deploy", stage, identity);
2103
+ if (!identity) {
2104
+ printWarning("Could not resolve AWS identity. Is the AWS CLI configured?");
2107
2105
  }
2108
2106
  }
2109
2107
  const terraformDir = process.env.THINKWORK_TERRAFORM_DIR || process.cwd();
@@ -2128,6 +2126,32 @@ async function runLocalTerraformDeploy(opts) {
2128
2126
  await runPostDeployProbe(stage);
2129
2127
  printSummary("deploy", stage, tiers, startTime);
2130
2128
  }
2129
+ async function confirmLocalDeployStage(initialStage, opts, deps = {}) {
2130
+ if (opts.yes) return initialStage;
2131
+ let stage = initialStage;
2132
+ while (true) {
2133
+ const ok = await (deps.confirm ?? confirm)(deployConfirmMessage(stage));
2134
+ if (ok) return stage;
2135
+ const canPromptForAnotherStage = deps.stdoutIsTty ?? Boolean(process.stdout.isTTY);
2136
+ if (!canPromptForAnotherStage) return null;
2137
+ const nextStage = (await promptAlternativeDeployStage(stage, deps.promptInput)).trim();
2138
+ if (!nextStage) return null;
2139
+ const check = validateStage(nextStage);
2140
+ if (!check.valid) {
2141
+ throw new Error(check.error);
2142
+ }
2143
+ stage = nextStage;
2144
+ }
2145
+ }
2146
+ function deployConfirmMessage(stage) {
2147
+ return isProdLike(stage) ? ` Stage "${stage}" is production-like. Deploy?` : ` Deploy to stage "${stage}"?`;
2148
+ }
2149
+ async function promptAlternativeDeployStage(currentStage, promptInput) {
2150
+ const message = `Deployment stage to deploy instead of "${currentStage}" (blank to abort):`;
2151
+ if (promptInput) return promptInput(message);
2152
+ const { input: input21 } = await import("@inquirer/prompts");
2153
+ return input21({ message });
2154
+ }
2131
2155
  function printEnterpriseDeploySummary(result) {
2132
2156
  const workflow = result.workflow;
2133
2157
  if (result.kind === "bootstrap") {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "thinkwork-cli",
3
- "version": "0.12.11",
3
+ "version": "0.12.12",
4
4
  "description": "Thinkwork CLI — deploy, manage, and interact with your Thinkwork stack",
5
5
  "license": "Apache-2.0",
6
6
  "type": "module",