@ooneex/cli 1.1.11 → 1.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +9 -0
- package/dist/index.js +353 -169
- package/dist/index.js.map +23 -23
- package/package.json +12 -12
package/dist/index.js
CHANGED
|
@@ -1,38 +1,46 @@
|
|
|
1
1
|
#!/usr/bin/env bun
|
|
2
2
|
// @bun
|
|
3
|
-
var
|
|
4
|
-
`),
|
|
5
|
-
`+s,width:
|
|
6
|
-
`)r.name="enter";else if(e==="\t")r.name="tab";else if(e==="\b"||e==="\x7F"||e==="\x1B\x7F"||e==="\x1B\b")r.name="backspace",r.meta=e.charAt(0)==="\x1B";else if(e==="\x1B"||e==="\x1B\x1B")r.name="escape",r.meta=e.length===2;else if(e===" "||e==="\x1B ")r.name="space",r.meta=e.length===2;else if(e<="\x1A")r.name=String.fromCharCode(e.charCodeAt(0)+97-1),r.ctrl=!0;else if(e.length===1&&e>="0"&&e<="9")r.name="number";else if(e.length===1&&e>="a"&&e<="z")r.name=e;else if(e.length===1&&e>="A"&&e<="Z")r.name=e.toLowerCase(),r.shift=!0;else if(s=In.exec(e))r.meta=!0,r.shift=/^[A-Z]$/.test(s[1]);else if(s=Ln.exec(e)){let i=[...e];if(i[0]==="\x1B"&&i[1]==="\x1B")r.option=!0;let o=[s[1],s[2],s[4],s[6]].filter(Boolean).join(""),n=(s[3]||s[5]||1)-1;r.ctrl=!!(n&4),r.meta=!!(n&10),r.shift=!!(n&1),r.code=o,r.name=$n[o],r.shift=Gn(o)||r.shift,r.ctrl=Un(o)||r.ctrl}return r};_e.listen=(e={},t)=>{let{stdin:s}=e;if(!s||s!==process.stdin&&!s.isTTY)throw Error("Invalid stream passed");let r=ts.createInterface({terminal:!0,input:s});ts.emitKeypressEvents(s,r);let i=new Pn((a,p)=>t(a,_e(a,p),r)),o=s.isRaw;if(s.isTTY)s.setRawMode(!0);return s.on("keypress",i.enqueue),r.resume(),()=>{if(s.isTTY)s.setRawMode(o);s.removeListener("keypress",i.enqueue),i.destroy(),r.pause(),r.close()}};_e.action=(e,t,s)=>{let r={...On,...s};if(t.ctrl)return t.action=r.ctrl[t.name],t;if(t.option&&r.option)return t.action=r.option[t.name],t;if(t.shift)return t.action=r.shift[t.name],t;return t.action=r.keys[t.name],t};ss.exports=_e});var is=A((em,rs)=>{rs.exports=(e)=>{e.timers=e.timers||{};let t=e.options.timers;if(!t)return;for(let s of Object.keys(t)){let r=t[s];if(typeof r==="number")r={interval:r};qn(e,s,r)}};function qn(e,t,s={}){let r=e.timers[t]={name:t,start:Date.now(),ms:0,tick:0},i=s.interval||120;r.frames=s.frames||[],r.loading=!0;let o=setInterval(()=>{r.ms=Date.now()-r.start,r.tick++,e.render()},i);return r.stop=()=>{r.loading=!1,clearInterval(o)},Reflect.defineProperty(r,"interval",{value:o}),e.once("close",()=>r.stop()),r.stop}});var as=A((tm,ns)=>{var{define:Kn,width:Hn}=R();class os{constructor(e){let t=e.options;Kn(this,"_prompt",e),this.type=e.type,this.name=e.name,this.message="",this.header="",this.footer="",this.error="",this.hint="",this.input="",this.cursor=0,this.index=0,this.lines=0,this.tick=0,this.prompt="",this.buffer="",this.width=Hn(t.stdout||process.stdout),Object.assign(this,t),this.name=this.name||this.message,this.message=this.message||this.name,this.symbols=e.symbols,this.styles=e.styles,this.required=new Set,this.cancelled=!1,this.submitted=!1}clone(){let e={...this};return e.status=this.status,e.buffer=Buffer.from(e.buffer),delete e.clone,e}set color(e){this._color=e}get color(){let e=this.prompt.styles;if(this.cancelled)return e.cancelled;if(this.submitted)return e.submitted;let t=this._color||e[this.status];return typeof t==="function"?t:e.pending}set loading(e){this._loading=e}get loading(){if(typeof this._loading==="boolean")return this._loading;if(this.loadingChoices)return"choices";return!1}get status(){if(this.cancelled)return"cancelled";if(this.submitted)return"submitted";return"pending"}}ns.exports=os});var ls=A((sm,ps)=>{var ot=R(),_=Ne(),nt={default:_.noop,noop:_.noop,set inverse(e){this._inverse=e},get inverse(){return this._inverse||ot.inverse(this.primary)},set complement(e){this._complement=e},get complement(){return this._complement||ot.complement(this.primary)},primary:_.cyan,success:_.green,danger:_.magenta,strong:_.bold,warning:_.yellow,muted:_.dim,disabled:_.gray,dark:_.dim.gray,underline:_.underline,set info(e){this._info=e},get info(){return this._info||this.primary},set em(e){this._em=e},get em(){return this._em||this.primary.underline},set heading(e){this._heading=e},get heading(){return this._heading||this.muted.underline},set pending(e){this._pending=e},get pending(){return this._pending||this.primary},set submitted(e){this._submitted=e},get submitted(){return this._submitted||this.success},set cancelled(e){this._cancelled=e},get cancelled(){return this._cancelled||this.danger},set typing(e){this._typing=e},get typing(){return this._typing||this.dim},set placeholder(e){this._placeholder=e},get placeholder(){return this._placeholder||this.primary.dim},set highlight(e){this._highlight=e},get highlight(){return this._highlight||this.inverse}};nt.merge=(e={})=>{if(e.styles&&typeof e.styles.enabled==="boolean")_.enabled=e.styles.enabled;if(e.styles&&typeof e.styles.visible==="boolean")_.visible=e.styles.visible;let t=ot.merge({},nt,e.styles);delete t.merge;for(let s of Object.keys(_))if(!hasOwnProperty.call(t,s))Reflect.defineProperty(t,s,{get:()=>_[s]});for(let s of Object.keys(_.styles))if(!hasOwnProperty.call(t,s))Reflect.defineProperty(t,s,{get:()=>_[s]});return t};ps.exports=nt});var ms=A((rm,cs)=>{var at=process.platform==="win32",G=Ne(),Wn=R(),pt={...G.symbols,upDownDoubleArrow:"\u21D5",upDownDoubleArrow2:"\u2B0D",upDownArrow:"\u2195",asterisk:"*",asterism:"\u2042",bulletWhite:"\u25E6",electricArrow:"\u2301",ellipsisLarge:"\u22EF",ellipsisSmall:"\u2026",fullBlock:"\u2588",identicalTo:"\u2261",indicator:G.symbols.check,leftAngle:"\u2039",mark:"\u203B",minus:"\u2212",multiplication:"\xD7",obelus:"\xF7",percent:"%",pilcrow:"\xB6",pilcrow2:"\u2761",pencilUpRight:"\u2710",pencilDownRight:"\u270E",pencilRight:"\u270F",plus:"+",plusMinus:"\xB1",pointRight:"\u261E",rightAngle:"\u203A",section:"\xA7",hexagon:{off:"\u2B21",on:"\u2B22",disabled:"\u2B22"},ballot:{on:"\u2611",off:"\u2610",disabled:"\u2612"},stars:{on:"\u2605",off:"\u2606",disabled:"\u2606"},folder:{on:"\u25BC",off:"\u25B6",disabled:"\u25B6"},prefix:{pending:G.symbols.question,submitted:G.symbols.check,cancelled:G.symbols.cross},separator:{pending:G.symbols.pointerSmall,submitted:G.symbols.middot,cancelled:G.symbols.middot},radio:{off:at?"( )":"\u25EF",on:at?"(*)":"\u25C9",disabled:at?"(|)":"\u24BE"},numbers:["\u24EA","\u2460","\u2461","\u2462","\u2463","\u2464","\u2465","\u2466","\u2467","\u2468","\u2469","\u246A","\u246B","\u246C","\u246D","\u246E","\u246F","\u2470","\u2471","\u2472","\u2473","\u3251","\u3252","\u3253","\u3254","\u3255","\u3256","\u3257","\u3258","\u3259","\u325A","\u325B","\u325C","\u325D","\u325E","\u325F","\u32B1","\u32B2","\u32B3","\u32B4","\u32B5","\u32B6","\u32B7","\u32B8","\u32B9","\u32BA","\u32BB","\u32BC","\u32BD","\u32BE","\u32BF"]};pt.merge=(e)=>{let t=Wn.merge({},G.symbols,pt,e.symbols);return delete t.merge,t};cs.exports=pt});var us=A((im,ds)=>{var Yn=ls(),Vn=ms(),Fn=R();ds.exports=(e)=>{e.options=Fn.merge({},e.options.theme,e.options),e.symbols=Vn.merge(e.options),e.styles=Yn.merge(e.options)}});var gs=A((fs,ys)=>{var hs=process.env.TERM_PROGRAM==="Apple_Terminal",Qn=V(),lt=R(),L=ys.exports=fs,ct=!1,F=L.code={bell:"\x07",beep:"\x07",beginning:"\x1B[G",down:"\x1B[J",esc:"\x1B[",getPosition:"\x1B[6n",hide:"\x1B[?25l",line:"\x1B[2K",lineEnd:"\x1B[K",lineStart:"\x1B[1K",restorePosition:"\x1B["+(hs?"8":"u"),savePosition:"\x1B["+(hs?"7":"s"),screen:"\x1B[2J",show:"\x1B[?25h",up:"\x1B[1J"},ne=L.cursor={get hidden(){return ct},hide(){return ct=!0,F.hide},show(){return ct=!1,F.show},forward:(e=1)=>`\x1B[${e}C`,backward:(e=1)=>`\x1B[${e}D`,nextLine:(e=1)=>"\x1B[E".repeat(e),prevLine:(e=1)=>"\x1B[F".repeat(e),up:(e=1)=>e?`\x1B[${e}A`:"",down:(e=1)=>e?`\x1B[${e}B`:"",right:(e=1)=>e?`\x1B[${e}C`:"",left:(e=1)=>e?`\x1B[${e}D`:"",to(e,t){return t?`\x1B[${t+1};${e+1}H`:`\x1B[${e+1}G`},move(e=0,t=0){let s="";return s+=e<0?ne.left(-e):e>0?ne.right(e):"",s+=t<0?ne.up(-t):t>0?ne.down(t):"",s},strLen(e){var t=0,s=e.length,r=-1;for(var i=0;i<s;i++)if(r=e.charCodeAt(i),r>=0&&r<=128)t+=1;else t+=2;return t},restore(e={}){let{after:t,cursor:s,initial:r,input:i,prompt:o,size:n,value:a}=e;if(r=lt.isPrimitive(r)?String(r):"",i=lt.isPrimitive(i)?String(i):"",a=lt.isPrimitive(a)?String(a):"",n){let p=L.cursor.up(n)+L.cursor.to(this.strLen(o)),l=i.length-s;if(l>0)p+=L.cursor.left(l);return p}if(a||t){let p=!i&&!!r?-this.strLen(r):-this.strLen(i)+s;if(t)p-=this.strLen(t);if(i===""&&r&&!o.includes(r))p+=this.strLen(r);return L.cursor.move(p)}}},mt=L.erase={screen:F.screen,up:F.up,down:F.down,line:F.line,lineEnd:F.lineEnd,lineStart:F.lineStart,lines(e){let t="";for(let s=0;s<e;s++)t+=L.erase.line+(s<e-1?L.cursor.up(1):"");if(e)t+=L.code.beginning;return t}};L.clear=(e="",t=process.stdout.columns)=>{if(!t)return mt.line+ne.to(0);let s=(o)=>[...Qn(o)].length,r=e.split(/\r?\n/),i=0;for(let o of r)i+=1+Math.floor(Math.max(s(o)-1,0)/t);return(mt.line+ne.prevLine()).repeat(i-1)+mt.line+ne.to(0)}});var ce=A((om,As)=>{var zn=he("events"),Es=V(),dt=it(),Zn=is(),Xn=as(),Jn=us(),C=R(),ae=gs();class ut extends zn{constructor(e={}){super();this.name=e.name,this.type=e.type,this.options=e,Jn(this),Zn(this),this.state=new Xn(this),this.initial=[e.initial,e.default].find((t)=>t!=null),this.stdout=e.stdout||process.stdout,this.stdin=e.stdin||process.stdin,this.scale=e.scale||1,this.term=this.options.term||process.env.TERM_PROGRAM,this.margin=kn(this.options.margin),this.setMaxListeners(0),jn(this)}async keypress(e,t={}){this.keypressed=!0;let s=dt.action(e,dt(e,t),this.options.actions);this.state.keypress=s,this.emit("keypress",e,s),this.emit("state",this.state.clone());let r=this.options[s.action]||this[s.action]||this.dispatch;if(typeof r==="function")return await r.call(this,e,s);this.alert()}alert(){if(delete this.state.alert,this.options.show===!1)this.emit("alert");else this.stdout.write(ae.code.beep)}cursorHide(){this.stdout.write(ae.cursor.hide());let e=C.onExit(()=>this.cursorShow());this.on("close",()=>{this.cursorShow(),e()})}cursorShow(){this.stdout.write(ae.cursor.show())}write(e){if(!e)return;if(this.stdout&&this.state.show!==!1)this.stdout.write(e);this.state.buffer+=e}clear(e=0){let t=this.state.buffer;if(this.state.buffer="",!t&&!e||this.options.show===!1)return;this.stdout.write(ae.cursor.down(e)+ae.clear(t,this.width))}restore(){if(this.state.closed||this.options.show===!1)return;let{prompt:e,after:t,rest:s}=this.sections(),{cursor:r,initial:i="",input:o="",value:n=""}=this,a=this.state.size=s.length,p={after:t,cursor:r,initial:i,input:o,prompt:e,size:a,value:n},l=ae.cursor.restore(p);if(l)this.stdout.write(l)}sections(){let{buffer:e,input:t,prompt:s}=this.state;s=Es(s);let r=Es(e),i=r.indexOf(s),o=r.slice(0,i),a=r.slice(i).split(`
|
|
7
|
-
`),
|
|
3
|
+
var qi=Object.create;var{getPrototypeOf:Wi,defineProperty:It,getOwnPropertyNames:Ki}=Object;var Hi=Object.prototype.hasOwnProperty;function Yi(e){return this[e]}var Vi,Fi,te=(e,t,s)=>{var r=e!=null&&typeof e==="object";if(r){var o=t?Vi??=new WeakMap:Fi??=new WeakMap,i=o.get(e);if(i)return i}s=e!=null?qi(Wi(e)):{};let n=t||!e||!e.__esModule?It(s,"default",{value:e,enumerable:!0}):s;for(let a of Ki(e))if(!Hi.call(n,a))It(n,a,{get:Yi.bind(e,a),enumerable:!0});if(r)o.set(e,n);return n};var A=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports);var g=function(e,t,s,r){var o=arguments.length,i=o<3?t:r===null?r=Object.getOwnPropertyDescriptor(t,s):r,n;if(typeof Reflect==="object"&&typeof Reflect.decorate==="function")i=Reflect.decorate(e,t,s,r);else for(var a=e.length-1;a>=0;a--)if(n=e[a])i=(o<3?n(i):o>3?n(t,s,i):n(t,s))||i;return o>3&&i&&Object.defineProperty(t,s,i),i};var fe=import.meta.require;var Ht=A((kd,ye)=>{var en=typeof process<"u"&&process.env.TERM_PROGRAM==="Hyper",tn=typeof process<"u"&&process.platform==="win32",qt=typeof process<"u"&&process.platform==="linux",st={ballotDisabled:"\u2612",ballotOff:"\u2610",ballotOn:"\u2611",bullet:"\u2022",bulletWhite:"\u25E6",fullBlock:"\u2588",heart:"\u2764",identicalTo:"\u2261",line:"\u2500",mark:"\u203B",middot:"\xB7",minus:"\uFF0D",multiplication:"\xD7",obelus:"\xF7",pencilDownRight:"\u270E",pencilRight:"\u270F",pencilUpRight:"\u2710",percent:"%",pilcrow2:"\u2761",pilcrow:"\xB6",plusMinus:"\xB1",question:"?",section:"\xA7",starsOff:"\u2606",starsOn:"\u2605",upDownArrow:"\u2195"},Wt=Object.assign({},st,{check:"\u221A",cross:"\xD7",ellipsisLarge:"...",ellipsis:"...",info:"i",questionSmall:"?",pointer:">",pointerSmall:"\xBB",radioOff:"( )",radioOn:"(*)",warning:"\u203C"}),Kt=Object.assign({},st,{ballotCross:"\u2718",check:"\u2714",cross:"\u2716",ellipsisLarge:"\u22EF",ellipsis:"\u2026",info:"\u2139",questionFull:"\uFF1F",questionSmall:"\uFE56",pointer:qt?"\u25B8":"\u276F",pointerSmall:qt?"\u2023":"\u203A",radioOff:"\u25EF",radioOn:"\u25C9",warning:"\u26A0"});ye.exports=tn&&!en?Wt:Kt;Reflect.defineProperty(ye.exports,"common",{enumerable:!1,value:st});Reflect.defineProperty(ye.exports,"windows",{enumerable:!1,value:Wt});Reflect.defineProperty(ye.exports,"other",{enumerable:!1,value:Kt})});var Ne=A((ep,rt)=>{var sn=(e)=>e!==null&&typeof e==="object"&&!Array.isArray(e),rn=/[\u001b\u009b][[\]#;?()]*(?:(?:(?:[^\W_]*;?[^\W_]*)\u0007)|(?:(?:[0-9]{1,4}(;[0-9]{0,4})*)?[~0-9=<>cf-nqrtyA-PRZ]))/g,on=()=>{if(typeof process<"u")return process.env.FORCE_COLOR!=="0";return!1},Yt=()=>{let e={enabled:on(),visible:!0,styles:{},keys:{}},t=(i)=>{let n=i.open=`\x1B[${i.codes[0]}m`,a=i.close=`\x1B[${i.codes[1]}m`,l=i.regex=new RegExp(`\\u001b\\[${i.codes[1]}m`,"g");return i.wrap=(m,c)=>{if(m.includes(a))m=m.replace(l,a+n);let p=n+m+a;return c?p.replace(/\r*\n/g,`${a}$&${n}`):p},i},s=(i,n,a)=>{return typeof i==="function"?i(n):i.wrap(n,a)},r=(i,n)=>{if(i===""||i==null)return"";if(e.enabled===!1)return i;if(e.visible===!1)return"";let a=""+i,l=a.includes(`
|
|
4
|
+
`),m=n.length;if(m>0&&n.includes("unstyle"))n=[...new Set(["unstyle",...n])].reverse();while(m-- >0)a=s(e.styles[n[m]],a,l);return a},o=(i,n,a)=>{e.styles[i]=t({name:i,codes:n}),(e.keys[a]||(e.keys[a]=[])).push(i),Reflect.defineProperty(e,i,{configurable:!0,enumerable:!0,set(m){e.alias(i,m)},get(){let m=(c)=>r(c,m.stack);return Reflect.setPrototypeOf(m,e),m.stack=this.stack?this.stack.concat(i):[i],m}})};return o("reset",[0,0],"modifier"),o("bold",[1,22],"modifier"),o("dim",[2,22],"modifier"),o("italic",[3,23],"modifier"),o("underline",[4,24],"modifier"),o("inverse",[7,27],"modifier"),o("hidden",[8,28],"modifier"),o("strikethrough",[9,29],"modifier"),o("black",[30,39],"color"),o("red",[31,39],"color"),o("green",[32,39],"color"),o("yellow",[33,39],"color"),o("blue",[34,39],"color"),o("magenta",[35,39],"color"),o("cyan",[36,39],"color"),o("white",[37,39],"color"),o("gray",[90,39],"color"),o("grey",[90,39],"color"),o("bgBlack",[40,49],"bg"),o("bgRed",[41,49],"bg"),o("bgGreen",[42,49],"bg"),o("bgYellow",[43,49],"bg"),o("bgBlue",[44,49],"bg"),o("bgMagenta",[45,49],"bg"),o("bgCyan",[46,49],"bg"),o("bgWhite",[47,49],"bg"),o("blackBright",[90,39],"bright"),o("redBright",[91,39],"bright"),o("greenBright",[92,39],"bright"),o("yellowBright",[93,39],"bright"),o("blueBright",[94,39],"bright"),o("magentaBright",[95,39],"bright"),o("cyanBright",[96,39],"bright"),o("whiteBright",[97,39],"bright"),o("bgBlackBright",[100,49],"bgBright"),o("bgRedBright",[101,49],"bgBright"),o("bgGreenBright",[102,49],"bgBright"),o("bgYellowBright",[103,49],"bgBright"),o("bgBlueBright",[104,49],"bgBright"),o("bgMagentaBright",[105,49],"bgBright"),o("bgCyanBright",[106,49],"bgBright"),o("bgWhiteBright",[107,49],"bgBright"),e.ansiRegex=rn,e.hasColor=e.hasAnsi=(i)=>{return e.ansiRegex.lastIndex=0,typeof i==="string"&&i!==""&&e.ansiRegex.test(i)},e.alias=(i,n)=>{let a=typeof n==="string"?e[n]:n;if(typeof a!=="function")throw TypeError("Expected alias to be the name of an existing color (string) or a function");if(!a.stack)Reflect.defineProperty(a,"name",{value:i}),e.styles[i]=a,a.stack=[i];Reflect.defineProperty(e,i,{configurable:!0,enumerable:!0,set(l){e.alias(i,l)},get(){let l=(m)=>r(m,l.stack);return Reflect.setPrototypeOf(l,e),l.stack=this.stack?this.stack.concat(a.stack):a.stack,l}})},e.theme=(i)=>{if(!sn(i))throw TypeError("Expected theme to be an object");for(let n of Object.keys(i))e.alias(n,i[n]);return e},e.alias("unstyle",(i)=>{if(typeof i==="string"&&i!=="")return e.ansiRegex.lastIndex=0,i.replace(e.ansiRegex,"");return""}),e.alias("noop",(i)=>i),e.none=e.clear=e.noop,e.stripColor=e.unstyle,e.symbols=Ht(),e.define=o,e};rt.exports=Yt();rt.exports.create=Yt});var R=A((an)=>{var nn=Object.prototype.toString,L=Ne(),Vt=!1,ge=new Set,Ft={yellow:"blue",cyan:"red",green:"magenta",black:"white",blue:"yellow",red:"cyan",magenta:"green",white:"black"};an.longest=(e,t)=>{return e.reduce((s,r)=>Math.max(s,t?r[t].length:r.length),0)};an.hasColor=(e)=>!!e&&L.hasColor(e);var Me=an.isObject=(e)=>{return e!==null&&typeof e==="object"&&!Array.isArray(e)};an.nativeType=(e)=>{return nn.call(e).slice(8,-1).toLowerCase().replace(/\s/g,"")};an.isAsyncFn=(e)=>{return an.nativeType(e)==="asyncfunction"};an.isPrimitive=(e)=>{return e!=null&&typeof e!=="object"&&typeof e!=="function"};an.resolve=(e,t,...s)=>{if(typeof t==="function")return t.call(e,...s);return t};an.scrollDown=(e=[])=>[...e.slice(1),e[0]];an.scrollUp=(e=[])=>[e.pop(),...e];an.reorder=(e=[])=>{let t=e.slice();return t.sort((s,r)=>{if(s.index>r.index)return 1;if(s.index<r.index)return-1;return 0}),t};an.swap=(e,t,s)=>{let r=e.length,o=s===r?0:s<0?r-1:s,i=e[t];e[t]=e[o],e[o]=i};an.width=(e,t=80)=>{let s=e&&e.columns?e.columns:t;if(e&&typeof e.getWindowSize==="function")s=e.getWindowSize()[0];if(process.platform==="win32")return s-1;return s};an.height=(e,t=20)=>{let s=e&&e.rows?e.rows:t;if(e&&typeof e.getWindowSize==="function")s=e.getWindowSize()[1];return s};an.wordWrap=(e,t={})=>{if(!e)return e;if(typeof t==="number")t={width:t};let{indent:s="",newline:r=`
|
|
5
|
+
`+s,width:o=80}=t,i=(r+s).match(/[^\S\n]/g)||[];o-=i.length;let n=`.{1,${o}}([\\s\\u200B]+|$)|[^\\s\\u200B]+?([\\s\\u200B]+|$)`,a=e.trim(),l=new RegExp(n,"g"),m=a.match(l)||[];if(m=m.map((c)=>c.replace(/\n$/,"")),t.padEnd)m=m.map((c)=>c.padEnd(o," "));if(t.padStart)m=m.map((c)=>c.padStart(o," "));return s+m.join(r)};an.unmute=(e)=>{let t=e.stack.find((r)=>L.keys.color.includes(r));if(t)return L[t];if(e.stack.find((r)=>r.slice(2)==="bg"))return L[t.slice(2)];return(r)=>r};an.pascal=(e)=>e?e[0].toUpperCase()+e.slice(1):"";an.inverse=(e)=>{if(!e||!e.stack)return e;let t=e.stack.find((r)=>L.keys.color.includes(r));if(t){let r=L["bg"+an.pascal(t)];return r?r.black:e}let s=e.stack.find((r)=>r.slice(0,2)==="bg");if(s)return L[s.slice(2).toLowerCase()]||e;return L.none};an.complement=(e)=>{if(!e||!e.stack)return e;let t=e.stack.find((r)=>L.keys.color.includes(r)),s=e.stack.find((r)=>r.slice(0,2)==="bg");if(t&&!s)return L[Ft[t]||t];if(s){let r=s.slice(2).toLowerCase(),o=Ft[r];if(!o)return e;return L["bg"+an.pascal(o)]||e}return L.none};an.meridiem=(e)=>{let t=e.getHours(),s=e.getMinutes(),r=t>=12?"pm":"am";t=t%12;let o=t===0?12:t,i=s<10?"0"+s:s;return o+":"+i+" "+r};an.set=(e={},t="",s)=>{return t.split(".").reduce((r,o,i,n)=>{let a=n.length-1>i?r[o]||{}:s;if(!an.isObject(a)&&i<n.length-1)a={};return r[o]=a},e)};an.get=(e={},t="",s)=>{let r=e[t]==null?t.split(".").reduce((o,i)=>o&&o[i],e):e[t];return r==null?s:r};an.mixin=(e,t)=>{if(!Me(e))return t;if(!Me(t))return e;for(let s of Object.keys(t)){let r=Object.getOwnPropertyDescriptor(t,s);if(hasOwnProperty.call(r,"value"))if(hasOwnProperty.call(e,s)&&Me(r.value)){let o=Object.getOwnPropertyDescriptor(e,s);if(Me(o.value)&&o.value!==r.value)e[s]=an.merge({},e[s],t[s]);else Reflect.defineProperty(e,s,r)}else Reflect.defineProperty(e,s,r);else Reflect.defineProperty(e,s,r)}return e};an.merge=(...e)=>{let t={};for(let s of e)an.mixin(t,s);return t};an.mixinEmitter=(e,t)=>{let s=t.constructor.prototype;for(let r of Object.keys(s)){let o=s[r];if(typeof o==="function")an.define(e,r,o.bind(t));else an.define(e,r,o)}};var Te=(e,t)=>{if(Vt)return;if(Vt=!0,ge.forEach((s)=>s()),e===!0)process.exit(128+t)},Qt=Te.bind(null,!0,15),zt=Te.bind(null,!0,2);an.onExit=(e)=>{if(ge.size===0)process.once("SIGTERM",Qt),process.once("SIGINT",zt),process.once("exit",Te);return ge.add(e),()=>{if(ge.delete(e),ge.size===0)process.off("SIGTERM",Qt),process.off("SIGINT",zt),process.off("exit",Te)}};an.define=(e,t,s)=>{Reflect.defineProperty(e,t,{value:s})};an.defineExport=(e,t,s)=>{let r;Reflect.defineProperty(e,t,{enumerable:!0,configurable:!0,set(o){r=o},get(){return r?r():s()}})}});var kt=A((sp,jt)=>{jt.exports=({onlyFirst:e=!1}={})=>{let t=["[\\u001B\\u009B][[\\]()#;?]*(?:(?:(?:(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]+)*|[a-zA-Z\\d]+(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]*)*)?\\u0007)","(?:(?:\\d{1,4}(?:;\\d{0,4})*)?[\\dA-PR-TZcf-ntqry=><~]))"].join("|");return new RegExp(t,e?void 0:"g")}});var se=A((rp,es)=>{var On=kt();es.exports=(e)=>typeof e==="string"?e.replace(On(),""):e});var ts=A((Cn)=>{Cn.ctrl={a:"first",b:"backward",c:"cancel",d:"deleteForward",e:"last",f:"forward",g:"reset",i:"tab",k:"cutForward",l:"reset",n:"newItem",m:"cancel",j:"submit",p:"search",r:"remove",s:"save",u:"undo",w:"cutLeft",x:"toggleCursor",v:"paste"};Cn.shift={up:"shiftUp",down:"shiftDown",left:"shiftLeft",right:"shiftRight",tab:"prev"};Cn.fn={up:"pageUp",down:"pageDown",left:"pageLeft",right:"pageRight",delete:"deleteForward"};Cn.option={b:"backward",f:"forward",d:"cutRight",left:"cutLeft",up:"altUp",down:"altDown"};Cn.keys={pageup:"pageUp",pagedown:"pageDown",home:"home",end:"end",cancel:"cancel",delete:"deleteForward",backspace:"delete",down:"down",enter:"submit",escape:"cancel",left:"left",space:"space",number:"number",return:"submit",right:"right",tab:"next",up:"up"}});var rs=A((ip,ss)=>{ss.exports=class{_queue=[];_executing=!1;_jobRunner=null;constructor(t){this._jobRunner=t}enqueue=(...t)=>{this._queue.push(t),this._dequeue()};destroy(){this._queue.length=0,this._jobRunner=null}_dequeue(){if(this._executing||!this._queue.length)return;this._executing=!0,this._jobRunner(...this._queue.shift()),setTimeout(()=>{this._executing=!1,this._dequeue()})}}});var it=A((np,is)=>{var os=fe("readline"),Un=ts(),Gn=rs(),qn=/^(?:\x1b)([a-zA-Z0-9])$/,Wn=/^(?:\x1b+)(O|N|\[|\[\[)(?:(\d+)(?:;(\d+))?([~^$])|(?:1;)?(\d+)?([a-zA-Z]))/,Kn={OP:"f1",OQ:"f2",OR:"f3",OS:"f4","[11~":"f1","[12~":"f2","[13~":"f3","[14~":"f4","[[A":"f1","[[B":"f2","[[C":"f3","[[D":"f4","[[E":"f5","[15~":"f5","[17~":"f6","[18~":"f7","[19~":"f8","[20~":"f9","[21~":"f10","[23~":"f11","[24~":"f12","[A":"up","[B":"down","[C":"right","[D":"left","[E":"clear","[F":"end","[H":"home",OA:"up",OB:"down",OC:"right",OD:"left",OE:"clear",OF:"end",OH:"home","[1~":"home","[2~":"insert","[3~":"delete","[4~":"end","[5~":"pageup","[6~":"pagedown","[[5~":"pageup","[[6~":"pagedown","[7~":"home","[8~":"end","[a":"up","[b":"down","[c":"right","[d":"left","[e":"clear","[2$":"insert","[3$":"delete","[5$":"pageup","[6$":"pagedown","[7$":"home","[8$":"end",Oa:"up",Ob:"down",Oc:"right",Od:"left",Oe:"clear","[2^":"insert","[3^":"delete","[5^":"pageup","[6^":"pagedown","[7^":"home","[8^":"end","[Z":"tab"};function Hn(e){return["[a","[b","[c","[d","[e","[2$","[3$","[5$","[6$","[7$","[8$","[Z"].includes(e)}function Yn(e){return["Oa","Ob","Oc","Od","Oe","[2^","[3^","[5^","[6^","[7^","[8^"].includes(e)}var ve=(e="",t={})=>{let s,r={name:t.name,ctrl:!1,meta:!1,shift:!1,option:!1,sequence:e,raw:e,...t};if(Buffer.isBuffer(e))if(e[0]>127&&e[1]===void 0)e[0]-=128,e="\x1B"+String(e);else e=String(e);else if(e!==void 0&&typeof e!=="string")e=String(e);else if(!e)e=r.sequence||"";if(r.sequence=r.sequence||e||r.name,e==="\r")r.raw=void 0,r.name="return";else if(e===`
|
|
6
|
+
`)r.name="enter";else if(e==="\t")r.name="tab";else if(e==="\b"||e==="\x7F"||e==="\x1B\x7F"||e==="\x1B\b")r.name="backspace",r.meta=e.charAt(0)==="\x1B";else if(e==="\x1B"||e==="\x1B\x1B")r.name="escape",r.meta=e.length===2;else if(e===" "||e==="\x1B ")r.name="space",r.meta=e.length===2;else if(e<="\x1A")r.name=String.fromCharCode(e.charCodeAt(0)+97-1),r.ctrl=!0;else if(e.length===1&&e>="0"&&e<="9")r.name="number";else if(e.length===1&&e>="a"&&e<="z")r.name=e;else if(e.length===1&&e>="A"&&e<="Z")r.name=e.toLowerCase(),r.shift=!0;else if(s=qn.exec(e))r.meta=!0,r.shift=/^[A-Z]$/.test(s[1]);else if(s=Wn.exec(e)){let o=[...e];if(o[0]==="\x1B"&&o[1]==="\x1B")r.option=!0;let i=[s[1],s[2],s[4],s[6]].filter(Boolean).join(""),n=(s[3]||s[5]||1)-1;r.ctrl=!!(n&4),r.meta=!!(n&10),r.shift=!!(n&1),r.code=i,r.name=Kn[i],r.shift=Hn(i)||r.shift,r.ctrl=Yn(i)||r.ctrl}return r};ve.listen=(e={},t)=>{let{stdin:s}=e;if(!s||s!==process.stdin&&!s.isTTY)throw Error("Invalid stream passed");let r=os.createInterface({terminal:!0,input:s});os.emitKeypressEvents(s,r);let o=new Gn((a,l)=>t(a,ve(a,l),r)),i=s.isRaw;if(s.isTTY)s.setRawMode(!0);return s.on("keypress",o.enqueue),r.resume(),()=>{if(s.isTTY)s.setRawMode(i);s.removeListener("keypress",o.enqueue),o.destroy(),r.pause(),r.close()}};ve.action=(e,t,s)=>{let r={...Un,...s};if(t.ctrl)return t.action=r.ctrl[t.name],t;if(t.option&&r.option)return t.action=r.option[t.name],t;if(t.shift)return t.action=r.shift[t.name],t;return t.action=r.keys[t.name],t};is.exports=ve});var as=A((ap,ns)=>{ns.exports=(e)=>{e.timers=e.timers||{};let t=e.options.timers;if(!t)return;for(let s of Object.keys(t)){let r=t[s];if(typeof r==="number")r={interval:r};Vn(e,s,r)}};function Vn(e,t,s={}){let r=e.timers[t]={name:t,start:Date.now(),ms:0,tick:0},o=s.interval||120;r.frames=s.frames||[],r.loading=!0;let i=setInterval(()=>{r.ms=Date.now()-r.start,r.tick++,e.render()},o);return r.stop=()=>{r.loading=!1,clearInterval(i)},Reflect.defineProperty(r,"interval",{value:i}),e.once("close",()=>r.stop()),r.stop}});var ds=A((lp,ms)=>{var{define:Fn,width:Qn}=R();class ls{constructor(e){let t=e.options;Fn(this,"_prompt",e),this.type=e.type,this.name=e.name,this.message="",this.header="",this.footer="",this.error="",this.hint="",this.input="",this.cursor=0,this.index=0,this.lines=0,this.tick=0,this.prompt="",this.buffer="",this.width=Qn(t.stdout||process.stdout),Object.assign(this,t),this.name=this.name||this.message,this.message=this.message||this.name,this.symbols=e.symbols,this.styles=e.styles,this.required=new Set,this.cancelled=!1,this.submitted=!1}clone(){let e={...this};return e.status=this.status,e.buffer=Buffer.from(e.buffer),delete e.clone,e}set color(e){this._color=e}get color(){let e=this.prompt.styles;if(this.cancelled)return e.cancelled;if(this.submitted)return e.submitted;let t=this._color||e[this.status];return typeof t==="function"?t:e.pending}set loading(e){this._loading=e}get loading(){if(typeof this._loading==="boolean")return this._loading;if(this.loadingChoices)return"choices";return!1}get status(){if(this.cancelled)return"cancelled";if(this.submitted)return"submitted";return"pending"}}ms.exports=ls});var us=A((mp,ps)=>{var nt=R(),T=Ne(),at={default:T.noop,noop:T.noop,set inverse(e){this._inverse=e},get inverse(){return this._inverse||nt.inverse(this.primary)},set complement(e){this._complement=e},get complement(){return this._complement||nt.complement(this.primary)},primary:T.cyan,success:T.green,danger:T.magenta,strong:T.bold,warning:T.yellow,muted:T.dim,disabled:T.gray,dark:T.dim.gray,underline:T.underline,set info(e){this._info=e},get info(){return this._info||this.primary},set em(e){this._em=e},get em(){return this._em||this.primary.underline},set heading(e){this._heading=e},get heading(){return this._heading||this.muted.underline},set pending(e){this._pending=e},get pending(){return this._pending||this.primary},set submitted(e){this._submitted=e},get submitted(){return this._submitted||this.success},set cancelled(e){this._cancelled=e},get cancelled(){return this._cancelled||this.danger},set typing(e){this._typing=e},get typing(){return this._typing||this.dim},set placeholder(e){this._placeholder=e},get placeholder(){return this._placeholder||this.primary.dim},set highlight(e){this._highlight=e},get highlight(){return this._highlight||this.inverse}};at.merge=(e={})=>{if(e.styles&&typeof e.styles.enabled==="boolean")T.enabled=e.styles.enabled;if(e.styles&&typeof e.styles.visible==="boolean")T.visible=e.styles.visible;let t=nt.merge({},at,e.styles);delete t.merge;for(let s of Object.keys(T))if(!hasOwnProperty.call(t,s))Reflect.defineProperty(t,s,{get:()=>T[s]});for(let s of Object.keys(T.styles))if(!hasOwnProperty.call(t,s))Reflect.defineProperty(t,s,{get:()=>T[s]});return t};ps.exports=at});var hs=A((dp,cs)=>{var lt=process.platform==="win32",H=Ne(),zn=R(),mt={...H.symbols,upDownDoubleArrow:"\u21D5",upDownDoubleArrow2:"\u2B0D",upDownArrow:"\u2195",asterisk:"*",asterism:"\u2042",bulletWhite:"\u25E6",electricArrow:"\u2301",ellipsisLarge:"\u22EF",ellipsisSmall:"\u2026",fullBlock:"\u2588",identicalTo:"\u2261",indicator:H.symbols.check,leftAngle:"\u2039",mark:"\u203B",minus:"\u2212",multiplication:"\xD7",obelus:"\xF7",percent:"%",pilcrow:"\xB6",pilcrow2:"\u2761",pencilUpRight:"\u2710",pencilDownRight:"\u270E",pencilRight:"\u270F",plus:"+",plusMinus:"\xB1",pointRight:"\u261E",rightAngle:"\u203A",section:"\xA7",hexagon:{off:"\u2B21",on:"\u2B22",disabled:"\u2B22"},ballot:{on:"\u2611",off:"\u2610",disabled:"\u2612"},stars:{on:"\u2605",off:"\u2606",disabled:"\u2606"},folder:{on:"\u25BC",off:"\u25B6",disabled:"\u25B6"},prefix:{pending:H.symbols.question,submitted:H.symbols.check,cancelled:H.symbols.cross},separator:{pending:H.symbols.pointerSmall,submitted:H.symbols.middot,cancelled:H.symbols.middot},radio:{off:lt?"( )":"\u25EF",on:lt?"(*)":"\u25C9",disabled:lt?"(|)":"\u24BE"},numbers:["\u24EA","\u2460","\u2461","\u2462","\u2463","\u2464","\u2465","\u2466","\u2467","\u2468","\u2469","\u246A","\u246B","\u246C","\u246D","\u246E","\u246F","\u2470","\u2471","\u2472","\u2473","\u3251","\u3252","\u3253","\u3254","\u3255","\u3256","\u3257","\u3258","\u3259","\u325A","\u325B","\u325C","\u325D","\u325E","\u325F","\u32B1","\u32B2","\u32B3","\u32B4","\u32B5","\u32B6","\u32B7","\u32B8","\u32B9","\u32BA","\u32BB","\u32BC","\u32BD","\u32BE","\u32BF"]};mt.merge=(e)=>{let t=zn.merge({},H.symbols,mt,e.symbols);return delete t.merge,t};cs.exports=mt});var ys=A((pp,fs)=>{var Zn=us(),Xn=hs(),Jn=R();fs.exports=(e)=>{e.options=Jn.merge({},e.options.theme,e.options),e.symbols=Xn.merge(e.options),e.styles=Zn.merge(e.options)}});var bs=A((Es,As)=>{var gs=process.env.TERM_PROGRAM==="Apple_Terminal",jn=se(),dt=R(),I=As.exports=Es,pt=!1,re=I.code={bell:"\x07",beep:"\x07",beginning:"\x1B[G",down:"\x1B[J",esc:"\x1B[",getPosition:"\x1B[6n",hide:"\x1B[?25l",line:"\x1B[2K",lineEnd:"\x1B[K",lineStart:"\x1B[1K",restorePosition:"\x1B["+(gs?"8":"u"),savePosition:"\x1B["+(gs?"7":"s"),screen:"\x1B[2J",show:"\x1B[?25h",up:"\x1B[1J"},ae=I.cursor={get hidden(){return pt},hide(){return pt=!0,re.hide},show(){return pt=!1,re.show},forward:(e=1)=>`\x1B[${e}C`,backward:(e=1)=>`\x1B[${e}D`,nextLine:(e=1)=>"\x1B[E".repeat(e),prevLine:(e=1)=>"\x1B[F".repeat(e),up:(e=1)=>e?`\x1B[${e}A`:"",down:(e=1)=>e?`\x1B[${e}B`:"",right:(e=1)=>e?`\x1B[${e}C`:"",left:(e=1)=>e?`\x1B[${e}D`:"",to(e,t){return t?`\x1B[${t+1};${e+1}H`:`\x1B[${e+1}G`},move(e=0,t=0){let s="";return s+=e<0?ae.left(-e):e>0?ae.right(e):"",s+=t<0?ae.up(-t):t>0?ae.down(t):"",s},strLen(e){var t=0,s=e.length,r=-1;for(var o=0;o<s;o++)if(r=e.charCodeAt(o),r>=0&&r<=128)t+=1;else t+=2;return t},restore(e={}){let{after:t,cursor:s,initial:r,input:o,prompt:i,size:n,value:a}=e;if(r=dt.isPrimitive(r)?String(r):"",o=dt.isPrimitive(o)?String(o):"",a=dt.isPrimitive(a)?String(a):"",n){let l=I.cursor.up(n)+I.cursor.to(this.strLen(i)),m=o.length-s;if(m>0)l+=I.cursor.left(m);return l}if(a||t){let l=!o&&!!r?-this.strLen(r):-this.strLen(o)+s;if(t)l-=this.strLen(t);if(o===""&&r&&!i.includes(r))l+=this.strLen(r);return I.cursor.move(l)}}},ut=I.erase={screen:re.screen,up:re.up,down:re.down,line:re.line,lineEnd:re.lineEnd,lineStart:re.lineStart,lines(e){let t="";for(let s=0;s<e;s++)t+=I.erase.line+(s<e-1?I.cursor.up(1):"");if(e)t+=I.code.beginning;return t}};I.clear=(e="",t=process.stdout.columns)=>{if(!t)return ut.line+ae.to(0);let s=(i)=>[...jn(i)].length,r=e.split(/\r?\n/),o=0;for(let i of r)o+=1+Math.floor(Math.max(s(i)-1,0)/t);return(ut.line+ae.prevLine()).repeat(o-1)+ut.line+ae.to(0)}});var pe=A((up,ws)=>{var kn=fe("events"),xs=se(),ct=it(),ea=as(),ta=ds(),sa=ys(),O=R(),le=bs();class ht extends kn{constructor(e={}){super();this.name=e.name,this.type=e.type,this.options=e,sa(this),ea(this),this.state=new ta(this),this.initial=[e.initial,e.default].find((t)=>t!=null),this.stdout=e.stdout||process.stdout,this.stdin=e.stdin||process.stdin,this.scale=e.scale||1,this.term=this.options.term||process.env.TERM_PROGRAM,this.margin=oa(this.options.margin),this.setMaxListeners(0),ra(this)}async keypress(e,t={}){this.keypressed=!0;let s=ct.action(e,ct(e,t),this.options.actions);this.state.keypress=s,this.emit("keypress",e,s),this.emit("state",this.state.clone());let r=this.options[s.action]||this[s.action]||this.dispatch;if(typeof r==="function")return await r.call(this,e,s);this.alert()}alert(){if(delete this.state.alert,this.options.show===!1)this.emit("alert");else this.stdout.write(le.code.beep)}cursorHide(){this.stdout.write(le.cursor.hide());let e=O.onExit(()=>this.cursorShow());this.on("close",()=>{this.cursorShow(),e()})}cursorShow(){this.stdout.write(le.cursor.show())}write(e){if(!e)return;if(this.stdout&&this.state.show!==!1)this.stdout.write(e);this.state.buffer+=e}clear(e=0){let t=this.state.buffer;if(this.state.buffer="",!t&&!e||this.options.show===!1)return;this.stdout.write(le.cursor.down(e)+le.clear(t,this.width))}restore(){if(this.state.closed||this.options.show===!1)return;let{prompt:e,after:t,rest:s}=this.sections(),{cursor:r,initial:o="",input:i="",value:n=""}=this,a=this.state.size=s.length,l={after:t,cursor:r,initial:o,input:i,prompt:e,size:a,value:n},m=le.cursor.restore(l);if(m)this.stdout.write(m)}sections(){let{buffer:e,input:t,prompt:s}=this.state;s=xs(s);let r=xs(e),o=r.indexOf(s),i=r.slice(0,o),a=r.slice(o).split(`
|
|
7
|
+
`),l=a[0],m=a[a.length-1],p=(s+(t?" "+t:"")).length,u=p<l.length?l.slice(p+1):"";return{header:i,prompt:l,after:u,rest:a.slice(1),last:m}}async submit(){if(this.state.submitted=!0,this.state.validating=!0,this.options.onSubmit)await this.options.onSubmit.call(this,this.name,this.value,this);let e=this.state.error||await this.validate(this.value,this.state);if(e!==!0){let t=`
|
|
8
8
|
`+this.symbols.pointer+" ";if(typeof e==="string")t+=e.trim();else t+="Invalid input";this.state.error=`
|
|
9
|
-
`+this.styles.danger(t),this.state.submitted=!1,await this.render(),await this.alert(),this.state.validating=!1,this.state.error=void 0;return}this.state.validating=!1,await this.render(),await this.close(),this.value=await this.result(this.value),this.emit("submit",this.value)}async cancel(e){if(this.state.cancelled=this.state.submitted=!0,await this.render(),await this.close(),typeof this.options.onCancel==="function")await this.options.onCancel.call(this,this.name,this.value,this);this.emit("cancel",await this.error(e))}async close(){this.state.closed=!0;try{let e=this.sections(),t=Math.ceil(e.prompt.length/this.width);if(e.rest)this.write(
|
|
10
|
-
`.repeat(t))}catch(e){}this.emit("close")}start(){if(!this.stop&&this.options.show!==!1)this.stop=
|
|
11
|
-
`:" ",r=[];for(let i=0;i<4;i++){let o=s(i);if(t[i])r.push(o.repeat(t[i]));else r.push("")}return r}As.exports=ut});var xs=A((nm,ws)=>{var ea=R(),bs={default(e,t){return t},checkbox(e,t){throw Error("checkbox role is not implemented yet")},editable(e,t){throw Error("editable role is not implemented yet")},expandable(e,t){throw Error("expandable role is not implemented yet")},heading(e,t){return t.disabled="",t.indicator=[t.indicator," "].find((s)=>s!=null),t.message=t.message||"",t},input(e,t){throw Error("input role is not implemented yet")},option(e,t){return bs.default(e,t)},radio(e,t){throw Error("radio role is not implemented yet")},separator(e,t){return t.disabled="",t.indicator=[t.indicator," "].find((s)=>s!=null),t.message=t.message||e.symbols.line.repeat(5),t},spacer(e,t){return t}};ws.exports=(e,t={})=>{let s=ea.merge({},bs,t.roles);return s[e]||s.default}});var ge=A((am,Ts)=>{var ta=V(),sa=ce(),ra=xs(),ve=R(),{reorder:ht,scrollUp:ia,scrollDown:oa,isObject:Ss,swap:na}=ve;class Ms extends sa{constructor(e){super(e);this.cursorHide(),this.maxSelected=e.maxSelected||1/0,this.multiple=e.multiple||!1,this.initial=e.initial||0,this.delay=e.delay||0,this.longest=0,this.num=""}async initialize(){if(typeof this.options.initial==="function")this.initial=await this.options.initial.call(this);await this.reset(!0),await super.initialize()}async reset(){let{choices:e,initial:t,autofocus:s,suggest:r}=this.options;if(this.state._choices=[],this.state.choices=[],this.choices=await Promise.all(await this.toChoices(e)),this.choices.forEach((i)=>i.enabled=!1),typeof r!=="function"&&this.selectable.length===0)throw Error("At least one choice must be selectable");if(Ss(t))t=Object.keys(t);if(Array.isArray(t)){if(s!=null)this.index=this.findIndex(s);t.forEach((i)=>this.enable(this.find(i))),await this.render()}else{if(s!=null)t=s;if(typeof t==="string")t=this.findIndex(t);if(typeof t==="number"&&t>-1)this.index=Math.max(0,Math.min(t,this.choices.length)),this.enable(this.find(this.index))}if(this.isDisabled(this.focused))await this.down()}async toChoices(e,t){this.state.loadingChoices=!0;let s=[],r=0,i=async(o,n)=>{if(typeof o==="function")o=await o.call(this);if(o instanceof Promise)o=await o;for(let a=0;a<o.length;a++){let p=o[a]=await this.toChoice(o[a],r++,n);if(s.push(p),p.choices)await i(p.choices,p)}return s};return i(e,t).then((o)=>{return this.state.loadingChoices=!1,o})}async toChoice(e,t,s){if(typeof e==="function")e=await e.call(this,this);if(e instanceof Promise)e=await e;if(typeof e==="string")e={name:e};if(e.normalized)return e;e.normalized=!0;let r=e.value;if(e=ra(e.role,this.options)(this,e),typeof e.disabled==="string"&&!e.hint)e.hint=e.disabled,e.disabled=!0;if(e.disabled===!0&&e.hint==null)e.hint="(disabled)";if(e.index!=null)return e;if(e.name=e.name||e.key||e.title||e.value||e.message,e.message=e.message||e.name||"",e.value=[e.value,e.name].find(this.isValue.bind(this)),e.input="",e.index=t,e.cursor=0,ve.define(e,"parent",s),e.level=s?s.level+1:1,e.indent==null)e.indent=s?s.indent+" ":e.indent||"";if(e.path=s?s.path+"."+e.name:e.name,e.enabled=!!(this.multiple&&!this.isDisabled(e)&&(e.enabled||this.isSelected(e))),!this.isDisabled(e))this.longest=Math.max(this.longest,ta(e.message).length);let o={...e};if(e.reset=(n=o.input,a=o.value)=>{for(let p of Object.keys(o))e[p]=o[p];e.input=n,e.value=a},r==null&&typeof e.initial==="function")e.input=await e.initial.call(this,this.state,e,t);return e}async onChoice(e,t){if(this.emit("choice",e,t,this),typeof e.onChoice==="function")await e.onChoice.call(this,this.state,e,t)}async addChoice(e,t,s){let r=await this.toChoice(e,t,s);return this.choices.push(r),this.index=this.choices.length-1,this.limit=this.choices.length,r}async newItem(e,t,s){let r={name:"New choice name?",editable:!0,newChoice:!0,...e},i=await this.addChoice(r,t,s);return i.updateChoice=()=>{delete i.newChoice,i.name=i.message=i.input,i.input="",i.cursor=0},this.render()}indent(e){if(e.indent==null)return e.level>1?" ".repeat(e.level-1):"";return e.indent}dispatch(e,t){if(this.multiple&&this[t.name])return this[t.name]();this.alert()}focus(e,t){if(typeof t!=="boolean")t=e.enabled;if(t&&!e.enabled&&this.selected.length>=this.maxSelected)return this.alert();return this.index=e.index,e.enabled=t&&!this.isDisabled(e),e}space(){if(!this.multiple)return this.alert();if(!this.focused)return;return this.toggle(this.focused),this.render()}a(){if(this.maxSelected<this.choices.length)return this.alert();let e=this.selectable.every((t)=>t.enabled);return this.choices.forEach((t)=>t.enabled=!e),this.render()}i(){if(this.choices.length-this.selected.length>this.maxSelected)return this.alert();return this.choices.forEach((e)=>e.enabled=!e.enabled),this.render()}g(){if(!this.choices.some((t)=>!!t.parent))return this.a();let e=this.focused;return this.toggle(e.parent&&!e.choices?e.parent:e),this.render()}toggle(e,t){if(!e.enabled&&this.selected.length>=this.maxSelected)return this.alert();if(typeof t!=="boolean")t=!e.enabled;if(e.enabled=t,e.choices)e.choices.forEach((r)=>this.toggle(r,t));let s=e.parent;while(s){let r=s.choices.filter((i)=>this.isDisabled(i));s.enabled=r.every((i)=>i.enabled===!0),s=s.parent}return Ns(this,this.choices),this.emit("toggle",e,this),e}enable(e){if(this.selected.length>=this.maxSelected)return this.alert();return e.enabled=!this.isDisabled(e),e.choices&&e.choices.forEach(this.enable.bind(this)),e}disable(e){return e.enabled=!1,e.choices&&e.choices.forEach(this.disable.bind(this)),e}number(e){this.num+=e;let t=(s)=>{let r=Number(s);if(r>this.choices.length-1)return this.alert();let i=this.focused,o=this.choices.find((n)=>r===n.index);if(!o.enabled&&this.selected.length>=this.maxSelected)return this.alert();if(this.visible.indexOf(o)===-1){let n=ht(this.choices),a=n.indexOf(o);if(i.index>a){let p=n.slice(a,a+this.limit),l=n.filter((c)=>!p.includes(c));this.choices=p.concat(l)}else{let p=a-this.limit+1;this.choices=n.slice(p).concat(n.slice(0,p))}}return this.index=this.choices.indexOf(o),this.toggle(this.focused),this.render()};return clearTimeout(this.numberTimeout),new Promise((s)=>{let r=this.choices.length,i=this.num,o=(n=!1,a)=>{if(clearTimeout(this.numberTimeout),n)a=t(i);this.num="",s(a)};if(i==="0"||i.length===1&&Number(i+"0")>r)return o(!0);if(Number(i)>r)return o(!1,this.alert());this.numberTimeout=setTimeout(()=>o(!0),this.delay)})}home(){return this.choices=ht(this.choices),this.index=0,this.render()}end(){let e=this.choices.length-this.limit,t=ht(this.choices);return this.choices=t.slice(e).concat(t.slice(0,e)),this.index=this.limit-1,this.render()}first(){return this.index=0,this.render()}last(){return this.index=this.visible.length-1,this.render()}prev(){if(this.visible.length<=1)return this.alert();return this.up()}next(){if(this.visible.length<=1)return this.alert();return this.down()}right(){if(this.cursor>=this.input.length)return this.alert();return this.cursor++,this.render()}left(){if(this.cursor<=0)return this.alert();return this.cursor--,this.render()}up(){let e=this.choices.length,t=this.visible.length,s=this.index;if(this.options.scroll===!1&&s===0)return this.alert();if(e>t&&s===0)return this.scrollUp();if(this.index=(s-1%e+e)%e,this.isDisabled()&&!this.allChoicesAreDisabled())return this.up();return this.render()}down(){let e=this.choices.length,t=this.visible.length,s=this.index;if(this.options.scroll===!1&&s===t-1)return this.alert();if(e>t&&s===t-1)return this.scrollDown();if(this.index=(s+1)%e,this.isDisabled()&&!this.allChoicesAreDisabled())return this.down();return this.render()}scrollUp(e=0){if(this.choices=ia(this.choices),this.index=e,this.isDisabled())return this.up();return this.render()}scrollDown(e=this.visible.length-1){if(this.choices=oa(this.choices),this.index=e,this.isDisabled())return this.down();return this.render()}async shiftUp(){if(this.options.sort===!0){this.sorting=!0,this.swap(this.index-1),await this.up(),this.sorting=!1;return}return this.scrollUp(this.index)}async shiftDown(){if(this.options.sort===!0){this.sorting=!0,this.swap(this.index+1),await this.down(),this.sorting=!1;return}return this.scrollDown(this.index)}pageUp(){if(this.visible.length<=1)return this.alert();if(this.limit=Math.max(this.limit-1,0),this.index=Math.min(this.limit-1,this.index),this._limit=this.limit,this.isDisabled())return this.up();return this.render()}pageDown(){if(this.visible.length>=this.choices.length)return this.alert();if(this.index=Math.max(0,this.index),this.limit=Math.min(this.limit+1,this.choices.length),this._limit=this.limit,this.isDisabled())return this.down();return this.render()}swap(e){na(this.choices,this.index,e)}allChoicesAreDisabled(e=this.choices){return e.every((t)=>this.isDisabled(t))}isDisabled(e=this.focused){if(e&&["disabled","collapsed","hidden","completing","readonly"].some((s)=>e[s]===!0))return!0;return e&&e.role==="heading"}isEnabled(e=this.focused){if(Array.isArray(e))return e.every((t)=>this.isEnabled(t));if(e.choices){let t=e.choices.filter((s)=>!this.isDisabled(s));return e.enabled&&t.every((s)=>this.isEnabled(s))}return e.enabled&&!this.isDisabled(e)}isChoice(e,t){return e.name===t||e.index===Number(t)}isSelected(e){if(Array.isArray(this.initial))return this.initial.some((t)=>this.isChoice(e,t));return this.isChoice(e,this.initial)}map(e=[],t="value"){return[].concat(e||[]).reduce((s,r)=>{return s[r]=this.find(r,t),s},{})}filter(e,t){let r=typeof e==="function"?e:(n,a)=>[n.name,a].includes(e),o=(this.options.multiple?this.state._choices:this.choices).filter(r);if(t)return o.map((n)=>n[t]);return o}find(e,t){if(Ss(e))return t?e[t]:e;let r=typeof e==="function"?e:(o,n)=>[o.name,n].includes(e),i=this.choices.find(r);if(i)return t?i[t]:i}findIndex(e){return this.choices.indexOf(this.find(e))}async submit(){let e=this.focused;if(!e)return this.alert();if(e.newChoice){if(!e.input)return this.alert();return e.updateChoice(),this.render()}if(this.choices.some((o)=>o.newChoice))return this.alert();let{reorder:t,sort:s}=this.options,r=this.multiple===!0,i=this.selected;if(i===void 0)return this.alert();if(Array.isArray(i)&&t!==!1&&s!==!0)i=ve.reorder(i);return this.value=r?i.map((o)=>o.name):i.name,super.submit()}set choices(e=[]){this.state._choices=this.state._choices||[],this.state.choices=e;for(let t of e)if(!this.state._choices.some((s)=>s.name===t.name))this.state._choices.push(t);if(!this._initial&&this.options.initial){this._initial=!0;let t=this.initial;if(typeof t==="string"||typeof t==="number"){let s=this.find(t);if(s)this.initial=s.index,this.focus(s,!0)}}}get choices(){return Ns(this,this.state.choices||[])}set visible(e){this.state.visible=e}get visible(){return(this.state.visible||this.choices).slice(0,this.limit)}set limit(e){this.state.limit=e}get limit(){let{state:e,options:t,choices:s}=this,r=e.limit||this._limit||t.limit||s.length;return Math.min(r,this.height)}set value(e){super.value=e}get value(){if(typeof super.value!=="string"&&super.value===this.initial)return this.input;return super.value}set index(e){this.state.index=e}get index(){return Math.max(0,this.state?this.state.index:0)}get enabled(){return this.filter(this.isEnabled.bind(this))}get focused(){let e=this.choices[this.index];if(e&&this.state.submitted&&this.multiple!==!0)e.enabled=!0;return e}get selectable(){return this.choices.filter((e)=>!this.isDisabled(e))}get selected(){return this.multiple?this.enabled:this.focused}}function Ns(e,t){if(t instanceof Promise)return t;if(typeof t==="function"){if(ve.isAsyncFn(t))return t;t=t.call(e,e)}for(let s of t){if(Array.isArray(s.choices)){let r=s.choices.filter((i)=>!e.isDisabled(i));s.enabled=r.every((i)=>i.enabled===!0)}if(e.isDisabled(s)===!0)delete s.enabled}return t}Ts.exports=Ms});var Q=A((pm,vs)=>{var aa=ge(),ft=R();class _s extends aa{constructor(e){super(e);this.emptyError=this.options.emptyError||"No items were selected"}async dispatch(e,t){if(this.multiple)return this[t.name]?await this[t.name](e,t):await super.dispatch(e,t);this.alert()}separator(){if(this.options.separator)return super.separator();let e=this.styles.muted(this.symbols.ellipsis);return this.state.submitted?super.separator():e}pointer(e,t){return!this.multiple||this.options.pointer?super.pointer(e,t):""}indicator(e,t){return this.multiple?super.indicator(e,t):""}choiceMessage(e,t){let s=this.resolve(e.message,this.state,e,t);if(e.role==="heading"&&!ft.hasColor(s))s=this.styles.strong(s);return this.resolve(s,this.state,e,t)}choiceSeparator(){return":"}async renderChoice(e,t){await this.onChoice(e,t);let s=this.index===t,r=await this.pointer(e,t),i=await this.indicator(e,t)+(e.pad||""),o=await this.resolve(e.hint,this.state,e,t);if(o&&!ft.hasColor(o))o=this.styles.muted(o);let n=this.indent(e),a=await this.choiceMessage(e,t),p=()=>[this.margin[3],n+r+i,a,this.margin[1],o].filter(Boolean).join(" ");if(e.role==="heading")return p();if(e.disabled){if(!ft.hasColor(a))a=this.styles.disabled(a);return p()}if(s)a=this.styles.em(a);return p()}async renderChoices(){if(this.state.loading==="choices")return this.styles.warning("Loading choices");if(this.state.submitted)return"";let e=this.visible.map(async(i,o)=>await this.renderChoice(i,o)),t=await Promise.all(e);if(!t.length)t.push(this.styles.danger("No matching choices"));let s=this.margin[0]+t.join(`
|
|
9
|
+
`+this.styles.danger(t),this.state.submitted=!1,await this.render(),await this.alert(),this.state.validating=!1,this.state.error=void 0;return}this.state.validating=!1,await this.render(),await this.close(),this.value=await this.result(this.value),this.emit("submit",this.value)}async cancel(e){if(this.state.cancelled=this.state.submitted=!0,await this.render(),await this.close(),typeof this.options.onCancel==="function")await this.options.onCancel.call(this,this.name,this.value,this);this.emit("cancel",await this.error(e))}async close(){this.state.closed=!0;try{let e=this.sections(),t=Math.ceil(e.prompt.length/this.width);if(e.rest)this.write(le.cursor.down(e.rest.length));this.write(`
|
|
10
|
+
`.repeat(t))}catch(e){}this.emit("close")}start(){if(!this.stop&&this.options.show!==!1)this.stop=ct.listen(this,this.keypress.bind(this)),this.once("close",this.stop),this.emit("start",this)}async skip(){if(this.skipped=this.options.skip===!0,typeof this.options.skip==="function")this.skipped=await this.options.skip.call(this,this.name,this.value);return this.skipped}async initialize(){let{format:e,options:t,result:s}=this;if(this.format=()=>e.call(this,this.value),this.result=()=>s.call(this,this.value),typeof t.initial==="function")this.initial=await t.initial.call(this,this);if(typeof t.onRun==="function")await t.onRun.call(this,this);if(typeof t.onSubmit==="function"){let r=t.onSubmit.bind(this),o=this.submit.bind(this);delete this.options.onSubmit,this.submit=async()=>{return await r(this.name,this.value,this),o()}}await this.start(),await this.render()}render(){throw Error("expected prompt to have a custom render method")}run(){return new Promise(async(e,t)=>{if(this.once("submit",e),this.once("cancel",t),await this.skip())return this.render=()=>{},this.submit();await this.initialize(),this.emit("run")})}async element(e,t,s){let{options:r,state:o,symbols:i,timers:n}=this,a=n&&n[e];o.timer=a;let l=r[e]||o[e]||i[e],m=t&&t[e]!=null?t[e]:await l;if(m==="")return m;let c=await this.resolve(m,o,t,s);if(!c&&t&&t[e])return this.resolve(l,o,t,s);return c}async prefix(){let e=await this.element("prefix")||this.symbols,t=this.timers&&this.timers.prefix,s=this.state;if(s.timer=t,O.isObject(e))e=e[s.status]||e.pending;if(!O.hasColor(e))return(this.styles[s.status]||this.styles.pending)(e);return e}async message(){let e=await this.element("message");if(!O.hasColor(e))return this.styles.strong(e);return e}async separator(){let e=await this.element("separator")||this.symbols,t=this.timers&&this.timers.separator,s=this.state;s.timer=t;let r=e[s.status]||e.pending||s.separator,o=await this.resolve(r,s);if(O.isObject(o))o=o[s.status]||o.pending;if(!O.hasColor(o))return this.styles.muted(o);return o}async pointer(e,t){let s=await this.element("pointer",e,t);if(typeof s==="string"&&O.hasColor(s))return s;if(s){let r=this.styles,o=this.index===t,i=o?r.primary:(l)=>l,n=await this.resolve(s[o?"on":"off"]||s,this.state),a=!O.hasColor(n)?i(n):n;return o?a:" ".repeat(n.length)}}async indicator(e,t){let s=await this.element("indicator",e,t);if(typeof s==="string"&&O.hasColor(s))return s;if(s){let r=this.styles,o=e.enabled===!0,i=o?r.success:r.dark,n=s[o?"on":"off"]||s;return!O.hasColor(n)?i(n):n}return""}body(){return null}footer(){if(this.state.status==="pending")return this.element("footer")}header(){if(this.state.status==="pending")return this.element("header")}async hint(){if(this.state.status==="pending"&&!this.isValue(this.state.input)){let e=await this.element("hint");if(!O.hasColor(e))return this.styles.muted(e);return e}}error(e){return!this.state.submitted?e||this.state.error:""}format(e){return e}result(e){return e}validate(e){if(this.options.required===!0)return this.isValue(e);return!0}isValue(e){return e!=null&&e!==""}resolve(e,...t){return O.resolve(this,e,...t)}get base(){return ht.prototype}get style(){return this.styles[this.state.status]}get height(){return this.options.rows||O.height(this.stdout,25)}get width(){return this.options.columns||O.width(this.stdout,80)}get size(){return{width:this.width,height:this.height}}set cursor(e){this.state.cursor=e}get cursor(){return this.state.cursor}set input(e){this.state.input=e}get input(){return this.state.input}set value(e){this.state.value=e}get value(){let{input:e,value:t}=this.state,s=[t,e].find(this.isValue.bind(this));return this.isValue(s)?s:this.initial}static get prompt(){return(e)=>new this(e).run()}}function ra(e){let t=(o)=>{return e[o]===void 0||typeof e[o]==="function"},s=["actions","choices","initial","margin","roles","styles","symbols","theme","timers","value"],r=["body","footer","error","header","hint","indicator","message","prefix","separator","skip"];for(let o of Object.keys(e.options)){if(s.includes(o))continue;if(/^on[A-Z]/.test(o))continue;let i=e.options[o];if(typeof i==="function"&&t(o)){if(!r.includes(o))e[o]=i.bind(e)}else if(typeof e[o]!=="function")e[o]=i}}function oa(e){if(typeof e==="number")e=[e,e,e,e];let t=[].concat(e||[]),s=(o)=>o%2===0?`
|
|
11
|
+
`:" ",r=[];for(let o=0;o<4;o++){let i=s(o);if(t[o])r.push(i.repeat(t[o]));else r.push("")}return r}ws.exports=ht});var Ns=A((cp,_s)=>{var ia=R(),Ss={default(e,t){return t},checkbox(e,t){throw Error("checkbox role is not implemented yet")},editable(e,t){throw Error("editable role is not implemented yet")},expandable(e,t){throw Error("expandable role is not implemented yet")},heading(e,t){return t.disabled="",t.indicator=[t.indicator," "].find((s)=>s!=null),t.message=t.message||"",t},input(e,t){throw Error("input role is not implemented yet")},option(e,t){return Ss.default(e,t)},radio(e,t){throw Error("radio role is not implemented yet")},separator(e,t){return t.disabled="",t.indicator=[t.indicator," "].find((s)=>s!=null),t.message=t.message||e.symbols.line.repeat(5),t},spacer(e,t){return t}};_s.exports=(e,t={})=>{let s=ia.merge({},Ss,t.roles);return s[e]||s.default}});var Ee=A((hp,Rs)=>{var na=se(),aa=pe(),la=Ns(),Re=R(),{reorder:ft,scrollUp:ma,scrollDown:da,isObject:Ms,swap:pa}=Re;class vs extends aa{constructor(e){super(e);this.cursorHide(),this.maxSelected=e.maxSelected||1/0,this.multiple=e.multiple||!1,this.initial=e.initial||0,this.delay=e.delay||0,this.longest=0,this.num=""}async initialize(){if(typeof this.options.initial==="function")this.initial=await this.options.initial.call(this);await this.reset(!0),await super.initialize()}async reset(){let{choices:e,initial:t,autofocus:s,suggest:r}=this.options;if(this.state._choices=[],this.state.choices=[],this.choices=await Promise.all(await this.toChoices(e)),this.choices.forEach((o)=>o.enabled=!1),typeof r!=="function"&&this.selectable.length===0)throw Error("At least one choice must be selectable");if(Ms(t))t=Object.keys(t);if(Array.isArray(t)){if(s!=null)this.index=this.findIndex(s);t.forEach((o)=>this.enable(this.find(o))),await this.render()}else{if(s!=null)t=s;if(typeof t==="string")t=this.findIndex(t);if(typeof t==="number"&&t>-1)this.index=Math.max(0,Math.min(t,this.choices.length)),this.enable(this.find(this.index))}if(this.isDisabled(this.focused))await this.down()}async toChoices(e,t){this.state.loadingChoices=!0;let s=[],r=0,o=async(i,n)=>{if(typeof i==="function")i=await i.call(this);if(i instanceof Promise)i=await i;for(let a=0;a<i.length;a++){let l=i[a]=await this.toChoice(i[a],r++,n);if(s.push(l),l.choices)await o(l.choices,l)}return s};return o(e,t).then((i)=>{return this.state.loadingChoices=!1,i})}async toChoice(e,t,s){if(typeof e==="function")e=await e.call(this,this);if(e instanceof Promise)e=await e;if(typeof e==="string")e={name:e};if(e.normalized)return e;e.normalized=!0;let r=e.value;if(e=la(e.role,this.options)(this,e),typeof e.disabled==="string"&&!e.hint)e.hint=e.disabled,e.disabled=!0;if(e.disabled===!0&&e.hint==null)e.hint="(disabled)";if(e.index!=null)return e;if(e.name=e.name||e.key||e.title||e.value||e.message,e.message=e.message||e.name||"",e.value=[e.value,e.name].find(this.isValue.bind(this)),e.input="",e.index=t,e.cursor=0,Re.define(e,"parent",s),e.level=s?s.level+1:1,e.indent==null)e.indent=s?s.indent+" ":e.indent||"";if(e.path=s?s.path+"."+e.name:e.name,e.enabled=!!(this.multiple&&!this.isDisabled(e)&&(e.enabled||this.isSelected(e))),!this.isDisabled(e))this.longest=Math.max(this.longest,na(e.message).length);let i={...e};if(e.reset=(n=i.input,a=i.value)=>{for(let l of Object.keys(i))e[l]=i[l];e.input=n,e.value=a},r==null&&typeof e.initial==="function")e.input=await e.initial.call(this,this.state,e,t);return e}async onChoice(e,t){if(this.emit("choice",e,t,this),typeof e.onChoice==="function")await e.onChoice.call(this,this.state,e,t)}async addChoice(e,t,s){let r=await this.toChoice(e,t,s);return this.choices.push(r),this.index=this.choices.length-1,this.limit=this.choices.length,r}async newItem(e,t,s){let r={name:"New choice name?",editable:!0,newChoice:!0,...e},o=await this.addChoice(r,t,s);return o.updateChoice=()=>{delete o.newChoice,o.name=o.message=o.input,o.input="",o.cursor=0},this.render()}indent(e){if(e.indent==null)return e.level>1?" ".repeat(e.level-1):"";return e.indent}dispatch(e,t){if(this.multiple&&this[t.name])return this[t.name]();this.alert()}focus(e,t){if(typeof t!=="boolean")t=e.enabled;if(t&&!e.enabled&&this.selected.length>=this.maxSelected)return this.alert();return this.index=e.index,e.enabled=t&&!this.isDisabled(e),e}space(){if(!this.multiple)return this.alert();if(!this.focused)return;return this.toggle(this.focused),this.render()}a(){if(this.maxSelected<this.choices.length)return this.alert();let e=this.selectable.every((t)=>t.enabled);return this.choices.forEach((t)=>t.enabled=!e),this.render()}i(){if(this.choices.length-this.selected.length>this.maxSelected)return this.alert();return this.choices.forEach((e)=>e.enabled=!e.enabled),this.render()}g(){if(!this.choices.some((t)=>!!t.parent))return this.a();let e=this.focused;return this.toggle(e.parent&&!e.choices?e.parent:e),this.render()}toggle(e,t){if(!e.enabled&&this.selected.length>=this.maxSelected)return this.alert();if(typeof t!=="boolean")t=!e.enabled;if(e.enabled=t,e.choices)e.choices.forEach((r)=>this.toggle(r,t));let s=e.parent;while(s){let r=s.choices.filter((o)=>this.isDisabled(o));s.enabled=r.every((o)=>o.enabled===!0),s=s.parent}return Ts(this,this.choices),this.emit("toggle",e,this),e}enable(e){if(this.selected.length>=this.maxSelected)return this.alert();return e.enabled=!this.isDisabled(e),e.choices&&e.choices.forEach(this.enable.bind(this)),e}disable(e){return e.enabled=!1,e.choices&&e.choices.forEach(this.disable.bind(this)),e}number(e){this.num+=e;let t=(s)=>{let r=Number(s);if(r>this.choices.length-1)return this.alert();let o=this.focused,i=this.choices.find((n)=>r===n.index);if(!i.enabled&&this.selected.length>=this.maxSelected)return this.alert();if(this.visible.indexOf(i)===-1){let n=ft(this.choices),a=n.indexOf(i);if(o.index>a){let l=n.slice(a,a+this.limit),m=n.filter((c)=>!l.includes(c));this.choices=l.concat(m)}else{let l=a-this.limit+1;this.choices=n.slice(l).concat(n.slice(0,l))}}return this.index=this.choices.indexOf(i),this.toggle(this.focused),this.render()};return clearTimeout(this.numberTimeout),new Promise((s)=>{let r=this.choices.length,o=this.num,i=(n=!1,a)=>{if(clearTimeout(this.numberTimeout),n)a=t(o);this.num="",s(a)};if(o==="0"||o.length===1&&Number(o+"0")>r)return i(!0);if(Number(o)>r)return i(!1,this.alert());this.numberTimeout=setTimeout(()=>i(!0),this.delay)})}home(){return this.choices=ft(this.choices),this.index=0,this.render()}end(){let e=this.choices.length-this.limit,t=ft(this.choices);return this.choices=t.slice(e).concat(t.slice(0,e)),this.index=this.limit-1,this.render()}first(){return this.index=0,this.render()}last(){return this.index=this.visible.length-1,this.render()}prev(){if(this.visible.length<=1)return this.alert();return this.up()}next(){if(this.visible.length<=1)return this.alert();return this.down()}right(){if(this.cursor>=this.input.length)return this.alert();return this.cursor++,this.render()}left(){if(this.cursor<=0)return this.alert();return this.cursor--,this.render()}up(){let e=this.choices.length,t=this.visible.length,s=this.index;if(this.options.scroll===!1&&s===0)return this.alert();if(e>t&&s===0)return this.scrollUp();if(this.index=(s-1%e+e)%e,this.isDisabled()&&!this.allChoicesAreDisabled())return this.up();return this.render()}down(){let e=this.choices.length,t=this.visible.length,s=this.index;if(this.options.scroll===!1&&s===t-1)return this.alert();if(e>t&&s===t-1)return this.scrollDown();if(this.index=(s+1)%e,this.isDisabled()&&!this.allChoicesAreDisabled())return this.down();return this.render()}scrollUp(e=0){if(this.choices=ma(this.choices),this.index=e,this.isDisabled())return this.up();return this.render()}scrollDown(e=this.visible.length-1){if(this.choices=da(this.choices),this.index=e,this.isDisabled())return this.down();return this.render()}async shiftUp(){if(this.options.sort===!0){this.sorting=!0,this.swap(this.index-1),await this.up(),this.sorting=!1;return}return this.scrollUp(this.index)}async shiftDown(){if(this.options.sort===!0){this.sorting=!0,this.swap(this.index+1),await this.down(),this.sorting=!1;return}return this.scrollDown(this.index)}pageUp(){if(this.visible.length<=1)return this.alert();if(this.limit=Math.max(this.limit-1,0),this.index=Math.min(this.limit-1,this.index),this._limit=this.limit,this.isDisabled())return this.up();return this.render()}pageDown(){if(this.visible.length>=this.choices.length)return this.alert();if(this.index=Math.max(0,this.index),this.limit=Math.min(this.limit+1,this.choices.length),this._limit=this.limit,this.isDisabled())return this.down();return this.render()}swap(e){pa(this.choices,this.index,e)}allChoicesAreDisabled(e=this.choices){return e.every((t)=>this.isDisabled(t))}isDisabled(e=this.focused){if(e&&["disabled","collapsed","hidden","completing","readonly"].some((s)=>e[s]===!0))return!0;return e&&e.role==="heading"}isEnabled(e=this.focused){if(Array.isArray(e))return e.every((t)=>this.isEnabled(t));if(e.choices){let t=e.choices.filter((s)=>!this.isDisabled(s));return e.enabled&&t.every((s)=>this.isEnabled(s))}return e.enabled&&!this.isDisabled(e)}isChoice(e,t){return e.name===t||e.index===Number(t)}isSelected(e){if(Array.isArray(this.initial))return this.initial.some((t)=>this.isChoice(e,t));return this.isChoice(e,this.initial)}map(e=[],t="value"){return[].concat(e||[]).reduce((s,r)=>{return s[r]=this.find(r,t),s},{})}filter(e,t){let r=typeof e==="function"?e:(n,a)=>[n.name,a].includes(e),i=(this.options.multiple?this.state._choices:this.choices).filter(r);if(t)return i.map((n)=>n[t]);return i}find(e,t){if(Ms(e))return t?e[t]:e;let r=typeof e==="function"?e:(i,n)=>[i.name,n].includes(e),o=this.choices.find(r);if(o)return t?o[t]:o}findIndex(e){return this.choices.indexOf(this.find(e))}async submit(){let e=this.focused;if(!e)return this.alert();if(e.newChoice){if(!e.input)return this.alert();return e.updateChoice(),this.render()}if(this.choices.some((i)=>i.newChoice))return this.alert();let{reorder:t,sort:s}=this.options,r=this.multiple===!0,o=this.selected;if(o===void 0)return this.alert();if(Array.isArray(o)&&t!==!1&&s!==!0)o=Re.reorder(o);return this.value=r?o.map((i)=>i.name):o.name,super.submit()}set choices(e=[]){this.state._choices=this.state._choices||[],this.state.choices=e;for(let t of e)if(!this.state._choices.some((s)=>s.name===t.name))this.state._choices.push(t);if(!this._initial&&this.options.initial){this._initial=!0;let t=this.initial;if(typeof t==="string"||typeof t==="number"){let s=this.find(t);if(s)this.initial=s.index,this.focus(s,!0)}}}get choices(){return Ts(this,this.state.choices||[])}set visible(e){this.state.visible=e}get visible(){return(this.state.visible||this.choices).slice(0,this.limit)}set limit(e){this.state.limit=e}get limit(){let{state:e,options:t,choices:s}=this,r=e.limit||this._limit||t.limit||s.length;return Math.min(r,this.height)}set value(e){super.value=e}get value(){if(typeof super.value!=="string"&&super.value===this.initial)return this.input;return super.value}set index(e){this.state.index=e}get index(){return Math.max(0,this.state?this.state.index:0)}get enabled(){return this.filter(this.isEnabled.bind(this))}get focused(){let e=this.choices[this.index];if(e&&this.state.submitted&&this.multiple!==!0)e.enabled=!0;return e}get selectable(){return this.choices.filter((e)=>!this.isDisabled(e))}get selected(){return this.multiple?this.enabled:this.focused}}function Ts(e,t){if(t instanceof Promise)return t;if(typeof t==="function"){if(Re.isAsyncFn(t))return t;t=t.call(e,e)}for(let s of t){if(Array.isArray(s.choices)){let r=s.choices.filter((o)=>!e.isDisabled(o));s.enabled=r.every((o)=>o.enabled===!0)}if(e.isDisabled(s)===!0)delete s.enabled}return t}Rs.exports=vs});var oe=A((fp,Os)=>{var ua=Ee(),yt=R();class Ds extends ua{constructor(e){super(e);this.emptyError=this.options.emptyError||"No items were selected"}async dispatch(e,t){if(this.multiple)return this[t.name]?await this[t.name](e,t):await super.dispatch(e,t);this.alert()}separator(){if(this.options.separator)return super.separator();let e=this.styles.muted(this.symbols.ellipsis);return this.state.submitted?super.separator():e}pointer(e,t){return!this.multiple||this.options.pointer?super.pointer(e,t):""}indicator(e,t){return this.multiple?super.indicator(e,t):""}choiceMessage(e,t){let s=this.resolve(e.message,this.state,e,t);if(e.role==="heading"&&!yt.hasColor(s))s=this.styles.strong(s);return this.resolve(s,this.state,e,t)}choiceSeparator(){return":"}async renderChoice(e,t){await this.onChoice(e,t);let s=this.index===t,r=await this.pointer(e,t),o=await this.indicator(e,t)+(e.pad||""),i=await this.resolve(e.hint,this.state,e,t);if(i&&!yt.hasColor(i))i=this.styles.muted(i);let n=this.indent(e),a=await this.choiceMessage(e,t),l=()=>[this.margin[3],n+r+o,a,this.margin[1],i].filter(Boolean).join(" ");if(e.role==="heading")return l();if(e.disabled){if(!yt.hasColor(a))a=this.styles.disabled(a);return l()}if(s)a=this.styles.em(a);return l()}async renderChoices(){if(this.state.loading==="choices")return this.styles.warning("Loading choices");if(this.state.submitted)return"";let e=this.visible.map(async(o,i)=>await this.renderChoice(o,i)),t=await Promise.all(e);if(!t.length)t.push(this.styles.danger("No matching choices"));let s=this.margin[0]+t.join(`
|
|
12
12
|
`),r;if(this.options.choicesHeader)r=await this.resolve(this.options.choicesHeader,this.state);return[r,s].filter(Boolean).join(`
|
|
13
|
-
`)}format(){if(!this.state.submitted||this.state.cancelled)return"";if(Array.isArray(this.selected))return this.selected.map((e)=>this.styles.primary(e.name)).join(", ");return this.styles.primary(this.selected.name)}async render(){let{submitted:e,size:t}=this.state,s="",r=await this.header(),
|
|
14
|
-
`)),this.write(this.margin[2]),this.restore()}}
|
|
15
|
-
`)),this.restore()}set value(e){super.value=e}get value(){return this.cast(super.value)}}
|
|
16
|
-
`,t)}return super.keypress(e,t)}moveCursor(e){this.cursor+=e}reset(){return this.input=this.value="",this.cursor=0,this.render()}dispatch(e,t){if(!e||t.ctrl||t.code)return this.alert();this.append(e)}append(e){let{cursor:t,input:s}=this.state;this.input=`${s}`.slice(0,t)+e+`${s}`.slice(t),this.moveCursor(String(e).length),this.render()}insert(e){this.append(e)}delete(){let{cursor:e,input:t}=this.state;if(e<=0)return this.alert();this.input=`${t}`.slice(0,e-1)+`${t}`.slice(e),this.moveCursor(-1),this.render()}deleteForward(){let{cursor:e,input:t}=this.state;if(t[e]===void 0)return this.alert();this.input=`${t}`.slice(0,e)+`${t}`.slice(e+1),this.render()}cutForward(){let e=this.cursor;if(this.input.length<=e)return this.alert();this.state.clipboard.push(this.input.slice(e)),this.input=this.input.slice(0,e),this.render()}cutLeft(){let e=this.cursor;if(e===0)return this.alert();let t=this.input.slice(0,e),s=this.input.slice(e),r=t.split(" ");this.state.clipboard.push(r.pop()),this.input=r.join(" "),this.cursor=this.input.length,this.input+=s,this.render()}paste(){if(!this.state.clipboard.length)return this.alert();this.insert(this.state.clipboard.pop()),this.render()}toggleCursor(){if(this.state.prevCursor)this.cursor=this.state.prevCursor,this.state.prevCursor=0;else this.state.prevCursor=this.cursor,this.cursor=0;this.render()}first(){this.cursor=0,this.render()}last(){this.cursor=this.input.length-1,this.render()}next(){let e=this.initial!=null?String(this.initial):"";if(!e||!e.startsWith(this.input))return this.alert();this.input=this.initial,this.cursor=this.initial.length,this.render()}prev(){if(!this.input)return this.alert();this.reset()}backward(){return this.left()}forward(){return this.right()}right(){if(this.cursor>=this.input.length)return this.alert();return this.moveCursor(1),this.render()}left(){if(this.cursor<=0)return this.alert();return this.moveCursor(-1),this.render()}isValue(e){return!!e}async format(e=this.value){let t=await this.resolve(this.initial,this.state);if(!this.state.submitted)return
|
|
17
|
-
`)),this.restore()}}
|
|
13
|
+
`)}format(){if(!this.state.submitted||this.state.cancelled)return"";if(Array.isArray(this.selected))return this.selected.map((e)=>this.styles.primary(e.name)).join(", ");return this.styles.primary(this.selected.name)}async render(){let{submitted:e,size:t}=this.state,s="",r=await this.header(),o=await this.prefix(),i=await this.separator(),n=await this.message();if(this.options.promptLine!==!1)s=[o,n,i,""].join(" "),this.state.prompt=s;let a=await this.format(),l=await this.error()||await this.hint(),m=await this.renderChoices(),c=await this.footer();if(a)s+=a;if(l&&!s.includes(l))s+=" "+l;if(e&&!a&&!m.trim()&&this.multiple&&this.emptyError!=null)s+=this.styles.danger(this.emptyError);this.clear(t),this.write([r,s,m,c].filter(Boolean).join(`
|
|
14
|
+
`)),this.write(this.margin[2]),this.restore()}}Os.exports=Ds});var Ps=A((yp,Bs)=>{var ca=oe(),ha=(e,t)=>{let s=e?new RegExp(e,"ig"):/$^/;return(r)=>{return e?r.replace(s,(o)=>t(o)):r}};class Cs extends ca{constructor(e){super(e);this.cursorShow()}moveCursor(e){this.state.cursor+=e}dispatch(e){return this.append(e)}space(e){return this.options.multiple?super.space(e):this.append(e)}append(e){let{cursor:t,input:s}=this.state;return this.input=s.slice(0,t)+e+s.slice(t),this.moveCursor(1),this.complete()}delete(){let{cursor:e,input:t}=this.state;if(!t)return this.alert();return this.input=t.slice(0,e-1)+t.slice(e),this.moveCursor(-1),this.complete()}deleteForward(){let{cursor:e,input:t}=this.state;if(t[e]===void 0)return this.alert();return this.input=`${t}`.slice(0,e)+`${t}`.slice(e+1),this.complete()}number(e){return this.append(e)}async complete(){this.completing=!0,this.choices=await this.suggest(this.input,this.state._choices),this.state.limit=void 0,this.index=Math.min(Math.max(this.visible.length-1,0),this.index),await this.render(),this.completing=!1}suggest(e=this.input,t=this.state._choices){if(typeof this.options.suggest==="function")return this.options.suggest.call(this,e,t);let s=e.toLowerCase();return t.filter((r)=>r.message.toLowerCase().includes(s))}pointer(){return""}format(){if(!this.focused)return this.input;if(this.options.multiple&&this.state.submitted)return this.selected.map((e)=>this.styles.primary(e.message)).join(", ");if(this.state.submitted){let e=this.value=this.input=this.focused.value;return this.styles.primary(e)}return this.input}async render(){if(this.state.status!=="pending")return super.render();let e=this.options.highlight||this.styles.complement,t=(o,i)=>{if(!o)return o;if(e.stack)return e(o);return e.call(this,o)},s=ha(this.input,t),r=this.choices;this.choices=r.map((o)=>({...o,message:s(o.message)})),await super.render(),this.choices=r}submit(){if(this.options.multiple)this.value=this.selected.map((e)=>e.name);return super.submit()}}Bs.exports=Cs});var Et=A((gp,Ls)=>{var gt=R();Ls.exports=(e,t={})=>{e.cursorHide();let{input:s="",initial:r="",pos:o,showCursor:i=!0,color:n}=t,a=n||e.styles.placeholder,l=gt.inverse(e.styles.primary),m=(f)=>l(e.styles.black(f)),c=s,p=" ",u=m(p);if(e.blink&&e.blink.off===!0)m=(f)=>f,u="";if(i&&o===0&&r===""&&s==="")return m(p);if(i&&o===0&&(s===r||s===""))return m(r[0])+a(r.slice(1));r=gt.isPrimitive(r)?`${r}`:"",s=gt.isPrimitive(s)?`${s}`:"";let d=r&&r.startsWith(s)&&r!==s,h=d?m(r[s.length]):u;if(o!==s.length&&i===!0)c=s.slice(0,o)+m(s[o])+s.slice(o+1),h="";if(i===!1)h="";if(d){let f=e.styles.unstyle(c+h);return c+h+a(r.slice(f.length))}return c+h}});var De=A((Ep,$s)=>{var fa=se(),ya=oe(),ga=Et();class Is extends ya{constructor(e){super({...e,multiple:!0});this.type="form",this.initial=this.options.initial,this.align=[this.options.align,"right"].find((t)=>t!=null),this.emptyError="",this.values={}}async reset(e){if(await super.reset(),e===!0)this._index=this.index;return this.index=this._index,this.values={},this.choices.forEach((t)=>t.reset&&t.reset()),this.render()}dispatch(e){return!!e&&this.append(e)}append(e){let t=this.focused;if(!t)return this.alert();let{cursor:s,input:r}=t;return t.value=t.input=r.slice(0,s)+e+r.slice(s),t.cursor++,this.render()}delete(){let e=this.focused;if(!e||e.cursor<=0)return this.alert();let{cursor:t,input:s}=e;return e.value=e.input=s.slice(0,t-1)+s.slice(t),e.cursor--,this.render()}deleteForward(){let e=this.focused;if(!e)return this.alert();let{cursor:t,input:s}=e;if(s[t]===void 0)return this.alert();let r=`${s}`.slice(0,t)+`${s}`.slice(t+1);return e.value=e.input=r,this.render()}right(){let e=this.focused;if(!e)return this.alert();if(e.cursor>=e.input.length)return this.alert();return e.cursor++,this.render()}left(){let e=this.focused;if(!e)return this.alert();if(e.cursor<=0)return this.alert();return e.cursor--,this.render()}space(e,t){return this.dispatch(e,t)}number(e,t){return this.dispatch(e,t)}next(){let e=this.focused;if(!e)return this.alert();let{initial:t,input:s}=e;if(t&&t.startsWith(s)&&s!==t)return e.value=e.input=t,e.cursor=e.value.length,this.render();return super.next()}prev(){let e=this.focused;if(!e)return this.alert();if(e.cursor===0)return super.prev();return e.value=e.input="",e.cursor=0,this.render()}separator(){return""}format(e){return!this.state.submitted?super.format(e):""}pointer(){return""}indicator(e){return e.input?"\u29BF":"\u2299"}async choiceSeparator(e,t){let s=await this.resolve(e.separator,this.state,e,t)||":";return s?" "+this.styles.disabled(s):""}async renderChoice(e,t){await this.onChoice(e,t);let{state:s,styles:r}=this,{cursor:o,initial:i="",name:n,input:a=""}=e,{muted:l,submitted:m,primary:c,danger:p}=r,u=this.index===t,d=e.validate||(()=>!0),h=await this.choiceSeparator(e,t),f=e.message;if(this.align==="right")f=f.padStart(this.longest+1," ");if(this.align==="left")f=f.padEnd(this.longest+1," ");let x=this.values[n]=a||i,y=a?"success":"dark";if(await d.call(e,x,this.state)!==!0)y="danger";let b=r[y],w=b(await this.indicator(e,t))+(e.pad||""),_=this.indent(e),M=()=>[_,w,f+h,a].filter(Boolean).join(" ");if(s.submitted)return f=fa(f),a=m(a),M();if(e.format)a=await e.format.call(this,a,e,t);else{let D=this.styles.muted;a=ga(this,{input:a,initial:i,pos:o,showCursor:u,color:D})}if(!this.isValue(a))a=this.styles.muted(this.symbols.ellipsis);if(e.result)this.values[n]=await e.result.call(this,x,e,t);if(u)f=c(f);if(e.error)a+=(a?" ":"")+p(e.error.trim());else if(e.hint)a+=(a?" ":"")+l(e.hint.trim());return M()}async submit(){return this.value=this.values,super.base.submit.call(this)}}$s.exports=Is});var At=A((Ap,Gs)=>{var Ea=De(),Aa=()=>{throw Error("expected prompt to have a custom authenticate method")},Us=(e=Aa)=>{class t extends Ea{constructor(s){super(s)}async submit(){this.value=await e.call(this,this.values,this.state),super.base.submit.call(this)}static create(s){return Us(s)}}return t};Gs.exports=Us()});var Ks=A((bp,Ws)=>{var ba=At();function xa(e,t){if(e.username===this.options.username&&e.password===this.options.password)return!0;return!1}var qs=(e=xa)=>{let t=[{name:"username",message:"username"},{name:"password",message:"password",format(r){if(this.options.showPassword)return r;return(this.state.submitted?this.styles.primary:this.styles.muted)(this.symbols.asterisk.repeat(r.length))}}];class s extends ba.create(e){constructor(r){super({...r,choices:t})}static create(r){return qs(r)}}return s};Ws.exports=qs()});var Oe=A((xp,Ys)=>{var wa=pe(),{isPrimitive:Sa,hasColor:_a}=R();class Hs extends wa{constructor(e){super(e);this.cursorHide()}async initialize(){let e=await this.resolve(this.initial,this.state);this.input=await this.cast(e),await super.initialize()}dispatch(e){if(!this.isValue(e))return this.alert();return this.input=e,this.submit()}format(e){let{styles:t,state:s}=this;return!s.submitted?t.primary(e):t.success(e)}cast(e){return this.isTrue(e)}isTrue(e){return/^[ty1]/i.test(e)}isFalse(e){return/^[fn0]/i.test(e)}isValue(e){return Sa(e)&&(this.isTrue(e)||this.isFalse(e))}async hint(){if(this.state.status==="pending"){let e=await this.element("hint");if(!_a(e))return this.styles.muted(e);return e}}async render(){let{input:e,size:t}=this.state,s=await this.prefix(),r=await this.separator(),o=await this.message(),i=this.styles.muted(this.default),n=[s,o,i,r].filter(Boolean).join(" ");this.state.prompt=n;let a=await this.header(),l=this.value=this.cast(e),m=await this.format(l),c=await this.error()||await this.hint(),p=await this.footer();if(c&&!n.includes(c))m+=" "+c;n+=" "+m,this.clear(t),this.write([a,n,p].filter(Boolean).join(`
|
|
15
|
+
`)),this.restore()}set value(e){super.value=e}get value(){return this.cast(super.value)}}Ys.exports=Hs});var Qs=A((wp,Fs)=>{var Na=Oe();class Vs extends Na{constructor(e){super(e);this.default=this.options.default||(this.initial?"(Y/n)":"(y/N)")}}Fs.exports=Vs});var Xs=A((Sp,Zs)=>{var Ma=oe(),Ta=De(),ue=Ta.prototype;class zs extends Ma{constructor(e){super({...e,multiple:!0});this.align=[this.options.align,"left"].find((t)=>t!=null),this.emptyError="",this.values={}}dispatch(e,t){let s=this.focused,r=s.parent||{};if(!s.editable&&!r.editable){if(e==="a"||e==="i")return super[e]()}return ue.dispatch.call(this,e,t)}append(e,t){return ue.append.call(this,e,t)}delete(e,t){return ue.delete.call(this,e,t)}space(e){return this.focused.editable?this.append(e):super.space()}number(e){return this.focused.editable?this.append(e):super.number(e)}next(){return this.focused.editable?ue.next.call(this):super.next()}prev(){return this.focused.editable?ue.prev.call(this):super.prev()}async indicator(e,t){let s=e.indicator||"",r=e.editable?s:super.indicator(e,t);return await this.resolve(r,this.state,e,t)||""}indent(e){return e.role==="heading"?"":e.editable?" ":" "}async renderChoice(e,t){if(e.indent="",e.editable)return ue.renderChoice.call(this,e,t);return super.renderChoice(e,t)}error(){return""}footer(){return this.state.error}async validate(){let e=!0;for(let t of this.choices){if(typeof t.validate!=="function")continue;if(t.role==="heading")continue;let s=t.parent?this.value[t.parent.name]:this.value;if(t.editable)s=t.value===t.name?t.initial||"":t.value;else if(!this.isDisabled(t))s=t.enabled===!0;if(e=await t.validate(s,this.state),e!==!0)break}if(e!==!0)this.state.error=typeof e==="string"?e:"Invalid Input";return e}submit(){if(this.focused.newChoice===!0)return super.submit();if(this.choices.some((e)=>e.newChoice))return this.alert();this.value={};for(let e of this.choices){let t=e.parent?this.value[e.parent.name]:this.value;if(e.role==="heading"){this.value[e.name]={};continue}if(e.editable)t[e.name]=e.value===e.name?e.initial||"":e.value;else if(!this.isDisabled(e))t[e.name]=e.enabled===!0}return this.base.submit.call(this)}}Zs.exports=zs});var me=A((_p,js)=>{var va=pe(),Ra=it(),Da=Et(),{isPrimitive:Oa}=R();class Js extends va{constructor(e){super(e);if(this.initial=Oa(this.initial)?String(this.initial):"",this.initial)this.cursorHide();this.state.prevCursor=0,this.state.clipboard=[],this.keypressTimeout=this.options.keypressTimeout!==void 0?this.options.keypressTimeout:null}async keypress(e,t=e?Ra(e,{}):{}){let s=Date.now(),r=s-this.lastKeypress;this.lastKeypress=s;let o=t.name==="return"||t.name==="enter",i=this.state.prevKeypress,n;if(this.state.prevKeypress=t,this.keypressTimeout!=null&&o){if(r<this.keypressTimeout)return this.submit();this.state.multilineBuffer=this.state.multilineBuffer||"",this.state.multilineBuffer+=e,n=!0,i=null}if(n||this.options.multiline&&o){if(!i||i.name!=="return")return this.append(`
|
|
16
|
+
`,t)}return super.keypress(e,t)}moveCursor(e){this.cursor+=e}reset(){return this.input=this.value="",this.cursor=0,this.render()}dispatch(e,t){if(!e||t.ctrl||t.code)return this.alert();this.append(e)}append(e){let{cursor:t,input:s}=this.state;this.input=`${s}`.slice(0,t)+e+`${s}`.slice(t),this.moveCursor(String(e).length),this.render()}insert(e){this.append(e)}delete(){let{cursor:e,input:t}=this.state;if(e<=0)return this.alert();this.input=`${t}`.slice(0,e-1)+`${t}`.slice(e),this.moveCursor(-1),this.render()}deleteForward(){let{cursor:e,input:t}=this.state;if(t[e]===void 0)return this.alert();this.input=`${t}`.slice(0,e)+`${t}`.slice(e+1),this.render()}cutForward(){let e=this.cursor;if(this.input.length<=e)return this.alert();this.state.clipboard.push(this.input.slice(e)),this.input=this.input.slice(0,e),this.render()}cutLeft(){let e=this.cursor;if(e===0)return this.alert();let t=this.input.slice(0,e),s=this.input.slice(e),r=t.split(" ");this.state.clipboard.push(r.pop()),this.input=r.join(" "),this.cursor=this.input.length,this.input+=s,this.render()}paste(){if(!this.state.clipboard.length)return this.alert();this.insert(this.state.clipboard.pop()),this.render()}toggleCursor(){if(this.state.prevCursor)this.cursor=this.state.prevCursor,this.state.prevCursor=0;else this.state.prevCursor=this.cursor,this.cursor=0;this.render()}first(){this.cursor=0,this.render()}last(){this.cursor=this.input.length-1,this.render()}next(){let e=this.initial!=null?String(this.initial):"";if(!e||!e.startsWith(this.input))return this.alert();this.input=this.initial,this.cursor=this.initial.length,this.render()}prev(){if(!this.input)return this.alert();this.reset()}backward(){return this.left()}forward(){return this.right()}right(){if(this.cursor>=this.input.length)return this.alert();return this.moveCursor(1),this.render()}left(){if(this.cursor<=0)return this.alert();return this.moveCursor(-1),this.render()}isValue(e){return!!e}async format(e=this.value){let t=await this.resolve(this.initial,this.state);if(!this.state.submitted)return Da(this,{input:e,initial:t,pos:this.cursor});return this.styles.submitted(e||t)}async render(){let e=this.state.size,t=await this.prefix(),s=await this.separator(),r=await this.message(),o=[t,r,s].filter(Boolean).join(" ");this.state.prompt=o;let i=await this.header(),n=await this.format(),a=await this.error()||await this.hint(),l=await this.footer();if(a&&!n.includes(a))n+=" "+a;o+=" "+n,this.clear(e),this.write([i,o,l].filter(Boolean).join(`
|
|
17
|
+
`)),this.restore()}}js.exports=Js});var er=A((Np,ks)=>{var Ca=(e)=>e.filter((t,s)=>e.lastIndexOf(t)===s),Ce=(e)=>Ca(e).filter(Boolean);ks.exports=(e,t={},s="")=>{let{past:r=[],present:o=""}=t,i,n;switch(e){case"prev":case"undo":return i=r.slice(0,r.length-1),n=r[r.length-1]||"",{past:Ce([s,...i]),present:n};case"next":case"redo":return i=r.slice(1),n=r[0]||"",{past:Ce([...i,s]),present:n};case"save":return{past:Ce([...r,s]),present:""};case"remove":if(n=Ce(r.filter((a)=>a!==s)),o="",n.length)o=n.pop();return{past:n,present:o};default:throw Error(`Invalid action: "${e}"`)}}});var bt=A((Mp,rr)=>{var Ba=me(),tr=er();class sr extends Ba{constructor(e){super(e);let t=this.options.history;if(t&&t.store){let s=t.values||this.initial;this.autosave=!!t.autosave,this.store=t.store,this.data=this.store.get("values")||{past:[],present:s},this.initial=this.data.present||this.data.past[this.data.past.length-1]}}completion(e){if(!this.store)return this.alert();if(this.data=tr(e,this.data,this.input),!this.data.present)return this.alert();return this.input=this.data.present,this.cursor=this.input.length,this.render()}altUp(){return this.completion("prev")}altDown(){return this.completion("next")}prev(){return this.save(),super.prev()}save(){if(!this.store)return;this.data=tr("save",this.data,this.input),this.store.set("values",this.data)}submit(){if(this.store&&this.autosave===!0)this.save();return super.submit()}}rr.exports=sr});var nr=A((Tp,ir)=>{var Pa=me();class or extends Pa{format(){return""}}ir.exports=or});var mr=A((vp,lr)=>{var La=me();class ar extends La{constructor(e={}){super(e);this.sep=this.options.separator||/, */,this.initial=e.initial||""}split(e=this.value){return e?String(e).split(this.sep):[]}format(){let e=this.state.submitted?this.styles.primary:(t)=>t;return this.list.map(e).join(", ")}async submit(e){let t=this.state.error||await this.validate(this.list,this.state);if(t!==!0)return this.state.error=t,super.submit();return this.value=this.list,super.submit()}get list(){return this.split()}}lr.exports=ar});var ur=A((Rp,pr)=>{var Ia=oe();class dr extends Ia{constructor(e){super({...e,multiple:!0})}}pr.exports=dr});var xt=A((Dp,hr)=>{var $a=me();class cr extends $a{constructor(e={}){super({style:"number",...e});this.min=this.isValue(e.min)?this.toNumber(e.min):-1/0,this.max=this.isValue(e.max)?this.toNumber(e.max):1/0,this.delay=e.delay!=null?e.delay:1000,this.float=e.float!==!1,this.round=e.round===!0||e.float===!1,this.major=e.major||10,this.minor=e.minor||1,this.initial=e.initial!=null?e.initial:"",this.input=String(this.initial),this.cursor=this.input.length,this.cursorShow()}append(e){if(!/[-+.]/.test(e)||e==="."&&this.input.includes("."))return this.alert("invalid number");return super.append(e)}number(e){return super.append(e)}next(){if(this.input&&this.input!==this.initial)return this.alert();if(!this.isValue(this.initial))return this.alert();return this.input=this.initial,this.cursor=String(this.initial).length,this.render()}up(e){let t=e||this.minor,s=this.toNumber(this.input);if(s>this.max+t)return this.alert();return this.input=`${s+t}`,this.render()}down(e){let t=e||this.minor,s=this.toNumber(this.input);if(s<this.min-t)return this.alert();return this.input=`${s-t}`,this.render()}shiftDown(){return this.down(this.major)}shiftUp(){return this.up(this.major)}format(e=this.input){if(typeof this.options.format==="function")return this.options.format.call(this,e);return this.styles.info(e)}toNumber(e=""){return this.float?+e:Math.round(+e)}isValue(e){return/^[-+]?[0-9]+((\.)|(\.[0-9]+))?$/.test(e)}submit(){let e=[this.input,this.initial].find((t)=>this.isValue(t));return this.value=this.toNumber(e||0),super.submit()}}hr.exports=cr});var gr=A((Op,yr)=>{var Ua=me();class fr extends Ua{constructor(e){super(e);this.cursorShow()}format(e=this.input){if(!this.keypressed)return"";return(this.state.submitted?this.styles.primary:this.styles.muted)(this.symbols.asterisk.repeat(e.length))}}yr.exports=fr});var xr=A((Cp,br)=>{var Ga=se(),qa=Ee(),Er=R();class Ar extends qa{constructor(e={}){super(e);this.widths=[].concat(e.messageWidth||50),this.align=[].concat(e.align||"left"),this.linebreak=e.linebreak||!1,this.edgeLength=e.edgeLength||3,this.newline=e.newline||`
|
|
18
18
|
`;let t=e.startNumber||1;if(typeof this.scale==="number")this.scaleKey=!1,this.scale=Array(this.scale).fill(0).map((s,r)=>({name:r+t}))}async reset(){return this.tableized=!1,await super.reset(),this.render()}tableize(){if(this.tableized===!0)return;this.tableized=!0;let e=0;for(let t of this.choices){e=Math.max(e,t.message.length),t.scaleIndex=t.initial||2,t.scale=[];for(let s=0;s<this.scale.length;s++)t.scale.push({index:s})}this.widths[0]=Math.min(this.widths[0],e+3)}async dispatch(e,t){if(this.multiple)return this[t.name]?await this[t.name](e,t):await super.dispatch(e,t);this.alert()}heading(e,t,s){return this.styles.strong(e)}separator(){return this.styles.muted(this.symbols.ellipsis)}right(){let e=this.focused;if(e.scaleIndex>=this.scale.length-1)return this.alert();return e.scaleIndex++,this.render()}left(){let e=this.focused;if(e.scaleIndex<=0)return this.alert();return e.scaleIndex--,this.render()}indent(){return""}format(){if(this.state.submitted)return this.choices.map((t)=>this.styles.info(t.index)).join(", ");return""}pointer(){return""}renderScaleKey(){if(this.scaleKey===!1)return"";if(this.state.submitted)return"";return["",...this.scale.map((s)=>` ${s.name} - ${s.message}`)].map((s)=>this.styles.muted(s)).join(`
|
|
19
|
-
`)}renderScaleHeading(e){let t=this.scale.map((a)=>a.name);if(typeof this.options.renderScaleHeading==="function")t=this.options.renderScaleHeading.call(this,e);let s=this.scaleLength-t.join("").length,r=Math.round(s/(t.length-1)),
|
|
20
|
-
`).map((
|
|
21
|
-
`)].filter(Boolean)}async renderChoices(){if(this.state.submitted)return"";this.tableize();let e=this.visible.map(async(r,
|
|
22
|
-
`)}async render(){let{submitted:e,size:t}=this.state,s=await this.prefix(),r=await this.separator(),
|
|
23
|
-
`)),!this.state.submitted)this.write(this.margin[2]);this.restore()}submit(){this.value={};for(let e of this.choices)this.value[e.name]=e.scaleIndex;return this.base.submit.call(this)}}
|
|
24
|
-
`){
|
|
25
|
-
`).map((b)=>" "+b),
|
|
26
|
-
`),
|
|
27
|
-
`].find((
|
|
28
|
-
`;return this.state.error=n,super.submit()}if(t.size)return this.state.error="Required: "+[...t.keys()].join(", "),super.submit();let
|
|
19
|
+
`)}renderScaleHeading(e){let t=this.scale.map((a)=>a.name);if(typeof this.options.renderScaleHeading==="function")t=this.options.renderScaleHeading.call(this,e);let s=this.scaleLength-t.join("").length,r=Math.round(s/(t.length-1)),i=t.map((a)=>this.styles.strong(a)).join(" ".repeat(r)),n=" ".repeat(this.widths[0]);return this.margin[3]+n+this.margin[1]+i}scaleIndicator(e,t,s){if(typeof this.options.scaleIndicator==="function")return this.options.scaleIndicator.call(this,e,t,s);let r=e.scaleIndex===t.index;if(t.disabled)return this.styles.hint(this.symbols.radio.disabled);if(r)return this.styles.success(this.symbols.radio.on);return this.symbols.radio.off}renderScale(e,t){let s=e.scale.map((o)=>this.scaleIndicator(e,o,t)),r=this.term==="Hyper"?"":" ";return s.join(r+this.symbols.line.repeat(this.edgeLength))}async renderChoice(e,t){await this.onChoice(e,t);let s=this.index===t,r=await this.pointer(e,t),o=await e.hint;if(o&&!Er.hasColor(o))o=this.styles.muted(o);let i=(d)=>this.margin[3]+d.replace(/\s+$/,"").padEnd(this.widths[0]," "),n=this.newline,a=this.indent(e),l=await this.resolve(e.message,this.state,e,t),m=await this.renderScale(e,t),c=this.margin[1]+this.margin[3];this.scaleLength=Ga(m).length,this.widths[0]=Math.min(this.widths[0],this.width-this.scaleLength-c.length);let u=Er.wordWrap(l,{width:this.widths[0],newline:n}).split(`
|
|
20
|
+
`).map((d)=>i(d)+this.margin[1]);if(s)m=this.styles.info(m),u=u.map((d)=>this.styles.info(d));if(u[0]+=m,this.linebreak)u.push("");return[a+r,u.join(`
|
|
21
|
+
`)].filter(Boolean)}async renderChoices(){if(this.state.submitted)return"";this.tableize();let e=this.visible.map(async(r,o)=>await this.renderChoice(r,o)),t=await Promise.all(e),s=await this.renderScaleHeading();return this.margin[0]+[s,...t.map((r)=>r.join(" "))].join(`
|
|
22
|
+
`)}async render(){let{submitted:e,size:t}=this.state,s=await this.prefix(),r=await this.separator(),o=await this.message(),i="";if(this.options.promptLine!==!1)i=[s,o,r,""].join(" "),this.state.prompt=i;let n=await this.header(),a=await this.format(),l=await this.renderScaleKey(),m=await this.error()||await this.hint(),c=await this.renderChoices(),p=await this.footer(),u=this.emptyError;if(a)i+=a;if(m&&!i.includes(m))i+=" "+m;if(e&&!a&&!c.trim()&&this.multiple&&u!=null)i+=this.styles.danger(u);if(this.clear(t),this.write([n,i,l,c,p].filter(Boolean).join(`
|
|
23
|
+
`)),!this.state.submitted)this.write(this.margin[2]);this.restore()}submit(){this.value={};for(let e of this.choices)this.value[e.name]=e.scaleIndex;return this.base.submit.call(this)}}br.exports=Ar});var Nr=A((Bp,_r)=>{var wr=se(),Wa=(e="")=>{return typeof e==="string"?e.replace(/^['"]|['"]$/g,""):""};class Sr{constructor(e){this.name=e.key,this.field=e.field||{},this.value=Wa(e.initial||this.field.initial||""),this.message=e.message||this.name,this.cursor=0,this.input="",this.lines=[]}}var Ka=async(e={},t={},s=(r)=>r)=>{let r=new Set,o=e.fields||[],i=e.template,n=[],a=[],l=[],m=1;if(typeof i==="function")i=await i();let c=-1,p=()=>i[++c],u=()=>i[c+1],d=(h)=>{h.line=m,n.push(h)};d({type:"bos",value:""});while(c<i.length-1){let h=p();if(/^[^\S\n ]$/.test(h)){d({type:"text",value:h});continue}if(h===`
|
|
24
|
+
`){d({type:"newline",value:h}),m++;continue}if(h==="\\"){h+=p(),d({type:"text",value:h});continue}if((h==="$"||h==="#"||h==="{")&&u()==="{"){let x=p();h+=x;let y={type:"template",open:h,inner:"",close:"",value:h},b;while(b=p()){if(b==="}"){if(u()==="}")b+=p();y.value+=b,y.close=b;break}if(b===":")y.initial="",y.key=y.inner;else if(y.initial!==void 0)y.initial+=b;y.value+=b,y.inner+=b}if(y.template=y.open+(y.initial||y.inner)+y.close,y.key=y.key||y.inner,hasOwnProperty.call(t,y.key))y.initial=t[y.key];y=s(y),d(y),l.push(y.key),r.add(y.key);let w=a.find((_)=>_.name===y.key);if(y.field=o.find((_)=>_.name===y.key),!w)w=new Sr(y),a.push(w);w.lines.push(y.line-1);continue}let f=n[n.length-1];if(f.type==="text"&&f.line===m)f.value+=h;else d({type:"text",value:h})}return d({type:"eos",value:""}),{input:i,tabstops:n,unique:r,keys:l,items:a}};_r.exports=async(e)=>{let t=e.options,s=new Set(t.required===!0?[]:t.required||[]),r={...t.values,...t.initial},{tabstops:o,items:i,keys:n}=await Ka(t,r),a=wt("result",e,t),l=wt("format",e,t),m=wt("validate",e,t,!0),c=e.isValue.bind(e);return async(p={},u=!1)=>{let d=0;p.required=s,p.items=i,p.keys=n,p.output="";let h=async(b,w,_,M)=>{let D=await m(b,w,_,M);if(D===!1)return"Invalid field "+_.name;return D};for(let b of o){let{value:w,key:_}=b;if(b.type!=="template"){if(w)p.output+=w;continue}if(b.type==="template"){let M=i.find((de)=>de.name===_);if(t.required===!0)p.required.add(M.name);let D=[M.input,p.values[M.value],M.value,w].find(c),ee=(M.field||{}).message||b.inner;if(u){let de=await h(p.values[_],p,M,d);if(de&&typeof de==="string"||de===!1){p.invalid.set(_,de);continue}p.invalid.delete(_);let Gi=await a(p.values[_],p,M,d);p.output+=wr(Gi);continue}M.placeholder=!1;let Ui=w;if(w=await l(w,p,M,d),D!==w)p.values[_]=D,w=e.styles.typing(D),p.missing.delete(ee);else if(p.values[_]=void 0,D=`<${ee}>`,w=e.styles.primary(D),M.placeholder=!0,p.required.has(_))p.missing.add(ee);if(p.missing.has(ee)&&p.validating)w=e.styles.warning(D);if(p.invalid.has(_)&&p.validating)w=e.styles.danger(D);if(d===p.index)if(Ui!==w)w=e.styles.underline(w);else w=e.styles.heading(wr(w));d++}if(w)p.output+=w}let f=p.output.split(`
|
|
25
|
+
`).map((b)=>" "+b),x=i.length,y=0;for(let b of i){if(p.invalid.has(b.name))b.lines.forEach((w)=>{if(f[w][0]!==" ")return;f[w]=p.styles.danger(p.symbols.bullet)+f[w].slice(1)});if(e.isValue(p.values[b.name]))y++}return p.completed=(y/x*100).toFixed(0),p.output=f.join(`
|
|
26
|
+
`),p.output}};function wt(e,t,s,r){return(o,i,n,a)=>{if(typeof n.field[e]==="function")return n.field[e].call(t,o,i,n,a);return[r,o].find((l)=>t.isValue(l))}}});var vr=A((Pp,Tr)=>{var Ha=se(),Ya=Nr(),Va=pe();class Mr extends Va{constructor(e){super(e);this.cursorHide(),this.reset(!0)}async initialize(){this.interpolate=await Ya(this),await super.initialize()}async reset(e){if(this.state.keys=[],this.state.invalid=new Map,this.state.missing=new Set,this.state.completed=0,this.state.values={},e!==!0)await this.initialize(),await this.render()}moveCursor(e){let t=this.getItem();this.cursor+=e,t.cursor+=e}dispatch(e,t){if(!t.code&&!t.ctrl&&e!=null&&this.getItem()){this.append(e,t);return}this.alert()}append(e,t){let s=this.getItem(),r=s.input.slice(0,this.cursor),o=s.input.slice(this.cursor);this.input=s.input=`${r}${e}${o}`,this.moveCursor(1),this.render()}delete(){let e=this.getItem();if(this.cursor<=0||!e.input)return this.alert();let t=e.input.slice(this.cursor),s=e.input.slice(0,this.cursor-1);this.input=e.input=`${s}${t}`,this.moveCursor(-1),this.render()}increment(e){return e>=this.state.keys.length-1?0:e+1}decrement(e){return e<=0?this.state.keys.length-1:e-1}first(){this.state.index=0,this.render()}last(){this.state.index=this.state.keys.length-1,this.render()}right(){if(this.cursor>=this.input.length)return this.alert();this.moveCursor(1),this.render()}left(){if(this.cursor<=0)return this.alert();this.moveCursor(-1),this.render()}prev(){this.state.index=this.decrement(this.state.index),this.getItem(),this.render()}next(){this.state.index=this.increment(this.state.index),this.getItem(),this.render()}up(){this.prev()}down(){this.next()}format(e){let t=this.state.completed<100?this.styles.warning:this.styles.success;if(this.state.submitted===!0&&this.state.completed!==100)t=this.styles.danger;return t(`${this.state.completed}% completed`)}async render(){let{index:e,keys:t=[],submitted:s,size:r}=this.state,o=[this.options.newline,`
|
|
27
|
+
`].find((y)=>y!=null),i=await this.prefix(),n=await this.separator(),a=await this.message(),l=[i,a,n].filter(Boolean).join(" ");this.state.prompt=l;let m=await this.header(),c=await this.error()||"",p=await this.hint()||"",u=s?"":await this.interpolate(this.state),d=this.state.key=t[e]||"",h=await this.format(d),f=await this.footer();if(h)l+=" "+h;if(p&&!h&&this.state.completed===0)l+=" "+p;this.clear(r);let x=[m,l,u,f,c.trim()];this.write(x.filter(Boolean).join(o)),this.restore()}getItem(e){let{items:t,keys:s,index:r}=this.state,o=t.find((i)=>i.name===s[r]);if(o&&o.input!=null)this.input=o.input,this.cursor=o.cursor;return o}async submit(){if(typeof this.interpolate!=="function")await this.initialize();await this.interpolate(this.state,!0);let{invalid:e,missing:t,output:s,values:r}=this.state;if(e.size){let n="";for(let[a,l]of e)n+=`Invalid ${a}: ${l}
|
|
28
|
+
`;return this.state.error=n,super.submit()}if(t.size)return this.state.error="Required: "+[...t.keys()].join(", "),super.submit();let i=Ha(s).split(`
|
|
29
29
|
`).map((n)=>n.slice(1)).join(`
|
|
30
|
-
`);return this.value={values:r,result:
|
|
31
|
-
`)}}async toChoices(...e){if(this.createdScales)return!1;this.createdScales=!0;let t=await super.toChoices(...e);for(let s of t)s.scale=
|
|
32
|
-
`);if(s)
|
|
33
|
-
`)}format(){if(this.state.submitted)return this.choices.map((t)=>this.styles.info(t.scaleIdx)).join(", ");return""}async render(){let{submitted:e,size:t}=this.state,s=await this.prefix(),r=await this.separator(),
|
|
34
|
-
`)),this.restore()}submit(){this.value={};for(let e of this.choices)this.value[e.name]=e.scaleIdx;return this.base.submit.call(this)}}function
|
|
35
|
-
`)),this.write(this.margin[2]),this.restore()}}Or.exports=Br});var $r=A((Dm,Lr)=>{var Va=Q();class Ir extends Va{constructor(e){super(e);if(typeof this.options.correctChoice!=="number"||this.options.correctChoice<0)throw Error("Please specify the index of the correct answer from the list of choices")}async toChoices(e,t){let s=await super.toChoices(e,t);if(s.length<2)throw Error("Please give at least two choices to the user");if(this.options.correctChoice>s.length)throw Error("Please specify the index of the correct answer from the list of choices");return s}check(e){return e.index===this.options.correctChoice}async result(e){return{selectedAnswer:e,correctAnswer:this.options.choices[this.options.correctChoice].value,correct:await this.check(this.state)}}}Lr.exports=Ir});var Ur=A((xt)=>{var Gr=R(),M=(e,t)=>{Gr.defineExport(xt,e,t),Gr.defineExport(xt,e.toLowerCase(),t)};M("AutoComplete",()=>Ds());M("BasicAuth",()=>Us());M("Confirm",()=>Ys());M("Editable",()=>Qs());M("Form",()=>Re());M("Input",()=>At());M("Invisible",()=>rr());M("List",()=>nr());M("MultiSelect",()=>lr());M("Numeral",()=>bt());M("Password",()=>hr());M("Scale",()=>Er());M("Select",()=>Q());M("Snippet",()=>Mr());M("Sort",()=>vr());M("Survey",()=>Dr());M("Text",()=>At());M("Toggle",()=>Pr());M("Quiz",()=>$r())});var Kr=A((Om,qr)=>{qr.exports={ArrayPrompt:ge(),AuthPrompt:Et(),BooleanPrompt:Ce(),NumberPrompt:bt(),StringPrompt:pe()}});var Z=A((Pm,Wr)=>{var Hr=he("assert"),Nt=he("events"),z=R();class $ extends Nt{constructor(e,t){super();this.options=z.merge({},e),this.answers={...t}}register(e,t){if(z.isObject(e)){for(let r of Object.keys(e))this.register(r,e[r]);return this}Hr.equal(typeof t,"function","expected a function");let s=e.toLowerCase();if(t.prototype instanceof this.Prompt)this.prompts[s]=t;else this.prompts[s]=t(this.Prompt,this);return this}async prompt(e=[]){for(let t of[].concat(e))try{if(typeof t==="function")t=await t.call(this);await this.ask(z.merge({},this.options,t))}catch(s){return Promise.reject(s)}return this.answers}async ask(e){if(typeof e==="function")e=await e.call(this);let t=z.merge({},this.options,e),{type:s,name:r}=e,{set:i,get:o}=z;if(typeof s==="function")s=await s.call(this,e,this.answers);if(!s)return this.answers[r];if(s==="number")s="numeral";Hr(this.prompts[s],`Prompt "${s}" is not registered`);let n=new this.prompts[s](t),a=o(this.answers,r);if(n.state.answers=this.answers,n.enquirer=this,r)n.on("submit",(l)=>{this.emit("answer",r,l,n),i(this.answers,r,l)});let p=n.emit.bind(n);if(n.emit=(...l)=>{return this.emit.call(this,...l),p(...l)},this.emit("prompt",n,this),t.autofill&&a!=null){if(n.value=n.input=a,t.autofill==="show")await n.submit()}else a=n.value=await n.run();return a}use(e){return e.call(this,this),this}set Prompt(e){this._Prompt=e}get Prompt(){return this._Prompt||this.constructor.Prompt}get prompts(){return this.constructor.prompts}static set Prompt(e){this._Prompt=e}static get Prompt(){return this._Prompt||ce()}static get prompts(){return Ur()}static get types(){return Kr()}static get prompt(){let e=(t,...s)=>{let r=new this(...s),i=r.emit.bind(r);return r.emit=(...o)=>{return e.emit(...o),i(...o)},r.prompt(t)};return z.mixinEmitter(e,new Nt),e}}z.mixinEmitter($,new Nt);var St=$.prompts;for(let e of Object.keys(St)){let t=e.toLowerCase(),s=(r)=>new St[e](r).run();if($.prompt[t]=s,$[t]=s,!$[e])Reflect.defineProperty($,e,{get:()=>St[e]})}var Ee=(e)=>{z.defineExport($,e,()=>$.types[e])};Ee("ArrayPrompt");Ee("AuthPrompt");Ee("BooleanPrompt");Ee("NumberPrompt");Ee("StringPrompt");Wr.exports=$});var eo=A((Ct,Dt)=>{(function(e,t){if(typeof Ct==="object"&&typeof Dt==="object")Dt.exports=t();else if(typeof define==="function"&&define.amd)define(function(){return t()});else e.pluralize=t()})(Ct,function(){var e=[],t=[],s={},r={},i={};function o(m){if(typeof m==="string")return new RegExp("^"+m+"$","i");return m}function n(m,u){if(m===u)return u;if(m===m.toLowerCase())return u.toLowerCase();if(m===m.toUpperCase())return u.toUpperCase();if(m[0]===m[0].toUpperCase())return u.charAt(0).toUpperCase()+u.substr(1).toLowerCase();return u.toLowerCase()}function a(m,u){return m.replace(/\$(\d{1,2})/g,function(y,S){return u[S]||""})}function p(m,u){return m.replace(u[0],function(y,S){var f=a(u[1],arguments);if(y==="")return n(m[S-1],f);return n(y,f)})}function l(m,u,y){if(!m.length||s.hasOwnProperty(m))return u;var S=y.length;while(S--){var f=y[S];if(f[0].test(u))return p(u,f)}return u}function c(m,u,y){return function(S){var f=S.toLowerCase();if(u.hasOwnProperty(f))return n(S,f);if(m.hasOwnProperty(f))return n(S,m[f]);return l(f,S,y)}}function d(m,u,y,S){return function(f){var b=f.toLowerCase();if(u.hasOwnProperty(b))return!0;if(m.hasOwnProperty(b))return!1;return l(b,b,y)===b}}function h(m,u,y){var S=u===1?h.singular(m):h.plural(m);return(y?u+" ":"")+S}return h.plural=c(i,r,e),h.isPlural=d(i,r,e),h.singular=c(r,i,t),h.isSingular=d(r,i,t),h.addPluralRule=function(m,u){e.push([o(m),u])},h.addSingularRule=function(m,u){t.push([o(m),u])},h.addUncountableRule=function(m){if(typeof m==="string"){s[m.toLowerCase()]=!0;return}h.addPluralRule(m,"$0"),h.addSingularRule(m,"$0")},h.addIrregularRule=function(m,u){u=u.toLowerCase(),m=m.toLowerCase(),i[m]=u,r[u]=m},[["I","we"],["me","us"],["he","they"],["she","they"],["them","them"],["myself","ourselves"],["yourself","yourselves"],["itself","themselves"],["herself","themselves"],["himself","themselves"],["themself","themselves"],["is","are"],["was","were"],["has","have"],["this","these"],["that","those"],["echo","echoes"],["dingo","dingoes"],["volcano","volcanoes"],["tornado","tornadoes"],["torpedo","torpedoes"],["genus","genera"],["viscus","viscera"],["stigma","stigmata"],["stoma","stomata"],["dogma","dogmata"],["lemma","lemmata"],["schema","schemata"],["anathema","anathemata"],["ox","oxen"],["axe","axes"],["die","dice"],["yes","yeses"],["foot","feet"],["eave","eaves"],["goose","geese"],["tooth","teeth"],["quiz","quizzes"],["human","humans"],["proof","proofs"],["carve","carves"],["valve","valves"],["looey","looies"],["thief","thieves"],["groove","grooves"],["pickaxe","pickaxes"],["passerby","passersby"]].forEach(function(m){return h.addIrregularRule(m[0],m[1])}),[[/s?$/i,"s"],[/[^\u0000-\u007F]$/i,"$0"],[/([^aeiou]ese)$/i,"$1"],[/(ax|test)is$/i,"$1es"],[/(alias|[^aou]us|t[lm]as|gas|ris)$/i,"$1es"],[/(e[mn]u)s?$/i,"$1s"],[/([^l]ias|[aeiou]las|[ejzr]as|[iu]am)$/i,"$1"],[/(alumn|syllab|vir|radi|nucle|fung|cact|stimul|termin|bacill|foc|uter|loc|strat)(?:us|i)$/i,"$1i"],[/(alumn|alg|vertebr)(?:a|ae)$/i,"$1ae"],[/(seraph|cherub)(?:im)?$/i,"$1im"],[/(her|at|gr)o$/i,"$1oes"],[/(agend|addend|millenni|dat|extrem|bacteri|desiderat|strat|candelabr|errat|ov|symposi|curricul|automat|quor)(?:a|um)$/i,"$1a"],[/(apheli|hyperbat|periheli|asyndet|noumen|phenomen|criteri|organ|prolegomen|hedr|automat)(?:a|on)$/i,"$1a"],[/sis$/i,"ses"],[/(?:(kni|wi|li)fe|(ar|l|ea|eo|oa|hoo)f)$/i,"$1$2ves"],[/([^aeiouy]|qu)y$/i,"$1ies"],[/([^ch][ieo][ln])ey$/i,"$1ies"],[/(x|ch|ss|sh|zz)$/i,"$1es"],[/(matr|cod|mur|sil|vert|ind|append)(?:ix|ex)$/i,"$1ices"],[/\b((?:tit)?m|l)(?:ice|ouse)$/i,"$1ice"],[/(pe)(?:rson|ople)$/i,"$1ople"],[/(child)(?:ren)?$/i,"$1ren"],[/eaux$/i,"$0"],[/m[ae]n$/i,"men"],["thou","you"]].forEach(function(m){return h.addPluralRule(m[0],m[1])}),[[/s$/i,""],[/(ss)$/i,"$1"],[/(wi|kni|(?:after|half|high|low|mid|non|night|[^\w]|^)li)ves$/i,"$1fe"],[/(ar|(?:wo|[ae])l|[eo][ao])ves$/i,"$1f"],[/ies$/i,"y"],[/\b([pl]|zomb|(?:neck|cross)?t|coll|faer|food|gen|goon|group|lass|talk|goal|cut)ies$/i,"$1ie"],[/\b(mon|smil)ies$/i,"$1ey"],[/\b((?:tit)?m|l)ice$/i,"$1ouse"],[/(seraph|cherub)im$/i,"$1"],[/(x|ch|ss|sh|zz|tto|go|cho|alias|[^aou]us|t[lm]as|gas|(?:her|at|gr)o|[aeiou]ris)(?:es)?$/i,"$1"],[/(analy|diagno|parenthe|progno|synop|the|empha|cri|ne)(?:sis|ses)$/i,"$1sis"],[/(movie|twelve|abuse|e[mn]u)s$/i,"$1"],[/(test)(?:is|es)$/i,"$1is"],[/(alumn|syllab|vir|radi|nucle|fung|cact|stimul|termin|bacill|foc|uter|loc|strat)(?:us|i)$/i,"$1us"],[/(agend|addend|millenni|dat|extrem|bacteri|desiderat|strat|candelabr|errat|ov|symposi|curricul|quor)a$/i,"$1um"],[/(apheli|hyperbat|periheli|asyndet|noumen|phenomen|criteri|organ|prolegomen|hedr|automat)a$/i,"$1on"],[/(alumn|alg|vertebr)ae$/i,"$1a"],[/(cod|mur|sil|vert|ind)ices$/i,"$1ex"],[/(matr|append)ices$/i,"$1ix"],[/(pe)(rson|ople)$/i,"$1rson"],[/(child)ren$/i,"$1"],[/(eau)x?$/i,"$1"],[/men$/i,"man"]].forEach(function(m){return h.addSingularRule(m[0],m[1])}),["adulthood","advice","agenda","aid","aircraft","alcohol","ammo","analytics","anime","athletics","audio","bison","blood","bream","buffalo","butter","carp","cash","chassis","chess","clothing","cod","commerce","cooperation","corps","debris","diabetes","digestion","elk","energy","equipment","excretion","expertise","firmware","flounder","fun","gallows","garbage","graffiti","hardware","headquarters","health","herpes","highjinks","homework","housework","information","jeans","justice","kudos","labour","literature","machinery","mackerel","mail","media","mews","moose","music","mud","manga","news","only","personnel","pike","plankton","pliers","police","pollution","premises","rain","research","rice","salmon","scissors","series","sewage","shambles","shrimp","software","species","staff","swine","tennis","traffic","transportation","trout","tuna","wealth","welfare","whiting","wildebeest","wildlife","you",/pok[e\u00E9]mon$/i,/[^aeiou]ese$/i,/deer$/i,/fish$/i,/measles$/i,/o[iu]s$/i,/pox$/i,/sheep$/i].forEach(h.addUncountableRule),h})});import{parseArgs as Nc}from"util";import{TerminalLogger as Mc}from"@ooneex/logger";import{container as Ho}from"@ooneex/container";var xe=[];var Pt=(e)=>{let t=null;return xe.find((s)=>{return t=Ho.get(s),t.getName()===e}),t};import{homedir as Qo}from"os";import{join as et}from"path";import{TerminalLogger as zo}from"@ooneex/logger";import{container as Wo,EContainerScope as Yo}from"@ooneex/container";var E={command:(e=Yo.Singleton)=>{return(t)=>{Wo.add(t,e),xe.push(t)}}};var It=`#compdef oo ooneex
|
|
30
|
+
`);return this.value={values:r,result:i},super.submit()}}Tr.exports=Mr});var Or=A((Lp,Dr)=>{var Fa=oe();class Rr extends Fa{constructor(e){super({...e,reorder:!1,sort:!0,multiple:!0});this.state.hint=[this.options.hint,"(Use <shift>+<up/down> to sort)"].find(this.isValue.bind(this))}indicator(){return""}async renderChoice(e,t){let s=await super.renderChoice(e,t),r=this.symbols.identicalTo+" ",o=this.index===t&&this.sorting?this.styles.muted(r):" ";if(this.options.drag===!1)o="";if(this.options.numbered===!0)return o+`${t+1} - `+s;return o+s}get selected(){return this.choices}submit(){return this.value=this.choices.map((e)=>e.value),super.submit()}}Dr.exports=Rr});var Pr=A((Ip,Br)=>{var Qa=Ee();class Cr extends Qa{constructor(e={}){super(e);if(this.emptyError=e.emptyError||"No items were selected",this.term=process.env.TERM_PROGRAM,!this.options.header){let t=["","4 - Strongly Agree","3 - Agree","2 - Neutral","1 - Disagree","0 - Strongly Disagree",""];t=t.map((s)=>this.styles.muted(s)),this.state.header=t.join(`
|
|
31
|
+
`)}}async toChoices(...e){if(this.createdScales)return!1;this.createdScales=!0;let t=await super.toChoices(...e);for(let s of t)s.scale=za(5,this.options),s.scaleIdx=2;return t}dispatch(){this.alert()}space(){let e=this.focused,t=e.scale[e.scaleIdx],s=t.selected;return e.scale.forEach((r)=>r.selected=!1),t.selected=!s,this.render()}indicator(){return""}pointer(){return""}separator(){return this.styles.muted(this.symbols.ellipsis)}right(){let e=this.focused;if(e.scaleIdx>=e.scale.length-1)return this.alert();return e.scaleIdx++,this.render()}left(){let e=this.focused;if(e.scaleIdx<=0)return this.alert();return e.scaleIdx--,this.render()}indent(){return" "}async renderChoice(e,t){await this.onChoice(e,t);let s=this.index===t,r=this.term==="Hyper",o=!r?8:9,i=!r?" ":"",n=this.symbols.line.repeat(o),a=" ".repeat(o+(r?0:1)),l=(b)=>(b?this.styles.success("\u25C9"):"\u25EF")+i,m=t+1+".",c=s?this.styles.heading:this.styles.noop,p=await this.resolve(e.message,this.state,e,t),u=this.indent(e),d=u+e.scale.map((b,w)=>l(w===e.scaleIdx)).join(n),h=(b)=>b===e.scaleIdx?c(b):b,f=u+e.scale.map((b,w)=>h(w)).join(a),x=()=>[m,p].filter(Boolean).join(" "),y=()=>[x(),d,f," "].filter(Boolean).join(`
|
|
32
|
+
`);if(s)d=this.styles.cyan(d),f=this.styles.cyan(f);return y()}async renderChoices(){if(this.state.submitted)return"";let e=this.visible.map(async(s,r)=>await this.renderChoice(s,r)),t=await Promise.all(e);if(!t.length)t.push(this.styles.danger("No matching choices"));return t.join(`
|
|
33
|
+
`)}format(){if(this.state.submitted)return this.choices.map((t)=>this.styles.info(t.scaleIdx)).join(", ");return""}async render(){let{submitted:e,size:t}=this.state,s=await this.prefix(),r=await this.separator(),o=await this.message(),i=[s,o,r].filter(Boolean).join(" ");this.state.prompt=i;let n=await this.header(),a=await this.format(),l=await this.error()||await this.hint(),m=await this.renderChoices(),c=await this.footer();if(a||!l)i+=" "+a;if(l&&!i.includes(l))i+=" "+l;if(e&&!a&&!m&&this.multiple&&this.type!=="form")i+=this.styles.danger(this.emptyError);this.clear(t),this.write([i,n,m,c].filter(Boolean).join(`
|
|
34
|
+
`)),this.restore()}submit(){this.value={};for(let e of this.choices)this.value[e.name]=e.scaleIdx;return this.base.submit.call(this)}}function za(e,t={}){if(Array.isArray(t.scale))return t.scale.map((r)=>({...r}));let s=[];for(let r=1;r<e+1;r++)s.push({i:r,selected:!1});return s}Br.exports=Cr});var $r=A(($p,Ir)=>{var Za=Oe();class Lr extends Za{async initialize(){await super.initialize(),this.value=this.initial=this.resolve(this.options.initial),this.disabled=this.options.disabled||"no",this.enabled=this.options.enabled||"yes",await this.render()}reset(){this.value=this.initial,this.render()}delete(){this.alert()}toggle(){this.value=!this.value,this.render()}enable(){if(this.value===!0)return this.alert();this.value=!0,this.render()}disable(){if(this.value===!1)return this.alert();this.value=!1,this.render()}up(){this.toggle()}down(){this.toggle()}right(){this.toggle()}left(){this.toggle()}next(){this.toggle()}prev(){this.toggle()}dispatch(e="",t){switch(e.toLowerCase()){case" ":return this.toggle();case"1":case"y":case"t":return this.enable();case"0":case"n":case"f":return this.disable();default:return this.alert()}}format(){let e=(s)=>this.styles.primary.underline(s);return[this.value?this.disabled:e(this.disabled),this.value?e(this.enabled):this.enabled].join(this.styles.muted(" / "))}async render(){let{size:e}=this.state,t=await this.header(),s=await this.prefix(),r=await this.separator(),o=await this.message(),i=await this.format(),n=await this.error()||await this.hint(),a=await this.footer(),l=[s,o,r,i].join(" ");if(this.state.prompt=l,n&&!l.includes(n))l+=" "+n;this.clear(e),this.write([t,l,a].filter(Boolean).join(`
|
|
35
|
+
`)),this.write(this.margin[2]),this.restore()}}Ir.exports=Lr});var qr=A((Up,Gr)=>{var Xa=oe();class Ur extends Xa{constructor(e){super(e);if(typeof this.options.correctChoice!=="number"||this.options.correctChoice<0)throw Error("Please specify the index of the correct answer from the list of choices")}async toChoices(e,t){let s=await super.toChoices(e,t);if(s.length<2)throw Error("Please give at least two choices to the user");if(this.options.correctChoice>s.length)throw Error("Please specify the index of the correct answer from the list of choices");return s}check(e){return e.index===this.options.correctChoice}async result(e){return{selectedAnswer:e,correctAnswer:this.options.choices[this.options.correctChoice].value,correct:await this.check(this.state)}}}Gr.exports=Ur});var Kr=A((St)=>{var Wr=R(),N=(e,t)=>{Wr.defineExport(St,e,t),Wr.defineExport(St,e.toLowerCase(),t)};N("AutoComplete",()=>Ps());N("BasicAuth",()=>Ks());N("Confirm",()=>Qs());N("Editable",()=>Xs());N("Form",()=>De());N("Input",()=>bt());N("Invisible",()=>nr());N("List",()=>mr());N("MultiSelect",()=>ur());N("Numeral",()=>xt());N("Password",()=>gr());N("Scale",()=>xr());N("Select",()=>oe());N("Snippet",()=>vr());N("Sort",()=>Or());N("Survey",()=>Pr());N("Text",()=>bt());N("Toggle",()=>$r());N("Quiz",()=>qr())});var Yr=A((qp,Hr)=>{Hr.exports={ArrayPrompt:Ee(),AuthPrompt:At(),BooleanPrompt:Oe(),NumberPrompt:xt(),StringPrompt:me()}});var ne=A((Wp,Fr)=>{var Vr=fe("assert"),Nt=fe("events"),ie=R();class $ extends Nt{constructor(e,t){super();this.options=ie.merge({},e),this.answers={...t}}register(e,t){if(ie.isObject(e)){for(let r of Object.keys(e))this.register(r,e[r]);return this}Vr.equal(typeof t,"function","expected a function");let s=e.toLowerCase();if(t.prototype instanceof this.Prompt)this.prompts[s]=t;else this.prompts[s]=t(this.Prompt,this);return this}async prompt(e=[]){for(let t of[].concat(e))try{if(typeof t==="function")t=await t.call(this);await this.ask(ie.merge({},this.options,t))}catch(s){return Promise.reject(s)}return this.answers}async ask(e){if(typeof e==="function")e=await e.call(this);let t=ie.merge({},this.options,e),{type:s,name:r}=e,{set:o,get:i}=ie;if(typeof s==="function")s=await s.call(this,e,this.answers);if(!s)return this.answers[r];if(s==="number")s="numeral";Vr(this.prompts[s],`Prompt "${s}" is not registered`);let n=new this.prompts[s](t),a=i(this.answers,r);if(n.state.answers=this.answers,n.enquirer=this,r)n.on("submit",(m)=>{this.emit("answer",r,m,n),o(this.answers,r,m)});let l=n.emit.bind(n);if(n.emit=(...m)=>{return this.emit.call(this,...m),l(...m)},this.emit("prompt",n,this),t.autofill&&a!=null){if(n.value=n.input=a,t.autofill==="show")await n.submit()}else a=n.value=await n.run();return a}use(e){return e.call(this,this),this}set Prompt(e){this._Prompt=e}get Prompt(){return this._Prompt||this.constructor.Prompt}get prompts(){return this.constructor.prompts}static set Prompt(e){this._Prompt=e}static get Prompt(){return this._Prompt||pe()}static get prompts(){return Kr()}static get types(){return Yr()}static get prompt(){let e=(t,...s)=>{let r=new this(...s),o=r.emit.bind(r);return r.emit=(...i)=>{return e.emit(...i),o(...i)},r.prompt(t)};return ie.mixinEmitter(e,new Nt),e}}ie.mixinEmitter($,new Nt);var _t=$.prompts;for(let e of Object.keys(_t)){let t=e.toLowerCase(),s=(r)=>new _t[e](r).run();if($.prompt[t]=s,$[t]=s,!$[e])Reflect.defineProperty($,e,{get:()=>_t[e]})}var Ae=(e)=>{ie.defineExport($,e,()=>$.types[e])};Ae("ArrayPrompt");Ae("AuthPrompt");Ae("BooleanPrompt");Ae("NumberPrompt");Ae("StringPrompt");Fr.exports=$});var ai=A((Ot,Ct)=>{(function(e,t){if(typeof Ot==="object"&&typeof Ct==="object")Ct.exports=t();else if(typeof define==="function"&&define.amd)define(function(){return t()});else e.pluralize=t()})(Ot,function(){var e=[],t=[],s={},r={},o={};function i(d){if(typeof d==="string")return new RegExp("^"+d+"$","i");return d}function n(d,h){if(d===h)return h;if(d===d.toLowerCase())return h.toLowerCase();if(d===d.toUpperCase())return h.toUpperCase();if(d[0]===d[0].toUpperCase())return h.charAt(0).toUpperCase()+h.substr(1).toLowerCase();return h.toLowerCase()}function a(d,h){return d.replace(/\$(\d{1,2})/g,function(f,x){return h[x]||""})}function l(d,h){return d.replace(h[0],function(f,x){var y=a(h[1],arguments);if(f==="")return n(d[x-1],y);return n(f,y)})}function m(d,h,f){if(!d.length||s.hasOwnProperty(d))return h;var x=f.length;while(x--){var y=f[x];if(y[0].test(h))return l(h,y)}return h}function c(d,h,f){return function(x){var y=x.toLowerCase();if(h.hasOwnProperty(y))return n(x,y);if(d.hasOwnProperty(y))return n(x,d[y]);return m(y,x,f)}}function p(d,h,f,x){return function(y){var b=y.toLowerCase();if(h.hasOwnProperty(b))return!0;if(d.hasOwnProperty(b))return!1;return m(b,b,f)===b}}function u(d,h,f){var x=h===1?u.singular(d):u.plural(d);return(f?h+" ":"")+x}return u.plural=c(o,r,e),u.isPlural=p(o,r,e),u.singular=c(r,o,t),u.isSingular=p(r,o,t),u.addPluralRule=function(d,h){e.push([i(d),h])},u.addSingularRule=function(d,h){t.push([i(d),h])},u.addUncountableRule=function(d){if(typeof d==="string"){s[d.toLowerCase()]=!0;return}u.addPluralRule(d,"$0"),u.addSingularRule(d,"$0")},u.addIrregularRule=function(d,h){h=h.toLowerCase(),d=d.toLowerCase(),o[d]=h,r[h]=d},[["I","we"],["me","us"],["he","they"],["she","they"],["them","them"],["myself","ourselves"],["yourself","yourselves"],["itself","themselves"],["herself","themselves"],["himself","themselves"],["themself","themselves"],["is","are"],["was","were"],["has","have"],["this","these"],["that","those"],["echo","echoes"],["dingo","dingoes"],["volcano","volcanoes"],["tornado","tornadoes"],["torpedo","torpedoes"],["genus","genera"],["viscus","viscera"],["stigma","stigmata"],["stoma","stomata"],["dogma","dogmata"],["lemma","lemmata"],["schema","schemata"],["anathema","anathemata"],["ox","oxen"],["axe","axes"],["die","dice"],["yes","yeses"],["foot","feet"],["eave","eaves"],["goose","geese"],["tooth","teeth"],["quiz","quizzes"],["human","humans"],["proof","proofs"],["carve","carves"],["valve","valves"],["looey","looies"],["thief","thieves"],["groove","grooves"],["pickaxe","pickaxes"],["passerby","passersby"]].forEach(function(d){return u.addIrregularRule(d[0],d[1])}),[[/s?$/i,"s"],[/[^\u0000-\u007F]$/i,"$0"],[/([^aeiou]ese)$/i,"$1"],[/(ax|test)is$/i,"$1es"],[/(alias|[^aou]us|t[lm]as|gas|ris)$/i,"$1es"],[/(e[mn]u)s?$/i,"$1s"],[/([^l]ias|[aeiou]las|[ejzr]as|[iu]am)$/i,"$1"],[/(alumn|syllab|vir|radi|nucle|fung|cact|stimul|termin|bacill|foc|uter|loc|strat)(?:us|i)$/i,"$1i"],[/(alumn|alg|vertebr)(?:a|ae)$/i,"$1ae"],[/(seraph|cherub)(?:im)?$/i,"$1im"],[/(her|at|gr)o$/i,"$1oes"],[/(agend|addend|millenni|dat|extrem|bacteri|desiderat|strat|candelabr|errat|ov|symposi|curricul|automat|quor)(?:a|um)$/i,"$1a"],[/(apheli|hyperbat|periheli|asyndet|noumen|phenomen|criteri|organ|prolegomen|hedr|automat)(?:a|on)$/i,"$1a"],[/sis$/i,"ses"],[/(?:(kni|wi|li)fe|(ar|l|ea|eo|oa|hoo)f)$/i,"$1$2ves"],[/([^aeiouy]|qu)y$/i,"$1ies"],[/([^ch][ieo][ln])ey$/i,"$1ies"],[/(x|ch|ss|sh|zz)$/i,"$1es"],[/(matr|cod|mur|sil|vert|ind|append)(?:ix|ex)$/i,"$1ices"],[/\b((?:tit)?m|l)(?:ice|ouse)$/i,"$1ice"],[/(pe)(?:rson|ople)$/i,"$1ople"],[/(child)(?:ren)?$/i,"$1ren"],[/eaux$/i,"$0"],[/m[ae]n$/i,"men"],["thou","you"]].forEach(function(d){return u.addPluralRule(d[0],d[1])}),[[/s$/i,""],[/(ss)$/i,"$1"],[/(wi|kni|(?:after|half|high|low|mid|non|night|[^\w]|^)li)ves$/i,"$1fe"],[/(ar|(?:wo|[ae])l|[eo][ao])ves$/i,"$1f"],[/ies$/i,"y"],[/\b([pl]|zomb|(?:neck|cross)?t|coll|faer|food|gen|goon|group|lass|talk|goal|cut)ies$/i,"$1ie"],[/\b(mon|smil)ies$/i,"$1ey"],[/\b((?:tit)?m|l)ice$/i,"$1ouse"],[/(seraph|cherub)im$/i,"$1"],[/(x|ch|ss|sh|zz|tto|go|cho|alias|[^aou]us|t[lm]as|gas|(?:her|at|gr)o|[aeiou]ris)(?:es)?$/i,"$1"],[/(analy|diagno|parenthe|progno|synop|the|empha|cri|ne)(?:sis|ses)$/i,"$1sis"],[/(movie|twelve|abuse|e[mn]u)s$/i,"$1"],[/(test)(?:is|es)$/i,"$1is"],[/(alumn|syllab|vir|radi|nucle|fung|cact|stimul|termin|bacill|foc|uter|loc|strat)(?:us|i)$/i,"$1us"],[/(agend|addend|millenni|dat|extrem|bacteri|desiderat|strat|candelabr|errat|ov|symposi|curricul|quor)a$/i,"$1um"],[/(apheli|hyperbat|periheli|asyndet|noumen|phenomen|criteri|organ|prolegomen|hedr|automat)a$/i,"$1on"],[/(alumn|alg|vertebr)ae$/i,"$1a"],[/(cod|mur|sil|vert|ind)ices$/i,"$1ex"],[/(matr|append)ices$/i,"$1ix"],[/(pe)(rson|ople)$/i,"$1rson"],[/(child)ren$/i,"$1"],[/(eau)x?$/i,"$1"],[/men$/i,"man"]].forEach(function(d){return u.addSingularRule(d[0],d[1])}),["adulthood","advice","agenda","aid","aircraft","alcohol","ammo","analytics","anime","athletics","audio","bison","blood","bream","buffalo","butter","carp","cash","chassis","chess","clothing","cod","commerce","cooperation","corps","debris","diabetes","digestion","elk","energy","equipment","excretion","expertise","firmware","flounder","fun","gallows","garbage","graffiti","hardware","headquarters","health","herpes","highjinks","homework","housework","information","jeans","justice","kudos","labour","literature","machinery","mackerel","mail","media","mews","moose","music","mud","manga","news","only","personnel","pike","plankton","pliers","police","pollution","premises","rain","research","rice","salmon","scissors","series","sewage","shambles","shrimp","software","species","staff","swine","tennis","traffic","transportation","trout","tuna","wealth","welfare","whiting","wildebeest","wildlife","you",/pok[e\u00E9]mon$/i,/[^aeiou]ese$/i,/deer$/i,/fish$/i,/measles$/i,/o[iu]s$/i,/pox$/i,/sheep$/i].forEach(u.addUncountableRule),u})});import{parseArgs as Od}from"util";import{TerminalLogger as Cd}from"@ooneex/logger";import{container as Qi}from"@ooneex/container";var Se=[];var $t=(e)=>{let t=null;return Se.find((s)=>{return t=Qi.get(s),t.getName()===e}),t};import{homedir as ji}from"os";import{join as tt}from"path";import{TerminalLogger as ki}from"@ooneex/logger";import{container as zi,EContainerScope as Zi}from"@ooneex/container";var E={command:(e=Zi.Singleton)=>{return(t)=>{zi.add(t,e),Se.push(t)}}};var Ut=`#compdef oo ooneex
|
|
36
|
+
|
|
37
|
+
_oo_modules() {
|
|
38
|
+
local -a modules
|
|
39
|
+
if [[ -d modules ]]; then
|
|
40
|
+
modules=(\${(@f)"$(command ls -1 modules 2>/dev/null)"})
|
|
41
|
+
compadd -a modules
|
|
42
|
+
fi
|
|
43
|
+
}
|
|
36
44
|
|
|
37
45
|
_oo() {
|
|
38
46
|
local -a commands
|
|
@@ -76,6 +84,7 @@ _oo() {
|
|
|
76
84
|
make:controller)
|
|
77
85
|
_arguments -s \\
|
|
78
86
|
'--name=[Name of the resource]:name' \\
|
|
87
|
+
'--module=[Module name]:module:_oo_modules' \\
|
|
79
88
|
'--route-name=[Route name]:route_name' \\
|
|
80
89
|
'--route-path=[Route path]:route_path' \\
|
|
81
90
|
'--route-method=[Route HTTP method]:method:(GET POST PUT PATCH DELETE HEAD OPTIONS)' \\
|
|
@@ -84,25 +93,30 @@ _oo() {
|
|
|
84
93
|
make:middleware)
|
|
85
94
|
_arguments -s \\
|
|
86
95
|
'--name=[Name of the resource]:name' \\
|
|
96
|
+
'--module=[Module name]:module:_oo_modules' \\
|
|
87
97
|
'--is-socket[Socket mode]'
|
|
88
98
|
;;
|
|
89
99
|
make:entity)
|
|
90
100
|
_arguments -s \\
|
|
91
101
|
'--name=[Name of the resource]:name' \\
|
|
102
|
+
'--module=[Module name]:module:_oo_modules' \\
|
|
92
103
|
'--table-name=[Database table name]:table_name'
|
|
93
104
|
;;
|
|
94
105
|
make:pubsub)
|
|
95
106
|
_arguments -s \\
|
|
96
107
|
'--name=[Name of the resource]:name' \\
|
|
108
|
+
'--module=[Module name]:module:_oo_modules' \\
|
|
97
109
|
'--channel=[Channel name]:channel'
|
|
98
110
|
;;
|
|
99
111
|
make:migration)
|
|
100
112
|
_arguments -s \\
|
|
113
|
+
'--module=[Module name]:module:_oo_modules' \\
|
|
101
114
|
'--dir=[Directory]:dir:_files -/'
|
|
102
115
|
;;
|
|
103
116
|
make:seed)
|
|
104
117
|
_arguments -s \\
|
|
105
118
|
'--name=[Name of the resource]:name' \\
|
|
119
|
+
'--module=[Module name]:module:_oo_modules' \\
|
|
106
120
|
'--dir=[Directory]:dir:_files -/'
|
|
107
121
|
;;
|
|
108
122
|
make:module)
|
|
@@ -111,11 +125,18 @@ _oo() {
|
|
|
111
125
|
;;
|
|
112
126
|
make:docker)
|
|
113
127
|
_arguments -s \\
|
|
114
|
-
'--name=[Docker service name]:name:(clickhouse elasticsearch grafana jaeger keycloak libretranslate maildev memcached minio mongodb mysql nats ooneex-jade postgres prometheus rabbitmq redis temporal vault)'
|
|
128
|
+
'--name=[Docker service name]:name:(clickhouse elasticsearch grafana jaeger keycloak libretranslate maildev memcached minio mongodb mysql nats ooneex-jade postgres prometheus rabbitmq redis temporal vault)' \\
|
|
129
|
+
'--module=[Module name]:module:_oo_modules'
|
|
115
130
|
;;
|
|
116
|
-
make:
|
|
131
|
+
make:app)
|
|
117
132
|
_arguments -s \\
|
|
118
|
-
'--name=[Name of the resource]:name'
|
|
133
|
+
'--name=[Name of the resource]:name' \\
|
|
134
|
+
'--destination=[Destination path]:destination:_files -/'
|
|
135
|
+
;;
|
|
136
|
+
make:ai|make:analytics|make:cache|make:cron|make:database|make:logger|make:mailer|make:permission|make:repository|make:service|make:storage|make:vector-database)
|
|
137
|
+
_arguments -s \\
|
|
138
|
+
'--name=[Name of the resource]:name' \\
|
|
139
|
+
'--module=[Module name]:module:_oo_modules'
|
|
119
140
|
;;
|
|
120
141
|
make:claude:skill|completion:zsh)
|
|
121
142
|
;;
|
|
@@ -125,7 +146,15 @@ _oo() {
|
|
|
125
146
|
}
|
|
126
147
|
|
|
127
148
|
_oo "$@"
|
|
128
|
-
`;var
|
|
149
|
+
`;var Gt=`#compdef oo ooneex
|
|
150
|
+
|
|
151
|
+
_ooneex_modules() {
|
|
152
|
+
local -a modules
|
|
153
|
+
if [[ -d modules ]]; then
|
|
154
|
+
modules=(\${(@f)"$(command ls -1 modules 2>/dev/null)"})
|
|
155
|
+
compadd -a modules
|
|
156
|
+
fi
|
|
157
|
+
}
|
|
129
158
|
|
|
130
159
|
_ooneex() {
|
|
131
160
|
local -a commands
|
|
@@ -169,6 +198,7 @@ _ooneex() {
|
|
|
169
198
|
make:controller)
|
|
170
199
|
_arguments -s \\
|
|
171
200
|
'--name=[Name of the resource]:name' \\
|
|
201
|
+
'--module=[Module name]:module:_ooneex_modules' \\
|
|
172
202
|
'--route-name=[Route name]:route_name' \\
|
|
173
203
|
'--route-path=[Route path]:route_path' \\
|
|
174
204
|
'--route-method=[Route HTTP method]:method:(GET POST PUT PATCH DELETE HEAD OPTIONS)' \\
|
|
@@ -177,25 +207,30 @@ _ooneex() {
|
|
|
177
207
|
make:middleware)
|
|
178
208
|
_arguments -s \\
|
|
179
209
|
'--name=[Name of the resource]:name' \\
|
|
210
|
+
'--module=[Module name]:module:_ooneex_modules' \\
|
|
180
211
|
'--is-socket[Socket mode]'
|
|
181
212
|
;;
|
|
182
213
|
make:entity)
|
|
183
214
|
_arguments -s \\
|
|
184
215
|
'--name=[Name of the resource]:name' \\
|
|
216
|
+
'--module=[Module name]:module:_ooneex_modules' \\
|
|
185
217
|
'--table-name=[Database table name]:table_name'
|
|
186
218
|
;;
|
|
187
219
|
make:pubsub)
|
|
188
220
|
_arguments -s \\
|
|
189
221
|
'--name=[Name of the resource]:name' \\
|
|
222
|
+
'--module=[Module name]:module:_ooneex_modules' \\
|
|
190
223
|
'--channel=[Channel name]:channel'
|
|
191
224
|
;;
|
|
192
225
|
make:migration)
|
|
193
226
|
_arguments -s \\
|
|
227
|
+
'--module=[Module name]:module:_ooneex_modules' \\
|
|
194
228
|
'--dir=[Directory]:dir:_files -/'
|
|
195
229
|
;;
|
|
196
230
|
make:seed)
|
|
197
231
|
_arguments -s \\
|
|
198
232
|
'--name=[Name of the resource]:name' \\
|
|
233
|
+
'--module=[Module name]:module:_ooneex_modules' \\
|
|
199
234
|
'--dir=[Directory]:dir:_files -/'
|
|
200
235
|
;;
|
|
201
236
|
make:module)
|
|
@@ -204,11 +239,18 @@ _ooneex() {
|
|
|
204
239
|
;;
|
|
205
240
|
make:docker)
|
|
206
241
|
_arguments -s \\
|
|
207
|
-
'--name=[Docker service name]:name:(clickhouse elasticsearch grafana jaeger keycloak libretranslate maildev memcached minio mongodb mysql nats ooneex-jade postgres prometheus rabbitmq redis temporal vault)'
|
|
242
|
+
'--name=[Docker service name]:name:(clickhouse elasticsearch grafana jaeger keycloak libretranslate maildev memcached minio mongodb mysql nats ooneex-jade postgres prometheus rabbitmq redis temporal vault)' \\
|
|
243
|
+
'--module=[Module name]:module:_ooneex_modules'
|
|
208
244
|
;;
|
|
209
|
-
make:
|
|
245
|
+
make:app)
|
|
210
246
|
_arguments -s \\
|
|
211
|
-
'--name=[Name of the resource]:name'
|
|
247
|
+
'--name=[Name of the resource]:name' \\
|
|
248
|
+
'--destination=[Destination path]:destination:_files -/'
|
|
249
|
+
;;
|
|
250
|
+
make:ai|make:analytics|make:cache|make:cron|make:database|make:logger|make:mailer|make:permission|make:repository|make:service|make:storage|make:vector-database)
|
|
251
|
+
_arguments -s \\
|
|
252
|
+
'--name=[Name of the resource]:name' \\
|
|
253
|
+
'--module=[Module name]:module:_ooneex_modules'
|
|
212
254
|
;;
|
|
213
255
|
make:claude:skill|completion:zsh)
|
|
214
256
|
;;
|
|
@@ -218,9 +260,9 @@ _ooneex() {
|
|
|
218
260
|
}
|
|
219
261
|
|
|
220
262
|
_ooneex "$@"
|
|
221
|
-
`;class
|
|
263
|
+
`;class _e{getName(){return"completion:zsh"}getDescription(){return"Install Zsh completion for oo command"}async run(){let e=tt(ji(),".zsh"),t=tt(e,"_oo");await Bun.write(t,Ut);let s=tt(e,"_ooneex");await Bun.write(s,Gt);let r=new ki;r.success(`${t} created successfully`,void 0,{showTimestamp:!1,showArrow:!1,useSymbol:!0}),r.success(`${s} created successfully`,void 0,{showTimestamp:!1,showArrow:!1,useSymbol:!0}),r.info(`Add the following to your .zshrc if not already present:
|
|
222
264
|
fpath=(~/.zsh $fpath)
|
|
223
|
-
autoload -Uz compinit && compinit`,void 0,{showTimestamp:!1,showArrow:!1,useSymbol:!0})}}
|
|
265
|
+
autoload -Uz compinit && compinit`,void 0,{showTimestamp:!1,showArrow:!1,useSymbol:!0})}}_e=g([E.command()],_e);import{join as Y}from"path";import{TerminalLogger as rl}from"@ooneex/logger";import{toPascalCase as ol}from"@ooneex/utils";var Qr=te(ne(),1);import{Assert as Ja,Validation as ja}from"@ooneex/validation";var ka=1,el=/^[a-zA-Z][a-zA-Z0-9-]*$/;class be extends ja{getConstraint(){return Ja(`string >= ${ka}`)}getErrorMessage(){return"Name must start with a letter and contain only letters, numbers, and hyphens"}validate(e,t){let s=super.validate(e,t);if(!s.isValid)return s;let r=e;if(!el.test(r))return{isValid:!1,message:this.getErrorMessage()||"Invalid name format"};return{isValid:!0}}}var S=async(e)=>{return(await Qr.prompt({type:"input",name:"name",message:e.message,validate:(s)=>{let o=new be().validate(s);if(!o.isValid)return o.message||"Controller name is invalid";return!0}})).name};var zr=`import { describe, expect, test } from "bun:test";
|
|
224
266
|
import { {{NAME}}Ai } from "@/ai/{{NAME}}Ai";
|
|
225
267
|
|
|
226
268
|
describe("{{NAME}}Ai", () => {
|
|
@@ -238,7 +280,7 @@ describe("{{NAME}}Ai", () => {
|
|
|
238
280
|
expect(typeof {{NAME}}Ai.prototype.runStream).toBe("function");
|
|
239
281
|
});
|
|
240
282
|
});
|
|
241
|
-
`;var
|
|
283
|
+
`;var Zr=`import { decorator, type IAiChat, OpenAi, type OpenAiConfigType } from "@ooneex/ai";
|
|
242
284
|
import { inject } from "@ooneex/container";
|
|
243
285
|
|
|
244
286
|
@decorator.ai()
|
|
@@ -256,7 +298,7 @@ export class {{NAME}}Ai implements IAiChat<OpenAiConfigType> {
|
|
|
256
298
|
yield* this.ai.runStream(prompt || "My prompt", config);
|
|
257
299
|
}
|
|
258
300
|
}
|
|
259
|
-
`;class Be{getName(){return"make:ai"}getDescription(){return"Generate a new AI class"}async run(e){let{name:t}=e;if(!t)t=await
|
|
301
|
+
`;class Be{getName(){return"make:ai"}getDescription(){return"Generate a new AI class"}async run(e){let{name:t,module:s}=e;if(!t)t=await S({message:"Enter name"});t=ol(t).replace(/Ai$/,"");let r=Zr.replace(/{{NAME}}/g,t),o=s?Y("modules",s):".",i=Y(o,"src","ai"),n=Y(process.cwd(),i),a=Y(n,`${t}Ai.ts`);await Bun.write(a,r);let l=zr.replace(/{{NAME}}/g,t),m=Y(o,"tests","ai"),c=Y(process.cwd(),m),p=Y(c,`${t}Ai.spec.ts`);await Bun.write(p,l);let u=new rl;u.success(`${Y(i,t)}Ai.ts created successfully`,void 0,{showTimestamp:!1,showArrow:!1,useSymbol:!0}),u.success(`${Y(m,t)}Ai.spec.ts created successfully`,void 0,{showTimestamp:!1,showArrow:!1,useSymbol:!0})}}Be=g([E.command()],Be);import{join as V}from"path";import{TerminalLogger as al}from"@ooneex/logger";import{toPascalCase as ll}from"@ooneex/utils";var Xr=`import { describe, expect, test } from "bun:test";
|
|
260
302
|
import { {{NAME}}Analytics } from "@/analytics/{{NAME}}Analytics";
|
|
261
303
|
|
|
262
304
|
describe("{{NAME}}Analytics", () => {
|
|
@@ -269,7 +311,7 @@ describe("{{NAME}}Analytics", () => {
|
|
|
269
311
|
expect(typeof {{NAME}}Analytics.prototype.capture).toBe("function");
|
|
270
312
|
});
|
|
271
313
|
});
|
|
272
|
-
`;var
|
|
314
|
+
`;var Jr=`import { decorator } from "@ooneex/analytics";
|
|
273
315
|
import type { IAnalytics } from "@ooneex/analytics";
|
|
274
316
|
|
|
275
317
|
type CaptureOptionsType = Record<string, unknown>;
|
|
@@ -280,7 +322,7 @@ export class {{NAME}}Analytics<T extends CaptureOptionsType = CaptureOptionsType
|
|
|
280
322
|
// console.log("Analytics captured:", options);
|
|
281
323
|
}
|
|
282
324
|
}
|
|
283
|
-
`;class
|
|
325
|
+
`;class Pe{getName(){return"make:analytics"}getDescription(){return"Generate a new analytics class"}async run(e){let{name:t,module:s}=e;if(!t)t=await S({message:"Enter analytics name"});t=ll(t).replace(/Analytics$/,"");let r=Jr.replace(/{{NAME}}/g,t),o=s?V("modules",s):".",i=V(o,"src","analytics"),n=V(process.cwd(),i),a=V(n,`${t}Analytics.ts`);await Bun.write(a,r);let l=Xr.replace(/{{NAME}}/g,t),m=V(o,"tests","analytics"),c=V(process.cwd(),m),p=V(c,`${t}Analytics.spec.ts`);await Bun.write(p,l);let u=new al;u.success(`${V(i,t)}Analytics.ts created successfully`,void 0,{showTimestamp:!1,showArrow:!1,useSymbol:!0}),u.success(`${V(m,t)}Analytics.spec.ts created successfully`,void 0,{showTimestamp:!1,showArrow:!1,useSymbol:!0})}}Pe=g([E.command()],Pe);import{join as v}from"path";import{TerminalLogger as Dl}from"@ooneex/logger";import{toKebabCase as Ol,toSnakeCase as Cl}from"@ooneex/utils";var jr=te(ne(),1);var kr=async(e)=>{let t=new be;return(await jr.prompt({type:"input",name:"destination",message:e.message,initial:e.initial||".",validate:(r)=>{let o=t.validate(r);if(!o.isValid)return o.message||"Invalid destination";return!0}})).destination};var eo=`import { RuleConfigSeverity, type UserConfig } from "@commitlint/types";
|
|
284
326
|
|
|
285
327
|
const Configuration: UserConfig = {
|
|
286
328
|
extends: ["@commitlint/config-conventional"],
|
|
@@ -421,7 +463,7 @@ const Configuration: UserConfig = {
|
|
|
421
463
|
};
|
|
422
464
|
|
|
423
465
|
export default Configuration;
|
|
424
|
-
`;var
|
|
466
|
+
`;var to=`# Logs
|
|
425
467
|
logs
|
|
426
468
|
*.log
|
|
427
469
|
npm-debug.log*
|
|
@@ -571,7 +613,41 @@ vite.config.ts.timestamp-*
|
|
|
571
613
|
|
|
572
614
|
# Application
|
|
573
615
|
var/
|
|
574
|
-
`;var
|
|
616
|
+
`;var so=`import { inject } from "@ooneex/container";
|
|
617
|
+
import { AppEnv } from "@ooneex/app-env";
|
|
618
|
+
import { DataSource } from "typeorm";
|
|
619
|
+
import { TypeormPgDatabase, DatabaseException, decorator } from "@ooneex/database";
|
|
620
|
+
import { AppModule } from "@/AppModule";
|
|
621
|
+
|
|
622
|
+
@decorator.database()
|
|
623
|
+
export class AppDatabase extends TypeormPgDatabase {
|
|
624
|
+
constructor(@inject(AppEnv) private readonly env: AppEnv) {
|
|
625
|
+
super();
|
|
626
|
+
}
|
|
627
|
+
|
|
628
|
+
public getSource(): DataSource {
|
|
629
|
+
const url = this.env.DATABASE_URL;
|
|
630
|
+
|
|
631
|
+
if (!url) {
|
|
632
|
+
throw new DatabaseException(
|
|
633
|
+
"Database URL is required. Please set the DATABASE_URL environment variable.",
|
|
634
|
+
);
|
|
635
|
+
}
|
|
636
|
+
|
|
637
|
+
this.source = new DataSource({
|
|
638
|
+
synchronize: false,
|
|
639
|
+
entities: AppModule.entities,
|
|
640
|
+
extra: {
|
|
641
|
+
max: 10,
|
|
642
|
+
},
|
|
643
|
+
url,
|
|
644
|
+
type: "postgres",
|
|
645
|
+
});
|
|
646
|
+
|
|
647
|
+
return this.source;
|
|
648
|
+
}
|
|
649
|
+
}
|
|
650
|
+
`;var ro=`{
|
|
575
651
|
"$schema": "./node_modules/@biomejs/biome/configuration_schema.json",
|
|
576
652
|
"vcs": {
|
|
577
653
|
"enabled": true,
|
|
@@ -650,7 +726,7 @@ var/
|
|
|
650
726
|
}
|
|
651
727
|
}
|
|
652
728
|
}
|
|
653
|
-
`;var
|
|
729
|
+
`;var oo=`[test]
|
|
654
730
|
coverage = true
|
|
655
731
|
|
|
656
732
|
[workspace]
|
|
@@ -683,16 +759,93 @@ buildDependencies = [
|
|
|
683
759
|
"@swc/core",
|
|
684
760
|
"nx",
|
|
685
761
|
]
|
|
762
|
+
`;var io=`# use the official Bun image
|
|
763
|
+
# see all versions at https://hub.docker.com/r/oven/bun/tags
|
|
764
|
+
FROM oven/bun:1 AS base
|
|
765
|
+
WORKDIR /{{NAME}}
|
|
766
|
+
|
|
767
|
+
# Declare the build-time argument with an optional default
|
|
768
|
+
ARG DATABASE_URL
|
|
769
|
+
|
|
770
|
+
# Promote build arg to runtime environment variable
|
|
771
|
+
ENV DATABASE_URL=\${DATABASE_URL}
|
|
772
|
+
|
|
773
|
+
# install dependencies into temp directory
|
|
774
|
+
# this will cache them and speed up future builds
|
|
775
|
+
FROM base AS install
|
|
776
|
+
RUN mkdir -p /temp/dev
|
|
777
|
+
COPY package.json bun.lock /temp/dev/
|
|
778
|
+
RUN cd /temp/dev && bun install --frozen-lockfile
|
|
779
|
+
|
|
780
|
+
# install with --production (exclude devDependencies)
|
|
781
|
+
RUN mkdir -p /temp/prod
|
|
782
|
+
COPY package.json bun.lock /temp/prod/
|
|
783
|
+
RUN cd /temp/prod && bun install --frozen-lockfile --production
|
|
784
|
+
|
|
785
|
+
# copy node_modules from temp directory
|
|
786
|
+
# then copy all (non-ignored) project files into the image
|
|
787
|
+
FROM base AS prerelease
|
|
788
|
+
COPY --from=install /temp/dev/node_modules node_modules
|
|
789
|
+
COPY . .
|
|
790
|
+
|
|
791
|
+
# build
|
|
792
|
+
ENV NODE_ENV=production
|
|
793
|
+
RUN bun run build
|
|
794
|
+
|
|
795
|
+
# copy production dependencies and source code into final image
|
|
796
|
+
FROM base AS release
|
|
797
|
+
COPY --from=install /temp/prod/node_modules node_modules
|
|
798
|
+
COPY --from=prerelease /ooneex/dist .
|
|
799
|
+
COPY --from=prerelease /ooneex/package.json .
|
|
800
|
+
|
|
801
|
+
# run the app
|
|
802
|
+
USER bun
|
|
803
|
+
EXPOSE 3000/tcp
|
|
804
|
+
ENTRYPOINT [ "bun", "run", "index.js" ]
|
|
805
|
+
`;var no=`services:
|
|
806
|
+
# PostgreSQL - Primary relational database
|
|
807
|
+
# Docs: https://www.postgresql.org/docs/
|
|
808
|
+
# Connection: postgresql://ooneex:ooneex@localhost:5432/ooneex
|
|
809
|
+
postgres:
|
|
810
|
+
image: postgres:17-alpine
|
|
811
|
+
container_name: {{NAME}}_db
|
|
812
|
+
restart: "on-failure"
|
|
813
|
+
ports:
|
|
814
|
+
- "5432:5432"
|
|
815
|
+
volumes:
|
|
816
|
+
- {{NAME}}_db_data:/var/lib/postgresql/data:rw
|
|
817
|
+
environment:
|
|
818
|
+
- POSTGRES_ROOT_PASSWORD=ooneex
|
|
819
|
+
- POSTGRES_DATABASE=ooneex
|
|
820
|
+
- POSTGRES_USER=ooneex
|
|
821
|
+
- POSTGRES_PASSWORD=ooneex
|
|
822
|
+
- PGDATA=/var/lib/postgresql/data/pgdata
|
|
823
|
+
|
|
824
|
+
# Redis - In-memory data store for caching and sessions
|
|
825
|
+
# Docs: https://redis.io/docs/
|
|
826
|
+
# Connection: redis://localhost:6379
|
|
827
|
+
redis:
|
|
828
|
+
image: redis:8.4-alpine
|
|
829
|
+
container_name: {{NAME}}_redis
|
|
830
|
+
restart: "on-failure"
|
|
831
|
+
ports:
|
|
832
|
+
- "6379:6379"
|
|
833
|
+
volumes:
|
|
834
|
+
- {{NAME}}_redis_data:/data:rw
|
|
835
|
+
|
|
836
|
+
volumes:
|
|
837
|
+
{{NAME}}_db_data:
|
|
838
|
+
{{NAME}}_redis_data:
|
|
686
839
|
`;var Mt=`# =============================================================================
|
|
687
840
|
# App
|
|
688
841
|
# =============================================================================
|
|
689
842
|
|
|
690
|
-
# Application environment (local, development, staging, production)
|
|
843
|
+
# Application environment (local, development, staging, testing, test, qa, uat, integration, preview, demo, sandbox, beta, canary, hotfix, production)
|
|
691
844
|
APP_ENV="local"
|
|
692
845
|
# Server port number (default: 3000)
|
|
693
846
|
PORT=3000
|
|
694
847
|
# Server hostname (default: 0.0.0.0)
|
|
695
|
-
HOST_NAME=
|
|
848
|
+
HOST_NAME=
|
|
696
849
|
|
|
697
850
|
# =============================================================================
|
|
698
851
|
# Logs
|
|
@@ -723,21 +876,21 @@ ANALYTICS_POSTHOG_HOST="https://eu.i.posthog.com"
|
|
|
723
876
|
# =============================================================================
|
|
724
877
|
|
|
725
878
|
# Redis connection URL for caching
|
|
726
|
-
CACHE_REDIS_URL=
|
|
879
|
+
CACHE_REDIS_URL=
|
|
727
880
|
|
|
728
881
|
# =============================================================================
|
|
729
882
|
# Pub/Sub
|
|
730
883
|
# =============================================================================
|
|
731
884
|
|
|
732
885
|
# Redis connection URL for pub/sub messaging
|
|
733
|
-
PUBSUB_REDIS_URL=
|
|
886
|
+
PUBSUB_REDIS_URL=
|
|
734
887
|
|
|
735
888
|
# =============================================================================
|
|
736
889
|
# Rate limit
|
|
737
890
|
# =============================================================================
|
|
738
891
|
|
|
739
892
|
# Redis connection URL for rate limiting
|
|
740
|
-
RATE_LIMIT_REDIS_URL=
|
|
893
|
+
RATE_LIMIT_REDIS_URL=
|
|
741
894
|
|
|
742
895
|
# =============================================================================
|
|
743
896
|
# CORS
|
|
@@ -784,7 +937,6 @@ FILESYSTEM_STORAGE_PATH=
|
|
|
784
937
|
# =============================================================================
|
|
785
938
|
|
|
786
939
|
# PostgreSQL connection URL
|
|
787
|
-
# DATABASE_URL="postgres://username:password@localhost:5432/database_name"
|
|
788
940
|
DATABASE_URL=
|
|
789
941
|
# Redis connection URL for Redis-based database operations
|
|
790
942
|
DATABASE_REDIS_URL=
|
|
@@ -839,9 +991,45 @@ POLAR_ENVIRONMENT=
|
|
|
839
991
|
|
|
840
992
|
# Clerk authentication secret key
|
|
841
993
|
CLERK_SECRET_KEY=
|
|
842
|
-
|
|
994
|
+
|
|
995
|
+
# =============================================================================
|
|
996
|
+
# Allowed Users
|
|
997
|
+
# =============================================================================
|
|
998
|
+
|
|
999
|
+
# Comma-separated allowed user emails for development environment
|
|
1000
|
+
DEVELOPMENT_ALLOWED_USERS=
|
|
1001
|
+
# Comma-separated allowed user emails for staging environment
|
|
1002
|
+
STAGING_ALLOWED_USERS=
|
|
1003
|
+
# Comma-separated allowed user emails for testing environment
|
|
1004
|
+
TESTING_ALLOWED_USERS=
|
|
1005
|
+
# Comma-separated allowed user emails for test environment
|
|
1006
|
+
TEST_ALLOWED_USERS=
|
|
1007
|
+
# Comma-separated allowed user emails for QA environment
|
|
1008
|
+
QA_ALLOWED_USERS=
|
|
1009
|
+
# Comma-separated allowed user emails for UAT environment
|
|
1010
|
+
UAT_ALLOWED_USERS=
|
|
1011
|
+
# Comma-separated allowed user emails for integration environment
|
|
1012
|
+
INTEGRATION_ALLOWED_USERS=
|
|
1013
|
+
# Comma-separated allowed user emails for preview environment
|
|
1014
|
+
PREVIEW_ALLOWED_USERS=
|
|
1015
|
+
# Comma-separated allowed user emails for demo environment
|
|
1016
|
+
DEMO_ALLOWED_USERS=
|
|
1017
|
+
# Comma-separated allowed user emails for sandbox environment
|
|
1018
|
+
SANDBOX_ALLOWED_USERS=
|
|
1019
|
+
# Comma-separated allowed user emails for beta environment
|
|
1020
|
+
BETA_ALLOWED_USERS=
|
|
1021
|
+
# Comma-separated allowed user emails for canary environment
|
|
1022
|
+
CANARY_ALLOWED_USERS=
|
|
1023
|
+
# Comma-separated allowed user emails for hotfix environment
|
|
1024
|
+
HOTFIX_ALLOWED_USERS=
|
|
1025
|
+
# Comma-separated system user emails (have access across all environments)
|
|
1026
|
+
SYSTEM_USERS=
|
|
1027
|
+
# Comma-separated super admin user emails
|
|
1028
|
+
SUPER_ADMIN_USERS=
|
|
1029
|
+
# Comma-separated admin user emails
|
|
1030
|
+
ADMIN_USERS=
|
|
1031
|
+
`;var ao=`import { PostHogAnalytics } from "@ooneex/analytics";
|
|
843
1032
|
import { App } from "@ooneex/app";
|
|
844
|
-
import { AppEnv, type EnvType } from "@ooneex/app-env";
|
|
845
1033
|
import { RedisCache } from "@ooneex/cache";
|
|
846
1034
|
import { LogtailLogger, ExceptionLogger, TerminalLogger } from "@ooneex/logger";
|
|
847
1035
|
import { ResendMailer } from "@ooneex/mailer";
|
|
@@ -850,8 +1038,6 @@ import { RedisRateLimiter } from "@ooneex/rate-limit";
|
|
|
850
1038
|
import { BunnyStorage } from "@ooneex/storage";
|
|
851
1039
|
import { AppModule } from "./AppModule";
|
|
852
1040
|
|
|
853
|
-
const appEnv = new AppEnv((Bun.env.NODE_ENV || Bun.env.APP_ENV || "production") as EnvType);
|
|
854
|
-
|
|
855
1041
|
const app = new App({
|
|
856
1042
|
prefix: "api",
|
|
857
1043
|
loggers: [LogtailLogger, TerminalLogger],
|
|
@@ -866,12 +1052,11 @@ const app = new App({
|
|
|
866
1052
|
cors: CorsMiddleware,
|
|
867
1053
|
cronJobs: AppModule.cronJobs,
|
|
868
1054
|
events: AppModule.events,
|
|
869
|
-
env: appEnv,
|
|
870
1055
|
generateRouteDoc: true,
|
|
871
1056
|
});
|
|
872
1057
|
|
|
873
1058
|
await app.run();
|
|
874
|
-
`;var
|
|
1059
|
+
`;var lo=`{
|
|
875
1060
|
"$schema": "./node_modules/nx/schemas/nx-schema.json",
|
|
876
1061
|
"targetDefaults": {
|
|
877
1062
|
"build": {
|
|
@@ -901,7 +1086,7 @@ await app.run();
|
|
|
901
1086
|
],
|
|
902
1087
|
"packageManager": "bun"
|
|
903
1088
|
}
|
|
904
|
-
`;var
|
|
1089
|
+
`;var mo=`{
|
|
905
1090
|
"name": "{{NAME}}",
|
|
906
1091
|
"module": "index.ts",
|
|
907
1092
|
"private": true,
|
|
@@ -923,25 +1108,25 @@ await app.run();
|
|
|
923
1108
|
"modules/*"
|
|
924
1109
|
],
|
|
925
1110
|
"dependencies": {
|
|
926
|
-
"@ooneex/analytics": "^
|
|
927
|
-
"@ooneex/app": "^
|
|
928
|
-
"@ooneex/app-env": "^
|
|
929
|
-
"@ooneex/auth": "^
|
|
930
|
-
"@ooneex/cache": "^
|
|
931
|
-
"@ooneex/container": "^
|
|
932
|
-
"@ooneex/database": "^
|
|
933
|
-
"@ooneex/logger": "^
|
|
934
|
-
"@ooneex/mailer": "^
|
|
935
|
-
"@ooneex/middleware": "^
|
|
936
|
-
"@ooneex/module": "^
|
|
937
|
-
"@ooneex/rate-limit": "^
|
|
938
|
-
"@ooneex/role": "^
|
|
939
|
-
"@ooneex/routing": "^
|
|
940
|
-
"@ooneex/storage": "^
|
|
941
|
-
"@ooneex/translation": "^
|
|
942
|
-
"@ooneex/types": "^
|
|
943
|
-
"@ooneex/utils": "^0.1.
|
|
944
|
-
"@ooneex/validation": "^
|
|
1111
|
+
"@ooneex/analytics": "^1.0.2",
|
|
1112
|
+
"@ooneex/app": "^1.1.1",
|
|
1113
|
+
"@ooneex/app-env": "^1.0.2",
|
|
1114
|
+
"@ooneex/auth": "^1.1.1",
|
|
1115
|
+
"@ooneex/cache": "^1.0.2",
|
|
1116
|
+
"@ooneex/container": "^1.0.1",
|
|
1117
|
+
"@ooneex/database": "^1.0.2",
|
|
1118
|
+
"@ooneex/logger": "^1.1.1",
|
|
1119
|
+
"@ooneex/mailer": "^1.0.2",
|
|
1120
|
+
"@ooneex/middleware": "^1.1.1",
|
|
1121
|
+
"@ooneex/module": "^1.1.1",
|
|
1122
|
+
"@ooneex/rate-limit": "^1.0.2",
|
|
1123
|
+
"@ooneex/role": "^1.0.1",
|
|
1124
|
+
"@ooneex/routing": "^1.1.1",
|
|
1125
|
+
"@ooneex/storage": "^1.0.2",
|
|
1126
|
+
"@ooneex/translation": "^1.0.1",
|
|
1127
|
+
"@ooneex/types": "^1.0.1",
|
|
1128
|
+
"@ooneex/utils": "^0.1.0",
|
|
1129
|
+
"@ooneex/validation": "^1.0.2",
|
|
945
1130
|
"pg": "^8.16.3",
|
|
946
1131
|
"apache-arrow": "^21.1.0",
|
|
947
1132
|
"reflect-metadata": "^0.2.2"
|
|
@@ -954,9 +1139,8 @@ await app.run();
|
|
|
954
1139
|
"@commitlint/types": "^20.3.1",
|
|
955
1140
|
"@nx/js": "^22.3.3",
|
|
956
1141
|
"@nx/workspace": "^22.3.3",
|
|
957
|
-
"@ooneex/
|
|
958
|
-
"@ooneex/
|
|
959
|
-
"@ooneex/seeds": "^0.17.0",
|
|
1142
|
+
"@ooneex/migrations": "^1.1.1",
|
|
1143
|
+
"@ooneex/seeds": "^1.1.1",
|
|
960
1144
|
"@swc-node/register": "^1.11.1",
|
|
961
1145
|
"@swc/core": "^1.15.8",
|
|
962
1146
|
"@swc/helpers": "~0.5.18",
|
|
@@ -976,7 +1160,7 @@ await app.run();
|
|
|
976
1160
|
]
|
|
977
1161
|
}
|
|
978
1162
|
}
|
|
979
|
-
`;var
|
|
1163
|
+
`;var po=`{
|
|
980
1164
|
"compilerOptions": {
|
|
981
1165
|
"jsx": "react-jsx",
|
|
982
1166
|
"lib": ["ES2022", "DOM"],
|
|
@@ -1004,7 +1188,7 @@ await app.run();
|
|
|
1004
1188
|
},
|
|
1005
1189
|
"exclude": ["node_modules", ".github", ".husky", ".nx", ".zed", ".vscode"]
|
|
1006
1190
|
}
|
|
1007
|
-
`;import{join as
|
|
1191
|
+
`;import{join as C}from"path";import{TerminalLogger as Tl}from"@ooneex/logger";import{toKebabCase as vl,toPascalCase as Rl}from"@ooneex/utils";var uo=`#!/usr/bin/env bun
|
|
1008
1192
|
|
|
1009
1193
|
import { migrationUp } from "@ooneex/migrations";
|
|
1010
1194
|
import "@/migrations/migrations";
|
|
@@ -1013,7 +1197,7 @@ await migrationUp({
|
|
|
1013
1197
|
databaseUrl: Bun.env.DATABASE_URL || ":memory:",
|
|
1014
1198
|
tableName: "migrations",
|
|
1015
1199
|
});
|
|
1016
|
-
`;var
|
|
1200
|
+
`;var co=`import type { ModuleType } from "@ooneex/module";
|
|
1017
1201
|
|
|
1018
1202
|
export const {{NAME}}Module: ModuleType = {
|
|
1019
1203
|
controllers: [],
|
|
@@ -1023,7 +1207,7 @@ export const {{NAME}}Module: ModuleType = {
|
|
|
1023
1207
|
cronJobs: [],
|
|
1024
1208
|
events: [],
|
|
1025
1209
|
};
|
|
1026
|
-
`;var
|
|
1210
|
+
`;var ho=`{
|
|
1027
1211
|
"name": "@module/{{NAME}}",
|
|
1028
1212
|
"description": "",
|
|
1029
1213
|
"version": "0.0.1",
|
|
@@ -1034,13 +1218,13 @@ export const {{NAME}}Module: ModuleType = {
|
|
|
1034
1218
|
"seed:run": "bun run ./bin/bin/run.ts"
|
|
1035
1219
|
}
|
|
1036
1220
|
}
|
|
1037
|
-
`;var
|
|
1221
|
+
`;var fo=`#!/usr/bin/env bun
|
|
1038
1222
|
|
|
1039
1223
|
import { seedRun } from "@ooneex/seeds";
|
|
1040
1224
|
import "@/seeds/seeds";
|
|
1041
1225
|
|
|
1042
1226
|
await seedRun();
|
|
1043
|
-
`;var
|
|
1227
|
+
`;var yo=`import { describe, expect, test } from "bun:test";
|
|
1044
1228
|
import { {{NAME}}Module } from "@/{{NAME}}Module";
|
|
1045
1229
|
|
|
1046
1230
|
describe("{{NAME}}Module", () => {
|
|
@@ -1064,7 +1248,7 @@ describe("{{NAME}}Module", () => {
|
|
|
1064
1248
|
expect(Array.isArray({{NAME}}Module.events)).toBe(true);
|
|
1065
1249
|
});
|
|
1066
1250
|
});
|
|
1067
|
-
`;var
|
|
1251
|
+
`;var go=`{
|
|
1068
1252
|
"extends": "../../tsconfig.json",
|
|
1069
1253
|
"compilerOptions": {
|
|
1070
1254
|
"types": ["@types/bun"],
|
|
@@ -1075,10 +1259,10 @@ describe("{{NAME}}Module", () => {
|
|
|
1075
1259
|
"include": ["src/**/*.ts", "src/**/*.tsx", "tests/**/*.ts", "tests/**/*.tsx"],
|
|
1076
1260
|
"exclude": ["node_modules", "dist"]
|
|
1077
1261
|
}
|
|
1078
|
-
`;class
|
|
1079
|
-
`,a=r.lastIndexOf("import "),
|
|
1080
|
-
`,a);r=`${r.slice(0,
|
|
1081
|
-
`)}async run(e){let{cwd:t=process.cwd(),silent:s=!1,skipBin:r=!1,skipMigrations:
|
|
1262
|
+
`;class ce{getName(){return"make:module"}getDescription(){return"Generate a new module"}async addToAppModule(e,t,s){let r=await Bun.file(e).text(),o=`${t}Module`,i=`@${s}/${o}`,n=`import { ${o} } from "${i}";
|
|
1263
|
+
`,a=r.lastIndexOf("import "),l=r.indexOf(`
|
|
1264
|
+
`,a);r=`${r.slice(0,l+1)}${n}${r.slice(l+1)}`;let m=["controllers","entities","permissions","middlewares","cronJobs","events"];for(let c of m){let p=new RegExp(`(${c}:\\s*\\[)([^\\]]*)`,"s"),u=r.match(p);if(u){let d=u[2]?.trim(),h=`...${o}.${c}`,f=d?`${d}, ${h}`:h;r=r.replace(p,`$1${f}`)}}await Bun.write(e,r)}async addPathAlias(e,t){let s=await Bun.file(e).text(),r=JSON.parse(s);r.compilerOptions??={},r.compilerOptions.paths??={},r.compilerOptions.paths[`@${t}/*`]=[`../${t}/src/*`],await Bun.write(e,`${JSON.stringify(r,null,2)}
|
|
1265
|
+
`)}async run(e){let{cwd:t=process.cwd(),silent:s=!1,skipBin:r=!1,skipMigrations:o=!1,skipSeeds:i=!1}=e,{name:n}=e;if(!n)n=await S({message:"Enter module name"});let a=Rl(n).replace(/Module$/,""),l=vl(a),m=C(t,"modules",l),c=C(m,"bin"),p=C(m,"src"),u=C(m,"tests"),d=co.replace(/{{NAME}}/g,a),h=ho.replace(/{{NAME}}/g,l),f=yo.replace(/{{NAME}}/g,a);if(!r)await Bun.write(C(c,"migration","up.ts"),uo),await Bun.write(C(c,"seed","run.ts"),fo);if(await Bun.write(C(p,`${a}Module.ts`),d),!o)await Bun.write(C(p,"migrations","migrations.ts"),"");if(!i)await Bun.write(C(p,"seeds","seeds.ts"),"");if(await Bun.write(C(m,"package.json"),h),await Bun.write(C(m,"tsconfig.json"),go),await Bun.write(C(u,`${a}Module.spec.ts`),f),l!=="app"){let y=C(t,"modules","app","src","AppModule.ts");if(await Bun.file(y).exists())await this.addToAppModule(y,a,l)}let x=C(t,"modules","app","tsconfig.json");if(await Bun.file(x).exists())await this.addPathAlias(x,l);if(!s)new Tl().success(`modules/${l} created successfully`,void 0,{showTimestamp:!1,showArrow:!1,useSymbol:!0})}}ce=g([E.command()],ce);class Le{getName(){return"make:app"}getDescription(){return"Generate a new application"}async run(e){let{name:t,destination:s}=e;if(!t)t=await S({message:"Enter application name"});let r=Ol(t);if(!s)s=await kr({message:"Enter destination path",initial:r});let o=mo.replace(/{{NAME}}/g,r);await Bun.write(v(s,".commitlintrc.ts"),eo),await Bun.write(v(s,".gitignore"),to),await Bun.write(v(s,"biome.jsonc"),ro),await Bun.write(v(s,"bunfig.toml"),oo),await Bun.write(v(s,"nx.json"),lo),await Bun.write(v(s,"package.json"),o),await Bun.write(v(s,"tsconfig.json"),po),await Bun.write(v(s,".husky","commit-msg"),'bunx commitlint --edit "$1"'),await Bun.write(v(s,".husky","pre-commit"),"lint-staged"),await new ce().run({name:"app",cwd:s,silent:!0,skipBin:!0,skipMigrations:!0,skipSeeds:!0});let n=v(s,"modules","app","package.json"),a=await Bun.file(n).json();a.scripts.dev="docker compose up -d && bun --hot run ./src/index.ts",a.scripts.build="bun build ./src/index.ts --outdir ./dist --target bun",await Bun.write(n,JSON.stringify(a,null,2));let l=Mt.replace("DATABASE_URL=",'DATABASE_URL="postgresql://ooneex:ooneex@localhost:5432/ooneex"').replace("CACHE_REDIS_URL=",'CACHE_REDIS_URL="redis://localhost:6379"').replace("PUBSUB_REDIS_URL=",'PUBSUB_REDIS_URL="redis://localhost:6379"').replace("RATE_LIMIT_REDIS_URL=",'RATE_LIMIT_REDIS_URL="redis://localhost:6379"').replace("DATABASE_REDIS_URL=",'DATABASE_REDIS_URL="redis://localhost:6379"');await Bun.write(v(s,"modules","app",".env"),l),await Bun.write(v(s,"modules","app",".env.example"),Mt),await Bun.write(v(s,"modules","app","src","databases","AppDatabase.ts"),so),await Bun.write(v(s,"modules","app","src","index.ts"),ao);let m=Cl(t),c=no.replace(/{{NAME}}/g,m);await Bun.write(v(s,"modules","app","docker-compose.yml"),c);let p=io.replace(/{{NAME}}/g,m);await Bun.write(v(s,"modules","app","Dockerfile"),p),await Bun.write(v(s,"modules","app","var",".gitkeep"),""),new Dl().success(`${r} created successfully at ${s}`,void 0,{showTimestamp:!1,showArrow:!1,useSymbol:!0})}}Le=g([E.command()],Le);import{join as F}from"path";import{TerminalLogger as Ll}from"@ooneex/logger";import{toPascalCase as Il}from"@ooneex/utils";var Eo=`import { describe, expect, test } from "bun:test";
|
|
1082
1266
|
import { {{NAME}}Cache } from "@/cache/{{NAME}}Cache";
|
|
1083
1267
|
|
|
1084
1268
|
describe("{{NAME}}Cache", () => {
|
|
@@ -1106,7 +1290,7 @@ describe("{{NAME}}Cache", () => {
|
|
|
1106
1290
|
expect(typeof {{NAME}}Cache.prototype.has).toBe("function");
|
|
1107
1291
|
});
|
|
1108
1292
|
});
|
|
1109
|
-
`;var
|
|
1293
|
+
`;var Ao=`import { CacheException, decorator } from "@ooneex/cache";
|
|
1110
1294
|
import type { ICache } from "@ooneex/cache";
|
|
1111
1295
|
|
|
1112
1296
|
@decorator.cache()
|
|
@@ -1127,7 +1311,7 @@ export class {{NAME}}Cache implements ICache {
|
|
|
1127
1311
|
throw new CacheException(\`Failed to check if key "\${key}" exists: Not implemented\`);
|
|
1128
1312
|
}
|
|
1129
1313
|
}
|
|
1130
|
-
`;class Ie{getName(){return"make:cache"}getDescription(){return"Generate a new cache class"}async run(e){let{name:t}=e;if(!t)t=await
|
|
1314
|
+
`;class Ie{getName(){return"make:cache"}getDescription(){return"Generate a new cache class"}async run(e){let{name:t,module:s}=e;if(!t)t=await S({message:"Enter cache name"});t=Il(t).replace(/Cache$/,"");let r=Ao.replace(/{{NAME}}/g,t),o=s?F("modules",s):".",i=F(o,"src","cache"),n=F(process.cwd(),i),a=F(n,`${t}Cache.ts`);await Bun.write(a,r);let l=Eo.replace(/{{NAME}}/g,t),m=F(o,"tests","cache"),c=F(process.cwd(),m),p=F(c,`${t}Cache.spec.ts`);await Bun.write(p,l);let u=new Ll;u.success(`${F(i,t)}Cache.ts created successfully`,void 0,{showTimestamp:!1,showArrow:!1,useSymbol:!0}),u.success(`${F(m,t)}Cache.spec.ts created successfully`,void 0,{showTimestamp:!1,showArrow:!1,useSymbol:!0})}}Ie=g([E.command()],Ie);import{basename as $l,join as he}from"path";import{TerminalLogger as Ul}from"@ooneex/logger";var{Glob:Gl}=globalThis.Bun;class $e{getName(){return"make:claude:skill"}getDescription(){return"Generate Claude skills from templates"}async run(){let e=he(import.meta.dir,"..","templates","claude","skills"),t=he(".claude","skills"),s=he(process.cwd(),t),r=new Gl("*.md.txt"),o=new Ul;for await(let i of r.scan(e)){let n=await Bun.file(he(e,i)).text(),a=$l(i,".md.txt"),l=he(s,`${a}.md`);await Bun.write(l,n),o.success(`${he(t,a)}.md created successfully`,void 0,{showTimestamp:!1,showArrow:!1,useSymbol:!0})}}}$e=g([E.command()],$e);import{basename as tm,join as B}from"path";import{TerminalLogger as sm}from"@ooneex/logger";import{toKebabCase as rm,toPascalCase as Dt,trim as om}from"@ooneex/utils";var bo=te(ne(),1),Ue=async(e)=>{return(await bo.prompt({type:"confirm",name:"confirm",message:e.message})).confirm};var xe=["GET","POST","PUT","DELETE","PATCH","OPTIONS","HEAD"];var xo=te(ne(),1);import{Assert as ql,Validation as Wl}from"@ooneex/validation";class Tt extends Wl{getConstraint(){return ql("string >= 3")}getErrorMessage(){return`Route method must be one of: ${xe.join(", ")}`}validate(e,t){let s=super.validate(e,t);if(!s.isValid)return s;let r=e;if(r.trim()!==r)return{isValid:!1,message:this.getErrorMessage()||"Invalid route method format"};let o=r.toUpperCase();if(!xe.includes(o))return{isValid:!1,message:this.getErrorMessage()||"Invalid route method"};return{isValid:!0}}}var wo=async(e)=>{return(await xo.prompt({type:"select",name:"method",message:e.message,initial:e.initial??0,choices:xe.map((s)=>s),validate:(s)=>{let o=new Tt().validate(s);if(!o.isValid)return o.message||"Route method is invalid";return!0}})).method};var So=te(ne(),1);import{Assert as Kl,Validation as Hl}from"@ooneex/validation";var Yl=/^[a-zA-Z0-9]+\.[a-zA-Z0-9]+\.[a-zA-Z0-9]+$/;class vt extends Hl{getConstraint(){return Kl("string >= 7")}getErrorMessage(){return"Route name must follow format: namespace.resource.action (e.g., 'api.users.list')"}validate(e,t){let s=super.validate(e,t);if(!s.isValid)return s;let r=e;if(r.trim()!==r)return{isValid:!1,message:this.getErrorMessage()||"Invalid route name format"};if(!Yl.test(r))return{isValid:!1,message:this.getErrorMessage()||"Invalid route name format"};let o=r.split(".");if(o.length!==3)return{isValid:!1,message:this.getErrorMessage()||"Invalid route name format"};let[i,n,a]=o;if(!i||!n||!a)return{isValid:!1,message:this.getErrorMessage()||"Invalid route name format"};return{isValid:!0}}}var _o=async(e)=>{return(await So.prompt({type:"input",name:"routeName",message:e.message,validate:(s)=>{let o=new vt().validate(s);if(!o.isValid)return o.message||"Route name is invalid";return!0}})).routeName};var No=te(ne(),1);import{Assert as Vl,Validation as Fl}from"@ooneex/validation";var Ql=1,zl=/^\/[\w\-/:]*$/,Zl=/^[a-zA-Z0-9\-_]+$/,Xl=/^:[a-zA-Z][a-zA-Z0-9]*$/;class Rt extends Fl{getConstraint(){return Vl(`string >= ${Ql}`)}getErrorMessage(){return"Route path must start with '/' and contain only valid segments (e.g., '/users', '/api/users/:id')"}validate(e,t){let s=super.validate(e,t);if(!s.isValid)return s;let r=e;if(r.trim()!==r)return{isValid:!1,message:this.getErrorMessage()||"Invalid route path format"};if(!r.startsWith("/"))return{isValid:!1,message:"Route path must start with '/'"};if(r.length>1&&r.endsWith("/"))return{isValid:!1,message:"Route path cannot end with '/' (except for root path)"};if(!zl.test(r))return{isValid:!1,message:this.getErrorMessage()||"Invalid route path format"};if(r==="/")return{isValid:!0};let o=r.slice(1).split("/");for(let i of o){if(!i)return{isValid:!1,message:"Route path cannot contain empty segments (double slashes)"};if(i.startsWith(":")){if(!Xl.test(i))return{isValid:!1,message:`Invalid parameter segment '${i}'. Parameters must follow format ':paramName' with alphanumeric characters only`}}else if(!Zl.test(i))return{isValid:!1,message:`Invalid path segment '${i}'. Segments must contain only letters, numbers, hyphens, and underscores`}}return{isValid:!0}}}var Mo=async(e)=>{return(await No.prompt({type:"input",name:"path",message:e.message,initial:e.initial??"/",validate:(s)=>{let o=new Rt().validate(s);if(!o.isValid)return o.message||"Route path is invalid";return!0}})).path};var To=`import type { ContextType } from "@ooneex/socket";
|
|
1131
1315
|
import { ERole } from "@ooneex/role";
|
|
1132
1316
|
import { Route } from "@ooneex/routing";
|
|
1133
1317
|
import { Assert } from "@ooneex/validation";
|
|
@@ -1160,7 +1344,7 @@ export class {{NAME}}Controller {
|
|
|
1160
1344
|
});
|
|
1161
1345
|
}
|
|
1162
1346
|
}
|
|
1163
|
-
`;var
|
|
1347
|
+
`;var vo=`import { describe, expect, test } from "bun:test";
|
|
1164
1348
|
import { {{NAME}}Controller } from "@/controllers/{{NAME}}Controller";
|
|
1165
1349
|
|
|
1166
1350
|
describe("{{NAME}}Controller", () => {
|
|
@@ -1173,7 +1357,7 @@ describe("{{NAME}}Controller", () => {
|
|
|
1173
1357
|
expect(typeof {{NAME}}Controller.prototype.index).toBe("function");
|
|
1174
1358
|
});
|
|
1175
1359
|
});
|
|
1176
|
-
`;var
|
|
1360
|
+
`;var Ro=`import type { ContextType } from "@ooneex/controller";
|
|
1177
1361
|
import { ERole } from "@ooneex/role";
|
|
1178
1362
|
import { Route } from "@ooneex/routing";
|
|
1179
1363
|
import { Assert } from "@ooneex/validation";
|
|
@@ -1206,7 +1390,7 @@ export class {{NAME}}Controller {
|
|
|
1206
1390
|
});
|
|
1207
1391
|
}
|
|
1208
1392
|
}
|
|
1209
|
-
`;var
|
|
1393
|
+
`;var Do=`export type {{TYPE_NAME}}RouteType = {
|
|
1210
1394
|
params: {
|
|
1211
1395
|
|
|
1212
1396
|
},
|
|
@@ -1220,9 +1404,9 @@ export class {{NAME}}Controller {
|
|
|
1220
1404
|
|
|
1221
1405
|
},
|
|
1222
1406
|
};
|
|
1223
|
-
`;class Ge{getName(){return"make:controller"}getDescription(){return"Generate a new controller class"}async addToModule(e,t){let s=await Bun.file(e).text(),r=`${t}Controller`,
|
|
1224
|
-
`,
|
|
1225
|
-
`,
|
|
1407
|
+
`;class Ge{getName(){return"make:controller"}getDescription(){return"Generate a new controller class"}async addToModule(e,t){let s=await Bun.file(e).text(),r=`${t}Controller`,o=`import { ${r} } from "./controllers/${r}";
|
|
1408
|
+
`,i=s.lastIndexOf("import "),n=s.indexOf(`
|
|
1409
|
+
`,i);s=`${s.slice(0,n+1)}${o}${s.slice(n+1)}`;let a=/(controllers:\s*\[)([^\]]*)/s,l=s.match(a);if(l){let m=l[2]?.trim(),c=m?`${m}, ${r}`:r;s=s.replace(a,`$1${c}`)}await Bun.write(e,s)}async run(e){let{name:t,module:s,isSocket:r}=e;if(!t)t=await S({message:"Enter controller name"});if(r===void 0)r=await Ue({message:"Is this a socket controller?"});t=Dt(t).replace(/Controller$/,"");let{route:o={}}=e,n=(r?To:Ro).replaceAll("{{NAME}}",t),a="",l="";if(!o.name)o.name=await _o({message:"Enter route name (e.g., api.user.create)"});if(a=Dt(o.name),l=o.name,n=n.replaceAll("{{ROUTE_NAME}}",o.name).replaceAll("{{TYPE_NAME}}",a).replaceAll("{{TYPE_NAME_FILE}}",l),!o.path)o.path=await Mo({message:"Enter route path",initial:"/"});let m=`/${rm(om(o.path,"/"))}`;if(n=n.replaceAll("{{ROUTE_PATH}}",m),!r&&!o.method)o.method=await wo({message:"Enter route method"});if(!r&&o.method)n=n.replaceAll("{{ROUTE_METHOD}}",o.method.toLowerCase());let c=s?B("modules",s):".",p=B(c,"src","controllers"),u=B(process.cwd(),p),d=B(u,`${t}Controller.ts`);await Bun.write(d,n);let h=B(c,"src","types","routes"),f=B(process.cwd(),h),x=B(f,`${l}.ts`),y=Do.replaceAll("{{TYPE_NAME}}",a);await Bun.write(x,y);let b=vo.replace(/{{NAME}}/g,t),w=B(c,"tests","controllers"),_=B(process.cwd(),w),M=B(_,`${t}Controller.spec.ts`);await Bun.write(M,b);let D=Dt(tm(process.cwd())),we=B(process.cwd(),"src",`${D}Module.ts`);if(await Bun.file(we).exists())await this.addToModule(we,t);let ee=new sm;ee.success(`${B(p,t)}Controller.ts created successfully`,void 0,{showTimestamp:!1,showArrow:!1,useSymbol:!0}),ee.success(`${B(h,l)}.ts created successfully`,void 0,{showTimestamp:!1,showArrow:!1,useSymbol:!0}),ee.success(`${B(w,t)}Controller.spec.ts created successfully`,void 0,{showTimestamp:!1,showArrow:!1,useSymbol:!0})}}Ge=g([E.command()],Ge);import{basename as am,join as U}from"path";import{TerminalLogger as lm}from"@ooneex/logger";import{toPascalCase as Bo}from"@ooneex/utils";var Oo=`import { describe, expect, test } from "bun:test";
|
|
1226
1410
|
import { {{NAME}}Cron } from "@/cron/{{NAME}}Cron";
|
|
1227
1411
|
|
|
1228
1412
|
describe("{{NAME}}Cron", () => {
|
|
@@ -1245,7 +1429,7 @@ describe("{{NAME}}Cron", () => {
|
|
|
1245
1429
|
expect(typeof {{NAME}}Cron.prototype.handler).toBe("function");
|
|
1246
1430
|
});
|
|
1247
1431
|
});
|
|
1248
|
-
`;var
|
|
1432
|
+
`;var Co=`import type { TimeZoneType } from "@ooneex/country";
|
|
1249
1433
|
import type { CronTimeType } from "@ooneex/cron";
|
|
1250
1434
|
import { Cron, decorator } from "@ooneex/cron";
|
|
1251
1435
|
|
|
@@ -1266,9 +1450,9 @@ export class {{NAME}}Cron extends Cron {
|
|
|
1266
1450
|
// console.log("{{NAME}}Cron handler executed");
|
|
1267
1451
|
}
|
|
1268
1452
|
}
|
|
1269
|
-
`;class
|
|
1270
|
-
`,
|
|
1271
|
-
`,
|
|
1453
|
+
`;class qe{getName(){return"make:cron"}getDescription(){return"Generate a new cron class"}async addToModule(e,t){let s=await Bun.file(e).text(),r=`${t}Cron`,o=`import { ${r} } from "./cron/${r}";
|
|
1454
|
+
`,i=s.lastIndexOf("import "),n=s.indexOf(`
|
|
1455
|
+
`,i);s=`${s.slice(0,n+1)}${o}${s.slice(n+1)}`;let a=/(cronJobs:\s*\[)([^\]]*)/s,l=s.match(a);if(l){let m=l[2]?.trim(),c=m?`${m}, ${r}`:r;s=s.replace(a,`$1${c}`)}await Bun.write(e,s)}async run(e){let{name:t,module:s}=e;if(!t)t=await S({message:"Enter cron name"});t=Bo(t).replace(/Cron$/,"");let r=Co.replace(/{{NAME}}/g,t),o=s?U("modules",s):".",i=U(o,"src","cron"),n=U(process.cwd(),i),a=U(n,`${t}Cron.ts`);await Bun.write(a,r);let l=Oo.replace(/{{NAME}}/g,t),m=U(o,"tests","cron"),c=U(process.cwd(),m),p=U(c,`${t}Cron.spec.ts`);await Bun.write(p,l);let u=Bo(am(process.cwd())),d=U(process.cwd(),"src",`${u}Module.ts`);if(await Bun.file(d).exists())await this.addToModule(d,t);let h=new lm;h.success(`${U(i,t)}Cron.ts created successfully`,void 0,{showTimestamp:!1,showArrow:!1,useSymbol:!0}),h.success(`${U(m,t)}Cron.spec.ts created successfully`,void 0,{showTimestamp:!1,showArrow:!1,useSymbol:!0})}}qe=g([E.command()],qe);import{join as Q}from"path";import{TerminalLogger as pm}from"@ooneex/logger";import{toPascalCase as um}from"@ooneex/utils";var Po=`import { describe, expect, test } from "bun:test";
|
|
1272
1456
|
import { {{NAME}}Database } from "@/databases/{{NAME}}Database";
|
|
1273
1457
|
|
|
1274
1458
|
describe("{{NAME}}Database", () => {
|
|
@@ -1281,7 +1465,7 @@ describe("{{NAME}}Database", () => {
|
|
|
1281
1465
|
expect(typeof {{NAME}}Database.prototype.getSource).toBe("function");
|
|
1282
1466
|
});
|
|
1283
1467
|
});
|
|
1284
|
-
`;var
|
|
1468
|
+
`;var Lo=`import { DataSource } from "typeorm";
|
|
1285
1469
|
import { TypeormDatabase, DatabaseException, decorator } from "@ooneex/database";
|
|
1286
1470
|
|
|
1287
1471
|
@decorator.database()
|
|
@@ -1304,7 +1488,7 @@ export class {{NAME}}Database extends TypeormDatabase {
|
|
|
1304
1488
|
return this.source;
|
|
1305
1489
|
}
|
|
1306
1490
|
}
|
|
1307
|
-
`;class
|
|
1491
|
+
`;class We{getName(){return"make:database"}getDescription(){return"Generate a new database class"}async run(e){let{name:t,module:s}=e;if(!t)t=await S({message:"Enter database name"});t=um(t).replace(/DatabaseAdapter$/,"").replace(/Database$/,"");let r=Lo.replace(/{{NAME}}/g,t),o=s?Q("modules",s):".",i=Q(o,"src","databases"),n=Q(process.cwd(),i),a=Q(n,`${t}Database.ts`);await Bun.write(a,r);let l=Po.replace(/{{NAME}}/g,t),m=Q(o,"tests","databases"),c=Q(process.cwd(),m),p=Q(c,`${t}Database.spec.ts`);await Bun.write(p,l);let u=new pm;u.success(`${Q(i,t)}Database.ts created successfully`,void 0,{showTimestamp:!1,showArrow:!1,useSymbol:!0}),u.success(`${Q(m,t)}Database.spec.ts created successfully`,void 0,{showTimestamp:!1,showArrow:!1,useSymbol:!0})}}We=g([E.command()],We);import{join as ii}from"path";import{TerminalLogger as Cm}from"@ooneex/logger";var{YAML:ni}=globalThis.Bun;var $o=te(ne(),1),Io=["clickhouse","elasticsearch","grafana","jaeger","keycloak","libretranslate","maildev","memcached","minio","mongodb","mysql","nats","postgres","prometheus","rabbitmq","redis","temporal","vault"],Uo=async(e)=>{return(await $o.prompt({type:"autocomplete",name:"service",message:e.message,initial:e.initial,choices:Io.map((s)=>s),validate:(s)=>{if(!Io.includes(s))return"Docker service is invalid";return!0}})).service};var Go=`services:
|
|
1308
1492
|
# ClickHouse - Column-oriented OLAP database for analytics
|
|
1309
1493
|
# Docs: https://clickhouse.com/docs
|
|
1310
1494
|
# HTTP API: http://localhost:8123
|
|
@@ -1325,7 +1509,7 @@ export class {{NAME}}Database extends TypeormDatabase {
|
|
|
1325
1509
|
|
|
1326
1510
|
volumes:
|
|
1327
1511
|
clickhouse_data:
|
|
1328
|
-
`;var
|
|
1512
|
+
`;var qo=`services:
|
|
1329
1513
|
# Elasticsearch - Full-text search and analytics engine
|
|
1330
1514
|
# Docs: https://www.elastic.co/guide/en/elasticsearch/reference/current/index.html
|
|
1331
1515
|
# HTTP API: http://localhost:9200
|
|
@@ -1346,7 +1530,7 @@ volumes:
|
|
|
1346
1530
|
|
|
1347
1531
|
volumes:
|
|
1348
1532
|
elasticsearch_data:
|
|
1349
|
-
`;var
|
|
1533
|
+
`;var Wo=`services:
|
|
1350
1534
|
# Grafana - Metrics visualization and dashboards
|
|
1351
1535
|
# Docs: https://grafana.com/docs/grafana/latest/
|
|
1352
1536
|
# Web UI: http://localhost:3000 (ooneex/ooneex)
|
|
@@ -1364,7 +1548,7 @@ volumes:
|
|
|
1364
1548
|
|
|
1365
1549
|
volumes:
|
|
1366
1550
|
grafana_data:
|
|
1367
|
-
`;var
|
|
1551
|
+
`;var Ko=`services:
|
|
1368
1552
|
# Jaeger - Distributed tracing system
|
|
1369
1553
|
# Docs: https://www.jaegertracing.io/docs/
|
|
1370
1554
|
# Web UI: http://localhost:16686
|
|
@@ -1378,7 +1562,7 @@ volumes:
|
|
|
1378
1562
|
- "16686:16686"
|
|
1379
1563
|
- "6831:6831/udp"
|
|
1380
1564
|
- "14268:14268"
|
|
1381
|
-
`;var
|
|
1565
|
+
`;var Ho=`services:
|
|
1382
1566
|
# Keycloak - Identity and access management
|
|
1383
1567
|
# Docs: https://www.keycloak.org/documentation
|
|
1384
1568
|
# Admin Console: http://localhost:8080 (ooneex/ooneex)
|
|
@@ -1392,7 +1576,7 @@ volumes:
|
|
|
1392
1576
|
- KEYCLOAK_ADMIN=ooneex
|
|
1393
1577
|
- KEYCLOAK_ADMIN_PASSWORD=ooneex
|
|
1394
1578
|
command: start-dev
|
|
1395
|
-
`;var
|
|
1579
|
+
`;var Yo=`services:
|
|
1396
1580
|
# LibreTranslate - Self-hosted machine translation API
|
|
1397
1581
|
# Docs: https://libretranslate.com/docs/
|
|
1398
1582
|
# API: http://localhost:4000
|
|
@@ -1419,7 +1603,7 @@ volumes:
|
|
|
1419
1603
|
|
|
1420
1604
|
volumes:
|
|
1421
1605
|
libretranslate_models:
|
|
1422
|
-
`;var
|
|
1606
|
+
`;var Vo=`services:
|
|
1423
1607
|
# MailDev - Email testing tool with web UI
|
|
1424
1608
|
# Docs: https://github.com/maildev/maildev
|
|
1425
1609
|
# Web UI: http://localhost:1080
|
|
@@ -1430,7 +1614,7 @@ volumes:
|
|
|
1430
1614
|
ports:
|
|
1431
1615
|
- "1080:1080"
|
|
1432
1616
|
- "1025:1025"
|
|
1433
|
-
`;var
|
|
1617
|
+
`;var Fo=`services:
|
|
1434
1618
|
# Memcached - Distributed memory caching system
|
|
1435
1619
|
# Docs: https://memcached.org/
|
|
1436
1620
|
# Connection: localhost:11211
|
|
@@ -1440,7 +1624,7 @@ volumes:
|
|
|
1440
1624
|
restart: "on-failure"
|
|
1441
1625
|
ports:
|
|
1442
1626
|
- "11211:11211"
|
|
1443
|
-
`;var
|
|
1627
|
+
`;var Qo=`services:
|
|
1444
1628
|
# MinIO - S3-compatible object storage
|
|
1445
1629
|
# Docs: https://min.io/docs/minio/container/index.html
|
|
1446
1630
|
# API: http://localhost:9000
|
|
@@ -1461,7 +1645,7 @@ volumes:
|
|
|
1461
1645
|
|
|
1462
1646
|
volumes:
|
|
1463
1647
|
minio_data:
|
|
1464
|
-
`;var
|
|
1648
|
+
`;var zo=`services:
|
|
1465
1649
|
# MongoDB - NoSQL document database
|
|
1466
1650
|
# Docs: https://www.mongodb.com/docs/
|
|
1467
1651
|
# Connection: mongodb://ooneex:ooneex@localhost:27017/ooneex
|
|
@@ -1480,7 +1664,7 @@ volumes:
|
|
|
1480
1664
|
|
|
1481
1665
|
volumes:
|
|
1482
1666
|
mongodb_data:
|
|
1483
|
-
`;var
|
|
1667
|
+
`;var Zo=`services:
|
|
1484
1668
|
# MySQL - Alternative relational database
|
|
1485
1669
|
# Docs: https://dev.mysql.com/doc/
|
|
1486
1670
|
# Connection: mysql://ooneex:ooneex@localhost:3306/ooneex
|
|
@@ -1500,7 +1684,7 @@ volumes:
|
|
|
1500
1684
|
|
|
1501
1685
|
volumes:
|
|
1502
1686
|
mysql_db:
|
|
1503
|
-
`;var
|
|
1687
|
+
`;var Xo=`services:
|
|
1504
1688
|
# NATS - High-performance messaging system with JetStream
|
|
1505
1689
|
# Docs: https://docs.nats.io/
|
|
1506
1690
|
# Client: localhost:4222
|
|
@@ -1513,7 +1697,7 @@ volumes:
|
|
|
1513
1697
|
- "4222:4222"
|
|
1514
1698
|
- "8222:8222"
|
|
1515
1699
|
command: "--jetstream --http_port 8222"
|
|
1516
|
-
`;var
|
|
1700
|
+
`;var Jo=`services:
|
|
1517
1701
|
# Jade - FastAPI REST API to fetch YouTube metadata and download videos or audio via Dockerized microservice.
|
|
1518
1702
|
# API: http://localhost:8000
|
|
1519
1703
|
# Docs: http://localhost:8000/docs
|
|
@@ -1531,7 +1715,7 @@ volumes:
|
|
|
1531
1715
|
|
|
1532
1716
|
volumes:
|
|
1533
1717
|
jade_data:
|
|
1534
|
-
`;var
|
|
1718
|
+
`;var jo=`services:
|
|
1535
1719
|
# PostgreSQL - Primary relational database
|
|
1536
1720
|
# Docs: https://www.postgresql.org/docs/
|
|
1537
1721
|
# Connection: postgresql://ooneex:ooneex@localhost:5432/ooneex
|
|
@@ -1552,7 +1736,7 @@ volumes:
|
|
|
1552
1736
|
|
|
1553
1737
|
volumes:
|
|
1554
1738
|
postgres_db:
|
|
1555
|
-
`;var
|
|
1739
|
+
`;var ko=`services:
|
|
1556
1740
|
# Prometheus - Metrics collection and monitoring
|
|
1557
1741
|
# Docs: https://prometheus.io/docs/
|
|
1558
1742
|
# Web UI: http://localhost:9090
|
|
@@ -1567,7 +1751,7 @@ volumes:
|
|
|
1567
1751
|
|
|
1568
1752
|
volumes:
|
|
1569
1753
|
prometheus_data:
|
|
1570
|
-
`;var
|
|
1754
|
+
`;var ei=`services:
|
|
1571
1755
|
# RabbitMQ - Message broker for async processing
|
|
1572
1756
|
# Docs: https://www.rabbitmq.com/docs
|
|
1573
1757
|
# AMQP: amqp://ooneex:ooneex@localhost:5672/ooneex
|
|
@@ -1589,7 +1773,7 @@ volumes:
|
|
|
1589
1773
|
|
|
1590
1774
|
volumes:
|
|
1591
1775
|
rabbitmq_data:
|
|
1592
|
-
`;var
|
|
1776
|
+
`;var ti=`services:
|
|
1593
1777
|
# Redis - In-memory data store for caching and sessions
|
|
1594
1778
|
# Docs: https://redis.io/docs/
|
|
1595
1779
|
# Connection: redis://localhost:6379
|
|
@@ -1604,7 +1788,7 @@ volumes:
|
|
|
1604
1788
|
|
|
1605
1789
|
volumes:
|
|
1606
1790
|
redis_data:
|
|
1607
|
-
`;var
|
|
1791
|
+
`;var si=`services:
|
|
1608
1792
|
# Temporal - Workflow orchestration engine
|
|
1609
1793
|
# Docs: https://docs.temporal.io/
|
|
1610
1794
|
# gRPC: localhost:7233
|
|
@@ -1621,7 +1805,7 @@ volumes:
|
|
|
1621
1805
|
- POSTGRES_USER=ooneex
|
|
1622
1806
|
- POSTGRES_PWD=ooneex
|
|
1623
1807
|
- POSTGRES_SEEDS=postgres
|
|
1624
|
-
`;var
|
|
1808
|
+
`;var ri=`services:
|
|
1625
1809
|
# Vault - Secrets management and encryption
|
|
1626
1810
|
# Docs: https://developer.hashicorp.com/vault/docs
|
|
1627
1811
|
# Web UI: http://localhost:8200 (token: ooneex)
|
|
@@ -1636,20 +1820,20 @@ volumes:
|
|
|
1636
1820
|
- VAULT_DEV_LISTEN_ADDRESS=0.0.0.0:8200
|
|
1637
1821
|
cap_add:
|
|
1638
1822
|
- IPC_LOCK
|
|
1639
|
-
`;var
|
|
1640
|
-
`),s=[],r=!1;for(let
|
|
1641
|
-
`)}function
|
|
1642
|
-
volumes:`),u
|
|
1643
|
-
networks:`),
|
|
1644
|
-
${c}${
|
|
1645
|
-
${c}`;for(let
|
|
1646
|
-
volumes:`)){let
|
|
1647
|
-
volumes:`),b=
|
|
1648
|
-
${
|
|
1823
|
+
`;var oi={clickhouse:Go,elasticsearch:qo,grafana:Wo,"ooneex-jade":Jo,jaeger:Ko,keycloak:Ho,libretranslate:Yo,maildev:Vo,memcached:Fo,minio:Qo,mongodb:zo,mysql:Zo,nats:Xo,postgres:jo,prometheus:ko,rabbitmq:ei,redis:ti,temporal:si,vault:ri};function Bm(e){let t=e.split(`
|
|
1824
|
+
`),s=[],r=!1;for(let o of t){if(o.startsWith("services:")){r=!0;continue}if(r){if(o.startsWith("volumes:")||o.startsWith("networks:"))break;s.push(o)}}return s.join(`
|
|
1825
|
+
`)}function Pm(e){let t=ni.parse(e);return t.volumes?Object.keys(t.volumes):[]}class Ke{getName(){return"make:docker"}getDescription(){return"Add a docker service to docker-compose.yml"}async run(e){let{name:t}=e;if(!t)t=await Uo({message:"Select docker service"});let s=oi[t],r=ii(process.cwd(),"docker-compose.yml"),o=new Cm,i=Bun.file(r);if(await i.exists()){let l=await i.text(),m=ni.parse(l);if(m.services&&t in m.services){o.warn(`Service "${t}" already exists in docker-compose.yml`,void 0,{showTimestamp:!1,showArrow:!1,useSymbol:!0});return}let c=Bm(s),p=Pm(s),u=l,d=u.indexOf(`
|
|
1826
|
+
volumes:`),h=u.indexOf(`
|
|
1827
|
+
networks:`),f=-1;if(d!==-1&&h!==-1)f=Math.min(d,h);else if(d!==-1)f=d;else if(h!==-1)f=h;if(f!==-1)u=`${u.slice(0,f)}
|
|
1828
|
+
${c}${u.slice(f)}`;else u=`${u.trimEnd()}
|
|
1829
|
+
${c}`;for(let x of p)if(!u.includes(` ${x}:`))if(u.includes(`
|
|
1830
|
+
volumes:`)){let y=u.indexOf(`
|
|
1831
|
+
volumes:`),b=u.slice(y+9);u=`${u.slice(0,y+9)}
|
|
1832
|
+
${x}:${b}`}else u=`${u.trimEnd()}
|
|
1649
1833
|
|
|
1650
1834
|
volumes:
|
|
1651
|
-
${
|
|
1652
|
-
`;await Bun.write(r,
|
|
1835
|
+
${x}:
|
|
1836
|
+
`;await Bun.write(r,u)}else await Bun.write(r,s);let n=ii(process.cwd(),"package.json"),a=Bun.file(n);if(await a.exists()){let l=await a.json();l.scripts=l.scripts||{},l.scripts.docker="docker compose up -d",await Bun.write(n,JSON.stringify(l,null,2))}o.success(`Service "${t}" added to docker-compose.yml`,void 0,{showTimestamp:!1,showArrow:!1,useSymbol:!0}),o.info("Run 'bun run docker' to start docker containers",void 0,{showTimestamp:!1,showArrow:!0,showLevel:!1})}}Ke=g([E.command()],Ke);var pi=te(ai(),1);import{basename as $m,join as G}from"path";import{TerminalLogger as Um}from"@ooneex/logger";import{toPascalCase as di,toSnakeCase as Gm}from"@ooneex/utils";var li=`import { describe, expect, test } from "bun:test";
|
|
1653
1837
|
import { {{NAME}}Entity } from "@/entities/{{NAME}}Entity";
|
|
1654
1838
|
|
|
1655
1839
|
describe("{{NAME}}Entity", () => {
|
|
@@ -1714,7 +1898,7 @@ describe("{{NAME}}Entity", () => {
|
|
|
1714
1898
|
expect("deletedAt" in entity).toBe(true);
|
|
1715
1899
|
});
|
|
1716
1900
|
});
|
|
1717
|
-
`;var
|
|
1901
|
+
`;var mi=`import type { LocaleType } from "@ooneex/translation";
|
|
1718
1902
|
import { random } from "@ooneex/utils";
|
|
1719
1903
|
import { Column, CreateDateColumn, DeleteDateColumn, PrimaryColumn, UpdateDateColumn } from "typeorm";
|
|
1720
1904
|
|
|
@@ -1765,9 +1949,9 @@ export class {{NAME}}Entity extends BaseEntity {
|
|
|
1765
1949
|
@DeleteDateColumn({ name: "deleted_at" })
|
|
1766
1950
|
deletedAt?: Date;
|
|
1767
1951
|
}
|
|
1768
|
-
`;class He{getName(){return"make:entity"}getDescription(){return"Generate a new entity class"}async addToModule(e,t){let s=await Bun.file(e).text(),r=`${t}Entity`,
|
|
1769
|
-
`,
|
|
1770
|
-
`,
|
|
1952
|
+
`;class He{getName(){return"make:entity"}getDescription(){return"Generate a new entity class"}async addToModule(e,t){let s=await Bun.file(e).text(),r=`${t}Entity`,o=`import { ${r} } from "./entities/${r}";
|
|
1953
|
+
`,i=s.lastIndexOf("import "),n=s.indexOf(`
|
|
1954
|
+
`,i);s=`${s.slice(0,n+1)}${o}${s.slice(n+1)}`;let a=/(entities:\s*\[)([^\]]*)/s,l=s.match(a);if(l){let m=l[2]?.trim(),c=m?`${m}, ${r}`:r;s=s.replace(a,`$1${c}`)}await Bun.write(e,s)}async run(e){let{name:t,module:s,tableName:r}=e;if(!t)t=await S({message:"Enter entity name"});if(t=di(t).replace(/Entity$/,""),!r)r=Gm(pi.default(t));let o=mi.replace(/{{NAME}}/g,t).replace(/{{TABLE_NAME}}/g,r),i=s?G("modules",s):".",n=G(i,"src","entities"),a=G(process.cwd(),n),l=G(a,`${t}Entity.ts`);await Bun.write(l,o);let m=li.replace(/{{NAME}}/g,t),c=G(i,"tests","entities"),p=G(process.cwd(),c),u=G(p,`${t}Entity.spec.ts`);await Bun.write(u,m);let d=di($m(process.cwd())),h=G(process.cwd(),"src",`${d}Module.ts`);if(await Bun.file(h).exists())await this.addToModule(h,t);let f=new Um;f.success(`${G(n,t)}Entity.ts created successfully`,void 0,{showTimestamp:!1,showArrow:!1,useSymbol:!0}),f.success(`${G(c,t)}Entity.spec.ts created successfully`,void 0,{showTimestamp:!1,showArrow:!1,useSymbol:!0})}}He=g([E.command()],He);import{join as z}from"path";import{TerminalLogger as Km}from"@ooneex/logger";import{toPascalCase as Hm}from"@ooneex/utils";var ui=`import { describe, expect, test } from "bun:test";
|
|
1771
1955
|
import { {{NAME}}Logger } from "@/loggers/{{NAME}}Logger";
|
|
1772
1956
|
|
|
1773
1957
|
describe("{{NAME}}Logger", () => {
|
|
@@ -1810,7 +1994,7 @@ describe("{{NAME}}Logger", () => {
|
|
|
1810
1994
|
expect(typeof {{NAME}}Logger.prototype.error).toBe("function");
|
|
1811
1995
|
});
|
|
1812
1996
|
});
|
|
1813
|
-
`;var
|
|
1997
|
+
`;var ci=`import type { IException } from "@ooneex/exception";
|
|
1814
1998
|
import type { ILogger } from "@ooneex/logger";
|
|
1815
1999
|
import type { ScalarType } from "@ooneex/types";
|
|
1816
2000
|
import { decorator } from "@ooneex/logger";
|
|
@@ -1845,7 +2029,7 @@ export class {{NAME}}Logger implements ILogger {
|
|
|
1845
2029
|
// Handle error logging
|
|
1846
2030
|
}
|
|
1847
2031
|
}
|
|
1848
|
-
`;class
|
|
2032
|
+
`;class Ye{getName(){return"make:logger"}getDescription(){return"Generate a new logger class"}async run(e){let{name:t,module:s}=e;if(!t)t=await S({message:"Enter logger name"});t=Hm(t).replace(/Logger$/,"");let r=ci.replace(/{{NAME}}/g,t),o=s?z("modules",s):".",i=z(o,"src","loggers"),n=z(process.cwd(),i),a=z(n,`${t}Logger.ts`);await Bun.write(a,r);let l=ui.replace(/{{NAME}}/g,t),m=z(o,"tests","loggers"),c=z(process.cwd(),m),p=z(c,`${t}Logger.spec.ts`);await Bun.write(p,l);let u=new Km;u.success(`${z(i,t)}Logger.ts created successfully`,void 0,{showTimestamp:!1,showArrow:!1,useSymbol:!0}),u.success(`${z(m,t)}Logger.spec.ts created successfully`,void 0,{showTimestamp:!1,showArrow:!1,useSymbol:!0})}}Ye=g([E.command()],Ye);import{join as P}from"path";import{TerminalLogger as zm}from"@ooneex/logger";import{toPascalCase as Zm}from"@ooneex/utils";var hi=`import { describe, expect, test } from "bun:test";
|
|
1849
2033
|
import { {{NAME}}Mailer } from "@/mailers/{{NAME}}Mailer";
|
|
1850
2034
|
|
|
1851
2035
|
describe("{{NAME}}Mailer", () => {
|
|
@@ -1858,7 +2042,7 @@ describe("{{NAME}}Mailer", () => {
|
|
|
1858
2042
|
expect(typeof {{NAME}}Mailer.prototype.send).toBe("function");
|
|
1859
2043
|
});
|
|
1860
2044
|
});
|
|
1861
|
-
`;var
|
|
2045
|
+
`;var fi=`import { inject } from "@ooneex/container";
|
|
1862
2046
|
import type { IMailer } from "@ooneex/mailer";
|
|
1863
2047
|
import { type {{NAME}}MailerPropsType, {{NAME}}MailerTemplate } from "./{{NAME}}MailerTemplate";
|
|
1864
2048
|
|
|
@@ -1882,7 +2066,7 @@ export class {{NAME}}Mailer implements IMailer {
|
|
|
1882
2066
|
});
|
|
1883
2067
|
}
|
|
1884
2068
|
}
|
|
1885
|
-
`;var
|
|
2069
|
+
`;var yi=`import { describe, expect, test } from "bun:test";
|
|
1886
2070
|
import { {{NAME}}MailerTemplate } from "@/mailers/{{NAME}}MailerTemplate";
|
|
1887
2071
|
|
|
1888
2072
|
describe("{{NAME}}MailerTemplate", () => {
|
|
@@ -1894,7 +2078,7 @@ describe("{{NAME}}MailerTemplate", () => {
|
|
|
1894
2078
|
expect(typeof {{NAME}}MailerTemplate).toBe("function");
|
|
1895
2079
|
});
|
|
1896
2080
|
});
|
|
1897
|
-
`;var
|
|
2081
|
+
`;var gi=`import { MailerLayout } from "@ooneex/mailer";
|
|
1898
2082
|
|
|
1899
2083
|
export type {{NAME}}MailerPropsType = {
|
|
1900
2084
|
link: string;
|
|
@@ -1909,7 +2093,7 @@ export const {{NAME}}MailerTemplate = (props?: {{NAME}}MailerPropsType) => (
|
|
|
1909
2093
|
<MailerLayout.Footer />
|
|
1910
2094
|
</MailerLayout>
|
|
1911
2095
|
);
|
|
1912
|
-
`;class
|
|
2096
|
+
`;class Ve{getName(){return"make:mailer"}getDescription(){return"Generate a new mailer class"}async run(e){let{name:t,module:s}=e;if(!t)t=await S({message:"Enter mailer name"});t=Zm(t).replace(/Mailer$/,"");let r=fi.replace(/{{NAME}}/g,t),o=gi.replace(/{{NAME}}/g,t),i=s?P("modules",s):".",n=P(i,"src","mailers"),a=P(process.cwd(),n),l=P(a,`${t}Mailer.ts`),m=P(a,`${t}MailerTemplate.tsx`);await Bun.write(l,r),await Bun.write(m,o);let c=hi.replace(/{{NAME}}/g,t),p=yi.replace(/{{NAME}}/g,t),u=P(i,"tests","mailers"),d=P(process.cwd(),u),h=P(d,`${t}Mailer.spec.ts`),f=P(d,`${t}MailerTemplate.spec.ts`);await Bun.write(h,c),await Bun.write(f,p);let x=new zm;x.success(`${P(n,t)}Mailer.ts created successfully`,void 0,{showTimestamp:!1,showArrow:!1,useSymbol:!0}),x.success(`${P(n,t)}MailerTemplate.tsx created successfully`,void 0,{showTimestamp:!1,showArrow:!1,useSymbol:!0}),x.success(`${P(u,t)}Mailer.spec.ts created successfully`,void 0,{showTimestamp:!1,showArrow:!1,useSymbol:!0}),x.success(`${P(u,t)}MailerTemplate.spec.ts created successfully`,void 0,{showTimestamp:!1,showArrow:!1,useSymbol:!0})}}Ve=g([E.command()],Ve);import{basename as km,join as q}from"path";import{TerminalLogger as ed}from"@ooneex/logger";import{toPascalCase as xi}from"@ooneex/utils";var Ei=`import type { ContextType } from "@ooneex/socket";
|
|
1913
2097
|
import { decorator, type IMiddleware } from "@ooneex/middleware";
|
|
1914
2098
|
|
|
1915
2099
|
@decorator.middleware()
|
|
@@ -1921,7 +2105,7 @@ export class {{NAME}}Middleware implements IMiddleware {
|
|
|
1921
2105
|
return context
|
|
1922
2106
|
}
|
|
1923
2107
|
}
|
|
1924
|
-
`;var
|
|
2108
|
+
`;var Ai=`import { describe, expect, test } from "bun:test";
|
|
1925
2109
|
import { {{NAME}}Middleware } from "@/middlewares/{{NAME}}Middleware";
|
|
1926
2110
|
|
|
1927
2111
|
describe("{{NAME}}Middleware", () => {
|
|
@@ -1934,7 +2118,7 @@ describe("{{NAME}}Middleware", () => {
|
|
|
1934
2118
|
expect(typeof {{NAME}}Middleware.prototype.handler).toBe("function");
|
|
1935
2119
|
});
|
|
1936
2120
|
});
|
|
1937
|
-
`;var
|
|
2121
|
+
`;var bi=`import type { ContextType } from "@ooneex/controller";
|
|
1938
2122
|
import { decorator, type IMiddleware } from "@ooneex/middleware";
|
|
1939
2123
|
|
|
1940
2124
|
@decorator.middleware()
|
|
@@ -1946,9 +2130,9 @@ export class {{NAME}}Middleware implements IMiddleware {
|
|
|
1946
2130
|
return context
|
|
1947
2131
|
}
|
|
1948
2132
|
}
|
|
1949
|
-
`;class
|
|
1950
|
-
`,
|
|
1951
|
-
`,
|
|
2133
|
+
`;class Fe{getName(){return"make:middleware"}getDescription(){return"Generate a new middleware class"}async addToModule(e,t){let s=await Bun.file(e).text(),r=`${t}Middleware`,o=`import { ${r} } from "./middlewares/${r}";
|
|
2134
|
+
`,i=s.lastIndexOf("import "),n=s.indexOf(`
|
|
2135
|
+
`,i);s=`${s.slice(0,n+1)}${o}${s.slice(n+1)}`;let a=/(middlewares:\s*\[)([^\]]*)/s,l=s.match(a);if(l){let m=l[2]?.trim(),c=m?`${m}, ${r}`:r;s=s.replace(a,`$1${c}`)}await Bun.write(e,s)}async run(e){let{name:t,module:s,isSocket:r}=e;if(!t)t=await S({message:"Enter middleware name"});if(r===void 0)r=await Ue({message:"Is this a socket middleware?"});t=xi(t).replace(/Middleware$/,"");let i=(r?Ei:bi).replace(/{{NAME}}/g,t),n=s?q("modules",s):".",a=q(n,"src","middlewares"),l=q(process.cwd(),a),m=q(l,`${t}Middleware.ts`);await Bun.write(m,i);let c=Ai.replace(/{{NAME}}/g,t),p=q(n,"tests","middlewares"),u=q(process.cwd(),p),d=q(u,`${t}Middleware.spec.ts`);await Bun.write(d,c);let h=xi(km(process.cwd())),f=q(process.cwd(),"src",`${h}Module.ts`);if(await Bun.file(f).exists())await this.addToModule(f,t);let x=new ed;x.success(`${q(a,t)}Middleware.ts created successfully`,void 0,{showTimestamp:!1,showArrow:!1,useSymbol:!0}),x.success(`${q(p,t)}Middleware.spec.ts created successfully`,void 0,{showTimestamp:!1,showArrow:!1,useSymbol:!0})}}Fe=g([E.command()],Fe);import{join as Bt}from"path";import{TerminalLogger as td}from"@ooneex/logger";import{migrationCreate as sd}from"@ooneex/migrations";class Qe{getName(){return"make:migration"}getDescription(){return"Generate a new migration file"}async run(e){let{module:t}=e,s=t?Bt("modules",t):".";await sd({dir:Bt(s,"src/migrations")});let r=Bt(process.cwd(),"package.json"),o=Bun.file(r);if(await o.exists()){let n=await o.json();n.scripts=n.scripts||{},n.scripts["migration:up"]="bun ./bin/migration/up.ts",await Bun.write(r,JSON.stringify(n,null,2))}let i=new td;i.success("Migration file created successfully",void 0,{showTimestamp:!1,showArrow:!1,useSymbol:!0}),i.info("Run 'bun run migration:up' to execute migrations",void 0,{showTimestamp:!1,showArrow:!0,showLevel:!1})}}Qe=g([E.command()],Qe);import{basename as id,join as W}from"path";import{TerminalLogger as nd}from"@ooneex/logger";import{toPascalCase as _i}from"@ooneex/utils";var wi=`import { describe, expect, test } from "bun:test";
|
|
1952
2136
|
import { Permission } from "@ooneex/permission";
|
|
1953
2137
|
import { {{NAME}}Permission } from "@/permissions/{{NAME}}Permission";
|
|
1954
2138
|
|
|
@@ -1973,7 +2157,7 @@ describe("{{NAME}}Permission", () => {
|
|
|
1973
2157
|
});
|
|
1974
2158
|
|
|
1975
2159
|
});
|
|
1976
|
-
`;var
|
|
2160
|
+
`;var Si=`import { decorator, Permission } from "@ooneex/permission";
|
|
1977
2161
|
import type { IUser } from "@ooneex/user";
|
|
1978
2162
|
|
|
1979
2163
|
@decorator.permission()
|
|
@@ -2012,9 +2196,9 @@ export class {{NAME}}Permission extends Permission {
|
|
|
2012
2196
|
return this;
|
|
2013
2197
|
}
|
|
2014
2198
|
}
|
|
2015
|
-
`;class
|
|
2016
|
-
`,
|
|
2017
|
-
`,
|
|
2199
|
+
`;class ze{getName(){return"make:permission"}getDescription(){return"Generate a new permission class"}async addToModule(e,t){let s=await Bun.file(e).text(),r=`${t}Permission`,o=`import { ${r} } from "./permissions/${r}";
|
|
2200
|
+
`,i=s.lastIndexOf("import "),n=s.indexOf(`
|
|
2201
|
+
`,i);s=`${s.slice(0,n+1)}${o}${s.slice(n+1)}`;let a=/(permissions:\s*\[)([^\]]*)/s,l=s.match(a);if(l){let m=l[2]?.trim(),c=m?`${m}, ${r}`:r;s=s.replace(a,`$1${c}`)}await Bun.write(e,s)}async run(e){let{name:t,module:s}=e;if(!t)t=await S({message:"Enter permission name"});t=_i(t).replace(/Permission$/,"");let r=Si.replace(/{{NAME}}/g,t),o=s?W("modules",s):".",i=W(o,"src","permissions"),n=W(process.cwd(),i),a=W(n,`${t}Permission.ts`);await Bun.write(a,r);let l=wi.replace(/{{NAME}}/g,t),m=W(o,"tests","permissions"),c=W(process.cwd(),m),p=W(c,`${t}Permission.spec.ts`);await Bun.write(p,l);let u=_i(id(process.cwd())),d=W(process.cwd(),"src",`${u}Module.ts`);if(await Bun.file(d).exists())await this.addToModule(d,t);let h=new nd;h.success(`${W(i,t)}Permission.ts created successfully`,void 0,{showTimestamp:!1,showArrow:!1,useSymbol:!0}),h.success(`${W(m,t)}Permission.spec.ts created successfully`,void 0,{showTimestamp:!1,showArrow:!1,useSymbol:!0})}}ze=g([E.command()],ze);import{basename as md,join as K}from"path";import{TerminalLogger as dd}from"@ooneex/logger";import{toKebabCase as pd,toPascalCase as Ti}from"@ooneex/utils";var Ni=`import { describe, expect, test } from "bun:test";
|
|
2018
2202
|
import { {{NAME}}PubSub } from "@/pubsub/{{NAME}}PubSub";
|
|
2019
2203
|
|
|
2020
2204
|
describe("{{NAME}}PubSub", () => {
|
|
@@ -2052,7 +2236,7 @@ describe("{{NAME}}PubSub", () => {
|
|
|
2052
2236
|
expect(typeof {{NAME}}PubSub.prototype.unsubscribeAll).toBe("function");
|
|
2053
2237
|
});
|
|
2054
2238
|
});
|
|
2055
|
-
`;var
|
|
2239
|
+
`;var Mi=`import { inject } from "@ooneex/container";
|
|
2056
2240
|
import type { ScalarType } from "@ooneex/types";
|
|
2057
2241
|
import { decorator, PubSub, RedisPubSub } from "@ooneex/pub-sub";
|
|
2058
2242
|
|
|
@@ -2074,9 +2258,9 @@ export class {{NAME}}Event<Data extends Record<string, ScalarType> = Record<stri
|
|
|
2074
2258
|
// TODO: Implement handler logic here
|
|
2075
2259
|
}
|
|
2076
2260
|
}
|
|
2077
|
-
`;class
|
|
2078
|
-
`,
|
|
2079
|
-
`,
|
|
2261
|
+
`;class Ze{getName(){return"make:pubsub"}getDescription(){return"Generate a new PubSub event class"}async addToModule(e,t){let s=await Bun.file(e).text(),r=`${t}Event`,o=`import { ${r} } from "./events/${r}";
|
|
2262
|
+
`,i=s.lastIndexOf("import "),n=s.indexOf(`
|
|
2263
|
+
`,i);s=`${s.slice(0,n+1)}${o}${s.slice(n+1)}`;let a=/(events:\s*\[)([^\]]*)/s,l=s.match(a);if(l){let m=l[2]?.trim(),c=m?`${m}, ${r}`:r;s=s.replace(a,`$1${c}`)}await Bun.write(e,s)}async run(e){let{name:t,module:s,channel:r}=e;if(!t)t=await S({message:"Enter name"});if(t=Ti(t).replace(/PubSub$/,""),!r)r=pd(t);let o=Mi.replace(/{{NAME}}/g,t).replace(/{{CHANNEL}}/g,r),i=s?K("modules",s):".",n=K(i,"src","events"),a=K(process.cwd(),n),l=K(a,`${t}Event.ts`);await Bun.write(l,o);let m=Ni.replace(/{{NAME}}/g,t),c=K(i,"tests","events"),p=K(process.cwd(),c),u=K(p,`${t}Event.spec.ts`);await Bun.write(u,m);let d=Ti(md(process.cwd())),h=K(process.cwd(),"src",`${d}Module.ts`);if(await Bun.file(h).exists())await this.addToModule(h,t);let f=new dd;f.success(`${K(n,t)}Event.ts created successfully`,void 0,{showTimestamp:!1,showArrow:!1,useSymbol:!0}),f.success(`${K(c,t)}Event.spec.ts created successfully`,void 0,{showTimestamp:!1,showArrow:!1,useSymbol:!0})}}Ze=g([E.command()],Ze);import{join as Z}from"path";import{TerminalLogger as hd}from"@ooneex/logger";import{toPascalCase as fd}from"@ooneex/utils";var vi=`import { describe, expect, test } from "bun:test";
|
|
2080
2264
|
import { {{NAME}}Repository } from "@/repositories/{{NAME}}Repository";
|
|
2081
2265
|
|
|
2082
2266
|
describe("{{NAME}}Repository", () => {
|
|
@@ -2139,7 +2323,7 @@ describe("{{NAME}}Repository", () => {
|
|
|
2139
2323
|
expect(typeof {{NAME}}Repository.prototype.count).toBe("function");
|
|
2140
2324
|
});
|
|
2141
2325
|
});
|
|
2142
|
-
`;var
|
|
2326
|
+
`;var Ri=`import { inject } from "@ooneex/container";
|
|
2143
2327
|
import type { ITypeormDatabase } from "@ooneex/database";
|
|
2144
2328
|
import { decorator } from "@ooneex/repository";
|
|
2145
2329
|
import type { FilterResultType } from "@ooneex/types";
|
|
@@ -2261,7 +2445,7 @@ export class {{NAME}}Repository {
|
|
|
2261
2445
|
return await repository.count(criteria ? { where: criteria } : {});
|
|
2262
2446
|
}
|
|
2263
2447
|
}
|
|
2264
|
-
`;class
|
|
2448
|
+
`;class Xe{getName(){return"make:repository"}getDescription(){return"Generate a new repository class"}async run(e){let{name:t,module:s}=e;if(!t)t=await S({message:"Enter repository name"});t=fd(t).replace(/Repository$/,"");let r=Ri.replace(/{{NAME}}/g,t),o=s?Z("modules",s):".",i=Z(o,"src","repositories"),n=Z(process.cwd(),i),a=Z(n,`${t}Repository.ts`);await Bun.write(a,r);let l=vi.replace(/{{NAME}}/g,t),m=Z(o,"tests","repositories"),c=Z(process.cwd(),m),p=Z(c,`${t}Repository.spec.ts`);await Bun.write(p,l);let u=new hd;u.success(`${Z(i,t)}Repository.ts created successfully`,void 0,{showTimestamp:!1,showArrow:!1,useSymbol:!0}),u.success(`${Z(m,t)}Repository.spec.ts created successfully`,void 0,{showTimestamp:!1,showArrow:!1,useSymbol:!0})}}Xe=g([E.command()],Xe);import{join as Pt}from"path";import{TerminalLogger as yd}from"@ooneex/logger";import{seedCreate as gd}from"@ooneex/seeds";class Je{getName(){return"make:seed"}getDescription(){return"Generate a new seed file"}async run(e){let{name:t,module:s}=e;if(!t)t=await S({message:"Enter seed name"});let r=s?Pt("modules",s):".",o=await gd({name:t,dir:Pt(r,"src/seeds")}),i=Pt(process.cwd(),"package.json"),n=Bun.file(i);if(await n.exists()){let l=await n.json();l.scripts=l.scripts||{},l.scripts["seed:run"]="bun ./bin/seed/run.ts",await Bun.write(i,JSON.stringify(l,null,2))}let a=new yd;a.success(`${o} created successfully`,void 0,{showTimestamp:!1,showArrow:!1,useSymbol:!0}),a.info("Run 'bun run seed:run' to execute seeds",void 0,{showTimestamp:!1,showArrow:!0,showLevel:!1})}}Je=g([E.command()],Je);import{join as X}from"path";import{TerminalLogger as bd}from"@ooneex/logger";import{toPascalCase as xd}from"@ooneex/utils";var Di=`import { describe, expect, test } from "bun:test";
|
|
2265
2449
|
import { {{NAME}}Service } from "@/services/{{NAME}}Service";
|
|
2266
2450
|
|
|
2267
2451
|
describe("{{NAME}}Service", () => {
|
|
@@ -2274,7 +2458,7 @@ describe("{{NAME}}Service", () => {
|
|
|
2274
2458
|
expect(typeof {{NAME}}Service.prototype.execute).toBe("function");
|
|
2275
2459
|
});
|
|
2276
2460
|
});
|
|
2277
|
-
`;var
|
|
2461
|
+
`;var Oi=`import { decorator } from "@ooneex/service";
|
|
2278
2462
|
import type { IService } from "@ooneex/service";
|
|
2279
2463
|
|
|
2280
2464
|
type ServiceDataType = Record<string, unknown>;
|
|
@@ -2285,7 +2469,7 @@ export class {{NAME}}Service<T extends ServiceDataType = ServiceDataType> implem
|
|
|
2285
2469
|
// TODO: Implement service logic
|
|
2286
2470
|
}
|
|
2287
2471
|
}
|
|
2288
|
-
`;class
|
|
2472
|
+
`;class je{getName(){return"make:service"}getDescription(){return"Generate a new service class"}async run(e){let{name:t,module:s}=e;if(!t)t=await S({message:"Enter service name"});t=xd(t).replace(/Service$/,"");let r=Oi.replace(/{{NAME}}/g,t),o=s?X("modules",s):".",i=X(o,"src","services"),n=X(process.cwd(),i),a=X(n,`${t}Service.ts`);await Bun.write(a,r);let l=Di.replace(/{{NAME}}/g,t),m=X(o,"tests","services"),c=X(process.cwd(),m),p=X(c,`${t}Service.spec.ts`);await Bun.write(p,l);let u=new bd;u.success(`${X(i,t)}Service.ts created successfully`,void 0,{showTimestamp:!1,showArrow:!1,useSymbol:!0}),u.success(`${X(m,t)}Service.spec.ts created successfully`,void 0,{showTimestamp:!1,showArrow:!1,useSymbol:!0})}}je=g([E.command()],je);import{join as J}from"path";import{TerminalLogger as _d}from"@ooneex/logger";import{toPascalCase as Nd,toSnakeCase as Md}from"@ooneex/utils";var Ci=`import { describe, expect, test } from "bun:test";
|
|
2289
2473
|
import { {{NAME}}StorageAdapter } from "@/storage/{{NAME}}StorageAdapter";
|
|
2290
2474
|
|
|
2291
2475
|
describe("{{NAME}}StorageAdapter", () => {
|
|
@@ -2302,7 +2486,7 @@ describe("{{NAME}}StorageAdapter", () => {
|
|
|
2302
2486
|
expect(typeof {{NAME}}StorageAdapter.prototype.getOptions).toBe("function");
|
|
2303
2487
|
});
|
|
2304
2488
|
});
|
|
2305
|
-
`;var
|
|
2489
|
+
`;var Bi=`import { Storage, decorator, StorageException } from "@ooneex/storage";
|
|
2306
2490
|
import type { S3Options } from "bun";
|
|
2307
2491
|
|
|
2308
2492
|
@decorator.storage()
|
|
@@ -2357,7 +2541,7 @@ export class {{NAME}}Storage extends Storage {
|
|
|
2357
2541
|
};
|
|
2358
2542
|
}
|
|
2359
2543
|
}
|
|
2360
|
-
`;class
|
|
2544
|
+
`;class ke{getName(){return"make:storage"}getDescription(){return"Generate a new storage class"}async run(e){let{name:t,module:s}=e;if(!t)t=await S({message:"Enter storage name"});t=Nd(t).replace(/Storage$/,"");let r=Md(t).toUpperCase(),o=Bi.replace(/{{NAME}}/g,t).replace(/{{NAME_UPPER}}/g,r),i=s?J("modules",s):".",n=J(i,"src","storage"),a=J(process.cwd(),n),l=J(a,`${t}Storage.ts`);await Bun.write(l,o);let m=Ci.replace(/{{NAME}}/g,t),c=J(i,"tests","storage"),p=J(process.cwd(),c),u=J(p,`${t}Storage.spec.ts`);await Bun.write(u,m);let d=new _d;d.success(`${J(n,t)}Storage.ts created successfully`,void 0,{showTimestamp:!1,showArrow:!1,useSymbol:!0}),d.success(`${J(c,t)}Storage.spec.ts created successfully`,void 0,{showTimestamp:!1,showArrow:!1,useSymbol:!0})}}ke=g([E.command()],ke);import{join as j}from"path";import{TerminalLogger as Rd}from"@ooneex/logger";import{toPascalCase as Dd}from"@ooneex/utils";var Pi=`import { describe, expect, test } from "bun:test";
|
|
2361
2545
|
import { {{NAME}}VectorDatabase } from "@/databases/{{NAME}}VectorDatabase";
|
|
2362
2546
|
|
|
2363
2547
|
describe("{{NAME}}VectorDatabase", () => {
|
|
@@ -2380,7 +2564,7 @@ describe("{{NAME}}VectorDatabase", () => {
|
|
|
2380
2564
|
expect(typeof {{NAME}}VectorDatabase.prototype.getSchema).toBe("function");
|
|
2381
2565
|
});
|
|
2382
2566
|
});
|
|
2383
|
-
`;var
|
|
2567
|
+
`;var Li=`import { VectorDatabase, decorator } from "@ooneex/rag";
|
|
2384
2568
|
import type { EmbeddingModelType, EmbeddingProviderType, FieldValueType } from "@ooneex/rag";
|
|
2385
2569
|
import { Utf8 } from "apache-arrow";
|
|
2386
2570
|
|
|
@@ -2404,8 +2588,8 @@ export class {{NAME}}VectorDatabase extends VectorDatabase<DataType> {
|
|
|
2404
2588
|
};
|
|
2405
2589
|
}
|
|
2406
2590
|
}
|
|
2407
|
-
`;class
|
|
2408
|
-
`),process.exit(1);var
|
|
2409
|
-
`),process.exit(1);var
|
|
2591
|
+
`;class et{getName(){return"make:vector-database"}getDescription(){return"Generate a new vector database class"}async run(e){let{name:t,module:s}=e;if(!t)t=await S({message:"Enter vector database name"});t=Dd(t).replace(/VectorDatabase$/,"").replace(/Database$/,"");let r=Li.replace(/{{NAME}}/g,t),o=s?j("modules",s):".",i=j(o,"src","databases"),n=j(process.cwd(),i),a=j(n,`${t}VectorDatabase.ts`);await Bun.write(a,r);let l=Pi.replace(/{{NAME}}/g,t),m=j(o,"tests","databases"),c=j(process.cwd(),m),p=j(c,`${t}VectorDatabase.spec.ts`);await Bun.write(p,l);let u=new Rd;u.success(`${j(i,t)}VectorDatabase.ts created successfully`,void 0,{showTimestamp:!1,showArrow:!1,useSymbol:!0}),u.success(`${j(m,t)}VectorDatabase.spec.ts created successfully`,void 0,{showTimestamp:!1,showArrow:!1,useSymbol:!0})}}et=g([E.command()],et);var{values:k,positionals:Bd}=Od({args:Bun.argv,options:{name:{type:"string"},"route-name":{type:"string"},"route-path":{type:"string"},"route-method":{type:"string"},"is-socket":{type:"boolean"},dir:{type:"string"},channel:{type:"string"},"table-name":{type:"string"},module:{type:"string"}},strict:!0,allowPositionals:!0}),Lt=new Cd,Ii=Bd[2];if(!Ii)Lt.error(`Command name is required
|
|
2592
|
+
`),process.exit(1);var $i=$t(Ii);if(!$i)Lt.info(`No commands found
|
|
2593
|
+
`),process.exit(1);var Pd={name:k.name,dir:k.dir,channel:k.channel,isSocket:k["is-socket"],tableName:k["table-name"],module:k.module,route:{name:k["route-name"],path:k["route-path"],method:k["route-method"]}};try{await $i.run(Pd)}catch(e){Lt.error(e,void 0,{showArrow:!1,showTimestamp:!1,showLevel:!1}),process.exit(1)}
|
|
2410
2594
|
|
|
2411
|
-
//# debugId=
|
|
2595
|
+
//# debugId=F98E15BA88CC51D864756E2164756E21
|