@visulima/cerebro 1.1.50 → 1.1.52
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 +36 -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.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 +10 -10
- package/dist/packem_shared/default-DRd7Q7Xw.mjs +0 -10
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,39 @@
|
|
|
1
|
+
## @visulima/cerebro [1.1.52](https://github.com/visulima/visulima/compare/@visulima/cerebro@1.1.51...@visulima/cerebro@1.1.52) (2025-10-15)
|
|
2
|
+
|
|
3
|
+
### Bug Fixes
|
|
4
|
+
|
|
5
|
+
* update @visulima/packem to 2.0.0-alpha.29 and refine packem.config.ts settings ([63f14a1](https://github.com/visulima/visulima/commit/63f14a1c11bd7c004e76874ed0b3938ad4740da6))
|
|
6
|
+
* update @visulima/packem to 2.0.0-alpha.30 across multiple packages for improved compatibility ([27b346e](https://github.com/visulima/visulima/commit/27b346eaa1c0fb0e420d9a9824482028307f4249))
|
|
7
|
+
|
|
8
|
+
### Miscellaneous Chores
|
|
9
|
+
|
|
10
|
+
* update package dependencies across multiple packages for improved compatibility and performance ([9567591](https://github.com/visulima/visulima/commit/9567591c415da3002f3a4fe08f8caf7ce01ca5f7))
|
|
11
|
+
|
|
12
|
+
### Code Refactoring
|
|
13
|
+
|
|
14
|
+
* consolidate ESLint configuration and remove obsolete files for improved maintainability ([76d27af](https://github.com/visulima/visulima/commit/76d27afba1dd1946820dc28ae8add2aa1b0ec288))
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
### Dependencies
|
|
18
|
+
|
|
19
|
+
* **@visulima/boxen:** upgraded to 2.0.4
|
|
20
|
+
* **@visulima/colorize:** upgraded to 1.4.24
|
|
21
|
+
* **@visulima/find-cache-dir:** upgraded to 2.0.0
|
|
22
|
+
* **@visulima/pail:** upgraded to 2.1.30
|
|
23
|
+
* **@visulima/path:** upgraded to 2.0.0
|
|
24
|
+
|
|
25
|
+
## @visulima/cerebro [1.1.51](https://github.com/visulima/visulima/compare/@visulima/cerebro@1.1.50...@visulima/cerebro@1.1.51) (2025-09-23)
|
|
26
|
+
|
|
27
|
+
### Miscellaneous Chores
|
|
28
|
+
|
|
29
|
+
* update package.json and pnpm-lock.yaml to include publint@0.3.12 and adjust build/test commands to exclude shared-utils ([1f7b3c0](https://github.com/visulima/visulima/commit/1f7b3c0381d77edfeec80ea1bf57b3469e929414))
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
### Dependencies
|
|
33
|
+
|
|
34
|
+
* **@visulima/find-cache-dir:** upgraded to 1.0.35
|
|
35
|
+
* **@visulima/pail:** upgraded to 2.1.29
|
|
36
|
+
|
|
1
37
|
## @visulima/cerebro [1.1.50](https://github.com/visulima/visulima/compare/@visulima/cerebro@1.1.49...@visulima/cerebro@1.1.50) (2025-09-19)
|
|
2
38
|
|
|
3
39
|
### 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
|
-
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 At=Object.defineProperty;var O=(n,r)=>At(n,"name",{value:r,configurable:!0});import{createRequire as zt}from"node:module";import{findCacheDirSync as Et}from"@visulima/find-cache-dir";const Pt=zt(import.meta.url),C=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,le=O(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 Pt(n)},"__cjs_getBuiltinModule"),{existsSync:fe,mkdirSync:Ct,writeFileSync:Nt,readFileSync:St}=le("node:fs"),{get:Ut}=le("node:https");var It=Object.defineProperty,Zt=O((n,r)=>It(n,"name",{value:r,configurable:!0}),"o$1");const Rt=Zt((n,r)=>{const s=n.split(".").map(Number),u=r.split(".").map(Number);for(const[d,g]of s.entries()){if(g>u[d])return!0;if(g<u[d])return!1}return!1},"semverGt");var Bt=Object.defineProperty,T=O((n,r)=>Bt(n,"name",{value:r,configurable:!0}),"I"),Lt=Object.defineProperty,c=T((n,r)=>Lt(n,"name",{value:r,configurable:!0}),"__name$2");let ue=c(()=>{var n=(()=>{var r=Object.defineProperty,s=Object.getOwnPropertyDescriptor,u=Object.getOwnPropertyNames,d=Object.prototype.hasOwnProperty,g=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"),h=c(e=>x(r({},"__esModule",{value:!0}),e),"W"),y={};g(y,{zeptomatch:c(()=>jt,"zeptomatch")});var W=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"),ye=c(e=>typeof e=="object"&&e!==null,"rr"),be=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")})(),F=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"),Me=c((e,t,o={})=>{const a={cache:{},input:e,index:0,indexBacktrackMax:0,options:o,output:[]},i=M(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)=>W(e)?Oe(e,t):F(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 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"),ke=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)?Ae(i,t):ze(i,t)}},"ur"),Ae=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=M(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(M);return Z(I(V(a=>{for(let i=0,f=o.length;i<f;i++)if(!o[i](a))return!1;return!0}),t))},"_"),w=c((e,t)=>{const o=e.map(M);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=M(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=M(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=M(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 A=0,Mt=$.length;A<Mt;A+=2){const Ot=$[A*2],kt=$[A*2+1];P.set(Ot,kt)}$.length=0}const b=P.get(p);if(b===!1)return!1;if($e(b))return i.index=b,!0;if(b)return i.index=b.index,b.output?.length&&i.output.push(...b.output),!0}const ae=i.output.length,_t=o(i);if(m.indexMax=Math.max(m.indexMax,p),_t){const P=i.index,b=i.output.length;if(b>ae){const A=i.output.slice(ae,b);$.push(p,{index:P,output:A})}else $.push(p,P);return!0}else return $.push(p,!1),!1}}})(),K=c(e=>{let t;return o=>(t||(t=M(e())),t(o))},"A"),M=_e(e=>{if(z(e))return xe(e)?K(e):e;if(F(e)||be(e))return l(e);if(W(e))return E(e);if(ye(e))return w(Object.values(e));throw new Error("Invalid rule")}),j=c(e=>e,"v"),Y=c(e=>t=>Me(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"),R=c((e,t)=>{if(t<e)return R(t,e);const o=[];for(;e<=t;)o.push(e++);return o},"$"),Se=c((e,t,o)=>R(e,t).map(a=>String(a).padStart(o,"0")),"fr"),X=c((e,t)=>R(Q(e),Q(t)).map(Ne),"j"),B=l(/\\./,j),Ee=l(/[$.*+?^(){}[\]\|]/,e=>`\\${e}`),Ue=l(/./,j),Ie=l(/^(?:!!)*!(.*)$/,(e,t)=>`(?!^${ie(t)}$).*?`),Ze=l(/^(!!)+/,""),Re=w([Ie,Ze]),Be=l(/\/(\*\*\/)+/,"(?:[\\\\/].+[\\\\/]|[\\\\/])"),Le=l(/^(\*\*\/)+/,"(?:^|.*[\\\\/])"),De=l(/\/(\*\*)$/,"(?:[\\\\/].*|$)"),Te=l(/\*\*/,".*"),ee=w([Be,Le,De,Te]),qe=l(/\*\/(?!\*\*\/|\*$)/,"[^\\\\/]*[\\\\/]"),We=l(/\*/,"[^\\\\/]*"),te=w([qe,We]),ne=l("?","[^\\\\/]"),Fe=l("[",j),Je=l("]",j),Ge=l(/[!^]/,"^\\\\/"),Ve=l(/[a-z]-[a-z]|[0-9]-[0-9]/i,j),Ke=l(/[$.*+?^(){}[\|]/,e=>`\\${e}`),Ye=l(/[^\]]/,j),He=w([B,Ke,Ve,Ye]),re=E([Fe,Pe(Ge),S(He),Je]),Qe=l("{","(?:"),Xe=l("}",")"),et=l(/(\d+)\.\.(\d+)/,(e,t,o)=>Se(+t,+o,Math.min(t.length,o.length)).join("|")),tt=l(/([a-z]+)\.\.([a-z]+)/,(e,t,o)=>X(t,o).join("|")),nt=l(/([A-Z]+)\.\.([A-Z]+)/,(e,t,o)=>X(t.toLowerCase(),o.toLowerCase()).join("|").toUpperCase()),rt=w([et,tt,nt]),oe=E([Qe,rt,Xe]),ot=l("{","(?:"),st=l("}",")"),it=l(",","|"),at=l(/[$.*+?^(){[\]\|]/,e=>`\\${e}`),ut=l(/[^}]/,j),ct=K(()=>se),lt=w([ee,te,ne,re,oe,ct,B,at,it,ut]),se=E([ot,S(lt),st]),ft=S(w([Re,ee,te,ne,re,oe,se,B,Ee,Ue])),pt=ft,dt=Y(pt),ie=dt,gt=l(/\\./,j),ht=l(/./,j),mt=l(/\*\*\*+/,"*"),xt=l(/([^/{[(!])\*\*/,(e,t)=>`${t}*`),vt=l(/(^|.)\*\*(?=[^*/)\]}])/,(e,t)=>`${t}*`),$t=S(w([gt,mt,xt,vt,ht])),yt=$t,bt=Y(yt),wt=bt,U=c((e,t)=>Array.isArray(e)?e.map(U.compile).some(o=>o.test(t)):U.compile(e).test(t),"S");U.compile=Ce(e=>new RegExp(`^${ie(wt(e))}[\\\\/]?$`,"s"));var jt=U;return h(y)})();return n.default||n},"_lazyMatch"),L;const Dt=c((n,r)=>(L||(L=ue(),ue=null),L(n,r)),"default");var Tt=Object.defineProperty,qt=T((n,r)=>Tt(n,"name",{value:r,configurable:!0}),"__name$1");const Wt=/^[A-Z]:\//i,k=qt((n="")=>n&&n.replaceAll("\\","/").replace(Wt,r=>r.toUpperCase()),"normalizeWindowsPath");var Ft=Object.defineProperty,v=T((n,r)=>Ft(n,"name",{value:r,configurable:!0}),"__name");const Jt=/^[/\\]{2}/,Gt=/^[/\\](?![/\\])|^[/\\]{2}(?!\.)|^[A-Z]:[/\\]/i,pe=/^[A-Z]:$/i,ce=/^\/([A-Z]:)?$/i,Vt=/.(\.[^./]+)$/,Kt=/^[/\\]|^[a-z]:[/\\]/i,Yt=v(()=>typeof process.cwd=="function"?process.cwd().replaceAll("\\","/"):"/","cwd"),de=v((n,r)=>{let s="",u=0,d=-1,g=0,x=null;for(let h=0;h<=n.length;++h){if(h<n.length)x=n[h];else{if(x==="/")break;x="/"}if(x==="/"){if(!(d===h-1||g===1))if(g===2){if(s.length<2||u!==2||!s.endsWith(".")||s.at(-2)!=="."){if(s.length>2){const y=s.lastIndexOf("/");y===-1?(s="",u=0):(s=s.slice(0,y),u=s.length-1-s.lastIndexOf("/")),d=h,g=0;continue}else if(s.length>0){s="",u=0,d=h,g=0;continue}}r&&(s+=s.length>0?"/..":"..",u=2)}else s.length>0?s+=`/${n.slice(d+1,h)}`:s=n.slice(d+1,h),u=h-d-1;d=h,g=0}else x==="."&&g!==-1?++g:g=-1}return s},"normalizeString"),N=v(n=>Gt.test(n),"isAbsolute"),ge=v(function(n){if(n.length===0)return".";n=k(n);const r=Jt.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"),Ht=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 ge(r)},"join"),D=v(function(...n){n=n.map(u=>k(u));let r="",s=!1;for(let u=n.length-1;u>=-1&&!s;u--){const d=u>=0?n[u]:Yt();!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 k(n)},"toNamespacedPath");const Qt=v(function(n){return Vt.exec(k(n))?.[1]??""},"extname");v(function(n,r){const s=D(n).replace(ce,"$1").split("/"),u=D(r).replace(ce,"$1").split("/");if(u[0][1]===":"&&s[0][1]===":"&&s[0]!==u[0])return u.join("/");const d=[...s];for(const g of d){if(u[0]!==g)break;s.shift(),u.shift()}return[...s.map(()=>".."),...u].join("/")},"relative");const he=v(n=>{const r=k(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 k(n.root?D(...r):r.join("/"))},"format");const Xt=v((n,r)=>{const s=k(n).split("/").pop();return r&&s.endsWith(r)?s.slice(0,-r.length):s},"basename");v(function(n){const r=Kt.exec(n)?.[0]?.replace(/\\/g,"/")??"",s=Xt(n),u=Qt(s);return{base:s,dir:he(n),ext:u,name:s.slice(0,s.length-u.length),root:r}},"parse");v((n,r)=>Dt(r,ge(n)),"matchesGlob");var en=Object.defineProperty,q=O((n,r)=>en(n,"name",{value:r,configurable:!0}),"r");const tn="last-update-check.json",me=q(n=>{const r=Et(n);if(r===void 0)throw new Error("Could not find cache directory");return Ht(r,tn)},"getConfigFile"),nn=q(n=>{const r=me(n);try{if(!fe(r))return;const{lastUpdateCheck:s}=JSON.parse(St(r,"utf8"));return s}catch{return}},"getLastUpdate"),rn=q(n=>{const r=me(n),s=he(r);fe(s)||Ct(s,{recursive:!0}),Nt(r,JSON.stringify({lastUpdateCheck:Date.now()}))},"saveLastUpdate");var on=Object.defineProperty,sn=O((n,r)=>on(n,"name",{value:r,configurable:!0}),"g");const an=sn(async(n,r,s)=>{const u=s.replace("__NAME__",n);return await new Promise((d,g)=>{Ut(u,x=>{let h="";x.on("data",y=>h+=y),x.on("end",()=>{try{const y=JSON.parse(h)[r];y||g(new Error("Error getting version")),d(y)}catch{g(new Error("Could not parse version response"))}})}).on("error",x=>g(x))})},"getDistributionVersion");var un=Object.defineProperty,cn=O((n,r)=>un(n,"name",{value:r,configurable:!0}),"i");const dn=cn(async({alwaysRun:n,debug:r,distTag:s="latest",pkg:u,registryUrl:d="https://registry.npmjs.org/-/package/__NAME__/dist-tags",updateCheckInterval:g=1e3*60*60*24})=>{const x=nn(u.name);if(n||!x||x<Date.now()-g){const h=await an(u.name,s,d);if(rn(u.name),Rt(h,u.version))return h;r&&console.error(`Latest version (${h}) not newer than current version (${u.version})`)}else r&&console.error(`Too recent to check for a new update. simpleUpdateNotifier() interval set to ${g}ms but only ${Date.now()-x}ms since last check.`);return null},"hasNewVersion");export{dn 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.52",
|
|
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,16 +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.30",
|
|
93
93
|
"cli-table3": "^0.6.5",
|
|
94
94
|
"command-line-args": "^6.0.1",
|
|
95
95
|
"fastest-levenshtein": "^1.0.16"
|
|
96
96
|
},
|
|
97
97
|
"engines": {
|
|
98
|
-
"node": ">=18.0.0 <=
|
|
98
|
+
"node": ">=18.0.0 <=24.x"
|
|
99
99
|
},
|
|
100
100
|
"os": [
|
|
101
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};
|