@jakejarvis/acai 0.1.0 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cli.mjs +3117 -93
- package/package.json +2 -1
package/dist/cli.mjs
CHANGED
|
@@ -1,111 +1,3135 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import e,{stdin as t,stdout as n}from"process";import*as r from"readline";import i from"readline";import{ReadStream as a}from"tty";import{existsSync as o,lstatSync as s,mkdtempSync as c,readdirSync as l,rmSync as u,writeFileSync as d}from"fs";import{dirname as f,join as p}from"path";import{parseArgs as m,stripVTControlCharacters as h}from"util";import{spawn as g}from"child_process";import{tmpdir as _}from"os";var v=Object.create,y=Object.defineProperty,b=Object.getOwnPropertyDescriptor,x=Object.getOwnPropertyNames,S=Object.getPrototypeOf,C=Object.prototype.hasOwnProperty,w=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),ee=(e,t,n,r)=>{if(t&&typeof t==`object`||typeof t==`function`)for(var i=x(t),a=0,o=i.length,s;a<o;a++)s=i[a],!C.call(e,s)&&s!==n&&y(e,s,{get:(e=>t[e]).bind(null,s),enumerable:!(r=b(t,s))||r.enumerable});return e},te=(e,t,n)=>(n=e==null?{}:v(S(e)),ee(t||!e||!e.__esModule?y(n,`default`,{value:e,enumerable:!0}):n,e)),ne=w(((e,t)=>{let n=process||{},r=n.argv||[],i=n.env||{},a=!(i.NO_COLOR||r.includes(`--no-color`))&&(!!i.FORCE_COLOR||r.includes(`--color`)||n.platform===`win32`||(n.stdout||{}).isTTY&&i.TERM!==`dumb`||!!i.CI),o=(e,t,n=e)=>r=>{let i=``+r,a=i.indexOf(t,e.length);return~a?e+s(i,t,n,a)+t:e+i+t},s=(e,t,n,r)=>{let i=``,a=0;do i+=e.substring(a,r)+n,a=r+t.length,r=e.indexOf(t,a);while(~r);return i+e.substring(a)},c=(e=a)=>{let t=e?o:()=>String;return{isColorSupported:e,reset:t(`\x1B[0m`,`\x1B[0m`),bold:t(`\x1B[1m`,`\x1B[22m`,`\x1B[22m\x1B[1m`),dim:t(`\x1B[2m`,`\x1B[22m`,`\x1B[22m\x1B[2m`),italic:t(`\x1B[3m`,`\x1B[23m`),underline:t(`\x1B[4m`,`\x1B[24m`),inverse:t(`\x1B[7m`,`\x1B[27m`),hidden:t(`\x1B[8m`,`\x1B[28m`),strikethrough:t(`\x1B[9m`,`\x1B[29m`),black:t(`\x1B[30m`,`\x1B[39m`),red:t(`\x1B[31m`,`\x1B[39m`),green:t(`\x1B[32m`,`\x1B[39m`),yellow:t(`\x1B[33m`,`\x1B[39m`),blue:t(`\x1B[34m`,`\x1B[39m`),magenta:t(`\x1B[35m`,`\x1B[39m`),cyan:t(`\x1B[36m`,`\x1B[39m`),white:t(`\x1B[37m`,`\x1B[39m`),gray:t(`\x1B[90m`,`\x1B[39m`),bgBlack:t(`\x1B[40m`,`\x1B[49m`),bgRed:t(`\x1B[41m`,`\x1B[49m`),bgGreen:t(`\x1B[42m`,`\x1B[49m`),bgYellow:t(`\x1B[43m`,`\x1B[49m`),bgBlue:t(`\x1B[44m`,`\x1B[49m`),bgMagenta:t(`\x1B[45m`,`\x1B[49m`),bgCyan:t(`\x1B[46m`,`\x1B[49m`),bgWhite:t(`\x1B[47m`,`\x1B[49m`),blackBright:t(`\x1B[90m`,`\x1B[39m`),redBright:t(`\x1B[91m`,`\x1B[39m`),greenBright:t(`\x1B[92m`,`\x1B[39m`),yellowBright:t(`\x1B[93m`,`\x1B[39m`),blueBright:t(`\x1B[94m`,`\x1B[39m`),magentaBright:t(`\x1B[95m`,`\x1B[39m`),cyanBright:t(`\x1B[96m`,`\x1B[39m`),whiteBright:t(`\x1B[97m`,`\x1B[39m`),bgBlackBright:t(`\x1B[100m`,`\x1B[49m`),bgRedBright:t(`\x1B[101m`,`\x1B[49m`),bgGreenBright:t(`\x1B[102m`,`\x1B[49m`),bgYellowBright:t(`\x1B[103m`,`\x1B[49m`),bgBlueBright:t(`\x1B[104m`,`\x1B[49m`),bgMagentaBright:t(`\x1B[105m`,`\x1B[49m`),bgCyanBright:t(`\x1B[106m`,`\x1B[49m`),bgWhiteBright:t(`\x1B[107m`,`\x1B[49m`)}};t.exports=c(),t.exports.createColors=c})),re=w(((e,t)=>{let n={to(e,t){return t?`[${t+1};${e+1}H`:`[${e+1}G`},move(e,t){let n=``;return e<0?n+=`[${-e}D`:e>0&&(n+=`[${e}C`),t<0?n+=`[${-t}A`:t>0&&(n+=`[${t}B`),n},up:(e=1)=>`[${e}A`,down:(e=1)=>`[${e}B`,forward:(e=1)=>`[${e}C`,backward:(e=1)=>`[${e}D`,nextLine:(e=1)=>`\x1B[E`.repeat(e),prevLine:(e=1)=>`\x1B[F`.repeat(e),left:`\x1B[G`,hide:`\x1B[?25l`,show:`\x1B[?25h`,save:`\x1B7`,restore:`\x1B8`};t.exports={cursor:n,scroll:{up:(e=1)=>`\x1B[S`.repeat(e),down:(e=1)=>`\x1B[T`.repeat(e)},erase:{screen:`\x1B[2J`,up:(e=1)=>`\x1B[1J`.repeat(e),down:(e=1)=>`\x1B[J`.repeat(e),line:`\x1B[2K`,lineEnd:`\x1B[K`,lineStart:`\x1B[1K`,lines(e){let t=``;for(let r=0;r<e;r++)t+=this.line+(r<e-1?n.up():``);return e&&(t+=n.left),t}},beep:`\x07`}})),T=te(ne(),1),E=re();function D(e,t,n){if(!n.some(e=>!e.disabled))return e;let r=e+t,i=Math.max(n.length-1,0),a=r<0?i:r>i?0:r;return n[a].disabled?D(a,t<0?-1:1,n):a}const ie=e=>e===161||e===164||e===167||e===168||e===170||e===173||e===174||e>=176&&e<=180||e>=182&&e<=186||e>=188&&e<=191||e===198||e===208||e===215||e===216||e>=222&&e<=225||e===230||e>=232&&e<=234||e===236||e===237||e===240||e===242||e===243||e>=247&&e<=250||e===252||e===254||e===257||e===273||e===275||e===283||e===294||e===295||e===299||e>=305&&e<=307||e===312||e>=319&&e<=322||e===324||e>=328&&e<=331||e===333||e===338||e===339||e===358||e===359||e===363||e===462||e===464||e===466||e===468||e===470||e===472||e===474||e===476||e===593||e===609||e===708||e===711||e>=713&&e<=715||e===717||e===720||e>=728&&e<=731||e===733||e===735||e>=768&&e<=879||e>=913&&e<=929||e>=931&&e<=937||e>=945&&e<=961||e>=963&&e<=969||e===1025||e>=1040&&e<=1103||e===1105||e===8208||e>=8211&&e<=8214||e===8216||e===8217||e===8220||e===8221||e>=8224&&e<=8226||e>=8228&&e<=8231||e===8240||e===8242||e===8243||e===8245||e===8251||e===8254||e===8308||e===8319||e>=8321&&e<=8324||e===8364||e===8451||e===8453||e===8457||e===8467||e===8470||e===8481||e===8482||e===8486||e===8491||e===8531||e===8532||e>=8539&&e<=8542||e>=8544&&e<=8555||e>=8560&&e<=8569||e===8585||e>=8592&&e<=8601||e===8632||e===8633||e===8658||e===8660||e===8679||e===8704||e===8706||e===8707||e===8711||e===8712||e===8715||e===8719||e===8721||e===8725||e===8730||e>=8733&&e<=8736||e===8739||e===8741||e>=8743&&e<=8748||e===8750||e>=8756&&e<=8759||e===8764||e===8765||e===8776||e===8780||e===8786||e===8800||e===8801||e>=8804&&e<=8807||e===8810||e===8811||e===8814||e===8815||e===8834||e===8835||e===8838||e===8839||e===8853||e===8857||e===8869||e===8895||e===8978||e>=9312&&e<=9449||e>=9451&&e<=9547||e>=9552&&e<=9587||e>=9600&&e<=9615||e>=9618&&e<=9621||e===9632||e===9633||e>=9635&&e<=9641||e===9650||e===9651||e===9654||e===9655||e===9660||e===9661||e===9664||e===9665||e>=9670&&e<=9672||e===9675||e>=9678&&e<=9681||e>=9698&&e<=9701||e===9711||e===9733||e===9734||e===9737||e===9742||e===9743||e===9756||e===9758||e===9792||e===9794||e===9824||e===9825||e>=9827&&e<=9829||e>=9831&&e<=9834||e===9836||e===9837||e===9839||e===9886||e===9887||e===9919||e>=9926&&e<=9933||e>=9935&&e<=9939||e>=9941&&e<=9953||e===9955||e===9960||e===9961||e>=9963&&e<=9969||e===9972||e>=9974&&e<=9977||e===9979||e===9980||e===9982||e===9983||e===10045||e>=10102&&e<=10111||e>=11094&&e<=11097||e>=12872&&e<=12879||e>=57344&&e<=63743||e>=65024&&e<=65039||e===65533||e>=127232&&e<=127242||e>=127248&&e<=127277||e>=127280&&e<=127337||e>=127344&&e<=127373||e===127375||e===127376||e>=127387&&e<=127404||e>=917760&&e<=917999||e>=983040&&e<=1048573||e>=1048576&&e<=1114109,ae=e=>e===12288||e>=65281&&e<=65376||e>=65504&&e<=65510,oe=e=>e>=4352&&e<=4447||e===8986||e===8987||e===9001||e===9002||e>=9193&&e<=9196||e===9200||e===9203||e===9725||e===9726||e===9748||e===9749||e>=9800&&e<=9811||e===9855||e===9875||e===9889||e===9898||e===9899||e===9917||e===9918||e===9924||e===9925||e===9934||e===9940||e===9962||e===9970||e===9971||e===9973||e===9978||e===9981||e===9989||e===9994||e===9995||e===10024||e===10060||e===10062||e>=10067&&e<=10069||e===10071||e>=10133&&e<=10135||e===10160||e===10175||e===11035||e===11036||e===11088||e===11093||e>=11904&&e<=11929||e>=11931&&e<=12019||e>=12032&&e<=12245||e>=12272&&e<=12287||e>=12289&&e<=12350||e>=12353&&e<=12438||e>=12441&&e<=12543||e>=12549&&e<=12591||e>=12593&&e<=12686||e>=12688&&e<=12771||e>=12783&&e<=12830||e>=12832&&e<=12871||e>=12880&&e<=19903||e>=19968&&e<=42124||e>=42128&&e<=42182||e>=43360&&e<=43388||e>=44032&&e<=55203||e>=63744&&e<=64255||e>=65040&&e<=65049||e>=65072&&e<=65106||e>=65108&&e<=65126||e>=65128&&e<=65131||e>=94176&&e<=94180||e===94192||e===94193||e>=94208&&e<=100343||e>=100352&&e<=101589||e>=101632&&e<=101640||e>=110576&&e<=110579||e>=110581&&e<=110587||e===110589||e===110590||e>=110592&&e<=110882||e===110898||e>=110928&&e<=110930||e===110933||e>=110948&&e<=110951||e>=110960&&e<=111355||e===126980||e===127183||e===127374||e>=127377&&e<=127386||e>=127488&&e<=127490||e>=127504&&e<=127547||e>=127552&&e<=127560||e===127568||e===127569||e>=127584&&e<=127589||e>=127744&&e<=127776||e>=127789&&e<=127797||e>=127799&&e<=127868||e>=127870&&e<=127891||e>=127904&&e<=127946||e>=127951&&e<=127955||e>=127968&&e<=127984||e===127988||e>=127992&&e<=128062||e===128064||e>=128066&&e<=128252||e>=128255&&e<=128317||e>=128331&&e<=128334||e>=128336&&e<=128359||e===128378||e===128405||e===128406||e===128420||e>=128507&&e<=128591||e>=128640&&e<=128709||e===128716||e>=128720&&e<=128722||e>=128725&&e<=128727||e>=128732&&e<=128735||e===128747||e===128748||e>=128756&&e<=128764||e>=128992&&e<=129003||e===129008||e>=129292&&e<=129338||e>=129340&&e<=129349||e>=129351&&e<=129535||e>=129648&&e<=129660||e>=129664&&e<=129672||e>=129680&&e<=129725||e>=129727&&e<=129733||e>=129742&&e<=129755||e>=129760&&e<=129768||e>=129776&&e<=129784||e>=131072&&e<=196605||e>=196608&&e<=262141,O=/[\u001b\u009b][[()#;?]*(?:[0-9]{1,4}(?:;[0-9]{0,4})*)?[0-9A-ORZcf-nqry=><]/y,k=/[\x00-\x08\x0A-\x1F\x7F-\x9F]{1,1000}/y,A=/\t{1,1000}/y,se=/[\u{1F1E6}-\u{1F1FF}]{2}|\u{1F3F4}[\u{E0061}-\u{E007A}]{2}[\u{E0030}-\u{E0039}\u{E0061}-\u{E007A}]{1,3}\u{E007F}|(?:\p{Emoji}\uFE0F\u20E3?|\p{Emoji_Modifier_Base}\p{Emoji_Modifier}?|\p{Emoji_Presentation})(?:\u200D(?:\p{Emoji_Modifier_Base}\p{Emoji_Modifier}?|\p{Emoji_Presentation}|\p{Emoji}\uFE0F\u20E3?))*/uy,j=/(?:[\x20-\x7E\xA0-\xFF](?!\uFE0F)){1,1000}/y,ce=/\p{M}+/gu,le={limit:1/0,ellipsis:``},ue=(e,t={},n={})=>{let r=t.limit??1/0,i=t.ellipsis??``,a=t?.ellipsisWidth??(i?ue(i,le,n).width:0),o=n.ansiWidth??0,s=n.controlWidth??0,c=n.tabWidth??8,l=n.ambiguousWidth??1,u=n.emojiWidth??2,d=n.fullWidthWidth??2,f=n.regularWidth??1,p=n.wideWidth??2,m=0,h=0,g=e.length,_=0,v=!1,y=g,b=Math.max(0,r-a),x=0,S=0,C=0,w=0;t:for(;;){if(S>x||h>=g&&h>m){let t=e.slice(x,S)||e.slice(m,h);_=0;for(let e of t.replaceAll(ce,``)){let t=e.codePointAt(0)||0;if(w=ae(t)?d:oe(t)?p:l!==f&&ie(t)?l:f,C+w>b&&(y=Math.min(y,Math.max(x,m)+_)),C+w>r){v=!0;break t}_+=e.length,C+=w}x=S=0}if(h>=g)break;if(j.lastIndex=h,j.test(e)){if(_=j.lastIndex-h,w=_*f,C+w>b&&(y=Math.min(y,h+Math.floor((b-C)/f))),C+w>r){v=!0;break}C+=w,x=m,S=h,h=m=j.lastIndex;continue}if(O.lastIndex=h,O.test(e)){if(C+o>b&&(y=Math.min(y,h)),C+o>r){v=!0;break}C+=o,x=m,S=h,h=m=O.lastIndex;continue}if(k.lastIndex=h,k.test(e)){if(_=k.lastIndex-h,w=_*s,C+w>b&&(y=Math.min(y,h+Math.floor((b-C)/s))),C+w>r){v=!0;break}C+=w,x=m,S=h,h=m=k.lastIndex;continue}if(A.lastIndex=h,A.test(e)){if(_=A.lastIndex-h,w=_*c,C+w>b&&(y=Math.min(y,h+Math.floor((b-C)/c))),C+w>r){v=!0;break}C+=w,x=m,S=h,h=m=A.lastIndex;continue}if(se.lastIndex=h,se.test(e)){if(C+u>b&&(y=Math.min(y,h)),C+u>r){v=!0;break}C+=u,x=m,S=h,h=m=se.lastIndex;continue}h+=1}return{width:v?b:C,index:v?y:g,truncated:v,ellipsed:v&&r>=a}},de={limit:1/0,ellipsis:``,ellipsisWidth:0},M=(e,t={})=>ue(e,de,t).width,fe=`]8;;`,pe=RegExp(`(?:\\[(?<code>\\d+)m|\\${fe}(?<uri>.*))`,`y`),me=e=>{if(e>=30&&e<=37||e>=90&&e<=97)return 39;if(e>=40&&e<=47||e>=100&&e<=107)return 49;if(e===1||e===2)return 22;if(e===3)return 23;if(e===4)return 24;if(e===7)return 27;if(e===8)return 28;if(e===9)return 29;if(e===0)return 0},he=e=>`[${e}m`,ge=e=>`${fe}${e}`,_e=e=>e.map(e=>M(e)),ve=(e,t,n)=>{let r=t[Symbol.iterator](),i=!1,a=!1,o=e.at(-1),s=o===void 0?0:M(o),c=r.next(),l=r.next(),u=0;for(;!c.done;){let o=c.value,d=M(o);s+d<=n?e[e.length-1]+=o:(e.push(o),s=0),(o===`\x1B`||o===``)&&(i=!0,a=t.startsWith(fe,u+1)),i?a?o===`\x07`&&(i=!1,a=!1):o===`m`&&(i=!1):(s+=d,s===n&&!l.done&&(e.push(``),s=0)),c=l,l=r.next(),u+=o.length}o=e.at(-1),!s&&o!==void 0&&o.length>0&&e.length>1&&(e[e.length-2]+=e.pop())},ye=e=>{let t=e.split(` `),n=t.length;for(;n>0&&!(M(t[n-1])>0);)n--;return n===t.length?e:t.slice(0,n).join(` `)+t.slice(n).join(``)},be=(e,t,n={})=>{if(n.trim!==!1&&e.trim()===``)return``;let r=``,i,a,o=e.split(` `),s=_e(o),c=[``];for(let[e,r]of o.entries()){n.trim!==!1&&(c[c.length-1]=(c.at(-1)??``).trimStart());let i=M(c.at(-1)??``);if(e!==0&&(i>=t&&(n.wordWrap===!1||n.trim===!1)&&(c.push(``),i=0),(i>0||n.trim===!1)&&(c[c.length-1]+=` `,i++)),n.hard&&s[e]>t){let n=t-i,a=1+Math.floor((s[e]-n-1)/t);Math.floor((s[e]-1)/t)<a&&c.push(``),ve(c,r,t);continue}if(i+s[e]>t&&i>0&&s[e]>0){if(n.wordWrap===!1&&i<t){ve(c,r,t);continue}c.push(``)}if(i+s[e]>t&&n.wordWrap===!1){ve(c,r,t);continue}c[c.length-1]+=r}n.trim!==!1&&(c=c.map(e=>ye(e)));let l=c.join(`
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
2
|
+
import { createRequire } from "module";
|
|
3
|
+
import N, { cwd, stdin, stdout } from "process";
|
|
4
|
+
import * as k$1 from "readline";
|
|
5
|
+
import c from "readline";
|
|
6
|
+
import { ReadStream } from "tty";
|
|
7
|
+
import { existsSync, lstatSync, mkdtempSync, readdirSync, rmSync, writeFileSync } from "fs";
|
|
8
|
+
import { delimiter, dirname, join, normalize, resolve } from "path";
|
|
9
|
+
import { parseArgs, stripVTControlCharacters } from "util";
|
|
10
|
+
import { spawn } from "child_process";
|
|
11
|
+
import { PassThrough } from "stream";
|
|
12
|
+
import { tmpdir } from "os";
|
|
13
|
+
|
|
14
|
+
//#region \0rolldown/runtime.js
|
|
15
|
+
var __create = Object.create;
|
|
16
|
+
var __defProp = Object.defineProperty;
|
|
17
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
18
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
19
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
20
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
21
|
+
var __commonJSMin = (cb, mod) => () => (mod || cb((mod = { exports: {} }).exports, mod), mod.exports);
|
|
22
|
+
var __copyProps = (to, from, except, desc) => {
|
|
23
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
24
|
+
for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
|
|
25
|
+
key = keys[i];
|
|
26
|
+
if (!__hasOwnProp.call(to, key) && key !== except) {
|
|
27
|
+
__defProp(to, key, {
|
|
28
|
+
get: ((k) => from[k]).bind(null, key),
|
|
29
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
return to;
|
|
35
|
+
};
|
|
36
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
|
|
37
|
+
value: mod,
|
|
38
|
+
enumerable: true
|
|
39
|
+
}) : target, mod));
|
|
40
|
+
|
|
41
|
+
//#endregion
|
|
42
|
+
//#region node_modules/picocolors/picocolors.js
|
|
43
|
+
var require_picocolors = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
44
|
+
let p = process || {}, argv = p.argv || [], env = p.env || {};
|
|
45
|
+
let isColorSupported = !(!!env.NO_COLOR || argv.includes("--no-color")) && (!!env.FORCE_COLOR || argv.includes("--color") || p.platform === "win32" || (p.stdout || {}).isTTY && env.TERM !== "dumb" || !!env.CI);
|
|
46
|
+
let formatter = (open, close, replace = open) => (input) => {
|
|
47
|
+
let string = "" + input, index = string.indexOf(close, open.length);
|
|
48
|
+
return ~index ? open + replaceClose(string, close, replace, index) + close : open + string + close;
|
|
49
|
+
};
|
|
50
|
+
let replaceClose = (string, close, replace, index) => {
|
|
51
|
+
let result = "", cursor = 0;
|
|
52
|
+
do {
|
|
53
|
+
result += string.substring(cursor, index) + replace;
|
|
54
|
+
cursor = index + close.length;
|
|
55
|
+
index = string.indexOf(close, cursor);
|
|
56
|
+
} while (~index);
|
|
57
|
+
return result + string.substring(cursor);
|
|
58
|
+
};
|
|
59
|
+
let createColors = (enabled = isColorSupported) => {
|
|
60
|
+
let f = enabled ? formatter : () => String;
|
|
61
|
+
return {
|
|
62
|
+
isColorSupported: enabled,
|
|
63
|
+
reset: f("\x1B[0m", "\x1B[0m"),
|
|
64
|
+
bold: f("\x1B[1m", "\x1B[22m", "\x1B[22m\x1B[1m"),
|
|
65
|
+
dim: f("\x1B[2m", "\x1B[22m", "\x1B[22m\x1B[2m"),
|
|
66
|
+
italic: f("\x1B[3m", "\x1B[23m"),
|
|
67
|
+
underline: f("\x1B[4m", "\x1B[24m"),
|
|
68
|
+
inverse: f("\x1B[7m", "\x1B[27m"),
|
|
69
|
+
hidden: f("\x1B[8m", "\x1B[28m"),
|
|
70
|
+
strikethrough: f("\x1B[9m", "\x1B[29m"),
|
|
71
|
+
black: f("\x1B[30m", "\x1B[39m"),
|
|
72
|
+
red: f("\x1B[31m", "\x1B[39m"),
|
|
73
|
+
green: f("\x1B[32m", "\x1B[39m"),
|
|
74
|
+
yellow: f("\x1B[33m", "\x1B[39m"),
|
|
75
|
+
blue: f("\x1B[34m", "\x1B[39m"),
|
|
76
|
+
magenta: f("\x1B[35m", "\x1B[39m"),
|
|
77
|
+
cyan: f("\x1B[36m", "\x1B[39m"),
|
|
78
|
+
white: f("\x1B[37m", "\x1B[39m"),
|
|
79
|
+
gray: f("\x1B[90m", "\x1B[39m"),
|
|
80
|
+
bgBlack: f("\x1B[40m", "\x1B[49m"),
|
|
81
|
+
bgRed: f("\x1B[41m", "\x1B[49m"),
|
|
82
|
+
bgGreen: f("\x1B[42m", "\x1B[49m"),
|
|
83
|
+
bgYellow: f("\x1B[43m", "\x1B[49m"),
|
|
84
|
+
bgBlue: f("\x1B[44m", "\x1B[49m"),
|
|
85
|
+
bgMagenta: f("\x1B[45m", "\x1B[49m"),
|
|
86
|
+
bgCyan: f("\x1B[46m", "\x1B[49m"),
|
|
87
|
+
bgWhite: f("\x1B[47m", "\x1B[49m"),
|
|
88
|
+
blackBright: f("\x1B[90m", "\x1B[39m"),
|
|
89
|
+
redBright: f("\x1B[91m", "\x1B[39m"),
|
|
90
|
+
greenBright: f("\x1B[92m", "\x1B[39m"),
|
|
91
|
+
yellowBright: f("\x1B[93m", "\x1B[39m"),
|
|
92
|
+
blueBright: f("\x1B[94m", "\x1B[39m"),
|
|
93
|
+
magentaBright: f("\x1B[95m", "\x1B[39m"),
|
|
94
|
+
cyanBright: f("\x1B[96m", "\x1B[39m"),
|
|
95
|
+
whiteBright: f("\x1B[97m", "\x1B[39m"),
|
|
96
|
+
bgBlackBright: f("\x1B[100m", "\x1B[49m"),
|
|
97
|
+
bgRedBright: f("\x1B[101m", "\x1B[49m"),
|
|
98
|
+
bgGreenBright: f("\x1B[102m", "\x1B[49m"),
|
|
99
|
+
bgYellowBright: f("\x1B[103m", "\x1B[49m"),
|
|
100
|
+
bgBlueBright: f("\x1B[104m", "\x1B[49m"),
|
|
101
|
+
bgMagentaBright: f("\x1B[105m", "\x1B[49m"),
|
|
102
|
+
bgCyanBright: f("\x1B[106m", "\x1B[49m"),
|
|
103
|
+
bgWhiteBright: f("\x1B[107m", "\x1B[49m")
|
|
104
|
+
};
|
|
105
|
+
};
|
|
106
|
+
module.exports = createColors();
|
|
107
|
+
module.exports.createColors = createColors;
|
|
108
|
+
}));
|
|
109
|
+
|
|
110
|
+
//#endregion
|
|
111
|
+
//#region node_modules/sisteransi/src/index.js
|
|
112
|
+
var require_src = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
113
|
+
const ESC = "\x1B";
|
|
114
|
+
const CSI = `${ESC}[`;
|
|
115
|
+
const beep = "\x07";
|
|
116
|
+
const cursor = {
|
|
117
|
+
to(x, y) {
|
|
118
|
+
if (!y) return `${CSI}${x + 1}G`;
|
|
119
|
+
return `${CSI}${y + 1};${x + 1}H`;
|
|
120
|
+
},
|
|
121
|
+
move(x, y) {
|
|
122
|
+
let ret = "";
|
|
123
|
+
if (x < 0) ret += `${CSI}${-x}D`;
|
|
124
|
+
else if (x > 0) ret += `${CSI}${x}C`;
|
|
125
|
+
if (y < 0) ret += `${CSI}${-y}A`;
|
|
126
|
+
else if (y > 0) ret += `${CSI}${y}B`;
|
|
127
|
+
return ret;
|
|
128
|
+
},
|
|
129
|
+
up: (count = 1) => `${CSI}${count}A`,
|
|
130
|
+
down: (count = 1) => `${CSI}${count}B`,
|
|
131
|
+
forward: (count = 1) => `${CSI}${count}C`,
|
|
132
|
+
backward: (count = 1) => `${CSI}${count}D`,
|
|
133
|
+
nextLine: (count = 1) => `${CSI}E`.repeat(count),
|
|
134
|
+
prevLine: (count = 1) => `${CSI}F`.repeat(count),
|
|
135
|
+
left: `${CSI}G`,
|
|
136
|
+
hide: `${CSI}?25l`,
|
|
137
|
+
show: `${CSI}?25h`,
|
|
138
|
+
save: `${ESC}7`,
|
|
139
|
+
restore: `${ESC}8`
|
|
140
|
+
};
|
|
141
|
+
const scroll = {
|
|
142
|
+
up: (count = 1) => `${CSI}S`.repeat(count),
|
|
143
|
+
down: (count = 1) => `${CSI}T`.repeat(count)
|
|
144
|
+
};
|
|
145
|
+
const erase = {
|
|
146
|
+
screen: `${CSI}2J`,
|
|
147
|
+
up: (count = 1) => `${CSI}1J`.repeat(count),
|
|
148
|
+
down: (count = 1) => `${CSI}J`.repeat(count),
|
|
149
|
+
line: `${CSI}2K`,
|
|
150
|
+
lineEnd: `${CSI}K`,
|
|
151
|
+
lineStart: `${CSI}1K`,
|
|
152
|
+
lines(count) {
|
|
153
|
+
let clear = "";
|
|
154
|
+
for (let i = 0; i < count; i++) clear += this.line + (i < count - 1 ? cursor.up() : "");
|
|
155
|
+
if (count) clear += cursor.left;
|
|
156
|
+
return clear;
|
|
157
|
+
}
|
|
158
|
+
};
|
|
159
|
+
module.exports = {
|
|
160
|
+
cursor,
|
|
161
|
+
scroll,
|
|
162
|
+
erase,
|
|
163
|
+
beep
|
|
164
|
+
};
|
|
165
|
+
}));
|
|
166
|
+
|
|
167
|
+
//#endregion
|
|
168
|
+
//#region node_modules/@clack/core/dist/index.mjs
|
|
169
|
+
var import_picocolors = /* @__PURE__ */ __toESM(require_picocolors(), 1);
|
|
170
|
+
var import_src = require_src();
|
|
171
|
+
function B$1(t, e, s) {
|
|
172
|
+
if (!s.some((u) => !u.disabled)) return t;
|
|
173
|
+
const i = t + e, r = Math.max(s.length - 1, 0), n = i < 0 ? r : i > r ? 0 : i;
|
|
174
|
+
return s[n].disabled ? B$1(n, e < 0 ? -1 : 1, s) : n;
|
|
175
|
+
}
|
|
176
|
+
const at$1 = (t) => t === 161 || t === 164 || t === 167 || t === 168 || t === 170 || t === 173 || t === 174 || t >= 176 && t <= 180 || t >= 182 && t <= 186 || t >= 188 && t <= 191 || t === 198 || t === 208 || t === 215 || t === 216 || t >= 222 && t <= 225 || t === 230 || t >= 232 && t <= 234 || t === 236 || t === 237 || t === 240 || t === 242 || t === 243 || t >= 247 && t <= 250 || t === 252 || t === 254 || t === 257 || t === 273 || t === 275 || t === 283 || t === 294 || t === 295 || t === 299 || t >= 305 && t <= 307 || t === 312 || t >= 319 && t <= 322 || t === 324 || t >= 328 && t <= 331 || t === 333 || t === 338 || t === 339 || t === 358 || t === 359 || t === 363 || t === 462 || t === 464 || t === 466 || t === 468 || t === 470 || t === 472 || t === 474 || t === 476 || t === 593 || t === 609 || t === 708 || t === 711 || t >= 713 && t <= 715 || t === 717 || t === 720 || t >= 728 && t <= 731 || t === 733 || t === 735 || t >= 768 && t <= 879 || t >= 913 && t <= 929 || t >= 931 && t <= 937 || t >= 945 && t <= 961 || t >= 963 && t <= 969 || t === 1025 || t >= 1040 && t <= 1103 || t === 1105 || t === 8208 || t >= 8211 && t <= 8214 || t === 8216 || t === 8217 || t === 8220 || t === 8221 || t >= 8224 && t <= 8226 || t >= 8228 && t <= 8231 || t === 8240 || t === 8242 || t === 8243 || t === 8245 || t === 8251 || t === 8254 || t === 8308 || t === 8319 || t >= 8321 && t <= 8324 || t === 8364 || t === 8451 || t === 8453 || t === 8457 || t === 8467 || t === 8470 || t === 8481 || t === 8482 || t === 8486 || t === 8491 || t === 8531 || t === 8532 || t >= 8539 && t <= 8542 || t >= 8544 && t <= 8555 || t >= 8560 && t <= 8569 || t === 8585 || t >= 8592 && t <= 8601 || t === 8632 || t === 8633 || t === 8658 || t === 8660 || t === 8679 || t === 8704 || t === 8706 || t === 8707 || t === 8711 || t === 8712 || t === 8715 || t === 8719 || t === 8721 || t === 8725 || t === 8730 || t >= 8733 && t <= 8736 || t === 8739 || t === 8741 || t >= 8743 && t <= 8748 || t === 8750 || t >= 8756 && t <= 8759 || t === 8764 || t === 8765 || t === 8776 || t === 8780 || t === 8786 || t === 8800 || t === 8801 || t >= 8804 && t <= 8807 || t === 8810 || t === 8811 || t === 8814 || t === 8815 || t === 8834 || t === 8835 || t === 8838 || t === 8839 || t === 8853 || t === 8857 || t === 8869 || t === 8895 || t === 8978 || t >= 9312 && t <= 9449 || t >= 9451 && t <= 9547 || t >= 9552 && t <= 9587 || t >= 9600 && t <= 9615 || t >= 9618 && t <= 9621 || t === 9632 || t === 9633 || t >= 9635 && t <= 9641 || t === 9650 || t === 9651 || t === 9654 || t === 9655 || t === 9660 || t === 9661 || t === 9664 || t === 9665 || t >= 9670 && t <= 9672 || t === 9675 || t >= 9678 && t <= 9681 || t >= 9698 && t <= 9701 || t === 9711 || t === 9733 || t === 9734 || t === 9737 || t === 9742 || t === 9743 || t === 9756 || t === 9758 || t === 9792 || t === 9794 || t === 9824 || t === 9825 || t >= 9827 && t <= 9829 || t >= 9831 && t <= 9834 || t === 9836 || t === 9837 || t === 9839 || t === 9886 || t === 9887 || t === 9919 || t >= 9926 && t <= 9933 || t >= 9935 && t <= 9939 || t >= 9941 && t <= 9953 || t === 9955 || t === 9960 || t === 9961 || t >= 9963 && t <= 9969 || t === 9972 || t >= 9974 && t <= 9977 || t === 9979 || t === 9980 || t === 9982 || t === 9983 || t === 10045 || t >= 10102 && t <= 10111 || t >= 11094 && t <= 11097 || t >= 12872 && t <= 12879 || t >= 57344 && t <= 63743 || t >= 65024 && t <= 65039 || t === 65533 || t >= 127232 && t <= 127242 || t >= 127248 && t <= 127277 || t >= 127280 && t <= 127337 || t >= 127344 && t <= 127373 || t === 127375 || t === 127376 || t >= 127387 && t <= 127404 || t >= 917760 && t <= 917999 || t >= 983040 && t <= 1048573 || t >= 1048576 && t <= 1114109, lt$1 = (t) => t === 12288 || t >= 65281 && t <= 65376 || t >= 65504 && t <= 65510, ht$1 = (t) => t >= 4352 && t <= 4447 || t === 8986 || t === 8987 || t === 9001 || t === 9002 || t >= 9193 && t <= 9196 || t === 9200 || t === 9203 || t === 9725 || t === 9726 || t === 9748 || t === 9749 || t >= 9800 && t <= 9811 || t === 9855 || t === 9875 || t === 9889 || t === 9898 || t === 9899 || t === 9917 || t === 9918 || t === 9924 || t === 9925 || t === 9934 || t === 9940 || t === 9962 || t === 9970 || t === 9971 || t === 9973 || t === 9978 || t === 9981 || t === 9989 || t === 9994 || t === 9995 || t === 10024 || t === 10060 || t === 10062 || t >= 10067 && t <= 10069 || t === 10071 || t >= 10133 && t <= 10135 || t === 10160 || t === 10175 || t === 11035 || t === 11036 || t === 11088 || t === 11093 || t >= 11904 && t <= 11929 || t >= 11931 && t <= 12019 || t >= 12032 && t <= 12245 || t >= 12272 && t <= 12287 || t >= 12289 && t <= 12350 || t >= 12353 && t <= 12438 || t >= 12441 && t <= 12543 || t >= 12549 && t <= 12591 || t >= 12593 && t <= 12686 || t >= 12688 && t <= 12771 || t >= 12783 && t <= 12830 || t >= 12832 && t <= 12871 || t >= 12880 && t <= 19903 || t >= 19968 && t <= 42124 || t >= 42128 && t <= 42182 || t >= 43360 && t <= 43388 || t >= 44032 && t <= 55203 || t >= 63744 && t <= 64255 || t >= 65040 && t <= 65049 || t >= 65072 && t <= 65106 || t >= 65108 && t <= 65126 || t >= 65128 && t <= 65131 || t >= 94176 && t <= 94180 || t === 94192 || t === 94193 || t >= 94208 && t <= 100343 || t >= 100352 && t <= 101589 || t >= 101632 && t <= 101640 || t >= 110576 && t <= 110579 || t >= 110581 && t <= 110587 || t === 110589 || t === 110590 || t >= 110592 && t <= 110882 || t === 110898 || t >= 110928 && t <= 110930 || t === 110933 || t >= 110948 && t <= 110951 || t >= 110960 && t <= 111355 || t === 126980 || t === 127183 || t === 127374 || t >= 127377 && t <= 127386 || t >= 127488 && t <= 127490 || t >= 127504 && t <= 127547 || t >= 127552 && t <= 127560 || t === 127568 || t === 127569 || t >= 127584 && t <= 127589 || t >= 127744 && t <= 127776 || t >= 127789 && t <= 127797 || t >= 127799 && t <= 127868 || t >= 127870 && t <= 127891 || t >= 127904 && t <= 127946 || t >= 127951 && t <= 127955 || t >= 127968 && t <= 127984 || t === 127988 || t >= 127992 && t <= 128062 || t === 128064 || t >= 128066 && t <= 128252 || t >= 128255 && t <= 128317 || t >= 128331 && t <= 128334 || t >= 128336 && t <= 128359 || t === 128378 || t === 128405 || t === 128406 || t === 128420 || t >= 128507 && t <= 128591 || t >= 128640 && t <= 128709 || t === 128716 || t >= 128720 && t <= 128722 || t >= 128725 && t <= 128727 || t >= 128732 && t <= 128735 || t === 128747 || t === 128748 || t >= 128756 && t <= 128764 || t >= 128992 && t <= 129003 || t === 129008 || t >= 129292 && t <= 129338 || t >= 129340 && t <= 129349 || t >= 129351 && t <= 129535 || t >= 129648 && t <= 129660 || t >= 129664 && t <= 129672 || t >= 129680 && t <= 129725 || t >= 129727 && t <= 129733 || t >= 129742 && t <= 129755 || t >= 129760 && t <= 129768 || t >= 129776 && t <= 129784 || t >= 131072 && t <= 196605 || t >= 196608 && t <= 262141, O$1 = /[\u001b\u009b][[()#;?]*(?:[0-9]{1,4}(?:;[0-9]{0,4})*)?[0-9A-ORZcf-nqry=><]/y, y$1 = /[\x00-\x08\x0A-\x1F\x7F-\x9F]{1,1000}/y, L = /\t{1,1000}/y, P$1 = /[\u{1F1E6}-\u{1F1FF}]{2}|\u{1F3F4}[\u{E0061}-\u{E007A}]{2}[\u{E0030}-\u{E0039}\u{E0061}-\u{E007A}]{1,3}\u{E007F}|(?:\p{Emoji}\uFE0F\u20E3?|\p{Emoji_Modifier_Base}\p{Emoji_Modifier}?|\p{Emoji_Presentation})(?:\u200D(?:\p{Emoji_Modifier_Base}\p{Emoji_Modifier}?|\p{Emoji_Presentation}|\p{Emoji}\uFE0F\u20E3?))*/uy, M$2 = /(?:[\x20-\x7E\xA0-\xFF](?!\uFE0F)){1,1000}/y, ct$1 = /\p{M}+/gu, ft$1 = {
|
|
177
|
+
limit: Infinity,
|
|
178
|
+
ellipsis: ""
|
|
179
|
+
}, X$1 = (t, e = {}, s = {}) => {
|
|
180
|
+
const i = e.limit ?? Infinity, r = e.ellipsis ?? "", n = e?.ellipsisWidth ?? (r ? X$1(r, ft$1, s).width : 0), u = s.ansiWidth ?? 0, a = s.controlWidth ?? 0, l = s.tabWidth ?? 8, E = s.ambiguousWidth ?? 1, g = s.emojiWidth ?? 2, m = s.fullWidthWidth ?? 2, A = s.regularWidth ?? 1, V = s.wideWidth ?? 2;
|
|
181
|
+
let h = 0, o = 0, p = t.length, v = 0, F = !1, d = p, b = Math.max(0, i - n), C = 0, w = 0, c = 0, f = 0;
|
|
182
|
+
t: for (;;) {
|
|
183
|
+
if (w > C || o >= p && o > h) {
|
|
184
|
+
const ut = t.slice(C, w) || t.slice(h, o);
|
|
185
|
+
v = 0;
|
|
186
|
+
for (const Y of ut.replaceAll(ct$1, "")) {
|
|
187
|
+
const $ = Y.codePointAt(0) || 0;
|
|
188
|
+
if (lt$1($) ? f = m : ht$1($) ? f = V : E !== A && at$1($) ? f = E : f = A, c + f > b && (d = Math.min(d, Math.max(C, h) + v)), c + f > i) {
|
|
189
|
+
F = !0;
|
|
190
|
+
break t;
|
|
191
|
+
}
|
|
192
|
+
v += Y.length, c += f;
|
|
193
|
+
}
|
|
194
|
+
C = w = 0;
|
|
195
|
+
}
|
|
196
|
+
if (o >= p) break;
|
|
197
|
+
if (M$2.lastIndex = o, M$2.test(t)) {
|
|
198
|
+
if (v = M$2.lastIndex - o, f = v * A, c + f > b && (d = Math.min(d, o + Math.floor((b - c) / A))), c + f > i) {
|
|
199
|
+
F = !0;
|
|
200
|
+
break;
|
|
201
|
+
}
|
|
202
|
+
c += f, C = h, w = o, o = h = M$2.lastIndex;
|
|
203
|
+
continue;
|
|
204
|
+
}
|
|
205
|
+
if (O$1.lastIndex = o, O$1.test(t)) {
|
|
206
|
+
if (c + u > b && (d = Math.min(d, o)), c + u > i) {
|
|
207
|
+
F = !0;
|
|
208
|
+
break;
|
|
209
|
+
}
|
|
210
|
+
c += u, C = h, w = o, o = h = O$1.lastIndex;
|
|
211
|
+
continue;
|
|
212
|
+
}
|
|
213
|
+
if (y$1.lastIndex = o, y$1.test(t)) {
|
|
214
|
+
if (v = y$1.lastIndex - o, f = v * a, c + f > b && (d = Math.min(d, o + Math.floor((b - c) / a))), c + f > i) {
|
|
215
|
+
F = !0;
|
|
216
|
+
break;
|
|
217
|
+
}
|
|
218
|
+
c += f, C = h, w = o, o = h = y$1.lastIndex;
|
|
219
|
+
continue;
|
|
220
|
+
}
|
|
221
|
+
if (L.lastIndex = o, L.test(t)) {
|
|
222
|
+
if (v = L.lastIndex - o, f = v * l, c + f > b && (d = Math.min(d, o + Math.floor((b - c) / l))), c + f > i) {
|
|
223
|
+
F = !0;
|
|
224
|
+
break;
|
|
225
|
+
}
|
|
226
|
+
c += f, C = h, w = o, o = h = L.lastIndex;
|
|
227
|
+
continue;
|
|
228
|
+
}
|
|
229
|
+
if (P$1.lastIndex = o, P$1.test(t)) {
|
|
230
|
+
if (c + g > b && (d = Math.min(d, o)), c + g > i) {
|
|
231
|
+
F = !0;
|
|
232
|
+
break;
|
|
233
|
+
}
|
|
234
|
+
c += g, C = h, w = o, o = h = P$1.lastIndex;
|
|
235
|
+
continue;
|
|
236
|
+
}
|
|
237
|
+
o += 1;
|
|
238
|
+
}
|
|
239
|
+
return {
|
|
240
|
+
width: F ? b : c,
|
|
241
|
+
index: F ? d : p,
|
|
242
|
+
truncated: F,
|
|
243
|
+
ellipsed: F && i >= n
|
|
244
|
+
};
|
|
245
|
+
}, pt$1 = {
|
|
246
|
+
limit: Infinity,
|
|
247
|
+
ellipsis: "",
|
|
248
|
+
ellipsisWidth: 0
|
|
249
|
+
}, S$1 = (t, e = {}) => X$1(t, pt$1, e).width, W$2 = "\x1B", Z$1 = "", Ft$1 = 39, j$1 = "\x07", Q$1 = "[", dt$1 = "]", tt = "m", U$2 = `${dt$1}8;;`, et$1 = new RegExp(`(?:\\${Q$1}(?<code>\\d+)m|\\${U$2}(?<uri>.*)${j$1})`, "y"), mt$1 = (t) => {
|
|
250
|
+
if (t >= 30 && t <= 37 || t >= 90 && t <= 97) return 39;
|
|
251
|
+
if (t >= 40 && t <= 47 || t >= 100 && t <= 107) return 49;
|
|
252
|
+
if (t === 1 || t === 2) return 22;
|
|
253
|
+
if (t === 3) return 23;
|
|
254
|
+
if (t === 4) return 24;
|
|
255
|
+
if (t === 7) return 27;
|
|
256
|
+
if (t === 8) return 28;
|
|
257
|
+
if (t === 9) return 29;
|
|
258
|
+
if (t === 0) return 0;
|
|
259
|
+
}, st$1 = (t) => `${W$2}${Q$1}${t}${tt}`, it$1 = (t) => `${W$2}${U$2}${t}${j$1}`, gt$1 = (t) => t.map((e) => S$1(e)), G$1 = (t, e, s) => {
|
|
260
|
+
const i = e[Symbol.iterator]();
|
|
261
|
+
let r = !1, n = !1, u = t.at(-1), a = u === void 0 ? 0 : S$1(u), l = i.next(), E = i.next(), g = 0;
|
|
262
|
+
for (; !l.done;) {
|
|
263
|
+
const m = l.value, A = S$1(m);
|
|
264
|
+
a + A <= s ? t[t.length - 1] += m : (t.push(m), a = 0), (m === W$2 || m === Z$1) && (r = !0, n = e.startsWith(U$2, g + 1)), r ? n ? m === j$1 && (r = !1, n = !1) : m === tt && (r = !1) : (a += A, a === s && !E.done && (t.push(""), a = 0)), l = E, E = i.next(), g += m.length;
|
|
265
|
+
}
|
|
266
|
+
u = t.at(-1), !a && u !== void 0 && u.length > 0 && t.length > 1 && (t[t.length - 2] += t.pop());
|
|
267
|
+
}, vt$1 = (t) => {
|
|
268
|
+
const e = t.split(" ");
|
|
269
|
+
let s = e.length;
|
|
270
|
+
for (; s > 0 && !(S$1(e[s - 1]) > 0);) s--;
|
|
271
|
+
return s === e.length ? t : e.slice(0, s).join(" ") + e.slice(s).join("");
|
|
272
|
+
}, Et$1 = (t, e, s = {}) => {
|
|
273
|
+
if (s.trim !== !1 && t.trim() === "") return "";
|
|
274
|
+
let i = "", r, n;
|
|
275
|
+
const u = t.split(" "), a = gt$1(u);
|
|
276
|
+
let l = [""];
|
|
277
|
+
for (const [h, o] of u.entries()) {
|
|
278
|
+
s.trim !== !1 && (l[l.length - 1] = (l.at(-1) ?? "").trimStart());
|
|
279
|
+
let p = S$1(l.at(-1) ?? "");
|
|
280
|
+
if (h !== 0 && (p >= e && (s.wordWrap === !1 || s.trim === !1) && (l.push(""), p = 0), (p > 0 || s.trim === !1) && (l[l.length - 1] += " ", p++)), s.hard && a[h] > e) {
|
|
281
|
+
const v = e - p, F = 1 + Math.floor((a[h] - v - 1) / e);
|
|
282
|
+
Math.floor((a[h] - 1) / e) < F && l.push(""), G$1(l, o, e);
|
|
283
|
+
continue;
|
|
284
|
+
}
|
|
285
|
+
if (p + a[h] > e && p > 0 && a[h] > 0) {
|
|
286
|
+
if (s.wordWrap === !1 && p < e) {
|
|
287
|
+
G$1(l, o, e);
|
|
288
|
+
continue;
|
|
289
|
+
}
|
|
290
|
+
l.push("");
|
|
291
|
+
}
|
|
292
|
+
if (p + a[h] > e && s.wordWrap === !1) {
|
|
293
|
+
G$1(l, o, e);
|
|
294
|
+
continue;
|
|
295
|
+
}
|
|
296
|
+
l[l.length - 1] += o;
|
|
297
|
+
}
|
|
298
|
+
s.trim !== !1 && (l = l.map((h) => vt$1(h)));
|
|
299
|
+
const E = l.join(`
|
|
300
|
+
`), g = E[Symbol.iterator]();
|
|
301
|
+
let m = g.next(), A = g.next(), V = 0;
|
|
302
|
+
for (; !m.done;) {
|
|
303
|
+
const h = m.value, o = A.value;
|
|
304
|
+
if (i += h, h === W$2 || h === Z$1) {
|
|
305
|
+
et$1.lastIndex = V + 1;
|
|
306
|
+
const F = et$1.exec(E)?.groups;
|
|
307
|
+
if (F?.code !== void 0) {
|
|
308
|
+
const d = Number.parseFloat(F.code);
|
|
309
|
+
r = d === Ft$1 ? void 0 : d;
|
|
310
|
+
} else F?.uri !== void 0 && (n = F.uri.length === 0 ? void 0 : F.uri);
|
|
311
|
+
}
|
|
312
|
+
const p = r ? mt$1(r) : void 0;
|
|
313
|
+
o === `
|
|
314
|
+
` ? (n && (i += it$1("")), r && p && (i += st$1(p))) : h === `
|
|
315
|
+
` && (r && p && (i += st$1(r)), n && (i += it$1(n))), V += h.length, m = A, A = g.next();
|
|
316
|
+
}
|
|
317
|
+
return i;
|
|
318
|
+
};
|
|
319
|
+
function K$2(t, e, s) {
|
|
320
|
+
return String(t).normalize().replaceAll(`\r
|
|
321
|
+
`, `
|
|
7
322
|
`).split(`
|
|
8
|
-
`).map(
|
|
9
|
-
`)
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
`)),this._prevFrame=e;return}}this.output.write(E.erase.down())}this.output.write(e),this.state===`initial`&&(this.state=`active`),this._prevFrame=e}}},ke=class extends L{get cursor(){return this.value?0:1}get _value(){return this.cursor===0}constructor(e){super(e,!1),this.value=!!e.initialValue,this.on(`userInput`,()=>{this.value=this._value}),this.on(`confirm`,e=>{this.output.write(E.cursor.move(0,-1)),this.value=e,this.state=`submit`,this.close()}),this.on(`cursor`,()=>{this.value=!this.value})}},Ae=class extends L{options;cursor=0;#e;getGroupItems(e){return this.options.filter(t=>t.group===e)}isGroupSelected(e){let t=this.getGroupItems(e),n=this.value;return n===void 0?!1:t.every(e=>n.includes(e.value))}toggleValue(){let e=this.options[this.cursor];if(this.value===void 0&&(this.value=[]),e.group===!0){let t=e.value,n=this.getGroupItems(t);this.isGroupSelected(t)?this.value=this.value.filter(e=>n.findIndex(t=>t.value===e)===-1):this.value=[...this.value,...n.map(e=>e.value)],this.value=Array.from(new Set(this.value))}else this.value=this.value.includes(e.value)?this.value.filter(t=>t!==e.value):[...this.value,e.value]}constructor(e){super(e,!1);let{options:t}=e;this.#e=e.selectableGroups!==!1,this.options=Object.entries(t).flatMap(([e,t])=>[{value:e,group:!0,label:e},...t.map(t=>({...t,group:e}))]),this.value=[...e.initialValues??[]],this.cursor=Math.max(this.options.findIndex(({value:t})=>t===e.cursorAt),this.#e?0:1),this.on(`cursor`,e=>{switch(e){case`left`:case`up`:{this.cursor=this.cursor===0?this.options.length-1:this.cursor-1;let e=this.options[this.cursor]?.group===!0;!this.#e&&e&&(this.cursor=this.cursor===0?this.options.length-1:this.cursor-1);break}case`down`:case`right`:{this.cursor=this.cursor===this.options.length-1?0:this.cursor+1;let e=this.options[this.cursor]?.group===!0;!this.#e&&e&&(this.cursor=this.cursor===this.options.length-1?0:this.cursor+1);break}case`space`:this.toggleValue();break}})}},je=class extends L{options;cursor=0;get _selectedValue(){return this.options[this.cursor]}changeValue(){this.value=this._selectedValue.value}constructor(e){super(e,!1),this.options=e.options;let t=this.options.findIndex(({value:t})=>t===e.initialValue),n=t===-1?0:t;this.cursor=this.options[n].disabled?D(n,1,this.options):n,this.changeValue(),this.on(`cursor`,e=>{switch(e){case`left`:case`up`:this.cursor=D(this.cursor,-1,this.options);break;case`down`:case`right`:this.cursor=D(this.cursor,1,this.options);break}this.changeValue()})}},Me=class extends L{get userInputWithCursor(){if(this.state===`submit`)return this.userInput;let e=this.userInput;if(this.cursor>=e.length)return`${this.userInput}\u2588`;let t=e.slice(0,this.cursor),[n,...r]=e.slice(this.cursor);return`${t}${T.default.inverse(n)}${r.join(``)}`}get cursor(){return this._cursor}constructor(e){super({...e,initialUserInput:e.initialUserInput??e.initialValue}),this.on(`userInput`,e=>{this._setValue(e)}),this.on(`finalize`,()=>{this.value||=e.defaultValue,this.value===void 0&&(this.value=``)})}};function Ne(){return e.platform===`win32`?!!e.env.CI||!!e.env.WT_SESSION||!!e.env.TERMINUS_SUBLIME||e.env.ConEmuTask===`{cmd::Cmder}`||e.env.TERM_PROGRAM===`Terminus-Sublime`||e.env.TERM_PROGRAM===`vscode`||e.env.TERM===`xterm-256color`||e.env.TERM===`alacritty`||e.env.TERMINAL_EMULATOR===`JetBrains-JediTerm`:e.env.TERM!==`linux`}const Pe=Ne(),Fe=()=>process.env.CI===`true`,R=(e,t)=>Pe?e:t,Ie=R(`◆`,`*`),Le=R(`■`,`x`),Re=R(`▲`,`x`),z=R(`◇`,`o`),ze=R(`┌`,`T`),B=R(`│`,`|`),V=R(`└`,`—`),Be=R(`●`,`>`),H=R(`○`,` `),Ve=R(`◻`,`[•]`),He=R(`◼`,`[+]`),Ue=R(`◻`,`[ ]`),We=R(`●`,`•`),Ge=R(`◆`,`*`),Ke=R(`▲`,`!`),qe=R(`■`,`x`),U=e=>{switch(e){case`initial`:case`active`:return T.default.cyan(Ie);case`cancel`:return T.default.red(Le);case`error`:return T.default.yellow(Re);case`submit`:return T.default.green(z)}},Je=e=>{switch(e){case`initial`:case`active`:return T.default.cyan(B);case`cancel`:return T.default.red(B);case`error`:return T.default.yellow(B);case`submit`:return T.default.green(B)}},Ye=e=>e===161||e===164||e===167||e===168||e===170||e===173||e===174||e>=176&&e<=180||e>=182&&e<=186||e>=188&&e<=191||e===198||e===208||e===215||e===216||e>=222&&e<=225||e===230||e>=232&&e<=234||e===236||e===237||e===240||e===242||e===243||e>=247&&e<=250||e===252||e===254||e===257||e===273||e===275||e===283||e===294||e===295||e===299||e>=305&&e<=307||e===312||e>=319&&e<=322||e===324||e>=328&&e<=331||e===333||e===338||e===339||e===358||e===359||e===363||e===462||e===464||e===466||e===468||e===470||e===472||e===474||e===476||e===593||e===609||e===708||e===711||e>=713&&e<=715||e===717||e===720||e>=728&&e<=731||e===733||e===735||e>=768&&e<=879||e>=913&&e<=929||e>=931&&e<=937||e>=945&&e<=961||e>=963&&e<=969||e===1025||e>=1040&&e<=1103||e===1105||e===8208||e>=8211&&e<=8214||e===8216||e===8217||e===8220||e===8221||e>=8224&&e<=8226||e>=8228&&e<=8231||e===8240||e===8242||e===8243||e===8245||e===8251||e===8254||e===8308||e===8319||e>=8321&&e<=8324||e===8364||e===8451||e===8453||e===8457||e===8467||e===8470||e===8481||e===8482||e===8486||e===8491||e===8531||e===8532||e>=8539&&e<=8542||e>=8544&&e<=8555||e>=8560&&e<=8569||e===8585||e>=8592&&e<=8601||e===8632||e===8633||e===8658||e===8660||e===8679||e===8704||e===8706||e===8707||e===8711||e===8712||e===8715||e===8719||e===8721||e===8725||e===8730||e>=8733&&e<=8736||e===8739||e===8741||e>=8743&&e<=8748||e===8750||e>=8756&&e<=8759||e===8764||e===8765||e===8776||e===8780||e===8786||e===8800||e===8801||e>=8804&&e<=8807||e===8810||e===8811||e===8814||e===8815||e===8834||e===8835||e===8838||e===8839||e===8853||e===8857||e===8869||e===8895||e===8978||e>=9312&&e<=9449||e>=9451&&e<=9547||e>=9552&&e<=9587||e>=9600&&e<=9615||e>=9618&&e<=9621||e===9632||e===9633||e>=9635&&e<=9641||e===9650||e===9651||e===9654||e===9655||e===9660||e===9661||e===9664||e===9665||e>=9670&&e<=9672||e===9675||e>=9678&&e<=9681||e>=9698&&e<=9701||e===9711||e===9733||e===9734||e===9737||e===9742||e===9743||e===9756||e===9758||e===9792||e===9794||e===9824||e===9825||e>=9827&&e<=9829||e>=9831&&e<=9834||e===9836||e===9837||e===9839||e===9886||e===9887||e===9919||e>=9926&&e<=9933||e>=9935&&e<=9939||e>=9941&&e<=9953||e===9955||e===9960||e===9961||e>=9963&&e<=9969||e===9972||e>=9974&&e<=9977||e===9979||e===9980||e===9982||e===9983||e===10045||e>=10102&&e<=10111||e>=11094&&e<=11097||e>=12872&&e<=12879||e>=57344&&e<=63743||e>=65024&&e<=65039||e===65533||e>=127232&&e<=127242||e>=127248&&e<=127277||e>=127280&&e<=127337||e>=127344&&e<=127373||e===127375||e===127376||e>=127387&&e<=127404||e>=917760&&e<=917999||e>=983040&&e<=1048573||e>=1048576&&e<=1114109,Xe=e=>e===12288||e>=65281&&e<=65376||e>=65504&&e<=65510,Ze=e=>e>=4352&&e<=4447||e===8986||e===8987||e===9001||e===9002||e>=9193&&e<=9196||e===9200||e===9203||e===9725||e===9726||e===9748||e===9749||e>=9800&&e<=9811||e===9855||e===9875||e===9889||e===9898||e===9899||e===9917||e===9918||e===9924||e===9925||e===9934||e===9940||e===9962||e===9970||e===9971||e===9973||e===9978||e===9981||e===9989||e===9994||e===9995||e===10024||e===10060||e===10062||e>=10067&&e<=10069||e===10071||e>=10133&&e<=10135||e===10160||e===10175||e===11035||e===11036||e===11088||e===11093||e>=11904&&e<=11929||e>=11931&&e<=12019||e>=12032&&e<=12245||e>=12272&&e<=12287||e>=12289&&e<=12350||e>=12353&&e<=12438||e>=12441&&e<=12543||e>=12549&&e<=12591||e>=12593&&e<=12686||e>=12688&&e<=12771||e>=12783&&e<=12830||e>=12832&&e<=12871||e>=12880&&e<=19903||e>=19968&&e<=42124||e>=42128&&e<=42182||e>=43360&&e<=43388||e>=44032&&e<=55203||e>=63744&&e<=64255||e>=65040&&e<=65049||e>=65072&&e<=65106||e>=65108&&e<=65126||e>=65128&&e<=65131||e>=94176&&e<=94180||e===94192||e===94193||e>=94208&&e<=100343||e>=100352&&e<=101589||e>=101632&&e<=101640||e>=110576&&e<=110579||e>=110581&&e<=110587||e===110589||e===110590||e>=110592&&e<=110882||e===110898||e>=110928&&e<=110930||e===110933||e>=110948&&e<=110951||e>=110960&&e<=111355||e===126980||e===127183||e===127374||e>=127377&&e<=127386||e>=127488&&e<=127490||e>=127504&&e<=127547||e>=127552&&e<=127560||e===127568||e===127569||e>=127584&&e<=127589||e>=127744&&e<=127776||e>=127789&&e<=127797||e>=127799&&e<=127868||e>=127870&&e<=127891||e>=127904&&e<=127946||e>=127951&&e<=127955||e>=127968&&e<=127984||e===127988||e>=127992&&e<=128062||e===128064||e>=128066&&e<=128252||e>=128255&&e<=128317||e>=128331&&e<=128334||e>=128336&&e<=128359||e===128378||e===128405||e===128406||e===128420||e>=128507&&e<=128591||e>=128640&&e<=128709||e===128716||e>=128720&&e<=128722||e>=128725&&e<=128727||e>=128732&&e<=128735||e===128747||e===128748||e>=128756&&e<=128764||e>=128992&&e<=129003||e===129008||e>=129292&&e<=129338||e>=129340&&e<=129349||e>=129351&&e<=129535||e>=129648&&e<=129660||e>=129664&&e<=129672||e>=129680&&e<=129725||e>=129727&&e<=129733||e>=129742&&e<=129755||e>=129760&&e<=129768||e>=129776&&e<=129784||e>=131072&&e<=196605||e>=196608&&e<=262141,W=/[\u001b\u009b][[()#;?]*(?:[0-9]{1,4}(?:;[0-9]{0,4})*)?[0-9A-ORZcf-nqry=><]/y,G=/[\x00-\x08\x0A-\x1F\x7F-\x9F]{1,1000}/y,K=/\t{1,1000}/y,Qe=/[\u{1F1E6}-\u{1F1FF}]{2}|\u{1F3F4}[\u{E0061}-\u{E007A}]{2}[\u{E0030}-\u{E0039}\u{E0061}-\u{E007A}]{1,3}\u{E007F}|(?:\p{Emoji}\uFE0F\u20E3?|\p{Emoji_Modifier_Base}\p{Emoji_Modifier}?|\p{Emoji_Presentation})(?:\u200D(?:\p{Emoji_Modifier_Base}\p{Emoji_Modifier}?|\p{Emoji_Presentation}|\p{Emoji}\uFE0F\u20E3?))*/uy,q=/(?:[\x20-\x7E\xA0-\xFF](?!\uFE0F)){1,1000}/y,$e=/\p{M}+/gu,et={limit:1/0,ellipsis:``},tt=(e,t={},n={})=>{let r=t.limit??1/0,i=t.ellipsis??``,a=t?.ellipsisWidth??(i?tt(i,et,n).width:0),o=n.ansiWidth??0,s=n.controlWidth??0,c=n.tabWidth??8,l=n.ambiguousWidth??1,u=n.emojiWidth??2,d=n.fullWidthWidth??2,f=n.regularWidth??1,p=n.wideWidth??2,m=0,h=0,g=e.length,_=0,v=!1,y=g,b=Math.max(0,r-a),x=0,S=0,C=0,w=0;t:for(;;){if(S>x||h>=g&&h>m){let t=e.slice(x,S)||e.slice(m,h);_=0;for(let e of t.replaceAll($e,``)){let t=e.codePointAt(0)||0;if(w=Xe(t)?d:Ze(t)?p:l!==f&&Ye(t)?l:f,C+w>b&&(y=Math.min(y,Math.max(x,m)+_)),C+w>r){v=!0;break t}_+=e.length,C+=w}x=S=0}if(h>=g)break;if(q.lastIndex=h,q.test(e)){if(_=q.lastIndex-h,w=_*f,C+w>b&&(y=Math.min(y,h+Math.floor((b-C)/f))),C+w>r){v=!0;break}C+=w,x=m,S=h,h=m=q.lastIndex;continue}if(W.lastIndex=h,W.test(e)){if(C+o>b&&(y=Math.min(y,h)),C+o>r){v=!0;break}C+=o,x=m,S=h,h=m=W.lastIndex;continue}if(G.lastIndex=h,G.test(e)){if(_=G.lastIndex-h,w=_*s,C+w>b&&(y=Math.min(y,h+Math.floor((b-C)/s))),C+w>r){v=!0;break}C+=w,x=m,S=h,h=m=G.lastIndex;continue}if(K.lastIndex=h,K.test(e)){if(_=K.lastIndex-h,w=_*c,C+w>b&&(y=Math.min(y,h+Math.floor((b-C)/c))),C+w>r){v=!0;break}C+=w,x=m,S=h,h=m=K.lastIndex;continue}if(Qe.lastIndex=h,Qe.test(e)){if(C+u>b&&(y=Math.min(y,h)),C+u>r){v=!0;break}C+=u,x=m,S=h,h=m=Qe.lastIndex;continue}h+=1}return{width:v?b:C,index:v?y:g,truncated:v,ellipsed:v&&r>=a}},nt={limit:1/0,ellipsis:``,ellipsisWidth:0},J=(e,t={})=>tt(e,nt,t).width,rt=`]8;;`,it=RegExp(`(?:\\[(?<code>\\d+)m|\\${rt}(?<uri>.*))`,`y`),at=e=>{if(e>=30&&e<=37||e>=90&&e<=97)return 39;if(e>=40&&e<=47||e>=100&&e<=107)return 49;if(e===1||e===2)return 22;if(e===3)return 23;if(e===4)return 24;if(e===7)return 27;if(e===8)return 28;if(e===9)return 29;if(e===0)return 0},ot=e=>`[${e}m`,st=e=>`${rt}${e}`,ct=e=>e.map(e=>J(e)),lt=(e,t,n)=>{let r=t[Symbol.iterator](),i=!1,a=!1,o=e.at(-1),s=o===void 0?0:J(o),c=r.next(),l=r.next(),u=0;for(;!c.done;){let o=c.value,d=J(o);s+d<=n?e[e.length-1]+=o:(e.push(o),s=0),(o===`\x1B`||o===``)&&(i=!0,a=t.startsWith(rt,u+1)),i?a?o===`\x07`&&(i=!1,a=!1):o===`m`&&(i=!1):(s+=d,s===n&&!l.done&&(e.push(``),s=0)),c=l,l=r.next(),u+=o.length}o=e.at(-1),!s&&o!==void 0&&o.length>0&&e.length>1&&(e[e.length-2]+=e.pop())},ut=e=>{let t=e.split(` `),n=t.length;for(;n>0&&!(J(t[n-1])>0);)n--;return n===t.length?e:t.slice(0,n).join(` `)+t.slice(n).join(``)},dt=(e,t,n={})=>{if(n.trim!==!1&&e.trim()===``)return``;let r=``,i,a,o=e.split(` `),s=ct(o),c=[``];for(let[e,r]of o.entries()){n.trim!==!1&&(c[c.length-1]=(c.at(-1)??``).trimStart());let i=J(c.at(-1)??``);if(e!==0&&(i>=t&&(n.wordWrap===!1||n.trim===!1)&&(c.push(``),i=0),(i>0||n.trim===!1)&&(c[c.length-1]+=` `,i++)),n.hard&&s[e]>t){let n=t-i,a=1+Math.floor((s[e]-n-1)/t);Math.floor((s[e]-1)/t)<a&&c.push(``),lt(c,r,t);continue}if(i+s[e]>t&&i>0&&s[e]>0){if(n.wordWrap===!1&&i<t){lt(c,r,t);continue}c.push(``)}if(i+s[e]>t&&n.wordWrap===!1){lt(c,r,t);continue}c[c.length-1]+=r}n.trim!==!1&&(c=c.map(e=>ut(e)));let l=c.join(`
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
323
|
+
`).map((i) => Et$1(i, e, s)).join(`
|
|
324
|
+
`);
|
|
325
|
+
}
|
|
326
|
+
const _$1 = {
|
|
327
|
+
actions: new Set([
|
|
328
|
+
"up",
|
|
329
|
+
"down",
|
|
330
|
+
"left",
|
|
331
|
+
"right",
|
|
332
|
+
"space",
|
|
333
|
+
"enter",
|
|
334
|
+
"cancel"
|
|
335
|
+
]),
|
|
336
|
+
aliases: new Map([
|
|
337
|
+
["k", "up"],
|
|
338
|
+
["j", "down"],
|
|
339
|
+
["h", "left"],
|
|
340
|
+
["l", "right"],
|
|
341
|
+
["", "cancel"],
|
|
342
|
+
["escape", "cancel"]
|
|
343
|
+
]),
|
|
344
|
+
messages: {
|
|
345
|
+
cancel: "Canceled",
|
|
346
|
+
error: "Something went wrong"
|
|
347
|
+
},
|
|
348
|
+
withGuide: !0
|
|
349
|
+
};
|
|
350
|
+
function H$2(t, e) {
|
|
351
|
+
if (typeof t == "string") return _$1.aliases.get(t) === e;
|
|
352
|
+
for (const s of t) if (s !== void 0 && H$2(s, e)) return !0;
|
|
353
|
+
return !1;
|
|
354
|
+
}
|
|
355
|
+
function _t(t, e) {
|
|
356
|
+
if (t === e) return;
|
|
357
|
+
const s = t.split(`
|
|
358
|
+
`), i = e.split(`
|
|
359
|
+
`), r = Math.max(s.length, i.length), n = [];
|
|
360
|
+
for (let u = 0; u < r; u++) s[u] !== i[u] && n.push(u);
|
|
361
|
+
return {
|
|
362
|
+
lines: n,
|
|
363
|
+
numLinesBefore: s.length,
|
|
364
|
+
numLinesAfter: i.length,
|
|
365
|
+
numLines: r
|
|
366
|
+
};
|
|
367
|
+
}
|
|
368
|
+
const bt$1 = globalThis.process.platform.startsWith("win"), z$1 = Symbol("clack:cancel");
|
|
369
|
+
function Ct$1(t) {
|
|
370
|
+
return t === z$1;
|
|
371
|
+
}
|
|
372
|
+
function T$1(t, e) {
|
|
373
|
+
const s = t;
|
|
374
|
+
s.isTTY && s.setRawMode(e);
|
|
375
|
+
}
|
|
376
|
+
function Bt({ input: t = stdin, output: e = stdout, overwrite: s = !0, hideCursor: i = !0 } = {}) {
|
|
377
|
+
const r = k$1.createInterface({
|
|
378
|
+
input: t,
|
|
379
|
+
output: e,
|
|
380
|
+
prompt: "",
|
|
381
|
+
tabSize: 1
|
|
382
|
+
});
|
|
383
|
+
k$1.emitKeypressEvents(t, r), t instanceof ReadStream && t.isTTY && t.setRawMode(!0);
|
|
384
|
+
const n = (u, { name: a, sequence: l }) => {
|
|
385
|
+
if (H$2([
|
|
386
|
+
String(u),
|
|
387
|
+
a,
|
|
388
|
+
l
|
|
389
|
+
], "cancel")) {
|
|
390
|
+
i && e.write(import_src.cursor.show), process.exit(0);
|
|
391
|
+
return;
|
|
392
|
+
}
|
|
393
|
+
if (!s) return;
|
|
394
|
+
const g = a === "return" ? 0 : -1, m = a === "return" ? -1 : 0;
|
|
395
|
+
k$1.moveCursor(e, g, m, () => {
|
|
396
|
+
k$1.clearLine(e, 1, () => {
|
|
397
|
+
t.once("keypress", n);
|
|
398
|
+
});
|
|
399
|
+
});
|
|
400
|
+
};
|
|
401
|
+
return i && e.write(import_src.cursor.hide), t.once("keypress", n), () => {
|
|
402
|
+
t.off("keypress", n), i && e.write(import_src.cursor.show), t instanceof ReadStream && t.isTTY && !bt$1 && t.setRawMode(!1), r.terminal = !1, r.close();
|
|
403
|
+
};
|
|
404
|
+
}
|
|
405
|
+
const rt$1 = (t) => "columns" in t && typeof t.columns == "number" ? t.columns : 80, nt$1 = (t) => "rows" in t && typeof t.rows == "number" ? t.rows : 20;
|
|
406
|
+
function xt(t, e, s, i = s) {
|
|
407
|
+
return K$2(e, rt$1(t ?? stdout) - s.length, {
|
|
408
|
+
hard: !0,
|
|
409
|
+
trim: !1
|
|
410
|
+
}).split(`
|
|
411
|
+
`).map((n, u) => `${u === 0 ? i : s}${n}`).join(`
|
|
412
|
+
`);
|
|
413
|
+
}
|
|
414
|
+
var x$2 = class {
|
|
415
|
+
input;
|
|
416
|
+
output;
|
|
417
|
+
_abortSignal;
|
|
418
|
+
rl;
|
|
419
|
+
opts;
|
|
420
|
+
_render;
|
|
421
|
+
_track = !1;
|
|
422
|
+
_prevFrame = "";
|
|
423
|
+
_subscribers = /* @__PURE__ */ new Map();
|
|
424
|
+
_cursor = 0;
|
|
425
|
+
state = "initial";
|
|
426
|
+
error = "";
|
|
427
|
+
value;
|
|
428
|
+
userInput = "";
|
|
429
|
+
constructor(e, s = !0) {
|
|
430
|
+
const { input: i = stdin, output: r = stdout, render: n, signal: u, ...a } = e;
|
|
431
|
+
this.opts = a, this.onKeypress = this.onKeypress.bind(this), this.close = this.close.bind(this), this.render = this.render.bind(this), this._render = n.bind(this), this._track = s, this._abortSignal = u, this.input = i, this.output = r;
|
|
432
|
+
}
|
|
433
|
+
unsubscribe() {
|
|
434
|
+
this._subscribers.clear();
|
|
435
|
+
}
|
|
436
|
+
setSubscriber(e, s) {
|
|
437
|
+
const i = this._subscribers.get(e) ?? [];
|
|
438
|
+
i.push(s), this._subscribers.set(e, i);
|
|
439
|
+
}
|
|
440
|
+
on(e, s) {
|
|
441
|
+
this.setSubscriber(e, { cb: s });
|
|
442
|
+
}
|
|
443
|
+
once(e, s) {
|
|
444
|
+
this.setSubscriber(e, {
|
|
445
|
+
cb: s,
|
|
446
|
+
once: !0
|
|
447
|
+
});
|
|
448
|
+
}
|
|
449
|
+
emit(e, ...s) {
|
|
450
|
+
const i = this._subscribers.get(e) ?? [], r = [];
|
|
451
|
+
for (const n of i) n.cb(...s), n.once && r.push(() => i.splice(i.indexOf(n), 1));
|
|
452
|
+
for (const n of r) n();
|
|
453
|
+
}
|
|
454
|
+
prompt() {
|
|
455
|
+
return new Promise((e) => {
|
|
456
|
+
if (this._abortSignal) {
|
|
457
|
+
if (this._abortSignal.aborted) return this.state = "cancel", this.close(), e(z$1);
|
|
458
|
+
this._abortSignal.addEventListener("abort", () => {
|
|
459
|
+
this.state = "cancel", this.close();
|
|
460
|
+
}, { once: !0 });
|
|
461
|
+
}
|
|
462
|
+
this.rl = c.createInterface({
|
|
463
|
+
input: this.input,
|
|
464
|
+
tabSize: 2,
|
|
465
|
+
prompt: "",
|
|
466
|
+
escapeCodeTimeout: 50,
|
|
467
|
+
terminal: !0
|
|
468
|
+
}), this.rl.prompt(), this.opts.initialUserInput !== void 0 && this._setUserInput(this.opts.initialUserInput, !0), this.input.on("keypress", this.onKeypress), T$1(this.input, !0), this.output.on("resize", this.render), this.render(), this.once("submit", () => {
|
|
469
|
+
this.output.write(import_src.cursor.show), this.output.off("resize", this.render), T$1(this.input, !1), e(this.value);
|
|
470
|
+
}), this.once("cancel", () => {
|
|
471
|
+
this.output.write(import_src.cursor.show), this.output.off("resize", this.render), T$1(this.input, !1), e(z$1);
|
|
472
|
+
});
|
|
473
|
+
});
|
|
474
|
+
}
|
|
475
|
+
_isActionKey(e, s) {
|
|
476
|
+
return e === " ";
|
|
477
|
+
}
|
|
478
|
+
_setValue(e) {
|
|
479
|
+
this.value = e, this.emit("value", this.value);
|
|
480
|
+
}
|
|
481
|
+
_setUserInput(e, s) {
|
|
482
|
+
this.userInput = e ?? "", this.emit("userInput", this.userInput), s && this._track && this.rl && (this.rl.write(this.userInput), this._cursor = this.rl.cursor);
|
|
483
|
+
}
|
|
484
|
+
_clearUserInput() {
|
|
485
|
+
this.rl?.write(null, {
|
|
486
|
+
ctrl: !0,
|
|
487
|
+
name: "u"
|
|
488
|
+
}), this._setUserInput("");
|
|
489
|
+
}
|
|
490
|
+
onKeypress(e, s) {
|
|
491
|
+
if (this._track && s.name !== "return" && (s.name && this._isActionKey(e, s) && this.rl?.write(null, {
|
|
492
|
+
ctrl: !0,
|
|
493
|
+
name: "h"
|
|
494
|
+
}), this._cursor = this.rl?.cursor ?? 0, this._setUserInput(this.rl?.line)), this.state === "error" && (this.state = "active"), s?.name && (!this._track && _$1.aliases.has(s.name) && this.emit("cursor", _$1.aliases.get(s.name)), _$1.actions.has(s.name) && this.emit("cursor", s.name)), e && (e.toLowerCase() === "y" || e.toLowerCase() === "n") && this.emit("confirm", e.toLowerCase() === "y"), this.emit("key", e?.toLowerCase(), s), s?.name === "return") {
|
|
495
|
+
if (this.opts.validate) {
|
|
496
|
+
const i = this.opts.validate(this.value);
|
|
497
|
+
i && (this.error = i instanceof Error ? i.message : i, this.state = "error", this.rl?.write(this.userInput));
|
|
498
|
+
}
|
|
499
|
+
this.state !== "error" && (this.state = "submit");
|
|
500
|
+
}
|
|
501
|
+
H$2([
|
|
502
|
+
e,
|
|
503
|
+
s?.name,
|
|
504
|
+
s?.sequence
|
|
505
|
+
], "cancel") && (this.state = "cancel"), (this.state === "submit" || this.state === "cancel") && this.emit("finalize"), this.render(), (this.state === "submit" || this.state === "cancel") && this.close();
|
|
506
|
+
}
|
|
507
|
+
close() {
|
|
508
|
+
this.input.unpipe(), this.input.removeListener("keypress", this.onKeypress), this.output.write(`
|
|
509
|
+
`), T$1(this.input, !1), this.rl?.close(), this.rl = void 0, this.emit(`${this.state}`, this.value), this.unsubscribe();
|
|
510
|
+
}
|
|
511
|
+
restoreCursor() {
|
|
512
|
+
const e = K$2(this._prevFrame, process.stdout.columns, {
|
|
513
|
+
hard: !0,
|
|
514
|
+
trim: !1
|
|
515
|
+
}).split(`
|
|
516
|
+
`).length - 1;
|
|
517
|
+
this.output.write(import_src.cursor.move(-999, e * -1));
|
|
518
|
+
}
|
|
519
|
+
render() {
|
|
520
|
+
const e = K$2(this._render(this) ?? "", process.stdout.columns, {
|
|
521
|
+
hard: !0,
|
|
522
|
+
trim: !1
|
|
523
|
+
});
|
|
524
|
+
if (e !== this._prevFrame) {
|
|
525
|
+
if (this.state === "initial") this.output.write(import_src.cursor.hide);
|
|
526
|
+
else {
|
|
527
|
+
const s = _t(this._prevFrame, e), i = nt$1(this.output);
|
|
528
|
+
if (this.restoreCursor(), s) {
|
|
529
|
+
const r = Math.max(0, s.numLinesAfter - i), n = Math.max(0, s.numLinesBefore - i);
|
|
530
|
+
let u = s.lines.find((a) => a >= r);
|
|
531
|
+
if (u === void 0) {
|
|
532
|
+
this._prevFrame = e;
|
|
533
|
+
return;
|
|
534
|
+
}
|
|
535
|
+
if (s.lines.length === 1) {
|
|
536
|
+
this.output.write(import_src.cursor.move(0, u - n)), this.output.write(import_src.erase.lines(1));
|
|
537
|
+
const a = e.split(`
|
|
538
|
+
`);
|
|
539
|
+
this.output.write(a[u]), this._prevFrame = e, this.output.write(import_src.cursor.move(0, a.length - u - 1));
|
|
540
|
+
return;
|
|
541
|
+
} else if (s.lines.length > 1) {
|
|
542
|
+
if (r < n) u = r;
|
|
543
|
+
else {
|
|
544
|
+
const l = u - n;
|
|
545
|
+
l > 0 && this.output.write(import_src.cursor.move(0, l));
|
|
546
|
+
}
|
|
547
|
+
this.output.write(import_src.erase.down());
|
|
548
|
+
const a = e.split(`
|
|
549
|
+
`).slice(u);
|
|
550
|
+
this.output.write(a.join(`
|
|
551
|
+
`)), this._prevFrame = e;
|
|
552
|
+
return;
|
|
553
|
+
}
|
|
554
|
+
}
|
|
555
|
+
this.output.write(import_src.erase.down());
|
|
556
|
+
}
|
|
557
|
+
this.output.write(e), this.state === "initial" && (this.state = "active"), this._prevFrame = e;
|
|
558
|
+
}
|
|
559
|
+
}
|
|
560
|
+
};
|
|
561
|
+
function wt$1(t, e) {
|
|
562
|
+
if (t === void 0 || e.length === 0) return 0;
|
|
563
|
+
const s = e.findIndex((i) => i.value === t);
|
|
564
|
+
return s !== -1 ? s : 0;
|
|
565
|
+
}
|
|
566
|
+
function Dt$1(t, e) {
|
|
567
|
+
return (e.label ?? String(e.value)).toLowerCase().includes(t.toLowerCase());
|
|
568
|
+
}
|
|
569
|
+
function St$1(t, e) {
|
|
570
|
+
if (e) return t ? e : e[0];
|
|
571
|
+
}
|
|
572
|
+
var Vt$1 = class extends x$2 {
|
|
573
|
+
filteredOptions;
|
|
574
|
+
multiple;
|
|
575
|
+
isNavigating = !1;
|
|
576
|
+
selectedValues = [];
|
|
577
|
+
focusedValue;
|
|
578
|
+
#t = 0;
|
|
579
|
+
#s = "";
|
|
580
|
+
#i;
|
|
581
|
+
#e;
|
|
582
|
+
get cursor() {
|
|
583
|
+
return this.#t;
|
|
584
|
+
}
|
|
585
|
+
get userInputWithCursor() {
|
|
586
|
+
if (!this.userInput) return import_picocolors.default.inverse(import_picocolors.default.hidden("_"));
|
|
587
|
+
if (this._cursor >= this.userInput.length) return `${this.userInput}\u2588`;
|
|
588
|
+
const e = this.userInput.slice(0, this._cursor), [s, ...i] = this.userInput.slice(this._cursor);
|
|
589
|
+
return `${e}${import_picocolors.default.inverse(s)}${i.join("")}`;
|
|
590
|
+
}
|
|
591
|
+
get options() {
|
|
592
|
+
return typeof this.#e == "function" ? this.#e() : this.#e;
|
|
593
|
+
}
|
|
594
|
+
constructor(e) {
|
|
595
|
+
super(e), this.#e = e.options;
|
|
596
|
+
const s = this.options;
|
|
597
|
+
this.filteredOptions = [...s], this.multiple = e.multiple === !0, this.#i = e.filter ?? Dt$1;
|
|
598
|
+
let i;
|
|
599
|
+
if (e.initialValue && Array.isArray(e.initialValue) ? this.multiple ? i = e.initialValue : i = e.initialValue.slice(0, 1) : !this.multiple && this.options.length > 0 && (i = [this.options[0].value]), i) for (const r of i) {
|
|
600
|
+
const n = s.findIndex((u) => u.value === r);
|
|
601
|
+
n !== -1 && (this.toggleSelected(r), this.#t = n);
|
|
602
|
+
}
|
|
603
|
+
this.focusedValue = this.options[this.#t]?.value, this.on("key", (r, n) => this.#r(r, n)), this.on("userInput", (r) => this.#n(r));
|
|
604
|
+
}
|
|
605
|
+
_isActionKey(e, s) {
|
|
606
|
+
return e === " " || this.multiple && this.isNavigating && s.name === "space" && e !== void 0 && e !== "";
|
|
607
|
+
}
|
|
608
|
+
#r(e, s) {
|
|
609
|
+
const i = s.name === "up", r = s.name === "down", n = s.name === "return";
|
|
610
|
+
i || r ? (this.#t = B$1(this.#t, i ? -1 : 1, this.filteredOptions), this.focusedValue = this.filteredOptions[this.#t]?.value, this.multiple || (this.selectedValues = [this.focusedValue]), this.isNavigating = !0) : n ? this.value = St$1(this.multiple, this.selectedValues) : this.multiple ? this.focusedValue !== void 0 && (s.name === "tab" || this.isNavigating && s.name === "space") ? this.toggleSelected(this.focusedValue) : this.isNavigating = !1 : (this.focusedValue && (this.selectedValues = [this.focusedValue]), this.isNavigating = !1);
|
|
611
|
+
}
|
|
612
|
+
deselectAll() {
|
|
613
|
+
this.selectedValues = [];
|
|
614
|
+
}
|
|
615
|
+
toggleSelected(e) {
|
|
616
|
+
this.filteredOptions.length !== 0 && (this.multiple ? this.selectedValues.includes(e) ? this.selectedValues = this.selectedValues.filter((s) => s !== e) : this.selectedValues = [...this.selectedValues, e] : this.selectedValues = [e]);
|
|
617
|
+
}
|
|
618
|
+
#n(e) {
|
|
619
|
+
if (e !== this.#s) {
|
|
620
|
+
this.#s = e;
|
|
621
|
+
const s = this.options;
|
|
622
|
+
e ? this.filteredOptions = s.filter((n) => this.#i(e, n)) : this.filteredOptions = [...s];
|
|
623
|
+
this.#t = B$1(wt$1(this.focusedValue, this.filteredOptions), 0, this.filteredOptions);
|
|
624
|
+
const r = this.filteredOptions[this.#t];
|
|
625
|
+
r && !r.disabled ? this.focusedValue = r.value : this.focusedValue = void 0, this.multiple || (this.focusedValue !== void 0 ? this.toggleSelected(this.focusedValue) : this.deselectAll());
|
|
626
|
+
}
|
|
627
|
+
}
|
|
628
|
+
};
|
|
629
|
+
var kt$1 = class extends x$2 {
|
|
630
|
+
get cursor() {
|
|
631
|
+
return this.value ? 0 : 1;
|
|
632
|
+
}
|
|
633
|
+
get _value() {
|
|
634
|
+
return this.cursor === 0;
|
|
635
|
+
}
|
|
636
|
+
constructor(e) {
|
|
637
|
+
super(e, !1), this.value = !!e.initialValue, this.on("userInput", () => {
|
|
638
|
+
this.value = this._value;
|
|
639
|
+
}), this.on("confirm", (s) => {
|
|
640
|
+
this.output.write(import_src.cursor.move(0, -1)), this.value = s, this.state = "submit", this.close();
|
|
641
|
+
}), this.on("cursor", () => {
|
|
642
|
+
this.value = !this.value;
|
|
643
|
+
});
|
|
644
|
+
}
|
|
645
|
+
};
|
|
646
|
+
var yt$1 = class extends x$2 {
|
|
647
|
+
options;
|
|
648
|
+
cursor = 0;
|
|
649
|
+
#t;
|
|
650
|
+
getGroupItems(e) {
|
|
651
|
+
return this.options.filter((s) => s.group === e);
|
|
652
|
+
}
|
|
653
|
+
isGroupSelected(e) {
|
|
654
|
+
const s = this.getGroupItems(e), i = this.value;
|
|
655
|
+
return i === void 0 ? !1 : s.every((r) => i.includes(r.value));
|
|
656
|
+
}
|
|
657
|
+
toggleValue() {
|
|
658
|
+
const e = this.options[this.cursor];
|
|
659
|
+
if (this.value === void 0 && (this.value = []), e.group === !0) {
|
|
660
|
+
const s = e.value, i = this.getGroupItems(s);
|
|
661
|
+
this.isGroupSelected(s) ? this.value = this.value.filter((r) => i.findIndex((n) => n.value === r) === -1) : this.value = [...this.value, ...i.map((r) => r.value)], this.value = Array.from(new Set(this.value));
|
|
662
|
+
} else this.value = this.value.includes(e.value) ? this.value.filter((i) => i !== e.value) : [...this.value, e.value];
|
|
663
|
+
}
|
|
664
|
+
constructor(e) {
|
|
665
|
+
super(e, !1);
|
|
666
|
+
const { options: s } = e;
|
|
667
|
+
this.#t = e.selectableGroups !== !1, this.options = Object.entries(s).flatMap(([i, r]) => [{
|
|
668
|
+
value: i,
|
|
669
|
+
group: !0,
|
|
670
|
+
label: i
|
|
671
|
+
}, ...r.map((n) => ({
|
|
672
|
+
...n,
|
|
673
|
+
group: i
|
|
674
|
+
}))]), this.value = [...e.initialValues ?? []], this.cursor = Math.max(this.options.findIndex(({ value: i }) => i === e.cursorAt), this.#t ? 0 : 1), this.on("cursor", (i) => {
|
|
675
|
+
switch (i) {
|
|
676
|
+
case "left":
|
|
677
|
+
case "up": {
|
|
678
|
+
this.cursor = this.cursor === 0 ? this.options.length - 1 : this.cursor - 1;
|
|
679
|
+
const r = this.options[this.cursor]?.group === !0;
|
|
680
|
+
!this.#t && r && (this.cursor = this.cursor === 0 ? this.options.length - 1 : this.cursor - 1);
|
|
681
|
+
break;
|
|
682
|
+
}
|
|
683
|
+
case "down":
|
|
684
|
+
case "right": {
|
|
685
|
+
this.cursor = this.cursor === this.options.length - 1 ? 0 : this.cursor + 1;
|
|
686
|
+
const r = this.options[this.cursor]?.group === !0;
|
|
687
|
+
!this.#t && r && (this.cursor = this.cursor === this.options.length - 1 ? 0 : this.cursor + 1);
|
|
688
|
+
break;
|
|
689
|
+
}
|
|
690
|
+
case "space":
|
|
691
|
+
this.toggleValue();
|
|
692
|
+
break;
|
|
693
|
+
}
|
|
694
|
+
});
|
|
695
|
+
}
|
|
696
|
+
};
|
|
697
|
+
var Lt$1 = class extends x$2 {
|
|
698
|
+
options;
|
|
699
|
+
cursor = 0;
|
|
700
|
+
get _value() {
|
|
701
|
+
return this.options[this.cursor].value;
|
|
702
|
+
}
|
|
703
|
+
get _enabledOptions() {
|
|
704
|
+
return this.options.filter((e) => e.disabled !== !0);
|
|
705
|
+
}
|
|
706
|
+
toggleAll() {
|
|
707
|
+
const e = this._enabledOptions;
|
|
708
|
+
this.value = this.value !== void 0 && this.value.length === e.length ? [] : e.map((i) => i.value);
|
|
709
|
+
}
|
|
710
|
+
toggleInvert() {
|
|
711
|
+
const e = this.value;
|
|
712
|
+
if (!e) return;
|
|
713
|
+
this.value = this._enabledOptions.filter((i) => !e.includes(i.value)).map((i) => i.value);
|
|
714
|
+
}
|
|
715
|
+
toggleValue() {
|
|
716
|
+
this.value === void 0 && (this.value = []);
|
|
717
|
+
this.value = this.value.includes(this._value) ? this.value.filter((s) => s !== this._value) : [...this.value, this._value];
|
|
718
|
+
}
|
|
719
|
+
constructor(e) {
|
|
720
|
+
super(e, !1), this.options = e.options, this.value = [...e.initialValues ?? []];
|
|
721
|
+
const s = Math.max(this.options.findIndex(({ value: i }) => i === e.cursorAt), 0);
|
|
722
|
+
this.cursor = this.options[s].disabled ? B$1(s, 1, this.options) : s, this.on("key", (i) => {
|
|
723
|
+
i === "a" && this.toggleAll(), i === "i" && this.toggleInvert();
|
|
724
|
+
}), this.on("cursor", (i) => {
|
|
725
|
+
switch (i) {
|
|
726
|
+
case "left":
|
|
727
|
+
case "up":
|
|
728
|
+
this.cursor = B$1(this.cursor, -1, this.options);
|
|
729
|
+
break;
|
|
730
|
+
case "down":
|
|
731
|
+
case "right":
|
|
732
|
+
this.cursor = B$1(this.cursor, 1, this.options);
|
|
733
|
+
break;
|
|
734
|
+
case "space":
|
|
735
|
+
this.toggleValue();
|
|
736
|
+
break;
|
|
737
|
+
}
|
|
738
|
+
});
|
|
739
|
+
}
|
|
740
|
+
};
|
|
741
|
+
let Mt$1 = class extends x$2 {
|
|
742
|
+
_mask = "•";
|
|
743
|
+
get cursor() {
|
|
744
|
+
return this._cursor;
|
|
745
|
+
}
|
|
746
|
+
get masked() {
|
|
747
|
+
return this.userInput.replaceAll(/./g, this._mask);
|
|
748
|
+
}
|
|
749
|
+
get userInputWithCursor() {
|
|
750
|
+
if (this.state === "submit" || this.state === "cancel") return this.masked;
|
|
751
|
+
const e = this.userInput;
|
|
752
|
+
if (this.cursor >= e.length) return `${this.masked}${import_picocolors.default.inverse(import_picocolors.default.hidden("_"))}`;
|
|
753
|
+
const s = this.masked, i = s.slice(0, this.cursor), r = s.slice(this.cursor);
|
|
754
|
+
return `${i}${import_picocolors.default.inverse(r[0])}${r.slice(1)}`;
|
|
755
|
+
}
|
|
756
|
+
clear() {
|
|
757
|
+
this._clearUserInput();
|
|
758
|
+
}
|
|
759
|
+
constructor({ mask: e, ...s }) {
|
|
760
|
+
super(s), this._mask = e ?? "•", this.on("userInput", (i) => {
|
|
761
|
+
this._setValue(i);
|
|
762
|
+
});
|
|
763
|
+
}
|
|
764
|
+
};
|
|
765
|
+
var Wt$1 = class extends x$2 {
|
|
766
|
+
options;
|
|
767
|
+
cursor = 0;
|
|
768
|
+
get _selectedValue() {
|
|
769
|
+
return this.options[this.cursor];
|
|
770
|
+
}
|
|
771
|
+
changeValue() {
|
|
772
|
+
this.value = this._selectedValue.value;
|
|
773
|
+
}
|
|
774
|
+
constructor(e) {
|
|
775
|
+
super(e, !1), this.options = e.options;
|
|
776
|
+
const s = this.options.findIndex(({ value: r }) => r === e.initialValue), i = s === -1 ? 0 : s;
|
|
777
|
+
this.cursor = this.options[i].disabled ? B$1(i, 1, this.options) : i, this.changeValue(), this.on("cursor", (r) => {
|
|
778
|
+
switch (r) {
|
|
779
|
+
case "left":
|
|
780
|
+
case "up":
|
|
781
|
+
this.cursor = B$1(this.cursor, -1, this.options);
|
|
782
|
+
break;
|
|
783
|
+
case "down":
|
|
784
|
+
case "right":
|
|
785
|
+
this.cursor = B$1(this.cursor, 1, this.options);
|
|
786
|
+
break;
|
|
787
|
+
}
|
|
788
|
+
this.changeValue();
|
|
789
|
+
});
|
|
790
|
+
}
|
|
791
|
+
};
|
|
792
|
+
var Tt$1 = class extends x$2 {
|
|
793
|
+
options;
|
|
794
|
+
cursor = 0;
|
|
795
|
+
constructor(e) {
|
|
796
|
+
super(e, !1), this.options = e.options;
|
|
797
|
+
const s = e.caseSensitive === !0, i = this.options.map(({ value: [r] }) => s ? r : r?.toLowerCase());
|
|
798
|
+
this.cursor = Math.max(i.indexOf(e.initialValue), 0), this.on("key", (r, n) => {
|
|
799
|
+
if (!r) return;
|
|
800
|
+
const u = s && n.shift ? r.toUpperCase() : r;
|
|
801
|
+
if (!i.includes(u)) return;
|
|
802
|
+
const a = this.options.find(({ value: [l] }) => s ? l === u : l?.toLowerCase() === r);
|
|
803
|
+
a && (this.value = a.value, this.state = "submit", this.emit("submit"));
|
|
804
|
+
});
|
|
805
|
+
}
|
|
806
|
+
};
|
|
807
|
+
var $t$1 = class extends x$2 {
|
|
808
|
+
get userInputWithCursor() {
|
|
809
|
+
if (this.state === "submit") return this.userInput;
|
|
810
|
+
const e = this.userInput;
|
|
811
|
+
if (this.cursor >= e.length) return `${this.userInput}\u2588`;
|
|
812
|
+
const s = e.slice(0, this.cursor), [i, ...r] = e.slice(this.cursor);
|
|
813
|
+
return `${s}${import_picocolors.default.inverse(i)}${r.join("")}`;
|
|
814
|
+
}
|
|
815
|
+
get cursor() {
|
|
816
|
+
return this._cursor;
|
|
817
|
+
}
|
|
818
|
+
constructor(e) {
|
|
819
|
+
super({
|
|
820
|
+
...e,
|
|
821
|
+
initialUserInput: e.initialUserInput ?? e.initialValue
|
|
822
|
+
}), this.on("userInput", (s) => {
|
|
823
|
+
this._setValue(s);
|
|
824
|
+
}), this.on("finalize", () => {
|
|
825
|
+
this.value || (this.value = e.defaultValue), this.value === void 0 && (this.value = "");
|
|
826
|
+
});
|
|
827
|
+
}
|
|
828
|
+
};
|
|
829
|
+
|
|
830
|
+
//#endregion
|
|
831
|
+
//#region node_modules/@clack/prompts/dist/index.mjs
|
|
832
|
+
function me() {
|
|
833
|
+
return N.platform !== "win32" ? N.env.TERM !== "linux" : !!N.env.CI || !!N.env.WT_SESSION || !!N.env.TERMINUS_SUBLIME || N.env.ConEmuTask === "{cmd::Cmder}" || N.env.TERM_PROGRAM === "Terminus-Sublime" || N.env.TERM_PROGRAM === "vscode" || N.env.TERM === "xterm-256color" || N.env.TERM === "alacritty" || N.env.TERMINAL_EMULATOR === "JetBrains-JediTerm";
|
|
834
|
+
}
|
|
835
|
+
const et = me(), ct = () => process.env.CI === "true", Mt = (t) => t.isTTY === !0, C$1 = (t, r) => et ? t : r, Rt = C$1("◆", "*"), dt = C$1("■", "x"), $t = C$1("▲", "x"), V$1 = C$1("◇", "o"), ht = C$1("┌", "T"), d$1 = C$1("│", "|"), x$1 = C$1("└", "—"), Ot = C$1("┐", "T"), Pt = C$1("┘", "—"), Q = C$1("●", ">"), H$1 = C$1("○", " "), st = C$1("◻", "[•]"), U$1 = C$1("◼", "[+]"), q$1 = C$1("◻", "[ ]"), Nt = C$1("▪", "•"), rt = C$1("─", "-"), mt = C$1("╮", "+"), Wt = C$1("├", "+"), pt = C$1("╯", "+"), gt = C$1("╰", "+"), Lt = C$1("╭", "+"), ft = C$1("●", "•"), Ft = C$1("◆", "*"), yt = C$1("▲", "!"), Et = C$1("■", "x"), W$1 = (t) => {
|
|
836
|
+
switch (t) {
|
|
837
|
+
case "initial":
|
|
838
|
+
case "active": return import_picocolors.default.cyan(Rt);
|
|
839
|
+
case "cancel": return import_picocolors.default.red(dt);
|
|
840
|
+
case "error": return import_picocolors.default.yellow($t);
|
|
841
|
+
case "submit": return import_picocolors.default.green(V$1);
|
|
842
|
+
}
|
|
843
|
+
}, vt = (t) => {
|
|
844
|
+
switch (t) {
|
|
845
|
+
case "initial":
|
|
846
|
+
case "active": return import_picocolors.default.cyan(d$1);
|
|
847
|
+
case "cancel": return import_picocolors.default.red(d$1);
|
|
848
|
+
case "error": return import_picocolors.default.yellow(d$1);
|
|
849
|
+
case "submit": return import_picocolors.default.green(d$1);
|
|
850
|
+
}
|
|
851
|
+
}, pe = (t) => t === 161 || t === 164 || t === 167 || t === 168 || t === 170 || t === 173 || t === 174 || t >= 176 && t <= 180 || t >= 182 && t <= 186 || t >= 188 && t <= 191 || t === 198 || t === 208 || t === 215 || t === 216 || t >= 222 && t <= 225 || t === 230 || t >= 232 && t <= 234 || t === 236 || t === 237 || t === 240 || t === 242 || t === 243 || t >= 247 && t <= 250 || t === 252 || t === 254 || t === 257 || t === 273 || t === 275 || t === 283 || t === 294 || t === 295 || t === 299 || t >= 305 && t <= 307 || t === 312 || t >= 319 && t <= 322 || t === 324 || t >= 328 && t <= 331 || t === 333 || t === 338 || t === 339 || t === 358 || t === 359 || t === 363 || t === 462 || t === 464 || t === 466 || t === 468 || t === 470 || t === 472 || t === 474 || t === 476 || t === 593 || t === 609 || t === 708 || t === 711 || t >= 713 && t <= 715 || t === 717 || t === 720 || t >= 728 && t <= 731 || t === 733 || t === 735 || t >= 768 && t <= 879 || t >= 913 && t <= 929 || t >= 931 && t <= 937 || t >= 945 && t <= 961 || t >= 963 && t <= 969 || t === 1025 || t >= 1040 && t <= 1103 || t === 1105 || t === 8208 || t >= 8211 && t <= 8214 || t === 8216 || t === 8217 || t === 8220 || t === 8221 || t >= 8224 && t <= 8226 || t >= 8228 && t <= 8231 || t === 8240 || t === 8242 || t === 8243 || t === 8245 || t === 8251 || t === 8254 || t === 8308 || t === 8319 || t >= 8321 && t <= 8324 || t === 8364 || t === 8451 || t === 8453 || t === 8457 || t === 8467 || t === 8470 || t === 8481 || t === 8482 || t === 8486 || t === 8491 || t === 8531 || t === 8532 || t >= 8539 && t <= 8542 || t >= 8544 && t <= 8555 || t >= 8560 && t <= 8569 || t === 8585 || t >= 8592 && t <= 8601 || t === 8632 || t === 8633 || t === 8658 || t === 8660 || t === 8679 || t === 8704 || t === 8706 || t === 8707 || t === 8711 || t === 8712 || t === 8715 || t === 8719 || t === 8721 || t === 8725 || t === 8730 || t >= 8733 && t <= 8736 || t === 8739 || t === 8741 || t >= 8743 && t <= 8748 || t === 8750 || t >= 8756 && t <= 8759 || t === 8764 || t === 8765 || t === 8776 || t === 8780 || t === 8786 || t === 8800 || t === 8801 || t >= 8804 && t <= 8807 || t === 8810 || t === 8811 || t === 8814 || t === 8815 || t === 8834 || t === 8835 || t === 8838 || t === 8839 || t === 8853 || t === 8857 || t === 8869 || t === 8895 || t === 8978 || t >= 9312 && t <= 9449 || t >= 9451 && t <= 9547 || t >= 9552 && t <= 9587 || t >= 9600 && t <= 9615 || t >= 9618 && t <= 9621 || t === 9632 || t === 9633 || t >= 9635 && t <= 9641 || t === 9650 || t === 9651 || t === 9654 || t === 9655 || t === 9660 || t === 9661 || t === 9664 || t === 9665 || t >= 9670 && t <= 9672 || t === 9675 || t >= 9678 && t <= 9681 || t >= 9698 && t <= 9701 || t === 9711 || t === 9733 || t === 9734 || t === 9737 || t === 9742 || t === 9743 || t === 9756 || t === 9758 || t === 9792 || t === 9794 || t === 9824 || t === 9825 || t >= 9827 && t <= 9829 || t >= 9831 && t <= 9834 || t === 9836 || t === 9837 || t === 9839 || t === 9886 || t === 9887 || t === 9919 || t >= 9926 && t <= 9933 || t >= 9935 && t <= 9939 || t >= 9941 && t <= 9953 || t === 9955 || t === 9960 || t === 9961 || t >= 9963 && t <= 9969 || t === 9972 || t >= 9974 && t <= 9977 || t === 9979 || t === 9980 || t === 9982 || t === 9983 || t === 10045 || t >= 10102 && t <= 10111 || t >= 11094 && t <= 11097 || t >= 12872 && t <= 12879 || t >= 57344 && t <= 63743 || t >= 65024 && t <= 65039 || t === 65533 || t >= 127232 && t <= 127242 || t >= 127248 && t <= 127277 || t >= 127280 && t <= 127337 || t >= 127344 && t <= 127373 || t === 127375 || t === 127376 || t >= 127387 && t <= 127404 || t >= 917760 && t <= 917999 || t >= 983040 && t <= 1048573 || t >= 1048576 && t <= 1114109, ge = (t) => t === 12288 || t >= 65281 && t <= 65376 || t >= 65504 && t <= 65510, fe = (t) => t >= 4352 && t <= 4447 || t === 8986 || t === 8987 || t === 9001 || t === 9002 || t >= 9193 && t <= 9196 || t === 9200 || t === 9203 || t === 9725 || t === 9726 || t === 9748 || t === 9749 || t >= 9800 && t <= 9811 || t === 9855 || t === 9875 || t === 9889 || t === 9898 || t === 9899 || t === 9917 || t === 9918 || t === 9924 || t === 9925 || t === 9934 || t === 9940 || t === 9962 || t === 9970 || t === 9971 || t === 9973 || t === 9978 || t === 9981 || t === 9989 || t === 9994 || t === 9995 || t === 10024 || t === 10060 || t === 10062 || t >= 10067 && t <= 10069 || t === 10071 || t >= 10133 && t <= 10135 || t === 10160 || t === 10175 || t === 11035 || t === 11036 || t === 11088 || t === 11093 || t >= 11904 && t <= 11929 || t >= 11931 && t <= 12019 || t >= 12032 && t <= 12245 || t >= 12272 && t <= 12287 || t >= 12289 && t <= 12350 || t >= 12353 && t <= 12438 || t >= 12441 && t <= 12543 || t >= 12549 && t <= 12591 || t >= 12593 && t <= 12686 || t >= 12688 && t <= 12771 || t >= 12783 && t <= 12830 || t >= 12832 && t <= 12871 || t >= 12880 && t <= 19903 || t >= 19968 && t <= 42124 || t >= 42128 && t <= 42182 || t >= 43360 && t <= 43388 || t >= 44032 && t <= 55203 || t >= 63744 && t <= 64255 || t >= 65040 && t <= 65049 || t >= 65072 && t <= 65106 || t >= 65108 && t <= 65126 || t >= 65128 && t <= 65131 || t >= 94176 && t <= 94180 || t === 94192 || t === 94193 || t >= 94208 && t <= 100343 || t >= 100352 && t <= 101589 || t >= 101632 && t <= 101640 || t >= 110576 && t <= 110579 || t >= 110581 && t <= 110587 || t === 110589 || t === 110590 || t >= 110592 && t <= 110882 || t === 110898 || t >= 110928 && t <= 110930 || t === 110933 || t >= 110948 && t <= 110951 || t >= 110960 && t <= 111355 || t === 126980 || t === 127183 || t === 127374 || t >= 127377 && t <= 127386 || t >= 127488 && t <= 127490 || t >= 127504 && t <= 127547 || t >= 127552 && t <= 127560 || t === 127568 || t === 127569 || t >= 127584 && t <= 127589 || t >= 127744 && t <= 127776 || t >= 127789 && t <= 127797 || t >= 127799 && t <= 127868 || t >= 127870 && t <= 127891 || t >= 127904 && t <= 127946 || t >= 127951 && t <= 127955 || t >= 127968 && t <= 127984 || t === 127988 || t >= 127992 && t <= 128062 || t === 128064 || t >= 128066 && t <= 128252 || t >= 128255 && t <= 128317 || t >= 128331 && t <= 128334 || t >= 128336 && t <= 128359 || t === 128378 || t === 128405 || t === 128406 || t === 128420 || t >= 128507 && t <= 128591 || t >= 128640 && t <= 128709 || t === 128716 || t >= 128720 && t <= 128722 || t >= 128725 && t <= 128727 || t >= 128732 && t <= 128735 || t === 128747 || t === 128748 || t >= 128756 && t <= 128764 || t >= 128992 && t <= 129003 || t === 129008 || t >= 129292 && t <= 129338 || t >= 129340 && t <= 129349 || t >= 129351 && t <= 129535 || t >= 129648 && t <= 129660 || t >= 129664 && t <= 129672 || t >= 129680 && t <= 129725 || t >= 129727 && t <= 129733 || t >= 129742 && t <= 129755 || t >= 129760 && t <= 129768 || t >= 129776 && t <= 129784 || t >= 131072 && t <= 196605 || t >= 196608 && t <= 262141, At = /[\u001b\u009b][[()#;?]*(?:[0-9]{1,4}(?:;[0-9]{0,4})*)?[0-9A-ORZcf-nqry=><]/y, it = /[\x00-\x08\x0A-\x1F\x7F-\x9F]{1,1000}/y, nt = /\t{1,1000}/y, wt = /[\u{1F1E6}-\u{1F1FF}]{2}|\u{1F3F4}[\u{E0061}-\u{E007A}]{2}[\u{E0030}-\u{E0039}\u{E0061}-\u{E007A}]{1,3}\u{E007F}|(?:\p{Emoji}\uFE0F\u20E3?|\p{Emoji_Modifier_Base}\p{Emoji_Modifier}?|\p{Emoji_Presentation})(?:\u200D(?:\p{Emoji_Modifier_Base}\p{Emoji_Modifier}?|\p{Emoji_Presentation}|\p{Emoji}\uFE0F\u20E3?))*/uy, at = /(?:[\x20-\x7E\xA0-\xFF](?!\uFE0F)){1,1000}/y, Fe = /\p{M}+/gu, ye = {
|
|
852
|
+
limit: Infinity,
|
|
853
|
+
ellipsis: ""
|
|
854
|
+
}, jt = (t, r = {}, s = {}) => {
|
|
855
|
+
const i = r.limit ?? Infinity, a = r.ellipsis ?? "", o = r?.ellipsisWidth ?? (a ? jt(a, ye, s).width : 0), u = s.ansiWidth ?? 0, l = s.controlWidth ?? 0, n = s.tabWidth ?? 8, c = s.ambiguousWidth ?? 1, g = s.emojiWidth ?? 2, F = s.fullWidthWidth ?? 2, p = s.regularWidth ?? 1, E = s.wideWidth ?? 2;
|
|
856
|
+
let $ = 0, m = 0, h = t.length, y = 0, f = !1, v = h, S = Math.max(0, i - o), I = 0, B = 0, A = 0, w = 0;
|
|
857
|
+
t: for (;;) {
|
|
858
|
+
if (B > I || m >= h && m > $) {
|
|
859
|
+
const _ = t.slice(I, B) || t.slice($, m);
|
|
860
|
+
y = 0;
|
|
861
|
+
for (const D of _.replaceAll(Fe, "")) {
|
|
862
|
+
const T = D.codePointAt(0) || 0;
|
|
863
|
+
if (ge(T) ? w = F : fe(T) ? w = E : c !== p && pe(T) ? w = c : w = p, A + w > S && (v = Math.min(v, Math.max(I, $) + y)), A + w > i) {
|
|
864
|
+
f = !0;
|
|
865
|
+
break t;
|
|
866
|
+
}
|
|
867
|
+
y += D.length, A += w;
|
|
868
|
+
}
|
|
869
|
+
I = B = 0;
|
|
870
|
+
}
|
|
871
|
+
if (m >= h) break;
|
|
872
|
+
if (at.lastIndex = m, at.test(t)) {
|
|
873
|
+
if (y = at.lastIndex - m, w = y * p, A + w > S && (v = Math.min(v, m + Math.floor((S - A) / p))), A + w > i) {
|
|
874
|
+
f = !0;
|
|
875
|
+
break;
|
|
876
|
+
}
|
|
877
|
+
A += w, I = $, B = m, m = $ = at.lastIndex;
|
|
878
|
+
continue;
|
|
879
|
+
}
|
|
880
|
+
if (At.lastIndex = m, At.test(t)) {
|
|
881
|
+
if (A + u > S && (v = Math.min(v, m)), A + u > i) {
|
|
882
|
+
f = !0;
|
|
883
|
+
break;
|
|
884
|
+
}
|
|
885
|
+
A += u, I = $, B = m, m = $ = At.lastIndex;
|
|
886
|
+
continue;
|
|
887
|
+
}
|
|
888
|
+
if (it.lastIndex = m, it.test(t)) {
|
|
889
|
+
if (y = it.lastIndex - m, w = y * l, A + w > S && (v = Math.min(v, m + Math.floor((S - A) / l))), A + w > i) {
|
|
890
|
+
f = !0;
|
|
891
|
+
break;
|
|
892
|
+
}
|
|
893
|
+
A += w, I = $, B = m, m = $ = it.lastIndex;
|
|
894
|
+
continue;
|
|
895
|
+
}
|
|
896
|
+
if (nt.lastIndex = m, nt.test(t)) {
|
|
897
|
+
if (y = nt.lastIndex - m, w = y * n, A + w > S && (v = Math.min(v, m + Math.floor((S - A) / n))), A + w > i) {
|
|
898
|
+
f = !0;
|
|
899
|
+
break;
|
|
900
|
+
}
|
|
901
|
+
A += w, I = $, B = m, m = $ = nt.lastIndex;
|
|
902
|
+
continue;
|
|
903
|
+
}
|
|
904
|
+
if (wt.lastIndex = m, wt.test(t)) {
|
|
905
|
+
if (A + g > S && (v = Math.min(v, m)), A + g > i) {
|
|
906
|
+
f = !0;
|
|
907
|
+
break;
|
|
908
|
+
}
|
|
909
|
+
A += g, I = $, B = m, m = $ = wt.lastIndex;
|
|
910
|
+
continue;
|
|
911
|
+
}
|
|
912
|
+
m += 1;
|
|
913
|
+
}
|
|
914
|
+
return {
|
|
915
|
+
width: f ? S : A,
|
|
916
|
+
index: f ? v : h,
|
|
917
|
+
truncated: f,
|
|
918
|
+
ellipsed: f && i >= o
|
|
919
|
+
};
|
|
920
|
+
}, Ee = {
|
|
921
|
+
limit: Infinity,
|
|
922
|
+
ellipsis: "",
|
|
923
|
+
ellipsisWidth: 0
|
|
924
|
+
}, M$1 = (t, r = {}) => jt(t, Ee, r).width, ot = "\x1B", Gt = "", ve = 39, Ct = "\x07", kt = "[", Ae = "]", Vt = "m", St = `${Ae}8;;`, Ht = new RegExp(`(?:\\${kt}(?<code>\\d+)m|\\${St}(?<uri>.*)${Ct})`, "y"), we = (t) => {
|
|
925
|
+
if (t >= 30 && t <= 37 || t >= 90 && t <= 97) return 39;
|
|
926
|
+
if (t >= 40 && t <= 47 || t >= 100 && t <= 107) return 49;
|
|
927
|
+
if (t === 1 || t === 2) return 22;
|
|
928
|
+
if (t === 3) return 23;
|
|
929
|
+
if (t === 4) return 24;
|
|
930
|
+
if (t === 7) return 27;
|
|
931
|
+
if (t === 8) return 28;
|
|
932
|
+
if (t === 9) return 29;
|
|
933
|
+
if (t === 0) return 0;
|
|
934
|
+
}, Ut = (t) => `${ot}${kt}${t}${Vt}`, Kt = (t) => `${ot}${St}${t}${Ct}`, Ce = (t) => t.map((r) => M$1(r)), It = (t, r, s) => {
|
|
935
|
+
const i = r[Symbol.iterator]();
|
|
936
|
+
let a = !1, o = !1, u = t.at(-1), l = u === void 0 ? 0 : M$1(u), n = i.next(), c = i.next(), g = 0;
|
|
937
|
+
for (; !n.done;) {
|
|
938
|
+
const F = n.value, p = M$1(F);
|
|
939
|
+
l + p <= s ? t[t.length - 1] += F : (t.push(F), l = 0), (F === ot || F === Gt) && (a = !0, o = r.startsWith(St, g + 1)), a ? o ? F === Ct && (a = !1, o = !1) : F === Vt && (a = !1) : (l += p, l === s && !c.done && (t.push(""), l = 0)), n = c, c = i.next(), g += F.length;
|
|
940
|
+
}
|
|
941
|
+
u = t.at(-1), !l && u !== void 0 && u.length > 0 && t.length > 1 && (t[t.length - 2] += t.pop());
|
|
942
|
+
}, Se = (t) => {
|
|
943
|
+
const r = t.split(" ");
|
|
944
|
+
let s = r.length;
|
|
945
|
+
for (; s > 0 && !(M$1(r[s - 1]) > 0);) s--;
|
|
946
|
+
return s === r.length ? t : r.slice(0, s).join(" ") + r.slice(s).join("");
|
|
947
|
+
}, Ie = (t, r, s = {}) => {
|
|
948
|
+
if (s.trim !== !1 && t.trim() === "") return "";
|
|
949
|
+
let i = "", a, o;
|
|
950
|
+
const u = t.split(" "), l = Ce(u);
|
|
951
|
+
let n = [""];
|
|
952
|
+
for (const [$, m] of u.entries()) {
|
|
953
|
+
s.trim !== !1 && (n[n.length - 1] = (n.at(-1) ?? "").trimStart());
|
|
954
|
+
let h = M$1(n.at(-1) ?? "");
|
|
955
|
+
if ($ !== 0 && (h >= r && (s.wordWrap === !1 || s.trim === !1) && (n.push(""), h = 0), (h > 0 || s.trim === !1) && (n[n.length - 1] += " ", h++)), s.hard && l[$] > r) {
|
|
956
|
+
const y = r - h, f = 1 + Math.floor((l[$] - y - 1) / r);
|
|
957
|
+
Math.floor((l[$] - 1) / r) < f && n.push(""), It(n, m, r);
|
|
958
|
+
continue;
|
|
959
|
+
}
|
|
960
|
+
if (h + l[$] > r && h > 0 && l[$] > 0) {
|
|
961
|
+
if (s.wordWrap === !1 && h < r) {
|
|
962
|
+
It(n, m, r);
|
|
963
|
+
continue;
|
|
964
|
+
}
|
|
965
|
+
n.push("");
|
|
966
|
+
}
|
|
967
|
+
if (h + l[$] > r && s.wordWrap === !1) {
|
|
968
|
+
It(n, m, r);
|
|
969
|
+
continue;
|
|
970
|
+
}
|
|
971
|
+
n[n.length - 1] += m;
|
|
972
|
+
}
|
|
973
|
+
s.trim !== !1 && (n = n.map(($) => Se($)));
|
|
974
|
+
const c = n.join(`
|
|
975
|
+
`), g = c[Symbol.iterator]();
|
|
976
|
+
let F = g.next(), p = g.next(), E = 0;
|
|
977
|
+
for (; !F.done;) {
|
|
978
|
+
const $ = F.value, m = p.value;
|
|
979
|
+
if (i += $, $ === ot || $ === Gt) {
|
|
980
|
+
Ht.lastIndex = E + 1;
|
|
981
|
+
const f = Ht.exec(c)?.groups;
|
|
982
|
+
if (f?.code !== void 0) {
|
|
983
|
+
const v = Number.parseFloat(f.code);
|
|
984
|
+
a = v === ve ? void 0 : v;
|
|
985
|
+
} else f?.uri !== void 0 && (o = f.uri.length === 0 ? void 0 : f.uri);
|
|
986
|
+
}
|
|
987
|
+
const h = a ? we(a) : void 0;
|
|
988
|
+
m === `
|
|
989
|
+
` ? (o && (i += Kt("")), a && h && (i += Ut(h))) : $ === `
|
|
990
|
+
` && (a && h && (i += Ut(a)), o && (i += Kt(o))), E += $.length, F = p, p = g.next();
|
|
991
|
+
}
|
|
992
|
+
return i;
|
|
993
|
+
};
|
|
994
|
+
function J(t, r, s) {
|
|
995
|
+
return String(t).normalize().replaceAll(`\r
|
|
996
|
+
`, `
|
|
23
997
|
`).split(`
|
|
24
|
-
`).map(
|
|
25
|
-
`)
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
$
|
|
42
|
-
$
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
$
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
998
|
+
`).map((i) => Ie(i, r, s)).join(`
|
|
999
|
+
`);
|
|
1000
|
+
}
|
|
1001
|
+
const be = (t, r, s, i, a) => {
|
|
1002
|
+
let o = r, u = 0;
|
|
1003
|
+
for (let l = s; l < i; l++) {
|
|
1004
|
+
const n = t[l];
|
|
1005
|
+
if (o = o - n.length, u++, o <= a) break;
|
|
1006
|
+
}
|
|
1007
|
+
return {
|
|
1008
|
+
lineCount: o,
|
|
1009
|
+
removals: u
|
|
1010
|
+
};
|
|
1011
|
+
}, X = (t) => {
|
|
1012
|
+
const { cursor: r, options: s, style: i } = t, a = t.output ?? process.stdout, o = rt$1(a), u = t.columnPadding ?? 0, l = t.rowPadding ?? 4, n = o - u, c = nt$1(a), g = import_picocolors.default.dim("..."), F = t.maxItems ?? Number.POSITIVE_INFINITY, p = Math.max(c - l, 0), E = Math.max(Math.min(F, p), 5);
|
|
1013
|
+
let $ = 0;
|
|
1014
|
+
r >= E - 3 && ($ = Math.max(Math.min(r - E + 3, s.length - E), 0));
|
|
1015
|
+
let m = E < s.length && $ > 0, h = E < s.length && $ + E < s.length;
|
|
1016
|
+
const y = Math.min($ + E, s.length), f = [];
|
|
1017
|
+
let v = 0;
|
|
1018
|
+
m && v++, h && v++;
|
|
1019
|
+
const S = $ + (m ? 1 : 0), I = y - (h ? 1 : 0);
|
|
1020
|
+
for (let A = S; A < I; A++) {
|
|
1021
|
+
const w = J(i(s[A], A === r), n, {
|
|
1022
|
+
hard: !0,
|
|
1023
|
+
trim: !1
|
|
1024
|
+
}).split(`
|
|
1025
|
+
`);
|
|
1026
|
+
f.push(w), v += w.length;
|
|
1027
|
+
}
|
|
1028
|
+
if (v > p) {
|
|
1029
|
+
let A = 0, w = 0, _ = v;
|
|
1030
|
+
const D = r - S, T = (Y, L) => be(f, _, Y, L, p);
|
|
1031
|
+
m ? ({lineCount: _, removals: A} = T(0, D), _ > p && ({lineCount: _, removals: w} = T(D + 1, f.length))) : ({lineCount: _, removals: w} = T(D + 1, f.length), _ > p && ({lineCount: _, removals: A} = T(0, D))), A > 0 && (m = !0, f.splice(0, A)), w > 0 && (h = !0, f.splice(f.length - w, w));
|
|
1032
|
+
}
|
|
1033
|
+
const B = [];
|
|
1034
|
+
m && B.push(g);
|
|
1035
|
+
for (const A of f) for (const w of A) B.push(w);
|
|
1036
|
+
return h && B.push(g), B;
|
|
1037
|
+
};
|
|
1038
|
+
function qt(t) {
|
|
1039
|
+
return t.label ?? String(t.value ?? "");
|
|
1040
|
+
}
|
|
1041
|
+
function Jt(t, r) {
|
|
1042
|
+
if (!t) return !0;
|
|
1043
|
+
const s = (r.label ?? String(r.value ?? "")).toLowerCase(), i = (r.hint ?? "").toLowerCase(), a = String(r.value).toLowerCase(), o = t.toLowerCase();
|
|
1044
|
+
return s.includes(o) || i.includes(o) || a.includes(o);
|
|
1045
|
+
}
|
|
1046
|
+
function Be(t, r) {
|
|
1047
|
+
const s = [];
|
|
1048
|
+
for (const i of r) t.includes(i.value) && s.push(i);
|
|
1049
|
+
return s;
|
|
1050
|
+
}
|
|
1051
|
+
const Xt = (t) => new Vt$1({
|
|
1052
|
+
options: t.options,
|
|
1053
|
+
initialValue: t.initialValue ? [t.initialValue] : void 0,
|
|
1054
|
+
initialUserInput: t.initialUserInput,
|
|
1055
|
+
filter: t.filter ?? ((r, s) => Jt(r, s)),
|
|
1056
|
+
signal: t.signal,
|
|
1057
|
+
input: t.input,
|
|
1058
|
+
output: t.output,
|
|
1059
|
+
validate: t.validate,
|
|
1060
|
+
render() {
|
|
1061
|
+
const r = t.withGuide ?? _$1.withGuide, s = r ? [`${import_picocolors.default.gray(d$1)}`, `${W$1(this.state)} ${t.message}`] : [`${W$1(this.state)} ${t.message}`], i = this.userInput, a = this.options, o = t.placeholder, u = i === "" && o !== void 0, l = (n, c) => {
|
|
1062
|
+
const g = qt(n), F = n.hint && n.value === this.focusedValue ? import_picocolors.default.dim(` (${n.hint})`) : "";
|
|
1063
|
+
switch (c) {
|
|
1064
|
+
case "active": return `${import_picocolors.default.green(Q)} ${g}${F}`;
|
|
1065
|
+
case "inactive": return `${import_picocolors.default.dim(H$1)} ${import_picocolors.default.dim(g)}`;
|
|
1066
|
+
case "disabled": return `${import_picocolors.default.gray(H$1)} ${import_picocolors.default.strikethrough(import_picocolors.default.gray(g))}`;
|
|
1067
|
+
}
|
|
1068
|
+
};
|
|
1069
|
+
switch (this.state) {
|
|
1070
|
+
case "submit": {
|
|
1071
|
+
const n = Be(this.selectedValues, a), c = n.length > 0 ? ` ${import_picocolors.default.dim(n.map(qt).join(", "))}` : "", g = r ? import_picocolors.default.gray(d$1) : "";
|
|
1072
|
+
return `${s.join(`
|
|
1073
|
+
`)}
|
|
1074
|
+
${g}${c}`;
|
|
1075
|
+
}
|
|
1076
|
+
case "cancel": {
|
|
1077
|
+
const n = i ? ` ${import_picocolors.default.strikethrough(import_picocolors.default.dim(i))}` : "", c = r ? import_picocolors.default.gray(d$1) : "";
|
|
1078
|
+
return `${s.join(`
|
|
1079
|
+
`)}
|
|
1080
|
+
${c}${n}`;
|
|
1081
|
+
}
|
|
1082
|
+
default: {
|
|
1083
|
+
const n = this.state === "error" ? import_picocolors.default.yellow : import_picocolors.default.cyan, c = r ? `${n(d$1)} ` : "", g = r ? n(x$1) : "";
|
|
1084
|
+
let F = "";
|
|
1085
|
+
if (this.isNavigating || u) {
|
|
1086
|
+
const f = u ? o : i;
|
|
1087
|
+
F = f !== "" ? ` ${import_picocolors.default.dim(f)}` : "";
|
|
1088
|
+
} else F = ` ${this.userInputWithCursor}`;
|
|
1089
|
+
const p = this.filteredOptions.length !== a.length ? import_picocolors.default.dim(` (${this.filteredOptions.length} match${this.filteredOptions.length === 1 ? "" : "es"})`) : "", E = this.filteredOptions.length === 0 && i ? [`${c}${import_picocolors.default.yellow("No matches found")}`] : [], $ = this.state === "error" ? [`${c}${import_picocolors.default.yellow(this.error)}`] : [];
|
|
1090
|
+
r && s.push(`${c.trimEnd()}`), s.push(`${c}${import_picocolors.default.dim("Search:")}${F}${p}`, ...E, ...$);
|
|
1091
|
+
const h = [`${c}${[
|
|
1092
|
+
`${import_picocolors.default.dim("↑/↓")} to select`,
|
|
1093
|
+
`${import_picocolors.default.dim("Enter:")} confirm`,
|
|
1094
|
+
`${import_picocolors.default.dim("Type:")} to search`
|
|
1095
|
+
].join(" • ")}`, g], y = this.filteredOptions.length === 0 ? [] : X({
|
|
1096
|
+
cursor: this.cursor,
|
|
1097
|
+
options: this.filteredOptions,
|
|
1098
|
+
columnPadding: r ? 3 : 0,
|
|
1099
|
+
rowPadding: s.length + h.length,
|
|
1100
|
+
style: (f, v) => l(f, f.disabled ? "disabled" : v ? "active" : "inactive"),
|
|
1101
|
+
maxItems: t.maxItems,
|
|
1102
|
+
output: t.output
|
|
1103
|
+
});
|
|
1104
|
+
return [
|
|
1105
|
+
...s,
|
|
1106
|
+
...y.map((f) => `${c}${f}`),
|
|
1107
|
+
...h
|
|
1108
|
+
].join(`
|
|
1109
|
+
`);
|
|
1110
|
+
}
|
|
1111
|
+
}
|
|
1112
|
+
}
|
|
1113
|
+
}).prompt(), xe = (t) => {
|
|
1114
|
+
const r = (i, a, o, u) => {
|
|
1115
|
+
const l = o.includes(i.value), n = i.label ?? String(i.value ?? ""), c = i.hint && u !== void 0 && i.value === u ? import_picocolors.default.dim(` (${i.hint})`) : "", g = l ? import_picocolors.default.green(U$1) : import_picocolors.default.dim(q$1);
|
|
1116
|
+
return i.disabled ? `${import_picocolors.default.gray(q$1)} ${import_picocolors.default.strikethrough(import_picocolors.default.gray(n))}` : a ? `${g} ${n}${c}` : `${g} ${import_picocolors.default.dim(n)}`;
|
|
1117
|
+
}, s = new Vt$1({
|
|
1118
|
+
options: t.options,
|
|
1119
|
+
multiple: !0,
|
|
1120
|
+
filter: t.filter ?? ((i, a) => Jt(i, a)),
|
|
1121
|
+
validate: () => {
|
|
1122
|
+
if (t.required && s.selectedValues.length === 0) return "Please select at least one item";
|
|
1123
|
+
},
|
|
1124
|
+
initialValue: t.initialValues,
|
|
1125
|
+
signal: t.signal,
|
|
1126
|
+
input: t.input,
|
|
1127
|
+
output: t.output,
|
|
1128
|
+
render() {
|
|
1129
|
+
const i = `${import_picocolors.default.gray(d$1)}
|
|
1130
|
+
${W$1(this.state)} ${t.message}
|
|
1131
|
+
`, a = this.userInput, o = t.placeholder, u = a === "" && o !== void 0, l = this.isNavigating || u ? import_picocolors.default.dim(u ? o : a) : this.userInputWithCursor, n = this.options, c = this.filteredOptions.length !== n.length ? import_picocolors.default.dim(` (${this.filteredOptions.length} match${this.filteredOptions.length === 1 ? "" : "es"})`) : "";
|
|
1132
|
+
switch (this.state) {
|
|
1133
|
+
case "submit": return `${i}${import_picocolors.default.gray(d$1)} ${import_picocolors.default.dim(`${this.selectedValues.length} items selected`)}`;
|
|
1134
|
+
case "cancel": return `${i}${import_picocolors.default.gray(d$1)} ${import_picocolors.default.strikethrough(import_picocolors.default.dim(a))}`;
|
|
1135
|
+
default: {
|
|
1136
|
+
const g = this.state === "error" ? import_picocolors.default.yellow : import_picocolors.default.cyan, F = [
|
|
1137
|
+
`${import_picocolors.default.dim("↑/↓")} to navigate`,
|
|
1138
|
+
`${import_picocolors.default.dim(this.isNavigating ? "Space/Tab:" : "Tab:")} select`,
|
|
1139
|
+
`${import_picocolors.default.dim("Enter:")} confirm`,
|
|
1140
|
+
`${import_picocolors.default.dim("Type:")} to search`
|
|
1141
|
+
], p = this.filteredOptions.length === 0 && a ? [`${g(d$1)} ${import_picocolors.default.yellow("No matches found")}`] : [], E = this.state === "error" ? [`${g(d$1)} ${import_picocolors.default.yellow(this.error)}`] : [], $ = [
|
|
1142
|
+
...`${i}${g(d$1)}`.split(`
|
|
1143
|
+
`),
|
|
1144
|
+
`${g(d$1)} ${import_picocolors.default.dim("Search:")} ${l}${c}`,
|
|
1145
|
+
...p,
|
|
1146
|
+
...E
|
|
1147
|
+
], m = [`${g(d$1)} ${F.join(" • ")}`, `${g(x$1)}`], h = X({
|
|
1148
|
+
cursor: this.cursor,
|
|
1149
|
+
options: this.filteredOptions,
|
|
1150
|
+
style: (y, f) => r(y, f, this.selectedValues, this.focusedValue),
|
|
1151
|
+
maxItems: t.maxItems,
|
|
1152
|
+
output: t.output,
|
|
1153
|
+
rowPadding: $.length + m.length
|
|
1154
|
+
});
|
|
1155
|
+
return [
|
|
1156
|
+
...$,
|
|
1157
|
+
...h.map((y) => `${g(d$1)} ${y}`),
|
|
1158
|
+
...m
|
|
1159
|
+
].join(`
|
|
1160
|
+
`);
|
|
1161
|
+
}
|
|
1162
|
+
}
|
|
1163
|
+
}
|
|
1164
|
+
});
|
|
1165
|
+
return s.prompt();
|
|
1166
|
+
}, _e = [
|
|
1167
|
+
Lt,
|
|
1168
|
+
mt,
|
|
1169
|
+
gt,
|
|
1170
|
+
pt
|
|
1171
|
+
], De = [
|
|
1172
|
+
ht,
|
|
1173
|
+
Ot,
|
|
1174
|
+
x$1,
|
|
1175
|
+
Pt
|
|
1176
|
+
];
|
|
1177
|
+
function Yt(t, r, s, i) {
|
|
1178
|
+
let a = s, o = s;
|
|
1179
|
+
return i === "center" ? a = Math.floor((r - t) / 2) : i === "right" && (a = r - t - s), o = r - a - t, [a, o];
|
|
1180
|
+
}
|
|
1181
|
+
const Te = (t) => t, Me = (t = "", r = "", s) => {
|
|
1182
|
+
const i = s?.output ?? process.stdout, a = rt$1(i), o = 2, u = s?.titlePadding ?? 1, l = s?.contentPadding ?? 2, n = s?.width === void 0 || s.width === "auto" ? 1 : Math.min(1, s.width), c = s?.withGuide ?? _$1.withGuide ? `${d$1} ` : "", g = s?.formatBorder ?? Te, F = (s?.rounded ? _e : De).map(g), p = g(rt), E = g(d$1), $ = M$1(c), m = M$1(r), h = a - $;
|
|
1183
|
+
let y = Math.floor(a * n) - $;
|
|
1184
|
+
if (s?.width === "auto") {
|
|
1185
|
+
const _ = t.split(`
|
|
1186
|
+
`);
|
|
1187
|
+
let D = m + u * 2;
|
|
1188
|
+
for (const Y of _) {
|
|
1189
|
+
const L = M$1(Y) + l * 2;
|
|
1190
|
+
L > D && (D = L);
|
|
1191
|
+
}
|
|
1192
|
+
const T = D + o;
|
|
1193
|
+
T < y && (y = T);
|
|
1194
|
+
}
|
|
1195
|
+
y % 2 !== 0 && (y < h ? y++ : y--);
|
|
1196
|
+
const f = y - o, v = f - u * 2, S = m > v ? `${r.slice(0, v - 3)}...` : r, [I, B] = Yt(M$1(S), f, u, s?.titleAlign), A = J(t, f - l * 2, {
|
|
1197
|
+
hard: !0,
|
|
1198
|
+
trim: !1
|
|
1199
|
+
});
|
|
1200
|
+
i.write(`${c}${F[0]}${p.repeat(I)}${S}${p.repeat(B)}${F[1]}
|
|
1201
|
+
`);
|
|
1202
|
+
const w = A.split(`
|
|
1203
|
+
`);
|
|
1204
|
+
for (const _ of w) {
|
|
1205
|
+
const [D, T] = Yt(M$1(_), f, l, s?.contentAlign);
|
|
1206
|
+
i.write(`${c}${E}${" ".repeat(D)}${_}${" ".repeat(T)}${E}
|
|
1207
|
+
`);
|
|
1208
|
+
}
|
|
1209
|
+
i.write(`${c}${F[2]}${p.repeat(f)}${F[3]}
|
|
1210
|
+
`);
|
|
1211
|
+
}, Re = (t) => {
|
|
1212
|
+
const r = t.active ?? "Yes", s = t.inactive ?? "No";
|
|
1213
|
+
return new kt$1({
|
|
1214
|
+
active: r,
|
|
1215
|
+
inactive: s,
|
|
1216
|
+
signal: t.signal,
|
|
1217
|
+
input: t.input,
|
|
1218
|
+
output: t.output,
|
|
1219
|
+
initialValue: t.initialValue ?? !0,
|
|
1220
|
+
render() {
|
|
1221
|
+
const i = t.withGuide ?? _$1.withGuide, a = `${i ? `${import_picocolors.default.gray(d$1)}
|
|
1222
|
+
` : ""}${W$1(this.state)} ${t.message}
|
|
1223
|
+
`, o = this.value ? r : s;
|
|
1224
|
+
switch (this.state) {
|
|
1225
|
+
case "submit": return `${a}${i ? `${import_picocolors.default.gray(d$1)} ` : ""}${import_picocolors.default.dim(o)}`;
|
|
1226
|
+
case "cancel": return `${a}${i ? `${import_picocolors.default.gray(d$1)} ` : ""}${import_picocolors.default.strikethrough(import_picocolors.default.dim(o))}${i ? `
|
|
1227
|
+
${import_picocolors.default.gray(d$1)}` : ""}`;
|
|
1228
|
+
default: {
|
|
1229
|
+
const u = i ? `${import_picocolors.default.cyan(d$1)} ` : "", l = i ? import_picocolors.default.cyan(x$1) : "";
|
|
1230
|
+
return `${a}${u}${this.value ? `${import_picocolors.default.green(Q)} ${r}` : `${import_picocolors.default.dim(H$1)} ${import_picocolors.default.dim(r)}`}${t.vertical ? i ? `
|
|
1231
|
+
${import_picocolors.default.cyan(d$1)} ` : `
|
|
1232
|
+
` : ` ${import_picocolors.default.dim("/")} `}${this.value ? `${import_picocolors.default.dim(H$1)} ${import_picocolors.default.dim(s)}` : `${import_picocolors.default.green(Q)} ${s}`}
|
|
1233
|
+
${l}
|
|
1234
|
+
`;
|
|
1235
|
+
}
|
|
1236
|
+
}
|
|
1237
|
+
}
|
|
1238
|
+
}).prompt();
|
|
1239
|
+
}, Oe = async (t, r) => {
|
|
1240
|
+
const s = {}, i = Object.keys(t);
|
|
1241
|
+
for (const a of i) {
|
|
1242
|
+
const o = t[a], u = await o({ results: s })?.catch((l) => {
|
|
1243
|
+
throw l;
|
|
1244
|
+
});
|
|
1245
|
+
if (typeof r?.onCancel == "function" && Ct$1(u)) {
|
|
1246
|
+
s[a] = "canceled", r.onCancel({ results: s });
|
|
1247
|
+
continue;
|
|
1248
|
+
}
|
|
1249
|
+
s[a] = u;
|
|
1250
|
+
}
|
|
1251
|
+
return s;
|
|
1252
|
+
}, Pe = (t) => {
|
|
1253
|
+
const { selectableGroups: r = !0, groupSpacing: s = 0 } = t, i = (o, u, l = []) => {
|
|
1254
|
+
const n = o.label ?? String(o.value), c = typeof o.group == "string", g = c && (l[l.indexOf(o) + 1] ?? { group: !0 }), F = c && g && g.group === !0, p = c ? r ? `${F ? x$1 : d$1} ` : " " : "";
|
|
1255
|
+
let E = "";
|
|
1256
|
+
if (s > 0 && !c) {
|
|
1257
|
+
const m = `
|
|
1258
|
+
${import_picocolors.default.cyan(d$1)}`;
|
|
1259
|
+
E = `${m.repeat(s - 1)}${m} `;
|
|
1260
|
+
}
|
|
1261
|
+
if (u === "active") return `${E}${import_picocolors.default.dim(p)}${import_picocolors.default.cyan(st)} ${n}${o.hint ? ` ${import_picocolors.default.dim(`(${o.hint})`)}` : ""}`;
|
|
1262
|
+
if (u === "group-active") return `${E}${p}${import_picocolors.default.cyan(st)} ${import_picocolors.default.dim(n)}`;
|
|
1263
|
+
if (u === "group-active-selected") return `${E}${p}${import_picocolors.default.green(U$1)} ${import_picocolors.default.dim(n)}`;
|
|
1264
|
+
if (u === "selected") {
|
|
1265
|
+
const m = c || r ? import_picocolors.default.green(U$1) : "";
|
|
1266
|
+
return `${E}${import_picocolors.default.dim(p)}${m} ${import_picocolors.default.dim(n)}${o.hint ? ` ${import_picocolors.default.dim(`(${o.hint})`)}` : ""}`;
|
|
1267
|
+
}
|
|
1268
|
+
if (u === "cancelled") return `${import_picocolors.default.strikethrough(import_picocolors.default.dim(n))}`;
|
|
1269
|
+
if (u === "active-selected") return `${E}${import_picocolors.default.dim(p)}${import_picocolors.default.green(U$1)} ${n}${o.hint ? ` ${import_picocolors.default.dim(`(${o.hint})`)}` : ""}`;
|
|
1270
|
+
if (u === "submitted") return `${import_picocolors.default.dim(n)}`;
|
|
1271
|
+
const $ = c || r ? import_picocolors.default.dim(q$1) : "";
|
|
1272
|
+
return `${E}${import_picocolors.default.dim(p)}${$} ${import_picocolors.default.dim(n)}`;
|
|
1273
|
+
}, a = t.required ?? !0;
|
|
1274
|
+
return new yt$1({
|
|
1275
|
+
options: t.options,
|
|
1276
|
+
signal: t.signal,
|
|
1277
|
+
input: t.input,
|
|
1278
|
+
output: t.output,
|
|
1279
|
+
initialValues: t.initialValues,
|
|
1280
|
+
required: a,
|
|
1281
|
+
cursorAt: t.cursorAt,
|
|
1282
|
+
selectableGroups: r,
|
|
1283
|
+
validate(o) {
|
|
1284
|
+
if (a && (o === void 0 || o.length === 0)) return `Please select at least one option.
|
|
1285
|
+
${import_picocolors.default.reset(import_picocolors.default.dim(`Press ${import_picocolors.default.gray(import_picocolors.default.bgWhite(import_picocolors.default.inverse(" space ")))} to select, ${import_picocolors.default.gray(import_picocolors.default.bgWhite(import_picocolors.default.inverse(" enter ")))} to submit`))}`;
|
|
1286
|
+
},
|
|
1287
|
+
render() {
|
|
1288
|
+
const o = `${import_picocolors.default.gray(d$1)}
|
|
1289
|
+
${W$1(this.state)} ${t.message}
|
|
1290
|
+
`, u = this.value ?? [];
|
|
1291
|
+
switch (this.state) {
|
|
1292
|
+
case "submit": {
|
|
1293
|
+
const l = this.options.filter(({ value: c }) => u.includes(c)).map((c) => i(c, "submitted")), n = l.length === 0 ? "" : ` ${l.join(import_picocolors.default.dim(", "))}`;
|
|
1294
|
+
return `${o}${import_picocolors.default.gray(d$1)}${n}`;
|
|
1295
|
+
}
|
|
1296
|
+
case "cancel": {
|
|
1297
|
+
const l = this.options.filter(({ value: n }) => u.includes(n)).map((n) => i(n, "cancelled")).join(import_picocolors.default.dim(", "));
|
|
1298
|
+
return `${o}${import_picocolors.default.gray(d$1)} ${l.trim() ? `${l}
|
|
1299
|
+
${import_picocolors.default.gray(d$1)}` : ""}`;
|
|
1300
|
+
}
|
|
1301
|
+
case "error": {
|
|
1302
|
+
const l = this.error.split(`
|
|
1303
|
+
`).map((n, c) => c === 0 ? `${import_picocolors.default.yellow(x$1)} ${import_picocolors.default.yellow(n)}` : ` ${n}`).join(`
|
|
1304
|
+
`);
|
|
1305
|
+
return `${o}${import_picocolors.default.yellow(d$1)} ${this.options.map((n, c, g) => {
|
|
1306
|
+
const F = u.includes(n.value) || n.group === !0 && this.isGroupSelected(`${n.value}`), p = c === this.cursor;
|
|
1307
|
+
return !p && typeof n.group == "string" && this.options[this.cursor].value === n.group ? i(n, F ? "group-active-selected" : "group-active", g) : p && F ? i(n, "active-selected", g) : F ? i(n, "selected", g) : i(n, p ? "active" : "inactive", g);
|
|
1308
|
+
}).join(`
|
|
1309
|
+
${import_picocolors.default.yellow(d$1)} `)}
|
|
1310
|
+
${l}
|
|
1311
|
+
`;
|
|
1312
|
+
}
|
|
1313
|
+
default: {
|
|
1314
|
+
const l = this.options.map((c, g, F) => {
|
|
1315
|
+
const p = u.includes(c.value) || c.group === !0 && this.isGroupSelected(`${c.value}`), E = g === this.cursor, $ = !E && typeof c.group == "string" && this.options[this.cursor].value === c.group;
|
|
1316
|
+
let m = "";
|
|
1317
|
+
return $ ? m = i(c, p ? "group-active-selected" : "group-active", F) : E && p ? m = i(c, "active-selected", F) : p ? m = i(c, "selected", F) : m = i(c, E ? "active" : "inactive", F), `${g !== 0 && !m.startsWith(`
|
|
1318
|
+
`) ? " " : ""}${m}`;
|
|
1319
|
+
}).join(`
|
|
1320
|
+
${import_picocolors.default.cyan(d$1)}`), n = l.startsWith(`
|
|
1321
|
+
`) ? "" : " ";
|
|
1322
|
+
return `${o}${import_picocolors.default.cyan(d$1)}${n}${l}
|
|
1323
|
+
${import_picocolors.default.cyan(x$1)}
|
|
1324
|
+
`;
|
|
1325
|
+
}
|
|
1326
|
+
}
|
|
1327
|
+
}
|
|
1328
|
+
}).prompt();
|
|
1329
|
+
}, R$1 = {
|
|
1330
|
+
message: (t = [], { symbol: r = import_picocolors.default.gray(d$1), secondarySymbol: s = import_picocolors.default.gray(d$1), output: i = process.stdout, spacing: a = 1, withGuide: o } = {}) => {
|
|
1331
|
+
const u = [], l = o ?? _$1.withGuide, n = l ? s : "", c = l ? `${r} ` : "", g = l ? `${s} ` : "";
|
|
1332
|
+
for (let p = 0; p < a; p++) u.push(n);
|
|
1333
|
+
const F = Array.isArray(t) ? t : t.split(`
|
|
1334
|
+
`);
|
|
1335
|
+
if (F.length > 0) {
|
|
1336
|
+
const [p, ...E] = F;
|
|
1337
|
+
p.length > 0 ? u.push(`${c}${p}`) : u.push(l ? r : "");
|
|
1338
|
+
for (const $ of E) $.length > 0 ? u.push(`${g}${$}`) : u.push(l ? s : "");
|
|
1339
|
+
}
|
|
1340
|
+
i.write(`${u.join(`
|
|
50
1341
|
`)}
|
|
51
|
-
`)
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
1342
|
+
`);
|
|
1343
|
+
},
|
|
1344
|
+
info: (t, r) => {
|
|
1345
|
+
R$1.message(t, {
|
|
1346
|
+
...r,
|
|
1347
|
+
symbol: import_picocolors.default.blue(ft)
|
|
1348
|
+
});
|
|
1349
|
+
},
|
|
1350
|
+
success: (t, r) => {
|
|
1351
|
+
R$1.message(t, {
|
|
1352
|
+
...r,
|
|
1353
|
+
symbol: import_picocolors.default.green(Ft)
|
|
1354
|
+
});
|
|
1355
|
+
},
|
|
1356
|
+
step: (t, r) => {
|
|
1357
|
+
R$1.message(t, {
|
|
1358
|
+
...r,
|
|
1359
|
+
symbol: import_picocolors.default.green(V$1)
|
|
1360
|
+
});
|
|
1361
|
+
},
|
|
1362
|
+
warn: (t, r) => {
|
|
1363
|
+
R$1.message(t, {
|
|
1364
|
+
...r,
|
|
1365
|
+
symbol: import_picocolors.default.yellow(yt)
|
|
1366
|
+
});
|
|
1367
|
+
},
|
|
1368
|
+
warning: (t, r) => {
|
|
1369
|
+
R$1.warn(t, r);
|
|
1370
|
+
},
|
|
1371
|
+
error: (t, r) => {
|
|
1372
|
+
R$1.message(t, {
|
|
1373
|
+
...r,
|
|
1374
|
+
symbol: import_picocolors.default.red(Et)
|
|
1375
|
+
});
|
|
1376
|
+
}
|
|
1377
|
+
}, Ne = (t = "", r) => {
|
|
1378
|
+
(r?.output ?? process.stdout).write(`${import_picocolors.default.gray(x$1)} ${import_picocolors.default.red(t)}
|
|
1379
|
+
|
|
1380
|
+
`);
|
|
1381
|
+
}, We = (t = "", r) => {
|
|
1382
|
+
(r?.output ?? process.stdout).write(`${import_picocolors.default.gray(ht)} ${t}
|
|
1383
|
+
`);
|
|
1384
|
+
}, Le = (t = "", r) => {
|
|
1385
|
+
(r?.output ?? process.stdout).write(`${import_picocolors.default.gray(d$1)}
|
|
1386
|
+
${import_picocolors.default.gray(x$1)} ${t}
|
|
1387
|
+
|
|
1388
|
+
`);
|
|
1389
|
+
}, Z = (t, r) => t.split(`
|
|
1390
|
+
`).map((s) => r(s)).join(`
|
|
1391
|
+
`), je = (t) => {
|
|
1392
|
+
const r = (i, a) => {
|
|
1393
|
+
const o = i.label ?? String(i.value);
|
|
1394
|
+
return a === "disabled" ? `${import_picocolors.default.gray(q$1)} ${Z(o, (u) => import_picocolors.default.strikethrough(import_picocolors.default.gray(u)))}${i.hint ? ` ${import_picocolors.default.dim(`(${i.hint ?? "disabled"})`)}` : ""}` : a === "active" ? `${import_picocolors.default.cyan(st)} ${o}${i.hint ? ` ${import_picocolors.default.dim(`(${i.hint})`)}` : ""}` : a === "selected" ? `${import_picocolors.default.green(U$1)} ${Z(o, import_picocolors.default.dim)}${i.hint ? ` ${import_picocolors.default.dim(`(${i.hint})`)}` : ""}` : a === "cancelled" ? `${Z(o, (u) => import_picocolors.default.strikethrough(import_picocolors.default.dim(u)))}` : a === "active-selected" ? `${import_picocolors.default.green(U$1)} ${o}${i.hint ? ` ${import_picocolors.default.dim(`(${i.hint})`)}` : ""}` : a === "submitted" ? `${Z(o, import_picocolors.default.dim)}` : `${import_picocolors.default.dim(q$1)} ${Z(o, import_picocolors.default.dim)}`;
|
|
1395
|
+
}, s = t.required ?? !0;
|
|
1396
|
+
return new Lt$1({
|
|
1397
|
+
options: t.options,
|
|
1398
|
+
signal: t.signal,
|
|
1399
|
+
input: t.input,
|
|
1400
|
+
output: t.output,
|
|
1401
|
+
initialValues: t.initialValues,
|
|
1402
|
+
required: s,
|
|
1403
|
+
cursorAt: t.cursorAt,
|
|
1404
|
+
validate(i) {
|
|
1405
|
+
if (s && (i === void 0 || i.length === 0)) return `Please select at least one option.
|
|
1406
|
+
${import_picocolors.default.reset(import_picocolors.default.dim(`Press ${import_picocolors.default.gray(import_picocolors.default.bgWhite(import_picocolors.default.inverse(" space ")))} to select, ${import_picocolors.default.gray(import_picocolors.default.bgWhite(import_picocolors.default.inverse(" enter ")))} to submit`))}`;
|
|
1407
|
+
},
|
|
1408
|
+
render() {
|
|
1409
|
+
const i = xt(t.output, t.message, `${vt(this.state)} `, `${W$1(this.state)} `), a = `${import_picocolors.default.gray(d$1)}
|
|
71
1410
|
${i}
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
${t
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
1411
|
+
`, o = this.value ?? [], u = (l, n) => {
|
|
1412
|
+
if (l.disabled) return r(l, "disabled");
|
|
1413
|
+
const c = o.includes(l.value);
|
|
1414
|
+
return n && c ? r(l, "active-selected") : c ? r(l, "selected") : r(l, n ? "active" : "inactive");
|
|
1415
|
+
};
|
|
1416
|
+
switch (this.state) {
|
|
1417
|
+
case "submit": {
|
|
1418
|
+
const l = this.options.filter(({ value: c }) => o.includes(c)).map((c) => r(c, "submitted")).join(import_picocolors.default.dim(", ")) || import_picocolors.default.dim("none");
|
|
1419
|
+
return `${a}${xt(t.output, l, `${import_picocolors.default.gray(d$1)} `)}`;
|
|
1420
|
+
}
|
|
1421
|
+
case "cancel": {
|
|
1422
|
+
const l = this.options.filter(({ value: c }) => o.includes(c)).map((c) => r(c, "cancelled")).join(import_picocolors.default.dim(", "));
|
|
1423
|
+
if (l.trim() === "") return `${a}${import_picocolors.default.gray(d$1)}`;
|
|
1424
|
+
return `${a}${xt(t.output, l, `${import_picocolors.default.gray(d$1)} `)}
|
|
1425
|
+
${import_picocolors.default.gray(d$1)}`;
|
|
1426
|
+
}
|
|
1427
|
+
case "error": {
|
|
1428
|
+
const l = `${import_picocolors.default.yellow(d$1)} `, n = this.error.split(`
|
|
1429
|
+
`).map((F, p) => p === 0 ? `${import_picocolors.default.yellow(x$1)} ${import_picocolors.default.yellow(F)}` : ` ${F}`).join(`
|
|
1430
|
+
`), c = a.split(`
|
|
1431
|
+
`).length, g = n.split(`
|
|
1432
|
+
`).length + 1;
|
|
1433
|
+
return `${a}${l}${X({
|
|
1434
|
+
output: t.output,
|
|
1435
|
+
options: this.options,
|
|
1436
|
+
cursor: this.cursor,
|
|
1437
|
+
maxItems: t.maxItems,
|
|
1438
|
+
columnPadding: l.length,
|
|
1439
|
+
rowPadding: c + g,
|
|
1440
|
+
style: u
|
|
1441
|
+
}).join(`
|
|
1442
|
+
${l}`)}
|
|
1443
|
+
${n}
|
|
1444
|
+
`;
|
|
1445
|
+
}
|
|
1446
|
+
default: {
|
|
1447
|
+
const l = `${import_picocolors.default.cyan(d$1)} `, n = a.split(`
|
|
1448
|
+
`).length;
|
|
1449
|
+
return `${a}${l}${X({
|
|
1450
|
+
output: t.output,
|
|
1451
|
+
options: this.options,
|
|
1452
|
+
cursor: this.cursor,
|
|
1453
|
+
maxItems: t.maxItems,
|
|
1454
|
+
columnPadding: l.length,
|
|
1455
|
+
rowPadding: n + 2,
|
|
1456
|
+
style: u
|
|
1457
|
+
}).join(`
|
|
1458
|
+
${l}`)}
|
|
1459
|
+
${import_picocolors.default.cyan(x$1)}
|
|
1460
|
+
`;
|
|
1461
|
+
}
|
|
1462
|
+
}
|
|
1463
|
+
}
|
|
1464
|
+
}).prompt();
|
|
1465
|
+
}, Ge = (t) => import_picocolors.default.dim(t), ke = (t, r, s) => {
|
|
1466
|
+
const i = {
|
|
1467
|
+
hard: !0,
|
|
1468
|
+
trim: !1
|
|
1469
|
+
}, a = J(t, r, i).split(`
|
|
1470
|
+
`), o = a.reduce((n, c) => Math.max(M$1(c), n), 0);
|
|
1471
|
+
return J(t, r - (a.map(s).reduce((n, c) => Math.max(M$1(c), n), 0) - o), i);
|
|
1472
|
+
}, Ve = (t = "", r = "", s) => {
|
|
1473
|
+
const i = s?.output ?? N.stdout, a = s?.withGuide ?? _$1.withGuide, o = s?.format ?? Ge, u = [
|
|
1474
|
+
"",
|
|
1475
|
+
...ke(t, rt$1(i) - 6, o).split(`
|
|
1476
|
+
`).map(o),
|
|
1477
|
+
""
|
|
1478
|
+
], l = M$1(r), n = Math.max(u.reduce((p, E) => {
|
|
1479
|
+
const $ = M$1(E);
|
|
1480
|
+
return $ > p ? $ : p;
|
|
1481
|
+
}, 0), l) + 2, c = u.map((p) => `${import_picocolors.default.gray(d$1)} ${p}${" ".repeat(n - M$1(p))}${import_picocolors.default.gray(d$1)}`).join(`
|
|
1482
|
+
`), g = a ? `${import_picocolors.default.gray(d$1)}
|
|
1483
|
+
` : "", F = a ? Wt : gt;
|
|
1484
|
+
i.write(`${g}${import_picocolors.default.green(V$1)} ${import_picocolors.default.reset(r)} ${import_picocolors.default.gray(rt.repeat(Math.max(n - l - 1, 1)) + mt)}
|
|
1485
|
+
${c}
|
|
1486
|
+
${import_picocolors.default.gray(F + rt.repeat(n + 2) + pt)}
|
|
1487
|
+
`);
|
|
1488
|
+
}, He = (t) => new Mt$1({
|
|
1489
|
+
validate: t.validate,
|
|
1490
|
+
mask: t.mask ?? Nt,
|
|
1491
|
+
signal: t.signal,
|
|
1492
|
+
input: t.input,
|
|
1493
|
+
output: t.output,
|
|
1494
|
+
render() {
|
|
1495
|
+
const r = t.withGuide ?? _$1.withGuide, s = `${r ? `${import_picocolors.default.gray(d$1)}
|
|
1496
|
+
` : ""}${W$1(this.state)} ${t.message}
|
|
1497
|
+
`, i = this.userInputWithCursor, a = this.masked;
|
|
1498
|
+
switch (this.state) {
|
|
1499
|
+
case "error": {
|
|
1500
|
+
const o = r ? `${import_picocolors.default.yellow(d$1)} ` : "", u = r ? `${import_picocolors.default.yellow(x$1)} ` : "", l = a ?? "";
|
|
1501
|
+
return t.clearOnError && this.clear(), `${s.trim()}
|
|
1502
|
+
${o}${l}
|
|
1503
|
+
${u}${import_picocolors.default.yellow(this.error)}
|
|
1504
|
+
`;
|
|
1505
|
+
}
|
|
1506
|
+
case "submit": return `${s}${r ? `${import_picocolors.default.gray(d$1)} ` : ""}${a ? import_picocolors.default.dim(a) : ""}`;
|
|
1507
|
+
case "cancel": return `${s}${r ? `${import_picocolors.default.gray(d$1)} ` : ""}${a ? import_picocolors.default.strikethrough(import_picocolors.default.dim(a)) : ""}${a && r ? `
|
|
1508
|
+
${import_picocolors.default.gray(d$1)}` : ""}`;
|
|
1509
|
+
default: return `${s}${r ? `${import_picocolors.default.cyan(d$1)} ` : ""}${i}
|
|
1510
|
+
${r ? import_picocolors.default.cyan(x$1) : ""}
|
|
1511
|
+
`;
|
|
1512
|
+
}
|
|
1513
|
+
}
|
|
1514
|
+
}).prompt(), Ue = (t) => {
|
|
1515
|
+
const r = t.validate;
|
|
1516
|
+
return Xt({
|
|
1517
|
+
...t,
|
|
1518
|
+
initialUserInput: t.initialValue ?? t.root ?? process.cwd(),
|
|
1519
|
+
maxItems: 5,
|
|
1520
|
+
validate(s) {
|
|
1521
|
+
if (!Array.isArray(s)) {
|
|
1522
|
+
if (!s) return "Please select a path";
|
|
1523
|
+
if (r) return r(s);
|
|
1524
|
+
}
|
|
1525
|
+
},
|
|
1526
|
+
options() {
|
|
1527
|
+
const s = this.userInput;
|
|
1528
|
+
if (s === "") return [];
|
|
1529
|
+
try {
|
|
1530
|
+
let i;
|
|
1531
|
+
return existsSync(s) ? lstatSync(s).isDirectory() ? i = s : i = dirname(s) : i = dirname(s), readdirSync(i).map((a) => {
|
|
1532
|
+
const o = join(i, a);
|
|
1533
|
+
return {
|
|
1534
|
+
name: a,
|
|
1535
|
+
path: o,
|
|
1536
|
+
isDirectory: lstatSync(o).isDirectory()
|
|
1537
|
+
};
|
|
1538
|
+
}).filter(({ path: a, isDirectory: o }) => a.startsWith(s) && (t.directory || !o)).map((a) => ({ value: a.path }));
|
|
1539
|
+
} catch {
|
|
1540
|
+
return [];
|
|
1541
|
+
}
|
|
1542
|
+
}
|
|
1543
|
+
});
|
|
1544
|
+
}, Ke = import_picocolors.default.magenta, bt = ({ indicator: t = "dots", onCancel: r, output: s = process.stdout, cancelMessage: i, errorMessage: a, frames: o = et ? [
|
|
1545
|
+
"◒",
|
|
1546
|
+
"◐",
|
|
1547
|
+
"◓",
|
|
1548
|
+
"◑"
|
|
1549
|
+
] : [
|
|
1550
|
+
"•",
|
|
1551
|
+
"o",
|
|
1552
|
+
"O",
|
|
1553
|
+
"0"
|
|
1554
|
+
], delay: u = et ? 80 : 120, signal: l, ...n } = {}) => {
|
|
1555
|
+
const c = ct();
|
|
1556
|
+
let g, F, p = !1, E = !1, $ = "", m, h = performance.now();
|
|
1557
|
+
const y = rt$1(s), f = n?.styleFrame ?? Ke, v = (b) => {
|
|
1558
|
+
const O = b > 1 ? a ?? _$1.messages.error : i ?? _$1.messages.cancel;
|
|
1559
|
+
E = b === 1, p && (L(O, b), E && typeof r == "function" && r());
|
|
1560
|
+
}, S = () => v(2), I = () => v(1), B = () => {
|
|
1561
|
+
process.on("uncaughtExceptionMonitor", S), process.on("unhandledRejection", S), process.on("SIGINT", I), process.on("SIGTERM", I), process.on("exit", v), l && l.addEventListener("abort", I);
|
|
1562
|
+
}, A = () => {
|
|
1563
|
+
process.removeListener("uncaughtExceptionMonitor", S), process.removeListener("unhandledRejection", S), process.removeListener("SIGINT", I), process.removeListener("SIGTERM", I), process.removeListener("exit", v), l && l.removeEventListener("abort", I);
|
|
1564
|
+
}, w = () => {
|
|
1565
|
+
if (m === void 0) return;
|
|
1566
|
+
c && s.write(`
|
|
1567
|
+
`);
|
|
1568
|
+
const b = J(m, y, {
|
|
1569
|
+
hard: !0,
|
|
1570
|
+
trim: !1
|
|
1571
|
+
}).split(`
|
|
1572
|
+
`);
|
|
1573
|
+
b.length > 1 && s.write(import_src.cursor.up(b.length - 1)), s.write(import_src.cursor.to(0)), s.write(import_src.erase.down());
|
|
1574
|
+
}, _ = (b) => b.replace(/\.+$/, ""), D = (b) => {
|
|
1575
|
+
const O = (performance.now() - b) / 1e3, j = Math.floor(O / 60), G = Math.floor(O % 60);
|
|
1576
|
+
return j > 0 ? `[${j}m ${G}s]` : `[${G}s]`;
|
|
1577
|
+
}, T = n.withGuide ?? _$1.withGuide, Y = (b = "") => {
|
|
1578
|
+
p = !0, g = Bt({ output: s }), $ = _(b), h = performance.now(), T && s.write(`${import_picocolors.default.gray(d$1)}
|
|
1579
|
+
`);
|
|
1580
|
+
let O = 0, j = 0;
|
|
1581
|
+
B(), F = setInterval(() => {
|
|
1582
|
+
if (c && $ === m) return;
|
|
1583
|
+
w(), m = $;
|
|
1584
|
+
const G = f(o[O]);
|
|
1585
|
+
let tt;
|
|
1586
|
+
if (c) tt = `${G} ${$}...`;
|
|
1587
|
+
else if (t === "timer") tt = `${G} ${$} ${D(h)}`;
|
|
1588
|
+
else {
|
|
1589
|
+
const te = ".".repeat(Math.floor(j)).slice(0, 3);
|
|
1590
|
+
tt = `${G} ${$}${te}`;
|
|
1591
|
+
}
|
|
1592
|
+
const Zt = J(tt, y, {
|
|
1593
|
+
hard: !0,
|
|
1594
|
+
trim: !1
|
|
1595
|
+
});
|
|
1596
|
+
s.write(Zt), O = O + 1 < o.length ? O + 1 : 0, j = j < 4 ? j + .125 : 0;
|
|
1597
|
+
}, u);
|
|
1598
|
+
}, L = (b = "", O = 0, j = !1) => {
|
|
1599
|
+
if (!p) return;
|
|
1600
|
+
p = !1, clearInterval(F), w();
|
|
1601
|
+
const G = O === 0 ? import_picocolors.default.green(V$1) : O === 1 ? import_picocolors.default.red(dt) : import_picocolors.default.red($t);
|
|
1602
|
+
$ = b ?? $, j || (t === "timer" ? s.write(`${G} ${$} ${D(h)}
|
|
1603
|
+
`) : s.write(`${G} ${$}
|
|
1604
|
+
`)), A(), g();
|
|
1605
|
+
};
|
|
1606
|
+
return {
|
|
1607
|
+
start: Y,
|
|
1608
|
+
stop: (b = "") => L(b, 0),
|
|
1609
|
+
message: (b = "") => {
|
|
1610
|
+
$ = _(b ?? $);
|
|
1611
|
+
},
|
|
1612
|
+
cancel: (b = "") => L(b, 1),
|
|
1613
|
+
error: (b = "") => L(b, 2),
|
|
1614
|
+
clear: () => L("", 0, !0),
|
|
1615
|
+
get isCancelled() {
|
|
1616
|
+
return E;
|
|
1617
|
+
}
|
|
1618
|
+
};
|
|
1619
|
+
}, zt = {
|
|
1620
|
+
light: C$1("─", "-"),
|
|
1621
|
+
heavy: C$1("━", "="),
|
|
1622
|
+
block: C$1("█", "#")
|
|
1623
|
+
};
|
|
1624
|
+
const lt = (t, r) => t.includes(`
|
|
1625
|
+
`) ? t.split(`
|
|
1626
|
+
`).map((s) => r(s)).join(`
|
|
1627
|
+
`) : r(t), Je = (t) => {
|
|
1628
|
+
const r = (s, i) => {
|
|
1629
|
+
const a = s.label ?? String(s.value);
|
|
1630
|
+
switch (i) {
|
|
1631
|
+
case "disabled": return `${import_picocolors.default.gray(H$1)} ${lt(a, import_picocolors.default.gray)}${s.hint ? ` ${import_picocolors.default.dim(`(${s.hint ?? "disabled"})`)}` : ""}`;
|
|
1632
|
+
case "selected": return `${lt(a, import_picocolors.default.dim)}`;
|
|
1633
|
+
case "active": return `${import_picocolors.default.green(Q)} ${a}${s.hint ? ` ${import_picocolors.default.dim(`(${s.hint})`)}` : ""}`;
|
|
1634
|
+
case "cancelled": return `${lt(a, (o) => import_picocolors.default.strikethrough(import_picocolors.default.dim(o)))}`;
|
|
1635
|
+
default: return `${import_picocolors.default.dim(H$1)} ${lt(a, import_picocolors.default.dim)}`;
|
|
1636
|
+
}
|
|
1637
|
+
};
|
|
1638
|
+
return new Wt$1({
|
|
1639
|
+
options: t.options,
|
|
1640
|
+
signal: t.signal,
|
|
1641
|
+
input: t.input,
|
|
1642
|
+
output: t.output,
|
|
1643
|
+
initialValue: t.initialValue,
|
|
1644
|
+
render() {
|
|
1645
|
+
const s = t.withGuide ?? _$1.withGuide, i = `${W$1(this.state)} `, a = `${vt(this.state)} `, o = xt(t.output, t.message, a, i), u = `${s ? `${import_picocolors.default.gray(d$1)}
|
|
1646
|
+
` : ""}${o}
|
|
1647
|
+
`;
|
|
1648
|
+
switch (this.state) {
|
|
1649
|
+
case "submit": {
|
|
1650
|
+
const l = s ? `${import_picocolors.default.gray(d$1)} ` : "";
|
|
1651
|
+
return `${u}${xt(t.output, r(this.options[this.cursor], "selected"), l)}`;
|
|
1652
|
+
}
|
|
1653
|
+
case "cancel": {
|
|
1654
|
+
const l = s ? `${import_picocolors.default.gray(d$1)} ` : "";
|
|
1655
|
+
return `${u}${xt(t.output, r(this.options[this.cursor], "cancelled"), l)}${s ? `
|
|
1656
|
+
${import_picocolors.default.gray(d$1)}` : ""}`;
|
|
1657
|
+
}
|
|
1658
|
+
default: {
|
|
1659
|
+
const l = s ? `${import_picocolors.default.cyan(d$1)} ` : "", n = s ? import_picocolors.default.cyan(x$1) : "", c = u.split(`
|
|
1660
|
+
`).length, g = s ? 2 : 1;
|
|
1661
|
+
return `${u}${l}${X({
|
|
1662
|
+
output: t.output,
|
|
1663
|
+
cursor: this.cursor,
|
|
1664
|
+
options: this.options,
|
|
1665
|
+
maxItems: t.maxItems,
|
|
1666
|
+
columnPadding: l.length,
|
|
1667
|
+
rowPadding: c + g,
|
|
1668
|
+
style: (F, p) => r(F, F.disabled ? "disabled" : p ? "active" : "inactive")
|
|
1669
|
+
}).join(`
|
|
1670
|
+
${l}`)}
|
|
1671
|
+
${n}
|
|
1672
|
+
`;
|
|
1673
|
+
}
|
|
1674
|
+
}
|
|
1675
|
+
}
|
|
1676
|
+
}).prompt();
|
|
1677
|
+
}, Xe = (t) => {
|
|
1678
|
+
const r = (s, i = "inactive") => {
|
|
1679
|
+
const a = s.label ?? String(s.value);
|
|
1680
|
+
return i === "selected" ? `${import_picocolors.default.dim(a)}` : i === "cancelled" ? `${import_picocolors.default.strikethrough(import_picocolors.default.dim(a))}` : i === "active" ? `${import_picocolors.default.bgCyan(import_picocolors.default.gray(` ${s.value} `))} ${a}${s.hint ? ` ${import_picocolors.default.dim(`(${s.hint})`)}` : ""}` : `${import_picocolors.default.gray(import_picocolors.default.bgWhite(import_picocolors.default.inverse(` ${s.value} `)))} ${a}${s.hint ? ` ${import_picocolors.default.dim(`(${s.hint})`)}` : ""}`;
|
|
1681
|
+
};
|
|
1682
|
+
return new Tt$1({
|
|
1683
|
+
options: t.options,
|
|
1684
|
+
signal: t.signal,
|
|
1685
|
+
input: t.input,
|
|
1686
|
+
output: t.output,
|
|
1687
|
+
initialValue: t.initialValue,
|
|
1688
|
+
caseSensitive: t.caseSensitive,
|
|
1689
|
+
render() {
|
|
1690
|
+
const s = t.withGuide ?? _$1.withGuide, i = `${s ? `${import_picocolors.default.gray(d$1)}
|
|
1691
|
+
` : ""}${W$1(this.state)} ${t.message}
|
|
1692
|
+
`;
|
|
1693
|
+
switch (this.state) {
|
|
1694
|
+
case "submit": {
|
|
1695
|
+
const a = s ? `${import_picocolors.default.gray(d$1)} ` : "", o = this.options.find((l) => l.value === this.value) ?? t.options[0];
|
|
1696
|
+
return `${i}${xt(t.output, r(o, "selected"), a)}`;
|
|
1697
|
+
}
|
|
1698
|
+
case "cancel": {
|
|
1699
|
+
const a = s ? `${import_picocolors.default.gray(d$1)} ` : "";
|
|
1700
|
+
return `${i}${xt(t.output, r(this.options[0], "cancelled"), a)}${s ? `
|
|
1701
|
+
${import_picocolors.default.gray(d$1)}` : ""}`;
|
|
1702
|
+
}
|
|
1703
|
+
default: {
|
|
1704
|
+
const a = s ? `${import_picocolors.default.cyan(d$1)} ` : "", o = s ? import_picocolors.default.cyan(x$1) : "";
|
|
1705
|
+
return `${i}${this.options.map((l, n) => xt(t.output, r(l, n === this.cursor ? "active" : "inactive"), a)).join(`
|
|
1706
|
+
`)}
|
|
1707
|
+
${o}
|
|
1708
|
+
`;
|
|
1709
|
+
}
|
|
1710
|
+
}
|
|
1711
|
+
}
|
|
1712
|
+
}).prompt();
|
|
1713
|
+
}, Qt = `${import_picocolors.default.gray(d$1)} `, K$1 = {
|
|
1714
|
+
message: async (t, { symbol: r = import_picocolors.default.gray(d$1) } = {}) => {
|
|
1715
|
+
process.stdout.write(`${import_picocolors.default.gray(d$1)}
|
|
1716
|
+
${r} `);
|
|
1717
|
+
let s = 3;
|
|
1718
|
+
for await (let i of t) {
|
|
1719
|
+
i = i.replace(/\n/g, `
|
|
1720
|
+
${Qt}`), i.includes(`
|
|
1721
|
+
`) && (s = 3 + stripVTControlCharacters(i.slice(i.lastIndexOf(`
|
|
1722
|
+
`))).length);
|
|
1723
|
+
const a = stripVTControlCharacters(i).length;
|
|
1724
|
+
s + a < process.stdout.columns ? (s += a, process.stdout.write(i)) : (process.stdout.write(`
|
|
1725
|
+
${Qt}${i.trimStart()}`), s = 3 + stripVTControlCharacters(i.trimStart()).length);
|
|
1726
|
+
}
|
|
1727
|
+
process.stdout.write(`
|
|
1728
|
+
`);
|
|
1729
|
+
},
|
|
1730
|
+
info: (t) => K$1.message(t, { symbol: import_picocolors.default.blue(ft) }),
|
|
1731
|
+
success: (t) => K$1.message(t, { symbol: import_picocolors.default.green(Ft) }),
|
|
1732
|
+
step: (t) => K$1.message(t, { symbol: import_picocolors.default.green(V$1) }),
|
|
1733
|
+
warn: (t) => K$1.message(t, { symbol: import_picocolors.default.yellow(yt) }),
|
|
1734
|
+
warning: (t) => K$1.warn(t),
|
|
1735
|
+
error: (t) => K$1.message(t, { symbol: import_picocolors.default.red(Et) })
|
|
1736
|
+
}, Ye = async (t, r) => {
|
|
1737
|
+
for (const s of t) {
|
|
1738
|
+
if (s.enabled === !1) continue;
|
|
1739
|
+
const i = bt(r);
|
|
1740
|
+
i.start(s.title);
|
|
1741
|
+
const a = await s.task(i.message);
|
|
1742
|
+
i.stop(a || s.title);
|
|
1743
|
+
}
|
|
1744
|
+
}, ze = (t) => t.replace(/\x1b\[(?:\d+;)*\d*[ABCDEFGHfJKSTsu]|\x1b\[(s|u)/g, ""), Qe = (t) => {
|
|
1745
|
+
const r = t.output ?? process.stdout, s = rt$1(r), i = import_picocolors.default.gray(d$1), a = t.spacing ?? 1, o = 3, u = t.retainLog === !0, l = !ct() && Mt(r);
|
|
1746
|
+
r.write(`${i}
|
|
1747
|
+
`), r.write(`${import_picocolors.default.green(V$1)} ${t.title}
|
|
1748
|
+
`);
|
|
1749
|
+
for (let h = 0; h < a; h++) r.write(`${i}
|
|
1750
|
+
`);
|
|
1751
|
+
const n = [{
|
|
1752
|
+
value: "",
|
|
1753
|
+
full: ""
|
|
1754
|
+
}];
|
|
1755
|
+
let c = !1;
|
|
1756
|
+
const g = (h) => {
|
|
1757
|
+
if (n.length === 0) return;
|
|
1758
|
+
let y = 0;
|
|
1759
|
+
h && (y += a + 2);
|
|
1760
|
+
for (const f of n) {
|
|
1761
|
+
const { value: v, result: S } = f;
|
|
1762
|
+
let I = S?.message ?? v;
|
|
1763
|
+
if (I.length === 0) continue;
|
|
1764
|
+
S === void 0 && f.header !== void 0 && f.header !== "" && (I += `
|
|
1765
|
+
${f.header}`);
|
|
1766
|
+
const B = I.split(`
|
|
1767
|
+
`).reduce((A, w) => w === "" ? A + 1 : A + Math.ceil((w.length + o) / s), 0);
|
|
1768
|
+
y += B;
|
|
1769
|
+
}
|
|
1770
|
+
y > 0 && (y += 1, r.write(import_src.erase.lines(y)));
|
|
1771
|
+
}, F = (h, y, f) => {
|
|
1772
|
+
const v = f ? `${h.full}
|
|
1773
|
+
${h.value}` : h.value;
|
|
1774
|
+
h.header !== void 0 && h.header !== "" && R$1.message(h.header.split(`
|
|
1775
|
+
`).map(import_picocolors.default.bold), {
|
|
1776
|
+
output: r,
|
|
1777
|
+
secondarySymbol: i,
|
|
1778
|
+
symbol: i,
|
|
1779
|
+
spacing: 0
|
|
1780
|
+
}), R$1.message(v.split(`
|
|
1781
|
+
`).map(import_picocolors.default.dim), {
|
|
1782
|
+
output: r,
|
|
1783
|
+
secondarySymbol: i,
|
|
1784
|
+
symbol: i,
|
|
1785
|
+
spacing: y ?? a
|
|
1786
|
+
});
|
|
1787
|
+
}, p = () => {
|
|
1788
|
+
for (const h of n) {
|
|
1789
|
+
const { header: y, value: f, full: v } = h;
|
|
1790
|
+
(y === void 0 || y.length === 0) && f.length === 0 || F(h, void 0, u === !0 && v.length > 0);
|
|
1791
|
+
}
|
|
1792
|
+
}, E = (h, y, f) => {
|
|
1793
|
+
if (g(!1), (f?.raw !== !0 || !c) && h.value !== "" && (h.value += `
|
|
1794
|
+
`), h.value += ze(y), c = f?.raw === !0, t.limit !== void 0) {
|
|
1795
|
+
const v = h.value.split(`
|
|
1796
|
+
`), S = v.length - t.limit;
|
|
1797
|
+
if (S > 0) {
|
|
1798
|
+
const I = v.splice(0, S);
|
|
1799
|
+
u && (h.full += (h.full === "" ? "" : `
|
|
1800
|
+
`) + I.join(`
|
|
1801
|
+
`));
|
|
1802
|
+
}
|
|
1803
|
+
h.value = v.join(`
|
|
1804
|
+
`);
|
|
1805
|
+
}
|
|
1806
|
+
l && $();
|
|
1807
|
+
}, $ = () => {
|
|
1808
|
+
for (const h of n) h.result ? h.result.status === "error" ? R$1.error(h.result.message, {
|
|
1809
|
+
output: r,
|
|
1810
|
+
secondarySymbol: i,
|
|
1811
|
+
spacing: 0
|
|
1812
|
+
}) : R$1.success(h.result.message, {
|
|
1813
|
+
output: r,
|
|
1814
|
+
secondarySymbol: i,
|
|
1815
|
+
spacing: 0
|
|
1816
|
+
}) : h.value !== "" && F(h, 0);
|
|
1817
|
+
}, m = (h, y) => {
|
|
1818
|
+
g(!1), h.result = y, l && $();
|
|
1819
|
+
};
|
|
1820
|
+
return {
|
|
1821
|
+
message(h, y) {
|
|
1822
|
+
E(n[0], h, y);
|
|
1823
|
+
},
|
|
1824
|
+
group(h) {
|
|
1825
|
+
const y = {
|
|
1826
|
+
header: h,
|
|
1827
|
+
value: "",
|
|
1828
|
+
full: ""
|
|
1829
|
+
};
|
|
1830
|
+
return n.push(y), {
|
|
1831
|
+
message(f, v) {
|
|
1832
|
+
E(y, f, v);
|
|
1833
|
+
},
|
|
1834
|
+
error(f) {
|
|
1835
|
+
m(y, {
|
|
1836
|
+
status: "error",
|
|
1837
|
+
message: f
|
|
1838
|
+
});
|
|
1839
|
+
},
|
|
1840
|
+
success(f) {
|
|
1841
|
+
m(y, {
|
|
1842
|
+
status: "success",
|
|
1843
|
+
message: f
|
|
1844
|
+
});
|
|
1845
|
+
}
|
|
1846
|
+
};
|
|
1847
|
+
},
|
|
1848
|
+
error(h, y) {
|
|
1849
|
+
g(!0), R$1.error(h, {
|
|
1850
|
+
output: r,
|
|
1851
|
+
secondarySymbol: i,
|
|
1852
|
+
spacing: 1
|
|
1853
|
+
}), y?.showLog !== !1 && p(), n.splice(1, n.length - 1), n[0].value = "", n[0].full = "";
|
|
1854
|
+
},
|
|
1855
|
+
success(h, y) {
|
|
1856
|
+
g(!0), R$1.success(h, {
|
|
1857
|
+
output: r,
|
|
1858
|
+
secondarySymbol: i,
|
|
1859
|
+
spacing: 1
|
|
1860
|
+
}), y?.showLog === !0 && p(), n.splice(1, n.length - 1), n[0].value = "", n[0].full = "";
|
|
1861
|
+
}
|
|
1862
|
+
};
|
|
1863
|
+
}, Ze = (t) => new $t$1({
|
|
1864
|
+
validate: t.validate,
|
|
1865
|
+
placeholder: t.placeholder,
|
|
1866
|
+
defaultValue: t.defaultValue,
|
|
1867
|
+
initialValue: t.initialValue,
|
|
1868
|
+
output: t.output,
|
|
1869
|
+
signal: t.signal,
|
|
1870
|
+
input: t.input,
|
|
1871
|
+
render() {
|
|
1872
|
+
const r = t?.withGuide ?? _$1.withGuide, s = `${`${r ? `${import_picocolors.default.gray(d$1)}
|
|
1873
|
+
` : ""}${W$1(this.state)} `}${t.message}
|
|
1874
|
+
`, i = t.placeholder ? import_picocolors.default.inverse(t.placeholder[0]) + import_picocolors.default.dim(t.placeholder.slice(1)) : import_picocolors.default.inverse(import_picocolors.default.hidden("_")), a = this.userInput ? this.userInputWithCursor : i, o = this.value ?? "";
|
|
1875
|
+
switch (this.state) {
|
|
1876
|
+
case "error": {
|
|
1877
|
+
const u = this.error ? ` ${import_picocolors.default.yellow(this.error)}` : "", l = r ? `${import_picocolors.default.yellow(d$1)} ` : "", n = r ? import_picocolors.default.yellow(x$1) : "";
|
|
1878
|
+
return `${s.trim()}
|
|
1879
|
+
${l}${a}
|
|
1880
|
+
${n}${u}
|
|
1881
|
+
`;
|
|
1882
|
+
}
|
|
1883
|
+
case "submit": {
|
|
1884
|
+
const u = o ? ` ${import_picocolors.default.dim(o)}` : "";
|
|
1885
|
+
return `${s}${r ? import_picocolors.default.gray(d$1) : ""}${u}`;
|
|
1886
|
+
}
|
|
1887
|
+
case "cancel": {
|
|
1888
|
+
const u = o ? ` ${import_picocolors.default.strikethrough(import_picocolors.default.dim(o))}` : "", l = r ? import_picocolors.default.gray(d$1) : "";
|
|
1889
|
+
return `${s}${l}${u}${o.trim() ? `
|
|
1890
|
+
${l}` : ""}`;
|
|
1891
|
+
}
|
|
1892
|
+
default: return `${s}${r ? `${import_picocolors.default.cyan(d$1)} ` : ""}${a}
|
|
1893
|
+
${r ? import_picocolors.default.cyan(x$1) : ""}
|
|
1894
|
+
`;
|
|
1895
|
+
}
|
|
1896
|
+
}
|
|
1897
|
+
}).prompt();
|
|
1898
|
+
|
|
1899
|
+
//#endregion
|
|
1900
|
+
//#region node_modules/tinyexec/dist/main.js
|
|
1901
|
+
var l = Object.create;
|
|
1902
|
+
var u = Object.defineProperty;
|
|
1903
|
+
var d = Object.getOwnPropertyDescriptor;
|
|
1904
|
+
var f = Object.getOwnPropertyNames;
|
|
1905
|
+
var p = Object.getPrototypeOf;
|
|
1906
|
+
var m = Object.prototype.hasOwnProperty;
|
|
1907
|
+
var h = (e, t) => () => (t || e((t = { exports: {} }).exports, t), t.exports);
|
|
1908
|
+
var g = (e, t, n, r) => {
|
|
1909
|
+
if (t && typeof t === "object" || typeof t === "function") for (var i = f(t), a = 0, o = i.length, s; a < o; a++) {
|
|
1910
|
+
s = i[a];
|
|
1911
|
+
if (!m.call(e, s) && s !== n) u(e, s, {
|
|
1912
|
+
get: ((e) => t[e]).bind(null, s),
|
|
1913
|
+
enumerable: !(r = d(t, s)) || r.enumerable
|
|
1914
|
+
});
|
|
1915
|
+
}
|
|
1916
|
+
return e;
|
|
1917
|
+
};
|
|
1918
|
+
var _ = (e, t, n) => (n = e != null ? l(p(e)) : {}, g(t || !e || !e.__esModule ? u(n, "default", {
|
|
1919
|
+
value: e,
|
|
1920
|
+
enumerable: true
|
|
1921
|
+
}) : n, e));
|
|
1922
|
+
var v = /* @__PURE__ */ createRequire(import.meta.url);
|
|
1923
|
+
const y = /^path$/i;
|
|
1924
|
+
const b = {
|
|
1925
|
+
key: "PATH",
|
|
1926
|
+
value: ""
|
|
1927
|
+
};
|
|
1928
|
+
function x(e) {
|
|
1929
|
+
for (const t in e) {
|
|
1930
|
+
if (!Object.prototype.hasOwnProperty.call(e, t) || !y.test(t)) continue;
|
|
1931
|
+
const n = e[t];
|
|
1932
|
+
if (!n) return b;
|
|
1933
|
+
return {
|
|
1934
|
+
key: t,
|
|
1935
|
+
value: n
|
|
1936
|
+
};
|
|
1937
|
+
}
|
|
1938
|
+
return b;
|
|
1939
|
+
}
|
|
1940
|
+
function S(e, t) {
|
|
1941
|
+
const i = t.value.split(delimiter);
|
|
1942
|
+
let o = e;
|
|
1943
|
+
let s;
|
|
1944
|
+
do {
|
|
1945
|
+
i.push(resolve(o, "node_modules", ".bin"));
|
|
1946
|
+
s = o;
|
|
1947
|
+
o = dirname(o);
|
|
1948
|
+
} while (o !== s);
|
|
1949
|
+
return {
|
|
1950
|
+
key: t.key,
|
|
1951
|
+
value: i.join(delimiter)
|
|
1952
|
+
};
|
|
1953
|
+
}
|
|
1954
|
+
function C(e, t) {
|
|
1955
|
+
const n = {
|
|
1956
|
+
...process.env,
|
|
1957
|
+
...t
|
|
1958
|
+
};
|
|
1959
|
+
const r = S(e, x(n));
|
|
1960
|
+
n[r.key] = r.value;
|
|
1961
|
+
return n;
|
|
1962
|
+
}
|
|
1963
|
+
const w = (e) => {
|
|
1964
|
+
let t = e.length;
|
|
1965
|
+
const n = new PassThrough();
|
|
1966
|
+
const r = () => {
|
|
1967
|
+
if (--t === 0) n.emit("end");
|
|
1968
|
+
};
|
|
1969
|
+
for (const t of e) {
|
|
1970
|
+
t.pipe(n, { end: false });
|
|
1971
|
+
t.on("end", r);
|
|
1972
|
+
}
|
|
1973
|
+
return n;
|
|
1974
|
+
};
|
|
1975
|
+
var T = h((exports, t) => {
|
|
1976
|
+
t.exports = a;
|
|
1977
|
+
a.sync = o;
|
|
1978
|
+
var n = v("fs");
|
|
1979
|
+
function r(e, t) {
|
|
1980
|
+
var n = t.pathExt !== void 0 ? t.pathExt : process.env.PATHEXT;
|
|
1981
|
+
if (!n) return true;
|
|
1982
|
+
n = n.split(";");
|
|
1983
|
+
if (n.indexOf("") !== -1) return true;
|
|
1984
|
+
for (var r = 0; r < n.length; r++) {
|
|
1985
|
+
var i = n[r].toLowerCase();
|
|
1986
|
+
if (i && e.substr(-i.length).toLowerCase() === i) return true;
|
|
1987
|
+
}
|
|
1988
|
+
return false;
|
|
1989
|
+
}
|
|
1990
|
+
function i(e, t, n) {
|
|
1991
|
+
if (!e.isSymbolicLink() && !e.isFile()) return false;
|
|
1992
|
+
return r(t, n);
|
|
1993
|
+
}
|
|
1994
|
+
function a(e, t, r) {
|
|
1995
|
+
n.stat(e, function(n, a) {
|
|
1996
|
+
r(n, n ? false : i(a, e, t));
|
|
1997
|
+
});
|
|
1998
|
+
}
|
|
1999
|
+
function o(e, t) {
|
|
2000
|
+
return i(n.statSync(e), e, t);
|
|
2001
|
+
}
|
|
2002
|
+
});
|
|
2003
|
+
var E = h((exports, t) => {
|
|
2004
|
+
t.exports = r;
|
|
2005
|
+
r.sync = i;
|
|
2006
|
+
var n = v("fs");
|
|
2007
|
+
function r(e, t, r) {
|
|
2008
|
+
n.stat(e, function(e, n) {
|
|
2009
|
+
r(e, e ? false : a(n, t));
|
|
2010
|
+
});
|
|
2011
|
+
}
|
|
2012
|
+
function i(e, t) {
|
|
2013
|
+
return a(n.statSync(e), t);
|
|
2014
|
+
}
|
|
2015
|
+
function a(e, t) {
|
|
2016
|
+
return e.isFile() && o(e, t);
|
|
2017
|
+
}
|
|
2018
|
+
function o(e, t) {
|
|
2019
|
+
var n = e.mode;
|
|
2020
|
+
var r = e.uid;
|
|
2021
|
+
var i = e.gid;
|
|
2022
|
+
var a = t.uid !== void 0 ? t.uid : process.getuid && process.getuid();
|
|
2023
|
+
var o = t.gid !== void 0 ? t.gid : process.getgid && process.getgid();
|
|
2024
|
+
var s = parseInt("100", 8);
|
|
2025
|
+
var c = parseInt("010", 8);
|
|
2026
|
+
var l = parseInt("001", 8);
|
|
2027
|
+
var u = s | c;
|
|
2028
|
+
return n & l || n & c && i === o || n & s && r === a || n & u && a === 0;
|
|
2029
|
+
}
|
|
2030
|
+
});
|
|
2031
|
+
var D = h((exports, t) => {
|
|
2032
|
+
v("fs");
|
|
2033
|
+
var r;
|
|
2034
|
+
if (process.platform === "win32" || global.TESTING_WINDOWS) r = T();
|
|
2035
|
+
else r = E();
|
|
2036
|
+
t.exports = i;
|
|
2037
|
+
i.sync = a;
|
|
2038
|
+
function i(e, t, n) {
|
|
2039
|
+
if (typeof t === "function") {
|
|
2040
|
+
n = t;
|
|
2041
|
+
t = {};
|
|
2042
|
+
}
|
|
2043
|
+
if (!n) {
|
|
2044
|
+
if (typeof Promise !== "function") throw new TypeError("callback not provided");
|
|
2045
|
+
return new Promise(function(n, r) {
|
|
2046
|
+
i(e, t || {}, function(e, t) {
|
|
2047
|
+
if (e) r(e);
|
|
2048
|
+
else n(t);
|
|
2049
|
+
});
|
|
2050
|
+
});
|
|
2051
|
+
}
|
|
2052
|
+
r(e, t || {}, function(e, r) {
|
|
2053
|
+
if (e) {
|
|
2054
|
+
if (e.code === "EACCES" || t && t.ignoreErrors) {
|
|
2055
|
+
e = null;
|
|
2056
|
+
r = false;
|
|
2057
|
+
}
|
|
2058
|
+
}
|
|
2059
|
+
n(e, r);
|
|
2060
|
+
});
|
|
2061
|
+
}
|
|
2062
|
+
function a(e, t) {
|
|
2063
|
+
try {
|
|
2064
|
+
return r.sync(e, t || {});
|
|
2065
|
+
} catch (e) {
|
|
2066
|
+
if (t && t.ignoreErrors || e.code === "EACCES") return false;
|
|
2067
|
+
else throw e;
|
|
2068
|
+
}
|
|
2069
|
+
}
|
|
2070
|
+
});
|
|
2071
|
+
var O = h((exports, t) => {
|
|
2072
|
+
const n = process.platform === "win32" || process.env.OSTYPE === "cygwin" || process.env.OSTYPE === "msys";
|
|
2073
|
+
const r = v("path");
|
|
2074
|
+
const i = n ? ";" : ":";
|
|
2075
|
+
const a = D();
|
|
2076
|
+
const o = (e) => Object.assign(/* @__PURE__ */ new Error(`not found: ${e}`), { code: "ENOENT" });
|
|
2077
|
+
const s = (e, t) => {
|
|
2078
|
+
const r = t.colon || i;
|
|
2079
|
+
const a = e.match(/\//) || n && e.match(/\\/) ? [""] : [...n ? [process.cwd()] : [], ...(t.path || process.env.PATH || "").split(r)];
|
|
2080
|
+
const o = n ? t.pathExt || process.env.PATHEXT || ".EXE;.CMD;.BAT;.COM" : "";
|
|
2081
|
+
const s = n ? o.split(r) : [""];
|
|
2082
|
+
if (n) {
|
|
2083
|
+
if (e.indexOf(".") !== -1 && s[0] !== "") s.unshift("");
|
|
2084
|
+
}
|
|
2085
|
+
return {
|
|
2086
|
+
pathEnv: a,
|
|
2087
|
+
pathExt: s,
|
|
2088
|
+
pathExtExe: o
|
|
2089
|
+
};
|
|
2090
|
+
};
|
|
2091
|
+
const c = (e, t, n) => {
|
|
2092
|
+
if (typeof t === "function") {
|
|
2093
|
+
n = t;
|
|
2094
|
+
t = {};
|
|
2095
|
+
}
|
|
2096
|
+
if (!t) t = {};
|
|
2097
|
+
const { pathEnv: i, pathExt: c, pathExtExe: l } = s(e, t);
|
|
2098
|
+
const u = [];
|
|
2099
|
+
const d = (n) => new Promise((a, s) => {
|
|
2100
|
+
if (n === i.length) return t.all && u.length ? a(u) : s(o(e));
|
|
2101
|
+
const c = i[n];
|
|
2102
|
+
const l = /^".*"$/.test(c) ? c.slice(1, -1) : c;
|
|
2103
|
+
const d = r.join(l, e);
|
|
2104
|
+
a(f(!l && /^\.[\\\/]/.test(e) ? e.slice(0, 2) + d : d, n, 0));
|
|
2105
|
+
});
|
|
2106
|
+
const f = (e, n, r) => new Promise((i, o) => {
|
|
2107
|
+
if (r === c.length) return i(d(n + 1));
|
|
2108
|
+
const s = c[r];
|
|
2109
|
+
a(e + s, { pathExt: l }, (a, o) => {
|
|
2110
|
+
if (!a && o) if (t.all) u.push(e + s);
|
|
2111
|
+
else return i(e + s);
|
|
2112
|
+
return i(f(e, n, r + 1));
|
|
2113
|
+
});
|
|
2114
|
+
});
|
|
2115
|
+
return n ? d(0).then((e) => n(null, e), n) : d(0);
|
|
2116
|
+
};
|
|
2117
|
+
const l = (e, t) => {
|
|
2118
|
+
t = t || {};
|
|
2119
|
+
const { pathEnv: n, pathExt: i, pathExtExe: c } = s(e, t);
|
|
2120
|
+
const l = [];
|
|
2121
|
+
for (let o = 0; o < n.length; o++) {
|
|
2122
|
+
const s = n[o];
|
|
2123
|
+
const u = /^".*"$/.test(s) ? s.slice(1, -1) : s;
|
|
2124
|
+
const d = r.join(u, e);
|
|
2125
|
+
const f = !u && /^\.[\\\/]/.test(e) ? e.slice(0, 2) + d : d;
|
|
2126
|
+
for (let e = 0; e < i.length; e++) {
|
|
2127
|
+
const n = f + i[e];
|
|
2128
|
+
try {
|
|
2129
|
+
if (a.sync(n, { pathExt: c })) if (t.all) l.push(n);
|
|
2130
|
+
else return n;
|
|
2131
|
+
} catch (e) {}
|
|
2132
|
+
}
|
|
2133
|
+
}
|
|
2134
|
+
if (t.all && l.length) return l;
|
|
2135
|
+
if (t.nothrow) return null;
|
|
2136
|
+
throw o(e);
|
|
2137
|
+
};
|
|
2138
|
+
t.exports = c;
|
|
2139
|
+
c.sync = l;
|
|
2140
|
+
});
|
|
2141
|
+
var k = h((exports, t) => {
|
|
2142
|
+
const n = (e = {}) => {
|
|
2143
|
+
const t = e.env || process.env;
|
|
2144
|
+
if ((e.platform || process.platform) !== "win32") return "PATH";
|
|
2145
|
+
return Object.keys(t).reverse().find((e) => e.toUpperCase() === "PATH") || "Path";
|
|
2146
|
+
};
|
|
2147
|
+
t.exports = n;
|
|
2148
|
+
t.exports.default = n;
|
|
2149
|
+
});
|
|
2150
|
+
var A = h((exports, t) => {
|
|
2151
|
+
const n = v("path");
|
|
2152
|
+
const r = O();
|
|
2153
|
+
const i = k();
|
|
2154
|
+
function a(e, t) {
|
|
2155
|
+
const a = e.options.env || process.env;
|
|
2156
|
+
const o = process.cwd();
|
|
2157
|
+
const s = e.options.cwd != null;
|
|
2158
|
+
const c = s && process.chdir !== void 0 && !process.chdir.disabled;
|
|
2159
|
+
if (c) try {
|
|
2160
|
+
process.chdir(e.options.cwd);
|
|
2161
|
+
} catch (e) {}
|
|
2162
|
+
let l;
|
|
2163
|
+
try {
|
|
2164
|
+
l = r.sync(e.command, {
|
|
2165
|
+
path: a[i({ env: a })],
|
|
2166
|
+
pathExt: t ? n.delimiter : void 0
|
|
2167
|
+
});
|
|
2168
|
+
} catch (e) {} finally {
|
|
2169
|
+
if (c) process.chdir(o);
|
|
2170
|
+
}
|
|
2171
|
+
if (l) l = n.resolve(s ? e.options.cwd : "", l);
|
|
2172
|
+
return l;
|
|
2173
|
+
}
|
|
2174
|
+
function o(e) {
|
|
2175
|
+
return a(e) || a(e, true);
|
|
2176
|
+
}
|
|
2177
|
+
t.exports = o;
|
|
2178
|
+
});
|
|
2179
|
+
var j = h((exports, t) => {
|
|
2180
|
+
const n = /([()\][%!^"`<>&|;, *?])/g;
|
|
2181
|
+
function r(e) {
|
|
2182
|
+
e = e.replace(n, "^$1");
|
|
2183
|
+
return e;
|
|
2184
|
+
}
|
|
2185
|
+
function i(e, t) {
|
|
2186
|
+
e = `${e}`;
|
|
2187
|
+
e = e.replace(/(\\*)"/g, "$1$1\\\"");
|
|
2188
|
+
e = e.replace(/(\\*)$/, "$1$1");
|
|
2189
|
+
e = `"${e}"`;
|
|
2190
|
+
e = e.replace(n, "^$1");
|
|
2191
|
+
if (t) e = e.replace(n, "^$1");
|
|
2192
|
+
return e;
|
|
2193
|
+
}
|
|
2194
|
+
t.exports.command = r;
|
|
2195
|
+
t.exports.argument = i;
|
|
2196
|
+
});
|
|
2197
|
+
var M = h((exports, t) => {
|
|
2198
|
+
t.exports = /^#!(.*)/;
|
|
2199
|
+
});
|
|
2200
|
+
var N$1 = h((exports, t) => {
|
|
2201
|
+
const n = M();
|
|
2202
|
+
t.exports = (e = "") => {
|
|
2203
|
+
const t = e.match(n);
|
|
2204
|
+
if (!t) return null;
|
|
2205
|
+
const [r, i] = t[0].replace(/#! ?/, "").split(" ");
|
|
2206
|
+
const a = r.split("/").pop();
|
|
2207
|
+
if (a === "env") return i;
|
|
2208
|
+
return i ? `${a} ${i}` : a;
|
|
2209
|
+
};
|
|
2210
|
+
});
|
|
2211
|
+
var P = h((exports, t) => {
|
|
2212
|
+
const n = v("fs");
|
|
2213
|
+
const r = N$1();
|
|
2214
|
+
function i(e) {
|
|
2215
|
+
const t = 150;
|
|
2216
|
+
const i = Buffer.alloc(t);
|
|
2217
|
+
let a;
|
|
2218
|
+
try {
|
|
2219
|
+
a = n.openSync(e, "r");
|
|
2220
|
+
n.readSync(a, i, 0, t, 0);
|
|
2221
|
+
n.closeSync(a);
|
|
2222
|
+
} catch (e) {}
|
|
2223
|
+
return r(i.toString());
|
|
2224
|
+
}
|
|
2225
|
+
t.exports = i;
|
|
2226
|
+
});
|
|
2227
|
+
var F = h((exports, t) => {
|
|
2228
|
+
const n = v("path");
|
|
2229
|
+
const r = A();
|
|
2230
|
+
const i = j();
|
|
2231
|
+
const a = P();
|
|
2232
|
+
const o = process.platform === "win32";
|
|
2233
|
+
const s = /\.(?:com|exe)$/i;
|
|
2234
|
+
const c = /node_modules[\\/].bin[\\/][^\\/]+\.cmd$/i;
|
|
2235
|
+
function l(e) {
|
|
2236
|
+
e.file = r(e);
|
|
2237
|
+
const t = e.file && a(e.file);
|
|
2238
|
+
if (t) {
|
|
2239
|
+
e.args.unshift(e.file);
|
|
2240
|
+
e.command = t;
|
|
2241
|
+
return r(e);
|
|
2242
|
+
}
|
|
2243
|
+
return e.file;
|
|
2244
|
+
}
|
|
2245
|
+
function u(e) {
|
|
2246
|
+
if (!o) return e;
|
|
2247
|
+
const t = l(e);
|
|
2248
|
+
const r = !s.test(t);
|
|
2249
|
+
if (e.options.forceShell || r) {
|
|
2250
|
+
const r = c.test(t);
|
|
2251
|
+
e.command = n.normalize(e.command);
|
|
2252
|
+
e.command = i.command(e.command);
|
|
2253
|
+
e.args = e.args.map((e) => i.argument(e, r));
|
|
2254
|
+
e.args = [
|
|
2255
|
+
"/d",
|
|
2256
|
+
"/s",
|
|
2257
|
+
"/c",
|
|
2258
|
+
`"${[e.command].concat(e.args).join(" ")}"`
|
|
2259
|
+
];
|
|
2260
|
+
e.command = process.env.comspec || "cmd.exe";
|
|
2261
|
+
e.options.windowsVerbatimArguments = true;
|
|
2262
|
+
}
|
|
2263
|
+
return e;
|
|
2264
|
+
}
|
|
2265
|
+
function d(e, t, n) {
|
|
2266
|
+
if (t && !Array.isArray(t)) {
|
|
2267
|
+
n = t;
|
|
2268
|
+
t = null;
|
|
2269
|
+
}
|
|
2270
|
+
t = t ? t.slice(0) : [];
|
|
2271
|
+
n = Object.assign({}, n);
|
|
2272
|
+
const r = {
|
|
2273
|
+
command: e,
|
|
2274
|
+
args: t,
|
|
2275
|
+
options: n,
|
|
2276
|
+
file: void 0,
|
|
2277
|
+
original: {
|
|
2278
|
+
command: e,
|
|
2279
|
+
args: t
|
|
2280
|
+
}
|
|
2281
|
+
};
|
|
2282
|
+
return n.shell ? r : u(r);
|
|
2283
|
+
}
|
|
2284
|
+
t.exports = d;
|
|
2285
|
+
});
|
|
2286
|
+
var I = h((exports, t) => {
|
|
2287
|
+
const n = process.platform === "win32";
|
|
2288
|
+
function r(e, t) {
|
|
2289
|
+
return Object.assign(/* @__PURE__ */ new Error(`${t} ${e.command} ENOENT`), {
|
|
2290
|
+
code: "ENOENT",
|
|
2291
|
+
errno: "ENOENT",
|
|
2292
|
+
syscall: `${t} ${e.command}`,
|
|
2293
|
+
path: e.command,
|
|
2294
|
+
spawnargs: e.args
|
|
2295
|
+
});
|
|
2296
|
+
}
|
|
2297
|
+
function i(e, t) {
|
|
2298
|
+
if (!n) return;
|
|
2299
|
+
const r = e.emit;
|
|
2300
|
+
e.emit = function(n, i) {
|
|
2301
|
+
if (n === "exit") {
|
|
2302
|
+
const n = a(i, t, "spawn");
|
|
2303
|
+
if (n) return r.call(e, "error", n);
|
|
2304
|
+
}
|
|
2305
|
+
return r.apply(e, arguments);
|
|
2306
|
+
};
|
|
2307
|
+
}
|
|
2308
|
+
function a(e, t) {
|
|
2309
|
+
if (n && e === 1 && !t.file) return r(t.original, "spawn");
|
|
2310
|
+
return null;
|
|
2311
|
+
}
|
|
2312
|
+
function o(e, t) {
|
|
2313
|
+
if (n && e === 1 && !t.file) return r(t.original, "spawnSync");
|
|
2314
|
+
return null;
|
|
2315
|
+
}
|
|
2316
|
+
t.exports = {
|
|
2317
|
+
hookChildProcess: i,
|
|
2318
|
+
verifyENOENT: a,
|
|
2319
|
+
verifyENOENTSync: o,
|
|
2320
|
+
notFoundError: r
|
|
2321
|
+
};
|
|
2322
|
+
});
|
|
2323
|
+
var R = _(h((exports, t) => {
|
|
2324
|
+
const n = v("child_process");
|
|
2325
|
+
const r = F();
|
|
2326
|
+
const i = I();
|
|
2327
|
+
function a(e, t, a) {
|
|
2328
|
+
const o = r(e, t, a);
|
|
2329
|
+
const s = n.spawn(o.command, o.args, o.options);
|
|
2330
|
+
i.hookChildProcess(s, o);
|
|
2331
|
+
return s;
|
|
2332
|
+
}
|
|
2333
|
+
function o(e, t, a) {
|
|
2334
|
+
const o = r(e, t, a);
|
|
2335
|
+
const s = n.spawnSync(o.command, o.args, o.options);
|
|
2336
|
+
s.error = s.error || i.verifyENOENTSync(s.status, o);
|
|
2337
|
+
return s;
|
|
2338
|
+
}
|
|
2339
|
+
t.exports = a;
|
|
2340
|
+
t.exports.spawn = a;
|
|
2341
|
+
t.exports.sync = o;
|
|
2342
|
+
t.exports._parse = r;
|
|
2343
|
+
t.exports._enoent = i;
|
|
2344
|
+
})(), 1);
|
|
2345
|
+
var z = class extends Error {
|
|
2346
|
+
result;
|
|
2347
|
+
output;
|
|
2348
|
+
get exitCode() {
|
|
2349
|
+
if (this.result.exitCode !== null) return this.result.exitCode;
|
|
2350
|
+
}
|
|
2351
|
+
constructor(e, t) {
|
|
2352
|
+
super(`Process exited with non-zero status (${e.exitCode})`);
|
|
2353
|
+
this.result = e;
|
|
2354
|
+
this.output = t;
|
|
2355
|
+
}
|
|
2356
|
+
};
|
|
2357
|
+
const B = {
|
|
2358
|
+
timeout: void 0,
|
|
2359
|
+
persist: false
|
|
2360
|
+
};
|
|
2361
|
+
const V = { windowsHide: true };
|
|
2362
|
+
function H(e, t) {
|
|
2363
|
+
return {
|
|
2364
|
+
command: normalize(e),
|
|
2365
|
+
args: t ?? []
|
|
2366
|
+
};
|
|
2367
|
+
}
|
|
2368
|
+
function U(e) {
|
|
2369
|
+
const t = new AbortController();
|
|
2370
|
+
for (const n of e) {
|
|
2371
|
+
if (n.aborted) {
|
|
2372
|
+
t.abort();
|
|
2373
|
+
return n;
|
|
2374
|
+
}
|
|
2375
|
+
const e = () => {
|
|
2376
|
+
t.abort(n.reason);
|
|
2377
|
+
};
|
|
2378
|
+
n.addEventListener("abort", e, { signal: t.signal });
|
|
2379
|
+
}
|
|
2380
|
+
return t.signal;
|
|
2381
|
+
}
|
|
2382
|
+
async function W(e) {
|
|
2383
|
+
let t = "";
|
|
2384
|
+
for await (const n of e) t += n.toString();
|
|
2385
|
+
return t;
|
|
2386
|
+
}
|
|
2387
|
+
var G = class {
|
|
2388
|
+
_process;
|
|
2389
|
+
_aborted = false;
|
|
2390
|
+
_options;
|
|
2391
|
+
_command;
|
|
2392
|
+
_args;
|
|
2393
|
+
_resolveClose;
|
|
2394
|
+
_processClosed;
|
|
2395
|
+
_thrownError;
|
|
2396
|
+
get process() {
|
|
2397
|
+
return this._process;
|
|
2398
|
+
}
|
|
2399
|
+
get pid() {
|
|
2400
|
+
return this._process?.pid;
|
|
2401
|
+
}
|
|
2402
|
+
get exitCode() {
|
|
2403
|
+
if (this._process && this._process.exitCode !== null) return this._process.exitCode;
|
|
2404
|
+
}
|
|
2405
|
+
constructor(e, t, n) {
|
|
2406
|
+
this._options = {
|
|
2407
|
+
...B,
|
|
2408
|
+
...n
|
|
2409
|
+
};
|
|
2410
|
+
this._command = e;
|
|
2411
|
+
this._args = t ?? [];
|
|
2412
|
+
this._processClosed = new Promise((e) => {
|
|
2413
|
+
this._resolveClose = e;
|
|
2414
|
+
});
|
|
2415
|
+
}
|
|
2416
|
+
kill(e) {
|
|
2417
|
+
return this._process?.kill(e) === true;
|
|
2418
|
+
}
|
|
2419
|
+
get aborted() {
|
|
2420
|
+
return this._aborted;
|
|
2421
|
+
}
|
|
2422
|
+
get killed() {
|
|
2423
|
+
return this._process?.killed === true;
|
|
2424
|
+
}
|
|
2425
|
+
pipe(e, t, n) {
|
|
2426
|
+
return q(e, t, {
|
|
2427
|
+
...n,
|
|
2428
|
+
stdin: this
|
|
2429
|
+
});
|
|
2430
|
+
}
|
|
2431
|
+
async *[Symbol.asyncIterator]() {
|
|
2432
|
+
const e = this._process;
|
|
2433
|
+
if (!e) return;
|
|
2434
|
+
const t = [];
|
|
2435
|
+
if (this._streamErr) t.push(this._streamErr);
|
|
2436
|
+
if (this._streamOut) t.push(this._streamOut);
|
|
2437
|
+
const n = w(t);
|
|
2438
|
+
const r = c.createInterface({ input: n });
|
|
2439
|
+
for await (const e of r) yield e.toString();
|
|
2440
|
+
await this._processClosed;
|
|
2441
|
+
e.removeAllListeners();
|
|
2442
|
+
if (this._thrownError) throw this._thrownError;
|
|
2443
|
+
if (this._options?.throwOnError && this.exitCode !== 0 && this.exitCode !== void 0) throw new z(this);
|
|
2444
|
+
}
|
|
2445
|
+
async _waitForOutput() {
|
|
2446
|
+
const e = this._process;
|
|
2447
|
+
if (!e) throw new Error("No process was started");
|
|
2448
|
+
const [t, n] = await Promise.all([this._streamOut ? W(this._streamOut) : "", this._streamErr ? W(this._streamErr) : ""]);
|
|
2449
|
+
await this._processClosed;
|
|
2450
|
+
if (this._options?.stdin) await this._options.stdin;
|
|
2451
|
+
e.removeAllListeners();
|
|
2452
|
+
if (this._thrownError) throw this._thrownError;
|
|
2453
|
+
const r = {
|
|
2454
|
+
stderr: n,
|
|
2455
|
+
stdout: t,
|
|
2456
|
+
exitCode: this.exitCode
|
|
2457
|
+
};
|
|
2458
|
+
if (this._options.throwOnError && this.exitCode !== 0 && this.exitCode !== void 0) throw new z(this, r);
|
|
2459
|
+
return r;
|
|
2460
|
+
}
|
|
2461
|
+
then(e, t) {
|
|
2462
|
+
return this._waitForOutput().then(e, t);
|
|
2463
|
+
}
|
|
2464
|
+
_streamOut;
|
|
2465
|
+
_streamErr;
|
|
2466
|
+
spawn() {
|
|
2467
|
+
const e = cwd();
|
|
2468
|
+
const n = this._options;
|
|
2469
|
+
const r = {
|
|
2470
|
+
...V,
|
|
2471
|
+
...n.nodeOptions
|
|
2472
|
+
};
|
|
2473
|
+
const i = [];
|
|
2474
|
+
this._resetState();
|
|
2475
|
+
if (n.timeout !== void 0) i.push(AbortSignal.timeout(n.timeout));
|
|
2476
|
+
if (n.signal !== void 0) i.push(n.signal);
|
|
2477
|
+
if (n.persist === true) r.detached = true;
|
|
2478
|
+
if (i.length > 0) r.signal = U(i);
|
|
2479
|
+
r.env = C(e, r.env);
|
|
2480
|
+
const { command: a, args: s } = H(this._command, this._args);
|
|
2481
|
+
const c = (0, R._parse)(a, s, r);
|
|
2482
|
+
const l = spawn(c.command, c.args, c.options);
|
|
2483
|
+
if (l.stderr) this._streamErr = l.stderr;
|
|
2484
|
+
if (l.stdout) this._streamOut = l.stdout;
|
|
2485
|
+
this._process = l;
|
|
2486
|
+
l.once("error", this._onError);
|
|
2487
|
+
l.once("close", this._onClose);
|
|
2488
|
+
if (n.stdin !== void 0 && l.stdin && n.stdin.process) {
|
|
2489
|
+
const { stdout: e } = n.stdin.process;
|
|
2490
|
+
if (e) e.pipe(l.stdin);
|
|
2491
|
+
}
|
|
2492
|
+
}
|
|
2493
|
+
_resetState() {
|
|
2494
|
+
this._aborted = false;
|
|
2495
|
+
this._processClosed = new Promise((e) => {
|
|
2496
|
+
this._resolveClose = e;
|
|
2497
|
+
});
|
|
2498
|
+
this._thrownError = void 0;
|
|
2499
|
+
}
|
|
2500
|
+
_onError = (e) => {
|
|
2501
|
+
if (e.name === "AbortError" && (!(e.cause instanceof Error) || e.cause.name !== "TimeoutError")) {
|
|
2502
|
+
this._aborted = true;
|
|
2503
|
+
return;
|
|
2504
|
+
}
|
|
2505
|
+
this._thrownError = e;
|
|
2506
|
+
};
|
|
2507
|
+
_onClose = () => {
|
|
2508
|
+
if (this._resolveClose) this._resolveClose();
|
|
2509
|
+
};
|
|
2510
|
+
};
|
|
2511
|
+
const K = (e, t, n) => {
|
|
2512
|
+
const r = new G(e, t, n);
|
|
2513
|
+
r.spawn();
|
|
2514
|
+
return r;
|
|
2515
|
+
};
|
|
2516
|
+
const q = K;
|
|
2517
|
+
|
|
2518
|
+
//#endregion
|
|
2519
|
+
//#region src/prompts.ts
|
|
2520
|
+
/**
|
|
2521
|
+
* Shared prompt-building logic for all providers.
|
|
2522
|
+
*/
|
|
2523
|
+
function buildSystemPrompt(commitLog, instructions) {
|
|
2524
|
+
const truncatedLog = truncate(commitLog, 1e4);
|
|
2525
|
+
const hasHistory = Boolean(commitLog.trim());
|
|
2526
|
+
const parts = [
|
|
2527
|
+
`You are a git commit message generator. Your ONLY output is a commit message — nothing else.`,
|
|
2528
|
+
``,
|
|
2529
|
+
`RECENT COMMIT HISTORY FROM THIS REPO:`,
|
|
2530
|
+
`\`\`\``,
|
|
2531
|
+
hasHistory ? truncatedLog : "(no history — new repo)",
|
|
2532
|
+
`\`\`\``,
|
|
2533
|
+
``
|
|
2534
|
+
];
|
|
2535
|
+
if (!hasHistory) parts.push(`Since this is a new repo with no commit history, use this default style:`, `- Conventional commits format (feat:, fix:, chore:, docs:, refactor:, etc.)`, `- Imperative mood, lowercase after prefix`, `- Subject line followed by an optional body with 1-3 bullet points summarizing key changes`, `- Only include body bullets when the diff warrants it — don't add filler`, ``);
|
|
2536
|
+
parts.push(`INSTRUCTIONS:`, `1. Study the commit history above carefully. Notice the format, conventions, tone, and style.`, ` - Do they use conventional commits (feat:, fix:, etc.)?`, ` - Gitmoji? Ticket prefixes? Brackets?`, ` - Imperative mood or past tense?`, ` - Capitalized or lowercase?`, ` - Subject-only, or subject + body?`, ` - What level of detail?`, `2. Generate a commit message for the staged changes that **matches the repo's existing style exactly**.`, `3. Do NOT invent issue/ticket numbers unless they appear in the diff.`, `4. If the style uses a subject + body format, separate them with a blank line.`, ` Wrap body lines at 72 characters.`, `5. When the repo has no established style, default to conventional commits (feat:, fix:, chore:, etc.)`, ` with an optional body of 1-3 concise bullet points. Only include bullets when the changes are`, ` complex enough to warrant them — do not pad with filler.`, `6. Disregard generated files (lockfiles, migration files, build output, etc.) when evaluating changes.`, ` Focus on the human-authored source changes to determine the commit message.`, `7. NEVER add "Co-authored-by", "Signed-off-by", or any git trailers to the commit message.`);
|
|
2537
|
+
if (instructions) parts.push(``, `ADDITIONAL USER INSTRUCTIONS:`, instructions);
|
|
2538
|
+
parts.push(``, `REMINDER: Output ONLY the raw commit message text. No quotes, no markdown fences, no explanation, no preamble.`);
|
|
2539
|
+
return parts.join("\n");
|
|
2540
|
+
}
|
|
2541
|
+
function buildUserPrompt(diff, stat, files) {
|
|
2542
|
+
const truncatedDiff = truncateDiff(diff, 15e3);
|
|
2543
|
+
return [
|
|
2544
|
+
`Generate a commit message for these staged changes:`,
|
|
2545
|
+
``,
|
|
2546
|
+
`Files changed:`,
|
|
2547
|
+
files.join("\n"),
|
|
2548
|
+
``,
|
|
2549
|
+
`Diff stat:`,
|
|
2550
|
+
stat,
|
|
2551
|
+
``,
|
|
2552
|
+
`Full diff:`,
|
|
2553
|
+
truncatedDiff
|
|
2554
|
+
].join("\n");
|
|
2555
|
+
}
|
|
2556
|
+
/**
|
|
2557
|
+
* Truncate plain text to a character limit.
|
|
2558
|
+
*/
|
|
2559
|
+
function truncate(text, maxChars) {
|
|
2560
|
+
if (text.length <= maxChars) return text;
|
|
2561
|
+
return `${text.slice(0, maxChars)}\n\n[... truncated ...]`;
|
|
2562
|
+
}
|
|
2563
|
+
/**
|
|
2564
|
+
* Truncate a unified diff at hunk boundaries so we don't cut mid-hunk.
|
|
2565
|
+
* Keeps whole hunks (starting with @@ or diff --git) until the budget
|
|
2566
|
+
* is exhausted, then appends a note about the omitted remainder.
|
|
2567
|
+
*/
|
|
2568
|
+
function truncateDiff(diff, maxChars) {
|
|
2569
|
+
if (diff.length <= maxChars) return diff;
|
|
2570
|
+
const sections = diff.split(/(?=^diff --git )/m);
|
|
2571
|
+
let result = "";
|
|
2572
|
+
for (const section of sections) {
|
|
2573
|
+
if (result.length + section.length > maxChars) {
|
|
2574
|
+
const hunks = section.split(/(?=^@@ )/m);
|
|
2575
|
+
for (const hunk of hunks) {
|
|
2576
|
+
if (result.length + hunk.length > maxChars) break;
|
|
2577
|
+
result += hunk;
|
|
2578
|
+
}
|
|
2579
|
+
break;
|
|
2580
|
+
}
|
|
2581
|
+
result += section;
|
|
2582
|
+
}
|
|
2583
|
+
if (result.length < diff.length) result += "\n\n[... diff truncated — stat summary above covers all files ...]";
|
|
2584
|
+
return result;
|
|
2585
|
+
}
|
|
2586
|
+
|
|
2587
|
+
//#endregion
|
|
2588
|
+
//#region src/providers.ts
|
|
2589
|
+
const claude = {
|
|
2590
|
+
name: "Claude",
|
|
2591
|
+
bin: "claude",
|
|
2592
|
+
versionArgs: ["--version"],
|
|
2593
|
+
defaultModel: "sonnet",
|
|
2594
|
+
buildArgs({ userPrompt, systemPrompt, model }) {
|
|
2595
|
+
return [
|
|
2596
|
+
"-p",
|
|
2597
|
+
userPrompt,
|
|
2598
|
+
"--output-format",
|
|
2599
|
+
"json",
|
|
2600
|
+
"--model",
|
|
2601
|
+
model,
|
|
2602
|
+
"--tools",
|
|
2603
|
+
"",
|
|
2604
|
+
"--strict-mcp-config",
|
|
2605
|
+
"--no-session-persistence",
|
|
2606
|
+
"--system-prompt",
|
|
2607
|
+
systemPrompt
|
|
2608
|
+
];
|
|
2609
|
+
},
|
|
2610
|
+
parseOutput(stdout) {
|
|
2611
|
+
let parsed;
|
|
2612
|
+
try {
|
|
2613
|
+
parsed = JSON.parse(stdout);
|
|
2614
|
+
} catch {
|
|
2615
|
+
throw new Error(`Failed to parse Claude response as JSON. Raw output:\n${stdout.slice(0, 500)}`);
|
|
2616
|
+
}
|
|
2617
|
+
if (parsed.is_error) throw new Error(`Claude error: ${parsed.result}`);
|
|
2618
|
+
const result = (parsed.result || "").trim();
|
|
2619
|
+
if (!result) throw new Error("Claude returned an empty commit message.");
|
|
2620
|
+
return result;
|
|
2621
|
+
}
|
|
2622
|
+
};
|
|
2623
|
+
const codex = {
|
|
2624
|
+
name: "Codex",
|
|
2625
|
+
bin: "codex",
|
|
2626
|
+
versionArgs: ["--version"],
|
|
2627
|
+
defaultModel: "gpt-5.1-codex-mini",
|
|
2628
|
+
buildArgs({ userPrompt, systemPrompt, model }) {
|
|
2629
|
+
return [
|
|
2630
|
+
"exec",
|
|
2631
|
+
userPrompt,
|
|
2632
|
+
"--model",
|
|
2633
|
+
model,
|
|
2634
|
+
"-c",
|
|
2635
|
+
`developer_instructions=${systemPrompt}`,
|
|
2636
|
+
"-c",
|
|
2637
|
+
"model_reasoning_effort=medium",
|
|
2638
|
+
"-c",
|
|
2639
|
+
"check_for_update_on_startup=false",
|
|
2640
|
+
"--ephemeral",
|
|
2641
|
+
"--sandbox",
|
|
2642
|
+
"read-only"
|
|
2643
|
+
];
|
|
2644
|
+
},
|
|
2645
|
+
parseOutput(stdout) {
|
|
2646
|
+
const result = stdout.trim();
|
|
2647
|
+
if (!result) throw new Error("Codex returned an empty commit message.");
|
|
2648
|
+
return result;
|
|
2649
|
+
}
|
|
2650
|
+
};
|
|
2651
|
+
const providers = {
|
|
2652
|
+
claude,
|
|
2653
|
+
codex
|
|
2654
|
+
};
|
|
2655
|
+
/**
|
|
2656
|
+
* Check that a provider's CLI binary is installed and accessible.
|
|
2657
|
+
*/
|
|
2658
|
+
async function ensureProvider(provider) {
|
|
2659
|
+
const { exitCode } = await q(provider.bin, provider.versionArgs, { nodeOptions: { stdio: [
|
|
2660
|
+
"ignore",
|
|
2661
|
+
"pipe",
|
|
2662
|
+
"pipe"
|
|
2663
|
+
] } });
|
|
2664
|
+
if (exitCode !== 0) throw new Error(`${provider.name} CLI ("${provider.bin}") not found. Make sure it is installed and on your PATH.`);
|
|
2665
|
+
}
|
|
2666
|
+
/**
|
|
2667
|
+
* Generate a commit message using the given provider's CLI.
|
|
2668
|
+
*/
|
|
2669
|
+
async function generateCommitMessage(provider, opts) {
|
|
2670
|
+
const { diff, stat, files, commitLog, model, instructions, log } = opts;
|
|
2671
|
+
const systemPrompt = buildSystemPrompt(commitLog, instructions);
|
|
2672
|
+
const userPrompt = buildUserPrompt(diff, stat, files);
|
|
2673
|
+
log?.(`System prompt:\n${systemPrompt}`);
|
|
2674
|
+
log?.(`User prompt:\n${userPrompt}`);
|
|
2675
|
+
const args = provider.buildArgs({
|
|
2676
|
+
userPrompt,
|
|
2677
|
+
systemPrompt,
|
|
2678
|
+
model
|
|
2679
|
+
});
|
|
2680
|
+
const { stdout, stderr, exitCode } = await q(provider.bin, args, {
|
|
2681
|
+
timeout: 12e4,
|
|
2682
|
+
nodeOptions: { stdio: [
|
|
2683
|
+
"ignore",
|
|
2684
|
+
"pipe",
|
|
2685
|
+
"pipe"
|
|
2686
|
+
] }
|
|
2687
|
+
});
|
|
2688
|
+
log?.(`Raw response:\n${stdout}${stderr ? `\nStderr:\n${stderr}` : ""}`);
|
|
2689
|
+
if (exitCode !== 0) throw new Error(`${provider.name} exited with code ${exitCode}\n${stderr || stdout}`);
|
|
2690
|
+
return provider.parseOutput(stdout);
|
|
2691
|
+
}
|
|
2692
|
+
|
|
2693
|
+
//#endregion
|
|
2694
|
+
//#region src/args.ts
|
|
2695
|
+
const DEFAULT_PROVIDER = "claude";
|
|
2696
|
+
const options = {
|
|
2697
|
+
provider: {
|
|
2698
|
+
type: "string",
|
|
2699
|
+
short: "p"
|
|
2700
|
+
},
|
|
2701
|
+
model: {
|
|
2702
|
+
type: "string",
|
|
2703
|
+
short: "m"
|
|
2704
|
+
},
|
|
2705
|
+
yolo: {
|
|
2706
|
+
type: "boolean",
|
|
2707
|
+
short: "y"
|
|
2708
|
+
},
|
|
2709
|
+
verbose: {
|
|
2710
|
+
type: "boolean",
|
|
2711
|
+
short: "v"
|
|
2712
|
+
},
|
|
2713
|
+
help: {
|
|
2714
|
+
type: "boolean",
|
|
2715
|
+
short: "h"
|
|
2716
|
+
}
|
|
2717
|
+
};
|
|
2718
|
+
function parseConfig() {
|
|
2719
|
+
const { values } = parseArgs({
|
|
2720
|
+
args: process.argv.slice(2),
|
|
2721
|
+
options,
|
|
2722
|
+
strict: false
|
|
2723
|
+
});
|
|
2724
|
+
return {
|
|
2725
|
+
provider: values.provider ?? process.env.ACAI_PROVIDER ?? DEFAULT_PROVIDER,
|
|
2726
|
+
model: values.model ?? process.env.ACAI_MODEL ?? "",
|
|
2727
|
+
yolo: values.yolo ?? false,
|
|
2728
|
+
verbose: values.verbose ?? false,
|
|
2729
|
+
help: values.help ?? false
|
|
2730
|
+
};
|
|
2731
|
+
}
|
|
2732
|
+
function printUsage() {
|
|
2733
|
+
const providerNames = Object.keys(providers).join(", ");
|
|
2734
|
+
console.log(`
|
|
92
2735
|
Usage: acai [options]
|
|
93
2736
|
|
|
94
2737
|
Options:
|
|
95
|
-
-p, --provider <name> AI provider to use (${
|
|
2738
|
+
-p, --provider <name> AI provider to use (${providerNames}) (default: ${DEFAULT_PROVIDER})
|
|
96
2739
|
Can also set ACAI_PROVIDER env var
|
|
97
2740
|
-m, --model <model> Model to use (default: provider-specific)
|
|
98
2741
|
Can also set ACAI_MODEL env var
|
|
99
2742
|
-y, --yolo Stage all changes and commit without confirmation
|
|
2743
|
+
-v, --verbose Print prompts sent to the provider and raw responses
|
|
100
2744
|
-h, --help Show this help message
|
|
101
2745
|
|
|
102
2746
|
Examples:
|
|
103
2747
|
acai # use Claude with default model
|
|
104
2748
|
acai -p codex # use OpenAI Codex CLI
|
|
105
2749
|
acai -p codex -m o4-mini # use Codex with specific model
|
|
106
|
-
acai --model haiku
|
|
107
|
-
acai
|
|
108
|
-
`.trimStart())
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
2750
|
+
acai --model haiku # use Claude with haiku for speed
|
|
2751
|
+
acai --yolo # skip interaction and commit all changes
|
|
2752
|
+
`.trimStart());
|
|
2753
|
+
}
|
|
2754
|
+
|
|
2755
|
+
//#endregion
|
|
2756
|
+
//#region src/git.ts
|
|
2757
|
+
async function ensureGitRepo() {
|
|
2758
|
+
const { stdout, exitCode } = await q("git", ["rev-parse", "--is-inside-work-tree"]);
|
|
2759
|
+
if (exitCode !== 0 || stdout.trim() !== "true") throw new Error("Not inside a git repository.");
|
|
2760
|
+
}
|
|
2761
|
+
async function getStagedDiff() {
|
|
2762
|
+
const { stdout, exitCode } = await q("git", ["diff", "--cached"]);
|
|
2763
|
+
return exitCode === 0 ? stdout.trim() : null;
|
|
2764
|
+
}
|
|
2765
|
+
async function getStagedStat() {
|
|
2766
|
+
const { stdout, exitCode } = await q("git", [
|
|
2767
|
+
"diff",
|
|
2768
|
+
"--cached",
|
|
2769
|
+
"--stat"
|
|
2770
|
+
]);
|
|
2771
|
+
return exitCode === 0 ? stdout.trim() : null;
|
|
2772
|
+
}
|
|
2773
|
+
async function getStagedFiles() {
|
|
2774
|
+
const { stdout, exitCode } = await q("git", [
|
|
2775
|
+
"diff",
|
|
2776
|
+
"--cached",
|
|
2777
|
+
"--name-only"
|
|
2778
|
+
]);
|
|
2779
|
+
if (exitCode !== 0 || !stdout.trim()) return [];
|
|
2780
|
+
return stdout.trim().split("\n").filter(Boolean);
|
|
2781
|
+
}
|
|
2782
|
+
/**
|
|
2783
|
+
* Return all unstaged/untracked files with their status.
|
|
2784
|
+
* Parses the index (XY) columns of `git status --porcelain`.
|
|
2785
|
+
*/
|
|
2786
|
+
async function getUnstagedFiles() {
|
|
2787
|
+
const { stdout, exitCode } = await q("git", [
|
|
2788
|
+
"status",
|
|
2789
|
+
"--porcelain",
|
|
2790
|
+
"-z"
|
|
2791
|
+
]);
|
|
2792
|
+
if (exitCode !== 0 || !stdout) return [];
|
|
2793
|
+
const files = [];
|
|
2794
|
+
const entries = stdout.split("\0");
|
|
2795
|
+
for (let i = 0; i < entries.length; i++) {
|
|
2796
|
+
const entry = entries[i];
|
|
2797
|
+
if (!entry || entry.length < 4) continue;
|
|
2798
|
+
const index = entry[0];
|
|
2799
|
+
const wt = entry[1];
|
|
2800
|
+
const path = entry.slice(3);
|
|
2801
|
+
if (index === "R") i++;
|
|
2802
|
+
if (entry[0] === "?" && entry[1] === "?") files.push({
|
|
2803
|
+
path,
|
|
2804
|
+
status: "untracked"
|
|
2805
|
+
});
|
|
2806
|
+
else if (wt === "D") files.push({
|
|
2807
|
+
path,
|
|
2808
|
+
status: "deleted"
|
|
2809
|
+
});
|
|
2810
|
+
else if (wt === "M" || wt === "A") files.push({
|
|
2811
|
+
path,
|
|
2812
|
+
status: "modified"
|
|
2813
|
+
});
|
|
2814
|
+
}
|
|
2815
|
+
return files;
|
|
2816
|
+
}
|
|
2817
|
+
async function stageAll() {
|
|
2818
|
+
await q("git", ["add", "-A"], { throwOnError: true });
|
|
2819
|
+
}
|
|
2820
|
+
async function stageFiles(paths) {
|
|
2821
|
+
if (paths.length === 0) return;
|
|
2822
|
+
await q("git", [
|
|
2823
|
+
"add",
|
|
2824
|
+
"--",
|
|
2825
|
+
...paths
|
|
2826
|
+
], { throwOnError: true });
|
|
2827
|
+
}
|
|
2828
|
+
/**
|
|
2829
|
+
* Get the last N non-merge commit messages (subject + body).
|
|
2830
|
+
*/
|
|
2831
|
+
async function getRecentCommitLog(count = 10) {
|
|
2832
|
+
const { stdout, exitCode } = await q("git", [
|
|
2833
|
+
"log",
|
|
2834
|
+
`--format=%s%n%b%n---`,
|
|
2835
|
+
`-n`,
|
|
2836
|
+
String(count),
|
|
2837
|
+
"--no-merges"
|
|
2838
|
+
]);
|
|
2839
|
+
return exitCode === 0 ? stdout.trim() : null;
|
|
2840
|
+
}
|
|
2841
|
+
/**
|
|
2842
|
+
* Commit using a temp file (avoids shell escaping nightmares).
|
|
2843
|
+
*/
|
|
2844
|
+
async function commit(message) {
|
|
2845
|
+
const tmpDir = mkdtempSync(join(tmpdir(), "acai-"));
|
|
2846
|
+
const tmpPath = join(tmpDir, "commit-msg.txt");
|
|
2847
|
+
writeFileSync(tmpPath, message, "utf-8");
|
|
2848
|
+
try {
|
|
2849
|
+
await q("git", [
|
|
2850
|
+
"commit",
|
|
2851
|
+
"-F",
|
|
2852
|
+
tmpPath
|
|
2853
|
+
], { throwOnError: true });
|
|
2854
|
+
} finally {
|
|
2855
|
+
try {
|
|
2856
|
+
rmSync(tmpDir, { recursive: true });
|
|
2857
|
+
} catch {}
|
|
2858
|
+
}
|
|
2859
|
+
}
|
|
2860
|
+
|
|
2861
|
+
//#endregion
|
|
2862
|
+
//#region bin/cli.ts
|
|
2863
|
+
async function main() {
|
|
2864
|
+
const config = parseConfig();
|
|
2865
|
+
if (config.help) {
|
|
2866
|
+
printUsage();
|
|
2867
|
+
process.exit(0);
|
|
2868
|
+
}
|
|
2869
|
+
const provider = providers[config.provider];
|
|
2870
|
+
if (!provider) {
|
|
2871
|
+
const available = Object.keys(providers).join(", ");
|
|
2872
|
+
console.error(`Unknown provider "${config.provider}". Available: ${available}`);
|
|
2873
|
+
process.exit(1);
|
|
2874
|
+
}
|
|
2875
|
+
const model = config.model || provider.defaultModel;
|
|
2876
|
+
We("acai");
|
|
2877
|
+
const s = bt();
|
|
2878
|
+
try {
|
|
2879
|
+
await ensureGitRepo();
|
|
2880
|
+
} catch {
|
|
2881
|
+
Ne("Not a git repository.");
|
|
2882
|
+
process.exit(1);
|
|
2883
|
+
}
|
|
2884
|
+
try {
|
|
2885
|
+
await ensureProvider(provider);
|
|
2886
|
+
} catch (e) {
|
|
2887
|
+
Ne(e.message);
|
|
2888
|
+
process.exit(1);
|
|
2889
|
+
}
|
|
2890
|
+
let diff = await getStagedDiff();
|
|
2891
|
+
if (!diff) {
|
|
2892
|
+
const unstaged = await getUnstagedFiles();
|
|
2893
|
+
if (unstaged.length === 0) {
|
|
2894
|
+
Ne("Nothing to commit — working tree clean.");
|
|
2895
|
+
process.exit(0);
|
|
2896
|
+
}
|
|
2897
|
+
if (config.yolo) await stageAll();
|
|
2898
|
+
else {
|
|
2899
|
+
const shouldStage = await Re({
|
|
2900
|
+
message: "Stage all changes?",
|
|
2901
|
+
initialValue: true
|
|
2902
|
+
});
|
|
2903
|
+
if (Ct$1(shouldStage)) {
|
|
2904
|
+
Ne("Aborted.");
|
|
2905
|
+
process.exit(0);
|
|
2906
|
+
}
|
|
2907
|
+
if (shouldStage) await stageAll();
|
|
2908
|
+
else if (!await promptFilePicker(unstaged, "Select files to stage")) {
|
|
2909
|
+
Ne("Nothing staged.");
|
|
2910
|
+
process.exit(0);
|
|
2911
|
+
}
|
|
2912
|
+
}
|
|
2913
|
+
diff = await getStagedDiff();
|
|
2914
|
+
if (!diff) {
|
|
2915
|
+
Ne("Still no diff after staging. Nothing to commit.");
|
|
2916
|
+
process.exit(0);
|
|
2917
|
+
}
|
|
2918
|
+
}
|
|
2919
|
+
if (!config.yolo) {
|
|
2920
|
+
const remaining = await getUnstagedFiles();
|
|
2921
|
+
if (remaining.length > 0) {
|
|
2922
|
+
const addMore = await Re({
|
|
2923
|
+
message: `${remaining.length} other changed file${remaining.length === 1 ? "" : "s"} not staged. Add more?`,
|
|
2924
|
+
initialValue: false
|
|
2925
|
+
});
|
|
2926
|
+
if (Ct$1(addMore)) {
|
|
2927
|
+
Ne("Aborted.");
|
|
2928
|
+
process.exit(0);
|
|
2929
|
+
}
|
|
2930
|
+
if (addMore) {
|
|
2931
|
+
await promptFilePicker(remaining, "Select additional files to stage");
|
|
2932
|
+
diff = await getStagedDiff();
|
|
2933
|
+
}
|
|
2934
|
+
}
|
|
2935
|
+
}
|
|
2936
|
+
const stat = await getStagedStat() || "";
|
|
2937
|
+
const files = await getStagedFiles();
|
|
2938
|
+
const MAX_LISTED = 5;
|
|
2939
|
+
const listed = files.slice(0, MAX_LISTED).join(", ");
|
|
2940
|
+
const extra = files.length > MAX_LISTED ? ` and ${files.length - MAX_LISTED} more` : "";
|
|
2941
|
+
R$1.info(`Staged ${files.length} file${files.length === 1 ? "" : "s"}: ${import_picocolors.default.dim(listed + extra)}`);
|
|
2942
|
+
const commitLog = await getRecentCommitLog(10) || "";
|
|
2943
|
+
let instructions;
|
|
2944
|
+
while (true) {
|
|
2945
|
+
s.start(`Waiting for ${provider.name}`);
|
|
2946
|
+
let message;
|
|
2947
|
+
try {
|
|
2948
|
+
message = await generateCommitMessage(provider, {
|
|
2949
|
+
diff,
|
|
2950
|
+
stat,
|
|
2951
|
+
files,
|
|
2952
|
+
commitLog,
|
|
2953
|
+
model,
|
|
2954
|
+
instructions,
|
|
2955
|
+
log: config.verbose ? (msg) => R$1.message(import_picocolors.default.dim(msg)) : void 0
|
|
2956
|
+
});
|
|
2957
|
+
} catch (e) {
|
|
2958
|
+
s.stop("Failed");
|
|
2959
|
+
Ne(`Generation failed: ${e.message}`);
|
|
2960
|
+
process.exit(1);
|
|
2961
|
+
}
|
|
2962
|
+
s.stop(`Here's what ${provider.name} ${import_picocolors.default.dim(`(${model})`)} came up with:`);
|
|
2963
|
+
R$1.message(formatMessageForDisplay(message));
|
|
2964
|
+
if (config.yolo) {
|
|
2965
|
+
await doCommit(message);
|
|
2966
|
+
break;
|
|
2967
|
+
}
|
|
2968
|
+
const action = await Je({
|
|
2969
|
+
message: "What should we do?",
|
|
2970
|
+
options: [
|
|
2971
|
+
{
|
|
2972
|
+
value: "commit",
|
|
2973
|
+
label: "✓ Commit"
|
|
2974
|
+
},
|
|
2975
|
+
{
|
|
2976
|
+
value: "edit",
|
|
2977
|
+
label: "✎ Edit",
|
|
2978
|
+
hint: "open in editor and commit on save"
|
|
2979
|
+
},
|
|
2980
|
+
{
|
|
2981
|
+
value: "revise",
|
|
2982
|
+
label: "↻ Revise",
|
|
2983
|
+
hint: `give ${provider.name} feedback and try again`
|
|
2984
|
+
},
|
|
2985
|
+
{
|
|
2986
|
+
value: "copy",
|
|
2987
|
+
label: "⎘ Copy",
|
|
2988
|
+
hint: "copy message to clipboard and exit"
|
|
2989
|
+
},
|
|
2990
|
+
{
|
|
2991
|
+
value: "cancel",
|
|
2992
|
+
label: "✕ Cancel"
|
|
2993
|
+
}
|
|
2994
|
+
]
|
|
2995
|
+
});
|
|
2996
|
+
if (Ct$1(action) || action === "cancel") {
|
|
2997
|
+
Ne("Aborted.");
|
|
2998
|
+
process.exit(0);
|
|
2999
|
+
}
|
|
3000
|
+
if (action === "commit") {
|
|
3001
|
+
await doCommit(message);
|
|
3002
|
+
break;
|
|
3003
|
+
}
|
|
3004
|
+
if (action === "edit") {
|
|
3005
|
+
const edited = await editInEditor(message);
|
|
3006
|
+
if (edited?.trim()) await doCommit(edited.trim());
|
|
3007
|
+
else {
|
|
3008
|
+
R$1.warn("Empty message after editing — not committing.");
|
|
3009
|
+
continue;
|
|
3010
|
+
}
|
|
3011
|
+
break;
|
|
3012
|
+
}
|
|
3013
|
+
if (action === "copy") {
|
|
3014
|
+
await copyToClipboard(message);
|
|
3015
|
+
Le("Copied to clipboard.");
|
|
3016
|
+
process.exit(0);
|
|
3017
|
+
}
|
|
3018
|
+
if (action === "revise") {
|
|
3019
|
+
const feedback = await Ze({
|
|
3020
|
+
message: `What should ${provider.name} change?`,
|
|
3021
|
+
placeholder: "e.g. make it shorter, mention the API refactor, use past tense…"
|
|
3022
|
+
});
|
|
3023
|
+
if (Ct$1(feedback) || !feedback) continue;
|
|
3024
|
+
instructions = `The user wants you to revise the message. Previous attempt was:\n\`\`\`\n${message}\n\`\`\`\nUser feedback: ${feedback}`;
|
|
3025
|
+
}
|
|
3026
|
+
}
|
|
3027
|
+
}
|
|
3028
|
+
/**
|
|
3029
|
+
* Show a grouped multi-select file picker and stage the selected files.
|
|
3030
|
+
* Returns true if files were staged, false if cancelled/empty.
|
|
3031
|
+
*/
|
|
3032
|
+
async function promptFilePicker(files, message) {
|
|
3033
|
+
const STATUS_LABELS = {
|
|
3034
|
+
modified: "Modified",
|
|
3035
|
+
untracked: "Untracked",
|
|
3036
|
+
deleted: "Deleted"
|
|
3037
|
+
};
|
|
3038
|
+
const groups = {};
|
|
3039
|
+
for (const file of files) {
|
|
3040
|
+
const group = STATUS_LABELS[file.status];
|
|
3041
|
+
groups[group] ??= [];
|
|
3042
|
+
groups[group].push({
|
|
3043
|
+
value: file.path,
|
|
3044
|
+
label: file.path
|
|
3045
|
+
});
|
|
3046
|
+
}
|
|
3047
|
+
const selected = await Pe({
|
|
3048
|
+
message,
|
|
3049
|
+
options: groups
|
|
3050
|
+
});
|
|
3051
|
+
if (Ct$1(selected) || selected.length === 0) return false;
|
|
3052
|
+
await stageFiles(selected);
|
|
3053
|
+
return true;
|
|
3054
|
+
}
|
|
3055
|
+
async function doCommit(message) {
|
|
3056
|
+
const s = bt();
|
|
3057
|
+
s.start("Committing");
|
|
3058
|
+
try {
|
|
3059
|
+
await commit(message);
|
|
3060
|
+
s.stop("Committed!");
|
|
3061
|
+
} catch (e) {
|
|
3062
|
+
s.stop("Failed");
|
|
3063
|
+
Ne(`Commit failed: ${e.message}`);
|
|
3064
|
+
process.exit(1);
|
|
3065
|
+
}
|
|
3066
|
+
}
|
|
3067
|
+
function formatMessageForDisplay(message) {
|
|
3068
|
+
const lines = message.split("\n");
|
|
3069
|
+
const subject = lines[0];
|
|
3070
|
+
const body = lines.slice(1).join("\n").trim();
|
|
3071
|
+
let display = import_picocolors.default.bold(import_picocolors.default.green(subject));
|
|
3072
|
+
if (body) display += `\n${import_picocolors.default.dim(body)}`;
|
|
3073
|
+
return display;
|
|
3074
|
+
}
|
|
3075
|
+
async function editInEditor(message) {
|
|
3076
|
+
const { spawn } = await import("child_process");
|
|
3077
|
+
const { writeFileSync, readFileSync, mkdtempSync, rmSync } = await import("fs");
|
|
3078
|
+
const { join } = await import("path");
|
|
3079
|
+
const { tmpdir } = await import("os");
|
|
3080
|
+
const editor = process.env.EDITOR || process.env.VISUAL || "vi";
|
|
3081
|
+
const tmpDir = mkdtempSync(join(tmpdir(), "acai-"));
|
|
3082
|
+
const tmpPath = join(tmpDir, "COMMIT_EDITMSG");
|
|
3083
|
+
writeFileSync(tmpPath, message, "utf-8");
|
|
3084
|
+
try {
|
|
3085
|
+
if (await new Promise((resolve, reject) => {
|
|
3086
|
+
const proc = spawn(editor, [tmpPath], {
|
|
3087
|
+
stdio: "inherit",
|
|
3088
|
+
shell: true
|
|
3089
|
+
});
|
|
3090
|
+
proc.on("error", reject);
|
|
3091
|
+
proc.on("close", resolve);
|
|
3092
|
+
}) !== 0) return null;
|
|
3093
|
+
return readFileSync(tmpPath, "utf-8");
|
|
3094
|
+
} finally {
|
|
3095
|
+
try {
|
|
3096
|
+
rmSync(tmpDir, { recursive: true });
|
|
3097
|
+
} catch {}
|
|
3098
|
+
}
|
|
3099
|
+
}
|
|
3100
|
+
async function copyToClipboard(text) {
|
|
3101
|
+
const { spawn } = await import("child_process");
|
|
3102
|
+
for (const [bin, ...args] of [
|
|
3103
|
+
["pbcopy"],
|
|
3104
|
+
[
|
|
3105
|
+
"xclip",
|
|
3106
|
+
"-selection",
|
|
3107
|
+
"clipboard"
|
|
3108
|
+
],
|
|
3109
|
+
[
|
|
3110
|
+
"xsel",
|
|
3111
|
+
"--clipboard",
|
|
3112
|
+
"--input"
|
|
3113
|
+
],
|
|
3114
|
+
["wl-copy"]
|
|
3115
|
+
]) if (await new Promise((resolve) => {
|
|
3116
|
+
const proc = spawn(bin, args, { stdio: [
|
|
3117
|
+
"pipe",
|
|
3118
|
+
"ignore",
|
|
3119
|
+
"ignore"
|
|
3120
|
+
] });
|
|
3121
|
+
proc.on("error", () => resolve(false));
|
|
3122
|
+
proc.stdin.write(text);
|
|
3123
|
+
proc.stdin.end();
|
|
3124
|
+
proc.on("close", (code) => resolve(code === 0));
|
|
3125
|
+
})) return;
|
|
3126
|
+
R$1.warn("Couldn't copy to clipboard. Here's the raw message:");
|
|
3127
|
+
console.log(text);
|
|
3128
|
+
}
|
|
3129
|
+
main().catch((e) => {
|
|
3130
|
+
Ne(e.message);
|
|
3131
|
+
process.exit(1);
|
|
3132
|
+
});
|
|
3133
|
+
|
|
3134
|
+
//#endregion
|
|
3135
|
+
export { };
|