package-checker-cli
Version:
AI-powered CLI tool for intelligent dependency analysis and code assistance
28 lines • 193 kB
JavaScript
#!/usr/bin/env node
"use strict";var So=Object.create;var cs=Object.defineProperty;var vo=Object.getOwnPropertyDescriptor;var ko=Object.getOwnPropertyNames;var Eo=Object.getPrototypeOf,_o=Object.prototype.hasOwnProperty;var k=(n,t)=>()=>(t||n((t={exports:{}}).exports,t),t.exports);var xo=(n,t,e,i)=>{if(t&&typeof t=="object"||typeof t=="function")for(let s of ko(t))!_o.call(n,s)&&s!==e&&cs(n,s,{get:()=>t[s],enumerable:!(i=vo(t,s))||i.enumerable});return n};var ut=(n,t,e)=>(e=n!=null?So(Eo(n)):{},xo(t||!n||!n.__esModule?cs(e,"default",{value:n,enumerable:!0}):e,n));var ce=k(pi=>{var De=class extends Error{constructor(t,e,i){super(i),Error.captureStackTrace(this,this.constructor),this.name=this.constructor.name,this.code=e,this.exitCode=t,this.nestedError=void 0}},fi=class extends De{constructor(t){super(1,"commander.invalidArgument",t),Error.captureStackTrace(this,this.constructor),this.name=this.constructor.name}};pi.CommanderError=De;pi.InvalidArgumentError=fi});var Ie=k(mi=>{var{InvalidArgumentError:Oo}=ce(),di=class{constructor(t,e){switch(this.description=e||"",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,e){return e===this.defaultValue||!Array.isArray(e)?[t]:e.concat(t)}default(t,e){return this.defaultValue=t,this.defaultValueDescription=e,this}argParser(t){return this.parseArg=t,this}choices(t){return this.argChoices=t.slice(),this.parseArg=(e,i)=>{if(!this.argChoices.includes(e))throw new Oo(`Allowed choices are ${this.argChoices.join(", ")}.`);return this.variadic?this._concatValue(e,i):e},this}argRequired(){return this.required=!0,this}argOptional(){return this.required=!1,this}};function Co(n){let t=n.name()+(n.variadic===!0?"...":"");return n.required?"<"+t+">":"["+t+"]"}mi.Argument=di;mi.humanReadableArgName=Co});var wi=k(yi=>{var{humanReadableArgName:Ao}=Ie(),gi=class{constructor(){this.helpWidth=void 0,this.minWidthToWrap=40,this.sortSubcommands=!1,this.sortOptions=!1,this.showGlobalOptions=!1}prepareContext(t){this.helpWidth=this.helpWidth??t.helpWidth??80}visibleCommands(t){let e=t.commands.filter(s=>!s._hidden),i=t._getHelpCommand();return i&&!i._hidden&&e.push(i),this.sortSubcommands&&e.sort((s,r)=>s.name().localeCompare(r.name())),e}compareOptions(t,e){let i=s=>s.short?s.short.replace(/^-/,""):s.long.replace(/^--/,"");return i(t).localeCompare(i(e))}visibleOptions(t){let e=t.options.filter(s=>!s.hidden),i=t._getHelpOption();if(i&&!i.hidden){let s=i.short&&t._findOption(i.short),r=i.long&&t._findOption(i.long);!s&&!r?e.push(i):i.long&&!r?e.push(t.createOption(i.long,i.description)):i.short&&!s&&e.push(t.createOption(i.short,i.description))}return this.sortOptions&&e.sort(this.compareOptions),e}visibleGlobalOptions(t){if(!this.showGlobalOptions)return[];let e=[];for(let i=t.parent;i;i=i.parent){let s=i.options.filter(r=>!r.hidden);e.push(...s)}return this.sortOptions&&e.sort(this.compareOptions),e}visibleArguments(t){return t._argsDescription&&t.registeredArguments.forEach(e=>{e.description=e.description||t._argsDescription[e.name()]||""}),t.registeredArguments.find(e=>e.description)?t.registeredArguments:[]}subcommandTerm(t){let e=t.registeredArguments.map(i=>Ao(i)).join(" ");return t._name+(t._aliases[0]?"|"+t._aliases[0]:"")+(t.options.length?" [options]":"")+(e?" "+e:"")}optionTerm(t){return t.flags}argumentTerm(t){return t.name()}longestSubcommandTermLength(t,e){return e.visibleCommands(t).reduce((i,s)=>Math.max(i,this.displayWidth(e.styleSubcommandTerm(e.subcommandTerm(s)))),0)}longestOptionTermLength(t,e){return e.visibleOptions(t).reduce((i,s)=>Math.max(i,this.displayWidth(e.styleOptionTerm(e.optionTerm(s)))),0)}longestGlobalOptionTermLength(t,e){return e.visibleGlobalOptions(t).reduce((i,s)=>Math.max(i,this.displayWidth(e.styleOptionTerm(e.optionTerm(s)))),0)}longestArgumentTermLength(t,e){return e.visibleArguments(t).reduce((i,s)=>Math.max(i,this.displayWidth(e.styleArgumentTerm(e.argumentTerm(s)))),0)}commandUsage(t){let e=t._name;t._aliases[0]&&(e=e+"|"+t._aliases[0]);let i="";for(let s=t.parent;s;s=s.parent)i=s.name()+" "+i;return i+e+" "+t.usage()}commandDescription(t){return t.description()}subcommandDescription(t){return t.summary()||t.description()}optionDescription(t){let e=[];if(t.argChoices&&e.push(`choices: ${t.argChoices.map(i=>JSON.stringify(i)).join(", ")}`),t.defaultValue!==void 0&&(t.required||t.optional||t.isBoolean()&&typeof t.defaultValue=="boolean")&&e.push(`default: ${t.defaultValueDescription||JSON.stringify(t.defaultValue)}`),t.presetArg!==void 0&&t.optional&&e.push(`preset: ${JSON.stringify(t.presetArg)}`),t.envVar!==void 0&&e.push(`env: ${t.envVar}`),e.length>0){let i=`(${e.join(", ")})`;return t.description?`${t.description} ${i}`:i}return t.description}argumentDescription(t){let e=[];if(t.argChoices&&e.push(`choices: ${t.argChoices.map(i=>JSON.stringify(i)).join(", ")}`),t.defaultValue!==void 0&&e.push(`default: ${t.defaultValueDescription||JSON.stringify(t.defaultValue)}`),e.length>0){let i=`(${e.join(", ")})`;return t.description?`${t.description} ${i}`:i}return t.description}formatItemList(t,e,i){return e.length===0?[]:[i.styleTitle(t),...e,""]}groupItems(t,e,i){let s=new Map;return t.forEach(r=>{let o=i(r);s.has(o)||s.set(o,[])}),e.forEach(r=>{let o=i(r);s.has(o)||s.set(o,[]),s.get(o).push(r)}),s}formatHelp(t,e){let i=e.padWidth(t,e),s=e.helpWidth??80;function r(u,f){return e.formatItem(u,i,f,e)}let o=[`${e.styleTitle("Usage:")} ${e.styleUsage(e.commandUsage(t))}`,""],a=e.commandDescription(t);a.length>0&&(o=o.concat([e.boxWrap(e.styleCommandDescription(a),s),""]));let c=e.visibleArguments(t).map(u=>r(e.styleArgumentTerm(e.argumentTerm(u)),e.styleArgumentDescription(e.argumentDescription(u))));if(o=o.concat(this.formatItemList("Arguments:",c,e)),this.groupItems(t.options,e.visibleOptions(t),u=>u.helpGroupHeading??"Options:").forEach((u,f)=>{let p=u.map(d=>r(e.styleOptionTerm(e.optionTerm(d)),e.styleOptionDescription(e.optionDescription(d))));o=o.concat(this.formatItemList(f,p,e))}),e.showGlobalOptions){let u=e.visibleGlobalOptions(t).map(f=>r(e.styleOptionTerm(e.optionTerm(f)),e.styleOptionDescription(e.optionDescription(f))));o=o.concat(this.formatItemList("Global Options:",u,e))}return this.groupItems(t.commands,e.visibleCommands(t),u=>u.helpGroup()||"Commands:").forEach((u,f)=>{let p=u.map(d=>r(e.styleSubcommandTerm(e.subcommandTerm(d)),e.styleSubcommandDescription(e.subcommandDescription(d))));o=o.concat(this.formatItemList(f,p,e))}),o.join(`
`)}displayWidth(t){return ls(t).length}styleTitle(t){return t}styleUsage(t){return t.split(" ").map(e=>e==="[options]"?this.styleOptionText(e):e==="[command]"?this.styleSubcommandText(e):e[0]==="["||e[0]==="<"?this.styleArgumentText(e):this.styleCommandText(e)).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(e=>e==="[options]"?this.styleOptionText(e):e[0]==="["||e[0]==="<"?this.styleArgumentText(e):this.styleSubcommandText(e)).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,e){return Math.max(e.longestOptionTermLength(t,e),e.longestGlobalOptionTermLength(t,e),e.longestSubcommandTermLength(t,e),e.longestArgumentTermLength(t,e))}preformatted(t){return/\n[^\S\r\n]/.test(t)}formatItem(t,e,i,s){let o=" ".repeat(2);if(!i)return o+t;let a=t.padEnd(e+t.length-s.displayWidth(t)),c=2,l=(this.helpWidth??80)-e-c-2,u;return l<this.minWidthToWrap||s.preformatted(i)?u=i:u=s.boxWrap(i,l).replace(/\n/g,`
`+" ".repeat(e+c)),o+a+" ".repeat(c)+u.replace(/\n/g,`
${o}`)}boxWrap(t,e){if(e<this.minWidthToWrap)return t;let i=t.split(/\r\n|\n/),s=/[\s]*[^\s]+/g,r=[];return i.forEach(o=>{let a=o.match(s);if(a===null){r.push("");return}let c=[a.shift()],h=this.displayWidth(c[0]);a.forEach(l=>{let u=this.displayWidth(l);if(h+u<=e){c.push(l),h+=u;return}r.push(c.join(""));let f=l.trimStart();c=[f],h=this.displayWidth(f)}),r.push(c.join(""))}),r.join(`
`)}};function ls(n){let t=/\x1b\[\d*(;\d*)*m/g;return n.replace(t,"")}yi.Help=gi;yi.stripColor=ls});var ki=k(vi=>{var{InvalidArgumentError:Po}=ce(),bi=class{constructor(t,e){this.flags=t,this.description=e||"",this.required=t.includes("<"),this.optional=t.includes("["),this.variadic=/\w\.\.\.[>\]]$/.test(t),this.mandatory=!1;let i=Fo(t);this.short=i.shortFlag,this.long=i.longFlag,this.negate=!1,this.long&&(this.negate=this.long.startsWith("--no-")),this.defaultValue=void 0,this.defaultValueDescription=void 0,this.presetArg=void 0,this.envVar=void 0,this.parseArg=void 0,this.hidden=!1,this.argChoices=void 0,this.conflictsWith=[],this.implied=void 0,this.helpGroupHeading=void 0}default(t,e){return this.defaultValue=t,this.defaultValueDescription=e,this}preset(t){return this.presetArg=t,this}conflicts(t){return this.conflictsWith=this.conflictsWith.concat(t),this}implies(t){let e=t;return typeof t=="string"&&(e={[t]:!0}),this.implied=Object.assign(this.implied||{},e),this}env(t){return this.envVar=t,this}argParser(t){return this.parseArg=t,this}makeOptionMandatory(t=!0){return this.mandatory=!!t,this}hideHelp(t=!0){return this.hidden=!!t,this}_concatValue(t,e){return e===this.defaultValue||!Array.isArray(e)?[t]:e.concat(t)}choices(t){return this.argChoices=t.slice(),this.parseArg=(e,i)=>{if(!this.argChoices.includes(e))throw new Po(`Allowed choices are ${this.argChoices.join(", ")}.`);return this.variadic?this._concatValue(e,i):e},this}name(){return this.long?this.long.replace(/^--/,""):this.short.replace(/^-/,"")}attributeName(){return this.negate?hs(this.name().replace(/^no-/,"")):hs(this.name())}helpGroup(t){return this.helpGroupHeading=t,this}is(t){return this.short===t||this.long===t}isBoolean(){return!this.required&&!this.optional&&!this.negate}},Si=class{constructor(t){this.positiveOptions=new Map,this.negativeOptions=new Map,this.dualOptions=new Set,t.forEach(e=>{e.negate?this.negativeOptions.set(e.attributeName(),e):this.positiveOptions.set(e.attributeName(),e)}),this.negativeOptions.forEach((e,i)=>{this.positiveOptions.has(i)&&this.dualOptions.add(i)})}valueFromOption(t,e){let i=e.attributeName();if(!this.dualOptions.has(i))return!0;let s=this.negativeOptions.get(i).presetArg,r=s!==void 0?s:!1;return e.negate===(r===t)}};function hs(n){return n.split("-").reduce((t,e)=>t+e[0].toUpperCase()+e.slice(1))}function Fo(n){let t,e,i=/^-[^-]$/,s=/^--[^-]/,r=n.split(/[ |,]+/).concat("guard");if(i.test(r[0])&&(t=r.shift()),s.test(r[0])&&(e=r.shift()),!t&&i.test(r[0])&&(t=r.shift()),!t&&s.test(r[0])&&(t=e,e=r.shift()),r[0].startsWith("-")){let o=r[0],a=`option creation failed due to '${o}' in option flags '${n}'`;throw/^-[^-][^-]/.test(o)?new Error(`${a}
- 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')`):i.test(o)?new Error(`${a}
- too many short flags`):s.test(o)?new Error(`${a}
- too many long flags`):new Error(`${a}
- unrecognised flag format`)}if(t===void 0&&e===void 0)throw new Error(`option creation failed due to no flags found in '${n}'.`);return{shortFlag:t,longFlag:e}}vi.Option=bi;vi.DualOptions=Si});var fs=k(us=>{function To(n,t){if(Math.abs(n.length-t.length)>3)return Math.max(n.length,t.length);let e=[];for(let i=0;i<=n.length;i++)e[i]=[i];for(let i=0;i<=t.length;i++)e[0][i]=i;for(let i=1;i<=t.length;i++)for(let s=1;s<=n.length;s++){let r=1;n[s-1]===t[i-1]?r=0:r=1,e[s][i]=Math.min(e[s-1][i]+1,e[s][i-1]+1,e[s-1][i-1]+r),s>1&&i>1&&n[s-1]===t[i-2]&&n[s-2]===t[i-1]&&(e[s][i]=Math.min(e[s][i],e[s-2][i-2]+1))}return e[n.length][t.length]}function $o(n,t){if(!t||t.length===0)return"";t=Array.from(new Set(t));let e=n.startsWith("--");e&&(n=n.slice(2),t=t.map(o=>o.slice(2)));let i=[],s=3,r=.4;return t.forEach(o=>{if(o.length<=1)return;let a=To(n,o),c=Math.max(n.length,o.length);(c-a)/c>r&&(a<s?(s=a,i=[o]):a===s&&i.push(o))}),i.sort((o,a)=>o.localeCompare(a)),e&&(i=i.map(o=>`--${o}`)),i.length>1?`
(Did you mean one of ${i.join(", ")}?)`:i.length===1?`
(Did you mean ${i[0]}?)`:""}us.suggestSimilar=$o});var gs=k(Ci=>{var Do=require("node:events").EventEmitter,Ei=require("node:child_process"),_t=require("node:path"),Ne=require("node:fs"),x=require("node:process"),{Argument:Io,humanReadableArgName:No}=Ie(),{CommanderError:_i}=ce(),{Help:jo,stripColor:Ro}=wi(),{Option:ps,DualOptions:Mo}=ki(),{suggestSimilar:ds}=fs(),xi=class n extends Do{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=>x.stdout.write(e),writeErr:e=>x.stderr.write(e),outputError:(e,i)=>i(e),getOutHelpWidth:()=>x.stdout.isTTY?x.stdout.columns:void 0,getErrHelpWidth:()=>x.stderr.isTTY?x.stderr.columns:void 0,getOutHasColors:()=>Oi()??(x.stdout.isTTY&&x.stdout.hasColors?.()),getErrHasColors:()=>Oi()??(x.stderr.isTTY&&x.stderr.hasColors?.()),stripColor:e=>Ro(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(){let t=[];for(let e=this;e;e=e.parent)t.push(e);return t}command(t,e,i){let s=e,r=i;typeof s=="object"&&s!==null&&(r=s,s=null),r=r||{};let[,o,a]=t.match(/([^ ]+) *(.*)/),c=this.createCommand(o);return s&&(c.description(s),c._executableHandler=!0),r.isDefault&&(this._defaultCommandName=c._name),c._hidden=!!(r.noHelp||r.hidden),c._executableFile=r.executableFile||null,a&&c.arguments(a),this._registerCommand(c),c.parent=this,c.copyInheritedSettings(this),s?this:c}createCommand(t){return new n(t)}createHelp(){return Object.assign(new jo,this.configureHelp())}configureHelp(t){return t===void 0?this._helpConfiguration:(this._helpConfiguration=t,this)}configureOutput(t){return t===void 0?this._outputConfiguration:(this._outputConfiguration=Object.assign({},this._outputConfiguration,t),this)}showHelpAfterError(t=!0){return typeof t!="string"&&(t=!!t),this._showHelpAfterError=t,this}showSuggestionAfterError(t=!0){return this._showSuggestionAfterError=!!t,this}addCommand(t,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 Io(t,e)}argument(t,e,i,s){let r=this.createArgument(t,e);return typeof i=="function"?r.default(s).argParser(i):r.default(i),this.addArgument(r),this}arguments(t){return t.trim().split(/ +/).forEach(e=>{this.argument(e)}),this}addArgument(t){let e=this.registeredArguments.slice(-1)[0];if(e&&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;let i=t??"help [command]",[,s,r]=i.match(/([^ ]+) *(.*)/),o=e??"display help for command",a=this.createCommand(s);return a.helpOption(!1),r&&a.arguments(r),o&&a.description(o),this._addImplicitHelpCommand=!0,this._helpCommand=a,(t||e)&&this._initCommandGroup(a),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){let i=["preSubcommand","preAction","postAction"];if(!i.includes(t))throw new Error(`Unexpected value for event passed to hook : '${t}'.
Expecting one of '${i.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,i){this._exitCallback&&this._exitCallback(new _i(t,e,i)),x.exit(t)}action(t){let e=i=>{let s=this.registeredArguments.length,r=i.slice(0,s);return this._storeOptionsAsProperties?r[s]=this:r[s]=this.opts(),r.push(this),t.apply(this,r)};return this._actionHandler=e,this}createOption(t,e){return new ps(t,e)}_callParseArg(t,e,i,s){try{return t.parseArg(e,i)}catch(r){if(r.code==="commander.invalidArgument"){let o=`${s} ${r.message}`;this.error(o,{exitCode:r.exitCode,code:r.code})}throw r}}_registerOption(t){let e=t.short&&this._findOption(t.short)||t.long&&this._findOption(t.long);if(e){let i=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 '${i}'
- already used by option '${e.flags}'`)}this._initOptionGroup(t),this.options.push(t)}_registerCommand(t){let e=s=>[s.name()].concat(s.aliases()),i=e(t).find(s=>this._findCommand(s));if(i){let s=e(this._findCommand(i)).join("|"),r=e(t).join("|");throw new Error(`cannot add command '${r}' as already have command '${s}'`)}this._initCommandGroup(t),this.commands.push(t)}addOption(t){this._registerOption(t);let e=t.name(),i=t.attributeName();if(t.negate){let r=t.long.replace(/^--no-/,"--");this._findOption(r)||this.setOptionValueWithSource(i,t.defaultValue===void 0?!0:t.defaultValue,"default")}else t.defaultValue!==void 0&&this.setOptionValueWithSource(i,t.defaultValue,"default");let s=(r,o,a)=>{r==null&&t.presetArg!==void 0&&(r=t.presetArg);let c=this.getOptionValue(i);r!==null&&t.parseArg?r=this._callParseArg(t,r,c,o):r!==null&&t.variadic&&(r=t._concatValue(r,c)),r==null&&(t.negate?r=!1:t.isBoolean()||t.optional?r=!0:r=""),this.setOptionValueWithSource(i,r,a)};return this.on("option:"+e,r=>{let o=`error: option '${t.flags}' argument '${r}' is invalid.`;s(r,o,"cli")}),t.envVar&&this.on("optionEnv:"+e,r=>{let o=`error: option '${t.flags}' value '${r}' from env '${t.envVar}' is invalid.`;s(r,o,"env")}),this}_optionEx(t,e,i,s,r){if(typeof e=="object"&&e instanceof ps)throw new Error("To add an Option object use addOption() instead of option() or requiredOption()");let o=this.createOption(e,i);if(o.makeOptionMandatory(!!t.mandatory),typeof s=="function")o.default(r).argParser(s);else if(s instanceof RegExp){let a=s;s=(c,h)=>{let l=a.exec(c);return l?l[0]:h},o.default(r).argParser(s)}else o.default(s);return this.addOption(o)}option(t,e,i,s){return this._optionEx({},t,e,i,s)}requiredOption(t,e,i,s){return this._optionEx({mandatory:!0},t,e,i,s)}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,i){return this._storeOptionsAsProperties?this[t]=e:this._optionValues[t]=e,this._optionValueSources[t]=i,this}getOptionValueSource(t){return this._optionValueSources[t]}getOptionValueSourceWithGlobals(t){let e;return this._getCommandAndAncestors().forEach(i=>{i.getOptionValueSource(t)!==void 0&&(e=i.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){x.versions?.electron&&(e.from="electron");let s=x.execArgv??[];(s.includes("-e")||s.includes("--eval")||s.includes("-p")||s.includes("--print"))&&(e.from="eval")}t===void 0&&(t=x.argv),this.rawArgs=t.slice();let i;switch(e.from){case void 0:case"node":this._scriptPath=t[1],i=t.slice(2);break;case"electron":x.defaultApp?(this._scriptPath=t[1],i=t.slice(2)):i=t.slice(1);break;case"user":i=t.slice(0);break;case"eval":i=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",i}parse(t,e){this._prepareForParse();let i=this._prepareUserArgs(t,e);return this._parseCommand([],i),this}async parseAsync(t,e){this._prepareForParse();let i=this._prepareUserArgs(t,e);return await this._parseCommand([],i),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,i){if(Ne.existsSync(t))return;let s=e?`searched for local subcommand relative to directory '${e}'`:"no directory for search for local subcommand, use .executableDir() to supply a custom directory",r=`'${t}' does not exist
- if '${i}' 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
- ${s}`;throw new Error(r)}_executeSubCommand(t,e){e=e.slice();let i=!1,s=[".js",".ts",".tsx",".mjs",".cjs"];function r(l,u){let f=_t.resolve(l,u);if(Ne.existsSync(f))return f;if(s.includes(_t.extname(u)))return;let p=s.find(d=>Ne.existsSync(`${f}${d}`));if(p)return`${f}${p}`}this._checkForMissingMandatoryOptions(),this._checkForConflictingOptions();let o=t._executableFile||`${this._name}-${t._name}`,a=this._executableDir||"";if(this._scriptPath){let l;try{l=Ne.realpathSync(this._scriptPath)}catch{l=this._scriptPath}a=_t.resolve(_t.dirname(l),a)}if(a){let l=r(a,o);if(!l&&!t._executableFile&&this._scriptPath){let u=_t.basename(this._scriptPath,_t.extname(this._scriptPath));u!==this._name&&(l=r(a,`${u}-${t._name}`))}o=l||o}i=s.includes(_t.extname(o));let c;x.platform!=="win32"?i?(e.unshift(o),e=ms(x.execArgv).concat(e),c=Ei.spawn(x.argv[0],e,{stdio:"inherit"})):c=Ei.spawn(o,e,{stdio:"inherit"}):(this._checkForMissingExecutable(o,a,t._name),e.unshift(o),e=ms(x.execArgv).concat(e),c=Ei.spawn(x.execPath,e,{stdio:"inherit"})),c.killed||["SIGUSR1","SIGUSR2","SIGTERM","SIGINT","SIGHUP"].forEach(u=>{x.on(u,()=>{c.killed===!1&&c.exitCode===null&&c.kill(u)})});let h=this._exitCallback;c.on("close",l=>{l=l??1,h?h(new _i(l,"commander.executeSubCommandAsync","(close)")):x.exit(l)}),c.on("error",l=>{if(l.code==="ENOENT")this._checkForMissingExecutable(o,a,t._name);else if(l.code==="EACCES")throw new Error(`'${o}' not executable`);if(!h)x.exit(1);else{let u=new _i(1,"commander.executeSubCommandAsync","(error)");u.nestedError=l,h(u)}}),this.runningCommand=c}_dispatchSubcommand(t,e,i){let s=this._findCommand(t);s||this.help({error:!0}),s._prepareForParse();let r;return r=this._chainOrCallSubCommandHook(r,s,"preSubcommand"),r=this._chainOrCall(r,()=>{if(s._executableHandler)this._executeSubCommand(s,e.concat(i));else return s._parseCommand(e,i)}),r}_dispatchHelpCommand(t){t||this.help();let 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(){let t=(i,s,r)=>{let o=s;if(s!==null&&i.parseArg){let a=`error: command-argument value '${s}' is invalid for argument '${i.name()}'.`;o=this._callParseArg(i,s,r,a)}return o};this._checkNumberOfArguments();let e=[];this.registeredArguments.forEach((i,s)=>{let r=i.defaultValue;i.variadic?s<this.args.length?(r=this.args.slice(s),i.parseArg&&(r=r.reduce((o,a)=>t(i,a,o),i.defaultValue))):r===void 0&&(r=[]):s<this.args.length&&(r=this.args[s],i.parseArg&&(r=t(i,r,i.defaultValue))),e[s]=r}),this.processedArgs=e}_chainOrCall(t,e){return t&&t.then&&typeof t.then=="function"?t.then(()=>e()):e()}_chainOrCallHooks(t,e){let i=t,s=[];return this._getCommandAndAncestors().reverse().filter(r=>r._lifeCycleHooks[e]!==void 0).forEach(r=>{r._lifeCycleHooks[e].forEach(o=>{s.push({hookedCommand:r,callback:o})})}),e==="postAction"&&s.reverse(),s.forEach(r=>{i=this._chainOrCall(i,()=>r.callback(r.hookedCommand,this))}),i}_chainOrCallSubCommandHook(t,e,i){let s=t;return this._lifeCycleHooks[i]!==void 0&&this._lifeCycleHooks[i].forEach(r=>{s=this._chainOrCall(s,()=>r(this,e))}),s}_parseCommand(t,e){let i=this.parseOptions(e);if(this._parseOptionsEnv(),this._parseOptionsImplied(),t=t.concat(i.operands),e=i.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(i.unknown),this._checkForMissingMandatoryOptions(),this._checkForConflictingOptions();let s=()=>{i.unknown.length>0&&this.unknownOption(i.unknown[0])},r=`command:${this.name()}`;if(this._actionHandler){s(),this._processArguments();let o;return o=this._chainOrCallHooks(o,"preAction"),o=this._chainOrCall(o,()=>this._actionHandler(this.processedArgs)),this.parent&&(o=this._chainOrCall(o,()=>{this.parent.emit(r,t,e)})),o=this._chainOrCallHooks(o,"postAction"),o}if(this.parent&&this.parent.listenerCount(r))s(),this._processArguments(),this.parent.emit(r,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():(s(),this._processArguments())}else this.commands.length?(s(),this.help({error:!0})):(s(),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(){let t=this.options.filter(i=>{let s=i.attributeName();return this.getOptionValue(s)===void 0?!1:this.getOptionValueSource(s)!=="default"});t.filter(i=>i.conflictsWith.length>0).forEach(i=>{let s=t.find(r=>i.conflictsWith.includes(r.attributeName()));s&&this._conflictingOption(i,s)})}_checkForConflictingOptions(){this._getCommandAndAncestors().forEach(t=>{t._checkForConflictingLocalOptions()})}parseOptions(t){let e=[],i=[],s=e,r=t.slice();function o(h){return h.length>1&&h[0]==="-"}let a=h=>/^-\d*\.?\d+(e[+-]?\d+)?$/.test(h)?!this._getCommandAndAncestors().some(l=>l.options.map(u=>u.short).some(u=>/^-\d$/.test(u))):!1,c=null;for(;r.length;){let h=r.shift();if(h==="--"){s===i&&s.push(h),s.push(...r);break}if(c&&(!o(h)||a(h))){this.emit(`option:${c.name()}`,h);continue}if(c=null,o(h)){let l=this._findOption(h);if(l){if(l.required){let u=r.shift();u===void 0&&this.optionMissingArgument(l),this.emit(`option:${l.name()}`,u)}else if(l.optional){let u=null;r.length>0&&(!o(r[0])||a(r[0]))&&(u=r.shift()),this.emit(`option:${l.name()}`,u)}else this.emit(`option:${l.name()}`);c=l.variadic?l:null;continue}}if(h.length>2&&h[0]==="-"&&h[1]!=="-"){let l=this._findOption(`-${h[1]}`);if(l){l.required||l.optional&&this._combineFlagAndOptionalValue?this.emit(`option:${l.name()}`,h.slice(2)):(this.emit(`option:${l.name()}`),r.unshift(`-${h.slice(2)}`));continue}}if(/^--[^=]+=/.test(h)){let l=h.indexOf("="),u=this._findOption(h.slice(0,l));if(u&&(u.required||u.optional)){this.emit(`option:${u.name()}`,h.slice(l+1));continue}}if(s===e&&o(h)&&!(this.commands.length===0&&a(h))&&(s=i),(this._enablePositionalOptions||this._passThroughOptions)&&e.length===0&&i.length===0){if(this._findCommand(h)){e.push(h),r.length>0&&i.push(...r);break}else if(this._getHelpCommand()&&h===this._getHelpCommand().name()){e.push(h),r.length>0&&e.push(...r);break}else if(this._defaultCommandName){i.push(h),r.length>0&&i.push(...r);break}}if(this._passThroughOptions){s.push(h),r.length>0&&s.push(...r);break}s.push(h)}return{operands:e,unknown:i}}opts(){if(this._storeOptionsAsProperties){let t={},e=this.options.length;for(let i=0;i<e;i++){let s=this.options[i].attributeName();t[s]=s===this._versionOptionName?this._version:this[s]}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}));let i=e||{},s=i.exitCode||1,r=i.code||"commander.error";this._exit(s,r,t)}_parseOptionsEnv(){this.options.forEach(t=>{if(t.envVar&&t.envVar in x.env){let e=t.attributeName();(this.getOptionValue(e)===void 0||["default","config","env"].includes(this.getOptionValueSource(e)))&&(t.required||t.optional?this.emit(`optionEnv:${t.name()}`,x.env[t.envVar]):this.emit(`optionEnv:${t.name()}`))}})}_parseOptionsImplied(){let t=new Mo(this.options),e=i=>this.getOptionValue(i)!==void 0&&!["default","implied"].includes(this.getOptionValueSource(i));this.options.filter(i=>i.implied!==void 0&&e(i.attributeName())&&t.valueFromOption(this.getOptionValue(i.attributeName()),i)).forEach(i=>{Object.keys(i.implied).filter(s=>!e(s)).forEach(s=>{this.setOptionValueWithSource(s,i.implied[s],"implied")})})}missingArgument(t){let e=`error: missing required argument '${t}'`;this.error(e,{code:"commander.missingArgument"})}optionMissingArgument(t){let e=`error: option '${t.flags}' argument missing`;this.error(e,{code:"commander.optionMissingArgument"})}missingMandatoryOptionValue(t){let e=`error: required option '${t.flags}' not specified`;this.error(e,{code:"commander.missingMandatoryOptionValue"})}_conflictingOption(t,e){let i=o=>{let a=o.attributeName(),c=this.getOptionValue(a),h=this.options.find(u=>u.negate&&a===u.attributeName()),l=this.options.find(u=>!u.negate&&a===u.attributeName());return h&&(h.presetArg===void 0&&c===!1||h.presetArg!==void 0&&c===h.presetArg)?h:l||o},s=o=>{let a=i(o),c=a.attributeName();return this.getOptionValueSource(c)==="env"?`environment variable '${a.envVar}'`:`option '${a.flags}'`},r=`error: ${s(t)} cannot be used with ${s(e)}`;this.error(r,{code:"commander.conflictingOption"})}unknownOption(t){if(this._allowUnknownOption)return;let e="";if(t.startsWith("--")&&this._showSuggestionAfterError){let s=[],r=this;do{let o=r.createHelp().visibleOptions(r).filter(a=>a.long).map(a=>a.long);s=s.concat(o),r=r.parent}while(r&&!r._enablePositionalOptions);e=ds(t,s)}let i=`error: unknown option '${t}'${e}`;this.error(i,{code:"commander.unknownOption"})}_excessArguments(t){if(this._allowExcessArguments)return;let e=this.registeredArguments.length,i=e===1?"":"s",r=`error: too many arguments${this.parent?` for '${this.name()}'`:""}. Expected ${e} argument${i} but got ${t.length}.`;this.error(r,{code:"commander.excessArguments"})}unknownCommand(){let t=this.args[0],e="";if(this._showSuggestionAfterError){let s=[];this.createHelp().visibleCommands(this).forEach(r=>{s.push(r.name()),r.alias()&&s.push(r.alias())}),e=ds(t,s)}let i=`error: unknown command '${t}'${e}`;this.error(i,{code:"commander.unknownCommand"})}version(t,e,i){if(t===void 0)return this._version;this._version=t,e=e||"-V, --version",i=i||"output the version number";let s=this.createOption(e,i);return this._versionOptionName=s.attributeName(),this._registerOption(s),this.on("option:"+s.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");let i=this.parent?._findCommand(t);if(i){let s=[i.name()].concat(i.aliases()).join("|");throw new Error(`cannot add alias '${t}' to command '${this.name()}' as already have command '${s}'`)}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;let e=this.registeredArguments.map(i=>No(i));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=_t.basename(t,_t.extname(t)),this}executableDir(t){return t===void 0?this._executableDir:(this._executableDir=t,this)}helpInformation(t){let e=this.createHelp(),i=this._getOutputContext(t);e.prepareContext({error:i.error,helpWidth:i.helpWidth,outputHasColors:i.hasColors});let s=e.formatHelp(this,e);return i.hasColors?s:this._outputConfiguration.stripColor(s)}_getOutputContext(t){t=t||{};let e=!!t.error,i,s,r;return e?(i=a=>this._outputConfiguration.writeErr(a),s=this._outputConfiguration.getErrHasColors(),r=this._outputConfiguration.getErrHelpWidth()):(i=a=>this._outputConfiguration.writeOut(a),s=this._outputConfiguration.getOutHasColors(),r=this._outputConfiguration.getOutHelpWidth()),{error:e,write:a=>(s||(a=this._outputConfiguration.stripColor(a)),i(a)),hasColors:s,helpWidth:r}}outputHelp(t){let e;typeof t=="function"&&(e=t,t=void 0);let i=this._getOutputContext(t),s={error:i.error,write:i.write,command:this};this._getCommandAndAncestors().reverse().forEach(o=>o.emit("beforeAllHelp",s)),this.emit("beforeHelp",s);let r=this.helpInformation({error:i.error});if(e&&(r=e(r),typeof r!="string"&&!Buffer.isBuffer(r)))throw new Error("outputHelp callback must return a string or a Buffer");i.write(r),this._getHelpOption()?.long&&this.emit(this._getHelpOption().long),this.emit("afterHelp",s),this._getCommandAndAncestors().forEach(o=>o.emit("afterAllHelp",s))}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(x.exitCode??0);e===0&&t&&typeof t!="function"&&t.error&&(e=1),this._exit(e,"commander.help","(outputHelp)")}addHelpText(t,e){let i=["beforeAll","before","after","afterAll"];if(!i.includes(t))throw new Error(`Unexpected value for position to addHelpText.
Expecting one of '${i.join("', '")}'`);let s=`${t}Help`;return this.on(s,r=>{let o;typeof e=="function"?o=e({error:r.error,command:r.command}):o=e,o&&r.write(`${o}
`)}),this}_outputHelpIfRequested(t){let e=this._getHelpOption();e&&t.find(s=>e.is(s))&&(this.outputHelp(),this._exit(0,"commander.helpDisplayed","(outputHelp)"))}};function ms(n){return n.map(t=>{if(!t.startsWith("--inspect"))return t;let e,i="127.0.0.1",s="9229",r;return(r=t.match(/^(--inspect(-brk)?)$/))!==null?e=r[1]:(r=t.match(/^(--inspect(-brk|-port)?)=([^:]+)$/))!==null?(e=r[1],/^\d+$/.test(r[3])?s=r[3]:i=r[3]):(r=t.match(/^(--inspect(-brk|-port)?)=([^:]+):(\d+)$/))!==null&&(e=r[1],i=r[3],s=r[4]),e&&s!=="0"?`${e}=${i}:${parseInt(s)+1}`:t})}function Oi(){if(x.env.NO_COLOR||x.env.FORCE_COLOR==="0"||x.env.FORCE_COLOR==="false")return!1;if(x.env.FORCE_COLOR||x.env.CLICOLOR_FORCE!==void 0)return!0}Ci.Command=xi;Ci.useColor=Oi});var Ss=k(ot=>{var{Argument:ys}=Ie(),{Command:Ai}=gs(),{CommanderError:Lo,InvalidArgumentError:ws}=ce(),{Help:qo}=wi(),{Option:bs}=ki();ot.program=new Ai;ot.createCommand=n=>new Ai(n);ot.createOption=(n,t)=>new bs(n,t);ot.createArgument=(n,t)=>new ys(n,t);ot.Command=Ai;ot.Option=bs;ot.Argument=ys;ot.Help=qo;ot.CommanderError=Lo;ot.InvalidArgumentError=ws;ot.InvalidOptionArgumentError=ws});var N=k(Pi=>{"use strict";Pi.fromCallback=function(n){return Object.defineProperty(function(...t){if(typeof t[t.length-1]=="function")n.apply(this,t);else return new Promise((e,i)=>{t.push((s,r)=>s!=null?i(s):e(r)),n.apply(this,t)})},"name",{value:n.name})};Pi.fromPromise=function(n){return Object.defineProperty(function(...t){let e=t[t.length-1];if(typeof e!="function")return n.apply(this,t);t.pop(),n.apply(this,t).then(i=>e(null,i),e)},"name",{value:n.name})}});var _s=k((Oh,Es)=>{var Ft=require("constants"),Wo=process.cwd,je=null,zo=process.env.GRACEFUL_FS_PLATFORM||process.platform;process.cwd=function(){return je||(je=Wo.call(process)),je};try{process.cwd()}catch{}typeof process.chdir=="function"&&(Fi=process.chdir,process.chdir=function(n){je=null,Fi.call(process,n)},Object.setPrototypeOf&&Object.setPrototypeOf(process.chdir,Fi));var Fi;Es.exports=Ho;function Ho(n){Ft.hasOwnProperty("O_SYMLINK")&&process.version.match(/^v0\.6\.[0-2]|^v0\.5\./)&&t(n),n.lutimes||e(n),n.chown=r(n.chown),n.fchown=r(n.fchown),n.lchown=r(n.lchown),n.chmod=i(n.chmod),n.fchmod=i(n.fchmod),n.lchmod=i(n.lchmod),n.chownSync=o(n.chownSync),n.fchownSync=o(n.fchownSync),n.lchownSync=o(n.lchownSync),n.chmodSync=s(n.chmodSync),n.fchmodSync=s(n.fchmodSync),n.lchmodSync=s(n.lchmodSync),n.stat=a(n.stat),n.fstat=a(n.fstat),n.lstat=a(n.lstat),n.statSync=c(n.statSync),n.fstatSync=c(n.fstatSync),n.lstatSync=c(n.lstatSync),n.chmod&&!n.lchmod&&(n.lchmod=function(l,u,f){f&&process.nextTick(f)},n.lchmodSync=function(){}),n.chown&&!n.lchown&&(n.lchown=function(l,u,f,p){p&&process.nextTick(p)},n.lchownSync=function(){}),zo==="win32"&&(n.rename=typeof n.rename!="function"?n.rename:function(l){function u(f,p,d){var m=Date.now(),y=0;l(f,p,function g(S){if(S&&(S.code==="EACCES"||S.code==="EPERM"||S.code==="EBUSY")&&Date.now()-m<6e4){setTimeout(function(){n.stat(p,function(b,v){b&&b.code==="ENOENT"?l(f,p,g):d(S)})},y),y<100&&(y+=10);return}d&&d(S)})}return Object.setPrototypeOf&&Object.setPrototypeOf(u,l),u}(n.rename)),n.read=typeof n.read!="function"?n.read:function(l){function u(f,p,d,m,y,g){var S;if(g&&typeof g=="function"){var b=0;S=function(v,O,$){if(v&&v.code==="EAGAIN"&&b<10)return b++,l.call(n,f,p,d,m,y,S);g.apply(this,arguments)}}return l.call(n,f,p,d,m,y,S)}return Object.setPrototypeOf&&Object.setPrototypeOf(u,l),u}(n.read),n.readSync=typeof n.readSync!="function"?n.readSync:function(l){return function(u,f,p,d,m){for(var y=0;;)try{return l.call(n,u,f,p,d,m)}catch(g){if(g.code==="EAGAIN"&&y<10){y++;continue}throw g}}}(n.readSync);function t(l){l.lchmod=function(u,f,p){l.open(u,Ft.O_WRONLY|Ft.O_SYMLINK,f,function(d,m){if(d){p&&p(d);return}l.fchmod(m,f,function(y){l.close(m,function(g){p&&p(y||g)})})})},l.lchmodSync=function(u,f){var p=l.openSync(u,Ft.O_WRONLY|Ft.O_SYMLINK,f),d=!0,m;try{m=l.fchmodSync(p,f),d=!1}finally{if(d)try{l.closeSync(p)}catch{}else l.closeSync(p)}return m}}function e(l){Ft.hasOwnProperty("O_SYMLINK")&&l.futimes?(l.lutimes=function(u,f,p,d){l.open(u,Ft.O_SYMLINK,function(m,y){if(m){d&&d(m);return}l.futimes(y,f,p,function(g){l.close(y,function(S){d&&d(g||S)})})})},l.lutimesSync=function(u,f,p){var d=l.openSync(u,Ft.O_SYMLINK),m,y=!0;try{m=l.futimesSync(d,f,p),y=!1}finally{if(y)try{l.closeSync(d)}catch{}else l.closeSync(d)}return m}):l.futimes&&(l.lutimes=function(u,f,p,d){d&&process.nextTick(d)},l.lutimesSync=function(){})}function i(l){return l&&function(u,f,p){return l.call(n,u,f,function(d){h(d)&&(d=null),p&&p.apply(this,arguments)})}}function s(l){return l&&function(u,f){try{return l.call(n,u,f)}catch(p){if(!h(p))throw p}}}function r(l){return l&&function(u,f,p,d){return l.call(n,u,f,p,function(m){h(m)&&(m=null),d&&d.apply(this,arguments)})}}function o(l){return l&&function(u,f,p){try{return l.call(n,u,f,p)}catch(d){if(!h(d))throw d}}}function a(l){return l&&function(u,f,p){typeof f=="function"&&(p=f,f=null);function d(m,y){y&&(y.uid<0&&(y.uid+=4294967296),y.gid<0&&(y.gid+=4294967296)),p&&p.apply(this,arguments)}return f?l.call(n,u,f,d):l.call(n,u,d)}}function c(l){return l&&function(u,f){var p=f?l.call(n,u,f):l.call(n,u);return p&&(p.uid<0&&(p.uid+=4294967296),p.gid<0&&(p.gid+=4294967296)),p}}function h(l){if(!l||l.code==="ENOSYS")return!0;var u=!process.getuid||process.getuid()!==0;return!!(u&&(l.code==="EINVAL"||l.code==="EPERM"))}}});var Cs=k((Ch,Os)=>{var xs=require("stream").Stream;Os.exports=Uo;function Uo(n){return{ReadStream:t,WriteStream:e};function t(i,s){if(!(this instanceof t))return new t(i,s);xs.call(this);var r=this;this.path=i,this.fd=null,this.readable=!0,this.paused=!1,this.flags="r",this.mode=438,this.bufferSize=64*1024,s=s||{};for(var o=Object.keys(s),a=0,c=o.length;a<c;a++){var h=o[a];this[h]=s[h]}if(this.encoding&&this.setEncoding(this.encoding),this.start!==void 0){if(typeof this.start!="number")throw TypeError("start must be a Number");if(this.end===void 0)this.end=1/0;else if(typeof this.end!="number")throw TypeError("end must be a Number");if(this.start>this.end)throw new Error("start must be <= end");this.pos=this.start}if(this.fd!==null){process.nextTick(function(){r._read()});return}n.open(this.path,this.flags,this.mode,function(l,u){if(l){r.emit("error",l),r.readable=!1;return}r.fd=u,r.emit("open",u),r._read()})}function e(i,s){if(!(this instanceof e))return new e(i,s);xs.call(this),this.path=i,this.fd=null,this.writable=!0,this.flags="w",this.encoding="binary",this.mode=438,this.bytesWritten=0,s=s||{};for(var r=Object.keys(s),o=0,a=r.length;o<a;o++){var c=r[o];this[c]=s[c]}if(this.start!==void 0){if(typeof this.start!="number")throw TypeError("start must be a Number");if(this.start<0)throw new Error("start must be >= zero");this.pos=this.start}this.busy=!1,this._queue=[],this.fd===null&&(this._open=n.open,this._queue.push([this._open,this.path,this.flags,this.mode,void 0]),this.flush())}}});var Ps=k((Ah,As)=>{"use strict";As.exports=Vo;var Go=Object.getPrototypeOf||function(n){return n.__proto__};function Vo(n){if(n===null||typeof n!="object")return n;if(n instanceof Object)var t={__proto__:Go(n)};else var t=Object.create(null);return Object.getOwnPropertyNames(n).forEach(function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(n,e))}),t}});var Gt=k((Ph,Di)=>{var F=require("fs"),Bo=_s(),Jo=Cs(),Yo=Ps(),Re=require("util"),H,Le;typeof Symbol=="function"&&typeof Symbol.for=="function"?(H=Symbol.for("graceful-fs.queue"),Le=Symbol.for("graceful-fs.previous")):(H="___graceful-fs.queue",Le="___graceful-fs.previous");function Ko(){}function $s(n,t){Object.defineProperty(n,H,{get:function(){return t}})}var Mt=Ko;Re.debuglog?Mt=Re.debuglog("gfs4"):/\bgfs4\b/i.test(process.env.NODE_DEBUG||"")&&(Mt=function(){var n=Re.format.apply(Re,arguments);n="GFS4: "+n.split(/\n/).join(`
GFS4: `),console.error(n)});F[H]||(Fs=global[H]||[],$s(F,Fs),F.close=function(n){function t(e,i){return n.call(F,e,function(s){s||Ts(),typeof i=="function"&&i.apply(this,arguments)})}return Object.defineProperty(t,Le,{value:n}),t}(F.close),F.closeSync=function(n){function t(e){n.apply(F,arguments),Ts()}return Object.defineProperty(t,Le,{value:n}),t}(F.closeSync),/\bgfs4\b/i.test(process.env.NODE_DEBUG||"")&&process.on("exit",function(){Mt(F[H]),require("assert").equal(F[H].length,0)}));var Fs;global[H]||$s(global,F[H]);Di.exports=Ti(Yo(F));process.env.TEST_GRACEFUL_FS_GLOBAL_PATCH&&!F.__patched&&(Di.exports=Ti(F),F.__patched=!0);function Ti(n){Bo(n),n.gracefulify=Ti,n.createReadStream=O,n.createWriteStream=$;var t=n.readFile;n.readFile=e;function e(w,E,_){return typeof E=="function"&&(_=E,E=null),q(w,E,_);function q(W,I,P,T){return t(W,I,function(C){C&&(C.code==="EMFILE"||C.code==="ENFILE")?Ut([q,[W,I,P],C,T||Date.now(),Date.now()]):typeof P=="function"&&P.apply(this,arguments)})}}var i=n.writeFile;n.writeFile=s;function s(w,E,_,q){return typeof _=="function"&&(q=_,_=null),W(w,E,_,q);function W(I,P,T,C,z){return i(I,P,T,function(A){A&&(A.code==="EMFILE"||A.code==="ENFILE")?Ut([W,[I,P,T,C],A,z||Date.now(),Date.now()]):typeof C=="function"&&C.apply(this,arguments)})}}var r=n.appendFile;r&&(n.appendFile=o);function o(w,E,_,q){return typeof _=="function"&&(q=_,_=null),W(w,E,_,q);function W(I,P,T,C,z){return r(I,P,T,function(A){A&&(A.code==="EMFILE"||A.code==="ENFILE")?Ut([W,[I,P,T,C],A,z||Date.now(),Date.now()]):typeof C=="function"&&C.apply(this,arguments)})}}var a=n.copyFile;a&&(n.copyFile=c);function c(w,E,_,q){return typeof _=="function"&&(q=_,_=0),W(w,E,_,q);function W(I,P,T,C,z){return a(I,P,T,function(A){A&&(A.code==="EMFILE"||A.code==="ENFILE")?Ut([W,[I,P,T,C],A,z||Date.now(),Date.now()]):typeof C=="function"&&C.apply(this,arguments)})}}var h=n.readdir;n.readdir=u;var l=/^v[0-5]\./;function u(w,E,_){typeof E=="function"&&(_=E,E=null);var q=l.test(process.version)?function(P,T,C,z){return h(P,W(P,T,C,z))}:function(P,T,C,z){return h(P,T,W(P,T,C,z))};return q(w,E,_);function W(I,P,T,C){return function(z,A){z&&(z.code==="EMFILE"||z.code==="ENFILE")?Ut([q,[I,P,T],z,C||Date.now(),Date.now()]):(A&&A.sort&&A.sort(),typeof T=="function"&&T.call(this,z,A))}}}if(process.version.substr(0,4)==="v0.8"){var f=Jo(n);g=f.ReadStream,b=f.WriteStream}var p=n.ReadStream;p&&(g.prototype=Object.create(p.prototype),g.prototype.open=S);var d=n.WriteStream;d&&(b.prototype=Object.create(d.prototype),b.prototype.open=v),Object.defineProperty(n,"ReadStream",{get:function(){return g},set:function(w){g=w},enumerable:!0,configurable:!0}),Object.defineProperty(n,"WriteStream",{get:function(){return b},set:function(w){b=w},enumerable:!0,conf