cdk-real-drift 0.4.36 → 0.4.37
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/dist/cli.js +52 -12
- package/dist/cli.js.map +1 -1
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -10582,7 +10582,31 @@ function splitRecordedByBaseline(recorded, baseline) {
|
|
|
10582
10582
|
function selectRecorded(findings, selectedKeys) {
|
|
10583
10583
|
return buildRecorded(findings).filter((e) => selectedKeys.has(recordedKey(e)));
|
|
10584
10584
|
}
|
|
10585
|
-
|
|
10585
|
+
function pathSegments$1(path) {
|
|
10586
|
+
return path.replace(/\[([^\]]*)\]/g, ".$1").split(".").filter((s) => s.length > 0);
|
|
10587
|
+
}
|
|
10588
|
+
function descendDeclared(node, seg) {
|
|
10589
|
+
if (node === null || typeof node !== "object") return void 0;
|
|
10590
|
+
if (Array.isArray(node)) {
|
|
10591
|
+
for (const el of node) if (el !== null && typeof el === "object" && !Array.isArray(el)) {
|
|
10592
|
+
for (const idf of DELTA_IDENTITY_FIELDS) if (String(el[idf]) === seg) return el;
|
|
10593
|
+
}
|
|
10594
|
+
const idx = Number(seg);
|
|
10595
|
+
return Number.isInteger(idx) && idx >= 0 && idx < node.length ? node[idx] : void 0;
|
|
10596
|
+
}
|
|
10597
|
+
return node[seg];
|
|
10598
|
+
}
|
|
10599
|
+
function declaredPathIsPromoted(declared, path) {
|
|
10600
|
+
if (declared === void 0) return false;
|
|
10601
|
+
let node = declared;
|
|
10602
|
+
for (const seg of pathSegments$1(path)) {
|
|
10603
|
+
if (node === null || typeof node !== "object") return true;
|
|
10604
|
+
const next = descendDeclared(node, seg);
|
|
10605
|
+
if (next === void 0) return false;
|
|
10606
|
+
node = next;
|
|
10607
|
+
}
|
|
10608
|
+
return true;
|
|
10609
|
+
}
|
|
10586
10610
|
/**
|
|
10587
10611
|
* Reconcile undeclared findings against the recorded baseline (per ENTRY, R62):
|
|
10588
10612
|
* - an undeclared finding matching an recorded entry (same value) is suppressed;
|
|
@@ -10708,7 +10732,7 @@ function applyBaseline(findings, baseline, opts = {}) {
|
|
|
10708
10732
|
removedFromTemplate.push(`${a.logicalId}.${a.path}`);
|
|
10709
10733
|
continue;
|
|
10710
10734
|
}
|
|
10711
|
-
if (
|
|
10735
|
+
if (declaredPathIsPromoted(opts.declaredByLogical?.get(a.logicalId), a.path)) {
|
|
10712
10736
|
promotedStale.push(`${a.logicalId}.${a.path}`);
|
|
10713
10737
|
continue;
|
|
10714
10738
|
}
|
|
@@ -10767,9 +10791,16 @@ function formatTypeMismatchStaleNote(paths) {
|
|
|
10767
10791
|
const n = paths.length;
|
|
10768
10792
|
return `note: ${n === 1 ? `baseline entry (${paths[0]}) was` : `${n} baseline entries were`} recorded against a resource whose logicalId now has a DIFFERENT type — re-run \`cdkrd record\`.`;
|
|
10769
10793
|
}
|
|
10770
|
-
/**
|
|
10794
|
+
/**
|
|
10795
|
+
* logicalId -> the resource's declared model, for applyBaseline's promotion check.
|
|
10796
|
+
* #1079: carries the WHOLE declared object (not just its top-level key set) so a NESTED
|
|
10797
|
+
* recorded path the user later declares is RESOLVED against the declared tree and folded
|
|
10798
|
+
* as promoted-to-code, rather than surfacing a false "removed since record". The map
|
|
10799
|
+
* feeds ApplyBaselineOptions.declaredByLogical; `applyBaseline` walks it per recorded path
|
|
10800
|
+
* via `declaredPathIsPromoted`.
|
|
10801
|
+
*/
|
|
10771
10802
|
function declaredKeysByLogical(resources) {
|
|
10772
|
-
return new Map(resources.map((r) => [r.logicalId,
|
|
10803
|
+
return new Map(resources.map((r) => [r.logicalId, r.declared]));
|
|
10773
10804
|
}
|
|
10774
10805
|
function constructPathsByLogical(resources) {
|
|
10775
10806
|
const m = /* @__PURE__ */ new Map();
|
|
@@ -13798,26 +13829,32 @@ async function revertStack(p) {
|
|
|
13798
13829
|
if (plan.items.length === 0) {
|
|
13799
13830
|
const dc = driftCount(drifted);
|
|
13800
13831
|
const uc = unrecordedCount(drifted);
|
|
13801
|
-
const
|
|
13802
|
-
out("\n" + style.drift(
|
|
13832
|
+
const reason = `nothing revertable — ${[...dc > 0 ? [`${dc} drift(s)`] : [], ...uc > 0 ? [`${uc} unrecorded value(s)`] : []].join(" + ")} remain.`;
|
|
13833
|
+
out("\n" + style.drift(reason));
|
|
13803
13834
|
return {
|
|
13804
13835
|
exit: 1,
|
|
13805
|
-
aborted: false
|
|
13836
|
+
aborted: false,
|
|
13837
|
+
refusedReason: reason
|
|
13806
13838
|
};
|
|
13807
13839
|
}
|
|
13808
13840
|
if (dryRun) {
|
|
13809
|
-
|
|
13841
|
+
const opCount = plan.items.reduce((n, i) => n + i.ops.length, 0);
|
|
13842
|
+
out(`\n(dry-run) would apply ${opCount} op(s) to ${plan.items.length} resource(s). No changes made.`);
|
|
13810
13843
|
return {
|
|
13811
13844
|
exit: 0,
|
|
13812
|
-
aborted: false
|
|
13845
|
+
aborted: false,
|
|
13846
|
+
plannedOps: opCount,
|
|
13847
|
+
plannedResources: plan.items.length
|
|
13813
13848
|
};
|
|
13814
13849
|
}
|
|
13815
13850
|
if (!yes) {
|
|
13816
13851
|
if (!interactive) {
|
|
13817
|
-
|
|
13852
|
+
const reason = "refusing to write to AWS non-interactively — pass --yes to apply (or --dry-run to preview).";
|
|
13853
|
+
console.error("\nrefusing to write to AWS non-interactively — pass --yes to apply (or --dry-run to preview).");
|
|
13818
13854
|
return {
|
|
13819
13855
|
exit: 2,
|
|
13820
|
-
aborted: false
|
|
13856
|
+
aborted: false,
|
|
13857
|
+
refusedReason: reason
|
|
13821
13858
|
};
|
|
13822
13859
|
}
|
|
13823
13860
|
if (!autoSelectAll) {
|
|
@@ -15517,7 +15554,10 @@ async function runRevert(args) {
|
|
|
15517
15554
|
reverted: outcome.reverted ?? 0,
|
|
15518
15555
|
failed: outcome.failed ?? 0,
|
|
15519
15556
|
aborted: outcome.aborted,
|
|
15520
|
-
exit: outcome.exit
|
|
15557
|
+
exit: outcome.exit,
|
|
15558
|
+
...outcome.plannedOps !== void 0 && { plannedOps: outcome.plannedOps },
|
|
15559
|
+
...outcome.plannedResources !== void 0 && { plannedResources: outcome.plannedResources },
|
|
15560
|
+
...outcome.refusedReason !== void 0 && { refusedReason: outcome.refusedReason }
|
|
15521
15561
|
});
|
|
15522
15562
|
} catch (e) {
|
|
15523
15563
|
if (isStackNotDeployed(e)) {
|