10981 lines
369 KiB
JavaScript
Executable File
10981 lines
369 KiB
JavaScript
Executable File
#!/usr/bin/env node
|
||
var __create = Object.create;
|
||
var __defProp = Object.defineProperty;
|
||
var __defProps = Object.defineProperties;
|
||
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
||
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
||
var __getOwnPropNames = Object.getOwnPropertyNames;
|
||
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
||
var __getProtoOf = Object.getPrototypeOf;
|
||
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
||
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
||
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
||
var __spreadValues = (a, b) => {
|
||
for (var prop in b || (b = {}))
|
||
if (__hasOwnProp.call(b, prop))
|
||
__defNormalProp(a, prop, b[prop]);
|
||
if (__getOwnPropSymbols)
|
||
for (var prop of __getOwnPropSymbols(b)) {
|
||
if (__propIsEnum.call(b, prop))
|
||
__defNormalProp(a, prop, b[prop]);
|
||
}
|
||
return a;
|
||
};
|
||
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
||
var __markAsModule = (target) => __defProp(target, "__esModule", { value: true });
|
||
var __commonJS = (cb, mod) => function __require() {
|
||
return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
|
||
};
|
||
var __reExport = (target, module2, copyDefault, desc) => {
|
||
if (module2 && typeof module2 === "object" || typeof module2 === "function") {
|
||
for (let key of __getOwnPropNames(module2))
|
||
if (!__hasOwnProp.call(target, key) && (copyDefault || key !== "default"))
|
||
__defProp(target, key, { get: () => module2[key], enumerable: !(desc = __getOwnPropDesc(module2, key)) || desc.enumerable });
|
||
}
|
||
return target;
|
||
};
|
||
var __toESM = (module2, isNodeMode) => {
|
||
return __reExport(__markAsModule(__defProp(module2 != null ? __create(__getProtoOf(module2)) : {}, "default", !isNodeMode && module2 && module2.__esModule ? { get: () => module2.default, enumerable: true } : { value: module2, enumerable: true })), module2);
|
||
};
|
||
|
||
// node_modules/ms/index.js
|
||
var require_ms = __commonJS({
|
||
"node_modules/ms/index.js"(exports, module2) {
|
||
var s = 1e3;
|
||
var m = s * 60;
|
||
var h = m * 60;
|
||
var d = h * 24;
|
||
var w = d * 7;
|
||
var y = d * 365.25;
|
||
module2.exports = function(val, options) {
|
||
options = options || {};
|
||
var type = typeof val;
|
||
if (type === "string" && val.length > 0) {
|
||
return parse2(val);
|
||
} else if (type === "number" && isFinite(val)) {
|
||
return options.long ? fmtLong(val) : fmtShort(val);
|
||
}
|
||
throw new Error("val is not a non-empty string or a valid number. val=" + JSON.stringify(val));
|
||
};
|
||
function parse2(str) {
|
||
str = String(str);
|
||
if (str.length > 100) {
|
||
return;
|
||
}
|
||
var match = /^(-?(?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(str);
|
||
if (!match) {
|
||
return;
|
||
}
|
||
var n = parseFloat(match[1]);
|
||
var type = (match[2] || "ms").toLowerCase();
|
||
switch (type) {
|
||
case "years":
|
||
case "year":
|
||
case "yrs":
|
||
case "yr":
|
||
case "y":
|
||
return n * y;
|
||
case "weeks":
|
||
case "week":
|
||
case "w":
|
||
return n * w;
|
||
case "days":
|
||
case "day":
|
||
case "d":
|
||
return n * d;
|
||
case "hours":
|
||
case "hour":
|
||
case "hrs":
|
||
case "hr":
|
||
case "h":
|
||
return n * h;
|
||
case "minutes":
|
||
case "minute":
|
||
case "mins":
|
||
case "min":
|
||
case "m":
|
||
return n * m;
|
||
case "seconds":
|
||
case "second":
|
||
case "secs":
|
||
case "sec":
|
||
case "s":
|
||
return n * s;
|
||
case "milliseconds":
|
||
case "millisecond":
|
||
case "msecs":
|
||
case "msec":
|
||
case "ms":
|
||
return n;
|
||
default:
|
||
return void 0;
|
||
}
|
||
}
|
||
function fmtShort(ms) {
|
||
var msAbs = Math.abs(ms);
|
||
if (msAbs >= d) {
|
||
return Math.round(ms / d) + "d";
|
||
}
|
||
if (msAbs >= h) {
|
||
return Math.round(ms / h) + "h";
|
||
}
|
||
if (msAbs >= m) {
|
||
return Math.round(ms / m) + "m";
|
||
}
|
||
if (msAbs >= s) {
|
||
return Math.round(ms / s) + "s";
|
||
}
|
||
return ms + "ms";
|
||
}
|
||
function fmtLong(ms) {
|
||
var msAbs = Math.abs(ms);
|
||
if (msAbs >= d) {
|
||
return plural(ms, msAbs, d, "day");
|
||
}
|
||
if (msAbs >= h) {
|
||
return plural(ms, msAbs, h, "hour");
|
||
}
|
||
if (msAbs >= m) {
|
||
return plural(ms, msAbs, m, "minute");
|
||
}
|
||
if (msAbs >= s) {
|
||
return plural(ms, msAbs, s, "second");
|
||
}
|
||
return ms + " ms";
|
||
}
|
||
function plural(ms, msAbs, n, name) {
|
||
var isPlural = msAbs >= n * 1.5;
|
||
return Math.round(ms / n) + " " + name + (isPlural ? "s" : "");
|
||
}
|
||
}
|
||
});
|
||
|
||
// node_modules/debug/src/common.js
|
||
var require_common = __commonJS({
|
||
"node_modules/debug/src/common.js"(exports, module2) {
|
||
function setup(env2) {
|
||
createDebug.debug = createDebug;
|
||
createDebug.default = createDebug;
|
||
createDebug.coerce = coerce;
|
||
createDebug.disable = disable;
|
||
createDebug.enable = enable;
|
||
createDebug.enabled = enabled;
|
||
createDebug.humanize = require_ms();
|
||
createDebug.destroy = destroy;
|
||
Object.keys(env2).forEach((key) => {
|
||
createDebug[key] = env2[key];
|
||
});
|
||
createDebug.names = [];
|
||
createDebug.skips = [];
|
||
createDebug.formatters = {};
|
||
function selectColor(namespace) {
|
||
let hash = 0;
|
||
for (let i = 0; i < namespace.length; i++) {
|
||
hash = (hash << 5) - hash + namespace.charCodeAt(i);
|
||
hash |= 0;
|
||
}
|
||
return createDebug.colors[Math.abs(hash) % createDebug.colors.length];
|
||
}
|
||
createDebug.selectColor = selectColor;
|
||
function createDebug(namespace) {
|
||
let prevTime;
|
||
let enableOverride = null;
|
||
let namespacesCache;
|
||
let enabledCache;
|
||
function debug(...args) {
|
||
if (!debug.enabled) {
|
||
return;
|
||
}
|
||
const self = debug;
|
||
const curr = Number(new Date());
|
||
const ms = curr - (prevTime || curr);
|
||
self.diff = ms;
|
||
self.prev = prevTime;
|
||
self.curr = curr;
|
||
prevTime = curr;
|
||
args[0] = createDebug.coerce(args[0]);
|
||
if (typeof args[0] !== "string") {
|
||
args.unshift("%O");
|
||
}
|
||
let index = 0;
|
||
args[0] = args[0].replace(/%([a-zA-Z%])/g, (match, format3) => {
|
||
if (match === "%%") {
|
||
return "%";
|
||
}
|
||
index++;
|
||
const formatter = createDebug.formatters[format3];
|
||
if (typeof formatter === "function") {
|
||
const val = args[index];
|
||
match = formatter.call(self, val);
|
||
args.splice(index, 1);
|
||
index--;
|
||
}
|
||
return match;
|
||
});
|
||
createDebug.formatArgs.call(self, args);
|
||
const logFn = self.log || createDebug.log;
|
||
logFn.apply(self, args);
|
||
}
|
||
debug.namespace = namespace;
|
||
debug.useColors = createDebug.useColors();
|
||
debug.color = createDebug.selectColor(namespace);
|
||
debug.extend = extend;
|
||
debug.destroy = createDebug.destroy;
|
||
Object.defineProperty(debug, "enabled", {
|
||
enumerable: true,
|
||
configurable: false,
|
||
get: () => {
|
||
if (enableOverride !== null) {
|
||
return enableOverride;
|
||
}
|
||
if (namespacesCache !== createDebug.namespaces) {
|
||
namespacesCache = createDebug.namespaces;
|
||
enabledCache = createDebug.enabled(namespace);
|
||
}
|
||
return enabledCache;
|
||
},
|
||
set: (v) => {
|
||
enableOverride = v;
|
||
}
|
||
});
|
||
if (typeof createDebug.init === "function") {
|
||
createDebug.init(debug);
|
||
}
|
||
return debug;
|
||
}
|
||
function extend(namespace, delimiter) {
|
||
const newDebug = createDebug(this.namespace + (typeof delimiter === "undefined" ? ":" : delimiter) + namespace);
|
||
newDebug.log = this.log;
|
||
return newDebug;
|
||
}
|
||
function enable(namespaces) {
|
||
createDebug.save(namespaces);
|
||
createDebug.namespaces = namespaces;
|
||
createDebug.names = [];
|
||
createDebug.skips = [];
|
||
let i;
|
||
const split = (typeof namespaces === "string" ? namespaces : "").split(/[\s,]+/);
|
||
const len = split.length;
|
||
for (i = 0; i < len; i++) {
|
||
if (!split[i]) {
|
||
continue;
|
||
}
|
||
namespaces = split[i].replace(/\*/g, ".*?");
|
||
if (namespaces[0] === "-") {
|
||
createDebug.skips.push(new RegExp("^" + namespaces.substr(1) + "$"));
|
||
} else {
|
||
createDebug.names.push(new RegExp("^" + namespaces + "$"));
|
||
}
|
||
}
|
||
}
|
||
function disable() {
|
||
const namespaces = [
|
||
...createDebug.names.map(toNamespace),
|
||
...createDebug.skips.map(toNamespace).map((namespace) => "-" + namespace)
|
||
].join(",");
|
||
createDebug.enable("");
|
||
return namespaces;
|
||
}
|
||
function enabled(name) {
|
||
if (name[name.length - 1] === "*") {
|
||
return true;
|
||
}
|
||
let i;
|
||
let len;
|
||
for (i = 0, len = createDebug.skips.length; i < len; i++) {
|
||
if (createDebug.skips[i].test(name)) {
|
||
return false;
|
||
}
|
||
}
|
||
for (i = 0, len = createDebug.names.length; i < len; i++) {
|
||
if (createDebug.names[i].test(name)) {
|
||
return true;
|
||
}
|
||
}
|
||
return false;
|
||
}
|
||
function toNamespace(regexp) {
|
||
return regexp.toString().substring(2, regexp.toString().length - 2).replace(/\.\*\?$/, "*");
|
||
}
|
||
function coerce(val) {
|
||
if (val instanceof Error) {
|
||
return val.stack || val.message;
|
||
}
|
||
return val;
|
||
}
|
||
function destroy() {
|
||
console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.");
|
||
}
|
||
createDebug.enable(createDebug.load());
|
||
return createDebug;
|
||
}
|
||
module2.exports = setup;
|
||
}
|
||
});
|
||
|
||
// node_modules/debug/src/browser.js
|
||
var require_browser = __commonJS({
|
||
"node_modules/debug/src/browser.js"(exports, module2) {
|
||
exports.formatArgs = formatArgs;
|
||
exports.save = save;
|
||
exports.load = load;
|
||
exports.useColors = useColors;
|
||
exports.storage = localstorage();
|
||
exports.destroy = (() => {
|
||
let warned = false;
|
||
return () => {
|
||
if (!warned) {
|
||
warned = true;
|
||
console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.");
|
||
}
|
||
};
|
||
})();
|
||
exports.colors = [
|
||
"#0000CC",
|
||
"#0000FF",
|
||
"#0033CC",
|
||
"#0033FF",
|
||
"#0066CC",
|
||
"#0066FF",
|
||
"#0099CC",
|
||
"#0099FF",
|
||
"#00CC00",
|
||
"#00CC33",
|
||
"#00CC66",
|
||
"#00CC99",
|
||
"#00CCCC",
|
||
"#00CCFF",
|
||
"#3300CC",
|
||
"#3300FF",
|
||
"#3333CC",
|
||
"#3333FF",
|
||
"#3366CC",
|
||
"#3366FF",
|
||
"#3399CC",
|
||
"#3399FF",
|
||
"#33CC00",
|
||
"#33CC33",
|
||
"#33CC66",
|
||
"#33CC99",
|
||
"#33CCCC",
|
||
"#33CCFF",
|
||
"#6600CC",
|
||
"#6600FF",
|
||
"#6633CC",
|
||
"#6633FF",
|
||
"#66CC00",
|
||
"#66CC33",
|
||
"#9900CC",
|
||
"#9900FF",
|
||
"#9933CC",
|
||
"#9933FF",
|
||
"#99CC00",
|
||
"#99CC33",
|
||
"#CC0000",
|
||
"#CC0033",
|
||
"#CC0066",
|
||
"#CC0099",
|
||
"#CC00CC",
|
||
"#CC00FF",
|
||
"#CC3300",
|
||
"#CC3333",
|
||
"#CC3366",
|
||
"#CC3399",
|
||
"#CC33CC",
|
||
"#CC33FF",
|
||
"#CC6600",
|
||
"#CC6633",
|
||
"#CC9900",
|
||
"#CC9933",
|
||
"#CCCC00",
|
||
"#CCCC33",
|
||
"#FF0000",
|
||
"#FF0033",
|
||
"#FF0066",
|
||
"#FF0099",
|
||
"#FF00CC",
|
||
"#FF00FF",
|
||
"#FF3300",
|
||
"#FF3333",
|
||
"#FF3366",
|
||
"#FF3399",
|
||
"#FF33CC",
|
||
"#FF33FF",
|
||
"#FF6600",
|
||
"#FF6633",
|
||
"#FF9900",
|
||
"#FF9933",
|
||
"#FFCC00",
|
||
"#FFCC33"
|
||
];
|
||
function useColors() {
|
||
if (typeof window !== "undefined" && window.process && (window.process.type === "renderer" || window.process.__nwjs)) {
|
||
return true;
|
||
}
|
||
if (typeof navigator !== "undefined" && navigator.userAgent && navigator.userAgent.toLowerCase().match(/(edge|trident)\/(\d+)/)) {
|
||
return false;
|
||
}
|
||
return typeof document !== "undefined" && document.documentElement && document.documentElement.style && document.documentElement.style.WebkitAppearance || typeof window !== "undefined" && window.console && (window.console.firebug || window.console.exception && window.console.table) || typeof navigator !== "undefined" && navigator.userAgent && navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/) && parseInt(RegExp.$1, 10) >= 31 || typeof navigator !== "undefined" && navigator.userAgent && navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/);
|
||
}
|
||
function formatArgs(args) {
|
||
args[0] = (this.useColors ? "%c" : "") + this.namespace + (this.useColors ? " %c" : " ") + args[0] + (this.useColors ? "%c " : " ") + "+" + module2.exports.humanize(this.diff);
|
||
if (!this.useColors) {
|
||
return;
|
||
}
|
||
const c = "color: " + this.color;
|
||
args.splice(1, 0, c, "color: inherit");
|
||
let index = 0;
|
||
let lastC = 0;
|
||
args[0].replace(/%[a-zA-Z%]/g, (match) => {
|
||
if (match === "%%") {
|
||
return;
|
||
}
|
||
index++;
|
||
if (match === "%c") {
|
||
lastC = index;
|
||
}
|
||
});
|
||
args.splice(lastC, 0, c);
|
||
}
|
||
exports.log = console.debug || console.log || (() => {
|
||
});
|
||
function save(namespaces) {
|
||
try {
|
||
if (namespaces) {
|
||
exports.storage.setItem("debug", namespaces);
|
||
} else {
|
||
exports.storage.removeItem("debug");
|
||
}
|
||
} catch (error) {
|
||
}
|
||
}
|
||
function load() {
|
||
let r;
|
||
try {
|
||
r = exports.storage.getItem("debug");
|
||
} catch (error) {
|
||
}
|
||
if (!r && typeof process !== "undefined" && "env" in process) {
|
||
r = process.env.DEBUG;
|
||
}
|
||
return r;
|
||
}
|
||
function localstorage() {
|
||
try {
|
||
return localStorage;
|
||
} catch (error) {
|
||
}
|
||
}
|
||
module2.exports = require_common()(exports);
|
||
var { formatters } = module2.exports;
|
||
formatters.j = function(v) {
|
||
try {
|
||
return JSON.stringify(v);
|
||
} catch (error) {
|
||
return "[UnexpectedJSONParseError]: " + error.message;
|
||
}
|
||
};
|
||
}
|
||
});
|
||
|
||
// node_modules/has-flag/index.js
|
||
var require_has_flag = __commonJS({
|
||
"node_modules/has-flag/index.js"(exports, module2) {
|
||
"use strict";
|
||
module2.exports = (flag, argv = process.argv) => {
|
||
const prefix = flag.startsWith("-") ? "" : flag.length === 1 ? "-" : "--";
|
||
const position = argv.indexOf(prefix + flag);
|
||
const terminatorPosition = argv.indexOf("--");
|
||
return position !== -1 && (terminatorPosition === -1 || position < terminatorPosition);
|
||
};
|
||
}
|
||
});
|
||
|
||
// node_modules/supports-color/index.js
|
||
var require_supports_color = __commonJS({
|
||
"node_modules/supports-color/index.js"(exports, module2) {
|
||
"use strict";
|
||
var os = require("os");
|
||
var tty = require("tty");
|
||
var hasFlag = require_has_flag();
|
||
var { env: env2 } = process;
|
||
var forceColor;
|
||
if (hasFlag("no-color") || hasFlag("no-colors") || hasFlag("color=false") || hasFlag("color=never")) {
|
||
forceColor = 0;
|
||
} else if (hasFlag("color") || hasFlag("colors") || hasFlag("color=true") || hasFlag("color=always")) {
|
||
forceColor = 1;
|
||
}
|
||
if ("FORCE_COLOR" in env2) {
|
||
if (env2.FORCE_COLOR === "true") {
|
||
forceColor = 1;
|
||
} else if (env2.FORCE_COLOR === "false") {
|
||
forceColor = 0;
|
||
} else {
|
||
forceColor = env2.FORCE_COLOR.length === 0 ? 1 : Math.min(parseInt(env2.FORCE_COLOR, 10), 3);
|
||
}
|
||
}
|
||
function translateLevel(level) {
|
||
if (level === 0) {
|
||
return false;
|
||
}
|
||
return {
|
||
level,
|
||
hasBasic: true,
|
||
has256: level >= 2,
|
||
has16m: level >= 3
|
||
};
|
||
}
|
||
function supportsColor(haveStream, streamIsTTY) {
|
||
if (forceColor === 0) {
|
||
return 0;
|
||
}
|
||
if (hasFlag("color=16m") || hasFlag("color=full") || hasFlag("color=truecolor")) {
|
||
return 3;
|
||
}
|
||
if (hasFlag("color=256")) {
|
||
return 2;
|
||
}
|
||
if (haveStream && !streamIsTTY && forceColor === void 0) {
|
||
return 0;
|
||
}
|
||
const min = forceColor || 0;
|
||
if (env2.TERM === "dumb") {
|
||
return min;
|
||
}
|
||
if (process.platform === "win32") {
|
||
const osRelease = os.release().split(".");
|
||
if (Number(osRelease[0]) >= 10 && Number(osRelease[2]) >= 10586) {
|
||
return Number(osRelease[2]) >= 14931 ? 3 : 2;
|
||
}
|
||
return 1;
|
||
}
|
||
if ("CI" in env2) {
|
||
if (["TRAVIS", "CIRCLECI", "APPVEYOR", "GITLAB_CI", "GITHUB_ACTIONS", "BUILDKITE"].some((sign) => sign in env2) || env2.CI_NAME === "codeship") {
|
||
return 1;
|
||
}
|
||
return min;
|
||
}
|
||
if ("TEAMCITY_VERSION" in env2) {
|
||
return /^(9\.(0*[1-9]\d*)\.|\d{2,}\.)/.test(env2.TEAMCITY_VERSION) ? 1 : 0;
|
||
}
|
||
if (env2.COLORTERM === "truecolor") {
|
||
return 3;
|
||
}
|
||
if ("TERM_PROGRAM" in env2) {
|
||
const version = parseInt((env2.TERM_PROGRAM_VERSION || "").split(".")[0], 10);
|
||
switch (env2.TERM_PROGRAM) {
|
||
case "iTerm.app":
|
||
return version >= 3 ? 3 : 2;
|
||
case "Apple_Terminal":
|
||
return 2;
|
||
}
|
||
}
|
||
if (/-256(color)?$/i.test(env2.TERM)) {
|
||
return 2;
|
||
}
|
||
if (/^screen|^xterm|^vt100|^vt220|^rxvt|color|ansi|cygwin|linux/i.test(env2.TERM)) {
|
||
return 1;
|
||
}
|
||
if ("COLORTERM" in env2) {
|
||
return 1;
|
||
}
|
||
return min;
|
||
}
|
||
function getSupportLevel(stream) {
|
||
const level = supportsColor(stream, stream && stream.isTTY);
|
||
return translateLevel(level);
|
||
}
|
||
module2.exports = {
|
||
supportsColor: getSupportLevel,
|
||
stdout: translateLevel(supportsColor(true, tty.isatty(1))),
|
||
stderr: translateLevel(supportsColor(true, tty.isatty(2)))
|
||
};
|
||
}
|
||
});
|
||
|
||
// node_modules/debug/src/node.js
|
||
var require_node = __commonJS({
|
||
"node_modules/debug/src/node.js"(exports, module2) {
|
||
var tty = require("tty");
|
||
var util = require("util");
|
||
exports.init = init;
|
||
exports.log = log4;
|
||
exports.formatArgs = formatArgs;
|
||
exports.save = save;
|
||
exports.load = load;
|
||
exports.useColors = useColors;
|
||
exports.destroy = util.deprecate(() => {
|
||
}, "Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.");
|
||
exports.colors = [6, 2, 3, 4, 5, 1];
|
||
try {
|
||
const supportsColor = require_supports_color();
|
||
if (supportsColor && (supportsColor.stderr || supportsColor).level >= 2) {
|
||
exports.colors = [
|
||
20,
|
||
21,
|
||
26,
|
||
27,
|
||
32,
|
||
33,
|
||
38,
|
||
39,
|
||
40,
|
||
41,
|
||
42,
|
||
43,
|
||
44,
|
||
45,
|
||
56,
|
||
57,
|
||
62,
|
||
63,
|
||
68,
|
||
69,
|
||
74,
|
||
75,
|
||
76,
|
||
77,
|
||
78,
|
||
79,
|
||
80,
|
||
81,
|
||
92,
|
||
93,
|
||
98,
|
||
99,
|
||
112,
|
||
113,
|
||
128,
|
||
129,
|
||
134,
|
||
135,
|
||
148,
|
||
149,
|
||
160,
|
||
161,
|
||
162,
|
||
163,
|
||
164,
|
||
165,
|
||
166,
|
||
167,
|
||
168,
|
||
169,
|
||
170,
|
||
171,
|
||
172,
|
||
173,
|
||
178,
|
||
179,
|
||
184,
|
||
185,
|
||
196,
|
||
197,
|
||
198,
|
||
199,
|
||
200,
|
||
201,
|
||
202,
|
||
203,
|
||
204,
|
||
205,
|
||
206,
|
||
207,
|
||
208,
|
||
209,
|
||
214,
|
||
215,
|
||
220,
|
||
221
|
||
];
|
||
}
|
||
} catch (error) {
|
||
}
|
||
exports.inspectOpts = Object.keys(process.env).filter((key) => {
|
||
return /^debug_/i.test(key);
|
||
}).reduce((obj, key) => {
|
||
const prop = key.substring(6).toLowerCase().replace(/_([a-z])/g, (_, k) => {
|
||
return k.toUpperCase();
|
||
});
|
||
let val = process.env[key];
|
||
if (/^(yes|on|true|enabled)$/i.test(val)) {
|
||
val = true;
|
||
} else if (/^(no|off|false|disabled)$/i.test(val)) {
|
||
val = false;
|
||
} else if (val === "null") {
|
||
val = null;
|
||
} else {
|
||
val = Number(val);
|
||
}
|
||
obj[prop] = val;
|
||
return obj;
|
||
}, {});
|
||
function useColors() {
|
||
return "colors" in exports.inspectOpts ? Boolean(exports.inspectOpts.colors) : tty.isatty(process.stderr.fd);
|
||
}
|
||
function formatArgs(args) {
|
||
const { namespace: name, useColors: useColors2 } = this;
|
||
if (useColors2) {
|
||
const c = this.color;
|
||
const colorCode = "[3" + (c < 8 ? c : "8;5;" + c);
|
||
const prefix = ` ${colorCode};1m${name} [0m`;
|
||
args[0] = prefix + args[0].split("\n").join("\n" + prefix);
|
||
args.push(colorCode + "m+" + module2.exports.humanize(this.diff) + "[0m");
|
||
} else {
|
||
args[0] = getDate() + name + " " + args[0];
|
||
}
|
||
}
|
||
function getDate() {
|
||
if (exports.inspectOpts.hideDate) {
|
||
return "";
|
||
}
|
||
return new Date().toISOString() + " ";
|
||
}
|
||
function log4(...args) {
|
||
return process.stderr.write(util.format(...args) + "\n");
|
||
}
|
||
function save(namespaces) {
|
||
if (namespaces) {
|
||
process.env.DEBUG = namespaces;
|
||
} else {
|
||
delete process.env.DEBUG;
|
||
}
|
||
}
|
||
function load() {
|
||
return process.env.DEBUG;
|
||
}
|
||
function init(debug) {
|
||
debug.inspectOpts = {};
|
||
const keys = Object.keys(exports.inspectOpts);
|
||
for (let i = 0; i < keys.length; i++) {
|
||
debug.inspectOpts[keys[i]] = exports.inspectOpts[keys[i]];
|
||
}
|
||
}
|
||
module2.exports = require_common()(exports);
|
||
var { formatters } = module2.exports;
|
||
formatters.o = function(v) {
|
||
this.inspectOpts.colors = this.useColors;
|
||
return util.inspect(v, this.inspectOpts).split("\n").map((str) => str.trim()).join(" ");
|
||
};
|
||
formatters.O = function(v) {
|
||
this.inspectOpts.colors = this.useColors;
|
||
return util.inspect(v, this.inspectOpts);
|
||
};
|
||
}
|
||
});
|
||
|
||
// node_modules/debug/src/index.js
|
||
var require_src = __commonJS({
|
||
"node_modules/debug/src/index.js"(exports, module2) {
|
||
if (typeof process === "undefined" || process.type === "renderer" || process.browser === true || process.__nwjs) {
|
||
module2.exports = require_browser();
|
||
} else {
|
||
module2.exports = require_node();
|
||
}
|
||
}
|
||
});
|
||
|
||
// node_modules/color-name/index.js
|
||
var require_color_name = __commonJS({
|
||
"node_modules/color-name/index.js"(exports, 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/color-convert/conversions.js
|
||
var require_conversions = __commonJS({
|
||
"node_modules/color-convert/conversions.js"(exports, module2) {
|
||
var cssKeywords = require_color_name();
|
||
var reverseKeywords = {};
|
||
for (const key of Object.keys(cssKeywords)) {
|
||
reverseKeywords[cssKeywords[key]] = key;
|
||
}
|
||
var convert = {
|
||
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"] }
|
||
};
|
||
module2.exports = convert;
|
||
for (const model of Object.keys(convert)) {
|
||
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);
|
||
}
|
||
const { channels, labels } = convert[model];
|
||
delete convert[model].channels;
|
||
delete convert[model].labels;
|
||
Object.defineProperty(convert[model], "channels", { value: channels });
|
||
Object.defineProperty(convert[model], "labels", { value: labels });
|
||
}
|
||
convert.rgb.hsl = function(rgb) {
|
||
const r = rgb[0] / 255;
|
||
const g = rgb[1] / 255;
|
||
const b = rgb[2] / 255;
|
||
const min = Math.min(r, g, b);
|
||
const max = Math.max(r, g, b);
|
||
const delta = max - min;
|
||
let h;
|
||
let s;
|
||
if (max === min) {
|
||
h = 0;
|
||
} else if (r === max) {
|
||
h = (g - b) / delta;
|
||
} else if (g === max) {
|
||
h = 2 + (b - r) / delta;
|
||
} else if (b === max) {
|
||
h = 4 + (r - g) / delta;
|
||
}
|
||
h = Math.min(h * 60, 360);
|
||
if (h < 0) {
|
||
h += 360;
|
||
}
|
||
const l = (min + max) / 2;
|
||
if (max === min) {
|
||
s = 0;
|
||
} else if (l <= 0.5) {
|
||
s = delta / (max + min);
|
||
} else {
|
||
s = delta / (2 - max - min);
|
||
}
|
||
return [h, s * 100, l * 100];
|
||
};
|
||
convert.rgb.hsv = function(rgb) {
|
||
let rdif;
|
||
let gdif;
|
||
let bdif;
|
||
let h;
|
||
let s;
|
||
const r = rgb[0] / 255;
|
||
const g = rgb[1] / 255;
|
||
const b = rgb[2] / 255;
|
||
const v = Math.max(r, g, b);
|
||
const diff = v - Math.min(r, g, b);
|
||
const diffc = function(c) {
|
||
return (v - c) / 6 / diff + 1 / 2;
|
||
};
|
||
if (diff === 0) {
|
||
h = 0;
|
||
s = 0;
|
||
} else {
|
||
s = diff / v;
|
||
rdif = diffc(r);
|
||
gdif = diffc(g);
|
||
bdif = diffc(b);
|
||
if (r === v) {
|
||
h = bdif - gdif;
|
||
} else if (g === v) {
|
||
h = 1 / 3 + rdif - bdif;
|
||
} else if (b === v) {
|
||
h = 2 / 3 + gdif - rdif;
|
||
}
|
||
if (h < 0) {
|
||
h += 1;
|
||
} else if (h > 1) {
|
||
h -= 1;
|
||
}
|
||
}
|
||
return [
|
||
h * 360,
|
||
s * 100,
|
||
v * 100
|
||
];
|
||
};
|
||
convert.rgb.hwb = function(rgb) {
|
||
const r = rgb[0];
|
||
const g = rgb[1];
|
||
let b = rgb[2];
|
||
const h = convert.rgb.hsl(rgb)[0];
|
||
const w = 1 / 255 * Math.min(r, Math.min(g, b));
|
||
b = 1 - 1 / 255 * Math.max(r, Math.max(g, b));
|
||
return [h, w * 100, b * 100];
|
||
};
|
||
convert.rgb.cmyk = function(rgb) {
|
||
const r = rgb[0] / 255;
|
||
const g = rgb[1] / 255;
|
||
const b = rgb[2] / 255;
|
||
const k = Math.min(1 - r, 1 - g, 1 - b);
|
||
const c = (1 - r - k) / (1 - k) || 0;
|
||
const m = (1 - g - k) / (1 - k) || 0;
|
||
const y = (1 - b - k) / (1 - k) || 0;
|
||
return [c * 100, m * 100, y * 100, k * 100];
|
||
};
|
||
function comparativeDistance(x, y) {
|
||
return (x[0] - y[0]) ** 2 + (x[1] - y[1]) ** 2 + (x[2] - y[2]) ** 2;
|
||
}
|
||
convert.rgb.keyword = function(rgb) {
|
||
const reversed = reverseKeywords[rgb];
|
||
if (reversed) {
|
||
return reversed;
|
||
}
|
||
let currentClosestDistance = Infinity;
|
||
let currentClosestKeyword;
|
||
for (const keyword of Object.keys(cssKeywords)) {
|
||
const value = cssKeywords[keyword];
|
||
const 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) {
|
||
let r = rgb[0] / 255;
|
||
let g = rgb[1] / 255;
|
||
let b = rgb[2] / 255;
|
||
r = r > 0.04045 ? ((r + 0.055) / 1.055) ** 2.4 : r / 12.92;
|
||
g = g > 0.04045 ? ((g + 0.055) / 1.055) ** 2.4 : g / 12.92;
|
||
b = b > 0.04045 ? ((b + 0.055) / 1.055) ** 2.4 : b / 12.92;
|
||
const x = r * 0.4124 + g * 0.3576 + b * 0.1805;
|
||
const y = r * 0.2126 + g * 0.7152 + b * 0.0722;
|
||
const z = r * 0.0193 + g * 0.1192 + b * 0.9505;
|
||
return [x * 100, y * 100, z * 100];
|
||
};
|
||
convert.rgb.lab = function(rgb) {
|
||
const xyz = convert.rgb.xyz(rgb);
|
||
let x = xyz[0];
|
||
let y = xyz[1];
|
||
let z = xyz[2];
|
||
x /= 95.047;
|
||
y /= 100;
|
||
z /= 108.883;
|
||
x = x > 8856e-6 ? x ** (1 / 3) : 7.787 * x + 16 / 116;
|
||
y = y > 8856e-6 ? y ** (1 / 3) : 7.787 * y + 16 / 116;
|
||
z = z > 8856e-6 ? z ** (1 / 3) : 7.787 * z + 16 / 116;
|
||
const l = 116 * y - 16;
|
||
const a = 500 * (x - y);
|
||
const b = 200 * (y - z);
|
||
return [l, a, b];
|
||
};
|
||
convert.hsl.rgb = function(hsl) {
|
||
const h = hsl[0] / 360;
|
||
const s = hsl[1] / 100;
|
||
const l = hsl[2] / 100;
|
||
let t2;
|
||
let t3;
|
||
let val;
|
||
if (s === 0) {
|
||
val = l * 255;
|
||
return [val, val, val];
|
||
}
|
||
if (l < 0.5) {
|
||
t2 = l * (1 + s);
|
||
} else {
|
||
t2 = l + s - l * s;
|
||
}
|
||
const t1 = 2 * l - t2;
|
||
const rgb = [0, 0, 0];
|
||
for (let i = 0; i < 3; i++) {
|
||
t3 = h + 1 / 3 * -(i - 1);
|
||
if (t3 < 0) {
|
||
t3++;
|
||
}
|
||
if (t3 > 1) {
|
||
t3--;
|
||
}
|
||
if (6 * t3 < 1) {
|
||
val = t1 + (t2 - t1) * 6 * t3;
|
||
} else if (2 * t3 < 1) {
|
||
val = t2;
|
||
} else if (3 * t3 < 2) {
|
||
val = t1 + (t2 - t1) * (2 / 3 - t3) * 6;
|
||
} else {
|
||
val = t1;
|
||
}
|
||
rgb[i] = val * 255;
|
||
}
|
||
return rgb;
|
||
};
|
||
convert.hsl.hsv = function(hsl) {
|
||
const h = hsl[0];
|
||
let s = hsl[1] / 100;
|
||
let l = hsl[2] / 100;
|
||
let smin = s;
|
||
const lmin = Math.max(l, 0.01);
|
||
l *= 2;
|
||
s *= l <= 1 ? l : 2 - l;
|
||
smin *= lmin <= 1 ? lmin : 2 - lmin;
|
||
const v = (l + s) / 2;
|
||
const sv = l === 0 ? 2 * smin / (lmin + smin) : 2 * s / (l + s);
|
||
return [h, sv * 100, v * 100];
|
||
};
|
||
convert.hsv.rgb = function(hsv) {
|
||
const h = hsv[0] / 60;
|
||
const s = hsv[1] / 100;
|
||
let v = hsv[2] / 100;
|
||
const hi = Math.floor(h) % 6;
|
||
const f = h - Math.floor(h);
|
||
const p = 255 * v * (1 - s);
|
||
const q = 255 * v * (1 - s * f);
|
||
const t = 255 * v * (1 - s * (1 - f));
|
||
v *= 255;
|
||
switch (hi) {
|
||
case 0:
|
||
return [v, t, p];
|
||
case 1:
|
||
return [q, v, p];
|
||
case 2:
|
||
return [p, v, t];
|
||
case 3:
|
||
return [p, q, v];
|
||
case 4:
|
||
return [t, p, v];
|
||
case 5:
|
||
return [v, p, q];
|
||
}
|
||
};
|
||
convert.hsv.hsl = function(hsv) {
|
||
const h = hsv[0];
|
||
const s = hsv[1] / 100;
|
||
const v = hsv[2] / 100;
|
||
const vmin = Math.max(v, 0.01);
|
||
let sl;
|
||
let l;
|
||
l = (2 - s) * v;
|
||
const lmin = (2 - s) * vmin;
|
||
sl = s * vmin;
|
||
sl /= lmin <= 1 ? lmin : 2 - lmin;
|
||
sl = sl || 0;
|
||
l /= 2;
|
||
return [h, sl * 100, l * 100];
|
||
};
|
||
convert.hwb.rgb = function(hwb) {
|
||
const h = hwb[0] / 360;
|
||
let wh = hwb[1] / 100;
|
||
let bl = hwb[2] / 100;
|
||
const ratio = wh + bl;
|
||
let f;
|
||
if (ratio > 1) {
|
||
wh /= ratio;
|
||
bl /= ratio;
|
||
}
|
||
const i = Math.floor(6 * h);
|
||
const v = 1 - bl;
|
||
f = 6 * h - i;
|
||
if ((i & 1) !== 0) {
|
||
f = 1 - f;
|
||
}
|
||
const n = wh + f * (v - wh);
|
||
let r;
|
||
let g;
|
||
let b;
|
||
switch (i) {
|
||
default:
|
||
case 6:
|
||
case 0:
|
||
r = v;
|
||
g = n;
|
||
b = wh;
|
||
break;
|
||
case 1:
|
||
r = n;
|
||
g = v;
|
||
b = wh;
|
||
break;
|
||
case 2:
|
||
r = wh;
|
||
g = v;
|
||
b = n;
|
||
break;
|
||
case 3:
|
||
r = wh;
|
||
g = n;
|
||
b = v;
|
||
break;
|
||
case 4:
|
||
r = n;
|
||
g = wh;
|
||
b = v;
|
||
break;
|
||
case 5:
|
||
r = v;
|
||
g = wh;
|
||
b = n;
|
||
break;
|
||
}
|
||
return [r * 255, g * 255, b * 255];
|
||
};
|
||
convert.cmyk.rgb = function(cmyk) {
|
||
const c = cmyk[0] / 100;
|
||
const m = cmyk[1] / 100;
|
||
const y = cmyk[2] / 100;
|
||
const k = cmyk[3] / 100;
|
||
const r = 1 - Math.min(1, c * (1 - k) + k);
|
||
const g = 1 - Math.min(1, m * (1 - k) + k);
|
||
const b = 1 - Math.min(1, y * (1 - k) + k);
|
||
return [r * 255, g * 255, b * 255];
|
||
};
|
||
convert.xyz.rgb = function(xyz) {
|
||
const x = xyz[0] / 100;
|
||
const y = xyz[1] / 100;
|
||
const z = xyz[2] / 100;
|
||
let r;
|
||
let g;
|
||
let b;
|
||
r = x * 3.2406 + y * -1.5372 + z * -0.4986;
|
||
g = x * -0.9689 + y * 1.8758 + z * 0.0415;
|
||
b = x * 0.0557 + y * -0.204 + z * 1.057;
|
||
r = r > 31308e-7 ? 1.055 * r ** (1 / 2.4) - 0.055 : r * 12.92;
|
||
g = g > 31308e-7 ? 1.055 * g ** (1 / 2.4) - 0.055 : g * 12.92;
|
||
b = b > 31308e-7 ? 1.055 * b ** (1 / 2.4) - 0.055 : b * 12.92;
|
||
r = Math.min(Math.max(0, r), 1);
|
||
g = Math.min(Math.max(0, g), 1);
|
||
b = Math.min(Math.max(0, b), 1);
|
||
return [r * 255, g * 255, b * 255];
|
||
};
|
||
convert.xyz.lab = function(xyz) {
|
||
let x = xyz[0];
|
||
let y = xyz[1];
|
||
let z = xyz[2];
|
||
x /= 95.047;
|
||
y /= 100;
|
||
z /= 108.883;
|
||
x = x > 8856e-6 ? x ** (1 / 3) : 7.787 * x + 16 / 116;
|
||
y = y > 8856e-6 ? y ** (1 / 3) : 7.787 * y + 16 / 116;
|
||
z = z > 8856e-6 ? z ** (1 / 3) : 7.787 * z + 16 / 116;
|
||
const l = 116 * y - 16;
|
||
const a = 500 * (x - y);
|
||
const b = 200 * (y - z);
|
||
return [l, a, b];
|
||
};
|
||
convert.lab.xyz = function(lab) {
|
||
const l = lab[0];
|
||
const a = lab[1];
|
||
const b = lab[2];
|
||
let x;
|
||
let y;
|
||
let z;
|
||
y = (l + 16) / 116;
|
||
x = a / 500 + y;
|
||
z = y - b / 200;
|
||
const y2 = y ** 3;
|
||
const x2 = x ** 3;
|
||
const z2 = z ** 3;
|
||
y = y2 > 8856e-6 ? y2 : (y - 16 / 116) / 7.787;
|
||
x = x2 > 8856e-6 ? x2 : (x - 16 / 116) / 7.787;
|
||
z = z2 > 8856e-6 ? z2 : (z - 16 / 116) / 7.787;
|
||
x *= 95.047;
|
||
y *= 100;
|
||
z *= 108.883;
|
||
return [x, y, z];
|
||
};
|
||
convert.lab.lch = function(lab) {
|
||
const l = lab[0];
|
||
const a = lab[1];
|
||
const b = lab[2];
|
||
let h;
|
||
const hr = Math.atan2(b, a);
|
||
h = hr * 360 / 2 / Math.PI;
|
||
if (h < 0) {
|
||
h += 360;
|
||
}
|
||
const c = Math.sqrt(a * a + b * b);
|
||
return [l, c, h];
|
||
};
|
||
convert.lch.lab = function(lch) {
|
||
const l = lch[0];
|
||
const c = lch[1];
|
||
const h = lch[2];
|
||
const hr = h / 360 * 2 * Math.PI;
|
||
const a = c * Math.cos(hr);
|
||
const b = c * Math.sin(hr);
|
||
return [l, a, b];
|
||
};
|
||
convert.rgb.ansi16 = function(args, saturation = null) {
|
||
const [r, g, b] = args;
|
||
let value = saturation === null ? convert.rgb.hsv(args)[2] : saturation;
|
||
value = Math.round(value / 50);
|
||
if (value === 0) {
|
||
return 30;
|
||
}
|
||
let ansi2 = 30 + (Math.round(b / 255) << 2 | Math.round(g / 255) << 1 | Math.round(r / 255));
|
||
if (value === 2) {
|
||
ansi2 += 60;
|
||
}
|
||
return ansi2;
|
||
};
|
||
convert.hsv.ansi16 = function(args) {
|
||
return convert.rgb.ansi16(convert.hsv.rgb(args), args[2]);
|
||
};
|
||
convert.rgb.ansi256 = function(args) {
|
||
const r = args[0];
|
||
const g = args[1];
|
||
const b = args[2];
|
||
if (r === g && g === b) {
|
||
if (r < 8) {
|
||
return 16;
|
||
}
|
||
if (r > 248) {
|
||
return 231;
|
||
}
|
||
return Math.round((r - 8) / 247 * 24) + 232;
|
||
}
|
||
const ansi2 = 16 + 36 * Math.round(r / 255 * 5) + 6 * Math.round(g / 255 * 5) + Math.round(b / 255 * 5);
|
||
return ansi2;
|
||
};
|
||
convert.ansi16.rgb = function(args) {
|
||
let color = args % 10;
|
||
if (color === 0 || color === 7) {
|
||
if (args > 50) {
|
||
color += 3.5;
|
||
}
|
||
color = color / 10.5 * 255;
|
||
return [color, color, color];
|
||
}
|
||
const mult = (~~(args > 50) + 1) * 0.5;
|
||
const r = (color & 1) * mult * 255;
|
||
const g = (color >> 1 & 1) * mult * 255;
|
||
const b = (color >> 2 & 1) * mult * 255;
|
||
return [r, g, b];
|
||
};
|
||
convert.ansi256.rgb = function(args) {
|
||
if (args >= 232) {
|
||
const c = (args - 232) * 10 + 8;
|
||
return [c, c, c];
|
||
}
|
||
args -= 16;
|
||
let rem;
|
||
const r = Math.floor(args / 36) / 5 * 255;
|
||
const g = Math.floor((rem = args % 36) / 6) / 5 * 255;
|
||
const b = rem % 6 / 5 * 255;
|
||
return [r, g, b];
|
||
};
|
||
convert.rgb.hex = function(args) {
|
||
const integer = ((Math.round(args[0]) & 255) << 16) + ((Math.round(args[1]) & 255) << 8) + (Math.round(args[2]) & 255);
|
||
const string = integer.toString(16).toUpperCase();
|
||
return "000000".substring(string.length) + string;
|
||
};
|
||
convert.hex.rgb = function(args) {
|
||
const match = args.toString(16).match(/[a-f0-9]{6}|[a-f0-9]{3}/i);
|
||
if (!match) {
|
||
return [0, 0, 0];
|
||
}
|
||
let colorString = match[0];
|
||
if (match[0].length === 3) {
|
||
colorString = colorString.split("").map((char) => {
|
||
return char + char;
|
||
}).join("");
|
||
}
|
||
const integer = parseInt(colorString, 16);
|
||
const r = integer >> 16 & 255;
|
||
const g = integer >> 8 & 255;
|
||
const b = integer & 255;
|
||
return [r, g, b];
|
||
};
|
||
convert.rgb.hcg = function(rgb) {
|
||
const r = rgb[0] / 255;
|
||
const g = rgb[1] / 255;
|
||
const b = rgb[2] / 255;
|
||
const max = Math.max(Math.max(r, g), b);
|
||
const min = Math.min(Math.min(r, g), b);
|
||
const chroma = max - min;
|
||
let grayscale;
|
||
let hue;
|
||
if (chroma < 1) {
|
||
grayscale = min / (1 - chroma);
|
||
} else {
|
||
grayscale = 0;
|
||
}
|
||
if (chroma <= 0) {
|
||
hue = 0;
|
||
} else if (max === r) {
|
||
hue = (g - b) / chroma % 6;
|
||
} else if (max === g) {
|
||
hue = 2 + (b - r) / chroma;
|
||
} else {
|
||
hue = 4 + (r - g) / chroma;
|
||
}
|
||
hue /= 6;
|
||
hue %= 1;
|
||
return [hue * 360, chroma * 100, grayscale * 100];
|
||
};
|
||
convert.hsl.hcg = function(hsl) {
|
||
const s = hsl[1] / 100;
|
||
const l = hsl[2] / 100;
|
||
const c = l < 0.5 ? 2 * s * l : 2 * s * (1 - l);
|
||
let f = 0;
|
||
if (c < 1) {
|
||
f = (l - 0.5 * c) / (1 - c);
|
||
}
|
||
return [hsl[0], c * 100, f * 100];
|
||
};
|
||
convert.hsv.hcg = function(hsv) {
|
||
const s = hsv[1] / 100;
|
||
const v = hsv[2] / 100;
|
||
const c = s * v;
|
||
let f = 0;
|
||
if (c < 1) {
|
||
f = (v - c) / (1 - c);
|
||
}
|
||
return [hsv[0], c * 100, f * 100];
|
||
};
|
||
convert.hcg.rgb = function(hcg) {
|
||
const h = hcg[0] / 360;
|
||
const c = hcg[1] / 100;
|
||
const g = hcg[2] / 100;
|
||
if (c === 0) {
|
||
return [g * 255, g * 255, g * 255];
|
||
}
|
||
const pure = [0, 0, 0];
|
||
const hi = h % 1 * 6;
|
||
const v = hi % 1;
|
||
const w = 1 - v;
|
||
let mg = 0;
|
||
switch (Math.floor(hi)) {
|
||
case 0:
|
||
pure[0] = 1;
|
||
pure[1] = v;
|
||
pure[2] = 0;
|
||
break;
|
||
case 1:
|
||
pure[0] = w;
|
||
pure[1] = 1;
|
||
pure[2] = 0;
|
||
break;
|
||
case 2:
|
||
pure[0] = 0;
|
||
pure[1] = 1;
|
||
pure[2] = v;
|
||
break;
|
||
case 3:
|
||
pure[0] = 0;
|
||
pure[1] = w;
|
||
pure[2] = 1;
|
||
break;
|
||
case 4:
|
||
pure[0] = v;
|
||
pure[1] = 0;
|
||
pure[2] = 1;
|
||
break;
|
||
default:
|
||
pure[0] = 1;
|
||
pure[1] = 0;
|
||
pure[2] = w;
|
||
}
|
||
mg = (1 - c) * g;
|
||
return [
|
||
(c * pure[0] + mg) * 255,
|
||
(c * pure[1] + mg) * 255,
|
||
(c * pure[2] + mg) * 255
|
||
];
|
||
};
|
||
convert.hcg.hsv = function(hcg) {
|
||
const c = hcg[1] / 100;
|
||
const g = hcg[2] / 100;
|
||
const v = c + g * (1 - c);
|
||
let f = 0;
|
||
if (v > 0) {
|
||
f = c / v;
|
||
}
|
||
return [hcg[0], f * 100, v * 100];
|
||
};
|
||
convert.hcg.hsl = function(hcg) {
|
||
const c = hcg[1] / 100;
|
||
const g = hcg[2] / 100;
|
||
const l = g * (1 - c) + 0.5 * c;
|
||
let s = 0;
|
||
if (l > 0 && l < 0.5) {
|
||
s = c / (2 * l);
|
||
} else if (l >= 0.5 && l < 1) {
|
||
s = c / (2 * (1 - l));
|
||
}
|
||
return [hcg[0], s * 100, l * 100];
|
||
};
|
||
convert.hcg.hwb = function(hcg) {
|
||
const c = hcg[1] / 100;
|
||
const g = hcg[2] / 100;
|
||
const v = c + g * (1 - c);
|
||
return [hcg[0], (v - c) * 100, (1 - v) * 100];
|
||
};
|
||
convert.hwb.hcg = function(hwb) {
|
||
const w = hwb[1] / 100;
|
||
const b = hwb[2] / 100;
|
||
const v = 1 - b;
|
||
const c = v - w;
|
||
let g = 0;
|
||
if (c < 1) {
|
||
g = (v - c) / (1 - c);
|
||
}
|
||
return [hwb[0], c * 100, g * 100];
|
||
};
|
||
convert.apple.rgb = function(apple) {
|
||
return [apple[0] / 65535 * 255, apple[1] / 65535 * 255, apple[2] / 65535 * 255];
|
||
};
|
||
convert.rgb.apple = function(rgb) {
|
||
return [rgb[0] / 255 * 65535, rgb[1] / 255 * 65535, rgb[2] / 255 * 65535];
|
||
};
|
||
convert.gray.rgb = function(args) {
|
||
return [args[0] / 100 * 255, args[0] / 100 * 255, args[0] / 100 * 255];
|
||
};
|
||
convert.gray.hsl = function(args) {
|
||
return [0, 0, args[0]];
|
||
};
|
||
convert.gray.hsv = convert.gray.hsl;
|
||
convert.gray.hwb = function(gray) {
|
||
return [0, 100, gray[0]];
|
||
};
|
||
convert.gray.cmyk = function(gray) {
|
||
return [0, 0, 0, gray[0]];
|
||
};
|
||
convert.gray.lab = function(gray) {
|
||
return [gray[0], 0, 0];
|
||
};
|
||
convert.gray.hex = function(gray) {
|
||
const val = Math.round(gray[0] / 100 * 255) & 255;
|
||
const integer = (val << 16) + (val << 8) + val;
|
||
const string = integer.toString(16).toUpperCase();
|
||
return "000000".substring(string.length) + string;
|
||
};
|
||
convert.rgb.gray = function(rgb) {
|
||
const val = (rgb[0] + rgb[1] + rgb[2]) / 3;
|
||
return [val / 255 * 100];
|
||
};
|
||
}
|
||
});
|
||
|
||
// node_modules/color-convert/route.js
|
||
var require_route = __commonJS({
|
||
"node_modules/color-convert/route.js"(exports, module2) {
|
||
var conversions = require_conversions();
|
||
function buildGraph() {
|
||
const graph = {};
|
||
const models = Object.keys(conversions);
|
||
for (let len = models.length, i = 0; i < len; i++) {
|
||
graph[models[i]] = {
|
||
distance: -1,
|
||
parent: null
|
||
};
|
||
}
|
||
return graph;
|
||
}
|
||
function deriveBFS(fromModel) {
|
||
const graph = buildGraph();
|
||
const queue = [fromModel];
|
||
graph[fromModel].distance = 0;
|
||
while (queue.length) {
|
||
const current = queue.pop();
|
||
const adjacents = Object.keys(conversions[current]);
|
||
for (let len = adjacents.length, i = 0; i < len; i++) {
|
||
const adjacent = adjacents[i];
|
||
const node = graph[adjacent];
|
||
if (node.distance === -1) {
|
||
node.distance = graph[current].distance + 1;
|
||
node.parent = current;
|
||
queue.unshift(adjacent);
|
||
}
|
||
}
|
||
}
|
||
return graph;
|
||
}
|
||
function link(from, to) {
|
||
return function(args) {
|
||
return to(from(args));
|
||
};
|
||
}
|
||
function wrapConversion(toModel, graph) {
|
||
const path = [graph[toModel].parent, toModel];
|
||
let fn = conversions[graph[toModel].parent][toModel];
|
||
let cur = graph[toModel].parent;
|
||
while (graph[cur].parent) {
|
||
path.unshift(graph[cur].parent);
|
||
fn = link(conversions[graph[cur].parent][cur], fn);
|
||
cur = graph[cur].parent;
|
||
}
|
||
fn.conversion = path;
|
||
return fn;
|
||
}
|
||
module2.exports = function(fromModel) {
|
||
const graph = deriveBFS(fromModel);
|
||
const conversion4 = {};
|
||
const models = Object.keys(graph);
|
||
for (let len = models.length, i = 0; i < len; i++) {
|
||
const toModel = models[i];
|
||
const node = graph[toModel];
|
||
if (node.parent === null) {
|
||
continue;
|
||
}
|
||
conversion4[toModel] = wrapConversion(toModel, graph);
|
||
}
|
||
return conversion4;
|
||
};
|
||
}
|
||
});
|
||
|
||
// node_modules/color-convert/index.js
|
||
var require_color_convert = __commonJS({
|
||
"node_modules/color-convert/index.js"(exports, module2) {
|
||
var conversions = require_conversions();
|
||
var route = require_route();
|
||
var convert = {};
|
||
var models = Object.keys(conversions);
|
||
function wrapRaw(fn) {
|
||
const wrappedFn = function(...args) {
|
||
const arg0 = args[0];
|
||
if (arg0 === void 0 || arg0 === null) {
|
||
return arg0;
|
||
}
|
||
if (arg0.length > 1) {
|
||
args = arg0;
|
||
}
|
||
return fn(args);
|
||
};
|
||
if ("conversion" in fn) {
|
||
wrappedFn.conversion = fn.conversion;
|
||
}
|
||
return wrappedFn;
|
||
}
|
||
function wrapRounded(fn) {
|
||
const wrappedFn = function(...args) {
|
||
const arg0 = args[0];
|
||
if (arg0 === void 0 || arg0 === null) {
|
||
return arg0;
|
||
}
|
||
if (arg0.length > 1) {
|
||
args = arg0;
|
||
}
|
||
const result = fn(args);
|
||
if (typeof result === "object") {
|
||
for (let len = result.length, i = 0; i < len; i++) {
|
||
result[i] = Math.round(result[i]);
|
||
}
|
||
}
|
||
return result;
|
||
};
|
||
if ("conversion" in fn) {
|
||
wrappedFn.conversion = fn.conversion;
|
||
}
|
||
return wrappedFn;
|
||
}
|
||
models.forEach((fromModel) => {
|
||
convert[fromModel] = {};
|
||
Object.defineProperty(convert[fromModel], "channels", { value: conversions[fromModel].channels });
|
||
Object.defineProperty(convert[fromModel], "labels", { value: conversions[fromModel].labels });
|
||
const routes = route(fromModel);
|
||
const routeModels = Object.keys(routes);
|
||
routeModels.forEach((toModel) => {
|
||
const fn = routes[toModel];
|
||
convert[fromModel][toModel] = wrapRounded(fn);
|
||
convert[fromModel][toModel].raw = wrapRaw(fn);
|
||
});
|
||
});
|
||
module2.exports = convert;
|
||
}
|
||
});
|
||
|
||
// node_modules/ansi-styles/index.js
|
||
var require_ansi_styles = __commonJS({
|
||
"node_modules/ansi-styles/index.js"(exports, module2) {
|
||
"use strict";
|
||
var wrapAnsi16 = (fn, offset) => (...args) => {
|
||
const code = fn(...args);
|
||
return `[${code + offset}m`;
|
||
};
|
||
var wrapAnsi256 = (fn, offset) => (...args) => {
|
||
const code = fn(...args);
|
||
return `[${38 + offset};5;${code}m`;
|
||
};
|
||
var wrapAnsi16m = (fn, offset) => (...args) => {
|
||
const rgb = fn(...args);
|
||
return `[${38 + offset};2;${rgb[0]};${rgb[1]};${rgb[2]}m`;
|
||
};
|
||
var ansi2ansi = (n) => n;
|
||
var rgb2rgb = (r, g, b) => [r, g, b];
|
||
var setLazyProperty = (object, property, get) => {
|
||
Object.defineProperty(object, property, {
|
||
get: () => {
|
||
const value = get();
|
||
Object.defineProperty(object, property, {
|
||
value,
|
||
enumerable: true,
|
||
configurable: true
|
||
});
|
||
return value;
|
||
},
|
||
enumerable: true,
|
||
configurable: true
|
||
});
|
||
};
|
||
var colorConvert;
|
||
var makeDynamicStyles = (wrap2, targetSpace, identity, isBackground) => {
|
||
if (colorConvert === void 0) {
|
||
colorConvert = require_color_convert();
|
||
}
|
||
const offset = isBackground ? 10 : 0;
|
||
const styles = {};
|
||
for (const [sourceSpace, suite] of Object.entries(colorConvert)) {
|
||
const name = sourceSpace === "ansi16" ? "ansi" : sourceSpace;
|
||
if (sourceSpace === targetSpace) {
|
||
styles[name] = wrap2(identity, offset);
|
||
} else if (typeof suite === "object") {
|
||
styles[name] = wrap2(suite[targetSpace], offset);
|
||
}
|
||
}
|
||
return styles;
|
||
};
|
||
function assembleStyles() {
|
||
const codes = /* @__PURE__ */ new Map();
|
||
const styles = {
|
||
modifier: {
|
||
reset: [0, 0],
|
||
bold: [1, 22],
|
||
dim: [2, 22],
|
||
italic: [3, 23],
|
||
underline: [4, 24],
|
||
inverse: [7, 27],
|
||
hidden: [8, 28],
|
||
strikethrough: [9, 29]
|
||
},
|
||
color: {
|
||
black: [30, 39],
|
||
red: [31, 39],
|
||
green: [32, 39],
|
||
yellow: [33, 39],
|
||
blue: [34, 39],
|
||
magenta: [35, 39],
|
||
cyan: [36, 39],
|
||
white: [37, 39],
|
||
blackBright: [90, 39],
|
||
redBright: [91, 39],
|
||
greenBright: [92, 39],
|
||
yellowBright: [93, 39],
|
||
blueBright: [94, 39],
|
||
magentaBright: [95, 39],
|
||
cyanBright: [96, 39],
|
||
whiteBright: [97, 39]
|
||
},
|
||
bgColor: {
|
||
bgBlack: [40, 49],
|
||
bgRed: [41, 49],
|
||
bgGreen: [42, 49],
|
||
bgYellow: [43, 49],
|
||
bgBlue: [44, 49],
|
||
bgMagenta: [45, 49],
|
||
bgCyan: [46, 49],
|
||
bgWhite: [47, 49],
|
||
bgBlackBright: [100, 49],
|
||
bgRedBright: [101, 49],
|
||
bgGreenBright: [102, 49],
|
||
bgYellowBright: [103, 49],
|
||
bgBlueBright: [104, 49],
|
||
bgMagentaBright: [105, 49],
|
||
bgCyanBright: [106, 49],
|
||
bgWhiteBright: [107, 49]
|
||
}
|
||
};
|
||
styles.color.gray = styles.color.blackBright;
|
||
styles.bgColor.bgGray = styles.bgColor.bgBlackBright;
|
||
styles.color.grey = styles.color.blackBright;
|
||
styles.bgColor.bgGrey = styles.bgColor.bgBlackBright;
|
||
for (const [groupName, group] of Object.entries(styles)) {
|
||
for (const [styleName, style] of Object.entries(group)) {
|
||
styles[styleName] = {
|
||
open: `[${style[0]}m`,
|
||
close: `[${style[1]}m`
|
||
};
|
||
group[styleName] = styles[styleName];
|
||
codes.set(style[0], style[1]);
|
||
}
|
||
Object.defineProperty(styles, groupName, {
|
||
value: group,
|
||
enumerable: false
|
||
});
|
||
}
|
||
Object.defineProperty(styles, "codes", {
|
||
value: codes,
|
||
enumerable: false
|
||
});
|
||
styles.color.close = "[39m";
|
||
styles.bgColor.close = "[49m";
|
||
setLazyProperty(styles.color, "ansi", () => makeDynamicStyles(wrapAnsi16, "ansi16", ansi2ansi, false));
|
||
setLazyProperty(styles.color, "ansi256", () => makeDynamicStyles(wrapAnsi256, "ansi256", ansi2ansi, false));
|
||
setLazyProperty(styles.color, "ansi16m", () => makeDynamicStyles(wrapAnsi16m, "rgb", rgb2rgb, false));
|
||
setLazyProperty(styles.bgColor, "ansi", () => makeDynamicStyles(wrapAnsi16, "ansi16", ansi2ansi, true));
|
||
setLazyProperty(styles.bgColor, "ansi256", () => makeDynamicStyles(wrapAnsi256, "ansi256", ansi2ansi, true));
|
||
setLazyProperty(styles.bgColor, "ansi16m", () => makeDynamicStyles(wrapAnsi16m, "rgb", rgb2rgb, true));
|
||
return styles;
|
||
}
|
||
Object.defineProperty(module2, "exports", {
|
||
enumerable: true,
|
||
get: assembleStyles
|
||
});
|
||
}
|
||
});
|
||
|
||
// node_modules/chalk/source/util.js
|
||
var require_util = __commonJS({
|
||
"node_modules/chalk/source/util.js"(exports, module2) {
|
||
"use strict";
|
||
var stringReplaceAll = (string, substring, replacer) => {
|
||
let index = string.indexOf(substring);
|
||
if (index === -1) {
|
||
return string;
|
||
}
|
||
const substringLength = substring.length;
|
||
let endIndex = 0;
|
||
let returnValue = "";
|
||
do {
|
||
returnValue += string.substr(endIndex, index - endIndex) + substring + replacer;
|
||
endIndex = index + substringLength;
|
||
index = string.indexOf(substring, endIndex);
|
||
} while (index !== -1);
|
||
returnValue += string.substr(endIndex);
|
||
return returnValue;
|
||
};
|
||
var stringEncaseCRLFWithFirstIndex = (string, prefix, postfix, index) => {
|
||
let endIndex = 0;
|
||
let returnValue = "";
|
||
do {
|
||
const gotCR = string[index - 1] === "\r";
|
||
returnValue += string.substr(endIndex, (gotCR ? index - 1 : index) - endIndex) + prefix + (gotCR ? "\r\n" : "\n") + postfix;
|
||
endIndex = index + 1;
|
||
index = string.indexOf("\n", endIndex);
|
||
} while (index !== -1);
|
||
returnValue += string.substr(endIndex);
|
||
return returnValue;
|
||
};
|
||
module2.exports = {
|
||
stringReplaceAll,
|
||
stringEncaseCRLFWithFirstIndex
|
||
};
|
||
}
|
||
});
|
||
|
||
// node_modules/chalk/source/templates.js
|
||
var require_templates = __commonJS({
|
||
"node_modules/chalk/source/templates.js"(exports, module2) {
|
||
"use strict";
|
||
var TEMPLATE_REGEX = /(?:\\(u(?:[a-f\d]{4}|\{[a-f\d]{1,6}\})|x[a-f\d]{2}|.))|(?:\{(~)?(\w+(?:\([^)]*\))?(?:\.\w+(?:\([^)]*\))?)*)(?:[ \t]|(?=\r?\n)))|(\})|((?:.|[\r\n\f])+?)/gi;
|
||
var STYLE_REGEX = /(?:^|\.)(\w+)(?:\(([^)]*)\))?/g;
|
||
var STRING_REGEX = /^(['"])((?:\\.|(?!\1)[^\\])*)\1$/;
|
||
var ESCAPE_REGEX = /\\(u(?:[a-f\d]{4}|{[a-f\d]{1,6}})|x[a-f\d]{2}|.)|([^\\])/gi;
|
||
var ESCAPES = /* @__PURE__ */ new Map([
|
||
["n", "\n"],
|
||
["r", "\r"],
|
||
["t", " "],
|
||
["b", "\b"],
|
||
["f", "\f"],
|
||
["v", "\v"],
|
||
["0", "\0"],
|
||
["\\", "\\"],
|
||
["e", ""],
|
||
["a", "\x07"]
|
||
]);
|
||
function unescape(c) {
|
||
const u = c[0] === "u";
|
||
const bracket = c[1] === "{";
|
||
if (u && !bracket && c.length === 5 || c[0] === "x" && c.length === 3) {
|
||
return String.fromCharCode(parseInt(c.slice(1), 16));
|
||
}
|
||
if (u && bracket) {
|
||
return String.fromCodePoint(parseInt(c.slice(2, -1), 16));
|
||
}
|
||
return ESCAPES.get(c) || c;
|
||
}
|
||
function parseArguments(name, arguments_) {
|
||
const results = [];
|
||
const chunks = arguments_.trim().split(/\s*,\s*/g);
|
||
let matches;
|
||
for (const chunk of chunks) {
|
||
const number = Number(chunk);
|
||
if (!Number.isNaN(number)) {
|
||
results.push(number);
|
||
} else if (matches = chunk.match(STRING_REGEX)) {
|
||
results.push(matches[2].replace(ESCAPE_REGEX, (m, escape, character) => escape ? unescape(escape) : character));
|
||
} else {
|
||
throw new Error(`Invalid Chalk template style argument: ${chunk} (in style '${name}')`);
|
||
}
|
||
}
|
||
return results;
|
||
}
|
||
function parseStyle(style) {
|
||
STYLE_REGEX.lastIndex = 0;
|
||
const results = [];
|
||
let matches;
|
||
while ((matches = STYLE_REGEX.exec(style)) !== null) {
|
||
const name = matches[1];
|
||
if (matches[2]) {
|
||
const args = parseArguments(name, matches[2]);
|
||
results.push([name].concat(args));
|
||
} else {
|
||
results.push([name]);
|
||
}
|
||
}
|
||
return results;
|
||
}
|
||
function buildStyle(chalk, styles) {
|
||
const enabled = {};
|
||
for (const layer of styles) {
|
||
for (const style of layer.styles) {
|
||
enabled[style[0]] = layer.inverse ? null : style.slice(1);
|
||
}
|
||
}
|
||
let current = chalk;
|
||
for (const [styleName, styles2] of Object.entries(enabled)) {
|
||
if (!Array.isArray(styles2)) {
|
||
continue;
|
||
}
|
||
if (!(styleName in current)) {
|
||
throw new Error(`Unknown Chalk style: ${styleName}`);
|
||
}
|
||
current = styles2.length > 0 ? current[styleName](...styles2) : current[styleName];
|
||
}
|
||
return current;
|
||
}
|
||
module2.exports = (chalk, temporary) => {
|
||
const styles = [];
|
||
const chunks = [];
|
||
let chunk = [];
|
||
temporary.replace(TEMPLATE_REGEX, (m, escapeCharacter, inverse, style, close, character) => {
|
||
if (escapeCharacter) {
|
||
chunk.push(unescape(escapeCharacter));
|
||
} else if (style) {
|
||
const string = chunk.join("");
|
||
chunk = [];
|
||
chunks.push(styles.length === 0 ? string : buildStyle(chalk, styles)(string));
|
||
styles.push({ inverse, styles: parseStyle(style) });
|
||
} else if (close) {
|
||
if (styles.length === 0) {
|
||
throw new Error("Found extraneous } in Chalk template literal");
|
||
}
|
||
chunks.push(buildStyle(chalk, styles)(chunk.join("")));
|
||
chunk = [];
|
||
styles.pop();
|
||
} else {
|
||
chunk.push(character);
|
||
}
|
||
});
|
||
chunks.push(chunk.join(""));
|
||
if (styles.length > 0) {
|
||
const errMessage = `Chalk template literal is missing ${styles.length} closing bracket${styles.length === 1 ? "" : "s"} (\`}\`)`;
|
||
throw new Error(errMessage);
|
||
}
|
||
return chunks.join("");
|
||
};
|
||
}
|
||
});
|
||
|
||
// node_modules/chalk/source/index.js
|
||
var require_source = __commonJS({
|
||
"node_modules/chalk/source/index.js"(exports, module2) {
|
||
"use strict";
|
||
var ansiStyles = require_ansi_styles();
|
||
var { stdout: stdoutColor, stderr: stderrColor } = require_supports_color();
|
||
var {
|
||
stringReplaceAll,
|
||
stringEncaseCRLFWithFirstIndex
|
||
} = require_util();
|
||
var { isArray } = Array;
|
||
var levelMapping = [
|
||
"ansi",
|
||
"ansi",
|
||
"ansi256",
|
||
"ansi16m"
|
||
];
|
||
var styles = /* @__PURE__ */ Object.create(null);
|
||
var applyOptions = (object, options = {}) => {
|
||
if (options.level && !(Number.isInteger(options.level) && options.level >= 0 && options.level <= 3)) {
|
||
throw new Error("The `level` option should be an integer from 0 to 3");
|
||
}
|
||
const colorLevel = stdoutColor ? stdoutColor.level : 0;
|
||
object.level = options.level === void 0 ? colorLevel : options.level;
|
||
};
|
||
var ChalkClass = class {
|
||
constructor(options) {
|
||
return chalkFactory(options);
|
||
}
|
||
};
|
||
var chalkFactory = (options) => {
|
||
const chalk2 = {};
|
||
applyOptions(chalk2, options);
|
||
chalk2.template = (...arguments_) => chalkTag(chalk2.template, ...arguments_);
|
||
Object.setPrototypeOf(chalk2, Chalk.prototype);
|
||
Object.setPrototypeOf(chalk2.template, chalk2);
|
||
chalk2.template.constructor = () => {
|
||
throw new Error("`chalk.constructor()` is deprecated. Use `new chalk.Instance()` instead.");
|
||
};
|
||
chalk2.template.Instance = ChalkClass;
|
||
return chalk2.template;
|
||
};
|
||
function Chalk(options) {
|
||
return chalkFactory(options);
|
||
}
|
||
for (const [styleName, style] of Object.entries(ansiStyles)) {
|
||
styles[styleName] = {
|
||
get() {
|
||
const builder = createBuilder(this, createStyler(style.open, style.close, this._styler), this._isEmpty);
|
||
Object.defineProperty(this, styleName, { value: builder });
|
||
return builder;
|
||
}
|
||
};
|
||
}
|
||
styles.visible = {
|
||
get() {
|
||
const builder = createBuilder(this, this._styler, true);
|
||
Object.defineProperty(this, "visible", { value: builder });
|
||
return builder;
|
||
}
|
||
};
|
||
var usedModels = ["rgb", "hex", "keyword", "hsl", "hsv", "hwb", "ansi", "ansi256"];
|
||
for (const model of usedModels) {
|
||
styles[model] = {
|
||
get() {
|
||
const { level } = this;
|
||
return function(...arguments_) {
|
||
const styler = createStyler(ansiStyles.color[levelMapping[level]][model](...arguments_), ansiStyles.color.close, this._styler);
|
||
return createBuilder(this, styler, this._isEmpty);
|
||
};
|
||
}
|
||
};
|
||
}
|
||
for (const model of usedModels) {
|
||
const bgModel = "bg" + model[0].toUpperCase() + model.slice(1);
|
||
styles[bgModel] = {
|
||
get() {
|
||
const { level } = this;
|
||
return function(...arguments_) {
|
||
const styler = createStyler(ansiStyles.bgColor[levelMapping[level]][model](...arguments_), ansiStyles.bgColor.close, this._styler);
|
||
return createBuilder(this, styler, this._isEmpty);
|
||
};
|
||
}
|
||
};
|
||
}
|
||
var proto = Object.defineProperties(() => {
|
||
}, __spreadProps(__spreadValues({}, styles), {
|
||
level: {
|
||
enumerable: true,
|
||
get() {
|
||
return this._generator.level;
|
||
},
|
||
set(level) {
|
||
this._generator.level = level;
|
||
}
|
||
}
|
||
}));
|
||
var createStyler = (open, close, parent) => {
|
||
let openAll;
|
||
let closeAll;
|
||
if (parent === void 0) {
|
||
openAll = open;
|
||
closeAll = close;
|
||
} else {
|
||
openAll = parent.openAll + open;
|
||
closeAll = close + parent.closeAll;
|
||
}
|
||
return {
|
||
open,
|
||
close,
|
||
openAll,
|
||
closeAll,
|
||
parent
|
||
};
|
||
};
|
||
var createBuilder = (self, _styler, _isEmpty) => {
|
||
const builder = (...arguments_) => {
|
||
if (isArray(arguments_[0]) && isArray(arguments_[0].raw)) {
|
||
return applyStyle(builder, chalkTag(builder, ...arguments_));
|
||
}
|
||
return applyStyle(builder, arguments_.length === 1 ? "" + arguments_[0] : arguments_.join(" "));
|
||
};
|
||
Object.setPrototypeOf(builder, proto);
|
||
builder._generator = self;
|
||
builder._styler = _styler;
|
||
builder._isEmpty = _isEmpty;
|
||
return builder;
|
||
};
|
||
var applyStyle = (self, string) => {
|
||
if (self.level <= 0 || !string) {
|
||
return self._isEmpty ? "" : string;
|
||
}
|
||
let styler = self._styler;
|
||
if (styler === void 0) {
|
||
return string;
|
||
}
|
||
const { openAll, closeAll } = styler;
|
||
if (string.indexOf("") !== -1) {
|
||
while (styler !== void 0) {
|
||
string = stringReplaceAll(string, styler.close, styler.open);
|
||
styler = styler.parent;
|
||
}
|
||
}
|
||
const lfIndex = string.indexOf("\n");
|
||
if (lfIndex !== -1) {
|
||
string = stringEncaseCRLFWithFirstIndex(string, closeAll, openAll, lfIndex);
|
||
}
|
||
return openAll + string + closeAll;
|
||
};
|
||
var template;
|
||
var chalkTag = (chalk2, ...strings) => {
|
||
const [firstString] = strings;
|
||
if (!isArray(firstString) || !isArray(firstString.raw)) {
|
||
return strings.join(" ");
|
||
}
|
||
const arguments_ = strings.slice(1);
|
||
const parts = [firstString.raw[0]];
|
||
for (let i = 1; i < firstString.length; i++) {
|
||
parts.push(String(arguments_[i - 1]).replace(/[{}\\]/g, "\\$&"), String(firstString.raw[i]));
|
||
}
|
||
if (template === void 0) {
|
||
template = require_templates();
|
||
}
|
||
return template(chalk2, parts.join(""));
|
||
};
|
||
Object.defineProperties(Chalk.prototype, styles);
|
||
var chalk = Chalk();
|
||
chalk.supportsColor = stdoutColor;
|
||
chalk.stderr = Chalk({ level: stderrColor ? stderrColor.level : 0 });
|
||
chalk.stderr.supportsColor = stderrColor;
|
||
module2.exports = chalk;
|
||
}
|
||
});
|
||
|
||
// node_modules/universalify/index.js
|
||
var require_universalify = __commonJS({
|
||
"node_modules/universalify/index.js"(exports) {
|
||
"use strict";
|
||
exports.fromCallback = function(fn) {
|
||
return Object.defineProperty(function(...args) {
|
||
if (typeof args[args.length - 1] === "function")
|
||
fn.apply(this, args);
|
||
else {
|
||
return new Promise((resolve6, reject) => {
|
||
fn.call(this, ...args, (err, res) => err != null ? reject(err) : resolve6(res));
|
||
});
|
||
}
|
||
}, "name", { value: fn.name });
|
||
};
|
||
exports.fromPromise = function(fn) {
|
||
return Object.defineProperty(function(...args) {
|
||
const cb = args[args.length - 1];
|
||
if (typeof cb !== "function")
|
||
return fn.apply(this, args);
|
||
else
|
||
fn.apply(this, args.slice(0, -1)).then((r) => cb(null, r), cb);
|
||
}, "name", { value: fn.name });
|
||
};
|
||
}
|
||
});
|
||
|
||
// node_modules/graceful-fs/polyfills.js
|
||
var require_polyfills = __commonJS({
|
||
"node_modules/graceful-fs/polyfills.js"(exports, module2) {
|
||
var constants = require("constants");
|
||
var origCwd = process.cwd;
|
||
var cwd = null;
|
||
var platform = process.env.GRACEFUL_FS_PLATFORM || process.platform;
|
||
process.cwd = function() {
|
||
if (!cwd)
|
||
cwd = origCwd.call(process);
|
||
return cwd;
|
||
};
|
||
try {
|
||
process.cwd();
|
||
} catch (er) {
|
||
}
|
||
if (typeof process.chdir === "function") {
|
||
chdir = process.chdir;
|
||
process.chdir = function(d) {
|
||
cwd = null;
|
||
chdir.call(process, d);
|
||
};
|
||
if (Object.setPrototypeOf)
|
||
Object.setPrototypeOf(process.chdir, chdir);
|
||
}
|
||
var chdir;
|
||
module2.exports = patch;
|
||
function patch(fs) {
|
||
if (constants.hasOwnProperty("O_SYMLINK") && process.version.match(/^v0\.6\.[0-2]|^v0\.5\./)) {
|
||
patchLchmod(fs);
|
||
}
|
||
if (!fs.lutimes) {
|
||
patchLutimes(fs);
|
||
}
|
||
fs.chown = chownFix(fs.chown);
|
||
fs.fchown = chownFix(fs.fchown);
|
||
fs.lchown = chownFix(fs.lchown);
|
||
fs.chmod = chmodFix(fs.chmod);
|
||
fs.fchmod = chmodFix(fs.fchmod);
|
||
fs.lchmod = chmodFix(fs.lchmod);
|
||
fs.chownSync = chownFixSync(fs.chownSync);
|
||
fs.fchownSync = chownFixSync(fs.fchownSync);
|
||
fs.lchownSync = chownFixSync(fs.lchownSync);
|
||
fs.chmodSync = chmodFixSync(fs.chmodSync);
|
||
fs.fchmodSync = chmodFixSync(fs.fchmodSync);
|
||
fs.lchmodSync = chmodFixSync(fs.lchmodSync);
|
||
fs.stat = statFix(fs.stat);
|
||
fs.fstat = statFix(fs.fstat);
|
||
fs.lstat = statFix(fs.lstat);
|
||
fs.statSync = statFixSync(fs.statSync);
|
||
fs.fstatSync = statFixSync(fs.fstatSync);
|
||
fs.lstatSync = statFixSync(fs.lstatSync);
|
||
if (!fs.lchmod) {
|
||
fs.lchmod = function(path, mode, cb) {
|
||
if (cb)
|
||
process.nextTick(cb);
|
||
};
|
||
fs.lchmodSync = function() {
|
||
};
|
||
}
|
||
if (!fs.lchown) {
|
||
fs.lchown = function(path, uid, gid, cb) {
|
||
if (cb)
|
||
process.nextTick(cb);
|
||
};
|
||
fs.lchownSync = function() {
|
||
};
|
||
}
|
||
if (platform === "win32") {
|
||
fs.rename = function(fs$rename) {
|
||
return function(from, to, cb) {
|
||
var start = Date.now();
|
||
var backoff = 0;
|
||
fs$rename(from, to, function CB(er) {
|
||
if (er && (er.code === "EACCES" || er.code === "EPERM") && Date.now() - start < 6e4) {
|
||
setTimeout(function() {
|
||
fs.stat(to, function(stater, st) {
|
||
if (stater && stater.code === "ENOENT")
|
||
fs$rename(from, to, CB);
|
||
else
|
||
cb(er);
|
||
});
|
||
}, backoff);
|
||
if (backoff < 100)
|
||
backoff += 10;
|
||
return;
|
||
}
|
||
if (cb)
|
||
cb(er);
|
||
});
|
||
};
|
||
}(fs.rename);
|
||
}
|
||
fs.read = function(fs$read) {
|
||
function read(fd, buffer, offset, length, position, callback_) {
|
||
var callback;
|
||
if (callback_ && typeof callback_ === "function") {
|
||
var eagCounter = 0;
|
||
callback = function(er, _, __) {
|
||
if (er && er.code === "EAGAIN" && eagCounter < 10) {
|
||
eagCounter++;
|
||
return fs$read.call(fs, fd, buffer, offset, length, position, callback);
|
||
}
|
||
callback_.apply(this, arguments);
|
||
};
|
||
}
|
||
return fs$read.call(fs, fd, buffer, offset, length, position, callback);
|
||
}
|
||
if (Object.setPrototypeOf)
|
||
Object.setPrototypeOf(read, fs$read);
|
||
return read;
|
||
}(fs.read);
|
||
fs.readSync = function(fs$readSync) {
|
||
return function(fd, buffer, offset, length, position) {
|
||
var eagCounter = 0;
|
||
while (true) {
|
||
try {
|
||
return fs$readSync.call(fs, fd, buffer, offset, length, position);
|
||
} catch (er) {
|
||
if (er.code === "EAGAIN" && eagCounter < 10) {
|
||
eagCounter++;
|
||
continue;
|
||
}
|
||
throw er;
|
||
}
|
||
}
|
||
};
|
||
}(fs.readSync);
|
||
function patchLchmod(fs2) {
|
||
fs2.lchmod = function(path, mode, callback) {
|
||
fs2.open(path, constants.O_WRONLY | constants.O_SYMLINK, mode, function(err, fd) {
|
||
if (err) {
|
||
if (callback)
|
||
callback(err);
|
||
return;
|
||
}
|
||
fs2.fchmod(fd, mode, function(err2) {
|
||
fs2.close(fd, function(err22) {
|
||
if (callback)
|
||
callback(err2 || err22);
|
||
});
|
||
});
|
||
});
|
||
};
|
||
fs2.lchmodSync = function(path, mode) {
|
||
var fd = fs2.openSync(path, constants.O_WRONLY | constants.O_SYMLINK, mode);
|
||
var threw = true;
|
||
var ret;
|
||
try {
|
||
ret = fs2.fchmodSync(fd, mode);
|
||
threw = false;
|
||
} finally {
|
||
if (threw) {
|
||
try {
|
||
fs2.closeSync(fd);
|
||
} catch (er) {
|
||
}
|
||
} else {
|
||
fs2.closeSync(fd);
|
||
}
|
||
}
|
||
return ret;
|
||
};
|
||
}
|
||
function patchLutimes(fs2) {
|
||
if (constants.hasOwnProperty("O_SYMLINK")) {
|
||
fs2.lutimes = function(path, at, mt, cb) {
|
||
fs2.open(path, constants.O_SYMLINK, function(er, fd) {
|
||
if (er) {
|
||
if (cb)
|
||
cb(er);
|
||
return;
|
||
}
|
||
fs2.futimes(fd, at, mt, function(er2) {
|
||
fs2.close(fd, function(er22) {
|
||
if (cb)
|
||
cb(er2 || er22);
|
||
});
|
||
});
|
||
});
|
||
};
|
||
fs2.lutimesSync = function(path, at, mt) {
|
||
var fd = fs2.openSync(path, constants.O_SYMLINK);
|
||
var ret;
|
||
var threw = true;
|
||
try {
|
||
ret = fs2.futimesSync(fd, at, mt);
|
||
threw = false;
|
||
} finally {
|
||
if (threw) {
|
||
try {
|
||
fs2.closeSync(fd);
|
||
} catch (er) {
|
||
}
|
||
} else {
|
||
fs2.closeSync(fd);
|
||
}
|
||
}
|
||
return ret;
|
||
};
|
||
} else {
|
||
fs2.lutimes = function(_a, _b, _c, cb) {
|
||
if (cb)
|
||
process.nextTick(cb);
|
||
};
|
||
fs2.lutimesSync = function() {
|
||
};
|
||
}
|
||
}
|
||
function chmodFix(orig) {
|
||
if (!orig)
|
||
return orig;
|
||
return function(target, mode, cb) {
|
||
return orig.call(fs, target, mode, function(er) {
|
||
if (chownErOk(er))
|
||
er = null;
|
||
if (cb)
|
||
cb.apply(this, arguments);
|
||
});
|
||
};
|
||
}
|
||
function chmodFixSync(orig) {
|
||
if (!orig)
|
||
return orig;
|
||
return function(target, mode) {
|
||
try {
|
||
return orig.call(fs, target, mode);
|
||
} catch (er) {
|
||
if (!chownErOk(er))
|
||
throw er;
|
||
}
|
||
};
|
||
}
|
||
function chownFix(orig) {
|
||
if (!orig)
|
||
return orig;
|
||
return function(target, uid, gid, cb) {
|
||
return orig.call(fs, target, uid, gid, function(er) {
|
||
if (chownErOk(er))
|
||
er = null;
|
||
if (cb)
|
||
cb.apply(this, arguments);
|
||
});
|
||
};
|
||
}
|
||
function chownFixSync(orig) {
|
||
if (!orig)
|
||
return orig;
|
||
return function(target, uid, gid) {
|
||
try {
|
||
return orig.call(fs, target, uid, gid);
|
||
} catch (er) {
|
||
if (!chownErOk(er))
|
||
throw er;
|
||
}
|
||
};
|
||
}
|
||
function statFix(orig) {
|
||
if (!orig)
|
||
return orig;
|
||
return function(target, options, cb) {
|
||
if (typeof options === "function") {
|
||
cb = options;
|
||
options = null;
|
||
}
|
||
function callback(er, stats) {
|
||
if (stats) {
|
||
if (stats.uid < 0)
|
||
stats.uid += 4294967296;
|
||
if (stats.gid < 0)
|
||
stats.gid += 4294967296;
|
||
}
|
||
if (cb)
|
||
cb.apply(this, arguments);
|
||
}
|
||
return options ? orig.call(fs, target, options, callback) : orig.call(fs, target, callback);
|
||
};
|
||
}
|
||
function statFixSync(orig) {
|
||
if (!orig)
|
||
return orig;
|
||
return function(target, options) {
|
||
var stats = options ? orig.call(fs, target, options) : orig.call(fs, target);
|
||
if (stats) {
|
||
if (stats.uid < 0)
|
||
stats.uid += 4294967296;
|
||
if (stats.gid < 0)
|
||
stats.gid += 4294967296;
|
||
}
|
||
return stats;
|
||
};
|
||
}
|
||
function chownErOk(er) {
|
||
if (!er)
|
||
return true;
|
||
if (er.code === "ENOSYS")
|
||
return true;
|
||
var nonroot = !process.getuid || process.getuid() !== 0;
|
||
if (nonroot) {
|
||
if (er.code === "EINVAL" || er.code === "EPERM")
|
||
return true;
|
||
}
|
||
return false;
|
||
}
|
||
}
|
||
}
|
||
});
|
||
|
||
// node_modules/graceful-fs/legacy-streams.js
|
||
var require_legacy_streams = __commonJS({
|
||
"node_modules/graceful-fs/legacy-streams.js"(exports, module2) {
|
||
var Stream = require("stream").Stream;
|
||
module2.exports = legacy;
|
||
function legacy(fs) {
|
||
return {
|
||
ReadStream,
|
||
WriteStream
|
||
};
|
||
function ReadStream(path, options) {
|
||
if (!(this instanceof ReadStream))
|
||
return new ReadStream(path, options);
|
||
Stream.call(this);
|
||
var self = this;
|
||
this.path = path;
|
||
this.fd = null;
|
||
this.readable = true;
|
||
this.paused = false;
|
||
this.flags = "r";
|
||
this.mode = 438;
|
||
this.bufferSize = 64 * 1024;
|
||
options = options || {};
|
||
var keys = Object.keys(options);
|
||
for (var index = 0, length = keys.length; index < length; index++) {
|
||
var key = keys[index];
|
||
this[key] = options[key];
|
||
}
|
||
if (this.encoding)
|
||
this.setEncoding(this.encoding);
|
||
if (this.start !== void 0) {
|
||
if (typeof this.start !== "number") {
|
||
throw TypeError("start must be a Number");
|
||
}
|
||
if (this.end === void 0) {
|
||
this.end = Infinity;
|
||
} else if (typeof this.end !== "number") {
|
||
throw TypeError("end must be a Number");
|
||
}
|
||
if (this.start > this.end) {
|
||
throw new Error("start must be <= end");
|
||
}
|
||
this.pos = this.start;
|
||
}
|
||
if (this.fd !== null) {
|
||
process.nextTick(function() {
|
||
self._read();
|
||
});
|
||
return;
|
||
}
|
||
fs.open(this.path, this.flags, this.mode, function(err, fd) {
|
||
if (err) {
|
||
self.emit("error", err);
|
||
self.readable = false;
|
||
return;
|
||
}
|
||
self.fd = fd;
|
||
self.emit("open", fd);
|
||
self._read();
|
||
});
|
||
}
|
||
function WriteStream(path, options) {
|
||
if (!(this instanceof WriteStream))
|
||
return new WriteStream(path, options);
|
||
Stream.call(this);
|
||
this.path = path;
|
||
this.fd = null;
|
||
this.writable = true;
|
||
this.flags = "w";
|
||
this.encoding = "binary";
|
||
this.mode = 438;
|
||
this.bytesWritten = 0;
|
||
options = options || {};
|
||
var keys = Object.keys(options);
|
||
for (var index = 0, length = keys.length; index < length; index++) {
|
||
var key = keys[index];
|
||
this[key] = options[key];
|
||
}
|
||
if (this.start !== void 0) {
|
||
if (typeof this.start !== "number") {
|
||
throw TypeError("start must be a Number");
|
||
}
|
||
if (this.start < 0) {
|
||
throw new Error("start must be >= zero");
|
||
}
|
||
this.pos = this.start;
|
||
}
|
||
this.busy = false;
|
||
this._queue = [];
|
||
if (this.fd === null) {
|
||
this._open = fs.open;
|
||
this._queue.push([this._open, this.path, this.flags, this.mode, void 0]);
|
||
this.flush();
|
||
}
|
||
}
|
||
}
|
||
}
|
||
});
|
||
|
||
// node_modules/graceful-fs/clone.js
|
||
var require_clone = __commonJS({
|
||
"node_modules/graceful-fs/clone.js"(exports, module2) {
|
||
"use strict";
|
||
module2.exports = clone;
|
||
var getPrototypeOf = Object.getPrototypeOf || function(obj) {
|
||
return obj.__proto__;
|
||
};
|
||
function clone(obj) {
|
||
if (obj === null || typeof obj !== "object")
|
||
return obj;
|
||
if (obj instanceof Object)
|
||
var copy = { __proto__: getPrototypeOf(obj) };
|
||
else
|
||
var copy = /* @__PURE__ */ Object.create(null);
|
||
Object.getOwnPropertyNames(obj).forEach(function(key) {
|
||
Object.defineProperty(copy, key, Object.getOwnPropertyDescriptor(obj, key));
|
||
});
|
||
return copy;
|
||
}
|
||
}
|
||
});
|
||
|
||
// node_modules/graceful-fs/graceful-fs.js
|
||
var require_graceful_fs = __commonJS({
|
||
"node_modules/graceful-fs/graceful-fs.js"(exports, module2) {
|
||
var fs = require("fs");
|
||
var polyfills = require_polyfills();
|
||
var legacy = require_legacy_streams();
|
||
var clone = require_clone();
|
||
var util = require("util");
|
||
var gracefulQueue;
|
||
var previousSymbol;
|
||
if (typeof Symbol === "function" && typeof Symbol.for === "function") {
|
||
gracefulQueue = Symbol.for("graceful-fs.queue");
|
||
previousSymbol = Symbol.for("graceful-fs.previous");
|
||
} else {
|
||
gracefulQueue = "___graceful-fs.queue";
|
||
previousSymbol = "___graceful-fs.previous";
|
||
}
|
||
function noop() {
|
||
}
|
||
function publishQueue(context, queue2) {
|
||
Object.defineProperty(context, gracefulQueue, {
|
||
get: function() {
|
||
return queue2;
|
||
}
|
||
});
|
||
}
|
||
var debug = noop;
|
||
if (util.debuglog)
|
||
debug = util.debuglog("gfs4");
|
||
else if (/\bgfs4\b/i.test(process.env.NODE_DEBUG || ""))
|
||
debug = function() {
|
||
var m = util.format.apply(util, arguments);
|
||
m = "GFS4: " + m.split(/\n/).join("\nGFS4: ");
|
||
console.error(m);
|
||
};
|
||
if (!fs[gracefulQueue]) {
|
||
queue = global[gracefulQueue] || [];
|
||
publishQueue(fs, queue);
|
||
fs.close = function(fs$close) {
|
||
function close(fd, cb) {
|
||
return fs$close.call(fs, fd, function(err) {
|
||
if (!err) {
|
||
resetQueue();
|
||
}
|
||
if (typeof cb === "function")
|
||
cb.apply(this, arguments);
|
||
});
|
||
}
|
||
Object.defineProperty(close, previousSymbol, {
|
||
value: fs$close
|
||
});
|
||
return close;
|
||
}(fs.close);
|
||
fs.closeSync = function(fs$closeSync) {
|
||
function closeSync(fd) {
|
||
fs$closeSync.apply(fs, arguments);
|
||
resetQueue();
|
||
}
|
||
Object.defineProperty(closeSync, previousSymbol, {
|
||
value: fs$closeSync
|
||
});
|
||
return closeSync;
|
||
}(fs.closeSync);
|
||
if (/\bgfs4\b/i.test(process.env.NODE_DEBUG || "")) {
|
||
process.on("exit", function() {
|
||
debug(fs[gracefulQueue]);
|
||
require("assert").equal(fs[gracefulQueue].length, 0);
|
||
});
|
||
}
|
||
}
|
||
var queue;
|
||
if (!global[gracefulQueue]) {
|
||
publishQueue(global, fs[gracefulQueue]);
|
||
}
|
||
module2.exports = patch(clone(fs));
|
||
if (process.env.TEST_GRACEFUL_FS_GLOBAL_PATCH && !fs.__patched) {
|
||
module2.exports = patch(fs);
|
||
fs.__patched = true;
|
||
}
|
||
function patch(fs2) {
|
||
polyfills(fs2);
|
||
fs2.gracefulify = patch;
|
||
fs2.createReadStream = createReadStream;
|
||
fs2.createWriteStream = createWriteStream;
|
||
var fs$readFile = fs2.readFile;
|
||
fs2.readFile = readFile;
|
||
function readFile(path, options, cb) {
|
||
if (typeof options === "function")
|
||
cb = options, options = null;
|
||
return go$readFile(path, options, cb);
|
||
function go$readFile(path2, options2, cb2, startTime) {
|
||
return fs$readFile(path2, options2, function(err) {
|
||
if (err && (err.code === "EMFILE" || err.code === "ENFILE"))
|
||
enqueue([go$readFile, [path2, options2, cb2], err, startTime || Date.now(), Date.now()]);
|
||
else {
|
||
if (typeof cb2 === "function")
|
||
cb2.apply(this, arguments);
|
||
}
|
||
});
|
||
}
|
||
}
|
||
var fs$writeFile = fs2.writeFile;
|
||
fs2.writeFile = writeFile2;
|
||
function writeFile2(path, data, options, cb) {
|
||
if (typeof options === "function")
|
||
cb = options, options = null;
|
||
return go$writeFile(path, data, options, cb);
|
||
function go$writeFile(path2, data2, options2, cb2, startTime) {
|
||
return fs$writeFile(path2, data2, options2, function(err) {
|
||
if (err && (err.code === "EMFILE" || err.code === "ENFILE"))
|
||
enqueue([go$writeFile, [path2, data2, options2, cb2], err, startTime || Date.now(), Date.now()]);
|
||
else {
|
||
if (typeof cb2 === "function")
|
||
cb2.apply(this, arguments);
|
||
}
|
||
});
|
||
}
|
||
}
|
||
var fs$appendFile = fs2.appendFile;
|
||
if (fs$appendFile)
|
||
fs2.appendFile = appendFile;
|
||
function appendFile(path, data, options, cb) {
|
||
if (typeof options === "function")
|
||
cb = options, options = null;
|
||
return go$appendFile(path, data, options, cb);
|
||
function go$appendFile(path2, data2, options2, cb2, startTime) {
|
||
return fs$appendFile(path2, data2, options2, function(err) {
|
||
if (err && (err.code === "EMFILE" || err.code === "ENFILE"))
|
||
enqueue([go$appendFile, [path2, data2, options2, cb2], err, startTime || Date.now(), Date.now()]);
|
||
else {
|
||
if (typeof cb2 === "function")
|
||
cb2.apply(this, arguments);
|
||
}
|
||
});
|
||
}
|
||
}
|
||
var fs$copyFile = fs2.copyFile;
|
||
if (fs$copyFile)
|
||
fs2.copyFile = copyFile;
|
||
function copyFile(src, dest, flags, cb) {
|
||
if (typeof flags === "function") {
|
||
cb = flags;
|
||
flags = 0;
|
||
}
|
||
return go$copyFile(src, dest, flags, cb);
|
||
function go$copyFile(src2, dest2, flags2, cb2, startTime) {
|
||
return fs$copyFile(src2, dest2, flags2, function(err) {
|
||
if (err && (err.code === "EMFILE" || err.code === "ENFILE"))
|
||
enqueue([go$copyFile, [src2, dest2, flags2, cb2], err, startTime || Date.now(), Date.now()]);
|
||
else {
|
||
if (typeof cb2 === "function")
|
||
cb2.apply(this, arguments);
|
||
}
|
||
});
|
||
}
|
||
}
|
||
var fs$readdir = fs2.readdir;
|
||
fs2.readdir = readdir;
|
||
function readdir(path, options, cb) {
|
||
if (typeof options === "function")
|
||
cb = options, options = null;
|
||
return go$readdir(path, options, cb);
|
||
function go$readdir(path2, options2, cb2, startTime) {
|
||
return fs$readdir(path2, options2, function(err, files) {
|
||
if (err && (err.code === "EMFILE" || err.code === "ENFILE"))
|
||
enqueue([go$readdir, [path2, options2, cb2], err, startTime || Date.now(), Date.now()]);
|
||
else {
|
||
if (files && files.sort)
|
||
files.sort();
|
||
if (typeof cb2 === "function")
|
||
cb2.call(this, err, files);
|
||
}
|
||
});
|
||
}
|
||
}
|
||
if (process.version.substr(0, 4) === "v0.8") {
|
||
var legStreams = legacy(fs2);
|
||
ReadStream = legStreams.ReadStream;
|
||
WriteStream = legStreams.WriteStream;
|
||
}
|
||
var fs$ReadStream = fs2.ReadStream;
|
||
if (fs$ReadStream) {
|
||
ReadStream.prototype = Object.create(fs$ReadStream.prototype);
|
||
ReadStream.prototype.open = ReadStream$open;
|
||
}
|
||
var fs$WriteStream = fs2.WriteStream;
|
||
if (fs$WriteStream) {
|
||
WriteStream.prototype = Object.create(fs$WriteStream.prototype);
|
||
WriteStream.prototype.open = WriteStream$open;
|
||
}
|
||
Object.defineProperty(fs2, "ReadStream", {
|
||
get: function() {
|
||
return ReadStream;
|
||
},
|
||
set: function(val) {
|
||
ReadStream = val;
|
||
},
|
||
enumerable: true,
|
||
configurable: true
|
||
});
|
||
Object.defineProperty(fs2, "WriteStream", {
|
||
get: function() {
|
||
return WriteStream;
|
||
},
|
||
set: function(val) {
|
||
WriteStream = val;
|
||
},
|
||
enumerable: true,
|
||
configurable: true
|
||
});
|
||
var FileReadStream = ReadStream;
|
||
Object.defineProperty(fs2, "FileReadStream", {
|
||
get: function() {
|
||
return FileReadStream;
|
||
},
|
||
set: function(val) {
|
||
FileReadStream = val;
|
||
},
|
||
enumerable: true,
|
||
configurable: true
|
||
});
|
||
var FileWriteStream = WriteStream;
|
||
Object.defineProperty(fs2, "FileWriteStream", {
|
||
get: function() {
|
||
return FileWriteStream;
|
||
},
|
||
set: function(val) {
|
||
FileWriteStream = val;
|
||
},
|
||
enumerable: true,
|
||
configurable: true
|
||
});
|
||
function ReadStream(path, options) {
|
||
if (this instanceof ReadStream)
|
||
return fs$ReadStream.apply(this, arguments), this;
|
||
else
|
||
return ReadStream.apply(Object.create(ReadStream.prototype), arguments);
|
||
}
|
||
function ReadStream$open() {
|
||
var that = this;
|
||
open(that.path, that.flags, that.mode, function(err, fd) {
|
||
if (err) {
|
||
if (that.autoClose)
|
||
that.destroy();
|
||
that.emit("error", err);
|
||
} else {
|
||
that.fd = fd;
|
||
that.emit("open", fd);
|
||
that.read();
|
||
}
|
||
});
|
||
}
|
||
function WriteStream(path, options) {
|
||
if (this instanceof WriteStream)
|
||
return fs$WriteStream.apply(this, arguments), this;
|
||
else
|
||
return WriteStream.apply(Object.create(WriteStream.prototype), arguments);
|
||
}
|
||
function WriteStream$open() {
|
||
var that = this;
|
||
open(that.path, that.flags, that.mode, function(err, fd) {
|
||
if (err) {
|
||
that.destroy();
|
||
that.emit("error", err);
|
||
} else {
|
||
that.fd = fd;
|
||
that.emit("open", fd);
|
||
}
|
||
});
|
||
}
|
||
function createReadStream(path, options) {
|
||
return new fs2.ReadStream(path, options);
|
||
}
|
||
function createWriteStream(path, options) {
|
||
return new fs2.WriteStream(path, options);
|
||
}
|
||
var fs$open = fs2.open;
|
||
fs2.open = open;
|
||
function open(path, flags, mode, cb) {
|
||
if (typeof mode === "function")
|
||
cb = mode, mode = null;
|
||
return go$open(path, flags, mode, cb);
|
||
function go$open(path2, flags2, mode2, cb2, startTime) {
|
||
return fs$open(path2, flags2, mode2, function(err, fd) {
|
||
if (err && (err.code === "EMFILE" || err.code === "ENFILE"))
|
||
enqueue([go$open, [path2, flags2, mode2, cb2], err, startTime || Date.now(), Date.now()]);
|
||
else {
|
||
if (typeof cb2 === "function")
|
||
cb2.apply(this, arguments);
|
||
}
|
||
});
|
||
}
|
||
}
|
||
return fs2;
|
||
}
|
||
function enqueue(elem) {
|
||
debug("ENQUEUE", elem[0].name, elem[1]);
|
||
fs[gracefulQueue].push(elem);
|
||
retry();
|
||
}
|
||
var retryTimer;
|
||
function resetQueue() {
|
||
var now = Date.now();
|
||
for (var i = 0; i < fs[gracefulQueue].length; ++i) {
|
||
if (fs[gracefulQueue][i].length > 2) {
|
||
fs[gracefulQueue][i][3] = now;
|
||
fs[gracefulQueue][i][4] = now;
|
||
}
|
||
}
|
||
retry();
|
||
}
|
||
function retry() {
|
||
clearTimeout(retryTimer);
|
||
retryTimer = void 0;
|
||
if (fs[gracefulQueue].length === 0)
|
||
return;
|
||
var elem = fs[gracefulQueue].shift();
|
||
var fn = elem[0];
|
||
var args = elem[1];
|
||
var err = elem[2];
|
||
var startTime = elem[3];
|
||
var lastTime = elem[4];
|
||
if (startTime === void 0) {
|
||
debug("RETRY", fn.name, args);
|
||
fn.apply(null, args);
|
||
} else if (Date.now() - startTime >= 6e4) {
|
||
debug("TIMEOUT", fn.name, args);
|
||
var cb = args.pop();
|
||
if (typeof cb === "function")
|
||
cb.call(null, err);
|
||
} else {
|
||
var sinceAttempt = Date.now() - lastTime;
|
||
var sinceStart = Math.max(lastTime - startTime, 1);
|
||
var desiredDelay = Math.min(sinceStart * 1.2, 100);
|
||
if (sinceAttempt >= desiredDelay) {
|
||
debug("RETRY", fn.name, args);
|
||
fn.apply(null, args.concat([startTime]));
|
||
} else {
|
||
fs[gracefulQueue].push(elem);
|
||
}
|
||
}
|
||
if (retryTimer === void 0) {
|
||
retryTimer = setTimeout(retry, 0);
|
||
}
|
||
}
|
||
}
|
||
});
|
||
|
||
// node_modules/fs-extra/lib/fs/index.js
|
||
var require_fs = __commonJS({
|
||
"node_modules/fs-extra/lib/fs/index.js"(exports) {
|
||
"use strict";
|
||
var u = require_universalify().fromCallback;
|
||
var fs = require_graceful_fs();
|
||
var api = [
|
||
"access",
|
||
"appendFile",
|
||
"chmod",
|
||
"chown",
|
||
"close",
|
||
"copyFile",
|
||
"fchmod",
|
||
"fchown",
|
||
"fdatasync",
|
||
"fstat",
|
||
"fsync",
|
||
"ftruncate",
|
||
"futimes",
|
||
"lchmod",
|
||
"lchown",
|
||
"link",
|
||
"lstat",
|
||
"mkdir",
|
||
"mkdtemp",
|
||
"open",
|
||
"opendir",
|
||
"readdir",
|
||
"readFile",
|
||
"readlink",
|
||
"realpath",
|
||
"rename",
|
||
"rm",
|
||
"rmdir",
|
||
"stat",
|
||
"symlink",
|
||
"truncate",
|
||
"unlink",
|
||
"utimes",
|
||
"writeFile"
|
||
].filter((key) => {
|
||
return typeof fs[key] === "function";
|
||
});
|
||
Object.assign(exports, fs);
|
||
api.forEach((method) => {
|
||
exports[method] = u(fs[method]);
|
||
});
|
||
exports.realpath.native = u(fs.realpath.native);
|
||
exports.exists = function(filename, callback) {
|
||
if (typeof callback === "function") {
|
||
return fs.exists(filename, callback);
|
||
}
|
||
return new Promise((resolve6) => {
|
||
return fs.exists(filename, resolve6);
|
||
});
|
||
};
|
||
exports.read = function(fd, buffer, offset, length, position, callback) {
|
||
if (typeof callback === "function") {
|
||
return fs.read(fd, buffer, offset, length, position, callback);
|
||
}
|
||
return new Promise((resolve6, reject) => {
|
||
fs.read(fd, buffer, offset, length, position, (err, bytesRead, buffer2) => {
|
||
if (err)
|
||
return reject(err);
|
||
resolve6({ bytesRead, buffer: buffer2 });
|
||
});
|
||
});
|
||
};
|
||
exports.write = function(fd, buffer, ...args) {
|
||
if (typeof args[args.length - 1] === "function") {
|
||
return fs.write(fd, buffer, ...args);
|
||
}
|
||
return new Promise((resolve6, reject) => {
|
||
fs.write(fd, buffer, ...args, (err, bytesWritten, buffer2) => {
|
||
if (err)
|
||
return reject(err);
|
||
resolve6({ bytesWritten, buffer: buffer2 });
|
||
});
|
||
});
|
||
};
|
||
if (typeof fs.writev === "function") {
|
||
exports.writev = function(fd, buffers, ...args) {
|
||
if (typeof args[args.length - 1] === "function") {
|
||
return fs.writev(fd, buffers, ...args);
|
||
}
|
||
return new Promise((resolve6, reject) => {
|
||
fs.writev(fd, buffers, ...args, (err, bytesWritten, buffers2) => {
|
||
if (err)
|
||
return reject(err);
|
||
resolve6({ bytesWritten, buffers: buffers2 });
|
||
});
|
||
});
|
||
};
|
||
}
|
||
}
|
||
});
|
||
|
||
// node_modules/fs-extra/lib/mkdirs/utils.js
|
||
var require_utils = __commonJS({
|
||
"node_modules/fs-extra/lib/mkdirs/utils.js"(exports, module2) {
|
||
"use strict";
|
||
var path = require("path");
|
||
module2.exports.checkPath = function checkPath(pth) {
|
||
if (process.platform === "win32") {
|
||
const pathHasInvalidWinCharacters = /[<>:"|?*]/.test(pth.replace(path.parse(pth).root, ""));
|
||
if (pathHasInvalidWinCharacters) {
|
||
const error = new Error(`Path contains invalid characters: ${pth}`);
|
||
error.code = "EINVAL";
|
||
throw error;
|
||
}
|
||
}
|
||
};
|
||
}
|
||
});
|
||
|
||
// node_modules/fs-extra/lib/mkdirs/make-dir.js
|
||
var require_make_dir = __commonJS({
|
||
"node_modules/fs-extra/lib/mkdirs/make-dir.js"(exports, module2) {
|
||
"use strict";
|
||
var fs = require_fs();
|
||
var { checkPath } = require_utils();
|
||
var getMode = (options) => {
|
||
const defaults = { mode: 511 };
|
||
if (typeof options === "number")
|
||
return options;
|
||
return __spreadValues(__spreadValues({}, defaults), options).mode;
|
||
};
|
||
module2.exports.makeDir = async (dir, options) => {
|
||
checkPath(dir);
|
||
return fs.mkdir(dir, {
|
||
mode: getMode(options),
|
||
recursive: true
|
||
});
|
||
};
|
||
module2.exports.makeDirSync = (dir, options) => {
|
||
checkPath(dir);
|
||
return fs.mkdirSync(dir, {
|
||
mode: getMode(options),
|
||
recursive: true
|
||
});
|
||
};
|
||
}
|
||
});
|
||
|
||
// node_modules/fs-extra/lib/mkdirs/index.js
|
||
var require_mkdirs = __commonJS({
|
||
"node_modules/fs-extra/lib/mkdirs/index.js"(exports, module2) {
|
||
"use strict";
|
||
var u = require_universalify().fromPromise;
|
||
var { makeDir: _makeDir, makeDirSync } = require_make_dir();
|
||
var makeDir = u(_makeDir);
|
||
module2.exports = {
|
||
mkdirs: makeDir,
|
||
mkdirsSync: makeDirSync,
|
||
mkdirp: makeDir,
|
||
mkdirpSync: makeDirSync,
|
||
ensureDir: makeDir,
|
||
ensureDirSync: makeDirSync
|
||
};
|
||
}
|
||
});
|
||
|
||
// node_modules/fs-extra/lib/util/utimes.js
|
||
var require_utimes = __commonJS({
|
||
"node_modules/fs-extra/lib/util/utimes.js"(exports, module2) {
|
||
"use strict";
|
||
var fs = require_graceful_fs();
|
||
function utimesMillis(path, atime, mtime, callback) {
|
||
fs.open(path, "r+", (err, fd) => {
|
||
if (err)
|
||
return callback(err);
|
||
fs.futimes(fd, atime, mtime, (futimesErr) => {
|
||
fs.close(fd, (closeErr) => {
|
||
if (callback)
|
||
callback(futimesErr || closeErr);
|
||
});
|
||
});
|
||
});
|
||
}
|
||
function utimesMillisSync(path, atime, mtime) {
|
||
const fd = fs.openSync(path, "r+");
|
||
fs.futimesSync(fd, atime, mtime);
|
||
return fs.closeSync(fd);
|
||
}
|
||
module2.exports = {
|
||
utimesMillis,
|
||
utimesMillisSync
|
||
};
|
||
}
|
||
});
|
||
|
||
// node_modules/fs-extra/lib/util/stat.js
|
||
var require_stat = __commonJS({
|
||
"node_modules/fs-extra/lib/util/stat.js"(exports, module2) {
|
||
"use strict";
|
||
var fs = require_fs();
|
||
var path = require("path");
|
||
var util = require("util");
|
||
function getStats(src, dest, opts) {
|
||
const statFunc = opts.dereference ? (file) => fs.stat(file, { bigint: true }) : (file) => fs.lstat(file, { bigint: true });
|
||
return Promise.all([
|
||
statFunc(src),
|
||
statFunc(dest).catch((err) => {
|
||
if (err.code === "ENOENT")
|
||
return null;
|
||
throw err;
|
||
})
|
||
]).then(([srcStat, destStat]) => ({ srcStat, destStat }));
|
||
}
|
||
function getStatsSync(src, dest, opts) {
|
||
let destStat;
|
||
const statFunc = opts.dereference ? (file) => fs.statSync(file, { bigint: true }) : (file) => fs.lstatSync(file, { bigint: true });
|
||
const srcStat = statFunc(src);
|
||
try {
|
||
destStat = statFunc(dest);
|
||
} catch (err) {
|
||
if (err.code === "ENOENT")
|
||
return { srcStat, destStat: null };
|
||
throw err;
|
||
}
|
||
return { srcStat, destStat };
|
||
}
|
||
function checkPaths(src, dest, funcName, opts, cb) {
|
||
util.callbackify(getStats)(src, dest, opts, (err, stats) => {
|
||
if (err)
|
||
return cb(err);
|
||
const { srcStat, destStat } = stats;
|
||
if (destStat) {
|
||
if (areIdentical(srcStat, destStat)) {
|
||
const srcBaseName = path.basename(src);
|
||
const destBaseName = path.basename(dest);
|
||
if (funcName === "move" && srcBaseName !== destBaseName && srcBaseName.toLowerCase() === destBaseName.toLowerCase()) {
|
||
return cb(null, { srcStat, destStat, isChangingCase: true });
|
||
}
|
||
return cb(new Error("Source and destination must not be the same."));
|
||
}
|
||
if (srcStat.isDirectory() && !destStat.isDirectory()) {
|
||
return cb(new Error(`Cannot overwrite non-directory '${dest}' with directory '${src}'.`));
|
||
}
|
||
if (!srcStat.isDirectory() && destStat.isDirectory()) {
|
||
return cb(new Error(`Cannot overwrite directory '${dest}' with non-directory '${src}'.`));
|
||
}
|
||
}
|
||
if (srcStat.isDirectory() && isSrcSubdir(src, dest)) {
|
||
return cb(new Error(errMsg(src, dest, funcName)));
|
||
}
|
||
return cb(null, { srcStat, destStat });
|
||
});
|
||
}
|
||
function checkPathsSync(src, dest, funcName, opts) {
|
||
const { srcStat, destStat } = getStatsSync(src, dest, opts);
|
||
if (destStat) {
|
||
if (areIdentical(srcStat, destStat)) {
|
||
const srcBaseName = path.basename(src);
|
||
const destBaseName = path.basename(dest);
|
||
if (funcName === "move" && srcBaseName !== destBaseName && srcBaseName.toLowerCase() === destBaseName.toLowerCase()) {
|
||
return { srcStat, destStat, isChangingCase: true };
|
||
}
|
||
throw new Error("Source and destination must not be the same.");
|
||
}
|
||
if (srcStat.isDirectory() && !destStat.isDirectory()) {
|
||
throw new Error(`Cannot overwrite non-directory '${dest}' with directory '${src}'.`);
|
||
}
|
||
if (!srcStat.isDirectory() && destStat.isDirectory()) {
|
||
throw new Error(`Cannot overwrite directory '${dest}' with non-directory '${src}'.`);
|
||
}
|
||
}
|
||
if (srcStat.isDirectory() && isSrcSubdir(src, dest)) {
|
||
throw new Error(errMsg(src, dest, funcName));
|
||
}
|
||
return { srcStat, destStat };
|
||
}
|
||
function checkParentPaths(src, srcStat, dest, funcName, cb) {
|
||
const srcParent = path.resolve(path.dirname(src));
|
||
const destParent = path.resolve(path.dirname(dest));
|
||
if (destParent === srcParent || destParent === path.parse(destParent).root)
|
||
return cb();
|
||
fs.stat(destParent, { bigint: true }, (err, destStat) => {
|
||
if (err) {
|
||
if (err.code === "ENOENT")
|
||
return cb();
|
||
return cb(err);
|
||
}
|
||
if (areIdentical(srcStat, destStat)) {
|
||
return cb(new Error(errMsg(src, dest, funcName)));
|
||
}
|
||
return checkParentPaths(src, srcStat, destParent, funcName, cb);
|
||
});
|
||
}
|
||
function checkParentPathsSync(src, srcStat, dest, funcName) {
|
||
const srcParent = path.resolve(path.dirname(src));
|
||
const destParent = path.resolve(path.dirname(dest));
|
||
if (destParent === srcParent || destParent === path.parse(destParent).root)
|
||
return;
|
||
let destStat;
|
||
try {
|
||
destStat = fs.statSync(destParent, { bigint: true });
|
||
} catch (err) {
|
||
if (err.code === "ENOENT")
|
||
return;
|
||
throw err;
|
||
}
|
||
if (areIdentical(srcStat, destStat)) {
|
||
throw new Error(errMsg(src, dest, funcName));
|
||
}
|
||
return checkParentPathsSync(src, srcStat, destParent, funcName);
|
||
}
|
||
function areIdentical(srcStat, destStat) {
|
||
return destStat.ino && destStat.dev && destStat.ino === srcStat.ino && destStat.dev === srcStat.dev;
|
||
}
|
||
function isSrcSubdir(src, dest) {
|
||
const srcArr = path.resolve(src).split(path.sep).filter((i) => i);
|
||
const destArr = path.resolve(dest).split(path.sep).filter((i) => i);
|
||
return srcArr.reduce((acc, cur, i) => acc && destArr[i] === cur, true);
|
||
}
|
||
function errMsg(src, dest, funcName) {
|
||
return `Cannot ${funcName} '${src}' to a subdirectory of itself, '${dest}'.`;
|
||
}
|
||
module2.exports = {
|
||
checkPaths,
|
||
checkPathsSync,
|
||
checkParentPaths,
|
||
checkParentPathsSync,
|
||
isSrcSubdir,
|
||
areIdentical
|
||
};
|
||
}
|
||
});
|
||
|
||
// node_modules/fs-extra/lib/copy-sync/copy-sync.js
|
||
var require_copy_sync = __commonJS({
|
||
"node_modules/fs-extra/lib/copy-sync/copy-sync.js"(exports, module2) {
|
||
"use strict";
|
||
var fs = require_graceful_fs();
|
||
var path = require("path");
|
||
var mkdirsSync = require_mkdirs().mkdirsSync;
|
||
var utimesMillisSync = require_utimes().utimesMillisSync;
|
||
var stat = require_stat();
|
||
function copySync2(src, dest, opts) {
|
||
if (typeof opts === "function") {
|
||
opts = { filter: opts };
|
||
}
|
||
opts = opts || {};
|
||
opts.clobber = "clobber" in opts ? !!opts.clobber : true;
|
||
opts.overwrite = "overwrite" in opts ? !!opts.overwrite : opts.clobber;
|
||
if (opts.preserveTimestamps && process.arch === "ia32") {
|
||
console.warn(`fs-extra: Using the preserveTimestamps option in 32-bit node is not recommended;
|
||
|
||
see https://github.com/jprichardson/node-fs-extra/issues/269`);
|
||
}
|
||
const { srcStat, destStat } = stat.checkPathsSync(src, dest, "copy", opts);
|
||
stat.checkParentPathsSync(src, srcStat, dest, "copy");
|
||
return handleFilterAndCopy(destStat, src, dest, opts);
|
||
}
|
||
function handleFilterAndCopy(destStat, src, dest, opts) {
|
||
if (opts.filter && !opts.filter(src, dest))
|
||
return;
|
||
const destParent = path.dirname(dest);
|
||
if (!fs.existsSync(destParent))
|
||
mkdirsSync(destParent);
|
||
return getStats(destStat, src, dest, opts);
|
||
}
|
||
function startCopy(destStat, src, dest, opts) {
|
||
if (opts.filter && !opts.filter(src, dest))
|
||
return;
|
||
return getStats(destStat, src, dest, opts);
|
||
}
|
||
function getStats(destStat, src, dest, opts) {
|
||
const statSync3 = opts.dereference ? fs.statSync : fs.lstatSync;
|
||
const srcStat = statSync3(src);
|
||
if (srcStat.isDirectory())
|
||
return onDir(srcStat, destStat, src, dest, opts);
|
||
else if (srcStat.isFile() || srcStat.isCharacterDevice() || srcStat.isBlockDevice())
|
||
return onFile(srcStat, destStat, src, dest, opts);
|
||
else if (srcStat.isSymbolicLink())
|
||
return onLink(destStat, src, dest, opts);
|
||
else if (srcStat.isSocket())
|
||
throw new Error(`Cannot copy a socket file: ${src}`);
|
||
else if (srcStat.isFIFO())
|
||
throw new Error(`Cannot copy a FIFO pipe: ${src}`);
|
||
throw new Error(`Unknown file: ${src}`);
|
||
}
|
||
function onFile(srcStat, destStat, src, dest, opts) {
|
||
if (!destStat)
|
||
return copyFile(srcStat, src, dest, opts);
|
||
return mayCopyFile(srcStat, src, dest, opts);
|
||
}
|
||
function mayCopyFile(srcStat, src, dest, opts) {
|
||
if (opts.overwrite) {
|
||
fs.unlinkSync(dest);
|
||
return copyFile(srcStat, src, dest, opts);
|
||
} else if (opts.errorOnExist) {
|
||
throw new Error(`'${dest}' already exists`);
|
||
}
|
||
}
|
||
function copyFile(srcStat, src, dest, opts) {
|
||
fs.copyFileSync(src, dest);
|
||
if (opts.preserveTimestamps)
|
||
handleTimestamps(srcStat.mode, src, dest);
|
||
return setDestMode(dest, srcStat.mode);
|
||
}
|
||
function handleTimestamps(srcMode, src, dest) {
|
||
if (fileIsNotWritable(srcMode))
|
||
makeFileWritable(dest, srcMode);
|
||
return setDestTimestamps(src, dest);
|
||
}
|
||
function fileIsNotWritable(srcMode) {
|
||
return (srcMode & 128) === 0;
|
||
}
|
||
function makeFileWritable(dest, srcMode) {
|
||
return setDestMode(dest, srcMode | 128);
|
||
}
|
||
function setDestMode(dest, srcMode) {
|
||
return fs.chmodSync(dest, srcMode);
|
||
}
|
||
function setDestTimestamps(src, dest) {
|
||
const updatedSrcStat = fs.statSync(src);
|
||
return utimesMillisSync(dest, updatedSrcStat.atime, updatedSrcStat.mtime);
|
||
}
|
||
function onDir(srcStat, destStat, src, dest, opts) {
|
||
if (!destStat)
|
||
return mkDirAndCopy(srcStat.mode, src, dest, opts);
|
||
return copyDir(src, dest, opts);
|
||
}
|
||
function mkDirAndCopy(srcMode, src, dest, opts) {
|
||
fs.mkdirSync(dest);
|
||
copyDir(src, dest, opts);
|
||
return setDestMode(dest, srcMode);
|
||
}
|
||
function copyDir(src, dest, opts) {
|
||
fs.readdirSync(src).forEach((item) => copyDirItem(item, src, dest, opts));
|
||
}
|
||
function copyDirItem(item, src, dest, opts) {
|
||
const srcItem = path.join(src, item);
|
||
const destItem = path.join(dest, item);
|
||
const { destStat } = stat.checkPathsSync(srcItem, destItem, "copy", opts);
|
||
return startCopy(destStat, srcItem, destItem, opts);
|
||
}
|
||
function onLink(destStat, src, dest, opts) {
|
||
let resolvedSrc = fs.readlinkSync(src);
|
||
if (opts.dereference) {
|
||
resolvedSrc = path.resolve(process.cwd(), resolvedSrc);
|
||
}
|
||
if (!destStat) {
|
||
return fs.symlinkSync(resolvedSrc, dest);
|
||
} else {
|
||
let resolvedDest;
|
||
try {
|
||
resolvedDest = fs.readlinkSync(dest);
|
||
} catch (err) {
|
||
if (err.code === "EINVAL" || err.code === "UNKNOWN")
|
||
return fs.symlinkSync(resolvedSrc, dest);
|
||
throw err;
|
||
}
|
||
if (opts.dereference) {
|
||
resolvedDest = path.resolve(process.cwd(), resolvedDest);
|
||
}
|
||
if (stat.isSrcSubdir(resolvedSrc, resolvedDest)) {
|
||
throw new Error(`Cannot copy '${resolvedSrc}' to a subdirectory of itself, '${resolvedDest}'.`);
|
||
}
|
||
if (fs.statSync(dest).isDirectory() && stat.isSrcSubdir(resolvedDest, resolvedSrc)) {
|
||
throw new Error(`Cannot overwrite '${resolvedDest}' with '${resolvedSrc}'.`);
|
||
}
|
||
return copyLink(resolvedSrc, dest);
|
||
}
|
||
}
|
||
function copyLink(resolvedSrc, dest) {
|
||
fs.unlinkSync(dest);
|
||
return fs.symlinkSync(resolvedSrc, dest);
|
||
}
|
||
module2.exports = copySync2;
|
||
}
|
||
});
|
||
|
||
// node_modules/fs-extra/lib/copy-sync/index.js
|
||
var require_copy_sync2 = __commonJS({
|
||
"node_modules/fs-extra/lib/copy-sync/index.js"(exports, module2) {
|
||
"use strict";
|
||
module2.exports = {
|
||
copySync: require_copy_sync()
|
||
};
|
||
}
|
||
});
|
||
|
||
// node_modules/fs-extra/lib/path-exists/index.js
|
||
var require_path_exists = __commonJS({
|
||
"node_modules/fs-extra/lib/path-exists/index.js"(exports, module2) {
|
||
"use strict";
|
||
var u = require_universalify().fromPromise;
|
||
var fs = require_fs();
|
||
function pathExists(path) {
|
||
return fs.access(path).then(() => true).catch(() => false);
|
||
}
|
||
module2.exports = {
|
||
pathExists: u(pathExists),
|
||
pathExistsSync: fs.existsSync
|
||
};
|
||
}
|
||
});
|
||
|
||
// node_modules/fs-extra/lib/copy/copy.js
|
||
var require_copy = __commonJS({
|
||
"node_modules/fs-extra/lib/copy/copy.js"(exports, module2) {
|
||
"use strict";
|
||
var fs = require_graceful_fs();
|
||
var path = require("path");
|
||
var mkdirs = require_mkdirs().mkdirs;
|
||
var pathExists = require_path_exists().pathExists;
|
||
var utimesMillis = require_utimes().utimesMillis;
|
||
var stat = require_stat();
|
||
function copy(src, dest, opts, cb) {
|
||
if (typeof opts === "function" && !cb) {
|
||
cb = opts;
|
||
opts = {};
|
||
} else if (typeof opts === "function") {
|
||
opts = { filter: opts };
|
||
}
|
||
cb = cb || function() {
|
||
};
|
||
opts = opts || {};
|
||
opts.clobber = "clobber" in opts ? !!opts.clobber : true;
|
||
opts.overwrite = "overwrite" in opts ? !!opts.overwrite : opts.clobber;
|
||
if (opts.preserveTimestamps && process.arch === "ia32") {
|
||
console.warn(`fs-extra: Using the preserveTimestamps option in 32-bit node is not recommended;
|
||
|
||
see https://github.com/jprichardson/node-fs-extra/issues/269`);
|
||
}
|
||
stat.checkPaths(src, dest, "copy", opts, (err, stats) => {
|
||
if (err)
|
||
return cb(err);
|
||
const { srcStat, destStat } = stats;
|
||
stat.checkParentPaths(src, srcStat, dest, "copy", (err2) => {
|
||
if (err2)
|
||
return cb(err2);
|
||
if (opts.filter)
|
||
return handleFilter(checkParentDir, destStat, src, dest, opts, cb);
|
||
return checkParentDir(destStat, src, dest, opts, cb);
|
||
});
|
||
});
|
||
}
|
||
function checkParentDir(destStat, src, dest, opts, cb) {
|
||
const destParent = path.dirname(dest);
|
||
pathExists(destParent, (err, dirExists) => {
|
||
if (err)
|
||
return cb(err);
|
||
if (dirExists)
|
||
return getStats(destStat, src, dest, opts, cb);
|
||
mkdirs(destParent, (err2) => {
|
||
if (err2)
|
||
return cb(err2);
|
||
return getStats(destStat, src, dest, opts, cb);
|
||
});
|
||
});
|
||
}
|
||
function handleFilter(onInclude, destStat, src, dest, opts, cb) {
|
||
Promise.resolve(opts.filter(src, dest)).then((include) => {
|
||
if (include)
|
||
return onInclude(destStat, src, dest, opts, cb);
|
||
return cb();
|
||
}, (error) => cb(error));
|
||
}
|
||
function startCopy(destStat, src, dest, opts, cb) {
|
||
if (opts.filter)
|
||
return handleFilter(getStats, destStat, src, dest, opts, cb);
|
||
return getStats(destStat, src, dest, opts, cb);
|
||
}
|
||
function getStats(destStat, src, dest, opts, cb) {
|
||
const stat2 = opts.dereference ? fs.stat : fs.lstat;
|
||
stat2(src, (err, srcStat) => {
|
||
if (err)
|
||
return cb(err);
|
||
if (srcStat.isDirectory())
|
||
return onDir(srcStat, destStat, src, dest, opts, cb);
|
||
else if (srcStat.isFile() || srcStat.isCharacterDevice() || srcStat.isBlockDevice())
|
||
return onFile(srcStat, destStat, src, dest, opts, cb);
|
||
else if (srcStat.isSymbolicLink())
|
||
return onLink(destStat, src, dest, opts, cb);
|
||
else if (srcStat.isSocket())
|
||
return cb(new Error(`Cannot copy a socket file: ${src}`));
|
||
else if (srcStat.isFIFO())
|
||
return cb(new Error(`Cannot copy a FIFO pipe: ${src}`));
|
||
return cb(new Error(`Unknown file: ${src}`));
|
||
});
|
||
}
|
||
function onFile(srcStat, destStat, src, dest, opts, cb) {
|
||
if (!destStat)
|
||
return copyFile(srcStat, src, dest, opts, cb);
|
||
return mayCopyFile(srcStat, src, dest, opts, cb);
|
||
}
|
||
function mayCopyFile(srcStat, src, dest, opts, cb) {
|
||
if (opts.overwrite) {
|
||
fs.unlink(dest, (err) => {
|
||
if (err)
|
||
return cb(err);
|
||
return copyFile(srcStat, src, dest, opts, cb);
|
||
});
|
||
} else if (opts.errorOnExist) {
|
||
return cb(new Error(`'${dest}' already exists`));
|
||
} else
|
||
return cb();
|
||
}
|
||
function copyFile(srcStat, src, dest, opts, cb) {
|
||
fs.copyFile(src, dest, (err) => {
|
||
if (err)
|
||
return cb(err);
|
||
if (opts.preserveTimestamps)
|
||
return handleTimestampsAndMode(srcStat.mode, src, dest, cb);
|
||
return setDestMode(dest, srcStat.mode, cb);
|
||
});
|
||
}
|
||
function handleTimestampsAndMode(srcMode, src, dest, cb) {
|
||
if (fileIsNotWritable(srcMode)) {
|
||
return makeFileWritable(dest, srcMode, (err) => {
|
||
if (err)
|
||
return cb(err);
|
||
return setDestTimestampsAndMode(srcMode, src, dest, cb);
|
||
});
|
||
}
|
||
return setDestTimestampsAndMode(srcMode, src, dest, cb);
|
||
}
|
||
function fileIsNotWritable(srcMode) {
|
||
return (srcMode & 128) === 0;
|
||
}
|
||
function makeFileWritable(dest, srcMode, cb) {
|
||
return setDestMode(dest, srcMode | 128, cb);
|
||
}
|
||
function setDestTimestampsAndMode(srcMode, src, dest, cb) {
|
||
setDestTimestamps(src, dest, (err) => {
|
||
if (err)
|
||
return cb(err);
|
||
return setDestMode(dest, srcMode, cb);
|
||
});
|
||
}
|
||
function setDestMode(dest, srcMode, cb) {
|
||
return fs.chmod(dest, srcMode, cb);
|
||
}
|
||
function setDestTimestamps(src, dest, cb) {
|
||
fs.stat(src, (err, updatedSrcStat) => {
|
||
if (err)
|
||
return cb(err);
|
||
return utimesMillis(dest, updatedSrcStat.atime, updatedSrcStat.mtime, cb);
|
||
});
|
||
}
|
||
function onDir(srcStat, destStat, src, dest, opts, cb) {
|
||
if (!destStat)
|
||
return mkDirAndCopy(srcStat.mode, src, dest, opts, cb);
|
||
return copyDir(src, dest, opts, cb);
|
||
}
|
||
function mkDirAndCopy(srcMode, src, dest, opts, cb) {
|
||
fs.mkdir(dest, (err) => {
|
||
if (err)
|
||
return cb(err);
|
||
copyDir(src, dest, opts, (err2) => {
|
||
if (err2)
|
||
return cb(err2);
|
||
return setDestMode(dest, srcMode, cb);
|
||
});
|
||
});
|
||
}
|
||
function copyDir(src, dest, opts, cb) {
|
||
fs.readdir(src, (err, items) => {
|
||
if (err)
|
||
return cb(err);
|
||
return copyDirItems(items, src, dest, opts, cb);
|
||
});
|
||
}
|
||
function copyDirItems(items, src, dest, opts, cb) {
|
||
const item = items.pop();
|
||
if (!item)
|
||
return cb();
|
||
return copyDirItem(items, item, src, dest, opts, cb);
|
||
}
|
||
function copyDirItem(items, item, src, dest, opts, cb) {
|
||
const srcItem = path.join(src, item);
|
||
const destItem = path.join(dest, item);
|
||
stat.checkPaths(srcItem, destItem, "copy", opts, (err, stats) => {
|
||
if (err)
|
||
return cb(err);
|
||
const { destStat } = stats;
|
||
startCopy(destStat, srcItem, destItem, opts, (err2) => {
|
||
if (err2)
|
||
return cb(err2);
|
||
return copyDirItems(items, src, dest, opts, cb);
|
||
});
|
||
});
|
||
}
|
||
function onLink(destStat, src, dest, opts, cb) {
|
||
fs.readlink(src, (err, resolvedSrc) => {
|
||
if (err)
|
||
return cb(err);
|
||
if (opts.dereference) {
|
||
resolvedSrc = path.resolve(process.cwd(), resolvedSrc);
|
||
}
|
||
if (!destStat) {
|
||
return fs.symlink(resolvedSrc, dest, cb);
|
||
} else {
|
||
fs.readlink(dest, (err2, resolvedDest) => {
|
||
if (err2) {
|
||
if (err2.code === "EINVAL" || err2.code === "UNKNOWN")
|
||
return fs.symlink(resolvedSrc, dest, cb);
|
||
return cb(err2);
|
||
}
|
||
if (opts.dereference) {
|
||
resolvedDest = path.resolve(process.cwd(), resolvedDest);
|
||
}
|
||
if (stat.isSrcSubdir(resolvedSrc, resolvedDest)) {
|
||
return cb(new Error(`Cannot copy '${resolvedSrc}' to a subdirectory of itself, '${resolvedDest}'.`));
|
||
}
|
||
if (destStat.isDirectory() && stat.isSrcSubdir(resolvedDest, resolvedSrc)) {
|
||
return cb(new Error(`Cannot overwrite '${resolvedDest}' with '${resolvedSrc}'.`));
|
||
}
|
||
return copyLink(resolvedSrc, dest, cb);
|
||
});
|
||
}
|
||
});
|
||
}
|
||
function copyLink(resolvedSrc, dest, cb) {
|
||
fs.unlink(dest, (err) => {
|
||
if (err)
|
||
return cb(err);
|
||
return fs.symlink(resolvedSrc, dest, cb);
|
||
});
|
||
}
|
||
module2.exports = copy;
|
||
}
|
||
});
|
||
|
||
// node_modules/fs-extra/lib/copy/index.js
|
||
var require_copy2 = __commonJS({
|
||
"node_modules/fs-extra/lib/copy/index.js"(exports, module2) {
|
||
"use strict";
|
||
var u = require_universalify().fromCallback;
|
||
module2.exports = {
|
||
copy: u(require_copy())
|
||
};
|
||
}
|
||
});
|
||
|
||
// node_modules/fs-extra/lib/remove/rimraf.js
|
||
var require_rimraf = __commonJS({
|
||
"node_modules/fs-extra/lib/remove/rimraf.js"(exports, module2) {
|
||
"use strict";
|
||
var fs = require_graceful_fs();
|
||
var path = require("path");
|
||
var assert = require("assert");
|
||
var isWindows = process.platform === "win32";
|
||
function defaults(options) {
|
||
const methods = [
|
||
"unlink",
|
||
"chmod",
|
||
"stat",
|
||
"lstat",
|
||
"rmdir",
|
||
"readdir"
|
||
];
|
||
methods.forEach((m) => {
|
||
options[m] = options[m] || fs[m];
|
||
m = m + "Sync";
|
||
options[m] = options[m] || fs[m];
|
||
});
|
||
options.maxBusyTries = options.maxBusyTries || 3;
|
||
}
|
||
function rimraf(p, options, cb) {
|
||
let busyTries = 0;
|
||
if (typeof options === "function") {
|
||
cb = options;
|
||
options = {};
|
||
}
|
||
assert(p, "rimraf: missing path");
|
||
assert.strictEqual(typeof p, "string", "rimraf: path should be a string");
|
||
assert.strictEqual(typeof cb, "function", "rimraf: callback function required");
|
||
assert(options, "rimraf: invalid options argument provided");
|
||
assert.strictEqual(typeof options, "object", "rimraf: options should be object");
|
||
defaults(options);
|
||
rimraf_(p, options, function CB(er) {
|
||
if (er) {
|
||
if ((er.code === "EBUSY" || er.code === "ENOTEMPTY" || er.code === "EPERM") && busyTries < options.maxBusyTries) {
|
||
busyTries++;
|
||
const time = busyTries * 100;
|
||
return setTimeout(() => rimraf_(p, options, CB), time);
|
||
}
|
||
if (er.code === "ENOENT")
|
||
er = null;
|
||
}
|
||
cb(er);
|
||
});
|
||
}
|
||
function rimraf_(p, options, cb) {
|
||
assert(p);
|
||
assert(options);
|
||
assert(typeof cb === "function");
|
||
options.lstat(p, (er, st) => {
|
||
if (er && er.code === "ENOENT") {
|
||
return cb(null);
|
||
}
|
||
if (er && er.code === "EPERM" && isWindows) {
|
||
return fixWinEPERM(p, options, er, cb);
|
||
}
|
||
if (st && st.isDirectory()) {
|
||
return rmdir(p, options, er, cb);
|
||
}
|
||
options.unlink(p, (er2) => {
|
||
if (er2) {
|
||
if (er2.code === "ENOENT") {
|
||
return cb(null);
|
||
}
|
||
if (er2.code === "EPERM") {
|
||
return isWindows ? fixWinEPERM(p, options, er2, cb) : rmdir(p, options, er2, cb);
|
||
}
|
||
if (er2.code === "EISDIR") {
|
||
return rmdir(p, options, er2, cb);
|
||
}
|
||
}
|
||
return cb(er2);
|
||
});
|
||
});
|
||
}
|
||
function fixWinEPERM(p, options, er, cb) {
|
||
assert(p);
|
||
assert(options);
|
||
assert(typeof cb === "function");
|
||
options.chmod(p, 438, (er2) => {
|
||
if (er2) {
|
||
cb(er2.code === "ENOENT" ? null : er);
|
||
} else {
|
||
options.stat(p, (er3, stats) => {
|
||
if (er3) {
|
||
cb(er3.code === "ENOENT" ? null : er);
|
||
} else if (stats.isDirectory()) {
|
||
rmdir(p, options, er, cb);
|
||
} else {
|
||
options.unlink(p, cb);
|
||
}
|
||
});
|
||
}
|
||
});
|
||
}
|
||
function fixWinEPERMSync(p, options, er) {
|
||
let stats;
|
||
assert(p);
|
||
assert(options);
|
||
try {
|
||
options.chmodSync(p, 438);
|
||
} catch (er2) {
|
||
if (er2.code === "ENOENT") {
|
||
return;
|
||
} else {
|
||
throw er;
|
||
}
|
||
}
|
||
try {
|
||
stats = options.statSync(p);
|
||
} catch (er3) {
|
||
if (er3.code === "ENOENT") {
|
||
return;
|
||
} else {
|
||
throw er;
|
||
}
|
||
}
|
||
if (stats.isDirectory()) {
|
||
rmdirSync(p, options, er);
|
||
} else {
|
||
options.unlinkSync(p);
|
||
}
|
||
}
|
||
function rmdir(p, options, originalEr, cb) {
|
||
assert(p);
|
||
assert(options);
|
||
assert(typeof cb === "function");
|
||
options.rmdir(p, (er) => {
|
||
if (er && (er.code === "ENOTEMPTY" || er.code === "EEXIST" || er.code === "EPERM")) {
|
||
rmkids(p, options, cb);
|
||
} else if (er && er.code === "ENOTDIR") {
|
||
cb(originalEr);
|
||
} else {
|
||
cb(er);
|
||
}
|
||
});
|
||
}
|
||
function rmkids(p, options, cb) {
|
||
assert(p);
|
||
assert(options);
|
||
assert(typeof cb === "function");
|
||
options.readdir(p, (er, files) => {
|
||
if (er)
|
||
return cb(er);
|
||
let n = files.length;
|
||
let errState;
|
||
if (n === 0)
|
||
return options.rmdir(p, cb);
|
||
files.forEach((f) => {
|
||
rimraf(path.join(p, f), options, (er2) => {
|
||
if (errState) {
|
||
return;
|
||
}
|
||
if (er2)
|
||
return cb(errState = er2);
|
||
if (--n === 0) {
|
||
options.rmdir(p, cb);
|
||
}
|
||
});
|
||
});
|
||
});
|
||
}
|
||
function rimrafSync(p, options) {
|
||
let st;
|
||
options = options || {};
|
||
defaults(options);
|
||
assert(p, "rimraf: missing path");
|
||
assert.strictEqual(typeof p, "string", "rimraf: path should be a string");
|
||
assert(options, "rimraf: missing options");
|
||
assert.strictEqual(typeof options, "object", "rimraf: options should be object");
|
||
try {
|
||
st = options.lstatSync(p);
|
||
} catch (er) {
|
||
if (er.code === "ENOENT") {
|
||
return;
|
||
}
|
||
if (er.code === "EPERM" && isWindows) {
|
||
fixWinEPERMSync(p, options, er);
|
||
}
|
||
}
|
||
try {
|
||
if (st && st.isDirectory()) {
|
||
rmdirSync(p, options, null);
|
||
} else {
|
||
options.unlinkSync(p);
|
||
}
|
||
} catch (er) {
|
||
if (er.code === "ENOENT") {
|
||
return;
|
||
} else if (er.code === "EPERM") {
|
||
return isWindows ? fixWinEPERMSync(p, options, er) : rmdirSync(p, options, er);
|
||
} else if (er.code !== "EISDIR") {
|
||
throw er;
|
||
}
|
||
rmdirSync(p, options, er);
|
||
}
|
||
}
|
||
function rmdirSync(p, options, originalEr) {
|
||
assert(p);
|
||
assert(options);
|
||
try {
|
||
options.rmdirSync(p);
|
||
} catch (er) {
|
||
if (er.code === "ENOTDIR") {
|
||
throw originalEr;
|
||
} else if (er.code === "ENOTEMPTY" || er.code === "EEXIST" || er.code === "EPERM") {
|
||
rmkidsSync(p, options);
|
||
} else if (er.code !== "ENOENT") {
|
||
throw er;
|
||
}
|
||
}
|
||
}
|
||
function rmkidsSync(p, options) {
|
||
assert(p);
|
||
assert(options);
|
||
options.readdirSync(p).forEach((f) => rimrafSync(path.join(p, f), options));
|
||
if (isWindows) {
|
||
const startTime = Date.now();
|
||
do {
|
||
try {
|
||
const ret = options.rmdirSync(p, options);
|
||
return ret;
|
||
} catch {
|
||
}
|
||
} while (Date.now() - startTime < 500);
|
||
} else {
|
||
const ret = options.rmdirSync(p, options);
|
||
return ret;
|
||
}
|
||
}
|
||
module2.exports = rimraf;
|
||
rimraf.sync = rimrafSync;
|
||
}
|
||
});
|
||
|
||
// node_modules/fs-extra/lib/remove/index.js
|
||
var require_remove = __commonJS({
|
||
"node_modules/fs-extra/lib/remove/index.js"(exports, module2) {
|
||
"use strict";
|
||
var fs = require_graceful_fs();
|
||
var u = require_universalify().fromCallback;
|
||
var rimraf = require_rimraf();
|
||
function remove(path, callback) {
|
||
if (fs.rm)
|
||
return fs.rm(path, { recursive: true, force: true }, callback);
|
||
rimraf(path, callback);
|
||
}
|
||
function removeSync(path) {
|
||
if (fs.rmSync)
|
||
return fs.rmSync(path, { recursive: true, force: true });
|
||
rimraf.sync(path);
|
||
}
|
||
module2.exports = {
|
||
remove: u(remove),
|
||
removeSync
|
||
};
|
||
}
|
||
});
|
||
|
||
// node_modules/fs-extra/lib/empty/index.js
|
||
var require_empty = __commonJS({
|
||
"node_modules/fs-extra/lib/empty/index.js"(exports, module2) {
|
||
"use strict";
|
||
var u = require_universalify().fromPromise;
|
||
var fs = require_fs();
|
||
var path = require("path");
|
||
var mkdir = require_mkdirs();
|
||
var remove = require_remove();
|
||
var emptyDir = u(async function emptyDir2(dir) {
|
||
let items;
|
||
try {
|
||
items = await fs.readdir(dir);
|
||
} catch {
|
||
return mkdir.mkdirs(dir);
|
||
}
|
||
return Promise.all(items.map((item) => remove.remove(path.join(dir, item))));
|
||
});
|
||
function emptyDirSync(dir) {
|
||
let items;
|
||
try {
|
||
items = fs.readdirSync(dir);
|
||
} catch {
|
||
return mkdir.mkdirsSync(dir);
|
||
}
|
||
items.forEach((item) => {
|
||
item = path.join(dir, item);
|
||
remove.removeSync(item);
|
||
});
|
||
}
|
||
module2.exports = {
|
||
emptyDirSync,
|
||
emptydirSync: emptyDirSync,
|
||
emptyDir,
|
||
emptydir: emptyDir
|
||
};
|
||
}
|
||
});
|
||
|
||
// node_modules/fs-extra/lib/ensure/file.js
|
||
var require_file = __commonJS({
|
||
"node_modules/fs-extra/lib/ensure/file.js"(exports, module2) {
|
||
"use strict";
|
||
var u = require_universalify().fromCallback;
|
||
var path = require("path");
|
||
var fs = require_graceful_fs();
|
||
var mkdir = require_mkdirs();
|
||
function createFile(file, callback) {
|
||
function makeFile() {
|
||
fs.writeFile(file, "", (err) => {
|
||
if (err)
|
||
return callback(err);
|
||
callback();
|
||
});
|
||
}
|
||
fs.stat(file, (err, stats) => {
|
||
if (!err && stats.isFile())
|
||
return callback();
|
||
const dir = path.dirname(file);
|
||
fs.stat(dir, (err2, stats2) => {
|
||
if (err2) {
|
||
if (err2.code === "ENOENT") {
|
||
return mkdir.mkdirs(dir, (err3) => {
|
||
if (err3)
|
||
return callback(err3);
|
||
makeFile();
|
||
});
|
||
}
|
||
return callback(err2);
|
||
}
|
||
if (stats2.isDirectory())
|
||
makeFile();
|
||
else {
|
||
fs.readdir(dir, (err3) => {
|
||
if (err3)
|
||
return callback(err3);
|
||
});
|
||
}
|
||
});
|
||
});
|
||
}
|
||
function createFileSync(file) {
|
||
let stats;
|
||
try {
|
||
stats = fs.statSync(file);
|
||
} catch {
|
||
}
|
||
if (stats && stats.isFile())
|
||
return;
|
||
const dir = path.dirname(file);
|
||
try {
|
||
if (!fs.statSync(dir).isDirectory()) {
|
||
fs.readdirSync(dir);
|
||
}
|
||
} catch (err) {
|
||
if (err && err.code === "ENOENT")
|
||
mkdir.mkdirsSync(dir);
|
||
else
|
||
throw err;
|
||
}
|
||
fs.writeFileSync(file, "");
|
||
}
|
||
module2.exports = {
|
||
createFile: u(createFile),
|
||
createFileSync
|
||
};
|
||
}
|
||
});
|
||
|
||
// node_modules/fs-extra/lib/ensure/link.js
|
||
var require_link = __commonJS({
|
||
"node_modules/fs-extra/lib/ensure/link.js"(exports, module2) {
|
||
"use strict";
|
||
var u = require_universalify().fromCallback;
|
||
var path = require("path");
|
||
var fs = require_graceful_fs();
|
||
var mkdir = require_mkdirs();
|
||
var pathExists = require_path_exists().pathExists;
|
||
var { areIdentical } = require_stat();
|
||
function createLink(srcpath, dstpath, callback) {
|
||
function makeLink(srcpath2, dstpath2) {
|
||
fs.link(srcpath2, dstpath2, (err) => {
|
||
if (err)
|
||
return callback(err);
|
||
callback(null);
|
||
});
|
||
}
|
||
fs.lstat(dstpath, (_, dstStat) => {
|
||
fs.lstat(srcpath, (err, srcStat) => {
|
||
if (err) {
|
||
err.message = err.message.replace("lstat", "ensureLink");
|
||
return callback(err);
|
||
}
|
||
if (dstStat && areIdentical(srcStat, dstStat))
|
||
return callback(null);
|
||
const dir = path.dirname(dstpath);
|
||
pathExists(dir, (err2, dirExists) => {
|
||
if (err2)
|
||
return callback(err2);
|
||
if (dirExists)
|
||
return makeLink(srcpath, dstpath);
|
||
mkdir.mkdirs(dir, (err3) => {
|
||
if (err3)
|
||
return callback(err3);
|
||
makeLink(srcpath, dstpath);
|
||
});
|
||
});
|
||
});
|
||
});
|
||
}
|
||
function createLinkSync(srcpath, dstpath) {
|
||
let dstStat;
|
||
try {
|
||
dstStat = fs.lstatSync(dstpath);
|
||
} catch {
|
||
}
|
||
try {
|
||
const srcStat = fs.lstatSync(srcpath);
|
||
if (dstStat && areIdentical(srcStat, dstStat))
|
||
return;
|
||
} catch (err) {
|
||
err.message = err.message.replace("lstat", "ensureLink");
|
||
throw err;
|
||
}
|
||
const dir = path.dirname(dstpath);
|
||
const dirExists = fs.existsSync(dir);
|
||
if (dirExists)
|
||
return fs.linkSync(srcpath, dstpath);
|
||
mkdir.mkdirsSync(dir);
|
||
return fs.linkSync(srcpath, dstpath);
|
||
}
|
||
module2.exports = {
|
||
createLink: u(createLink),
|
||
createLinkSync
|
||
};
|
||
}
|
||
});
|
||
|
||
// node_modules/fs-extra/lib/ensure/symlink-paths.js
|
||
var require_symlink_paths = __commonJS({
|
||
"node_modules/fs-extra/lib/ensure/symlink-paths.js"(exports, module2) {
|
||
"use strict";
|
||
var path = require("path");
|
||
var fs = require_graceful_fs();
|
||
var pathExists = require_path_exists().pathExists;
|
||
function symlinkPaths(srcpath, dstpath, callback) {
|
||
if (path.isAbsolute(srcpath)) {
|
||
return fs.lstat(srcpath, (err) => {
|
||
if (err) {
|
||
err.message = err.message.replace("lstat", "ensureSymlink");
|
||
return callback(err);
|
||
}
|
||
return callback(null, {
|
||
toCwd: srcpath,
|
||
toDst: srcpath
|
||
});
|
||
});
|
||
} else {
|
||
const dstdir = path.dirname(dstpath);
|
||
const relativeToDst = path.join(dstdir, srcpath);
|
||
return pathExists(relativeToDst, (err, exists) => {
|
||
if (err)
|
||
return callback(err);
|
||
if (exists) {
|
||
return callback(null, {
|
||
toCwd: relativeToDst,
|
||
toDst: srcpath
|
||
});
|
||
} else {
|
||
return fs.lstat(srcpath, (err2) => {
|
||
if (err2) {
|
||
err2.message = err2.message.replace("lstat", "ensureSymlink");
|
||
return callback(err2);
|
||
}
|
||
return callback(null, {
|
||
toCwd: srcpath,
|
||
toDst: path.relative(dstdir, srcpath)
|
||
});
|
||
});
|
||
}
|
||
});
|
||
}
|
||
}
|
||
function symlinkPathsSync(srcpath, dstpath) {
|
||
let exists;
|
||
if (path.isAbsolute(srcpath)) {
|
||
exists = fs.existsSync(srcpath);
|
||
if (!exists)
|
||
throw new Error("absolute srcpath does not exist");
|
||
return {
|
||
toCwd: srcpath,
|
||
toDst: srcpath
|
||
};
|
||
} else {
|
||
const dstdir = path.dirname(dstpath);
|
||
const relativeToDst = path.join(dstdir, srcpath);
|
||
exists = fs.existsSync(relativeToDst);
|
||
if (exists) {
|
||
return {
|
||
toCwd: relativeToDst,
|
||
toDst: srcpath
|
||
};
|
||
} else {
|
||
exists = fs.existsSync(srcpath);
|
||
if (!exists)
|
||
throw new Error("relative srcpath does not exist");
|
||
return {
|
||
toCwd: srcpath,
|
||
toDst: path.relative(dstdir, srcpath)
|
||
};
|
||
}
|
||
}
|
||
}
|
||
module2.exports = {
|
||
symlinkPaths,
|
||
symlinkPathsSync
|
||
};
|
||
}
|
||
});
|
||
|
||
// node_modules/fs-extra/lib/ensure/symlink-type.js
|
||
var require_symlink_type = __commonJS({
|
||
"node_modules/fs-extra/lib/ensure/symlink-type.js"(exports, module2) {
|
||
"use strict";
|
||
var fs = require_graceful_fs();
|
||
function symlinkType(srcpath, type, callback) {
|
||
callback = typeof type === "function" ? type : callback;
|
||
type = typeof type === "function" ? false : type;
|
||
if (type)
|
||
return callback(null, type);
|
||
fs.lstat(srcpath, (err, stats) => {
|
||
if (err)
|
||
return callback(null, "file");
|
||
type = stats && stats.isDirectory() ? "dir" : "file";
|
||
callback(null, type);
|
||
});
|
||
}
|
||
function symlinkTypeSync(srcpath, type) {
|
||
let stats;
|
||
if (type)
|
||
return type;
|
||
try {
|
||
stats = fs.lstatSync(srcpath);
|
||
} catch {
|
||
return "file";
|
||
}
|
||
return stats && stats.isDirectory() ? "dir" : "file";
|
||
}
|
||
module2.exports = {
|
||
symlinkType,
|
||
symlinkTypeSync
|
||
};
|
||
}
|
||
});
|
||
|
||
// node_modules/fs-extra/lib/ensure/symlink.js
|
||
var require_symlink = __commonJS({
|
||
"node_modules/fs-extra/lib/ensure/symlink.js"(exports, module2) {
|
||
"use strict";
|
||
var u = require_universalify().fromCallback;
|
||
var path = require("path");
|
||
var fs = require_fs();
|
||
var _mkdirs = require_mkdirs();
|
||
var mkdirs = _mkdirs.mkdirs;
|
||
var mkdirsSync = _mkdirs.mkdirsSync;
|
||
var _symlinkPaths = require_symlink_paths();
|
||
var symlinkPaths = _symlinkPaths.symlinkPaths;
|
||
var symlinkPathsSync = _symlinkPaths.symlinkPathsSync;
|
||
var _symlinkType = require_symlink_type();
|
||
var symlinkType = _symlinkType.symlinkType;
|
||
var symlinkTypeSync = _symlinkType.symlinkTypeSync;
|
||
var pathExists = require_path_exists().pathExists;
|
||
var { areIdentical } = require_stat();
|
||
function createSymlink(srcpath, dstpath, type, callback) {
|
||
callback = typeof type === "function" ? type : callback;
|
||
type = typeof type === "function" ? false : type;
|
||
fs.lstat(dstpath, (err, stats) => {
|
||
if (!err && stats.isSymbolicLink()) {
|
||
Promise.all([
|
||
fs.stat(srcpath),
|
||
fs.stat(dstpath)
|
||
]).then(([srcStat, dstStat]) => {
|
||
if (areIdentical(srcStat, dstStat))
|
||
return callback(null);
|
||
_createSymlink(srcpath, dstpath, type, callback);
|
||
});
|
||
} else
|
||
_createSymlink(srcpath, dstpath, type, callback);
|
||
});
|
||
}
|
||
function _createSymlink(srcpath, dstpath, type, callback) {
|
||
symlinkPaths(srcpath, dstpath, (err, relative2) => {
|
||
if (err)
|
||
return callback(err);
|
||
srcpath = relative2.toDst;
|
||
symlinkType(relative2.toCwd, type, (err2, type2) => {
|
||
if (err2)
|
||
return callback(err2);
|
||
const dir = path.dirname(dstpath);
|
||
pathExists(dir, (err3, dirExists) => {
|
||
if (err3)
|
||
return callback(err3);
|
||
if (dirExists)
|
||
return fs.symlink(srcpath, dstpath, type2, callback);
|
||
mkdirs(dir, (err4) => {
|
||
if (err4)
|
||
return callback(err4);
|
||
fs.symlink(srcpath, dstpath, type2, callback);
|
||
});
|
||
});
|
||
});
|
||
});
|
||
}
|
||
function createSymlinkSync(srcpath, dstpath, type) {
|
||
let stats;
|
||
try {
|
||
stats = fs.lstatSync(dstpath);
|
||
} catch {
|
||
}
|
||
if (stats && stats.isSymbolicLink()) {
|
||
const srcStat = fs.statSync(srcpath);
|
||
const dstStat = fs.statSync(dstpath);
|
||
if (areIdentical(srcStat, dstStat))
|
||
return;
|
||
}
|
||
const relative2 = symlinkPathsSync(srcpath, dstpath);
|
||
srcpath = relative2.toDst;
|
||
type = symlinkTypeSync(relative2.toCwd, type);
|
||
const dir = path.dirname(dstpath);
|
||
const exists = fs.existsSync(dir);
|
||
if (exists)
|
||
return fs.symlinkSync(srcpath, dstpath, type);
|
||
mkdirsSync(dir);
|
||
return fs.symlinkSync(srcpath, dstpath, type);
|
||
}
|
||
module2.exports = {
|
||
createSymlink: u(createSymlink),
|
||
createSymlinkSync
|
||
};
|
||
}
|
||
});
|
||
|
||
// node_modules/fs-extra/lib/ensure/index.js
|
||
var require_ensure = __commonJS({
|
||
"node_modules/fs-extra/lib/ensure/index.js"(exports, module2) {
|
||
"use strict";
|
||
var file = require_file();
|
||
var link = require_link();
|
||
var symlink = require_symlink();
|
||
module2.exports = {
|
||
createFile: file.createFile,
|
||
createFileSync: file.createFileSync,
|
||
ensureFile: file.createFile,
|
||
ensureFileSync: file.createFileSync,
|
||
createLink: link.createLink,
|
||
createLinkSync: link.createLinkSync,
|
||
ensureLink: link.createLink,
|
||
ensureLinkSync: link.createLinkSync,
|
||
createSymlink: symlink.createSymlink,
|
||
createSymlinkSync: symlink.createSymlinkSync,
|
||
ensureSymlink: symlink.createSymlink,
|
||
ensureSymlinkSync: symlink.createSymlinkSync
|
||
};
|
||
}
|
||
});
|
||
|
||
// node_modules/jsonfile/utils.js
|
||
var require_utils2 = __commonJS({
|
||
"node_modules/jsonfile/utils.js"(exports, module2) {
|
||
function stringify(obj, { EOL = "\n", finalEOL = true, replacer = null, spaces } = {}) {
|
||
const EOF = finalEOL ? EOL : "";
|
||
const str = JSON.stringify(obj, replacer, spaces);
|
||
return str.replace(/\n/g, EOL) + EOF;
|
||
}
|
||
function stripBom(content) {
|
||
if (Buffer.isBuffer(content))
|
||
content = content.toString("utf8");
|
||
return content.replace(/^\uFEFF/, "");
|
||
}
|
||
module2.exports = { stringify, stripBom };
|
||
}
|
||
});
|
||
|
||
// node_modules/jsonfile/index.js
|
||
var require_jsonfile = __commonJS({
|
||
"node_modules/jsonfile/index.js"(exports, module2) {
|
||
var _fs;
|
||
try {
|
||
_fs = require_graceful_fs();
|
||
} catch (_) {
|
||
_fs = require("fs");
|
||
}
|
||
var universalify = require_universalify();
|
||
var { stringify, stripBom } = require_utils2();
|
||
async function _readFile(file, options = {}) {
|
||
if (typeof options === "string") {
|
||
options = { encoding: options };
|
||
}
|
||
const fs = options.fs || _fs;
|
||
const shouldThrow = "throws" in options ? options.throws : true;
|
||
let data = await universalify.fromCallback(fs.readFile)(file, options);
|
||
data = stripBom(data);
|
||
let obj;
|
||
try {
|
||
obj = JSON.parse(data, options ? options.reviver : null);
|
||
} catch (err) {
|
||
if (shouldThrow) {
|
||
err.message = `${file}: ${err.message}`;
|
||
throw err;
|
||
} else {
|
||
return null;
|
||
}
|
||
}
|
||
return obj;
|
||
}
|
||
var readFile = universalify.fromPromise(_readFile);
|
||
function readFileSync6(file, options = {}) {
|
||
if (typeof options === "string") {
|
||
options = { encoding: options };
|
||
}
|
||
const fs = options.fs || _fs;
|
||
const shouldThrow = "throws" in options ? options.throws : true;
|
||
try {
|
||
let content = fs.readFileSync(file, options);
|
||
content = stripBom(content);
|
||
return JSON.parse(content, options.reviver);
|
||
} catch (err) {
|
||
if (shouldThrow) {
|
||
err.message = `${file}: ${err.message}`;
|
||
throw err;
|
||
} else {
|
||
return null;
|
||
}
|
||
}
|
||
}
|
||
async function _writeFile(file, obj, options = {}) {
|
||
const fs = options.fs || _fs;
|
||
const str = stringify(obj, options);
|
||
await universalify.fromCallback(fs.writeFile)(file, str, options);
|
||
}
|
||
var writeFile2 = universalify.fromPromise(_writeFile);
|
||
function writeFileSync3(file, obj, options = {}) {
|
||
const fs = options.fs || _fs;
|
||
const str = stringify(obj, options);
|
||
return fs.writeFileSync(file, str, options);
|
||
}
|
||
var jsonfile = {
|
||
readFile,
|
||
readFileSync: readFileSync6,
|
||
writeFile: writeFile2,
|
||
writeFileSync: writeFileSync3
|
||
};
|
||
module2.exports = jsonfile;
|
||
}
|
||
});
|
||
|
||
// node_modules/fs-extra/lib/json/jsonfile.js
|
||
var require_jsonfile2 = __commonJS({
|
||
"node_modules/fs-extra/lib/json/jsonfile.js"(exports, module2) {
|
||
"use strict";
|
||
var jsonFile = require_jsonfile();
|
||
module2.exports = {
|
||
readJson: jsonFile.readFile,
|
||
readJsonSync: jsonFile.readFileSync,
|
||
writeJson: jsonFile.writeFile,
|
||
writeJsonSync: jsonFile.writeFileSync
|
||
};
|
||
}
|
||
});
|
||
|
||
// node_modules/fs-extra/lib/output/index.js
|
||
var require_output = __commonJS({
|
||
"node_modules/fs-extra/lib/output/index.js"(exports, module2) {
|
||
"use strict";
|
||
var u = require_universalify().fromCallback;
|
||
var fs = require_graceful_fs();
|
||
var path = require("path");
|
||
var mkdir = require_mkdirs();
|
||
var pathExists = require_path_exists().pathExists;
|
||
function outputFile(file, data, encoding, callback) {
|
||
if (typeof encoding === "function") {
|
||
callback = encoding;
|
||
encoding = "utf8";
|
||
}
|
||
const dir = path.dirname(file);
|
||
pathExists(dir, (err, itDoes) => {
|
||
if (err)
|
||
return callback(err);
|
||
if (itDoes)
|
||
return fs.writeFile(file, data, encoding, callback);
|
||
mkdir.mkdirs(dir, (err2) => {
|
||
if (err2)
|
||
return callback(err2);
|
||
fs.writeFile(file, data, encoding, callback);
|
||
});
|
||
});
|
||
}
|
||
function outputFileSync(file, ...args) {
|
||
const dir = path.dirname(file);
|
||
if (fs.existsSync(dir)) {
|
||
return fs.writeFileSync(file, ...args);
|
||
}
|
||
mkdir.mkdirsSync(dir);
|
||
fs.writeFileSync(file, ...args);
|
||
}
|
||
module2.exports = {
|
||
outputFile: u(outputFile),
|
||
outputFileSync
|
||
};
|
||
}
|
||
});
|
||
|
||
// node_modules/fs-extra/lib/json/output-json.js
|
||
var require_output_json = __commonJS({
|
||
"node_modules/fs-extra/lib/json/output-json.js"(exports, module2) {
|
||
"use strict";
|
||
var { stringify } = require_utils2();
|
||
var { outputFile } = require_output();
|
||
async function outputJson(file, data, options = {}) {
|
||
const str = stringify(data, options);
|
||
await outputFile(file, str, options);
|
||
}
|
||
module2.exports = outputJson;
|
||
}
|
||
});
|
||
|
||
// node_modules/fs-extra/lib/json/output-json-sync.js
|
||
var require_output_json_sync = __commonJS({
|
||
"node_modules/fs-extra/lib/json/output-json-sync.js"(exports, module2) {
|
||
"use strict";
|
||
var { stringify } = require_utils2();
|
||
var { outputFileSync } = require_output();
|
||
function outputJsonSync(file, data, options) {
|
||
const str = stringify(data, options);
|
||
outputFileSync(file, str, options);
|
||
}
|
||
module2.exports = outputJsonSync;
|
||
}
|
||
});
|
||
|
||
// node_modules/fs-extra/lib/json/index.js
|
||
var require_json = __commonJS({
|
||
"node_modules/fs-extra/lib/json/index.js"(exports, module2) {
|
||
"use strict";
|
||
var u = require_universalify().fromPromise;
|
||
var jsonFile = require_jsonfile2();
|
||
jsonFile.outputJson = u(require_output_json());
|
||
jsonFile.outputJsonSync = require_output_json_sync();
|
||
jsonFile.outputJSON = jsonFile.outputJson;
|
||
jsonFile.outputJSONSync = jsonFile.outputJsonSync;
|
||
jsonFile.writeJSON = jsonFile.writeJson;
|
||
jsonFile.writeJSONSync = jsonFile.writeJsonSync;
|
||
jsonFile.readJSON = jsonFile.readJson;
|
||
jsonFile.readJSONSync = jsonFile.readJsonSync;
|
||
module2.exports = jsonFile;
|
||
}
|
||
});
|
||
|
||
// node_modules/fs-extra/lib/move-sync/move-sync.js
|
||
var require_move_sync = __commonJS({
|
||
"node_modules/fs-extra/lib/move-sync/move-sync.js"(exports, module2) {
|
||
"use strict";
|
||
var fs = require_graceful_fs();
|
||
var path = require("path");
|
||
var copySync2 = require_copy_sync2().copySync;
|
||
var removeSync = require_remove().removeSync;
|
||
var mkdirpSync = require_mkdirs().mkdirpSync;
|
||
var stat = require_stat();
|
||
function moveSync(src, dest, opts) {
|
||
opts = opts || {};
|
||
const overwrite = opts.overwrite || opts.clobber || false;
|
||
const { srcStat, isChangingCase = false } = stat.checkPathsSync(src, dest, "move", opts);
|
||
stat.checkParentPathsSync(src, srcStat, dest, "move");
|
||
if (!isParentRoot(dest))
|
||
mkdirpSync(path.dirname(dest));
|
||
return doRename(src, dest, overwrite, isChangingCase);
|
||
}
|
||
function isParentRoot(dest) {
|
||
const parent = path.dirname(dest);
|
||
const parsedPath = path.parse(parent);
|
||
return parsedPath.root === parent;
|
||
}
|
||
function doRename(src, dest, overwrite, isChangingCase) {
|
||
if (isChangingCase)
|
||
return rename(src, dest, overwrite);
|
||
if (overwrite) {
|
||
removeSync(dest);
|
||
return rename(src, dest, overwrite);
|
||
}
|
||
if (fs.existsSync(dest))
|
||
throw new Error("dest already exists.");
|
||
return rename(src, dest, overwrite);
|
||
}
|
||
function rename(src, dest, overwrite) {
|
||
try {
|
||
fs.renameSync(src, dest);
|
||
} catch (err) {
|
||
if (err.code !== "EXDEV")
|
||
throw err;
|
||
return moveAcrossDevice(src, dest, overwrite);
|
||
}
|
||
}
|
||
function moveAcrossDevice(src, dest, overwrite) {
|
||
const opts = {
|
||
overwrite,
|
||
errorOnExist: true
|
||
};
|
||
copySync2(src, dest, opts);
|
||
return removeSync(src);
|
||
}
|
||
module2.exports = moveSync;
|
||
}
|
||
});
|
||
|
||
// node_modules/fs-extra/lib/move-sync/index.js
|
||
var require_move_sync2 = __commonJS({
|
||
"node_modules/fs-extra/lib/move-sync/index.js"(exports, module2) {
|
||
"use strict";
|
||
module2.exports = {
|
||
moveSync: require_move_sync()
|
||
};
|
||
}
|
||
});
|
||
|
||
// node_modules/fs-extra/lib/move/move.js
|
||
var require_move = __commonJS({
|
||
"node_modules/fs-extra/lib/move/move.js"(exports, module2) {
|
||
"use strict";
|
||
var fs = require_graceful_fs();
|
||
var path = require("path");
|
||
var copy = require_copy2().copy;
|
||
var remove = require_remove().remove;
|
||
var mkdirp = require_mkdirs().mkdirp;
|
||
var pathExists = require_path_exists().pathExists;
|
||
var stat = require_stat();
|
||
function move(src, dest, opts, cb) {
|
||
if (typeof opts === "function") {
|
||
cb = opts;
|
||
opts = {};
|
||
}
|
||
const overwrite = opts.overwrite || opts.clobber || false;
|
||
stat.checkPaths(src, dest, "move", opts, (err, stats) => {
|
||
if (err)
|
||
return cb(err);
|
||
const { srcStat, isChangingCase = false } = stats;
|
||
stat.checkParentPaths(src, srcStat, dest, "move", (err2) => {
|
||
if (err2)
|
||
return cb(err2);
|
||
if (isParentRoot(dest))
|
||
return doRename(src, dest, overwrite, isChangingCase, cb);
|
||
mkdirp(path.dirname(dest), (err3) => {
|
||
if (err3)
|
||
return cb(err3);
|
||
return doRename(src, dest, overwrite, isChangingCase, cb);
|
||
});
|
||
});
|
||
});
|
||
}
|
||
function isParentRoot(dest) {
|
||
const parent = path.dirname(dest);
|
||
const parsedPath = path.parse(parent);
|
||
return parsedPath.root === parent;
|
||
}
|
||
function doRename(src, dest, overwrite, isChangingCase, cb) {
|
||
if (isChangingCase)
|
||
return rename(src, dest, overwrite, cb);
|
||
if (overwrite) {
|
||
return remove(dest, (err) => {
|
||
if (err)
|
||
return cb(err);
|
||
return rename(src, dest, overwrite, cb);
|
||
});
|
||
}
|
||
pathExists(dest, (err, destExists) => {
|
||
if (err)
|
||
return cb(err);
|
||
if (destExists)
|
||
return cb(new Error("dest already exists."));
|
||
return rename(src, dest, overwrite, cb);
|
||
});
|
||
}
|
||
function rename(src, dest, overwrite, cb) {
|
||
fs.rename(src, dest, (err) => {
|
||
if (!err)
|
||
return cb();
|
||
if (err.code !== "EXDEV")
|
||
return cb(err);
|
||
return moveAcrossDevice(src, dest, overwrite, cb);
|
||
});
|
||
}
|
||
function moveAcrossDevice(src, dest, overwrite, cb) {
|
||
const opts = {
|
||
overwrite,
|
||
errorOnExist: true
|
||
};
|
||
copy(src, dest, opts, (err) => {
|
||
if (err)
|
||
return cb(err);
|
||
return remove(src, cb);
|
||
});
|
||
}
|
||
module2.exports = move;
|
||
}
|
||
});
|
||
|
||
// node_modules/fs-extra/lib/move/index.js
|
||
var require_move2 = __commonJS({
|
||
"node_modules/fs-extra/lib/move/index.js"(exports, module2) {
|
||
"use strict";
|
||
var u = require_universalify().fromCallback;
|
||
module2.exports = {
|
||
move: u(require_move())
|
||
};
|
||
}
|
||
});
|
||
|
||
// node_modules/fs-extra/lib/index.js
|
||
var require_lib = __commonJS({
|
||
"node_modules/fs-extra/lib/index.js"(exports, module2) {
|
||
"use strict";
|
||
module2.exports = __spreadValues(__spreadValues(__spreadValues(__spreadValues(__spreadValues(__spreadValues(__spreadValues(__spreadValues(__spreadValues(__spreadValues(__spreadValues(__spreadValues({}, require_fs()), require_copy_sync2()), require_copy2()), require_empty()), require_ensure()), require_json()), require_mkdirs()), require_move_sync2()), require_move2()), require_output()), require_path_exists()), require_remove());
|
||
}
|
||
});
|
||
|
||
// node_modules/yargs/lib/platform-shims/esm.mjs
|
||
var import_assert = require("assert");
|
||
|
||
// node_modules/cliui/build/lib/index.js
|
||
var align = {
|
||
right: alignRight,
|
||
center: alignCenter
|
||
};
|
||
var top = 0;
|
||
var right = 1;
|
||
var bottom = 2;
|
||
var left = 3;
|
||
var UI = class {
|
||
constructor(opts) {
|
||
var _a;
|
||
this.width = opts.width;
|
||
this.wrap = (_a = opts.wrap) !== null && _a !== void 0 ? _a : true;
|
||
this.rows = [];
|
||
}
|
||
span(...args) {
|
||
const cols = this.div(...args);
|
||
cols.span = true;
|
||
}
|
||
resetOutput() {
|
||
this.rows = [];
|
||
}
|
||
div(...args) {
|
||
if (args.length === 0) {
|
||
this.div("");
|
||
}
|
||
if (this.wrap && this.shouldApplyLayoutDSL(...args) && typeof args[0] === "string") {
|
||
return this.applyLayoutDSL(args[0]);
|
||
}
|
||
const cols = args.map((arg) => {
|
||
if (typeof arg === "string") {
|
||
return this.colFromString(arg);
|
||
}
|
||
return arg;
|
||
});
|
||
this.rows.push(cols);
|
||
return cols;
|
||
}
|
||
shouldApplyLayoutDSL(...args) {
|
||
return args.length === 1 && typeof args[0] === "string" && /[\t\n]/.test(args[0]);
|
||
}
|
||
applyLayoutDSL(str) {
|
||
const rows = str.split("\n").map((row) => row.split(" "));
|
||
let leftColumnWidth = 0;
|
||
rows.forEach((columns) => {
|
||
if (columns.length > 1 && mixin.stringWidth(columns[0]) > leftColumnWidth) {
|
||
leftColumnWidth = Math.min(Math.floor(this.width * 0.5), mixin.stringWidth(columns[0]));
|
||
}
|
||
});
|
||
rows.forEach((columns) => {
|
||
this.div(...columns.map((r, i) => {
|
||
return {
|
||
text: r.trim(),
|
||
padding: this.measurePadding(r),
|
||
width: i === 0 && columns.length > 1 ? leftColumnWidth : void 0
|
||
};
|
||
}));
|
||
});
|
||
return this.rows[this.rows.length - 1];
|
||
}
|
||
colFromString(text) {
|
||
return {
|
||
text,
|
||
padding: this.measurePadding(text)
|
||
};
|
||
}
|
||
measurePadding(str) {
|
||
const noAnsi = mixin.stripAnsi(str);
|
||
return [0, noAnsi.match(/\s*$/)[0].length, 0, noAnsi.match(/^\s*/)[0].length];
|
||
}
|
||
toString() {
|
||
const lines = [];
|
||
this.rows.forEach((row) => {
|
||
this.rowToString(row, lines);
|
||
});
|
||
return lines.filter((line) => !line.hidden).map((line) => line.text).join("\n");
|
||
}
|
||
rowToString(row, lines) {
|
||
this.rasterize(row).forEach((rrow, r) => {
|
||
let str = "";
|
||
rrow.forEach((col, c) => {
|
||
const { width } = row[c];
|
||
const wrapWidth = this.negatePadding(row[c]);
|
||
let ts = col;
|
||
if (wrapWidth > mixin.stringWidth(col)) {
|
||
ts += " ".repeat(wrapWidth - mixin.stringWidth(col));
|
||
}
|
||
if (row[c].align && row[c].align !== "left" && this.wrap) {
|
||
const fn = align[row[c].align];
|
||
ts = fn(ts, wrapWidth);
|
||
if (mixin.stringWidth(ts) < wrapWidth) {
|
||
ts += " ".repeat((width || 0) - mixin.stringWidth(ts) - 1);
|
||
}
|
||
}
|
||
const padding = row[c].padding || [0, 0, 0, 0];
|
||
if (padding[left]) {
|
||
str += " ".repeat(padding[left]);
|
||
}
|
||
str += addBorder(row[c], ts, "| ");
|
||
str += ts;
|
||
str += addBorder(row[c], ts, " |");
|
||
if (padding[right]) {
|
||
str += " ".repeat(padding[right]);
|
||
}
|
||
if (r === 0 && lines.length > 0) {
|
||
str = this.renderInline(str, lines[lines.length - 1]);
|
||
}
|
||
});
|
||
lines.push({
|
||
text: str.replace(/ +$/, ""),
|
||
span: row.span
|
||
});
|
||
});
|
||
return lines;
|
||
}
|
||
renderInline(source, previousLine) {
|
||
const match = source.match(/^ */);
|
||
const leadingWhitespace = match ? match[0].length : 0;
|
||
const target = previousLine.text;
|
||
const targetTextWidth = mixin.stringWidth(target.trimRight());
|
||
if (!previousLine.span) {
|
||
return source;
|
||
}
|
||
if (!this.wrap) {
|
||
previousLine.hidden = true;
|
||
return target + source;
|
||
}
|
||
if (leadingWhitespace < targetTextWidth) {
|
||
return source;
|
||
}
|
||
previousLine.hidden = true;
|
||
return target.trimRight() + " ".repeat(leadingWhitespace - targetTextWidth) + source.trimLeft();
|
||
}
|
||
rasterize(row) {
|
||
const rrows = [];
|
||
const widths = this.columnWidths(row);
|
||
let wrapped;
|
||
row.forEach((col, c) => {
|
||
col.width = widths[c];
|
||
if (this.wrap) {
|
||
wrapped = mixin.wrap(col.text, this.negatePadding(col), { hard: true }).split("\n");
|
||
} else {
|
||
wrapped = col.text.split("\n");
|
||
}
|
||
if (col.border) {
|
||
wrapped.unshift("." + "-".repeat(this.negatePadding(col) + 2) + ".");
|
||
wrapped.push("'" + "-".repeat(this.negatePadding(col) + 2) + "'");
|
||
}
|
||
if (col.padding) {
|
||
wrapped.unshift(...new Array(col.padding[top] || 0).fill(""));
|
||
wrapped.push(...new Array(col.padding[bottom] || 0).fill(""));
|
||
}
|
||
wrapped.forEach((str, r) => {
|
||
if (!rrows[r]) {
|
||
rrows.push([]);
|
||
}
|
||
const rrow = rrows[r];
|
||
for (let i = 0; i < c; i++) {
|
||
if (rrow[i] === void 0) {
|
||
rrow.push("");
|
||
}
|
||
}
|
||
rrow.push(str);
|
||
});
|
||
});
|
||
return rrows;
|
||
}
|
||
negatePadding(col) {
|
||
let wrapWidth = col.width || 0;
|
||
if (col.padding) {
|
||
wrapWidth -= (col.padding[left] || 0) + (col.padding[right] || 0);
|
||
}
|
||
if (col.border) {
|
||
wrapWidth -= 4;
|
||
}
|
||
return wrapWidth;
|
||
}
|
||
columnWidths(row) {
|
||
if (!this.wrap) {
|
||
return row.map((col) => {
|
||
return col.width || mixin.stringWidth(col.text);
|
||
});
|
||
}
|
||
let unset = row.length;
|
||
let remainingWidth = this.width;
|
||
const widths = row.map((col) => {
|
||
if (col.width) {
|
||
unset--;
|
||
remainingWidth -= col.width;
|
||
return col.width;
|
||
}
|
||
return void 0;
|
||
});
|
||
const unsetWidth = unset ? Math.floor(remainingWidth / unset) : 0;
|
||
return widths.map((w, i) => {
|
||
if (w === void 0) {
|
||
return Math.max(unsetWidth, _minWidth(row[i]));
|
||
}
|
||
return w;
|
||
});
|
||
}
|
||
};
|
||
function addBorder(col, ts, style) {
|
||
if (col.border) {
|
||
if (/[.']-+[.']/.test(ts)) {
|
||
return "";
|
||
}
|
||
if (ts.trim().length !== 0) {
|
||
return style;
|
||
}
|
||
return " ";
|
||
}
|
||
return "";
|
||
}
|
||
function _minWidth(col) {
|
||
const padding = col.padding || [];
|
||
const minWidth = 1 + (padding[left] || 0) + (padding[right] || 0);
|
||
if (col.border) {
|
||
return minWidth + 4;
|
||
}
|
||
return minWidth;
|
||
}
|
||
function getWindowWidth() {
|
||
if (typeof process === "object" && process.stdout && process.stdout.columns) {
|
||
return process.stdout.columns;
|
||
}
|
||
return 80;
|
||
}
|
||
function alignRight(str, width) {
|
||
str = str.trim();
|
||
const strWidth = mixin.stringWidth(str);
|
||
if (strWidth < width) {
|
||
return " ".repeat(width - strWidth) + str;
|
||
}
|
||
return str;
|
||
}
|
||
function alignCenter(str, width) {
|
||
str = str.trim();
|
||
const strWidth = mixin.stringWidth(str);
|
||
if (strWidth >= width) {
|
||
return str;
|
||
}
|
||
return " ".repeat(width - strWidth >> 1) + str;
|
||
}
|
||
var mixin;
|
||
function cliui(opts, _mixin) {
|
||
mixin = _mixin;
|
||
return new UI({
|
||
width: (opts === null || opts === void 0 ? void 0 : opts.width) || getWindowWidth(),
|
||
wrap: opts === null || opts === void 0 ? void 0 : opts.wrap
|
||
});
|
||
}
|
||
|
||
// node_modules/cliui/build/lib/string-utils.js
|
||
var ansi = new RegExp("(?:\\[(?:\\d+[ABCDEFGJKSTm]|\\d+;\\d+[Hfm]|\\d+;\\d+;\\d+m|6n|s|u|\\?25[lh])|\\w)", "g");
|
||
function stripAnsi(str) {
|
||
return str.replace(ansi, "");
|
||
}
|
||
function wrap(str, width) {
|
||
const [start, end] = str.match(ansi) || ["", ""];
|
||
str = stripAnsi(str);
|
||
let wrapped = "";
|
||
for (let i = 0; i < str.length; i++) {
|
||
if (i !== 0 && i % width === 0) {
|
||
wrapped += "\n";
|
||
}
|
||
wrapped += str.charAt(i);
|
||
}
|
||
if (start && end) {
|
||
wrapped = `${start}${wrapped}${end}`;
|
||
}
|
||
return wrapped;
|
||
}
|
||
|
||
// node_modules/cliui/index.mjs
|
||
function ui(opts) {
|
||
return cliui(opts, {
|
||
stringWidth: (str) => {
|
||
return [...str].length;
|
||
},
|
||
stripAnsi,
|
||
wrap
|
||
});
|
||
}
|
||
|
||
// node_modules/escalade/sync/index.mjs
|
||
var import_path = require("path");
|
||
var import_fs = require("fs");
|
||
function sync_default(start, callback) {
|
||
let dir = (0, import_path.resolve)(".", start);
|
||
let tmp, stats = (0, import_fs.statSync)(dir);
|
||
if (!stats.isDirectory()) {
|
||
dir = (0, import_path.dirname)(dir);
|
||
}
|
||
while (true) {
|
||
tmp = callback(dir, (0, import_fs.readdirSync)(dir));
|
||
if (tmp)
|
||
return (0, import_path.resolve)(dir, tmp);
|
||
dir = (0, import_path.dirname)(tmp = dir);
|
||
if (tmp === dir)
|
||
break;
|
||
}
|
||
}
|
||
|
||
// node_modules/yargs/lib/platform-shims/esm.mjs
|
||
var import_util3 = require("util");
|
||
var import_fs4 = require("fs");
|
||
var import_url = require("url");
|
||
|
||
// node_modules/yargs-parser/build/lib/index.js
|
||
var import_util = require("util");
|
||
var import_path2 = require("path");
|
||
|
||
// node_modules/yargs-parser/build/lib/string-utils.js
|
||
function camelCase(str) {
|
||
const isCamelCase = str !== str.toLowerCase() && str !== str.toUpperCase();
|
||
if (!isCamelCase) {
|
||
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(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);
|
||
}
|
||
|
||
// node_modules/yargs-parser/build/lib/tokenize-arg-string.js
|
||
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;
|
||
}
|
||
|
||
// node_modules/yargs-parser/build/lib/yargs-parser-types.js
|
||
var DefaultValuesForTypeKey;
|
||
(function(DefaultValuesForTypeKey2) {
|
||
DefaultValuesForTypeKey2["BOOLEAN"] = "boolean";
|
||
DefaultValuesForTypeKey2["STRING"] = "string";
|
||
DefaultValuesForTypeKey2["NUMBER"] = "number";
|
||
DefaultValuesForTypeKey2["ARRAY"] = "array";
|
||
})(DefaultValuesForTypeKey || (DefaultValuesForTypeKey = {}));
|
||
|
||
// node_modules/yargs-parser/build/lib/yargs-parser.js
|
||
var mixin2;
|
||
var YargsParser = class {
|
||
constructor(_mixin) {
|
||
mixin2 = _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(/* @__PURE__ */ 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 = Object.assign(/* @__PURE__ */ Object.create(null), opts.default);
|
||
const configObjects = opts.configObjects || [];
|
||
const envPrefix = opts.envPrefix;
|
||
const notFlagsOption = configuration["populate--"];
|
||
const notFlagsArgv = notFlagsOption ? "--" : "_";
|
||
const newAliases = /* @__PURE__ */ Object.create(null);
|
||
const defaulted = /* @__PURE__ */ Object.create(null);
|
||
const __ = opts.__ || mixin2.format;
|
||
const flags = {
|
||
aliases: /* @__PURE__ */ Object.create(null),
|
||
arrays: /* @__PURE__ */ Object.create(null),
|
||
bools: /* @__PURE__ */ Object.create(null),
|
||
strings: /* @__PURE__ */ Object.create(null),
|
||
numbers: /* @__PURE__ */ Object.create(null),
|
||
counts: /* @__PURE__ */ Object.create(null),
|
||
normalize: /* @__PURE__ */ Object.create(null),
|
||
configs: /* @__PURE__ */ Object.create(null),
|
||
nargs: /* @__PURE__ */ Object.create(null),
|
||
coercions: /* @__PURE__ */ Object.create(null),
|
||
keys: []
|
||
};
|
||
const negative = /^-([0-9]+(\.[0-9]+)?|\.[0-9]+)$/;
|
||
const negatedBoolean = new RegExp("^--" + configuration["negation-prefix"] + "(.+)");
|
||
[].concat(opts.array || []).filter(Boolean).forEach(function(opt) {
|
||
const key = typeof opt === "object" ? opt.key : opt;
|
||
const assignment = Object.keys(opt).map(function(key2) {
|
||
const arrayFlagKeys = {
|
||
boolean: "bools",
|
||
string: "strings",
|
||
number: "numbers"
|
||
};
|
||
return arrayFlagKeys[key2];
|
||
}).filter(Boolean).pop();
|
||
if (assignment) {
|
||
flags[assignment][key] = true;
|
||
}
|
||
flags.arrays[key] = true;
|
||
flags.keys.push(key);
|
||
});
|
||
[].concat(opts.boolean || []).filter(Boolean).forEach(function(key) {
|
||
flags.bools[key] = true;
|
||
flags.keys.push(key);
|
||
});
|
||
[].concat(opts.string || []).filter(Boolean).forEach(function(key) {
|
||
flags.strings[key] = true;
|
||
flags.keys.push(key);
|
||
});
|
||
[].concat(opts.number || []).filter(Boolean).forEach(function(key) {
|
||
flags.numbers[key] = true;
|
||
flags.keys.push(key);
|
||
});
|
||
[].concat(opts.count || []).filter(Boolean).forEach(function(key) {
|
||
flags.counts[key] = true;
|
||
flags.keys.push(key);
|
||
});
|
||
[].concat(opts.normalize || []).filter(Boolean).forEach(function(key) {
|
||
flags.normalize[key] = true;
|
||
flags.keys.push(key);
|
||
});
|
||
if (typeof opts.narg === "object") {
|
||
Object.entries(opts.narg).forEach(([key, value]) => {
|
||
if (typeof value === "number") {
|
||
flags.nargs[key] = value;
|
||
flags.keys.push(key);
|
||
}
|
||
});
|
||
}
|
||
if (typeof opts.coerce === "object") {
|
||
Object.entries(opts.coerce).forEach(([key, value]) => {
|
||
if (typeof value === "function") {
|
||
flags.coercions[key] = value;
|
||
flags.keys.push(key);
|
||
}
|
||
});
|
||
}
|
||
if (typeof opts.config !== "undefined") {
|
||
if (Array.isArray(opts.config) || typeof opts.config === "string") {
|
||
;
|
||
[].concat(opts.config).filter(Boolean).forEach(function(key) {
|
||
flags.configs[key] = true;
|
||
});
|
||
} else if (typeof opts.config === "object") {
|
||
Object.entries(opts.config).forEach(([key, value]) => {
|
||
if (typeof value === "boolean" || typeof value === "function") {
|
||
flags.configs[key] = value;
|
||
}
|
||
});
|
||
}
|
||
}
|
||
extendAliases(opts.key, aliases, opts.default, flags.arrays);
|
||
Object.keys(defaults).forEach(function(key) {
|
||
(flags.aliases[key] || []).forEach(function(alias) {
|
||
defaults[alias] = defaults[key];
|
||
});
|
||
});
|
||
let error = null;
|
||
checkConfiguration();
|
||
let notFlags = [];
|
||
const argv = Object.assign(/* @__PURE__ */ 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;
|
||
let letters;
|
||
let m;
|
||
let next;
|
||
let value;
|
||
if (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 = m[1];
|
||
setArg(key, checkAllAliases(key, 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 = m[1];
|
||
if (checkAllAliases(key, flags.arrays)) {
|
||
i = eatArray(i, key, args);
|
||
} else if (checkAllAliases(key, flags.nargs) !== false) {
|
||
i = eatNargs(i, key, args);
|
||
} else {
|
||
next = args[i + 1];
|
||
if (next !== void 0 && (!next.match(/^-/) || next.match(negative)) && !checkAllAliases(key, flags.bools) && !checkAllAliases(key, flags.counts)) {
|
||
setArg(key, next);
|
||
i++;
|
||
} else if (/^(true|false)$/.test(next)) {
|
||
setArg(key, next);
|
||
i++;
|
||
} else {
|
||
setArg(key, defaultValue(key));
|
||
}
|
||
}
|
||
}
|
||
} 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 = m[1];
|
||
if (next !== void 0 && !next.match(/^-/) && !checkAllAliases(key, flags.bools) && !checkAllAliases(key, flags.counts)) {
|
||
setArg(key, next);
|
||
i++;
|
||
} else {
|
||
setArg(key, defaultValue(key));
|
||
}
|
||
}
|
||
} 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 = letters[j];
|
||
if (checkAllAliases(key, flags.arrays)) {
|
||
i = eatArray(i, key, args, value);
|
||
} else if (checkAllAliases(key, flags.nargs) !== false) {
|
||
i = eatNargs(i, key, args, value);
|
||
} else {
|
||
setArg(key, 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 = arg.slice(-1)[0];
|
||
if (!broken && key !== "-") {
|
||
if (checkAllAliases(key, flags.arrays)) {
|
||
i = eatArray(i, key, args);
|
||
} else if (checkAllAliases(key, flags.nargs) !== false) {
|
||
i = eatNargs(i, key, args);
|
||
} else {
|
||
next = args[i + 1];
|
||
if (next !== void 0 && (!/^(-|--)[^-]/.test(next) || next.match(negative)) && !checkAllAliases(key, flags.bools) && !checkAllAliases(key, flags.counts)) {
|
||
setArg(key, next);
|
||
i++;
|
||
} else if (/^(true|false)$/.test(next)) {
|
||
setArg(key, next);
|
||
i++;
|
||
} else {
|
||
setArg(key, defaultValue(key));
|
||
}
|
||
}
|
||
}
|
||
} else if (arg.match(/^-[0-9]$/) && arg.match(negative) && checkAllAliases(arg.slice(1), flags.bools)) {
|
||
key = arg.slice(1);
|
||
setArg(key, defaultValue(key));
|
||
} 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, true);
|
||
applyCoercions(argv);
|
||
if (configuration["set-placeholder-key"])
|
||
setPlaceholderKeys(argv);
|
||
Object.keys(flags.counts).forEach(function(key) {
|
||
if (!hasKey(argv, key.split(".")))
|
||
setArg(key, 0);
|
||
});
|
||
if (notFlagsOption && notFlags.length)
|
||
argv[notFlagsArgv] = [];
|
||
notFlags.forEach(function(key) {
|
||
argv[notFlagsArgv].push(key);
|
||
});
|
||
if (configuration["camel-case-expansion"] && configuration["strip-dashed"]) {
|
||
Object.keys(argv).filter((key) => key !== "--" && key.includes("-")).forEach((key) => {
|
||
delete argv[key];
|
||
});
|
||
}
|
||
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(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, args2, argAfterEqualSign) {
|
||
let ii;
|
||
let toEat = checkAllAliases(key, flags.nargs);
|
||
toEat = typeof toEat !== "number" || isNaN(toEat) ? 1 : toEat;
|
||
if (toEat === 0) {
|
||
if (!isUndefined(argAfterEqualSign)) {
|
||
error = Error(__("Argument unexpected for: %s", key));
|
||
}
|
||
setArg(key, defaultValue(key));
|
||
return i;
|
||
}
|
||
let available = isUndefined(argAfterEqualSign) ? 0 : 1;
|
||
if (configuration["nargs-eats-options"]) {
|
||
if (args2.length - (i + 1) + available < toEat) {
|
||
error = Error(__("Not enough arguments following: %s", key));
|
||
}
|
||
available = toEat;
|
||
} else {
|
||
for (ii = i + 1; ii < args2.length; ii++) {
|
||
if (!args2[ii].match(/^-[^0-9]/) || args2[ii].match(negative) || isUnknownOptionAsArg(args2[ii]))
|
||
available++;
|
||
else
|
||
break;
|
||
}
|
||
if (available < toEat)
|
||
error = Error(__("Not enough arguments following: %s", key));
|
||
}
|
||
let consumed = Math.min(available, toEat);
|
||
if (!isUndefined(argAfterEqualSign) && consumed > 0) {
|
||
setArg(key, argAfterEqualSign);
|
||
consumed--;
|
||
}
|
||
for (ii = i + 1; ii < consumed + i + 1; ii++) {
|
||
setArg(key, args2[ii]);
|
||
}
|
||
return i + consumed;
|
||
}
|
||
function eatArray(i, key, args2, argAfterEqualSign) {
|
||
let argsToSet = [];
|
||
let next = argAfterEqualSign || args2[i + 1];
|
||
const nargsCount = checkAllAliases(key, flags.nargs);
|
||
if (checkAllAliases(key, flags.bools) && !/^(true|false)$/.test(next)) {
|
||
argsToSet.push(true);
|
||
} else if (isUndefined(next) || isUndefined(argAfterEqualSign) && /^-/.test(next) && !negative.test(next) && !isUnknownOptionAsArg(next)) {
|
||
if (defaults[key] !== void 0) {
|
||
const defVal = defaults[key];
|
||
argsToSet = Array.isArray(defVal) ? defVal : [defVal];
|
||
}
|
||
} else {
|
||
if (!isUndefined(argAfterEqualSign)) {
|
||
argsToSet.push(processValue(key, argAfterEqualSign, true));
|
||
}
|
||
for (let ii = i + 1; ii < args2.length; ii++) {
|
||
if (!configuration["greedy-arrays"] && argsToSet.length > 0 || nargsCount && typeof nargsCount === "number" && argsToSet.length >= nargsCount)
|
||
break;
|
||
next = args2[ii];
|
||
if (/^-/.test(next) && !negative.test(next) && !isUnknownOptionAsArg(next))
|
||
break;
|
||
i = ii;
|
||
argsToSet.push(processValue(key, next, inputIsString));
|
||
}
|
||
}
|
||
if (typeof nargsCount === "number" && (nargsCount && argsToSet.length < nargsCount || isNaN(nargsCount) && argsToSet.length === 0)) {
|
||
error = Error(__("Not enough arguments following: %s", key));
|
||
}
|
||
setArg(key, argsToSet);
|
||
return i;
|
||
}
|
||
function setArg(key, val, shouldStripQuotes = inputIsString) {
|
||
if (/-/.test(key) && configuration["camel-case-expansion"]) {
|
||
const alias = key.split(".").map(function(prop) {
|
||
return camelCase(prop);
|
||
}).join(".");
|
||
addNewAlias(key, alias);
|
||
}
|
||
const value = processValue(key, val, shouldStripQuotes);
|
||
const splitKey = key.split(".");
|
||
setKey(argv, splitKey, value);
|
||
if (flags.aliases[key]) {
|
||
flags.aliases[key].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] || []).includes(keyProperties.join("."))) {
|
||
setKey(argv, keyProperties, value);
|
||
}
|
||
});
|
||
}
|
||
if (checkAllAliases(key, flags.normalize) && !checkAllAliases(key, flags.arrays)) {
|
||
const keys = [key].concat(flags.aliases[key] || []);
|
||
keys.forEach(function(key2) {
|
||
Object.defineProperty(argvReturn, key2, {
|
||
enumerable: true,
|
||
get() {
|
||
return val;
|
||
},
|
||
set(value2) {
|
||
val = typeof value2 === "string" ? mixin2.normalize(value2) : value2;
|
||
}
|
||
});
|
||
});
|
||
}
|
||
}
|
||
function addNewAlias(key, alias) {
|
||
if (!(flags.aliases[key] && flags.aliases[key].length)) {
|
||
flags.aliases[key] = [alias];
|
||
newAliases[alias] = true;
|
||
}
|
||
if (!(flags.aliases[alias] && flags.aliases[alias].length)) {
|
||
addNewAlias(alias, key);
|
||
}
|
||
}
|
||
function processValue(key, val, shouldStripQuotes) {
|
||
if (shouldStripQuotes) {
|
||
val = stripQuotes(val);
|
||
}
|
||
if (checkAllAliases(key, flags.bools) || checkAllAliases(key, flags.counts)) {
|
||
if (typeof val === "string")
|
||
val = val === "true";
|
||
}
|
||
let value = Array.isArray(val) ? val.map(function(v) {
|
||
return maybeCoerceNumber(key, v);
|
||
}) : maybeCoerceNumber(key, val);
|
||
if (checkAllAliases(key, flags.counts) && (isUndefined(value) || typeof value === "boolean")) {
|
||
value = increment();
|
||
}
|
||
if (checkAllAliases(key, flags.normalize) && checkAllAliases(key, flags.arrays)) {
|
||
if (Array.isArray(val))
|
||
value = val.map((val2) => {
|
||
return mixin2.normalize(val2);
|
||
});
|
||
else
|
||
value = mixin2.normalize(val);
|
||
}
|
||
return value;
|
||
}
|
||
function maybeCoerceNumber(key, value) {
|
||
if (!configuration["parse-positional-numbers"] && key === "_")
|
||
return value;
|
||
if (!checkAllAliases(key, flags.strings) && !checkAllAliases(key, flags.bools) && !Array.isArray(value)) {
|
||
const shouldCoerceNumber = looksLikeNumber(value) && configuration["parse-numbers"] && Number.isSafeInteger(Math.floor(parseFloat(`${value}`)));
|
||
if (shouldCoerceNumber || !isUndefined(value) && checkAllAliases(key, flags.numbers)) {
|
||
value = Number(value);
|
||
}
|
||
}
|
||
return value;
|
||
}
|
||
function setConfig(argv2) {
|
||
const configLookup = /* @__PURE__ */ Object.create(null);
|
||
applyDefaultsAndAliases(configLookup, flags.aliases, defaults);
|
||
Object.keys(flags.configs).forEach(function(configKey) {
|
||
const configPath = argv2[configKey] || configLookup[configKey];
|
||
if (configPath) {
|
||
try {
|
||
let config = null;
|
||
const resolvedConfigPath = mixin2.resolve(mixin2.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 = mixin2.require(resolvedConfigPath);
|
||
}
|
||
setConfigObject(config);
|
||
} catch (ex) {
|
||
if (ex.name === "PermissionDenied")
|
||
error = ex;
|
||
else if (argv2[configKey])
|
||
error = Error(__("Invalid JSON config file: %s", configPath));
|
||
}
|
||
}
|
||
});
|
||
}
|
||
function setConfigObject(config, prev) {
|
||
Object.keys(config).forEach(function(key) {
|
||
const value = config[key];
|
||
const fullKey = prev ? prev + "." + key : key;
|
||
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(argv2, configOnly) {
|
||
if (typeof envPrefix === "undefined")
|
||
return;
|
||
const prefix = typeof envPrefix === "string" ? envPrefix : "";
|
||
const env2 = mixin2.env();
|
||
Object.keys(env2).forEach(function(envVar) {
|
||
if (prefix === "" || envVar.lastIndexOf(prefix, 0) === 0) {
|
||
const keys = envVar.split("__").map(function(key, i) {
|
||
if (i === 0) {
|
||
key = key.substring(prefix.length);
|
||
}
|
||
return camelCase(key);
|
||
});
|
||
if ((configOnly && flags.configs[keys.join(".")] || !configOnly) && !hasKey(argv2, keys)) {
|
||
setArg(keys.join("."), env2[envVar]);
|
||
}
|
||
}
|
||
});
|
||
}
|
||
function applyCoercions(argv2) {
|
||
let coerce;
|
||
const applied = /* @__PURE__ */ new Set();
|
||
Object.keys(argv2).forEach(function(key) {
|
||
if (!applied.has(key)) {
|
||
coerce = checkAllAliases(key, flags.coercions);
|
||
if (typeof coerce === "function") {
|
||
try {
|
||
const value = maybeCoerceNumber(key, coerce(argv2[key]));
|
||
[].concat(flags.aliases[key] || [], key).forEach((ali) => {
|
||
applied.add(ali);
|
||
argv2[ali] = value;
|
||
});
|
||
} catch (err) {
|
||
error = err;
|
||
}
|
||
}
|
||
}
|
||
});
|
||
}
|
||
function setPlaceholderKeys(argv2) {
|
||
flags.keys.forEach((key) => {
|
||
if (~key.indexOf("."))
|
||
return;
|
||
if (typeof argv2[key] === "undefined")
|
||
argv2[key] = void 0;
|
||
});
|
||
return argv2;
|
||
}
|
||
function applyDefaultsAndAliases(obj, aliases2, defaults2, canLog = false) {
|
||
Object.keys(defaults2).forEach(function(key) {
|
||
if (!hasKey(obj, key.split("."))) {
|
||
setKey(obj, key.split("."), defaults2[key]);
|
||
if (canLog)
|
||
defaulted[key] = true;
|
||
(aliases2[key] || []).forEach(function(x) {
|
||
if (hasKey(obj, x.split(".")))
|
||
return;
|
||
setKey(obj, x.split("."), defaults2[key]);
|
||
});
|
||
}
|
||
});
|
||
}
|
||
function hasKey(obj, keys) {
|
||
let o = obj;
|
||
if (!configuration["dot-notation"])
|
||
keys = [keys.join(".")];
|
||
keys.slice(0, -1).forEach(function(key2) {
|
||
o = o[key2] || {};
|
||
});
|
||
const key = keys[keys.length - 1];
|
||
if (typeof o !== "object")
|
||
return false;
|
||
else
|
||
return key in o;
|
||
}
|
||
function setKey(obj, keys, value) {
|
||
let o = obj;
|
||
if (!configuration["dot-notation"])
|
||
keys = [keys.join(".")];
|
||
keys.slice(0, -1).forEach(function(key2) {
|
||
key2 = sanitizeKey(key2);
|
||
if (typeof o === "object" && o[key2] === void 0) {
|
||
o[key2] = {};
|
||
}
|
||
if (typeof o[key2] !== "object" || Array.isArray(o[key2])) {
|
||
if (Array.isArray(o[key2])) {
|
||
o[key2].push({});
|
||
} else {
|
||
o[key2] = [o[key2], {}];
|
||
}
|
||
o = o[key2][o[key2].length - 1];
|
||
} else {
|
||
o = o[key2];
|
||
}
|
||
});
|
||
const key = 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, flags.nargs)) {
|
||
duplicate = true;
|
||
if (!isUndefined(o[key]) && flags.nargs[key] === 1 || Array.isArray(o[key]) && o[key].length === flags.nargs[key]) {
|
||
o[key] = void 0;
|
||
}
|
||
}
|
||
if (value === increment()) {
|
||
o[key] = increment(o[key]);
|
||
} else if (Array.isArray(o[key])) {
|
||
if (duplicate && isTypeArray && isValueArray) {
|
||
o[key] = configuration["flatten-duplicate-arrays"] ? o[key].concat(value) : (Array.isArray(o[key][0]) ? o[key] : [o[key]]).concat([value]);
|
||
} else if (!duplicate && Boolean(isTypeArray) === Boolean(isValueArray)) {
|
||
o[key] = value;
|
||
} else {
|
||
o[key] = o[key].concat([value]);
|
||
}
|
||
} else if (o[key] === void 0 && isTypeArray) {
|
||
o[key] = isValueArray ? value : [value];
|
||
} else if (duplicate && !(o[key] === void 0 || checkAllAliases(key, flags.counts) || checkAllAliases(key, flags.bools))) {
|
||
o[key] = [o[key], value];
|
||
} else {
|
||
o[key] = value;
|
||
}
|
||
}
|
||
function extendAliases(...args2) {
|
||
args2.forEach(function(obj) {
|
||
Object.keys(obj || {}).forEach(function(key) {
|
||
if (flags.aliases[key])
|
||
return;
|
||
flags.aliases[key] = [].concat(aliases[key] || []);
|
||
flags.aliases[key].concat(key).forEach(function(x) {
|
||
if (/-/.test(x) && configuration["camel-case-expansion"]) {
|
||
const c = camelCase(x);
|
||
if (c !== key && flags.aliases[key].indexOf(c) === -1) {
|
||
flags.aliases[key].push(c);
|
||
newAliases[c] = true;
|
||
}
|
||
}
|
||
});
|
||
flags.aliases[key].concat(key).forEach(function(x) {
|
||
if (x.length > 1 && /[A-Z]/.test(x) && configuration["camel-case-expansion"]) {
|
||
const c = decamelize(x, "-");
|
||
if (c !== key && flags.aliases[key].indexOf(c) === -1) {
|
||
flags.aliases[key].push(c);
|
||
newAliases[c] = true;
|
||
}
|
||
}
|
||
});
|
||
flags.aliases[key].forEach(function(x) {
|
||
flags.aliases[x] = [key].concat(flags.aliases[key].filter(function(y) {
|
||
return x !== y;
|
||
}));
|
||
});
|
||
});
|
||
});
|
||
}
|
||
function checkAllAliases(key, flag) {
|
||
const toCheck = [].concat(flags.aliases[key] || [], key);
|
||
const keys = Object.keys(flag);
|
||
const setAlias = toCheck.find((key2) => keys.includes(key2));
|
||
return setAlias ? flag[setAlias] : false;
|
||
}
|
||
function hasAnyFlag(key) {
|
||
const flagsKeys = Object.keys(flags);
|
||
const toCheck = [].concat(flagsKeys.map((k) => flags[k]));
|
||
return toCheck.some(function(flag) {
|
||
return Array.isArray(flag) ? flag.includes(key) : flag[key];
|
||
});
|
||
}
|
||
function hasFlagsMatching(arg, ...patterns) {
|
||
const toCheck = [].concat(...patterns);
|
||
return toCheck.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;
|
||
}
|
||
const flagWithEquals = /^-+([^=]+?)=[\s\S]*$/;
|
||
const normalFlag = /^-+([^=]+?)$/;
|
||
const flagEndingInHyphen = /^-+([^=]+?)-$/;
|
||
const flagEndingInDigits = /^-+([^=]+?\d+)$/;
|
||
const flagEndingInNonWordCharacters = /^-+([^=]+?)\W+.*$/;
|
||
return !hasFlagsMatching(arg, flagWithEquals, negatedBoolean, normalFlag, flagEndingInHyphen, flagEndingInDigits, flagEndingInNonWordCharacters);
|
||
}
|
||
function defaultValue(key) {
|
||
if (!checkAllAliases(key, flags.bools) && !checkAllAliases(key, flags.counts) && `${key}` in defaults) {
|
||
return defaults[key];
|
||
} else {
|
||
return defaultForType(guessType2(key));
|
||
}
|
||
}
|
||
function defaultForType(type) {
|
||
const def = {
|
||
[DefaultValuesForTypeKey.BOOLEAN]: true,
|
||
[DefaultValuesForTypeKey.STRING]: "",
|
||
[DefaultValuesForTypeKey.NUMBER]: void 0,
|
||
[DefaultValuesForTypeKey.ARRAY]: []
|
||
};
|
||
return def[type];
|
||
}
|
||
function guessType2(key) {
|
||
let type = DefaultValuesForTypeKey.BOOLEAN;
|
||
if (checkAllAliases(key, flags.strings))
|
||
type = DefaultValuesForTypeKey.STRING;
|
||
else if (checkAllAliases(key, flags.numbers))
|
||
type = DefaultValuesForTypeKey.NUMBER;
|
||
else if (checkAllAliases(key, flags.bools))
|
||
type = DefaultValuesForTypeKey.BOOLEAN;
|
||
else if (checkAllAliases(key, flags.arrays))
|
||
type = DefaultValuesForTypeKey.ARRAY;
|
||
return type;
|
||
}
|
||
function isUndefined(num) {
|
||
return num === void 0;
|
||
}
|
||
function checkConfiguration() {
|
||
Object.keys(flags.counts).find((key) => {
|
||
if (checkAllAliases(key, flags.arrays)) {
|
||
error = Error(__("Invalid configuration: %s, opts.count excludes opts.array.", key));
|
||
return true;
|
||
} else if (checkAllAliases(key, flags.nargs)) {
|
||
error = Error(__("Invalid configuration: %s, opts.count excludes opts.narg.", key));
|
||
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 = /* @__PURE__ */ Object.create(null);
|
||
let change = true;
|
||
Object.keys(aliases).forEach(function(key) {
|
||
aliasArrays.push([].concat(aliases[key], key));
|
||
});
|
||
while (change) {
|
||
change = false;
|
||
for (let i = 0; i < aliasArrays.length; i++) {
|
||
for (let ii = i + 1; ii < aliasArrays.length; ii++) {
|
||
const intersect = aliasArrays[i].filter(function(v) {
|
||
return aliasArrays[ii].indexOf(v) !== -1;
|
||
});
|
||
if (intersect.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) {
|
||
if (key === "__proto__")
|
||
return "___proto___";
|
||
return key;
|
||
}
|
||
function stripQuotes(val) {
|
||
return typeof val === "string" && (val[0] === "'" || val[0] === '"') && val[val.length - 1] === val[0] ? val.substring(1, val.length - 1) : val;
|
||
}
|
||
|
||
// node_modules/yargs-parser/build/lib/index.js
|
||
var import_fs2 = require("fs");
|
||
var minNodeVersion = process && process.env && process.env.YARGS_MIN_NODE_VERSION ? Number(process.env.YARGS_MIN_NODE_VERSION) : 12;
|
||
if (process && process.version) {
|
||
const major = Number(process.version.match(/v([^.]+)/)[1]);
|
||
if (major < 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`);
|
||
}
|
||
}
|
||
var env = process ? process.env : {};
|
||
var parser = new YargsParser({
|
||
cwd: process.cwd,
|
||
env: () => {
|
||
return env;
|
||
},
|
||
format: import_util.format,
|
||
normalize: import_path2.normalize,
|
||
resolve: import_path2.resolve,
|
||
require: (path) => {
|
||
if (typeof require !== "undefined") {
|
||
return require(path);
|
||
} else if (path.match(/\.json$/)) {
|
||
return JSON.parse((0, import_fs2.readFileSync)(path, "utf8"));
|
||
} else {
|
||
throw Error("only .json config files are supported in ESM");
|
||
}
|
||
}
|
||
});
|
||
var yargsParser = function Parser(args, opts) {
|
||
const result = parser.parse(args.slice(), opts);
|
||
return result.argv;
|
||
};
|
||
yargsParser.detailed = function(args, opts) {
|
||
return parser.parse(args.slice(), opts);
|
||
};
|
||
yargsParser.camelCase = camelCase;
|
||
yargsParser.decamelize = decamelize;
|
||
yargsParser.looksLikeNumber = looksLikeNumber;
|
||
var lib_default = yargsParser;
|
||
|
||
// node_modules/yargs/lib/platform-shims/esm.mjs
|
||
var import_path4 = require("path");
|
||
|
||
// node_modules/yargs/build/lib/utils/process-argv.js
|
||
function getProcessArgvBinIndex() {
|
||
if (isBundledElectronApp())
|
||
return 0;
|
||
return 1;
|
||
}
|
||
function isBundledElectronApp() {
|
||
return isElectronApp() && !process.defaultApp;
|
||
}
|
||
function isElectronApp() {
|
||
return !!process.versions.electron;
|
||
}
|
||
function hideBin(argv) {
|
||
return argv.slice(getProcessArgvBinIndex() + 1);
|
||
}
|
||
function getProcessArgvBin() {
|
||
return process.argv[getProcessArgvBinIndex()];
|
||
}
|
||
|
||
// node_modules/yargs/build/lib/yerror.js
|
||
var YError = class extends Error {
|
||
constructor(msg) {
|
||
super(msg || "yargs error");
|
||
this.name = "YError";
|
||
Error.captureStackTrace(this, YError);
|
||
}
|
||
};
|
||
|
||
// node_modules/y18n/build/lib/platform-shims/node.js
|
||
var import_fs3 = require("fs");
|
||
var import_util2 = require("util");
|
||
var import_path3 = require("path");
|
||
var node_default = {
|
||
fs: {
|
||
readFileSync: import_fs3.readFileSync,
|
||
writeFile: import_fs3.writeFile
|
||
},
|
||
format: import_util2.format,
|
||
resolve: import_path3.resolve,
|
||
exists: (file) => {
|
||
try {
|
||
return (0, import_fs3.statSync)(file).isFile();
|
||
} catch (err) {
|
||
return false;
|
||
}
|
||
}
|
||
};
|
||
|
||
// node_modules/y18n/build/lib/index.js
|
||
var shim;
|
||
var Y18N = class {
|
||
constructor(opts) {
|
||
opts = opts || {};
|
||
this.directory = opts.directory || "./locales";
|
||
this.updateFiles = typeof opts.updateFiles === "boolean" ? opts.updateFiles : true;
|
||
this.locale = opts.locale || "en";
|
||
this.fallbackToLanguage = typeof opts.fallbackToLanguage === "boolean" ? opts.fallbackToLanguage : true;
|
||
this.cache = /* @__PURE__ */ Object.create(null);
|
||
this.writeQueue = [];
|
||
}
|
||
__(...args) {
|
||
if (typeof arguments[0] !== "string") {
|
||
return this._taggedLiteral(arguments[0], ...arguments);
|
||
}
|
||
const str = args.shift();
|
||
let cb = function() {
|
||
};
|
||
if (typeof args[args.length - 1] === "function")
|
||
cb = args.pop();
|
||
cb = cb || function() {
|
||
};
|
||
if (!this.cache[this.locale])
|
||
this._readLocaleFile();
|
||
if (!this.cache[this.locale][str] && this.updateFiles) {
|
||
this.cache[this.locale][str] = str;
|
||
this._enqueueWrite({
|
||
directory: this.directory,
|
||
locale: this.locale,
|
||
cb
|
||
});
|
||
} else {
|
||
cb();
|
||
}
|
||
return shim.format.apply(shim.format, [this.cache[this.locale][str] || str].concat(args));
|
||
}
|
||
__n() {
|
||
const args = Array.prototype.slice.call(arguments);
|
||
const singular = args.shift();
|
||
const plural = args.shift();
|
||
const quantity = args.shift();
|
||
let cb = function() {
|
||
};
|
||
if (typeof args[args.length - 1] === "function")
|
||
cb = args.pop();
|
||
if (!this.cache[this.locale])
|
||
this._readLocaleFile();
|
||
let str = quantity === 1 ? singular : plural;
|
||
if (this.cache[this.locale][singular]) {
|
||
const entry = this.cache[this.locale][singular];
|
||
str = entry[quantity === 1 ? "one" : "other"];
|
||
}
|
||
if (!this.cache[this.locale][singular] && this.updateFiles) {
|
||
this.cache[this.locale][singular] = {
|
||
one: singular,
|
||
other: plural
|
||
};
|
||
this._enqueueWrite({
|
||
directory: this.directory,
|
||
locale: this.locale,
|
||
cb
|
||
});
|
||
} else {
|
||
cb();
|
||
}
|
||
const values = [str];
|
||
if (~str.indexOf("%d"))
|
||
values.push(quantity);
|
||
return shim.format.apply(shim.format, values.concat(args));
|
||
}
|
||
setLocale(locale) {
|
||
this.locale = locale;
|
||
}
|
||
getLocale() {
|
||
return this.locale;
|
||
}
|
||
updateLocale(obj) {
|
||
if (!this.cache[this.locale])
|
||
this._readLocaleFile();
|
||
for (const key in obj) {
|
||
if (Object.prototype.hasOwnProperty.call(obj, key)) {
|
||
this.cache[this.locale][key] = obj[key];
|
||
}
|
||
}
|
||
}
|
||
_taggedLiteral(parts, ...args) {
|
||
let str = "";
|
||
parts.forEach(function(part, i) {
|
||
const arg = args[i + 1];
|
||
str += part;
|
||
if (typeof arg !== "undefined") {
|
||
str += "%s";
|
||
}
|
||
});
|
||
return this.__.apply(this, [str].concat([].slice.call(args, 1)));
|
||
}
|
||
_enqueueWrite(work) {
|
||
this.writeQueue.push(work);
|
||
if (this.writeQueue.length === 1)
|
||
this._processWriteQueue();
|
||
}
|
||
_processWriteQueue() {
|
||
const _this = this;
|
||
const work = this.writeQueue[0];
|
||
const directory = work.directory;
|
||
const locale = work.locale;
|
||
const cb = work.cb;
|
||
const languageFile = this._resolveLocaleFile(directory, locale);
|
||
const serializedLocale = JSON.stringify(this.cache[locale], null, 2);
|
||
shim.fs.writeFile(languageFile, serializedLocale, "utf-8", function(err) {
|
||
_this.writeQueue.shift();
|
||
if (_this.writeQueue.length > 0)
|
||
_this._processWriteQueue();
|
||
cb(err);
|
||
});
|
||
}
|
||
_readLocaleFile() {
|
||
let localeLookup = {};
|
||
const languageFile = this._resolveLocaleFile(this.directory, this.locale);
|
||
try {
|
||
if (shim.fs.readFileSync) {
|
||
localeLookup = JSON.parse(shim.fs.readFileSync(languageFile, "utf-8"));
|
||
}
|
||
} catch (err) {
|
||
if (err instanceof SyntaxError) {
|
||
err.message = "syntax error in " + languageFile;
|
||
}
|
||
if (err.code === "ENOENT")
|
||
localeLookup = {};
|
||
else
|
||
throw err;
|
||
}
|
||
this.cache[this.locale] = localeLookup;
|
||
}
|
||
_resolveLocaleFile(directory, locale) {
|
||
let file = shim.resolve(directory, "./", locale + ".json");
|
||
if (this.fallbackToLanguage && !this._fileExistsSync(file) && ~locale.lastIndexOf("_")) {
|
||
const languageFile = shim.resolve(directory, "./", locale.split("_")[0] + ".json");
|
||
if (this._fileExistsSync(languageFile))
|
||
file = languageFile;
|
||
}
|
||
return file;
|
||
}
|
||
_fileExistsSync(file) {
|
||
return shim.exists(file);
|
||
}
|
||
};
|
||
function y18n(opts, _shim) {
|
||
shim = _shim;
|
||
const y18n3 = new Y18N(opts);
|
||
return {
|
||
__: y18n3.__.bind(y18n3),
|
||
__n: y18n3.__n.bind(y18n3),
|
||
setLocale: y18n3.setLocale.bind(y18n3),
|
||
getLocale: y18n3.getLocale.bind(y18n3),
|
||
updateLocale: y18n3.updateLocale.bind(y18n3),
|
||
locale: y18n3.locale
|
||
};
|
||
}
|
||
|
||
// node_modules/y18n/index.mjs
|
||
var y18n2 = (opts) => {
|
||
return y18n(opts, node_default);
|
||
};
|
||
var y18n_default = y18n2;
|
||
|
||
// node_modules/yargs/lib/platform-shims/esm.mjs
|
||
var import_meta = {};
|
||
var REQUIRE_ERROR = "require is not supported by ESM";
|
||
var REQUIRE_DIRECTORY_ERROR = "loading a directory of commands is not supported yet for ESM";
|
||
var __dirname2;
|
||
try {
|
||
__dirname2 = (0, import_url.fileURLToPath)(import_meta.url);
|
||
} catch (e) {
|
||
__dirname2 = process.cwd();
|
||
}
|
||
var mainFilename = __dirname2.split("node_modules")[0];
|
||
var esm_default = {
|
||
assert: {
|
||
notStrictEqual: import_assert.notStrictEqual,
|
||
strictEqual: import_assert.strictEqual
|
||
},
|
||
cliui: ui,
|
||
findUp: sync_default,
|
||
getEnv: (key) => {
|
||
return process.env[key];
|
||
},
|
||
inspect: import_util3.inspect,
|
||
getCallerFile: () => {
|
||
throw new YError(REQUIRE_DIRECTORY_ERROR);
|
||
},
|
||
getProcessArgvBin,
|
||
mainFilename: mainFilename || process.cwd(),
|
||
Parser: lib_default,
|
||
path: {
|
||
basename: import_path4.basename,
|
||
dirname: import_path4.dirname,
|
||
extname: import_path4.extname,
|
||
relative: import_path4.relative,
|
||
resolve: import_path4.resolve
|
||
},
|
||
process: {
|
||
argv: () => process.argv,
|
||
cwd: process.cwd,
|
||
emitWarning: (warning, type) => process.emitWarning(warning, type),
|
||
execPath: () => process.execPath,
|
||
exit: process.exit,
|
||
nextTick: process.nextTick,
|
||
stdColumns: typeof process.stdout.columns !== "undefined" ? process.stdout.columns : null
|
||
},
|
||
readFileSync: import_fs4.readFileSync,
|
||
require: () => {
|
||
throw new YError(REQUIRE_ERROR);
|
||
},
|
||
requireDirectory: () => {
|
||
throw new YError(REQUIRE_DIRECTORY_ERROR);
|
||
},
|
||
stringWidth: (str) => {
|
||
return [...str].length;
|
||
},
|
||
y18n: y18n_default({
|
||
directory: (0, import_path4.resolve)(__dirname2, "../../../locales"),
|
||
updateFiles: false
|
||
})
|
||
};
|
||
|
||
// node_modules/yargs/build/lib/typings/common-types.js
|
||
function assertNotStrictEqual(actual, expected, shim3, message) {
|
||
shim3.assert.notStrictEqual(actual, expected, message);
|
||
}
|
||
function assertSingleKey(actual, shim3) {
|
||
shim3.assert.strictEqual(typeof actual, "string");
|
||
}
|
||
function objectKeys(object) {
|
||
return Object.keys(object);
|
||
}
|
||
|
||
// node_modules/yargs/build/lib/utils/is-promise.js
|
||
function isPromise(maybePromise) {
|
||
return !!maybePromise && !!maybePromise.then && typeof maybePromise.then === "function";
|
||
}
|
||
|
||
// node_modules/yargs/build/lib/parse-command.js
|
||
function parseCommand(cmd) {
|
||
const extraSpacesStrippedCommand = cmd.replace(/\s{2,}/g, " ");
|
||
const splitCommand = extraSpacesStrippedCommand.split(/\s+(?![^[]*]|[^<]*>)/);
|
||
const bregex = /\.*[\][<>]/g;
|
||
const firstCommand = splitCommand.shift();
|
||
if (!firstCommand)
|
||
throw new Error(`No command found in: ${cmd}`);
|
||
const parsedCommand = {
|
||
cmd: firstCommand.replace(bregex, ""),
|
||
demanded: [],
|
||
optional: []
|
||
};
|
||
splitCommand.forEach((cmd2, i) => {
|
||
let variadic = false;
|
||
cmd2 = cmd2.replace(/\s/g, "");
|
||
if (/\.+[\]>]/.test(cmd2) && i === splitCommand.length - 1)
|
||
variadic = true;
|
||
if (/^\[/.test(cmd2)) {
|
||
parsedCommand.optional.push({
|
||
cmd: cmd2.replace(bregex, "").split("|"),
|
||
variadic
|
||
});
|
||
} else {
|
||
parsedCommand.demanded.push({
|
||
cmd: cmd2.replace(bregex, "").split("|"),
|
||
variadic
|
||
});
|
||
}
|
||
});
|
||
return parsedCommand;
|
||
}
|
||
|
||
// node_modules/yargs/build/lib/argsert.js
|
||
var positionName = ["first", "second", "third", "fourth", "fifth", "sixth"];
|
||
function argsert(arg1, arg2, arg3) {
|
||
function parseArgs() {
|
||
return typeof arg1 === "object" ? [{ demanded: [], optional: [] }, arg1, arg2] : [
|
||
parseCommand(`cmd ${arg1}`),
|
||
arg2,
|
||
arg3
|
||
];
|
||
}
|
||
try {
|
||
let position = 0;
|
||
const [parsed, callerArguments, _length] = parseArgs();
|
||
const args = [].slice.call(callerArguments);
|
||
while (args.length && args[args.length - 1] === void 0)
|
||
args.pop();
|
||
const length = _length || args.length;
|
||
if (length < parsed.demanded.length) {
|
||
throw new YError(`Not enough arguments provided. Expected ${parsed.demanded.length} but received ${args.length}.`);
|
||
}
|
||
const totalCommands = parsed.demanded.length + parsed.optional.length;
|
||
if (length > totalCommands) {
|
||
throw new YError(`Too many arguments provided. Expected max ${totalCommands} but received ${length}.`);
|
||
}
|
||
parsed.demanded.forEach((demanded) => {
|
||
const arg = args.shift();
|
||
const observedType = guessType(arg);
|
||
const matchingTypes = demanded.cmd.filter((type) => type === observedType || type === "*");
|
||
if (matchingTypes.length === 0)
|
||
argumentTypeError(observedType, demanded.cmd, position);
|
||
position += 1;
|
||
});
|
||
parsed.optional.forEach((optional) => {
|
||
if (args.length === 0)
|
||
return;
|
||
const arg = args.shift();
|
||
const observedType = guessType(arg);
|
||
const matchingTypes = optional.cmd.filter((type) => type === observedType || type === "*");
|
||
if (matchingTypes.length === 0)
|
||
argumentTypeError(observedType, optional.cmd, position);
|
||
position += 1;
|
||
});
|
||
} catch (err) {
|
||
console.warn(err.stack);
|
||
}
|
||
}
|
||
function guessType(arg) {
|
||
if (Array.isArray(arg)) {
|
||
return "array";
|
||
} else if (arg === null) {
|
||
return "null";
|
||
}
|
||
return typeof arg;
|
||
}
|
||
function argumentTypeError(observedType, allowedTypes, position) {
|
||
throw new YError(`Invalid ${positionName[position] || "manyith"} argument. Expected ${allowedTypes.join(" or ")} but received ${observedType}.`);
|
||
}
|
||
|
||
// node_modules/yargs/build/lib/middleware.js
|
||
var GlobalMiddleware = class {
|
||
constructor(yargs) {
|
||
this.globalMiddleware = [];
|
||
this.frozens = [];
|
||
this.yargs = yargs;
|
||
}
|
||
addMiddleware(callback, applyBeforeValidation, global2 = true, mutates = false) {
|
||
argsert("<array|function> [boolean] [boolean] [boolean]", [callback, applyBeforeValidation, global2], arguments.length);
|
||
if (Array.isArray(callback)) {
|
||
for (let i = 0; i < callback.length; i++) {
|
||
if (typeof callback[i] !== "function") {
|
||
throw Error("middleware must be a function");
|
||
}
|
||
const m = callback[i];
|
||
m.applyBeforeValidation = applyBeforeValidation;
|
||
m.global = global2;
|
||
}
|
||
Array.prototype.push.apply(this.globalMiddleware, callback);
|
||
} else if (typeof callback === "function") {
|
||
const m = callback;
|
||
m.applyBeforeValidation = applyBeforeValidation;
|
||
m.global = global2;
|
||
m.mutates = mutates;
|
||
this.globalMiddleware.push(callback);
|
||
}
|
||
return this.yargs;
|
||
}
|
||
addCoerceMiddleware(callback, option) {
|
||
const aliases = this.yargs.getAliases();
|
||
this.globalMiddleware = this.globalMiddleware.filter((m) => {
|
||
const toCheck = [...aliases[option] || [], option];
|
||
if (!m.option)
|
||
return true;
|
||
else
|
||
return !toCheck.includes(m.option);
|
||
});
|
||
callback.option = option;
|
||
return this.addMiddleware(callback, true, true, true);
|
||
}
|
||
getMiddleware() {
|
||
return this.globalMiddleware;
|
||
}
|
||
freeze() {
|
||
this.frozens.push([...this.globalMiddleware]);
|
||
}
|
||
unfreeze() {
|
||
const frozen = this.frozens.pop();
|
||
if (frozen !== void 0)
|
||
this.globalMiddleware = frozen;
|
||
}
|
||
reset() {
|
||
this.globalMiddleware = this.globalMiddleware.filter((m) => m.global);
|
||
}
|
||
};
|
||
function commandMiddlewareFactory(commandMiddleware) {
|
||
if (!commandMiddleware)
|
||
return [];
|
||
return commandMiddleware.map((middleware) => {
|
||
middleware.applyBeforeValidation = false;
|
||
return middleware;
|
||
});
|
||
}
|
||
function applyMiddleware(argv, yargs, middlewares, beforeValidation) {
|
||
return middlewares.reduce((acc, middleware) => {
|
||
if (middleware.applyBeforeValidation !== beforeValidation) {
|
||
return acc;
|
||
}
|
||
if (middleware.mutates) {
|
||
if (middleware.applied)
|
||
return acc;
|
||
middleware.applied = true;
|
||
}
|
||
if (isPromise(acc)) {
|
||
return acc.then((initialObj) => Promise.all([initialObj, middleware(initialObj, yargs)])).then(([initialObj, middlewareObj]) => Object.assign(initialObj, middlewareObj));
|
||
} else {
|
||
const result = middleware(acc, yargs);
|
||
return isPromise(result) ? result.then((middlewareObj) => Object.assign(acc, middlewareObj)) : Object.assign(acc, result);
|
||
}
|
||
}, argv);
|
||
}
|
||
|
||
// node_modules/yargs/build/lib/utils/maybe-async-result.js
|
||
function maybeAsyncResult(getResult, resultHandler, errorHandler = (err) => {
|
||
throw err;
|
||
}) {
|
||
try {
|
||
const result = isFunction(getResult) ? getResult() : getResult;
|
||
return isPromise(result) ? result.then((result2) => resultHandler(result2)) : resultHandler(result);
|
||
} catch (err) {
|
||
return errorHandler(err);
|
||
}
|
||
}
|
||
function isFunction(arg) {
|
||
return typeof arg === "function";
|
||
}
|
||
|
||
// node_modules/yargs/build/lib/utils/which-module.js
|
||
function whichModule(exported) {
|
||
if (typeof require === "undefined")
|
||
return null;
|
||
for (let i = 0, files = Object.keys(require.cache), mod; i < files.length; i++) {
|
||
mod = require.cache[files[i]];
|
||
if (mod.exports === exported)
|
||
return mod;
|
||
}
|
||
return null;
|
||
}
|
||
|
||
// node_modules/yargs/build/lib/command.js
|
||
var DEFAULT_MARKER = /(^\*)|(^\$0)/;
|
||
var CommandInstance = class {
|
||
constructor(usage2, validation2, globalMiddleware, shim3) {
|
||
this.requireCache = /* @__PURE__ */ new Set();
|
||
this.handlers = {};
|
||
this.aliasMap = {};
|
||
this.frozens = [];
|
||
this.shim = shim3;
|
||
this.usage = usage2;
|
||
this.globalMiddleware = globalMiddleware;
|
||
this.validation = validation2;
|
||
}
|
||
addDirectory(dir, req, callerFile, opts) {
|
||
opts = opts || {};
|
||
if (typeof opts.recurse !== "boolean")
|
||
opts.recurse = false;
|
||
if (!Array.isArray(opts.extensions))
|
||
opts.extensions = ["js"];
|
||
const parentVisit = typeof opts.visit === "function" ? opts.visit : (o) => o;
|
||
opts.visit = (obj, joined, filename) => {
|
||
const visited = parentVisit(obj, joined, filename);
|
||
if (visited) {
|
||
if (this.requireCache.has(joined))
|
||
return visited;
|
||
else
|
||
this.requireCache.add(joined);
|
||
this.addHandler(visited);
|
||
}
|
||
return visited;
|
||
};
|
||
this.shim.requireDirectory({ require: req, filename: callerFile }, dir, opts);
|
||
}
|
||
addHandler(cmd, description, builder, handler, commandMiddleware, deprecated) {
|
||
let aliases = [];
|
||
const middlewares = commandMiddlewareFactory(commandMiddleware);
|
||
handler = handler || (() => {
|
||
});
|
||
if (Array.isArray(cmd)) {
|
||
if (isCommandAndAliases(cmd)) {
|
||
[cmd, ...aliases] = cmd;
|
||
} else {
|
||
for (const command2 of cmd) {
|
||
this.addHandler(command2);
|
||
}
|
||
}
|
||
} else if (isCommandHandlerDefinition(cmd)) {
|
||
let command2 = Array.isArray(cmd.command) || typeof cmd.command === "string" ? cmd.command : this.moduleName(cmd);
|
||
if (cmd.aliases)
|
||
command2 = [].concat(command2).concat(cmd.aliases);
|
||
this.addHandler(command2, this.extractDesc(cmd), cmd.builder, cmd.handler, cmd.middlewares, cmd.deprecated);
|
||
return;
|
||
} else if (isCommandBuilderDefinition(builder)) {
|
||
this.addHandler([cmd].concat(aliases), description, builder.builder, builder.handler, builder.middlewares, builder.deprecated);
|
||
return;
|
||
}
|
||
if (typeof cmd === "string") {
|
||
const parsedCommand = parseCommand(cmd);
|
||
aliases = aliases.map((alias) => parseCommand(alias).cmd);
|
||
let isDefault = false;
|
||
const parsedAliases = [parsedCommand.cmd].concat(aliases).filter((c) => {
|
||
if (DEFAULT_MARKER.test(c)) {
|
||
isDefault = true;
|
||
return false;
|
||
}
|
||
return true;
|
||
});
|
||
if (parsedAliases.length === 0 && isDefault)
|
||
parsedAliases.push("$0");
|
||
if (isDefault) {
|
||
parsedCommand.cmd = parsedAliases[0];
|
||
aliases = parsedAliases.slice(1);
|
||
cmd = cmd.replace(DEFAULT_MARKER, parsedCommand.cmd);
|
||
}
|
||
aliases.forEach((alias) => {
|
||
this.aliasMap[alias] = parsedCommand.cmd;
|
||
});
|
||
if (description !== false) {
|
||
this.usage.command(cmd, description, isDefault, aliases, deprecated);
|
||
}
|
||
this.handlers[parsedCommand.cmd] = {
|
||
original: cmd,
|
||
description,
|
||
handler,
|
||
builder: builder || {},
|
||
middlewares,
|
||
deprecated,
|
||
demanded: parsedCommand.demanded,
|
||
optional: parsedCommand.optional
|
||
};
|
||
if (isDefault)
|
||
this.defaultCommand = this.handlers[parsedCommand.cmd];
|
||
}
|
||
}
|
||
getCommandHandlers() {
|
||
return this.handlers;
|
||
}
|
||
getCommands() {
|
||
return Object.keys(this.handlers).concat(Object.keys(this.aliasMap));
|
||
}
|
||
hasDefaultCommand() {
|
||
return !!this.defaultCommand;
|
||
}
|
||
runCommand(command2, yargs, parsed, commandIndex, helpOnly, helpOrVersionSet) {
|
||
const commandHandler = this.handlers[command2] || this.handlers[this.aliasMap[command2]] || this.defaultCommand;
|
||
const currentContext = yargs.getInternalMethods().getContext();
|
||
const parentCommands = currentContext.commands.slice();
|
||
const isDefaultCommand = !command2;
|
||
if (command2) {
|
||
currentContext.commands.push(command2);
|
||
currentContext.fullCommands.push(commandHandler.original);
|
||
}
|
||
const builderResult = this.applyBuilderUpdateUsageAndParse(isDefaultCommand, commandHandler, yargs, parsed.aliases, parentCommands, commandIndex, helpOnly, helpOrVersionSet);
|
||
return isPromise(builderResult) ? builderResult.then((result) => this.applyMiddlewareAndGetResult(isDefaultCommand, commandHandler, result.innerArgv, currentContext, helpOnly, result.aliases, yargs)) : this.applyMiddlewareAndGetResult(isDefaultCommand, commandHandler, builderResult.innerArgv, currentContext, helpOnly, builderResult.aliases, yargs);
|
||
}
|
||
applyBuilderUpdateUsageAndParse(isDefaultCommand, commandHandler, yargs, aliases, parentCommands, commandIndex, helpOnly, helpOrVersionSet) {
|
||
const builder = commandHandler.builder;
|
||
let innerYargs = yargs;
|
||
if (isCommandBuilderCallback(builder)) {
|
||
const builderOutput = builder(yargs.getInternalMethods().reset(aliases), helpOrVersionSet);
|
||
if (isPromise(builderOutput)) {
|
||
return builderOutput.then((output) => {
|
||
innerYargs = isYargsInstance(output) ? output : yargs;
|
||
return this.parseAndUpdateUsage(isDefaultCommand, commandHandler, innerYargs, parentCommands, commandIndex, helpOnly);
|
||
});
|
||
}
|
||
} else if (isCommandBuilderOptionDefinitions(builder)) {
|
||
innerYargs = yargs.getInternalMethods().reset(aliases);
|
||
Object.keys(commandHandler.builder).forEach((key) => {
|
||
innerYargs.option(key, builder[key]);
|
||
});
|
||
}
|
||
return this.parseAndUpdateUsage(isDefaultCommand, commandHandler, innerYargs, parentCommands, commandIndex, helpOnly);
|
||
}
|
||
parseAndUpdateUsage(isDefaultCommand, commandHandler, innerYargs, parentCommands, commandIndex, helpOnly) {
|
||
if (isDefaultCommand)
|
||
innerYargs.getInternalMethods().getUsageInstance().unfreeze();
|
||
if (this.shouldUpdateUsage(innerYargs)) {
|
||
innerYargs.getInternalMethods().getUsageInstance().usage(this.usageFromParentCommandsCommandHandler(parentCommands, commandHandler), commandHandler.description);
|
||
}
|
||
const innerArgv = innerYargs.getInternalMethods().runYargsParserAndExecuteCommands(null, void 0, true, commandIndex, helpOnly);
|
||
return isPromise(innerArgv) ? innerArgv.then((argv) => ({
|
||
aliases: innerYargs.parsed.aliases,
|
||
innerArgv: argv
|
||
})) : {
|
||
aliases: innerYargs.parsed.aliases,
|
||
innerArgv
|
||
};
|
||
}
|
||
shouldUpdateUsage(yargs) {
|
||
return !yargs.getInternalMethods().getUsageInstance().getUsageDisabled() && yargs.getInternalMethods().getUsageInstance().getUsage().length === 0;
|
||
}
|
||
usageFromParentCommandsCommandHandler(parentCommands, commandHandler) {
|
||
const c = DEFAULT_MARKER.test(commandHandler.original) ? commandHandler.original.replace(DEFAULT_MARKER, "").trim() : commandHandler.original;
|
||
const pc = parentCommands.filter((c2) => {
|
||
return !DEFAULT_MARKER.test(c2);
|
||
});
|
||
pc.push(c);
|
||
return `$0 ${pc.join(" ")}`;
|
||
}
|
||
applyMiddlewareAndGetResult(isDefaultCommand, commandHandler, innerArgv, currentContext, helpOnly, aliases, yargs) {
|
||
let positionalMap = {};
|
||
if (helpOnly)
|
||
return innerArgv;
|
||
if (!yargs.getInternalMethods().getHasOutput()) {
|
||
positionalMap = this.populatePositionals(commandHandler, innerArgv, currentContext, yargs);
|
||
}
|
||
const middlewares = this.globalMiddleware.getMiddleware().slice(0).concat(commandHandler.middlewares);
|
||
innerArgv = applyMiddleware(innerArgv, yargs, middlewares, true);
|
||
if (!yargs.getInternalMethods().getHasOutput()) {
|
||
const validation2 = yargs.getInternalMethods().runValidation(aliases, positionalMap, yargs.parsed.error, isDefaultCommand);
|
||
innerArgv = maybeAsyncResult(innerArgv, (result) => {
|
||
validation2(result);
|
||
return result;
|
||
});
|
||
}
|
||
if (commandHandler.handler && !yargs.getInternalMethods().getHasOutput()) {
|
||
yargs.getInternalMethods().setHasOutput();
|
||
const populateDoubleDash = !!yargs.getOptions().configuration["populate--"];
|
||
yargs.getInternalMethods().postProcess(innerArgv, populateDoubleDash, false, false);
|
||
innerArgv = applyMiddleware(innerArgv, yargs, middlewares, false);
|
||
innerArgv = maybeAsyncResult(innerArgv, (result) => {
|
||
const handlerResult = commandHandler.handler(result);
|
||
return isPromise(handlerResult) ? handlerResult.then(() => result) : result;
|
||
});
|
||
if (!isDefaultCommand) {
|
||
yargs.getInternalMethods().getUsageInstance().cacheHelpMessage();
|
||
}
|
||
if (isPromise(innerArgv) && !yargs.getInternalMethods().hasParseCallback()) {
|
||
innerArgv.catch((error) => {
|
||
try {
|
||
yargs.getInternalMethods().getUsageInstance().fail(null, error);
|
||
} catch (_err) {
|
||
}
|
||
});
|
||
}
|
||
}
|
||
if (!isDefaultCommand) {
|
||
currentContext.commands.pop();
|
||
currentContext.fullCommands.pop();
|
||
}
|
||
return innerArgv;
|
||
}
|
||
populatePositionals(commandHandler, argv, context, yargs) {
|
||
argv._ = argv._.slice(context.commands.length);
|
||
const demanded = commandHandler.demanded.slice(0);
|
||
const optional = commandHandler.optional.slice(0);
|
||
const positionalMap = {};
|
||
this.validation.positionalCount(demanded.length, argv._.length);
|
||
while (demanded.length) {
|
||
const demand = demanded.shift();
|
||
this.populatePositional(demand, argv, positionalMap);
|
||
}
|
||
while (optional.length) {
|
||
const maybe = optional.shift();
|
||
this.populatePositional(maybe, argv, positionalMap);
|
||
}
|
||
argv._ = context.commands.concat(argv._.map((a) => "" + a));
|
||
this.postProcessPositionals(argv, positionalMap, this.cmdToParseOptions(commandHandler.original), yargs);
|
||
return positionalMap;
|
||
}
|
||
populatePositional(positional, argv, positionalMap) {
|
||
const cmd = positional.cmd[0];
|
||
if (positional.variadic) {
|
||
positionalMap[cmd] = argv._.splice(0).map(String);
|
||
} else {
|
||
if (argv._.length)
|
||
positionalMap[cmd] = [String(argv._.shift())];
|
||
}
|
||
}
|
||
cmdToParseOptions(cmdString) {
|
||
const parseOptions = {
|
||
array: [],
|
||
default: {},
|
||
alias: {},
|
||
demand: {}
|
||
};
|
||
const parsed = parseCommand(cmdString);
|
||
parsed.demanded.forEach((d) => {
|
||
const [cmd, ...aliases] = d.cmd;
|
||
if (d.variadic) {
|
||
parseOptions.array.push(cmd);
|
||
parseOptions.default[cmd] = [];
|
||
}
|
||
parseOptions.alias[cmd] = aliases;
|
||
parseOptions.demand[cmd] = true;
|
||
});
|
||
parsed.optional.forEach((o) => {
|
||
const [cmd, ...aliases] = o.cmd;
|
||
if (o.variadic) {
|
||
parseOptions.array.push(cmd);
|
||
parseOptions.default[cmd] = [];
|
||
}
|
||
parseOptions.alias[cmd] = aliases;
|
||
});
|
||
return parseOptions;
|
||
}
|
||
postProcessPositionals(argv, positionalMap, parseOptions, yargs) {
|
||
const options = Object.assign({}, yargs.getOptions());
|
||
options.default = Object.assign(parseOptions.default, options.default);
|
||
for (const key of Object.keys(parseOptions.alias)) {
|
||
options.alias[key] = (options.alias[key] || []).concat(parseOptions.alias[key]);
|
||
}
|
||
options.array = options.array.concat(parseOptions.array);
|
||
options.config = {};
|
||
const unparsed = [];
|
||
Object.keys(positionalMap).forEach((key) => {
|
||
positionalMap[key].map((value) => {
|
||
if (options.configuration["unknown-options-as-args"])
|
||
options.key[key] = true;
|
||
unparsed.push(`--${key}`);
|
||
unparsed.push(value);
|
||
});
|
||
});
|
||
if (!unparsed.length)
|
||
return;
|
||
const config = Object.assign({}, options.configuration, {
|
||
"populate--": false
|
||
});
|
||
const parsed = this.shim.Parser.detailed(unparsed, Object.assign({}, options, {
|
||
configuration: config
|
||
}));
|
||
if (parsed.error) {
|
||
yargs.getInternalMethods().getUsageInstance().fail(parsed.error.message, parsed.error);
|
||
} else {
|
||
const positionalKeys = Object.keys(positionalMap);
|
||
Object.keys(positionalMap).forEach((key) => {
|
||
positionalKeys.push(...parsed.aliases[key]);
|
||
});
|
||
const defaults = yargs.getOptions().default;
|
||
Object.keys(parsed.argv).forEach((key) => {
|
||
if (positionalKeys.includes(key)) {
|
||
if (!positionalMap[key])
|
||
positionalMap[key] = parsed.argv[key];
|
||
if (!Object.prototype.hasOwnProperty.call(defaults, key) && Object.prototype.hasOwnProperty.call(argv, key) && Object.prototype.hasOwnProperty.call(parsed.argv, key) && (Array.isArray(argv[key]) || Array.isArray(parsed.argv[key]))) {
|
||
argv[key] = [].concat(argv[key], parsed.argv[key]);
|
||
} else {
|
||
argv[key] = parsed.argv[key];
|
||
}
|
||
}
|
||
});
|
||
}
|
||
}
|
||
runDefaultBuilderOn(yargs) {
|
||
if (!this.defaultCommand)
|
||
return;
|
||
if (this.shouldUpdateUsage(yargs)) {
|
||
const commandString = DEFAULT_MARKER.test(this.defaultCommand.original) ? this.defaultCommand.original : this.defaultCommand.original.replace(/^[^[\]<>]*/, "$0 ");
|
||
yargs.getInternalMethods().getUsageInstance().usage(commandString, this.defaultCommand.description);
|
||
}
|
||
const builder = this.defaultCommand.builder;
|
||
if (isCommandBuilderCallback(builder)) {
|
||
return builder(yargs, true);
|
||
} else if (!isCommandBuilderDefinition(builder)) {
|
||
Object.keys(builder).forEach((key) => {
|
||
yargs.option(key, builder[key]);
|
||
});
|
||
}
|
||
return void 0;
|
||
}
|
||
moduleName(obj) {
|
||
const mod = whichModule(obj);
|
||
if (!mod)
|
||
throw new Error(`No command name given for module: ${this.shim.inspect(obj)}`);
|
||
return this.commandFromFilename(mod.filename);
|
||
}
|
||
commandFromFilename(filename) {
|
||
return this.shim.path.basename(filename, this.shim.path.extname(filename));
|
||
}
|
||
extractDesc({ describe, description, desc }) {
|
||
for (const test of [describe, description, desc]) {
|
||
if (typeof test === "string" || test === false)
|
||
return test;
|
||
assertNotStrictEqual(test, true, this.shim);
|
||
}
|
||
return false;
|
||
}
|
||
freeze() {
|
||
this.frozens.push({
|
||
handlers: this.handlers,
|
||
aliasMap: this.aliasMap,
|
||
defaultCommand: this.defaultCommand
|
||
});
|
||
}
|
||
unfreeze() {
|
||
const frozen = this.frozens.pop();
|
||
assertNotStrictEqual(frozen, void 0, this.shim);
|
||
({
|
||
handlers: this.handlers,
|
||
aliasMap: this.aliasMap,
|
||
defaultCommand: this.defaultCommand
|
||
} = frozen);
|
||
}
|
||
reset() {
|
||
this.handlers = {};
|
||
this.aliasMap = {};
|
||
this.defaultCommand = void 0;
|
||
this.requireCache = /* @__PURE__ */ new Set();
|
||
return this;
|
||
}
|
||
};
|
||
function command(usage2, validation2, globalMiddleware, shim3) {
|
||
return new CommandInstance(usage2, validation2, globalMiddleware, shim3);
|
||
}
|
||
function isCommandBuilderDefinition(builder) {
|
||
return typeof builder === "object" && !!builder.builder && typeof builder.handler === "function";
|
||
}
|
||
function isCommandAndAliases(cmd) {
|
||
return cmd.every((c) => typeof c === "string");
|
||
}
|
||
function isCommandBuilderCallback(builder) {
|
||
return typeof builder === "function";
|
||
}
|
||
function isCommandBuilderOptionDefinitions(builder) {
|
||
return typeof builder === "object";
|
||
}
|
||
function isCommandHandlerDefinition(cmd) {
|
||
return typeof cmd === "object" && !Array.isArray(cmd);
|
||
}
|
||
|
||
// node_modules/yargs/build/lib/utils/obj-filter.js
|
||
function objFilter(original = {}, filter = () => true) {
|
||
const obj = {};
|
||
objectKeys(original).forEach((key) => {
|
||
if (filter(key, original[key])) {
|
||
obj[key] = original[key];
|
||
}
|
||
});
|
||
return obj;
|
||
}
|
||
|
||
// node_modules/yargs/build/lib/utils/set-blocking.js
|
||
function setBlocking(blocking) {
|
||
if (typeof process === "undefined")
|
||
return;
|
||
[process.stdout, process.stderr].forEach((_stream) => {
|
||
const stream = _stream;
|
||
if (stream._handle && stream.isTTY && typeof stream._handle.setBlocking === "function") {
|
||
stream._handle.setBlocking(blocking);
|
||
}
|
||
});
|
||
}
|
||
|
||
// node_modules/yargs/build/lib/usage.js
|
||
function isBoolean(fail) {
|
||
return typeof fail === "boolean";
|
||
}
|
||
function usage(yargs, shim3) {
|
||
const __ = shim3.y18n.__;
|
||
const self = {};
|
||
const fails = [];
|
||
self.failFn = function failFn(f) {
|
||
fails.push(f);
|
||
};
|
||
let failMessage = null;
|
||
let showHelpOnFail = true;
|
||
self.showHelpOnFail = function showHelpOnFailFn(arg1 = true, arg2) {
|
||
function parseFunctionArgs() {
|
||
return typeof arg1 === "string" ? [true, arg1] : [arg1, arg2];
|
||
}
|
||
const [enabled, message] = parseFunctionArgs();
|
||
failMessage = message;
|
||
showHelpOnFail = enabled;
|
||
return self;
|
||
};
|
||
let failureOutput = false;
|
||
self.fail = function fail(msg, err) {
|
||
const logger = yargs.getInternalMethods().getLoggerInstance();
|
||
if (fails.length) {
|
||
for (let i = fails.length - 1; i >= 0; --i) {
|
||
const fail2 = fails[i];
|
||
if (isBoolean(fail2)) {
|
||
if (err)
|
||
throw err;
|
||
else if (msg)
|
||
throw Error(msg);
|
||
} else {
|
||
fail2(msg, err, self);
|
||
}
|
||
}
|
||
} else {
|
||
if (yargs.getExitProcess())
|
||
setBlocking(true);
|
||
if (!failureOutput) {
|
||
failureOutput = true;
|
||
if (showHelpOnFail) {
|
||
yargs.showHelp("error");
|
||
logger.error();
|
||
}
|
||
if (msg || err)
|
||
logger.error(msg || err);
|
||
if (failMessage) {
|
||
if (msg || err)
|
||
logger.error("");
|
||
logger.error(failMessage);
|
||
}
|
||
}
|
||
err = err || new YError(msg);
|
||
if (yargs.getExitProcess()) {
|
||
return yargs.exit(1);
|
||
} else if (yargs.getInternalMethods().hasParseCallback()) {
|
||
return yargs.exit(1, err);
|
||
} else {
|
||
throw err;
|
||
}
|
||
}
|
||
};
|
||
let usages = [];
|
||
let usageDisabled = false;
|
||
self.usage = (msg, description) => {
|
||
if (msg === null) {
|
||
usageDisabled = true;
|
||
usages = [];
|
||
return self;
|
||
}
|
||
usageDisabled = false;
|
||
usages.push([msg, description || ""]);
|
||
return self;
|
||
};
|
||
self.getUsage = () => {
|
||
return usages;
|
||
};
|
||
self.getUsageDisabled = () => {
|
||
return usageDisabled;
|
||
};
|
||
self.getPositionalGroupName = () => {
|
||
return __("Positionals:");
|
||
};
|
||
let examples = [];
|
||
self.example = (cmd, description) => {
|
||
examples.push([cmd, description || ""]);
|
||
};
|
||
let commands = [];
|
||
self.command = function command2(cmd, description, isDefault, aliases, deprecated = false) {
|
||
if (isDefault) {
|
||
commands = commands.map((cmdArray) => {
|
||
cmdArray[2] = false;
|
||
return cmdArray;
|
||
});
|
||
}
|
||
commands.push([cmd, description || "", isDefault, aliases, deprecated]);
|
||
};
|
||
self.getCommands = () => commands;
|
||
let descriptions = {};
|
||
self.describe = function describe(keyOrKeys, desc) {
|
||
if (Array.isArray(keyOrKeys)) {
|
||
keyOrKeys.forEach((k) => {
|
||
self.describe(k, desc);
|
||
});
|
||
} else if (typeof keyOrKeys === "object") {
|
||
Object.keys(keyOrKeys).forEach((k) => {
|
||
self.describe(k, keyOrKeys[k]);
|
||
});
|
||
} else {
|
||
descriptions[keyOrKeys] = desc;
|
||
}
|
||
};
|
||
self.getDescriptions = () => descriptions;
|
||
let epilogs = [];
|
||
self.epilog = (msg) => {
|
||
epilogs.push(msg);
|
||
};
|
||
let wrapSet = false;
|
||
let wrap2;
|
||
self.wrap = (cols) => {
|
||
wrapSet = true;
|
||
wrap2 = cols;
|
||
};
|
||
function getWrap() {
|
||
if (!wrapSet) {
|
||
wrap2 = windowWidth();
|
||
wrapSet = true;
|
||
}
|
||
return wrap2;
|
||
}
|
||
const deferY18nLookupPrefix = "__yargsString__:";
|
||
self.deferY18nLookup = (str) => deferY18nLookupPrefix + str;
|
||
self.help = function help() {
|
||
if (cachedHelpMessage)
|
||
return cachedHelpMessage;
|
||
normalizeAliases();
|
||
const base$0 = yargs.customScriptName ? yargs.$0 : shim3.path.basename(yargs.$0);
|
||
const demandedOptions = yargs.getDemandedOptions();
|
||
const demandedCommands = yargs.getDemandedCommands();
|
||
const deprecatedOptions = yargs.getDeprecatedOptions();
|
||
const groups = yargs.getGroups();
|
||
const options = yargs.getOptions();
|
||
let keys = [];
|
||
keys = keys.concat(Object.keys(descriptions));
|
||
keys = keys.concat(Object.keys(demandedOptions));
|
||
keys = keys.concat(Object.keys(demandedCommands));
|
||
keys = keys.concat(Object.keys(options.default));
|
||
keys = keys.filter(filterHiddenOptions);
|
||
keys = Object.keys(keys.reduce((acc, key) => {
|
||
if (key !== "_")
|
||
acc[key] = true;
|
||
return acc;
|
||
}, {}));
|
||
const theWrap = getWrap();
|
||
const ui2 = shim3.cliui({
|
||
width: theWrap,
|
||
wrap: !!theWrap
|
||
});
|
||
if (!usageDisabled) {
|
||
if (usages.length) {
|
||
usages.forEach((usage2) => {
|
||
ui2.div({ text: `${usage2[0].replace(/\$0/g, base$0)}` });
|
||
if (usage2[1]) {
|
||
ui2.div({ text: `${usage2[1]}`, padding: [1, 0, 0, 0] });
|
||
}
|
||
});
|
||
ui2.div();
|
||
} else if (commands.length) {
|
||
let u = null;
|
||
if (demandedCommands._) {
|
||
u = `${base$0} <${__("command")}>
|
||
`;
|
||
} else {
|
||
u = `${base$0} [${__("command")}]
|
||
`;
|
||
}
|
||
ui2.div(`${u}`);
|
||
}
|
||
}
|
||
if (commands.length > 1 || commands.length === 1 && !commands[0][2]) {
|
||
ui2.div(__("Commands:"));
|
||
const context = yargs.getInternalMethods().getContext();
|
||
const parentCommands = context.commands.length ? `${context.commands.join(" ")} ` : "";
|
||
if (yargs.getInternalMethods().getParserConfiguration()["sort-commands"] === true) {
|
||
commands = commands.sort((a, b) => a[0].localeCompare(b[0]));
|
||
}
|
||
const prefix = base$0 ? `${base$0} ` : "";
|
||
commands.forEach((command2) => {
|
||
const commandString = `${prefix}${parentCommands}${command2[0].replace(/^\$0 ?/, "")}`;
|
||
ui2.span({
|
||
text: commandString,
|
||
padding: [0, 2, 0, 2],
|
||
width: maxWidth(commands, theWrap, `${base$0}${parentCommands}`) + 4
|
||
}, { text: command2[1] });
|
||
const hints = [];
|
||
if (command2[2])
|
||
hints.push(`[${__("default")}]`);
|
||
if (command2[3] && command2[3].length) {
|
||
hints.push(`[${__("aliases:")} ${command2[3].join(", ")}]`);
|
||
}
|
||
if (command2[4]) {
|
||
if (typeof command2[4] === "string") {
|
||
hints.push(`[${__("deprecated: %s", command2[4])}]`);
|
||
} else {
|
||
hints.push(`[${__("deprecated")}]`);
|
||
}
|
||
}
|
||
if (hints.length) {
|
||
ui2.div({
|
||
text: hints.join(" "),
|
||
padding: [0, 0, 0, 2],
|
||
align: "right"
|
||
});
|
||
} else {
|
||
ui2.div();
|
||
}
|
||
});
|
||
ui2.div();
|
||
}
|
||
const aliasKeys = (Object.keys(options.alias) || []).concat(Object.keys(yargs.parsed.newAliases) || []);
|
||
keys = keys.filter((key) => !yargs.parsed.newAliases[key] && aliasKeys.every((alias) => (options.alias[alias] || []).indexOf(key) === -1));
|
||
const defaultGroup = __("Options:");
|
||
if (!groups[defaultGroup])
|
||
groups[defaultGroup] = [];
|
||
addUngroupedKeys(keys, options.alias, groups, defaultGroup);
|
||
const isLongSwitch = (sw) => /^--/.test(getText(sw));
|
||
const displayedGroups = Object.keys(groups).filter((groupName) => groups[groupName].length > 0).map((groupName) => {
|
||
const normalizedKeys = groups[groupName].filter(filterHiddenOptions).map((key) => {
|
||
if (aliasKeys.includes(key))
|
||
return key;
|
||
for (let i = 0, aliasKey; (aliasKey = aliasKeys[i]) !== void 0; i++) {
|
||
if ((options.alias[aliasKey] || []).includes(key))
|
||
return aliasKey;
|
||
}
|
||
return key;
|
||
});
|
||
return { groupName, normalizedKeys };
|
||
}).filter(({ normalizedKeys }) => normalizedKeys.length > 0).map(({ groupName, normalizedKeys }) => {
|
||
const switches = normalizedKeys.reduce((acc, key) => {
|
||
acc[key] = [key].concat(options.alias[key] || []).map((sw) => {
|
||
if (groupName === self.getPositionalGroupName())
|
||
return sw;
|
||
else {
|
||
return (/^[0-9]$/.test(sw) ? options.boolean.includes(key) ? "-" : "--" : sw.length > 1 ? "--" : "-") + sw;
|
||
}
|
||
}).sort((sw1, sw2) => isLongSwitch(sw1) === isLongSwitch(sw2) ? 0 : isLongSwitch(sw1) ? 1 : -1).join(", ");
|
||
return acc;
|
||
}, {});
|
||
return { groupName, normalizedKeys, switches };
|
||
});
|
||
const shortSwitchesUsed = displayedGroups.filter(({ groupName }) => groupName !== self.getPositionalGroupName()).some(({ normalizedKeys, switches }) => !normalizedKeys.every((key) => isLongSwitch(switches[key])));
|
||
if (shortSwitchesUsed) {
|
||
displayedGroups.filter(({ groupName }) => groupName !== self.getPositionalGroupName()).forEach(({ normalizedKeys, switches }) => {
|
||
normalizedKeys.forEach((key) => {
|
||
if (isLongSwitch(switches[key])) {
|
||
switches[key] = addIndentation(switches[key], "-x, ".length);
|
||
}
|
||
});
|
||
});
|
||
}
|
||
displayedGroups.forEach(({ groupName, normalizedKeys, switches }) => {
|
||
ui2.div(groupName);
|
||
normalizedKeys.forEach((key) => {
|
||
const kswitch = switches[key];
|
||
let desc = descriptions[key] || "";
|
||
let type = null;
|
||
if (desc.includes(deferY18nLookupPrefix))
|
||
desc = __(desc.substring(deferY18nLookupPrefix.length));
|
||
if (options.boolean.includes(key))
|
||
type = `[${__("boolean")}]`;
|
||
if (options.count.includes(key))
|
||
type = `[${__("count")}]`;
|
||
if (options.string.includes(key))
|
||
type = `[${__("string")}]`;
|
||
if (options.normalize.includes(key))
|
||
type = `[${__("string")}]`;
|
||
if (options.array.includes(key))
|
||
type = `[${__("array")}]`;
|
||
if (options.number.includes(key))
|
||
type = `[${__("number")}]`;
|
||
const deprecatedExtra = (deprecated) => typeof deprecated === "string" ? `[${__("deprecated: %s", deprecated)}]` : `[${__("deprecated")}]`;
|
||
const extra = [
|
||
key in deprecatedOptions ? deprecatedExtra(deprecatedOptions[key]) : null,
|
||
type,
|
||
key in demandedOptions ? `[${__("required")}]` : null,
|
||
options.choices && options.choices[key] ? `[${__("choices:")} ${self.stringifiedValues(options.choices[key])}]` : null,
|
||
defaultString(options.default[key], options.defaultDescription[key])
|
||
].filter(Boolean).join(" ");
|
||
ui2.span({
|
||
text: getText(kswitch),
|
||
padding: [0, 2, 0, 2 + getIndentation(kswitch)],
|
||
width: maxWidth(switches, theWrap) + 4
|
||
}, desc);
|
||
if (extra)
|
||
ui2.div({ text: extra, padding: [0, 0, 0, 2], align: "right" });
|
||
else
|
||
ui2.div();
|
||
});
|
||
ui2.div();
|
||
});
|
||
if (examples.length) {
|
||
ui2.div(__("Examples:"));
|
||
examples.forEach((example) => {
|
||
example[0] = example[0].replace(/\$0/g, base$0);
|
||
});
|
||
examples.forEach((example) => {
|
||
if (example[1] === "") {
|
||
ui2.div({
|
||
text: example[0],
|
||
padding: [0, 2, 0, 2]
|
||
});
|
||
} else {
|
||
ui2.div({
|
||
text: example[0],
|
||
padding: [0, 2, 0, 2],
|
||
width: maxWidth(examples, theWrap) + 4
|
||
}, {
|
||
text: example[1]
|
||
});
|
||
}
|
||
});
|
||
ui2.div();
|
||
}
|
||
if (epilogs.length > 0) {
|
||
const e = epilogs.map((epilog) => epilog.replace(/\$0/g, base$0)).join("\n");
|
||
ui2.div(`${e}
|
||
`);
|
||
}
|
||
return ui2.toString().replace(/\s*$/, "");
|
||
};
|
||
function maxWidth(table, theWrap, modifier) {
|
||
let width = 0;
|
||
if (!Array.isArray(table)) {
|
||
table = Object.values(table).map((v) => [v]);
|
||
}
|
||
table.forEach((v) => {
|
||
width = Math.max(shim3.stringWidth(modifier ? `${modifier} ${getText(v[0])}` : getText(v[0])) + getIndentation(v[0]), width);
|
||
});
|
||
if (theWrap)
|
||
width = Math.min(width, parseInt((theWrap * 0.5).toString(), 10));
|
||
return width;
|
||
}
|
||
function normalizeAliases() {
|
||
const demandedOptions = yargs.getDemandedOptions();
|
||
const options = yargs.getOptions();
|
||
(Object.keys(options.alias) || []).forEach((key) => {
|
||
options.alias[key].forEach((alias) => {
|
||
if (descriptions[alias])
|
||
self.describe(key, descriptions[alias]);
|
||
if (alias in demandedOptions)
|
||
yargs.demandOption(key, demandedOptions[alias]);
|
||
if (options.boolean.includes(alias))
|
||
yargs.boolean(key);
|
||
if (options.count.includes(alias))
|
||
yargs.count(key);
|
||
if (options.string.includes(alias))
|
||
yargs.string(key);
|
||
if (options.normalize.includes(alias))
|
||
yargs.normalize(key);
|
||
if (options.array.includes(alias))
|
||
yargs.array(key);
|
||
if (options.number.includes(alias))
|
||
yargs.number(key);
|
||
});
|
||
});
|
||
}
|
||
let cachedHelpMessage;
|
||
self.cacheHelpMessage = function() {
|
||
cachedHelpMessage = this.help();
|
||
};
|
||
self.clearCachedHelpMessage = function() {
|
||
cachedHelpMessage = void 0;
|
||
};
|
||
self.hasCachedHelpMessage = function() {
|
||
return !!cachedHelpMessage;
|
||
};
|
||
function addUngroupedKeys(keys, aliases, groups, defaultGroup) {
|
||
let groupedKeys = [];
|
||
let toCheck = null;
|
||
Object.keys(groups).forEach((group) => {
|
||
groupedKeys = groupedKeys.concat(groups[group]);
|
||
});
|
||
keys.forEach((key) => {
|
||
toCheck = [key].concat(aliases[key]);
|
||
if (!toCheck.some((k) => groupedKeys.indexOf(k) !== -1)) {
|
||
groups[defaultGroup].push(key);
|
||
}
|
||
});
|
||
return groupedKeys;
|
||
}
|
||
function filterHiddenOptions(key) {
|
||
return yargs.getOptions().hiddenOptions.indexOf(key) < 0 || yargs.parsed.argv[yargs.getOptions().showHiddenOpt];
|
||
}
|
||
self.showHelp = (level) => {
|
||
const logger = yargs.getInternalMethods().getLoggerInstance();
|
||
if (!level)
|
||
level = "error";
|
||
const emit = typeof level === "function" ? level : logger[level];
|
||
emit(self.help());
|
||
};
|
||
self.functionDescription = (fn) => {
|
||
const description = fn.name ? shim3.Parser.decamelize(fn.name, "-") : __("generated-value");
|
||
return ["(", description, ")"].join("");
|
||
};
|
||
self.stringifiedValues = function stringifiedValues(values, separator) {
|
||
let string = "";
|
||
const sep = separator || ", ";
|
||
const array = [].concat(values);
|
||
if (!values || !array.length)
|
||
return string;
|
||
array.forEach((value) => {
|
||
if (string.length)
|
||
string += sep;
|
||
string += JSON.stringify(value);
|
||
});
|
||
return string;
|
||
};
|
||
function defaultString(value, defaultDescription) {
|
||
let string = `[${__("default:")} `;
|
||
if (value === void 0 && !defaultDescription)
|
||
return null;
|
||
if (defaultDescription) {
|
||
string += defaultDescription;
|
||
} else {
|
||
switch (typeof value) {
|
||
case "string":
|
||
string += `"${value}"`;
|
||
break;
|
||
case "object":
|
||
string += JSON.stringify(value);
|
||
break;
|
||
default:
|
||
string += value;
|
||
}
|
||
}
|
||
return `${string}]`;
|
||
}
|
||
function windowWidth() {
|
||
const maxWidth2 = 80;
|
||
if (shim3.process.stdColumns) {
|
||
return Math.min(maxWidth2, shim3.process.stdColumns);
|
||
} else {
|
||
return maxWidth2;
|
||
}
|
||
}
|
||
let version = null;
|
||
self.version = (ver) => {
|
||
version = ver;
|
||
};
|
||
self.showVersion = (level) => {
|
||
const logger = yargs.getInternalMethods().getLoggerInstance();
|
||
if (!level)
|
||
level = "error";
|
||
const emit = typeof level === "function" ? level : logger[level];
|
||
emit(version);
|
||
};
|
||
self.reset = function reset(localLookup) {
|
||
failMessage = null;
|
||
failureOutput = false;
|
||
usages = [];
|
||
usageDisabled = false;
|
||
epilogs = [];
|
||
examples = [];
|
||
commands = [];
|
||
descriptions = objFilter(descriptions, (k) => !localLookup[k]);
|
||
return self;
|
||
};
|
||
const frozens = [];
|
||
self.freeze = function freeze() {
|
||
frozens.push({
|
||
failMessage,
|
||
failureOutput,
|
||
usages,
|
||
usageDisabled,
|
||
epilogs,
|
||
examples,
|
||
commands,
|
||
descriptions
|
||
});
|
||
};
|
||
self.unfreeze = function unfreeze() {
|
||
const frozen = frozens.pop();
|
||
if (!frozen)
|
||
return;
|
||
({
|
||
failMessage,
|
||
failureOutput,
|
||
usages,
|
||
usageDisabled,
|
||
epilogs,
|
||
examples,
|
||
commands,
|
||
descriptions
|
||
} = frozen);
|
||
};
|
||
return self;
|
||
}
|
||
function isIndentedText(text) {
|
||
return typeof text === "object";
|
||
}
|
||
function addIndentation(text, indent) {
|
||
return isIndentedText(text) ? { text: text.text, indentation: text.indentation + indent } : { text, indentation: indent };
|
||
}
|
||
function getIndentation(text) {
|
||
return isIndentedText(text) ? text.indentation : 0;
|
||
}
|
||
function getText(text) {
|
||
return isIndentedText(text) ? text.text : text;
|
||
}
|
||
|
||
// node_modules/yargs/build/lib/completion-templates.js
|
||
var completionShTemplate = `###-begin-{{app_name}}-completions-###
|
||
#
|
||
# yargs command completion script
|
||
#
|
||
# Installation: {{app_path}} {{completion_command}} >> ~/.bashrc
|
||
# or {{app_path}} {{completion_command}} >> ~/.bash_profile on OSX.
|
||
#
|
||
_{{app_name}}_yargs_completions()
|
||
{
|
||
local cur_word args type_list
|
||
|
||
cur_word="\${COMP_WORDS[COMP_CWORD]}"
|
||
args=("\${COMP_WORDS[@]}")
|
||
|
||
# ask yargs to generate completions.
|
||
type_list=$({{app_path}} --get-yargs-completions "\${args[@]}")
|
||
|
||
COMPREPLY=( $(compgen -W "\${type_list}" -- \${cur_word}) )
|
||
|
||
# if no match was found, fall back to filename completion
|
||
if [ \${#COMPREPLY[@]} -eq 0 ]; then
|
||
COMPREPLY=()
|
||
fi
|
||
|
||
return 0
|
||
}
|
||
complete -o bashdefault -o default -F _{{app_name}}_yargs_completions {{app_name}}
|
||
###-end-{{app_name}}-completions-###
|
||
`;
|
||
var completionZshTemplate = `#compdef {{app_name}}
|
||
###-begin-{{app_name}}-completions-###
|
||
#
|
||
# yargs command completion script
|
||
#
|
||
# Installation: {{app_path}} {{completion_command}} >> ~/.zshrc
|
||
# or {{app_path}} {{completion_command}} >> ~/.zsh_profile on OSX.
|
||
#
|
||
_{{app_name}}_yargs_completions()
|
||
{
|
||
local reply
|
||
local si=$IFS
|
||
IFS=$'
|
||
' reply=($(COMP_CWORD="$((CURRENT-1))" COMP_LINE="$BUFFER" COMP_POINT="$CURSOR" {{app_path}} --get-yargs-completions "\${words[@]}"))
|
||
IFS=$si
|
||
_describe 'values' reply
|
||
}
|
||
compdef _{{app_name}}_yargs_completions {{app_name}}
|
||
###-end-{{app_name}}-completions-###
|
||
`;
|
||
|
||
// node_modules/yargs/build/lib/completion.js
|
||
var Completion = class {
|
||
constructor(yargs, usage2, command2, shim3) {
|
||
var _a, _b, _c;
|
||
this.yargs = yargs;
|
||
this.usage = usage2;
|
||
this.command = command2;
|
||
this.shim = shim3;
|
||
this.completionKey = "get-yargs-completions";
|
||
this.aliases = null;
|
||
this.customCompletionFunction = null;
|
||
this.zshShell = (_c = ((_a = this.shim.getEnv("SHELL")) === null || _a === void 0 ? void 0 : _a.includes("zsh")) || ((_b = this.shim.getEnv("ZSH_NAME")) === null || _b === void 0 ? void 0 : _b.includes("zsh"))) !== null && _c !== void 0 ? _c : false;
|
||
}
|
||
defaultCompletion(args, argv, current, done) {
|
||
const handlers = this.command.getCommandHandlers();
|
||
for (let i = 0, ii = args.length; i < ii; ++i) {
|
||
if (handlers[args[i]] && handlers[args[i]].builder) {
|
||
const builder = handlers[args[i]].builder;
|
||
if (isCommandBuilderCallback(builder)) {
|
||
const y = this.yargs.getInternalMethods().reset();
|
||
builder(y, true);
|
||
return y.argv;
|
||
}
|
||
}
|
||
}
|
||
const completions = [];
|
||
this.commandCompletions(completions, args, current);
|
||
this.optionCompletions(completions, args, argv, current);
|
||
this.choicesCompletions(completions, args, argv, current);
|
||
done(null, completions);
|
||
}
|
||
commandCompletions(completions, args, current) {
|
||
const parentCommands = this.yargs.getInternalMethods().getContext().commands;
|
||
if (!current.match(/^-/) && parentCommands[parentCommands.length - 1] !== current && !this.previousArgHasChoices(args)) {
|
||
this.usage.getCommands().forEach((usageCommand) => {
|
||
const commandName = parseCommand(usageCommand[0]).cmd;
|
||
if (args.indexOf(commandName) === -1) {
|
||
if (!this.zshShell) {
|
||
completions.push(commandName);
|
||
} else {
|
||
const desc = usageCommand[1] || "";
|
||
completions.push(commandName.replace(/:/g, "\\:") + ":" + desc);
|
||
}
|
||
}
|
||
});
|
||
}
|
||
}
|
||
optionCompletions(completions, args, argv, current) {
|
||
if ((current.match(/^-/) || current === "" && completions.length === 0) && !this.previousArgHasChoices(args)) {
|
||
const options = this.yargs.getOptions();
|
||
const positionalKeys = this.yargs.getGroups()[this.usage.getPositionalGroupName()] || [];
|
||
Object.keys(options.key).forEach((key) => {
|
||
const negable = !!options.configuration["boolean-negation"] && options.boolean.includes(key);
|
||
const isPositionalKey = positionalKeys.includes(key);
|
||
if (!isPositionalKey && !this.argsContainKey(args, argv, key, negable)) {
|
||
this.completeOptionKey(key, completions, current);
|
||
if (negable && !!options.default[key])
|
||
this.completeOptionKey(`no-${key}`, completions, current);
|
||
}
|
||
});
|
||
}
|
||
}
|
||
choicesCompletions(completions, args, argv, current) {
|
||
if (this.previousArgHasChoices(args)) {
|
||
const choices = this.getPreviousArgChoices(args);
|
||
if (choices && choices.length > 0) {
|
||
completions.push(...choices);
|
||
}
|
||
}
|
||
}
|
||
getPreviousArgChoices(args) {
|
||
if (args.length < 1)
|
||
return;
|
||
let previousArg = args[args.length - 1];
|
||
let filter = "";
|
||
if (!previousArg.startsWith("--") && args.length > 1) {
|
||
filter = previousArg;
|
||
previousArg = args[args.length - 2];
|
||
}
|
||
if (!previousArg.startsWith("--"))
|
||
return;
|
||
const previousArgKey = previousArg.replace(/-/g, "");
|
||
const options = this.yargs.getOptions();
|
||
if (Object.keys(options.key).some((key) => key === previousArgKey) && Array.isArray(options.choices[previousArgKey])) {
|
||
return options.choices[previousArgKey].filter((choice) => !filter || choice.startsWith(filter));
|
||
}
|
||
}
|
||
previousArgHasChoices(args) {
|
||
const choices = this.getPreviousArgChoices(args);
|
||
return choices !== void 0 && choices.length > 0;
|
||
}
|
||
argsContainKey(args, argv, key, negable) {
|
||
if (args.indexOf(`--${key}`) !== -1)
|
||
return true;
|
||
if (negable && args.indexOf(`--no-${key}`) !== -1)
|
||
return true;
|
||
if (this.aliases) {
|
||
for (const alias of this.aliases[key]) {
|
||
if (argv[alias] !== void 0)
|
||
return true;
|
||
}
|
||
}
|
||
return false;
|
||
}
|
||
completeOptionKey(key, completions, current) {
|
||
const descs = this.usage.getDescriptions();
|
||
const startsByTwoDashes = (s) => /^--/.test(s);
|
||
const isShortOption = (s) => /^[^0-9]$/.test(s);
|
||
const dashes = !startsByTwoDashes(current) && isShortOption(key) ? "-" : "--";
|
||
if (!this.zshShell) {
|
||
completions.push(dashes + key);
|
||
} else {
|
||
const desc = descs[key] || "";
|
||
completions.push(dashes + `${key.replace(/:/g, "\\:")}:${desc.replace("__yargsString__:", "")}`);
|
||
}
|
||
}
|
||
customCompletion(args, argv, current, done) {
|
||
assertNotStrictEqual(this.customCompletionFunction, null, this.shim);
|
||
if (isSyncCompletionFunction(this.customCompletionFunction)) {
|
||
const result = this.customCompletionFunction(current, argv);
|
||
if (isPromise(result)) {
|
||
return result.then((list) => {
|
||
this.shim.process.nextTick(() => {
|
||
done(null, list);
|
||
});
|
||
}).catch((err) => {
|
||
this.shim.process.nextTick(() => {
|
||
done(err, void 0);
|
||
});
|
||
});
|
||
}
|
||
return done(null, result);
|
||
} else if (isFallbackCompletionFunction(this.customCompletionFunction)) {
|
||
return this.customCompletionFunction(current, argv, (onCompleted = done) => this.defaultCompletion(args, argv, current, onCompleted), (completions) => {
|
||
done(null, completions);
|
||
});
|
||
} else {
|
||
return this.customCompletionFunction(current, argv, (completions) => {
|
||
done(null, completions);
|
||
});
|
||
}
|
||
}
|
||
getCompletion(args, done) {
|
||
const current = args.length ? args[args.length - 1] : "";
|
||
const argv = this.yargs.parse(args, true);
|
||
const completionFunction = this.customCompletionFunction ? (argv2) => this.customCompletion(args, argv2, current, done) : (argv2) => this.defaultCompletion(args, argv2, current, done);
|
||
return isPromise(argv) ? argv.then(completionFunction) : completionFunction(argv);
|
||
}
|
||
generateCompletionScript($0, cmd) {
|
||
let script = this.zshShell ? completionZshTemplate : completionShTemplate;
|
||
const name = this.shim.path.basename($0);
|
||
if ($0.match(/\.js$/))
|
||
$0 = `./${$0}`;
|
||
script = script.replace(/{{app_name}}/g, name);
|
||
script = script.replace(/{{completion_command}}/g, cmd);
|
||
return script.replace(/{{app_path}}/g, $0);
|
||
}
|
||
registerFunction(fn) {
|
||
this.customCompletionFunction = fn;
|
||
}
|
||
setParsed(parsed) {
|
||
this.aliases = parsed.aliases;
|
||
}
|
||
};
|
||
function completion(yargs, usage2, command2, shim3) {
|
||
return new Completion(yargs, usage2, command2, shim3);
|
||
}
|
||
function isSyncCompletionFunction(completionFunction) {
|
||
return completionFunction.length < 3;
|
||
}
|
||
function isFallbackCompletionFunction(completionFunction) {
|
||
return completionFunction.length > 3;
|
||
}
|
||
|
||
// node_modules/yargs/build/lib/utils/levenshtein.js
|
||
function levenshtein(a, b) {
|
||
if (a.length === 0)
|
||
return b.length;
|
||
if (b.length === 0)
|
||
return a.length;
|
||
const matrix = [];
|
||
let i;
|
||
for (i = 0; i <= b.length; i++) {
|
||
matrix[i] = [i];
|
||
}
|
||
let j;
|
||
for (j = 0; j <= a.length; j++) {
|
||
matrix[0][j] = j;
|
||
}
|
||
for (i = 1; i <= b.length; i++) {
|
||
for (j = 1; j <= a.length; j++) {
|
||
if (b.charAt(i - 1) === a.charAt(j - 1)) {
|
||
matrix[i][j] = matrix[i - 1][j - 1];
|
||
} else {
|
||
if (i > 1 && j > 1 && b.charAt(i - 2) === a.charAt(j - 1) && b.charAt(i - 1) === a.charAt(j - 2)) {
|
||
matrix[i][j] = matrix[i - 2][j - 2] + 1;
|
||
} else {
|
||
matrix[i][j] = Math.min(matrix[i - 1][j - 1] + 1, Math.min(matrix[i][j - 1] + 1, matrix[i - 1][j] + 1));
|
||
}
|
||
}
|
||
}
|
||
}
|
||
return matrix[b.length][a.length];
|
||
}
|
||
|
||
// node_modules/yargs/build/lib/validation.js
|
||
var specialKeys = ["$0", "--", "_"];
|
||
function validation(yargs, usage2, shim3) {
|
||
const __ = shim3.y18n.__;
|
||
const __n = shim3.y18n.__n;
|
||
const self = {};
|
||
self.nonOptionCount = function nonOptionCount(argv) {
|
||
const demandedCommands = yargs.getDemandedCommands();
|
||
const positionalCount = argv._.length + (argv["--"] ? argv["--"].length : 0);
|
||
const _s = positionalCount - yargs.getInternalMethods().getContext().commands.length;
|
||
if (demandedCommands._ && (_s < demandedCommands._.min || _s > demandedCommands._.max)) {
|
||
if (_s < demandedCommands._.min) {
|
||
if (demandedCommands._.minMsg !== void 0) {
|
||
usage2.fail(demandedCommands._.minMsg ? demandedCommands._.minMsg.replace(/\$0/g, _s.toString()).replace(/\$1/, demandedCommands._.min.toString()) : null);
|
||
} else {
|
||
usage2.fail(__n("Not enough non-option arguments: got %s, need at least %s", "Not enough non-option arguments: got %s, need at least %s", _s, _s.toString(), demandedCommands._.min.toString()));
|
||
}
|
||
} else if (_s > demandedCommands._.max) {
|
||
if (demandedCommands._.maxMsg !== void 0) {
|
||
usage2.fail(demandedCommands._.maxMsg ? demandedCommands._.maxMsg.replace(/\$0/g, _s.toString()).replace(/\$1/, demandedCommands._.max.toString()) : null);
|
||
} else {
|
||
usage2.fail(__n("Too many non-option arguments: got %s, maximum of %s", "Too many non-option arguments: got %s, maximum of %s", _s, _s.toString(), demandedCommands._.max.toString()));
|
||
}
|
||
}
|
||
}
|
||
};
|
||
self.positionalCount = function positionalCount(required, observed) {
|
||
if (observed < required) {
|
||
usage2.fail(__n("Not enough non-option arguments: got %s, need at least %s", "Not enough non-option arguments: got %s, need at least %s", observed, observed + "", required + ""));
|
||
}
|
||
};
|
||
self.requiredArguments = function requiredArguments(argv, demandedOptions) {
|
||
let missing = null;
|
||
for (const key of Object.keys(demandedOptions)) {
|
||
if (!Object.prototype.hasOwnProperty.call(argv, key) || typeof argv[key] === "undefined") {
|
||
missing = missing || {};
|
||
missing[key] = demandedOptions[key];
|
||
}
|
||
}
|
||
if (missing) {
|
||
const customMsgs = [];
|
||
for (const key of Object.keys(missing)) {
|
||
const msg = missing[key];
|
||
if (msg && customMsgs.indexOf(msg) < 0) {
|
||
customMsgs.push(msg);
|
||
}
|
||
}
|
||
const customMsg = customMsgs.length ? `
|
||
${customMsgs.join("\n")}` : "";
|
||
usage2.fail(__n("Missing required argument: %s", "Missing required arguments: %s", Object.keys(missing).length, Object.keys(missing).join(", ") + customMsg));
|
||
}
|
||
};
|
||
self.unknownArguments = function unknownArguments(argv, aliases, positionalMap, isDefaultCommand, checkPositionals = true) {
|
||
var _a;
|
||
const commandKeys = yargs.getInternalMethods().getCommandInstance().getCommands();
|
||
const unknown = [];
|
||
const currentContext = yargs.getInternalMethods().getContext();
|
||
Object.keys(argv).forEach((key) => {
|
||
if (!specialKeys.includes(key) && !Object.prototype.hasOwnProperty.call(positionalMap, key) && !Object.prototype.hasOwnProperty.call(yargs.getInternalMethods().getParseContext(), key) && !self.isValidAndSomeAliasIsNotNew(key, aliases)) {
|
||
unknown.push(key);
|
||
}
|
||
});
|
||
if (checkPositionals && (currentContext.commands.length > 0 || commandKeys.length > 0 || isDefaultCommand)) {
|
||
argv._.slice(currentContext.commands.length).forEach((key) => {
|
||
if (!commandKeys.includes("" + key)) {
|
||
unknown.push("" + key);
|
||
}
|
||
});
|
||
}
|
||
if (checkPositionals) {
|
||
const demandedCommands = yargs.getDemandedCommands();
|
||
const maxNonOptDemanded = ((_a = demandedCommands._) === null || _a === void 0 ? void 0 : _a.max) || 0;
|
||
const expected = currentContext.commands.length + maxNonOptDemanded;
|
||
if (expected < argv._.length) {
|
||
argv._.slice(expected).forEach((key) => {
|
||
key = String(key);
|
||
if (!currentContext.commands.includes(key) && !unknown.includes(key)) {
|
||
unknown.push(key);
|
||
}
|
||
});
|
||
}
|
||
}
|
||
if (unknown.length) {
|
||
usage2.fail(__n("Unknown argument: %s", "Unknown arguments: %s", unknown.length, unknown.join(", ")));
|
||
}
|
||
};
|
||
self.unknownCommands = function unknownCommands(argv) {
|
||
const commandKeys = yargs.getInternalMethods().getCommandInstance().getCommands();
|
||
const unknown = [];
|
||
const currentContext = yargs.getInternalMethods().getContext();
|
||
if (currentContext.commands.length > 0 || commandKeys.length > 0) {
|
||
argv._.slice(currentContext.commands.length).forEach((key) => {
|
||
if (!commandKeys.includes("" + key)) {
|
||
unknown.push("" + key);
|
||
}
|
||
});
|
||
}
|
||
if (unknown.length > 0) {
|
||
usage2.fail(__n("Unknown command: %s", "Unknown commands: %s", unknown.length, unknown.join(", ")));
|
||
return true;
|
||
} else {
|
||
return false;
|
||
}
|
||
};
|
||
self.isValidAndSomeAliasIsNotNew = function isValidAndSomeAliasIsNotNew(key, aliases) {
|
||
if (!Object.prototype.hasOwnProperty.call(aliases, key)) {
|
||
return false;
|
||
}
|
||
const newAliases = yargs.parsed.newAliases;
|
||
return [key, ...aliases[key]].some((a) => !Object.prototype.hasOwnProperty.call(newAliases, a) || !newAliases[key]);
|
||
};
|
||
self.limitedChoices = function limitedChoices(argv) {
|
||
const options = yargs.getOptions();
|
||
const invalid = {};
|
||
if (!Object.keys(options.choices).length)
|
||
return;
|
||
Object.keys(argv).forEach((key) => {
|
||
if (specialKeys.indexOf(key) === -1 && Object.prototype.hasOwnProperty.call(options.choices, key)) {
|
||
[].concat(argv[key]).forEach((value) => {
|
||
if (options.choices[key].indexOf(value) === -1 && value !== void 0) {
|
||
invalid[key] = (invalid[key] || []).concat(value);
|
||
}
|
||
});
|
||
}
|
||
});
|
||
const invalidKeys = Object.keys(invalid);
|
||
if (!invalidKeys.length)
|
||
return;
|
||
let msg = __("Invalid values:");
|
||
invalidKeys.forEach((key) => {
|
||
msg += `
|
||
${__("Argument: %s, Given: %s, Choices: %s", key, usage2.stringifiedValues(invalid[key]), usage2.stringifiedValues(options.choices[key]))}`;
|
||
});
|
||
usage2.fail(msg);
|
||
};
|
||
let implied = {};
|
||
self.implies = function implies(key, value) {
|
||
argsert("<string|object> [array|number|string]", [key, value], arguments.length);
|
||
if (typeof key === "object") {
|
||
Object.keys(key).forEach((k) => {
|
||
self.implies(k, key[k]);
|
||
});
|
||
} else {
|
||
yargs.global(key);
|
||
if (!implied[key]) {
|
||
implied[key] = [];
|
||
}
|
||
if (Array.isArray(value)) {
|
||
value.forEach((i) => self.implies(key, i));
|
||
} else {
|
||
assertNotStrictEqual(value, void 0, shim3);
|
||
implied[key].push(value);
|
||
}
|
||
}
|
||
};
|
||
self.getImplied = function getImplied() {
|
||
return implied;
|
||
};
|
||
function keyExists(argv, val) {
|
||
const num = Number(val);
|
||
val = isNaN(num) ? val : num;
|
||
if (typeof val === "number") {
|
||
val = argv._.length >= val;
|
||
} else if (val.match(/^--no-.+/)) {
|
||
val = val.match(/^--no-(.+)/)[1];
|
||
val = !Object.prototype.hasOwnProperty.call(argv, val);
|
||
} else {
|
||
val = Object.prototype.hasOwnProperty.call(argv, val);
|
||
}
|
||
return val;
|
||
}
|
||
self.implications = function implications(argv) {
|
||
const implyFail = [];
|
||
Object.keys(implied).forEach((key) => {
|
||
const origKey = key;
|
||
(implied[key] || []).forEach((value) => {
|
||
let key2 = origKey;
|
||
const origValue = value;
|
||
key2 = keyExists(argv, key2);
|
||
value = keyExists(argv, value);
|
||
if (key2 && !value) {
|
||
implyFail.push(` ${origKey} -> ${origValue}`);
|
||
}
|
||
});
|
||
});
|
||
if (implyFail.length) {
|
||
let msg = `${__("Implications failed:")}
|
||
`;
|
||
implyFail.forEach((value) => {
|
||
msg += value;
|
||
});
|
||
usage2.fail(msg);
|
||
}
|
||
};
|
||
let conflicting = {};
|
||
self.conflicts = function conflicts(key, value) {
|
||
argsert("<string|object> [array|string]", [key, value], arguments.length);
|
||
if (typeof key === "object") {
|
||
Object.keys(key).forEach((k) => {
|
||
self.conflicts(k, key[k]);
|
||
});
|
||
} else {
|
||
yargs.global(key);
|
||
if (!conflicting[key]) {
|
||
conflicting[key] = [];
|
||
}
|
||
if (Array.isArray(value)) {
|
||
value.forEach((i) => self.conflicts(key, i));
|
||
} else {
|
||
conflicting[key].push(value);
|
||
}
|
||
}
|
||
};
|
||
self.getConflicting = () => conflicting;
|
||
self.conflicting = function conflictingFn(argv) {
|
||
Object.keys(argv).forEach((key) => {
|
||
if (conflicting[key]) {
|
||
conflicting[key].forEach((value) => {
|
||
if (value && argv[key] !== void 0 && argv[value] !== void 0) {
|
||
usage2.fail(__("Arguments %s and %s are mutually exclusive", key, value));
|
||
}
|
||
});
|
||
}
|
||
});
|
||
if (yargs.getInternalMethods().getParserConfiguration()["strip-dashed"]) {
|
||
Object.keys(conflicting).forEach((key) => {
|
||
conflicting[key].forEach((value) => {
|
||
if (value && argv[shim3.Parser.camelCase(key)] !== void 0 && argv[shim3.Parser.camelCase(value)] !== void 0) {
|
||
usage2.fail(__("Arguments %s and %s are mutually exclusive", key, value));
|
||
}
|
||
});
|
||
});
|
||
}
|
||
};
|
||
self.recommendCommands = function recommendCommands(cmd, potentialCommands) {
|
||
const threshold = 3;
|
||
potentialCommands = potentialCommands.sort((a, b) => b.length - a.length);
|
||
let recommended = null;
|
||
let bestDistance = Infinity;
|
||
for (let i = 0, candidate; (candidate = potentialCommands[i]) !== void 0; i++) {
|
||
const d = levenshtein(cmd, candidate);
|
||
if (d <= threshold && d < bestDistance) {
|
||
bestDistance = d;
|
||
recommended = candidate;
|
||
}
|
||
}
|
||
if (recommended)
|
||
usage2.fail(__("Did you mean %s?", recommended));
|
||
};
|
||
self.reset = function reset(localLookup) {
|
||
implied = objFilter(implied, (k) => !localLookup[k]);
|
||
conflicting = objFilter(conflicting, (k) => !localLookup[k]);
|
||
return self;
|
||
};
|
||
const frozens = [];
|
||
self.freeze = function freeze() {
|
||
frozens.push({
|
||
implied,
|
||
conflicting
|
||
});
|
||
};
|
||
self.unfreeze = function unfreeze() {
|
||
const frozen = frozens.pop();
|
||
assertNotStrictEqual(frozen, void 0, shim3);
|
||
({ implied, conflicting } = frozen);
|
||
};
|
||
return self;
|
||
}
|
||
|
||
// node_modules/yargs/build/lib/utils/apply-extends.js
|
||
var previouslyVisitedConfigs = [];
|
||
var shim2;
|
||
function applyExtends(config, cwd, mergeExtends, _shim) {
|
||
shim2 = _shim;
|
||
let defaultConfig = {};
|
||
if (Object.prototype.hasOwnProperty.call(config, "extends")) {
|
||
if (typeof config.extends !== "string")
|
||
return defaultConfig;
|
||
const isPath = /\.json|\..*rc$/.test(config.extends);
|
||
let pathToDefault = null;
|
||
if (!isPath) {
|
||
try {
|
||
pathToDefault = require.resolve(config.extends);
|
||
} catch (_err) {
|
||
return config;
|
||
}
|
||
} else {
|
||
pathToDefault = getPathToDefaultConfig(cwd, config.extends);
|
||
}
|
||
checkForCircularExtends(pathToDefault);
|
||
previouslyVisitedConfigs.push(pathToDefault);
|
||
defaultConfig = isPath ? JSON.parse(shim2.readFileSync(pathToDefault, "utf8")) : require(config.extends);
|
||
delete config.extends;
|
||
defaultConfig = applyExtends(defaultConfig, shim2.path.dirname(pathToDefault), mergeExtends, shim2);
|
||
}
|
||
previouslyVisitedConfigs = [];
|
||
return mergeExtends ? mergeDeep(defaultConfig, config) : Object.assign({}, defaultConfig, config);
|
||
}
|
||
function checkForCircularExtends(cfgPath) {
|
||
if (previouslyVisitedConfigs.indexOf(cfgPath) > -1) {
|
||
throw new YError(`Circular extended configurations: '${cfgPath}'.`);
|
||
}
|
||
}
|
||
function getPathToDefaultConfig(cwd, pathToExtend) {
|
||
return shim2.path.resolve(cwd, pathToExtend);
|
||
}
|
||
function mergeDeep(config1, config2) {
|
||
const target = {};
|
||
function isObject(obj) {
|
||
return obj && typeof obj === "object" && !Array.isArray(obj);
|
||
}
|
||
Object.assign(target, config1);
|
||
for (const key of Object.keys(config2)) {
|
||
if (isObject(config2[key]) && isObject(target[key])) {
|
||
target[key] = mergeDeep(config1[key], config2[key]);
|
||
} else {
|
||
target[key] = config2[key];
|
||
}
|
||
}
|
||
return target;
|
||
}
|
||
|
||
// node_modules/yargs/build/lib/yargs-factory.js
|
||
var __classPrivateFieldSet = function(receiver, state, value, kind, f) {
|
||
if (kind === "m")
|
||
throw new TypeError("Private method is not writable");
|
||
if (kind === "a" && !f)
|
||
throw new TypeError("Private accessor was defined without a setter");
|
||
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver))
|
||
throw new TypeError("Cannot write private member to an object whose class did not declare it");
|
||
return kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value), value;
|
||
};
|
||
var __classPrivateFieldGet = function(receiver, state, kind, f) {
|
||
if (kind === "a" && !f)
|
||
throw new TypeError("Private accessor was defined without a getter");
|
||
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver))
|
||
throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
||
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
||
};
|
||
var _YargsInstance_command;
|
||
var _YargsInstance_cwd;
|
||
var _YargsInstance_context;
|
||
var _YargsInstance_completion;
|
||
var _YargsInstance_completionCommand;
|
||
var _YargsInstance_defaultShowHiddenOpt;
|
||
var _YargsInstance_exitError;
|
||
var _YargsInstance_detectLocale;
|
||
var _YargsInstance_emittedWarnings;
|
||
var _YargsInstance_exitProcess;
|
||
var _YargsInstance_frozens;
|
||
var _YargsInstance_globalMiddleware;
|
||
var _YargsInstance_groups;
|
||
var _YargsInstance_hasOutput;
|
||
var _YargsInstance_helpOpt;
|
||
var _YargsInstance_logger;
|
||
var _YargsInstance_output;
|
||
var _YargsInstance_options;
|
||
var _YargsInstance_parentRequire;
|
||
var _YargsInstance_parserConfig;
|
||
var _YargsInstance_parseFn;
|
||
var _YargsInstance_parseContext;
|
||
var _YargsInstance_pkgs;
|
||
var _YargsInstance_preservedGroups;
|
||
var _YargsInstance_processArgs;
|
||
var _YargsInstance_recommendCommands;
|
||
var _YargsInstance_shim;
|
||
var _YargsInstance_strict;
|
||
var _YargsInstance_strictCommands;
|
||
var _YargsInstance_strictOptions;
|
||
var _YargsInstance_usage;
|
||
var _YargsInstance_versionOpt;
|
||
var _YargsInstance_validation;
|
||
function YargsFactory(_shim) {
|
||
return (processArgs = [], cwd = _shim.process.cwd(), parentRequire) => {
|
||
const yargs = new YargsInstance(processArgs, cwd, parentRequire, _shim);
|
||
Object.defineProperty(yargs, "argv", {
|
||
get: () => {
|
||
return yargs.parse();
|
||
},
|
||
enumerable: true
|
||
});
|
||
yargs.help();
|
||
yargs.version();
|
||
return yargs;
|
||
};
|
||
}
|
||
var kCopyDoubleDash = Symbol("copyDoubleDash");
|
||
var kCreateLogger = Symbol("copyDoubleDash");
|
||
var kDeleteFromParserHintObject = Symbol("deleteFromParserHintObject");
|
||
var kEmitWarning = Symbol("emitWarning");
|
||
var kFreeze = Symbol("freeze");
|
||
var kGetDollarZero = Symbol("getDollarZero");
|
||
var kGetParserConfiguration = Symbol("getParserConfiguration");
|
||
var kGuessLocale = Symbol("guessLocale");
|
||
var kGuessVersion = Symbol("guessVersion");
|
||
var kParsePositionalNumbers = Symbol("parsePositionalNumbers");
|
||
var kPkgUp = Symbol("pkgUp");
|
||
var kPopulateParserHintArray = Symbol("populateParserHintArray");
|
||
var kPopulateParserHintSingleValueDictionary = Symbol("populateParserHintSingleValueDictionary");
|
||
var kPopulateParserHintArrayDictionary = Symbol("populateParserHintArrayDictionary");
|
||
var kPopulateParserHintDictionary = Symbol("populateParserHintDictionary");
|
||
var kSanitizeKey = Symbol("sanitizeKey");
|
||
var kSetKey = Symbol("setKey");
|
||
var kUnfreeze = Symbol("unfreeze");
|
||
var kValidateAsync = Symbol("validateAsync");
|
||
var kGetCommandInstance = Symbol("getCommandInstance");
|
||
var kGetContext = Symbol("getContext");
|
||
var kGetHasOutput = Symbol("getHasOutput");
|
||
var kGetLoggerInstance = Symbol("getLoggerInstance");
|
||
var kGetParseContext = Symbol("getParseContext");
|
||
var kGetUsageInstance = Symbol("getUsageInstance");
|
||
var kGetValidationInstance = Symbol("getValidationInstance");
|
||
var kHasParseCallback = Symbol("hasParseCallback");
|
||
var kPostProcess = Symbol("postProcess");
|
||
var kRebase = Symbol("rebase");
|
||
var kReset = Symbol("reset");
|
||
var kRunYargsParserAndExecuteCommands = Symbol("runYargsParserAndExecuteCommands");
|
||
var kRunValidation = Symbol("runValidation");
|
||
var kSetHasOutput = Symbol("setHasOutput");
|
||
var kTrackManuallySetKeys = Symbol("kTrackManuallySetKeys");
|
||
var YargsInstance = class {
|
||
constructor(processArgs = [], cwd, parentRequire, shim3) {
|
||
this.customScriptName = false;
|
||
this.parsed = false;
|
||
_YargsInstance_command.set(this, void 0);
|
||
_YargsInstance_cwd.set(this, void 0);
|
||
_YargsInstance_context.set(this, { commands: [], fullCommands: [] });
|
||
_YargsInstance_completion.set(this, null);
|
||
_YargsInstance_completionCommand.set(this, null);
|
||
_YargsInstance_defaultShowHiddenOpt.set(this, "show-hidden");
|
||
_YargsInstance_exitError.set(this, null);
|
||
_YargsInstance_detectLocale.set(this, true);
|
||
_YargsInstance_emittedWarnings.set(this, {});
|
||
_YargsInstance_exitProcess.set(this, true);
|
||
_YargsInstance_frozens.set(this, []);
|
||
_YargsInstance_globalMiddleware.set(this, void 0);
|
||
_YargsInstance_groups.set(this, {});
|
||
_YargsInstance_hasOutput.set(this, false);
|
||
_YargsInstance_helpOpt.set(this, null);
|
||
_YargsInstance_logger.set(this, void 0);
|
||
_YargsInstance_output.set(this, "");
|
||
_YargsInstance_options.set(this, void 0);
|
||
_YargsInstance_parentRequire.set(this, void 0);
|
||
_YargsInstance_parserConfig.set(this, {});
|
||
_YargsInstance_parseFn.set(this, null);
|
||
_YargsInstance_parseContext.set(this, null);
|
||
_YargsInstance_pkgs.set(this, {});
|
||
_YargsInstance_preservedGroups.set(this, {});
|
||
_YargsInstance_processArgs.set(this, void 0);
|
||
_YargsInstance_recommendCommands.set(this, false);
|
||
_YargsInstance_shim.set(this, void 0);
|
||
_YargsInstance_strict.set(this, false);
|
||
_YargsInstance_strictCommands.set(this, false);
|
||
_YargsInstance_strictOptions.set(this, false);
|
||
_YargsInstance_usage.set(this, void 0);
|
||
_YargsInstance_versionOpt.set(this, null);
|
||
_YargsInstance_validation.set(this, void 0);
|
||
__classPrivateFieldSet(this, _YargsInstance_shim, shim3, "f");
|
||
__classPrivateFieldSet(this, _YargsInstance_processArgs, processArgs, "f");
|
||
__classPrivateFieldSet(this, _YargsInstance_cwd, cwd, "f");
|
||
__classPrivateFieldSet(this, _YargsInstance_parentRequire, parentRequire, "f");
|
||
__classPrivateFieldSet(this, _YargsInstance_globalMiddleware, new GlobalMiddleware(this), "f");
|
||
this.$0 = this[kGetDollarZero]();
|
||
this[kReset]();
|
||
__classPrivateFieldSet(this, _YargsInstance_command, __classPrivateFieldGet(this, _YargsInstance_command, "f"), "f");
|
||
__classPrivateFieldSet(this, _YargsInstance_usage, __classPrivateFieldGet(this, _YargsInstance_usage, "f"), "f");
|
||
__classPrivateFieldSet(this, _YargsInstance_validation, __classPrivateFieldGet(this, _YargsInstance_validation, "f"), "f");
|
||
__classPrivateFieldSet(this, _YargsInstance_options, __classPrivateFieldGet(this, _YargsInstance_options, "f"), "f");
|
||
__classPrivateFieldGet(this, _YargsInstance_options, "f").showHiddenOpt = __classPrivateFieldGet(this, _YargsInstance_defaultShowHiddenOpt, "f");
|
||
__classPrivateFieldSet(this, _YargsInstance_logger, this[kCreateLogger](), "f");
|
||
}
|
||
addHelpOpt(opt, msg) {
|
||
const defaultHelpOpt = "help";
|
||
argsert("[string|boolean] [string]", [opt, msg], arguments.length);
|
||
if (__classPrivateFieldGet(this, _YargsInstance_helpOpt, "f")) {
|
||
this[kDeleteFromParserHintObject](__classPrivateFieldGet(this, _YargsInstance_helpOpt, "f"));
|
||
__classPrivateFieldSet(this, _YargsInstance_helpOpt, null, "f");
|
||
}
|
||
if (opt === false && msg === void 0)
|
||
return this;
|
||
__classPrivateFieldSet(this, _YargsInstance_helpOpt, typeof opt === "string" ? opt : defaultHelpOpt, "f");
|
||
this.boolean(__classPrivateFieldGet(this, _YargsInstance_helpOpt, "f"));
|
||
this.describe(__classPrivateFieldGet(this, _YargsInstance_helpOpt, "f"), msg || __classPrivateFieldGet(this, _YargsInstance_usage, "f").deferY18nLookup("Show help"));
|
||
return this;
|
||
}
|
||
help(opt, msg) {
|
||
return this.addHelpOpt(opt, msg);
|
||
}
|
||
addShowHiddenOpt(opt, msg) {
|
||
argsert("[string|boolean] [string]", [opt, msg], arguments.length);
|
||
if (opt === false && msg === void 0)
|
||
return this;
|
||
const showHiddenOpt = typeof opt === "string" ? opt : __classPrivateFieldGet(this, _YargsInstance_defaultShowHiddenOpt, "f");
|
||
this.boolean(showHiddenOpt);
|
||
this.describe(showHiddenOpt, msg || __classPrivateFieldGet(this, _YargsInstance_usage, "f").deferY18nLookup("Show hidden options"));
|
||
__classPrivateFieldGet(this, _YargsInstance_options, "f").showHiddenOpt = showHiddenOpt;
|
||
return this;
|
||
}
|
||
showHidden(opt, msg) {
|
||
return this.addShowHiddenOpt(opt, msg);
|
||
}
|
||
alias(key, value) {
|
||
argsert("<object|string|array> [string|array]", [key, value], arguments.length);
|
||
this[kPopulateParserHintArrayDictionary](this.alias.bind(this), "alias", key, value);
|
||
return this;
|
||
}
|
||
array(keys) {
|
||
argsert("<array|string>", [keys], arguments.length);
|
||
this[kPopulateParserHintArray]("array", keys);
|
||
this[kTrackManuallySetKeys](keys);
|
||
return this;
|
||
}
|
||
boolean(keys) {
|
||
argsert("<array|string>", [keys], arguments.length);
|
||
this[kPopulateParserHintArray]("boolean", keys);
|
||
this[kTrackManuallySetKeys](keys);
|
||
return this;
|
||
}
|
||
check(f, global2) {
|
||
argsert("<function> [boolean]", [f, global2], arguments.length);
|
||
this.middleware((argv, _yargs) => {
|
||
return maybeAsyncResult(() => {
|
||
return f(argv, _yargs.getOptions());
|
||
}, (result) => {
|
||
if (!result) {
|
||
__classPrivateFieldGet(this, _YargsInstance_usage, "f").fail(__classPrivateFieldGet(this, _YargsInstance_shim, "f").y18n.__("Argument check failed: %s", f.toString()));
|
||
} else if (typeof result === "string" || result instanceof Error) {
|
||
__classPrivateFieldGet(this, _YargsInstance_usage, "f").fail(result.toString(), result);
|
||
}
|
||
return argv;
|
||
}, (err) => {
|
||
__classPrivateFieldGet(this, _YargsInstance_usage, "f").fail(err.message ? err.message : err.toString(), err);
|
||
return argv;
|
||
});
|
||
}, false, global2);
|
||
return this;
|
||
}
|
||
choices(key, value) {
|
||
argsert("<object|string|array> [string|array]", [key, value], arguments.length);
|
||
this[kPopulateParserHintArrayDictionary](this.choices.bind(this), "choices", key, value);
|
||
return this;
|
||
}
|
||
coerce(keys, value) {
|
||
argsert("<object|string|array> [function]", [keys, value], arguments.length);
|
||
if (Array.isArray(keys)) {
|
||
if (!value) {
|
||
throw new YError("coerce callback must be provided");
|
||
}
|
||
for (const key of keys) {
|
||
this.coerce(key, value);
|
||
}
|
||
return this;
|
||
} else if (typeof keys === "object") {
|
||
for (const key of Object.keys(keys)) {
|
||
this.coerce(key, keys[key]);
|
||
}
|
||
return this;
|
||
}
|
||
if (!value) {
|
||
throw new YError("coerce callback must be provided");
|
||
}
|
||
__classPrivateFieldGet(this, _YargsInstance_options, "f").key[keys] = true;
|
||
__classPrivateFieldGet(this, _YargsInstance_globalMiddleware, "f").addCoerceMiddleware((argv, yargs) => {
|
||
let aliases;
|
||
return maybeAsyncResult(() => {
|
||
aliases = yargs.getAliases();
|
||
return value(argv[keys]);
|
||
}, (result) => {
|
||
argv[keys] = result;
|
||
if (aliases[keys]) {
|
||
for (const alias of aliases[keys]) {
|
||
argv[alias] = result;
|
||
}
|
||
}
|
||
return argv;
|
||
}, (err) => {
|
||
throw new YError(err.message);
|
||
});
|
||
}, keys);
|
||
return this;
|
||
}
|
||
conflicts(key1, key2) {
|
||
argsert("<string|object> [string|array]", [key1, key2], arguments.length);
|
||
__classPrivateFieldGet(this, _YargsInstance_validation, "f").conflicts(key1, key2);
|
||
return this;
|
||
}
|
||
config(key = "config", msg, parseFn) {
|
||
argsert("[object|string] [string|function] [function]", [key, msg, parseFn], arguments.length);
|
||
if (typeof key === "object" && !Array.isArray(key)) {
|
||
key = applyExtends(key, __classPrivateFieldGet(this, _YargsInstance_cwd, "f"), this[kGetParserConfiguration]()["deep-merge-config"] || false, __classPrivateFieldGet(this, _YargsInstance_shim, "f"));
|
||
__classPrivateFieldGet(this, _YargsInstance_options, "f").configObjects = (__classPrivateFieldGet(this, _YargsInstance_options, "f").configObjects || []).concat(key);
|
||
return this;
|
||
}
|
||
if (typeof msg === "function") {
|
||
parseFn = msg;
|
||
msg = void 0;
|
||
}
|
||
this.describe(key, msg || __classPrivateFieldGet(this, _YargsInstance_usage, "f").deferY18nLookup("Path to JSON config file"));
|
||
(Array.isArray(key) ? key : [key]).forEach((k) => {
|
||
__classPrivateFieldGet(this, _YargsInstance_options, "f").config[k] = parseFn || true;
|
||
});
|
||
return this;
|
||
}
|
||
completion(cmd, desc, fn) {
|
||
argsert("[string] [string|boolean|function] [function]", [cmd, desc, fn], arguments.length);
|
||
if (typeof desc === "function") {
|
||
fn = desc;
|
||
desc = void 0;
|
||
}
|
||
__classPrivateFieldSet(this, _YargsInstance_completionCommand, cmd || __classPrivateFieldGet(this, _YargsInstance_completionCommand, "f") || "completion", "f");
|
||
if (!desc && desc !== false) {
|
||
desc = "generate completion script";
|
||
}
|
||
this.command(__classPrivateFieldGet(this, _YargsInstance_completionCommand, "f"), desc);
|
||
if (fn)
|
||
__classPrivateFieldGet(this, _YargsInstance_completion, "f").registerFunction(fn);
|
||
return this;
|
||
}
|
||
command(cmd, description, builder, handler, middlewares, deprecated) {
|
||
argsert("<string|array|object> [string|boolean] [function|object] [function] [array] [boolean|string]", [cmd, description, builder, handler, middlewares, deprecated], arguments.length);
|
||
__classPrivateFieldGet(this, _YargsInstance_command, "f").addHandler(cmd, description, builder, handler, middlewares, deprecated);
|
||
return this;
|
||
}
|
||
commands(cmd, description, builder, handler, middlewares, deprecated) {
|
||
return this.command(cmd, description, builder, handler, middlewares, deprecated);
|
||
}
|
||
commandDir(dir, opts) {
|
||
argsert("<string> [object]", [dir, opts], arguments.length);
|
||
const req = __classPrivateFieldGet(this, _YargsInstance_parentRequire, "f") || __classPrivateFieldGet(this, _YargsInstance_shim, "f").require;
|
||
__classPrivateFieldGet(this, _YargsInstance_command, "f").addDirectory(dir, req, __classPrivateFieldGet(this, _YargsInstance_shim, "f").getCallerFile(), opts);
|
||
return this;
|
||
}
|
||
count(keys) {
|
||
argsert("<array|string>", [keys], arguments.length);
|
||
this[kPopulateParserHintArray]("count", keys);
|
||
this[kTrackManuallySetKeys](keys);
|
||
return this;
|
||
}
|
||
default(key, value, defaultDescription) {
|
||
argsert("<object|string|array> [*] [string]", [key, value, defaultDescription], arguments.length);
|
||
if (defaultDescription) {
|
||
assertSingleKey(key, __classPrivateFieldGet(this, _YargsInstance_shim, "f"));
|
||
__classPrivateFieldGet(this, _YargsInstance_options, "f").defaultDescription[key] = defaultDescription;
|
||
}
|
||
if (typeof value === "function") {
|
||
assertSingleKey(key, __classPrivateFieldGet(this, _YargsInstance_shim, "f"));
|
||
if (!__classPrivateFieldGet(this, _YargsInstance_options, "f").defaultDescription[key])
|
||
__classPrivateFieldGet(this, _YargsInstance_options, "f").defaultDescription[key] = __classPrivateFieldGet(this, _YargsInstance_usage, "f").functionDescription(value);
|
||
value = value.call();
|
||
}
|
||
this[kPopulateParserHintSingleValueDictionary](this.default.bind(this), "default", key, value);
|
||
return this;
|
||
}
|
||
defaults(key, value, defaultDescription) {
|
||
return this.default(key, value, defaultDescription);
|
||
}
|
||
demandCommand(min = 1, max, minMsg, maxMsg) {
|
||
argsert("[number] [number|string] [string|null|undefined] [string|null|undefined]", [min, max, minMsg, maxMsg], arguments.length);
|
||
if (typeof max !== "number") {
|
||
minMsg = max;
|
||
max = Infinity;
|
||
}
|
||
this.global("_", false);
|
||
__classPrivateFieldGet(this, _YargsInstance_options, "f").demandedCommands._ = {
|
||
min,
|
||
max,
|
||
minMsg,
|
||
maxMsg
|
||
};
|
||
return this;
|
||
}
|
||
demand(keys, max, msg) {
|
||
if (Array.isArray(max)) {
|
||
max.forEach((key) => {
|
||
assertNotStrictEqual(msg, true, __classPrivateFieldGet(this, _YargsInstance_shim, "f"));
|
||
this.demandOption(key, msg);
|
||
});
|
||
max = Infinity;
|
||
} else if (typeof max !== "number") {
|
||
msg = max;
|
||
max = Infinity;
|
||
}
|
||
if (typeof keys === "number") {
|
||
assertNotStrictEqual(msg, true, __classPrivateFieldGet(this, _YargsInstance_shim, "f"));
|
||
this.demandCommand(keys, max, msg, msg);
|
||
} else if (Array.isArray(keys)) {
|
||
keys.forEach((key) => {
|
||
assertNotStrictEqual(msg, true, __classPrivateFieldGet(this, _YargsInstance_shim, "f"));
|
||
this.demandOption(key, msg);
|
||
});
|
||
} else {
|
||
if (typeof msg === "string") {
|
||
this.demandOption(keys, msg);
|
||
} else if (msg === true || typeof msg === "undefined") {
|
||
this.demandOption(keys);
|
||
}
|
||
}
|
||
return this;
|
||
}
|
||
demandOption(keys, msg) {
|
||
argsert("<object|string|array> [string]", [keys, msg], arguments.length);
|
||
this[kPopulateParserHintSingleValueDictionary](this.demandOption.bind(this), "demandedOptions", keys, msg);
|
||
return this;
|
||
}
|
||
deprecateOption(option, message) {
|
||
argsert("<string> [string|boolean]", [option, message], arguments.length);
|
||
__classPrivateFieldGet(this, _YargsInstance_options, "f").deprecatedOptions[option] = message;
|
||
return this;
|
||
}
|
||
describe(keys, description) {
|
||
argsert("<object|string|array> [string]", [keys, description], arguments.length);
|
||
this[kSetKey](keys, true);
|
||
__classPrivateFieldGet(this, _YargsInstance_usage, "f").describe(keys, description);
|
||
return this;
|
||
}
|
||
detectLocale(detect) {
|
||
argsert("<boolean>", [detect], arguments.length);
|
||
__classPrivateFieldSet(this, _YargsInstance_detectLocale, detect, "f");
|
||
return this;
|
||
}
|
||
env(prefix) {
|
||
argsert("[string|boolean]", [prefix], arguments.length);
|
||
if (prefix === false)
|
||
delete __classPrivateFieldGet(this, _YargsInstance_options, "f").envPrefix;
|
||
else
|
||
__classPrivateFieldGet(this, _YargsInstance_options, "f").envPrefix = prefix || "";
|
||
return this;
|
||
}
|
||
epilogue(msg) {
|
||
argsert("<string>", [msg], arguments.length);
|
||
__classPrivateFieldGet(this, _YargsInstance_usage, "f").epilog(msg);
|
||
return this;
|
||
}
|
||
epilog(msg) {
|
||
return this.epilogue(msg);
|
||
}
|
||
example(cmd, description) {
|
||
argsert("<string|array> [string]", [cmd, description], arguments.length);
|
||
if (Array.isArray(cmd)) {
|
||
cmd.forEach((exampleParams) => this.example(...exampleParams));
|
||
} else {
|
||
__classPrivateFieldGet(this, _YargsInstance_usage, "f").example(cmd, description);
|
||
}
|
||
return this;
|
||
}
|
||
exit(code, err) {
|
||
__classPrivateFieldSet(this, _YargsInstance_hasOutput, true, "f");
|
||
__classPrivateFieldSet(this, _YargsInstance_exitError, err, "f");
|
||
if (__classPrivateFieldGet(this, _YargsInstance_exitProcess, "f"))
|
||
__classPrivateFieldGet(this, _YargsInstance_shim, "f").process.exit(code);
|
||
}
|
||
exitProcess(enabled = true) {
|
||
argsert("[boolean]", [enabled], arguments.length);
|
||
__classPrivateFieldSet(this, _YargsInstance_exitProcess, enabled, "f");
|
||
return this;
|
||
}
|
||
fail(f) {
|
||
argsert("<function|boolean>", [f], arguments.length);
|
||
if (typeof f === "boolean" && f !== false) {
|
||
throw new YError("Invalid first argument. Expected function or boolean 'false'");
|
||
}
|
||
__classPrivateFieldGet(this, _YargsInstance_usage, "f").failFn(f);
|
||
return this;
|
||
}
|
||
getAliases() {
|
||
return this.parsed ? this.parsed.aliases : {};
|
||
}
|
||
async getCompletion(args, done) {
|
||
argsert("<array> [function]", [args, done], arguments.length);
|
||
if (!done) {
|
||
return new Promise((resolve6, reject) => {
|
||
__classPrivateFieldGet(this, _YargsInstance_completion, "f").getCompletion(args, (err, completions) => {
|
||
if (err)
|
||
reject(err);
|
||
else
|
||
resolve6(completions);
|
||
});
|
||
});
|
||
} else {
|
||
return __classPrivateFieldGet(this, _YargsInstance_completion, "f").getCompletion(args, done);
|
||
}
|
||
}
|
||
getDemandedOptions() {
|
||
argsert([], 0);
|
||
return __classPrivateFieldGet(this, _YargsInstance_options, "f").demandedOptions;
|
||
}
|
||
getDemandedCommands() {
|
||
argsert([], 0);
|
||
return __classPrivateFieldGet(this, _YargsInstance_options, "f").demandedCommands;
|
||
}
|
||
getDeprecatedOptions() {
|
||
argsert([], 0);
|
||
return __classPrivateFieldGet(this, _YargsInstance_options, "f").deprecatedOptions;
|
||
}
|
||
getDetectLocale() {
|
||
return __classPrivateFieldGet(this, _YargsInstance_detectLocale, "f");
|
||
}
|
||
getExitProcess() {
|
||
return __classPrivateFieldGet(this, _YargsInstance_exitProcess, "f");
|
||
}
|
||
getGroups() {
|
||
return Object.assign({}, __classPrivateFieldGet(this, _YargsInstance_groups, "f"), __classPrivateFieldGet(this, _YargsInstance_preservedGroups, "f"));
|
||
}
|
||
getHelp() {
|
||
__classPrivateFieldSet(this, _YargsInstance_hasOutput, true, "f");
|
||
if (!__classPrivateFieldGet(this, _YargsInstance_usage, "f").hasCachedHelpMessage()) {
|
||
if (!this.parsed) {
|
||
const parse2 = this[kRunYargsParserAndExecuteCommands](__classPrivateFieldGet(this, _YargsInstance_processArgs, "f"), void 0, void 0, 0, true);
|
||
if (isPromise(parse2)) {
|
||
return parse2.then(() => {
|
||
return __classPrivateFieldGet(this, _YargsInstance_usage, "f").help();
|
||
});
|
||
}
|
||
}
|
||
const builderResponse = __classPrivateFieldGet(this, _YargsInstance_command, "f").runDefaultBuilderOn(this);
|
||
if (isPromise(builderResponse)) {
|
||
return builderResponse.then(() => {
|
||
return __classPrivateFieldGet(this, _YargsInstance_usage, "f").help();
|
||
});
|
||
}
|
||
}
|
||
return Promise.resolve(__classPrivateFieldGet(this, _YargsInstance_usage, "f").help());
|
||
}
|
||
getOptions() {
|
||
return __classPrivateFieldGet(this, _YargsInstance_options, "f");
|
||
}
|
||
getStrict() {
|
||
return __classPrivateFieldGet(this, _YargsInstance_strict, "f");
|
||
}
|
||
getStrictCommands() {
|
||
return __classPrivateFieldGet(this, _YargsInstance_strictCommands, "f");
|
||
}
|
||
getStrictOptions() {
|
||
return __classPrivateFieldGet(this, _YargsInstance_strictOptions, "f");
|
||
}
|
||
global(globals, global2) {
|
||
argsert("<string|array> [boolean]", [globals, global2], arguments.length);
|
||
globals = [].concat(globals);
|
||
if (global2 !== false) {
|
||
__classPrivateFieldGet(this, _YargsInstance_options, "f").local = __classPrivateFieldGet(this, _YargsInstance_options, "f").local.filter((l) => globals.indexOf(l) === -1);
|
||
} else {
|
||
globals.forEach((g) => {
|
||
if (!__classPrivateFieldGet(this, _YargsInstance_options, "f").local.includes(g))
|
||
__classPrivateFieldGet(this, _YargsInstance_options, "f").local.push(g);
|
||
});
|
||
}
|
||
return this;
|
||
}
|
||
group(opts, groupName) {
|
||
argsert("<string|array> <string>", [opts, groupName], arguments.length);
|
||
const existing = __classPrivateFieldGet(this, _YargsInstance_preservedGroups, "f")[groupName] || __classPrivateFieldGet(this, _YargsInstance_groups, "f")[groupName];
|
||
if (__classPrivateFieldGet(this, _YargsInstance_preservedGroups, "f")[groupName]) {
|
||
delete __classPrivateFieldGet(this, _YargsInstance_preservedGroups, "f")[groupName];
|
||
}
|
||
const seen = {};
|
||
__classPrivateFieldGet(this, _YargsInstance_groups, "f")[groupName] = (existing || []).concat(opts).filter((key) => {
|
||
if (seen[key])
|
||
return false;
|
||
return seen[key] = true;
|
||
});
|
||
return this;
|
||
}
|
||
hide(key) {
|
||
argsert("<string>", [key], arguments.length);
|
||
__classPrivateFieldGet(this, _YargsInstance_options, "f").hiddenOptions.push(key);
|
||
return this;
|
||
}
|
||
implies(key, value) {
|
||
argsert("<string|object> [number|string|array]", [key, value], arguments.length);
|
||
__classPrivateFieldGet(this, _YargsInstance_validation, "f").implies(key, value);
|
||
return this;
|
||
}
|
||
locale(locale) {
|
||
argsert("[string]", [locale], arguments.length);
|
||
if (!locale) {
|
||
this[kGuessLocale]();
|
||
return __classPrivateFieldGet(this, _YargsInstance_shim, "f").y18n.getLocale();
|
||
}
|
||
__classPrivateFieldSet(this, _YargsInstance_detectLocale, false, "f");
|
||
__classPrivateFieldGet(this, _YargsInstance_shim, "f").y18n.setLocale(locale);
|
||
return this;
|
||
}
|
||
middleware(callback, applyBeforeValidation, global2) {
|
||
return __classPrivateFieldGet(this, _YargsInstance_globalMiddleware, "f").addMiddleware(callback, !!applyBeforeValidation, global2);
|
||
}
|
||
nargs(key, value) {
|
||
argsert("<string|object|array> [number]", [key, value], arguments.length);
|
||
this[kPopulateParserHintSingleValueDictionary](this.nargs.bind(this), "narg", key, value);
|
||
return this;
|
||
}
|
||
normalize(keys) {
|
||
argsert("<array|string>", [keys], arguments.length);
|
||
this[kPopulateParserHintArray]("normalize", keys);
|
||
return this;
|
||
}
|
||
number(keys) {
|
||
argsert("<array|string>", [keys], arguments.length);
|
||
this[kPopulateParserHintArray]("number", keys);
|
||
this[kTrackManuallySetKeys](keys);
|
||
return this;
|
||
}
|
||
option(key, opt) {
|
||
argsert("<string|object> [object]", [key, opt], arguments.length);
|
||
if (typeof key === "object") {
|
||
Object.keys(key).forEach((k) => {
|
||
this.options(k, key[k]);
|
||
});
|
||
} else {
|
||
if (typeof opt !== "object") {
|
||
opt = {};
|
||
}
|
||
this[kTrackManuallySetKeys](key);
|
||
if (__classPrivateFieldGet(this, _YargsInstance_versionOpt, "f") && (key === "version" || (opt === null || opt === void 0 ? void 0 : opt.alias) === "version")) {
|
||
this[kEmitWarning]([
|
||
'"version" is a reserved word.',
|
||
"Please do one of the following:",
|
||
'- Disable version with `yargs.version(false)` if using "version" as an option',
|
||
"- Use the built-in `yargs.version` method instead (if applicable)",
|
||
"- Use a different option key",
|
||
"https://yargs.js.org/docs/#api-reference-version"
|
||
].join("\n"), void 0, "versionWarning");
|
||
}
|
||
__classPrivateFieldGet(this, _YargsInstance_options, "f").key[key] = true;
|
||
if (opt.alias)
|
||
this.alias(key, opt.alias);
|
||
const deprecate = opt.deprecate || opt.deprecated;
|
||
if (deprecate) {
|
||
this.deprecateOption(key, deprecate);
|
||
}
|
||
const demand = opt.demand || opt.required || opt.require;
|
||
if (demand) {
|
||
this.demand(key, demand);
|
||
}
|
||
if (opt.demandOption) {
|
||
this.demandOption(key, typeof opt.demandOption === "string" ? opt.demandOption : void 0);
|
||
}
|
||
if (opt.conflicts) {
|
||
this.conflicts(key, opt.conflicts);
|
||
}
|
||
if ("default" in opt) {
|
||
this.default(key, opt.default);
|
||
}
|
||
if (opt.implies !== void 0) {
|
||
this.implies(key, opt.implies);
|
||
}
|
||
if (opt.nargs !== void 0) {
|
||
this.nargs(key, opt.nargs);
|
||
}
|
||
if (opt.config) {
|
||
this.config(key, opt.configParser);
|
||
}
|
||
if (opt.normalize) {
|
||
this.normalize(key);
|
||
}
|
||
if (opt.choices) {
|
||
this.choices(key, opt.choices);
|
||
}
|
||
if (opt.coerce) {
|
||
this.coerce(key, opt.coerce);
|
||
}
|
||
if (opt.group) {
|
||
this.group(key, opt.group);
|
||
}
|
||
if (opt.boolean || opt.type === "boolean") {
|
||
this.boolean(key);
|
||
if (opt.alias)
|
||
this.boolean(opt.alias);
|
||
}
|
||
if (opt.array || opt.type === "array") {
|
||
this.array(key);
|
||
if (opt.alias)
|
||
this.array(opt.alias);
|
||
}
|
||
if (opt.number || opt.type === "number") {
|
||
this.number(key);
|
||
if (opt.alias)
|
||
this.number(opt.alias);
|
||
}
|
||
if (opt.string || opt.type === "string") {
|
||
this.string(key);
|
||
if (opt.alias)
|
||
this.string(opt.alias);
|
||
}
|
||
if (opt.count || opt.type === "count") {
|
||
this.count(key);
|
||
}
|
||
if (typeof opt.global === "boolean") {
|
||
this.global(key, opt.global);
|
||
}
|
||
if (opt.defaultDescription) {
|
||
__classPrivateFieldGet(this, _YargsInstance_options, "f").defaultDescription[key] = opt.defaultDescription;
|
||
}
|
||
if (opt.skipValidation) {
|
||
this.skipValidation(key);
|
||
}
|
||
const desc = opt.describe || opt.description || opt.desc;
|
||
this.describe(key, desc);
|
||
if (opt.hidden) {
|
||
this.hide(key);
|
||
}
|
||
if (opt.requiresArg) {
|
||
this.requiresArg(key);
|
||
}
|
||
}
|
||
return this;
|
||
}
|
||
options(key, opt) {
|
||
return this.option(key, opt);
|
||
}
|
||
parse(args, shortCircuit, _parseFn) {
|
||
argsert("[string|array] [function|boolean|object] [function]", [args, shortCircuit, _parseFn], arguments.length);
|
||
this[kFreeze]();
|
||
if (typeof args === "undefined") {
|
||
args = __classPrivateFieldGet(this, _YargsInstance_processArgs, "f");
|
||
}
|
||
if (typeof shortCircuit === "object") {
|
||
__classPrivateFieldSet(this, _YargsInstance_parseContext, shortCircuit, "f");
|
||
shortCircuit = _parseFn;
|
||
}
|
||
if (typeof shortCircuit === "function") {
|
||
__classPrivateFieldSet(this, _YargsInstance_parseFn, shortCircuit, "f");
|
||
shortCircuit = false;
|
||
}
|
||
if (!shortCircuit)
|
||
__classPrivateFieldSet(this, _YargsInstance_processArgs, args, "f");
|
||
if (__classPrivateFieldGet(this, _YargsInstance_parseFn, "f"))
|
||
__classPrivateFieldSet(this, _YargsInstance_exitProcess, false, "f");
|
||
const parsed = this[kRunYargsParserAndExecuteCommands](args, !!shortCircuit);
|
||
const tmpParsed = this.parsed;
|
||
__classPrivateFieldGet(this, _YargsInstance_completion, "f").setParsed(this.parsed);
|
||
if (isPromise(parsed)) {
|
||
return parsed.then((argv) => {
|
||
if (__classPrivateFieldGet(this, _YargsInstance_parseFn, "f"))
|
||
__classPrivateFieldGet(this, _YargsInstance_parseFn, "f").call(this, __classPrivateFieldGet(this, _YargsInstance_exitError, "f"), argv, __classPrivateFieldGet(this, _YargsInstance_output, "f"));
|
||
return argv;
|
||
}).catch((err) => {
|
||
if (__classPrivateFieldGet(this, _YargsInstance_parseFn, "f")) {
|
||
__classPrivateFieldGet(this, _YargsInstance_parseFn, "f")(err, this.parsed.argv, __classPrivateFieldGet(this, _YargsInstance_output, "f"));
|
||
}
|
||
throw err;
|
||
}).finally(() => {
|
||
this[kUnfreeze]();
|
||
this.parsed = tmpParsed;
|
||
});
|
||
} else {
|
||
if (__classPrivateFieldGet(this, _YargsInstance_parseFn, "f"))
|
||
__classPrivateFieldGet(this, _YargsInstance_parseFn, "f").call(this, __classPrivateFieldGet(this, _YargsInstance_exitError, "f"), parsed, __classPrivateFieldGet(this, _YargsInstance_output, "f"));
|
||
this[kUnfreeze]();
|
||
this.parsed = tmpParsed;
|
||
}
|
||
return parsed;
|
||
}
|
||
parseAsync(args, shortCircuit, _parseFn) {
|
||
const maybePromise = this.parse(args, shortCircuit, _parseFn);
|
||
return !isPromise(maybePromise) ? Promise.resolve(maybePromise) : maybePromise;
|
||
}
|
||
parseSync(args, shortCircuit, _parseFn) {
|
||
const maybePromise = this.parse(args, shortCircuit, _parseFn);
|
||
if (isPromise(maybePromise)) {
|
||
throw new YError(".parseSync() must not be used with asynchronous builders, handlers, or middleware");
|
||
}
|
||
return maybePromise;
|
||
}
|
||
parserConfiguration(config) {
|
||
argsert("<object>", [config], arguments.length);
|
||
__classPrivateFieldSet(this, _YargsInstance_parserConfig, config, "f");
|
||
return this;
|
||
}
|
||
pkgConf(key, rootPath) {
|
||
argsert("<string> [string]", [key, rootPath], arguments.length);
|
||
let conf = null;
|
||
const obj = this[kPkgUp](rootPath || __classPrivateFieldGet(this, _YargsInstance_cwd, "f"));
|
||
if (obj[key] && typeof obj[key] === "object") {
|
||
conf = applyExtends(obj[key], rootPath || __classPrivateFieldGet(this, _YargsInstance_cwd, "f"), this[kGetParserConfiguration]()["deep-merge-config"] || false, __classPrivateFieldGet(this, _YargsInstance_shim, "f"));
|
||
__classPrivateFieldGet(this, _YargsInstance_options, "f").configObjects = (__classPrivateFieldGet(this, _YargsInstance_options, "f").configObjects || []).concat(conf);
|
||
}
|
||
return this;
|
||
}
|
||
positional(key, opts) {
|
||
argsert("<string> <object>", [key, opts], arguments.length);
|
||
const supportedOpts = [
|
||
"default",
|
||
"defaultDescription",
|
||
"implies",
|
||
"normalize",
|
||
"choices",
|
||
"conflicts",
|
||
"coerce",
|
||
"type",
|
||
"describe",
|
||
"desc",
|
||
"description",
|
||
"alias"
|
||
];
|
||
opts = objFilter(opts, (k, v) => {
|
||
if (k === "type" && !["string", "number", "boolean"].includes(v))
|
||
return false;
|
||
return supportedOpts.includes(k);
|
||
});
|
||
const fullCommand = __classPrivateFieldGet(this, _YargsInstance_context, "f").fullCommands[__classPrivateFieldGet(this, _YargsInstance_context, "f").fullCommands.length - 1];
|
||
const parseOptions = fullCommand ? __classPrivateFieldGet(this, _YargsInstance_command, "f").cmdToParseOptions(fullCommand) : {
|
||
array: [],
|
||
alias: {},
|
||
default: {},
|
||
demand: {}
|
||
};
|
||
objectKeys(parseOptions).forEach((pk) => {
|
||
const parseOption = parseOptions[pk];
|
||
if (Array.isArray(parseOption)) {
|
||
if (parseOption.indexOf(key) !== -1)
|
||
opts[pk] = true;
|
||
} else {
|
||
if (parseOption[key] && !(pk in opts))
|
||
opts[pk] = parseOption[key];
|
||
}
|
||
});
|
||
this.group(key, __classPrivateFieldGet(this, _YargsInstance_usage, "f").getPositionalGroupName());
|
||
return this.option(key, opts);
|
||
}
|
||
recommendCommands(recommend = true) {
|
||
argsert("[boolean]", [recommend], arguments.length);
|
||
__classPrivateFieldSet(this, _YargsInstance_recommendCommands, recommend, "f");
|
||
return this;
|
||
}
|
||
required(keys, max, msg) {
|
||
return this.demand(keys, max, msg);
|
||
}
|
||
require(keys, max, msg) {
|
||
return this.demand(keys, max, msg);
|
||
}
|
||
requiresArg(keys) {
|
||
argsert("<array|string|object> [number]", [keys], arguments.length);
|
||
if (typeof keys === "string" && __classPrivateFieldGet(this, _YargsInstance_options, "f").narg[keys]) {
|
||
return this;
|
||
} else {
|
||
this[kPopulateParserHintSingleValueDictionary](this.requiresArg.bind(this), "narg", keys, NaN);
|
||
}
|
||
return this;
|
||
}
|
||
showCompletionScript($0, cmd) {
|
||
argsert("[string] [string]", [$0, cmd], arguments.length);
|
||
$0 = $0 || this.$0;
|
||
__classPrivateFieldGet(this, _YargsInstance_logger, "f").log(__classPrivateFieldGet(this, _YargsInstance_completion, "f").generateCompletionScript($0, cmd || __classPrivateFieldGet(this, _YargsInstance_completionCommand, "f") || "completion"));
|
||
return this;
|
||
}
|
||
showHelp(level) {
|
||
argsert("[string|function]", [level], arguments.length);
|
||
__classPrivateFieldSet(this, _YargsInstance_hasOutput, true, "f");
|
||
if (!__classPrivateFieldGet(this, _YargsInstance_usage, "f").hasCachedHelpMessage()) {
|
||
if (!this.parsed) {
|
||
const parse2 = this[kRunYargsParserAndExecuteCommands](__classPrivateFieldGet(this, _YargsInstance_processArgs, "f"), void 0, void 0, 0, true);
|
||
if (isPromise(parse2)) {
|
||
parse2.then(() => {
|
||
__classPrivateFieldGet(this, _YargsInstance_usage, "f").showHelp(level);
|
||
});
|
||
return this;
|
||
}
|
||
}
|
||
const builderResponse = __classPrivateFieldGet(this, _YargsInstance_command, "f").runDefaultBuilderOn(this);
|
||
if (isPromise(builderResponse)) {
|
||
builderResponse.then(() => {
|
||
__classPrivateFieldGet(this, _YargsInstance_usage, "f").showHelp(level);
|
||
});
|
||
return this;
|
||
}
|
||
}
|
||
__classPrivateFieldGet(this, _YargsInstance_usage, "f").showHelp(level);
|
||
return this;
|
||
}
|
||
scriptName(scriptName) {
|
||
this.customScriptName = true;
|
||
this.$0 = scriptName;
|
||
return this;
|
||
}
|
||
showHelpOnFail(enabled, message) {
|
||
argsert("[boolean|string] [string]", [enabled, message], arguments.length);
|
||
__classPrivateFieldGet(this, _YargsInstance_usage, "f").showHelpOnFail(enabled, message);
|
||
return this;
|
||
}
|
||
showVersion(level) {
|
||
argsert("[string|function]", [level], arguments.length);
|
||
__classPrivateFieldGet(this, _YargsInstance_usage, "f").showVersion(level);
|
||
return this;
|
||
}
|
||
skipValidation(keys) {
|
||
argsert("<array|string>", [keys], arguments.length);
|
||
this[kPopulateParserHintArray]("skipValidation", keys);
|
||
return this;
|
||
}
|
||
strict(enabled) {
|
||
argsert("[boolean]", [enabled], arguments.length);
|
||
__classPrivateFieldSet(this, _YargsInstance_strict, enabled !== false, "f");
|
||
return this;
|
||
}
|
||
strictCommands(enabled) {
|
||
argsert("[boolean]", [enabled], arguments.length);
|
||
__classPrivateFieldSet(this, _YargsInstance_strictCommands, enabled !== false, "f");
|
||
return this;
|
||
}
|
||
strictOptions(enabled) {
|
||
argsert("[boolean]", [enabled], arguments.length);
|
||
__classPrivateFieldSet(this, _YargsInstance_strictOptions, enabled !== false, "f");
|
||
return this;
|
||
}
|
||
string(keys) {
|
||
argsert("<array|string>", [keys], arguments.length);
|
||
this[kPopulateParserHintArray]("string", keys);
|
||
this[kTrackManuallySetKeys](keys);
|
||
return this;
|
||
}
|
||
terminalWidth() {
|
||
argsert([], 0);
|
||
return __classPrivateFieldGet(this, _YargsInstance_shim, "f").process.stdColumns;
|
||
}
|
||
updateLocale(obj) {
|
||
return this.updateStrings(obj);
|
||
}
|
||
updateStrings(obj) {
|
||
argsert("<object>", [obj], arguments.length);
|
||
__classPrivateFieldSet(this, _YargsInstance_detectLocale, false, "f");
|
||
__classPrivateFieldGet(this, _YargsInstance_shim, "f").y18n.updateLocale(obj);
|
||
return this;
|
||
}
|
||
usage(msg, description, builder, handler) {
|
||
argsert("<string|null|undefined> [string|boolean] [function|object] [function]", [msg, description, builder, handler], arguments.length);
|
||
if (description !== void 0) {
|
||
assertNotStrictEqual(msg, null, __classPrivateFieldGet(this, _YargsInstance_shim, "f"));
|
||
if ((msg || "").match(/^\$0( |$)/)) {
|
||
return this.command(msg, description, builder, handler);
|
||
} else {
|
||
throw new YError(".usage() description must start with $0 if being used as alias for .command()");
|
||
}
|
||
} else {
|
||
__classPrivateFieldGet(this, _YargsInstance_usage, "f").usage(msg);
|
||
return this;
|
||
}
|
||
}
|
||
version(opt, msg, ver) {
|
||
const defaultVersionOpt = "version";
|
||
argsert("[boolean|string] [string] [string]", [opt, msg, ver], arguments.length);
|
||
if (__classPrivateFieldGet(this, _YargsInstance_versionOpt, "f")) {
|
||
this[kDeleteFromParserHintObject](__classPrivateFieldGet(this, _YargsInstance_versionOpt, "f"));
|
||
__classPrivateFieldGet(this, _YargsInstance_usage, "f").version(void 0);
|
||
__classPrivateFieldSet(this, _YargsInstance_versionOpt, null, "f");
|
||
}
|
||
if (arguments.length === 0) {
|
||
ver = this[kGuessVersion]();
|
||
opt = defaultVersionOpt;
|
||
} else if (arguments.length === 1) {
|
||
if (opt === false) {
|
||
return this;
|
||
}
|
||
ver = opt;
|
||
opt = defaultVersionOpt;
|
||
} else if (arguments.length === 2) {
|
||
ver = msg;
|
||
msg = void 0;
|
||
}
|
||
__classPrivateFieldSet(this, _YargsInstance_versionOpt, typeof opt === "string" ? opt : defaultVersionOpt, "f");
|
||
msg = msg || __classPrivateFieldGet(this, _YargsInstance_usage, "f").deferY18nLookup("Show version number");
|
||
__classPrivateFieldGet(this, _YargsInstance_usage, "f").version(ver || void 0);
|
||
this.boolean(__classPrivateFieldGet(this, _YargsInstance_versionOpt, "f"));
|
||
this.describe(__classPrivateFieldGet(this, _YargsInstance_versionOpt, "f"), msg);
|
||
return this;
|
||
}
|
||
wrap(cols) {
|
||
argsert("<number|null|undefined>", [cols], arguments.length);
|
||
__classPrivateFieldGet(this, _YargsInstance_usage, "f").wrap(cols);
|
||
return this;
|
||
}
|
||
[(_YargsInstance_command = /* @__PURE__ */ new WeakMap(), _YargsInstance_cwd = /* @__PURE__ */ new WeakMap(), _YargsInstance_context = /* @__PURE__ */ new WeakMap(), _YargsInstance_completion = /* @__PURE__ */ new WeakMap(), _YargsInstance_completionCommand = /* @__PURE__ */ new WeakMap(), _YargsInstance_defaultShowHiddenOpt = /* @__PURE__ */ new WeakMap(), _YargsInstance_exitError = /* @__PURE__ */ new WeakMap(), _YargsInstance_detectLocale = /* @__PURE__ */ new WeakMap(), _YargsInstance_emittedWarnings = /* @__PURE__ */ new WeakMap(), _YargsInstance_exitProcess = /* @__PURE__ */ new WeakMap(), _YargsInstance_frozens = /* @__PURE__ */ new WeakMap(), _YargsInstance_globalMiddleware = /* @__PURE__ */ new WeakMap(), _YargsInstance_groups = /* @__PURE__ */ new WeakMap(), _YargsInstance_hasOutput = /* @__PURE__ */ new WeakMap(), _YargsInstance_helpOpt = /* @__PURE__ */ new WeakMap(), _YargsInstance_logger = /* @__PURE__ */ new WeakMap(), _YargsInstance_output = /* @__PURE__ */ new WeakMap(), _YargsInstance_options = /* @__PURE__ */ new WeakMap(), _YargsInstance_parentRequire = /* @__PURE__ */ new WeakMap(), _YargsInstance_parserConfig = /* @__PURE__ */ new WeakMap(), _YargsInstance_parseFn = /* @__PURE__ */ new WeakMap(), _YargsInstance_parseContext = /* @__PURE__ */ new WeakMap(), _YargsInstance_pkgs = /* @__PURE__ */ new WeakMap(), _YargsInstance_preservedGroups = /* @__PURE__ */ new WeakMap(), _YargsInstance_processArgs = /* @__PURE__ */ new WeakMap(), _YargsInstance_recommendCommands = /* @__PURE__ */ new WeakMap(), _YargsInstance_shim = /* @__PURE__ */ new WeakMap(), _YargsInstance_strict = /* @__PURE__ */ new WeakMap(), _YargsInstance_strictCommands = /* @__PURE__ */ new WeakMap(), _YargsInstance_strictOptions = /* @__PURE__ */ new WeakMap(), _YargsInstance_usage = /* @__PURE__ */ new WeakMap(), _YargsInstance_versionOpt = /* @__PURE__ */ new WeakMap(), _YargsInstance_validation = /* @__PURE__ */ new WeakMap(), kCopyDoubleDash)](argv) {
|
||
if (!argv._ || !argv["--"])
|
||
return argv;
|
||
argv._.push.apply(argv._, argv["--"]);
|
||
try {
|
||
delete argv["--"];
|
||
} catch (_err) {
|
||
}
|
||
return argv;
|
||
}
|
||
[kCreateLogger]() {
|
||
return {
|
||
log: (...args) => {
|
||
if (!this[kHasParseCallback]())
|
||
console.log(...args);
|
||
__classPrivateFieldSet(this, _YargsInstance_hasOutput, true, "f");
|
||
if (__classPrivateFieldGet(this, _YargsInstance_output, "f").length)
|
||
__classPrivateFieldSet(this, _YargsInstance_output, __classPrivateFieldGet(this, _YargsInstance_output, "f") + "\n", "f");
|
||
__classPrivateFieldSet(this, _YargsInstance_output, __classPrivateFieldGet(this, _YargsInstance_output, "f") + args.join(" "), "f");
|
||
},
|
||
error: (...args) => {
|
||
if (!this[kHasParseCallback]())
|
||
console.error(...args);
|
||
__classPrivateFieldSet(this, _YargsInstance_hasOutput, true, "f");
|
||
if (__classPrivateFieldGet(this, _YargsInstance_output, "f").length)
|
||
__classPrivateFieldSet(this, _YargsInstance_output, __classPrivateFieldGet(this, _YargsInstance_output, "f") + "\n", "f");
|
||
__classPrivateFieldSet(this, _YargsInstance_output, __classPrivateFieldGet(this, _YargsInstance_output, "f") + args.join(" "), "f");
|
||
}
|
||
};
|
||
}
|
||
[kDeleteFromParserHintObject](optionKey) {
|
||
objectKeys(__classPrivateFieldGet(this, _YargsInstance_options, "f")).forEach((hintKey) => {
|
||
if (((key) => key === "configObjects")(hintKey))
|
||
return;
|
||
const hint = __classPrivateFieldGet(this, _YargsInstance_options, "f")[hintKey];
|
||
if (Array.isArray(hint)) {
|
||
if (hint.includes(optionKey))
|
||
hint.splice(hint.indexOf(optionKey), 1);
|
||
} else if (typeof hint === "object") {
|
||
delete hint[optionKey];
|
||
}
|
||
});
|
||
delete __classPrivateFieldGet(this, _YargsInstance_usage, "f").getDescriptions()[optionKey];
|
||
}
|
||
[kEmitWarning](warning, type, deduplicationId) {
|
||
if (!__classPrivateFieldGet(this, _YargsInstance_emittedWarnings, "f")[deduplicationId]) {
|
||
__classPrivateFieldGet(this, _YargsInstance_shim, "f").process.emitWarning(warning, type);
|
||
__classPrivateFieldGet(this, _YargsInstance_emittedWarnings, "f")[deduplicationId] = true;
|
||
}
|
||
}
|
||
[kFreeze]() {
|
||
__classPrivateFieldGet(this, _YargsInstance_frozens, "f").push({
|
||
options: __classPrivateFieldGet(this, _YargsInstance_options, "f"),
|
||
configObjects: __classPrivateFieldGet(this, _YargsInstance_options, "f").configObjects.slice(0),
|
||
exitProcess: __classPrivateFieldGet(this, _YargsInstance_exitProcess, "f"),
|
||
groups: __classPrivateFieldGet(this, _YargsInstance_groups, "f"),
|
||
strict: __classPrivateFieldGet(this, _YargsInstance_strict, "f"),
|
||
strictCommands: __classPrivateFieldGet(this, _YargsInstance_strictCommands, "f"),
|
||
strictOptions: __classPrivateFieldGet(this, _YargsInstance_strictOptions, "f"),
|
||
completionCommand: __classPrivateFieldGet(this, _YargsInstance_completionCommand, "f"),
|
||
output: __classPrivateFieldGet(this, _YargsInstance_output, "f"),
|
||
exitError: __classPrivateFieldGet(this, _YargsInstance_exitError, "f"),
|
||
hasOutput: __classPrivateFieldGet(this, _YargsInstance_hasOutput, "f"),
|
||
parsed: this.parsed,
|
||
parseFn: __classPrivateFieldGet(this, _YargsInstance_parseFn, "f"),
|
||
parseContext: __classPrivateFieldGet(this, _YargsInstance_parseContext, "f")
|
||
});
|
||
__classPrivateFieldGet(this, _YargsInstance_usage, "f").freeze();
|
||
__classPrivateFieldGet(this, _YargsInstance_validation, "f").freeze();
|
||
__classPrivateFieldGet(this, _YargsInstance_command, "f").freeze();
|
||
__classPrivateFieldGet(this, _YargsInstance_globalMiddleware, "f").freeze();
|
||
}
|
||
[kGetDollarZero]() {
|
||
let $0 = "";
|
||
let default$0;
|
||
if (/\b(node|iojs|electron)(\.exe)?$/.test(__classPrivateFieldGet(this, _YargsInstance_shim, "f").process.argv()[0])) {
|
||
default$0 = __classPrivateFieldGet(this, _YargsInstance_shim, "f").process.argv().slice(1, 2);
|
||
} else {
|
||
default$0 = __classPrivateFieldGet(this, _YargsInstance_shim, "f").process.argv().slice(0, 1);
|
||
}
|
||
$0 = default$0.map((x) => {
|
||
const b = this[kRebase](__classPrivateFieldGet(this, _YargsInstance_cwd, "f"), x);
|
||
return x.match(/^(\/|([a-zA-Z]:)?\\)/) && b.length < x.length ? b : x;
|
||
}).join(" ").trim();
|
||
if (__classPrivateFieldGet(this, _YargsInstance_shim, "f").getEnv("_") && __classPrivateFieldGet(this, _YargsInstance_shim, "f").getProcessArgvBin() === __classPrivateFieldGet(this, _YargsInstance_shim, "f").getEnv("_")) {
|
||
$0 = __classPrivateFieldGet(this, _YargsInstance_shim, "f").getEnv("_").replace(`${__classPrivateFieldGet(this, _YargsInstance_shim, "f").path.dirname(__classPrivateFieldGet(this, _YargsInstance_shim, "f").process.execPath())}/`, "");
|
||
}
|
||
return $0;
|
||
}
|
||
[kGetParserConfiguration]() {
|
||
return __classPrivateFieldGet(this, _YargsInstance_parserConfig, "f");
|
||
}
|
||
[kGuessLocale]() {
|
||
if (!__classPrivateFieldGet(this, _YargsInstance_detectLocale, "f"))
|
||
return;
|
||
const locale = __classPrivateFieldGet(this, _YargsInstance_shim, "f").getEnv("LC_ALL") || __classPrivateFieldGet(this, _YargsInstance_shim, "f").getEnv("LC_MESSAGES") || __classPrivateFieldGet(this, _YargsInstance_shim, "f").getEnv("LANG") || __classPrivateFieldGet(this, _YargsInstance_shim, "f").getEnv("LANGUAGE") || "en_US";
|
||
this.locale(locale.replace(/[.:].*/, ""));
|
||
}
|
||
[kGuessVersion]() {
|
||
const obj = this[kPkgUp]();
|
||
return obj.version || "unknown";
|
||
}
|
||
[kParsePositionalNumbers](argv) {
|
||
const args = argv["--"] ? argv["--"] : argv._;
|
||
for (let i = 0, arg; (arg = args[i]) !== void 0; i++) {
|
||
if (__classPrivateFieldGet(this, _YargsInstance_shim, "f").Parser.looksLikeNumber(arg) && Number.isSafeInteger(Math.floor(parseFloat(`${arg}`)))) {
|
||
args[i] = Number(arg);
|
||
}
|
||
}
|
||
return argv;
|
||
}
|
||
[kPkgUp](rootPath) {
|
||
const npath = rootPath || "*";
|
||
if (__classPrivateFieldGet(this, _YargsInstance_pkgs, "f")[npath])
|
||
return __classPrivateFieldGet(this, _YargsInstance_pkgs, "f")[npath];
|
||
let obj = {};
|
||
try {
|
||
let startDir = rootPath || __classPrivateFieldGet(this, _YargsInstance_shim, "f").mainFilename;
|
||
if (!rootPath && __classPrivateFieldGet(this, _YargsInstance_shim, "f").path.extname(startDir)) {
|
||
startDir = __classPrivateFieldGet(this, _YargsInstance_shim, "f").path.dirname(startDir);
|
||
}
|
||
const pkgJsonPath = __classPrivateFieldGet(this, _YargsInstance_shim, "f").findUp(startDir, (dir, names) => {
|
||
if (names.includes("package.json")) {
|
||
return "package.json";
|
||
} else {
|
||
return void 0;
|
||
}
|
||
});
|
||
assertNotStrictEqual(pkgJsonPath, void 0, __classPrivateFieldGet(this, _YargsInstance_shim, "f"));
|
||
obj = JSON.parse(__classPrivateFieldGet(this, _YargsInstance_shim, "f").readFileSync(pkgJsonPath, "utf8"));
|
||
} catch (_noop) {
|
||
}
|
||
__classPrivateFieldGet(this, _YargsInstance_pkgs, "f")[npath] = obj || {};
|
||
return __classPrivateFieldGet(this, _YargsInstance_pkgs, "f")[npath];
|
||
}
|
||
[kPopulateParserHintArray](type, keys) {
|
||
keys = [].concat(keys);
|
||
keys.forEach((key) => {
|
||
key = this[kSanitizeKey](key);
|
||
__classPrivateFieldGet(this, _YargsInstance_options, "f")[type].push(key);
|
||
});
|
||
}
|
||
[kPopulateParserHintSingleValueDictionary](builder, type, key, value) {
|
||
this[kPopulateParserHintDictionary](builder, type, key, value, (type2, key2, value2) => {
|
||
__classPrivateFieldGet(this, _YargsInstance_options, "f")[type2][key2] = value2;
|
||
});
|
||
}
|
||
[kPopulateParserHintArrayDictionary](builder, type, key, value) {
|
||
this[kPopulateParserHintDictionary](builder, type, key, value, (type2, key2, value2) => {
|
||
__classPrivateFieldGet(this, _YargsInstance_options, "f")[type2][key2] = (__classPrivateFieldGet(this, _YargsInstance_options, "f")[type2][key2] || []).concat(value2);
|
||
});
|
||
}
|
||
[kPopulateParserHintDictionary](builder, type, key, value, singleKeyHandler) {
|
||
if (Array.isArray(key)) {
|
||
key.forEach((k) => {
|
||
builder(k, value);
|
||
});
|
||
} else if (((key2) => typeof key2 === "object")(key)) {
|
||
for (const k of objectKeys(key)) {
|
||
builder(k, key[k]);
|
||
}
|
||
} else {
|
||
singleKeyHandler(type, this[kSanitizeKey](key), value);
|
||
}
|
||
}
|
||
[kSanitizeKey](key) {
|
||
if (key === "__proto__")
|
||
return "___proto___";
|
||
return key;
|
||
}
|
||
[kSetKey](key, set) {
|
||
this[kPopulateParserHintSingleValueDictionary](this[kSetKey].bind(this), "key", key, set);
|
||
return this;
|
||
}
|
||
[kUnfreeze]() {
|
||
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m;
|
||
const frozen = __classPrivateFieldGet(this, _YargsInstance_frozens, "f").pop();
|
||
assertNotStrictEqual(frozen, void 0, __classPrivateFieldGet(this, _YargsInstance_shim, "f"));
|
||
let configObjects;
|
||
_a = this, _b = this, _c = this, _d = this, _e = this, _f = this, _g = this, _h = this, _j = this, _k = this, _l = this, _m = this, {
|
||
options: { set value(_o) {
|
||
__classPrivateFieldSet(_a, _YargsInstance_options, _o, "f");
|
||
} }.value,
|
||
configObjects,
|
||
exitProcess: { set value(_o) {
|
||
__classPrivateFieldSet(_b, _YargsInstance_exitProcess, _o, "f");
|
||
} }.value,
|
||
groups: { set value(_o) {
|
||
__classPrivateFieldSet(_c, _YargsInstance_groups, _o, "f");
|
||
} }.value,
|
||
output: { set value(_o) {
|
||
__classPrivateFieldSet(_d, _YargsInstance_output, _o, "f");
|
||
} }.value,
|
||
exitError: { set value(_o) {
|
||
__classPrivateFieldSet(_e, _YargsInstance_exitError, _o, "f");
|
||
} }.value,
|
||
hasOutput: { set value(_o) {
|
||
__classPrivateFieldSet(_f, _YargsInstance_hasOutput, _o, "f");
|
||
} }.value,
|
||
parsed: this.parsed,
|
||
strict: { set value(_o) {
|
||
__classPrivateFieldSet(_g, _YargsInstance_strict, _o, "f");
|
||
} }.value,
|
||
strictCommands: { set value(_o) {
|
||
__classPrivateFieldSet(_h, _YargsInstance_strictCommands, _o, "f");
|
||
} }.value,
|
||
strictOptions: { set value(_o) {
|
||
__classPrivateFieldSet(_j, _YargsInstance_strictOptions, _o, "f");
|
||
} }.value,
|
||
completionCommand: { set value(_o) {
|
||
__classPrivateFieldSet(_k, _YargsInstance_completionCommand, _o, "f");
|
||
} }.value,
|
||
parseFn: { set value(_o) {
|
||
__classPrivateFieldSet(_l, _YargsInstance_parseFn, _o, "f");
|
||
} }.value,
|
||
parseContext: { set value(_o) {
|
||
__classPrivateFieldSet(_m, _YargsInstance_parseContext, _o, "f");
|
||
} }.value
|
||
} = frozen;
|
||
__classPrivateFieldGet(this, _YargsInstance_options, "f").configObjects = configObjects;
|
||
__classPrivateFieldGet(this, _YargsInstance_usage, "f").unfreeze();
|
||
__classPrivateFieldGet(this, _YargsInstance_validation, "f").unfreeze();
|
||
__classPrivateFieldGet(this, _YargsInstance_command, "f").unfreeze();
|
||
__classPrivateFieldGet(this, _YargsInstance_globalMiddleware, "f").unfreeze();
|
||
}
|
||
[kValidateAsync](validation2, argv) {
|
||
return maybeAsyncResult(argv, (result) => {
|
||
validation2(result);
|
||
return result;
|
||
});
|
||
}
|
||
getInternalMethods() {
|
||
return {
|
||
getCommandInstance: this[kGetCommandInstance].bind(this),
|
||
getContext: this[kGetContext].bind(this),
|
||
getHasOutput: this[kGetHasOutput].bind(this),
|
||
getLoggerInstance: this[kGetLoggerInstance].bind(this),
|
||
getParseContext: this[kGetParseContext].bind(this),
|
||
getParserConfiguration: this[kGetParserConfiguration].bind(this),
|
||
getUsageInstance: this[kGetUsageInstance].bind(this),
|
||
getValidationInstance: this[kGetValidationInstance].bind(this),
|
||
hasParseCallback: this[kHasParseCallback].bind(this),
|
||
postProcess: this[kPostProcess].bind(this),
|
||
reset: this[kReset].bind(this),
|
||
runValidation: this[kRunValidation].bind(this),
|
||
runYargsParserAndExecuteCommands: this[kRunYargsParserAndExecuteCommands].bind(this),
|
||
setHasOutput: this[kSetHasOutput].bind(this)
|
||
};
|
||
}
|
||
[kGetCommandInstance]() {
|
||
return __classPrivateFieldGet(this, _YargsInstance_command, "f");
|
||
}
|
||
[kGetContext]() {
|
||
return __classPrivateFieldGet(this, _YargsInstance_context, "f");
|
||
}
|
||
[kGetHasOutput]() {
|
||
return __classPrivateFieldGet(this, _YargsInstance_hasOutput, "f");
|
||
}
|
||
[kGetLoggerInstance]() {
|
||
return __classPrivateFieldGet(this, _YargsInstance_logger, "f");
|
||
}
|
||
[kGetParseContext]() {
|
||
return __classPrivateFieldGet(this, _YargsInstance_parseContext, "f") || {};
|
||
}
|
||
[kGetUsageInstance]() {
|
||
return __classPrivateFieldGet(this, _YargsInstance_usage, "f");
|
||
}
|
||
[kGetValidationInstance]() {
|
||
return __classPrivateFieldGet(this, _YargsInstance_validation, "f");
|
||
}
|
||
[kHasParseCallback]() {
|
||
return !!__classPrivateFieldGet(this, _YargsInstance_parseFn, "f");
|
||
}
|
||
[kPostProcess](argv, populateDoubleDash, calledFromCommand, runGlobalMiddleware) {
|
||
if (calledFromCommand)
|
||
return argv;
|
||
if (isPromise(argv))
|
||
return argv;
|
||
if (!populateDoubleDash) {
|
||
argv = this[kCopyDoubleDash](argv);
|
||
}
|
||
const parsePositionalNumbers = this[kGetParserConfiguration]()["parse-positional-numbers"] || this[kGetParserConfiguration]()["parse-positional-numbers"] === void 0;
|
||
if (parsePositionalNumbers) {
|
||
argv = this[kParsePositionalNumbers](argv);
|
||
}
|
||
if (runGlobalMiddleware) {
|
||
argv = applyMiddleware(argv, this, __classPrivateFieldGet(this, _YargsInstance_globalMiddleware, "f").getMiddleware(), false);
|
||
}
|
||
return argv;
|
||
}
|
||
[kReset](aliases = {}) {
|
||
__classPrivateFieldSet(this, _YargsInstance_options, __classPrivateFieldGet(this, _YargsInstance_options, "f") || {}, "f");
|
||
const tmpOptions = {};
|
||
tmpOptions.local = __classPrivateFieldGet(this, _YargsInstance_options, "f").local || [];
|
||
tmpOptions.configObjects = __classPrivateFieldGet(this, _YargsInstance_options, "f").configObjects || [];
|
||
const localLookup = {};
|
||
tmpOptions.local.forEach((l) => {
|
||
localLookup[l] = true;
|
||
(aliases[l] || []).forEach((a) => {
|
||
localLookup[a] = true;
|
||
});
|
||
});
|
||
Object.assign(__classPrivateFieldGet(this, _YargsInstance_preservedGroups, "f"), Object.keys(__classPrivateFieldGet(this, _YargsInstance_groups, "f")).reduce((acc, groupName) => {
|
||
const keys = __classPrivateFieldGet(this, _YargsInstance_groups, "f")[groupName].filter((key) => !(key in localLookup));
|
||
if (keys.length > 0) {
|
||
acc[groupName] = keys;
|
||
}
|
||
return acc;
|
||
}, {}));
|
||
__classPrivateFieldSet(this, _YargsInstance_groups, {}, "f");
|
||
const arrayOptions = [
|
||
"array",
|
||
"boolean",
|
||
"string",
|
||
"skipValidation",
|
||
"count",
|
||
"normalize",
|
||
"number",
|
||
"hiddenOptions"
|
||
];
|
||
const objectOptions = [
|
||
"narg",
|
||
"key",
|
||
"alias",
|
||
"default",
|
||
"defaultDescription",
|
||
"config",
|
||
"choices",
|
||
"demandedOptions",
|
||
"demandedCommands",
|
||
"deprecatedOptions"
|
||
];
|
||
arrayOptions.forEach((k) => {
|
||
tmpOptions[k] = (__classPrivateFieldGet(this, _YargsInstance_options, "f")[k] || []).filter((k2) => !localLookup[k2]);
|
||
});
|
||
objectOptions.forEach((k) => {
|
||
tmpOptions[k] = objFilter(__classPrivateFieldGet(this, _YargsInstance_options, "f")[k], (k2) => !localLookup[k2]);
|
||
});
|
||
tmpOptions.envPrefix = __classPrivateFieldGet(this, _YargsInstance_options, "f").envPrefix;
|
||
__classPrivateFieldSet(this, _YargsInstance_options, tmpOptions, "f");
|
||
__classPrivateFieldSet(this, _YargsInstance_usage, __classPrivateFieldGet(this, _YargsInstance_usage, "f") ? __classPrivateFieldGet(this, _YargsInstance_usage, "f").reset(localLookup) : usage(this, __classPrivateFieldGet(this, _YargsInstance_shim, "f")), "f");
|
||
__classPrivateFieldSet(this, _YargsInstance_validation, __classPrivateFieldGet(this, _YargsInstance_validation, "f") ? __classPrivateFieldGet(this, _YargsInstance_validation, "f").reset(localLookup) : validation(this, __classPrivateFieldGet(this, _YargsInstance_usage, "f"), __classPrivateFieldGet(this, _YargsInstance_shim, "f")), "f");
|
||
__classPrivateFieldSet(this, _YargsInstance_command, __classPrivateFieldGet(this, _YargsInstance_command, "f") ? __classPrivateFieldGet(this, _YargsInstance_command, "f").reset() : command(__classPrivateFieldGet(this, _YargsInstance_usage, "f"), __classPrivateFieldGet(this, _YargsInstance_validation, "f"), __classPrivateFieldGet(this, _YargsInstance_globalMiddleware, "f"), __classPrivateFieldGet(this, _YargsInstance_shim, "f")), "f");
|
||
if (!__classPrivateFieldGet(this, _YargsInstance_completion, "f"))
|
||
__classPrivateFieldSet(this, _YargsInstance_completion, completion(this, __classPrivateFieldGet(this, _YargsInstance_usage, "f"), __classPrivateFieldGet(this, _YargsInstance_command, "f"), __classPrivateFieldGet(this, _YargsInstance_shim, "f")), "f");
|
||
__classPrivateFieldGet(this, _YargsInstance_globalMiddleware, "f").reset();
|
||
__classPrivateFieldSet(this, _YargsInstance_completionCommand, null, "f");
|
||
__classPrivateFieldSet(this, _YargsInstance_output, "", "f");
|
||
__classPrivateFieldSet(this, _YargsInstance_exitError, null, "f");
|
||
__classPrivateFieldSet(this, _YargsInstance_hasOutput, false, "f");
|
||
this.parsed = false;
|
||
return this;
|
||
}
|
||
[kRebase](base, dir) {
|
||
return __classPrivateFieldGet(this, _YargsInstance_shim, "f").path.relative(base, dir);
|
||
}
|
||
[kRunYargsParserAndExecuteCommands](args, shortCircuit, calledFromCommand, commandIndex = 0, helpOnly = false) {
|
||
let skipValidation = !!calledFromCommand || helpOnly;
|
||
args = args || __classPrivateFieldGet(this, _YargsInstance_processArgs, "f");
|
||
__classPrivateFieldGet(this, _YargsInstance_options, "f").__ = __classPrivateFieldGet(this, _YargsInstance_shim, "f").y18n.__;
|
||
__classPrivateFieldGet(this, _YargsInstance_options, "f").configuration = this[kGetParserConfiguration]();
|
||
const populateDoubleDash = !!__classPrivateFieldGet(this, _YargsInstance_options, "f").configuration["populate--"];
|
||
const config = Object.assign({}, __classPrivateFieldGet(this, _YargsInstance_options, "f").configuration, {
|
||
"populate--": true
|
||
});
|
||
const parsed = __classPrivateFieldGet(this, _YargsInstance_shim, "f").Parser.detailed(args, Object.assign({}, __classPrivateFieldGet(this, _YargsInstance_options, "f"), {
|
||
configuration: __spreadValues({ "parse-positional-numbers": false }, config)
|
||
}));
|
||
const argv = Object.assign(parsed.argv, __classPrivateFieldGet(this, _YargsInstance_parseContext, "f"));
|
||
let argvPromise = void 0;
|
||
const aliases = parsed.aliases;
|
||
let helpOptSet = false;
|
||
let versionOptSet = false;
|
||
Object.keys(argv).forEach((key) => {
|
||
if (key === __classPrivateFieldGet(this, _YargsInstance_helpOpt, "f") && argv[key]) {
|
||
helpOptSet = true;
|
||
} else if (key === __classPrivateFieldGet(this, _YargsInstance_versionOpt, "f") && argv[key]) {
|
||
versionOptSet = true;
|
||
}
|
||
});
|
||
argv.$0 = this.$0;
|
||
this.parsed = parsed;
|
||
if (commandIndex === 0) {
|
||
__classPrivateFieldGet(this, _YargsInstance_usage, "f").clearCachedHelpMessage();
|
||
}
|
||
try {
|
||
this[kGuessLocale]();
|
||
if (shortCircuit) {
|
||
return this[kPostProcess](argv, populateDoubleDash, !!calledFromCommand, false);
|
||
}
|
||
if (__classPrivateFieldGet(this, _YargsInstance_helpOpt, "f")) {
|
||
const helpCmds = [__classPrivateFieldGet(this, _YargsInstance_helpOpt, "f")].concat(aliases[__classPrivateFieldGet(this, _YargsInstance_helpOpt, "f")] || []).filter((k) => k.length > 1);
|
||
if (helpCmds.includes("" + argv._[argv._.length - 1])) {
|
||
argv._.pop();
|
||
helpOptSet = true;
|
||
}
|
||
}
|
||
const handlerKeys = __classPrivateFieldGet(this, _YargsInstance_command, "f").getCommands();
|
||
const requestCompletions = __classPrivateFieldGet(this, _YargsInstance_completion, "f").completionKey in argv;
|
||
const skipRecommendation = helpOptSet || requestCompletions || helpOnly;
|
||
if (argv._.length) {
|
||
if (handlerKeys.length) {
|
||
let firstUnknownCommand;
|
||
for (let i = commandIndex || 0, cmd; argv._[i] !== void 0; i++) {
|
||
cmd = String(argv._[i]);
|
||
if (handlerKeys.includes(cmd) && cmd !== __classPrivateFieldGet(this, _YargsInstance_completionCommand, "f")) {
|
||
const innerArgv = __classPrivateFieldGet(this, _YargsInstance_command, "f").runCommand(cmd, this, parsed, i + 1, helpOnly, helpOptSet || versionOptSet || helpOnly);
|
||
return this[kPostProcess](innerArgv, populateDoubleDash, !!calledFromCommand, false);
|
||
} else if (!firstUnknownCommand && cmd !== __classPrivateFieldGet(this, _YargsInstance_completionCommand, "f")) {
|
||
firstUnknownCommand = cmd;
|
||
break;
|
||
}
|
||
}
|
||
if (!__classPrivateFieldGet(this, _YargsInstance_command, "f").hasDefaultCommand() && __classPrivateFieldGet(this, _YargsInstance_recommendCommands, "f") && firstUnknownCommand && !skipRecommendation) {
|
||
__classPrivateFieldGet(this, _YargsInstance_validation, "f").recommendCommands(firstUnknownCommand, handlerKeys);
|
||
}
|
||
}
|
||
if (__classPrivateFieldGet(this, _YargsInstance_completionCommand, "f") && argv._.includes(__classPrivateFieldGet(this, _YargsInstance_completionCommand, "f")) && !requestCompletions) {
|
||
if (__classPrivateFieldGet(this, _YargsInstance_exitProcess, "f"))
|
||
setBlocking(true);
|
||
this.showCompletionScript();
|
||
this.exit(0);
|
||
}
|
||
}
|
||
if (__classPrivateFieldGet(this, _YargsInstance_command, "f").hasDefaultCommand() && !skipRecommendation) {
|
||
const innerArgv = __classPrivateFieldGet(this, _YargsInstance_command, "f").runCommand(null, this, parsed, 0, helpOnly, helpOptSet || versionOptSet || helpOnly);
|
||
return this[kPostProcess](innerArgv, populateDoubleDash, !!calledFromCommand, false);
|
||
}
|
||
if (requestCompletions) {
|
||
if (__classPrivateFieldGet(this, _YargsInstance_exitProcess, "f"))
|
||
setBlocking(true);
|
||
args = [].concat(args);
|
||
const completionArgs = args.slice(args.indexOf(`--${__classPrivateFieldGet(this, _YargsInstance_completion, "f").completionKey}`) + 1);
|
||
__classPrivateFieldGet(this, _YargsInstance_completion, "f").getCompletion(completionArgs, (err, completions) => {
|
||
if (err)
|
||
throw new YError(err.message);
|
||
(completions || []).forEach((completion2) => {
|
||
__classPrivateFieldGet(this, _YargsInstance_logger, "f").log(completion2);
|
||
});
|
||
this.exit(0);
|
||
});
|
||
return this[kPostProcess](argv, !populateDoubleDash, !!calledFromCommand, false);
|
||
}
|
||
if (!__classPrivateFieldGet(this, _YargsInstance_hasOutput, "f")) {
|
||
if (helpOptSet) {
|
||
if (__classPrivateFieldGet(this, _YargsInstance_exitProcess, "f"))
|
||
setBlocking(true);
|
||
skipValidation = true;
|
||
this.showHelp("log");
|
||
this.exit(0);
|
||
} else if (versionOptSet) {
|
||
if (__classPrivateFieldGet(this, _YargsInstance_exitProcess, "f"))
|
||
setBlocking(true);
|
||
skipValidation = true;
|
||
__classPrivateFieldGet(this, _YargsInstance_usage, "f").showVersion("log");
|
||
this.exit(0);
|
||
}
|
||
}
|
||
if (!skipValidation && __classPrivateFieldGet(this, _YargsInstance_options, "f").skipValidation.length > 0) {
|
||
skipValidation = Object.keys(argv).some((key) => __classPrivateFieldGet(this, _YargsInstance_options, "f").skipValidation.indexOf(key) >= 0 && argv[key] === true);
|
||
}
|
||
if (!skipValidation) {
|
||
if (parsed.error)
|
||
throw new YError(parsed.error.message);
|
||
if (!requestCompletions) {
|
||
const validation2 = this[kRunValidation](aliases, {}, parsed.error);
|
||
if (!calledFromCommand) {
|
||
argvPromise = applyMiddleware(argv, this, __classPrivateFieldGet(this, _YargsInstance_globalMiddleware, "f").getMiddleware(), true);
|
||
}
|
||
argvPromise = this[kValidateAsync](validation2, argvPromise !== null && argvPromise !== void 0 ? argvPromise : argv);
|
||
if (isPromise(argvPromise) && !calledFromCommand) {
|
||
argvPromise = argvPromise.then(() => {
|
||
return applyMiddleware(argv, this, __classPrivateFieldGet(this, _YargsInstance_globalMiddleware, "f").getMiddleware(), false);
|
||
});
|
||
}
|
||
}
|
||
}
|
||
} catch (err) {
|
||
if (err instanceof YError)
|
||
__classPrivateFieldGet(this, _YargsInstance_usage, "f").fail(err.message, err);
|
||
else
|
||
throw err;
|
||
}
|
||
return this[kPostProcess](argvPromise !== null && argvPromise !== void 0 ? argvPromise : argv, populateDoubleDash, !!calledFromCommand, true);
|
||
}
|
||
[kRunValidation](aliases, positionalMap, parseErrors, isDefaultCommand) {
|
||
const demandedOptions = __spreadValues({}, this.getDemandedOptions());
|
||
return (argv) => {
|
||
if (parseErrors)
|
||
throw new YError(parseErrors.message);
|
||
__classPrivateFieldGet(this, _YargsInstance_validation, "f").nonOptionCount(argv);
|
||
__classPrivateFieldGet(this, _YargsInstance_validation, "f").requiredArguments(argv, demandedOptions);
|
||
let failedStrictCommands = false;
|
||
if (__classPrivateFieldGet(this, _YargsInstance_strictCommands, "f")) {
|
||
failedStrictCommands = __classPrivateFieldGet(this, _YargsInstance_validation, "f").unknownCommands(argv);
|
||
}
|
||
if (__classPrivateFieldGet(this, _YargsInstance_strict, "f") && !failedStrictCommands) {
|
||
__classPrivateFieldGet(this, _YargsInstance_validation, "f").unknownArguments(argv, aliases, positionalMap, !!isDefaultCommand);
|
||
} else if (__classPrivateFieldGet(this, _YargsInstance_strictOptions, "f")) {
|
||
__classPrivateFieldGet(this, _YargsInstance_validation, "f").unknownArguments(argv, aliases, {}, false, false);
|
||
}
|
||
__classPrivateFieldGet(this, _YargsInstance_validation, "f").limitedChoices(argv);
|
||
__classPrivateFieldGet(this, _YargsInstance_validation, "f").implications(argv);
|
||
__classPrivateFieldGet(this, _YargsInstance_validation, "f").conflicting(argv);
|
||
};
|
||
}
|
||
[kSetHasOutput]() {
|
||
__classPrivateFieldSet(this, _YargsInstance_hasOutput, true, "f");
|
||
}
|
||
[kTrackManuallySetKeys](keys) {
|
||
if (typeof keys === "string") {
|
||
__classPrivateFieldGet(this, _YargsInstance_options, "f").key[keys] = true;
|
||
} else {
|
||
for (const k of keys) {
|
||
__classPrivateFieldGet(this, _YargsInstance_options, "f").key[k] = true;
|
||
}
|
||
}
|
||
}
|
||
};
|
||
function isYargsInstance(y) {
|
||
return !!y && typeof y.getInternalMethods === "function";
|
||
}
|
||
|
||
// node_modules/yargs/index.mjs
|
||
var Yargs = YargsFactory(esm_default);
|
||
var yargs_default = Yargs;
|
||
|
||
// src/process.ts
|
||
var import_debug2 = __toESM(require_src());
|
||
var FS2 = __toESM(require("fs"));
|
||
var import_chalk = __toESM(require_source());
|
||
var Path2 = __toESM(require("path"));
|
||
|
||
// src/tokenizer.ts
|
||
var TokenizerError = class extends Error {
|
||
index;
|
||
constructor(message, index) {
|
||
super(message);
|
||
this.index = index;
|
||
}
|
||
};
|
||
function regexMatcher(regex, type) {
|
||
if (typeof regex === "string")
|
||
regex = new RegExp(regex);
|
||
return (input, index) => {
|
||
let matches = input.substring(index).match(regex);
|
||
if (!matches || matches.length <= 0)
|
||
return void 0;
|
||
return {
|
||
type,
|
||
value: matches[0],
|
||
startIdx: index,
|
||
endIdx: index + matches[0].length
|
||
};
|
||
};
|
||
}
|
||
var matcher = [
|
||
regexMatcher(/^\s+/, "space"),
|
||
regexMatcher(/^(\/\*)(.|\s)*?(\*\/)/g, "comment"),
|
||
regexMatcher(/^\/\/.+/, "comment"),
|
||
regexMatcher(/^#.+/, "comment"),
|
||
regexMatcher(/^".*?"/, "string"),
|
||
regexMatcher(/^(type|enum|import|service|define)\b/, "keyword"),
|
||
regexMatcher(/^\@/, "at"),
|
||
regexMatcher(/^\:/, "colon"),
|
||
regexMatcher(/^\;/, "semicolon"),
|
||
regexMatcher(/^\,/, "comma"),
|
||
regexMatcher(/^\=/, "equals"),
|
||
regexMatcher(/^{/, "curly_open"),
|
||
regexMatcher(/^}/, "curly_close"),
|
||
regexMatcher(/^\(/, "bracket_open"),
|
||
regexMatcher(/^\)/, "bracket_close"),
|
||
regexMatcher(/^\[\]/, "array"),
|
||
regexMatcher(/^\?/, "questionmark"),
|
||
regexMatcher(/^[\.0-9]+/, "number"),
|
||
regexMatcher(/^[a-zA-Z_]([a-zA-Z0-9_]?)+/, "text")
|
||
];
|
||
function tokenize(input) {
|
||
let index = 0;
|
||
let tokens = [];
|
||
while (index < input.length) {
|
||
const matches = matcher.map((m) => m(input, index)).filter((e) => !!e);
|
||
let match = matches[0];
|
||
if (match) {
|
||
if (match.type !== "space" && match.type !== "comment") {
|
||
tokens.push(match);
|
||
}
|
||
index += match.value.length;
|
||
} else {
|
||
throw new TokenizerError(`Unexpected token '${input.substring(index, index + 1)}'`, index);
|
||
}
|
||
}
|
||
return tokens;
|
||
}
|
||
|
||
// src/parser.ts
|
||
var ParserError = class extends Error {
|
||
token;
|
||
constructor(message, token) {
|
||
super(message);
|
||
this.token = token;
|
||
}
|
||
};
|
||
function parse(tokens, file) {
|
||
const tokenIterator = tokens[Symbol.iterator]();
|
||
let currentToken = tokenIterator.next().value;
|
||
let nextToken = tokenIterator.next().value;
|
||
const eatToken = (value) => {
|
||
if (value && value !== currentToken.value) {
|
||
throw new ParserError(`Unexpected token value, expected '${value}', received '${currentToken.value}'`, currentToken);
|
||
}
|
||
let idx = currentToken.startIdx;
|
||
currentToken = nextToken;
|
||
nextToken = tokenIterator.next().value;
|
||
return idx;
|
||
};
|
||
const eatText = () => {
|
||
checkTypes("text");
|
||
let val = currentToken.value;
|
||
let idx = currentToken.startIdx;
|
||
eatToken();
|
||
return [val, idx];
|
||
};
|
||
const eatNumber = () => {
|
||
checkTypes("number");
|
||
let val = Number(currentToken.value);
|
||
if (Number.isNaN(val)) {
|
||
throw new ParserError(`Value cannot be parsed as number! ${currentToken.value}`, currentToken);
|
||
}
|
||
eatToken();
|
||
return val;
|
||
};
|
||
const checkTypes = (...types) => {
|
||
if (types.indexOf(currentToken.type) < 0) {
|
||
throw new ParserError(`Unexpected token value, expected ${types.join(" | ")}, received '${currentToken.value}'`, currentToken);
|
||
}
|
||
};
|
||
const parseTypeField = () => {
|
||
const idx = currentToken.startIdx;
|
||
let name = currentToken.value;
|
||
eatToken();
|
||
eatToken(":");
|
||
let array = false;
|
||
let type;
|
||
let mapKey = void 0;
|
||
if (currentToken.type === "curly_open") {
|
||
eatToken("{");
|
||
[mapKey] = eatText();
|
||
eatToken(",");
|
||
[type] = eatText();
|
||
eatToken("}");
|
||
} else {
|
||
[type] = eatText();
|
||
if (currentToken.type === "array") {
|
||
array = true;
|
||
eatToken("[]");
|
||
}
|
||
}
|
||
eatToken(";");
|
||
return {
|
||
type: "type_field",
|
||
name,
|
||
fieldtype: type,
|
||
array,
|
||
map: mapKey,
|
||
location: { file, idx }
|
||
};
|
||
};
|
||
const parseTypeStatement = () => {
|
||
const idx = eatToken("type");
|
||
let [name] = eatText();
|
||
eatToken("{");
|
||
let fields = [];
|
||
while (currentToken.type === "text" || currentToken.type === "keyword") {
|
||
fields.push(parseTypeField());
|
||
}
|
||
eatToken("}");
|
||
return {
|
||
type: "type",
|
||
name,
|
||
fields,
|
||
location: { file, idx }
|
||
};
|
||
};
|
||
const parseImportStatement = () => {
|
||
const idx = eatToken("import");
|
||
checkTypes("text", "string");
|
||
let path = currentToken.value;
|
||
if (currentToken.type === "string") {
|
||
path = path.substring(1, path.length - 1);
|
||
}
|
||
eatToken();
|
||
eatToken(";");
|
||
return {
|
||
type: "import",
|
||
path,
|
||
location: { file, idx }
|
||
};
|
||
};
|
||
const parseEnumValue = () => {
|
||
let [name, idx] = eatText();
|
||
let value = void 0;
|
||
if (currentToken.type === "equals") {
|
||
eatToken("=");
|
||
value = eatNumber();
|
||
}
|
||
return {
|
||
type: "enum_value",
|
||
name,
|
||
value,
|
||
location: { file, idx }
|
||
};
|
||
};
|
||
const parseEnumStatement = () => {
|
||
let idx = eatToken("enum");
|
||
let [name] = eatText();
|
||
eatToken("{");
|
||
let values = [];
|
||
let next = currentToken.type === "text";
|
||
while (next) {
|
||
values.push(parseEnumValue());
|
||
if (currentToken.type === "comma") {
|
||
eatToken(",");
|
||
next = true;
|
||
} else {
|
||
next = false;
|
||
}
|
||
}
|
||
eatToken("}");
|
||
return {
|
||
type: "enum",
|
||
name,
|
||
values,
|
||
location: { file, idx }
|
||
};
|
||
};
|
||
const parseFunctionDecorator = (decorators = /* @__PURE__ */ new Map()) => {
|
||
const idx = eatToken("@");
|
||
const [decorator] = eatText();
|
||
eatToken("(");
|
||
let args = [];
|
||
let first = true;
|
||
while (currentToken.value !== ")") {
|
||
if (first) {
|
||
first = false;
|
||
} else {
|
||
eatToken(",");
|
||
}
|
||
checkTypes("string");
|
||
args.push(currentToken.value.slice(1, -1));
|
||
eatToken();
|
||
}
|
||
eatToken(")");
|
||
let dec = decorators.get(decorator) || [];
|
||
dec.push(args);
|
||
decorators.set(decorator, dec);
|
||
return decorators;
|
||
};
|
||
const parseServiceFunction = (decorators, notification) => {
|
||
const [name, idx] = eatText();
|
||
eatToken("(");
|
||
let input_streaming = void 0;
|
||
let inputs = [];
|
||
if (currentToken.value !== ")") {
|
||
while (true) {
|
||
const [name2] = eatText();
|
||
eatToken(":");
|
||
const [type] = eatText();
|
||
let array = false;
|
||
if (currentToken.type === "array") {
|
||
array = true;
|
||
eatToken("[]");
|
||
}
|
||
inputs.push({ name: name2, type, array });
|
||
if (currentToken.value !== ",")
|
||
break;
|
||
eatToken(",");
|
||
}
|
||
}
|
||
eatToken(")");
|
||
let return_type = void 0;
|
||
if (!notification) {
|
||
eatToken(":");
|
||
let [type] = eatText();
|
||
let array = false;
|
||
if (currentToken.type === "array") {
|
||
array = true;
|
||
eatToken("[]");
|
||
}
|
||
return_type = {
|
||
type,
|
||
array
|
||
};
|
||
}
|
||
eatToken(";");
|
||
return {
|
||
type: "service_function",
|
||
name,
|
||
location: {
|
||
file,
|
||
idx
|
||
},
|
||
inputs,
|
||
return_type,
|
||
decorators
|
||
};
|
||
};
|
||
const parseServiceStatement = () => {
|
||
let idx = eatToken("service");
|
||
let [name] = eatText();
|
||
eatToken("{");
|
||
let functions = [];
|
||
while (currentToken.type !== "curly_close") {
|
||
let decorators = /* @__PURE__ */ new Map();
|
||
while (currentToken.type == "at") {
|
||
parseFunctionDecorator(decorators);
|
||
}
|
||
let notification = false;
|
||
if (currentToken.value == "notification") {
|
||
eatText();
|
||
notification = true;
|
||
}
|
||
functions.push(parseServiceFunction(decorators, notification));
|
||
}
|
||
eatToken("}");
|
||
return {
|
||
type: "service",
|
||
name,
|
||
functions,
|
||
location: { file, idx }
|
||
};
|
||
};
|
||
const parseDefine = () => {
|
||
const idx = eatToken("define");
|
||
let [key] = eatText();
|
||
let value = void 0;
|
||
if (currentToken.type == "string") {
|
||
value = currentToken.value.slice(1, -1);
|
||
eatToken();
|
||
} else {
|
||
[value] = eatText();
|
||
}
|
||
eatToken(";");
|
||
return {
|
||
type: "define",
|
||
location: { file, idx },
|
||
key,
|
||
value
|
||
};
|
||
};
|
||
const parseStatement = () => {
|
||
if (currentToken.type === "keyword") {
|
||
switch (currentToken.value) {
|
||
case "type":
|
||
return parseTypeStatement();
|
||
case "import":
|
||
return parseImportStatement();
|
||
case "enum":
|
||
return parseEnumStatement();
|
||
case "service":
|
||
return parseServiceStatement();
|
||
case "define":
|
||
return parseDefine();
|
||
default:
|
||
throw new ParserError(`Unknown keyword ${currentToken.value}`, currentToken);
|
||
}
|
||
} else {
|
||
throw new ParserError(`Invalid statement! ${currentToken.value}`, currentToken);
|
||
}
|
||
};
|
||
const nodes = [];
|
||
while (currentToken) {
|
||
nodes.push(parseStatement());
|
||
}
|
||
return nodes;
|
||
}
|
||
|
||
// src/ir.ts
|
||
var import_debug = __toESM(require_src());
|
||
var log = (0, import_debug.default)("app");
|
||
var BUILTIN = ["float", "int", "string", "boolean"];
|
||
var IRError = class extends Error {
|
||
constructor(statement, message) {
|
||
super("Error building IR: " + message);
|
||
this.statement = statement;
|
||
}
|
||
};
|
||
function get_ir(parsed) {
|
||
log("Generatie IR from parse output");
|
||
let builtin = [...BUILTIN];
|
||
let defined = [];
|
||
let types = [];
|
||
let enums = [];
|
||
let steps = [];
|
||
let options = {};
|
||
parsed.forEach((statement) => {
|
||
log("Working on statement of type %s", statement.type);
|
||
if (statement.type == "import")
|
||
throw new IRError(statement, "Import statements are invalid at this step!");
|
||
if (statement.type === "type") {
|
||
if (defined.indexOf(statement.name) >= 0) {
|
||
throw new IRError(statement, `Type ${statement.name} already defined!`);
|
||
}
|
||
let depends = [];
|
||
const fields = statement.fields.map((field) => {
|
||
if (field.type !== "type_field") {
|
||
throw new IRError(field, "Invalid statement!");
|
||
}
|
||
if (defined.indexOf(field.fieldtype) < 0) {
|
||
if (builtin.indexOf(field.fieldtype) < 0 && field.fieldtype !== statement.name) {
|
||
throw new IRError(field, `Type ${field.fieldtype} is not defined!`);
|
||
}
|
||
} else {
|
||
if (depends.indexOf(field.fieldtype) < 0)
|
||
depends.push(field.fieldtype);
|
||
}
|
||
if (field.map && field.map !== "int" && field.map !== "string") {
|
||
throw new IRError(field, `Type ${field.map} is not valid as map key!`);
|
||
}
|
||
return {
|
||
name: field.name,
|
||
type: field.fieldtype,
|
||
array: field.array,
|
||
map: field.map
|
||
};
|
||
});
|
||
steps.push([
|
||
statement.type,
|
||
{
|
||
name: statement.name,
|
||
depends,
|
||
fields
|
||
}
|
||
]);
|
||
defined.push(statement.name);
|
||
types.push(statement.name);
|
||
} else if (statement.type === "enum") {
|
||
if (defined.indexOf(statement.name) >= 0) {
|
||
throw new IRError(statement, `Type ${statement.name} already defined!`);
|
||
}
|
||
let last = -1;
|
||
let values = statement.values.map((values2) => {
|
||
let value = last + 1;
|
||
if (values2.value) {
|
||
if (values2.value <= last) {
|
||
throw new IRError(statement, "Enum value must be larger than the previous one!");
|
||
} else {
|
||
value = values2.value;
|
||
}
|
||
}
|
||
last = value;
|
||
return {
|
||
name: values2.name,
|
||
value
|
||
};
|
||
});
|
||
steps.push([
|
||
"enum",
|
||
{
|
||
name: statement.name,
|
||
values
|
||
}
|
||
]);
|
||
defined.push(statement.name);
|
||
enums.push(statement.name);
|
||
} else if (statement.type === "service") {
|
||
if (defined.indexOf(statement.name) >= 0) {
|
||
throw new IRError(statement, `Type ${statement.name} already defined!`);
|
||
}
|
||
let depends = [];
|
||
let alreadyFoundFunctions = /* @__PURE__ */ new Set();
|
||
let functions = statement.functions.map((fnc) => {
|
||
if (alreadyFoundFunctions.has(fnc.name))
|
||
throw new IRError(fnc, `Function with name ${fnc.name} already defined!`);
|
||
alreadyFoundFunctions.add(fnc.name);
|
||
if (fnc.return_type) {
|
||
if (defined.indexOf(fnc.return_type.type) >= 0) {
|
||
if (!depends.some((a) => a === fnc.return_type.type))
|
||
depends.push(fnc.return_type.type);
|
||
} else {
|
||
if (fnc.return_type.type !== "void" && builtin.indexOf(fnc.return_type.type) < 0) {
|
||
throw new IRError(fnc, `Type ${fnc.return_type.type} is not defined`);
|
||
}
|
||
}
|
||
}
|
||
for (const input of fnc.inputs) {
|
||
if (defined.indexOf(input.type) >= 0) {
|
||
if (!depends.some((a) => a === input.type))
|
||
depends.push(input.type);
|
||
} else {
|
||
if (builtin.indexOf(input.type) < 0) {
|
||
throw new IRError(fnc, `Type ${input.type} is not defined`);
|
||
}
|
||
}
|
||
}
|
||
let decorators = {};
|
||
fnc.decorators.forEach((values, key) => {
|
||
for (const val of values) {
|
||
switch (key) {
|
||
case "Description":
|
||
if (decorators.description)
|
||
throw new IRError(fnc, `Decorator 'Description' can only be used once!`);
|
||
if (val.length != 1)
|
||
throw new IRError(fnc, `Decorator 'Description' requires exactly one parameter!`);
|
||
decorators.description = val[0];
|
||
break;
|
||
case "Returns":
|
||
if (decorators.returns)
|
||
throw new IRError(fnc, `Decorator 'Returns' can only be used once!`);
|
||
if (val.length != 1)
|
||
throw new IRError(fnc, `Decorator 'Returns' requires exactly one parameter!`);
|
||
decorators.returns = val[0];
|
||
break;
|
||
case "Param":
|
||
if (!decorators.parameters)
|
||
decorators.parameters = [];
|
||
if (val.length != 2)
|
||
throw new IRError(fnc, `Decorator 'Param' requires exactly two parameters!`);
|
||
const [name, description] = val;
|
||
if (!fnc.inputs.find((e) => e.name == name))
|
||
throw new IRError(fnc, `Decorator 'Param' requires the first param to equal the name of a function parameter!`);
|
||
if (decorators.parameters.find((e) => e.name == name))
|
||
throw new IRError(fnc, `Decorator 'Param' has already been set for the parameter ${name}!`);
|
||
decorators.parameters.push({
|
||
name,
|
||
description
|
||
});
|
||
break;
|
||
default:
|
||
throw new IRError(fnc, `Decorator ${key} is not a valid decorator!`);
|
||
}
|
||
}
|
||
});
|
||
return {
|
||
name: fnc.name,
|
||
inputs: fnc.inputs,
|
||
return: fnc.return_type,
|
||
decorators
|
||
};
|
||
});
|
||
steps.push([
|
||
"service",
|
||
{
|
||
name: statement.name,
|
||
depends,
|
||
functions
|
||
}
|
||
]);
|
||
} else if (statement.type == "define") {
|
||
options[statement.key] = statement.value;
|
||
if ((statement.key == "use_messagepack" || statement.key == "allow_bytes") && statement.value == "true") {
|
||
options["allow_bytes"] = true;
|
||
builtin.push("bytes");
|
||
}
|
||
} else {
|
||
throw new IRError(statement, "Invalid statement!");
|
||
}
|
||
});
|
||
return {
|
||
options,
|
||
steps
|
||
};
|
||
}
|
||
|
||
// src/compile.ts
|
||
var FS = __toESM(require("fs"));
|
||
var FSE = __toESM(require_lib());
|
||
var Path = __toESM(require("path"));
|
||
var CompileTarget = class {
|
||
constructor(outputFolder, options) {
|
||
this.outputFolder = outputFolder;
|
||
this.options = options;
|
||
if (!FS.existsSync(outputFolder)) {
|
||
FS.mkdirSync(outputFolder, {
|
||
recursive: true
|
||
});
|
||
}
|
||
}
|
||
writeFile(name, content) {
|
||
let resPath = Path.join(this.outputFolder, name);
|
||
let resDir = Path.dirname(resPath);
|
||
if (!FS.existsSync(resDir))
|
||
FS.mkdirSync(resDir, { recursive: true });
|
||
if (content instanceof Promise) {
|
||
content.then((res) => FS.writeFileSync(resPath, res));
|
||
} else {
|
||
FS.writeFileSync(resPath, content);
|
||
}
|
||
}
|
||
getTemplate(name) {
|
||
let path = Path.join(__dirname, "../templates/" + name);
|
||
let file = FS.readFileSync(path, "utf-8");
|
||
const splitted = file.split("\n");
|
||
let res = [];
|
||
let ignore = false;
|
||
for (const line of splitted) {
|
||
if (ignore) {
|
||
ignore = false;
|
||
} else if (line.trim().startsWith("//@template-ignore")) {
|
||
ignore = true;
|
||
} else {
|
||
res.push(line);
|
||
}
|
||
}
|
||
return res.join("\n");
|
||
}
|
||
loadTemplateFolder(name) {
|
||
let root = Path.join(__dirname, "../templates/", name);
|
||
FSE.copySync(root, this.outputFolder, {});
|
||
}
|
||
};
|
||
function compile(ir, target) {
|
||
target.start();
|
||
ir.steps.forEach((step) => {
|
||
const [type, def] = step;
|
||
if (type == "type")
|
||
target.generateType(def);
|
||
else if (type == "enum")
|
||
target.generateEnum(def);
|
||
else if (type == "service")
|
||
target.generateService(def);
|
||
});
|
||
if (target.finalize)
|
||
target.finalize(ir.steps);
|
||
}
|
||
|
||
// src/targets/typescript.ts
|
||
var conversion = {
|
||
boolean: "boolean",
|
||
int: "number",
|
||
float: "number",
|
||
string: "string",
|
||
void: "void",
|
||
bytes: "Uint8Array"
|
||
};
|
||
function toJSType(type) {
|
||
return conversion[type] || type;
|
||
}
|
||
var TypescriptTarget = class extends CompileTarget {
|
||
name = "Typescript";
|
||
flavour = "node";
|
||
start() {
|
||
this.writeFormattedFile("ts_base.ts", this.getTemplate("ts_base.ts"));
|
||
}
|
||
generateImport(imports, path) {
|
||
return `import ${imports} from "${path + (this.flavour === "esm" ? ".ts" : "")}";
|
||
`;
|
||
}
|
||
generateImports(a, def) {
|
||
a(0, this.generateImport(`{ VerificationError, apply_int, apply_float, apply_string, apply_boolean, apply_void }`, `./ts_base`));
|
||
a(0, def.depends.map((dep) => this.generateImport(`${dep}, { apply_${dep} }`, "./" + dep)));
|
||
}
|
||
getFileName(typename) {
|
||
return typename + ".ts";
|
||
}
|
||
writeFormattedFile(file, code) {
|
||
this.writeFile(file, code);
|
||
}
|
||
generateType(def) {
|
||
let lines = [];
|
||
const a = (i, t) => {
|
||
if (!Array.isArray(t)) {
|
||
t = [t];
|
||
}
|
||
t.forEach((l) => lines.push(" ".repeat(i) + l.trim()));
|
||
};
|
||
this.generateImports(a, def);
|
||
a(0, `export default class ${def.name} {`);
|
||
a(1, def.fields.map((field) => {
|
||
let type = "";
|
||
if (field.array) {
|
||
type = toJSType(field.type) + "[]";
|
||
} else if (field.map) {
|
||
type = `{ [key: ${toJSType(field.map)}]: ${toJSType(field.type)} }`;
|
||
} else {
|
||
type = toJSType(field.type);
|
||
}
|
||
return `${field.name}?: ${type}; `;
|
||
}));
|
||
a(0, ``);
|
||
a(1, `constructor(init?:Partial<${def.name}>){`);
|
||
a(2, `if(init){`);
|
||
def.fields.forEach((field) => {
|
||
a(3, `if(init["${field.name}"])`);
|
||
a(4, `this.${field.name} = init["${field.name}"];`);
|
||
});
|
||
a(2, `}`);
|
||
a(1, `}`);
|
||
a(0, ``);
|
||
a(0, ``);
|
||
a(1, `static apply(data: ${def.name}) {`);
|
||
a(2, `apply_${def.name}(data);`);
|
||
a(1, `}`);
|
||
a(0, `}`);
|
||
a(0, ``);
|
||
a(0, `export function apply_${def.name}(data: ${def.name}): ${def.name} {`);
|
||
{
|
||
a(1, `if(typeof data !== "object") throw new VerificationError("${def.name}", undefined, data);`);
|
||
a(1, `let res = new ${def.name}() as any;`);
|
||
def.fields.forEach((field) => {
|
||
a(1, `if(data["${field.name}"] !== null && data["${field.name}"] !== undefined) {`);
|
||
if (field.array) {
|
||
a(2, `if(!Array.isArray(data["${field.name}"])) throw new VerificationError("array", "${field.name}", data["${field.name}"]);`);
|
||
a(2, `res["${field.name}"] = data["${field.name}"].map(elm=>`);
|
||
a(3, `apply_${field.type}(elm)`);
|
||
a(2, `)`);
|
||
} else if (field.map) {
|
||
a(2, `if(typeof data["${field.name}"] !== "object") throw new VerificationError("map", "${field.name}", data["${field.name}"]);`);
|
||
a(2, `res["${field.name}"] = {}`);
|
||
a(2, `Object.entries(data["${field.name}"]).forEach(([key, val]) => res["${field.name}"][key] = apply_${field.type}(val))`);
|
||
} else {
|
||
a(2, `res["${field.name}"] = apply_${field.type}(data["${field.name}"])`);
|
||
}
|
||
a(1, `}`);
|
||
});
|
||
a(1, `return res;`);
|
||
}
|
||
a(0, `}`);
|
||
a(0, ``);
|
||
this.writeFormattedFile(this.getFileName(def.name), lines.join("\n"));
|
||
}
|
||
generateEnum(def) {
|
||
let lines = [];
|
||
const a = (i, t) => {
|
||
if (!Array.isArray(t)) {
|
||
t = [t];
|
||
}
|
||
t.forEach((l) => lines.push(" ".repeat(i) + l.trim()));
|
||
};
|
||
a(0, this.generateImport("{ VerificationError }", "./ts_base"));
|
||
a(0, `enum ${def.name} {`);
|
||
for (const value of def.values) {
|
||
a(1, `${value.name}=${value.value},`);
|
||
}
|
||
a(0, `}`);
|
||
a(0, ``);
|
||
a(0, `export default ${def.name}`);
|
||
a(0, ``);
|
||
a(0, `export function apply_${def.name} (data: ${def.name}): ${def.name} {`);
|
||
a(1, `data = Number(data);`);
|
||
a(1, `if(${def.name}[data] == undefined) throw new VerificationError("${def.name}", undefined, data);`);
|
||
a(1, `return data;`);
|
||
a(0, `}`);
|
||
this.writeFormattedFile(this.getFileName(def.name), lines.join("\n"));
|
||
}
|
||
generateServiceClient(def) {
|
||
this.writeFormattedFile("service_client.ts", this.generateImport("{ RequestObject, ResponseObject, ErrorCodes, Logging }", "./service_base") + this.generateImport(" { VerificationError }", "./ts_base") + "\n\n" + this.getTemplate("ts_service_client.ts"));
|
||
let lines = [];
|
||
const a = (i, t) => {
|
||
if (!Array.isArray(t)) {
|
||
t = [t];
|
||
}
|
||
t.forEach((l) => lines.push(" ".repeat(i) + l.trim()));
|
||
};
|
||
this.generateImports(a, def);
|
||
a(0, `export type {`);
|
||
def.depends.forEach((dep) => {
|
||
a(1, `${dep},`);
|
||
});
|
||
a(0, `}`);
|
||
a(0, this.generateImport("{ Service, ServiceProvider, getRandomID }", "./service_client"));
|
||
a(0, ``);
|
||
a(0, `export class ${def.name} extends Service {`);
|
||
a(1, `constructor(provider: ServiceProvider){`);
|
||
a(2, `super(provider, "${def.name}");`);
|
||
a(1, `}`);
|
||
for (const fnc of def.functions) {
|
||
const params = fnc.inputs.map((e) => `${e.name}: ${toJSType(e.type) + (e.array ? "[]" : "")}`).join(", ");
|
||
if (!fnc.return) {
|
||
a(1, `${fnc.name}(${params}): void {`);
|
||
a(2, `this._provider.sendMessage({`);
|
||
a(3, `jsonrpc: "2.0",`);
|
||
a(3, `method: "${def.name}.${fnc.name}",`);
|
||
a(3, `params: [...arguments]`);
|
||
a(2, `});`);
|
||
a(1, `}`);
|
||
} else {
|
||
const retType = fnc.return ? toJSType(fnc.return.type) + (fnc.return.array ? "[]" : "") : "void";
|
||
a(1, `${fnc.name}(${params}): Promise<${retType}> {`);
|
||
a(2, `return new Promise<${retType}>((ok, err) => {`);
|
||
a(3, `this._provider.sendMessage({`);
|
||
a(4, `jsonrpc: "2.0",`);
|
||
a(4, `id: getRandomID(16),`);
|
||
a(4, `method: "${def.name}.${fnc.name}",`);
|
||
a(4, `params: [...arguments]`);
|
||
a(3, `}, {`);
|
||
a(4, `ok, err`);
|
||
a(3, `});`);
|
||
a(2, `}).then(result => {`);
|
||
if (fnc.return.array) {
|
||
a(3, `for(let i = 0; i < result.length; i++) {`);
|
||
a(4, `result[i] = apply_${fnc.return.type}(result[i]);`);
|
||
a(3, `}`);
|
||
} else {
|
||
a(3, `result = apply_${fnc.return.type}(result);`);
|
||
}
|
||
a(3, `return result;`);
|
||
a(2, `});`);
|
||
a(1, `}`);
|
||
}
|
||
a(0, ``);
|
||
}
|
||
a(0, `}`);
|
||
this.writeFormattedFile(this.getFileName(def.name + "_client"), lines.join("\n"));
|
||
}
|
||
generateServiceServer(def) {
|
||
var _a;
|
||
let lines = [];
|
||
const a = (i, t) => {
|
||
if (!Array.isArray(t)) {
|
||
t = [t];
|
||
}
|
||
t.forEach((l) => lines.push(" ".repeat(i) + l.trim()));
|
||
};
|
||
this.writeFormattedFile("service_server.ts", this.generateImport("{ RequestObject, ResponseObject, ErrorCodes, Logging }", "./service_base") + this.generateImport(" { VerificationError }", "./ts_base") + "\n\n" + this.getTemplate("ts_service_server.ts"));
|
||
this.generateImports(a, def);
|
||
a(0, `export type {`);
|
||
def.depends.forEach((dep) => {
|
||
a(1, `${dep},`);
|
||
});
|
||
a(0, `}`);
|
||
a(0, this.generateImport("{ Service }", "./service_server"));
|
||
a(0, ``);
|
||
a(0, `export abstract class ${def.name}<T> extends Service<T> {`);
|
||
a(1, `public name = "${def.name}";`);
|
||
a(1, `constructor(){`);
|
||
a(2, `super();`);
|
||
for (const fnc of def.functions) {
|
||
a(2, `this.functions.add("${fnc.name}")`);
|
||
}
|
||
a(1, `}`);
|
||
a(0, ``);
|
||
for (const fnc of def.functions) {
|
||
const params = [
|
||
...fnc.inputs.map((e) => `${e.name}: ${toJSType(e.type) + (e.array ? "[]" : "")}`),
|
||
`ctx: T`
|
||
].join(", ");
|
||
const retVal = fnc.return ? `Promise<${toJSType(fnc.return.type) + (fnc.return.array ? "[]" : "")}>` : `void`;
|
||
a(1, `abstract ${fnc.name}(${params}): ${retVal};`);
|
||
a(1, `_${fnc.name}(params: any[] | any, ctx: T): ${retVal} {`);
|
||
a(2, `let p: any[] = [];`);
|
||
a(2, `if(Array.isArray(params)){`);
|
||
a(3, `p = params;`);
|
||
a(3, `while(p.length < ${fnc.inputs.length})`);
|
||
a(4, `p.push(undefined)`);
|
||
a(2, `} else {`);
|
||
for (const param of fnc.inputs) {
|
||
a(3, `p.push(params["${param.name}"])`);
|
||
}
|
||
a(2, `}`);
|
||
a(2, ``);
|
||
for (let i = 0; i < fnc.inputs.length; i++) {
|
||
a(2, `if(p[${i}] !== null && p[${i}] !== undefined) {`);
|
||
if (fnc.inputs[i].array) {
|
||
a(2, `for(const elm of p[${i}]) {`);
|
||
a(3, `apply_${fnc.inputs[i].type}(elm)`);
|
||
a(2, `}`);
|
||
} else {
|
||
a(2, `apply_${fnc.inputs[i].type}(p[${i}])`);
|
||
}
|
||
a(2, `}`);
|
||
}
|
||
a(2, ``);
|
||
a(2, `p.push(ctx);`);
|
||
a(2, `//@ts-ignore This will cause a typescript error when strict checking, since p is not a tuple`);
|
||
a(2, `return this.${fnc.name}.call(this, ...p)` + (fnc.return ? `.then(${((_a = fnc.return) == null ? void 0 : _a.array) ? `res => res.map(e => apply_${fnc.return.type}(e))` : `res => apply_${fnc.return.type}(res)`});` : ""));
|
||
a(1, `}`);
|
||
a(0, ``);
|
||
}
|
||
a(0, `}`);
|
||
this.writeFormattedFile(this.getFileName(def.name + "_server"), lines.join("\n"));
|
||
}
|
||
generateService(def) {
|
||
this.writeFormattedFile("service_base.ts", this.getTemplate("ts_service_base.ts"));
|
||
this.generateServiceClient(def);
|
||
this.generateServiceServer(def);
|
||
}
|
||
finalize(steps) {
|
||
let linesClient = [];
|
||
let linesServer = [];
|
||
const ac = (i, t) => {
|
||
if (!Array.isArray(t)) {
|
||
t = [t];
|
||
}
|
||
t.forEach((l) => linesClient.push(" ".repeat(i) + l.trim()));
|
||
};
|
||
const as = (i, t) => {
|
||
if (!Array.isArray(t)) {
|
||
t = [t];
|
||
}
|
||
t.forEach((l) => linesServer.push(" ".repeat(i) + l.trim()));
|
||
};
|
||
let lines = [];
|
||
const a = (i, t) => {
|
||
if (!Array.isArray(t)) {
|
||
t = [t];
|
||
}
|
||
t.forEach((l) => lines.push(" ".repeat(i) + l.trim()));
|
||
};
|
||
let hasService = false;
|
||
steps.forEach(([type, def]) => {
|
||
switch (type) {
|
||
case "type":
|
||
a(0, this.generateImport(`${def.name}, { apply_${def.name} }`, "./" + def.name));
|
||
a(0, `export { apply_${def.name} }`);
|
||
a(0, `export { ${def.name} }`);
|
||
a(0, ``);
|
||
break;
|
||
case "enum":
|
||
a(0, this.generateImport(`${def.name}, { apply_${def.name} }`, "./" + def.name));
|
||
a(0, `export { ${def.name}, apply_${def.name} }`);
|
||
a(0, ``);
|
||
break;
|
||
case "service":
|
||
let ext = this.flavour == "esm" ? ".ts" : "";
|
||
if (!hasService) {
|
||
hasService = true;
|
||
ac(0, `export * from "./service_client${ext}"`);
|
||
ac(0, ``);
|
||
as(0, `export * from "./service_server${ext}"`);
|
||
as(0, ``);
|
||
a(0, `export * as Client from "./index_client${ext}"`);
|
||
a(0, `export * as Server from "./index_server${ext}"`);
|
||
a(0, `export { Logging } from "./service_base${ext}"`);
|
||
a(0, ``);
|
||
}
|
||
ac(0, `export { ${def.name} } from "./${def.name}_client${ext}"`);
|
||
as(0, `export { ${def.name} } from "./${def.name}_server${ext}"`);
|
||
ac(0, ``);
|
||
as(0, ``);
|
||
break;
|
||
}
|
||
});
|
||
this.writeFormattedFile(this.getFileName("index"), lines.join("\n"));
|
||
this.writeFormattedFile(this.getFileName("index_client"), linesClient.join("\n"));
|
||
this.writeFormattedFile(this.getFileName("index_server"), linesServer.join("\n"));
|
||
}
|
||
};
|
||
var ESMTypescriptTarget = class extends TypescriptTarget {
|
||
name = "ts-esm";
|
||
flavour = "esm";
|
||
};
|
||
var NodeJSTypescriptTarget = class extends TypescriptTarget {
|
||
name = "ts-node";
|
||
flavour = "node";
|
||
};
|
||
|
||
// src/targets/csharp.ts
|
||
var conversion2 = {
|
||
boolean: "bool",
|
||
int: "long",
|
||
float: "double",
|
||
string: "string",
|
||
void: "void",
|
||
bytes: ""
|
||
};
|
||
function toCSharpType(type) {
|
||
return conversion2[type] || type;
|
||
}
|
||
var CSharpTarget = class extends CompileTarget {
|
||
name = "c#";
|
||
get namespace() {
|
||
return this.options.csharp_namespace || "JRPC";
|
||
}
|
||
start() {
|
||
if (this.options.allow_bytes == true) {
|
||
throw new Error("C# has no support for 'bytes' yet!");
|
||
}
|
||
this.writeFile(this.namespace + ".csproj", this.getTemplate("CSharp/CSharp.csproj"));
|
||
const fixNS = (input) => input.replace("__NAMESPACE__", this.namespace);
|
||
const copyClass = (name) => this.writeFile(name + ".cs", fixNS(this.getTemplate(`CSharp/${name}.cs`)));
|
||
copyClass("JRpcClient");
|
||
copyClass("JRpcServer");
|
||
copyClass("JRpcTransport");
|
||
}
|
||
generateType(definition) {
|
||
let lines = [];
|
||
const a = (i, t) => {
|
||
if (!Array.isArray(t)) {
|
||
t = [t];
|
||
}
|
||
t.forEach((l) => lines.push(" ".repeat(i) + l.trim()));
|
||
};
|
||
a(0, `using System.Text.Json;`);
|
||
a(0, `using System.Text.Json.Serialization;`);
|
||
a(0, `using System.Collections.Generic;`);
|
||
a(0, ``);
|
||
a(0, `namespace ${this.namespace};`);
|
||
a(0, ``);
|
||
a(0, `public class ${definition.name} {`);
|
||
for (const field of definition.fields) {
|
||
if (field.array) {
|
||
a(1, `public IList<${toCSharpType(field.type)}>? ${field.name} { get; set; }`);
|
||
} else if (field.map) {
|
||
a(1, `public Dictionary<${toCSharpType(field.map)}, ${toCSharpType(field.type)}>? ${field.name} { get; set; }`);
|
||
} else {
|
||
a(1, `public ${toCSharpType(field.type)}? ${field.name} { get; set; }`);
|
||
}
|
||
}
|
||
a(0, `}`);
|
||
this.writeFile(`${definition.name}.cs`, lines.join("\n"));
|
||
}
|
||
generateEnum(definition) {
|
||
let lines = [];
|
||
const a = (i, t) => {
|
||
if (!Array.isArray(t)) {
|
||
t = [t];
|
||
}
|
||
t.forEach((l) => lines.push(" ".repeat(i) + l.trim()));
|
||
};
|
||
a(0, `using System.Text.Json;`);
|
||
a(0, `using System.Text.Json.Serialization;`);
|
||
a(0, ``);
|
||
a(0, `namespace ${this.namespace};`);
|
||
a(0, ``);
|
||
a(0, `public enum ${definition.name} {`);
|
||
for (const field of definition.values) {
|
||
a(1, `${field.name} = ${field.value},`);
|
||
}
|
||
a(0, `}`);
|
||
this.writeFile(`${definition.name}.cs`, lines.join("\n"));
|
||
}
|
||
generateServiceClient(definition) {
|
||
let lines = [];
|
||
const a = (i, t) => {
|
||
if (!Array.isArray(t)) {
|
||
t = [t];
|
||
}
|
||
t.forEach((l) => lines.push(" ".repeat(i) + l.trim()));
|
||
};
|
||
a(0, `using System;`);
|
||
a(0, `using System.Text.Json;`);
|
||
a(0, `using System.Text.Json.Serialization;`);
|
||
a(0, `using System.Text.Json.Nodes;`);
|
||
a(0, `using System.Threading.Tasks;`);
|
||
a(0, `using System.Collections.Generic;`);
|
||
a(0, ``);
|
||
a(0, `namespace ${this.namespace};`);
|
||
a(0, ``);
|
||
a(0, `public class ${definition.name}Client {`);
|
||
a(0, ``);
|
||
a(1, `private JRpcClient Client;`);
|
||
a(0, ``);
|
||
a(1, `public ${definition.name}Client(JRpcClient client) {`);
|
||
a(2, `this.Client = client;`);
|
||
a(1, `}`);
|
||
a(0, ``);
|
||
for (const fnc of definition.functions) {
|
||
let params = fnc.inputs.map((inp) => {
|
||
if (inp.array) {
|
||
return `List<${toCSharpType(inp.type)}> ${inp.name}`;
|
||
} else {
|
||
return `${toCSharpType(inp.type)} ${inp.name}`;
|
||
}
|
||
}).join(", ");
|
||
const genParam = () => a(2, `var param = new JsonArray(${fnc.inputs.map((e) => `JsonSerializer.SerializeToNode(${e.name})`).join(", ")});`);
|
||
if (fnc.return) {
|
||
if (fnc.return.type == "void") {
|
||
a(1, `public async Task ${fnc.name}(${params}) {`);
|
||
genParam();
|
||
a(2, `await this.Client.SendRequestRaw("${definition.name}.${fnc.name}", param);`);
|
||
a(1, `}`);
|
||
} else {
|
||
let ret = fnc.return ? fnc.return.array ? `IList<${toCSharpType(fnc.return.type)}>` : toCSharpType(fnc.return.type) : void 0;
|
||
a(1, `public async Task<${ret}?> ${fnc.name}(${params}) {`);
|
||
genParam();
|
||
a(2, `return await this.Client.SendRequest<${ret}>("${definition.name}.${fnc.name}", param);`);
|
||
a(1, `}`);
|
||
}
|
||
} else {
|
||
a(1, `public void ${fnc.name}(${params}) {`);
|
||
genParam();
|
||
a(2, `this.Client.SendNotification("${definition.name}.${fnc.name}", param);`);
|
||
a(1, `}`);
|
||
}
|
||
a(1, ``);
|
||
}
|
||
a(0, `}`);
|
||
this.writeFile(`${definition.name}Client.cs`, lines.join("\n"));
|
||
}
|
||
generateServiceServer(definition) {
|
||
let lines = [];
|
||
const a = (i, t) => {
|
||
if (!Array.isArray(t)) {
|
||
t = [t];
|
||
}
|
||
t.forEach((l) => lines.push(" ".repeat(i) + l.trim()));
|
||
};
|
||
a(0, `using System;`);
|
||
a(0, `using System.Text.Json;`);
|
||
a(0, `using System.Text.Json.Serialization;`);
|
||
a(0, `using System.Text.Json.Nodes;`);
|
||
a(0, `using System.Threading.Tasks;`);
|
||
a(0, `using System.Collections.Generic;`);
|
||
a(0, ``);
|
||
a(0, `namespace ${this.namespace};`);
|
||
a(0, ``);
|
||
a(0, `public abstract class ${definition.name}Server<TContext> : JRpcService<TContext> {`);
|
||
a(0, ``);
|
||
a(1, `public override string Name {`);
|
||
a(2, `get {`);
|
||
a(3, `return "${definition.name}";`);
|
||
a(2, `}`);
|
||
a(1, `}`);
|
||
a(0, ``);
|
||
a(1, `public ${definition.name}Server() {`);
|
||
for (const fnc of definition.functions) {
|
||
a(2, `this.RegisterFunction("${fnc.name}");`);
|
||
}
|
||
a(1, `}`);
|
||
a(0, ``);
|
||
for (const fnc of definition.functions) {
|
||
let params = [
|
||
...fnc.inputs.map((inp) => {
|
||
if (inp.array) {
|
||
return `List<${toCSharpType(inp.type)}> ${inp.name}`;
|
||
} else {
|
||
return `${toCSharpType(inp.type)} ${inp.name}`;
|
||
}
|
||
}),
|
||
"TContext ctx"
|
||
].join(", ");
|
||
if (fnc.return) {
|
||
if (fnc.return.type == "void") {
|
||
a(1, `public abstract Task ${fnc.name}(${params});`);
|
||
} else {
|
||
let ret = fnc.return ? fnc.return.array ? `IList<${toCSharpType(fnc.return.type)}>` : toCSharpType(fnc.return.type) : void 0;
|
||
a(1, `public abstract Task<${ret}> ${fnc.name}(${params});`);
|
||
}
|
||
} else {
|
||
a(1, `public abstract void ${fnc.name}(${params});`);
|
||
}
|
||
}
|
||
a(0, ``);
|
||
a(1, `public async override Task<JsonNode?> HandleRequest(string func, JsonNode param, TContext context) {`);
|
||
a(2, `switch(func) {`);
|
||
for (const fnc of definition.functions) {
|
||
a(3, `case "${fnc.name}": {`);
|
||
a(4, `if(param is JsonObject) {`);
|
||
a(5, `var ja = new JsonArray(${fnc.inputs.map((inp) => {
|
||
return `param["${inp.name}"]`;
|
||
}).join(", ")});`);
|
||
a(5, `param = ja;`);
|
||
a(4, `}`);
|
||
let pref = "";
|
||
if (fnc.return) {
|
||
if (fnc.return.type != "void")
|
||
pref = "var result = await ";
|
||
else
|
||
pref = "await ";
|
||
}
|
||
a(4, pref + `this.${fnc.name}(${[
|
||
...fnc.inputs.map((inp, idx) => {
|
||
let type = inp.array ? `List<${toCSharpType(inp.type)}>` : `${toCSharpType(inp.type)}`;
|
||
return `param[${idx}]!.Deserialize<${type}>()`;
|
||
}),
|
||
"context"
|
||
].join(", ")});`);
|
||
if (fnc.return && fnc.return.type != "void") {
|
||
a(4, `return JsonSerializer.SerializeToNode(result);`);
|
||
} else {
|
||
a(4, `return null;`);
|
||
}
|
||
a(3, `}`);
|
||
a(0, ``);
|
||
}
|
||
a(3, `default:`);
|
||
a(4, `throw new Exception("Invalid Method!");`);
|
||
a(2, `}`);
|
||
a(1, `}`);
|
||
a(0, `}`);
|
||
this.writeFile(`${definition.name}Server.cs`, lines.join("\n"));
|
||
}
|
||
generateService(definition) {
|
||
this.generateServiceClient(definition);
|
||
this.generateServiceServer(definition);
|
||
}
|
||
finalize(steps) {
|
||
}
|
||
};
|
||
|
||
// src/targets/rust.ts
|
||
var conversion3 = {
|
||
boolean: "bool",
|
||
float: "f64",
|
||
int: "i64",
|
||
string: "String",
|
||
void: "void",
|
||
bytes: "Vec<u8>"
|
||
};
|
||
function toRustType(type) {
|
||
return conversion3[type] || type;
|
||
}
|
||
function toSnake(input) {
|
||
return input[0].toLowerCase() + input.slice(1).replace(/[A-Z]/g, (letter) => `_${letter.toLowerCase()}`);
|
||
}
|
||
var RustTarget = class extends CompileTarget {
|
||
name = "rust";
|
||
get crate() {
|
||
return this.options.rust_crate;
|
||
}
|
||
start() {
|
||
if (!this.crate)
|
||
throw new Error("Setting a crate name is required. Add the following to your jrpc file: 'define rust_crate <name>'");
|
||
if (this.options.allow_bytes == true) {
|
||
throw new Error("Rust has no support for 'bytes' yet!");
|
||
}
|
||
this.writeFile("Cargo.toml", this.getTemplate("Rust/Cargo.toml").replace("${NAME}", this.crate));
|
||
}
|
||
addDependencies(a, def) {
|
||
for (const dep of def.depends) {
|
||
a(0, `use crate::${dep};`);
|
||
}
|
||
a(0, ``);
|
||
a(0, ``);
|
||
}
|
||
generateType(definition) {
|
||
let lines = [];
|
||
const a = (i, t) => {
|
||
if (!Array.isArray(t)) {
|
||
t = [t];
|
||
}
|
||
t.forEach((l) => lines.push(" ".repeat(i) + l.trim()));
|
||
};
|
||
if (definition.fields.find((e) => e.map))
|
||
a(0, `use std::collections::hash_map::HashMap;`);
|
||
a(0, `use serde::{Deserialize, Serialize};`);
|
||
this.addDependencies(a, definition);
|
||
a(0, `#[derive(Clone, Debug, Serialize, Deserialize)]`);
|
||
a(0, `pub struct ${definition.name} {`);
|
||
for (const field of definition.fields) {
|
||
if (field.array) {
|
||
a(1, `pub ${field.name}: Vec<${toRustType(field.type)}>,`);
|
||
} else if (field.map) {
|
||
a(1, `pub ${field.name}: HashMap<${toRustType(field.map)}, ${toRustType(field.type)}>,`);
|
||
} else {
|
||
a(1, `pub ${field.name}: ${toRustType(field.type)},`);
|
||
}
|
||
}
|
||
a(0, `}`);
|
||
this.writeFile(`src/${toSnake(definition.name)}.rs`, lines.join("\n"));
|
||
}
|
||
generateEnum(definition) {
|
||
let lines = [];
|
||
const a = (i, t) => {
|
||
if (!Array.isArray(t)) {
|
||
t = [t];
|
||
}
|
||
t.forEach((l) => lines.push(" ".repeat(i) + l.trim()));
|
||
};
|
||
a(0, `use int_enum::IntEnum;`);
|
||
a(0, `use serde::{Deserialize, Serialize};`);
|
||
a(0, ``);
|
||
a(0, ``);
|
||
a(0, `#[repr(i64)]`);
|
||
a(0, "#[derive(Clone, Copy, Debug, Eq, PartialEq, IntEnum, Deserialize, Serialize)]");
|
||
a(0, `pub enum ${definition.name} {`);
|
||
for (const field of definition.values) {
|
||
a(1, `${field.name} = ${field.value},`);
|
||
}
|
||
a(0, `}`);
|
||
this.writeFile(`src/${toSnake(definition.name)}.rs`, lines.join("\n"));
|
||
}
|
||
generateService(definition) {
|
||
}
|
||
generateLib(steps) {
|
||
let lines = [];
|
||
const a = (i, t) => {
|
||
if (!Array.isArray(t)) {
|
||
t = [t];
|
||
}
|
||
t.forEach((l) => lines.push(" ".repeat(i) + l.trim()));
|
||
};
|
||
for (const [typ, def] of steps) {
|
||
if (typ == "type" || typ == "enum") {
|
||
a(0, `mod ${toSnake(def.name)};`);
|
||
a(0, `pub use ${toSnake(def.name)}::${def.name};`);
|
||
}
|
||
}
|
||
this.writeFile(`src/lib.rs`, lines.join("\n"));
|
||
}
|
||
finalize(steps) {
|
||
this.generateLib(steps);
|
||
}
|
||
};
|
||
|
||
// src/process.ts
|
||
var CatchedError = class extends Error {
|
||
};
|
||
var log2 = (0, import_debug2.default)("app");
|
||
var Targets = /* @__PURE__ */ new Map();
|
||
Targets.set("ts-esm", ESMTypescriptTarget);
|
||
Targets.set("ts-node", NodeJSTypescriptTarget);
|
||
Targets.set("c#", CSharpTarget);
|
||
Targets.set("rust", RustTarget);
|
||
function indexToLineAndCol(src, index) {
|
||
let line = 1;
|
||
let col = 1;
|
||
for (let i = 0; i < index; i++) {
|
||
if (src.charAt(i) === "\n") {
|
||
line++;
|
||
col = 1;
|
||
} else {
|
||
col++;
|
||
}
|
||
}
|
||
return { line, col };
|
||
}
|
||
var fileCache = /* @__PURE__ */ new Map();
|
||
function getFile(name) {
|
||
if (fileCache.has(name))
|
||
return fileCache.get(name);
|
||
else {
|
||
try {
|
||
const data = FS2.readFileSync(name, "utf-8");
|
||
fileCache.set(name, data);
|
||
return data;
|
||
} catch (err) {
|
||
printError(new Error(`Cannot open file ${name};`), null, 0);
|
||
}
|
||
}
|
||
return void 0;
|
||
}
|
||
function printError(err, file, idx) {
|
||
let loc = { line: 0, col: 0 };
|
||
if (file != null) {
|
||
const data = getFile(file);
|
||
if (data)
|
||
loc = indexToLineAndCol(data, idx);
|
||
}
|
||
console.error(`${import_chalk.default.red("ERROR: at")} ${file}:${loc.line}:${loc.col}`);
|
||
console.error(" ", err.message);
|
||
log2(err.stack);
|
||
}
|
||
function processFile(ctx, file, root = false) {
|
||
file = Path2.resolve(file);
|
||
if (ctx.processedFiles.has(file)) {
|
||
log2("Skipping file %s since it has already be processed", file);
|
||
return null;
|
||
}
|
||
ctx.processedFiles.add(file);
|
||
log2("Processing file %s", file);
|
||
const content = getFile(file);
|
||
if (!content)
|
||
throw new Error("Could not open file " + file);
|
||
try {
|
||
log2("Tokenizing %s", file);
|
||
const tokens = tokenize(content);
|
||
log2("Parsing %s", file);
|
||
const parsed = parse(tokens, file);
|
||
log2("Resolving imports of %s", file);
|
||
let resolved = parsed.map((statement) => {
|
||
if (statement.type == "import") {
|
||
const base = Path2.dirname(file);
|
||
const resolved2 = Path2.resolve(Path2.join(base, statement.path + ".jrpc"));
|
||
return processFile(ctx, resolved2);
|
||
} else {
|
||
return statement;
|
||
}
|
||
}).filter((e) => !!e).flat(1);
|
||
return resolved;
|
||
} catch (err) {
|
||
if (err instanceof TokenizerError) {
|
||
printError(err, file, err.index);
|
||
if (!root)
|
||
throw new CatchedError();
|
||
} else if (err instanceof ParserError) {
|
||
printError(err, file, err.token.startIdx);
|
||
if (!root)
|
||
throw new CatchedError();
|
||
} else if (root && err instanceof CatchedError) {
|
||
return null;
|
||
} else {
|
||
throw err;
|
||
}
|
||
}
|
||
}
|
||
function startCompile(options) {
|
||
const ctx = {
|
||
options,
|
||
processedFiles: /* @__PURE__ */ new Set()
|
||
};
|
||
let ir = void 0;
|
||
if (options.input.endsWith(".json")) {
|
||
ir = JSON.parse(FS2.readFileSync(options.input, "utf-8"));
|
||
} else {
|
||
const parsed = processFile(ctx, options.input, true);
|
||
if (!parsed)
|
||
process.exit(1);
|
||
try {
|
||
ir = get_ir(parsed);
|
||
} catch (err) {
|
||
if (err instanceof IRError) {
|
||
printError(err, err.statement.location.file, err.statement.location.idx);
|
||
process.exit(1);
|
||
} else {
|
||
throw err;
|
||
}
|
||
}
|
||
}
|
||
if (!ir)
|
||
throw new Error("Error compiling: Cannot get IR");
|
||
if (options.emitDefinitions) {
|
||
FS2.writeFileSync(options.emitDefinitions, JSON.stringify(ir, void 0, 3));
|
||
}
|
||
if (options.targets.length <= 0) {
|
||
console.log(import_chalk.default.yellow("WARNING:"), "No targets selected!");
|
||
}
|
||
options.targets.forEach((target) => {
|
||
const tg = Targets.get(target.type);
|
||
if (!tg) {
|
||
console.log(import_chalk.default.red("ERROR:"), "Target not supported!");
|
||
return;
|
||
}
|
||
compile(ir, new tg(target.output, ir.options));
|
||
});
|
||
}
|
||
|
||
// src/index.ts
|
||
var import_debug3 = __toESM(require_src());
|
||
var log3 = (0, import_debug3.default)("app");
|
||
import_debug3.default.disable();
|
||
yargs_default(hideBin(process.argv)).version("1.0.0").command("compile <input>", "Compile source", (yargs) => {
|
||
return yargs.positional("input", {
|
||
describe: "Input file",
|
||
type: "string",
|
||
demandOption: true
|
||
}).option("definition", {
|
||
type: "string",
|
||
describe: "Emit definition json at specified location"
|
||
}).option("output", {
|
||
type: "string",
|
||
describe: "Output lang and location 'ts:out/' 'c:/test'",
|
||
alias: "o",
|
||
coerce: (arg) => {
|
||
if (!arg)
|
||
return [];
|
||
if (!Array.isArray(arg))
|
||
arg = [arg];
|
||
return arg.map((input) => {
|
||
const [type, output] = input.split(":", 2);
|
||
return {
|
||
type,
|
||
output
|
||
};
|
||
});
|
||
},
|
||
array: true
|
||
});
|
||
}, (argv) => {
|
||
if (argv.verbose) {
|
||
import_debug3.default.enable("app");
|
||
}
|
||
log3("Received compile command with args", argv);
|
||
startCompile({
|
||
input: argv.input,
|
||
targets: argv.output,
|
||
emitDefinitions: argv.definition
|
||
});
|
||
}).command("targets", "List all targets", (yargs) => yargs, () => {
|
||
console.log("Targets:");
|
||
Targets.forEach((__dirname3, target) => {
|
||
console.log(" " + target);
|
||
});
|
||
}).option("verbose", {
|
||
alias: "v",
|
||
type: "boolean",
|
||
describe: "Adds additional outputs"
|
||
}).strictCommands().demandCommand().parse();
|
||
/**
|
||
* @fileoverview Main entrypoint for libraries using yargs-parser in Node.js
|
||
* CJS and ESM environments.
|
||
*
|
||
* @license
|
||
* Copyright (c) 2016, Contributors
|
||
* SPDX-License-Identifier: ISC
|
||
*/
|
||
/**
|
||
* @license
|
||
* Copyright (c) 2016, Contributors
|
||
* SPDX-License-Identifier: ISC
|
||
*/
|