utquidem
Version:
The meta-framework suite designed from scratch for frontend-focused modern web development.
1 lines • 31.4 kB
JavaScript
(()=>{var e={81:e=>{"use strict";e.exports=require("child_process")},361:e=>{"use strict";e.exports=require("events")},147:e=>{"use strict";e.exports=require("fs")},17:e=>{"use strict";e.exports=require("path")},922:(e,t,i)=>{const{Argument:n}=i(969);const{Command:s}=i(694);const{CommanderError:r,InvalidArgumentError:o}=i(967);const{Help:a}=i(34);const{Option:h}=i(278);t=e.exports=new s;t.program=t;t.Argument=n;t.Command=s;t.CommanderError=r;t.Help=a;t.InvalidArgumentError=o;t.InvalidOptionArgumentError=o;t.Option=h},969:(e,t,i)=>{const{InvalidArgumentError:n}=i(967);class Argument{constructor(e,t){this.description=t||"";this.variadic=false;this.parseArg=undefined;this.defaultValue=undefined;this.defaultValueDescription=undefined;this.argChoices=undefined;switch(e[0]){case"<":this.required=true;this._name=e.slice(1,-1);break;case"[":this.required=false;this._name=e.slice(1,-1);break;default:this.required=true;this._name=e;break}if(this._name.length>3&&this._name.slice(-3)==="..."){this.variadic=true;this._name=this._name.slice(0,-3)}}name(){return this._name}_concatValue(e,t){if(t===this.defaultValue||!Array.isArray(t)){return[e]}return t.concat(e)}default(e,t){this.defaultValue=e;this.defaultValueDescription=t;return this}argParser(e){this.parseArg=e;return this}choices(e){this.argChoices=e;this.parseArg=(t,i)=>{if(!e.includes(t)){throw new n(`Allowed choices are ${e.join(", ")}.`)}if(this.variadic){return this._concatValue(t,i)}return t};return this}argRequired(){this.required=true;return this}argOptional(){this.required=false;return this}}function humanReadableArgName(e){const t=e.name()+(e.variadic===true?"...":"");return e.required?"<"+t+">":"["+t+"]"}t.Argument=Argument;t.humanReadableArgName=humanReadableArgName},694:(e,t,i)=>{const n=i(361).EventEmitter;const s=i(81);const r=i(17);const o=i(147);const{Argument:a,humanReadableArgName:h}=i(969);const{CommanderError:l}=i(967);const{Help:u}=i(34);const{Option:c,splitOptionFlags:p}=i(278);const{suggestSimilar:m}=i(461);class Command extends n{constructor(e){super();this.commands=[];this.options=[];this.parent=null;this._allowUnknownOption=false;this._allowExcessArguments=true;this._args=[];this.args=[];this.rawArgs=[];this.processedArgs=[];this._scriptPath=null;this._name=e||"";this._optionValues={};this._optionValueSources={};this._storeOptionsAsProperties=false;this._actionHandler=null;this._executableHandler=false;this._executableFile=null;this._defaultCommandName=null;this._exitCallback=null;this._aliases=[];this._combineFlagAndOptionalValue=true;this._description="";this._argsDescription=undefined;this._enablePositionalOptions=false;this._passThroughOptions=false;this._lifeCycleHooks={};this._showHelpAfterError=false;this._showSuggestionAfterError=false;this._outputConfiguration={writeOut:e=>process.stdout.write(e),writeErr:e=>process.stderr.write(e),getOutHelpWidth:()=>process.stdout.isTTY?process.stdout.columns:undefined,getErrHelpWidth:()=>process.stderr.isTTY?process.stderr.columns:undefined,outputError:(e,t)=>t(e)};this._hidden=false;this._hasHelpOption=true;this._helpFlags="-h, --help";this._helpDescription="display help for command";this._helpShortFlag="-h";this._helpLongFlag="--help";this._addImplicitHelpCommand=undefined;this._helpCommandName="help";this._helpCommandnameAndArgs="help [command]";this._helpCommandDescription="display help for command";this._helpConfiguration={}}copyInheritedSettings(e){this._outputConfiguration=e._outputConfiguration;this._hasHelpOption=e._hasHelpOption;this._helpFlags=e._helpFlags;this._helpDescription=e._helpDescription;this._helpShortFlag=e._helpShortFlag;this._helpLongFlag=e._helpLongFlag;this._helpCommandName=e._helpCommandName;this._helpCommandnameAndArgs=e._helpCommandnameAndArgs;this._helpCommandDescription=e._helpCommandDescription;this._helpConfiguration=e._helpConfiguration;this._exitCallback=e._exitCallback;this._storeOptionsAsProperties=e._storeOptionsAsProperties;this._combineFlagAndOptionalValue=e._combineFlagAndOptionalValue;this._allowExcessArguments=e._allowExcessArguments;this._enablePositionalOptions=e._enablePositionalOptions;this._showHelpAfterError=e._showHelpAfterError;this._showSuggestionAfterError=e._showSuggestionAfterError;return this}command(e,t,i){let n=t;let s=i;if(typeof n==="object"&&n!==null){s=n;n=null}s=s||{};const[,r,o]=e.match(/([^ ]+) *(.*)/);const a=this.createCommand(r);if(n){a.description(n);a._executableHandler=true}if(s.isDefault)this._defaultCommandName=a._name;a._hidden=!!(s.noHelp||s.hidden);a._executableFile=s.executableFile||null;if(o)a.arguments(o);this.commands.push(a);a.parent=this;a.copyInheritedSettings(this);if(n)return this;return a}createCommand(e){return new Command(e)}createHelp(){return Object.assign(new u,this.configureHelp())}configureHelp(e){if(e===undefined)return this._helpConfiguration;this._helpConfiguration=e;return this}configureOutput(e){if(e===undefined)return this._outputConfiguration;Object.assign(this._outputConfiguration,e);return this}showHelpAfterError(e=true){if(typeof e!=="string")e=!!e;this._showHelpAfterError=e;return this}showSuggestionAfterError(e=true){this._showSuggestionAfterError=!!e;return this}addCommand(e,t){if(!e._name)throw new Error("Command passed to .addCommand() must have a name");function checkExplicitNames(e){e.forEach((e=>{if(e._executableHandler&&!e._executableFile){throw new Error(`Must specify executableFile for deeply nested executable: ${e.name()}`)}checkExplicitNames(e.commands)}))}checkExplicitNames(e.commands);t=t||{};if(t.isDefault)this._defaultCommandName=e._name;if(t.noHelp||t.hidden)e._hidden=true;this.commands.push(e);e.parent=this;return this}createArgument(e,t){return new a(e,t)}argument(e,t,i,n){const s=this.createArgument(e,t);if(typeof i==="function"){s.default(n).argParser(i)}else{s.default(i)}this.addArgument(s);return this}arguments(e){e.split(/ +/).forEach((e=>{this.argument(e)}));return this}addArgument(e){const t=this._args.slice(-1)[0];if(t&&t.variadic){throw new Error(`only the last argument can be variadic '${t.name()}'`)}if(e.required&&e.defaultValue!==undefined&&e.parseArg===undefined){throw new Error(`a default value for a required argument is never used: '${e.name()}'`)}this._args.push(e);return this}addHelpCommand(e,t){if(e===false){this._addImplicitHelpCommand=false}else{this._addImplicitHelpCommand=true;if(typeof e==="string"){this._helpCommandName=e.split(" ")[0];this._helpCommandnameAndArgs=e}this._helpCommandDescription=t||this._helpCommandDescription}return this}_hasImplicitHelpCommand(){if(this._addImplicitHelpCommand===undefined){return this.commands.length&&!this._actionHandler&&!this._findCommand("help")}return this._addImplicitHelpCommand}hook(e,t){const i=["preAction","postAction"];if(!i.includes(e)){throw new Error(`Unexpected value for event passed to hook : '${e}'.\nExpecting one of '${i.join("', '")}'`)}if(this._lifeCycleHooks[e]){this._lifeCycleHooks[e].push(t)}else{this._lifeCycleHooks[e]=[t]}return this}exitOverride(e){if(e){this._exitCallback=e}else{this._exitCallback=e=>{if(e.code!=="commander.executeSubCommandAsync"){throw e}else{}}}return this}_exit(e,t,i){if(this._exitCallback){this._exitCallback(new l(e,t,i))}process.exit(e)}action(e){const listener=t=>{const i=this._args.length;const n=t.slice(0,i);if(this._storeOptionsAsProperties){n[i]=this}else{n[i]=this.opts()}n.push(this);return e.apply(this,n)};this._actionHandler=listener;return this}createOption(e,t){return new c(e,t)}addOption(e){const t=e.name();const i=e.attributeName();let n=e.defaultValue;if(e.negate||e.optional||e.required||typeof n==="boolean"){if(e.negate){const t=e.long.replace(/^--no-/,"--");n=this._findOption(t)?this.getOptionValue(i):true}if(n!==undefined){this.setOptionValueWithSource(i,n,"default")}}this.options.push(e);const handleOptionValue=(t,s,r)=>{const o=this.getOptionValue(i);if(t!==null&&e.parseArg){try{t=e.parseArg(t,o===undefined?n:o)}catch(e){if(e.code==="commander.invalidArgument"){const t=`${s} ${e.message}`;this._displayError(e.exitCode,e.code,t)}throw e}}else if(t!==null&&e.variadic){t=e._concatValue(t,o)}if(typeof o==="boolean"||typeof o==="undefined"){if(t==null){this.setOptionValueWithSource(i,e.negate?false:n||true,r)}else{this.setOptionValueWithSource(i,t,r)}}else if(t!==null){this.setOptionValueWithSource(i,e.negate?false:t,r)}};this.on("option:"+t,(t=>{const i=`error: option '${e.flags}' argument '${t}' is invalid.`;handleOptionValue(t,i,"cli")}));if(e.envVar){this.on("optionEnv:"+t,(t=>{const i=`error: option '${e.flags}' value '${t}' from env '${e.envVar}' is invalid.`;handleOptionValue(t,i,"env")}))}return this}_optionEx(e,t,i,n,s){const r=this.createOption(t,i);r.makeOptionMandatory(!!e.mandatory);if(typeof n==="function"){r.default(s).argParser(n)}else if(n instanceof RegExp){const e=n;n=(t,i)=>{const n=e.exec(t);return n?n[0]:i};r.default(s).argParser(n)}else{r.default(n)}return this.addOption(r)}option(e,t,i,n){return this._optionEx({},e,t,i,n)}requiredOption(e,t,i,n){return this._optionEx({mandatory:true},e,t,i,n)}combineFlagAndOptionalValue(e=true){this._combineFlagAndOptionalValue=!!e;return this}allowUnknownOption(e=true){this._allowUnknownOption=!!e;return this}allowExcessArguments(e=true){this._allowExcessArguments=!!e;return this}enablePositionalOptions(e=true){this._enablePositionalOptions=!!e;return this}passThroughOptions(e=true){this._passThroughOptions=!!e;if(!!this.parent&&e&&!this.parent._enablePositionalOptions){throw new Error("passThroughOptions can not be used without turning on enablePositionalOptions for parent command(s)")}return this}storeOptionsAsProperties(e=true){this._storeOptionsAsProperties=!!e;if(this.options.length){throw new Error("call .storeOptionsAsProperties() before adding options")}return this}getOptionValue(e){if(this._storeOptionsAsProperties){return this[e]}return this._optionValues[e]}setOptionValue(e,t){if(this._storeOptionsAsProperties){this[e]=t}else{this._optionValues[e]=t}return this}setOptionValueWithSource(e,t,i){this.setOptionValue(e,t);this._optionValueSources[e]=i;return this}getOptionValueSource(e){return this._optionValueSources[e]}_prepareUserArgs(e,t){if(e!==undefined&&!Array.isArray(e)){throw new Error("first parameter to parse must be array or undefined")}t=t||{};if(e===undefined){e=process.argv;if(process.versions&&process.versions.electron){t.from="electron"}}this.rawArgs=e.slice();let i;switch(t.from){case undefined:case"node":this._scriptPath=e[1];i=e.slice(2);break;case"electron":if(process.defaultApp){this._scriptPath=e[1];i=e.slice(2)}else{i=e.slice(1)}break;case"user":i=e.slice(0);break;default:throw new Error(`unexpected parse option { from: '${t.from}' }`)}if(!this._scriptPath&&require.main){this._scriptPath=require.main.filename}this._name=this._name||this._scriptPath&&r.basename(this._scriptPath,r.extname(this._scriptPath));return i}parse(e,t){const i=this._prepareUserArgs(e,t);this._parseCommand([],i);return this}async parseAsync(e,t){const i=this._prepareUserArgs(e,t);await this._parseCommand([],i);return this}_executeSubCommand(e,t){t=t.slice();let i=false;const n=[".js",".ts",".tsx",".mjs",".cjs"];this._checkForMissingMandatoryOptions();let a=this._scriptPath;if(!a&&require.main){a=require.main.filename}let h;try{const e=o.realpathSync(a);h=r.dirname(e)}catch(e){h="."}let u=r.basename(a,r.extname(a))+"-"+e._name;if(e._executableFile){u=e._executableFile}const c=r.join(h,u);if(o.existsSync(c)){u=c}else{n.forEach((e=>{if(o.existsSync(`${c}${e}`)){u=`${c}${e}`}}))}i=n.includes(r.extname(u));let p;if(process.platform!=="win32"){if(i){t.unshift(u);t=incrementNodeInspectorPort(process.execArgv).concat(t);p=s.spawn(process.argv[0],t,{stdio:"inherit"})}else{p=s.spawn(u,t,{stdio:"inherit"})}}else{t.unshift(u);t=incrementNodeInspectorPort(process.execArgv).concat(t);p=s.spawn(process.execPath,t,{stdio:"inherit"})}const m=["SIGUSR1","SIGUSR2","SIGTERM","SIGINT","SIGHUP"];m.forEach((e=>{process.on(e,(()=>{if(p.killed===false&&p.exitCode===null){p.kill(e)}}))}));const d=this._exitCallback;if(!d){p.on("close",process.exit.bind(process))}else{p.on("close",(()=>{d(new l(process.exitCode||0,"commander.executeSubCommandAsync","(close)"))}))}p.on("error",(t=>{if(t.code==="ENOENT"){const t=`'${u}' does not exist\n - if '${e._name}' is not meant to be an executable command, remove description parameter from '.command()' and use '.description()' instead\n - if the default executable name is not suitable, use the executableFile option to supply a custom name`;throw new Error(t)}else if(t.code==="EACCES"){throw new Error(`'${u}' not executable`)}if(!d){process.exit(1)}else{const e=new l(1,"commander.executeSubCommandAsync","(error)");e.nestedError=t;d(e)}}));this.runningCommand=p}_dispatchSubcommand(e,t,i){const n=this._findCommand(e);if(!n)this.help({error:true});if(n._executableHandler){this._executeSubCommand(n,t.concat(i))}else{return n._parseCommand(t,i)}}_checkNumberOfArguments(){this._args.forEach(((e,t)=>{if(e.required&&this.args[t]==null){this.missingArgument(e.name())}}));if(this._args.length>0&&this._args[this._args.length-1].variadic){return}if(this.args.length>this._args.length){this._excessArguments(this.args)}}_processArguments(){const myParseArg=(e,t,i)=>{let n=t;if(t!==null&&e.parseArg){try{n=e.parseArg(t,i)}catch(i){if(i.code==="commander.invalidArgument"){const n=`error: command-argument value '${t}' is invalid for argument '${e.name()}'. ${i.message}`;this._displayError(i.exitCode,i.code,n)}throw i}}return n};this._checkNumberOfArguments();const e=[];this._args.forEach(((t,i)=>{let n=t.defaultValue;if(t.variadic){if(i<this.args.length){n=this.args.slice(i);if(t.parseArg){n=n.reduce(((e,i)=>myParseArg(t,i,e)),t.defaultValue)}}else if(n===undefined){n=[]}}else if(i<this.args.length){n=this.args[i];if(t.parseArg){n=myParseArg(t,n,t.defaultValue)}}e[i]=n}));this.processedArgs=e}_chainOrCall(e,t){if(e&&e.then&&typeof e.then==="function"){return e.then((()=>t()))}return t()}_chainOrCallHooks(e,t){let i=e;const n=[];getCommandAndParents(this).reverse().filter((e=>e._lifeCycleHooks[t]!==undefined)).forEach((e=>{e._lifeCycleHooks[t].forEach((t=>{n.push({hookedCommand:e,callback:t})}))}));if(t==="postAction"){n.reverse()}n.forEach((e=>{i=this._chainOrCall(i,(()=>e.callback(e.hookedCommand,this)))}));return i}_parseCommand(e,t){const i=this.parseOptions(t);this._parseOptionsEnv();e=e.concat(i.operands);t=i.unknown;this.args=e.concat(t);if(e&&this._findCommand(e[0])){return this._dispatchSubcommand(e[0],e.slice(1),t)}if(this._hasImplicitHelpCommand()&&e[0]===this._helpCommandName){if(e.length===1){this.help()}return this._dispatchSubcommand(e[1],[],[this._helpLongFlag])}if(this._defaultCommandName){outputHelpIfRequested(this,t);return this._dispatchSubcommand(this._defaultCommandName,e,t)}if(this.commands.length&&this.args.length===0&&!this._actionHandler&&!this._defaultCommandName){this.help({error:true})}outputHelpIfRequested(this,i.unknown);this._checkForMissingMandatoryOptions();const checkForUnknownOptions=()=>{if(i.unknown.length>0){this.unknownOption(i.unknown[0])}};const n=`command:${this.name()}`;if(this._actionHandler){checkForUnknownOptions();this._processArguments();let i;i=this._chainOrCallHooks(i,"preAction");i=this._chainOrCall(i,(()=>this._actionHandler(this.processedArgs)));if(this.parent)this.parent.emit(n,e,t);i=this._chainOrCallHooks(i,"postAction");return i}if(this.parent&&this.parent.listenerCount(n)){checkForUnknownOptions();this._processArguments();this.parent.emit(n,e,t)}else if(e.length){if(this._findCommand("*")){return this._dispatchSubcommand("*",e,t)}if(this.listenerCount("command:*")){this.emit("command:*",e,t)}else if(this.commands.length){this.unknownCommand()}else{checkForUnknownOptions();this._processArguments()}}else if(this.commands.length){checkForUnknownOptions();this.help({error:true})}else{checkForUnknownOptions();this._processArguments()}}_findCommand(e){if(!e)return undefined;return this.commands.find((t=>t._name===e||t._aliases.includes(e)))}_findOption(e){return this.options.find((t=>t.is(e)))}_checkForMissingMandatoryOptions(){for(let e=this;e;e=e.parent){e.options.forEach((t=>{if(t.mandatory&&e.getOptionValue(t.attributeName())===undefined){e.missingMandatoryOptionValue(t)}}))}}parseOptions(e){const t=[];const i=[];let n=t;const s=e.slice();function maybeOption(e){return e.length>1&&e[0]==="-"}let r=null;while(s.length){const e=s.shift();if(e==="--"){if(n===i)n.push(e);n.push(...s);break}if(r&&!maybeOption(e)){this.emit(`option:${r.name()}`,e);continue}r=null;if(maybeOption(e)){const t=this._findOption(e);if(t){if(t.required){const e=s.shift();if(e===undefined)this.optionMissingArgument(t);this.emit(`option:${t.name()}`,e)}else if(t.optional){let e=null;if(s.length>0&&!maybeOption(s[0])){e=s.shift()}this.emit(`option:${t.name()}`,e)}else{this.emit(`option:${t.name()}`)}r=t.variadic?t:null;continue}}if(e.length>2&&e[0]==="-"&&e[1]!=="-"){const t=this._findOption(`-${e[1]}`);if(t){if(t.required||t.optional&&this._combineFlagAndOptionalValue){this.emit(`option:${t.name()}`,e.slice(2))}else{this.emit(`option:${t.name()}`);s.unshift(`-${e.slice(2)}`)}continue}}if(/^--[^=]+=/.test(e)){const t=e.indexOf("=");const i=this._findOption(e.slice(0,t));if(i&&(i.required||i.optional)){this.emit(`option:${i.name()}`,e.slice(t+1));continue}}if(maybeOption(e)){n=i}if((this._enablePositionalOptions||this._passThroughOptions)&&t.length===0&&i.length===0){if(this._findCommand(e)){t.push(e);if(s.length>0)i.push(...s);break}else if(e===this._helpCommandName&&this._hasImplicitHelpCommand()){t.push(e);if(s.length>0)t.push(...s);break}else if(this._defaultCommandName){i.push(e);if(s.length>0)i.push(...s);break}}if(this._passThroughOptions){n.push(e);if(s.length>0)n.push(...s);break}n.push(e)}return{operands:t,unknown:i}}opts(){if(this._storeOptionsAsProperties){const e={};const t=this.options.length;for(let i=0;i<t;i++){const t=this.options[i].attributeName();e[t]=t===this._versionOptionName?this._version:this[t]}return e}return this._optionValues}_displayError(e,t,i){this._outputConfiguration.outputError(`${i}\n`,this._outputConfiguration.writeErr);if(typeof this._showHelpAfterError==="string"){this._outputConfiguration.writeErr(`${this._showHelpAfterError}\n`)}else if(this._showHelpAfterError){this._outputConfiguration.writeErr("\n");this.outputHelp({error:true})}this._exit(e,t,i)}_parseOptionsEnv(){this.options.forEach((e=>{if(e.envVar&&e.envVar in process.env){const t=e.attributeName();if(this.getOptionValue(t)===undefined||["default","config","env"].includes(this.getOptionValueSource(t))){if(e.required||e.optional){this.emit(`optionEnv:${e.name()}`,process.env[e.envVar])}else{this.emit(`optionEnv:${e.name()}`)}}}}))}missingArgument(e){const t=`error: missing required argument '${e}'`;this._displayError(1,"commander.missingArgument",t)}optionMissingArgument(e){const t=`error: option '${e.flags}' argument missing`;this._displayError(1,"commander.optionMissingArgument",t)}missingMandatoryOptionValue(e){const t=`error: required option '${e.flags}' not specified`;this._displayError(1,"commander.missingMandatoryOptionValue",t)}unknownOption(e){if(this._allowUnknownOption)return;let t="";if(e.startsWith("--")&&this._showSuggestionAfterError){let i=[];let n=this;do{const e=n.createHelp().visibleOptions(n).filter((e=>e.long)).map((e=>e.long));i=i.concat(e);n=n.parent}while(n&&!n._enablePositionalOptions);t=m(e,i)}const i=`error: unknown option '${e}'${t}`;this._displayError(1,"commander.unknownOption",i)}_excessArguments(e){if(this._allowExcessArguments)return;const t=this._args.length;const i=t===1?"":"s";const n=this.parent?` for '${this.name()}'`:"";const s=`error: too many arguments${n}. Expected ${t} argument${i} but got ${e.length}.`;this._displayError(1,"commander.excessArguments",s)}unknownCommand(){const e=this.args[0];let t="";if(this._showSuggestionAfterError){const i=[];this.createHelp().visibleCommands(this).forEach((e=>{i.push(e.name());if(e.alias())i.push(e.alias())}));t=m(e,i)}const i=`error: unknown command '${e}'${t}`;this._displayError(1,"commander.unknownCommand",i)}version(e,t,i){if(e===undefined)return this._version;this._version=e;t=t||"-V, --version";i=i||"output the version number";const n=this.createOption(t,i);this._versionOptionName=n.attributeName();this.options.push(n);this.on("option:"+n.name(),(()=>{this._outputConfiguration.writeOut(`${e}\n`);this._exit(0,"commander.version",e)}));return this}description(e,t){if(e===undefined&&t===undefined)return this._description;this._description=e;if(t){this._argsDescription=t}return this}alias(e){if(e===undefined)return this._aliases[0];let t=this;if(this.commands.length!==0&&this.commands[this.commands.length-1]._executableHandler){t=this.commands[this.commands.length-1]}if(e===t._name)throw new Error("Command alias can't be the same as its name");t._aliases.push(e);return this}aliases(e){if(e===undefined)return this._aliases;e.forEach((e=>this.alias(e)));return this}usage(e){if(e===undefined){if(this._usage)return this._usage;const e=this._args.map((e=>h(e)));return[].concat(this.options.length||this._hasHelpOption?"[options]":[],this.commands.length?"[command]":[],this._args.length?e:[]).join(" ")}this._usage=e;return this}name(e){if(e===undefined)return this._name;this._name=e;return this}helpInformation(e){const t=this.createHelp();if(t.helpWidth===undefined){t.helpWidth=e&&e.error?this._outputConfiguration.getErrHelpWidth():this._outputConfiguration.getOutHelpWidth()}return t.formatHelp(this,t)}_getHelpContext(e){e=e||{};const t={error:!!e.error};let i;if(t.error){i=e=>this._outputConfiguration.writeErr(e)}else{i=e=>this._outputConfiguration.writeOut(e)}t.write=e.write||i;t.command=this;return t}outputHelp(e){let t;if(typeof e==="function"){t=e;e=undefined}const i=this._getHelpContext(e);getCommandAndParents(this).reverse().forEach((e=>e.emit("beforeAllHelp",i)));this.emit("beforeHelp",i);let n=this.helpInformation(i);if(t){n=t(n);if(typeof n!=="string"&&!Buffer.isBuffer(n)){throw new Error("outputHelp callback must return a string or a Buffer")}}i.write(n);this.emit(this._helpLongFlag);this.emit("afterHelp",i);getCommandAndParents(this).forEach((e=>e.emit("afterAllHelp",i)))}helpOption(e,t){if(typeof e==="boolean"){this._hasHelpOption=e;return this}this._helpFlags=e||this._helpFlags;this._helpDescription=t||this._helpDescription;const i=p(this._helpFlags);this._helpShortFlag=i.shortFlag;this._helpLongFlag=i.longFlag;return this}help(e){this.outputHelp(e);let t=process.exitCode||0;if(t===0&&e&&typeof e!=="function"&&e.error){t=1}this._exit(t,"commander.help","(outputHelp)")}addHelpText(e,t){const i=["beforeAll","before","after","afterAll"];if(!i.includes(e)){throw new Error(`Unexpected value for position to addHelpText.\nExpecting one of '${i.join("', '")}'`)}const n=`${e}Help`;this.on(n,(e=>{let i;if(typeof t==="function"){i=t({error:e.error,command:e.command})}else{i=t}if(i){e.write(`${i}\n`)}}));return this}}function outputHelpIfRequested(e,t){const i=e._hasHelpOption&&t.find((t=>t===e._helpLongFlag||t===e._helpShortFlag));if(i){e.outputHelp();e._exit(0,"commander.helpDisplayed","(outputHelp)")}}function incrementNodeInspectorPort(e){return e.map((e=>{if(!e.startsWith("--inspect")){return e}let t;let i="127.0.0.1";let n="9229";let s;if((s=e.match(/^(--inspect(-brk)?)$/))!==null){t=s[1]}else if((s=e.match(/^(--inspect(-brk|-port)?)=([^:]+)$/))!==null){t=s[1];if(/^\d+$/.test(s[3])){n=s[3]}else{i=s[3]}}else if((s=e.match(/^(--inspect(-brk|-port)?)=([^:]+):(\d+)$/))!==null){t=s[1];i=s[3];n=s[4]}if(t&&n!=="0"){return`${t}=${i}:${parseInt(n)+1}`}return e}))}function getCommandAndParents(e){const t=[];for(let i=e;i;i=i.parent){t.push(i)}return t}t.Command=Command},967:(e,t)=>{class CommanderError extends Error{constructor(e,t,i){super(i);Error.captureStackTrace(this,this.constructor);this.name=this.constructor.name;this.code=t;this.exitCode=e;this.nestedError=undefined}}class InvalidArgumentError extends CommanderError{constructor(e){super(1,"commander.invalidArgument",e);Error.captureStackTrace(this,this.constructor);this.name=this.constructor.name}}t.CommanderError=CommanderError;t.InvalidArgumentError=InvalidArgumentError},34:(e,t,i)=>{const{humanReadableArgName:n}=i(969);class Help{constructor(){this.helpWidth=undefined;this.sortSubcommands=false;this.sortOptions=false}visibleCommands(e){const t=e.commands.filter((e=>!e._hidden));if(e._hasImplicitHelpCommand()){const[,i,n]=e._helpCommandnameAndArgs.match(/([^ ]+) *(.*)/);const s=e.createCommand(i).helpOption(false);s.description(e._helpCommandDescription);if(n)s.arguments(n);t.push(s)}if(this.sortSubcommands){t.sort(((e,t)=>e.name().localeCompare(t.name())))}return t}visibleOptions(e){const t=e.options.filter((e=>!e.hidden));const i=e._hasHelpOption&&e._helpShortFlag&&!e._findOption(e._helpShortFlag);const n=e._hasHelpOption&&!e._findOption(e._helpLongFlag);if(i||n){let s;if(!i){s=e.createOption(e._helpLongFlag,e._helpDescription)}else if(!n){s=e.createOption(e._helpShortFlag,e._helpDescription)}else{s=e.createOption(e._helpFlags,e._helpDescription)}t.push(s)}if(this.sortOptions){const getSortKey=e=>e.short?e.short.replace(/^-/,""):e.long.replace(/^--/,"");t.sort(((e,t)=>getSortKey(e).localeCompare(getSortKey(t))))}return t}visibleArguments(e){if(e._argsDescription){e._args.forEach((t=>{t.description=t.description||e._argsDescription[t.name()]||""}))}if(e._args.find((e=>e.description))){return e._args}return[]}subcommandTerm(e){const t=e._args.map((e=>n(e))).join(" ");return e._name+(e._aliases[0]?"|"+e._aliases[0]:"")+(e.options.length?" [options]":"")+(t?" "+t:"")}optionTerm(e){return e.flags}argumentTerm(e){return e.name()}longestSubcommandTermLength(e,t){return t.visibleCommands(e).reduce(((e,i)=>Math.max(e,t.subcommandTerm(i).length)),0)}longestOptionTermLength(e,t){return t.visibleOptions(e).reduce(((e,i)=>Math.max(e,t.optionTerm(i).length)),0)}longestArgumentTermLength(e,t){return t.visibleArguments(e).reduce(((e,i)=>Math.max(e,t.argumentTerm(i).length)),0)}commandUsage(e){let t=e._name;if(e._aliases[0]){t=t+"|"+e._aliases[0]}let i="";for(let t=e.parent;t;t=t.parent){i=t.name()+" "+i}return i+t+" "+e.usage()}commandDescription(e){return e.description()}subcommandDescription(e){return e.description()}optionDescription(e){const t=[];if(e.argChoices&&!e.negate){t.push(`choices: ${e.argChoices.map((e=>JSON.stringify(e))).join(", ")}`)}if(e.defaultValue!==undefined&&!e.negate){t.push(`default: ${e.defaultValueDescription||JSON.stringify(e.defaultValue)}`)}if(e.envVar!==undefined){t.push(`env: ${e.envVar}`)}if(t.length>0){return`${e.description} (${t.join(", ")})`}return e.description}argumentDescription(e){const t=[];if(e.argChoices){t.push(`choices: ${e.argChoices.map((e=>JSON.stringify(e))).join(", ")}`)}if(e.defaultValue!==undefined){t.push(`default: ${e.defaultValueDescription||JSON.stringify(e.defaultValue)}`)}if(t.length>0){const i=`(${t.join(", ")})`;if(e.description){return`${e.description} ${i}`}return i}return e.description}formatHelp(e,t){const i=t.padWidth(e,t);const n=t.helpWidth||80;const s=2;const r=2;function formatItem(e,o){if(o){const a=`${e.padEnd(i+r)}${o}`;return t.wrap(a,n-s,i+r)}return e}function formatList(e){return e.join("\n").replace(/^/gm," ".repeat(s))}let o=[`Usage: ${t.commandUsage(e)}`,""];const a=t.commandDescription(e);if(a.length>0){o=o.concat([a,""])}const h=t.visibleArguments(e).map((e=>formatItem(t.argumentTerm(e),t.argumentDescription(e))));if(h.length>0){o=o.concat(["Arguments:",formatList(h),""])}const l=t.visibleOptions(e).map((e=>formatItem(t.optionTerm(e),t.optionDescription(e))));if(l.length>0){o=o.concat(["Options:",formatList(l),""])}const u=t.visibleCommands(e).map((e=>formatItem(t.subcommandTerm(e),t.subcommandDescription(e))));if(u.length>0){o=o.concat(["Commands:",formatList(u),""])}return o.join("\n")}padWidth(e,t){return Math.max(t.longestOptionTermLength(e,t),t.longestSubcommandTermLength(e,t),t.longestArgumentTermLength(e,t))}wrap(e,t,i,n=40){if(e.match(/[\n]\s+/))return e;const s=t-i;if(s<n)return e;const r=e.substr(0,i);const o=e.substr(i);const a=" ".repeat(i);const h=new RegExp(".{1,"+(s-1)+"}([\\s]|$)|[^\\s]+?([\\s]|$)","g");const l=o.match(h)||[];return r+l.map(((e,t)=>{if(e.slice(-1)==="\n"){e=e.slice(0,e.length-1)}return(t>0?a:"")+e.trimRight()})).join("\n")}}t.Help=Help},278:(e,t,i)=>{const{InvalidArgumentError:n}=i(967);class Option{constructor(e,t){this.flags=e;this.description=t||"";this.required=e.includes("<");this.optional=e.includes("[");this.variadic=/\w\.\.\.[>\]]$/.test(e);this.mandatory=false;const i=splitOptionFlags(e);this.short=i.shortFlag;this.long=i.longFlag;this.negate=false;if(this.long){this.negate=this.long.startsWith("--no-")}this.defaultValue=undefined;this.defaultValueDescription=undefined;this.envVar=undefined;this.parseArg=undefined;this.hidden=false;this.argChoices=undefined}default(e,t){this.defaultValue=e;this.defaultValueDescription=t;return this}env(e){this.envVar=e;return this}argParser(e){this.parseArg=e;return this}makeOptionMandatory(e=true){this.mandatory=!!e;return this}hideHelp(e=true){this.hidden=!!e;return this}_concatValue(e,t){if(t===this.defaultValue||!Array.isArray(t)){return[e]}return t.concat(e)}choices(e){this.argChoices=e;this.parseArg=(t,i)=>{if(!e.includes(t)){throw new n(`Allowed choices are ${e.join(", ")}.`)}if(this.variadic){return this._concatValue(t,i)}return t};return this}name(){if(this.long){return this.long.replace(/^--/,"")}return this.short.replace(/^-/,"")}attributeName(){return camelcase(this.name().replace(/^no-/,""))}is(e){return this.short===e||this.long===e}}function camelcase(e){return e.split("-").reduce(((e,t)=>e+t[0].toUpperCase()+t.slice(1)))}function splitOptionFlags(e){let t;let i;const n=e.split(/[ |,]+/);if(n.length>1&&!/^[[<]/.test(n[1]))t=n.shift();i=n.shift();if(!t&&/^-[^-]$/.test(i)){t=i;i=undefined}return{shortFlag:t,longFlag:i}}t.Option=Option;t.splitOptionFlags=splitOptionFlags},461:(e,t)=>{const i=3;function editDistance(e,t){if(Math.abs(e.length-t.length)>i)return Math.max(e.length,t.length);const n=[];for(let t=0;t<=e.length;t++){n[t]=[t]}for(let e=0;e<=t.length;e++){n[0][e]=e}for(let i=1;i<=t.length;i++){for(let s=1;s<=e.length;s++){let r=1;if(e[s-1]===t[i-1]){r=0}else{r=1}n[s][i]=Math.min(n[s-1][i]+1,n[s][i-1]+1,n[s-1][i-1]+r);if(s>1&&i>1&&e[s-1]===t[i-2]&&e[s-2]===t[i-1]){n[s][i]=Math.min(n[s][i],n[s-2][i-2]+1)}}}return n[e.length][t.length]}function suggestSimilar(e,t){if(!t||t.length===0)return"";t=Array.from(new Set(t));const n=e.startsWith("--");if(n){e=e.slice(2);t=t.map((e=>e.slice(2)))}let s=[];let r=i;const o=.4;t.forEach((t=>{if(t.length<=1)return;const i=editDistance(e,t);const n=Math.max(e.length,t.length);const a=(n-i)/n;if(a>o){if(i<r){r=i;s=[t]}else if(i===r){s.push(t)}}}));s.sort(((e,t)=>e.localeCompare(t)));if(n){s=s.map((e=>`--${e}`))}if(s.length>1){return`\n(Did you mean one of ${s.join(", ")}?)`}if(s.length===1){return`\n(Did you mean ${s[0]}?)`}return""}t.suggestSimilar=suggestSimilar}};var t={};function __nccwpck_require__(i){var n=t[i];if(n!==undefined){return n.exports}var s=t[i]={exports:{}};var r=true;try{e[i](s,s.exports,__nccwpck_require__);r=false}finally{if(r)delete t[i]}return s.exports}if(typeof __nccwpck_require__!=="undefined")__nccwpck_require__.ab=__dirname+"/";var i=__nccwpck_require__(922);module.exports=i})();