UNPKG

sunnyrain-cli

Version:

- sunnyrain-cli 是一个基于 Node.js 的命令行工具,用于管理和操作项目

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