@versiwfekit/verify-commit
Version:
verify-commit config used by versiw
27 lines • 90.2 kB
JavaScript
#!/usr/bin/env node
import Bu from"node:events";import _u from"node:child_process";import Oe from"node:path";import Se from"node:fs";import H,{stdin as Te,stdout as ke}from"node:process";import"node:util";import*as q from"node:readline";import Ve from"node:readline";import{WriteStream as vu}from"node:tty";import xu from"child_process";import ue from"path";import te from"fs";var $u=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function re(s){return s&&s.__esModule&&Object.prototype.hasOwnProperty.call(s,"default")?s.default:s}var N={exports:{}},He;function wu(){if(He)return N.exports;He=1;let s=process||{},i=s.argv||[],o=s.env||{},a=!(o.NO_COLOR||i.includes("--no-color"))&&(!!o.FORCE_COLOR||i.includes("--color")||s.platform==="win32"||(s.stdout||{}).isTTY&&o.TERM!=="dumb"||!!o.CI),t=(D,l,p=D)=>d=>{let f=""+d,g=f.indexOf(l,D.length);return~g?D+r(f,l,p,g)+l:D+f+l},r=(D,l,p,d)=>{let f="",g=0;do f+=D.substring(g,d)+p,g=d+l.length,d=D.indexOf(l,g);while(~d);return f+D.substring(g)},e=(D=a)=>{let l=D?t:()=>String;return{isColorSupported:D,reset:l("\x1B[0m","\x1B[0m"),bold:l("\x1B[1m","\x1B[22m","\x1B[22m\x1B[1m"),dim:l("\x1B[2m","\x1B[22m","\x1B[22m\x1B[2m"),italic:l("\x1B[3m","\x1B[23m"),underline:l("\x1B[4m","\x1B[24m"),inverse:l("\x1B[7m","\x1B[27m"),hidden:l("\x1B[8m","\x1B[28m"),strikethrough:l("\x1B[9m","\x1B[29m"),black:l("\x1B[30m","\x1B[39m"),red:l("\x1B[31m","\x1B[39m"),green:l("\x1B[32m","\x1B[39m"),yellow:l("\x1B[33m","\x1B[39m"),blue:l("\x1B[34m","\x1B[39m"),magenta:l("\x1B[35m","\x1B[39m"),cyan:l("\x1B[36m","\x1B[39m"),white:l("\x1B[37m","\x1B[39m"),gray:l("\x1B[90m","\x1B[39m"),bgBlack:l("\x1B[40m","\x1B[49m"),bgRed:l("\x1B[41m","\x1B[49m"),bgGreen:l("\x1B[42m","\x1B[49m"),bgYellow:l("\x1B[43m","\x1B[49m"),bgBlue:l("\x1B[44m","\x1B[49m"),bgMagenta:l("\x1B[45m","\x1B[49m"),bgCyan:l("\x1B[46m","\x1B[49m"),bgWhite:l("\x1B[47m","\x1B[49m"),blackBright:l("\x1B[90m","\x1B[39m"),redBright:l("\x1B[91m","\x1B[39m"),greenBright:l("\x1B[92m","\x1B[39m"),yellowBright:l("\x1B[93m","\x1B[39m"),blueBright:l("\x1B[94m","\x1B[39m"),magentaBright:l("\x1B[95m","\x1B[39m"),cyanBright:l("\x1B[96m","\x1B[39m"),whiteBright:l("\x1B[97m","\x1B[39m"),bgBlackBright:l("\x1B[100m","\x1B[49m"),bgRedBright:l("\x1B[101m","\x1B[49m"),bgGreenBright:l("\x1B[102m","\x1B[49m"),bgYellowBright:l("\x1B[103m","\x1B[49m"),bgBlueBright:l("\x1B[104m","\x1B[49m"),bgMagentaBright:l("\x1B[105m","\x1B[49m"),bgCyanBright:l("\x1B[106m","\x1B[49m"),bgWhiteBright:l("\x1B[107m","\x1B[49m")}};return N.exports=e(),N.exports.createColors=e,N.exports}var yu=wu();const F=re(yu);var T={},L={},G={},Pe;function U(){if(Pe)return G;Pe=1;class s extends Error{constructor(a,t,r){super(r),Error.captureStackTrace(this,this.constructor),this.name=this.constructor.name,this.code=t,this.exitCode=a,this.nestedError=void 0}}class i extends s{constructor(a){super(1,"commander.invalidArgument",a),Error.captureStackTrace(this,this.constructor),this.name=this.constructor.name}}return G.CommanderError=s,G.InvalidArgumentError=i,G}var Me;function ie(){if(Me)return L;Me=1;const{InvalidArgumentError:s}=U();class i{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,e)=>{if(!this.argChoices.includes(r))throw new s(`Allowed choices are ${this.argChoices.join(", ")}.`);return this.variadic?this._concatValue(r,e):r},this}argRequired(){return this.required=!0,this}argOptional(){return this.required=!1,this}}function o(a){const t=a.name()+(a.variadic===!0?"...":"");return a.required?"<"+t+">":"["+t+"]"}return L.Argument=i,L.humanReadableArgName=o,L}var K={},z={},Re;function We(){if(Re)return z;Re=1;const{humanReadableArgName:s}=ie();class i{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){const r=t.commands.filter(D=>!D._hidden),e=t._getHelpCommand();return e&&!e._hidden&&r.push(e),this.sortSubcommands&&r.sort((D,l)=>D.name().localeCompare(l.name())),r}compareOptions(t,r){const e=D=>D.short?D.short.replace(/^-/,""):D.long.replace(/^--/,"");return e(t).localeCompare(e(r))}visibleOptions(t){const r=t.options.filter(D=>!D.hidden),e=t._getHelpOption();if(e&&!e.hidden){const D=e.short&&t._findOption(e.short),l=e.long&&t._findOption(e.long);!D&&!l?r.push(e):e.long&&!l?r.push(t.createOption(e.long,e.description)):e.short&&!D&&r.push(t.createOption(e.short,e.description))}return this.sortOptions&&r.sort(this.compareOptions),r}visibleGlobalOptions(t){if(!this.showGlobalOptions)return[];const r=[];for(let e=t.parent;e;e=e.parent){const D=e.options.filter(l=>!l.hidden);r.push(...D)}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){const r=t.registeredArguments.map(e=>s(e)).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((e,D)=>Math.max(e,this.displayWidth(r.styleSubcommandTerm(r.subcommandTerm(D)))),0)}longestOptionTermLength(t,r){return r.visibleOptions(t).reduce((e,D)=>Math.max(e,this.displayWidth(r.styleOptionTerm(r.optionTerm(D)))),0)}longestGlobalOptionTermLength(t,r){return r.visibleGlobalOptions(t).reduce((e,D)=>Math.max(e,this.displayWidth(r.styleOptionTerm(r.optionTerm(D)))),0)}longestArgumentTermLength(t,r){return r.visibleArguments(t).reduce((e,D)=>Math.max(e,this.displayWidth(r.styleArgumentTerm(r.argumentTerm(D)))),0)}commandUsage(t){let r=t._name;t._aliases[0]&&(r=r+"|"+t._aliases[0]);let e="";for(let D=t.parent;D;D=D.parent)e=D.name()+" "+e;return e+r+" "+t.usage()}commandDescription(t){return t.description()}subcommandDescription(t){return t.summary()||t.description()}optionDescription(t){const r=[];return t.argChoices&&r.push(`choices: ${t.argChoices.map(e=>JSON.stringify(e)).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?`${t.description} (${r.join(", ")})`:t.description}argumentDescription(t){const r=[];if(t.argChoices&&r.push(`choices: ${t.argChoices.map(e=>JSON.stringify(e)).join(", ")}`),t.defaultValue!==void 0&&r.push(`default: ${t.defaultValueDescription||JSON.stringify(t.defaultValue)}`),r.length>0){const e=`(${r.join(", ")})`;return t.description?`${t.description} ${e}`:e}return t.description}formatHelp(t,r){const e=r.padWidth(t,r),D=r.helpWidth??80;function l(B,x){return r.formatItem(B,e,x,r)}let p=[`${r.styleTitle("Usage:")} ${r.styleUsage(r.commandUsage(t))}`,""];const d=r.commandDescription(t);d.length>0&&(p=p.concat([r.boxWrap(r.styleCommandDescription(d),D),""]));const f=r.visibleArguments(t).map(B=>l(r.styleArgumentTerm(r.argumentTerm(B)),r.styleArgumentDescription(r.argumentDescription(B))));f.length>0&&(p=p.concat([r.styleTitle("Arguments:"),...f,""]));const g=r.visibleOptions(t).map(B=>l(r.styleOptionTerm(r.optionTerm(B)),r.styleOptionDescription(r.optionDescription(B))));if(g.length>0&&(p=p.concat([r.styleTitle("Options:"),...g,""])),r.showGlobalOptions){const B=r.visibleGlobalOptions(t).map(x=>l(r.styleOptionTerm(r.optionTerm(x)),r.styleOptionDescription(r.optionDescription(x))));B.length>0&&(p=p.concat([r.styleTitle("Global Options:"),...B,""]))}const A=r.visibleCommands(t).map(B=>l(r.styleSubcommandTerm(r.subcommandTerm(B)),r.styleSubcommandDescription(r.subcommandDescription(B))));return A.length>0&&(p=p.concat([r.styleTitle("Commands:"),...A,""])),p.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,e,D){const p=" ".repeat(2);if(!e)return p+t;const d=t.padEnd(r+t.length-D.displayWidth(t)),f=2,A=(this.helpWidth??80)-r-f-2;let B;return A<this.minWidthToWrap||D.preformatted(e)?B=e:B=D.boxWrap(e,A).replace(/\n/g,`
`+" ".repeat(r+f)),p+d+" ".repeat(f)+B.replace(/\n/g,`
${p}`)}boxWrap(t,r){if(r<this.minWidthToWrap)return t;const e=t.split(/\r\n|\n/),D=/[\s]*[^\s]+/g,l=[];return e.forEach(p=>{const d=p.match(D);if(d===null){l.push("");return}let f=[d.shift()],g=this.displayWidth(f[0]);d.forEach(A=>{const B=this.displayWidth(A);if(g+B<=r){f.push(A),g+=B;return}l.push(f.join(""));const x=A.trimStart();f=[x],g=this.displayWidth(x)}),l.push(f.join(""))}),l.join(`
`)}}function o(a){const t=/\x1b\[\d*(;\d*)*m/g;return a.replace(t,"")}return z.Help=i,z.stripColor=o,z}var Y={},Ie;function je(){if(Ie)return Y;Ie=1;const{InvalidArgumentError:s}=U();class i{constructor(e,D){this.flags=e,this.description=D||"",this.required=e.includes("<"),this.optional=e.includes("["),this.variadic=/\w\.\.\.[>\]]$/.test(e),this.mandatory=!1;const l=t(e);this.short=l.shortFlag,this.long=l.longFlag,this.negate=!1,this.long&&(this.negate=this.long.startsWith("--no-")),this.defaultValue=void 0,this.defaultValueDescription=void 0,this.presetArg=void 0,this.envVar=void 0,this.parseArg=void 0,this.hidden=!1,this.argChoices=void 0,this.conflictsWith=[],this.implied=void 0}default(e,D){return this.defaultValue=e,this.defaultValueDescription=D,this}preset(e){return this.presetArg=e,this}conflicts(e){return this.conflictsWith=this.conflictsWith.concat(e),this}implies(e){let D=e;return typeof e=="string"&&(D={[e]:!0}),this.implied=Object.assign(this.implied||{},D),this}env(e){return this.envVar=e,this}argParser(e){return this.parseArg=e,this}makeOptionMandatory(e=!0){return this.mandatory=!!e,this}hideHelp(e=!0){return this.hidden=!!e,this}_concatValue(e,D){return D===this.defaultValue||!Array.isArray(D)?[e]:D.concat(e)}choices(e){return this.argChoices=e.slice(),this.parseArg=(D,l)=>{if(!this.argChoices.includes(D))throw new s(`Allowed choices are ${this.argChoices.join(", ")}.`);return this.variadic?this._concatValue(D,l):D},this}name(){return this.long?this.long.replace(/^--/,""):this.short.replace(/^-/,"")}attributeName(){return this.negate?a(this.name().replace(/^no-/,"")):a(this.name())}is(e){return this.short===e||this.long===e}isBoolean(){return!this.required&&!this.optional&&!this.negate}}class o{constructor(e){this.positiveOptions=new Map,this.negativeOptions=new Map,this.dualOptions=new Set,e.forEach(D=>{D.negate?this.negativeOptions.set(D.attributeName(),D):this.positiveOptions.set(D.attributeName(),D)}),this.negativeOptions.forEach((D,l)=>{this.positiveOptions.has(l)&&this.dualOptions.add(l)})}valueFromOption(e,D){const l=D.attributeName();if(!this.dualOptions.has(l))return!0;const p=this.negativeOptions.get(l).presetArg,d=p!==void 0?p:!1;return D.negate===(d===e)}}function a(r){return r.split("-").reduce((e,D)=>e+D[0].toUpperCase()+D.slice(1))}function t(r){let e,D;const l=/^-[^-]$/,p=/^--[^-]/,d=r.split(/[ |,]+/).concat("guard");if(l.test(d[0])&&(e=d.shift()),p.test(d[0])&&(D=d.shift()),!e&&l.test(d[0])&&(e=d.shift()),!e&&p.test(d[0])&&(e=D,D=d.shift()),d[0].startsWith("-")){const f=d[0],g=`option creation failed due to '${f}' in option flags '${r}'`;throw/^-[^-][^-]/.test(f)?new Error(`${g}
- 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')`):l.test(f)?new Error(`${g}
- too many short flags`):p.test(f)?new Error(`${g}
- too many long flags`):new Error(`${g}
- unrecognised flag format`)}if(e===void 0&&D===void 0)throw new Error(`option creation failed due to no flags found in '${r}'.`);return{shortFlag:e,longFlag:D}}return Y.Option=i,Y.DualOptions=o,Y}var se={},qe;function Ou(){if(qe)return se;qe=1;const s=3;function i(a,t){if(Math.abs(a.length-t.length)>s)return Math.max(a.length,t.length);const r=[];for(let e=0;e<=a.length;e++)r[e]=[e];for(let e=0;e<=t.length;e++)r[0][e]=e;for(let e=1;e<=t.length;e++)for(let D=1;D<=a.length;D++){let l=1;a[D-1]===t[e-1]?l=0:l=1,r[D][e]=Math.min(r[D-1][e]+1,r[D][e-1]+1,r[D-1][e-1]+l),D>1&&e>1&&a[D-1]===t[e-2]&&a[D-2]===t[e-1]&&(r[D][e]=Math.min(r[D][e],r[D-2][e-2]+1))}return r[a.length][t.length]}function o(a,t){if(!t||t.length===0)return"";t=Array.from(new Set(t));const r=a.startsWith("--");r&&(a=a.slice(2),t=t.map(p=>p.slice(2)));let e=[],D=s;const l=.4;return t.forEach(p=>{if(p.length<=1)return;const d=i(a,p),f=Math.max(a.length,p.length);(f-d)/f>l&&(d<D?(D=d,e=[p]):d===D&&e.push(p))}),e.sort((p,d)=>p.localeCompare(d)),r&&(e=e.map(p=>`--${p}`)),e.length>1?`
(Did you mean one of ${e.join(", ")}?)`:e.length===1?`
(Did you mean ${e[0]}?)`:""}return se.suggestSimilar=o,se}var Ne;function Su(){if(Ne)return K;Ne=1;const s=Bu.EventEmitter,i=_u,o=Oe,a=Se,t=H,{Argument:r,humanReadableArgName:e}=ie(),{CommanderError:D}=U(),{Help:l,stripColor:p}=We(),{Option:d,DualOptions:f}=je(),{suggestSimilar:g}=Ou();class A extends s{constructor(u){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=u||"",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:n=>t.stdout.write(n),writeErr:n=>t.stderr.write(n),outputError:(n,h)=>h(n),getOutHelpWidth:()=>t.stdout.isTTY?t.stdout.columns:void 0,getErrHelpWidth:()=>t.stderr.isTTY?t.stderr.columns:void 0,getOutHasColors:()=>x()??(t.stdout.isTTY&&t.stdout.hasColors?.()),getErrHasColors:()=>x()??(t.stderr.isTTY&&t.stderr.hasColors?.()),stripColor:n=>p(n)},this._hidden=!1,this._helpOption=void 0,this._addImplicitHelpCommand=void 0,this._helpCommand=void 0,this._helpConfiguration={}}copyInheritedSettings(u){return this._outputConfiguration=u._outputConfiguration,this._helpOption=u._helpOption,this._helpCommand=u._helpCommand,this._helpConfiguration=u._helpConfiguration,this._exitCallback=u._exitCallback,this._storeOptionsAsProperties=u._storeOptionsAsProperties,this._combineFlagAndOptionalValue=u._combineFlagAndOptionalValue,this._allowExcessArguments=u._allowExcessArguments,this._enablePositionalOptions=u._enablePositionalOptions,this._showHelpAfterError=u._showHelpAfterError,this._showSuggestionAfterError=u._showSuggestionAfterError,this}_getCommandAndAncestors(){const u=[];for(let n=this;n;n=n.parent)u.push(n);return u}command(u,n,h){let c=n,m=h;typeof c=="object"&&c!==null&&(m=c,c=null),m=m||{};const[,C,b]=u.match(/([^ ]+) *(.*)/),E=this.createCommand(C);return c&&(E.description(c),E._executableHandler=!0),m.isDefault&&(this._defaultCommandName=E._name),E._hidden=!!(m.noHelp||m.hidden),E._executableFile=m.executableFile||null,b&&E.arguments(b),this._registerCommand(E),E.parent=this,E.copyInheritedSettings(this),c?this:E}createCommand(u){return new A(u)}createHelp(){return Object.assign(new l,this.configureHelp())}configureHelp(u){return u===void 0?this._helpConfiguration:(this._helpConfiguration=u,this)}configureOutput(u){return u===void 0?this._outputConfiguration:(Object.assign(this._outputConfiguration,u),this)}showHelpAfterError(u=!0){return typeof u!="string"&&(u=!!u),this._showHelpAfterError=u,this}showSuggestionAfterError(u=!0){return this._showSuggestionAfterError=!!u,this}addCommand(u,n){if(!u._name)throw new Error(`Command passed to .addCommand() must have a name
- specify the name in Command constructor or using .name()`);return n=n||{},n.isDefault&&(this._defaultCommandName=u._name),(n.noHelp||n.hidden)&&(u._hidden=!0),this._registerCommand(u),u.parent=this,u._checkForBrokenPassThrough(),this}createArgument(u,n){return new r(u,n)}argument(u,n,h,c){const m=this.createArgument(u,n);return typeof h=="function"?m.default(c).argParser(h):m.default(h),this.addArgument(m),this}arguments(u){return u.trim().split(/ +/).forEach(n=>{this.argument(n)}),this}addArgument(u){const n=this.registeredArguments.slice(-1)[0];if(n&&n.variadic)throw new Error(`only the last argument can be variadic '${n.name()}'`);if(u.required&&u.defaultValue!==void 0&&u.parseArg===void 0)throw new Error(`a default value for a required argument is never used: '${u.name()}'`);return this.registeredArguments.push(u),this}helpCommand(u,n){if(typeof u=="boolean")return this._addImplicitHelpCommand=u,this;u=u??"help [command]";const[,h,c]=u.match(/([^ ]+) *(.*)/),m=n??"display help for command",C=this.createCommand(h);return C.helpOption(!1),c&&C.arguments(c),m&&C.description(m),this._addImplicitHelpCommand=!0,this._helpCommand=C,this}addHelpCommand(u,n){return typeof u!="object"?(this.helpCommand(u,n),this):(this._addImplicitHelpCommand=!0,this._helpCommand=u,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(u,n){const h=["preSubcommand","preAction","postAction"];if(!h.includes(u))throw new Error(`Unexpected value for event passed to hook : '${u}'.
Expecting one of '${h.join("', '")}'`);return this._lifeCycleHooks[u]?this._lifeCycleHooks[u].push(n):this._lifeCycleHooks[u]=[n],this}exitOverride(u){return u?this._exitCallback=u:this._exitCallback=n=>{if(n.code!=="commander.executeSubCommandAsync")throw n},this}_exit(u,n,h){this._exitCallback&&this._exitCallback(new D(u,n,h)),t.exit(u)}action(u){const n=h=>{const c=this.registeredArguments.length,m=h.slice(0,c);return this._storeOptionsAsProperties?m[c]=this:m[c]=this.opts(),m.push(this),u.apply(this,m)};return this._actionHandler=n,this}createOption(u,n){return new d(u,n)}_callParseArg(u,n,h,c){try{return u.parseArg(n,h)}catch(m){if(m.code==="commander.invalidArgument"){const C=`${c} ${m.message}`;this.error(C,{exitCode:m.exitCode,code:m.code})}throw m}}_registerOption(u){const n=u.short&&this._findOption(u.short)||u.long&&this._findOption(u.long);if(n){const h=u.long&&this._findOption(u.long)?u.long:u.short;throw new Error(`Cannot add option '${u.flags}'${this._name&&` to command '${this._name}'`} due to conflicting flag '${h}'
- already used by option '${n.flags}'`)}this.options.push(u)}_registerCommand(u){const n=c=>[c.name()].concat(c.aliases()),h=n(u).find(c=>this._findCommand(c));if(h){const c=n(this._findCommand(h)).join("|"),m=n(u).join("|");throw new Error(`cannot add command '${m}' as already have command '${c}'`)}this.commands.push(u)}addOption(u){this._registerOption(u);const n=u.name(),h=u.attributeName();if(u.negate){const m=u.long.replace(/^--no-/,"--");this._findOption(m)||this.setOptionValueWithSource(h,u.defaultValue===void 0?!0:u.defaultValue,"default")}else u.defaultValue!==void 0&&this.setOptionValueWithSource(h,u.defaultValue,"default");const c=(m,C,b)=>{m==null&&u.presetArg!==void 0&&(m=u.presetArg);const E=this.getOptionValue(h);m!==null&&u.parseArg?m=this._callParseArg(u,m,E,C):m!==null&&u.variadic&&(m=u._concatValue(m,E)),m==null&&(u.negate?m=!1:u.isBoolean()||u.optional?m=!0:m=""),this.setOptionValueWithSource(h,m,b)};return this.on("option:"+n,m=>{const C=`error: option '${u.flags}' argument '${m}' is invalid.`;c(m,C,"cli")}),u.envVar&&this.on("optionEnv:"+n,m=>{const C=`error: option '${u.flags}' value '${m}' from env '${u.envVar}' is invalid.`;c(m,C,"env")}),this}_optionEx(u,n,h,c,m){if(typeof n=="object"&&n instanceof d)throw new Error("To add an Option object use addOption() instead of option() or requiredOption()");const C=this.createOption(n,h);if(C.makeOptionMandatory(!!u.mandatory),typeof c=="function")C.default(m).argParser(c);else if(c instanceof RegExp){const b=c;c=(E,v)=>{const _=b.exec(E);return _?_[0]:v},C.default(m).argParser(c)}else C.default(c);return this.addOption(C)}option(u,n,h,c){return this._optionEx({},u,n,h,c)}requiredOption(u,n,h,c){return this._optionEx({mandatory:!0},u,n,h,c)}combineFlagAndOptionalValue(u=!0){return this._combineFlagAndOptionalValue=!!u,this}allowUnknownOption(u=!0){return this._allowUnknownOption=!!u,this}allowExcessArguments(u=!0){return this._allowExcessArguments=!!u,this}enablePositionalOptions(u=!0){return this._enablePositionalOptions=!!u,this}passThroughOptions(u=!0){return this._passThroughOptions=!!u,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(u=!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=!!u,this}getOptionValue(u){return this._storeOptionsAsProperties?this[u]:this._optionValues[u]}setOptionValue(u,n){return this.setOptionValueWithSource(u,n,void 0)}setOptionValueWithSource(u,n,h){return this._storeOptionsAsProperties?this[u]=n:this._optionValues[u]=n,this._optionValueSources[u]=h,this}getOptionValueSource(u){return this._optionValueSources[u]}getOptionValueSourceWithGlobals(u){let n;return this._getCommandAndAncestors().forEach(h=>{h.getOptionValueSource(u)!==void 0&&(n=h.getOptionValueSource(u))}),n}_prepareUserArgs(u,n){if(u!==void 0&&!Array.isArray(u))throw new Error("first parameter to parse must be array or undefined");if(n=n||{},u===void 0&&n.from===void 0){t.versions?.electron&&(n.from="electron");const c=t.execArgv??[];(c.includes("-e")||c.includes("--eval")||c.includes("-p")||c.includes("--print"))&&(n.from="eval")}u===void 0&&(u=t.argv),this.rawArgs=u.slice();let h;switch(n.from){case void 0:case"node":this._scriptPath=u[1],h=u.slice(2);break;case"electron":t.defaultApp?(this._scriptPath=u[1],h=u.slice(2)):h=u.slice(1);break;case"user":h=u.slice(0);break;case"eval":h=u.slice(1);break;default:throw new Error(`unexpected parse option { from: '${n.from}' }`)}return!this._name&&this._scriptPath&&this.nameFromFilename(this._scriptPath),this._name=this._name||"program",h}parse(u,n){this._prepareForParse();const h=this._prepareUserArgs(u,n);return this._parseCommand([],h),this}async parseAsync(u,n){this._prepareForParse();const h=this._prepareUserArgs(u,n);return await this._parseCommand([],h),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(u,n,h){if(a.existsSync(u))return;const c=n?`searched for local subcommand relative to directory '${n}'`:"no directory for search for local subcommand, use .executableDir() to supply a custom directory",m=`'${u}' does not exist
- if '${h}' 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
- ${c}`;throw new Error(m)}_executeSubCommand(u,n){n=n.slice();let h=!1;const c=[".js",".ts",".tsx",".mjs",".cjs"];function m(_,y){const j=o.resolve(_,y);if(a.existsSync(j))return j;if(c.includes(o.extname(y)))return;const ye=c.find(Au=>a.existsSync(`${j}${Au}`));if(ye)return`${j}${ye}`}this._checkForMissingMandatoryOptions(),this._checkForConflictingOptions();let C=u._executableFile||`${this._name}-${u._name}`,b=this._executableDir||"";if(this._scriptPath){let _;try{_=a.realpathSync(this._scriptPath)}catch{_=this._scriptPath}b=o.resolve(o.dirname(_),b)}if(b){let _=m(b,C);if(!_&&!u._executableFile&&this._scriptPath){const y=o.basename(this._scriptPath,o.extname(this._scriptPath));y!==this._name&&(_=m(b,`${y}-${u._name}`))}C=_||C}h=c.includes(o.extname(C));let E;t.platform!=="win32"?h?(n.unshift(C),n=B(t.execArgv).concat(n),E=i.spawn(t.argv[0],n,{stdio:"inherit"})):E=i.spawn(C,n,{stdio:"inherit"}):(this._checkForMissingExecutable(C,b,u._name),n.unshift(C),n=B(t.execArgv).concat(n),E=i.spawn(t.execPath,n,{stdio:"inherit"})),E.killed||["SIGUSR1","SIGUSR2","SIGTERM","SIGINT","SIGHUP"].forEach(y=>{t.on(y,()=>{E.killed===!1&&E.exitCode===null&&E.kill(y)})});const v=this._exitCallback;E.on("close",_=>{_=_??1,v?v(new D(_,"commander.executeSubCommandAsync","(close)")):t.exit(_)}),E.on("error",_=>{if(_.code==="ENOENT")this._checkForMissingExecutable(C,b,u._name);else if(_.code==="EACCES")throw new Error(`'${C}' not executable`);if(!v)t.exit(1);else{const y=new D(1,"commander.executeSubCommandAsync","(error)");y.nestedError=_,v(y)}}),this.runningCommand=E}_dispatchSubcommand(u,n,h){const c=this._findCommand(u);c||this.help({error:!0}),c._prepareForParse();let m;return m=this._chainOrCallSubCommandHook(m,c,"preSubcommand"),m=this._chainOrCall(m,()=>{if(c._executableHandler)this._executeSubCommand(c,n.concat(h));else return c._parseCommand(n,h)}),m}_dispatchHelpCommand(u){u||this.help();const n=this._findCommand(u);return n&&!n._executableHandler&&n.help(),this._dispatchSubcommand(u,[],[this._getHelpOption()?.long??this._getHelpOption()?.short??"--help"])}_checkNumberOfArguments(){this.registeredArguments.forEach((u,n)=>{u.required&&this.args[n]==null&&this.missingArgument(u.name())}),!(this.registeredArguments.length>0&&this.registeredArguments[this.registeredArguments.length-1].variadic)&&this.args.length>this.registeredArguments.length&&this._excessArguments(this.args)}_processArguments(){const u=(h,c,m)=>{let C=c;if(c!==null&&h.parseArg){const b=`error: command-argument value '${c}' is invalid for argument '${h.name()}'.`;C=this._callParseArg(h,c,m,b)}return C};this._checkNumberOfArguments();const n=[];this.registeredArguments.forEach((h,c)=>{let m=h.defaultValue;h.variadic?c<this.args.length?(m=this.args.slice(c),h.parseArg&&(m=m.reduce((C,b)=>u(h,b,C),h.defaultValue))):m===void 0&&(m=[]):c<this.args.length&&(m=this.args[c],h.parseArg&&(m=u(h,m,h.defaultValue))),n[c]=m}),this.processedArgs=n}_chainOrCall(u,n){return u&&u.then&&typeof u.then=="function"?u.then(()=>n()):n()}_chainOrCallHooks(u,n){let h=u;const c=[];return this._getCommandAndAncestors().reverse().filter(m=>m._lifeCycleHooks[n]!==void 0).forEach(m=>{m._lifeCycleHooks[n].forEach(C=>{c.push({hookedCommand:m,callback:C})})}),n==="postAction"&&c.reverse(),c.forEach(m=>{h=this._chainOrCall(h,()=>m.callback(m.hookedCommand,this))}),h}_chainOrCallSubCommandHook(u,n,h){let c=u;return this._lifeCycleHooks[h]!==void 0&&this._lifeCycleHooks[h].forEach(m=>{c=this._chainOrCall(c,()=>m(this,n))}),c}_parseCommand(u,n){const h=this.parseOptions(n);if(this._parseOptionsEnv(),this._parseOptionsImplied(),u=u.concat(h.operands),n=h.unknown,this.args=u.concat(n),u&&this._findCommand(u[0]))return this._dispatchSubcommand(u[0],u.slice(1),n);if(this._getHelpCommand()&&u[0]===this._getHelpCommand().name())return this._dispatchHelpCommand(u[1]);if(this._defaultCommandName)return this._outputHelpIfRequested(n),this._dispatchSubcommand(this._defaultCommandName,u,n);this.commands.length&&this.args.length===0&&!this._actionHandler&&!this._defaultCommandName&&this.help({error:!0}),this._outputHelpIfRequested(h.unknown),this._checkForMissingMandatoryOptions(),this._checkForConflictingOptions();const c=()=>{h.unknown.length>0&&this.unknownOption(h.unknown[0])},m=`command:${this.name()}`;if(this._actionHandler){c(),this._processArguments();let C;return C=this._chainOrCallHooks(C,"preAction"),C=this._chainOrCall(C,()=>this._actionHandler(this.processedArgs)),this.parent&&(C=this._chainOrCall(C,()=>{this.parent.emit(m,u,n)})),C=this._chainOrCallHooks(C,"postAction"),C}if(this.parent&&this.parent.listenerCount(m))c(),this._processArguments(),this.parent.emit(m,u,n);else if(u.length){if(this._findCommand("*"))return this._dispatchSubcommand("*",u,n);this.listenerCount("command:*")?this.emit("command:*",u,n):this.commands.length?this.unknownCommand():(c(),this._processArguments())}else this.commands.length?(c(),this.help({error:!0})):(c(),this._processArguments())}_findCommand(u){if(u)return this.commands.find(n=>n._name===u||n._aliases.includes(u))}_findOption(u){return this.options.find(n=>n.is(u))}_checkForMissingMandatoryOptions(){this._getCommandAndAncestors().forEach(u=>{u.options.forEach(n=>{n.mandatory&&u.getOptionValue(n.attributeName())===void 0&&u.missingMandatoryOptionValue(n)})})}_checkForConflictingLocalOptions(){const u=this.options.filter(h=>{const c=h.attributeName();return this.getOptionValue(c)===void 0?!1:this.getOptionValueSource(c)!=="default"});u.filter(h=>h.conflictsWith.length>0).forEach(h=>{const c=u.find(m=>h.conflictsWith.includes(m.attributeName()));c&&this._conflictingOption(h,c)})}_checkForConflictingOptions(){this._getCommandAndAncestors().forEach(u=>{u._checkForConflictingLocalOptions()})}parseOptions(u){const n=[],h=[];let c=n;const m=u.slice();function C(E){return E.length>1&&E[0]==="-"}let b=null;for(;m.length;){const E=m.shift();if(E==="--"){c===h&&c.push(E),c.push(...m);break}if(b&&!C(E)){this.emit(`option:${b.name()}`,E);continue}if(b=null,C(E)){const v=this._findOption(E);if(v){if(v.required){const _=m.shift();_===void 0&&this.optionMissingArgument(v),this.emit(`option:${v.name()}`,_)}else if(v.optional){let _=null;m.length>0&&!C(m[0])&&(_=m.shift()),this.emit(`option:${v.name()}`,_)}else this.emit(`option:${v.name()}`);b=v.variadic?v:null;continue}}if(E.length>2&&E[0]==="-"&&E[1]!=="-"){const v=this._findOption(`-${E[1]}`);if(v){v.required||v.optional&&this._combineFlagAndOptionalValue?this.emit(`option:${v.name()}`,E.slice(2)):(this.emit(`option:${v.name()}`),m.unshift(`-${E.slice(2)}`));continue}}if(/^--[^=]+=/.test(E)){const v=E.indexOf("="),_=this._findOption(E.slice(0,v));if(_&&(_.required||_.optional)){this.emit(`option:${_.name()}`,E.slice(v+1));continue}}if(C(E)&&(c=h),(this._enablePositionalOptions||this._passThroughOptions)&&n.length===0&&h.length===0){if(this._findCommand(E)){n.push(E),m.length>0&&h.push(...m);break}else if(this._getHelpCommand()&&E===this._getHelpCommand().name()){n.push(E),m.length>0&&n.push(...m);break}else if(this._defaultCommandName){h.push(E),m.length>0&&h.push(...m);break}}if(this._passThroughOptions){c.push(E),m.length>0&&c.push(...m);break}c.push(E)}return{operands:n,unknown:h}}opts(){if(this._storeOptionsAsProperties){const u={},n=this.options.length;for(let h=0;h<n;h++){const c=this.options[h].attributeName();u[c]=c===this._versionOptionName?this._version:this[c]}return u}return this._optionValues}optsWithGlobals(){return this._getCommandAndAncestors().reduce((u,n)=>Object.assign(u,n.opts()),{})}error(u,n){this._outputConfiguration.outputError(`${u}
`,this._outputConfiguration.writeErr),typeof this._showHelpAfterError=="string"?this._outputConfiguration.writeErr(`${this._showHelpAfterError}
`):this._showHelpAfterError&&(this._outputConfiguration.writeErr(`
`),this.outputHelp({error:!0}));const h=n||{},c=h.exitCode||1,m=h.code||"commander.error";this._exit(c,m,u)}_parseOptionsEnv(){this.options.forEach(u=>{if(u.envVar&&u.envVar in t.env){const n=u.attributeName();(this.getOptionValue(n)===void 0||["default","config","env"].includes(this.getOptionValueSource(n)))&&(u.required||u.optional?this.emit(`optionEnv:${u.name()}`,t.env[u.envVar]):this.emit(`optionEnv:${u.name()}`))}})}_parseOptionsImplied(){const u=new f(this.options),n=h=>this.getOptionValue(h)!==void 0&&!["default","implied"].includes(this.getOptionValueSource(h));this.options.filter(h=>h.implied!==void 0&&n(h.attributeName())&&u.valueFromOption(this.getOptionValue(h.attributeName()),h)).forEach(h=>{Object.keys(h.implied).filter(c=>!n(c)).forEach(c=>{this.setOptionValueWithSource(c,h.implied[c],"implied")})})}missingArgument(u){const n=`error: missing required argument '${u}'`;this.error(n,{code:"commander.missingArgument"})}optionMissingArgument(u){const n=`error: option '${u.flags}' argument missing`;this.error(n,{code:"commander.optionMissingArgument"})}missingMandatoryOptionValue(u){const n=`error: required option '${u.flags}' not specified`;this.error(n,{code:"commander.missingMandatoryOptionValue"})}_conflictingOption(u,n){const h=C=>{const b=C.attributeName(),E=this.getOptionValue(b),v=this.options.find(y=>y.negate&&b===y.attributeName()),_=this.options.find(y=>!y.negate&&b===y.attributeName());return v&&(v.presetArg===void 0&&E===!1||v.presetArg!==void 0&&E===v.presetArg)?v:_||C},c=C=>{const b=h(C),E=b.attributeName();return this.getOptionValueSource(E)==="env"?`environment variable '${b.envVar}'`:`option '${b.flags}'`},m=`error: ${c(u)} cannot be used with ${c(n)}`;this.error(m,{code:"commander.conflictingOption"})}unknownOption(u){if(this._allowUnknownOption)return;let n="";if(u.startsWith("--")&&this._showSuggestionAfterError){let c=[],m=this;do{const C=m.createHelp().visibleOptions(m).filter(b=>b.long).map(b=>b.long);c=c.concat(C),m=m.parent}while(m&&!m._enablePositionalOptions);n=g(u,c)}const h=`error: unknown option '${u}'${n}`;this.error(h,{code:"commander.unknownOption"})}_excessArguments(u){if(this._allowExcessArguments)return;const n=this.registeredArguments.length,h=n===1?"":"s",m=`error: too many arguments${this.parent?` for '${this.name()}'`:""}. Expected ${n} argument${h} but got ${u.length}.`;this.error(m,{code:"commander.excessArguments"})}unknownCommand(){const u=this.args[0];let n="";if(this._showSuggestionAfterError){const c=[];this.createHelp().visibleCommands(this).forEach(m=>{c.push(m.name()),m.alias()&&c.push(m.alias())}),n=g(u,c)}const h=`error: unknown command '${u}'${n}`;this.error(h,{code:"commander.unknownCommand"})}version(u,n,h){if(u===void 0)return this._version;this._version=u,n=n||"-V, --version",h=h||"output the version number";const c=this.createOption(n,h);return this._versionOptionName=c.attributeName(),this._registerOption(c),this.on("option:"+c.name(),()=>{this._outputConfiguration.writeOut(`${u}
`),this._exit(0,"commander.version",u)}),this}description(u,n){return u===void 0&&n===void 0?this._description:(this._description=u,n&&(this._argsDescription=n),this)}summary(u){return u===void 0?this._summary:(this._summary=u,this)}alias(u){if(u===void 0)return this._aliases[0];let n=this;if(this.commands.length!==0&&this.commands[this.commands.length-1]._executableHandler&&(n=this.commands[this.commands.length-1]),u===n._name)throw new Error("Command alias can't be the same as its name");const h=this.parent?._findCommand(u);if(h){const c=[h.name()].concat(h.aliases()).join("|");throw new Error(`cannot add alias '${u}' to command '${this.name()}' as already have command '${c}'`)}return n._aliases.push(u),this}aliases(u){return u===void 0?this._aliases:(u.forEach(n=>this.alias(n)),this)}usage(u){if(u===void 0){if(this._usage)return this._usage;const n=this.registeredArguments.map(h=>e(h));return[].concat(this.options.length||this._helpOption!==null?"[options]":[],this.commands.length?"[command]":[],this.registeredArguments.length?n:[]).join(" ")}return this._usage=u,this}name(u){return u===void 0?this._name:(this._name=u,this)}nameFromFilename(u){return this._name=o.basename(u,o.extname(u)),this}executableDir(u){return u===void 0?this._executableDir:(this._executableDir=u,this)}helpInformation(u){const n=this.createHelp(),h=this._getOutputContext(u);n.prepareContext({error:h.error,helpWidth:h.helpWidth,outputHasColors:h.hasColors});const c=n.formatHelp(this,n);return h.hasColors?c:this._outputConfiguration.stripColor(c)}_getOutputContext(u){u=u||{};const n=!!u.error;let h,c,m;return n?(h=b=>this._outputConfiguration.writeErr(b),c=this._outputConfiguration.getErrHasColors(),m=this._outputConfiguration.getErrHelpWidth()):(h=b=>this._outputConfiguration.writeOut(b),c=this._outputConfiguration.getOutHasColors(),m=this._outputConfiguration.getOutHelpWidth()),{error:n,write:b=>(c||(b=this._outputConfiguration.stripColor(b)),h(b)),hasColors:c,helpWidth:m}}outputHelp(u){let n;typeof u=="function"&&(n=u,u=void 0);const h=this._getOutputContext(u),c={error:h.error,write:h.write,command:this};this._getCommandAndAncestors().reverse().forEach(C=>C.emit("beforeAllHelp",c)),this.emit("beforeHelp",c);let m=this.helpInformation({error:h.error});if(n&&(m=n(m),typeof m!="string"&&!Buffer.isBuffer(m)))throw new Error("outputHelp callback must return a string or a Buffer");h.write(m),this._getHelpOption()?.long&&this.emit(this._getHelpOption().long),this.emit("afterHelp",c),this._getCommandAndAncestors().forEach(C=>C.emit("afterAllHelp",c))}helpOption(u,n){return typeof u=="boolean"?(u?this._helpOption=this._helpOption??void 0:this._helpOption=null,this):(u=u??"-h, --help",n=n??"display help for command",this._helpOption=this.createOption(u,n),this)}_getHelpOption(){return this._helpOption===void 0&&this.helpOption(void 0,void 0),this._helpOption}addHelpOption(u){return this._helpOption=u,this}help(u){this.outputHelp(u);let n=Number(t.exitCode??0);n===0&&u&&typeof u!="function"&&u.error&&(n=1),this._exit(n,"commander.help","(outputHelp)")}addHelpText(u,n){const h=["beforeAll","before","after","afterAll"];if(!h.includes(u))throw new Error(`Unexpected value for position to addHelpText.
Expecting one of '${h.join("', '")}'`);const c=`${u}Help`;return this.on(c,m=>{let C;typeof n=="function"?C=n({error:m.error,command:m.command}):C=n,C&&m.write(`${C}
`)}),this}_outputHelpIfRequested(u){const n=this._getHelpOption();n&&u.find(c=>n.is(c))&&(this.outputHelp(),this._exit(0,"commander.helpDisplayed","(outputHelp)"))}}function B(S){return S.map(u=>{if(!u.startsWith("--inspect"))return u;let n,h="127.0.0.1",c="9229",m;return(m=u.match(/^(--inspect(-brk)?)$/))!==null?n=m[1]:(m=u.match(/^(--inspect(-brk|-port)?)=([^:]+)$/))!==null?(n=m[1],/^\d+$/.test(m[3])?c=m[3]:h=m[3]):(m=u.match(/^(--inspect(-brk|-port)?)=([^:]+):(\d+)$/))!==null&&(n=m[1],h=m[3],c=m[4]),n&&c!=="0"?`${n}=${h}:${parseInt(c)+1}`:u})}function x(){if(t.env.NO_COLOR||t.env.FORCE_COLOR==="0"||t.env.FORCE_COLOR==="false")return!1;if(t.env.FORCE_COLOR||t.env.CLICOLOR_FORCE!==void 0)return!0}return K.Command=A,K.useColor=x,K}var Le;function Tu(){if(Le)return T;Le=1;const{Argument:s}=ie(),{Command:i}=Su(),{CommanderError:o,InvalidArgumentError:a}=U(),{Help:t}=We(),{Option:r}=je();return T.program=new i,T.createCommand=e=>new i(e),T.createOption=(e,D)=>new r(e,D),T.createArgument=(e,D)=>new s(e,D),T.Command=i,T.Option=r,T.Argument=s,T.Help=t,T.CommanderError=o,T.InvalidArgumentError=a,T.InvalidOptionArgumentError=a,T}var ku=Tu();const Vu=re(ku),{program:Ge,createCommand:Xt,createArgument:Zt,createOption:Qt,CommanderError:er,InvalidArgumentError:ur,InvalidOptionArgumentError:tr,Command:rr,Argument:ir,Option:sr,Help:nr}=Vu;var ne,Ue;function Hu(){if(Ue)return ne;Ue=1;const s="\x1B",i=`${s}[`,o="\x07",a={to(e,D){return D?`${i}${D+1};${e+1}H`:`${i}${e+1}G`},move(e,D){let l="";return e<0?l+=`${i}${-e}D`:e>0&&(l+=`${i}${e}C`),D<0?l+=`${i}${-D}A`:D>0&&(l+=`${i}${D}B`),l},up:(e=1)=>`${i}${e}A`,down:(e=1)=>`${i}${e}B`,forward:(e=1)=>`${i}${e}C`,backward:(e=1)=>`${i}${e}D`,nextLine:(e=1)=>`${i}E`.repeat(e),prevLine:(e=1)=>`${i}F`.repeat(e),left:`${i}G`,hide:`${i}?25l`,show:`${i}?25h`,save:`${s}7`,restore:`${s}8`},t={up:(e=1)=>`${i}S`.repeat(e),down:(e=1)=>`${i}T`.repeat(e)},r={screen:`${i}2J`,up:(e=1)=>`${i}1J`.repeat(e),down:(e=1)=>`${i}J`.repeat(e),line:`${i}2K`,lineEnd:`${i}K`,lineStart:`${i}1K`,lines(e){let D="";for(let l=0;l<e;l++)D+=this.line+(l<e-1?a.up():"");return e&&(D+=a.left),D}};return ne={cursor:a,scroll:t,erase:r,beep:o},ne}var O=Hu();function Pu({onlyFirst:s=!1}={}){const i=["[\\u001B\\u009B][[\\]()#;?]*(?:(?:(?:(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]+)*|[a-zA-Z\\d]+(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]*)*)?(?:\\u0007|\\u001B\\u005C|\\u009C))","(?:(?:\\d{1,4}(?:;\\d{0,4})*)?[\\dA-PR-TZcf-nq-uy=><~]))"].join("|");return new RegExp(i,s?void 0:"g")}const Mu=Pu();function Ke(s){if(typeof s!="string")throw new TypeError(`Expected a \`string\`, got \`${typeof s}\``);return s.replace(Mu,"")}function ze(s){return s&&s.__esModule&&Object.prototype.hasOwnProperty.call(s,"default")?s.default:s}var Ye={exports:{}};(function(s){var i={};s.exports=i,i.eastAsianWidth=function(a){var t=a.charCodeAt(0),r=a.length==2?a.charCodeAt(1):0,e=t;return 55296<=t&&t<=56319&&56320<=r&&r<=57343&&(t&=1023,r&=1023,e=t<<10|r,e+=65536),e==12288||65281<=e&&e<=65376||65504<=e&&e<=65510?"F":e==8361||65377<=e&&e<=65470||65474<=e&&e<=65479||65482<=e&&e<=65487||65490<=e&&e<=65495||65498<=e&&e<=65500||65512<=e&&e<=65518?"H":4352<=e&&e<=4447||4515<=e&&e<=4519||4602<=e&&e<=4607||9001<=e&&e<=9002||11904<=e&&e<=11929||11931<=e&&e<=12019||12032<=e&&e<=12245||12272<=e&&e<=12283||12289<=e&&e<=12350||12353<=e&&e<=12438||12441<=e&&e<=12543||12549<=e&&e<=12589||12593<=e&&e<=12686||12688<=e&&e<=12730||12736<=e&&e<=12771||12784<=e&&e<=12830||12832<=e&&e<=12871||12880<=e&&e<=13054||13056<=e&&e<=19903||19968<=e&&e<=42124||42128<=e&&e<=42182||43360<=e&&e<=43388||44032<=e&&e<=55203||55216<=e&&e<=55238||55243<=e&&e<=55291||63744<=e&&e<=64255||65040<=e&&e<=65049||65072<=e&&e<=65106||65108<=e&&e<=65126||65128<=e&&e<=65131||110592<=e&&e<=110593||127488<=e&&e<=127490||127504<=e&&e<=127546||127552<=e&&e<=127560||127568<=e&&e<=127569||131072<=e&&e<=194367||177984<=e&&e<=196605||196608<=e&&e<=262141?"W":32<=e&&e<=126||162<=e&&e<=163||165<=e&&e<=166||e==172||e==175||10214<=e&&e<=10221||10629<=e&&e<=10630?"Na":e==161||e==164||167<=e&&e<=168||e==170||173<=e&&e<=174||176<=e&&e<=180||182<=e&&e<=186||188<=e&&e<=191||e==198||e==208||215<=e&&e<=216||222<=e&&e<=225||e==230||232<=e&&e<=234||236<=e&&e<=237||e==240||242<=e&&e<=243||247<=e&&e<=250||e==252||e==254||e==257||e==273||e==275||e==283||294<=e&&e<=295||e==299||305<=e&&e<=307||e==312||319<=e&&e<=322||e==324||328<=e&&e<=331||e==333||338<=e&&e<=339||358<=e&&e<=359||e==363||e==462||e==464||e==466||e==468||e==470||e==472||e==474||e==476||e==593||e==609||e==708||e==711||713<=e&&e<=715||e==717||e==720||728<=e&&e<=731||e==733||e==735||768<=e&&e<=879||913<=e&&e<=929||931<=e&&e<=937||945<=e&&e<=961||963<=e&&e<=969||e==1025||1040<=e&&e<=1103||e==1105||e==8208||8211<=e&&e<=8214||8216<=e&&e<=8217||8220<=e&&e<=8221||8224<=e&&e<=8226||8228<=e&&e<=8231||e==8240||8242<=e&&e<=8243||e==8245||e==8251||e==8254||e==8308||e==8319||8321<=e&&e<=8324||e==8364||e==8451||e==8453||e==8457||e==8467||e==8470||8481<=e&&e<=8482||e==8486||e==8491||8531<=e&&e<=8532||8539<=e&&e<=8542||8544<=e&&e<=8555||8560<=e&&e<=8569||e==8585||8592<=e&&e<=8601||8632<=e&&e<=8633||e==8658||e==8660||e==8679||e==8704||8706<=e&&e<=8707||8711<=e&&e<=8712||e==8715||e==8719||e==8721||e==8725||e==8730||8733<=e&&e<=8736||e==8739||e==8741||8743<=e&&e<=8748||e==8750||8756<=e&&e<=8759||8764<=e&&e<=8765||e==8776||e==8780||e==8786||8800<=e&&e<=8801||8804<=e&&e<=8807||8810<=e&&e<=8811||8814<=e&&e<=8815||8834<=e&&e<=8835||8838<=e&&e<=8839||e==8853||e==8857||e==8869||e==8895||e==8978||9312<=e&&e<=9449||9451<=e&&e<=9547||9552<=e&&e<=9587||9600<=e&&e<=9615||9618<=e&&e<=9621||9632<=e&&e<=9633||9635<=e&&e<=9641||9650<=e&&e<=9651||9654<=e&&e<=9655||9660<=e&&e<=9661||9664<=e&&e<=9665||9670<=e&&e<=9672||e==9675||9678<=e&&e<=9681||9698<=e&&e<=9701||e==9711||9733<=e&&e<=9734||e==9737||9742<=e&&e<=9743||9748<=e&&e<=9749||e==9756||e==9758||e==9792||e==9794||9824<=e&&e<=9825||9827<=e&&e<=9829||9831<=e&&e<=9834||9836<=e&&e<=9837||e==9839||9886<=e&&e<=9887||9918<=e&&e<=9919||9924<=e&&e<=9933||9935<=e&&e<=9953||e==9955||9960<=e&&e<=9983||e==10045||e==10071||10102<=e&&e<=10111||11093<=e&&e<=11097||12872<=e&&e<=12879||57344<=e&&e<=63743||65024<=e&&e<=65039||e==65533||127232<=e&&e<=127242||127248<=e&&e<=127277||127280<=e&&e<=127337||127344<=e&&e<=127386||917760<=e&&e<=917999||983040<=e&&e<=1048573||1048576<=e&&e<=1114109?"A":"N"},i.characterLength=function(a){var t=this.eastAsianWidth(a);return t=="F"||t=="W"||t=="A"?2:1};function o(a){return a.match(/[\uD800-\uDBFF][\uDC00-\uDFFF]|[^\uD800-\uDFFF]/g)||[]}i.length=function(a){for(var t=o(a),r=0,e=0;e<t.length;e++)r=r+this.characterLength(t[e]);return r},i.slice=function(a,t,r){textLen=i.length(a),t=t||0,r=r||1,t<0&&(t=textLen+t),r<0&&(r=textLen+r);for(var e="",D=0,l=o(a),p=0;p<l.length;p++){var d=l[p],f=i.length(d);if(D>=t-(f==2?1:0))if(D+f<=r)e+=d;else break;D+=f}return e}})(Ye);var Ru=Ye.exports;const Wu=ze(Ru);var Iu=function(){return/\uD83C\uDFF4\uDB40\uDC67\uDB40\uDC62(?:\uDB40\uDC77\uDB40\uDC6C\uDB40\uDC73|\uDB40\uDC73\uDB40\uDC63\uDB40\uDC74|\uDB40\uDC65\uDB40\uDC6E\uDB40\uDC67)\uDB40\uDC7F|(?:\uD83E\uDDD1\uD83C\uDFFF\u200D\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1|\uD83D\uDC69\uD83C\uDFFF\u200D\uD83E\uDD1D\u200D(?:\uD83D[\uDC68\uDC69]))(?:\uD83C[\uDFFB-\uDFFE])|(?:\uD83E\uDDD1\uD83C\uDFFE\u200D\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1|\uD83D\uDC69\uD83C\uDFFE\u200D\uD83E\uDD1D\u200D(?:\uD83D[\uDC68\uDC69]))(?:\uD83C[\uDFFB-\uDFFD\uDFFF])|(?:\uD83E\uDDD1\uD83C\uDFFD\u200D\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1|\uD83D\uDC69\uD83C\uDFFD\u200D\uD83E\uDD1D\u200D(?:\uD83D[\uDC68\uDC69]))(?:\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF])|(?:\uD83E\uDDD1\uD83C\uDFFC\u200D\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1|\uD83D\uDC69\uD83C\uDFFC\u200D\uD83E\uDD1D\u200D(?:\uD83D[\uDC68\uDC69]))(?:\uD83C[\uDFFB\uDFFD-\uDFFF])|(?:\uD83E\uDDD1\uD83C\uDFFB\u200D\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1|\uD83D\uDC69\uD83C\uDFFB\u200D\uD83E\uDD1D\u200D(?:\uD83D[\uDC68\uDC69]))(?:\uD83C[\uDFFC-\uDFFF])|\uD83D\uDC68(?:\uD83C\uDFFB(?:\u200D(?:\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D\uD83D\uDC68(?:\uD83C[\uDFFB-\uDFFF])|\uD83D\uDC68(?:\uD83C[\uDFFB-\uDFFF]))|\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFC-\uDFFF])|[\u2695\u2696\u2708]\uFE0F|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD]))?|(?:\uD83C[\uDFFC-\uDFFF])\u200D\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D\uD83D\uDC68(?:\uD83C[\uDFFB-\uDFFF])|\uD83D\uDC68(?:\uD83C[\uDFFB-\uDFFF]))|\u200D(?:\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D)?\uD83D\uDC68|(?:\uD83D[\uDC68\uDC69])\u200D(?:\uD83D\uDC66\u200D\uD83D\uDC66|\uD83D\uDC67\u200D(?:\uD83D[\uDC66\uDC67]))|\uD83D\uDC66\u200D\uD83D\uDC66|\uD83D\uDC67\u200D(?:\uD83D[\uDC66\uDC67])|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFF\u200D(?:\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFB-\uDFFE])|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFE\u200D(?:\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFB-\uDFFD\uDFFF])|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFD\u200D(?:\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF])|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFC\u200D(?:\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFB\uDFFD-\uDFFF])|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|(?:\uD83C