@elysiumjs/styx 0.2.0 → 0.3.0
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.
- package/package.json +1 -1
- package/styx.js +72 -58
package/package.json
CHANGED
package/styx.js
CHANGED
|
@@ -1,99 +1,113 @@
|
|
|
1
1
|
#!/usr/bin/env bun
|
|
2
2
|
// @bun
|
|
3
|
-
var
|
|
4
|
-
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}var
|
|
3
|
+
var A$=Object.create;var{getPrototypeOf:C$,defineProperty:i0,getOwnPropertyNames:q$}=Object;var N$=Object.prototype.hasOwnProperty;var F=(Y,$,Z)=>{Z=Y!=null?A$(C$(Y)):{};let H=$||!Y||!Y.__esModule?i0(Z,"default",{value:Y,enumerable:!0}):Z;for(let D of q$(Y))if(!N$.call(H,D))i0(H,D,{get:()=>Y[D],enumerable:!0});return H};var Q=(Y,$)=>()=>($||Y(($={exports:{}}).exports,$),$.exports);var B=function(Y,$,Z,H){var D=arguments.length,U=D<3?$:H===null?H=Object.getOwnPropertyDescriptor($,Z):H,J;if(typeof Reflect==="object"&&typeof Reflect.decorate==="function")U=Reflect.decorate(Y,$,Z,H);else for(var X=Y.length-1;X>=0;X--)if(J=Y[X])U=(D<3?J(U):D>3?J($,Z,U):J($,Z))||U;return D>3&&U&&Object.defineProperty($,Z,U),U};var R=(Y,$)=>{if(typeof Reflect==="object"&&typeof Reflect.metadata==="function")return Reflect.metadata(Y,$)};var N1=import.meta.require;var S=Q((m7,t0)=>{var{FORCE_COLOR:P$,NODE_DISABLE_COLORS:j$,TERM:T$}=process.env,W={enabled:!j$&&T$!=="dumb"&&P$!=="0",reset:E(0,0),bold:E(1,22),dim:E(2,22),italic:E(3,23),underline:E(4,24),inverse:E(7,27),hidden:E(8,28),strikethrough:E(9,29),black:E(30,39),red:E(31,39),green:E(32,39),yellow:E(33,39),blue:E(34,39),magenta:E(35,39),cyan:E(36,39),white:E(37,39),gray:E(90,39),grey:E(90,39),bgBlack:E(40,49),bgRed:E(41,49),bgGreen:E(42,49),bgYellow:E(43,49),bgBlue:E(44,49),bgMagenta:E(45,49),bgCyan:E(46,49),bgWhite:E(47,49)};function o0(Y,$){let Z=0,H,D="",U="";for(;Z<Y.length;Z++)if(H=Y[Z],D+=H.open,U+=H.close,$.includes(H.close))$=$.replace(H.rgx,H.close+H.open);return D+$+U}function k$(Y,$){let Z={has:Y,keys:$};return Z.reset=W.reset.bind(Z),Z.bold=W.bold.bind(Z),Z.dim=W.dim.bind(Z),Z.italic=W.italic.bind(Z),Z.underline=W.underline.bind(Z),Z.inverse=W.inverse.bind(Z),Z.hidden=W.hidden.bind(Z),Z.strikethrough=W.strikethrough.bind(Z),Z.black=W.black.bind(Z),Z.red=W.red.bind(Z),Z.green=W.green.bind(Z),Z.yellow=W.yellow.bind(Z),Z.blue=W.blue.bind(Z),Z.magenta=W.magenta.bind(Z),Z.cyan=W.cyan.bind(Z),Z.white=W.white.bind(Z),Z.gray=W.gray.bind(Z),Z.grey=W.grey.bind(Z),Z.bgBlack=W.bgBlack.bind(Z),Z.bgRed=W.bgRed.bind(Z),Z.bgGreen=W.bgGreen.bind(Z),Z.bgYellow=W.bgYellow.bind(Z),Z.bgBlue=W.bgBlue.bind(Z),Z.bgMagenta=W.bgMagenta.bind(Z),Z.bgCyan=W.bgCyan.bind(Z),Z.bgWhite=W.bgWhite.bind(Z),Z}function E(Y,$){let Z={open:`\x1B[${Y}m`,close:`\x1B[${$}m`,rgx:new RegExp(`\\x1b\\[${$}m`,"g")};return function(H){if(this!==void 0&&this.has!==void 0)return this.has.includes(Y)||(this.has.push(Y),this.keys.push(Z)),H===void 0?this:W.enabled?o0(this.keys,H+""):H+"";return H===void 0?k$([Y],[Z]):W.enabled?o0([Z],H+""):H+""}}t0.exports=W});var a0=Q((p7,s0)=>{s0.exports=(Y,$)=>{if(Y.meta&&Y.name!=="escape")return;if(Y.ctrl){if(Y.name==="a")return"first";if(Y.name==="c")return"abort";if(Y.name==="d")return"abort";if(Y.name==="e")return"last";if(Y.name==="g")return"reset"}if($){if(Y.name==="j")return"down";if(Y.name==="k")return"up"}if(Y.name==="return")return"submit";if(Y.name==="enter")return"submit";if(Y.name==="backspace")return"delete";if(Y.name==="delete")return"deleteForward";if(Y.name==="abort")return"abort";if(Y.name==="escape")return"exit";if(Y.name==="tab")return"next";if(Y.name==="pagedown")return"nextPage";if(Y.name==="pageup")return"prevPage";if(Y.name==="home")return"home";if(Y.name==="end")return"end";if(Y.name==="up")return"up";if(Y.name==="down")return"down";if(Y.name==="right")return"right";if(Y.name==="left")return"left";return!1}});var P1=Q((i7,r0)=>{r0.exports=(Y)=>{let $=["[\\u001B\\u009B][[\\]()#;?]*(?:(?:(?:(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]+)*|[a-zA-Z\\d]+(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]*)*)?\\u0007)","(?:(?:\\d{1,4}(?:;\\d{0,4})*)?[\\dA-PRZcf-ntqry=><~]))"].join("|"),Z=new RegExp($,"g");return typeof Y==="string"?Y.replace(Z,""):Y}});var M=Q((o7,e0)=>{var a1={to(Y,$){if(!$)return`\x1B[${Y+1}G`;return`\x1B[${$+1};${Y+1}H`},move(Y,$){let Z="";if(Y<0)Z+=`\x1B[${-Y}D`;else if(Y>0)Z+=`\x1B[${Y}C`;if($<0)Z+=`\x1B[${-$}A`;else if($>0)Z+=`\x1B[${$}B`;return Z},up:(Y=1)=>`\x1B[${Y}A`,down:(Y=1)=>`\x1B[${Y}B`,forward:(Y=1)=>`\x1B[${Y}C`,backward:(Y=1)=>`\x1B[${Y}D`,nextLine:(Y=1)=>"\x1B[E".repeat(Y),prevLine:(Y=1)=>"\x1B[F".repeat(Y),left:"\x1B[G",hide:"\x1B[?25l",show:"\x1B[?25h",save:"\x1B7",restore:"\x1B8"},_$={up:(Y=1)=>"\x1B[S".repeat(Y),down:(Y=1)=>"\x1B[T".repeat(Y)},b$={screen:"\x1B[2J",up:(Y=1)=>"\x1B[1J".repeat(Y),down:(Y=1)=>"\x1B[J".repeat(Y),line:"\x1B[2K",lineEnd:"\x1B[K",lineStart:"\x1B[1K",lines(Y){let $="";for(let Z=0;Z<Y;Z++)$+=this.line+(Z<Y-1?a1.up():"");if(Y)$+=a1.left;return $}};e0.exports={cursor:a1,scroll:_$,erase:b$,beep:"\x07"}});var U2=Q((t7,H2)=>{function x$(Y,$){var Z=typeof Symbol!=="undefined"&&Y[Symbol.iterator]||Y["@@iterator"];if(!Z){if(Array.isArray(Y)||(Z=h$(Y))||$&&Y&&typeof Y.length==="number"){if(Z)Y=Z;var H=0,D=function z(){};return{s:D,n:function z(){if(H>=Y.length)return{done:!0};return{done:!1,value:Y[H++]}},e:function z(K){throw K},f:D}}throw new TypeError(`Invalid attempt to iterate non-iterable instance.
|
|
4
|
+
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}var U=!0,J=!1,X;return{s:function z(){Z=Z.call(Y)},n:function z(){var K=Z.next();return U=K.done,K},e:function z(K){J=!0,X=K},f:function z(){try{if(!U&&Z.return!=null)Z.return()}finally{if(J)throw X}}}}function h$(Y,$){if(!Y)return;if(typeof Y==="string")return Y2(Y,$);var Z=Object.prototype.toString.call(Y).slice(8,-1);if(Z==="Object"&&Y.constructor)Z=Y.constructor.name;if(Z==="Map"||Z==="Set")return Array.from(Y);if(Z==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(Z))return Y2(Y,$)}function Y2(Y,$){if($==null||$>Y.length)$=Y.length;for(var Z=0,H=new Array($);Z<$;Z++)H[Z]=Y[Z];return H}var f$=P1(),Z2=M(),$2=Z2.erase,w$=Z2.cursor,g$=(Y)=>[...f$(Y)].length;H2.exports=function(Y,$){if(!$)return $2.line+w$.to(0);let Z=0,H=Y.split(/\r?\n/);var D=x$(H),U;try{for(D.s();!(U=D.n()).done;){let J=U.value;Z+=1+Math.floor(Math.max(g$(J)-1,0)/$)}}catch(J){D.e(J)}finally{D.f()}return $2.lines(Z)}});var r1=Q((s7,D2)=>{var z1={arrowUp:"\u2191",arrowDown:"\u2193",arrowLeft:"\u2190",arrowRight:"\u2192",radioOn:"\u25C9",radioOff:"\u25EF",tick:"\u2714",cross:"\u2716",ellipsis:"\u2026",pointerSmall:"\u203A",line:"\u2500",pointer:"\u276F"},v$={arrowUp:z1.arrowUp,arrowDown:z1.arrowDown,arrowLeft:z1.arrowLeft,arrowRight:z1.arrowRight,radioOn:"(*)",radioOff:"( )",tick:"\u221A",cross:"\xD7",ellipsis:"...",pointerSmall:"\xBB",line:"\u2500",pointer:">"},y$=process.platform==="win32"?v$:z1;D2.exports=y$});var X2=Q((a7,J2)=>{var Z1=S(),e=r1(),e1=Object.freeze({password:{scale:1,render:(Y)=>"*".repeat(Y.length)},emoji:{scale:2,render:(Y)=>"\uD83D\uDE03".repeat(Y.length)},invisible:{scale:0,render:(Y)=>""},default:{scale:1,render:(Y)=>`${Y}`}}),d$=(Y)=>e1[Y]||e1.default,K1=Object.freeze({aborted:Z1.red(e.cross),done:Z1.green(e.tick),exited:Z1.yellow(e.cross),default:Z1.cyan("?")}),u$=(Y,$,Z)=>$?K1.aborted:Z?K1.exited:Y?K1.done:K1.default,c$=(Y)=>Z1.gray(Y?e.ellipsis:e.pointerSmall),l$=(Y,$)=>Z1.gray(Y?$?e.pointerSmall:"+":e.line);J2.exports={styles:e1,render:d$,symbols:K1,symbol:u$,delimiter:c$,item:l$}});var z2=Q((r7,Q2)=>{var n$=P1();Q2.exports=function(Y,$){let Z=String(n$(Y)||"").split(/\r?\n/);if(!$)return Z.length;return Z.map((H)=>Math.ceil(H.length/$)).reduce((H,D)=>H+D)}});var B2=Q((e7,K2)=>{K2.exports=(Y,$={})=>{let Z=Number.isSafeInteger(parseInt($.margin))?new Array(parseInt($.margin)).fill(" ").join(""):$.margin||"",H=$.width;return(Y||"").split(/\r?\n/g).map((D)=>D.split(/\s+/g).reduce((U,J)=>{if(J.length+Z.length>=H||U[U.length-1].length+J.length+1<H)U[U.length-1]+=` ${J}`;else U.push(`${Z}${J}`);return U},[Z]).join(`
|
|
5
5
|
`)).join(`
|
|
6
|
-
`)}});var
|
|
7
|
-
`),this.close()}validate(){var Y=this;return
|
|
8
|
-
`),Y.close()})()}next(){if(!this.placeholder)return this.bell();this.value=this.initial,this.cursor=this.rendered.length,this.fire(),this.render()}moveCursor(Y){if(this.placeholder)return;this.cursor=this.cursor+Y,this.cursorOffset+=Y}_(Y,$){let Z=this.value.slice(0,this.cursor),H=this.value.slice(this.cursor);this.value=`${Z}${Y}${H}`,this.red=!1,this.cursor=this.placeholder?0:Z.length+1,this.render()}delete(){if(this.isCursorAtStart())return this.bell();let Y=this.value.slice(0,this.cursor-1),$=this.value.slice(this.cursor);if(this.value=`${Y}${$}`,this.red=!1,this.isCursorAtStart())this.cursorOffset=0;else this.cursorOffset++,this.moveCursor(-1);this.render()}deleteForward(){if(this.cursor*this.scale>=this.rendered.length||this.placeholder)return this.bell();let Y=this.value.slice(0,this.cursor),$=this.value.slice(this.cursor+1);if(this.value=`${Y}${$}`,this.red=!1,this.isCursorAtEnd())this.cursorOffset=0;else this.cursorOffset++;this.render()}first(){this.cursor=0,this.render()}last(){this.cursor=this.value.length,this.render()}left(){if(this.cursor<=0||this.placeholder)return this.bell();this.moveCursor(-1),this.render()}right(){if(this.cursor*this.scale>=this.rendered.length||this.placeholder)return this.bell();this.moveCursor(1),this.render()}isCursorAtStart(){return this.cursor===0||this.placeholder&&this.cursor===1}isCursorAtEnd(){return this.cursor===this.rendered.length||this.placeholder&&this.cursor===this.rendered.length+1}render(){if(this.closed)return;if(!this.firstRender){if(this.outputError)this.out.write(B1.down(
|
|
6
|
+
`)}});var W2=Q((YU,R2)=>{R2.exports=(Y,$,Z)=>{Z=Z||$;let H=Math.min($-Z,Y-Math.floor(Z/2));if(H<0)H=0;let D=Math.min(H+Z,$);return{startIndex:H,endIndex:D}}});var N=Q(($U,E2)=>{E2.exports={action:a0(),clear:U2(),style:X2(),strip:P1(),figures:r1(),lines:z2(),wrap:B2(),entriesToDisplay:W2()}});var g=Q((ZU,M2)=>{var L2=N1("readline"),m$=N(),p$=m$.action,i$=N1("events"),G2=M(),o$=G2.beep,t$=G2.cursor,s$=S();class S2 extends i${constructor(Y={}){super();this.firstRender=!0,this.in=Y.stdin||process.stdin,this.out=Y.stdout||process.stdout,this.onRender=(Y.onRender||(()=>{return})).bind(this);let $=L2.createInterface({input:this.in,escapeCodeTimeout:50});if(L2.emitKeypressEvents(this.in,$),this.in.isTTY)this.in.setRawMode(!0);let Z=["SelectPrompt","MultiselectPrompt"].indexOf(this.constructor.name)>-1,H=(D,U)=>{let J=p$(U,Z);if(J===!1)this._&&this._(D,U);else if(typeof this[J]==="function")this[J](U);else this.bell()};this.close=()=>{if(this.out.write(t$.show),this.in.removeListener("keypress",H),this.in.isTTY)this.in.setRawMode(!1);$.close(),this.emit(this.aborted?"abort":this.exited?"exit":"submit",this.value),this.closed=!0},this.in.on("keypress",H)}fire(){this.emit("state",{value:this.value,aborted:!!this.aborted,exited:!!this.exited})}bell(){this.out.write(o$)}render(){if(this.onRender(s$),this.firstRender)this.firstRender=!1}}M2.exports=S2});var C2=Q((HU,A2)=>{function F2(Y,$,Z,H,D,U,J){try{var X=Y[U](J),z=X.value}catch(K){Z(K);return}if(X.done)$(z);else Promise.resolve(z).then(H,D)}function O2(Y){return function(){var $=this,Z=arguments;return new Promise(function(H,D){var U=Y.apply($,Z);function J(z){F2(U,H,D,J,X,"next",z)}function X(z){F2(U,H,D,J,X,"throw",z)}J(void 0)})}}var j1=S(),a$=g(),V2=M(),r$=V2.erase,B1=V2.cursor,T1=N(),Y0=T1.style,$0=T1.clear,e$=T1.lines,YZ=T1.figures;class I2 extends a${constructor(Y={}){super(Y);this.transform=Y0.render(Y.style),this.scale=this.transform.scale,this.msg=Y.message,this.initial=Y.initial||"",this.validator=Y.validate||(()=>!0),this.value="",this.errorMsg=Y.error||"Please Enter A Valid Value",this.cursor=Number(!!this.initial),this.cursorOffset=0,this.clear=$0("",this.out.columns),this.render()}set value(Y){if(!Y&&this.initial)this.placeholder=!0,this.rendered=j1.gray(this.transform.render(this.initial));else this.placeholder=!1,this.rendered=this.transform.render(Y);this._value=Y,this.fire()}get value(){return this._value}reset(){this.value="",this.cursor=Number(!!this.initial),this.cursorOffset=0,this.fire(),this.render()}exit(){this.abort()}abort(){this.value=this.value||this.initial,this.done=this.aborted=!0,this.error=!1,this.red=!1,this.fire(),this.render(),this.out.write(`
|
|
7
|
+
`),this.close()}validate(){var Y=this;return O2(function*(){let $=yield Y.validator(Y.value);if(typeof $==="string")Y.errorMsg=$,$=!1;Y.error=!$})()}submit(){var Y=this;return O2(function*(){if(Y.value=Y.value||Y.initial,Y.cursorOffset=0,Y.cursor=Y.rendered.length,yield Y.validate(),Y.error){Y.red=!0,Y.fire(),Y.render();return}Y.done=!0,Y.aborted=!1,Y.fire(),Y.render(),Y.out.write(`
|
|
8
|
+
`),Y.close()})()}next(){if(!this.placeholder)return this.bell();this.value=this.initial,this.cursor=this.rendered.length,this.fire(),this.render()}moveCursor(Y){if(this.placeholder)return;this.cursor=this.cursor+Y,this.cursorOffset+=Y}_(Y,$){let Z=this.value.slice(0,this.cursor),H=this.value.slice(this.cursor);this.value=`${Z}${Y}${H}`,this.red=!1,this.cursor=this.placeholder?0:Z.length+1,this.render()}delete(){if(this.isCursorAtStart())return this.bell();let Y=this.value.slice(0,this.cursor-1),$=this.value.slice(this.cursor);if(this.value=`${Y}${$}`,this.red=!1,this.isCursorAtStart())this.cursorOffset=0;else this.cursorOffset++,this.moveCursor(-1);this.render()}deleteForward(){if(this.cursor*this.scale>=this.rendered.length||this.placeholder)return this.bell();let Y=this.value.slice(0,this.cursor),$=this.value.slice(this.cursor+1);if(this.value=`${Y}${$}`,this.red=!1,this.isCursorAtEnd())this.cursorOffset=0;else this.cursorOffset++;this.render()}first(){this.cursor=0,this.render()}last(){this.cursor=this.value.length,this.render()}left(){if(this.cursor<=0||this.placeholder)return this.bell();this.moveCursor(-1),this.render()}right(){if(this.cursor*this.scale>=this.rendered.length||this.placeholder)return this.bell();this.moveCursor(1),this.render()}isCursorAtStart(){return this.cursor===0||this.placeholder&&this.cursor===1}isCursorAtEnd(){return this.cursor===this.rendered.length||this.placeholder&&this.cursor===this.rendered.length+1}render(){if(this.closed)return;if(!this.firstRender){if(this.outputError)this.out.write(B1.down(e$(this.outputError,this.out.columns)-1)+$0(this.outputError,this.out.columns));this.out.write($0(this.outputText,this.out.columns))}if(super.render(),this.outputError="",this.outputText=[Y0.symbol(this.done,this.aborted),j1.bold(this.msg),Y0.delimiter(this.done),this.red?j1.red(this.rendered):this.rendered].join(" "),this.error)this.outputError+=this.errorMsg.split(`
|
|
9
9
|
`).reduce((Y,$,Z)=>Y+`
|
|
10
|
-
${Z?" ":
|
|
10
|
+
${Z?" ":YZ.pointerSmall} ${j1.red().italic($)}`,"");this.out.write(r$.line+B1.to(0)+this.outputText+B1.save+this.outputError+B1.restore+B1.move(this.cursorOffset,0))}}A2.exports=I2});var T2=Q((UU,j2)=>{var v=S(),$Z=g(),R1=N(),q2=R1.style,N2=R1.clear,k1=R1.figures,ZZ=R1.wrap,HZ=R1.entriesToDisplay,UZ=M(),DZ=UZ.cursor;class P2 extends $Z{constructor(Y={}){super(Y);this.msg=Y.message,this.hint=Y.hint||"- Use arrow-keys. Return to submit.",this.warn=Y.warn||"- This option is disabled",this.cursor=Y.initial||0,this.choices=Y.choices.map(($,Z)=>{if(typeof $==="string")$={title:$,value:Z};return{title:$&&($.title||$.value||$),value:$&&($.value===void 0?Z:$.value),description:$&&$.description,selected:$&&$.selected,disabled:$&&$.disabled}}),this.optionsPerPage=Y.optionsPerPage||10,this.value=(this.choices[this.cursor]||{}).value,this.clear=N2("",this.out.columns),this.render()}moveCursor(Y){this.cursor=Y,this.value=this.choices[Y].value,this.fire()}reset(){this.moveCursor(0),this.fire(),this.render()}exit(){this.abort()}abort(){this.done=this.aborted=!0,this.fire(),this.render(),this.out.write(`
|
|
11
11
|
`),this.close()}submit(){if(!this.selection.disabled)this.done=!0,this.aborted=!1,this.fire(),this.render(),this.out.write(`
|
|
12
|
-
`),this.close();else this.bell()}first(){this.moveCursor(0),this.render()}last(){this.moveCursor(this.choices.length-1),this.render()}up(){if(this.cursor===0)this.moveCursor(this.choices.length-1);else this.moveCursor(this.cursor-1);this.render()}down(){if(this.cursor===this.choices.length-1)this.moveCursor(0);else this.moveCursor(this.cursor+1);this.render()}next(){this.moveCursor((this.cursor+1)%this.choices.length),this.render()}_(Y,$){if(Y===" ")return this.submit()}get selection(){return this.choices[this.cursor]}render(){if(this.closed)return;if(this.firstRender)this.out.write(
|
|
13
|
-
`;for(let H=$;H<Z;H++){let U,
|
|
14
|
-
`+
|
|
15
|
-
`}}this.out.write(this.outputText)}}
|
|
12
|
+
`),this.close();else this.bell()}first(){this.moveCursor(0),this.render()}last(){this.moveCursor(this.choices.length-1),this.render()}up(){if(this.cursor===0)this.moveCursor(this.choices.length-1);else this.moveCursor(this.cursor-1);this.render()}down(){if(this.cursor===this.choices.length-1)this.moveCursor(0);else this.moveCursor(this.cursor+1);this.render()}next(){this.moveCursor((this.cursor+1)%this.choices.length),this.render()}_(Y,$){if(Y===" ")return this.submit()}get selection(){return this.choices[this.cursor]}render(){if(this.closed)return;if(this.firstRender)this.out.write(DZ.hide);else this.out.write(N2(this.outputText,this.out.columns));super.render();let Y=HZ(this.cursor,this.choices.length,this.optionsPerPage),$=Y.startIndex,Z=Y.endIndex;if(this.outputText=[q2.symbol(this.done,this.aborted),v.bold(this.msg),q2.delimiter(!1),this.done?this.selection.title:this.selection.disabled?v.yellow(this.warn):v.gray(this.hint)].join(" "),!this.done){this.outputText+=`
|
|
13
|
+
`;for(let H=$;H<Z;H++){let D,U,J="",X=this.choices[H];if(H===$&&$>0)U=k1.arrowUp;else if(H===Z-1&&Z<this.choices.length)U=k1.arrowDown;else U=" ";if(X.disabled)D=this.cursor===H?v.gray().underline(X.title):v.strikethrough().gray(X.title),U=(this.cursor===H?v.bold().gray(k1.pointer)+" ":" ")+U;else if(D=this.cursor===H?v.cyan().underline(X.title):X.title,U=(this.cursor===H?v.cyan(k1.pointer)+" ":" ")+U,X.description&&this.cursor===H){if(J=` - ${X.description}`,U.length+D.length+J.length>=this.out.columns||X.description.split(/\r?\n/).length>1)J=`
|
|
14
|
+
`+ZZ(X.description,{margin:3,width:this.out.columns})}this.outputText+=`${U} ${D}${v.gray(J)}
|
|
15
|
+
`}}this.out.write(this.outputText)}}j2.exports=P2});var w2=Q((DU,f2)=>{var _1=S(),JZ=g(),b2=N(),k2=b2.style,XZ=b2.clear,x2=M(),_2=x2.cursor,QZ=x2.erase;class h2 extends JZ{constructor(Y={}){super(Y);this.msg=Y.message,this.value=!!Y.initial,this.active=Y.active||"on",this.inactive=Y.inactive||"off",this.initialValue=this.value,this.render()}reset(){this.value=this.initialValue,this.fire(),this.render()}exit(){this.abort()}abort(){this.done=this.aborted=!0,this.fire(),this.render(),this.out.write(`
|
|
16
16
|
`),this.close()}submit(){this.done=!0,this.aborted=!1,this.fire(),this.render(),this.out.write(`
|
|
17
|
-
`),this.close()}deactivate(){if(this.value===!1)return this.bell();this.value=!1,this.render()}activate(){if(this.value===!0)return this.bell();this.value=!0,this.render()}delete(){this.deactivate()}left(){this.deactivate()}right(){this.activate()}down(){this.deactivate()}up(){this.activate()}next(){this.value=!this.value,this.fire(),this.render()}_(Y,$){if(Y===" ")this.value=!this.value;else if(Y==="1")this.value=!0;else if(Y==="0")this.value=!1;else return this.bell();this.render()}render(){if(this.closed)return;if(this.firstRender)this.out.write(
|
|
18
|
-
`),this.close()}validate(){var Y=this;return
|
|
19
|
-
`),Y.close()})()}up(){this.typed="",this.parts[this.cursor].up(),this.render()}down(){this.typed="",this.parts[this.cursor].down(),this.render()}left(){let Y=this.parts[this.cursor].prev();if(Y==null)return this.bell();this.moveCursor(this.parts.indexOf(Y)),this.render()}right(){let Y=this.parts[this.cursor].next();if(Y==null)return this.bell();this.moveCursor(this.parts.indexOf(Y)),this.render()}next(){let Y=this.parts[this.cursor].next();this.moveCursor(Y?this.parts.indexOf(Y):this.parts.findIndex(($)=>$ instanceof
|
|
17
|
+
`),this.close()}deactivate(){if(this.value===!1)return this.bell();this.value=!1,this.render()}activate(){if(this.value===!0)return this.bell();this.value=!0,this.render()}delete(){this.deactivate()}left(){this.deactivate()}right(){this.activate()}down(){this.deactivate()}up(){this.activate()}next(){this.value=!this.value,this.fire(),this.render()}_(Y,$){if(Y===" ")this.value=!this.value;else if(Y==="1")this.value=!0;else if(Y==="0")this.value=!1;else return this.bell();this.render()}render(){if(this.closed)return;if(this.firstRender)this.out.write(_2.hide);else this.out.write(XZ(this.outputText,this.out.columns));super.render(),this.outputText=[k2.symbol(this.done,this.aborted),_1.bold(this.msg),k2.delimiter(this.done),this.value?this.inactive:_1.cyan().underline(this.inactive),_1.gray("/"),this.value?_1.cyan().underline(this.active):this.active].join(" "),this.out.write(QZ.line+_2.to(0)+this.outputText)}}f2.exports=h2});var T=Q((JU,g2)=>{class b1{constructor({token:Y,date:$,parts:Z,locales:H}){this.token=Y,this.date=$||new Date,this.parts=Z||[this],this.locales=H||{}}up(){}down(){}next(){let Y=this.parts.indexOf(this);return this.parts.find(($,Z)=>Z>Y&&$ instanceof b1)}setTo(Y){}prev(){let Y=[].concat(this.parts).reverse(),$=Y.indexOf(this);return Y.find((Z,H)=>H>$&&Z instanceof b1)}toString(){return String(this.date)}}g2.exports=b1});var d2=Q((XU,y2)=>{var zZ=T();class v2 extends zZ{constructor(Y={}){super(Y)}up(){this.date.setHours((this.date.getHours()+12)%24)}down(){this.up()}toString(){let Y=this.date.getHours()>12?"pm":"am";return/\A/.test(this.token)?Y.toUpperCase():Y}}y2.exports=v2});var l2=Q((QU,c2)=>{var KZ=T(),BZ=(Y)=>{return Y=Y%10,Y===1?"st":Y===2?"nd":Y===3?"rd":"th"};class u2 extends KZ{constructor(Y={}){super(Y)}up(){this.date.setDate(this.date.getDate()+1)}down(){this.date.setDate(this.date.getDate()-1)}setTo(Y){this.date.setDate(parseInt(Y.substr(-2)))}toString(){let Y=this.date.getDate(),$=this.date.getDay();return this.token==="DD"?String(Y).padStart(2,"0"):this.token==="Do"?Y+BZ(Y):this.token==="d"?$+1:this.token==="ddd"?this.locales.weekdaysShort[$]:this.token==="dddd"?this.locales.weekdays[$]:Y}}c2.exports=u2});var p2=Q((zU,m2)=>{var RZ=T();class n2 extends RZ{constructor(Y={}){super(Y)}up(){this.date.setHours(this.date.getHours()+1)}down(){this.date.setHours(this.date.getHours()-1)}setTo(Y){this.date.setHours(parseInt(Y.substr(-2)))}toString(){let Y=this.date.getHours();if(/h/.test(this.token))Y=Y%12||12;return this.token.length>1?String(Y).padStart(2,"0"):Y}}m2.exports=n2});var t2=Q((KU,o2)=>{var WZ=T();class i2 extends WZ{constructor(Y={}){super(Y)}up(){this.date.setMilliseconds(this.date.getMilliseconds()+1)}down(){this.date.setMilliseconds(this.date.getMilliseconds()-1)}setTo(Y){this.date.setMilliseconds(parseInt(Y.substr(-this.token.length)))}toString(){return String(this.date.getMilliseconds()).padStart(4,"0").substr(0,this.token.length)}}o2.exports=i2});var r2=Q((BU,a2)=>{var EZ=T();class s2 extends EZ{constructor(Y={}){super(Y)}up(){this.date.setMinutes(this.date.getMinutes()+1)}down(){this.date.setMinutes(this.date.getMinutes()-1)}setTo(Y){this.date.setMinutes(parseInt(Y.substr(-2)))}toString(){let Y=this.date.getMinutes();return this.token.length>1?String(Y).padStart(2,"0"):Y}}a2.exports=s2});var $4=Q((RU,Y4)=>{var LZ=T();class e2 extends LZ{constructor(Y={}){super(Y)}up(){this.date.setMonth(this.date.getMonth()+1)}down(){this.date.setMonth(this.date.getMonth()-1)}setTo(Y){Y=parseInt(Y.substr(-2))-1,this.date.setMonth(Y<0?0:Y)}toString(){let Y=this.date.getMonth(),$=this.token.length;return $===2?String(Y+1).padStart(2,"0"):$===3?this.locales.monthsShort[Y]:$===4?this.locales.months[Y]:String(Y+1)}}Y4.exports=e2});var U4=Q((WU,H4)=>{var GZ=T();class Z4 extends GZ{constructor(Y={}){super(Y)}up(){this.date.setSeconds(this.date.getSeconds()+1)}down(){this.date.setSeconds(this.date.getSeconds()-1)}setTo(Y){this.date.setSeconds(parseInt(Y.substr(-2)))}toString(){let Y=this.date.getSeconds();return this.token.length>1?String(Y).padStart(2,"0"):Y}}H4.exports=Z4});var X4=Q((EU,J4)=>{var SZ=T();class D4 extends SZ{constructor(Y={}){super(Y)}up(){this.date.setFullYear(this.date.getFullYear()+1)}down(){this.date.setFullYear(this.date.getFullYear()-1)}setTo(Y){this.date.setFullYear(Y.substr(-4))}toString(){let Y=String(this.date.getFullYear()).padStart(4,"0");return this.token.length===2?Y.substr(-2):Y}}J4.exports=D4});var z4=Q((LU,Q4)=>{Q4.exports={DatePart:T(),Meridiem:d2(),Day:l2(),Hours:p2(),Milliseconds:t2(),Minutes:r2(),Month:$4(),Seconds:U4(),Year:X4()}});var O4=Q((GU,F4)=>{function K4(Y,$,Z,H,D,U,J){try{var X=Y[U](J),z=X.value}catch(K){Z(K);return}if(X.done)$(z);else Promise.resolve(z).then(H,D)}function B4(Y){return function(){var $=this,Z=arguments;return new Promise(function(H,D){var U=Y.apply($,Z);function J(z){K4(U,H,D,J,X,"next",z)}function X(z){K4(U,H,D,J,X,"throw",z)}J(void 0)})}}var Z0=S(),MZ=g(),H0=N(),R4=H0.style,W4=H0.clear,FZ=H0.figures,S4=M(),OZ=S4.erase,E4=S4.cursor,y=z4(),L4=y.DatePart,VZ=y.Meridiem,IZ=y.Day,AZ=y.Hours,CZ=y.Milliseconds,qZ=y.Minutes,NZ=y.Month,PZ=y.Seconds,jZ=y.Year,TZ=/\\(.)|"((?:\\["\\]|[^"])+)"|(D[Do]?|d{3,4}|d)|(M{1,4})|(YY(?:YY)?)|([aA])|([Hh]{1,2})|(m{1,2})|(s{1,2})|(S{1,4})|./g,G4={1:({token:Y})=>Y.replace(/\\(.)/g,"$1"),2:(Y)=>new IZ(Y),3:(Y)=>new NZ(Y),4:(Y)=>new jZ(Y),5:(Y)=>new VZ(Y),6:(Y)=>new AZ(Y),7:(Y)=>new qZ(Y),8:(Y)=>new PZ(Y),9:(Y)=>new CZ(Y)},kZ={months:"January,February,March,April,May,June,July,August,September,October,November,December".split(","),monthsShort:"Jan,Feb,Mar,Apr,May,Jun,Jul,Aug,Sep,Oct,Nov,Dec".split(","),weekdays:"Sunday,Monday,Tuesday,Wednesday,Thursday,Friday,Saturday".split(","),weekdaysShort:"Sun,Mon,Tue,Wed,Thu,Fri,Sat".split(",")};class M4 extends MZ{constructor(Y={}){super(Y);this.msg=Y.message,this.cursor=0,this.typed="",this.locales=Object.assign(kZ,Y.locales),this._date=Y.initial||new Date,this.errorMsg=Y.error||"Please Enter A Valid Value",this.validator=Y.validate||(()=>!0),this.mask=Y.mask||"YYYY-MM-DD HH:mm:ss",this.clear=W4("",this.out.columns),this.render()}get value(){return this.date}get date(){return this._date}set date(Y){if(Y)this._date.setTime(Y.getTime())}set mask(Y){let $;this.parts=[];while($=TZ.exec(Y)){let H=$.shift(),D=$.findIndex((U)=>U!=null);this.parts.push(D in G4?G4[D]({token:$[D]||H,date:this.date,parts:this.parts,locales:this.locales}):$[D]||H)}let Z=this.parts.reduce((H,D)=>{if(typeof D==="string"&&typeof H[H.length-1]==="string")H[H.length-1]+=D;else H.push(D);return H},[]);this.parts.splice(0),this.parts.push(...Z),this.reset()}moveCursor(Y){this.typed="",this.cursor=Y,this.fire()}reset(){this.moveCursor(this.parts.findIndex((Y)=>Y instanceof L4)),this.fire(),this.render()}exit(){this.abort()}abort(){this.done=this.aborted=!0,this.error=!1,this.fire(),this.render(),this.out.write(`
|
|
18
|
+
`),this.close()}validate(){var Y=this;return B4(function*(){let $=yield Y.validator(Y.value);if(typeof $==="string")Y.errorMsg=$,$=!1;Y.error=!$})()}submit(){var Y=this;return B4(function*(){if(yield Y.validate(),Y.error){Y.color="red",Y.fire(),Y.render();return}Y.done=!0,Y.aborted=!1,Y.fire(),Y.render(),Y.out.write(`
|
|
19
|
+
`),Y.close()})()}up(){this.typed="",this.parts[this.cursor].up(),this.render()}down(){this.typed="",this.parts[this.cursor].down(),this.render()}left(){let Y=this.parts[this.cursor].prev();if(Y==null)return this.bell();this.moveCursor(this.parts.indexOf(Y)),this.render()}right(){let Y=this.parts[this.cursor].next();if(Y==null)return this.bell();this.moveCursor(this.parts.indexOf(Y)),this.render()}next(){let Y=this.parts[this.cursor].next();this.moveCursor(Y?this.parts.indexOf(Y):this.parts.findIndex(($)=>$ instanceof L4)),this.render()}_(Y){if(/\d/.test(Y))this.typed+=Y,this.parts[this.cursor].setTo(this.typed),this.render()}render(){if(this.closed)return;if(this.firstRender)this.out.write(E4.hide);else this.out.write(W4(this.outputText,this.out.columns));if(super.render(),this.outputText=[R4.symbol(this.done,this.aborted),Z0.bold(this.msg),R4.delimiter(!1),this.parts.reduce((Y,$,Z)=>Y.concat(Z===this.cursor&&!this.done?Z0.cyan().underline($.toString()):$),[]).join("")].join(" "),this.error)this.outputText+=this.errorMsg.split(`
|
|
20
20
|
`).reduce((Y,$,Z)=>Y+`
|
|
21
|
-
${Z?" ":
|
|
22
|
-
`),this.close()}validate(){var Y=this;return
|
|
23
|
-
`),Y.close()})()}up(){if(this.typed="",this.value==="")this.value=this.min-this.inc;if(this.value>=this.max)return this.bell();this.value+=this.inc,this.color="cyan",this.fire(),this.render()}down(){if(this.typed="",this.value==="")this.value=this.min+this.inc;if(this.value<=this.min)return this.bell();this.value-=this.inc,this.color="cyan",this.fire(),this.render()}delete(){let Y=this.value.toString();if(Y.length===0)return this.bell();if(this.value=this.parse(Y=Y.slice(0,-1))||"",this.value!==""&&this.value<this.min)this.value=this.min;this.color="cyan",this.fire(),this.render()}next(){this.value=this.initial,this.fire(),this.render()}_(Y,$){if(!this.valid(Y))return this.bell();let Z=Date.now();if(Z-this.lastHit>1000)this.typed="";if(this.typed+=Y,this.lastHit=Z,this.color="cyan",Y===".")return this.fire();if(this.value=Math.min(this.parse(this.typed),this.max),this.value>this.max)this.value=this.max;if(this.value<this.min)this.value=this.min;this.fire(),this.render()}render(){if(this.closed)return;if(!this.firstRender){if(this.outputError)this.out.write(
|
|
21
|
+
${Z?" ":FZ.pointerSmall} ${Z0.red().italic($)}`,"");this.out.write(OZ.line+E4.to(0)+this.outputText)}}F4.exports=M4});var j4=Q((SU,P4)=>{function V4(Y,$,Z,H,D,U,J){try{var X=Y[U](J),z=X.value}catch(K){Z(K);return}if(X.done)$(z);else Promise.resolve(z).then(H,D)}function I4(Y){return function(){var $=this,Z=arguments;return new Promise(function(H,D){var U=Y.apply($,Z);function J(z){V4(U,H,D,J,X,"next",z)}function X(z){V4(U,H,D,J,X,"throw",z)}J(void 0)})}}var x1=S(),_Z=g(),q4=M(),h1=q4.cursor,bZ=q4.erase,f1=N(),U0=f1.style,xZ=f1.figures,A4=f1.clear,hZ=f1.lines,fZ=/[0-9]/,D0=(Y)=>Y!==void 0,C4=(Y,$)=>{let Z=Math.pow(10,$);return Math.round(Y*Z)/Z};class N4 extends _Z{constructor(Y={}){super(Y);this.transform=U0.render(Y.style),this.msg=Y.message,this.initial=D0(Y.initial)?Y.initial:"",this.float=!!Y.float,this.round=Y.round||2,this.inc=Y.increment||1,this.min=D0(Y.min)?Y.min:-1/0,this.max=D0(Y.max)?Y.max:1/0,this.errorMsg=Y.error||"Please Enter A Valid Value",this.validator=Y.validate||(()=>!0),this.color="cyan",this.value="",this.typed="",this.lastHit=0,this.render()}set value(Y){if(!Y&&Y!==0)this.placeholder=!0,this.rendered=x1.gray(this.transform.render(`${this.initial}`)),this._value="";else this.placeholder=!1,this.rendered=this.transform.render(`${C4(Y,this.round)}`),this._value=C4(Y,this.round);this.fire()}get value(){return this._value}parse(Y){return this.float?parseFloat(Y):parseInt(Y)}valid(Y){return Y==="-"||Y==="."&&this.float||fZ.test(Y)}reset(){this.typed="",this.value="",this.fire(),this.render()}exit(){this.abort()}abort(){let Y=this.value;this.value=Y!==""?Y:this.initial,this.done=this.aborted=!0,this.error=!1,this.fire(),this.render(),this.out.write(`
|
|
22
|
+
`),this.close()}validate(){var Y=this;return I4(function*(){let $=yield Y.validator(Y.value);if(typeof $==="string")Y.errorMsg=$,$=!1;Y.error=!$})()}submit(){var Y=this;return I4(function*(){if(yield Y.validate(),Y.error){Y.color="red",Y.fire(),Y.render();return}let $=Y.value;Y.value=$!==""?$:Y.initial,Y.done=!0,Y.aborted=!1,Y.error=!1,Y.fire(),Y.render(),Y.out.write(`
|
|
23
|
+
`),Y.close()})()}up(){if(this.typed="",this.value==="")this.value=this.min-this.inc;if(this.value>=this.max)return this.bell();this.value+=this.inc,this.color="cyan",this.fire(),this.render()}down(){if(this.typed="",this.value==="")this.value=this.min+this.inc;if(this.value<=this.min)return this.bell();this.value-=this.inc,this.color="cyan",this.fire(),this.render()}delete(){let Y=this.value.toString();if(Y.length===0)return this.bell();if(this.value=this.parse(Y=Y.slice(0,-1))||"",this.value!==""&&this.value<this.min)this.value=this.min;this.color="cyan",this.fire(),this.render()}next(){this.value=this.initial,this.fire(),this.render()}_(Y,$){if(!this.valid(Y))return this.bell();let Z=Date.now();if(Z-this.lastHit>1000)this.typed="";if(this.typed+=Y,this.lastHit=Z,this.color="cyan",Y===".")return this.fire();if(this.value=Math.min(this.parse(this.typed),this.max),this.value>this.max)this.value=this.max;if(this.value<this.min)this.value=this.min;this.fire(),this.render()}render(){if(this.closed)return;if(!this.firstRender){if(this.outputError)this.out.write(h1.down(hZ(this.outputError,this.out.columns)-1)+A4(this.outputError,this.out.columns));this.out.write(A4(this.outputText,this.out.columns))}if(super.render(),this.outputError="",this.outputText=[U0.symbol(this.done,this.aborted),x1.bold(this.msg),U0.delimiter(this.done),!this.done||!this.done&&!this.placeholder?x1[this.color]().underline(this.rendered):this.rendered].join(" "),this.error)this.outputError+=this.errorMsg.split(`
|
|
24
24
|
`).reduce((Y,$,Z)=>Y+`
|
|
25
|
-
${Z?" ":
|
|
25
|
+
${Z?" ":xZ.pointerSmall} ${x1.red().italic($)}`,"");this.out.write(bZ.line+h1.to(0)+this.outputText+h1.save+this.outputError+h1.restore)}}P4.exports=N4});var J0=Q((MU,b4)=>{var k=S(),wZ=M(),gZ=wZ.cursor,vZ=g(),W1=N(),T4=W1.clear,i=W1.figures,k4=W1.style,yZ=W1.wrap,dZ=W1.entriesToDisplay;class _4 extends vZ{constructor(Y={}){super(Y);if(this.msg=Y.message,this.cursor=Y.cursor||0,this.scrollIndex=Y.cursor||0,this.hint=Y.hint||"",this.warn=Y.warn||"- This option is disabled -",this.minSelected=Y.min,this.showMinError=!1,this.maxChoices=Y.max,this.instructions=Y.instructions,this.optionsPerPage=Y.optionsPerPage||10,this.value=Y.choices.map(($,Z)=>{if(typeof $==="string")$={title:$,value:Z};return{title:$&&($.title||$.value||$),description:$&&$.description,value:$&&($.value===void 0?Z:$.value),selected:$&&$.selected,disabled:$&&$.disabled}}),this.clear=T4("",this.out.columns),!Y.overrideRender)this.render()}reset(){this.value.map((Y)=>!Y.selected),this.cursor=0,this.fire(),this.render()}selected(){return this.value.filter((Y)=>Y.selected)}exit(){this.abort()}abort(){this.done=this.aborted=!0,this.fire(),this.render(),this.out.write(`
|
|
26
26
|
`),this.close()}submit(){let Y=this.value.filter(($)=>$.selected);if(this.minSelected&&Y.length<this.minSelected)this.showMinError=!0,this.render();else this.done=!0,this.aborted=!1,this.fire(),this.render(),this.out.write(`
|
|
27
27
|
`),this.close()}first(){this.cursor=0,this.render()}last(){this.cursor=this.value.length-1,this.render()}next(){this.cursor=(this.cursor+1)%this.value.length,this.render()}up(){if(this.cursor===0)this.cursor=this.value.length-1;else this.cursor--;this.render()}down(){if(this.cursor===this.value.length-1)this.cursor=0;else this.cursor++;this.render()}left(){this.value[this.cursor].selected=!1,this.render()}right(){if(this.value.filter((Y)=>Y.selected).length>=this.maxChoices)return this.bell();this.value[this.cursor].selected=!0,this.render()}handleSpaceToggle(){let Y=this.value[this.cursor];if(Y.selected)Y.selected=!1,this.render();else if(Y.disabled||this.value.filter(($)=>$.selected).length>=this.maxChoices)return this.bell();else Y.selected=!0,this.render()}toggleAll(){if(this.maxChoices!==void 0||this.value[this.cursor].disabled)return this.bell();let Y=!this.value[this.cursor].selected;this.value.filter(($)=>!$.disabled).forEach(($)=>$.selected=Y),this.render()}_(Y,$){if(Y===" ")this.handleSpaceToggle();else if(Y==="a")this.toggleAll();else return this.bell()}renderInstructions(){if(this.instructions===void 0||this.instructions){if(typeof this.instructions==="string")return this.instructions;return`
|
|
28
28
|
Instructions:
|
|
29
|
-
${
|
|
30
|
-
${
|
|
29
|
+
${i.arrowUp}/${i.arrowDown}: Highlight option
|
|
30
|
+
${i.arrowLeft}/${i.arrowRight}/[space]: Toggle selection
|
|
31
31
|
`+(this.maxChoices===void 0?` a: Toggle all
|
|
32
|
-
`:"")+" enter/return: Complete answer"}return""}renderOption(Y,$,Z,H){let
|
|
33
|
-
`+
|
|
34
|
-
`+
|
|
35
|
-
`)}renderOptions(Y){if(!this.done)return this.paginateOptions(Y);return""}renderDoneOrInstructions(){if(this.done)return this.value.filter(($)=>$.selected).map(($)=>$.title).join(", ");let Y=[
|
|
32
|
+
`:"")+" enter/return: Complete answer"}return""}renderOption(Y,$,Z,H){let D=($.selected?k.green(i.radioOn):i.radioOff)+" "+H+" ",U,J;if($.disabled)U=Y===Z?k.gray().underline($.title):k.strikethrough().gray($.title);else if(U=Y===Z?k.cyan().underline($.title):$.title,Y===Z&&$.description){if(J=` - ${$.description}`,D.length+U.length+J.length>=this.out.columns||$.description.split(/\r?\n/).length>1)J=`
|
|
33
|
+
`+yZ($.description,{margin:D.length,width:this.out.columns})}return D+U+k.gray(J||"")}paginateOptions(Y){if(Y.length===0)return k.red("No matches for this query.");let $=dZ(this.cursor,Y.length,this.optionsPerPage),Z=$.startIndex,H=$.endIndex,D,U=[];for(let J=Z;J<H;J++){if(J===Z&&Z>0)D=i.arrowUp;else if(J===H-1&&H<Y.length)D=i.arrowDown;else D=" ";U.push(this.renderOption(this.cursor,Y[J],J,D))}return`
|
|
34
|
+
`+U.join(`
|
|
35
|
+
`)}renderOptions(Y){if(!this.done)return this.paginateOptions(Y);return""}renderDoneOrInstructions(){if(this.done)return this.value.filter(($)=>$.selected).map(($)=>$.title).join(", ");let Y=[k.gray(this.hint),this.renderInstructions()];if(this.value[this.cursor].disabled)Y.push(k.yellow(this.warn));return Y.join(" ")}render(){if(this.closed)return;if(this.firstRender)this.out.write(gZ.hide);super.render();let Y=[k4.symbol(this.done,this.aborted),k.bold(this.msg),k4.delimiter(!1),this.renderDoneOrInstructions()].join(" ");if(this.showMinError)Y+=k.red(`You must select a minimum of ${this.minSelected} choices.`),this.showMinError=!1;Y+=this.renderOptions(this.value),this.out.write(this.clear+Y),this.clear=T4(Y,this.out.columns)}}b4.exports=_4});var d4=Q((FU,y4)=>{function x4(Y,$,Z,H,D,U,J){try{var X=Y[U](J),z=X.value}catch(K){Z(K);return}if(X.done)$(z);else Promise.resolve(z).then(H,D)}function uZ(Y){return function(){var $=this,Z=arguments;return new Promise(function(H,D){var U=Y.apply($,Z);function J(z){x4(U,H,D,J,X,"next",z)}function X(z){x4(U,H,D,J,X,"throw",z)}J(void 0)})}}var E1=S(),cZ=g(),g4=M(),lZ=g4.erase,h4=g4.cursor,L1=N(),X0=L1.style,f4=L1.clear,Q0=L1.figures,nZ=L1.wrap,mZ=L1.entriesToDisplay,w4=(Y,$)=>Y[$]&&(Y[$].value||Y[$].title||Y[$]),pZ=(Y,$)=>Y[$]&&(Y[$].title||Y[$].value||Y[$]),iZ=(Y,$)=>{let Z=Y.findIndex((H)=>H.value===$||H.title===$);return Z>-1?Z:void 0};class v4 extends cZ{constructor(Y={}){super(Y);this.msg=Y.message,this.suggest=Y.suggest,this.choices=Y.choices,this.initial=typeof Y.initial==="number"?Y.initial:iZ(Y.choices,Y.initial),this.select=this.initial||Y.cursor||0,this.i18n={noMatches:Y.noMatches||"no matches found"},this.fallback=Y.fallback||this.initial,this.clearFirst=Y.clearFirst||!1,this.suggestions=[],this.input="",this.limit=Y.limit||10,this.cursor=0,this.transform=X0.render(Y.style),this.scale=this.transform.scale,this.render=this.render.bind(this),this.complete=this.complete.bind(this),this.clear=f4("",this.out.columns),this.complete(this.render),this.render()}set fallback(Y){this._fb=Number.isSafeInteger(parseInt(Y))?parseInt(Y):Y}get fallback(){let Y;if(typeof this._fb==="number")Y=this.choices[this._fb];else if(typeof this._fb==="string")Y={title:this._fb};return Y||this._fb||{title:this.i18n.noMatches}}moveSelect(Y){if(this.select=Y,this.suggestions.length>0)this.value=w4(this.suggestions,Y);else this.value=this.fallback.value;this.fire()}complete(Y){var $=this;return uZ(function*(){let Z=$.completing=$.suggest($.input,$.choices),H=yield Z;if($.completing!==Z)return;$.suggestions=H.map((U,J,X)=>({title:pZ(X,J),value:w4(X,J),description:U.description})),$.completing=!1;let D=Math.max(H.length-1,0);$.moveSelect(Math.min(D,$.select)),Y&&Y()})()}reset(){this.input="",this.complete(()=>{this.moveSelect(this.initial!==void 0?this.initial:0),this.render()}),this.render()}exit(){if(this.clearFirst&&this.input.length>0)this.reset();else this.done=this.exited=!0,this.aborted=!1,this.fire(),this.render(),this.out.write(`
|
|
36
36
|
`),this.close()}abort(){this.done=this.aborted=!0,this.exited=!1,this.fire(),this.render(),this.out.write(`
|
|
37
37
|
`),this.close()}submit(){this.done=!0,this.aborted=this.exited=!1,this.fire(),this.render(),this.out.write(`
|
|
38
|
-
`),this.close()}_(Y,$){let Z=this.input.slice(0,this.cursor),H=this.input.slice(this.cursor);this.input=`${Z}${Y}${H}`,this.cursor=Z.length+1,this.complete(this.render),this.render()}delete(){if(this.cursor===0)return this.bell();let Y=this.input.slice(0,this.cursor-1),$=this.input.slice(this.cursor);this.input=`${Y}${$}`,this.complete(this.render),this.cursor=this.cursor-1,this.render()}deleteForward(){if(this.cursor*this.scale>=this.rendered.length)return this.bell();let Y=this.input.slice(0,this.cursor),$=this.input.slice(this.cursor+1);this.input=`${Y}${$}`,this.complete(this.render),this.render()}first(){this.moveSelect(0),this.render()}last(){this.moveSelect(this.suggestions.length-1),this.render()}up(){if(this.select===0)this.moveSelect(this.suggestions.length-1);else this.moveSelect(this.select-1);this.render()}down(){if(this.select===this.suggestions.length-1)this.moveSelect(0);else this.moveSelect(this.select+1);this.render()}next(){if(this.select===this.suggestions.length-1)this.moveSelect(0);else this.moveSelect(this.select+1);this.render()}nextPage(){this.moveSelect(Math.min(this.select+this.limit,this.suggestions.length-1)),this.render()}prevPage(){this.moveSelect(Math.max(this.select-this.limit,0)),this.render()}left(){if(this.cursor<=0)return this.bell();this.cursor=this.cursor-1,this.render()}right(){if(this.cursor*this.scale>=this.rendered.length)return this.bell();this.cursor=this.cursor+1,this.render()}renderOption(Y,$,Z,H){let U
|
|
39
|
-
`+
|
|
38
|
+
`),this.close()}_(Y,$){let Z=this.input.slice(0,this.cursor),H=this.input.slice(this.cursor);this.input=`${Z}${Y}${H}`,this.cursor=Z.length+1,this.complete(this.render),this.render()}delete(){if(this.cursor===0)return this.bell();let Y=this.input.slice(0,this.cursor-1),$=this.input.slice(this.cursor);this.input=`${Y}${$}`,this.complete(this.render),this.cursor=this.cursor-1,this.render()}deleteForward(){if(this.cursor*this.scale>=this.rendered.length)return this.bell();let Y=this.input.slice(0,this.cursor),$=this.input.slice(this.cursor+1);this.input=`${Y}${$}`,this.complete(this.render),this.render()}first(){this.moveSelect(0),this.render()}last(){this.moveSelect(this.suggestions.length-1),this.render()}up(){if(this.select===0)this.moveSelect(this.suggestions.length-1);else this.moveSelect(this.select-1);this.render()}down(){if(this.select===this.suggestions.length-1)this.moveSelect(0);else this.moveSelect(this.select+1);this.render()}next(){if(this.select===this.suggestions.length-1)this.moveSelect(0);else this.moveSelect(this.select+1);this.render()}nextPage(){this.moveSelect(Math.min(this.select+this.limit,this.suggestions.length-1)),this.render()}prevPage(){this.moveSelect(Math.max(this.select-this.limit,0)),this.render()}left(){if(this.cursor<=0)return this.bell();this.cursor=this.cursor-1,this.render()}right(){if(this.cursor*this.scale>=this.rendered.length)return this.bell();this.cursor=this.cursor+1,this.render()}renderOption(Y,$,Z,H){let D,U=Z?Q0.arrowUp:H?Q0.arrowDown:" ",J=$?E1.cyan().underline(Y.title):Y.title;if(U=($?E1.cyan(Q0.pointer)+" ":" ")+U,Y.description){if(D=` - ${Y.description}`,U.length+J.length+D.length>=this.out.columns||Y.description.split(/\r?\n/).length>1)D=`
|
|
39
|
+
`+nZ(Y.description,{margin:3,width:this.out.columns})}return U+" "+J+E1.gray(D||"")}render(){if(this.closed)return;if(this.firstRender)this.out.write(h4.hide);else this.out.write(f4(this.outputText,this.out.columns));super.render();let Y=mZ(this.select,this.choices.length,this.limit),$=Y.startIndex,Z=Y.endIndex;if(this.outputText=[X0.symbol(this.done,this.aborted,this.exited),E1.bold(this.msg),X0.delimiter(this.completing),this.done&&this.suggestions[this.select]?this.suggestions[this.select].title:this.rendered=this.transform.render(this.input)].join(" "),!this.done){let H=this.suggestions.slice($,Z).map((D,U)=>this.renderOption(D,this.select===U+$,U===0&&$>0,U+$===Z-1&&Z<this.choices.length)).join(`
|
|
40
40
|
`);this.outputText+=`
|
|
41
|
-
`+(H||
|
|
41
|
+
`+(H||E1.gray(this.fallback.title))}this.out.write(lZ.line+h4.to(0)+this.outputText)}}y4.exports=v4});var m4=Q((OU,n4)=>{var d=S(),oZ=M(),tZ=oZ.cursor,sZ=J0(),z0=N(),u4=z0.clear,c4=z0.style,H1=z0.figures;class l4 extends sZ{constructor(Y={}){Y.overrideRender=!0;super(Y);this.inputValue="",this.clear=u4("",this.out.columns),this.filteredOptions=this.value,this.render()}last(){this.cursor=this.filteredOptions.length-1,this.render()}next(){this.cursor=(this.cursor+1)%this.filteredOptions.length,this.render()}up(){if(this.cursor===0)this.cursor=this.filteredOptions.length-1;else this.cursor--;this.render()}down(){if(this.cursor===this.filteredOptions.length-1)this.cursor=0;else this.cursor++;this.render()}left(){this.filteredOptions[this.cursor].selected=!1,this.render()}right(){if(this.value.filter((Y)=>Y.selected).length>=this.maxChoices)return this.bell();this.filteredOptions[this.cursor].selected=!0,this.render()}delete(){if(this.inputValue.length)this.inputValue=this.inputValue.substr(0,this.inputValue.length-1),this.updateFilteredOptions()}updateFilteredOptions(){let Y=this.filteredOptions[this.cursor];this.filteredOptions=this.value.filter((Z)=>{if(this.inputValue){if(typeof Z.title==="string"){if(Z.title.toLowerCase().includes(this.inputValue.toLowerCase()))return!0}if(typeof Z.value==="string"){if(Z.value.toLowerCase().includes(this.inputValue.toLowerCase()))return!0}return!1}return!0});let $=this.filteredOptions.findIndex((Z)=>Z===Y);this.cursor=$<0?0:$,this.render()}handleSpaceToggle(){let Y=this.filteredOptions[this.cursor];if(Y.selected)Y.selected=!1,this.render();else if(Y.disabled||this.value.filter(($)=>$.selected).length>=this.maxChoices)return this.bell();else Y.selected=!0,this.render()}handleInputChange(Y){this.inputValue=this.inputValue+Y,this.updateFilteredOptions()}_(Y,$){if(Y===" ")this.handleSpaceToggle();else this.handleInputChange(Y)}renderInstructions(){if(this.instructions===void 0||this.instructions){if(typeof this.instructions==="string")return this.instructions;return`
|
|
42
42
|
Instructions:
|
|
43
|
-
${
|
|
44
|
-
${
|
|
43
|
+
${H1.arrowUp}/${H1.arrowDown}: Highlight option
|
|
44
|
+
${H1.arrowLeft}/${H1.arrowRight}/[space]: Toggle selection
|
|
45
45
|
[a,b,c]/delete: Filter choices
|
|
46
46
|
enter/return: Complete answer
|
|
47
47
|
`}return""}renderCurrentInput(){return`
|
|
48
|
-
Filtered results for: ${this.inputValue?this.inputValue:
|
|
49
|
-
`}renderOption(Y,$,Z){let H;if($.disabled)H=Y===Z?
|
|
48
|
+
Filtered results for: ${this.inputValue?this.inputValue:d.gray("Enter something to filter")}
|
|
49
|
+
`}renderOption(Y,$,Z){let H;if($.disabled)H=Y===Z?d.gray().underline($.title):d.strikethrough().gray($.title);else H=Y===Z?d.cyan().underline($.title):$.title;return($.selected?d.green(H1.radioOn):H1.radioOff)+" "+H}renderDoneOrInstructions(){if(this.done)return this.value.filter(($)=>$.selected).map(($)=>$.title).join(", ");let Y=[d.gray(this.hint),this.renderInstructions(),this.renderCurrentInput()];if(this.filteredOptions.length&&this.filteredOptions[this.cursor].disabled)Y.push(d.yellow(this.warn));return Y.join(" ")}render(){if(this.closed)return;if(this.firstRender)this.out.write(tZ.hide);super.render();let Y=[c4.symbol(this.done,this.aborted),d.bold(this.msg),c4.delimiter(!1),this.renderDoneOrInstructions()].join(" ");if(this.showMinError)Y+=d.red(`You must select a minimum of ${this.minSelected} choices.`),this.showMinError=!1;Y+=this.renderOptions(this.filteredOptions),this.out.write(this.clear+Y),this.clear=u4(Y,this.out.columns)}}n4.exports=l4});var e4=Q((VU,r4)=>{var p4=S(),aZ=g(),t4=N(),i4=t4.style,rZ=t4.clear,s4=M(),eZ=s4.erase,o4=s4.cursor;class a4 extends aZ{constructor(Y={}){super(Y);this.msg=Y.message,this.value=Y.initial,this.initialValue=!!Y.initial,this.yesMsg=Y.yes||"yes",this.yesOption=Y.yesOption||"(Y/n)",this.noMsg=Y.no||"no",this.noOption=Y.noOption||"(y/N)",this.render()}reset(){this.value=this.initialValue,this.fire(),this.render()}exit(){this.abort()}abort(){this.done=this.aborted=!0,this.fire(),this.render(),this.out.write(`
|
|
50
50
|
`),this.close()}submit(){this.value=this.value||!1,this.done=!0,this.aborted=!1,this.fire(),this.render(),this.out.write(`
|
|
51
|
-
`),this.close()}_(Y,$){if(Y.toLowerCase()==="y")return this.value=!0,this.submit();if(Y.toLowerCase()==="n")return this.value=!1,this.submit();return this.bell()}render(){if(this.closed)return;if(this.firstRender)this.out.write(
|
|
52
|
-
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}var
|
|
51
|
+
`),this.close()}_(Y,$){if(Y.toLowerCase()==="y")return this.value=!0,this.submit();if(Y.toLowerCase()==="n")return this.value=!1,this.submit();return this.bell()}render(){if(this.closed)return;if(this.firstRender)this.out.write(o4.hide);else this.out.write(rZ(this.outputText,this.out.columns));super.render(),this.outputText=[i4.symbol(this.done,this.aborted),p4.bold(this.msg),i4.delimiter(this.done),this.done?this.value?this.yesMsg:this.noMsg:p4.gray(this.initialValue?this.yesOption:this.noOption)].join(" "),this.out.write(eZ.line+o4.to(0)+this.outputText)}}r4.exports=a4});var $9=Q((IU,Y9)=>{Y9.exports={TextPrompt:C2(),SelectPrompt:T2(),TogglePrompt:w2(),DatePrompt:O4(),NumberPrompt:j4(),MultiselectPrompt:J0(),AutocompletePrompt:d4(),AutocompleteMultiselectPrompt:m4(),ConfirmPrompt:e4()}});var H9=Q((Z9)=>{var A=Z9,YH=$9(),w1=(Y)=>Y;function _(Y,$,Z={}){return new Promise((H,D)=>{let U=new YH[Y]($),J=Z.onAbort||w1,X=Z.onSubmit||w1,z=Z.onExit||w1;U.on("state",$.onState||w1),U.on("submit",(K)=>H(X(K))),U.on("exit",(K)=>H(z(K))),U.on("abort",(K)=>D(J(K)))})}A.text=(Y)=>_("TextPrompt",Y);A.password=(Y)=>{return Y.style="password",A.text(Y)};A.invisible=(Y)=>{return Y.style="invisible",A.text(Y)};A.number=(Y)=>_("NumberPrompt",Y);A.date=(Y)=>_("DatePrompt",Y);A.confirm=(Y)=>_("ConfirmPrompt",Y);A.list=(Y)=>{let $=Y.separator||",";return _("TextPrompt",Y,{onSubmit:(Z)=>Z.split($).map((H)=>H.trim())})};A.toggle=(Y)=>_("TogglePrompt",Y);A.select=(Y)=>_("SelectPrompt",Y);A.multiselect=(Y)=>{Y.choices=[].concat(Y.choices||[]);let $=(Z)=>Z.filter((H)=>H.selected).map((H)=>H.value);return _("MultiselectPrompt",Y,{onAbort:$,onSubmit:$})};A.autocompleteMultiselect=(Y)=>{Y.choices=[].concat(Y.choices||[]);let $=(Z)=>Z.filter((H)=>H.selected).map((H)=>H.value);return _("AutocompleteMultiselectPrompt",Y,{onAbort:$,onSubmit:$})};var $H=(Y,$)=>Promise.resolve($.filter((Z)=>Z.title.slice(0,Y.length).toLowerCase()===Y.toLowerCase()));A.autocomplete=(Y)=>{return Y.suggest=Y.suggest||$H,Y.choices=[].concat(Y.choices||[]),_("AutocompletePrompt",Y)}});var B9=Q((CU,K9)=>{function U9(Y,$){var Z=Object.keys(Y);if(Object.getOwnPropertySymbols){var H=Object.getOwnPropertySymbols(Y);if($)H=H.filter(function(D){return Object.getOwnPropertyDescriptor(Y,D).enumerable});Z.push.apply(Z,H)}return Z}function D9(Y){for(var $=1;$<arguments.length;$++){var Z=arguments[$]!=null?arguments[$]:{};if($%2)U9(Object(Z),!0).forEach(function(H){ZH(Y,H,Z[H])});else if(Object.getOwnPropertyDescriptors)Object.defineProperties(Y,Object.getOwnPropertyDescriptors(Z));else U9(Object(Z)).forEach(function(H){Object.defineProperty(Y,H,Object.getOwnPropertyDescriptor(Z,H))})}return Y}function ZH(Y,$,Z){if($ in Y)Object.defineProperty(Y,$,{value:Z,enumerable:!0,configurable:!0,writable:!0});else Y[$]=Z;return Y}function HH(Y,$){var Z=typeof Symbol!=="undefined"&&Y[Symbol.iterator]||Y["@@iterator"];if(!Z){if(Array.isArray(Y)||(Z=UH(Y))||$&&Y&&typeof Y.length==="number"){if(Z)Y=Z;var H=0,D=function z(){};return{s:D,n:function z(){if(H>=Y.length)return{done:!0};return{done:!1,value:Y[H++]}},e:function z(K){throw K},f:D}}throw new TypeError(`Invalid attempt to iterate non-iterable instance.
|
|
52
|
+
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}var U=!0,J=!1,X;return{s:function z(){Z=Z.call(Y)},n:function z(){var K=Z.next();return U=K.done,K},e:function z(K){J=!0,X=K},f:function z(){try{if(!U&&Z.return!=null)Z.return()}finally{if(J)throw X}}}}function UH(Y,$){if(!Y)return;if(typeof Y==="string")return J9(Y,$);var Z=Object.prototype.toString.call(Y).slice(8,-1);if(Z==="Object"&&Y.constructor)Z=Y.constructor.name;if(Z==="Map"||Z==="Set")return Array.from(Y);if(Z==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(Z))return J9(Y,$)}function J9(Y,$){if($==null||$>Y.length)$=Y.length;for(var Z=0,H=new Array($);Z<$;Z++)H[Z]=Y[Z];return H}function X9(Y,$,Z,H,D,U,J){try{var X=Y[U](J),z=X.value}catch(K){Z(K);return}if(X.done)$(z);else Promise.resolve(z).then(H,D)}function Q9(Y){return function(){var $=this,Z=arguments;return new Promise(function(H,D){var U=Y.apply($,Z);function J(z){X9(U,H,D,J,X,"next",z)}function X(z){X9(U,H,D,J,X,"throw",z)}J(void 0)})}}var K0=H9(),DH=["suggest","format","onState","validate","onRender","type"],z9=()=>{};function o(){return B0.apply(this,arguments)}function B0(){return B0=Q9(function*(Y=[],{onSubmit:$=z9,onCancel:Z=z9}={}){let H={},D=o._override||{};Y=[].concat(Y);let U,J,X,z,K,a,r=function(){var p=Q9(function*(w,q1,p0=!1){if(!p0&&w.validate&&w.validate(q1)!==!0)return;return w.format?yield w.format(q1,H):q1});return function w(q1,p0){return p.apply(this,arguments)}}();var G=HH(Y),q;try{for(G.s();!(q=G.n()).done;){J=q.value;var C1=J;if(z=C1.name,K=C1.type,typeof K==="function")K=yield K(U,D9({},H),J),J.type=K;if(!K)continue;for(let p in J){if(DH.includes(p))continue;let w=J[p];J[p]=typeof w==="function"?yield w(U,D9({},H),a):w}if(a=J,typeof J.message!=="string")throw new Error("prompt message is required");var m0=J;if(z=m0.name,K=m0.type,K0[K]===void 0)throw new Error(`prompt type (${K}) is not defined`);if(D[J.name]!==void 0){if(U=yield r(J,D[J.name]),U!==void 0){H[z]=U;continue}}try{U=o._injected?JH(o._injected,J.initial):yield K0[K](J),H[z]=U=yield r(J,U,!0),X=yield $(J,U,H)}catch(p){X=!(yield Z(J,H))}if(X)return H}}catch(p){G.e(p)}finally{G.f()}return H}),B0.apply(this,arguments)}function JH(Y,$){let Z=Y.shift();if(Z instanceof Error)throw Z;return Z===void 0?$:Z}function XH(Y){o._injected=(o._injected||[]).concat(Y)}function QH(Y){o._override=Object.assign({},Y)}K9.exports=Object.assign(o,{prompt:o,prompts:K0,inject:XH,override:QH})});var W9=Q((qU,R9)=>{R9.exports=(Y,$)=>{if(Y.meta&&Y.name!=="escape")return;if(Y.ctrl){if(Y.name==="a")return"first";if(Y.name==="c")return"abort";if(Y.name==="d")return"abort";if(Y.name==="e")return"last";if(Y.name==="g")return"reset"}if($){if(Y.name==="j")return"down";if(Y.name==="k")return"up"}if(Y.name==="return")return"submit";if(Y.name==="enter")return"submit";if(Y.name==="backspace")return"delete";if(Y.name==="delete")return"deleteForward";if(Y.name==="abort")return"abort";if(Y.name==="escape")return"exit";if(Y.name==="tab")return"next";if(Y.name==="pagedown")return"nextPage";if(Y.name==="pageup")return"prevPage";if(Y.name==="home")return"home";if(Y.name==="end")return"end";if(Y.name==="up")return"up";if(Y.name==="down")return"down";if(Y.name==="right")return"right";if(Y.name==="left")return"left";return!1}});var g1=Q((NU,E9)=>{E9.exports=(Y)=>{let $=["[\\u001B\\u009B][[\\]()#;?]*(?:(?:(?:(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]+)*|[a-zA-Z\\d]+(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]*)*)?\\u0007)","(?:(?:\\d{1,4}(?:;\\d{0,4})*)?[\\dA-PRZcf-ntqry=><~]))"].join("|"),Z=new RegExp($,"g");return typeof Y==="string"?Y.replace(Z,""):Y}});var S9=Q((PU,G9)=>{var zH=g1(),{erase:L9,cursor:KH}=M(),BH=(Y)=>[...zH(Y)].length;G9.exports=function(Y,$){if(!$)return L9.line+KH.to(0);let Z=0,H=Y.split(/\r?\n/);for(let D of H)Z+=1+Math.floor(Math.max(BH(D)-1,0)/$);return L9.lines(Z)}});var R0=Q((jU,M9)=>{var G1={arrowUp:"\u2191",arrowDown:"\u2193",arrowLeft:"\u2190",arrowRight:"\u2192",radioOn:"\u25C9",radioOff:"\u25EF",tick:"\u2714",cross:"\u2716",ellipsis:"\u2026",pointerSmall:"\u203A",line:"\u2500",pointer:"\u276F"},RH={arrowUp:G1.arrowUp,arrowDown:G1.arrowDown,arrowLeft:G1.arrowLeft,arrowRight:G1.arrowRight,radioOn:"(*)",radioOff:"( )",tick:"\u221A",cross:"\xD7",ellipsis:"...",pointerSmall:"\xBB",line:"\u2500",pointer:">"},WH=process.platform==="win32"?RH:G1;M9.exports=WH});var O9=Q((TU,F9)=>{var U1=S(),Y1=R0(),W0=Object.freeze({password:{scale:1,render:(Y)=>"*".repeat(Y.length)},emoji:{scale:2,render:(Y)=>"\uD83D\uDE03".repeat(Y.length)},invisible:{scale:0,render:(Y)=>""},default:{scale:1,render:(Y)=>`${Y}`}}),EH=(Y)=>W0[Y]||W0.default,S1=Object.freeze({aborted:U1.red(Y1.cross),done:U1.green(Y1.tick),exited:U1.yellow(Y1.cross),default:U1.cyan("?")}),LH=(Y,$,Z)=>$?S1.aborted:Z?S1.exited:Y?S1.done:S1.default,GH=(Y)=>U1.gray(Y?Y1.ellipsis:Y1.pointerSmall),SH=(Y,$)=>U1.gray(Y?$?Y1.pointerSmall:"+":Y1.line);F9.exports={styles:W0,render:EH,symbols:S1,symbol:LH,delimiter:GH,item:SH}});var I9=Q((kU,V9)=>{var MH=g1();V9.exports=function(Y,$){let Z=String(MH(Y)||"").split(/\r?\n/);if(!$)return Z.length;return Z.map((H)=>Math.ceil(H.length/$)).reduce((H,D)=>H+D)}});var C9=Q((_U,A9)=>{A9.exports=(Y,$={})=>{let Z=Number.isSafeInteger(parseInt($.margin))?new Array(parseInt($.margin)).fill(" ").join(""):$.margin||"",H=$.width;return(Y||"").split(/\r?\n/g).map((D)=>D.split(/\s+/g).reduce((U,J)=>{if(J.length+Z.length>=H||U[U.length-1].length+J.length+1<H)U[U.length-1]+=` ${J}`;else U.push(`${Z}${J}`);return U},[Z]).join(`
|
|
53
53
|
`)).join(`
|
|
54
|
-
`)}});var
|
|
54
|
+
`)}});var N9=Q((bU,q9)=>{q9.exports=(Y,$,Z)=>{Z=Z||$;let H=Math.min($-Z,Y-Math.floor(Z/2));if(H<0)H=0;let D=Math.min(H+Z,$);return{startIndex:H,endIndex:D}}});var P=Q((xU,P9)=>{P9.exports={action:W9(),clear:S9(),style:O9(),strip:g1(),figures:R0(),lines:I9(),wrap:C9(),entriesToDisplay:N9()}});var u=Q((hU,k9)=>{var j9=N1("readline"),{action:FH}=P(),OH=N1("events"),{beep:VH,cursor:IH}=M(),AH=S();class T9 extends OH{constructor(Y={}){super();this.firstRender=!0,this.in=Y.stdin||process.stdin,this.out=Y.stdout||process.stdout,this.onRender=(Y.onRender||(()=>{return})).bind(this);let $=j9.createInterface({input:this.in,escapeCodeTimeout:50});if(j9.emitKeypressEvents(this.in,$),this.in.isTTY)this.in.setRawMode(!0);let Z=["SelectPrompt","MultiselectPrompt"].indexOf(this.constructor.name)>-1,H=(D,U)=>{let J=FH(U,Z);if(J===!1)this._&&this._(D,U);else if(typeof this[J]==="function")this[J](U);else this.bell()};this.close=()=>{if(this.out.write(IH.show),this.in.removeListener("keypress",H),this.in.isTTY)this.in.setRawMode(!1);$.close(),this.emit(this.aborted?"abort":this.exited?"exit":"submit",this.value),this.closed=!0},this.in.on("keypress",H)}fire(){this.emit("state",{value:this.value,aborted:!!this.aborted,exited:!!this.exited})}bell(){this.out.write(VH)}render(){if(this.onRender(AH),this.firstRender)this.firstRender=!1}}k9.exports=T9});var x9=Q((fU,b9)=>{var v1=S(),CH=u(),{erase:qH,cursor:M1}=M(),{style:E0,clear:L0,lines:NH,figures:PH}=P();class _9 extends CH{constructor(Y={}){super(Y);this.transform=E0.render(Y.style),this.scale=this.transform.scale,this.msg=Y.message,this.initial=Y.initial||"",this.validator=Y.validate||(()=>!0),this.value="",this.errorMsg=Y.error||"Please Enter A Valid Value",this.cursor=Number(!!this.initial),this.cursorOffset=0,this.clear=L0("",this.out.columns),this.render()}set value(Y){if(!Y&&this.initial)this.placeholder=!0,this.rendered=v1.gray(this.transform.render(this.initial));else this.placeholder=!1,this.rendered=this.transform.render(Y);this._value=Y,this.fire()}get value(){return this._value}reset(){this.value="",this.cursor=Number(!!this.initial),this.cursorOffset=0,this.fire(),this.render()}exit(){this.abort()}abort(){this.value=this.value||this.initial,this.done=this.aborted=!0,this.error=!1,this.red=!1,this.fire(),this.render(),this.out.write(`
|
|
55
55
|
`),this.close()}async validate(){let Y=await this.validator(this.value);if(typeof Y==="string")this.errorMsg=Y,Y=!1;this.error=!Y}async submit(){if(this.value=this.value||this.initial,this.cursorOffset=0,this.cursor=this.rendered.length,await this.validate(),this.error){this.red=!0,this.fire(),this.render();return}this.done=!0,this.aborted=!1,this.fire(),this.render(),this.out.write(`
|
|
56
|
-
`),this.close()}next(){if(!this.placeholder)return this.bell();this.value=this.initial,this.cursor=this.rendered.length,this.fire(),this.render()}moveCursor(Y){if(this.placeholder)return;this.cursor=this.cursor+Y,this.cursorOffset+=Y}_(Y,$){let Z=this.value.slice(0,this.cursor),H=this.value.slice(this.cursor);this.value=`${Z}${Y}${H}`,this.red=!1,this.cursor=this.placeholder?0:Z.length+1,this.render()}delete(){if(this.isCursorAtStart())return this.bell();let Y=this.value.slice(0,this.cursor-1),$=this.value.slice(this.cursor);if(this.value=`${Y}${$}`,this.red=!1,this.isCursorAtStart())this.cursorOffset=0;else this.cursorOffset++,this.moveCursor(-1);this.render()}deleteForward(){if(this.cursor*this.scale>=this.rendered.length||this.placeholder)return this.bell();let Y=this.value.slice(0,this.cursor),$=this.value.slice(this.cursor+1);if(this.value=`${Y}${$}`,this.red=!1,this.isCursorAtEnd())this.cursorOffset=0;else this.cursorOffset++;this.render()}first(){this.cursor=0,this.render()}last(){this.cursor=this.value.length,this.render()}left(){if(this.cursor<=0||this.placeholder)return this.bell();this.moveCursor(-1),this.render()}right(){if(this.cursor*this.scale>=this.rendered.length||this.placeholder)return this.bell();this.moveCursor(1),this.render()}isCursorAtStart(){return this.cursor===0||this.placeholder&&this.cursor===1}isCursorAtEnd(){return this.cursor===this.rendered.length||this.placeholder&&this.cursor===this.rendered.length+1}render(){if(this.closed)return;if(!this.firstRender){if(this.outputError)this.out.write(
|
|
56
|
+
`),this.close()}next(){if(!this.placeholder)return this.bell();this.value=this.initial,this.cursor=this.rendered.length,this.fire(),this.render()}moveCursor(Y){if(this.placeholder)return;this.cursor=this.cursor+Y,this.cursorOffset+=Y}_(Y,$){let Z=this.value.slice(0,this.cursor),H=this.value.slice(this.cursor);this.value=`${Z}${Y}${H}`,this.red=!1,this.cursor=this.placeholder?0:Z.length+1,this.render()}delete(){if(this.isCursorAtStart())return this.bell();let Y=this.value.slice(0,this.cursor-1),$=this.value.slice(this.cursor);if(this.value=`${Y}${$}`,this.red=!1,this.isCursorAtStart())this.cursorOffset=0;else this.cursorOffset++,this.moveCursor(-1);this.render()}deleteForward(){if(this.cursor*this.scale>=this.rendered.length||this.placeholder)return this.bell();let Y=this.value.slice(0,this.cursor),$=this.value.slice(this.cursor+1);if(this.value=`${Y}${$}`,this.red=!1,this.isCursorAtEnd())this.cursorOffset=0;else this.cursorOffset++;this.render()}first(){this.cursor=0,this.render()}last(){this.cursor=this.value.length,this.render()}left(){if(this.cursor<=0||this.placeholder)return this.bell();this.moveCursor(-1),this.render()}right(){if(this.cursor*this.scale>=this.rendered.length||this.placeholder)return this.bell();this.moveCursor(1),this.render()}isCursorAtStart(){return this.cursor===0||this.placeholder&&this.cursor===1}isCursorAtEnd(){return this.cursor===this.rendered.length||this.placeholder&&this.cursor===this.rendered.length+1}render(){if(this.closed)return;if(!this.firstRender){if(this.outputError)this.out.write(M1.down(NH(this.outputError,this.out.columns)-1)+L0(this.outputError,this.out.columns));this.out.write(L0(this.outputText,this.out.columns))}if(super.render(),this.outputError="",this.outputText=[E0.symbol(this.done,this.aborted),v1.bold(this.msg),E0.delimiter(this.done),this.red?v1.red(this.rendered):this.rendered].join(" "),this.error)this.outputError+=this.errorMsg.split(`
|
|
57
57
|
`).reduce((Y,$,Z)=>Y+`
|
|
58
|
-
${Z?" ":
|
|
58
|
+
${Z?" ":PH.pointerSmall} ${v1.red().italic($)}`,"");this.out.write(qH.line+M1.to(0)+this.outputText+M1.save+this.outputError+M1.restore+M1.move(this.cursorOffset,0))}}b9.exports=_9});var v9=Q((wU,g9)=>{var c=S(),jH=u(),{style:h9,clear:f9,figures:y1,wrap:TH,entriesToDisplay:kH}=P(),{cursor:_H}=M();class w9 extends jH{constructor(Y={}){super(Y);this.msg=Y.message,this.hint=Y.hint||"- Use arrow-keys. Return to submit.",this.warn=Y.warn||"- This option is disabled",this.cursor=Y.initial||0,this.choices=Y.choices.map(($,Z)=>{if(typeof $==="string")$={title:$,value:Z};return{title:$&&($.title||$.value||$),value:$&&($.value===void 0?Z:$.value),description:$&&$.description,selected:$&&$.selected,disabled:$&&$.disabled}}),this.optionsPerPage=Y.optionsPerPage||10,this.value=(this.choices[this.cursor]||{}).value,this.clear=f9("",this.out.columns),this.render()}moveCursor(Y){this.cursor=Y,this.value=this.choices[Y].value,this.fire()}reset(){this.moveCursor(0),this.fire(),this.render()}exit(){this.abort()}abort(){this.done=this.aborted=!0,this.fire(),this.render(),this.out.write(`
|
|
59
59
|
`),this.close()}submit(){if(!this.selection.disabled)this.done=!0,this.aborted=!1,this.fire(),this.render(),this.out.write(`
|
|
60
|
-
`),this.close();else this.bell()}first(){this.moveCursor(0),this.render()}last(){this.moveCursor(this.choices.length-1),this.render()}up(){if(this.cursor===0)this.moveCursor(this.choices.length-1);else this.moveCursor(this.cursor-1);this.render()}down(){if(this.cursor===this.choices.length-1)this.moveCursor(0);else this.moveCursor(this.cursor+1);this.render()}next(){this.moveCursor((this.cursor+1)%this.choices.length),this.render()}_(Y,$){if(Y===" ")return this.submit()}get selection(){return this.choices[this.cursor]}render(){if(this.closed)return;if(this.firstRender)this.out.write(
|
|
61
|
-
`;for(let Z=Y;Z<$;Z++){let H,U
|
|
62
|
-
`+
|
|
63
|
-
`}}this.out.write(this.outputText)}}
|
|
60
|
+
`),this.close();else this.bell()}first(){this.moveCursor(0),this.render()}last(){this.moveCursor(this.choices.length-1),this.render()}up(){if(this.cursor===0)this.moveCursor(this.choices.length-1);else this.moveCursor(this.cursor-1);this.render()}down(){if(this.cursor===this.choices.length-1)this.moveCursor(0);else this.moveCursor(this.cursor+1);this.render()}next(){this.moveCursor((this.cursor+1)%this.choices.length),this.render()}_(Y,$){if(Y===" ")return this.submit()}get selection(){return this.choices[this.cursor]}render(){if(this.closed)return;if(this.firstRender)this.out.write(_H.hide);else this.out.write(f9(this.outputText,this.out.columns));super.render();let{startIndex:Y,endIndex:$}=kH(this.cursor,this.choices.length,this.optionsPerPage);if(this.outputText=[h9.symbol(this.done,this.aborted),c.bold(this.msg),h9.delimiter(!1),this.done?this.selection.title:this.selection.disabled?c.yellow(this.warn):c.gray(this.hint)].join(" "),!this.done){this.outputText+=`
|
|
61
|
+
`;for(let Z=Y;Z<$;Z++){let H,D,U="",J=this.choices[Z];if(Z===Y&&Y>0)D=y1.arrowUp;else if(Z===$-1&&$<this.choices.length)D=y1.arrowDown;else D=" ";if(J.disabled)H=this.cursor===Z?c.gray().underline(J.title):c.strikethrough().gray(J.title),D=(this.cursor===Z?c.bold().gray(y1.pointer)+" ":" ")+D;else if(H=this.cursor===Z?c.cyan().underline(J.title):J.title,D=(this.cursor===Z?c.cyan(y1.pointer)+" ":" ")+D,J.description&&this.cursor===Z){if(U=` - ${J.description}`,D.length+H.length+U.length>=this.out.columns||J.description.split(/\r?\n/).length>1)U=`
|
|
62
|
+
`+TH(J.description,{margin:3,width:this.out.columns})}this.outputText+=`${D} ${H}${c.gray(U)}
|
|
63
|
+
`}}this.out.write(this.outputText)}}g9.exports=w9});var l9=Q((gU,c9)=>{var d1=S(),bH=u(),{style:y9,clear:xH}=P(),{cursor:d9,erase:hH}=M();class u9 extends bH{constructor(Y={}){super(Y);this.msg=Y.message,this.value=!!Y.initial,this.active=Y.active||"on",this.inactive=Y.inactive||"off",this.initialValue=this.value,this.render()}reset(){this.value=this.initialValue,this.fire(),this.render()}exit(){this.abort()}abort(){this.done=this.aborted=!0,this.fire(),this.render(),this.out.write(`
|
|
64
64
|
`),this.close()}submit(){this.done=!0,this.aborted=!1,this.fire(),this.render(),this.out.write(`
|
|
65
|
-
`),this.close()}deactivate(){if(this.value===!1)return this.bell();this.value=!1,this.render()}activate(){if(this.value===!0)return this.bell();this.value=!0,this.render()}delete(){this.deactivate()}left(){this.deactivate()}right(){this.activate()}down(){this.deactivate()}up(){this.activate()}next(){this.value=!this.value,this.fire(),this.render()}_(Y,$){if(Y===" ")this.value=!this.value;else if(Y==="1")this.value=!0;else if(Y==="0")this.value=!1;else return this.bell();this.render()}render(){if(this.closed)return;if(this.firstRender)this.out.write(
|
|
65
|
+
`),this.close()}deactivate(){if(this.value===!1)return this.bell();this.value=!1,this.render()}activate(){if(this.value===!0)return this.bell();this.value=!0,this.render()}delete(){this.deactivate()}left(){this.deactivate()}right(){this.activate()}down(){this.deactivate()}up(){this.activate()}next(){this.value=!this.value,this.fire(),this.render()}_(Y,$){if(Y===" ")this.value=!this.value;else if(Y==="1")this.value=!0;else if(Y==="0")this.value=!1;else return this.bell();this.render()}render(){if(this.closed)return;if(this.firstRender)this.out.write(d9.hide);else this.out.write(xH(this.outputText,this.out.columns));super.render(),this.outputText=[y9.symbol(this.done,this.aborted),d1.bold(this.msg),y9.delimiter(this.done),this.value?this.inactive:d1.cyan().underline(this.inactive),d1.gray("/"),this.value?d1.cyan().underline(this.active):this.active].join(" "),this.out.write(hH.line+d9.to(0)+this.outputText)}}c9.exports=u9});var b=Q((vU,n9)=>{class u1{constructor({token:Y,date:$,parts:Z,locales:H}){this.token=Y,this.date=$||new Date,this.parts=Z||[this],this.locales=H||{}}up(){}down(){}next(){let Y=this.parts.indexOf(this);return this.parts.find(($,Z)=>Z>Y&&$ instanceof u1)}setTo(Y){}prev(){let Y=[].concat(this.parts).reverse(),$=Y.indexOf(this);return Y.find((Z,H)=>H>$&&Z instanceof u1)}toString(){return String(this.date)}}n9.exports=u1});var i9=Q((yU,p9)=>{var fH=b();class m9 extends fH{constructor(Y={}){super(Y)}up(){this.date.setHours((this.date.getHours()+12)%24)}down(){this.up()}toString(){let Y=this.date.getHours()>12?"pm":"am";return/\A/.test(this.token)?Y.toUpperCase():Y}}p9.exports=m9});var s9=Q((dU,t9)=>{var wH=b(),gH=(Y)=>{return Y=Y%10,Y===1?"st":Y===2?"nd":Y===3?"rd":"th"};class o9 extends wH{constructor(Y={}){super(Y)}up(){this.date.setDate(this.date.getDate()+1)}down(){this.date.setDate(this.date.getDate()-1)}setTo(Y){this.date.setDate(parseInt(Y.substr(-2)))}toString(){let Y=this.date.getDate(),$=this.date.getDay();return this.token==="DD"?String(Y).padStart(2,"0"):this.token==="Do"?Y+gH(Y):this.token==="d"?$+1:this.token==="ddd"?this.locales.weekdaysShort[$]:this.token==="dddd"?this.locales.weekdays[$]:Y}}t9.exports=o9});var e9=Q((uU,r9)=>{var vH=b();class a9 extends vH{constructor(Y={}){super(Y)}up(){this.date.setHours(this.date.getHours()+1)}down(){this.date.setHours(this.date.getHours()-1)}setTo(Y){this.date.setHours(parseInt(Y.substr(-2)))}toString(){let Y=this.date.getHours();if(/h/.test(this.token))Y=Y%12||12;return this.token.length>1?String(Y).padStart(2,"0"):Y}}r9.exports=a9});var ZY=Q((cU,$Y)=>{var yH=b();class YY extends yH{constructor(Y={}){super(Y)}up(){this.date.setMilliseconds(this.date.getMilliseconds()+1)}down(){this.date.setMilliseconds(this.date.getMilliseconds()-1)}setTo(Y){this.date.setMilliseconds(parseInt(Y.substr(-this.token.length)))}toString(){return String(this.date.getMilliseconds()).padStart(4,"0").substr(0,this.token.length)}}$Y.exports=YY});var DY=Q((lU,UY)=>{var dH=b();class HY extends dH{constructor(Y={}){super(Y)}up(){this.date.setMinutes(this.date.getMinutes()+1)}down(){this.date.setMinutes(this.date.getMinutes()-1)}setTo(Y){this.date.setMinutes(parseInt(Y.substr(-2)))}toString(){let Y=this.date.getMinutes();return this.token.length>1?String(Y).padStart(2,"0"):Y}}UY.exports=HY});var QY=Q((nU,XY)=>{var uH=b();class JY extends uH{constructor(Y={}){super(Y)}up(){this.date.setMonth(this.date.getMonth()+1)}down(){this.date.setMonth(this.date.getMonth()-1)}setTo(Y){Y=parseInt(Y.substr(-2))-1,this.date.setMonth(Y<0?0:Y)}toString(){let Y=this.date.getMonth(),$=this.token.length;return $===2?String(Y+1).padStart(2,"0"):$===3?this.locales.monthsShort[Y]:$===4?this.locales.months[Y]:String(Y+1)}}XY.exports=JY});var BY=Q((mU,KY)=>{var cH=b();class zY extends cH{constructor(Y={}){super(Y)}up(){this.date.setSeconds(this.date.getSeconds()+1)}down(){this.date.setSeconds(this.date.getSeconds()-1)}setTo(Y){this.date.setSeconds(parseInt(Y.substr(-2)))}toString(){let Y=this.date.getSeconds();return this.token.length>1?String(Y).padStart(2,"0"):Y}}KY.exports=zY});var EY=Q((pU,WY)=>{var lH=b();class RY extends lH{constructor(Y={}){super(Y)}up(){this.date.setFullYear(this.date.getFullYear()+1)}down(){this.date.setFullYear(this.date.getFullYear()-1)}setTo(Y){this.date.setFullYear(Y.substr(-4))}toString(){let Y=String(this.date.getFullYear()).padStart(4,"0");return this.token.length===2?Y.substr(-2):Y}}WY.exports=RY});var GY=Q((iU,LY)=>{LY.exports={DatePart:b(),Meridiem:i9(),Day:s9(),Hours:e9(),Milliseconds:ZY(),Minutes:DY(),Month:QY(),Seconds:BY(),Year:EY()}});var CY=Q((oU,AY)=>{var G0=S(),nH=u(),{style:SY,clear:MY,figures:mH}=P(),{erase:pH,cursor:FY}=M(),{DatePart:OY,Meridiem:iH,Day:oH,Hours:tH,Milliseconds:sH,Minutes:aH,Month:rH,Seconds:eH,Year:Y7}=GY(),$7=/\\(.)|"((?:\\["\\]|[^"])+)"|(D[Do]?|d{3,4}|d)|(M{1,4})|(YY(?:YY)?)|([aA])|([Hh]{1,2})|(m{1,2})|(s{1,2})|(S{1,4})|./g,VY={1:({token:Y})=>Y.replace(/\\(.)/g,"$1"),2:(Y)=>new oH(Y),3:(Y)=>new rH(Y),4:(Y)=>new Y7(Y),5:(Y)=>new iH(Y),6:(Y)=>new tH(Y),7:(Y)=>new aH(Y),8:(Y)=>new eH(Y),9:(Y)=>new sH(Y)},Z7={months:"January,February,March,April,May,June,July,August,September,October,November,December".split(","),monthsShort:"Jan,Feb,Mar,Apr,May,Jun,Jul,Aug,Sep,Oct,Nov,Dec".split(","),weekdays:"Sunday,Monday,Tuesday,Wednesday,Thursday,Friday,Saturday".split(","),weekdaysShort:"Sun,Mon,Tue,Wed,Thu,Fri,Sat".split(",")};class IY extends nH{constructor(Y={}){super(Y);this.msg=Y.message,this.cursor=0,this.typed="",this.locales=Object.assign(Z7,Y.locales),this._date=Y.initial||new Date,this.errorMsg=Y.error||"Please Enter A Valid Value",this.validator=Y.validate||(()=>!0),this.mask=Y.mask||"YYYY-MM-DD HH:mm:ss",this.clear=MY("",this.out.columns),this.render()}get value(){return this.date}get date(){return this._date}set date(Y){if(Y)this._date.setTime(Y.getTime())}set mask(Y){let $;this.parts=[];while($=$7.exec(Y)){let H=$.shift(),D=$.findIndex((U)=>U!=null);this.parts.push(D in VY?VY[D]({token:$[D]||H,date:this.date,parts:this.parts,locales:this.locales}):$[D]||H)}let Z=this.parts.reduce((H,D)=>{if(typeof D==="string"&&typeof H[H.length-1]==="string")H[H.length-1]+=D;else H.push(D);return H},[]);this.parts.splice(0),this.parts.push(...Z),this.reset()}moveCursor(Y){this.typed="",this.cursor=Y,this.fire()}reset(){this.moveCursor(this.parts.findIndex((Y)=>Y instanceof OY)),this.fire(),this.render()}exit(){this.abort()}abort(){this.done=this.aborted=!0,this.error=!1,this.fire(),this.render(),this.out.write(`
|
|
66
66
|
`),this.close()}async validate(){let Y=await this.validator(this.value);if(typeof Y==="string")this.errorMsg=Y,Y=!1;this.error=!Y}async submit(){if(await this.validate(),this.error){this.color="red",this.fire(),this.render();return}this.done=!0,this.aborted=!1,this.fire(),this.render(),this.out.write(`
|
|
67
|
-
`),this.close()}up(){this.typed="",this.parts[this.cursor].up(),this.render()}down(){this.typed="",this.parts[this.cursor].down(),this.render()}left(){let Y=this.parts[this.cursor].prev();if(Y==null)return this.bell();this.moveCursor(this.parts.indexOf(Y)),this.render()}right(){let Y=this.parts[this.cursor].next();if(Y==null)return this.bell();this.moveCursor(this.parts.indexOf(Y)),this.render()}next(){let Y=this.parts[this.cursor].next();this.moveCursor(Y?this.parts.indexOf(Y):this.parts.findIndex(($)=>$ instanceof
|
|
67
|
+
`),this.close()}up(){this.typed="",this.parts[this.cursor].up(),this.render()}down(){this.typed="",this.parts[this.cursor].down(),this.render()}left(){let Y=this.parts[this.cursor].prev();if(Y==null)return this.bell();this.moveCursor(this.parts.indexOf(Y)),this.render()}right(){let Y=this.parts[this.cursor].next();if(Y==null)return this.bell();this.moveCursor(this.parts.indexOf(Y)),this.render()}next(){let Y=this.parts[this.cursor].next();this.moveCursor(Y?this.parts.indexOf(Y):this.parts.findIndex(($)=>$ instanceof OY)),this.render()}_(Y){if(/\d/.test(Y))this.typed+=Y,this.parts[this.cursor].setTo(this.typed),this.render()}render(){if(this.closed)return;if(this.firstRender)this.out.write(FY.hide);else this.out.write(MY(this.outputText,this.out.columns));if(super.render(),this.outputText=[SY.symbol(this.done,this.aborted),G0.bold(this.msg),SY.delimiter(!1),this.parts.reduce((Y,$,Z)=>Y.concat(Z===this.cursor&&!this.done?G0.cyan().underline($.toString()):$),[]).join("")].join(" "),this.error)this.outputText+=this.errorMsg.split(`
|
|
68
68
|
`).reduce((Y,$,Z)=>Y+`
|
|
69
|
-
${Z?" ":
|
|
69
|
+
${Z?" ":mH.pointerSmall} ${G0.red().italic($)}`,"");this.out.write(pH.line+FY.to(0)+this.outputText)}}AY.exports=IY});var TY=Q((tU,jY)=>{var c1=S(),H7=u(),{cursor:l1,erase:U7}=M(),{style:S0,figures:D7,clear:qY,lines:J7}=P(),X7=/[0-9]/,M0=(Y)=>Y!==void 0,NY=(Y,$)=>{let Z=Math.pow(10,$);return Math.round(Y*Z)/Z};class PY extends H7{constructor(Y={}){super(Y);this.transform=S0.render(Y.style),this.msg=Y.message,this.initial=M0(Y.initial)?Y.initial:"",this.float=!!Y.float,this.round=Y.round||2,this.inc=Y.increment||1,this.min=M0(Y.min)?Y.min:-1/0,this.max=M0(Y.max)?Y.max:1/0,this.errorMsg=Y.error||"Please Enter A Valid Value",this.validator=Y.validate||(()=>!0),this.color="cyan",this.value="",this.typed="",this.lastHit=0,this.render()}set value(Y){if(!Y&&Y!==0)this.placeholder=!0,this.rendered=c1.gray(this.transform.render(`${this.initial}`)),this._value="";else this.placeholder=!1,this.rendered=this.transform.render(`${NY(Y,this.round)}`),this._value=NY(Y,this.round);this.fire()}get value(){return this._value}parse(Y){return this.float?parseFloat(Y):parseInt(Y)}valid(Y){return Y==="-"||Y==="."&&this.float||X7.test(Y)}reset(){this.typed="",this.value="",this.fire(),this.render()}exit(){this.abort()}abort(){let Y=this.value;this.value=Y!==""?Y:this.initial,this.done=this.aborted=!0,this.error=!1,this.fire(),this.render(),this.out.write(`
|
|
70
70
|
`),this.close()}async validate(){let Y=await this.validator(this.value);if(typeof Y==="string")this.errorMsg=Y,Y=!1;this.error=!Y}async submit(){if(await this.validate(),this.error){this.color="red",this.fire(),this.render();return}let Y=this.value;this.value=Y!==""?Y:this.initial,this.done=!0,this.aborted=!1,this.error=!1,this.fire(),this.render(),this.out.write(`
|
|
71
|
-
`),this.close()}up(){if(this.typed="",this.value==="")this.value=this.min-this.inc;if(this.value>=this.max)return this.bell();this.value+=this.inc,this.color="cyan",this.fire(),this.render()}down(){if(this.typed="",this.value==="")this.value=this.min+this.inc;if(this.value<=this.min)return this.bell();this.value-=this.inc,this.color="cyan",this.fire(),this.render()}delete(){let Y=this.value.toString();if(Y.length===0)return this.bell();if(this.value=this.parse(Y=Y.slice(0,-1))||"",this.value!==""&&this.value<this.min)this.value=this.min;this.color="cyan",this.fire(),this.render()}next(){this.value=this.initial,this.fire(),this.render()}_(Y,$){if(!this.valid(Y))return this.bell();let Z=Date.now();if(Z-this.lastHit>1000)this.typed="";if(this.typed+=Y,this.lastHit=Z,this.color="cyan",Y===".")return this.fire();if(this.value=Math.min(this.parse(this.typed),this.max),this.value>this.max)this.value=this.max;if(this.value<this.min)this.value=this.min;this.fire(),this.render()}render(){if(this.closed)return;if(!this.firstRender){if(this.outputError)this.out.write(l1.down(
|
|
71
|
+
`),this.close()}up(){if(this.typed="",this.value==="")this.value=this.min-this.inc;if(this.value>=this.max)return this.bell();this.value+=this.inc,this.color="cyan",this.fire(),this.render()}down(){if(this.typed="",this.value==="")this.value=this.min+this.inc;if(this.value<=this.min)return this.bell();this.value-=this.inc,this.color="cyan",this.fire(),this.render()}delete(){let Y=this.value.toString();if(Y.length===0)return this.bell();if(this.value=this.parse(Y=Y.slice(0,-1))||"",this.value!==""&&this.value<this.min)this.value=this.min;this.color="cyan",this.fire(),this.render()}next(){this.value=this.initial,this.fire(),this.render()}_(Y,$){if(!this.valid(Y))return this.bell();let Z=Date.now();if(Z-this.lastHit>1000)this.typed="";if(this.typed+=Y,this.lastHit=Z,this.color="cyan",Y===".")return this.fire();if(this.value=Math.min(this.parse(this.typed),this.max),this.value>this.max)this.value=this.max;if(this.value<this.min)this.value=this.min;this.fire(),this.render()}render(){if(this.closed)return;if(!this.firstRender){if(this.outputError)this.out.write(l1.down(J7(this.outputError,this.out.columns)-1)+qY(this.outputError,this.out.columns));this.out.write(qY(this.outputText,this.out.columns))}if(super.render(),this.outputError="",this.outputText=[S0.symbol(this.done,this.aborted),c1.bold(this.msg),S0.delimiter(this.done),!this.done||!this.done&&!this.placeholder?c1[this.color]().underline(this.rendered):this.rendered].join(" "),this.error)this.outputError+=this.errorMsg.split(`
|
|
72
72
|
`).reduce((Y,$,Z)=>Y+`
|
|
73
|
-
${Z?" ":
|
|
73
|
+
${Z?" ":D7.pointerSmall} ${c1.red().italic($)}`,"");this.out.write(U7.line+l1.to(0)+this.outputText+l1.save+this.outputError+l1.restore)}}jY.exports=PY});var F0=Q((sU,xY)=>{var x=S(),{cursor:Q7}=M(),z7=u(),{clear:kY,figures:t,style:_Y,wrap:K7,entriesToDisplay:B7}=P();class bY extends z7{constructor(Y={}){super(Y);if(this.msg=Y.message,this.cursor=Y.cursor||0,this.scrollIndex=Y.cursor||0,this.hint=Y.hint||"",this.warn=Y.warn||"- This option is disabled -",this.minSelected=Y.min,this.showMinError=!1,this.maxChoices=Y.max,this.instructions=Y.instructions,this.optionsPerPage=Y.optionsPerPage||10,this.value=Y.choices.map(($,Z)=>{if(typeof $==="string")$={title:$,value:Z};return{title:$&&($.title||$.value||$),description:$&&$.description,value:$&&($.value===void 0?Z:$.value),selected:$&&$.selected,disabled:$&&$.disabled}}),this.clear=kY("",this.out.columns),!Y.overrideRender)this.render()}reset(){this.value.map((Y)=>!Y.selected),this.cursor=0,this.fire(),this.render()}selected(){return this.value.filter((Y)=>Y.selected)}exit(){this.abort()}abort(){this.done=this.aborted=!0,this.fire(),this.render(),this.out.write(`
|
|
74
74
|
`),this.close()}submit(){let Y=this.value.filter(($)=>$.selected);if(this.minSelected&&Y.length<this.minSelected)this.showMinError=!0,this.render();else this.done=!0,this.aborted=!1,this.fire(),this.render(),this.out.write(`
|
|
75
75
|
`),this.close()}first(){this.cursor=0,this.render()}last(){this.cursor=this.value.length-1,this.render()}next(){this.cursor=(this.cursor+1)%this.value.length,this.render()}up(){if(this.cursor===0)this.cursor=this.value.length-1;else this.cursor--;this.render()}down(){if(this.cursor===this.value.length-1)this.cursor=0;else this.cursor++;this.render()}left(){this.value[this.cursor].selected=!1,this.render()}right(){if(this.value.filter((Y)=>Y.selected).length>=this.maxChoices)return this.bell();this.value[this.cursor].selected=!0,this.render()}handleSpaceToggle(){let Y=this.value[this.cursor];if(Y.selected)Y.selected=!1,this.render();else if(Y.disabled||this.value.filter(($)=>$.selected).length>=this.maxChoices)return this.bell();else Y.selected=!0,this.render()}toggleAll(){if(this.maxChoices!==void 0||this.value[this.cursor].disabled)return this.bell();let Y=!this.value[this.cursor].selected;this.value.filter(($)=>!$.disabled).forEach(($)=>$.selected=Y),this.render()}_(Y,$){if(Y===" ")this.handleSpaceToggle();else if(Y==="a")this.toggleAll();else return this.bell()}renderInstructions(){if(this.instructions===void 0||this.instructions){if(typeof this.instructions==="string")return this.instructions;return`
|
|
76
76
|
Instructions:
|
|
77
|
-
${
|
|
78
|
-
${
|
|
77
|
+
${t.arrowUp}/${t.arrowDown}: Highlight option
|
|
78
|
+
${t.arrowLeft}/${t.arrowRight}/[space]: Toggle selection
|
|
79
79
|
`+(this.maxChoices===void 0?` a: Toggle all
|
|
80
|
-
`:"")+" enter/return: Complete answer"}return""}renderOption(Y,$,Z,H){let
|
|
81
|
-
`+
|
|
82
|
-
`+
|
|
83
|
-
`)}renderOptions(Y){if(!this.done)return this.paginateOptions(Y);return""}renderDoneOrInstructions(){if(this.done)return this.value.filter(($)=>$.selected).map(($)=>$.title).join(", ");let Y=[
|
|
80
|
+
`:"")+" enter/return: Complete answer"}return""}renderOption(Y,$,Z,H){let D=($.selected?x.green(t.radioOn):t.radioOff)+" "+H+" ",U,J;if($.disabled)U=Y===Z?x.gray().underline($.title):x.strikethrough().gray($.title);else if(U=Y===Z?x.cyan().underline($.title):$.title,Y===Z&&$.description){if(J=` - ${$.description}`,D.length+U.length+J.length>=this.out.columns||$.description.split(/\r?\n/).length>1)J=`
|
|
81
|
+
`+K7($.description,{margin:D.length,width:this.out.columns})}return D+U+x.gray(J||"")}paginateOptions(Y){if(Y.length===0)return x.red("No matches for this query.");let{startIndex:$,endIndex:Z}=B7(this.cursor,Y.length,this.optionsPerPage),H,D=[];for(let U=$;U<Z;U++){if(U===$&&$>0)H=t.arrowUp;else if(U===Z-1&&Z<Y.length)H=t.arrowDown;else H=" ";D.push(this.renderOption(this.cursor,Y[U],U,H))}return`
|
|
82
|
+
`+D.join(`
|
|
83
|
+
`)}renderOptions(Y){if(!this.done)return this.paginateOptions(Y);return""}renderDoneOrInstructions(){if(this.done)return this.value.filter(($)=>$.selected).map(($)=>$.title).join(", ");let Y=[x.gray(this.hint),this.renderInstructions()];if(this.value[this.cursor].disabled)Y.push(x.yellow(this.warn));return Y.join(" ")}render(){if(this.closed)return;if(this.firstRender)this.out.write(Q7.hide);super.render();let Y=[_Y.symbol(this.done,this.aborted),x.bold(this.msg),_Y.delimiter(!1),this.renderDoneOrInstructions()].join(" ");if(this.showMinError)Y+=x.red(`You must select a minimum of ${this.minSelected} choices.`),this.showMinError=!1;Y+=this.renderOptions(this.value),this.out.write(this.clear+Y),this.clear=kY(Y,this.out.columns)}}xY.exports=bY});var yY=Q((aU,vY)=>{var F1=S(),R7=u(),{erase:W7,cursor:hY}=M(),{style:O0,clear:fY,figures:V0,wrap:E7,entriesToDisplay:L7}=P(),wY=(Y,$)=>Y[$]&&(Y[$].value||Y[$].title||Y[$]),G7=(Y,$)=>Y[$]&&(Y[$].title||Y[$].value||Y[$]),S7=(Y,$)=>{let Z=Y.findIndex((H)=>H.value===$||H.title===$);return Z>-1?Z:void 0};class gY extends R7{constructor(Y={}){super(Y);this.msg=Y.message,this.suggest=Y.suggest,this.choices=Y.choices,this.initial=typeof Y.initial==="number"?Y.initial:S7(Y.choices,Y.initial),this.select=this.initial||Y.cursor||0,this.i18n={noMatches:Y.noMatches||"no matches found"},this.fallback=Y.fallback||this.initial,this.clearFirst=Y.clearFirst||!1,this.suggestions=[],this.input="",this.limit=Y.limit||10,this.cursor=0,this.transform=O0.render(Y.style),this.scale=this.transform.scale,this.render=this.render.bind(this),this.complete=this.complete.bind(this),this.clear=fY("",this.out.columns),this.complete(this.render),this.render()}set fallback(Y){this._fb=Number.isSafeInteger(parseInt(Y))?parseInt(Y):Y}get fallback(){let Y;if(typeof this._fb==="number")Y=this.choices[this._fb];else if(typeof this._fb==="string")Y={title:this._fb};return Y||this._fb||{title:this.i18n.noMatches}}moveSelect(Y){if(this.select=Y,this.suggestions.length>0)this.value=wY(this.suggestions,Y);else this.value=this.fallback.value;this.fire()}async complete(Y){let $=this.completing=this.suggest(this.input,this.choices),Z=await $;if(this.completing!==$)return;this.suggestions=Z.map((D,U,J)=>({title:G7(J,U),value:wY(J,U),description:D.description})),this.completing=!1;let H=Math.max(Z.length-1,0);this.moveSelect(Math.min(H,this.select)),Y&&Y()}reset(){this.input="",this.complete(()=>{this.moveSelect(this.initial!==void 0?this.initial:0),this.render()}),this.render()}exit(){if(this.clearFirst&&this.input.length>0)this.reset();else this.done=this.exited=!0,this.aborted=!1,this.fire(),this.render(),this.out.write(`
|
|
84
84
|
`),this.close()}abort(){this.done=this.aborted=!0,this.exited=!1,this.fire(),this.render(),this.out.write(`
|
|
85
85
|
`),this.close()}submit(){this.done=!0,this.aborted=this.exited=!1,this.fire(),this.render(),this.out.write(`
|
|
86
|
-
`),this.close()}_(Y,$){let Z=this.input.slice(0,this.cursor),H=this.input.slice(this.cursor);this.input=`${Z}${Y}${H}`,this.cursor=Z.length+1,this.complete(this.render),this.render()}delete(){if(this.cursor===0)return this.bell();let Y=this.input.slice(0,this.cursor-1),$=this.input.slice(this.cursor);this.input=`${Y}${$}`,this.complete(this.render),this.cursor=this.cursor-1,this.render()}deleteForward(){if(this.cursor*this.scale>=this.rendered.length)return this.bell();let Y=this.input.slice(0,this.cursor),$=this.input.slice(this.cursor+1);this.input=`${Y}${$}`,this.complete(this.render),this.render()}first(){this.moveSelect(0),this.render()}last(){this.moveSelect(this.suggestions.length-1),this.render()}up(){if(this.select===0)this.moveSelect(this.suggestions.length-1);else this.moveSelect(this.select-1);this.render()}down(){if(this.select===this.suggestions.length-1)this.moveSelect(0);else this.moveSelect(this.select+1);this.render()}next(){if(this.select===this.suggestions.length-1)this.moveSelect(0);else this.moveSelect(this.select+1);this.render()}nextPage(){this.moveSelect(Math.min(this.select+this.limit,this.suggestions.length-1)),this.render()}prevPage(){this.moveSelect(Math.max(this.select-this.limit,0)),this.render()}left(){if(this.cursor<=0)return this.bell();this.cursor=this.cursor-1,this.render()}right(){if(this.cursor*this.scale>=this.rendered.length)return this.bell();this.cursor=this.cursor+1,this.render()}renderOption(Y,$,Z,H){let U
|
|
87
|
-
`+
|
|
86
|
+
`),this.close()}_(Y,$){let Z=this.input.slice(0,this.cursor),H=this.input.slice(this.cursor);this.input=`${Z}${Y}${H}`,this.cursor=Z.length+1,this.complete(this.render),this.render()}delete(){if(this.cursor===0)return this.bell();let Y=this.input.slice(0,this.cursor-1),$=this.input.slice(this.cursor);this.input=`${Y}${$}`,this.complete(this.render),this.cursor=this.cursor-1,this.render()}deleteForward(){if(this.cursor*this.scale>=this.rendered.length)return this.bell();let Y=this.input.slice(0,this.cursor),$=this.input.slice(this.cursor+1);this.input=`${Y}${$}`,this.complete(this.render),this.render()}first(){this.moveSelect(0),this.render()}last(){this.moveSelect(this.suggestions.length-1),this.render()}up(){if(this.select===0)this.moveSelect(this.suggestions.length-1);else this.moveSelect(this.select-1);this.render()}down(){if(this.select===this.suggestions.length-1)this.moveSelect(0);else this.moveSelect(this.select+1);this.render()}next(){if(this.select===this.suggestions.length-1)this.moveSelect(0);else this.moveSelect(this.select+1);this.render()}nextPage(){this.moveSelect(Math.min(this.select+this.limit,this.suggestions.length-1)),this.render()}prevPage(){this.moveSelect(Math.max(this.select-this.limit,0)),this.render()}left(){if(this.cursor<=0)return this.bell();this.cursor=this.cursor-1,this.render()}right(){if(this.cursor*this.scale>=this.rendered.length)return this.bell();this.cursor=this.cursor+1,this.render()}renderOption(Y,$,Z,H){let D,U=Z?V0.arrowUp:H?V0.arrowDown:" ",J=$?F1.cyan().underline(Y.title):Y.title;if(U=($?F1.cyan(V0.pointer)+" ":" ")+U,Y.description){if(D=` - ${Y.description}`,U.length+J.length+D.length>=this.out.columns||Y.description.split(/\r?\n/).length>1)D=`
|
|
87
|
+
`+E7(Y.description,{margin:3,width:this.out.columns})}return U+" "+J+F1.gray(D||"")}render(){if(this.closed)return;if(this.firstRender)this.out.write(hY.hide);else this.out.write(fY(this.outputText,this.out.columns));super.render();let{startIndex:Y,endIndex:$}=L7(this.select,this.choices.length,this.limit);if(this.outputText=[O0.symbol(this.done,this.aborted,this.exited),F1.bold(this.msg),O0.delimiter(this.completing),this.done&&this.suggestions[this.select]?this.suggestions[this.select].title:this.rendered=this.transform.render(this.input)].join(" "),!this.done){let Z=this.suggestions.slice(Y,$).map((H,D)=>this.renderOption(H,this.select===D+Y,D===0&&Y>0,D+Y===$-1&&$<this.choices.length)).join(`
|
|
88
88
|
`);this.outputText+=`
|
|
89
|
-
`+(Z||
|
|
89
|
+
`+(Z||F1.gray(this.fallback.title))}this.out.write(W7.line+hY.to(0)+this.outputText)}}vY.exports=gY});var nY=Q((rU,lY)=>{var l=S(),{cursor:M7}=M(),F7=F0(),{clear:dY,style:uY,figures:D1}=P();class cY extends F7{constructor(Y={}){Y.overrideRender=!0;super(Y);this.inputValue="",this.clear=dY("",this.out.columns),this.filteredOptions=this.value,this.render()}last(){this.cursor=this.filteredOptions.length-1,this.render()}next(){this.cursor=(this.cursor+1)%this.filteredOptions.length,this.render()}up(){if(this.cursor===0)this.cursor=this.filteredOptions.length-1;else this.cursor--;this.render()}down(){if(this.cursor===this.filteredOptions.length-1)this.cursor=0;else this.cursor++;this.render()}left(){this.filteredOptions[this.cursor].selected=!1,this.render()}right(){if(this.value.filter((Y)=>Y.selected).length>=this.maxChoices)return this.bell();this.filteredOptions[this.cursor].selected=!0,this.render()}delete(){if(this.inputValue.length)this.inputValue=this.inputValue.substr(0,this.inputValue.length-1),this.updateFilteredOptions()}updateFilteredOptions(){let Y=this.filteredOptions[this.cursor];this.filteredOptions=this.value.filter((Z)=>{if(this.inputValue){if(typeof Z.title==="string"){if(Z.title.toLowerCase().includes(this.inputValue.toLowerCase()))return!0}if(typeof Z.value==="string"){if(Z.value.toLowerCase().includes(this.inputValue.toLowerCase()))return!0}return!1}return!0});let $=this.filteredOptions.findIndex((Z)=>Z===Y);this.cursor=$<0?0:$,this.render()}handleSpaceToggle(){let Y=this.filteredOptions[this.cursor];if(Y.selected)Y.selected=!1,this.render();else if(Y.disabled||this.value.filter(($)=>$.selected).length>=this.maxChoices)return this.bell();else Y.selected=!0,this.render()}handleInputChange(Y){this.inputValue=this.inputValue+Y,this.updateFilteredOptions()}_(Y,$){if(Y===" ")this.handleSpaceToggle();else this.handleInputChange(Y)}renderInstructions(){if(this.instructions===void 0||this.instructions){if(typeof this.instructions==="string")return this.instructions;return`
|
|
90
90
|
Instructions:
|
|
91
|
-
${
|
|
92
|
-
${
|
|
91
|
+
${D1.arrowUp}/${D1.arrowDown}: Highlight option
|
|
92
|
+
${D1.arrowLeft}/${D1.arrowRight}/[space]: Toggle selection
|
|
93
93
|
[a,b,c]/delete: Filter choices
|
|
94
94
|
enter/return: Complete answer
|
|
95
95
|
`}return""}renderCurrentInput(){return`
|
|
96
|
-
Filtered results for: ${this.inputValue?this.inputValue:
|
|
97
|
-
`}renderOption(Y,$,Z){let H;if($.disabled)H=Y===Z?
|
|
96
|
+
Filtered results for: ${this.inputValue?this.inputValue:l.gray("Enter something to filter")}
|
|
97
|
+
`}renderOption(Y,$,Z){let H;if($.disabled)H=Y===Z?l.gray().underline($.title):l.strikethrough().gray($.title);else H=Y===Z?l.cyan().underline($.title):$.title;return($.selected?l.green(D1.radioOn):D1.radioOff)+" "+H}renderDoneOrInstructions(){if(this.done)return this.value.filter(($)=>$.selected).map(($)=>$.title).join(", ");let Y=[l.gray(this.hint),this.renderInstructions(),this.renderCurrentInput()];if(this.filteredOptions.length&&this.filteredOptions[this.cursor].disabled)Y.push(l.yellow(this.warn));return Y.join(" ")}render(){if(this.closed)return;if(this.firstRender)this.out.write(M7.hide);super.render();let Y=[uY.symbol(this.done,this.aborted),l.bold(this.msg),uY.delimiter(!1),this.renderDoneOrInstructions()].join(" ");if(this.showMinError)Y+=l.red(`You must select a minimum of ${this.minSelected} choices.`),this.showMinError=!1;Y+=this.renderOptions(this.filteredOptions),this.out.write(this.clear+Y),this.clear=dY(Y,this.out.columns)}}lY.exports=cY});var sY=Q((eU,tY)=>{var mY=S(),O7=u(),{style:pY,clear:V7}=P(),{erase:I7,cursor:iY}=M();class oY extends O7{constructor(Y={}){super(Y);this.msg=Y.message,this.value=Y.initial,this.initialValue=!!Y.initial,this.yesMsg=Y.yes||"yes",this.yesOption=Y.yesOption||"(Y/n)",this.noMsg=Y.no||"no",this.noOption=Y.noOption||"(y/N)",this.render()}reset(){this.value=this.initialValue,this.fire(),this.render()}exit(){this.abort()}abort(){this.done=this.aborted=!0,this.fire(),this.render(),this.out.write(`
|
|
98
98
|
`),this.close()}submit(){this.value=this.value||!1,this.done=!0,this.aborted=!1,this.fire(),this.render(),this.out.write(`
|
|
99
|
-
`),this.close()}_(Y,$){if(Y.toLowerCase()==="y")return this.value=!0,this.submit();if(Y.toLowerCase()==="n")return this.value=!1,this.submit();return this.bell()}render(){if(this.closed)return;if(this.firstRender)this.out.write(cY.hide);else this.out.write(B7(this.outputText,this.out.columns));super.render(),this.outputText=[uY.symbol(this.done,this.aborted),dY.bold(this.msg),uY.delimiter(this.done),this.done?this.value?this.yesMsg:this.noMsg:dY.gray(this.initialValue?this.yesOption:this.noOption)].join(" "),this.out.write(R7.line+cY.to(0)+this.outputText)}}nY.exports=lY});var pY=K((cD,iY)=>{iY.exports={TextPrompt:j9(),SelectPrompt:x9(),TogglePrompt:y9(),DatePrompt:OY(),NumberPrompt:AY(),MultiselectPrompt:I0(),AutocompletePrompt:bY(),AutocompleteMultiselectPrompt:vY(),ConfirmPrompt:mY()}});var oY=K((tY)=>{var A=tY,W7=pY(),n1=(Y)=>Y;function x(Y,$,Z={}){return new Promise((H,U)=>{let D=new W7[Y]($),z=Z.onAbort||n1,J=Z.onSubmit||n1,X=Z.onExit||n1;D.on("state",$.onState||n1),D.on("submit",(Q)=>H(J(Q))),D.on("exit",(Q)=>H(X(Q))),D.on("abort",(Q)=>U(z(Q)))})}A.text=(Y)=>x("TextPrompt",Y);A.password=(Y)=>{return Y.style="password",A.text(Y)};A.invisible=(Y)=>{return Y.style="invisible",A.text(Y)};A.number=(Y)=>x("NumberPrompt",Y);A.date=(Y)=>x("DatePrompt",Y);A.confirm=(Y)=>x("ConfirmPrompt",Y);A.list=(Y)=>{let $=Y.separator||",";return x("TextPrompt",Y,{onSubmit:(Z)=>Z.split($).map((H)=>H.trim())})};A.toggle=(Y)=>x("TogglePrompt",Y);A.select=(Y)=>x("SelectPrompt",Y);A.multiselect=(Y)=>{Y.choices=[].concat(Y.choices||[]);let $=(Z)=>Z.filter((H)=>H.selected).map((H)=>H.value);return x("MultiselectPrompt",Y,{onAbort:$,onSubmit:$})};A.autocompleteMultiselect=(Y)=>{Y.choices=[].concat(Y.choices||[]);let $=(Z)=>Z.filter((H)=>H.selected).map((H)=>H.value);return x("AutocompleteMultiselectPrompt",Y,{onAbort:$,onSubmit:$})};var L7=(Y,$)=>Promise.resolve($.filter((Z)=>Z.title.slice(0,Y.length).toLowerCase()===Y.toLowerCase()));A.autocomplete=(Y)=>{return Y.suggest=Y.suggest||L7,Y.choices=[].concat(Y.choices||[]),x("AutocompletePrompt",Y)}});var rY=K((nD,sY)=>{var V0=oY(),G7=["suggest","format","onState","validate","onRender","type"],aY=()=>{};async function a(Y=[],{onSubmit:$=aY,onCancel:Z=aY}={}){let H={},U=a._override||{};Y=[].concat(Y);let D,z,J,X,Q,J1,K1=async(F,P,A1=!1)=>{if(!A1&&F.validate&&F.validate(P)!==!0)return;return F.format?await F.format(P,H):P};for(z of Y){if({name:X,type:Q}=z,typeof Q==="function")Q=await Q(D,{...H},z),z.type=Q;if(!Q)continue;for(let F in z){if(G7.includes(F))continue;let P=z[F];z[F]=typeof P==="function"?await P(D,{...H},J1):P}if(J1=z,typeof z.message!=="string")throw new Error("prompt message is required");if({name:X,type:Q}=z,V0[Q]===void 0)throw new Error(`prompt type (${Q}) is not defined`);if(U[z.name]!==void 0){if(D=await K1(z,U[z.name]),D!==void 0){H[X]=D;continue}}try{D=a._injected?M7(a._injected,z.initial):await V0[Q](z),H[X]=D=await K1(z,D,!0),J=await $(z,D,H)}catch(F){J=!await Z(z,H)}if(J)return H}return H}function M7(Y,$){let Z=Y.shift();if(Z instanceof Error)throw Z;return Z===void 0?$:Z}function E7(Y){a._injected=(a._injected||[]).concat(Y)}function I7(Y){a._override=Object.assign({},Y)}sY.exports=Object.assign(a,{prompt:a,prompts:V0,inject:E7,override:I7})});var l=K((mD,eY)=>{function O7(Y){Y=(Array.isArray(Y)?Y:Y.split(".")).map(Number);let $=0,Z=process.versions.node.split(".").map(Number);for(;$<Y.length;$++){if(Z[$]>Y[$])return!1;if(Y[$]>Z[$])return!0}return!1}eY.exports=O7("8.6.0")?z9():rY()});var n=K((eD,$$)=>{var S7=/\{([0-9a-zA-Z_]+)\}/g;$$.exports=V7;function V7(Y){var $;if(arguments.length===2&&typeof arguments[1]==="object")$=arguments[1];else{$=new Array(arguments.length-1);for(var Z=1;Z<arguments.length;++Z)$[Z-1]=arguments[Z]}if(!$||!$.hasOwnProperty)$={};return Y.replace(S7,function H(U,D,z){var J;if(Y[z-1]==="{"&&Y[z+U.length]==="}")return D;else{if(J=$.hasOwnProperty(D)?$[D]:null,J===null||J===void 0)return"";return J}})}});var F0=O(l(),1);import{join as A7}from"path";import{Command as S1,CommandArgumentType as i1}from"@elysiumjs/core";var Y$=(Y)=>{if(!Y||Y.length===0)return"";let $=Y.toLowerCase();return $.substring(0,1).toUpperCase()+$.substring(1,$.length)};var I=(Y,$)=>{let Z=Y?.replace(/([A-Z])+/g,Y$).split(/(?=[A-Z])|[\.\-\s_]/).map((U)=>U.toLowerCase())??[];if(Z.length===0)return"";if(Z.length===1)return Z[0];let H=Z.reduce((U,D)=>{return`${U}_${D.toLowerCase()}`});return $?.splitOnNumber===!1?H:H.replace(/([A-Za-z]{1}[0-9]{1})/,(U)=>`${U[0]}_${U[1]}`)};var D1=(Y)=>{let $=Y?.split(/[\.\-\s_]/).map((Z)=>Z.toLowerCase())??[];if($.length===0)return"";return $.map((Z)=>Z.charAt(0).toUpperCase()+Z.slice(1)).join("")};var m1=(Y,$=" ")=>{if(!Y)return"";let Z=$.replace(/[\W]{1}/g,"\\$&"),H=new RegExp(`^[${Z}]+|[${Z}]+$`,"g");return Y.replace(H,"")};var Z$=O(n(),1);import{resolve as F7}from"path";var G=async()=>{let Y=Bun.file(F7(".elysiumrc"));if(!Y.exists())throw new Error("Elysium config file not found.");return JSON.parse(await Y.text())};var S=async(Y)=>{let $=await G();if($.mono)return"./src";return $.modules[Y]};import{dirname as q7}from"path";var V=()=>{return q7(Bun.fileURLToPath(import.meta.url))};class q0 extends S1{static command="make:command";static description="Creates a new command.";async run(){if(!this.command||!this.name)return this.setup();let Y=await G(),$={module:this.module,name:this.name,command:this.command,description:this.description};if(!$.module&&!Y.mono){let Z=await F0.default({type:"select",name:"module",message:"Module:",choices:Object.keys(Y.modules??{}).map((H)=>({title:H,value:H}))});$.module=Z.module}return this.build($)}async setup(){let Y=await G(),Z=await F0.default([{type(){return Y.mono?null:"select"},name:"module",message:"Module:",choices(){return Object.keys(Y.modules??{}).map((H)=>({title:H,value:H}))}},{type:"text",name:"command",message:"Command Name:",initial:"user:say",validate(H){if(H.length<1)return"Command name cannot be empty";return!0}},{type:"text",name:"description",message:"Command Description:",initial:"Say something",validate(H){if(H.length<1)return"Command description cannot be empty";return!0}}]);return Z.name=D1(Z.command.replaceAll(":","_")),this.build(Z)}async build(Y){if(!Y.name){this.error("Operation cancelled.");return}if(!Y.name.endsWith("Command"))Y.name+="Command";let $=Bun.file(A7(V(),"stubs/command.stub")),Z=Z$.default(await $.text(),Y),H=Y.module?await S(Y.module):"./src",U=I(Y.name.replace("Command","")),D=Bun.file(`${H}/commands/${U}.command.ts`);await D.write(Z),this.success(`Command ${this.bold(D.name)} created successfully.`)}}B([S1.arg({description:"The name of the command to create",type:i1.STRING}),R("design:type",String)],q0.prototype,"name",void 0),B([S1.arg({description:"The module where the command will be created",type:i1.STRING}),R("design:type",String)],q0.prototype,"module",void 0),B([S1.arg({description:"The command to create",type:i1.STRING}),R("design:type",String)],q0.prototype,"command",void 0),B([S1.arg({description:"The description of the command",type:i1.STRING}),R("design:type",String)],q0.prototype,"description",void 0);var A0=O(l(),1);import{join as C7}from"path";import{Command as b,CommandArgumentType as m}from"@elysiumjs/core";var H$=O(n(),1);class C0 extends b{constructor(){super(...arguments);this.http=!1;this.wamp=!1;this.ws=!1;this.server=!1;this.request=!1;this.path="/users"}static command="make:controller";static description="Creates a new controller.";async run(){if(!this.name)return this.setup();let Y=await G(),$={module:this.module,type:"http",scope:"SERVER",name:this.name,path:this.path,realm:this.realm??"realm1"};if(!$.module&&!Y.mono){let Z=await A0.default({type:"select",name:"module",message:"Module:",choices:Object.keys(Y.modules??{}).map((H)=>({title:H,value:H}))});$.module=Z.module}if(this.http)$.type="http";else if(this.wamp)$.type="wamp";else if(this.ws)$.type="ws";if(this.server)$.scope="SERVER";else if(this.request)$.scope="REQUEST";return this.build($)}async setup(){let Y="http",$=await G(),H=await A0.default([{type(){return $.mono?null:"select"},name:"module",message:"Module:",choices(){return Object.keys($.modules??{}).map((U)=>({title:U,value:U}))}},{type:"select",name:"type",message:"Controller Type:",choices:[{title:"HTTP",value:"http"},{title:"WAMP",value:"wamp"},{title:"WebSocket",value:"ws"}]},{type:"text",name:"name",message:"Controller Name:",initial:"UserController",validate:(U)=>{if(U.length<1)return"Controller name cannot be empty";return!0}},{type:"text",name:"path",message(U,D){return Y=D.type,D.type==="wamp"?"Controller URL":"Controller Path:"},initial(U,D){return D.type==="wamp"?"ws://localhost:8000":"/users"},validate(U){if(Y==="wamp")return U.match(/^wss?:\/\//)?!0:"The URL must start with ws:// or wss://";if(U[0]!=="/")return"The path must start with a slash (/)";return!0}},{type(U,D){return D.type==="http"?"select":null},name:"scope",message:"Controller Scope:",choices:[{title:"SERVER",value:"SERVER",description:"An unique instance of the controller is created for the entire lifecycle of the server."},{title:"REQUEST",value:"REQUEST",description:"An instance of the controller is created for each request."}]},{type(U,D){return D.type==="wamp"?"text":null},name:"realm",message:"Controller Realm:",initial:"realm1",validate(U){if(U.length<1)return"Realm name cannot be empty";return!0}}]);return this.build(H)}async build(Y){if(!Y.type||!Y.name||!Y.path){this.error("Operation cancelled.");return}if(!Y.name.endsWith("Controller"))Y.name+="Controller";let $=Bun.file(C7(V(),`stubs/${Y.type}.controller.stub`)),Z=H$.default(await $.text(),Y),H=Y.module?await S(Y.module):"./src",U=I(Y.name.replace("Controller","")),D=Bun.file(`${H}/controllers/${Y.type}/${U}.controller.ts`);await D.write(Z),this.success(`Controller ${this.bold(D.name)} created successfully.`)}}B([b.arg({description:"The name of the controller to create",type:m.STRING}),R("design:type",String)],C0.prototype,"name",void 0),B([b.arg({description:"The module where the controller will be created",type:m.STRING}),R("design:type",String)],C0.prototype,"module",void 0),B([b.arg({description:"Whether to create a HTTP controller",type:m.BOOLEAN,default:!1}),R("design:type",Boolean)],C0.prototype,"http",void 0),B([b.arg({description:"Whether to create a WAMP controller",type:m.BOOLEAN,default:!1}),R("design:type",Boolean)],C0.prototype,"wamp",void 0),B([b.arg({description:"Whether to create a WebSocket controller",type:m.BOOLEAN,default:!1}),R("design:type",Boolean)],C0.prototype,"ws",void 0),B([b.arg({description:"Whether to create a SERVER scope controller",type:m.BOOLEAN,default:!1}),R("design:type",Boolean)],C0.prototype,"server",void 0),B([b.arg({description:"Whether to create a REQUEST scope controller",type:m.BOOLEAN,default:!1}),R("design:type",Boolean)],C0.prototype,"request",void 0),B([b.arg({description:"The path or URL of the controller",type:m.STRING}),R("design:type",String)],C0.prototype,"path",void 0),B([b.arg({description:"The realm of the controller (only applicable to WAMP controllers)",type:m.STRING}),R("design:type",String)],C0.prototype,"realm",void 0);var N0=O(l(),1);import{join as N7}from"path";import{Command as V1,CommandArgumentType as p1}from"@elysiumjs/core";var D$=O(n(),1);class P0 extends V1{constructor(){super(...arguments);this.queue="default"}static command="make:job";static description="Creates a new job.";async run(){if(!this.name)return this.setup();let Y=await G(),$={module:this.module,name:this.name,alias:this.alias,queue:this.queue??"default"};if(!$.module&&!Y.mono){let Z=await N0.default({type:"select",name:"module",message:"Module:",choices:Object.keys(Y.modules??{}).map((H)=>({title:H,value:H}))});$.module=Z.module}return this.build($)}async setup(){let Y=await G(),Z=await N0.default([{type(){return Y.mono?null:"select"},name:"module",message:"Module:",choices(){return Object.keys(Y.modules??{}).map((H)=>({title:H,value:H}))}},{type:"text",name:"name",message:"Job Name:",initial:"SendEmailJob",validate(H){if(H.length<1)return"Job name cannot be empty";return!0}},{type:"text",name:"alias",message:"Job Alias:",initial(H,U){return U.name},validate(H){if(H.length<1)return"Job alias cannot be empty";return!0}},{type:"text",name:"queue",message:"Job Queue:",initial:"default"}]);return this.build(Z)}async build(Y){if(!Y.name){this.error("Operation cancelled.");return}if(!Y.name.endsWith("Job"))Y.name+="Job";if(!Y.alias)Y.alias=Y.name;let $=Bun.file(N7(V(),"stubs/job.stub")),Z=D$.default(await $.text(),Y),H=Y.module?await S(Y.module):"./src",U=I(Y.name.replace("Job","")),D=Bun.file(`${H}/jobs/${U}.job.ts`);await D.write(Z),this.success(`Job ${this.bold(D.name)} created successfully.`)}}B([V1.arg({description:"The name of the job to create",type:p1.STRING}),R("design:type",String)],P0.prototype,"name",void 0),B([V1.arg({description:"The module where the job will be created",type:p1.STRING}),R("design:type",String)],P0.prototype,"module",void 0),B([V1.arg({description:"The alias of the job to create",type:p1.STRING}),R("design:type",String)],P0.prototype,"alias",void 0),B([V1.arg({description:"The name of the queue where the job will be dispatched",type:p1.STRING,default:"default"}),R("design:type",String)],P0.prototype,"queue",void 0);var T0=O(l(),1);import{join as P7}from"path";import{Command as j0,CommandArgumentType as U$}from"@elysiumjs/core";var z$=O(n(),1);class k0 extends j0{static command="make:middleware";static description="Creates a new middleware.";async run(){if(!this.name)return this.setup();let Y=await G(),$={module:this.module,name:this.name};if(!$.module&&!Y.mono){let Z=await T0.default({type:"select",name:"module",message:"Module:",choices:Object.keys(Y.modules??{}).map((H)=>({title:H,value:H}))});$.module=Z.module}return this.build($)}async setup(){let Y=await G(),Z=await T0.default([{type(){return Y.mono?null:"select"},name:"module",message:"Module:",choices(){return Object.keys(Y.modules??{}).map((H)=>({title:H,value:H}))}},{type:"text",name:"name",message:"Middleware Name:",initial:"AuthMiddleware",validate(H){if(H.length<1)return"Middleware name cannot be empty";return!0}}]);return this.build(Z)}async build(Y){if(!Y.name){this.error("Operation cancelled.");return}if(!Y.name.endsWith("Middleware"))Y.name+="Middleware";let $=Bun.file(P7(V(),"stubs/middleware.stub")),Z=z$.default(await $.text(),Y),H=Y.module?await S(Y.module):"./src",U=I(Y.name.replace("Middleware","")),D=Bun.file(`${H}/middlewares/${U}.middleware.ts`);await D.write(Z),this.success(`Middleware ${this.bold(D.name)} created successfully.`)}}B([j0.arg({description:"The name of the middleware to create",type:U$.STRING}),R("design:type",String)],k0.prototype,"name",void 0),B([j0.arg({description:"The module where the middleware will be created",type:U$.STRING}),R("design:type",String)],k0.prototype,"module",void 0);var _0=O(l(),1);import{join as j7}from"path";import{Command as F1,CommandArgumentType as t1}from"@elysiumjs/core";var J$=O(n(),1);class h0 extends F1{constructor(){super(...arguments);this.supportTenancy=!1}static command="make:model";static description="Creates a new model.";async run(){if(!this.name||!this.tableName)return this.setup();let Y=await G(),$={module:this.module,table:this.tableName,name:this.name,supportTenancy:this.supportTenancy};if(!$.module&&!Y.mono){let Z=await _0.default({type:"select",name:"module",message:"Module:",choices:Object.keys(Y.modules??{}).map((H)=>({title:H,value:H}))});$.module=Z.module}if(!$.name)$.name=m1(D1($.table),"s");return $.canonicalName=$.name,this.build($)}async setup(){let Y=await G(),Z=await _0.default([{type(){return Y.mono?null:"select"},name:"module",message:"Module:",choices(){return Object.keys(Y.modules??{}).map((H)=>({title:H,value:H}))}},{type:"text",name:"table",message:"Table Name:",initial:"users",validate(H){if(H.length<1)return"Table name cannot be empty";return!0}},{type:"text",name:"name",message:"Model Name:",initial(H,U){return m1(D1(U.table),"s")},validate(H){if(H.length<1)return"Model name cannot be empty";return!0}},{type:"select",name:"supportTenancy",message:"Support Tenancy:",choices:[{title:"Yes",value:!0,description:"The model supports multi-tenancy."},{title:"No",value:!1,description:"The model does not support multi-tenancy."}]}]);return this.build(Z)}async build(Y){if(!Y.name){this.error("Operation cancelled.");return}if(!Y.name.endsWith("Model"))Y.name+="Model";Y.canonicalName=Y.name.replace("Model","");let $=Bun.file(j7(V(),"stubs/model.stub")),Z=J$.default(await $.text(),Y),H=Y.module?await S(Y.module):"./src",U=I(Y.name.replace("Model","")),D=Bun.file(`${H}/models/${U}.model.ts`);await D.write(Z),this.success(`Model ${this.bold(D.name)} created successfully.`)}}B([F1.arg({description:"The name of the model to create",type:t1.STRING}),R("design:type",String)],h0.prototype,"name",void 0),B([F1.arg({description:"The module where the model will be created",type:t1.STRING}),R("design:type",String)],h0.prototype,"module",void 0),B([F1.arg({name:"table",description:"The name of the table wrapped by the model",type:t1.STRING}),R("design:type",String)],h0.prototype,"tableName",void 0),B([F1.arg({name:"support-tenancy",description:"Support tenancy",type:t1.BOOLEAN,default:!1}),R("design:type",Boolean)],h0.prototype,"supportTenancy",void 0);var x0=O(l(),1);import{join as T7}from"path";import{Command as e,CommandArgumentType as U1}from"@elysiumjs/core";var K$=O(n(),1);class b0 extends e{constructor(){super(...arguments);this.factory=!1;this.singleton=!1}static command="make:repository";static description="Creates a new repository.";async run(){if(!this.name)return this.setup();let Y=await G(),$={module:this.module,name:this.name,alias:this.alias,scope:this.factory?"FACTORY":this.singleton?"SINGLETON":"SINGLETON",model:this.model};if(!$.module&&!Y.mono){let Z=await x0.default({type:"select",name:"module",message:"Module:",choices:Object.keys(Y.modules??{}).map((H)=>({title:H,value:H}))});$.module=Z.module}return this.build($)}async setup(){let Y=await G(),Z=await x0.default([{type(){return Y.mono?null:"select"},name:"module",message:"Module:",choices(){return Object.keys(Y.modules??{}).map((H)=>({title:H,value:H}))}},{type:"text",name:"name",message:"Repository Name:",initial:"UserRepository",validate(H){if(H.length<1)return"Repository name cannot be empty";return!0}},{type:"text",name:"model",message:"Model Name:",initial:"UserModel",validate(H){if(H.length<1)return"Model name cannot be empty";return!0}},{type:"text",name:"alias",message:"Repository Alias:",initial(H,U){return U.name},validate(H){if(H.length<1)return"Repository alias cannot be empty";return!0}},{type:"select",name:"scope",message:"Repository Scope:",choices:[{title:"SINGLETON",value:"SINGLETON",description:"A single instance of the repository is created."},{title:"FACTORY",value:"FACTORY",description:"A new instance of the repository is created each time it is injected."}]}]);return this.build(Z)}async build(Y){if(!Y.name){this.error("Operation cancelled.");return}if(!Y.name.endsWith("Repository"))Y.name+="Repository";if(!Y.alias)Y.alias=Y.name;let $=Bun.file(T7(V(),"stubs/repository.stub")),Z=K$.default(await $.text(),{...Y,module:Y.module??"root",model_name:Y.model.replace("Model","").toLowerCase()}),H=Y.module?await S(Y.module):"./src",U=I(Y.name.replace("Repository","")),D=Bun.file(`${H}/repositories/${U}.repository.ts`);await D.write(Z),this.success(`Repository ${this.bold(D.name)} created successfully.`)}}B([e.arg({description:"The name of the repository to create",type:U1.STRING}),R("design:type",String)],b0.prototype,"name",void 0),B([e.arg({description:"The module where the repository will be created",type:U1.STRING}),R("design:type",String)],b0.prototype,"module",void 0),B([e.arg({description:"The alias of the repository to create",type:U1.STRING}),R("design:type",String)],b0.prototype,"alias",void 0),B([e.arg({description:"The model used by the repository",type:U1.STRING}),R("design:type",String)],b0.prototype,"model",void 0),B([e.arg({description:"Create a factory repository",type:U1.BOOLEAN,default:!1}),R("design:type",Boolean)],b0.prototype,"factory",void 0),B([e.arg({description:"Create a singleton repository",type:U1.BOOLEAN,default:!1}),R("design:type",Boolean)],b0.prototype,"singleton",void 0);var f0=O(l(),1);import{join as k7}from"path";import{Command as z1,CommandArgumentType as q1}from"@elysiumjs/core";var X$=O(n(),1);class w0 extends z1{constructor(){super(...arguments);this.factory=!1;this.singleton=!1}static command="make:service";static description="Creates a new service.";async run(){if(!this.name)return this.setup();let Y=await G(),$={module:this.module,name:this.name,alias:this.alias,scope:this.factory?"FACTORY":this.singleton?"SINGLETON":"SINGLETON"};if(!$.module&&!Y.mono){let Z=await f0.default({type:"select",name:"module",message:"Module:",choices:Object.keys(Y.modules??{}).map((H)=>({title:H,value:H}))});$.module=Z.module}return this.build($)}async setup(){let Y=await G(),Z=await f0.default([{type(){return Y.mono?null:"select"},name:"module",message:"Module:",choices(){return Object.keys(Y.modules??{}).map((H)=>({title:H,value:H}))}},{type:"text",name:"name",message:"Service Name:",initial:"UserService",validate(H){if(H.length<1)return"Service name cannot be empty";return!0}},{type:"text",name:"alias",message:"Service Alias:",initial(H,U){return U.name},validate(H){if(H.length<1)return"Service alias cannot be empty";return!0}},{type:"select",name:"scope",message:"Service Scope:",choices:[{title:"SINGLETON",value:"SINGLETON",description:"A single instance of the service is created."},{title:"FACTORY",value:"FACTORY",description:"A new instance of the service is created each time it is injected."}]}]);return this.build(Z)}async build(Y){if(!Y.name){this.error("Operation cancelled.");return}if(!Y.name.endsWith("Service"))Y.name+="Service";if(!Y.alias)Y.alias=Y.name;let $=Bun.file(k7(V(),"stubs/service.stub")),Z=X$.default(await $.text(),Y),H=Y.module?await S(Y.module):"./src",U=I(Y.name.replace("Service","")),D=Bun.file(`${H}/services/${U}.service.ts`);await D.write(Z),this.success(`Service ${this.bold(D.name)} created successfully.`)}}B([z1.arg({description:"The name of the service to create",type:q1.STRING}),R("design:type",String)],w0.prototype,"name",void 0),B([z1.arg({description:"The module where the service will be created",type:q1.STRING}),R("design:type",String)],w0.prototype,"module",void 0),B([z1.arg({description:"The alias of the service to create",type:q1.STRING}),R("design:type",String)],w0.prototype,"alias",void 0),B([z1.arg({description:"Create a factory service",type:q1.BOOLEAN,default:!1}),R("design:type",Boolean)],w0.prototype,"factory",void 0),B([z1.arg({description:"Create a singleton service",type:q1.BOOLEAN,default:!1}),R("design:type",Boolean)],w0.prototype,"singleton",void 0);var y0=O(l(),1);import{join as _7}from"path";import{Command as g0,CommandArgumentType as Q$}from"@elysiumjs/core";var B$=O(n(),1);class v0 extends g0{static command="make:validator";static description="Creates a new validator.";async run(){if(!this.name)return this.setup();let Y=await G(),$={module:this.module,name:this.name};if(!$.module&&!Y.mono){let Z=await y0.default({type:"select",name:"module",message:"Module:",choices:Object.keys(Y.modules??{}).map((H)=>({title:H,value:H}))});$.module=Z.module}return this.build($)}async setup(){let Y=await G(),Z=await y0.default([{type(){return Y.mono?null:"select"},name:"module",message:"Module:",choices(){return Object.keys(Y.modules??{}).map((H)=>({title:H,value:H}))}},{type:"text",name:"name",message:"Validator Name:",initial:"LoginValidator",validate(H){if(H.length<1)return"Validator name cannot be empty";return!0}}]);return this.build(Z)}async build(Y){if(!Y.name){this.error("Operation cancelled.");return}if(!Y.name.endsWith("Validator"))Y.name+="Validator";if(!Y.request_name)Y.request_name=Y.name.replace("Validator","Request");let $=Bun.file(_7(V(),"stubs/validator.stub")),Z=B$.default(await $.text(),Y),H=Y.module?await S(Y.module):"./src",U=I(Y.name.replace("Validator","")),D=Bun.file(`${H}/validators/${U}.validator.ts`);await D.write(Z),this.success(`Validator ${this.bold(D.name)} created successfully.`)}}B([g0.arg({description:"The name of the validator to create",type:Q$.STRING}),R("design:type",String)],v0.prototype,"name",void 0),B([g0.arg({description:"The module where the validator will be created",type:Q$.STRING}),R("design:type",String)],v0.prototype,"module",void 0);var{App:R$}=await import(`${process.cwd()}/src/app`);class o1 extends R${}o1=B([R$.register({commands:[q0,C0,P0,k0,h0,b0,w0,v0]})],o1);new o1;
|
|
99
|
+
`),this.close()}_(Y,$){if(Y.toLowerCase()==="y")return this.value=!0,this.submit();if(Y.toLowerCase()==="n")return this.value=!1,this.submit();return this.bell()}render(){if(this.closed)return;if(this.firstRender)this.out.write(iY.hide);else this.out.write(V7(this.outputText,this.out.columns));super.render(),this.outputText=[pY.symbol(this.done,this.aborted),mY.bold(this.msg),pY.delimiter(this.done),this.done?this.value?this.yesMsg:this.noMsg:mY.gray(this.initialValue?this.yesOption:this.noOption)].join(" "),this.out.write(I7.line+iY.to(0)+this.outputText)}}tY.exports=oY});var rY=Q((Y5,aY)=>{aY.exports={TextPrompt:x9(),SelectPrompt:v9(),TogglePrompt:l9(),DatePrompt:CY(),NumberPrompt:TY(),MultiselectPrompt:F0(),AutocompletePrompt:yY(),AutocompleteMultiselectPrompt:nY(),ConfirmPrompt:sY()}});var Y$=Q((eY)=>{var C=eY,A7=rY(),n1=(Y)=>Y;function h(Y,$,Z={}){return new Promise((H,D)=>{let U=new A7[Y]($),J=Z.onAbort||n1,X=Z.onSubmit||n1,z=Z.onExit||n1;U.on("state",$.onState||n1),U.on("submit",(K)=>H(X(K))),U.on("exit",(K)=>H(z(K))),U.on("abort",(K)=>D(J(K)))})}C.text=(Y)=>h("TextPrompt",Y);C.password=(Y)=>{return Y.style="password",C.text(Y)};C.invisible=(Y)=>{return Y.style="invisible",C.text(Y)};C.number=(Y)=>h("NumberPrompt",Y);C.date=(Y)=>h("DatePrompt",Y);C.confirm=(Y)=>h("ConfirmPrompt",Y);C.list=(Y)=>{let $=Y.separator||",";return h("TextPrompt",Y,{onSubmit:(Z)=>Z.split($).map((H)=>H.trim())})};C.toggle=(Y)=>h("TogglePrompt",Y);C.select=(Y)=>h("SelectPrompt",Y);C.multiselect=(Y)=>{Y.choices=[].concat(Y.choices||[]);let $=(Z)=>Z.filter((H)=>H.selected).map((H)=>H.value);return h("MultiselectPrompt",Y,{onAbort:$,onSubmit:$})};C.autocompleteMultiselect=(Y)=>{Y.choices=[].concat(Y.choices||[]);let $=(Z)=>Z.filter((H)=>H.selected).map((H)=>H.value);return h("AutocompleteMultiselectPrompt",Y,{onAbort:$,onSubmit:$})};var C7=(Y,$)=>Promise.resolve($.filter((Z)=>Z.title.slice(0,Y.length).toLowerCase()===Y.toLowerCase()));C.autocomplete=(Y)=>{return Y.suggest=Y.suggest||C7,Y.choices=[].concat(Y.choices||[]),h("AutocompletePrompt",Y)}});var H$=Q((Z5,Z$)=>{var I0=Y$(),q7=["suggest","format","onState","validate","onRender","type"],$$=()=>{};async function s(Y=[],{onSubmit:$=$$,onCancel:Z=$$}={}){let H={},D=s._override||{};Y=[].concat(Y);let U,J,X,z,K,a,r=async(G,q,C1=!1)=>{if(!C1&&G.validate&&G.validate(q)!==!0)return;return G.format?await G.format(q,H):q};for(J of Y){if({name:z,type:K}=J,typeof K==="function")K=await K(U,{...H},J),J.type=K;if(!K)continue;for(let G in J){if(q7.includes(G))continue;let q=J[G];J[G]=typeof q==="function"?await q(U,{...H},a):q}if(a=J,typeof J.message!=="string")throw new Error("prompt message is required");if({name:z,type:K}=J,I0[K]===void 0)throw new Error(`prompt type (${K}) is not defined`);if(D[J.name]!==void 0){if(U=await r(J,D[J.name]),U!==void 0){H[z]=U;continue}}try{U=s._injected?N7(s._injected,J.initial):await I0[K](J),H[z]=U=await r(J,U,!0),X=await $(J,U,H)}catch(G){X=!await Z(J,H)}if(X)return H}return H}function N7(Y,$){let Z=Y.shift();if(Z instanceof Error)throw Z;return Z===void 0?$:Z}function P7(Y){s._injected=(s._injected||[]).concat(Y)}function j7(Y){s._override=Object.assign({},Y)}Z$.exports=Object.assign(s,{prompt:s,prompts:I0,inject:P7,override:j7})});var j=Q((H5,U$)=>{function T7(Y){Y=(Array.isArray(Y)?Y:Y.split(".")).map(Number);let $=0,Z=process.versions.node.split(".").map(Number);for(;$<Y.length;$++){if(Z[$]>Y[$])return!1;if(Y[$]>Z[$])return!0}return!1}U$.exports=T7("8.6.0")?B9():H$()});var n=Q((u5,J$)=>{var k7=/\{([0-9a-zA-Z_]+)\}/g;J$.exports=_7;function _7(Y){var $;if(arguments.length===2&&typeof arguments[1]==="object")$=arguments[1];else{$=new Array(arguments.length-1);for(var Z=1;Z<arguments.length;++Z)$[Z-1]=arguments[Z]}if(!$||!$.hasOwnProperty)$={};return Y.replace(k7,function H(D,U,J){var X;if(Y[J-1]==="{"&&Y[J+D.length]==="}")return U;else{if(X=$.hasOwnProperty(U)?$[U]:null,X===null||X===void 0)return"";return X}})}});var C0=F(j(),1);import{join as h7}from"path";import{Command as O1,CommandArgumentType as p1}from"@elysiumjs/core";var A0=(Y,$,Z="asc")=>{if(!Y)return[];let H=(U,J)=>`${$(U)}`.localeCompare($(J)),D=(U,J)=>`${$(J)}`.localeCompare($(U));return Y.slice().sort(Z==="desc"?D:H)};var D$=(Y)=>{if(!Y||Y.length===0)return"";let $=Y.toLowerCase();return $.substring(0,1).toUpperCase()+$.substring(1,$.length)};var O=(Y,$)=>{let Z=Y?.replace(/([A-Z])+/g,D$).split(/(?=[A-Z])|[\.\-\s_]/).map((D)=>D.toLowerCase())??[];if(Z.length===0)return"";if(Z.length===1)return Z[0];let H=Z.reduce((D,U)=>{return`${D}_${U.toLowerCase()}`});return $?.splitOnNumber===!1?H:H.replace(/([A-Za-z]{1}[0-9]{1})/,(D)=>`${D[0]}_${D[1]}`)};var J1=(Y)=>{let $=Y?.split(/[\.\-\s_]/).map((Z)=>Z.toLowerCase())??[];if($.length===0)return"";return $.map((Z)=>Z.charAt(0).toUpperCase()+Z.slice(1)).join("")};var m1=(Y,$=" ")=>{if(!Y)return"";let Z=$.replace(/[\W]{1}/g,"\\$&"),H=new RegExp(`^[${Z}]+|[${Z}]+$`,"g");return Y.replace(H,"")};var X$=F(n(),1);import{resolve as b7}from"path";var L=async()=>{let Y=Bun.file(b7(".elysiumrc"));if(!Y.exists())throw new Error("Elysium config file not found.");return JSON.parse(await Y.text())};var V=async(Y)=>{let $=await L();if($.mono)return"./src";return $.modules[Y]};import{dirname as x7}from"path";var I=()=>{return x7(Bun.fileURLToPath(import.meta.url))};class q0 extends O1{static command="make:command";static description="Creates a new command.";async run(){if(!this.command||!this.name)return this.setup();let Y=await L(),$={module:this.module,name:this.name,command:this.command,description:this.description};if(!$.module&&!Y.mono){let Z=await C0.default({type:"select",name:"module",message:"Module:",choices:Object.keys(Y.modules??{}).map((H)=>({title:H,value:H}))});$.module=Z.module}return this.build($)}async setup(){let Y=await L(),Z=await C0.default([{type(){return Y.mono?null:"select"},name:"module",message:"Module:",choices(){return Object.keys(Y.modules??{}).map((H)=>({title:H,value:H}))}},{type:"text",name:"command",message:"Command Name:",initial:"user:say",validate(H){if(H.length<1)return"Command name cannot be empty";return!0}},{type:"text",name:"description",message:"Command Description:",initial:"Say something",validate(H){if(H.length<1)return"Command description cannot be empty";return!0}}]);return Z.name=J1(Z.command.replaceAll(":","_")),this.build(Z)}async build(Y){if(!Y.name){this.error("Operation cancelled.");return}if(!Y.name.endsWith("Command"))Y.name+="Command";let $=Bun.file(h7(I(),"stubs/command.stub")),Z=X$.default(await $.text(),Y),H=Y.module?await V(Y.module):"./src",D=O(Y.name.replace("Command","")),U=Bun.file(`${H}/commands/${D}.command.ts`);await U.write(Z),this.success(`Command ${this.bold(U.name)} created successfully.`)}}B([O1.arg({description:"The name of the command to create",type:p1.STRING}),R("design:type",String)],q0.prototype,"name",void 0),B([O1.arg({description:"The module where the command will be created",type:p1.STRING}),R("design:type",String)],q0.prototype,"module",void 0),B([O1.arg({description:"The command to create",type:p1.STRING}),R("design:type",String)],q0.prototype,"command",void 0),B([O1.arg({description:"The description of the command",type:p1.STRING}),R("design:type",String)],q0.prototype,"description",void 0);var N0=F(j(),1);import{join as f7}from"path";import{Command as f,CommandArgumentType as m}from"@elysiumjs/core";var Q$=F(n(),1);class P0 extends f{constructor(){super(...arguments);this.http=!1;this.wamp=!1;this.ws=!1;this.server=!1;this.request=!1;this.path="/users"}static command="make:controller";static description="Creates a new controller.";async run(){if(!this.name)return this.setup();let Y=await L(),$={module:this.module,type:"http",scope:"SERVER",name:this.name,path:this.path,realm:this.realm??"realm1"};if(!$.module&&!Y.mono){let Z=await N0.default({type:"select",name:"module",message:"Module:",choices:Object.keys(Y.modules??{}).map((H)=>({title:H,value:H}))});$.module=Z.module}if(this.http)$.type="http";else if(this.wamp)$.type="wamp";else if(this.ws)$.type="ws";if(this.server)$.scope="SERVER";else if(this.request)$.scope="REQUEST";return this.build($)}async setup(){let Y="http",$=await L(),H=await N0.default([{type(){return $.mono?null:"select"},name:"module",message:"Module:",choices(){return Object.keys($.modules??{}).map((D)=>({title:D,value:D}))}},{type:"select",name:"type",message:"Controller Type:",choices:[{title:"HTTP",value:"http"},{title:"WAMP",value:"wamp"},{title:"WebSocket",value:"ws"}]},{type:"text",name:"name",message:"Controller Name:",initial:"UserController",validate:(D)=>{if(D.length<1)return"Controller name cannot be empty";return!0}},{type:"text",name:"path",message(D,U){return Y=U.type,U.type==="wamp"?"Controller URL":"Controller Path:"},initial(D,U){return U.type==="wamp"?"ws://localhost:8000":"/users"},validate(D){if(Y==="wamp")return D.match(/^wss?:\/\//)?!0:"The URL must start with ws:// or wss://";if(D[0]!=="/")return"The path must start with a slash (/)";return!0}},{type(D,U){return U.type==="http"?"select":null},name:"scope",message:"Controller Scope:",choices:[{title:"SERVER",value:"SERVER",description:"An unique instance of the controller is created for the entire lifecycle of the server."},{title:"REQUEST",value:"REQUEST",description:"An instance of the controller is created for each request."}]},{type(D,U){return U.type==="wamp"?"text":null},name:"realm",message:"Controller Realm:",initial:"realm1",validate(D){if(D.length<1)return"Realm name cannot be empty";return!0}}]);return this.build(H)}async build(Y){if(!Y.type||!Y.name||!Y.path){this.error("Operation cancelled.");return}if(!Y.name.endsWith("Controller"))Y.name+="Controller";let $=Bun.file(f7(I(),`stubs/${Y.type}.controller.stub`)),Z=Q$.default(await $.text(),Y),H=Y.module?await V(Y.module):"./src",D=O(Y.name.replace("Controller","")),U=Bun.file(`${H}/controllers/${Y.type}/${D}.controller.ts`);await U.write(Z),this.success(`Controller ${this.bold(U.name)} created successfully.`)}}B([f.arg({description:"The name of the controller to create",type:m.STRING}),R("design:type",String)],P0.prototype,"name",void 0),B([f.arg({description:"The module where the controller will be created",type:m.STRING}),R("design:type",String)],P0.prototype,"module",void 0),B([f.arg({description:"Whether to create a HTTP controller",type:m.BOOLEAN,default:!1}),R("design:type",Boolean)],P0.prototype,"http",void 0),B([f.arg({description:"Whether to create a WAMP controller",type:m.BOOLEAN,default:!1}),R("design:type",Boolean)],P0.prototype,"wamp",void 0),B([f.arg({description:"Whether to create a WebSocket controller",type:m.BOOLEAN,default:!1}),R("design:type",Boolean)],P0.prototype,"ws",void 0),B([f.arg({description:"Whether to create a SERVER scope controller",type:m.BOOLEAN,default:!1}),R("design:type",Boolean)],P0.prototype,"server",void 0),B([f.arg({description:"Whether to create a REQUEST scope controller",type:m.BOOLEAN,default:!1}),R("design:type",Boolean)],P0.prototype,"request",void 0),B([f.arg({description:"The path or URL of the controller",type:m.STRING}),R("design:type",String)],P0.prototype,"path",void 0),B([f.arg({description:"The realm of the controller (only applicable to WAMP controllers)",type:m.STRING}),R("design:type",String)],P0.prototype,"realm",void 0);var j0=F(j(),1);import{join as w7}from"path";import{Command as V1,CommandArgumentType as i1}from"@elysiumjs/core";var z$=F(n(),1);class T0 extends V1{constructor(){super(...arguments);this.queue="default"}static command="make:job";static description="Creates a new job.";async run(){if(!this.name)return this.setup();let Y=await L(),$={module:this.module,name:this.name,alias:this.alias,queue:this.queue??"default"};if(!$.module&&!Y.mono){let Z=await j0.default({type:"select",name:"module",message:"Module:",choices:Object.keys(Y.modules??{}).map((H)=>({title:H,value:H}))});$.module=Z.module}return this.build($)}async setup(){let Y=await L(),Z=await j0.default([{type(){return Y.mono?null:"select"},name:"module",message:"Module:",choices(){return Object.keys(Y.modules??{}).map((H)=>({title:H,value:H}))}},{type:"text",name:"name",message:"Job Name:",initial:"SendEmailJob",validate(H){if(H.length<1)return"Job name cannot be empty";return!0}},{type:"text",name:"alias",message:"Job Alias:",initial(H,D){return D.name},validate(H){if(H.length<1)return"Job alias cannot be empty";return!0}},{type:"text",name:"queue",message:"Job Queue:",initial:"default"}]);return this.build(Z)}async build(Y){if(!Y.name){this.error("Operation cancelled.");return}if(!Y.name.endsWith("Job"))Y.name+="Job";if(!Y.alias)Y.alias=Y.name;let $=Bun.file(w7(I(),"stubs/job.stub")),Z=z$.default(await $.text(),Y),H=Y.module?await V(Y.module):"./src",D=O(Y.name.replace("Job","")),U=Bun.file(`${H}/jobs/${D}.job.ts`);await U.write(Z),this.success(`Job ${this.bold(U.name)} created successfully.`)}}B([V1.arg({description:"The name of the job to create",type:i1.STRING}),R("design:type",String)],T0.prototype,"name",void 0),B([V1.arg({description:"The module where the job will be created",type:i1.STRING}),R("design:type",String)],T0.prototype,"module",void 0),B([V1.arg({description:"The alias of the job to create",type:i1.STRING}),R("design:type",String)],T0.prototype,"alias",void 0),B([V1.arg({description:"The name of the queue where the job will be dispatched",type:i1.STRING,default:"default"}),R("design:type",String)],T0.prototype,"queue",void 0);var _0=F(j(),1);import{join as g7}from"path";import{Command as k0,CommandArgumentType as K$}from"@elysiumjs/core";var B$=F(n(),1);class b0 extends k0{static command="make:middleware";static description="Creates a new middleware.";async run(){if(!this.name)return this.setup();let Y=await L(),$={module:this.module,name:this.name};if(!$.module&&!Y.mono){let Z=await _0.default({type:"select",name:"module",message:"Module:",choices:Object.keys(Y.modules??{}).map((H)=>({title:H,value:H}))});$.module=Z.module}return this.build($)}async setup(){let Y=await L(),Z=await _0.default([{type(){return Y.mono?null:"select"},name:"module",message:"Module:",choices(){return Object.keys(Y.modules??{}).map((H)=>({title:H,value:H}))}},{type:"text",name:"name",message:"Middleware Name:",initial:"AuthMiddleware",validate(H){if(H.length<1)return"Middleware name cannot be empty";return!0}}]);return this.build(Z)}async build(Y){if(!Y.name){this.error("Operation cancelled.");return}if(!Y.name.endsWith("Middleware"))Y.name+="Middleware";let $=Bun.file(g7(I(),"stubs/middleware.stub")),Z=B$.default(await $.text(),Y),H=Y.module?await V(Y.module):"./src",D=O(Y.name.replace("Middleware","")),U=Bun.file(`${H}/middlewares/${D}.middleware.ts`);await U.write(Z),this.success(`Middleware ${this.bold(U.name)} created successfully.`)}}B([k0.arg({description:"The name of the middleware to create",type:K$.STRING}),R("design:type",String)],b0.prototype,"name",void 0),B([k0.arg({description:"The module where the middleware will be created",type:K$.STRING}),R("design:type",String)],b0.prototype,"module",void 0);var x0=F(j(),1);import{join as v7}from"path";import{Command as I1,CommandArgumentType as o1}from"@elysiumjs/core";var R$=F(n(),1);class h0 extends I1{constructor(){super(...arguments);this.supportTenancy=!1}static command="make:model";static description="Creates a new model.";async run(){if(!this.name||!this.tableName)return this.setup();let Y=await L(),$={module:this.module,table:this.tableName,name:this.name,supportTenancy:this.supportTenancy};if(!$.module&&!Y.mono){let Z=await x0.default({type:"select",name:"module",message:"Module:",choices:Object.keys(Y.modules??{}).map((H)=>({title:H,value:H}))});$.module=Z.module}if(!$.name)$.name=m1(J1($.table),"s");return $.canonicalName=$.name,this.build($)}async setup(){let Y=await L(),Z=await x0.default([{type(){return Y.mono?null:"select"},name:"module",message:"Module:",choices(){return Object.keys(Y.modules??{}).map((H)=>({title:H,value:H}))}},{type:"text",name:"table",message:"Table Name:",initial:"users",validate(H){if(H.length<1)return"Table name cannot be empty";return!0}},{type:"text",name:"name",message:"Model Name:",initial(H,D){return m1(J1(D.table),"s")},validate(H){if(H.length<1)return"Model name cannot be empty";return!0}},{type:"select",name:"supportTenancy",message:"Support Tenancy:",choices:[{title:"Yes",value:!0,description:"The model supports multi-tenancy."},{title:"No",value:!1,description:"The model does not support multi-tenancy."}]}]);return this.build(Z)}async build(Y){if(!Y.name){this.error("Operation cancelled.");return}if(!Y.name.endsWith("Model"))Y.name+="Model";Y.canonicalName=Y.name.replace("Model","");let $=Bun.file(v7(I(),"stubs/model.stub")),Z=R$.default(await $.text(),Y),H=Y.module?await V(Y.module):"./src",D=O(Y.name.replace("Model","")),U=Bun.file(`${H}/models/${D}.model.ts`);await U.write(Z),this.success(`Model ${this.bold(U.name)} created successfully.`)}}B([I1.arg({description:"The name of the model to create",type:o1.STRING}),R("design:type",String)],h0.prototype,"name",void 0),B([I1.arg({description:"The module where the model will be created",type:o1.STRING}),R("design:type",String)],h0.prototype,"module",void 0),B([I1.arg({name:"table",description:"The name of the table wrapped by the model",type:o1.STRING}),R("design:type",String)],h0.prototype,"tableName",void 0),B([I1.arg({name:"support-tenancy",description:"Support tenancy",type:o1.BOOLEAN,default:!1}),R("design:type",Boolean)],h0.prototype,"supportTenancy",void 0);var f0=F(j(),1);import{join as y7}from"path";import{Command as $1,CommandArgumentType as X1}from"@elysiumjs/core";var W$=F(n(),1);class w0 extends $1{constructor(){super(...arguments);this.factory=!1;this.singleton=!1}static command="make:repository";static description="Creates a new repository.";async run(){if(!this.name)return this.setup();let Y=await L(),$={module:this.module,name:this.name,alias:this.alias,scope:this.factory?"FACTORY":this.singleton?"SINGLETON":"SINGLETON",model:this.model};if(!$.module&&!Y.mono){let Z=await f0.default({type:"select",name:"module",message:"Module:",choices:Object.keys(Y.modules??{}).map((H)=>({title:H,value:H}))});$.module=Z.module}return this.build($)}async setup(){let Y=await L(),Z=await f0.default([{type(){return Y.mono?null:"select"},name:"module",message:"Module:",choices(){return Object.keys(Y.modules??{}).map((H)=>({title:H,value:H}))}},{type:"text",name:"name",message:"Repository Name:",initial:"UserRepository",validate(H){if(H.length<1)return"Repository name cannot be empty";return!0}},{type:"text",name:"model",message:"Model Name:",initial:"UserModel",validate(H){if(H.length<1)return"Model name cannot be empty";return!0}},{type:"text",name:"alias",message:"Repository Alias:",initial(H,D){return D.name},validate(H){if(H.length<1)return"Repository alias cannot be empty";return!0}},{type:"select",name:"scope",message:"Repository Scope:",choices:[{title:"SINGLETON",value:"SINGLETON",description:"A single instance of the repository is created."},{title:"FACTORY",value:"FACTORY",description:"A new instance of the repository is created each time it is injected."}]}]);return this.build(Z)}async build(Y){if(!Y.name){this.error("Operation cancelled.");return}if(!Y.name.endsWith("Repository"))Y.name+="Repository";if(!Y.alias)Y.alias=Y.name;let $=Bun.file(y7(I(),"stubs/repository.stub")),Z=W$.default(await $.text(),{...Y,module:Y.module??"root",model_name:O(Y.model.replace("Model",""))}),H=Y.module?await V(Y.module):"./src",D=O(Y.name.replace("Repository","")),U=Bun.file(`${H}/repositories/${D}.repository.ts`);await U.write(Z),this.success(`Repository ${this.bold(U.name)} created successfully.`)}}B([$1.arg({description:"The name of the repository to create",type:X1.STRING}),R("design:type",String)],w0.prototype,"name",void 0),B([$1.arg({description:"The module where the repository will be created",type:X1.STRING}),R("design:type",String)],w0.prototype,"module",void 0),B([$1.arg({description:"The alias of the repository to create",type:X1.STRING}),R("design:type",String)],w0.prototype,"alias",void 0),B([$1.arg({description:"The model used by the repository",type:X1.STRING}),R("design:type",String)],w0.prototype,"model",void 0),B([$1.arg({description:"Create a factory repository",type:X1.BOOLEAN,default:!1}),R("design:type",Boolean)],w0.prototype,"factory",void 0),B([$1.arg({description:"Create a singleton repository",type:X1.BOOLEAN,default:!1}),R("design:type",Boolean)],w0.prototype,"singleton",void 0);var g0=F(j(),1);import{join as d7}from"path";import{Command as Q1,CommandArgumentType as A1}from"@elysiumjs/core";var E$=F(n(),1);class v0 extends Q1{constructor(){super(...arguments);this.factory=!1;this.singleton=!1}static command="make:service";static description="Creates a new service.";async run(){if(!this.name)return this.setup();let Y=await L(),$={module:this.module,name:this.name,alias:this.alias,scope:this.factory?"FACTORY":this.singleton?"SINGLETON":"SINGLETON"};if(!$.module&&!Y.mono){let Z=await g0.default({type:"select",name:"module",message:"Module:",choices:Object.keys(Y.modules??{}).map((H)=>({title:H,value:H}))});$.module=Z.module}return this.build($)}async setup(){let Y=await L(),Z=await g0.default([{type(){return Y.mono?null:"select"},name:"module",message:"Module:",choices(){return Object.keys(Y.modules??{}).map((H)=>({title:H,value:H}))}},{type:"text",name:"name",message:"Service Name:",initial:"UserService",validate(H){if(H.length<1)return"Service name cannot be empty";return!0}},{type:"text",name:"alias",message:"Service Alias:",initial(H,D){return D.name},validate(H){if(H.length<1)return"Service alias cannot be empty";return!0}},{type:"select",name:"scope",message:"Service Scope:",choices:[{title:"SINGLETON",value:"SINGLETON",description:"A single instance of the service is created."},{title:"FACTORY",value:"FACTORY",description:"A new instance of the service is created each time it is injected."}]}]);return this.build(Z)}async build(Y){if(!Y.name){this.error("Operation cancelled.");return}if(!Y.name.endsWith("Service"))Y.name+="Service";if(!Y.alias)Y.alias=Y.name;let $=Bun.file(d7(I(),"stubs/service.stub")),Z=E$.default(await $.text(),Y),H=Y.module?await V(Y.module):"./src",D=O(Y.name.replace("Service","")),U=Bun.file(`${H}/services/${D}.service.ts`);await U.write(Z),this.success(`Service ${this.bold(U.name)} created successfully.`)}}B([Q1.arg({description:"The name of the service to create",type:A1.STRING}),R("design:type",String)],v0.prototype,"name",void 0),B([Q1.arg({description:"The module where the service will be created",type:A1.STRING}),R("design:type",String)],v0.prototype,"module",void 0),B([Q1.arg({description:"The alias of the service to create",type:A1.STRING}),R("design:type",String)],v0.prototype,"alias",void 0),B([Q1.arg({description:"Create a factory service",type:A1.BOOLEAN,default:!1}),R("design:type",Boolean)],v0.prototype,"factory",void 0),B([Q1.arg({description:"Create a singleton service",type:A1.BOOLEAN,default:!1}),R("design:type",Boolean)],v0.prototype,"singleton",void 0);var d0=F(j(),1);import{join as u7}from"path";import{Command as y0,CommandArgumentType as L$}from"@elysiumjs/core";var G$=F(n(),1);class u0 extends y0{static command="make:validator";static description="Creates a new validator.";async run(){if(!this.name)return this.setup();let Y=await L(),$={module:this.module,name:this.name};if(!$.module&&!Y.mono){let Z=await d0.default({type:"select",name:"module",message:"Module:",choices:Object.keys(Y.modules??{}).map((H)=>({title:H,value:H}))});$.module=Z.module}return this.build($)}async setup(){let Y=await L(),Z=await d0.default([{type(){return Y.mono?null:"select"},name:"module",message:"Module:",choices(){return Object.keys(Y.modules??{}).map((H)=>({title:H,value:H}))}},{type:"text",name:"name",message:"Validator Name:",initial:"LoginValidator",validate(H){if(H.length<1)return"Validator name cannot be empty";return!0}}]);return this.build(Z)}async build(Y){if(!Y.name){this.error("Operation cancelled.");return}if(!Y.name.endsWith("Validator"))Y.name+="Validator";if(!Y.request_name)Y.request_name=Y.name.replace("Validator","Request");let $=Bun.file(u7(I(),"stubs/validator.stub")),Z=G$.default(await $.text(),Y),H=Y.module?await V(Y.module):"./src",D=O(Y.name.replace("Validator","")),U=Bun.file(`${H}/validators/${D}.validator.ts`);await U.write(Z),this.success(`Validator ${this.bold(U.name)} created successfully.`)}}B([y0.arg({description:"The name of the validator to create",type:L$.STRING}),R("design:type",String)],u0.prototype,"name",void 0),B([y0.arg({description:"The module where the validator will be created",type:L$.STRING}),R("design:type",String)],u0.prototype,"module",void 0);var M$=F(j(),1);import{exists as c7}from"fs/promises";import{Command as S$,CommandArgumentType as l7}from"@elysiumjs/core";class c0 extends S${static command="migration:generate";static description="Generates migration files.";async run(){if(!this.name){let Z=await M$.default([{type:"text",name:"name",message:"Migration Name:",initial:"create_users_table",validate(H){if(H.length<1)return"Migration name cannot be empty";return!0}}]);this.name=Z.name}let Y="./src/database/schemas";if(await c7(`${process.cwd()}/src/database/schema.ts`))Y="./src/database/schema.ts";await Bun.$`bunx --bun drizzle-kit generate --dialect postgresql --schema ${Y} --out ./src/database/migrations --prefix timestamp --name ${this.name}`;let $=new Bun.Glob(`${process.cwd()}/src/database/migrations/**/*.sql`).scan();for await(let Z of $){let H=Bun.file(Z),D=await H.text();await H.write(D.replace(/"public"./gm,""))}}}B([S$.arg({description:"The name of the migration to create",type:l7.STRING}),R("design:type",String)],c0.prototype,"name",void 0);var V$=F(j(),1);import{basename as F$}from"path";import{Command as t1,CommandArgumentType as l0,Database as O$}from"@elysiumjs/core";class n0 extends t1{constructor(){super(...arguments);this.tenant="";this.connection="default";this.fresh=!1}static command="migration:run";static description="Generates migration files.";async run(){if(!O$.connectionExists(this.connection))return this.error(`Connection ${this.bold(this.connection)} does not exist.`),process.exit(1);let Y=O$.getConnection(this.connection).$client;await Y.connect(),await Y.begin(async($)=>{if(this.fresh)await $`DROP SCHEMA IF EXISTS ${$(this.tenant)} CASCADE;`,await $`CREATE SCHEMA ${$(this.tenant)};`;let[{schema_exists:Z}]=await $`SELECT EXISTS (
|
|
100
|
+
SELECT schema_name
|
|
101
|
+
FROM information_schema.schemata
|
|
102
|
+
WHERE schema_name = ${this.tenant}
|
|
103
|
+
) AS schema_exists;`;if(!Z)if((await V$.default([{type:"confirm",name:"create",message:`Schema ${this.tenant} does not exist. Do you want to create it?`,initial:!0}])).create)await $`CREATE SCHEMA ${$(this.tenant)};`;else return this.error(`Schema ${this.bold(this.tenant)} creation cancelled.`),process.exit(1);await $`SET search_path TO ${$(this.tenant)};`;let[{table_exists:H}]=await $`SELECT EXISTS (
|
|
104
|
+
SELECT *
|
|
105
|
+
FROM information_schema.tables
|
|
106
|
+
WHERE table_name = 'elysium_migrations'
|
|
107
|
+
AND table_schema = ${this.tenant}
|
|
108
|
+
) AS table_exists;`;if(!H)await $`CREATE TABLE elysium_migrations (
|
|
109
|
+
id SERIAL PRIMARY KEY,
|
|
110
|
+
name TEXT NOT NULL,
|
|
111
|
+
batch INTEGER NOT NULL,
|
|
112
|
+
applied_at TIMESTAMP NOT NULL
|
|
113
|
+
);`;let U=(await $`SELECT name FROM elysium_migrations;`).map((G)=>G.name),J=new Bun.Glob("./src/database/migrations/**/*.sql").scan({absolute:!0,onlyFiles:!0}),X=await Array.fromAsync(J),z=A0(X.filter((G)=>!U.includes(F$(G))),(G)=>G);if(z.length===0){this.success("No new migrations to apply.");return}let K=this.spinner(`Running migrations for tenant ${this.bold(this.tenant)}...`),[{max:a}]=await $`SELECT MAX(batch) + 1 AS max FROM elysium_migrations;`,r=a??0;for(let G of z){await $.file(G);let[{name:q}]=await $`INSERT INTO elysium_migrations (name, batch, applied_at) VALUES (${F$(G)}, ${r}, ${new Date}) RETURNING name;`;K.pause(`Migration ${this.bold(q)} applied successfully.`)}K.complete(`Migrations for tenant ${this.bold(this.tenant)} applied successfully.`)}),await Y.close()}}B([t1.arg({description:"The name of the tenant in which the migrations will be executed.",type:l0.STRING,required:!0}),R("design:type",String)],n0.prototype,"tenant",void 0),B([t1.arg({description:"The name of the connection to use.",type:l0.STRING,default:"default"}),R("design:type",String)],n0.prototype,"connection",void 0),B([t1.arg({description:"Drop the entire schema before running the migrations.",type:l0.BOOLEAN,default:!1}),R("design:type",Boolean)],n0.prototype,"fresh",void 0);var{App:I$}=await import(`${process.cwd()}/src/app`);class s1 extends I${}s1=B([I$.register({commands:[q0,P0,T0,b0,h0,w0,v0,u0,c0,n0]})],s1);new s1;
|