@testiny/cli
Version:
A command-line client for Testiny
27 lines • 3.15 MB
JavaScript
#!/usr/bin/env node
"use strict";var d8e=Object.create;var $T=Object.defineProperty;var cX=Object.getOwnPropertyDescriptor;var f8e=Object.getOwnPropertyNames;var A8e=Object.getPrototypeOf,h8e=Object.prototype.hasOwnProperty;var s=(e,t)=>$T(e,"name",{value:t,configurable:!0});var h=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports);var p8e=(e,t,r,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let i of f8e(t))!h8e.call(e,i)&&i!==r&&$T(e,i,{get:()=>t[i],enumerable:!(n=cX(t,i))||n.enumerable});return e};var we=(e,t,r)=>(r=e!=null?d8e(A8e(e)):{},p8e(t||!e||!e.__esModule?$T(r,"default",{value:e,enumerable:!0}):r,e));var R=(e,t,r,n)=>{for(var i=n>1?void 0:n?cX(t,r):t,a=e.length-1,o;a>=0;a--)(o=e[a])&&(i=(n?o(t,r,i):o(i))||i);return n&&i&&$T(t,r,i),i};var pE=h(UP=>{var ZT=class extends Error{static{s(this,"CommanderError")}constructor(t,r,n){super(n),Error.captureStackTrace(this,this.constructor),this.name=this.constructor.name,this.code=r,this.exitCode=t,this.nestedError=void 0}},FP=class extends ZT{static{s(this,"InvalidArgumentError")}constructor(t){super(1,"commander.invalidArgument",t),Error.captureStackTrace(this,this.constructor),this.name=this.constructor.name}};UP.CommanderError=ZT;UP.InvalidArgumentError=FP});var XT=h(HP=>{var{InvalidArgumentError:D8e}=pE(),qP=class{static{s(this,"Argument")}constructor(t,r){switch(this.description=r||"",this.variadic=!1,this.parseArg=void 0,this.defaultValue=void 0,this.defaultValueDescription=void 0,this.argChoices=void 0,t[0]){case"<":this.required=!0,this._name=t.slice(1,-1);break;case"[":this.required=!1,this._name=t.slice(1,-1);break;default:this.required=!0,this._name=t;break}this._name.endsWith("...")&&(this.variadic=!0,this._name=this._name.slice(0,-3))}name(){return this._name}_collectValue(t,r){return r===this.defaultValue||!Array.isArray(r)?[t]:(r.push(t),r)}default(t,r){return this.defaultValue=t,this.defaultValueDescription=r,this}argParser(t){return this.parseArg=t,this}choices(t){return this.argChoices=t.slice(),this.parseArg=(r,n)=>{if(!this.argChoices.includes(r))throw new D8e(`Allowed choices are ${this.argChoices.join(", ")}.`);return this.variadic?this._collectValue(r,n):r},this}argRequired(){return this.required=!0,this}argOptional(){return this.required=!1,this}};function N8e(e){let t=e.name()+(e.variadic===!0?"...":"");return e.required?"<"+t+">":"["+t+"]"}s(N8e,"humanReadableArgName");HP.Argument=qP;HP.humanReadableArgName=N8e});var GP=h(VP=>{var{humanReadableArgName:R8e}=XT(),jP=class{static{s(this,"Help")}constructor(){this.helpWidth=void 0,this.minWidthToWrap=40,this.sortSubcommands=!1,this.sortOptions=!1,this.showGlobalOptions=!1}prepareContext(t){this.helpWidth=this.helpWidth??t.helpWidth??80}visibleCommands(t){let r=t.commands.filter(i=>!i._hidden),n=t._getHelpCommand();return n&&!n._hidden&&r.push(n),this.sortSubcommands&&r.sort((i,a)=>i.name().localeCompare(a.name())),r}compareOptions(t,r){let n=s(i=>i.short?i.short.replace(/^-/,""):i.long.replace(/^--/,""),"getSortKey");return n(t).localeCompare(n(r))}visibleOptions(t){let r=t.options.filter(i=>!i.hidden),n=t._getHelpOption();if(n&&!n.hidden){let i=n.short&&t._findOption(n.short),a=n.long&&t._findOption(n.long);!i&&!a?r.push(n):n.long&&!a?r.push(t.createOption(n.long,n.description)):n.short&&!i&&r.push(t.createOption(n.short,n.description))}return this.sortOptions&&r.sort(this.compareOptions),r}visibleGlobalOptions(t){if(!this.showGlobalOptions)return[];let r=[];for(let n=t.parent;n;n=n.parent){let i=n.options.filter(a=>!a.hidden);r.push(...i)}return this.sortOptions&&r.sort(this.compareOptions),r}visibleArguments(t){return t._argsDescription&&t.registeredArguments.forEach(r=>{r.description=r.description||t._argsDescription[r.name()]||""}),t.registeredArguments.find(r=>r.description)?t.registeredArguments:[]}subcommandTerm(t){let r=t.registeredArguments.map(n=>R8e(n)).join(" ");return t._name+(t._aliases[0]?"|"+t._aliases[0]:"")+(t.options.length?" [options]":"")+(r?" "+r:"")}optionTerm(t){return t.flags}argumentTerm(t){return t.name()}longestSubcommandTermLength(t,r){return r.visibleCommands(t).reduce((n,i)=>Math.max(n,this.displayWidth(r.styleSubcommandTerm(r.subcommandTerm(i)))),0)}longestOptionTermLength(t,r){return r.visibleOptions(t).reduce((n,i)=>Math.max(n,this.displayWidth(r.styleOptionTerm(r.optionTerm(i)))),0)}longestGlobalOptionTermLength(t,r){return r.visibleGlobalOptions(t).reduce((n,i)=>Math.max(n,this.displayWidth(r.styleOptionTerm(r.optionTerm(i)))),0)}longestArgumentTermLength(t,r){return r.visibleArguments(t).reduce((n,i)=>Math.max(n,this.displayWidth(r.styleArgumentTerm(r.argumentTerm(i)))),0)}commandUsage(t){let r=t._name;t._aliases[0]&&(r=r+"|"+t._aliases[0]);let n="";for(let i=t.parent;i;i=i.parent)n=i.name()+" "+n;return n+r+" "+t.usage()}commandDescription(t){return t.description()}subcommandDescription(t){return t.summary()||t.description()}optionDescription(t){let r=[];if(t.argChoices&&r.push(`choices: ${t.argChoices.map(n=>JSON.stringify(n)).join(", ")}`),t.defaultValue!==void 0&&(t.required||t.optional||t.isBoolean()&&typeof t.defaultValue=="boolean")&&r.push(`default: ${t.defaultValueDescription||JSON.stringify(t.defaultValue)}`),t.presetArg!==void 0&&t.optional&&r.push(`preset: ${JSON.stringify(t.presetArg)}`),t.envVar!==void 0&&r.push(`env: ${t.envVar}`),r.length>0){let n=`(${r.join(", ")})`;return t.description?`${t.description} ${n}`:n}return t.description}argumentDescription(t){let r=[];if(t.argChoices&&r.push(`choices: ${t.argChoices.map(n=>JSON.stringify(n)).join(", ")}`),t.defaultValue!==void 0&&r.push(`default: ${t.defaultValueDescription||JSON.stringify(t.defaultValue)}`),r.length>0){let n=`(${r.join(", ")})`;return t.description?`${t.description} ${n}`:n}return t.description}formatItemList(t,r,n){return r.length===0?[]:[n.styleTitle(t),...r,""]}groupItems(t,r,n){let i=new Map;return t.forEach(a=>{let o=n(a);i.has(o)||i.set(o,[])}),r.forEach(a=>{let o=n(a);i.has(o)||i.set(o,[]),i.get(o).push(a)}),i}formatHelp(t,r){let n=r.padWidth(t,r),i=r.helpWidth??80;function a(f,A){return r.formatItem(f,n,A,r)}s(a,"callFormatItem");let o=[`${r.styleTitle("Usage:")} ${r.styleUsage(r.commandUsage(t))}`,""],u=r.commandDescription(t);u.length>0&&(o=o.concat([r.boxWrap(r.styleCommandDescription(u),i),""]));let c=r.visibleArguments(t).map(f=>a(r.styleArgumentTerm(r.argumentTerm(f)),r.styleArgumentDescription(r.argumentDescription(f))));if(o=o.concat(this.formatItemList("Arguments:",c,r)),this.groupItems(t.options,r.visibleOptions(t),f=>f.helpGroupHeading??"Options:").forEach((f,A)=>{let m=f.map(p=>a(r.styleOptionTerm(r.optionTerm(p)),r.styleOptionDescription(r.optionDescription(p))));o=o.concat(this.formatItemList(A,m,r))}),r.showGlobalOptions){let f=r.visibleGlobalOptions(t).map(A=>a(r.styleOptionTerm(r.optionTerm(A)),r.styleOptionDescription(r.optionDescription(A))));o=o.concat(this.formatItemList("Global Options:",f,r))}return this.groupItems(t.commands,r.visibleCommands(t),f=>f.helpGroup()||"Commands:").forEach((f,A)=>{let m=f.map(p=>a(r.styleSubcommandTerm(r.subcommandTerm(p)),r.styleSubcommandDescription(r.subcommandDescription(p))));o=o.concat(this.formatItemList(A,m,r))}),o.join(`
`)}displayWidth(t){return IX(t).length}styleTitle(t){return t}styleUsage(t){return t.split(" ").map(r=>r==="[options]"?this.styleOptionText(r):r==="[command]"?this.styleSubcommandText(r):r[0]==="["||r[0]==="<"?this.styleArgumentText(r):this.styleCommandText(r)).join(" ")}styleCommandDescription(t){return this.styleDescriptionText(t)}styleOptionDescription(t){return this.styleDescriptionText(t)}styleSubcommandDescription(t){return this.styleDescriptionText(t)}styleArgumentDescription(t){return this.styleDescriptionText(t)}styleDescriptionText(t){return t}styleOptionTerm(t){return this.styleOptionText(t)}styleSubcommandTerm(t){return t.split(" ").map(r=>r==="[options]"?this.styleOptionText(r):r[0]==="["||r[0]==="<"?this.styleArgumentText(r):this.styleSubcommandText(r)).join(" ")}styleArgumentTerm(t){return this.styleArgumentText(t)}styleOptionText(t){return t}styleArgumentText(t){return t}styleSubcommandText(t){return t}styleCommandText(t){return t}padWidth(t,r){return Math.max(r.longestOptionTermLength(t,r),r.longestGlobalOptionTermLength(t,r),r.longestSubcommandTermLength(t,r),r.longestArgumentTermLength(t,r))}preformatted(t){return/\n[^\S\r\n]/.test(t)}formatItem(t,r,n,i){let o=" ".repeat(2);if(!n)return o+t;let u=t.padEnd(r+t.length-i.displayWidth(t)),c=2,d=(this.helpWidth??80)-r-c-2,f;return d<this.minWidthToWrap||i.preformatted(n)?f=n:f=i.boxWrap(n,d).replace(/\n/g,`
`+" ".repeat(r+c)),o+u+" ".repeat(c)+f.replace(/\n/g,`
${o}`)}boxWrap(t,r){if(r<this.minWidthToWrap)return t;let n=t.split(/\r\n|\n/),i=/[\s]*[^\s]+/g,a=[];return n.forEach(o=>{let u=o.match(i);if(u===null){a.push("");return}let c=[u.shift()],l=this.displayWidth(c[0]);u.forEach(d=>{let f=this.displayWidth(d);if(l+f<=r){c.push(d),l+=f;return}a.push(c.join(""));let A=d.trimStart();c=[A],l=this.displayWidth(A)}),a.push(c.join(""))}),a.join(`
`)}};function IX(e){let t=/\x1b\[\d*(;\d*)*m/g;return e.replace(t,"")}s(IX,"stripColor");VP.Help=jP;VP.stripColor=IX});var zP=h($P=>{var{InvalidArgumentError:k8e}=pE(),WP=class{static{s(this,"Option")}constructor(t,r){this.flags=t,this.description=r||"",this.required=t.includes("<"),this.optional=t.includes("["),this.variadic=/\w\.\.\.[>\]]$/.test(t),this.mandatory=!1;let n=O8e(t);this.short=n.shortFlag,this.long=n.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(t,r){return this.defaultValue=t,this.defaultValueDescription=r,this}preset(t){return this.presetArg=t,this}conflicts(t){return this.conflictsWith=this.conflictsWith.concat(t),this}implies(t){let r=t;return typeof t=="string"&&(r={[t]:!0}),this.implied=Object.assign(this.implied||{},r),this}env(t){return this.envVar=t,this}argParser(t){return this.parseArg=t,this}makeOptionMandatory(t=!0){return this.mandatory=!!t,this}hideHelp(t=!0){return this.hidden=!!t,this}_collectValue(t,r){return r===this.defaultValue||!Array.isArray(r)?[t]:(r.push(t),r)}choices(t){return this.argChoices=t.slice(),this.parseArg=(r,n)=>{if(!this.argChoices.includes(r))throw new k8e(`Allowed choices are ${this.argChoices.join(", ")}.`);return this.variadic?this._collectValue(r,n):r},this}name(){return this.long?this.long.replace(/^--/,""):this.short.replace(/^-/,"")}attributeName(){return this.negate?CX(this.name().replace(/^no-/,"")):CX(this.name())}helpGroup(t){return this.helpGroupHeading=t,this}is(t){return this.short===t||this.long===t}isBoolean(){return!this.required&&!this.optional&&!this.negate}},YP=class{static{s(this,"DualOptions")}constructor(t){this.positiveOptions=new Map,this.negativeOptions=new Map,this.dualOptions=new Set,t.forEach(r=>{r.negate?this.negativeOptions.set(r.attributeName(),r):this.positiveOptions.set(r.attributeName(),r)}),this.negativeOptions.forEach((r,n)=>{this.positiveOptions.has(n)&&this.dualOptions.add(n)})}valueFromOption(t,r){let n=r.attributeName();if(!this.dualOptions.has(n))return!0;let i=this.negativeOptions.get(n).presetArg,a=i!==void 0?i:!1;return r.negate===(a===t)}};function CX(e){return e.split("-").reduce((t,r)=>t+r[0].toUpperCase()+r.slice(1))}s(CX,"camelcase");function O8e(e){let t,r,n=/^-[^-]$/,i=/^--[^-]/,a=e.split(/[ |,]+/).concat("guard");if(n.test(a[0])&&(t=a.shift()),i.test(a[0])&&(r=a.shift()),!t&&n.test(a[0])&&(t=a.shift()),!t&&i.test(a[0])&&(t=r,r=a.shift()),a[0].startsWith("-")){let o=a[0],u=`option creation failed due to '${o}' in option flags '${e}'`;throw/^-[^-][^-]/.test(o)?new Error(`${u}
- 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')`):n.test(o)?new Error(`${u}
- too many short flags`):i.test(o)?new Error(`${u}
- too many long flags`):new Error(`${u}
- unrecognised flag format`)}if(t===void 0&&r===void 0)throw new Error(`option creation failed due to no flags found in '${e}'.`);return{shortFlag:t,longFlag:r}}s(O8e,"splitOptionFlags");$P.Option=WP;$P.DualOptions=YP});var SX=h(_X=>{function Q8e(e,t){if(Math.abs(e.length-t.length)>3)return Math.max(e.length,t.length);let r=[];for(let n=0;n<=e.length;n++)r[n]=[n];for(let n=0;n<=t.length;n++)r[0][n]=n;for(let n=1;n<=t.length;n++)for(let i=1;i<=e.length;i++){let a=1;e[i-1]===t[n-1]?a=0:a=1,r[i][n]=Math.min(r[i-1][n]+1,r[i][n-1]+1,r[i-1][n-1]+a),i>1&&n>1&&e[i-1]===t[n-2]&&e[i-2]===t[n-1]&&(r[i][n]=Math.min(r[i][n],r[i-2][n-2]+1))}return r[e.length][t.length]}s(Q8e,"editDistance");function M8e(e,t){if(!t||t.length===0)return"";t=Array.from(new Set(t));let r=e.startsWith("--");r&&(e=e.slice(2),t=t.map(o=>o.slice(2)));let n=[],i=3,a=.4;return t.forEach(o=>{if(o.length<=1)return;let u=Q8e(e,o),c=Math.max(e.length,o.length);(c-u)/c>a&&(u<i?(i=u,n=[o]):u===i&&n.push(o))}),n.sort((o,u)=>o.localeCompare(u)),r&&(n=n.map(o=>`--${o}`)),n.length>1?`
(Did you mean one of ${n.join(", ")}?)`:n.length===1?`
(Did you mean ${n[0]}?)`:""}s(M8e,"suggestSimilar");_X.suggestSimilar=M8e});var BX=h(e3=>{var P8e=require("node:events").EventEmitter,JP=require("node:child_process"),kl=require("node:path"),ev=require("node:fs"),Zt=require("node:process"),{Argument:L8e,humanReadableArgName:F8e}=XT(),{CommanderError:KP}=pE(),{Help:U8e,stripColor:q8e}=GP(),{Option:TX,DualOptions:H8e}=zP(),{suggestSimilar:vX}=SX(),ZP=class e extends P8e{static{s(this,"Command")}constructor(t){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=t||"",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:s(r=>Zt.stdout.write(r),"writeOut"),writeErr:s(r=>Zt.stderr.write(r),"writeErr"),outputError:s((r,n)=>n(r),"outputError"),getOutHelpWidth:s(()=>Zt.stdout.isTTY?Zt.stdout.columns:void 0,"getOutHelpWidth"),getErrHelpWidth:s(()=>Zt.stderr.isTTY?Zt.stderr.columns:void 0,"getErrHelpWidth"),getOutHasColors:s(()=>XP()??(Zt.stdout.isTTY&&Zt.stdout.hasColors?.()),"getOutHasColors"),getErrHasColors:s(()=>XP()??(Zt.stderr.isTTY&&Zt.stderr.hasColors?.()),"getErrHasColors"),stripColor:s(r=>q8e(r),"stripColor")},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(t){return this._outputConfiguration=t._outputConfiguration,this._helpOption=t._helpOption,this._helpCommand=t._helpCommand,this._helpConfiguration=t._helpConfiguration,this._exitCallback=t._exitCallback,this._storeOptionsAsProperties=t._storeOptionsAsProperties,this._combineFlagAndOptionalValue=t._combineFlagAndOptionalValue,this._allowExcessArguments=t._allowExcessArguments,this._enablePositionalOptions=t._enablePositionalOptions,this._showHelpAfterError=t._showHelpAfterError,this._showSuggestionAfterError=t._showSuggestionAfterError,this}_getCommandAndAncestors(){let t=[];for(let r=this;r;r=r.parent)t.push(r);return t}command(t,r,n){let i=r,a=n;typeof i=="object"&&i!==null&&(a=i,i=null),a=a||{};let[,o,u]=t.match(/([^ ]+) *(.*)/),c=this.createCommand(o);return i&&(c.description(i),c._executableHandler=!0),a.isDefault&&(this._defaultCommandName=c._name),c._hidden=!!(a.noHelp||a.hidden),c._executableFile=a.executableFile||null,u&&c.arguments(u),this._registerCommand(c),c.parent=this,c.copyInheritedSettings(this),i?this:c}createCommand(t){return new e(t)}createHelp(){return Object.assign(new U8e,this.configureHelp())}configureHelp(t){return t===void 0?this._helpConfiguration:(this._helpConfiguration=t,this)}configureOutput(t){return t===void 0?this._outputConfiguration:(this._outputConfiguration={...this._outputConfiguration,...t},this)}showHelpAfterError(t=!0){return typeof t!="string"&&(t=!!t),this._showHelpAfterError=t,this}showSuggestionAfterError(t=!0){return this._showSuggestionAfterError=!!t,this}addCommand(t,r){if(!t._name)throw new Error(`Command passed to .addCommand() must have a name
- specify the name in Command constructor or using .name()`);return r=r||{},r.isDefault&&(this._defaultCommandName=t._name),(r.noHelp||r.hidden)&&(t._hidden=!0),this._registerCommand(t),t.parent=this,t._checkForBrokenPassThrough(),this}createArgument(t,r){return new L8e(t,r)}argument(t,r,n,i){let a=this.createArgument(t,r);return typeof n=="function"?a.default(i).argParser(n):a.default(n),this.addArgument(a),this}arguments(t){return t.trim().split(/ +/).forEach(r=>{this.argument(r)}),this}addArgument(t){let r=this.registeredArguments.slice(-1)[0];if(r?.variadic)throw new Error(`only the last argument can be variadic '${r.name()}'`);if(t.required&&t.defaultValue!==void 0&&t.parseArg===void 0)throw new Error(`a default value for a required argument is never used: '${t.name()}'`);return this.registeredArguments.push(t),this}helpCommand(t,r){if(typeof t=="boolean")return this._addImplicitHelpCommand=t,t&&this._defaultCommandGroup&&this._initCommandGroup(this._getHelpCommand()),this;let n=t??"help [command]",[,i,a]=n.match(/([^ ]+) *(.*)/),o=r??"display help for command",u=this.createCommand(i);return u.helpOption(!1),a&&u.arguments(a),o&&u.description(o),this._addImplicitHelpCommand=!0,this._helpCommand=u,(t||r)&&this._initCommandGroup(u),this}addHelpCommand(t,r){return typeof t!="object"?(this.helpCommand(t,r),this):(this._addImplicitHelpCommand=!0,this._helpCommand=t,this._initCommandGroup(t),this)}_getHelpCommand(){return this._addImplicitHelpCommand??(this.commands.length&&!this._actionHandler&&!this._findCommand("help"))?(this._helpCommand===void 0&&this.helpCommand(void 0,void 0),this._helpCommand):null}hook(t,r){let n=["preSubcommand","preAction","postAction"];if(!n.includes(t))throw new Error(`Unexpected value for event passed to hook : '${t}'.
Expecting one of '${n.join("', '")}'`);return this._lifeCycleHooks[t]?this._lifeCycleHooks[t].push(r):this._lifeCycleHooks[t]=[r],this}exitOverride(t){return t?this._exitCallback=t:this._exitCallback=r=>{if(r.code!=="commander.executeSubCommandAsync")throw r},this}_exit(t,r,n){this._exitCallback&&this._exitCallback(new KP(t,r,n)),Zt.exit(t)}action(t){let r=s(n=>{let i=this.registeredArguments.length,a=n.slice(0,i);return this._storeOptionsAsProperties?a[i]=this:a[i]=this.opts(),a.push(this),t.apply(this,a)},"listener");return this._actionHandler=r,this}createOption(t,r){return new TX(t,r)}_callParseArg(t,r,n,i){try{return t.parseArg(r,n)}catch(a){if(a.code==="commander.invalidArgument"){let o=`${i} ${a.message}`;this.error(o,{exitCode:a.exitCode,code:a.code})}throw a}}_registerOption(t){let r=t.short&&this._findOption(t.short)||t.long&&this._findOption(t.long);if(r){let n=t.long&&this._findOption(t.long)?t.long:t.short;throw new Error(`Cannot add option '${t.flags}'${this._name&&` to command '${this._name}'`} due to conflicting flag '${n}'
- already used by option '${r.flags}'`)}this._initOptionGroup(t),this.options.push(t)}_registerCommand(t){let r=s(i=>[i.name()].concat(i.aliases()),"knownBy"),n=r(t).find(i=>this._findCommand(i));if(n){let i=r(this._findCommand(n)).join("|"),a=r(t).join("|");throw new Error(`cannot add command '${a}' as already have command '${i}'`)}this._initCommandGroup(t),this.commands.push(t)}addOption(t){this._registerOption(t);let r=t.name(),n=t.attributeName();if(t.negate){let a=t.long.replace(/^--no-/,"--");this._findOption(a)||this.setOptionValueWithSource(n,t.defaultValue===void 0?!0:t.defaultValue,"default")}else t.defaultValue!==void 0&&this.setOptionValueWithSource(n,t.defaultValue,"default");let i=s((a,o,u)=>{a==null&&t.presetArg!==void 0&&(a=t.presetArg);let c=this.getOptionValue(n);a!==null&&t.parseArg?a=this._callParseArg(t,a,c,o):a!==null&&t.variadic&&(a=t._collectValue(a,c)),a==null&&(t.negate?a=!1:t.isBoolean()||t.optional?a=!0:a=""),this.setOptionValueWithSource(n,a,u)},"handleOptionValue");return this.on("option:"+r,a=>{let o=`error: option '${t.flags}' argument '${a}' is invalid.`;i(a,o,"cli")}),t.envVar&&this.on("optionEnv:"+r,a=>{let o=`error: option '${t.flags}' value '${a}' from env '${t.envVar}' is invalid.`;i(a,o,"env")}),this}_optionEx(t,r,n,i,a){if(typeof r=="object"&&r instanceof TX)throw new Error("To add an Option object use addOption() instead of option() or requiredOption()");let o=this.createOption(r,n);if(o.makeOptionMandatory(!!t.mandatory),typeof i=="function")o.default(a).argParser(i);else if(i instanceof RegExp){let u=i;i=s((c,l)=>{let d=u.exec(c);return d?d[0]:l},"fn"),o.default(a).argParser(i)}else o.default(i);return this.addOption(o)}option(t,r,n,i){return this._optionEx({},t,r,n,i)}requiredOption(t,r,n,i){return this._optionEx({mandatory:!0},t,r,n,i)}combineFlagAndOptionalValue(t=!0){return this._combineFlagAndOptionalValue=!!t,this}allowUnknownOption(t=!0){return this._allowUnknownOption=!!t,this}allowExcessArguments(t=!0){return this._allowExcessArguments=!!t,this}enablePositionalOptions(t=!0){return this._enablePositionalOptions=!!t,this}passThroughOptions(t=!0){return this._passThroughOptions=!!t,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(t=!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=!!t,this}getOptionValue(t){return this._storeOptionsAsProperties?this[t]:this._optionValues[t]}setOptionValue(t,r){return this.setOptionValueWithSource(t,r,void 0)}setOptionValueWithSource(t,r,n){return this._storeOptionsAsProperties?this[t]=r:this._optionValues[t]=r,this._optionValueSources[t]=n,this}getOptionValueSource(t){return this._optionValueSources[t]}getOptionValueSourceWithGlobals(t){let r;return this._getCommandAndAncestors().forEach(n=>{n.getOptionValueSource(t)!==void 0&&(r=n.getOptionValueSource(t))}),r}_prepareUserArgs(t,r){if(t!==void 0&&!Array.isArray(t))throw new Error("first parameter to parse must be array or undefined");if(r=r||{},t===void 0&&r.from===void 0){Zt.versions?.electron&&(r.from="electron");let i=Zt.execArgv??[];(i.includes("-e")||i.includes("--eval")||i.includes("-p")||i.includes("--print"))&&(r.from="eval")}t===void 0&&(t=Zt.argv),this.rawArgs=t.slice();let n;switch(r.from){case void 0:case"node":this._scriptPath=t[1],n=t.slice(2);break;case"electron":Zt.defaultApp?(this._scriptPath=t[1],n=t.slice(2)):n=t.slice(1);break;case"user":n=t.slice(0);break;case"eval":n=t.slice(1);break;default:throw new Error(`unexpected parse option { from: '${r.from}' }`)}return!this._name&&this._scriptPath&&this.nameFromFilename(this._scriptPath),this._name=this._name||"program",n}parse(t,r){this._prepareForParse();let n=this._prepareUserArgs(t,r);return this._parseCommand([],n),this}async parseAsync(t,r){this._prepareForParse();let n=this._prepareUserArgs(t,r);return await this._parseCommand([],n),this}_prepareForParse(){this._savedState===null?this.saveStateBeforeParse():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(t,r,n){if(ev.existsSync(t))return;let i=r?`searched for local subcommand relative to directory '${r}'`:"no directory for search for local subcommand, use .executableDir() to supply a custom directory",a=`'${t}' does not exist
- if '${n}' 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
- ${i}`;throw new Error(a)}_executeSubCommand(t,r){r=r.slice();let n=!1,i=[".js",".ts",".tsx",".mjs",".cjs"];function a(d,f){let A=kl.resolve(d,f);if(ev.existsSync(A))return A;if(i.includes(kl.extname(f)))return;let m=i.find(p=>ev.existsSync(`${A}${p}`));if(m)return`${A}${m}`}s(a,"findFile"),this._checkForMissingMandatoryOptions(),this._checkForConflictingOptions();let o=t._executableFile||`${this._name}-${t._name}`,u=this._executableDir||"";if(this._scriptPath){let d;try{d=ev.realpathSync(this._scriptPath)}catch{d=this._scriptPath}u=kl.resolve(kl.dirname(d),u)}if(u){let d=a(u,o);if(!d&&!t._executableFile&&this._scriptPath){let f=kl.basename(this._scriptPath,kl.extname(this._scriptPath));f!==this._name&&(d=a(u,`${f}-${t._name}`))}o=d||o}n=i.includes(kl.extname(o));let c;Zt.platform!=="win32"?n?(r.unshift(o),r=wX(Zt.execArgv).concat(r),c=JP.spawn(Zt.argv[0],r,{stdio:"inherit"})):c=JP.spawn(o,r,{stdio:"inherit"}):(this._checkForMissingExecutable(o,u,t._name),r.unshift(o),r=wX(Zt.execArgv).concat(r),c=JP.spawn(Zt.execPath,r,{stdio:"inherit"})),c.killed||["SIGUSR1","SIGUSR2","SIGTERM","SIGINT","SIGHUP"].forEach(f=>{Zt.on(f,()=>{c.killed===!1&&c.exitCode===null&&c.kill(f)})});let l=this._exitCallback;c.on("close",d=>{d=d??1,l?l(new KP(d,"commander.executeSubCommandAsync","(close)")):Zt.exit(d)}),c.on("error",d=>{if(d.code==="ENOENT")this._checkForMissingExecutable(o,u,t._name);else if(d.code==="EACCES")throw new Error(`'${o}' not executable`);if(!l)Zt.exit(1);else{let f=new KP(1,"commander.executeSubCommandAsync","(error)");f.nestedError=d,l(f)}}),this.runningCommand=c}_dispatchSubcommand(t,r,n){let i=this._findCommand(t);i||this.help({error:!0}),i._prepareForParse();let a;return a=this._chainOrCallSubCommandHook(a,i,"preSubcommand"),a=this._chainOrCall(a,()=>{if(i._executableHandler)this._executeSubCommand(i,r.concat(n));else return i._parseCommand(r,n)}),a}_dispatchHelpCommand(t){t||this.help();let r=this._findCommand(t);return r&&!r._executableHandler&&r.help(),this._dispatchSubcommand(t,[],[this._getHelpOption()?.long??this._getHelpOption()?.short??"--help"])}_checkNumberOfArguments(){this.registeredArguments.forEach((t,r)=>{t.required&&this.args[r]==null&&this.missingArgument(t.name())}),!(this.registeredArguments.length>0&&this.registeredArguments[this.registeredArguments.length-1].variadic)&&this.args.length>this.registeredArguments.length&&this._excessArguments(this.args)}_processArguments(){let t=s((n,i,a)=>{let o=i;if(i!==null&&n.parseArg){let u=`error: command-argument value '${i}' is invalid for argument '${n.name()}'.`;o=this._callParseArg(n,i,a,u)}return o},"myParseArg");this._checkNumberOfArguments();let r=[];this.registeredArguments.forEach((n,i)=>{let a=n.defaultValue;n.variadic?i<this.args.length?(a=this.args.slice(i),n.parseArg&&(a=a.reduce((o,u)=>t(n,u,o),n.defaultValue))):a===void 0&&(a=[]):i<this.args.length&&(a=this.args[i],n.parseArg&&(a=t(n,a,n.defaultValue))),r[i]=a}),this.processedArgs=r}_chainOrCall(t,r){return t?.then&&typeof t.then=="function"?t.then(()=>r()):r()}_chainOrCallHooks(t,r){let n=t,i=[];return this._getCommandAndAncestors().reverse().filter(a=>a._lifeCycleHooks[r]!==void 0).forEach(a=>{a._lifeCycleHooks[r].forEach(o=>{i.push({hookedCommand:a,callback:o})})}),r==="postAction"&&i.reverse(),i.forEach(a=>{n=this._chainOrCall(n,()=>a.callback(a.hookedCommand,this))}),n}_chainOrCallSubCommandHook(t,r,n){let i=t;return this._lifeCycleHooks[n]!==void 0&&this._lifeCycleHooks[n].forEach(a=>{i=this._chainOrCall(i,()=>a(this,r))}),i}_parseCommand(t,r){let n=this.parseOptions(r);if(this._parseOptionsEnv(),this._parseOptionsImplied(),t=t.concat(n.operands),r=n.unknown,this.args=t.concat(r),t&&this._findCommand(t[0]))return this._dispatchSubcommand(t[0],t.slice(1),r);if(this._getHelpCommand()&&t[0]===this._getHelpCommand().name())return this._dispatchHelpCommand(t[1]);if(this._defaultCommandName)return this._outputHelpIfRequested(r),this._dispatchSubcommand(this._defaultCommandName,t,r);this.commands.length&&this.args.length===0&&!this._actionHandler&&!this._defaultCommandName&&this.help({error:!0}),this._outputHelpIfRequested(n.unknown),this._checkForMissingMandatoryOptions(),this._checkForConflictingOptions();let i=s(()=>{n.unknown.length>0&&this.unknownOption(n.unknown[0])},"checkForUnknownOptions"),a=`command:${this.name()}`;if(this._actionHandler){i(),this._processArguments();let o;return o=this._chainOrCallHooks(o,"preAction"),o=this._chainOrCall(o,()=>this._actionHandler(this.processedArgs)),this.parent&&(o=this._chainOrCall(o,()=>{this.parent.emit(a,t,r)})),o=this._chainOrCallHooks(o,"postAction"),o}if(this.parent?.listenerCount(a))i(),this._processArguments(),this.parent.emit(a,t,r);else if(t.length){if(this._findCommand("*"))return this._dispatchSubcommand("*",t,r);this.listenerCount("command:*")?this.emit("command:*",t,r):this.commands.length?this.unknownCommand():(i(),this._processArguments())}else this.commands.length?(i(),this.help({error:!0})):(i(),this._processArguments())}_findCommand(t){if(t)return this.commands.find(r=>r._name===t||r._aliases.includes(t))}_findOption(t){return this.options.find(r=>r.is(t))}_checkForMissingMandatoryOptions(){this._getCommandAndAncestors().forEach(t=>{t.options.forEach(r=>{r.mandatory&&t.getOptionValue(r.attributeName())===void 0&&t.missingMandatoryOptionValue(r)})})}_checkForConflictingLocalOptions(){let t=this.options.filter(n=>{let i=n.attributeName();return this.getOptionValue(i)===void 0?!1:this.getOptionValueSource(i)!=="default"});t.filter(n=>n.conflictsWith.length>0).forEach(n=>{let i=t.find(a=>n.conflictsWith.includes(a.attributeName()));i&&this._conflictingOption(n,i)})}_checkForConflictingOptions(){this._getCommandAndAncestors().forEach(t=>{t._checkForConflictingLocalOptions()})}parseOptions(t){let r=[],n=[],i=r;function a(d){return d.length>1&&d[0]==="-"}s(a,"maybeOption");let o=s(d=>/^-(\d+|\d*\.\d+)(e[+-]?\d+)?$/.test(d)?!this._getCommandAndAncestors().some(f=>f.options.map(A=>A.short).some(A=>/^-\d$/.test(A))):!1,"negativeNumberArg"),u=null,c=null,l=0;for(;l<t.length||c;){let d=c??t[l++];if(c=null,d==="--"){i===n&&i.push(d),i.push(...t.slice(l));break}if(u&&(!a(d)||o(d))){this.emit(`option:${u.name()}`,d);continue}if(u=null,a(d)){let f=this._findOption(d);if(f){if(f.required){let A=t[l++];A===void 0&&this.optionMissingArgument(f),this.emit(`option:${f.name()}`,A)}else if(f.optional){let A=null;l<t.length&&(!a(t[l])||o(t[l]))&&(A=t[l++]),this.emit(`option:${f.name()}`,A)}else this.emit(`option:${f.name()}`);u=f.variadic?f:null;continue}}if(d.length>2&&d[0]==="-"&&d[1]!=="-"){let f=this._findOption(`-${d[1]}`);if(f){f.required||f.optional&&this._combineFlagAndOptionalValue?this.emit(`option:${f.name()}`,d.slice(2)):(this.emit(`option:${f.name()}`),c=`-${d.slice(2)}`);continue}}if(/^--[^=]+=/.test(d)){let f=d.indexOf("="),A=this._findOption(d.slice(0,f));if(A&&(A.required||A.optional)){this.emit(`option:${A.name()}`,d.slice(f+1));continue}}if(i===r&&a(d)&&!(this.commands.length===0&&o(d))&&(i=n),(this._enablePositionalOptions||this._passThroughOptions)&&r.length===0&&n.length===0){if(this._findCommand(d)){r.push(d),n.push(...t.slice(l));break}else if(this._getHelpCommand()&&d===this._getHelpCommand().name()){r.push(d,...t.slice(l));break}else if(this._defaultCommandName){n.push(d,...t.slice(l));break}}if(this._passThroughOptions){i.push(d,...t.slice(l));break}i.push(d)}return{operands:r,unknown:n}}opts(){if(this._storeOptionsAsProperties){let t={},r=this.options.length;for(let n=0;n<r;n++){let i=this.options[n].attributeName();t[i]=i===this._versionOptionName?this._version:this[i]}return t}return this._optionValues}optsWithGlobals(){return this._getCommandAndAncestors().reduce((t,r)=>Object.assign(t,r.opts()),{})}error(t,r){this._outputConfiguration.outputError(`${t}
`,this._outputConfiguration.writeErr),typeof this._showHelpAfterError=="string"?this._outputConfiguration.writeErr(`${this._showHelpAfterError}
`):this._showHelpAfterError&&(this._outputConfiguration.writeErr(`
`),this.outputHelp({error:!0}));let n=r||{},i=n.exitCode||1,a=n.code||"commander.error";this._exit(i,a,t)}_parseOptionsEnv(){this.options.forEach(t=>{if(t.envVar&&t.envVar in Zt.env){let r=t.attributeName();(this.getOptionValue(r)===void 0||["default","config","env"].includes(this.getOptionValueSource(r)))&&(t.required||t.optional?this.emit(`optionEnv:${t.name()}`,Zt.env[t.envVar]):this.emit(`optionEnv:${t.name()}`))}})}_parseOptionsImplied(){let t=new H8e(this.options),r=s(n=>this.getOptionValue(n)!==void 0&&!["default","implied"].includes(this.getOptionValueSource(n)),"hasCustomOptionValue");this.options.filter(n=>n.implied!==void 0&&r(n.attributeName())&&t.valueFromOption(this.getOptionValue(n.attributeName()),n)).forEach(n=>{Object.keys(n.implied).filter(i=>!r(i)).forEach(i=>{this.setOptionValueWithSource(i,n.implied[i],"implied")})})}missingArgument(t){let r=`error: missing required argument '${t}'`;this.error(r,{code:"commander.missingArgument"})}optionMissingArgument(t){let r=`error: option '${t.flags}' argument missing`;this.error(r,{code:"commander.optionMissingArgument"})}missingMandatoryOptionValue(t){let r=`error: required option '${t.flags}' not specified`;this.error(r,{code:"commander.missingMandatoryOptionValue"})}_conflictingOption(t,r){let n=s(o=>{let u=o.attributeName(),c=this.getOptionValue(u),l=this.options.find(f=>f.negate&&u===f.attributeName()),d=this.options.find(f=>!f.negate&&u===f.attributeName());return l&&(l.presetArg===void 0&&c===!1||l.presetArg!==void 0&&c===l.presetArg)?l:d||o},"findBestOptionFromValue"),i=s(o=>{let u=n(o),c=u.attributeName();return this.getOptionValueSource(c)==="env"?`environment variable '${u.envVar}'`:`option '${u.flags}'`},"getErrorMessage"),a=`error: ${i(t)} cannot be used with ${i(r)}`;this.error(a,{code:"commander.conflictingOption"})}unknownOption(t){if(this._allowUnknownOption)return;let r="";if(t.startsWith("--")&&this._showSuggestionAfterError){let i=[],a=this;do{let o=a.createHelp().visibleOptions(a).filter(u=>u.long).map(u=>u.long);i=i.concat(o),a=a.parent}while(a&&!a._enablePositionalOptions);r=vX(t,i)}let n=`error: unknown option '${t}'${r}`;this.error(n,{code:"commander.unknownOption"})}_excessArguments(t){if(this._allowExcessArguments)return;let r=this.registeredArguments.length,n=r===1?"":"s",a=`error: too many arguments${this.parent?` for '${this.name()}'`:""}. Expected ${r} argument${n} but got ${t.length}.`;this.error(a,{code:"commander.excessArguments"})}unknownCommand(){let t=this.args[0],r="";if(this._showSuggestionAfterError){let i=[];this.createHelp().visibleCommands(this).forEach(a=>{i.push(a.name()),a.alias()&&i.push(a.alias())}),r=vX(t,i)}let n=`error: unknown command '${t}'${r}`;this.error(n,{code:"commander.unknownCommand"})}version(t,r,n){if(t===void 0)return this._version;this._version=t,r=r||"-V, --version",n=n||"output the version number";let i=this.createOption(r,n);return this._versionOptionName=i.attributeName(),this._registerOption(i),this.on("option:"+i.name(),()=>{this._outputConfiguration.writeOut(`${t}
`),this._exit(0,"commander.version",t)}),this}description(t,r){return t===void 0&&r===void 0?this._description:(this._description=t,r&&(this._argsDescription=r),this)}summary(t){return t===void 0?this._summary:(this._summary=t,this)}alias(t){if(t===void 0)return this._aliases[0];let r=this;if(this.commands.length!==0&&this.commands[this.commands.length-1]._executableHandler&&(r=this.commands[this.commands.length-1]),t===r._name)throw new Error("Command alias can't be the same as its name");let n=this.parent?._findCommand(t);if(n){let i=[n.name()].concat(n.aliases()).join("|");throw new Error(`cannot add alias '${t}' to command '${this.name()}' as already have command '${i}'`)}return r._aliases.push(t),this}aliases(t){return t===void 0?this._aliases:(t.forEach(r=>this.alias(r)),this)}usage(t){if(t===void 0){if(this._usage)return this._usage;let r=this.registeredArguments.map(n=>F8e(n));return[].concat(this.options.length||this._helpOption!==null?"[options]":[],this.commands.length?"[command]":[],this.registeredArguments.length?r:[]).join(" ")}return this._usage=t,this}name(t){return t===void 0?this._name:(this._name=t,this)}helpGroup(t){return t===void 0?this._helpGroupHeading??"":(this._helpGroupHeading=t,this)}commandsGroup(t){return t===void 0?this._defaultCommandGroup??"":(this._defaultCommandGroup=t,this)}optionsGroup(t){return t===void 0?this._defaultOptionGroup??"":(this._defaultOptionGroup=t,this)}_initOptionGroup(t){this._defaultOptionGroup&&!t.helpGroupHeading&&t.helpGroup(this._defaultOptionGroup)}_initCommandGroup(t){this._defaultCommandGroup&&!t.helpGroup()&&t.helpGroup(this._defaultCommandGroup)}nameFromFilename(t){return this._name=kl.basename(t,kl.extname(t)),this}executableDir(t){return t===void 0?this._executableDir:(this._executableDir=t,this)}helpInformation(t){let r=this.createHelp(),n=this._getOutputContext(t);r.prepareContext({error:n.error,helpWidth:n.helpWidth,outputHasColors:n.hasColors});let i=r.formatHelp(this,r);return n.hasColors?i:this._outputConfiguration.stripColor(i)}_getOutputContext(t){t=t||{};let r=!!t.error,n,i,a;return r?(n=s(u=>this._outputConfiguration.writeErr(u),"baseWrite"),i=this._outputConfiguration.getErrHasColors(),a=this._outputConfiguration.getErrHelpWidth()):(n=s(u=>this._outputConfiguration.writeOut(u),"baseWrite"),i=this._outputConfiguration.getOutHasColors(),a=this._outputConfiguration.getOutHelpWidth()),{error:r,write:s(u=>(i||(u=this._outputConfiguration.stripColor(u)),n(u)),"write"),hasColors:i,helpWidth:a}}outputHelp(t){let r;typeof t=="function"&&(r=t,t=void 0);let n=this._getOutputContext(t),i={error:n.error,write:n.write,command:this};this._getCommandAndAncestors().reverse().forEach(o=>o.emit("beforeAllHelp",i)),this.emit("beforeHelp",i);let a=this.helpInformation({error:n.error});if(r&&(a=r(a),typeof a!="string"&&!Buffer.isBuffer(a)))throw new Error("outputHelp callback must return a string or a Buffer");n.write(a),this._getHelpOption()?.long&&this.emit(this._getHelpOption().long),this.emit("afterHelp",i),this._getCommandAndAncestors().forEach(o=>o.emit("afterAllHelp",i))}helpOption(t,r){return typeof t=="boolean"?(t?(this._helpOption===null&&(this._helpOption=void 0),this._defaultOptionGroup&&this._initOptionGroup(this._getHelpOption())):this._helpOption=null,this):(this._helpOption=this.createOption(t??"-h, --help",r??"display help for command"),(t||r)&&this._initOptionGroup(this._helpOption),this)}_getHelpOption(){return this._helpOption===void 0&&this.helpOption(void 0,void 0),this._helpOption}addHelpOption(t){return this._helpOption=t,this._initOptionGroup(t),this}help(t){this.outputHelp(t);let r=Number(Zt.exitCode??0);r===0&&t&&typeof t!="function"&&t.error&&(r=1),this._exit(r,"commander.help","(outputHelp)")}addHelpText(t,r){let n=["beforeAll","before","after","afterAll"];if(!n.includes(t))throw new Error(`Unexpected value for position to addHelpText.
Expecting one of '${n.join("', '")}'`);let i=`${t}Help`;return this.on(i,a=>{let o;typeof r=="function"?o=r({error:a.error,command:a.command}):o=r,o&&a.write(`${o}
`)}),this}_outputHelpIfRequested(t){let r=this._getHelpOption();r&&t.find(i=>r.is(i))&&(this.outputHelp(),this._exit(0,"commander.helpDisplayed","(outputHelp)"))}};function wX(e){return e.map(t=>{if(!t.startsWith("--inspect"))return t;let r,n="127.0.0.1",i="9229",a;return(a=t.match(/^(--inspect(-brk)?)$/))!==null?r=a[1]:(a=t.match(/^(--inspect(-brk|-port)?)=([^:]+)$/))!==null?(r=a[1],/^\d+$/.test(a[3])?i=a[3]:n=a[3]):(a=t.match(/^(--inspect(-brk|-port)?)=([^:]+):(\d+)$/))!==null&&(r=a[1],n=a[3],i=a[4]),r&&i!=="0"?`${r}=${n}:${parseInt(i)+1}`:t})}s(wX,"incrementNodeInspectorPort");function XP(){if(Zt.env.NO_COLOR||Zt.env.FORCE_COLOR==="0"||Zt.env.FORCE_COLOR==="false")return!1;if(Zt.env.FORCE_COLOR||Zt.env.CLICOLOR_FORCE!==void 0)return!0}s(XP,"useColor");e3.Command=ZP;e3.useColor=XP});var RX=h(Aa=>{var{Argument:xX}=XT(),{Command:t3}=BX(),{CommanderError:j8e,InvalidArgumentError:DX}=pE(),{Help:V8e}=GP(),{Option:NX}=zP();Aa.program=new t3;Aa.createCommand=e=>new t3(e);Aa.createOption=(e,t)=>new NX(e,t);Aa.createArgument=(e,t)=>new xX(e,t);Aa.Command=t3;Aa.Option=NX;Aa.Argument=xX;Aa.Help=V8e;Aa.CommanderError=j8e;Aa.InvalidArgumentError=DX;Aa.InvalidOptionArgumentError=DX});var jX=h(q0=>{"use strict";Object.defineProperty(q0,"__esModule",{value:!0});q0.splitWhen=q0.flatten=void 0;function X8e(e){return e.reduce((t,r)=>[].concat(t,r),[])}s(X8e,"flatten");q0.flatten=X8e;function eUe(e,t){let r=[[]],n=0;for(let i of e)t(i)?(n++,r[n]=[]):r[n].push(i);return r}s(eUe,"splitWhen");q0.splitWhen=eUe});var VX=h(lv=>{"use strict";Object.defineProperty(lv,"__esModule",{value:!0});lv.isEnoentCodeError=void 0;function tUe(e){return e.code==="ENOENT"}s(tUe,"isEnoentCodeError");lv.isEnoentCodeError=tUe});var GX=h(dv=>{"use strict";Object.defineProperty(dv,"__esModule",{value:!0});dv.createDirentFromStats=void 0;var u3=class{static{s(this,"DirentFromStats")}constructor(t,r){this.name=t,this.isBlockDevice=r.isBlockDevice.bind(r),this.isCharacterDevice=r.isCharacterDevice.bind(r),this.isDirectory=r.isDirectory.bind(r),this.isFIFO=r.isFIFO.bind(r),this.isFile=r.isFile.bind(r),this.isSocket=r.isSocket.bind(r),this.isSymbolicLink=r.isSymbolicLink.bind(r)}};function rUe(e,t){return new u3(e,t)}s(rUe,"createDirentFromStats");dv.createDirentFromStats=rUe});var zX=h(bn=>{"use strict";Object.defineProperty(bn,"__esModule",{value:!0});bn.convertPosixPathToPattern=bn.convertWindowsPathToPattern=bn.convertPathToPattern=bn.escapePosixPath=bn.escapeWindowsPath=bn.escape=bn.removeLeadingDotSegment=bn.makeAbsolute=bn.unixify=void 0;var nUe=require("os"),iUe=require("path"),WX=nUe.platform()==="win32",sUe=2,aUe=/(\\?)([()*?[\]{|}]|^!|[!+@](?=\()|\\(?![!()*+?@[\]{|}]))/g,oUe=/(\\?)([()[\]{}]|^!|[!+@](?=\())/g,uUe=/^\\\\([.?])/,cUe=/\\(?![!()+@[\]{}])/g;function lUe(e){return e.replace(/\\/g,"/")}s(lUe,"unixify");bn.unixify=lUe;function dUe(e,t){return iUe.resolve(e,t)}s(dUe,"makeAbsolute");bn.makeAbsolute=dUe;function fUe(e){if(e.charAt(0)==="."){let t=e.charAt(1);if(t==="/"||t==="\\")return e.slice(sUe)}return e}s(fUe,"removeLeadingDotSegment");bn.removeLeadingDotSegment=fUe;bn.escape=WX?c3:l3;function c3(e){return e.replace(oUe,"\\$2")}s(c3,"escapeWindowsPath");bn.escapeWindowsPath=c3;function l3(e){return e.replace(aUe,"\\$2")}s(l3,"escapePosixPath");bn.escapePosixPath=l3;bn.convertPathToPattern=WX?YX:$X;function YX(e){return c3(e).replace(uUe,"//$1").replace(cUe,"/")}s(YX,"convertWindowsPathToPattern");bn.convertWindowsPathToPattern=YX;function $X(e){return l3(e)}s($X,"convertPosixPathToPattern");bn.convertPosixPathToPattern=$X});var KX=h((Zcr,JX)=>{JX.exports=s(function(t){if(typeof t!="string"||t==="")return!1;for(var r;r=/(\\).|([@?!+*]\(.*\))/g.exec(t);){if(r[2])return!0;t=t.slice(r.index+r[0].length)}return!1},"isExtglob")});var eee=h((elr,XX)=>{var AUe=KX(),ZX={"{":"}","(":")","[":"]"},hUe=s(function(e){if(e[0]==="!")return!0;for(var t=0,r=-2,n=-2,i=-2,a=-2,o=-2;t<e.length;){if(e[t]==="*"||e[t+1]==="?"&&/[\].+)]/.test(e[t])||n!==-1&&e[t]==="["&&e[t+1]!=="]"&&(n<t&&(n=e.indexOf("]",t)),n>t&&(o===-1||o>n||(o=e.indexOf("\\",t),o===-1||o>n)))||i!==-1&&e[t]==="{"&&e[t+1]!=="}"&&(i=e.indexOf("}",t),i>t&&(o=e.indexOf("\\",t),o===-1||o>i))||a!==-1&&e[t]==="("&&e[t+1]==="?"&&/[:!=]/.test(e[t+2])&&e[t+3]!==")"&&(a=e.indexOf(")",t),a>t&&(o=e.indexOf("\\",t),o===-1||o>a))||r!==-1&&e[t]==="("&&e[t+1]!=="|"&&(r<t&&(r=e.indexOf("|",t)),r!==-1&&e[r+1]!==")"&&(a=e.indexOf(")",r),a>r&&(o=e.indexOf("\\",r),o===-1||o>a))))return!0;if(e[t]==="\\"){var u=e[t+1];t+=2;var c=ZX[u];if(c){var l=e.indexOf(c,t);l!==-1&&(t=l+1)}if(e[t]==="!")return!0}else t++}return!1},"strictCheck"),pUe=s(function(e){if(e[0]==="!")return!0;for(var t=0;t<e.length;){if(/[*?{}()[\]]/.test(e[t]))return!0;if(e[t]==="\\"){var r=e[t+1];t+=2;var n=ZX[r];if(n){var i=e.indexOf(n,t);i!==-1&&(t=i+1)}if(e[t]==="!")return!0}else t++}return!1},"relaxedCheck");XX.exports=s(function(t,r){if(typeof t!="string"||t==="")return!1;if(AUe(t))return!0;var n=hUe;return r&&r.strict===!1&&(n=pUe),n(t)},"isGlob")});var ree=h((rlr,tee)=>{"use strict";var mUe=eee(),gUe=require("path").posix.dirname,bUe=require("os").platform()==="win32",d3="/",yUe=/\\/g,EUe=/[\{\[].*[\}\]]$/,IUe=/(^|[^\\])([\{\[]|\([^\)]+$)/,CUe=/\\([\!\*\?\|\[\]\(\)\{\}])/g;tee.exports=s(function(t,r){var n=Object.assign({flipBackslashes:!0},r);n.flipBackslashes&&bUe&&t.indexOf(d3)<0&&(t=t.replace(yUe,d3)),EUe.test(t)&&(t+=d3),t+="a";do t=gUe(t);while(mUe(t)||IUe.test(t));return t.replace(CUe,"$1")},"globParent")});var fv=h(ha=>{"use strict";ha.isInteger=e=>typeof e=="number"?Number.isInteger(e):typeof e=="string"&&e.trim()!==""?Number.isInteger(Number(e)):!1;ha.find=(e,t)=>e.nodes.find(r=>r.type===t);ha.exceedsLimit=(e,t,r=1,n)=>n===!1||!ha.isInteger(e)||!ha.isInteger(t)?!1:(Number(t)-Number(e))/Number(r)>=n;ha.escapeNode=(e,t=0,r)=>{let n=e.nodes[t];n&&(r&&n.type===r||n.type==="open"||n.type==="close")&&n.escaped!==!0&&(n.value="\\"+n.value,n.escaped=!0)};ha.encloseBrace=e=>e.type!=="brace"?!1:e.commas>>0+e.ranges>>0===0?(e.invalid=!0,!0):!1;ha.isInvalidBrace=e=>e.type!=="brace"?!1:e.invalid===!0||e.dollar?!0:e.commas>>0+e.ranges>>0===0||e.open!==!0||e.close!==!0?(e.invalid=!0,!0):!1;ha.isOpenOrClose=e=>e.type==="open"||e.type==="close"?!0:e.open===!0||e.close===!0;ha.reduce=e=>e.reduce((t,r)=>(r.type==="text"&&t.push(r.value),r.type==="range"&&(r.type="text"),t),[]);ha.flatten=(...e)=>{let t=[],r=s(n=>{for(let i=0;i<n.length;i++){let a=n[i];if(Array.isArray(a)){r(a);continue}a!==void 0&&t.push(a)}return t},"flat");return r(e),t}});var Av=h((alr,iee)=>{"use strict";var nee=fv();iee.exports=(e,t={})=>{let r=s((n,i={})=>{let a=t.escapeInvalid&&nee.isInvalidBrace(i),o=n.invalid===!0&&t.escapeInvalid===!0,u="";if(n.value)return(a||o)&&nee.isOpenOrClose(n)?"\\"+n.value:n.value;if(n.value)return n.value;if(n.nodes)for(let c of n.nodes)u+=r(c);return u},"stringify");return r(e)}});var aee=h((ulr,see)=>{"use strict";see.exports=function(e){return typeof e=="number"?e-e===0:typeof e=="string"&&e.trim()!==""?Number.isFinite?Number.isFinite(+e):isFinite(+e):!1}});var pee=h((clr,hee)=>{"use strict";var oee=aee(),Rh=s((e,t,r)=>{if(oee(e)===!1)throw new TypeError("toRegexRange: expected the first argument to be a number");if(t===void 0||e===t)return String(e);if(oee(t)===!1)throw new TypeError("toRegexRange: expected the second argument to be a number.");let n={relaxZeros:!0,...r};typeof n.strictZeros=="boolean"&&(n.relaxZeros=n.strictZeros===!1);let i=String(n.relaxZeros),a=String(n.shorthand),o=String(n.capture),u=String(n.wrap),c=e+":"+t+"="+i+a+o+u;if(Rh.cache.hasOwnProperty(c))return Rh.cache[c].result;let l=Math.min(e,t),d=Math.max(e,t);if(Math.abs(l-d)===1){let g=e+"|"+t;return n.capture?`(${g})`:n.wrap===!1?g:`(?:${g})`}let f=Aee(e)||Aee(t),A={min:e,max:t,a:l,b:d},m=[],p=[];if(f&&(A.isPadded=f,A.maxLen=String(A.max).length),l<0){let g=d<0?Math.abs(d):1;p=uee(g,Math.abs(l),A,n),l=A.a=0}return d>=0&&(m=uee(l,d,A,n)),A.negatives=p,A.positives=m,A.result=_Ue(p,m,n),n.capture===!0?A.result=`(${A.result})`:n.wrap!==!1&&m.length+p.length>1&&(A.result=`(?:${A.result})`),Rh.cache[c]=A,A.result},"toRegexRange");function _Ue(e,t,r){let n=f3(e,t,"-",!1,r)||[],i=f3(t,e,"",!1,r)||[],a=f3(e,t,"-?",!0,r)||[];return n.concat(a).concat(i).join("|")}s(_Ue,"collatePatterns");function SUe(e,t){let r=1,n=1,i=lee(e,r),a=new Set([t]);for(;e<=i&&i<=t;)a.add(i),r+=1,i=lee(e,r);for(i=dee(t+1,n)-1;e<i&&i<=t;)a.add(i),n+=1,i=dee(t+1,n)-1;return a=[...a],a.sort(wUe),a}s(SUe,"splitToRanges");function TUe(e,t,r){if(e===t)return{pattern:e,count:[],digits:0};let n=vUe(e,t),i=n.length,a="",o=0;for(let u=0;u<i;u++){let[c,l]=n[u];c===l?a+=c:c!=="0"||l!=="9"?a+=BUe(c,l,r):o++}return o&&(a+=r.shorthand===!0?"\\d":"[0-9]"),{pattern:a,count:[o],digits:i}}s(TUe,"rangeToPattern");function uee(e,t,r,n){let i=SUe(e,t),a=[],o=e,u;for(let c=0;c<i.length;c++){let l=i[c],d=TUe(String(o),String(l),n),f="";if(!r.isPadded&&u&&u.pattern===d.pattern){u.count.length>1&&u.count.pop(),u.count.push(d.count[0]),u.string=u.pattern+fee(u.count),o=l+1;continue}r.isPadded&&(f=xUe(l,r,n)),d.string=f+d.pattern+fee(d.count),a.push(d),o=l+1,u=d}return a}s(uee,"splitToPatterns");function f3(e,t,r,n,i){let a=[];for(let o of e){let{string:u}=o;!n&&!cee(t,"string",u)&&a.push(r+u),n&&cee(t,"string",u)&&a.push(r+u)}return a}s(f3,"filterPatterns");function vUe(e,t){let r=[];for(let n=0;n<e.length;n++)r.push([e[n],t[n]]);return r}s(vUe,"zip");function wUe(e,t){return e>t?1:t>e?-1:0}s(wUe,"compare");function cee(e,t,r){return e.some(n=>n[t]===r)}s(cee,"contains");function lee(e,t){return Number(String(e).slice(0,-t)+"9".repeat(t))}s(lee,"countNines");function de