npm-check-updates 19.6.5 → 20.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/build/cli.js CHANGED
@@ -18,16 +18,16 @@ Expecting one of '${n.join("', '")}'`);return this._lifeCycleHooks[t]?this._life
18
18
  - 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
19
19
  - if '${n}' is not meant to be an executable command, remove description parameter from '.command()' and use '.description()' instead
20
20
  - if the default executable name is not suitable, use the executableFile option to supply a custom name or path
21
- - ${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}
21
+ - ${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*\.\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}
22
22
  `,this._outputConfiguration.writeErr),typeof this._showHelpAfterError=="string"?this._outputConfiguration.writeErr(`${this._showHelpAfterError}
23
23
  `):this._showHelpAfterError&&(this._outputConfiguration.writeErr(`
24
24
  `),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}
25
25
  `),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.
26
26
  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}
27
- `)}),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}")}
27
+ `)}),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-D8bKSgSs.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}")}
28
28
  Run ${n.cyan("{updateCommand}")} to update
29
29
  ${n.dim.underline(v.update.type==="major"?O.map(w=>n.dim.underline(w)).join(`
30
30
  `):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)+`
31
31
  `:c==="version"||c==="v"||c==="V"?H.renderExtendedHelp({long:"version",short:"v",description:Q,type:"string"})+`
32
- `:`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})})();
32
+ `:`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.default(e,{cli:!0})})();
33
33
  //# sourceMappingURL=cli.js.map