cdk-real-drift 0.12.21 → 0.12.22
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 +18 -1
- package/dist/cli.js.map +1 -1
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -594,6 +594,19 @@ async function loadConfig() {
|
|
|
594
594
|
if (e.code === "ENOENT") return { ignore: [] };
|
|
595
595
|
throw e;
|
|
596
596
|
}
|
|
597
|
+
return parseConfigRaw(raw);
|
|
598
|
+
}
|
|
599
|
+
/**
|
|
600
|
+
* Validate-and-parse the decoded `.cdkrd/ignore.yaml` text into a `CdkrdConfig`. This is
|
|
601
|
+
* loadConfig's body AFTER the read+decode, factored out so a caller that ALREADY holds the
|
|
602
|
+
* raw bytes (addIgnoreRules' pre-write `existingRaw`) can derive the same validated config
|
|
603
|
+
* from the SAME snapshot — without a second `readFile`. Sharing one snapshot between the
|
|
604
|
+
* write basis and the dedupe basis is the #1290 fix: a peer rule that landed on disk between
|
|
605
|
+
* two separate reads would otherwise be in the dedupe basis but not the write basis, and get
|
|
606
|
+
* clobbered. Applies every guard loadConfig applied on read (syntax errors, alias/anchor,
|
|
607
|
+
* non-mapping, unknown top-level key, `ignore` typed as an array, per-entry validation).
|
|
608
|
+
*/
|
|
609
|
+
function parseConfigRaw(raw) {
|
|
597
610
|
let parsed;
|
|
598
611
|
const doc = parseDocument(raw, { prettyErrors: true });
|
|
599
612
|
const [firstError] = doc.errors;
|
|
@@ -798,6 +811,10 @@ async function atomicWrite(dest, content) {
|
|
|
798
811
|
* a concurrent `cdkrd` process, the on-disk config is RE-READ immediately before the write
|
|
799
812
|
* and the incoming rules merged against THAT fresh state — so a rule another process
|
|
800
813
|
* appended between our initial `loadConfig` and our write is preserved, not clobbered.
|
|
814
|
+
* The re-read is a SINGLE snapshot: both the write basis (`existingRaw`, re-emitted with its
|
|
815
|
+
* comments) and the dedupe basis (`parseConfigRaw(existingRaw)`) come from those same bytes,
|
|
816
|
+
* so a peer rule on disk is BOTH carried forward AND deduped against — never in one but not
|
|
817
|
+
* the other (#1290).
|
|
801
818
|
*/
|
|
802
819
|
async function addIgnoreRules(newRules) {
|
|
803
820
|
const firstPass = mergeIgnoreRules((await loadConfig()).ignore, newRules);
|
|
@@ -814,7 +831,7 @@ async function addIgnoreRules(newRules) {
|
|
|
814
831
|
} catch (e) {
|
|
815
832
|
if (e.code !== "ENOENT") throw e;
|
|
816
833
|
}
|
|
817
|
-
const { added, alreadyPresent } = mergeIgnoreRules(existingRaw !== void 0 && existingRaw.trim() !== "" ? (
|
|
834
|
+
const { added, alreadyPresent } = mergeIgnoreRules(existingRaw !== void 0 && existingRaw.trim() !== "" ? parseConfigRaw(existingRaw).ignore : [], newRules);
|
|
818
835
|
if (added.length === 0) return {
|
|
819
836
|
path: CONFIG_PATH,
|
|
820
837
|
added,
|