UNPKG

github-app-installation-token

Version:

npm/script and binary 📦 to get a token from a GitHub App

1,365 lines (1,361 loc) • 1.14 MB
#! /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 __objRest = (source, exclude) => { var target = {}; for (var prop in source) if (__hasOwnProp.call(source, prop) && exclude.indexOf(prop) < 0) target[prop] = source[prop]; if (source != null && __getOwnPropSymbols) for (var prop of __getOwnPropSymbols(source)) { if (exclude.indexOf(prop) < 0 && __propIsEnum.call(source, prop)) target[prop] = source[prop]; } return target; }; 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/commander/index.js var require_commander = __commonJS({ "node_modules/commander/index.js"(exports, module2) { var EventEmitter = require("events").EventEmitter; var spawn = require("child_process").spawn; var path = require("path"); var fs2 = require("fs"); var Option = class { constructor(flags, description2) { this.flags = flags; this.required = flags.includes("<"); this.optional = flags.includes("["); this.variadic = /\w\.\.\.[>\]]$/.test(flags); this.mandatory = false; const optionFlags = _parseOptionFlags(flags); this.short = optionFlags.shortFlag; this.long = optionFlags.longFlag; this.negate = false; if (this.long) { this.negate = this.long.startsWith("--no-"); } this.description = description2 || ""; this.defaultValue = void 0; } name() { if (this.long) { return this.long.replace(/^--/, ""); } return this.short.replace(/^-/, ""); } attributeName() { return camelcase(this.name().replace(/^no-/, "")); } is(arg) { return this.short === arg || this.long === arg; } }; var CommanderError = class extends Error { constructor(exitCode, code, message) { super(message); Error.captureStackTrace(this, this.constructor); this.name = this.constructor.name; this.code = code; this.exitCode = exitCode; this.nestedError = void 0; } }; var Command = class extends EventEmitter { constructor(name2) { super(); this.commands = []; this.options = []; this.parent = null; this._allowUnknownOption = false; this._args = []; this.rawArgs = null; this._scriptPath = null; this._name = name2 || ""; this._optionValues = {}; this._storeOptionsAsProperties = true; this._storeOptionsAsPropertiesCalled = false; this._passCommandToAction = true; this._actionResults = []; this._actionHandler = null; this._executableHandler = false; this._executableFile = null; this._defaultCommandName = null; this._exitCallback = null; this._aliases = []; this._combineFlagAndOptionalValue = true; this._hidden = false; this._hasHelpOption = true; this._helpFlags = "-h, --help"; this._helpDescription = "display help for command"; this._helpShortFlag = "-h"; this._helpLongFlag = "--help"; this._hasImplicitHelpCommand = void 0; this._helpCommandName = "help"; this._helpCommandnameAndArgs = "help [command]"; this._helpCommandDescription = "display help for command"; } command(nameAndArgs, actionOptsOrExecDesc, execOpts) { let desc = actionOptsOrExecDesc; let opts = execOpts; if (typeof desc === "object" && desc !== null) { opts = desc; desc = null; } opts = opts || {}; const args = nameAndArgs.split(/ +/); const cmd = this.createCommand(args.shift()); if (desc) { cmd.description(desc); cmd._executableHandler = true; } if (opts.isDefault) this._defaultCommandName = cmd._name; cmd._hidden = !!(opts.noHelp || opts.hidden); cmd._hasHelpOption = this._hasHelpOption; cmd._helpFlags = this._helpFlags; cmd._helpDescription = this._helpDescription; cmd._helpShortFlag = this._helpShortFlag; cmd._helpLongFlag = this._helpLongFlag; cmd._helpCommandName = this._helpCommandName; cmd._helpCommandnameAndArgs = this._helpCommandnameAndArgs; cmd._helpCommandDescription = this._helpCommandDescription; cmd._exitCallback = this._exitCallback; cmd._storeOptionsAsProperties = this._storeOptionsAsProperties; cmd._passCommandToAction = this._passCommandToAction; cmd._combineFlagAndOptionalValue = this._combineFlagAndOptionalValue; cmd._executableFile = opts.executableFile || null; this.commands.push(cmd); cmd._parseExpectedArgs(args); cmd.parent = this; if (desc) return this; return cmd; } createCommand(name2) { return new Command(name2); } addCommand(cmd, opts) { if (!cmd._name) throw new Error("Command passed to .addCommand() must have a name"); function checkExplicitNames(commandArray) { commandArray.forEach((cmd2) => { if (cmd2._executableHandler && !cmd2._executableFile) { throw new Error(`Must specify executableFile for deeply nested executable: ${cmd2.name()}`); } checkExplicitNames(cmd2.commands); }); } checkExplicitNames(cmd.commands); opts = opts || {}; if (opts.isDefault) this._defaultCommandName = cmd._name; if (opts.noHelp || opts.hidden) cmd._hidden = true; this.commands.push(cmd); cmd.parent = this; return this; } arguments(desc) { return this._parseExpectedArgs(desc.split(/ +/)); } addHelpCommand(enableOrNameAndArgs, description2) { if (enableOrNameAndArgs === false) { this._hasImplicitHelpCommand = false; } else { this._hasImplicitHelpCommand = true; if (typeof enableOrNameAndArgs === "string") { this._helpCommandName = enableOrNameAndArgs.split(" ")[0]; this._helpCommandnameAndArgs = enableOrNameAndArgs; } this._helpCommandDescription = description2 || this._helpCommandDescription; } return this; } _lazyHasImplicitHelpCommand() { if (this._hasImplicitHelpCommand === void 0) { this._hasImplicitHelpCommand = this.commands.length && !this._actionHandler && !this._findCommand("help"); } return this._hasImplicitHelpCommand; } _parseExpectedArgs(args) { if (!args.length) return; args.forEach((arg) => { const argDetails = { required: false, name: "", variadic: false }; switch (arg[0]) { case "<": argDetails.required = true; argDetails.name = arg.slice(1, -1); break; case "[": argDetails.name = arg.slice(1, -1); break; } if (argDetails.name.length > 3 && argDetails.name.slice(-3) === "...") { argDetails.variadic = true; argDetails.name = argDetails.name.slice(0, -3); } if (argDetails.name) { this._args.push(argDetails); } }); this._args.forEach((arg, i) => { if (arg.variadic && i < this._args.length - 1) { throw new Error(`only the last argument can be variadic '${arg.name}'`); } }); return this; } exitOverride(fn) { if (fn) { this._exitCallback = fn; } else { this._exitCallback = (err) => { if (err.code !== "commander.executeSubCommandAsync") { throw err; } else { } }; } return this; } _exit(exitCode, code, message) { if (this._exitCallback) { this._exitCallback(new CommanderError(exitCode, code, message)); } process.exit(exitCode); } action(fn) { const listener = (args) => { const expectedArgsCount = this._args.length; const actionArgs = args.slice(0, expectedArgsCount); if (this._passCommandToAction) { actionArgs[expectedArgsCount] = this; } else { actionArgs[expectedArgsCount] = this.opts(); } if (args.length > expectedArgsCount) { actionArgs.push(args.slice(expectedArgsCount)); } const actionResult = fn.apply(this, actionArgs); let rootCommand = this; while (rootCommand.parent) { rootCommand = rootCommand.parent; } rootCommand._actionResults.push(actionResult); }; this._actionHandler = listener; return this; } _checkForOptionNameClash(option) { if (!this._storeOptionsAsProperties || this._storeOptionsAsPropertiesCalled) { return; } if (option.name() === "help") { return; } const commandProperty = this._getOptionValue(option.attributeName()); if (commandProperty === void 0) { return; } let foundClash = true; if (option.negate) { const positiveLongFlag = option.long.replace(/^--no-/, "--"); foundClash = !this._findOption(positiveLongFlag); } else if (option.long) { const negativeLongFlag = option.long.replace(/^--/, "--no-"); foundClash = !this._findOption(negativeLongFlag); } if (foundClash) { throw new Error(`option '${option.name()}' clashes with existing property '${option.attributeName()}' on Command - call storeOptionsAsProperties(false) to store option values safely, - or call storeOptionsAsProperties(true) to suppress this check, - or change option name Read more on https://git.io/JJc0W`); } } _optionEx(config, flags, description2, fn, defaultValue) { const option = new Option(flags, description2); const oname = option.name(); const name2 = option.attributeName(); option.mandatory = !!config.mandatory; this._checkForOptionNameClash(option); if (typeof fn !== "function") { if (fn instanceof RegExp) { const regex = fn; fn = (val, def) => { const m = regex.exec(val); return m ? m[0] : def; }; } else { defaultValue = fn; fn = null; } } if (option.negate || option.optional || option.required || typeof defaultValue === "boolean") { if (option.negate) { const positiveLongFlag = option.long.replace(/^--no-/, "--"); defaultValue = this._findOption(positiveLongFlag) ? this._getOptionValue(name2) : true; } if (defaultValue !== void 0) { this._setOptionValue(name2, defaultValue); option.defaultValue = defaultValue; } } this.options.push(option); this.on("option:" + oname, (val) => { const oldValue = this._getOptionValue(name2); if (val !== null && fn) { val = fn(val, oldValue === void 0 ? defaultValue : oldValue); } else if (val !== null && option.variadic) { if (oldValue === defaultValue || !Array.isArray(oldValue)) { val = [val]; } else { val = oldValue.concat(val); } } if (typeof oldValue === "boolean" || typeof oldValue === "undefined") { if (val == null) { this._setOptionValue(name2, option.negate ? false : defaultValue || true); } else { this._setOptionValue(name2, val); } } else if (val !== null) { this._setOptionValue(name2, option.negate ? false : val); } }); return this; } option(flags, description2, fn, defaultValue) { return this._optionEx({}, flags, description2, fn, defaultValue); } requiredOption(flags, description2, fn, defaultValue) { return this._optionEx({ mandatory: true }, flags, description2, fn, defaultValue); } combineFlagAndOptionalValue(arg) { this._combineFlagAndOptionalValue = arg === void 0 || arg; return this; } allowUnknownOption(arg) { this._allowUnknownOption = arg === void 0 || arg; return this; } storeOptionsAsProperties(value) { this._storeOptionsAsPropertiesCalled = true; this._storeOptionsAsProperties = value === void 0 || value; if (this.options.length) { throw new Error("call .storeOptionsAsProperties() before adding options"); } return this; } passCommandToAction(value) { this._passCommandToAction = value === void 0 || value; return this; } _setOptionValue(key, value) { if (this._storeOptionsAsProperties) { this[key] = value; } else { this._optionValues[key] = value; } } _getOptionValue(key) { if (this._storeOptionsAsProperties) { return this[key]; } return this._optionValues[key]; } parse(argv, parseOptions) { if (argv !== void 0 && !Array.isArray(argv)) { throw new Error("first parameter to parse must be array or undefined"); } parseOptions = parseOptions || {}; if (argv === void 0) { argv = process.argv; if (process.versions && process.versions.electron) { parseOptions.from = "electron"; } } this.rawArgs = argv.slice(); let userArgs; switch (parseOptions.from) { case void 0: case "node": this._scriptPath = argv[1]; userArgs = argv.slice(2); break; case "electron": if (process.defaultApp) { this._scriptPath = argv[1]; userArgs = argv.slice(2); } else { userArgs = argv.slice(1); } break; case "user": userArgs = argv.slice(0); break; default: throw new Error(`unexpected parse option { from: '${parseOptions.from}' }`); } if (!this._scriptPath && process.mainModule) { this._scriptPath = process.mainModule.filename; } this._name = this._name || this._scriptPath && path.basename(this._scriptPath, path.extname(this._scriptPath)); this._parseCommand([], userArgs); return this; } parseAsync(argv, parseOptions) { this.parse(argv, parseOptions); return Promise.all(this._actionResults).then(() => this); } _executeSubCommand(subcommand, args) { args = args.slice(); let launchWithNode = false; const sourceExt = [".js", ".ts", ".tsx", ".mjs"]; this._checkForMissingMandatoryOptions(); let scriptPath = this._scriptPath; if (!scriptPath && process.mainModule) { scriptPath = process.mainModule.filename; } let baseDir; try { const resolvedLink = fs2.realpathSync(scriptPath); baseDir = path.dirname(resolvedLink); } catch (e) { baseDir = "."; } let bin2 = path.basename(scriptPath, path.extname(scriptPath)) + "-" + subcommand._name; if (subcommand._executableFile) { bin2 = subcommand._executableFile; } const localBin = path.join(baseDir, bin2); if (fs2.existsSync(localBin)) { bin2 = localBin; } else { sourceExt.forEach((ext) => { if (fs2.existsSync(`${localBin}${ext}`)) { bin2 = `${localBin}${ext}`; } }); } launchWithNode = sourceExt.includes(path.extname(bin2)); let proc; if (process.platform !== "win32") { if (launchWithNode) { args.unshift(bin2); args = incrementNodeInspectorPort(process.execArgv).concat(args); proc = spawn(process.argv[0], args, { stdio: "inherit" }); } else { proc = spawn(bin2, args, { stdio: "inherit" }); } } else { args.unshift(bin2); args = incrementNodeInspectorPort(process.execArgv).concat(args); proc = spawn(process.execPath, args, { stdio: "inherit" }); } const signals = ["SIGUSR1", "SIGUSR2", "SIGTERM", "SIGINT", "SIGHUP"]; signals.forEach((signal) => { process.on(signal, () => { if (proc.killed === false && proc.exitCode === null) { proc.kill(signal); } }); }); const exitCallback = this._exitCallback; if (!exitCallback) { proc.on("close", process.exit.bind(process)); } else { proc.on("close", () => { exitCallback(new CommanderError(process.exitCode || 0, "commander.executeSubCommandAsync", "(close)")); }); } proc.on("error", (err) => { if (err.code === "ENOENT") { const executableMissing = `'${bin2}' does not exist - if '${subcommand._name}' is not meant to be an executable command, remove description parameter from '.command()' and use '.description()' instead - if the default executable name is not suitable, use the executableFile option to supply a custom name`; throw new Error(executableMissing); } else if (err.code === "EACCES") { throw new Error(`'${bin2}' not executable`); } if (!exitCallback) { process.exit(1); } else { const wrappedError = new CommanderError(1, "commander.executeSubCommandAsync", "(error)"); wrappedError.nestedError = err; exitCallback(wrappedError); } }); this.runningCommand = proc; } _dispatchSubcommand(commandName, operands, unknown) { const subCommand = this._findCommand(commandName); if (!subCommand) this._helpAndError(); if (subCommand._executableHandler) { this._executeSubCommand(subCommand, operands.concat(unknown)); } else { subCommand._parseCommand(operands, unknown); } } _parseCommand(operands, unknown) { const parsed = this.parseOptions(unknown); operands = operands.concat(parsed.operands); unknown = parsed.unknown; this.args = operands.concat(unknown); if (operands && this._findCommand(operands[0])) { this._dispatchSubcommand(operands[0], operands.slice(1), unknown); } else if (this._lazyHasImplicitHelpCommand() && operands[0] === this._helpCommandName) { if (operands.length === 1) { this.help(); } else { this._dispatchSubcommand(operands[1], [], [this._helpLongFlag]); } } else if (this._defaultCommandName) { outputHelpIfRequested(this, unknown); this._dispatchSubcommand(this._defaultCommandName, operands, unknown); } else { if (this.commands.length && this.args.length === 0 && !this._actionHandler && !this._defaultCommandName) { this._helpAndError(); } outputHelpIfRequested(this, parsed.unknown); this._checkForMissingMandatoryOptions(); if (parsed.unknown.length > 0) { this.unknownOption(parsed.unknown[0]); } if (this._actionHandler) { const args = this.args.slice(); this._args.forEach((arg, i) => { if (arg.required && args[i] == null) { this.missingArgument(arg.name); } else if (arg.variadic) { args[i] = args.splice(i); } }); this._actionHandler(args); this.emit("command:" + this.name(), operands, unknown); } else if (operands.length) { if (this._findCommand("*")) { this._dispatchSubcommand("*", operands, unknown); } else if (this.listenerCount("command:*")) { this.emit("command:*", operands, unknown); } else if (this.commands.length) { this.unknownCommand(); } } else if (this.commands.length) { this._helpAndError(); } else { } } } _findCommand(name2) { if (!name2) return void 0; return this.commands.find((cmd) => cmd._name === name2 || cmd._aliases.includes(name2)); } _findOption(arg) { return this.options.find((option) => option.is(arg)); } _checkForMissingMandatoryOptions() { for (let cmd = this; cmd; cmd = cmd.parent) { cmd.options.forEach((anOption) => { if (anOption.mandatory && cmd._getOptionValue(anOption.attributeName()) === void 0) { cmd.missingMandatoryOptionValue(anOption); } }); } } parseOptions(argv) { const operands = []; const unknown = []; let dest = operands; const args = argv.slice(); function maybeOption(arg) { return arg.length > 1 && arg[0] === "-"; } let activeVariadicOption = null; while (args.length) { const arg = args.shift(); if (arg === "--") { if (dest === unknown) dest.push(arg); dest.push(...args); break; } if (activeVariadicOption && !maybeOption(arg)) { this.emit(`option:${activeVariadicOption.name()}`, arg); continue; } activeVariadicOption = null; if (maybeOption(arg)) { const option = this._findOption(arg); if (option) { if (option.required) { const value = args.shift(); if (value === void 0) this.optionMissingArgument(option); this.emit(`option:${option.name()}`, value); } else if (option.optional) { let value = null; if (args.length > 0 && !maybeOption(args[0])) { value = args.shift(); } this.emit(`option:${option.name()}`, value); } else { this.emit(`option:${option.name()}`); } activeVariadicOption = option.variadic ? option : null; continue; } } if (arg.length > 2 && arg[0] === "-" && arg[1] !== "-") { const option = this._findOption(`-${arg[1]}`); if (option) { if (option.required || option.optional && this._combineFlagAndOptionalValue) { this.emit(`option:${option.name()}`, arg.slice(2)); } else { this.emit(`option:${option.name()}`); args.unshift(`-${arg.slice(2)}`); } continue; } } if (/^--[^=]+=/.test(arg)) { const index = arg.indexOf("="); const option = this._findOption(arg.slice(0, index)); if (option && (option.required || option.optional)) { this.emit(`option:${option.name()}`, arg.slice(index + 1)); continue; } } if (arg.length > 1 && arg[0] === "-") { dest = unknown; } dest.push(arg); } return { operands, unknown }; } opts() { if (this._storeOptionsAsProperties) { const result = {}; const len = this.options.length; for (let i = 0; i < len; i++) { const key = this.options[i].attributeName(); result[key] = key === this._versionOptionName ? this._version : this[key]; } return result; } return this._optionValues; } missingArgument(name2) { const message = `error: missing required argument '${name2}'`; console.error(message); this._exit(1, "commander.missingArgument", message); } optionMissingArgument(option, flag) { let message; if (flag) { message = `error: option '${option.flags}' argument missing, got '${flag}'`; } else { message = `error: option '${option.flags}' argument missing`; } console.error(message); this._exit(1, "commander.optionMissingArgument", message); } missingMandatoryOptionValue(option) { const message = `error: required option '${option.flags}' not specified`; console.error(message); this._exit(1, "commander.missingMandatoryOptionValue", message); } unknownOption(flag) { if (this._allowUnknownOption) return; const message = `error: unknown option '${flag}'`; console.error(message); this._exit(1, "commander.unknownOption", message); } unknownCommand() { const partCommands = [this.name()]; for (let parentCmd = this.parent; parentCmd; parentCmd = parentCmd.parent) { partCommands.unshift(parentCmd.name()); } const fullCommand = partCommands.join(" "); const message = `error: unknown command '${this.args[0]}'.` + (this._hasHelpOption ? ` See '${fullCommand} ${this._helpLongFlag}'.` : ""); console.error(message); this._exit(1, "commander.unknownCommand", message); } version(str, flags, description2) { if (str === void 0) return this._version; this._version = str; flags = flags || "-V, --version"; description2 = description2 || "output the version number"; const versionOption = new Option(flags, description2); this._versionOptionName = versionOption.attributeName(); this.options.push(versionOption); this.on("option:" + versionOption.name(), () => { process.stdout.write(str + "\n"); this._exit(0, "commander.version", str); }); return this; } description(str, argsDescription) { if (str === void 0 && argsDescription === void 0) return this._description; this._description = str; this._argsDescription = argsDescription; return this; } alias(alias) { if (alias === void 0) return this._aliases[0]; let command2 = this; if (this.commands.length !== 0 && this.commands[this.commands.length - 1]._executableHandler) { command2 = this.commands[this.commands.length - 1]; } if (alias === command2._name) throw new Error("Command alias can't be the same as its name"); command2._aliases.push(alias); return this; } aliases(aliases) { if (aliases === void 0) return this._aliases; aliases.forEach((alias) => this.alias(alias)); return this; } usage(str) { if (str === void 0) { if (this._usage) return this._usage; const args = this._args.map((arg) => { return humanReadableArgName(arg); }); return [].concat(this.options.length || this._hasHelpOption ? "[options]" : [], this.commands.length ? "[command]" : [], this._args.length ? args : []).join(" "); } this._usage = str; return this; } name(str) { if (str === void 0) return this._name; this._name = str; return this; } prepareCommands() { const commandDetails = this.commands.filter((cmd) => { return !cmd._hidden; }).map((cmd) => { const args = cmd._args.map((arg) => { return humanReadableArgName(arg); }).join(" "); return [ cmd._name + (cmd._aliases[0] ? "|" + cmd._aliases[0] : "") + (cmd.options.length ? " [options]" : "") + (args ? " " + args : ""), cmd._description ]; }); if (this._lazyHasImplicitHelpCommand()) { commandDetails.push([this._helpCommandnameAndArgs, this._helpCommandDescription]); } return commandDetails; } largestCommandLength() { const commands = this.prepareCommands(); return commands.reduce((max, command2) => { return Math.max(max, command2[0].length); }, 0); } largestOptionLength() { const options = [].slice.call(this.options); options.push({ flags: this._helpFlags }); return options.reduce((max, option) => { return Math.max(max, option.flags.length); }, 0); } largestArgLength() { return this._args.reduce((max, arg) => { return Math.max(max, arg.name.length); }, 0); } padWidth() { let width = this.largestOptionLength(); if (this._argsDescription && this._args.length) { if (this.largestArgLength() > width) { width = this.largestArgLength(); } } if (this.commands && this.commands.length) { if (this.largestCommandLength() > width) { width = this.largestCommandLength(); } } return width; } optionHelp() { const width = this.padWidth(); const columns = process.stdout.columns || 80; const descriptionWidth = columns - width - 4; function padOptionDetails(flags, description2) { return pad(flags, width) + " " + optionalWrap(description2, descriptionWidth, width + 2); } ; const help = this.options.map((option) => { const fullDesc = option.description + (!option.negate && option.defaultValue !== void 0 ? " (default: " + JSON.stringify(option.defaultValue) + ")" : ""); return padOptionDetails(option.flags, fullDesc); }); const showShortHelpFlag = this._hasHelpOption && this._helpShortFlag && !this._findOption(this._helpShortFlag); const showLongHelpFlag = this._hasHelpOption && !this._findOption(this._helpLongFlag); if (showShortHelpFlag || showLongHelpFlag) { let helpFlags = this._helpFlags; if (!showShortHelpFlag) { helpFlags = this._helpLongFlag; } else if (!showLongHelpFlag) { helpFlags = this._helpShortFlag; } help.push(padOptionDetails(helpFlags, this._helpDescription)); } return help.join("\n"); } commandHelp() { if (!this.commands.length && !this._lazyHasImplicitHelpCommand()) return ""; const commands = this.prepareCommands(); const width = this.padWidth(); const columns = process.stdout.columns || 80; const descriptionWidth = columns - width - 4; return [ "Commands:", commands.map((cmd) => { const desc = cmd[1] ? " " + cmd[1] : ""; return (desc ? pad(cmd[0], width) : cmd[0]) + optionalWrap(desc, descriptionWidth, width + 2); }).join("\n").replace(/^/gm, " "), "" ].join("\n"); } helpInformation() { let desc = []; if (this._description) { desc = [ this._description, "" ]; const argsDescription = this._argsDescription; if (argsDescription && this._args.length) { const width = this.padWidth(); const columns = process.stdout.columns || 80; const descriptionWidth = columns - width - 5; desc.push("Arguments:"); this._args.forEach((arg) => { desc.push(" " + pad(arg.name, width) + " " + wrap(argsDescription[arg.name] || "", descriptionWidth, width + 4)); }); desc.push(""); } } let cmdName = this._name; if (this._aliases[0]) { cmdName = cmdName + "|" + this._aliases[0]; } let parentCmdNames = ""; for (let parentCmd = this.parent; parentCmd; parentCmd = parentCmd.parent) { parentCmdNames = parentCmd.name() + " " + parentCmdNames; } const usage = [ "Usage: " + parentCmdNames + cmdName + " " + this.usage(), "" ]; let cmds = []; const commandHelp = this.commandHelp(); if (commandHelp) cmds = [commandHelp]; let options = []; if (this._hasHelpOption || this.options.length > 0) { options = [ "Options:", "" + this.optionHelp().replace(/^/gm, " "), "" ]; } return usage.concat(desc).concat(options).concat(cmds).join("\n"); } outputHelp(cb) { if (!cb) { cb = (passthru) => { return passthru; }; } const cbOutput = cb(this.helpInformation()); if (typeof cbOutput !== "string" && !Buffer.isBuffer(cbOutput)) { throw new Error("outputHelp callback must return a string or a Buffer"); } process.stdout.write(cbOutput); this.emit(this._helpLongFlag); } helpOption(flags, description2) { if (typeof flags === "boolean") { this._hasHelpOption = flags; return this; } this._helpFlags = flags || this._helpFlags; this._helpDescription = description2 || this._helpDescription; const helpFlags = _parseOptionFlags(this._helpFlags); this._helpShortFlag = helpFlags.shortFlag; this._helpLongFlag = helpFlags.longFlag; return this; } help(cb) { this.outputHelp(cb); this._exit(process.exitCode || 0, "commander.help", "(outputHelp)"); } _helpAndError() { this.outputHelp(); this._exit(1, "commander.help", "(outputHelp)"); } }; exports = module2.exports = new Command(); exports.program = exports; exports.Command = Command; exports.Option = Option; exports.CommanderError = CommanderError; function camelcase(flag) { return flag.split("-").reduce((str, word) => { return str + word[0].toUpperCase() + word.slice(1); }); } function pad(str, width) { const len = Math.max(0, width - str.length); return str + Array(len + 1).join(" "); } function wrap(str, width, indent) { const regex = new RegExp(".{1," + (width - 1) + "}([\\s\u200B]|$)|[^\\s\u200B]+?([\\s\u200B]|$)", "g"); const lines = str.match(regex) || []; return lines.map((line, i) => { if (line.slice(-1) === "\n") { line = line.slice(0, line.length - 1); } return (i > 0 && indent ? Array(indent + 1).join(" ") : "") + line.trimRight(); }).join("\n"); } function optionalWrap(str, width, indent) { if (str.match(/[\n]\s+/)) return str; const minWidth = 40; if (width < minWidth) return str; return wrap(str, width, indent); } function outputHelpIfRequested(cmd, args) { const helpOption = cmd._hasHelpOption && args.find((arg) => arg === cmd._helpLongFlag || arg === cmd._helpShortFlag); if (helpOption) { cmd.outputHelp(); cmd._exit(0, "commander.helpDisplayed", "(outputHelp)"); } } function humanReadableArgName(arg) { const nameOutput = arg.name + (arg.variadic === true ? "..." : ""); return arg.required ? "<" + nameOutput + ">" : "[" + nameOutput + "]"; } function _parseOptionFlags(flags) { let shortFlag; let longFlag; const flagParts = flags.split(/[ |,]+/); if (flagParts.length > 1 && !/^[[<]/.test(flagParts[1])) shortFlag = flagParts.shift(); longFlag = flagParts.shift(); if (!shortFlag && /^-[^-]$/.test(longFlag)) { shortFlag = longFlag; longFlag = void 0; } return { shortFlag, longFlag }; } function incrementNodeInspectorPort(args) { return args.map((arg) => { if (!arg.startsWith("--inspect")) { return arg; } let debugOption; let debugHost = "127.0.0.1"; let debugPort = "9229"; let match; if ((match = arg.match(/^(--inspect(-brk)?)$/)) !== null) { debugOption = match[1]; } else if ((match = arg.match(/^(--inspect(-brk|-port)?)=([^:]+)$/)) !== null) { debugOption = match[1]; if (/^\d+$/.test(match[3])) { debugPort = match[3]; } else { debugHost = match[3]; } } else if ((match = arg.match(/^(--inspect(-brk|-port)?)=([^:]+):(\d+)$/)) !== null) { debugOption = match[1]; debugHost = match[3]; debugPort = match[4]; } if (debugOption && debugPort !== "0") { return `${debugOption}=${debugHost}:${parseInt(debugPort) + 1}`; } return arg; }); } } }); // node_modules/ora/node_modules/color-name/index.js var require_color_name = __commonJS({ "node_modules/ora/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/ora/node_modules/color-convert/conversions.js var require_conversions = __commonJS({ "node_modules/ora/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) **