cdk-real-drift 0.12.16 → 0.12.18

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 CHANGED
@@ -563,6 +563,20 @@ const RULE_OBJECT_KEYS = new Set([
563
563
  "region"
564
564
  ]);
565
565
  const FILE_HEADER = "# cdkrd ignore rules — properties cdkrd should stop reporting as drift.\n# Each rule: { path, stack?, account?, region? }; `path` is a\n# \"<constructPath|logicalId>.<property>\" glob, the scopes narrow WHERE it applies.\n# Add a comment above a rule to record WHY it is ignored.\n";
566
+ function looksUtf16(buf, nulAtOddIndex) {
567
+ const n = Math.min(buf.length, 64);
568
+ if (n < 2) return false;
569
+ let pairs = 0;
570
+ for (let i = nulAtOddIndex ? 1 : 0; i < n; i += 2) {
571
+ if (buf[i] !== 0) return false;
572
+ pairs++;
573
+ }
574
+ return pairs > 0;
575
+ }
576
+ function decodeConfig(buf) {
577
+ const encoding = buf[0] === 255 && buf[1] === 254 ? "utf-16le" : buf[0] === 254 && buf[1] === 255 ? "utf-16be" : looksUtf16(buf, true) ? "utf-16le" : looksUtf16(buf, false) ? "utf-16be" : "utf-8";
578
+ return new TextDecoder(encoding).decode(buf);
579
+ }
566
580
  /**
567
581
  * Load `.cdkrd/ignore.yaml` (cwd-relative). Absent file -> empty config (no migration
568
582
  * needed). A comments-only / empty file parses to null -> empty config too. Invalid
@@ -575,7 +589,7 @@ const FILE_HEADER = "# cdkrd ignore rules — properties cdkrd should stop repor
575
589
  async function loadConfig() {
576
590
  let raw;
577
591
  try {
578
- raw = await readFile(CONFIG_PATH, "utf8");
592
+ raw = decodeConfig(await readFile(CONFIG_PATH));
579
593
  } catch (e) {
580
594
  if (e.code === "ENOENT") return { ignore: [] };
581
595
  throw e;
@@ -796,7 +810,7 @@ async function addIgnoreRules(newRules) {
796
810
  await mkdir(dirname(CONFIG_PATH), { recursive: true });
797
811
  let existingRaw;
798
812
  try {
799
- existingRaw = await readFile(CONFIG_PATH, "utf8");
813
+ existingRaw = decodeConfig(await readFile(CONFIG_PATH));
800
814
  } catch (e) {
801
815
  if (e.code !== "ENOENT") throw e;
802
816
  }
@@ -9783,7 +9797,9 @@ const readMetricFilter = async ({ physicalId, declared, region }) => {
9783
9797
  ...t.unit !== void 0 && { Unit: t.unit },
9784
9798
  ...t.dimensions !== void 0 && { Dimensions: t.dimensions }
9785
9799
  })),
9786
- ...mf.applyOnTransformedLogs !== void 0 && { ApplyOnTransformedLogs: mf.applyOnTransformedLogs }
9800
+ ...mf.applyOnTransformedLogs !== void 0 && { ApplyOnTransformedLogs: mf.applyOnTransformedLogs },
9801
+ ...mf.fieldSelectionCriteria !== void 0 && { FieldSelectionCriteria: mf.fieldSelectionCriteria },
9802
+ ...mf.emitSystemFieldDimensions !== void 0 && { EmitSystemFieldDimensions: mf.emitSystemFieldDimensions }
9787
9803
  };
9788
9804
  };
9789
9805
  const readSchedulerSchedule = async ({ physicalId, declared, region }) => {
@@ -10792,7 +10808,7 @@ function resolveRefNode(node, definitions) {
10792
10808
  return n;
10793
10809
  }
10794
10810
  function pointerToDotted$1(p) {
10795
- return p.replace(/^\/properties\//, "").replace(/\/properties\//g, "/").replace(/\/properties$/, "").replace(/\//g, ".");
10811
+ return p.replace(/^\/?properties\//, "").replace(/\/properties\//g, "/").replace(/\/properties$/, "").replace(/\//g, ".");
10796
10812
  }
10797
10813
  function variantBranches(node) {
10798
10814
  return [