@bugron/validate-dependabot-yaml
Version:
CLI for validating Dependabot v2 YAML configuration files
1,281 lines (1,270 loc) • 262 kB
JavaScript
#!/usr/bin/env node
import { createRequire } from "node:module";
import path, { dirname } from "node:path";
import fs$1, { readFileSync } from "node:fs";
import Ajv from "ajv";
import YAML from "yaml";
import fetch from "node-fetch";
import process$1 from "node:process";
import require$$0$1, { format } from "util";
import { normalize, resolve } from "path";
import { readFileSync as readFileSync$1 } from "fs";
import { fileURLToPath } from "node:url";
import require$$0$2 from "os";
import require$$0 from "url";
//#region rolldown:runtime
var __require = /* @__PURE__ */ createRequire(import.meta.url);
//#endregion
//#region src/parseDependabotYaml.ts
function parseDependabotYaml(dependabotYamlContents) {
return YAML.parse(dependabotYamlContents);
}
//#endregion
//#region src/validators/uniqueCombination.ts
/**
* Fixes the issue mentioned in https://github.com/marocchino/validate-dependabot/issues/743
* See docs: https://docs.github.com/en/code-security/dependabot/dependabot-version-updates/configuration-options-for-the-dependabot.yml-file#directory
*
* Directory/directories values must be unique and cannot overlap with the directory or directories entries in blocks that have the same ecosystem and target-branch.
*/
function uniqueCombination(json) {
const groupedUpdates = json.updates.reduce((allUpdates, update) => {
const key$1 = `${update["package-ecosystem"]}-${update["target-branch"]}`;
allUpdates[key$1] = [...allUpdates[key$1] || [], update];
return allUpdates;
}, {});
if (Object.keys(groupedUpdates).some((key$1) => {
const allDirectories = groupedUpdates[key$1]?.flatMap((update) => {
if ("directory" in update) return [update.directory];
return update.directories;
});
return new Set(allDirectories).size !== allDirectories?.length;
})) return {
keyword: "customError",
dataPath: ".updates",
schemaPath: "#/customError",
params: { propertyName: "customError" },
message: "Update configs must have a unique combination of 'package-ecosystem', 'directory', and 'target-branch'"
};
}
//#endregion
//#region src/validators/dependencyTypeGroups.ts
const SUPPORTED_ECOSYSTEMS$1 = [
"bundler",
"composer",
"mix",
"maven",
"npm",
"pip"
];
/**
* Fixes the issue mentioned in https://github.com/dependabot/dependabot-core/issues/13121
* See docs: https://docs.github.com/en/code-security/dependabot/working-with-dependabot/dependabot-options-reference#dependency-type-groups
*
* Ensures that dependency-type option is used with supported package ecosystems
*/
function dependencyTypeGroups(json) {
if (json.updates.some((update) => !SUPPORTED_ECOSYSTEMS$1.includes(update["package-ecosystem"]) && Object.keys(update.groups ?? []).some((groupName) => update.groups?.[groupName]?.["dependency-type"] !== void 0))) return {
keyword: "customError",
dataPath: ".dependency-type",
schemaPath: "#/customError",
params: { propertyName: "customError" },
message: `'dependency-type' option is only supported for the following package ecosystems: ${SUPPORTED_ECOSYSTEMS$1}`
};
}
//#endregion
//#region src/validators/unsupportedCooldownSemVer.ts
const SUPPORTED_ECOSYSTEMS = [
"bundler",
"bun",
"cargo",
"composer",
"dotnet-sdk",
"elm",
"gomod",
"gradle",
"mix",
"maven",
"npm",
"nuget",
"pip",
"pub",
"swift",
"uv"
];
/**
* Fixes the issue mentioned in https://github.com/dependabot/dependabot-core/issues/13121#issuecomment-3314288971
* See docs: https://docs.github.com/en/code-security/dependabot/working-with-dependabot/dependabot-options-reference#configuration-of-cooldown
*
* Ensures cooldown semver-major-days, semver-minor-days, semver-patch-days options are used with supported package ecosystems
*/
function unsupportedCooldownSemVer(json) {
const errorObjects = [];
for (let index = 0; index < json.updates.length; index++) {
const update = json.updates[index];
if (update?.cooldown && !SUPPORTED_ECOSYSTEMS.includes(update["package-ecosystem"])) {
for (const key$1 of [
"semver-major-days",
"semver-minor-days",
"semver-patch-days"
]) if (update.cooldown[key$1] !== void 0) errorObjects.push({
keyword: "unsupportedCooldownSemVer",
dataPath: `/updates/${index}/cooldown/${key$1}`,
schemaPath: "#/customError",
params: {},
message: `The '${key$1}' option in 'cooldown' is not supported for the '${update["package-ecosystem"]}' package ecosystem.`
});
}
}
return errorObjects;
}
//#endregion
//#region src/customValidations.ts
function customValidations(json) {
return [
uniqueCombination,
dependencyTypeGroups,
unsupportedCooldownSemVer
].reduce((errors, validatorFunction) => {
const error = validatorFunction(json);
if (!error) return errors;
if (Array.isArray(error)) return [...errors, ...error];
return [...errors, error];
}, []);
}
//#endregion
//#region src/fetchSchema.ts
async function fetchSchema() {
return (await fetch("https://json.schemastore.org/dependabot-2.0.json")).json();
}
//#endregion
//#region src/validateDependabotYaml.ts
async function validateDependabotYaml(dependabotYamlContents, v2Schema) {
const ajv = new Ajv({
extendRefs: true,
allErrors: true
});
const json = parseDependabotYaml(dependabotYamlContents);
const customErrors = customValidations(json);
let schema = v2Schema;
if (!schema) schema = await fetchSchema();
const validate$1 = ajv.compile(schema);
if (await validate$1(json) && !customErrors.length) return { message: "success" };
return {
errors: [...validate$1.errors ?? [], ...customErrors],
message: "failure"
};
}
//#endregion
//#region src/errorLoggers.ts
function jsonLogger(errors, pretty = false) {
process.stdout.write(JSON.stringify(errors, null, pretty ? 2 : 0));
}
function markdownLogger(errors) {
const message = `
## Dependabot YAML validation errors
| keyword | message | dataPath |
| ------- | ------- | -------- |
${errors.map(({ keyword: keyword$1, message: message$1, dataPath }) => `| ${keyword$1} | ${message$1} | ${dataPath} |`).join("\n")}
`;
process.stdout.write(message);
}
//#endregion
//#region node_modules/.pnpm/meow@13.2.0/node_modules/meow/build/dependencies.js
function camelCase$1(str) {
if (!(str !== str.toLowerCase() && str !== str.toUpperCase())) str = str.toLowerCase();
if (str.indexOf("-") === -1 && str.indexOf("_") === -1) return str;
else {
let camelcase = "";
let nextChrUpper = false;
const leadingHyphens = str.match(/^-+/);
for (let i = leadingHyphens ? leadingHyphens[0].length : 0; i < str.length; i++) {
let chr = str.charAt(i);
if (nextChrUpper) {
nextChrUpper = false;
chr = chr.toUpperCase();
}
if (i !== 0 && (chr === "-" || chr === "_")) nextChrUpper = true;
else if (chr !== "-" && chr !== "_") camelcase += chr;
}
return camelcase;
}
}
function decamelize$1(str, joinString) {
const lowercase = str.toLowerCase();
joinString = joinString || "-";
let notCamelcase = "";
for (let i = 0; i < str.length; i++) {
const chrLower = lowercase.charAt(i);
const chrString = str.charAt(i);
if (chrLower !== chrString && i > 0) notCamelcase += `${joinString}${lowercase.charAt(i)}`;
else notCamelcase += chrString;
}
return notCamelcase;
}
function looksLikeNumber(x) {
if (x === null || x === void 0) return false;
if (typeof x === "number") return true;
if (/^0x[0-9a-f]+$/i.test(x)) return true;
if (/^0[^.]/.test(x)) return false;
return /^[-]?(?:\d+(?:\.\d*)?|\.\d+)(e[-+]?\d+)?$/.test(x);
}
function tokenizeArgString(argString) {
if (Array.isArray(argString)) return argString.map((e) => typeof e !== "string" ? e + "" : e);
argString = argString.trim();
let i = 0;
let prevC = null;
let c = null;
let opening = null;
const args = [];
for (let ii = 0; ii < argString.length; ii++) {
prevC = c;
c = argString.charAt(ii);
if (c === " " && !opening) {
if (!(prevC === " ")) i++;
continue;
}
if (c === opening) opening = null;
else if ((c === "'" || c === "\"") && !opening) opening = c;
if (!args[i]) args[i] = "";
args[i] += c;
}
return args;
}
var DefaultValuesForTypeKey;
(function(DefaultValuesForTypeKey$1) {
DefaultValuesForTypeKey$1["BOOLEAN"] = "boolean";
DefaultValuesForTypeKey$1["STRING"] = "string";
DefaultValuesForTypeKey$1["NUMBER"] = "number";
DefaultValuesForTypeKey$1["ARRAY"] = "array";
})(DefaultValuesForTypeKey || (DefaultValuesForTypeKey = {}));
let mixin;
var YargsParser = class {
constructor(_mixin) {
mixin = _mixin;
}
parse(argsInput, options) {
const opts = Object.assign({
alias: void 0,
array: void 0,
boolean: void 0,
config: void 0,
configObjects: void 0,
configuration: void 0,
coerce: void 0,
count: void 0,
default: void 0,
envPrefix: void 0,
narg: void 0,
normalize: void 0,
string: void 0,
number: void 0,
__: void 0,
key: void 0
}, options);
const args = tokenizeArgString(argsInput);
const inputIsString = typeof argsInput === "string";
const aliases = combineAliases(Object.assign(Object.create(null), opts.alias));
const configuration = Object.assign({
"boolean-negation": true,
"camel-case-expansion": true,
"combine-arrays": false,
"dot-notation": true,
"duplicate-arguments-array": true,
"flatten-duplicate-arrays": true,
"greedy-arrays": true,
"halt-at-non-option": false,
"nargs-eats-options": false,
"negation-prefix": "no-",
"parse-numbers": true,
"parse-positional-numbers": true,
"populate--": false,
"set-placeholder-key": false,
"short-option-groups": true,
"strip-aliased": false,
"strip-dashed": false,
"unknown-options-as-args": false
}, opts.configuration);
const defaults$1 = Object.assign(Object.create(null), opts.default);
const configObjects = opts.configObjects || [];
const envPrefix = opts.envPrefix;
const notFlagsOption = configuration["populate--"];
const notFlagsArgv = notFlagsOption ? "--" : "_";
const newAliases = Object.create(null);
const defaulted = Object.create(null);
const __ = opts.__ || mixin.format;
const flags = {
aliases: Object.create(null),
arrays: Object.create(null),
bools: Object.create(null),
strings: Object.create(null),
numbers: Object.create(null),
counts: Object.create(null),
normalize: Object.create(null),
configs: Object.create(null),
nargs: Object.create(null),
coercions: Object.create(null),
keys: []
};
const negative = /^-([0-9]+(\.[0-9]+)?|\.[0-9]+)$/;
const negatedBoolean = /* @__PURE__ */ new RegExp("^--" + configuration["negation-prefix"] + "(.+)");
[].concat(opts.array || []).filter(Boolean).forEach(function(opt) {
const key$1 = typeof opt === "object" ? opt.key : opt;
const assignment = Object.keys(opt).map(function(key$2) {
return {
boolean: "bools",
string: "strings",
number: "numbers"
}[key$2];
}).filter(Boolean).pop();
if (assignment) flags[assignment][key$1] = true;
flags.arrays[key$1] = true;
flags.keys.push(key$1);
});
[].concat(opts.boolean || []).filter(Boolean).forEach(function(key$1) {
flags.bools[key$1] = true;
flags.keys.push(key$1);
});
[].concat(opts.string || []).filter(Boolean).forEach(function(key$1) {
flags.strings[key$1] = true;
flags.keys.push(key$1);
});
[].concat(opts.number || []).filter(Boolean).forEach(function(key$1) {
flags.numbers[key$1] = true;
flags.keys.push(key$1);
});
[].concat(opts.count || []).filter(Boolean).forEach(function(key$1) {
flags.counts[key$1] = true;
flags.keys.push(key$1);
});
[].concat(opts.normalize || []).filter(Boolean).forEach(function(key$1) {
flags.normalize[key$1] = true;
flags.keys.push(key$1);
});
if (typeof opts.narg === "object") Object.entries(opts.narg).forEach(([key$1, value]) => {
if (typeof value === "number") {
flags.nargs[key$1] = value;
flags.keys.push(key$1);
}
});
if (typeof opts.coerce === "object") Object.entries(opts.coerce).forEach(([key$1, value]) => {
if (typeof value === "function") {
flags.coercions[key$1] = value;
flags.keys.push(key$1);
}
});
if (typeof opts.config !== "undefined") {
if (Array.isArray(opts.config) || typeof opts.config === "string") [].concat(opts.config).filter(Boolean).forEach(function(key$1) {
flags.configs[key$1] = true;
});
else if (typeof opts.config === "object") Object.entries(opts.config).forEach(([key$1, value]) => {
if (typeof value === "boolean" || typeof value === "function") flags.configs[key$1] = value;
});
}
extendAliases(opts.key, aliases, opts.default, flags.arrays);
Object.keys(defaults$1).forEach(function(key$1) {
(flags.aliases[key$1] || []).forEach(function(alias) {
defaults$1[alias] = defaults$1[key$1];
});
});
let error = null;
checkConfiguration();
let notFlags = [];
const argv = Object.assign(Object.create(null), { _: [] });
const argvReturn = {};
for (let i = 0; i < args.length; i++) {
const arg = args[i];
const truncatedArg = arg.replace(/^-{3,}/, "---");
let broken;
let key$1;
let letters;
let m;
let next;
let value;
if (arg !== "--" && /^-/.test(arg) && isUnknownOptionAsArg(arg)) pushPositional(arg);
else if (truncatedArg.match(/^---+(=|$)/)) {
pushPositional(arg);
continue;
} else if (arg.match(/^--.+=/) || !configuration["short-option-groups"] && arg.match(/^-.+=/)) {
m = arg.match(/^--?([^=]+)=([\s\S]*)$/);
if (m !== null && Array.isArray(m) && m.length >= 3) if (checkAllAliases(m[1], flags.arrays)) i = eatArray(i, m[1], args, m[2]);
else if (checkAllAliases(m[1], flags.nargs) !== false) i = eatNargs(i, m[1], args, m[2]);
else setArg(m[1], m[2], true);
} else if (arg.match(negatedBoolean) && configuration["boolean-negation"]) {
m = arg.match(negatedBoolean);
if (m !== null && Array.isArray(m) && m.length >= 2) {
key$1 = m[1];
setArg(key$1, checkAllAliases(key$1, flags.arrays) ? [false] : false);
}
} else if (arg.match(/^--.+/) || !configuration["short-option-groups"] && arg.match(/^-[^-]+/)) {
m = arg.match(/^--?(.+)/);
if (m !== null && Array.isArray(m) && m.length >= 2) {
key$1 = m[1];
if (checkAllAliases(key$1, flags.arrays)) i = eatArray(i, key$1, args);
else if (checkAllAliases(key$1, flags.nargs) !== false) i = eatNargs(i, key$1, args);
else {
next = args[i + 1];
if (next !== void 0 && (!next.match(/^-/) || next.match(negative)) && !checkAllAliases(key$1, flags.bools) && !checkAllAliases(key$1, flags.counts)) {
setArg(key$1, next);
i++;
} else if (/^(true|false)$/.test(next)) {
setArg(key$1, next);
i++;
} else setArg(key$1, defaultValue(key$1));
}
}
} else if (arg.match(/^-.\..+=/)) {
m = arg.match(/^-([^=]+)=([\s\S]*)$/);
if (m !== null && Array.isArray(m) && m.length >= 3) setArg(m[1], m[2]);
} else if (arg.match(/^-.\..+/) && !arg.match(negative)) {
next = args[i + 1];
m = arg.match(/^-(.\..+)/);
if (m !== null && Array.isArray(m) && m.length >= 2) {
key$1 = m[1];
if (next !== void 0 && !next.match(/^-/) && !checkAllAliases(key$1, flags.bools) && !checkAllAliases(key$1, flags.counts)) {
setArg(key$1, next);
i++;
} else setArg(key$1, defaultValue(key$1));
}
} else if (arg.match(/^-[^-]+/) && !arg.match(negative)) {
letters = arg.slice(1, -1).split("");
broken = false;
for (let j = 0; j < letters.length; j++) {
next = arg.slice(j + 2);
if (letters[j + 1] && letters[j + 1] === "=") {
value = arg.slice(j + 3);
key$1 = letters[j];
if (checkAllAliases(key$1, flags.arrays)) i = eatArray(i, key$1, args, value);
else if (checkAllAliases(key$1, flags.nargs) !== false) i = eatNargs(i, key$1, args, value);
else setArg(key$1, value);
broken = true;
break;
}
if (next === "-") {
setArg(letters[j], next);
continue;
}
if (/[A-Za-z]/.test(letters[j]) && /^-?\d+(\.\d*)?(e-?\d+)?$/.test(next) && checkAllAliases(next, flags.bools) === false) {
setArg(letters[j], next);
broken = true;
break;
}
if (letters[j + 1] && letters[j + 1].match(/\W/)) {
setArg(letters[j], next);
broken = true;
break;
} else setArg(letters[j], defaultValue(letters[j]));
}
key$1 = arg.slice(-1)[0];
if (!broken && key$1 !== "-") if (checkAllAliases(key$1, flags.arrays)) i = eatArray(i, key$1, args);
else if (checkAllAliases(key$1, flags.nargs) !== false) i = eatNargs(i, key$1, args);
else {
next = args[i + 1];
if (next !== void 0 && (!/^(-|--)[^-]/.test(next) || next.match(negative)) && !checkAllAliases(key$1, flags.bools) && !checkAllAliases(key$1, flags.counts)) {
setArg(key$1, next);
i++;
} else if (/^(true|false)$/.test(next)) {
setArg(key$1, next);
i++;
} else setArg(key$1, defaultValue(key$1));
}
} else if (arg.match(/^-[0-9]$/) && arg.match(negative) && checkAllAliases(arg.slice(1), flags.bools)) {
key$1 = arg.slice(1);
setArg(key$1, defaultValue(key$1));
} else if (arg === "--") {
notFlags = args.slice(i + 1);
break;
} else if (configuration["halt-at-non-option"]) {
notFlags = args.slice(i);
break;
} else pushPositional(arg);
}
applyEnvVars(argv, true);
applyEnvVars(argv, false);
setConfig(argv);
setConfigObjects();
applyDefaultsAndAliases(argv, flags.aliases, defaults$1, true);
applyCoercions(argv);
if (configuration["set-placeholder-key"]) setPlaceholderKeys(argv);
Object.keys(flags.counts).forEach(function(key$1) {
if (!hasKey(argv, key$1.split("."))) setArg(key$1, 0);
});
if (notFlagsOption && notFlags.length) argv[notFlagsArgv] = [];
notFlags.forEach(function(key$1) {
argv[notFlagsArgv].push(key$1);
});
if (configuration["camel-case-expansion"] && configuration["strip-dashed"]) Object.keys(argv).filter((key$1) => key$1 !== "--" && key$1.includes("-")).forEach((key$1) => {
delete argv[key$1];
});
if (configuration["strip-aliased"]) [].concat(...Object.keys(aliases).map((k) => aliases[k])).forEach((alias) => {
if (configuration["camel-case-expansion"] && alias.includes("-")) delete argv[alias.split(".").map((prop) => camelCase$1(prop)).join(".")];
delete argv[alias];
});
function pushPositional(arg) {
const maybeCoercedNumber = maybeCoerceNumber("_", arg);
if (typeof maybeCoercedNumber === "string" || typeof maybeCoercedNumber === "number") argv._.push(maybeCoercedNumber);
}
function eatNargs(i, key$1, args$1, argAfterEqualSign) {
let ii;
let toEat = checkAllAliases(key$1, flags.nargs);
toEat = typeof toEat !== "number" || isNaN(toEat) ? 1 : toEat;
if (toEat === 0) {
if (!isUndefined(argAfterEqualSign)) error = Error(__("Argument unexpected for: %s", key$1));
setArg(key$1, defaultValue(key$1));
return i;
}
let available = isUndefined(argAfterEqualSign) ? 0 : 1;
if (configuration["nargs-eats-options"]) {
if (args$1.length - (i + 1) + available < toEat) error = Error(__("Not enough arguments following: %s", key$1));
available = toEat;
} else {
for (ii = i + 1; ii < args$1.length; ii++) if (!args$1[ii].match(/^-[^0-9]/) || args$1[ii].match(negative) || isUnknownOptionAsArg(args$1[ii])) available++;
else break;
if (available < toEat) error = Error(__("Not enough arguments following: %s", key$1));
}
let consumed = Math.min(available, toEat);
if (!isUndefined(argAfterEqualSign) && consumed > 0) {
setArg(key$1, argAfterEqualSign);
consumed--;
}
for (ii = i + 1; ii < consumed + i + 1; ii++) setArg(key$1, args$1[ii]);
return i + consumed;
}
function eatArray(i, key$1, args$1, argAfterEqualSign) {
let argsToSet = [];
let next = argAfterEqualSign || args$1[i + 1];
const nargsCount = checkAllAliases(key$1, flags.nargs);
if (checkAllAliases(key$1, flags.bools) && !/^(true|false)$/.test(next)) argsToSet.push(true);
else if (isUndefined(next) || isUndefined(argAfterEqualSign) && /^-/.test(next) && !negative.test(next) && !isUnknownOptionAsArg(next)) {
if (defaults$1[key$1] !== void 0) {
const defVal = defaults$1[key$1];
argsToSet = Array.isArray(defVal) ? defVal : [defVal];
}
} else {
if (!isUndefined(argAfterEqualSign)) argsToSet.push(processValue(key$1, argAfterEqualSign, true));
for (let ii = i + 1; ii < args$1.length; ii++) {
if (!configuration["greedy-arrays"] && argsToSet.length > 0 || nargsCount && typeof nargsCount === "number" && argsToSet.length >= nargsCount) break;
next = args$1[ii];
if (/^-/.test(next) && !negative.test(next) && !isUnknownOptionAsArg(next)) break;
i = ii;
argsToSet.push(processValue(key$1, next, inputIsString));
}
}
if (typeof nargsCount === "number" && (nargsCount && argsToSet.length < nargsCount || isNaN(nargsCount) && argsToSet.length === 0)) error = Error(__("Not enough arguments following: %s", key$1));
setArg(key$1, argsToSet);
return i;
}
function setArg(key$1, val, shouldStripQuotes = inputIsString) {
if (/-/.test(key$1) && configuration["camel-case-expansion"]) {
const alias = key$1.split(".").map(function(prop) {
return camelCase$1(prop);
}).join(".");
addNewAlias(key$1, alias);
}
const value = processValue(key$1, val, shouldStripQuotes);
const splitKey = key$1.split(".");
setKey(argv, splitKey, value);
if (flags.aliases[key$1]) flags.aliases[key$1].forEach(function(x) {
const keyProperties = x.split(".");
setKey(argv, keyProperties, value);
});
if (splitKey.length > 1 && configuration["dot-notation"]) (flags.aliases[splitKey[0]] || []).forEach(function(x) {
let keyProperties = x.split(".");
const a = [].concat(splitKey);
a.shift();
keyProperties = keyProperties.concat(a);
if (!(flags.aliases[key$1] || []).includes(keyProperties.join("."))) setKey(argv, keyProperties, value);
});
if (checkAllAliases(key$1, flags.normalize) && !checkAllAliases(key$1, flags.arrays)) [key$1].concat(flags.aliases[key$1] || []).forEach(function(key$2) {
Object.defineProperty(argvReturn, key$2, {
enumerable: true,
get() {
return val;
},
set(value$1) {
val = typeof value$1 === "string" ? mixin.normalize(value$1) : value$1;
}
});
});
}
function addNewAlias(key$1, alias) {
if (!(flags.aliases[key$1] && flags.aliases[key$1].length)) {
flags.aliases[key$1] = [alias];
newAliases[alias] = true;
}
if (!(flags.aliases[alias] && flags.aliases[alias].length)) addNewAlias(alias, key$1);
}
function processValue(key$1, val, shouldStripQuotes) {
if (shouldStripQuotes) val = stripQuotes(val);
if (checkAllAliases(key$1, flags.bools) || checkAllAliases(key$1, flags.counts)) {
if (typeof val === "string") val = val === "true";
}
let value = Array.isArray(val) ? val.map(function(v) {
return maybeCoerceNumber(key$1, v);
}) : maybeCoerceNumber(key$1, val);
if (checkAllAliases(key$1, flags.counts) && (isUndefined(value) || typeof value === "boolean")) value = increment();
if (checkAllAliases(key$1, flags.normalize) && checkAllAliases(key$1, flags.arrays)) if (Array.isArray(val)) value = val.map((val$1) => {
return mixin.normalize(val$1);
});
else value = mixin.normalize(val);
return value;
}
function maybeCoerceNumber(key$1, value) {
if (!configuration["parse-positional-numbers"] && key$1 === "_") return value;
if (!checkAllAliases(key$1, flags.strings) && !checkAllAliases(key$1, flags.bools) && !Array.isArray(value)) {
if (looksLikeNumber(value) && configuration["parse-numbers"] && Number.isSafeInteger(Math.floor(parseFloat(`${value}`))) || !isUndefined(value) && checkAllAliases(key$1, flags.numbers)) value = Number(value);
}
return value;
}
function setConfig(argv$1) {
const configLookup = Object.create(null);
applyDefaultsAndAliases(configLookup, flags.aliases, defaults$1);
Object.keys(flags.configs).forEach(function(configKey) {
const configPath = argv$1[configKey] || configLookup[configKey];
if (configPath) try {
let config = null;
const resolvedConfigPath = mixin.resolve(mixin.cwd(), configPath);
const resolveConfig = flags.configs[configKey];
if (typeof resolveConfig === "function") {
try {
config = resolveConfig(resolvedConfigPath);
} catch (e) {
config = e;
}
if (config instanceof Error) {
error = config;
return;
}
} else config = mixin.require(resolvedConfigPath);
setConfigObject(config);
} catch (ex) {
if (ex.name === "PermissionDenied") error = ex;
else if (argv$1[configKey]) error = Error(__("Invalid JSON config file: %s", configPath));
}
});
}
function setConfigObject(config, prev) {
Object.keys(config).forEach(function(key$1) {
const value = config[key$1];
const fullKey = prev ? prev + "." + key$1 : key$1;
if (typeof value === "object" && value !== null && !Array.isArray(value) && configuration["dot-notation"]) setConfigObject(value, fullKey);
else if (!hasKey(argv, fullKey.split(".")) || checkAllAliases(fullKey, flags.arrays) && configuration["combine-arrays"]) setArg(fullKey, value);
});
}
function setConfigObjects() {
if (typeof configObjects !== "undefined") configObjects.forEach(function(configObject) {
setConfigObject(configObject);
});
}
function applyEnvVars(argv$1, configOnly) {
if (typeof envPrefix === "undefined") return;
const prefix = typeof envPrefix === "string" ? envPrefix : "";
const env$3 = mixin.env();
Object.keys(env$3).forEach(function(envVar) {
if (prefix === "" || envVar.lastIndexOf(prefix, 0) === 0) {
const keys = envVar.split("__").map(function(key$1, i) {
if (i === 0) key$1 = key$1.substring(prefix.length);
return camelCase$1(key$1);
});
if ((configOnly && flags.configs[keys.join(".")] || !configOnly) && !hasKey(argv$1, keys)) setArg(keys.join("."), env$3[envVar]);
}
});
}
function applyCoercions(argv$1) {
let coerce;
const applied = /* @__PURE__ */ new Set();
Object.keys(argv$1).forEach(function(key$1) {
if (!applied.has(key$1)) {
coerce = checkAllAliases(key$1, flags.coercions);
if (typeof coerce === "function") try {
const value = maybeCoerceNumber(key$1, coerce(argv$1[key$1]));
[].concat(flags.aliases[key$1] || [], key$1).forEach((ali) => {
applied.add(ali);
argv$1[ali] = value;
});
} catch (err) {
error = err;
}
}
});
}
function setPlaceholderKeys(argv$1) {
flags.keys.forEach((key$1) => {
if (~key$1.indexOf(".")) return;
if (typeof argv$1[key$1] === "undefined") argv$1[key$1] = void 0;
});
return argv$1;
}
function applyDefaultsAndAliases(obj, aliases$1, defaults$2, canLog = false) {
Object.keys(defaults$2).forEach(function(key$1) {
if (!hasKey(obj, key$1.split("."))) {
setKey(obj, key$1.split("."), defaults$2[key$1]);
if (canLog) defaulted[key$1] = true;
(aliases$1[key$1] || []).forEach(function(x) {
if (hasKey(obj, x.split("."))) return;
setKey(obj, x.split("."), defaults$2[key$1]);
});
}
});
}
function hasKey(obj, keys) {
let o = obj;
if (!configuration["dot-notation"]) keys = [keys.join(".")];
keys.slice(0, -1).forEach(function(key$2) {
o = o[key$2] || {};
});
const key$1 = keys[keys.length - 1];
if (typeof o !== "object") return false;
else return key$1 in o;
}
function setKey(obj, keys, value) {
let o = obj;
if (!configuration["dot-notation"]) keys = [keys.join(".")];
keys.slice(0, -1).forEach(function(key$2) {
key$2 = sanitizeKey(key$2);
if (typeof o === "object" && o[key$2] === void 0) o[key$2] = {};
if (typeof o[key$2] !== "object" || Array.isArray(o[key$2])) {
if (Array.isArray(o[key$2])) o[key$2].push({});
else o[key$2] = [o[key$2], {}];
o = o[key$2][o[key$2].length - 1];
} else o = o[key$2];
});
const key$1 = sanitizeKey(keys[keys.length - 1]);
const isTypeArray = checkAllAliases(keys.join("."), flags.arrays);
const isValueArray = Array.isArray(value);
let duplicate = configuration["duplicate-arguments-array"];
if (!duplicate && checkAllAliases(key$1, flags.nargs)) {
duplicate = true;
if (!isUndefined(o[key$1]) && flags.nargs[key$1] === 1 || Array.isArray(o[key$1]) && o[key$1].length === flags.nargs[key$1]) o[key$1] = void 0;
}
if (value === increment()) o[key$1] = increment(o[key$1]);
else if (Array.isArray(o[key$1])) if (duplicate && isTypeArray && isValueArray) o[key$1] = configuration["flatten-duplicate-arrays"] ? o[key$1].concat(value) : (Array.isArray(o[key$1][0]) ? o[key$1] : [o[key$1]]).concat([value]);
else if (!duplicate && Boolean(isTypeArray) === Boolean(isValueArray)) o[key$1] = value;
else o[key$1] = o[key$1].concat([value]);
else if (o[key$1] === void 0 && isTypeArray) o[key$1] = isValueArray ? value : [value];
else if (duplicate && !(o[key$1] === void 0 || checkAllAliases(key$1, flags.counts) || checkAllAliases(key$1, flags.bools))) o[key$1] = [o[key$1], value];
else o[key$1] = value;
}
function extendAliases(...args$1) {
args$1.forEach(function(obj) {
Object.keys(obj || {}).forEach(function(key$1) {
if (flags.aliases[key$1]) return;
flags.aliases[key$1] = [].concat(aliases[key$1] || []);
flags.aliases[key$1].concat(key$1).forEach(function(x) {
if (/-/.test(x) && configuration["camel-case-expansion"]) {
const c = camelCase$1(x);
if (c !== key$1 && flags.aliases[key$1].indexOf(c) === -1) {
flags.aliases[key$1].push(c);
newAliases[c] = true;
}
}
});
flags.aliases[key$1].concat(key$1).forEach(function(x) {
if (x.length > 1 && /[A-Z]/.test(x) && configuration["camel-case-expansion"]) {
const c = decamelize$1(x, "-");
if (c !== key$1 && flags.aliases[key$1].indexOf(c) === -1) {
flags.aliases[key$1].push(c);
newAliases[c] = true;
}
}
});
flags.aliases[key$1].forEach(function(x) {
flags.aliases[x] = [key$1].concat(flags.aliases[key$1].filter(function(y) {
return x !== y;
}));
});
});
});
}
function checkAllAliases(key$1, flag) {
const toCheck = [].concat(flags.aliases[key$1] || [], key$1);
const keys = Object.keys(flag);
const setAlias = toCheck.find((key$2) => keys.includes(key$2));
return setAlias ? flag[setAlias] : false;
}
function hasAnyFlag(key$1) {
const flagsKeys = Object.keys(flags);
return [].concat(flagsKeys.map((k) => flags[k])).some(function(flag) {
return Array.isArray(flag) ? flag.includes(key$1) : flag[key$1];
});
}
function hasFlagsMatching(arg, ...patterns) {
return [].concat(...patterns).some(function(pattern) {
const match = arg.match(pattern);
return match && hasAnyFlag(match[1]);
});
}
function hasAllShortFlags(arg) {
if (arg.match(negative) || !arg.match(/^-[^-]+/)) return false;
let hasAllFlags = true;
let next;
const letters = arg.slice(1).split("");
for (let j = 0; j < letters.length; j++) {
next = arg.slice(j + 2);
if (!hasAnyFlag(letters[j])) {
hasAllFlags = false;
break;
}
if (letters[j + 1] && letters[j + 1] === "=" || next === "-" || /[A-Za-z]/.test(letters[j]) && /^-?\d+(\.\d*)?(e-?\d+)?$/.test(next) || letters[j + 1] && letters[j + 1].match(/\W/)) break;
}
return hasAllFlags;
}
function isUnknownOptionAsArg(arg) {
return configuration["unknown-options-as-args"] && isUnknownOption(arg);
}
function isUnknownOption(arg) {
arg = arg.replace(/^-{3,}/, "--");
if (arg.match(negative)) return false;
if (hasAllShortFlags(arg)) return false;
return !hasFlagsMatching(arg, /^-+([^=]+?)=[\s\S]*$/, negatedBoolean, /^-+([^=]+?)$/, /^-+([^=]+?)-$/, /^-+([^=]+?\d+)$/, /^-+([^=]+?)\W+.*$/);
}
function defaultValue(key$1) {
if (!checkAllAliases(key$1, flags.bools) && !checkAllAliases(key$1, flags.counts) && `${key$1}` in defaults$1) return defaults$1[key$1];
else return defaultForType(guessType(key$1));
}
function defaultForType(type) {
return {
[DefaultValuesForTypeKey.BOOLEAN]: true,
[DefaultValuesForTypeKey.STRING]: "",
[DefaultValuesForTypeKey.NUMBER]: void 0,
[DefaultValuesForTypeKey.ARRAY]: []
}[type];
}
function guessType(key$1) {
let type = DefaultValuesForTypeKey.BOOLEAN;
if (checkAllAliases(key$1, flags.strings)) type = DefaultValuesForTypeKey.STRING;
else if (checkAllAliases(key$1, flags.numbers)) type = DefaultValuesForTypeKey.NUMBER;
else if (checkAllAliases(key$1, flags.bools)) type = DefaultValuesForTypeKey.BOOLEAN;
else if (checkAllAliases(key$1, flags.arrays)) type = DefaultValuesForTypeKey.ARRAY;
return type;
}
function isUndefined(num) {
return num === void 0;
}
function checkConfiguration() {
Object.keys(flags.counts).find((key$1) => {
if (checkAllAliases(key$1, flags.arrays)) {
error = Error(__("Invalid configuration: %s, opts.count excludes opts.array.", key$1));
return true;
} else if (checkAllAliases(key$1, flags.nargs)) {
error = Error(__("Invalid configuration: %s, opts.count excludes opts.narg.", key$1));
return true;
}
return false;
});
}
return {
aliases: Object.assign({}, flags.aliases),
argv: Object.assign(argvReturn, argv),
configuration,
defaulted: Object.assign({}, defaulted),
error,
newAliases: Object.assign({}, newAliases)
};
}
};
function combineAliases(aliases) {
const aliasArrays = [];
const combined = Object.create(null);
let change = true;
Object.keys(aliases).forEach(function(key$1) {
aliasArrays.push([].concat(aliases[key$1], key$1));
});
while (change) {
change = false;
for (let i = 0; i < aliasArrays.length; i++) for (let ii = i + 1; ii < aliasArrays.length; ii++) if (aliasArrays[i].filter(function(v) {
return aliasArrays[ii].indexOf(v) !== -1;
}).length) {
aliasArrays[i] = aliasArrays[i].concat(aliasArrays[ii]);
aliasArrays.splice(ii, 1);
change = true;
break;
}
}
aliasArrays.forEach(function(aliasArray) {
aliasArray = aliasArray.filter(function(v, i, self) {
return self.indexOf(v) === i;
});
const lastAlias = aliasArray.pop();
if (lastAlias !== void 0 && typeof lastAlias === "string") combined[lastAlias] = aliasArray;
});
return combined;
}
function increment(orig) {
return orig !== void 0 ? orig + 1 : 1;
}
function sanitizeKey(key$1) {
if (key$1 === "__proto__") return "___proto___";
return key$1;
}
function stripQuotes(val) {
return typeof val === "string" && (val[0] === "'" || val[0] === "\"") && val[val.length - 1] === val[0] ? val.substring(1, val.length - 1) : val;
}
var _a, _b, _c;
const minNodeVersion = process && process.env && process.env.YARGS_MIN_NODE_VERSION ? Number(process.env.YARGS_MIN_NODE_VERSION) : 12;
const nodeVersion = (_b = (_a = process === null || process === void 0 ? void 0 : process.versions) === null || _a === void 0 ? void 0 : _a.node) !== null && _b !== void 0 ? _b : (_c = process === null || process === void 0 ? void 0 : process.version) === null || _c === void 0 ? void 0 : _c.slice(1);
if (nodeVersion) {
if (Number(nodeVersion.match(/^([^.]+)/)[1]) < minNodeVersion) throw Error(`yargs parser supports a minimum Node.js version of ${minNodeVersion}. Read our version support policy: https://github.com/yargs/yargs-parser#supported-nodejs-versions`);
}
const env$2 = process ? process.env : {};
const parser = new YargsParser({
cwd: process.cwd,
env: () => {
return env$2;
},
format,
normalize,
resolve,
require: (path$2) => {
if (typeof __require !== "undefined") return __require(path$2);
else if (path$2.match(/\.json$/)) return JSON.parse(readFileSync$1(path$2, "utf8"));
else throw Error("only .json config files are supported in ESM");
}
});
const yargsParser = function Parser(args, opts) {
return parser.parse(args.slice(), opts).argv;
};
yargsParser.detailed = function(args, opts) {
return parser.parse(args.slice(), opts);
};
yargsParser.camelCase = camelCase$1;
yargsParser.decamelize = decamelize$1;
yargsParser.looksLikeNumber = looksLikeNumber;
const isObject$3 = (value) => typeof value === "object" && value !== null;
const isObjectCustom$1 = (value) => isObject$3(value) && !(value instanceof RegExp) && !(value instanceof Error) && !(value instanceof Date);
const mapObjectSkip$1 = Symbol("mapObjectSkip");
const _mapObject = (object, mapper, options, isSeen = /* @__PURE__ */ new WeakMap()) => {
options = {
deep: false,
target: {},
...options
};
if (isSeen.has(object)) return isSeen.get(object);
isSeen.set(object, options.target);
const { target } = options;
delete options.target;
const mapArray = (array) => array.map((element) => isObjectCustom$1(element) ? _mapObject(element, mapper, options, isSeen) : element);
if (Array.isArray(object)) return mapArray(object);
for (const [key$1, value] of Object.entries(object)) {
const mapResult = mapper(key$1, value, object);
if (mapResult === mapObjectSkip$1) continue;
let [newKey, newValue, { shouldRecurse = true } = {}] = mapResult;
if (newKey === "__proto__") continue;
if (options.deep && shouldRecurse && isObjectCustom$1(newValue)) newValue = Array.isArray(newValue) ? mapArray(newValue) : _mapObject(newValue, mapper, options, isSeen);
target[newKey] = newValue;
}
return target;
};
function mapObject$2(object, mapper, options) {
if (!isObject$3(object)) throw new TypeError(`Expected an object, got \`${object}\` (${typeof object})`);
return _mapObject(object, mapper, options);
}
const UPPERCASE = /[\p{Lu}]/u;
const LOWERCASE = /[\p{Ll}]/u;
const LEADING_CAPITAL = /^[\p{Lu}](?![\p{Lu}])/gu;
const IDENTIFIER$1 = /([\p{Alpha}\p{N}_]|$)/u;
const SEPARATORS = /[_.\- ]+/;
const LEADING_SEPARATORS = /* @__PURE__ */ new RegExp("^" + SEPARATORS.source);
const SEPARATORS_AND_IDENTIFIER = new RegExp(SEPARATORS.source + IDENTIFIER$1.source, "gu");
const NUMBERS_AND_IDENTIFIER = new RegExp("\\d+" + IDENTIFIER$1.source, "gu");
const preserveCamelCase = (string, toLowerCase, toUpperCase, preserveConsecutiveUppercase$1) => {
let isLastCharLower = false;
let isLastCharUpper = false;
let isLastLastCharUpper = false;
let isLastLastCharPreserved = false;
for (let index = 0; index < string.length; index++) {
const character = string[index];
isLastLastCharPreserved = index > 2 ? string[index - 3] === "-" : true;
if (isLastCharLower && UPPERCASE.test(character)) {
string = string.slice(0, index) + "-" + string.slice(index);
isLastCharLower = false;
isLastLastCharUpper = isLastCharUpper;
isLastCharUpper = true;
index++;
} else if (isLastCharUpper && isLastLastCharUpper && LOWERCASE.test(character) && (!isLastLastCharPreserved || preserveConsecutiveUppercase$1)) {
string = string.slice(0, index - 1) + "-" + string.slice(index - 1);
isLastLastCharUpper = isLastCharUpper;
isLastCharUpper = false;
isLastCharLower = true;
} else {
isLastCharLower = toLowerCase(character) === character && toUpperCase(character) !== character;
isLastLastCharUpper = isLastCharUpper;
isLastCharUpper = toUpperCase(character) === character && toLowerCase(character) !== character;
}
}
return string;
};
const preserveConsecutiveUppercase = (input, toLowerCase) => {
LEADING_CAPITAL.lastIndex = 0;
return input.replaceAll(LEADING_CAPITAL, (match) => toLowerCase(match));
};
const postProcess = (input, toUpperCase) => {
SEPARATORS_AND_IDENTIFIER.lastIndex = 0;
NUMBERS_AND_IDENTIFIER.lastIndex = 0;
return input.replaceAll(NUMBERS_AND_IDENTIFIER, (match, pattern, offset) => ["_", "-"].includes(input.charAt(offset + match.length)) ? match : toUpperCase(match)).replaceAll(SEPARATORS_AND_IDENTIFIER, (_, identifier$1) => toUpperCase(identifier$1));
};
function camelCase(input, options) {
if (!(typeof input === "string" || Array.isArray(input))) throw new TypeError("Expected the input to be `string | string[]`");
options = {
pascalCase: false,
preserveConsecutiveUppercase: false,
...options
};
if (Array.isArray(input)) input = input.map((x) => x.trim()).filter((x) => x.length).join("-");
else input = input.trim();
if (input.length === 0) return "";
const toLowerCase = options.locale === false ? (string) => string.toLowerCase() : (string) => string.toLocaleLowerCase(options.locale);
const toUpperCase = options.locale === false ? (string) => string.toUpperCase() : (string) => string.toLocaleUpperCase(options.locale);
if (input.length === 1) {
if (SEPARATORS.test(input)) return "";
return options.pascalCase ? toUpperCase(input) : toLowerCase(input);
}
if (input !== toLowerCase(input)) input = preserveCamelCase(input, toLowerCase, toUpperCase, options.preserveConsecutiveUppercase);
input = input.replace(LEADING_SEPARATORS, "");
input = options.preserveConsecutiveUppercase ? preserveConsecutiveUppercase(input, toLowerCase) : toLowerCase(input);
if (options.pascalCase) input = toUpperCase(input.charAt(0)) + input.slice(1);
return postProcess(input, toUpperCase);
}
var QuickLRU = class extends Map {
constructor(options = {}) {
super();
if (!(options.maxSize && options.maxSize > 0)) throw new TypeError("`maxSize` must be a number greater than 0");
if (typeof options.maxAge === "number" && options.maxAge === 0) throw new TypeError("`maxAge` must be a number greater than 0");
this.maxSize = options.maxSize;
this.maxAge = options.maxAge || Number.POSITIVE_INFINITY;
this.onEviction = options.onEviction;
this.cache = /* @__PURE__ */ new Map();
this.oldCache = /* @__PURE__ */ new Map();
this._size = 0;
}
_emitEvictions(cache$3) {
if (typeof this.onEviction !== "function") return;
for (const [key$1, item] of cache$3) this.onEviction(key$1, item.value);
}
_deleteIfExpired(key$1, item) {
if (typeof item.expiry === "number" && item.expiry <= Date.now()) {
if (typeof this.onEviction === "function") this.onEviction(key$1, item.value);
return this.delete(key$1);
}
return false;
}
_getOrDeleteIfExpired(key$1, item) {
if (this._deleteIfExpired(key$1, item) === false) return item.value;
}
_getItemValue(key$1, item) {
return item.expiry ? this._getOrDeleteIfExpired(key$1, item) : item.value;
}
_peek(key$1, cache$3) {
const item = cache$3.get(key$1);
return this._getItemValue(key$1, item);
}
_set(key$1, value) {
this.cache.set(key$1, value);
this._size++;
if (this._size >= this.maxSize) {
this._size = 0;
this._emitEvictions(this.oldCache);
this.oldCache = this.cache;
this.cache = /* @__PURE__ */ new Map();
}
}
_moveToRecent(key$1, item) {
this.oldCache.delete(key$1);
this._set(key$1, item);
}
*_entriesAscending() {
for (const item of this.oldCache) {
const [key$1, value] = item;
if (!this.cache.has(key$1)) {
if (this._deleteIfExpired(key$1, value) === false) yield item;
}
}
for (const item of this.cache) {
const [key$1, value] = item;
if (this._deleteIfExpired(key$1, value) === false) yield item;
}
}
get(key$1) {
if (this.cache.has(key$1)) {
const item = this.cache.get(key$1);
return this._getItemValue(key$1, item);
}
if (this.oldCache.has(key$1)) {
const item = this.oldCache.get(key$1);
if (this._deleteIfExpired(key$1, item) === false) {
this._moveToRecent(key$1, item);
return item.value;
}
}
}
set(key$1, value, { maxAge = this.maxAge } = {}) {
const expiry = typeof maxAge === "number" && maxAge !== Number.POSITIVE_INFINITY ? Date.now() + maxAge : void 0;
if (this.cache.has(key$1)) this.cache.set(key$1, {
value,
expiry
});
else this._set(key$1, {
value,
expiry
});
return this;
}
has(key$1) {
if (this.cache.has(key$1)) return !this._deleteIfExpired(key$1, this.cache.get(key$1));
if (this.oldCache.has(key$1)) return !this._deleteIfExpired(key$1, this.oldCache.get(key$1));
return false;
}
peek(key$1) {
if (this.cache.has(key$1)) return this._peek(key$1, this.cache);
if (this.oldCache.has(key$1)) return this._peek(key$1, this.oldCache);
}
delete(key$1) {
const deleted = this.cache.delete(key$1);
if (deleted) this._size--;
return this.oldCache.delete(key$1) || deleted;
}
clear() {
this.cache.clear();
this.oldCache.clear();
this._size = 0;
}
resize(newSize) {
if (!(newSize && newSize > 0)) throw new TypeError("`maxSize` must be a number greater than 0");
const items = [...this._entriesAscending()];
const removeCount = items.length - newSize;
if (removeCount < 0) {
this.cache = new Map(items);
this.oldCache = /* @__PURE__ */ new Map();
this._size = items.length;
} else {
if (removeCount > 0) this._emitEvictions(items.slice(0, removeCount));
this.oldCache = new Map(items.slice(removeCount));
this.cache = /* @__PURE__ */ new Map();
this._size = 0;
}
this.maxSize = newSize;
}
*keys() {
for (const [key$1] of this) yield key$1;
}
*values() {
for (const [, value] of this) yield value;
}
*[Symbol.iterator]() {
for (const item of this.cache) {
const [key$1, value] = item;
if (this._deleteIfExpired(key$1, value) === false) yield [key$1, value.value];
}
for (const item of this.oldCache) {
const [key$1, value] = item;
if (!this.cache.has(key$1)) {
if (this._deleteIfExpired(key$1, value) === false) yield [key$1, value.value];
}
}
}
*entriesDescending() {
let items = [...this.cache];
for (let i = items.length - 1; i >= 0; --i) {
const [key$1, value] = items[i];
if (this._deleteIfExpired(key$1, value) === false) yield [key$1, value.value];
}
items = [...this.oldCache];
for (let i = items.length - 1; i >= 0; --i) {
const [key$1, value] = items[i];
if (!this.cache.has(key$1)) {
if (this._deleteIfExpired(key$1, value) === false) yield [key$1, value.value];
}
}
}
*entriesAscending() {
for (const [key$1, value] of this._entriesAscending()) yield [key$1, value.value];
}
get size() {
if (!this._size) return this.oldCache.size;
let oldCacheSize = 0;
for (const key$1 of this.oldCache.keys()) if (!this.cache.has(key$1)) oldCacheSize++;
return Math.min(this._size + oldCacheSize, this.maxSize);
}
entries() {
return this.entriesAscending();
}
forEach(callbackFunction, thisArgument = this) {
for (const [key$1, value] of this.entriesAscending()) callbackFunction.call(thisArgument, value, key$1, this);
}
get [Symbol.toStringTag]() {
return JSON.stringify([...this.entriesAscending()]);
}
};
const has$1 = (array, key$1) => array.some((element) => {
if (typeof element === "string") return element === key$1;
element.lastIndex = 0;
return element.test(key$1);
});
const cache$2 = new QuickLRU({ maxSize: 1e5 });
const isObject$2 = (value) => typeof value === "object" && value !== null && !(value instanceof RegExp) && !(value instanceof Error) && !(value instanceof Date);
const transform$1 = (input, options = {}) => {
if (!isObject$2(input)) return input;
const { exclude, pascalCase = false, stopPaths, deep = false, preserveConsecutiveUppercase: preserveConsecutiveUppercase$1 = false } = options;
const stopPathsSet = new Set(stopPaths);
const makeMapper = (parentPath) => (key$1, value) => {
if (deep && isObject$2(value)) {
const path$2 = parentPath === void 0 ? key$1 : `${parentPath}.${key$1}`;
if (!stopPathsSet.has(path$2)) value = mapObject$2(value, makeMapper(path$2));
}
if (!(exclude && has$1(exclude, key$1))) {
const cacheKey = pascalCase ? `${key$1}_` : key$1;
if (cache$2.has(cacheKey)) key$1 = cache$2.get(cacheKey);
else {
const returnValue = camelCase(key$1, {
pascalCase,
locale: false,
preserveConsecutiveUppercase: preserveConsecutiveUppercase$1
});
if (key$1.length < 100) cache$2.set(cacheKey, returnValue);
key$1 = returnValue;
}
}
return [key$1, value];
};
return mapObject$2(input, makeMapper(void 0));
};
function camelcaseKeys(input, options) {
if (Array.isArray(input)) return Object.keys(input).map((key$1) => transform$1(input[key$1], options));
return transform$1(input, options);
}
function trimNewlines(string) {
let start = 0;
let end = string.length;
while (start < end && (string[start] === "\r" || string[start] === "\n")) start++;
while (end > start && (string[end - 1] === "\r" || string[end - 1] === "\n")) end--;
return start > 0 || end < string.length ? string.slice(start, end) : string;
}
function getDefaultExportFromCjs(x) {
return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, "default") ? x["default"] : x;
}
var minIndent = (string) => {
const match = string.match(/^[ \t]*(?=\S)/gm);
if (!match) return 0;
return match.reduce((r, a) => Math.min(r, a.length), Infinity);
};
const minIndent$1 = getDefaultExportFromCjs(minIndent);
function stripIndent(string) {
const indent = minIndent$1(string);
if (indent === 0) return string;
const regex = new RegExp(`^[ \\t]{${indent}}`, "gm");
return string.replace(regex, "");
}
function indentString(string, count = 1, options = {}) {
const { indent = " ", includeEmptyLines = false } = options;
if (typeof string !== "string") throw new TypeError(`Expected \`input\` to be a \`string\`, got \`${typeof string}\``);
if (typeof count !== "number") throw new TypeError(`Expected \`count\` to be a \`number\`, got \`${typeof count}\``);
if (count < 0) throw new RangeError(`Expected \`count\` to be at least 0, got \`${count}\``);
if (typeof indent !== "string") throw new TypeError(`Expected \`options.indent\` to be a \`string\`, got \`${typeof indent}\``);
if (count === 0) return string;
const regex = includeEmptyLines ? /^/gm : /^(?!\s*$)/gm;
return string.replace(regex, indent.repeat(count));
}
function redent(string, count = 0, options = {}) {
return indentString(stripIndent(string), count, options);
}
var debug_1 = typeof process === "object"