cdk-real-drift 0.3.11 → 0.3.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.
- package/dist/cli.js +33 -19
- package/dist/cli.js.map +1 -1
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -12417,14 +12417,26 @@ const driftCount = (findings) => findings.filter(isDrift).length;
|
|
|
12417
12417
|
const unrecordedCount = (findings) => findings.filter((f) => f.unrecorded === true).length;
|
|
12418
12418
|
const sleep = (ms) => new Promise((r) => setTimeout(r, ms));
|
|
12419
12419
|
/**
|
|
12420
|
+
* The per-stack label shown in a DECISION prompt — the SAME `Name (region)` form the
|
|
12421
|
+
* report header uses (`check.ts` `${stackName} (${region})`). After #899 exact-name
|
|
12422
|
+
* selection targets EVERY same-named region instance, so a bare `stackName` in a
|
|
12423
|
+
* record/ignore/revert prompt is indistinguishable across regions (a wrong-region
|
|
12424
|
+
* record/ignore/revert hazard, #947). Naming the region disambiguates them. Pure +
|
|
12425
|
+
* exported so the wording is unit-tested.
|
|
12426
|
+
*/
|
|
12427
|
+
function stackLabel$1(stackName, region) {
|
|
12428
|
+
return `${stackName} (${region})`;
|
|
12429
|
+
}
|
|
12430
|
+
/**
|
|
12420
12431
|
* The revert confirm message (R52). When NOT-revertable findings exist (e.g. a
|
|
12421
12432
|
* no-baseline first check with one declared drift and 100+ undeclared values),
|
|
12422
12433
|
* users read "This WRITES to AWS" as "everything I just saw gets written" —
|
|
12423
12434
|
* state explicitly that ONLY the listed op(s) are written and the rest is
|
|
12424
12435
|
* untouched. Pure + exported so the wording is unit-tested.
|
|
12425
12436
|
*/
|
|
12426
|
-
function revertConfirmMessage(stackName, opCount, notRevertableCount) {
|
|
12427
|
-
|
|
12437
|
+
function revertConfirmMessage(stackName, region, opCount, notRevertableCount) {
|
|
12438
|
+
const scope = notRevertableCount > 0 ? ` Only the ${opCount} selected op(s) are written — the ${notRevertableCount} NOT-revertable finding(s) are untouched.` : "";
|
|
12439
|
+
return `Apply ${opCount} revert op(s) to ${stackLabel$1(stackName, region)}? This WRITES to AWS.${scope}`;
|
|
12428
12440
|
}
|
|
12429
12441
|
/**
|
|
12430
12442
|
* The post-revert surviving-drift pointer list (R46), capped (R52): after a
|
|
@@ -12448,8 +12460,9 @@ function formatSurvivingDrift(remaining, stackName = "", cap = 10) {
|
|
|
12448
12460
|
* (the folded would just nag forever), whereas deselecting a standout to "record the rest"
|
|
12449
12461
|
* IS useful — so standouts toggle, the folded always record. Pure + exported.
|
|
12450
12462
|
*/
|
|
12451
|
-
function recordSelectMessage(stackName, foldedCount = 0) {
|
|
12452
|
-
|
|
12463
|
+
function recordSelectMessage(stackName, region, foldedCount = 0) {
|
|
12464
|
+
const fold = foldedCount > 0 ? `; +${foldedCount} folded sub-key(s) ALWAYS recorded too (--verbose to itemize)` : "";
|
|
12465
|
+
return `${stackLabel$1(stackName, region)}: select undeclared value(s) to record (unselected stay reported)${fold}`;
|
|
12453
12466
|
}
|
|
12454
12467
|
/**
|
|
12455
12468
|
* Split the to-record delta into STANDOUT (itemized in the record multiselect) and FOLDED
|
|
@@ -12540,8 +12553,8 @@ function filterRevertPlan(plan, picked) {
|
|
|
12540
12553
|
notRevertable: plan.notRevertable
|
|
12541
12554
|
};
|
|
12542
12555
|
}
|
|
12543
|
-
function revertSelectMessage(stackName) {
|
|
12544
|
-
return `${stackName}: select the op(s) to revert (unselected are not written)`;
|
|
12556
|
+
function revertSelectMessage(stackName, region) {
|
|
12557
|
+
return `${stackLabel$1(stackName, region)}: select the op(s) to revert (unselected are not written)`;
|
|
12545
12558
|
}
|
|
12546
12559
|
/**
|
|
12547
12560
|
* Record the current undeclared state into the baseline file. In an interactive run
|
|
@@ -12559,7 +12572,7 @@ async function recordStack(p) {
|
|
|
12559
12572
|
const { stackName, region, desired, findings, yes, interactive, preselectedKeys, expandNested } = p;
|
|
12560
12573
|
const existing = await loadBaseline(stackName, desired.accountId, region);
|
|
12561
12574
|
if (existing) checkBaselineAccount(existing, desired.accountId, stackName);
|
|
12562
|
-
if (!yes && existing) console.error(`note: ${stackName}: will overwrite the existing baseline file on confirm (nothing written yet; it is git-tracked — review the diff afterwards). Pass --yes to silence.`);
|
|
12575
|
+
if (!yes && existing) console.error(`note: ${stackLabel$1(stackName, region)}: will overwrite the existing baseline file on confirm (nothing written yet; it is git-tracked — review the diff afterwards). Pass --yes to silence.`);
|
|
12563
12576
|
let recorded = carryForwardUnreadable(buildRecorded(findings), existing, findings);
|
|
12564
12577
|
let refreshedOnly = false;
|
|
12565
12578
|
if (!yes && recorded.length > 0) {
|
|
@@ -12582,7 +12595,7 @@ async function recordStack(p) {
|
|
|
12582
12595
|
const { standout, folded } = splitFoldedNested(changed, findings, expandNested);
|
|
12583
12596
|
if (standout.length === 0) {
|
|
12584
12597
|
const proceed = await confirm({
|
|
12585
|
-
message: `${stackName}: record ${folded.length} undeclared sub-key value(s)? (--verbose to itemize each)`,
|
|
12598
|
+
message: `${stackLabel$1(stackName, region)}: record ${folded.length} undeclared sub-key value(s)? (--verbose to itemize each)`,
|
|
12586
12599
|
initialValue: true
|
|
12587
12600
|
});
|
|
12588
12601
|
if (isCancel(proceed) || !proceed) {
|
|
@@ -12594,7 +12607,7 @@ async function recordStack(p) {
|
|
|
12594
12607
|
}
|
|
12595
12608
|
picked = changed.map((e) => recordedKey(e));
|
|
12596
12609
|
} else {
|
|
12597
|
-
const fromPrompt = await bulkMultiselect(recordSelectMessage(stackName, folded.length), standout.map((e) => ({
|
|
12610
|
+
const fromPrompt = await bulkMultiselect(recordSelectMessage(stackName, region, folded.length), standout.map((e) => ({
|
|
12598
12611
|
value: recordedKey(e),
|
|
12599
12612
|
label: e.path ? `${e.logicalId}.${e.path}` : `${e.logicalId} (added resource)`,
|
|
12600
12613
|
selected: true
|
|
@@ -12613,7 +12626,7 @@ async function recordStack(p) {
|
|
|
12613
12626
|
recorded = [...unchanged, ...selectedChanged];
|
|
12614
12627
|
if (recorded.length === 0 && !preselectedKeys) {
|
|
12615
12628
|
const proceed = await confirm({
|
|
12616
|
-
message: `${stackName}: record nothing? This writes an EMPTY baseline — every undeclared value stays reported as unrecorded.`,
|
|
12629
|
+
message: `${stackLabel$1(stackName, region)}: record nothing? This writes an EMPTY baseline — every undeclared value stays reported as unrecorded.`,
|
|
12617
12630
|
initialValue: false
|
|
12618
12631
|
});
|
|
12619
12632
|
if (isCancel(proceed) || !proceed) {
|
|
@@ -12643,8 +12656,8 @@ async function recordStack(p) {
|
|
|
12643
12656
|
}
|
|
12644
12657
|
/** Header for ignore's multiselect. The key hints are rendered by `bulkMultiselect`
|
|
12645
12658
|
* itself, so this is just the one-line prompt. Pure + exported for unit tests. */
|
|
12646
|
-
function ignoreSelectMessage(stackName) {
|
|
12647
|
-
return `${stackName}: select drift to ignore — stops reporting it (writes .cdkrd/ignore.yaml)`;
|
|
12659
|
+
function ignoreSelectMessage(stackName, region) {
|
|
12660
|
+
return `${stackLabel$1(stackName, region)}: select drift to ignore — stops reporting it (writes .cdkrd/ignore.yaml)`;
|
|
12648
12661
|
}
|
|
12649
12662
|
const ignoreFindingKey = (f) => `${f.logicalId}::${f.path}`;
|
|
12650
12663
|
/**
|
|
@@ -12695,7 +12708,7 @@ async function ignoreStack(p) {
|
|
|
12695
12708
|
added: 0
|
|
12696
12709
|
};
|
|
12697
12710
|
}
|
|
12698
|
-
const picked = await bulkMultiselect(ignoreSelectMessage(stackName), ignoreSelectOptions(ignorable, stackName));
|
|
12711
|
+
const picked = await bulkMultiselect(ignoreSelectMessage(stackName, region), ignoreSelectOptions(ignorable, stackName));
|
|
12699
12712
|
if (picked === void 0) {
|
|
12700
12713
|
console.error(`note: ${stackName}: ignore cancelled — config unchanged`);
|
|
12701
12714
|
return {
|
|
@@ -12873,7 +12886,7 @@ async function revertStack(p) {
|
|
|
12873
12886
|
};
|
|
12874
12887
|
}
|
|
12875
12888
|
if (!autoSelectAll) {
|
|
12876
|
-
const picked = await bulkMultiselect(revertSelectMessage(stackName), revertSelectOptions(plan));
|
|
12889
|
+
const picked = await bulkMultiselect(revertSelectMessage(stackName, region), revertSelectOptions(plan));
|
|
12877
12890
|
if (picked === void 0) {
|
|
12878
12891
|
out(style.note("aborted."));
|
|
12879
12892
|
return {
|
|
@@ -12890,7 +12903,7 @@ async function revertStack(p) {
|
|
|
12890
12903
|
};
|
|
12891
12904
|
}
|
|
12892
12905
|
}
|
|
12893
|
-
const ok = await confirm({ message: revertConfirmMessage(stackName, plan.items.reduce((n, i) => n + i.ops.length, 0), plan.notRevertable.length) });
|
|
12906
|
+
const ok = await confirm({ message: revertConfirmMessage(stackName, region, plan.items.reduce((n, i) => n + i.ops.length, 0), plan.notRevertable.length) });
|
|
12894
12907
|
if (isCancel(ok) || !ok) {
|
|
12895
12908
|
out(style.note("aborted."));
|
|
12896
12909
|
return {
|
|
@@ -13907,9 +13920,10 @@ function buildResolveOptions(actions, decidableCount, recordLabel = "snapshot")
|
|
|
13907
13920
|
/** The top-menu prompt, worded by the remaining exit state (drift vs unrecorded-only vs
|
|
13908
13921
|
* R141 no-baseline establish). `prefix` carries the `[2/3] ` multi-stack position cue
|
|
13909
13922
|
* (issue #539) — empty for a lone stack. Pure + exported. */
|
|
13910
|
-
function resolveMenuMessage(stackName, code, establishOnly = false, prefix = "") {
|
|
13911
|
-
|
|
13912
|
-
|
|
13923
|
+
function resolveMenuMessage(stackName, region, code, establishOnly = false, prefix = "") {
|
|
13924
|
+
const label = stackLabel$1(stackName, region);
|
|
13925
|
+
if (establishOnly) return `${prefix}${label}: no .cdkrd baseline yet — record the current state as your baseline?`;
|
|
13926
|
+
return code === 1 ? `${prefix}${label}: drift found — what do you want to do?` : `${prefix}${label}: potential drift found (live-only, no baseline yet) — what do you want to do?`;
|
|
13913
13927
|
}
|
|
13914
13928
|
async function resolveInteractively(p) {
|
|
13915
13929
|
const opts = baselineOpts(p);
|
|
@@ -13929,7 +13943,7 @@ async function resolveInteractively(p) {
|
|
|
13929
13943
|
const recordLabel = recordable ? "snapshot" : declaredDrift ? "establish-drift" : deletedDrift ? "establish-deleted" : "establish";
|
|
13930
13944
|
const options = buildResolveOptions(actions, decidable.length, recordLabel);
|
|
13931
13945
|
const choice = await select({
|
|
13932
|
-
message: resolveMenuMessage(p.stackName, code, establishOnly, p.positionPrefix ?? ""),
|
|
13946
|
+
message: resolveMenuMessage(p.stackName, p.region, code, establishOnly, p.positionPrefix ?? ""),
|
|
13933
13947
|
options,
|
|
13934
13948
|
initialValue: "nothing"
|
|
13935
13949
|
});
|