@codedrifters/configulator 0.0.431 → 0.0.433

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.
package/lib/index.mjs CHANGED
@@ -41148,7 +41148,7 @@ var MonorepoProject = class extends TypeScriptAppProject {
41148
41148
  workflowOptions: {
41149
41149
  schedule: UpgradeDependenciesSchedule.DAILY
41150
41150
  },
41151
- cooldown: 1
41151
+ cooldown: 7
41152
41152
  },
41153
41153
  /**
41154
41154
  * Disable tsconfig.dev.json in the root since we aren't going to be
@@ -41655,7 +41655,7 @@ var TypeScriptProject = class extends typescript.TypeScriptProject {
41655
41655
  workflowOptions: {
41656
41656
  schedule: UpgradeDependenciesSchedule2.WEEKLY
41657
41657
  },
41658
- cooldown: 1
41658
+ cooldown: 7
41659
41659
  } : {}
41660
41660
  },
41661
41661
  /**
@@ -42230,6 +42230,7 @@ var DIFF_REPORT_JOB_ID = "diff-report";
42230
42230
  var DIFF_OUTPUT_DIRECTORY = "cdk-diff";
42231
42231
  var DIFF_PART_ARTIFACT_PREFIX = "cdk-diff-part";
42232
42232
  var DIFF_ARTIFACT_NAME = "cdk-diff";
42233
+ var DIFF_NEW_STACK_MARKER = "NEW STACK";
42233
42234
  var DIFF_PART_RETENTION_DAYS = 1;
42234
42235
  var DIFF_SUMMARY_BYTE_LIMIT = 9e5;
42235
42236
  var RUN_URL = "${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}";
@@ -42305,6 +42306,11 @@ var DiffReportJob = class _DiffReportJob extends Component23 {
42305
42306
  * captured anything from one that simply had no changes — the latter has a
42306
42307
  * file, carrying the CDK CLI's own no-differences wording, rather than being
42307
42308
  * detected by matching on it.
42309
+ *
42310
+ * A capture carrying {@link DIFF_NEW_STACK_MARKER} lines has its banners
42311
+ * lifted out of the `<details>` block and quoted under the heading, so a
42312
+ * target that will be created from scratch reads as such without expanding
42313
+ * anything.
42308
42314
  */
42309
42315
  this.renderSummaryStep = () => {
42310
42316
  if (!this.summary || this.targets.length === 0) {
@@ -42329,6 +42335,10 @@ var DiffReportJob = class _DiffReportJob extends Component23 {
42329
42335
  ' echo ""',
42330
42336
  " continue",
42331
42337
  " fi",
42338
+ ` if grep -q '^${DIFF_NEW_STACK_MARKER}' "$file"; then`,
42339
+ ` grep '^${DIFF_NEW_STACK_MARKER}' "$file" | sed 's/^/> **/; s/$/**/'`,
42340
+ ' echo ""',
42341
+ " fi",
42332
42342
  " echo '<details><summary>cdk diff output</summary>'",
42333
42343
  ' echo ""',
42334
42344
  " echo '```'",
@@ -42906,6 +42916,11 @@ var AwsDeployWorkflow = class _AwsDeployWorkflow extends Component25 {
42906
42916
  * `app` and `stackPatterns` target the built cloud assembly, and `ci` /
42907
42917
  * `noColor` force the human-readable diff onto stdout without ANSI escapes
42908
42918
  * (without `--ci` the CLI interleaves it into stderr alongside logs).
42919
+ *
42920
+ * `method` is the one resolved flag not baked into the rendered command. A
42921
+ * from-scratch target has to be classified before it can be diffed — see
42922
+ * {@link diffProbeLines} — so the command reads the effective method from
42923
+ * `$method`.
42909
42924
  */
42910
42925
  this.diffSteps = (target) => {
42911
42926
  const {
@@ -42920,6 +42935,20 @@ var AwsDeployWorkflow = class _AwsDeployWorkflow extends Component25 {
42920
42935
  const { rootCdkOut, cdkCli } = awsDeploymentConfig;
42921
42936
  const label = `${awsStageType}/${deploymentTargetRole}/${account}/${region}`;
42922
42937
  const outputFile = this.buildDiffOutputFile(target);
42938
+ const stackPatterns = stackPattern ? [stackPattern] : void 0;
42939
+ const diffCommand = [
42940
+ `pnpm dlx "aws-cdk@${cdkCli.cliVersion}"`,
42941
+ renderCdkDiff({
42942
+ ...cdkCli.diffOptionsFor(target),
42943
+ app: rootCdkOut,
42944
+ ci: true,
42945
+ noColor: true,
42946
+ method: void 0,
42947
+ stackPatterns: void 0
42948
+ }),
42949
+ '--method="$method"',
42950
+ ...(stackPatterns ?? []).map((pattern) => `"${pattern}"`)
42951
+ ].join(" ");
42923
42952
  return [
42924
42953
  ...this.setupPnpm(),
42925
42954
  ...this.setupNode(),
@@ -42937,11 +42966,14 @@ var AwsDeployWorkflow = class _AwsDeployWorkflow extends Component25 {
42937
42966
  }
42938
42967
  },
42939
42968
  /**
42940
- * Run CDK Diff, capturing the output while leaving it visible in the job
42941
- * log. `pipefail` keeps the CLI's exit code from being masked by `tee`.
42969
+ * Classify the target's stacks, then run CDK Diff, capturing the output
42970
+ * while leaving it visible in the job log. `pipefail` keeps the CLI's
42971
+ * exit code from being masked by `tee`.
42942
42972
  *
42943
42973
  * The capture lands under the same path the report job will merge it
42944
- * back to, so a target's file name is identical in both places.
42974
+ * back to, so a target's file name is identical in both places. It is
42975
+ * truncated first and appended to from there, so a re-run never reads a
42976
+ * previous attempt's banners.
42945
42977
  */
42946
42978
  {
42947
42979
  name: `Diff ${label}`,
@@ -42949,13 +42981,9 @@ var AwsDeployWorkflow = class _AwsDeployWorkflow extends Component25 {
42949
42981
  run: [
42950
42982
  "set -o pipefail",
42951
42983
  `mkdir -p ${DIFF_OUTPUT_DIRECTORY}`,
42952
- `pnpm dlx "aws-cdk@${cdkCli.cliVersion}" ${renderCdkDiff({
42953
- ...cdkCli.diffOptionsFor(target),
42954
- app: rootCdkOut,
42955
- ci: true,
42956
- noColor: true,
42957
- stackPatterns: stackPattern ? [stackPattern] : void 0
42958
- })} 2>&1 | tee ${outputFile}`
42984
+ `: > ${outputFile}`,
42985
+ ...this.diffProbeLines(target, outputFile),
42986
+ `${diffCommand} 2>&1 | tee -a ${outputFile}`
42959
42987
  ].join("\n")
42960
42988
  },
42961
42989
  /**
@@ -42971,6 +42999,70 @@ var AwsDeployWorkflow = class _AwsDeployWorkflow extends Component25 {
42971
42999
  })
42972
43000
  ];
42973
43001
  };
43002
+ /**
43003
+ * Lines that classify every stack a target's pattern matches before the diff
43004
+ * runs, so a stack that will be created from scratch is reported as such
43005
+ * instead of failing the job.
43006
+ *
43007
+ * `cdk diff --method=change-set` asks CloudFormation for an `UPDATE` change
43008
+ * set whenever the stack exists — and a `ROLLBACK_COMPLETE` /
43009
+ * `ROLLBACK_FAILED` tombstone left by a failed first create does exist, so
43010
+ * CloudFormation rejects the request and the job goes red. `cdk deploy`
43011
+ * consults `stackStatus.isCreationFailure`, deletes the tombstone and
43012
+ * recreates the stack, so the apply succeeds on exactly the stack the diff
43013
+ * refuses to look at. Under the `plan-apply` gate that asymmetry is a hard
43014
+ * blocker rather than a cosmetic one: the apply requires a successful plan
43015
+ * run, so one from-scratch target blocks applying any plan for the stage.
43016
+ *
43017
+ * `cdk list --long --json` resolves the pattern to CloudFormation stack names
43018
+ * out of the built assembly's manifest — no synth, no cloud call — and each
43019
+ * name costs one `describe-stacks`, which needs only
43020
+ * `cloudformation:DescribeStacks`. Any role that can run a change-set diff
43021
+ * already carries it. A `cdk list` that fails contributes no names, leaving
43022
+ * the diff to run exactly as it does today.
43023
+ *
43024
+ * A genuinely absent stack keeps the configured method — CDK gives it a
43025
+ * `CREATE` change set and diffs it fine. Only a tombstone moves the method,
43026
+ * and only to `template`, never to `auto`: `auto` would swallow a real
43027
+ * permission failure and present a degraded diff as authoritative, which is
43028
+ * what an explicit `change-set` pin exists to prevent. `template`
43029
+ * over-reporting replacements is vacuous here, because every resource in a
43030
+ * stack built from scratch is an add.
43031
+ *
43032
+ * The method is per invocation, not per stack — `cdk diff` diffs everything
43033
+ * its pattern matches in one pass. A pattern matching several stacks where
43034
+ * only one is a tombstone therefore diffs all of them with `template`, and
43035
+ * the banner names the stack that caused it.
43036
+ */
43037
+ this.diffProbeLines = (target, outputFile) => {
43038
+ const { ciDeploymentConfig, awsDeploymentConfig } = target;
43039
+ const { stackPattern } = ciDeploymentConfig ?? {};
43040
+ const { rootCdkOut, cdkCli } = awsDeploymentConfig;
43041
+ const configuredMethod = cdkCli.diffOptionsFor(target).method ?? CDK_DIFF_METHOD.ChangeSet;
43042
+ const listCommand = `pnpm dlx "aws-cdk@${cdkCli.cliVersion}" ${renderCdkList(
43043
+ {
43044
+ app: rootCdkOut,
43045
+ json: true,
43046
+ long: true,
43047
+ stackPatterns: stackPattern ? [stackPattern] : void 0
43048
+ }
43049
+ )}`;
43050
+ return [
43051
+ `method=${configuredMethod}`,
43052
+ "while read -r stack; do",
43053
+ ' status=$(aws cloudformation describe-stacks --stack-name "$stack" --query "Stacks[0].StackStatus" --output text 2>/dev/null || echo NOT_FOUND)',
43054
+ ' case "$status" in',
43055
+ " NOT_FOUND|REVIEW_IN_PROGRESS)",
43056
+ ` echo "${DIFF_NEW_STACK_MARKER} \u2014 $stack does not exist yet, so this target will be created from scratch." | tee -a ${outputFile}`,
43057
+ " ;;",
43058
+ " ROLLBACK_COMPLETE|ROLLBACK_FAILED)",
43059
+ ` method=${CDK_DIFF_METHOD.Template}`,
43060
+ ` echo "${DIFF_NEW_STACK_MARKER} \u2014 $stack exists only as a failed-create tombstone ($status), so this target will be created from scratch. Diffing it with --method=${CDK_DIFF_METHOD.Template}." | tee -a ${outputFile}`,
43061
+ " ;;",
43062
+ " esac",
43063
+ `done < <(${listCommand} 2>/dev/null | jq -r '.[].name' 2>/dev/null)`
43064
+ ];
43065
+ };
42974
43066
  if (!(project.root instanceof MonorepoProject)) {
42975
43067
  throw new Error(
42976
43068
  "AwsDeployWorkflow requires the root project to be a MonorepoProject"
@@ -43522,7 +43614,7 @@ var AwsCdkProject = class extends awscdk.AwsCdkTypeScriptApp {
43522
43614
  workflowOptions: {
43523
43615
  schedule: UpgradeDependenciesSchedule3.WEEKLY
43524
43616
  },
43525
- cooldown: 1
43617
+ cooldown: 7
43526
43618
  },
43527
43619
  /**
43528
43620
  * Only release when the package source content or package.json changes.
@@ -44175,6 +44267,7 @@ export {
44175
44267
  DEFAULT_UPSTREAM_CONFIGULATOR_ENABLED,
44176
44268
  DEPLOY_GATE,
44177
44269
  DIFF_ARTIFACT_NAME,
44270
+ DIFF_NEW_STACK_MARKER,
44178
44271
  DIFF_OUTPUT_DIRECTORY,
44179
44272
  DIFF_PART_ARTIFACT_PREFIX,
44180
44273
  DIFF_REPORT_JOB_ID,