@aws/pdk
Version:
All documentation is located at: https://aws.github.io/aws-pdk
1,480 lines (1,474 loc) • 5.81 MB
JavaScript
#!/usr/bin/env node
"use strict";
var __create = Object.create;
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __getProtoOf = Object.getPrototypeOf;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __commonJS = (cb, mod2) => function __require() {
return mod2 || (0, cb[__getOwnPropNames(cb)[0]])((mod2 = { exports: {} }).exports, mod2), mod2.exports;
};
var __copyProps = (to4, from, except, desc) => {
if (from && typeof from === "object" || typeof from === "function") {
for (let key of __getOwnPropNames(from))
if (!__hasOwnProp.call(to4, key) && key !== except)
__defProp(to4, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
}
return to4;
};
var __toESM = (mod2, isNodeMode, target) => (target = mod2 != null ? __create(__getProtoOf(mod2)) : {}, __copyProps(
// If the importer is in node compatibility mode or this is not an ESM
// file that has been converted to a CommonJS file using a Babel-
// compatible transform (i.e. "__esModule" has not been set), then set
// "default" to the CommonJS "module.exports" for node compatibility.
isNodeMode || !mod2 || !mod2.__esModule ? __defProp(target, "default", { value: mod2, enumerable: true }) : target,
mod2
));
// ../../node_modules/.pnpm/lodash.camelcase@4.3.0/node_modules/lodash.camelcase/index.js
var require_lodash = __commonJS({
"../../node_modules/.pnpm/lodash.camelcase@4.3.0/node_modules/lodash.camelcase/index.js"(exports2, module2) {
var INFINITY = 1 / 0;
var symbolTag = "[object Symbol]";
var reAsciiWord = /[^\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\x7f]+/g;
var reLatin = /[\xc0-\xd6\xd8-\xf6\xf8-\xff\u0100-\u017f]/g;
var rsAstralRange = "\\ud800-\\udfff";
var rsComboMarksRange = "\\u0300-\\u036f\\ufe20-\\ufe23";
var rsComboSymbolsRange = "\\u20d0-\\u20f0";
var rsDingbatRange = "\\u2700-\\u27bf";
var rsLowerRange = "a-z\\xdf-\\xf6\\xf8-\\xff";
var rsMathOpRange = "\\xac\\xb1\\xd7\\xf7";
var rsNonCharRange = "\\x00-\\x2f\\x3a-\\x40\\x5b-\\x60\\x7b-\\xbf";
var rsPunctuationRange = "\\u2000-\\u206f";
var rsSpaceRange = " \\t\\x0b\\f\\xa0\\ufeff\\n\\r\\u2028\\u2029\\u1680\\u180e\\u2000\\u2001\\u2002\\u2003\\u2004\\u2005\\u2006\\u2007\\u2008\\u2009\\u200a\\u202f\\u205f\\u3000";
var rsUpperRange = "A-Z\\xc0-\\xd6\\xd8-\\xde";
var rsVarRange = "\\ufe0e\\ufe0f";
var rsBreakRange = rsMathOpRange + rsNonCharRange + rsPunctuationRange + rsSpaceRange;
var rsApos = "['\u2019]";
var rsAstral = "[" + rsAstralRange + "]";
var rsBreak = "[" + rsBreakRange + "]";
var rsCombo = "[" + rsComboMarksRange + rsComboSymbolsRange + "]";
var rsDigits = "\\d+";
var rsDingbat = "[" + rsDingbatRange + "]";
var rsLower = "[" + rsLowerRange + "]";
var rsMisc = "[^" + rsAstralRange + rsBreakRange + rsDigits + rsDingbatRange + rsLowerRange + rsUpperRange + "]";
var rsFitz = "\\ud83c[\\udffb-\\udfff]";
var rsModifier = "(?:" + rsCombo + "|" + rsFitz + ")";
var rsNonAstral = "[^" + rsAstralRange + "]";
var rsRegional = "(?:\\ud83c[\\udde6-\\uddff]){2}";
var rsSurrPair = "[\\ud800-\\udbff][\\udc00-\\udfff]";
var rsUpper = "[" + rsUpperRange + "]";
var rsZWJ = "\\u200d";
var rsLowerMisc = "(?:" + rsLower + "|" + rsMisc + ")";
var rsUpperMisc = "(?:" + rsUpper + "|" + rsMisc + ")";
var rsOptLowerContr = "(?:" + rsApos + "(?:d|ll|m|re|s|t|ve))?";
var rsOptUpperContr = "(?:" + rsApos + "(?:D|LL|M|RE|S|T|VE))?";
var reOptMod = rsModifier + "?";
var rsOptVar = "[" + rsVarRange + "]?";
var rsOptJoin = "(?:" + rsZWJ + "(?:" + [rsNonAstral, rsRegional, rsSurrPair].join("|") + ")" + rsOptVar + reOptMod + ")*";
var rsSeq = rsOptVar + reOptMod + rsOptJoin;
var rsEmoji = "(?:" + [rsDingbat, rsRegional, rsSurrPair].join("|") + ")" + rsSeq;
var rsSymbol = "(?:" + [rsNonAstral + rsCombo + "?", rsCombo, rsRegional, rsSurrPair, rsAstral].join("|") + ")";
var reApos = RegExp(rsApos, "g");
var reComboMark = RegExp(rsCombo, "g");
var reUnicode = RegExp(rsFitz + "(?=" + rsFitz + ")|" + rsSymbol + rsSeq, "g");
var reUnicodeWord = RegExp([
rsUpper + "?" + rsLower + "+" + rsOptLowerContr + "(?=" + [rsBreak, rsUpper, "$"].join("|") + ")",
rsUpperMisc + "+" + rsOptUpperContr + "(?=" + [rsBreak, rsUpper + rsLowerMisc, "$"].join("|") + ")",
rsUpper + "?" + rsLowerMisc + "+" + rsOptLowerContr,
rsUpper + "+" + rsOptUpperContr,
rsDigits,
rsEmoji
].join("|"), "g");
var reHasUnicode = RegExp("[" + rsZWJ + rsAstralRange + rsComboMarksRange + rsComboSymbolsRange + rsVarRange + "]");
var reHasUnicodeWord = /[a-z][A-Z]|[A-Z]{2,}[a-z]|[0-9][a-zA-Z]|[a-zA-Z][0-9]|[^a-zA-Z0-9 ]/;
var deburredLetters = {
// Latin-1 Supplement block.
"\xC0": "A",
"\xC1": "A",
"\xC2": "A",
"\xC3": "A",
"\xC4": "A",
"\xC5": "A",
"\xE0": "a",
"\xE1": "a",
"\xE2": "a",
"\xE3": "a",
"\xE4": "a",
"\xE5": "a",
"\xC7": "C",
"\xE7": "c",
"\xD0": "D",
"\xF0": "d",
"\xC8": "E",
"\xC9": "E",
"\xCA": "E",
"\xCB": "E",
"\xE8": "e",
"\xE9": "e",
"\xEA": "e",
"\xEB": "e",
"\xCC": "I",
"\xCD": "I",
"\xCE": "I",
"\xCF": "I",
"\xEC": "i",
"\xED": "i",
"\xEE": "i",
"\xEF": "i",
"\xD1": "N",
"\xF1": "n",
"\xD2": "O",
"\xD3": "O",
"\xD4": "O",
"\xD5": "O",
"\xD6": "O",
"\xD8": "O",
"\xF2": "o",
"\xF3": "o",
"\xF4": "o",
"\xF5": "o",
"\xF6": "o",
"\xF8": "o",
"\xD9": "U",
"\xDA": "U",
"\xDB": "U",
"\xDC": "U",
"\xF9": "u",
"\xFA": "u",
"\xFB": "u",
"\xFC": "u",
"\xDD": "Y",
"\xFD": "y",
"\xFF": "y",
"\xC6": "Ae",
"\xE6": "ae",
"\xDE": "Th",
"\xFE": "th",
"\xDF": "ss",
// Latin Extended-A block.
"\u0100": "A",
"\u0102": "A",
"\u0104": "A",
"\u0101": "a",
"\u0103": "a",
"\u0105": "a",
"\u0106": "C",
"\u0108": "C",
"\u010A": "C",
"\u010C": "C",
"\u0107": "c",
"\u0109": "c",
"\u010B": "c",
"\u010D": "c",
"\u010E": "D",
"\u0110": "D",
"\u010F": "d",
"\u0111": "d",
"\u0112": "E",
"\u0114": "E",
"\u0116": "E",
"\u0118": "E",
"\u011A": "E",
"\u0113": "e",
"\u0115": "e",
"\u0117": "e",
"\u0119": "e",
"\u011B": "e",
"\u011C": "G",
"\u011E": "G",
"\u0120": "G",
"\u0122": "G",
"\u011D": "g",
"\u011F": "g",
"\u0121": "g",
"\u0123": "g",
"\u0124": "H",
"\u0126": "H",
"\u0125": "h",
"\u0127": "h",
"\u0128": "I",
"\u012A": "I",
"\u012C": "I",
"\u012E": "I",
"\u0130": "I",
"\u0129": "i",
"\u012B": "i",
"\u012D": "i",
"\u012F": "i",
"\u0131": "i",
"\u0134": "J",
"\u0135": "j",
"\u0136": "K",
"\u0137": "k",
"\u0138": "k",
"\u0139": "L",
"\u013B": "L",
"\u013D": "L",
"\u013F": "L",
"\u0141": "L",
"\u013A": "l",
"\u013C": "l",
"\u013E": "l",
"\u0140": "l",
"\u0142": "l",
"\u0143": "N",
"\u0145": "N",
"\u0147": "N",
"\u014A": "N",
"\u0144": "n",
"\u0146": "n",
"\u0148": "n",
"\u014B": "n",
"\u014C": "O",
"\u014E": "O",
"\u0150": "O",
"\u014D": "o",
"\u014F": "o",
"\u0151": "o",
"\u0154": "R",
"\u0156": "R",
"\u0158": "R",
"\u0155": "r",
"\u0157": "r",
"\u0159": "r",
"\u015A": "S",
"\u015C": "S",
"\u015E": "S",
"\u0160": "S",
"\u015B": "s",
"\u015D": "s",
"\u015F": "s",
"\u0161": "s",
"\u0162": "T",
"\u0164": "T",
"\u0166": "T",
"\u0163": "t",
"\u0165": "t",
"\u0167": "t",
"\u0168": "U",
"\u016A": "U",
"\u016C": "U",
"\u016E": "U",
"\u0170": "U",
"\u0172": "U",
"\u0169": "u",
"\u016B": "u",
"\u016D": "u",
"\u016F": "u",
"\u0171": "u",
"\u0173": "u",
"\u0174": "W",
"\u0175": "w",
"\u0176": "Y",
"\u0177": "y",
"\u0178": "Y",
"\u0179": "Z",
"\u017B": "Z",
"\u017D": "Z",
"\u017A": "z",
"\u017C": "z",
"\u017E": "z",
"\u0132": "IJ",
"\u0133": "ij",
"\u0152": "Oe",
"\u0153": "oe",
"\u0149": "'n",
"\u017F": "ss"
};
var freeGlobal = typeof global == "object" && global && global.Object === Object && global;
var freeSelf = typeof self == "object" && self && self.Object === Object && self;
var root = freeGlobal || freeSelf || Function("return this")();
function arrayReduce(array, iteratee, accumulator, initAccum) {
var index = -1, length = array ? array.length : 0;
if (initAccum && length) {
accumulator = array[++index];
}
while (++index < length) {
accumulator = iteratee(accumulator, array[index], index, array);
}
return accumulator;
}
function asciiToArray(string) {
return string.split("");
}
function asciiWords(string) {
return string.match(reAsciiWord) || [];
}
function basePropertyOf(object) {
return function(key) {
return object == null ? void 0 : object[key];
};
}
var deburrLetter = basePropertyOf(deburredLetters);
function hasUnicode(string) {
return reHasUnicode.test(string);
}
function hasUnicodeWord(string) {
return reHasUnicodeWord.test(string);
}
function stringToArray(string) {
return hasUnicode(string) ? unicodeToArray(string) : asciiToArray(string);
}
function unicodeToArray(string) {
return string.match(reUnicode) || [];
}
function unicodeWords(string) {
return string.match(reUnicodeWord) || [];
}
var objectProto = Object.prototype;
var objectToString = objectProto.toString;
var Symbol2 = root.Symbol;
var symbolProto = Symbol2 ? Symbol2.prototype : void 0;
var symbolToString = symbolProto ? symbolProto.toString : void 0;
function baseSlice(array, start, end) {
var index = -1, length = array.length;
if (start < 0) {
start = -start > length ? 0 : length + start;
}
end = end > length ? length : end;
if (end < 0) {
end += length;
}
length = start > end ? 0 : end - start >>> 0;
start >>>= 0;
var result = Array(length);
while (++index < length) {
result[index] = array[index + start];
}
return result;
}
function baseToString(value) {
if (typeof value == "string") {
return value;
}
if (isSymbol(value)) {
return symbolToString ? symbolToString.call(value) : "";
}
var result = value + "";
return result == "0" && 1 / value == -INFINITY ? "-0" : result;
}
function castSlice(array, start, end) {
var length = array.length;
end = end === void 0 ? length : end;
return !start && end >= length ? array : baseSlice(array, start, end);
}
function createCaseFirst(methodName) {
return function(string) {
string = toString(string);
var strSymbols = hasUnicode(string) ? stringToArray(string) : void 0;
var chr = strSymbols ? strSymbols[0] : string.charAt(0);
var trailing = strSymbols ? castSlice(strSymbols, 1).join("") : string.slice(1);
return chr[methodName]() + trailing;
};
}
function createCompounder(callback) {
return function(string) {
return arrayReduce(words(deburr(string).replace(reApos, "")), callback, "");
};
}
function isObjectLike(value) {
return !!value && typeof value == "object";
}
function isSymbol(value) {
return typeof value == "symbol" || isObjectLike(value) && objectToString.call(value) == symbolTag;
}
function toString(value) {
return value == null ? "" : baseToString(value);
}
var camelCase = createCompounder(function(result, word, index) {
word = word.toLowerCase();
return result + (index ? capitalize(word) : word);
});
function capitalize(string) {
return upperFirst(toString(string).toLowerCase());
}
function deburr(string) {
string = toString(string);
return string && string.replace(reLatin, deburrLetter).replace(reComboMark, "");
}
var upperFirst = createCaseFirst("toUpperCase");
function words(string, pattern, guard) {
string = toString(string);
pattern = guard ? void 0 : pattern;
if (pattern === void 0) {
return hasUnicodeWord(string) ? unicodeWords(string) : asciiWords(string);
}
return string.match(pattern) || [];
}
module2.exports = camelCase;
}
});
// ../../node_modules/.pnpm/command-line-args@5.2.1/node_modules/command-line-args/dist/index.js
var require_dist = __commonJS({
"../../node_modules/.pnpm/command-line-args@5.2.1/node_modules/command-line-args/dist/index.js"(exports2, module2) {
"use strict";
function _interopDefault(ex) {
return ex && typeof ex === "object" && "default" in ex ? ex["default"] : ex;
}
var camelCase = _interopDefault(require_lodash());
function isObject(input) {
return typeof input === "object" && input !== null;
}
function isArrayLike(input) {
return isObject(input) && typeof input.length === "number";
}
function arrayify(input) {
if (Array.isArray(input)) {
return input;
}
if (input === void 0) {
return [];
}
if (isArrayLike(input) || input instanceof Set) {
return Array.from(input);
}
return [input];
}
function isObject$1(input) {
return typeof input === "object" && input !== null;
}
function isArrayLike$1(input) {
return isObject$1(input) && typeof input.length === "number";
}
function arrayify$1(input) {
if (Array.isArray(input)) {
return input;
} else {
if (input === void 0) {
return [];
} else if (isArrayLike$1(input)) {
return Array.prototype.slice.call(input);
} else {
return [input];
}
}
}
function findReplace(array, testFn) {
const found = [];
const replaceWiths = arrayify$1(arguments);
replaceWiths.splice(0, 2);
arrayify$1(array).forEach((value, index) => {
let expanded = [];
replaceWiths.forEach((replaceWith) => {
if (typeof replaceWith === "function") {
expanded = expanded.concat(replaceWith(value));
} else {
expanded.push(replaceWith);
}
});
if (testFn(value)) {
found.push({
index,
replaceWithValue: expanded
});
}
});
found.reverse().forEach((item) => {
const spliceArgs = [item.index, 1].concat(item.replaceWithValue);
array.splice.apply(array, spliceArgs);
});
return array;
}
var re12 = {
short: /^-([^\d-])$/,
long: /^--(\S+)/,
combinedShort: /^-[^\d-]{2,}$/,
optEquals: /^(--\S+?)=(.*)/
};
var ArgvArray = class extends Array {
/**
* Clears the array has loads the supplied input.
* @param {string[]} argv - The argv list to load. Defaults to `process.argv`.
*/
load(argv) {
this.clear();
if (argv && argv !== process.argv) {
argv = arrayify(argv);
} else {
argv = process.argv.slice(0);
const deleteCount = process.execArgv.some(isExecArg) ? 1 : 2;
argv.splice(0, deleteCount);
}
argv.forEach((arg) => this.push(String(arg)));
}
/**
* Clear the array.
*/
clear() {
this.length = 0;
}
/**
* expand ``--option=value` style args.
*/
expandOptionEqualsNotation() {
if (this.some((arg) => re12.optEquals.test(arg))) {
const expandedArgs = [];
this.forEach((arg) => {
const matches = arg.match(re12.optEquals);
if (matches) {
expandedArgs.push(matches[1], matches[2]);
} else {
expandedArgs.push(arg);
}
});
this.clear();
this.load(expandedArgs);
}
}
/**
* expand getopt-style combinedShort options.
*/
expandGetoptNotation() {
if (this.hasCombinedShortOptions()) {
findReplace(this, re12.combinedShort, expandCombinedShortArg);
}
}
/**
* Returns true if the array contains combined short options (e.g. `-ab`).
* @returns {boolean}
*/
hasCombinedShortOptions() {
return this.some((arg) => re12.combinedShort.test(arg));
}
static from(argv) {
const result = new this();
result.load(argv);
return result;
}
};
function expandCombinedShortArg(arg) {
arg = arg.slice(1);
return arg.split("").map((letter) => "-" + letter);
}
function isOptionEqualsNotation(arg) {
return re12.optEquals.test(arg);
}
function isOption(arg) {
return (re12.short.test(arg) || re12.long.test(arg)) && !re12.optEquals.test(arg);
}
function isLongOption(arg) {
return re12.long.test(arg) && !isOptionEqualsNotation(arg);
}
function getOptionName(arg) {
if (re12.short.test(arg)) {
return arg.match(re12.short)[1];
} else if (isLongOption(arg)) {
return arg.match(re12.long)[1];
} else if (isOptionEqualsNotation(arg)) {
return arg.match(re12.optEquals)[1].replace(/^--/, "");
} else {
return null;
}
}
function isValue(arg) {
return !(isOption(arg) || re12.combinedShort.test(arg) || re12.optEquals.test(arg));
}
function isExecArg(arg) {
return ["--eval", "-e"].indexOf(arg) > -1 || arg.startsWith("--eval=");
}
function isNumber(n41) {
return !isNaN(parseFloat(n41)) && isFinite(n41);
}
function isPlainObject(input) {
return input !== null && typeof input === "object" && input.constructor === Object;
}
function isArrayLike$2(input) {
return isObject$2(input) && typeof input.length === "number";
}
function isObject$2(input) {
return typeof input === "object" && input !== null;
}
function isDefined(input) {
return typeof input !== "undefined";
}
function isString(input) {
return typeof input === "string";
}
function isBoolean(input) {
return typeof input === "boolean";
}
function isFunction(input) {
return typeof input === "function";
}
function isClass(input) {
if (isFunction(input)) {
return /^class /.test(Function.prototype.toString.call(input));
} else {
return false;
}
}
function isPrimitive(input) {
if (input === null) return true;
switch (typeof input) {
case "string":
case "number":
case "symbol":
case "undefined":
case "boolean":
return true;
default:
return false;
}
}
function isPromise(input) {
if (input) {
const isPromise2 = isDefined(Promise) && input instanceof Promise;
const isThenable = input.then && typeof input.then === "function";
return !!(isPromise2 || isThenable);
} else {
return false;
}
}
function isIterable(input) {
if (input === null || !isDefined(input)) {
return false;
} else {
return typeof input[Symbol.iterator] === "function" || typeof input[Symbol.asyncIterator] === "function";
}
}
var t43 = {
isNumber,
isString,
isBoolean,
isPlainObject,
isArrayLike: isArrayLike$2,
isObject: isObject$2,
isDefined,
isFunction,
isClass,
isPrimitive,
isPromise,
isIterable
};
var OptionDefinition = class {
constructor(definition) {
this.name = definition.name;
this.type = definition.type || String;
this.alias = definition.alias;
this.multiple = definition.multiple;
this.lazyMultiple = definition.lazyMultiple;
this.defaultOption = definition.defaultOption;
this.defaultValue = definition.defaultValue;
this.group = definition.group;
for (const prop in definition) {
if (!this[prop]) this[prop] = definition[prop];
}
}
isBoolean() {
return this.type === Boolean || t43.isFunction(this.type) && this.type.name === "Boolean";
}
isMultiple() {
return this.multiple || this.lazyMultiple;
}
static create(def) {
const result = new this(def);
return result;
}
};
var Definitions = class extends Array {
/**
* validate option definitions
* @param {boolean} [caseInsensitive=false] - whether arguments will be parsed in a case insensitive manner
* @returns {string}
*/
validate(caseInsensitive) {
const someHaveNoName = this.some((def) => !def.name);
if (someHaveNoName) {
halt(
"INVALID_DEFINITIONS",
"Invalid option definitions: the `name` property is required on each definition"
);
}
const someDontHaveFunctionType = this.some((def) => def.type && typeof def.type !== "function");
if (someDontHaveFunctionType) {
halt(
"INVALID_DEFINITIONS",
"Invalid option definitions: the `type` property must be a setter fuction (default: `Boolean`)"
);
}
let invalidOption;
const numericAlias = this.some((def) => {
invalidOption = def;
return t43.isDefined(def.alias) && t43.isNumber(def.alias);
});
if (numericAlias) {
halt(
"INVALID_DEFINITIONS",
"Invalid option definition: to avoid ambiguity an alias cannot be numeric [--" + invalidOption.name + " alias is -" + invalidOption.alias + "]"
);
}
const multiCharacterAlias = this.some((def) => {
invalidOption = def;
return t43.isDefined(def.alias) && def.alias.length !== 1;
});
if (multiCharacterAlias) {
halt(
"INVALID_DEFINITIONS",
"Invalid option definition: an alias must be a single character"
);
}
const hypenAlias = this.some((def) => {
invalidOption = def;
return def.alias === "-";
});
if (hypenAlias) {
halt(
"INVALID_DEFINITIONS",
'Invalid option definition: an alias cannot be "-"'
);
}
const duplicateName = hasDuplicates(this.map((def) => caseInsensitive ? def.name.toLowerCase() : def.name));
if (duplicateName) {
halt(
"INVALID_DEFINITIONS",
"Two or more option definitions have the same name"
);
}
const duplicateAlias = hasDuplicates(this.map((def) => caseInsensitive && t43.isDefined(def.alias) ? def.alias.toLowerCase() : def.alias));
if (duplicateAlias) {
halt(
"INVALID_DEFINITIONS",
"Two or more option definitions have the same alias"
);
}
const duplicateDefaultOption = this.filter((def) => def.defaultOption === true).length > 1;
if (duplicateDefaultOption) {
halt(
"INVALID_DEFINITIONS",
"Only one option definition can be the defaultOption"
);
}
const defaultBoolean = this.some((def) => {
invalidOption = def;
return def.isBoolean() && def.defaultOption;
});
if (defaultBoolean) {
halt(
"INVALID_DEFINITIONS",
`A boolean option ["${invalidOption.name}"] can not also be the defaultOption.`
);
}
}
/**
* Get definition by option arg (e.g. `--one` or `-o`)
* @param {string} [arg] the argument name to get the definition for
* @param {boolean} [caseInsensitive] whether to use case insensitive comparisons when finding the appropriate definition
* @returns {Definition}
*/
get(arg, caseInsensitive) {
if (isOption(arg)) {
if (re12.short.test(arg)) {
const shortOptionName = getOptionName(arg);
if (caseInsensitive) {
const lowercaseShortOptionName = shortOptionName.toLowerCase();
return this.find((def) => t43.isDefined(def.alias) && def.alias.toLowerCase() === lowercaseShortOptionName);
} else {
return this.find((def) => def.alias === shortOptionName);
}
} else {
const optionName = getOptionName(arg);
if (caseInsensitive) {
const lowercaseOptionName = optionName.toLowerCase();
return this.find((def) => def.name.toLowerCase() === lowercaseOptionName);
} else {
return this.find((def) => def.name === optionName);
}
}
} else {
return this.find((def) => def.name === arg);
}
}
getDefault() {
return this.find((def) => def.defaultOption === true);
}
isGrouped() {
return this.some((def) => def.group);
}
whereGrouped() {
return this.filter(containsValidGroup);
}
whereNotGrouped() {
return this.filter((def) => !containsValidGroup(def));
}
whereDefaultValueSet() {
return this.filter((def) => t43.isDefined(def.defaultValue));
}
static from(definitions, caseInsensitive) {
if (definitions instanceof this) return definitions;
const result = super.from(arrayify(definitions), (def) => OptionDefinition.create(def));
result.validate(caseInsensitive);
return result;
}
};
function halt(name, message) {
const err = new Error(message);
err.name = name;
throw err;
}
function containsValidGroup(def) {
return arrayify(def.group).some((group) => group);
}
function hasDuplicates(array) {
const items = {};
for (let i50 = 0; i50 < array.length; i50++) {
const value = array[i50];
if (items[value]) {
return true;
} else {
if (t43.isDefined(value)) items[value] = true;
}
}
}
var ArgvParser = class {
/**
* @param {OptionDefinitions} - Definitions array
* @param {object} [options] - Options
* @param {string[]} [options.argv] - Overrides `process.argv`
* @param {boolean} [options.stopAtFirstUnknown] -
* @param {boolean} [options.caseInsensitive] - Arguments will be parsed in a case insensitive manner. Defaults to false.
*/
constructor(definitions, options) {
this.options = Object.assign({}, options);
this.definitions = Definitions.from(definitions, this.options.caseInsensitive);
this.argv = ArgvArray.from(this.options.argv);
if (this.argv.hasCombinedShortOptions()) {
findReplace(this.argv, re12.combinedShort.test.bind(re12.combinedShort), (arg) => {
arg = arg.slice(1);
return arg.split("").map((letter) => ({ origArg: `-${arg}`, arg: "-" + letter }));
});
}
}
/**
* Yields one `{ event, name, value, arg, def }` argInfo object for each arg in `process.argv` (or `options.argv`).
*/
*[Symbol.iterator]() {
const definitions = this.definitions;
let def;
let value;
let name;
let event;
let singularDefaultSet = false;
let unknownFound = false;
let origArg;
for (let arg of this.argv) {
if (t43.isPlainObject(arg)) {
origArg = arg.origArg;
arg = arg.arg;
}
if (unknownFound && this.options.stopAtFirstUnknown) {
yield { event: "unknown_value", arg, name: "_unknown", value: void 0 };
continue;
}
if (isOption(arg)) {
def = definitions.get(arg, this.options.caseInsensitive);
value = void 0;
if (def) {
value = def.isBoolean() ? true : null;
event = "set";
} else {
event = "unknown_option";
}
} else if (isOptionEqualsNotation(arg)) {
const matches = arg.match(re12.optEquals);
def = definitions.get(matches[1], this.options.caseInsensitive);
if (def) {
if (def.isBoolean()) {
yield { event: "unknown_value", arg, name: "_unknown", value, def };
event = "set";
value = true;
} else {
event = "set";
value = matches[2];
}
} else {
event = "unknown_option";
}
} else if (isValue(arg)) {
if (def) {
value = arg;
event = "set";
} else {
def = this.definitions.getDefault();
if (def && !singularDefaultSet) {
value = arg;
event = "set";
} else {
event = "unknown_value";
def = void 0;
}
}
}
name = def ? def.name : "_unknown";
const argInfo = { event, arg, name, value, def };
if (origArg) {
argInfo.subArg = arg;
argInfo.arg = origArg;
}
yield argInfo;
if (name === "_unknown") unknownFound = true;
if (def && def.defaultOption && !def.isMultiple() && event === "set") singularDefaultSet = true;
if (def && def.isBoolean()) def = void 0;
if (def && !def.multiple && t43.isDefined(value) && value !== null) {
def = void 0;
}
value = void 0;
event = void 0;
name = void 0;
origArg = void 0;
}
}
};
var _value = /* @__PURE__ */ new WeakMap();
var Option = class {
constructor(definition) {
this.definition = new OptionDefinition(definition);
this.state = null;
this.resetToDefault();
}
get() {
return _value.get(this);
}
set(val) {
this._set(val, "set");
}
_set(val, state) {
const def = this.definition;
if (def.isMultiple()) {
if (val !== null && val !== void 0) {
const arr = this.get();
if (this.state === "default") arr.length = 0;
arr.push(def.type(val));
this.state = state;
}
} else {
if (!def.isMultiple() && this.state === "set") {
const err = new Error(`Singular option already set [${this.definition.name}=${this.get()}]`);
err.name = "ALREADY_SET";
err.value = val;
err.optionName = def.name;
throw err;
} else if (val === null || val === void 0) {
_value.set(this, val);
} else {
_value.set(this, def.type(val));
this.state = state;
}
}
}
resetToDefault() {
if (t43.isDefined(this.definition.defaultValue)) {
if (this.definition.isMultiple()) {
_value.set(this, arrayify(this.definition.defaultValue).slice());
} else {
_value.set(this, this.definition.defaultValue);
}
} else {
if (this.definition.isMultiple()) {
_value.set(this, []);
} else {
_value.set(this, null);
}
}
this.state = "default";
}
static create(definition) {
definition = new OptionDefinition(definition);
if (definition.isBoolean()) {
return FlagOption.create(definition);
} else {
return new this(definition);
}
}
};
var FlagOption = class extends Option {
set(val) {
super.set(true);
}
static create(def) {
return new this(def);
}
};
var Output = class extends Map {
constructor(definitions) {
super();
this.definitions = Definitions.from(definitions);
this.set("_unknown", Option.create({ name: "_unknown", multiple: true }));
for (const def of this.definitions.whereDefaultValueSet()) {
this.set(def.name, Option.create(def));
}
}
toObject(options) {
options = options || {};
const output = {};
for (const item of this) {
const name = options.camelCase && item[0] !== "_unknown" ? camelCase(item[0]) : item[0];
const option = item[1];
if (name === "_unknown" && !option.get().length) continue;
output[name] = option.get();
}
if (options.skipUnknown) delete output._unknown;
return output;
}
};
var GroupedOutput = class extends Output {
toObject(options) {
const superOutputNoCamel = super.toObject({ skipUnknown: options.skipUnknown });
const superOutput = super.toObject(options);
const unknown = superOutput._unknown;
delete superOutput._unknown;
const grouped = {
_all: superOutput
};
if (unknown && unknown.length) grouped._unknown = unknown;
this.definitions.whereGrouped().forEach((def) => {
const name = options.camelCase ? camelCase(def.name) : def.name;
const outputValue = superOutputNoCamel[def.name];
for (const groupName of arrayify(def.group)) {
grouped[groupName] = grouped[groupName] || {};
if (t43.isDefined(outputValue)) {
grouped[groupName][name] = outputValue;
}
}
});
this.definitions.whereNotGrouped().forEach((def) => {
const name = options.camelCase ? camelCase(def.name) : def.name;
const outputValue = superOutputNoCamel[def.name];
if (t43.isDefined(outputValue)) {
if (!grouped._none) grouped._none = {};
grouped._none[name] = outputValue;
}
});
return grouped;
}
};
function commandLineArgs(optionDefinitions, options) {
options = options || {};
if (options.stopAtFirstUnknown) options.partial = true;
optionDefinitions = Definitions.from(optionDefinitions, options.caseInsensitive);
const parser = new ArgvParser(optionDefinitions, {
argv: options.argv,
stopAtFirstUnknown: options.stopAtFirstUnknown,
caseInsensitive: options.caseInsensitive
});
const OutputClass = optionDefinitions.isGrouped() ? GroupedOutput : Output;
const output = new OutputClass(optionDefinitions);
for (const argInfo of parser) {
const arg = argInfo.subArg || argInfo.arg;
if (!options.partial) {
if (argInfo.event === "unknown_value") {
const err = new Error(`Unknown value: ${arg}`);
err.name = "UNKNOWN_VALUE";
err.value = arg;
throw err;
} else if (argInfo.event === "unknown_option") {
const err = new Error(`Unknown option: ${arg}`);
err.name = "UNKNOWN_OPTION";
err.optionName = arg;
throw err;
}
}
let option;
if (output.has(argInfo.name)) {
option = output.get(argInfo.name);
} else {
option = Option.create(argInfo.def);
output.set(argInfo.name, option);
}
if (argInfo.name === "_unknown") {
option.set(arg);
} else {
option.set(argInfo.value);
}
}
return output.toObject({ skipUnknown: !options.partial, camelCase: options.camelCase });
}
module2.exports = commandLineArgs;
}
});
// ../../node_modules/.pnpm/array-back@4.0.2/node_modules/array-back/dist/index.js
var require_dist2 = __commonJS({
"../../node_modules/.pnpm/array-back@4.0.2/node_modules/array-back/dist/index.js"(exports2, module2) {
(function(global2, factory) {
typeof exports2 === "object" && typeof module2 !== "undefined" ? module2.exports = factory() : typeof define === "function" && define.amd ? define(factory) : (global2 = global2 || self, global2.arrayBack = factory());
})(exports2, function() {
"use strict";
function isObject(input) {
return typeof input === "object" && input !== null;
}
function isArrayLike(input) {
return isObject(input) && typeof input.length === "number";
}
function arrayify(input) {
if (Array.isArray(input)) {
return input;
}
if (input === void 0) {
return [];
}
if (isArrayLike(input) || input instanceof Set) {
return Array.from(input);
}
return [input];
}
return arrayify;
});
}
});
// ../../node_modules/.pnpm/escape-string-regexp@1.0.5/node_modules/escape-string-regexp/index.js
var require_escape_string_regexp = __commonJS({
"../../node_modules/.pnpm/escape-string-regexp@1.0.5/node_modules/escape-string-regexp/index.js"(exports2, module2) {
"use strict";
var matchOperatorsRe = /[|\\{}()[\]^$+*?.]/g;
module2.exports = function(str) {
if (typeof str !== "string") {
throw new TypeError("Expected a string");
}
return str.replace(matchOperatorsRe, "\\$&");
};
}
});
// ../../node_modules/.pnpm/color-name@1.1.3/node_modules/color-name/index.js
var require_color_name = __commonJS({
"../../node_modules/.pnpm/color-name@1.1.3/node_modules/color-name/index.js"(exports2, module2) {
"use strict";
module2.exports = {
"aliceblue": [240, 248, 255],
"antiquewhite": [250, 235, 215],
"aqua": [0, 255, 255],
"aquamarine": [127, 255, 212],
"azure": [240, 255, 255],
"beige": [245, 245, 220],
"bisque": [255, 228, 196],
"black": [0, 0, 0],
"blanchedalmond": [255, 235, 205],
"blue": [0, 0, 255],
"blueviolet": [138, 43, 226],
"brown": [165, 42, 42],
"burlywood": [222, 184, 135],
"cadetblue": [95, 158, 160],
"chartreuse": [127, 255, 0],
"chocolate": [210, 105, 30],
"coral": [255, 127, 80],
"cornflowerblue": [100, 149, 237],
"cornsilk": [255, 248, 220],
"crimson": [220, 20, 60],
"cyan": [0, 255, 255],
"darkblue": [0, 0, 139],
"darkcyan": [0, 139, 139],
"darkgoldenrod": [184, 134, 11],
"darkgray": [169, 169, 169],
"darkgreen": [0, 100, 0],
"darkgrey": [169, 169, 169],
"darkkhaki": [189, 183, 107],
"darkmagenta": [139, 0, 139],
"darkolivegreen": [85, 107, 47],
"darkorange": [255, 140, 0],
"darkorchid": [153, 50, 204],
"darkred": [139, 0, 0],
"darksalmon": [233, 150, 122],
"darkseagreen": [143, 188, 143],
"darkslateblue": [72, 61, 139],
"darkslategray": [47, 79, 79],
"darkslategrey": [47, 79, 79],
"darkturquoise": [0, 206, 209],
"darkviolet": [148, 0, 211],
"deeppink": [255, 20, 147],
"deepskyblue": [0, 191, 255],
"dimgray": [105, 105, 105],
"dimgrey": [105, 105, 105],
"dodgerblue": [30, 144, 255],
"firebrick": [178, 34, 34],
"floralwhite": [255, 250, 240],
"forestgreen": [34, 139, 34],
"fuchsia": [255, 0, 255],
"gainsboro": [220, 220, 220],
"ghostwhite": [248, 248, 255],
"gold": [255, 215, 0],
"goldenrod": [218, 165, 32],
"gray": [128, 128, 128],
"green": [0, 128, 0],
"greenyellow": [173, 255, 47],
"grey": [128, 128, 128],
"honeydew": [240, 255, 240],
"hotpink": [255, 105, 180],
"indianred": [205, 92, 92],
"indigo": [75, 0, 130],
"ivory": [255, 255, 240],
"khaki": [240, 230, 140],
"lavender": [230, 230, 250],
"lavenderblush": [255, 240, 245],
"lawngreen": [124, 252, 0],
"lemonchiffon": [255, 250, 205],
"lightblue": [173, 216, 230],
"lightcoral": [240, 128, 128],
"lightcyan": [224, 255, 255],
"lightgoldenrodyellow": [250, 250, 210],
"lightgray": [211, 211, 211],
"lightgreen": [144, 238, 144],
"lightgrey": [211, 211, 211],
"lightpink": [255, 182, 193],
"lightsalmon": [255, 160, 122],
"lightseagreen": [32, 178, 170],
"lightskyblue": [135, 206, 250],
"lightslategray": [119, 136, 153],
"lightslategrey": [119, 136, 153],
"lightsteelblue": [176, 196, 222],
"lightyellow": [255, 255, 224],
"lime": [0, 255, 0],
"limegreen": [50, 205, 50],
"linen": [250, 240, 230],
"magenta": [255, 0, 255],
"maroon": [128, 0, 0],
"mediumaquamarine": [102, 205, 170],
"mediumblue": [0, 0, 205],
"mediumorchid": [186, 85, 211],
"mediumpurple": [147, 112, 219],
"mediumseagreen": [60, 179, 113],
"mediumslateblue": [123, 104, 238],
"mediumspringgreen": [0, 250, 154],
"mediumturquoise": [72, 209, 204],
"mediumvioletred": [199, 21, 133],
"midnightblue": [25, 25, 112],
"mintcream": [245, 255, 250],
"mistyrose": [255, 228, 225],
"moccasin": [255, 228, 181],
"navajowhite": [255, 222, 173],
"navy": [0, 0, 128],
"oldlace": [253, 245, 230],
"olive": [128, 128, 0],
"olivedrab": [107, 142, 35],
"orange": [255, 165, 0],
"orangered": [255, 69, 0],
"orchid": [218, 112, 214],
"palegoldenrod": [238, 232, 170],
"palegreen": [152, 251, 152],
"paleturquoise": [175, 238, 238],
"palevioletred": [219, 112, 147],
"papayawhip": [255, 239, 213],
"peachpuff": [255, 218, 185],
"peru": [205, 133, 63],
"pink": [255, 192, 203],
"plum": [221, 160, 221],
"powderblue": [176, 224, 230],
"purple": [128, 0, 128],
"rebeccapurple": [102, 51, 153],
"red": [255, 0, 0],
"rosybrown": [188, 143, 143],
"royalblue": [65, 105, 225],
"saddlebrown": [139, 69, 19],
"salmon": [250, 128, 114],
"sandybrown": [244, 164, 96],
"seagreen": [46, 139, 87],
"seashell": [255, 245, 238],
"sienna": [160, 82, 45],
"silver": [192, 192, 192],
"skyblue": [135, 206, 235],
"slateblue": [106, 90, 205],
"slategray": [112, 128, 144],
"slategrey": [112, 128, 144],
"snow": [255, 250, 250],
"springgreen": [0, 255, 127],
"steelblue": [70, 130, 180],
"tan": [210, 180, 140],
"teal": [0, 128, 128],
"thistle": [216, 191, 216],
"tomato": [255, 99, 71],
"turquoise": [64, 224, 208],
"violet": [238, 130, 238],
"wheat": [245, 222, 179],
"white": [255, 255, 255],
"whitesmoke": [245, 245, 245],
"yellow": [255, 255, 0],
"yellowgreen": [154, 205, 50]
};
}
});
// ../../node_modules/.pnpm/color-convert@1.9.3/node_modules/color-convert/conversions.js
var require_conversions = __commonJS({
"../../node_modules/.pnpm/color-convert@1.9.3/node_modules/color-convert/conversions.js"(exports2, module2) {
var cssKeywords = require_color_name();
var reverseKeywords = {};
for (key in cssKeywords) {
if (cssKeywords.hasOwnProperty(key)) {
reverseKeywords[cssKeywords[key]] = key;
}
}
var key;
var convert = module2.exports = {
rgb: { channels: 3, labels: "rgb" },
hsl: { channels: 3, labels: "hsl" },
hsv: { channels: 3, labels: "hsv" },
hwb: { channels: 3, labels: "hwb" },
cmyk: { channels: 4, labels: "cmyk" },
xyz: { channels: 3, labels: "xyz" },
lab: { channels: 3, labels: "lab" },
lch: { channels: 3, labels: "lch" },
hex: { channels: 1, labels: ["hex"] },
keyword: { channels: 1, labels: ["keyword"] },
ansi16: { channels: 1, labels: ["ansi16"] },
ansi256: { channels: 1, labels: ["ansi256"] },
hcg: { channels: 3, labels: ["h", "c", "g"] },
apple: { channels: 3, labels: ["r16", "g16", "b16"] },
gray: { channels: 1, labels: ["gray"] }
};
for (model in convert) {
if (convert.hasOwnProperty(model)) {
if (!("channels" in convert[model])) {
throw new Error("missing channels property: " + model);
}
if (!("labels" in convert[model])) {
throw new Error("missing channel labels property: " + model);
}
if (convert[model].labels.length !== convert[model].channels) {
throw new Error("channel and label counts mismatch: " + model);
}
channels = convert[model].channels;
labels = convert[model].labels;
delete convert[model].channels;
delete convert[model].labels;
Object.defineProperty(convert[model], "channels", { value: channels });
Object.defineProperty(convert[model], "labels", { value: labels });
}
}
var channels;
var labels;
var model;
convert.rgb.hsl = function(rgb) {
var r40 = rgb[0] / 255;
var g61 = rgb[1] / 255;
var b64 = rgb[2] / 255;
var min = Math.min(r40, g61, b64);
var max = Math.max(r40, g61, b64);
var delta = max - min;
var h63;
var s60;
var l57;
if (max === min) {
h63 = 0;
} else if (r40 === max) {
h63 = (g61 - b64) / delta;
} else if (g61 === max) {
h63 = 2 + (b64 - r40) / delta;
} else if (b64 === max) {
h63 = 4 + (r40 - g61) / delta;
}
h63 = Math.min(h63 * 60, 360);
if (h63 < 0) {
h63 += 360;
}
l57 = (min + max) / 2;
if (max === min) {
s60 = 0;
} else if (l57 <= 0.5) {
s60 = delta / (max + min);
} else {
s60 = delta / (2 - max - min);
}
return [h63, s60 * 100, l57 * 100];
};
convert.rgb.hsv = function(rgb) {
var rdif;
var gdif;
var bdif;
var h63;
var s60;
var r40 = rgb[0] / 255;
var g61 = rgb[1] / 255;
var b64 = rgb[2] / 255;
var v53 = Math.max(r40, g61, b64);
var diff = v53 - Math.min(r40, g61, b64);
var diffc = function(c65) {
return (v53 - c65) / 6 / diff + 1 / 2;
};
if (diff === 0) {
h63 = s60 = 0;
} else {
s60 = diff / v53;
rdif = diffc(r40);
gdif = diffc(g61);
bdif = diffc(b64);
if (r40 === v53) {
h63 = bdif - gdif;
} else if (g61 === v53) {
h63 = 1 / 3 + rdif - bdif;
} else if (b64 === v53) {
h63 = 2 / 3 + gdif - rdif;
}
if (h63 < 0) {
h63 += 1;
} else if (h63 > 1) {
h63 -= 1;
}
}
return [
h63 * 360,
s60 * 100,
v53 * 100
];
};
convert.rgb.hwb = function(rgb) {
var r40 = rgb[0];
var g61 = rgb[1];
var b64 = rgb[2];
var h63 = convert.rgb.hsl(rgb)[0];
var w55 = 1 / 255 * Math.min(r40, Math.min(g61, b64));
b64 = 1 - 1 / 255 * Math.max(r40, Math.max(g61, b64));
return [h63, w55 * 100, b64 * 100];
};
convert.rgb.cmyk = function(rgb) {
var r40 = rgb[0] / 255;
var g61 = rgb[1] / 255;
var b64 = rgb[2] / 255;
var c65;
var m54;
var y64;
var k59;
k59 = Math.min(1 - r40, 1 - g61, 1 - b64);
c65 = (1 - r40 - k59) / (1 - k59) || 0;
m54 = (1 - g61 - k59) / (1 - k59) || 0;
y64 = (1 - b64 - k59) / (1 - k59) || 0;
return [c65 * 100, m54 * 100, y64 * 100, k59 * 100];
};
function comparativeDistance(x62, y64) {
return Math.pow(x62[0] - y64[0], 2) + Math.pow(x62[1] - y64[1], 2) + Math.pow(x62[2] - y64[2], 2);
}
convert.rgb.keyword = function(rgb) {
var reversed = reverseKeywords[rgb];
if (reversed) {
return reversed;
}
var currentClosestDistance = Infinity;
var currentClosestKeyword;
for (var keyword in cssKeywords) {
if (cssKeywords.hasOwnProperty(keyword)) {
var value = cssKeywords[keyword];
var distance = comparativeDistance(rgb, value);
if (distance < currentClosestDistance) {
currentClosestDistance = distance;
currentClosestKeyword = keyword;
}
}
}
return currentClosestKeyword;
};
convert.keyword.rgb = function(keyword) {
return cssKeywords[keyword];
};
convert.rgb.xyz = function(rgb) {
var r40 = rgb[0] / 255;
var g61 = rgb[1] / 255;
var b64 = rgb[2] / 255;
r40 = r40 > 0.04045 ? Math.pow((r40 + 0.055) / 1.055, 2.4) : r40 / 12.92;
g61 = g61 > 0.04045 ? Math.pow((g61 + 0.055) / 1.055, 2.4) : g61 / 12.92;
b64 = b64 > 0.04045 ? Math.pow((b64 + 0.055) / 1.055, 2.4) : b64 / 12.92;
var x62 = r40 * 0.4124 + g61 * 0.3576 + b64 * 0.1805;
var y64 = r40 * 0.2126 + g61 * 0.7152 + b64 * 0.0722;
var z50 = r40 * 0.0193 + g61 * 0.1192 + b64 * 0.9505;
return [x62 * 100, y64 * 100, z50 * 100];
};
convert.rgb.lab = function(rgb) {
var xyz = convert.rgb.xyz(rgb);
var x62 = xyz[0];
var y64 = xyz[1];
var z50 =