@elysiumjs/styx 0.7.0 → 0.7.2
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/dist/index.js +17 -17
- package/package.json +51 -47
- package/stubs/model.stub +2 -2
- package/stubs/repository.stub +3 -2
- package/.turbo/turbo-build.log +0 -9
package/dist/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
var g$=Object.create;var{getPrototypeOf:v$,defineProperty:H2,getOwnPropertyNames:y$}=Object;var d$=Object.prototype.hasOwnProperty;var V=(Y,$,H)=>{H=Y!=null?g$(v$(Y)):{};let Z=$||!Y||!Y.__esModule?H2(H,"default",{value:Y,enumerable:!0}):H;for(let X of y$(Y))if(!d$.call(Z,X))H2(Z,X,{get:()=>Y[X],enumerable:!0});return Z};var K=(Y,$)=>()=>($||Y(($={exports:{}}).exports,$),$.exports);var z=function(Y,$,H,Z){var X=arguments.length,U=X<3?$:Z===null?Z=Object.getOwnPropertyDescriptor($,H):Z,Q;if(typeof Reflect==="object"&&typeof Reflect.decorate==="function")U=Reflect.decorate(Y,$,H,Z);else for(var J=Y.length-1;J>=0;J--)if(Q=Y[J])U=(X<3?Q(U):X>3?Q($,H,U):Q($,H))||U;return X>3&&U&&Object.defineProperty($,H,U),U};var L=(Y,$)=>{if(typeof Reflect==="object"&&typeof Reflect.metadata==="function")return Reflect.metadata(Y,$)};var _1=import.meta.require;var I=K((SU,U2)=>{var{FORCE_COLOR:c$,NODE_DISABLE_COLORS:l$,TERM:p$}=process.env,B={enabled:!l$&&p$!=="dumb"&&c$!=="0",reset:S(0,0),bold:S(1,22),dim:S(2,22),italic:S(3,23),underline:S(4,24),inverse:S(7,27),hidden:S(8,28),strikethrough:S(9,29),black:S(30,39),red:S(31,39),green:S(32,39),yellow:S(33,39),blue:S(34,39),magenta:S(35,39),cyan:S(36,39),white:S(37,39),gray:S(90,39),grey:S(90,39),bgBlack:S(40,49),bgRed:S(41,49),bgGreen:S(42,49),bgYellow:S(43,49),bgBlue:S(44,49),bgMagenta:S(45,49),bgCyan:S(46,49),bgWhite:S(47,49)};function Z2(Y,$){let H=0,Z,X="",U="";for(;H<Y.length;H++)if(Z=Y[H],X+=Z.open,U+=Z.close,$.includes(Z.close))$=$.replace(Z.rgx,Z.close+Z.open);return X+$+U}function n$(Y,$){let H={has:Y,keys:$};return H.reset=B.reset.bind(H),H.bold=B.bold.bind(H),H.dim=B.dim.bind(H),H.italic=B.italic.bind(H),H.underline=B.underline.bind(H),H.inverse=B.inverse.bind(H),H.hidden=B.hidden.bind(H),H.strikethrough=B.strikethrough.bind(H),H.black=B.black.bind(H),H.red=B.red.bind(H),H.green=B.green.bind(H),H.yellow=B.yellow.bind(H),H.blue=B.blue.bind(H),H.magenta=B.magenta.bind(H),H.cyan=B.cyan.bind(H),H.white=B.white.bind(H),H.gray=B.gray.bind(H),H.grey=B.grey.bind(H),H.bgBlack=B.bgBlack.bind(H),H.bgRed=B.bgRed.bind(H),H.bgGreen=B.bgGreen.bind(H),H.bgYellow=B.bgYellow.bind(H),H.bgBlue=B.bgBlue.bind(H),H.bgMagenta=B.bgMagenta.bind(H),H.bgCyan=B.bgCyan.bind(H),H.bgWhite=B.bgWhite.bind(H),H}function S(Y,$){let H={open:`\x1B[${Y}m`,close:`\x1B[${$}m`,rgx:new RegExp(`\\x1b\\[${$}m`,"g")};return function(Z){if(this!==void 0&&this.has!==void 0)return this.has.includes(Y)||(this.has.push(Y),this.keys.push(H)),Z===void 0?this:B.enabled?Z2(this.keys,Z+""):Z+"";return Z===void 0?n$([Y],[H]):B.enabled?Z2([H],Z+""):Z+""}}U2.exports=B});var Q2=K((RU,X2)=>{X2.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 k1=K((GU,J2)=>{J2.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("|"),H=new RegExp($,"g");return typeof Y==="string"?Y.replace(H,""):Y}});var O=K((IU,D2)=>{var Y0={to(Y,$){if(!$)return`\x1B[${Y+1}G`;return`\x1B[${$+1};${Y+1}H`},move(Y,$){let H="";if(Y<0)H+=`\x1B[${-Y}D`;else if(Y>0)H+=`\x1B[${Y}C`;if($<0)H+=`\x1B[${-$}A`;else if($>0)H+=`\x1B[${$}B`;return H},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"},i$={up:(Y=1)=>"\x1B[S".repeat(Y),down:(Y=1)=>"\x1B[T".repeat(Y)},m$={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 H=0;H<Y;H++)$+=this.line+(H<Y-1?Y0.up():"");if(Y)$+=Y0.left;return $}};D2.exports={cursor:Y0,scroll:i$,erase:m$,beep:"\x07"}});var B2=K((OU,L2)=>{function
|
|
3
|
-
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}var U=!0,Q=!1,J;return{s:function(){H=H.call(Y)},n:function(){var W=H.next();return U=W.done,W},e:function(W){Q=!0,J=W},f:function(){try{if(!U&&H.return!=null)H.return()}finally{if(Q)throw J}}}}function
|
|
2
|
+
var g$=Object.create;var{getPrototypeOf:v$,defineProperty:H2,getOwnPropertyNames:y$}=Object;var d$=Object.prototype.hasOwnProperty;var V=(Y,$,H)=>{H=Y!=null?g$(v$(Y)):{};let Z=$||!Y||!Y.__esModule?H2(H,"default",{value:Y,enumerable:!0}):H;for(let X of y$(Y))if(!d$.call(Z,X))H2(Z,X,{get:()=>Y[X],enumerable:!0});return Z};var K=(Y,$)=>()=>($||Y(($={exports:{}}).exports,$),$.exports);var z=function(Y,$,H,Z){var X=arguments.length,U=X<3?$:Z===null?Z=Object.getOwnPropertyDescriptor($,H):Z,Q;if(typeof Reflect==="object"&&typeof Reflect.decorate==="function")U=Reflect.decorate(Y,$,H,Z);else for(var J=Y.length-1;J>=0;J--)if(Q=Y[J])U=(X<3?Q(U):X>3?Q($,H,U):Q($,H))||U;return X>3&&U&&Object.defineProperty($,H,U),U};var L=(Y,$)=>{if(typeof Reflect==="object"&&typeof Reflect.metadata==="function")return Reflect.metadata(Y,$)};var _1=import.meta.require;var I=K((SU,U2)=>{var{FORCE_COLOR:c$,NODE_DISABLE_COLORS:l$,TERM:p$}=process.env,B={enabled:!l$&&p$!=="dumb"&&c$!=="0",reset:S(0,0),bold:S(1,22),dim:S(2,22),italic:S(3,23),underline:S(4,24),inverse:S(7,27),hidden:S(8,28),strikethrough:S(9,29),black:S(30,39),red:S(31,39),green:S(32,39),yellow:S(33,39),blue:S(34,39),magenta:S(35,39),cyan:S(36,39),white:S(37,39),gray:S(90,39),grey:S(90,39),bgBlack:S(40,49),bgRed:S(41,49),bgGreen:S(42,49),bgYellow:S(43,49),bgBlue:S(44,49),bgMagenta:S(45,49),bgCyan:S(46,49),bgWhite:S(47,49)};function Z2(Y,$){let H=0,Z,X="",U="";for(;H<Y.length;H++)if(Z=Y[H],X+=Z.open,U+=Z.close,$.includes(Z.close))$=$.replace(Z.rgx,Z.close+Z.open);return X+$+U}function n$(Y,$){let H={has:Y,keys:$};return H.reset=B.reset.bind(H),H.bold=B.bold.bind(H),H.dim=B.dim.bind(H),H.italic=B.italic.bind(H),H.underline=B.underline.bind(H),H.inverse=B.inverse.bind(H),H.hidden=B.hidden.bind(H),H.strikethrough=B.strikethrough.bind(H),H.black=B.black.bind(H),H.red=B.red.bind(H),H.green=B.green.bind(H),H.yellow=B.yellow.bind(H),H.blue=B.blue.bind(H),H.magenta=B.magenta.bind(H),H.cyan=B.cyan.bind(H),H.white=B.white.bind(H),H.gray=B.gray.bind(H),H.grey=B.grey.bind(H),H.bgBlack=B.bgBlack.bind(H),H.bgRed=B.bgRed.bind(H),H.bgGreen=B.bgGreen.bind(H),H.bgYellow=B.bgYellow.bind(H),H.bgBlue=B.bgBlue.bind(H),H.bgMagenta=B.bgMagenta.bind(H),H.bgCyan=B.bgCyan.bind(H),H.bgWhite=B.bgWhite.bind(H),H}function S(Y,$){let H={open:`\x1B[${Y}m`,close:`\x1B[${$}m`,rgx:new RegExp(`\\x1b\\[${$}m`,"g")};return function(Z){if(this!==void 0&&this.has!==void 0)return this.has.includes(Y)||(this.has.push(Y),this.keys.push(H)),Z===void 0?this:B.enabled?Z2(this.keys,Z+""):Z+"";return Z===void 0?n$([Y],[H]):B.enabled?Z2([H],Z+""):Z+""}}U2.exports=B});var Q2=K((RU,X2)=>{X2.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 k1=K((GU,J2)=>{J2.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("|"),H=new RegExp($,"g");return typeof Y==="string"?Y.replace(H,""):Y}});var O=K((IU,D2)=>{var Y0={to(Y,$){if(!$)return`\x1B[${Y+1}G`;return`\x1B[${$+1};${Y+1}H`},move(Y,$){let H="";if(Y<0)H+=`\x1B[${-Y}D`;else if(Y>0)H+=`\x1B[${Y}C`;if($<0)H+=`\x1B[${-$}A`;else if($>0)H+=`\x1B[${$}B`;return H},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"},i$={up:(Y=1)=>"\x1B[S".repeat(Y),down:(Y=1)=>"\x1B[T".repeat(Y)},m$={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 H=0;H<Y;H++)$+=this.line+(H<Y-1?Y0.up():"");if(Y)$+=Y0.left;return $}};D2.exports={cursor:Y0,scroll:i$,erase:m$,beep:"\x07"}});var B2=K((OU,L2)=>{function t$(Y,$){var H=typeof Symbol<"u"&&Y[Symbol.iterator]||Y["@@iterator"];if(!H){if(Array.isArray(Y)||(H=s$(Y))||$&&Y&&typeof Y.length==="number"){if(H)Y=H;var Z=0,X=function(){};return{s:X,n:function(){if(Z>=Y.length)return{done:!0};return{done:!1,value:Y[Z++]}},e:function(W){throw W},f:X}}throw TypeError(`Invalid attempt to iterate non-iterable instance.
|
|
3
|
+
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}var U=!0,Q=!1,J;return{s:function(){H=H.call(Y)},n:function(){var W=H.next();return U=W.done,W},e:function(W){Q=!0,J=W},f:function(){try{if(!U&&H.return!=null)H.return()}finally{if(Q)throw J}}}}function s$(Y,$){if(!Y)return;if(typeof Y==="string")return z2(Y,$);var H=Object.prototype.toString.call(Y).slice(8,-1);if(H==="Object"&&Y.constructor)H=Y.constructor.name;if(H==="Map"||H==="Set")return Array.from(Y);if(H==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(H))return z2(Y,$)}function z2(Y,$){if($==null||$>Y.length)$=Y.length;for(var H=0,Z=Array($);H<$;H++)Z[H]=Y[H];return Z}var o$=k1(),W2=O(),K2=W2.erase,r$=W2.cursor,a$=(Y)=>[...o$(Y)].length;L2.exports=function(Y,$){if(!$)return K2.line+r$.to(0);let H=0,Z=Y.split(/\r?\n/);var X=t$(Z),U;try{for(X.s();!(U=X.n()).done;){let Q=U.value;H+=1+Math.floor(Math.max(a$(Q)-1,0)/$)}}catch(Q){X.e(Q)}finally{X.f()}return K2.lines(H)}});var $0=K((FU,E2)=>{var L1={arrowUp:"\u2191",arrowDown:"\u2193",arrowLeft:"\u2190",arrowRight:"\u2192",radioOn:"\u25C9",radioOff:"\u25EF",tick:"\u2714",cross:"\u2716",ellipsis:"\u2026",pointerSmall:"\u203A",line:"\u2500",pointer:"\u276F"},e$={arrowUp:L1.arrowUp,arrowDown:L1.arrowDown,arrowLeft:L1.arrowLeft,arrowRight:L1.arrowRight,radioOn:"(*)",radioOff:"( )",tick:"\u221A",cross:"\xD7",ellipsis:"...",pointerSmall:"\xBB",line:"\u2500",pointer:">"},YH=process.platform==="win32"?e$:L1;E2.exports=YH});var R2=K((VU,S2)=>{var X1=I(),H1=$0(),H0=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}`}}),$H=(Y)=>H0[Y]||H0.default,B1=Object.freeze({aborted:X1.red(H1.cross),done:X1.green(H1.tick),exited:X1.yellow(H1.cross),default:X1.cyan("?")}),HH=(Y,$,H)=>$?B1.aborted:H?B1.exited:Y?B1.done:B1.default,ZH=(Y)=>X1.gray(Y?H1.ellipsis:H1.pointerSmall),UH=(Y,$)=>X1.gray(Y?$?H1.pointerSmall:"+":H1.line);S2.exports={styles:H0,render:$H,symbols:B1,symbol:HH,delimiter:ZH,item:UH}});var I2=K((AU,G2)=>{var XH=k1();G2.exports=function(Y,$){let H=String(XH(Y)||"").split(/\r?\n/);if(!$)return H.length;return H.map((Z)=>Math.ceil(Z.length/$)).reduce((Z,X)=>Z+X)}});var F2=K((MU,O2)=>{O2.exports=(Y,$={})=>{let H=Number.isSafeInteger(parseInt($.margin))?Array(parseInt($.margin)).fill(" ").join(""):$.margin||"",Z=$.width;return(Y||"").split(/\r?\n/g).map((X)=>X.split(/\s+/g).reduce((U,Q)=>{if(Q.length+H.length>=Z||U[U.length-1].length+Q.length+1<Z)U[U.length-1]+=` ${Q}`;else U.push(`${H}${Q}`);return U},[H]).join(`
|
|
4
4
|
`)).join(`
|
|
5
5
|
`)}});var A2=K((qU,V2)=>{V2.exports=(Y,$,H)=>{H=H||$;let Z=Math.min($-H,Y-Math.floor(H/2));if(Z<0)Z=0;let X=Math.min(Z+H,$);return{startIndex:Z,endIndex:X}}});var C=K((NU,M2)=>{M2.exports={action:Q2(),clear:B2(),style:R2(),strip:k1(),figures:$0(),lines:I2(),wrap:F2(),entriesToDisplay:A2()}});var y=K((TU,P2)=>{var q2=_1("readline"),QH=C(),JH=QH.action,DH=_1("events"),N2=O(),zH=N2.beep,KH=N2.cursor,WH=I();class T2 extends DH{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 $=q2.createInterface({input:this.in,escapeCodeTimeout:50});if(q2.emitKeypressEvents(this.in,$),this.in.isTTY)this.in.setRawMode(!0);let H=["SelectPrompt","MultiselectPrompt"].indexOf(this.constructor.name)>-1,Z=(X,U)=>{let Q=JH(U,H);if(Q===!1)this._&&this._(X,U);else if(typeof this[Q]==="function")this[Q](U);else this.bell()};this.close=()=>{if(this.out.write(KH.show),this.in.removeListener("keypress",Z),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",Z)}fire(){this.emit("state",{value:this.value,aborted:!!this.aborted,exited:!!this.exited})}bell(){this.out.write(zH)}render(){if(this.onRender(WH),this.firstRender)this.firstRender=!1}}P2.exports=T2});var x2=K((PU,h2)=>{function C2(Y,$,H,Z,X,U,Q){try{var J=Y[U](Q),D=J.value}catch(W){H(W);return}if(J.done)$(D);else Promise.resolve(D).then(Z,X)}function j2(Y){return function(){var $=this,H=arguments;return new Promise(function(Z,X){var U=Y.apply($,H);function Q(D){C2(U,Z,X,Q,J,"next",D)}function J(D){C2(U,Z,X,Q,J,"throw",D)}Q(void 0)})}}var h1=I(),LH=y(),_2=O(),BH=_2.erase,E1=_2.cursor,x1=C(),Z0=x1.style,U0=x1.clear,EH=x1.lines,SH=x1.figures;class k2 extends LH{constructor(Y={}){super(Y);this.transform=Z0.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=U0("",this.out.columns),this.render()}set value(Y){if(!Y&&this.initial)this.placeholder=!0,this.rendered=h1.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(`
|
|
6
6
|
`),this.close()}validate(){var Y=this;return j2(function*(){let $=yield Y.validator(Y.value);if(typeof $==="string")Y.errorMsg=$,$=!1;Y.error=!$})()}submit(){var Y=this;return j2(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(`
|
|
@@ -13,15 +13,15 @@ ${H?" ":SH.pointerSmall} ${h1.red().italic($)}`,"");this.out.write(BH.line+E1.to
|
|
|
13
13
|
`+GH(J.description,{margin:3,width:this.out.columns})}this.outputText+=`${U} ${X}${d.gray(Q)}
|
|
14
14
|
`}}this.out.write(this.outputText)}}g2.exports=w2});var n2=K((jU,p2)=>{var f1=I(),VH=y(),u2=C(),y2=u2.style,AH=u2.clear,c2=O(),d2=c2.cursor,MH=c2.erase;class l2 extends VH{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(`
|
|
15
15
|
`),this.close()}submit(){this.done=!0,this.aborted=!1,this.fire(),this.render(),this.out.write(`
|
|
16
|
-
`),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(d2.hide);else this.out.write(AH(this.outputText,this.out.columns));super.render(),this.outputText=[y2.symbol(this.done,this.aborted),f1.bold(this.msg),y2.delimiter(this.done),this.value?this.inactive:f1.cyan().underline(this.inactive),f1.gray("/"),this.value?f1.cyan().underline(this.active):this.active].join(" "),this.out.write(MH.line+d2.to(0)+this.outputText)}}p2.exports=l2});var k=K((_U,i2)=>{class w1{constructor({token:Y,date:$,parts:H,locales:Z}){this.token=Y,this.date=$||new Date,this.parts=H||[this],this.locales=Z||{}}up(){}down(){}next(){let Y=this.parts.indexOf(this);return this.parts.find(($,H)=>H>Y&&$ instanceof w1)}setTo(Y){}prev(){let Y=[].concat(this.parts).reverse(),$=Y.indexOf(this);return Y.find((H,Z)=>Z>$&&H instanceof w1)}toString(){return String(this.date)}}i2.exports=w1});var
|
|
16
|
+
`),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(d2.hide);else this.out.write(AH(this.outputText,this.out.columns));super.render(),this.outputText=[y2.symbol(this.done,this.aborted),f1.bold(this.msg),y2.delimiter(this.done),this.value?this.inactive:f1.cyan().underline(this.inactive),f1.gray("/"),this.value?f1.cyan().underline(this.active):this.active].join(" "),this.out.write(MH.line+d2.to(0)+this.outputText)}}p2.exports=l2});var k=K((_U,i2)=>{class w1{constructor({token:Y,date:$,parts:H,locales:Z}){this.token=Y,this.date=$||new Date,this.parts=H||[this],this.locales=Z||{}}up(){}down(){}next(){let Y=this.parts.indexOf(this);return this.parts.find(($,H)=>H>Y&&$ instanceof w1)}setTo(Y){}prev(){let Y=[].concat(this.parts).reverse(),$=Y.indexOf(this);return Y.find((H,Z)=>Z>$&&H instanceof w1)}toString(){return String(this.date)}}i2.exports=w1});var s2=K((kU,t2)=>{var qH=k();class m2 extends qH{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}}t2.exports=m2});var a2=K((hU,r2)=>{var NH=k(),TH=(Y)=>{return Y=Y%10,Y===1?"st":Y===2?"nd":Y===3?"rd":"th"};class o2 extends NH{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+TH(Y):this.token==="d"?$+1:this.token==="ddd"?this.locales.weekdaysShort[$]:this.token==="dddd"?this.locales.weekdays[$]:Y}}r2.exports=o2});var $4=K((xU,Y4)=>{var PH=k();class e2 extends PH{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}}Y4.exports=e2});var U4=K((bU,Z4)=>{var CH=k();class H4 extends CH{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)}}Z4.exports=H4});var J4=K((fU,Q4)=>{var jH=k();class X4 extends jH{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}}Q4.exports=X4});var K4=K((wU,z4)=>{var _H=k();class D4 extends _H{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)}}z4.exports=D4});var B4=K((gU,L4)=>{var kH=k();class W4 extends kH{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}}L4.exports=W4});var R4=K((vU,S4)=>{var hH=k();class E4 extends hH{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}}S4.exports=E4});var I4=K((yU,G4)=>{G4.exports={DatePart:k(),Meridiem:s2(),Day:a2(),Hours:$4(),Milliseconds:U4(),Minutes:J4(),Month:K4(),Seconds:B4(),Year:R4()}});var j4=K((dU,C4)=>{function O4(Y,$,H,Z,X,U,Q){try{var J=Y[U](Q),D=J.value}catch(W){H(W);return}if(J.done)$(D);else Promise.resolve(D).then(Z,X)}function F4(Y){return function(){var $=this,H=arguments;return new Promise(function(Z,X){var U=Y.apply($,H);function Q(D){O4(U,Z,X,Q,J,"next",D)}function J(D){O4(U,Z,X,Q,J,"throw",D)}Q(void 0)})}}var X0=I(),xH=y(),Q0=C(),V4=Q0.style,A4=Q0.clear,bH=Q0.figures,T4=O(),fH=T4.erase,M4=T4.cursor,u=I4(),q4=u.DatePart,wH=u.Meridiem,gH=u.Day,vH=u.Hours,yH=u.Milliseconds,dH=u.Minutes,uH=u.Month,cH=u.Seconds,lH=u.Year,pH=/\\(.)|"((?:\\["\\]|[^"])+)"|(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,N4={1:({token:Y})=>Y.replace(/\\(.)/g,"$1"),2:(Y)=>new gH(Y),3:(Y)=>new uH(Y),4:(Y)=>new lH(Y),5:(Y)=>new wH(Y),6:(Y)=>new vH(Y),7:(Y)=>new dH(Y),8:(Y)=>new cH(Y),9:(Y)=>new yH(Y)},nH={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 P4 extends xH{constructor(Y={}){super(Y);this.msg=Y.message,this.cursor=0,this.typed="",this.locales=Object.assign(nH,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=A4("",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($=pH.exec(Y)){let Z=$.shift(),X=$.findIndex((U)=>U!=null);this.parts.push(X in N4?N4[X]({token:$[X]||Z,date:this.date,parts:this.parts,locales:this.locales}):$[X]||Z)}let H=this.parts.reduce((Z,X)=>{if(typeof X==="string"&&typeof Z[Z.length-1]==="string")Z[Z.length-1]+=X;else Z.push(X);return Z},[]);this.parts.splice(0),this.parts.push(...H),this.reset()}moveCursor(Y){this.typed="",this.cursor=Y,this.fire()}reset(){this.moveCursor(this.parts.findIndex((Y)=>Y instanceof q4)),this.fire(),this.render()}exit(){this.abort()}abort(){this.done=this.aborted=!0,this.error=!1,this.fire(),this.render(),this.out.write(`
|
|
17
17
|
`),this.close()}validate(){var Y=this;return F4(function*(){let $=yield Y.validator(Y.value);if(typeof $==="string")Y.errorMsg=$,$=!1;Y.error=!$})()}submit(){var Y=this;return F4(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(`
|
|
18
18
|
`),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 q4)),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(M4.hide);else this.out.write(A4(this.outputText,this.out.columns));if(super.render(),this.outputText=[V4.symbol(this.done,this.aborted),X0.bold(this.msg),V4.delimiter(!1),this.parts.reduce((Y,$,H)=>Y.concat(H===this.cursor&&!this.done?X0.cyan().underline($.toString()):$),[]).join("")].join(" "),this.error)this.outputText+=this.errorMsg.split(`
|
|
19
19
|
`).reduce((Y,$,H)=>Y+`
|
|
20
|
-
${H?" ":bH.pointerSmall} ${X0.red().italic($)}`,"");this.out.write(fH.line+M4.to(0)+this.outputText)}}C4.exports=P4});var g4=K((uU,w4)=>{function _4(Y,$,H,Z,X,U,Q){try{var J=Y[U](Q),D=J.value}catch(W){H(W);return}if(J.done)$(D);else Promise.resolve(D).then(Z,X)}function k4(Y){return function(){var $=this,H=arguments;return new Promise(function(Z,X){var U=Y.apply($,H);function Q(D){_4(U,Z,X,Q,J,"next",D)}function J(D){_4(U,Z,X,Q,J,"throw",D)}Q(void 0)})}}var g1=I(),iH=y(),b4=O(),v1=b4.cursor,mH=b4.erase,y1=C(),J0=y1.style,
|
|
20
|
+
${H?" ":bH.pointerSmall} ${X0.red().italic($)}`,"");this.out.write(fH.line+M4.to(0)+this.outputText)}}C4.exports=P4});var g4=K((uU,w4)=>{function _4(Y,$,H,Z,X,U,Q){try{var J=Y[U](Q),D=J.value}catch(W){H(W);return}if(J.done)$(D);else Promise.resolve(D).then(Z,X)}function k4(Y){return function(){var $=this,H=arguments;return new Promise(function(Z,X){var U=Y.apply($,H);function Q(D){_4(U,Z,X,Q,J,"next",D)}function J(D){_4(U,Z,X,Q,J,"throw",D)}Q(void 0)})}}var g1=I(),iH=y(),b4=O(),v1=b4.cursor,mH=b4.erase,y1=C(),J0=y1.style,tH=y1.figures,h4=y1.clear,sH=y1.lines,oH=/[0-9]/,D0=(Y)=>Y!==void 0,x4=(Y,$)=>{let H=Math.pow(10,$);return Math.round(Y*H)/H};class f4 extends iH{constructor(Y={}){super(Y);this.transform=J0.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=g1.gray(this.transform.render(`${this.initial}`)),this._value="";else this.placeholder=!1,this.rendered=this.transform.render(`${x4(Y,this.round)}`),this._value=x4(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||oH.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(`
|
|
21
21
|
`),this.close()}validate(){var Y=this;return k4(function*(){let $=yield Y.validator(Y.value);if(typeof $==="string")Y.errorMsg=$,$=!1;Y.error=!$})()}submit(){var Y=this;return k4(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(`
|
|
22
|
-
`),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 H=Date.now();if(H-this.lastHit>1000)this.typed="";if(this.typed+=Y,this.lastHit=H,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(v1.down(
|
|
22
|
+
`),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 H=Date.now();if(H-this.lastHit>1000)this.typed="";if(this.typed+=Y,this.lastHit=H,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(v1.down(sH(this.outputError,this.out.columns)-1)+h4(this.outputError,this.out.columns));this.out.write(h4(this.outputText,this.out.columns))}if(super.render(),this.outputError="",this.outputText=[J0.symbol(this.done,this.aborted),g1.bold(this.msg),J0.delimiter(this.done),!this.done||!this.done&&!this.placeholder?g1[this.color]().underline(this.rendered):this.rendered].join(" "),this.error)this.outputError+=this.errorMsg.split(`
|
|
23
23
|
`).reduce((Y,$,H)=>Y+`
|
|
24
|
-
${H?" ":
|
|
24
|
+
${H?" ":tH.pointerSmall} ${g1.red().italic($)}`,"");this.out.write(mH.line+v1.to(0)+this.outputText+v1.save+this.outputError+v1.restore)}}w4.exports=f4});var z0=K((cU,u4)=>{var h=I(),rH=O(),aH=rH.cursor,eH=y(),R1=C(),v4=R1.clear,o=R1.figures,y4=R1.style,YZ=R1.wrap,$Z=R1.entriesToDisplay;class d4 extends eH{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(($,H)=>{if(typeof $==="string")$={title:$,value:H};return{title:$&&($.title||$.value||$),description:$&&$.description,value:$&&($.value===void 0?H:$.value),selected:$&&$.selected,disabled:$&&$.disabled}}),this.clear=v4("",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(`
|
|
25
25
|
`),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(`
|
|
26
26
|
`),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`
|
|
27
27
|
Instructions:
|
|
@@ -31,13 +31,13 @@ Instructions:
|
|
|
31
31
|
`:"")+" enter/return: Complete answer"}return""}renderOption(Y,$,H,Z){let X=($.selected?h.green(o.radioOn):o.radioOff)+" "+Z+" ",U,Q;if($.disabled)U=Y===H?h.gray().underline($.title):h.strikethrough().gray($.title);else if(U=Y===H?h.cyan().underline($.title):$.title,Y===H&&$.description){if(Q=` - ${$.description}`,X.length+U.length+Q.length>=this.out.columns||$.description.split(/\r?\n/).length>1)Q=`
|
|
32
32
|
`+YZ($.description,{margin:X.length,width:this.out.columns})}return X+U+h.gray(Q||"")}paginateOptions(Y){if(Y.length===0)return h.red("No matches for this query.");let $=$Z(this.cursor,Y.length,this.optionsPerPage),H=$.startIndex,Z=$.endIndex,X,U=[];for(let Q=H;Q<Z;Q++){if(Q===H&&H>0)X=o.arrowUp;else if(Q===Z-1&&Z<Y.length)X=o.arrowDown;else X=" ";U.push(this.renderOption(this.cursor,Y[Q],Q,X))}return`
|
|
33
33
|
`+U.join(`
|
|
34
|
-
`)}renderOptions(Y){if(!this.done)return this.paginateOptions(Y);return""}renderDoneOrInstructions(){if(this.done)return this.value.filter(($)=>$.selected).map(($)=>$.title).join(", ");let Y=[h.gray(this.hint),this.renderInstructions()];if(this.value[this.cursor].disabled)Y.push(h.yellow(this.warn));return Y.join(" ")}render(){if(this.closed)return;if(this.firstRender)this.out.write(aH.hide);super.render();let Y=[y4.symbol(this.done,this.aborted),h.bold(this.msg),y4.delimiter(!1),this.renderDoneOrInstructions()].join(" ");if(this.showMinError)Y+=h.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=v4(Y,this.out.columns)}}u4.exports=d4});var
|
|
34
|
+
`)}renderOptions(Y){if(!this.done)return this.paginateOptions(Y);return""}renderDoneOrInstructions(){if(this.done)return this.value.filter(($)=>$.selected).map(($)=>$.title).join(", ");let Y=[h.gray(this.hint),this.renderInstructions()];if(this.value[this.cursor].disabled)Y.push(h.yellow(this.warn));return Y.join(" ")}render(){if(this.closed)return;if(this.firstRender)this.out.write(aH.hide);super.render();let Y=[y4.symbol(this.done,this.aborted),h.bold(this.msg),y4.delimiter(!1),this.renderDoneOrInstructions()].join(" ");if(this.showMinError)Y+=h.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=v4(Y,this.out.columns)}}u4.exports=d4});var s4=K((lU,t4)=>{function c4(Y,$,H,Z,X,U,Q){try{var J=Y[U](Q),D=J.value}catch(W){H(W);return}if(J.done)$(D);else Promise.resolve(D).then(Z,X)}function HZ(Y){return function(){var $=this,H=arguments;return new Promise(function(Z,X){var U=Y.apply($,H);function Q(D){c4(U,Z,X,Q,J,"next",D)}function J(D){c4(U,Z,X,Q,J,"throw",D)}Q(void 0)})}}var G1=I(),ZZ=y(),i4=O(),UZ=i4.erase,l4=i4.cursor,I1=C(),K0=I1.style,p4=I1.clear,W0=I1.figures,XZ=I1.wrap,QZ=I1.entriesToDisplay,n4=(Y,$)=>Y[$]&&(Y[$].value||Y[$].title||Y[$]),JZ=(Y,$)=>Y[$]&&(Y[$].title||Y[$].value||Y[$]),DZ=(Y,$)=>{let H=Y.findIndex((Z)=>Z.value===$||Z.title===$);return H>-1?H:void 0};class m4 extends ZZ{constructor(Y={}){super(Y);this.msg=Y.message,this.suggest=Y.suggest,this.choices=Y.choices,this.initial=typeof Y.initial==="number"?Y.initial:DZ(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=K0.render(Y.style),this.scale=this.transform.scale,this.render=this.render.bind(this),this.complete=this.complete.bind(this),this.clear=p4("",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=n4(this.suggestions,Y);else this.value=this.fallback.value;this.fire()}complete(Y){var $=this;return HZ(function*(){let H=$.completing=$.suggest($.input,$.choices),Z=yield H;if($.completing!==H)return;$.suggestions=Z.map((U,Q,J)=>({title:JZ(J,Q),value:n4(J,Q),description:U.description})),$.completing=!1;let X=Math.max(Z.length-1,0);$.moveSelect(Math.min(X,$.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(`
|
|
35
35
|
`),this.close()}abort(){this.done=this.aborted=!0,this.exited=!1,this.fire(),this.render(),this.out.write(`
|
|
36
36
|
`),this.close()}submit(){this.done=!0,this.aborted=this.exited=!1,this.fire(),this.render(),this.out.write(`
|
|
37
37
|
`),this.close()}_(Y,$){let H=this.input.slice(0,this.cursor),Z=this.input.slice(this.cursor);this.input=`${H}${Y}${Z}`,this.cursor=H.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,$,H,Z){let X,U=H?W0.arrowUp:Z?W0.arrowDown:" ",Q=$?G1.cyan().underline(Y.title):Y.title;if(U=($?G1.cyan(W0.pointer)+" ":" ")+U,Y.description){if(X=` - ${Y.description}`,U.length+Q.length+X.length>=this.out.columns||Y.description.split(/\r?\n/).length>1)X=`
|
|
38
38
|
`+XZ(Y.description,{margin:3,width:this.out.columns})}return U+" "+Q+G1.gray(X||"")}render(){if(this.closed)return;if(this.firstRender)this.out.write(l4.hide);else this.out.write(p4(this.outputText,this.out.columns));super.render();let Y=QZ(this.select,this.choices.length,this.limit),$=Y.startIndex,H=Y.endIndex;if(this.outputText=[K0.symbol(this.done,this.aborted,this.exited),G1.bold(this.msg),K0.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($,H).map((X,U)=>this.renderOption(X,this.select===U+$,U===0&&$>0,U+$===H-1&&H<this.choices.length)).join(`
|
|
39
39
|
`);this.outputText+=`
|
|
40
|
-
`+(Z||G1.gray(this.fallback.title))}this.out.write(UZ.line+l4.to(0)+this.outputText)}}
|
|
40
|
+
`+(Z||G1.gray(this.fallback.title))}this.out.write(UZ.line+l4.to(0)+this.outputText)}}t4.exports=m4});var Y9=K((pU,e4)=>{var c=I(),zZ=O(),KZ=zZ.cursor,WZ=z0(),L0=C(),o4=L0.clear,r4=L0.style,Q1=L0.figures;class a4 extends WZ{constructor(Y={}){Y.overrideRender=!0;super(Y);this.inputValue="",this.clear=o4("",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((H)=>{if(this.inputValue){if(typeof H.title==="string"){if(H.title.toLowerCase().includes(this.inputValue.toLowerCase()))return!0}if(typeof H.value==="string"){if(H.value.toLowerCase().includes(this.inputValue.toLowerCase()))return!0}return!1}return!0});let $=this.filteredOptions.findIndex((H)=>H===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`
|
|
41
41
|
Instructions:
|
|
42
42
|
${Q1.arrowUp}/${Q1.arrowDown}: Highlight option
|
|
43
43
|
${Q1.arrowLeft}/${Q1.arrowRight}/[space]: Toggle selection
|
|
@@ -47,8 +47,8 @@ Instructions:
|
|
|
47
47
|
Filtered results for: ${this.inputValue?this.inputValue:c.gray("Enter something to filter")}
|
|
48
48
|
`}renderOption(Y,$,H){let Z;if($.disabled)Z=Y===H?c.gray().underline($.title):c.strikethrough().gray($.title);else Z=Y===H?c.cyan().underline($.title):$.title;return($.selected?c.green(Q1.radioOn):Q1.radioOff)+" "+Z}renderDoneOrInstructions(){if(this.done)return this.value.filter(($)=>$.selected).map(($)=>$.title).join(", ");let Y=[c.gray(this.hint),this.renderInstructions(),this.renderCurrentInput()];if(this.filteredOptions.length&&this.filteredOptions[this.cursor].disabled)Y.push(c.yellow(this.warn));return Y.join(" ")}render(){if(this.closed)return;if(this.firstRender)this.out.write(KZ.hide);super.render();let Y=[r4.symbol(this.done,this.aborted),c.bold(this.msg),r4.delimiter(!1),this.renderDoneOrInstructions()].join(" ");if(this.showMinError)Y+=c.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=o4(Y,this.out.columns)}}e4.exports=a4});var D9=K((nU,J9)=>{var $9=I(),LZ=y(),U9=C(),H9=U9.style,BZ=U9.clear,X9=O(),EZ=X9.erase,Z9=X9.cursor;class Q9 extends LZ{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(`
|
|
49
49
|
`),this.close()}submit(){this.value=this.value||!1,this.done=!0,this.aborted=!1,this.fire(),this.render(),this.out.write(`
|
|
50
|
-
`),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(Z9.hide);else this.out.write(BZ(this.outputText,this.out.columns));super.render(),this.outputText=[H9.symbol(this.done,this.aborted),$9.bold(this.msg),H9.delimiter(this.done),this.done?this.value?this.yesMsg:this.noMsg:$9.gray(this.initialValue?this.yesOption:this.noOption)].join(" "),this.out.write(EZ.line+Z9.to(0)+this.outputText)}}J9.exports=Q9});var K9=K((iU,z9)=>{z9.exports={TextPrompt:x2(),SelectPrompt:v2(),TogglePrompt:n2(),DatePrompt:j4(),NumberPrompt:g4(),MultiselectPrompt:z0(),AutocompletePrompt:
|
|
51
|
-
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}var U=!0,Q=!1,J;return{s:function(){H=H.call(Y)},n:function(){var W=H.next();return U=W.done,W},e:function(W){Q=!0,J=W},f:function(){try{if(!U&&H.return!=null)H.return()}finally{if(Q)throw J}}}}function OZ(Y,$){if(!Y)return;if(typeof Y==="string")return S9(Y,$);var H=Object.prototype.toString.call(Y).slice(8,-1);if(H==="Object"&&Y.constructor)H=Y.constructor.name;if(H==="Map"||H==="Set")return Array.from(Y);if(H==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(H))return S9(Y,$)}function S9(Y,$){if($==null||$>Y.length)$=Y.length;for(var H=0,Z=Array($);H<$;H++)Z[H]=Y[H];return Z}function R9(Y,$,H,Z,X,U,Q){try{var J=Y[U](Q),D=J.value}catch(W){H(W);return}if(J.done)$(D);else Promise.resolve(D).then(Z,X)}function G9(Y){return function(){var $=this,H=arguments;return new Promise(function(Z,X){var U=Y.apply($,H);function Q(D){R9(U,Z,X,Q,J,"next",D)}function J(D){R9(U,Z,X,Q,J,"throw",D)}Q(void 0)})}}var B0=L9(),FZ=["suggest","format","onState","validate","onRender","type"],I9=()=>{};function r(){return E0.apply(this,arguments)}function E0(){return E0=G9(function*(Y=[],{onSubmit:$=I9,onCancel:H=I9}={}){let Z={},X=r._override||{};Y=[].concat(Y);let U,Q,J,D,W,Y1,$1=function(){var
|
|
50
|
+
`),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(Z9.hide);else this.out.write(BZ(this.outputText,this.out.columns));super.render(),this.outputText=[H9.symbol(this.done,this.aborted),$9.bold(this.msg),H9.delimiter(this.done),this.done?this.value?this.yesMsg:this.noMsg:$9.gray(this.initialValue?this.yesOption:this.noOption)].join(" "),this.out.write(EZ.line+Z9.to(0)+this.outputText)}}J9.exports=Q9});var K9=K((iU,z9)=>{z9.exports={TextPrompt:x2(),SelectPrompt:v2(),TogglePrompt:n2(),DatePrompt:j4(),NumberPrompt:g4(),MultiselectPrompt:z0(),AutocompletePrompt:s4(),AutocompleteMultiselectPrompt:Y9(),ConfirmPrompt:D9()}});var L9=K((W9)=>{var q=W9,SZ=K9(),d1=(Y)=>Y;function x(Y,$,H={}){return new Promise((Z,X)=>{let U=new SZ[Y]($),Q=H.onAbort||d1,J=H.onSubmit||d1,D=H.onExit||d1;U.on("state",$.onState||d1),U.on("submit",(W)=>Z(J(W))),U.on("exit",(W)=>Z(D(W))),U.on("abort",(W)=>X(Q(W)))})}q.text=(Y)=>x("TextPrompt",Y);q.password=(Y)=>{return Y.style="password",q.text(Y)};q.invisible=(Y)=>{return Y.style="invisible",q.text(Y)};q.number=(Y)=>x("NumberPrompt",Y);q.date=(Y)=>x("DatePrompt",Y);q.confirm=(Y)=>x("ConfirmPrompt",Y);q.list=(Y)=>{let $=Y.separator||",";return x("TextPrompt",Y,{onSubmit:(H)=>H.split($).map((Z)=>Z.trim())})};q.toggle=(Y)=>x("TogglePrompt",Y);q.select=(Y)=>x("SelectPrompt",Y);q.multiselect=(Y)=>{Y.choices=[].concat(Y.choices||[]);let $=(H)=>H.filter((Z)=>Z.selected).map((Z)=>Z.value);return x("MultiselectPrompt",Y,{onAbort:$,onSubmit:$})};q.autocompleteMultiselect=(Y)=>{Y.choices=[].concat(Y.choices||[]);let $=(H)=>H.filter((Z)=>Z.selected).map((Z)=>Z.value);return x("AutocompleteMultiselectPrompt",Y,{onAbort:$,onSubmit:$})};var RZ=(Y,$)=>Promise.resolve($.filter((H)=>H.title.slice(0,Y.length).toLowerCase()===Y.toLowerCase()));q.autocomplete=(Y)=>{return Y.suggest=Y.suggest||RZ,Y.choices=[].concat(Y.choices||[]),x("AutocompletePrompt",Y)}});var F9=K((tU,O9)=>{function B9(Y,$){var H=Object.keys(Y);if(Object.getOwnPropertySymbols){var Z=Object.getOwnPropertySymbols(Y);if($)Z=Z.filter(function(X){return Object.getOwnPropertyDescriptor(Y,X).enumerable});H.push.apply(H,Z)}return H}function E9(Y){for(var $=1;$<arguments.length;$++){var H=arguments[$]!=null?arguments[$]:{};if($%2)B9(Object(H),!0).forEach(function(Z){GZ(Y,Z,H[Z])});else if(Object.getOwnPropertyDescriptors)Object.defineProperties(Y,Object.getOwnPropertyDescriptors(H));else B9(Object(H)).forEach(function(Z){Object.defineProperty(Y,Z,Object.getOwnPropertyDescriptor(H,Z))})}return Y}function GZ(Y,$,H){if($ in Y)Object.defineProperty(Y,$,{value:H,enumerable:!0,configurable:!0,writable:!0});else Y[$]=H;return Y}function IZ(Y,$){var H=typeof Symbol<"u"&&Y[Symbol.iterator]||Y["@@iterator"];if(!H){if(Array.isArray(Y)||(H=OZ(Y))||$&&Y&&typeof Y.length==="number"){if(H)Y=H;var Z=0,X=function(){};return{s:X,n:function(){if(Z>=Y.length)return{done:!0};return{done:!1,value:Y[Z++]}},e:function(W){throw W},f:X}}throw TypeError(`Invalid attempt to iterate non-iterable instance.
|
|
51
|
+
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}var U=!0,Q=!1,J;return{s:function(){H=H.call(Y)},n:function(){var W=H.next();return U=W.done,W},e:function(W){Q=!0,J=W},f:function(){try{if(!U&&H.return!=null)H.return()}finally{if(Q)throw J}}}}function OZ(Y,$){if(!Y)return;if(typeof Y==="string")return S9(Y,$);var H=Object.prototype.toString.call(Y).slice(8,-1);if(H==="Object"&&Y.constructor)H=Y.constructor.name;if(H==="Map"||H==="Set")return Array.from(Y);if(H==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(H))return S9(Y,$)}function S9(Y,$){if($==null||$>Y.length)$=Y.length;for(var H=0,Z=Array($);H<$;H++)Z[H]=Y[H];return Z}function R9(Y,$,H,Z,X,U,Q){try{var J=Y[U](Q),D=J.value}catch(W){H(W);return}if(J.done)$(D);else Promise.resolve(D).then(Z,X)}function G9(Y){return function(){var $=this,H=arguments;return new Promise(function(Z,X){var U=Y.apply($,H);function Q(D){R9(U,Z,X,Q,J,"next",D)}function J(D){R9(U,Z,X,Q,J,"throw",D)}Q(void 0)})}}var B0=L9(),FZ=["suggest","format","onState","validate","onRender","type"],I9=()=>{};function r(){return E0.apply(this,arguments)}function E0(){return E0=G9(function*(Y=[],{onSubmit:$=I9,onCancel:H=I9}={}){let Z={},X=r._override||{};Y=[].concat(Y);let U,Q,J,D,W,Y1,$1=function(){var s=G9(function*(v,j1,$2=!1){if(!$2&&v.validate&&v.validate(j1)!==!0)return;return v.format?yield v.format(j1,Z):j1});return function(j1,$2){return s.apply(this,arguments)}}();var G=IZ(Y),P;try{for(G.s();!(P=G.n()).done;){Q=P.value;var C1=Q;if(D=C1.name,W=C1.type,typeof W==="function")W=yield W(U,E9({},Z),Q),Q.type=W;if(!W)continue;for(let s in Q){if(FZ.includes(s))continue;let v=Q[s];Q[s]=typeof v==="function"?yield v(U,E9({},Z),Y1):v}if(Y1=Q,typeof Q.message!=="string")throw Error("prompt message is required");var Y2=Q;if(D=Y2.name,W=Y2.type,B0[W]===void 0)throw Error(`prompt type (${W}) is not defined`);if(X[Q.name]!==void 0){if(U=yield $1(Q,X[Q.name]),U!==void 0){Z[D]=U;continue}}try{U=r._injected?VZ(r._injected,Q.initial):yield B0[W](Q),Z[D]=U=yield $1(Q,U,!0),J=yield $(Q,U,Z)}catch(s){J=!(yield H(Q,Z))}if(J)return Z}}catch(s){G.e(s)}finally{G.f()}return Z}),E0.apply(this,arguments)}function VZ(Y,$){let H=Y.shift();if(H instanceof Error)throw H;return H===void 0?$:H}function AZ(Y){r._injected=(r._injected||[]).concat(Y)}function MZ(Y){r._override=Object.assign({},Y)}O9.exports=Object.assign(r,{prompt:r,prompts:B0,inject:AZ,override:MZ})});var A9=K((sU,V9)=>{V9.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 u1=K((oU,M9)=>{M9.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("|"),H=new RegExp($,"g");return typeof Y==="string"?Y.replace(H,""):Y}});var T9=K((rU,N9)=>{var qZ=u1(),{erase:q9,cursor:NZ}=O(),TZ=(Y)=>[...qZ(Y)].length;N9.exports=function(Y,$){if(!$)return q9.line+NZ.to(0);let H=0,Z=Y.split(/\r?\n/);for(let X of Z)H+=1+Math.floor(Math.max(TZ(X)-1,0)/$);return q9.lines(H)}});var S0=K((aU,P9)=>{var O1={arrowUp:"\u2191",arrowDown:"\u2193",arrowLeft:"\u2190",arrowRight:"\u2192",radioOn:"\u25C9",radioOff:"\u25EF",tick:"\u2714",cross:"\u2716",ellipsis:"\u2026",pointerSmall:"\u203A",line:"\u2500",pointer:"\u276F"},PZ={arrowUp:O1.arrowUp,arrowDown:O1.arrowDown,arrowLeft:O1.arrowLeft,arrowRight:O1.arrowRight,radioOn:"(*)",radioOff:"( )",tick:"\u221A",cross:"\xD7",ellipsis:"...",pointerSmall:"\xBB",line:"\u2500",pointer:">"},CZ=process.platform==="win32"?PZ:O1;P9.exports=CZ});var j9=K((eU,C9)=>{var J1=I(),Z1=S0(),R0=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}`}}),jZ=(Y)=>R0[Y]||R0.default,F1=Object.freeze({aborted:J1.red(Z1.cross),done:J1.green(Z1.tick),exited:J1.yellow(Z1.cross),default:J1.cyan("?")}),_Z=(Y,$,H)=>$?F1.aborted:H?F1.exited:Y?F1.done:F1.default,kZ=(Y)=>J1.gray(Y?Z1.ellipsis:Z1.pointerSmall),hZ=(Y,$)=>J1.gray(Y?$?Z1.pointerSmall:"+":Z1.line);C9.exports={styles:R0,render:jZ,symbols:F1,symbol:_Z,delimiter:kZ,item:hZ}});var k9=K((Y5,_9)=>{var xZ=u1();_9.exports=function(Y,$){let H=String(xZ(Y)||"").split(/\r?\n/);if(!$)return H.length;return H.map((Z)=>Math.ceil(Z.length/$)).reduce((Z,X)=>Z+X)}});var x9=K(($5,h9)=>{h9.exports=(Y,$={})=>{let H=Number.isSafeInteger(parseInt($.margin))?Array(parseInt($.margin)).fill(" ").join(""):$.margin||"",Z=$.width;return(Y||"").split(/\r?\n/g).map((X)=>X.split(/\s+/g).reduce((U,Q)=>{if(Q.length+H.length>=Z||U[U.length-1].length+Q.length+1<Z)U[U.length-1]+=` ${Q}`;else U.push(`${H}${Q}`);return U},[H]).join(`
|
|
52
52
|
`)).join(`
|
|
53
53
|
`)}});var f9=K((H5,b9)=>{b9.exports=(Y,$,H)=>{H=H||$;let Z=Math.min($-H,Y-Math.floor(H/2));if(Z<0)Z=0;let X=Math.min(Z+H,$);return{startIndex:Z,endIndex:X}}});var j=K((Z5,w9)=>{w9.exports={action:A9(),clear:T9(),style:j9(),strip:u1(),figures:S0(),lines:k9(),wrap:x9(),entriesToDisplay:f9()}});var l=K((U5,y9)=>{var g9=_1("readline"),{action:bZ}=j(),fZ=_1("events"),{beep:wZ,cursor:gZ}=O(),vZ=I();class v9 extends fZ{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 $=g9.createInterface({input:this.in,escapeCodeTimeout:50});if(g9.emitKeypressEvents(this.in,$),this.in.isTTY)this.in.setRawMode(!0);let H=["SelectPrompt","MultiselectPrompt"].indexOf(this.constructor.name)>-1,Z=(X,U)=>{let Q=bZ(U,H);if(Q===!1)this._&&this._(X,U);else if(typeof this[Q]==="function")this[Q](U);else this.bell()};this.close=()=>{if(this.out.write(gZ.show),this.in.removeListener("keypress",Z),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",Z)}fire(){this.emit("state",{value:this.value,aborted:!!this.aborted,exited:!!this.exited})}bell(){this.out.write(wZ)}render(){if(this.onRender(vZ),this.firstRender)this.firstRender=!1}}y9.exports=v9});var c9=K((X5,u9)=>{var c1=I(),yZ=l(),{erase:dZ,cursor:V1}=O(),{style:G0,clear:I0,lines:uZ,figures:cZ}=j();class d9 extends yZ{constructor(Y={}){super(Y);this.transform=G0.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=I0("",this.out.columns),this.render()}set value(Y){if(!Y&&this.initial)this.placeholder=!0,this.rendered=c1.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(`
|
|
54
54
|
`),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(`
|
|
@@ -59,9 +59,9 @@ ${H?" ":cZ.pointerSmall} ${c1.red().italic($)}`,"");this.out.write(dZ.line+V1.to
|
|
|
59
59
|
`),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(iZ.hide);else this.out.write(p9(this.outputText,this.out.columns));super.render();let{startIndex:Y,endIndex:$}=nZ(this.cursor,this.choices.length,this.optionsPerPage);if(this.outputText=[l9.symbol(this.done,this.aborted),p.bold(this.msg),l9.delimiter(!1),this.done?this.selection.title:this.selection.disabled?p.yellow(this.warn):p.gray(this.hint)].join(" "),!this.done){this.outputText+=`
|
|
60
60
|
`;for(let H=Y;H<$;H++){let Z,X,U="",Q=this.choices[H];if(H===Y&&Y>0)X=l1.arrowUp;else if(H===$-1&&$<this.choices.length)X=l1.arrowDown;else X=" ";if(Q.disabled)Z=this.cursor===H?p.gray().underline(Q.title):p.strikethrough().gray(Q.title),X=(this.cursor===H?p.bold().gray(l1.pointer)+" ":" ")+X;else if(Z=this.cursor===H?p.cyan().underline(Q.title):Q.title,X=(this.cursor===H?p.cyan(l1.pointer)+" ":" ")+X,Q.description&&this.cursor===H){if(U=` - ${Q.description}`,X.length+Z.length+U.length>=this.out.columns||Q.description.split(/\r?\n/).length>1)U=`
|
|
61
61
|
`+pZ(Q.description,{margin:3,width:this.out.columns})}this.outputText+=`${X} ${Z}${p.gray(U)}
|
|
62
|
-
`}}this.out.write(this.outputText)}}i9.exports=n9});var a9=K((J5,r9)=>{var p1=I(),mZ=l(),{style:
|
|
62
|
+
`}}this.out.write(this.outputText)}}i9.exports=n9});var a9=K((J5,r9)=>{var p1=I(),mZ=l(),{style:t9,clear:tZ}=j(),{cursor:s9,erase:sZ}=O();class o9 extends mZ{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(`
|
|
63
63
|
`),this.close()}submit(){this.done=!0,this.aborted=!1,this.fire(),this.render(),this.out.write(`
|
|
64
|
-
`),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(
|
|
64
|
+
`),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(s9.hide);else this.out.write(tZ(this.outputText,this.out.columns));super.render(),this.outputText=[t9.symbol(this.done,this.aborted),p1.bold(this.msg),t9.delimiter(this.done),this.value?this.inactive:p1.cyan().underline(this.inactive),p1.gray("/"),this.value?p1.cyan().underline(this.active):this.active].join(" "),this.out.write(sZ.line+s9.to(0)+this.outputText)}}r9.exports=o9});var b=K((D5,e9)=>{class n1{constructor({token:Y,date:$,parts:H,locales:Z}){this.token=Y,this.date=$||new Date,this.parts=H||[this],this.locales=Z||{}}up(){}down(){}next(){let Y=this.parts.indexOf(this);return this.parts.find(($,H)=>H>Y&&$ instanceof n1)}setTo(Y){}prev(){let Y=[].concat(this.parts).reverse(),$=Y.indexOf(this);return Y.find((H,Z)=>Z>$&&H instanceof n1)}toString(){return String(this.date)}}e9.exports=n1});var HY=K((z5,$Y)=>{var oZ=b();class YY extends oZ{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}}$Y.exports=YY});var XY=K((K5,UY)=>{var rZ=b(),aZ=(Y)=>{return Y=Y%10,Y===1?"st":Y===2?"nd":Y===3?"rd":"th"};class ZY extends rZ{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+aZ(Y):this.token==="d"?$+1:this.token==="ddd"?this.locales.weekdaysShort[$]:this.token==="dddd"?this.locales.weekdays[$]:Y}}UY.exports=ZY});var DY=K((W5,JY)=>{var eZ=b();class QY extends eZ{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}}JY.exports=QY});var WY=K((L5,KY)=>{var Y7=b();class zY extends Y7{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)}}KY.exports=zY});var EY=K((B5,BY)=>{var $7=b();class LY extends $7{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}}BY.exports=LY});var GY=K((E5,RY)=>{var H7=b();class SY extends H7{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)}}RY.exports=SY});var FY=K((S5,OY)=>{var Z7=b();class IY extends Z7{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}}OY.exports=IY});var MY=K((R5,AY)=>{var U7=b();class VY extends U7{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}}AY.exports=VY});var NY=K((G5,qY)=>{qY.exports={DatePart:b(),Meridiem:HY(),Day:XY(),Hours:DY(),Milliseconds:WY(),Minutes:EY(),Month:GY(),Seconds:FY(),Year:MY()}});var xY=K((I5,hY)=>{var O0=I(),X7=l(),{style:TY,clear:PY,figures:Q7}=j(),{erase:J7,cursor:CY}=O(),{DatePart:jY,Meridiem:D7,Day:z7,Hours:K7,Milliseconds:W7,Minutes:L7,Month:B7,Seconds:E7,Year:S7}=NY(),R7=/\\(.)|"((?:\\["\\]|[^"])+)"|(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,_Y={1:({token:Y})=>Y.replace(/\\(.)/g,"$1"),2:(Y)=>new z7(Y),3:(Y)=>new B7(Y),4:(Y)=>new S7(Y),5:(Y)=>new D7(Y),6:(Y)=>new K7(Y),7:(Y)=>new L7(Y),8:(Y)=>new E7(Y),9:(Y)=>new W7(Y)},G7={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 kY extends X7{constructor(Y={}){super(Y);this.msg=Y.message,this.cursor=0,this.typed="",this.locales=Object.assign(G7,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=PY("",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($=R7.exec(Y)){let Z=$.shift(),X=$.findIndex((U)=>U!=null);this.parts.push(X in _Y?_Y[X]({token:$[X]||Z,date:this.date,parts:this.parts,locales:this.locales}):$[X]||Z)}let H=this.parts.reduce((Z,X)=>{if(typeof X==="string"&&typeof Z[Z.length-1]==="string")Z[Z.length-1]+=X;else Z.push(X);return Z},[]);this.parts.splice(0),this.parts.push(...H),this.reset()}moveCursor(Y){this.typed="",this.cursor=Y,this.fire()}reset(){this.moveCursor(this.parts.findIndex((Y)=>Y instanceof jY)),this.fire(),this.render()}exit(){this.abort()}abort(){this.done=this.aborted=!0,this.error=!1,this.fire(),this.render(),this.out.write(`
|
|
65
65
|
`),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(`
|
|
66
66
|
`),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 jY)),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(CY.hide);else this.out.write(PY(this.outputText,this.out.columns));if(super.render(),this.outputText=[TY.symbol(this.done,this.aborted),O0.bold(this.msg),TY.delimiter(!1),this.parts.reduce((Y,$,H)=>Y.concat(H===this.cursor&&!this.done?O0.cyan().underline($.toString()):$),[]).join("")].join(" "),this.error)this.outputText+=this.errorMsg.split(`
|
|
67
67
|
`).reduce((Y,$,H)=>Y+`
|
|
@@ -79,13 +79,13 @@ Instructions:
|
|
|
79
79
|
`:"")+" enter/return: Complete answer"}return""}renderOption(Y,$,H,Z){let X=($.selected?f.green(a.radioOn):a.radioOff)+" "+Z+" ",U,Q;if($.disabled)U=Y===H?f.gray().underline($.title):f.strikethrough().gray($.title);else if(U=Y===H?f.cyan().underline($.title):$.title,Y===H&&$.description){if(Q=` - ${$.description}`,X.length+U.length+Q.length>=this.out.columns||$.description.split(/\r?\n/).length>1)Q=`
|
|
80
80
|
`+N7($.description,{margin:X.length,width:this.out.columns})}return X+U+f.gray(Q||"")}paginateOptions(Y){if(Y.length===0)return f.red("No matches for this query.");let{startIndex:$,endIndex:H}=T7(this.cursor,Y.length,this.optionsPerPage),Z,X=[];for(let U=$;U<H;U++){if(U===$&&$>0)Z=a.arrowUp;else if(U===H-1&&H<Y.length)Z=a.arrowDown;else Z=" ";X.push(this.renderOption(this.cursor,Y[U],U,Z))}return`
|
|
81
81
|
`+X.join(`
|
|
82
|
-
`)}renderOptions(Y){if(!this.done)return this.paginateOptions(Y);return""}renderDoneOrInstructions(){if(this.done)return this.value.filter(($)=>$.selected).map(($)=>$.title).join(", ");let Y=[f.gray(this.hint),this.renderInstructions()];if(this.value[this.cursor].disabled)Y.push(f.yellow(this.warn));return Y.join(" ")}render(){if(this.closed)return;if(this.firstRender)this.out.write(M7.hide);super.render();let Y=[dY.symbol(this.done,this.aborted),f.bold(this.msg),dY.delimiter(!1),this.renderDoneOrInstructions()].join(" ");if(this.showMinError)Y+=f.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=yY(Y,this.out.columns)}}cY.exports=uY});var
|
|
82
|
+
`)}renderOptions(Y){if(!this.done)return this.paginateOptions(Y);return""}renderDoneOrInstructions(){if(this.done)return this.value.filter(($)=>$.selected).map(($)=>$.title).join(", ");let Y=[f.gray(this.hint),this.renderInstructions()];if(this.value[this.cursor].disabled)Y.push(f.yellow(this.warn));return Y.join(" ")}render(){if(this.closed)return;if(this.firstRender)this.out.write(M7.hide);super.render();let Y=[dY.symbol(this.done,this.aborted),f.bold(this.msg),dY.delimiter(!1),this.renderDoneOrInstructions()].join(" ");if(this.showMinError)Y+=f.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=yY(Y,this.out.columns)}}cY.exports=uY});var tY=K((V5,mY)=>{var A1=I(),P7=l(),{erase:C7,cursor:lY}=O(),{style:M0,clear:pY,figures:q0,wrap:j7,entriesToDisplay:_7}=j(),nY=(Y,$)=>Y[$]&&(Y[$].value||Y[$].title||Y[$]),k7=(Y,$)=>Y[$]&&(Y[$].title||Y[$].value||Y[$]),h7=(Y,$)=>{let H=Y.findIndex((Z)=>Z.value===$||Z.title===$);return H>-1?H:void 0};class iY extends P7{constructor(Y={}){super(Y);this.msg=Y.message,this.suggest=Y.suggest,this.choices=Y.choices,this.initial=typeof Y.initial==="number"?Y.initial:h7(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=M0.render(Y.style),this.scale=this.transform.scale,this.render=this.render.bind(this),this.complete=this.complete.bind(this),this.clear=pY("",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=nY(this.suggestions,Y);else this.value=this.fallback.value;this.fire()}async complete(Y){let $=this.completing=this.suggest(this.input,this.choices),H=await $;if(this.completing!==$)return;this.suggestions=H.map((X,U,Q)=>({title:k7(Q,U),value:nY(Q,U),description:X.description})),this.completing=!1;let Z=Math.max(H.length-1,0);this.moveSelect(Math.min(Z,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(`
|
|
83
83
|
`),this.close()}abort(){this.done=this.aborted=!0,this.exited=!1,this.fire(),this.render(),this.out.write(`
|
|
84
84
|
`),this.close()}submit(){this.done=!0,this.aborted=this.exited=!1,this.fire(),this.render(),this.out.write(`
|
|
85
85
|
`),this.close()}_(Y,$){let H=this.input.slice(0,this.cursor),Z=this.input.slice(this.cursor);this.input=`${H}${Y}${Z}`,this.cursor=H.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,$,H,Z){let X,U=H?q0.arrowUp:Z?q0.arrowDown:" ",Q=$?A1.cyan().underline(Y.title):Y.title;if(U=($?A1.cyan(q0.pointer)+" ":" ")+U,Y.description){if(X=` - ${Y.description}`,U.length+Q.length+X.length>=this.out.columns||Y.description.split(/\r?\n/).length>1)X=`
|
|
86
86
|
`+j7(Y.description,{margin:3,width:this.out.columns})}return U+" "+Q+A1.gray(X||"")}render(){if(this.closed)return;if(this.firstRender)this.out.write(lY.hide);else this.out.write(pY(this.outputText,this.out.columns));super.render();let{startIndex:Y,endIndex:$}=_7(this.select,this.choices.length,this.limit);if(this.outputText=[M0.symbol(this.done,this.aborted,this.exited),A1.bold(this.msg),M0.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(Y,$).map((Z,X)=>this.renderOption(Z,this.select===X+Y,X===0&&Y>0,X+Y===$-1&&$<this.choices.length)).join(`
|
|
87
87
|
`);this.outputText+=`
|
|
88
|
-
`+(H||A1.gray(this.fallback.title))}this.out.write(C7.line+lY.to(0)+this.outputText)}}mY.exports=iY});var eY=K((A5,aY)=>{var n=I(),{cursor:x7}=O(),b7=A0(),{clear:
|
|
88
|
+
`+(H||A1.gray(this.fallback.title))}this.out.write(C7.line+lY.to(0)+this.outputText)}}mY.exports=iY});var eY=K((A5,aY)=>{var n=I(),{cursor:x7}=O(),b7=A0(),{clear:sY,style:oY,figures:D1}=j();class rY extends b7{constructor(Y={}){Y.overrideRender=!0;super(Y);this.inputValue="",this.clear=sY("",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((H)=>{if(this.inputValue){if(typeof H.title==="string"){if(H.title.toLowerCase().includes(this.inputValue.toLowerCase()))return!0}if(typeof H.value==="string"){if(H.value.toLowerCase().includes(this.inputValue.toLowerCase()))return!0}return!1}return!0});let $=this.filteredOptions.findIndex((H)=>H===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`
|
|
89
89
|
Instructions:
|
|
90
90
|
${D1.arrowUp}/${D1.arrowDown}: Highlight option
|
|
91
91
|
${D1.arrowLeft}/${D1.arrowRight}/[space]: Toggle selection
|
|
@@ -93,9 +93,9 @@ Instructions:
|
|
|
93
93
|
enter/return: Complete answer
|
|
94
94
|
`}return""}renderCurrentInput(){return`
|
|
95
95
|
Filtered results for: ${this.inputValue?this.inputValue:n.gray("Enter something to filter")}
|
|
96
|
-
`}renderOption(Y,$,H){let Z;if($.disabled)Z=Y===H?n.gray().underline($.title):n.strikethrough().gray($.title);else Z=Y===H?n.cyan().underline($.title):$.title;return($.selected?n.green(D1.radioOn):D1.radioOff)+" "+Z}renderDoneOrInstructions(){if(this.done)return this.value.filter(($)=>$.selected).map(($)=>$.title).join(", ");let Y=[n.gray(this.hint),this.renderInstructions(),this.renderCurrentInput()];if(this.filteredOptions.length&&this.filteredOptions[this.cursor].disabled)Y.push(n.yellow(this.warn));return Y.join(" ")}render(){if(this.closed)return;if(this.firstRender)this.out.write(x7.hide);super.render();let Y=[oY.symbol(this.done,this.aborted),n.bold(this.msg),oY.delimiter(!1),this.renderDoneOrInstructions()].join(" ");if(this.showMinError)Y+=n.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=
|
|
96
|
+
`}renderOption(Y,$,H){let Z;if($.disabled)Z=Y===H?n.gray().underline($.title):n.strikethrough().gray($.title);else Z=Y===H?n.cyan().underline($.title):$.title;return($.selected?n.green(D1.radioOn):D1.radioOff)+" "+Z}renderDoneOrInstructions(){if(this.done)return this.value.filter(($)=>$.selected).map(($)=>$.title).join(", ");let Y=[n.gray(this.hint),this.renderInstructions(),this.renderCurrentInput()];if(this.filteredOptions.length&&this.filteredOptions[this.cursor].disabled)Y.push(n.yellow(this.warn));return Y.join(" ")}render(){if(this.closed)return;if(this.firstRender)this.out.write(x7.hide);super.render();let Y=[oY.symbol(this.done,this.aborted),n.bold(this.msg),oY.delimiter(!1),this.renderDoneOrInstructions()].join(" ");if(this.showMinError)Y+=n.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=sY(Y,this.out.columns)}}aY.exports=rY});var X$=K((M5,U$)=>{var Y$=I(),f7=l(),{style:$$,clear:w7}=j(),{erase:g7,cursor:H$}=O();class Z$ extends f7{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(`
|
|
97
97
|
`),this.close()}submit(){this.value=this.value||!1,this.done=!0,this.aborted=!1,this.fire(),this.render(),this.out.write(`
|
|
98
|
-
`),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(H$.hide);else this.out.write(w7(this.outputText,this.out.columns));super.render(),this.outputText=[$$.symbol(this.done,this.aborted),Y$.bold(this.msg),$$.delimiter(this.done),this.done?this.value?this.yesMsg:this.noMsg:Y$.gray(this.initialValue?this.yesOption:this.noOption)].join(" "),this.out.write(g7.line+H$.to(0)+this.outputText)}}U$.exports=Z$});var J$=K((q5,Q$)=>{Q$.exports={TextPrompt:c9(),SelectPrompt:m9(),TogglePrompt:a9(),DatePrompt:xY(),NumberPrompt:vY(),MultiselectPrompt:A0(),AutocompletePrompt:sY(),AutocompleteMultiselectPrompt:eY(),ConfirmPrompt:X$()}});var z$=K((D$)=>{var N=D$,v7=J$(),s1=(Y)=>Y;function w(Y,$,H={}){return new Promise((Z,X)=>{let U=new v7[Y]($),Q=H.onAbort||s1,J=H.onSubmit||s1,D=H.onExit||s1;U.on("state",$.onState||s1),U.on("submit",(W)=>Z(J(W))),U.on("exit",(W)=>Z(D(W))),U.on("abort",(W)=>X(Q(W)))})}N.text=(Y)=>w("TextPrompt",Y);N.password=(Y)=>{return Y.style="password",N.text(Y)};N.invisible=(Y)=>{return Y.style="invisible",N.text(Y)};N.number=(Y)=>w("NumberPrompt",Y);N.date=(Y)=>w("DatePrompt",Y);N.confirm=(Y)=>w("ConfirmPrompt",Y);N.list=(Y)=>{let $=Y.separator||",";return w("TextPrompt",Y,{onSubmit:(H)=>H.split($).map((Z)=>Z.trim())})};N.toggle=(Y)=>w("TogglePrompt",Y);N.select=(Y)=>w("SelectPrompt",Y);N.multiselect=(Y)=>{Y.choices=[].concat(Y.choices||[]);let $=(H)=>H.filter((Z)=>Z.selected).map((Z)=>Z.value);return w("MultiselectPrompt",Y,{onAbort:$,onSubmit:$})};N.autocompleteMultiselect=(Y)=>{Y.choices=[].concat(Y.choices||[]);let $=(H)=>H.filter((Z)=>Z.selected).map((Z)=>Z.value);return w("AutocompleteMultiselectPrompt",Y,{onAbort:$,onSubmit:$})};var y7=(Y,$)=>Promise.resolve($.filter((H)=>H.title.slice(0,Y.length).toLowerCase()===Y.toLowerCase()));N.autocomplete=(Y)=>{return Y.suggest=Y.suggest||y7,Y.choices=[].concat(Y.choices||[]),w("AutocompletePrompt",Y)}});var L$=K((T5,W$)=>{var N0=z$(),d7=["suggest","format","onState","validate","onRender","type"],K$=()=>{};async function e(Y=[],{onSubmit:$=K$,onCancel:H=K$}={}){let Z={},X=e._override||{};Y=[].concat(Y);let U,Q,J,D,W,Y1,$1=async(G,P,C1=!1)=>{if(!C1&&G.validate&&G.validate(P)!==!0)return;return G.format?await G.format(P,Z):P};for(Q of Y){if({name:D,type:W}=Q,typeof W==="function")W=await W(U,{...Z},Q),Q.type=W;if(!W)continue;for(let G in Q){if(d7.includes(G))continue;let P=Q[G];Q[G]=typeof P==="function"?await P(U,{...Z},Y1):P}if(Y1=Q,typeof Q.message!=="string")throw Error("prompt message is required");if({name:D,type:W}=Q,N0[W]===void 0)throw Error(`prompt type (${W}) is not defined`);if(X[Q.name]!==void 0){if(U=await $1(Q,X[Q.name]),U!==void 0){Z[D]=U;continue}}try{U=e._injected?u7(e._injected,Q.initial):await N0[W](Q),Z[D]=U=await $1(Q,U,!0),J=await $(Q,U,Z)}catch(G){J=!await H(Q,Z)}if(J)return Z}return Z}function u7(Y,$){let H=Y.shift();if(H instanceof Error)throw H;return H===void 0?$:H}function c7(Y){e._injected=(e._injected||[]).concat(Y)}function l7(Y){e._override=Object.assign({},Y)}W$.exports=Object.assign(e,{prompt:e,prompts:N0,inject:c7,override:l7})});var T=K((P5,B$)=>{function p7(Y){Y=(Array.isArray(Y)?Y:Y.split(".")).map(Number);let $=0,H=process.versions.node.split(".").map(Number);for(;$<Y.length;$++){if(H[$]>Y[$])return!1;if(Y[$]>H[$])return!0}return!1}B$.exports=p7("8.6.0")?F9():L$()});var i=K((W8,S$)=>{var n7=/\{([0-9a-zA-Z_]+)\}/g;S$.exports=i7;function i7(Y){var $;if(arguments.length===2&&typeof arguments[1]==="object")$=arguments[1];else{$=Array(arguments.length-1);for(var H=1;H<arguments.length;++H)$[H-1]=arguments[H]}if(!$||!$.hasOwnProperty)$={};return Y.replace(n7,function(X,U,Q){var J;if(Y[Q-1]==="{"&&Y[Q+X.length]==="}")return U;else{if(J=$.hasOwnProperty(U)?$[U]:null,J===null||J===void 0)return"";return J}})}});import"reflect-metadata";import"@elysiumjs/core";import{Command as u$}from"@elysiumjs/core";class R extends u${static dev=!0}var P0=V(T(),1);import{join as r7}from"path";import{Command as q1,CommandArgumentType as o1}from"@elysiumjs/core";var T0=(Y,$,H="asc")=>{if(!Y)return[];let Z=(U,Q)=>`${$(U)}`.localeCompare($(Q)),X=(U,Q)=>`${$(Q)}`.localeCompare($(U));return Y.slice().sort(H==="desc"?X:Z)};var E$=(Y)=>{if(!Y||Y.length===0)return"";let $=Y.toLowerCase();return $.substring(0,1).toUpperCase()+$.substring(1,$.length)};var F=(Y,$)=>{let H=Y?.replace(/([A-Z])+/g,E$).split(/(?=[A-Z])|[\.\-\s_]/).map((X)=>X.toLowerCase())??[];if(H.length===0)return"";if(H.length===1)return H[0];let Z=H.reduce((X,U)=>{return`${X}_${U.toLowerCase()}`});return $?.splitOnNumber===!1?Z:Z.replace(/([A-Za-z]{1}[0-9]{1})/,(X)=>`${X[0]}_${X[1]}`)};var z1=(Y)=>{let $=Y?.split(/[\.\-\s_]/).map((H)=>H.toLowerCase())??[];if($.length===0)return"";return $.map((H)=>H.charAt(0).toUpperCase()+H.slice(1)).join("")};var t1=(Y,$=" ")=>{if(!Y)return"";let H=$.replace(/[\W]{1}/g,"\\$&"),Z=new RegExp(`^[${H}]+|[${H}]+$`,"g");return Y.replace(Z,"")};var O$=V(i(),1);import{join as o7}from"path";import{existsSync as m7}from"fs";import{mkdir as s7,readdir as R$,rename as G$}from"fs/promises";import{dirname as I$,extname as t7,join as _}from"path";var A=()=>{return I$(Bun.fileURLToPath(import.meta.url))},m=()=>{let Y=process.cwd(),$=Y;while(!0){if(m7(_($,".elysiumrc")))return $;let H=I$($);if($===H)break;$=H}return Y},M1=async(Y,$)=>{let H=m();{let Z=_(H,"src","modules",Y);if(await s7(Z,{recursive:!0}),$)if($==="root"){let X=await R$(_(H,"src"));for(let U of X){if(["app.ts","env.ts","database","modules"].includes(U))continue;let Q=_(H,"src",U),J=_(Z,U==="main.module.ts"?`${Y}.module.ts`:U);await G$(Q,J)}}else{let X=_(H,"src","modules",$);await G$(X,Z)}}{let Z=await Bun.file(_(H,"package.json")).json();if(Z.imports=Z.imports??{},Z.imports[`#${Y}/*`]=`./src/modules/${Y}/*.ts`,$&&$!=="root")delete Z.imports[`#${$}/*`];await Bun.write(_(H,"package.json"),JSON.stringify(Z,null,2))}{let Z=await Bun.file(_(H,".elysiumrc")).json();if(Z.mono=!1,Z.modules=Z.modules??{},Z.modules[Y]=`./src/modules/${Y}`,$)delete Z.modules[$];await Bun.write(_(H,".elysiumrc"),JSON.stringify(Z,null,2))}if($){let Z=async(X)=>{let U=await R$(X,{withFileTypes:!0});for(let Q of U){let J=_(X,Q.name);if(Q.isDirectory())await Z(J);else if(t7(Q.name)===".ts"){let D=await Bun.file(J).text();if($==="root")D=D.replace(new RegExp(`(['"])#${$}/((?!(env|app|database(?:/|$))).*?)(['"])`,"g"),`$1#${Y}/$2$4`);else D=D.replace(new RegExp(`(['"])#${$}/`,"g"),`$1#${Y}/`);D=D.replace(new RegExp(`(['"])#${$}/main\\.module(['"])/g`,"g"),`$1#${Y}/${Y}.module$2`),D=D.replace(new RegExp(`(['"])#${$}/main\\.module\\.ts(['"])?/g`,"g"),`$1#${Y}/${Y}.module$2`),await Bun.write(J,D)}}};await Z(H)}};var E=async()=>{let Y=Bun.file(o7(m(),".elysiumrc"));if(!Y.exists())throw Error("Elysium config file not found.");return Y.json()};var M=async(Y)=>{let $=await E();if($.mono)return"./src";return $.modules[Y]};class C0 extends R{static command="make:command";static description="Creates a new command.";async run(){if(!this.command||!this.name)return this.setup();let Y=await E(),$={module:this.module,name:this.name,command:this.command,description:this.description};if(!$.module&&!Y.mono){let H=await P0.default({type:"select",name:"module",message:"Module:",choices:Object.keys(Y.modules??{}).map((Z)=>({title:Z,value:Z}))});$.module=H.module}return this.build($)}async setup(){let Y=await E(),H=await P0.default([{type(){return Y.mono?null:"select"},name:"module",message:"Module:",choices(){return Object.keys(Y.modules??{}).map((Z)=>({title:Z,value:Z}))}},{type:"text",name:"command",message:"Command Name:",initial:"user:say",validate(Z){if(Z.length<1)return"Command name cannot be empty";return!0}},{type:"text",name:"description",message:"Command Description:",initial:"Say something",validate(Z){if(Z.length<1)return"Command description cannot be empty";return!0}}],{onCancel:()=>{this.error("Operation cancelled."),process.exit(0)}});return H.name=z1(H.command.replaceAll(":","_")),this.build(H)}async build(Y){if(!Y.name){this.error("Operation cancelled.");return}if(!Y.name.endsWith("Command"))Y.name+="Command";let $=Bun.file(r7(A(),"stubs/command.stub")),H=O$.default(await $.text(),Y),Z=Y.module?await M(Y.module):"./src",X=F(Y.name.replace("Command","")),U=Bun.file(`${Z}/commands/${X}.command.ts`);await U.write(H),this.success(`Command ${this.bold(U.name)} created successfully.`)}}z([q1.arg({description:"The name of the command to create",type:o1.STRING}),L("design:type",String)],C0.prototype,"name",void 0),z([q1.arg({description:"The module where the command will be created",type:o1.STRING}),L("design:type",String)],C0.prototype,"module",void 0),z([q1.arg({description:"The command to create",type:o1.STRING}),L("design:type",String)],C0.prototype,"command",void 0),z([q1.arg({description:"The description of the command",type:o1.STRING}),L("design:type",String)],C0.prototype,"description",void 0),C0=z([q1.register()],C0);var j0=V(T(),1);import{join as a7}from"path";import{Command as g,CommandArgumentType as s}from"@elysiumjs/core";var F$=V(i(),1);class _0 extends R{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 E(),$={module:this.module,type:"http",scope:"SERVER",name:this.name,path:this.path,realm:this.realm??"realm1"};if(!$.module&&!Y.mono){let H=await j0.default({type:"select",name:"module",message:"Module:",choices:Object.keys(Y.modules??{}).map((Z)=>({title:Z,value:Z}))});$.module=H.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 E(),Z=await j0.default([{type(){return $.mono?null:"select"},name:"module",message:"Module:",choices(){return Object.keys($.modules??{}).map((X)=>({title:X,value:X}))}},{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:(X)=>{if(X.length<1)return"Controller name cannot be empty";return!0}},{type:"text",name:"path",message(X,U){return Y=U.type,U.type==="wamp"?"Controller URL":"Controller Path:"},initial(X,U){return U.type==="wamp"?"ws://localhost:8000":"/users"},validate(X){if(Y==="wamp")return X.match(/^wss?:\/\//)?!0:"The URL must start with ws:// or wss://";if(X[0]!=="/")return"The path must start with a slash (/)";return!0}},{type(X,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(X,U){return U.type==="wamp"?"text":null},name:"realm",message:"Controller Realm:",initial:"realm1",validate(X){if(X.length<1)return"Realm name cannot be empty";return!0}}],{onCancel:()=>{this.error("Operation cancelled."),process.exit(0)}});return this.build(Z)}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(a7(A(),`stubs/${Y.type}.controller.stub`)),H=F$.default(await $.text(),Y),Z=Y.module?await M(Y.module):"./src",X=F(Y.name.replace("Controller","")),U=Bun.file(`${Z}/controllers/${Y.type}/${X}.controller.ts`);await U.write(H),this.success(`Controller ${this.bold(U.name)} created successfully.`)}}z([g.arg({description:"The name of the controller to create",type:s.STRING}),L("design:type",String)],_0.prototype,"name",void 0),z([g.arg({description:"The module where the controller will be created",type:s.STRING}),L("design:type",String)],_0.prototype,"module",void 0),z([g.arg({description:"Whether to create a HTTP controller",type:s.BOOLEAN,default:!1}),L("design:type",Boolean)],_0.prototype,"http",void 0),z([g.arg({description:"Whether to create a WAMP controller",type:s.BOOLEAN,default:!1}),L("design:type",Boolean)],_0.prototype,"wamp",void 0),z([g.arg({description:"Whether to create a WebSocket controller",type:s.BOOLEAN,default:!1}),L("design:type",Boolean)],_0.prototype,"ws",void 0),z([g.arg({description:"Whether to create a SERVER scope controller",type:s.BOOLEAN,default:!1}),L("design:type",Boolean)],_0.prototype,"server",void 0),z([g.arg({description:"Whether to create a REQUEST scope controller",type:s.BOOLEAN,default:!1}),L("design:type",Boolean)],_0.prototype,"request",void 0),z([g.arg({description:"The path or URL of the controller",type:s.STRING}),L("design:type",String)],_0.prototype,"path",void 0),z([g.arg({description:"The realm of the controller (only applicable to WAMP controllers)",type:s.STRING}),L("design:type",String)],_0.prototype,"realm",void 0),_0=z([g.register()],_0);var k0=V(T(),1);import{join as e7}from"path";import{Command as N1,CommandArgumentType as r1}from"@elysiumjs/core";var V$=V(i(),1);class h0 extends R{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 E(),$={module:this.module,name:this.name,alias:this.alias,queue:this.queue??"default"};if(!$.module&&!Y.mono){let H=await k0.default({type:"select",name:"module",message:"Module:",choices:Object.keys(Y.modules??{}).map((Z)=>({title:Z,value:Z}))});$.module=H.module}return this.build($)}async setup(){let Y=await E(),H=await k0.default([{type(){return Y.mono?null:"select"},name:"module",message:"Module:",choices(){return Object.keys(Y.modules??{}).map((Z)=>({title:Z,value:Z}))}},{type:"text",name:"name",message:"Job Name:",initial:"SendEmailJob",validate(Z){if(Z.length<1)return"Job name cannot be empty";return!0}},{type:"text",name:"alias",message:"Job Alias:",initial(Z,X){return X.name},validate(Z){if(Z.length<1)return"Job alias cannot be empty";return!0}},{type:"text",name:"queue",message:"Job Queue:",initial:"default"}],{onCancel:()=>{this.error("Operation cancelled."),process.exit(0)}});return this.build(H)}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(e7(A(),"stubs/job.stub")),H=V$.default(await $.text(),Y),Z=Y.module?await M(Y.module):"./src",X=F(Y.name.replace("Job","")),U=Bun.file(`${Z}/jobs/${X}.job.ts`);await U.write(H),this.success(`Job ${this.bold(U.name)} created successfully.`)}}z([N1.arg({description:"The name of the job to create",type:r1.STRING}),L("design:type",String)],h0.prototype,"name",void 0),z([N1.arg({description:"The module where the job will be created",type:r1.STRING}),L("design:type",String)],h0.prototype,"module",void 0),z([N1.arg({description:"The alias of the job to create",type:r1.STRING}),L("design:type",String)],h0.prototype,"alias",void 0),z([N1.arg({description:"The name of the queue where the job will be dispatched",type:r1.STRING,default:"default"}),L("design:type",String)],h0.prototype,"queue",void 0),h0=z([N1.register()],h0);var b0=V(T(),1);import{join as YU}from"path";import{Command as x0,CommandArgumentType as A$}from"@elysiumjs/core";var M$=V(i(),1);class f0 extends R{static command="make:middleware";static description="Creates a new middleware.";async run(){if(!this.name)return this.setup();let Y=await E(),$={module:this.module,name:this.name};if(!$.module&&!Y.mono){let H=await b0.default({type:"select",name:"module",message:"Module:",choices:Object.keys(Y.modules??{}).map((Z)=>({title:Z,value:Z}))});$.module=H.module}return this.build($)}async setup(){let Y=await E(),H=await b0.default([{type(){return Y.mono?null:"select"},name:"module",message:"Module:",choices(){return Object.keys(Y.modules??{}).map((Z)=>({title:Z,value:Z}))}},{type:"text",name:"name",message:"Middleware Name:",initial:"AuthMiddleware",validate(Z){if(Z.length<1)return"Middleware name cannot be empty";return!0}}],{onCancel:()=>{this.error("Operation cancelled."),process.exit(0)}});return this.build(H)}async build(Y){if(!Y.name){this.error("Operation cancelled.");return}if(!Y.name.endsWith("Middleware"))Y.name+="Middleware";let $=Bun.file(YU(A(),"stubs/middleware.stub")),H=M$.default(await $.text(),Y),Z=Y.module?await M(Y.module):"./src",X=F(Y.name.replace("Middleware","")),U=Bun.file(`${Z}/middlewares/${X}.middleware.ts`);await U.write(H),this.success(`Middleware ${this.bold(U.name)} created successfully.`)}}z([x0.arg({description:"The name of the middleware to create",type:A$.STRING}),L("design:type",String)],f0.prototype,"name",void 0),z([x0.arg({description:"The module where the middleware will be created",type:A$.STRING}),L("design:type",String)],f0.prototype,"module",void 0),f0=z([x0.register()],f0);var w0=V(T(),1);import{join as $U}from"path";import{Command as T1,CommandArgumentType as a1}from"@elysiumjs/core";var q$=V(i(),1);class g0 extends R{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 E(),$={module:this.module,table:this.tableName,name:this.name,supportTenancy:this.supportTenancy};if(!$.module&&!Y.mono){let H=await w0.default({type:"select",name:"module",message:"Module:",choices:Object.keys(Y.modules??{}).map((Z)=>({title:Z,value:Z}))},{onCancel:()=>process.exit(1)});$.module=H.module}if(!$.name)$.name=t1(z1($.table),"s");return $.canonicalName=$.name,this.build($)}async setup(){let Y=await E(),H=await w0.default([{type(){return Y.mono?null:"select"},name:"module",message:"Module:",choices(){return Object.keys(Y.modules??{}).map((Z)=>({title:Z,value:Z}))}},{type:"text",name:"table",message:"Table Name:",initial:"users",validate(Z){if(Z.length<1)return"Table name cannot be empty";return!0}},{type:"text",name:"name",message:"Model Name:",initial(Z,X){return t1(z1(X.table),"s")},validate(Z){if(Z.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."}]}],{onCancel:()=>{this.error("Operation cancelled."),process.exit(0)}});return this.build(H)}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($U(A(),"stubs/model.stub")),H=q$.default(await $.text(),Y),Z=Y.module?await M(Y.module):"./src",X=F(Y.name.replace("Model","")),U=Bun.file(`${Z}/models/${X}.model.ts`);await U.write(H),this.success(`Model ${this.bold(U.name)} created successfully.`)}}z([T1.arg({description:"The name of the model to create",type:a1.STRING}),L("design:type",String)],g0.prototype,"name",void 0),z([T1.arg({description:"The module where the model will be created",type:a1.STRING}),L("design:type",String)],g0.prototype,"module",void 0),z([T1.arg({name:"table",description:"The name of the table wrapped by the model",type:a1.STRING}),L("design:type",String)],g0.prototype,"tableName",void 0),z([T1.arg({name:"support-tenancy",description:"Support tenancy",type:a1.BOOLEAN,default:!1}),L("design:type",Boolean)],g0.prototype,"supportTenancy",void 0),g0=z([T1.register()],g0);var v0=V(T(),1);import{join as HU}from"path";import{Command as U1,CommandArgumentType as K1}from"@elysiumjs/core";var N$=V(i(),1);class y0 extends R{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 E(),$={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 H=await v0.default({type:"select",name:"module",message:"Module:",choices:Object.keys(Y.modules??{}).map((Z)=>({title:Z,value:Z}))});$.module=H.module}return this.build($)}async setup(){let Y=await E(),H=await v0.default([{type(){return Y.mono?null:"select"},name:"module",message:"Module:",choices(){return Object.keys(Y.modules??{}).map((Z)=>({title:Z,value:Z}))}},{type:"text",name:"name",message:"Repository Name:",initial:"UserRepository",validate(Z){if(Z.length<1)return"Repository name cannot be empty";return!0}},{type:"text",name:"model",message:"Model Name:",initial:"UserModel",validate(Z){if(Z.length<1)return"Model name cannot be empty";return!0}},{type:"text",name:"alias",message:"Repository Alias:",initial(Z,X){return X.name},validate(Z){if(Z.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."}]}],{onCancel:()=>{this.error("Operation cancelled."),process.exit(0)}});return this.build(H)}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(HU(A(),"stubs/repository.stub")),H=N$.default(await $.text(),{...Y,module:Y.module??"root",model_name:F(Y.model.replace("Model",""))}),Z=Y.module?await M(Y.module):"./src",X=F(Y.name.replace("Repository","")),U=Bun.file(`${Z}/repositories/${X}.repository.ts`);await U.write(H),this.success(`Repository ${this.bold(U.name)} created successfully.`)}}z([U1.arg({description:"The name of the repository to create",type:K1.STRING}),L("design:type",String)],y0.prototype,"name",void 0),z([U1.arg({description:"The module where the repository will be created",type:K1.STRING}),L("design:type",String)],y0.prototype,"module",void 0),z([U1.arg({description:"The alias of the repository to create",type:K1.STRING}),L("design:type",String)],y0.prototype,"alias",void 0),z([U1.arg({description:"The model used by the repository",type:K1.STRING}),L("design:type",String)],y0.prototype,"model",void 0),z([U1.arg({description:"Create a factory repository",type:K1.BOOLEAN,default:!1}),L("design:type",Boolean)],y0.prototype,"factory",void 0),z([U1.arg({description:"Create a singleton repository",type:K1.BOOLEAN,default:!1}),L("design:type",Boolean)],y0.prototype,"singleton",void 0),y0=z([U1.register()],y0);var d0=V(T(),1);import{join as ZU}from"path";import{Command as W1,CommandArgumentType as P1}from"@elysiumjs/core";var T$=V(i(),1);class u0 extends R{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 E(),$={module:this.module,name:this.name,alias:this.alias,scope:this.factory?"FACTORY":this.singleton?"SINGLETON":"SINGLETON"};if(!$.module&&!Y.mono){let H=await d0.default({type:"select",name:"module",message:"Module:",choices:Object.keys(Y.modules??{}).map((Z)=>({title:Z,value:Z}))});$.module=H.module}return this.build($)}async setup(){let Y=await E(),H=await d0.default([{type(){return Y.mono?null:"select"},name:"module",message:"Module:",choices(){return Object.keys(Y.modules??{}).map((Z)=>({title:Z,value:Z}))}},{type:"text",name:"name",message:"Service Name:",initial:"UserService",validate(Z){if(Z.length<1)return"Service name cannot be empty";return!0}},{type:"text",name:"alias",message:"Service Alias:",initial(Z,X){return X.name},validate(Z){if(Z.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."}]}],{onCancel:()=>{this.error("Operation cancelled."),process.exit(0)}});return this.build(H)}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(ZU(A(),"stubs/service.stub")),H=T$.default(await $.text(),Y),Z=Y.module?await M(Y.module):"./src",X=F(Y.name.replace("Service","")),U=Bun.file(`${Z}/services/${X}.service.ts`);await U.write(H),this.success(`Service ${this.bold(U.name)} created successfully.`)}}z([W1.arg({description:"The name of the service to create",type:P1.STRING}),L("design:type",String)],u0.prototype,"name",void 0),z([W1.arg({description:"The module where the service will be created",type:P1.STRING}),L("design:type",String)],u0.prototype,"module",void 0),z([W1.arg({description:"The alias of the service to create",type:P1.STRING}),L("design:type",String)],u0.prototype,"alias",void 0),z([W1.arg({description:"Create a factory service",type:P1.BOOLEAN,default:!1}),L("design:type",Boolean)],u0.prototype,"factory",void 0),z([W1.arg({description:"Create a singleton service",type:P1.BOOLEAN,default:!1}),L("design:type",Boolean)],u0.prototype,"singleton",void 0),u0=z([W1.register()],u0);var l0=V(T(),1);import{join as UU}from"path";import{Command as c0,CommandArgumentType as P$}from"@elysiumjs/core";var C$=V(i(),1);class p0 extends R{static command="make:validator";static description="Creates a new validator.";async run(){if(!this.name)return this.setup();let Y=await E(),$={module:this.module,name:this.name};if(!$.module&&!Y.mono){let H=await l0.default({type:"select",name:"module",message:"Module:",choices:Object.keys(Y.modules??{}).map((Z)=>({title:Z,value:Z}))});$.module=H.module}return this.build($)}async setup(){let Y=await E(),H=await l0.default([{type(){return Y.mono?null:"select"},name:"module",message:"Module:",choices(){return Object.keys(Y.modules??{}).map((Z)=>({title:Z,value:Z}))}},{type:"text",name:"name",message:"Validator Name:",initial:"LoginValidator",validate(Z){if(Z.length<1)return"Validator name cannot be empty";return!0}}],{onCancel:()=>{this.error("Operation cancelled."),process.exit(0)}});return this.build(H)}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(UU(A(),"stubs/validator.stub")),H=C$.default(await $.text(),Y),Z=Y.module?await M(Y.module):"./src",X=F(Y.name.replace("Validator","")),U=Bun.file(`${Z}/validators/${X}.validator.ts`);await U.write(H),this.success(`Validator ${this.bold(U.name)} created successfully.`)}}z([c0.arg({description:"The name of the validator to create",type:P$.STRING}),L("design:type",String)],p0.prototype,"name",void 0),z([c0.arg({description:"The module where the validator will be created",type:P$.STRING}),L("design:type",String)],p0.prototype,"module",void 0),p0=z([c0.register()],p0);var _$=V(T(),1);import{exists as XU}from"fs/promises";import{Command as j$,CommandArgumentType as QU}from"@elysiumjs/core";class n0 extends R{static command="migration:generate";static description="Generates migration files.";async run(){if(!this.name){let Z=await _$.default([{type:"text",name:"name",message:"Migration Name:",initial:"create_users_table",validate(X){if(X.length<1)return"Migration name cannot be empty";return!0}}],{onCancel:()=>{this.error("Operation cancelled."),process.exit(0)}});this.name=Z.name}let Y=m(),$=`${Y}/src/database/schemas`;if(await XU(`${Y}/src/database/schema.ts`))$=`${Y}/src/database/schema.ts`;await Bun.$`bunx --bun drizzle-kit generate --dialect postgresql --schema ${$} --out ${Y}/src/database/migrations --prefix timestamp --name ${this.name}`;let H=new Bun.Glob(`${Y}/src/database/migrations/**/*.sql`).scan();for await(let Z of H){let X=Bun.file(Z),U=await X.text();await X.write(U.replace(/"public"\./gm,""))}}}z([j$.arg({description:"The name of the migration to create",type:QU.STRING}),L("design:type",String)],n0.prototype,"name",void 0),n0=z([j$.register()],n0);var x$=V(T(),1);import{basename as k$}from"path";import{Command as e1,CommandArgumentType as i0,Database as h$}from"@elysiumjs/core";class m0 extends R{constructor(){super(...arguments);this.tenant="";this.connection="default";this.fresh=!1}static command="migration:run";static description="Generates migration files.";async run(){if(!h$.connectionExists(this.connection))return this.error(`Connection ${this.bold(this.connection)} does not exist.`),process.exit(1);let Y=h$.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:H}]=await $`SELECT EXISTS (
|
|
98
|
+
`),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(H$.hide);else this.out.write(w7(this.outputText,this.out.columns));super.render(),this.outputText=[$$.symbol(this.done,this.aborted),Y$.bold(this.msg),$$.delimiter(this.done),this.done?this.value?this.yesMsg:this.noMsg:Y$.gray(this.initialValue?this.yesOption:this.noOption)].join(" "),this.out.write(g7.line+H$.to(0)+this.outputText)}}U$.exports=Z$});var J$=K((q5,Q$)=>{Q$.exports={TextPrompt:c9(),SelectPrompt:m9(),TogglePrompt:a9(),DatePrompt:xY(),NumberPrompt:vY(),MultiselectPrompt:A0(),AutocompletePrompt:tY(),AutocompleteMultiselectPrompt:eY(),ConfirmPrompt:X$()}});var z$=K((D$)=>{var N=D$,v7=J$(),t1=(Y)=>Y;function w(Y,$,H={}){return new Promise((Z,X)=>{let U=new v7[Y]($),Q=H.onAbort||t1,J=H.onSubmit||t1,D=H.onExit||t1;U.on("state",$.onState||t1),U.on("submit",(W)=>Z(J(W))),U.on("exit",(W)=>Z(D(W))),U.on("abort",(W)=>X(Q(W)))})}N.text=(Y)=>w("TextPrompt",Y);N.password=(Y)=>{return Y.style="password",N.text(Y)};N.invisible=(Y)=>{return Y.style="invisible",N.text(Y)};N.number=(Y)=>w("NumberPrompt",Y);N.date=(Y)=>w("DatePrompt",Y);N.confirm=(Y)=>w("ConfirmPrompt",Y);N.list=(Y)=>{let $=Y.separator||",";return w("TextPrompt",Y,{onSubmit:(H)=>H.split($).map((Z)=>Z.trim())})};N.toggle=(Y)=>w("TogglePrompt",Y);N.select=(Y)=>w("SelectPrompt",Y);N.multiselect=(Y)=>{Y.choices=[].concat(Y.choices||[]);let $=(H)=>H.filter((Z)=>Z.selected).map((Z)=>Z.value);return w("MultiselectPrompt",Y,{onAbort:$,onSubmit:$})};N.autocompleteMultiselect=(Y)=>{Y.choices=[].concat(Y.choices||[]);let $=(H)=>H.filter((Z)=>Z.selected).map((Z)=>Z.value);return w("AutocompleteMultiselectPrompt",Y,{onAbort:$,onSubmit:$})};var y7=(Y,$)=>Promise.resolve($.filter((H)=>H.title.slice(0,Y.length).toLowerCase()===Y.toLowerCase()));N.autocomplete=(Y)=>{return Y.suggest=Y.suggest||y7,Y.choices=[].concat(Y.choices||[]),w("AutocompletePrompt",Y)}});var L$=K((T5,W$)=>{var N0=z$(),d7=["suggest","format","onState","validate","onRender","type"],K$=()=>{};async function e(Y=[],{onSubmit:$=K$,onCancel:H=K$}={}){let Z={},X=e._override||{};Y=[].concat(Y);let U,Q,J,D,W,Y1,$1=async(G,P,C1=!1)=>{if(!C1&&G.validate&&G.validate(P)!==!0)return;return G.format?await G.format(P,Z):P};for(Q of Y){if({name:D,type:W}=Q,typeof W==="function")W=await W(U,{...Z},Q),Q.type=W;if(!W)continue;for(let G in Q){if(d7.includes(G))continue;let P=Q[G];Q[G]=typeof P==="function"?await P(U,{...Z},Y1):P}if(Y1=Q,typeof Q.message!=="string")throw Error("prompt message is required");if({name:D,type:W}=Q,N0[W]===void 0)throw Error(`prompt type (${W}) is not defined`);if(X[Q.name]!==void 0){if(U=await $1(Q,X[Q.name]),U!==void 0){Z[D]=U;continue}}try{U=e._injected?u7(e._injected,Q.initial):await N0[W](Q),Z[D]=U=await $1(Q,U,!0),J=await $(Q,U,Z)}catch(G){J=!await H(Q,Z)}if(J)return Z}return Z}function u7(Y,$){let H=Y.shift();if(H instanceof Error)throw H;return H===void 0?$:H}function c7(Y){e._injected=(e._injected||[]).concat(Y)}function l7(Y){e._override=Object.assign({},Y)}W$.exports=Object.assign(e,{prompt:e,prompts:N0,inject:c7,override:l7})});var T=K((P5,B$)=>{function p7(Y){Y=(Array.isArray(Y)?Y:Y.split(".")).map(Number);let $=0,H=process.versions.node.split(".").map(Number);for(;$<Y.length;$++){if(H[$]>Y[$])return!1;if(Y[$]>H[$])return!0}return!1}B$.exports=p7("8.6.0")?F9():L$()});var i=K((W8,S$)=>{var n7=/\{([0-9a-zA-Z_]+)\}/g;S$.exports=i7;function i7(Y){var $;if(arguments.length===2&&typeof arguments[1]==="object")$=arguments[1];else{$=Array(arguments.length-1);for(var H=1;H<arguments.length;++H)$[H-1]=arguments[H]}if(!$||!$.hasOwnProperty)$={};return Y.replace(n7,function(X,U,Q){var J;if(Y[Q-1]==="{"&&Y[Q+X.length]==="}")return U;else{if(J=$.hasOwnProperty(U)?$[U]:null,J===null||J===void 0)return"";return J}})}});import"reflect-metadata";import"@elysiumjs/core";import{Command as u$}from"@elysiumjs/core";class R extends u${static dev=!0}var P0=V(T(),1);import{join as r7}from"path";import{Command as q1,CommandArgumentType as o1}from"@elysiumjs/core";var T0=(Y,$,H="asc")=>{if(!Y)return[];let Z=(U,Q)=>`${$(U)}`.localeCompare($(Q)),X=(U,Q)=>`${$(Q)}`.localeCompare($(U));return Y.slice().sort(H==="desc"?X:Z)};var E$=(Y)=>{if(!Y||Y.length===0)return"";let $=Y.toLowerCase();return $.substring(0,1).toUpperCase()+$.substring(1,$.length)};var F=(Y,$)=>{let H=Y?.replace(/([A-Z])+/g,E$).split(/(?=[A-Z])|[\.\-\s_]/).map((X)=>X.toLowerCase())??[];if(H.length===0)return"";if(H.length===1)return H[0];let Z=H.reduce((X,U)=>{return`${X}_${U.toLowerCase()}`});return $?.splitOnNumber===!1?Z:Z.replace(/([A-Za-z]{1}[0-9]{1})/,(X)=>`${X[0]}_${X[1]}`)};var z1=(Y)=>{let $=Y?.split(/[\.\-\s_]/).map((H)=>H.toLowerCase())??[];if($.length===0)return"";return $.map((H)=>H.charAt(0).toUpperCase()+H.slice(1)).join("")};var s1=(Y,$=" ")=>{if(!Y)return"";let H=$.replace(/[\W]{1}/g,"\\$&"),Z=new RegExp(`^[${H}]+|[${H}]+$`,"g");return Y.replace(Z,"")};var O$=V(i(),1);import{join as o7}from"path";import{existsSync as m7}from"fs";import{mkdir as t7,readdir as R$,rename as G$}from"fs/promises";import{dirname as I$,extname as s7,join as _}from"path";var A=()=>{return I$(Bun.fileURLToPath(import.meta.url))},m=()=>{let Y=process.cwd(),$=Y;while(!0){if(m7(_($,".elysiumrc")))return $;let H=I$($);if($===H)break;$=H}return Y},M1=async(Y,$)=>{let H=m();{let Z=_(H,"src","modules",Y);if(await t7(Z,{recursive:!0}),$)if($==="root"){let X=await R$(_(H,"src"));for(let U of X){if(["app.ts","env.ts","database","modules"].includes(U))continue;let Q=_(H,"src",U),J=_(Z,U==="main.module.ts"?`${Y}.module.ts`:U);await G$(Q,J)}}else{let X=_(H,"src","modules",$);await G$(X,Z)}}{let Z=await Bun.file(_(H,"package.json")).json();if(Z.imports=Z.imports??{},Z.imports[`#${Y}/*`]=`./src/modules/${Y}/*.ts`,$&&$!=="root")delete Z.imports[`#${$}/*`];await Bun.write(_(H,"package.json"),JSON.stringify(Z,null,2))}{let Z=await Bun.file(_(H,".elysiumrc")).json();if(Z.mono=!1,Z.modules=Z.modules??{},Z.modules[Y]=`./src/modules/${Y}`,$)delete Z.modules[$];await Bun.write(_(H,".elysiumrc"),JSON.stringify(Z,null,2))}if($){let Z=async(X)=>{let U=await R$(X,{withFileTypes:!0});for(let Q of U){let J=_(X,Q.name);if(Q.isDirectory())await Z(J);else if(s7(Q.name)===".ts"){let D=await Bun.file(J).text();if($==="root")D=D.replace(new RegExp(`(['"])#${$}/((?!(env|app|database(?:/|$))).*?)(['"])`,"g"),`$1#${Y}/$2$4`);else D=D.replace(new RegExp(`(['"])#${$}/`,"g"),`$1#${Y}/`);D=D.replace(new RegExp(`(['"])#${$}/main\\.module(['"])/g`,"g"),`$1#${Y}/${Y}.module$2`),D=D.replace(new RegExp(`(['"])#${$}/main\\.module\\.ts(['"])?/g`,"g"),`$1#${Y}/${Y}.module$2`),await Bun.write(J,D)}}};await Z(H)}};var E=async()=>{let Y=Bun.file(o7(m(),".elysiumrc"));if(!Y.exists())throw Error("Elysium config file not found.");return Y.json()};var M=async(Y)=>{let $=await E();if($.mono)return"./src";return $.modules[Y]};class C0 extends R{static command="make:command";static description="Creates a new command.";async run(){if(!this.command||!this.name)return this.setup();let Y=await E(),$={module:this.module,name:this.name,command:this.command,description:this.description};if(!$.module&&!Y.mono){let H=await P0.default({type:"select",name:"module",message:"Module:",choices:Object.keys(Y.modules??{}).map((Z)=>({title:Z,value:Z}))});$.module=H.module}return this.build($)}async setup(){let Y=await E(),H=await P0.default([{type(){return Y.mono?null:"select"},name:"module",message:"Module:",choices(){return Object.keys(Y.modules??{}).map((Z)=>({title:Z,value:Z}))}},{type:"text",name:"command",message:"Command Name:",initial:"user:say",validate(Z){if(Z.length<1)return"Command name cannot be empty";return!0}},{type:"text",name:"description",message:"Command Description:",initial:"Say something",validate(Z){if(Z.length<1)return"Command description cannot be empty";return!0}}],{onCancel:()=>{this.error("Operation cancelled."),process.exit(0)}});return H.name=z1(H.command.replaceAll(":","_")),this.build(H)}async build(Y){if(!Y.name){this.error("Operation cancelled.");return}if(!Y.name.endsWith("Command"))Y.name+="Command";let $=Bun.file(r7(A(),"stubs/command.stub")),H=O$.default(await $.text(),Y),Z=Y.module?await M(Y.module):"./src",X=F(Y.name.replace("Command","")),U=Bun.file(`${Z}/commands/${X}.command.ts`);await U.write(H),this.success(`Command ${this.bold(U.name)} created successfully.`)}}z([q1.arg({description:"The name of the command to create",type:o1.STRING}),L("design:type",String)],C0.prototype,"name",void 0),z([q1.arg({description:"The module where the command will be created",type:o1.STRING}),L("design:type",String)],C0.prototype,"module",void 0),z([q1.arg({description:"The command to create",type:o1.STRING}),L("design:type",String)],C0.prototype,"command",void 0),z([q1.arg({description:"The description of the command",type:o1.STRING}),L("design:type",String)],C0.prototype,"description",void 0),C0=z([q1.register()],C0);var j0=V(T(),1);import{join as a7}from"path";import{Command as g,CommandArgumentType as t}from"@elysiumjs/core";var F$=V(i(),1);class _0 extends R{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 E(),$={module:this.module,type:"http",scope:"SERVER",name:this.name,path:this.path,realm:this.realm??"realm1"};if(!$.module&&!Y.mono){let H=await j0.default({type:"select",name:"module",message:"Module:",choices:Object.keys(Y.modules??{}).map((Z)=>({title:Z,value:Z}))});$.module=H.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 E(),Z=await j0.default([{type(){return $.mono?null:"select"},name:"module",message:"Module:",choices(){return Object.keys($.modules??{}).map((X)=>({title:X,value:X}))}},{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:(X)=>{if(X.length<1)return"Controller name cannot be empty";return!0}},{type:"text",name:"path",message(X,U){return Y=U.type,U.type==="wamp"?"Controller URL":"Controller Path:"},initial(X,U){return U.type==="wamp"?"ws://localhost:8000":"/users"},validate(X){if(Y==="wamp")return X.match(/^wss?:\/\//)?!0:"The URL must start with ws:// or wss://";if(X[0]!=="/")return"The path must start with a slash (/)";return!0}},{type(X,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(X,U){return U.type==="wamp"?"text":null},name:"realm",message:"Controller Realm:",initial:"realm1",validate(X){if(X.length<1)return"Realm name cannot be empty";return!0}}],{onCancel:()=>{this.error("Operation cancelled."),process.exit(0)}});return this.build(Z)}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(a7(A(),`stubs/${Y.type}.controller.stub`)),H=F$.default(await $.text(),Y),Z=Y.module?await M(Y.module):"./src",X=F(Y.name.replace("Controller","")),U=Bun.file(`${Z}/controllers/${Y.type}/${X}.controller.ts`);await U.write(H),this.success(`Controller ${this.bold(U.name)} created successfully.`)}}z([g.arg({description:"The name of the controller to create",type:t.STRING}),L("design:type",String)],_0.prototype,"name",void 0),z([g.arg({description:"The module where the controller will be created",type:t.STRING}),L("design:type",String)],_0.prototype,"module",void 0),z([g.arg({description:"Whether to create a HTTP controller",type:t.BOOLEAN,default:!1}),L("design:type",Boolean)],_0.prototype,"http",void 0),z([g.arg({description:"Whether to create a WAMP controller",type:t.BOOLEAN,default:!1}),L("design:type",Boolean)],_0.prototype,"wamp",void 0),z([g.arg({description:"Whether to create a WebSocket controller",type:t.BOOLEAN,default:!1}),L("design:type",Boolean)],_0.prototype,"ws",void 0),z([g.arg({description:"Whether to create a SERVER scope controller",type:t.BOOLEAN,default:!1}),L("design:type",Boolean)],_0.prototype,"server",void 0),z([g.arg({description:"Whether to create a REQUEST scope controller",type:t.BOOLEAN,default:!1}),L("design:type",Boolean)],_0.prototype,"request",void 0),z([g.arg({description:"The path or URL of the controller",type:t.STRING}),L("design:type",String)],_0.prototype,"path",void 0),z([g.arg({description:"The realm of the controller (only applicable to WAMP controllers)",type:t.STRING}),L("design:type",String)],_0.prototype,"realm",void 0),_0=z([g.register()],_0);var k0=V(T(),1);import{join as e7}from"path";import{Command as N1,CommandArgumentType as r1}from"@elysiumjs/core";var V$=V(i(),1);class h0 extends R{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 E(),$={module:this.module,name:this.name,alias:this.alias,queue:this.queue??"default"};if(!$.module&&!Y.mono){let H=await k0.default({type:"select",name:"module",message:"Module:",choices:Object.keys(Y.modules??{}).map((Z)=>({title:Z,value:Z}))});$.module=H.module}return this.build($)}async setup(){let Y=await E(),H=await k0.default([{type(){return Y.mono?null:"select"},name:"module",message:"Module:",choices(){return Object.keys(Y.modules??{}).map((Z)=>({title:Z,value:Z}))}},{type:"text",name:"name",message:"Job Name:",initial:"SendEmailJob",validate(Z){if(Z.length<1)return"Job name cannot be empty";return!0}},{type:"text",name:"alias",message:"Job Alias:",initial(Z,X){return X.name},validate(Z){if(Z.length<1)return"Job alias cannot be empty";return!0}},{type:"text",name:"queue",message:"Job Queue:",initial:"default"}],{onCancel:()=>{this.error("Operation cancelled."),process.exit(0)}});return this.build(H)}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(e7(A(),"stubs/job.stub")),H=V$.default(await $.text(),Y),Z=Y.module?await M(Y.module):"./src",X=F(Y.name.replace("Job","")),U=Bun.file(`${Z}/jobs/${X}.job.ts`);await U.write(H),this.success(`Job ${this.bold(U.name)} created successfully.`)}}z([N1.arg({description:"The name of the job to create",type:r1.STRING}),L("design:type",String)],h0.prototype,"name",void 0),z([N1.arg({description:"The module where the job will be created",type:r1.STRING}),L("design:type",String)],h0.prototype,"module",void 0),z([N1.arg({description:"The alias of the job to create",type:r1.STRING}),L("design:type",String)],h0.prototype,"alias",void 0),z([N1.arg({description:"The name of the queue where the job will be dispatched",type:r1.STRING,default:"default"}),L("design:type",String)],h0.prototype,"queue",void 0),h0=z([N1.register()],h0);var b0=V(T(),1);import{join as YU}from"path";import{Command as x0,CommandArgumentType as A$}from"@elysiumjs/core";var M$=V(i(),1);class f0 extends R{static command="make:middleware";static description="Creates a new middleware.";async run(){if(!this.name)return this.setup();let Y=await E(),$={module:this.module,name:this.name};if(!$.module&&!Y.mono){let H=await b0.default({type:"select",name:"module",message:"Module:",choices:Object.keys(Y.modules??{}).map((Z)=>({title:Z,value:Z}))});$.module=H.module}return this.build($)}async setup(){let Y=await E(),H=await b0.default([{type(){return Y.mono?null:"select"},name:"module",message:"Module:",choices(){return Object.keys(Y.modules??{}).map((Z)=>({title:Z,value:Z}))}},{type:"text",name:"name",message:"Middleware Name:",initial:"AuthMiddleware",validate(Z){if(Z.length<1)return"Middleware name cannot be empty";return!0}}],{onCancel:()=>{this.error("Operation cancelled."),process.exit(0)}});return this.build(H)}async build(Y){if(!Y.name){this.error("Operation cancelled.");return}if(!Y.name.endsWith("Middleware"))Y.name+="Middleware";let $=Bun.file(YU(A(),"stubs/middleware.stub")),H=M$.default(await $.text(),Y),Z=Y.module?await M(Y.module):"./src",X=F(Y.name.replace("Middleware","")),U=Bun.file(`${Z}/middlewares/${X}.middleware.ts`);await U.write(H),this.success(`Middleware ${this.bold(U.name)} created successfully.`)}}z([x0.arg({description:"The name of the middleware to create",type:A$.STRING}),L("design:type",String)],f0.prototype,"name",void 0),z([x0.arg({description:"The module where the middleware will be created",type:A$.STRING}),L("design:type",String)],f0.prototype,"module",void 0),f0=z([x0.register()],f0);var w0=V(T(),1);import{join as $U}from"path";import{Command as T1,CommandArgumentType as a1}from"@elysiumjs/core";var q$=V(i(),1);class g0 extends R{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 E(),$={module:this.module,table:this.tableName,name:this.name,supportTenancy:this.supportTenancy};if(!$.module&&!Y.mono){let H=await w0.default({type:"select",name:"module",message:"Module:",choices:Object.keys(Y.modules??{}).map((Z)=>({title:Z,value:Z}))},{onCancel:()=>process.exit(1)});$.module=H.module}if(!$.name)$.name=s1(z1($.table),"s");return $.canonicalName=$.name,this.build($)}async setup(){let Y=await E(),H=await w0.default([{type(){return Y.mono?null:"select"},name:"module",message:"Module:",choices(){return Object.keys(Y.modules??{}).map((Z)=>({title:Z,value:Z}))}},{type:"text",name:"table",message:"Table Name:",initial:"users",validate(Z){if(Z.length<1)return"Table name cannot be empty";return!0}},{type:"text",name:"name",message:"Model Name:",initial(Z,X){return s1(z1(X.table),"s")},validate(Z){if(Z.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."}]}],{onCancel:()=>{this.error("Operation cancelled."),process.exit(0)}});return this.build(H)}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($U(A(),"stubs/model.stub")),H=q$.default(await $.text(),Y),Z=Y.module?await M(Y.module):"./src",X=F(Y.name.replace("Model","")),U=Bun.file(`${Z}/models/${X}.model.ts`);await U.write(H),this.success(`Model ${this.bold(U.name)} created successfully.`)}}z([T1.arg({description:"The name of the model to create",type:a1.STRING}),L("design:type",String)],g0.prototype,"name",void 0),z([T1.arg({description:"The module where the model will be created",type:a1.STRING}),L("design:type",String)],g0.prototype,"module",void 0),z([T1.arg({name:"table",description:"The name of the table wrapped by the model",type:a1.STRING}),L("design:type",String)],g0.prototype,"tableName",void 0),z([T1.arg({name:"support-tenancy",description:"Support tenancy",type:a1.BOOLEAN,default:!1}),L("design:type",Boolean)],g0.prototype,"supportTenancy",void 0),g0=z([T1.register()],g0);var v0=V(T(),1);import{join as HU}from"path";import{Command as U1,CommandArgumentType as K1}from"@elysiumjs/core";var N$=V(i(),1);class y0 extends R{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 E(),$={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 H=await v0.default({type:"select",name:"module",message:"Module:",choices:Object.keys(Y.modules??{}).map((Z)=>({title:Z,value:Z}))});$.module=H.module}return this.build($)}async setup(){let Y=await E(),H=await v0.default([{type(){return Y.mono?null:"select"},name:"module",message:"Module:",choices(){return Object.keys(Y.modules??{}).map((Z)=>({title:Z,value:Z}))}},{type:"text",name:"name",message:"Repository Name:",initial:"UserRepository",validate(Z){if(Z.length<1)return"Repository name cannot be empty";return!0}},{type:"text",name:"model",message:"Model Name:",initial:"UserModel",validate(Z){if(Z.length<1)return"Model name cannot be empty";return!0}},{type:"text",name:"alias",message:"Repository Alias:",initial(Z,X){return X.name},validate(Z){if(Z.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."}]}],{onCancel:()=>{this.error("Operation cancelled."),process.exit(0)}});return this.build(H)}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(HU(A(),"stubs/repository.stub")),H=N$.default(await $.text(),{...Y,module:Y.module??"root",model_name:F(Y.model.replace("Model",""))}),Z=Y.module?await M(Y.module):"./src",X=F(Y.name.replace("Repository","")),U=Bun.file(`${Z}/repositories/${X}.repository.ts`);await U.write(H),this.success(`Repository ${this.bold(U.name)} created successfully.`)}}z([U1.arg({description:"The name of the repository to create",type:K1.STRING}),L("design:type",String)],y0.prototype,"name",void 0),z([U1.arg({description:"The module where the repository will be created",type:K1.STRING}),L("design:type",String)],y0.prototype,"module",void 0),z([U1.arg({description:"The alias of the repository to create",type:K1.STRING}),L("design:type",String)],y0.prototype,"alias",void 0),z([U1.arg({description:"The model used by the repository",type:K1.STRING}),L("design:type",String)],y0.prototype,"model",void 0),z([U1.arg({description:"Create a factory repository",type:K1.BOOLEAN,default:!1}),L("design:type",Boolean)],y0.prototype,"factory",void 0),z([U1.arg({description:"Create a singleton repository",type:K1.BOOLEAN,default:!1}),L("design:type",Boolean)],y0.prototype,"singleton",void 0),y0=z([U1.register()],y0);var d0=V(T(),1);import{join as ZU}from"path";import{Command as W1,CommandArgumentType as P1}from"@elysiumjs/core";var T$=V(i(),1);class u0 extends R{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 E(),$={module:this.module,name:this.name,alias:this.alias,scope:this.factory?"FACTORY":this.singleton?"SINGLETON":"SINGLETON"};if(!$.module&&!Y.mono){let H=await d0.default({type:"select",name:"module",message:"Module:",choices:Object.keys(Y.modules??{}).map((Z)=>({title:Z,value:Z}))});$.module=H.module}return this.build($)}async setup(){let Y=await E(),H=await d0.default([{type(){return Y.mono?null:"select"},name:"module",message:"Module:",choices(){return Object.keys(Y.modules??{}).map((Z)=>({title:Z,value:Z}))}},{type:"text",name:"name",message:"Service Name:",initial:"UserService",validate(Z){if(Z.length<1)return"Service name cannot be empty";return!0}},{type:"text",name:"alias",message:"Service Alias:",initial(Z,X){return X.name},validate(Z){if(Z.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."}]}],{onCancel:()=>{this.error("Operation cancelled."),process.exit(0)}});return this.build(H)}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(ZU(A(),"stubs/service.stub")),H=T$.default(await $.text(),Y),Z=Y.module?await M(Y.module):"./src",X=F(Y.name.replace("Service","")),U=Bun.file(`${Z}/services/${X}.service.ts`);await U.write(H),this.success(`Service ${this.bold(U.name)} created successfully.`)}}z([W1.arg({description:"The name of the service to create",type:P1.STRING}),L("design:type",String)],u0.prototype,"name",void 0),z([W1.arg({description:"The module where the service will be created",type:P1.STRING}),L("design:type",String)],u0.prototype,"module",void 0),z([W1.arg({description:"The alias of the service to create",type:P1.STRING}),L("design:type",String)],u0.prototype,"alias",void 0),z([W1.arg({description:"Create a factory service",type:P1.BOOLEAN,default:!1}),L("design:type",Boolean)],u0.prototype,"factory",void 0),z([W1.arg({description:"Create a singleton service",type:P1.BOOLEAN,default:!1}),L("design:type",Boolean)],u0.prototype,"singleton",void 0),u0=z([W1.register()],u0);var l0=V(T(),1);import{join as UU}from"path";import{Command as c0,CommandArgumentType as P$}from"@elysiumjs/core";var C$=V(i(),1);class p0 extends R{static command="make:validator";static description="Creates a new validator.";async run(){if(!this.name)return this.setup();let Y=await E(),$={module:this.module,name:this.name};if(!$.module&&!Y.mono){let H=await l0.default({type:"select",name:"module",message:"Module:",choices:Object.keys(Y.modules??{}).map((Z)=>({title:Z,value:Z}))});$.module=H.module}return this.build($)}async setup(){let Y=await E(),H=await l0.default([{type(){return Y.mono?null:"select"},name:"module",message:"Module:",choices(){return Object.keys(Y.modules??{}).map((Z)=>({title:Z,value:Z}))}},{type:"text",name:"name",message:"Validator Name:",initial:"LoginValidator",validate(Z){if(Z.length<1)return"Validator name cannot be empty";return!0}}],{onCancel:()=>{this.error("Operation cancelled."),process.exit(0)}});return this.build(H)}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(UU(A(),"stubs/validator.stub")),H=C$.default(await $.text(),Y),Z=Y.module?await M(Y.module):"./src",X=F(Y.name.replace("Validator","")),U=Bun.file(`${Z}/validators/${X}.validator.ts`);await U.write(H),this.success(`Validator ${this.bold(U.name)} created successfully.`)}}z([c0.arg({description:"The name of the validator to create",type:P$.STRING}),L("design:type",String)],p0.prototype,"name",void 0),z([c0.arg({description:"The module where the validator will be created",type:P$.STRING}),L("design:type",String)],p0.prototype,"module",void 0),p0=z([c0.register()],p0);var _$=V(T(),1);import{exists as XU}from"fs/promises";import{Command as j$,CommandArgumentType as QU}from"@elysiumjs/core";class n0 extends R{static command="migration:generate";static description="Generates migration files.";async run(){if(!this.name){let Z=await _$.default([{type:"text",name:"name",message:"Migration Name:",initial:"create_users_table",validate(X){if(X.length<1)return"Migration name cannot be empty";return!0}}],{onCancel:()=>{this.error("Operation cancelled."),process.exit(0)}});this.name=Z.name}let Y=m(),$=`${Y}/src/database/schemas`;if(await XU(`${Y}/src/database/schema.ts`))$=`${Y}/src/database/schema.ts`;await Bun.$`bunx --bun drizzle-kit generate --dialect postgresql --schema ${$} --out ${Y}/src/database/migrations --prefix timestamp --name ${this.name}`;let H=new Bun.Glob(`${Y}/src/database/migrations/**/*.sql`).scan();for await(let Z of H){let X=Bun.file(Z),U=await X.text();await X.write(U.replace(/"public"\./gm,""))}}}z([j$.arg({description:"The name of the migration to create",type:QU.STRING}),L("design:type",String)],n0.prototype,"name",void 0),n0=z([j$.register()],n0);var x$=V(T(),1);import{basename as k$}from"path";import{Command as e1,CommandArgumentType as i0}from"@elysiumjs/core";import{Database as h$}from"@elysiumjs/mnemosyne-drizzle";class m0 extends R{constructor(){super(...arguments);this.tenant="";this.connection="default";this.fresh=!1}static command="migration:run";static description="Generates migration files.";async run(){if(!h$.connectionExists(this.connection))return this.error(`Connection ${this.bold(this.connection)} does not exist.`),process.exit(1);let Y=h$.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:H}]=await $`SELECT EXISTS (
|
|
99
99
|
SELECT schema_name
|
|
100
100
|
FROM information_schema.schemata
|
|
101
101
|
WHERE schema_name = ${this.tenant}
|
|
@@ -109,4 +109,4 @@ Filtered results for: ${this.inputValue?this.inputValue:n.gray("Enter something
|
|
|
109
109
|
name TEXT NOT NULL,
|
|
110
110
|
batch INTEGER NOT NULL,
|
|
111
111
|
applied_at TIMESTAMP NOT NULL
|
|
112
|
-
);`;let U=(await $`SELECT name FROM elysium_migrations;`).map((G)=>G.name),Q=new Bun.Glob("./src/database/migrations/**/*.sql").scan({absolute:!0,onlyFiles:!0}),J=await Array.fromAsync(Q),D=T0(J.filter((G)=>!U.includes(k$(G))),(G)=>G);if(D.length===0){this.success("No new migrations to apply.");return}let W=this.spinner(`Running migrations for tenant ${this.bold(this.tenant)}...`),[{max:Y1}]=await $`SELECT MAX(batch) + 1 AS max FROM elysium_migrations;`,$1=Y1??0;for(let G of D){await $.file(G);let[{name:P}]=await $`INSERT INTO elysium_migrations (name, batch, applied_at) VALUES (${k$(G)}, ${$1}, ${new Date}) RETURNING name;`;W.pause(`Migration ${this.bold(P)} applied successfully.`)}W.complete(`Migrations for tenant ${this.bold(this.tenant)} applied successfully.`)}),await Y.close()}}z([e1.arg({description:"The name of the tenant in which the migrations will be executed.",type:i0.STRING,required:!0}),L("design:type",String)],m0.prototype,"tenant",void 0),z([e1.arg({description:"The name of the connection to use.",type:i0.STRING,default:"default"}),L("design:type",String)],m0.prototype,"connection",void 0),z([e1.arg({description:"Drop the entire schema before running the migrations.",type:i0.BOOLEAN,default:!1}),L("design:type",Boolean)],m0.prototype,"fresh",void 0),m0=z([e1.register()],m0);var
|
|
112
|
+
);`;let U=(await $`SELECT name FROM elysium_migrations;`).map((G)=>G.name),Q=new Bun.Glob("./src/database/migrations/**/*.sql").scan({absolute:!0,onlyFiles:!0}),J=await Array.fromAsync(Q),D=T0(J.filter((G)=>!U.includes(k$(G))),(G)=>G);if(D.length===0){this.success("No new migrations to apply.");return}let W=this.spinner(`Running migrations for tenant ${this.bold(this.tenant)}...`),[{max:Y1}]=await $`SELECT MAX(batch) + 1 AS max FROM elysium_migrations;`,$1=Y1??0;for(let G of D){await $.file(G);let[{name:P}]=await $`INSERT INTO elysium_migrations (name, batch, applied_at) VALUES (${k$(G)}, ${$1}, ${new Date}) RETURNING name;`;W.pause(`Migration ${this.bold(P)} applied successfully.`)}W.complete(`Migrations for tenant ${this.bold(this.tenant)} applied successfully.`)}),await Y.close()}}z([e1.arg({description:"The name of the tenant in which the migrations will be executed.",type:i0.STRING,required:!0}),L("design:type",String)],m0.prototype,"tenant",void 0),z([e1.arg({description:"The name of the connection to use.",type:i0.STRING,default:"default"}),L("design:type",String)],m0.prototype,"connection",void 0),z([e1.arg({description:"Drop the entire schema before running the migrations.",type:i0.BOOLEAN,default:!1}),L("design:type",Boolean)],m0.prototype,"fresh",void 0),m0=z([e1.register()],m0);var t0=V(T(),1);import{exists as JU,rmdir as DU}from"fs/promises";import{join as zU}from"path";import{Command as b$,CommandArgumentType as KU}from"@elysiumjs/core";class s0 extends R{static command="module:new";static description="Creates a new module.";module;convert=!1;async run(){let Y=await E();if(!this.name){let $=await t0.default({type:"text",name:"name",message:"New module name:",initial:"module",validate(H){return H.length>0?!0:"Module name cannot be empty"}},{onCancel:()=>process.exit(0)});this.name=F($.name)}if(Y.mono){let{module:$,convert:H}=await t0.default([{type:"confirm",name:"convert",message:"This project is a mono-module project. Do you want to convert it to a multi-module project?",initial:!1},{type:(Z)=>Z?"text":null,name:"module",message:"Current module name:",initial:"main",validate(Z){return Z.length>0?!0:"Module name cannot be empty"}}],{onCancel:()=>process.exit(0)});if(!H)return this.error("Operation cancelled. The project is left unchanged.");this.module=F($),this.convert=H}if(this.convert){let $=zU(m(),"src","modules");if(await JU($))await DU($,{recursive:!0});await M1(this.module,"root"),this.success("Project converted to multi-module."),this.success(`Module '${this.module}' created.`)}await M1(this.name),this.success(`Module '${this.name}' created.`)}}z([b$.arg({description:"The name of the module to create",type:KU.STRING}),L("design:type",String)],s0.prototype,"name",void 0),s0=z([b$.register()],s0);var r0=V(T(),1);import{Command as o0,CommandArgumentType as f$}from"@elysiumjs/core";class a0 extends R{static command="module:rename";static description="Renames a module.";async run(){if((await E()).mono)return this.error("This operation is not supported for mono-module projects.");if(!this.module){let{module:$}=await r0.default({type:"text",name:"module",message:"Module to rename:",validate:(H)=>H.length>0});this.module=$}if(!this.name){let{name:$}=await r0.default({type:"text",name:"name",message:"New module name:",initial:this.module,validate:(H)=>H.length>0});this.name=$}if(this.module===this.name)return this.info("Module name is the same as the current name.");await M1(this.name,this.module),this.success(`Module '${this.module}' renamed to '${this.name}'.`)}}z([o0.arg({description:"The module to rename",type:f$.STRING}),L("design:type",String)],a0.prototype,"module",void 0),z([o0.arg({description:"The new name of the module",type:f$.STRING}),L("design:type",String)],a0.prototype,"name",void 0),a0=z([o0.register()],a0);var WU=m(),{App:w$}=await import(`${WU}/src/app`);class e0 extends w${}e0=z([w$.register()],e0);export{e0 as StyxApp};
|
package/package.json
CHANGED
|
@@ -1,49 +1,53 @@
|
|
|
1
1
|
{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
2
|
+
"name": "@elysiumjs/styx",
|
|
3
|
+
"version": "0.7.2",
|
|
4
|
+
"license": "Apache-2.0",
|
|
5
|
+
"description": "The CLI tool for the Elysium.js framework.",
|
|
6
|
+
"private": false,
|
|
7
|
+
"author": "Workbud Technologies Inc.",
|
|
8
|
+
"repository": {
|
|
9
|
+
"type": "git",
|
|
10
|
+
"url": "https://github.com/workbud/elysium"
|
|
11
|
+
},
|
|
12
|
+
"homepage": "https://github.com/workbud/elysium",
|
|
13
|
+
"scripts": {
|
|
14
|
+
"format": "prettier --write \"./src/**/*.ts\"",
|
|
15
|
+
"clean": "rimraf dist",
|
|
16
|
+
"build:js": "bun build ./src/styx.ts ./src/index.ts --outdir ./dist --target bun -e @elysiumjs/* -e reflect-metadata --root ./src --minify",
|
|
17
|
+
"build:ts": "tsc",
|
|
18
|
+
"build": "bun run clean && bun run build:js && bun run build:ts",
|
|
19
|
+
"typecheck": "tsc --noEmit",
|
|
20
|
+
"prepublishOnly": "bun run build"
|
|
21
|
+
},
|
|
22
|
+
"keywords": [
|
|
23
|
+
"elysium",
|
|
24
|
+
"framework",
|
|
25
|
+
"web",
|
|
26
|
+
"api",
|
|
27
|
+
"typescript",
|
|
28
|
+
"cli"
|
|
29
|
+
],
|
|
30
|
+
"type": "module",
|
|
31
|
+
"bin": {
|
|
32
|
+
"styx": "dist/styx.js"
|
|
33
|
+
},
|
|
34
|
+
"module": "dist/index.js",
|
|
35
|
+
"types": "dist/index.d.ts",
|
|
36
|
+
"devDependencies": {
|
|
37
|
+
"@elysiumjs/core": "0.7.0",
|
|
38
|
+
"@elysiumjs/heracles": "0.6.1",
|
|
39
|
+
"@elysiumjs/mnemosyne": "0.1.0",
|
|
40
|
+
"@elysiumjs/mnemosyne-drizzle": "0.1.1",
|
|
41
|
+
"@types/prompts": "^2.4.9",
|
|
42
|
+
"@types/string-template": "^1.0.7",
|
|
43
|
+
"prompts": "^2.4.2",
|
|
44
|
+
"radash": "^12.1.1",
|
|
45
|
+
"string-template": "^1.0.0"
|
|
46
|
+
},
|
|
47
|
+
"peerDependencies": {
|
|
48
|
+
"@elysiumjs/core": "^0.7.0",
|
|
49
|
+
"@elysiumjs/heracles": "^0.6.1",
|
|
50
|
+
"@elysiumjs/mnemosyne": "^0.1.0",
|
|
51
|
+
"@elysiumjs/mnemosyne-drizzle": "^0.1.1"
|
|
52
|
+
}
|
|
49
53
|
}
|
package/stubs/model.stub
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { DrizzleModel } from '@elysiumjs/mnemosyne-drizzle';
|
|
2
2
|
import { uuid } from 'drizzle-orm/pg-core';
|
|
3
3
|
|
|
4
|
-
export class {name} extends
|
|
4
|
+
export class {name} extends DrizzleModel('{table}', {
|
|
5
5
|
id: uuid().primaryKey().defaultRandom(),
|
|
6
6
|
}) {
|
|
7
7
|
public static readonly supportTenancy = {supportTenancy};
|
package/stubs/repository.stub
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Service, ServiceScope } from '@elysiumjs/core';
|
|
2
|
+
import { DrizzleRepository } from '@elysiumjs/mnemosyne-drizzle';
|
|
2
3
|
|
|
3
4
|
import { {model} } from '#{module}/models/{model_name}.model';
|
|
4
5
|
|
|
5
6
|
@Service.register({ name: '{alias}', scope: ServiceScope.{scope} })
|
|
6
|
-
export class {name} extends
|
|
7
|
+
export class {name} extends DrizzleRepository({model}) {}
|
package/.turbo/turbo-build.log
DELETED
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
$ bun run clean && bun run build:js && bun run build:ts
|
|
2
|
-
$ rimraf dist
|
|
3
|
-
$ bun build ./src/styx.ts ./src/index.ts --outdir ./dist --target bun -e @elysiumjs/* -e reflect-metadata --root ./src --minify
|
|
4
|
-
Bundled 96 modules in 45ms
|
|
5
|
-
|
|
6
|
-
styx.js 76 bytes (entry point)
|
|
7
|
-
index.js 115.57 KB (entry point)
|
|
8
|
-
|
|
9
|
-
$ tsc
|