create-napps 0.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +30 -0
- package/dist/index.js +83 -0
- package/index.js +3 -0
- package/package.json +28 -0
- package/templates/pdp-template/index.ts +3 -0
- package/templates/pdp-template/package-lock.json +373 -0
- package/templates/pdp-template/package.json +21 -0
- package/templates/pdp-template/src/customProductInfoGrid.ts +41 -0
- package/templates/pdp-template/src/customTechInfo.ts +35 -0
- package/templates/pdp-template/src/customTextBlock.ts +79 -0
- package/templates/pdp-template/tsconfig.json +25 -0
- package/templates/pdp-template/vite.config.ts +14 -0
package/README.md
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
# create-napps <a href="https://npmjs.com/package/create-napps"></a>
|
|
2
|
+
|
|
3
|
+
## Scaffolding Your First NAPPS component extension project
|
|
4
|
+
|
|
5
|
+
> **Compatibility Note:**
|
|
6
|
+
> Requires [Node.js](https://nodejs.org/en/) version 20.19+, 22.12+.
|
|
7
|
+
|
|
8
|
+
With NPM:
|
|
9
|
+
|
|
10
|
+
```bash
|
|
11
|
+
npm create napps-cli@latest
|
|
12
|
+
```
|
|
13
|
+
|
|
14
|
+
With Yarn:
|
|
15
|
+
|
|
16
|
+
```bash
|
|
17
|
+
yarn create napps-cli@latest
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
With PNPM:
|
|
21
|
+
|
|
22
|
+
```bash
|
|
23
|
+
pnpm create napps-cli@latest
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
With Bun:
|
|
27
|
+
|
|
28
|
+
```bash
|
|
29
|
+
bun create napps-cli@latest
|
|
30
|
+
```
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import{createRequire as e}from"node:module";import{fileURLToPath as t}from"node:url";import n from"node:path";import r from"fs";import{copyFile as i,lstat as a,mkdir as o,readFile as s,readdir as c,writeFile as l}from"fs/promises";var u=Object.create,d=Object.defineProperty,f=Object.getOwnPropertyDescriptor,p=Object.getOwnPropertyNames,m=Object.getPrototypeOf,h=Object.prototype.hasOwnProperty,g=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),_=(e,t,n,r)=>{if(t&&typeof t==`object`||typeof t==`function`)for(var i=p(t),a=0,o=i.length,s;a<o;a++)s=i[a],!h.call(e,s)&&s!==n&&d(e,s,{get:(e=>t[e]).bind(null,s),enumerable:!(r=f(t,s))||r.enumerable});return e},v=(e,t,n)=>(n=e==null?{}:u(m(e)),_(t||!e||!e.__esModule?d(n,`default`,{value:e,enumerable:!0}):n,e)),y=e(import.meta.url),b=g(((e,t)=>{let{FORCE_COLOR:n,NODE_DISABLE_COLORS:r,TERM:i}=process.env,a={enabled:!r&&i!==`dumb`&&n!==`0`,reset:c(0,0),bold:c(1,22),dim:c(2,22),italic:c(3,23),underline:c(4,24),inverse:c(7,27),hidden:c(8,28),strikethrough:c(9,29),black:c(30,39),red:c(31,39),green:c(32,39),yellow:c(33,39),blue:c(34,39),magenta:c(35,39),cyan:c(36,39),white:c(37,39),gray:c(90,39),grey:c(90,39),bgBlack:c(40,49),bgRed:c(41,49),bgGreen:c(42,49),bgYellow:c(43,49),bgBlue:c(44,49),bgMagenta:c(45,49),bgCyan:c(46,49),bgWhite:c(47,49)};function o(e,t){let n=0,r,i=``,a=``;for(;n<e.length;n++)r=e[n],i+=r.open,a+=r.close,t.includes(r.close)&&(t=t.replace(r.rgx,r.close+r.open));return i+t+a}function s(e,t){let n={has:e,keys:t};return n.reset=a.reset.bind(n),n.bold=a.bold.bind(n),n.dim=a.dim.bind(n),n.italic=a.italic.bind(n),n.underline=a.underline.bind(n),n.inverse=a.inverse.bind(n),n.hidden=a.hidden.bind(n),n.strikethrough=a.strikethrough.bind(n),n.black=a.black.bind(n),n.red=a.red.bind(n),n.green=a.green.bind(n),n.yellow=a.yellow.bind(n),n.blue=a.blue.bind(n),n.magenta=a.magenta.bind(n),n.cyan=a.cyan.bind(n),n.white=a.white.bind(n),n.gray=a.gray.bind(n),n.grey=a.grey.bind(n),n.bgBlack=a.bgBlack.bind(n),n.bgRed=a.bgRed.bind(n),n.bgGreen=a.bgGreen.bind(n),n.bgYellow=a.bgYellow.bind(n),n.bgBlue=a.bgBlue.bind(n),n.bgMagenta=a.bgMagenta.bind(n),n.bgCyan=a.bgCyan.bind(n),n.bgWhite=a.bgWhite.bind(n),n}function c(e,t){let n={open:`\x1b[${e}m`,close:`\x1b[${t}m`,rgx:RegExp(`\\x1b\\[${t}m`,`g`)};return function(t){return this!==void 0&&this.has!==void 0?(this.has.includes(e)||(this.has.push(e),this.keys.push(n)),t===void 0?this:a.enabled?o(this.keys,t+``):t+``):t===void 0?s([e],[n]):a.enabled?o([n],t+``):t+``}}t.exports=a})),x=g(((e,t)=>{t.exports=(e,t)=>{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(t){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}}})),S=g(((e,t)=>{t.exports=e=>{let t=[`[\\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(`|`),n=new RegExp(t,`g`);return typeof e==`string`?e.replace(n,``):e}})),C=g(((e,t)=>{let n={to(e,t){return t?`[${t+1};${e+1}H`:`[${e+1}G`},move(e,t){let n=``;return e<0?n+=`[${-e}D`:e>0&&(n+=`[${e}C`),t<0?n+=`[${-t}A`:t>0&&(n+=`[${t}B`),n},up:(e=1)=>`[${e}A`,down:(e=1)=>`[${e}B`,forward:(e=1)=>`[${e}C`,backward:(e=1)=>`[${e}D`,nextLine:(e=1)=>`\x1B[E`.repeat(e),prevLine:(e=1)=>`\x1B[F`.repeat(e),left:`\x1B[G`,hide:`\x1B[?25l`,show:`\x1B[?25h`,save:`\x1B7`,restore:`\x1B8`};t.exports={cursor:n,scroll:{up:(e=1)=>`\x1B[S`.repeat(e),down:(e=1)=>`\x1B[T`.repeat(e)},erase:{screen:`\x1B[2J`,up:(e=1)=>`\x1B[1J`.repeat(e),down:(e=1)=>`\x1B[J`.repeat(e),line:`\x1B[2K`,lineEnd:`\x1B[K`,lineStart:`\x1B[1K`,lines(e){let t=``;for(let r=0;r<e;r++)t+=this.line+(r<e-1?n.up():``);return e&&(t+=n.left),t}},beep:`\x07`}})),w=g(((e,t)=>{function n(e,t){var n=typeof Symbol<`u`&&e[Symbol.iterator]||e[`@@iterator`];if(!n){if(Array.isArray(e)||(n=r(e))||t&&e&&typeof e.length==`number`){n&&(e=n);var i=0,a=function(){};return{s:a,n:function(){return i>=e.length?{done:!0}:{done:!1,value:e[i++]}},e:function(e){throw e},f:a}}throw TypeError(`Invalid attempt to iterate non-iterable instance.
|
|
2
|
+
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}var o=!0,s=!1,c;return{s:function(){n=n.call(e)},n:function(){var e=n.next();return o=e.done,e},e:function(e){s=!0,c=e},f:function(){try{!o&&n.return!=null&&n.return()}finally{if(s)throw c}}}}function r(e,t){if(e){if(typeof e==`string`)return i(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);if(n===`Object`&&e.constructor&&(n=e.constructor.name),n===`Map`||n===`Set`)return Array.from(e);if(n===`Arguments`||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return i(e,t)}}function i(e,t){(t==null||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}let a=S(),o=C(),s=o.erase,c=o.cursor,l=e=>[...a(e)].length;t.exports=function(e,t){if(!t)return s.line+c.to(0);let r=0;var i=n(e.split(/\r?\n/)),a;try{for(i.s();!(a=i.n()).done;){let e=a.value;r+=1+Math.floor(Math.max(l(e)-1,0)/t)}}catch(e){i.e(e)}finally{i.f()}return s.lines(r)}})),T=g(((e,t)=>{let n={arrowUp:`↑`,arrowDown:`↓`,arrowLeft:`←`,arrowRight:`→`,radioOn:`◉`,radioOff:`◯`,tick:`✔`,cross:`✖`,ellipsis:`…`,pointerSmall:`›`,line:`─`,pointer:`❯`},r={arrowUp:n.arrowUp,arrowDown:n.arrowDown,arrowLeft:n.arrowLeft,arrowRight:n.arrowRight,radioOn:`(*)`,radioOff:`( )`,tick:`√`,cross:`×`,ellipsis:`...`,pointerSmall:`»`,line:`─`,pointer:`>`};t.exports=process.platform===`win32`?r:n})),E=g(((e,t)=>{let n=b(),r=T(),i=Object.freeze({password:{scale:1,render:e=>`*`.repeat(e.length)},emoji:{scale:2,render:e=>`😃`.repeat(e.length)},invisible:{scale:0,render:e=>``},default:{scale:1,render:e=>`${e}`}}),a=e=>i[e]||i.default,o=Object.freeze({aborted:n.red(r.cross),done:n.green(r.tick),exited:n.yellow(r.cross),default:n.cyan(`?`)});t.exports={styles:i,render:a,symbols:o,symbol:(e,t,n)=>t?o.aborted:n?o.exited:e?o.done:o.default,delimiter:e=>n.gray(e?r.ellipsis:r.pointerSmall),item:(e,t)=>n.gray(e?t?r.pointerSmall:`+`:r.line)}})),D=g(((e,t)=>{let n=S();t.exports=function(e,t){let r=String(n(e)||``).split(/\r?\n/);return t?r.map(e=>Math.ceil(e.length/t)).reduce((e,t)=>e+t):r.length}})),ee=g(((e,t)=>{t.exports=(e,t={})=>{let n=Number.isSafeInteger(parseInt(t.margin))?Array(parseInt(t.margin)).fill(` `).join(``):t.margin||``,r=t.width;return(e||``).split(/\r?\n/g).map(e=>e.split(/\s+/g).reduce((e,t)=>(t.length+n.length>=r||e[e.length-1].length+t.length+1<r?e[e.length-1]+=` ${t}`:e.push(`${n}${t}`),e),[n]).join(`
|
|
3
|
+
`)).join(`
|
|
4
|
+
`)}})),O=g(((e,t)=>{t.exports=(e,t,n)=>{n||=t;let r=Math.min(t-n,e-Math.floor(n/2));r<0&&(r=0);let i=Math.min(r+n,t);return{startIndex:r,endIndex:i}}})),k=g(((e,t)=>{t.exports={action:x(),clear:w(),style:E(),strip:S(),figures:T(),lines:D(),wrap:ee(),entriesToDisplay:O()}})),A=g(((e,t)=>{let n=y(`readline`),r=k().action,i=y(`events`),a=C(),o=a.beep,s=a.cursor,c=b();t.exports=class extends i{constructor(e={}){super(),this.firstRender=!0,this.in=e.stdin||process.stdin,this.out=e.stdout||process.stdout,this.onRender=(e.onRender||(()=>void 0)).bind(this);let t=n.createInterface({input:this.in,escapeCodeTimeout:50});n.emitKeypressEvents(this.in,t),this.in.isTTY&&this.in.setRawMode(!0);let i=[`SelectPrompt`,`MultiselectPrompt`].indexOf(this.constructor.name)>-1,a=(e,t)=>{let n=r(t,i);n===!1?this._&&this._(e,t):typeof this[n]==`function`?this[n](t):this.bell()};this.close=()=>{this.out.write(s.show),this.in.removeListener(`keypress`,a),this.in.isTTY&&this.in.setRawMode(!1),t.close(),this.emit(this.aborted?`abort`:this.exited?`exit`:`submit`,this.value),this.closed=!0},this.in.on(`keypress`,a)}fire(){this.emit(`state`,{value:this.value,aborted:!!this.aborted,exited:!!this.exited})}bell(){this.out.write(o)}render(){this.onRender(c),this.firstRender&&=!1}}})),te=g(((e,t)=>{function n(e,t,n,r,i,a,o){try{var s=e[a](o),c=s.value}catch(e){n(e);return}s.done?t(c):Promise.resolve(c).then(r,i)}function r(e){return function(){var t=this,r=arguments;return new Promise(function(i,a){var o=e.apply(t,r);function s(e){n(o,i,a,s,c,`next`,e)}function c(e){n(o,i,a,s,c,`throw`,e)}s(void 0)})}}let i=b(),a=A(),o=C(),s=o.erase,c=o.cursor,l=k(),u=l.style,d=l.clear,f=l.lines,p=l.figures;t.exports=class extends a{constructor(e={}){super(e),this.transform=u.render(e.style),this.scale=this.transform.scale,this.msg=e.message,this.initial=e.initial||``,this.validator=e.validate||(()=>!0),this.value=``,this.errorMsg=e.error||`Please Enter A Valid Value`,this.cursor=Number(!!this.initial),this.cursorOffset=0,this.clear=d(``,this.out.columns),this.render()}set value(e){!e&&this.initial?(this.placeholder=!0,this.rendered=i.gray(this.transform.render(this.initial))):(this.placeholder=!1,this.rendered=this.transform.render(e)),this._value=e,this.fire()}get value(){return this._value}reset(){this.value=``,this.cursor=Number(!!this.initial),this.cursorOffset=0,this.fire(),this.render()}exit(){this.abort()}abort(){this.value=this.value||this.initial,this.done=this.aborted=!0,this.error=!1,this.red=!1,this.fire(),this.render(),this.out.write(`
|
|
5
|
+
`),this.close()}validate(){var e=this;return r(function*(){let t=yield e.validator(e.value);typeof t==`string`&&(e.errorMsg=t,t=!1),e.error=!t})()}submit(){var e=this;return r(function*(){if(e.value=e.value||e.initial,e.cursorOffset=0,e.cursor=e.rendered.length,yield e.validate(),e.error){e.red=!0,e.fire(),e.render();return}e.done=!0,e.aborted=!1,e.fire(),e.render(),e.out.write(`
|
|
6
|
+
`),e.close()})()}next(){if(!this.placeholder)return this.bell();this.value=this.initial,this.cursor=this.rendered.length,this.fire(),this.render()}moveCursor(e){this.placeholder||(this.cursor+=e,this.cursorOffset+=e)}_(e,t){let n=this.value.slice(0,this.cursor);this.value=`${n}${e}${this.value.slice(this.cursor)}`,this.red=!1,this.cursor=this.placeholder?0:n.length+1,this.render()}delete(){if(this.isCursorAtStart())return this.bell();this.value=`${this.value.slice(0,this.cursor-1)}${this.value.slice(this.cursor)}`,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();this.value=`${this.value.slice(0,this.cursor)}${this.value.slice(this.cursor+1)}`,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(c.down(f(this.outputError,this.out.columns)-1)+d(this.outputError,this.out.columns)),this.out.write(d(this.outputText,this.out.columns))),super.render(),this.outputError=``,this.outputText=[u.symbol(this.done,this.aborted),i.bold(this.msg),u.delimiter(this.done),this.red?i.red(this.rendered):this.rendered].join(` `),this.error&&(this.outputError+=this.errorMsg.split(`
|
|
7
|
+
`).reduce((e,t,n)=>e+`\n${n?` `:p.pointerSmall} ${i.red().italic(t)}`,``)),this.out.write(s.line+c.to(0)+this.outputText+c.save+this.outputError+c.restore+c.move(this.cursorOffset,0)))}}})),ne=g(((e,t)=>{let n=b(),r=A(),i=k(),a=i.style,o=i.clear,s=i.figures,c=i.wrap,l=i.entriesToDisplay,u=C().cursor;t.exports=class extends r{constructor(e={}){super(e),this.msg=e.message,this.hint=e.hint||`- Use arrow-keys. Return to submit.`,this.warn=e.warn||`- This option is disabled`,this.cursor=e.initial||0,this.choices=e.choices.map((e,t)=>(typeof e==`string`&&(e={title:e,value:t}),{title:e&&(e.title||e.value||e),value:e&&(e.value===void 0?t:e.value),description:e&&e.description,selected:e&&e.selected,disabled:e&&e.disabled})),this.optionsPerPage=e.optionsPerPage||10,this.value=(this.choices[this.cursor]||{}).value,this.clear=o(``,this.out.columns),this.render()}moveCursor(e){this.cursor=e,this.value=this.choices[e].value,this.fire()}reset(){this.moveCursor(0),this.fire(),this.render()}exit(){this.abort()}abort(){this.done=this.aborted=!0,this.fire(),this.render(),this.out.write(`
|
|
8
|
+
`),this.close()}submit(){this.selection.disabled?this.bell():(this.done=!0,this.aborted=!1,this.fire(),this.render(),this.out.write(`
|
|
9
|
+
`),this.close())}first(){this.moveCursor(0),this.render()}last(){this.moveCursor(this.choices.length-1),this.render()}up(){this.cursor===0?this.moveCursor(this.choices.length-1):this.moveCursor(this.cursor-1),this.render()}down(){this.cursor===this.choices.length-1?this.moveCursor(0):this.moveCursor(this.cursor+1),this.render()}next(){this.moveCursor((this.cursor+1)%this.choices.length),this.render()}_(e,t){if(e===` `)return this.submit()}get selection(){return this.choices[this.cursor]}render(){if(this.closed)return;this.firstRender?this.out.write(u.hide):this.out.write(o(this.outputText,this.out.columns)),super.render();let e=l(this.cursor,this.choices.length,this.optionsPerPage),t=e.startIndex,r=e.endIndex;if(this.outputText=[a.symbol(this.done,this.aborted),n.bold(this.msg),a.delimiter(!1),this.done?this.selection.title:this.selection.disabled?n.yellow(this.warn):n.gray(this.hint)].join(` `),!this.done){this.outputText+=`
|
|
10
|
+
`;for(let e=t;e<r;e++){let i,a,o=``,l=this.choices[e];a=e===t&&t>0?s.arrowUp:e===r-1&&r<this.choices.length?s.arrowDown:` `,l.disabled?(i=this.cursor===e?n.gray().underline(l.title):n.strikethrough().gray(l.title),a=(this.cursor===e?n.bold().gray(s.pointer)+` `:` `)+a):(i=this.cursor===e?n.cyan().underline(l.title):l.title,a=(this.cursor===e?n.cyan(s.pointer)+` `:` `)+a,l.description&&this.cursor===e&&(o=` - ${l.description}`,(a.length+i.length+o.length>=this.out.columns||l.description.split(/\r?\n/).length>1)&&(o=`
|
|
11
|
+
`+c(l.description,{margin:3,width:this.out.columns})))),this.outputText+=`${a} ${i}${n.gray(o)}\n`}}this.out.write(this.outputText)}}})),re=g(((e,t)=>{let n=b(),r=A(),i=k(),a=i.style,o=i.clear,s=C(),c=s.cursor,l=s.erase;t.exports=class extends r{constructor(e={}){super(e),this.msg=e.message,this.value=!!e.initial,this.active=e.active||`on`,this.inactive=e.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(`
|
|
12
|
+
`),this.close()}submit(){this.done=!0,this.aborted=!1,this.fire(),this.render(),this.out.write(`
|
|
13
|
+
`),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()}_(e,t){if(e===` `)this.value=!this.value;else if(e===`1`)this.value=!0;else if(e===`0`)this.value=!1;else return this.bell();this.render()}render(){this.closed||(this.firstRender?this.out.write(c.hide):this.out.write(o(this.outputText,this.out.columns)),super.render(),this.outputText=[a.symbol(this.done,this.aborted),n.bold(this.msg),a.delimiter(this.done),this.value?this.inactive:n.cyan().underline(this.inactive),n.gray(`/`),this.value?n.cyan().underline(this.active):this.active].join(` `),this.out.write(l.line+c.to(0)+this.outputText))}}})),j=g(((e,t)=>{t.exports=class e{constructor({token:e,date:t,parts:n,locales:r}){this.token=e,this.date=t||new Date,this.parts=n||[this],this.locales=r||{}}up(){}down(){}next(){let t=this.parts.indexOf(this);return this.parts.find((n,r)=>r>t&&n instanceof e)}setTo(e){}prev(){let t=[].concat(this.parts).reverse(),n=t.indexOf(this);return t.find((t,r)=>r>n&&t instanceof e)}toString(){return String(this.date)}}})),ie=g(((e,t)=>{let n=j();t.exports=class extends n{constructor(e={}){super(e)}up(){this.date.setHours((this.date.getHours()+12)%24)}down(){this.up()}toString(){let e=this.date.getHours()>12?`pm`:`am`;return/\A/.test(this.token)?e.toUpperCase():e}}})),ae=g(((e,t)=>{let n=j(),r=e=>(e%=10,e===1?`st`:e===2?`nd`:e===3?`rd`:`th`);t.exports=class extends n{constructor(e={}){super(e)}up(){this.date.setDate(this.date.getDate()+1)}down(){this.date.setDate(this.date.getDate()-1)}setTo(e){this.date.setDate(parseInt(e.substr(-2)))}toString(){let e=this.date.getDate(),t=this.date.getDay();return this.token===`DD`?String(e).padStart(2,`0`):this.token===`Do`?e+r(e):this.token===`d`?t+1:this.token===`ddd`?this.locales.weekdaysShort[t]:this.token===`dddd`?this.locales.weekdays[t]:e}}})),oe=g(((e,t)=>{let n=j();t.exports=class extends n{constructor(e={}){super(e)}up(){this.date.setHours(this.date.getHours()+1)}down(){this.date.setHours(this.date.getHours()-1)}setTo(e){this.date.setHours(parseInt(e.substr(-2)))}toString(){let e=this.date.getHours();return/h/.test(this.token)&&(e=e%12||12),this.token.length>1?String(e).padStart(2,`0`):e}}})),se=g(((e,t)=>{let n=j();t.exports=class extends n{constructor(e={}){super(e)}up(){this.date.setMilliseconds(this.date.getMilliseconds()+1)}down(){this.date.setMilliseconds(this.date.getMilliseconds()-1)}setTo(e){this.date.setMilliseconds(parseInt(e.substr(-this.token.length)))}toString(){return String(this.date.getMilliseconds()).padStart(4,`0`).substr(0,this.token.length)}}})),ce=g(((e,t)=>{let n=j();t.exports=class extends n{constructor(e={}){super(e)}up(){this.date.setMinutes(this.date.getMinutes()+1)}down(){this.date.setMinutes(this.date.getMinutes()-1)}setTo(e){this.date.setMinutes(parseInt(e.substr(-2)))}toString(){let e=this.date.getMinutes();return this.token.length>1?String(e).padStart(2,`0`):e}}})),M=g(((e,t)=>{let n=j();t.exports=class extends n{constructor(e={}){super(e)}up(){this.date.setMonth(this.date.getMonth()+1)}down(){this.date.setMonth(this.date.getMonth()-1)}setTo(e){e=parseInt(e.substr(-2))-1,this.date.setMonth(e<0?0:e)}toString(){let e=this.date.getMonth(),t=this.token.length;return t===2?String(e+1).padStart(2,`0`):t===3?this.locales.monthsShort[e]:t===4?this.locales.months[e]:String(e+1)}}})),N=g(((e,t)=>{let n=j();t.exports=class extends n{constructor(e={}){super(e)}up(){this.date.setSeconds(this.date.getSeconds()+1)}down(){this.date.setSeconds(this.date.getSeconds()-1)}setTo(e){this.date.setSeconds(parseInt(e.substr(-2)))}toString(){let e=this.date.getSeconds();return this.token.length>1?String(e).padStart(2,`0`):e}}})),P=g(((e,t)=>{let n=j();t.exports=class extends n{constructor(e={}){super(e)}up(){this.date.setFullYear(this.date.getFullYear()+1)}down(){this.date.setFullYear(this.date.getFullYear()-1)}setTo(e){this.date.setFullYear(e.substr(-4))}toString(){let e=String(this.date.getFullYear()).padStart(4,`0`);return this.token.length===2?e.substr(-2):e}}})),F=g(((e,t)=>{t.exports={DatePart:j(),Meridiem:ie(),Day:ae(),Hours:oe(),Milliseconds:se(),Minutes:ce(),Month:M(),Seconds:N(),Year:P()}})),I=g(((e,t)=>{function n(e,t,n,r,i,a,o){try{var s=e[a](o),c=s.value}catch(e){n(e);return}s.done?t(c):Promise.resolve(c).then(r,i)}function r(e){return function(){var t=this,r=arguments;return new Promise(function(i,a){var o=e.apply(t,r);function s(e){n(o,i,a,s,c,`next`,e)}function c(e){n(o,i,a,s,c,`throw`,e)}s(void 0)})}}let i=b(),a=A(),o=k(),s=o.style,c=o.clear,l=o.figures,u=C(),d=u.erase,f=u.cursor,p=F(),m=p.DatePart,h=p.Meridiem,g=p.Day,_=p.Hours,v=p.Milliseconds,y=p.Minutes,x=p.Month,S=p.Seconds,w=p.Year,T=/\\(.)|"((?:\\["\\]|[^"])+)"|(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,E={1:({token:e})=>e.replace(/\\(.)/g,`$1`),2:e=>new g(e),3:e=>new x(e),4:e=>new w(e),5:e=>new h(e),6:e=>new _(e),7:e=>new y(e),8:e=>new S(e),9:e=>new v(e)},D={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(`,`)};t.exports=class extends a{constructor(e={}){super(e),this.msg=e.message,this.cursor=0,this.typed=``,this.locales=Object.assign(D,e.locales),this._date=e.initial||new Date,this.errorMsg=e.error||`Please Enter A Valid Value`,this.validator=e.validate||(()=>!0),this.mask=e.mask||`YYYY-MM-DD HH:mm:ss`,this.clear=c(``,this.out.columns),this.render()}get value(){return this.date}get date(){return this._date}set date(e){e&&this._date.setTime(e.getTime())}set mask(e){let t;for(this.parts=[];t=T.exec(e);){let e=t.shift(),n=t.findIndex(e=>e!=null);this.parts.push(n in E?E[n]({token:t[n]||e,date:this.date,parts:this.parts,locales:this.locales}):t[n]||e)}let n=this.parts.reduce((e,t)=>(typeof t==`string`&&typeof e[e.length-1]==`string`?e[e.length-1]+=t:e.push(t),e),[]);this.parts.splice(0),this.parts.push(...n),this.reset()}moveCursor(e){this.typed=``,this.cursor=e,this.fire()}reset(){this.moveCursor(this.parts.findIndex(e=>e instanceof m)),this.fire(),this.render()}exit(){this.abort()}abort(){this.done=this.aborted=!0,this.error=!1,this.fire(),this.render(),this.out.write(`
|
|
14
|
+
`),this.close()}validate(){var e=this;return r(function*(){let t=yield e.validator(e.value);typeof t==`string`&&(e.errorMsg=t,t=!1),e.error=!t})()}submit(){var e=this;return r(function*(){if(yield e.validate(),e.error){e.color=`red`,e.fire(),e.render();return}e.done=!0,e.aborted=!1,e.fire(),e.render(),e.out.write(`
|
|
15
|
+
`),e.close()})()}up(){this.typed=``,this.parts[this.cursor].up(),this.render()}down(){this.typed=``,this.parts[this.cursor].down(),this.render()}left(){let e=this.parts[this.cursor].prev();if(e==null)return this.bell();this.moveCursor(this.parts.indexOf(e)),this.render()}right(){let e=this.parts[this.cursor].next();if(e==null)return this.bell();this.moveCursor(this.parts.indexOf(e)),this.render()}next(){let e=this.parts[this.cursor].next();this.moveCursor(e?this.parts.indexOf(e):this.parts.findIndex(e=>e instanceof m)),this.render()}_(e){/\d/.test(e)&&(this.typed+=e,this.parts[this.cursor].setTo(this.typed),this.render())}render(){this.closed||(this.firstRender?this.out.write(f.hide):this.out.write(c(this.outputText,this.out.columns)),super.render(),this.outputText=[s.symbol(this.done,this.aborted),i.bold(this.msg),s.delimiter(!1),this.parts.reduce((e,t,n)=>e.concat(n===this.cursor&&!this.done?i.cyan().underline(t.toString()):t),[]).join(``)].join(` `),this.error&&(this.outputText+=this.errorMsg.split(`
|
|
16
|
+
`).reduce((e,t,n)=>e+`\n${n?` `:l.pointerSmall} ${i.red().italic(t)}`,``)),this.out.write(d.line+f.to(0)+this.outputText))}}})),L=g(((e,t)=>{function n(e,t,n,r,i,a,o){try{var s=e[a](o),c=s.value}catch(e){n(e);return}s.done?t(c):Promise.resolve(c).then(r,i)}function r(e){return function(){var t=this,r=arguments;return new Promise(function(i,a){var o=e.apply(t,r);function s(e){n(o,i,a,s,c,`next`,e)}function c(e){n(o,i,a,s,c,`throw`,e)}s(void 0)})}}let i=b(),a=A(),o=C(),s=o.cursor,c=o.erase,l=k(),u=l.style,d=l.figures,f=l.clear,p=l.lines,m=/[0-9]/,h=e=>e!==void 0,g=(e,t)=>{let n=10**t;return Math.round(e*n)/n};t.exports=class extends a{constructor(e={}){super(e),this.transform=u.render(e.style),this.msg=e.message,this.initial=h(e.initial)?e.initial:``,this.float=!!e.float,this.round=e.round||2,this.inc=e.increment||1,this.min=h(e.min)?e.min:-1/0,this.max=h(e.max)?e.max:1/0,this.errorMsg=e.error||`Please Enter A Valid Value`,this.validator=e.validate||(()=>!0),this.color=`cyan`,this.value=``,this.typed=``,this.lastHit=0,this.render()}set value(e){!e&&e!==0?(this.placeholder=!0,this.rendered=i.gray(this.transform.render(`${this.initial}`)),this._value=``):(this.placeholder=!1,this.rendered=this.transform.render(`${g(e,this.round)}`),this._value=g(e,this.round)),this.fire()}get value(){return this._value}parse(e){return this.float?parseFloat(e):parseInt(e)}valid(e){return e===`-`||e===`.`&&this.float||m.test(e)}reset(){this.typed=``,this.value=``,this.fire(),this.render()}exit(){this.abort()}abort(){let e=this.value;this.value=e===``?this.initial:e,this.done=this.aborted=!0,this.error=!1,this.fire(),this.render(),this.out.write(`
|
|
17
|
+
`),this.close()}validate(){var e=this;return r(function*(){let t=yield e.validator(e.value);typeof t==`string`&&(e.errorMsg=t,t=!1),e.error=!t})()}submit(){var e=this;return r(function*(){if(yield e.validate(),e.error){e.color=`red`,e.fire(),e.render();return}let t=e.value;e.value=t===``?e.initial:t,e.done=!0,e.aborted=!1,e.error=!1,e.fire(),e.render(),e.out.write(`
|
|
18
|
+
`),e.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 e=this.value.toString();if(e.length===0)return this.bell();this.value=this.parse(e=e.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()}_(e,t){if(!this.valid(e))return this.bell();let n=Date.now();if(n-this.lastHit>1e3&&(this.typed=``),this.typed+=e,this.lastHit=n,this.color=`cyan`,e===`.`)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(s.down(p(this.outputError,this.out.columns)-1)+f(this.outputError,this.out.columns)),this.out.write(f(this.outputText,this.out.columns))),super.render(),this.outputError=``,this.outputText=[u.symbol(this.done,this.aborted),i.bold(this.msg),u.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(`
|
|
19
|
+
`).reduce((e,t,n)=>e+`\n${n?` `:d.pointerSmall} ${i.red().italic(t)}`,``)),this.out.write(c.line+s.to(0)+this.outputText+s.save+this.outputError+s.restore))}}})),R=g(((e,t)=>{let n=b(),r=C().cursor,i=A(),a=k(),o=a.clear,s=a.figures,c=a.style,l=a.wrap,u=a.entriesToDisplay;t.exports=class extends i{constructor(e={}){super(e),this.msg=e.message,this.cursor=e.cursor||0,this.scrollIndex=e.cursor||0,this.hint=e.hint||``,this.warn=e.warn||`- This option is disabled -`,this.minSelected=e.min,this.showMinError=!1,this.maxChoices=e.max,this.instructions=e.instructions,this.optionsPerPage=e.optionsPerPage||10,this.value=e.choices.map((e,t)=>(typeof e==`string`&&(e={title:e,value:t}),{title:e&&(e.title||e.value||e),description:e&&e.description,value:e&&(e.value===void 0?t:e.value),selected:e&&e.selected,disabled:e&&e.disabled})),this.clear=o(``,this.out.columns),e.overrideRender||this.render()}reset(){this.value.map(e=>!e.selected),this.cursor=0,this.fire(),this.render()}selected(){return this.value.filter(e=>e.selected)}exit(){this.abort()}abort(){this.done=this.aborted=!0,this.fire(),this.render(),this.out.write(`
|
|
20
|
+
`),this.close()}submit(){let e=this.value.filter(e=>e.selected);this.minSelected&&e.length<this.minSelected?(this.showMinError=!0,this.render()):(this.done=!0,this.aborted=!1,this.fire(),this.render(),this.out.write(`
|
|
21
|
+
`),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(e=>e.selected).length>=this.maxChoices)return this.bell();this.value[this.cursor].selected=!0,this.render()}handleSpaceToggle(){let e=this.value[this.cursor];if(e.selected)e.selected=!1,this.render();else if(e.disabled||this.value.filter(e=>e.selected).length>=this.maxChoices)return this.bell();else e.selected=!0,this.render()}toggleAll(){if(this.maxChoices!==void 0||this.value[this.cursor].disabled)return this.bell();let e=!this.value[this.cursor].selected;this.value.filter(e=>!e.disabled).forEach(t=>t.selected=e),this.render()}_(e,t){if(e===` `)this.handleSpaceToggle();else if(e===`a`)this.toggleAll();else return this.bell()}renderInstructions(){return this.instructions===void 0||this.instructions?typeof this.instructions==`string`?this.instructions:`
|
|
22
|
+
Instructions:
|
|
23
|
+
${s.arrowUp}/${s.arrowDown}: Highlight option\n ${s.arrowLeft}/${s.arrowRight}/[space]: Toggle selection\n`+(this.maxChoices===void 0?` a: Toggle all
|
|
24
|
+
`:``)+` enter/return: Complete answer`:``}renderOption(e,t,r,i){let a=(t.selected?n.green(s.radioOn):s.radioOff)+` `+i+` `,o,c;return t.disabled?o=e===r?n.gray().underline(t.title):n.strikethrough().gray(t.title):(o=e===r?n.cyan().underline(t.title):t.title,e===r&&t.description&&(c=` - ${t.description}`,(a.length+o.length+c.length>=this.out.columns||t.description.split(/\r?\n/).length>1)&&(c=`
|
|
25
|
+
`+l(t.description,{margin:a.length,width:this.out.columns})))),a+o+n.gray(c||``)}paginateOptions(e){if(e.length===0)return n.red(`No matches for this query.`);let t=u(this.cursor,e.length,this.optionsPerPage),r=t.startIndex,i=t.endIndex,a,o=[];for(let t=r;t<i;t++)a=t===r&&r>0?s.arrowUp:t===i-1&&i<e.length?s.arrowDown:` `,o.push(this.renderOption(this.cursor,e[t],t,a));return`
|
|
26
|
+
`+o.join(`
|
|
27
|
+
`)}renderOptions(e){return this.done?``:this.paginateOptions(e)}renderDoneOrInstructions(){if(this.done)return this.value.filter(e=>e.selected).map(e=>e.title).join(`, `);let e=[n.gray(this.hint),this.renderInstructions()];return this.value[this.cursor].disabled&&e.push(n.yellow(this.warn)),e.join(` `)}render(){if(this.closed)return;this.firstRender&&this.out.write(r.hide),super.render();let e=[c.symbol(this.done,this.aborted),n.bold(this.msg),c.delimiter(!1),this.renderDoneOrInstructions()].join(` `);this.showMinError&&=(e+=n.red(`You must select a minimum of ${this.minSelected} choices.`),!1),e+=this.renderOptions(this.value),this.out.write(this.clear+e),this.clear=o(e,this.out.columns)}}})),z=g(((e,t)=>{function n(e,t,n,r,i,a,o){try{var s=e[a](o),c=s.value}catch(e){n(e);return}s.done?t(c):Promise.resolve(c).then(r,i)}function r(e){return function(){var t=this,r=arguments;return new Promise(function(i,a){var o=e.apply(t,r);function s(e){n(o,i,a,s,c,`next`,e)}function c(e){n(o,i,a,s,c,`throw`,e)}s(void 0)})}}let i=b(),a=A(),o=C(),s=o.erase,c=o.cursor,l=k(),u=l.style,d=l.clear,f=l.figures,p=l.wrap,m=l.entriesToDisplay,h=(e,t)=>e[t]&&(e[t].value||e[t].title||e[t]),g=(e,t)=>e[t]&&(e[t].title||e[t].value||e[t]),_=(e,t)=>{let n=e.findIndex(e=>e.value===t||e.title===t);return n>-1?n:void 0};t.exports=class extends a{constructor(e={}){super(e),this.msg=e.message,this.suggest=e.suggest,this.choices=e.choices,this.initial=typeof e.initial==`number`?e.initial:_(e.choices,e.initial),this.select=this.initial||e.cursor||0,this.i18n={noMatches:e.noMatches||`no matches found`},this.fallback=e.fallback||this.initial,this.clearFirst=e.clearFirst||!1,this.suggestions=[],this.input=``,this.limit=e.limit||10,this.cursor=0,this.transform=u.render(e.style),this.scale=this.transform.scale,this.render=this.render.bind(this),this.complete=this.complete.bind(this),this.clear=d(``,this.out.columns),this.complete(this.render),this.render()}set fallback(e){this._fb=Number.isSafeInteger(parseInt(e))?parseInt(e):e}get fallback(){let e;return typeof this._fb==`number`?e=this.choices[this._fb]:typeof this._fb==`string`&&(e={title:this._fb}),e||this._fb||{title:this.i18n.noMatches}}moveSelect(e){this.select=e,this.suggestions.length>0?this.value=h(this.suggestions,e):this.value=this.fallback.value,this.fire()}complete(e){var t=this;return r(function*(){let n=t.completing=t.suggest(t.input,t.choices),r=yield n;if(t.completing!==n)return;t.suggestions=r.map((e,t,n)=>({title:g(n,t),value:h(n,t),description:e.description})),t.completing=!1;let i=Math.max(r.length-1,0);t.moveSelect(Math.min(i,t.select)),e&&e()})()}reset(){this.input=``,this.complete(()=>{this.moveSelect(this.initial===void 0?0:this.initial),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(`
|
|
28
|
+
`),this.close())}abort(){this.done=this.aborted=!0,this.exited=!1,this.fire(),this.render(),this.out.write(`
|
|
29
|
+
`),this.close()}submit(){this.done=!0,this.aborted=this.exited=!1,this.fire(),this.render(),this.out.write(`
|
|
30
|
+
`),this.close()}_(e,t){let n=this.input.slice(0,this.cursor);this.input=`${n}${e}${this.input.slice(this.cursor)}`,this.cursor=n.length+1,this.complete(this.render),this.render()}delete(){if(this.cursor===0)return this.bell();this.input=`${this.input.slice(0,this.cursor-1)}${this.input.slice(this.cursor)}`,this.complete(this.render),--this.cursor,this.render()}deleteForward(){if(this.cursor*this.scale>=this.rendered.length)return this.bell();this.input=`${this.input.slice(0,this.cursor)}${this.input.slice(this.cursor+1)}`,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.render()}right(){if(this.cursor*this.scale>=this.rendered.length)return this.bell();this.cursor+=1,this.render()}renderOption(e,t,n,r){let a,o=n?f.arrowUp:r?f.arrowDown:` `,s=t?i.cyan().underline(e.title):e.title;return o=(t?i.cyan(f.pointer)+` `:` `)+o,e.description&&(a=` - ${e.description}`,(o.length+s.length+a.length>=this.out.columns||e.description.split(/\r?\n/).length>1)&&(a=`
|
|
31
|
+
`+p(e.description,{margin:3,width:this.out.columns}))),o+` `+s+i.gray(a||``)}render(){if(this.closed)return;this.firstRender?this.out.write(c.hide):this.out.write(d(this.outputText,this.out.columns)),super.render();let e=m(this.select,this.choices.length,this.limit),t=e.startIndex,n=e.endIndex;if(this.outputText=[u.symbol(this.done,this.aborted,this.exited),i.bold(this.msg),u.delimiter(this.completing),this.done&&this.suggestions[this.select]?this.suggestions[this.select].title:this.rendered=this.transform.render(this.input)].join(` `),!this.done){let e=this.suggestions.slice(t,n).map((e,r)=>this.renderOption(e,this.select===r+t,r===0&&t>0,r+t===n-1&&n<this.choices.length)).join(`
|
|
32
|
+
`);this.outputText+=`
|
|
33
|
+
`+(e||i.gray(this.fallback.title))}this.out.write(s.line+c.to(0)+this.outputText)}}})),B=g(((e,t)=>{let n=b(),r=C().cursor,i=R(),a=k(),o=a.clear,s=a.style,c=a.figures;t.exports=class extends i{constructor(e={}){e.overrideRender=!0,super(e),this.inputValue=``,this.clear=o(``,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(e=>e.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(){let e=this.filteredOptions[this.cursor];this.filteredOptions=this.value.filter(e=>this.inputValue?!!(typeof e.title==`string`&&e.title.toLowerCase().includes(this.inputValue.toLowerCase())||typeof e.value==`string`&&e.value.toLowerCase().includes(this.inputValue.toLowerCase())):!0);let t=this.filteredOptions.findIndex(t=>t===e);this.cursor=t<0?0:t,this.render()}handleSpaceToggle(){let e=this.filteredOptions[this.cursor];if(e.selected)e.selected=!1,this.render();else if(e.disabled||this.value.filter(e=>e.selected).length>=this.maxChoices)return this.bell();else e.selected=!0,this.render()}handleInputChange(e){this.inputValue+=e,this.updateFilteredOptions()}_(e,t){e===` `?this.handleSpaceToggle():this.handleInputChange(e)}renderInstructions(){return this.instructions===void 0||this.instructions?typeof this.instructions==`string`?this.instructions:`
|
|
34
|
+
Instructions:
|
|
35
|
+
${c.arrowUp}/${c.arrowDown}: Highlight option
|
|
36
|
+
${c.arrowLeft}/${c.arrowRight}/[space]: Toggle selection
|
|
37
|
+
[a,b,c]/delete: Filter choices
|
|
38
|
+
enter/return: Complete answer
|
|
39
|
+
`:``}renderCurrentInput(){return`
|
|
40
|
+
Filtered results for: ${this.inputValue?this.inputValue:n.gray(`Enter something to filter`)}\n`}renderOption(e,t,r){let i;return i=t.disabled?e===r?n.gray().underline(t.title):n.strikethrough().gray(t.title):e===r?n.cyan().underline(t.title):t.title,(t.selected?n.green(c.radioOn):c.radioOff)+` `+i}renderDoneOrInstructions(){if(this.done)return this.value.filter(e=>e.selected).map(e=>e.title).join(`, `);let e=[n.gray(this.hint),this.renderInstructions(),this.renderCurrentInput()];return this.filteredOptions.length&&this.filteredOptions[this.cursor].disabled&&e.push(n.yellow(this.warn)),e.join(` `)}render(){if(this.closed)return;this.firstRender&&this.out.write(r.hide),super.render();let e=[s.symbol(this.done,this.aborted),n.bold(this.msg),s.delimiter(!1),this.renderDoneOrInstructions()].join(` `);this.showMinError&&=(e+=n.red(`You must select a minimum of ${this.minSelected} choices.`),!1),e+=this.renderOptions(this.filteredOptions),this.out.write(this.clear+e),this.clear=o(e,this.out.columns)}}})),V=g(((e,t)=>{let n=b(),r=A(),i=k(),a=i.style,o=i.clear,s=C(),c=s.erase,l=s.cursor;t.exports=class extends r{constructor(e={}){super(e),this.msg=e.message,this.value=e.initial,this.initialValue=!!e.initial,this.yesMsg=e.yes||`yes`,this.yesOption=e.yesOption||`(Y/n)`,this.noMsg=e.no||`no`,this.noOption=e.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(`
|
|
41
|
+
`),this.close()}submit(){this.value=this.value||!1,this.done=!0,this.aborted=!1,this.fire(),this.render(),this.out.write(`
|
|
42
|
+
`),this.close()}_(e,t){return e.toLowerCase()===`y`?(this.value=!0,this.submit()):e.toLowerCase()===`n`?(this.value=!1,this.submit()):this.bell()}render(){this.closed||(this.firstRender?this.out.write(l.hide):this.out.write(o(this.outputText,this.out.columns)),super.render(),this.outputText=[a.symbol(this.done,this.aborted),n.bold(this.msg),a.delimiter(this.done),this.done?this.value?this.yesMsg:this.noMsg:n.gray(this.initialValue?this.yesOption:this.noOption)].join(` `),this.out.write(c.line+l.to(0)+this.outputText))}}})),H=g(((e,t)=>{t.exports={TextPrompt:te(),SelectPrompt:ne(),TogglePrompt:re(),DatePrompt:I(),NumberPrompt:L(),MultiselectPrompt:R(),AutocompletePrompt:z(),AutocompleteMultiselectPrompt:B(),ConfirmPrompt:V()}})),U=g((e=>{let t=e,n=H(),r=e=>e;function i(e,t,i={}){return new Promise((a,o)=>{let s=new n[e](t),c=i.onAbort||r,l=i.onSubmit||r,u=i.onExit||r;s.on(`state`,t.onState||r),s.on(`submit`,e=>a(l(e))),s.on(`exit`,e=>a(u(e))),s.on(`abort`,e=>o(c(e)))})}t.text=e=>i(`TextPrompt`,e),t.password=e=>(e.style=`password`,t.text(e)),t.invisible=e=>(e.style=`invisible`,t.text(e)),t.number=e=>i(`NumberPrompt`,e),t.date=e=>i(`DatePrompt`,e),t.confirm=e=>i(`ConfirmPrompt`,e),t.list=e=>{let t=e.separator||`,`;return i(`TextPrompt`,e,{onSubmit:e=>e.split(t).map(e=>e.trim())})},t.toggle=e=>i(`TogglePrompt`,e),t.select=e=>i(`SelectPrompt`,e),t.multiselect=e=>{e.choices=[].concat(e.choices||[]);let t=e=>e.filter(e=>e.selected).map(e=>e.value);return i(`MultiselectPrompt`,e,{onAbort:t,onSubmit:t})},t.autocompleteMultiselect=e=>{e.choices=[].concat(e.choices||[]);let t=e=>e.filter(e=>e.selected).map(e=>e.value);return i(`AutocompleteMultiselectPrompt`,e,{onAbort:t,onSubmit:t})};let a=(e,t)=>Promise.resolve(t.filter(t=>t.title.slice(0,e.length).toLowerCase()===e.toLowerCase()));t.autocomplete=e=>(e.suggest=e.suggest||a,e.choices=[].concat(e.choices||[]),i(`AutocompletePrompt`,e))})),W=g(((e,t)=>{function n(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function r(e){for(var t=1;t<arguments.length;t++){var r=arguments[t]==null?{}:arguments[t];t%2?n(Object(r),!0).forEach(function(t){i(e,t,r[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):n(Object(r)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))})}return e}function i(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function a(e,t){var n=typeof Symbol<`u`&&e[Symbol.iterator]||e[`@@iterator`];if(!n){if(Array.isArray(e)||(n=o(e))||t&&e&&typeof e.length==`number`){n&&(e=n);var r=0,i=function(){};return{s:i,n:function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}},e:function(e){throw e},f:i}}throw TypeError(`Invalid attempt to iterate non-iterable instance.
|
|
43
|
+
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}var a=!0,s=!1,c;return{s:function(){n=n.call(e)},n:function(){var e=n.next();return a=e.done,e},e:function(e){s=!0,c=e},f:function(){try{!a&&n.return!=null&&n.return()}finally{if(s)throw c}}}}function o(e,t){if(e){if(typeof e==`string`)return s(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);if(n===`Object`&&e.constructor&&(n=e.constructor.name),n===`Map`||n===`Set`)return Array.from(e);if(n===`Arguments`||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return s(e,t)}}function s(e,t){(t==null||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function c(e,t,n,r,i,a,o){try{var s=e[a](o),c=s.value}catch(e){n(e);return}s.done?t(c):Promise.resolve(c).then(r,i)}function l(e){return function(){var t=this,n=arguments;return new Promise(function(r,i){var a=e.apply(t,n);function o(e){c(a,r,i,o,s,`next`,e)}function s(e){c(a,r,i,o,s,`throw`,e)}o(void 0)})}}let u=U(),d=[`suggest`,`format`,`onState`,`validate`,`onRender`,`type`],f=()=>{};function p(){return m.apply(this,arguments)}function m(){return m=l(function*(e=[],{onSubmit:t=f,onCancel:n=f}={}){let i={},o=p._override||{};e=[].concat(e);let s,c,m,g,_,v,y=function(){var e=l(function*(e,t,n=!1){if(!(!n&&e.validate&&e.validate(t)!==!0))return e.format?yield e.format(t,i):t});return function(t,n){return e.apply(this,arguments)}}();var b=a(e),x;try{for(b.s();!(x=b.n()).done;){c=x.value;var S=c;if(g=S.name,_=S.type,typeof _==`function`&&(_=yield _(s,r({},i),c),c.type=_),_){for(let e in c){if(d.includes(e))continue;let t=c[e];c[e]=typeof t==`function`?yield t(s,r({},i),v):t}if(v=c,typeof c.message!=`string`)throw Error(`prompt message is required`);var C=c;if(g=C.name,_=C.type,u[_]===void 0)throw Error(`prompt type (${_}) is not defined`);if(o[c.name]!==void 0&&(s=yield y(c,o[c.name]),s!==void 0)){i[g]=s;continue}try{s=p._injected?h(p._injected,c.initial):yield u[_](c),i[g]=s=yield y(c,s,!0),m=yield t(c,s,i)}catch{m=!(yield n(c,i))}if(m)return i}}}catch(e){b.e(e)}finally{b.f()}return i}),m.apply(this,arguments)}function h(e,t){let n=e.shift();if(n instanceof Error)throw n;return n===void 0?t:n}function g(e){p._injected=(p._injected||[]).concat(e)}function _(e){p._override=Object.assign({},e)}t.exports=Object.assign(p,{prompt:p,prompts:u,inject:g,override:_})})),G=g(((e,t)=>{t.exports=(e,t)=>{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(t){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}}})),K=g(((e,t)=>{t.exports=e=>{let t=[`[\\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(`|`),n=new RegExp(t,`g`);return typeof e==`string`?e.replace(n,``):e}})),le=g(((e,t)=>{let n=K(),{erase:r,cursor:i}=C(),a=e=>[...n(e)].length;t.exports=function(e,t){if(!t)return r.line+i.to(0);let n=0,o=e.split(/\r?\n/);for(let e of o)n+=1+Math.floor(Math.max(a(e)-1,0)/t);return r.lines(n)}})),q=g(((e,t)=>{let n={arrowUp:`↑`,arrowDown:`↓`,arrowLeft:`←`,arrowRight:`→`,radioOn:`◉`,radioOff:`◯`,tick:`✔`,cross:`✖`,ellipsis:`…`,pointerSmall:`›`,line:`─`,pointer:`❯`},r={arrowUp:n.arrowUp,arrowDown:n.arrowDown,arrowLeft:n.arrowLeft,arrowRight:n.arrowRight,radioOn:`(*)`,radioOff:`( )`,tick:`√`,cross:`×`,ellipsis:`...`,pointerSmall:`»`,line:`─`,pointer:`>`};t.exports=process.platform===`win32`?r:n})),ue=g(((e,t)=>{let n=b(),r=q(),i=Object.freeze({password:{scale:1,render:e=>`*`.repeat(e.length)},emoji:{scale:2,render:e=>`😃`.repeat(e.length)},invisible:{scale:0,render:e=>``},default:{scale:1,render:e=>`${e}`}}),a=e=>i[e]||i.default,o=Object.freeze({aborted:n.red(r.cross),done:n.green(r.tick),exited:n.yellow(r.cross),default:n.cyan(`?`)});t.exports={styles:i,render:a,symbols:o,symbol:(e,t,n)=>t?o.aborted:n?o.exited:e?o.done:o.default,delimiter:e=>n.gray(e?r.ellipsis:r.pointerSmall),item:(e,t)=>n.gray(e?t?r.pointerSmall:`+`:r.line)}})),de=g(((e,t)=>{let n=K();t.exports=function(e,t){let r=String(n(e)||``).split(/\r?\n/);return t?r.map(e=>Math.ceil(e.length/t)).reduce((e,t)=>e+t):r.length}})),fe=g(((e,t)=>{t.exports=(e,t={})=>{let n=Number.isSafeInteger(parseInt(t.margin))?Array(parseInt(t.margin)).fill(` `).join(``):t.margin||``,r=t.width;return(e||``).split(/\r?\n/g).map(e=>e.split(/\s+/g).reduce((e,t)=>(t.length+n.length>=r||e[e.length-1].length+t.length+1<r?e[e.length-1]+=` ${t}`:e.push(`${n}${t}`),e),[n]).join(`
|
|
44
|
+
`)).join(`
|
|
45
|
+
`)}})),pe=g(((e,t)=>{t.exports=(e,t,n)=>{n||=t;let r=Math.min(t-n,e-Math.floor(n/2));r<0&&(r=0);let i=Math.min(r+n,t);return{startIndex:r,endIndex:i}}})),J=g(((e,t)=>{t.exports={action:G(),clear:le(),style:ue(),strip:K(),figures:q(),lines:de(),wrap:fe(),entriesToDisplay:pe()}})),Y=g(((e,t)=>{let n=y(`readline`),{action:r}=J(),i=y(`events`),{beep:a,cursor:o}=C(),s=b();t.exports=class extends i{constructor(e={}){super(),this.firstRender=!0,this.in=e.stdin||process.stdin,this.out=e.stdout||process.stdout,this.onRender=(e.onRender||(()=>void 0)).bind(this);let t=n.createInterface({input:this.in,escapeCodeTimeout:50});n.emitKeypressEvents(this.in,t),this.in.isTTY&&this.in.setRawMode(!0);let i=[`SelectPrompt`,`MultiselectPrompt`].indexOf(this.constructor.name)>-1,a=(e,t)=>{let n=r(t,i);n===!1?this._&&this._(e,t):typeof this[n]==`function`?this[n](t):this.bell()};this.close=()=>{this.out.write(o.show),this.in.removeListener(`keypress`,a),this.in.isTTY&&this.in.setRawMode(!1),t.close(),this.emit(this.aborted?`abort`:this.exited?`exit`:`submit`,this.value),this.closed=!0},this.in.on(`keypress`,a)}fire(){this.emit(`state`,{value:this.value,aborted:!!this.aborted,exited:!!this.exited})}bell(){this.out.write(a)}render(){this.onRender(s),this.firstRender&&=!1}}})),me=g(((e,t)=>{let n=b(),r=Y(),{erase:i,cursor:a}=C(),{style:o,clear:s,lines:c,figures:l}=J();t.exports=class extends r{constructor(e={}){super(e),this.transform=o.render(e.style),this.scale=this.transform.scale,this.msg=e.message,this.initial=e.initial||``,this.validator=e.validate||(()=>!0),this.value=``,this.errorMsg=e.error||`Please Enter A Valid Value`,this.cursor=Number(!!this.initial),this.cursorOffset=0,this.clear=s(``,this.out.columns),this.render()}set value(e){!e&&this.initial?(this.placeholder=!0,this.rendered=n.gray(this.transform.render(this.initial))):(this.placeholder=!1,this.rendered=this.transform.render(e)),this._value=e,this.fire()}get value(){return this._value}reset(){this.value=``,this.cursor=Number(!!this.initial),this.cursorOffset=0,this.fire(),this.render()}exit(){this.abort()}abort(){this.value=this.value||this.initial,this.done=this.aborted=!0,this.error=!1,this.red=!1,this.fire(),this.render(),this.out.write(`
|
|
46
|
+
`),this.close()}async validate(){let e=await this.validator(this.value);typeof e==`string`&&(this.errorMsg=e,e=!1),this.error=!e}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(`
|
|
47
|
+
`),this.close()}next(){if(!this.placeholder)return this.bell();this.value=this.initial,this.cursor=this.rendered.length,this.fire(),this.render()}moveCursor(e){this.placeholder||(this.cursor+=e,this.cursorOffset+=e)}_(e,t){let n=this.value.slice(0,this.cursor);this.value=`${n}${e}${this.value.slice(this.cursor)}`,this.red=!1,this.cursor=this.placeholder?0:n.length+1,this.render()}delete(){if(this.isCursorAtStart())return this.bell();this.value=`${this.value.slice(0,this.cursor-1)}${this.value.slice(this.cursor)}`,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();this.value=`${this.value.slice(0,this.cursor)}${this.value.slice(this.cursor+1)}`,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(a.down(c(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),n.bold(this.msg),o.delimiter(this.done),this.red?n.red(this.rendered):this.rendered].join(` `),this.error&&(this.outputError+=this.errorMsg.split(`
|
|
48
|
+
`).reduce((e,t,r)=>e+`\n${r?` `:l.pointerSmall} ${n.red().italic(t)}`,``)),this.out.write(i.line+a.to(0)+this.outputText+a.save+this.outputError+a.restore+a.move(this.cursorOffset,0)))}}})),he=g(((e,t)=>{let n=b(),r=Y(),{style:i,clear:a,figures:o,wrap:s,entriesToDisplay:c}=J(),{cursor:l}=C();t.exports=class extends r{constructor(e={}){super(e),this.msg=e.message,this.hint=e.hint||`- Use arrow-keys. Return to submit.`,this.warn=e.warn||`- This option is disabled`,this.cursor=e.initial||0,this.choices=e.choices.map((e,t)=>(typeof e==`string`&&(e={title:e,value:t}),{title:e&&(e.title||e.value||e),value:e&&(e.value===void 0?t:e.value),description:e&&e.description,selected:e&&e.selected,disabled:e&&e.disabled})),this.optionsPerPage=e.optionsPerPage||10,this.value=(this.choices[this.cursor]||{}).value,this.clear=a(``,this.out.columns),this.render()}moveCursor(e){this.cursor=e,this.value=this.choices[e].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(`
|
|
49
|
+
`),this.close()}submit(){this.selection.disabled?this.bell():(this.done=!0,this.aborted=!1,this.fire(),this.render(),this.out.write(`
|
|
50
|
+
`),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()}_(e,t){if(e===` `)return this.submit()}get selection(){return this.choices[this.cursor]}render(){if(this.closed)return;this.firstRender?this.out.write(l.hide):this.out.write(a(this.outputText,this.out.columns)),super.render();let{startIndex:e,endIndex:t}=c(this.cursor,this.choices.length,this.optionsPerPage);if(this.outputText=[i.symbol(this.done,this.aborted),n.bold(this.msg),i.delimiter(!1),this.done?this.selection.title:this.selection.disabled?n.yellow(this.warn):n.gray(this.hint)].join(` `),!this.done){this.outputText+=`
|
|
51
|
+
`;for(let r=e;r<t;r++){let i,a,c=``,l=this.choices[r];a=r===e&&e>0?o.arrowUp:r===t-1&&t<this.choices.length?o.arrowDown:` `,l.disabled?(i=this.cursor===r?n.gray().underline(l.title):n.strikethrough().gray(l.title),a=(this.cursor===r?n.bold().gray(o.pointer)+` `:` `)+a):(i=this.cursor===r?n.cyan().underline(l.title):l.title,a=(this.cursor===r?n.cyan(o.pointer)+` `:` `)+a,l.description&&this.cursor===r&&(c=` - ${l.description}`,(a.length+i.length+c.length>=this.out.columns||l.description.split(/\r?\n/).length>1)&&(c=`
|
|
52
|
+
`+s(l.description,{margin:3,width:this.out.columns})))),this.outputText+=`${a} ${i}${n.gray(c)}\n`}}this.out.write(this.outputText)}}})),ge=g(((e,t)=>{let n=b(),r=Y(),{style:i,clear:a}=J(),{cursor:o,erase:s}=C();t.exports=class extends r{constructor(e={}){super(e),this.msg=e.message,this.value=!!e.initial,this.active=e.active||`on`,this.inactive=e.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(`
|
|
53
|
+
`),this.close()}submit(){this.done=!0,this.aborted=!1,this.fire(),this.render(),this.out.write(`
|
|
54
|
+
`),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()}_(e,t){if(e===` `)this.value=!this.value;else if(e===`1`)this.value=!0;else if(e===`0`)this.value=!1;else return this.bell();this.render()}render(){this.closed||(this.firstRender?this.out.write(o.hide):this.out.write(a(this.outputText,this.out.columns)),super.render(),this.outputText=[i.symbol(this.done,this.aborted),n.bold(this.msg),i.delimiter(this.done),this.value?this.inactive:n.cyan().underline(this.inactive),n.gray(`/`),this.value?n.cyan().underline(this.active):this.active].join(` `),this.out.write(s.line+o.to(0)+this.outputText))}}})),X=g(((e,t)=>{t.exports=class e{constructor({token:e,date:t,parts:n,locales:r}){this.token=e,this.date=t||new Date,this.parts=n||[this],this.locales=r||{}}up(){}down(){}next(){let t=this.parts.indexOf(this);return this.parts.find((n,r)=>r>t&&n instanceof e)}setTo(e){}prev(){let t=[].concat(this.parts).reverse(),n=t.indexOf(this);return t.find((t,r)=>r>n&&t instanceof e)}toString(){return String(this.date)}}})),_e=g(((e,t)=>{let n=X();t.exports=class extends n{constructor(e={}){super(e)}up(){this.date.setHours((this.date.getHours()+12)%24)}down(){this.up()}toString(){let e=this.date.getHours()>12?`pm`:`am`;return/\A/.test(this.token)?e.toUpperCase():e}}})),ve=g(((e,t)=>{let n=X(),r=e=>(e%=10,e===1?`st`:e===2?`nd`:e===3?`rd`:`th`);t.exports=class extends n{constructor(e={}){super(e)}up(){this.date.setDate(this.date.getDate()+1)}down(){this.date.setDate(this.date.getDate()-1)}setTo(e){this.date.setDate(parseInt(e.substr(-2)))}toString(){let e=this.date.getDate(),t=this.date.getDay();return this.token===`DD`?String(e).padStart(2,`0`):this.token===`Do`?e+r(e):this.token===`d`?t+1:this.token===`ddd`?this.locales.weekdaysShort[t]:this.token===`dddd`?this.locales.weekdays[t]:e}}})),ye=g(((e,t)=>{let n=X();t.exports=class extends n{constructor(e={}){super(e)}up(){this.date.setHours(this.date.getHours()+1)}down(){this.date.setHours(this.date.getHours()-1)}setTo(e){this.date.setHours(parseInt(e.substr(-2)))}toString(){let e=this.date.getHours();return/h/.test(this.token)&&(e=e%12||12),this.token.length>1?String(e).padStart(2,`0`):e}}})),be=g(((e,t)=>{let n=X();t.exports=class extends n{constructor(e={}){super(e)}up(){this.date.setMilliseconds(this.date.getMilliseconds()+1)}down(){this.date.setMilliseconds(this.date.getMilliseconds()-1)}setTo(e){this.date.setMilliseconds(parseInt(e.substr(-this.token.length)))}toString(){return String(this.date.getMilliseconds()).padStart(4,`0`).substr(0,this.token.length)}}})),xe=g(((e,t)=>{let n=X();t.exports=class extends n{constructor(e={}){super(e)}up(){this.date.setMinutes(this.date.getMinutes()+1)}down(){this.date.setMinutes(this.date.getMinutes()-1)}setTo(e){this.date.setMinutes(parseInt(e.substr(-2)))}toString(){let e=this.date.getMinutes();return this.token.length>1?String(e).padStart(2,`0`):e}}})),Se=g(((e,t)=>{let n=X();t.exports=class extends n{constructor(e={}){super(e)}up(){this.date.setMonth(this.date.getMonth()+1)}down(){this.date.setMonth(this.date.getMonth()-1)}setTo(e){e=parseInt(e.substr(-2))-1,this.date.setMonth(e<0?0:e)}toString(){let e=this.date.getMonth(),t=this.token.length;return t===2?String(e+1).padStart(2,`0`):t===3?this.locales.monthsShort[e]:t===4?this.locales.months[e]:String(e+1)}}})),Ce=g(((e,t)=>{let n=X();t.exports=class extends n{constructor(e={}){super(e)}up(){this.date.setSeconds(this.date.getSeconds()+1)}down(){this.date.setSeconds(this.date.getSeconds()-1)}setTo(e){this.date.setSeconds(parseInt(e.substr(-2)))}toString(){let e=this.date.getSeconds();return this.token.length>1?String(e).padStart(2,`0`):e}}})),we=g(((e,t)=>{let n=X();t.exports=class extends n{constructor(e={}){super(e)}up(){this.date.setFullYear(this.date.getFullYear()+1)}down(){this.date.setFullYear(this.date.getFullYear()-1)}setTo(e){this.date.setFullYear(e.substr(-4))}toString(){let e=String(this.date.getFullYear()).padStart(4,`0`);return this.token.length===2?e.substr(-2):e}}})),Te=g(((e,t)=>{t.exports={DatePart:X(),Meridiem:_e(),Day:ve(),Hours:ye(),Milliseconds:be(),Minutes:xe(),Month:Se(),Seconds:Ce(),Year:we()}})),Ee=g(((e,t)=>{let n=b(),r=Y(),{style:i,clear:a,figures:o}=J(),{erase:s,cursor:c}=C(),{DatePart:l,Meridiem:u,Day:d,Hours:f,Milliseconds:p,Minutes:m,Month:h,Seconds:g,Year:_}=Te(),v=/\\(.)|"((?:\\["\\]|[^"])+)"|(D[Do]?|d{3,4}|d)|(M{1,4})|(YY(?:YY)?)|([aA])|([Hh]{1,2})|(m{1,2})|(s{1,2})|(S{1,4})|./g,y={1:({token:e})=>e.replace(/\\(.)/g,`$1`),2:e=>new d(e),3:e=>new h(e),4:e=>new _(e),5:e=>new u(e),6:e=>new f(e),7:e=>new m(e),8:e=>new g(e),9:e=>new p(e)},x={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(`,`)};t.exports=class extends r{constructor(e={}){super(e),this.msg=e.message,this.cursor=0,this.typed=``,this.locales=Object.assign(x,e.locales),this._date=e.initial||new Date,this.errorMsg=e.error||`Please Enter A Valid Value`,this.validator=e.validate||(()=>!0),this.mask=e.mask||`YYYY-MM-DD HH:mm:ss`,this.clear=a(``,this.out.columns),this.render()}get value(){return this.date}get date(){return this._date}set date(e){e&&this._date.setTime(e.getTime())}set mask(e){let t;for(this.parts=[];t=v.exec(e);){let e=t.shift(),n=t.findIndex(e=>e!=null);this.parts.push(n in y?y[n]({token:t[n]||e,date:this.date,parts:this.parts,locales:this.locales}):t[n]||e)}let n=this.parts.reduce((e,t)=>(typeof t==`string`&&typeof e[e.length-1]==`string`?e[e.length-1]+=t:e.push(t),e),[]);this.parts.splice(0),this.parts.push(...n),this.reset()}moveCursor(e){this.typed=``,this.cursor=e,this.fire()}reset(){this.moveCursor(this.parts.findIndex(e=>e instanceof l)),this.fire(),this.render()}exit(){this.abort()}abort(){this.done=this.aborted=!0,this.error=!1,this.fire(),this.render(),this.out.write(`
|
|
55
|
+
`),this.close()}async validate(){let e=await this.validator(this.value);typeof e==`string`&&(this.errorMsg=e,e=!1),this.error=!e}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(`
|
|
56
|
+
`),this.close()}up(){this.typed=``,this.parts[this.cursor].up(),this.render()}down(){this.typed=``,this.parts[this.cursor].down(),this.render()}left(){let e=this.parts[this.cursor].prev();if(e==null)return this.bell();this.moveCursor(this.parts.indexOf(e)),this.render()}right(){let e=this.parts[this.cursor].next();if(e==null)return this.bell();this.moveCursor(this.parts.indexOf(e)),this.render()}next(){let e=this.parts[this.cursor].next();this.moveCursor(e?this.parts.indexOf(e):this.parts.findIndex(e=>e instanceof l)),this.render()}_(e){/\d/.test(e)&&(this.typed+=e,this.parts[this.cursor].setTo(this.typed),this.render())}render(){this.closed||(this.firstRender?this.out.write(c.hide):this.out.write(a(this.outputText,this.out.columns)),super.render(),this.outputText=[i.symbol(this.done,this.aborted),n.bold(this.msg),i.delimiter(!1),this.parts.reduce((e,t,r)=>e.concat(r===this.cursor&&!this.done?n.cyan().underline(t.toString()):t),[]).join(``)].join(` `),this.error&&(this.outputText+=this.errorMsg.split(`
|
|
57
|
+
`).reduce((e,t,r)=>e+`\n${r?` `:o.pointerSmall} ${n.red().italic(t)}`,``)),this.out.write(s.line+c.to(0)+this.outputText))}}})),De=g(((e,t)=>{let n=b(),r=Y(),{cursor:i,erase:a}=C(),{style:o,figures:s,clear:c,lines:l}=J(),u=/[0-9]/,d=e=>e!==void 0,f=(e,t)=>{let n=10**t;return Math.round(e*n)/n};t.exports=class extends r{constructor(e={}){super(e),this.transform=o.render(e.style),this.msg=e.message,this.initial=d(e.initial)?e.initial:``,this.float=!!e.float,this.round=e.round||2,this.inc=e.increment||1,this.min=d(e.min)?e.min:-1/0,this.max=d(e.max)?e.max:1/0,this.errorMsg=e.error||`Please Enter A Valid Value`,this.validator=e.validate||(()=>!0),this.color=`cyan`,this.value=``,this.typed=``,this.lastHit=0,this.render()}set value(e){!e&&e!==0?(this.placeholder=!0,this.rendered=n.gray(this.transform.render(`${this.initial}`)),this._value=``):(this.placeholder=!1,this.rendered=this.transform.render(`${f(e,this.round)}`),this._value=f(e,this.round)),this.fire()}get value(){return this._value}parse(e){return this.float?parseFloat(e):parseInt(e)}valid(e){return e===`-`||e===`.`&&this.float||u.test(e)}reset(){this.typed=``,this.value=``,this.fire(),this.render()}exit(){this.abort()}abort(){let e=this.value;this.value=e===``?this.initial:e,this.done=this.aborted=!0,this.error=!1,this.fire(),this.render(),this.out.write(`
|
|
58
|
+
`),this.close()}async validate(){let e=await this.validator(this.value);typeof e==`string`&&(this.errorMsg=e,e=!1),this.error=!e}async submit(){if(await this.validate(),this.error){this.color=`red`,this.fire(),this.render();return}let e=this.value;this.value=e===``?this.initial:e,this.done=!0,this.aborted=!1,this.error=!1,this.fire(),this.render(),this.out.write(`
|
|
59
|
+
`),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 e=this.value.toString();if(e.length===0)return this.bell();this.value=this.parse(e=e.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()}_(e,t){if(!this.valid(e))return this.bell();let n=Date.now();if(n-this.lastHit>1e3&&(this.typed=``),this.typed+=e,this.lastHit=n,this.color=`cyan`,e===`.`)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(l(this.outputError,this.out.columns)-1)+c(this.outputError,this.out.columns)),this.out.write(c(this.outputText,this.out.columns))),super.render(),this.outputError=``,this.outputText=[o.symbol(this.done,this.aborted),n.bold(this.msg),o.delimiter(this.done),!this.done||!this.done&&!this.placeholder?n[this.color]().underline(this.rendered):this.rendered].join(` `),this.error&&(this.outputError+=this.errorMsg.split(`
|
|
60
|
+
`).reduce((e,t,r)=>e+`\n${r?` `:s.pointerSmall} ${n.red().italic(t)}`,``)),this.out.write(a.line+i.to(0)+this.outputText+i.save+this.outputError+i.restore))}}})),Z=g(((e,t)=>{let n=b(),{cursor:r}=C(),i=Y(),{clear:a,figures:o,style:s,wrap:c,entriesToDisplay:l}=J();t.exports=class extends i{constructor(e={}){super(e),this.msg=e.message,this.cursor=e.cursor||0,this.scrollIndex=e.cursor||0,this.hint=e.hint||``,this.warn=e.warn||`- This option is disabled -`,this.minSelected=e.min,this.showMinError=!1,this.maxChoices=e.max,this.instructions=e.instructions,this.optionsPerPage=e.optionsPerPage||10,this.value=e.choices.map((e,t)=>(typeof e==`string`&&(e={title:e,value:t}),{title:e&&(e.title||e.value||e),description:e&&e.description,value:e&&(e.value===void 0?t:e.value),selected:e&&e.selected,disabled:e&&e.disabled})),this.clear=a(``,this.out.columns),e.overrideRender||this.render()}reset(){this.value.map(e=>!e.selected),this.cursor=0,this.fire(),this.render()}selected(){return this.value.filter(e=>e.selected)}exit(){this.abort()}abort(){this.done=this.aborted=!0,this.fire(),this.render(),this.out.write(`
|
|
61
|
+
`),this.close()}submit(){let e=this.value.filter(e=>e.selected);this.minSelected&&e.length<this.minSelected?(this.showMinError=!0,this.render()):(this.done=!0,this.aborted=!1,this.fire(),this.render(),this.out.write(`
|
|
62
|
+
`),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(e=>e.selected).length>=this.maxChoices)return this.bell();this.value[this.cursor].selected=!0,this.render()}handleSpaceToggle(){let e=this.value[this.cursor];if(e.selected)e.selected=!1,this.render();else if(e.disabled||this.value.filter(e=>e.selected).length>=this.maxChoices)return this.bell();else e.selected=!0,this.render()}toggleAll(){if(this.maxChoices!==void 0||this.value[this.cursor].disabled)return this.bell();let e=!this.value[this.cursor].selected;this.value.filter(e=>!e.disabled).forEach(t=>t.selected=e),this.render()}_(e,t){if(e===` `)this.handleSpaceToggle();else if(e===`a`)this.toggleAll();else return this.bell()}renderInstructions(){return this.instructions===void 0||this.instructions?typeof this.instructions==`string`?this.instructions:`
|
|
63
|
+
Instructions:
|
|
64
|
+
${o.arrowUp}/${o.arrowDown}: Highlight option\n ${o.arrowLeft}/${o.arrowRight}/[space]: Toggle selection\n`+(this.maxChoices===void 0?` a: Toggle all
|
|
65
|
+
`:``)+` enter/return: Complete answer`:``}renderOption(e,t,r,i){let a=(t.selected?n.green(o.radioOn):o.radioOff)+` `+i+` `,s,l;return t.disabled?s=e===r?n.gray().underline(t.title):n.strikethrough().gray(t.title):(s=e===r?n.cyan().underline(t.title):t.title,e===r&&t.description&&(l=` - ${t.description}`,(a.length+s.length+l.length>=this.out.columns||t.description.split(/\r?\n/).length>1)&&(l=`
|
|
66
|
+
`+c(t.description,{margin:a.length,width:this.out.columns})))),a+s+n.gray(l||``)}paginateOptions(e){if(e.length===0)return n.red(`No matches for this query.`);let{startIndex:t,endIndex:r}=l(this.cursor,e.length,this.optionsPerPage),i,a=[];for(let n=t;n<r;n++)i=n===t&&t>0?o.arrowUp:n===r-1&&r<e.length?o.arrowDown:` `,a.push(this.renderOption(this.cursor,e[n],n,i));return`
|
|
67
|
+
`+a.join(`
|
|
68
|
+
`)}renderOptions(e){return this.done?``:this.paginateOptions(e)}renderDoneOrInstructions(){if(this.done)return this.value.filter(e=>e.selected).map(e=>e.title).join(`, `);let e=[n.gray(this.hint),this.renderInstructions()];return this.value[this.cursor].disabled&&e.push(n.yellow(this.warn)),e.join(` `)}render(){if(this.closed)return;this.firstRender&&this.out.write(r.hide),super.render();let e=[s.symbol(this.done,this.aborted),n.bold(this.msg),s.delimiter(!1),this.renderDoneOrInstructions()].join(` `);this.showMinError&&=(e+=n.red(`You must select a minimum of ${this.minSelected} choices.`),!1),e+=this.renderOptions(this.value),this.out.write(this.clear+e),this.clear=a(e,this.out.columns)}}})),Oe=g(((e,t)=>{let n=b(),r=Y(),{erase:i,cursor:a}=C(),{style:o,clear:s,figures:c,wrap:l,entriesToDisplay:u}=J(),d=(e,t)=>e[t]&&(e[t].value||e[t].title||e[t]),f=(e,t)=>e[t]&&(e[t].title||e[t].value||e[t]),p=(e,t)=>{let n=e.findIndex(e=>e.value===t||e.title===t);return n>-1?n:void 0};t.exports=class extends r{constructor(e={}){super(e),this.msg=e.message,this.suggest=e.suggest,this.choices=e.choices,this.initial=typeof e.initial==`number`?e.initial:p(e.choices,e.initial),this.select=this.initial||e.cursor||0,this.i18n={noMatches:e.noMatches||`no matches found`},this.fallback=e.fallback||this.initial,this.clearFirst=e.clearFirst||!1,this.suggestions=[],this.input=``,this.limit=e.limit||10,this.cursor=0,this.transform=o.render(e.style),this.scale=this.transform.scale,this.render=this.render.bind(this),this.complete=this.complete.bind(this),this.clear=s(``,this.out.columns),this.complete(this.render),this.render()}set fallback(e){this._fb=Number.isSafeInteger(parseInt(e))?parseInt(e):e}get fallback(){let e;return typeof this._fb==`number`?e=this.choices[this._fb]:typeof this._fb==`string`&&(e={title:this._fb}),e||this._fb||{title:this.i18n.noMatches}}moveSelect(e){this.select=e,this.suggestions.length>0?this.value=d(this.suggestions,e):this.value=this.fallback.value,this.fire()}async complete(e){let t=this.completing=this.suggest(this.input,this.choices),n=await t;if(this.completing!==t)return;this.suggestions=n.map((e,t,n)=>({title:f(n,t),value:d(n,t),description:e.description})),this.completing=!1;let r=Math.max(n.length-1,0);this.moveSelect(Math.min(r,this.select)),e&&e()}reset(){this.input=``,this.complete(()=>{this.moveSelect(this.initial===void 0?0:this.initial),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(`
|
|
69
|
+
`),this.close())}abort(){this.done=this.aborted=!0,this.exited=!1,this.fire(),this.render(),this.out.write(`
|
|
70
|
+
`),this.close()}submit(){this.done=!0,this.aborted=this.exited=!1,this.fire(),this.render(),this.out.write(`
|
|
71
|
+
`),this.close()}_(e,t){let n=this.input.slice(0,this.cursor);this.input=`${n}${e}${this.input.slice(this.cursor)}`,this.cursor=n.length+1,this.complete(this.render),this.render()}delete(){if(this.cursor===0)return this.bell();this.input=`${this.input.slice(0,this.cursor-1)}${this.input.slice(this.cursor)}`,this.complete(this.render),--this.cursor,this.render()}deleteForward(){if(this.cursor*this.scale>=this.rendered.length)return this.bell();this.input=`${this.input.slice(0,this.cursor)}${this.input.slice(this.cursor+1)}`,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.render()}right(){if(this.cursor*this.scale>=this.rendered.length)return this.bell();this.cursor+=1,this.render()}renderOption(e,t,r,i){let a,o=r?c.arrowUp:i?c.arrowDown:` `,s=t?n.cyan().underline(e.title):e.title;return o=(t?n.cyan(c.pointer)+` `:` `)+o,e.description&&(a=` - ${e.description}`,(o.length+s.length+a.length>=this.out.columns||e.description.split(/\r?\n/).length>1)&&(a=`
|
|
72
|
+
`+l(e.description,{margin:3,width:this.out.columns}))),o+` `+s+n.gray(a||``)}render(){if(this.closed)return;this.firstRender?this.out.write(a.hide):this.out.write(s(this.outputText,this.out.columns)),super.render();let{startIndex:e,endIndex:t}=u(this.select,this.choices.length,this.limit);if(this.outputText=[o.symbol(this.done,this.aborted,this.exited),n.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){let r=this.suggestions.slice(e,t).map((n,r)=>this.renderOption(n,this.select===r+e,r===0&&e>0,r+e===t-1&&t<this.choices.length)).join(`
|
|
73
|
+
`);this.outputText+=`
|
|
74
|
+
`+(r||n.gray(this.fallback.title))}this.out.write(i.line+a.to(0)+this.outputText)}}})),Q=g(((e,t)=>{let n=b(),{cursor:r}=C(),i=Z(),{clear:a,style:o,figures:s}=J();t.exports=class extends i{constructor(e={}){e.overrideRender=!0,super(e),this.inputValue=``,this.clear=a(``,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(e=>e.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(){let e=this.filteredOptions[this.cursor];this.filteredOptions=this.value.filter(e=>this.inputValue?!!(typeof e.title==`string`&&e.title.toLowerCase().includes(this.inputValue.toLowerCase())||typeof e.value==`string`&&e.value.toLowerCase().includes(this.inputValue.toLowerCase())):!0);let t=this.filteredOptions.findIndex(t=>t===e);this.cursor=t<0?0:t,this.render()}handleSpaceToggle(){let e=this.filteredOptions[this.cursor];if(e.selected)e.selected=!1,this.render();else if(e.disabled||this.value.filter(e=>e.selected).length>=this.maxChoices)return this.bell();else e.selected=!0,this.render()}handleInputChange(e){this.inputValue+=e,this.updateFilteredOptions()}_(e,t){e===` `?this.handleSpaceToggle():this.handleInputChange(e)}renderInstructions(){return this.instructions===void 0||this.instructions?typeof this.instructions==`string`?this.instructions:`
|
|
75
|
+
Instructions:
|
|
76
|
+
${s.arrowUp}/${s.arrowDown}: Highlight option
|
|
77
|
+
${s.arrowLeft}/${s.arrowRight}/[space]: Toggle selection
|
|
78
|
+
[a,b,c]/delete: Filter choices
|
|
79
|
+
enter/return: Complete answer
|
|
80
|
+
`:``}renderCurrentInput(){return`
|
|
81
|
+
Filtered results for: ${this.inputValue?this.inputValue:n.gray(`Enter something to filter`)}\n`}renderOption(e,t,r){let i;return i=t.disabled?e===r?n.gray().underline(t.title):n.strikethrough().gray(t.title):e===r?n.cyan().underline(t.title):t.title,(t.selected?n.green(s.radioOn):s.radioOff)+` `+i}renderDoneOrInstructions(){if(this.done)return this.value.filter(e=>e.selected).map(e=>e.title).join(`, `);let e=[n.gray(this.hint),this.renderInstructions(),this.renderCurrentInput()];return this.filteredOptions.length&&this.filteredOptions[this.cursor].disabled&&e.push(n.yellow(this.warn)),e.join(` `)}render(){if(this.closed)return;this.firstRender&&this.out.write(r.hide),super.render();let e=[o.symbol(this.done,this.aborted),n.bold(this.msg),o.delimiter(!1),this.renderDoneOrInstructions()].join(` `);this.showMinError&&=(e+=n.red(`You must select a minimum of ${this.minSelected} choices.`),!1),e+=this.renderOptions(this.filteredOptions),this.out.write(this.clear+e),this.clear=a(e,this.out.columns)}}})),ke=g(((e,t)=>{let n=b(),r=Y(),{style:i,clear:a}=J(),{erase:o,cursor:s}=C();t.exports=class extends r{constructor(e={}){super(e),this.msg=e.message,this.value=e.initial,this.initialValue=!!e.initial,this.yesMsg=e.yes||`yes`,this.yesOption=e.yesOption||`(Y/n)`,this.noMsg=e.no||`no`,this.noOption=e.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(`
|
|
82
|
+
`),this.close()}submit(){this.value=this.value||!1,this.done=!0,this.aborted=!1,this.fire(),this.render(),this.out.write(`
|
|
83
|
+
`),this.close()}_(e,t){return e.toLowerCase()===`y`?(this.value=!0,this.submit()):e.toLowerCase()===`n`?(this.value=!1,this.submit()):this.bell()}render(){this.closed||(this.firstRender?this.out.write(s.hide):this.out.write(a(this.outputText,this.out.columns)),super.render(),this.outputText=[i.symbol(this.done,this.aborted),n.bold(this.msg),i.delimiter(this.done),this.done?this.value?this.yesMsg:this.noMsg:n.gray(this.initialValue?this.yesOption:this.noOption)].join(` `),this.out.write(o.line+s.to(0)+this.outputText))}}})),Ae=g(((e,t)=>{t.exports={TextPrompt:me(),SelectPrompt:he(),TogglePrompt:ge(),DatePrompt:Ee(),NumberPrompt:De(),MultiselectPrompt:Z(),AutocompletePrompt:Oe(),AutocompleteMultiselectPrompt:Q(),ConfirmPrompt:ke()}})),je=g((e=>{let t=e,n=Ae(),r=e=>e;function i(e,t,i={}){return new Promise((a,o)=>{let s=new n[e](t),c=i.onAbort||r,l=i.onSubmit||r,u=i.onExit||r;s.on(`state`,t.onState||r),s.on(`submit`,e=>a(l(e))),s.on(`exit`,e=>a(u(e))),s.on(`abort`,e=>o(c(e)))})}t.text=e=>i(`TextPrompt`,e),t.password=e=>(e.style=`password`,t.text(e)),t.invisible=e=>(e.style=`invisible`,t.text(e)),t.number=e=>i(`NumberPrompt`,e),t.date=e=>i(`DatePrompt`,e),t.confirm=e=>i(`ConfirmPrompt`,e),t.list=e=>{let t=e.separator||`,`;return i(`TextPrompt`,e,{onSubmit:e=>e.split(t).map(e=>e.trim())})},t.toggle=e=>i(`TogglePrompt`,e),t.select=e=>i(`SelectPrompt`,e),t.multiselect=e=>{e.choices=[].concat(e.choices||[]);let t=e=>e.filter(e=>e.selected).map(e=>e.value);return i(`MultiselectPrompt`,e,{onAbort:t,onSubmit:t})},t.autocompleteMultiselect=e=>{e.choices=[].concat(e.choices||[]);let t=e=>e.filter(e=>e.selected).map(e=>e.value);return i(`AutocompleteMultiselectPrompt`,e,{onAbort:t,onSubmit:t})};let a=(e,t)=>Promise.resolve(t.filter(t=>t.title.slice(0,e.length).toLowerCase()===e.toLowerCase()));t.autocomplete=e=>(e.suggest=e.suggest||a,e.choices=[].concat(e.choices||[]),i(`AutocompletePrompt`,e))})),Me=g(((e,t)=>{let n=je(),r=[`suggest`,`format`,`onState`,`validate`,`onRender`,`type`],i=()=>{};async function a(e=[],{onSubmit:t=i,onCancel:s=i}={}){let c={},l=a._override||{};e=[].concat(e);let u,d,f,p,m,h,g=async(e,t,n=!1)=>{if(!(!n&&e.validate&&e.validate(t)!==!0))return e.format?await e.format(t,c):t};for(d of e)if({name:p,type:m}=d,typeof m==`function`&&(m=await m(u,{...c},d),d.type=m),m){for(let e in d){if(r.includes(e))continue;let t=d[e];d[e]=typeof t==`function`?await t(u,{...c},h):t}if(h=d,typeof d.message!=`string`)throw Error(`prompt message is required`);if({name:p,type:m}=d,n[m]===void 0)throw Error(`prompt type (${m}) is not defined`);if(l[d.name]!==void 0&&(u=await g(d,l[d.name]),u!==void 0)){c[p]=u;continue}try{u=a._injected?o(a._injected,d.initial):await n[m](d),c[p]=u=await g(d,u,!0),f=await t(d,u,c)}catch{f=!await s(d,c)}if(f)return c}return c}function o(e,t){let n=e.shift();if(n instanceof Error)throw n;return n===void 0?t:n}function s(e){a._injected=(a._injected||[]).concat(e)}function c(e){a._override=Object.assign({},e)}t.exports=Object.assign(a,{prompt:a,prompts:n,inject:s,override:c})})),Ne=v(g(((e,t)=>{function n(e){e=(Array.isArray(e)?e:e.split(`.`)).map(Number);let t=0,n=process.versions.node.split(`.`).map(Number);for(;t<e.length;t++){if(n[t]>e[t])return!1;if(e[t]>n[t])return!0}return!1}t.exports=n(`8.6.0`)?W():Me()}))(),1);const Pe=[{value:`pdp-template`,title:`Product layout`,description:`A template for creating a PDP Component extension`}],Fe=/^[a-z0-9-]+$/,Ie=process.cwd(),$=async(e,t)=>{let r=await c(e);for(let s of r){let r=n.join(e,s),c=n.join(t,s);(await a(r)).isDirectory()?(await o(c),await $(r,c)):await i(r,c)}},Le=async(e,t)=>{let r=n.join(e,`package.json`);try{let e=await s(r,`utf8`),n=JSON.parse(e);n.name=t,await l(r,JSON.stringify(n,null,2),`utf8`)}catch(e){console.log(e.message)}};(async()=>{try{let{projectName:e,template:i}=await(0,Ne.default)([{type:`select`,name:`template`,message:`Select template`,choices:Pe},{type:`text`,name:`projectName`,message:`Enter your project name`,initial:`my-project`,format:e=>e.toLowerCase().split(` `).join(`-`),validate:e=>Fe.test(e)?!0:`Project name should not contain special characters except hyphen (-)`}]),a=n.join(Ie,e),o=n.resolve(t(import.meta.url),`../../templates`,`${i}`);if(console.log(a),!r.existsSync(a))console.log(`Target directory doesn't exist`),console.log(`Creating directory...`),r.mkdirSync(a,{recursive:!0}),console.log(`Finished creating directory`),await $(o,a),await Le(a,e),console.log(`Finished generating your project ${e}`),console.log(`cd ${e}`),console.log(`npm install`);else throw Error(`Target directory already exist!`)}catch(e){console.log(e.message)}})();export{};
|
package/index.js
ADDED
package/package.json
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "create-napps",
|
|
3
|
+
"private": false,
|
|
4
|
+
"version": "0.0.2",
|
|
5
|
+
"author": "NAPPS",
|
|
6
|
+
"type": "module",
|
|
7
|
+
"main": "index.js",
|
|
8
|
+
"bin": {
|
|
9
|
+
"create-napps": "index.js"
|
|
10
|
+
},
|
|
11
|
+
"files": [
|
|
12
|
+
"templates/*",
|
|
13
|
+
"dist",
|
|
14
|
+
"dist/*"
|
|
15
|
+
],
|
|
16
|
+
"scripts": {
|
|
17
|
+
"build": "tsdown",
|
|
18
|
+
"prepublishOnly": "npm run build"
|
|
19
|
+
},
|
|
20
|
+
"engines": {
|
|
21
|
+
"node": "^20.19.0 || >=22.12.0"
|
|
22
|
+
},
|
|
23
|
+
"devDependencies": {
|
|
24
|
+
"@types/prompts": "^2.4.9",
|
|
25
|
+
"prompts": "^2.4.2",
|
|
26
|
+
"tsdown": "^0.16.6"
|
|
27
|
+
}
|
|
28
|
+
}
|
|
@@ -0,0 +1,373 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "pdp-template",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"lockfileVersion": 3,
|
|
5
|
+
"requires": true,
|
|
6
|
+
"packages": {
|
|
7
|
+
"": {
|
|
8
|
+
"name": "pdp-template",
|
|
9
|
+
"version": "1.0.0",
|
|
10
|
+
"dependencies": {
|
|
11
|
+
"component-extension": "file:../../../component-extension"
|
|
12
|
+
},
|
|
13
|
+
"devDependencies": {
|
|
14
|
+
"typescript": "~5.9.3",
|
|
15
|
+
"vite": "npm:rolldown-vite@7.2.5"
|
|
16
|
+
}
|
|
17
|
+
},
|
|
18
|
+
"../../../component-extension": {
|
|
19
|
+
"version": "1.0.0",
|
|
20
|
+
"devDependencies": {
|
|
21
|
+
"typescript": "~5.9.3",
|
|
22
|
+
"vite": "npm:rolldown-vite@7.2.5",
|
|
23
|
+
"vite-plugin-dts": "^4.5.4"
|
|
24
|
+
}
|
|
25
|
+
},
|
|
26
|
+
"node_modules/@oxc-project/runtime": {
|
|
27
|
+
"version": "0.97.0",
|
|
28
|
+
"dev": true,
|
|
29
|
+
"license": "MIT",
|
|
30
|
+
"engines": {
|
|
31
|
+
"node": "^20.19.0 || >=22.12.0"
|
|
32
|
+
}
|
|
33
|
+
},
|
|
34
|
+
"node_modules/@oxc-project/types": {
|
|
35
|
+
"version": "0.97.0",
|
|
36
|
+
"dev": true,
|
|
37
|
+
"license": "MIT",
|
|
38
|
+
"funding": {
|
|
39
|
+
"url": "https://github.com/sponsors/Boshen"
|
|
40
|
+
}
|
|
41
|
+
},
|
|
42
|
+
"node_modules/@rolldown/binding-linux-x64-gnu": {
|
|
43
|
+
"version": "1.0.0-beta.50",
|
|
44
|
+
"cpu": [
|
|
45
|
+
"x64"
|
|
46
|
+
],
|
|
47
|
+
"dev": true,
|
|
48
|
+
"license": "MIT",
|
|
49
|
+
"optional": true,
|
|
50
|
+
"os": [
|
|
51
|
+
"linux"
|
|
52
|
+
],
|
|
53
|
+
"engines": {
|
|
54
|
+
"node": "^20.19.0 || >=22.12.0"
|
|
55
|
+
}
|
|
56
|
+
},
|
|
57
|
+
"node_modules/@rolldown/binding-linux-x64-musl": {
|
|
58
|
+
"version": "1.0.0-beta.50",
|
|
59
|
+
"cpu": [
|
|
60
|
+
"x64"
|
|
61
|
+
],
|
|
62
|
+
"dev": true,
|
|
63
|
+
"license": "MIT",
|
|
64
|
+
"optional": true,
|
|
65
|
+
"os": [
|
|
66
|
+
"linux"
|
|
67
|
+
],
|
|
68
|
+
"engines": {
|
|
69
|
+
"node": "^20.19.0 || >=22.12.0"
|
|
70
|
+
}
|
|
71
|
+
},
|
|
72
|
+
"node_modules/@rolldown/pluginutils": {
|
|
73
|
+
"version": "1.0.0-beta.50",
|
|
74
|
+
"dev": true,
|
|
75
|
+
"license": "MIT"
|
|
76
|
+
},
|
|
77
|
+
"node_modules/component-extension": {
|
|
78
|
+
"resolved": "../../../component-extension",
|
|
79
|
+
"link": true
|
|
80
|
+
},
|
|
81
|
+
"node_modules/detect-libc": {
|
|
82
|
+
"version": "2.1.2",
|
|
83
|
+
"dev": true,
|
|
84
|
+
"license": "Apache-2.0",
|
|
85
|
+
"engines": {
|
|
86
|
+
"node": ">=8"
|
|
87
|
+
}
|
|
88
|
+
},
|
|
89
|
+
"node_modules/fdir": {
|
|
90
|
+
"version": "6.5.0",
|
|
91
|
+
"dev": true,
|
|
92
|
+
"license": "MIT",
|
|
93
|
+
"engines": {
|
|
94
|
+
"node": ">=12.0.0"
|
|
95
|
+
},
|
|
96
|
+
"peerDependencies": {
|
|
97
|
+
"picomatch": "^3 || ^4"
|
|
98
|
+
},
|
|
99
|
+
"peerDependenciesMeta": {
|
|
100
|
+
"picomatch": {
|
|
101
|
+
"optional": true
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
},
|
|
105
|
+
"node_modules/lightningcss": {
|
|
106
|
+
"version": "1.30.2",
|
|
107
|
+
"dev": true,
|
|
108
|
+
"license": "MPL-2.0",
|
|
109
|
+
"dependencies": {
|
|
110
|
+
"detect-libc": "^2.0.3"
|
|
111
|
+
},
|
|
112
|
+
"engines": {
|
|
113
|
+
"node": ">= 12.0.0"
|
|
114
|
+
},
|
|
115
|
+
"funding": {
|
|
116
|
+
"type": "opencollective",
|
|
117
|
+
"url": "https://opencollective.com/parcel"
|
|
118
|
+
},
|
|
119
|
+
"optionalDependencies": {
|
|
120
|
+
"lightningcss-android-arm64": "1.30.2",
|
|
121
|
+
"lightningcss-darwin-arm64": "1.30.2",
|
|
122
|
+
"lightningcss-darwin-x64": "1.30.2",
|
|
123
|
+
"lightningcss-freebsd-x64": "1.30.2",
|
|
124
|
+
"lightningcss-linux-arm-gnueabihf": "1.30.2",
|
|
125
|
+
"lightningcss-linux-arm64-gnu": "1.30.2",
|
|
126
|
+
"lightningcss-linux-arm64-musl": "1.30.2",
|
|
127
|
+
"lightningcss-linux-x64-gnu": "1.30.2",
|
|
128
|
+
"lightningcss-linux-x64-musl": "1.30.2",
|
|
129
|
+
"lightningcss-win32-arm64-msvc": "1.30.2",
|
|
130
|
+
"lightningcss-win32-x64-msvc": "1.30.2"
|
|
131
|
+
}
|
|
132
|
+
},
|
|
133
|
+
"node_modules/lightningcss-linux-x64-gnu": {
|
|
134
|
+
"version": "1.30.2",
|
|
135
|
+
"cpu": [
|
|
136
|
+
"x64"
|
|
137
|
+
],
|
|
138
|
+
"dev": true,
|
|
139
|
+
"license": "MPL-2.0",
|
|
140
|
+
"optional": true,
|
|
141
|
+
"os": [
|
|
142
|
+
"linux"
|
|
143
|
+
],
|
|
144
|
+
"engines": {
|
|
145
|
+
"node": ">= 12.0.0"
|
|
146
|
+
},
|
|
147
|
+
"funding": {
|
|
148
|
+
"type": "opencollective",
|
|
149
|
+
"url": "https://opencollective.com/parcel"
|
|
150
|
+
}
|
|
151
|
+
},
|
|
152
|
+
"node_modules/lightningcss-linux-x64-musl": {
|
|
153
|
+
"version": "1.30.2",
|
|
154
|
+
"cpu": [
|
|
155
|
+
"x64"
|
|
156
|
+
],
|
|
157
|
+
"dev": true,
|
|
158
|
+
"license": "MPL-2.0",
|
|
159
|
+
"optional": true,
|
|
160
|
+
"os": [
|
|
161
|
+
"linux"
|
|
162
|
+
],
|
|
163
|
+
"engines": {
|
|
164
|
+
"node": ">= 12.0.0"
|
|
165
|
+
},
|
|
166
|
+
"funding": {
|
|
167
|
+
"type": "opencollective",
|
|
168
|
+
"url": "https://opencollective.com/parcel"
|
|
169
|
+
}
|
|
170
|
+
},
|
|
171
|
+
"node_modules/nanoid": {
|
|
172
|
+
"version": "3.3.11",
|
|
173
|
+
"dev": true,
|
|
174
|
+
"funding": [
|
|
175
|
+
{
|
|
176
|
+
"type": "github",
|
|
177
|
+
"url": "https://github.com/sponsors/ai"
|
|
178
|
+
}
|
|
179
|
+
],
|
|
180
|
+
"license": "MIT",
|
|
181
|
+
"bin": {
|
|
182
|
+
"nanoid": "bin/nanoid.cjs"
|
|
183
|
+
},
|
|
184
|
+
"engines": {
|
|
185
|
+
"node": "^10 || ^12 || ^13.7 || ^14 || >=15.0.1"
|
|
186
|
+
}
|
|
187
|
+
},
|
|
188
|
+
"node_modules/picocolors": {
|
|
189
|
+
"version": "1.1.1",
|
|
190
|
+
"dev": true,
|
|
191
|
+
"license": "ISC"
|
|
192
|
+
},
|
|
193
|
+
"node_modules/picomatch": {
|
|
194
|
+
"version": "4.0.3",
|
|
195
|
+
"dev": true,
|
|
196
|
+
"license": "MIT",
|
|
197
|
+
"engines": {
|
|
198
|
+
"node": ">=12"
|
|
199
|
+
},
|
|
200
|
+
"funding": {
|
|
201
|
+
"url": "https://github.com/sponsors/jonschlinkert"
|
|
202
|
+
}
|
|
203
|
+
},
|
|
204
|
+
"node_modules/postcss": {
|
|
205
|
+
"version": "8.5.6",
|
|
206
|
+
"dev": true,
|
|
207
|
+
"funding": [
|
|
208
|
+
{
|
|
209
|
+
"type": "opencollective",
|
|
210
|
+
"url": "https://opencollective.com/postcss/"
|
|
211
|
+
},
|
|
212
|
+
{
|
|
213
|
+
"type": "tidelift",
|
|
214
|
+
"url": "https://tidelift.com/funding/github/npm/postcss"
|
|
215
|
+
},
|
|
216
|
+
{
|
|
217
|
+
"type": "github",
|
|
218
|
+
"url": "https://github.com/sponsors/ai"
|
|
219
|
+
}
|
|
220
|
+
],
|
|
221
|
+
"license": "MIT",
|
|
222
|
+
"dependencies": {
|
|
223
|
+
"nanoid": "^3.3.11",
|
|
224
|
+
"picocolors": "^1.1.1",
|
|
225
|
+
"source-map-js": "^1.2.1"
|
|
226
|
+
},
|
|
227
|
+
"engines": {
|
|
228
|
+
"node": "^10 || ^12 || >=14"
|
|
229
|
+
}
|
|
230
|
+
},
|
|
231
|
+
"node_modules/rolldown": {
|
|
232
|
+
"version": "1.0.0-beta.50",
|
|
233
|
+
"dev": true,
|
|
234
|
+
"license": "MIT",
|
|
235
|
+
"dependencies": {
|
|
236
|
+
"@oxc-project/types": "=0.97.0",
|
|
237
|
+
"@rolldown/pluginutils": "1.0.0-beta.50"
|
|
238
|
+
},
|
|
239
|
+
"bin": {
|
|
240
|
+
"rolldown": "bin/cli.mjs"
|
|
241
|
+
},
|
|
242
|
+
"engines": {
|
|
243
|
+
"node": "^20.19.0 || >=22.12.0"
|
|
244
|
+
},
|
|
245
|
+
"optionalDependencies": {
|
|
246
|
+
"@rolldown/binding-android-arm64": "1.0.0-beta.50",
|
|
247
|
+
"@rolldown/binding-darwin-arm64": "1.0.0-beta.50",
|
|
248
|
+
"@rolldown/binding-darwin-x64": "1.0.0-beta.50",
|
|
249
|
+
"@rolldown/binding-freebsd-x64": "1.0.0-beta.50",
|
|
250
|
+
"@rolldown/binding-linux-arm-gnueabihf": "1.0.0-beta.50",
|
|
251
|
+
"@rolldown/binding-linux-arm64-gnu": "1.0.0-beta.50",
|
|
252
|
+
"@rolldown/binding-linux-arm64-musl": "1.0.0-beta.50",
|
|
253
|
+
"@rolldown/binding-linux-x64-gnu": "1.0.0-beta.50",
|
|
254
|
+
"@rolldown/binding-linux-x64-musl": "1.0.0-beta.50",
|
|
255
|
+
"@rolldown/binding-openharmony-arm64": "1.0.0-beta.50",
|
|
256
|
+
"@rolldown/binding-wasm32-wasi": "1.0.0-beta.50",
|
|
257
|
+
"@rolldown/binding-win32-arm64-msvc": "1.0.0-beta.50",
|
|
258
|
+
"@rolldown/binding-win32-ia32-msvc": "1.0.0-beta.50",
|
|
259
|
+
"@rolldown/binding-win32-x64-msvc": "1.0.0-beta.50"
|
|
260
|
+
}
|
|
261
|
+
},
|
|
262
|
+
"node_modules/source-map-js": {
|
|
263
|
+
"version": "1.2.1",
|
|
264
|
+
"dev": true,
|
|
265
|
+
"license": "BSD-3-Clause",
|
|
266
|
+
"engines": {
|
|
267
|
+
"node": ">=0.10.0"
|
|
268
|
+
}
|
|
269
|
+
},
|
|
270
|
+
"node_modules/tinyglobby": {
|
|
271
|
+
"version": "0.2.15",
|
|
272
|
+
"dev": true,
|
|
273
|
+
"license": "MIT",
|
|
274
|
+
"dependencies": {
|
|
275
|
+
"fdir": "^6.5.0",
|
|
276
|
+
"picomatch": "^4.0.3"
|
|
277
|
+
},
|
|
278
|
+
"engines": {
|
|
279
|
+
"node": ">=12.0.0"
|
|
280
|
+
},
|
|
281
|
+
"funding": {
|
|
282
|
+
"url": "https://github.com/sponsors/SuperchupuDev"
|
|
283
|
+
}
|
|
284
|
+
},
|
|
285
|
+
"node_modules/typescript": {
|
|
286
|
+
"version": "5.9.3",
|
|
287
|
+
"dev": true,
|
|
288
|
+
"license": "Apache-2.0",
|
|
289
|
+
"bin": {
|
|
290
|
+
"tsc": "bin/tsc",
|
|
291
|
+
"tsserver": "bin/tsserver"
|
|
292
|
+
},
|
|
293
|
+
"engines": {
|
|
294
|
+
"node": ">=14.17"
|
|
295
|
+
}
|
|
296
|
+
},
|
|
297
|
+
"node_modules/vite": {
|
|
298
|
+
"name": "rolldown-vite",
|
|
299
|
+
"version": "7.2.5",
|
|
300
|
+
"dev": true,
|
|
301
|
+
"license": "MIT",
|
|
302
|
+
"dependencies": {
|
|
303
|
+
"@oxc-project/runtime": "0.97.0",
|
|
304
|
+
"fdir": "^6.5.0",
|
|
305
|
+
"lightningcss": "^1.30.2",
|
|
306
|
+
"picomatch": "^4.0.3",
|
|
307
|
+
"postcss": "^8.5.6",
|
|
308
|
+
"rolldown": "1.0.0-beta.50",
|
|
309
|
+
"tinyglobby": "^0.2.15"
|
|
310
|
+
},
|
|
311
|
+
"bin": {
|
|
312
|
+
"vite": "bin/vite.js"
|
|
313
|
+
},
|
|
314
|
+
"engines": {
|
|
315
|
+
"node": "^20.19.0 || >=22.12.0"
|
|
316
|
+
},
|
|
317
|
+
"funding": {
|
|
318
|
+
"url": "https://github.com/vitejs/vite?sponsor=1"
|
|
319
|
+
},
|
|
320
|
+
"optionalDependencies": {
|
|
321
|
+
"fsevents": "~2.3.3"
|
|
322
|
+
},
|
|
323
|
+
"peerDependencies": {
|
|
324
|
+
"@types/node": "^20.19.0 || >=22.12.0",
|
|
325
|
+
"esbuild": "^0.25.0",
|
|
326
|
+
"jiti": ">=1.21.0",
|
|
327
|
+
"less": "^4.0.0",
|
|
328
|
+
"sass": "^1.70.0",
|
|
329
|
+
"sass-embedded": "^1.70.0",
|
|
330
|
+
"stylus": ">=0.54.8",
|
|
331
|
+
"sugarss": "^5.0.0",
|
|
332
|
+
"terser": "^5.16.0",
|
|
333
|
+
"tsx": "^4.8.1",
|
|
334
|
+
"yaml": "^2.4.2"
|
|
335
|
+
},
|
|
336
|
+
"peerDependenciesMeta": {
|
|
337
|
+
"@types/node": {
|
|
338
|
+
"optional": true
|
|
339
|
+
},
|
|
340
|
+
"esbuild": {
|
|
341
|
+
"optional": true
|
|
342
|
+
},
|
|
343
|
+
"jiti": {
|
|
344
|
+
"optional": true
|
|
345
|
+
},
|
|
346
|
+
"less": {
|
|
347
|
+
"optional": true
|
|
348
|
+
},
|
|
349
|
+
"sass": {
|
|
350
|
+
"optional": true
|
|
351
|
+
},
|
|
352
|
+
"sass-embedded": {
|
|
353
|
+
"optional": true
|
|
354
|
+
},
|
|
355
|
+
"stylus": {
|
|
356
|
+
"optional": true
|
|
357
|
+
},
|
|
358
|
+
"sugarss": {
|
|
359
|
+
"optional": true
|
|
360
|
+
},
|
|
361
|
+
"terser": {
|
|
362
|
+
"optional": true
|
|
363
|
+
},
|
|
364
|
+
"tsx": {
|
|
365
|
+
"optional": true
|
|
366
|
+
},
|
|
367
|
+
"yaml": {
|
|
368
|
+
"optional": true
|
|
369
|
+
}
|
|
370
|
+
}
|
|
371
|
+
}
|
|
372
|
+
}
|
|
373
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "textblock",
|
|
3
|
+
"private": true,
|
|
4
|
+
"version": "1.0.0",
|
|
5
|
+
"main": "index.ts",
|
|
6
|
+
"scripts": {
|
|
7
|
+
"dev": "vite",
|
|
8
|
+
"build": "tsc && vite build",
|
|
9
|
+
"preview": "vite preview"
|
|
10
|
+
},
|
|
11
|
+
"dependencies": {
|
|
12
|
+
"@napps/component-extension": "^1.0.0"
|
|
13
|
+
},
|
|
14
|
+
"devDependencies": {
|
|
15
|
+
"typescript": "~5.9.3",
|
|
16
|
+
"vite": "npm:rolldown-vite@7.2.5"
|
|
17
|
+
},
|
|
18
|
+
"overrides": {
|
|
19
|
+
"vite": "npm:rolldown-vite@7.2.5"
|
|
20
|
+
}
|
|
21
|
+
}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import {
|
|
2
|
+
type ComponentContext,
|
|
3
|
+
ProductInfoGridComponent,
|
|
4
|
+
ProductInfoGridLayoutType,
|
|
5
|
+
} from '@napps/component-extension';
|
|
6
|
+
|
|
7
|
+
class CustomProductInfoGridComponent extends ProductInfoGridComponent {
|
|
8
|
+
onComponentCreated(): void {
|
|
9
|
+
console.log('CustomProductInfoGridComponent created');
|
|
10
|
+
this.updateState({
|
|
11
|
+
headline: 'Custom Product Info Grid Component',
|
|
12
|
+
columns: 3,
|
|
13
|
+
content: [
|
|
14
|
+
{
|
|
15
|
+
label: 'Feature 1',
|
|
16
|
+
image: 'https://tse1.mm.bing.net/th/id/OIP.1QN9rkUC3T3kmbnMfsnBIAHaE8?pid=Api',
|
|
17
|
+
},
|
|
18
|
+
{
|
|
19
|
+
label: 'Feature 2',
|
|
20
|
+
image: 'https://tse3.mm.bing.net/th/id/OIP.cvg_MdgYsY9-fKD5eV8SpgHaE5?pid=Api',
|
|
21
|
+
},
|
|
22
|
+
{
|
|
23
|
+
label: 'Feature 3',
|
|
24
|
+
image: 'https://tse4.mm.bing.net/th/id/OIP.bTJMYEgcqimQIALD__XXXQHaEo?pid=Api',
|
|
25
|
+
},
|
|
26
|
+
],
|
|
27
|
+
aspectRatio: 1,
|
|
28
|
+
hideLabels: false,
|
|
29
|
+
layoutType: ProductInfoGridLayoutType.Grid,
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
export const createComponent = (componentContext: ComponentContext) => {
|
|
35
|
+
const component = new CustomProductInfoGridComponent(componentContext);
|
|
36
|
+
component.setInitialState({
|
|
37
|
+
isCollapsable: true,
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
return component;
|
|
41
|
+
};
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import {
|
|
2
|
+
TechnicalInformationComponent,
|
|
3
|
+
type ComponentContext,
|
|
4
|
+
TablePin,
|
|
5
|
+
TableHeader,
|
|
6
|
+
TableStyle,
|
|
7
|
+
} from '@napps/component-extension';
|
|
8
|
+
|
|
9
|
+
class CustomTechnicalInfoComponent extends TechnicalInformationComponent {
|
|
10
|
+
onComponentCreated(): void {
|
|
11
|
+
this.updateState({
|
|
12
|
+
headline: 'Custom Technical Information Component',
|
|
13
|
+
content: [
|
|
14
|
+
'First line of technical info.',
|
|
15
|
+
'Second line of technical info.',
|
|
16
|
+
'Third line of technical info.',
|
|
17
|
+
'Fourth line of technical info.',
|
|
18
|
+
],
|
|
19
|
+
isTable: true,
|
|
20
|
+
isCollapsable: true,
|
|
21
|
+
tablePin: TablePin.FirstRow,
|
|
22
|
+
tableHeader: TableHeader.FirstColumn,
|
|
23
|
+
tableStyle: TableStyle.Stripes,
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export const createComponent = (componentContext: ComponentContext) => {
|
|
29
|
+
const component = new CustomTechnicalInfoComponent(componentContext);
|
|
30
|
+
component.setInitialState({
|
|
31
|
+
isCollapsable: true,
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
return component;
|
|
35
|
+
};
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import {
|
|
2
|
+
type ComponentContext,
|
|
3
|
+
TextBlockComponent,
|
|
4
|
+
} from '@napps/component-extension';
|
|
5
|
+
|
|
6
|
+
class CustomTextBlockComponent extends TextBlockComponent {
|
|
7
|
+
async onComponentCreated() {
|
|
8
|
+
this.updateState(
|
|
9
|
+
'Custom Text Block Component Initialized from typescript'
|
|
10
|
+
);
|
|
11
|
+
|
|
12
|
+
// @ts-ignore
|
|
13
|
+
const product = await productService.getProductById('9097715679480');
|
|
14
|
+
const productJSON = JSON.stringify(product);
|
|
15
|
+
|
|
16
|
+
this.updateState(productJSON);
|
|
17
|
+
|
|
18
|
+
const response = await fetch(
|
|
19
|
+
'https://napps-mobile-app-teste.myshopify.com/api/2025-10/graphql.json',
|
|
20
|
+
{
|
|
21
|
+
method: 'POST',
|
|
22
|
+
headers: {
|
|
23
|
+
'X-Shopify-Storefront-Access-Token':
|
|
24
|
+
'26c778624f0aae5fffbac53a8d432cba',
|
|
25
|
+
'Content-Type': 'application/json',
|
|
26
|
+
},
|
|
27
|
+
body: JSON.stringify({
|
|
28
|
+
query: `
|
|
29
|
+
query collectionProducts {
|
|
30
|
+
collection(id: "gid://shopify/Collection/467037552888") {
|
|
31
|
+
products(first: 250) {
|
|
32
|
+
filters {
|
|
33
|
+
presentation
|
|
34
|
+
label,
|
|
35
|
+
type
|
|
36
|
+
values {
|
|
37
|
+
label,
|
|
38
|
+
swatch {
|
|
39
|
+
color
|
|
40
|
+
},
|
|
41
|
+
count,
|
|
42
|
+
input,
|
|
43
|
+
id
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
nodes {
|
|
47
|
+
options(first: 250) {
|
|
48
|
+
id,
|
|
49
|
+
name,
|
|
50
|
+
optionValues {
|
|
51
|
+
id
|
|
52
|
+
name
|
|
53
|
+
swatch {
|
|
54
|
+
color
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
`,
|
|
63
|
+
}),
|
|
64
|
+
}
|
|
65
|
+
);
|
|
66
|
+
|
|
67
|
+
const responsePayload = await response.json();
|
|
68
|
+
|
|
69
|
+
console.log(responsePayload);
|
|
70
|
+
|
|
71
|
+
this.updateState(responsePayload);
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
export const createComponent = (componentContext: ComponentContext) => {
|
|
76
|
+
const component = new CustomTextBlockComponent(componentContext);
|
|
77
|
+
|
|
78
|
+
return component;
|
|
79
|
+
};
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
{
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
"target": "ES2022",
|
|
4
|
+
"useDefineForClassFields": true,
|
|
5
|
+
"module": "ESNext",
|
|
6
|
+
"lib": ["ES2022", "DOM", "DOM.Iterable"],
|
|
7
|
+
"types": ["vite/client"],
|
|
8
|
+
"skipLibCheck": true,
|
|
9
|
+
|
|
10
|
+
/* Bundler mode */
|
|
11
|
+
"moduleResolution": "bundler",
|
|
12
|
+
"allowImportingTsExtensions": true,
|
|
13
|
+
"verbatimModuleSyntax": true,
|
|
14
|
+
"moduleDetection": "force",
|
|
15
|
+
"noEmit": true,
|
|
16
|
+
|
|
17
|
+
/* Linting */
|
|
18
|
+
"strict": true,
|
|
19
|
+
"noUnusedLocals": true,
|
|
20
|
+
"noUnusedParameters": false,
|
|
21
|
+
"erasableSyntaxOnly": false,
|
|
22
|
+
"noFallthroughCasesInSwitch": true,
|
|
23
|
+
"noUncheckedSideEffectImports": true
|
|
24
|
+
}
|
|
25
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { defineConfig } from 'vite';
|
|
2
|
+
|
|
3
|
+
export default defineConfig({
|
|
4
|
+
build: {
|
|
5
|
+
// Specify that this is a library build
|
|
6
|
+
lib: {
|
|
7
|
+
entry: 'index.ts',
|
|
8
|
+
name: 'ComponentExtension',
|
|
9
|
+
fileName: (format) => `component-extension.${format}.js`,
|
|
10
|
+
formats: ['es'],
|
|
11
|
+
},
|
|
12
|
+
target: 'es2020',
|
|
13
|
+
},
|
|
14
|
+
});
|