create-spectrum-project 0.2.0 → 0.3.1
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 +12 -9
- package/dist/bin.js +79 -76
- package/dist/scaffold.js +69 -2
- package/package.json +1 -1
- package/templates/base/AGENTS.md.tmpl +24 -0
- package/templates/base/CLAUDE.md +3 -0
- package/templates/base/package.json.tmpl +3 -4
- package/templates/base/{tsconfig.json → tsconfig.json.tmpl} +1 -1
package/README.md
CHANGED
|
@@ -5,13 +5,13 @@ Scaffolds a new [Spectrum](https://photon.codes/docs/spectrum-ts/introduction) p
|
|
|
5
5
|
## Interactive
|
|
6
6
|
|
|
7
7
|
```sh
|
|
8
|
-
|
|
8
|
+
bun create spectrum-project@latest
|
|
9
9
|
# or
|
|
10
|
-
npm create spectrum-project@latest
|
|
10
|
+
npm create spectrum-project@latest
|
|
11
11
|
# or
|
|
12
|
-
pnpm create spectrum-project
|
|
12
|
+
pnpm create spectrum-project@latest
|
|
13
13
|
# or
|
|
14
|
-
yarn create spectrum-project
|
|
14
|
+
yarn create spectrum-project@latest
|
|
15
15
|
```
|
|
16
16
|
|
|
17
17
|
You'll be asked for:
|
|
@@ -19,12 +19,13 @@ You'll be asked for:
|
|
|
19
19
|
- Which interface (terminal sandbox, iMessage, or WhatsApp Business)
|
|
20
20
|
- Your package manager (auto-detected)
|
|
21
21
|
- Whether to install dependencies and initialize git
|
|
22
|
+
- Whether to install the `spectrum` agent skill (default: yes)
|
|
22
23
|
|
|
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
|
+
The generated project includes `src/index.ts` with the selected providers wired in, a `package.json` pinned to the current `spectrum-ts` release, an `AGENTS.md` + `CLAUDE.md` so AI coding agents have project context immediately, the `spectrum` skill from [`photon-hq/skills`](https://github.com/photon-hq/skills) installed locally, a ready-to-fill `.env` (plus a tracked `.env.example`) for any required credentials, and an echo loop that runs on `bun start`.
|
|
24
25
|
|
|
25
26
|
## Non-interactive
|
|
26
27
|
|
|
27
|
-
Pass flags to skip prompts. Run `create
|
|
28
|
+
Pass flags to skip prompts. Run `bun create spectrum-project@latest --help` for the full list.
|
|
28
29
|
|
|
29
30
|
```
|
|
30
31
|
Usage: create-spectrum-project [directory] [options]
|
|
@@ -34,6 +35,7 @@ Options:
|
|
|
34
35
|
--pm <m> bun | npm | pnpm | yarn (default: detected)
|
|
35
36
|
--no-install Skip dependency install
|
|
36
37
|
--no-git Skip git init
|
|
38
|
+
--no-skills Skip Spectrum skill install
|
|
37
39
|
-y, --yes Use defaults; skip interactive prompts
|
|
38
40
|
--verbose Stream install stdout/stderr
|
|
39
41
|
-h, --help Show help
|
|
@@ -47,18 +49,19 @@ Defaults (applied by `-y` and as fallbacks for any flag you don't set):
|
|
|
47
49
|
- Package manager: detected from your shell, otherwise `bun`
|
|
48
50
|
- Install dependencies: yes
|
|
49
51
|
- Initialize git: yes
|
|
52
|
+
- Install Spectrum skill: yes
|
|
50
53
|
|
|
51
54
|
Examples:
|
|
52
55
|
|
|
53
56
|
```sh
|
|
54
57
|
# iMessage, no prompts, all defaults
|
|
55
|
-
|
|
58
|
+
bun create spectrum-project@latest -y
|
|
56
59
|
|
|
57
60
|
# Terminal sandbox (dev TUI, no credentials)
|
|
58
|
-
|
|
61
|
+
bun create spectrum-project@latest my-app --providers terminal
|
|
59
62
|
|
|
60
63
|
# iMessage + WhatsApp on pnpm, skip git
|
|
61
|
-
|
|
64
|
+
bun create spectrum-project@latest my-app --providers imessage,whatsapp-business --pm pnpm --no-git
|
|
62
65
|
```
|
|
63
66
|
|
|
64
67
|
## Requirements
|
package/dist/bin.js
CHANGED
|
@@ -1,132 +1,135 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import{createRequire as
|
|
3
|
-
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}var
|
|
2
|
+
import{createRequire as z7}from"node:module";var s$=Object.create;var{getPrototypeOf:o$,defineProperty:A0,getOwnPropertyNames:r$}=Object;var e$=Object.prototype.hasOwnProperty;function $7($){return this[$]}var Z7,H7,v1=($,Z,H)=>{var z=$!=null&&typeof $==="object";if(z){var J=Z?Z7??=new WeakMap:H7??=new WeakMap,B=J.get($);if(B)return B}H=$!=null?s$(o$($)):{};let X=Z||!$||!$.__esModule?A0(H,"default",{value:$,enumerable:!0}):H;for(let Q of r$($))if(!e$.call(X,Q))A0(X,Q,{get:$7.bind($,Q),enumerable:!0});if(z)J.set($,X);return X};var Y=($,Z)=>()=>(Z||$((Z={exports:{}}).exports,Z),Z.exports);var M1=z7(import.meta.url);var c1=Y((J8,u1)=>{var R1=process||{},I0=R1.argv||[],F1=R1.env||{},J7=!(!!F1.NO_COLOR||I0.includes("--no-color"))&&(!!F1.FORCE_COLOR||I0.includes("--color")||R1.platform==="win32"||(R1.stdout||{}).isTTY&&F1.TERM!=="dumb"||!!F1.CI),B7=($,Z,H=$)=>(z)=>{let J=""+z,B=J.indexOf(Z,$.length);return~B?$+X7(J,Z,H,B)+Z:$+J+Z},X7=($,Z,H,z)=>{let J="",B=0;do J+=$.substring(B,z)+H,B=z+Z.length,z=$.indexOf(Z,B);while(~z);return J+$.substring(B)},S0=($=J7)=>{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")}};u1.exports=S0();u1.exports.createColors=S0});var G=Y((X8,E0)=>{var{FORCE_COLOR:Q7,NODE_DISABLE_COLORS:U7,TERM:C7}=process.env,D={enabled:!U7&&C7!=="dumb"&&Q7!=="0",reset:K(0,0),bold:K(1,22),dim:K(2,22),italic:K(3,23),underline:K(4,24),inverse:K(7,27),hidden:K(8,28),strikethrough:K(9,29),black:K(30,39),red:K(31,39),green:K(32,39),yellow:K(33,39),blue:K(34,39),magenta:K(35,39),cyan:K(36,39),white:K(37,39),gray:K(90,39),grey:K(90,39),bgBlack:K(40,49),bgRed:K(41,49),bgGreen:K(42,49),bgYellow:K(43,49),bgBlue:K(44,49),bgMagenta:K(45,49),bgCyan:K(46,49),bgWhite:K(47,49)};function L0($,Z){let H=0,z,J="",B="";for(;H<$.length;H++)if(z=$[H],J+=z.open,B+=z.close,Z.includes(z.close))Z=Z.replace(z.rgx,z.close+z.open);return J+Z+B}function Y7($,Z){let H={has:$,keys:Z};return H.reset=D.reset.bind(H),H.bold=D.bold.bind(H),H.dim=D.dim.bind(H),H.italic=D.italic.bind(H),H.underline=D.underline.bind(H),H.inverse=D.inverse.bind(H),H.hidden=D.hidden.bind(H),H.strikethrough=D.strikethrough.bind(H),H.black=D.black.bind(H),H.red=D.red.bind(H),H.green=D.green.bind(H),H.yellow=D.yellow.bind(H),H.blue=D.blue.bind(H),H.magenta=D.magenta.bind(H),H.cyan=D.cyan.bind(H),H.white=D.white.bind(H),H.gray=D.gray.bind(H),H.grey=D.grey.bind(H),H.bgBlack=D.bgBlack.bind(H),H.bgRed=D.bgRed.bind(H),H.bgGreen=D.bgGreen.bind(H),H.bgYellow=D.bgYellow.bind(H),H.bgBlue=D.bgBlue.bind(H),H.bgMagenta=D.bgMagenta.bind(H),H.bgCyan=D.bgCyan.bind(H),H.bgWhite=D.bgWhite.bind(H),H}function K($,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:D.enabled?L0(this.keys,z+""):z+"";return z===void 0?Y7([$],[H]):D.enabled?L0([H],z+""):z+""}}E0.exports=D});var b0=Y((Q8,j0)=>{j0.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 N1=Y((U8,P0)=>{P0.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((C8,T0)=>{var l1={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"},W7={up:($=1)=>"\x1B[S".repeat($),down:($=1)=>"\x1B[T".repeat($)},D7={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?l1.up():"");if($)Z+=l1.left;return Z}};T0.exports={cursor:l1,scroll:W7,erase:D7,beep:"\x07"}});var _0=Y((Y8,k0)=>{function K7($,Z){var H=typeof Symbol<"u"&&$[Symbol.iterator]||$["@@iterator"];if(!H){if(Array.isArray($)||(H=G7($))||Z&&$&&typeof $.length==="number"){if(H)$=H;var z=0,J=function(){};return{s:J,n:function(){if(z>=$.length)return{done:!0};return{done:!1,value:$[z++]}},e:function(C){throw C},f:J}}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 B=!0,X=!1,Q;return{s:function(){H=H.call($)},n:function(){var C=H.next();return B=C.done,C},e:function(C){X=!0,Q=C},f:function(){try{if(!B&&H.return!=null)H.return()}finally{if(X)throw Q}}}}function G7($,Z){if(!$)return;if(typeof $==="string")return x0($,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 x0($,Z)}function x0($,Z){if(Z==null||Z>$.length)Z=$.length;for(var H=0,z=Array(Z);H<Z;H++)z[H]=$[H];return z}var M7=N1(),h0=M(),w0=h0.erase,F7=h0.cursor,R7=($)=>[...M7($)].length;k0.exports=function($,Z){if(!Z)return w0.line+F7.to(0);let H=0,z=$.split(/\r?\n/);var J=K7(z),B;try{for(J.s();!(B=J.n()).done;){let X=B.value;H+=1+Math.floor(Math.max(R7(X)-1,0)/Z)}}catch(X){J.e(X)}finally{J.f()}return w0.lines(H)}});var i1=Y((W8,f0)=>{var Z1={arrowUp:"↑",arrowDown:"↓",arrowLeft:"←",arrowRight:"→",radioOn:"◉",radioOff:"◯",tick:"✔",cross:"✖",ellipsis:"…",pointerSmall:"›",line:"─",pointer:"❯"},O7={arrowUp:Z1.arrowUp,arrowDown:Z1.arrowDown,arrowLeft:Z1.arrowLeft,arrowRight:Z1.arrowRight,radioOn:"(*)",radioOff:"( )",tick:"√",cross:"×",ellipsis:"...",pointerSmall:"»",line:"─",pointer:">"},N7=process.platform==="win32"?O7:Z1;f0.exports=N7});var d0=Y((D8,g0)=>{var o=G(),a=i1(),p1=Object.freeze({password:{scale:1,render:($)=>"*".repeat($.length)},emoji:{scale:2,render:($)=>"\uD83D\uDE03".repeat($.length)},invisible:{scale:0,render:($)=>""},default:{scale:1,render:($)=>`${$}`}}),V7=($)=>p1[$]||p1.default,H1=Object.freeze({aborted:o.red(a.cross),done:o.green(a.tick),exited:o.yellow(a.cross),default:o.cyan("?")}),A7=($,Z,H)=>Z?H1.aborted:H?H1.exited:$?H1.done:H1.default,I7=($)=>o.gray($?a.ellipsis:a.pointerSmall),S7=($,Z)=>o.gray($?Z?a.pointerSmall:"+":a.line);g0.exports={styles:p1,render:V7,symbols:H1,symbol:A7,delimiter:I7,item:S7}});var v0=Y((K8,y0)=>{var q7=N1();y0.exports=function($,Z){let H=String(q7($)||"").split(/\r?\n/);if(!Z)return H.length;return H.map((z)=>Math.ceil(z.length/Z)).reduce((z,J)=>z+J)}});var c0=Y((G8,u0)=>{u0.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((J)=>J.split(/\s+/g).reduce((B,X)=>{if(X.length+H.length>=z||B[B.length-1].length+X.length+1<z)B[B.length-1]+=` ${X}`;else B.push(`${H}${X}`);return B},[H]).join(`
|
|
4
4
|
`)).join(`
|
|
5
|
-
`)}});var
|
|
6
|
-
`),this.close()}validate(){var $=this;return
|
|
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(
|
|
5
|
+
`)}});var n0=Y((M8,m0)=>{m0.exports=($,Z,H)=>{H=H||Z;let z=Math.min(Z-H,$-Math.floor(H/2));if(z<0)z=0;let J=Math.min(z+H,Z);return{startIndex:z,endIndex:J}}});var q=Y((F8,l0)=>{l0.exports={action:b0(),clear:_0(),style:d0(),strip:N1(),figures:i1(),lines:v0(),wrap:c0(),entriesToDisplay:n0()}});var h=Y((R8,t0)=>{var i0=M1("readline"),L7=q(),E7=L7.action,j7=M1("events"),p0=M(),b7=p0.beep,P7=p0.cursor,T7=G();class a0 extends j7{constructor($={}){super();this.firstRender=!0,this.in=$.stdin||process.stdin,this.out=$.stdout||process.stdout,this.onRender=($.onRender||(()=>{return})).bind(this);let Z=i0.createInterface({input:this.in,escapeCodeTimeout:50});if(i0.emitKeypressEvents(this.in,Z),this.in.isTTY)this.in.setRawMode(!0);let H=["SelectPrompt","MultiselectPrompt"].indexOf(this.constructor.name)>-1,z=(J,B)=>{let X=E7(B,H);if(X===!1)this._&&this._(J,B);else if(typeof this[X]==="function")this[X](B);else this.bell()};this.close=()=>{if(this.out.write(P7.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(b7)}render(){if(this.onRender(T7),this.firstRender)this.firstRender=!1}}t0.exports=a0});var Z9=Y((O8,$9)=>{function s0($,Z,H,z,J,B,X){try{var Q=$[B](X),U=Q.value}catch(C){H(C);return}if(Q.done)Z(U);else Promise.resolve(U).then(z,J)}function o0($){return function(){var Z=this,H=arguments;return new Promise(function(z,J){var B=$.apply(Z,H);function X(U){s0(B,z,J,X,Q,"next",U)}function Q(U){s0(B,z,J,X,Q,"throw",U)}X(void 0)})}}var V1=G(),x7=h(),r0=M(),w7=r0.erase,z1=r0.cursor,A1=q(),a1=A1.style,t1=A1.clear,h7=A1.lines,k7=A1.figures;class e0 extends x7{constructor($={}){super($);this.transform=a1.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=t1("",this.out.columns),this.render()}set value($){if(!$&&this.initial)this.placeholder=!0,this.rendered=V1.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
|
+
`),this.close()}validate(){var $=this;return o0(function*(){let Z=yield $.validator($.value);if(typeof Z==="string")$.errorMsg=Z,Z=!1;$.error=!Z})()}submit(){var $=this;return o0(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
|
+
`),$.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(z1.down(h7(this.outputError,this.out.columns)-1)+t1(this.outputError,this.out.columns));this.out.write(t1(this.outputText,this.out.columns))}if(super.render(),this.outputError="",this.outputText=[a1.symbol(this.done,this.aborted),V1.bold(this.msg),a1.delimiter(this.done),this.red?V1.red(this.rendered):this.rendered].join(" "),this.error)this.outputError+=this.errorMsg.split(`
|
|
8
8
|
`).reduce(($,Z,H)=>$+`
|
|
9
|
-
${H?" ":
|
|
9
|
+
${H?" ":k7.pointerSmall} ${V1.red().italic(Z)}`,"");this.out.write(w7.line+z1.to(0)+this.outputText+z1.save+this.outputError+z1.restore+z1.move(this.cursorOffset,0))}}$9.exports=e0});var X9=Y((N8,B9)=>{var k=G(),_7=h(),J1=q(),H9=J1.style,z9=J1.clear,I1=J1.figures,f7=J1.wrap,g7=J1.entriesToDisplay,d7=M(),y7=d7.cursor;class J9 extends _7{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=z9("",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(
|
|
12
|
-
`;for(let z=Z;z<H;z++){let B,
|
|
13
|
-
`+
|
|
14
|
-
`}}this.out.write(this.outputText)}}B9.exports=
|
|
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(y7.hide);else this.out.write(z9(this.outputText,this.out.columns));super.render();let $=g7(this.cursor,this.choices.length,this.optionsPerPage),Z=$.startIndex,H=$.endIndex;if(this.outputText=[H9.symbol(this.done,this.aborted),k.bold(this.msg),H9.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 J,B,X="",Q=this.choices[z];if(z===Z&&Z>0)B=I1.arrowUp;else if(z===H-1&&H<this.choices.length)B=I1.arrowDown;else B=" ";if(Q.disabled)J=this.cursor===z?k.gray().underline(Q.title):k.strikethrough().gray(Q.title),B=(this.cursor===z?k.bold().gray(I1.pointer)+" ":" ")+B;else if(J=this.cursor===z?k.cyan().underline(Q.title):Q.title,B=(this.cursor===z?k.cyan(I1.pointer)+" ":" ")+B,Q.description&&this.cursor===z){if(X=` - ${Q.description}`,B.length+J.length+X.length>=this.out.columns||Q.description.split(/\r?\n/).length>1)X=`
|
|
13
|
+
`+f7(Q.description,{margin:3,width:this.out.columns})}this.outputText+=`${B} ${J}${k.gray(X)}
|
|
14
|
+
`}}this.out.write(this.outputText)}}B9.exports=J9});var K9=Y((V8,D9)=>{var S1=G(),v7=h(),C9=q(),Q9=C9.style,u7=C9.clear,Y9=M(),U9=Y9.cursor,c7=Y9.erase;class W9 extends v7{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(
|
|
17
|
-
`),this.close()}validate(){var $=this;return
|
|
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
|
|
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(U9.hide);else this.out.write(u7(this.outputText,this.out.columns));super.render(),this.outputText=[Q9.symbol(this.done,this.aborted),S1.bold(this.msg),Q9.delimiter(this.done),this.value?this.inactive:S1.cyan().underline(this.inactive),S1.gray("/"),this.value?S1.cyan().underline(this.active):this.active].join(" "),this.out.write(c7.line+U9.to(0)+this.outputText)}}D9.exports=W9});var E=Y((A8,G9)=>{class q1{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 q1)}setTo($){}prev(){let $=[].concat(this.parts).reverse(),Z=$.indexOf(this);return $.find((H,z)=>z>Z&&H instanceof q1)}toString(){return String(this.date)}}G9.exports=q1});var R9=Y((I8,F9)=>{var m7=E();class M9 extends m7{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():$}}F9.exports=M9});var V9=Y((S8,N9)=>{var n7=E(),l7=($)=>{return $=$%10,$===1?"st":$===2?"nd":$===3?"rd":"th"};class O9 extends n7{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"?$+l7($):this.token==="d"?Z+1:this.token==="ddd"?this.locales.weekdaysShort[Z]:this.token==="dddd"?this.locales.weekdays[Z]:$}}N9.exports=O9});var S9=Y((q8,I9)=>{var i7=E();class A9 extends i7{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"):$}}I9.exports=A9});var E9=Y((L8,L9)=>{var p7=E();class q9 extends p7{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)}}L9.exports=q9});var P9=Y((E8,b9)=>{var a7=E();class j9 extends a7{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"):$}}b9.exports=j9});var w9=Y((j8,x9)=>{var t7=E();class T9 extends t7{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)}}x9.exports=T9});var _9=Y((b8,k9)=>{var s7=E();class h9 extends s7{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"):$}}k9.exports=h9});var d9=Y((P8,g9)=>{var o7=E();class f9 extends o7{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):$}}g9.exports=f9});var v9=Y((T8,y9)=>{y9.exports={DatePart:E(),Meridiem:R9(),Day:V9(),Hours:S9(),Milliseconds:E9(),Minutes:P9(),Month:w9(),Seconds:_9(),Year:d9()}});var o9=Y((x8,s9)=>{function u9($,Z,H,z,J,B,X){try{var Q=$[B](X),U=Q.value}catch(C){H(C);return}if(Q.done)Z(U);else Promise.resolve(U).then(z,J)}function c9($){return function(){var Z=this,H=arguments;return new Promise(function(z,J){var B=$.apply(Z,H);function X(U){u9(B,z,J,X,Q,"next",U)}function Q(U){u9(B,z,J,X,Q,"throw",U)}X(void 0)})}}var s1=G(),r7=h(),o1=q(),m9=o1.style,n9=o1.clear,e7=o1.figures,a9=M(),$Z=a9.erase,l9=a9.cursor,_=v9(),i9=_.DatePart,ZZ=_.Meridiem,HZ=_.Day,zZ=_.Hours,JZ=_.Milliseconds,BZ=_.Minutes,XZ=_.Month,QZ=_.Seconds,UZ=_.Year,CZ=/\\(.)|"((?:\\["\\]|[^"])+)"|(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,p9={1:({token:$})=>$.replace(/\\(.)/g,"$1"),2:($)=>new HZ($),3:($)=>new XZ($),4:($)=>new UZ($),5:($)=>new ZZ($),6:($)=>new zZ($),7:($)=>new BZ($),8:($)=>new QZ($),9:($)=>new JZ($)},YZ={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 t9 extends r7{constructor($={}){super($);this.msg=$.message,this.cursor=0,this.typed="",this.locales=Object.assign(YZ,$.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=n9("",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=CZ.exec($)){let z=Z.shift(),J=Z.findIndex((B)=>B!=null);this.parts.push(J in p9?p9[J]({token:Z[J]||z,date:this.date,parts:this.parts,locales:this.locales}):Z[J]||z)}let H=this.parts.reduce((z,J)=>{if(typeof J==="string"&&typeof z[z.length-1]==="string")z[z.length-1]+=J;else z.push(J);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 i9)),this.fire(),this.render()}exit(){this.abort()}abort(){this.done=this.aborted=!0,this.error=!1,this.fire(),this.render(),this.out.write(`
|
|
17
|
+
`),this.close()}validate(){var $=this;return c9(function*(){let Z=yield $.validator($.value);if(typeof Z==="string")$.errorMsg=Z,Z=!1;$.error=!Z})()}submit(){var $=this;return c9(function*(){if(yield $.validate(),$.error){$.color="red",$.fire(),$.render();return}$.done=!0,$.aborted=!1,$.fire(),$.render(),$.out.write(`
|
|
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 i9)),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(l9.hide);else this.out.write(n9(this.outputText,this.out.columns));if(super.render(),this.outputText=[m9.symbol(this.done,this.aborted),s1.bold(this.msg),m9.delimiter(!1),this.parts.reduce(($,Z,H)=>$.concat(H===this.cursor&&!this.done?s1.cyan().underline(Z.toString()):Z),[]).join("")].join(" "),this.error)this.outputText+=this.errorMsg.split(`
|
|
19
19
|
`).reduce(($,Z,H)=>$+`
|
|
20
|
-
${H?" ":
|
|
21
|
-
`),this.close()}validate(){var $=this;return
|
|
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(
|
|
20
|
+
${H?" ":e7.pointerSmall} ${s1.red().italic(Z)}`,"");this.out.write($Z.line+l9.to(0)+this.outputText)}}s9.exports=t9});var B2=Y((w8,J2)=>{function r9($,Z,H,z,J,B,X){try{var Q=$[B](X),U=Q.value}catch(C){H(C);return}if(Q.done)Z(U);else Promise.resolve(U).then(z,J)}function e9($){return function(){var Z=this,H=arguments;return new Promise(function(z,J){var B=$.apply(Z,H);function X(U){r9(B,z,J,X,Q,"next",U)}function Q(U){r9(B,z,J,X,Q,"throw",U)}X(void 0)})}}var L1=G(),WZ=h(),H2=M(),E1=H2.cursor,DZ=H2.erase,j1=q(),r1=j1.style,KZ=j1.figures,$2=j1.clear,GZ=j1.lines,MZ=/[0-9]/,e1=($)=>$!==void 0,Z2=($,Z)=>{let H=Math.pow(10,Z);return Math.round($*H)/H};class z2 extends WZ{constructor($={}){super($);this.transform=r1.render($.style),this.msg=$.message,this.initial=e1($.initial)?$.initial:"",this.float=!!$.float,this.round=$.round||2,this.inc=$.increment||1,this.min=e1($.min)?$.min:-1/0,this.max=e1($.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=L1.gray(this.transform.render(`${this.initial}`)),this._value="";else this.placeholder=!1,this.rendered=this.transform.render(`${Z2($,this.round)}`),this._value=Z2($,this.round);this.fire()}get value(){return this._value}parse($){return this.float?parseFloat($):parseInt($)}valid($){return $==="-"||$==="."&&this.float||MZ.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
|
+
`),this.close()}validate(){var $=this;return e9(function*(){let Z=yield $.validator($.value);if(typeof Z==="string")$.errorMsg=Z,Z=!1;$.error=!Z})()}submit(){var $=this;return e9(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
|
+
`),$.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(E1.down(GZ(this.outputError,this.out.columns)-1)+$2(this.outputError,this.out.columns));this.out.write($2(this.outputText,this.out.columns))}if(super.render(),this.outputError="",this.outputText=[r1.symbol(this.done,this.aborted),L1.bold(this.msg),r1.delimiter(this.done),!this.done||!this.done&&!this.placeholder?L1[this.color]().underline(this.rendered):this.rendered].join(" "),this.error)this.outputError+=this.errorMsg.split(`
|
|
23
23
|
`).reduce(($,Z,H)=>$+`
|
|
24
|
-
${H?" ":KZ.pointerSmall} ${
|
|
24
|
+
${H?" ":KZ.pointerSmall} ${L1.red().italic(Z)}`,"");this.out.write(DZ.line+E1.to(0)+this.outputText+E1.save+this.outputError+E1.restore)}}J2.exports=z2});var $0=Y((h8,C2)=>{var j=G(),FZ=M(),RZ=FZ.cursor,OZ=h(),B1=q(),X2=B1.clear,c=B1.figures,Q2=B1.style,NZ=B1.wrap,VZ=B1.entriesToDisplay;class U2 extends OZ{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=X2("",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
28
|
${c.arrowUp}/${c.arrowDown}: Highlight option
|
|
29
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
|
|
32
|
-
`+
|
|
33
|
-
`+
|
|
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 $=[
|
|
31
|
+
`:"")+" enter/return: Complete answer"}return""}renderOption($,Z,H,z){let J=(Z.selected?j.green(c.radioOn):c.radioOff)+" "+z+" ",B,X;if(Z.disabled)B=$===H?j.gray().underline(Z.title):j.strikethrough().gray(Z.title);else if(B=$===H?j.cyan().underline(Z.title):Z.title,$===H&&Z.description){if(X=` - ${Z.description}`,J.length+B.length+X.length>=this.out.columns||Z.description.split(/\r?\n/).length>1)X=`
|
|
32
|
+
`+NZ(Z.description,{margin:J.length,width:this.out.columns})}return J+B+j.gray(X||"")}paginateOptions($){if($.length===0)return j.red("No matches for this query.");let Z=VZ(this.cursor,$.length,this.optionsPerPage),H=Z.startIndex,z=Z.endIndex,J,B=[];for(let X=H;X<z;X++){if(X===H&&H>0)J=c.arrowUp;else if(X===z-1&&z<$.length)J=c.arrowDown;else J=" ";B.push(this.renderOption(this.cursor,$[X],X,J))}return`
|
|
33
|
+
`+B.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 $=[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 $=[Q2.symbol(this.done,this.aborted),j.bold(this.msg),Q2.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=X2($,this.out.columns)}}C2.exports=U2});var R2=Y((k8,F2)=>{function Y2($,Z,H,z,J,B,X){try{var Q=$[B](X),U=Q.value}catch(C){H(C);return}if(Q.done)Z(U);else Promise.resolve(U).then(z,J)}function AZ($){return function(){var Z=this,H=arguments;return new Promise(function(z,J){var B=$.apply(Z,H);function X(U){Y2(B,z,J,X,Q,"next",U)}function Q(U){Y2(B,z,J,X,Q,"throw",U)}X(void 0)})}}var X1=G(),IZ=h(),G2=M(),SZ=G2.erase,W2=G2.cursor,Q1=q(),Z0=Q1.style,D2=Q1.clear,H0=Q1.figures,qZ=Q1.wrap,LZ=Q1.entriesToDisplay,K2=($,Z)=>$[Z]&&($[Z].value||$[Z].title||$[Z]),EZ=($,Z)=>$[Z]&&($[Z].title||$[Z].value||$[Z]),jZ=($,Z)=>{let H=$.findIndex((z)=>z.value===Z||z.title===Z);return H>-1?H:void 0};class M2 extends IZ{constructor($={}){super($);this.msg=$.message,this.suggest=$.suggest,this.choices=$.choices,this.initial=typeof $.initial==="number"?$.initial:jZ($.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=Z0.render($.style),this.scale=this.transform.scale,this.render=this.render.bind(this),this.complete=this.complete.bind(this),this.clear=D2("",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 AZ(function*(){let H=Z.completing=Z.suggest(Z.input,Z.choices),z=yield H;if(Z.completing!==H)return;Z.suggestions=z.map((B,X,Q)=>({title:EZ(Q,X),value:K2(Q,X),description:B.description})),Z.completing=!1;let J=Math.max(z.length-1,0);Z.moveSelect(Math.min(J,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
|
-
`),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
|
|
38
|
-
`+
|
|
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 J,B=H?H0.arrowUp:z?H0.arrowDown:" ",X=Z?X1.cyan().underline($.title):$.title;if(B=(Z?X1.cyan(H0.pointer)+" ":" ")+B,$.description){if(J=` - ${$.description}`,B.length+X.length+J.length>=this.out.columns||$.description.split(/\r?\n/).length>1)J=`
|
|
38
|
+
`+qZ($.description,{margin:3,width:this.out.columns})}return B+" "+X+X1.gray(J||"")}render(){if(this.closed)return;if(this.firstRender)this.out.write(W2.hide);else this.out.write(D2(this.outputText,this.out.columns));super.render();let $=LZ(this.select,this.choices.length,this.limit),Z=$.startIndex,H=$.endIndex;if(this.outputText=[Z0.symbol(this.done,this.aborted,this.exited),X1.bold(this.msg),Z0.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((J,B)=>this.renderOption(J,this.select===B+Z,B===0&&Z>0,B+Z===H-1&&H<this.choices.length)).join(`
|
|
39
39
|
`);this.outputText+=`
|
|
40
|
-
`+(z||
|
|
40
|
+
`+(z||X1.gray(this.fallback.title))}this.out.write(SZ.line+W2.to(0)+this.outputText)}}F2.exports=M2});var I2=Y((_8,A2)=>{var f=G(),bZ=M(),PZ=bZ.cursor,TZ=$0(),z0=q(),O2=z0.clear,N2=z0.style,r=z0.figures;class V2 extends TZ{constructor($={}){$.overrideRender=!0;super($);this.inputValue="",this.clear=O2("",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
|
-
${
|
|
43
|
-
${
|
|
42
|
+
${r.arrowUp}/${r.arrowDown}: Highlight option
|
|
43
|
+
${r.arrowLeft}/${r.arrowRight}/[space]: Toggle selection
|
|
44
44
|
[a,b,c]/delete: Filter choices
|
|
45
45
|
enter/return: Complete answer
|
|
46
46
|
`}return""}renderCurrentInput(){return`
|
|
47
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(
|
|
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(r.radioOn):r.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(PZ.hide);super.render();let $=[N2.symbol(this.done,this.aborted),f.bold(this.msg),N2.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=O2($,this.out.columns)}}A2.exports=V2});var T2=Y((f8,P2)=>{var S2=G(),xZ=h(),E2=q(),q2=E2.style,wZ=E2.clear,j2=M(),hZ=j2.erase,L2=j2.cursor;class b2 extends xZ{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
|
|
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(L2.hide);else this.out.write(wZ(this.outputText,this.out.columns));super.render(),this.outputText=[q2.symbol(this.done,this.aborted),S2.bold(this.msg),q2.delimiter(this.done),this.done?this.value?this.yesMsg:this.noMsg:S2.gray(this.initialValue?this.yesOption:this.noOption)].join(" "),this.out.write(hZ.line+L2.to(0)+this.outputText)}}P2.exports=b2});var w2=Y((g8,x2)=>{x2.exports={TextPrompt:Z9(),SelectPrompt:X9(),TogglePrompt:K9(),DatePrompt:o9(),NumberPrompt:B2(),MultiselectPrompt:$0(),AutocompletePrompt:R2(),AutocompleteMultiselectPrompt:I2(),ConfirmPrompt:T2()}});var k2=Y((h2)=>{var A=h2,kZ=w2(),b1=($)=>$;function b($,Z,H={}){return new Promise((z,J)=>{let B=new kZ[$](Z),X=H.onAbort||b1,Q=H.onSubmit||b1,U=H.onExit||b1;B.on("state",Z.onState||b1),B.on("submit",(C)=>z(Q(C))),B.on("exit",(C)=>z(U(C))),B.on("abort",(C)=>J(X(C)))})}A.text=($)=>b("TextPrompt",$);A.password=($)=>{return $.style="password",A.text($)};A.invisible=($)=>{return $.style="invisible",A.text($)};A.number=($)=>b("NumberPrompt",$);A.date=($)=>b("DatePrompt",$);A.confirm=($)=>b("ConfirmPrompt",$);A.list=($)=>{let Z=$.separator||",";return b("TextPrompt",$,{onSubmit:(H)=>H.split(Z).map((z)=>z.trim())})};A.toggle=($)=>b("TogglePrompt",$);A.select=($)=>b("SelectPrompt",$);A.multiselect=($)=>{$.choices=[].concat($.choices||[]);let Z=(H)=>H.filter((z)=>z.selected).map((z)=>z.value);return b("MultiselectPrompt",$,{onAbort:Z,onSubmit:Z})};A.autocompleteMultiselect=($)=>{$.choices=[].concat($.choices||[]);let Z=(H)=>H.filter((z)=>z.selected).map((z)=>z.value);return b("AutocompleteMultiselectPrompt",$,{onAbort:Z,onSubmit:Z})};var _Z=($,Z)=>Promise.resolve(Z.filter((H)=>H.title.slice(0,$.length).toLowerCase()===$.toLowerCase()));A.autocomplete=($)=>{return $.suggest=$.suggest||_Z,$.choices=[].concat($.choices||[]),b("AutocompletePrompt",$)}});var c2=Y((y8,u2)=>{function _2($,Z){var H=Object.keys($);if(Object.getOwnPropertySymbols){var z=Object.getOwnPropertySymbols($);if(Z)z=z.filter(function(J){return Object.getOwnPropertyDescriptor($,J).enumerable});H.push.apply(H,z)}return H}function f2($){for(var Z=1;Z<arguments.length;Z++){var H=arguments[Z]!=null?arguments[Z]:{};if(Z%2)_2(Object(H),!0).forEach(function(z){fZ($,z,H[z])});else if(Object.getOwnPropertyDescriptors)Object.defineProperties($,Object.getOwnPropertyDescriptors(H));else _2(Object(H)).forEach(function(z){Object.defineProperty($,z,Object.getOwnPropertyDescriptor(H,z))})}return $}function fZ($,Z,H){if(Z in $)Object.defineProperty($,Z,{value:H,enumerable:!0,configurable:!0,writable:!0});else $[Z]=H;return $}function gZ($,Z){var H=typeof Symbol<"u"&&$[Symbol.iterator]||$["@@iterator"];if(!H){if(Array.isArray($)||(H=dZ($))||Z&&$&&typeof $.length==="number"){if(H)$=H;var z=0,J=function(){};return{s:J,n:function(){if(z>=$.length)return{done:!0};return{done:!1,value:$[z++]}},e:function(C){throw C},f:J}}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 B=!0,X=!1,Q;return{s:function(){H=H.call($)},n:function(){var C=H.next();return B=C.done,C},e:function(C){X=!0,Q=C},f:function(){try{if(!B&&H.return!=null)H.return()}finally{if(X)throw Q}}}}function dZ($,Z){if(!$)return;if(typeof $==="string")return g2($,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 g2($,Z)}function g2($,Z){if(Z==null||Z>$.length)Z=$.length;for(var H=0,z=Array(Z);H<Z;H++)z[H]=$[H];return z}function d2($,Z,H,z,J,B,X){try{var Q=$[B](X),U=Q.value}catch(C){H(C);return}if(Q.done)Z(U);else Promise.resolve(U).then(z,J)}function y2($){return function(){var Z=this,H=arguments;return new Promise(function(z,J){var B=$.apply(Z,H);function X(U){d2(B,z,J,X,Q,"next",U)}function Q(U){d2(B,z,J,X,Q,"throw",U)}X(void 0)})}}var J0=k2(),yZ=["suggest","format","onState","validate","onRender","type"],v2=()=>{};function m(){return B0.apply(this,arguments)}function B0(){return B0=y2(function*($=[],{onSubmit:Z=v2,onCancel:H=v2}={}){let z={},J=m._override||{};$=[].concat($);let B,X,Q,U,C,O,W=function(){var V=y2(function*(w,G1,V0=!1){if(!V0&&w.validate&&w.validate(G1)!==!0)return;return w.format?yield w.format(G1,z):G1});return function(G1,V0){return V.apply(this,arguments)}}();var F=gZ($),N;try{for(F.s();!(N=F.n()).done;){X=N.value;var p=X;if(U=p.name,C=p.type,typeof C==="function")C=yield C(B,f2({},z),X),X.type=C;if(!C)continue;for(let V in X){if(yZ.includes(V))continue;let w=X[V];X[V]=typeof w==="function"?yield w(B,f2({},z),O):w}if(O=X,typeof X.message!=="string")throw Error("prompt message is required");var u=X;if(U=u.name,C=u.type,J0[C]===void 0)throw Error(`prompt type (${C}) is not defined`);if(J[X.name]!==void 0){if(B=yield W(X,J[X.name]),B!==void 0){z[U]=B;continue}}try{B=m._injected?vZ(m._injected,X.initial):yield J0[C](X),z[U]=B=yield W(X,B,!0),Q=yield Z(X,B,z)}catch(V){Q=!(yield H(X,z))}if(Q)return z}}catch(V){F.e(V)}finally{F.f()}return z}),B0.apply(this,arguments)}function vZ($,Z){let H=$.shift();if(H instanceof Error)throw H;return H===void 0?Z:H}function uZ($){m._injected=(m._injected||[]).concat($)}function cZ($){m._override=Object.assign({},$)}u2.exports=Object.assign(m,{prompt:m,prompts:J0,inject:uZ,override:cZ})});var n2=Y((v8,m2)=>{m2.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 P1=Y((u8,l2)=>{l2.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 a2=Y((c8,p2)=>{var mZ=P1(),{erase:i2,cursor:nZ}=M(),lZ=($)=>[...mZ($)].length;p2.exports=function($,Z){if(!Z)return i2.line+nZ.to(0);let H=0,z=$.split(/\r?\n/);for(let J of z)H+=1+Math.floor(Math.max(lZ(J)-1,0)/Z);return i2.lines(H)}});var X0=Y((m8,t2)=>{var U1={arrowUp:"↑",arrowDown:"↓",arrowLeft:"←",arrowRight:"→",radioOn:"◉",radioOff:"◯",tick:"✔",cross:"✖",ellipsis:"…",pointerSmall:"›",line:"─",pointer:"❯"},iZ={arrowUp:U1.arrowUp,arrowDown:U1.arrowDown,arrowLeft:U1.arrowLeft,arrowRight:U1.arrowRight,radioOn:"(*)",radioOff:"( )",tick:"√",cross:"×",ellipsis:"...",pointerSmall:"»",line:"─",pointer:">"},pZ=process.platform==="win32"?iZ:U1;t2.exports=pZ});var o2=Y((n8,s2)=>{var e=G(),t=X0(),Q0=Object.freeze({password:{scale:1,render:($)=>"*".repeat($.length)},emoji:{scale:2,render:($)=>"\uD83D\uDE03".repeat($.length)},invisible:{scale:0,render:($)=>""},default:{scale:1,render:($)=>`${$}`}}),aZ=($)=>Q0[$]||Q0.default,C1=Object.freeze({aborted:e.red(t.cross),done:e.green(t.tick),exited:e.yellow(t.cross),default:e.cyan("?")}),tZ=($,Z,H)=>Z?C1.aborted:H?C1.exited:$?C1.done:C1.default,sZ=($)=>e.gray($?t.ellipsis:t.pointerSmall),oZ=($,Z)=>e.gray($?Z?t.pointerSmall:"+":t.line);s2.exports={styles:Q0,render:aZ,symbols:C1,symbol:tZ,delimiter:sZ,item:oZ}});var e2=Y((l8,r2)=>{var rZ=P1();r2.exports=function($,Z){let H=String(rZ($)||"").split(/\r?\n/);if(!Z)return H.length;return H.map((z)=>Math.ceil(z.length/Z)).reduce((z,J)=>z+J)}});var Z4=Y((i8,$4)=>{$4.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((J)=>J.split(/\s+/g).reduce((B,X)=>{if(X.length+H.length>=z||B[B.length-1].length+X.length+1<z)B[B.length-1]+=` ${X}`;else B.push(`${H}${X}`);return B},[H]).join(`
|
|
52
52
|
`)).join(`
|
|
53
|
-
`)}});var
|
|
53
|
+
`)}});var z4=Y((p8,H4)=>{H4.exports=($,Z,H)=>{H=H||Z;let z=Math.min(Z-H,$-Math.floor(H/2));if(z<0)z=0;let J=Math.min(z+H,Z);return{startIndex:z,endIndex:J}}});var L=Y((a8,J4)=>{J4.exports={action:n2(),clear:a2(),style:o2(),strip:P1(),figures:X0(),lines:e2(),wrap:Z4(),entriesToDisplay:z4()}});var g=Y((t8,Q4)=>{var B4=M1("readline"),{action:eZ}=L(),$5=M1("events"),{beep:Z5,cursor:H5}=M(),z5=G();class X4 extends $5{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=(J,B)=>{let X=eZ(B,H);if(X===!1)this._&&this._(J,B);else if(typeof this[X]==="function")this[X](B);else this.bell()};this.close=()=>{if(this.out.write(H5.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(Z5)}render(){if(this.onRender(z5),this.firstRender)this.firstRender=!1}}Q4.exports=X4});var Y4=Y((s8,C4)=>{var T1=G(),J5=g(),{erase:B5,cursor:Y1}=M(),{style:U0,clear:C0,lines:X5,figures:Q5}=L();class U4 extends J5{constructor($={}){super($);this.transform=U0.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=C0("",this.out.columns),this.render()}set value($){if(!$&&this.initial)this.placeholder=!0,this.rendered=T1.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
|
-
`),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(
|
|
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(Y1.down(X5(this.outputError,this.out.columns)-1)+C0(this.outputError,this.out.columns));this.out.write(C0(this.outputText,this.out.columns))}if(super.render(),this.outputError="",this.outputText=[U0.symbol(this.done,this.aborted),T1.bold(this.msg),U0.delimiter(this.done),this.red?T1.red(this.rendered):this.rendered].join(" "),this.error)this.outputError+=this.errorMsg.split(`
|
|
56
56
|
`).reduce(($,Z,H)=>$+`
|
|
57
|
-
${H?" ":
|
|
57
|
+
${H?" ":Q5.pointerSmall} ${T1.red().italic(Z)}`,"");this.out.write(B5.line+Y1.to(0)+this.outputText+Y1.save+this.outputError+Y1.restore+Y1.move(this.cursorOffset,0))}}C4.exports=U4});var M4=Y((o8,G4)=>{var d=G(),U5=g(),{style:W4,clear:D4,figures:x1,wrap:C5,entriesToDisplay:Y5}=L(),{cursor:W5}=M();class K4 extends U5{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=D4("",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(
|
|
60
|
-
`;for(let H=$;H<Z;H++){let z,B
|
|
61
|
-
`+
|
|
62
|
-
`}}this.out.write(this.outputText)}}
|
|
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(W5.hide);else this.out.write(D4(this.outputText,this.out.columns));super.render();let{startIndex:$,endIndex:Z}=Y5(this.cursor,this.choices.length,this.optionsPerPage);if(this.outputText=[W4.symbol(this.done,this.aborted),d.bold(this.msg),W4.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,J,B="",X=this.choices[H];if(H===$&&$>0)J=x1.arrowUp;else if(H===Z-1&&Z<this.choices.length)J=x1.arrowDown;else J=" ";if(X.disabled)z=this.cursor===H?d.gray().underline(X.title):d.strikethrough().gray(X.title),J=(this.cursor===H?d.bold().gray(x1.pointer)+" ":" ")+J;else if(z=this.cursor===H?d.cyan().underline(X.title):X.title,J=(this.cursor===H?d.cyan(x1.pointer)+" ":" ")+J,X.description&&this.cursor===H){if(B=` - ${X.description}`,J.length+z.length+B.length>=this.out.columns||X.description.split(/\r?\n/).length>1)B=`
|
|
61
|
+
`+C5(X.description,{margin:3,width:this.out.columns})}this.outputText+=`${J} ${z}${d.gray(B)}
|
|
62
|
+
`}}this.out.write(this.outputText)}}G4.exports=K4});var V4=Y((r8,N4)=>{var w1=G(),D5=g(),{style:F4,clear:K5}=L(),{cursor:R4,erase:G5}=M();class O4 extends D5{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=[
|
|
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=[F4.symbol(this.done,this.aborted),w1.bold(this.msg),F4.delimiter(this.done),this.value?this.inactive:w1.cyan().underline(this.inactive),w1.gray("/"),this.value?w1.cyan().underline(this.active):this.active].join(" "),this.out.write(G5.line+R4.to(0)+this.outputText)}}N4.exports=O4});var P=Y((e8,A4)=>{class h1{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 h1)}setTo($){}prev(){let $=[].concat(this.parts).reverse(),Z=$.indexOf(this);return $.find((H,z)=>z>Z&&H instanceof h1)}toString(){return String(this.date)}}A4.exports=h1});var q4=Y(($H,S4)=>{var M5=P();class I4 extends M5{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():$}}S4.exports=I4});var j4=Y((ZH,E4)=>{var F5=P(),R5=($)=>{return $=$%10,$===1?"st":$===2?"nd":$===3?"rd":"th"};class L4 extends F5{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]:$}}E4.exports=L4});var T4=Y((HH,P4)=>{var O5=P();class b4 extends O5{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"):$}}P4.exports=b4});var h4=Y((zH,w4)=>{var N5=P();class x4 extends N5{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)}}w4.exports=x4});var f4=Y((JH,_4)=>{var V5=P();class k4 extends V5{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"):$}}_4.exports=k4});var y4=Y((BH,d4)=>{var A5=P();class g4 extends A5{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)}}d4.exports=g4});var c4=Y((XH,u4)=>{var I5=P();class v4 extends I5{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"):$}}u4.exports=v4});var l4=Y((QH,n4)=>{var S5=P();class m4 extends S5{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):$}}n4.exports=m4});var p4=Y((UH,i4)=>{i4.exports={DatePart:P(),Meridiem:q4(),Day:j4(),Hours:T4(),Milliseconds:h4(),Minutes:f4(),Month:y4(),Seconds:c4(),Year:l4()}});var Z$=Y((CH,$$)=>{var Y0=G(),q5=g(),{style:a4,clear:t4,figures:L5}=L(),{erase:E5,cursor:s4}=M(),{DatePart:o4,Meridiem:j5,Day:b5,Hours:P5,Milliseconds:T5,Minutes:x5,Month:w5,Seconds:h5,Year:k5}=p4(),_5=/\\(.)|"((?:\\["\\]|[^"])+)"|(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,r4={1:({token:$})=>$.replace(/\\(.)/g,"$1"),2:($)=>new b5($),3:($)=>new w5($),4:($)=>new k5($),5:($)=>new j5($),6:($)=>new P5($),7:($)=>new x5($),8:($)=>new h5($),9:($)=>new T5($)},f5={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 e4 extends q5{constructor($={}){super($);this.msg=$.message,this.cursor=0,this.typed="",this.locales=Object.assign(f5,$.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=t4("",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=_5.exec($)){let z=Z.shift(),J=Z.findIndex((B)=>B!=null);this.parts.push(J in r4?r4[J]({token:Z[J]||z,date:this.date,parts:this.parts,locales:this.locales}):Z[J]||z)}let H=this.parts.reduce((z,J)=>{if(typeof J==="string"&&typeof z[z.length-1]==="string")z[z.length-1]+=J;else z.push(J);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 o4)),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
|
-
`),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
|
|
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 o4)),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(s4.hide);else this.out.write(t4(this.outputText,this.out.columns));if(super.render(),this.outputText=[a4.symbol(this.done,this.aborted),Y0.bold(this.msg),a4.delimiter(!1),this.parts.reduce(($,Z,H)=>$.concat(H===this.cursor&&!this.done?Y0.cyan().underline(Z.toString()):Z),[]).join("")].join(" "),this.error)this.outputText+=this.errorMsg.split(`
|
|
67
67
|
`).reduce(($,Z,H)=>$+`
|
|
68
|
-
${H?" ":
|
|
68
|
+
${H?" ":L5.pointerSmall} ${Y0.red().italic(Z)}`,"");this.out.write(E5.line+s4.to(0)+this.outputText)}}$$.exports=e4});var X$=Y((YH,B$)=>{var k1=G(),g5=g(),{cursor:_1,erase:d5}=M(),{style:W0,figures:y5,clear:H$,lines:v5}=L(),u5=/[0-9]/,D0=($)=>$!==void 0,z$=($,Z)=>{let H=Math.pow(10,Z);return Math.round($*H)/H};class J$ extends g5{constructor($={}){super($);this.transform=W0.render($.style),this.msg=$.message,this.initial=D0($.initial)?$.initial:"",this.float=!!$.float,this.round=$.round||2,this.inc=$.increment||1,this.min=D0($.min)?$.min:-1/0,this.max=D0($.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=k1.gray(this.transform.render(`${this.initial}`)),this._value="";else this.placeholder=!1,this.rendered=this.transform.render(`${z$($,this.round)}`),this._value=z$($,this.round);this.fire()}get value(){return this._value}parse($){return this.float?parseFloat($):parseInt($)}valid($){return $==="-"||$==="."&&this.float||u5.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
|
-
`),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(
|
|
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(_1.down(v5(this.outputError,this.out.columns)-1)+H$(this.outputError,this.out.columns));this.out.write(H$(this.outputText,this.out.columns))}if(super.render(),this.outputError="",this.outputText=[W0.symbol(this.done,this.aborted),k1.bold(this.msg),W0.delimiter(this.done),!this.done||!this.done&&!this.placeholder?k1[this.color]().underline(this.rendered):this.rendered].join(" "),this.error)this.outputError+=this.errorMsg.split(`
|
|
71
71
|
`).reduce(($,Z,H)=>$+`
|
|
72
|
-
${H?" ":
|
|
72
|
+
${H?" ":y5.pointerSmall} ${k1.red().italic(Z)}`,"");this.out.write(d5.line+_1.to(0)+this.outputText+_1.save+this.outputError+_1.restore)}}B$.exports=J$});var K0=Y((WH,Y$)=>{var T=G(),{cursor:c5}=M(),m5=g(),{clear:Q$,figures:n,style:U$,wrap:n5,entriesToDisplay:l5}=L();class C$ extends m5{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=Q$("",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
76
|
${n.arrowUp}/${n.arrowDown}: Highlight option
|
|
77
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
|
|
80
|
-
`+
|
|
81
|
-
`+
|
|
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(
|
|
79
|
+
`:"")+" enter/return: Complete answer"}return""}renderOption($,Z,H,z){let J=(Z.selected?T.green(n.radioOn):n.radioOff)+" "+z+" ",B,X;if(Z.disabled)B=$===H?T.gray().underline(Z.title):T.strikethrough().gray(Z.title);else if(B=$===H?T.cyan().underline(Z.title):Z.title,$===H&&Z.description){if(X=` - ${Z.description}`,J.length+B.length+X.length>=this.out.columns||Z.description.split(/\r?\n/).length>1)X=`
|
|
80
|
+
`+n5(Z.description,{margin:J.length,width:this.out.columns})}return J+B+T.gray(X||"")}paginateOptions($){if($.length===0)return T.red("No matches for this query.");let{startIndex:Z,endIndex:H}=l5(this.cursor,$.length,this.optionsPerPage),z,J=[];for(let B=Z;B<H;B++){if(B===Z&&Z>0)z=n.arrowUp;else if(B===H-1&&H<$.length)z=n.arrowDown;else z=" ";J.push(this.renderOption(this.cursor,$[B],B,z))}return`
|
|
81
|
+
`+J.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 $=[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(c5.hide);super.render();let $=[U$.symbol(this.done,this.aborted),T.bold(this.msg),U$.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=Q$($,this.out.columns)}}Y$.exports=C$});var F$=Y((DH,M$)=>{var W1=G(),i5=g(),{erase:p5,cursor:W$}=M(),{style:G0,clear:D$,figures:M0,wrap:a5,entriesToDisplay:t5}=L(),K$=($,Z)=>$[Z]&&($[Z].value||$[Z].title||$[Z]),s5=($,Z)=>$[Z]&&($[Z].title||$[Z].value||$[Z]),o5=($,Z)=>{let H=$.findIndex((z)=>z.value===Z||z.title===Z);return H>-1?H:void 0};class G$ extends i5{constructor($={}){super($);this.msg=$.message,this.suggest=$.suggest,this.choices=$.choices,this.initial=typeof $.initial==="number"?$.initial:o5($.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=G0.render($.style),this.scale=this.transform.scale,this.render=this.render.bind(this),this.complete=this.complete.bind(this),this.clear=D$("",this.out.columns),this.complete(this.render),this.render()}set fallback($){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((J,B,X)=>({title:s5(X,B),value:K$(X,B),description:J.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
|
-
`),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
|
|
86
|
-
`+
|
|
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 J,B=H?M0.arrowUp:z?M0.arrowDown:" ",X=Z?W1.cyan().underline($.title):$.title;if(B=(Z?W1.cyan(M0.pointer)+" ":" ")+B,$.description){if(J=` - ${$.description}`,B.length+X.length+J.length>=this.out.columns||$.description.split(/\r?\n/).length>1)J=`
|
|
86
|
+
`+a5($.description,{margin:3,width:this.out.columns})}return B+" "+X+W1.gray(J||"")}render(){if(this.closed)return;if(this.firstRender)this.out.write(W$.hide);else this.out.write(D$(this.outputText,this.out.columns));super.render();let{startIndex:$,endIndex:Z}=t5(this.select,this.choices.length,this.limit);if(this.outputText=[G0.symbol(this.done,this.aborted,this.exited),W1.bold(this.msg),G0.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,J)=>this.renderOption(z,this.select===J+$,J===0&&$>0,J+$===Z-1&&Z<this.choices.length)).join(`
|
|
87
87
|
`);this.outputText+=`
|
|
88
|
-
`+(H||
|
|
88
|
+
`+(H||W1.gray(this.fallback.title))}this.out.write(p5.line+W$.to(0)+this.outputText)}}M$.exports=G$});var A$=Y((KH,V$)=>{var y=G(),{cursor:r5}=M(),e5=K0(),{clear:R$,style:O$,figures:$1}=L();class N$ extends e5{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
|
-
${
|
|
91
|
-
${
|
|
90
|
+
${$1.arrowUp}/${$1.arrowDown}: Highlight option
|
|
91
|
+
${$1.arrowLeft}/${$1.arrowRight}/[space]: Toggle selection
|
|
92
92
|
[a,b,c]/delete: Filter choices
|
|
93
93
|
enter/return: Complete answer
|
|
94
94
|
`}return""}renderCurrentInput(){return`
|
|
95
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(
|
|
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($1.radioOn):$1.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(r5.hide);super.render();let $=[O$.symbol(this.done,this.aborted),y.bold(this.msg),O$.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)}}V$.exports=N$});var j$=Y((GH,E$)=>{var I$=G(),$6=g(),{style:S$,clear:Z6}=L(),{erase:H6,cursor:q$}=M();class L$ extends $6{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(
|
|
99
|
-
`),
|
|
100
|
-
`),topLevelEnvVars:
|
|
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(q$.hide);else this.out.write(Z6(this.outputText,this.out.columns));super.render(),this.outputText=[S$.symbol(this.done,this.aborted),I$.bold(this.msg),S$.delimiter(this.done),this.done?this.value?this.yesMsg:this.noMsg:I$.gray(this.initialValue?this.yesOption:this.noOption)].join(" "),this.out.write(H6.line+q$.to(0)+this.outputText)}}E$.exports=L$});var P$=Y((MH,b$)=>{b$.exports={TextPrompt:Y4(),SelectPrompt:M4(),TogglePrompt:V4(),DatePrompt:Z$(),NumberPrompt:X$(),MultiselectPrompt:K0(),AutocompletePrompt:F$(),AutocompleteMultiselectPrompt:A$(),ConfirmPrompt:j$()}});var x$=Y((T$)=>{var I=T$,z6=P$(),f1=($)=>$;function x($,Z,H={}){return new Promise((z,J)=>{let B=new z6[$](Z),X=H.onAbort||f1,Q=H.onSubmit||f1,U=H.onExit||f1;B.on("state",Z.onState||f1),B.on("submit",(C)=>z(Q(C))),B.on("exit",(C)=>z(U(C))),B.on("abort",(C)=>J(X(C)))})}I.text=($)=>x("TextPrompt",$);I.password=($)=>{return $.style="password",I.text($)};I.invisible=($)=>{return $.style="invisible",I.text($)};I.number=($)=>x("NumberPrompt",$);I.date=($)=>x("DatePrompt",$);I.confirm=($)=>x("ConfirmPrompt",$);I.list=($)=>{let Z=$.separator||",";return x("TextPrompt",$,{onSubmit:(H)=>H.split(Z).map((z)=>z.trim())})};I.toggle=($)=>x("TogglePrompt",$);I.select=($)=>x("SelectPrompt",$);I.multiselect=($)=>{$.choices=[].concat($.choices||[]);let Z=(H)=>H.filter((z)=>z.selected).map((z)=>z.value);return x("MultiselectPrompt",$,{onAbort:Z,onSubmit:Z})};I.autocompleteMultiselect=($)=>{$.choices=[].concat($.choices||[]);let Z=(H)=>H.filter((z)=>z.selected).map((z)=>z.value);return x("AutocompleteMultiselectPrompt",$,{onAbort:Z,onSubmit:Z})};var J6=($,Z)=>Promise.resolve(Z.filter((H)=>H.title.slice(0,$.length).toLowerCase()===$.toLowerCase()));I.autocomplete=($)=>{return $.suggest=$.suggest||J6,$.choices=[].concat($.choices||[]),x("AutocompletePrompt",$)}});var k$=Y((RH,h$)=>{var F0=x$(),B6=["suggest","format","onState","validate","onRender","type"],w$=()=>{};async function l($=[],{onSubmit:Z=w$,onCancel:H=w$}={}){let z={},J=l._override||{};$=[].concat($);let B,X,Q,U,C,O,W=async(F,N,p=!1)=>{if(!p&&F.validate&&F.validate(N)!==!0)return;return F.format?await F.format(N,z):N};for(X of $){if({name:U,type:C}=X,typeof C==="function")C=await C(B,{...z},X),X.type=C;if(!C)continue;for(let F in X){if(B6.includes(F))continue;let N=X[F];X[F]=typeof N==="function"?await N(B,{...z},O):N}if(O=X,typeof X.message!=="string")throw Error("prompt message is required");if({name:U,type:C}=X,F0[C]===void 0)throw Error(`prompt type (${C}) is not defined`);if(J[X.name]!==void 0){if(B=await W(X,J[X.name]),B!==void 0){z[U]=B;continue}}try{B=l._injected?X6(l._injected,X.initial):await F0[C](X),z[U]=B=await W(X,B,!0),Q=await Z(X,B,z)}catch(F){Q=!await H(X,z)}if(Q)return z}return z}function X6($,Z){let H=$.shift();if(H instanceof Error)throw H;return H===void 0?Z:H}function Q6($){l._injected=(l._injected||[]).concat($)}function U6($){l._override=Object.assign({},$)}h$.exports=Object.assign(l,{prompt:l,prompts:F0,inject:Q6,override:U6})});var f$=Y((OH,_$)=>{function C6($){$=(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}_$.exports=C6("8.6.0")?c2():k$()});var R=v1(c1(),1);import{readFile as m6}from"node:fs/promises";import{basename as t$}from"node:path";import{fileURLToPath as n6}from"node:url";import{parseArgs as l6}from"node:util";function m1($){return $==="bun"||$==="npm"||$==="pnpm"||$==="yarn"}function O1(){let $=process.env.npm_config_user_agent;if(!$)return null;let Z=$.split(" ")[0];if(!Z)return null;let H=Z.split("/")[0];return m1(H)?H:null}function n1($){return $==="yarn"?"yarn":`${$} install`}function q0($,Z){if($==="npm")return`npm run ${Z}`;return`${$} ${Z}`}var p$=v1(c1(),1),i=v1(f$(),1);import{spawn as O6}from"node:child_process";import{mkdir as m$,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 N0,resolve as j6}from"node:path";import{mkdir as Y6,readdir as W6,readFile as D6,writeFile as K6}from"node:fs/promises";import{dirname as g$,join as R0,relative as G6}from"node:path";import{fileURLToPath as M6}from"node:url";function d$($,Z){if($.length===0)throw Error("assembleProviders: at least one provider required");let H=$.map((W)=>{let F=Z.find((N)=>N.key===W);if(!F)throw Error(`Unknown provider "${W}". Available: ${Z.map((N)=>N.key).join(", ")}`);return F}),z=H.some((W)=>W.key!==S),J=[...H.filter((W)=>W.key===S),...Z.filter((W)=>W.key!==S).filter((W)=>H.some((F)=>F.key===W.key))],B=['import { Spectrum } from "spectrum-ts";'],X=[],Q=[];for(let W of J)B.push(`import { ${W.import} } from "${W.path}";`),X.push(` // ${W.label}`),X.push(` ${W.import}.config(),`),Q.push(W.label);let U=B.join(`
|
|
99
|
+
`),C=[];if(z)C.push(" projectId: process.env.PROJECT_ID!,"),C.push(" projectSecret: process.env.PROJECT_SECRET!,");C.push(" providers: ["),C.push(...X),C.push(" ],");let O=z?["PROJECT_ID","PROJECT_SECRET"]:[];return{importsBlock:U,spectrumConfigBody:C.join(`
|
|
100
|
+
`),topLevelEnvVars:O,providerEnvVars:[],needsEnvFile:z,providersHuman:Q.join(", ")}}var F6=/\{\{([a-zA-Z][a-zA-Z0-9]*)\}\}/g;function R6($,Z){return $.replaceAll(F6,(H,z)=>{if(!(z in Z))throw Error(`Unknown template token: {{${z}}}`);return Z[z]??""})}function y$(){return R0(g$(M6(import.meta.url)),"..","templates","base")}async function v$($,Z,H,z){let J=await W6($,{withFileTypes:!0,recursive:!0});for(let B of J){if(!B.isFile())continue;let X=R0(B.parentPath,B.name),Q=G6($,X);if(!z.emitEnvFile&&Q==="env.example.tmpl")continue;let U=Q==="_gitignore"?".gitignore":Q;if(U.endsWith(".tmpl"))U=U.slice(0,-5);if(U==="env.example")U=".env.example";let C=R0(Z,U),O=await D6(X,"utf8"),W=B.name.endsWith(".tmpl")||Q==="_gitignore"?R6(O,H):O;await Y6(g$(C),{recursive:!0}),await K6(C,W)}}var S="terminal";class g1 extends Error{name="TargetExistsError"}class d1 extends Error{name="VersionResolutionError"}class y1 extends Error{name="InstallError";exitCode;constructor($,Z){super($);this.exitCode=Z}}var O0="^0.0.0",b6="spectrum",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 P6($){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 n$($){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(!P6(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 T6={step:($)=>process.stderr.write(`${$}
|
|
101
101
|
`),warn:($)=>process.stderr.write(`warn: ${$}
|
|
102
|
-
`),stream:($)=>process.stderr.write($)};async function
|
|
103
|
-
`))}await A6(
|
|
104
|
-
`),providersHuman:z.providersHuman,pmInstallCmd:
|
|
102
|
+
`),stream:($)=>process.stderr.write($)};async function l$($){let Z=$.logger??T6;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),J=$.packageManager??O1()??"bun";if(await x6(H))throw new g1(`Target directory is not empty: ${H}`);Z.step("Resolving spectrum-ts version…");let B=await h6($.resolveSpectrumTsVersion,Z),X=d$($.providers,$.manifest),Q=k6({name:z,spectrumTsVersion:B,assembly:X,pm:J}),U=L6(H);await m$(U,{recursive:!0});let C=await N6(N0(U,".create-spectrum-project-")),O=!1;try{if(Z.step("Copying template…"),await v$(y$(),C,Q,{emitEnvFile:X.needsEnvFile}),X.needsEnvFile){let u=[];for(let V of X.topLevelEnvVars)if(V==="PROJECT_ID"&&$.credentials)u.push(`PROJECT_ID=${$.credentials.projectId}`);else if(V==="PROJECT_SECRET"&&$.credentials)u.push(`PROJECT_SECRET=${$.credentials.projectSecret}`);else u.push(`${V}=`);for(let V of X.providerEnvVars)u.push(`${V}=`);await S6(N0(C,".env"),u.join(`
|
|
103
|
+
`))}await A6(C,H),O=!0}finally{if(!O)await I6(C,{recursive:!0,force:!0})}let W=$.skills!==!1?v6(H,$.skillsRunner??u6,Z):Promise.resolve(!1),F=!1;if($.install!==!1)Z.step(`Running ${n1(J)}…`),await d6(J,H,Z),F=!0;if($.skills!==!1)Z.step("Installing Spectrum skill…");let N=await W,p=!1;if($.git!==!1)Z.step("Initializing git…"),p=await y6(H,Z);return{targetDir:H,spectrumTsVersion:B,needsEnvFile:X.needsEnvFile,steps:{copied:!0,installed:F,skillsInstalled:N,gitInitialized:p}}}async function x6($){try{return(await V6($)).length>0}catch(Z){if(Z.code==="ENOENT")return!1;throw Z}}var w6="https://registry.npmjs.org/spectrum-ts";async function h6($,Z){try{if($)return await $();let H=await fetch(w6,{headers:{accept:"application/json"}});if(!H.ok)throw Error(`registry responded ${H.status}`);let J=(await H.json())["dist-tags"]?.latest;if(!J)throw Error("registry response missing dist-tags.latest");return`^${J}`}catch(H){if(Z.warn(`Could not resolve spectrum-ts version from npm (${H instanceof Error?H.message:String(H)}); using bundled fallback ${O0}.`),!O0)throw new d1("No spectrum-ts fallback version available");return O0}}function k6($){let{name:Z,spectrumTsVersion:H,assembly:z,pm:J}=$,B=[];if(z.topLevelEnvVars.length>0){B.push("# Top-level Spectrum credentials (from your Photon dashboard).");for(let Q of z.topLevelEnvVars)B.push(`${Q}=`)}if(z.providerEnvVars.length>0){if(B.length>0)B.push("");B.push("# WhatsApp Business (from Meta for Developers).");for(let Q of z.providerEnvVars)B.push(`${Q}=`)}let X=_6(J);return{name:Z,spectrumTsVersion:H,importsBlock:z.importsBlock,spectrumConfigBody:z.spectrumConfigBody,envBlock:B.join(`
|
|
104
|
+
`),providersHuman:z.providersHuman,pmInstallCmd:n1(J),pmStartCmd:q0(J,"start"),startScript:X.startScript,devScript:X.devScript,extraDevDeps:X.extraDevDeps,tsTypes:X.tsTypes,envSetupBlock:g6(z.topLevelEnvVars,z.providerEnvVars),envAgentBlock:z.needsEnvFile?f6:""}}function _6($){if($==="bun")return{startScript:"bun src/index.ts",devScript:"bun --watch src/index.ts",extraDevDeps:`,
|
|
105
|
+
"@types/bun": "latest"`,tsTypes:'"bun", "node"'};return{startScript:"tsx src/index.ts",devScript:"tsx watch src/index.ts",extraDevDeps:`,
|
|
106
|
+
"@types/node": "^22",
|
|
107
|
+
"tsx": "^4"`,tsTypes:'"node"'}}var f6="## Environment\n\nThis project reads secrets from `.env` (gitignored). **Do not read, write, or echo `.env`** — it contains credentials.\n\nIf startup fails with an authentication error, tell the user to verify their `PROJECT_ID` / `PROJECT_SECRET` at the [Photon dashboard](https://app.photon.codes).\n\n";function g6($,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
108
|
`)}
|
|
106
|
-
`}function
|
|
107
|
-
${
|
|
108
|
-
`),process.exit(130)};async function
|
|
109
|
+
`}function D1($,Z,H,z){return new Promise((J,B)=>{let Q=O6($,Z,{...H,stdio:z?["ignore","pipe","pipe"]:["ignore","ignore","ignore"]});if(z)Q.stdout?.setEncoding("utf8"),Q.stdout?.on("data",z),Q.stderr?.setEncoding("utf8"),Q.stderr?.on("data",z);Q.once("error",B),Q.once("close",(U)=>J(U??-1))})}async function d6($,Z,H){let z=$==="yarn"?[]:["install"],J=await D1($,z,{cwd:Z},(B)=>H.stream(B));if(J!==0)throw new y1(`\`${$} ${z.join(" ")}\` exited with code ${J}`,J)}async function y6($,Z){try{if(await D1("git",["init","-b","main"],{cwd:$})!==0)return Z.warn("git init failed; skipping git setup."),!1;if(await D1("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 D1("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}}async function v6($,Z,H){try{await m$(N0($,".claude"),{recursive:!0});let J=await Z(["-y","skills","add","photon-hq/skills","--skill",b6,"--agent","*","-y"],$);if(J!==0)return H.warn(`Spectrum skill install exited ${J}; skipping.`),!1;return!0}catch(z){return H.warn(`Spectrum skill install unavailable: ${z instanceof Error?z.message:String(z)}`),!1}}var u6=($,Z)=>{let H=typeof process.versions.bun==="string"?"bunx":"npx";return D1(H,$,{cwd:Z})};var s=()=>{process.stderr.write(`
|
|
110
|
+
${p$.default.dim("Cancelled.")}
|
|
111
|
+
`),process.exit(130)};async function a$($,Z){let H=$.targetDir??(await i.default({type:"text",name:"value",message:"Project directory",initial:"my-spectrum-app"},{onCancel:s})).value,z=$.providers??await c6(Z),J=O1()??"bun",B=["bun","npm","pnpm","yarn"],X=$.packageManager??(await i.default({type:"select",name:"value",message:"Package manager",choices:B.map((O)=>({title:O,value:O})),initial:B.indexOf(J)},{onCancel:s})).value,Q=$.install??(await i.default({type:"confirm",name:"value",message:"Install dependencies?",initial:!0},{onCancel:s})).value,U=$.skills??(await i.default({type:"confirm",name:"value",message:"Install Spectrum skill for AI agents?",initial:!0},{onCancel:s})).value,C=$.git??(await i.default({type:"confirm",name:"value",message:"Initialize git?",initial:!0},{onCancel:s})).value;return{targetDir:H,providers:z,packageManager:X,manifest:Z,install:Q,git:C,skills:U}}async function c6($){let Z=$.find((J)=>J.key===S),H=$.filter((J)=>J.key!==S);if(!Z)return i$(H);if(H.length===0)return[Z.key];let{kind:z}=await i.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:s});if(z==="terminal")return[Z.key];return i$(H)}async function i$($){let{values:Z}=await i.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:s});return Z}var v={ok:R.default.green("✓"),err:R.default.red("✗"),arrow:R.default.dim("→"),dot:R.default.dim("·")},i6=new Set(["slack"]);function p6($){return $.filter((Z)=>!i6.has(Z.key))}async function a6(){let{values:$,positionals:Z}=l6({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"},"no-skills":{type:"boolean"},yes:{type:"boolean",short:"y"},verbose:{type:"boolean"},help:{type:"boolean",short:"h"},version:{type:"boolean"}},allowPositionals:!0,strict:!0}),H=await Z8();if($.help)return $8(),0;if($.version)return process.stdout.write(`create-spectrum-project ${H}
|
|
109
112
|
`),0;process.stdout.write(`
|
|
110
|
-
${
|
|
113
|
+
${R.default.bold("create-spectrum-project")} ${R.default.dim(`v${H}`)}
|
|
111
114
|
|
|
112
|
-
`);let z=await
|
|
113
|
-
`)},stream:()=>{}}),
|
|
114
|
-
`);let
|
|
115
|
-
`),
|
|
116
|
-
${v.arrow} ${
|
|
115
|
+
`);let z=await n$({step:()=>{},warn:(W)=>{process.stderr.write(`${R.default.yellow("!")} ${W}
|
|
116
|
+
`)},stream:()=>{}}),J=p6(z),B=t6($,Z,J),X=$.yes?o6(B,J):await a$(B,J);if(!$.yes)process.stdout.write(`
|
|
117
|
+
`);let Q=Date.now(),U=e6(),C;try{C=await l$({...X,manifest:z,logger:{step:(W)=>U.text(W),warn:(W)=>{U.suspend(),process.stderr.write(`${R.default.yellow("!")} ${W}
|
|
118
|
+
`),U.resume()},stream:(W)=>{if($.verbose)process.stderr.write(W)}}})}catch(W){throw U.stop(),W}let O=((Date.now()-Q)/1000).toFixed(1);return U.stop(`${v.ok} Created ${R.default.cyan(t$(C.targetDir))} ${v.dot} ${R.default.bold(`spectrum-ts ${C.spectrumTsVersion}`)} ${R.default.dim(`(${O}s)`)}`),r6(C,X),process.stdout.write(`
|
|
119
|
+
${v.arrow} ${R.default.dim("Docs:")} ${R.default.cyan("https://photon.codes/docs/spectrum-ts")}
|
|
117
120
|
|
|
118
|
-
`),0}function
|
|
119
|
-
${
|
|
120
|
-
`);for(let
|
|
121
|
-
`)}}function
|
|
122
|
-
`)}};let $=["⠋","⠙","⠹","⠸","⠼","⠴","⠦","⠧","⠇","⠏"],Z=0,H="Working",z=!1,
|
|
123
|
-
`)}}}function
|
|
124
|
-
`))}async function
|
|
125
|
-
`),process.exit(2)}try{process.exitCode=await
|
|
121
|
+
`),0}function t6($,Z,H){let z={};if(Z[0])z.targetDir=Z[0];if(typeof $.providers==="string")z.providers=s6($.providers,H);if(typeof $.pm==="string"){if(!m1($.pm))K1("--pm must be one of bun, npm, pnpm, yarn");z.packageManager=$.pm}if($["no-install"])z.install=!1;if($["no-git"])z.git=!1;if($["no-skills"])z.skills=!1;return z}function s6($,Z){let H=Z.map((J)=>J.key),z=$.split(",").map((J)=>J.trim()).filter(Boolean);for(let J of z)if(!H.includes(J))K1(`Unknown provider: ${J}. Available: ${H.join(", ")}`);if(z.length===0)K1("--providers must list at least one provider");if(z.includes(S)&&z.length>1)K1(`${S} is a dev-only TUI and can't be mixed with platform providers. Pick ${S} on its own, or pick one or more of: ${H.filter((J)=>J!==S).join(", ")}.`);return z}function o6($,Z){let H=Z.find((J)=>J.key!==S)?.key??Z[0]?.key;if(!H)K1("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,skills:$.skills??!0}}function r6($,Z){let H=Z.packageManager??"bun",J=[{cmd:`cd ${t$($.targetDir)}`}];if(!$.steps.installed)J.push({cmd:H==="yarn"?"yarn":`${H} install`});if($.needsEnvFile)J.push({note:"fill in .env with your credentials"});if(J.push({cmd:H==="npm"?"npm run start":`${H} start`}),Z.skills!==!1&&!$.steps.skillsInstalled){let B=typeof process.versions.bun==="string"?"bunx":"npx";J.push({note:`spectrum skill install failed; retry: ${B} -y skills add photon-hq/skills --skill spectrum --agent '*' -y`})}process.stdout.write(`
|
|
122
|
+
${R.default.bold("Next steps")}
|
|
123
|
+
`);for(let B of J){let X="cmd"in B?` ${R.default.dim("$")} ${B.cmd}`:` ${R.default.dim(`# ${B.note}`)}`;process.stdout.write(`${X}
|
|
124
|
+
`)}}function e6(){if(!process.stderr.isTTY)return{text:()=>{},suspend:()=>{},resume:()=>{},stop:(X)=>{if(X)process.stderr.write(`${X}
|
|
125
|
+
`)}};let $=["⠋","⠙","⠹","⠸","⠼","⠴","⠦","⠧","⠇","⠏"],Z=0,H="Working",z=!1,J=()=>{if(z)return;process.stderr.write(`\r\x1B[K${R.default.dim($[Z++%$.length])} ${H}`)},B=setInterval(J,80);return J(),{text:(X)=>{H=X,J()},suspend:()=>{z=!0,process.stderr.write("\r\x1B[K")},resume:()=>{z=!1,J()},stop:(X)=>{if(clearInterval(B),process.stderr.write("\r\x1B[K"),X)process.stderr.write(`${X}
|
|
126
|
+
`)}}}function $8(){let $=(J)=>R.default.cyan(J),Z=(J)=>R.default.dim(J),H=(J)=>J.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($("--no-skills")),"Skip Spectrum skill install"],[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(["",` ${R.default.bold("Usage")}`,` ${Z("$")} create-spectrum-project ${Z("[directory] [options]")}`,"",` ${R.default.bold("Options")}`,...z.map(([J,B])=>` ${J}${Z(B)}`),""].join(`
|
|
127
|
+
`))}async function Z8(){try{let $=n6(new URL("../package.json",import.meta.url));return JSON.parse(await m6($,"utf8")).version??"0.0.0"}catch{return"0.0.0"}}function K1($){process.stderr.write(`${v.err} ${$}
|
|
128
|
+
`),process.exit(2)}try{process.exitCode=await a6()}catch($){if($ instanceof g1)process.stderr.write(`
|
|
126
129
|
${v.err} ${$.message}
|
|
127
|
-
`),process.exitCode=1;else if($ instanceof
|
|
130
|
+
`),process.exitCode=1;else if($ instanceof y1)process.stderr.write(`
|
|
128
131
|
${v.err} Install failed (exit ${$.exitCode}). cd into the project and run install manually to retry.
|
|
129
|
-
`),process.exitCode=1;else if($ instanceof
|
|
132
|
+
`),process.exitCode=1;else if($ instanceof d1)process.stderr.write(`
|
|
130
133
|
${v.err} ${$.message}
|
|
131
134
|
`),process.exitCode=1;else if($ instanceof Error){if(process.stderr.write(`
|
|
132
135
|
${v.err} ${$.message}
|
package/dist/scaffold.js
CHANGED
|
@@ -147,6 +147,7 @@ class InstallError extends Error {
|
|
|
147
147
|
}
|
|
148
148
|
}
|
|
149
149
|
var FALLBACK_SPECTRUM_TS_VERSION = "^0.0.0";
|
|
150
|
+
var SPECTRUM_SKILL = "spectrum";
|
|
150
151
|
var MANIFEST_URL = "https://unpkg.com/spectrum-ts/manifest.json";
|
|
151
152
|
var FALLBACK_MANIFEST = [
|
|
152
153
|
{
|
|
@@ -259,12 +260,17 @@ async function scaffold(options) {
|
|
|
259
260
|
await rm(tmp, { recursive: true, force: true });
|
|
260
261
|
}
|
|
261
262
|
}
|
|
263
|
+
const skillsPromise = options.skills !== false ? trySkillsInstall(targetDir, options.skillsRunner ?? defaultSkillsRunner, logger) : Promise.resolve(false);
|
|
262
264
|
let installed = false;
|
|
263
265
|
if (options.install !== false) {
|
|
264
266
|
logger.step(`Running ${installCmd(pm)}…`);
|
|
265
267
|
await runInstall(pm, targetDir, logger);
|
|
266
268
|
installed = true;
|
|
267
269
|
}
|
|
270
|
+
if (options.skills !== false) {
|
|
271
|
+
logger.step("Installing Spectrum skill…");
|
|
272
|
+
}
|
|
273
|
+
const skillsInstalled = await skillsPromise;
|
|
268
274
|
let gitInitialized = false;
|
|
269
275
|
if (options.git !== false) {
|
|
270
276
|
logger.step("Initializing git…");
|
|
@@ -274,7 +280,7 @@ async function scaffold(options) {
|
|
|
274
280
|
targetDir,
|
|
275
281
|
spectrumTsVersion,
|
|
276
282
|
needsEnvFile: assembly.needsEnvFile,
|
|
277
|
-
steps: { copied: true, installed, gitInitialized }
|
|
283
|
+
steps: { copied: true, installed, skillsInstalled, gitInitialized }
|
|
278
284
|
};
|
|
279
285
|
}
|
|
280
286
|
async function isNonEmptyDir(path) {
|
|
@@ -332,6 +338,7 @@ function buildTokens(args) {
|
|
|
332
338
|
envLines.push(`${k}=`);
|
|
333
339
|
}
|
|
334
340
|
}
|
|
341
|
+
const runtime = pmRuntimeTokens(pm);
|
|
335
342
|
return {
|
|
336
343
|
name,
|
|
337
344
|
spectrumTsVersion,
|
|
@@ -342,9 +349,40 @@ function buildTokens(args) {
|
|
|
342
349
|
providersHuman: assembly.providersHuman,
|
|
343
350
|
pmInstallCmd: installCmd(pm),
|
|
344
351
|
pmStartCmd: runScriptCmd(pm, "start"),
|
|
345
|
-
|
|
352
|
+
startScript: runtime.startScript,
|
|
353
|
+
devScript: runtime.devScript,
|
|
354
|
+
extraDevDeps: runtime.extraDevDeps,
|
|
355
|
+
tsTypes: runtime.tsTypes,
|
|
356
|
+
envSetupBlock: buildEnvSetupBlock(assembly.topLevelEnvVars, assembly.providerEnvVars),
|
|
357
|
+
envAgentBlock: assembly.needsEnvFile ? ENV_AGENT_BLOCK : ""
|
|
358
|
+
};
|
|
359
|
+
}
|
|
360
|
+
function pmRuntimeTokens(pm) {
|
|
361
|
+
if (pm === "bun") {
|
|
362
|
+
return {
|
|
363
|
+
startScript: "bun src/index.ts",
|
|
364
|
+
devScript: "bun --watch src/index.ts",
|
|
365
|
+
extraDevDeps: `,
|
|
366
|
+
"@types/bun": "latest"`,
|
|
367
|
+
tsTypes: '"bun", "node"'
|
|
368
|
+
};
|
|
369
|
+
}
|
|
370
|
+
return {
|
|
371
|
+
startScript: "tsx src/index.ts",
|
|
372
|
+
devScript: "tsx watch src/index.ts",
|
|
373
|
+
extraDevDeps: `,
|
|
374
|
+
"@types/node": "^22",
|
|
375
|
+
"tsx": "^4"`,
|
|
376
|
+
tsTypes: '"node"'
|
|
346
377
|
};
|
|
347
378
|
}
|
|
379
|
+
var ENV_AGENT_BLOCK = `## Environment
|
|
380
|
+
|
|
381
|
+
This project reads secrets from \`.env\` (gitignored). **Do not read, write, or echo \`.env\`** — it contains credentials.
|
|
382
|
+
|
|
383
|
+
If startup fails with an authentication error, tell the user to verify their \`PROJECT_ID\` / \`PROJECT_SECRET\` at the [Photon dashboard](https://app.photon.codes).
|
|
384
|
+
|
|
385
|
+
`;
|
|
348
386
|
function buildEnvSetupBlock(top, provider) {
|
|
349
387
|
if (top.length === 0 && provider.length === 0) {
|
|
350
388
|
return "";
|
|
@@ -429,6 +467,35 @@ async function tryGitInit(cwd, logger) {
|
|
|
429
467
|
return false;
|
|
430
468
|
}
|
|
431
469
|
}
|
|
470
|
+
async function trySkillsInstall(cwd, runner, logger) {
|
|
471
|
+
try {
|
|
472
|
+
await mkdir2(join2(cwd, ".claude"), { recursive: true });
|
|
473
|
+
const args = [
|
|
474
|
+
"-y",
|
|
475
|
+
"skills",
|
|
476
|
+
"add",
|
|
477
|
+
"photon-hq/skills",
|
|
478
|
+
"--skill",
|
|
479
|
+
SPECTRUM_SKILL,
|
|
480
|
+
"--agent",
|
|
481
|
+
"*",
|
|
482
|
+
"-y"
|
|
483
|
+
];
|
|
484
|
+
const exit = await runner(args, cwd);
|
|
485
|
+
if (exit !== 0) {
|
|
486
|
+
logger.warn(`Spectrum skill install exited ${exit}; skipping.`);
|
|
487
|
+
return false;
|
|
488
|
+
}
|
|
489
|
+
return true;
|
|
490
|
+
} catch (err) {
|
|
491
|
+
logger.warn(`Spectrum skill install unavailable: ${err instanceof Error ? err.message : String(err)}`);
|
|
492
|
+
return false;
|
|
493
|
+
}
|
|
494
|
+
}
|
|
495
|
+
var defaultSkillsRunner = (args, cwd) => {
|
|
496
|
+
const runner = typeof process.versions.bun === "string" ? "bunx" : "npx";
|
|
497
|
+
return spawnExit(runner, args, { cwd });
|
|
498
|
+
};
|
|
432
499
|
export {
|
|
433
500
|
scaffold,
|
|
434
501
|
fetchManifest,
|
package/package.json
CHANGED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
# {{name}} — agent instructions
|
|
2
|
+
|
|
3
|
+
This is a [Spectrum](https://photon.codes/docs/spectrum-ts) app, pinned to `spectrum-ts@{{spectrumTsVersion}}`. The entry point is `src/index.ts`, which configures the {{providersHuman}} provider(s) and runs the echo loop.
|
|
4
|
+
|
|
5
|
+
## Working in this project
|
|
6
|
+
|
|
7
|
+
- Run the app with `{{pmStartCmd}}`.
|
|
8
|
+
- Add providers by importing them in `src/index.ts` and listing them in the `Spectrum({ providers: [...] })` config.
|
|
9
|
+
- Outgoing message content uses the builders documented in the skill (text, attachment, voice, contact, richlink, poll, group, custom).
|
|
10
|
+
|
|
11
|
+
{{envAgentBlock}}## Spectrum SDK reference
|
|
12
|
+
|
|
13
|
+
This project includes the `spectrum` skill from [`photon-hq/skills`](https://github.com/photon-hq/skills). Your agent should auto-discover it. If it doesn't, or if you switch agents, install for your agent with:
|
|
14
|
+
|
|
15
|
+
```sh
|
|
16
|
+
npx skills add photon-hq/skills --skill spectrum --agent <your-agent>
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
(Use `--agent '*'` to install for all supported agents.)
|
|
20
|
+
|
|
21
|
+
## See also
|
|
22
|
+
|
|
23
|
+
- [Spectrum docs](https://photon.codes/docs/spectrum-ts)
|
|
24
|
+
- [`spectrum-ts` on GitHub](https://github.com/photon-hq/spectrum-ts)
|
|
@@ -4,14 +4,13 @@
|
|
|
4
4
|
"private": true,
|
|
5
5
|
"type": "module",
|
|
6
6
|
"scripts": {
|
|
7
|
-
"start": "
|
|
8
|
-
"dev": "
|
|
7
|
+
"start": "{{startScript}}",
|
|
8
|
+
"dev": "{{devScript}}"
|
|
9
9
|
},
|
|
10
10
|
"dependencies": {
|
|
11
11
|
"spectrum-ts": "{{spectrumTsVersion}}"
|
|
12
12
|
},
|
|
13
13
|
"devDependencies": {
|
|
14
|
-
"typescript": "^5"
|
|
15
|
-
"@types/bun": "latest"
|
|
14
|
+
"typescript": "^5"{{extraDevDeps}}
|
|
16
15
|
}
|
|
17
16
|
}
|