create-leo-app 0.8.7 → 0.8.8
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 +3 -3
- package/dist/index.mjs +32 -32
- package/package.json +1 -1
- package/template-extension/package.json +1 -1
- package/template-nextjs-ts/package.json +1 -1
- package/template-node/package.json +1 -1
- package/template-node-ts/package.json +1 -1
- package/template-offline-public-transaction-ts/package.json +1 -1
- package/template-react-leo/package.json +1 -1
- package/template-react-managed-worker/package.json +1 -1
- package/template-react-ts/package.json +1 -1
- package/template-vanilla/package.json +1 -1
package/README.md
CHANGED
|
@@ -13,14 +13,14 @@ npm create leo-app@latest
|
|
|
13
13
|
|
|
14
14
|
Then follow the prompts!
|
|
15
15
|
|
|
16
|
-
You can also directly specify the project name you want to use via additional command line options. For example, to scaffold a Leo project, run:
|
|
16
|
+
You can also directly specify the project name and template you want to use via additional command line options. For example, to scaffold a Leo project using the Vanilla JavaScript template, run:
|
|
17
17
|
|
|
18
18
|
```bash
|
|
19
19
|
# npm 6.x
|
|
20
|
-
npm create leo-app@latest my-leo-app
|
|
20
|
+
npm create leo-app@latest my-leo-app --template vanilla
|
|
21
21
|
|
|
22
22
|
# npm 7+, extra double-dash is needed:
|
|
23
|
-
npm create leo-app@latest my-leo-app
|
|
23
|
+
npm create leo-app@latest my-leo-app -- --template vanilla
|
|
24
24
|
```
|
|
25
25
|
|
|
26
26
|
Currently supported template presets include:
|
package/dist/index.mjs
CHANGED
|
@@ -1,52 +1,52 @@
|
|
|
1
|
-
import T from"node:fs";import P from"node:path";import{fileURLToPath as ye}from"node:url";import Se from"readline";import xe from"events";function
|
|
1
|
+
import T from"node:fs";import P from"node:path";import{fileURLToPath as ye}from"node:url";import Se from"readline";import xe from"events";function Ct(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var V,Dt;function $e(){if(Dt)return V;Dt=1;function e(t,l){var c=t;l.slice(0,-1).forEach(function(m){c=c[m]||{}});var i=l[l.length-1];return i in c}function r(t){return typeof t=="number"||/^0x[0-9a-f]+$/i.test(t)?!0:/^[-+]?(?:\d+(?:\.\d*)?|\.\d+)(e[-+]?\d+)?$/.test(t)}function d(t,l){return l==="constructor"&&typeof t[l]=="function"||l==="__proto__"}return V=function(t,l){l||(l={});var c={bools:{},strings:{},unknownFn:null};typeof l.unknown=="function"&&(c.unknownFn=l.unknown),typeof l.boolean=="boolean"&&l.boolean?c.allBools=!0:[].concat(l.boolean).filter(Boolean).forEach(function(w){c.bools[w]=!0});var i={};function m(w){return i[w].some(function($){return c.bools[$]})}Object.keys(l.alias||{}).forEach(function(w){i[w]=[].concat(l.alias[w]),i[w].forEach(function($){i[$]=[w].concat(i[w].filter(function(R){return $!==R}))})}),[].concat(l.string).filter(Boolean).forEach(function(w){c.strings[w]=!0,i[w]&&[].concat(i[w]).forEach(function($){c.strings[$]=!0})});var o=l.default||{},n={_:[]};function s(w,$){return c.allBools&&/^--[^=]+$/.test($)||c.strings[w]||c.bools[w]||i[w]}function a(w,$,R){for(var S=w,N=0;N<$.length-1;N++){var E=$[N];if(d(S,E))return;S[E]===void 0&&(S[E]={}),(S[E]===Object.prototype||S[E]===Number.prototype||S[E]===String.prototype)&&(S[E]={}),S[E]===Array.prototype&&(S[E]=[]),S=S[E]}var I=$[$.length-1];d(S,I)||((S===Object.prototype||S===Number.prototype||S===String.prototype)&&(S={}),S===Array.prototype&&(S=[]),S[I]===void 0||c.bools[I]||typeof S[I]=="boolean"?S[I]=R:Array.isArray(S[I])?S[I].push(R):S[I]=[S[I],R])}function p(w,$,R){if(!(R&&c.unknownFn&&!s(w,R)&&c.unknownFn(R)===!1)){var S=!c.strings[w]&&r($)?Number($):$;a(n,w.split("."),S),(i[w]||[]).forEach(function(N){a(n,N.split("."),S)})}}Object.keys(c.bools).forEach(function(w){p(w,o[w]===void 0?!1:o[w])});var u=[];t.indexOf("--")!==-1&&(u=t.slice(t.indexOf("--")+1),t=t.slice(0,t.indexOf("--")));for(var h=0;h<t.length;h++){var f=t[h],v,x;if(/^--.+=/.test(f)){var O=f.match(/^--([^=]+)=([\s\S]*)$/);v=O[1];var M=O[2];c.bools[v]&&(M=M!=="false"),p(v,M,f)}else if(/^--no-.+/.test(f))v=f.match(/^--no-(.+)/)[1],p(v,!1,f);else if(/^--.+/.test(f))v=f.match(/^--(.+)/)[1],x=t[h+1],x!==void 0&&!/^(-|--)[^-]/.test(x)&&!c.bools[v]&&!c.allBools&&(!i[v]||!m(v))?(p(v,x,f),h+=1):/^(true|false)$/.test(x)?(p(v,x==="true",f),h+=1):p(v,c.strings[v]?"":!0,f);else if(/^-[^-]+/.test(f)){for(var g=f.slice(1,-1).split(""),b=!1,y=0;y<g.length;y++){if(x=f.slice(y+2),x==="-"){p(g[y],x,f);continue}if(/[A-Za-z]/.test(g[y])&&x[0]==="="){p(g[y],x.slice(1),f),b=!0;break}if(/[A-Za-z]/.test(g[y])&&/-?\d+(\.\d*)?(e-?\d+)?$/.test(x)){p(g[y],x,f),b=!0;break}if(g[y+1]&&g[y+1].match(/\W/)){p(g[y],f.slice(y+2),f),b=!0;break}else p(g[y],c.strings[g[y]]?"":!0,f)}v=f.slice(-1)[0],!b&&v!=="-"&&(t[h+1]&&!/^(-|--)[^-]/.test(t[h+1])&&!c.bools[v]&&(!i[v]||!m(v))?(p(v,t[h+1],f),h+=1):t[h+1]&&/^(true|false)$/.test(t[h+1])?(p(v,t[h+1]==="true",f),h+=1):p(v,c.strings[v]?"":!0,f))}else if((!c.unknownFn||c.unknownFn(f)!==!1)&&n._.push(c.strings._||!r(f)?f:Number(f)),l.stopEarly){n._.push.apply(n._,t.slice(h+1));break}}return Object.keys(o).forEach(function(w){e(n,w.split("."))||(a(n,w.split("."),o[w]),(i[w]||[]).forEach(function($){a(n,$.split("."),o[w])}))}),l["--"]?n["--"]=u.slice():u.forEach(function(w){n._.push(w)}),n},V}var Me=$e();const Oe=Ct(Me);var B={},U,Et;function C(){if(Et)return U;Et=1;const{FORCE_COLOR:e,NODE_DISABLE_COLORS:r,TERM:d}=process.env,t={enabled:!r&&d!=="dumb"&&e!=="0",reset:i(0,0),bold:i(1,22),dim:i(2,22),italic:i(3,23),underline:i(4,24),inverse:i(7,27),hidden:i(8,28),strikethrough:i(9,29),black:i(30,39),red:i(31,39),green:i(32,39),yellow:i(33,39),blue:i(34,39),magenta:i(35,39),cyan:i(36,39),white:i(37,39),gray:i(90,39),grey:i(90,39),bgBlack:i(40,49),bgRed:i(41,49),bgGreen:i(42,49),bgYellow:i(43,49),bgBlue:i(44,49),bgMagenta:i(45,49),bgCyan:i(46,49),bgWhite:i(47,49)};function l(m,o){let n=0,s,a="",p="";for(;n<m.length;n++)s=m[n],a+=s.open,p+=s.close,o.includes(s.close)&&(o=o.replace(s.rgx,s.close+s.open));return a+o+p}function c(m,o){let n={has:m,keys:o};return n.reset=t.reset.bind(n),n.bold=t.bold.bind(n),n.dim=t.dim.bind(n),n.italic=t.italic.bind(n),n.underline=t.underline.bind(n),n.inverse=t.inverse.bind(n),n.hidden=t.hidden.bind(n),n.strikethrough=t.strikethrough.bind(n),n.black=t.black.bind(n),n.red=t.red.bind(n),n.green=t.green.bind(n),n.yellow=t.yellow.bind(n),n.blue=t.blue.bind(n),n.magenta=t.magenta.bind(n),n.cyan=t.cyan.bind(n),n.white=t.white.bind(n),n.gray=t.gray.bind(n),n.grey=t.grey.bind(n),n.bgBlack=t.bgBlack.bind(n),n.bgRed=t.bgRed.bind(n),n.bgGreen=t.bgGreen.bind(n),n.bgYellow=t.bgYellow.bind(n),n.bgBlue=t.bgBlue.bind(n),n.bgMagenta=t.bgMagenta.bind(n),n.bgCyan=t.bgCyan.bind(n),n.bgWhite=t.bgWhite.bind(n),n}function i(m,o){let n={open:`\x1B[${m}m`,close:`\x1B[${o}m`,rgx:new RegExp(`\\x1b\\[${o}m`,"g")};return function(s){return this!==void 0&&this.has!==void 0?(this.has.includes(m)||(this.has.push(m),this.keys.push(n)),s===void 0?this:t.enabled?l(this.keys,s+""):s+""):s===void 0?c([m],[n]):t.enabled?l([n],s+""):s+""}}return U=t,U}var J,qt;function Re(){return qt||(qt=1,J=(e,r)=>{if(!(e.meta&&e.name!=="escape")){if(e.ctrl){if(e.name==="a")return"first";if(e.name==="c"||e.name==="d")return"abort";if(e.name==="e")return"last";if(e.name==="g")return"reset"}if(r){if(e.name==="j")return"down";if(e.name==="k")return"up"}return e.name==="return"||e.name==="enter"?"submit":e.name==="backspace"?"delete":e.name==="delete"?"deleteForward":e.name==="abort"?"abort":e.name==="escape"?"exit":e.name==="tab"?"next":e.name==="pagedown"?"nextPage":e.name==="pageup"?"prevPage":e.name==="home"?"home":e.name==="end"?"end":e.name==="up"?"up":e.name==="down"?"down":e.name==="right"?"right":e.name==="left"?"left":!1}}),J}var k,It;function z(){return It||(It=1,k=e=>{const r=["[\\u001B\\u009B][[\\]()#;?]*(?:(?:(?:(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]+)*|[a-zA-Z\\d]+(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]*)*)?\\u0007)","(?:(?:\\d{1,4}(?:;\\d{0,4})*)?[\\dA-PRZcf-ntqry=><~]))"].join("|"),d=new RegExp(r,"g");return typeof e=="string"?e.replace(d,""):e}),k}var G,_t;function D(){if(_t)return G;_t=1;const e="\x1B",r=`${e}[`,d="\x07",t={to(i,m){return m?`${r}${m+1};${i+1}H`:`${r}${i+1}G`},move(i,m){let o="";return i<0?o+=`${r}${-i}D`:i>0&&(o+=`${r}${i}C`),m<0?o+=`${r}${-m}A`:m>0&&(o+=`${r}${m}B`),o},up:(i=1)=>`${r}${i}A`,down:(i=1)=>`${r}${i}B`,forward:(i=1)=>`${r}${i}C`,backward:(i=1)=>`${r}${i}D`,nextLine:(i=1)=>`${r}E`.repeat(i),prevLine:(i=1)=>`${r}F`.repeat(i),left:`${r}G`,hide:`${r}?25l`,show:`${r}?25h`,save:`${e}7`,restore:`${e}8`},l={up:(i=1)=>`${r}S`.repeat(i),down:(i=1)=>`${r}T`.repeat(i)},c={screen:`${r}2J`,up:(i=1)=>`${r}1J`.repeat(i),down:(i=1)=>`${r}J`.repeat(i),line:`${r}2K`,lineEnd:`${r}K`,lineStart:`${r}1K`,lines(i){let m="";for(let o=0;o<i;o++)m+=this.line+(o<i-1?t.up():"");return i&&(m+=t.left),m}};return G={cursor:t,scroll:l,erase:c,beep:d},G}var K,At;function Te(){if(At)return K;At=1;const e=z(),{erase:r,cursor:d}=D(),t=l=>[...e(l)].length;return K=function(l,c){if(!c)return r.line+d.to(0);let i=0;const m=l.split(/\r?\n/);for(let o of m)i+=1+Math.floor(Math.max(t(o)-1,0)/c);return r.lines(i)},K}var W,jt;function Ft(){if(jt)return W;jt=1;const e={arrowUp:"\u2191",arrowDown:"\u2193",arrowLeft:"\u2190",arrowRight:"\u2192",radioOn:"\u25C9",radioOff:"\u25EF",tick:"\u2714",cross:"\u2716",ellipsis:"\u2026",pointerSmall:"\u203A",line:"\u2500",pointer:"\u276F"},r={arrowUp:e.arrowUp,arrowDown:e.arrowDown,arrowLeft:e.arrowLeft,arrowRight:e.arrowRight,radioOn:"(*)",radioOff:"( )",tick:"\u221A",cross:"\xD7",ellipsis:"...",pointerSmall:"\xBB",line:"\u2500",pointer:">"};return W=process.platform==="win32"?r:e,W}var Z,Lt;function Pe(){if(Lt)return Z;Lt=1;const e=C(),r=Ft(),d=Object.freeze({password:{scale:1,render:o=>"*".repeat(o.length)},emoji:{scale:2,render:o=>"\u{1F603}".repeat(o.length)},invisible:{scale:0,render:o=>""},default:{scale:1,render:o=>`${o}`}}),t=o=>d[o]||d.default,l=Object.freeze({aborted:e.red(r.cross),done:e.green(r.tick),exited:e.yellow(r.cross),default:e.cyan("?")});return Z={styles:d,render:t,symbols:l,symbol:(o,n,s)=>n?l.aborted:s?l.exited:o?l.done:l.default,delimiter:o=>e.gray(o?r.ellipsis:r.pointerSmall),item:(o,n)=>e.gray(o?n?r.pointerSmall:"+":r.line)},Z}var X,Nt;function Ce(){if(Nt)return X;Nt=1;const e=z();return X=function(r,d){let t=String(e(r)||"").split(/\r?\n/);return d?t.map(l=>Math.ceil(l.length/d)).reduce((l,c)=>l+c):t.length},X}var Q,Yt;function De(){return Yt||(Yt=1,Q=(e,r={})=>{const d=Number.isSafeInteger(parseInt(r.margin))?new Array(parseInt(r.margin)).fill(" ").join(""):r.margin||"",t=r.width;return(e||"").split(/\r?\n/g).map(l=>l.split(/\s+/g).reduce((c,i)=>(i.length+d.length>=t||c[c.length-1].length+i.length+1<t?c[c.length-1]+=` ${i}`:c.push(`${d}${i}`),c),[d]).join(`
|
|
2
2
|
`)).join(`
|
|
3
|
-
`)}),Q}var tt,
|
|
3
|
+
`)}),Q}var tt,Ht;function Ee(){return Ht||(Ht=1,tt=(e,r,d)=>{d=d||r;let t=Math.min(r-d,e-Math.floor(d/2));t<0&&(t=0);let l=Math.min(t+d,r);return{startIndex:t,endIndex:l}}),tt}var et,Vt;function q(){return Vt||(Vt=1,et={action:Re(),clear:Te(),style:Pe(),strip:z(),figures:Ft(),lines:Ce(),wrap:De(),entriesToDisplay:Ee()}),et}var it,Bt;function A(){if(Bt)return it;Bt=1;const e=Se,{action:r}=q(),d=xe,{beep:t,cursor:l}=D(),c=C();class i extends d{constructor(o={}){super(),this.firstRender=!0,this.in=o.stdin||process.stdin,this.out=o.stdout||process.stdout,this.onRender=(o.onRender||(()=>{})).bind(this);const n=e.createInterface({input:this.in,escapeCodeTimeout:50});e.emitKeypressEvents(this.in,n),this.in.isTTY&&this.in.setRawMode(!0);const s=["SelectPrompt","MultiselectPrompt"].indexOf(this.constructor.name)>-1,a=(p,u)=>{let h=r(u,s);h===!1?this._&&this._(p,u):typeof this[h]=="function"?this[h](u):this.bell()};this.close=()=>{this.out.write(l.show),this.in.removeListener("keypress",a),this.in.isTTY&&this.in.setRawMode(!1),n.close(),this.emit(this.aborted?"abort":this.exited?"exit":"submit",this.value),this.closed=!0},this.in.on("keypress",a)}fire(){this.emit("state",{value:this.value,aborted:!!this.aborted,exited:!!this.exited})}bell(){this.out.write(t)}render(){this.onRender(c),this.firstRender&&(this.firstRender=!1)}}return it=i,it}var st,Ut;function qe(){if(Ut)return st;Ut=1;const e=C(),r=A(),{erase:d,cursor:t}=D(),{style:l,clear:c,lines:i,figures:m}=q();class o extends r{constructor(s={}){super(s),this.transform=l.render(s.style),this.scale=this.transform.scale,this.msg=s.message,this.initial=s.initial||"",this.validator=s.validate||(()=>!0),this.value="",this.errorMsg=s.error||"Please Enter A Valid Value",this.cursor=+!!this.initial,this.cursorOffset=0,this.clear=c("",this.out.columns),this.render()}set value(s){!s&&this.initial?(this.placeholder=!0,this.rendered=e.gray(this.transform.render(this.initial))):(this.placeholder=!1,this.rendered=this.transform.render(s)),this._value=s,this.fire()}get value(){return this._value}reset(){this.value="",this.cursor=+!!this.initial,this.cursorOffset=0,this.fire(),this.render()}exit(){this.abort()}abort(){this.value=this.value||this.initial,this.done=this.aborted=!0,this.error=!1,this.red=!1,this.fire(),this.render(),this.out.write(`
|
|
4
4
|
`),this.close()}async validate(){let s=await this.validator(this.value);typeof s=="string"&&(this.errorMsg=s,s=!1),this.error=!s}async submit(){if(this.value=this.value||this.initial,this.cursorOffset=0,this.cursor=this.rendered.length,await this.validate(),this.error){this.red=!0,this.fire(),this.render();return}this.done=!0,this.aborted=!1,this.fire(),this.render(),this.out.write(`
|
|
5
|
-
`),this.close()}next(){if(!this.placeholder)return this.bell();this.value=this.initial,this.cursor=this.rendered.length,this.fire(),this.render()}moveCursor(s){this.placeholder||(this.cursor=this.cursor+s,this.cursorOffset+=s)}_(s,
|
|
6
|
-
`).reduce((s,
|
|
7
|
-
${p?" ":m.pointerSmall} ${e.red().italic(
|
|
5
|
+
`),this.close()}next(){if(!this.placeholder)return this.bell();this.value=this.initial,this.cursor=this.rendered.length,this.fire(),this.render()}moveCursor(s){this.placeholder||(this.cursor=this.cursor+s,this.cursorOffset+=s)}_(s,a){let p=this.value.slice(0,this.cursor),u=this.value.slice(this.cursor);this.value=`${p}${s}${u}`,this.red=!1,this.cursor=this.placeholder?0:p.length+1,this.render()}delete(){if(this.isCursorAtStart())return this.bell();let s=this.value.slice(0,this.cursor-1),a=this.value.slice(this.cursor);this.value=`${s}${a}`,this.red=!1,this.isCursorAtStart()?this.cursorOffset=0:(this.cursorOffset++,this.moveCursor(-1)),this.render()}deleteForward(){if(this.cursor*this.scale>=this.rendered.length||this.placeholder)return this.bell();let s=this.value.slice(0,this.cursor),a=this.value.slice(this.cursor+1);this.value=`${s}${a}`,this.red=!1,this.isCursorAtEnd()?this.cursorOffset=0:this.cursorOffset++,this.render()}first(){this.cursor=0,this.render()}last(){this.cursor=this.value.length,this.render()}left(){if(this.cursor<=0||this.placeholder)return this.bell();this.moveCursor(-1),this.render()}right(){if(this.cursor*this.scale>=this.rendered.length||this.placeholder)return this.bell();this.moveCursor(1),this.render()}isCursorAtStart(){return this.cursor===0||this.placeholder&&this.cursor===1}isCursorAtEnd(){return this.cursor===this.rendered.length||this.placeholder&&this.cursor===this.rendered.length+1}render(){this.closed||(this.firstRender||(this.outputError&&this.out.write(t.down(i(this.outputError,this.out.columns)-1)+c(this.outputError,this.out.columns)),this.out.write(c(this.outputText,this.out.columns))),super.render(),this.outputError="",this.outputText=[l.symbol(this.done,this.aborted),e.bold(this.msg),l.delimiter(this.done),this.red?e.red(this.rendered):this.rendered].join(" "),this.error&&(this.outputError+=this.errorMsg.split(`
|
|
6
|
+
`).reduce((s,a,p)=>s+`
|
|
7
|
+
${p?" ":m.pointerSmall} ${e.red().italic(a)}`,"")),this.out.write(d.line+t.to(0)+this.outputText+t.save+this.outputError+t.restore+t.move(this.cursorOffset,0)))}}return st=o,st}var rt,Jt;function Ie(){if(Jt)return rt;Jt=1;const e=C(),r=A(),{style:d,clear:t,figures:l,wrap:c,entriesToDisplay:i}=q(),{cursor:m}=D();class o extends r{constructor(s={}){super(s),this.msg=s.message,this.hint=s.hint||"- Use arrow-keys. Return to submit.",this.warn=s.warn||"- This option is disabled",this.cursor=s.initial||0,this.choices=s.choices.map((a,p)=>(typeof a=="string"&&(a={title:a,value:p}),{title:a&&(a.title||a.value||a),value:a&&(a.value===void 0?p:a.value),description:a&&a.description,selected:a&&a.selected,disabled:a&&a.disabled})),this.optionsPerPage=s.optionsPerPage||10,this.value=(this.choices[this.cursor]||{}).value,this.clear=t("",this.out.columns),this.render()}moveCursor(s){this.cursor=s,this.value=this.choices[s].value,this.fire()}reset(){this.moveCursor(0),this.fire(),this.render()}exit(){this.abort()}abort(){this.done=this.aborted=!0,this.fire(),this.render(),this.out.write(`
|
|
8
8
|
`),this.close()}submit(){this.selection.disabled?this.bell():(this.done=!0,this.aborted=!1,this.fire(),this.render(),this.out.write(`
|
|
9
|
-
`),this.close())}first(){this.moveCursor(0),this.render()}last(){this.moveCursor(this.choices.length-1),this.render()}up(){this.cursor===0?this.moveCursor(this.choices.length-1):this.moveCursor(this.cursor-1),this.render()}down(){this.cursor===this.choices.length-1?this.moveCursor(0):this.moveCursor(this.cursor+1),this.render()}next(){this.moveCursor((this.cursor+1)%this.choices.length),this.render()}_(s,
|
|
10
|
-
`;for(let p=s;p<
|
|
11
|
-
`+
|
|
12
|
-
`}}this.out.write(this.outputText)}}return rt=o,rt}var nt,
|
|
9
|
+
`),this.close())}first(){this.moveCursor(0),this.render()}last(){this.moveCursor(this.choices.length-1),this.render()}up(){this.cursor===0?this.moveCursor(this.choices.length-1):this.moveCursor(this.cursor-1),this.render()}down(){this.cursor===this.choices.length-1?this.moveCursor(0):this.moveCursor(this.cursor+1),this.render()}next(){this.moveCursor((this.cursor+1)%this.choices.length),this.render()}_(s,a){if(s===" ")return this.submit()}get selection(){return this.choices[this.cursor]}render(){if(this.closed)return;this.firstRender?this.out.write(m.hide):this.out.write(t(this.outputText,this.out.columns)),super.render();let{startIndex:s,endIndex:a}=i(this.cursor,this.choices.length,this.optionsPerPage);if(this.outputText=[d.symbol(this.done,this.aborted),e.bold(this.msg),d.delimiter(!1),this.done?this.selection.title:this.selection.disabled?e.yellow(this.warn):e.gray(this.hint)].join(" "),!this.done){this.outputText+=`
|
|
10
|
+
`;for(let p=s;p<a;p++){let u,h,f="",v=this.choices[p];p===s&&s>0?h=l.arrowUp:p===a-1&&a<this.choices.length?h=l.arrowDown:h=" ",v.disabled?(u=this.cursor===p?e.gray().underline(v.title):e.strikethrough().gray(v.title),h=(this.cursor===p?e.bold().gray(l.pointer)+" ":" ")+h):(u=this.cursor===p?e.cyan().underline(v.title):v.title,h=(this.cursor===p?e.cyan(l.pointer)+" ":" ")+h,v.description&&this.cursor===p&&(f=` - ${v.description}`,(h.length+u.length+f.length>=this.out.columns||v.description.split(/\r?\n/).length>1)&&(f=`
|
|
11
|
+
`+c(v.description,{margin:3,width:this.out.columns})))),this.outputText+=`${h} ${u}${e.gray(f)}
|
|
12
|
+
`}}this.out.write(this.outputText)}}return rt=o,rt}var nt,kt;function _e(){if(kt)return nt;kt=1;const e=C(),r=A(),{style:d,clear:t}=q(),{cursor:l,erase:c}=D();class i extends r{constructor(o={}){super(o),this.msg=o.message,this.value=!!o.initial,this.active=o.active||"on",this.inactive=o.inactive||"off",this.initialValue=this.value,this.render()}reset(){this.value=this.initialValue,this.fire(),this.render()}exit(){this.abort()}abort(){this.done=this.aborted=!0,this.fire(),this.render(),this.out.write(`
|
|
13
13
|
`),this.close()}submit(){this.done=!0,this.aborted=!1,this.fire(),this.render(),this.out.write(`
|
|
14
|
-
`),this.close()}deactivate(){if(this.value===!1)return this.bell();this.value=!1,this.render()}activate(){if(this.value===!0)return this.bell();this.value=!0,this.render()}delete(){this.deactivate()}left(){this.deactivate()}right(){this.activate()}down(){this.deactivate()}up(){this.activate()}next(){this.value=!this.value,this.fire(),this.render()}_(o,n){if(o===" ")this.value=!this.value;else if(o==="1")this.value=!0;else if(o==="0")this.value=!1;else return this.bell();this.render()}render(){this.closed||(this.firstRender?this.out.write(l.hide):this.out.write(t(this.outputText,this.out.columns)),super.render(),this.outputText=[
|
|
14
|
+
`),this.close()}deactivate(){if(this.value===!1)return this.bell();this.value=!1,this.render()}activate(){if(this.value===!0)return this.bell();this.value=!0,this.render()}delete(){this.deactivate()}left(){this.deactivate()}right(){this.activate()}down(){this.deactivate()}up(){this.activate()}next(){this.value=!this.value,this.fire(),this.render()}_(o,n){if(o===" ")this.value=!this.value;else if(o==="1")this.value=!0;else if(o==="0")this.value=!1;else return this.bell();this.render()}render(){this.closed||(this.firstRender?this.out.write(l.hide):this.out.write(t(this.outputText,this.out.columns)),super.render(),this.outputText=[d.symbol(this.done,this.aborted),e.bold(this.msg),d.delimiter(this.done),this.value?this.inactive:e.cyan().underline(this.inactive),e.gray("/"),this.value?e.cyan().underline(this.active):this.active].join(" "),this.out.write(c.line+l.to(0)+this.outputText))}}return nt=i,nt}var ot,zt;function _(){if(zt)return ot;zt=1;class e{constructor({token:d,date:t,parts:l,locales:c}){this.token=d,this.date=t||new Date,this.parts=l||[this],this.locales=c||{}}up(){}down(){}next(){const d=this.parts.indexOf(this);return this.parts.find((t,l)=>l>d&&t instanceof e)}setTo(d){}prev(){let d=[].concat(this.parts).reverse();const t=d.indexOf(this);return d.find((l,c)=>c>t&&l instanceof e)}toString(){return String(this.date)}}return ot=e,ot}var lt,Gt;function Ae(){if(Gt)return lt;Gt=1;const e=_();class r extends e{constructor(t={}){super(t)}up(){this.date.setHours((this.date.getHours()+12)%24)}down(){this.up()}toString(){let t=this.date.getHours()>12?"pm":"am";return/\A/.test(this.token)?t.toUpperCase():t}}return lt=r,lt}var ht,Kt;function je(){if(Kt)return ht;Kt=1;const e=_(),r=t=>(t=t%10,t===1?"st":t===2?"nd":t===3?"rd":"th");class d extends e{constructor(l={}){super(l)}up(){this.date.setDate(this.date.getDate()+1)}down(){this.date.setDate(this.date.getDate()-1)}setTo(l){this.date.setDate(parseInt(l.substr(-2)))}toString(){let l=this.date.getDate(),c=this.date.getDay();return this.token==="DD"?String(l).padStart(2,"0"):this.token==="Do"?l+r(l):this.token==="d"?c+1:this.token==="ddd"?this.locales.weekdaysShort[c]:this.token==="dddd"?this.locales.weekdays[c]:l}}return ht=d,ht}var at,Wt;function Fe(){if(Wt)return at;Wt=1;const e=_();class r extends e{constructor(t={}){super(t)}up(){this.date.setHours(this.date.getHours()+1)}down(){this.date.setHours(this.date.getHours()-1)}setTo(t){this.date.setHours(parseInt(t.substr(-2)))}toString(){let t=this.date.getHours();return/h/.test(this.token)&&(t=t%12||12),this.token.length>1?String(t).padStart(2,"0"):t}}return at=r,at}var ut,Zt;function Le(){if(Zt)return ut;Zt=1;const e=_();class r extends e{constructor(t={}){super(t)}up(){this.date.setMilliseconds(this.date.getMilliseconds()+1)}down(){this.date.setMilliseconds(this.date.getMilliseconds()-1)}setTo(t){this.date.setMilliseconds(parseInt(t.substr(-this.token.length)))}toString(){return String(this.date.getMilliseconds()).padStart(4,"0").substr(0,this.token.length)}}return ut=r,ut}var ct,Xt;function Ne(){if(Xt)return ct;Xt=1;const e=_();class r extends e{constructor(t={}){super(t)}up(){this.date.setMinutes(this.date.getMinutes()+1)}down(){this.date.setMinutes(this.date.getMinutes()-1)}setTo(t){this.date.setMinutes(parseInt(t.substr(-2)))}toString(){let t=this.date.getMinutes();return this.token.length>1?String(t).padStart(2,"0"):t}}return ct=r,ct}var dt,Qt;function Ye(){if(Qt)return dt;Qt=1;const e=_();class r extends e{constructor(t={}){super(t)}up(){this.date.setMonth(this.date.getMonth()+1)}down(){this.date.setMonth(this.date.getMonth()-1)}setTo(t){t=parseInt(t.substr(-2))-1,this.date.setMonth(t<0?0:t)}toString(){let t=this.date.getMonth(),l=this.token.length;return l===2?String(t+1).padStart(2,"0"):l===3?this.locales.monthsShort[t]:l===4?this.locales.months[t]:String(t+1)}}return dt=r,dt}var ft,te;function He(){if(te)return ft;te=1;const e=_();class r extends e{constructor(t={}){super(t)}up(){this.date.setSeconds(this.date.getSeconds()+1)}down(){this.date.setSeconds(this.date.getSeconds()-1)}setTo(t){this.date.setSeconds(parseInt(t.substr(-2)))}toString(){let t=this.date.getSeconds();return this.token.length>1?String(t).padStart(2,"0"):t}}return ft=r,ft}var pt,ee;function Ve(){if(ee)return pt;ee=1;const e=_();class r extends e{constructor(t={}){super(t)}up(){this.date.setFullYear(this.date.getFullYear()+1)}down(){this.date.setFullYear(this.date.getFullYear()-1)}setTo(t){this.date.setFullYear(t.substr(-4))}toString(){let t=String(this.date.getFullYear()).padStart(4,"0");return this.token.length===2?t.substr(-2):t}}return pt=r,pt}var mt,ie;function Be(){return ie||(ie=1,mt={DatePart:_(),Meridiem:Ae(),Day:je(),Hours:Fe(),Milliseconds:Le(),Minutes:Ne(),Month:Ye(),Seconds:He(),Year:Ve()}),mt}var gt,se;function Ue(){if(se)return gt;se=1;const e=C(),r=A(),{style:d,clear:t,figures:l}=q(),{erase:c,cursor:i}=D(),{DatePart:m,Meridiem:o,Day:n,Hours:s,Milliseconds:a,Minutes:p,Month:u,Seconds:h,Year:f}=Be(),v=/\\(.)|"((?:\\["\\]|[^"])+)"|(D[Do]?|d{3,4}|d)|(M{1,4})|(YY(?:YY)?)|([aA])|([Hh]{1,2})|(m{1,2})|(s{1,2})|(S{1,4})|./g,x={1:({token:g})=>g.replace(/\\(.)/g,"$1"),2:g=>new n(g),3:g=>new u(g),4:g=>new f(g),5:g=>new o(g),6:g=>new s(g),7:g=>new p(g),8:g=>new h(g),9:g=>new a(g)},O={months:"January,February,March,April,May,June,July,August,September,October,November,December".split(","),monthsShort:"Jan,Feb,Mar,Apr,May,Jun,Jul,Aug,Sep,Oct,Nov,Dec".split(","),weekdays:"Sunday,Monday,Tuesday,Wednesday,Thursday,Friday,Saturday".split(","),weekdaysShort:"Sun,Mon,Tue,Wed,Thu,Fri,Sat".split(",")};class M extends r{constructor(b={}){super(b),this.msg=b.message,this.cursor=0,this.typed="",this.locales=Object.assign(O,b.locales),this._date=b.initial||new Date,this.errorMsg=b.error||"Please Enter A Valid Value",this.validator=b.validate||(()=>!0),this.mask=b.mask||"YYYY-MM-DD HH:mm:ss",this.clear=t("",this.out.columns),this.render()}get value(){return this.date}get date(){return this._date}set date(b){b&&this._date.setTime(b.getTime())}set mask(b){let y;for(this.parts=[];y=v.exec(b);){let $=y.shift(),R=y.findIndex(S=>S!=null);this.parts.push(R in x?x[R]({token:y[R]||$,date:this.date,parts:this.parts,locales:this.locales}):y[R]||$)}let w=this.parts.reduce(($,R)=>(typeof R=="string"&&typeof $[$.length-1]=="string"?$[$.length-1]+=R:$.push(R),$),[]);this.parts.splice(0),this.parts.push(...w),this.reset()}moveCursor(b){this.typed="",this.cursor=b,this.fire()}reset(){this.moveCursor(this.parts.findIndex(b=>b instanceof m)),this.fire(),this.render()}exit(){this.abort()}abort(){this.done=this.aborted=!0,this.error=!1,this.fire(),this.render(),this.out.write(`
|
|
15
15
|
`),this.close()}async validate(){let b=await this.validator(this.value);typeof b=="string"&&(this.errorMsg=b,b=!1),this.error=!b}async submit(){if(await this.validate(),this.error){this.color="red",this.fire(),this.render();return}this.done=!0,this.aborted=!1,this.fire(),this.render(),this.out.write(`
|
|
16
|
-
`),this.close()}up(){this.typed="",this.parts[this.cursor].up(),this.render()}down(){this.typed="",this.parts[this.cursor].down(),this.render()}left(){let b=this.parts[this.cursor].prev();if(b==null)return this.bell();this.moveCursor(this.parts.indexOf(b)),this.render()}right(){let b=this.parts[this.cursor].next();if(b==null)return this.bell();this.moveCursor(this.parts.indexOf(b)),this.render()}next(){let b=this.parts[this.cursor].next();this.moveCursor(b?this.parts.indexOf(b):this.parts.findIndex(
|
|
17
|
-
`).reduce((b,
|
|
18
|
-
${w?" ":l.pointerSmall} ${e.red().italic(
|
|
19
|
-
`),this.close()}async validate(){let
|
|
20
|
-
`),this.close()}up(){if(this.typed="",this.value===""&&(this.value=this.min-this.inc),this.value>=this.max)return this.bell();this.value+=this.inc,this.color="cyan",this.fire(),this.render()}down(){if(this.typed="",this.value===""&&(this.value=this.min+this.inc),this.value<=this.min)return this.bell();this.value-=this.inc,this.color="cyan",this.fire(),this.render()}delete(){let
|
|
21
|
-
`).reduce((
|
|
22
|
-
${f?" ":
|
|
23
|
-
`),this.close()}submit(){const s=this.value.filter(
|
|
24
|
-
`),this.close())}first(){this.cursor=0,this.render()}last(){this.cursor=this.value.length-1,this.render()}next(){this.cursor=(this.cursor+1)%this.value.length,this.render()}up(){this.cursor===0?this.cursor=this.value.length-1:this.cursor--,this.render()}down(){this.cursor===this.value.length-1?this.cursor=0:this.cursor++,this.render()}left(){this.value[this.cursor].selected=!1,this.render()}right(){if(this.value.filter(s=>s.selected).length>=this.maxChoices)return this.bell();this.value[this.cursor].selected=!0,this.render()}handleSpaceToggle(){const s=this.value[this.cursor];if(s.selected)s.selected=!1,this.render();else{if(s.disabled||this.value.filter(
|
|
16
|
+
`),this.close()}up(){this.typed="",this.parts[this.cursor].up(),this.render()}down(){this.typed="",this.parts[this.cursor].down(),this.render()}left(){let b=this.parts[this.cursor].prev();if(b==null)return this.bell();this.moveCursor(this.parts.indexOf(b)),this.render()}right(){let b=this.parts[this.cursor].next();if(b==null)return this.bell();this.moveCursor(this.parts.indexOf(b)),this.render()}next(){let b=this.parts[this.cursor].next();this.moveCursor(b?this.parts.indexOf(b):this.parts.findIndex(y=>y instanceof m)),this.render()}_(b){/\d/.test(b)&&(this.typed+=b,this.parts[this.cursor].setTo(this.typed),this.render())}render(){this.closed||(this.firstRender?this.out.write(i.hide):this.out.write(t(this.outputText,this.out.columns)),super.render(),this.outputText=[d.symbol(this.done,this.aborted),e.bold(this.msg),d.delimiter(!1),this.parts.reduce((b,y,w)=>b.concat(w===this.cursor&&!this.done?e.cyan().underline(y.toString()):y),[]).join("")].join(" "),this.error&&(this.outputText+=this.errorMsg.split(`
|
|
17
|
+
`).reduce((b,y,w)=>b+`
|
|
18
|
+
${w?" ":l.pointerSmall} ${e.red().italic(y)}`,"")),this.out.write(c.line+i.to(0)+this.outputText))}}return gt=M,gt}var vt,re;function Je(){if(re)return vt;re=1;const e=C(),r=A(),{cursor:d,erase:t}=D(),{style:l,figures:c,clear:i,lines:m}=q(),o=/[0-9]/,n=p=>p!==void 0,s=(p,u)=>{let h=Math.pow(10,u);return Math.round(p*h)/h};class a extends r{constructor(u={}){super(u),this.transform=l.render(u.style),this.msg=u.message,this.initial=n(u.initial)?u.initial:"",this.float=!!u.float,this.round=u.round||2,this.inc=u.increment||1,this.min=n(u.min)?u.min:-1/0,this.max=n(u.max)?u.max:1/0,this.errorMsg=u.error||"Please Enter A Valid Value",this.validator=u.validate||(()=>!0),this.color="cyan",this.value="",this.typed="",this.lastHit=0,this.render()}set value(u){!u&&u!==0?(this.placeholder=!0,this.rendered=e.gray(this.transform.render(`${this.initial}`)),this._value=""):(this.placeholder=!1,this.rendered=this.transform.render(`${s(u,this.round)}`),this._value=s(u,this.round)),this.fire()}get value(){return this._value}parse(u){return this.float?parseFloat(u):parseInt(u)}valid(u){return u==="-"||u==="."&&this.float||o.test(u)}reset(){this.typed="",this.value="",this.fire(),this.render()}exit(){this.abort()}abort(){let u=this.value;this.value=u!==""?u:this.initial,this.done=this.aborted=!0,this.error=!1,this.fire(),this.render(),this.out.write(`
|
|
19
|
+
`),this.close()}async validate(){let u=await this.validator(this.value);typeof u=="string"&&(this.errorMsg=u,u=!1),this.error=!u}async submit(){if(await this.validate(),this.error){this.color="red",this.fire(),this.render();return}let u=this.value;this.value=u!==""?u:this.initial,this.done=!0,this.aborted=!1,this.error=!1,this.fire(),this.render(),this.out.write(`
|
|
20
|
+
`),this.close()}up(){if(this.typed="",this.value===""&&(this.value=this.min-this.inc),this.value>=this.max)return this.bell();this.value+=this.inc,this.color="cyan",this.fire(),this.render()}down(){if(this.typed="",this.value===""&&(this.value=this.min+this.inc),this.value<=this.min)return this.bell();this.value-=this.inc,this.color="cyan",this.fire(),this.render()}delete(){let u=this.value.toString();if(u.length===0)return this.bell();this.value=this.parse(u=u.slice(0,-1))||"",this.value!==""&&this.value<this.min&&(this.value=this.min),this.color="cyan",this.fire(),this.render()}next(){this.value=this.initial,this.fire(),this.render()}_(u,h){if(!this.valid(u))return this.bell();const f=Date.now();if(f-this.lastHit>1e3&&(this.typed=""),this.typed+=u,this.lastHit=f,this.color="cyan",u===".")return this.fire();this.value=Math.min(this.parse(this.typed),this.max),this.value>this.max&&(this.value=this.max),this.value<this.min&&(this.value=this.min),this.fire(),this.render()}render(){this.closed||(this.firstRender||(this.outputError&&this.out.write(d.down(m(this.outputError,this.out.columns)-1)+i(this.outputError,this.out.columns)),this.out.write(i(this.outputText,this.out.columns))),super.render(),this.outputError="",this.outputText=[l.symbol(this.done,this.aborted),e.bold(this.msg),l.delimiter(this.done),!this.done||!this.done&&!this.placeholder?e[this.color]().underline(this.rendered):this.rendered].join(" "),this.error&&(this.outputError+=this.errorMsg.split(`
|
|
21
|
+
`).reduce((u,h,f)=>u+`
|
|
22
|
+
${f?" ":c.pointerSmall} ${e.red().italic(h)}`,"")),this.out.write(t.line+d.to(0)+this.outputText+d.save+this.outputError+d.restore))}}return vt=a,vt}var bt,ne;function oe(){if(ne)return bt;ne=1;const e=C(),{cursor:r}=D(),d=A(),{clear:t,figures:l,style:c,wrap:i,entriesToDisplay:m}=q();class o extends d{constructor(s={}){super(s),this.msg=s.message,this.cursor=s.cursor||0,this.scrollIndex=s.cursor||0,this.hint=s.hint||"",this.warn=s.warn||"- This option is disabled -",this.minSelected=s.min,this.showMinError=!1,this.maxChoices=s.max,this.instructions=s.instructions,this.optionsPerPage=s.optionsPerPage||10,this.value=s.choices.map((a,p)=>(typeof a=="string"&&(a={title:a,value:p}),{title:a&&(a.title||a.value||a),description:a&&a.description,value:a&&(a.value===void 0?p:a.value),selected:a&&a.selected,disabled:a&&a.disabled})),this.clear=t("",this.out.columns),s.overrideRender||this.render()}reset(){this.value.map(s=>!s.selected),this.cursor=0,this.fire(),this.render()}selected(){return this.value.filter(s=>s.selected)}exit(){this.abort()}abort(){this.done=this.aborted=!0,this.fire(),this.render(),this.out.write(`
|
|
23
|
+
`),this.close()}submit(){const s=this.value.filter(a=>a.selected);this.minSelected&&s.length<this.minSelected?(this.showMinError=!0,this.render()):(this.done=!0,this.aborted=!1,this.fire(),this.render(),this.out.write(`
|
|
24
|
+
`),this.close())}first(){this.cursor=0,this.render()}last(){this.cursor=this.value.length-1,this.render()}next(){this.cursor=(this.cursor+1)%this.value.length,this.render()}up(){this.cursor===0?this.cursor=this.value.length-1:this.cursor--,this.render()}down(){this.cursor===this.value.length-1?this.cursor=0:this.cursor++,this.render()}left(){this.value[this.cursor].selected=!1,this.render()}right(){if(this.value.filter(s=>s.selected).length>=this.maxChoices)return this.bell();this.value[this.cursor].selected=!0,this.render()}handleSpaceToggle(){const s=this.value[this.cursor];if(s.selected)s.selected=!1,this.render();else{if(s.disabled||this.value.filter(a=>a.selected).length>=this.maxChoices)return this.bell();s.selected=!0,this.render()}}toggleAll(){if(this.maxChoices!==void 0||this.value[this.cursor].disabled)return this.bell();const s=!this.value[this.cursor].selected;this.value.filter(a=>!a.disabled).forEach(a=>a.selected=s),this.render()}_(s,a){if(s===" ")this.handleSpaceToggle();else if(s==="a")this.toggleAll();else return this.bell()}renderInstructions(){return this.instructions===void 0||this.instructions?typeof this.instructions=="string"?this.instructions:`
|
|
25
25
|
Instructions:
|
|
26
26
|
${l.arrowUp}/${l.arrowDown}: Highlight option
|
|
27
27
|
${l.arrowLeft}/${l.arrowRight}/[space]: Toggle selection
|
|
28
28
|
`+(this.maxChoices===void 0?` a: Toggle all
|
|
29
|
-
`:"")+" enter/return: Complete answer":""}renderOption(s,
|
|
30
|
-
`+i(
|
|
29
|
+
`:"")+" enter/return: Complete answer":""}renderOption(s,a,p,u){const h=(a.selected?e.green(l.radioOn):l.radioOff)+" "+u+" ";let f,v;return a.disabled?f=s===p?e.gray().underline(a.title):e.strikethrough().gray(a.title):(f=s===p?e.cyan().underline(a.title):a.title,s===p&&a.description&&(v=` - ${a.description}`,(h.length+f.length+v.length>=this.out.columns||a.description.split(/\r?\n/).length>1)&&(v=`
|
|
30
|
+
`+i(a.description,{margin:h.length,width:this.out.columns})))),h+f+e.gray(v||"")}paginateOptions(s){if(s.length===0)return e.red("No matches for this query.");let{startIndex:a,endIndex:p}=m(this.cursor,s.length,this.optionsPerPage),u,h=[];for(let f=a;f<p;f++)f===a&&a>0?u=l.arrowUp:f===p-1&&p<s.length?u=l.arrowDown:u=" ",h.push(this.renderOption(this.cursor,s[f],f,u));return`
|
|
31
31
|
`+h.join(`
|
|
32
|
-
`)}renderOptions(s){return this.done?"":this.paginateOptions(s)}renderDoneOrInstructions(){if(this.done)return this.value.filter(
|
|
32
|
+
`)}renderOptions(s){return this.done?"":this.paginateOptions(s)}renderDoneOrInstructions(){if(this.done)return this.value.filter(a=>a.selected).map(a=>a.title).join(", ");const s=[e.gray(this.hint),this.renderInstructions()];return this.value[this.cursor].disabled&&s.push(e.yellow(this.warn)),s.join(" ")}render(){if(this.closed)return;this.firstRender&&this.out.write(r.hide),super.render();let s=[c.symbol(this.done,this.aborted),e.bold(this.msg),c.delimiter(!1),this.renderDoneOrInstructions()].join(" ");this.showMinError&&(s+=e.red(`You must select a minimum of ${this.minSelected} choices.`),this.showMinError=!1),s+=this.renderOptions(this.value),this.out.write(this.clear+s),this.clear=t(s,this.out.columns)}}return bt=o,bt}var wt,le;function ke(){if(le)return wt;le=1;const e=C(),r=A(),{erase:d,cursor:t}=D(),{style:l,clear:c,figures:i,wrap:m,entriesToDisplay:o}=q(),n=(u,h)=>u[h]&&(u[h].value||u[h].title||u[h]),s=(u,h)=>u[h]&&(u[h].title||u[h].value||u[h]),a=(u,h)=>{const f=u.findIndex(v=>v.value===h||v.title===h);return f>-1?f:void 0};class p extends r{constructor(h={}){super(h),this.msg=h.message,this.suggest=h.suggest,this.choices=h.choices,this.initial=typeof h.initial=="number"?h.initial:a(h.choices,h.initial),this.select=this.initial||h.cursor||0,this.i18n={noMatches:h.noMatches||"no matches found"},this.fallback=h.fallback||this.initial,this.clearFirst=h.clearFirst||!1,this.suggestions=[],this.input="",this.limit=h.limit||10,this.cursor=0,this.transform=l.render(h.style),this.scale=this.transform.scale,this.render=this.render.bind(this),this.complete=this.complete.bind(this),this.clear=c("",this.out.columns),this.complete(this.render),this.render()}set fallback(h){this._fb=Number.isSafeInteger(parseInt(h))?parseInt(h):h}get fallback(){let h;return typeof this._fb=="number"?h=this.choices[this._fb]:typeof this._fb=="string"&&(h={title:this._fb}),h||this._fb||{title:this.i18n.noMatches}}moveSelect(h){this.select=h,this.suggestions.length>0?this.value=n(this.suggestions,h):this.value=this.fallback.value,this.fire()}async complete(h){const f=this.completing=this.suggest(this.input,this.choices),v=await f;if(this.completing!==f)return;this.suggestions=v.map((O,M,g)=>({title:s(g,M),value:n(g,M),description:O.description})),this.completing=!1;const x=Math.max(v.length-1,0);this.moveSelect(Math.min(x,this.select)),h&&h()}reset(){this.input="",this.complete(()=>{this.moveSelect(this.initial!==void 0?this.initial:0),this.render()}),this.render()}exit(){this.clearFirst&&this.input.length>0?this.reset():(this.done=this.exited=!0,this.aborted=!1,this.fire(),this.render(),this.out.write(`
|
|
33
33
|
`),this.close())}abort(){this.done=this.aborted=!0,this.exited=!1,this.fire(),this.render(),this.out.write(`
|
|
34
34
|
`),this.close()}submit(){this.done=!0,this.aborted=this.exited=!1,this.fire(),this.render(),this.out.write(`
|
|
35
|
-
`),this.close()}_(h,f){let
|
|
36
|
-
`+m(h.description,{margin:3,width:this.out.columns}))),
|
|
35
|
+
`),this.close()}_(h,f){let v=this.input.slice(0,this.cursor),x=this.input.slice(this.cursor);this.input=`${v}${h}${x}`,this.cursor=v.length+1,this.complete(this.render),this.render()}delete(){if(this.cursor===0)return this.bell();let h=this.input.slice(0,this.cursor-1),f=this.input.slice(this.cursor);this.input=`${h}${f}`,this.complete(this.render),this.cursor=this.cursor-1,this.render()}deleteForward(){if(this.cursor*this.scale>=this.rendered.length)return this.bell();let h=this.input.slice(0,this.cursor),f=this.input.slice(this.cursor+1);this.input=`${h}${f}`,this.complete(this.render),this.render()}first(){this.moveSelect(0),this.render()}last(){this.moveSelect(this.suggestions.length-1),this.render()}up(){this.select===0?this.moveSelect(this.suggestions.length-1):this.moveSelect(this.select-1),this.render()}down(){this.select===this.suggestions.length-1?this.moveSelect(0):this.moveSelect(this.select+1),this.render()}next(){this.select===this.suggestions.length-1?this.moveSelect(0):this.moveSelect(this.select+1),this.render()}nextPage(){this.moveSelect(Math.min(this.select+this.limit,this.suggestions.length-1)),this.render()}prevPage(){this.moveSelect(Math.max(this.select-this.limit,0)),this.render()}left(){if(this.cursor<=0)return this.bell();this.cursor=this.cursor-1,this.render()}right(){if(this.cursor*this.scale>=this.rendered.length)return this.bell();this.cursor=this.cursor+1,this.render()}renderOption(h,f,v,x){let O,M=v?i.arrowUp:x?i.arrowDown:" ",g=f?e.cyan().underline(h.title):h.title;return M=(f?e.cyan(i.pointer)+" ":" ")+M,h.description&&(O=` - ${h.description}`,(M.length+g.length+O.length>=this.out.columns||h.description.split(/\r?\n/).length>1)&&(O=`
|
|
36
|
+
`+m(h.description,{margin:3,width:this.out.columns}))),M+" "+g+e.gray(O||"")}render(){if(this.closed)return;this.firstRender?this.out.write(t.hide):this.out.write(c(this.outputText,this.out.columns)),super.render();let{startIndex:h,endIndex:f}=o(this.select,this.choices.length,this.limit);if(this.outputText=[l.symbol(this.done,this.aborted,this.exited),e.bold(this.msg),l.delimiter(this.completing),this.done&&this.suggestions[this.select]?this.suggestions[this.select].title:this.rendered=this.transform.render(this.input)].join(" "),!this.done){const v=this.suggestions.slice(h,f).map((x,O)=>this.renderOption(x,this.select===O+h,O===0&&h>0,O+h===f-1&&f<this.choices.length)).join(`
|
|
37
37
|
`);this.outputText+=`
|
|
38
|
-
`+(
|
|
38
|
+
`+(v||e.gray(this.fallback.title))}this.out.write(d.line+t.to(0)+this.outputText)}}return wt=p,wt}var yt,he;function ze(){if(he)return yt;he=1;const e=C(),{cursor:r}=D(),d=oe(),{clear:t,style:l,figures:c}=q();class i extends d{constructor(o={}){o.overrideRender=!0,super(o),this.inputValue="",this.clear=t("",this.out.columns),this.filteredOptions=this.value,this.render()}last(){this.cursor=this.filteredOptions.length-1,this.render()}next(){this.cursor=(this.cursor+1)%this.filteredOptions.length,this.render()}up(){this.cursor===0?this.cursor=this.filteredOptions.length-1:this.cursor--,this.render()}down(){this.cursor===this.filteredOptions.length-1?this.cursor=0:this.cursor++,this.render()}left(){this.filteredOptions[this.cursor].selected=!1,this.render()}right(){if(this.value.filter(o=>o.selected).length>=this.maxChoices)return this.bell();this.filteredOptions[this.cursor].selected=!0,this.render()}delete(){this.inputValue.length&&(this.inputValue=this.inputValue.substr(0,this.inputValue.length-1),this.updateFilteredOptions())}updateFilteredOptions(){const o=this.filteredOptions[this.cursor];this.filteredOptions=this.value.filter(s=>this.inputValue?!!(typeof s.title=="string"&&s.title.toLowerCase().includes(this.inputValue.toLowerCase())||typeof s.value=="string"&&s.value.toLowerCase().includes(this.inputValue.toLowerCase())):!0);const n=this.filteredOptions.findIndex(s=>s===o);this.cursor=n<0?0:n,this.render()}handleSpaceToggle(){const o=this.filteredOptions[this.cursor];if(o.selected)o.selected=!1,this.render();else{if(o.disabled||this.value.filter(n=>n.selected).length>=this.maxChoices)return this.bell();o.selected=!0,this.render()}}handleInputChange(o){this.inputValue=this.inputValue+o,this.updateFilteredOptions()}_(o,n){o===" "?this.handleSpaceToggle():this.handleInputChange(o)}renderInstructions(){return this.instructions===void 0||this.instructions?typeof this.instructions=="string"?this.instructions:`
|
|
39
39
|
Instructions:
|
|
40
|
-
${
|
|
41
|
-
${
|
|
40
|
+
${c.arrowUp}/${c.arrowDown}: Highlight option
|
|
41
|
+
${c.arrowLeft}/${c.arrowRight}/[space]: Toggle selection
|
|
42
42
|
[a,b,c]/delete: Filter choices
|
|
43
43
|
enter/return: Complete answer
|
|
44
44
|
`:""}renderCurrentInput(){return`
|
|
45
45
|
Filtered results for: ${this.inputValue?this.inputValue:e.gray("Enter something to filter")}
|
|
46
|
-
`}renderOption(o,n,s){let
|
|
46
|
+
`}renderOption(o,n,s){let a;return n.disabled?a=o===s?e.gray().underline(n.title):e.strikethrough().gray(n.title):a=o===s?e.cyan().underline(n.title):n.title,(n.selected?e.green(c.radioOn):c.radioOff)+" "+a}renderDoneOrInstructions(){if(this.done)return this.value.filter(n=>n.selected).map(n=>n.title).join(", ");const o=[e.gray(this.hint),this.renderInstructions(),this.renderCurrentInput()];return this.filteredOptions.length&&this.filteredOptions[this.cursor].disabled&&o.push(e.yellow(this.warn)),o.join(" ")}render(){if(this.closed)return;this.firstRender&&this.out.write(r.hide),super.render();let o=[l.symbol(this.done,this.aborted),e.bold(this.msg),l.delimiter(!1),this.renderDoneOrInstructions()].join(" ");this.showMinError&&(o+=e.red(`You must select a minimum of ${this.minSelected} choices.`),this.showMinError=!1),o+=this.renderOptions(this.filteredOptions),this.out.write(this.clear+o),this.clear=t(o,this.out.columns)}}return yt=i,yt}var St,ae;function Ge(){if(ae)return St;ae=1;const e=C(),r=A(),{style:d,clear:t}=q(),{erase:l,cursor:c}=D();class i extends r{constructor(o={}){super(o),this.msg=o.message,this.value=o.initial,this.initialValue=!!o.initial,this.yesMsg=o.yes||"yes",this.yesOption=o.yesOption||"(Y/n)",this.noMsg=o.no||"no",this.noOption=o.noOption||"(y/N)",this.render()}reset(){this.value=this.initialValue,this.fire(),this.render()}exit(){this.abort()}abort(){this.done=this.aborted=!0,this.fire(),this.render(),this.out.write(`
|
|
47
47
|
`),this.close()}submit(){this.value=this.value||!1,this.done=!0,this.aborted=!1,this.fire(),this.render(),this.out.write(`
|
|
48
|
-
`),this.close()}_(o,n){return o.toLowerCase()==="y"?(this.value=!0,this.submit()):o.toLowerCase()==="n"?(this.value=!1,this.submit()):this.bell()}render(){this.closed||(this.firstRender?this.out.write(
|
|
49
|
-
Scaffolding project in ${
|
|
50
|
-
`);const
|
|
48
|
+
`),this.close()}_(o,n){return o.toLowerCase()==="y"?(this.value=!0,this.submit()):o.toLowerCase()==="n"?(this.value=!1,this.submit()):this.bell()}render(){this.closed||(this.firstRender?this.out.write(c.hide):this.out.write(t(this.outputText,this.out.columns)),super.render(),this.outputText=[d.symbol(this.done,this.aborted),e.bold(this.msg),d.delimiter(this.done),this.done?this.value?this.yesMsg:this.noMsg:e.gray(this.initialValue?this.yesOption:this.noOption)].join(" "),this.out.write(l.line+c.to(0)+this.outputText))}}return St=i,St}var xt,ue;function Ke(){return ue||(ue=1,xt={TextPrompt:qe(),SelectPrompt:Ie(),TogglePrompt:_e(),DatePrompt:Ue(),NumberPrompt:Je(),MultiselectPrompt:oe(),AutocompletePrompt:ke(),AutocompleteMultiselectPrompt:ze(),ConfirmPrompt:Ge()}),xt}var ce;function We(){return ce||(ce=1,function(e){const r=e,d=Ke(),t=i=>i;function l(i,m,o={}){return new Promise((n,s)=>{const a=new d[i](m),p=o.onAbort||t,u=o.onSubmit||t,h=o.onExit||t;a.on("state",m.onState||t),a.on("submit",f=>n(u(f))),a.on("exit",f=>n(h(f))),a.on("abort",f=>s(p(f)))})}r.text=i=>l("TextPrompt",i),r.password=i=>(i.style="password",r.text(i)),r.invisible=i=>(i.style="invisible",r.text(i)),r.number=i=>l("NumberPrompt",i),r.date=i=>l("DatePrompt",i),r.confirm=i=>l("ConfirmPrompt",i),r.list=i=>{const m=i.separator||",";return l("TextPrompt",i,{onSubmit:o=>o.split(m).map(n=>n.trim())})},r.toggle=i=>l("TogglePrompt",i),r.select=i=>l("SelectPrompt",i),r.multiselect=i=>{i.choices=[].concat(i.choices||[]);const m=o=>o.filter(n=>n.selected).map(n=>n.value);return l("MultiselectPrompt",i,{onAbort:m,onSubmit:m})},r.autocompleteMultiselect=i=>{i.choices=[].concat(i.choices||[]);const m=o=>o.filter(n=>n.selected).map(n=>n.value);return l("AutocompleteMultiselectPrompt",i,{onAbort:m,onSubmit:m})};const c=(i,m)=>Promise.resolve(m.filter(o=>o.title.slice(0,i.length).toLowerCase()===i.toLowerCase()));r.autocomplete=i=>(i.suggest=i.suggest||c,i.choices=[].concat(i.choices||[]),l("AutocompletePrompt",i))}(B)),B}var $t,de;function Ze(){if(de)return $t;de=1;const e=We(),r=["suggest","format","onState","validate","onRender","type"],d=()=>{};async function t(m=[],{onSubmit:o=d,onCancel:n=d}={}){const s={},a=t._override||{};m=[].concat(m);let p,u,h,f,v,x;const O=async(M,g,b=!1)=>{if(!(!b&&M.validate&&M.validate(g)!==!0))return M.format?await M.format(g,s):g};for(u of m)if({name:f,type:v}=u,typeof v=="function"&&(v=await v(p,{...s},u),u.type=v),!!v){for(let M in u){if(r.includes(M))continue;let g=u[M];u[M]=typeof g=="function"?await g(p,{...s},x):g}if(x=u,typeof u.message!="string")throw new Error("prompt message is required");if({name:f,type:v}=u,e[v]===void 0)throw new Error(`prompt type (${v}) is not defined`);if(a[u.name]!==void 0&&(p=await O(u,a[u.name]),p!==void 0)){s[f]=p;continue}try{p=t._injected?l(t._injected,u.initial):await e[v](u),s[f]=p=await O(u,p,!0),h=await o(u,p,s)}catch{h=!await n(u,s)}if(h)return s}return s}function l(m,o){const n=m.shift();if(n instanceof Error)throw n;return n===void 0?o:n}function c(m){t._injected=(t._injected||[]).concat(m)}function i(m){t._override=Object.assign({},m)}return $t=Object.assign(t,{prompt:t,prompts:e,inject:c,override:i}),$t}var Xe=Ze();const Qe=Ct(Xe);let j=!0;const L=typeof self<"u"?self:typeof window<"u"?window:typeof global<"u"?global:{};let Y=0;if(L.process&&L.process.env&&L.process.stdout){const{FORCE_COLOR:e,NODE_DISABLE_COLORS:r,NO_COLOR:d,TERM:t,COLORTERM:l}=L.process.env;r||d||e==="0"?j=!1:e==="1"||e==="2"||e==="3"?j=!0:t==="dumb"?j=!1:"CI"in L.process.env&&["TRAVIS","CIRCLECI","APPVEYOR","GITLAB_CI","GITHUB_ACTIONS","BUILDKITE","DRONE"].some(c=>c in L.process.env)?j=!0:j=process.stdout.isTTY,j&&(process.platform==="win32"||l&&(l==="truecolor"||l==="24bit")?Y=3:t&&(t.endsWith("-256color")||t.endsWith("256"))?Y=2:Y=1)}let fe={enabled:j,supportLevel:Y};function F(e,r,d=1){const t=`\x1B[${e}m`,l=`\x1B[${r}m`,c=new RegExp(`\\x1b\\[${r}m`,"g");return i=>fe.enabled&&fe.supportLevel>=d?t+(""+i).replace(c,t)+l:""+i}const H=F(0,0),Mt=F(31,39),pe=F(32,39),me=F(33,39),ti=F(36,39),ei=F(37,39),ii=F(92,39),Ot=Oe(process.argv.slice(2),{string:["_"]}),Rt=process.cwd(),Tt=[{name:"vanilla",display:"Vanilla",color:me,variants:[{name:"vanilla",display:"JavaScript",color:me}]},{name:"react",display:"React",color:ti,variants:[{name:"react-leo",display:"JavaScript + Leo",color:ii},{name:"react-ts",display:"React + TypeScript",color:Mt},{name:"nextjs-ts",display:"TypeScript + Next.js",color:ei}]},{name:"node",display:"Node.js",color:pe,variants:[{name:"node",display:"Node.js",color:pe}]}],ge=Tt.map(e=>e.variants&&e.variants.map(r=>r.name)||[e.name]).reduce((e,r)=>e.concat(r),[]),si={_gitignore:".gitignore"},Pt="aleo-project";async function ri(){const e=ve(Ot._[0]),r=Ot.template||Ot.t;let d=e||Pt;const t=()=>d==="."?P.basename(P.resolve()):d;let l,c;if(r&&ge.includes(r))for(const g of Tt){const b=g.variants.find(y=>y.name===r);if(b){l=g,c=b.name;break}}let i;try{i=await Qe([{type:e?null:"text",name:"projectName",message:H("Project name:"),initial:Pt,onState:g=>{d=ve(g.value)||Pt}},{type:()=>!T.existsSync(d)||li(d)?null:"confirm",name:"overwrite",message:()=>(d==="."?"Current directory":`Target directory "${d}"`)+" is not empty. Remove existing files and continue?"},{type:(g,{overwrite:b})=>{if(b===!1)throw new Error(Mt("\u2716")+" Operation cancelled");return null},name:"overwriteChecker"},{type:()=>we(t())?null:"text",name:"packageName",message:H("Package name:"),initial:()=>ni(t()),validate:g=>we(g)||"Invalid package.json name"},{type:l?null:"select",name:"framework",message:typeof r=="string"&&!ge.includes(r)?H(`"${r}" isn't a valid template. Please choose from below: `):H("Select a framework:"),initial:0,choices:Tt.map(g=>{const b=g.color;return{title:b(g.display||g.name),value:g}})},{type:c?null:"select",name:"variant",message:H("Select a variant:"),choices:g=>g.variants.map(b=>{const y=b.color;return{title:y(b.display||b.name),value:b.name}})}],{onCancel:()=>{throw new Error(Mt("\u2716")+" Operation cancelled")}})}catch(g){console.log(g.message);return}const{framework:m,overwrite:o,packageName:n,variant:s}=i,a=P.join(Rt,d);o?hi(a):T.existsSync(a)||T.mkdirSync(a,{recursive:!0});let p=s||m?.name||r;const u=ai(process.env.npm_config_user_agent),h=u?u.name:"npm";console.log(`
|
|
49
|
+
Scaffolding project in ${a}...`);const f=P.resolve(ye(import.meta.url),"../..",`template-${p}`),v=(g,b)=>{const y=P.join(a,si[g]??g);b?T.writeFileSync(y,b):be(P.join(f,g),y)},x=T.readdirSync(f);for(const g of x.filter(b=>b!=="package.json"))v(g);const O=JSON.parse(T.readFileSync(P.join(f,"package.json"),"utf-8"));O.name=n||t(),v("package.json",JSON.stringify(O,null,2)+`
|
|
50
|
+
`);const M=P.relative(Rt,a);console.log(`
|
|
51
51
|
Done. Now run:
|
|
52
|
-
`),
|
|
52
|
+
`),a!==Rt&&console.log(` cd ${M.includes(" ")?`"${M}"`:M}`),console.log(` ${h} install`),console.log(` ${h} run dev`),console.log()}function ve(e){return e?.trim().replace(/\/+$/g,"")}function be(e,r){T.statSync(e).isDirectory()?oi(e,r):T.copyFileSync(e,r)}function we(e){return/^(?:@[a-z\d\-*~][a-z\d\-*._~]*\/)?[a-z\d\-~][a-z\d\-._~]*$/.test(e)}function ni(e){return e.trim().toLowerCase().replace(/\s+/g,"-").replace(/^[._]/,"").replace(/[^a-z\d\-~]+/g,"-")}function oi(e,r){T.mkdirSync(r,{recursive:!0});for(const d of T.readdirSync(e)){const t=P.resolve(e,d),l=P.resolve(r,d);be(t,l)}}function li(e){const r=T.readdirSync(e);return r.length===0||r.length===1&&r[0]===".git"}function hi(e){if(T.existsSync(e))for(const r of T.readdirSync(e))r!==".git"&&T.rmSync(P.resolve(e,r),{recursive:!0,force:!0})}function ai(e){if(!e)return;const r=e.split(" ")[0].split("/");return{name:r[0],version:r[1]}}ri().catch(e=>{console.error(e)});
|
package/package.json
CHANGED