cdk-real-drift 0.5.1 → 0.5.3
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 +42 -13
- package/dist/cli.js.map +1 -1
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -10657,7 +10657,12 @@ function carryForwardUnreadable(recorded, existing, findings) {
|
|
|
10657
10657
|
const unreadable = new Set(findings.filter((f) => f.tier === "skipped" || f.modelReadFailed).map((f) => f.logicalId));
|
|
10658
10658
|
if (unreadable.size === 0) return recorded;
|
|
10659
10659
|
const present = new Set(recorded.map(recordedKey));
|
|
10660
|
-
const
|
|
10660
|
+
const isUnread = (e) => {
|
|
10661
|
+
if (unreadable.has(e.logicalId)) return true;
|
|
10662
|
+
const parent = addedChildParentLogicalId(e.logicalId);
|
|
10663
|
+
return parent !== void 0 && unreadable.has(parent);
|
|
10664
|
+
};
|
|
10665
|
+
const preserved = prior.filter((e) => isUnread(e) && !present.has(recordedKey(e)));
|
|
10661
10666
|
return preserved.length === 0 ? recorded : [...recorded, ...preserved];
|
|
10662
10667
|
}
|
|
10663
10668
|
/**
|
|
@@ -10861,6 +10866,10 @@ function selectRecorded(findings, selectedKeys) {
|
|
|
10861
10866
|
function pathSegments$1(path) {
|
|
10862
10867
|
return path.replace(/\[([^\]]*)\]/g, ".$1").split(".").filter((s) => s.length > 0);
|
|
10863
10868
|
}
|
|
10869
|
+
function addedChildParentLogicalId(logicalId) {
|
|
10870
|
+
const slash = logicalId.indexOf("/");
|
|
10871
|
+
return slash < 0 ? void 0 : logicalId.slice(0, slash);
|
|
10872
|
+
}
|
|
10864
10873
|
function descendDeclared(node, seg) {
|
|
10865
10874
|
if (node === null || typeof node !== "object") return void 0;
|
|
10866
10875
|
if (Array.isArray(node)) {
|
|
@@ -10979,6 +10988,8 @@ function applyBaseline(findings, baseline, opts = {}) {
|
|
|
10979
10988
|
const currentPaths = new Set(findings.filter((f) => f.tier === "undeclared" || f.tier === "atDefault" || f.tier === "generated").map((f) => `${f.logicalId}.${f.path}`));
|
|
10980
10989
|
const skippedLogical = new Set(findings.filter((f) => f.tier === "skipped").map((f) => f.logicalId));
|
|
10981
10990
|
const deletedLogical = new Set(findings.filter((f) => f.tier === "deleted").map((f) => f.logicalId));
|
|
10991
|
+
const presentAddedLogical = new Set(findings.filter((f) => f.tier === "added").map((f) => f.logicalId));
|
|
10992
|
+
const readParentLogical = new Set(findings.filter((f) => f.tier !== "skipped" && f.tier !== "deleted").map((f) => f.logicalId));
|
|
10982
10993
|
const declaredDriftByLogical = /* @__PURE__ */ new Map();
|
|
10983
10994
|
for (const f of findings) {
|
|
10984
10995
|
if (f.tier !== "declared") continue;
|
|
@@ -10992,7 +11003,20 @@ function applyBaseline(findings, baseline, opts = {}) {
|
|
|
10992
11003
|
const replacedStale = [];
|
|
10993
11004
|
const typeMismatchStale = [];
|
|
10994
11005
|
for (const a of recorded) {
|
|
10995
|
-
if (a.path === "")
|
|
11006
|
+
if (a.path === "") {
|
|
11007
|
+
if (presentAddedLogical.has(a.logicalId)) continue;
|
|
11008
|
+
const parent = addedChildParentLogicalId(a.logicalId);
|
|
11009
|
+
if (!(parent !== void 0 && readParentLogical.has(parent))) continue;
|
|
11010
|
+
kept.push({
|
|
11011
|
+
tier: "deleted",
|
|
11012
|
+
logicalId: a.logicalId,
|
|
11013
|
+
resourceType: a.resourceType,
|
|
11014
|
+
...opts.constructPathByLogical?.get(a.logicalId) !== void 0 && { constructPath: opts.constructPathByLogical.get(a.logicalId) },
|
|
11015
|
+
path: "",
|
|
11016
|
+
note: "recorded added resource removed since record"
|
|
11017
|
+
});
|
|
11018
|
+
continue;
|
|
11019
|
+
}
|
|
10996
11020
|
if (isTypeVoid(a)) {
|
|
10997
11021
|
typeMismatchStale.push(`${a.logicalId}.${a.path}`);
|
|
10998
11022
|
continue;
|
|
@@ -15476,8 +15500,17 @@ async function perFinding(p, decidable) {
|
|
|
15476
15500
|
exit: p.code,
|
|
15477
15501
|
awsMutated: false
|
|
15478
15502
|
};
|
|
15503
|
+
if (groups.ignore.length > 0) await ignoreStack({
|
|
15504
|
+
stackName: p.stackName,
|
|
15505
|
+
findings: groups.ignore,
|
|
15506
|
+
yes: true,
|
|
15507
|
+
interactive: true,
|
|
15508
|
+
accountId: p.desired.accountId,
|
|
15509
|
+
region: p.region
|
|
15510
|
+
});
|
|
15479
15511
|
if (groups.record.length > 0) {
|
|
15480
15512
|
const preselectedKeys = new Set(buildRecorded(groups.record).map(recordedKey));
|
|
15513
|
+
const recordConfig = groups.ignore.length > 0 ? await loadConfig() : p.config;
|
|
15481
15514
|
await recordStack({
|
|
15482
15515
|
stackName: p.stackName,
|
|
15483
15516
|
region: p.region,
|
|
@@ -15486,22 +15519,15 @@ async function perFinding(p, decidable) {
|
|
|
15486
15519
|
stackName: p.stackName,
|
|
15487
15520
|
accountId: p.desired.accountId,
|
|
15488
15521
|
region: p.region
|
|
15489
|
-
},
|
|
15522
|
+
}, recordConfig),
|
|
15490
15523
|
yes: p.yes,
|
|
15491
15524
|
interactive: true,
|
|
15492
15525
|
preselectedKeys
|
|
15493
15526
|
});
|
|
15494
15527
|
}
|
|
15495
|
-
if (groups.ignore.length > 0) await ignoreStack({
|
|
15496
|
-
stackName: p.stackName,
|
|
15497
|
-
findings: groups.ignore,
|
|
15498
|
-
yes: true,
|
|
15499
|
-
interactive: true,
|
|
15500
|
-
accountId: p.desired.accountId,
|
|
15501
|
-
region: p.region
|
|
15502
|
-
});
|
|
15503
15528
|
let revertResolved = /* @__PURE__ */ new Set();
|
|
15504
15529
|
let revertExit = 0;
|
|
15530
|
+
let revertAborted = false;
|
|
15505
15531
|
if (groups.revert.length > 0) {
|
|
15506
15532
|
const revertKeys = new Set(groups.revert.map(keyOf));
|
|
15507
15533
|
const outcome = await revertStack({
|
|
@@ -15522,15 +15548,18 @@ async function perFinding(p, decidable) {
|
|
|
15522
15548
|
interactive: true,
|
|
15523
15549
|
autoSelectAll: true
|
|
15524
15550
|
});
|
|
15551
|
+
revertAborted = outcome.aborted;
|
|
15525
15552
|
if (!outcome.aborted) {
|
|
15526
15553
|
revertResolved = revertKeys;
|
|
15527
15554
|
revertExit = outcome.exit;
|
|
15528
15555
|
}
|
|
15529
15556
|
}
|
|
15530
|
-
|
|
15557
|
+
const revertSummary = revertAborted ? summarizeChoices(chosen.map((a) => a === "revert" ? "skip" : a)) : summarizeChoices(chosen);
|
|
15558
|
+
const cancelledNote = revertAborted ? ` (${groups.revert.length} revert cancelled)` : "";
|
|
15559
|
+
console.error(`note: ${p.stackName}: per-finding decisions applied (${revertSummary})${cancelledNote}.`);
|
|
15531
15560
|
return {
|
|
15532
15561
|
exit: Math.max(await recomputeExit(p, revertResolved), revertExit),
|
|
15533
|
-
awsMutated: groups.revert.length > 0
|
|
15562
|
+
awsMutated: groups.revert.length > 0 && !revertAborted
|
|
15534
15563
|
};
|
|
15535
15564
|
}
|
|
15536
15565
|
|