create-enchilada 1.0.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/LICENSE +21 -0
- package/README.md +16 -0
- package/dist/index.js +123 -0
- package/index.js +3 -0
- package/package.json +79 -0
- package/templates/node-express/.prettierrc.json +9 -0
- package/templates/node-express/.sequelizerc +6 -0
- package/templates/node-express/env-example +8 -0
- package/templates/node-express/eslint.config.mjs +15 -0
- package/templates/node-express/jest.config.js +13 -0
- package/templates/node-express/jest.config.unit.js +17 -0
- package/templates/node-express/package.json +47 -0
- package/templates/node-express/src/auth/index.js +1 -0
- package/templates/node-express/src/config/index.js +13 -0
- package/templates/node-express/src/db/index.js +16 -0
- package/templates/node-express/src/dtos/index.js +1 -0
- package/templates/node-express/src/index.js +24 -0
- package/templates/node-express/src/libs/sequelize.js +23 -0
- package/templates/node-express/src/middlewares/index.js +1 -0
- package/templates/node-express/src/routes/index.js +1 -0
- package/templates/node-express/src/services/index.js +1 -0
- package/templates/node-express/unit/fake.unit.test.js +5 -0
- package/templates/react/_gitignore +89 -0
- package/templates/react/index.html +13 -0
- package/templates/react/package.json +21 -0
- package/templates/react/src/App.css +3 -0
- package/templates/react/src/App.jsx +19 -0
- package/templates/react/src/index.css +57 -0
- package/templates/react/src/main.jsx +10 -0
- package/templates/react/vite.config.js +7 -0
- package/templates/react-dev/.babelrc +7 -0
- package/templates/react-dev/__tests__/App.test.jsx +9 -0
- package/templates/react-dev/_gitignore +89 -0
- package/templates/react-dev/eslint.config.js +27 -0
- package/templates/react-dev/index.html +13 -0
- package/templates/react-dev/jest.config.cjs +13 -0
- package/templates/react-dev/jest.setup.js +1 -0
- package/templates/react-dev/package.json +41 -0
- package/templates/react-dev/postcss.config.mjs +5 -0
- package/templates/react-dev/src/App.jsx +22 -0
- package/templates/react-dev/src/index.css +1 -0
- package/templates/react-dev/src/main.jsx +10 -0
- package/templates/react-dev/vite.config.js +7 -0
- package/templates/react-dev-typescript/.babelrc +11 -0
- package/templates/react-dev-typescript/__tests__/App.test.tsx +11 -0
- package/templates/react-dev-typescript/_gitignore +89 -0
- package/templates/react-dev-typescript/eslint.config.js +29 -0
- package/templates/react-dev-typescript/index.html +13 -0
- package/templates/react-dev-typescript/jest.config.cjs +13 -0
- package/templates/react-dev-typescript/jest.setup.js +1 -0
- package/templates/react-dev-typescript/package.json +44 -0
- package/templates/react-dev-typescript/postcss.config.mjs +5 -0
- package/templates/react-dev-typescript/src/App.tsx +21 -0
- package/templates/react-dev-typescript/src/index.css +1 -0
- package/templates/react-dev-typescript/src/main.tsx +10 -0
- package/templates/react-dev-typescript/src/vite-env.d.ts +1 -0
- package/templates/react-dev-typescript/tsconfig.app.json +27 -0
- package/templates/react-dev-typescript/tsconfig.json +11 -0
- package/templates/react-dev-typescript/tsconfig.node.json +13 -0
- package/templates/react-dev-typescript/vite.config.ts +7 -0
- package/templates/react-dev-webpack/.babelrc +7 -0
- package/templates/react-dev-webpack/__tests__/App.test.jsx +9 -0
- package/templates/react-dev-webpack/_gitignore +89 -0
- package/templates/react-dev-webpack/eslint.config.js +27 -0
- package/templates/react-dev-webpack/index.html +13 -0
- package/templates/react-dev-webpack/jest.config.cjs +13 -0
- package/templates/react-dev-webpack/jest.setup.js +1 -0
- package/templates/react-dev-webpack/package.json +45 -0
- package/templates/react-dev-webpack/postcss.config.mjs +5 -0
- package/templates/react-dev-webpack/src/App.jsx +22 -0
- package/templates/react-dev-webpack/src/index.css +1 -0
- package/templates/react-dev-webpack/src/main.jsx +10 -0
- package/templates/react-dev-webpack/webpack.config.cjs +43 -0
- package/templates/react-experimental/_gitignore +89 -0
- package/templates/react-experimental/farm.config.ts +5 -0
- package/templates/react-experimental/index.html +12 -0
- package/templates/react-experimental/oxlintrc.json +12 -0
- package/templates/react-experimental/package.json +28 -0
- package/templates/react-experimental/src/App.css +3 -0
- package/templates/react-experimental/src/App.jsx +20 -0
- package/templates/react-experimental/src/index.css +57 -0
- package/templates/react-experimental/src/main.jsx +10 -0
- package/templates/react-experimental/tsconfig.json +25 -0
- package/templates/react-experimental/tsconfig.node.json +11 -0
- package/templates/react-typescript/_gitignore +89 -0
- package/templates/react-typescript/eslint.config.js +26 -0
- package/templates/react-typescript/index.html +13 -0
- package/templates/react-typescript/package.json +29 -0
- package/templates/react-typescript/src/App.css +3 -0
- package/templates/react-typescript/src/App.tsx +18 -0
- package/templates/react-typescript/src/index.css +57 -0
- package/templates/react-typescript/src/main.tsx +10 -0
- package/templates/react-typescript/src/vite-env.d.ts +1 -0
- package/templates/react-typescript/tsconfig.app.json +27 -0
- package/templates/react-typescript/tsconfig.json +11 -0
- package/templates/react-typescript/tsconfig.node.json +13 -0
- package/templates/react-typescript/vite.config.ts +7 -0
- package/templates/react-webpack/.babelrc +6 -0
- package/templates/react-webpack/_gitignore +89 -0
- package/templates/react-webpack/index.html +13 -0
- package/templates/react-webpack/package.json +25 -0
- package/templates/react-webpack/src/App.css +3 -0
- package/templates/react-webpack/src/App.jsx +19 -0
- package/templates/react-webpack/src/index.css +57 -0
- package/templates/react-webpack/src/main.jsx +10 -0
- package/templates/react-webpack/webpack.config.js +43 -0
- package/templates/vanilla-js/_gitignore +89 -0
- package/templates/vanilla-js/index.html +17 -0
- package/templates/vanilla-js/index.js +11 -0
- package/templates/vanilla-js/package.json +14 -0
- package/templates/vanilla-js/style.css +60 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2024 Ivan Emmanuel Robles Alonso
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
<div align="center">
|
|
2
|
+
A quick way to start your web applications.
|
|
3
|
+
</p>
|
|
4
|
+
</div>
|
|
5
|
+
|
|
6
|
+
### Template List
|
|
7
|
+
| TEMPLATE | DESCRIPTION |
|
|
8
|
+
| :------- | :---------- |
|
|
9
|
+
| **vanilla-js** | Vanilla JS + Vite |
|
|
10
|
+
| **react** | React + Vite |
|
|
11
|
+
| **react-webpack** | React + Webpack |
|
|
12
|
+
| **react-typescript** | React + Vite + TypeScript + ESlint |
|
|
13
|
+
| **react-dev** | React + Vite + Tailwind CSS + ESlint + React Testing Library |
|
|
14
|
+
| **react-dev-typescript** | React + Typescript + Vite + Tailwind CSS + ESlint + React Testing Library |
|
|
15
|
+
| **react-dev-webpack** | React + Webpack + Tailwind CSS + ESlint + React Testing Library |
|
|
16
|
+
| **node-express** | NodeJS + Express + Sequelize + ESlint + Jest |
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
import Mt from"readline";import Rt from"events";import{fileURLToPath as Pt}from"node:url";import J from"node:path";import oe,{argv as hi}from"node:process";import ui from"node:os";import Ct from"node:tty";import{readFileSync as ai,writeFileSync as ci,existsSync as Dt,mkdirSync as di}from"fs";import{readdirSync as fi,lstatSync as pi,mkdirSync as mi,copyFileSync as gi}from"node:fs";function Et(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var le={},he,_t;function E(){if(_t)return he;_t=1;const{FORCE_COLOR:e,NODE_DISABLE_COLORS:r,TERM:i}=process.env,t={enabled:!r&&i!=="dumb"&&e!=="0",reset:s(0,0),bold:s(1,22),dim:s(2,22),italic:s(3,23),underline:s(4,24),inverse:s(7,27),hidden:s(8,28),strikethrough:s(9,29),black:s(30,39),red:s(31,39),green:s(32,39),yellow:s(33,39),blue:s(34,39),magenta:s(35,39),cyan:s(36,39),white:s(37,39),gray:s(90,39),grey:s(90,39),bgBlack:s(40,49),bgRed:s(41,49),bgGreen:s(42,49),bgYellow:s(43,49),bgBlue:s(44,49),bgMagenta:s(45,49),bgCyan:s(46,49),bgWhite:s(47,49)};function o(v,h){let a=0,n,d="",c="";for(;a<v.length;a++)n=v[a],d+=n.open,c+=n.close,h.includes(n.close)&&(h=h.replace(n.rgx,n.close+n.open));return d+h+c}function m(v,h){let a={has:v,keys:h};return a.reset=t.reset.bind(a),a.bold=t.bold.bind(a),a.dim=t.dim.bind(a),a.italic=t.italic.bind(a),a.underline=t.underline.bind(a),a.inverse=t.inverse.bind(a),a.hidden=t.hidden.bind(a),a.strikethrough=t.strikethrough.bind(a),a.black=t.black.bind(a),a.red=t.red.bind(a),a.green=t.green.bind(a),a.yellow=t.yellow.bind(a),a.blue=t.blue.bind(a),a.magenta=t.magenta.bind(a),a.cyan=t.cyan.bind(a),a.white=t.white.bind(a),a.gray=t.gray.bind(a),a.grey=t.grey.bind(a),a.bgBlack=t.bgBlack.bind(a),a.bgRed=t.bgRed.bind(a),a.bgGreen=t.bgGreen.bind(a),a.bgYellow=t.bgYellow.bind(a),a.bgBlue=t.bgBlue.bind(a),a.bgMagenta=t.bgMagenta.bind(a),a.bgCyan=t.bgCyan.bind(a),a.bgWhite=t.bgWhite.bind(a),a}function s(v,h){let a={open:`\x1B[${v}m`,close:`\x1B[${h}m`,rgx:new RegExp(`\\x1b\\[${h}m`,"g")};return function(n){return this!==void 0&&this.has!==void 0?(this.has.includes(v)||(this.has.push(v),this.keys.push(a)),n===void 0?this:t.enabled?o(this.keys,n+""):n+""):n===void 0?m([v],[a]):t.enabled?o([a],n+""):n+""}}return he=t,he}var ue,At;function vi(){return At||(At=1,ue=(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}}),ue}var ae,qt;function ce(){return qt||(qt=1,ae=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("|"),i=new RegExp(r,"g");return typeof e=="string"?e.replace(i,""):e}),ae}var de,It;function _(){if(It)return de;It=1;const e="\x1B",r=`${e}[`,i="\x07",t={to(s,v){return v?`${r}${v+1};${s+1}H`:`${r}${s+1}G`},move(s,v){let h="";return s<0?h+=`${r}${-s}D`:s>0&&(h+=`${r}${s}C`),v<0?h+=`${r}${-v}A`:v>0&&(h+=`${r}${v}B`),h},up:(s=1)=>`${r}${s}A`,down:(s=1)=>`${r}${s}B`,forward:(s=1)=>`${r}${s}C`,backward:(s=1)=>`${r}${s}D`,nextLine:(s=1)=>`${r}E`.repeat(s),prevLine:(s=1)=>`${r}F`.repeat(s),left:`${r}G`,hide:`${r}?25l`,show:`${r}?25h`,save:`${e}7`,restore:`${e}8`},o={up:(s=1)=>`${r}S`.repeat(s),down:(s=1)=>`${r}T`.repeat(s)},m={screen:`${r}2J`,up:(s=1)=>`${r}1J`.repeat(s),down:(s=1)=>`${r}J`.repeat(s),line:`${r}2K`,lineEnd:`${r}K`,lineStart:`${r}1K`,lines(s){let v="";for(let h=0;h<s;h++)v+=this.line+(h<s-1?t.up():"");return s&&(v+=t.left),v}};return de={cursor:t,scroll:o,erase:m,beep:i},de}var fe,jt;function bi(){if(jt)return fe;jt=1;function e(h,a){var n=typeof Symbol<"u"&&h[Symbol.iterator]||h["@@iterator"];if(!n){if(Array.isArray(h)||(n=r(h))||a){n&&(h=n);var d=0,c=function(){};return{s:c,n:function(){return d>=h.length?{done:!0}:{done:!1,value:h[d++]}},e:function(f){throw f},f:c}}throw new TypeError(`Invalid attempt to iterate non-iterable instance.
|
|
2
|
+
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}var l=!0,u=!1,y;return{s:function(){n=n.call(h)},n:function(){var f=n.next();return l=f.done,f},e:function(f){u=!0,y=f},f:function(){try{!l&&n.return!=null&&n.return()}finally{if(u)throw y}}}}function r(h,a){if(h){if(typeof h=="string")return i(h,a);var n=Object.prototype.toString.call(h).slice(8,-1);if(n==="Object"&&h.constructor&&(n=h.constructor.name),n==="Map"||n==="Set")return Array.from(h);if(n==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return i(h,a)}}function i(h,a){(a==null||a>h.length)&&(a=h.length);for(var n=0,d=new Array(a);n<a;n++)d[n]=h[n];return d}const t=ce(),o=_(),m=o.erase,s=o.cursor,v=h=>[...t(h)].length;return fe=function(h,a){if(!a)return m.line+s.to(0);let n=0;const d=h.split(/\r?\n/);var c=e(d),l;try{for(c.s();!(l=c.n()).done;){let u=l.value;n+=1+Math.floor(Math.max(v(u)-1,0)/a)}}catch(u){c.e(u)}finally{c.f()}return m.lines(n)},fe}var pe,Ft;function Nt(){if(Ft)return pe;Ft=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 pe=process.platform==="win32"?r:e,pe}var me,Lt;function yi(){if(Lt)return me;Lt=1;const e=E(),r=Nt(),i=Object.freeze({password:{scale:1,render:h=>"*".repeat(h.length)},emoji:{scale:2,render:h=>"\u{1F603}".repeat(h.length)},invisible:{scale:0,render:h=>""},default:{scale:1,render:h=>`${h}`}}),t=h=>i[h]||i.default,o=Object.freeze({aborted:e.red(r.cross),done:e.green(r.tick),exited:e.yellow(r.cross),default:e.cyan("?")});return me={styles:i,render:t,symbols:o,symbol:(h,a,n)=>a?o.aborted:n?o.exited:h?o.done:o.default,delimiter:h=>e.gray(h?r.ellipsis:r.pointerSmall),item:(h,a)=>e.gray(h?a?r.pointerSmall:"+":r.line)},me}var ge,Yt;function wi(){if(Yt)return ge;Yt=1;const e=ce();return ge=function(r,i){let t=String(e(r)||"").split(/\r?\n/);return i?t.map(o=>Math.ceil(o.length/i)).reduce((o,m)=>o+m):t.length},ge}var ve,kt;function xi(){return kt||(kt=1,ve=(e,r={})=>{const i=Number.isSafeInteger(parseInt(r.margin))?new Array(parseInt(r.margin)).fill(" ").join(""):r.margin||"",t=r.width;return(e||"").split(/\r?\n/g).map(o=>o.split(/\s+/g).reduce((m,s)=>(s.length+i.length>=t||m[m.length-1].length+s.length+1<t?m[m.length-1]+=` ${s}`:m.push(`${i}${s}`),m),[i]).join(`
|
|
3
|
+
`)).join(`
|
|
4
|
+
`)}),ve}var be,Bt;function Si(){return Bt||(Bt=1,be=(e,r,i)=>{i=i||r;let t=Math.min(r-i,e-Math.floor(i/2));t<0&&(t=0);let o=Math.min(t+i,r);return{startIndex:t,endIndex:o}}),be}var ye,Vt;function k(){return Vt||(Vt=1,ye={action:vi(),clear:bi(),style:yi(),strip:ce(),figures:Nt(),lines:wi(),wrap:xi(),entriesToDisplay:Si()}),ye}var we,Ht;function W(){if(Ht)return we;Ht=1;const e=Mt,r=k(),i=r.action,t=Rt,o=_(),m=o.beep,s=o.cursor,v=E();class h extends t{constructor(n={}){super(),this.firstRender=!0,this.in=n.stdin||process.stdin,this.out=n.stdout||process.stdout,this.onRender=(n.onRender||(()=>{})).bind(this);const d=e.createInterface({input:this.in,escapeCodeTimeout:50});e.emitKeypressEvents(this.in,d),this.in.isTTY&&this.in.setRawMode(!0);const c=["SelectPrompt","MultiselectPrompt"].indexOf(this.constructor.name)>-1,l=(u,y)=>{let g=i(y,c);g===!1?this._&&this._(u,y):typeof this[g]=="function"?this[g](y):this.bell()};this.close=()=>{this.out.write(s.show),this.in.removeListener("keypress",l),this.in.isTTY&&this.in.setRawMode(!1),d.close(),this.emit(this.aborted?"abort":this.exited?"exit":"submit",this.value),this.closed=!0},this.in.on("keypress",l)}fire(){this.emit("state",{value:this.value,aborted:!!this.aborted,exited:!!this.exited})}bell(){this.out.write(m)}render(){this.onRender(v),this.firstRender&&(this.firstRender=!1)}}return we=h,we}var xe,Ut;function $i(){if(Ut)return xe;Ut=1;function e(l,u,y,g,f,p,b){try{var w=l[p](b),x=w.value}catch(S){y(S);return}w.done?u(x):Promise.resolve(x).then(g,f)}function r(l){return function(){var u=this,y=arguments;return new Promise(function(g,f){var p=l.apply(u,y);function b(x){e(p,g,f,b,w,"next",x)}function w(x){e(p,g,f,b,w,"throw",x)}b(void 0)})}}const i=E(),t=W(),o=_(),m=o.erase,s=o.cursor,v=k(),h=v.style,a=v.clear,n=v.lines,d=v.figures;class c extends t{constructor(u={}){super(u),this.transform=h.render(u.style),this.scale=this.transform.scale,this.msg=u.message,this.initial=u.initial||"",this.validator=u.validate||(()=>!0),this.value="",this.errorMsg=u.error||"Please Enter A Valid Value",this.cursor=+!!this.initial,this.cursorOffset=0,this.clear=a("",this.out.columns),this.render()}set value(u){!u&&this.initial?(this.placeholder=!0,this.rendered=i.gray(this.transform.render(this.initial))):(this.placeholder=!1,this.rendered=this.transform.render(u)),this._value=u,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(`
|
|
5
|
+
`),this.close()}validate(){var u=this;return r(function*(){let y=yield u.validator(u.value);typeof y=="string"&&(u.errorMsg=y,y=!1),u.error=!y})()}submit(){var u=this;return r(function*(){if(u.value=u.value||u.initial,u.cursorOffset=0,u.cursor=u.rendered.length,yield u.validate(),u.error){u.red=!0,u.fire(),u.render();return}u.done=!0,u.aborted=!1,u.fire(),u.render(),u.out.write(`
|
|
6
|
+
`),u.close()})()}next(){if(!this.placeholder)return this.bell();this.value=this.initial,this.cursor=this.rendered.length,this.fire(),this.render()}moveCursor(u){this.placeholder||(this.cursor=this.cursor+u,this.cursorOffset+=u)}_(u,y){let g=this.value.slice(0,this.cursor),f=this.value.slice(this.cursor);this.value=`${g}${u}${f}`,this.red=!1,this.cursor=this.placeholder?0:g.length+1,this.render()}delete(){if(this.isCursorAtStart())return this.bell();let u=this.value.slice(0,this.cursor-1),y=this.value.slice(this.cursor);this.value=`${u}${y}`,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 u=this.value.slice(0,this.cursor),y=this.value.slice(this.cursor+1);this.value=`${u}${y}`,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(s.down(n(this.outputError,this.out.columns)-1)+a(this.outputError,this.out.columns)),this.out.write(a(this.outputText,this.out.columns))),super.render(),this.outputError="",this.outputText=[h.symbol(this.done,this.aborted),i.bold(this.msg),h.delimiter(this.done),this.red?i.red(this.rendered):this.rendered].join(" "),this.error&&(this.outputError+=this.errorMsg.split(`
|
|
7
|
+
`).reduce((u,y,g)=>u+`
|
|
8
|
+
${g?" ":d.pointerSmall} ${i.red().italic(y)}`,"")),this.out.write(m.line+s.to(0)+this.outputText+s.save+this.outputError+s.restore+s.move(this.cursorOffset,0)))}}return xe=c,xe}var Se,Gt;function Ti(){if(Gt)return Se;Gt=1;const e=E(),r=W(),i=k(),t=i.style,o=i.clear,m=i.figures,s=i.wrap,v=i.entriesToDisplay,h=_(),a=h.cursor;class n extends r{constructor(c={}){super(c),this.msg=c.message,this.hint=c.hint||"- Use arrow-keys. Return to submit.",this.warn=c.warn||"- This option is disabled",this.cursor=c.initial||0,this.choices=c.choices.map((l,u)=>(typeof l=="string"&&(l={title:l,value:u}),{title:l&&(l.title||l.value||l),value:l&&(l.value===void 0?u:l.value),description:l&&l.description,selected:l&&l.selected,disabled:l&&l.disabled})),this.optionsPerPage=c.optionsPerPage||10,this.value=(this.choices[this.cursor]||{}).value,this.clear=o("",this.out.columns),this.render()}moveCursor(c){this.cursor=c,this.value=this.choices[c].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(`
|
|
9
|
+
`),this.close()}submit(){this.selection.disabled?this.bell():(this.done=!0,this.aborted=!1,this.fire(),this.render(),this.out.write(`
|
|
10
|
+
`),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()}_(c,l){if(c===" ")return this.submit()}get selection(){return this.choices[this.cursor]}render(){if(this.closed)return;this.firstRender?this.out.write(a.hide):this.out.write(o(this.outputText,this.out.columns)),super.render();let c=v(this.cursor,this.choices.length,this.optionsPerPage),l=c.startIndex,u=c.endIndex;if(this.outputText=[t.symbol(this.done,this.aborted),e.bold(this.msg),t.delimiter(!1),this.done?this.selection.title:this.selection.disabled?e.yellow(this.warn):e.gray(this.hint)].join(" "),!this.done){this.outputText+=`
|
|
11
|
+
`;for(let y=l;y<u;y++){let g,f,p="",b=this.choices[y];y===l&&l>0?f=m.arrowUp:y===u-1&&u<this.choices.length?f=m.arrowDown:f=" ",b.disabled?(g=this.cursor===y?e.gray().underline(b.title):e.strikethrough().gray(b.title),f=(this.cursor===y?e.bold().gray(m.pointer)+" ":" ")+f):(g=this.cursor===y?e.cyan().underline(b.title):b.title,f=(this.cursor===y?e.cyan(m.pointer)+" ":" ")+f,b.description&&this.cursor===y&&(p=` - ${b.description}`,(f.length+g.length+p.length>=this.out.columns||b.description.split(/\r?\n/).length>1)&&(p=`
|
|
12
|
+
`+s(b.description,{margin:3,width:this.out.columns})))),this.outputText+=`${f} ${g}${e.gray(p)}
|
|
13
|
+
`}}this.out.write(this.outputText)}}return Se=n,Se}var $e,Jt;function Oi(){if(Jt)return $e;Jt=1;const e=E(),r=W(),i=k(),t=i.style,o=i.clear,m=_(),s=m.cursor,v=m.erase;class h extends r{constructor(n={}){super(n),this.msg=n.message,this.value=!!n.initial,this.active=n.active||"on",this.inactive=n.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(`
|
|
14
|
+
`),this.close()}submit(){this.done=!0,this.aborted=!1,this.fire(),this.render(),this.out.write(`
|
|
15
|
+
`),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()}_(n,d){if(n===" ")this.value=!this.value;else if(n==="1")this.value=!0;else if(n==="0")this.value=!1;else return this.bell();this.render()}render(){this.closed||(this.firstRender?this.out.write(s.hide):this.out.write(o(this.outputText,this.out.columns)),super.render(),this.outputText=[t.symbol(this.done,this.aborted),e.bold(this.msg),t.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(v.line+s.to(0)+this.outputText))}}return $e=h,$e}var Te,Wt;function U(){if(Wt)return Te;Wt=1;class e{constructor({token:i,date:t,parts:o,locales:m}){this.token=i,this.date=t||new Date,this.parts=o||[this],this.locales=m||{}}up(){}down(){}next(){const i=this.parts.indexOf(this);return this.parts.find((t,o)=>o>i&&t instanceof e)}setTo(i){}prev(){let i=[].concat(this.parts).reverse();const t=i.indexOf(this);return i.find((o,m)=>m>t&&o instanceof e)}toString(){return String(this.date)}}return Te=e,Te}var Oe,zt;function Mi(){if(zt)return Oe;zt=1;const e=U();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 Oe=r,Oe}var Me,Kt;function Ri(){if(Kt)return Me;Kt=1;const e=U(),r=t=>(t=t%10,t===1?"st":t===2?"nd":t===3?"rd":"th");class i extends e{constructor(o={}){super(o)}up(){this.date.setDate(this.date.getDate()+1)}down(){this.date.setDate(this.date.getDate()-1)}setTo(o){this.date.setDate(parseInt(o.substr(-2)))}toString(){let o=this.date.getDate(),m=this.date.getDay();return this.token==="DD"?String(o).padStart(2,"0"):this.token==="Do"?o+r(o):this.token==="d"?m+1:this.token==="ddd"?this.locales.weekdaysShort[m]:this.token==="dddd"?this.locales.weekdays[m]:o}}return Me=i,Me}var Re,Zt;function Pi(){if(Zt)return Re;Zt=1;const e=U();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 Re=r,Re}var Pe,Xt;function Ci(){if(Xt)return Pe;Xt=1;const e=U();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 Pe=r,Pe}var Ce,Qt;function Di(){if(Qt)return Ce;Qt=1;const e=U();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 Ce=r,Ce}var De,er;function Ei(){if(er)return De;er=1;const e=U();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(),o=this.token.length;return o===2?String(t+1).padStart(2,"0"):o===3?this.locales.monthsShort[t]:o===4?this.locales.months[t]:String(t+1)}}return De=r,De}var Ee,tr;function _i(){if(tr)return Ee;tr=1;const e=U();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 Ee=r,Ee}var _e,rr;function Ai(){if(rr)return _e;rr=1;const e=U();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 _e=r,_e}var Ae,ir;function qi(){return ir||(ir=1,Ae={DatePart:U(),Meridiem:Mi(),Day:Ri(),Hours:Pi(),Milliseconds:Ci(),Minutes:Di(),Month:Ei(),Seconds:_i(),Year:Ai()}),Ae}var qe,sr;function Ii(){if(sr)return qe;sr=1;function e($,O,P,F,A,I,Y){try{var N=$[I](Y),j=N.value}catch(X){P(X);return}N.done?O(j):Promise.resolve(j).then(F,A)}function r($){return function(){var O=this,P=arguments;return new Promise(function(F,A){var I=$.apply(O,P);function Y(j){e(I,F,A,Y,N,"next",j)}function N(j){e(I,F,A,Y,N,"throw",j)}Y(void 0)})}}const i=E(),t=W(),o=k(),m=o.style,s=o.clear,v=o.figures,h=_(),a=h.erase,n=h.cursor,d=qi(),c=d.DatePart,l=d.Meridiem,u=d.Day,y=d.Hours,g=d.Milliseconds,f=d.Minutes,p=d.Month,b=d.Seconds,w=d.Year,x=/\\(.)|"((?:\\["\\]|[^"])+)"|(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,S={1:({token:$})=>$.replace(/\\(.)/g,"$1"),2:$=>new u($),3:$=>new p($),4:$=>new w($),5:$=>new l($),6:$=>new y($),7:$=>new f($),8:$=>new b($),9:$=>new g($)},T={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 t{constructor(O={}){super(O),this.msg=O.message,this.cursor=0,this.typed="",this.locales=Object.assign(T,O.locales),this._date=O.initial||new Date,this.errorMsg=O.error||"Please Enter A Valid Value",this.validator=O.validate||(()=>!0),this.mask=O.mask||"YYYY-MM-DD HH:mm:ss",this.clear=s("",this.out.columns),this.render()}get value(){return this.date}get date(){return this._date}set date(O){O&&this._date.setTime(O.getTime())}set mask(O){let P;for(this.parts=[];P=x.exec(O);){let A=P.shift(),I=P.findIndex(Y=>Y!=null);this.parts.push(I in S?S[I]({token:P[I]||A,date:this.date,parts:this.parts,locales:this.locales}):P[I]||A)}let F=this.parts.reduce((A,I)=>(typeof I=="string"&&typeof A[A.length-1]=="string"?A[A.length-1]+=I:A.push(I),A),[]);this.parts.splice(0),this.parts.push(...F),this.reset()}moveCursor(O){this.typed="",this.cursor=O,this.fire()}reset(){this.moveCursor(this.parts.findIndex(O=>O instanceof c)),this.fire(),this.render()}exit(){this.abort()}abort(){this.done=this.aborted=!0,this.error=!1,this.fire(),this.render(),this.out.write(`
|
|
16
|
+
`),this.close()}validate(){var O=this;return r(function*(){let P=yield O.validator(O.value);typeof P=="string"&&(O.errorMsg=P,P=!1),O.error=!P})()}submit(){var O=this;return r(function*(){if(yield O.validate(),O.error){O.color="red",O.fire(),O.render();return}O.done=!0,O.aborted=!1,O.fire(),O.render(),O.out.write(`
|
|
17
|
+
`),O.close()})()}up(){this.typed="",this.parts[this.cursor].up(),this.render()}down(){this.typed="",this.parts[this.cursor].down(),this.render()}left(){let O=this.parts[this.cursor].prev();if(O==null)return this.bell();this.moveCursor(this.parts.indexOf(O)),this.render()}right(){let O=this.parts[this.cursor].next();if(O==null)return this.bell();this.moveCursor(this.parts.indexOf(O)),this.render()}next(){let O=this.parts[this.cursor].next();this.moveCursor(O?this.parts.indexOf(O):this.parts.findIndex(P=>P instanceof c)),this.render()}_(O){/\d/.test(O)&&(this.typed+=O,this.parts[this.cursor].setTo(this.typed),this.render())}render(){this.closed||(this.firstRender?this.out.write(n.hide):this.out.write(s(this.outputText,this.out.columns)),super.render(),this.outputText=[m.symbol(this.done,this.aborted),i.bold(this.msg),m.delimiter(!1),this.parts.reduce((O,P,F)=>O.concat(F===this.cursor&&!this.done?i.cyan().underline(P.toString()):P),[]).join("")].join(" "),this.error&&(this.outputText+=this.errorMsg.split(`
|
|
18
|
+
`).reduce((O,P,F)=>O+`
|
|
19
|
+
${F?" ":v.pointerSmall} ${i.red().italic(P)}`,"")),this.out.write(a.line+n.to(0)+this.outputText))}}return qe=M,qe}var Ie,nr;function ji(){if(nr)return Ie;nr=1;function e(g,f,p,b,w,x,S){try{var T=g[x](S),M=T.value}catch($){p($);return}T.done?f(M):Promise.resolve(M).then(b,w)}function r(g){return function(){var f=this,p=arguments;return new Promise(function(b,w){var x=g.apply(f,p);function S(M){e(x,b,w,S,T,"next",M)}function T(M){e(x,b,w,S,T,"throw",M)}S(void 0)})}}const i=E(),t=W(),o=_(),m=o.cursor,s=o.erase,v=k(),h=v.style,a=v.figures,n=v.clear,d=v.lines,c=/[0-9]/,l=g=>g!==void 0,u=(g,f)=>{let p=Math.pow(10,f);return Math.round(g*p)/p};class y extends t{constructor(f={}){super(f),this.transform=h.render(f.style),this.msg=f.message,this.initial=l(f.initial)?f.initial:"",this.float=!!f.float,this.round=f.round||2,this.inc=f.increment||1,this.min=l(f.min)?f.min:-1/0,this.max=l(f.max)?f.max:1/0,this.errorMsg=f.error||"Please Enter A Valid Value",this.validator=f.validate||(()=>!0),this.color="cyan",this.value="",this.typed="",this.lastHit=0,this.render()}set value(f){!f&&f!==0?(this.placeholder=!0,this.rendered=i.gray(this.transform.render(`${this.initial}`)),this._value=""):(this.placeholder=!1,this.rendered=this.transform.render(`${u(f,this.round)}`),this._value=u(f,this.round)),this.fire()}get value(){return this._value}parse(f){return this.float?parseFloat(f):parseInt(f)}valid(f){return f==="-"||f==="."&&this.float||c.test(f)}reset(){this.typed="",this.value="",this.fire(),this.render()}exit(){this.abort()}abort(){let f=this.value;this.value=f!==""?f:this.initial,this.done=this.aborted=!0,this.error=!1,this.fire(),this.render(),this.out.write(`
|
|
20
|
+
`),this.close()}validate(){var f=this;return r(function*(){let p=yield f.validator(f.value);typeof p=="string"&&(f.errorMsg=p,p=!1),f.error=!p})()}submit(){var f=this;return r(function*(){if(yield f.validate(),f.error){f.color="red",f.fire(),f.render();return}let p=f.value;f.value=p!==""?p:f.initial,f.done=!0,f.aborted=!1,f.error=!1,f.fire(),f.render(),f.out.write(`
|
|
21
|
+
`),f.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 f=this.value.toString();if(f.length===0)return this.bell();this.value=this.parse(f=f.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()}_(f,p){if(!this.valid(f))return this.bell();const b=Date.now();if(b-this.lastHit>1e3&&(this.typed=""),this.typed+=f,this.lastHit=b,this.color="cyan",f===".")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(m.down(d(this.outputError,this.out.columns)-1)+n(this.outputError,this.out.columns)),this.out.write(n(this.outputText,this.out.columns))),super.render(),this.outputError="",this.outputText=[h.symbol(this.done,this.aborted),i.bold(this.msg),h.delimiter(this.done),!this.done||!this.done&&!this.placeholder?i[this.color]().underline(this.rendered):this.rendered].join(" "),this.error&&(this.outputError+=this.errorMsg.split(`
|
|
22
|
+
`).reduce((f,p,b)=>f+`
|
|
23
|
+
${b?" ":a.pointerSmall} ${i.red().italic(p)}`,"")),this.out.write(s.line+m.to(0)+this.outputText+m.save+this.outputError+m.restore))}}return Ie=y,Ie}var je,or;function lr(){if(or)return je;or=1;const e=E(),r=_(),i=r.cursor,t=W(),o=k(),m=o.clear,s=o.figures,v=o.style,h=o.wrap,a=o.entriesToDisplay;class n extends t{constructor(c={}){super(c),this.msg=c.message,this.cursor=c.cursor||0,this.scrollIndex=c.cursor||0,this.hint=c.hint||"",this.warn=c.warn||"- This option is disabled -",this.minSelected=c.min,this.showMinError=!1,this.maxChoices=c.max,this.instructions=c.instructions,this.optionsPerPage=c.optionsPerPage||10,this.value=c.choices.map((l,u)=>(typeof l=="string"&&(l={title:l,value:u}),{title:l&&(l.title||l.value||l),description:l&&l.description,value:l&&(l.value===void 0?u:l.value),selected:l&&l.selected,disabled:l&&l.disabled})),this.clear=m("",this.out.columns),c.overrideRender||this.render()}reset(){this.value.map(c=>!c.selected),this.cursor=0,this.fire(),this.render()}selected(){return this.value.filter(c=>c.selected)}exit(){this.abort()}abort(){this.done=this.aborted=!0,this.fire(),this.render(),this.out.write(`
|
|
24
|
+
`),this.close()}submit(){const c=this.value.filter(l=>l.selected);this.minSelected&&c.length<this.minSelected?(this.showMinError=!0,this.render()):(this.done=!0,this.aborted=!1,this.fire(),this.render(),this.out.write(`
|
|
25
|
+
`),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(c=>c.selected).length>=this.maxChoices)return this.bell();this.value[this.cursor].selected=!0,this.render()}handleSpaceToggle(){const c=this.value[this.cursor];if(c.selected)c.selected=!1,this.render();else{if(c.disabled||this.value.filter(l=>l.selected).length>=this.maxChoices)return this.bell();c.selected=!0,this.render()}}toggleAll(){if(this.maxChoices!==void 0||this.value[this.cursor].disabled)return this.bell();const c=!this.value[this.cursor].selected;this.value.filter(l=>!l.disabled).forEach(l=>l.selected=c),this.render()}_(c,l){if(c===" ")this.handleSpaceToggle();else if(c==="a")this.toggleAll();else return this.bell()}renderInstructions(){return this.instructions===void 0||this.instructions?typeof this.instructions=="string"?this.instructions:`
|
|
26
|
+
Instructions:
|
|
27
|
+
${s.arrowUp}/${s.arrowDown}: Highlight option
|
|
28
|
+
${s.arrowLeft}/${s.arrowRight}/[space]: Toggle selection
|
|
29
|
+
`+(this.maxChoices===void 0?` a: Toggle all
|
|
30
|
+
`:"")+" enter/return: Complete answer":""}renderOption(c,l,u,y){const g=(l.selected?e.green(s.radioOn):s.radioOff)+" "+y+" ";let f,p;return l.disabled?f=c===u?e.gray().underline(l.title):e.strikethrough().gray(l.title):(f=c===u?e.cyan().underline(l.title):l.title,c===u&&l.description&&(p=` - ${l.description}`,(g.length+f.length+p.length>=this.out.columns||l.description.split(/\r?\n/).length>1)&&(p=`
|
|
31
|
+
`+h(l.description,{margin:g.length,width:this.out.columns})))),g+f+e.gray(p||"")}paginateOptions(c){if(c.length===0)return e.red("No matches for this query.");let l=a(this.cursor,c.length,this.optionsPerPage),u=l.startIndex,y=l.endIndex,g,f=[];for(let p=u;p<y;p++)p===u&&u>0?g=s.arrowUp:p===y-1&&y<c.length?g=s.arrowDown:g=" ",f.push(this.renderOption(this.cursor,c[p],p,g));return`
|
|
32
|
+
`+f.join(`
|
|
33
|
+
`)}renderOptions(c){return this.done?"":this.paginateOptions(c)}renderDoneOrInstructions(){if(this.done)return this.value.filter(l=>l.selected).map(l=>l.title).join(", ");const c=[e.gray(this.hint),this.renderInstructions()];return this.value[this.cursor].disabled&&c.push(e.yellow(this.warn)),c.join(" ")}render(){if(this.closed)return;this.firstRender&&this.out.write(i.hide),super.render();let c=[v.symbol(this.done,this.aborted),e.bold(this.msg),v.delimiter(!1),this.renderDoneOrInstructions()].join(" ");this.showMinError&&(c+=e.red(`You must select a minimum of ${this.minSelected} choices.`),this.showMinError=!1),c+=this.renderOptions(this.value),this.out.write(this.clear+c),this.clear=m(c,this.out.columns)}}return je=n,je}var Fe,hr;function Fi(){if(hr)return Fe;hr=1;function e(f,p,b,w,x,S,T){try{var M=f[S](T),$=M.value}catch(O){b(O);return}M.done?p($):Promise.resolve($).then(w,x)}function r(f){return function(){var p=this,b=arguments;return new Promise(function(w,x){var S=f.apply(p,b);function T($){e(S,w,x,T,M,"next",$)}function M($){e(S,w,x,T,M,"throw",$)}T(void 0)})}}const i=E(),t=W(),o=_(),m=o.erase,s=o.cursor,v=k(),h=v.style,a=v.clear,n=v.figures,d=v.wrap,c=v.entriesToDisplay,l=(f,p)=>f[p]&&(f[p].value||f[p].title||f[p]),u=(f,p)=>f[p]&&(f[p].title||f[p].value||f[p]),y=(f,p)=>{const b=f.findIndex(w=>w.value===p||w.title===p);return b>-1?b:void 0};class g extends t{constructor(p={}){super(p),this.msg=p.message,this.suggest=p.suggest,this.choices=p.choices,this.initial=typeof p.initial=="number"?p.initial:y(p.choices,p.initial),this.select=this.initial||p.cursor||0,this.i18n={noMatches:p.noMatches||"no matches found"},this.fallback=p.fallback||this.initial,this.clearFirst=p.clearFirst||!1,this.suggestions=[],this.input="",this.limit=p.limit||10,this.cursor=0,this.transform=h.render(p.style),this.scale=this.transform.scale,this.render=this.render.bind(this),this.complete=this.complete.bind(this),this.clear=a("",this.out.columns),this.complete(this.render),this.render()}set fallback(p){this._fb=Number.isSafeInteger(parseInt(p))?parseInt(p):p}get fallback(){let p;return typeof this._fb=="number"?p=this.choices[this._fb]:typeof this._fb=="string"&&(p={title:this._fb}),p||this._fb||{title:this.i18n.noMatches}}moveSelect(p){this.select=p,this.suggestions.length>0?this.value=l(this.suggestions,p):this.value=this.fallback.value,this.fire()}complete(p){var b=this;return r(function*(){const w=b.completing=b.suggest(b.input,b.choices),x=yield w;if(b.completing!==w)return;b.suggestions=x.map((T,M,$)=>({title:u($,M),value:l($,M),description:T.description})),b.completing=!1;const S=Math.max(x.length-1,0);b.moveSelect(Math.min(S,b.select)),p&&p()})()}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(`
|
|
34
|
+
`),this.close())}abort(){this.done=this.aborted=!0,this.exited=!1,this.fire(),this.render(),this.out.write(`
|
|
35
|
+
`),this.close()}submit(){this.done=!0,this.aborted=this.exited=!1,this.fire(),this.render(),this.out.write(`
|
|
36
|
+
`),this.close()}_(p,b){let w=this.input.slice(0,this.cursor),x=this.input.slice(this.cursor);this.input=`${w}${p}${x}`,this.cursor=w.length+1,this.complete(this.render),this.render()}delete(){if(this.cursor===0)return this.bell();let p=this.input.slice(0,this.cursor-1),b=this.input.slice(this.cursor);this.input=`${p}${b}`,this.complete(this.render),this.cursor=this.cursor-1,this.render()}deleteForward(){if(this.cursor*this.scale>=this.rendered.length)return this.bell();let p=this.input.slice(0,this.cursor),b=this.input.slice(this.cursor+1);this.input=`${p}${b}`,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(p,b,w,x){let S,T=w?n.arrowUp:x?n.arrowDown:" ",M=b?i.cyan().underline(p.title):p.title;return T=(b?i.cyan(n.pointer)+" ":" ")+T,p.description&&(S=` - ${p.description}`,(T.length+M.length+S.length>=this.out.columns||p.description.split(/\r?\n/).length>1)&&(S=`
|
|
37
|
+
`+d(p.description,{margin:3,width:this.out.columns}))),T+" "+M+i.gray(S||"")}render(){if(this.closed)return;this.firstRender?this.out.write(s.hide):this.out.write(a(this.outputText,this.out.columns)),super.render();let p=c(this.select,this.choices.length,this.limit),b=p.startIndex,w=p.endIndex;if(this.outputText=[h.symbol(this.done,this.aborted,this.exited),i.bold(this.msg),h.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 x=this.suggestions.slice(b,w).map((S,T)=>this.renderOption(S,this.select===T+b,T===0&&b>0,T+b===w-1&&w<this.choices.length)).join(`
|
|
38
|
+
`);this.outputText+=`
|
|
39
|
+
`+(x||i.gray(this.fallback.title))}this.out.write(m.line+s.to(0)+this.outputText)}}return Fe=g,Fe}var Ne,ur;function Ni(){if(ur)return Ne;ur=1;const e=E(),r=_(),i=r.cursor,t=lr(),o=k(),m=o.clear,s=o.style,v=o.figures;class h extends t{constructor(n={}){n.overrideRender=!0,super(n),this.inputValue="",this.clear=m("",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(n=>n.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 n=this.filteredOptions[this.cursor];this.filteredOptions=this.value.filter(c=>this.inputValue?!!(typeof c.title=="string"&&c.title.toLowerCase().includes(this.inputValue.toLowerCase())||typeof c.value=="string"&&c.value.toLowerCase().includes(this.inputValue.toLowerCase())):!0);const d=this.filteredOptions.findIndex(c=>c===n);this.cursor=d<0?0:d,this.render()}handleSpaceToggle(){const n=this.filteredOptions[this.cursor];if(n.selected)n.selected=!1,this.render();else{if(n.disabled||this.value.filter(d=>d.selected).length>=this.maxChoices)return this.bell();n.selected=!0,this.render()}}handleInputChange(n){this.inputValue=this.inputValue+n,this.updateFilteredOptions()}_(n,d){n===" "?this.handleSpaceToggle():this.handleInputChange(n)}renderInstructions(){return this.instructions===void 0||this.instructions?typeof this.instructions=="string"?this.instructions:`
|
|
40
|
+
Instructions:
|
|
41
|
+
${v.arrowUp}/${v.arrowDown}: Highlight option
|
|
42
|
+
${v.arrowLeft}/${v.arrowRight}/[space]: Toggle selection
|
|
43
|
+
[a,b,c]/delete: Filter choices
|
|
44
|
+
enter/return: Complete answer
|
|
45
|
+
`:""}renderCurrentInput(){return`
|
|
46
|
+
Filtered results for: ${this.inputValue?this.inputValue:e.gray("Enter something to filter")}
|
|
47
|
+
`}renderOption(n,d,c){let l;return d.disabled?l=n===c?e.gray().underline(d.title):e.strikethrough().gray(d.title):l=n===c?e.cyan().underline(d.title):d.title,(d.selected?e.green(v.radioOn):v.radioOff)+" "+l}renderDoneOrInstructions(){if(this.done)return this.value.filter(d=>d.selected).map(d=>d.title).join(", ");const n=[e.gray(this.hint),this.renderInstructions(),this.renderCurrentInput()];return this.filteredOptions.length&&this.filteredOptions[this.cursor].disabled&&n.push(e.yellow(this.warn)),n.join(" ")}render(){if(this.closed)return;this.firstRender&&this.out.write(i.hide),super.render();let n=[s.symbol(this.done,this.aborted),e.bold(this.msg),s.delimiter(!1),this.renderDoneOrInstructions()].join(" ");this.showMinError&&(n+=e.red(`You must select a minimum of ${this.minSelected} choices.`),this.showMinError=!1),n+=this.renderOptions(this.filteredOptions),this.out.write(this.clear+n),this.clear=m(n,this.out.columns)}}return Ne=h,Ne}var Le,ar;function Li(){if(ar)return Le;ar=1;const e=E(),r=W(),i=k(),t=i.style,o=i.clear,m=_(),s=m.erase,v=m.cursor;class h extends r{constructor(n={}){super(n),this.msg=n.message,this.value=n.initial,this.initialValue=!!n.initial,this.yesMsg=n.yes||"yes",this.yesOption=n.yesOption||"(Y/n)",this.noMsg=n.no||"no",this.noOption=n.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(`
|
|
48
|
+
`),this.close()}submit(){this.value=this.value||!1,this.done=!0,this.aborted=!1,this.fire(),this.render(),this.out.write(`
|
|
49
|
+
`),this.close()}_(n,d){return n.toLowerCase()==="y"?(this.value=!0,this.submit()):n.toLowerCase()==="n"?(this.value=!1,this.submit()):this.bell()}render(){this.closed||(this.firstRender?this.out.write(v.hide):this.out.write(o(this.outputText,this.out.columns)),super.render(),this.outputText=[t.symbol(this.done,this.aborted),e.bold(this.msg),t.delimiter(this.done),this.done?this.value?this.yesMsg:this.noMsg:e.gray(this.initialValue?this.yesOption:this.noOption)].join(" "),this.out.write(s.line+v.to(0)+this.outputText))}}return Le=h,Le}var Ye,cr;function Yi(){return cr||(cr=1,Ye={TextPrompt:$i(),SelectPrompt:Ti(),TogglePrompt:Oi(),DatePrompt:Ii(),NumberPrompt:ji(),MultiselectPrompt:lr(),AutocompletePrompt:Fi(),AutocompleteMultiselectPrompt:Ni(),ConfirmPrompt:Li()}),Ye}var dr;function ki(){return dr||(dr=1,function(e){const r=e,i=Yi(),t=s=>s;function o(s,v,h={}){return new Promise((a,n)=>{const d=new i[s](v),c=h.onAbort||t,l=h.onSubmit||t,u=h.onExit||t;d.on("state",v.onState||t),d.on("submit",y=>a(l(y))),d.on("exit",y=>a(u(y))),d.on("abort",y=>n(c(y)))})}r.text=s=>o("TextPrompt",s),r.password=s=>(s.style="password",r.text(s)),r.invisible=s=>(s.style="invisible",r.text(s)),r.number=s=>o("NumberPrompt",s),r.date=s=>o("DatePrompt",s),r.confirm=s=>o("ConfirmPrompt",s),r.list=s=>{const v=s.separator||",";return o("TextPrompt",s,{onSubmit:h=>h.split(v).map(a=>a.trim())})},r.toggle=s=>o("TogglePrompt",s),r.select=s=>o("SelectPrompt",s),r.multiselect=s=>{s.choices=[].concat(s.choices||[]);const v=h=>h.filter(a=>a.selected).map(a=>a.value);return o("MultiselectPrompt",s,{onAbort:v,onSubmit:v})},r.autocompleteMultiselect=s=>{s.choices=[].concat(s.choices||[]);const v=h=>h.filter(a=>a.selected).map(a=>a.value);return o("AutocompleteMultiselectPrompt",s,{onAbort:v,onSubmit:v})};const m=(s,v)=>Promise.resolve(v.filter(h=>h.title.slice(0,s.length).toLowerCase()===s.toLowerCase()));r.autocomplete=s=>(s.suggest=s.suggest||m,s.choices=[].concat(s.choices||[]),o("AutocompletePrompt",s))}(le)),le}var ke,fr;function Bi(){if(fr)return ke;fr=1;function e(g,f){var p=Object.keys(g);if(Object.getOwnPropertySymbols){var b=Object.getOwnPropertySymbols(g);f&&(b=b.filter(function(w){return Object.getOwnPropertyDescriptor(g,w).enumerable})),p.push.apply(p,b)}return p}function r(g){for(var f=1;f<arguments.length;f++){var p=arguments[f]!=null?arguments[f]:{};f%2?e(Object(p),!0).forEach(function(b){i(g,b,p[b])}):Object.getOwnPropertyDescriptors?Object.defineProperties(g,Object.getOwnPropertyDescriptors(p)):e(Object(p)).forEach(function(b){Object.defineProperty(g,b,Object.getOwnPropertyDescriptor(p,b))})}return g}function i(g,f,p){return f in g?Object.defineProperty(g,f,{value:p,enumerable:!0,configurable:!0,writable:!0}):g[f]=p,g}function t(g,f){var p=typeof Symbol<"u"&&g[Symbol.iterator]||g["@@iterator"];if(!p){if(Array.isArray(g)||(p=o(g))||f){p&&(g=p);var b=0,w=function(){};return{s:w,n:function(){return b>=g.length?{done:!0}:{done:!1,value:g[b++]}},e:function($){throw $},f:w}}throw new TypeError(`Invalid attempt to iterate non-iterable instance.
|
|
50
|
+
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}var x=!0,S=!1,T;return{s:function(){p=p.call(g)},n:function(){var $=p.next();return x=$.done,$},e:function($){S=!0,T=$},f:function(){try{!x&&p.return!=null&&p.return()}finally{if(S)throw T}}}}function o(g,f){if(g){if(typeof g=="string")return m(g,f);var p=Object.prototype.toString.call(g).slice(8,-1);if(p==="Object"&&g.constructor&&(p=g.constructor.name),p==="Map"||p==="Set")return Array.from(g);if(p==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(p))return m(g,f)}}function m(g,f){(f==null||f>g.length)&&(f=g.length);for(var p=0,b=new Array(f);p<f;p++)b[p]=g[p];return b}function s(g,f,p,b,w,x,S){try{var T=g[x](S),M=T.value}catch($){p($);return}T.done?f(M):Promise.resolve(M).then(b,w)}function v(g){return function(){var f=this,p=arguments;return new Promise(function(b,w){var x=g.apply(f,p);function S(M){s(x,b,w,S,T,"next",M)}function T(M){s(x,b,w,S,T,"throw",M)}S(void 0)})}}const h=ki(),a=["suggest","format","onState","validate","onRender","type"],n=()=>{};function d(){return c.apply(this,arguments)}function c(){return c=v(function*(g=[],{onSubmit:f=n,onCancel:p=n}={}){const b={},w=d._override||{};g=[].concat(g);let x,S,T,M,$,O;const P=function(){var N=v(function*(j,X,Ot=!1){if(!(!Ot&&j.validate&&j.validate(X)!==!0))return j.format?yield j.format(X,b):X});return function(X,Ot){return N.apply(this,arguments)}}();var F=t(g),A;try{for(F.s();!(A=F.n()).done;){S=A.value;var I=S;if(M=I.name,$=I.type,typeof $=="function"&&($=yield $(x,r({},b),S),S.type=$),!!$){for(let N in S){if(a.includes(N))continue;let j=S[N];S[N]=typeof j=="function"?yield j(x,r({},b),O):j}if(O=S,typeof S.message!="string")throw new Error("prompt message is required");var Y=S;if(M=Y.name,$=Y.type,h[$]===void 0)throw new Error(`prompt type (${$}) is not defined`);if(w[S.name]!==void 0&&(x=yield P(S,w[S.name]),x!==void 0)){b[M]=x;continue}try{x=d._injected?l(d._injected,S.initial):yield h[$](S),b[M]=x=yield P(S,x,!0),T=yield f(S,x,b)}catch{T=!(yield p(S,b))}if(T)return b}}}catch(N){F.e(N)}finally{F.f()}return b}),c.apply(this,arguments)}function l(g,f){const p=g.shift();if(p instanceof Error)throw p;return p===void 0?f:p}function u(g){d._injected=(d._injected||[]).concat(g)}function y(g){d._override=Object.assign({},g)}return ke=Object.assign(d,{prompt:d,prompts:h,inject:u,override:y}),ke}var Be={},Ve,pr;function Vi(){return pr||(pr=1,Ve=(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}}),Ve}var He,mr;function Ue(){return mr||(mr=1,He=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("|"),i=new RegExp(r,"g");return typeof e=="string"?e.replace(i,""):e}),He}var Ge,gr;function Hi(){if(gr)return Ge;gr=1;const e=Ue(),{erase:r,cursor:i}=_(),t=o=>[...e(o)].length;return Ge=function(o,m){if(!m)return r.line+i.to(0);let s=0;const v=o.split(/\r?\n/);for(let h of v)s+=1+Math.floor(Math.max(t(h)-1,0)/m);return r.lines(s)},Ge}var Je,vr;function br(){if(vr)return Je;vr=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 Je=process.platform==="win32"?r:e,Je}var We,yr;function Ui(){if(yr)return We;yr=1;const e=E(),r=br(),i=Object.freeze({password:{scale:1,render:h=>"*".repeat(h.length)},emoji:{scale:2,render:h=>"\u{1F603}".repeat(h.length)},invisible:{scale:0,render:h=>""},default:{scale:1,render:h=>`${h}`}}),t=h=>i[h]||i.default,o=Object.freeze({aborted:e.red(r.cross),done:e.green(r.tick),exited:e.yellow(r.cross),default:e.cyan("?")});return We={styles:i,render:t,symbols:o,symbol:(h,a,n)=>a?o.aborted:n?o.exited:h?o.done:o.default,delimiter:h=>e.gray(h?r.ellipsis:r.pointerSmall),item:(h,a)=>e.gray(h?a?r.pointerSmall:"+":r.line)},We}var ze,wr;function Gi(){if(wr)return ze;wr=1;const e=Ue();return ze=function(r,i){let t=String(e(r)||"").split(/\r?\n/);return i?t.map(o=>Math.ceil(o.length/i)).reduce((o,m)=>o+m):t.length},ze}var Ke,xr;function Ji(){return xr||(xr=1,Ke=(e,r={})=>{const i=Number.isSafeInteger(parseInt(r.margin))?new Array(parseInt(r.margin)).fill(" ").join(""):r.margin||"",t=r.width;return(e||"").split(/\r?\n/g).map(o=>o.split(/\s+/g).reduce((m,s)=>(s.length+i.length>=t||m[m.length-1].length+s.length+1<t?m[m.length-1]+=` ${s}`:m.push(`${i}${s}`),m),[i]).join(`
|
|
51
|
+
`)).join(`
|
|
52
|
+
`)}),Ke}var Ze,Sr;function Wi(){return Sr||(Sr=1,Ze=(e,r,i)=>{i=i||r;let t=Math.min(r-i,e-Math.floor(i/2));t<0&&(t=0);let o=Math.min(t+i,r);return{startIndex:t,endIndex:o}}),Ze}var Xe,$r;function B(){return $r||($r=1,Xe={action:Vi(),clear:Hi(),style:Ui(),strip:Ue(),figures:br(),lines:Gi(),wrap:Ji(),entriesToDisplay:Wi()}),Xe}var Qe,Tr;function z(){if(Tr)return Qe;Tr=1;const e=Mt,{action:r}=B(),i=Rt,{beep:t,cursor:o}=_(),m=E();class s extends i{constructor(h={}){super(),this.firstRender=!0,this.in=h.stdin||process.stdin,this.out=h.stdout||process.stdout,this.onRender=(h.onRender||(()=>{})).bind(this);const a=e.createInterface({input:this.in,escapeCodeTimeout:50});e.emitKeypressEvents(this.in,a),this.in.isTTY&&this.in.setRawMode(!0);const n=["SelectPrompt","MultiselectPrompt"].indexOf(this.constructor.name)>-1,d=(c,l)=>{let u=r(l,n);u===!1?this._&&this._(c,l):typeof this[u]=="function"?this[u](l):this.bell()};this.close=()=>{this.out.write(o.show),this.in.removeListener("keypress",d),this.in.isTTY&&this.in.setRawMode(!1),a.close(),this.emit(this.aborted?"abort":this.exited?"exit":"submit",this.value),this.closed=!0},this.in.on("keypress",d)}fire(){this.emit("state",{value:this.value,aborted:!!this.aborted,exited:!!this.exited})}bell(){this.out.write(t)}render(){this.onRender(m),this.firstRender&&(this.firstRender=!1)}}return Qe=s,Qe}var et,Or;function zi(){if(Or)return et;Or=1;const e=E(),r=z(),{erase:i,cursor:t}=_(),{style:o,clear:m,lines:s,figures:v}=B();class h extends r{constructor(n={}){super(n),this.transform=o.render(n.style),this.scale=this.transform.scale,this.msg=n.message,this.initial=n.initial||"",this.validator=n.validate||(()=>!0),this.value="",this.errorMsg=n.error||"Please Enter A Valid Value",this.cursor=+!!this.initial,this.cursorOffset=0,this.clear=m("",this.out.columns),this.render()}set value(n){!n&&this.initial?(this.placeholder=!0,this.rendered=e.gray(this.transform.render(this.initial))):(this.placeholder=!1,this.rendered=this.transform.render(n)),this._value=n,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(`
|
|
53
|
+
`),this.close()}async validate(){let n=await this.validator(this.value);typeof n=="string"&&(this.errorMsg=n,n=!1),this.error=!n}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(`
|
|
54
|
+
`),this.close()}next(){if(!this.placeholder)return this.bell();this.value=this.initial,this.cursor=this.rendered.length,this.fire(),this.render()}moveCursor(n){this.placeholder||(this.cursor=this.cursor+n,this.cursorOffset+=n)}_(n,d){let c=this.value.slice(0,this.cursor),l=this.value.slice(this.cursor);this.value=`${c}${n}${l}`,this.red=!1,this.cursor=this.placeholder?0:c.length+1,this.render()}delete(){if(this.isCursorAtStart())return this.bell();let n=this.value.slice(0,this.cursor-1),d=this.value.slice(this.cursor);this.value=`${n}${d}`,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 n=this.value.slice(0,this.cursor),d=this.value.slice(this.cursor+1);this.value=`${n}${d}`,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(s(this.outputError,this.out.columns)-1)+m(this.outputError,this.out.columns)),this.out.write(m(this.outputText,this.out.columns))),super.render(),this.outputError="",this.outputText=[o.symbol(this.done,this.aborted),e.bold(this.msg),o.delimiter(this.done),this.red?e.red(this.rendered):this.rendered].join(" "),this.error&&(this.outputError+=this.errorMsg.split(`
|
|
55
|
+
`).reduce((n,d,c)=>n+`
|
|
56
|
+
${c?" ":v.pointerSmall} ${e.red().italic(d)}`,"")),this.out.write(i.line+t.to(0)+this.outputText+t.save+this.outputError+t.restore+t.move(this.cursorOffset,0)))}}return et=h,et}var tt,Mr;function Ki(){if(Mr)return tt;Mr=1;const e=E(),r=z(),{style:i,clear:t,figures:o,wrap:m,entriesToDisplay:s}=B(),{cursor:v}=_();class h extends r{constructor(n={}){super(n),this.msg=n.message,this.hint=n.hint||"- Use arrow-keys. Return to submit.",this.warn=n.warn||"- This option is disabled",this.cursor=n.initial||0,this.choices=n.choices.map((d,c)=>(typeof d=="string"&&(d={title:d,value:c}),{title:d&&(d.title||d.value||d),value:d&&(d.value===void 0?c:d.value),description:d&&d.description,selected:d&&d.selected,disabled:d&&d.disabled})),this.optionsPerPage=n.optionsPerPage||10,this.value=(this.choices[this.cursor]||{}).value,this.clear=t("",this.out.columns),this.render()}moveCursor(n){this.cursor=n,this.value=this.choices[n].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(`
|
|
57
|
+
`),this.close()}submit(){this.selection.disabled?this.bell():(this.done=!0,this.aborted=!1,this.fire(),this.render(),this.out.write(`
|
|
58
|
+
`),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()}_(n,d){if(n===" ")return this.submit()}get selection(){return this.choices[this.cursor]}render(){if(this.closed)return;this.firstRender?this.out.write(v.hide):this.out.write(t(this.outputText,this.out.columns)),super.render();let{startIndex:n,endIndex:d}=s(this.cursor,this.choices.length,this.optionsPerPage);if(this.outputText=[i.symbol(this.done,this.aborted),e.bold(this.msg),i.delimiter(!1),this.done?this.selection.title:this.selection.disabled?e.yellow(this.warn):e.gray(this.hint)].join(" "),!this.done){this.outputText+=`
|
|
59
|
+
`;for(let c=n;c<d;c++){let l,u,y="",g=this.choices[c];c===n&&n>0?u=o.arrowUp:c===d-1&&d<this.choices.length?u=o.arrowDown:u=" ",g.disabled?(l=this.cursor===c?e.gray().underline(g.title):e.strikethrough().gray(g.title),u=(this.cursor===c?e.bold().gray(o.pointer)+" ":" ")+u):(l=this.cursor===c?e.cyan().underline(g.title):g.title,u=(this.cursor===c?e.cyan(o.pointer)+" ":" ")+u,g.description&&this.cursor===c&&(y=` - ${g.description}`,(u.length+l.length+y.length>=this.out.columns||g.description.split(/\r?\n/).length>1)&&(y=`
|
|
60
|
+
`+m(g.description,{margin:3,width:this.out.columns})))),this.outputText+=`${u} ${l}${e.gray(y)}
|
|
61
|
+
`}}this.out.write(this.outputText)}}return tt=h,tt}var rt,Rr;function Zi(){if(Rr)return rt;Rr=1;const e=E(),r=z(),{style:i,clear:t}=B(),{cursor:o,erase:m}=_();class s extends r{constructor(h={}){super(h),this.msg=h.message,this.value=!!h.initial,this.active=h.active||"on",this.inactive=h.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(`
|
|
62
|
+
`),this.close()}submit(){this.done=!0,this.aborted=!1,this.fire(),this.render(),this.out.write(`
|
|
63
|
+
`),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()}_(h,a){if(h===" ")this.value=!this.value;else if(h==="1")this.value=!0;else if(h==="0")this.value=!1;else return this.bell();this.render()}render(){this.closed||(this.firstRender?this.out.write(o.hide):this.out.write(t(this.outputText,this.out.columns)),super.render(),this.outputText=[i.symbol(this.done,this.aborted),e.bold(this.msg),i.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(m.line+o.to(0)+this.outputText))}}return rt=s,rt}var it,Pr;function G(){if(Pr)return it;Pr=1;class e{constructor({token:i,date:t,parts:o,locales:m}){this.token=i,this.date=t||new Date,this.parts=o||[this],this.locales=m||{}}up(){}down(){}next(){const i=this.parts.indexOf(this);return this.parts.find((t,o)=>o>i&&t instanceof e)}setTo(i){}prev(){let i=[].concat(this.parts).reverse();const t=i.indexOf(this);return i.find((o,m)=>m>t&&o instanceof e)}toString(){return String(this.date)}}return it=e,it}var st,Cr;function Xi(){if(Cr)return st;Cr=1;const e=G();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 st=r,st}var nt,Dr;function Qi(){if(Dr)return nt;Dr=1;const e=G(),r=t=>(t=t%10,t===1?"st":t===2?"nd":t===3?"rd":"th");class i extends e{constructor(o={}){super(o)}up(){this.date.setDate(this.date.getDate()+1)}down(){this.date.setDate(this.date.getDate()-1)}setTo(o){this.date.setDate(parseInt(o.substr(-2)))}toString(){let o=this.date.getDate(),m=this.date.getDay();return this.token==="DD"?String(o).padStart(2,"0"):this.token==="Do"?o+r(o):this.token==="d"?m+1:this.token==="ddd"?this.locales.weekdaysShort[m]:this.token==="dddd"?this.locales.weekdays[m]:o}}return nt=i,nt}var ot,Er;function es(){if(Er)return ot;Er=1;const e=G();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 ot=r,ot}var lt,_r;function ts(){if(_r)return lt;_r=1;const e=G();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 lt=r,lt}var ht,Ar;function rs(){if(Ar)return ht;Ar=1;const e=G();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 ht=r,ht}var ut,qr;function is(){if(qr)return ut;qr=1;const e=G();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(),o=this.token.length;return o===2?String(t+1).padStart(2,"0"):o===3?this.locales.monthsShort[t]:o===4?this.locales.months[t]:String(t+1)}}return ut=r,ut}var at,Ir;function ss(){if(Ir)return at;Ir=1;const e=G();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 at=r,at}var ct,jr;function ns(){if(jr)return ct;jr=1;const e=G();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 ct=r,ct}var dt,Fr;function os(){return Fr||(Fr=1,dt={DatePart:G(),Meridiem:Xi(),Day:Qi(),Hours:es(),Milliseconds:ts(),Minutes:rs(),Month:is(),Seconds:ss(),Year:ns()}),dt}var ft,Nr;function ls(){if(Nr)return ft;Nr=1;const e=E(),r=z(),{style:i,clear:t,figures:o}=B(),{erase:m,cursor:s}=_(),{DatePart:v,Meridiem:h,Day:a,Hours:n,Milliseconds:d,Minutes:c,Month:l,Seconds:u,Year:y}=os(),g=/\\(.)|"((?:\\["\\]|[^"])+)"|(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,f={1:({token:w})=>w.replace(/\\(.)/g,"$1"),2:w=>new a(w),3:w=>new l(w),4:w=>new y(w),5:w=>new h(w),6:w=>new n(w),7:w=>new c(w),8:w=>new u(w),9:w=>new d(w)},p={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 b extends r{constructor(x={}){super(x),this.msg=x.message,this.cursor=0,this.typed="",this.locales=Object.assign(p,x.locales),this._date=x.initial||new Date,this.errorMsg=x.error||"Please Enter A Valid Value",this.validator=x.validate||(()=>!0),this.mask=x.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(x){x&&this._date.setTime(x.getTime())}set mask(x){let S;for(this.parts=[];S=g.exec(x);){let M=S.shift(),$=S.findIndex(O=>O!=null);this.parts.push($ in f?f[$]({token:S[$]||M,date:this.date,parts:this.parts,locales:this.locales}):S[$]||M)}let T=this.parts.reduce((M,$)=>(typeof $=="string"&&typeof M[M.length-1]=="string"?M[M.length-1]+=$:M.push($),M),[]);this.parts.splice(0),this.parts.push(...T),this.reset()}moveCursor(x){this.typed="",this.cursor=x,this.fire()}reset(){this.moveCursor(this.parts.findIndex(x=>x instanceof v)),this.fire(),this.render()}exit(){this.abort()}abort(){this.done=this.aborted=!0,this.error=!1,this.fire(),this.render(),this.out.write(`
|
|
64
|
+
`),this.close()}async validate(){let x=await this.validator(this.value);typeof x=="string"&&(this.errorMsg=x,x=!1),this.error=!x}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(`
|
|
65
|
+
`),this.close()}up(){this.typed="",this.parts[this.cursor].up(),this.render()}down(){this.typed="",this.parts[this.cursor].down(),this.render()}left(){let x=this.parts[this.cursor].prev();if(x==null)return this.bell();this.moveCursor(this.parts.indexOf(x)),this.render()}right(){let x=this.parts[this.cursor].next();if(x==null)return this.bell();this.moveCursor(this.parts.indexOf(x)),this.render()}next(){let x=this.parts[this.cursor].next();this.moveCursor(x?this.parts.indexOf(x):this.parts.findIndex(S=>S instanceof v)),this.render()}_(x){/\d/.test(x)&&(this.typed+=x,this.parts[this.cursor].setTo(this.typed),this.render())}render(){this.closed||(this.firstRender?this.out.write(s.hide):this.out.write(t(this.outputText,this.out.columns)),super.render(),this.outputText=[i.symbol(this.done,this.aborted),e.bold(this.msg),i.delimiter(!1),this.parts.reduce((x,S,T)=>x.concat(T===this.cursor&&!this.done?e.cyan().underline(S.toString()):S),[]).join("")].join(" "),this.error&&(this.outputText+=this.errorMsg.split(`
|
|
66
|
+
`).reduce((x,S,T)=>x+`
|
|
67
|
+
${T?" ":o.pointerSmall} ${e.red().italic(S)}`,"")),this.out.write(m.line+s.to(0)+this.outputText))}}return ft=b,ft}var pt,Lr;function hs(){if(Lr)return pt;Lr=1;const e=E(),r=z(),{cursor:i,erase:t}=_(),{style:o,figures:m,clear:s,lines:v}=B(),h=/[0-9]/,a=c=>c!==void 0,n=(c,l)=>{let u=Math.pow(10,l);return Math.round(c*u)/u};class d extends r{constructor(l={}){super(l),this.transform=o.render(l.style),this.msg=l.message,this.initial=a(l.initial)?l.initial:"",this.float=!!l.float,this.round=l.round||2,this.inc=l.increment||1,this.min=a(l.min)?l.min:-1/0,this.max=a(l.max)?l.max:1/0,this.errorMsg=l.error||"Please Enter A Valid Value",this.validator=l.validate||(()=>!0),this.color="cyan",this.value="",this.typed="",this.lastHit=0,this.render()}set value(l){!l&&l!==0?(this.placeholder=!0,this.rendered=e.gray(this.transform.render(`${this.initial}`)),this._value=""):(this.placeholder=!1,this.rendered=this.transform.render(`${n(l,this.round)}`),this._value=n(l,this.round)),this.fire()}get value(){return this._value}parse(l){return this.float?parseFloat(l):parseInt(l)}valid(l){return l==="-"||l==="."&&this.float||h.test(l)}reset(){this.typed="",this.value="",this.fire(),this.render()}exit(){this.abort()}abort(){let l=this.value;this.value=l!==""?l:this.initial,this.done=this.aborted=!0,this.error=!1,this.fire(),this.render(),this.out.write(`
|
|
68
|
+
`),this.close()}async validate(){let l=await this.validator(this.value);typeof l=="string"&&(this.errorMsg=l,l=!1),this.error=!l}async submit(){if(await this.validate(),this.error){this.color="red",this.fire(),this.render();return}let l=this.value;this.value=l!==""?l:this.initial,this.done=!0,this.aborted=!1,this.error=!1,this.fire(),this.render(),this.out.write(`
|
|
69
|
+
`),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 l=this.value.toString();if(l.length===0)return this.bell();this.value=this.parse(l=l.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()}_(l,u){if(!this.valid(l))return this.bell();const y=Date.now();if(y-this.lastHit>1e3&&(this.typed=""),this.typed+=l,this.lastHit=y,this.color="cyan",l===".")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(i.down(v(this.outputError,this.out.columns)-1)+s(this.outputError,this.out.columns)),this.out.write(s(this.outputText,this.out.columns))),super.render(),this.outputError="",this.outputText=[o.symbol(this.done,this.aborted),e.bold(this.msg),o.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(`
|
|
70
|
+
`).reduce((l,u,y)=>l+`
|
|
71
|
+
${y?" ":m.pointerSmall} ${e.red().italic(u)}`,"")),this.out.write(t.line+i.to(0)+this.outputText+i.save+this.outputError+i.restore))}}return pt=d,pt}var mt,Yr;function kr(){if(Yr)return mt;Yr=1;const e=E(),{cursor:r}=_(),i=z(),{clear:t,figures:o,style:m,wrap:s,entriesToDisplay:v}=B();class h extends i{constructor(n={}){super(n),this.msg=n.message,this.cursor=n.cursor||0,this.scrollIndex=n.cursor||0,this.hint=n.hint||"",this.warn=n.warn||"- This option is disabled -",this.minSelected=n.min,this.showMinError=!1,this.maxChoices=n.max,this.instructions=n.instructions,this.optionsPerPage=n.optionsPerPage||10,this.value=n.choices.map((d,c)=>(typeof d=="string"&&(d={title:d,value:c}),{title:d&&(d.title||d.value||d),description:d&&d.description,value:d&&(d.value===void 0?c:d.value),selected:d&&d.selected,disabled:d&&d.disabled})),this.clear=t("",this.out.columns),n.overrideRender||this.render()}reset(){this.value.map(n=>!n.selected),this.cursor=0,this.fire(),this.render()}selected(){return this.value.filter(n=>n.selected)}exit(){this.abort()}abort(){this.done=this.aborted=!0,this.fire(),this.render(),this.out.write(`
|
|
72
|
+
`),this.close()}submit(){const n=this.value.filter(d=>d.selected);this.minSelected&&n.length<this.minSelected?(this.showMinError=!0,this.render()):(this.done=!0,this.aborted=!1,this.fire(),this.render(),this.out.write(`
|
|
73
|
+
`),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(n=>n.selected).length>=this.maxChoices)return this.bell();this.value[this.cursor].selected=!0,this.render()}handleSpaceToggle(){const n=this.value[this.cursor];if(n.selected)n.selected=!1,this.render();else{if(n.disabled||this.value.filter(d=>d.selected).length>=this.maxChoices)return this.bell();n.selected=!0,this.render()}}toggleAll(){if(this.maxChoices!==void 0||this.value[this.cursor].disabled)return this.bell();const n=!this.value[this.cursor].selected;this.value.filter(d=>!d.disabled).forEach(d=>d.selected=n),this.render()}_(n,d){if(n===" ")this.handleSpaceToggle();else if(n==="a")this.toggleAll();else return this.bell()}renderInstructions(){return this.instructions===void 0||this.instructions?typeof this.instructions=="string"?this.instructions:`
|
|
74
|
+
Instructions:
|
|
75
|
+
${o.arrowUp}/${o.arrowDown}: Highlight option
|
|
76
|
+
${o.arrowLeft}/${o.arrowRight}/[space]: Toggle selection
|
|
77
|
+
`+(this.maxChoices===void 0?` a: Toggle all
|
|
78
|
+
`:"")+" enter/return: Complete answer":""}renderOption(n,d,c,l){const u=(d.selected?e.green(o.radioOn):o.radioOff)+" "+l+" ";let y,g;return d.disabled?y=n===c?e.gray().underline(d.title):e.strikethrough().gray(d.title):(y=n===c?e.cyan().underline(d.title):d.title,n===c&&d.description&&(g=` - ${d.description}`,(u.length+y.length+g.length>=this.out.columns||d.description.split(/\r?\n/).length>1)&&(g=`
|
|
79
|
+
`+s(d.description,{margin:u.length,width:this.out.columns})))),u+y+e.gray(g||"")}paginateOptions(n){if(n.length===0)return e.red("No matches for this query.");let{startIndex:d,endIndex:c}=v(this.cursor,n.length,this.optionsPerPage),l,u=[];for(let y=d;y<c;y++)y===d&&d>0?l=o.arrowUp:y===c-1&&c<n.length?l=o.arrowDown:l=" ",u.push(this.renderOption(this.cursor,n[y],y,l));return`
|
|
80
|
+
`+u.join(`
|
|
81
|
+
`)}renderOptions(n){return this.done?"":this.paginateOptions(n)}renderDoneOrInstructions(){if(this.done)return this.value.filter(d=>d.selected).map(d=>d.title).join(", ");const n=[e.gray(this.hint),this.renderInstructions()];return this.value[this.cursor].disabled&&n.push(e.yellow(this.warn)),n.join(" ")}render(){if(this.closed)return;this.firstRender&&this.out.write(r.hide),super.render();let n=[m.symbol(this.done,this.aborted),e.bold(this.msg),m.delimiter(!1),this.renderDoneOrInstructions()].join(" ");this.showMinError&&(n+=e.red(`You must select a minimum of ${this.minSelected} choices.`),this.showMinError=!1),n+=this.renderOptions(this.value),this.out.write(this.clear+n),this.clear=t(n,this.out.columns)}}return mt=h,mt}var gt,Br;function us(){if(Br)return gt;Br=1;const e=E(),r=z(),{erase:i,cursor:t}=_(),{style:o,clear:m,figures:s,wrap:v,entriesToDisplay:h}=B(),a=(l,u)=>l[u]&&(l[u].value||l[u].title||l[u]),n=(l,u)=>l[u]&&(l[u].title||l[u].value||l[u]),d=(l,u)=>{const y=l.findIndex(g=>g.value===u||g.title===u);return y>-1?y:void 0};class c extends r{constructor(u={}){super(u),this.msg=u.message,this.suggest=u.suggest,this.choices=u.choices,this.initial=typeof u.initial=="number"?u.initial:d(u.choices,u.initial),this.select=this.initial||u.cursor||0,this.i18n={noMatches:u.noMatches||"no matches found"},this.fallback=u.fallback||this.initial,this.clearFirst=u.clearFirst||!1,this.suggestions=[],this.input="",this.limit=u.limit||10,this.cursor=0,this.transform=o.render(u.style),this.scale=this.transform.scale,this.render=this.render.bind(this),this.complete=this.complete.bind(this),this.clear=m("",this.out.columns),this.complete(this.render),this.render()}set fallback(u){this._fb=Number.isSafeInteger(parseInt(u))?parseInt(u):u}get fallback(){let u;return typeof this._fb=="number"?u=this.choices[this._fb]:typeof this._fb=="string"&&(u={title:this._fb}),u||this._fb||{title:this.i18n.noMatches}}moveSelect(u){this.select=u,this.suggestions.length>0?this.value=a(this.suggestions,u):this.value=this.fallback.value,this.fire()}async complete(u){const y=this.completing=this.suggest(this.input,this.choices),g=await y;if(this.completing!==y)return;this.suggestions=g.map((p,b,w)=>({title:n(w,b),value:a(w,b),description:p.description})),this.completing=!1;const f=Math.max(g.length-1,0);this.moveSelect(Math.min(f,this.select)),u&&u()}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(`
|
|
82
|
+
`),this.close())}abort(){this.done=this.aborted=!0,this.exited=!1,this.fire(),this.render(),this.out.write(`
|
|
83
|
+
`),this.close()}submit(){this.done=!0,this.aborted=this.exited=!1,this.fire(),this.render(),this.out.write(`
|
|
84
|
+
`),this.close()}_(u,y){let g=this.input.slice(0,this.cursor),f=this.input.slice(this.cursor);this.input=`${g}${u}${f}`,this.cursor=g.length+1,this.complete(this.render),this.render()}delete(){if(this.cursor===0)return this.bell();let u=this.input.slice(0,this.cursor-1),y=this.input.slice(this.cursor);this.input=`${u}${y}`,this.complete(this.render),this.cursor=this.cursor-1,this.render()}deleteForward(){if(this.cursor*this.scale>=this.rendered.length)return this.bell();let u=this.input.slice(0,this.cursor),y=this.input.slice(this.cursor+1);this.input=`${u}${y}`,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(u,y,g,f){let p,b=g?s.arrowUp:f?s.arrowDown:" ",w=y?e.cyan().underline(u.title):u.title;return b=(y?e.cyan(s.pointer)+" ":" ")+b,u.description&&(p=` - ${u.description}`,(b.length+w.length+p.length>=this.out.columns||u.description.split(/\r?\n/).length>1)&&(p=`
|
|
85
|
+
`+v(u.description,{margin:3,width:this.out.columns}))),b+" "+w+e.gray(p||"")}render(){if(this.closed)return;this.firstRender?this.out.write(t.hide):this.out.write(m(this.outputText,this.out.columns)),super.render();let{startIndex:u,endIndex:y}=h(this.select,this.choices.length,this.limit);if(this.outputText=[o.symbol(this.done,this.aborted,this.exited),e.bold(this.msg),o.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 g=this.suggestions.slice(u,y).map((f,p)=>this.renderOption(f,this.select===p+u,p===0&&u>0,p+u===y-1&&y<this.choices.length)).join(`
|
|
86
|
+
`);this.outputText+=`
|
|
87
|
+
`+(g||e.gray(this.fallback.title))}this.out.write(i.line+t.to(0)+this.outputText)}}return gt=c,gt}var vt,Vr;function as(){if(Vr)return vt;Vr=1;const e=E(),{cursor:r}=_(),i=kr(),{clear:t,style:o,figures:m}=B();class s extends i{constructor(h={}){h.overrideRender=!0,super(h),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(h=>h.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 h=this.filteredOptions[this.cursor];this.filteredOptions=this.value.filter(n=>this.inputValue?!!(typeof n.title=="string"&&n.title.toLowerCase().includes(this.inputValue.toLowerCase())||typeof n.value=="string"&&n.value.toLowerCase().includes(this.inputValue.toLowerCase())):!0);const a=this.filteredOptions.findIndex(n=>n===h);this.cursor=a<0?0:a,this.render()}handleSpaceToggle(){const h=this.filteredOptions[this.cursor];if(h.selected)h.selected=!1,this.render();else{if(h.disabled||this.value.filter(a=>a.selected).length>=this.maxChoices)return this.bell();h.selected=!0,this.render()}}handleInputChange(h){this.inputValue=this.inputValue+h,this.updateFilteredOptions()}_(h,a){h===" "?this.handleSpaceToggle():this.handleInputChange(h)}renderInstructions(){return this.instructions===void 0||this.instructions?typeof this.instructions=="string"?this.instructions:`
|
|
88
|
+
Instructions:
|
|
89
|
+
${m.arrowUp}/${m.arrowDown}: Highlight option
|
|
90
|
+
${m.arrowLeft}/${m.arrowRight}/[space]: Toggle selection
|
|
91
|
+
[a,b,c]/delete: Filter choices
|
|
92
|
+
enter/return: Complete answer
|
|
93
|
+
`:""}renderCurrentInput(){return`
|
|
94
|
+
Filtered results for: ${this.inputValue?this.inputValue:e.gray("Enter something to filter")}
|
|
95
|
+
`}renderOption(h,a,n){let d;return a.disabled?d=h===n?e.gray().underline(a.title):e.strikethrough().gray(a.title):d=h===n?e.cyan().underline(a.title):a.title,(a.selected?e.green(m.radioOn):m.radioOff)+" "+d}renderDoneOrInstructions(){if(this.done)return this.value.filter(a=>a.selected).map(a=>a.title).join(", ");const h=[e.gray(this.hint),this.renderInstructions(),this.renderCurrentInput()];return this.filteredOptions.length&&this.filteredOptions[this.cursor].disabled&&h.push(e.yellow(this.warn)),h.join(" ")}render(){if(this.closed)return;this.firstRender&&this.out.write(r.hide),super.render();let h=[o.symbol(this.done,this.aborted),e.bold(this.msg),o.delimiter(!1),this.renderDoneOrInstructions()].join(" ");this.showMinError&&(h+=e.red(`You must select a minimum of ${this.minSelected} choices.`),this.showMinError=!1),h+=this.renderOptions(this.filteredOptions),this.out.write(this.clear+h),this.clear=t(h,this.out.columns)}}return vt=s,vt}var bt,Hr;function cs(){if(Hr)return bt;Hr=1;const e=E(),r=z(),{style:i,clear:t}=B(),{erase:o,cursor:m}=_();class s extends r{constructor(h={}){super(h),this.msg=h.message,this.value=h.initial,this.initialValue=!!h.initial,this.yesMsg=h.yes||"yes",this.yesOption=h.yesOption||"(Y/n)",this.noMsg=h.no||"no",this.noOption=h.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(`
|
|
96
|
+
`),this.close()}submit(){this.value=this.value||!1,this.done=!0,this.aborted=!1,this.fire(),this.render(),this.out.write(`
|
|
97
|
+
`),this.close()}_(h,a){return h.toLowerCase()==="y"?(this.value=!0,this.submit()):h.toLowerCase()==="n"?(this.value=!1,this.submit()):this.bell()}render(){this.closed||(this.firstRender?this.out.write(m.hide):this.out.write(t(this.outputText,this.out.columns)),super.render(),this.outputText=[i.symbol(this.done,this.aborted),e.bold(this.msg),i.delimiter(this.done),this.done?this.value?this.yesMsg:this.noMsg:e.gray(this.initialValue?this.yesOption:this.noOption)].join(" "),this.out.write(o.line+m.to(0)+this.outputText))}}return bt=s,bt}var yt,Ur;function ds(){return Ur||(Ur=1,yt={TextPrompt:zi(),SelectPrompt:Ki(),TogglePrompt:Zi(),DatePrompt:ls(),NumberPrompt:hs(),MultiselectPrompt:kr(),AutocompletePrompt:us(),AutocompleteMultiselectPrompt:as(),ConfirmPrompt:cs()}),yt}var Gr;function fs(){return Gr||(Gr=1,function(e){const r=e,i=ds(),t=s=>s;function o(s,v,h={}){return new Promise((a,n)=>{const d=new i[s](v),c=h.onAbort||t,l=h.onSubmit||t,u=h.onExit||t;d.on("state",v.onState||t),d.on("submit",y=>a(l(y))),d.on("exit",y=>a(u(y))),d.on("abort",y=>n(c(y)))})}r.text=s=>o("TextPrompt",s),r.password=s=>(s.style="password",r.text(s)),r.invisible=s=>(s.style="invisible",r.text(s)),r.number=s=>o("NumberPrompt",s),r.date=s=>o("DatePrompt",s),r.confirm=s=>o("ConfirmPrompt",s),r.list=s=>{const v=s.separator||",";return o("TextPrompt",s,{onSubmit:h=>h.split(v).map(a=>a.trim())})},r.toggle=s=>o("TogglePrompt",s),r.select=s=>o("SelectPrompt",s),r.multiselect=s=>{s.choices=[].concat(s.choices||[]);const v=h=>h.filter(a=>a.selected).map(a=>a.value);return o("MultiselectPrompt",s,{onAbort:v,onSubmit:v})},r.autocompleteMultiselect=s=>{s.choices=[].concat(s.choices||[]);const v=h=>h.filter(a=>a.selected).map(a=>a.value);return o("AutocompleteMultiselectPrompt",s,{onAbort:v,onSubmit:v})};const m=(s,v)=>Promise.resolve(v.filter(h=>h.title.slice(0,s.length).toLowerCase()===s.toLowerCase()));r.autocomplete=s=>(s.suggest=s.suggest||m,s.choices=[].concat(s.choices||[]),o("AutocompletePrompt",s))}(Be)),Be}var wt,Jr;function ps(){if(Jr)return wt;Jr=1;const e=fs(),r=["suggest","format","onState","validate","onRender","type"],i=()=>{};async function t(v=[],{onSubmit:h=i,onCancel:a=i}={}){const n={},d=t._override||{};v=[].concat(v);let c,l,u,y,g,f;const p=async(b,w,x=!1)=>{if(!(!x&&b.validate&&b.validate(w)!==!0))return b.format?await b.format(w,n):w};for(l of v)if({name:y,type:g}=l,typeof g=="function"&&(g=await g(c,{...n},l),l.type=g),!!g){for(let b in l){if(r.includes(b))continue;let w=l[b];l[b]=typeof w=="function"?await w(c,{...n},f):w}if(f=l,typeof l.message!="string")throw new Error("prompt message is required");if({name:y,type:g}=l,e[g]===void 0)throw new Error(`prompt type (${g}) is not defined`);if(d[l.name]!==void 0&&(c=await p(l,d[l.name]),c!==void 0)){n[y]=c;continue}try{c=t._injected?o(t._injected,l.initial):await e[g](l),n[y]=c=await p(l,c,!0),u=await h(l,c,n)}catch{u=!await a(l,n)}if(u)return n}return n}function o(v,h){const a=v.shift();if(a instanceof Error)throw a;return a===void 0?h:a}function m(v){t._injected=(t._injected||[]).concat(v)}function s(v){t._override=Object.assign({},v)}return wt=Object.assign(t,{prompt:t,prompts:e,inject:m,override:s}),wt}function ms(e){e=(Array.isArray(e)?e:e.split(".")).map(Number);let r=0,i=process.versions.node.split(".").map(Number);for(;r<e.length;r++){if(i[r]>e[r])return!1;if(e[r]>i[r])return!0}return!1}var gs=ms("8.6.0")?Bi():ps(),ie=Et(gs);function vs(e,r){var i=e;r.slice(0,-1).forEach(function(o){i=i[o]||{}});var t=r[r.length-1];return t in i}function Wr(e){return typeof e=="number"||/^0x[0-9a-f]+$/i.test(e)?!0:/^[-+]?(?:\d+(?:\.\d*)?|\.\d+)(e[-+]?\d+)?$/.test(e)}function zr(e,r){return r==="constructor"&&typeof e[r]=="function"||r==="__proto__"}var bs=function(e,r){r||(r={});var i={bools:{},strings:{},unknownFn:null};typeof r.unknown=="function"&&(i.unknownFn=r.unknown),typeof r.boolean=="boolean"&&r.boolean?i.allBools=!0:[].concat(r.boolean).filter(Boolean).forEach(function(w){i.bools[w]=!0});var t={};function o(w){return t[w].some(function(x){return i.bools[x]})}Object.keys(r.alias||{}).forEach(function(w){t[w]=[].concat(r.alias[w]),t[w].forEach(function(x){t[x]=[w].concat(t[w].filter(function(S){return x!==S}))})}),[].concat(r.string).filter(Boolean).forEach(function(w){i.strings[w]=!0,t[w]&&[].concat(t[w]).forEach(function(x){i.strings[x]=!0})});var m=r.default||{},s={_:[]};function v(w,x){return i.allBools&&/^--[^=]+$/.test(x)||i.strings[w]||i.bools[w]||t[w]}function h(w,x,S){for(var T=w,M=0;M<x.length-1;M++){var $=x[M];if(zr(T,$))return;T[$]===void 0&&(T[$]={}),(T[$]===Object.prototype||T[$]===Number.prototype||T[$]===String.prototype)&&(T[$]={}),T[$]===Array.prototype&&(T[$]=[]),T=T[$]}var O=x[x.length-1];zr(T,O)||((T===Object.prototype||T===Number.prototype||T===String.prototype)&&(T={}),T===Array.prototype&&(T=[]),T[O]===void 0||i.bools[O]||typeof T[O]=="boolean"?T[O]=S:Array.isArray(T[O])?T[O].push(S):T[O]=[T[O],S])}function a(w,x,S){if(!(S&&i.unknownFn&&!v(w,S)&&i.unknownFn(S)===!1)){var T=!i.strings[w]&&Wr(x)?Number(x):x;h(s,w.split("."),T),(t[w]||[]).forEach(function(M){h(s,M.split("."),T)})}}Object.keys(i.bools).forEach(function(w){a(w,m[w]===void 0?!1:m[w])});var n=[];e.indexOf("--")!==-1&&(n=e.slice(e.indexOf("--")+1),e=e.slice(0,e.indexOf("--")));for(var d=0;d<e.length;d++){var c=e[d],l,u;if(/^--.+=/.test(c)){var y=c.match(/^--([^=]+)=([\s\S]*)$/);l=y[1];var g=y[2];i.bools[l]&&(g=g!=="false"),a(l,g,c)}else if(/^--no-.+/.test(c))l=c.match(/^--no-(.+)/)[1],a(l,!1,c);else if(/^--.+/.test(c))l=c.match(/^--(.+)/)[1],u=e[d+1],u!==void 0&&!/^(-|--)[^-]/.test(u)&&!i.bools[l]&&!i.allBools&&(!t[l]||!o(l))?(a(l,u,c),d+=1):/^(true|false)$/.test(u)?(a(l,u==="true",c),d+=1):a(l,i.strings[l]?"":!0,c);else if(/^-[^-]+/.test(c)){for(var f=c.slice(1,-1).split(""),p=!1,b=0;b<f.length;b++){if(u=c.slice(b+2),u==="-"){a(f[b],u,c);continue}if(/[A-Za-z]/.test(f[b])&&u[0]==="="){a(f[b],u.slice(1),c),p=!0;break}if(/[A-Za-z]/.test(f[b])&&/-?\d+(\.\d*)?(e-?\d+)?$/.test(u)){a(f[b],u,c),p=!0;break}if(f[b+1]&&f[b+1].match(/\W/)){a(f[b],c.slice(b+2),c),p=!0;break}else a(f[b],i.strings[f[b]]?"":!0,c)}l=c.slice(-1)[0],!p&&l!=="-"&&(e[d+1]&&!/^(-|--)[^-]/.test(e[d+1])&&!i.bools[l]&&(!t[l]||!o(l))?(a(l,e[d+1],c),d+=1):e[d+1]&&/^(true|false)$/.test(e[d+1])?(a(l,e[d+1]==="true",c),d+=1):a(l,i.strings[l]?"":!0,c))}else if((!i.unknownFn||i.unknownFn(c)!==!1)&&s._.push(i.strings._||!Wr(c)?c:Number(c)),r.stopEarly){s._.push.apply(s._,e.slice(d+1));break}}return Object.keys(m).forEach(function(w){vs(s,w.split("."))||(h(s,w.split("."),m[w]),(t[w]||[]).forEach(function(x){h(s,x.split("."),m[w])}))}),r["--"]?s["--"]=n.slice():n.forEach(function(w){s._.push(w)}),s},ys=Et(bs);const xt=10,Kr=(e=0)=>r=>`\x1B[${r+e}m`,Zr=(e=0)=>r=>`\x1B[${38+e};5;${r}m`,Xr=(e=0)=>(r,i,t)=>`\x1B[${38+e};2;${r};${i};${t}m`,C={modifier:{reset:[0,0],bold:[1,22],dim:[2,22],italic:[3,23],underline:[4,24],overline:[53,55],inverse:[7,27],hidden:[8,28],strikethrough:[9,29]},color:{black:[30,39],red:[31,39],green:[32,39],yellow:[33,39],blue:[34,39],magenta:[35,39],cyan:[36,39],white:[37,39],blackBright:[90,39],gray:[90,39],grey:[90,39],redBright:[91,39],greenBright:[92,39],yellowBright:[93,39],blueBright:[94,39],magentaBright:[95,39],cyanBright:[96,39],whiteBright:[97,39]},bgColor:{bgBlack:[40,49],bgRed:[41,49],bgGreen:[42,49],bgYellow:[43,49],bgBlue:[44,49],bgMagenta:[45,49],bgCyan:[46,49],bgWhite:[47,49],bgBlackBright:[100,49],bgGray:[100,49],bgGrey:[100,49],bgRedBright:[101,49],bgGreenBright:[102,49],bgYellowBright:[103,49],bgBlueBright:[104,49],bgMagentaBright:[105,49],bgCyanBright:[106,49],bgWhiteBright:[107,49]}};Object.keys(C.modifier);const ws=Object.keys(C.color),xs=Object.keys(C.bgColor);[...ws,...xs];function Ss(){const e=new Map;for(const[r,i]of Object.entries(C)){for(const[t,o]of Object.entries(i))C[t]={open:`\x1B[${o[0]}m`,close:`\x1B[${o[1]}m`},i[t]=C[t],e.set(o[0],o[1]);Object.defineProperty(C,r,{value:i,enumerable:!1})}return Object.defineProperty(C,"codes",{value:e,enumerable:!1}),C.color.close="\x1B[39m",C.bgColor.close="\x1B[49m",C.color.ansi=Kr(),C.color.ansi256=Zr(),C.color.ansi16m=Xr(),C.bgColor.ansi=Kr(xt),C.bgColor.ansi256=Zr(xt),C.bgColor.ansi16m=Xr(xt),Object.defineProperties(C,{rgbToAnsi256:{value(r,i,t){return r===i&&i===t?r<8?16:r>248?231:Math.round((r-8)/247*24)+232:16+36*Math.round(r/255*5)+6*Math.round(i/255*5)+Math.round(t/255*5)},enumerable:!1},hexToRgb:{value(r){const i=/[a-f\d]{6}|[a-f\d]{3}/i.exec(r.toString(16));if(!i)return[0,0,0];let[t]=i;t.length===3&&(t=[...t].map(m=>m+m).join(""));const o=Number.parseInt(t,16);return[o>>16&255,o>>8&255,o&255]},enumerable:!1},hexToAnsi256:{value:r=>C.rgbToAnsi256(...C.hexToRgb(r)),enumerable:!1},ansi256ToAnsi:{value(r){if(r<8)return 30+r;if(r<16)return 90+(r-8);let i,t,o;if(r>=232)i=((r-232)*10+8)/255,t=i,o=i;else{r-=16;const v=r%36;i=Math.floor(r/36)/5,t=Math.floor(v/6)/5,o=v%6/5}const m=Math.max(i,t,o)*2;if(m===0)return 30;let s=30+(Math.round(o)<<2|Math.round(t)<<1|Math.round(i));return m===2&&(s+=60),s},enumerable:!1},rgbToAnsi:{value:(r,i,t)=>C.ansi256ToAnsi(C.rgbToAnsi256(r,i,t)),enumerable:!1},hexToAnsi:{value:r=>C.ansi256ToAnsi(C.hexToAnsi256(r)),enumerable:!1}}),C}const V=Ss();function L(e,r=globalThis.Deno?globalThis.Deno.args:oe.argv){const i=e.startsWith("-")?"":e.length===1?"-":"--",t=r.indexOf(i+e),o=r.indexOf("--");return t!==-1&&(o===-1||t<o)}const{env:D}=oe;let se;L("no-color")||L("no-colors")||L("color=false")||L("color=never")?se=0:(L("color")||L("colors")||L("color=true")||L("color=always"))&&(se=1);function $s(){if("FORCE_COLOR"in D)return D.FORCE_COLOR==="true"?1:D.FORCE_COLOR==="false"?0:D.FORCE_COLOR.length===0?1:Math.min(Number.parseInt(D.FORCE_COLOR,10),3)}function Ts(e){return e===0?!1:{level:e,hasBasic:!0,has256:e>=2,has16m:e>=3}}function Os(e,{streamIsTTY:r,sniffFlags:i=!0}={}){const t=$s();t!==void 0&&(se=t);const o=i?se:t;if(o===0)return 0;if(i){if(L("color=16m")||L("color=full")||L("color=truecolor"))return 3;if(L("color=256"))return 2}if("TF_BUILD"in D&&"AGENT_NAME"in D)return 1;if(e&&!r&&o===void 0)return 0;const m=o||0;if(D.TERM==="dumb")return m;if(oe.platform==="win32"){const s=ui.release().split(".");return Number(s[0])>=10&&Number(s[2])>=10586?Number(s[2])>=14931?3:2:1}if("CI"in D)return"GITHUB_ACTIONS"in D||"GITEA_ACTIONS"in D?3:["TRAVIS","CIRCLECI","APPVEYOR","GITLAB_CI","BUILDKITE","DRONE"].some(s=>s in D)||D.CI_NAME==="codeship"?1:m;if("TEAMCITY_VERSION"in D)return/^(9\.(0*[1-9]\d*)\.|\d{2,}\.)/.test(D.TEAMCITY_VERSION)?1:0;if(D.COLORTERM==="truecolor"||D.TERM==="xterm-kitty")return 3;if("TERM_PROGRAM"in D){const s=Number.parseInt((D.TERM_PROGRAM_VERSION||"").split(".")[0],10);switch(D.TERM_PROGRAM){case"iTerm.app":return s>=3?3:2;case"Apple_Terminal":return 2}}return/-256(color)?$/i.test(D.TERM)?2:/^screen|^xterm|^vt100|^vt220|^rxvt|color|ansi|cygwin|linux/i.test(D.TERM)||"COLORTERM"in D?1:m}function Qr(e,r={}){const i=Os(e,{streamIsTTY:e&&e.isTTY,...r});return Ts(i)}const Ms={stdout:Qr({isTTY:Ct.isatty(1)}),stderr:Qr({isTTY:Ct.isatty(2)})};function Rs(e,r,i){let t=e.indexOf(r);if(t===-1)return e;const o=r.length;let m=0,s="";do s+=e.slice(m,t)+r+i,m=t+o,t=e.indexOf(r,m);while(t!==-1);return s+=e.slice(m),s}function Ps(e,r,i,t){let o=0,m="";do{const s=e[t-1]==="\r";m+=e.slice(o,s?t-1:t)+r+(s?`\r
|
|
98
|
+
`:`
|
|
99
|
+
`)+i,o=t+1,t=e.indexOf(`
|
|
100
|
+
`,o)}while(t!==-1);return m+=e.slice(o),m}const{stdout:ei,stderr:ti}=Ms,St=Symbol("GENERATOR"),Q=Symbol("STYLER"),te=Symbol("IS_EMPTY"),ri=["ansi","ansi","ansi256","ansi16m"],ee=Object.create(null),Cs=(e,r={})=>{if(r.level&&!(Number.isInteger(r.level)&&r.level>=0&&r.level<=3))throw new Error("The `level` option should be an integer from 0 to 3");const i=ei?ei.level:0;e.level=r.level===void 0?i:r.level},Ds=e=>{const r=(...i)=>i.join(" ");return Cs(r,e),Object.setPrototypeOf(r,re.prototype),r};function re(e){return Ds(e)}Object.setPrototypeOf(re.prototype,Function.prototype);for(const[e,r]of Object.entries(V))ee[e]={get(){const i=ne(this,Tt(r.open,r.close,this[Q]),this[te]);return Object.defineProperty(this,e,{value:i}),i}};ee.visible={get(){const e=ne(this,this[Q],!0);return Object.defineProperty(this,"visible",{value:e}),e}};const $t=(e,r,i,...t)=>e==="rgb"?r==="ansi16m"?V[i].ansi16m(...t):r==="ansi256"?V[i].ansi256(V.rgbToAnsi256(...t)):V[i].ansi(V.rgbToAnsi(...t)):e==="hex"?$t("rgb",r,i,...V.hexToRgb(...t)):V[i][e](...t),Es=["rgb","hex","ansi256"];for(const e of Es){ee[e]={get(){const{level:i}=this;return function(...t){const o=Tt($t(e,ri[i],"color",...t),V.color.close,this[Q]);return ne(this,o,this[te])}}};const r="bg"+e[0].toUpperCase()+e.slice(1);ee[r]={get(){const{level:i}=this;return function(...t){const o=Tt($t(e,ri[i],"bgColor",...t),V.bgColor.close,this[Q]);return ne(this,o,this[te])}}}}const _s=Object.defineProperties(()=>{},{...ee,level:{enumerable:!0,get(){return this[St].level},set(e){this[St].level=e}}}),Tt=(e,r,i)=>{let t,o;return i===void 0?(t=e,o=r):(t=i.openAll+e,o=r+i.closeAll),{open:e,close:r,openAll:t,closeAll:o,parent:i}},ne=(e,r,i)=>{const t=(...o)=>As(t,o.length===1?""+o[0]:o.join(" "));return Object.setPrototypeOf(t,_s),t[St]=e,t[Q]=r,t[te]=i,t},As=(e,r)=>{if(e.level<=0||!r)return e[te]?"":r;let i=e[Q];if(i===void 0)return r;const{openAll:t,closeAll:o}=i;if(r.includes("\x1B"))for(;i!==void 0;)r=Rs(r,i.close,i.open),i=i.parent;const m=r.indexOf(`
|
|
101
|
+
`);return m!==-1&&(r=Ps(r,o,t,m)),t+r+o};Object.defineProperties(re.prototype,ee);const q=re();re({level:ti?ti.level:0});const R={backend:q.hex("#3677FF"),frontend:q.hex("#6DC6FE"),vanilla:q.hex("#EEC900"),react:q.hex("3B89E0"),typescript:q.hex("30B3ED"),ok:q.hex("30ED86"),error:q.hex("ED3066"),info:q.hex("42ECDE"),gray:q.hex("#686868"),vue:q.hex("54E6A5"),warn:q.hex("#EC9942"),webpack:q.hex("#75AFCC"),node:q.hex("#417E38"),rust:q.hex("#D34516"),experimental:q.hex("#FA2200")};function K(e){const r=22-e.length;return q.reset(R.gray(`${" ".repeat(r)}|${" ".repeat(2)}`))}function H(e){const r=e.split(" ");return e==="Frontend"?R.frontend(e):e==="Backend"?R.backend(e):e==="VanillaJS"?R.vanilla(e):e==="NodeJS"||r.includes("Node")?R.node(e):r.includes("JavaScript")?R.react(e):r.includes("TypeScript")?R.typescript(e):r.includes("React")?R.react(e):r.includes("TypeScript")?R.typescript(e):e}function Z(e){return q.reset(e)}const ii={Frontend:{VanillaJS:[{value:"vanilla-js",title:H("VanillaJS"),description:R.error("Vanilla JS + Vite.")}],"React JavaScript":[{value:"react",title:`${H("React")}${K("React")}${Z(R.error("React + Vite."))}`},{value:"react-dev",title:`${H("React Dev")}${K("React Dev")}${Z(R.error("Tailwind + Linter + Tests"))}`},{value:"react-webpack",title:`${H("React Webpack")}${K("React Webpack")}${Z(R.error("React + Webpack."))}`},{value:"react-dev-webpack",title:`${H("React Dev Webpack")}${K("React Dev Webpack")}${Z(R.error("Tailwind + Linter + Tests"))}`}],"React TypeScript":[{value:"react-typescript",title:`${H("React TypeScript")}${K("React TypeScript")}${Z(R.error("React + Vite + TypeScript"))}`},{value:"react-dev-typescript",title:`${H("React Dev TypeScript")}${K("React Dev TypeScript")}${Z(R.error("Tailwind + Linter + Tests"))}`}]},Backend:{NodeJS:[{value:"node-express",title:`${H("Node Express")}${K("Node Express")}${Z(R.error("Express + Sequelize + Linter + Tests"))}`}]}},si=(e,r)=>{fi(e).forEach(i=>{const t=J.join(e,i);let o=J.join(r,i);i==="_gitignore"&&(o=J.join(r,".gitignore")),pi(t).isDirectory()?(mi(o),si(t,o)):gi(t,o)})},qs=(e,r)=>{const i=J.join(e,"package.json");try{const t=ai(i,"utf8"),o=JSON.parse(t);o.name=r,ci(i,JSON.stringify(o,null,2),"utf8")}catch(t){console.log(t.message)}};async function ni(e,r,i){const t=Dt(e),o=Dt(r);t||console.log(R.error("Invalid Template")),o&&console.log(R.error("Target directory already exist!")),t&&!o&&(console.info(`\u{1F4C2} ${R.ok("Target directory doesn't exist")}`),console.info(`\u{1F6A7} ${R.ok("Creating directory")}`),di(r,{recursive:!0}),console.info(`\u{1F4C1} ${R.ok("Finished creating directory")}`),si(e,r),qs(r,i),console.info(`\u{1F680} ${R.ok(`Finished generating your app ${R.error(i)}`)}`),console.info(`\u{1F3E0} ${R.info(`cd ${i}`)}`),console.info(`\u{1F9EA} ${R.info("npm install")}`))}const Is=e=>e.toLowerCase().split(/[\s|_]/).join("-"),js=e=>e.match(/[^a-zA-Z0-9-\s]/g)?"App name should not contain special characters except hyphen (-)":!0,oi=`
|
|
102
|
+
Usage: create-enchilada [OPTION]... [DIRECTORY]
|
|
103
|
+
|
|
104
|
+
Create a new app. With no arguments,
|
|
105
|
+
starting the CLI in interactive mode.
|
|
106
|
+
|
|
107
|
+
Options:
|
|
108
|
+
directory The project's name in the current directory,
|
|
109
|
+
e.g., my-app, would be like ./my-app/
|
|
110
|
+
the directory should not exist.
|
|
111
|
+
-t, --template NAME Use a specific template.
|
|
112
|
+
-h, --help Display a help message, and exit.
|
|
113
|
+
|
|
114
|
+
Available templates:
|
|
115
|
+
vanilla-js Vanilla JS + Vite
|
|
116
|
+
react React + Vite.
|
|
117
|
+
react-dev Tailwind + Linter + Tests
|
|
118
|
+
react-webpack React + Webpack.
|
|
119
|
+
react-dev-webpack Tailwind + Linter + Tests
|
|
120
|
+
react-typescript React + Vite + TypeScript
|
|
121
|
+
react-dev-typescript Tailwind + Linter + Tests
|
|
122
|
+
node-express Express + Sequelize + Linter + Tests
|
|
123
|
+
`,Fs=ys(hi.slice(2)),li=async e=>{const r=e.template||e.t,i=e._[0],{help:t,h:o}=e;if(t||o)return console.info(oi),oi;if(!r||!i)try{const m=await ie([{type:"select",name:"category",message:"Select the type of project:",choices:Object.keys(ii).map(y=>({title:H(y),value:y}))}]);m.category||process.exit(0);const s=ii[m.category],v=await ie({type:"select",name:"subcategory",message:`Select the technology for ${m.category}:`,choices:Object.keys(s).map(y=>({title:H(y),value:y}))});v.subcategory||process.exit(0);const h=s[v.subcategory],a=await ie({type:"select",name:"template",message:`Select the template for ${v.subcategory}:`,choices:h});a.template||process.exit(0);const n=await ie({type:"text",name:"appName",message:R.typescript("Enter your app name"),initial:"my-app",format:y=>Is(y),validate:y=>js(y)});n.appName||process.exit(0);const{template:d}=a,{appName:c}=n,l=J.join(process.cwd(),c),u=J.resolve(Pt(import.meta.url),"../../templates",`${d}`);ni(u,l,c)}catch(m){console.error(R.error(m.message))}else try{const m=r,s=i,v=J.join(process.cwd(),s),h=J.resolve(Pt(import.meta.url),"../../templates",`${m}`);ni(h,v,s)}catch(m){console.error(R.error(m.message))}return 0};li(Fs);export{li as default};
|
package/index.js
ADDED
package/package.json
ADDED
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "create-enchilada",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"type": "module",
|
|
5
|
+
"description": "A quick way to start your web applications.",
|
|
6
|
+
"main": "index.js",
|
|
7
|
+
"scripts": {
|
|
8
|
+
"lint": "eslint .",
|
|
9
|
+
"build": "rollup --config",
|
|
10
|
+
"cov:clean": "rimraf .nyc_output && rimraf coverage",
|
|
11
|
+
"cov:unit": "NODE_OPTIONS=--experimental-vm-modules jest --forceExit --colors --detectOpenHandles -c jest.config.unit.js",
|
|
12
|
+
"test:unit": "npm-run-all cov:clean cov:unit",
|
|
13
|
+
"cov:e2e": "NODE_ENV=e2e NODE_OPTIONS=--experimental-vm-modules jest --forceExit --colors --detectOpenHandles --runInBand -c jest.config.e2e.js",
|
|
14
|
+
"test:e2e": "NODE_ENV=e2e npm-run-all cov:clean cov:e2e"
|
|
15
|
+
},
|
|
16
|
+
"repository": {
|
|
17
|
+
"type": "git",
|
|
18
|
+
"url": "git+https://github.com/Sharmaz/enchilada.git"
|
|
19
|
+
},
|
|
20
|
+
"keywords": [
|
|
21
|
+
"cli",
|
|
22
|
+
"react",
|
|
23
|
+
"javascript",
|
|
24
|
+
"vanilla",
|
|
25
|
+
"typescript",
|
|
26
|
+
"farm",
|
|
27
|
+
"vite",
|
|
28
|
+
"webpack",
|
|
29
|
+
"tailwindcss",
|
|
30
|
+
"eslint",
|
|
31
|
+
"oxlint",
|
|
32
|
+
"jest",
|
|
33
|
+
"react testing library",
|
|
34
|
+
"app",
|
|
35
|
+
"web",
|
|
36
|
+
"node",
|
|
37
|
+
"express"
|
|
38
|
+
],
|
|
39
|
+
"bin": {
|
|
40
|
+
"create-enchilada": "index.js"
|
|
41
|
+
},
|
|
42
|
+
"preferGlobal": true,
|
|
43
|
+
"engines": {
|
|
44
|
+
"node": "^18.0.0 || >=20.0.0"
|
|
45
|
+
},
|
|
46
|
+
"files": [
|
|
47
|
+
"index.js",
|
|
48
|
+
"templates/*",
|
|
49
|
+
"dist"
|
|
50
|
+
],
|
|
51
|
+
"author": "Ivan Robles <contact@ivanrobles.pro>",
|
|
52
|
+
"license": "MIT",
|
|
53
|
+
"bugs": {
|
|
54
|
+
"url": "https://github.com/Sharmaz/enchilada/issues"
|
|
55
|
+
},
|
|
56
|
+
"homepage": "https://github.com/Sharmaz/enchilada#readme",
|
|
57
|
+
"devDependencies": {
|
|
58
|
+
"@jest/globals": "^29.7.0",
|
|
59
|
+
"@rollup/plugin-commonjs": "^26.0.1",
|
|
60
|
+
"@rollup/plugin-node-resolve": "^15.2.3",
|
|
61
|
+
"cli-prompts-test": "^0.3.0",
|
|
62
|
+
"eslint": "^8.57.0",
|
|
63
|
+
"eslint-config-airbnb-base": "^15.0.0",
|
|
64
|
+
"eslint-config-prettier": "^9.1.0",
|
|
65
|
+
"eslint-plugin-react": "^7.34.2",
|
|
66
|
+
"eslint-plugin-react-hooks": "^4.6.2",
|
|
67
|
+
"eslint-plugin-react-refresh": "^0.4.7",
|
|
68
|
+
"execa": "^9.2.0",
|
|
69
|
+
"jest": "^29.7.0",
|
|
70
|
+
"npm-run-all": "^4.1.5",
|
|
71
|
+
"rollup": "^4.18.0",
|
|
72
|
+
"rollup-plugin-esbuild": "^6.1.1"
|
|
73
|
+
},
|
|
74
|
+
"dependencies": {
|
|
75
|
+
"chalk": "^5.3.0",
|
|
76
|
+
"minimist": "^1.2.8",
|
|
77
|
+
"prompts": "^2.4.2"
|
|
78
|
+
}
|
|
79
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
module.exports = {
|
|
2
|
+
testEnvironment: 'node',
|
|
3
|
+
collectCoverage: true,
|
|
4
|
+
coverageDirectory: 'coverage',
|
|
5
|
+
testMatch: [],
|
|
6
|
+
transformIgnorePatterns: [
|
|
7
|
+
'[/\\\\\\\\]node_modules[/\\\\\\\\].+\\\\.(js|ts)$'
|
|
8
|
+
],
|
|
9
|
+
transform: {},
|
|
10
|
+
coveragePathIgnorePatterns: [
|
|
11
|
+
"/node_modules/"
|
|
12
|
+
]
|
|
13
|
+
};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
const commonConfig = require('./jest.config.js');
|
|
2
|
+
|
|
3
|
+
module.exports = {
|
|
4
|
+
...commonConfig,
|
|
5
|
+
testMatch: [
|
|
6
|
+
'**/*.unit.test.{js,ts}'
|
|
7
|
+
],
|
|
8
|
+
collectCoverageFrom: [
|
|
9
|
+
'**/db/**/*.js',
|
|
10
|
+
'**/libs/**/*.js',
|
|
11
|
+
'**/middlewares/**/*.js',
|
|
12
|
+
'**/routes/**/*.js',
|
|
13
|
+
'**/services/**/*.js',
|
|
14
|
+
'**/utils/**/*.js'
|
|
15
|
+
],
|
|
16
|
+
coverageDirectory: 'coverage/unit'
|
|
17
|
+
};
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "node-express",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"main": "index.js",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"scripts": {
|
|
7
|
+
"start": "node src/index.js",
|
|
8
|
+
"start:dev": "nodemon src/index.js",
|
|
9
|
+
"lint": "eslint .",
|
|
10
|
+
"cov:clean": "rimraf .nyc_output && rimraf coverage",
|
|
11
|
+
"cov:unit": "jest --forceExit --colors -c jest.config.unit.js",
|
|
12
|
+
"test:unit": "npm-run-all cov:clean cov:unit"
|
|
13
|
+
},
|
|
14
|
+
"keywords": [],
|
|
15
|
+
"author": "",
|
|
16
|
+
"license": "ISC",
|
|
17
|
+
"description": "",
|
|
18
|
+
"dependencies": {
|
|
19
|
+
"bcrypt": "^5.1.1",
|
|
20
|
+
"body-parser": "^1.20.3",
|
|
21
|
+
"cookie-parser": "^1.4.6",
|
|
22
|
+
"cors": "^2.8.5",
|
|
23
|
+
"dotenv": "^16.4.5",
|
|
24
|
+
"express": "^4.21.0",
|
|
25
|
+
"jsonwebtoken": "^9.0.2",
|
|
26
|
+
"passport": "^0.7.0",
|
|
27
|
+
"passport-jwt": "^4.0.1",
|
|
28
|
+
"passport-local": "^1.0.0",
|
|
29
|
+
"pg": "^8.13.0",
|
|
30
|
+
"pg-hstore": "^2.3.4",
|
|
31
|
+
"sequelize": "^6.37.3",
|
|
32
|
+
"umzug": "^3.8.2",
|
|
33
|
+
"uuid": "^10.0.0"
|
|
34
|
+
},
|
|
35
|
+
"devDependencies": {
|
|
36
|
+
"@eslint/js": "^9.11.1",
|
|
37
|
+
"@jest/globals": "^29.7.0",
|
|
38
|
+
"eslint": "^9.11.1",
|
|
39
|
+
"globals": "^15.9.0",
|
|
40
|
+
"jest": "^29.7.0",
|
|
41
|
+
"nodemon": "^3.1.7",
|
|
42
|
+
"npm-run-all": "^4.1.5",
|
|
43
|
+
"prettier": "^3.3.3",
|
|
44
|
+
"sequelize-cli": "^6.6.2",
|
|
45
|
+
"sequelize-mock": "^0.10.2"
|
|
46
|
+
}
|
|
47
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
// Using strategies with passport.js
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
// Using env variables.
|
|
2
|
+
require('dotenv').config()
|
|
3
|
+
|
|
4
|
+
const config = {
|
|
5
|
+
port: process.env.PORT || 3000,
|
|
6
|
+
dbUser: process.env.DB_USER,
|
|
7
|
+
dbPassword: process.env.DB_PASSWORD,
|
|
8
|
+
dbName: process.env.DB_NAME,
|
|
9
|
+
dbHost: process.env.DB_HOST,
|
|
10
|
+
dbPort: process.env.DB_PORT
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
module.exports = config;
|