UNPKG

npm-check-updates

Version:

Find newer versions of dependencies than what your package.json allows

34 lines (33 loc) 47 kB
#!/usr/bin/env node "use strict";const H=require("./index.js"),et=require("node:events"),it=require("node:child_process"),nt=require("node:path"),rt=require("node:fs"),st=require("node:process");var S={},T={},j={},M;function F(){if(M)return j;M=1;class x extends Error{constructor(f,i,r){super(r),Error.captureStackTrace(this,this.constructor),this.name=this.constructor.name,this.code=i,this.exitCode=f,this.nestedError=void 0}}class v extends x{constructor(f){super(1,"commander.invalidArgument",f),Error.captureStackTrace(this,this.constructor),this.name=this.constructor.name}}return j.CommanderError=x,j.InvalidArgumentError=v,j}var R;function q(){if(R)return T;R=1;const{InvalidArgumentError:x}=F();class v{constructor(i,r){switch(this.description=r||"",this.variadic=!1,this.parseArg=void 0,this.defaultValue=void 0,this.defaultValueDescription=void 0,this.argChoices=void 0,i[0]){case"<":this.required=!0,this._name=i.slice(1,-1);break;case"[":this.required=!1,this._name=i.slice(1,-1);break;default:this.required=!0,this._name=i;break}this._name.endsWith("...")&&(this.variadic=!0,this._name=this._name.slice(0,-3))}name(){return this._name}_collectValue(i,r){return r===this.defaultValue||!Array.isArray(r)?[i]:(r.push(i),r)}default(i,r){return this.defaultValue=i,this.defaultValueDescription=r,this}argParser(i){return this.parseArg=i,this}choices(i){return this.argChoices=i.slice(),this.parseArg=(r,s)=>{if(!this.argChoices.includes(r))throw new x(`Allowed choices are ${this.argChoices.join(", ")}.`);return this.variadic?this._collectValue(r,s):r},this}argRequired(){return this.required=!0,this}argOptional(){return this.required=!1,this}}function E(f){const i=f.name()+(f.variadic===!0?"...":"");return f.required?"<"+i+">":"["+i+"]"}return T.Argument=v,T.humanReadableArgName=E,T}var P={},D={},L;function X(){if(L)return D;L=1;const{humanReadableArgName:x}=q();class v{constructor(){this.helpWidth=void 0,this.minWidthToWrap=40,this.sortSubcommands=!1,this.sortOptions=!1,this.showGlobalOptions=!1}prepareContext(i){this.helpWidth=this.helpWidth??i.helpWidth??80}visibleCommands(i){const r=i.commands.filter(u=>!u._hidden),s=i._getHelpCommand();return s&&!s._hidden&&r.push(s),this.sortSubcommands&&r.sort((u,_)=>u.name().localeCompare(_.name())),r}compareOptions(i,r){const s=u=>u.short?u.short.replace(/^-/,""):u.long.replace(/^--/,"");return s(i).localeCompare(s(r))}visibleOptions(i){const r=i.options.filter(u=>!u.hidden),s=i._getHelpOption();if(s&&!s.hidden){const u=s.short&&i._findOption(s.short),_=s.long&&i._findOption(s.long);!u&&!_?r.push(s):s.long&&!_?r.push(i.createOption(s.long,s.description)):s.short&&!u&&r.push(i.createOption(s.short,s.description))}return this.sortOptions&&r.sort(this.compareOptions),r}visibleGlobalOptions(i){if(!this.showGlobalOptions)return[];const r=[];for(let s=i.parent;s;s=s.parent){const u=s.options.filter(_=>!_.hidden);r.push(...u)}return this.sortOptions&&r.sort(this.compareOptions),r}visibleArguments(i){return i._argsDescription&&i.registeredArguments.forEach(r=>{r.description=r.description||i._argsDescription[r.name()]||""}),i.registeredArguments.find(r=>r.description)?i.registeredArguments:[]}subcommandTerm(i){const r=i.registeredArguments.map(s=>x(s)).join(" ");return i._name+(i._aliases[0]?"|"+i._aliases[0]:"")+(i.options.length?" [options]":"")+(r?" "+r:"")}optionTerm(i){return i.flags}argumentTerm(i){return i.name()}longestSubcommandTermLength(i,r){return r.visibleCommands(i).reduce((s,u)=>Math.max(s,this.displayWidth(r.styleSubcommandTerm(r.subcommandTerm(u)))),0)}longestOptionTermLength(i,r){return r.visibleOptions(i).reduce((s,u)=>Math.max(s,this.displayWidth(r.styleOptionTerm(r.optionTerm(u)))),0)}longestGlobalOptionTermLength(i,r){return r.visibleGlobalOptions(i).reduce((s,u)=>Math.max(s,this.displayWidth(r.styleOptionTerm(r.optionTerm(u)))),0)}longestArgumentTermLength(i,r){return r.visibleArguments(i).reduce((s,u)=>Math.max(s,this.displayWidth(r.styleArgumentTerm(r.argumentTerm(u)))),0)}commandUsage(i){let r=i._name;i._aliases[0]&&(r=r+"|"+i._aliases[0]);let s="";for(let u=i.parent;u;u=u.parent)s=u.name()+" "+s;return s+r+" "+i.usage()}commandDescription(i){return i.description()}subcommandDescription(i){return i.summary()||i.description()}optionDescription(i){const r=[];if(i.argChoices&&r.push(`choices: ${i.argChoices.map(s=>JSON.stringify(s)).join(", ")}`),i.defaultValue!==void 0&&(i.required||i.optional||i.isBoolean()&&typeof i.defaultValue=="boolean")&&r.push(`default: ${i.defaultValueDescription||JSON.stringify(i.defaultValue)}`),i.presetArg!==void 0&&i.optional&&r.push(`preset: ${JSON.stringify(i.presetArg)}`),i.envVar!==void 0&&r.push(`env: ${i.envVar}`),r.length>0){const s=`(${r.join(", ")})`;return i.description?`${i.description} ${s}`:s}return i.description}argumentDescription(i){const r=[];if(i.argChoices&&r.push(`choices: ${i.argChoices.map(s=>JSON.stringify(s)).join(", ")}`),i.defaultValue!==void 0&&r.push(`default: ${i.defaultValueDescription||JSON.stringify(i.defaultValue)}`),r.length>0){const s=`(${r.join(", ")})`;return i.description?`${i.description} ${s}`:s}return i.description}formatItemList(i,r,s){return r.length===0?[]:[s.styleTitle(i),...r,""]}groupItems(i,r,s){const u=new Map;return i.forEach(_=>{const l=s(_);u.has(l)||u.set(l,[])}),r.forEach(_=>{const l=s(_);u.has(l)||u.set(l,[]),u.get(l).push(_)}),u}formatHelp(i,r){const s=r.padWidth(i,r),u=r.helpWidth??80;function _(d,b){return r.formatItem(d,s,b,r)}let l=[`${r.styleTitle("Usage:")} ${r.styleUsage(r.commandUsage(i))}`,""];const g=r.commandDescription(i);g.length>0&&(l=l.concat([r.boxWrap(r.styleCommandDescription(g),u),""]));const h=r.visibleArguments(i).map(d=>_(r.styleArgumentTerm(r.argumentTerm(d)),r.styleArgumentDescription(r.argumentDescription(d))));if(l=l.concat(this.formatItemList("Arguments:",h,r)),this.groupItems(i.options,r.visibleOptions(i),d=>d.helpGroupHeading??"Options:").forEach((d,b)=>{const V=d.map(t=>_(r.styleOptionTerm(r.optionTerm(t)),r.styleOptionDescription(r.optionDescription(t))));l=l.concat(this.formatItemList(b,V,r))}),r.showGlobalOptions){const d=r.visibleGlobalOptions(i).map(b=>_(r.styleOptionTerm(r.optionTerm(b)),r.styleOptionDescription(r.optionDescription(b))));l=l.concat(this.formatItemList("Global Options:",d,r))}return this.groupItems(i.commands,r.visibleCommands(i),d=>d.helpGroup()||"Commands:").forEach((d,b)=>{const V=d.map(t=>_(r.styleSubcommandTerm(r.subcommandTerm(t)),r.styleSubcommandDescription(r.subcommandDescription(t))));l=l.concat(this.formatItemList(b,V,r))}),l.join(` `)}displayWidth(i){return E(i).length}styleTitle(i){return i}styleUsage(i){return i.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(i){return this.styleDescriptionText(i)}styleOptionDescription(i){return this.styleDescriptionText(i)}styleSubcommandDescription(i){return this.styleDescriptionText(i)}styleArgumentDescription(i){return this.styleDescriptionText(i)}styleDescriptionText(i){return i}styleOptionTerm(i){return this.styleOptionText(i)}styleSubcommandTerm(i){return i.split(" ").map(r=>r==="[options]"?this.styleOptionText(r):r[0]==="["||r[0]==="<"?this.styleArgumentText(r):this.styleSubcommandText(r)).join(" ")}styleArgumentTerm(i){return this.styleArgumentText(i)}styleOptionText(i){return i}styleArgumentText(i){return i}styleSubcommandText(i){return i}styleCommandText(i){return i}padWidth(i,r){return Math.max(r.longestOptionTermLength(i,r),r.longestGlobalOptionTermLength(i,r),r.longestSubcommandTermLength(i,r),r.longestArgumentTermLength(i,r))}preformatted(i){return/\n[^\S\r\n]/.test(i)}formatItem(i,r,s,u){const l=" ".repeat(2);if(!s)return l+i;const g=i.padEnd(r+i.length-u.displayWidth(i)),h=2,y=(this.helpWidth??80)-r-h-2;let d;return y<this.minWidthToWrap||u.preformatted(s)?d=s:d=u.boxWrap(s,y).replace(/\n/g,` `+" ".repeat(r+h)),l+g+" ".repeat(h)+d.replace(/\n/g,` ${l}`)}boxWrap(i,r){if(r<this.minWidthToWrap)return i;const s=i.split(/\r\n|\n/),u=/[\s]*[^\s]+/g,_=[];return s.forEach(l=>{const g=l.match(u);if(g===null){_.push("");return}let h=[g.shift()],p=this.displayWidth(h[0]);g.forEach(y=>{const d=this.displayWidth(y);if(p+d<=r){h.push(y),p+=d;return}_.push(h.join(""));const b=y.trimStart();h=[b],p=this.displayWidth(b)}),_.push(h.join(""))}),_.join(` `)}}function E(f){const i=/\x1b\[\d*(;\d*)*m/g;return f.replace(i,"")}return D.Help=v,D.stripColor=E,D}var W={},B;function Z(){if(B)return W;B=1;const{InvalidArgumentError:x}=F();class v{constructor(s,u){this.flags=s,this.description=u||"",this.required=s.includes("<"),this.optional=s.includes("["),this.variadic=/\w\.\.\.[>\]]$/.test(s),this.mandatory=!1;const _=i(s);this.short=_.shortFlag,this.long=_.longFlag,this.negate=!1,this.long&&(this.negate=this.long.startsWith("--no-")),this.defaultValue=void 0,this.defaultValueDescription=void 0,this.presetArg=void 0,this.envVar=void 0,this.parseArg=void 0,this.hidden=!1,this.argChoices=void 0,this.conflictsWith=[],this.implied=void 0,this.helpGroupHeading=void 0}default(s,u){return this.defaultValue=s,this.defaultValueDescription=u,this}preset(s){return this.presetArg=s,this}conflicts(s){return this.conflictsWith=this.conflictsWith.concat(s),this}implies(s){let u=s;return typeof s=="string"&&(u={[s]:!0}),this.implied=Object.assign(this.implied||{},u),this}env(s){return this.envVar=s,this}argParser(s){return this.parseArg=s,this}makeOptionMandatory(s=!0){return this.mandatory=!!s,this}hideHelp(s=!0){return this.hidden=!!s,this}_collectValue(s,u){return u===this.defaultValue||!Array.isArray(u)?[s]:(u.push(s),u)}choices(s){return this.argChoices=s.slice(),this.parseArg=(u,_)=>{if(!this.argChoices.includes(u))throw new x(`Allowed choices are ${this.argChoices.join(", ")}.`);return this.variadic?this._collectValue(u,_):u},this}name(){return this.long?this.long.replace(/^--/,""):this.short.replace(/^-/,"")}attributeName(){return this.negate?f(this.name().replace(/^no-/,"")):f(this.name())}helpGroup(s){return this.helpGroupHeading=s,this}is(s){return this.short===s||this.long===s}isBoolean(){return!this.required&&!this.optional&&!this.negate}}class E{constructor(s){this.positiveOptions=new Map,this.negativeOptions=new Map,this.dualOptions=new Set,s.forEach(u=>{u.negate?this.negativeOptions.set(u.attributeName(),u):this.positiveOptions.set(u.attributeName(),u)}),this.negativeOptions.forEach((u,_)=>{this.positiveOptions.has(_)&&this.dualOptions.add(_)})}valueFromOption(s,u){const _=u.attributeName();if(!this.dualOptions.has(_))return!0;const l=this.negativeOptions.get(_).presetArg,g=l!==void 0?l:!1;return u.negate===(g===s)}}function f(r){return r.split("-").reduce((s,u)=>s+u[0].toUpperCase()+u.slice(1))}function i(r){let s,u;const _=/^-[^-]$/,l=/^--[^-]/,g=r.split(/[ |,]+/).concat("guard");if(_.test(g[0])&&(s=g.shift()),l.test(g[0])&&(u=g.shift()),!s&&_.test(g[0])&&(s=g.shift()),!s&&l.test(g[0])&&(s=u,u=g.shift()),g[0].startsWith("-")){const h=g[0],p=`option creation failed due to '${h}' in option flags '${r}'`;throw/^-[^-][^-]/.test(h)?new Error(`${p} - 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')`):_.test(h)?new Error(`${p} - too many short flags`):l.test(h)?new Error(`${p} - too many long flags`):new Error(`${p} - unrecognised flag format`)}if(s===void 0&&u===void 0)throw new Error(`option creation failed due to no flags found in '${r}'.`);return{shortFlag:s,longFlag:u}}return W.Option=v,W.DualOptions=E,W}var G={},U;function ot(){if(U)return G;U=1;const x=3;function v(f,i){if(Math.abs(f.length-i.length)>x)return Math.max(f.length,i.length);const r=[];for(let s=0;s<=f.length;s++)r[s]=[s];for(let s=0;s<=i.length;s++)r[0][s]=s;for(let s=1;s<=i.length;s++)for(let u=1;u<=f.length;u++){let _=1;f[u-1]===i[s-1]?_=0:_=1,r[u][s]=Math.min(r[u-1][s]+1,r[u][s-1]+1,r[u-1][s-1]+_),u>1&&s>1&&f[u-1]===i[s-2]&&f[u-2]===i[s-1]&&(r[u][s]=Math.min(r[u][s],r[u-2][s-2]+1))}return r[f.length][i.length]}function E(f,i){if(!i||i.length===0)return"";i=Array.from(new Set(i));const r=f.startsWith("--");r&&(f=f.slice(2),i=i.map(l=>l.slice(2)));let s=[],u=x;const _=.4;return i.forEach(l=>{if(l.length<=1)return;const g=v(f,l),h=Math.max(f.length,l.length);(h-g)/h>_&&(g<u?(u=g,s=[l]):g===u&&s.push(l))}),s.sort((l,g)=>l.localeCompare(g)),r&&(s=s.map(l=>`--${l}`)),s.length>1?` (Did you mean one of ${s.join(", ")}?)`:s.length===1?` (Did you mean ${s[0]}?)`:""}return G.suggestSimilar=E,G}var J;function at(){if(J)return P;J=1;const x=et.EventEmitter,v=it,E=nt,f=rt,i=st,{Argument:r,humanReadableArgName:s}=q(),{CommanderError:u}=F(),{Help:_,stripColor:l}=X(),{Option:g,DualOptions:h}=Z(),{suggestSimilar:p}=ot();class y extends x{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:e=>i.stdout.write(e),writeErr:e=>i.stderr.write(e),outputError:(e,n)=>n(e),getOutHelpWidth:()=>i.stdout.isTTY?i.stdout.columns:void 0,getErrHelpWidth:()=>i.stderr.isTTY?i.stderr.columns:void 0,getOutHasColors:()=>b()??(i.stdout.isTTY&&i.stdout.hasColors?.()),getErrHasColors:()=>b()??(i.stderr.isTTY&&i.stderr.hasColors?.()),stripColor:e=>l(e)},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(){const t=[];for(let e=this;e;e=e.parent)t.push(e);return t}command(t,e,n){let o=e,a=n;typeof o=="object"&&o!==null&&(a=o,o=null),a=a||{};const[,c,O]=t.match(/([^ ]+) *(.*)/),C=this.createCommand(c);return o&&(C.description(o),C._executableHandler=!0),a.isDefault&&(this._defaultCommandName=C._name),C._hidden=!!(a.noHelp||a.hidden),C._executableFile=a.executableFile||null,O&&C.arguments(O),this._registerCommand(C),C.parent=this,C.copyInheritedSettings(this),o?this:C}createCommand(t){return new y(t)}createHelp(){return Object.assign(new _,this.configureHelp())}configureHelp(t){return t===void 0?this._helpConfiguration:(this._helpConfiguration=t,this)}configureOutput(t){return t===void 0?this._outputConfiguration:(this._outputConfiguration={...this._outputConfiguration,...t},this)}showHelpAfterError(t=!0){return typeof t!="string"&&(t=!!t),this._showHelpAfterError=t,this}showSuggestionAfterError(t=!0){return this._showSuggestionAfterError=!!t,this}addCommand(t,e){if(!t._name)throw new Error(`Command passed to .addCommand() must have a name - specify the name in Command constructor or using .name()`);return e=e||{},e.isDefault&&(this._defaultCommandName=t._name),(e.noHelp||e.hidden)&&(t._hidden=!0),this._registerCommand(t),t.parent=this,t._checkForBrokenPassThrough(),this}createArgument(t,e){return new r(t,e)}argument(t,e,n,o){const a=this.createArgument(t,e);return typeof n=="function"?a.default(o).argParser(n):a.default(n),this.addArgument(a),this}arguments(t){return t.trim().split(/ +/).forEach(e=>{this.argument(e)}),this}addArgument(t){const e=this.registeredArguments.slice(-1)[0];if(e?.variadic)throw new Error(`only the last argument can be variadic '${e.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,e){if(typeof t=="boolean")return this._addImplicitHelpCommand=t,t&&this._defaultCommandGroup&&this._initCommandGroup(this._getHelpCommand()),this;const n=t??"help [command]",[,o,a]=n.match(/([^ ]+) *(.*)/),c=e??"display help for command",O=this.createCommand(o);return O.helpOption(!1),a&&O.arguments(a),c&&O.description(c),this._addImplicitHelpCommand=!0,this._helpCommand=O,(t||e)&&this._initCommandGroup(O),this}addHelpCommand(t,e){return typeof t!="object"?(this.helpCommand(t,e),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,e){const 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(e):this._lifeCycleHooks[t]=[e],this}exitOverride(t){return t?this._exitCallback=t:this._exitCallback=e=>{if(e.code!=="commander.executeSubCommandAsync")throw e},this}_exit(t,e,n){this._exitCallback&&this._exitCallback(new u(t,e,n)),i.exit(t)}action(t){const e=n=>{const o=this.registeredArguments.length,a=n.slice(0,o);return this._storeOptionsAsProperties?a[o]=this:a[o]=this.opts(),a.push(this),t.apply(this,a)};return this._actionHandler=e,this}createOption(t,e){return new g(t,e)}_callParseArg(t,e,n,o){try{return t.parseArg(e,n)}catch(a){if(a.code==="commander.invalidArgument"){const c=`${o} ${a.message}`;this.error(c,{exitCode:a.exitCode,code:a.code})}throw a}}_registerOption(t){const e=t.short&&this._findOption(t.short)||t.long&&this._findOption(t.long);if(e){const 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 '${e.flags}'`)}this._initOptionGroup(t),this.options.push(t)}_registerCommand(t){const e=o=>[o.name()].concat(o.aliases()),n=e(t).find(o=>this._findCommand(o));if(n){const o=e(this._findCommand(n)).join("|"),a=e(t).join("|");throw new Error(`cannot add command '${a}' as already have command '${o}'`)}this._initCommandGroup(t),this.commands.push(t)}addOption(t){this._registerOption(t);const e=t.name(),n=t.attributeName();if(t.negate){const 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");const o=(a,c,O)=>{a==null&&t.presetArg!==void 0&&(a=t.presetArg);const C=this.getOptionValue(n);a!==null&&t.parseArg?a=this._callParseArg(t,a,C,c):a!==null&&t.variadic&&(a=t._collectValue(a,C)),a==null&&(t.negate?a=!1:t.isBoolean()||t.optional?a=!0:a=""),this.setOptionValueWithSource(n,a,O)};return this.on("option:"+e,a=>{const c=`error: option '${t.flags}' argument '${a}' is invalid.`;o(a,c,"cli")}),t.envVar&&this.on("optionEnv:"+e,a=>{const c=`error: option '${t.flags}' value '${a}' from env '${t.envVar}' is invalid.`;o(a,c,"env")}),this}_optionEx(t,e,n,o,a){if(typeof e=="object"&&e instanceof g)throw new Error("To add an Option object use addOption() instead of option() or requiredOption()");const c=this.createOption(e,n);if(c.makeOptionMandatory(!!t.mandatory),typeof o=="function")c.default(a).argParser(o);else if(o instanceof RegExp){const O=o;o=(C,w)=>{const m=O.exec(C);return m?m[0]:w},c.default(a).argParser(o)}else c.default(o);return this.addOption(c)}option(t,e,n,o){return this._optionEx({},t,e,n,o)}requiredOption(t,e,n,o){return this._optionEx({mandatory:!0},t,e,n,o)}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,e){return this.setOptionValueWithSource(t,e,void 0)}setOptionValueWithSource(t,e,n){return this._storeOptionsAsProperties?this[t]=e:this._optionValues[t]=e,this._optionValueSources[t]=n,this}getOptionValueSource(t){return this._optionValueSources[t]}getOptionValueSourceWithGlobals(t){let e;return this._getCommandAndAncestors().forEach(n=>{n.getOptionValueSource(t)!==void 0&&(e=n.getOptionValueSource(t))}),e}_prepareUserArgs(t,e){if(t!==void 0&&!Array.isArray(t))throw new Error("first parameter to parse must be array or undefined");if(e=e||{},t===void 0&&e.from===void 0){i.versions?.electron&&(e.from="electron");const o=i.execArgv??[];(o.includes("-e")||o.includes("--eval")||o.includes("-p")||o.includes("--print"))&&(e.from="eval")}t===void 0&&(t=i.argv),this.rawArgs=t.slice();let n;switch(e.from){case void 0:case"node":this._scriptPath=t[1],n=t.slice(2);break;case"electron":i.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: '${e.from}' }`)}return!this._name&&this._scriptPath&&this.nameFromFilename(this._scriptPath),this._name=this._name||"program",n}parse(t,e){this._prepareForParse();const n=this._prepareUserArgs(t,e);return this._parseCommand([],n),this}async parseAsync(t,e){this._prepareForParse();const n=this._prepareUserArgs(t,e);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,e,n){if(f.existsSync(t))return;const o=e?`searched for local subcommand relative to directory '${e}'`:"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 - ${o}`;throw new Error(a)}_executeSubCommand(t,e){e=e.slice();let n=!1;const o=[".js",".ts",".tsx",".mjs",".cjs"];function a(m,A){const $=E.resolve(m,A);if(f.existsSync($))return $;if(o.includes(E.extname(A)))return;const N=o.find(tt=>f.existsSync(`${$}${tt}`));if(N)return`${$}${N}`}this._checkForMissingMandatoryOptions(),this._checkForConflictingOptions();let c=t._executableFile||`${this._name}-${t._name}`,O=this._executableDir||"";if(this._scriptPath){let m;try{m=f.realpathSync(this._scriptPath)}catch{m=this._scriptPath}O=E.resolve(E.dirname(m),O)}if(O){let m=a(O,c);if(!m&&!t._executableFile&&this._scriptPath){const A=E.basename(this._scriptPath,E.extname(this._scriptPath));A!==this._name&&(m=a(O,`${A}-${t._name}`))}c=m||c}n=o.includes(E.extname(c));let C;i.platform!=="win32"?n?(e.unshift(c),e=d(i.execArgv).concat(e),C=v.spawn(i.argv[0],e,{stdio:"inherit"})):C=v.spawn(c,e,{stdio:"inherit"}):(this._checkForMissingExecutable(c,O,t._name),e.unshift(c),e=d(i.execArgv).concat(e),C=v.spawn(i.execPath,e,{stdio:"inherit"})),C.killed||["SIGUSR1","SIGUSR2","SIGTERM","SIGINT","SIGHUP"].forEach(A=>{i.on(A,()=>{C.killed===!1&&C.exitCode===null&&C.kill(A)})});const w=this._exitCallback;C.on("close",m=>{m=m??1,w?w(new u(m,"commander.executeSubCommandAsync","(close)")):i.exit(m)}),C.on("error",m=>{if(m.code==="ENOENT")this._checkForMissingExecutable(c,O,t._name);else if(m.code==="EACCES")throw new Error(`'${c}' not executable`);if(!w)i.exit(1);else{const A=new u(1,"commander.executeSubCommandAsync","(error)");A.nestedError=m,w(A)}}),this.runningCommand=C}_dispatchSubcommand(t,e,n){const o=this._findCommand(t);o||this.help({error:!0}),o._prepareForParse();let a;return a=this._chainOrCallSubCommandHook(a,o,"preSubcommand"),a=this._chainOrCall(a,()=>{if(o._executableHandler)this._executeSubCommand(o,e.concat(n));else return o._parseCommand(e,n)}),a}_dispatchHelpCommand(t){t||this.help();const e=this._findCommand(t);return e&&!e._executableHandler&&e.help(),this._dispatchSubcommand(t,[],[this._getHelpOption()?.long??this._getHelpOption()?.short??"--help"])}_checkNumberOfArguments(){this.registeredArguments.forEach((t,e)=>{t.required&&this.args[e]==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(){const t=(n,o,a)=>{let c=o;if(o!==null&&n.parseArg){const O=`error: command-argument value '${o}' is invalid for argument '${n.name()}'.`;c=this._callParseArg(n,o,a,O)}return c};this._checkNumberOfArguments();const e=[];this.registeredArguments.forEach((n,o)=>{let a=n.defaultValue;n.variadic?o<this.args.length?(a=this.args.slice(o),n.parseArg&&(a=a.reduce((c,O)=>t(n,O,c),n.defaultValue))):a===void 0&&(a=[]):o<this.args.length&&(a=this.args[o],n.parseArg&&(a=t(n,a,n.defaultValue))),e[o]=a}),this.processedArgs=e}_chainOrCall(t,e){return t?.then&&typeof t.then=="function"?t.then(()=>e()):e()}_chainOrCallHooks(t,e){let n=t;const o=[];return this._getCommandAndAncestors().reverse().filter(a=>a._lifeCycleHooks[e]!==void 0).forEach(a=>{a._lifeCycleHooks[e].forEach(c=>{o.push({hookedCommand:a,callback:c})})}),e==="postAction"&&o.reverse(),o.forEach(a=>{n=this._chainOrCall(n,()=>a.callback(a.hookedCommand,this))}),n}_chainOrCallSubCommandHook(t,e,n){let o=t;return this._lifeCycleHooks[n]!==void 0&&this._lifeCycleHooks[n].forEach(a=>{o=this._chainOrCall(o,()=>a(this,e))}),o}_parseCommand(t,e){const n=this.parseOptions(e);if(this._parseOptionsEnv(),this._parseOptionsImplied(),t=t.concat(n.operands),e=n.unknown,this.args=t.concat(e),t&&this._findCommand(t[0]))return this._dispatchSubcommand(t[0],t.slice(1),e);if(this._getHelpCommand()&&t[0]===this._getHelpCommand().name())return this._dispatchHelpCommand(t[1]);if(this._defaultCommandName)return this._outputHelpIfRequested(e),this._dispatchSubcommand(this._defaultCommandName,t,e);this.commands.length&&this.args.length===0&&!this._actionHandler&&!this._defaultCommandName&&this.help({error:!0}),this._outputHelpIfRequested(n.unknown),this._checkForMissingMandatoryOptions(),this._checkForConflictingOptions();const o=()=>{n.unknown.length>0&&this.unknownOption(n.unknown[0])},a=`command:${this.name()}`;if(this._actionHandler){o(),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(a,t,e)})),c=this._chainOrCallHooks(c,"postAction"),c}if(this.parent?.listenerCount(a))o(),this._processArguments(),this.parent.emit(a,t,e);else if(t.length){if(this._findCommand("*"))return this._dispatchSubcommand("*",t,e);this.listenerCount("command:*")?this.emit("command:*",t,e):this.commands.length?this.unknownCommand():(o(),this._processArguments())}else this.commands.length?(o(),this.help({error:!0})):(o(),this._processArguments())}_findCommand(t){if(t)return this.commands.find(e=>e._name===t||e._aliases.includes(t))}_findOption(t){return this.options.find(e=>e.is(t))}_checkForMissingMandatoryOptions(){this._getCommandAndAncestors().forEach(t=>{t.options.forEach(e=>{e.mandatory&&t.getOptionValue(e.attributeName())===void 0&&t.missingMandatoryOptionValue(e)})})}_checkForConflictingLocalOptions(){const t=this.options.filter(n=>{const o=n.attributeName();return this.getOptionValue(o)===void 0?!1:this.getOptionValueSource(o)!=="default"});t.filter(n=>n.conflictsWith.length>0).forEach(n=>{const o=t.find(a=>n.conflictsWith.includes(a.attributeName()));o&&this._conflictingOption(n,o)})}_checkForConflictingOptions(){this._getCommandAndAncestors().forEach(t=>{t._checkForConflictingLocalOptions()})}parseOptions(t){const e=[],n=[];let o=e;function a(m){return m.length>1&&m[0]==="-"}const c=m=>/^-\d*\.?\d+(e[+-]?\d+)?$/.test(m)?!this._getCommandAndAncestors().some(A=>A.options.map($=>$.short).some($=>/^-\d$/.test($))):!1;let O=null,C=null,w=0;for(;w<t.length||C;){const m=C??t[w++];if(C=null,m==="--"){o===n&&o.push(m),o.push(...t.slice(w));break}if(O&&(!a(m)||c(m))){this.emit(`option:${O.name()}`,m);continue}if(O=null,a(m)){const A=this._findOption(m);if(A){if(A.required){const $=t[w++];$===void 0&&this.optionMissingArgument(A),this.emit(`option:${A.name()}`,$)}else if(A.optional){let $=null;w<t.length&&(!a(t[w])||c(t[w]))&&($=t[w++]),this.emit(`option:${A.name()}`,$)}else this.emit(`option:${A.name()}`);O=A.variadic?A:null;continue}}if(m.length>2&&m[0]==="-"&&m[1]!=="-"){const A=this._findOption(`-${m[1]}`);if(A){A.required||A.optional&&this._combineFlagAndOptionalValue?this.emit(`option:${A.name()}`,m.slice(2)):(this.emit(`option:${A.name()}`),C=`-${m.slice(2)}`);continue}}if(/^--[^=]+=/.test(m)){const A=m.indexOf("="),$=this._findOption(m.slice(0,A));if($&&($.required||$.optional)){this.emit(`option:${$.name()}`,m.slice(A+1));continue}}if(o===e&&a(m)&&!(this.commands.length===0&&c(m))&&(o=n),(this._enablePositionalOptions||this._passThroughOptions)&&e.length===0&&n.length===0){if(this._findCommand(m)){e.push(m),n.push(...t.slice(w));break}else if(this._getHelpCommand()&&m===this._getHelpCommand().name()){e.push(m,...t.slice(w));break}else if(this._defaultCommandName){n.push(m,...t.slice(w));break}}if(this._passThroughOptions){o.push(m,...t.slice(w));break}o.push(m)}return{operands:e,unknown:n}}opts(){if(this._storeOptionsAsProperties){const t={},e=this.options.length;for(let n=0;n<e;n++){const o=this.options[n].attributeName();t[o]=o===this._versionOptionName?this._version:this[o]}return t}return this._optionValues}optsWithGlobals(){return this._getCommandAndAncestors().reduce((t,e)=>Object.assign(t,e.opts()),{})}error(t,e){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}));const n=e||{},o=n.exitCode||1,a=n.code||"commander.error";this._exit(o,a,t)}_parseOptionsEnv(){this.options.forEach(t=>{if(t.envVar&&t.envVar in i.env){const e=t.attributeName();(this.getOptionValue(e)===void 0||["default","config","env"].includes(this.getOptionValueSource(e)))&&(t.required||t.optional?this.emit(`optionEnv:${t.name()}`,i.env[t.envVar]):this.emit(`optionEnv:${t.name()}`))}})}_parseOptionsImplied(){const t=new h(this.options),e=n=>this.getOptionValue(n)!==void 0&&!["default","implied"].includes(this.getOptionValueSource(n));this.options.filter(n=>n.implied!==void 0&&e(n.attributeName())&&t.valueFromOption(this.getOptionValue(n.attributeName()),n)).forEach(n=>{Object.keys(n.implied).filter(o=>!e(o)).forEach(o=>{this.setOptionValueWithSource(o,n.implied[o],"implied")})})}missingArgument(t){const e=`error: missing required argument '${t}'`;this.error(e,{code:"commander.missingArgument"})}optionMissingArgument(t){const e=`error: option '${t.flags}' argument missing`;this.error(e,{code:"commander.optionMissingArgument"})}missingMandatoryOptionValue(t){const e=`error: required option '${t.flags}' not specified`;this.error(e,{code:"commander.missingMandatoryOptionValue"})}_conflictingOption(t,e){const n=c=>{const O=c.attributeName(),C=this.getOptionValue(O),w=this.options.find(A=>A.negate&&O===A.attributeName()),m=this.options.find(A=>!A.negate&&O===A.attributeName());return w&&(w.presetArg===void 0&&C===!1||w.presetArg!==void 0&&C===w.presetArg)?w:m||c},o=c=>{const O=n(c),C=O.attributeName();return this.getOptionValueSource(C)==="env"?`environment variable '${O.envVar}'`:`option '${O.flags}'`},a=`error: ${o(t)} cannot be used with ${o(e)}`;this.error(a,{code:"commander.conflictingOption"})}unknownOption(t){if(this._allowUnknownOption)return;let e="";if(t.startsWith("--")&&this._showSuggestionAfterError){let o=[],a=this;do{const c=a.createHelp().visibleOptions(a).filter(O=>O.long).map(O=>O.long);o=o.concat(c),a=a.parent}while(a&&!a._enablePositionalOptions);e=p(t,o)}const n=`error: unknown option '${t}'${e}`;this.error(n,{code:"commander.unknownOption"})}_excessArguments(t){if(this._allowExcessArguments)return;const e=this.registeredArguments.length,n=e===1?"":"s",a=`error: too many arguments${this.parent?` for '${this.name()}'`:""}. Expected ${e} argument${n} but got ${t.length}.`;this.error(a,{code:"commander.excessArguments"})}unknownCommand(){const t=this.args[0];let e="";if(this._showSuggestionAfterError){const o=[];this.createHelp().visibleCommands(this).forEach(a=>{o.push(a.name()),a.alias()&&o.push(a.alias())}),e=p(t,o)}const n=`error: unknown command '${t}'${e}`;this.error(n,{code:"commander.unknownCommand"})}version(t,e,n){if(t===void 0)return this._version;this._version=t,e=e||"-V, --version",n=n||"output the version number";const o=this.createOption(e,n);return this._versionOptionName=o.attributeName(),this._registerOption(o),this.on("option:"+o.name(),()=>{this._outputConfiguration.writeOut(`${t} `),this._exit(0,"commander.version",t)}),this}description(t,e){return t===void 0&&e===void 0?this._description:(this._description=t,e&&(this._argsDescription=e),this)}summary(t){return t===void 0?this._summary:(this._summary=t,this)}alias(t){if(t===void 0)return this._aliases[0];let e=this;if(this.commands.length!==0&&this.commands[this.commands.length-1]._executableHandler&&(e=this.commands[this.commands.length-1]),t===e._name)throw new Error("Command alias can't be the same as its name");const n=this.parent?._findCommand(t);if(n){const o=[n.name()].concat(n.aliases()).join("|");throw new Error(`cannot add alias '${t}' to command '${this.name()}' as already have command '${o}'`)}return e._aliases.push(t),this}aliases(t){return t===void 0?this._aliases:(t.forEach(e=>this.alias(e)),this)}usage(t){if(t===void 0){if(this._usage)return this._usage;const e=this.registeredArguments.map(n=>s(n));return[].concat(this.options.length||this._helpOption!==null?"[options]":[],this.commands.length?"[command]":[],this.registeredArguments.length?e:[]).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=E.basename(t,E.extname(t)),this}executableDir(t){return t===void 0?this._executableDir:(this._executableDir=t,this)}helpInformation(t){const e=this.createHelp(),n=this._getOutputContext(t);e.prepareContext({error:n.error,helpWidth:n.helpWidth,outputHasColors:n.hasColors});const o=e.formatHelp(this,e);return n.hasColors?o:this._outputConfiguration.stripColor(o)}_getOutputContext(t){t=t||{};const e=!!t.error;let n,o,a;return e?(n=O=>this._outputConfiguration.writeErr(O),o=this._outputConfiguration.getErrHasColors(),a=this._outputConfiguration.getErrHelpWidth()):(n=O=>this._outputConfiguration.writeOut(O),o=this._outputConfiguration.getOutHasColors(),a=this._outputConfiguration.getOutHelpWidth()),{error:e,write:O=>(o||(O=this._outputConfiguration.stripColor(O)),n(O)),hasColors:o,helpWidth:a}}outputHelp(t){let e;typeof t=="function"&&(e=t,t=void 0);const n=this._getOutputContext(t),o={error:n.error,write:n.write,command:this};this._getCommandAndAncestors().reverse().forEach(c=>c.emit("beforeAllHelp",o)),this.emit("beforeHelp",o);let a=this.helpInformation({error:n.error});if(e&&(a=e(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",o),this._getCommandAndAncestors().forEach(c=>c.emit("afterAllHelp",o))}helpOption(t,e){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",e??"display help for command"),(t||e)&&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 e=Number(i.exitCode??0);e===0&&t&&typeof t!="function"&&t.error&&(e=1),this._exit(e,"commander.help","(outputHelp)")}addHelpText(t,e){const n=["beforeAll","before","after","afterAll"];if(!n.includes(t))throw new Error(`Unexpected value for position to addHelpText. Expecting one of '${n.join("', '")}'`);const o=`${t}Help`;return this.on(o,a=>{let c;typeof e=="function"?c=e({error:a.error,command:a.command}):c=e,c&&a.write(`${c} `)}),this}_outputHelpIfRequested(t){const e=this._getHelpOption();e&&t.find(o=>e.is(o))&&(this.outputHelp(),this._exit(0,"commander.helpDisplayed","(outputHelp)"))}}function d(V){return V.map(t=>{if(!t.startsWith("--inspect"))return t;let e,n="127.0.0.1",o="9229",a;return(a=t.match(/^(--inspect(-brk)?)$/))!==null?e=a[1]:(a=t.match(/^(--inspect(-brk|-port)?)=([^:]+)$/))!==null?(e=a[1],/^\d+$/.test(a[3])?o=a[3]:n=a[3]):(a=t.match(/^(--inspect(-brk|-port)?)=([^:]+):(\d+)$/))!==null&&(e=a[1],n=a[3],o=a[4]),e&&o!=="0"?`${e}=${n}:${parseInt(o)+1}`:t})}function b(){if(i.env.NO_COLOR||i.env.FORCE_COLOR==="0"||i.env.FORCE_COLOR==="false")return!1;if(i.env.FORCE_COLOR||i.env.CLICOLOR_FORCE!==void 0)return!0}return P.Command=y,P.useColor=b,P}var Y;function ut(){if(Y)return S;Y=1;const{Argument:x}=q(),{Command:v}=at(),{CommanderError:E,InvalidArgumentError:f}=F(),{Help:i}=X(),{Option:r}=Z();return S.program=new v,S.createCommand=s=>new v(s),S.createOption=(s,u)=>new r(s,u),S.createArgument=(s,u)=>new x(s,u),S.Command=v,S.Option=r,S.Argument=x,S.Help=i,S.CommanderError=E,S.InvalidArgumentError=f,S.InvalidOptionArgumentError=f,S}var lt=ut();const ht=H.getDefaultExportFromCjs(lt),{program:k,createCommand:_t,createArgument:Ot,createOption:Ct,CommanderError:At,InvalidArgumentError:bt,InvalidOptionArgumentError:yt,Command:wt,Argument:vt,Option:K,Help:ct}=ht;var I,z;function pt(){if(z)return I;z=1,I=v;function x(f){return f instanceof Buffer?Buffer.from(f):new f.constructor(f.buffer.slice(),f.byteOffset,f.length)}function v(f){if(f=f||{},f.circles)return E(f);const i=new Map;if(i.set(Date,l=>new Date(l)),i.set(Map,(l,g)=>new Map(s(Array.from(l),g))),i.set(Set,(l,g)=>new Set(s(Array.from(l),g))),f.constructorHandlers)for(const l of f.constructorHandlers)i.set(l[0],l[1]);let r=null;return f.proto?_:u;function s(l,g){const h=Object.keys(l),p=new Array(h.length);for(let y=0;y<h.length;y++){const d=h[y],b=l[d];typeof b!="object"||b===null?p[d]=b:b.constructor!==Object&&(r=i.get(b.constructor))?p[d]=r(b,g):ArrayBuffer.isView(b)?p[d]=x(b):p[d]=g(b)}return p}function u(l){if(typeof l!="object"||l===null)return l;if(Array.isArray(l))return s(l,u);if(l.constructor!==Object&&(r=i.get(l.constructor)))return r(l,u);const g={};for(const h in l){if(Object.hasOwnProperty.call(l,h)===!1)continue;const p=l[h];typeof p!="object"||p===null?g[h]=p:p.constructor!==Object&&(r=i.get(p.constructor))?g[h]=r(p,u):ArrayBuffer.isView(p)?g[h]=x(p):g[h]=u(p)}return g}function _(l){if(typeof l!="object"||l===null)return l;if(Array.isArray(l))return s(l,_);if(l.constructor!==Object&&(r=i.get(l.constructor)))return r(l,_);const g={};for(const h in l){const p=l[h];typeof p!="object"||p===null?g[h]=p:p.constructor!==Object&&(r=i.get(p.constructor))?g[h]=r(p,_):ArrayBuffer.isView(p)?g[h]=x(p):g[h]=_(p)}return g}}function E(f){const i=[],r=[],s=new Map;if(s.set(Date,h=>new Date(h)),s.set(Map,(h,p)=>new Map(_(Array.from(h),p))),s.set(Set,(h,p)=>new Set(_(Array.from(h),p))),f.constructorHandlers)for(const h of f.constructorHandlers)s.set(h[0],h[1]);let u=null;return f.proto?g:l;function _(h,p){const y=Object.keys(h),d=new Array(y.length);for(let b=0;b<y.length;b++){const V=y[b],t=h[V];if(typeof t!="object"||t===null)d[V]=t;else if(t.constructor!==Object&&(u=s.get(t.constructor)))d[V]=u(t,p);else if(ArrayBuffer.isView(t))d[V]=x(t);else{const e=i.indexOf(t);e!==-1?d[V]=r[e]:d[V]=p(t)}}return d}function l(h){if(typeof h!="object"||h===null)return h;if(Array.isArray(h))return _(h,l);if(h.constructor!==Object&&(u=s.get(h.constructor)))return u(h,l);const p={};i.push(h),r.push(p);for(const y in h){if(Object.hasOwnProperty.call(h,y)===!1)continue;const d=h[y];if(typeof d!="object"||d===null)p[y]=d;else if(d.constructor!==Object&&(u=s.get(d.constructor)))p[y]=u(d,l);else if(ArrayBuffer.isView(d))p[y]=x(d);else{const b=i.indexOf(d);b!==-1?p[y]=r[b]:p[y]=l(d)}}return i.pop(),r.pop(),p}function g(h){if(typeof h!="object"||h===null)return h;if(Array.isArray(h))return _(h,g);if(h.constructor!==Object&&(u=s.get(h.constructor)))return u(h,g);const p={};i.push(h),r.push(p);for(const y in h){const d=h[y];if(typeof d!="object"||d===null)p[y]=d;else if(d.constructor!==Object&&(u=s.get(d.constructor)))p[y]=u(d,g);else if(ArrayBuffer.isView(d))p[y]=x(d);else{const b=i.indexOf(d);b!==-1?p[y]=r[b]:p[y]=g(d)}}return i.pop(),r.pop(),p}}return I}var dt=pt();const ft=H.getDefaultExportFromCjs(dt),Q="Output the version number of npm-check-updates.",mt=x=>x.replace(/`/g,""),gt=ft();(async()=>{const{default:x}=await Promise.resolve().then(()=>require("./index-Cx8RNc34.js")),v=x({pkg:H.pkg});if(v.update&&v.update.latest!==H.pkg.version){const{default:n}=await Promise.resolve().then(()=>require("./index-Bl96b__P.js")),o=H.semver.parse(v.update.current)?.major,a=H.semver.parse(v.update.latest)?.major,O=(o&&a&&a>=o?new Array(a-o).fill(0).map((w,m)=>o+m+1):[]).map(w=>`${H.pkg.homepage??""}/releases/tag/v${w}.0.0`),C=`${H.pkg.homepage??""}/compare/v${v.update.current}...v${v.update.latest}`;v.notify({defer:!1,isGlobal:!0,message:`Update available ${n.dim("{currentVersion}")}${n.reset(" → ")}${v.update.type==="major"?n.red("{latestVersion}"):v.update.type==="minor"?n.yellow("{latestVersion}"):n.green("{latestVersion}")} Run ${n.cyan("{updateCommand}")} to update ${n.dim.underline(v.update.type==="major"?O.map(w=>n.dim.underline(w)).join(` `):C)}`})}const E=process.argv.slice(2),f=E.findIndex(n=>n==="--help"||n==="-h");if(f!==-1&&E[f+1]){const n=E[f+1].replace(/^-*/,"");n==="help"||n==="h"?console.info("Would you like some help with your help?"):(await H.chalkInit(),[...E.slice(0,f),...E.slice(f+1)].forEach(a=>{const c=a.replace(/^-*/,""),O=H.cliOptionsSorted.find(C=>c===C.long||c===C.short||c===`no-${C.long}`&&C.type==="boolean");console.info(O?H.renderExtendedHelp(O)+` `:c==="version"||c==="v"||c==="V"?H.renderExtendedHelp({long:"version",short:"v",description:Q,type:"string"})+` `:`Unknown option: ${a}`)})),process.exit(0)}const i=new Set(H.cliOptionsSorted.filter(n=>n.cli===!1).map(n=>`--${n.long}`));k.description("[filter] is a list or regex of package names to check (all others will be ignored).").usage("[options] [filter]").configureHelp({optionTerm:n=>n.long&&i.has(n.long)?n.long.replace("--","")+"*":n.long==="--version"?"-v, -V, --version":n.flags.replace("[bool]",""),optionDescription:n=>n.long==="--version"?Q:n.long==="--help"?`You're lookin' at it. Run "ncu --help <option>" for a specific option.`:ct.prototype.optionDescription(n)}).addOption(new K("-v, --versionAlias").hideHelp()).on("option:versionAlias",()=>{console.info(H.pkg.version),process.exit(0)}),H.cliOptionsSorted.forEach(({long:n,short:o,arg:a,description:c,default:O,help:C,parse:w,type:m})=>{const A=`${o?`-${o}, `:""}--${n}${a?` <${a}>`:""}`,$=`${mt(c)}${C?` Run "ncu --help ${n}" for details.`:""}`;k.option(A,$,w||O,w?O:void 0),m==="boolean"&&k.addOption(new K(`--no-${n}`).default(!1).hideHelp())}),k.version(H.pkg.version);const r=gt(k._optionValues);k.allowExcessArguments(!0),k.parse(process.argv);const s=k.opts(),u=process.argv.slice(2),{color:_,configFileName:l,configFilePath:g,global:h,packageFile:p,mergeConfig:y}=s;await H.chalkInit(_);const d=!process.env.NCU_TESTS||g||y?await H.getNcuRc({configFileName:l,configFilePath:g,global:h,packageFile:p,options:{...s,cli:!0}}):null,b=(d?.args||[]).filter((n,o,a)=>(typeof n!="string"||!n.startsWith("-")||!u.includes(n))&&(typeof a[o-1]!="string"||!a[o-1].startsWith("-")||!u.includes(a[o-1]))),V=[...process.argv.slice(0,2),...b,...u];k._optionValues=r,k.parse(V);const t=k.opts(),e={...d&&Object.keys(d.config).length>0?{rcConfigPath:d.filePath}:null,...H.pickBy(k.opts(),n=>n!==void 0),args:k.args,...t.filter?{filter:t.filter}:null,...t.reject?{reject:t.reject}:null};H.run(e,{cli:!0})})(); //# sourceMappingURL=cli.js.map