@visulima/cerebro 1.1.51 → 1.1.53
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/CHANGELOG.md +35 -0
- package/dist/index.cjs +1 -1
- package/dist/index.d.cts +4 -4
- package/dist/index.d.mts +5 -3
- package/dist/index.d.ts +4 -4
- package/dist/index.mjs +1 -1
- package/dist/packem_chunks/has-new-version.cjs +1 -1
- package/dist/packem_chunks/has-new-version.mjs +1 -1
- package/dist/packem_shared/default-BkkIk32s.mjs +10 -0
- package/dist/packem_shared/{default-BD7MGssY.cjs → default-DpvcDeMt.cjs} +3 -3
- package/package.json +11 -12
- package/dist/packem_shared/default-DRd7Q7Xw.mjs +0 -10
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,38 @@
|
|
|
1
|
+
## @visulima/cerebro [1.1.53](https://github.com/visulima/visulima/compare/@visulima/cerebro@1.1.52...@visulima/cerebro@1.1.53) (2025-10-15)
|
|
2
|
+
|
|
3
|
+
### Bug Fixes
|
|
4
|
+
|
|
5
|
+
* downgraded `@visulima/find-cache-dir` to version 1.0.35 ([8f21f66](https://github.com/visulima/visulima/commit/8f21f66ead00c7bc35e7c775d8a18280f8863c0b))
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
### Dependencies
|
|
9
|
+
|
|
10
|
+
* **@visulima/pail:** upgraded to 2.1.31
|
|
11
|
+
|
|
12
|
+
## @visulima/cerebro [1.1.52](https://github.com/visulima/visulima/compare/@visulima/cerebro@1.1.51...@visulima/cerebro@1.1.52) (2025-10-15)
|
|
13
|
+
|
|
14
|
+
### Bug Fixes
|
|
15
|
+
|
|
16
|
+
* update @visulima/packem to 2.0.0-alpha.29 and refine packem.config.ts settings ([63f14a1](https://github.com/visulima/visulima/commit/63f14a1c11bd7c004e76874ed0b3938ad4740da6))
|
|
17
|
+
* update @visulima/packem to 2.0.0-alpha.30 across multiple packages for improved compatibility ([27b346e](https://github.com/visulima/visulima/commit/27b346eaa1c0fb0e420d9a9824482028307f4249))
|
|
18
|
+
|
|
19
|
+
### Miscellaneous Chores
|
|
20
|
+
|
|
21
|
+
* update package dependencies across multiple packages for improved compatibility and performance ([9567591](https://github.com/visulima/visulima/commit/9567591c415da3002f3a4fe08f8caf7ce01ca5f7))
|
|
22
|
+
|
|
23
|
+
### Code Refactoring
|
|
24
|
+
|
|
25
|
+
* consolidate ESLint configuration and remove obsolete files for improved maintainability ([76d27af](https://github.com/visulima/visulima/commit/76d27afba1dd1946820dc28ae8add2aa1b0ec288))
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
### Dependencies
|
|
29
|
+
|
|
30
|
+
* **@visulima/boxen:** upgraded to 2.0.4
|
|
31
|
+
* **@visulima/colorize:** upgraded to 1.4.24
|
|
32
|
+
* **@visulima/find-cache-dir:** upgraded to 2.0.0
|
|
33
|
+
* **@visulima/pail:** upgraded to 2.1.30
|
|
34
|
+
* **@visulima/path:** upgraded to 2.0.0
|
|
35
|
+
|
|
1
36
|
## @visulima/cerebro [1.1.51](https://github.com/visulima/visulima/compare/@visulima/cerebro@1.1.50...@visulima/cerebro@1.1.51) (2025-09-23)
|
|
2
37
|
|
|
3
38
|
### Miscellaneous Chores
|
package/dist/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";const e=require("./packem_shared/default-
|
|
1
|
+
"use strict";const e=require("./packem_shared/default-DpvcDeMt.cjs");module.exports=e.Cli;
|
package/dist/index.d.cts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { OptionDefinition as OptionDefinition$1 } from 'command-line-args';
|
|
2
2
|
import { TableConstructorOptions } from 'cli-table3';
|
|
3
|
-
import { Pail
|
|
3
|
+
import { Pail } from '@visulima/pail/server';
|
|
4
|
+
import { ConstructorOptions } from '@visulima/pail';
|
|
4
5
|
|
|
5
6
|
type UpdateNotifierOptions = {
|
|
6
7
|
alwaysRun?: boolean;
|
|
@@ -89,8 +90,8 @@ interface Cli$1 {
|
|
|
89
90
|
addExtension: (extension: Extension) => this;
|
|
90
91
|
enableUpdateNotifier: ({ alwaysRun, distTag, updateCheckInterval }: Partial<Omit<UpdateNotifierOptions, "debug | pkg">>) => this;
|
|
91
92
|
getCliName: () => string;
|
|
92
|
-
getCommandSection: () => CommandSection;
|
|
93
93
|
getCommands: () => Map<string, Command>;
|
|
94
|
+
getCommandSection: () => CommandSection;
|
|
94
95
|
getCwd: () => string;
|
|
95
96
|
getPackageName: () => string | undefined;
|
|
96
97
|
getPackageVersion: () => string | undefined;
|
|
@@ -153,6 +154,5 @@ declare class Cli implements Cli$1 {
|
|
|
153
154
|
type OutputType = 1 | 2 | 4;
|
|
154
155
|
type VERBOSITY_LEVEL = 16 | 32 | 64 | 128 | 256;
|
|
155
156
|
|
|
156
|
-
export { type ArgumentDefinition, type Cli$1 as Cli, type CliOptions, type Command, type Extension, type OptionDefinition, type OutputType, type Toolbox, type VERBOSITY_LEVEL, };
|
|
157
|
-
|
|
158
157
|
export = Cli;
|
|
158
|
+
export type { ArgumentDefinition, Cli$1 as Cli, CliOptions, Command, Extension, OptionDefinition, OutputType, Toolbox, VERBOSITY_LEVEL };
|
package/dist/index.d.mts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { OptionDefinition as OptionDefinition$1 } from 'command-line-args';
|
|
2
2
|
import { TableConstructorOptions } from 'cli-table3';
|
|
3
|
-
import { Pail
|
|
3
|
+
import { Pail } from '@visulima/pail/server';
|
|
4
|
+
import { ConstructorOptions } from '@visulima/pail';
|
|
4
5
|
|
|
5
6
|
type UpdateNotifierOptions = {
|
|
6
7
|
alwaysRun?: boolean;
|
|
@@ -89,8 +90,8 @@ interface Cli$1 {
|
|
|
89
90
|
addExtension: (extension: Extension) => this;
|
|
90
91
|
enableUpdateNotifier: ({ alwaysRun, distTag, updateCheckInterval }: Partial<Omit<UpdateNotifierOptions, "debug | pkg">>) => this;
|
|
91
92
|
getCliName: () => string;
|
|
92
|
-
getCommandSection: () => CommandSection;
|
|
93
93
|
getCommands: () => Map<string, Command>;
|
|
94
|
+
getCommandSection: () => CommandSection;
|
|
94
95
|
getCwd: () => string;
|
|
95
96
|
getPackageName: () => string | undefined;
|
|
96
97
|
getPackageVersion: () => string | undefined;
|
|
@@ -153,4 +154,5 @@ declare class Cli implements Cli$1 {
|
|
|
153
154
|
type OutputType = 1 | 2 | 4;
|
|
154
155
|
type VERBOSITY_LEVEL = 16 | 32 | 64 | 128 | 256;
|
|
155
156
|
|
|
156
|
-
export {
|
|
157
|
+
export { Cli as default };
|
|
158
|
+
export type { ArgumentDefinition, Cli$1 as Cli, CliOptions, Command, Extension, OptionDefinition, OutputType, Toolbox, VERBOSITY_LEVEL };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { OptionDefinition as OptionDefinition$1 } from 'command-line-args';
|
|
2
2
|
import { TableConstructorOptions } from 'cli-table3';
|
|
3
|
-
import { Pail
|
|
3
|
+
import { Pail } from '@visulima/pail/server';
|
|
4
|
+
import { ConstructorOptions } from '@visulima/pail';
|
|
4
5
|
|
|
5
6
|
type UpdateNotifierOptions = {
|
|
6
7
|
alwaysRun?: boolean;
|
|
@@ -89,8 +90,8 @@ interface Cli$1 {
|
|
|
89
90
|
addExtension: (extension: Extension) => this;
|
|
90
91
|
enableUpdateNotifier: ({ alwaysRun, distTag, updateCheckInterval }: Partial<Omit<UpdateNotifierOptions, "debug | pkg">>) => this;
|
|
91
92
|
getCliName: () => string;
|
|
92
|
-
getCommandSection: () => CommandSection;
|
|
93
93
|
getCommands: () => Map<string, Command>;
|
|
94
|
+
getCommandSection: () => CommandSection;
|
|
94
95
|
getCwd: () => string;
|
|
95
96
|
getPackageName: () => string | undefined;
|
|
96
97
|
getPackageVersion: () => string | undefined;
|
|
@@ -153,6 +154,5 @@ declare class Cli implements Cli$1 {
|
|
|
153
154
|
type OutputType = 1 | 2 | 4;
|
|
154
155
|
type VERBOSITY_LEVEL = 16 | 32 | 64 | 128 | 256;
|
|
155
156
|
|
|
156
|
-
export { type ArgumentDefinition, type Cli$1 as Cli, type CliOptions, type Command, type Extension, type OptionDefinition, type OutputType, type Toolbox, type VERBOSITY_LEVEL, };
|
|
157
|
-
|
|
158
157
|
export = Cli;
|
|
158
|
+
export type { ArgumentDefinition, Cli$1 as Cli, CliOptions, Command, Extension, OptionDefinition, OutputType, Toolbox, VERBOSITY_LEVEL };
|
package/dist/index.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{Cli as f}from"./packem_shared/default-
|
|
1
|
+
import{Cli as f}from"./packem_shared/default-BkkIk32s.mjs";export{f as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var kt=Object.defineProperty;var A=(n,o)=>kt(n,"name",{value:o,configurable:!0});Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const S=require("node:fs"),Mt=require("@visulima/find-cache-dir"),At=require("node:https");var zt=Object.defineProperty,Pt=A((n,o)=>zt(n,"name",{value:o,configurable:!0}),"o$1");const St=Pt((n,o)=>{const i=n.split(".").map(Number),u=o.split(".").map(Number);for(const[d,h]of i.entries()){if(h>u[d])return!0;if(h<u[d])return!1}return!1},"semverGt");var Ct=Object.defineProperty,B=A((n,o)=>Ct(n,"name",{value:o,configurable:!0}),"I"),Et=Object.defineProperty,c=B((n,o)=>Et(n,"name",{value:o,configurable:!0}),"__name$2");let ue=c(()=>{var n=(()=>{var o=Object.defineProperty,i=Object.getOwnPropertyDescriptor,u=Object.getOwnPropertyNames,d=Object.prototype.hasOwnProperty,h=c((e,t)=>{for(var r in t)o(e,r,{get:t[r],enumerable:!0})},"J"),x=c((e,t,r,a)=>{if(t&&typeof t=="object"||typeof t=="function")for(let s of u(t))!d.call(e,s)&&s!==r&&o(e,s,{get:c(()=>t[s],"get"),enumerable:!(a=i(t,s))||a.enumerable});return e},"T"),g=c(e=>x(o({},"__esModule",{value:!0}),e),"W"),y={};h(y,{zeptomatch:c(()=>bt,"zeptomatch")});var F=c(e=>Array.isArray(e),"k"),z=c(e=>typeof e=="function","x"),ge=c(e=>e.length===0,"K"),me=(()=>{const{toString:e}=Function.prototype,t=/(?:^\(\s*(?:[^,.()]|\.(?!\.\.))*\s*\)\s*=>|^\s*[a-zA-Z$_][a-zA-Z0-9$_]*\s*=>)/;return r=>(r.length===0||r.length===1)&&t.test(e.call(r))})(),xe=c(e=>typeof e=="number","Y"),ve=c(e=>typeof e=="object"&&e!==null,"rr"),$e=c(e=>e instanceof RegExp,"er"),ye=(()=>{const e=/\\\(|\((?!\?(?::|=|!|<=|<!))/;return t=>e.test(t.source)})(),be=(()=>{const e=/^[a-zA-Z0-9_-]+$/;return t=>e.test(t.source)&&!t.flags.includes("i")})(),T=c(e=>typeof e=="string","M"),O=c(e=>e===void 0,"f"),we=c(e=>{const t=new Map;return r=>{const a=t.get(r);if(a!==void 0)return a;const s=e(r);return t.set(r,s),s}},"ar"),je=c((e,t,r={})=>{const a={cache:{},input:e,index:0,indexBacktrackMax:0,options:r,output:[]},s=_(t)(a),f=Math.max(a.index,a.indexBacktrackMax);if(s&&a.index===e.length)return a.output;throw new Error(`Failed to parse at index ${f}`)},"or"),l=c((e,t)=>F(e)?Oe(e,t):T(e)?J(e,t):_e(e,t),"o"),Oe=c((e,t)=>{const r={};for(const a of e){if(a.length!==1)throw new Error(`Invalid character: "${a}"`);const s=a.charCodeAt(0);r[s]=!0}return a=>{const s=a.input;let f=a.index,p=f;for(;p<s.length&&s.charCodeAt(p)in r;)p+=1;if(p>f){if(!O(t)&&!a.options.silent){const m=s.slice(f,p),$=z(t)?t(m,s,`${f}`):t;O($)||a.output.push($)}a.index=p}return!0}},"ir"),_e=c((e,t)=>{if(be(e))return J(e.source,t);{const r=e.source,a=e.flags.replace(/y|$/,"y"),s=new RegExp(r,a);return ye(e)&&z(t)&&!me(t)?ke(s,t):Me(s,t)}},"ur"),ke=c((e,t)=>r=>{const a=r.index,s=r.input;e.lastIndex=a;const f=e.exec(s);if(f){const p=e.lastIndex;if(!r.options.silent){const m=t(...f,s,`${a}`);O(m)||r.output.push(m)}return r.index=p,!0}else return!1},"sr"),Me=c((e,t)=>r=>{const a=r.index,s=r.input;if(e.lastIndex=a,e.test(s)){const f=e.lastIndex;if(!O(t)&&!r.options.silent){const p=z(t)?t(s.slice(a,f),s,`${a}`):t;O(p)||r.output.push(p)}return r.index=f,!0}else return!1},"cr"),J=c((e,t)=>r=>{const a=r.index,s=r.input;if(s.startsWith(e,a)){if(!O(t)&&!r.options.silent){const f=z(t)?t(e,s,`${a}`):t;O(f)||r.output.push(f)}return r.index+=e.length,!0}else return!1},"R"),G=c((e,t,r,a)=>{const s=_(e),f=t>1;return Z(I(V(p=>{let m=0;for(;m<r;){const $=p.index;if(!s(p)||(m+=1,p.index===$))break}return m>=t},f),a))},"O"),Ae=c((e,t)=>G(e,0,1,t),"lr"),E=c((e,t)=>G(e,0,1/0,t),"m"),N=c((e,t)=>{const r=e.map(_);return Z(I(V(a=>{for(let s=0,f=r.length;s<f;s++)if(!r[s](a))return!1;return!0}),t))},"_"),w=c((e,t)=>{const r=e.map(_);return Z(I(a=>{for(let s=0,f=r.length;s<f;s++)if(r[s](a))return!0;return!1},t))},"p"),V=c((e,t=!0,r=!1)=>{const a=_(e);return t?s=>{const f=s.index,p=s.output.length,m=a(s);return!m&&!r&&(s.indexBacktrackMax=Math.max(s.indexBacktrackMax,s.index)),(!m||r)&&(s.index=f,s.output.length!==p&&(s.output.length=p)),m}:a},"P"),I=c((e,t)=>{const r=_(e);return t?a=>{if(a.options.silent)return r(a);const s=a.output.length;if(r(a)){const f=a.output.splice(s,1/0),p=t(f);return O(p)||a.output.push(p),!0}else return!1}:r},"C"),Z=(()=>{let e=0;return t=>{const r=_(t),a=e+=1;return s=>{var f;if(s.options.memoization===!1)return r(s);const p=s.index,m=(f=s.cache)[a]||(f[a]={indexMax:-1,queue:[]}),$=m.queue;if(p<=m.indexMax){const P=m.store||(m.store=new Map);if($.length){for(let M=0,jt=$.length;M<jt;M+=2){const Ot=$[M*2],_t=$[M*2+1];P.set(Ot,_t)}$.length=0}const b=P.get(p);if(b===!1)return!1;if(xe(b))return s.index=b,!0;if(b)return s.index=b.index,b.output?.length&&s.output.push(...b.output),!0}const ae=s.output.length,wt=r(s);if(m.indexMax=Math.max(m.indexMax,p),wt){const P=s.index,b=s.output.length;if(b>ae){const M=s.output.slice(ae,b);$.push(p,{index:P,output:M})}else $.push(p,P);return!0}else return $.push(p,!1),!1}}})(),K=c(e=>{let t;return r=>(t||(t=_(e())),t(r))},"A"),_=we(e=>{if(z(e))return ge(e)?K(e):e;if(T(e)||$e(e))return l(e);if(F(e))return N(e);if(ve(e))return w(Object.values(e));throw new Error("Invalid rule")}),j=c(e=>e,"v"),Y=c(e=>t=>je(t,e,{memoization:!1}).join(""),"z"),ze=c(e=>{const t={};return r=>t[r]??(t[r]=e(r))},"pr"),H="abcdefghijklmnopqrstuvwxyz",Pe=c(e=>{let t="";for(;e>0;){const r=(e-1)%26;t=H[r]+t,e=Math.floor((e-1)/26)}return t},"vr"),Q=c(e=>{let t=0;for(let r=0,a=e.length;r<a;r++)t=t*26+H.indexOf(e[r])+1;return t},"N"),D=c((e,t)=>{if(t<e)return D(t,e);const r=[];for(;e<=t;)r.push(e++);return r},"$"),Se=c((e,t,r)=>D(e,t).map(a=>String(a).padStart(r,"0")),"fr"),X=c((e,t)=>D(Q(e),Q(t)).map(Pe),"j"),L=l(/\\./,j),Ce=l(/[$.*+?^(){}[\]\|]/,e=>`\\${e}`),Ee=l(/./,j),Ne=l(/^(?:!!)*!(.*)$/,(e,t)=>`(?!^${ie(t)}$).*?`),Ue=l(/^(!!)+/,""),Ie=w([Ne,Ue]),Ze=l(/\/(\*\*\/)+/,"(?:[\\\\/].+[\\\\/]|[\\\\/])"),De=l(/^(\*\*\/)+/,"(?:^|.*[\\\\/])"),Le=l(/\/(\*\*)$/,"(?:[\\\\/].*|$)"),Re=l(/\*\*/,".*"),ee=w([Ze,De,Le,Re]),qe=l(/\*\/(?!\*\*\/|\*$)/,"[^\\\\/]*[\\\\/]"),Be=l(/\*/,"[^\\\\/]*"),te=w([qe,Be]),ne=l("?","[^\\\\/]"),We=l("[",j),Fe=l("]",j),Te=l(/[!^]/,"^\\\\/"),Je=l(/[a-z]-[a-z]|[0-9]-[0-9]/i,j),Ge=l(/[$.*+?^(){}[\|]/,e=>`\\${e}`),Ve=l(/[^\]]/,j),Ke=w([L,Ge,Je,Ve]),re=N([We,Ae(Te),E(Ke),Fe]),Ye=l("{","(?:"),He=l("}",")"),Qe=l(/(\d+)\.\.(\d+)/,(e,t,r)=>Se(+t,+r,Math.min(t.length,r.length)).join("|")),Xe=l(/([a-z]+)\.\.([a-z]+)/,(e,t,r)=>X(t,r).join("|")),et=l(/([A-Z]+)\.\.([A-Z]+)/,(e,t,r)=>X(t.toLowerCase(),r.toLowerCase()).join("|").toUpperCase()),tt=w([Qe,Xe,et]),oe=N([Ye,tt,He]),nt=l("{","(?:"),rt=l("}",")"),ot=l(",","|"),st=l(/[$.*+?^(){[\]\|]/,e=>`\\${e}`),it=l(/[^}]/,j),at=K(()=>se),ut=w([ee,te,ne,re,oe,at,L,st,ot,it]),se=N([nt,E(ut),rt]),ct=E(w([Ie,ee,te,ne,re,oe,se,L,Ce,Ee])),lt=ct,ft=Y(lt),ie=ft,pt=l(/\\./,j),dt=l(/./,j),ht=l(/\*\*\*+/,"*"),gt=l(/([^/{[(!])\*\*/,(e,t)=>`${t}*`),mt=l(/(^|.)\*\*(?=[^*/)\]}])/,(e,t)=>`${t}*`),xt=E(w([pt,ht,gt,mt,dt])),vt=xt,$t=Y(vt),yt=$t,U=c((e,t)=>Array.isArray(e)?e.map(U.compile).some(r=>r.test(t)):U.compile(e).test(t),"S");U.compile=ze(e=>new RegExp(`^${ie(yt(e))}[\\\\/]?$`,"s"));var bt=U;return g(y)})();return n.default||n},"_lazyMatch"),R;const Nt=c((n,o)=>(R||(R=ue(),ue=null),R(n,o)),"default");var Ut=Object.defineProperty,It=B((n,o)=>Ut(n,"name",{value:o,configurable:!0}),"__name$1");const Zt=/^[A-Z]:\//i,k=It((n="")=>n&&n.replaceAll("\\","/").replace(Zt,o=>o.toUpperCase()),"normalizeWindowsPath");var Dt=Object.defineProperty,v=B((n,o)=>Dt(n,"name",{value:o,configurable:!0}),"__name");const Lt=/^[/\\]{2}/,Rt=/^[/\\](?![/\\])|^[/\\]{2}(?!\.)|^[A-Z]:[/\\]/i,le=/^[A-Z]:$/i,ce=/^\/([A-Z]:)?$/i,qt=/.(\.[^./]+)$/,Bt=/^[/\\]|^[a-z]:[/\\]/i,Wt=v(()=>typeof process.cwd=="function"?process.cwd().replaceAll("\\","/"):"/","cwd"),fe=v((n,o)=>{let i="",u=0,d=-1,h=0,x=null;for(let g=0;g<=n.length;++g){if(g<n.length)x=n[g];else{if(x==="/")break;x="/"}if(x==="/"){if(!(d===g-1||h===1))if(h===2){if(i.length<2||u!==2||!i.endsWith(".")||i.at(-2)!=="."){if(i.length>2){const y=i.lastIndexOf("/");y===-1?(i="",u=0):(i=i.slice(0,y),u=i.length-1-i.lastIndexOf("/")),d=g,h=0;continue}else if(i.length>0){i="",u=0,d=g,h=0;continue}}o&&(i+=i.length>0?"/..":"..",u=2)}else i.length>0?i+=`/${n.slice(d+1,g)}`:i=n.slice(d+1,g),u=g-d-1;d=g,h=0}else x==="."&&h!==-1?++h:h=-1}return i},"normalizeString"),C=v(n=>Rt.test(n),"isAbsolute"),pe=v(function(n){if(n.length===0)return".";n=k(n);const o=Lt.exec(n),i=C(n),u=n.at(-1)==="/";return n=fe(n,!i),n.length===0?i?"/":u?"./":".":(u&&(n+="/"),le.test(n)&&(n+="/"),o?i?`//${n}`:`//./${n}`:i&&!C(n)?`/${n}`:n)},"normalize"),Ft=v((...n)=>{let o="";for(const i of n)if(i)if(o.length>0){const u=o[o.length-1]==="/",d=i[0]==="/";u&&d?o+=i.slice(1):o+=u||d?i:`/${i}`}else o+=i;return pe(o)},"join"),q=v(function(...n){n=n.map(u=>k(u));let o="",i=!1;for(let u=n.length-1;u>=-1&&!i;u--){const d=u>=0?n[u]:Wt();!d||d.length===0||(o=`${d}/${o}`,i=C(d))}return o=fe(o,!i),i&&!C(o)?`/${o}`:o.length>0?o:"."},"resolve");v(function(n){return k(n)},"toNamespacedPath");const Tt=v(function(n){return qt.exec(k(n))?.[1]??""},"extname");v(function(n,o){const i=q(n).replace(ce,"$1").split("/"),u=q(o).replace(ce,"$1").split("/");if(u[0][1]===":"&&i[0][1]===":"&&i[0]!==u[0])return u.join("/");const d=[...i];for(const h of d){if(u[0]!==h)break;i.shift(),u.shift()}return[...i.map(()=>".."),...u].join("/")},"relative");const de=v(n=>{const o=k(n).replace(/\/$/,"").split("/").slice(0,-1);return o.length===1&&le.test(o[0])&&(o[0]+="/"),o.join("/")||(C(n)?"/":".")},"dirname");v(function(n){const o=[n.root,n.dir,n.base??n.name+n.ext].filter(Boolean);return k(n.root?q(...o):o.join("/"))},"format");const Jt=v((n,o)=>{const i=k(n).split("/").pop();return o&&i.endsWith(o)?i.slice(0,-o.length):i},"basename");v(function(n){const o=Bt.exec(n)?.[0]?.replace(/\\/g,"/")??"",i=Jt(n),u=Tt(i);return{base:i,dir:de(n),ext:u,name:i.slice(0,i.length-u.length),root:o}},"parse");v((n,o)=>Nt(o,pe(n)),"matchesGlob");var Gt=Object.defineProperty,W=A((n,o)=>Gt(n,"name",{value:o,configurable:!0}),"r");const Vt="last-update-check.json",he=W(n=>{const o=Mt.findCacheDirSync(n);if(o===void 0)throw new Error("Could not find cache directory");return Ft(o,Vt)},"getConfigFile"),Kt=W(n=>{const o=he(n);try{if(!S.existsSync(o))return;const{lastUpdateCheck:i}=JSON.parse(S.readFileSync(o,"utf8"));return i}catch{return}},"getLastUpdate"),Yt=W(n=>{const o=he(n),i=de(o);S.existsSync(i)||S.mkdirSync(i,{recursive:!0}),S.writeFileSync(o,JSON.stringify({lastUpdateCheck:Date.now()}))},"saveLastUpdate");var Ht=Object.defineProperty,Qt=A((n,o)=>Ht(n,"name",{value:o,configurable:!0}),"g");const Xt=Qt(async(n,o,i)=>{const u=i.replace("__NAME__",n);return await new Promise((d,h)=>{At.get(u,x=>{let g="";x.on("data",y=>g+=y),x.on("end",()=>{try{const y=JSON.parse(g)[o];y||h(new Error("Error getting version")),d(y)}catch{h(new Error("Could not parse version response"))}})}).on("error",x=>h(x))})},"getDistributionVersion");var en=Object.defineProperty,tn=A((n,o)=>en(n,"name",{value:o,configurable:!0}),"i");const nn=tn(async({alwaysRun:n,debug:o,distTag:i="latest",pkg:u,registryUrl:d="https://registry.npmjs.org/-/package/__NAME__/dist-tags",updateCheckInterval:h=1e3*60*60*24})=>{const x=Kt(u.name);if(n||!x||x<Date.now()-h){const g=await Xt(u.name,i,d);if(Yt(u.name),St(g,u.version))return g;o&&console.error(`Latest version (${g}) not newer than current version (${u.version})`)}else o&&console.error(`Too recent to check for a new update. simpleUpdateNotifier() interval set to ${h}ms but only ${Date.now()-x}ms since last check.`);return null},"hasNewVersion");exports.default=nn;
|
|
1
|
+
"use strict";var Mt=Object.defineProperty;var z=(n,r)=>Mt(n,"name",{value:r,configurable:!0});Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const C=require("node:fs"),zt=require("@visulima/find-cache-dir"),Pt=require("node:https");var _t=Object.defineProperty,Ct=z((n,r)=>_t(n,"name",{value:r,configurable:!0}),"o$1");const St=Ct((n,r)=>{const i=n.split(".").map(Number),u=r.split(".").map(Number);for(const[d,h]of i.entries()){if(h>u[d])return!0;if(h<u[d])return!1}return!1},"semverGt");var Et=Object.defineProperty,Nt=z((n,r)=>Et(n,"name",{value:r,configurable:!0}),"ce"),Ut=Object.defineProperty,F=Nt((n,r)=>Ut(n,"name",{value:r,configurable:!0}),"C"),It=Object.defineProperty,c=F((n,r)=>It(n,"name",{value:r,configurable:!0}),"u$1");let ue=c(()=>{var n=(()=>{var r=Object.defineProperty,i=Object.getOwnPropertyDescriptor,u=Object.getOwnPropertyNames,d=Object.prototype.hasOwnProperty,h=c((e,t)=>{for(var o in t)r(e,o,{get:t[o],enumerable:!0})},"J"),x=c((e,t,o,a)=>{if(t&&typeof t=="object"||typeof t=="function")for(let s of u(t))!d.call(e,s)&&s!==o&&r(e,s,{get:c(()=>t[s],"get"),enumerable:!(a=i(t,s))||a.enumerable});return e},"T"),g=c(e=>x(r({},"__esModule",{value:!0}),e),"W"),y={};h(y,{zeptomatch:c(()=>wt,"zeptomatch")});var W=c(e=>Array.isArray(e),"k"),P=c(e=>typeof e=="function","x"),ge=c(e=>e.length===0,"K"),me=(()=>{const{toString:e}=Function.prototype,t=/(?:^\(\s*(?:[^,.()]|\.(?!\.\.))*\s*\)\s*=>|^\s*[a-zA-Z$_][a-zA-Z0-9$_]*\s*=>)/;return o=>(o.length===0||o.length===1)&&t.test(e.call(o))})(),xe=c(e=>typeof e=="number","Y"),ve=c(e=>typeof e=="object"&&e!==null,"rr"),$e=c(e=>e instanceof RegExp,"er"),ye=(()=>{const e=/\\\(|\((?!\?(?::|=|!|<=|<!))/;return t=>e.test(t.source)})(),be=(()=>{const e=/^[a-zA-Z0-9_-]+$/;return t=>e.test(t.source)&&!t.flags.includes("i")})(),T=c(e=>typeof e=="string","M"),O=c(e=>e===void 0,"f"),we=c(e=>{const t=new Map;return o=>{const a=t.get(o);if(a!==void 0)return a;const s=e(o);return t.set(o,s),s}},"ar"),je=c((e,t,o={})=>{const a={cache:{},input:e,index:0,indexBacktrackMax:0,options:o,output:[]},s=k(t)(a),f=Math.max(a.index,a.indexBacktrackMax);if(s&&a.index===e.length)return a.output;throw new Error(`Failed to parse at index ${f}`)},"or"),l=c((e,t)=>W(e)?Oe(e,t):T(e)?J(e,t):ke(e,t),"o"),Oe=c((e,t)=>{const o={};for(const a of e){if(a.length!==1)throw new Error(`Invalid character: "${a}"`);const s=a.charCodeAt(0);o[s]=!0}return a=>{const s=a.input;let f=a.index,p=f;for(;p<s.length&&s.charCodeAt(p)in o;)p+=1;if(p>f){if(!O(t)&&!a.options.silent){const m=s.slice(f,p),$=P(t)?t(m,s,`${f}`):t;O($)||a.output.push($)}a.index=p}return!0}},"ir"),ke=c((e,t)=>{if(be(e))return J(e.source,t);{const o=e.source,a=e.flags.replace(/y|$/,"y"),s=new RegExp(o,a);return ye(e)&&P(t)&&!me(t)?Ae(s,t):Me(s,t)}},"ur"),Ae=c((e,t)=>o=>{const a=o.index,s=o.input;e.lastIndex=a;const f=e.exec(s);if(f){const p=e.lastIndex;if(!o.options.silent){const m=t(...f,s,`${a}`);O(m)||o.output.push(m)}return o.index=p,!0}else return!1},"sr"),Me=c((e,t)=>o=>{const a=o.index,s=o.input;if(e.lastIndex=a,e.test(s)){const f=e.lastIndex;if(!O(t)&&!o.options.silent){const p=P(t)?t(s.slice(a,f),s,`${a}`):t;O(p)||o.output.push(p)}return o.index=f,!0}else return!1},"cr"),J=c((e,t)=>o=>{const a=o.index,s=o.input;if(s.startsWith(e,a)){if(!O(t)&&!o.options.silent){const f=P(t)?t(e,s,`${a}`):t;O(f)||o.output.push(f)}return o.index+=e.length,!0}else return!1},"R"),G=c((e,t,o,a)=>{const s=k(e),f=t>1;return Z(I(V(p=>{let m=0;for(;m<o;){const $=p.index;if(!s(p)||(m+=1,p.index===$))break}return m>=t},f),a))},"O"),ze=c((e,t)=>G(e,0,1,t),"lr"),E=c((e,t)=>G(e,0,1/0,t),"m"),N=c((e,t)=>{const o=e.map(k);return Z(I(V(a=>{for(let s=0,f=o.length;s<f;s++)if(!o[s](a))return!1;return!0}),t))},"S"),w=c((e,t)=>{const o=e.map(k);return Z(I(a=>{for(let s=0,f=o.length;s<f;s++)if(o[s](a))return!0;return!1},t))},"p"),V=c((e,t=!0,o=!1)=>{const a=k(e);return t?s=>{const f=s.index,p=s.output.length,m=a(s);return!m&&!o&&(s.indexBacktrackMax=Math.max(s.indexBacktrackMax,s.index)),(!m||o)&&(s.index=f,s.output.length!==p&&(s.output.length=p)),m}:a},"P"),I=c((e,t)=>{const o=k(e);return t?a=>{if(a.options.silent)return o(a);const s=a.output.length;if(o(a)){const f=a.output.splice(s,1/0),p=t(f);return O(p)||a.output.push(p),!0}else return!1}:o},"C"),Z=(()=>{let e=0;return t=>{const o=k(t),a=e+=1;return s=>{var f;if(s.options.memoization===!1)return o(s);const p=s.index,m=(f=s.cache)[a]||(f[a]={indexMax:-1,queue:[]}),$=m.queue;if(p<=m.indexMax){const _=m.store||(m.store=new Map);if($.length){for(let M=0,Ot=$.length;M<Ot;M+=2){const kt=$[M*2],At=$[M*2+1];_.set(kt,At)}$.length=0}const b=_.get(p);if(b===!1)return!1;if(xe(b))return s.index=b,!0;if(b)return s.index=b.index,b.output?.length&&s.output.push(...b.output),!0}const ae=s.output.length,jt=o(s);if(m.indexMax=Math.max(m.indexMax,p),jt){const _=s.index,b=s.output.length;if(b>ae){const M=s.output.slice(ae,b);$.push(p,{index:_,output:M})}else $.push(p,_);return!0}else return $.push(p,!1),!1}}})(),K=c(e=>{let t;return o=>(t||(t=k(e())),t(o))},"A"),k=we(e=>{if(P(e))return ge(e)?K(e):e;if(T(e)||$e(e))return l(e);if(W(e))return N(e);if(ve(e))return w(Object.values(e));throw new Error("Invalid rule")}),j=c(e=>e,"v"),Y=c(e=>t=>je(t,e,{memoization:!1}).join(""),"z"),Pe=c(e=>{const t={};return o=>t[o]??(t[o]=e(o))},"pr"),H="abcdefghijklmnopqrstuvwxyz",_e=c(e=>{let t="";for(;e>0;){const o=(e-1)%26;t=H[o]+t,e=Math.floor((e-1)/26)}return t},"vr"),Q=c(e=>{let t=0;for(let o=0,a=e.length;o<a;o++)t=t*26+H.indexOf(e[o])+1;return t},"N"),D=c((e,t)=>{if(t<e)return D(t,e);const o=[];for(;e<=t;)o.push(e++);return o},"$"),Ce=c((e,t,o)=>D(e,t).map(a=>String(a).padStart(o,"0")),"fr"),X=c((e,t)=>D(Q(e),Q(t)).map(_e),"j"),L=l(/\\./,j),Se=l(/[$.*+?^(){}[\]\|]/,e=>`\\${e}`),Ee=l(/[\\/]/,"[\\\\/]"),Ne=l(/./,j),Ue=l(/^(?:!!)*!(.*)$/,(e,t)=>`(?!^${ie(t)}$).*?`),Ie=l(/^(!!)+/,""),Ze=w([Ue,Ie]),De=l(/\/(\*\*\/)+/,"(?:[\\\\/].+[\\\\/]|[\\\\/])"),Le=l(/^(\*\*\/)+/,"(?:^|.*[\\\\/])"),qe=l(/\/(\*\*)$/,"(?:[\\\\/].*|$)"),Be=l(/\*\*/,".*"),ee=w([De,Le,qe,Be]),Fe=l(/\*\/(?!\*\*\/|\*$)/,"[^\\\\/]*[\\\\/]"),Re=l(/\*/,"[^\\\\/]*"),te=w([Fe,Re]),ne=l("?","[^\\\\/]"),We=l("[",j),Te=l("]",j),Je=l(/[!^]/,"^\\\\/"),Ge=l(/[a-z]-[a-z]|[0-9]-[0-9]/i,j),Ve=l(/[$.*+?^(){}[\|]/,e=>`\\${e}`),Ke=l(/[^\]]/,j),Ye=w([L,Ve,Ge,Ke]),re=N([We,ze(Je),E(Ye),Te]),He=l("{","(?:"),Qe=l("}",")"),Xe=l(/(\d+)\.\.(\d+)/,(e,t,o)=>Ce(+t,+o,Math.min(t.length,o.length)).join("|")),et=l(/([a-z]+)\.\.([a-z]+)/,(e,t,o)=>X(t,o).join("|")),tt=l(/([A-Z]+)\.\.([A-Z]+)/,(e,t,o)=>X(t.toLowerCase(),o.toLowerCase()).join("|").toUpperCase()),nt=w([Xe,et,tt]),oe=N([He,nt,Qe]),rt=l("{","(?:"),ot=l("}",")"),st=l(",","|"),it=l(/[$.*+?^(){[\]\|]/,e=>`\\${e}`),at=l(/[^}]/,j),ut=K(()=>se),ct=w([ee,te,ne,re,oe,ut,L,it,st,at]),se=N([rt,E(ct),ot]),lt=E(w([Ze,ee,te,ne,re,oe,se,L,Se,Ee,Ne])),ft=lt,pt=Y(ft),ie=pt,dt=l(/\\./,j),ht=l(/./,j),gt=l(/\*\*\*+/,"*"),mt=l(/([^/{[(!])\*\*/,(e,t)=>`${t}*`),xt=l(/(^|.)\*\*(?=[^*/)\]}])/,(e,t)=>`${t}*`),vt=E(w([dt,gt,mt,xt,ht])),$t=vt,yt=Y($t),bt=yt,U=c((e,t)=>Array.isArray(e)?e.map(U.compile).some(o=>o.test(t)):U.compile(e).test(t),"_");U.compile=Pe(e=>new RegExp(`^${ie(bt(e))}[\\\\/]?$`,"s"));var wt=U;return g(y)})();return n.default||n},"_lazyMatch"),q;const Zt=c((n,r)=>(q||(q=ue(),ue=null),q(n,r)),"default");var Dt=Object.defineProperty,Lt=F((n,r)=>Dt(n,"name",{value:r,configurable:!0}),"t");const qt=/^[A-Z]:\//i,A=Lt((n="")=>n&&n.replaceAll("\\","/").replace(qt,r=>r.toUpperCase()),"normalizeWindowsPath");var Bt=Object.defineProperty,v=F((n,r)=>Bt(n,"name",{value:r,configurable:!0}),"r");const Ft=/^[/\\]{2}/,Rt=/^[/\\](?![/\\])|^[/\\]{2}(?!\.)|^[A-Z]:[/\\]/i,le=/^[A-Z]:$/i,ce=/^\/([A-Z]:)?$/i,Wt=/.(\.[^./]+)$/,Tt=/^[/\\]|^[a-z]:[/\\]/i,Jt=v(()=>typeof process.cwd=="function"?process.cwd().replaceAll("\\","/"):"/","cwd"),fe=v((n,r)=>{let i="",u=0,d=-1,h=0,x;for(let g=0;g<=n.length;++g){if(g<n.length)x=n[g];else{if(x==="/")break;x="/"}if(x==="/"){if(!(d===g-1||h===1))if(h===2){if(i.length<2||u!==2||!i.endsWith(".")||i.at(-2)!=="."){if(i.length>2){const y=i.lastIndexOf("/");y===-1?(i="",u=0):(i=i.slice(0,y),u=i.length-1-i.lastIndexOf("/")),d=g,h=0;continue}else if(i.length>0){i="",u=0,d=g,h=0;continue}}r&&(i+=i.length>0?"/..":"..",u=2)}else i.length>0?i+=`/${n.slice(d+1,g)}`:i=n.slice(d+1,g),u=g-d-1;d=g,h=0}else x==="."&&h!==-1?++h:h=-1}return i},"normalizeString"),S=v(n=>Rt.test(n),"isAbsolute"),pe=v(function(n){if(n.length===0)return".";n=A(n);const r=Ft.exec(n),i=S(n),u=n.at(-1)==="/";return n=fe(n,!i),n.length===0?i?"/":u?"./":".":(u&&(n+="/"),le.test(n)&&(n+="/"),r?i?`//${n}`:`//./${n}`:i&&!S(n)?`/${n}`:n)},"normalize"),Gt=v((...n)=>{let r="";for(const i of n)if(i)if(r.length>0){const u=r[r.length-1]==="/",d=i[0]==="/";u&&d?r+=i.slice(1):r+=u||d?i:`/${i}`}else r+=i;return pe(r)},"join"),B=v(function(...n){n=n.map(u=>A(u));let r="",i=!1;for(let u=n.length-1;u>=-1&&!i;u--){const d=u>=0?n[u]:Jt();!d||d.length===0||(r=`${d}/${r}`,i=S(d))}return r=fe(r,!i),i&&!S(r)?`/${r}`:r.length>0?r:"."},"resolve");v(function(n){return A(n)},"toNamespacedPath");const Vt=v(function(n){return Wt.exec(A(n))?.[1]??""},"extname");v(function(n,r){const i=B(n).replace(ce,"$1").split("/"),u=B(r).replace(ce,"$1").split("/");if(u[0][1]===":"&&i[0][1]===":"&&i[0]!==u[0])return u.join("/");const d=[...i];for(const h of d){if(u[0]!==h)break;i.shift(),u.shift()}return[...i.map(()=>".."),...u].join("/")},"relative");const de=v(n=>{const r=A(n).replace(/\/$/,"").split("/").slice(0,-1);return r.length===1&&le.test(r[0])&&(r[0]+="/"),r.join("/")||(S(n)?"/":".")},"dirname");v(function(n){const r=[n.root,n.dir,n.base??n.name+n.ext].filter(Boolean);return A(n.root?B(...r):r.join("/"))},"format");const Kt=v((n,r)=>{const i=A(n).split("/").pop();return r&&i.endsWith(r)?i.slice(0,-r.length):i},"basename");v(function(n){const r=Tt.exec(n)?.[0]?.replaceAll("\\","/")??"",i=Kt(n),u=Vt(i);return{base:i,dir:de(n),ext:u,name:i.slice(0,i.length-u.length),root:r}},"parse");v((n,r)=>Zt(r,pe(n)),"matchesGlob");var Yt=Object.defineProperty,R=z((n,r)=>Yt(n,"name",{value:r,configurable:!0}),"r");const Ht="last-update-check.json",he=R(n=>{const r=zt.findCacheDirSync(n);if(r===void 0)throw new Error("Could not find cache directory");return Gt(r,Ht)},"getConfigFile"),Qt=R(n=>{const r=he(n);try{if(!C.existsSync(r))return;const{lastUpdateCheck:i}=JSON.parse(C.readFileSync(r,"utf8"));return i}catch{return}},"getLastUpdate"),Xt=R(n=>{const r=he(n),i=de(r);C.existsSync(i)||C.mkdirSync(i,{recursive:!0}),C.writeFileSync(r,JSON.stringify({lastUpdateCheck:Date.now()}))},"saveLastUpdate");var en=Object.defineProperty,tn=z((n,r)=>en(n,"name",{value:r,configurable:!0}),"g");const nn=tn(async(n,r,i)=>{const u=i.replace("__NAME__",n);return await new Promise((d,h)=>{Pt.get(u,x=>{let g="";x.on("data",y=>g+=y),x.on("end",()=>{try{const y=JSON.parse(g)[r];y||h(new Error("Error getting version")),d(y)}catch{h(new Error("Could not parse version response"))}})}).on("error",x=>h(x))})},"getDistributionVersion");var rn=Object.defineProperty,on=z((n,r)=>rn(n,"name",{value:r,configurable:!0}),"i");const sn=on(async({alwaysRun:n,debug:r,distTag:i="latest",pkg:u,registryUrl:d="https://registry.npmjs.org/-/package/__NAME__/dist-tags",updateCheckInterval:h=1e3*60*60*24})=>{const x=Qt(u.name);if(n||!x||x<Date.now()-h){const g=await nn(u.name,i,d);if(Xt(u.name),St(g,u.version))return g;r&&console.error(`Latest version (${g}) not newer than current version (${u.version})`)}else r&&console.error(`Too recent to check for a new update. simpleUpdateNotifier() interval set to ${h}ms but only ${Date.now()-x}ms since last check.`);return null},"hasNewVersion");exports.default=sn;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
var At=Object.defineProperty;var _=(n,o)=>At(n,"name",{value:o,configurable:!0});import{existsSync as ce,mkdirSync as Mt,writeFileSync as _t,readFileSync as zt}from"node:fs";import{findCacheDirSync as Pt}from"@visulima/find-cache-dir";import{get as Ct}from"node:https";var St=Object.defineProperty,Et=_((n,o)=>St(n,"name",{value:o,configurable:!0}),"o$1");const Nt=Et((n,o)=>{const i=n.split(".").map(Number),u=o.split(".").map(Number);for(const[d,h]of i.entries()){if(h>u[d])return!0;if(h<u[d])return!1}return!1},"semverGt");var Ut=Object.defineProperty,B=_((n,o)=>Ut(n,"name",{value:o,configurable:!0}),"I"),It=Object.defineProperty,c=B((n,o)=>It(n,"name",{value:o,configurable:!0}),"__name$2");let ae=c(()=>{var n=(()=>{var o=Object.defineProperty,i=Object.getOwnPropertyDescriptor,u=Object.getOwnPropertyNames,d=Object.prototype.hasOwnProperty,h=c((e,t)=>{for(var r in t)o(e,r,{get:t[r],enumerable:!0})},"J"),x=c((e,t,r,a)=>{if(t&&typeof t=="object"||typeof t=="function")for(let s of u(t))!d.call(e,s)&&s!==r&&o(e,s,{get:c(()=>t[s],"get"),enumerable:!(a=i(t,s))||a.enumerable});return e},"T"),g=c(e=>x(o({},"__esModule",{value:!0}),e),"W"),y={};h(y,{zeptomatch:c(()=>bt,"zeptomatch")});var F=c(e=>Array.isArray(e),"k"),z=c(e=>typeof e=="function","x"),ge=c(e=>e.length===0,"K"),me=(()=>{const{toString:e}=Function.prototype,t=/(?:^\(\s*(?:[^,.()]|\.(?!\.\.))*\s*\)\s*=>|^\s*[a-zA-Z$_][a-zA-Z0-9$_]*\s*=>)/;return r=>(r.length===0||r.length===1)&&t.test(e.call(r))})(),xe=c(e=>typeof e=="number","Y"),$e=c(e=>typeof e=="object"&&e!==null,"rr"),ve=c(e=>e instanceof RegExp,"er"),ye=(()=>{const e=/\\\(|\((?!\?(?::|=|!|<=|<!))/;return t=>e.test(t.source)})(),be=(()=>{const e=/^[a-zA-Z0-9_-]+$/;return t=>e.test(t.source)&&!t.flags.includes("i")})(),J=c(e=>typeof e=="string","M"),O=c(e=>e===void 0,"f"),we=c(e=>{const t=new Map;return r=>{const a=t.get(r);if(a!==void 0)return a;const s=e(r);return t.set(r,s),s}},"ar"),je=c((e,t,r={})=>{const a={cache:{},input:e,index:0,indexBacktrackMax:0,options:r,output:[]},s=k(t)(a),f=Math.max(a.index,a.indexBacktrackMax);if(s&&a.index===e.length)return a.output;throw new Error(`Failed to parse at index ${f}`)},"or"),l=c((e,t)=>F(e)?Oe(e,t):J(e)?T(e,t):ke(e,t),"o"),Oe=c((e,t)=>{const r={};for(const a of e){if(a.length!==1)throw new Error(`Invalid character: "${a}"`);const s=a.charCodeAt(0);r[s]=!0}return a=>{const s=a.input;let f=a.index,p=f;for(;p<s.length&&s.charCodeAt(p)in r;)p+=1;if(p>f){if(!O(t)&&!a.options.silent){const m=s.slice(f,p),v=z(t)?t(m,s,`${f}`):t;O(v)||a.output.push(v)}a.index=p}return!0}},"ir"),ke=c((e,t)=>{if(be(e))return T(e.source,t);{const r=e.source,a=e.flags.replace(/y|$/,"y"),s=new RegExp(r,a);return ye(e)&&z(t)&&!me(t)?Ae(s,t):Me(s,t)}},"ur"),Ae=c((e,t)=>r=>{const a=r.index,s=r.input;e.lastIndex=a;const f=e.exec(s);if(f){const p=e.lastIndex;if(!r.options.silent){const m=t(...f,s,`${a}`);O(m)||r.output.push(m)}return r.index=p,!0}else return!1},"sr"),Me=c((e,t)=>r=>{const a=r.index,s=r.input;if(e.lastIndex=a,e.test(s)){const f=e.lastIndex;if(!O(t)&&!r.options.silent){const p=z(t)?t(s.slice(a,f),s,`${a}`):t;O(p)||r.output.push(p)}return r.index=f,!0}else return!1},"cr"),T=c((e,t)=>r=>{const a=r.index,s=r.input;if(s.startsWith(e,a)){if(!O(t)&&!r.options.silent){const f=z(t)?t(e,s,`${a}`):t;O(f)||r.output.push(f)}return r.index+=e.length,!0}else return!1},"R"),q=c((e,t,r,a)=>{const s=k(e),f=t>1;return I(U(G(p=>{let m=0;for(;m<r;){const v=p.index;if(!s(p)||(m+=1,p.index===v))break}return m>=t},f),a))},"O"),_e=c((e,t)=>q(e,0,1,t),"lr"),S=c((e,t)=>q(e,0,1/0,t),"m"),E=c((e,t)=>{const r=e.map(k);return I(U(G(a=>{for(let s=0,f=r.length;s<f;s++)if(!r[s](a))return!1;return!0}),t))},"_"),w=c((e,t)=>{const r=e.map(k);return I(U(a=>{for(let s=0,f=r.length;s<f;s++)if(r[s](a))return!0;return!1},t))},"p"),G=c((e,t=!0,r=!1)=>{const a=k(e);return t?s=>{const f=s.index,p=s.output.length,m=a(s);return!m&&!r&&(s.indexBacktrackMax=Math.max(s.indexBacktrackMax,s.index)),(!m||r)&&(s.index=f,s.output.length!==p&&(s.output.length=p)),m}:a},"P"),U=c((e,t)=>{const r=k(e);return t?a=>{if(a.options.silent)return r(a);const s=a.output.length;if(r(a)){const f=a.output.splice(s,1/0),p=t(f);return O(p)||a.output.push(p),!0}else return!1}:r},"C"),I=(()=>{let e=0;return t=>{const r=k(t),a=e+=1;return s=>{var f;if(s.options.memoization===!1)return r(s);const p=s.index,m=(f=s.cache)[a]||(f[a]={indexMax:-1,queue:[]}),v=m.queue;if(p<=m.indexMax){const P=m.store||(m.store=new Map);if(v.length){for(let M=0,jt=v.length;M<jt;M+=2){const Ot=v[M*2],kt=v[M*2+1];P.set(Ot,kt)}v.length=0}const b=P.get(p);if(b===!1)return!1;if(xe(b))return s.index=b,!0;if(b)return s.index=b.index,b.output?.length&&s.output.push(...b.output),!0}const ie=s.output.length,wt=r(s);if(m.indexMax=Math.max(m.indexMax,p),wt){const P=s.index,b=s.output.length;if(b>ie){const M=s.output.slice(ie,b);v.push(p,{index:P,output:M})}else v.push(p,P);return!0}else return v.push(p,!1),!1}}})(),V=c(e=>{let t;return r=>(t||(t=k(e())),t(r))},"A"),k=we(e=>{if(z(e))return ge(e)?V(e):e;if(J(e)||ve(e))return l(e);if(F(e))return E(e);if($e(e))return w(Object.values(e));throw new Error("Invalid rule")}),j=c(e=>e,"v"),K=c(e=>t=>je(t,e,{memoization:!1}).join(""),"z"),ze=c(e=>{const t={};return r=>t[r]??(t[r]=e(r))},"pr"),Y="abcdefghijklmnopqrstuvwxyz",Pe=c(e=>{let t="";for(;e>0;){const r=(e-1)%26;t=Y[r]+t,e=Math.floor((e-1)/26)}return t},"vr"),H=c(e=>{let t=0;for(let r=0,a=e.length;r<a;r++)t=t*26+Y.indexOf(e[r])+1;return t},"N"),Z=c((e,t)=>{if(t<e)return Z(t,e);const r=[];for(;e<=t;)r.push(e++);return r},"$"),Ce=c((e,t,r)=>Z(e,t).map(a=>String(a).padStart(r,"0")),"fr"),Q=c((e,t)=>Z(H(e),H(t)).map(Pe),"j"),L=l(/\\./,j),Se=l(/[$.*+?^(){}[\]\|]/,e=>`\\${e}`),Ee=l(/./,j),Ne=l(/^(?:!!)*!(.*)$/,(e,t)=>`(?!^${se(t)}$).*?`),Ue=l(/^(!!)+/,""),Ie=w([Ne,Ue]),Ze=l(/\/(\*\*\/)+/,"(?:[\\\\/].+[\\\\/]|[\\\\/])"),Le=l(/^(\*\*\/)+/,"(?:^|.*[\\\\/])"),De=l(/\/(\*\*)$/,"(?:[\\\\/].*|$)"),Re=l(/\*\*/,".*"),X=w([Ze,Le,De,Re]),Be=l(/\*\/(?!\*\*\/|\*$)/,"[^\\\\/]*[\\\\/]"),We=l(/\*/,"[^\\\\/]*"),ee=w([Be,We]),te=l("?","[^\\\\/]"),Fe=l("[",j),Je=l("]",j),Te=l(/[!^]/,"^\\\\/"),qe=l(/[a-z]-[a-z]|[0-9]-[0-9]/i,j),Ge=l(/[$.*+?^(){}[\|]/,e=>`\\${e}`),Ve=l(/[^\]]/,j),Ke=w([L,Ge,qe,Ve]),ne=E([Fe,_e(Te),S(Ke),Je]),Ye=l("{","(?:"),He=l("}",")"),Qe=l(/(\d+)\.\.(\d+)/,(e,t,r)=>Ce(+t,+r,Math.min(t.length,r.length)).join("|")),Xe=l(/([a-z]+)\.\.([a-z]+)/,(e,t,r)=>Q(t,r).join("|")),et=l(/([A-Z]+)\.\.([A-Z]+)/,(e,t,r)=>Q(t.toLowerCase(),r.toLowerCase()).join("|").toUpperCase()),tt=w([Qe,Xe,et]),re=E([Ye,tt,He]),nt=l("{","(?:"),rt=l("}",")"),ot=l(",","|"),st=l(/[$.*+?^(){[\]\|]/,e=>`\\${e}`),it=l(/[^}]/,j),at=V(()=>oe),ut=w([X,ee,te,ne,re,at,L,st,ot,it]),oe=E([nt,S(ut),rt]),ct=S(w([Ie,X,ee,te,ne,re,oe,L,Se,Ee])),lt=ct,ft=K(lt),se=ft,pt=l(/\\./,j),dt=l(/./,j),ht=l(/\*\*\*+/,"*"),gt=l(/([^/{[(!])\*\*/,(e,t)=>`${t}*`),mt=l(/(^|.)\*\*(?=[^*/)\]}])/,(e,t)=>`${t}*`),xt=S(w([pt,ht,gt,mt,dt])),$t=xt,vt=K($t),yt=vt,N=c((e,t)=>Array.isArray(e)?e.map(N.compile).some(r=>r.test(t)):N.compile(e).test(t),"S");N.compile=ze(e=>new RegExp(`^${se(yt(e))}[\\\\/]?$`,"s"));var bt=N;return g(y)})();return n.default||n},"_lazyMatch"),D;const Zt=c((n,o)=>(D||(D=ae(),ae=null),D(n,o)),"default");var Lt=Object.defineProperty,Dt=B((n,o)=>Lt(n,"name",{value:o,configurable:!0}),"__name$1");const Rt=/^[A-Z]:\//i,A=Dt((n="")=>n&&n.replaceAll("\\","/").replace(Rt,o=>o.toUpperCase()),"normalizeWindowsPath");var Bt=Object.defineProperty,$=B((n,o)=>Bt(n,"name",{value:o,configurable:!0}),"__name");const Wt=/^[/\\]{2}/,Ft=/^[/\\](?![/\\])|^[/\\]{2}(?!\.)|^[A-Z]:[/\\]/i,le=/^[A-Z]:$/i,ue=/^\/([A-Z]:)?$/i,Jt=/.(\.[^./]+)$/,Tt=/^[/\\]|^[a-z]:[/\\]/i,qt=$(()=>typeof process.cwd=="function"?process.cwd().replaceAll("\\","/"):"/","cwd"),fe=$((n,o)=>{let i="",u=0,d=-1,h=0,x=null;for(let g=0;g<=n.length;++g){if(g<n.length)x=n[g];else{if(x==="/")break;x="/"}if(x==="/"){if(!(d===g-1||h===1))if(h===2){if(i.length<2||u!==2||!i.endsWith(".")||i.at(-2)!=="."){if(i.length>2){const y=i.lastIndexOf("/");y===-1?(i="",u=0):(i=i.slice(0,y),u=i.length-1-i.lastIndexOf("/")),d=g,h=0;continue}else if(i.length>0){i="",u=0,d=g,h=0;continue}}o&&(i+=i.length>0?"/..":"..",u=2)}else i.length>0?i+=`/${n.slice(d+1,g)}`:i=n.slice(d+1,g),u=g-d-1;d=g,h=0}else x==="."&&h!==-1?++h:h=-1}return i},"normalizeString"),C=$(n=>Ft.test(n),"isAbsolute"),pe=$(function(n){if(n.length===0)return".";n=A(n);const o=Wt.exec(n),i=C(n),u=n.at(-1)==="/";return n=fe(n,!i),n.length===0?i?"/":u?"./":".":(u&&(n+="/"),le.test(n)&&(n+="/"),o?i?`//${n}`:`//./${n}`:i&&!C(n)?`/${n}`:n)},"normalize"),Gt=$((...n)=>{let o="";for(const i of n)if(i)if(o.length>0){const u=o[o.length-1]==="/",d=i[0]==="/";u&&d?o+=i.slice(1):o+=u||d?i:`/${i}`}else o+=i;return pe(o)},"join"),R=$(function(...n){n=n.map(u=>A(u));let o="",i=!1;for(let u=n.length-1;u>=-1&&!i;u--){const d=u>=0?n[u]:qt();!d||d.length===0||(o=`${d}/${o}`,i=C(d))}return o=fe(o,!i),i&&!C(o)?`/${o}`:o.length>0?o:"."},"resolve");$(function(n){return A(n)},"toNamespacedPath");const Vt=$(function(n){return Jt.exec(A(n))?.[1]??""},"extname");$(function(n,o){const i=R(n).replace(ue,"$1").split("/"),u=R(o).replace(ue,"$1").split("/");if(u[0][1]===":"&&i[0][1]===":"&&i[0]!==u[0])return u.join("/");const d=[...i];for(const h of d){if(u[0]!==h)break;i.shift(),u.shift()}return[...i.map(()=>".."),...u].join("/")},"relative");const de=$(n=>{const o=A(n).replace(/\/$/,"").split("/").slice(0,-1);return o.length===1&&le.test(o[0])&&(o[0]+="/"),o.join("/")||(C(n)?"/":".")},"dirname");$(function(n){const o=[n.root,n.dir,n.base??n.name+n.ext].filter(Boolean);return A(n.root?R(...o):o.join("/"))},"format");const Kt=$((n,o)=>{const i=A(n).split("/").pop();return o&&i.endsWith(o)?i.slice(0,-o.length):i},"basename");$(function(n){const o=Tt.exec(n)?.[0]?.replace(/\\/g,"/")??"",i=Kt(n),u=Vt(i);return{base:i,dir:de(n),ext:u,name:i.slice(0,i.length-u.length),root:o}},"parse");$((n,o)=>Zt(o,pe(n)),"matchesGlob");var Yt=Object.defineProperty,W=_((n,o)=>Yt(n,"name",{value:o,configurable:!0}),"r");const Ht="last-update-check.json",he=W(n=>{const o=Pt(n);if(o===void 0)throw new Error("Could not find cache directory");return Gt(o,Ht)},"getConfigFile"),Qt=W(n=>{const o=he(n);try{if(!ce(o))return;const{lastUpdateCheck:i}=JSON.parse(zt(o,"utf8"));return i}catch{return}},"getLastUpdate"),Xt=W(n=>{const o=he(n),i=de(o);ce(i)||Mt(i,{recursive:!0}),_t(o,JSON.stringify({lastUpdateCheck:Date.now()}))},"saveLastUpdate");var en=Object.defineProperty,tn=_((n,o)=>en(n,"name",{value:o,configurable:!0}),"g");const nn=tn(async(n,o,i)=>{const u=i.replace("__NAME__",n);return await new Promise((d,h)=>{Ct(u,x=>{let g="";x.on("data",y=>g+=y),x.on("end",()=>{try{const y=JSON.parse(g)[o];y||h(new Error("Error getting version")),d(y)}catch{h(new Error("Could not parse version response"))}})}).on("error",x=>h(x))})},"getDistributionVersion");var rn=Object.defineProperty,on=_((n,o)=>rn(n,"name",{value:o,configurable:!0}),"i");const ln=on(async({alwaysRun:n,debug:o,distTag:i="latest",pkg:u,registryUrl:d="https://registry.npmjs.org/-/package/__NAME__/dist-tags",updateCheckInterval:h=1e3*60*60*24})=>{const x=Qt(u.name);if(n||!x||x<Date.now()-h){const g=await nn(u.name,i,d);if(Xt(u.name),Nt(g,u.version))return g;o&&console.error(`Latest version (${g}) not newer than current version (${u.version})`)}else o&&console.error(`Too recent to check for a new update. simpleUpdateNotifier() interval set to ${h}ms but only ${Date.now()-x}ms since last check.`);return null},"hasNewVersion");export{ln as default};
|
|
1
|
+
var zt=Object.defineProperty;var k=(n,r)=>zt(n,"name",{value:r,configurable:!0});import{createRequire as Pt}from"node:module";import{findCacheDirSync as Ut}from"@visulima/find-cache-dir";const Ct=Pt(import.meta.url),C=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,le=k(n=>{if(typeof C<"u"&&C.versions&&C.versions.node){const[r,s]=C.versions.node.split(".").map(Number);if(r>22||r===22&&s>=3||r===20&&s>=16)return C.getBuiltinModule(n)}return Ct(n)},"__cjs_getBuiltinModule"),{existsSync:fe,mkdirSync:Nt,writeFileSync:St,readFileSync:Et}=le("node:fs"),{get:It}=le("node:https");var Zt=Object.defineProperty,Bt=k((n,r)=>Zt(n,"name",{value:r,configurable:!0}),"o$1");const Lt=Bt((n,r)=>{const s=n.split(".").map(Number),u=r.split(".").map(Number);for(const[d,h]of s.entries()){if(h>u[d])return!0;if(h<u[d])return!1}return!1},"semverGt");var Rt=Object.defineProperty,qt=k((n,r)=>Rt(n,"name",{value:r,configurable:!0}),"ce"),Dt=Object.defineProperty,D=qt((n,r)=>Dt(n,"name",{value:r,configurable:!0}),"C"),Tt=Object.defineProperty,c=D((n,r)=>Tt(n,"name",{value:r,configurable:!0}),"u$1");let ue=c(()=>{var n=(()=>{var r=Object.defineProperty,s=Object.getOwnPropertyDescriptor,u=Object.getOwnPropertyNames,d=Object.prototype.hasOwnProperty,h=c((e,t)=>{for(var o in t)r(e,o,{get:t[o],enumerable:!0})},"J"),x=c((e,t,o,a)=>{if(t&&typeof t=="object"||typeof t=="function")for(let i of u(t))!d.call(e,i)&&i!==o&&r(e,i,{get:c(()=>t[i],"get"),enumerable:!(a=s(t,i))||a.enumerable});return e},"T"),g=c(e=>x(r({},"__esModule",{value:!0}),e),"W"),b={};h(b,{zeptomatch:c(()=>_t,"zeptomatch")});var F=c(e=>Array.isArray(e),"k"),z=c(e=>typeof e=="function","x"),xe=c(e=>e.length===0,"K"),ve=(()=>{const{toString:e}=Function.prototype,t=/(?:^\(\s*(?:[^,.()]|\.(?!\.\.))*\s*\)\s*=>|^\s*[a-zA-Z$_][a-zA-Z0-9$_]*\s*=>)/;return o=>(o.length===0||o.length===1)&&t.test(e.call(o))})(),$e=c(e=>typeof e=="number","Y"),be=c(e=>typeof e=="object"&&e!==null,"rr"),ye=c(e=>e instanceof RegExp,"er"),we=(()=>{const e=/\\\(|\((?!\?(?::|=|!|<=|<!))/;return t=>e.test(t.source)})(),je=(()=>{const e=/^[a-zA-Z0-9_-]+$/;return t=>e.test(t.source)&&!t.flags.includes("i")})(),W=c(e=>typeof e=="string","M"),_=c(e=>e===void 0,"f"),_e=c(e=>{const t=new Map;return o=>{const a=t.get(o);if(a!==void 0)return a;const i=e(o);return t.set(o,i),i}},"ar"),Oe=c((e,t,o={})=>{const a={cache:{},input:e,index:0,indexBacktrackMax:0,options:o,output:[]},i=O(t)(a),f=Math.max(a.index,a.indexBacktrackMax);if(i&&a.index===e.length)return a.output;throw new Error(`Failed to parse at index ${f}`)},"or"),l=c((e,t)=>F(e)?ke(e,t):W(e)?J(e,t):Ae(e,t),"o"),ke=c((e,t)=>{const o={};for(const a of e){if(a.length!==1)throw new Error(`Invalid character: "${a}"`);const i=a.charCodeAt(0);o[i]=!0}return a=>{const i=a.input;let f=a.index,p=f;for(;p<i.length&&i.charCodeAt(p)in o;)p+=1;if(p>f){if(!_(t)&&!a.options.silent){const m=i.slice(f,p),$=z(t)?t(m,i,`${f}`):t;_($)||a.output.push($)}a.index=p}return!0}},"ir"),Ae=c((e,t)=>{if(je(e))return J(e.source,t);{const o=e.source,a=e.flags.replace(/y|$/,"y"),i=new RegExp(o,a);return we(e)&&z(t)&&!ve(t)?Me(i,t):ze(i,t)}},"ur"),Me=c((e,t)=>o=>{const a=o.index,i=o.input;e.lastIndex=a;const f=e.exec(i);if(f){const p=e.lastIndex;if(!o.options.silent){const m=t(...f,i,`${a}`);_(m)||o.output.push(m)}return o.index=p,!0}else return!1},"sr"),ze=c((e,t)=>o=>{const a=o.index,i=o.input;if(e.lastIndex=a,e.test(i)){const f=e.lastIndex;if(!_(t)&&!o.options.silent){const p=z(t)?t(i.slice(a,f),i,`${a}`):t;_(p)||o.output.push(p)}return o.index=f,!0}else return!1},"cr"),J=c((e,t)=>o=>{const a=o.index,i=o.input;if(i.startsWith(e,a)){if(!_(t)&&!o.options.silent){const f=z(t)?t(e,i,`${a}`):t;_(f)||o.output.push(f)}return o.index+=e.length,!0}else return!1},"R"),G=c((e,t,o,a)=>{const i=O(e),f=t>1;return Z(I(V(p=>{let m=0;for(;m<o;){const $=p.index;if(!i(p)||(m+=1,p.index===$))break}return m>=t},f),a))},"O"),Pe=c((e,t)=>G(e,0,1,t),"lr"),S=c((e,t)=>G(e,0,1/0,t),"m"),E=c((e,t)=>{const o=e.map(O);return Z(I(V(a=>{for(let i=0,f=o.length;i<f;i++)if(!o[i](a))return!1;return!0}),t))},"S"),w=c((e,t)=>{const o=e.map(O);return Z(I(a=>{for(let i=0,f=o.length;i<f;i++)if(o[i](a))return!0;return!1},t))},"p"),V=c((e,t=!0,o=!1)=>{const a=O(e);return t?i=>{const f=i.index,p=i.output.length,m=a(i);return!m&&!o&&(i.indexBacktrackMax=Math.max(i.indexBacktrackMax,i.index)),(!m||o)&&(i.index=f,i.output.length!==p&&(i.output.length=p)),m}:a},"P"),I=c((e,t)=>{const o=O(e);return t?a=>{if(a.options.silent)return o(a);const i=a.output.length;if(o(a)){const f=a.output.splice(i,1/0),p=t(f);return _(p)||a.output.push(p),!0}else return!1}:o},"C"),Z=(()=>{let e=0;return t=>{const o=O(t),a=e+=1;return i=>{var f;if(i.options.memoization===!1)return o(i);const p=i.index,m=(f=i.cache)[a]||(f[a]={indexMax:-1,queue:[]}),$=m.queue;if(p<=m.indexMax){const P=m.store||(m.store=new Map);if($.length){for(let M=0,kt=$.length;M<kt;M+=2){const At=$[M*2],Mt=$[M*2+1];P.set(At,Mt)}$.length=0}const y=P.get(p);if(y===!1)return!1;if($e(y))return i.index=y,!0;if(y)return i.index=y.index,y.output?.length&&i.output.push(...y.output),!0}const ae=i.output.length,Ot=o(i);if(m.indexMax=Math.max(m.indexMax,p),Ot){const P=i.index,y=i.output.length;if(y>ae){const M=i.output.slice(ae,y);$.push(p,{index:P,output:M})}else $.push(p,P);return!0}else return $.push(p,!1),!1}}})(),K=c(e=>{let t;return o=>(t||(t=O(e())),t(o))},"A"),O=_e(e=>{if(z(e))return xe(e)?K(e):e;if(W(e)||ye(e))return l(e);if(F(e))return E(e);if(be(e))return w(Object.values(e));throw new Error("Invalid rule")}),j=c(e=>e,"v"),Y=c(e=>t=>Oe(t,e,{memoization:!1}).join(""),"z"),Ce=c(e=>{const t={};return o=>t[o]??(t[o]=e(o))},"pr"),H="abcdefghijklmnopqrstuvwxyz",Ne=c(e=>{let t="";for(;e>0;){const o=(e-1)%26;t=H[o]+t,e=Math.floor((e-1)/26)}return t},"vr"),Q=c(e=>{let t=0;for(let o=0,a=e.length;o<a;o++)t=t*26+H.indexOf(e[o])+1;return t},"N"),B=c((e,t)=>{if(t<e)return B(t,e);const o=[];for(;e<=t;)o.push(e++);return o},"$"),Se=c((e,t,o)=>B(e,t).map(a=>String(a).padStart(o,"0")),"fr"),X=c((e,t)=>B(Q(e),Q(t)).map(Ne),"j"),L=l(/\\./,j),Ee=l(/[$.*+?^(){}[\]\|]/,e=>`\\${e}`),Ue=l(/[\\/]/,"[\\\\/]"),Ie=l(/./,j),Ze=l(/^(?:!!)*!(.*)$/,(e,t)=>`(?!^${ie(t)}$).*?`),Be=l(/^(!!)+/,""),Le=w([Ze,Be]),Re=l(/\/(\*\*\/)+/,"(?:[\\\\/].+[\\\\/]|[\\\\/])"),qe=l(/^(\*\*\/)+/,"(?:^|.*[\\\\/])"),De=l(/\/(\*\*)$/,"(?:[\\\\/].*|$)"),Te=l(/\*\*/,".*"),ee=w([Re,qe,De,Te]),Fe=l(/\*\/(?!\*\*\/|\*$)/,"[^\\\\/]*[\\\\/]"),We=l(/\*/,"[^\\\\/]*"),te=w([Fe,We]),ne=l("?","[^\\\\/]"),Je=l("[",j),Ge=l("]",j),Ve=l(/[!^]/,"^\\\\/"),Ke=l(/[a-z]-[a-z]|[0-9]-[0-9]/i,j),Ye=l(/[$.*+?^(){}[\|]/,e=>`\\${e}`),He=l(/[^\]]/,j),Qe=w([L,Ye,Ke,He]),re=E([Je,Pe(Ve),S(Qe),Ge]),Xe=l("{","(?:"),et=l("}",")"),tt=l(/(\d+)\.\.(\d+)/,(e,t,o)=>Se(+t,+o,Math.min(t.length,o.length)).join("|")),nt=l(/([a-z]+)\.\.([a-z]+)/,(e,t,o)=>X(t,o).join("|")),rt=l(/([A-Z]+)\.\.([A-Z]+)/,(e,t,o)=>X(t.toLowerCase(),o.toLowerCase()).join("|").toUpperCase()),ot=w([tt,nt,rt]),oe=E([Xe,ot,et]),st=l("{","(?:"),it=l("}",")"),at=l(",","|"),ut=l(/[$.*+?^(){[\]\|]/,e=>`\\${e}`),ct=l(/[^}]/,j),lt=K(()=>se),ft=w([ee,te,ne,re,oe,lt,L,ut,at,ct]),se=E([st,S(ft),it]),pt=S(w([Le,ee,te,ne,re,oe,se,L,Ee,Ue,Ie])),dt=pt,ht=Y(dt),ie=ht,gt=l(/\\./,j),mt=l(/./,j),xt=l(/\*\*\*+/,"*"),vt=l(/([^/{[(!])\*\*/,(e,t)=>`${t}*`),$t=l(/(^|.)\*\*(?=[^*/)\]}])/,(e,t)=>`${t}*`),bt=S(w([gt,xt,vt,$t,mt])),yt=bt,wt=Y(yt),jt=wt,U=c((e,t)=>Array.isArray(e)?e.map(U.compile).some(o=>o.test(t)):U.compile(e).test(t),"_");U.compile=Ce(e=>new RegExp(`^${ie(jt(e))}[\\\\/]?$`,"s"));var _t=U;return g(b)})();return n.default||n},"_lazyMatch"),R;const Ft=c((n,r)=>(R||(R=ue(),ue=null),R(n,r)),"default");var Wt=Object.defineProperty,Jt=D((n,r)=>Wt(n,"name",{value:r,configurable:!0}),"t");const Gt=/^[A-Z]:\//i,A=Jt((n="")=>n&&n.replaceAll("\\","/").replace(Gt,r=>r.toUpperCase()),"normalizeWindowsPath");var Vt=Object.defineProperty,v=D((n,r)=>Vt(n,"name",{value:r,configurable:!0}),"r");const Kt=/^[/\\]{2}/,Yt=/^[/\\](?![/\\])|^[/\\]{2}(?!\.)|^[A-Z]:[/\\]/i,pe=/^[A-Z]:$/i,ce=/^\/([A-Z]:)?$/i,Ht=/.(\.[^./]+)$/,Qt=/^[/\\]|^[a-z]:[/\\]/i,Xt=v(()=>typeof process.cwd=="function"?process.cwd().replaceAll("\\","/"):"/","cwd"),de=v((n,r)=>{let s="",u=0,d=-1,h=0,x;for(let g=0;g<=n.length;++g){if(g<n.length)x=n[g];else{if(x==="/")break;x="/"}if(x==="/"){if(!(d===g-1||h===1))if(h===2){if(s.length<2||u!==2||!s.endsWith(".")||s.at(-2)!=="."){if(s.length>2){const b=s.lastIndexOf("/");b===-1?(s="",u=0):(s=s.slice(0,b),u=s.length-1-s.lastIndexOf("/")),d=g,h=0;continue}else if(s.length>0){s="",u=0,d=g,h=0;continue}}r&&(s+=s.length>0?"/..":"..",u=2)}else s.length>0?s+=`/${n.slice(d+1,g)}`:s=n.slice(d+1,g),u=g-d-1;d=g,h=0}else x==="."&&h!==-1?++h:h=-1}return s},"normalizeString"),N=v(n=>Yt.test(n),"isAbsolute"),he=v(function(n){if(n.length===0)return".";n=A(n);const r=Kt.exec(n),s=N(n),u=n.at(-1)==="/";return n=de(n,!s),n.length===0?s?"/":u?"./":".":(u&&(n+="/"),pe.test(n)&&(n+="/"),r?s?`//${n}`:`//./${n}`:s&&!N(n)?`/${n}`:n)},"normalize"),en=v((...n)=>{let r="";for(const s of n)if(s)if(r.length>0){const u=r[r.length-1]==="/",d=s[0]==="/";u&&d?r+=s.slice(1):r+=u||d?s:`/${s}`}else r+=s;return he(r)},"join"),q=v(function(...n){n=n.map(u=>A(u));let r="",s=!1;for(let u=n.length-1;u>=-1&&!s;u--){const d=u>=0?n[u]:Xt();!d||d.length===0||(r=`${d}/${r}`,s=N(d))}return r=de(r,!s),s&&!N(r)?`/${r}`:r.length>0?r:"."},"resolve");v(function(n){return A(n)},"toNamespacedPath");const tn=v(function(n){return Ht.exec(A(n))?.[1]??""},"extname");v(function(n,r){const s=q(n).replace(ce,"$1").split("/"),u=q(r).replace(ce,"$1").split("/");if(u[0][1]===":"&&s[0][1]===":"&&s[0]!==u[0])return u.join("/");const d=[...s];for(const h of d){if(u[0]!==h)break;s.shift(),u.shift()}return[...s.map(()=>".."),...u].join("/")},"relative");const ge=v(n=>{const r=A(n).replace(/\/$/,"").split("/").slice(0,-1);return r.length===1&&pe.test(r[0])&&(r[0]+="/"),r.join("/")||(N(n)?"/":".")},"dirname");v(function(n){const r=[n.root,n.dir,n.base??n.name+n.ext].filter(Boolean);return A(n.root?q(...r):r.join("/"))},"format");const nn=v((n,r)=>{const s=A(n).split("/").pop();return r&&s.endsWith(r)?s.slice(0,-r.length):s},"basename");v(function(n){const r=Qt.exec(n)?.[0]?.replaceAll("\\","/")??"",s=nn(n),u=tn(s);return{base:s,dir:ge(n),ext:u,name:s.slice(0,s.length-u.length),root:r}},"parse");v((n,r)=>Ft(r,he(n)),"matchesGlob");var rn=Object.defineProperty,T=k((n,r)=>rn(n,"name",{value:r,configurable:!0}),"r");const on="last-update-check.json",me=T(n=>{const r=Ut(n);if(r===void 0)throw new Error("Could not find cache directory");return en(r,on)},"getConfigFile"),sn=T(n=>{const r=me(n);try{if(!fe(r))return;const{lastUpdateCheck:s}=JSON.parse(Et(r,"utf8"));return s}catch{return}},"getLastUpdate"),an=T(n=>{const r=me(n),s=ge(r);fe(s)||Nt(s,{recursive:!0}),St(r,JSON.stringify({lastUpdateCheck:Date.now()}))},"saveLastUpdate");var un=Object.defineProperty,cn=k((n,r)=>un(n,"name",{value:r,configurable:!0}),"g");const ln=cn(async(n,r,s)=>{const u=s.replace("__NAME__",n);return await new Promise((d,h)=>{It(u,x=>{let g="";x.on("data",b=>g+=b),x.on("end",()=>{try{const b=JSON.parse(g)[r];b||h(new Error("Error getting version")),d(b)}catch{h(new Error("Could not parse version response"))}})}).on("error",x=>h(x))})},"getDistributionVersion");var fn=Object.defineProperty,pn=k((n,r)=>fn(n,"name",{value:r,configurable:!0}),"i");const mn=pn(async({alwaysRun:n,debug:r,distTag:s="latest",pkg:u,registryUrl:d="https://registry.npmjs.org/-/package/__NAME__/dist-tags",updateCheckInterval:h=1e3*60*60*24})=>{const x=sn(u.name);if(n||!x||x<Date.now()-h){const g=await ln(u.name,s,d);if(an(u.name),Lt(g,u.version))return g;r&&console.error(`Latest version (${g}) not newer than current version (${u.version})`)}else r&&console.error(`Too recent to check for a new update. simpleUpdateNotifier() interval set to ${h}ms but only ${Date.now()-x}ms since last check.`);return null},"hasNewVersion");export{mn as default};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
var oe=Object.defineProperty;var c=(t,e)=>oe(t,"name",{value:e,configurable:!0});import{createRequire as ne}from"node:module";import{boxen as le}from"@visulima/boxen";import{bold as ce,dim as pe,reset as ue,green as me,yellow as de}from"@visulima/colorize";import{MessageFormatterProcessor as ge,CallerProcessor as he}from"@visulima/pail/processor";import{createPail as fe}from"@visulima/pail/server";import ve from"command-line-args";import ye from"@visulima/colorize/template";const R=ne(import.meta.url),f=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,re=c(t=>{if(typeof f<"u"&&f.versions&&f.versions.node){const[e,o]=f.versions.node.split(".").map(Number);if(e>22||e===22&&o>=3||e===20&&o>=16)return f.getBuiltinModule(t)}return R(t)},"__cjs_getBuiltinModule"),{cwd:ae,argv:B,env:m,execPath:ie,execArgv:se,exit:x}=f,O=R("cli-table3"),be=re("node:os"),{distance:$e}=R("fastest-levenshtein");var we=Object.defineProperty,_=c((t,e)=>we(t,"name",{value:e,configurable:!0}),"f$4");const Ee=/[\p{Lu}]/u,Oe=/[\p{Ll}]/u,k=/^[\p{Lu}](?![\p{Lu}])/gu,W=/([\p{Alpha}\p{N}_]|$)/u,S=/[_.\- ]+/,Ce=new RegExp("^"+S.source),U=new RegExp(S.source+W.source,"gu"),I=new RegExp("\\d+"+W.source,"gu"),_e=_((t,e,o,n)=>{let r=!1,i=!1,a=!1,s=!1;for(let l=0;l<t.length;l++){const p=t[l];s=l>2?t[l-3]==="-":!0,r&&Ee.test(p)?(t=t.slice(0,l)+"-"+t.slice(l),r=!1,a=i,i=!0,l++):i&&a&&Oe.test(p)&&(!s||n)?(t=t.slice(0,l-1)+"-"+t.slice(l-1),a=i,i=!1,r=!0):(r=e(p)===p&&o(p)!==p,a=i,i=o(p)===p&&e(p)!==p)}return t},"preserveCamelCase"),Ae=_((t,e)=>(k.lastIndex=0,t.replaceAll(k,o=>e(o))),"preserveConsecutiveUppercase"),Ne=_((t,e)=>(U.lastIndex=0,I.lastIndex=0,t.replaceAll(I,(o,n,r)=>["_","-"].includes(t.charAt(r+o.length))?o:e(o)).replaceAll(U,(o,n)=>e(n))),"postProcess");function H(t,e){if(!(typeof t=="string"||Array.isArray(t)))throw new TypeError("Expected the input to be `string | string[]`");if(e={pascalCase:!1,preserveConsecutiveUppercase:!1,...e},Array.isArray(t)?t=t.map(r=>r.trim()).filter(r=>r.length).join("-"):t=t.trim(),t.length===0)return"";const o=e.locale===!1?r=>r.toLowerCase():r=>r.toLocaleLowerCase(e.locale),n=e.locale===!1?r=>r.toUpperCase():r=>r.toLocaleUpperCase(e.locale);return t.length===1?S.test(t)?"":e.pascalCase?n(t):o(t):(t!==o(t)&&(t=_e(t,o,n,e.preserveConsecutiveUppercase)),t=t.replace(Ce,""),t=e.preserveConsecutiveUppercase?Ae(t,o):o(t),e.pascalCase&&(t=n(t.charAt(0))+t.slice(1)),Ne(t,n))}c(H,"S");_(H,"camelCase");const C=[{description:"Turn on verbose output",group:"global",name:"verbose",type:Boolean},{description:"Turn on debugging output",group:"global",name:"debug",type:Boolean},{alias:"h",description:"Print out helpful usage information",group:"global",name:"help",type:Boolean},{alias:"q",description:"Silence output",group:"global",name:"quiet",type:Boolean},{alias:"V",description:"Print version info",group:"global",name:"version",type:Boolean},{description:"Turn off colored output",group:"global",name:"no-color",type:Boolean},{description:"Force colored output",group:"global",name:"color",type:Boolean}];var Le=Object.defineProperty,xe=c((t,e)=>Le(t,"name",{value:e,configurable:!0}),"e$4");const u=xe(t=>t?ye(Object.assign([],{raw:[t.replaceAll("`","\\`")]})):"","templateFormat");var je=Object.defineProperty,Pe=c((t,e)=>je(t,"name",{value:e,configurable:!0}),"t$6");let J=class{static{c(this,"n")}static{Pe(this,"BaseSection")}lines;constructor(){this.lines=[]}add(e){this.lines.push(e)}toString(){return this.lines.join(be.EOL)}header(e){this.add(ce(e)),this.lines.push("")}};var Re=Object.defineProperty,Se=c((t,e)=>Re(t,"name",{value:e,configurable:!0}),"p$4");const w={chars:{bottom:"","bottom-left":"","bottom-mid":"","bottom-right":"",left:" ","left-mid":"",mid:"","mid-mid":"",middle:" ",right:"","right-mid":"",top:"","top-left":"","top-mid":"","top-right":""},colWidths:[40,60],style:{border:[],compact:!0,head:[],"padding-left":2,"padding-right":1},wordWrap:!0};let Te=class extends J{static{c(this,"y")}static{Se(this,"ContentSection")}constructor(e){if(super(),e.header&&this.header(u(e.header)),e.content){if(e.raw)if(Array.isArray(e.content)&&e.content.every(o=>typeof o=="string"))e.content.forEach(o=>{Array.isArray(o)?o.forEach(n=>this.add(u(n))):this.add(u(o))});else if(typeof e.content=="string")this.add(u(e.content));else throw new TypeError("Invalid raw content, must be a string or array of strings.");else this.add(this.getContentLines(e.content));this.add("")}}getContentLines(e){if(typeof e=="string"){const o=new O({...w,colWidths:[80]});return o.push([u(e)]),o.toString()}if(Array.isArray(e)&&e.every(o=>typeof o=="string"||Array.isArray(o)&&o.every(n=>typeof n=="string"))){const o=new O({...w});return e.forEach(n=>{Array.isArray(n)?o.push(n.map(r=>u(r))):o.push([u(n)])}),o.toString()}if(typeof e=="object"){const o=e;if(!o.options||!o.data)throw new Error(`Must have an "options" or "data" property
|
|
2
|
+
${JSON.stringify(e)}`);const n=new O({...w,...o.options,style:{...w.style,...o.options.style}});return o.data.forEach(r=>{Array.isArray(r)?n.push(r.map(i=>u(i))):n.push([u(r)])}),n.toString()}throw new Error(`invalid input - 'content' must be a string, array of strings or a object:
|
|
3
|
+
|
|
4
|
+
${JSON.stringify(e)}`)}};var Ve=Object.defineProperty,Be=c((t,e)=>Ve(t,"name",{value:e,configurable:!0}),"a$1");let ke=class extends J{static{c(this,"c")}static{Be(this,"OptionListSection")}constructor(e){super();let o=e.optionList??[];const n=Array.isArray(e.hide)?e.hide:[e.hide].filter(Boolean),r=Array.isArray(e.group)?e.group:[e.group].filter(Boolean);n.length>0&&(o=o.filter(a=>!n.includes(a.name))),e.header&&this.header(u(e.header)),r.length>0&&(o=o.filter(a=>{const s=r.includes("_none")&&!a.group,l=this.intersect(Array.isArray(a.group)?a.group:[a.group],r);return s||l?a:void 0}));const i=new O({chars:{bottom:"","bottom-left":"","bottom-mid":"","bottom-right":"",left:" ","left-mid":"",mid:"","mid-mid":"",middle:" ",right:"","right-mid":"",top:"","top-left":"","top-mid":"","top-right":""},colWidths:[40,40],style:{"padding-left":2,"padding-right":1},wordWrap:!0});o.forEach(a=>i.push([this.getOptionNames(a,e.reverseNameOrder??!1,e.isArgument??!1),u(a.description)])),this.add(i.toString()),this.lines.push("")}getOptionNames(e,o,n){if(!e.name)throw new TypeError("Invalid option definition, name is required.");let r=e.type?e.type.name.toLowerCase():"string";const i=e.multiple||e.lazyMultiple?"[]":"";r=u(e.typeLabel??`{underline ${r}${i}}`);let a;if(e.alias)if(e.name){const s=n?e.name:`{yellow --${e.name}}`;a=u(o?`{bold ${s}}, {bold -${e.alias}} ${r}`:`{bold -${e.alias}}, {bold ${s}} ${r}`)}else o?a=u(`{bold -${e.alias}} ${r}`):a=u(`{bold -${e.alias}} ${r}`);else a=u(`{bold ${n?e.name:`{yellow --${e.name}}`}} ${r}`);return a}intersect(e,o){return e.some(n=>o.includes(n))}};var Ue=Object.defineProperty,Ie=c((t,e)=>Ue(t,"name",{value:e,configurable:!0}),"o$3");const z=Ie(t=>(Array.isArray(t)?t:[t]).length===0?"":`
|
|
5
|
+
${t.map(e=>e.optionList?new ke(e).toString():new Te(e).toString()).join(`
|
|
6
|
+
`)}`,"commandLineUsage");var De=Object.defineProperty,A=c((t,e)=>De(t,"name",{value:e,configurable:!0}),"l$5");const D="__Other",M=A(t=>t.charAt(0).toUpperCase()+t.slice(1),"upperFirstChar"),Me=A((t,e,o,n)=>{t.debug("no command given, printing general help...");let r=[...new Set(o.values())].filter(a=>!a.hidden);n&&(r=r.filter(a=>a.group===n));const i=r.reduce((a,s)=>{const l=s.group??D;return a[l]||(a[l]=[]),a[l].push(s),a},{});t.raw(z([{content:`{cyan ${e.getCliName()}} {green <command>} [positional arguments] {yellow [options]}`,header:"{inverse.cyan Usage }"},...Object.keys(i).map(a=>({content:i[a].map(s=>{let l="";return typeof s.alias=="string"?l=s.alias:Array.isArray(s.alias)&&(l=s.alias.join(", ")),l!==""&&(l=` [${l}]`),[`{green ${s.name}} ${l}`,s.description??""]}),header:a===D||n?`{inverse.green Available${n?` ${M(n)}`:""} Commands }`:` {inverse.green ${M(a)} }`})),o.has("help")?{header:"{inverse.yellow Command Options }",optionList:o.get("help").options?.filter(a=>!a.hidden)}:void 0,{header:"{inverse.yellow Global Options }",optionList:C},{content:`Run "{cyan ${e.getCliName()}} {green help <command>}" or "{cyan ${e.getCliName()}} {green <command>} {yellow --help}" for help with a specific command.`,raw:!0}].filter(Boolean)))},"printGeneralHelp"),qe=A((t,e,o,n)=>{const r=o.get(n),i=[];if(i.push({content:`{cyan ${e.getCliName()}} {green ${r.name}}${r.argument?" [positional arguments]":""}${r.options?" [options]":""}`,header:"{inverse.cyan Usage }"}),r.description&&i.push({content:r.description,header:"{inverse.green Description }"}),r.argument&&i.push({header:"Command Positional Arguments",isArgument:!0,optionList:[r.argument]}),Array.isArray(r.options)&&r.options.length>0&&i.push({header:"{inverse.yellow Command Options }",optionList:r.options.filter(a=>!a.hidden)}),i.push({header:"{inverse.yellow Global Options }",optionList:C}),r.alias!==void 0&&r.alias.length>0){let a=r.alias;typeof r.alias=="string"&&(a=[r.alias]),i.splice(1,0,{content:a,header:"Alias(es)"})}Array.isArray(r.examples)&&r.examples.length>0&&i.push({content:r.examples,header:"Examples"}),t.raw(z(i))},"printCommandHelp");class Fe{static{c(this,"C")}static{A(this,"HelpCommand")}name="help";options=[{description:"Display only the specified group",name:"group",type:String}];commands;constructor(e){this.commands=e}execute(e){const{commandName:o,logger:n,options:r,runtime:i}=e,{footer:a,header:s}=i.getCommandSection();s&&n.raw(u(s)),o==="help"?Me(n,i,this.commands,r?.group):qe(n,i,this.commands,o),a&&n.raw(u(a))}}var Ye=Object.defineProperty,Ge=c((t,e)=>Ye(t,"name",{value:e,configurable:!0}),"s$7");const We={alias:["v","V"],description:"Output the version number",execute:Ge(({logger:t,runtime:e})=>{const o=e.getPackageVersion();o===void 0?(t.warn("Unknown version"),t.debug("The version number was not provided by the cli constructor.")):t.info(o)},"execute"),name:"version",options:[],usage:[]},q=16,He=32,Je=64,j=128,E="positionals";var ze=Object.defineProperty,Ke=c((t,e)=>ze(t,"name",{value:e,configurable:!0}),"m$2");let Qe=class{static{c(this,"c")}static{Ke(this,"EmptyToolbox")}result;argv;options;argument;command;commandName;runtime;logger;constructor(e,o){this.commandName=e,this.command=o}};var Xe=Object.defineProperty,Ze=c((t,e)=>Xe(t,"name",{value:e,configurable:!0}),"s$6");const et=Ze(()=>{const t=process.env.CEREBRO_MIN_NODE_VERSION?Number(process.env.CEREBRO_MIN_NODE_VERSION):18,e=process.version.replace("v","");Number(/v([^.]+)/.exec(process.version)[1])<t&&(console.log(`cerebro supports a minimum Node version of ${t}. You have ${e}. Read our version support policy: https://github.com/visulima/visulima#supported-nodejs-versions`),process.exit(1))},"checkNodeVersion");var tt=Object.defineProperty,ot=c((t,e)=>tt(t,"name",{value:e,configurable:!0}),"r$4");const nt=/^-{1,2}(\w+)(=(\w+))?$/,K=ot((t,e)=>{const o=nt.exec(t);if(o==null)return{};const n=o[1],r=e.find(i=>i.name===n||i.alias===n);return r!==void 0?{argName:r.name,argValue:o[3],option:r}:{}},"getParameterOption");var rt=Object.defineProperty,at=c((t,e)=>rt(t,"name",{value:e,configurable:!0}),"i$3");const b=at(t=>t.type?.name==="Boolean","isBoolean");var it=Object.defineProperty,P=c((t,e)=>it(t,"name",{value:e,configurable:!0}),"n$2");const F=P((t,e)=>{if(e.type===void 0)return t;if(e.type.name==="Boolean"){if(t==="true"||t==="1")return e.type(!0);if(t==="false"||t==="0")return e.type(!1)}return e.type(t)},"convertType"),st=new Set(["0","1","false","true"]),lt=P((t,e)=>{const o=P((n,r)=>{const{argName:i,argValue:a,option:s}=K(r,e),{lastOption:l}=n;return s&&b(s)&&a&&i?n.partial[i]=F(a,s):n.lastName&&l&&b(l)&&st.has(r)&&(n.partial[n.lastName]=F(r,l)),{lastName:i,lastOption:s,partial:n.partial}},"getBooleanValue");return t.reduce(o,{partial:{}}).partial},"getBooleanValues");var ct=Object.defineProperty,Q=c((t,e)=>ct(t,"name",{value:e,configurable:!0}),"p$1");const pt=Q(t=>{let e=t.type?t.type.name.toLowerCase():"string";const o=t.multiple??t.lazyMultiple?"[]":"";return e&&(e=e==="boolean"?"":`{underline ${e}${o}}`),e},"getTypeLabel"),ut=Q(t=>(b(t)||(t.typeLabel=t.typeLabel??pt(t),t.defaultOption&&(t.typeLabel=`${t.typeLabel} (D)`),t.required&&(t.typeLabel=`${t.typeLabel} (R)`)),t),"mapOptionTypeLabel");var mt=Object.defineProperty,Y=c((t,e)=>mt(t,"name",{value:e,configurable:!0}),"s$3");const dt=new Set(["0","1","false","true"]),gt=Y((t,e)=>{const o=Y((n,r)=>{const{argValue:i,option:a}=K(r,e),{lastOption:s}=n;if(s&&b(s)&&dt.has(r)){const l=[...n.args];return l.pop(),{args:l}}return a&&b(a)&&i?{args:n.args}:{args:[...n.args,r],lastOption:a}},"removeBooleanArguments");return t.reduce(o,{args:[]}).args},"removeBooleanValues");var ht=Object.defineProperty,X=c((t,e)=>ht(t,"name",{value:e,configurable:!0}),"e$2");const ft=new RegExp(/^-([^\d-])$/),vt=new RegExp(/^--(\S+)/),yt=new RegExp(/^-([^\d-]{2,})$/),bt=X(t=>ft.test(t)||vt.test(t)||yt.test(t),"isOption"),$t=X((t,e)=>{const o=e[0]&&bt(e[0])||e.length===0?null:e.shift()??null;if(!t.includes(o)){const n=new Error(`Command not recognised: ${o}`);throw n.command=o,n.name="INVALID_COMMAND",n}return{argv:e,command:o}},"commandLineCommands");var wt=Object.defineProperty,Z=c((t,e)=>wt(t,"name",{value:e,configurable:!0}),"i$1");const Et=Z((t,e)=>$e(t,e)<=t.length/3||e.includes(t),"isSimilar"),G=Z((t,e)=>{const o=t.toLowerCase();return e.filter(n=>Et(n.toLowerCase(),o))},"findAlternatives");var Ot=Object.defineProperty,Ct=c((t,e)=>Ot(t,"name",{value:e,configurable:!0}),"t$3");const _t=Ct((t,e)=>t.filter(o=>o.required&&e[o.name]==null).filter(o=>o.type?.name==="Boolean"?(e[o.name]=!1,!1):!0),"listMissingArguments");var At=Object.defineProperty,Nt=c((t,e)=>At(t,"name",{value:e,configurable:!0}),"t$2");const Lt=Nt(t=>{const e=new Map;return t.forEach(o=>{e.set(o.name,{...e.get(o.name),...o})}),[...e.values()]},"mergeArguments");var xt=Object.defineProperty,N=c((t,e)=>xt(t,"name",{value:e,configurable:!0}),"e$1");const jt=N(()=>!!process.versions.electron,"isElectronApp"),Pt=N(()=>jt()&&!process.defaultApp,"isBundledElectronApp"),Rt=N(()=>Pt()?0:1,"getProcessArgvBinIndex"),St=N(t=>t.slice(Rt()+1),"hideBin");var Tt=Object.defineProperty,ee=c((t,e)=>Tt(t,"name",{value:e,configurable:!0}),"i");const Vt=" ",Bt=ee((t,e)=>t.length===e.length&&t.every((o,n)=>o===e[n]),"equals"),kt=ee(t=>typeof t=="string"?t.split(Vt):Bt(t,process.argv)?St(t):t,"parseRawCommand");var Ut=Object.defineProperty,It=c((t,e)=>Ut(t,"name",{value:e,configurable:!0}),"t");const Dt=It(t=>{process.on("uncaughtException",e=>{t.error(`Uncaught exception: ${e}`),e?.stack&&t.error(e.stack),process.exit(1)}),process.on("unhandledRejection",e=>{t.error(`Promise rejection: ${e}`),e?.stack&&t.error(e.stack),process.exit(1)})},"registerExceptionHandler");var Mt=Object.defineProperty,y=c((t,e)=>Mt(t,"name",{value:e,configurable:!0}),"g");const qt="CI"in m&&("GITHUB_ACTIONS"in m||"GITLAB_CI"in m||"CIRCLECI"in m),Ft=y(t=>t.charAt(0).toLowerCase()+t.slice(1),"lowerFirstChar");class oo{static{c(this,"Cli")}static{y(this,"Cli")}logger;argv;cwd;cliName;packageVersion;packageName;extensions=[];commands;defaultCommand;updateNotifierOptions;commandSection;constructor(e,o={}){const{argv:n,cwd:r,packageName:i,packageVersion:a}={argv:B,cwd:ae(),...o};this.argv=kt(n),this.argv.includes("--quiet")||this.argv.includes("-q")?m.CEREBRO_OUTPUT_LEVEL=String(q):this.argv.includes("--verbose")||this.argv.includes("-v")?m.CEREBRO_OUTPUT_LEVEL=String(Je):this.argv.includes("--debug")||this.argv.includes("-vvv")||"DEBUG"in m?m.CEREBRO_OUTPUT_LEVEL=String(j):m.CEREBRO_OUTPUT_LEVEL=String(He);const s={32:"informational",64:"trace",128:"debug"},l=[new ge];m.CEREBRO_OUTPUT_LEVEL===String(j)&&l.push(new he),this.logger=fe({logLevel:m.CEREBRO_OUTPUT_LEVEL?s[m.CEREBRO_OUTPUT_LEVEL]??"informational":"informational",processors:l,...o.logger}),m.CEREBRO_OUTPUT_LEVEL===String(q)&&this.logger.disable(),et(),Dt(this.logger),this.cliName=e,this.packageVersion=a,this.packageName=i,this.cwd=r,this.defaultCommand="help",this.commandSection={header:`${this.cliName}${this.packageVersion?` v${this.packageVersion}`:""}`},this.commands=new Map,this.addCoreExtensions(),this.addCommand(We),this.addCommand(new Fe(this.commands))}setCommandSection(e){return this.commandSection=e,this}getCommandSection(){return this.commandSection}setDefaultCommand(e){return this.defaultCommand=e,this}addCommand(e){if(this.commands.has(e.name))throw new Error(`Ignored command with name "${e.name}", it was found in the command list.`);if(e.options?.map(o=>ut(o)),this.validateDoubleOptions(e),this.addNegatableOption(e),e.options?.forEach(o=>{o.__camelCaseName__=H(o.name)}),this.commands.set(e.name,e),e.alias!==void 0){let o=e.alias;typeof e.alias=="string"&&(o=[e.alias]),o.forEach(n=>{if(this.logger.debug("adding alias",n),this.commands.has(n))throw new Error(`Ignoring command alias "${n}, command with the same name was found."`);this.commands.set(n,e)})}return this}addExtension(e){return this.extensions.push(e),this}enableUpdateNotifier(e={}){if(!this.packageName||!this.packageVersion)throw new Error("Cannot enable update notifier without package name and version.");const o=Object.keys(e);if(o.length>0&&!o.includes("alwaysRun")&&!o.includes("distTag")&&!o.includes("updateCheckInterval"))throw new Error("Invalid update notifier options, please check the documentation.");return this.updateNotifierOptions={alwaysRun:!1,debug:m.CEREBRO_OUTPUT_LEVEL===String(j),distTag:"latest",pkg:{name:this.packageName,version:this.packageVersion},updateCheckInterval:1e3*60*60*24,...e},this}getCliName(){return this.cliName}getPackageVersion(){return this.packageVersion}getPackageName(){return this.packageName}getCommands(){return this.commands}getCwd(){return this.cwd}async run(e={}){const{shouldExitProcess:o=!0,...n}=e,r=[...this.commands.keys()];let i;this.logger.debug(`process.execPath: ${ie}`),this.logger.debug(`process.execArgv: ${se.join(" ")}`),this.logger.debug(`process.argv: ${B.join(" ")}`);try{i=$t([null,...r],this.argv)}catch(h){if(h.name==="INVALID_COMMAND"&&h.command){let T="";const V=G(h.command,[...this.commands.keys()]);V.length>0&&(T=` Did you mean: \r
|
|
7
|
+
- ${V.join(` \r
|
|
8
|
+
- `)}`),this.logger.error(`"${h.command}" is not an available command.${T}`)}else this.logger.error(h);return o?x(1):void 0}const a=i.command??this.defaultCommand,s=this.commands.get(a);if(typeof s.execute!="function")return this.logger.error(`Command "${s.name}" has no function to execute.`),o?x(1):void 0;const l=i.argv;this.logger.debug(`command '${a}' found, parsing command args: ${l.join(", ")}`);let p=Lt([...s.options??[],...C]);p.forEach(h=>{if(h.multiple&&h.lazyMultiple)throw new Error(`Argument "${h.name}" cannot have both multiple and lazyMultiple options, please choose one.`)}),s.argument&&(this.logger.debug("command has positional argument, parsing them..."),p=[{defaultOption:!0,description:s.argument?.description,group:"positionals",multiple:!0,name:E,type:s.argument?.type,typeLabel:s.argument?.typeLabel},...p]);const g=ve(p,{argv:gt(l,s.options??[]),camelCase:!0,partial:!0,stopAtFirstUnknown:!0}),$=lt(l,s.options??[]),v={...g,_all:{...g._all,...$}};this.validateCommandOptions(p,v,s);const d=new Qe(s.name,s);d.runtime=this,await this.registerExtensions(d),await this.updateNotifier(d);const{_all:L,positionals:te}=v;return L[E]&&delete L[E],d.argument=te?.[E]??[],d.argv=this.argv,d.options={...L,...n},this.mapNegatableOptions(d,s),this.mapImpliesOptions(d,s),this.validateCommandArgsForConflicts(p,d.options,s),this.logger.debug("command options parsed from options:"),this.logger.debug(JSON.stringify(d.options,null,2)),this.logger.debug("command argument parsed from argument:"),this.logger.debug(JSON.stringify(d.argument,null,2)),await this.prepareToolboxResult(v,d,s),o?x(0):void 0}validateDoubleOptions(e){if(Array.isArray(e.options)){const o=e.options.reduce((i,a)=>{const s=`${a.name}-${a.alias}`;return i[s]||(i[s]=[]),i[s].push(a),i},{}),n=Object.values(o).filter(i=>i.length>1);let r="";if(n.forEach(i=>{const a=i[0],s=i[1];let l="alias";a.name===s.name&&(l="name",a.alias===s.alias&&(l+=" and alias")),r+=`Cannot add option ${l} "${JSON.stringify(s)}" to command "${e.name}" due to conflicting option ${JSON.stringify(a)}
|
|
9
|
+
`}),r.length>0)throw new Error(r)}}addCoreExtensions(){this.addExtension({execute:y(e=>{e.logger=this.logger},"execute"),name:"logger"})}async prepareToolboxResult(e,o,n){if(e.global?.help){this.logger.debug("'--help' option found, running 'help' for given command...");const r=this.commands.get("help");if(!r)throw new Error("Help command not found.");await r.execute(o);return}if(e.global?.version||e.global?.V){this.logger.debug("'--version' option found, running 'version' for given command...");const r=this.commands.get("version");if(!r)throw new Error("Version command not found.");await r.execute(o);return}await n.execute(o)}async updateNotifier({logger:e}){if(this.updateNotifierOptions?.alwaysRun||!(m.NO_UPDATE_NOTIFIER||m.NODE_ENV==="test"||this.argv.includes("--no-update-notifier")||qt)&&this.updateNotifierOptions){e.raw("Checking for updates...");const o=await(await import("../packem_chunks/has-new-version.mjs").then(n=>n.default))(this.updateNotifierOptions);if(o){const n=`Update available ${pe(`${this.packageVersion}`)}${ue(" → ")}${me(o)}`;this.logger.error(le(n,{borderColor:y(r=>de(r),"borderColor"),borderStyle:"round",margin:1,padding:1,textAlignment:"center"}))}}}validateCommandOptions(e,o,n){const r=_t(e,o);if(r.length>0)throw new Error(`You called the command "${n.name}" without the required options: ${r.map(i=>i.name).join(", ")}`);if(o._unknown&&o._unknown.length>0){const i=[];if(o._unknown.forEach(a=>{const s=a.startsWith("--");let l=`Found unknown ${s?"option":"argument"} "${a}"`;if(s){const p=G(a.replace("--",""),[...(n.options??[]).map(g=>g.name),...C.map(g=>g.name)]);if(p.length>0){const[g,...$]=p.map(v=>`--${v}`);l+=$.length>0?`, did you mean ${g} or ${$.join(", ")}?`:`, did you mean ${g}?`}}i.push(l)}),i.length>0)throw new Error(i.join(`
|
|
10
|
+
`))}}validateCommandArgsForConflicts(e,o,n){const r=e.filter(i=>i.conflicts!==void 0);if(r.length>0){const i=r.find(a=>Array.isArray(a.conflicts)?a.conflicts.some(s=>o[s]!==void 0)&&o[a.name]!==void 0:o[a.conflicts]!==void 0&&o[a.name]!==void 0);if(i)throw new Error(`You called the command "${n.name}" with conflicting options: ${i.name} and ${typeof i.conflicts=="string"?i.conflicts:i.conflicts?.join(", ")}`)}}addNegatableOption(e){Array.isArray(e.options)&&e.options.forEach(o=>{if(o.name.startsWith("no-")&&!e.options.some(n=>n.name===o.name.replace("no-",""))){if(o.type!==Boolean){this.logger.debug(`Cannot add negated option "${o.name}" to command "${e.name}" because it is not a boolean.`);return}const n={...o,defaultValue:o.defaultValue===void 0?!0:!o.defaultValue,name:`${o.name.replace("no-","")}`};e.options.push(n)}})}async registerExtensions(e){const o=y(async n=>typeof n.execute!="function"?(this.logger.warn(`Skipped ${n.name} because execute is not a function.`),null):(await n.execute(e),null),"callback");for(const n of this.extensions)await o(n)}mapNegatableOptions(e,o){Object.entries(e.options).forEach(([n,r])=>{if(/^no\w+/.test(n)){const i=Ft(n.replace("no",""));this.logger.debug(`mapping negated option "${n}" to "${i}"`),e.options[i]=!r,o.options?.forEach(a=>{a.name===i&&(a.__negated__=!0)})}})}mapImpliesOptions(e,o){Object.keys(e.options).forEach(n=>{const r=o.options?.find(i=>i.__camelCaseName__===n&&i.__negated__===void 0&&i.implies!==void 0);if(r?.implies){const i=r.implies;Object.entries(i).forEach(([a,s])=>{if(e.options[a]===void 0)e.options[a]=s;else{const l=o.options?.find(p=>p.name===a);(l?.defaultValue===void 0||e.options[a]===l.defaultValue)&&(e.options[a]=s)}})}})}}export{oo as Cli};
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
"use strict";var ne=Object.create;var P=Object.defineProperty;var oe=Object.getOwnPropertyDescriptor;var re=Object.getOwnPropertyNames;var ae=Object.getPrototypeOf,ie=Object.prototype.hasOwnProperty;var c=(t,e)=>P(t,"name",{value:e,configurable:!0});var se=(t,e,n,o)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of re(e))!ie.call(t,r)&&r!==n&&P(t,r,{get:()=>e[r],enumerable:!(o=oe(e,r))||o.enumerable});return t};var le=(t,e,n)=>(n=t!=null?ne(ae(t)):{},se(e||!t||!t.__esModule?P(n,"default",{value:t,enumerable:!0}):n,t));Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const p=require("node:process"),ce=require("@visulima/boxen"),v=require("@visulima/colorize"),B=require("@visulima/pail/processor"),pe=require("@visulima/pail/server"),ue=require("command-line-args"),de=require("cli-table3"),me=require("@visulima/colorize/template"),ge=require("node:os"),he=require("fastest-levenshtein"),_=c(t=>t&&typeof t=="object"&&"default"in t?t.default:t,"_interopDefaultCompat"),fe=_(ue),O=_(de),ve=_(me),ye=_(ge);var be=Object.defineProperty,A=c((t,e)=>be(t,"name",{value:e,configurable:!0}),"f$
|
|
1
|
+
"use strict";var ne=Object.create;var P=Object.defineProperty;var oe=Object.getOwnPropertyDescriptor;var re=Object.getOwnPropertyNames;var ae=Object.getPrototypeOf,ie=Object.prototype.hasOwnProperty;var c=(t,e)=>P(t,"name",{value:e,configurable:!0});var se=(t,e,n,o)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of re(e))!ie.call(t,r)&&r!==n&&P(t,r,{get:()=>e[r],enumerable:!(o=oe(e,r))||o.enumerable});return t};var le=(t,e,n)=>(n=t!=null?ne(ae(t)):{},se(e||!t||!t.__esModule?P(n,"default",{value:t,enumerable:!0}):n,t));Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const p=require("node:process"),ce=require("@visulima/boxen"),v=require("@visulima/colorize"),B=require("@visulima/pail/processor"),pe=require("@visulima/pail/server"),ue=require("command-line-args"),de=require("cli-table3"),me=require("@visulima/colorize/template"),ge=require("node:os"),he=require("fastest-levenshtein"),_=c(t=>t&&typeof t=="object"&&"default"in t?t.default:t,"_interopDefaultCompat"),fe=_(ue),O=_(de),ve=_(me),ye=_(ge);var be=Object.defineProperty,A=c((t,e)=>be(t,"name",{value:e,configurable:!0}),"f$4");const $e=/[\p{Lu}]/u,we=/[\p{Ll}]/u,k=/^[\p{Lu}](?![\p{Lu}])/gu,W=/([\p{Alpha}\p{N}_]|$)/u,R=/[_.\- ]+/,Ee=new RegExp("^"+R.source),U=new RegExp(R.source+W.source,"gu"),I=new RegExp("\\d+"+W.source,"gu"),Oe=A((t,e,n,o)=>{let r=!1,i=!1,a=!1,s=!1;for(let l=0;l<t.length;l++){const u=t[l];s=l>2?t[l-3]==="-":!0,r&&$e.test(u)?(t=t.slice(0,l)+"-"+t.slice(l),r=!1,a=i,i=!0,l++):i&&a&&we.test(u)&&(!s||o)?(t=t.slice(0,l-1)+"-"+t.slice(l-1),a=i,i=!1,r=!0):(r=e(u)===u&&n(u)!==u,a=i,i=n(u)===u&&e(u)!==u)}return t},"preserveCamelCase"),Ce=A((t,e)=>(k.lastIndex=0,t.replaceAll(k,n=>e(n))),"preserveConsecutiveUppercase"),_e=A((t,e)=>(U.lastIndex=0,I.lastIndex=0,t.replaceAll(I,(n,o,r)=>["_","-"].includes(t.charAt(r+n.length))?n:e(n)).replaceAll(U,(n,o)=>e(o))),"postProcess");function H(t,e){if(!(typeof t=="string"||Array.isArray(t)))throw new TypeError("Expected the input to be `string | string[]`");if(e={pascalCase:!1,preserveConsecutiveUppercase:!1,...e},Array.isArray(t)?t=t.map(r=>r.trim()).filter(r=>r.length).join("-"):t=t.trim(),t.length===0)return"";const n=e.locale===!1?r=>r.toLowerCase():r=>r.toLocaleLowerCase(e.locale),o=e.locale===!1?r=>r.toUpperCase():r=>r.toLocaleUpperCase(e.locale);return t.length===1?R.test(t)?"":e.pascalCase?o(t):n(t):(t!==n(t)&&(t=Oe(t,n,o,e.preserveConsecutiveUppercase)),t=t.replace(Ee,""),t=e.preserveConsecutiveUppercase?Ce(t,n):n(t),e.pascalCase&&(t=o(t.charAt(0))+t.slice(1)),_e(t,o))}c(H,"S");A(H,"camelCase");const C=[{description:"Turn on verbose output",group:"global",name:"verbose",type:Boolean},{description:"Turn on debugging output",group:"global",name:"debug",type:Boolean},{alias:"h",description:"Print out helpful usage information",group:"global",name:"help",type:Boolean},{alias:"q",description:"Silence output",group:"global",name:"quiet",type:Boolean},{alias:"V",description:"Print version info",group:"global",name:"version",type:Boolean},{description:"Turn off colored output",group:"global",name:"no-color",type:Boolean},{description:"Force colored output",group:"global",name:"color",type:Boolean}];var Ae=Object.defineProperty,Ne=c((t,e)=>Ae(t,"name",{value:e,configurable:!0}),"e$4");const d=Ne(t=>t?ve(Object.assign([],{raw:[t.replaceAll("`","\\`")]})):"","templateFormat");var Le=Object.defineProperty,xe=c((t,e)=>Le(t,"name",{value:e,configurable:!0}),"t$6");let J=class{static{c(this,"n")}static{xe(this,"BaseSection")}lines;constructor(){this.lines=[]}add(e){this.lines.push(e)}toString(){return this.lines.join(ye.EOL)}header(e){this.add(v.bold(e)),this.lines.push("")}};var Pe=Object.defineProperty,Se=c((t,e)=>Pe(t,"name",{value:e,configurable:!0}),"p$4");const w={chars:{bottom:"","bottom-left":"","bottom-mid":"","bottom-right":"",left:" ","left-mid":"",mid:"","mid-mid":"",middle:" ",right:"","right-mid":"",top:"","top-left":"","top-mid":"","top-right":""},colWidths:[40,60],style:{border:[],compact:!0,head:[],"padding-left":2,"padding-right":1},wordWrap:!0};let je=class extends J{static{c(this,"y")}static{Se(this,"ContentSection")}constructor(e){if(super(),e.header&&this.header(d(e.header)),e.content){if(e.raw)if(Array.isArray(e.content)&&e.content.every(n=>typeof n=="string"))e.content.forEach(n=>{Array.isArray(n)?n.forEach(o=>this.add(d(o))):this.add(d(n))});else if(typeof e.content=="string")this.add(d(e.content));else throw new TypeError("Invalid raw content, must be a string or array of strings.");else this.add(this.getContentLines(e.content));this.add("")}}getContentLines(e){if(typeof e=="string"){const n=new O({...w,colWidths:[80]});return n.push([d(e)]),n.toString()}if(Array.isArray(e)&&e.every(n=>typeof n=="string"||Array.isArray(n)&&n.every(o=>typeof o=="string"))){const n=new O({...w});return e.forEach(o=>{Array.isArray(o)?n.push(o.map(r=>d(r))):n.push([d(o)])}),n.toString()}if(typeof e=="object"){const n=e;if(!n.options||!n.data)throw new Error(`Must have an "options" or "data" property
|
|
2
2
|
${JSON.stringify(e)}`);const o=new O({...w,...n.options,style:{...w.style,...n.options.style}});return n.data.forEach(r=>{Array.isArray(r)?o.push(r.map(i=>d(i))):o.push([d(r)])}),o.toString()}throw new Error(`invalid input - 'content' must be a string, array of strings or a object:
|
|
3
3
|
|
|
4
4
|
${JSON.stringify(e)}`)}};var Re=Object.defineProperty,Te=c((t,e)=>Re(t,"name",{value:e,configurable:!0}),"a$1");let Ve=class extends J{static{c(this,"c")}static{Te(this,"OptionListSection")}constructor(e){super();let n=e.optionList??[];const o=Array.isArray(e.hide)?e.hide:[e.hide].filter(Boolean),r=Array.isArray(e.group)?e.group:[e.group].filter(Boolean);o.length>0&&(n=n.filter(a=>!o.includes(a.name))),e.header&&this.header(d(e.header)),r.length>0&&(n=n.filter(a=>{const s=r.includes("_none")&&!a.group,l=this.intersect(Array.isArray(a.group)?a.group:[a.group],r);return s||l?a:void 0}));const i=new O({chars:{bottom:"","bottom-left":"","bottom-mid":"","bottom-right":"",left:" ","left-mid":"",mid:"","mid-mid":"",middle:" ",right:"","right-mid":"",top:"","top-left":"","top-mid":"","top-right":""},colWidths:[40,40],style:{"padding-left":2,"padding-right":1},wordWrap:!0});n.forEach(a=>i.push([this.getOptionNames(a,e.reverseNameOrder??!1,e.isArgument??!1),d(a.description)])),this.add(i.toString()),this.lines.push("")}getOptionNames(e,n,o){if(!e.name)throw new TypeError("Invalid option definition, name is required.");let r=e.type?e.type.name.toLowerCase():"string";const i=e.multiple||e.lazyMultiple?"[]":"";r=d(e.typeLabel??`{underline ${r}${i}}`);let a;if(e.alias)if(e.name){const s=o?e.name:`{yellow --${e.name}}`;a=d(n?`{bold ${s}}, {bold -${e.alias}} ${r}`:`{bold -${e.alias}}, {bold ${s}} ${r}`)}else n?a=d(`{bold -${e.alias}} ${r}`):a=d(`{bold -${e.alias}} ${r}`);else a=d(`{bold ${o?e.name:`{yellow --${e.name}}`}} ${r}`);return a}intersect(e,n){return e.some(o=>n.includes(o))}};var Be=Object.defineProperty,ke=c((t,e)=>Be(t,"name",{value:e,configurable:!0}),"o$3");const z=ke(t=>(Array.isArray(t)?t:[t]).length===0?"":`
|
|
5
5
|
${t.map(e=>e.optionList?new Ve(e).toString():new je(e).toString()).join(`
|
|
6
|
-
`)}`,"commandLineUsage");var Ue=Object.defineProperty,N=c((t,e)=>Ue(t,"name",{value:e,configurable:!0}),"l$5");const D="__Other",M=N(t=>t.charAt(0).toUpperCase()+t.slice(1),"upperFirstChar"),Ie=N((t,e,n,o)=>{t.debug("no command given, printing general help...");let r=[...new Set(n.values())].filter(a=>!a.hidden);o&&(r=r.filter(a=>a.group===o));const i=r.reduce((a,s)=>{const l=s.group??D;return a[l]||(a[l]=[]),a[l].push(s),a},{});t.raw(z([{content:`{cyan ${e.getCliName()}} {green <command>} [positional arguments] {yellow [options]}`,header:"{inverse.cyan Usage }"},...Object.keys(i).map(a=>({content:i[a].map(s=>{let l="";return typeof s.alias=="string"?l=s.alias:Array.isArray(s.alias)&&(l=s.alias.join(", ")),l!==""&&(l=` [${l}]`),[`{green ${s.name}} ${l}`,s.description??""]}),header:a===D||o?`{inverse.green Available${o?` ${M(o)}`:""} Commands }`:` {inverse.green ${M(a)} }`})),n.has("help")?{header:"{inverse.yellow Command Options }",optionList:n.get("help").options?.filter(a=>!a.hidden)}:void 0,{header:"{inverse.yellow Global Options }",optionList:C},{content:`Run "{cyan ${e.getCliName()}} {green help <command>}" or "{cyan ${e.getCliName()}} {green <command>} {yellow --help}" for help with a specific command.`,raw:!0}].filter(Boolean)))},"printGeneralHelp"),De=N((t,e,n,o)=>{const r=n.get(o),i=[];if(i.push({content:`{cyan ${e.getCliName()}} {green ${r.name}}${r.argument?" [positional arguments]":""}${r.options?" [options]":""}`,header:"{inverse.cyan Usage }"}),r.description&&i.push({content:r.description,header:"{inverse.green Description }"}),r.argument&&i.push({header:"Command Positional Arguments",isArgument:!0,optionList:[r.argument]}),Array.isArray(r.options)&&r.options.length>0&&i.push({header:"{inverse.yellow Command Options }",optionList:r.options.filter(a=>!a.hidden)}),i.push({header:"{inverse.yellow Global Options }",optionList:C}),r.alias!==void 0&&r.alias.length>0){let a=r.alias;typeof r.alias=="string"&&(a=[r.alias]),i.splice(1,0,{content:a,header:"Alias(es)"})}Array.isArray(r.examples)&&r.examples.length>0&&i.push({content:r.examples,header:"Examples"}),t.raw(z(i))},"printCommandHelp");class Me{static{c(this,"C")}static{N(this,"HelpCommand")}name="help";options=[{description:"Display only the specified group",name:"group",type:String}];commands;constructor(e){this.commands=e}execute(e){const{commandName:n,logger:o,options:r,runtime:i}=e,{footer:a,header:s}=i.getCommandSection();s&&o.raw(d(s)),n==="help"?Ie(o,i,this.commands,r?.group):De(o,i,this.commands,n),a&&o.raw(d(a))}}var qe=Object.defineProperty,Fe=c((t,e)=>qe(t,"name",{value:e,configurable:!0}),"s$7");const Ye={alias:["v","V"],description:"Output the version number",execute:Fe(({logger:t,runtime:e})=>{const n=e.getPackageVersion();n===void 0?(t.warn("Unknown version"),t.debug("The version number was not provided by the cli constructor.")):t.info(n)},"execute"),name:"version",options:[],usage:[]},q=16,Ge=32,We=64,S=128,E="positionals";var He=Object.defineProperty,Je=c((t,e)=>He(t,"name",{value:e,configurable:!0}),"m$2");let ze=class{static{c(this,"c")}static{Je(this,"EmptyToolbox")}result;argv;options;argument;command;commandName;runtime;logger;constructor(e,n){this.commandName=e,this.command=n}};var Ke=Object.defineProperty,Qe=c((t,e)=>Ke(t,"name",{value:e,configurable:!0}),"s$6");const Xe=Qe(()=>{const t=process.env.CEREBRO_MIN_NODE_VERSION?Number(process.env.CEREBRO_MIN_NODE_VERSION):18,e=process.version.replace("v","");Number(/v([^.]+)/.exec(process.version)[1])<t&&(console.log(`cerebro supports a minimum Node version of ${t}. You have ${e}. Read our version support policy: https://github.com/visulima/visulima#supported-nodejs-versions`),process.exit(1))},"checkNodeVersion");var Ze=Object.defineProperty,et=c((t,e)=>Ze(t,"name",{value:e,configurable:!0}),"r$4");const tt=/^-{1,2}(\w+)(=(\w+))?$/,K=et((t,e)=>{const n=tt.exec(t);if(n==null)return{};const o=n[1],r=e.find(i=>i.name===o||i.alias===o);return r!==void 0?{argName:r.name,argValue:n[3],option:r}:{}},"getParameterOption");var nt=Object.defineProperty,ot=c((t,e)=>nt(t,"name",{value:e,configurable:!0}),"i$3");const b=ot(t=>t.type?.name==="Boolean","isBoolean");var rt=Object.defineProperty,j=c((t,e)=>rt(t,"name",{value:e,configurable:!0}),"n$2");const F=j((t,e)=>{if(e.type===void 0)return t;if(e.type.name==="Boolean"){if(t==="true"||t==="1")return e.type(!0);if(t==="false"||t==="0")return e.type(!1)}return e.type(t)},"convertType"),at=new Set(["1","0","true","false"]),it=j((t,e)=>{const n=j((o,r)=>{const{argName:i,argValue:a,option:s}=K(r,e),{lastOption:l}=o;return s&&b(s)&&a&&i?o.partial[i]=F(a,s):o.lastName&&l&&b(l)&&at.has(r)&&(o.partial[o.lastName]=F(r,l)),{lastName:i,lastOption:s,partial:o.partial}},"getBooleanValue");return t.reduce(n,{partial:{}}).partial},"getBooleanValues");var st=Object.defineProperty,Q=c((t,e)=>st(t,"name",{value:e,configurable:!0}),"p$1");const lt=Q(t=>{let e=t.type?t.type.name.toLowerCase():"string";const n=t.multiple??t.lazyMultiple?"[]":"";return e&&(e=e==="boolean"?"":`{underline ${e}${n}}`),e},"getTypeLabel"),ct=Q(t=>(b(t)||(t.typeLabel=t.typeLabel??lt(t),t.defaultOption&&(t.typeLabel=`${t.typeLabel} (D)`),t.required&&(t.typeLabel=`${t.typeLabel} (R)`)),t),"mapOptionTypeLabel");var pt=Object.defineProperty,Y=c((t,e)=>pt(t,"name",{value:e,configurable:!0}),"s$3");const ut=new Set(["1","0","true","false"]),dt=Y((t,e)=>{const n=Y((o,r)=>{const{argValue:i,option:a}=K(r,e),{lastOption:s}=o;if(s&&b(s)&&ut.has(r)){const l=[...o.args];return l.pop(),{args:l}}return a&&b(a)&&i?{args:o.args}:{args:[...o.args,r],lastOption:a}},"removeBooleanArguments");return t.reduce(n,{args:[]}).args},"removeBooleanValues");var mt=Object.defineProperty,X=c((t,e)=>mt(t,"name",{value:e,configurable:!0}),"e$2");const gt=new RegExp(/^-([^\d-])$/),ht=new RegExp(/^--(\S+)/),ft=new RegExp(/^-([^\d-]{2,})$/),vt=X(t=>gt.test(t)||ht.test(t)||ft.test(t),"isOption"),yt=X((t,e)=>{const n=e[0]&&vt(e[0])||e.length===0?null:e.shift()??null;if(!t.includes(n)){const o=new Error(`Command not recognised: ${n}`);throw o.command=n,o.name="INVALID_COMMAND",o}return{argv:e,command:n}},"commandLineCommands");var bt=Object.defineProperty,Z=c((t,e)=>bt(t,"name",{value:e,configurable:!0}),"i$1");const $t=Z((t,e)=>he.distance(t,e)<=t.length/3||e.includes(t),"isSimilar"),G=Z((t,e)=>{const n=t.toLowerCase();return e.filter(o=>$t(o.toLowerCase(),n))},"findAlternatives");var wt=Object.defineProperty,Et=c((t,e)=>wt(t,"name",{value:e,configurable:!0}),"t$3");const Ot=Et((t,e)=>t.filter(n=>n.required&&e[n.name]==null).filter(n=>n.type?.name==="Boolean"?(e[n.name]=!1,!1):!0),"listMissingArguments");var Ct=Object.defineProperty,_t=c((t,e)=>Ct(t,"name",{value:e,configurable:!0}),"t$2");const At=_t(t=>{const e=new Map;return t.forEach(n=>{e.set(n.name,{...e.get(n.name),...n})}),[...e.values()]},"mergeArguments");var Nt=Object.defineProperty,L=c((t,e)=>Nt(t,"name",{value:e,configurable:!0}),"e$1");const Lt=L(()=>!!process.versions.electron,"isElectronApp"),xt=L(()=>Lt()&&!process.defaultApp,"isBundledElectronApp"),Pt=L(()=>xt()?0:1,"getProcessArgvBinIndex"),St=L(t=>t.slice(Pt()+1),"hideBin");var jt=Object.defineProperty,ee=c((t,e)=>jt(t,"name",{value:e,configurable:!0}),"i");const Rt=" ",Tt=ee((t,e)=>t.length===e.length&&t.every((n,o)=>n===e[o]),"equals"),Vt=ee(t=>typeof t=="string"?t.split(Rt):Tt(t,process.argv)?St(t):t,"parseRawCommand");var Bt=Object.defineProperty,kt=c((t,e)=>Bt(t,"name",{value:e,configurable:!0}),"t");const Ut=kt(t=>{process.on("uncaughtException",e=>{t.error(`Uncaught exception: ${e}`),e?.stack&&t.error(e.stack),process.exit(1)}),process.on("unhandledRejection",e=>{t.error(`Promise rejection: ${e}`),e?.stack&&t.error(e.stack),process.exit(1)})},"registerExceptionHandler");var It=Object.defineProperty,y=c((t,e)=>It(t,"name",{value:e,configurable:!0}),"g");const Dt="CI"in p.env&&("GITHUB_ACTIONS"in p.env||"GITLAB_CI"in p.env||"CIRCLECI"in p.env),Mt=y(t=>t.charAt(0).toLowerCase()+t.slice(1),"lowerFirstChar");class qt{static{c(this,"Cli")}static{y(this,"Cli")}logger;argv;cwd;cliName;packageVersion;packageName;extensions=[];commands;defaultCommand;updateNotifierOptions;commandSection;constructor(e,n={}){const{argv:o,cwd:r,packageName:i,packageVersion:a}={argv:p.argv,cwd:p.cwd(),...n};this.argv=Vt(o),this.argv.includes("--quiet")||this.argv.includes("-q")?p.env.CEREBRO_OUTPUT_LEVEL=String(q):this.argv.includes("--verbose")||this.argv.includes("-v")?p.env.CEREBRO_OUTPUT_LEVEL=String(We):this.argv.includes("--debug")||this.argv.includes("-vvv")||"DEBUG"in p.env?p.env.CEREBRO_OUTPUT_LEVEL=String(S):p.env.CEREBRO_OUTPUT_LEVEL=String(Ge);const s={32:"informational",64:"trace",128:"debug"},l=[new B.MessageFormatterProcessor];p.env.CEREBRO_OUTPUT_LEVEL===String(S)&&l.push(new B.CallerProcessor),this.logger=pe.createPail({logLevel:p.env.CEREBRO_OUTPUT_LEVEL?s[p.env.CEREBRO_OUTPUT_LEVEL]??"informational":"informational",processors:l,...n.logger}),p.env.CEREBRO_OUTPUT_LEVEL===String(q)&&this.logger.disable(),Xe(),Ut(this.logger),this.cliName=e,this.packageVersion=a,this.packageName=i,this.cwd=r,this.defaultCommand="help",this.commandSection={header:`${this.cliName}${this.packageVersion?` v${this.packageVersion}`:""}`},this.commands=new Map,this.addCoreExtensions(),this.addCommand(Ye),this.addCommand(new Me(this.commands))}setCommandSection(e){return this.commandSection=e,this}getCommandSection(){return this.commandSection}setDefaultCommand(e){return this.defaultCommand=e,this}addCommand(e){if(this.commands.has(e.name))throw new Error(`Ignored command with name "${e.name}", it was found in the command list.`);if(e.options?.map(n=>ct(n)),this.validateDoubleOptions(e),this.addNegatableOption(e),e.options?.forEach(n=>{n.__camelCaseName__=H(n.name)}),this.commands.set(e.name,e),e.alias!==void 0){let n=e.alias;typeof e.alias=="string"&&(n=[e.alias]),n.forEach(o=>{if(this.logger.debug("adding alias",o),this.commands.has(o))throw new Error(`Ignoring command alias "${o}, command with the same name was found."`);this.commands.set(o,e)})}return this}addExtension(e){return this.extensions.push(e),this}enableUpdateNotifier(e={}){if(!this.packageName||!this.packageVersion)throw new Error("Cannot enable update notifier without package name and version.");const n=Object.keys(e);if(n.length>0&&!n.includes("alwaysRun")&&!n.includes("distTag")&&!n.includes("updateCheckInterval"))throw new Error("Invalid update notifier options, please check the documentation.");return this.updateNotifierOptions={alwaysRun:!1,debug:p.env.CEREBRO_OUTPUT_LEVEL===String(S),distTag:"latest",pkg:{name:this.packageName,version:this.packageVersion},updateCheckInterval:1e3*60*60*24,...e},this}getCliName(){return this.cliName}getPackageVersion(){return this.packageVersion}getPackageName(){return this.packageName}getCommands(){return this.commands}getCwd(){return this.cwd}async run(e={}){const{shouldExitProcess:n=!0,...o}=e,r=[...this.commands.keys()];let i;this.logger.debug(`process.execPath: ${p.execPath}`),this.logger.debug(`process.execArgv: ${p.execArgv.join(" ")}`),this.logger.debug(`process.argv: ${p.argv.join(" ")}`);try{i=yt([null,...r],this.argv)}catch(h){if(h.name==="INVALID_COMMAND"&&h.command){let T="";const V=G(h.command,[...this.commands.keys()]);V.length>0&&(T=` Did you mean: \r
|
|
6
|
+
`)}`,"commandLineUsage");var Ue=Object.defineProperty,N=c((t,e)=>Ue(t,"name",{value:e,configurable:!0}),"l$5");const D="__Other",M=N(t=>t.charAt(0).toUpperCase()+t.slice(1),"upperFirstChar"),Ie=N((t,e,n,o)=>{t.debug("no command given, printing general help...");let r=[...new Set(n.values())].filter(a=>!a.hidden);o&&(r=r.filter(a=>a.group===o));const i=r.reduce((a,s)=>{const l=s.group??D;return a[l]||(a[l]=[]),a[l].push(s),a},{});t.raw(z([{content:`{cyan ${e.getCliName()}} {green <command>} [positional arguments] {yellow [options]}`,header:"{inverse.cyan Usage }"},...Object.keys(i).map(a=>({content:i[a].map(s=>{let l="";return typeof s.alias=="string"?l=s.alias:Array.isArray(s.alias)&&(l=s.alias.join(", ")),l!==""&&(l=` [${l}]`),[`{green ${s.name}} ${l}`,s.description??""]}),header:a===D||o?`{inverse.green Available${o?` ${M(o)}`:""} Commands }`:` {inverse.green ${M(a)} }`})),n.has("help")?{header:"{inverse.yellow Command Options }",optionList:n.get("help").options?.filter(a=>!a.hidden)}:void 0,{header:"{inverse.yellow Global Options }",optionList:C},{content:`Run "{cyan ${e.getCliName()}} {green help <command>}" or "{cyan ${e.getCliName()}} {green <command>} {yellow --help}" for help with a specific command.`,raw:!0}].filter(Boolean)))},"printGeneralHelp"),De=N((t,e,n,o)=>{const r=n.get(o),i=[];if(i.push({content:`{cyan ${e.getCliName()}} {green ${r.name}}${r.argument?" [positional arguments]":""}${r.options?" [options]":""}`,header:"{inverse.cyan Usage }"}),r.description&&i.push({content:r.description,header:"{inverse.green Description }"}),r.argument&&i.push({header:"Command Positional Arguments",isArgument:!0,optionList:[r.argument]}),Array.isArray(r.options)&&r.options.length>0&&i.push({header:"{inverse.yellow Command Options }",optionList:r.options.filter(a=>!a.hidden)}),i.push({header:"{inverse.yellow Global Options }",optionList:C}),r.alias!==void 0&&r.alias.length>0){let a=r.alias;typeof r.alias=="string"&&(a=[r.alias]),i.splice(1,0,{content:a,header:"Alias(es)"})}Array.isArray(r.examples)&&r.examples.length>0&&i.push({content:r.examples,header:"Examples"}),t.raw(z(i))},"printCommandHelp");class Me{static{c(this,"C")}static{N(this,"HelpCommand")}name="help";options=[{description:"Display only the specified group",name:"group",type:String}];commands;constructor(e){this.commands=e}execute(e){const{commandName:n,logger:o,options:r,runtime:i}=e,{footer:a,header:s}=i.getCommandSection();s&&o.raw(d(s)),n==="help"?Ie(o,i,this.commands,r?.group):De(o,i,this.commands,n),a&&o.raw(d(a))}}var qe=Object.defineProperty,Fe=c((t,e)=>qe(t,"name",{value:e,configurable:!0}),"s$7");const Ye={alias:["v","V"],description:"Output the version number",execute:Fe(({logger:t,runtime:e})=>{const n=e.getPackageVersion();n===void 0?(t.warn("Unknown version"),t.debug("The version number was not provided by the cli constructor.")):t.info(n)},"execute"),name:"version",options:[],usage:[]},q=16,Ge=32,We=64,S=128,E="positionals";var He=Object.defineProperty,Je=c((t,e)=>He(t,"name",{value:e,configurable:!0}),"m$2");let ze=class{static{c(this,"c")}static{Je(this,"EmptyToolbox")}result;argv;options;argument;command;commandName;runtime;logger;constructor(e,n){this.commandName=e,this.command=n}};var Ke=Object.defineProperty,Qe=c((t,e)=>Ke(t,"name",{value:e,configurable:!0}),"s$6");const Xe=Qe(()=>{const t=process.env.CEREBRO_MIN_NODE_VERSION?Number(process.env.CEREBRO_MIN_NODE_VERSION):18,e=process.version.replace("v","");Number(/v([^.]+)/.exec(process.version)[1])<t&&(console.log(`cerebro supports a minimum Node version of ${t}. You have ${e}. Read our version support policy: https://github.com/visulima/visulima#supported-nodejs-versions`),process.exit(1))},"checkNodeVersion");var Ze=Object.defineProperty,et=c((t,e)=>Ze(t,"name",{value:e,configurable:!0}),"r$4");const tt=/^-{1,2}(\w+)(=(\w+))?$/,K=et((t,e)=>{const n=tt.exec(t);if(n==null)return{};const o=n[1],r=e.find(i=>i.name===o||i.alias===o);return r!==void 0?{argName:r.name,argValue:n[3],option:r}:{}},"getParameterOption");var nt=Object.defineProperty,ot=c((t,e)=>nt(t,"name",{value:e,configurable:!0}),"i$3");const b=ot(t=>t.type?.name==="Boolean","isBoolean");var rt=Object.defineProperty,j=c((t,e)=>rt(t,"name",{value:e,configurable:!0}),"n$2");const F=j((t,e)=>{if(e.type===void 0)return t;if(e.type.name==="Boolean"){if(t==="true"||t==="1")return e.type(!0);if(t==="false"||t==="0")return e.type(!1)}return e.type(t)},"convertType"),at=new Set(["0","1","false","true"]),it=j((t,e)=>{const n=j((o,r)=>{const{argName:i,argValue:a,option:s}=K(r,e),{lastOption:l}=o;return s&&b(s)&&a&&i?o.partial[i]=F(a,s):o.lastName&&l&&b(l)&&at.has(r)&&(o.partial[o.lastName]=F(r,l)),{lastName:i,lastOption:s,partial:o.partial}},"getBooleanValue");return t.reduce(n,{partial:{}}).partial},"getBooleanValues");var st=Object.defineProperty,Q=c((t,e)=>st(t,"name",{value:e,configurable:!0}),"p$1");const lt=Q(t=>{let e=t.type?t.type.name.toLowerCase():"string";const n=t.multiple??t.lazyMultiple?"[]":"";return e&&(e=e==="boolean"?"":`{underline ${e}${n}}`),e},"getTypeLabel"),ct=Q(t=>(b(t)||(t.typeLabel=t.typeLabel??lt(t),t.defaultOption&&(t.typeLabel=`${t.typeLabel} (D)`),t.required&&(t.typeLabel=`${t.typeLabel} (R)`)),t),"mapOptionTypeLabel");var pt=Object.defineProperty,Y=c((t,e)=>pt(t,"name",{value:e,configurable:!0}),"s$3");const ut=new Set(["0","1","false","true"]),dt=Y((t,e)=>{const n=Y((o,r)=>{const{argValue:i,option:a}=K(r,e),{lastOption:s}=o;if(s&&b(s)&&ut.has(r)){const l=[...o.args];return l.pop(),{args:l}}return a&&b(a)&&i?{args:o.args}:{args:[...o.args,r],lastOption:a}},"removeBooleanArguments");return t.reduce(n,{args:[]}).args},"removeBooleanValues");var mt=Object.defineProperty,X=c((t,e)=>mt(t,"name",{value:e,configurable:!0}),"e$2");const gt=new RegExp(/^-([^\d-])$/),ht=new RegExp(/^--(\S+)/),ft=new RegExp(/^-([^\d-]{2,})$/),vt=X(t=>gt.test(t)||ht.test(t)||ft.test(t),"isOption"),yt=X((t,e)=>{const n=e[0]&&vt(e[0])||e.length===0?null:e.shift()??null;if(!t.includes(n)){const o=new Error(`Command not recognised: ${n}`);throw o.command=n,o.name="INVALID_COMMAND",o}return{argv:e,command:n}},"commandLineCommands");var bt=Object.defineProperty,Z=c((t,e)=>bt(t,"name",{value:e,configurable:!0}),"i$1");const $t=Z((t,e)=>he.distance(t,e)<=t.length/3||e.includes(t),"isSimilar"),G=Z((t,e)=>{const n=t.toLowerCase();return e.filter(o=>$t(o.toLowerCase(),n))},"findAlternatives");var wt=Object.defineProperty,Et=c((t,e)=>wt(t,"name",{value:e,configurable:!0}),"t$3");const Ot=Et((t,e)=>t.filter(n=>n.required&&e[n.name]==null).filter(n=>n.type?.name==="Boolean"?(e[n.name]=!1,!1):!0),"listMissingArguments");var Ct=Object.defineProperty,_t=c((t,e)=>Ct(t,"name",{value:e,configurable:!0}),"t$2");const At=_t(t=>{const e=new Map;return t.forEach(n=>{e.set(n.name,{...e.get(n.name),...n})}),[...e.values()]},"mergeArguments");var Nt=Object.defineProperty,L=c((t,e)=>Nt(t,"name",{value:e,configurable:!0}),"e$1");const Lt=L(()=>!!process.versions.electron,"isElectronApp"),xt=L(()=>Lt()&&!process.defaultApp,"isBundledElectronApp"),Pt=L(()=>xt()?0:1,"getProcessArgvBinIndex"),St=L(t=>t.slice(Pt()+1),"hideBin");var jt=Object.defineProperty,ee=c((t,e)=>jt(t,"name",{value:e,configurable:!0}),"i");const Rt=" ",Tt=ee((t,e)=>t.length===e.length&&t.every((n,o)=>n===e[o]),"equals"),Vt=ee(t=>typeof t=="string"?t.split(Rt):Tt(t,process.argv)?St(t):t,"parseRawCommand");var Bt=Object.defineProperty,kt=c((t,e)=>Bt(t,"name",{value:e,configurable:!0}),"t");const Ut=kt(t=>{process.on("uncaughtException",e=>{t.error(`Uncaught exception: ${e}`),e?.stack&&t.error(e.stack),process.exit(1)}),process.on("unhandledRejection",e=>{t.error(`Promise rejection: ${e}`),e?.stack&&t.error(e.stack),process.exit(1)})},"registerExceptionHandler");var It=Object.defineProperty,y=c((t,e)=>It(t,"name",{value:e,configurable:!0}),"g");const Dt="CI"in p.env&&("GITHUB_ACTIONS"in p.env||"GITLAB_CI"in p.env||"CIRCLECI"in p.env),Mt=y(t=>t.charAt(0).toLowerCase()+t.slice(1),"lowerFirstChar");class qt{static{c(this,"Cli")}static{y(this,"Cli")}logger;argv;cwd;cliName;packageVersion;packageName;extensions=[];commands;defaultCommand;updateNotifierOptions;commandSection;constructor(e,n={}){const{argv:o,cwd:r,packageName:i,packageVersion:a}={argv:p.argv,cwd:p.cwd(),...n};this.argv=Vt(o),this.argv.includes("--quiet")||this.argv.includes("-q")?p.env.CEREBRO_OUTPUT_LEVEL=String(q):this.argv.includes("--verbose")||this.argv.includes("-v")?p.env.CEREBRO_OUTPUT_LEVEL=String(We):this.argv.includes("--debug")||this.argv.includes("-vvv")||"DEBUG"in p.env?p.env.CEREBRO_OUTPUT_LEVEL=String(S):p.env.CEREBRO_OUTPUT_LEVEL=String(Ge);const s={32:"informational",64:"trace",128:"debug"},l=[new B.MessageFormatterProcessor];p.env.CEREBRO_OUTPUT_LEVEL===String(S)&&l.push(new B.CallerProcessor),this.logger=pe.createPail({logLevel:p.env.CEREBRO_OUTPUT_LEVEL?s[p.env.CEREBRO_OUTPUT_LEVEL]??"informational":"informational",processors:l,...n.logger}),p.env.CEREBRO_OUTPUT_LEVEL===String(q)&&this.logger.disable(),Xe(),Ut(this.logger),this.cliName=e,this.packageVersion=a,this.packageName=i,this.cwd=r,this.defaultCommand="help",this.commandSection={header:`${this.cliName}${this.packageVersion?` v${this.packageVersion}`:""}`},this.commands=new Map,this.addCoreExtensions(),this.addCommand(Ye),this.addCommand(new Me(this.commands))}setCommandSection(e){return this.commandSection=e,this}getCommandSection(){return this.commandSection}setDefaultCommand(e){return this.defaultCommand=e,this}addCommand(e){if(this.commands.has(e.name))throw new Error(`Ignored command with name "${e.name}", it was found in the command list.`);if(e.options?.map(n=>ct(n)),this.validateDoubleOptions(e),this.addNegatableOption(e),e.options?.forEach(n=>{n.__camelCaseName__=H(n.name)}),this.commands.set(e.name,e),e.alias!==void 0){let n=e.alias;typeof e.alias=="string"&&(n=[e.alias]),n.forEach(o=>{if(this.logger.debug("adding alias",o),this.commands.has(o))throw new Error(`Ignoring command alias "${o}, command with the same name was found."`);this.commands.set(o,e)})}return this}addExtension(e){return this.extensions.push(e),this}enableUpdateNotifier(e={}){if(!this.packageName||!this.packageVersion)throw new Error("Cannot enable update notifier without package name and version.");const n=Object.keys(e);if(n.length>0&&!n.includes("alwaysRun")&&!n.includes("distTag")&&!n.includes("updateCheckInterval"))throw new Error("Invalid update notifier options, please check the documentation.");return this.updateNotifierOptions={alwaysRun:!1,debug:p.env.CEREBRO_OUTPUT_LEVEL===String(S),distTag:"latest",pkg:{name:this.packageName,version:this.packageVersion},updateCheckInterval:1e3*60*60*24,...e},this}getCliName(){return this.cliName}getPackageVersion(){return this.packageVersion}getPackageName(){return this.packageName}getCommands(){return this.commands}getCwd(){return this.cwd}async run(e={}){const{shouldExitProcess:n=!0,...o}=e,r=[...this.commands.keys()];let i;this.logger.debug(`process.execPath: ${p.execPath}`),this.logger.debug(`process.execArgv: ${p.execArgv.join(" ")}`),this.logger.debug(`process.argv: ${p.argv.join(" ")}`);try{i=yt([null,...r],this.argv)}catch(h){if(h.name==="INVALID_COMMAND"&&h.command){let T="";const V=G(h.command,[...this.commands.keys()]);V.length>0&&(T=` Did you mean: \r
|
|
7
7
|
- ${V.join(` \r
|
|
8
8
|
- `)}`),this.logger.error(`"${h.command}" is not an available command.${T}`)}else this.logger.error(h);return n?p.exit(1):void 0}const a=i.command??this.defaultCommand,s=this.commands.get(a);if(typeof s.execute!="function")return this.logger.error(`Command "${s.name}" has no function to execute.`),n?p.exit(1):void 0;const l=i.argv;this.logger.debug(`command '${a}' found, parsing command args: ${l.join(", ")}`);let u=At([...s.options??[],...C]);u.forEach(h=>{if(h.multiple&&h.lazyMultiple)throw new Error(`Argument "${h.name}" cannot have both multiple and lazyMultiple options, please choose one.`)}),s.argument&&(this.logger.debug("command has positional argument, parsing them..."),u=[{defaultOption:!0,description:s.argument?.description,group:"positionals",multiple:!0,name:E,type:s.argument?.type,typeLabel:s.argument?.typeLabel},...u]);const g=fe(u,{argv:dt(l,s.options??[]),camelCase:!0,partial:!0,stopAtFirstUnknown:!0}),$=it(l,s.options??[]),f={...g,_all:{...g._all,...$}};this.validateCommandOptions(u,f,s);const m=new ze(s.name,s);m.runtime=this,await this.registerExtensions(m),await this.updateNotifier(m);const{_all:x,positionals:te}=f;return x[E]&&delete x[E],m.argument=te?.[E]??[],m.argv=this.argv,m.options={...x,...o},this.mapNegatableOptions(m,s),this.mapImpliesOptions(m,s),this.validateCommandArgsForConflicts(u,m.options,s),this.logger.debug("command options parsed from options:"),this.logger.debug(JSON.stringify(m.options,null,2)),this.logger.debug("command argument parsed from argument:"),this.logger.debug(JSON.stringify(m.argument,null,2)),await this.prepareToolboxResult(f,m,s),n?p.exit(0):void 0}validateDoubleOptions(e){if(Array.isArray(e.options)){const n=e.options.reduce((i,a)=>{const s=`${a.name}-${a.alias}`;return i[s]||(i[s]=[]),i[s].push(a),i},{}),o=Object.values(n).filter(i=>i.length>1);let r="";if(o.forEach(i=>{const a=i[0],s=i[1];let l="alias";a.name===s.name&&(l="name",a.alias===s.alias&&(l+=" and alias")),r+=`Cannot add option ${l} "${JSON.stringify(s)}" to command "${e.name}" due to conflicting option ${JSON.stringify(a)}
|
|
9
|
-
`}),r.length>0)throw new Error(r)}}addCoreExtensions(){this.addExtension({execute:y(e=>{e.logger=this.logger},"execute"),name:"logger"})}async prepareToolboxResult(e,n,o){if(e.global?.help){this.logger.debug("'--help' option found, running 'help' for given command...");const r=this.commands.get("help");if(!r)throw new Error("Help command not found.");await r.execute(n);return}if(e.global?.version||e.global?.V){this.logger.debug("'--version' option found, running 'version' for given command...");const r=this.commands.get("version");if(!r)throw new Error("Version command not found.");await r.execute(n);return}await o.execute(n)}async updateNotifier({logger:e}){if(this.updateNotifierOptions?.alwaysRun||!(p.env.NO_UPDATE_NOTIFIER||p.env.NODE_ENV==="test"||this.argv.includes("--no-update-notifier")||Dt)&&this.updateNotifierOptions){e.raw("Checking for updates...");const n=await(await import("../packem_chunks/has-new-version.cjs").then(o=>o.default))(this.updateNotifierOptions);if(n){const o
|
|
9
|
+
`}),r.length>0)throw new Error(r)}}addCoreExtensions(){this.addExtension({execute:y(e=>{e.logger=this.logger},"execute"),name:"logger"})}async prepareToolboxResult(e,n,o){if(e.global?.help){this.logger.debug("'--help' option found, running 'help' for given command...");const r=this.commands.get("help");if(!r)throw new Error("Help command not found.");await r.execute(n);return}if(e.global?.version||e.global?.V){this.logger.debug("'--version' option found, running 'version' for given command...");const r=this.commands.get("version");if(!r)throw new Error("Version command not found.");await r.execute(n);return}await o.execute(n)}async updateNotifier({logger:e}){if(this.updateNotifierOptions?.alwaysRun||!(p.env.NO_UPDATE_NOTIFIER||p.env.NODE_ENV==="test"||this.argv.includes("--no-update-notifier")||Dt)&&this.updateNotifierOptions){e.raw("Checking for updates...");const n=await(await import("../packem_chunks/has-new-version.cjs").then(o=>o.default))(this.updateNotifierOptions);if(n){const o=`Update available ${v.dim(`${this.packageVersion}`)}${v.reset(" → ")}${v.green(n)}`;this.logger.error(ce.boxen(o,{borderColor:y(r=>v.yellow(r),"borderColor"),borderStyle:"round",margin:1,padding:1,textAlignment:"center"}))}}}validateCommandOptions(e,n,o){const r=Ot(e,n);if(r.length>0)throw new Error(`You called the command "${o.name}" without the required options: ${r.map(i=>i.name).join(", ")}`);if(n._unknown&&n._unknown.length>0){const i=[];if(n._unknown.forEach(a=>{const s=a.startsWith("--");let l=`Found unknown ${s?"option":"argument"} "${a}"`;if(s){const u=G(a.replace("--",""),[...(o.options??[]).map(g=>g.name),...C.map(g=>g.name)]);if(u.length>0){const[g,...$]=u.map(f=>`--${f}`);l+=$.length>0?`, did you mean ${g} or ${$.join(", ")}?`:`, did you mean ${g}?`}}i.push(l)}),i.length>0)throw new Error(i.join(`
|
|
10
10
|
`))}}validateCommandArgsForConflicts(e,n,o){const r=e.filter(i=>i.conflicts!==void 0);if(r.length>0){const i=r.find(a=>Array.isArray(a.conflicts)?a.conflicts.some(s=>n[s]!==void 0)&&n[a.name]!==void 0:n[a.conflicts]!==void 0&&n[a.name]!==void 0);if(i)throw new Error(`You called the command "${o.name}" with conflicting options: ${i.name} and ${typeof i.conflicts=="string"?i.conflicts:i.conflicts?.join(", ")}`)}}addNegatableOption(e){Array.isArray(e.options)&&e.options.forEach(n=>{if(n.name.startsWith("no-")&&!e.options.some(o=>o.name===n.name.replace("no-",""))){if(n.type!==Boolean){this.logger.debug(`Cannot add negated option "${n.name}" to command "${e.name}" because it is not a boolean.`);return}const o={...n,defaultValue:n.defaultValue===void 0?!0:!n.defaultValue,name:`${n.name.replace("no-","")}`};e.options.push(o)}})}async registerExtensions(e){const n=y(async o=>typeof o.execute!="function"?(this.logger.warn(`Skipped ${o.name} because execute is not a function.`),null):(await o.execute(e),null),"callback");for(const o of this.extensions)await n(o)}mapNegatableOptions(e,n){Object.entries(e.options).forEach(([o,r])=>{if(/^no\w+/.test(o)){const i=Mt(o.replace("no",""));this.logger.debug(`mapping negated option "${o}" to "${i}"`),e.options[i]=!r,n.options?.forEach(a=>{a.name===i&&(a.__negated__=!0)})}})}mapImpliesOptions(e,n){Object.keys(e.options).forEach(o=>{const r=n.options?.find(i=>i.__camelCaseName__===o&&i.__negated__===void 0&&i.implies!==void 0);if(r?.implies){const i=r.implies;Object.entries(i).forEach(([a,s])=>{if(e.options[a]===void 0)e.options[a]=s;else{const l=n.options?.find(u=>u.name===a);(l?.defaultValue===void 0||e.options[a]===l.defaultValue)&&(e.options[a]=s)}})}})}}exports.Cli=qt;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@visulima/cerebro",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.53",
|
|
4
4
|
"description": "A delightful toolkit for building Node-powered CLIs.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"command",
|
|
@@ -58,13 +58,13 @@
|
|
|
58
58
|
"type": "module",
|
|
59
59
|
"exports": {
|
|
60
60
|
".": {
|
|
61
|
-
"require": {
|
|
62
|
-
"types": "./dist/index.d.cts",
|
|
63
|
-
"default": "./dist/index.cjs"
|
|
64
|
-
},
|
|
65
61
|
"import": {
|
|
66
62
|
"types": "./dist/index.d.mts",
|
|
67
63
|
"default": "./dist/index.mjs"
|
|
64
|
+
},
|
|
65
|
+
"require": {
|
|
66
|
+
"types": "./dist/index.d.cts",
|
|
67
|
+
"default": "./dist/index.cjs"
|
|
68
68
|
}
|
|
69
69
|
},
|
|
70
70
|
"./package.json": "./package.json"
|
|
@@ -86,17 +86,16 @@
|
|
|
86
86
|
"LICENSE.md"
|
|
87
87
|
],
|
|
88
88
|
"dependencies": {
|
|
89
|
-
"@visulima/boxen": "2.0.
|
|
90
|
-
"@visulima/colorize": "1.4.
|
|
91
|
-
"@visulima/find-cache-dir": "
|
|
92
|
-
"@visulima/pail": "2.1.
|
|
89
|
+
"@visulima/boxen": "2.0.4",
|
|
90
|
+
"@visulima/colorize": "1.4.24",
|
|
91
|
+
"@visulima/find-cache-dir": "2.0.0",
|
|
92
|
+
"@visulima/pail": "2.1.31",
|
|
93
93
|
"cli-table3": "^0.6.5",
|
|
94
94
|
"command-line-args": "^6.0.1",
|
|
95
|
-
"fastest-levenshtein": "^1.0.16"
|
|
96
|
-
"publint": "^0.3.12"
|
|
95
|
+
"fastest-levenshtein": "^1.0.16"
|
|
97
96
|
},
|
|
98
97
|
"engines": {
|
|
99
|
-
"node": ">=18.0.0 <=
|
|
98
|
+
"node": ">=18.0.0 <=24.x"
|
|
100
99
|
},
|
|
101
100
|
"os": [
|
|
102
101
|
"darwin",
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
var ee=Object.defineProperty;var c=(t,e)=>ee(t,"name",{value:e,configurable:!0});import{cwd as te,argv as V,env as u,execPath as oe,execArgv as ne,exit as L}from"node:process";import{boxen as re}from"@visulima/boxen";import{bold as ae,dim as ie,reset as se,green as le,yellow as ce}from"@visulima/colorize";import{MessageFormatterProcessor as pe,CallerProcessor as me}from"@visulima/pail/processor";import{createPail as ue}from"@visulima/pail/server";import de from"command-line-args";import E from"cli-table3";import ge from"@visulima/colorize/template";import he from"node:os";import{distance as fe}from"fastest-levenshtein";var ve=Object.defineProperty,C=c((t,e)=>ve(t,"name",{value:e,configurable:!0}),"f$3");const ye=/[\p{Lu}]/u,be=/[\p{Ll}]/u,T=/^[\p{Lu}](?![\p{Lu}])/gu,Y=/([\p{Alpha}\p{N}_]|$)/u,S=/[_.\- ]+/,$e=new RegExp("^"+S.source),B=new RegExp(S.source+Y.source,"gu"),k=new RegExp("\\d+"+Y.source,"gu"),we=C((t,e,o,n)=>{let r=!1,i=!1,a=!1,s=!1;for(let l=0;l<t.length;l++){const p=t[l];s=l>2?t[l-3]==="-":!0,r&&ye.test(p)?(t=t.slice(0,l)+"-"+t.slice(l),r=!1,a=i,i=!0,l++):i&&a&&be.test(p)&&(!s||n)?(t=t.slice(0,l-1)+"-"+t.slice(l-1),a=i,i=!1,r=!0):(r=e(p)===p&&o(p)!==p,a=i,i=o(p)===p&&e(p)!==p)}return t},"preserveCamelCase"),Ee=C((t,e)=>(T.lastIndex=0,t.replaceAll(T,o=>e(o))),"preserveConsecutiveUppercase"),Oe=C((t,e)=>(B.lastIndex=0,k.lastIndex=0,t.replaceAll(k,(o,n,r)=>["_","-"].includes(t.charAt(r+o.length))?o:e(o)).replaceAll(B,(o,n)=>e(n))),"postProcess");function G(t,e){if(!(typeof t=="string"||Array.isArray(t)))throw new TypeError("Expected the input to be `string | string[]`");if(e={pascalCase:!1,preserveConsecutiveUppercase:!1,...e},Array.isArray(t)?t=t.map(r=>r.trim()).filter(r=>r.length).join("-"):t=t.trim(),t.length===0)return"";const o=e.locale===!1?r=>r.toLowerCase():r=>r.toLocaleLowerCase(e.locale),n=e.locale===!1?r=>r.toUpperCase():r=>r.toLocaleUpperCase(e.locale);return t.length===1?S.test(t)?"":e.pascalCase?n(t):o(t):(t!==o(t)&&(t=we(t,o,n,e.preserveConsecutiveUppercase)),t=t.replace($e,""),t=e.preserveConsecutiveUppercase?Ee(t,o):o(t),e.pascalCase&&(t=n(t.charAt(0))+t.slice(1)),Oe(t,n))}c(G,"S");C(G,"camelCase");const O=[{description:"Turn on verbose output",group:"global",name:"verbose",type:Boolean},{description:"Turn on debugging output",group:"global",name:"debug",type:Boolean},{alias:"h",description:"Print out helpful usage information",group:"global",name:"help",type:Boolean},{alias:"q",description:"Silence output",group:"global",name:"quiet",type:Boolean},{alias:"V",description:"Print version info",group:"global",name:"version",type:Boolean},{description:"Turn off colored output",group:"global",name:"no-color",type:Boolean},{description:"Force colored output",group:"global",name:"color",type:Boolean}];var Ce=Object.defineProperty,Ae=c((t,e)=>Ce(t,"name",{value:e,configurable:!0}),"e$4");const m=Ae(t=>t?ge(Object.assign([],{raw:[t.replaceAll("`","\\`")]})):"","templateFormat");var Ne=Object.defineProperty,_e=c((t,e)=>Ne(t,"name",{value:e,configurable:!0}),"t$6");let W=class{static{c(this,"n")}static{_e(this,"BaseSection")}lines;constructor(){this.lines=[]}add(e){this.lines.push(e)}toString(){return this.lines.join(he.EOL)}header(e){this.add(ae(e)),this.lines.push("")}};var Le=Object.defineProperty,xe=c((t,e)=>Le(t,"name",{value:e,configurable:!0}),"p$4");const $={chars:{bottom:"","bottom-left":"","bottom-mid":"","bottom-right":"",left:" ","left-mid":"",mid:"","mid-mid":"",middle:" ",right:"","right-mid":"",top:"","top-left":"","top-mid":"","top-right":""},colWidths:[40,60],style:{border:[],compact:!0,head:[],"padding-left":2,"padding-right":1},wordWrap:!0};let Pe=class extends W{static{c(this,"y")}static{xe(this,"ContentSection")}constructor(e){if(super(),e.header&&this.header(m(e.header)),e.content){if(e.raw)if(Array.isArray(e.content)&&e.content.every(o=>typeof o=="string"))e.content.forEach(o=>{Array.isArray(o)?o.forEach(n=>this.add(m(n))):this.add(m(o))});else if(typeof e.content=="string")this.add(m(e.content));else throw new TypeError("Invalid raw content, must be a string or array of strings.");else this.add(this.getContentLines(e.content));this.add("")}}getContentLines(e){if(typeof e=="string"){const o=new E({...$,colWidths:[80]});return o.push([m(e)]),o.toString()}if(Array.isArray(e)&&e.every(o=>typeof o=="string"||Array.isArray(o)&&o.every(n=>typeof n=="string"))){const o=new E({...$});return e.forEach(n=>{Array.isArray(n)?o.push(n.map(r=>m(r))):o.push([m(n)])}),o.toString()}if(typeof e=="object"){const o=e;if(!o.options||!o.data)throw new Error(`Must have an "options" or "data" property
|
|
2
|
-
${JSON.stringify(e)}`);const n=new E({...$,...o.options,style:{...$.style,...o.options.style}});return o.data.forEach(r=>{Array.isArray(r)?n.push(r.map(i=>m(i))):n.push([m(r)])}),n.toString()}throw new Error(`invalid input - 'content' must be a string, array of strings or a object:
|
|
3
|
-
|
|
4
|
-
${JSON.stringify(e)}`)}};var Se=Object.defineProperty,Re=c((t,e)=>Se(t,"name",{value:e,configurable:!0}),"a$1");let je=class extends W{static{c(this,"c")}static{Re(this,"OptionListSection")}constructor(e){super();let o=e.optionList??[];const n=Array.isArray(e.hide)?e.hide:[e.hide].filter(Boolean),r=Array.isArray(e.group)?e.group:[e.group].filter(Boolean);n.length>0&&(o=o.filter(a=>!n.includes(a.name))),e.header&&this.header(m(e.header)),r.length>0&&(o=o.filter(a=>{const s=r.includes("_none")&&!a.group,l=this.intersect(Array.isArray(a.group)?a.group:[a.group],r);return s||l?a:void 0}));const i=new E({chars:{bottom:"","bottom-left":"","bottom-mid":"","bottom-right":"",left:" ","left-mid":"",mid:"","mid-mid":"",middle:" ",right:"","right-mid":"",top:"","top-left":"","top-mid":"","top-right":""},colWidths:[40,40],style:{"padding-left":2,"padding-right":1},wordWrap:!0});o.forEach(a=>i.push([this.getOptionNames(a,e.reverseNameOrder??!1,e.isArgument??!1),m(a.description)])),this.add(i.toString()),this.lines.push("")}getOptionNames(e,o,n){if(!e.name)throw new TypeError("Invalid option definition, name is required.");let r=e.type?e.type.name.toLowerCase():"string";const i=e.multiple||e.lazyMultiple?"[]":"";r=m(e.typeLabel??`{underline ${r}${i}}`);let a;if(e.alias)if(e.name){const s=n?e.name:`{yellow --${e.name}}`;a=m(o?`{bold ${s}}, {bold -${e.alias}} ${r}`:`{bold -${e.alias}}, {bold ${s}} ${r}`)}else o?a=m(`{bold -${e.alias}} ${r}`):a=m(`{bold -${e.alias}} ${r}`);else a=m(`{bold ${n?e.name:`{yellow --${e.name}}`}} ${r}`);return a}intersect(e,o){return e.some(n=>o.includes(n))}};var Ve=Object.defineProperty,Te=c((t,e)=>Ve(t,"name",{value:e,configurable:!0}),"o$3");const H=Te(t=>(Array.isArray(t)?t:[t]).length===0?"":`
|
|
5
|
-
${t.map(e=>e.optionList?new je(e).toString():new Pe(e).toString()).join(`
|
|
6
|
-
`)}`,"commandLineUsage");var Be=Object.defineProperty,A=c((t,e)=>Be(t,"name",{value:e,configurable:!0}),"l$5");const U="__Other",I=A(t=>t.charAt(0).toUpperCase()+t.slice(1),"upperFirstChar"),ke=A((t,e,o,n)=>{t.debug("no command given, printing general help...");let r=[...new Set(o.values())].filter(a=>!a.hidden);n&&(r=r.filter(a=>a.group===n));const i=r.reduce((a,s)=>{const l=s.group??U;return a[l]||(a[l]=[]),a[l].push(s),a},{});t.raw(H([{content:`{cyan ${e.getCliName()}} {green <command>} [positional arguments] {yellow [options]}`,header:"{inverse.cyan Usage }"},...Object.keys(i).map(a=>({content:i[a].map(s=>{let l="";return typeof s.alias=="string"?l=s.alias:Array.isArray(s.alias)&&(l=s.alias.join(", ")),l!==""&&(l=` [${l}]`),[`{green ${s.name}} ${l}`,s.description??""]}),header:a===U||n?`{inverse.green Available${n?` ${I(n)}`:""} Commands }`:` {inverse.green ${I(a)} }`})),o.has("help")?{header:"{inverse.yellow Command Options }",optionList:o.get("help").options?.filter(a=>!a.hidden)}:void 0,{header:"{inverse.yellow Global Options }",optionList:O},{content:`Run "{cyan ${e.getCliName()}} {green help <command>}" or "{cyan ${e.getCliName()}} {green <command>} {yellow --help}" for help with a specific command.`,raw:!0}].filter(Boolean)))},"printGeneralHelp"),Ue=A((t,e,o,n)=>{const r=o.get(n),i=[];if(i.push({content:`{cyan ${e.getCliName()}} {green ${r.name}}${r.argument?" [positional arguments]":""}${r.options?" [options]":""}`,header:"{inverse.cyan Usage }"}),r.description&&i.push({content:r.description,header:"{inverse.green Description }"}),r.argument&&i.push({header:"Command Positional Arguments",isArgument:!0,optionList:[r.argument]}),Array.isArray(r.options)&&r.options.length>0&&i.push({header:"{inverse.yellow Command Options }",optionList:r.options.filter(a=>!a.hidden)}),i.push({header:"{inverse.yellow Global Options }",optionList:O}),r.alias!==void 0&&r.alias.length>0){let a=r.alias;typeof r.alias=="string"&&(a=[r.alias]),i.splice(1,0,{content:a,header:"Alias(es)"})}Array.isArray(r.examples)&&r.examples.length>0&&i.push({content:r.examples,header:"Examples"}),t.raw(H(i))},"printCommandHelp");class Ie{static{c(this,"C")}static{A(this,"HelpCommand")}name="help";options=[{description:"Display only the specified group",name:"group",type:String}];commands;constructor(e){this.commands=e}execute(e){const{commandName:o,logger:n,options:r,runtime:i}=e,{footer:a,header:s}=i.getCommandSection();s&&n.raw(m(s)),o==="help"?ke(n,i,this.commands,r?.group):Ue(n,i,this.commands,o),a&&n.raw(m(a))}}var De=Object.defineProperty,Me=c((t,e)=>De(t,"name",{value:e,configurable:!0}),"s$7");const Fe={alias:["v","V"],description:"Output the version number",execute:Me(({logger:t,runtime:e})=>{const o=e.getPackageVersion();o===void 0?(t.warn("Unknown version"),t.debug("The version number was not provided by the cli constructor.")):t.info(o)},"execute"),name:"version",options:[],usage:[]},D=16,qe=32,Ye=64,x=128,w="positionals";var Ge=Object.defineProperty,We=c((t,e)=>Ge(t,"name",{value:e,configurable:!0}),"m$2");let He=class{static{c(this,"c")}static{We(this,"EmptyToolbox")}result;argv;options;argument;command;commandName;runtime;logger;constructor(e,o){this.commandName=e,this.command=o}};var Je=Object.defineProperty,ze=c((t,e)=>Je(t,"name",{value:e,configurable:!0}),"s$6");const Ke=ze(()=>{const t=process.env.CEREBRO_MIN_NODE_VERSION?Number(process.env.CEREBRO_MIN_NODE_VERSION):18,e=process.version.replace("v","");Number(/v([^.]+)/.exec(process.version)[1])<t&&(console.log(`cerebro supports a minimum Node version of ${t}. You have ${e}. Read our version support policy: https://github.com/visulima/visulima#supported-nodejs-versions`),process.exit(1))},"checkNodeVersion");var Qe=Object.defineProperty,Xe=c((t,e)=>Qe(t,"name",{value:e,configurable:!0}),"r$4");const Ze=/^-{1,2}(\w+)(=(\w+))?$/,J=Xe((t,e)=>{const o=Ze.exec(t);if(o==null)return{};const n=o[1],r=e.find(i=>i.name===n||i.alias===n);return r!==void 0?{argName:r.name,argValue:o[3],option:r}:{}},"getParameterOption");var et=Object.defineProperty,tt=c((t,e)=>et(t,"name",{value:e,configurable:!0}),"i$3");const y=tt(t=>t.type?.name==="Boolean","isBoolean");var ot=Object.defineProperty,P=c((t,e)=>ot(t,"name",{value:e,configurable:!0}),"n$2");const M=P((t,e)=>{if(e.type===void 0)return t;if(e.type.name==="Boolean"){if(t==="true"||t==="1")return e.type(!0);if(t==="false"||t==="0")return e.type(!1)}return e.type(t)},"convertType"),nt=new Set(["1","0","true","false"]),rt=P((t,e)=>{const o=P((n,r)=>{const{argName:i,argValue:a,option:s}=J(r,e),{lastOption:l}=n;return s&&y(s)&&a&&i?n.partial[i]=M(a,s):n.lastName&&l&&y(l)&&nt.has(r)&&(n.partial[n.lastName]=M(r,l)),{lastName:i,lastOption:s,partial:n.partial}},"getBooleanValue");return t.reduce(o,{partial:{}}).partial},"getBooleanValues");var at=Object.defineProperty,z=c((t,e)=>at(t,"name",{value:e,configurable:!0}),"p$1");const it=z(t=>{let e=t.type?t.type.name.toLowerCase():"string";const o=t.multiple??t.lazyMultiple?"[]":"";return e&&(e=e==="boolean"?"":`{underline ${e}${o}}`),e},"getTypeLabel"),st=z(t=>(y(t)||(t.typeLabel=t.typeLabel??it(t),t.defaultOption&&(t.typeLabel=`${t.typeLabel} (D)`),t.required&&(t.typeLabel=`${t.typeLabel} (R)`)),t),"mapOptionTypeLabel");var lt=Object.defineProperty,F=c((t,e)=>lt(t,"name",{value:e,configurable:!0}),"s$3");const ct=new Set(["1","0","true","false"]),pt=F((t,e)=>{const o=F((n,r)=>{const{argValue:i,option:a}=J(r,e),{lastOption:s}=n;if(s&&y(s)&&ct.has(r)){const l=[...n.args];return l.pop(),{args:l}}return a&&y(a)&&i?{args:n.args}:{args:[...n.args,r],lastOption:a}},"removeBooleanArguments");return t.reduce(o,{args:[]}).args},"removeBooleanValues");var mt=Object.defineProperty,K=c((t,e)=>mt(t,"name",{value:e,configurable:!0}),"e$2");const ut=new RegExp(/^-([^\d-])$/),dt=new RegExp(/^--(\S+)/),gt=new RegExp(/^-([^\d-]{2,})$/),ht=K(t=>ut.test(t)||dt.test(t)||gt.test(t),"isOption"),ft=K((t,e)=>{const o=e[0]&&ht(e[0])||e.length===0?null:e.shift()??null;if(!t.includes(o)){const n=new Error(`Command not recognised: ${o}`);throw n.command=o,n.name="INVALID_COMMAND",n}return{argv:e,command:o}},"commandLineCommands");var vt=Object.defineProperty,Q=c((t,e)=>vt(t,"name",{value:e,configurable:!0}),"i$1");const yt=Q((t,e)=>fe(t,e)<=t.length/3||e.includes(t),"isSimilar"),q=Q((t,e)=>{const o=t.toLowerCase();return e.filter(n=>yt(n.toLowerCase(),o))},"findAlternatives");var bt=Object.defineProperty,$t=c((t,e)=>bt(t,"name",{value:e,configurable:!0}),"t$3");const wt=$t((t,e)=>t.filter(o=>o.required&&e[o.name]==null).filter(o=>o.type?.name==="Boolean"?(e[o.name]=!1,!1):!0),"listMissingArguments");var Et=Object.defineProperty,Ot=c((t,e)=>Et(t,"name",{value:e,configurable:!0}),"t$2");const Ct=Ot(t=>{const e=new Map;return t.forEach(o=>{e.set(o.name,{...e.get(o.name),...o})}),[...e.values()]},"mergeArguments");var At=Object.defineProperty,N=c((t,e)=>At(t,"name",{value:e,configurable:!0}),"e$1");const Nt=N(()=>!!process.versions.electron,"isElectronApp"),_t=N(()=>Nt()&&!process.defaultApp,"isBundledElectronApp"),Lt=N(()=>_t()?0:1,"getProcessArgvBinIndex"),xt=N(t=>t.slice(Lt()+1),"hideBin");var Pt=Object.defineProperty,X=c((t,e)=>Pt(t,"name",{value:e,configurable:!0}),"i");const St=" ",Rt=X((t,e)=>t.length===e.length&&t.every((o,n)=>o===e[n]),"equals"),jt=X(t=>typeof t=="string"?t.split(St):Rt(t,process.argv)?xt(t):t,"parseRawCommand");var Vt=Object.defineProperty,Tt=c((t,e)=>Vt(t,"name",{value:e,configurable:!0}),"t");const Bt=Tt(t=>{process.on("uncaughtException",e=>{t.error(`Uncaught exception: ${e}`),e?.stack&&t.error(e.stack),process.exit(1)}),process.on("unhandledRejection",e=>{t.error(`Promise rejection: ${e}`),e?.stack&&t.error(e.stack),process.exit(1)})},"registerExceptionHandler");var kt=Object.defineProperty,v=c((t,e)=>kt(t,"name",{value:e,configurable:!0}),"g");const Ut="CI"in u&&("GITHUB_ACTIONS"in u||"GITLAB_CI"in u||"CIRCLECI"in u),It=v(t=>t.charAt(0).toLowerCase()+t.slice(1),"lowerFirstChar");class to{static{c(this,"Cli")}static{v(this,"Cli")}logger;argv;cwd;cliName;packageVersion;packageName;extensions=[];commands;defaultCommand;updateNotifierOptions;commandSection;constructor(e,o={}){const{argv:n,cwd:r,packageName:i,packageVersion:a}={argv:V,cwd:te(),...o};this.argv=jt(n),this.argv.includes("--quiet")||this.argv.includes("-q")?u.CEREBRO_OUTPUT_LEVEL=String(D):this.argv.includes("--verbose")||this.argv.includes("-v")?u.CEREBRO_OUTPUT_LEVEL=String(Ye):this.argv.includes("--debug")||this.argv.includes("-vvv")||"DEBUG"in u?u.CEREBRO_OUTPUT_LEVEL=String(x):u.CEREBRO_OUTPUT_LEVEL=String(qe);const s={32:"informational",64:"trace",128:"debug"},l=[new pe];u.CEREBRO_OUTPUT_LEVEL===String(x)&&l.push(new me),this.logger=ue({logLevel:u.CEREBRO_OUTPUT_LEVEL?s[u.CEREBRO_OUTPUT_LEVEL]??"informational":"informational",processors:l,...o.logger}),u.CEREBRO_OUTPUT_LEVEL===String(D)&&this.logger.disable(),Ke(),Bt(this.logger),this.cliName=e,this.packageVersion=a,this.packageName=i,this.cwd=r,this.defaultCommand="help",this.commandSection={header:`${this.cliName}${this.packageVersion?` v${this.packageVersion}`:""}`},this.commands=new Map,this.addCoreExtensions(),this.addCommand(Fe),this.addCommand(new Ie(this.commands))}setCommandSection(e){return this.commandSection=e,this}getCommandSection(){return this.commandSection}setDefaultCommand(e){return this.defaultCommand=e,this}addCommand(e){if(this.commands.has(e.name))throw new Error(`Ignored command with name "${e.name}", it was found in the command list.`);if(e.options?.map(o=>st(o)),this.validateDoubleOptions(e),this.addNegatableOption(e),e.options?.forEach(o=>{o.__camelCaseName__=G(o.name)}),this.commands.set(e.name,e),e.alias!==void 0){let o=e.alias;typeof e.alias=="string"&&(o=[e.alias]),o.forEach(n=>{if(this.logger.debug("adding alias",n),this.commands.has(n))throw new Error(`Ignoring command alias "${n}, command with the same name was found."`);this.commands.set(n,e)})}return this}addExtension(e){return this.extensions.push(e),this}enableUpdateNotifier(e={}){if(!this.packageName||!this.packageVersion)throw new Error("Cannot enable update notifier without package name and version.");const o=Object.keys(e);if(o.length>0&&!o.includes("alwaysRun")&&!o.includes("distTag")&&!o.includes("updateCheckInterval"))throw new Error("Invalid update notifier options, please check the documentation.");return this.updateNotifierOptions={alwaysRun:!1,debug:u.CEREBRO_OUTPUT_LEVEL===String(x),distTag:"latest",pkg:{name:this.packageName,version:this.packageVersion},updateCheckInterval:1e3*60*60*24,...e},this}getCliName(){return this.cliName}getPackageVersion(){return this.packageVersion}getPackageName(){return this.packageName}getCommands(){return this.commands}getCwd(){return this.cwd}async run(e={}){const{shouldExitProcess:o=!0,...n}=e,r=[...this.commands.keys()];let i;this.logger.debug(`process.execPath: ${oe}`),this.logger.debug(`process.execArgv: ${ne.join(" ")}`),this.logger.debug(`process.argv: ${V.join(" ")}`);try{i=ft([null,...r],this.argv)}catch(h){if(h.name==="INVALID_COMMAND"&&h.command){let R="";const j=q(h.command,[...this.commands.keys()]);j.length>0&&(R=` Did you mean: \r
|
|
7
|
-
- ${j.join(` \r
|
|
8
|
-
- `)}`),this.logger.error(`"${h.command}" is not an available command.${R}`)}else this.logger.error(h);return o?L(1):void 0}const a=i.command??this.defaultCommand,s=this.commands.get(a);if(typeof s.execute!="function")return this.logger.error(`Command "${s.name}" has no function to execute.`),o?L(1):void 0;const l=i.argv;this.logger.debug(`command '${a}' found, parsing command args: ${l.join(", ")}`);let p=Ct([...s.options??[],...O]);p.forEach(h=>{if(h.multiple&&h.lazyMultiple)throw new Error(`Argument "${h.name}" cannot have both multiple and lazyMultiple options, please choose one.`)}),s.argument&&(this.logger.debug("command has positional argument, parsing them..."),p=[{defaultOption:!0,description:s.argument?.description,group:"positionals",multiple:!0,name:w,type:s.argument?.type,typeLabel:s.argument?.typeLabel},...p]);const g=de(p,{argv:pt(l,s.options??[]),camelCase:!0,partial:!0,stopAtFirstUnknown:!0}),b=rt(l,s.options??[]),f={...g,_all:{...g._all,...b}};this.validateCommandOptions(p,f,s);const d=new He(s.name,s);d.runtime=this,await this.registerExtensions(d),await this.updateNotifier(d);const{_all:_,positionals:Z}=f;return _[w]&&delete _[w],d.argument=Z?.[w]??[],d.argv=this.argv,d.options={..._,...n},this.mapNegatableOptions(d,s),this.mapImpliesOptions(d,s),this.validateCommandArgsForConflicts(p,d.options,s),this.logger.debug("command options parsed from options:"),this.logger.debug(JSON.stringify(d.options,null,2)),this.logger.debug("command argument parsed from argument:"),this.logger.debug(JSON.stringify(d.argument,null,2)),await this.prepareToolboxResult(f,d,s),o?L(0):void 0}validateDoubleOptions(e){if(Array.isArray(e.options)){const o=e.options.reduce((i,a)=>{const s=`${a.name}-${a.alias}`;return i[s]||(i[s]=[]),i[s].push(a),i},{}),n=Object.values(o).filter(i=>i.length>1);let r="";if(n.forEach(i=>{const a=i[0],s=i[1];let l="alias";a.name===s.name&&(l="name",a.alias===s.alias&&(l+=" and alias")),r+=`Cannot add option ${l} "${JSON.stringify(s)}" to command "${e.name}" due to conflicting option ${JSON.stringify(a)}
|
|
9
|
-
`}),r.length>0)throw new Error(r)}}addCoreExtensions(){this.addExtension({execute:v(e=>{e.logger=this.logger},"execute"),name:"logger"})}async prepareToolboxResult(e,o,n){if(e.global?.help){this.logger.debug("'--help' option found, running 'help' for given command...");const r=this.commands.get("help");if(!r)throw new Error("Help command not found.");await r.execute(o);return}if(e.global?.version||e.global?.V){this.logger.debug("'--version' option found, running 'version' for given command...");const r=this.commands.get("version");if(!r)throw new Error("Version command not found.");await r.execute(o);return}await n.execute(o)}async updateNotifier({logger:e}){if(this.updateNotifierOptions?.alwaysRun||!(u.NO_UPDATE_NOTIFIER||u.NODE_ENV==="test"||this.argv.includes("--no-update-notifier")||Ut)&&this.updateNotifierOptions){e.raw("Checking for updates...");const o=await(await import("../packem_chunks/has-new-version.mjs").then(n=>n.default))(this.updateNotifierOptions);if(o){const n="Update available "+ie(this.packageVersion+"")+se(" → ")+le(o);this.logger.error(re(n,{borderColor:v(r=>ce(r),"borderColor"),borderStyle:"round",margin:1,padding:1,textAlignment:"center"}))}}}validateCommandOptions(e,o,n){const r=wt(e,o);if(r.length>0)throw new Error(`You called the command "${n.name}" without the required options: ${r.map(i=>i.name).join(", ")}`);if(o._unknown&&o._unknown.length>0){const i=[];if(o._unknown.forEach(a=>{const s=a.startsWith("--");let l=`Found unknown ${s?"option":"argument"} "${a}"`;if(s){const p=q(a.replace("--",""),[...(n.options??[]).map(g=>g.name),...O.map(g=>g.name)]);if(p.length>0){const[g,...b]=p.map(f=>`--${f}`);l+=b.length>0?`, did you mean ${g} or ${b.join(", ")}?`:`, did you mean ${g}?`}}i.push(l)}),i.length>0)throw new Error(i.join(`
|
|
10
|
-
`))}}validateCommandArgsForConflicts(e,o,n){const r=e.filter(i=>i.conflicts!==void 0);if(r.length>0){const i=r.find(a=>Array.isArray(a.conflicts)?a.conflicts.some(s=>o[s]!==void 0)&&o[a.name]!==void 0:o[a.conflicts]!==void 0&&o[a.name]!==void 0);if(i)throw new Error(`You called the command "${n.name}" with conflicting options: ${i.name} and ${typeof i.conflicts=="string"?i.conflicts:i.conflicts?.join(", ")}`)}}addNegatableOption(e){Array.isArray(e.options)&&e.options.forEach(o=>{if(o.name.startsWith("no-")&&!e.options.some(n=>n.name===o.name.replace("no-",""))){if(o.type!==Boolean){this.logger.debug(`Cannot add negated option "${o.name}" to command "${e.name}" because it is not a boolean.`);return}const n={...o,defaultValue:o.defaultValue===void 0?!0:!o.defaultValue,name:`${o.name.replace("no-","")}`};e.options.push(n)}})}async registerExtensions(e){const o=v(async n=>typeof n.execute!="function"?(this.logger.warn(`Skipped ${n.name} because execute is not a function.`),null):(await n.execute(e),null),"callback");for(const n of this.extensions)await o(n)}mapNegatableOptions(e,o){Object.entries(e.options).forEach(([n,r])=>{if(/^no\w+/.test(n)){const i=It(n.replace("no",""));this.logger.debug(`mapping negated option "${n}" to "${i}"`),e.options[i]=!r,o.options?.forEach(a=>{a.name===i&&(a.__negated__=!0)})}})}mapImpliesOptions(e,o){Object.keys(e.options).forEach(n=>{const r=o.options?.find(i=>i.__camelCaseName__===n&&i.__negated__===void 0&&i.implies!==void 0);if(r?.implies){const i=r.implies;Object.entries(i).forEach(([a,s])=>{if(e.options[a]===void 0)e.options[a]=s;else{const l=o.options?.find(p=>p.name===a);(l?.defaultValue===void 0||e.options[a]===l.defaultValue)&&(e.options[a]=s)}})}})}}export{to as Cli};
|