@testiny/cli
Version:
A command-line client for Testiny
27 lines • 1.6 MB
JavaScript
#!/usr/bin/env node
"use strict";var Jfe=Object.create;var qb=Object.defineProperty;var ZB=Object.getOwnPropertyDescriptor;var Xfe=Object.getOwnPropertyNames;var Qfe=Object.getPrototypeOf,epe=Object.prototype.hasOwnProperty;var s=(e,t)=>qb(e,"name",{value:t,configurable:!0});var p=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports);var tpe=(e,t,r,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let i of Xfe(t))!epe.call(e,i)&&i!==r&&qb(e,i,{get:()=>t[i],enumerable:!(n=ZB(t,i))||n.enumerable});return e};var me=(e,t,r)=>(r=e!=null?Jfe(Qfe(e)):{},tpe(t||!e||!e.__esModule?qb(r,"default",{value:e,enumerable:!0}):r,e));var A=(e,t,r,n)=>{for(var i=n>1?void 0:n?ZB(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&&qb(t,r,i),i};var ih=p(rE=>{var Vb=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}},tE=class extends Vb{static{s(this,"InvalidArgumentError")}constructor(t){super(1,"commander.invalidArgument",t),Error.captureStackTrace(this,this.constructor),this.name=this.constructor.name}};rE.CommanderError=Vb;rE.InvalidArgumentError=tE});var Ub=p(iE=>{var{InvalidArgumentError:gpe}=ih(),nE=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.length>3&&this._name.slice(-3)==="..."&&(this.variadic=!0,this._name=this._name.slice(0,-3))}name(){return this._name}_concatValue(t,r){return r===this.defaultValue||!Array.isArray(r)?[t]:r.concat(t)}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 gpe(`Allowed choices are ${this.argChoices.join(", ")}.`);return this.variadic?this._concatValue(r,n):r},this}argRequired(){return this.required=!0,this}argOptional(){return this.required=!1,this}};function ype(e){let t=e.name()+(e.variadic===!0?"...":"");return e.required?"<"+t+">":"["+t+"]"}s(ype,"humanReadableArgName");iE.Argument=nE;iE.humanReadableArgName=ype});var oE=p(aE=>{var{humanReadableArgName:bpe}=Ub(),sE=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=>bpe(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,h){return r.formatItem(f,n,h,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 l=r.visibleArguments(t).map(f=>a(r.styleArgumentTerm(r.argumentTerm(f)),r.styleArgumentDescription(r.argumentDescription(f))));if(o=o.concat(this.formatItemList("Arguments:",l,r)),this.groupItems(t.options,r.visibleOptions(t),f=>f.helpGroupHeading??"Options:").forEach((f,h)=>{let m=f.map(g=>a(r.styleOptionTerm(r.optionTerm(g)),r.styleOptionDescription(r.optionDescription(g))));o=o.concat(this.formatItemList(h,m,r))}),r.showGlobalOptions){let f=r.visibleGlobalOptions(t).map(h=>a(r.styleOptionTerm(r.optionTerm(h)),r.styleOptionDescription(r.optionDescription(h))));o=o.concat(this.formatItemList("Global Options:",f,r))}return this.groupItems(t.commands,r.visibleCommands(t),f=>f.helpGroup()||"Commands:").forEach((f,h)=>{let m=f.map(g=>a(r.styleSubcommandTerm(r.subcommandTerm(g)),r.styleSubcommandDescription(r.subcommandDescription(g))));o=o.concat(this.formatItemList(h,m,r))}),o.join(`
`)}displayWidth(t){return o$(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)),l=2,d=(this.helpWidth??80)-r-l-2,f;return d<this.minWidthToWrap||i.preformatted(n)?f=n:f=i.boxWrap(n,d).replace(/\n/g,`
`+" ".repeat(r+l)),o+u+" ".repeat(l)+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 l=[u.shift()],c=this.displayWidth(l[0]);u.forEach(d=>{let f=this.displayWidth(d);if(c+f<=r){l.push(d),c+=f;return}a.push(l.join(""));let h=d.trimStart();l=[h],c=this.displayWidth(h)}),a.push(l.join(""))}),a.join(`
`)}};function o$(e){let t=/\x1b\[\d*(;\d*)*m/g;return e.replace(t,"")}s(o$,"stripColor");aE.Help=sE;aE.stripColor=o$});var dE=p(cE=>{var{InvalidArgumentError:vpe}=ih(),uE=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=_pe(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}_concatValue(t,r){return r===this.defaultValue||!Array.isArray(r)?[t]:r.concat(t)}choices(t){return this.argChoices=t.slice(),this.parseArg=(r,n)=>{if(!this.argChoices.includes(r))throw new vpe(`Allowed choices are ${this.argChoices.join(", ")}.`);return this.variadic?this._concatValue(r,n):r},this}name(){return this.long?this.long.replace(/^--/,""):this.short.replace(/^-/,"")}attributeName(){return this.negate?u$(this.name().replace(/^no-/,"")):u$(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}},lE=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 u$(e){return e.split("-").reduce((t,r)=>t+r[0].toUpperCase()+r.slice(1))}s(u$,"camelcase");function _pe(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(_pe,"splitOptionFlags");cE.Option=uE;cE.DualOptions=lE});var c$=p(l$=>{function Spe(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(Spe,"editDistance");function xpe(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=Spe(e,o),l=Math.max(e.length,o.length);(l-u)/l>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(xpe,"suggestSimilar");l$.suggestSimilar=xpe});var h$=p(gE=>{var wpe=require("node:events").EventEmitter,fE=require("node:child_process"),po=require("node:path"),Wb=require("node:fs"),dt=require("node:process"),{Argument:Tpe,humanReadableArgName:Ipe}=Ub(),{CommanderError:pE}=ih(),{Help:Ape,stripColor:Epe}=oE(),{Option:d$,DualOptions:Cpe}=dE(),{suggestSimilar:f$}=c$(),hE=class e extends wpe{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=>dt.stdout.write(r),"writeOut"),writeErr:s(r=>dt.stderr.write(r),"writeErr"),outputError:s((r,n)=>n(r),"outputError"),getOutHelpWidth:s(()=>dt.stdout.isTTY?dt.stdout.columns:void 0,"getOutHelpWidth"),getErrHelpWidth:s(()=>dt.stderr.isTTY?dt.stderr.columns:void 0,"getErrHelpWidth"),getOutHasColors:s(()=>mE()??(dt.stdout.isTTY&&dt.stdout.hasColors?.()),"getOutHasColors"),getErrHasColors:s(()=>mE()??(dt.stderr.isTTY&&dt.stderr.hasColors?.()),"getErrHasColors"),stripColor:s(r=>Epe(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(/([^ ]+) *(.*)/),l=this.createCommand(o);return i&&(l.description(i),l._executableHandler=!0),a.isDefault&&(this._defaultCommandName=l._name),l._hidden=!!(a.noHelp||a.hidden),l._executableFile=a.executableFile||null,u&&l.arguments(u),this._registerCommand(l),l.parent=this,l.copyInheritedSettings(this),i?this:l}createCommand(t){return new e(t)}createHelp(){return Object.assign(new Ape,this.configureHelp())}configureHelp(t){return t===void 0?this._helpConfiguration:(this._helpConfiguration=t,this)}configureOutput(t){return t===void 0?this._outputConfiguration:(this._outputConfiguration=Object.assign({},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 Tpe(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&&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 pE(t,r,n)),dt.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 d$(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 l=this.getOptionValue(n);a!==null&&t.parseArg?a=this._callParseArg(t,a,l,o):a!==null&&t.variadic&&(a=t._concatValue(a,l)),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 d$)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((l,c)=>{let d=u.exec(l);return d?d[0]:c},"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){dt.versions?.electron&&(r.from="electron");let i=dt.execArgv??[];(i.includes("-e")||i.includes("--eval")||i.includes("-p")||i.includes("--print"))&&(r.from="eval")}t===void 0&&(t=dt.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":dt.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(Wb.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 h=po.resolve(d,f);if(Wb.existsSync(h))return h;if(i.includes(po.extname(f)))return;let m=i.find(g=>Wb.existsSync(`${h}${g}`));if(m)return`${h}${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=Wb.realpathSync(this._scriptPath)}catch{d=this._scriptPath}u=po.resolve(po.dirname(d),u)}if(u){let d=a(u,o);if(!d&&!t._executableFile&&this._scriptPath){let f=po.basename(this._scriptPath,po.extname(this._scriptPath));f!==this._name&&(d=a(u,`${f}-${t._name}`))}o=d||o}n=i.includes(po.extname(o));let l;dt.platform!=="win32"?n?(r.unshift(o),r=p$(dt.execArgv).concat(r),l=fE.spawn(dt.argv[0],r,{stdio:"inherit"})):l=fE.spawn(o,r,{stdio:"inherit"}):(this._checkForMissingExecutable(o,u,t._name),r.unshift(o),r=p$(dt.execArgv).concat(r),l=fE.spawn(dt.execPath,r,{stdio:"inherit"})),l.killed||["SIGUSR1","SIGUSR2","SIGTERM","SIGINT","SIGHUP"].forEach(f=>{dt.on(f,()=>{l.killed===!1&&l.exitCode===null&&l.kill(f)})});let c=this._exitCallback;l.on("close",d=>{d=d??1,c?c(new pE(d,"commander.executeSubCommandAsync","(close)")):dt.exit(d)}),l.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(!c)dt.exit(1);else{let f=new pE(1,"commander.executeSubCommandAsync","(error)");f.nestedError=d,c(f)}}),this.runningCommand=l}_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&&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&&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,a=t.slice();function o(c){return c.length>1&&c[0]==="-"}s(o,"maybeOption");let u=s(c=>/^-\d*\.?\d+(e[+-]?\d+)?$/.test(c)?!this._getCommandAndAncestors().some(d=>d.options.map(f=>f.short).some(f=>/^-\d$/.test(f))):!1,"negativeNumberArg"),l=null;for(;a.length;){let c=a.shift();if(c==="--"){i===n&&i.push(c),i.push(...a);break}if(l&&(!o(c)||u(c))){this.emit(`option:${l.name()}`,c);continue}if(l=null,o(c)){let d=this._findOption(c);if(d){if(d.required){let f=a.shift();f===void 0&&this.optionMissingArgument(d),this.emit(`option:${d.name()}`,f)}else if(d.optional){let f=null;a.length>0&&(!o(a[0])||u(a[0]))&&(f=a.shift()),this.emit(`option:${d.name()}`,f)}else this.emit(`option:${d.name()}`);l=d.variadic?d:null;continue}}if(c.length>2&&c[0]==="-"&&c[1]!=="-"){let d=this._findOption(`-${c[1]}`);if(d){d.required||d.optional&&this._combineFlagAndOptionalValue?this.emit(`option:${d.name()}`,c.slice(2)):(this.emit(`option:${d.name()}`),a.unshift(`-${c.slice(2)}`));continue}}if(/^--[^=]+=/.test(c)){let d=c.indexOf("="),f=this._findOption(c.slice(0,d));if(f&&(f.required||f.optional)){this.emit(`option:${f.name()}`,c.slice(d+1));continue}}if(i===r&&o(c)&&!(this.commands.length===0&&u(c))&&(i=n),(this._enablePositionalOptions||this._passThroughOptions)&&r.length===0&&n.length===0){if(this._findCommand(c)){r.push(c),a.length>0&&n.push(...a);break}else if(this._getHelpCommand()&&c===this._getHelpCommand().name()){r.push(c),a.length>0&&r.push(...a);break}else if(this._defaultCommandName){n.push(c),a.length>0&&n.push(...a);break}}if(this._passThroughOptions){i.push(c),a.length>0&&i.push(...a);break}i.push(c)}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 dt.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()}`,dt.env[t.envVar]):this.emit(`optionEnv:${t.name()}`))}})}_parseOptionsImplied(){let t=new Cpe(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(),l=this.getOptionValue(u),c=this.options.find(f=>f.negate&&u===f.attributeName()),d=this.options.find(f=>!f.negate&&u===f.attributeName());return c&&(c.presetArg===void 0&&l===!1||c.presetArg!==void 0&&l===c.presetArg)?c:d||o},"findBestOptionFromValue"),i=s(o=>{let u=n(o),l=u.attributeName();return this.getOptionValueSource(l)==="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=f$(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=f$(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=>Ipe(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=po.basename(t,po.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(dt.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 p$(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(p$,"incrementNodeInspectorPort");function mE(){if(dt.env.NO_COLOR||dt.env.FORCE_COLOR==="0"||dt.env.FORCE_COLOR==="false")return!1;if(dt.env.FORCE_COLOR||dt.env.CLICOLOR_FORCE!==void 0)return!0}s(mE,"useColor");gE.Command=hE;gE.useColor=mE});var b$=p(Gn=>{var{Argument:m$}=Ub(),{Command:yE}=h$(),{CommanderError:Ope,InvalidArgumentError:g$}=ih(),{Help:kpe}=oE(),{Option:y$}=dE();Gn.program=new yE;Gn.createCommand=e=>new yE(e);Gn.createOption=(e,t)=>new y$(e,t);Gn.createArgument=(e,t)=>new m$(e,t);Gn.Command=yE;Gn.Option=y$;Gn.Argument=m$;Gn.Help=kpe;Gn.CommanderError=Ope;Gn.InvalidArgumentError=g$;Gn.InvalidOptionArgumentError=g$});var k$=p(ad=>{"use strict";Object.defineProperty(ad,"__esModule",{value:!0});ad.splitWhen=ad.flatten=void 0;function jpe(e){return e.reduce((t,r)=>[].concat(t,r),[])}s(jpe,"flatten");ad.flatten=jpe;function Bpe(e,t){let r=[[]],n=0;for(let i of e)t(i)?(n++,r[n]=[]):r[n].push(i);return r}s(Bpe,"splitWhen");ad.splitWhen=Bpe});var P$=p(tv=>{"use strict";Object.defineProperty(tv,"__esModule",{value:!0});tv.isEnoentCodeError=void 0;function $pe(e){return e.code==="ENOENT"}s($pe,"isEnoentCodeError");tv.isEnoentCodeError=$pe});var R$=p(rv=>{"use strict";Object.defineProperty(rv,"__esModule",{value:!0});rv.createDirentFromStats=void 0;var TE=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 Vpe(e,t){return new TE(e,t)}s(Vpe,"createDirentFromStats");rv.createDirentFromStats=Vpe});var F$=p(dr=>{"use strict";Object.defineProperty(dr,"__esModule",{value:!0});dr.convertPosixPathToPattern=dr.convertWindowsPathToPattern=dr.convertPathToPattern=dr.escapePosixPath=dr.escapeWindowsPath=dr.escape=dr.removeLeadingDotSegment=dr.makeAbsolute=dr.unixify=void 0;var Upe=require("os"),Wpe=require("path"),M$=Upe.platform()==="win32",Hpe=2,zpe=/(\\?)([()*?[\]{|}]|^!|[!+@](?=\()|\\(?![!()*+?@[\]{|}]))/g,Gpe=/(\\?)([()[\]{}]|^!|[!+@](?=\())/g,Kpe=/^\\\\([.?])/,Zpe=/\\(?![!()+@[\]{}])/g;function Ype(e){return e.replace(/\\/g,"/")}s(Ype,"unixify");dr.unixify=Ype;function Jpe(e,t){return Wpe.resolve(e,t)}s(Jpe,"makeAbsolute");dr.makeAbsolute=Jpe;function Xpe(e){if(e.charAt(0)==="."){let t=e.charAt(1);if(t==="/"||t==="\\")return e.slice(Hpe)}return e}s(Xpe,"removeLeadingDotSegment");dr.removeLeadingDotSegment=Xpe;dr.escape=M$?IE:AE;function IE(e){return e.replace(Gpe,"\\$2")}s(IE,"escapeWindowsPath");dr.escapeWindowsPath=IE;function AE(e){return e.replace(zpe,"\\$2")}s(AE,"escapePosixPath");dr.escapePosixPath=AE;dr.convertPathToPattern=M$?N$:D$;function N$(e){return IE(e).replace(Kpe,"//$1").replace(Zpe,"/")}s(N$,"convertWindowsPathToPattern");dr.convertWindowsPathToPattern=N$;function D$(e){return AE(e)}s(D$,"convertPosixPathToPattern");dr.convertPosixPathToPattern=D$});var q$=p((Egt,L$)=>{L$.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 $$=p((Ogt,B$)=>{var Qpe=q$(),j$={"{":"}","(":")","[":"]"},ehe=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 l=j$[u];if(l){var c=e.indexOf(l,t);c!==-1&&(t=c+1)}if(e[t]==="!")return!0}else t++}return!1},"strictCheck"),the=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=j$[r];if(n){var i=e.indexOf(n,t);i!==-1&&(t=i+1)}if(e[t]==="!")return!0}else t++}return!1},"relaxedCheck");B$.exports=s(function(t,r){if(typeof t!="string"||t==="")return!1;if(Qpe(t))return!0;var n=ehe;return r&&r.strict===!1&&(n=the),n(t)},"isGlob")});var U$=p((Pgt,V$)=>{"use strict";var rhe=$$(),nhe=require("path").posix.dirname,ihe=require("os").platform()==="win32",EE="/",she=/\\/g,ahe=/[\{\[].*[\}\]]$/,ohe=/(^|[^\\])([\{\[]|\([^\)]+$)/,uhe=/\\([\!\*\?\|\[\]\(\)\{\}])/g;V$.exports=s(function(t,r){var n=Object.assign({flipBackslashes:!0},r);n.flipBackslashes&&ihe&&t.indexOf(EE)<0&&(t=t.replace(she,EE)),ahe.test(t)&&(t+=EE),t+="a";do t=nhe(t);while(rhe(t)||ohe.test(t));return t.replace(uhe,"$1")},"globParent")});var nv=p(Kn=>{"use strict";Kn.isInteger=e=>typeof e=="number"?Number.isInteger(e):typeof e=="string"&&e.trim()!==""?Number.isInteger(Number(e)):!1;Kn.find=(e,t)=>e.nodes.find(r=>r.type===t);Kn.exceedsLimit=(e,t,r=1,n)=>n===!1||!Kn.isInteger(e)||!Kn.isInteger(t)?!1:(Number(t)-Number(e))/Number(r)>=n;Kn.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)};Kn.encloseBrace=e=>e.type!=="brace"?!1:e.commas>>0+e.ranges>>0===0?(e.invalid=!0,!0):!1;Kn.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;Kn.isOpenOrClose=e=>e.type==="open"||e.type==="close"?!0:e.open===!0||e.close===!0;Kn.reduce=e=>e.reduce((t,r)=>(r.type==="text"&&t.push(r.value),r.type==="range"&&(r.type="text"),t),[]);Kn.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 iv=p((Dgt,H$)=>{"use strict";var W$=nv();H$.exports=(e,t={})=>{let r=s((n,i={})=>{let a=t.escapeInvalid&&W$.isInvalidBrace(i),o=n.invalid===!0&&t.escapeInvalid===!0,u="";if(n.value)return(a||o)&&W$.isOpenOrClose(n)?"\\"+n.value:n.value;if(n.value)return n.value;if(n.nodes)for(let l of n.nodes)u+=r(l);return u},"stringify");return r(e)}});var G$=p((Lgt,z$)=>{"use strict";z$.exports=function(e){return typeof e=="number"?e-e===0:typeof e=="string"&&e.trim()!==""?Number.isFinite?Number.isFinite(+e):isFinite(+e):!1}});var rV=p((qgt,tV)=>{"use strict";var K$=G$(),Zl=s((e,t,r)=>{if(K$(e)===!1)throw new TypeError("toRegexRange: expected the first argument to be a number");if(t===void 0||e===t)return String(e);if(K$(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),l=e+":"+t+"="+i+a+o+u;if(Zl.cache.hasOwnProperty(l))return Zl.cache[l].result;let c=Math.min(e,t),d=Math.max(e,t);if(Math.abs(c-d)===1){let y=e+"|"+t;return n.capture?`(${y})`:n.wrap===!1?y:`(?:${y})`}let f=eV(e)||eV(t),h={min:e,max:t,a:c,b:d},m=[],g=[];if(f&&(h.isPadded=f,h.maxLen=String(h.max).length),c<0){let y=d<0?Math.abs(d):1;g=Z$(y,Math.abs(c),h,n),c=h.a=0}return d>=0&&(m=Z$(c,d,h,n)),h.negatives=g,h.positives=m,h.result=lhe(g,m,n),n.capture===!0?h.result=`(${h.result})`:n.wrap!==!1&&m.length+g.length>1&&(h.result=`(?:${h.result})`),Zl.cache[l]=h,h.result},"toRegexRange");function lhe(e,t,r){let n=CE(e,t,"-",!1,r)||[],i=CE(t,e,"",!1,r)||[],a=CE(e,t,"-?",!0,r)||[];return n.concat(a).concat(i).join("|")}s(lhe,"collatePatterns");function che(e,t){let r=1,n=1,i=J$(e,r),a=new Set([t]);for(;e<=i&&i<=t;)a.add(i),r+=1,i=J$(e,r);for(i=X$(t+1,n)-1;e<i&&i<=t;)a.add(i),n+=1,i=X$(t+1,n)-1;return a=[...a],a.sort(phe),a}s(che,"splitToRanges");function dhe(e,t,r){if(e===t)return{pattern:e,count:[],digits:0};let n=fhe(e,t),i=n.length,a="",o=0;for(let u=0;u<i;u++){let[l,c]=n[u];l===c?a+=l:l!=="0"||c!=="9"?a+=hhe(l,c,r):o++}return o&&(a+=r.shorthand===!0?"\\d":"[0-9]"),{pattern:a,count:[o],digits:i}}s(dhe,"rangeToPattern");function Z$(e,t,r,n){let i=che(e,t),a=[],o=e,u;for(let l=0;l<i.length;l++){let c=i[l],d=dhe(String(o),String(c),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+Q$(u.count),o=c+1;continue}r.isPadded&&(f=mhe(c,r,n)),d.string=f+d.pattern+Q$(d.count),a.push(d),o=c+1,u=d}return a}s(Z$,"splitToPatterns");function CE(e,t,r,n,i){let a=[];for(let o of e){let{string:u}=o;!n&&!Y$(t,"string",u)&&a.push(r+u),n&&Y$(t,"string",u)&&a.push(r+u)}return a}s(CE,"filterPatterns");function fhe(e,t){let r=[];for(let n=0;n<e.length;n++)r.push([e[n],t[n]]);return r}s(fhe,"zip");function phe(e,t){return e>t?1:t>e?-1:0}s(phe,"compare");function Y$(e,t,r){return e.some(n=>n[t]===r)}s(Y$,"contains");function J$(e,t){return Number(String(e).slice(0,-t)+"9".repeat(t))}s