create-wsh-cli
Version:
wsh-通用模板
1 lines • 311 kB
JavaScript
"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"),u=require("node:util"),a=require("node:assert"),c=require("node:os"),l=require("node:tty"),f=require("node:crypto"),h=require("node:readline"),p=require("node:async_hooks");function d(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 m=d(h);function g(t,e,n,r){return new(n||(n=Promise))((function(i,o){function s(t){try{a(r.next(t))}catch(t){o(t)}}function u(t){try{a(r.throw(t))}catch(t){o(t)}}function a(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(s,u)}a((r=r.apply(t,e||[])).next())}))}"function"==typeof SuppressedError&&SuppressedError;var D="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function y(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var v,_,b={},w={},C={};function E(){if(v)return C;v=1;class t 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}}return C.CommanderError=t,C.InvalidArgumentError=class extends t{constructor(t){super(1,"commander.invalidArgument",t),Error.captureStackTrace(this,this.constructor),this.name=this.constructor.name}},C}function F(){if(_)return w;_=1;const{InvalidArgumentError:t}=E();return 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(e){return this.argChoices=e.slice(),this.parseArg=(e,n)=>{if(!this.argChoices.includes(e))throw new t(`Allowed choices are ${this.argChoices.join(", ")}.`);return this.variadic?this._concatValue(e,n):e},this}argRequired(){return this.required=!0,this}argOptional(){return this.required=!1,this}},w.humanReadableArgName=function(t){const e=t.name()+(!0===t.variadic?"...":"");return t.required?"<"+e+">":"["+e+"]"},w}var k,O={},x={};function S(){if(k)return x;k=1;const{humanReadableArgName:t}=F();function e(t){return t.replace(/\x1b\[\d*(;\d*)*m/g,"")}return x.Help=class{constructor(){this.helpWidth=void 0,this.minWidthToWrap=40,this.sortSubcommands=!1,this.sortOptions=!1,this.showGlobalOptions=!1}prepareContext(t){this.helpWidth=this.helpWidth??t.helpWidth??80}visibleCommands(t){const e=t.commands.filter((t=>!t._hidden)),n=t._getHelpCommand();return n&&!n._hidden&&e.push(n),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._getHelpOption();if(n&&!n.hidden){const r=n.short&&t._findOption(n.short),i=n.long&&t._findOption(n.long);r||i?n.long&&!i?e.push(t.createOption(n.long,n.description)):n.short&&!r&&e.push(t.createOption(n.short,n.description)):e.push(n)}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(e){const n=e.registeredArguments.map((e=>t(e))).join(" ");return e._name+(e._aliases[0]?"|"+e._aliases[0]:"")+(e.options.length?" [options]":"")+(n?" "+n:"")}optionTerm(t){return t.flags}argumentTerm(t){return t.name()}longestSubcommandTermLength(t,e){return e.visibleCommands(t).reduce(((t,n)=>Math.max(t,this.displayWidth(e.styleSubcommandTerm(e.subcommandTerm(n))))),0)}longestOptionTermLength(t,e){return e.visibleOptions(t).reduce(((t,n)=>Math.max(t,this.displayWidth(e.styleOptionTerm(e.optionTerm(n))))),0)}longestGlobalOptionTermLength(t,e){return e.visibleGlobalOptions(t).reduce(((t,n)=>Math.max(t,this.displayWidth(e.styleOptionTerm(e.optionTerm(n))))),0)}longestArgumentTermLength(t,e){return e.visibleArguments(t).reduce(((t,n)=>Math.max(t,this.displayWidth(e.styleArgumentTerm(e.argumentTerm(n))))),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,r){return e.formatItem(t,n,r,e)}let o=[`${e.styleTitle("Usage:")} ${e.styleUsage(e.commandUsage(t))}`,""];const s=e.commandDescription(t);s.length>0&&(o=o.concat([e.boxWrap(e.styleCommandDescription(s),r),""]));const u=e.visibleArguments(t).map((t=>i(e.styleArgumentTerm(e.argumentTerm(t)),e.styleArgumentDescription(e.argumentDescription(t)))));u.length>0&&(o=o.concat([e.styleTitle("Arguments:"),...u,""]));const a=e.visibleOptions(t).map((t=>i(e.styleOptionTerm(e.optionTerm(t)),e.styleOptionDescription(e.optionDescription(t)))));if(a.length>0&&(o=o.concat([e.styleTitle("Options:"),...a,""])),e.showGlobalOptions){const n=e.visibleGlobalOptions(t).map((t=>i(e.styleOptionTerm(e.optionTerm(t)),e.styleOptionDescription(e.optionDescription(t)))));n.length>0&&(o=o.concat([e.styleTitle("Global Options:"),...n,""]))}const c=e.visibleCommands(t).map((t=>i(e.styleSubcommandTerm(e.subcommandTerm(t)),e.styleSubcommandDescription(e.subcommandDescription(t)))));return c.length>0&&(o=o.concat([e.styleTitle("Commands:"),...c,""])),o.join("\n")}displayWidth(t){return e(t).length}styleTitle(t){return t}styleUsage(t){return t.split(" ").map((t=>"[options]"===t?this.styleOptionText(t):"[command]"===t?this.styleSubcommandText(t):"["===t[0]||"<"===t[0]?this.styleArgumentText(t):this.styleCommandText(t))).join(" ")}styleCommandDescription(t){return this.styleDescriptionText(t)}styleOptionDescription(t){return this.styleDescriptionText(t)}styleSubcommandDescription(t){return this.styleDescriptionText(t)}styleArgumentDescription(t){return this.styleDescriptionText(t)}styleDescriptionText(t){return t}styleOptionTerm(t){return this.styleOptionText(t)}styleSubcommandTerm(t){return t.split(" ").map((t=>"[options]"===t?this.styleOptionText(t):"["===t[0]||"<"===t[0]?this.styleArgumentText(t):this.styleSubcommandText(t))).join(" ")}styleArgumentTerm(t){return this.styleArgumentText(t)}styleOptionText(t){return t}styleArgumentText(t){return t}styleSubcommandText(t){return t}styleCommandText(t){return t}padWidth(t,e){return Math.max(e.longestOptionTermLength(t,e),e.longestGlobalOptionTermLength(t,e),e.longestSubcommandTermLength(t,e),e.longestArgumentTermLength(t,e))}preformatted(t){return/\n[^\S\r\n]/.test(t)}formatItem(t,e,n,r){const i=" ".repeat(2);if(!n)return i+t;const o=t.padEnd(e+t.length-r.displayWidth(t)),s=(this.helpWidth??80)-e-2-2;let u;if(s<this.minWidthToWrap||r.preformatted(n))u=n;else{u=r.boxWrap(n,s).replace(/\n/g,"\n"+" ".repeat(e+2))}return i+o+" ".repeat(2)+u.replace(/\n/g,`\n${i}`)}boxWrap(t,e){if(e<this.minWidthToWrap)return t;const n=t.split(/\r\n|\n/),r=/[\s]*[^\s]+/g,i=[];return n.forEach((t=>{const n=t.match(r);if(null===n)return void i.push("");let o=[n.shift()],s=this.displayWidth(o[0]);n.forEach((t=>{const n=this.displayWidth(t);if(s+n<=e)return o.push(t),void(s+=n);i.push(o.join(""));const r=t.trimStart();o=[r],s=this.displayWidth(r)})),i.push(o.join(""))})),i.join("\n")}},x.stripColor=e,x}var A,B={};function T(){if(A)return B;A=1;const{InvalidArgumentError:t}=E();function e(t){return t.split("-").reduce(((t,e)=>t+e[0].toUpperCase()+e.slice(1)))}return B.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=function(t){let e,n;const r=/^-[^-]$/,i=/^--[^-]/,o=t.split(/[ |,]+/).concat("guard");r.test(o[0])&&(e=o.shift());i.test(o[0])&&(n=o.shift());!e&&r.test(o[0])&&(e=o.shift());!e&&i.test(o[0])&&(e=n,n=o.shift());if(o[0].startsWith("-")){const e=o[0],n=`option creation failed due to '${e}' in option flags '${t}'`;if(/^-[^-][^-]/.test(e))throw new Error(`${n}\n- a short flag is a single dash and a single character\n - either use a single dash and a single character (for a short flag)\n - or use a double dash for a long option (and can have two, like '--ws, --workspace')`);if(r.test(e))throw new Error(`${n}\n- too many short flags`);if(i.test(e))throw new Error(`${n}\n- too many long flags`);throw new Error(`${n}\n- unrecognised flag format`)}if(void 0===e&&void 0===n)throw new Error(`option creation failed due to no flags found in '${t}'.`);return{shortFlag:e,longFlag:n}}(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(e){return this.argChoices=e.slice(),this.parseArg=(e,n)=>{if(!this.argChoices.includes(e))throw new t(`Allowed choices are ${this.argChoices.join(", ")}.`);return this.variadic?this._concatValue(e,n):e},this}name(){return this.long?this.long.replace(/^--/,""):this.short.replace(/^-/,"")}attributeName(){return this.negate?e(this.name().replace(/^no-/,"")):e(this.name())}is(t){return this.short===t||this.long===t}isBoolean(){return!this.required&&!this.optional&&!this.negate}},B.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)}},B}var R,j,M,$={};function P(){if(R)return $;R=1;return $.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]}?)`:""},$}var L=function(){if(M)return b;M=1;const{Argument:o}=F(),{Command:s}=function(){if(j)return O;j=1;const o=t.EventEmitter,s=e,u=n,a=r,c=i,{Argument:l,humanReadableArgName:f}=F(),{CommanderError:h}=E(),{Help:p,stripColor:d}=S(),{Option:m,DualOptions:g}=T(),{suggestSimilar:D}=P();class y extends o{constructor(t){super(),this.commands=[],this.options=[],this.parent=null,this._allowUnknownOption=!1,this._allowExcessArguments=!1,this.registeredArguments=[],this._args=this.registeredArguments,this.args=[],this.rawArgs=[],this.processedArgs=[],this._scriptPath=null,this._name=t||"",this._optionValues={},this._optionValueSources={},this._storeOptionsAsProperties=!1,this._actionHandler=null,this._executableHandler=!1,this._executableFile=null,this._executableDir=null,this._defaultCommandName=null,this._exitCallback=null,this._aliases=[],this._combineFlagAndOptionalValue=!0,this._description="",this._summary="",this._argsDescription=void 0,this._enablePositionalOptions=!1,this._passThroughOptions=!1,this._lifeCycleHooks={},this._showHelpAfterError=!1,this._showSuggestionAfterError=!0,this._savedState=null,this._outputConfiguration={writeOut:t=>c.stdout.write(t),writeErr:t=>c.stderr.write(t),outputError:(t,e)=>e(t),getOutHelpWidth:()=>c.stdout.isTTY?c.stdout.columns:void 0,getErrHelpWidth:()=>c.stderr.isTTY?c.stderr.columns:void 0,getOutHasColors:()=>_()??(c.stdout.isTTY&&c.stdout.hasColors?.()),getErrHasColors:()=>_()??(c.stderr.isTTY&&c.stderr.hasColors?.()),stripColor:t=>d(t)},this._hidden=!1,this._helpOption=void 0,this._addImplicitHelpCommand=void 0,this._helpCommand=void 0,this._helpConfiguration={}}copyInheritedSettings(t){return this._outputConfiguration=t._outputConfiguration,this._helpOption=t._helpOption,this._helpCommand=t._helpCommand,this._helpConfiguration=t._helpConfiguration,this._exitCallback=t._exitCallback,this._storeOptionsAsProperties=t._storeOptionsAsProperties,this._combineFlagAndOptionalValue=t._combineFlagAndOptionalValue,this._allowExcessArguments=t._allowExcessArguments,this._enablePositionalOptions=t._enablePositionalOptions,this._showHelpAfterError=t._showHelpAfterError,this._showSuggestionAfterError=t._showSuggestionAfterError,this}_getCommandAndAncestors(){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(/([^ ]+) *(.*)/),u=this.createCommand(o);return r&&(u.description(r),u._executableHandler=!0),i.isDefault&&(this._defaultCommandName=u._name),u._hidden=!(!i.noHelp&&!i.hidden),u._executableFile=i.executableFile||null,s&&u.arguments(s),this._registerCommand(u),u.parent=this,u.copyInheritedSettings(this),r?this:u}createCommand(t){return new y(t)}createHelp(){return Object.assign(new p,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._registerCommand(t),t.parent=this,t._checkForBrokenPassThrough(),this}createArgument(t,e){return new l(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}helpCommand(t,e){if("boolean"==typeof t)return this._addImplicitHelpCommand=t,this;t=t??"help [command]";const[,n,r]=t.match(/([^ ]+) *(.*)/),i=e??"display help for command",o=this.createCommand(n);return o.helpOption(!1),r&&o.arguments(r),i&&o.description(i),this._addImplicitHelpCommand=!0,this._helpCommand=o,this}addHelpCommand(t,e){return"object"!=typeof t?(this.helpCommand(t,e),this):(this._addImplicitHelpCommand=!0,this._helpCommand=t,this)}_getHelpCommand(){return this._addImplicitHelpCommand??(this.commands.length&&!this._actionHandler&&!this._findCommand("help"))?(void 0===this._helpCommand&&this.helpCommand(void 0,void 0),this._helpCommand):null}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 h(t,e,n)),c.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 m(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}}_registerOption(t){const e=t.short&&this._findOption(t.short)||t.long&&this._findOption(t.long);if(e){const n=t.long&&this._findOption(t.long)?t.long:t.short;throw new Error(`Cannot add option '${t.flags}'${this._name&&` to command '${this._name}'`} due to conflicting flag '${n}'\n- already used by option '${e.flags}'`)}this.options.push(t)}_registerCommand(t){const e=t=>[t.name()].concat(t.aliases()),n=e(t).find((t=>this._findCommand(t)));if(n){const r=e(this._findCommand(n)).join("|"),i=e(t).join("|");throw new Error(`cannot add command '${i}' as already have command '${r}'`)}this.commands.push(t)}addOption(t){this._registerOption(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");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 m)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){return this._passThroughOptions=!!t,this._checkForBrokenPassThrough(),this}_checkForBrokenPassThrough(){if(this.parent&&this._passThroughOptions&&!this.parent._enablePositionalOptions)throw new Error(`passThroughOptions cannot be used for '${this._name}' without turning on enablePositionalOptions for parent command(s)`)}storeOptionsAsProperties(t=!0){if(this.options.length)throw new Error("call .storeOptionsAsProperties() before adding options");if(Object.keys(this._optionValues).length)throw new Error("call .storeOptionsAsProperties() before setting option values");return this._storeOptionsAsProperties=!!t,this}getOptionValue(t){return this._storeOptionsAsProperties?this[t]:this._optionValues[t]}setOptionValue(t,e){return this.setOptionValueWithSource(t,e,void 0)}setOptionValueWithSource(t,e,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");if(e=e||{},void 0===t&&void 0===e.from){c.versions?.electron&&(e.from="electron");const t=c.execArgv??[];(t.includes("-e")||t.includes("--eval")||t.includes("-p")||t.includes("--print"))&&(e.from="eval")}let n;switch(void 0===t&&(t=c.argv),this.rawArgs=t.slice(),e.from){case void 0:case"node":this._scriptPath=t[1],n=t.slice(2);break;case"electron":c.defaultApp?(this._scriptPath=t[1],n=t.slice(2)):n=t.slice(1);break;case"user":n=t.slice(0);break;case"eval":n=t.slice(1);break;default:throw new Error(`unexpected parse option { from: '${e.from}' }`)}return!this._name&&this._scriptPath&&this.nameFromFilename(this._scriptPath),this._name=this._name||"program",n}parse(t,e){this._prepareForParse();const n=this._prepareUserArgs(t,e);return this._parseCommand([],n),this}async parseAsync(t,e){this._prepareForParse();const n=this._prepareUserArgs(t,e);return await this._parseCommand([],n),this}_prepareForParse(){null===this._savedState?this.saveStateBeforeParse():this.restoreStateBeforeParse()}saveStateBeforeParse(){this._savedState={_name:this._name,_optionValues:{...this._optionValues},_optionValueSources:{...this._optionValueSources}}}restoreStateBeforeParse(){if(this._storeOptionsAsProperties)throw new Error("Can not call parse again when storeOptionsAsProperties is true.\n- either make a new Command for each call to parse, or stop storing options as properties");this._name=this._savedState._name,this._scriptPath=null,this.rawArgs=[],this._optionValues={...this._savedState._optionValues},this._optionValueSources={...this._savedState._optionValueSources},this.args=[],this.processedArgs=[]}_checkForMissingExecutable(t,e,n){if(!a.existsSync(t))throw new Error(`'${t}' does not exist\n - if '${n}' 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?`searched for local subcommand relative to directory '${e}'`:"no directory for search for local subcommand, use .executableDir() to supply a custom directory"}`)}_executeSubCommand(t,e){e=e.slice();let n=!1;const r=[".js",".ts",".tsx",".mjs",".cjs"];function i(t,e){const n=u.resolve(t,e);if(a.existsSync(n))return n;if(r.includes(u.extname(e)))return;const i=r.find((t=>a.existsSync(`${n}${t}`)));return i?`${n}${i}`:void 0}this._checkForMissingMandatoryOptions(),this._checkForConflictingOptions();let o,l=t._executableFile||`${this._name}-${t._name}`,f=this._executableDir||"";if(this._scriptPath){let t;try{t=a.realpathSync(this._scriptPath)}catch{t=this._scriptPath}f=u.resolve(u.dirname(t),f)}if(f){let e=i(f,l);if(!e&&!t._executableFile&&this._scriptPath){const n=u.basename(this._scriptPath,u.extname(this._scriptPath));n!==this._name&&(e=i(f,`${n}-${t._name}`))}l=e||l}n=r.includes(u.extname(l)),"win32"!==c.platform?n?(e.unshift(l),e=v(c.execArgv).concat(e),o=s.spawn(c.argv[0],e,{stdio:"inherit"})):o=s.spawn(l,e,{stdio:"inherit"}):(this._checkForMissingExecutable(l,f,t._name),e.unshift(l),e=v(c.execArgv).concat(e),o=s.spawn(c.execPath,e,{stdio:"inherit"})),o.killed||["SIGUSR1","SIGUSR2","SIGTERM","SIGINT","SIGHUP"].forEach((t=>{c.on(t,(()=>{!1===o.killed&&null===o.exitCode&&o.kill(t)}))}));const p=this._exitCallback;o.on("close",(t=>{t=t??1,p?p(new h(t,"commander.executeSubCommandAsync","(close)")):c.exit(t)})),o.on("error",(e=>{if("ENOENT"===e.code)this._checkForMissingExecutable(l,f,t._name);else if("EACCES"===e.code)throw new Error(`'${l}' not executable`);if(p){const t=new h(1,"commander.executeSubCommandAsync","(error)");t.nestedError=e,p(t)}else c.exit(1)})),this.runningCommand=o}_dispatchSubcommand(t,e,n){const r=this._findCommand(t);let i;return r||this.help({error:!0}),r._prepareForParse(),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._getHelpOption()?.long??this._getHelpOption()?.short??"--help"])}_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._getHelpCommand()&&t[0]===this._getHelpCommand().name())return this._dispatchHelpCommand(t[1]);if(this._defaultCommandName)return this._outputHelpIfRequested(e),this._dispatchSubcommand(this._defaultCommandName,t,e);!this.commands.length||0!==this.args.length||this._actionHandler||this._defaultCommandName||this.help({error:!0}),this._outputHelpIfRequested(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(this._getHelpCommand()&&t===this._getHelpCommand().name()){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 c.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()}`,c.env[t.envVar]):this.emit(`optionEnv:${t.name()}`))}}))}_parseOptionsImplied(){const t=new g(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=D(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=D(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._registerOption(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");const n=this.parent?._findCommand(t);if(n){const e=[n.name()].concat(n.aliases()).join("|");throw new Error(`cannot add alias '${t}' to command '${this.name()}' as already have command '${e}'`)}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=>f(t)));return[].concat(this.options.length||null!==this._helpOption?"[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=u.basename(t,u.extname(t)),this}executableDir(t){return void 0===t?this._executableDir:(this._executableDir=t,this)}helpInformation(t){const e=this.createHelp(),n=this._getOutputContext(t);e.prepareContext({error:n.error,helpWidth:n.helpWidth,outputHasColors:n.hasColors});const r=e.formatHelp(this,e);return n.hasColors?r:this._outputConfiguration.stripColor(r)}_getOutputContext(t){const e=!!(t=t||{}).error;let n,r,i;return e?(n=t=>this._outputConfiguration.writeErr(t),r=this._outputConfiguration.getErrHasColors(),i=this._outputConfiguration.getErrHelpWidth()):(n=t=>this._outputConfiguration.writeOut(t),r=this._outputConfiguration.getOutHasColors(),i=this._outputConfiguration.getOutHelpWidth()),{error:e,write:t=>(r||(t=this._outputConfiguration.stripColor(t)),n(t)),hasColors:r,helpWidth:i}}outputHelp(t){let e;"function"==typeof t&&(e=t,t=void 0);const n=this._getOutputContext(t),r={error:n.error,write:n.write,command:this};this._getCommandAndAncestors().reverse().forEach((t=>t.emit("beforeAllHelp",r))),this.emit("beforeHelp",r);let i=this.helpInformation({error:n.error});if(e&&(i=e(i),"string"!=typeof i&&!Buffer.isBuffer(i)))throw new Error("outputHelp callback must return a string or a Buffer");n.write(i),this._getHelpOption()?.long&&this.emit(this._getHelpOption().long),this.emit("afterHelp",r),this._getCommandAndAncestors().forEach((t=>t.emit("afterAllHelp",r)))}helpOption(t,e){return"boolean"==typeof t?(this._helpOption=t?this._helpOption??void 0:null,this):(t=t??"-h, --help",e=e??"display help for command",this._helpOption=this.createOption(t,e),this)}_getHelpOption(){return void 0===this._helpOption&&this.helpOption(void 0,void 0),this._helpOption}addHelpOption(t){return this._helpOption=t,this}help(t){this.outputHelp(t);let e=Number(c.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}_outputHelpIfRequested(t){const e=this._getHelpOption();e&&t.find((t=>e.is(t)))&&(this.outputHelp(),this._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}))}function _(){return!c.env.NO_COLOR&&"0"!==c.env.FORCE_COLOR&&"false"!==c.env.FORCE_COLOR&&(!(!c.env.FORCE_COLOR&&void 0===c.env.CLICOLOR_FORCE)||void 0)}return O.Command=y,O.useColor=_,O}(),{CommanderError:u,InvalidArgumentError:a}=E(),{Help:c}=S(),{Option:l}=T();return b.program=new s,b.createCommand=t=>new s(t),b.createOption=(t,e)=>new l(t,e),b.createArgument=(t,e)=>new o(t,e),b.Command=s,b.Option=l,b.Argument=o,b.Help=c,b.CommanderError=u,b.InvalidArgumentError=a,b.InvalidOptionArgumentError=a,b}(),I=y(L);const{program:N,createCommand:U,createArgument:W,createOption:H,CommanderError:q,InvalidArgumentError:G,InvalidOptionArgumentError:V,Command:z,Argument:Y,Option:J,Help:K}=I;var Z,Q,X,tt,et,nt,rt,it,ot,st,ut={},at={};function ct(){return Z||(Z=1,at.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})},at.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}function lt(){if(X)return Q;X=1;var t=o,e=process.cwd,n=null,r=process.env.GRACEFUL_FS_PLATFORM||process.platform;process.cwd=function(){return n||(n=e.call(process)),n};try{process.cwd()}catch(t){}if("function"==typeof process.chdir){var i=process.chdir;process.chdir=function(t){n=null,i.call(process,t)},Object.setPrototypeOf&&Object.setPrototypeOf(process.chdir,i)}return Q=function(e){t.hasOwnProperty("O_SYMLINK")&&process.version.match(/^v0\.6\.[0-2]|^v0\.5\./)&&function(e){e.lchmod=function(n,r,i){e.open(n,t.O_WRONLY|t.O_SYMLINK,r,(function(t,n){t?i&&i(t):e.fchmod(n,r,(function(t){e.close(n,(function(e){i&&i(t||e)}))}))}))},e.lchmodSync=function(n,r){var i,o=e.openSync(n,t.O_WRONLY|t.O_SYMLINK,r),s=!0;try{i=e.fchmodSync(o,r),s=!1}finally{if(s)try{e.closeSync(o)}catch(t){}else e.closeSync(o)}return i}}(e);e.lutimes||function(e){t.hasOwnProperty("O_SYMLINK")&&e.futimes?(e.lutimes=function(n,r,i,o){e.open(n,t.O_SYMLINK,(function(t,n){t?o&&o(t):e.futimes(n,r,i,(function(t){e.close(n,(function(e){o&&o(t||e)}))}))}))},e.lutimesSync=function(n,r,i){var o,s=e.openSync(n,t.O_SYMLINK),u=!0;try{o=e.futimesSync(s,r,i),u=!1}finally{if(u)try{e.closeSync(s)}catch(t){}else e.closeSync(s)}return o}):e.futimes&&(e.lutimes=function(t,e,n,r){r&&process.nextTick(r)},e.lutimesSync=function(){})}(e);e.chown=o(e.chown),e.fchown=o(e.fchown),e.lchown=o(e.lchown),e.chmod=n(e.chmod),e.fchmod=n(e.fchmod),e.lchmod=n(e.lchmod),e.chownSync=s(e.chownSync),e.fchownSync=s(e.fchownSync),e.lchownSync=s(e.lchownSync),e.chmodSync=i(e.chmodSync),e.fchmodSync=i(e.fchmodSync),e.lchmodSync=i(e.lchmodSync),e.stat=u(e.stat),e.fstat=u(e.fstat),e.lstat=u(e.lstat),e.statSync=a(e.statSync),e.fstatSync=a(e.fstatSync),e.lstatSync=a(e.lstatSync),e.chmod&&!e.lchmod&&(e.lchmod=function(t,e,n){n&&process.nextTick(n)},e.lchmodSync=function(){});e.chown&&!e.lchown&&(e.lchown=function(t,e,n,r){r&&process.nextTick(r)},e.lchownSync=function(){});"win32"===r&&(e.rename="function"!=typeof e.rename?e.rename:function(t){function n(n,r,i){var o=Date.now(),s=0;t(n,r,(function u(a){if(a&&("EACCES"===a.code||"EPERM"===a.code||"EBUSY"===a.code)&&Date.now()-o<6e4)return setTimeout((function(){e.stat(r,(function(e,o){e&&"ENOENT"===e.code?t(n,r,u):i(a)}))}),s),void(s<100&&(s+=10));i&&i(a)}))}return Object.setPrototypeOf&&Object.setPrototypeOf(n,t),n}(e.rename));function n(t){return t?function(n,r,i){return t.call(e,n,r,(function(t){c(t)&&(t=null),i&&i.apply(this,arguments)}))}:t}function i(t){return t?function(n,r){try{return t.call(e,n,r)}catch(t){if(!c(t))throw t}}:t}function o(t){return t?function(n,r,i,o){return t.call(e,n,r,i,(function(t){c(t)&&(t=null),o&&o.apply(this,arguments)}))}:t}function s(t){return t?function(n,r,i){try{return t.call(e,n,r,i)}catch(t){if(!c(t))throw t}}:t}function u(t){return t?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?t.call(e,n,r,o):t.call(e,n,o)}:t}function a(t){return t?function(n,r){var i=r?t.call(e,n,r):t.call(e,n);return i&&(i.uid<0&&(i.uid+=4294967296),i.gid<0&&(i.gid+=4294967296)),i}:t}function c(t){return!t||("ENOSYS"===t.code||!(process.getuid&&0===process.getuid()||"EINVAL"!==t.code&&"EPERM"!==t.code))}e.read="function"!=typeof e.read?e.read:function(t){function n(n,r,i,o,s,u){var a;if(u&&"function"==typeof u){var c=0;a=function(l,f,h){if(l&&"EAGAIN"===l.code&&c<10)return c++,t.call(e,n,r,i,o,s,a);u.apply(this,arguments)}}return t.call(e,n,r,i,o,s,a)}return Object.setPrototypeOf&&Object.setPrototypeOf(n,t),n}(e.read),e.readSync="function"!=typeof e.readSync?e.readSync:(l=e.readSync,function(t,n,r,i,o){for(var s=0;;)try{return l.call(e,t,n,r,i,o)}catch(t){if("EAGAIN"===t.code&&s<10){s++;continue}throw t}});var l},Q}function ft(){if(ot)return it;ot=1;var t,e,n=r,i=lt(),o=function(){if(et)return tt;et=1;var t=s.Stream;return tt=function(e){return{ReadStream:function n(r,i){if(!(this instanceof n))return new n(r,i);t.call(this);var o=this;this.path=r,this.fd=null,this.readable=!0,this.paused=!1,this.flags="r",this.mode=438,this.bufferSize=65536,i=i||{};for(var s=Object.keys(i),u=0,a=s.length;u<a;u++){var c=s[u];this[c]=i[c]}if(this.encoding&&this.setEncoding(this.encoding),void 0!==this.start){if("number"!=typeof this.start)throw TypeError("start must be a Number");if(void 0===this.end)this.end=1/0;else if("number"!=typeof this.end)throw TypeError("end must be a Number");if(this.start>this.end)throw new Error("start must be <= end");this.pos=this.start}null===this.fd?e.open(this.path,this.flags,this.mode,(function(t,e){if(t)return o.emit("error",t),void(o.readable=!1);o.fd=e,o.emit("open",e),o._read()})):process.nextTick((function(){o._read()}))},WriteStream:function n(r,i){if(!(this instanceof n))return new n(r,i);t.call(this),this.path=r,this.fd=null,this.writable=!0,this.flags="w",this.encoding="binary",this.mode=438,this.bytesWritten=0,i=i||{};for(var o=Object.keys(i),s=0,u=o.length;s<u;s++){var a=o[s];this[a]=i[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=e.open,this._queue.push([this._open,this.path,this.flags,this.mode,void 0]),this.flush())}}},tt}(),c=function(){if(rt)return nt;rt=1,nt=function(e){if(null===e||"object"!=typeof e)return e;if(e instanceof Object)var n={__proto__:t(e)};else n=Object.create(null);return Object.getOwnPropertyNames(e).forEach((function(t){Object.defineProperty(n,t,Object.getOwnPropertyDescriptor(e,t))})),n};var t=Object.getPrototypeOf||function(t){return t.__proto__};return nt}(),l=u;function f(e,n){Object.defineProperty(e,t,{get:function(){return n}})}"function"==typeof Symbol&&"function"==typeof Symbol.for?(t=Symbol.for("graceful-fs.queue"),e=Symbol.for("graceful-fs.previous")):(t="___graceful-fs.queue",e="___graceful-fs.previous");var h,p=function(){};if(l.debuglog?p=l.debuglog("gfs4"):/\bgfs4\b/i.test(process.env.NODE_DEBUG||"")&&(p=function(){var t=l.format.apply(l,arguments);t="GFS4: "+t.split(/\n/).join("\nGFS4: "),console.error(t)}),!n[t]){var d=D[t]||[];f(n,d),n.close=function(t){function r(e,r){return t.call(n,e,(function(t){t||y(),"function"==typeof r&&r.apply(this,arguments)}))}return Object.defineProperty(r,e,{value:t}),r}(n.close),n.closeSync=function(t){function r(e){t.apply(n,arguments),y()}return Object.defineProperty(r,e,{value:t}),r}(n.closeSync),/\bgfs4\b/i.test(process.env.NODE_DEBUG||"")&&process.on("exit",(function(){p(n[t]),a.equal(n[t].length,0)}))}function m(t){i(t),t.gracefulify=m,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):g([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):g([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):g([t,[e,n,i,o],r,s||Date.now(),Date.now()])}))}(t,e,n,i)});var s=t.copyFile;s&&(t.copyFile=function(t,e,n,r){"function"==typeof n&&(r=n,n=0);return function t(e,n,r,i,o){return s(e,n,r,(function(s){!s||"EMFILE"!==s.code&&"ENFILE"!==s.code?"function"==typeof i&&i.apply(this,arguments):g([t,[e,n,r,i],s,o||Date.now(),Date.now()])}))}(t,e,n,r)});var u=t.readdir;t.readdir=function(t,e,n){"function"==typeof e&&(n=e,e=null);var r=a.test(process.version)?function(t,e,n,r){return u(t,i(t,e,n,r))}:function(t,e,n,r){return u(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)):g([r,[t,e,n],o,i||Date.now(),Date.now()])}}};var a=/^v[0-5]\./;if("v0.8"===process.version.substr(0,4)){var c=o(t);d=c.ReadStream,D=c.WriteStream}var l=t.ReadStream;l&&(d.prototype=Object.create(l.prototype),d.prototype.open=function(){var t=this;v(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 f=t.WriteStream;f&&(D.prototype=Object.create(f.prototype),D.prototype.open=function(){var t=this;v(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 d},set:function(t){d=t},enumerable:!0,configurable:!0}),Object.defineProperty(t,"WriteStream",{get:function(){return D},set:function(t){D=t},enumerable:!0,configurable:!0});var h=d;Object.defineProperty(t,"FileReadStream",{get:function(){return h},set:function(t){h=t},enumerable:!0,configurable:!0});var p=D;function d(t,e){return this instanceof d?(l.apply(this,arguments),this):d.apply(Object.create(d.prototype),arguments)}function D(t,e){return this instanceof D?(f.apply