UNPKG

create-bunkit

Version:

CLI to scaffold a new project from the bunkit template

33 lines 101 kB
#!/usr/bin/env bun // @bun var A1=Object.create;var{getPrototypeOf:P1,defineProperty:r,getOwnPropertyNames:T1}=Object;var I1=Object.prototype.hasOwnProperty;var N1=(_,F,B)=>{B=_!=null?A1(P1(_)):{};let E=F||!_||!_.__esModule?r(B,"default",{value:_,enumerable:!0}):B;for(let $ of T1(_))if(!I1.call(E,$))r(E,$,{get:()=>_[$],enumerable:!0});return E};var V=(_,F)=>()=>(F||_((F={exports:{}}).exports,F),F.exports);var w1=(_,F)=>{for(var B in F)r(_,B,{get:F[B],enumerable:!0,configurable:!0,set:(E)=>F[B]=()=>E})};var C=import.meta.require;var b=V((l1)=>{class e extends Error{constructor(_,F,B){super(B);Error.captureStackTrace(this,this.constructor),this.name=this.constructor.name,this.code=F,this.exitCode=_,this.nestedError=void 0}}class C0 extends e{constructor(_){super(1,"commander.invalidArgument",_);Error.captureStackTrace(this,this.constructor),this.name=this.constructor.name}}l1.CommanderError=e;l1.InvalidArgumentError=C0});var g=V((n1)=>{var{InvalidArgumentError:a1}=b();class O0{constructor(_,F){switch(this.description=F||"",this.variadic=!1,this.parseArg=void 0,this.defaultValue=void 0,this.defaultValueDescription=void 0,this.argChoices=void 0,_[0]){case"<":this.required=!0,this._name=_.slice(1,-1);break;case"[":this.required=!1,this._name=_.slice(1,-1);break;default:this.required=!0,this._name=_;break}if(this._name.endsWith("..."))this.variadic=!0,this._name=this._name.slice(0,-3)}name(){return this._name}_collectValue(_,F){if(F===this.defaultValue||!Array.isArray(F))return[_];return F.push(_),F}default(_,F){return this.defaultValue=_,this.defaultValueDescription=F,this}argParser(_){return this.parseArg=_,this}choices(_){return this.argChoices=_.slice(),this.parseArg=(F,B)=>{if(!this.argChoices.includes(F))throw new a1(`Allowed choices are ${this.argChoices.join(", ")}.`);if(this.variadic)return this._collectValue(F,B);return F},this}argRequired(){return this.required=!0,this}argOptional(){return this.required=!1,this}}function r1(_){let F=_.name()+(_.variadic===!0?"...":"");return _.required?"<"+F+">":"["+F+"]"}n1.Argument=O0;n1.humanReadableArgName=r1});var _0=V((e1)=>{var{humanReadableArgName:o1}=g();class y0{constructor(){this.helpWidth=void 0,this.minWidthToWrap=40,this.sortSubcommands=!1,this.sortOptions=!1,this.showGlobalOptions=!1}prepareContext(_){this.helpWidth=this.helpWidth??_.helpWidth??80}visibleCommands(_){let F=_.commands.filter((E)=>!E._hidden),B=_._getHelpCommand();if(B&&!B._hidden)F.push(B);if(this.sortSubcommands)F.sort((E,$)=>{return E.name().localeCompare($.name())});return F}compareOptions(_,F){let B=(E)=>{return E.short?E.short.replace(/^-/,""):E.long.replace(/^--/,"")};return B(_).localeCompare(B(F))}visibleOptions(_){let F=_.options.filter((E)=>!E.hidden),B=_._getHelpOption();if(B&&!B.hidden){let E=B.short&&_._findOption(B.short),$=B.long&&_._findOption(B.long);if(!E&&!$)F.push(B);else if(B.long&&!$)F.push(_.createOption(B.long,B.description));else if(B.short&&!E)F.push(_.createOption(B.short,B.description))}if(this.sortOptions)F.sort(this.compareOptions);return F}visibleGlobalOptions(_){if(!this.showGlobalOptions)return[];let F=[];for(let B=_.parent;B;B=B.parent){let E=B.options.filter(($)=>!$.hidden);F.push(...E)}if(this.sortOptions)F.sort(this.compareOptions);return F}visibleArguments(_){if(_._argsDescription)_.registeredArguments.forEach((F)=>{F.description=F.description||_._argsDescription[F.name()]||""});if(_.registeredArguments.find((F)=>F.description))return _.registeredArguments;return[]}subcommandTerm(_){let F=_.registeredArguments.map((B)=>o1(B)).join(" ");return _._name+(_._aliases[0]?"|"+_._aliases[0]:"")+(_.options.length?" [options]":"")+(F?" "+F:"")}optionTerm(_){return _.flags}argumentTerm(_){return _.name()}longestSubcommandTermLength(_,F){return F.visibleCommands(_).reduce((B,E)=>{return Math.max(B,this.displayWidth(F.styleSubcommandTerm(F.subcommandTerm(E))))},0)}longestOptionTermLength(_,F){return F.visibleOptions(_).reduce((B,E)=>{return Math.max(B,this.displayWidth(F.styleOptionTerm(F.optionTerm(E))))},0)}longestGlobalOptionTermLength(_,F){return F.visibleGlobalOptions(_).reduce((B,E)=>{return Math.max(B,this.displayWidth(F.styleOptionTerm(F.optionTerm(E))))},0)}longestArgumentTermLength(_,F){return F.visibleArguments(_).reduce((B,E)=>{return Math.max(B,this.displayWidth(F.styleArgumentTerm(F.argumentTerm(E))))},0)}commandUsage(_){let F=_._name;if(_._aliases[0])F=F+"|"+_._aliases[0];let B="";for(let E=_.parent;E;E=E.parent)B=E.name()+" "+B;return B+F+" "+_.usage()}commandDescription(_){return _.description()}subcommandDescription(_){return _.summary()||_.description()}optionDescription(_){let F=[];if(_.argChoices)F.push(`choices: ${_.argChoices.map((B)=>JSON.stringify(B)).join(", ")}`);if(_.defaultValue!==void 0){if(_.required||_.optional||_.isBoolean()&&typeof _.defaultValue==="boolean")F.push(`default: ${_.defaultValueDescription||JSON.stringify(_.defaultValue)}`)}if(_.presetArg!==void 0&&_.optional)F.push(`preset: ${JSON.stringify(_.presetArg)}`);if(_.envVar!==void 0)F.push(`env: ${_.envVar}`);if(F.length>0){let B=`(${F.join(", ")})`;if(_.description)return`${_.description} ${B}`;return B}return _.description}argumentDescription(_){let F=[];if(_.argChoices)F.push(`choices: ${_.argChoices.map((B)=>JSON.stringify(B)).join(", ")}`);if(_.defaultValue!==void 0)F.push(`default: ${_.defaultValueDescription||JSON.stringify(_.defaultValue)}`);if(F.length>0){let B=`(${F.join(", ")})`;if(_.description)return`${_.description} ${B}`;return B}return _.description}formatItemList(_,F,B){if(F.length===0)return[];return[B.styleTitle(_),...F,""]}groupItems(_,F,B){let E=new Map;return _.forEach(($)=>{let q=B($);if(!E.has(q))E.set(q,[])}),F.forEach(($)=>{let q=B($);if(!E.has(q))E.set(q,[]);E.get(q).push($)}),E}formatHelp(_,F){let B=F.padWidth(_,F),E=F.helpWidth??80;function $(X,D){return F.formatItem(X,B,D,F)}let q=[`${F.styleTitle("Usage:")} ${F.styleUsage(F.commandUsage(_))}`,""],J=F.commandDescription(_);if(J.length>0)q=q.concat([F.boxWrap(F.styleCommandDescription(J),E),""]);let z=F.visibleArguments(_).map((X)=>{return $(F.styleArgumentTerm(F.argumentTerm(X)),F.styleArgumentDescription(F.argumentDescription(X)))});if(q=q.concat(this.formatItemList("Arguments:",z,F)),this.groupItems(_.options,F.visibleOptions(_),(X)=>X.helpGroupHeading??"Options:").forEach((X,D)=>{let T=X.map((W)=>{return $(F.styleOptionTerm(F.optionTerm(W)),F.styleOptionDescription(F.optionDescription(W)))});q=q.concat(this.formatItemList(D,T,F))}),F.showGlobalOptions){let X=F.visibleGlobalOptions(_).map((D)=>{return $(F.styleOptionTerm(F.optionTerm(D)),F.styleOptionDescription(F.optionDescription(D)))});q=q.concat(this.formatItemList("Global Options:",X,F))}return this.groupItems(_.commands,F.visibleCommands(_),(X)=>X.helpGroup()||"Commands:").forEach((X,D)=>{let T=X.map((W)=>{return $(F.styleSubcommandTerm(F.subcommandTerm(W)),F.styleSubcommandDescription(F.subcommandDescription(W)))});q=q.concat(this.formatItemList(D,T,F))}),q.join(` `)}displayWidth(_){return b0(_).length}styleTitle(_){return _}styleUsage(_){return _.split(" ").map((F)=>{if(F==="[options]")return this.styleOptionText(F);if(F==="[command]")return this.styleSubcommandText(F);if(F[0]==="["||F[0]==="<")return this.styleArgumentText(F);return this.styleCommandText(F)}).join(" ")}styleCommandDescription(_){return this.styleDescriptionText(_)}styleOptionDescription(_){return this.styleDescriptionText(_)}styleSubcommandDescription(_){return this.styleDescriptionText(_)}styleArgumentDescription(_){return this.styleDescriptionText(_)}styleDescriptionText(_){return _}styleOptionTerm(_){return this.styleOptionText(_)}styleSubcommandTerm(_){return _.split(" ").map((F)=>{if(F==="[options]")return this.styleOptionText(F);if(F[0]==="["||F[0]==="<")return this.styleArgumentText(F);return this.styleSubcommandText(F)}).join(" ")}styleArgumentTerm(_){return this.styleArgumentText(_)}styleOptionText(_){return _}styleArgumentText(_){return _}styleSubcommandText(_){return _}styleCommandText(_){return _}padWidth(_,F){return Math.max(F.longestOptionTermLength(_,F),F.longestGlobalOptionTermLength(_,F),F.longestSubcommandTermLength(_,F),F.longestArgumentTermLength(_,F))}preformatted(_){return/\n[^\S\r\n]/.test(_)}formatItem(_,F,B,E){let q=" ".repeat(2);if(!B)return q+_;let J=_.padEnd(F+_.length-E.displayWidth(_)),z=2,Q=(this.helpWidth??80)-F-z-2,X;if(Q<this.minWidthToWrap||E.preformatted(B))X=B;else X=E.boxWrap(B,Q).replace(/\n/g,` `+" ".repeat(F+z));return q+J+" ".repeat(z)+X.replace(/\n/g,` ${q}`)}boxWrap(_,F){if(F<this.minWidthToWrap)return _;let B=_.split(/\r\n|\n/),E=/[\s]*[^\s]+/g,$=[];return B.forEach((q)=>{let J=q.match(E);if(J===null){$.push("");return}let z=[J.shift()],Z=this.displayWidth(z[0]);J.forEach((Q)=>{let X=this.displayWidth(Q);if(Z+X<=F){z.push(Q),Z+=X;return}$.push(z.join(""));let D=Q.trimStart();z=[D],Z=this.displayWidth(D)}),$.push(z.join(""))}),$.join(` `)}}function b0(_){let F=/\x1b\[\d*(;\d*)*m/g;return _.replace(F,"")}e1.Help=y0;e1.stripColor=b0});var F0=V(($2)=>{var{InvalidArgumentError:B2}=b();class v0{constructor(_,F){this.flags=_,this.description=F||"",this.required=_.includes("<"),this.optional=_.includes("["),this.variadic=/\w\.\.\.[>\]]$/.test(_),this.mandatory=!1;let B=E2(_);if(this.short=B.shortFlag,this.long=B.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,this.helpGroupHeading=void 0}default(_,F){return this.defaultValue=_,this.defaultValueDescription=F,this}preset(_){return this.presetArg=_,this}conflicts(_){return this.conflictsWith=this.conflictsWith.concat(_),this}implies(_){let F=_;if(typeof _==="string")F={[_]:!0};return this.implied=Object.assign(this.implied||{},F),this}env(_){return this.envVar=_,this}argParser(_){return this.parseArg=_,this}makeOptionMandatory(_=!0){return this.mandatory=!!_,this}hideHelp(_=!0){return this.hidden=!!_,this}_collectValue(_,F){if(F===this.defaultValue||!Array.isArray(F))return[_];return F.push(_),F}choices(_){return this.argChoices=_.slice(),this.parseArg=(F,B)=>{if(!this.argChoices.includes(F))throw new B2(`Allowed choices are ${this.argChoices.join(", ")}.`);if(this.variadic)return this._collectValue(F,B);return F},this}name(){if(this.long)return this.long.replace(/^--/,"");return this.short.replace(/^-/,"")}attributeName(){if(this.negate)return f0(this.name().replace(/^no-/,""));return f0(this.name())}helpGroup(_){return this.helpGroupHeading=_,this}is(_){return this.short===_||this.long===_}isBoolean(){return!this.required&&!this.optional&&!this.negate}}class x0{constructor(_){this.positiveOptions=new Map,this.negativeOptions=new Map,this.dualOptions=new Set,_.forEach((F)=>{if(F.negate)this.negativeOptions.set(F.attributeName(),F);else this.positiveOptions.set(F.attributeName(),F)}),this.negativeOptions.forEach((F,B)=>{if(this.positiveOptions.has(B))this.dualOptions.add(B)})}valueFromOption(_,F){let B=F.attributeName();if(!this.dualOptions.has(B))return!0;let E=this.negativeOptions.get(B).presetArg,$=E!==void 0?E:!1;return F.negate===($===_)}}function f0(_){return _.split("-").reduce((F,B)=>{return F+B[0].toUpperCase()+B.slice(1)})}function E2(_){let F,B,E=/^-[^-]$/,$=/^--[^-]/,q=_.split(/[ |,]+/).concat("guard");if(E.test(q[0]))F=q.shift();if($.test(q[0]))B=q.shift();if(!F&&E.test(q[0]))F=q.shift();if(!F&&$.test(q[0]))F=B,B=q.shift();if(q[0].startsWith("-")){let J=q[0],z=`option creation failed due to '${J}' in option flags '${_}'`;if(/^-[^-][^-]/.test(J))throw new Error(`${z} - a short flag is a single dash and a single character - either use a single dash and a single character (for a short flag) - or use a double dash for a long option (and can have two, like '--ws, --workspace')`);if(E.test(J))throw new Error(`${z} - too many short flags`);if($.test(J))throw new Error(`${z} - too many long flags`);throw new Error(`${z} - unrecognised flag format`)}if(F===void 0&&B===void 0)throw new Error(`option creation failed due to no flags found in '${_}'.`);return{shortFlag:F,longFlag:B}}$2.Option=v0;$2.DualOptions=x0});var h0=V((X2)=>{function z2(_,F){if(Math.abs(_.length-F.length)>3)return Math.max(_.length,F.length);let B=[];for(let E=0;E<=_.length;E++)B[E]=[E];for(let E=0;E<=F.length;E++)B[0][E]=E;for(let E=1;E<=F.length;E++)for(let $=1;$<=_.length;$++){let q=1;if(_[$-1]===F[E-1])q=0;else q=1;if(B[$][E]=Math.min(B[$-1][E]+1,B[$][E-1]+1,B[$-1][E-1]+q),$>1&&E>1&&_[$-1]===F[E-2]&&_[$-2]===F[E-1])B[$][E]=Math.min(B[$][E],B[$-2][E-2]+1)}return B[_.length][F.length]}function Q2(_,F){if(!F||F.length===0)return"";F=Array.from(new Set(F));let B=_.startsWith("--");if(B)_=_.slice(2),F=F.map((J)=>J.slice(2));let E=[],$=3,q=0.4;if(F.forEach((J)=>{if(J.length<=1)return;let z=z2(_,J),Z=Math.max(_.length,J.length);if((Z-z)/Z>q){if(z<$)$=z,E=[J];else if(z===$)E.push(J)}}),E.sort((J,z)=>J.localeCompare(z)),B)E=E.map((J)=>`--${J}`);if(E.length>1)return` (Did you mean one of ${E.join(", ")}?)`;if(E.length===1)return` (Did you mean ${E[0]}?)`;return""}X2.suggestSimilar=Q2});var m0=V((R2)=>{var U2=C("events").EventEmitter,B0=C("child_process"),L=C("path"),c=C("fs"),G=C("process"),{Argument:D2,humanReadableArgName:G2}=g(),{CommanderError:E0}=b(),{Help:M2,stripColor:Y2}=_0(),{Option:u0,DualOptions:H2}=F0(),{suggestSimilar:g0}=h0();class q0 extends U2{constructor(_){super();this.commands=[],this.options=[],this.parent=null,this._allowUnknownOption=!1,this._allowExcessArguments=!1,this.registeredArguments=[],this._args=this.registeredArguments,this.args=[],this.rawArgs=[],this.processedArgs=[],this._scriptPath=null,this._name=_||"",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._savedState=null,this._outputConfiguration={writeOut:(F)=>G.stdout.write(F),writeErr:(F)=>G.stderr.write(F),outputError:(F,B)=>B(F),getOutHelpWidth:()=>G.stdout.isTTY?G.stdout.columns:void 0,getErrHelpWidth:()=>G.stderr.isTTY?G.stderr.columns:void 0,getOutHasColors:()=>$0()??(G.stdout.isTTY&&G.stdout.hasColors?.()),getErrHasColors:()=>$0()??(G.stderr.isTTY&&G.stderr.hasColors?.()),stripColor:(F)=>Y2(F)},this._hidden=!1,this._helpOption=void 0,this._addImplicitHelpCommand=void 0,this._helpCommand=void 0,this._helpConfiguration={},this._helpGroupHeading=void 0,this._defaultCommandGroup=void 0,this._defaultOptionGroup=void 0}copyInheritedSettings(_){return this._outputConfiguration=_._outputConfiguration,this._helpOption=_._helpOption,this._helpCommand=_._helpCommand,this._helpConfiguration=_._helpConfiguration,this._exitCallback=_._exitCallback,this._storeOptionsAsProperties=_._storeOptionsAsProperties,this._combineFlagAndOptionalValue=_._combineFlagAndOptionalValue,this._allowExcessArguments=_._allowExcessArguments,this._enablePositionalOptions=_._enablePositionalOptions,this._showHelpAfterError=_._showHelpAfterError,this._showSuggestionAfterError=_._showSuggestionAfterError,this}_getCommandAndAncestors(){let _=[];for(let F=this;F;F=F.parent)_.push(F);return _}command(_,F,B){let E=F,$=B;if(typeof E==="object"&&E!==null)$=E,E=null;$=$||{};let[,q,J]=_.match(/([^ ]+) *(.*)/),z=this.createCommand(q);if(E)z.description(E),z._executableHandler=!0;if($.isDefault)this._defaultCommandName=z._name;if(z._hidden=!!($.noHelp||$.hidden),z._executableFile=$.executableFile||null,J)z.arguments(J);if(this._registerCommand(z),z.parent=this,z.copyInheritedSettings(this),E)return this;return z}createCommand(_){return new q0(_)}createHelp(){return Object.assign(new M2,this.configureHelp())}configureHelp(_){if(_===void 0)return this._helpConfiguration;return this._helpConfiguration=_,this}configureOutput(_){if(_===void 0)return this._outputConfiguration;return this._outputConfiguration={...this._outputConfiguration,..._},this}showHelpAfterError(_=!0){if(typeof _!=="string")_=!!_;return this._showHelpAfterError=_,this}showSuggestionAfterError(_=!0){return this._showSuggestionAfterError=!!_,this}addCommand(_,F){if(!_._name)throw new Error(`Command passed to .addCommand() must have a name - specify the name in Command constructor or using .name()`);if(F=F||{},F.isDefault)this._defaultCommandName=_._name;if(F.noHelp||F.hidden)_._hidden=!0;return this._registerCommand(_),_.parent=this,_._checkForBrokenPassThrough(),this}createArgument(_,F){return new D2(_,F)}argument(_,F,B,E){let $=this.createArgument(_,F);if(typeof B==="function")$.default(E).argParser(B);else $.default(B);return this.addArgument($),this}arguments(_){return _.trim().split(/ +/).forEach((F)=>{this.argument(F)}),this}addArgument(_){let F=this.registeredArguments.slice(-1)[0];if(F?.variadic)throw new Error(`only the last argument can be variadic '${F.name()}'`);if(_.required&&_.defaultValue!==void 0&&_.parseArg===void 0)throw new Error(`a default value for a required argument is never used: '${_.name()}'`);return this.registeredArguments.push(_),this}helpCommand(_,F){if(typeof _==="boolean"){if(this._addImplicitHelpCommand=_,_&&this._defaultCommandGroup)this._initCommandGroup(this._getHelpCommand());return this}let B=_??"help [command]",[,E,$]=B.match(/([^ ]+) *(.*)/),q=F??"display help for command",J=this.createCommand(E);if(J.helpOption(!1),$)J.arguments($);if(q)J.description(q);if(this._addImplicitHelpCommand=!0,this._helpCommand=J,_||F)this._initCommandGroup(J);return this}addHelpCommand(_,F){if(typeof _!=="object")return this.helpCommand(_,F),this;return this._addImplicitHelpCommand=!0,this._helpCommand=_,this._initCommandGroup(_),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(_,F){let B=["preSubcommand","preAction","postAction"];if(!B.includes(_))throw new Error(`Unexpected value for event passed to hook : '${_}'. Expecting one of '${B.join("', '")}'`);if(this._lifeCycleHooks[_])this._lifeCycleHooks[_].push(F);else this._lifeCycleHooks[_]=[F];return this}exitOverride(_){if(_)this._exitCallback=_;else this._exitCallback=(F)=>{if(F.code!=="commander.executeSubCommandAsync")throw F};return this}_exit(_,F,B){if(this._exitCallback)this._exitCallback(new E0(_,F,B));G.exit(_)}action(_){let F=(B)=>{let E=this.registeredArguments.length,$=B.slice(0,E);if(this._storeOptionsAsProperties)$[E]=this;else $[E]=this.opts();return $.push(this),_.apply(this,$)};return this._actionHandler=F,this}createOption(_,F){return new u0(_,F)}_callParseArg(_,F,B,E){try{return _.parseArg(F,B)}catch($){if($.code==="commander.invalidArgument"){let q=`${E} ${$.message}`;this.error(q,{exitCode:$.exitCode,code:$.code})}throw $}}_registerOption(_){let F=_.short&&this._findOption(_.short)||_.long&&this._findOption(_.long);if(F){let B=_.long&&this._findOption(_.long)?_.long:_.short;throw new Error(`Cannot add option '${_.flags}'${this._name&&` to command '${this._name}'`} due to conflicting flag '${B}' - already used by option '${F.flags}'`)}this._initOptionGroup(_),this.options.push(_)}_registerCommand(_){let F=(E)=>{return[E.name()].concat(E.aliases())},B=F(_).find((E)=>this._findCommand(E));if(B){let E=F(this._findCommand(B)).join("|"),$=F(_).join("|");throw new Error(`cannot add command '${$}' as already have command '${E}'`)}this._initCommandGroup(_),this.commands.push(_)}addOption(_){this._registerOption(_);let F=_.name(),B=_.attributeName();if(_.negate){let $=_.long.replace(/^--no-/,"--");if(!this._findOption($))this.setOptionValueWithSource(B,_.defaultValue===void 0?!0:_.defaultValue,"default")}else if(_.defaultValue!==void 0)this.setOptionValueWithSource(B,_.defaultValue,"default");let E=($,q,J)=>{if($==null&&_.presetArg!==void 0)$=_.presetArg;let z=this.getOptionValue(B);if($!==null&&_.parseArg)$=this._callParseArg(_,$,z,q);else if($!==null&&_.variadic)$=_._collectValue($,z);if($==null)if(_.negate)$=!1;else if(_.isBoolean()||_.optional)$=!0;else $="";this.setOptionValueWithSource(B,$,J)};if(this.on("option:"+F,($)=>{let q=`error: option '${_.flags}' argument '${$}' is invalid.`;E($,q,"cli")}),_.envVar)this.on("optionEnv:"+F,($)=>{let q=`error: option '${_.flags}' value '${$}' from env '${_.envVar}' is invalid.`;E($,q,"env")});return this}_optionEx(_,F,B,E,$){if(typeof F==="object"&&F instanceof u0)throw new Error("To add an Option object use addOption() instead of option() or requiredOption()");let q=this.createOption(F,B);if(q.makeOptionMandatory(!!_.mandatory),typeof E==="function")q.default($).argParser(E);else if(E instanceof RegExp){let J=E;E=(z,Z)=>{let Q=J.exec(z);return Q?Q[0]:Z},q.default($).argParser(E)}else q.default(E);return this.addOption(q)}option(_,F,B,E){return this._optionEx({},_,F,B,E)}requiredOption(_,F,B,E){return this._optionEx({mandatory:!0},_,F,B,E)}combineFlagAndOptionalValue(_=!0){return this._combineFlagAndOptionalValue=!!_,this}allowUnknownOption(_=!0){return this._allowUnknownOption=!!_,this}allowExcessArguments(_=!0){return this._allowExcessArguments=!!_,this}enablePositionalOptions(_=!0){return this._enablePositionalOptions=!!_,this}passThroughOptions(_=!0){return this._passThroughOptions=!!_,this._checkForBrokenPassThrough(),this}_checkForBrokenPassThrough(){if(this.parent&&this._passThroughOptions&&!this.parent._enablePositionalOptions)throw new Error(`passThroughOptions cannot be used for '${this._name}' without turning on enablePositionalOptions for parent command(s)`)}storeOptionsAsProperties(_=!0){if(this.options.length)throw new Error("call .storeOptionsAsProperties() before adding options");if(Object.keys(this._optionValues).length)throw new Error("call .storeOptionsAsProperties() before setting option values");return this._storeOptionsAsProperties=!!_,this}getOptionValue(_){if(this._storeOptionsAsProperties)return this[_];return this._optionValues[_]}setOptionValue(_,F){return this.setOptionValueWithSource(_,F,void 0)}setOptionValueWithSource(_,F,B){if(this._storeOptionsAsProperties)this[_]=F;else this._optionValues[_]=F;return this._optionValueSources[_]=B,this}getOptionValueSource(_){return this._optionValueSources[_]}getOptionValueSourceWithGlobals(_){let F;return this._getCommandAndAncestors().forEach((B)=>{if(B.getOptionValueSource(_)!==void 0)F=B.getOptionValueSource(_)}),F}_prepareUserArgs(_,F){if(_!==void 0&&!Array.isArray(_))throw new Error("first parameter to parse must be array or undefined");if(F=F||{},_===void 0&&F.from===void 0){if(G.versions?.electron)F.from="electron";let E=G.execArgv??[];if(E.includes("-e")||E.includes("--eval")||E.includes("-p")||E.includes("--print"))F.from="eval"}if(_===void 0)_=G.argv;this.rawArgs=_.slice();let B;switch(F.from){case void 0:case"node":this._scriptPath=_[1],B=_.slice(2);break;case"electron":if(G.defaultApp)this._scriptPath=_[1],B=_.slice(2);else B=_.slice(1);break;case"user":B=_.slice(0);break;case"eval":B=_.slice(1);break;default:throw new Error(`unexpected parse option { from: '${F.from}' }`)}if(!this._name&&this._scriptPath)this.nameFromFilename(this._scriptPath);return this._name=this._name||"program",B}parse(_,F){this._prepareForParse();let B=this._prepareUserArgs(_,F);return this._parseCommand([],B),this}async parseAsync(_,F){this._prepareForParse();let B=this._prepareUserArgs(_,F);return await this._parseCommand([],B),this}_prepareForParse(){if(this._savedState===null)this.saveStateBeforeParse();else this.restoreStateBeforeParse()}saveStateBeforeParse(){this._savedState={_name:this._name,_optionValues:{...this._optionValues},_optionValueSources:{...this._optionValueSources}}}restoreStateBeforeParse(){if(this._storeOptionsAsProperties)throw new Error(`Can not call parse again when storeOptionsAsProperties is true. - either make a new Command for each call to parse, or stop storing options as properties`);this._name=this._savedState._name,this._scriptPath=null,this.rawArgs=[],this._optionValues={...this._savedState._optionValues},this._optionValueSources={...this._savedState._optionValueSources},this.args=[],this.processedArgs=[]}_checkForMissingExecutable(_,F,B){if(c.existsSync(_))return;let E=F?`searched for local subcommand relative to directory '${F}'`:"no directory for search for local subcommand, use .executableDir() to supply a custom directory",$=`'${_}' does not exist - if '${B}' 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 or path - ${E}`;throw new Error($)}_executeSubCommand(_,F){F=F.slice();let B=!1,E=[".js",".ts",".tsx",".mjs",".cjs"];function $(Q,X){let D=L.resolve(Q,X);if(c.existsSync(D))return D;if(E.includes(L.extname(X)))return;let T=E.find((W)=>c.existsSync(`${D}${W}`));if(T)return`${D}${T}`;return}this._checkForMissingMandatoryOptions(),this._checkForConflictingOptions();let q=_._executableFile||`${this._name}-${_._name}`,J=this._executableDir||"";if(this._scriptPath){let Q;try{Q=c.realpathSync(this._scriptPath)}catch{Q=this._scriptPath}J=L.resolve(L.dirname(Q),J)}if(J){let Q=$(J,q);if(!Q&&!_._executableFile&&this._scriptPath){let X=L.basename(this._scriptPath,L.extname(this._scriptPath));if(X!==this._name)Q=$(J,`${X}-${_._name}`)}q=Q||q}B=E.includes(L.extname(q));let z;if(G.platform!=="win32")if(B)F.unshift(q),F=c0(G.execArgv).concat(F),z=B0.spawn(G.argv[0],F,{stdio:"inherit"});else z=B0.spawn(q,F,{stdio:"inherit"});else this._checkForMissingExecutable(q,J,_._name),F.unshift(q),F=c0(G.execArgv).concat(F),z=B0.spawn(G.execPath,F,{stdio:"inherit"});if(!z.killed)["SIGUSR1","SIGUSR2","SIGTERM","SIGINT","SIGHUP"].forEach((X)=>{G.on(X,()=>{if(z.killed===!1&&z.exitCode===null)z.kill(X)})});let Z=this._exitCallback;z.on("close",(Q)=>{if(Q=Q??1,!Z)G.exit(Q);else Z(new E0(Q,"commander.executeSubCommandAsync","(close)"))}),z.on("error",(Q)=>{if(Q.code==="ENOENT")this._checkForMissingExecutable(q,J,_._name);else if(Q.code==="EACCES")throw new Error(`'${q}' not executable`);if(!Z)G.exit(1);else{let X=new E0(1,"commander.executeSubCommandAsync","(error)");X.nestedError=Q,Z(X)}}),this.runningCommand=z}_dispatchSubcommand(_,F,B){let E=this._findCommand(_);if(!E)this.help({error:!0});E._prepareForParse();let $;return $=this._chainOrCallSubCommandHook($,E,"preSubcommand"),$=this._chainOrCall($,()=>{if(E._executableHandler)this._executeSubCommand(E,F.concat(B));else return E._parseCommand(F,B)}),$}_dispatchHelpCommand(_){if(!_)this.help();let F=this._findCommand(_);if(F&&!F._executableHandler)F.help();return this._dispatchSubcommand(_,[],[this._getHelpOption()?.long??this._getHelpOption()?.short??"--help"])}_checkNumberOfArguments(){if(this.registeredArguments.forEach((_,F)=>{if(_.required&&this.args[F]==null)this.missingArgument(_.name())}),this.registeredArguments.length>0&&this.registeredArguments[this.registeredArguments.length-1].variadic)return;if(this.args.length>this.registeredArguments.length)this._excessArguments(this.args)}_processArguments(){let _=(B,E,$)=>{let q=E;if(E!==null&&B.parseArg){let J=`error: command-argument value '${E}' is invalid for argument '${B.name()}'.`;q=this._callParseArg(B,E,$,J)}return q};this._checkNumberOfArguments();let F=[];this.registeredArguments.forEach((B,E)=>{let $=B.defaultValue;if(B.variadic){if(E<this.args.length){if($=this.args.slice(E),B.parseArg)$=$.reduce((q,J)=>{return _(B,J,q)},B.defaultValue)}else if($===void 0)$=[]}else if(E<this.args.length){if($=this.args[E],B.parseArg)$=_(B,$,B.defaultValue)}F[E]=$}),this.processedArgs=F}_chainOrCall(_,F){if(_?.then&&typeof _.then==="function")return _.then(()=>F());return F()}_chainOrCallHooks(_,F){let B=_,E=[];if(this._getCommandAndAncestors().reverse().filter(($)=>$._lifeCycleHooks[F]!==void 0).forEach(($)=>{$._lifeCycleHooks[F].forEach((q)=>{E.push({hookedCommand:$,callback:q})})}),F==="postAction")E.reverse();return E.forEach(($)=>{B=this._chainOrCall(B,()=>{return $.callback($.hookedCommand,this)})}),B}_chainOrCallSubCommandHook(_,F,B){let E=_;if(this._lifeCycleHooks[B]!==void 0)this._lifeCycleHooks[B].forEach(($)=>{E=this._chainOrCall(E,()=>{return $(this,F)})});return E}_parseCommand(_,F){let B=this.parseOptions(F);if(this._parseOptionsEnv(),this._parseOptionsImplied(),_=_.concat(B.operands),F=B.unknown,this.args=_.concat(F),_&&this._findCommand(_[0]))return this._dispatchSubcommand(_[0],_.slice(1),F);if(this._getHelpCommand()&&_[0]===this._getHelpCommand().name())return this._dispatchHelpCommand(_[1]);if(this._defaultCommandName)return this._outputHelpIfRequested(F),this._dispatchSubcommand(this._defaultCommandName,_,F);if(this.commands.length&&this.args.length===0&&!this._actionHandler&&!this._defaultCommandName)this.help({error:!0});this._outputHelpIfRequested(B.unknown),this._checkForMissingMandatoryOptions(),this._checkForConflictingOptions();let E=()=>{if(B.unknown.length>0)this.unknownOption(B.unknown[0])},$=`command:${this.name()}`;if(this._actionHandler){E(),this._processArguments();let q;if(q=this._chainOrCallHooks(q,"preAction"),q=this._chainOrCall(q,()=>this._actionHandler(this.processedArgs)),this.parent)q=this._chainOrCall(q,()=>{this.parent.emit($,_,F)});return q=this._chainOrCallHooks(q,"postAction"),q}if(this.parent?.listenerCount($))E(),this._processArguments(),this.parent.emit($,_,F);else if(_.length){if(this._findCommand("*"))return this._dispatchSubcommand("*",_,F);if(this.listenerCount("command:*"))this.emit("command:*",_,F);else if(this.commands.length)this.unknownCommand();else E(),this._processArguments()}else if(this.commands.length)E(),this.help({error:!0});else E(),this._processArguments()}_findCommand(_){if(!_)return;return this.commands.find((F)=>F._name===_||F._aliases.includes(_))}_findOption(_){return this.options.find((F)=>F.is(_))}_checkForMissingMandatoryOptions(){this._getCommandAndAncestors().forEach((_)=>{_.options.forEach((F)=>{if(F.mandatory&&_.getOptionValue(F.attributeName())===void 0)_.missingMandatoryOptionValue(F)})})}_checkForConflictingLocalOptions(){let _=this.options.filter((B)=>{let E=B.attributeName();if(this.getOptionValue(E)===void 0)return!1;return this.getOptionValueSource(E)!=="default"});_.filter((B)=>B.conflictsWith.length>0).forEach((B)=>{let E=_.find(($)=>B.conflictsWith.includes($.attributeName()));if(E)this._conflictingOption(B,E)})}_checkForConflictingOptions(){this._getCommandAndAncestors().forEach((_)=>{_._checkForConflictingLocalOptions()})}parseOptions(_){let F=[],B=[],E=F;function $(Q){return Q.length>1&&Q[0]==="-"}let q=(Q)=>{if(!/^-\d*\.?\d+(e[+-]?\d+)?$/.test(Q))return!1;return!this._getCommandAndAncestors().some((X)=>X.options.map((D)=>D.short).some((D)=>/^-\d$/.test(D)))},J=null,z=null,Z=0;while(Z<_.length||z){let Q=z??_[Z++];if(z=null,Q==="--"){if(E===B)E.push(Q);E.push(..._.slice(Z));break}if(J&&(!$(Q)||q(Q))){this.emit(`option:${J.name()}`,Q);continue}if(J=null,$(Q)){let X=this._findOption(Q);if(X){if(X.required){let D=_[Z++];if(D===void 0)this.optionMissingArgument(X);this.emit(`option:${X.name()}`,D)}else if(X.optional){let D=null;if(Z<_.length&&(!$(_[Z])||q(_[Z])))D=_[Z++];this.emit(`option:${X.name()}`,D)}else this.emit(`option:${X.name()}`);J=X.variadic?X:null;continue}}if(Q.length>2&&Q[0]==="-"&&Q[1]!=="-"){let X=this._findOption(`-${Q[1]}`);if(X){if(X.required||X.optional&&this._combineFlagAndOptionalValue)this.emit(`option:${X.name()}`,Q.slice(2));else this.emit(`option:${X.name()}`),z=`-${Q.slice(2)}`;continue}}if(/^--[^=]+=/.test(Q)){let X=Q.indexOf("="),D=this._findOption(Q.slice(0,X));if(D&&(D.required||D.optional)){this.emit(`option:${D.name()}`,Q.slice(X+1));continue}}if(E===F&&$(Q)&&!(this.commands.length===0&&q(Q)))E=B;if((this._enablePositionalOptions||this._passThroughOptions)&&F.length===0&&B.length===0){if(this._findCommand(Q)){F.push(Q),B.push(..._.slice(Z));break}else if(this._getHelpCommand()&&Q===this._getHelpCommand().name()){F.push(Q,..._.slice(Z));break}else if(this._defaultCommandName){B.push(Q,..._.slice(Z));break}}if(this._passThroughOptions){E.push(Q,..._.slice(Z));break}E.push(Q)}return{operands:F,unknown:B}}opts(){if(this._storeOptionsAsProperties){let _={},F=this.options.length;for(let B=0;B<F;B++){let E=this.options[B].attributeName();_[E]=E===this._versionOptionName?this._version:this[E]}return _}return this._optionValues}optsWithGlobals(){return this._getCommandAndAncestors().reduce((_,F)=>Object.assign(_,F.opts()),{})}error(_,F){if(this._outputConfiguration.outputError(`${_} `,this._outputConfiguration.writeErr),typeof this._showHelpAfterError==="string")this._outputConfiguration.writeErr(`${this._showHelpAfterError} `);else if(this._showHelpAfterError)this._outputConfiguration.writeErr(` `),this.outputHelp({error:!0});let B=F||{},E=B.exitCode||1,$=B.code||"commander.error";this._exit(E,$,_)}_parseOptionsEnv(){this.options.forEach((_)=>{if(_.envVar&&_.envVar in G.env){let F=_.attributeName();if(this.getOptionValue(F)===void 0||["default","config","env"].includes(this.getOptionValueSource(F)))if(_.required||_.optional)this.emit(`optionEnv:${_.name()}`,G.env[_.envVar]);else this.emit(`optionEnv:${_.name()}`)}})}_parseOptionsImplied(){let _=new H2(this.options),F=(B)=>{return this.getOptionValue(B)!==void 0&&!["default","implied"].includes(this.getOptionValueSource(B))};this.options.filter((B)=>B.implied!==void 0&&F(B.attributeName())&&_.valueFromOption(this.getOptionValue(B.attributeName()),B)).forEach((B)=>{Object.keys(B.implied).filter((E)=>!F(E)).forEach((E)=>{this.setOptionValueWithSource(E,B.implied[E],"implied")})})}missingArgument(_){let F=`error: missing required argument '${_}'`;this.error(F,{code:"commander.missingArgument"})}optionMissingArgument(_){let F=`error: option '${_.flags}' argument missing`;this.error(F,{code:"commander.optionMissingArgument"})}missingMandatoryOptionValue(_){let F=`error: required option '${_.flags}' not specified`;this.error(F,{code:"commander.missingMandatoryOptionValue"})}_conflictingOption(_,F){let B=(q)=>{let J=q.attributeName(),z=this.getOptionValue(J),Z=this.options.find((X)=>X.negate&&J===X.attributeName()),Q=this.options.find((X)=>!X.negate&&J===X.attributeName());if(Z&&(Z.presetArg===void 0&&z===!1||Z.presetArg!==void 0&&z===Z.presetArg))return Z;return Q||q},E=(q)=>{let J=B(q),z=J.attributeName();if(this.getOptionValueSource(z)==="env")return`environment variable '${J.envVar}'`;return`option '${J.flags}'`},$=`error: ${E(_)} cannot be used with ${E(F)}`;this.error($,{code:"commander.conflictingOption"})}unknownOption(_){if(this._allowUnknownOption)return;let F="";if(_.startsWith("--")&&this._showSuggestionAfterError){let E=[],$=this;do{let q=$.createHelp().visibleOptions($).filter((J)=>J.long).map((J)=>J.long);E=E.concat(q),$=$.parent}while($&&!$._enablePositionalOptions);F=g0(_,E)}let B=`error: unknown option '${_}'${F}`;this.error(B,{code:"commander.unknownOption"})}_excessArguments(_){if(this._allowExcessArguments)return;let F=this.registeredArguments.length,B=F===1?"":"s",$=`error: too many arguments${this.parent?` for '${this.name()}'`:""}. Expected ${F} argument${B} but got ${_.length}.`;this.error($,{code:"commander.excessArguments"})}unknownCommand(){let _=this.args[0],F="";if(this._showSuggestionAfterError){let E=[];this.createHelp().visibleCommands(this).forEach(($)=>{if(E.push($.name()),$.alias())E.push($.alias())}),F=g0(_,E)}let B=`error: unknown command '${_}'${F}`;this.error(B,{code:"commander.unknownCommand"})}version(_,F,B){if(_===void 0)return this._version;this._version=_,F=F||"-V, --version",B=B||"output the version number";let E=this.createOption(F,B);return this._versionOptionName=E.attributeName(),this._registerOption(E),this.on("option:"+E.name(),()=>{this._outputConfiguration.writeOut(`${_} `),this._exit(0,"commander.version",_)}),this}description(_,F){if(_===void 0&&F===void 0)return this._description;if(this._description=_,F)this._argsDescription=F;return this}summary(_){if(_===void 0)return this._summary;return this._summary=_,this}alias(_){if(_===void 0)return this._aliases[0];let F=this;if(this.commands.length!==0&&this.commands[this.commands.length-1]._executableHandler)F=this.commands[this.commands.length-1];if(_===F._name)throw new Error("Command alias can't be the same as its name");let B=this.parent?._findCommand(_);if(B){let E=[B.name()].concat(B.aliases()).join("|");throw new Error(`cannot add alias '${_}' to command '${this.name()}' as already have command '${E}'`)}return F._aliases.push(_),this}aliases(_){if(_===void 0)return this._aliases;return _.forEach((F)=>this.alias(F)),this}usage(_){if(_===void 0){if(this._usage)return this._usage;let F=this.registeredArguments.map((B)=>{return G2(B)});return[].concat(this.options.length||this._helpOption!==null?"[options]":[],this.commands.length?"[command]":[],this.registeredArguments.length?F:[]).join(" ")}return this._usage=_,this}name(_){if(_===void 0)return this._name;return this._name=_,this}helpGroup(_){if(_===void 0)return this._helpGroupHeading??"";return this._helpGroupHeading=_,this}commandsGroup(_){if(_===void 0)return this._defaultCommandGroup??"";return this._defaultCommandGroup=_,this}optionsGroup(_){if(_===void 0)return this._defaultOptionGroup??"";return this._defaultOptionGroup=_,this}_initOptionGroup(_){if(this._defaultOptionGroup&&!_.helpGroupHeading)_.helpGroup(this._defaultOptionGroup)}_initCommandGroup(_){if(this._defaultCommandGroup&&!_.helpGroup())_.helpGroup(this._defaultCommandGroup)}nameFromFilename(_){return this._name=L.basename(_,L.extname(_)),this}executableDir(_){if(_===void 0)return this._executableDir;return this._executableDir=_,this}helpInformation(_){let F=this.createHelp(),B=this._getOutputContext(_);F.prepareContext({error:B.error,helpWidth:B.helpWidth,outputHasColors:B.hasColors});let E=F.formatHelp(this,F);if(B.hasColors)return E;return this._outputConfiguration.stripColor(E)}_getOutputContext(_){_=_||{};let F=!!_.error,B,E,$;if(F)B=(J)=>this._outputConfiguration.writeErr(J),E=this._outputConfiguration.getErrHasColors(),$=this._outputConfiguration.getErrHelpWidth();else B=(J)=>this._outputConfiguration.writeOut(J),E=this._outputConfiguration.getOutHasColors(),$=this._outputConfiguration.getOutHelpWidth();return{error:F,write:(J)=>{if(!E)J=this._outputConfiguration.stripColor(J);return B(J)},hasColors:E,helpWidth:$}}outputHelp(_){let F;if(typeof _==="function")F=_,_=void 0;let B=this._getOutputContext(_),E={error:B.error,write:B.write,command:this};this._getCommandAndAncestors().reverse().forEach((q)=>q.emit("beforeAllHelp",E)),this.emit("beforeHelp",E);let $=this.helpInformation({error:B.error});if(F){if($=F($),typeof $!=="string"&&!Buffer.isBuffer($))throw new Error("outputHelp callback must return a string or a Buffer")}if(B.write($),this._getHelpOption()?.long)this.emit(this._getHelpOption().long);this.emit("afterHelp",E),this._getCommandAndAncestors().forEach((q)=>q.emit("afterAllHelp",E))}helpOption(_,F){if(typeof _==="boolean"){if(_){if(this._helpOption===null)this._helpOption=void 0;if(this._defaultOptionGroup)this._initOptionGroup(this._getHelpOption())}else this._helpOption=null;return this}if(this._helpOption=this.createOption(_??"-h, --help",F??"display help for command"),_||F)this._initOptionGroup(this._helpOption);return this}_getHelpOption(){if(this._helpOption===void 0)this.helpOption(void 0,void 0);return this._helpOption}addHelpOption(_){return this._helpOption=_,this._initOptionGroup(_),this}help(_){this.outputHelp(_);let F=Number(G.exitCode??0);if(F===0&&_&&typeof _!=="function"&&_.error)F=1;this._exit(F,"commander.help","(outputHelp)")}addHelpText(_,F){let B=["beforeAll","before","after","afterAll"];if(!B.includes(_))throw new Error(`Unexpected value for position to addHelpText. Expecting one of '${B.join("', '")}'`);let E=`${_}Help`;return this.on(E,($)=>{let q;if(typeof F==="function")q=F({error:$.error,command:$.command});else q=F;if(q)$.write(`${q} `)}),this}_outputHelpIfRequested(_){let F=this._getHelpOption();if(F&&_.find((E)=>F.is(E)))this.outputHelp(),this._exit(0,"commander.helpDisplayed","(outputHelp)")}}function c0(_){return _.map((F)=>{if(!F.startsWith("--inspect"))return F;let B,E="127.0.0.1",$="9229",q;if((q=F.match(/^(--inspect(-brk)?)$/))!==null)B=q[1];else if((q=F.match(/^(--inspect(-brk|-port)?)=([^:]+)$/))!==null)if(B=q[1],/^\d+$/.test(q[3]))$=q[3];else E=q[3];else if((q=F.match(/^(--inspect(-brk|-port)?)=([^:]+):(\d+)$/))!==null)B=q[1],E=q[3],$=q[4];if(B&&$!=="0")return`${B}=${E}:${parseInt($)+1}`;return F})}function $0(){if(G.env.NO_COLOR||G.env.FORCE_COLOR==="0"||G.env.FORCE_COLOR==="false")return!1;if(G.env.FORCE_COLOR||G.env.CLICOLOR_FORCE!==void 0)return!0;return}R2.Command=q0;R2.useColor=$0});var i0=V((V2)=>{var{Argument:d0}=g(),{Command:J0}=m0(),{CommanderError:L2,InvalidArgumentError:l0}=b(),{Help:W2}=_0(),{Option:p0}=F0();V2.program=new J0;V2.createCommand=(_)=>new J0(_);V2.createOption=(_,F)=>new p0(_,F);V2.createArgument=(_,F)=>new d0(_,F);V2.Command=J0;V2.Option=p0;V2.Argument=d0;V2.Help=W2;V2.CommanderError=L2;V2.InvalidArgumentError=l0;V2.InvalidOptionArgumentError=l0});import{join as Z_}from"path";var L0=(_=0)=>(F)=>`\x1B[${F+_}m`,W0=(_=0)=>(F)=>`\x1B[${38+_};5;${F}m`,V0=(_=0)=>(F,B,E)=>`\x1B[${38+_};2;${F};${B};${E}m`,M={modifier:{reset:[0,0],bold:[1,22],dim:[2,22],italic:[3,23],underline:[4,24],overline:[53,55],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],gray:[90,39],grey:[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],bgGray:[100,49],bgGrey:[100,49],bgRedBright:[101,49],bgGreenBright:[102,49],bgYellowBright:[103,49],bgBlueBright:[104,49],bgMagentaBright:[105,49],bgCyanBright:[106,49],bgWhiteBright:[107,49]}},G_=Object.keys(M.modifier),S1=Object.keys(M.color),k1=Object.keys(M.bgColor),M_=[...S1,...k1];function C1(){let _=new Map;for(let[F,B]of Object.entries(M)){for(let[E,$]of Object.entries(B))M[E]={open:`\x1B[${$[0]}m`,close:`\x1B[${$[1]}m`},B[E]=M[E],_.set($[0],$[1]);Object.defineProperty(M,F,{value:B,enumerable:!1})}return Object.defineProperty(M,"codes",{value:_,enumerable:!1}),M.color.close="\x1B[39m",M.bgColor.close="\x1B[49m",M.color.ansi=L0(),M.color.ansi256=W0(),M.color.ansi16m=V0(),M.bgColor.ansi=L0(10),M.bgColor.ansi256=W0(10),M.bgColor.ansi16m=V0(10),Object.defineProperties(M,{rgbToAnsi256:{value(F,B,E){if(F===B&&B===E){if(F<8)return 16;if(F>248)return 231;return Math.round((F-8)/247*24)+232}return 16+36*Math.round(F/255*5)+6*Math.round(B/255*5)+Math.round(E/255*5)},enumerable:!1},hexToRgb:{value(F){let B=/[a-f\d]{6}|[a-f\d]{3}/i.exec(F.toString(16));if(!B)return[0,0,0];let[E]=B;if(E.length===3)E=[...E].map((q)=>q+q).join("");let $=Number.parseInt(E,16);return[$>>16&255,$>>8&255,$&255]},enumerable:!1},hexToAnsi256:{value:(F)=>M.rgbToAnsi256(...M.hexToRgb(F)),enumerable:!1},ansi256ToAnsi:{value(F){if(F<8)return 30+F;if(F<16)return 90+(F-8);let B,E,$;if(F>=232)B=((F-232)*10+8)/255,E=B,$=B;else{F-=16;let z=F%36;B=Math.floor(F/36)/5,E=Math.floor(z/6)/5,$=z%6/5}let q=Math.max(B,E,$)*2;if(q===0)return 30;let J=30+(Math.round($)<<2|Math.round(E)<<1|Math.round(B));if(q===2)J+=60;return J},enumerable:!1},rgbToAnsi:{value:(F,B,E)=>M.ansi256ToAnsi(M.rgbToAnsi256(F,B,E)),enumerable:!1},hexToAnsi:{value:(F)=>M.ansi256ToAnsi(M.hexToAnsi256(F)),enumerable:!1}}),M}var O1=C1(),j=O1;import n from"process";import y1 from"os";import A0 from"tty";function R(_,F=globalThis.Deno?globalThis.Deno.args:n.argv){let B=_.startsWith("-")?"":_.length===1?"-":"--",E=F.indexOf(B+_),$=F.indexOf("--");return E!==-1&&($===-1||E<$)}var{env:Y}=n,h;if(R("no-color")||R("no-colors")||R("color=false")||R("color=never"))h=0;else if(R("color")||R("colors")||R("color=true")||R("color=always"))h=1;function b1(){if("FORCE_COLOR"in Y){if(Y.FORCE_COLOR==="true")return 1;if(Y.FORCE_COLOR==="false")return 0;return Y.FORCE_COLOR.length===0?1:Math.min(Number.parseInt(Y.FORCE_COLOR,10),3)}}function f1(_){if(_===0)return!1;return{level:_,hasBasic:!0,has256:_>=2,has16m:_>=3}}function v1(_,{streamIsTTY:F,sniffFlags:B=!0}={}){let E=b1();if(E!==void 0)h=E;let $=B?h:E;if($===0)return 0;if(B){if(R("color=16m")||R("color=full")||R("color=truecolor"))return 3;if(R("color=256"))return 2}if("TF_BUILD"in Y&&"AGENT_NAME"in Y)return 1;if(_&&!F&&$===void 0)return 0;let q=$||0;if(Y.TERM==="dumb")return q;if(n.platform==="win32"){let J=y1.release().split(".");if(Number(J[0])>=10&&Number(J[2])>=10586)return Number(J[2])>=14931?3:2;return 1}if("CI"in Y){if(["GITHUB_ACTIONS","GITEA_ACTIONS","CIRCLECI"].some((J)=>(J in Y)))return 3;if(["TRAVIS","APPVEYOR","GITLAB_CI","BUILDKITE","DRONE"].some((J)=>(J in Y))||Y.CI_NAME==="codeship")return 1;return q}if("TEAMCITY_VERSION"in Y)return/^(9\.(0*[1-9]\d*)\.|\d{2,}\.)/.test(Y.TEAMCITY_VERSION)?1:0;if(Y.COLORTERM==="truecolor")return 3;if(Y.TERM==="xterm-kitty")return 3;if(Y.TERM==="xterm-ghostty")return 3;if(Y.TERM==="wezterm")return 3;if("TERM_PROGRAM"in Y){let J=Number.parseInt((Y.TERM_PROGRAM_VERSION||"").split(".")[0],10);switch(Y.TERM_PROGRAM){case"iTerm.app":return J>=3?3:2;case"Apple_Terminal":return 2}}if(/-256(color)?$/i.test(Y.TERM))return 2;if(/^screen|^xterm|^vt100|^vt220|^rxvt|color|ansi|cygwin|linux/i.test(Y.TERM))return 1;if("COLORTERM"in Y)return 1;return q}function P0(_,F={}){let B=v1(_,{streamIsTTY:_&&_.isTTY,...F});return f1(B)}var x1={stdout:P0({isTTY:A0.isatty(1)}),stderr:P0({isTTY:A0.isatty(2)})},T0=x1;function I0(_,F,B){let E=_.indexOf(F);if(E===-1)return _;let $=F.length,q=0,J="";do J+=_.slice(q,E)+F+B,q=E+$,E=_.indexOf(F,q);while(E!==-1);return J+=_.slice(q),J}function N0(_,F,B,E){let $=0,q="";do{let J=_[E-1]==="\r";q+=_.slice($,J?E-1:E)+F+(J?`\r `:` `)+B,$=E+1,E=_.indexOf(` `,$)}while(E!==-1);return q+=_.slice($),q}var{stdout:w0,stderr:S0}=T0,s=Symbol("GENERATOR"),I=Symbol("STYLER"),O=Symbol("IS_EMPTY"),k0=["ansi","ansi","ansi256","ansi16m"],N=Object.create(null),h1=(_,F={})=>{if(F.level&&!(Number.isInteger(F.level)&&F.level>=0&&F.level<=3))throw new Error("The `level` option should be an integer from 0 to 3");let B=w0?w0.level:0;_.level=F.level===void 0?B:F.level};var u1=(_)=>{let F=(...B)=>B.join(" ");return h1(F,_),Object.setPrototypeOf(F,y.prototype),F};function y(_){return u1(_)}Object.setPrototypeOf(y.prototype,Function.prototype);for(let[_,F]of Object.entries(j))N[_]={get(){let B=u(this,o(F.open,F.close,this[I]),this[O]);return Object.defineProperty(this,_,{value:B}),B}};N.visible={get(){let _=u(this,this[I],!0);return Object.defineProperty(this,"visible",{value:_}),_}};var t=(_,F,B,...E)=>{if(_==="rgb"){if(F==="ansi16m")return j[B].ansi16m(...E);if(F==="ansi256")return j[B].ansi256(j.rgbToAnsi256(...E));return j[B].ansi(j.rgbToAnsi(...E))}if(_==="hex")return t("rgb",F,B,...j.hexToRgb(...E));return j[B][_](...E)},g1=["rgb","hex","ansi256"];for(let _ of g1){N[_]={get(){let{level:B}=this;return function(...E){let $=o(t(_,k0[B],"color",...E),j.color.close,this[I]);return u(this,$,this[O])}}};let F="bg"+_[0].toUpperCase()+_.slice(1);N[F]={get(){let{level:B}=this;return function(...E){let $=o(t(_,k0[B],"bgColor",...E),j.bgColor.close,this[I]);return u(this,$,this[O])}}}}var c1=Object.defineProperties(()=>{},{...N,level:{enumerable:!0,get(){return this[s].level},set(_){this[s].level=_}}}),o=(_,F,B)=>{let E,$;if(B===void 0)E=_,$=F;else E=B.openAll+_,$=F+B.closeAll;return{open:_,close:F,openAll:E,closeAll:$,parent:B}},u=(_,F,B)=>{let E=(...$)=>m1(E,$.length===1?""+$[0]:$.join(" "));return Object.setPrototypeOf(E,c1),E[s]=_,E[I]=F,E[O]=B,E},m1=(_,F)=>{if(_.level<=0||!F)return _[O]?"":F;let B=_[I];if(B===void 0)return F;let{openAll:E,closeAll:$}=B;if(F.includes("\x1B"))while(B!==void 0)F=I0(F,B.close,B.open),B=B.parent;let q=F.indexOf(` `);if(q!==-1)F=N0(F,$,E,q);return E+F+$};Object.defineProperties(y.prototype,N);var d1=y(),P_=y({level:S0?S0.level:0});var H=d1;var a0=N1(i0(),1),{program:y_,createCommand:b_,createArgument:f_,createOption:v_,CommanderError:x_,InvalidArgumentError:h_,InvalidOptionArgumentError:u_,Command:r0,Argument:g_,Option:c_,Help:m_}=a0.default;import{existsSync as X_}from"fs";import{rm as Q_,writeFile as H1}from"fs/promises";import{join as K0}from"path";import a from"process";import E1 from"process";import l from"process";var b2=(_,F,B,E)=>{if(B==="length"||B==="prototype")return;if(B==="arguments"||B==="caller")return;let $=Object.getOwnPropertyDescriptor(_,B),q=Object.getOwnPropertyDescriptor(F,B);if(!f2($,q)&&E)return;Object.defineProperty(_,B,q)},f2=function(_,F){return _===void 0||_.configurable||_.writable===F.writable&&_.enumerable===F.enumerable&&_.configurable===F.configurable&&(_.writable||_.value===F.value)},v2=(_,F)=>{let B=Object.getPrototypeOf(F);if(B===Object.getPrototypeOf(_))return;Object.setPrototypeOf(_,B)},x2=(_,F)=>`/* Wrapped ${_}*/ ${F}`,h2=Object.getOwnPropertyDescriptor(Function.prototype,"toString"),u2=Object.getOwnPropertyDescriptor(Function.prototype.toString,"name"),g2=(_,F,B)=>{let E=B===""?"":`with ${B.trim()}() `,$=x2.bind(null,E,F.toString());Object.defineProperty($,"name",u2);let{writable:q,enumerable:J,configurable:z}=h2;Object.defineProperty(_,"toString",{value:$,writable:q,enumerable:J,configurable:z})};function z0(_,F,{ignoreNonConfigurable:B=!1}={}){let{name:E}=_;for(let $ of Reflect.ownKeys(F))b2(_,F,$,B);return v2(_,F),g2(_,F,E),_}var m=new WeakMap,n0=(_,F={})=>{if(typeof _!=="function")throw new