create-reactive-vscode 0.2.16 → 0.2.18
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +444 -101
- package/package.json +4 -4
package/dist/index.cjs
CHANGED
|
@@ -1,106 +1,450 @@
|
|
|
1
|
-
var
|
|
2
|
-
|
|
1
|
+
var e=Object.create,t=Object.defineProperty,n=Object.getOwnPropertyDescriptor,r=Object.getOwnPropertyNames,i=Object.getPrototypeOf,a=Object.prototype.hasOwnProperty,o=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),s=(e,i,o,s)=>{if(i&&typeof i==`object`||typeof i==`function`)for(var c=r(i),l=0,u=c.length,d;l<u;l++)d=c[l],!a.call(e,d)&&d!==o&&t(e,d,{get:(e=>i[e]).bind(null,d),enumerable:!(s=n(i,d))||s.enumerable});return e},c=(n,r,a)=>(a=n==null?{}:e(i(n)),s(r||!n||!n.__esModule?t(a,`default`,{value:n,enumerable:!0}):a,n));const l=c(require(`node:fs`)),u=c(require(`node:path`)),d=c(require(`node:process`)),f=c(require(`node:os`)),p=c(require(`node:tty`)),m=10,h=(e=0)=>t=>`\u001B[${t+e}m`,g=(e=0)=>t=>`\u001B[${38+e};5;${t}m`,_=(e=0)=>(t,n,r)=>`\u001B[${38+e};2;${t};${n};${r}m`,v={modifier:{reset:[0,0],bold:[1,22],dim:[2,22],italic:[3,23],underline:[4,24],overline:[53,55],inverse:[7,27],hidden:[8,28],strikethrough:[9,29]},color:{black:[30,39],red:[31,39],green:[32,39],yellow:[33,39],blue:[34,39],magenta:[35,39],cyan:[36,39],white:[37,39],blackBright:[90,39],gray:[90,39],grey:[90,39],redBright:[91,39],greenBright:[92,39],yellowBright:[93,39],blueBright:[94,39],magentaBright:[95,39],cyanBright:[96,39],whiteBright:[97,39]},bgColor:{bgBlack:[40,49],bgRed:[41,49],bgGreen:[42,49],bgYellow:[43,49],bgBlue:[44,49],bgMagenta:[45,49],bgCyan:[46,49],bgWhite:[47,49],bgBlackBright:[100,49],bgGray:[100,49],bgGrey:[100,49],bgRedBright:[101,49],bgGreenBright:[102,49],bgYellowBright:[103,49],bgBlueBright:[104,49],bgMagentaBright:[105,49],bgCyanBright:[106,49],bgWhiteBright:[107,49]}},y=Object.keys(v.modifier),b=Object.keys(v.color),x=Object.keys(v.bgColor),S=[...b,...x];function C(){let e=new Map;for(let[t,n]of Object.entries(v)){for(let[t,r]of Object.entries(n))v[t]={open:`\u001B[${r[0]}m`,close:`\u001B[${r[1]}m`},n[t]=v[t],e.set(r[0],r[1]);Object.defineProperty(v,t,{value:n,enumerable:!1})}return Object.defineProperty(v,`codes`,{value:e,enumerable:!1}),v.color.close=`\x1B[39m`,v.bgColor.close=`\x1B[49m`,v.color.ansi=h(),v.color.ansi256=g(),v.color.ansi16m=_(),v.bgColor.ansi=h(m),v.bgColor.ansi256=g(m),v.bgColor.ansi16m=_(m),Object.defineProperties(v,{rgbToAnsi256:{value(e,t,n){return e===t&&t===n?e<8?16:e>248?231:Math.round((e-8)/247*24)+232:16+36*Math.round(e/255*5)+6*Math.round(t/255*5)+Math.round(n/255*5)},enumerable:!1},hexToRgb:{value(e){let t=/[a-f\d]{6}|[a-f\d]{3}/i.exec(e.toString(16));if(!t)return[0,0,0];let[n]=t;n.length===3&&(n=[...n].map(e=>e+e).join(``));let r=Number.parseInt(n,16);return[r>>16&255,r>>8&255,r&255]},enumerable:!1},hexToAnsi256:{value:e=>v.rgbToAnsi256(...v.hexToRgb(e)),enumerable:!1},ansi256ToAnsi:{value(e){if(e<8)return 30+e;if(e<16)return 90+(e-8);let t,n,r;if(e>=232)t=((e-232)*10+8)/255,n=t,r=t;else{e-=16;let i=e%36;t=Math.floor(e/36)/5,n=Math.floor(i/6)/5,r=i%6/5}let i=Math.max(t,n,r)*2;if(i===0)return 30;let a=30+(Math.round(r)<<2|Math.round(n)<<1|Math.round(t));return i===2&&(a+=60),a},enumerable:!1},rgbToAnsi:{value:(e,t,n)=>v.ansi256ToAnsi(v.rgbToAnsi256(e,t,n)),enumerable:!1},hexToAnsi:{value:e=>v.ansi256ToAnsi(v.hexToAnsi256(e)),enumerable:!1}}),v}const w=C();var T=w;function E(e,t=globalThis.Deno?globalThis.Deno.args:d.default.argv){let n=e.startsWith(`-`)?``:e.length===1?`-`:`--`,r=t.indexOf(n+e),i=t.indexOf(`--`);return r!==-1&&(i===-1||r<i)}const{env:D}=d.default;let O;E(`no-color`)||E(`no-colors`)||E(`color=false`)||E(`color=never`)?O=0:(E(`color`)||E(`colors`)||E(`color=true`)||E(`color=always`))&&(O=1);function ee(){if(`FORCE_COLOR`in D)return D.FORCE_COLOR===`true`?1:D.FORCE_COLOR===`false`?0:D.FORCE_COLOR.length===0?1:Math.min(Number.parseInt(D.FORCE_COLOR,10),3)}function te(e){return e===0?!1:{level:e,hasBasic:!0,has256:e>=2,has16m:e>=3}}function ne(e,{streamIsTTY:t,sniffFlags:n=!0}={}){let r=ee();r!==void 0&&(O=r);let i=n?O:r;if(i===0)return 0;if(n){if(E(`color=16m`)||E(`color=full`)||E(`color=truecolor`))return 3;if(E(`color=256`))return 2}if(`TF_BUILD`in D&&`AGENT_NAME`in D)return 1;if(e&&!t&&i===void 0)return 0;let a=i||0;if(D.TERM===`dumb`)return a;if(d.default.platform===`win32`){let e=f.default.release().split(`.`);return Number(e[0])>=10&&Number(e[2])>=10586?Number(e[2])>=14931?3:2:1}if(`CI`in D)return[`GITHUB_ACTIONS`,`GITEA_ACTIONS`,`CIRCLECI`].some(e=>e in D)?3:[`TRAVIS`,`APPVEYOR`,`GITLAB_CI`,`BUILDKITE`,`DRONE`].some(e=>e in D)||D.CI_NAME===`codeship`?1:a;if(`TEAMCITY_VERSION`in D)return/^(9\.(0*[1-9]\d*)\.|\d{2,}\.)/.test(D.TEAMCITY_VERSION)?1:0;if(D.COLORTERM===`truecolor`||D.TERM===`xterm-kitty`)return 3;if(`TERM_PROGRAM`in D){let e=Number.parseInt((D.TERM_PROGRAM_VERSION||``).split(`.`)[0],10);switch(D.TERM_PROGRAM){case`iTerm.app`:return e>=3?3:2;case`Apple_Terminal`:return 2}}return/-256(color)?$/i.test(D.TERM)?2:/^screen|^xterm|^vt100|^vt220|^rxvt|color|ansi|cygwin|linux/i.test(D.TERM)||`COLORTERM`in D?1:a}function k(e,t={}){let n=ne(e,{streamIsTTY:e&&e.isTTY,...t});return te(n)}const re={stdout:k({isTTY:p.default.isatty(1)}),stderr:k({isTTY:p.default.isatty(2)})};var ie=re;function ae(e,t,n){let r=e.indexOf(t);if(r===-1)return e;let i=t.length,a=0,o=``;do o+=e.slice(a,r)+t+n,a=r+i,r=e.indexOf(t,a);while(r!==-1);return o+=e.slice(a),o}function oe(e,t,n,r){let i=0,a=``;do{let o=e[r-1]===`\r`;a+=e.slice(i,o?r-1:r)+t+(o?`\r
|
|
2
|
+
`:`
|
|
3
|
+
`)+n,i=r+1,r=e.indexOf(`
|
|
4
|
+
`,i)}while(r!==-1);return a+=e.slice(i),a}const{stdout:A,stderr:se}=ie,j=Symbol(`GENERATOR`),M=Symbol(`STYLER`),N=Symbol(`IS_EMPTY`),P=[`ansi`,`ansi`,`ansi256`,`ansi16m`],F=Object.create(null),ce=(e,t={})=>{if(t.level&&!(Number.isInteger(t.level)&&t.level>=0&&t.level<=3))throw Error("The `level` option should be an integer from 0 to 3");let n=A?A.level:0;e.level=t.level===void 0?n:t.level},le=e=>{let t=(...e)=>e.join(` `);return ce(t,e),Object.setPrototypeOf(t,I.prototype),t};function I(e){return le(e)}Object.setPrototypeOf(I.prototype,Function.prototype);for(let[e,t]of Object.entries(T))F[e]={get(){let n=z(this,R(t.open,t.close,this[M]),this[N]);return Object.defineProperty(this,e,{value:n}),n}};F.visible={get(){let e=z(this,this[M],!0);return Object.defineProperty(this,`visible`,{value:e}),e}};const L=(e,t,n,...r)=>e===`rgb`?t===`ansi16m`?T[n].ansi16m(...r):t===`ansi256`?T[n].ansi256(T.rgbToAnsi256(...r)):T[n].ansi(T.rgbToAnsi(...r)):e===`hex`?L(`rgb`,t,n,...T.hexToRgb(...r)):T[n][e](...r),ue=[`rgb`,`hex`,`ansi256`];for(let e of ue){F[e]={get(){let{level:t}=this;return function(...n){let r=R(L(e,P[t],`color`,...n),T.color.close,this[M]);return z(this,r,this[N])}}};let t=`bg`+e[0].toUpperCase()+e.slice(1);F[t]={get(){let{level:t}=this;return function(...n){let r=R(L(e,P[t],`bgColor`,...n),T.bgColor.close,this[M]);return z(this,r,this[N])}}}}const de=Object.defineProperties(()=>{},{...F,level:{enumerable:!0,get(){return this[j].level},set(e){this[j].level=e}}}),R=(e,t,n)=>{let r,i;return n===void 0?(r=e,i=t):(r=n.openAll+e,i=t+n.closeAll),{open:e,close:t,openAll:r,closeAll:i,parent:n}},z=(e,t,n)=>{let r=(...e)=>fe(r,e.length===1?``+e[0]:e.join(` `));return Object.setPrototypeOf(r,de),r[j]=e,r[M]=t,r[N]=n,r},fe=(e,t)=>{if(e.level<=0||!t)return e[N]?``:t;let n=e[M];if(n===void 0)return t;let{openAll:r,closeAll:i}=n;if(t.includes(`\x1B`))for(;n!==void 0;)t=ae(t,n.close,n.open),n=n.parent;let a=t.indexOf(`
|
|
5
|
+
`);return a!==-1&&(t=oe(t,i,r,a)),r+t+i};Object.defineProperties(I.prototype,F);const pe=I(),me=I({level:se?se.level:0});var B=pe,V=o((exports,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}),he=o((exports,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}}}),H=o((exports,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}}),U=o((exports,t)=>{let n=`\x1B`,r=`${n}[`,i=`\x07`,a={to(e,t){return t?`${r}${t+1};${e+1}H`:`${r}${e+1}G`},move(e,t){let n=``;return e<0?n+=`${r}${-e}D`:e>0&&(n+=`${r}${e}C`),t<0?n+=`${r}${-t}A`:t>0&&(n+=`${r}${t}B`),n},up:(e=1)=>`${r}${e}A`,down:(e=1)=>`${r}${e}B`,forward:(e=1)=>`${r}${e}C`,backward:(e=1)=>`${r}${e}D`,nextLine:(e=1)=>`${r}E`.repeat(e),prevLine:(e=1)=>`${r}F`.repeat(e),left:`${r}G`,hide:`${r}?25l`,show:`${r}?25h`,save:`${n}7`,restore:`${n}8`},o={up:(e=1)=>`${r}S`.repeat(e),down:(e=1)=>`${r}T`.repeat(e)},s={screen:`${r}2J`,up:(e=1)=>`${r}1J`.repeat(e),down:(e=1)=>`${r}J`.repeat(e),line:`${r}2K`,lineEnd:`${r}K`,lineStart:`${r}1K`,lines(e){let t=``;for(let n=0;n<e;n++)t+=this.line+(n<e-1?a.up():``);return e&&(t+=a.left),t}};t.exports={cursor:a,scroll:o,erase:s,beep:i}}),ge=o((exports,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.
|
|
6
|
+
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=H(),o=U(),s=o.erase,c=o.cursor,l=e=>[...a(e)].length;
|
|
7
|
+
/**
|
|
8
|
+
* @param {string} prompt
|
|
9
|
+
* @param {number} perLine
|
|
10
|
+
*/
|
|
11
|
+
t.exports=function(e,t){if(!t)return s.line+c.to(0);let r=0,i=e.split(/\r?\n/);var a=n(i),o;try{for(a.s();!(o=a.n()).done;){let e=o.value;r+=1+Math.floor(Math.max(l(e)-1,0)/t)}}catch(e){a.e(e)}finally{a.f()}return s.lines(r)}}),W=o((exports,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:`>`},i=process.platform===`win32`?r:n;t.exports=i}),_e=o((exports,t)=>{let n=V(),r=W(),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(`?`)}),s=(e,t,n)=>t?o.aborted:n?o.exited:e?o.done:o.default,c=e=>n.gray(e?r.ellipsis:r.pointerSmall),l=(e,t)=>n.gray(e?t?r.pointerSmall:`+`:r.line);t.exports={styles:i,render:a,symbols:o,symbol:s,delimiter:c,item:l}}),ve=o((exports,t)=>{let n=H();
|
|
12
|
+
/**
|
|
13
|
+
* @param {string} msg
|
|
14
|
+
* @param {number} perLine
|
|
15
|
+
*/
|
|
16
|
+
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}}),ye=o((exports,t)=>{
|
|
17
|
+
/**
|
|
18
|
+
* @param {string} msg The message to wrap
|
|
19
|
+
* @param {object} opts
|
|
20
|
+
* @param {number|string} [opts.margin] Left margin
|
|
21
|
+
* @param {number} opts.width Maximum characters per line including the margin
|
|
22
|
+
*/
|
|
23
|
+
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
24
|
`)).join(`
|
|
4
|
-
`)}})
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
25
|
+
`)}}),be=o((exports,t)=>{
|
|
26
|
+
/**
|
|
27
|
+
* Determine what entries should be displayed on the screen, based on the
|
|
28
|
+
* currently selected index and the maximum visible. Used in list-based
|
|
29
|
+
* prompts like `select` and `multiselect`.
|
|
30
|
+
*
|
|
31
|
+
* @param {number} cursor the currently selected entry
|
|
32
|
+
* @param {number} total the total entries available to display
|
|
33
|
+
* @param {number} [maxVisible] the number of entries that can be displayed
|
|
34
|
+
*/
|
|
35
|
+
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}}}),G=o((exports,t)=>{t.exports={action:he(),clear:ge(),style:_e(),strip:H(),figures:W(),lines:ve(),wrap:ye(),entriesToDisplay:be()}}),K=o((exports,t)=>{let n=require(`readline`),r=G(),i=r.action,a=require(`events`),o=U(),s=o.beep,c=o.cursor,l=V();
|
|
36
|
+
/**
|
|
37
|
+
* Base prompt skeleton
|
|
38
|
+
* @param {Stream} [opts.stdin] The Readable stream to listen to
|
|
39
|
+
* @param {Stream} [opts.stdout] The Writable stream to write readline data to
|
|
40
|
+
*/
|
|
41
|
+
var u=class extends a{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 r=[`SelectPrompt`,`MultiselectPrompt`].indexOf(this.constructor.name)>-1,a=(e,t)=>{let n=i(t,r);n===!1?this._&&this._(e,t):typeof this[n]==`function`?this[n](t):this.bell()};this.close=()=>{this.out.write(c.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(s)}render(){this.onRender(l),this.firstRender&&=!1}};t.exports=u}),xe=o((exports,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=V(),a=K(),o=U(),s=o.erase,c=o.cursor,l=G(),u=l.style,d=l.clear,f=l.lines,p=l.figures;
|
|
42
|
+
/**
|
|
43
|
+
* TextPrompt Base Element
|
|
44
|
+
* @param {Object} opts Options
|
|
45
|
+
* @param {String} opts.message Message
|
|
46
|
+
* @param {String} [opts.style='default'] Render style
|
|
47
|
+
* @param {String} [opts.initial] Default value
|
|
48
|
+
* @param {Function} [opts.validate] Validate function
|
|
49
|
+
* @param {Stream} [opts.stdin] The Readable stream to listen to
|
|
50
|
+
* @param {Stream} [opts.stdout] The Writable stream to write readline data to
|
|
51
|
+
* @param {String} [opts.error] The invalid error label
|
|
52
|
+
*/
|
|
53
|
+
var m=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(`
|
|
54
|
+
`),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(`
|
|
55
|
+
`),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),r=this.value.slice(this.cursor);this.value=`${n}${e}${r}`,this.red=!1,this.cursor=this.placeholder?0:n.length+1,this.render()}delete(){if(this.isCursorAtStart())return this.bell();let e=this.value.slice(0,this.cursor-1),t=this.value.slice(this.cursor);this.value=`${e}${t}`,this.red=!1,this.isCursorAtStart()?this.cursorOffset=0:(this.cursorOffset++,this.moveCursor(-1)),this.render()}deleteForward(){if(this.cursor*this.scale>=this.rendered.length||this.placeholder)return this.bell();let e=this.value.slice(0,this.cursor),t=this.value.slice(this.cursor+1);this.value=`${e}${t}`,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(`
|
|
56
|
+
`).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)))}};t.exports=m}),Se=o((exports,t)=>{let n=V(),r=K(),i=G(),a=i.style,o=i.clear,s=i.figures,c=i.wrap,l=i.entriesToDisplay,u=U(),d=u.cursor;
|
|
57
|
+
/**
|
|
58
|
+
* SelectPrompt Base Element
|
|
59
|
+
* @param {Object} opts Options
|
|
60
|
+
* @param {String} opts.message Message
|
|
61
|
+
* @param {Array} opts.choices Array of choice objects
|
|
62
|
+
* @param {String} [opts.hint] Hint to display
|
|
63
|
+
* @param {Number} [opts.initial] Index of default value
|
|
64
|
+
* @param {Stream} [opts.stdin] The Readable stream to listen to
|
|
65
|
+
* @param {Stream} [opts.stdout] The Writable stream to write readline data to
|
|
66
|
+
* @param {Number} [opts.optionsPerPage=10] Max options to display at once
|
|
67
|
+
*/
|
|
68
|
+
var f=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(`
|
|
9
69
|
`),this.close()}submit(){this.selection.disabled?this.bell():(this.done=!0,this.aborted=!1,this.fire(),this.render(),this.out.write(`
|
|
10
|
-
`),this.close())}first(){this.moveCursor(0),this.render()}last(){this.moveCursor(this.choices.length-1),this.render()}up(){this.cursor===0?this.moveCursor(this.choices.length-1):this.moveCursor(this.cursor-1),this.render()}down(){this.cursor===this.choices.length-1?this.moveCursor(0):this.moveCursor(this.cursor+1),this.render()}next(){this.moveCursor((this.cursor+1)%this.choices.length),this.render()}_(e,t){if(e
|
|
11
|
-
`;for(let
|
|
12
|
-
`+
|
|
13
|
-
|
|
70
|
+
`),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(d.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+=`
|
|
71
|
+
`;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=`
|
|
72
|
+
`+c(l.description,{margin:3,width:this.out.columns})))),this.outputText+=`${a} ${i}${n.gray(o)}\n`}}this.out.write(this.outputText)}};t.exports=f}),Ce=o((exports,t)=>{let n=V(),r=K(),i=G(),a=i.style,o=i.clear,s=U(),c=s.cursor,l=s.erase;
|
|
73
|
+
/**
|
|
74
|
+
* TogglePrompt Base Element
|
|
75
|
+
* @param {Object} opts Options
|
|
76
|
+
* @param {String} opts.message Message
|
|
77
|
+
* @param {Boolean} [opts.initial=false] Default value
|
|
78
|
+
* @param {String} [opts.active='no'] Active label
|
|
79
|
+
* @param {String} [opts.inactive='off'] Inactive label
|
|
80
|
+
* @param {Stream} [opts.stdin] The Readable stream to listen to
|
|
81
|
+
* @param {Stream} [opts.stdout] The Writable stream to write readline data to
|
|
82
|
+
*/
|
|
83
|
+
var u=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(`
|
|
14
84
|
`),this.close()}submit(){this.done=!0,this.aborted=!1,this.fire(),this.render(),this.out.write(`
|
|
15
|
-
`),this.close()}deactivate(){if(this.value===!1)return this.bell();this.value=!1,this.render()}activate(){if(this.value===!0)return this.bell();this.value=!0,this.render()}delete(){this.deactivate()}left(){this.deactivate()}right(){this.activate()}down(){this.deactivate()}up(){this.activate()}next(){this.value=!this.value,this.fire(),this.render()}_(e,t){if(e
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
85
|
+
`),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))}};t.exports=u}),q=o((exports,t)=>{var n=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)}};t.exports=n}),we=o((exports,t)=>{let n=q();var r=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}};t.exports=r}),Te=o((exports,t)=>{let n=q(),r=e=>(e%=10,e===1?`st`:e===2?`nd`:e===3?`rd`:`th`);var i=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}};t.exports=i}),Ee=o((exports,t)=>{let n=q();var r=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}};t.exports=r}),De=o((exports,t)=>{let n=q();var r=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)}};t.exports=r}),Oe=o((exports,t)=>{let n=q();var r=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}};t.exports=r}),ke=o((exports,t)=>{let n=q();var r=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)}};t.exports=r}),Ae=o((exports,t)=>{let n=q();var r=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}};t.exports=r}),je=o((exports,t)=>{let n=q();var r=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}};t.exports=r}),Me=o((exports,t)=>{t.exports={DatePart:q(),Meridiem:we(),Day:Te(),Hours:Ee(),Milliseconds:De(),Minutes:Oe(),Month:ke(),Seconds:Ae(),Year:je()}}),Ne=o((exports,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=V(),a=K(),o=G(),s=o.style,c=o.clear,l=o.figures,u=U(),d=u.erase,f=u.cursor,p=Me(),m=p.DatePart,h=p.Meridiem,g=p.Day,_=p.Hours,v=p.Milliseconds,y=p.Minutes,b=p.Month,x=p.Seconds,S=p.Year,C=/\\(.)|"((?:\\["\\]|[^"])+)"|(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,w={1:({token:e})=>e.replace(/\\(.)/g,`$1`),2:e=>new g(e),3:e=>new b(e),4:e=>new S(e),5:e=>new h(e),6:e=>new _(e),7:e=>new y(e),8:e=>new x(e),9:e=>new v(e)},T={months:`January,February,March,April,May,June,July,August,September,October,November,December`.split(`,`),monthsShort:`Jan,Feb,Mar,Apr,May,Jun,Jul,Aug,Sep,Oct,Nov,Dec`.split(`,`),weekdays:`Sunday,Monday,Tuesday,Wednesday,Thursday,Friday,Saturday`.split(`,`),weekdaysShort:`Sun,Mon,Tue,Wed,Thu,Fri,Sat`.split(`,`)};
|
|
86
|
+
/**
|
|
87
|
+
* DatePrompt Base Element
|
|
88
|
+
* @param {Object} opts Options
|
|
89
|
+
* @param {String} opts.message Message
|
|
90
|
+
* @param {Number} [opts.initial] Index of default value
|
|
91
|
+
* @param {String} [opts.mask] The format mask
|
|
92
|
+
* @param {object} [opts.locales] The date locales
|
|
93
|
+
* @param {String} [opts.error] The error message shown on invalid value
|
|
94
|
+
* @param {Function} [opts.validate] Function to validate the submitted value
|
|
95
|
+
* @param {Stream} [opts.stdin] The Readable stream to listen to
|
|
96
|
+
* @param {Stream} [opts.stdout] The Writable stream to write readline data to
|
|
97
|
+
*/
|
|
98
|
+
var E=class extends a{constructor(e={}){super(e),this.msg=e.message,this.cursor=0,this.typed=``,this.locales=Object.assign(T,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=C.exec(e);){let e=t.shift(),n=t.findIndex(e=>e!=null);this.parts.push(n in w?w[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(`
|
|
99
|
+
`),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(`
|
|
100
|
+
`),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(`
|
|
101
|
+
`).reduce((e,t,n)=>e+`\n${n?` `:l.pointerSmall} ${i.red().italic(t)}`,``)),this.out.write(d.line+f.to(0)+this.outputText))}};t.exports=E}),Pe=o((exports,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=V(),a=K(),o=U(),s=o.cursor,c=o.erase,l=G(),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};
|
|
102
|
+
/**
|
|
103
|
+
* NumberPrompt Base Element
|
|
104
|
+
* @param {Object} opts Options
|
|
105
|
+
* @param {String} opts.message Message
|
|
106
|
+
* @param {String} [opts.style='default'] Render style
|
|
107
|
+
* @param {Number} [opts.initial] Default value
|
|
108
|
+
* @param {Number} [opts.max=+Infinity] Max value
|
|
109
|
+
* @param {Number} [opts.min=-Infinity] Min value
|
|
110
|
+
* @param {Boolean} [opts.float=false] Parse input as floats
|
|
111
|
+
* @param {Number} [opts.round=2] Round floats to x decimals
|
|
112
|
+
* @param {Number} [opts.increment=1] Number to increment by when using arrow-keys
|
|
113
|
+
* @param {Function} [opts.validate] Validate function
|
|
114
|
+
* @param {Stream} [opts.stdin] The Readable stream to listen to
|
|
115
|
+
* @param {Stream} [opts.stdout] The Writable stream to write readline data to
|
|
116
|
+
* @param {String} [opts.error] The invalid error label
|
|
117
|
+
*/
|
|
118
|
+
var _=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(`
|
|
119
|
+
`),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(`
|
|
120
|
+
`),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(`
|
|
121
|
+
`).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))}};t.exports=_}),J=o((exports,t)=>{let n=V(),r=U(),i=r.cursor,a=K(),o=G(),s=o.clear,c=o.figures,l=o.style,u=o.wrap,d=o.entriesToDisplay;
|
|
122
|
+
/**
|
|
123
|
+
* MultiselectPrompt Base Element
|
|
124
|
+
* @param {Object} opts Options
|
|
125
|
+
* @param {String} opts.message Message
|
|
126
|
+
* @param {Array} opts.choices Array of choice objects
|
|
127
|
+
* @param {String} [opts.hint] Hint to display
|
|
128
|
+
* @param {String} [opts.warn] Hint shown for disabled choices
|
|
129
|
+
* @param {Number} [opts.max] Max choices
|
|
130
|
+
* @param {Number} [opts.cursor=0] Cursor start position
|
|
131
|
+
* @param {Number} [opts.optionsPerPage=10] Max options to display at once
|
|
132
|
+
* @param {Stream} [opts.stdin] The Readable stream to listen to
|
|
133
|
+
* @param {Stream} [opts.stdout] The Writable stream to write readline data to
|
|
134
|
+
*/
|
|
135
|
+
var f=class extends a{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=s(``,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(`
|
|
136
|
+
`),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(`
|
|
137
|
+
`),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:`
|
|
26
138
|
Instructions:
|
|
27
|
-
${
|
|
28
|
-
${
|
|
29
|
-
`+(this.
|
|
30
|
-
`:"")+" enter/return: Complete answer":""}renderOption(e,t,s,r){let n=(t.selected?$.green(H.radioOn):H.radioOff)+" "+r+" ",o,l;return t.disabled?o=e===s?$.gray().underline(t.title):$.strikethrough().gray(t.title):(o=e===s?$.cyan().underline(t.title):t.title,e===s&&t.description&&(l=` - ${t.description}`,(n.length+o.length+l.length>=this.out.columns||t.description.split(/\r?\n/).length>1)&&(l=`
|
|
31
|
-
`+Ul(t.description,{margin:n.length,width:this.out.columns})))),n+o+$.gray(l||"")}paginateOptions(e){if(e.length===0)return $.red("No matches for this query.");let t=Wl(this.cursor,e.length,this.optionsPerPage),s=t.startIndex,r=t.endIndex,n,o=[];for(let l=s;l<r;l++)l===s&&s>0?n=H.arrowUp:l===r-1&&r<e.length?n=H.arrowDown:n=" ",o.push(this.renderOption(this.cursor,e[l],l,n));return`
|
|
139
|
+
${c.arrowUp}/${c.arrowDown}: Highlight option\n ${c.arrowLeft}/${c.arrowRight}/[space]: Toggle selection\n`+(this.maxChoices===void 0?` a: Toggle all
|
|
140
|
+
`:``)+` enter/return: Complete answer`:``}renderOption(e,t,r,i){let a=(t.selected?n.green(c.radioOn):c.radioOff)+` `+i+` `,o,s;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&&(s=` - ${t.description}`,(a.length+o.length+s.length>=this.out.columns||t.description.split(/\r?\n/).length>1)&&(s=`
|
|
141
|
+
`+u(t.description,{margin:a.length,width:this.out.columns})))),a+o+n.gray(s||``)}paginateOptions(e){if(e.length===0)return n.red(`No matches for this query.`);let t=d(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?c.arrowUp:t===i-1&&i<e.length?c.arrowDown:` `,o.push(this.renderOption(this.cursor,e[t],t,a));return`
|
|
32
142
|
`+o.join(`
|
|
33
|
-
`)}renderOptions(e){return this.done
|
|
143
|
+
`)}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(i.hide),super.render();let e=[l.symbol(this.done,this.aborted),n.bold(this.msg),l.delimiter(!1),this.renderDoneOrInstructions()].join(` `);this.showMinError&&(e+=n.red(`You must select a minimum of ${this.minSelected} choices.`),this.showMinError=!1),e+=this.renderOptions(this.value),this.out.write(this.clear+e),this.clear=s(e,this.out.columns)}};t.exports=f}),Fe=o((exports,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=V(),a=K(),o=U(),s=o.erase,c=o.cursor,l=G(),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};
|
|
144
|
+
/**
|
|
145
|
+
* TextPrompt Base Element
|
|
146
|
+
* @param {Object} opts Options
|
|
147
|
+
* @param {String} opts.message Message
|
|
148
|
+
* @param {Array} opts.choices Array of auto-complete choices objects
|
|
149
|
+
* @param {Function} [opts.suggest] Filter function. Defaults to sort by title
|
|
150
|
+
* @param {Number} [opts.limit=10] Max number of results to show
|
|
151
|
+
* @param {Number} [opts.cursor=0] Cursor start position
|
|
152
|
+
* @param {String} [opts.style='default'] Render style
|
|
153
|
+
* @param {String} [opts.fallback] Fallback message - initial to default value
|
|
154
|
+
* @param {String} [opts.initial] Index of the default value
|
|
155
|
+
* @param {Boolean} [opts.clearFirst] The first ESCAPE keypress will clear the input
|
|
156
|
+
* @param {Stream} [opts.stdin] The Readable stream to listen to
|
|
157
|
+
* @param {Stream} [opts.stdout] The Writable stream to write readline data to
|
|
158
|
+
* @param {String} [opts.noMatches] The no matches found label
|
|
159
|
+
*/
|
|
160
|
+
var v=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(`
|
|
34
161
|
`),this.close())}abort(){this.done=this.aborted=!0,this.exited=!1,this.fire(),this.render(),this.out.write(`
|
|
35
162
|
`),this.close()}submit(){this.done=!0,this.aborted=this.exited=!1,this.fire(),this.render(),this.out.write(`
|
|
36
|
-
`),this.close()}_(e,t){let
|
|
37
|
-
`+
|
|
163
|
+
`),this.close()}_(e,t){let n=this.input.slice(0,this.cursor),r=this.input.slice(this.cursor);this.input=`${n}${e}${r}`,this.cursor=n.length+1,this.complete(this.render),this.render()}delete(){if(this.cursor===0)return this.bell();let e=this.input.slice(0,this.cursor-1),t=this.input.slice(this.cursor);this.input=`${e}${t}`,this.complete(this.render),--this.cursor,this.render()}deleteForward(){if(this.cursor*this.scale>=this.rendered.length)return this.bell();let e=this.input.slice(0,this.cursor),t=this.input.slice(this.cursor+1);this.input=`${e}${t}`,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=`
|
|
164
|
+
`+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(`
|
|
38
165
|
`);this.outputText+=`
|
|
39
|
-
`+(
|
|
166
|
+
`+(e||i.gray(this.fallback.title))}this.out.write(s.line+c.to(0)+this.outputText)}};t.exports=v}),Ie=o((exports,t)=>{let n=V(),r=U(),i=r.cursor,a=J(),o=G(),s=o.clear,c=o.style,l=o.figures;
|
|
167
|
+
/**
|
|
168
|
+
* MultiselectPrompt Base Element
|
|
169
|
+
* @param {Object} opts Options
|
|
170
|
+
* @param {String} opts.message Message
|
|
171
|
+
* @param {Array} opts.choices Array of choice objects
|
|
172
|
+
* @param {String} [opts.hint] Hint to display
|
|
173
|
+
* @param {String} [opts.warn] Hint shown for disabled choices
|
|
174
|
+
* @param {Number} [opts.max] Max choices
|
|
175
|
+
* @param {Number} [opts.cursor=0] Cursor start position
|
|
176
|
+
* @param {Stream} [opts.stdin] The Readable stream to listen to
|
|
177
|
+
* @param {Stream} [opts.stdout] The Writable stream to write readline data to
|
|
178
|
+
*/
|
|
179
|
+
var u=class extends a{constructor(e={}){e.overrideRender=!0,super(e),this.inputValue=``,this.clear=s(``,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:`
|
|
40
180
|
Instructions:
|
|
41
|
-
${
|
|
42
|
-
${
|
|
181
|
+
${l.arrowUp}/${l.arrowDown}: Highlight option
|
|
182
|
+
${l.arrowLeft}/${l.arrowRight}/[space]: Toggle selection
|
|
43
183
|
[a,b,c]/delete: Filter choices
|
|
44
184
|
enter/return: Complete answer
|
|
45
|
-
|
|
46
|
-
Filtered results for: ${this.inputValue?this.inputValue:
|
|
47
|
-
|
|
185
|
+
`:``}renderCurrentInput(){return`
|
|
186
|
+
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(l.radioOn):l.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(i.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.`),this.showMinError=!1),e+=this.renderOptions(this.filteredOptions),this.out.write(this.clear+e),this.clear=s(e,this.out.columns)}};t.exports=u}),Le=o((exports,t)=>{let n=V(),r=K(),i=G(),a=i.style,o=i.clear,s=U(),c=s.erase,l=s.cursor;
|
|
187
|
+
/**
|
|
188
|
+
* ConfirmPrompt Base Element
|
|
189
|
+
* @param {Object} opts Options
|
|
190
|
+
* @param {String} opts.message Message
|
|
191
|
+
* @param {Boolean} [opts.initial] Default value (true/false)
|
|
192
|
+
* @param {Stream} [opts.stdin] The Readable stream to listen to
|
|
193
|
+
* @param {Stream} [opts.stdout] The Writable stream to write readline data to
|
|
194
|
+
* @param {String} [opts.yes] The "Yes" label
|
|
195
|
+
* @param {String} [opts.yesOption] The "Yes" option when choosing between yes/no
|
|
196
|
+
* @param {String} [opts.no] The "No" label
|
|
197
|
+
* @param {String} [opts.noOption] The "No" option when choosing between yes/no
|
|
198
|
+
*/
|
|
199
|
+
var u=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(`
|
|
48
200
|
`),this.close()}submit(){this.value=this.value||!1,this.done=!0,this.aborted=!1,this.fire(),this.render(),this.out.write(`
|
|
49
|
-
`),this.close()}_(e,t){return e.toLowerCase()
|
|
50
|
-
|
|
201
|
+
`),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))}};t.exports=u}),Re=o((exports,t)=>{t.exports={TextPrompt:xe(),SelectPrompt:Se(),TogglePrompt:Ce(),DatePrompt:Ne(),NumberPrompt:Pe(),MultiselectPrompt:J(),AutocompletePrompt:Fe(),AutocompleteMultiselectPrompt:Ie(),ConfirmPrompt:Le()}}),ze=o(exports=>{let t=exports,n=Re(),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()));
|
|
202
|
+
/**
|
|
203
|
+
* Interactive auto-complete prompt
|
|
204
|
+
* @param {string} args.message Prompt message to display
|
|
205
|
+
* @param {Array} args.choices Array of auto-complete choices objects `[{ title, value }, ...]`
|
|
206
|
+
* @param {Function} [args.suggest] Function to filter results based on user input. Defaults to sort by `title`
|
|
207
|
+
* @param {number} [args.limit=10] Max number of results to show
|
|
208
|
+
* @param {string} [args.style="default"] Render style ('default', 'password', 'invisible')
|
|
209
|
+
* @param {String} [args.initial] Index of the default value
|
|
210
|
+
* @param {boolean} [opts.clearFirst] The first ESCAPE keypress will clear the input
|
|
211
|
+
* @param {String} [args.fallback] Fallback message - defaults to initial value
|
|
212
|
+
* @param {function} [args.onState] On state change callback
|
|
213
|
+
* @param {Stream} [args.stdin] The Readable stream to listen to
|
|
214
|
+
* @param {Stream} [args.stdout] The Writable stream to write readline data to
|
|
215
|
+
* @returns {Promise} Promise with user input
|
|
216
|
+
*/
|
|
217
|
+
t.autocomplete=e=>(e.suggest=e.suggest||a,e.choices=[].concat(e.choices||[]),i(`AutocompletePrompt`,e))}),Be=o((exports,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.
|
|
218
|
+
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=ze(),d=[`suggest`,`format`,`onState`,`validate`,`onRender`,`type`],f=()=>{};
|
|
219
|
+
/**
|
|
220
|
+
* Prompt for a series of questions
|
|
221
|
+
* @param {Array|Object} questions Single question object or Array of question objects
|
|
222
|
+
* @param {Function} [onSubmit] Callback function called on prompt submit
|
|
223
|
+
* @param {Function} [onCancel] Callback function called on cancel/abort
|
|
224
|
+
* @returns {Object} Object with values from user input
|
|
225
|
+
*/
|
|
226
|
+
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=/* @__PURE__ */ 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:_})}),Ve=o((exports,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}}}),Y=o((exports,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}}),He=o((exports,t)=>{let n=Y(),{erase:r,cursor:i}=U(),a=e=>[...n(e)].length;
|
|
227
|
+
/**
|
|
228
|
+
* @param {string} prompt
|
|
229
|
+
* @param {number} perLine
|
|
230
|
+
*/
|
|
231
|
+
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)}}),Ue=o((exports,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:`>`},i=process.platform===`win32`?r:n;t.exports=i}),We=o((exports,t)=>{let n=V(),r=Ue(),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(`?`)}),s=(e,t,n)=>t?o.aborted:n?o.exited:e?o.done:o.default,c=e=>n.gray(e?r.ellipsis:r.pointerSmall),l=(e,t)=>n.gray(e?t?r.pointerSmall:`+`:r.line);t.exports={styles:i,render:a,symbols:o,symbol:s,delimiter:c,item:l}}),Ge=o((exports,t)=>{let n=Y();
|
|
232
|
+
/**
|
|
233
|
+
* @param {string} msg
|
|
234
|
+
* @param {number} perLine
|
|
235
|
+
*/
|
|
236
|
+
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}}),Ke=o((exports,t)=>{
|
|
237
|
+
/**
|
|
238
|
+
* @param {string} msg The message to wrap
|
|
239
|
+
* @param {object} opts
|
|
240
|
+
* @param {number|string} [opts.margin] Left margin
|
|
241
|
+
* @param {number} opts.width Maximum characters per line including the margin
|
|
242
|
+
*/
|
|
243
|
+
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(`
|
|
51
244
|
`)).join(`
|
|
52
|
-
`)}})
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
245
|
+
`)}}),qe=o((exports,t)=>{
|
|
246
|
+
/**
|
|
247
|
+
* Determine what entries should be displayed on the screen, based on the
|
|
248
|
+
* currently selected index and the maximum visible. Used in list-based
|
|
249
|
+
* prompts like `select` and `multiselect`.
|
|
250
|
+
*
|
|
251
|
+
* @param {number} cursor the currently selected entry
|
|
252
|
+
* @param {number} total the total entries available to display
|
|
253
|
+
* @param {number} [maxVisible] the number of entries that can be displayed
|
|
254
|
+
*/
|
|
255
|
+
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}}}),X=o((exports,t)=>{t.exports={action:Ve(),clear:He(),style:We(),strip:Y(),figures:Ue(),lines:Ge(),wrap:Ke(),entriesToDisplay:qe()}}),Z=o((exports,t)=>{let n=require(`readline`),{action:r}=X(),i=require(`events`),{beep:a,cursor:o}=U(),s=V();
|
|
256
|
+
/**
|
|
257
|
+
* Base prompt skeleton
|
|
258
|
+
* @param {Stream} [opts.stdin] The Readable stream to listen to
|
|
259
|
+
* @param {Stream} [opts.stdout] The Writable stream to write readline data to
|
|
260
|
+
*/
|
|
261
|
+
var c=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}};t.exports=c}),Je=o((exports,t)=>{let n=V(),r=Z(),{erase:i,cursor:a}=U(),{style:o,clear:s,lines:c,figures:l}=X();
|
|
262
|
+
/**
|
|
263
|
+
* TextPrompt Base Element
|
|
264
|
+
* @param {Object} opts Options
|
|
265
|
+
* @param {String} opts.message Message
|
|
266
|
+
* @param {String} [opts.style='default'] Render style
|
|
267
|
+
* @param {String} [opts.initial] Default value
|
|
268
|
+
* @param {Function} [opts.validate] Validate function
|
|
269
|
+
* @param {Stream} [opts.stdin] The Readable stream to listen to
|
|
270
|
+
* @param {Stream} [opts.stdout] The Writable stream to write readline data to
|
|
271
|
+
* @param {String} [opts.error] The invalid error label
|
|
272
|
+
*/
|
|
273
|
+
var u=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(`
|
|
274
|
+
`),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(`
|
|
275
|
+
`),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),r=this.value.slice(this.cursor);this.value=`${n}${e}${r}`,this.red=!1,this.cursor=this.placeholder?0:n.length+1,this.render()}delete(){if(this.isCursorAtStart())return this.bell();let e=this.value.slice(0,this.cursor-1),t=this.value.slice(this.cursor);this.value=`${e}${t}`,this.red=!1,this.isCursorAtStart()?this.cursorOffset=0:(this.cursorOffset++,this.moveCursor(-1)),this.render()}deleteForward(){if(this.cursor*this.scale>=this.rendered.length||this.placeholder)return this.bell();let e=this.value.slice(0,this.cursor),t=this.value.slice(this.cursor+1);this.value=`${e}${t}`,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(`
|
|
276
|
+
`).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)))}};t.exports=u}),Ye=o((exports,t)=>{let n=V(),r=Z(),{style:i,clear:a,figures:o,wrap:s,entriesToDisplay:c}=X(),{cursor:l}=U();
|
|
277
|
+
/**
|
|
278
|
+
* SelectPrompt Base Element
|
|
279
|
+
* @param {Object} opts Options
|
|
280
|
+
* @param {String} opts.message Message
|
|
281
|
+
* @param {Array} opts.choices Array of choice objects
|
|
282
|
+
* @param {String} [opts.hint] Hint to display
|
|
283
|
+
* @param {Number} [opts.initial] Index of default value
|
|
284
|
+
* @param {Stream} [opts.stdin] The Readable stream to listen to
|
|
285
|
+
* @param {Stream} [opts.stdout] The Writable stream to write readline data to
|
|
286
|
+
* @param {Number} [opts.optionsPerPage=10] Max options to display at once
|
|
287
|
+
*/
|
|
288
|
+
var u=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(`
|
|
57
289
|
`),this.close()}submit(){this.selection.disabled?this.bell():(this.done=!0,this.aborted=!1,this.fire(),this.render(),this.out.write(`
|
|
58
|
-
`),this.close())}first(){this.moveCursor(0),this.render()}last(){this.moveCursor(this.choices.length-1),this.render()}up(){this.cursor===0?this.moveCursor(this.choices.length-1):this.moveCursor(this.cursor-1),this.render()}down(){this.cursor===this.choices.length-1?this.moveCursor(0):this.moveCursor(this.cursor+1),this.render()}next(){this.moveCursor((this.cursor+1)%this.choices.length),this.render()}_(e,t){if(e
|
|
59
|
-
`;for(let
|
|
60
|
-
`+
|
|
61
|
-
|
|
290
|
+
`),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+=`
|
|
291
|
+
`;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=`
|
|
292
|
+
`+s(l.description,{margin:3,width:this.out.columns})))),this.outputText+=`${a} ${i}${n.gray(c)}\n`}}this.out.write(this.outputText)}};t.exports=u}),Xe=o((exports,t)=>{let n=V(),r=Z(),{style:i,clear:a}=X(),{cursor:o,erase:s}=U();
|
|
293
|
+
/**
|
|
294
|
+
* TogglePrompt Base Element
|
|
295
|
+
* @param {Object} opts Options
|
|
296
|
+
* @param {String} opts.message Message
|
|
297
|
+
* @param {Boolean} [opts.initial=false] Default value
|
|
298
|
+
* @param {String} [opts.active='no'] Active label
|
|
299
|
+
* @param {String} [opts.inactive='off'] Inactive label
|
|
300
|
+
* @param {Stream} [opts.stdin] The Readable stream to listen to
|
|
301
|
+
* @param {Stream} [opts.stdout] The Writable stream to write readline data to
|
|
302
|
+
*/
|
|
303
|
+
var c=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(`
|
|
62
304
|
`),this.close()}submit(){this.done=!0,this.aborted=!1,this.fire(),this.render(),this.out.write(`
|
|
63
|
-
`),this.close()}deactivate(){if(this.value===!1)return this.bell();this.value=!1,this.render()}activate(){if(this.value===!0)return this.bell();this.value=!0,this.render()}delete(){this.deactivate()}left(){this.deactivate()}right(){this.activate()}down(){this.deactivate()}up(){this.activate()}next(){this.value=!this.value,this.fire(),this.render()}_(e,t){if(e
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
305
|
+
`),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))}};t.exports=c}),Q=o((exports,t)=>{var n=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)}};t.exports=n}),Ze=o((exports,t)=>{let n=Q();var r=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}};t.exports=r}),Qe=o((exports,t)=>{let n=Q(),r=e=>(e%=10,e===1?`st`:e===2?`nd`:e===3?`rd`:`th`);var i=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}};t.exports=i}),$e=o((exports,t)=>{let n=Q();var r=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}};t.exports=r}),et=o((exports,t)=>{let n=Q();var r=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)}};t.exports=r}),tt=o((exports,t)=>{let n=Q();var r=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}};t.exports=r}),nt=o((exports,t)=>{let n=Q();var r=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)}};t.exports=r}),rt=o((exports,t)=>{let n=Q();var r=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}};t.exports=r}),it=o((exports,t)=>{let n=Q();var r=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}};t.exports=r}),at=o((exports,t)=>{t.exports={DatePart:Q(),Meridiem:Ze(),Day:Qe(),Hours:$e(),Milliseconds:et(),Minutes:tt(),Month:nt(),Seconds:rt(),Year:it()}}),ot=o((exports,t)=>{let n=V(),r=Z(),{style:i,clear:a,figures:o}=X(),{erase:s,cursor:c}=U(),{DatePart:l,Meridiem:u,Day:d,Hours:f,Milliseconds:p,Minutes:m,Month:h,Seconds:g,Year:_}=at(),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)},b={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(`,`)};
|
|
306
|
+
/**
|
|
307
|
+
* DatePrompt Base Element
|
|
308
|
+
* @param {Object} opts Options
|
|
309
|
+
* @param {String} opts.message Message
|
|
310
|
+
* @param {Number} [opts.initial] Index of default value
|
|
311
|
+
* @param {String} [opts.mask] The format mask
|
|
312
|
+
* @param {object} [opts.locales] The date locales
|
|
313
|
+
* @param {String} [opts.error] The error message shown on invalid value
|
|
314
|
+
* @param {Function} [opts.validate] Function to validate the submitted value
|
|
315
|
+
* @param {Stream} [opts.stdin] The Readable stream to listen to
|
|
316
|
+
* @param {Stream} [opts.stdout] The Writable stream to write readline data to
|
|
317
|
+
*/
|
|
318
|
+
var x=class extends r{constructor(e={}){super(e),this.msg=e.message,this.cursor=0,this.typed=``,this.locales=Object.assign(b,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(`
|
|
319
|
+
`),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(`
|
|
320
|
+
`),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(`
|
|
321
|
+
`).reduce((e,t,r)=>e+`\n${r?` `:o.pointerSmall} ${n.red().italic(t)}`,``)),this.out.write(s.line+c.to(0)+this.outputText))}};t.exports=x}),st=o((exports,t)=>{let n=V(),r=Z(),{cursor:i,erase:a}=U(),{style:o,figures:s,clear:c,lines:l}=X(),u=/[0-9]/,d=e=>e!==void 0,f=(e,t)=>{let n=10**t;return Math.round(e*n)/n};
|
|
322
|
+
/**
|
|
323
|
+
* NumberPrompt Base Element
|
|
324
|
+
* @param {Object} opts Options
|
|
325
|
+
* @param {String} opts.message Message
|
|
326
|
+
* @param {String} [opts.style='default'] Render style
|
|
327
|
+
* @param {Number} [opts.initial] Default value
|
|
328
|
+
* @param {Number} [opts.max=+Infinity] Max value
|
|
329
|
+
* @param {Number} [opts.min=-Infinity] Min value
|
|
330
|
+
* @param {Boolean} [opts.float=false] Parse input as floats
|
|
331
|
+
* @param {Number} [opts.round=2] Round floats to x decimals
|
|
332
|
+
* @param {Number} [opts.increment=1] Number to increment by when using arrow-keys
|
|
333
|
+
* @param {Function} [opts.validate] Validate function
|
|
334
|
+
* @param {Stream} [opts.stdin] The Readable stream to listen to
|
|
335
|
+
* @param {Stream} [opts.stdout] The Writable stream to write readline data to
|
|
336
|
+
* @param {String} [opts.error] The invalid error label
|
|
337
|
+
*/
|
|
338
|
+
var p=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(`
|
|
339
|
+
`),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(`
|
|
340
|
+
`),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(`
|
|
341
|
+
`).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))}};t.exports=p}),ct=o((exports,t)=>{let n=V(),{cursor:r}=U(),i=Z(),{clear:a,figures:o,style:s,wrap:c,entriesToDisplay:l}=X();
|
|
342
|
+
/**
|
|
343
|
+
* MultiselectPrompt Base Element
|
|
344
|
+
* @param {Object} opts Options
|
|
345
|
+
* @param {String} opts.message Message
|
|
346
|
+
* @param {Array} opts.choices Array of choice objects
|
|
347
|
+
* @param {String} [opts.hint] Hint to display
|
|
348
|
+
* @param {String} [opts.warn] Hint shown for disabled choices
|
|
349
|
+
* @param {Number} [opts.max] Max choices
|
|
350
|
+
* @param {Number} [opts.cursor=0] Cursor start position
|
|
351
|
+
* @param {Number} [opts.optionsPerPage=10] Max options to display at once
|
|
352
|
+
* @param {Stream} [opts.stdin] The Readable stream to listen to
|
|
353
|
+
* @param {Stream} [opts.stdout] The Writable stream to write readline data to
|
|
354
|
+
*/
|
|
355
|
+
var u=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(`
|
|
356
|
+
`),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(`
|
|
357
|
+
`),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:`
|
|
74
358
|
Instructions:
|
|
75
|
-
${
|
|
76
|
-
${
|
|
77
|
-
`+(this.
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
359
|
+
${o.arrowUp}/${o.arrowDown}: Highlight option\n ${o.arrowLeft}/${o.arrowRight}/[space]: Toggle selection\n`+(this.maxChoices===void 0?` a: Toggle all
|
|
360
|
+
`:``)+` 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=`
|
|
361
|
+
`+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`
|
|
362
|
+
`+a.join(`
|
|
363
|
+
`)}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.`),this.showMinError=!1),e+=this.renderOptions(this.value),this.out.write(this.clear+e),this.clear=a(e,this.out.columns)}};t.exports=u}),lt=o((exports,t)=>{let n=V(),r=Z(),{erase:i,cursor:a}=U(),{style:o,clear:s,figures:c,wrap:l,entriesToDisplay:u}=X(),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};
|
|
364
|
+
/**
|
|
365
|
+
* TextPrompt Base Element
|
|
366
|
+
* @param {Object} opts Options
|
|
367
|
+
* @param {String} opts.message Message
|
|
368
|
+
* @param {Array} opts.choices Array of auto-complete choices objects
|
|
369
|
+
* @param {Function} [opts.suggest] Filter function. Defaults to sort by title
|
|
370
|
+
* @param {Number} [opts.limit=10] Max number of results to show
|
|
371
|
+
* @param {Number} [opts.cursor=0] Cursor start position
|
|
372
|
+
* @param {String} [opts.style='default'] Render style
|
|
373
|
+
* @param {String} [opts.fallback] Fallback message - initial to default value
|
|
374
|
+
* @param {String} [opts.initial] Index of the default value
|
|
375
|
+
* @param {Boolean} [opts.clearFirst] The first ESCAPE keypress will clear the input
|
|
376
|
+
* @param {Stream} [opts.stdin] The Readable stream to listen to
|
|
377
|
+
* @param {Stream} [opts.stdout] The Writable stream to write readline data to
|
|
378
|
+
* @param {String} [opts.noMatches] The no matches found label
|
|
379
|
+
*/
|
|
380
|
+
var m=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(`
|
|
82
381
|
`),this.close())}abort(){this.done=this.aborted=!0,this.exited=!1,this.fire(),this.render(),this.out.write(`
|
|
83
382
|
`),this.close()}submit(){this.done=!0,this.aborted=this.exited=!1,this.fire(),this.render(),this.out.write(`
|
|
84
|
-
`),this.close()}_(e,t){let
|
|
85
|
-
`+
|
|
383
|
+
`),this.close()}_(e,t){let n=this.input.slice(0,this.cursor),r=this.input.slice(this.cursor);this.input=`${n}${e}${r}`,this.cursor=n.length+1,this.complete(this.render),this.render()}delete(){if(this.cursor===0)return this.bell();let e=this.input.slice(0,this.cursor-1),t=this.input.slice(this.cursor);this.input=`${e}${t}`,this.complete(this.render),--this.cursor,this.render()}deleteForward(){if(this.cursor*this.scale>=this.rendered.length)return this.bell();let e=this.input.slice(0,this.cursor),t=this.input.slice(this.cursor+1);this.input=`${e}${t}`,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=`
|
|
384
|
+
`+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(`
|
|
86
385
|
`);this.outputText+=`
|
|
87
|
-
`+(
|
|
386
|
+
`+(r||n.gray(this.fallback.title))}this.out.write(i.line+a.to(0)+this.outputText)}};t.exports=m}),ut=o((exports,t)=>{let n=V(),{cursor:r}=U(),i=ct(),{clear:a,style:o,figures:s}=X();
|
|
387
|
+
/**
|
|
388
|
+
* MultiselectPrompt Base Element
|
|
389
|
+
* @param {Object} opts Options
|
|
390
|
+
* @param {String} opts.message Message
|
|
391
|
+
* @param {Array} opts.choices Array of choice objects
|
|
392
|
+
* @param {String} [opts.hint] Hint to display
|
|
393
|
+
* @param {String} [opts.warn] Hint shown for disabled choices
|
|
394
|
+
* @param {Number} [opts.max] Max choices
|
|
395
|
+
* @param {Number} [opts.cursor=0] Cursor start position
|
|
396
|
+
* @param {Stream} [opts.stdin] The Readable stream to listen to
|
|
397
|
+
* @param {Stream} [opts.stdout] The Writable stream to write readline data to
|
|
398
|
+
*/
|
|
399
|
+
var c=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:`
|
|
88
400
|
Instructions:
|
|
89
|
-
${
|
|
90
|
-
${
|
|
401
|
+
${s.arrowUp}/${s.arrowDown}: Highlight option
|
|
402
|
+
${s.arrowLeft}/${s.arrowRight}/[space]: Toggle selection
|
|
91
403
|
[a,b,c]/delete: Filter choices
|
|
92
404
|
enter/return: Complete answer
|
|
93
|
-
|
|
94
|
-
Filtered results for: ${this.inputValue?this.inputValue:
|
|
95
|
-
|
|
405
|
+
`:``}renderCurrentInput(){return`
|
|
406
|
+
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.`),this.showMinError=!1),e+=this.renderOptions(this.filteredOptions),this.out.write(this.clear+e),this.clear=a(e,this.out.columns)}};t.exports=c}),dt=o((exports,t)=>{let n=V(),r=Z(),{style:i,clear:a}=X(),{erase:o,cursor:s}=U();
|
|
407
|
+
/**
|
|
408
|
+
* ConfirmPrompt Base Element
|
|
409
|
+
* @param {Object} opts Options
|
|
410
|
+
* @param {String} opts.message Message
|
|
411
|
+
* @param {Boolean} [opts.initial] Default value (true/false)
|
|
412
|
+
* @param {Stream} [opts.stdin] The Readable stream to listen to
|
|
413
|
+
* @param {Stream} [opts.stdout] The Writable stream to write readline data to
|
|
414
|
+
* @param {String} [opts.yes] The "Yes" label
|
|
415
|
+
* @param {String} [opts.yesOption] The "Yes" option when choosing between yes/no
|
|
416
|
+
* @param {String} [opts.no] The "No" label
|
|
417
|
+
* @param {String} [opts.noOption] The "No" option when choosing between yes/no
|
|
418
|
+
*/
|
|
419
|
+
var c=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(`
|
|
96
420
|
`),this.close()}submit(){this.value=this.value||!1,this.done=!0,this.aborted=!1,this.fire(),this.render(),this.out.write(`
|
|
97
|
-
`),this.close()}_(e,t){return e.toLowerCase()
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
421
|
+
`),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))}};t.exports=c}),ft=o((exports,t)=>{t.exports={TextPrompt:Je(),SelectPrompt:Ye(),TogglePrompt:Xe(),DatePrompt:ot(),NumberPrompt:st(),MultiselectPrompt:ct(),AutocompletePrompt:lt(),AutocompleteMultiselectPrompt:ut(),ConfirmPrompt:dt()}}),pt=o(exports=>{let t=exports,n=ft(),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()));
|
|
422
|
+
/**
|
|
423
|
+
* Interactive auto-complete prompt
|
|
424
|
+
* @param {string} args.message Prompt message to display
|
|
425
|
+
* @param {Array} args.choices Array of auto-complete choices objects `[{ title, value }, ...]`
|
|
426
|
+
* @param {Function} [args.suggest] Function to filter results based on user input. Defaults to sort by `title`
|
|
427
|
+
* @param {number} [args.limit=10] Max number of results to show
|
|
428
|
+
* @param {string} [args.style="default"] Render style ('default', 'password', 'invisible')
|
|
429
|
+
* @param {String} [args.initial] Index of the default value
|
|
430
|
+
* @param {boolean} [opts.clearFirst] The first ESCAPE keypress will clear the input
|
|
431
|
+
* @param {String} [args.fallback] Fallback message - defaults to initial value
|
|
432
|
+
* @param {function} [args.onState] On state change callback
|
|
433
|
+
* @param {Stream} [args.stdin] The Readable stream to listen to
|
|
434
|
+
* @param {Stream} [args.stdout] The Writable stream to write readline data to
|
|
435
|
+
* @returns {Promise} Promise with user input
|
|
436
|
+
*/
|
|
437
|
+
t.autocomplete=e=>(e.suggest=e.suggest||a,e.choices=[].concat(e.choices||[]),i(`AutocompletePrompt`,e))}),mt=o((exports,t)=>{let n=pt(),r=[`suggest`,`format`,`onState`,`validate`,`onRender`,`type`],i=()=>{};
|
|
438
|
+
/**
|
|
439
|
+
* Prompt for a series of questions
|
|
440
|
+
* @param {Array|Object} questions Single question object or Array of question objects
|
|
441
|
+
* @param {Function} [onSubmit] Callback function called on prompt submit
|
|
442
|
+
* @param {Function} [onCancel] Callback function called on cancel/abort
|
|
443
|
+
* @returns {Object} Object with values from user input
|
|
444
|
+
*/
|
|
445
|
+
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)continue;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})}),ht=o((exports,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`)?Be():mt()}),gt=`reactive-vscode`,_t=`module`,vt=`0.2.18`,yt=`Develop VSCode extension with Vue Reactivity API`,bt=`_Kerman <kermanx@qq.com>`,xt=`MIT`,St=`https://github.com/kermanx/reactive-vscode#readme`,Ct={type:`git`,url:`git+https://github.com/kermanx/reactive-vscode.git`},wt=`https://github.com/kermanx/reactive-vscode/issues`,Tt=[`vscode`,`extension`,`extension-development`,`vue`,`composition-api`,`reactive`,`reactivity`],Et=!1,Dt={".":{types:`./src/index.ts`,import:`./src/index.ts`}},Ot=`./src/index.ts`,kt=`./src/index.ts`,At=[`README.md`,`dist`],jt={typecheck:`tsc --noEmit`,build:`vite build`,prepublishOnly:`pnpm typecheck && pnpm build`},Mt={"@types/vscode":`^1.89.0`},Nt={"@reactive-vscode/reactivity":`workspace:*`},Pt={"@types/node":`^20.17.45`,"@types/vscode":`^1.99.1`,typescript:`^5.8.3`,vite:`^5.4.19`,"vite-plugin-dts":`^4.5.3`},Ft={exports:{".":{types:`./dist/index.d.ts`,import:`./dist/index.js`,require:`./dist/index.cjs`}},main:`./dist/index.cjs`,types:`./dist/index.d.ts`},It={name:gt,type:_t,version:vt,description:yt,author:bt,license:xt,homepage:St,repository:Ct,bugs:wt,keywords:Tt,sideEffects:Et,exports:Dt,main:Ot,types:kt,files:At,scripts:jt,peerDependencies:Mt,dependencies:Nt,devDependencies:Pt,publishConfig:Ft},Lt=`dist
|
|
102
446
|
node_modules
|
|
103
|
-
|
|
447
|
+
`,Rt=`{
|
|
104
448
|
"version": "0.2.0",
|
|
105
449
|
"configurations": [
|
|
106
450
|
{
|
|
@@ -116,10 +460,10 @@ node_modules
|
|
|
116
460
|
}
|
|
117
461
|
]
|
|
118
462
|
}
|
|
119
|
-
|
|
120
|
-
"publisher": "${
|
|
121
|
-
"name": "${
|
|
122
|
-
"displayName": "${
|
|
463
|
+
`,zt=(e,t,n,r)=>`{
|
|
464
|
+
"publisher": "${e}",
|
|
465
|
+
"name": "${t}",
|
|
466
|
+
"displayName": "${n}",
|
|
123
467
|
"type": "module",
|
|
124
468
|
"version": "0.0.1",
|
|
125
469
|
"private": true,
|
|
@@ -136,14 +480,14 @@ node_modules
|
|
|
136
480
|
"contributes": {
|
|
137
481
|
"commands": [
|
|
138
482
|
{
|
|
139
|
-
"command": "${
|
|
483
|
+
"command": "${t}.helloWorld",
|
|
140
484
|
"title": "Hello World"
|
|
141
485
|
}
|
|
142
486
|
],
|
|
143
487
|
"configuration": {
|
|
144
|
-
"title": "${
|
|
488
|
+
"title": "${n}",
|
|
145
489
|
"properties": {
|
|
146
|
-
"${
|
|
490
|
+
"${t}.message": {
|
|
147
491
|
"type": "string",
|
|
148
492
|
"default": "Hello World",
|
|
149
493
|
"description": "The message to show in the notification"
|
|
@@ -152,22 +496,22 @@ node_modules
|
|
|
152
496
|
}
|
|
153
497
|
},
|
|
154
498
|
"scripts": {
|
|
155
|
-
"build": "
|
|
156
|
-
"dev": "
|
|
499
|
+
"build": "tsdown --env.NODE_ENV production",
|
|
500
|
+
"dev": "tsdown --watch ./src --env.NODE_ENV development",
|
|
157
501
|
"typecheck": "tsc --noEmit",
|
|
158
502
|
"vscode:prepublish": "pnpm run build"
|
|
159
503
|
},
|
|
160
504
|
"devDependencies": {
|
|
161
505
|
"@types/node": "18.x",
|
|
162
506
|
"@types/vscode": "^1.89.0",
|
|
163
|
-
"reactive-vscode": "${
|
|
164
|
-
"
|
|
507
|
+
"reactive-vscode": "${r}",
|
|
508
|
+
"tsdown": "^0.11.5",
|
|
165
509
|
"typescript": "^5.4.5"
|
|
166
510
|
}
|
|
167
511
|
}
|
|
168
|
-
|
|
512
|
+
`,Bt=(e,t,n)=>`# ${n}
|
|
169
513
|
|
|
170
|
-
[](https://marketplace.visualstudio.com/items?itemName=${e}.${t}) [](https://marketplace.visualstudio.com/items?itemName=${e}.${t}) [](https://kermanx.github.io/reactive-vscode/)
|
|
171
515
|
|
|
172
516
|
A VS Code extension created with [Reactive VS Code](https://kermanx.github.io/reactive-vscode/).
|
|
173
517
|
|
|
@@ -196,7 +540,7 @@ A VS Code extension created with [Reactive VS Code](https://kermanx.github.io/re
|
|
|
196
540
|
* [Follow UX guidelines](https://code.visualstudio.com/api/ux-guidelines/overview) to create extensions that seamlessly integrate with VS Code's native interface and patterns.
|
|
197
541
|
* [Publish your extension](https://code.visualstudio.com/api/working-with-extensions/publishing-extension) on the VS Code extension marketplace.
|
|
198
542
|
* Automate builds by setting up [Continuous Integration](https://code.visualstudio.com/api/working-with-extensions/continuous-integration).
|
|
199
|
-
|
|
543
|
+
`,Vt=(e,t)=>({extension:`import { defineExtension, useCommand, useIsDarkTheme, watchEffect } from 'reactive-vscode'
|
|
200
544
|
import { window } from 'vscode'
|
|
201
545
|
import { message } from './configs'
|
|
202
546
|
import { logger } from './utils'
|
|
@@ -204,7 +548,7 @@ import { logger } from './utils'
|
|
|
204
548
|
export = defineExtension(() => {
|
|
205
549
|
logger.info('Extension Activated')
|
|
206
550
|
|
|
207
|
-
useCommand('${
|
|
551
|
+
useCommand('${e}.helloWorld', () => {
|
|
208
552
|
window.showInformationMessage(message.value)
|
|
209
553
|
})
|
|
210
554
|
|
|
@@ -215,13 +559,13 @@ export = defineExtension(() => {
|
|
|
215
559
|
})
|
|
216
560
|
`,configs:`import { defineConfigs } from 'reactive-vscode'
|
|
217
561
|
|
|
218
|
-
export const { message } = defineConfigs('${
|
|
562
|
+
export const { message } = defineConfigs('${e}', {
|
|
219
563
|
message: 'string',
|
|
220
564
|
})
|
|
221
565
|
`,utils:`import { defineLogger } from 'reactive-vscode'
|
|
222
566
|
|
|
223
|
-
export const logger = defineLogger('${
|
|
224
|
-
`})
|
|
567
|
+
export const logger = defineLogger('${t}')
|
|
568
|
+
`}),Ht=`{
|
|
225
569
|
"compilerOptions": {
|
|
226
570
|
"target": "ES2022",
|
|
227
571
|
"lib": ["ES2022"],
|
|
@@ -233,19 +577,18 @@ export const logger = defineLogger('${e}')
|
|
|
233
577
|
"esModuleInterop": true
|
|
234
578
|
}
|
|
235
579
|
}
|
|
236
|
-
|
|
580
|
+
`,Ut=`import { defineConfig } from 'tsdown'
|
|
237
581
|
|
|
238
582
|
export default defineConfig({
|
|
239
583
|
entry: ['src/extension.ts'],
|
|
240
584
|
format: ['cjs'],
|
|
241
585
|
target: 'node18',
|
|
242
|
-
clean: true,
|
|
243
586
|
minify: true,
|
|
244
587
|
external: [
|
|
245
588
|
'vscode',
|
|
246
589
|
],
|
|
247
590
|
})
|
|
248
|
-
|
|
591
|
+
`,Wt=`.vscode/**
|
|
249
592
|
.vscode-test/**
|
|
250
593
|
src/**
|
|
251
594
|
.gitignore
|
|
@@ -255,4 +598,4 @@ src/**
|
|
|
255
598
|
**/*.map
|
|
256
599
|
**/*.ts
|
|
257
600
|
**/.vscode-test.*
|
|
258
|
-
`;function
|
|
601
|
+
`;function Gt(e,t,n){function r(r){let i=r/e.length,a=t.map((e,t)=>{let r=n[t],a=Math.round(e+(r-e)*i);return a});return a}return e.split(``).map((e,t)=>{let n=r(t);return B.rgb(...n)(e)}).join(``)}const Kt=[34,152,99],qt=[31,156,240],Jt=[Gt(`Reactive VSCode`,Kt,qt),B.gray(`-`),Gt(`Develop VSCode Extension with Vue Composition API`,qt,Kt)].join(` `),Yt=d.default.env.npm_config_user_agent??``,$=/pnpm/.test(Yt)?`pnpm`:/yarn/.test(Yt)?`yarn`:`npm`,Xt=$===`npm`?`npm run`:$;function Zt(e){return/^(?:@[a-z0-9-*~][a-z0-9-*._~]*\/)?[a-z0-9-~][a-z0-9-._~]*$/.test(e)}function Qt(e){return e.trim().toLowerCase().replace(/\s+/g,`-`).replace(/^[._]/,``).replace(/[^a-z0-9-~]+/g,`-`)}var $t=c(ht(),1);async function en(){console.log(),console.log(Jt),console.log();let e=d.default.cwd(),t=d.default.argv.slice(2).filter(e=>/^[\w\- ]+$/.test(e)).map(e=>e.trim()).join(` `)||`Your Extension`,n=``,r=``,i=``;await(0,$t.default)([{name:`displayName`,type:`text`,message:`What's the display name of your extension?`,initial:t,onState:e=>t=e.value||t},{name:`identifier`,type:`text`,message:`What's the package name of your extension?`,initial:()=>r=Qt(t),validate:e=>Zt(e)||`Invalid package.json name`,onState:e=>r=e.value||r},{name:`publisher`,type:`text`,message:`What's your publisher name?`,initial:n,validate:e=>Zt(e)||`Invalid publisher name`,onState:e=>n=e.value||n},{name:`targetDir`,type:`text`,message:`Which directory do you want to scaffold the project in?`,initial:()=>i=r,validate:t=>!l.default.existsSync(u.default.resolve(e,t))||`Target directory already exists, please choose another name`,onState:e=>i=e.value||i}],{onCancel:()=>{console.log(),console.log(`${B.red(`×`)} Aborted.`),console.log(),d.default.exit(1)}});let a=u.default.resolve(e,i);console.log(),console.log(`Scaffolding project in ${a}...`),l.default.mkdirSync(a,{recursive:!0}),d.default.chdir(a),l.default.writeFileSync(`package.json`,zt(n,r,t,`^${It.version}`)),l.default.writeFileSync(`tsconfig.json`,Ht),l.default.writeFileSync(`.gitignore`,Lt),l.default.writeFileSync(`.vscodeignore`,Wt),l.default.writeFileSync(`tsdown.config.ts`,Ut),l.default.writeFileSync(`README.md`,Bt(n,r,t)),l.default.mkdirSync(`src`);let o=Vt(r,t);for(let[e,t]of Object.entries(o))l.default.writeFileSync(`src/${e}.ts`,t);l.default.mkdirSync(`.vscode`),l.default.writeFileSync(`.vscode/launch.json`,Rt),console.log(),console.log(`Done. Now run:`),console.log(),console.log(B.bold.green(` cd ${i}`)),console.log(B.bold.green(` ${$} install`)),console.log(B.bold.green(` code .`)),console.log(B.bold.green(` ${Xt} dev`)),console.log()}en();
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "create-reactive-vscode",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.2.
|
|
4
|
+
"version": "0.2.18",
|
|
5
5
|
"description": "Reactive-vscode project creator",
|
|
6
6
|
"author": "_Kerman <kermanx@qq.com>",
|
|
7
7
|
"license": "MIT",
|
|
@@ -28,12 +28,12 @@
|
|
|
28
28
|
"@types/prompts": "^2.4.9",
|
|
29
29
|
"chalk": "^5.4.1",
|
|
30
30
|
"prompts": "^2.4.2",
|
|
31
|
-
"
|
|
31
|
+
"tsdown": "^0.11.5",
|
|
32
32
|
"typescript": "^5.8.3"
|
|
33
33
|
},
|
|
34
34
|
"scripts": {
|
|
35
|
-
"dev": "
|
|
36
|
-
"build": "
|
|
35
|
+
"dev": "tsdown --watch",
|
|
36
|
+
"build": "tsdown",
|
|
37
37
|
"check": "tsc --noEmit"
|
|
38
38
|
}
|
|
39
39
|
}
|