cdk-real-drift 0.4.22 → 0.4.23

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
@@ -573,11 +573,17 @@ async function loadConfig() {
573
573
  }
574
574
  let parsed;
575
575
  const doc = parseDocument(raw, { prettyErrors: true });
576
- if (doc.errors.length > 0) throw new Error(`${CONFIG_PATH} is not valid YAML`);
576
+ const [firstError] = doc.errors;
577
+ if (firstError !== void 0) {
578
+ const more = doc.errors.length > 1 ? ` (+${doc.errors.length - 1} more)` : "";
579
+ throw new Error(`${CONFIG_PATH} is not valid YAML: ${firstError.message}${more}`);
580
+ }
577
581
  try {
578
582
  parsed = doc.toJS();
579
- } catch {
580
- throw new Error(`${CONFIG_PATH} is not valid YAML`);
583
+ } catch (e) {
584
+ const msg = e.message;
585
+ const hint = /alias|anchor/i.test(msg) ? " — a glob path starting with \"*\" or \"?\" must be quoted (e.g. `path: \"*.DesiredCount\"`) so it is read as a literal, not YAML alias/anchor syntax" : "";
586
+ throw new Error(`${CONFIG_PATH} is not valid YAML: ${msg}${hint}`);
581
587
  }
582
588
  if (parsed === null || parsed === void 0) return { ignore: [] };
583
589
  if (typeof parsed !== "object" || Array.isArray(parsed)) throw new Error(`${CONFIG_PATH} must be a YAML mapping`);
@@ -3788,6 +3794,16 @@ const TRUE_BOOL_TEST = /^(?:[Yy]es|YES|[Tt]rue|TRUE|[Oo]n|ON)$/;
3788
3794
  const FALSE_BOOL_TEST = /^(?:[Nn]o|NO|[Ff]alse|FALSE|[Oo]ff|OFF)$/;
3789
3795
  const BOOL_TAG = "tag:yaml.org,2002:bool";
3790
3796
  const TIMESTAMP_TAG = "tag:yaml.org,2002:timestamp";
3797
+ const INT_TAG = "tag:yaml.org,2002:int";
3798
+ const FLOAT_TAG = "tag:yaml.org,2002:float";
3799
+ const EXOTIC_NUMBER_FORMATS = new Set([
3800
+ "OCT",
3801
+ "HEX",
3802
+ "BIN",
3803
+ "TIME"
3804
+ ]);
3805
+ const CFN_INT_TEST = /^[-+]?(?:0|[1-9][0-9]*)$/;
3806
+ const CFN_FLOAT_TEST = /^[-+]?(?:(?:0|[1-9][0-9]*)(?:\.[0-9]*)?|\.[0-9]+)(?:[eE][-+]?[0-9]+)?$/;
3791
3807
  function restrictYaml11Tags(baseTags) {
3792
3808
  const restricted = [];
3793
3809
  for (const tag of baseTags) {
@@ -3803,6 +3819,25 @@ function restrictYaml11Tags(baseTags) {
3803
3819
  });
3804
3820
  continue;
3805
3821
  }
3822
+ if (tag.tag === INT_TAG) {
3823
+ const scalar = tag;
3824
+ if (scalar.format && EXOTIC_NUMBER_FORMATS.has(scalar.format)) continue;
3825
+ restricted.push({
3826
+ ...scalar,
3827
+ test: CFN_INT_TEST
3828
+ });
3829
+ continue;
3830
+ }
3831
+ if (tag.tag === FLOAT_TAG) {
3832
+ const scalar = tag;
3833
+ const isNaNTag = scalar.test instanceof RegExp && scalar.test.test(".inf");
3834
+ if (scalar.format && EXOTIC_NUMBER_FORMATS.has(scalar.format) || isNaNTag) continue;
3835
+ restricted.push({
3836
+ ...scalar,
3837
+ test: CFN_FLOAT_TEST
3838
+ });
3839
+ continue;
3840
+ }
3806
3841
  if (tag.tag === BOOL_TAG) {
3807
3842
  const scalar = tag;
3808
3843
  const isTrueTag = scalar.identify?.(true) === true;