create-spectrum-project 0.1.1 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +6 -3
- package/dist/bin.js +60 -60
- package/dist/scaffold.js +22 -18
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -20,7 +20,7 @@ You'll be asked for:
|
|
|
20
20
|
- Your package manager (auto-detected)
|
|
21
21
|
- Whether to install dependencies and initialize git
|
|
22
22
|
|
|
23
|
-
The generated project includes `src/index.ts` with the selected providers wired in, a `package.json` pinned to the current `spectrum-ts` release,
|
|
23
|
+
The generated project includes `src/index.ts` with the selected providers wired in, a `package.json` pinned to the current `spectrum-ts` release, a ready-to-fill `.env` (plus a tracked `.env.example`) for any required credentials, and an echo loop that runs on `bun start`.
|
|
24
24
|
|
|
25
25
|
## Non-interactive
|
|
26
26
|
|
|
@@ -43,7 +43,7 @@ Options:
|
|
|
43
43
|
Defaults (applied by `-y` and as fallbacks for any flag you don't set):
|
|
44
44
|
|
|
45
45
|
- Directory: `my-spectrum-app`
|
|
46
|
-
- Providers: `
|
|
46
|
+
- Providers: `imessage` (first platform in the manifest)
|
|
47
47
|
- Package manager: detected from your shell, otherwise `bun`
|
|
48
48
|
- Install dependencies: yes
|
|
49
49
|
- Initialize git: yes
|
|
@@ -51,9 +51,12 @@ Defaults (applied by `-y` and as fallbacks for any flag you don't set):
|
|
|
51
51
|
Examples:
|
|
52
52
|
|
|
53
53
|
```sh
|
|
54
|
-
#
|
|
54
|
+
# iMessage, no prompts, all defaults
|
|
55
55
|
bunx create-spectrum-project -y
|
|
56
56
|
|
|
57
|
+
# Terminal sandbox (dev TUI, no credentials)
|
|
58
|
+
bunx create-spectrum-project my-app --providers terminal
|
|
59
|
+
|
|
57
60
|
# iMessage + WhatsApp on pnpm, skip git
|
|
58
61
|
bunx create-spectrum-project my-app --providers imessage,whatsapp-business --pm pnpm --no-git
|
|
59
62
|
```
|
package/dist/bin.js
CHANGED
|
@@ -1,136 +1,136 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import{createRequire as H7}from"node:module";var t$=Object.create;var{getPrototypeOf:s$,defineProperty:V0,getOwnPropertyNames:o$}=Object;var r$=Object.prototype.hasOwnProperty;function e$($){return this[$]}var $7,Z7,y1=($,Z,H)=>{var z=$!=null&&typeof $==="object";if(z){var B=Z?$7??=new WeakMap:Z7??=new WeakMap,J=B.get($);if(J)return J}H=$!=null?t$(s$($)):{};let X=Z||!$||!$.__esModule?V0(H,"default",{value:$,enumerable:!0}):H;for(let C of o$($))if(!r$.call(X,C))V0(X,C,{get:e$.bind($,C),enumerable:!0});if(z)B.set($,X);return X};var Y=($,Z)=>()=>(Z||$((Z={exports:{}}).exports,Z),Z.exports);var K1=H7(import.meta.url);var u1=Y((e6,v1)=>{var G1=process||{},A0=G1.argv||[],D1=G1.env||{},z7=!(!!D1.NO_COLOR||A0.includes("--no-color"))&&(!!D1.FORCE_COLOR||A0.includes("--color")||G1.platform==="win32"||(G1.stdout||{}).isTTY&&D1.TERM!=="dumb"||!!D1.CI),B7=($,Z,H=$)=>(z)=>{let B=""+z,J=B.indexOf(Z,$.length);return~J?$+J7(B,Z,H,J)+Z:$+B+Z},J7=($,Z,H,z)=>{let B="",J=0;do B+=$.substring(J,z)+H,J=z+Z.length,z=$.indexOf(Z,J);while(~z);return B+$.substring(J)},I0=($=z7)=>{let Z=$?B7:()=>String;return{isColorSupported:$,reset:Z("\x1B[0m","\x1B[0m"),bold:Z("\x1B[1m","\x1B[22m","\x1B[22m\x1B[1m"),dim:Z("\x1B[2m","\x1B[22m","\x1B[22m\x1B[2m"),italic:Z("\x1B[3m","\x1B[23m"),underline:Z("\x1B[4m","\x1B[24m"),inverse:Z("\x1B[7m","\x1B[27m"),hidden:Z("\x1B[8m","\x1B[28m"),strikethrough:Z("\x1B[9m","\x1B[29m"),black:Z("\x1B[30m","\x1B[39m"),red:Z("\x1B[31m","\x1B[39m"),green:Z("\x1B[32m","\x1B[39m"),yellow:Z("\x1B[33m","\x1B[39m"),blue:Z("\x1B[34m","\x1B[39m"),magenta:Z("\x1B[35m","\x1B[39m"),cyan:Z("\x1B[36m","\x1B[39m"),white:Z("\x1B[37m","\x1B[39m"),gray:Z("\x1B[90m","\x1B[39m"),bgBlack:Z("\x1B[40m","\x1B[49m"),bgRed:Z("\x1B[41m","\x1B[49m"),bgGreen:Z("\x1B[42m","\x1B[49m"),bgYellow:Z("\x1B[43m","\x1B[49m"),bgBlue:Z("\x1B[44m","\x1B[49m"),bgMagenta:Z("\x1B[45m","\x1B[49m"),bgCyan:Z("\x1B[46m","\x1B[49m"),bgWhite:Z("\x1B[47m","\x1B[49m"),blackBright:Z("\x1B[90m","\x1B[39m"),redBright:Z("\x1B[91m","\x1B[39m"),greenBright:Z("\x1B[92m","\x1B[39m"),yellowBright:Z("\x1B[93m","\x1B[39m"),blueBright:Z("\x1B[94m","\x1B[39m"),magentaBright:Z("\x1B[95m","\x1B[39m"),cyanBright:Z("\x1B[96m","\x1B[39m"),whiteBright:Z("\x1B[97m","\x1B[39m"),bgBlackBright:Z("\x1B[100m","\x1B[49m"),bgRedBright:Z("\x1B[101m","\x1B[49m"),bgGreenBright:Z("\x1B[102m","\x1B[49m"),bgYellowBright:Z("\x1B[103m","\x1B[49m"),bgBlueBright:Z("\x1B[104m","\x1B[49m"),bgMagentaBright:Z("\x1B[105m","\x1B[49m"),bgCyanBright:Z("\x1B[106m","\x1B[49m"),bgWhiteBright:Z("\x1B[107m","\x1B[49m")}};v1.exports=I0();v1.exports.createColors=I0});var G=Y((Z8,
|
|
3
|
-
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}var J=!0,X=!1,C;return{s:function(){H=H.call($)},n:function(){var U=H.next();return J=U.done,U},e:function(U){X=!0,C=U},f:function(){try{if(!J&&H.return!=null)H.return()}finally{if(X)throw C}}}}function D7($,Z){if(!$)return;if(typeof $==="string")return T0($,Z);var H=Object.prototype.toString.call($).slice(8,-1);if(H==="Object"&&$.constructor)H=$.constructor.name;if(H==="Map"||H==="Set")return Array.from($);if(H==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(H))return T0($,Z)}function T0($,Z){if(Z==null||Z>$.length)Z=$.length;for(var H=0,z=Array(Z);H<Z;H++)z[H]=$[H];return z}var G7=R1(),w0=M(),x0=w0.erase,M7=w0.cursor,R7=($)=>[...G7($)].length;h0.exports=function($,Z){if(!Z)return x0.line+M7.to(0);let H=0,z=$.split(/\r?\n/);var B=K7(z),J;try{for(B.s();!(J=B.n()).done;){let X=J.value;H+=1+Math.floor(Math.max(R7(X)-1,0)/Z)}}catch(X){B.e(X)}finally{B.f()}return x0.lines(H)}});var l1=Y((X8,_0)=>{var r={arrowUp:"↑",arrowDown:"↓",arrowLeft:"←",arrowRight:"→",radioOn:"◉",radioOff:"◯",tick:"✔",cross:"✖",ellipsis:"…",pointerSmall:"›",line:"─",pointer:"❯"},F7={arrowUp:r.arrowUp,arrowDown:r.arrowDown,arrowLeft:r.arrowLeft,arrowRight:r.arrowRight,radioOn:"(*)",radioOff:"( )",tick:"√",cross:"×",ellipsis:"...",pointerSmall:"»",line:"─",pointer:">"},O7=process.platform==="win32"?F7:r;_0.exports=O7});var g0=Y((C8,f0)=>{var a=G(),
|
|
2
|
+
import{createRequire as H7}from"node:module";var t$=Object.create;var{getPrototypeOf:s$,defineProperty:V0,getOwnPropertyNames:o$}=Object;var r$=Object.prototype.hasOwnProperty;function e$($){return this[$]}var $7,Z7,y1=($,Z,H)=>{var z=$!=null&&typeof $==="object";if(z){var B=Z?$7??=new WeakMap:Z7??=new WeakMap,J=B.get($);if(J)return J}H=$!=null?t$(s$($)):{};let X=Z||!$||!$.__esModule?V0(H,"default",{value:$,enumerable:!0}):H;for(let C of o$($))if(!r$.call(X,C))V0(X,C,{get:e$.bind($,C),enumerable:!0});if(z)B.set($,X);return X};var Y=($,Z)=>()=>(Z||$((Z={exports:{}}).exports,Z),Z.exports);var K1=H7(import.meta.url);var u1=Y((e6,v1)=>{var G1=process||{},A0=G1.argv||[],D1=G1.env||{},z7=!(!!D1.NO_COLOR||A0.includes("--no-color"))&&(!!D1.FORCE_COLOR||A0.includes("--color")||G1.platform==="win32"||(G1.stdout||{}).isTTY&&D1.TERM!=="dumb"||!!D1.CI),B7=($,Z,H=$)=>(z)=>{let B=""+z,J=B.indexOf(Z,$.length);return~J?$+J7(B,Z,H,J)+Z:$+B+Z},J7=($,Z,H,z)=>{let B="",J=0;do B+=$.substring(J,z)+H,J=z+Z.length,z=$.indexOf(Z,J);while(~z);return B+$.substring(J)},I0=($=z7)=>{let Z=$?B7:()=>String;return{isColorSupported:$,reset:Z("\x1B[0m","\x1B[0m"),bold:Z("\x1B[1m","\x1B[22m","\x1B[22m\x1B[1m"),dim:Z("\x1B[2m","\x1B[22m","\x1B[22m\x1B[2m"),italic:Z("\x1B[3m","\x1B[23m"),underline:Z("\x1B[4m","\x1B[24m"),inverse:Z("\x1B[7m","\x1B[27m"),hidden:Z("\x1B[8m","\x1B[28m"),strikethrough:Z("\x1B[9m","\x1B[29m"),black:Z("\x1B[30m","\x1B[39m"),red:Z("\x1B[31m","\x1B[39m"),green:Z("\x1B[32m","\x1B[39m"),yellow:Z("\x1B[33m","\x1B[39m"),blue:Z("\x1B[34m","\x1B[39m"),magenta:Z("\x1B[35m","\x1B[39m"),cyan:Z("\x1B[36m","\x1B[39m"),white:Z("\x1B[37m","\x1B[39m"),gray:Z("\x1B[90m","\x1B[39m"),bgBlack:Z("\x1B[40m","\x1B[49m"),bgRed:Z("\x1B[41m","\x1B[49m"),bgGreen:Z("\x1B[42m","\x1B[49m"),bgYellow:Z("\x1B[43m","\x1B[49m"),bgBlue:Z("\x1B[44m","\x1B[49m"),bgMagenta:Z("\x1B[45m","\x1B[49m"),bgCyan:Z("\x1B[46m","\x1B[49m"),bgWhite:Z("\x1B[47m","\x1B[49m"),blackBright:Z("\x1B[90m","\x1B[39m"),redBright:Z("\x1B[91m","\x1B[39m"),greenBright:Z("\x1B[92m","\x1B[39m"),yellowBright:Z("\x1B[93m","\x1B[39m"),blueBright:Z("\x1B[94m","\x1B[39m"),magentaBright:Z("\x1B[95m","\x1B[39m"),cyanBright:Z("\x1B[96m","\x1B[39m"),whiteBright:Z("\x1B[97m","\x1B[39m"),bgBlackBright:Z("\x1B[100m","\x1B[49m"),bgRedBright:Z("\x1B[101m","\x1B[49m"),bgGreenBright:Z("\x1B[102m","\x1B[49m"),bgYellowBright:Z("\x1B[103m","\x1B[49m"),bgBlueBright:Z("\x1B[104m","\x1B[49m"),bgMagentaBright:Z("\x1B[105m","\x1B[49m"),bgCyanBright:Z("\x1B[106m","\x1B[49m"),bgWhiteBright:Z("\x1B[107m","\x1B[49m")}};v1.exports=I0();v1.exports.createColors=I0});var G=Y((Z8,L0)=>{var{FORCE_COLOR:X7,NODE_DISABLE_COLORS:C7,TERM:Q7}=process.env,K={enabled:!C7&&Q7!=="dumb"&&X7!=="0",reset:D(0,0),bold:D(1,22),dim:D(2,22),italic:D(3,23),underline:D(4,24),inverse:D(7,27),hidden:D(8,28),strikethrough:D(9,29),black:D(30,39),red:D(31,39),green:D(32,39),yellow:D(33,39),blue:D(34,39),magenta:D(35,39),cyan:D(36,39),white:D(37,39),gray:D(90,39),grey:D(90,39),bgBlack:D(40,49),bgRed:D(41,49),bgGreen:D(42,49),bgYellow:D(43,49),bgBlue:D(44,49),bgMagenta:D(45,49),bgCyan:D(46,49),bgWhite:D(47,49)};function q0($,Z){let H=0,z,B="",J="";for(;H<$.length;H++)if(z=$[H],B+=z.open,J+=z.close,Z.includes(z.close))Z=Z.replace(z.rgx,z.close+z.open);return B+Z+J}function U7($,Z){let H={has:$,keys:Z};return H.reset=K.reset.bind(H),H.bold=K.bold.bind(H),H.dim=K.dim.bind(H),H.italic=K.italic.bind(H),H.underline=K.underline.bind(H),H.inverse=K.inverse.bind(H),H.hidden=K.hidden.bind(H),H.strikethrough=K.strikethrough.bind(H),H.black=K.black.bind(H),H.red=K.red.bind(H),H.green=K.green.bind(H),H.yellow=K.yellow.bind(H),H.blue=K.blue.bind(H),H.magenta=K.magenta.bind(H),H.cyan=K.cyan.bind(H),H.white=K.white.bind(H),H.gray=K.gray.bind(H),H.grey=K.grey.bind(H),H.bgBlack=K.bgBlack.bind(H),H.bgRed=K.bgRed.bind(H),H.bgGreen=K.bgGreen.bind(H),H.bgYellow=K.bgYellow.bind(H),H.bgBlue=K.bgBlue.bind(H),H.bgMagenta=K.bgMagenta.bind(H),H.bgCyan=K.bgCyan.bind(H),H.bgWhite=K.bgWhite.bind(H),H}function D($,Z){let H={open:`\x1B[${$}m`,close:`\x1B[${Z}m`,rgx:new RegExp(`\\x1b\\[${Z}m`,"g")};return function(z){if(this!==void 0&&this.has!==void 0)return this.has.includes($)||(this.has.push($),this.keys.push(H)),z===void 0?this:K.enabled?q0(this.keys,z+""):z+"";return z===void 0?U7([$],[H]):K.enabled?q0([H],z+""):z+""}}L0.exports=K});var j0=Y((H8,E0)=>{E0.exports=($,Z)=>{if($.meta&&$.name!=="escape")return;if($.ctrl){if($.name==="a")return"first";if($.name==="c")return"abort";if($.name==="d")return"abort";if($.name==="e")return"last";if($.name==="g")return"reset"}if(Z){if($.name==="j")return"down";if($.name==="k")return"up"}if($.name==="return")return"submit";if($.name==="enter")return"submit";if($.name==="backspace")return"delete";if($.name==="delete")return"deleteForward";if($.name==="abort")return"abort";if($.name==="escape")return"exit";if($.name==="tab")return"next";if($.name==="pagedown")return"nextPage";if($.name==="pageup")return"prevPage";if($.name==="home")return"home";if($.name==="end")return"end";if($.name==="up")return"up";if($.name==="down")return"down";if($.name==="right")return"right";if($.name==="left")return"left";return!1}});var R1=Y((z8,b0)=>{b0.exports=($)=>{let Z=["[\\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("|"),H=new RegExp(Z,"g");return typeof $==="string"?$.replace(H,""):$}});var M=Y((B8,P0)=>{var n1={to($,Z){if(!Z)return`\x1B[${$+1}G`;return`\x1B[${Z+1};${$+1}H`},move($,Z){let H="";if($<0)H+=`\x1B[${-$}D`;else if($>0)H+=`\x1B[${$}C`;if(Z<0)H+=`\x1B[${-Z}A`;else if(Z>0)H+=`\x1B[${Z}B`;return H},up:($=1)=>`\x1B[${$}A`,down:($=1)=>`\x1B[${$}B`,forward:($=1)=>`\x1B[${$}C`,backward:($=1)=>`\x1B[${$}D`,nextLine:($=1)=>"\x1B[E".repeat($),prevLine:($=1)=>"\x1B[F".repeat($),left:"\x1B[G",hide:"\x1B[?25l",show:"\x1B[?25h",save:"\x1B7",restore:"\x1B8"},Y7={up:($=1)=>"\x1B[S".repeat($),down:($=1)=>"\x1B[T".repeat($)},W7={screen:"\x1B[2J",up:($=1)=>"\x1B[1J".repeat($),down:($=1)=>"\x1B[J".repeat($),line:"\x1B[2K",lineEnd:"\x1B[K",lineStart:"\x1B[1K",lines($){let Z="";for(let H=0;H<$;H++)Z+=this.line+(H<$-1?n1.up():"");if($)Z+=n1.left;return Z}};P0.exports={cursor:n1,scroll:Y7,erase:W7,beep:"\x07"}});var k0=Y((J8,h0)=>{function K7($,Z){var H=typeof Symbol<"u"&&$[Symbol.iterator]||$["@@iterator"];if(!H){if(Array.isArray($)||(H=D7($))||Z&&$&&typeof $.length==="number"){if(H)$=H;var z=0,B=function(){};return{s:B,n:function(){if(z>=$.length)return{done:!0};return{done:!1,value:$[z++]}},e:function(U){throw U},f:B}}throw TypeError(`Invalid attempt to iterate non-iterable instance.
|
|
3
|
+
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}var J=!0,X=!1,C;return{s:function(){H=H.call($)},n:function(){var U=H.next();return J=U.done,U},e:function(U){X=!0,C=U},f:function(){try{if(!J&&H.return!=null)H.return()}finally{if(X)throw C}}}}function D7($,Z){if(!$)return;if(typeof $==="string")return T0($,Z);var H=Object.prototype.toString.call($).slice(8,-1);if(H==="Object"&&$.constructor)H=$.constructor.name;if(H==="Map"||H==="Set")return Array.from($);if(H==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(H))return T0($,Z)}function T0($,Z){if(Z==null||Z>$.length)Z=$.length;for(var H=0,z=Array(Z);H<Z;H++)z[H]=$[H];return z}var G7=R1(),w0=M(),x0=w0.erase,M7=w0.cursor,R7=($)=>[...G7($)].length;h0.exports=function($,Z){if(!Z)return x0.line+M7.to(0);let H=0,z=$.split(/\r?\n/);var B=K7(z),J;try{for(B.s();!(J=B.n()).done;){let X=J.value;H+=1+Math.floor(Math.max(R7(X)-1,0)/Z)}}catch(X){B.e(X)}finally{B.f()}return x0.lines(H)}});var l1=Y((X8,_0)=>{var r={arrowUp:"↑",arrowDown:"↓",arrowLeft:"←",arrowRight:"→",radioOn:"◉",radioOff:"◯",tick:"✔",cross:"✖",ellipsis:"…",pointerSmall:"›",line:"─",pointer:"❯"},F7={arrowUp:r.arrowUp,arrowDown:r.arrowDown,arrowLeft:r.arrowLeft,arrowRight:r.arrowRight,radioOn:"(*)",radioOff:"( )",tick:"√",cross:"×",ellipsis:"...",pointerSmall:"»",line:"─",pointer:">"},O7=process.platform==="win32"?F7:r;_0.exports=O7});var g0=Y((C8,f0)=>{var a=G(),i=l1(),i1=Object.freeze({password:{scale:1,render:($)=>"*".repeat($.length)},emoji:{scale:2,render:($)=>"\uD83D\uDE03".repeat($.length)},invisible:{scale:0,render:($)=>""},default:{scale:1,render:($)=>`${$}`}}),N7=($)=>i1[$]||i1.default,e=Object.freeze({aborted:a.red(i.cross),done:a.green(i.tick),exited:a.yellow(i.cross),default:a.cyan("?")}),V7=($,Z,H)=>Z?e.aborted:H?e.exited:$?e.done:e.default,A7=($)=>a.gray($?i.ellipsis:i.pointerSmall),I7=($,Z)=>a.gray($?Z?i.pointerSmall:"+":i.line);f0.exports={styles:i1,render:N7,symbols:e,symbol:V7,delimiter:A7,item:I7}});var y0=Y((Q8,d0)=>{var S7=R1();d0.exports=function($,Z){let H=String(S7($)||"").split(/\r?\n/);if(!Z)return H.length;return H.map((z)=>Math.ceil(z.length/Z)).reduce((z,B)=>z+B)}});var u0=Y((U8,v0)=>{v0.exports=($,Z={})=>{let H=Number.isSafeInteger(parseInt(Z.margin))?Array(parseInt(Z.margin)).fill(" ").join(""):Z.margin||"",z=Z.width;return($||"").split(/\r?\n/g).map((B)=>B.split(/\s+/g).reduce((J,X)=>{if(X.length+H.length>=z||J[J.length-1].length+X.length+1<z)J[J.length-1]+=` ${X}`;else J.push(`${H}${X}`);return J},[H]).join(`
|
|
4
4
|
`)).join(`
|
|
5
|
-
`)}});var m0=Y((Y8,c0)=>{c0.exports=($,Z,H)=>{H=H||Z;let z=Math.min(Z-H,$-Math.floor(H/2));if(z<0)z=0;let B=Math.min(z+H,Z);return{startIndex:z,endIndex:B}}});var S=Y((W8,n0)=>{n0.exports={action:j0(),clear:k0(),style:g0(),strip:R1(),figures:l1(),lines:y0(),wrap:u0(),entriesToDisplay:m0()}});var
|
|
5
|
+
`)}});var m0=Y((Y8,c0)=>{c0.exports=($,Z,H)=>{H=H||Z;let z=Math.min(Z-H,$-Math.floor(H/2));if(z<0)z=0;let B=Math.min(z+H,Z);return{startIndex:z,endIndex:B}}});var S=Y((W8,n0)=>{n0.exports={action:j0(),clear:k0(),style:g0(),strip:R1(),figures:l1(),lines:y0(),wrap:u0(),entriesToDisplay:m0()}});var h=Y((K8,a0)=>{var l0=K1("readline"),q7=S(),L7=q7.action,E7=K1("events"),i0=M(),j7=i0.beep,b7=i0.cursor,P7=G();class p0 extends E7{constructor($={}){super();this.firstRender=!0,this.in=$.stdin||process.stdin,this.out=$.stdout||process.stdout,this.onRender=($.onRender||(()=>{return})).bind(this);let Z=l0.createInterface({input:this.in,escapeCodeTimeout:50});if(l0.emitKeypressEvents(this.in,Z),this.in.isTTY)this.in.setRawMode(!0);let H=["SelectPrompt","MultiselectPrompt"].indexOf(this.constructor.name)>-1,z=(B,J)=>{let X=L7(J,H);if(X===!1)this._&&this._(B,J);else if(typeof this[X]==="function")this[X](J);else this.bell()};this.close=()=>{if(this.out.write(b7.show),this.in.removeListener("keypress",z),this.in.isTTY)this.in.setRawMode(!1);Z.close(),this.emit(this.aborted?"abort":this.exited?"exit":"submit",this.value),this.closed=!0},this.in.on("keypress",z)}fire(){this.emit("state",{value:this.value,aborted:!!this.aborted,exited:!!this.exited})}bell(){this.out.write(j7)}render(){if(this.onRender(P7),this.firstRender)this.firstRender=!1}}a0.exports=p0});var $9=Y((D8,e0)=>{function t0($,Z,H,z,B,J,X){try{var C=$[J](X),Q=C.value}catch(U){H(U);return}if(C.done)Z(Q);else Promise.resolve(Q).then(z,B)}function s0($){return function(){var Z=this,H=arguments;return new Promise(function(z,B){var J=$.apply(Z,H);function X(Q){t0(J,z,B,X,C,"next",Q)}function C(Q){t0(J,z,B,X,C,"throw",Q)}X(void 0)})}}var F1=G(),T7=h(),o0=M(),x7=o0.erase,$1=o0.cursor,O1=S(),p1=O1.style,a1=O1.clear,w7=O1.lines,h7=O1.figures;class r0 extends T7{constructor($={}){super($);this.transform=p1.render($.style),this.scale=this.transform.scale,this.msg=$.message,this.initial=$.initial||"",this.validator=$.validate||(()=>!0),this.value="",this.errorMsg=$.error||"Please Enter A Valid Value",this.cursor=Number(!!this.initial),this.cursorOffset=0,this.clear=a1("",this.out.columns),this.render()}set value($){if(!$&&this.initial)this.placeholder=!0,this.rendered=F1.gray(this.transform.render(this.initial));else this.placeholder=!1,this.rendered=this.transform.render($);this._value=$,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(`
|
|
6
6
|
`),this.close()}validate(){var $=this;return s0(function*(){let Z=yield $.validator($.value);if(typeof Z==="string")$.errorMsg=Z,Z=!1;$.error=!Z})()}submit(){var $=this;return s0(function*(){if($.value=$.value||$.initial,$.cursorOffset=0,$.cursor=$.rendered.length,yield $.validate(),$.error){$.red=!0,$.fire(),$.render();return}$.done=!0,$.aborted=!1,$.fire(),$.render(),$.out.write(`
|
|
7
7
|
`),$.close()})()}next(){if(!this.placeholder)return this.bell();this.value=this.initial,this.cursor=this.rendered.length,this.fire(),this.render()}moveCursor($){if(this.placeholder)return;this.cursor=this.cursor+$,this.cursorOffset+=$}_($,Z){let H=this.value.slice(0,this.cursor),z=this.value.slice(this.cursor);this.value=`${H}${$}${z}`,this.red=!1,this.cursor=this.placeholder?0:H.length+1,this.render()}delete(){if(this.isCursorAtStart())return this.bell();let $=this.value.slice(0,this.cursor-1),Z=this.value.slice(this.cursor);if(this.value=`${$}${Z}`,this.red=!1,this.isCursorAtStart())this.cursorOffset=0;else this.cursorOffset++,this.moveCursor(-1);this.render()}deleteForward(){if(this.cursor*this.scale>=this.rendered.length||this.placeholder)return this.bell();let $=this.value.slice(0,this.cursor),Z=this.value.slice(this.cursor+1);if(this.value=`${$}${Z}`,this.red=!1,this.isCursorAtEnd())this.cursorOffset=0;else 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(){if(this.closed)return;if(!this.firstRender){if(this.outputError)this.out.write($1.down(w7(this.outputError,this.out.columns)-1)+a1(this.outputError,this.out.columns));this.out.write(a1(this.outputText,this.out.columns))}if(super.render(),this.outputError="",this.outputText=[p1.symbol(this.done,this.aborted),F1.bold(this.msg),p1.delimiter(this.done),this.red?F1.red(this.rendered):this.rendered].join(" "),this.error)this.outputError+=this.errorMsg.split(`
|
|
8
8
|
`).reduce(($,Z,H)=>$+`
|
|
9
|
-
${H?" ":h7.pointerSmall} ${F1.red().italic(Z)}`,"");this.out.write(x7.line+$1.to(0)+this.outputText+$1.save+this.outputError+$1.restore+$1.move(this.cursorOffset,0))}}e0.exports=r0});var J9=Y((G8,B9)=>{var
|
|
9
|
+
${H?" ":h7.pointerSmall} ${F1.red().italic(Z)}`,"");this.out.write(x7.line+$1.to(0)+this.outputText+$1.save+this.outputError+$1.restore+$1.move(this.cursorOffset,0))}}e0.exports=r0});var J9=Y((G8,B9)=>{var k=G(),k7=h(),Z1=S(),Z9=Z1.style,H9=Z1.clear,N1=Z1.figures,_7=Z1.wrap,f7=Z1.entriesToDisplay,g7=M(),d7=g7.cursor;class z9 extends k7{constructor($={}){super($);this.msg=$.message,this.hint=$.hint||"- Use arrow-keys. Return to submit.",this.warn=$.warn||"- This option is disabled",this.cursor=$.initial||0,this.choices=$.choices.map((Z,H)=>{if(typeof Z==="string")Z={title:Z,value:H};return{title:Z&&(Z.title||Z.value||Z),value:Z&&(Z.value===void 0?H:Z.value),description:Z&&Z.description,selected:Z&&Z.selected,disabled:Z&&Z.disabled}}),this.optionsPerPage=$.optionsPerPage||10,this.value=(this.choices[this.cursor]||{}).value,this.clear=H9("",this.out.columns),this.render()}moveCursor($){this.cursor=$,this.value=this.choices[$].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(`
|
|
10
10
|
`),this.close()}submit(){if(!this.selection.disabled)this.done=!0,this.aborted=!1,this.fire(),this.render(),this.out.write(`
|
|
11
|
-
`),this.close();else this.bell()}first(){this.moveCursor(0),this.render()}last(){this.moveCursor(this.choices.length-1),this.render()}up(){if(this.cursor===0)this.moveCursor(this.choices.length-1);else this.moveCursor(this.cursor-1);this.render()}down(){if(this.cursor===this.choices.length-1)this.moveCursor(0);else this.moveCursor(this.cursor+1);this.render()}next(){this.moveCursor((this.cursor+1)%this.choices.length),this.render()}_($,Z){if($===" ")return this.submit()}get selection(){return this.choices[this.cursor]}render(){if(this.closed)return;if(this.firstRender)this.out.write(d7.hide);else this.out.write(H9(this.outputText,this.out.columns));super.render();let $=f7(this.cursor,this.choices.length,this.optionsPerPage),Z=$.startIndex,H=$.endIndex;if(this.outputText=[Z9.symbol(this.done,this.aborted),
|
|
12
|
-
`;for(let z=Z;z<H;z++){let B,J,X="",C=this.choices[z];if(z===Z&&Z>0)J=N1.arrowUp;else if(z===H-1&&H<this.choices.length)J=N1.arrowDown;else J=" ";if(C.disabled)B=this.cursor===z?
|
|
13
|
-
`+_7(C.description,{margin:3,width:this.out.columns})}this.outputText+=`${J} ${B}${
|
|
14
|
-
`}}this.out.write(this.outputText)}}B9.exports=z9});var K9=Y((M8,W9)=>{var V1=G(),y7=
|
|
11
|
+
`),this.close();else this.bell()}first(){this.moveCursor(0),this.render()}last(){this.moveCursor(this.choices.length-1),this.render()}up(){if(this.cursor===0)this.moveCursor(this.choices.length-1);else this.moveCursor(this.cursor-1);this.render()}down(){if(this.cursor===this.choices.length-1)this.moveCursor(0);else this.moveCursor(this.cursor+1);this.render()}next(){this.moveCursor((this.cursor+1)%this.choices.length),this.render()}_($,Z){if($===" ")return this.submit()}get selection(){return this.choices[this.cursor]}render(){if(this.closed)return;if(this.firstRender)this.out.write(d7.hide);else this.out.write(H9(this.outputText,this.out.columns));super.render();let $=f7(this.cursor,this.choices.length,this.optionsPerPage),Z=$.startIndex,H=$.endIndex;if(this.outputText=[Z9.symbol(this.done,this.aborted),k.bold(this.msg),Z9.delimiter(!1),this.done?this.selection.title:this.selection.disabled?k.yellow(this.warn):k.gray(this.hint)].join(" "),!this.done){this.outputText+=`
|
|
12
|
+
`;for(let z=Z;z<H;z++){let B,J,X="",C=this.choices[z];if(z===Z&&Z>0)J=N1.arrowUp;else if(z===H-1&&H<this.choices.length)J=N1.arrowDown;else J=" ";if(C.disabled)B=this.cursor===z?k.gray().underline(C.title):k.strikethrough().gray(C.title),J=(this.cursor===z?k.bold().gray(N1.pointer)+" ":" ")+J;else if(B=this.cursor===z?k.cyan().underline(C.title):C.title,J=(this.cursor===z?k.cyan(N1.pointer)+" ":" ")+J,C.description&&this.cursor===z){if(X=` - ${C.description}`,J.length+B.length+X.length>=this.out.columns||C.description.split(/\r?\n/).length>1)X=`
|
|
13
|
+
`+_7(C.description,{margin:3,width:this.out.columns})}this.outputText+=`${J} ${B}${k.gray(X)}
|
|
14
|
+
`}}this.out.write(this.outputText)}}B9.exports=z9});var K9=Y((M8,W9)=>{var V1=G(),y7=h(),Q9=S(),X9=Q9.style,v7=Q9.clear,U9=M(),C9=U9.cursor,u7=U9.erase;class Y9 extends y7{constructor($={}){super($);this.msg=$.message,this.value=!!$.initial,this.active=$.active||"on",this.inactive=$.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(`
|
|
15
15
|
`),this.close()}submit(){this.done=!0,this.aborted=!1,this.fire(),this.render(),this.out.write(`
|
|
16
|
-
`),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()}_($,Z){if($===" ")this.value=!this.value;else if($==="1")this.value=!0;else if($==="0")this.value=!1;else return this.bell();this.render()}render(){if(this.closed)return;if(this.firstRender)this.out.write(C9.hide);else this.out.write(v7(this.outputText,this.out.columns));super.render(),this.outputText=[X9.symbol(this.done,this.aborted),V1.bold(this.msg),X9.delimiter(this.done),this.value?this.inactive:V1.cyan().underline(this.inactive),V1.gray("/"),this.value?V1.cyan().underline(this.active):this.active].join(" "),this.out.write(u7.line+C9.to(0)+this.outputText)}}W9.exports=Y9});var
|
|
16
|
+
`),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()}_($,Z){if($===" ")this.value=!this.value;else if($==="1")this.value=!0;else if($==="0")this.value=!1;else return this.bell();this.render()}render(){if(this.closed)return;if(this.firstRender)this.out.write(C9.hide);else this.out.write(v7(this.outputText,this.out.columns));super.render(),this.outputText=[X9.symbol(this.done,this.aborted),V1.bold(this.msg),X9.delimiter(this.done),this.value?this.inactive:V1.cyan().underline(this.inactive),V1.gray("/"),this.value?V1.cyan().underline(this.active):this.active].join(" "),this.out.write(u7.line+C9.to(0)+this.outputText)}}W9.exports=Y9});var E=Y((R8,D9)=>{class A1{constructor({token:$,date:Z,parts:H,locales:z}){this.token=$,this.date=Z||new Date,this.parts=H||[this],this.locales=z||{}}up(){}down(){}next(){let $=this.parts.indexOf(this);return this.parts.find((Z,H)=>H>$&&Z instanceof A1)}setTo($){}prev(){let $=[].concat(this.parts).reverse(),Z=$.indexOf(this);return $.find((H,z)=>z>Z&&H instanceof A1)}toString(){return String(this.date)}}D9.exports=A1});var R9=Y((F8,M9)=>{var c7=E();class G9 extends c7{constructor($={}){super($)}up(){this.date.setHours((this.date.getHours()+12)%24)}down(){this.up()}toString(){let $=this.date.getHours()>12?"pm":"am";return/\A/.test(this.token)?$.toUpperCase():$}}M9.exports=G9});var N9=Y((O8,O9)=>{var m7=E(),n7=($)=>{return $=$%10,$===1?"st":$===2?"nd":$===3?"rd":"th"};class F9 extends m7{constructor($={}){super($)}up(){this.date.setDate(this.date.getDate()+1)}down(){this.date.setDate(this.date.getDate()-1)}setTo($){this.date.setDate(parseInt($.substr(-2)))}toString(){let $=this.date.getDate(),Z=this.date.getDay();return this.token==="DD"?String($).padStart(2,"0"):this.token==="Do"?$+n7($):this.token==="d"?Z+1:this.token==="ddd"?this.locales.weekdaysShort[Z]:this.token==="dddd"?this.locales.weekdays[Z]:$}}O9.exports=F9});var I9=Y((N8,A9)=>{var l7=E();class V9 extends l7{constructor($={}){super($)}up(){this.date.setHours(this.date.getHours()+1)}down(){this.date.setHours(this.date.getHours()-1)}setTo($){this.date.setHours(parseInt($.substr(-2)))}toString(){let $=this.date.getHours();if(/h/.test(this.token))$=$%12||12;return this.token.length>1?String($).padStart(2,"0"):$}}A9.exports=V9});var L9=Y((V8,q9)=>{var i7=E();class S9 extends i7{constructor($={}){super($)}up(){this.date.setMilliseconds(this.date.getMilliseconds()+1)}down(){this.date.setMilliseconds(this.date.getMilliseconds()-1)}setTo($){this.date.setMilliseconds(parseInt($.substr(-this.token.length)))}toString(){return String(this.date.getMilliseconds()).padStart(4,"0").substr(0,this.token.length)}}q9.exports=S9});var b9=Y((A8,j9)=>{var p7=E();class E9 extends p7{constructor($={}){super($)}up(){this.date.setMinutes(this.date.getMinutes()+1)}down(){this.date.setMinutes(this.date.getMinutes()-1)}setTo($){this.date.setMinutes(parseInt($.substr(-2)))}toString(){let $=this.date.getMinutes();return this.token.length>1?String($).padStart(2,"0"):$}}j9.exports=E9});var x9=Y((I8,T9)=>{var a7=E();class P9 extends a7{constructor($={}){super($)}up(){this.date.setMonth(this.date.getMonth()+1)}down(){this.date.setMonth(this.date.getMonth()-1)}setTo($){$=parseInt($.substr(-2))-1,this.date.setMonth($<0?0:$)}toString(){let $=this.date.getMonth(),Z=this.token.length;return Z===2?String($+1).padStart(2,"0"):Z===3?this.locales.monthsShort[$]:Z===4?this.locales.months[$]:String($+1)}}T9.exports=P9});var k9=Y((S8,h9)=>{var t7=E();class w9 extends t7{constructor($={}){super($)}up(){this.date.setSeconds(this.date.getSeconds()+1)}down(){this.date.setSeconds(this.date.getSeconds()-1)}setTo($){this.date.setSeconds(parseInt($.substr(-2)))}toString(){let $=this.date.getSeconds();return this.token.length>1?String($).padStart(2,"0"):$}}h9.exports=w9});var g9=Y((q8,f9)=>{var s7=E();class _9 extends s7{constructor($={}){super($)}up(){this.date.setFullYear(this.date.getFullYear()+1)}down(){this.date.setFullYear(this.date.getFullYear()-1)}setTo($){this.date.setFullYear($.substr(-4))}toString(){let $=String(this.date.getFullYear()).padStart(4,"0");return this.token.length===2?$.substr(-2):$}}f9.exports=_9});var y9=Y((L8,d9)=>{d9.exports={DatePart:E(),Meridiem:R9(),Day:N9(),Hours:I9(),Milliseconds:L9(),Minutes:b9(),Month:x9(),Seconds:k9(),Year:g9()}});var s9=Y((E8,t9)=>{function v9($,Z,H,z,B,J,X){try{var C=$[J](X),Q=C.value}catch(U){H(U);return}if(C.done)Z(Q);else Promise.resolve(Q).then(z,B)}function u9($){return function(){var Z=this,H=arguments;return new Promise(function(z,B){var J=$.apply(Z,H);function X(Q){v9(J,z,B,X,C,"next",Q)}function C(Q){v9(J,z,B,X,C,"throw",Q)}X(void 0)})}}var t1=G(),o7=h(),s1=S(),c9=s1.style,m9=s1.clear,r7=s1.figures,p9=M(),e7=p9.erase,n9=p9.cursor,_=y9(),l9=_.DatePart,$Z=_.Meridiem,ZZ=_.Day,HZ=_.Hours,zZ=_.Milliseconds,BZ=_.Minutes,JZ=_.Month,XZ=_.Seconds,CZ=_.Year,QZ=/\\(.)|"((?:\\["\\]|[^"])+)"|(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,i9={1:({token:$})=>$.replace(/\\(.)/g,"$1"),2:($)=>new ZZ($),3:($)=>new JZ($),4:($)=>new CZ($),5:($)=>new $Z($),6:($)=>new HZ($),7:($)=>new BZ($),8:($)=>new XZ($),9:($)=>new zZ($)},UZ={months:"January,February,March,April,May,June,July,August,September,October,November,December".split(","),monthsShort:"Jan,Feb,Mar,Apr,May,Jun,Jul,Aug,Sep,Oct,Nov,Dec".split(","),weekdays:"Sunday,Monday,Tuesday,Wednesday,Thursday,Friday,Saturday".split(","),weekdaysShort:"Sun,Mon,Tue,Wed,Thu,Fri,Sat".split(",")};class a9 extends o7{constructor($={}){super($);this.msg=$.message,this.cursor=0,this.typed="",this.locales=Object.assign(UZ,$.locales),this._date=$.initial||new Date,this.errorMsg=$.error||"Please Enter A Valid Value",this.validator=$.validate||(()=>!0),this.mask=$.mask||"YYYY-MM-DD HH:mm:ss",this.clear=m9("",this.out.columns),this.render()}get value(){return this.date}get date(){return this._date}set date($){if($)this._date.setTime($.getTime())}set mask($){let Z;this.parts=[];while(Z=QZ.exec($)){let z=Z.shift(),B=Z.findIndex((J)=>J!=null);this.parts.push(B in i9?i9[B]({token:Z[B]||z,date:this.date,parts:this.parts,locales:this.locales}):Z[B]||z)}let H=this.parts.reduce((z,B)=>{if(typeof B==="string"&&typeof z[z.length-1]==="string")z[z.length-1]+=B;else z.push(B);return z},[]);this.parts.splice(0),this.parts.push(...H),this.reset()}moveCursor($){this.typed="",this.cursor=$,this.fire()}reset(){this.moveCursor(this.parts.findIndex(($)=>$ instanceof l9)),this.fire(),this.render()}exit(){this.abort()}abort(){this.done=this.aborted=!0,this.error=!1,this.fire(),this.render(),this.out.write(`
|
|
17
17
|
`),this.close()}validate(){var $=this;return u9(function*(){let Z=yield $.validator($.value);if(typeof Z==="string")$.errorMsg=Z,Z=!1;$.error=!Z})()}submit(){var $=this;return u9(function*(){if(yield $.validate(),$.error){$.color="red",$.fire(),$.render();return}$.done=!0,$.aborted=!1,$.fire(),$.render(),$.out.write(`
|
|
18
18
|
`),$.close()})()}up(){this.typed="",this.parts[this.cursor].up(),this.render()}down(){this.typed="",this.parts[this.cursor].down(),this.render()}left(){let $=this.parts[this.cursor].prev();if($==null)return this.bell();this.moveCursor(this.parts.indexOf($)),this.render()}right(){let $=this.parts[this.cursor].next();if($==null)return this.bell();this.moveCursor(this.parts.indexOf($)),this.render()}next(){let $=this.parts[this.cursor].next();this.moveCursor($?this.parts.indexOf($):this.parts.findIndex((Z)=>Z instanceof l9)),this.render()}_($){if(/\d/.test($))this.typed+=$,this.parts[this.cursor].setTo(this.typed),this.render()}render(){if(this.closed)return;if(this.firstRender)this.out.write(n9.hide);else this.out.write(m9(this.outputText,this.out.columns));if(super.render(),this.outputText=[c9.symbol(this.done,this.aborted),t1.bold(this.msg),c9.delimiter(!1),this.parts.reduce(($,Z,H)=>$.concat(H===this.cursor&&!this.done?t1.cyan().underline(Z.toString()):Z),[]).join("")].join(" "),this.error)this.outputText+=this.errorMsg.split(`
|
|
19
19
|
`).reduce(($,Z,H)=>$+`
|
|
20
|
-
${H?" ":r7.pointerSmall} ${t1.red().italic(Z)}`,"");this.out.write(e7.line+n9.to(0)+this.outputText)}}t9.exports=a9});var B2=Y((j8,z2)=>{function o9($,Z,H,z,B,J,X){try{var C=$[J](X),Q=C.value}catch(U){H(U);return}if(C.done)Z(Q);else Promise.resolve(Q).then(z,B)}function r9($){return function(){var Z=this,H=arguments;return new Promise(function(z,B){var J=$.apply(Z,H);function X(Q){o9(J,z,B,X,C,"next",Q)}function C(Q){o9(J,z,B,X,C,"throw",Q)}X(void 0)})}}var I1=G(),YZ=
|
|
20
|
+
${H?" ":r7.pointerSmall} ${t1.red().italic(Z)}`,"");this.out.write(e7.line+n9.to(0)+this.outputText)}}t9.exports=a9});var B2=Y((j8,z2)=>{function o9($,Z,H,z,B,J,X){try{var C=$[J](X),Q=C.value}catch(U){H(U);return}if(C.done)Z(Q);else Promise.resolve(Q).then(z,B)}function r9($){return function(){var Z=this,H=arguments;return new Promise(function(z,B){var J=$.apply(Z,H);function X(Q){o9(J,z,B,X,C,"next",Q)}function C(Q){o9(J,z,B,X,C,"throw",Q)}X(void 0)})}}var I1=G(),YZ=h(),Z2=M(),S1=Z2.cursor,WZ=Z2.erase,q1=S(),o1=q1.style,KZ=q1.figures,e9=q1.clear,DZ=q1.lines,GZ=/[0-9]/,r1=($)=>$!==void 0,$2=($,Z)=>{let H=Math.pow(10,Z);return Math.round($*H)/H};class H2 extends YZ{constructor($={}){super($);this.transform=o1.render($.style),this.msg=$.message,this.initial=r1($.initial)?$.initial:"",this.float=!!$.float,this.round=$.round||2,this.inc=$.increment||1,this.min=r1($.min)?$.min:-1/0,this.max=r1($.max)?$.max:1/0,this.errorMsg=$.error||"Please Enter A Valid Value",this.validator=$.validate||(()=>!0),this.color="cyan",this.value="",this.typed="",this.lastHit=0,this.render()}set value($){if(!$&&$!==0)this.placeholder=!0,this.rendered=I1.gray(this.transform.render(`${this.initial}`)),this._value="";else this.placeholder=!1,this.rendered=this.transform.render(`${$2($,this.round)}`),this._value=$2($,this.round);this.fire()}get value(){return this._value}parse($){return this.float?parseFloat($):parseInt($)}valid($){return $==="-"||$==="."&&this.float||GZ.test($)}reset(){this.typed="",this.value="",this.fire(),this.render()}exit(){this.abort()}abort(){let $=this.value;this.value=$!==""?$:this.initial,this.done=this.aborted=!0,this.error=!1,this.fire(),this.render(),this.out.write(`
|
|
21
21
|
`),this.close()}validate(){var $=this;return r9(function*(){let Z=yield $.validator($.value);if(typeof Z==="string")$.errorMsg=Z,Z=!1;$.error=!Z})()}submit(){var $=this;return r9(function*(){if(yield $.validate(),$.error){$.color="red",$.fire(),$.render();return}let Z=$.value;$.value=Z!==""?Z:$.initial,$.done=!0,$.aborted=!1,$.error=!1,$.fire(),$.render(),$.out.write(`
|
|
22
22
|
`),$.close()})()}up(){if(this.typed="",this.value==="")this.value=this.min-this.inc;if(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;if(this.value<=this.min)return this.bell();this.value-=this.inc,this.color="cyan",this.fire(),this.render()}delete(){let $=this.value.toString();if($.length===0)return this.bell();if(this.value=this.parse($=$.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()}_($,Z){if(!this.valid($))return this.bell();let H=Date.now();if(H-this.lastHit>1000)this.typed="";if(this.typed+=$,this.lastHit=H,this.color="cyan",$===".")return this.fire();if(this.value=Math.min(this.parse(this.typed),this.max),this.value>this.max)this.value=this.max;if(this.value<this.min)this.value=this.min;this.fire(),this.render()}render(){if(this.closed)return;if(!this.firstRender){if(this.outputError)this.out.write(S1.down(DZ(this.outputError,this.out.columns)-1)+e9(this.outputError,this.out.columns));this.out.write(e9(this.outputText,this.out.columns))}if(super.render(),this.outputError="",this.outputText=[o1.symbol(this.done,this.aborted),I1.bold(this.msg),o1.delimiter(this.done),!this.done||!this.done&&!this.placeholder?I1[this.color]().underline(this.rendered):this.rendered].join(" "),this.error)this.outputError+=this.errorMsg.split(`
|
|
23
23
|
`).reduce(($,Z,H)=>$+`
|
|
24
|
-
${H?" ":KZ.pointerSmall} ${I1.red().italic(Z)}`,"");this.out.write(WZ.line+S1.to(0)+this.outputText+S1.save+this.outputError+S1.restore)}}z2.exports=H2});var e1=Y((b8,Q2)=>{var
|
|
24
|
+
${H?" ":KZ.pointerSmall} ${I1.red().italic(Z)}`,"");this.out.write(WZ.line+S1.to(0)+this.outputText+S1.save+this.outputError+S1.restore)}}z2.exports=H2});var e1=Y((b8,Q2)=>{var j=G(),MZ=M(),RZ=MZ.cursor,FZ=h(),H1=S(),J2=H1.clear,c=H1.figures,X2=H1.style,OZ=H1.wrap,NZ=H1.entriesToDisplay;class C2 extends FZ{constructor($={}){super($);if(this.msg=$.message,this.cursor=$.cursor||0,this.scrollIndex=$.cursor||0,this.hint=$.hint||"",this.warn=$.warn||"- This option is disabled -",this.minSelected=$.min,this.showMinError=!1,this.maxChoices=$.max,this.instructions=$.instructions,this.optionsPerPage=$.optionsPerPage||10,this.value=$.choices.map((Z,H)=>{if(typeof Z==="string")Z={title:Z,value:H};return{title:Z&&(Z.title||Z.value||Z),description:Z&&Z.description,value:Z&&(Z.value===void 0?H:Z.value),selected:Z&&Z.selected,disabled:Z&&Z.disabled}}),this.clear=J2("",this.out.columns),!$.overrideRender)this.render()}reset(){this.value.map(($)=>!$.selected),this.cursor=0,this.fire(),this.render()}selected(){return this.value.filter(($)=>$.selected)}exit(){this.abort()}abort(){this.done=this.aborted=!0,this.fire(),this.render(),this.out.write(`
|
|
25
25
|
`),this.close()}submit(){let $=this.value.filter((Z)=>Z.selected);if(this.minSelected&&$.length<this.minSelected)this.showMinError=!0,this.render();else this.done=!0,this.aborted=!1,this.fire(),this.render(),this.out.write(`
|
|
26
26
|
`),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(){if(this.cursor===0)this.cursor=this.value.length-1;else this.cursor--;this.render()}down(){if(this.cursor===this.value.length-1)this.cursor=0;else this.cursor++;this.render()}left(){this.value[this.cursor].selected=!1,this.render()}right(){if(this.value.filter(($)=>$.selected).length>=this.maxChoices)return this.bell();this.value[this.cursor].selected=!0,this.render()}handleSpaceToggle(){let $=this.value[this.cursor];if($.selected)$.selected=!1,this.render();else if($.disabled||this.value.filter((Z)=>Z.selected).length>=this.maxChoices)return this.bell();else $.selected=!0,this.render()}toggleAll(){if(this.maxChoices!==void 0||this.value[this.cursor].disabled)return this.bell();let $=!this.value[this.cursor].selected;this.value.filter((Z)=>!Z.disabled).forEach((Z)=>Z.selected=$),this.render()}_($,Z){if($===" ")this.handleSpaceToggle();else if($==="a")this.toggleAll();else return this.bell()}renderInstructions(){if(this.instructions===void 0||this.instructions){if(typeof this.instructions==="string")return this.instructions;return`
|
|
27
27
|
Instructions:
|
|
28
|
-
${
|
|
29
|
-
${
|
|
28
|
+
${c.arrowUp}/${c.arrowDown}: Highlight option
|
|
29
|
+
${c.arrowLeft}/${c.arrowRight}/[space]: Toggle selection
|
|
30
30
|
`+(this.maxChoices===void 0?` a: Toggle all
|
|
31
|
-
`:"")+" enter/return: Complete answer"}return""}renderOption($,Z,H,z){let B=(Z.selected?
|
|
32
|
-
`+OZ(Z.description,{margin:B.length,width:this.out.columns})}return B+J+
|
|
31
|
+
`:"")+" enter/return: Complete answer"}return""}renderOption($,Z,H,z){let B=(Z.selected?j.green(c.radioOn):c.radioOff)+" "+z+" ",J,X;if(Z.disabled)J=$===H?j.gray().underline(Z.title):j.strikethrough().gray(Z.title);else if(J=$===H?j.cyan().underline(Z.title):Z.title,$===H&&Z.description){if(X=` - ${Z.description}`,B.length+J.length+X.length>=this.out.columns||Z.description.split(/\r?\n/).length>1)X=`
|
|
32
|
+
`+OZ(Z.description,{margin:B.length,width:this.out.columns})}return B+J+j.gray(X||"")}paginateOptions($){if($.length===0)return j.red("No matches for this query.");let Z=NZ(this.cursor,$.length,this.optionsPerPage),H=Z.startIndex,z=Z.endIndex,B,J=[];for(let X=H;X<z;X++){if(X===H&&H>0)B=c.arrowUp;else if(X===z-1&&z<$.length)B=c.arrowDown;else B=" ";J.push(this.renderOption(this.cursor,$[X],X,B))}return`
|
|
33
33
|
`+J.join(`
|
|
34
|
-
`)}renderOptions($){if(!this.done)return this.paginateOptions($);return""}renderDoneOrInstructions(){if(this.done)return this.value.filter((Z)=>Z.selected).map((Z)=>Z.title).join(", ");let $=[
|
|
34
|
+
`)}renderOptions($){if(!this.done)return this.paginateOptions($);return""}renderDoneOrInstructions(){if(this.done)return this.value.filter((Z)=>Z.selected).map((Z)=>Z.title).join(", ");let $=[j.gray(this.hint),this.renderInstructions()];if(this.value[this.cursor].disabled)$.push(j.yellow(this.warn));return $.join(" ")}render(){if(this.closed)return;if(this.firstRender)this.out.write(RZ.hide);super.render();let $=[X2.symbol(this.done,this.aborted),j.bold(this.msg),X2.delimiter(!1),this.renderDoneOrInstructions()].join(" ");if(this.showMinError)$+=j.red(`You must select a minimum of ${this.minSelected} choices.`),this.showMinError=!1;$+=this.renderOptions(this.value),this.out.write(this.clear+$),this.clear=J2($,this.out.columns)}}Q2.exports=C2});var R2=Y((P8,M2)=>{function U2($,Z,H,z,B,J,X){try{var C=$[J](X),Q=C.value}catch(U){H(U);return}if(C.done)Z(Q);else Promise.resolve(Q).then(z,B)}function VZ($){return function(){var Z=this,H=arguments;return new Promise(function(z,B){var J=$.apply(Z,H);function X(Q){U2(J,z,B,X,C,"next",Q)}function C(Q){U2(J,z,B,X,C,"throw",Q)}X(void 0)})}}var z1=G(),AZ=h(),D2=M(),IZ=D2.erase,Y2=D2.cursor,B1=S(),$0=B1.style,W2=B1.clear,Z0=B1.figures,SZ=B1.wrap,qZ=B1.entriesToDisplay,K2=($,Z)=>$[Z]&&($[Z].value||$[Z].title||$[Z]),LZ=($,Z)=>$[Z]&&($[Z].title||$[Z].value||$[Z]),EZ=($,Z)=>{let H=$.findIndex((z)=>z.value===Z||z.title===Z);return H>-1?H:void 0};class G2 extends AZ{constructor($={}){super($);this.msg=$.message,this.suggest=$.suggest,this.choices=$.choices,this.initial=typeof $.initial==="number"?$.initial:EZ($.choices,$.initial),this.select=this.initial||$.cursor||0,this.i18n={noMatches:$.noMatches||"no matches found"},this.fallback=$.fallback||this.initial,this.clearFirst=$.clearFirst||!1,this.suggestions=[],this.input="",this.limit=$.limit||10,this.cursor=0,this.transform=$0.render($.style),this.scale=this.transform.scale,this.render=this.render.bind(this),this.complete=this.complete.bind(this),this.clear=W2("",this.out.columns),this.complete(this.render),this.render()}set fallback($){this._fb=Number.isSafeInteger(parseInt($))?parseInt($):$}get fallback(){let $;if(typeof this._fb==="number")$=this.choices[this._fb];else if(typeof this._fb==="string")$={title:this._fb};return $||this._fb||{title:this.i18n.noMatches}}moveSelect($){if(this.select=$,this.suggestions.length>0)this.value=K2(this.suggestions,$);else this.value=this.fallback.value;this.fire()}complete($){var Z=this;return VZ(function*(){let H=Z.completing=Z.suggest(Z.input,Z.choices),z=yield H;if(Z.completing!==H)return;Z.suggestions=z.map((J,X,C)=>({title:LZ(C,X),value:K2(C,X),description:J.description})),Z.completing=!1;let B=Math.max(z.length-1,0);Z.moveSelect(Math.min(B,Z.select)),$&&$()})()}reset(){this.input="",this.complete(()=>{this.moveSelect(this.initial!==void 0?this.initial:0),this.render()}),this.render()}exit(){if(this.clearFirst&&this.input.length>0)this.reset();else this.done=this.exited=!0,this.aborted=!1,this.fire(),this.render(),this.out.write(`
|
|
35
35
|
`),this.close()}abort(){this.done=this.aborted=!0,this.exited=!1,this.fire(),this.render(),this.out.write(`
|
|
36
36
|
`),this.close()}submit(){this.done=!0,this.aborted=this.exited=!1,this.fire(),this.render(),this.out.write(`
|
|
37
37
|
`),this.close()}_($,Z){let H=this.input.slice(0,this.cursor),z=this.input.slice(this.cursor);this.input=`${H}${$}${z}`,this.cursor=H.length+1,this.complete(this.render),this.render()}delete(){if(this.cursor===0)return this.bell();let $=this.input.slice(0,this.cursor-1),Z=this.input.slice(this.cursor);this.input=`${$}${Z}`,this.complete(this.render),this.cursor=this.cursor-1,this.render()}deleteForward(){if(this.cursor*this.scale>=this.rendered.length)return this.bell();let $=this.input.slice(0,this.cursor),Z=this.input.slice(this.cursor+1);this.input=`${$}${Z}`,this.complete(this.render),this.render()}first(){this.moveSelect(0),this.render()}last(){this.moveSelect(this.suggestions.length-1),this.render()}up(){if(this.select===0)this.moveSelect(this.suggestions.length-1);else this.moveSelect(this.select-1);this.render()}down(){if(this.select===this.suggestions.length-1)this.moveSelect(0);else this.moveSelect(this.select+1);this.render()}next(){if(this.select===this.suggestions.length-1)this.moveSelect(0);else this.moveSelect(this.select+1);this.render()}nextPage(){this.moveSelect(Math.min(this.select+this.limit,this.suggestions.length-1)),this.render()}prevPage(){this.moveSelect(Math.max(this.select-this.limit,0)),this.render()}left(){if(this.cursor<=0)return this.bell();this.cursor=this.cursor-1,this.render()}right(){if(this.cursor*this.scale>=this.rendered.length)return this.bell();this.cursor=this.cursor+1,this.render()}renderOption($,Z,H,z){let B,J=H?Z0.arrowUp:z?Z0.arrowDown:" ",X=Z?z1.cyan().underline($.title):$.title;if(J=(Z?z1.cyan(Z0.pointer)+" ":" ")+J,$.description){if(B=` - ${$.description}`,J.length+X.length+B.length>=this.out.columns||$.description.split(/\r?\n/).length>1)B=`
|
|
38
|
-
`+SZ($.description,{margin:3,width:this.out.columns})}return J+" "+X+z1.gray(B||"")}render(){if(this.closed)return;if(this.firstRender)this.out.write(Y2.hide);else this.out.write(W2(this.outputText,this.out.columns));super.render();let $=
|
|
38
|
+
`+SZ($.description,{margin:3,width:this.out.columns})}return J+" "+X+z1.gray(B||"")}render(){if(this.closed)return;if(this.firstRender)this.out.write(Y2.hide);else this.out.write(W2(this.outputText,this.out.columns));super.render();let $=qZ(this.select,this.choices.length,this.limit),Z=$.startIndex,H=$.endIndex;if(this.outputText=[$0.symbol(this.done,this.aborted,this.exited),z1.bold(this.msg),$0.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 z=this.suggestions.slice(Z,H).map((B,J)=>this.renderOption(B,this.select===J+Z,J===0&&Z>0,J+Z===H-1&&H<this.choices.length)).join(`
|
|
39
39
|
`);this.outputText+=`
|
|
40
|
-
`+(z||z1.gray(this.fallback.title))}this.out.write(IZ.line+Y2.to(0)+this.outputText)}}M2.exports=G2});var A2=Y((T8,V2)=>{var
|
|
40
|
+
`+(z||z1.gray(this.fallback.title))}this.out.write(IZ.line+Y2.to(0)+this.outputText)}}M2.exports=G2});var A2=Y((T8,V2)=>{var f=G(),jZ=M(),bZ=jZ.cursor,PZ=e1(),H0=S(),F2=H0.clear,O2=H0.style,t=H0.figures;class N2 extends PZ{constructor($={}){$.overrideRender=!0;super($);this.inputValue="",this.clear=F2("",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(){if(this.cursor===0)this.cursor=this.filteredOptions.length-1;else this.cursor--;this.render()}down(){if(this.cursor===this.filteredOptions.length-1)this.cursor=0;else this.cursor++;this.render()}left(){this.filteredOptions[this.cursor].selected=!1,this.render()}right(){if(this.value.filter(($)=>$.selected).length>=this.maxChoices)return this.bell();this.filteredOptions[this.cursor].selected=!0,this.render()}delete(){if(this.inputValue.length)this.inputValue=this.inputValue.substr(0,this.inputValue.length-1),this.updateFilteredOptions()}updateFilteredOptions(){let $=this.filteredOptions[this.cursor];this.filteredOptions=this.value.filter((H)=>{if(this.inputValue){if(typeof H.title==="string"){if(H.title.toLowerCase().includes(this.inputValue.toLowerCase()))return!0}if(typeof H.value==="string"){if(H.value.toLowerCase().includes(this.inputValue.toLowerCase()))return!0}return!1}return!0});let Z=this.filteredOptions.findIndex((H)=>H===$);this.cursor=Z<0?0:Z,this.render()}handleSpaceToggle(){let $=this.filteredOptions[this.cursor];if($.selected)$.selected=!1,this.render();else if($.disabled||this.value.filter((Z)=>Z.selected).length>=this.maxChoices)return this.bell();else $.selected=!0,this.render()}handleInputChange($){this.inputValue=this.inputValue+$,this.updateFilteredOptions()}_($,Z){if($===" ")this.handleSpaceToggle();else this.handleInputChange($)}renderInstructions(){if(this.instructions===void 0||this.instructions){if(typeof this.instructions==="string")return this.instructions;return`
|
|
41
41
|
Instructions:
|
|
42
42
|
${t.arrowUp}/${t.arrowDown}: Highlight option
|
|
43
43
|
${t.arrowLeft}/${t.arrowRight}/[space]: Toggle selection
|
|
44
44
|
[a,b,c]/delete: Filter choices
|
|
45
45
|
enter/return: Complete answer
|
|
46
46
|
`}return""}renderCurrentInput(){return`
|
|
47
|
-
Filtered results for: ${this.inputValue?this.inputValue:
|
|
48
|
-
`}renderOption($,Z,H){let z;if(Z.disabled)z=$===H?
|
|
47
|
+
Filtered results for: ${this.inputValue?this.inputValue:f.gray("Enter something to filter")}
|
|
48
|
+
`}renderOption($,Z,H){let z;if(Z.disabled)z=$===H?f.gray().underline(Z.title):f.strikethrough().gray(Z.title);else z=$===H?f.cyan().underline(Z.title):Z.title;return(Z.selected?f.green(t.radioOn):t.radioOff)+" "+z}renderDoneOrInstructions(){if(this.done)return this.value.filter((Z)=>Z.selected).map((Z)=>Z.title).join(", ");let $=[f.gray(this.hint),this.renderInstructions(),this.renderCurrentInput()];if(this.filteredOptions.length&&this.filteredOptions[this.cursor].disabled)$.push(f.yellow(this.warn));return $.join(" ")}render(){if(this.closed)return;if(this.firstRender)this.out.write(bZ.hide);super.render();let $=[O2.symbol(this.done,this.aborted),f.bold(this.msg),O2.delimiter(!1),this.renderDoneOrInstructions()].join(" ");if(this.showMinError)$+=f.red(`You must select a minimum of ${this.minSelected} choices.`),this.showMinError=!1;$+=this.renderOptions(this.filteredOptions),this.out.write(this.clear+$),this.clear=F2($,this.out.columns)}}V2.exports=N2});var P2=Y((x8,b2)=>{var I2=G(),TZ=h(),L2=S(),S2=L2.style,xZ=L2.clear,E2=M(),wZ=E2.erase,q2=E2.cursor;class j2 extends TZ{constructor($={}){super($);this.msg=$.message,this.value=$.initial,this.initialValue=!!$.initial,this.yesMsg=$.yes||"yes",this.yesOption=$.yesOption||"(Y/n)",this.noMsg=$.no||"no",this.noOption=$.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(`
|
|
49
49
|
`),this.close()}submit(){this.value=this.value||!1,this.done=!0,this.aborted=!1,this.fire(),this.render(),this.out.write(`
|
|
50
|
-
`),this.close()}_($,Z){if($.toLowerCase()==="y")return this.value=!0,this.submit();if($.toLowerCase()==="n")return this.value=!1,this.submit();return this.bell()}render(){if(this.closed)return;if(this.firstRender)this.out.write(
|
|
51
|
-
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}var J=!0,X=!1,C;return{s:function(){H=H.call($)},n:function(){var U=H.next();return J=U.done,U},e:function(U){X=!0,C=U},f:function(){try{if(!J&&H.return!=null)H.return()}finally{if(X)throw C}}}}function gZ($,Z){if(!$)return;if(typeof $==="string")return f2($,Z);var H=Object.prototype.toString.call($).slice(8,-1);if(H==="Object"&&$.constructor)H=$.constructor.name;if(H==="Map"||H==="Set")return Array.from($);if(H==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(H))return f2($,Z)}function f2($,Z){if(Z==null||Z>$.length)Z=$.length;for(var H=0,z=Array(Z);H<Z;H++)z[H]=$[H];return z}function g2($,Z,H,z,B,J,X){try{var C=$[J](X),Q=C.value}catch(U){H(U);return}if(C.done)Z(Q);else Promise.resolve(Q).then(z,B)}function d2($){return function(){var Z=this,H=arguments;return new Promise(function(z,B){var J=$.apply(Z,H);function X(Q){g2(J,z,B,X,C,"next",Q)}function C(Q){g2(J,z,B,X,C,"throw",Q)}X(void 0)})}}var z0=h2(),dZ=["suggest","format","onState","validate","onRender","type"],y2=()=>{};function
|
|
50
|
+
`),this.close()}_($,Z){if($.toLowerCase()==="y")return this.value=!0,this.submit();if($.toLowerCase()==="n")return this.value=!1,this.submit();return this.bell()}render(){if(this.closed)return;if(this.firstRender)this.out.write(q2.hide);else this.out.write(xZ(this.outputText,this.out.columns));super.render(),this.outputText=[S2.symbol(this.done,this.aborted),I2.bold(this.msg),S2.delimiter(this.done),this.done?this.value?this.yesMsg:this.noMsg:I2.gray(this.initialValue?this.yesOption:this.noOption)].join(" "),this.out.write(wZ.line+q2.to(0)+this.outputText)}}b2.exports=j2});var x2=Y((w8,T2)=>{T2.exports={TextPrompt:$9(),SelectPrompt:J9(),TogglePrompt:K9(),DatePrompt:s9(),NumberPrompt:B2(),MultiselectPrompt:e1(),AutocompletePrompt:R2(),AutocompleteMultiselectPrompt:A2(),ConfirmPrompt:P2()}});var h2=Y((w2)=>{var V=w2,hZ=x2(),L1=($)=>$;function b($,Z,H={}){return new Promise((z,B)=>{let J=new hZ[$](Z),X=H.onAbort||L1,C=H.onSubmit||L1,Q=H.onExit||L1;J.on("state",Z.onState||L1),J.on("submit",(U)=>z(C(U))),J.on("exit",(U)=>z(Q(U))),J.on("abort",(U)=>B(X(U)))})}V.text=($)=>b("TextPrompt",$);V.password=($)=>{return $.style="password",V.text($)};V.invisible=($)=>{return $.style="invisible",V.text($)};V.number=($)=>b("NumberPrompt",$);V.date=($)=>b("DatePrompt",$);V.confirm=($)=>b("ConfirmPrompt",$);V.list=($)=>{let Z=$.separator||",";return b("TextPrompt",$,{onSubmit:(H)=>H.split(Z).map((z)=>z.trim())})};V.toggle=($)=>b("TogglePrompt",$);V.select=($)=>b("SelectPrompt",$);V.multiselect=($)=>{$.choices=[].concat($.choices||[]);let Z=(H)=>H.filter((z)=>z.selected).map((z)=>z.value);return b("MultiselectPrompt",$,{onAbort:Z,onSubmit:Z})};V.autocompleteMultiselect=($)=>{$.choices=[].concat($.choices||[]);let Z=(H)=>H.filter((z)=>z.selected).map((z)=>z.value);return b("AutocompleteMultiselectPrompt",$,{onAbort:Z,onSubmit:Z})};var kZ=($,Z)=>Promise.resolve(Z.filter((H)=>H.title.slice(0,$.length).toLowerCase()===$.toLowerCase()));V.autocomplete=($)=>{return $.suggest=$.suggest||kZ,$.choices=[].concat($.choices||[]),b("AutocompletePrompt",$)}});var u2=Y((k8,v2)=>{function k2($,Z){var H=Object.keys($);if(Object.getOwnPropertySymbols){var z=Object.getOwnPropertySymbols($);if(Z)z=z.filter(function(B){return Object.getOwnPropertyDescriptor($,B).enumerable});H.push.apply(H,z)}return H}function _2($){for(var Z=1;Z<arguments.length;Z++){var H=arguments[Z]!=null?arguments[Z]:{};if(Z%2)k2(Object(H),!0).forEach(function(z){_Z($,z,H[z])});else if(Object.getOwnPropertyDescriptors)Object.defineProperties($,Object.getOwnPropertyDescriptors(H));else k2(Object(H)).forEach(function(z){Object.defineProperty($,z,Object.getOwnPropertyDescriptor(H,z))})}return $}function _Z($,Z,H){if(Z in $)Object.defineProperty($,Z,{value:H,enumerable:!0,configurable:!0,writable:!0});else $[Z]=H;return $}function fZ($,Z){var H=typeof Symbol<"u"&&$[Symbol.iterator]||$["@@iterator"];if(!H){if(Array.isArray($)||(H=gZ($))||Z&&$&&typeof $.length==="number"){if(H)$=H;var z=0,B=function(){};return{s:B,n:function(){if(z>=$.length)return{done:!0};return{done:!1,value:$[z++]}},e:function(U){throw U},f:B}}throw TypeError(`Invalid attempt to iterate non-iterable instance.
|
|
51
|
+
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}var J=!0,X=!1,C;return{s:function(){H=H.call($)},n:function(){var U=H.next();return J=U.done,U},e:function(U){X=!0,C=U},f:function(){try{if(!J&&H.return!=null)H.return()}finally{if(X)throw C}}}}function gZ($,Z){if(!$)return;if(typeof $==="string")return f2($,Z);var H=Object.prototype.toString.call($).slice(8,-1);if(H==="Object"&&$.constructor)H=$.constructor.name;if(H==="Map"||H==="Set")return Array.from($);if(H==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(H))return f2($,Z)}function f2($,Z){if(Z==null||Z>$.length)Z=$.length;for(var H=0,z=Array(Z);H<Z;H++)z[H]=$[H];return z}function g2($,Z,H,z,B,J,X){try{var C=$[J](X),Q=C.value}catch(U){H(U);return}if(C.done)Z(Q);else Promise.resolve(Q).then(z,B)}function d2($){return function(){var Z=this,H=arguments;return new Promise(function(z,B){var J=$.apply(Z,H);function X(Q){g2(J,z,B,X,C,"next",Q)}function C(Q){g2(J,z,B,X,C,"throw",Q)}X(void 0)})}}var z0=h2(),dZ=["suggest","format","onState","validate","onRender","type"],y2=()=>{};function m(){return B0.apply(this,arguments)}function B0(){return B0=d2(function*($=[],{onSubmit:Z=y2,onCancel:H=y2}={}){let z={},B=m._override||{};$=[].concat($);let J,X,C,Q,U,N,W=function(){var u=d2(function*(w,W1,N0=!1){if(!N0&&w.validate&&w.validate(W1)!==!0)return;return w.format?yield w.format(W1,z):W1});return function(W1,N0){return u.apply(this,arguments)}}();var R=fZ($),O;try{for(R.s();!(O=R.n()).done;){X=O.value;var L=X;if(Q=L.name,U=L.type,typeof U==="function")U=yield U(J,_2({},z),X),X.type=U;if(!U)continue;for(let u in X){if(dZ.includes(u))continue;let w=X[u];X[u]=typeof w==="function"?yield w(J,_2({},z),N):w}if(N=X,typeof X.message!=="string")throw Error("prompt message is required");var O0=X;if(Q=O0.name,U=O0.type,z0[U]===void 0)throw Error(`prompt type (${U}) is not defined`);if(B[X.name]!==void 0){if(J=yield W(X,B[X.name]),J!==void 0){z[Q]=J;continue}}try{J=m._injected?yZ(m._injected,X.initial):yield z0[U](X),z[Q]=J=yield W(X,J,!0),C=yield Z(X,J,z)}catch(u){C=!(yield H(X,z))}if(C)return z}}catch(u){R.e(u)}finally{R.f()}return z}),B0.apply(this,arguments)}function yZ($,Z){let H=$.shift();if(H instanceof Error)throw H;return H===void 0?Z:H}function vZ($){m._injected=(m._injected||[]).concat($)}function uZ($){m._override=Object.assign({},$)}v2.exports=Object.assign(m,{prompt:m,prompts:z0,inject:vZ,override:uZ})});var m2=Y((_8,c2)=>{c2.exports=($,Z)=>{if($.meta&&$.name!=="escape")return;if($.ctrl){if($.name==="a")return"first";if($.name==="c")return"abort";if($.name==="d")return"abort";if($.name==="e")return"last";if($.name==="g")return"reset"}if(Z){if($.name==="j")return"down";if($.name==="k")return"up"}if($.name==="return")return"submit";if($.name==="enter")return"submit";if($.name==="backspace")return"delete";if($.name==="delete")return"deleteForward";if($.name==="abort")return"abort";if($.name==="escape")return"exit";if($.name==="tab")return"next";if($.name==="pagedown")return"nextPage";if($.name==="pageup")return"prevPage";if($.name==="home")return"home";if($.name==="end")return"end";if($.name==="up")return"up";if($.name==="down")return"down";if($.name==="right")return"right";if($.name==="left")return"left";return!1}});var E1=Y((f8,n2)=>{n2.exports=($)=>{let Z=["[\\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("|"),H=new RegExp(Z,"g");return typeof $==="string"?$.replace(H,""):$}});var p2=Y((g8,i2)=>{var cZ=E1(),{erase:l2,cursor:mZ}=M(),nZ=($)=>[...cZ($)].length;i2.exports=function($,Z){if(!Z)return l2.line+mZ.to(0);let H=0,z=$.split(/\r?\n/);for(let B of z)H+=1+Math.floor(Math.max(nZ(B)-1,0)/Z);return l2.lines(H)}});var J0=Y((d8,a2)=>{var J1={arrowUp:"↑",arrowDown:"↓",arrowLeft:"←",arrowRight:"→",radioOn:"◉",radioOff:"◯",tick:"✔",cross:"✖",ellipsis:"…",pointerSmall:"›",line:"─",pointer:"❯"},lZ={arrowUp:J1.arrowUp,arrowDown:J1.arrowDown,arrowLeft:J1.arrowLeft,arrowRight:J1.arrowRight,radioOn:"(*)",radioOff:"( )",tick:"√",cross:"×",ellipsis:"...",pointerSmall:"»",line:"─",pointer:">"},iZ=process.platform==="win32"?lZ:J1;a2.exports=iZ});var s2=Y((y8,t2)=>{var s=G(),p=J0(),X0=Object.freeze({password:{scale:1,render:($)=>"*".repeat($.length)},emoji:{scale:2,render:($)=>"\uD83D\uDE03".repeat($.length)},invisible:{scale:0,render:($)=>""},default:{scale:1,render:($)=>`${$}`}}),pZ=($)=>X0[$]||X0.default,X1=Object.freeze({aborted:s.red(p.cross),done:s.green(p.tick),exited:s.yellow(p.cross),default:s.cyan("?")}),aZ=($,Z,H)=>Z?X1.aborted:H?X1.exited:$?X1.done:X1.default,tZ=($)=>s.gray($?p.ellipsis:p.pointerSmall),sZ=($,Z)=>s.gray($?Z?p.pointerSmall:"+":p.line);t2.exports={styles:X0,render:pZ,symbols:X1,symbol:aZ,delimiter:tZ,item:sZ}});var r2=Y((v8,o2)=>{var oZ=E1();o2.exports=function($,Z){let H=String(oZ($)||"").split(/\r?\n/);if(!Z)return H.length;return H.map((z)=>Math.ceil(z.length/Z)).reduce((z,B)=>z+B)}});var $4=Y((u8,e2)=>{e2.exports=($,Z={})=>{let H=Number.isSafeInteger(parseInt(Z.margin))?Array(parseInt(Z.margin)).fill(" ").join(""):Z.margin||"",z=Z.width;return($||"").split(/\r?\n/g).map((B)=>B.split(/\s+/g).reduce((J,X)=>{if(X.length+H.length>=z||J[J.length-1].length+X.length+1<z)J[J.length-1]+=` ${X}`;else J.push(`${H}${X}`);return J},[H]).join(`
|
|
52
52
|
`)).join(`
|
|
53
|
-
`)}});var H4=Y((c8,Z4)=>{Z4.exports=($,Z,H)=>{H=H||Z;let z=Math.min(Z-H,$-Math.floor(H/2));if(z<0)z=0;let B=Math.min(z+H,Z);return{startIndex:z,endIndex:B}}});var
|
|
53
|
+
`)}});var H4=Y((c8,Z4)=>{Z4.exports=($,Z,H)=>{H=H||Z;let z=Math.min(Z-H,$-Math.floor(H/2));if(z<0)z=0;let B=Math.min(z+H,Z);return{startIndex:z,endIndex:B}}});var q=Y((m8,z4)=>{z4.exports={action:m2(),clear:p2(),style:s2(),strip:E1(),figures:J0(),lines:r2(),wrap:$4(),entriesToDisplay:H4()}});var g=Y((n8,X4)=>{var B4=K1("readline"),{action:rZ}=q(),eZ=K1("events"),{beep:$5,cursor:Z5}=M(),H5=G();class J4 extends eZ{constructor($={}){super();this.firstRender=!0,this.in=$.stdin||process.stdin,this.out=$.stdout||process.stdout,this.onRender=($.onRender||(()=>{return})).bind(this);let Z=B4.createInterface({input:this.in,escapeCodeTimeout:50});if(B4.emitKeypressEvents(this.in,Z),this.in.isTTY)this.in.setRawMode(!0);let H=["SelectPrompt","MultiselectPrompt"].indexOf(this.constructor.name)>-1,z=(B,J)=>{let X=rZ(J,H);if(X===!1)this._&&this._(B,J);else if(typeof this[X]==="function")this[X](J);else this.bell()};this.close=()=>{if(this.out.write(Z5.show),this.in.removeListener("keypress",z),this.in.isTTY)this.in.setRawMode(!1);Z.close(),this.emit(this.aborted?"abort":this.exited?"exit":"submit",this.value),this.closed=!0},this.in.on("keypress",z)}fire(){this.emit("state",{value:this.value,aborted:!!this.aborted,exited:!!this.exited})}bell(){this.out.write($5)}render(){if(this.onRender(H5),this.firstRender)this.firstRender=!1}}X4.exports=J4});var U4=Y((l8,Q4)=>{var j1=G(),z5=g(),{erase:B5,cursor:C1}=M(),{style:C0,clear:Q0,lines:J5,figures:X5}=q();class C4 extends z5{constructor($={}){super($);this.transform=C0.render($.style),this.scale=this.transform.scale,this.msg=$.message,this.initial=$.initial||"",this.validator=$.validate||(()=>!0),this.value="",this.errorMsg=$.error||"Please Enter A Valid Value",this.cursor=Number(!!this.initial),this.cursorOffset=0,this.clear=Q0("",this.out.columns),this.render()}set value($){if(!$&&this.initial)this.placeholder=!0,this.rendered=j1.gray(this.transform.render(this.initial));else this.placeholder=!1,this.rendered=this.transform.render($);this._value=$,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
54
|
`),this.close()}async validate(){let $=await this.validator(this.value);if(typeof $==="string")this.errorMsg=$,$=!1;this.error=!$}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(`
|
|
55
55
|
`),this.close()}next(){if(!this.placeholder)return this.bell();this.value=this.initial,this.cursor=this.rendered.length,this.fire(),this.render()}moveCursor($){if(this.placeholder)return;this.cursor=this.cursor+$,this.cursorOffset+=$}_($,Z){let H=this.value.slice(0,this.cursor),z=this.value.slice(this.cursor);this.value=`${H}${$}${z}`,this.red=!1,this.cursor=this.placeholder?0:H.length+1,this.render()}delete(){if(this.isCursorAtStart())return this.bell();let $=this.value.slice(0,this.cursor-1),Z=this.value.slice(this.cursor);if(this.value=`${$}${Z}`,this.red=!1,this.isCursorAtStart())this.cursorOffset=0;else this.cursorOffset++,this.moveCursor(-1);this.render()}deleteForward(){if(this.cursor*this.scale>=this.rendered.length||this.placeholder)return this.bell();let $=this.value.slice(0,this.cursor),Z=this.value.slice(this.cursor+1);if(this.value=`${$}${Z}`,this.red=!1,this.isCursorAtEnd())this.cursorOffset=0;else 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(){if(this.closed)return;if(!this.firstRender){if(this.outputError)this.out.write(C1.down(J5(this.outputError,this.out.columns)-1)+Q0(this.outputError,this.out.columns));this.out.write(Q0(this.outputText,this.out.columns))}if(super.render(),this.outputError="",this.outputText=[C0.symbol(this.done,this.aborted),j1.bold(this.msg),C0.delimiter(this.done),this.red?j1.red(this.rendered):this.rendered].join(" "),this.error)this.outputError+=this.errorMsg.split(`
|
|
56
56
|
`).reduce(($,Z,H)=>$+`
|
|
57
|
-
${H?" ":X5.pointerSmall} ${j1.red().italic(Z)}`,"");this.out.write(B5.line+C1.to(0)+this.outputText+C1.save+this.outputError+C1.restore+C1.move(this.cursorOffset,0))}}Q4.exports=C4});var G4=Y((i8,D4)=>{var
|
|
57
|
+
${H?" ":X5.pointerSmall} ${j1.red().italic(Z)}`,"");this.out.write(B5.line+C1.to(0)+this.outputText+C1.save+this.outputError+C1.restore+C1.move(this.cursorOffset,0))}}Q4.exports=C4});var G4=Y((i8,D4)=>{var d=G(),C5=g(),{style:Y4,clear:W4,figures:b1,wrap:Q5,entriesToDisplay:U5}=q(),{cursor:Y5}=M();class K4 extends C5{constructor($={}){super($);this.msg=$.message,this.hint=$.hint||"- Use arrow-keys. Return to submit.",this.warn=$.warn||"- This option is disabled",this.cursor=$.initial||0,this.choices=$.choices.map((Z,H)=>{if(typeof Z==="string")Z={title:Z,value:H};return{title:Z&&(Z.title||Z.value||Z),value:Z&&(Z.value===void 0?H:Z.value),description:Z&&Z.description,selected:Z&&Z.selected,disabled:Z&&Z.disabled}}),this.optionsPerPage=$.optionsPerPage||10,this.value=(this.choices[this.cursor]||{}).value,this.clear=W4("",this.out.columns),this.render()}moveCursor($){this.cursor=$,this.value=this.choices[$].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(`
|
|
58
58
|
`),this.close()}submit(){if(!this.selection.disabled)this.done=!0,this.aborted=!1,this.fire(),this.render(),this.out.write(`
|
|
59
|
-
`),this.close();else this.bell()}first(){this.moveCursor(0),this.render()}last(){this.moveCursor(this.choices.length-1),this.render()}up(){if(this.cursor===0)this.moveCursor(this.choices.length-1);else this.moveCursor(this.cursor-1);this.render()}down(){if(this.cursor===this.choices.length-1)this.moveCursor(0);else this.moveCursor(this.cursor+1);this.render()}next(){this.moveCursor((this.cursor+1)%this.choices.length),this.render()}_($,Z){if($===" ")return this.submit()}get selection(){return this.choices[this.cursor]}render(){if(this.closed)return;if(this.firstRender)this.out.write(Y5.hide);else this.out.write(W4(this.outputText,this.out.columns));super.render();let{startIndex:$,endIndex:Z}=U5(this.cursor,this.choices.length,this.optionsPerPage);if(this.outputText=[Y4.symbol(this.done,this.aborted),
|
|
60
|
-
`;for(let H=$;H<Z;H++){let z,B,J="",X=this.choices[H];if(H===$&&$>0)B=b1.arrowUp;else if(H===Z-1&&Z<this.choices.length)B=b1.arrowDown;else B=" ";if(X.disabled)z=this.cursor===H?
|
|
61
|
-
`+Q5(X.description,{margin:3,width:this.out.columns})}this.outputText+=`${B} ${z}${
|
|
62
|
-
`}}this.out.write(this.outputText)}}D4.exports=K4});var N4=Y((p8,O4)=>{var P1=G(),W5=
|
|
59
|
+
`),this.close();else this.bell()}first(){this.moveCursor(0),this.render()}last(){this.moveCursor(this.choices.length-1),this.render()}up(){if(this.cursor===0)this.moveCursor(this.choices.length-1);else this.moveCursor(this.cursor-1);this.render()}down(){if(this.cursor===this.choices.length-1)this.moveCursor(0);else this.moveCursor(this.cursor+1);this.render()}next(){this.moveCursor((this.cursor+1)%this.choices.length),this.render()}_($,Z){if($===" ")return this.submit()}get selection(){return this.choices[this.cursor]}render(){if(this.closed)return;if(this.firstRender)this.out.write(Y5.hide);else this.out.write(W4(this.outputText,this.out.columns));super.render();let{startIndex:$,endIndex:Z}=U5(this.cursor,this.choices.length,this.optionsPerPage);if(this.outputText=[Y4.symbol(this.done,this.aborted),d.bold(this.msg),Y4.delimiter(!1),this.done?this.selection.title:this.selection.disabled?d.yellow(this.warn):d.gray(this.hint)].join(" "),!this.done){this.outputText+=`
|
|
60
|
+
`;for(let H=$;H<Z;H++){let z,B,J="",X=this.choices[H];if(H===$&&$>0)B=b1.arrowUp;else if(H===Z-1&&Z<this.choices.length)B=b1.arrowDown;else B=" ";if(X.disabled)z=this.cursor===H?d.gray().underline(X.title):d.strikethrough().gray(X.title),B=(this.cursor===H?d.bold().gray(b1.pointer)+" ":" ")+B;else if(z=this.cursor===H?d.cyan().underline(X.title):X.title,B=(this.cursor===H?d.cyan(b1.pointer)+" ":" ")+B,X.description&&this.cursor===H){if(J=` - ${X.description}`,B.length+z.length+J.length>=this.out.columns||X.description.split(/\r?\n/).length>1)J=`
|
|
61
|
+
`+Q5(X.description,{margin:3,width:this.out.columns})}this.outputText+=`${B} ${z}${d.gray(J)}
|
|
62
|
+
`}}this.out.write(this.outputText)}}D4.exports=K4});var N4=Y((p8,O4)=>{var P1=G(),W5=g(),{style:M4,clear:K5}=q(),{cursor:R4,erase:D5}=M();class F4 extends W5{constructor($={}){super($);this.msg=$.message,this.value=!!$.initial,this.active=$.active||"on",this.inactive=$.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(`
|
|
63
63
|
`),this.close()}submit(){this.done=!0,this.aborted=!1,this.fire(),this.render(),this.out.write(`
|
|
64
|
-
`),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()}_($,Z){if($===" ")this.value=!this.value;else if($==="1")this.value=!0;else if($==="0")this.value=!1;else return this.bell();this.render()}render(){if(this.closed)return;if(this.firstRender)this.out.write(R4.hide);else this.out.write(K5(this.outputText,this.out.columns));super.render(),this.outputText=[M4.symbol(this.done,this.aborted),P1.bold(this.msg),M4.delimiter(this.done),this.value?this.inactive:P1.cyan().underline(this.inactive),P1.gray("/"),this.value?P1.cyan().underline(this.active):this.active].join(" "),this.out.write(D5.line+R4.to(0)+this.outputText)}}O4.exports=F4});var
|
|
64
|
+
`),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()}_($,Z){if($===" ")this.value=!this.value;else if($==="1")this.value=!0;else if($==="0")this.value=!1;else return this.bell();this.render()}render(){if(this.closed)return;if(this.firstRender)this.out.write(R4.hide);else this.out.write(K5(this.outputText,this.out.columns));super.render(),this.outputText=[M4.symbol(this.done,this.aborted),P1.bold(this.msg),M4.delimiter(this.done),this.value?this.inactive:P1.cyan().underline(this.inactive),P1.gray("/"),this.value?P1.cyan().underline(this.active):this.active].join(" "),this.out.write(D5.line+R4.to(0)+this.outputText)}}O4.exports=F4});var P=Y((a8,V4)=>{class T1{constructor({token:$,date:Z,parts:H,locales:z}){this.token=$,this.date=Z||new Date,this.parts=H||[this],this.locales=z||{}}up(){}down(){}next(){let $=this.parts.indexOf(this);return this.parts.find((Z,H)=>H>$&&Z instanceof T1)}setTo($){}prev(){let $=[].concat(this.parts).reverse(),Z=$.indexOf(this);return $.find((H,z)=>z>Z&&H instanceof T1)}toString(){return String(this.date)}}V4.exports=T1});var S4=Y((t8,I4)=>{var G5=P();class A4 extends G5{constructor($={}){super($)}up(){this.date.setHours((this.date.getHours()+12)%24)}down(){this.up()}toString(){let $=this.date.getHours()>12?"pm":"am";return/\A/.test(this.token)?$.toUpperCase():$}}I4.exports=A4});var E4=Y((s8,L4)=>{var M5=P(),R5=($)=>{return $=$%10,$===1?"st":$===2?"nd":$===3?"rd":"th"};class q4 extends M5{constructor($={}){super($)}up(){this.date.setDate(this.date.getDate()+1)}down(){this.date.setDate(this.date.getDate()-1)}setTo($){this.date.setDate(parseInt($.substr(-2)))}toString(){let $=this.date.getDate(),Z=this.date.getDay();return this.token==="DD"?String($).padStart(2,"0"):this.token==="Do"?$+R5($):this.token==="d"?Z+1:this.token==="ddd"?this.locales.weekdaysShort[Z]:this.token==="dddd"?this.locales.weekdays[Z]:$}}L4.exports=q4});var P4=Y((o8,b4)=>{var F5=P();class j4 extends F5{constructor($={}){super($)}up(){this.date.setHours(this.date.getHours()+1)}down(){this.date.setHours(this.date.getHours()-1)}setTo($){this.date.setHours(parseInt($.substr(-2)))}toString(){let $=this.date.getHours();if(/h/.test(this.token))$=$%12||12;return this.token.length>1?String($).padStart(2,"0"):$}}b4.exports=j4});var w4=Y((r8,x4)=>{var O5=P();class T4 extends O5{constructor($={}){super($)}up(){this.date.setMilliseconds(this.date.getMilliseconds()+1)}down(){this.date.setMilliseconds(this.date.getMilliseconds()-1)}setTo($){this.date.setMilliseconds(parseInt($.substr(-this.token.length)))}toString(){return String(this.date.getMilliseconds()).padStart(4,"0").substr(0,this.token.length)}}x4.exports=T4});var _4=Y((e8,k4)=>{var N5=P();class h4 extends N5{constructor($={}){super($)}up(){this.date.setMinutes(this.date.getMinutes()+1)}down(){this.date.setMinutes(this.date.getMinutes()-1)}setTo($){this.date.setMinutes(parseInt($.substr(-2)))}toString(){let $=this.date.getMinutes();return this.token.length>1?String($).padStart(2,"0"):$}}k4.exports=h4});var d4=Y(($H,g4)=>{var V5=P();class f4 extends V5{constructor($={}){super($)}up(){this.date.setMonth(this.date.getMonth()+1)}down(){this.date.setMonth(this.date.getMonth()-1)}setTo($){$=parseInt($.substr(-2))-1,this.date.setMonth($<0?0:$)}toString(){let $=this.date.getMonth(),Z=this.token.length;return Z===2?String($+1).padStart(2,"0"):Z===3?this.locales.monthsShort[$]:Z===4?this.locales.months[$]:String($+1)}}g4.exports=f4});var u4=Y((ZH,v4)=>{var A5=P();class y4 extends A5{constructor($={}){super($)}up(){this.date.setSeconds(this.date.getSeconds()+1)}down(){this.date.setSeconds(this.date.getSeconds()-1)}setTo($){this.date.setSeconds(parseInt($.substr(-2)))}toString(){let $=this.date.getSeconds();return this.token.length>1?String($).padStart(2,"0"):$}}v4.exports=y4});var n4=Y((HH,m4)=>{var I5=P();class c4 extends I5{constructor($={}){super($)}up(){this.date.setFullYear(this.date.getFullYear()+1)}down(){this.date.setFullYear(this.date.getFullYear()-1)}setTo($){this.date.setFullYear($.substr(-4))}toString(){let $=String(this.date.getFullYear()).padStart(4,"0");return this.token.length===2?$.substr(-2):$}}m4.exports=c4});var i4=Y((zH,l4)=>{l4.exports={DatePart:P(),Meridiem:S4(),Day:E4(),Hours:P4(),Milliseconds:w4(),Minutes:_4(),Month:d4(),Seconds:u4(),Year:n4()}});var $$=Y((BH,e4)=>{var U0=G(),S5=g(),{style:p4,clear:a4,figures:q5}=q(),{erase:L5,cursor:t4}=M(),{DatePart:s4,Meridiem:E5,Day:j5,Hours:b5,Milliseconds:P5,Minutes:T5,Month:x5,Seconds:w5,Year:h5}=i4(),k5=/\\(.)|"((?:\\["\\]|[^"])+)"|(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,o4={1:({token:$})=>$.replace(/\\(.)/g,"$1"),2:($)=>new j5($),3:($)=>new x5($),4:($)=>new h5($),5:($)=>new E5($),6:($)=>new b5($),7:($)=>new T5($),8:($)=>new w5($),9:($)=>new P5($)},_5={months:"January,February,March,April,May,June,July,August,September,October,November,December".split(","),monthsShort:"Jan,Feb,Mar,Apr,May,Jun,Jul,Aug,Sep,Oct,Nov,Dec".split(","),weekdays:"Sunday,Monday,Tuesday,Wednesday,Thursday,Friday,Saturday".split(","),weekdaysShort:"Sun,Mon,Tue,Wed,Thu,Fri,Sat".split(",")};class r4 extends S5{constructor($={}){super($);this.msg=$.message,this.cursor=0,this.typed="",this.locales=Object.assign(_5,$.locales),this._date=$.initial||new Date,this.errorMsg=$.error||"Please Enter A Valid Value",this.validator=$.validate||(()=>!0),this.mask=$.mask||"YYYY-MM-DD HH:mm:ss",this.clear=a4("",this.out.columns),this.render()}get value(){return this.date}get date(){return this._date}set date($){if($)this._date.setTime($.getTime())}set mask($){let Z;this.parts=[];while(Z=k5.exec($)){let z=Z.shift(),B=Z.findIndex((J)=>J!=null);this.parts.push(B in o4?o4[B]({token:Z[B]||z,date:this.date,parts:this.parts,locales:this.locales}):Z[B]||z)}let H=this.parts.reduce((z,B)=>{if(typeof B==="string"&&typeof z[z.length-1]==="string")z[z.length-1]+=B;else z.push(B);return z},[]);this.parts.splice(0),this.parts.push(...H),this.reset()}moveCursor($){this.typed="",this.cursor=$,this.fire()}reset(){this.moveCursor(this.parts.findIndex(($)=>$ instanceof s4)),this.fire(),this.render()}exit(){this.abort()}abort(){this.done=this.aborted=!0,this.error=!1,this.fire(),this.render(),this.out.write(`
|
|
65
65
|
`),this.close()}async validate(){let $=await this.validator(this.value);if(typeof $==="string")this.errorMsg=$,$=!1;this.error=!$}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(`
|
|
66
66
|
`),this.close()}up(){this.typed="",this.parts[this.cursor].up(),this.render()}down(){this.typed="",this.parts[this.cursor].down(),this.render()}left(){let $=this.parts[this.cursor].prev();if($==null)return this.bell();this.moveCursor(this.parts.indexOf($)),this.render()}right(){let $=this.parts[this.cursor].next();if($==null)return this.bell();this.moveCursor(this.parts.indexOf($)),this.render()}next(){let $=this.parts[this.cursor].next();this.moveCursor($?this.parts.indexOf($):this.parts.findIndex((Z)=>Z instanceof s4)),this.render()}_($){if(/\d/.test($))this.typed+=$,this.parts[this.cursor].setTo(this.typed),this.render()}render(){if(this.closed)return;if(this.firstRender)this.out.write(t4.hide);else this.out.write(a4(this.outputText,this.out.columns));if(super.render(),this.outputText=[p4.symbol(this.done,this.aborted),U0.bold(this.msg),p4.delimiter(!1),this.parts.reduce(($,Z,H)=>$.concat(H===this.cursor&&!this.done?U0.cyan().underline(Z.toString()):Z),[]).join("")].join(" "),this.error)this.outputText+=this.errorMsg.split(`
|
|
67
67
|
`).reduce(($,Z,H)=>$+`
|
|
68
|
-
${H?" ":
|
|
68
|
+
${H?" ":q5.pointerSmall} ${U0.red().italic(Z)}`,"");this.out.write(L5.line+t4.to(0)+this.outputText)}}e4.exports=r4});var J$=Y((JH,B$)=>{var x1=G(),f5=g(),{cursor:w1,erase:g5}=M(),{style:Y0,figures:d5,clear:Z$,lines:y5}=q(),v5=/[0-9]/,W0=($)=>$!==void 0,H$=($,Z)=>{let H=Math.pow(10,Z);return Math.round($*H)/H};class z$ extends f5{constructor($={}){super($);this.transform=Y0.render($.style),this.msg=$.message,this.initial=W0($.initial)?$.initial:"",this.float=!!$.float,this.round=$.round||2,this.inc=$.increment||1,this.min=W0($.min)?$.min:-1/0,this.max=W0($.max)?$.max:1/0,this.errorMsg=$.error||"Please Enter A Valid Value",this.validator=$.validate||(()=>!0),this.color="cyan",this.value="",this.typed="",this.lastHit=0,this.render()}set value($){if(!$&&$!==0)this.placeholder=!0,this.rendered=x1.gray(this.transform.render(`${this.initial}`)),this._value="";else this.placeholder=!1,this.rendered=this.transform.render(`${H$($,this.round)}`),this._value=H$($,this.round);this.fire()}get value(){return this._value}parse($){return this.float?parseFloat($):parseInt($)}valid($){return $==="-"||$==="."&&this.float||v5.test($)}reset(){this.typed="",this.value="",this.fire(),this.render()}exit(){this.abort()}abort(){let $=this.value;this.value=$!==""?$:this.initial,this.done=this.aborted=!0,this.error=!1,this.fire(),this.render(),this.out.write(`
|
|
69
69
|
`),this.close()}async validate(){let $=await this.validator(this.value);if(typeof $==="string")this.errorMsg=$,$=!1;this.error=!$}async submit(){if(await this.validate(),this.error){this.color="red",this.fire(),this.render();return}let $=this.value;this.value=$!==""?$:this.initial,this.done=!0,this.aborted=!1,this.error=!1,this.fire(),this.render(),this.out.write(`
|
|
70
70
|
`),this.close()}up(){if(this.typed="",this.value==="")this.value=this.min-this.inc;if(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;if(this.value<=this.min)return this.bell();this.value-=this.inc,this.color="cyan",this.fire(),this.render()}delete(){let $=this.value.toString();if($.length===0)return this.bell();if(this.value=this.parse($=$.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()}_($,Z){if(!this.valid($))return this.bell();let H=Date.now();if(H-this.lastHit>1000)this.typed="";if(this.typed+=$,this.lastHit=H,this.color="cyan",$===".")return this.fire();if(this.value=Math.min(this.parse(this.typed),this.max),this.value>this.max)this.value=this.max;if(this.value<this.min)this.value=this.min;this.fire(),this.render()}render(){if(this.closed)return;if(!this.firstRender){if(this.outputError)this.out.write(w1.down(y5(this.outputError,this.out.columns)-1)+Z$(this.outputError,this.out.columns));this.out.write(Z$(this.outputText,this.out.columns))}if(super.render(),this.outputError="",this.outputText=[Y0.symbol(this.done,this.aborted),x1.bold(this.msg),Y0.delimiter(this.done),!this.done||!this.done&&!this.placeholder?x1[this.color]().underline(this.rendered):this.rendered].join(" "),this.error)this.outputError+=this.errorMsg.split(`
|
|
71
71
|
`).reduce(($,Z,H)=>$+`
|
|
72
|
-
${H?" ":d5.pointerSmall} ${x1.red().italic(Z)}`,"");this.out.write(g5.line+w1.to(0)+this.outputText+w1.save+this.outputError+w1.restore)}}B$.exports=z$});var K0=Y((XH,U$)=>{var
|
|
72
|
+
${H?" ":d5.pointerSmall} ${x1.red().italic(Z)}`,"");this.out.write(g5.line+w1.to(0)+this.outputText+w1.save+this.outputError+w1.restore)}}B$.exports=z$});var K0=Y((XH,U$)=>{var T=G(),{cursor:u5}=M(),c5=g(),{clear:X$,figures:n,style:C$,wrap:m5,entriesToDisplay:n5}=q();class Q$ extends c5{constructor($={}){super($);if(this.msg=$.message,this.cursor=$.cursor||0,this.scrollIndex=$.cursor||0,this.hint=$.hint||"",this.warn=$.warn||"- This option is disabled -",this.minSelected=$.min,this.showMinError=!1,this.maxChoices=$.max,this.instructions=$.instructions,this.optionsPerPage=$.optionsPerPage||10,this.value=$.choices.map((Z,H)=>{if(typeof Z==="string")Z={title:Z,value:H};return{title:Z&&(Z.title||Z.value||Z),description:Z&&Z.description,value:Z&&(Z.value===void 0?H:Z.value),selected:Z&&Z.selected,disabled:Z&&Z.disabled}}),this.clear=X$("",this.out.columns),!$.overrideRender)this.render()}reset(){this.value.map(($)=>!$.selected),this.cursor=0,this.fire(),this.render()}selected(){return this.value.filter(($)=>$.selected)}exit(){this.abort()}abort(){this.done=this.aborted=!0,this.fire(),this.render(),this.out.write(`
|
|
73
73
|
`),this.close()}submit(){let $=this.value.filter((Z)=>Z.selected);if(this.minSelected&&$.length<this.minSelected)this.showMinError=!0,this.render();else this.done=!0,this.aborted=!1,this.fire(),this.render(),this.out.write(`
|
|
74
74
|
`),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(){if(this.cursor===0)this.cursor=this.value.length-1;else this.cursor--;this.render()}down(){if(this.cursor===this.value.length-1)this.cursor=0;else this.cursor++;this.render()}left(){this.value[this.cursor].selected=!1,this.render()}right(){if(this.value.filter(($)=>$.selected).length>=this.maxChoices)return this.bell();this.value[this.cursor].selected=!0,this.render()}handleSpaceToggle(){let $=this.value[this.cursor];if($.selected)$.selected=!1,this.render();else if($.disabled||this.value.filter((Z)=>Z.selected).length>=this.maxChoices)return this.bell();else $.selected=!0,this.render()}toggleAll(){if(this.maxChoices!==void 0||this.value[this.cursor].disabled)return this.bell();let $=!this.value[this.cursor].selected;this.value.filter((Z)=>!Z.disabled).forEach((Z)=>Z.selected=$),this.render()}_($,Z){if($===" ")this.handleSpaceToggle();else if($==="a")this.toggleAll();else return this.bell()}renderInstructions(){if(this.instructions===void 0||this.instructions){if(typeof this.instructions==="string")return this.instructions;return`
|
|
75
75
|
Instructions:
|
|
76
|
-
${
|
|
77
|
-
${
|
|
76
|
+
${n.arrowUp}/${n.arrowDown}: Highlight option
|
|
77
|
+
${n.arrowLeft}/${n.arrowRight}/[space]: Toggle selection
|
|
78
78
|
`+(this.maxChoices===void 0?` a: Toggle all
|
|
79
|
-
`:"")+" enter/return: Complete answer"}return""}renderOption($,Z,H,z){let B=(Z.selected?
|
|
80
|
-
`+m5(Z.description,{margin:B.length,width:this.out.columns})}return B+J+
|
|
79
|
+
`:"")+" enter/return: Complete answer"}return""}renderOption($,Z,H,z){let B=(Z.selected?T.green(n.radioOn):n.radioOff)+" "+z+" ",J,X;if(Z.disabled)J=$===H?T.gray().underline(Z.title):T.strikethrough().gray(Z.title);else if(J=$===H?T.cyan().underline(Z.title):Z.title,$===H&&Z.description){if(X=` - ${Z.description}`,B.length+J.length+X.length>=this.out.columns||Z.description.split(/\r?\n/).length>1)X=`
|
|
80
|
+
`+m5(Z.description,{margin:B.length,width:this.out.columns})}return B+J+T.gray(X||"")}paginateOptions($){if($.length===0)return T.red("No matches for this query.");let{startIndex:Z,endIndex:H}=n5(this.cursor,$.length,this.optionsPerPage),z,B=[];for(let J=Z;J<H;J++){if(J===Z&&Z>0)z=n.arrowUp;else if(J===H-1&&H<$.length)z=n.arrowDown;else z=" ";B.push(this.renderOption(this.cursor,$[J],J,z))}return`
|
|
81
81
|
`+B.join(`
|
|
82
|
-
`)}renderOptions($){if(!this.done)return this.paginateOptions($);return""}renderDoneOrInstructions(){if(this.done)return this.value.filter((Z)=>Z.selected).map((Z)=>Z.title).join(", ");let $=[
|
|
82
|
+
`)}renderOptions($){if(!this.done)return this.paginateOptions($);return""}renderDoneOrInstructions(){if(this.done)return this.value.filter((Z)=>Z.selected).map((Z)=>Z.title).join(", ");let $=[T.gray(this.hint),this.renderInstructions()];if(this.value[this.cursor].disabled)$.push(T.yellow(this.warn));return $.join(" ")}render(){if(this.closed)return;if(this.firstRender)this.out.write(u5.hide);super.render();let $=[C$.symbol(this.done,this.aborted),T.bold(this.msg),C$.delimiter(!1),this.renderDoneOrInstructions()].join(" ");if(this.showMinError)$+=T.red(`You must select a minimum of ${this.minSelected} choices.`),this.showMinError=!1;$+=this.renderOptions(this.value),this.out.write(this.clear+$),this.clear=X$($,this.out.columns)}}U$.exports=Q$});var M$=Y((CH,G$)=>{var Q1=G(),l5=g(),{erase:i5,cursor:Y$}=M(),{style:D0,clear:W$,figures:G0,wrap:p5,entriesToDisplay:a5}=q(),K$=($,Z)=>$[Z]&&($[Z].value||$[Z].title||$[Z]),t5=($,Z)=>$[Z]&&($[Z].title||$[Z].value||$[Z]),s5=($,Z)=>{let H=$.findIndex((z)=>z.value===Z||z.title===Z);return H>-1?H:void 0};class D$ extends l5{constructor($={}){super($);this.msg=$.message,this.suggest=$.suggest,this.choices=$.choices,this.initial=typeof $.initial==="number"?$.initial:s5($.choices,$.initial),this.select=this.initial||$.cursor||0,this.i18n={noMatches:$.noMatches||"no matches found"},this.fallback=$.fallback||this.initial,this.clearFirst=$.clearFirst||!1,this.suggestions=[],this.input="",this.limit=$.limit||10,this.cursor=0,this.transform=D0.render($.style),this.scale=this.transform.scale,this.render=this.render.bind(this),this.complete=this.complete.bind(this),this.clear=W$("",this.out.columns),this.complete(this.render),this.render()}set fallback($){this._fb=Number.isSafeInteger(parseInt($))?parseInt($):$}get fallback(){let $;if(typeof this._fb==="number")$=this.choices[this._fb];else if(typeof this._fb==="string")$={title:this._fb};return $||this._fb||{title:this.i18n.noMatches}}moveSelect($){if(this.select=$,this.suggestions.length>0)this.value=K$(this.suggestions,$);else this.value=this.fallback.value;this.fire()}async complete($){let Z=this.completing=this.suggest(this.input,this.choices),H=await Z;if(this.completing!==Z)return;this.suggestions=H.map((B,J,X)=>({title:t5(X,J),value:K$(X,J),description:B.description})),this.completing=!1;let z=Math.max(H.length-1,0);this.moveSelect(Math.min(z,this.select)),$&&$()}reset(){this.input="",this.complete(()=>{this.moveSelect(this.initial!==void 0?this.initial:0),this.render()}),this.render()}exit(){if(this.clearFirst&&this.input.length>0)this.reset();else this.done=this.exited=!0,this.aborted=!1,this.fire(),this.render(),this.out.write(`
|
|
83
83
|
`),this.close()}abort(){this.done=this.aborted=!0,this.exited=!1,this.fire(),this.render(),this.out.write(`
|
|
84
84
|
`),this.close()}submit(){this.done=!0,this.aborted=this.exited=!1,this.fire(),this.render(),this.out.write(`
|
|
85
85
|
`),this.close()}_($,Z){let H=this.input.slice(0,this.cursor),z=this.input.slice(this.cursor);this.input=`${H}${$}${z}`,this.cursor=H.length+1,this.complete(this.render),this.render()}delete(){if(this.cursor===0)return this.bell();let $=this.input.slice(0,this.cursor-1),Z=this.input.slice(this.cursor);this.input=`${$}${Z}`,this.complete(this.render),this.cursor=this.cursor-1,this.render()}deleteForward(){if(this.cursor*this.scale>=this.rendered.length)return this.bell();let $=this.input.slice(0,this.cursor),Z=this.input.slice(this.cursor+1);this.input=`${$}${Z}`,this.complete(this.render),this.render()}first(){this.moveSelect(0),this.render()}last(){this.moveSelect(this.suggestions.length-1),this.render()}up(){if(this.select===0)this.moveSelect(this.suggestions.length-1);else this.moveSelect(this.select-1);this.render()}down(){if(this.select===this.suggestions.length-1)this.moveSelect(0);else this.moveSelect(this.select+1);this.render()}next(){if(this.select===this.suggestions.length-1)this.moveSelect(0);else this.moveSelect(this.select+1);this.render()}nextPage(){this.moveSelect(Math.min(this.select+this.limit,this.suggestions.length-1)),this.render()}prevPage(){this.moveSelect(Math.max(this.select-this.limit,0)),this.render()}left(){if(this.cursor<=0)return this.bell();this.cursor=this.cursor-1,this.render()}right(){if(this.cursor*this.scale>=this.rendered.length)return this.bell();this.cursor=this.cursor+1,this.render()}renderOption($,Z,H,z){let B,J=H?G0.arrowUp:z?G0.arrowDown:" ",X=Z?Q1.cyan().underline($.title):$.title;if(J=(Z?Q1.cyan(G0.pointer)+" ":" ")+J,$.description){if(B=` - ${$.description}`,J.length+X.length+B.length>=this.out.columns||$.description.split(/\r?\n/).length>1)B=`
|
|
86
86
|
`+p5($.description,{margin:3,width:this.out.columns})}return J+" "+X+Q1.gray(B||"")}render(){if(this.closed)return;if(this.firstRender)this.out.write(Y$.hide);else this.out.write(W$(this.outputText,this.out.columns));super.render();let{startIndex:$,endIndex:Z}=a5(this.select,this.choices.length,this.limit);if(this.outputText=[D0.symbol(this.done,this.aborted,this.exited),Q1.bold(this.msg),D0.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 H=this.suggestions.slice($,Z).map((z,B)=>this.renderOption(z,this.select===B+$,B===0&&$>0,B+$===Z-1&&Z<this.choices.length)).join(`
|
|
87
87
|
`);this.outputText+=`
|
|
88
|
-
`+(H||Q1.gray(this.fallback.title))}this.out.write(i5.line+Y$.to(0)+this.outputText)}}G$.exports=D$});var V$=Y((QH,N$)=>{var
|
|
88
|
+
`+(H||Q1.gray(this.fallback.title))}this.out.write(i5.line+Y$.to(0)+this.outputText)}}G$.exports=D$});var V$=Y((QH,N$)=>{var y=G(),{cursor:o5}=M(),r5=K0(),{clear:R$,style:F$,figures:o}=q();class O$ extends r5{constructor($={}){$.overrideRender=!0;super($);this.inputValue="",this.clear=R$("",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(){if(this.cursor===0)this.cursor=this.filteredOptions.length-1;else this.cursor--;this.render()}down(){if(this.cursor===this.filteredOptions.length-1)this.cursor=0;else this.cursor++;this.render()}left(){this.filteredOptions[this.cursor].selected=!1,this.render()}right(){if(this.value.filter(($)=>$.selected).length>=this.maxChoices)return this.bell();this.filteredOptions[this.cursor].selected=!0,this.render()}delete(){if(this.inputValue.length)this.inputValue=this.inputValue.substr(0,this.inputValue.length-1),this.updateFilteredOptions()}updateFilteredOptions(){let $=this.filteredOptions[this.cursor];this.filteredOptions=this.value.filter((H)=>{if(this.inputValue){if(typeof H.title==="string"){if(H.title.toLowerCase().includes(this.inputValue.toLowerCase()))return!0}if(typeof H.value==="string"){if(H.value.toLowerCase().includes(this.inputValue.toLowerCase()))return!0}return!1}return!0});let Z=this.filteredOptions.findIndex((H)=>H===$);this.cursor=Z<0?0:Z,this.render()}handleSpaceToggle(){let $=this.filteredOptions[this.cursor];if($.selected)$.selected=!1,this.render();else if($.disabled||this.value.filter((Z)=>Z.selected).length>=this.maxChoices)return this.bell();else $.selected=!0,this.render()}handleInputChange($){this.inputValue=this.inputValue+$,this.updateFilteredOptions()}_($,Z){if($===" ")this.handleSpaceToggle();else this.handleInputChange($)}renderInstructions(){if(this.instructions===void 0||this.instructions){if(typeof this.instructions==="string")return this.instructions;return`
|
|
89
89
|
Instructions:
|
|
90
90
|
${o.arrowUp}/${o.arrowDown}: Highlight option
|
|
91
91
|
${o.arrowLeft}/${o.arrowRight}/[space]: Toggle selection
|
|
92
92
|
[a,b,c]/delete: Filter choices
|
|
93
93
|
enter/return: Complete answer
|
|
94
94
|
`}return""}renderCurrentInput(){return`
|
|
95
|
-
Filtered results for: ${this.inputValue?this.inputValue:
|
|
96
|
-
`}renderOption($,Z,H){let z;if(Z.disabled)z=$===H?
|
|
95
|
+
Filtered results for: ${this.inputValue?this.inputValue:y.gray("Enter something to filter")}
|
|
96
|
+
`}renderOption($,Z,H){let z;if(Z.disabled)z=$===H?y.gray().underline(Z.title):y.strikethrough().gray(Z.title);else z=$===H?y.cyan().underline(Z.title):Z.title;return(Z.selected?y.green(o.radioOn):o.radioOff)+" "+z}renderDoneOrInstructions(){if(this.done)return this.value.filter((Z)=>Z.selected).map((Z)=>Z.title).join(", ");let $=[y.gray(this.hint),this.renderInstructions(),this.renderCurrentInput()];if(this.filteredOptions.length&&this.filteredOptions[this.cursor].disabled)$.push(y.yellow(this.warn));return $.join(" ")}render(){if(this.closed)return;if(this.firstRender)this.out.write(o5.hide);super.render();let $=[F$.symbol(this.done,this.aborted),y.bold(this.msg),F$.delimiter(!1),this.renderDoneOrInstructions()].join(" ");if(this.showMinError)$+=y.red(`You must select a minimum of ${this.minSelected} choices.`),this.showMinError=!1;$+=this.renderOptions(this.filteredOptions),this.out.write(this.clear+$),this.clear=R$($,this.out.columns)}}N$.exports=O$});var E$=Y((UH,L$)=>{var A$=G(),e5=g(),{style:I$,clear:$6}=q(),{erase:Z6,cursor:S$}=M();class q$ extends e5{constructor($={}){super($);this.msg=$.message,this.value=$.initial,this.initialValue=!!$.initial,this.yesMsg=$.yes||"yes",this.yesOption=$.yesOption||"(Y/n)",this.noMsg=$.no||"no",this.noOption=$.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(`
|
|
97
97
|
`),this.close()}submit(){this.value=this.value||!1,this.done=!0,this.aborted=!1,this.fire(),this.render(),this.out.write(`
|
|
98
|
-
`),this.close()}_($,Z){if($.toLowerCase()==="y")return this.value=!0,this.submit();if($.toLowerCase()==="n")return this.value=!1,this.submit();return this.bell()}render(){if(this.closed)return;if(this.firstRender)this.out.write(S$.hide);else this.out.write($6(this.outputText,this.out.columns));super.render(),this.outputText=[I$.symbol(this.done,this.aborted),A$.bold(this.msg),I$.delimiter(this.done),this.done?this.value?this.yesMsg:this.noMsg:A$.gray(this.initialValue?this.yesOption:this.noOption)].join(" "),this.out.write(Z6.line+S$.to(0)+this.outputText)}}
|
|
98
|
+
`),this.close()}_($,Z){if($.toLowerCase()==="y")return this.value=!0,this.submit();if($.toLowerCase()==="n")return this.value=!1,this.submit();return this.bell()}render(){if(this.closed)return;if(this.firstRender)this.out.write(S$.hide);else this.out.write($6(this.outputText,this.out.columns));super.render(),this.outputText=[I$.symbol(this.done,this.aborted),A$.bold(this.msg),I$.delimiter(this.done),this.done?this.value?this.yesMsg:this.noMsg:A$.gray(this.initialValue?this.yesOption:this.noOption)].join(" "),this.out.write(Z6.line+S$.to(0)+this.outputText)}}L$.exports=q$});var b$=Y((YH,j$)=>{j$.exports={TextPrompt:U4(),SelectPrompt:G4(),TogglePrompt:N4(),DatePrompt:$$(),NumberPrompt:J$(),MultiselectPrompt:K0(),AutocompletePrompt:M$(),AutocompleteMultiselectPrompt:V$(),ConfirmPrompt:E$()}});var T$=Y((P$)=>{var A=P$,H6=b$(),h1=($)=>$;function x($,Z,H={}){return new Promise((z,B)=>{let J=new H6[$](Z),X=H.onAbort||h1,C=H.onSubmit||h1,Q=H.onExit||h1;J.on("state",Z.onState||h1),J.on("submit",(U)=>z(C(U))),J.on("exit",(U)=>z(Q(U))),J.on("abort",(U)=>B(X(U)))})}A.text=($)=>x("TextPrompt",$);A.password=($)=>{return $.style="password",A.text($)};A.invisible=($)=>{return $.style="invisible",A.text($)};A.number=($)=>x("NumberPrompt",$);A.date=($)=>x("DatePrompt",$);A.confirm=($)=>x("ConfirmPrompt",$);A.list=($)=>{let Z=$.separator||",";return x("TextPrompt",$,{onSubmit:(H)=>H.split(Z).map((z)=>z.trim())})};A.toggle=($)=>x("TogglePrompt",$);A.select=($)=>x("SelectPrompt",$);A.multiselect=($)=>{$.choices=[].concat($.choices||[]);let Z=(H)=>H.filter((z)=>z.selected).map((z)=>z.value);return x("MultiselectPrompt",$,{onAbort:Z,onSubmit:Z})};A.autocompleteMultiselect=($)=>{$.choices=[].concat($.choices||[]);let Z=(H)=>H.filter((z)=>z.selected).map((z)=>z.value);return x("AutocompleteMultiselectPrompt",$,{onAbort:Z,onSubmit:Z})};var z6=($,Z)=>Promise.resolve(Z.filter((H)=>H.title.slice(0,$.length).toLowerCase()===$.toLowerCase()));A.autocomplete=($)=>{return $.suggest=$.suggest||z6,$.choices=[].concat($.choices||[]),x("AutocompletePrompt",$)}});var h$=Y((KH,w$)=>{var M0=T$(),B6=["suggest","format","onState","validate","onRender","type"],x$=()=>{};async function l($=[],{onSubmit:Z=x$,onCancel:H=x$}={}){let z={},B=l._override||{};$=[].concat($);let J,X,C,Q,U,N,W=async(R,O,L=!1)=>{if(!L&&R.validate&&R.validate(O)!==!0)return;return R.format?await R.format(O,z):O};for(X of $){if({name:Q,type:U}=X,typeof U==="function")U=await U(J,{...z},X),X.type=U;if(!U)continue;for(let R in X){if(B6.includes(R))continue;let O=X[R];X[R]=typeof O==="function"?await O(J,{...z},N):O}if(N=X,typeof X.message!=="string")throw Error("prompt message is required");if({name:Q,type:U}=X,M0[U]===void 0)throw Error(`prompt type (${U}) is not defined`);if(B[X.name]!==void 0){if(J=await W(X,B[X.name]),J!==void 0){z[Q]=J;continue}}try{J=l._injected?J6(l._injected,X.initial):await M0[U](X),z[Q]=J=await W(X,J,!0),C=await Z(X,J,z)}catch(R){C=!await H(X,z)}if(C)return z}return z}function J6($,Z){let H=$.shift();if(H instanceof Error)throw H;return H===void 0?Z:H}function X6($){l._injected=(l._injected||[]).concat($)}function C6($){l._override=Object.assign({},$)}w$.exports=Object.assign(l,{prompt:l,prompts:M0,inject:X6,override:C6})});var _$=Y((DH,k$)=>{function Q6($){$=(Array.isArray($)?$:$.split(".")).map(Number);let Z=0,H=process.versions.node.split(".").map(Number);for(;Z<$.length;Z++){if(H[Z]>$[Z])return!1;if($[Z]>H[Z])return!0}return!1}k$.exports=Q6("8.6.0")?u2():h$()});var F=y1(u1(),1);import{readFile as d6}from"node:fs/promises";import{basename as a$}from"node:path";import{fileURLToPath as y6}from"node:url";import{parseArgs as v6}from"node:util";function c1($){return $==="bun"||$==="npm"||$==="pnpm"||$==="yarn"}function M1(){let $=process.env.npm_config_user_agent;if(!$)return null;let Z=$.split(" ")[0];if(!Z)return null;let H=Z.split("/")[0];return c1(H)?H:null}function m1($){return $==="yarn"?"yarn":`${$} install`}function S0($,Z){if($==="npm")return`npm run ${Z}`;return`${$} ${Z}`}var i$=y1(u1(),1),U1=y1(_$(),1);import{spawn as F6}from"node:child_process";import{mkdir as O6,mkdtemp as N6,readdir as V6,rename as A6,rm as I6,writeFile as S6}from"node:fs/promises";import{basename as q6,dirname as L6,isAbsolute as E6,join as v$,resolve as j6}from"node:path";import{mkdir as U6,readdir as Y6,readFile as W6,writeFile as K6}from"node:fs/promises";import{dirname as f$,join as R0,relative as D6}from"node:path";import{fileURLToPath as G6}from"node:url";function g$($,Z){if($.length===0)throw Error("assembleProviders: at least one provider required");let H=$.map((W)=>{let R=Z.find((O)=>O.key===W);if(!R)throw Error(`Unknown provider "${W}". Available: ${Z.map((O)=>O.key).join(", ")}`);return R}),z=H.some((W)=>W.key!==I),B=[...H.filter((W)=>W.key===I),...Z.filter((W)=>W.key!==I).filter((W)=>H.some((R)=>R.key===W.key))],J=['import { Spectrum } from "spectrum-ts";'],X=[],C=[];for(let W of B)J.push(`import { ${W.import} } from "${W.path}";`),X.push(` // ${W.label}`),X.push(` ${W.import}.config(),`),C.push(W.label);let Q=J.join(`
|
|
99
99
|
`),U=[];if(z)U.push(" projectId: process.env.PROJECT_ID!,"),U.push(" projectSecret: process.env.PROJECT_SECRET!,");U.push(" providers: ["),U.push(...X),U.push(" ],");let N=z?["PROJECT_ID","PROJECT_SECRET"]:[];return{importsBlock:Q,spectrumConfigBody:U.join(`
|
|
100
100
|
`),topLevelEnvVars:N,providerEnvVars:[],needsEnvFile:z,providersHuman:C.join(", ")}}var M6=/\{\{([a-zA-Z][a-zA-Z0-9]*)\}\}/g;function R6($,Z){return $.replaceAll(M6,(H,z)=>{if(!(z in Z))throw Error(`Unknown template token: {{${z}}}`);return Z[z]??""})}function d$(){return R0(f$(G6(import.meta.url)),"..","templates","base")}async function y$($,Z,H,z){let B=await Y6($,{withFileTypes:!0,recursive:!0});for(let J of B){if(!J.isFile())continue;let X=R0(J.parentPath,J.name),C=D6($,X);if(!z.emitEnvFile&&C==="env.example.tmpl")continue;let Q=C==="_gitignore"?".gitignore":C;if(Q.endsWith(".tmpl"))Q=Q.slice(0,-5);if(Q==="env.example")Q=".env.example";let U=R0(Z,Q),N=await W6(X,"utf8"),W=J.name.endsWith(".tmpl")||C==="_gitignore"?R6(N,H):N;await U6(f$(U),{recursive:!0}),await K6(U,W)}}var I="terminal";class _1 extends Error{name="TargetExistsError"}class f1 extends Error{name="VersionResolutionError"}class g1 extends Error{name="InstallError";exitCode;constructor($,Z){super($);this.exitCode=Z}}var F0="^0.0.0",u$="https://unpkg.com/spectrum-ts/manifest.json",c$=[{key:"imessage",import:"imessage",path:"spectrum-ts/providers/imessage",label:"iMessage"},{key:"slack",import:"slack",path:"spectrum-ts/providers/slack",label:"Slack"},{key:"terminal",import:"terminal",path:"spectrum-ts/providers/terminal",label:"Terminal"},{key:"whatsapp-business",import:"whatsappBusiness",path:"spectrum-ts/providers/whatsapp-business",label:"WhatsApp Business"}];function b6($){if(typeof $!=="object"||$===null)return!1;let Z=$;return typeof Z.key==="string"&&typeof Z.import==="string"&&typeof Z.path==="string"&&typeof Z.label==="string"}async function m$($){try{let Z=await fetch(u$,{headers:{accept:"application/json"}});if(!Z.ok)throw Error(`unpkg responded ${Z.status}`);let H=await Z.json();if(!Array.isArray(H))throw Error("manifest is not an array");for(let z of H)if(!b6(z))throw Error(`malformed manifest entry: ${JSON.stringify(z)}`);return H}catch(Z){return $?.warn(`Could not fetch spectrum-ts manifest from ${u$} (${Z instanceof Error?Z.message:String(Z)}); using bundled fallback (${c$.length} providers).`),c$}}var P6={step:($)=>process.stderr.write(`${$}
|
|
101
101
|
`),warn:($)=>process.stderr.write(`warn: ${$}
|
|
102
|
-
`),stream:($)=>process.stderr.write($)};async function n$($){let Z=$.logger??P6;if($.providers.length===0)throw Error("scaffold: providers must include at least one entry");let H=E6($.targetDir)?$.targetDir:j6(process.cwd(),$.targetDir),z=$.name??
|
|
103
|
-
`)
|
|
104
|
-
`),providersHuman:z.providersHuman,pmInstallCmd:m1(B),pmStartCmd:S0(B,"start"),envSetupBlock:k6(z.topLevelEnvVars,z.providerEnvVars)}}function k6($,Z){if($.length===0&&Z.length===0)return"";let H=["## Environment","","Before running,
|
|
102
|
+
`),stream:($)=>process.stderr.write($)};async function n$($){let Z=$.logger??P6;if($.providers.length===0)throw Error("scaffold: providers must include at least one entry");let H=E6($.targetDir)?$.targetDir:j6(process.cwd(),$.targetDir),z=$.name??q6(H),B=$.packageManager??M1()??"bun";if(await T6(H))throw new _1(`Target directory is not empty: ${H}`);Z.step("Resolving spectrum-ts version…");let J=await w6($.resolveSpectrumTsVersion,Z),X=g$($.providers,$.manifest),C=h6({name:z,spectrumTsVersion:J,assembly:X,pm:B}),Q=L6(H);await O6(Q,{recursive:!0});let U=await N6(v$(Q,".create-spectrum-project-")),N=!1;try{if(Z.step("Copying template…"),await y$(d$(),U,C,{emitEnvFile:X.needsEnvFile}),X.needsEnvFile){let O=[];for(let L of X.topLevelEnvVars)if(L==="PROJECT_ID"&&$.credentials)O.push(`PROJECT_ID=${$.credentials.projectId}`);else if(L==="PROJECT_SECRET"&&$.credentials)O.push(`PROJECT_SECRET=${$.credentials.projectSecret}`);else O.push(`${L}=`);for(let L of X.providerEnvVars)O.push(`${L}=`);await S6(v$(U,".env"),O.join(`
|
|
103
|
+
`))}await A6(U,H),N=!0}finally{if(!N)await I6(U,{recursive:!0,force:!0})}let W=!1;if($.install!==!1)Z.step(`Running ${m1(B)}…`),await _6(B,H,Z),W=!0;let R=!1;if($.git!==!1)Z.step("Initializing git…"),R=await f6(H,Z);return{targetDir:H,spectrumTsVersion:J,needsEnvFile:X.needsEnvFile,steps:{copied:!0,installed:W,gitInitialized:R}}}async function T6($){try{return(await V6($)).length>0}catch(Z){if(Z.code==="ENOENT")return!1;throw Z}}var x6="https://registry.npmjs.org/spectrum-ts";async function w6($,Z){try{if($)return await $();let H=await fetch(x6,{headers:{accept:"application/json"}});if(!H.ok)throw Error(`registry responded ${H.status}`);let B=(await H.json())["dist-tags"]?.latest;if(!B)throw Error("registry response missing dist-tags.latest");return`^${B}`}catch(H){if(Z.warn(`Could not resolve spectrum-ts version from npm (${H instanceof Error?H.message:String(H)}); using bundled fallback ${F0}.`),!F0)throw new f1("No spectrum-ts fallback version available");return F0}}function h6($){let{name:Z,spectrumTsVersion:H,assembly:z,pm:B}=$,J=[];if(z.topLevelEnvVars.length>0){J.push("# Top-level Spectrum credentials (from your Photon dashboard).");for(let X of z.topLevelEnvVars)J.push(`${X}=`)}if(z.providerEnvVars.length>0){if(J.length>0)J.push("");J.push("# WhatsApp Business (from Meta for Developers).");for(let X of z.providerEnvVars)J.push(`${X}=`)}return{name:Z,spectrumTsVersion:H,importsBlock:z.importsBlock,spectrumConfigBody:z.spectrumConfigBody,envBlock:J.join(`
|
|
104
|
+
`),providersHuman:z.providersHuman,pmInstallCmd:m1(B),pmStartCmd:S0(B,"start"),envSetupBlock:k6(z.topLevelEnvVars,z.providerEnvVars)}}function k6($,Z){if($.length===0&&Z.length===0)return"";let H=["## Environment","","Before running, open `.env` and fill in the values:",""];if($.length>0){H.push("From your project Settings on the [Photon dashboard](https://app.photon.codes):"),H.push("");for(let z of $)H.push(`- \`${z}\``);H.push("")}if(Z.length>0){H.push("From [Meta for Developers](https://developers.facebook.com) (WhatsApp Business):"),H.push("");for(let z of Z)H.push(`- \`${z}\``);H.push("")}return`${H.join(`
|
|
105
105
|
`)}
|
|
106
106
|
`}function k1($,Z,H,z){return new Promise((B,J)=>{let C=F6($,Z,{...H,stdio:z?["ignore","pipe","pipe"]:["ignore","ignore","ignore"]});if(z)C.stdout?.setEncoding("utf8"),C.stdout?.on("data",z),C.stderr?.setEncoding("utf8"),C.stderr?.on("data",z);C.once("error",J),C.once("close",(Q)=>B(Q??-1))})}async function _6($,Z,H){let z=$==="yarn"?[]:["install"],B=await k1($,z,{cwd:Z},(J)=>H.stream(J));if(B!==0)throw new g1(`\`${$} ${z.join(" ")}\` exited with code ${B}`,B)}async function f6($,Z){try{if(await k1("git",["init","-b","main"],{cwd:$})!==0)return Z.warn("git init failed; skipping git setup."),!1;if(await k1("git",["add","."],{cwd:$})!==0)return Z.warn("git add failed; skipping initial commit."),!1;let H={...process.env,GIT_AUTHOR_NAME:process.env.GIT_AUTHOR_NAME??"create-spectrum-project",GIT_AUTHOR_EMAIL:process.env.GIT_AUTHOR_EMAIL??"noreply@photon.codes",GIT_COMMITTER_NAME:process.env.GIT_COMMITTER_NAME??"create-spectrum-project",GIT_COMMITTER_EMAIL:process.env.GIT_COMMITTER_EMAIL??"noreply@photon.codes"};if(await k1("git",["commit","-m","Initial commit from create-spectrum-project","--no-verify"],{cwd:$,env:H})!==0)return Z.warn("git commit failed; repo initialized but no initial commit."),!1;return!0}catch(H){return Z.warn(`git not available: ${H instanceof Error?H.message:String(H)}`),!1}}var d1=()=>{process.stderr.write(`
|
|
107
107
|
${i$.default.dim("Cancelled.")}
|
|
108
|
-
`),process.exit(130)};async function p$($,Z){let H=$.targetDir??(await U1.default({type:"text",name:"value",message:"Project directory",initial:"my-spectrum-app"},{onCancel:d1})).value,z=$.providers??await g6(Z),B=M1()??"bun",J=["bun","npm","pnpm","yarn"],X=$.packageManager??(await U1.default({type:"select",name:"value",message:"Package manager",choices:J.map((C)=>({title:C,value:C})),initial:J.indexOf(B)},{onCancel:d1})).value;return{targetDir:H,providers:z,packageManager:X,manifest:Z,install:$.install??!0,git:$.git??!0}}async function g6($){let Z=$.find((B)=>B.key===I),H=$.filter((B)=>B.key!==I);if(!Z)return l$(H);if(H.length===0)return[Z.key];let{kind:z}=await U1.default({type:"select",name:"kind",message:"Project kind",choices:[{title:
|
|
108
|
+
`),process.exit(130)};async function p$($,Z){let H=$.targetDir??(await U1.default({type:"text",name:"value",message:"Project directory",initial:"my-spectrum-app"},{onCancel:d1})).value,z=$.providers??await g6(Z),B=M1()??"bun",J=["bun","npm","pnpm","yarn"],X=$.packageManager??(await U1.default({type:"select",name:"value",message:"Package manager",choices:J.map((C)=>({title:C,value:C})),initial:J.indexOf(B)},{onCancel:d1})).value;return{targetDir:H,providers:z,packageManager:X,manifest:Z,install:$.install??!0,git:$.git??!0}}async function g6($){let Z=$.find((B)=>B.key===I),H=$.filter((B)=>B.key!==I);if(!Z)return l$(H);if(H.length===0)return[Z.key];let{kind:z}=await U1.default({type:"select",name:"kind",message:"Project kind",choices:[{title:"Platforms",description:"pick one or more messaging interfaces",value:"platform"},{title:Z.label,description:"local dev / test TUI, no credentials",value:"terminal"}],initial:0},{onCancel:d1});if(z==="terminal")return[Z.key];return l$(H)}async function l$($){let{values:Z}=await U1.default({type:"multiselect",name:"values",message:"Which interfaces (space to toggle, enter to confirm)",instructions:!1,choices:$.map((H,z)=>({title:H.label,value:H.key,selected:z===0})),min:1},{onCancel:d1});return Z}var v={ok:F.default.green("✓"),err:F.default.red("✗"),arrow:F.default.dim("→"),dot:F.default.dim("·")},u6=new Set(["slack"]);function c6($){return $.filter((Z)=>!u6.has(Z.key))}async function m6(){let{values:$,positionals:Z}=v6({args:process.argv.slice(2),options:{providers:{type:"string"},pm:{type:"string"},install:{type:"boolean",default:!0},"no-install":{type:"boolean"},git:{type:"boolean",default:!0},"no-git":{type:"boolean"},yes:{type:"boolean",short:"y"},verbose:{type:"boolean"},help:{type:"boolean",short:"h"},version:{type:"boolean"}},allowPositionals:!0,strict:!0}),H=await s6();if($.help)return t6(),0;if($.version)return process.stdout.write(`create-spectrum-project ${H}
|
|
109
109
|
`),0;process.stdout.write(`
|
|
110
|
-
${
|
|
110
|
+
${F.default.bold("create-spectrum-project")} ${F.default.dim(`v${H}`)}
|
|
111
111
|
|
|
112
|
-
`);let z=await m$({step:()=>{},warn:(W)=>{process.stderr.write(`${
|
|
112
|
+
`);let z=await m$({step:()=>{},warn:(W)=>{process.stderr.write(`${F.default.yellow("!")} ${W}
|
|
113
113
|
`)},stream:()=>{}}),B=c6(z),J=n6($,Z,B),X=$.yes?i6(J,B):await p$(J,B);if(!$.yes)process.stdout.write(`
|
|
114
|
-
`);let C=Date.now(),Q=a6(),U;try{U=await n$({...X,manifest:z,logger:{step:(W)=>Q.text(W),warn:(W)=>{Q.suspend(),process.stderr.write(`${
|
|
115
|
-
`),Q.resume()},stream:(W)=>{if($.verbose)process.stderr.write(W)}}})}catch(W){throw Q.stop(),W}let N=((Date.now()-C)/1000).toFixed(1);return Q.stop(`${
|
|
116
|
-
${
|
|
114
|
+
`);let C=Date.now(),Q=a6(),U;try{U=await n$({...X,manifest:z,logger:{step:(W)=>Q.text(W),warn:(W)=>{Q.suspend(),process.stderr.write(`${F.default.yellow("!")} ${W}
|
|
115
|
+
`),Q.resume()},stream:(W)=>{if($.verbose)process.stderr.write(W)}}})}catch(W){throw Q.stop(),W}let N=((Date.now()-C)/1000).toFixed(1);return Q.stop(`${v.ok} Created ${F.default.cyan(a$(U.targetDir))} ${v.dot} ${F.default.bold(`spectrum-ts ${U.spectrumTsVersion}`)} ${F.default.dim(`(${N}s)`)}`),p6(U,X),process.stdout.write(`
|
|
116
|
+
${v.arrow} ${F.default.dim("Docs:")} ${F.default.cyan("https://photon.codes/docs/spectrum-ts")}
|
|
117
117
|
|
|
118
|
-
`),0}function n6($,Z,H){let z={};if(Z[0])z.targetDir=Z[0];if(typeof $.providers==="string")z.providers=l6($.providers,H);if(typeof $.pm==="string"){if(!c1($.pm))Y1("--pm must be one of bun, npm, pnpm, yarn");z.packageManager=$.pm}if($["no-install"])z.install=!1;if($["no-git"])z.git=!1;return z}function l6($,Z){let H=Z.map((B)=>B.key),z=$.split(",").map((B)=>B.trim()).filter(Boolean);for(let B of z)if(!H.includes(B))Y1(`Unknown provider: ${B}. Available: ${H.join(", ")}`);if(z.length===0)Y1("--providers must list at least one provider");if(z.includes(I)&&z.length>1)Y1(`${I} is a dev-only TUI and can't be mixed with
|
|
119
|
-
${
|
|
120
|
-
`);for(let
|
|
118
|
+
`),0}function n6($,Z,H){let z={};if(Z[0])z.targetDir=Z[0];if(typeof $.providers==="string")z.providers=l6($.providers,H);if(typeof $.pm==="string"){if(!c1($.pm))Y1("--pm must be one of bun, npm, pnpm, yarn");z.packageManager=$.pm}if($["no-install"])z.install=!1;if($["no-git"])z.git=!1;return z}function l6($,Z){let H=Z.map((B)=>B.key),z=$.split(",").map((B)=>B.trim()).filter(Boolean);for(let B of z)if(!H.includes(B))Y1(`Unknown provider: ${B}. Available: ${H.join(", ")}`);if(z.length===0)Y1("--providers must list at least one provider");if(z.includes(I)&&z.length>1)Y1(`${I} is a dev-only TUI and can't be mixed with platform providers. Pick ${I} on its own, or pick one or more of: ${H.filter((B)=>B!==I).join(", ")}.`);return z}function i6($,Z){let H=Z.find((B)=>B.key!==I)?.key??Z[0]?.key;if(!H)Y1("Manifest is empty — no providers to scaffold.");let z=$.providers??[H];return{targetDir:$.targetDir??"my-spectrum-app",providers:z,packageManager:$.packageManager,install:$.install??!0,git:$.git??!0}}function p6($,Z){let H=Z.packageManager??"bun",B=[{cmd:`cd ${a$($.targetDir)}`}];if(!$.steps.installed)B.push({cmd:H==="yarn"?"yarn":`${H} install`});if($.needsEnvFile)B.push({note:"fill in .env with your credentials"});B.push({cmd:H==="npm"?"npm run start":`${H} start`}),process.stdout.write(`
|
|
119
|
+
${F.default.bold("Next steps")}
|
|
120
|
+
`);for(let J of B){let X="cmd"in J?` ${F.default.dim("$")} ${J.cmd}`:` ${F.default.dim(`# ${J.note}`)}`;process.stdout.write(`${X}
|
|
121
121
|
`)}}function a6(){if(!process.stderr.isTTY)return{text:()=>{},suspend:()=>{},resume:()=>{},stop:(X)=>{if(X)process.stderr.write(`${X}
|
|
122
|
-
`)}};let $=["⠋","⠙","⠹","⠸","⠼","⠴","⠦","⠧","⠇","⠏"],Z=0,H="Working",z=!1,B=()=>{if(z)return;process.stderr.write(`\r\x1B[K${
|
|
123
|
-
`)}}}function t6(){let $=(B)=>
|
|
124
|
-
`))}async function s6(){try{let $=y6(new URL("../package.json",import.meta.url));return JSON.parse(await d6($,"utf8")).version??"0.0.0"}catch{return"0.0.0"}}function Y1($){process.stderr.write(`${
|
|
122
|
+
`)}};let $=["⠋","⠙","⠹","⠸","⠼","⠴","⠦","⠧","⠇","⠏"],Z=0,H="Working",z=!1,B=()=>{if(z)return;process.stderr.write(`\r\x1B[K${F.default.dim($[Z++%$.length])} ${H}`)},J=setInterval(B,80);return B(),{text:(X)=>{H=X,B()},suspend:()=>{z=!0,process.stderr.write("\r\x1B[K")},resume:()=>{z=!1,B()},stop:(X)=>{if(clearInterval(J),process.stderr.write("\r\x1B[K"),X)process.stderr.write(`${X}
|
|
123
|
+
`)}}}function t6(){let $=(B)=>F.default.cyan(B),Z=(B)=>F.default.dim(B),H=(B)=>B.padEnd(24," "),z=[[H(`${$("--providers")} <list>`),"Comma-separated provider keys (see Spectrum docs)"],[H(`${$("--pm")} <m>`),`bun | npm | pnpm | yarn ${Z("(default: detected)")}`],[H($("--no-install")),"Skip dependency install"],[H($("--no-git")),"Skip git init"],[H(`${$("-y")}, ${$("--yes")}`),"Use defaults; skip interactive prompts"],[H($("--verbose")),"Stream install stdout/stderr"],[H(`${$("-h")}, ${$("--help")}`),"Show this help"],[H($("--version")),"Show version"]];process.stdout.write(["",` ${F.default.bold("Usage")}`,` ${Z("$")} create-spectrum-project ${Z("[directory] [options]")}`,"",` ${F.default.bold("Options")}`,...z.map(([B,J])=>` ${B}${Z(J)}`),""].join(`
|
|
124
|
+
`))}async function s6(){try{let $=y6(new URL("../package.json",import.meta.url));return JSON.parse(await d6($,"utf8")).version??"0.0.0"}catch{return"0.0.0"}}function Y1($){process.stderr.write(`${v.err} ${$}
|
|
125
125
|
`),process.exit(2)}try{process.exitCode=await m6()}catch($){if($ instanceof _1)process.stderr.write(`
|
|
126
|
-
${
|
|
126
|
+
${v.err} ${$.message}
|
|
127
127
|
`),process.exitCode=1;else if($ instanceof g1)process.stderr.write(`
|
|
128
|
-
${
|
|
128
|
+
${v.err} Install failed (exit ${$.exitCode}). cd into the project and run install manually to retry.
|
|
129
129
|
`),process.exitCode=1;else if($ instanceof f1)process.stderr.write(`
|
|
130
|
-
${
|
|
130
|
+
${v.err} ${$.message}
|
|
131
131
|
`),process.exitCode=1;else if($ instanceof Error){if(process.stderr.write(`
|
|
132
|
-
${
|
|
132
|
+
${v.err} ${$.message}
|
|
133
133
|
`),process.argv.includes("--verbose")&&$.stack)process.stderr.write(`${$.stack}
|
|
134
134
|
`);process.exitCode=1}else process.stderr.write(`
|
|
135
|
-
${
|
|
135
|
+
${v.err} ${String($)}
|
|
136
136
|
`),process.exitCode=1}
|
package/dist/scaffold.js
CHANGED
|
@@ -51,7 +51,7 @@ function assembleProviders(providers, manifest) {
|
|
|
51
51
|
}
|
|
52
52
|
return entry;
|
|
53
53
|
});
|
|
54
|
-
const
|
|
54
|
+
const hasPlatform = selected.some((m) => m.key !== TERMINAL_KEY);
|
|
55
55
|
const ordered = [
|
|
56
56
|
...selected.filter((m) => m.key === TERMINAL_KEY),
|
|
57
57
|
...manifest.filter((m) => m.key !== TERMINAL_KEY).filter((m) => selected.some((s) => s.key === m.key))
|
|
@@ -68,21 +68,21 @@ function assembleProviders(providers, manifest) {
|
|
|
68
68
|
const importsBlock = imports.join(`
|
|
69
69
|
`);
|
|
70
70
|
const configLines = [];
|
|
71
|
-
if (
|
|
71
|
+
if (hasPlatform) {
|
|
72
72
|
configLines.push(" projectId: process.env.PROJECT_ID!,");
|
|
73
73
|
configLines.push(" projectSecret: process.env.PROJECT_SECRET!,");
|
|
74
74
|
}
|
|
75
75
|
configLines.push(" providers: [");
|
|
76
76
|
configLines.push(...providerLines);
|
|
77
77
|
configLines.push(" ],");
|
|
78
|
-
const topLevelEnvVars =
|
|
78
|
+
const topLevelEnvVars = hasPlatform ? ["PROJECT_ID", "PROJECT_SECRET"] : [];
|
|
79
79
|
return {
|
|
80
80
|
importsBlock,
|
|
81
81
|
spectrumConfigBody: configLines.join(`
|
|
82
82
|
`),
|
|
83
83
|
topLevelEnvVars,
|
|
84
84
|
providerEnvVars: [],
|
|
85
|
-
needsEnvFile:
|
|
85
|
+
needsEnvFile: hasPlatform,
|
|
86
86
|
providersHuman: humanParts.join(", ")
|
|
87
87
|
};
|
|
88
88
|
}
|
|
@@ -235,14 +235,22 @@ async function scaffold(options) {
|
|
|
235
235
|
await copyAndTransform(templatesDir(), tmp, tokens, {
|
|
236
236
|
emitEnvFile: assembly.needsEnvFile
|
|
237
237
|
});
|
|
238
|
-
if (
|
|
239
|
-
const
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
`);
|
|
245
|
-
|
|
238
|
+
if (assembly.needsEnvFile) {
|
|
239
|
+
const envLines = [];
|
|
240
|
+
for (const k of assembly.topLevelEnvVars) {
|
|
241
|
+
if (k === "PROJECT_ID" && options.credentials) {
|
|
242
|
+
envLines.push(`PROJECT_ID=${options.credentials.projectId}`);
|
|
243
|
+
} else if (k === "PROJECT_SECRET" && options.credentials) {
|
|
244
|
+
envLines.push(`PROJECT_SECRET=${options.credentials.projectSecret}`);
|
|
245
|
+
} else {
|
|
246
|
+
envLines.push(`${k}=`);
|
|
247
|
+
}
|
|
248
|
+
}
|
|
249
|
+
for (const k of assembly.providerEnvVars) {
|
|
250
|
+
envLines.push(`${k}=`);
|
|
251
|
+
}
|
|
252
|
+
await writeFile2(join2(tmp, ".env"), envLines.join(`
|
|
253
|
+
`));
|
|
246
254
|
}
|
|
247
255
|
await rename(tmp, targetDir);
|
|
248
256
|
copied = true;
|
|
@@ -344,15 +352,11 @@ function buildEnvSetupBlock(top, provider) {
|
|
|
344
352
|
const lines = [
|
|
345
353
|
"## Environment",
|
|
346
354
|
"",
|
|
347
|
-
"Before running,
|
|
348
|
-
"",
|
|
349
|
-
"```sh",
|
|
350
|
-
"cp .env.example .env",
|
|
351
|
-
"```",
|
|
355
|
+
"Before running, open `.env` and fill in the values:",
|
|
352
356
|
""
|
|
353
357
|
];
|
|
354
358
|
if (top.length > 0) {
|
|
355
|
-
lines.push("From your project Settings on the [Photon dashboard](https://photon.codes):");
|
|
359
|
+
lines.push("From your project Settings on the [Photon dashboard](https://app.photon.codes):");
|
|
356
360
|
lines.push("");
|
|
357
361
|
for (const k of top) {
|
|
358
362
|
lines.push(`- \`${k}\``);
|