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