gant-core 0.2.10 → 0.2.12

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -7,4 +7,4 @@
7
7
  *
8
8
  * MIT Licensed
9
9
  */
10
- const CA=v,xA=y,FA=l,PA=function(){var e;return e=jA?process.env.TEMP||process.env.TMP||(process.env.SystemRoot||process.env.windir)+"\\temp":process.env.TMPDIR||process.env.TMP||process.env.TEMP||"/tmp",SA.test(e)&&(e=e.slice(0,-1)),e},AA=process.binding("constants"),BA=PA(),MA="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz",TA=/XXXXXX/,kA=3,RA=(AA.O_CREAT||AA.fs.O_CREAT)|(AA.O_EXCL||AA.fs.O_EXCL)|(AA.O_RDWR||AA.fs.O_RDWR),IA=AA.EBADF||AA.os.errno.EBADF,LA=AA.ENOENT||AA.os.errno.ENOENT,NA=[];var UA=!1,GA=!1;function WA(e){var t=[],r=null;try{r=FA.randomBytes(e)}catch(t){r=FA.pseudoRandomBytes(e)}for(var n=0;n<e;n++)t.push(MA[r[n]%MA.length]);return t.join("")}function qA(e){return void 0===e}function VA(e,t){return"function"==typeof e?[t||{},e]:qA(e)?[{},t]:[e,t]}function zA(e){if(e.name)return xA.join(e.dir||BA,e.name);if(e.template)return e.template.replace(TA,WA(6));const t=[e.prefix||"tmp-",process.pid,WA(12),e.postfix||""].join("");return xA.join(e.dir||BA,t)}function $A(e,t){var r=VA(e,t),n=r[0],o=r[1],i=n.name?1:n.tries||kA;return isNaN(i)||i<0?o(new Error("Invalid tries")):n.template&&!n.template.match(TA)?o(new Error("Invalid template provided")):void function e(){const t=zA(n);CA.stat(t,(function(r){if(!r)return i-- >0?e():o(new Error("Could not get a unique tmp filename, max tries reached "+t));o(null,t)}))}()}function KA(e){var t=VA(e)[0],r=t.name?1:t.tries||kA;if(isNaN(r)||r<0)throw new Error("Invalid tries");if(t.template&&!t.template.match(TA))throw new Error("Invalid template provided");do{const e=zA(t);try{CA.statSync(e)}catch(t){return e}}while(r-- >0);throw new Error("Could not get a unique tmp filename, max tries reached")}function YA(e){const t=[e];do{for(var r=t.pop(),n=!1,o=CA.readdirSync(r),i=0,a=o.length;i<a;i++){var u=xA.join(r,o[i]);CA.lstatSync(u).isDirectory()?(n||(n=!0,t.push(r)),t.push(u)):CA.unlinkSync(u)}n||CA.rmdirSync(r)}while(0!==t.length)}function HA(e,t,r){const n=QA((function(e){try{0<=e[0]&&CA.closeSync(e[0])}catch(e){if(!(t=e,eB(t,-IA,"EBADF")||ZA(e)))throw e}var t;try{CA.unlinkSync(e[1])}catch(e){if(!ZA(e))throw e}}),[t,e]);return r.keep||NA.unshift(n),n}function JA(e,t){const r=QA(t.unsafeCleanup?YA:CA.rmdirSync.bind(CA),e);return t.keep||NA.unshift(r),r}function QA(e,t){var r=!1;return function n(o){if(!r){const o=NA.indexOf(n);o>=0&&NA.splice(o,1),r=!0,e(t)}o&&o(null)}}function XA(){if(!GA||UA)for(;NA.length;)try{NA[0].call(null)}catch(e){}}function ZA(e){return eB(e,-LA,"ENOENT")}function eB(e,t,r){return e.code==t||e.code==r}const tB=process.versions.node.split(".").map((function(e){return parseInt(e,10)}));0===tB[0]&&(tB[1]<9||9===tB[1]&&tB[2]<5)&&process.addListener("uncaughtException",(function(e){throw GA=!0,XA(),e})),process.addListener("exit",(function(e){e&&(GA=!0),XA()})),EA.tmpdir=BA,EA.dir=function(e,t){var r=VA(e,t),n=r[0],o=r[1];$A(n,(function(e,t){if(e)return o(e);CA.mkdir(t,n.mode||448,(function(e){if(e)return o(e);o(null,t,JA(t,n))}))}))},EA.dirSync=function(e){var t=VA(e)[0];const r=KA(t);return CA.mkdirSync(r,t.mode||448),{name:r,removeCallback:JA(r,t)}},EA.file=function(e,t){var r=VA(e,t),n=r[0],o=r[1];n.postfix=qA(n.postfix)?".tmp":n.postfix,$A(n,(function(e,t){if(e)return o(e);CA.open(t,RA,n.mode||384,(function(e,r){return e?o(e):n.discardDescriptor?CA.close(r,(function(e){if(e){try{CA.unlinkSync(t)}catch(t){ZA(t)||(e=t)}return o(e)}o(null,t,void 0,HA(t,-1,n))})):n.detachDescriptor?o(null,t,r,HA(t,-1,n)):void o(null,t,r,HA(t,r,n))}))}))},EA.fileSync=function(e){var t=VA(e)[0];t.postfix=t.postfix||".tmp";const r=t.discardDescriptor||t.detachDescriptor,n=KA(t);var o=CA.openSync(n,RA,t.mode||384);return t.discardDescriptor&&(CA.closeSync(o),o=void 0),{name:n,fd:o,removeCallback:HA(n,r?-1:o,t)}},EA.tmpName=$A,EA.tmpNameSync=KA,EA.setGracefulCleanup=function(){UA=!0};var rB={},nB=h.commonjsGlobal&&h.commonjsGlobal.__extends||function(){var e=function(t,r){return e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)t.hasOwnProperty(r)&&(e[r]=t[r])},e(t,r)};return function(t,r){function n(){this.constructor=t}e(t,r),t.prototype=null===r?Object.create(r):(n.prototype=r.prototype,new n)}}();Object.defineProperty(rB,"__esModule",{value:!0});var oB=function(e){function t(t){var r=this.constructor,n=e.call(this,"Failed to create temporary file for editor")||this;n.originalError=t;var o=r.prototype;return Object.setPrototypeOf?Object.setPrototypeOf(n,o):n.__proto__=r.prototype,n}return nB(t,e),t}(Error);rB.CreateFileError=oB;var iB={},aB=h.commonjsGlobal&&h.commonjsGlobal.__extends||function(){var e=function(t,r){return e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)t.hasOwnProperty(r)&&(e[r]=t[r])},e(t,r)};return function(t,r){function n(){this.constructor=t}e(t,r),t.prototype=null===r?Object.create(r):(n.prototype=r.prototype,new n)}}();Object.defineProperty(iB,"__esModule",{value:!0});var uB=function(e){function t(t){var r=this.constructor,n=e.call(this,"Failed launch editor")||this;n.originalError=t;var o=r.prototype;return Object.setPrototypeOf?Object.setPrototypeOf(n,o):n.__proto__=r.prototype,n}return aB(t,e),t}(Error);iB.LaunchEditorError=uB;var sB={},cB=h.commonjsGlobal&&h.commonjsGlobal.__extends||function(){var e=function(t,r){return e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)t.hasOwnProperty(r)&&(e[r]=t[r])},e(t,r)};return function(t,r){function n(){this.constructor=t}e(t,r),t.prototype=null===r?Object.create(r):(n.prototype=r.prototype,new n)}}();Object.defineProperty(sB,"__esModule",{value:!0});var lB=function(e){function t(t){var r=this.constructor,n=e.call(this,"Failed to read temporary file")||this;n.originalError=t;var o=r.prototype;return Object.setPrototypeOf?Object.setPrototypeOf(n,o):n.__proto__=r.prototype,n}return cB(t,e),t}(Error);sB.ReadFileError=lB;var fB={},pB=h.commonjsGlobal&&h.commonjsGlobal.__extends||function(){var e=function(t,r){return e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)t.hasOwnProperty(r)&&(e[r]=t[r])},e(t,r)};return function(t,r){function n(){this.constructor=t}e(t,r),t.prototype=null===r?Object.create(r):(n.prototype=r.prototype,new n)}}();Object.defineProperty(fB,"__esModule",{value:!0});var dB=function(e){function t(t){var r=this.constructor,n=e.call(this,"Failed to cleanup temporary file")||this;n.originalError=t;var o=r.prototype;return Object.setPrototypeOf?Object.setPrototypeOf(n,o):n.__proto__=r.prototype,n}return pB(t,e),t}(Error);fB.RemoveFileError=dB,Object.defineProperty(dP,"__esModule",{value:!0});var hB=hP,bB=s,vB=v,yB=OA,mB=EA,gB=rB;dP.CreateFileError=gB.CreateFileError;var DB=iB;dP.LaunchEditorError=DB.LaunchEditorError;var _B=sB;dP.ReadFileError=_B.ReadFileError;var wB=fB;dP.RemoveFileError=wB.RemoveFileError,dP.edit=function(e,t){void 0===e&&(e="");var r=new EB(e,t);return r.run(),r.cleanup(),r.text};var OB=dP.editAsync=function(e,t,r){void 0===e&&(e="");var n=new EB(e,r);n.runAsync((function(e,r){if(e)setImmediate(t,e,null);else try{n.cleanup(),setImmediate(t,null,r)}catch(e){setImmediate(t,e,null)}}))},EB=function(){function e(e,t){void 0===e&&(e=""),this.text="",this.fileOptions={},this.text=e,t&&(this.fileOptions=t),this.determineEditor(),this.createTemporaryFile()}return e.splitStringBySpace=function(e){for(var t=[],r="",n=0;n<e.length;n++){var o=e[n];n>0&&" "===o&&"\\"!==e[n-1]&&r.length>0?(t.push(r),r=""):r+=o}return r.length>0&&t.push(r),t},Object.defineProperty(e.prototype,"temp_file",{get:function(){return console.log("DEPRECATED: temp_file. Use tempFile moving forward."),this.tempFile},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"last_exit_status",{get:function(){return console.log("DEPRECATED: last_exit_status. Use lastExitStatus moving forward."),this.lastExitStatus},enumerable:!0,configurable:!0}),e.prototype.run=function(){return this.launchEditor(),this.readTemporaryFile(),this.text},e.prototype.runAsync=function(e){var t=this;try{this.launchEditorAsync((function(){try{t.readTemporaryFile(),setImmediate(e,null,t.text)}catch(t){setImmediate(e,t,null)}}))}catch(t){setImmediate(e,t,null)}},e.prototype.cleanup=function(){this.removeTemporaryFile()},e.prototype.determineEditor=function(){var t=process.env.VISUAL?process.env.VISUAL:process.env.EDITOR?process.env.EDITOR:/^win/.test(process.platform)?"notepad":"vim",r=e.splitStringBySpace(t).map((function(e){return e.replace("\\ "," ")})),n=r.shift();this.editor={args:r,bin:n}},e.prototype.createTemporaryFile=function(){try{this.tempFile=mB.tmpNameSync(this.fileOptions);var e={encoding:"utf8"};this.fileOptions.hasOwnProperty("mode")&&(e.mode=this.fileOptions.mode),vB.writeFileSync(this.tempFile,this.text,e)}catch(e){throw new gB.CreateFileError(e)}},e.prototype.readTemporaryFile=function(){try{var e=vB.readFileSync(this.tempFile);if(0===e.length)this.text="";else{var t=hB.detect(e).toString();yB.encodingExists(t)||(t="utf8"),this.text=yB.decode(e,t)}}catch(e){throw new _B.ReadFileError(e)}},e.prototype.removeTemporaryFile=function(){try{vB.unlinkSync(this.tempFile)}catch(e){throw new wB.RemoveFileError(e)}},e.prototype.launchEditor=function(){try{var e=bB.spawnSync(this.editor.bin,this.editor.args.concat([this.tempFile]),{stdio:"inherit"});this.lastExitStatus=e.status}catch(e){throw new DB.LaunchEditorError(e)}},e.prototype.launchEditorAsync=function(e){var t=this;try{bB.spawn(this.editor.bin,this.editor.args.concat([this.tempFile]),{stdio:"inherit"}).on("exit",(function(r){t.lastExitStatus=r,setImmediate(e)}))}catch(e){throw new DB.LaunchEditorError(e)}},e}();dP.ExternalEditor=EB;class jB extends nP{_run(e){this.done=e,this.editorResult=new Te.Subject;const t=Jv(this.rl);this.lineSubscription=t.line.subscribe(this.startExternalEditor.bind(this));void 0===this.opt.waitUserInput||this.opt.waitUserInput||this.startExternalEditor();const r=this.handleSubmitEvents(this.editorResult);return r.success.forEach(this.onEnd.bind(this)),r.error.forEach(this.onError.bind(this)),this.currentText=this.opt.default,this.opt.default=null,this.render(),this}render(e){let t="",r=this.getQuestion();"answered"===this.status?r+=K.dim("Received"):r+=K.dim("Press <enter> to launch your preferred editor."),e&&(t=K.red(">> ")+e),this.screen.render(r,t)}startExternalEditor(){this.rl.pause(),OB(this.currentText,this.endExternalEditor.bind(this),{postfix:this.opt.postfix??".txt"})}endExternalEditor(e,t){this.rl.resume(),e?this.editorResult.error(e):this.editorResult.next(t)}onEnd(e){this.editorResult.unsubscribe(),this.lineSubscription.unsubscribe(),this.answer=e.value,this.status="answered",this.render(),this.screen.done(),this.done(this.answer)}onError(e){this.render(e.isValid)}}var SB,CB={exports:{}},xB=Object.prototype.toString,FB=Math.max,PB=function(e,t){for(var r=[],n=0;n<e.length;n+=1)r[n]=e[n];for(var o=0;o<t.length;o+=1)r[o+e.length]=t[o];return r},AB=function(e){var t=this;if("function"!=typeof t||"[object Function]"!==xB.apply(t))throw new TypeError("Function.prototype.bind called on incompatible "+t);for(var r,n=function(e,t){for(var r=[],n=t||0,o=0;n<e.length;n+=1,o+=1)r[o]=e[n];return r}(arguments,1),o=FB(0,t.length-n.length),i=[],a=0;a<o;a++)i[a]="$"+a;if(r=Function("binder","return function ("+function(e,t){for(var r="",n=0;n<e.length;n+=1)r+=e[n],n+1<e.length&&(r+=t);return r}(i,",")+"){ return binder.apply(this,arguments); }")((function(){if(this instanceof r){var o=t.apply(this,PB(n,arguments));return Object(o)===o?o:this}return t.apply(e,PB(n,arguments))})),t.prototype){var u=function(){};u.prototype=t.prototype,r.prototype=new u,u.prototype=null}return r},BB=Function.prototype.bind||AB,MB=Error,TB=EvalError,kB=RangeError,RB=ReferenceError,IB=SyntaxError,LB=TypeError,NB=URIError,UB="undefined"!=typeof Symbol&&Symbol,GB=function(){if("function"!=typeof Symbol||"function"!=typeof Object.getOwnPropertySymbols)return!1;if("symbol"==typeof Symbol.iterator)return!0;var e={},t=Symbol("test"),r=Object(t);if("string"==typeof t)return!1;if("[object Symbol]"!==Object.prototype.toString.call(t))return!1;if("[object Symbol]"!==Object.prototype.toString.call(r))return!1;for(t in e[t]=42,e)return!1;if("function"==typeof Object.keys&&0!==Object.keys(e).length)return!1;if("function"==typeof Object.getOwnPropertyNames&&0!==Object.getOwnPropertyNames(e).length)return!1;var n=Object.getOwnPropertySymbols(e);if(1!==n.length||n[0]!==t)return!1;if(!Object.prototype.propertyIsEnumerable.call(e,t))return!1;if("function"==typeof Object.getOwnPropertyDescriptor){var o=Object.getOwnPropertyDescriptor(e,t);if(42!==o.value||!0!==o.enumerable)return!1}return!0},WB={__proto__:null,foo:{}},qB=Object,VB=Function.prototype.call,zB=Object.prototype.hasOwnProperty,$B=BB.call(VB,zB),KB=MB,YB=TB,HB=kB,JB=RB,QB=IB,XB=LB,ZB=NB,eM=Function,tM=function(e){try{return eM('"use strict"; return ('+e+").constructor;")()}catch(e){}},rM=Object.getOwnPropertyDescriptor;if(rM)try{rM({},"")}catch(e){rM=null}var nM=function(){throw new XB},oM=rM?function(){try{return nM}catch(e){try{return rM(arguments,"callee").get}catch(e){return nM}}}():nM,iM="function"==typeof UB&&"function"==typeof Symbol&&"symbol"==typeof UB("foo")&&"symbol"==typeof Symbol("bar")&&GB(),aM={__proto__:WB}.foo===WB.foo&&!(WB instanceof qB),uM=Object.getPrototypeOf||(aM?function(e){return e.__proto__}:null),sM={},cM="undefined"!=typeof Uint8Array&&uM?uM(Uint8Array):SB,lM={__proto__:null,"%AggregateError%":"undefined"==typeof AggregateError?SB:AggregateError,"%Array%":Array,"%ArrayBuffer%":"undefined"==typeof ArrayBuffer?SB:ArrayBuffer,"%ArrayIteratorPrototype%":iM&&uM?uM([][Symbol.iterator]()):SB,"%AsyncFromSyncIteratorPrototype%":SB,"%AsyncFunction%":sM,"%AsyncGenerator%":sM,"%AsyncGeneratorFunction%":sM,"%AsyncIteratorPrototype%":sM,"%Atomics%":"undefined"==typeof Atomics?SB:Atomics,"%BigInt%":"undefined"==typeof BigInt?SB:BigInt,"%BigInt64Array%":"undefined"==typeof BigInt64Array?SB:BigInt64Array,"%BigUint64Array%":"undefined"==typeof BigUint64Array?SB:BigUint64Array,"%Boolean%":Boolean,"%DataView%":"undefined"==typeof DataView?SB:DataView,"%Date%":Date,"%decodeURI%":decodeURI,"%decodeURIComponent%":decodeURIComponent,"%encodeURI%":encodeURI,"%encodeURIComponent%":encodeURIComponent,"%Error%":KB,"%eval%":eval,"%EvalError%":YB,"%Float32Array%":"undefined"==typeof Float32Array?SB:Float32Array,"%Float64Array%":"undefined"==typeof Float64Array?SB:Float64Array,"%FinalizationRegistry%":"undefined"==typeof FinalizationRegistry?SB:FinalizationRegistry,"%Function%":eM,"%GeneratorFunction%":sM,"%Int8Array%":"undefined"==typeof Int8Array?SB:Int8Array,"%Int16Array%":"undefined"==typeof Int16Array?SB:Int16Array,"%Int32Array%":"undefined"==typeof Int32Array?SB:Int32Array,"%isFinite%":isFinite,"%isNaN%":isNaN,"%IteratorPrototype%":iM&&uM?uM(uM([][Symbol.iterator]())):SB,"%JSON%":"object"==typeof JSON?JSON:SB,"%Map%":"undefined"==typeof Map?SB:Map,"%MapIteratorPrototype%":"undefined"!=typeof Map&&iM&&uM?uM((new Map)[Symbol.iterator]()):SB,"%Math%":Math,"%Number%":Number,"%Object%":Object,"%parseFloat%":parseFloat,"%parseInt%":parseInt,"%Promise%":"undefined"==typeof Promise?SB:Promise,"%Proxy%":"undefined"==typeof Proxy?SB:Proxy,"%RangeError%":HB,"%ReferenceError%":JB,"%Reflect%":"undefined"==typeof Reflect?SB:Reflect,"%RegExp%":RegExp,"%Set%":"undefined"==typeof Set?SB:Set,"%SetIteratorPrototype%":"undefined"!=typeof Set&&iM&&uM?uM((new Set)[Symbol.iterator]()):SB,"%SharedArrayBuffer%":"undefined"==typeof SharedArrayBuffer?SB:SharedArrayBuffer,"%String%":String,"%StringIteratorPrototype%":iM&&uM?uM(""[Symbol.iterator]()):SB,"%Symbol%":iM?Symbol:SB,"%SyntaxError%":QB,"%ThrowTypeError%":oM,"%TypedArray%":cM,"%TypeError%":XB,"%Uint8Array%":"undefined"==typeof Uint8Array?SB:Uint8Array,"%Uint8ClampedArray%":"undefined"==typeof Uint8ClampedArray?SB:Uint8ClampedArray,"%Uint16Array%":"undefined"==typeof Uint16Array?SB:Uint16Array,"%Uint32Array%":"undefined"==typeof Uint32Array?SB:Uint32Array,"%URIError%":ZB,"%WeakMap%":"undefined"==typeof WeakMap?SB:WeakMap,"%WeakRef%":"undefined"==typeof WeakRef?SB:WeakRef,"%WeakSet%":"undefined"==typeof WeakSet?SB:WeakSet};if(uM)try{null.error}catch(e){var fM=uM(uM(e));lM["%Error.prototype%"]=fM}var pM,dM,hM=function e(t){var r;if("%AsyncFunction%"===t)r=tM("async function () {}");else if("%GeneratorFunction%"===t)r=tM("function* () {}");else if("%AsyncGeneratorFunction%"===t)r=tM("async function* () {}");else if("%AsyncGenerator%"===t){var n=e("%AsyncGeneratorFunction%");n&&(r=n.prototype)}else if("%AsyncIteratorPrototype%"===t){var o=e("%AsyncGenerator%");o&&uM&&(r=uM(o.prototype))}return lM[t]=r,r},bM={__proto__:null,"%ArrayBufferPrototype%":["ArrayBuffer","prototype"],"%ArrayPrototype%":["Array","prototype"],"%ArrayProto_entries%":["Array","prototype","entries"],"%ArrayProto_forEach%":["Array","prototype","forEach"],"%ArrayProto_keys%":["Array","prototype","keys"],"%ArrayProto_values%":["Array","prototype","values"],"%AsyncFunctionPrototype%":["AsyncFunction","prototype"],"%AsyncGenerator%":["AsyncGeneratorFunction","prototype"],"%AsyncGeneratorPrototype%":["AsyncGeneratorFunction","prototype","prototype"],"%BooleanPrototype%":["Boolean","prototype"],"%DataViewPrototype%":["DataView","prototype"],"%DatePrototype%":["Date","prototype"],"%ErrorPrototype%":["Error","prototype"],"%EvalErrorPrototype%":["EvalError","prototype"],"%Float32ArrayPrototype%":["Float32Array","prototype"],"%Float64ArrayPrototype%":["Float64Array","prototype"],"%FunctionPrototype%":["Function","prototype"],"%Generator%":["GeneratorFunction","prototype"],"%GeneratorPrototype%":["GeneratorFunction","prototype","prototype"],"%Int8ArrayPrototype%":["Int8Array","prototype"],"%Int16ArrayPrototype%":["Int16Array","prototype"],"%Int32ArrayPrototype%":["Int32Array","prototype"],"%JSONParse%":["JSON","parse"],"%JSONStringify%":["JSON","stringify"],"%MapPrototype%":["Map","prototype"],"%NumberPrototype%":["Number","prototype"],"%ObjectPrototype%":["Object","prototype"],"%ObjProto_toString%":["Object","prototype","toString"],"%ObjProto_valueOf%":["Object","prototype","valueOf"],"%PromisePrototype%":["Promise","prototype"],"%PromiseProto_then%":["Promise","prototype","then"],"%Promise_all%":["Promise","all"],"%Promise_reject%":["Promise","reject"],"%Promise_resolve%":["Promise","resolve"],"%RangeErrorPrototype%":["RangeError","prototype"],"%ReferenceErrorPrototype%":["ReferenceError","prototype"],"%RegExpPrototype%":["RegExp","prototype"],"%SetPrototype%":["Set","prototype"],"%SharedArrayBufferPrototype%":["SharedArrayBuffer","prototype"],"%StringPrototype%":["String","prototype"],"%SymbolPrototype%":["Symbol","prototype"],"%SyntaxErrorPrototype%":["SyntaxError","prototype"],"%TypedArrayPrototype%":["TypedArray","prototype"],"%TypeErrorPrototype%":["TypeError","prototype"],"%Uint8ArrayPrototype%":["Uint8Array","prototype"],"%Uint8ClampedArrayPrototype%":["Uint8ClampedArray","prototype"],"%Uint16ArrayPrototype%":["Uint16Array","prototype"],"%Uint32ArrayPrototype%":["Uint32Array","prototype"],"%URIErrorPrototype%":["URIError","prototype"],"%WeakMapPrototype%":["WeakMap","prototype"],"%WeakSetPrototype%":["WeakSet","prototype"]},vM=BB,yM=$B,mM=vM.call(Function.call,Array.prototype.concat),gM=vM.call(Function.apply,Array.prototype.splice),DM=vM.call(Function.call,String.prototype.replace),_M=vM.call(Function.call,String.prototype.slice),wM=vM.call(Function.call,RegExp.prototype.exec),OM=/[^%.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|%$))/g,EM=/\\(\\)?/g,jM=function(e,t){var r,n=e;if(yM(bM,n)&&(n="%"+(r=bM[n])[0]+"%"),yM(lM,n)){var o=lM[n];if(o===sM&&(o=hM(n)),void 0===o&&!t)throw new XB("intrinsic "+e+" exists, but is not available. Please file an issue!");return{alias:r,name:n,value:o}}throw new QB("intrinsic "+e+" does not exist!")},SM=function(e,t){if("string"!=typeof e||0===e.length)throw new XB("intrinsic name must be a non-empty string");if(arguments.length>1&&"boolean"!=typeof t)throw new XB('"allowMissing" argument must be a boolean');if(null===wM(/^%?[^%]*%?$/,e))throw new QB("`%` may not be present anywhere but at the beginning and end of the intrinsic name");var r=function(e){var t=_M(e,0,1),r=_M(e,-1);if("%"===t&&"%"!==r)throw new QB("invalid intrinsic syntax, expected closing `%`");if("%"===r&&"%"!==t)throw new QB("invalid intrinsic syntax, expected opening `%`");var n=[];return DM(e,OM,(function(e,t,r,o){n[n.length]=r?DM(o,EM,"$1"):t||e})),n}(e),n=r.length>0?r[0]:"",o=jM("%"+n+"%",t),i=o.name,a=o.value,u=!1,s=o.alias;s&&(n=s[0],gM(r,mM([0,1],s)));for(var c=1,l=!0;c<r.length;c+=1){var f=r[c],p=_M(f,0,1),d=_M(f,-1);if(('"'===p||"'"===p||"`"===p||'"'===d||"'"===d||"`"===d)&&p!==d)throw new QB("property names with quotes must have matching quotes");if("constructor"!==f&&l||(u=!0),yM(lM,i="%"+(n+="."+f)+"%"))a=lM[i];else if(null!=a){if(!(f in a)){if(!t)throw new XB("base intrinsic for "+e+" exists, but the property is not available.");return}if(rM&&c+1>=r.length){var h=rM(a,f);a=(l=!!h)&&"get"in h&&!("originalValue"in h.get)?h.get:a[f]}else l=yM(a,f),a=a[f];l&&!u&&(lM[i]=a)}}return a};function CM(){if(dM)return pM;dM=1;var e=SM("%Object.defineProperty%",!0)||!1;if(e)try{e({},"a",{value:1})}catch(t){e=!1}return pM=e}var xM=SM("%Object.getOwnPropertyDescriptor%",!0);if(xM)try{xM([],"length")}catch(e){xM=null}var FM=xM,PM=CM(),AM=IB,BM=LB,MM=FM,TM=CM(),kM=function(){return!!TM};kM.hasArrayLengthDefineBug=function(){if(!TM)return null;try{return 1!==TM([],"length",{value:1}).length}catch(e){return!0}};var RM=SM,IM=function(e,t,r){if(!e||"object"!=typeof e&&"function"!=typeof e)throw new BM("`obj` must be an object or a function`");if("string"!=typeof t&&"symbol"!=typeof t)throw new BM("`property` must be a string or a symbol`");if(arguments.length>3&&"boolean"!=typeof arguments[3]&&null!==arguments[3])throw new BM("`nonEnumerable`, if provided, must be a boolean or null");if(arguments.length>4&&"boolean"!=typeof arguments[4]&&null!==arguments[4])throw new BM("`nonWritable`, if provided, must be a boolean or null");if(arguments.length>5&&"boolean"!=typeof arguments[5]&&null!==arguments[5])throw new BM("`nonConfigurable`, if provided, must be a boolean or null");if(arguments.length>6&&"boolean"!=typeof arguments[6])throw new BM("`loose`, if provided, must be a boolean");var n=arguments.length>3?arguments[3]:null,o=arguments.length>4?arguments[4]:null,i=arguments.length>5?arguments[5]:null,a=arguments.length>6&&arguments[6],u=!!MM&&MM(e,t);if(PM)PM(e,t,{configurable:null===i&&u?u.configurable:!i,enumerable:null===n&&u?u.enumerable:!n,value:r,writable:null===o&&u?u.writable:!o});else{if(!a&&(n||o||i))throw new AM("This environment does not support defining a property as non-configurable, non-writable, or non-enumerable.");e[t]=r}},LM=kM(),NM=FM,UM=LB,GM=RM("%Math.floor%"),WM=function(e,t){if("function"!=typeof e)throw new UM("`fn` is not a function");if("number"!=typeof t||t<0||t>4294967295||GM(t)!==t)throw new UM("`length` must be a positive 32-bit integer");var r=arguments.length>2&&!!arguments[2],n=!0,o=!0;if("length"in e&&NM){var i=NM(e,"length");i&&!i.configurable&&(n=!1),i&&!i.writable&&(o=!1)}return(n||o||!r)&&(LM?IM(e,"length",t,!0,!0):IM(e,"length",t)),e};!function(e){var t=BB,r=SM,n=WM,o=LB,i=r("%Function.prototype.apply%"),a=r("%Function.prototype.call%"),u=r("%Reflect.apply%",!0)||t.call(a,i),s=CM(),c=r("%Math.max%");e.exports=function(e){if("function"!=typeof e)throw new o("a function is required");var r=u(t,a,arguments);return n(r,1+c(0,e.length-(arguments.length-1)),!0)};var l=function(){return u(t,i,arguments)};s?s(e.exports,"apply",{value:l}):e.exports.apply=l}(CB);var qM=CB.exports,VM=i.Stream,zM=qM;function $M(e,t,r){var n=zM(e||function(e){this.queue(e)}),o=zM(t||function(){this.queue(null)}),i=!1,a=!1,u=[],s=!1,c=new VM;function l(){for(;u.length&&!c.paused;){var e=u.shift();if(null===e)return c.emit("end");c.emit("data",e)}}return c.readable=!0,c.writable=!0,c.paused=!1,c.autoDestroy=!(r&&!1===r.autoDestroy),c.write=function(e){return n(this,e),!c.paused},c.queue=function(e){return s||(null===e&&(s=!0),u.push(e),l()),c},c.push=c.queue,c.on("end",(function(){c.readable=!1,!c.writable&&c.autoDestroy&&process.nextTick((function(){c.destroy()}))})),c.end=function(e){if(!i)return i=!0,arguments.length&&c.write(e),c.writable=!1,o(c),!c.readable&&c.autoDestroy&&c.destroy(),c},c.destroy=function(){if(!a)return a=!0,i=!0,u.length=0,c.writable=!1,c.readable=!1,c.emit("close"),c},c.pause=function(){if(!c.paused)return c.paused=!0,c},c.resume=function(){return c.paused&&(c.paused=!1,c.emit("resume")),l(),c.paused||c.emit("drain"),c},c}var KM=$M;$M.through=$M;var YM=h.getDefaultExportFromCjs(KM);const HM=i;var JM=class extends HM{#e=null;constructor(e={}){super(e),this.writable=this.readable=!0,this.muted=!1,this.on("pipe",this._onpipe),this.replace=e.replace,this._prompt=e.prompt||null,this._hadControl=!1}#t(e,t){return this._dest?this._dest[e]:this._src?this._src[e]:t}#r(e,...t){"function"==typeof this._dest?.[e]&&this._dest[e](...t),"function"==typeof this._src?.[e]&&this._src[e](...t)}get isTTY(){return null!==this.#e?this.#e:this.#t("isTTY",!1)}set isTTY(e){this.#e=e}get rows(){return this.#t("rows")}get columns(){return this.#t("columns")}mute(){this.muted=!0}unmute(){this.muted=!1}_onpipe(e){this._src=e}pipe(e,t){return this._dest=e,super.pipe(e,t)}pause(){if(this._src)return this._src.pause()}resume(){if(this._src)return this._src.resume()}write(e){if(this.muted){if(!this.replace)return!0;if(e.match(/^\u001b/))return 0===e.indexOf(this._prompt)&&(e=(e=e.slice(this._prompt.length)).replace(/./g,this.replace),e=this._prompt+e),this._hadControl=!0,this.emit("data",e);this._prompt&&this._hadControl&&0===e.indexOf(this._prompt)&&(this._hadControl=!1,this.emit("data",this._prompt),e=e.slice(this._prompt.length)),e=e.toString().replace(/./g,this.replace)}this.emit("data",e)}end(e){this.muted&&(e=e&&this.replace?e.toString().replace(/./g,this.replace):null),e&&this.emit("data",e),this.emit("end")}destroy(...e){return this.#r("destroy",...e)}destroySoon(...e){return this.#r("destroySoon",...e)}close(...e){return this.#r("close",...e)}},QM=h.getDefaultExportFromCjs(JM);class XM{constructor(e){this.rl||=m.createInterface(function(e={}){e.skipTTYChecks=void 0===e.skipTTYChecks||e.skipTTYChecks;const t=e.input||process.stdin;if(!e.skipTTYChecks&&!t.isTTY){const e=new Error("Prompts can not be meaningfully rendered in non-TTY environments");throw e.isTtyError=!0,e}const r=new QM;r.pipe(e.output||process.stdout);const n=r;return{terminal:!0,...e,input:t,output:n}}(e)),this.rl.resume(),this.onForceClose=this.onForceClose.bind(this),process.on("exit",this.onForceClose),this.rl.on("SIGINT",this.onForceClose)}onForceClose(){this.close(),process.kill(process.pid,"SIGINT"),console.log("")}close(){this.rl.removeListener("SIGINT",this.onForceClose),process.removeListener("exit",this.onForceClose),this.rl.output.unmute(),this.activePrompt&&"function"==typeof this.activePrompt.close&&this.activePrompt.close(),this.rl.output.end(),this.rl.pause(),this.rl.close()}}var ZM=Dy,eT=j_,tT=vm,rT=Function.prototype,nT=Object.prototype,oT=rT.toString,iT=nT.hasOwnProperty,aT=oT.call(Object);var uT=function(e){if(!tT(e)||"[object Object]"!=ZM(e))return!1;var t=eT(e);if(null===t)return!0;var r=iT.call(t,"constructor")&&t.constructor;return"function"==typeof r&&r instanceof r&&oT.call(r)==aT},sT=VD,cT=rj,lT=cm,fT=_y,pT=oj;var dT=function(e,t,r,n){if(!fT(e))return e;for(var o=-1,i=(t=cT(t,e)).length,a=i-1,u=e;null!=u&&++o<i;){var s=pT(t[o]),c=r;if("__proto__"===s||"constructor"===s||"prototype"===s)return e;if(o!=a){var l=u[s];void 0===(c=n?n(l,s,u):void 0)&&(c=fT(l)?l:lT(t[o+1])?[]:{})}sT(u,s,c),u=u[s]}return e},hT=dT;var bT=function(e,t,r){return null==e?e:hT(e,t,r)};const vT=function(e,t,r){return"function"!=typeof e[t]?Te.of(e):Te.from(Me(e[t])(r).then((r=>(e[t]=r,e))))},yT={isPlainObject:h.getDefaultExportFromCjs(uT),set:h.getDefaultExportFromCjs(bT),get:lj};class mT extends XM{constructor(e,t){super(t),this.prompts=e}run(e,t){yT.isPlainObject(t)?this.answers={...t}:this.answers={},yT.isPlainObject(e)&&(e=Object.values(e).every((e=>yT.isPlainObject(e)&&void 0===e.name))?Object.entries(e).map((([e,t])=>({name:e,...t}))):[e]);const r=Array.isArray(e)?Te.from(e):e;return this.process=r.pipe(Te.concatMap(this.processQuestion.bind(this)),Te.publish()),this.process.connect(),this.process.pipe(Te.reduce(((e,t)=>(yT.set(e,t.name,t.answer),e)),this.answers)).toPromise(Promise).then(this.onCompletion.bind(this),this.onError.bind(this))}onCompletion(){return this.close(),this.answers}onError(e){return this.close(),Promise.reject(e)}processQuestion(e){return e={...e},Te.defer((()=>Te.of(e).pipe(Te.concatMap(this.setDefaultType.bind(this)),Te.concatMap(this.filterIfRunnable.bind(this)),Te.concatMap((()=>vT(e,"message",this.answers))),Te.concatMap((()=>vT(e,"default",this.answers))),Te.concatMap((()=>vT(e,"choices",this.answers))),Te.concatMap(this.fetchAnswer.bind(this)))))}fetchAnswer(e){const t=this.prompts[e.type];return this.activePrompt=new t(e,this.rl,this.answers),Te.defer((()=>Te.from(this.activePrompt.run().then((t=>({name:e.name,answer:t}))))))}setDefaultType(e){return this.prompts[e.type]||(e.type="input"),Te.defer((()=>Te.of(e)))}filterIfRunnable(e){if(!0!==e.askAnswered&&void 0!==yT.get(this.answers,e.name))return Te.empty();if(!1===e.when)return Te.empty();if("function"!=typeof e.when)return Te.of(e);const{answers:t}=this;return Te.defer((()=>Te.from(Me(e.when)(t).then((t=>{if(t)return e}))).pipe(Te.filter((e=>null!=e)))))}}function gT(e){const t=function(r,n){let o;try{o=new mT(t.prompts,e)}catch(e){return Promise.reject(e)}const i=o.run(r,n);return i.ui=o,i};return t.prompts={},t.registerPrompt=function(e,r){return t.prompts[e]=r,this},t.restoreDefaultPrompts=function(){this.registerPrompt("list",oP),this.registerPrompt("input",iP),this.registerPrompt("number",aP),this.registerPrompt("confirm",uP),this.registerPrompt("rawlist",sP),this.registerPrompt("expand",cP),this.registerPrompt("checkbox",lP),this.registerPrompt("password",pP),this.registerPrompt("editor",jB)},t.restoreDefaultPrompts(),t}const DT=gT();const _T={prompt:DT,ui:{BottomBar:class extends XM{constructor(e={}){super(e),this.log=YM(this.writeLog.bind(this)),this.bottomBar=e.bottomBar||"",this.render()}render(){return this.write(this.bottomBar),this}clean(){return XF(this.rl,this.bottomBar.split("\n").length),this}updateBottomBar(e){return XF(this.rl,1),this.rl.output.unmute(),this.clean(),this.bottomBar=e,this.render(),this.rl.output.mute(),this}writeLog(e){return this.rl.output.unmute(),this.clean(),this.rl.output.write(this.enforceLF(e.toString())),this.render(),this.rl.output.mute(),this}enforceLF(e){return e.match(/[\r\n]$/)?e:e+"\n"}write(e){const t=e.split(/\n/);this.height=t.length,this.rl.setPrompt(t[t.length-1]),0===this.rl.output.rows&&0===this.rl.output.columns&&JF(this.rl,e.length+this.rl.line.length),this.rl.output.write(e)}},Prompt:mT},createPromptModule:gT,registerPrompt:function(e,t){DT.registerPrompt(e,t)},restoreDefaultPrompts:function(){DT.restoreDefaultPrompts()},Separator:iS};var wT="0.2.9";const OT=process.cwd();exports.createModule=async()=>{const e=await g.loadJSON(y.resolve(OT,"package.json")),t=await _T.prompt([{type:"list",name:"type",message:"请选择一个选项:",default:"react",choices:["vue","react"]},{type:"input",message:"workspaces name",name:"workspaces",validate:function(e){return!(e&&!v.existsSync(y.resolve(OT,e)))||"工作空间不存在"}},{type:"input",message:"package name",name:"name",validate:function(e){return!!e.replace(/\s/g,"")||"姓名不能为空,请重新输入"}},{type:"input",message:"version",name:"version",default:e.version}]),r="vue"===t.type,n=v.readFileSync(y.resolve(__dirname,r?"../../template/template.vue.package.json":"../../template/template.package.json"),"utf-8"),o=h.ejs.compile(n),i=y.resolve(OT,t.workspaces,t.name);v.existsSync(y.resolve(i))||v.mkdirSync(i),s.exec(`cd ${i}`,((e,n,a)=>{e?console.error(`错误: ${e.message}`):a?console.error(`错误: ${a}`):(h.createCwdConfig(i,t.name,r),v.mkdirSync(y.resolve(i,"public")),v.mkdirSync(y.resolve(i,"src")),v.writeFileSync(y.resolve(i,"package.json"),o({...t,coreVersion:`^${wT}`})),v.writeFileSync(y.resolve(i,"tsconfig.json"),'{\n "extends": ["./src/.gant/tsconfig.json"]\n }'),v.writeFileSync(y.resolve(i,"tsconfig.json"),'{\n "extends": ["./src/.gant/tsconfig.json"]\n }'))}))},exports.stringWidthExports=FS;
10
+ const CA=v,xA=y,FA=l,PA=function(){var e;return e=jA?process.env.TEMP||process.env.TMP||(process.env.SystemRoot||process.env.windir)+"\\temp":process.env.TMPDIR||process.env.TMP||process.env.TEMP||"/tmp",SA.test(e)&&(e=e.slice(0,-1)),e},AA=process.binding("constants"),BA=PA(),MA="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz",TA=/XXXXXX/,kA=3,RA=(AA.O_CREAT||AA.fs.O_CREAT)|(AA.O_EXCL||AA.fs.O_EXCL)|(AA.O_RDWR||AA.fs.O_RDWR),IA=AA.EBADF||AA.os.errno.EBADF,LA=AA.ENOENT||AA.os.errno.ENOENT,NA=[];var UA=!1,GA=!1;function WA(e){var t=[],r=null;try{r=FA.randomBytes(e)}catch(t){r=FA.pseudoRandomBytes(e)}for(var n=0;n<e;n++)t.push(MA[r[n]%MA.length]);return t.join("")}function qA(e){return void 0===e}function VA(e,t){return"function"==typeof e?[t||{},e]:qA(e)?[{},t]:[e,t]}function zA(e){if(e.name)return xA.join(e.dir||BA,e.name);if(e.template)return e.template.replace(TA,WA(6));const t=[e.prefix||"tmp-",process.pid,WA(12),e.postfix||""].join("");return xA.join(e.dir||BA,t)}function $A(e,t){var r=VA(e,t),n=r[0],o=r[1],i=n.name?1:n.tries||kA;return isNaN(i)||i<0?o(new Error("Invalid tries")):n.template&&!n.template.match(TA)?o(new Error("Invalid template provided")):void function e(){const t=zA(n);CA.stat(t,(function(r){if(!r)return i-- >0?e():o(new Error("Could not get a unique tmp filename, max tries reached "+t));o(null,t)}))}()}function KA(e){var t=VA(e)[0],r=t.name?1:t.tries||kA;if(isNaN(r)||r<0)throw new Error("Invalid tries");if(t.template&&!t.template.match(TA))throw new Error("Invalid template provided");do{const e=zA(t);try{CA.statSync(e)}catch(t){return e}}while(r-- >0);throw new Error("Could not get a unique tmp filename, max tries reached")}function YA(e){const t=[e];do{for(var r=t.pop(),n=!1,o=CA.readdirSync(r),i=0,a=o.length;i<a;i++){var u=xA.join(r,o[i]);CA.lstatSync(u).isDirectory()?(n||(n=!0,t.push(r)),t.push(u)):CA.unlinkSync(u)}n||CA.rmdirSync(r)}while(0!==t.length)}function HA(e,t,r){const n=QA((function(e){try{0<=e[0]&&CA.closeSync(e[0])}catch(e){if(!(t=e,eB(t,-IA,"EBADF")||ZA(e)))throw e}var t;try{CA.unlinkSync(e[1])}catch(e){if(!ZA(e))throw e}}),[t,e]);return r.keep||NA.unshift(n),n}function JA(e,t){const r=QA(t.unsafeCleanup?YA:CA.rmdirSync.bind(CA),e);return t.keep||NA.unshift(r),r}function QA(e,t){var r=!1;return function n(o){if(!r){const o=NA.indexOf(n);o>=0&&NA.splice(o,1),r=!0,e(t)}o&&o(null)}}function XA(){if(!GA||UA)for(;NA.length;)try{NA[0].call(null)}catch(e){}}function ZA(e){return eB(e,-LA,"ENOENT")}function eB(e,t,r){return e.code==t||e.code==r}const tB=process.versions.node.split(".").map((function(e){return parseInt(e,10)}));0===tB[0]&&(tB[1]<9||9===tB[1]&&tB[2]<5)&&process.addListener("uncaughtException",(function(e){throw GA=!0,XA(),e})),process.addListener("exit",(function(e){e&&(GA=!0),XA()})),EA.tmpdir=BA,EA.dir=function(e,t){var r=VA(e,t),n=r[0],o=r[1];$A(n,(function(e,t){if(e)return o(e);CA.mkdir(t,n.mode||448,(function(e){if(e)return o(e);o(null,t,JA(t,n))}))}))},EA.dirSync=function(e){var t=VA(e)[0];const r=KA(t);return CA.mkdirSync(r,t.mode||448),{name:r,removeCallback:JA(r,t)}},EA.file=function(e,t){var r=VA(e,t),n=r[0],o=r[1];n.postfix=qA(n.postfix)?".tmp":n.postfix,$A(n,(function(e,t){if(e)return o(e);CA.open(t,RA,n.mode||384,(function(e,r){return e?o(e):n.discardDescriptor?CA.close(r,(function(e){if(e){try{CA.unlinkSync(t)}catch(t){ZA(t)||(e=t)}return o(e)}o(null,t,void 0,HA(t,-1,n))})):n.detachDescriptor?o(null,t,r,HA(t,-1,n)):void o(null,t,r,HA(t,r,n))}))}))},EA.fileSync=function(e){var t=VA(e)[0];t.postfix=t.postfix||".tmp";const r=t.discardDescriptor||t.detachDescriptor,n=KA(t);var o=CA.openSync(n,RA,t.mode||384);return t.discardDescriptor&&(CA.closeSync(o),o=void 0),{name:n,fd:o,removeCallback:HA(n,r?-1:o,t)}},EA.tmpName=$A,EA.tmpNameSync=KA,EA.setGracefulCleanup=function(){UA=!0};var rB={},nB=h.commonjsGlobal&&h.commonjsGlobal.__extends||function(){var e=function(t,r){return e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)t.hasOwnProperty(r)&&(e[r]=t[r])},e(t,r)};return function(t,r){function n(){this.constructor=t}e(t,r),t.prototype=null===r?Object.create(r):(n.prototype=r.prototype,new n)}}();Object.defineProperty(rB,"__esModule",{value:!0});var oB=function(e){function t(t){var r=this.constructor,n=e.call(this,"Failed to create temporary file for editor")||this;n.originalError=t;var o=r.prototype;return Object.setPrototypeOf?Object.setPrototypeOf(n,o):n.__proto__=r.prototype,n}return nB(t,e),t}(Error);rB.CreateFileError=oB;var iB={},aB=h.commonjsGlobal&&h.commonjsGlobal.__extends||function(){var e=function(t,r){return e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)t.hasOwnProperty(r)&&(e[r]=t[r])},e(t,r)};return function(t,r){function n(){this.constructor=t}e(t,r),t.prototype=null===r?Object.create(r):(n.prototype=r.prototype,new n)}}();Object.defineProperty(iB,"__esModule",{value:!0});var uB=function(e){function t(t){var r=this.constructor,n=e.call(this,"Failed launch editor")||this;n.originalError=t;var o=r.prototype;return Object.setPrototypeOf?Object.setPrototypeOf(n,o):n.__proto__=r.prototype,n}return aB(t,e),t}(Error);iB.LaunchEditorError=uB;var sB={},cB=h.commonjsGlobal&&h.commonjsGlobal.__extends||function(){var e=function(t,r){return e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)t.hasOwnProperty(r)&&(e[r]=t[r])},e(t,r)};return function(t,r){function n(){this.constructor=t}e(t,r),t.prototype=null===r?Object.create(r):(n.prototype=r.prototype,new n)}}();Object.defineProperty(sB,"__esModule",{value:!0});var lB=function(e){function t(t){var r=this.constructor,n=e.call(this,"Failed to read temporary file")||this;n.originalError=t;var o=r.prototype;return Object.setPrototypeOf?Object.setPrototypeOf(n,o):n.__proto__=r.prototype,n}return cB(t,e),t}(Error);sB.ReadFileError=lB;var fB={},pB=h.commonjsGlobal&&h.commonjsGlobal.__extends||function(){var e=function(t,r){return e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)t.hasOwnProperty(r)&&(e[r]=t[r])},e(t,r)};return function(t,r){function n(){this.constructor=t}e(t,r),t.prototype=null===r?Object.create(r):(n.prototype=r.prototype,new n)}}();Object.defineProperty(fB,"__esModule",{value:!0});var dB=function(e){function t(t){var r=this.constructor,n=e.call(this,"Failed to cleanup temporary file")||this;n.originalError=t;var o=r.prototype;return Object.setPrototypeOf?Object.setPrototypeOf(n,o):n.__proto__=r.prototype,n}return pB(t,e),t}(Error);fB.RemoveFileError=dB,Object.defineProperty(dP,"__esModule",{value:!0});var hB=hP,bB=s,vB=v,yB=OA,mB=EA,gB=rB;dP.CreateFileError=gB.CreateFileError;var DB=iB;dP.LaunchEditorError=DB.LaunchEditorError;var _B=sB;dP.ReadFileError=_B.ReadFileError;var wB=fB;dP.RemoveFileError=wB.RemoveFileError,dP.edit=function(e,t){void 0===e&&(e="");var r=new EB(e,t);return r.run(),r.cleanup(),r.text};var OB=dP.editAsync=function(e,t,r){void 0===e&&(e="");var n=new EB(e,r);n.runAsync((function(e,r){if(e)setImmediate(t,e,null);else try{n.cleanup(),setImmediate(t,null,r)}catch(e){setImmediate(t,e,null)}}))},EB=function(){function e(e,t){void 0===e&&(e=""),this.text="",this.fileOptions={},this.text=e,t&&(this.fileOptions=t),this.determineEditor(),this.createTemporaryFile()}return e.splitStringBySpace=function(e){for(var t=[],r="",n=0;n<e.length;n++){var o=e[n];n>0&&" "===o&&"\\"!==e[n-1]&&r.length>0?(t.push(r),r=""):r+=o}return r.length>0&&t.push(r),t},Object.defineProperty(e.prototype,"temp_file",{get:function(){return console.log("DEPRECATED: temp_file. Use tempFile moving forward."),this.tempFile},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"last_exit_status",{get:function(){return console.log("DEPRECATED: last_exit_status. Use lastExitStatus moving forward."),this.lastExitStatus},enumerable:!0,configurable:!0}),e.prototype.run=function(){return this.launchEditor(),this.readTemporaryFile(),this.text},e.prototype.runAsync=function(e){var t=this;try{this.launchEditorAsync((function(){try{t.readTemporaryFile(),setImmediate(e,null,t.text)}catch(t){setImmediate(e,t,null)}}))}catch(t){setImmediate(e,t,null)}},e.prototype.cleanup=function(){this.removeTemporaryFile()},e.prototype.determineEditor=function(){var t=process.env.VISUAL?process.env.VISUAL:process.env.EDITOR?process.env.EDITOR:/^win/.test(process.platform)?"notepad":"vim",r=e.splitStringBySpace(t).map((function(e){return e.replace("\\ "," ")})),n=r.shift();this.editor={args:r,bin:n}},e.prototype.createTemporaryFile=function(){try{this.tempFile=mB.tmpNameSync(this.fileOptions);var e={encoding:"utf8"};this.fileOptions.hasOwnProperty("mode")&&(e.mode=this.fileOptions.mode),vB.writeFileSync(this.tempFile,this.text,e)}catch(e){throw new gB.CreateFileError(e)}},e.prototype.readTemporaryFile=function(){try{var e=vB.readFileSync(this.tempFile);if(0===e.length)this.text="";else{var t=hB.detect(e).toString();yB.encodingExists(t)||(t="utf8"),this.text=yB.decode(e,t)}}catch(e){throw new _B.ReadFileError(e)}},e.prototype.removeTemporaryFile=function(){try{vB.unlinkSync(this.tempFile)}catch(e){throw new wB.RemoveFileError(e)}},e.prototype.launchEditor=function(){try{var e=bB.spawnSync(this.editor.bin,this.editor.args.concat([this.tempFile]),{stdio:"inherit"});this.lastExitStatus=e.status}catch(e){throw new DB.LaunchEditorError(e)}},e.prototype.launchEditorAsync=function(e){var t=this;try{bB.spawn(this.editor.bin,this.editor.args.concat([this.tempFile]),{stdio:"inherit"}).on("exit",(function(r){t.lastExitStatus=r,setImmediate(e)}))}catch(e){throw new DB.LaunchEditorError(e)}},e}();dP.ExternalEditor=EB;class jB extends nP{_run(e){this.done=e,this.editorResult=new Te.Subject;const t=Jv(this.rl);this.lineSubscription=t.line.subscribe(this.startExternalEditor.bind(this));void 0===this.opt.waitUserInput||this.opt.waitUserInput||this.startExternalEditor();const r=this.handleSubmitEvents(this.editorResult);return r.success.forEach(this.onEnd.bind(this)),r.error.forEach(this.onError.bind(this)),this.currentText=this.opt.default,this.opt.default=null,this.render(),this}render(e){let t="",r=this.getQuestion();"answered"===this.status?r+=K.dim("Received"):r+=K.dim("Press <enter> to launch your preferred editor."),e&&(t=K.red(">> ")+e),this.screen.render(r,t)}startExternalEditor(){this.rl.pause(),OB(this.currentText,this.endExternalEditor.bind(this),{postfix:this.opt.postfix??".txt"})}endExternalEditor(e,t){this.rl.resume(),e?this.editorResult.error(e):this.editorResult.next(t)}onEnd(e){this.editorResult.unsubscribe(),this.lineSubscription.unsubscribe(),this.answer=e.value,this.status="answered",this.render(),this.screen.done(),this.done(this.answer)}onError(e){this.render(e.isValid)}}var SB,CB={exports:{}},xB=Object.prototype.toString,FB=Math.max,PB=function(e,t){for(var r=[],n=0;n<e.length;n+=1)r[n]=e[n];for(var o=0;o<t.length;o+=1)r[o+e.length]=t[o];return r},AB=function(e){var t=this;if("function"!=typeof t||"[object Function]"!==xB.apply(t))throw new TypeError("Function.prototype.bind called on incompatible "+t);for(var r,n=function(e,t){for(var r=[],n=t||0,o=0;n<e.length;n+=1,o+=1)r[o]=e[n];return r}(arguments,1),o=FB(0,t.length-n.length),i=[],a=0;a<o;a++)i[a]="$"+a;if(r=Function("binder","return function ("+function(e,t){for(var r="",n=0;n<e.length;n+=1)r+=e[n],n+1<e.length&&(r+=t);return r}(i,",")+"){ return binder.apply(this,arguments); }")((function(){if(this instanceof r){var o=t.apply(this,PB(n,arguments));return Object(o)===o?o:this}return t.apply(e,PB(n,arguments))})),t.prototype){var u=function(){};u.prototype=t.prototype,r.prototype=new u,u.prototype=null}return r},BB=Function.prototype.bind||AB,MB=Error,TB=EvalError,kB=RangeError,RB=ReferenceError,IB=SyntaxError,LB=TypeError,NB=URIError,UB="undefined"!=typeof Symbol&&Symbol,GB=function(){if("function"!=typeof Symbol||"function"!=typeof Object.getOwnPropertySymbols)return!1;if("symbol"==typeof Symbol.iterator)return!0;var e={},t=Symbol("test"),r=Object(t);if("string"==typeof t)return!1;if("[object Symbol]"!==Object.prototype.toString.call(t))return!1;if("[object Symbol]"!==Object.prototype.toString.call(r))return!1;for(t in e[t]=42,e)return!1;if("function"==typeof Object.keys&&0!==Object.keys(e).length)return!1;if("function"==typeof Object.getOwnPropertyNames&&0!==Object.getOwnPropertyNames(e).length)return!1;var n=Object.getOwnPropertySymbols(e);if(1!==n.length||n[0]!==t)return!1;if(!Object.prototype.propertyIsEnumerable.call(e,t))return!1;if("function"==typeof Object.getOwnPropertyDescriptor){var o=Object.getOwnPropertyDescriptor(e,t);if(42!==o.value||!0!==o.enumerable)return!1}return!0},WB={__proto__:null,foo:{}},qB=Object,VB=Function.prototype.call,zB=Object.prototype.hasOwnProperty,$B=BB.call(VB,zB),KB=MB,YB=TB,HB=kB,JB=RB,QB=IB,XB=LB,ZB=NB,eM=Function,tM=function(e){try{return eM('"use strict"; return ('+e+").constructor;")()}catch(e){}},rM=Object.getOwnPropertyDescriptor;if(rM)try{rM({},"")}catch(e){rM=null}var nM=function(){throw new XB},oM=rM?function(){try{return nM}catch(e){try{return rM(arguments,"callee").get}catch(e){return nM}}}():nM,iM="function"==typeof UB&&"function"==typeof Symbol&&"symbol"==typeof UB("foo")&&"symbol"==typeof Symbol("bar")&&GB(),aM={__proto__:WB}.foo===WB.foo&&!(WB instanceof qB),uM=Object.getPrototypeOf||(aM?function(e){return e.__proto__}:null),sM={},cM="undefined"!=typeof Uint8Array&&uM?uM(Uint8Array):SB,lM={__proto__:null,"%AggregateError%":"undefined"==typeof AggregateError?SB:AggregateError,"%Array%":Array,"%ArrayBuffer%":"undefined"==typeof ArrayBuffer?SB:ArrayBuffer,"%ArrayIteratorPrototype%":iM&&uM?uM([][Symbol.iterator]()):SB,"%AsyncFromSyncIteratorPrototype%":SB,"%AsyncFunction%":sM,"%AsyncGenerator%":sM,"%AsyncGeneratorFunction%":sM,"%AsyncIteratorPrototype%":sM,"%Atomics%":"undefined"==typeof Atomics?SB:Atomics,"%BigInt%":"undefined"==typeof BigInt?SB:BigInt,"%BigInt64Array%":"undefined"==typeof BigInt64Array?SB:BigInt64Array,"%BigUint64Array%":"undefined"==typeof BigUint64Array?SB:BigUint64Array,"%Boolean%":Boolean,"%DataView%":"undefined"==typeof DataView?SB:DataView,"%Date%":Date,"%decodeURI%":decodeURI,"%decodeURIComponent%":decodeURIComponent,"%encodeURI%":encodeURI,"%encodeURIComponent%":encodeURIComponent,"%Error%":KB,"%eval%":eval,"%EvalError%":YB,"%Float32Array%":"undefined"==typeof Float32Array?SB:Float32Array,"%Float64Array%":"undefined"==typeof Float64Array?SB:Float64Array,"%FinalizationRegistry%":"undefined"==typeof FinalizationRegistry?SB:FinalizationRegistry,"%Function%":eM,"%GeneratorFunction%":sM,"%Int8Array%":"undefined"==typeof Int8Array?SB:Int8Array,"%Int16Array%":"undefined"==typeof Int16Array?SB:Int16Array,"%Int32Array%":"undefined"==typeof Int32Array?SB:Int32Array,"%isFinite%":isFinite,"%isNaN%":isNaN,"%IteratorPrototype%":iM&&uM?uM(uM([][Symbol.iterator]())):SB,"%JSON%":"object"==typeof JSON?JSON:SB,"%Map%":"undefined"==typeof Map?SB:Map,"%MapIteratorPrototype%":"undefined"!=typeof Map&&iM&&uM?uM((new Map)[Symbol.iterator]()):SB,"%Math%":Math,"%Number%":Number,"%Object%":Object,"%parseFloat%":parseFloat,"%parseInt%":parseInt,"%Promise%":"undefined"==typeof Promise?SB:Promise,"%Proxy%":"undefined"==typeof Proxy?SB:Proxy,"%RangeError%":HB,"%ReferenceError%":JB,"%Reflect%":"undefined"==typeof Reflect?SB:Reflect,"%RegExp%":RegExp,"%Set%":"undefined"==typeof Set?SB:Set,"%SetIteratorPrototype%":"undefined"!=typeof Set&&iM&&uM?uM((new Set)[Symbol.iterator]()):SB,"%SharedArrayBuffer%":"undefined"==typeof SharedArrayBuffer?SB:SharedArrayBuffer,"%String%":String,"%StringIteratorPrototype%":iM&&uM?uM(""[Symbol.iterator]()):SB,"%Symbol%":iM?Symbol:SB,"%SyntaxError%":QB,"%ThrowTypeError%":oM,"%TypedArray%":cM,"%TypeError%":XB,"%Uint8Array%":"undefined"==typeof Uint8Array?SB:Uint8Array,"%Uint8ClampedArray%":"undefined"==typeof Uint8ClampedArray?SB:Uint8ClampedArray,"%Uint16Array%":"undefined"==typeof Uint16Array?SB:Uint16Array,"%Uint32Array%":"undefined"==typeof Uint32Array?SB:Uint32Array,"%URIError%":ZB,"%WeakMap%":"undefined"==typeof WeakMap?SB:WeakMap,"%WeakRef%":"undefined"==typeof WeakRef?SB:WeakRef,"%WeakSet%":"undefined"==typeof WeakSet?SB:WeakSet};if(uM)try{null.error}catch(e){var fM=uM(uM(e));lM["%Error.prototype%"]=fM}var pM,dM,hM=function e(t){var r;if("%AsyncFunction%"===t)r=tM("async function () {}");else if("%GeneratorFunction%"===t)r=tM("function* () {}");else if("%AsyncGeneratorFunction%"===t)r=tM("async function* () {}");else if("%AsyncGenerator%"===t){var n=e("%AsyncGeneratorFunction%");n&&(r=n.prototype)}else if("%AsyncIteratorPrototype%"===t){var o=e("%AsyncGenerator%");o&&uM&&(r=uM(o.prototype))}return lM[t]=r,r},bM={__proto__:null,"%ArrayBufferPrototype%":["ArrayBuffer","prototype"],"%ArrayPrototype%":["Array","prototype"],"%ArrayProto_entries%":["Array","prototype","entries"],"%ArrayProto_forEach%":["Array","prototype","forEach"],"%ArrayProto_keys%":["Array","prototype","keys"],"%ArrayProto_values%":["Array","prototype","values"],"%AsyncFunctionPrototype%":["AsyncFunction","prototype"],"%AsyncGenerator%":["AsyncGeneratorFunction","prototype"],"%AsyncGeneratorPrototype%":["AsyncGeneratorFunction","prototype","prototype"],"%BooleanPrototype%":["Boolean","prototype"],"%DataViewPrototype%":["DataView","prototype"],"%DatePrototype%":["Date","prototype"],"%ErrorPrototype%":["Error","prototype"],"%EvalErrorPrototype%":["EvalError","prototype"],"%Float32ArrayPrototype%":["Float32Array","prototype"],"%Float64ArrayPrototype%":["Float64Array","prototype"],"%FunctionPrototype%":["Function","prototype"],"%Generator%":["GeneratorFunction","prototype"],"%GeneratorPrototype%":["GeneratorFunction","prototype","prototype"],"%Int8ArrayPrototype%":["Int8Array","prototype"],"%Int16ArrayPrototype%":["Int16Array","prototype"],"%Int32ArrayPrototype%":["Int32Array","prototype"],"%JSONParse%":["JSON","parse"],"%JSONStringify%":["JSON","stringify"],"%MapPrototype%":["Map","prototype"],"%NumberPrototype%":["Number","prototype"],"%ObjectPrototype%":["Object","prototype"],"%ObjProto_toString%":["Object","prototype","toString"],"%ObjProto_valueOf%":["Object","prototype","valueOf"],"%PromisePrototype%":["Promise","prototype"],"%PromiseProto_then%":["Promise","prototype","then"],"%Promise_all%":["Promise","all"],"%Promise_reject%":["Promise","reject"],"%Promise_resolve%":["Promise","resolve"],"%RangeErrorPrototype%":["RangeError","prototype"],"%ReferenceErrorPrototype%":["ReferenceError","prototype"],"%RegExpPrototype%":["RegExp","prototype"],"%SetPrototype%":["Set","prototype"],"%SharedArrayBufferPrototype%":["SharedArrayBuffer","prototype"],"%StringPrototype%":["String","prototype"],"%SymbolPrototype%":["Symbol","prototype"],"%SyntaxErrorPrototype%":["SyntaxError","prototype"],"%TypedArrayPrototype%":["TypedArray","prototype"],"%TypeErrorPrototype%":["TypeError","prototype"],"%Uint8ArrayPrototype%":["Uint8Array","prototype"],"%Uint8ClampedArrayPrototype%":["Uint8ClampedArray","prototype"],"%Uint16ArrayPrototype%":["Uint16Array","prototype"],"%Uint32ArrayPrototype%":["Uint32Array","prototype"],"%URIErrorPrototype%":["URIError","prototype"],"%WeakMapPrototype%":["WeakMap","prototype"],"%WeakSetPrototype%":["WeakSet","prototype"]},vM=BB,yM=$B,mM=vM.call(Function.call,Array.prototype.concat),gM=vM.call(Function.apply,Array.prototype.splice),DM=vM.call(Function.call,String.prototype.replace),_M=vM.call(Function.call,String.prototype.slice),wM=vM.call(Function.call,RegExp.prototype.exec),OM=/[^%.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|%$))/g,EM=/\\(\\)?/g,jM=function(e,t){var r,n=e;if(yM(bM,n)&&(n="%"+(r=bM[n])[0]+"%"),yM(lM,n)){var o=lM[n];if(o===sM&&(o=hM(n)),void 0===o&&!t)throw new XB("intrinsic "+e+" exists, but is not available. Please file an issue!");return{alias:r,name:n,value:o}}throw new QB("intrinsic "+e+" does not exist!")},SM=function(e,t){if("string"!=typeof e||0===e.length)throw new XB("intrinsic name must be a non-empty string");if(arguments.length>1&&"boolean"!=typeof t)throw new XB('"allowMissing" argument must be a boolean');if(null===wM(/^%?[^%]*%?$/,e))throw new QB("`%` may not be present anywhere but at the beginning and end of the intrinsic name");var r=function(e){var t=_M(e,0,1),r=_M(e,-1);if("%"===t&&"%"!==r)throw new QB("invalid intrinsic syntax, expected closing `%`");if("%"===r&&"%"!==t)throw new QB("invalid intrinsic syntax, expected opening `%`");var n=[];return DM(e,OM,(function(e,t,r,o){n[n.length]=r?DM(o,EM,"$1"):t||e})),n}(e),n=r.length>0?r[0]:"",o=jM("%"+n+"%",t),i=o.name,a=o.value,u=!1,s=o.alias;s&&(n=s[0],gM(r,mM([0,1],s)));for(var c=1,l=!0;c<r.length;c+=1){var f=r[c],p=_M(f,0,1),d=_M(f,-1);if(('"'===p||"'"===p||"`"===p||'"'===d||"'"===d||"`"===d)&&p!==d)throw new QB("property names with quotes must have matching quotes");if("constructor"!==f&&l||(u=!0),yM(lM,i="%"+(n+="."+f)+"%"))a=lM[i];else if(null!=a){if(!(f in a)){if(!t)throw new XB("base intrinsic for "+e+" exists, but the property is not available.");return}if(rM&&c+1>=r.length){var h=rM(a,f);a=(l=!!h)&&"get"in h&&!("originalValue"in h.get)?h.get:a[f]}else l=yM(a,f),a=a[f];l&&!u&&(lM[i]=a)}}return a};function CM(){if(dM)return pM;dM=1;var e=SM("%Object.defineProperty%",!0)||!1;if(e)try{e({},"a",{value:1})}catch(t){e=!1}return pM=e}var xM=SM("%Object.getOwnPropertyDescriptor%",!0);if(xM)try{xM([],"length")}catch(e){xM=null}var FM=xM,PM=CM(),AM=IB,BM=LB,MM=FM,TM=CM(),kM=function(){return!!TM};kM.hasArrayLengthDefineBug=function(){if(!TM)return null;try{return 1!==TM([],"length",{value:1}).length}catch(e){return!0}};var RM=SM,IM=function(e,t,r){if(!e||"object"!=typeof e&&"function"!=typeof e)throw new BM("`obj` must be an object or a function`");if("string"!=typeof t&&"symbol"!=typeof t)throw new BM("`property` must be a string or a symbol`");if(arguments.length>3&&"boolean"!=typeof arguments[3]&&null!==arguments[3])throw new BM("`nonEnumerable`, if provided, must be a boolean or null");if(arguments.length>4&&"boolean"!=typeof arguments[4]&&null!==arguments[4])throw new BM("`nonWritable`, if provided, must be a boolean or null");if(arguments.length>5&&"boolean"!=typeof arguments[5]&&null!==arguments[5])throw new BM("`nonConfigurable`, if provided, must be a boolean or null");if(arguments.length>6&&"boolean"!=typeof arguments[6])throw new BM("`loose`, if provided, must be a boolean");var n=arguments.length>3?arguments[3]:null,o=arguments.length>4?arguments[4]:null,i=arguments.length>5?arguments[5]:null,a=arguments.length>6&&arguments[6],u=!!MM&&MM(e,t);if(PM)PM(e,t,{configurable:null===i&&u?u.configurable:!i,enumerable:null===n&&u?u.enumerable:!n,value:r,writable:null===o&&u?u.writable:!o});else{if(!a&&(n||o||i))throw new AM("This environment does not support defining a property as non-configurable, non-writable, or non-enumerable.");e[t]=r}},LM=kM(),NM=FM,UM=LB,GM=RM("%Math.floor%"),WM=function(e,t){if("function"!=typeof e)throw new UM("`fn` is not a function");if("number"!=typeof t||t<0||t>4294967295||GM(t)!==t)throw new UM("`length` must be a positive 32-bit integer");var r=arguments.length>2&&!!arguments[2],n=!0,o=!0;if("length"in e&&NM){var i=NM(e,"length");i&&!i.configurable&&(n=!1),i&&!i.writable&&(o=!1)}return(n||o||!r)&&(LM?IM(e,"length",t,!0,!0):IM(e,"length",t)),e};!function(e){var t=BB,r=SM,n=WM,o=LB,i=r("%Function.prototype.apply%"),a=r("%Function.prototype.call%"),u=r("%Reflect.apply%",!0)||t.call(a,i),s=CM(),c=r("%Math.max%");e.exports=function(e){if("function"!=typeof e)throw new o("a function is required");var r=u(t,a,arguments);return n(r,1+c(0,e.length-(arguments.length-1)),!0)};var l=function(){return u(t,i,arguments)};s?s(e.exports,"apply",{value:l}):e.exports.apply=l}(CB);var qM=CB.exports,VM=i.Stream,zM=qM;function $M(e,t,r){var n=zM(e||function(e){this.queue(e)}),o=zM(t||function(){this.queue(null)}),i=!1,a=!1,u=[],s=!1,c=new VM;function l(){for(;u.length&&!c.paused;){var e=u.shift();if(null===e)return c.emit("end");c.emit("data",e)}}return c.readable=!0,c.writable=!0,c.paused=!1,c.autoDestroy=!(r&&!1===r.autoDestroy),c.write=function(e){return n(this,e),!c.paused},c.queue=function(e){return s||(null===e&&(s=!0),u.push(e),l()),c},c.push=c.queue,c.on("end",(function(){c.readable=!1,!c.writable&&c.autoDestroy&&process.nextTick((function(){c.destroy()}))})),c.end=function(e){if(!i)return i=!0,arguments.length&&c.write(e),c.writable=!1,o(c),!c.readable&&c.autoDestroy&&c.destroy(),c},c.destroy=function(){if(!a)return a=!0,i=!0,u.length=0,c.writable=!1,c.readable=!1,c.emit("close"),c},c.pause=function(){if(!c.paused)return c.paused=!0,c},c.resume=function(){return c.paused&&(c.paused=!1,c.emit("resume")),l(),c.paused||c.emit("drain"),c},c}var KM=$M;$M.through=$M;var YM=h.getDefaultExportFromCjs(KM);const HM=i;var JM=class extends HM{#e=null;constructor(e={}){super(e),this.writable=this.readable=!0,this.muted=!1,this.on("pipe",this._onpipe),this.replace=e.replace,this._prompt=e.prompt||null,this._hadControl=!1}#t(e,t){return this._dest?this._dest[e]:this._src?this._src[e]:t}#r(e,...t){"function"==typeof this._dest?.[e]&&this._dest[e](...t),"function"==typeof this._src?.[e]&&this._src[e](...t)}get isTTY(){return null!==this.#e?this.#e:this.#t("isTTY",!1)}set isTTY(e){this.#e=e}get rows(){return this.#t("rows")}get columns(){return this.#t("columns")}mute(){this.muted=!0}unmute(){this.muted=!1}_onpipe(e){this._src=e}pipe(e,t){return this._dest=e,super.pipe(e,t)}pause(){if(this._src)return this._src.pause()}resume(){if(this._src)return this._src.resume()}write(e){if(this.muted){if(!this.replace)return!0;if(e.match(/^\u001b/))return 0===e.indexOf(this._prompt)&&(e=(e=e.slice(this._prompt.length)).replace(/./g,this.replace),e=this._prompt+e),this._hadControl=!0,this.emit("data",e);this._prompt&&this._hadControl&&0===e.indexOf(this._prompt)&&(this._hadControl=!1,this.emit("data",this._prompt),e=e.slice(this._prompt.length)),e=e.toString().replace(/./g,this.replace)}this.emit("data",e)}end(e){this.muted&&(e=e&&this.replace?e.toString().replace(/./g,this.replace):null),e&&this.emit("data",e),this.emit("end")}destroy(...e){return this.#r("destroy",...e)}destroySoon(...e){return this.#r("destroySoon",...e)}close(...e){return this.#r("close",...e)}},QM=h.getDefaultExportFromCjs(JM);class XM{constructor(e){this.rl||=m.createInterface(function(e={}){e.skipTTYChecks=void 0===e.skipTTYChecks||e.skipTTYChecks;const t=e.input||process.stdin;if(!e.skipTTYChecks&&!t.isTTY){const e=new Error("Prompts can not be meaningfully rendered in non-TTY environments");throw e.isTtyError=!0,e}const r=new QM;r.pipe(e.output||process.stdout);const n=r;return{terminal:!0,...e,input:t,output:n}}(e)),this.rl.resume(),this.onForceClose=this.onForceClose.bind(this),process.on("exit",this.onForceClose),this.rl.on("SIGINT",this.onForceClose)}onForceClose(){this.close(),process.kill(process.pid,"SIGINT"),console.log("")}close(){this.rl.removeListener("SIGINT",this.onForceClose),process.removeListener("exit",this.onForceClose),this.rl.output.unmute(),this.activePrompt&&"function"==typeof this.activePrompt.close&&this.activePrompt.close(),this.rl.output.end(),this.rl.pause(),this.rl.close()}}var ZM=Dy,eT=j_,tT=vm,rT=Function.prototype,nT=Object.prototype,oT=rT.toString,iT=nT.hasOwnProperty,aT=oT.call(Object);var uT=function(e){if(!tT(e)||"[object Object]"!=ZM(e))return!1;var t=eT(e);if(null===t)return!0;var r=iT.call(t,"constructor")&&t.constructor;return"function"==typeof r&&r instanceof r&&oT.call(r)==aT},sT=VD,cT=rj,lT=cm,fT=_y,pT=oj;var dT=function(e,t,r,n){if(!fT(e))return e;for(var o=-1,i=(t=cT(t,e)).length,a=i-1,u=e;null!=u&&++o<i;){var s=pT(t[o]),c=r;if("__proto__"===s||"constructor"===s||"prototype"===s)return e;if(o!=a){var l=u[s];void 0===(c=n?n(l,s,u):void 0)&&(c=fT(l)?l:lT(t[o+1])?[]:{})}sT(u,s,c),u=u[s]}return e},hT=dT;var bT=function(e,t,r){return null==e?e:hT(e,t,r)};const vT=function(e,t,r){return"function"!=typeof e[t]?Te.of(e):Te.from(Me(e[t])(r).then((r=>(e[t]=r,e))))},yT={isPlainObject:h.getDefaultExportFromCjs(uT),set:h.getDefaultExportFromCjs(bT),get:lj};class mT extends XM{constructor(e,t){super(t),this.prompts=e}run(e,t){yT.isPlainObject(t)?this.answers={...t}:this.answers={},yT.isPlainObject(e)&&(e=Object.values(e).every((e=>yT.isPlainObject(e)&&void 0===e.name))?Object.entries(e).map((([e,t])=>({name:e,...t}))):[e]);const r=Array.isArray(e)?Te.from(e):e;return this.process=r.pipe(Te.concatMap(this.processQuestion.bind(this)),Te.publish()),this.process.connect(),this.process.pipe(Te.reduce(((e,t)=>(yT.set(e,t.name,t.answer),e)),this.answers)).toPromise(Promise).then(this.onCompletion.bind(this),this.onError.bind(this))}onCompletion(){return this.close(),this.answers}onError(e){return this.close(),Promise.reject(e)}processQuestion(e){return e={...e},Te.defer((()=>Te.of(e).pipe(Te.concatMap(this.setDefaultType.bind(this)),Te.concatMap(this.filterIfRunnable.bind(this)),Te.concatMap((()=>vT(e,"message",this.answers))),Te.concatMap((()=>vT(e,"default",this.answers))),Te.concatMap((()=>vT(e,"choices",this.answers))),Te.concatMap(this.fetchAnswer.bind(this)))))}fetchAnswer(e){const t=this.prompts[e.type];return this.activePrompt=new t(e,this.rl,this.answers),Te.defer((()=>Te.from(this.activePrompt.run().then((t=>({name:e.name,answer:t}))))))}setDefaultType(e){return this.prompts[e.type]||(e.type="input"),Te.defer((()=>Te.of(e)))}filterIfRunnable(e){if(!0!==e.askAnswered&&void 0!==yT.get(this.answers,e.name))return Te.empty();if(!1===e.when)return Te.empty();if("function"!=typeof e.when)return Te.of(e);const{answers:t}=this;return Te.defer((()=>Te.from(Me(e.when)(t).then((t=>{if(t)return e}))).pipe(Te.filter((e=>null!=e)))))}}function gT(e){const t=function(r,n){let o;try{o=new mT(t.prompts,e)}catch(e){return Promise.reject(e)}const i=o.run(r,n);return i.ui=o,i};return t.prompts={},t.registerPrompt=function(e,r){return t.prompts[e]=r,this},t.restoreDefaultPrompts=function(){this.registerPrompt("list",oP),this.registerPrompt("input",iP),this.registerPrompt("number",aP),this.registerPrompt("confirm",uP),this.registerPrompt("rawlist",sP),this.registerPrompt("expand",cP),this.registerPrompt("checkbox",lP),this.registerPrompt("password",pP),this.registerPrompt("editor",jB)},t.restoreDefaultPrompts(),t}const DT=gT();const _T={prompt:DT,ui:{BottomBar:class extends XM{constructor(e={}){super(e),this.log=YM(this.writeLog.bind(this)),this.bottomBar=e.bottomBar||"",this.render()}render(){return this.write(this.bottomBar),this}clean(){return XF(this.rl,this.bottomBar.split("\n").length),this}updateBottomBar(e){return XF(this.rl,1),this.rl.output.unmute(),this.clean(),this.bottomBar=e,this.render(),this.rl.output.mute(),this}writeLog(e){return this.rl.output.unmute(),this.clean(),this.rl.output.write(this.enforceLF(e.toString())),this.render(),this.rl.output.mute(),this}enforceLF(e){return e.match(/[\r\n]$/)?e:e+"\n"}write(e){const t=e.split(/\n/);this.height=t.length,this.rl.setPrompt(t[t.length-1]),0===this.rl.output.rows&&0===this.rl.output.columns&&JF(this.rl,e.length+this.rl.line.length),this.rl.output.write(e)}},Prompt:mT},createPromptModule:gT,registerPrompt:function(e,t){DT.registerPrompt(e,t)},restoreDefaultPrompts:function(){DT.restoreDefaultPrompts()},Separator:iS};var wT="0.2.12";const OT=process.cwd();exports.createModule=async()=>{const e=await g.loadJSON(y.resolve(OT,"package.json")),t=await _T.prompt([{type:"list",name:"type",message:"请选择一个选项:",default:"react",choices:["vue","react"]},{type:"input",message:"workspaces name",name:"workspaces",validate:function(e){return!(e&&!v.existsSync(y.resolve(OT,e)))||"工作空间不存在"}},{type:"input",message:"package name",name:"name",validate:function(e){return!!e.replace(/\s/g,"")||"姓名不能为空,请重新输入"}},{type:"input",message:"version",name:"version",default:e.version}]),r="vue"===t.type,n=v.readFileSync(y.resolve(__dirname,r?"../../template/template.vue.package.json":"../../template/template.package.json"),"utf-8"),o=h.ejs.compile(n),i=y.resolve(OT,t.workspaces,t.name);v.existsSync(y.resolve(i))||v.mkdirSync(i),s.exec(`cd ${i}`,((e,n,a)=>{e?console.error(`错误: ${e.message}`):a?console.error(`错误: ${a}`):(h.createCwdConfig(i,t.name,r),v.mkdirSync(y.resolve(i,"public")),v.mkdirSync(y.resolve(i,"src")),v.writeFileSync(y.resolve(i,"package.json"),o({...t,coreVersion:`^${wT}`})),v.writeFileSync(y.resolve(i,"tsconfig.json"),'{\n "extends": ["./src/.gant/tsconfig.json"]\n }'),v.writeFileSync(y.resolve(i,"tsconfig.json"),'{\n "extends": ["./src/.gant/tsconfig.json"]\n }'))}))},exports.stringWidthExports=FS;
package/lib/cli/index.js CHANGED
@@ -1,2 +1,2 @@
1
1
  #!/usr/bin/env node
2
- "use strict";var e,t=require("fs"),i=require("./config/index.js"),n=require("./webpack/Webpack.js"),r=require("chokidar"),s=require("path"),o=require("./utils/index.js"),a=require("./routes/index.js"),l=require("./tsconfig/index.js"),h=require("./copyfiles/index.js"),c=require("./create/config/index.js"),u=require("./create/module/index.js"),p=require("events"),m=require("child_process"),d=require("process"),g=require("./i18n/index.js");function f(e="development"){process.env.SRC="true",process.env.NODE_ENV=e;const c=process.cwd(),u=new i.Config({cwd:c});let p=u.getUserConfig();function m(r){const u=o.getSrcPath(),p=s.resolve(c,u,".gant");o.generateDir(p);const m=t.readFileSync(s.resolve(__dirname,"./template/core.txt"),"utf-8");o.writeFileToJS(s.resolve(p,"index.ts"),m);const d={[r?.name||"@@"]:c,...r?.resolve?.alias},g=[c];i.keys(r.packages).map((e=>{const t=r.packages[e];d[e]=t,g.push(t)})),l.generateTsConfig(p,{paths:d,includes:g,cwd:c,vue:r.vue});const f=[...i.keys(r.packages),c];h.copyAppsFiles(p,[...i.keys(r.packages),c]),h.copyPublicFiles(p,f.map((e=>s.resolve(e,"public")))),a.generateRoutes(s.resolve(p,"./routes"),r.routes);return new n.Webpack(r,c,e)}u.configFiles;let d=m(p);if("development"!==e)d.runBuild();else{d.runServer();let g=null;function f(e){g=r.watch(u.configFiles?.map((e=>s.dirname(e))),{}),g.on("change",(e=>{d.devServer.stop(),p=u.getUserConfig(),d=m(p),d.runServer({open:!1})}))}f()}}function _(){const e=process.cwd(),n=new i.Config({cwd:e});let r=n.getMsUserConfig();const a=o.getSrcPath(),h=s.resolve(e,a,".gant");t.existsSync(h)||t.mkdirSync(h,{recursive:!0});const c=t.readFileSync(s.resolve(__dirname,"./template/core.txt"),"utf-8");o.writeFileToJS(s.resolve(h,"index.ts"),c);const u=r?.name||"main",p={},m={...r?.resolve?.alias},d=[e];return r.mfa?.entry&&(p[u]={entry:r.mfa?.entry,publicPath:"string"==typeof r.mfa?.publicPath?[r.mfa?.publicPath]:r.mfa?.publicPath,port:r.mfa?.port,htmlTemplatePath:r.mfa.htmlTemplatePath,apps:[e],base:r.mfa.base,isMaster:!0}),r.mfa.pages?.map?.((e=>{const t="string"==typeof e.path?[e.path]:e.path,i="string"==typeof e.publicPath?[e.publicPath]:e.publicPath;d.push(...t),p[e.name]={entry:e.entry||r.mfa.subEntry,publicPath:i,port:e.port,htmlTemplatePath:e.htmlTemplatePath,apps:t,base:e.base,url:e.url}})),o.writeFileToJS(s.resolve(h,"appMaps.ts"),`export default ${JSON.stringify(p)}`),l.generateTsConfig(h,{includes:d,paths:m,cwd:e,vue:r.vue,createIncludes:!1}),{userConfig:r,msName:u,msConfig:p,configManager:n}}function v(e="development",t){process.env.SRC="false",process.env.NODE_ENV=e;const{userConfig:n,msName:r,msConfig:s,configManager:o}=_();if(i.isEmpty(n.mfa))return;const a=t||r,l=s[a];l&&b(o,e,n,a,l)}function b(e,l,u,p,m,d=!0){const g=process.cwd(),f=o.getSrcPath(),v=i.cloneDeep(u);const O=m.apps?.map?.((e=>i.Config.getMainConfigFile({cwd:e})))?.filter?.((e=>!!e));let C=function(){const r=s.resolve(g,f,`.gant/${p}`);o.generateDir(r),h.copyAppsFiles(r,m.apps),h.copyPublicFiles(r,m.publicPath);const u=t.readFileSync(s.resolve(__dirname,"./template/msentry.txt"),"utf-8"),d=c.ejs.compile(u);t.writeFileSync(s.resolve(r,"index.ts"),d({entry:s.join("../../",m.entry)}));const _=e.getMsPagesUserConfig(m.apps);return a.generateRoutes(s.resolve(r,"./routes"),_.routes),v.entry={index:s.resolve(r,"index.ts")},v.base=i.get(m,"base","/"),v.define={...v.define,APP_NAME:p},v.devServer={...v.devServer,port:m.port,static:{directory:s.resolve(r,"public")}},v.output={...v.output,chunkLoadingGlobal:`webpackJsonp_${p}`,chunkFilename:`${p}.[name].[id].[contenthash].js`,path:s.resolve(g,`dist/${p}`)},v.outputPathDir=s.resolve(g,`dist/${p}`),v.publicPathDir=s.resolve(g,`.gant/${p}/public`),new n.Webpack(v,g,l)}();if("development"!==l)C.runBuild();else{C.runServer({open:d});let A=null;function w(t){A=r.watch(t),A.on("change",(t=>{C.devServer.stop();const{userConfig:i,msConfig:n}=_();A.close(),b(e,l,i,p,n[p],!1)}))}w(O)}}require("./config/defineConfig.js"),require("./utils/getJavascriptfile.js"),require("module"),require("webpack"),require("webpack-dev-server"),require("./webpack/config/index.js"),require("./webpack/config/production.config.js"),require("./webpack/plugins/copy.js"),require("mini-css-extract-plugin"),require("css-minimizer-webpack-plugin"),require("terser-webpack-plugin"),require("compression-webpack-plugin"),require("./webpack/config/default.config.js"),require("html-webpack-plugin"),require("./webpack/config/cssRules.js"),require("./webpack/config/development.config.js"),require("./webpack/config/analyzer.config.js"),require("url"),require("os"),require("tty"),require("fs/promises"),require("assert"),require("v8"),require("util"),require("readline"),require("stream"),require("buffer"),require("string_decoder"),require("crypto"),require("node:process"),require("node:os"),require("node:tty"),require("node:assert"),require("node:readline"),require("http"),require("https"),require("net"),require("./i18n/utils.js"),require("zlib"),exports.Env=void 0,(e=exports.Env||(exports.Env={})).development="development",e.production="production",e.test="test";var O={exports:{}},C={},A={};let w=class extends Error{constructor(e,t,i){super(i),Error.captureStackTrace(this,this.constructor),this.name=this.constructor.name,this.code=t,this.exitCode=e,this.nestedError=void 0}};A.CommanderError=w,A.InvalidArgumentError=class extends w{constructor(e){super(1,"commander.invalidArgument",e),Error.captureStackTrace(this,this.constructor),this.name=this.constructor.name}};const{InvalidArgumentError:x}=A;C.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 x(`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}},C.humanReadableArgName=function(e){const t=e.name()+(!0===e.variadic?"...":"");return e.required?"<"+t+">":"["+t+"]"};var y={},E={};const{humanReadableArgName:k}=C;E.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[,i,n]=e._helpCommandnameAndArgs.match(/([^ ]+) *(.*)/),r=e.createCommand(i).helpOption(!1);r.description(e._helpCommandDescription),n&&r.arguments(n),t.push(r)}return this.sortSubcommands&&t.sort(((e,t)=>e.name().localeCompare(t.name()))),t}compareOptions(e,t){const i=e=>e.short?e.short.replace(/^-/,""):e.long.replace(/^--/,"");return i(e).localeCompare(i(t))}visibleOptions(e){const t=e.options.filter((e=>!e.hidden)),i=e._hasHelpOption&&e._helpShortFlag&&!e._findOption(e._helpShortFlag),n=e._hasHelpOption&&!e._findOption(e._helpLongFlag);if(i||n){let r;r=i?n?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 i=e.parent;i;i=i.parent){const e=i.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=>k(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,i)=>Math.max(e,t.subcommandTerm(i).length)),0)}longestOptionTermLength(e,t){return t.visibleOptions(e).reduce(((e,i)=>Math.max(e,t.optionTerm(i).length)),0)}longestGlobalOptionTermLength(e,t){return t.visibleGlobalOptions(e).reduce(((e,i)=>Math.max(e,t.optionTerm(i).length)),0)}longestArgumentTermLength(e,t){return t.visibleArguments(e).reduce(((e,i)=>Math.max(e,t.argumentTerm(i).length)),0)}commandUsage(e){let t=e._name;e._aliases[0]&&(t=t+"|"+e._aliases[0]);let i="";for(let t=e.parent;t;t=t.parent)i=t.name()+" "+i;return i+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 i=`(${t.join(", ")})`;return e.description?`${e.description} ${i}`:i}return e.description}formatHelp(e,t){const i=t.padWidth(e,t),n=t.helpWidth||80;function r(e,r){if(r){const s=`${e.padEnd(i+2)}${r}`;return t.wrap(s,n-2,i+2)}return e}function s(e){return e.join("\n").replace(/^/gm," ".repeat(2))}let o=[`Usage: ${t.commandUsage(e)}`,""];const a=t.commandDescription(e);a.length>0&&(o=o.concat([t.wrap(a,n,0),""]));const l=t.visibleArguments(e).map((e=>r(t.argumentTerm(e),t.argumentDescription(e))));l.length>0&&(o=o.concat(["Arguments:",s(l),""]));const h=t.visibleOptions(e).map((e=>r(t.optionTerm(e),t.optionDescription(e))));if(h.length>0&&(o=o.concat(["Options:",s(h),""])),this.showGlobalOptions){const i=t.visibleGlobalOptions(e).map((e=>r(t.optionTerm(e),t.optionDescription(e))));i.length>0&&(o=o.concat(["Global Options:",s(i),""]))}const c=t.visibleCommands(e).map((e=>r(t.subcommandTerm(e),t.subcommandDescription(e))));return c.length>0&&(o=o.concat(["Commands:",s(c),""])),o.join("\n")}padWidth(e,t){return Math.max(t.longestOptionTermLength(e,t),t.longestGlobalOptionTermLength(e,t),t.longestSubcommandTermLength(e,t),t.longestArgumentTermLength(e,t))}wrap(e,t,i,n=40){const r=new RegExp("[\\n][ \\f\\t\\v   -    \ufeff]+");if(e.match(r))return e;const s=t-i;if(s<n)return e;const o=e.slice(0,i),a=e.slice(i).replace("\r\n","\n"),l=" ".repeat(i),h="\\s​",c=new RegExp(`\n|.{1,${s-1}}([${h}]|$)|[^${h}]+?([${h}]|$)`,"g");return o+(a.match(c)||[]).map(((e,t)=>"\n"===e?"":(t>0?l:"")+e.trimEnd())).join("\n")}};var $={};const{InvalidArgumentError:S}=A;function H(e){let t,i;const n=e.split(/[ |,]+/);return n.length>1&&!/^[[<]/.test(n[1])&&(t=n.shift()),i=n.shift(),!t&&/^-[^-]$/.test(i)&&(t=i,i=void 0),{shortFlag:t,longFlag:i}}$.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 i=H(e);this.short=i.shortFlag,this.long=i.longFlag,this.negate=!1,this.long&&(this.negate=this.long.startsWith("--no-")),this.defaultValue=void 0,this.defaultValueDescription=void 0,this.presetArg=void 0,this.envVar=void 0,this.parseArg=void 0,this.hidden=!1,this.argChoices=void 0,this.conflictsWith=[],this.implied=void 0}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 S(`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}},$.splitOptionFlags=H,$.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 i=t.attributeName();if(!this.dualOptions.has(i))return!0;const n=this.negativeOptions.get(i).presetArg,r=void 0!==n&&n;return t.negate===(r===e)}};var V={};const F=3;V.suggestSimilar=function(e,t){if(!t||0===t.length)return"";t=Array.from(new Set(t));const i=e.startsWith("--");i&&(e=e.slice(2),t=t.map((e=>e.slice(2))));let n=[],r=F;return t.forEach((t=>{if(t.length<=1)return;const i=function(e,t){if(Math.abs(e.length-t.length)>F)return Math.max(e.length,t.length);const i=[];for(let t=0;t<=e.length;t++)i[t]=[t];for(let e=0;e<=t.length;e++)i[0][e]=e;for(let n=1;n<=t.length;n++)for(let r=1;r<=e.length;r++){let s=1;s=e[r-1]===t[n-1]?0:1,i[r][n]=Math.min(i[r-1][n]+1,i[r][n-1]+1,i[r-1][n-1]+s),r>1&&n>1&&e[r-1]===t[n-2]&&e[r-2]===t[n-1]&&(i[r][n]=Math.min(i[r][n],i[r-2][n-2]+1))}return i[e.length][t.length]}(e,t),s=Math.max(e.length,t.length);(s-i)/s>.4&&(i<r?(r=i,n=[t]):i===r&&n.push(t))})),n.sort(((e,t)=>e.localeCompare(t))),i&&(n=n.map((e=>`--${e}`))),n.length>1?`\n(Did you mean one of ${n.join(", ")}?)`:1===n.length?`\n(Did you mean ${n[0]}?)`:""};const q=p.EventEmitter,P=m,D=s,N=t,j=d,{Argument:T,humanReadableArgName:M}=C,{CommanderError:I}=A,{Help:W}=E,{Option:L,splitOptionFlags:U,DualOptions:G}=$,{suggestSimilar:R}=V;function J(e,t){e._hasHelpOption&&t.find((t=>t===e._helpLongFlag||t===e._helpShortFlag))&&(e.outputHelp(),e._exit(0,"commander.helpDisplayed","(outputHelp)"))}function z(e){return e.map((e=>{if(!e.startsWith("--inspect"))return e;let t,i,n="127.0.0.1",r="9229";return null!==(i=e.match(/^(--inspect(-brk)?)$/))?t=i[1]:null!==(i=e.match(/^(--inspect(-brk|-port)?)=([^:]+)$/))?(t=i[1],/^\d+$/.test(i[3])?r=i[3]:n=i[3]):null!==(i=e.match(/^(--inspect(-brk|-port)?)=([^:]+):(\d+)$/))&&(t=i[1],n=i[3],r=i[4]),t&&"0"!==r?`${t}=${n}:${parseInt(r)+1}`:e}))}y.Command=class e extends q{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=>j.stdout.write(e),writeErr:e=>j.stderr.write(e),getOutHelpWidth:()=>j.stdout.isTTY?j.stdout.columns:void 0,getErrHelpWidth:()=>j.stderr.isTTY?j.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,i){let n=t,r=i;"object"==typeof n&&null!==n&&(r=n,n=null),r=r||{};const[,s,o]=e.match(/([^ ]+) *(.*)/),a=this.createCommand(s);return n&&(a.description(n),a._executableHandler=!0),r.isDefault&&(this._defaultCommandName=a._name),a._hidden=!(!r.noHelp&&!r.hidden),a._executableFile=r.executableFile||null,o&&a.arguments(o),this.commands.push(a),a.parent=this,a.copyInheritedSettings(this),n?this:a}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 T(e,t)}argument(e,t,i,n){const r=this.createArgument(e,t);return"function"==typeof i?r.default(n).argParser(i):r.default(i),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 i=["preSubcommand","preAction","postAction"];if(!i.includes(e))throw new Error(`Unexpected value for event passed to hook : '${e}'.\nExpecting one of '${i.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,i){this._exitCallback&&this._exitCallback(new I(e,t,i)),j.exit(e)}action(e){return this._actionHandler=t=>{const i=this.registeredArguments.length,n=t.slice(0,i);return this._storeOptionsAsProperties?n[i]=this:n[i]=this.opts(),n.push(this),e.apply(this,n)},this}createOption(e,t){return new L(e,t)}_callParseArg(e,t,i,n){try{return e.parseArg(t,i)}catch(e){if("commander.invalidArgument"===e.code){const t=`${n} ${e.message}`;this.error(t,{exitCode:e.exitCode,code:e.code})}throw e}}addOption(e){const t=e.name(),i=e.attributeName();if(e.negate){const t=e.long.replace(/^--no-/,"--");this._findOption(t)||this.setOptionValueWithSource(i,void 0===e.defaultValue||e.defaultValue,"default")}else void 0!==e.defaultValue&&this.setOptionValueWithSource(i,e.defaultValue,"default");this.options.push(e);const n=(t,n,r)=>{null==t&&void 0!==e.presetArg&&(t=e.presetArg);const s=this.getOptionValue(i);null!==t&&e.parseArg?t=this._callParseArg(e,t,s,n):null!==t&&e.variadic&&(t=e._concatValue(t,s)),null==t&&(t=!e.negate&&(!(!e.isBoolean()&&!e.optional)||"")),this.setOptionValueWithSource(i,t,r)};return this.on("option:"+t,(t=>{const i=`error: option '${e.flags}' argument '${t}' is invalid.`;n(t,i,"cli")})),e.envVar&&this.on("optionEnv:"+t,(t=>{const i=`error: option '${e.flags}' value '${t}' from env '${e.envVar}' is invalid.`;n(t,i,"env")})),this}_optionEx(e,t,i,n,r){if("object"==typeof t&&t instanceof L)throw new Error("To add an Option object use addOption() instead of option() or requiredOption()");const s=this.createOption(t,i);if(s.makeOptionMandatory(!!e.mandatory),"function"==typeof n)s.default(r).argParser(n);else if(n instanceof RegExp){const e=n;n=(t,i)=>{const n=e.exec(t);return n?n[0]:i},s.default(r).argParser(n)}else s.default(n);return this.addOption(s)}option(e,t,i,n){return this._optionEx({},e,t,i,n)}requiredOption(e,t,i,n){return this._optionEx({mandatory:!0},e,t,i,n)}combineFlagAndOptionalValue(e=!0){return this._combineFlagAndOptionalValue=!!e,this}allowUnknownOption(e=!0){return this._allowUnknownOption=!!e,this}allowExcessArguments(e=!0){return this._allowExcessArguments=!!e,this}enablePositionalOptions(e=!0){return this._enablePositionalOptions=!!e,this}passThroughOptions(e=!0){if(this._passThroughOptions=!!e,this.parent&&e&&!this.parent._enablePositionalOptions)throw new Error("passThroughOptions can not be used without turning on enablePositionalOptions for parent command(s)");return this}storeOptionsAsProperties(e=!0){if(this.options.length)throw new Error("call .storeOptionsAsProperties() before adding options");return this._storeOptionsAsProperties=!!e,this}getOptionValue(e){return this._storeOptionsAsProperties?this[e]:this._optionValues[e]}setOptionValue(e,t){return this.setOptionValueWithSource(e,t,void 0)}setOptionValueWithSource(e,t,i){return this._storeOptionsAsProperties?this[e]=t:this._optionValues[e]=t,this._optionValueSources[e]=i,this}getOptionValueSource(e){return this._optionValueSources[e]}getOptionValueSourceWithGlobals(e){let t;return this._getCommandAndAncestors().forEach((i=>{void 0!==i.getOptionValueSource(e)&&(t=i.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 i;switch(t=t||{},void 0===e&&(e=j.argv,j.versions&&j.versions.electron&&(t.from="electron")),this.rawArgs=e.slice(),t.from){case void 0:case"node":this._scriptPath=e[1],i=e.slice(2);break;case"electron":j.defaultApp?(this._scriptPath=e[1],i=e.slice(2)):i=e.slice(1);break;case"user":i=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",i}parse(e,t){const i=this._prepareUserArgs(e,t);return this._parseCommand([],i),this}async parseAsync(e,t){const i=this._prepareUserArgs(e,t);return await this._parseCommand([],i),this}_executeSubCommand(e,t){t=t.slice();let i=!1;const n=[".js",".ts",".tsx",".mjs",".cjs"];function r(e,t){const i=D.resolve(e,t);if(N.existsSync(i))return i;if(n.includes(D.extname(t)))return;const r=n.find((e=>N.existsSync(`${i}${e}`)));return r?`${i}${r}`:void 0}this._checkForMissingMandatoryOptions(),this._checkForConflictingOptions();let s,o=e._executableFile||`${this._name}-${e._name}`,a=this._executableDir||"";if(this._scriptPath){let e;try{e=N.realpathSync(this._scriptPath)}catch(t){e=this._scriptPath}a=D.resolve(D.dirname(e),a)}if(a){let t=r(a,o);if(!t&&!e._executableFile&&this._scriptPath){const i=D.basename(this._scriptPath,D.extname(this._scriptPath));i!==this._name&&(t=r(a,`${i}-${e._name}`))}o=t||o}if(i=n.includes(D.extname(o)),"win32"!==j.platform?i?(t.unshift(o),t=z(j.execArgv).concat(t),s=P.spawn(j.argv[0],t,{stdio:"inherit"})):s=P.spawn(o,t,{stdio:"inherit"}):(t.unshift(o),t=z(j.execArgv).concat(t),s=P.spawn(j.execPath,t,{stdio:"inherit"})),!s.killed){["SIGUSR1","SIGUSR2","SIGTERM","SIGINT","SIGHUP"].forEach((e=>{j.on(e,(()=>{!1===s.killed&&null===s.exitCode&&s.kill(e)}))}))}const l=this._exitCallback;l?s.on("close",(()=>{l(new I(j.exitCode||0,"commander.executeSubCommandAsync","(close)"))})):s.on("close",j.exit.bind(j)),s.on("error",(t=>{if("ENOENT"===t.code){const t=a?`searched for local subcommand relative to directory '${a}'`:"no directory for search for local subcommand, use .executableDir() to supply a custom directory",i=`'${o}' 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(i)}if("EACCES"===t.code)throw new Error(`'${o}' not executable`);if(l){const e=new I(1,"commander.executeSubCommandAsync","(error)");e.nestedError=t,l(e)}else j.exit(1)})),this.runningCommand=s}_dispatchSubcommand(e,t,i){const n=this._findCommand(e);let r;return n||this.help({error:!0}),r=this._chainOrCallSubCommandHook(r,n,"preSubcommand"),r=this._chainOrCall(r,(()=>{if(!n._executableHandler)return n._parseCommand(t,i);this._executeSubCommand(n,t.concat(i))})),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,i)=>{let n=t;if(null!==t&&e.parseArg){const r=`error: command-argument value '${t}' is invalid for argument '${e.name()}'.`;n=this._callParseArg(e,t,i,r)}return n};this._checkNumberOfArguments();const t=[];this.registeredArguments.forEach(((i,n)=>{let r=i.defaultValue;i.variadic?n<this.args.length?(r=this.args.slice(n),i.parseArg&&(r=r.reduce(((t,n)=>e(i,n,t)),i.defaultValue))):void 0===r&&(r=[]):n<this.args.length&&(r=this.args[n],i.parseArg&&(r=e(i,r,i.defaultValue))),t[n]=r})),this.processedArgs=t}_chainOrCall(e,t){return e&&e.then&&"function"==typeof e.then?e.then((()=>t())):t()}_chainOrCallHooks(e,t){let i=e;const n=[];return this._getCommandAndAncestors().reverse().filter((e=>void 0!==e._lifeCycleHooks[t])).forEach((e=>{e._lifeCycleHooks[t].forEach((t=>{n.push({hookedCommand:e,callback:t})}))})),"postAction"===t&&n.reverse(),n.forEach((e=>{i=this._chainOrCall(i,(()=>e.callback(e.hookedCommand,this)))})),i}_chainOrCallSubCommandHook(e,t,i){let n=e;return void 0!==this._lifeCycleHooks[i]&&this._lifeCycleHooks[i].forEach((e=>{n=this._chainOrCall(n,(()=>e(this,t)))})),n}_parseCommand(e,t){const i=this.parseOptions(t);if(this._parseOptionsEnv(),this._parseOptionsImplied(),e=e.concat(i.operands),t=i.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,i.unknown),this._checkForMissingMandatoryOptions(),this._checkForConflictingOptions();const n=()=>{i.unknown.length>0&&this.unknownOption(i.unknown[0])},r=`command:${this.name()}`;if(this._actionHandler){let i;return n(),this._processArguments(),i=this._chainOrCallHooks(i,"preAction"),i=this._chainOrCall(i,(()=>this._actionHandler(this.processedArgs))),this.parent&&(i=this._chainOrCall(i,(()=>{this.parent.emit(r,e,t)}))),i=this._chainOrCallHooks(i,"postAction"),i}if(this.parent&&this.parent.listenerCount(r))n(),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():(n(),this._processArguments())}else this.commands.length?(n(),this.help({error:!0})):(n(),this._processArguments())}_findCommand(e){if(e)return this.commands.find((t=>t._name===e||t._aliases.includes(e)))}_findOption(e){return this.options.find((t=>t.is(e)))}_checkForMissingMandatoryOptions(){this._getCommandAndAncestors().forEach((e=>{e.options.forEach((t=>{t.mandatory&&void 0===e.getOptionValue(t.attributeName())&&e.missingMandatoryOptionValue(t)}))}))}_checkForConflictingLocalOptions(){const e=this.options.filter((e=>{const t=e.attributeName();return void 0!==this.getOptionValue(t)&&"default"!==this.getOptionValueSource(t)})),t=e.filter((e=>e.conflictsWith.length>0));t.forEach((t=>{const i=e.find((e=>t.conflictsWith.includes(e.attributeName())));i&&this._conflictingOption(t,i)}))}_checkForConflictingOptions(){this._getCommandAndAncestors().forEach((e=>{e._checkForConflictingLocalOptions()}))}parseOptions(e){const t=[],i=[];let n=t;const r=e.slice();function s(e){return e.length>1&&"-"===e[0]}let o=null;for(;r.length;){const e=r.shift();if("--"===e){n===i&&n.push(e),n.push(...r);break}if(!o||s(e)){if(o=null,s(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&&!s(r[0])&&(e=r.shift()),this.emit(`option:${t.name()}`,e)}else this.emit(`option:${t.name()}`);o=t.variadic?t:null;continue}}if(e.length>2&&"-"===e[0]&&"-"!==e[1]){const t=this._findOption(`-${e[1]}`);if(t){t.required||t.optional&&this._combineFlagAndOptionalValue?this.emit(`option:${t.name()}`,e.slice(2)):(this.emit(`option:${t.name()}`),r.unshift(`-${e.slice(2)}`));continue}}if(/^--[^=]+=/.test(e)){const t=e.indexOf("="),i=this._findOption(e.slice(0,t));if(i&&(i.required||i.optional)){this.emit(`option:${i.name()}`,e.slice(t+1));continue}}if(s(e)&&(n=i),(this._enablePositionalOptions||this._passThroughOptions)&&0===t.length&&0===i.length){if(this._findCommand(e)){t.push(e),r.length>0&&i.push(...r);break}if(e===this._helpCommandName&&this._hasImplicitHelpCommand()){t.push(e),r.length>0&&t.push(...r);break}if(this._defaultCommandName){i.push(e),r.length>0&&i.push(...r);break}}if(this._passThroughOptions){n.push(e),r.length>0&&n.push(...r);break}n.push(e)}else this.emit(`option:${o.name()}`,e)}return{operands:t,unknown:i}}opts(){if(this._storeOptionsAsProperties){const e={},t=this.options.length;for(let i=0;i<t;i++){const t=this.options[i].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 i=t||{},n=i.exitCode||1,r=i.code||"commander.error";this._exit(n,r,e)}_parseOptionsEnv(){this.options.forEach((e=>{if(e.envVar&&e.envVar in j.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()}`,j.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((i=>void 0!==i.implied&&t(i.attributeName())&&e.valueFromOption(this.getOptionValue(i.attributeName()),i))).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 i=e=>{const t=e.attributeName(),i=this.getOptionValue(t),n=this.options.find((e=>e.negate&&t===e.attributeName())),r=this.options.find((e=>!e.negate&&t===e.attributeName()));return n&&(void 0===n.presetArg&&!1===i||void 0!==n.presetArg&&i===n.presetArg)?n:r||e},n=e=>{const t=i(e),n=t.attributeName();return"env"===this.getOptionValueSource(n)?`environment variable '${t.envVar}'`:`option '${t.flags}'`},r=`error: ${n(e)} cannot be used with ${n(t)}`;this.error(r,{code:"commander.conflictingOption"})}unknownOption(e){if(this._allowUnknownOption)return;let t="";if(e.startsWith("--")&&this._showSuggestionAfterError){let i=[],n=this;do{const e=n.createHelp().visibleOptions(n).filter((e=>e.long)).map((e=>e.long));i=i.concat(e),n=n.parent}while(n&&!n._enablePositionalOptions);t=R(e,i)}const i=`error: unknown option '${e}'${t}`;this.error(i,{code:"commander.unknownOption"})}_excessArguments(e){if(this._allowExcessArguments)return;const t=this.registeredArguments.length,i=1===t?"":"s",n=`error: too many arguments${this.parent?` for '${this.name()}'`:""}. Expected ${t} argument${i} but got ${e.length}.`;this.error(n,{code:"commander.excessArguments"})}unknownCommand(){const e=this.args[0];let t="";if(this._showSuggestionAfterError){const i=[];this.createHelp().visibleCommands(this).forEach((e=>{i.push(e.name()),e.alias()&&i.push(e.alias())})),t=R(e,i)}const i=`error: unknown command '${e}'${t}`;this.error(i,{code:"commander.unknownCommand"})}version(e,t,i){if(void 0===e)return this._version;this._version=e,t=t||"-V, --version",i=i||"output the version number";const n=this.createOption(t,i);return this._versionOptionName=n.attributeName(),this.options.push(n),this.on("option:"+n.name(),(()=>{this._outputConfiguration.writeOut(`${e}\n`),this._exit(0,"commander.version",e)})),this}description(e,t){return void 0===e&&void 0===t?this._description:(this._description=e,t&&(this._argsDescription=t),this)}summary(e){return void 0===e?this._summary:(this._summary=e,this)}alias(e){if(void 0===e)return this._aliases[0];let t=this;if(0!==this.commands.length&&this.commands[this.commands.length-1]._executableHandler&&(t=this.commands[this.commands.length-1]),e===t._name)throw new Error("Command alias can't be the same as its name");return t._aliases.push(e),this}aliases(e){return void 0===e?this._aliases:(e.forEach((e=>this.alias(e))),this)}usage(e){if(void 0===e){if(this._usage)return this._usage;const e=this.registeredArguments.map((e=>M(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=D.basename(e,D.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 i;return i=t.error?e=>this._outputConfiguration.writeErr(e):e=>this._outputConfiguration.writeOut(e),t.write=e.write||i,t.command=this,t}outputHelp(e){let t;"function"==typeof e&&(t=e,e=void 0);const i=this._getHelpContext(e);this._getCommandAndAncestors().reverse().forEach((e=>e.emit("beforeAllHelp",i))),this.emit("beforeHelp",i);let n=this.helpInformation(i);if(t&&(n=t(n),"string"!=typeof n&&!Buffer.isBuffer(n)))throw new Error("outputHelp callback must return a string or a Buffer");i.write(n),this._helpLongFlag&&this.emit(this._helpLongFlag),this.emit("afterHelp",i),this._getCommandAndAncestors().forEach((e=>e.emit("afterAllHelp",i)))}helpOption(e,t){if("boolean"==typeof e)return this._hasHelpOption=e,this;this._helpFlags=e||this._helpFlags,this._helpDescription=t||this._helpDescription;const i=U(this._helpFlags);return this._helpShortFlag=i.shortFlag,this._helpLongFlag=i.longFlag,this}help(e){this.outputHelp(e);let t=j.exitCode||0;0===t&&e&&"function"!=typeof e&&e.error&&(t=1),this._exit(t,"commander.help","(outputHelp)")}addHelpText(e,t){const i=["beforeAll","before","after","afterAll"];if(!i.includes(e))throw new Error(`Unexpected value for position to addHelpText.\nExpecting one of '${i.join("', '")}'`);const n=`${e}Help`;return this.on(n,(e=>{let i;i="function"==typeof t?t({error:e.error,command:e.command}):t,i&&e.write(`${i}\n`)})),this}},function(e,t){const{Argument:i}=C,{Command:n}=y,{CommanderError:r,InvalidArgumentError:s}=A,{Help:o}=E,{Option:a}=$;(t=e.exports=new n).program=t,t.Command=n,t.Option=a,t.Argument=i,t.Help=o,t.CommanderError=r,t.InvalidArgumentError=s,t.InvalidOptionArgumentError=s}(O,O.exports);var B=O.exports,Y=c.getDefaultExportFromCjs(B);const{program:K,createCommand:Q,createArgument:X,createOption:Z,CommanderError:ee,InvalidArgumentError:te,InvalidOptionArgumentError:ie,Command:ne,Argument:re,Option:se,Help:oe}=Y,ae=new ne;ae.version("1.0.0","-v, --version","gant-core version"),ae.command("default",{isDefault:!0,noHelp:!0,hidden:!0}).action((()=>f())),ae.command("build").description("build cli").action((()=>f("build"))),ae.command("analyzer").description("bundle-analyzer").action((()=>f("analyzer"))),ae.command("i18n").arguments("[currentLanguage] [targetLanguage]").description("i18n translation").action(g.i18n),ae.command("create").description("创建项目").action((()=>u.createModule())),ae.command("mfa").arguments("[name]").action((e=>{v("development",e)})),ae.command("mfa-build").arguments("[name]").action((e=>{v("build",e)})),ae.command("mfa-analyzer").arguments("[name]").action((e=>{v("analyzer",e)}));(async()=>{try{ae.parse(process.argv)}catch(e){console.log("Start Error",g.color.red(e?.message))}})();
2
+ "use strict";var e,t=require("fs"),i=require("./config/index.js"),n=require("./webpack/Webpack.js"),r=require("chokidar"),s=require("path"),o=require("./utils/index.js"),a=require("./routes/index.js"),l=require("./tsconfig/index.js"),h=require("./copyfiles/index.js"),c=require("./create/config/index.js"),u=require("./create/module/index.js"),p=require("events"),m=require("child_process"),d=require("process"),g=require("./i18n/index.js");function f(e="development"){process.env.SRC="true",process.env.NODE_ENV=e;const c=process.cwd(),u=new i.Config({cwd:c});let p=u.getUserConfig();function m(r){const u=o.getSrcPath(),p=s.resolve(c,u,".gant");o.generateDir(p);const m=t.readFileSync(s.resolve(__dirname,"./template/core.txt"),"utf-8");o.writeFileToJS(s.resolve(p,"index.ts"),m);const d={[r?.name||"@@"]:c,...r?.resolve?.alias},g=[c];i.keys(r.packages).map((e=>{const t=r.packages[e];d[e]=t,g.push(t)})),l.generateTsConfig(p,{paths:d,includes:g,cwd:c,vue:r.vue});const f=[...Object.keys(r.packages).map((e=>r.packages[e])),c];h.copyAppsFiles(p,f),h.copyPublicFiles(p,f.map((e=>s.resolve(e,"public")))),a.generateRoutes(s.resolve(p,"./routes"),r.routes);return new n.Webpack(r,c,e)}u.configFiles;let d=m(p);if("development"!==e)d.runBuild();else{d.runServer();let g=null;function f(e){g=r.watch(u.configFiles?.map((e=>s.dirname(e))),{}),g.on("change",(e=>{d.devServer.stop(),p=u.getUserConfig(),d=m(p),d.runServer({open:!1})}))}f()}}function _(){const e=process.cwd(),n=new i.Config({cwd:e});let r=n.getMsUserConfig();const a=o.getSrcPath(),h=s.resolve(e,a,".gant");t.existsSync(h)||t.mkdirSync(h,{recursive:!0});const c=t.readFileSync(s.resolve(__dirname,"./template/core.txt"),"utf-8");o.writeFileToJS(s.resolve(h,"index.ts"),c);const u=r?.name||"main",p={},m={...r?.resolve?.alias},d=[e];return r.mfa?.entry&&(p[u]={entry:r.mfa?.entry,publicPath:"string"==typeof r.mfa?.publicPath?[r.mfa?.publicPath]:r.mfa?.publicPath,port:r.mfa?.port,htmlTemplatePath:r.mfa.htmlTemplatePath,apps:[e],base:r.mfa.base,isMaster:!0}),r.mfa.pages?.map?.((e=>{const t="string"==typeof e.path?[e.path]:e.path,i="string"==typeof e.publicPath?[e.publicPath]:e.publicPath;d.push(...t),p[e.name]={entry:e.entry||r.mfa.subEntry,publicPath:i,port:e.port,htmlTemplatePath:e.htmlTemplatePath,apps:t,base:e.base,url:e.url}})),o.writeFileToJS(s.resolve(h,"appMaps.ts"),`export default ${JSON.stringify(p)}`),l.generateTsConfig(h,{includes:d,paths:m,cwd:e,vue:r.vue,createIncludes:!1}),{userConfig:r,msName:u,msConfig:p,configManager:n}}function v(e="development",t){process.env.SRC="false",process.env.NODE_ENV=e;const{userConfig:n,msName:r,msConfig:s,configManager:o}=_();if(i.isEmpty(n.mfa))return;const a=t||r,l=s[a];l&&b(o,e,n,a,l)}function b(e,l,u,p,m,d=!0){const g=process.cwd(),f=o.getSrcPath(),v=i.cloneDeep(u);const O=m.apps?.map?.((e=>i.Config.getMainConfigFile({cwd:e})))?.filter?.((e=>!!e));let C=function(){const r=s.resolve(g,f,`.gant/${p}`);o.generateDir(r),h.copyAppsFiles(r,m.apps),h.copyPublicFiles(r,m.publicPath);const u=t.readFileSync(s.resolve(__dirname,"./template/msentry.txt"),"utf-8"),d=c.ejs.compile(u);t.writeFileSync(s.resolve(r,"index.ts"),d({entry:s.join("../../",m.entry)}));const _=e.getMsPagesUserConfig(m.apps);return a.generateRoutes(s.resolve(r,"./routes"),_.routes),v.entry={index:s.resolve(r,"index.ts")},v.base=i.get(m,"base","/"),v.define={...v.define,APP_NAME:p},v.devServer={...v.devServer,port:m.port,static:{directory:s.resolve(r,"public")}},v.output={...v.output,chunkLoadingGlobal:`webpackJsonp_${p}`,chunkFilename:`${p}.[name].[id].[contenthash].js`,path:s.resolve(g,`dist/${p}`)},v.outputPathDir=s.resolve(g,`dist/${p}`),v.publicPathDir=s.resolve(g,`.gant/${p}/public`),new n.Webpack(v,g,l)}();if("development"!==l)C.runBuild();else{C.runServer({open:d});let A=null;function w(t){A=r.watch(t),A.on("change",(t=>{C.devServer.stop();const{userConfig:i,msConfig:n}=_();A.close(),b(e,l,i,p,n[p],!1)}))}w(O)}}require("./config/defineConfig.js"),require("./utils/getJavascriptfile.js"),require("module"),require("webpack"),require("webpack-dev-server"),require("./webpack/config/index.js"),require("./webpack/config/production.config.js"),require("./webpack/plugins/copy.js"),require("mini-css-extract-plugin"),require("css-minimizer-webpack-plugin"),require("terser-webpack-plugin"),require("compression-webpack-plugin"),require("./webpack/config/default.config.js"),require("html-webpack-plugin"),require("./webpack/config/cssRules.js"),require("./webpack/config/development.config.js"),require("./webpack/config/analyzer.config.js"),require("url"),require("os"),require("tty"),require("fs/promises"),require("assert"),require("v8"),require("util"),require("readline"),require("stream"),require("buffer"),require("string_decoder"),require("crypto"),require("node:process"),require("node:os"),require("node:tty"),require("node:assert"),require("node:readline"),require("http"),require("https"),require("net"),require("./i18n/utils.js"),require("zlib"),exports.Env=void 0,(e=exports.Env||(exports.Env={})).development="development",e.production="production",e.test="test";var O={exports:{}},C={},A={};let w=class extends Error{constructor(e,t,i){super(i),Error.captureStackTrace(this,this.constructor),this.name=this.constructor.name,this.code=t,this.exitCode=e,this.nestedError=void 0}};A.CommanderError=w,A.InvalidArgumentError=class extends w{constructor(e){super(1,"commander.invalidArgument",e),Error.captureStackTrace(this,this.constructor),this.name=this.constructor.name}};const{InvalidArgumentError:x}=A;C.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 x(`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}},C.humanReadableArgName=function(e){const t=e.name()+(!0===e.variadic?"...":"");return e.required?"<"+t+">":"["+t+"]"};var y={},E={};const{humanReadableArgName:k}=C;E.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[,i,n]=e._helpCommandnameAndArgs.match(/([^ ]+) *(.*)/),r=e.createCommand(i).helpOption(!1);r.description(e._helpCommandDescription),n&&r.arguments(n),t.push(r)}return this.sortSubcommands&&t.sort(((e,t)=>e.name().localeCompare(t.name()))),t}compareOptions(e,t){const i=e=>e.short?e.short.replace(/^-/,""):e.long.replace(/^--/,"");return i(e).localeCompare(i(t))}visibleOptions(e){const t=e.options.filter((e=>!e.hidden)),i=e._hasHelpOption&&e._helpShortFlag&&!e._findOption(e._helpShortFlag),n=e._hasHelpOption&&!e._findOption(e._helpLongFlag);if(i||n){let r;r=i?n?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 i=e.parent;i;i=i.parent){const e=i.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=>k(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,i)=>Math.max(e,t.subcommandTerm(i).length)),0)}longestOptionTermLength(e,t){return t.visibleOptions(e).reduce(((e,i)=>Math.max(e,t.optionTerm(i).length)),0)}longestGlobalOptionTermLength(e,t){return t.visibleGlobalOptions(e).reduce(((e,i)=>Math.max(e,t.optionTerm(i).length)),0)}longestArgumentTermLength(e,t){return t.visibleArguments(e).reduce(((e,i)=>Math.max(e,t.argumentTerm(i).length)),0)}commandUsage(e){let t=e._name;e._aliases[0]&&(t=t+"|"+e._aliases[0]);let i="";for(let t=e.parent;t;t=t.parent)i=t.name()+" "+i;return i+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 i=`(${t.join(", ")})`;return e.description?`${e.description} ${i}`:i}return e.description}formatHelp(e,t){const i=t.padWidth(e,t),n=t.helpWidth||80;function r(e,r){if(r){const s=`${e.padEnd(i+2)}${r}`;return t.wrap(s,n-2,i+2)}return e}function s(e){return e.join("\n").replace(/^/gm," ".repeat(2))}let o=[`Usage: ${t.commandUsage(e)}`,""];const a=t.commandDescription(e);a.length>0&&(o=o.concat([t.wrap(a,n,0),""]));const l=t.visibleArguments(e).map((e=>r(t.argumentTerm(e),t.argumentDescription(e))));l.length>0&&(o=o.concat(["Arguments:",s(l),""]));const h=t.visibleOptions(e).map((e=>r(t.optionTerm(e),t.optionDescription(e))));if(h.length>0&&(o=o.concat(["Options:",s(h),""])),this.showGlobalOptions){const i=t.visibleGlobalOptions(e).map((e=>r(t.optionTerm(e),t.optionDescription(e))));i.length>0&&(o=o.concat(["Global Options:",s(i),""]))}const c=t.visibleCommands(e).map((e=>r(t.subcommandTerm(e),t.subcommandDescription(e))));return c.length>0&&(o=o.concat(["Commands:",s(c),""])),o.join("\n")}padWidth(e,t){return Math.max(t.longestOptionTermLength(e,t),t.longestGlobalOptionTermLength(e,t),t.longestSubcommandTermLength(e,t),t.longestArgumentTermLength(e,t))}wrap(e,t,i,n=40){const r=new RegExp("[\\n][ \\f\\t\\v   -    \ufeff]+");if(e.match(r))return e;const s=t-i;if(s<n)return e;const o=e.slice(0,i),a=e.slice(i).replace("\r\n","\n"),l=" ".repeat(i),h="\\s​",c=new RegExp(`\n|.{1,${s-1}}([${h}]|$)|[^${h}]+?([${h}]|$)`,"g");return o+(a.match(c)||[]).map(((e,t)=>"\n"===e?"":(t>0?l:"")+e.trimEnd())).join("\n")}};var $={};const{InvalidArgumentError:S}=A;function H(e){let t,i;const n=e.split(/[ |,]+/);return n.length>1&&!/^[[<]/.test(n[1])&&(t=n.shift()),i=n.shift(),!t&&/^-[^-]$/.test(i)&&(t=i,i=void 0),{shortFlag:t,longFlag:i}}$.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 i=H(e);this.short=i.shortFlag,this.long=i.longFlag,this.negate=!1,this.long&&(this.negate=this.long.startsWith("--no-")),this.defaultValue=void 0,this.defaultValueDescription=void 0,this.presetArg=void 0,this.envVar=void 0,this.parseArg=void 0,this.hidden=!1,this.argChoices=void 0,this.conflictsWith=[],this.implied=void 0}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 S(`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}},$.splitOptionFlags=H,$.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 i=t.attributeName();if(!this.dualOptions.has(i))return!0;const n=this.negativeOptions.get(i).presetArg,r=void 0!==n&&n;return t.negate===(r===e)}};var V={};const F=3;V.suggestSimilar=function(e,t){if(!t||0===t.length)return"";t=Array.from(new Set(t));const i=e.startsWith("--");i&&(e=e.slice(2),t=t.map((e=>e.slice(2))));let n=[],r=F;return t.forEach((t=>{if(t.length<=1)return;const i=function(e,t){if(Math.abs(e.length-t.length)>F)return Math.max(e.length,t.length);const i=[];for(let t=0;t<=e.length;t++)i[t]=[t];for(let e=0;e<=t.length;e++)i[0][e]=e;for(let n=1;n<=t.length;n++)for(let r=1;r<=e.length;r++){let s=1;s=e[r-1]===t[n-1]?0:1,i[r][n]=Math.min(i[r-1][n]+1,i[r][n-1]+1,i[r-1][n-1]+s),r>1&&n>1&&e[r-1]===t[n-2]&&e[r-2]===t[n-1]&&(i[r][n]=Math.min(i[r][n],i[r-2][n-2]+1))}return i[e.length][t.length]}(e,t),s=Math.max(e.length,t.length);(s-i)/s>.4&&(i<r?(r=i,n=[t]):i===r&&n.push(t))})),n.sort(((e,t)=>e.localeCompare(t))),i&&(n=n.map((e=>`--${e}`))),n.length>1?`\n(Did you mean one of ${n.join(", ")}?)`:1===n.length?`\n(Did you mean ${n[0]}?)`:""};const q=p.EventEmitter,P=m,D=s,N=t,j=d,{Argument:T,humanReadableArgName:M}=C,{CommanderError:I}=A,{Help:W}=E,{Option:L,splitOptionFlags:U,DualOptions:G}=$,{suggestSimilar:R}=V;function J(e,t){e._hasHelpOption&&t.find((t=>t===e._helpLongFlag||t===e._helpShortFlag))&&(e.outputHelp(),e._exit(0,"commander.helpDisplayed","(outputHelp)"))}function z(e){return e.map((e=>{if(!e.startsWith("--inspect"))return e;let t,i,n="127.0.0.1",r="9229";return null!==(i=e.match(/^(--inspect(-brk)?)$/))?t=i[1]:null!==(i=e.match(/^(--inspect(-brk|-port)?)=([^:]+)$/))?(t=i[1],/^\d+$/.test(i[3])?r=i[3]:n=i[3]):null!==(i=e.match(/^(--inspect(-brk|-port)?)=([^:]+):(\d+)$/))&&(t=i[1],n=i[3],r=i[4]),t&&"0"!==r?`${t}=${n}:${parseInt(r)+1}`:e}))}y.Command=class e extends q{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=>j.stdout.write(e),writeErr:e=>j.stderr.write(e),getOutHelpWidth:()=>j.stdout.isTTY?j.stdout.columns:void 0,getErrHelpWidth:()=>j.stderr.isTTY?j.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,i){let n=t,r=i;"object"==typeof n&&null!==n&&(r=n,n=null),r=r||{};const[,s,o]=e.match(/([^ ]+) *(.*)/),a=this.createCommand(s);return n&&(a.description(n),a._executableHandler=!0),r.isDefault&&(this._defaultCommandName=a._name),a._hidden=!(!r.noHelp&&!r.hidden),a._executableFile=r.executableFile||null,o&&a.arguments(o),this.commands.push(a),a.parent=this,a.copyInheritedSettings(this),n?this:a}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 T(e,t)}argument(e,t,i,n){const r=this.createArgument(e,t);return"function"==typeof i?r.default(n).argParser(i):r.default(i),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 i=["preSubcommand","preAction","postAction"];if(!i.includes(e))throw new Error(`Unexpected value for event passed to hook : '${e}'.\nExpecting one of '${i.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,i){this._exitCallback&&this._exitCallback(new I(e,t,i)),j.exit(e)}action(e){return this._actionHandler=t=>{const i=this.registeredArguments.length,n=t.slice(0,i);return this._storeOptionsAsProperties?n[i]=this:n[i]=this.opts(),n.push(this),e.apply(this,n)},this}createOption(e,t){return new L(e,t)}_callParseArg(e,t,i,n){try{return e.parseArg(t,i)}catch(e){if("commander.invalidArgument"===e.code){const t=`${n} ${e.message}`;this.error(t,{exitCode:e.exitCode,code:e.code})}throw e}}addOption(e){const t=e.name(),i=e.attributeName();if(e.negate){const t=e.long.replace(/^--no-/,"--");this._findOption(t)||this.setOptionValueWithSource(i,void 0===e.defaultValue||e.defaultValue,"default")}else void 0!==e.defaultValue&&this.setOptionValueWithSource(i,e.defaultValue,"default");this.options.push(e);const n=(t,n,r)=>{null==t&&void 0!==e.presetArg&&(t=e.presetArg);const s=this.getOptionValue(i);null!==t&&e.parseArg?t=this._callParseArg(e,t,s,n):null!==t&&e.variadic&&(t=e._concatValue(t,s)),null==t&&(t=!e.negate&&(!(!e.isBoolean()&&!e.optional)||"")),this.setOptionValueWithSource(i,t,r)};return this.on("option:"+t,(t=>{const i=`error: option '${e.flags}' argument '${t}' is invalid.`;n(t,i,"cli")})),e.envVar&&this.on("optionEnv:"+t,(t=>{const i=`error: option '${e.flags}' value '${t}' from env '${e.envVar}' is invalid.`;n(t,i,"env")})),this}_optionEx(e,t,i,n,r){if("object"==typeof t&&t instanceof L)throw new Error("To add an Option object use addOption() instead of option() or requiredOption()");const s=this.createOption(t,i);if(s.makeOptionMandatory(!!e.mandatory),"function"==typeof n)s.default(r).argParser(n);else if(n instanceof RegExp){const e=n;n=(t,i)=>{const n=e.exec(t);return n?n[0]:i},s.default(r).argParser(n)}else s.default(n);return this.addOption(s)}option(e,t,i,n){return this._optionEx({},e,t,i,n)}requiredOption(e,t,i,n){return this._optionEx({mandatory:!0},e,t,i,n)}combineFlagAndOptionalValue(e=!0){return this._combineFlagAndOptionalValue=!!e,this}allowUnknownOption(e=!0){return this._allowUnknownOption=!!e,this}allowExcessArguments(e=!0){return this._allowExcessArguments=!!e,this}enablePositionalOptions(e=!0){return this._enablePositionalOptions=!!e,this}passThroughOptions(e=!0){if(this._passThroughOptions=!!e,this.parent&&e&&!this.parent._enablePositionalOptions)throw new Error("passThroughOptions can not be used without turning on enablePositionalOptions for parent command(s)");return this}storeOptionsAsProperties(e=!0){if(this.options.length)throw new Error("call .storeOptionsAsProperties() before adding options");return this._storeOptionsAsProperties=!!e,this}getOptionValue(e){return this._storeOptionsAsProperties?this[e]:this._optionValues[e]}setOptionValue(e,t){return this.setOptionValueWithSource(e,t,void 0)}setOptionValueWithSource(e,t,i){return this._storeOptionsAsProperties?this[e]=t:this._optionValues[e]=t,this._optionValueSources[e]=i,this}getOptionValueSource(e){return this._optionValueSources[e]}getOptionValueSourceWithGlobals(e){let t;return this._getCommandAndAncestors().forEach((i=>{void 0!==i.getOptionValueSource(e)&&(t=i.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 i;switch(t=t||{},void 0===e&&(e=j.argv,j.versions&&j.versions.electron&&(t.from="electron")),this.rawArgs=e.slice(),t.from){case void 0:case"node":this._scriptPath=e[1],i=e.slice(2);break;case"electron":j.defaultApp?(this._scriptPath=e[1],i=e.slice(2)):i=e.slice(1);break;case"user":i=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",i}parse(e,t){const i=this._prepareUserArgs(e,t);return this._parseCommand([],i),this}async parseAsync(e,t){const i=this._prepareUserArgs(e,t);return await this._parseCommand([],i),this}_executeSubCommand(e,t){t=t.slice();let i=!1;const n=[".js",".ts",".tsx",".mjs",".cjs"];function r(e,t){const i=D.resolve(e,t);if(N.existsSync(i))return i;if(n.includes(D.extname(t)))return;const r=n.find((e=>N.existsSync(`${i}${e}`)));return r?`${i}${r}`:void 0}this._checkForMissingMandatoryOptions(),this._checkForConflictingOptions();let s,o=e._executableFile||`${this._name}-${e._name}`,a=this._executableDir||"";if(this._scriptPath){let e;try{e=N.realpathSync(this._scriptPath)}catch(t){e=this._scriptPath}a=D.resolve(D.dirname(e),a)}if(a){let t=r(a,o);if(!t&&!e._executableFile&&this._scriptPath){const i=D.basename(this._scriptPath,D.extname(this._scriptPath));i!==this._name&&(t=r(a,`${i}-${e._name}`))}o=t||o}if(i=n.includes(D.extname(o)),"win32"!==j.platform?i?(t.unshift(o),t=z(j.execArgv).concat(t),s=P.spawn(j.argv[0],t,{stdio:"inherit"})):s=P.spawn(o,t,{stdio:"inherit"}):(t.unshift(o),t=z(j.execArgv).concat(t),s=P.spawn(j.execPath,t,{stdio:"inherit"})),!s.killed){["SIGUSR1","SIGUSR2","SIGTERM","SIGINT","SIGHUP"].forEach((e=>{j.on(e,(()=>{!1===s.killed&&null===s.exitCode&&s.kill(e)}))}))}const l=this._exitCallback;l?s.on("close",(()=>{l(new I(j.exitCode||0,"commander.executeSubCommandAsync","(close)"))})):s.on("close",j.exit.bind(j)),s.on("error",(t=>{if("ENOENT"===t.code){const t=a?`searched for local subcommand relative to directory '${a}'`:"no directory for search for local subcommand, use .executableDir() to supply a custom directory",i=`'${o}' 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(i)}if("EACCES"===t.code)throw new Error(`'${o}' not executable`);if(l){const e=new I(1,"commander.executeSubCommandAsync","(error)");e.nestedError=t,l(e)}else j.exit(1)})),this.runningCommand=s}_dispatchSubcommand(e,t,i){const n=this._findCommand(e);let r;return n||this.help({error:!0}),r=this._chainOrCallSubCommandHook(r,n,"preSubcommand"),r=this._chainOrCall(r,(()=>{if(!n._executableHandler)return n._parseCommand(t,i);this._executeSubCommand(n,t.concat(i))})),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,i)=>{let n=t;if(null!==t&&e.parseArg){const r=`error: command-argument value '${t}' is invalid for argument '${e.name()}'.`;n=this._callParseArg(e,t,i,r)}return n};this._checkNumberOfArguments();const t=[];this.registeredArguments.forEach(((i,n)=>{let r=i.defaultValue;i.variadic?n<this.args.length?(r=this.args.slice(n),i.parseArg&&(r=r.reduce(((t,n)=>e(i,n,t)),i.defaultValue))):void 0===r&&(r=[]):n<this.args.length&&(r=this.args[n],i.parseArg&&(r=e(i,r,i.defaultValue))),t[n]=r})),this.processedArgs=t}_chainOrCall(e,t){return e&&e.then&&"function"==typeof e.then?e.then((()=>t())):t()}_chainOrCallHooks(e,t){let i=e;const n=[];return this._getCommandAndAncestors().reverse().filter((e=>void 0!==e._lifeCycleHooks[t])).forEach((e=>{e._lifeCycleHooks[t].forEach((t=>{n.push({hookedCommand:e,callback:t})}))})),"postAction"===t&&n.reverse(),n.forEach((e=>{i=this._chainOrCall(i,(()=>e.callback(e.hookedCommand,this)))})),i}_chainOrCallSubCommandHook(e,t,i){let n=e;return void 0!==this._lifeCycleHooks[i]&&this._lifeCycleHooks[i].forEach((e=>{n=this._chainOrCall(n,(()=>e(this,t)))})),n}_parseCommand(e,t){const i=this.parseOptions(t);if(this._parseOptionsEnv(),this._parseOptionsImplied(),e=e.concat(i.operands),t=i.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,i.unknown),this._checkForMissingMandatoryOptions(),this._checkForConflictingOptions();const n=()=>{i.unknown.length>0&&this.unknownOption(i.unknown[0])},r=`command:${this.name()}`;if(this._actionHandler){let i;return n(),this._processArguments(),i=this._chainOrCallHooks(i,"preAction"),i=this._chainOrCall(i,(()=>this._actionHandler(this.processedArgs))),this.parent&&(i=this._chainOrCall(i,(()=>{this.parent.emit(r,e,t)}))),i=this._chainOrCallHooks(i,"postAction"),i}if(this.parent&&this.parent.listenerCount(r))n(),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():(n(),this._processArguments())}else this.commands.length?(n(),this.help({error:!0})):(n(),this._processArguments())}_findCommand(e){if(e)return this.commands.find((t=>t._name===e||t._aliases.includes(e)))}_findOption(e){return this.options.find((t=>t.is(e)))}_checkForMissingMandatoryOptions(){this._getCommandAndAncestors().forEach((e=>{e.options.forEach((t=>{t.mandatory&&void 0===e.getOptionValue(t.attributeName())&&e.missingMandatoryOptionValue(t)}))}))}_checkForConflictingLocalOptions(){const e=this.options.filter((e=>{const t=e.attributeName();return void 0!==this.getOptionValue(t)&&"default"!==this.getOptionValueSource(t)})),t=e.filter((e=>e.conflictsWith.length>0));t.forEach((t=>{const i=e.find((e=>t.conflictsWith.includes(e.attributeName())));i&&this._conflictingOption(t,i)}))}_checkForConflictingOptions(){this._getCommandAndAncestors().forEach((e=>{e._checkForConflictingLocalOptions()}))}parseOptions(e){const t=[],i=[];let n=t;const r=e.slice();function s(e){return e.length>1&&"-"===e[0]}let o=null;for(;r.length;){const e=r.shift();if("--"===e){n===i&&n.push(e),n.push(...r);break}if(!o||s(e)){if(o=null,s(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&&!s(r[0])&&(e=r.shift()),this.emit(`option:${t.name()}`,e)}else this.emit(`option:${t.name()}`);o=t.variadic?t:null;continue}}if(e.length>2&&"-"===e[0]&&"-"!==e[1]){const t=this._findOption(`-${e[1]}`);if(t){t.required||t.optional&&this._combineFlagAndOptionalValue?this.emit(`option:${t.name()}`,e.slice(2)):(this.emit(`option:${t.name()}`),r.unshift(`-${e.slice(2)}`));continue}}if(/^--[^=]+=/.test(e)){const t=e.indexOf("="),i=this._findOption(e.slice(0,t));if(i&&(i.required||i.optional)){this.emit(`option:${i.name()}`,e.slice(t+1));continue}}if(s(e)&&(n=i),(this._enablePositionalOptions||this._passThroughOptions)&&0===t.length&&0===i.length){if(this._findCommand(e)){t.push(e),r.length>0&&i.push(...r);break}if(e===this._helpCommandName&&this._hasImplicitHelpCommand()){t.push(e),r.length>0&&t.push(...r);break}if(this._defaultCommandName){i.push(e),r.length>0&&i.push(...r);break}}if(this._passThroughOptions){n.push(e),r.length>0&&n.push(...r);break}n.push(e)}else this.emit(`option:${o.name()}`,e)}return{operands:t,unknown:i}}opts(){if(this._storeOptionsAsProperties){const e={},t=this.options.length;for(let i=0;i<t;i++){const t=this.options[i].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 i=t||{},n=i.exitCode||1,r=i.code||"commander.error";this._exit(n,r,e)}_parseOptionsEnv(){this.options.forEach((e=>{if(e.envVar&&e.envVar in j.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()}`,j.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((i=>void 0!==i.implied&&t(i.attributeName())&&e.valueFromOption(this.getOptionValue(i.attributeName()),i))).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 i=e=>{const t=e.attributeName(),i=this.getOptionValue(t),n=this.options.find((e=>e.negate&&t===e.attributeName())),r=this.options.find((e=>!e.negate&&t===e.attributeName()));return n&&(void 0===n.presetArg&&!1===i||void 0!==n.presetArg&&i===n.presetArg)?n:r||e},n=e=>{const t=i(e),n=t.attributeName();return"env"===this.getOptionValueSource(n)?`environment variable '${t.envVar}'`:`option '${t.flags}'`},r=`error: ${n(e)} cannot be used with ${n(t)}`;this.error(r,{code:"commander.conflictingOption"})}unknownOption(e){if(this._allowUnknownOption)return;let t="";if(e.startsWith("--")&&this._showSuggestionAfterError){let i=[],n=this;do{const e=n.createHelp().visibleOptions(n).filter((e=>e.long)).map((e=>e.long));i=i.concat(e),n=n.parent}while(n&&!n._enablePositionalOptions);t=R(e,i)}const i=`error: unknown option '${e}'${t}`;this.error(i,{code:"commander.unknownOption"})}_excessArguments(e){if(this._allowExcessArguments)return;const t=this.registeredArguments.length,i=1===t?"":"s",n=`error: too many arguments${this.parent?` for '${this.name()}'`:""}. Expected ${t} argument${i} but got ${e.length}.`;this.error(n,{code:"commander.excessArguments"})}unknownCommand(){const e=this.args[0];let t="";if(this._showSuggestionAfterError){const i=[];this.createHelp().visibleCommands(this).forEach((e=>{i.push(e.name()),e.alias()&&i.push(e.alias())})),t=R(e,i)}const i=`error: unknown command '${e}'${t}`;this.error(i,{code:"commander.unknownCommand"})}version(e,t,i){if(void 0===e)return this._version;this._version=e,t=t||"-V, --version",i=i||"output the version number";const n=this.createOption(t,i);return this._versionOptionName=n.attributeName(),this.options.push(n),this.on("option:"+n.name(),(()=>{this._outputConfiguration.writeOut(`${e}\n`),this._exit(0,"commander.version",e)})),this}description(e,t){return void 0===e&&void 0===t?this._description:(this._description=e,t&&(this._argsDescription=t),this)}summary(e){return void 0===e?this._summary:(this._summary=e,this)}alias(e){if(void 0===e)return this._aliases[0];let t=this;if(0!==this.commands.length&&this.commands[this.commands.length-1]._executableHandler&&(t=this.commands[this.commands.length-1]),e===t._name)throw new Error("Command alias can't be the same as its name");return t._aliases.push(e),this}aliases(e){return void 0===e?this._aliases:(e.forEach((e=>this.alias(e))),this)}usage(e){if(void 0===e){if(this._usage)return this._usage;const e=this.registeredArguments.map((e=>M(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=D.basename(e,D.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 i;return i=t.error?e=>this._outputConfiguration.writeErr(e):e=>this._outputConfiguration.writeOut(e),t.write=e.write||i,t.command=this,t}outputHelp(e){let t;"function"==typeof e&&(t=e,e=void 0);const i=this._getHelpContext(e);this._getCommandAndAncestors().reverse().forEach((e=>e.emit("beforeAllHelp",i))),this.emit("beforeHelp",i);let n=this.helpInformation(i);if(t&&(n=t(n),"string"!=typeof n&&!Buffer.isBuffer(n)))throw new Error("outputHelp callback must return a string or a Buffer");i.write(n),this._helpLongFlag&&this.emit(this._helpLongFlag),this.emit("afterHelp",i),this._getCommandAndAncestors().forEach((e=>e.emit("afterAllHelp",i)))}helpOption(e,t){if("boolean"==typeof e)return this._hasHelpOption=e,this;this._helpFlags=e||this._helpFlags,this._helpDescription=t||this._helpDescription;const i=U(this._helpFlags);return this._helpShortFlag=i.shortFlag,this._helpLongFlag=i.longFlag,this}help(e){this.outputHelp(e);let t=j.exitCode||0;0===t&&e&&"function"!=typeof e&&e.error&&(t=1),this._exit(t,"commander.help","(outputHelp)")}addHelpText(e,t){const i=["beforeAll","before","after","afterAll"];if(!i.includes(e))throw new Error(`Unexpected value for position to addHelpText.\nExpecting one of '${i.join("', '")}'`);const n=`${e}Help`;return this.on(n,(e=>{let i;i="function"==typeof t?t({error:e.error,command:e.command}):t,i&&e.write(`${i}\n`)})),this}},function(e,t){const{Argument:i}=C,{Command:n}=y,{CommanderError:r,InvalidArgumentError:s}=A,{Help:o}=E,{Option:a}=$;(t=e.exports=new n).program=t,t.Command=n,t.Option=a,t.Argument=i,t.Help=o,t.CommanderError=r,t.InvalidArgumentError=s,t.InvalidOptionArgumentError=s}(O,O.exports);var B=O.exports,Y=c.getDefaultExportFromCjs(B);const{program:K,createCommand:Q,createArgument:X,createOption:Z,CommanderError:ee,InvalidArgumentError:te,InvalidOptionArgumentError:ie,Command:ne,Argument:re,Option:se,Help:oe}=Y,ae=new ne;ae.version("1.0.0","-v, --version","gant-core version"),ae.command("default",{isDefault:!0,noHelp:!0,hidden:!0}).action((()=>f())),ae.command("build").description("build cli").action((()=>f("build"))),ae.command("analyzer").description("bundle-analyzer").action((()=>f("analyzer"))),ae.command("i18n").arguments("[currentLanguage] [targetLanguage]").description("i18n translation").action(g.i18n),ae.command("create").description("创建项目").action((()=>u.createModule())),ae.command("mfa").arguments("[name]").action((e=>{v("development",e)})),ae.command("mfa-build").arguments("[name]").action((e=>{v("build",e)})),ae.command("mfa-analyzer").arguments("[name]").action((e=>{v("analyzer",e)}));(async()=>{try{ae.parse(process.argv)}catch(e){console.log("Start Error",g.color.red(e?.message))}})();
@@ -1,2 +1,2 @@
1
1
  #!/usr/bin/env node
2
- "use strict";var e=require("../../utils/index.js"),t=require("html-webpack-plugin"),s=require("./cssRules.js"),r=require("path"),i=require("webpack"),o=require("../../config/index.js");const a=["name","routes","mpas","packages","microServiceMap","base","customHistoryApiFallback","outputPathDir","define","setting","vue","library","compression","terserOptions","htmlTemplatePath","locales","mfa","publicPathDir","provide"];exports.getDefaultConfig=(n,l)=>{const u=o.omit(l,a);let{base:c="/",routes:p,htmlTemplatePath:m,outputPathDir:d="dist",microServiceMap:g,define:h,setting:v,vue:f,provide:b}=o.pick(l,a);c=/^\/.*\/$/.test(c)?c:"/";let y=l.entry||{};const x=[];if(o.isEmpty(y)&&(y.index=r.resolve(n,"src/main")),"string"==typeof y.index){const s=e.getMpasPageHtml(m);x.push(new t({templateContent:s,filename:"index.html",chunks:["index"],publicPath:c,base:c})),l.entry=y}o.isEmpty(y)||Object.entries(y).forEach((([s,r])=>{if("index"!==s){const r=e.getMpasPageHtml(m?.replace("index.",s+"."));x.push(new t({templateContent:r,filename:`${s}.html`,chunks:[s],publicPath:c,base:c}))}}));const P=s.getCssRules(l.mode);return e.mergeConfig({entry:y,stats:"minimal",devServer:{static:{directory:r.resolve(n,"src/.gant/public"),publicPath:c},compress:!0,historyApiFallback:o.has(l,"customHistoryApiFallback")?l?.customHistoryApiFallback:{index:r.resolve(c,"index.html"),rewrites:[{from:/^\/public\/(.*)$/,to:e=>r.resolve(c,e.match[1])}]}},module:{rules:[...f?[{test:/\.vue$/,loader:require.resolve("vue-loader")}]:[],{test:/\.(ts|tsx)$/,exclude:/node_modules/,use:{loader:require.resolve("swc-loader"),options:{jsc:{parser:{syntax:"typescript",tsx:!0,dynamicImport:!0},transform:{...f?{}:{react:{runtime:"automatic",development:"development"===l.mode,refresh:"development"===l.mode}}}}}}},...P,{test:/\.html$/,use:require.resolve("html-loader")},{test:/\.(png|jpg|gif|woff|woff2|eot|ttf|svg)$/i,use:[{loader:require.resolve("url-loader"),options:{limit:8192,name:"[name][hash].[ext]",outputPath:"assets/"}}]}]},resolve:{extensions:[".tsx",".ts",".js",".jsx",".json",".vue"]},output:{path:r.resolve(n,d),publicPath:c,charset:!0,clean:!0},plugins:[...f?[new(require("vue-loader").VueLoaderPlugin)]:[],...x,new i.ProvidePlugin({...b,React:"react",process:"process/browser.js"}),new i.ProgressPlugin,new i.DefinePlugin({GANT_START_TIME:JSON.stringify(global.__gant_start_time),microServiceMap:JSON.stringify(g),BASE:JSON.stringify(c),SETTING:JSON.stringify(v||{}),...o.mapValues(h,(e=>JSON.stringify(e))),"process.env":JSON.stringify(process.env)})]},u)};
2
+ "use strict";var e=require("../../utils/index.js"),t=require("html-webpack-plugin"),s=require("./cssRules.js"),r=require("path"),i=require("webpack"),o=require("../../config/index.js");const a=["name","routes","mpas","packages","microServiceMap","base","customHistoryApiFallback","outputPathDir","define","setting","vue","library","compression","terserOptions","htmlTemplatePath","locales","mfa","publicPathDir","provide"];exports.getDefaultConfig=(n,l)=>{const u=o.omit(l,a);let{base:p="/",routes:c,htmlTemplatePath:m,outputPathDir:d="dist",microServiceMap:g,define:h,setting:v,vue:f,provide:y}=o.pick(l,a);p=/^\/.*\/$/.test(p)?p:"/";let b=l.entry||{};const x=[];if(o.isEmpty(b)&&(b.index=r.resolve(n,"src/main")),"string"==typeof b.index){const s=e.getMpasPageHtml(m);x.push(new t({templateContent:s,filename:"index.html",chunks:["index"],publicPath:p,base:p})),l.entry=b}o.isEmpty(b)||Object.entries(b).forEach((([s,r])=>{if("index"!==s){const r=e.getMpasPageHtml(m?.replace("index.",s+"."));x.push(new t({templateContent:r,filename:`${s}.html`,chunks:[s],publicPath:p,base:p}))}}));const P=s.getCssRules(l.mode);return e.mergeConfig({entry:b,stats:"minimal",devServer:{static:{directory:r.resolve(n,"src/.gant/public"),publicPath:p},compress:!0,historyApiFallback:o.has(l,"customHistoryApiFallback")?l?.customHistoryApiFallback:{index:r.resolve(p,"index.html"),rewrites:[{from:/^\/public\/(.*)$/,to:e=>r.resolve(p,e.match[1])}]}},module:{rules:[...f?[{test:/\.vue$/,loader:require.resolve("vue-loader")}]:[],{test:/\.(ts|tsx)$/,exclude:/node_modules/,use:{loader:require.resolve("swc-loader"),options:{jsc:{parser:{syntax:"typescript",tsx:!0,dynamicImport:!0},transform:{...f?{}:{react:{runtime:"automatic",development:"development"===l.mode,refresh:"development"===l.mode}}}}}}},...P,{test:/\.html$/,use:require.resolve("html-loader")},{test:/\.(png|jpg|gif|woff|woff2|eot|ttf|svg)$/i,use:[{loader:require.resolve("url-loader"),options:{limit:8192,name:"[name][hash].[ext]",outputPath:"assets/"}}]}]},resolve:{extensions:[".tsx",".ts",".js",".jsx",".json",".vue"]},output:{path:r.resolve(n,d),publicPath:p,charset:!0,clean:!0},plugins:[...f?[new(require("vue-loader").VueLoaderPlugin)]:[],...x,new i.ProvidePlugin({...y}),new i.ProgressPlugin,new i.DefinePlugin({GANT_START_TIME:JSON.stringify(global.__gant_start_time),microServiceMap:JSON.stringify(g),BASE:JSON.stringify(p),SETTING:JSON.stringify(v||{}),...o.mapValues(h,(e=>JSON.stringify(e))),"process.env":JSON.stringify(process.env)})]},u)};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "gant-core",
3
- "version": "0.2.10",
3
+ "version": "0.2.12",
4
4
  "description": "",
5
5
  "main": "lib/core/index.js",
6
6
  "types": "lib/types/index.d.ts",
@@ -20,33 +20,19 @@
20
20
  "axios": "^1.6.8",
21
21
  "cli-progress": "^3.12.0",
22
22
  "commander": "^11.1.0",
23
- "css-loader": "^6.10.0",
24
23
  "ejs": "^3.1.9",
25
- "file-loader": "^6.2.0",
26
24
  "fs": "^0.0.1-security",
27
- "html-loader": "^5.0.0",
28
25
  "i18next": "^23.10.1",
29
26
  "inquirer": "^9.2.14",
30
- "less": "^4.2.0",
31
- "less-loader": "^12.2.0",
32
- "loader-utils": "^3.2.1",
33
27
  "lodash-es": "^4.17.21",
34
28
  "md5-node": "^1.0.1",
35
29
  "mitt": "^3.0.1",
36
30
  "path": "^0.12.7",
37
31
  "picocolors": "^1.0.0",
38
- "postcss": "^8.4.35",
39
- "postcss-loader": "^8.1.1",
40
- "postcss-preset-env": "^9.5.1",
41
- "postcss-short": "^5.0.0",
42
32
  "prettier": "^3.2.5",
43
33
  "process": "^0.11.10",
44
- "style-loader": "^3.3.4",
45
- "swc-loader": "^0.2.6",
46
34
  "typescript": "^5.3.3",
47
- "url": "^0.11.3",
48
- "url-loader": "^4.1.1",
49
- "vue-loader": "^17.4.2"
35
+ "url": "^0.11.3"
50
36
  },
51
37
  "dependencies": {
52
38
  "@pmmmwh/react-refresh-webpack-plugin": "^0.5.11",
@@ -74,10 +60,24 @@
74
60
  "webpack": "^5.90.3",
75
61
  "webpack-bundle-analyzer": "^4.10.1",
76
62
  "webpack-dev-server": "^4.7.4",
77
- "ts-node": "^10.9.2",
63
+ "style-loader": "^3.3.4",
64
+ "less": "^4.2.0",
65
+ "less-loader": "^12.2.0",
66
+ "loader-utils": "^3.2.1",
67
+ "swc-loader": "^0.2.6",
68
+ "url-loader": "^4.1.1",
69
+ "vue-loader": "^17.4.2",
70
+ "html-loader": "^5.0.0",
71
+ "css-loader": "^6.10.0",
72
+ "file-loader": "^6.2.0",
73
+ "postcss": "^8.4.35",
74
+ "postcss-loader": "^8.1.1",
75
+ "postcss-preset-env": "^9.5.1",
76
+ "postcss-short": "^5.0.0",
78
77
  "@babel/core": "^7.26.0",
79
78
  "@babel/plugin-transform-modules-commonjs": "^7.26.3",
80
79
  "@babel/preset-env": "^7.26.0",
81
- "@babel/register": "^7.25.9"
80
+ "@babel/register": "^7.25.9",
81
+ "ts-node": "^10.9.2"
82
82
  }
83
83
  }