cdk-real-drift 0.4.1 → 0.4.2

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/README.md CHANGED
@@ -333,6 +333,10 @@ CI (with `--yes`).
333
333
  is always surfaced regardless (as the `skipped=N` footer line or a loud
334
334
  `warning:`); `--strict` only decides whether it fails the build.
335
335
  - Errors always exit `2`; `revert` exits `1` when drift remains after it.
336
+ - Interrupting a run with **Ctrl-C** (or **ESC**) during the gather/read phase
337
+ exits `130` (128 + SIGINT) for every verb — never `0`, so an aborted
338
+ `check --fail` can never be mistaken for "no drift" and an aborted `record` is
339
+ never a false "written".
336
340
 
337
341
  ```yaml
338
342
  - run: npm ci # cdkrd resolves the CDK app, so its deps must be installed
package/dist/cli.js CHANGED
@@ -71,6 +71,29 @@ async function flushAndExit(code) {
71
71
  process.exit(code);
72
72
  }
73
73
 
74
+ //#endregion
75
+ //#region src/interrupt.ts
76
+ let gatherActive = false;
77
+ function setGatherActive(active) {
78
+ gatherActive = active;
79
+ }
80
+ function interruptExitCode(code, active) {
81
+ return active && (code === void 0 || code === 0) ? 130 : code ?? 0;
82
+ }
83
+ let installed = false;
84
+ function installInterruptGuard() {
85
+ if (installed) return;
86
+ installed = true;
87
+ const realExit = process.exit.bind(process);
88
+ process.exit = (code) => realExit(interruptExitCode(code, gatherActive));
89
+ const onSignal = () => {
90
+ process.stderr.write("\x1B[?25h");
91
+ return realExit(130);
92
+ };
93
+ process.on("SIGINT", onSignal);
94
+ process.on("SIGTERM", onSignal);
95
+ }
96
+
74
97
  //#endregion
75
98
  //#region src/aws-errors.ts
76
99
  function isStackNotDeployed(e) {
@@ -9565,6 +9588,7 @@ async function regatherTouched(gathered, touched, region) {
9565
9588
  async function gatherWithProgress(show, label, run) {
9566
9589
  if (!show) return run();
9567
9590
  const s = spinner();
9591
+ setGatherActive(true);
9568
9592
  s.start(`${label}: reading live AWS state & computing drift…`);
9569
9593
  try {
9570
9594
  const gathered = await run();
@@ -9573,6 +9597,8 @@ async function gatherWithProgress(show, label, run) {
9573
9597
  } catch (e) {
9574
9598
  s.error(`${label}: read failed`);
9575
9599
  throw e;
9600
+ } finally {
9601
+ setGatherActive(false);
9576
9602
  }
9577
9603
  }
9578
9604
  function positionPrefix(idx, total) {
@@ -14694,6 +14720,7 @@ EXIT CODES
14694
14720
  record: 0 = written 2 = error/refused
14695
14721
  ignore: 0 = rule(s) written / nothing to ignore 2 = error/refused
14696
14722
  revert: 0 = converged/aborted 1 = drift remains 2 = error/apply failure
14723
+ all: 130 = interrupted (Ctrl-C / ESC) during the gather/read phase — never mistaken for clean
14697
14724
 
14698
14725
  The baseline lives at .cdkrd/baselines/<stack>.<accountId>.<region>.json — commit it; review
14699
14726
  its diff in PRs. Ignore rules live in .cdkrd/ignore.yaml — also git-committed.`;
@@ -14729,6 +14756,7 @@ async function main(argv) {
14729
14756
  return 2;
14730
14757
  }
14731
14758
  }
14759
+ installInterruptGuard();
14732
14760
  const argv = process.argv.slice(2);
14733
14761
  main(argv).then((code) => flushAndExit(code)).catch((e) => {
14734
14762
  const msg = e?.message ?? String(e);