| 7935 | `)}}hbY.Help=UFK});var c_7=m((IbY)=>{var{InvalidArgumentError:CbY}=eq8();class QFK{constructor(q,K){this.flags=q,this.description=K||"",this.required=q.includes("<"),this.optional=q.includes("["),this.variadic=/\w\.\.\.[>\]]$/.test(q),this.mandatory=!1;let _=xbY(q);if(this.short=_.shortFlag,this.long=_.longFlag,this.negate=!1,this.long)this.negate=this.long.startsWith("--no-");this.defaultValue=void 0,this.defaultValueDescription=void 0,this.presetArg=void 0,this.envVar=void 0,this.parseArg=void 0,this.hidden=!1,this.argChoices=void 0,this.conflictsWith=[],this.implied=void 0}default(q,K){return this.defaultValue=q,this.defaultValueDescription=K,this}preset(q){return this.presetArg=q,this}conflicts(q){return this.conflictsWith=this.conflictsWith.concat(q),this}implies(q){let K=q;if(typeof q==="string")K={[q]:!0};return this.implied=Object.assign(this.implied||{},K),this}env(q){return this.envVar=q,this}argParser(q){return this.parseArg=q,this}makeOptionMandatory(q=!0){return this.mandatory=!!q,this}hideHelp(q=!0){return this.hidden=!!q,this}_concatValue(q,K){if(K===this.defaultValue||!Array.isArray(K))return[q];return K.concat(q)}choices(q){return this.argChoices=q.slice(),this.parseArg=(K,_)=>{if(!this.argChoices.includes(K))throw new CbY(`Allowed choices are ${this.argChoices.join(", ")}.`);if(this.variadic)return this._concatValue(K,_);return K},this}name(){if(this.long)return this.long.replace(/^--/,"");return this.short.replace(/^-/,"")}attributeName(){return bbY(this.name().replace(/^no-/,""))}is(q){return this.short===q||this.long===q}isBoolean(){return!this.required&&!this.optional&&!this.negate}}class dFK{constructor(q){this.positiveOptions=new Map,this.negativeOptions=new Map,this.dualOptions=new Set,q.forEach((K)=>{if(K.negate)this.negativeOptions.set(K.attributeName(),K);else this.positiveOptions.set(K.attributeName(),K)}),this.negativeOptions.forEach((K,_)=>{if(this.positiveOptions.has(_))this.dualOptions.add(_)})}valueFromOption(q,K){let _=K.attributeName();if(!this.dualOptions.has(_))return!0;let z=this.negativeOptions.get(_).presetArg,Y=z!==void 0?z:!1;return K.negate===(Y===q)}}function bbY(q){return q.split("-").reduce((K,_)=>{return K+_[0].toUpperCase()+_.slice(1)})}function xbY(q){let K,_,z=q.split(/[ |,]+/);if(z.length>1&&!/^[[<]/.test(z[1]))K=z.shift();if(_=z.shift(),!K&&/^-[^-]$/.test(_))K=_,_=void 0;return{shortFlag:K,longFlag:_}}IbY.Option=QFK;IbY.DualOptions=dFK});var cFK=m((gbY)=>{function pbY(q,K){if(Math.abs(q.length-K.length)>3)return Math.max(q.length,K.length);let _=[];for(let z=0;z<=q.length;z++)_[z]=[z];for(let z=0;z<=K.length;z++)_[0][z]=z;for(let z=1;z<=K.length;z++)for(let Y=1;Y<=q.length;Y++){let $=1;if(q[Y-1]===K[z-1])$=0;else $=1;if(_[Y][z]=Math.min(_[Y-1][z]+1,_[Y][z-1]+1,_[Y-1][z-1]+$),Y>1&&z>1&&q[Y-1]===K[z-2]&&q[Y-2]===K[z-1])_[Y][z]=Math.min(_[Y][z],_[Y-2][z-2]+1)}return _[q.length][K.length]}function BbY(q,K){if(!K||K.length===0)return"";K=Array.from(new Set(K));let _=q.startsWith("--");if(_)q=q.slice(2),K=K.map((A)=>A.slice(2));let z=[],Y=3,$=0.4;if(K.forEach((A)=>{if(A.length<=1)return;let O=pbY(q,A),w=Math.max(q.length,A.length);if((w-O)/w>$){if(O<Y)Y=O,z=[A];else if(O===Y)z.push(A)}}),z.sort((A,O)=>A.localeCompare(O)),_)z=z.map((A)=>`--${A}`);if(z.length>1)return` |
| 7936 | (Did you mean one of ${z.join(", ")}?)`;if(z.length===1)return` |
| 7937 | (Did you mean ${z[0]}?)`;return""}gbY.suggestSimilar=BbY});var rFK=m((nbY)=>{var UbY=U6("node:events").EventEmitter,l_7=U6("node:child_process"),hs=U6("node:path"),n_7=U6("node:fs"),pJ=U6("node:process"),{Argument:QbY,humanReadableArgName:dbY}=iQ8(),{CommanderError:i_7}=eq8(),{Help:cbY}=d_7(),{Option:lFK,DualOptions:lbY}=c_7(),{suggestSimilar:nFK}=cFK();class r_7 extends UbY{constructor(q){super();this.commands=[],this.options=[],this.parent=null,this._allowUnknownOption=!1,this._allowExcessArguments=!0,this.registeredArguments=[],this._args=this.registeredArguments,this.args=[],this.rawArgs=[],this.processedArgs=[],this._scriptPath=null,this._name=q||"",this._optionValues={},this._optionValueSources={},this._storeOptionsAsProperties=!1,this._actionHandler=null,this._executableHandler=!1,this._executableFile=null,this._executableDir=null,this._defaultCommandName=null,this._exitCallback=null,this._aliases=[],this._combineFlagAndOptionalValue=!0,this._description="",this._summary="",this._argsDescription=void 0,this._enablePositionalOptions=!1,this._passThroughOptions=!1,this._lifeCycleHooks={},this._showHelpAfterError=!1,this._showSuggestionAfterError=!0,this._outputConfiguration={writeOut:(K)=>pJ.stdout.write(K),writeErr:(K)=>pJ.stderr.write(K),getOutHelpWidth:()=>pJ.stdout.isTTY?pJ.stdout.columns:void 0,getErrHelpWidth:()=>pJ.stderr.isTTY?pJ.stderr.columns:void 0,outputError:(K,_)=>_(K)},this._hidden=!1,this._helpOption=void 0,this._addImplicitHelpCommand=void 0,this._helpCommand=void 0,this._helpConfiguration={}}copyInheritedSettings(q){return this._outputConfiguration=q._outputConfiguration,this._helpOption=q._helpOption,this._helpCommand=q._helpCommand,this._helpConfiguration=q._helpConfiguration,this._exitCallback=q._exitCallback,this._storeOptionsAsProperties=q._storeOptionsAsProperties,this._combineFlagAndOptionalValue=q._combineFlagAndOptionalValue,this._allowExcessArguments=q._allowExcessArguments,this._enablePositionalOptions=q._enablePositionalOptions,this._showHelpAfterError=q._showHelpAfterError,this._showSuggestionAfterError=q._showSuggestionAfterError,this}_getCommandAndAncestors(){let q=[];for(let K=this;K;K=K.parent)q.push(K);return q}command(q,K,_){let z=K,Y=_;if(typeof z==="object"&&z!==null)Y=z,z=null;Y=Y||{};let[,$,A]=q.match(/([^ ]+) *(.*)/),O=this.createCommand($);if(z)O.description(z),O._executableHandler=!0;if(Y.isDefault)this._defaultCommandName=O._name;if(O._hidden=!!(Y.noHelp||Y.hidden),O._executableFile=Y.executableFile||null,A)O.arguments(A);if(this._registerCommand(O),O.parent=this,O.copyInheritedSettings(this),z)return this;return O}createCommand(q){return new r_7(q)}createHelp(){return Object.assign(new cbY,this.configureHelp())}configureHelp(q){if(q===void 0)return this._helpConfiguration;return this._helpConfiguration=q,this}configureOutput(q){if(q===void 0)return this._outputConfiguration;return Object.assign(this._outputConfiguration,q),this}showHelpAfterError(q=!0){if(typeof q!=="string")q=!!q;return this._showHelpAfterError=q,this}showSuggestionAfterError(q=!0){return this._showSuggestionAfterError=!!q,this}addCommand(q,K){if(!q._name)throw Error(`Command passed to .addCommand() must have a name |
| 7938 | - specify the name in Command constructor or using .name()`);if(K=K||{},K.isDefault)this._defaultCommandName=q._name;if(K.noHelp||K.hidden)q._hidden=!0;return this._registerCommand(q),q.parent=this,q._checkForBrokenPassThrough(),this}createArgument(q,K){return new QbY(q,K)}argument(q,K,_,z){let Y=this.createArgument(q,K);if(typeof _==="function")Y.default(z).argParser(_);else Y.default(_);return this.addArgument(Y),this}arguments(q){return q.trim().split(/ +/).forEach((K)=>{this.argument(K)}),this}addArgument(q){let K=this.registeredArguments.slice(-1)[0];if(K&&K.variadic)throw Error(`only the last argument can be variadic '${K.name()}'`);if(q.required&&q.defaultValue!==void 0&&q.parseArg===void 0)throw Error(`a default value for a required argument is never used: '${q.name()}'`);return this.registeredArguments.push(q),this}helpCommand(q,K){if(typeof q==="boolean")return this._addImplicitHelpCommand=q,this;q=q??"help [command]";let[,_,z]=q.match(/([^ ]+) *(.*)/),Y=K??"display help for command",$=this.createCommand(_);if($.helpOption(!1),z)$.arguments(z);if(Y)$.description(Y);return this._addImplicitHelpCommand=!0,this._helpCommand=$,this}addHelpCommand(q,K){if(typeof q!=="object")return this.helpCommand(q,K),this;return this._addImplicitHelpCommand=!0,this._helpCommand=q,this}_getHelpCommand(){if(this._addImplicitHelpCommand??(this.commands.length&&!this._actionHandler&&!this._findCommand("help"))){if(this._helpCommand===void 0)this.helpCommand(void 0,void 0);return this._helpCommand}return null}hook(q,K){let _=["preSubcommand","preAction","postAction"];if(!_.includes(q))throw Error(`Unexpected value for event passed to hook : '${q}'. |
| 7939 | Expecting one of '${_.join("', '")}'`);if(this._lifeCycleHooks[q])this._lifeCycleHooks[q].push(K);else this._lifeCycleHooks[q]=[K];return this}exitOverride(q){if(q)this._exitCallback=q;else this._exitCallback=(K)=>{if(K.code!=="commander.executeSubCommandAsync")throw K};return this}_exit(q,K,_){if(this._exitCallback)this._exitCallback(new i_7(q,K,_));pJ.exit(q)}action(q){let K=(_)=>{let z=this.registeredArguments.length,Y=_.slice(0,z);if(this._storeOptionsAsProperties)Y[z]=this;else Y[z]=this.opts();return Y.push(this),q.apply(this,Y)};return this._actionHandler=K,this}createOption(q,K){return new lFK(q,K)}_callParseArg(q,K,_,z){try{return q.parseArg(K,_)}catch(Y){if(Y.code==="commander.invalidArgument"){let $=`${z} ${Y.message}`;this.error($,{exitCode:Y.exitCode,code:Y.code})}throw Y}}_registerOption(q){let K=q.short&&this._findOption(q.short)||q.long&&this._findOption(q.long);if(K){let _=q.long&&this._findOption(q.long)?q.long:q.short;throw Error(`Cannot add option '${q.flags}'${this._name&&` to command '${this._name}'`} due to conflicting flag '${_}' |
| 7940 | - already used by option '${K.flags}'`)}this.options.push(q)}_registerCommand(q){let K=(z)=>{return[z.name()].concat(z.aliases())},_=K(q).find((z)=>this._findCommand(z));if(_){let z=K(this._findCommand(_)).join("|"),Y=K(q).join("|");throw Error(`cannot add command '${Y}' as already have command '${z}'`)}this.commands.push(q)}addOption(q){this._registerOption(q);let K=q.name(),_=q.attributeName();if(q.negate){let Y=q.long.replace(/^--no-/,"--");if(!this._findOption(Y))this.setOptionValueWithSource(_,q.defaultValue===void 0?!0:q.defaultValue,"default")}else if(q.defaultValue!==void 0)this.setOptionValueWithSource(_,q.defaultValue,"default");let z=(Y,$,A)=>{if(Y==null&&q.presetArg!==void 0)Y=q.presetArg;let O=this.getOptionValue(_);if(Y!==null&&q.parseArg)Y=this._callParseArg(q,Y,O,$);else if(Y!==null&&q.variadic)Y=q._concatValue(Y,O);if(Y==null)if(q.negate)Y=!1;else if(q.isBoolean()||q.optional)Y=!0;else Y="";this.setOptionValueWithSource(_,Y,A)};if(this.on("option:"+K,(Y)=>{let $=`error: option '${q.flags}' argument '${Y}' is invalid.`;z(Y,$,"cli")}),q.envVar)this.on("optionEnv:"+K,(Y)=>{let $=`error: option '${q.flags}' value '${Y}' from env '${q.envVar}' is invalid.`;z(Y,$,"env")});return this}_optionEx(q,K,_,z,Y){if(typeof K==="object"&&K instanceof lFK)throw Error("To add an Option object use addOption() instead of option() or requiredOption()");let $=this.createOption(K,_);if($.makeOptionMandatory(!!q.mandatory),typeof z==="function")$.default(Y).argParser(z);else if(z instanceof RegExp){let A=z;z=(O,w)=>{let j=A.exec(O);return j?j[0]:w},$.default(Y).argParser(z)}else $.default(z);return this.addOption($)}option(q,K,_,z){return this._optionEx({},q,K,_,z)}requiredOption(q,K,_,z){return this._optionEx({mandatory:!0},q,K,_,z)}combineFlagAndOptionalValue(q=!0){return this._combineFlagAndOptionalValue=!!q,this}allowUnknownOption(q=!0){return this._allowUnknownOption=!!q,this}allowExcessArguments(q=!0){return this._allowExcessArguments=!!q,this}enablePositionalOptions(q=!0){return this._enablePositionalOptions=!!q,this}passThroughOptions(q=!0){return this._passThroughOptions=!!q,this._checkForBrokenPassThrough(),this}_checkForBrokenPassThrough(){if(this.parent&&this._passThroughOptions&&!this.parent._enablePositionalOptions)throw Error(`passThroughOptions cannot be used for '${this._name}' without turning on enablePositionalOptions for parent command(s)`)}storeOptionsAsProperties(q=!0){if(this.options.length)throw Error("call .storeOptionsAsProperties() before adding options");if(Object.keys(this._optionValues).length)throw Error("call .storeOptionsAsProperties() before setting option values");return this._storeOptionsAsProperties=!!q,this}getOptionValue(q){if(this._storeOptionsAsProperties)return this[q];return this._optionValues[q]}setOptionValue(q,K){return this.setOptionValueWithSource(q,K,void 0)}setOptionValueWithSource(q,K,_){if(this._storeOptionsAsProperties)this[q]=K;else this._optionValues[q]=K;return this._optionValueSources[q]=_,this}getOptionValueSource(q){return this._optionValueSources[q]}getOptionValueSourceWithGlobals(q){let K;return this._getCommandAndAncestors().forEach((_)=>{if(_.getOptionValueSource(q)!==void 0)K=_.getOptionValueSource(q)}),K}_prepareUserArgs(q,K){if(q!==void 0&&!Array.isArray(q))throw Error("first parameter to parse must be array or undefined");if(K=K||{},q===void 0&&K.from===void 0){if(pJ.versions?.electron)K.from="electron";let z=pJ.execArgv??[];if(z.includes("-e")||z.includes("--eval")||z.includes("-p")||z.includes("--print"))K.from="eval"}if(q===void 0)q=pJ.argv;this.rawArgs=q.slice();let _;switch(K.from){case void 0:case"node":this._scriptPath=q[1],_=q.slice(2);break;case"electron":if(pJ.defaultApp)this._scriptPath=q[1],_=q.slice(2);else _=q.slice(1);break;case"user":_=q.slice(0);break;case"eval":_=q.slice(1);break;default:throw Error(`unexpected parse option { from: '${K.from}' }`)}if(!this._name&&this._scriptPath)this.nameFromFilename(this._scriptPath);return this._name=this._name||"program",_}parse(q,K){let _=this._prepareUserArgs(q,K);return this._parseCommand([],_),this}async parseAsync(q,K){let _=this._prepareUserArgs(q,K);return await this._parseCommand([],_),this}_executeSubCommand(q,K){K=K.slice();let _=!1,z=[".js",".ts",".tsx",".mjs",".cjs"];function Y(j,H){let J=hs.resolve(j,H);if(n_7.existsSync(J))return J;if(z.includes(hs.extname(H)))return;let M=z.find((X)=>n_7.existsSync(`${J}${X}`));if(M)return`${J}${M}`;return}this._checkForMissingMandatoryOptions(),this._checkForConflictingOptions();let $=q._executableFile||`${this._name}-${q._name}`,A=this._executableDir||"";if(this._scriptPath){let j;try{j=n_7.realpathSync(this._scriptPath)}catch(H){j=this._scriptPath}A=hs.resolve(hs.dirname(j),A)}if(A){let j=Y(A,$);if(!j&&!q._executableFile&&this._scriptPath){let H=hs.basename(this._scriptPath,hs.extname(this._scriptPath));if(H!==this._name)j=Y(A,`${H}-${q._name}`)}$=j||$}_=z.includes(hs.extname($));let O;if(pJ.platform!=="win32")if(_)K.unshift($),K=iFK(pJ.execArgv).concat(K),O=l_7.spawn(pJ.argv[0],K,{stdio:"inherit"});else O=l_7.spawn($,K,{stdio:"inherit"});else K.unshift($),K=iFK(pJ.execArgv).concat(K),O=l_7.spawn(pJ.execPath,K,{stdio:"inherit"});if(!O.killed)["SIGUSR1","SIGUSR2","SIGTERM","SIGINT","SIGHUP"].forEach((H)=>{pJ.on(H,()=>{if(O.killed===!1&&O.exitCode===null)O.kill(H)})});let w=this._exitCallback;O.on("close",(j)=>{if(j=j??1,!w)pJ.exit(j);else w(new i_7(j,"commander.executeSubCommandAsync","(close)"))}),O.on("error",(j)=>{if(j.code==="ENOENT"){let H=A?`searched for local subcommand relative to directory '${A}'`:"no directory for search for local subcommand, use .executableDir() to supply a custom directory",J=`'${$}' does not exist |