UNPKG

lxferic-cli

Version:

lxferic-cli 脚手架工具

1 lines 233 kB
"use strict";var e=require("node:events"),t=require("node:child_process"),r=require("node:path"),n=require("node:fs"),s=require("node:process"),i=require("node:constants"),o=require("node:stream"),u=require("node:util"),a=require("node:assert"),c=require("node:buffer"),l=require("node:tty"),h=require("node:os"),f=require("node:crypto"),p=require("node:readline"),d=require("node:async_hooks");function m(e){var t=Object.create(null);return e&&Object.keys(e).forEach(function(r){if("default"!==r){var n=Object.getOwnPropertyDescriptor(e,r);Object.defineProperty(t,r,n.get?n:{enumerable:!0,get:function(){return e[r]}})}}),t.default=e,Object.freeze(t)}var D=m(p);function g(e,t,r,n){return new(r||(r=Promise))(function(s,i){function o(e){try{a(n.next(e))}catch(e){i(e)}}function u(e){try{a(n.throw(e))}catch(e){i(e)}}function a(e){var t;e.done?s(e.value):(t=e.value,t instanceof r?t:new r(function(e){e(t)})).then(o,u)}a((n=n.apply(e,t||[])).next())})}"function"==typeof SuppressedError&&SuppressedError;var y="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function b(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var w,C,v={exports:{}},_={},E={};function F(){if(w)return E;w=1;class e extends Error{constructor(e,t,r){super(r),Error.captureStackTrace(this,this.constructor),this.name=this.constructor.name,this.code=t,this.exitCode=e,this.nestedError=void 0}}return E.CommanderError=e,E.InvalidArgumentError=class extends e{constructor(e){super(1,"commander.invalidArgument",e),Error.captureStackTrace(this,this.constructor),this.name=this.constructor.name}},E}function k(){if(C)return _;C=1;const{InvalidArgumentError:e}=F();return _.Argument=class{constructor(e,t){switch(this.description=t||"",this.variadic=!1,this.parseArg=void 0,this.defaultValue=void 0,this.defaultValueDescription=void 0,this.argChoices=void 0,e[0]){case"<":this.required=!0,this._name=e.slice(1,-1);break;case"[":this.required=!1,this._name=e.slice(1,-1);break;default:this.required=!0,this._name=e}this._name.length>3&&"..."===this._name.slice(-3)&&(this.variadic=!0,this._name=this._name.slice(0,-3))}name(){return this._name}_concatValue(e,t){return t!==this.defaultValue&&Array.isArray(t)?t.concat(e):[e]}default(e,t){return this.defaultValue=e,this.defaultValueDescription=t,this}argParser(e){return this.parseArg=e,this}choices(t){return this.argChoices=t.slice(),this.parseArg=(t,r)=>{if(!this.argChoices.includes(t))throw new e(`Allowed choices are ${this.argChoices.join(", ")}.`);return this.variadic?this._concatValue(t,r):t},this}argRequired(){return this.required=!0,this}argOptional(){return this.required=!1,this}},_.humanReadableArgName=function(e){const t=e.name()+(!0===e.variadic?"...":"");return e.required?"<"+t+">":"["+t+"]"},_}var O,S={},x={};function A(){if(O)return x;O=1;const{humanReadableArgName:e}=k();return x.Help=class{constructor(){this.helpWidth=void 0,this.sortSubcommands=!1,this.sortOptions=!1,this.showGlobalOptions=!1}visibleCommands(e){const t=e.commands.filter(e=>!e._hidden);if(e._hasImplicitHelpCommand()){const[,r,n]=e._helpCommandnameAndArgs.match(/([^ ]+) *(.*)/),s=e.createCommand(r).helpOption(!1);s.description(e._helpCommandDescription),n&&s.arguments(n),t.push(s)}return this.sortSubcommands&&t.sort((e,t)=>e.name().localeCompare(t.name())),t}compareOptions(e,t){const r=e=>e.short?e.short.replace(/^-/,""):e.long.replace(/^--/,"");return r(e).localeCompare(r(t))}visibleOptions(e){const t=e.options.filter(e=>!e.hidden),r=e._hasHelpOption&&e._helpShortFlag&&!e._findOption(e._helpShortFlag),n=e._hasHelpOption&&!e._findOption(e._helpLongFlag);if(r||n){let s;s=r?n?e.createOption(e._helpFlags,e._helpDescription):e.createOption(e._helpShortFlag,e._helpDescription):e.createOption(e._helpLongFlag,e._helpDescription),t.push(s)}return this.sortOptions&&t.sort(this.compareOptions),t}visibleGlobalOptions(e){if(!this.showGlobalOptions)return[];const t=[];for(let r=e.parent;r;r=r.parent){const e=r.options.filter(e=>!e.hidden);t.push(...e)}return this.sortOptions&&t.sort(this.compareOptions),t}visibleArguments(e){return e._argsDescription&&e.registeredArguments.forEach(t=>{t.description=t.description||e._argsDescription[t.name()]||""}),e.registeredArguments.find(e=>e.description)?e.registeredArguments:[]}subcommandTerm(t){const r=t.registeredArguments.map(t=>e(t)).join(" ");return t._name+(t._aliases[0]?"|"+t._aliases[0]:"")+(t.options.length?" [options]":"")+(r?" "+r:"")}optionTerm(e){return e.flags}argumentTerm(e){return e.name()}longestSubcommandTermLength(e,t){return t.visibleCommands(e).reduce((e,r)=>Math.max(e,t.subcommandTerm(r).length),0)}longestOptionTermLength(e,t){return t.visibleOptions(e).reduce((e,r)=>Math.max(e,t.optionTerm(r).length),0)}longestGlobalOptionTermLength(e,t){return t.visibleGlobalOptions(e).reduce((e,r)=>Math.max(e,t.optionTerm(r).length),0)}longestArgumentTermLength(e,t){return t.visibleArguments(e).reduce((e,r)=>Math.max(e,t.argumentTerm(r).length),0)}commandUsage(e){let t=e._name;e._aliases[0]&&(t=t+"|"+e._aliases[0]);let r="";for(let t=e.parent;t;t=t.parent)r=t.name()+" "+r;return r+t+" "+e.usage()}commandDescription(e){return e.description()}subcommandDescription(e){return e.summary()||e.description()}optionDescription(e){const t=[];if(e.argChoices&&t.push(`choices: ${e.argChoices.map(e=>JSON.stringify(e)).join(", ")}`),void 0!==e.defaultValue){(e.required||e.optional||e.isBoolean()&&"boolean"==typeof e.defaultValue)&&t.push(`default: ${e.defaultValueDescription||JSON.stringify(e.defaultValue)}`)}return void 0!==e.presetArg&&e.optional&&t.push(`preset: ${JSON.stringify(e.presetArg)}`),void 0!==e.envVar&&t.push(`env: ${e.envVar}`),t.length>0?`${e.description} (${t.join(", ")})`:e.description}argumentDescription(e){const t=[];if(e.argChoices&&t.push(`choices: ${e.argChoices.map(e=>JSON.stringify(e)).join(", ")}`),void 0!==e.defaultValue&&t.push(`default: ${e.defaultValueDescription||JSON.stringify(e.defaultValue)}`),t.length>0){const r=`(${t.join(", ")})`;return e.description?`${e.description} ${r}`:r}return e.description}formatHelp(e,t){const r=t.padWidth(e,t),n=t.helpWidth||80;function s(e,s){if(s){const i=`${e.padEnd(r+2)}${s}`;return t.wrap(i,n-2,r+2)}return e}function i(e){return e.join("\n").replace(/^/gm," ".repeat(2))}let o=[`Usage: ${t.commandUsage(e)}`,""];const u=t.commandDescription(e);u.length>0&&(o=o.concat([t.wrap(u,n,0),""]));const a=t.visibleArguments(e).map(e=>s(t.argumentTerm(e),t.argumentDescription(e)));a.length>0&&(o=o.concat(["Arguments:",i(a),""]));const c=t.visibleOptions(e).map(e=>s(t.optionTerm(e),t.optionDescription(e)));if(c.length>0&&(o=o.concat(["Options:",i(c),""])),this.showGlobalOptions){const r=t.visibleGlobalOptions(e).map(e=>s(t.optionTerm(e),t.optionDescription(e)));r.length>0&&(o=o.concat(["Global Options:",i(r),""]))}const l=t.visibleCommands(e).map(e=>s(t.subcommandTerm(e),t.subcommandDescription(e)));return l.length>0&&(o=o.concat(["Commands:",i(l),""])),o.join("\n")}padWidth(e,t){return Math.max(t.longestOptionTermLength(e,t),t.longestGlobalOptionTermLength(e,t),t.longestSubcommandTermLength(e,t),t.longestArgumentTermLength(e,t))}wrap(e,t,r,n=40){const s=new RegExp("[\\n][ \\f\\t\\v   -    \ufeff]+");if(e.match(s))return e;const i=t-r;if(i<n)return e;const o=e.slice(0,r),u=e.slice(r).replace("\r\n","\n"),a=" ".repeat(r),c="\\s​",l=new RegExp(`\n|.{1,${i-1}}([${c}]|$)|[^${c}]+?([${c}]|$)`,"g");return o+(u.match(l)||[]).map((e,t)=>"\n"===e?"":(t>0?a:"")+e.trimEnd()).join("\n")}},x}var B,T={};function M(){if(B)return T;B=1;const{InvalidArgumentError:e}=F();function t(e){let t,r;const n=e.split(/[ |,]+/);return n.length>1&&!/^[[<]/.test(n[1])&&(t=n.shift()),r=n.shift(),!t&&/^-[^-]$/.test(r)&&(t=r,r=void 0),{shortFlag:t,longFlag:r}}return T.Option=class{constructor(e,r){this.flags=e,this.description=r||"",this.required=e.includes("<"),this.optional=e.includes("["),this.variadic=/\w\.\.\.[>\]]$/.test(e),this.mandatory=!1;const n=t(e);this.short=n.shortFlag,this.long=n.longFlag,this.negate=!1,this.long&&(this.negate=this.long.startsWith("--no-")),this.defaultValue=void 0,this.defaultValueDescription=void 0,this.presetArg=void 0,this.envVar=void 0,this.parseArg=void 0,this.hidden=!1,this.argChoices=void 0,this.conflictsWith=[],this.implied=void 0}default(e,t){return this.defaultValue=e,this.defaultValueDescription=t,this}preset(e){return this.presetArg=e,this}conflicts(e){return this.conflictsWith=this.conflictsWith.concat(e),this}implies(e){let t=e;return"string"==typeof e&&(t={[e]:!0}),this.implied=Object.assign(this.implied||{},t),this}env(e){return this.envVar=e,this}argParser(e){return this.parseArg=e,this}makeOptionMandatory(e=!0){return this.mandatory=!!e,this}hideHelp(e=!0){return this.hidden=!!e,this}_concatValue(e,t){return t!==this.defaultValue&&Array.isArray(t)?t.concat(e):[e]}choices(t){return this.argChoices=t.slice(),this.parseArg=(t,r)=>{if(!this.argChoices.includes(t))throw new e(`Allowed choices are ${this.argChoices.join(", ")}.`);return this.variadic?this._concatValue(t,r):t},this}name(){return this.long?this.long.replace(/^--/,""):this.short.replace(/^-/,"")}attributeName(){return this.name().replace(/^no-/,"").split("-").reduce((e,t)=>e+t[0].toUpperCase()+t.slice(1))}is(e){return this.short===e||this.long===e}isBoolean(){return!this.required&&!this.optional&&!this.negate}},T.splitOptionFlags=t,T.DualOptions=class{constructor(e){this.positiveOptions=new Map,this.negativeOptions=new Map,this.dualOptions=new Set,e.forEach(e=>{e.negate?this.negativeOptions.set(e.attributeName(),e):this.positiveOptions.set(e.attributeName(),e)}),this.negativeOptions.forEach((e,t)=>{this.positiveOptions.has(t)&&this.dualOptions.add(t)})}valueFromOption(e,t){const r=t.attributeName();if(!this.dualOptions.has(r))return!0;const n=this.negativeOptions.get(r).presetArg,s=void 0!==n&&n;return t.negate===(s===e)}},T}var R,P,$,L={};function j(){if(R)return L;R=1;return L.suggestSimilar=function(e,t){if(!t||0===t.length)return"";t=Array.from(new Set(t));const r=e.startsWith("--");r&&(e=e.slice(2),t=t.map(e=>e.slice(2)));let n=[],s=3;return t.forEach(t=>{if(t.length<=1)return;const r=function(e,t){if(Math.abs(e.length-t.length)>3)return Math.max(e.length,t.length);const r=[];for(let t=0;t<=e.length;t++)r[t]=[t];for(let e=0;e<=t.length;e++)r[0][e]=e;for(let n=1;n<=t.length;n++)for(let s=1;s<=e.length;s++){let i=1;i=e[s-1]===t[n-1]?0:1,r[s][n]=Math.min(r[s-1][n]+1,r[s][n-1]+1,r[s-1][n-1]+i),s>1&&n>1&&e[s-1]===t[n-2]&&e[s-2]===t[n-1]&&(r[s][n]=Math.min(r[s][n],r[s-2][n-2]+1))}return r[e.length][t.length]}(e,t),i=Math.max(e.length,t.length);(i-r)/i>.4&&(r<s?(s=r,n=[t]):r===s&&n.push(t))}),n.sort((e,t)=>e.localeCompare(t)),r&&(n=n.map(e=>`--${e}`)),n.length>1?`\n(Did you mean one of ${n.join(", ")}?)`:1===n.length?`\n(Did you mean ${n[0]}?)`:""},L}var I=($||($=1,function(i,o){const{Argument:u}=k(),{Command:a}=function(){if(P)return S;P=1;const i=e.EventEmitter,o=t,u=r,a=n,c=s,{Argument:l,humanReadableArgName:h}=k(),{CommanderError:f}=F(),{Help:p}=A(),{Option:d,splitOptionFlags:m,DualOptions:D}=M(),{suggestSimilar:g}=j();class y extends i{constructor(e){super(),this.commands=[],this.options=[],this.parent=null,this._allowUnknownOption=!1,this._allowExcessArguments=!0,this.registeredArguments=[],this._args=this.registeredArguments,this.args=[],this.rawArgs=[],this.processedArgs=[],this._scriptPath=null,this._name=e||"",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._outputConfiguration={writeOut:e=>c.stdout.write(e),writeErr:e=>c.stderr.write(e),getOutHelpWidth:()=>c.stdout.isTTY?c.stdout.columns:void 0,getErrHelpWidth:()=>c.stderr.isTTY?c.stderr.columns:void 0,outputError:(e,t)=>t(e)},this._hidden=!1,this._hasHelpOption=!0,this._helpFlags="-h, --help",this._helpDescription="display help for command",this._helpShortFlag="-h",this._helpLongFlag="--help",this._addImplicitHelpCommand=void 0,this._helpCommandName="help",this._helpCommandnameAndArgs="help [command]",this._helpCommandDescription="display help for command",this._helpConfiguration={}}copyInheritedSettings(e){return this._outputConfiguration=e._outputConfiguration,this._hasHelpOption=e._hasHelpOption,this._helpFlags=e._helpFlags,this._helpDescription=e._helpDescription,this._helpShortFlag=e._helpShortFlag,this._helpLongFlag=e._helpLongFlag,this._helpCommandName=e._helpCommandName,this._helpCommandnameAndArgs=e._helpCommandnameAndArgs,this._helpCommandDescription=e._helpCommandDescription,this._helpConfiguration=e._helpConfiguration,this._exitCallback=e._exitCallback,this._storeOptionsAsProperties=e._storeOptionsAsProperties,this._combineFlagAndOptionalValue=e._combineFlagAndOptionalValue,this._allowExcessArguments=e._allowExcessArguments,this._enablePositionalOptions=e._enablePositionalOptions,this._showHelpAfterError=e._showHelpAfterError,this._showSuggestionAfterError=e._showSuggestionAfterError,this}_getCommandAndAncestors(){const e=[];for(let t=this;t;t=t.parent)e.push(t);return e}command(e,t,r){let n=t,s=r;"object"==typeof n&&null!==n&&(s=n,n=null),s=s||{};const[,i,o]=e.match(/([^ ]+) *(.*)/),u=this.createCommand(i);return n&&(u.description(n),u._executableHandler=!0),s.isDefault&&(this._defaultCommandName=u._name),u._hidden=!(!s.noHelp&&!s.hidden),u._executableFile=s.executableFile||null,o&&u.arguments(o),this.commands.push(u),u.parent=this,u.copyInheritedSettings(this),n?this:u}createCommand(e){return new y(e)}createHelp(){return Object.assign(new p,this.configureHelp())}configureHelp(e){return void 0===e?this._helpConfiguration:(this._helpConfiguration=e,this)}configureOutput(e){return void 0===e?this._outputConfiguration:(Object.assign(this._outputConfiguration,e),this)}showHelpAfterError(e=!0){return"string"!=typeof e&&(e=!!e),this._showHelpAfterError=e,this}showSuggestionAfterError(e=!0){return this._showSuggestionAfterError=!!e,this}addCommand(e,t){if(!e._name)throw new Error("Command passed to .addCommand() must have a name\n- specify the name in Command constructor or using .name()");return(t=t||{}).isDefault&&(this._defaultCommandName=e._name),(t.noHelp||t.hidden)&&(e._hidden=!0),this.commands.push(e),e.parent=this,this}createArgument(e,t){return new l(e,t)}argument(e,t,r,n){const s=this.createArgument(e,t);return"function"==typeof r?s.default(n).argParser(r):s.default(r),this.addArgument(s),this}arguments(e){return e.trim().split(/ +/).forEach(e=>{this.argument(e)}),this}addArgument(e){const t=this.registeredArguments.slice(-1)[0];if(t&&t.variadic)throw new Error(`only the last argument can be variadic '${t.name()}'`);if(e.required&&void 0!==e.defaultValue&&void 0===e.parseArg)throw new Error(`a default value for a required argument is never used: '${e.name()}'`);return this.registeredArguments.push(e),this}addHelpCommand(e,t){return!1===e?this._addImplicitHelpCommand=!1:(this._addImplicitHelpCommand=!0,"string"==typeof e&&(this._helpCommandName=e.split(" ")[0],this._helpCommandnameAndArgs=e),this._helpCommandDescription=t||this._helpCommandDescription),this}_hasImplicitHelpCommand(){return void 0===this._addImplicitHelpCommand?this.commands.length&&!this._actionHandler&&!this._findCommand("help"):this._addImplicitHelpCommand}hook(e,t){const r=["preSubcommand","preAction","postAction"];if(!r.includes(e))throw new Error(`Unexpected value for event passed to hook : '${e}'.\nExpecting one of '${r.join("', '")}'`);return this._lifeCycleHooks[e]?this._lifeCycleHooks[e].push(t):this._lifeCycleHooks[e]=[t],this}exitOverride(e){return this._exitCallback=e||(e=>{if("commander.executeSubCommandAsync"!==e.code)throw e}),this}_exit(e,t,r){this._exitCallback&&this._exitCallback(new f(e,t,r)),c.exit(e)}action(e){return this._actionHandler=t=>{const r=this.registeredArguments.length,n=t.slice(0,r);return this._storeOptionsAsProperties?n[r]=this:n[r]=this.opts(),n.push(this),e.apply(this,n)},this}createOption(e,t){return new d(e,t)}_callParseArg(e,t,r,n){try{return e.parseArg(t,r)}catch(e){if("commander.invalidArgument"===e.code){const t=`${n} ${e.message}`;this.error(t,{exitCode:e.exitCode,code:e.code})}throw e}}addOption(e){const t=e.name(),r=e.attributeName();if(e.negate){const t=e.long.replace(/^--no-/,"--");this._findOption(t)||this.setOptionValueWithSource(r,void 0===e.defaultValue||e.defaultValue,"default")}else void 0!==e.defaultValue&&this.setOptionValueWithSource(r,e.defaultValue,"default");this.options.push(e);const n=(t,n,s)=>{null==t&&void 0!==e.presetArg&&(t=e.presetArg);const i=this.getOptionValue(r);null!==t&&e.parseArg?t=this._callParseArg(e,t,i,n):null!==t&&e.variadic&&(t=e._concatValue(t,i)),null==t&&(t=!e.negate&&(!(!e.isBoolean()&&!e.optional)||"")),this.setOptionValueWithSource(r,t,s)};return this.on("option:"+t,t=>{const r=`error: option '${e.flags}' argument '${t}' is invalid.`;n(t,r,"cli")}),e.envVar&&this.on("optionEnv:"+t,t=>{const r=`error: option '${e.flags}' value '${t}' from env '${e.envVar}' is invalid.`;n(t,r,"env")}),this}_optionEx(e,t,r,n,s){if("object"==typeof t&&t instanceof d)throw new Error("To add an Option object use addOption() instead of option() or requiredOption()");const i=this.createOption(t,r);if(i.makeOptionMandatory(!!e.mandatory),"function"==typeof n)i.default(s).argParser(n);else if(n instanceof RegExp){const e=n;n=(t,r)=>{const n=e.exec(t);return n?n[0]:r},i.default(s).argParser(n)}else i.default(n);return this.addOption(i)}option(e,t,r,n){return this._optionEx({},e,t,r,n)}requiredOption(e,t,r,n){return this._optionEx({mandatory:!0},e,t,r,n)}combineFlagAndOptionalValue(e=!0){return this._combineFlagAndOptionalValue=!!e,this}allowUnknownOption(e=!0){return this._allowUnknownOption=!!e,this}allowExcessArguments(e=!0){return this._allowExcessArguments=!!e,this}enablePositionalOptions(e=!0){return this._enablePositionalOptions=!!e,this}passThroughOptions(e=!0){if(this._passThroughOptions=!!e,this.parent&&e&&!this.parent._enablePositionalOptions)throw new Error("passThroughOptions can not be used without turning on enablePositionalOptions for parent command(s)");return this}storeOptionsAsProperties(e=!0){if(this.options.length)throw new Error("call .storeOptionsAsProperties() before adding options");return this._storeOptionsAsProperties=!!e,this}getOptionValue(e){return this._storeOptionsAsProperties?this[e]:this._optionValues[e]}setOptionValue(e,t){return this.setOptionValueWithSource(e,t,void 0)}setOptionValueWithSource(e,t,r){return this._storeOptionsAsProperties?this[e]=t:this._optionValues[e]=t,this._optionValueSources[e]=r,this}getOptionValueSource(e){return this._optionValueSources[e]}getOptionValueSourceWithGlobals(e){let t;return this._getCommandAndAncestors().forEach(r=>{void 0!==r.getOptionValueSource(e)&&(t=r.getOptionValueSource(e))}),t}_prepareUserArgs(e,t){if(void 0!==e&&!Array.isArray(e))throw new Error("first parameter to parse must be array or undefined");let r;switch(t=t||{},void 0===e&&(e=c.argv,c.versions&&c.versions.electron&&(t.from="electron")),this.rawArgs=e.slice(),t.from){case void 0:case"node":this._scriptPath=e[1],r=e.slice(2);break;case"electron":c.defaultApp?(this._scriptPath=e[1],r=e.slice(2)):r=e.slice(1);break;case"user":r=e.slice(0);break;default:throw new Error(`unexpected parse option { from: '${t.from}' }`)}return!this._name&&this._scriptPath&&this.nameFromFilename(this._scriptPath),this._name=this._name||"program",r}parse(e,t){const r=this._prepareUserArgs(e,t);return this._parseCommand([],r),this}async parseAsync(e,t){const r=this._prepareUserArgs(e,t);return await this._parseCommand([],r),this}_executeSubCommand(e,t){t=t.slice();let r=!1;const n=[".js",".ts",".tsx",".mjs",".cjs"];function s(e,t){const r=u.resolve(e,t);if(a.existsSync(r))return r;if(n.includes(u.extname(t)))return;const s=n.find(e=>a.existsSync(`${r}${e}`));return s?`${r}${s}`:void 0}this._checkForMissingMandatoryOptions(),this._checkForConflictingOptions();let i,l=e._executableFile||`${this._name}-${e._name}`,h=this._executableDir||"";if(this._scriptPath){let e;try{e=a.realpathSync(this._scriptPath)}catch(t){e=this._scriptPath}h=u.resolve(u.dirname(e),h)}if(h){let t=s(h,l);if(!t&&!e._executableFile&&this._scriptPath){const r=u.basename(this._scriptPath,u.extname(this._scriptPath));r!==this._name&&(t=s(h,`${r}-${e._name}`))}l=t||l}r=n.includes(u.extname(l)),"win32"!==c.platform?r?(t.unshift(l),t=w(c.execArgv).concat(t),i=o.spawn(c.argv[0],t,{stdio:"inherit"})):i=o.spawn(l,t,{stdio:"inherit"}):(t.unshift(l),t=w(c.execArgv).concat(t),i=o.spawn(c.execPath,t,{stdio:"inherit"})),i.killed||["SIGUSR1","SIGUSR2","SIGTERM","SIGINT","SIGHUP"].forEach(e=>{c.on(e,()=>{!1===i.killed&&null===i.exitCode&&i.kill(e)})});const p=this._exitCallback;p?i.on("close",()=>{p(new f(c.exitCode||0,"commander.executeSubCommandAsync","(close)"))}):i.on("close",c.exit.bind(c)),i.on("error",t=>{if("ENOENT"===t.code){const t=h?`searched for local subcommand relative to directory '${h}'`:"no directory for search for local subcommand, use .executableDir() to supply a custom directory",r=`'${l}' does not exist\n - if '${e._name}' is not meant to be an executable command, remove description parameter from '.command()' and use '.description()' instead\n - if the default executable name is not suitable, use the executableFile option to supply a custom name or path\n - ${t}`;throw new Error(r)}if("EACCES"===t.code)throw new Error(`'${l}' not executable`);if(p){const e=new f(1,"commander.executeSubCommandAsync","(error)");e.nestedError=t,p(e)}else c.exit(1)}),this.runningCommand=i}_dispatchSubcommand(e,t,r){const n=this._findCommand(e);let s;return n||this.help({error:!0}),s=this._chainOrCallSubCommandHook(s,n,"preSubcommand"),s=this._chainOrCall(s,()=>{if(!n._executableHandler)return n._parseCommand(t,r);this._executeSubCommand(n,t.concat(r))}),s}_dispatchHelpCommand(e){e||this.help();const t=this._findCommand(e);return t&&!t._executableHandler&&t.help(),this._dispatchSubcommand(e,[],[this._helpLongFlag||this._helpShortFlag])}_checkNumberOfArguments(){this.registeredArguments.forEach((e,t)=>{e.required&&null==this.args[t]&&this.missingArgument(e.name())}),this.registeredArguments.length>0&&this.registeredArguments[this.registeredArguments.length-1].variadic||this.args.length>this.registeredArguments.length&&this._excessArguments(this.args)}_processArguments(){const e=(e,t,r)=>{let n=t;if(null!==t&&e.parseArg){const s=`error: command-argument value '${t}' is invalid for argument '${e.name()}'.`;n=this._callParseArg(e,t,r,s)}return n};this._checkNumberOfArguments();const t=[];this.registeredArguments.forEach((r,n)=>{let s=r.defaultValue;r.variadic?n<this.args.length?(s=this.args.slice(n),r.parseArg&&(s=s.reduce((t,n)=>e(r,n,t),r.defaultValue))):void 0===s&&(s=[]):n<this.args.length&&(s=this.args[n],r.parseArg&&(s=e(r,s,r.defaultValue))),t[n]=s}),this.processedArgs=t}_chainOrCall(e,t){return e&&e.then&&"function"==typeof e.then?e.then(()=>t()):t()}_chainOrCallHooks(e,t){let r=e;const n=[];return this._getCommandAndAncestors().reverse().filter(e=>void 0!==e._lifeCycleHooks[t]).forEach(e=>{e._lifeCycleHooks[t].forEach(t=>{n.push({hookedCommand:e,callback:t})})}),"postAction"===t&&n.reverse(),n.forEach(e=>{r=this._chainOrCall(r,()=>e.callback(e.hookedCommand,this))}),r}_chainOrCallSubCommandHook(e,t,r){let n=e;return void 0!==this._lifeCycleHooks[r]&&this._lifeCycleHooks[r].forEach(e=>{n=this._chainOrCall(n,()=>e(this,t))}),n}_parseCommand(e,t){const r=this.parseOptions(t);if(this._parseOptionsEnv(),this._parseOptionsImplied(),e=e.concat(r.operands),t=r.unknown,this.args=e.concat(t),e&&this._findCommand(e[0]))return this._dispatchSubcommand(e[0],e.slice(1),t);if(this._hasImplicitHelpCommand()&&e[0]===this._helpCommandName)return this._dispatchHelpCommand(e[1]);if(this._defaultCommandName)return b(this,t),this._dispatchSubcommand(this._defaultCommandName,e,t);!this.commands.length||0!==this.args.length||this._actionHandler||this._defaultCommandName||this.help({error:!0}),b(this,r.unknown),this._checkForMissingMandatoryOptions(),this._checkForConflictingOptions();const n=()=>{r.unknown.length>0&&this.unknownOption(r.unknown[0])},s=`command:${this.name()}`;if(this._actionHandler){let r;return n(),this._processArguments(),r=this._chainOrCallHooks(r,"preAction"),r=this._chainOrCall(r,()=>this._actionHandler(this.processedArgs)),this.parent&&(r=this._chainOrCall(r,()=>{this.parent.emit(s,e,t)})),r=this._chainOrCallHooks(r,"postAction"),r}if(this.parent&&this.parent.listenerCount(s))n(),this._processArguments(),this.parent.emit(s,e,t);else if(e.length){if(this._findCommand("*"))return this._dispatchSubcommand("*",e,t);this.listenerCount("command:*")?this.emit("command:*",e,t):this.commands.length?this.unknownCommand():(n(),this._processArguments())}else this.commands.length?(n(),this.help({error:!0})):(n(),this._processArguments())}_findCommand(e){if(e)return this.commands.find(t=>t._name===e||t._aliases.includes(e))}_findOption(e){return this.options.find(t=>t.is(e))}_checkForMissingMandatoryOptions(){this._getCommandAndAncestors().forEach(e=>{e.options.forEach(t=>{t.mandatory&&void 0===e.getOptionValue(t.attributeName())&&e.missingMandatoryOptionValue(t)})})}_checkForConflictingLocalOptions(){const e=this.options.filter(e=>{const t=e.attributeName();return void 0!==this.getOptionValue(t)&&"default"!==this.getOptionValueSource(t)}),t=e.filter(e=>e.conflictsWith.length>0);t.forEach(t=>{const r=e.find(e=>t.conflictsWith.includes(e.attributeName()));r&&this._conflictingOption(t,r)})}_checkForConflictingOptions(){this._getCommandAndAncestors().forEach(e=>{e._checkForConflictingLocalOptions()})}parseOptions(e){const t=[],r=[];let n=t;const s=e.slice();function i(e){return e.length>1&&"-"===e[0]}let o=null;for(;s.length;){const e=s.shift();if("--"===e){n===r&&n.push(e),n.push(...s);break}if(!o||i(e)){if(o=null,i(e)){const t=this._findOption(e);if(t){if(t.required){const e=s.shift();void 0===e&&this.optionMissingArgument(t),this.emit(`option:${t.name()}`,e)}else if(t.optional){let e=null;s.length>0&&!i(s[0])&&(e=s.shift()),this.emit(`option:${t.name()}`,e)}else this.emit(`option:${t.name()}`);o=t.variadic?t:null;continue}}if(e.length>2&&"-"===e[0]&&"-"!==e[1]){const t=this._findOption(`-${e[1]}`);if(t){t.required||t.optional&&this._combineFlagAndOptionalValue?this.emit(`option:${t.name()}`,e.slice(2)):(this.emit(`option:${t.name()}`),s.unshift(`-${e.slice(2)}`));continue}}if(/^--[^=]+=/.test(e)){const t=e.indexOf("="),r=this._findOption(e.slice(0,t));if(r&&(r.required||r.optional)){this.emit(`option:${r.name()}`,e.slice(t+1));continue}}if(i(e)&&(n=r),(this._enablePositionalOptions||this._passThroughOptions)&&0===t.length&&0===r.length){if(this._findCommand(e)){t.push(e),s.length>0&&r.push(...s);break}if(e===this._helpCommandName&&this._hasImplicitHelpCommand()){t.push(e),s.length>0&&t.push(...s);break}if(this._defaultCommandName){r.push(e),s.length>0&&r.push(...s);break}}if(this._passThroughOptions){n.push(e),s.length>0&&n.push(...s);break}n.push(e)}else this.emit(`option:${o.name()}`,e)}return{operands:t,unknown:r}}opts(){if(this._storeOptionsAsProperties){const e={},t=this.options.length;for(let r=0;r<t;r++){const t=this.options[r].attributeName();e[t]=t===this._versionOptionName?this._version:this[t]}return e}return this._optionValues}optsWithGlobals(){return this._getCommandAndAncestors().reduce((e,t)=>Object.assign(e,t.opts()),{})}error(e,t){this._outputConfiguration.outputError(`${e}\n`,this._outputConfiguration.writeErr),"string"==typeof this._showHelpAfterError?this._outputConfiguration.writeErr(`${this._showHelpAfterError}\n`):this._showHelpAfterError&&(this._outputConfiguration.writeErr("\n"),this.outputHelp({error:!0}));const r=t||{},n=r.exitCode||1,s=r.code||"commander.error";this._exit(n,s,e)}_parseOptionsEnv(){this.options.forEach(e=>{if(e.envVar&&e.envVar in c.env){const t=e.attributeName();(void 0===this.getOptionValue(t)||["default","config","env"].includes(this.getOptionValueSource(t)))&&(e.required||e.optional?this.emit(`optionEnv:${e.name()}`,c.env[e.envVar]):this.emit(`optionEnv:${e.name()}`))}})}_parseOptionsImplied(){const e=new D(this.options),t=e=>void 0!==this.getOptionValue(e)&&!["default","implied"].includes(this.getOptionValueSource(e));this.options.filter(r=>void 0!==r.implied&&t(r.attributeName())&&e.valueFromOption(this.getOptionValue(r.attributeName()),r)).forEach(e=>{Object.keys(e.implied).filter(e=>!t(e)).forEach(t=>{this.setOptionValueWithSource(t,e.implied[t],"implied")})})}missingArgument(e){const t=`error: missing required argument '${e}'`;this.error(t,{code:"commander.missingArgument"})}optionMissingArgument(e){const t=`error: option '${e.flags}' argument missing`;this.error(t,{code:"commander.optionMissingArgument"})}missingMandatoryOptionValue(e){const t=`error: required option '${e.flags}' not specified`;this.error(t,{code:"commander.missingMandatoryOptionValue"})}_conflictingOption(e,t){const r=e=>{const t=e.attributeName(),r=this.getOptionValue(t),n=this.options.find(e=>e.negate&&t===e.attributeName()),s=this.options.find(e=>!e.negate&&t===e.attributeName());return n&&(void 0===n.presetArg&&!1===r||void 0!==n.presetArg&&r===n.presetArg)?n:s||e},n=e=>{const t=r(e),n=t.attributeName();return"env"===this.getOptionValueSource(n)?`environment variable '${t.envVar}'`:`option '${t.flags}'`},s=`error: ${n(e)} cannot be used with ${n(t)}`;this.error(s,{code:"commander.conflictingOption"})}unknownOption(e){if(this._allowUnknownOption)return;let t="";if(e.startsWith("--")&&this._showSuggestionAfterError){let r=[],n=this;do{const e=n.createHelp().visibleOptions(n).filter(e=>e.long).map(e=>e.long);r=r.concat(e),n=n.parent}while(n&&!n._enablePositionalOptions);t=g(e,r)}const r=`error: unknown option '${e}'${t}`;this.error(r,{code:"commander.unknownOption"})}_excessArguments(e){if(this._allowExcessArguments)return;const t=this.registeredArguments.length,r=1===t?"":"s",n=`error: too many arguments${this.parent?` for '${this.name()}'`:""}. Expected ${t} argument${r} but got ${e.length}.`;this.error(n,{code:"commander.excessArguments"})}unknownCommand(){const e=this.args[0];let t="";if(this._showSuggestionAfterError){const r=[];this.createHelp().visibleCommands(this).forEach(e=>{r.push(e.name()),e.alias()&&r.push(e.alias())}),t=g(e,r)}const r=`error: unknown command '${e}'${t}`;this.error(r,{code:"commander.unknownCommand"})}version(e,t,r){if(void 0===e)return this._version;this._version=e,t=t||"-V, --version",r=r||"output the version number";const n=this.createOption(t,r);return this._versionOptionName=n.attributeName(),this.options.push(n),this.on("option:"+n.name(),()=>{this._outputConfiguration.writeOut(`${e}\n`),this._exit(0,"commander.version",e)}),this}description(e,t){return void 0===e&&void 0===t?this._description:(this._description=e,t&&(this._argsDescription=t),this)}summary(e){return void 0===e?this._summary:(this._summary=e,this)}alias(e){if(void 0===e)return this._aliases[0];let t=this;if(0!==this.commands.length&&this.commands[this.commands.length-1]._executableHandler&&(t=this.commands[this.commands.length-1]),e===t._name)throw new Error("Command alias can't be the same as its name");return t._aliases.push(e),this}aliases(e){return void 0===e?this._aliases:(e.forEach(e=>this.alias(e)),this)}usage(e){if(void 0===e){if(this._usage)return this._usage;const e=this.registeredArguments.map(e=>h(e));return[].concat(this.options.length||this._hasHelpOption?"[options]":[],this.commands.length?"[command]":[],this.registeredArguments.length?e:[]).join(" ")}return this._usage=e,this}name(e){return void 0===e?this._name:(this._name=e,this)}nameFromFilename(e){return this._name=u.basename(e,u.extname(e)),this}executableDir(e){return void 0===e?this._executableDir:(this._executableDir=e,this)}helpInformation(e){const t=this.createHelp();return void 0===t.helpWidth&&(t.helpWidth=e&&e.error?this._outputConfiguration.getErrHelpWidth():this._outputConfiguration.getOutHelpWidth()),t.formatHelp(this,t)}_getHelpContext(e){const t={error:!!(e=e||{}).error};let r;return r=t.error?e=>this._outputConfiguration.writeErr(e):e=>this._outputConfiguration.writeOut(e),t.write=e.write||r,t.command=this,t}outputHelp(e){let t;"function"==typeof e&&(t=e,e=void 0);const r=this._getHelpContext(e);this._getCommandAndAncestors().reverse().forEach(e=>e.emit("beforeAllHelp",r)),this.emit("beforeHelp",r);let n=this.helpInformation(r);if(t&&(n=t(n),"string"!=typeof n&&!Buffer.isBuffer(n)))throw new Error("outputHelp callback must return a string or a Buffer");r.write(n),this._helpLongFlag&&this.emit(this._helpLongFlag),this.emit("afterHelp",r),this._getCommandAndAncestors().forEach(e=>e.emit("afterAllHelp",r))}helpOption(e,t){if("boolean"==typeof e)return this._hasHelpOption=e,this;this._helpFlags=e||this._helpFlags,this._helpDescription=t||this._helpDescription;const r=m(this._helpFlags);return this._helpShortFlag=r.shortFlag,this._helpLongFlag=r.longFlag,this}help(e){this.outputHelp(e);let t=c.exitCode||0;0===t&&e&&"function"!=typeof e&&e.error&&(t=1),this._exit(t,"commander.help","(outputHelp)")}addHelpText(e,t){const r=["beforeAll","before","after","afterAll"];if(!r.includes(e))throw new Error(`Unexpected value for position to addHelpText.\nExpecting one of '${r.join("', '")}'`);const n=`${e}Help`;return this.on(n,e=>{let r;r="function"==typeof t?t({error:e.error,command:e.command}):t,r&&e.write(`${r}\n`)}),this}}function b(e,t){e._hasHelpOption&&t.find(t=>t===e._helpLongFlag||t===e._helpShortFlag)&&(e.outputHelp(),e._exit(0,"commander.helpDisplayed","(outputHelp)"))}function w(e){return e.map(e=>{if(!e.startsWith("--inspect"))return e;let t,r,n="127.0.0.1",s="9229";return null!==(r=e.match(/^(--inspect(-brk)?)$/))?t=r[1]:null!==(r=e.match(/^(--inspect(-brk|-port)?)=([^:]+)$/))?(t=r[1],/^\d+$/.test(r[3])?s=r[3]:n=r[3]):null!==(r=e.match(/^(--inspect(-brk|-port)?)=([^:]+):(\d+)$/))&&(t=r[1],n=r[3],s=r[4]),t&&"0"!==s?`${t}=${n}:${parseInt(s)+1}`:e})}return S.Command=y,S}(),{CommanderError:c,InvalidArgumentError:l}=F(),{Help:h}=A(),{Option:f}=M();(o=i.exports=new a).program=o,o.Command=a,o.Option=f,o.Argument=u,o.Help=h,o.CommanderError=c,o.InvalidArgumentError=l,o.InvalidOptionArgumentError=l}(v,v.exports)),v.exports),N=b(I);const{program:U,createCommand:G,createArgument:V,createOption:H,CommanderError:q,InvalidArgumentError:W,InvalidOptionArgumentError:z,Command:Y,Argument:J,Option:K,Help:Q}=N;var Z,X,ee,te,re,ne,se,ie,oe,ue,ae={},ce={};function le(){return Z||(Z=1,ce.fromCallback=function(e){return Object.defineProperty(function(...t){if("function"!=typeof t[t.length-1])return new Promise((r,n)=>{t.push((e,t)=>null!=e?n(e):r(t)),e.apply(this,t)});e.apply(this,t)},"name",{value:e.name})},ce.fromPromise=function(e){return Object.defineProperty(function(...t){const r=t[t.length-1];if("function"!=typeof r)return e.apply(this,t);t.pop(),e.apply(this,t).then(e=>r(null,e),r)},"name",{value:e.name})}),ce}function he(){if(ee)return X;ee=1;var e=i,t=process.cwd,r=null,n=process.env.GRACEFUL_FS_PLATFORM||process.platform;process.cwd=function(){return r||(r=t.call(process)),r};try{process.cwd()}catch(e){}if("function"==typeof process.chdir){var s=process.chdir;process.chdir=function(e){r=null,s.call(process,e)},Object.setPrototypeOf&&Object.setPrototypeOf(process.chdir,s)}return X=function(t){e.hasOwnProperty("O_SYMLINK")&&process.version.match(/^v0\.6\.[0-2]|^v0\.5\./)&&function(t){t.lchmod=function(r,n,s){t.open(r,e.O_WRONLY|e.O_SYMLINK,n,function(e,r){e?s&&s(e):t.fchmod(r,n,function(e){t.close(r,function(t){s&&s(e||t)})})})},t.lchmodSync=function(r,n){var s,i=t.openSync(r,e.O_WRONLY|e.O_SYMLINK,n),o=!0;try{s=t.fchmodSync(i,n),o=!1}finally{if(o)try{t.closeSync(i)}catch(e){}else t.closeSync(i)}return s}}(t);t.lutimes||function(t){e.hasOwnProperty("O_SYMLINK")&&t.futimes?(t.lutimes=function(r,n,s,i){t.open(r,e.O_SYMLINK,function(e,r){e?i&&i(e):t.futimes(r,n,s,function(e){t.close(r,function(t){i&&i(e||t)})})})},t.lutimesSync=function(r,n,s){var i,o=t.openSync(r,e.O_SYMLINK),u=!0;try{i=t.futimesSync(o,n,s),u=!1}finally{if(u)try{t.closeSync(o)}catch(e){}else t.closeSync(o)}return i}):t.futimes&&(t.lutimes=function(e,t,r,n){n&&process.nextTick(n)},t.lutimesSync=function(){})}(t);t.chown=i(t.chown),t.fchown=i(t.fchown),t.lchown=i(t.lchown),t.chmod=r(t.chmod),t.fchmod=r(t.fchmod),t.lchmod=r(t.lchmod),t.chownSync=o(t.chownSync),t.fchownSync=o(t.fchownSync),t.lchownSync=o(t.lchownSync),t.chmodSync=s(t.chmodSync),t.fchmodSync=s(t.fchmodSync),t.lchmodSync=s(t.lchmodSync),t.stat=u(t.stat),t.fstat=u(t.fstat),t.lstat=u(t.lstat),t.statSync=a(t.statSync),t.fstatSync=a(t.fstatSync),t.lstatSync=a(t.lstatSync),t.chmod&&!t.lchmod&&(t.lchmod=function(e,t,r){r&&process.nextTick(r)},t.lchmodSync=function(){});t.chown&&!t.lchown&&(t.lchown=function(e,t,r,n){n&&process.nextTick(n)},t.lchownSync=function(){});"win32"===n&&(t.rename="function"!=typeof t.rename?t.rename:function(e){function r(r,n,s){var i=Date.now(),o=0;e(r,n,function u(a){if(a&&("EACCES"===a.code||"EPERM"===a.code||"EBUSY"===a.code)&&Date.now()-i<6e4)return setTimeout(function(){t.stat(n,function(t,i){t&&"ENOENT"===t.code?e(r,n,u):s(a)})},o),void(o<100&&(o+=10));s&&s(a)})}return Object.setPrototypeOf&&Object.setPrototypeOf(r,e),r}(t.rename));function r(e){return e?function(r,n,s){return e.call(t,r,n,function(e){c(e)&&(e=null),s&&s.apply(this,arguments)})}:e}function s(e){return e?function(r,n){try{return e.call(t,r,n)}catch(e){if(!c(e))throw e}}:e}function i(e){return e?function(r,n,s,i){return e.call(t,r,n,s,function(e){c(e)&&(e=null),i&&i.apply(this,arguments)})}:e}function o(e){return e?function(r,n,s){try{return e.call(t,r,n,s)}catch(e){if(!c(e))throw e}}:e}function u(e){return e?function(r,n,s){function i(e,t){t&&(t.uid<0&&(t.uid+=4294967296),t.gid<0&&(t.gid+=4294967296)),s&&s.apply(this,arguments)}return"function"==typeof n&&(s=n,n=null),n?e.call(t,r,n,i):e.call(t,r,i)}:e}function a(e){return e?function(r,n){var s=n?e.call(t,r,n):e.call(t,r);return s&&(s.uid<0&&(s.uid+=4294967296),s.gid<0&&(s.gid+=4294967296)),s}:e}function c(e){return!e||("ENOSYS"===e.code||!(process.getuid&&0===process.getuid()||"EINVAL"!==e.code&&"EPERM"!==e.code))}t.read="function"!=typeof t.read?t.read:function(e){function r(r,n,s,i,o,u){var a;if(u&&"function"==typeof u){var c=0;a=function(l,h,f){if(l&&"EAGAIN"===l.code&&c<10)return c++,e.call(t,r,n,s,i,o,a);u.apply(this,arguments)}}return e.call(t,r,n,s,i,o,a)}return Object.setPrototypeOf&&Object.setPrototypeOf(r,e),r}(t.read),t.readSync="function"!=typeof t.readSync?t.readSync:(l=t.readSync,function(e,r,n,s,i){for(var o=0;;)try{return l.call(t,e,r,n,s,i)}catch(e){if("EAGAIN"===e.code&&o<10){o++;continue}throw e}});var l},X}function fe(){if(oe)return ie;oe=1;var e,t,r=n,s=he(),i=function(){if(re)return te;re=1;var e=o.Stream;return te=function(t){return{ReadStream:function r(n,s){if(!(this instanceof r))return new r(n,s);e.call(this);var i=this;this.path=n,this.fd=null,this.readable=!0,this.paused=!1,this.flags="r",this.mode=438,this.bufferSize=65536,s=s||{};for(var o=Object.keys(s),u=0,a=o.length;u<a;u++){var c=o[u];this[c]=s[c]}if(this.encoding&&this.setEncoding(this.encoding),void 0!==this.start){if("number"!=typeof this.start)throw TypeError("start must be a Number");if(void 0===this.end)this.end=1/0;else if("number"!=typeof this.end)throw TypeError("end must be a Number");if(this.start>this.end)throw new Error("start must be <= end");this.pos=this.start}null===this.fd?t.open(this.path,this.flags,this.mode,function(e,t){if(e)return i.emit("error",e),void(i.readable=!1);i.fd=t,i.emit("open",t),i._read()}):process.nextTick(function(){i._read()})},WriteStream:function r(n,s){if(!(this instanceof r))return new r(n,s);e.call(this),this.path=n,this.fd=null,this.writable=!0,this.flags="w",this.encoding="binary",this.mode=438,this.bytesWritten=0,s=s||{};for(var i=Object.keys(s),o=0,u=i.length;o<u;o++){var a=i[o];this[a]=s[a]}if(void 0!==this.start){if("number"!=typeof this.start)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=[],null===this.fd&&(this._open=t.open,this._queue.push([this._open,this.path,this.flags,this.mode,void 0]),this.flush())}}},te}(),c=function(){if(se)return ne;se=1,ne=function(t){if(null===t||"object"!=typeof t)return t;if(t instanceof Object)var r={__proto__:e(t)};else r=Object.create(null);return Object.getOwnPropertyNames(t).forEach(function(e){Object.defineProperty(r,e,Object.getOwnPropertyDescriptor(t,e))}),r};var e=Object.getPrototypeOf||function(e){return e.__proto__};return ne}(),l=u;function h(t,r){Object.defineProperty(t,e,{get:function(){return r}})}"function"==typeof Symbol&&"function"==typeof Symbol.for?(e=Symbol.for("graceful-fs.queue"),t=Symbol.for("graceful-fs.previous")):(e="___graceful-fs.queue",t="___graceful-fs.previous");var f,p=function(){};if(l.debuglog?p=l.debuglog("gfs4"):/\bgfs4\b/i.test(process.env.NODE_DEBUG||"")&&(p=function(){var e=l.format.apply(l,arguments);e="GFS4: "+e.split(/\n/).join("\nGFS4: "),console.error(e)}),!r[e]){var d=y[e]||[];h(r,d),r.close=function(e){function n(t,n){return e.call(r,t,function(e){e||g(),"function"==typeof n&&n.apply(this,arguments)})}return Object.defineProperty(n,t,{value:e}),n}(r.close),r.closeSync=function(e){function n(t){e.apply(r,arguments),g()}return Object.defineProperty(n,t,{value:e}),n}(r.closeSync),/\bgfs4\b/i.test(process.env.NODE_DEBUG||"")&&process.on("exit",function(){p(r[e]),a.equal(r[e].length,0)})}function m(e){s(e),e.gracefulify=m,e.createReadStream=function(t,r){return new e.ReadStream(t,r)},e.createWriteStream=function(t,r){return new e.WriteStream(t,r)};var t=e.readFile;e.readFile=function(e,r,n){"function"==typeof r&&(n=r,r=null);return function e(r,n,s,i){return t(r,n,function(t){!t||"EMFILE"!==t.code&&"ENFILE"!==t.code?"function"==typeof s&&s.apply(this,arguments):D([e,[r,n,s],t,i||Date.now(),Date.now()])})}(e,r,n)};var r=e.writeFile;e.writeFile=function(e,t,n,s){"function"==typeof n&&(s=n,n=null);return function e(t,n,s,i,o){return r(t,n,s,function(r){!r||"EMFILE"!==r.code&&"ENFILE"!==r.code?"function"==typeof i&&i.apply(this,arguments):D([e,[t,n,s,i],r,o||Date.now(),Date.now()])})}(e,t,n,s)};var n=e.appendFile;n&&(e.appendFile=function(e,t,r,s){"function"==typeof r&&(s=r,r=null);return function e(t,r,s,i,o){return n(t,r,s,function(n){!n||"EMFILE"!==n.code&&"ENFILE"!==n.code?"function"==typeof i&&i.apply(this,arguments):D([e,[t,r,s,i],n,o||Date.now(),Date.now()])})}(e,t,r,s)});var o=e.copyFile;o&&(e.copyFile=function(e,t,r,n){"function"==typeof r&&(n=r,r=0);return function e(t,r,n,s,i){return o(t,r,n,function(o){!o||"EMFILE"!==o.code&&"ENFILE"!==o.code?"function"==typeof s&&s.apply(this,arguments):D([e,[t,r,n,s],o,i||Date.now(),Date.now()])})}(e,t,r,n)});var u=e.readdir;e.readdir=function(e,t,r){"function"==typeof t&&(r=t,t=null);var n=a.test(process.version)?function(e,t,r,n){return u(e,s(e,t,r,n))}:function(e,t,r,n){return u(e,t,s(e,t,r,n))};return n(e,t,r);function s(e,t,r,s){return function(i,o){!i||"EMFILE"!==i.code&&"ENFILE"!==i.code?(o&&o.sort&&o.sort(),"function"==typeof r&&r.call(this,i,o)):D([n,[e,t,r],i,s||Date.now(),Date.now()])}}};var a=/^v[0-5]\./;if("v0.8"===process.version.substr(0,4)){var c=i(e);d=c.ReadStream,g=c.WriteStream}var l=e.ReadStream;l&&(d.prototype=Object.create(l.prototype),d.prototype.open=function(){var e=this;b(e.path,e.flags,e.mode,function(t,r){t?(e.autoClose&&e.destroy(),e.emit("error",t)):(e.fd=r,e.emit("open",r),e.read())})});var h=e.WriteStream;h&&(g.prototype=Object.create(h.prototype),g.prototype.open=function(){var e=this;b(e.path,e.flags,e.mode,function(t,r){t?(e.destroy(),e.emit("error",t)):(e.fd=r,e.emit("open",r))})}),Object.defineProperty(e,"ReadStream",{get:function(){return d},set:function(e){d=e},enumerable:!0,configurable:!0}),Object.defineProperty(e,"WriteStream",{get:function(){return g},set:function(e){g=e},enumerable:!0,configurable:!0});var f=d;Object.defineProperty(e,"FileReadStream",{get:function(){return f},set:function(e){f=e},enumerable:!0,configurable:!0});var p=g;function d(e,t){return this instanceof d?(l.apply(this,arguments),this):d.apply(Object.create(d.prototype),arguments)}function g(e,t){return this instanceof g?(h.apply(this,arguments),this):g.apply(Object.create(g.prototype),arguments)}Object.defineProperty(e,"FileWriteStream",{get:function(){return p},set:function(e){p=e},enumerable:!0,configurable:!0});var y=e.open;function b(e,t,r,n){return"function"==typeof r&&(n=r,r=null),function e(t,r,n,s,i){return y(t,r,n,function(o,u){!o||"EMFILE"!==o.code&&"ENFILE"!==o.code?"function"==typeof s&&s.apply(this,arguments):D([e,[t,r,n,s],o,i||Date.now(),Date.now()])})}(e,t,r,n)}return e.open=b,e}function D(t){p("ENQUEUE",t[0].name,t[1]),r[e].push(t),b()}function g(){for(var t=Date.now(),n=0;n<r[e].length;++n)r[e][n].length>2&&(r[e][n][3]=t,r[e][n][4]=t);b()}function b(){if(clearTimeout(f),f=void 0,0!==r[e].length){var t=r[e].shift(),n=t[0],s=t[1],i=t[2],o=t[3],u=t[4];if(void 0===o)p("RETRY",n.name,s),n.apply(null,s);else if(Date.now()-o>=6e4){p("TIMEOUT",n.name,s);var a=s.pop();"function"==typeof a&&a.call(null,i)}else{var c=Date.now()-u,l=Math.max(u-o,1);c>=Math.min(1.2*l,100)?(p("RETRY",n.name,s),n.apply(null,s.concat([o]))):r[e].push(t)}void 0===f&&(f=setTimeout(b,0))}}return y[e]||h(y,r[e]),ie=m(c(r)),process.env.TEST_GRACEFUL_FS_GLOBAL_PATCH&&!r.__patched&&(ie=m(r),r.__patched=!0),ie}function pe(){return ue||(ue=1,function(e){const t=le().fromCallback,r=fe(),n=["access","appendFile","chmod","chown","close","copyFile","cp","fchmod","fchown","fdatasync","fstat","fsync","ftruncate","futimes","glob","lchmod","lchown","lutimes","link","lstat","mkdir","mkdtemp","open","opendir","readdir","readFile","readlink","realpath","rename","rm","rmdir","stat","statfs","symlink","truncate","unlink","utimes","writeFile"].filter(e=>"function"==typeof r[e]);Object.assign(e,r),n.forEach(n=>{e[n]=t(r[n])}),e.exists=function(e,t){return"function"==typeof t?r.exists(e,t):new Promise(t=>r.exists(e,t))},e.read=function(e,t,n,s,i,o){return"function"==typeof o?r.read(e,t,n,s,i,o):new Promise((o,u)=>{r.read(e,t,n,s,i,(e,t,r)=>{if(e)return u(e);o({bytesRead:t,buffer:r})})})},e.write=function(e,t,...n){return"function"==typeof n[n.length-1]?r.write(e,t,...n):new Promise((s,i)=>{r.write(e,t,...n,(e,t,r)=>{if(e)return i(e);s({bytesWritten:t,buffer:r})})})},e.readv=function(e,t,...n){return"function"==typeof n[n.length-1]?r.readv(e,t,...n):new Promise((s,i)=>{r.readv(e,t,...n,(e,t,r)=>{if(e)return i(e);s({bytesRead:t,buffers:r})})})},e.writev=function(e,t,...n){return"function"==typeof n[n.length-1]?r.writev(e,t,...n):new Promise((s,i)=>{r.writev(e,t,...n,(e,t,r)=>{if(e)return i(e);s({bytesWritten:t,buffers:r})})})},"function"==typeof r.realpath.native?e.realpath.native=t(r.realpath.native):process.emitWarning("fs.realpath.native is not a function. Is fs being monkey-patched?","Warning","fs-extra-WARN0003")}(ae)),ae}var de,me,De,ge,ye,be,we,Ce,ve,_e,Ee,Fe,ke,Oe,Se,xe,Ae,Be,Te,Me,Re,Pe,$e,Le,je,Ie,Ne,Ue,Ge,Ve,He,qe,We,ze,Ye,Je,Ke,Qe,Ze,Xe,et,tt,rt,nt,st,it,ot,ut,at,ct,lt,ht,ft,pt,dt={},mt={};function Dt(){if(de)return mt;de=1;const e=r;return mt.checkPath=function(t){if("win32"===process.platform){if(/[<>:"|?*]/.test(t.replace(e.parse(t).root,""))){const e=new Error(`Path contains invalid characters: ${t}`);throw e.code="EINVAL",e}}},mt}function gt(){if(me)return dt;me=1;const e=pe(),{checkPath:t}=Dt(),r=e=>"number"==typeof e?e:{mode:511,...e}.mode;return dt.makeDir=async(n,s)=>(t(n),e.mkdir(n,{mode:r(s),recursive:!0})),dt.makeDirSync=(n,s)=>(t(n),e.mkdirSync(n,{mode:r(s),recursive:!0})),dt}function yt(){if(ge)return De;ge=1;const e=le().fromPromise,{makeDir:t,makeDirSync:r}=gt(),n=e(t);return De={mkdirs:n,mkdirsSync:r,mkdirp:n,mkdirpSync:r,ensureDir:n,ensureDirSync:r}}function bt(){if(be)return ye;be=1;const e=le().fromPromise,t=pe();return ye={pathExists:e(function(e){return t.access(e).then(()=>!0).catch(()=>!1)}),pathExistsSync:t.existsSync}}function wt(){if(Ce)return we;Ce=1;const e=pe(),t=le().fromPromise;return we={utimesMillis:t(async function(t,r,n){const s=await e.open(t,"r+");let i=null;try{await e.futimes(s,r,n)}finally{try{await e.close(s)}catch(e){i=e}}if(i)throw i}),utimesMillisSync:function(t,r,n){const s=e.openSync(t,"r+");return e.futimesSync(s,r,n),e.closeSync(s)}}}function Ct(){if(_e)return ve;_e=1;const e=pe(),t=r,n=le().fromPromise;function s(e,t){return void 0!==t.ino&&void 0!==t.dev&&t.ino===e.ino&&t.dev===e.dev}function i(e,r){const n=t.resolve(e).split(t.sep).filter(e=>e),s=t.resolve(r).split(t.sep).filter(e=>e);return n.every((e,t)=>s[t]===e)}function o(e,t,r){return`Cannot ${r} '${e}' to a subdirectory of itself, '${t}'.`}return ve={checkPaths:n(async function(r,n,u,a){const{srcStat:c,destStat:l}=await function(t,r,n){const s=n.dereference?t=>e.stat(t,{bigint:!0}):t=>e.lstat(t,{bigint:!0});return Promise.all([s(t),s(r).catch(e=>{if("ENOENT"===e.code)return null;throw e})]).then(([e,t])=>({srcStat:e,destStat:t}))}(r,n,a);if(l){if(s(c,l)){const e=t.basename(r),s=t.basename(n);if("move"===u&&e!==s&&e.toLowerCase()===s.toLowerCase())return{srcStat:c,destStat:l,isChangingCase:!0};throw new Error("Source and destination must not be the same.")}if(c.isDirectory()&&!l.isDirectory())throw new Error(`Cannot overwrite non-directory '${n}' with directory '${r}'.`);if(!c.isDirectory()&&l.isDirectory())throw new Error(`Cannot overwrite directory '${n}' with non-directory '${r}'.`)}if(c.isDirectory()&&i(r,n))throw new Error(o(r,n,u));return{srcStat:c,destStat:l}}),checkPaths