@visulima/cerebro 1.1.49 → 1.1.51

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 CHANGED
@@ -1,3 +1,27 @@
1
+ ## @visulima/cerebro [1.1.51](https://github.com/visulima/visulima/compare/@visulima/cerebro@1.1.50...@visulima/cerebro@1.1.51) (2025-09-23)
2
+
3
+ ### Miscellaneous Chores
4
+
5
+ * 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))
6
+
7
+
8
+ ### Dependencies
9
+
10
+ * **@visulima/find-cache-dir:** upgraded to 1.0.35
11
+ * **@visulima/pail:** upgraded to 2.1.29
12
+
13
+ ## @visulima/cerebro [1.1.50](https://github.com/visulima/visulima/compare/@visulima/cerebro@1.1.49...@visulima/cerebro@1.1.50) (2025-09-19)
14
+
15
+ ### Miscellaneous Chores
16
+
17
+ * **deps:** update build scripts and remove cross-env dependency ([7510e82](https://github.com/visulima/visulima/commit/7510e826b9235a0013fe61c82a7eb333bc4cbb78))
18
+
19
+
20
+ ### Dependencies
21
+
22
+ * **@visulima/find-cache-dir:** upgraded to 1.0.34
23
+ * **@visulima/pail:** upgraded to 2.1.28
24
+
1
25
  ## @visulima/cerebro [1.1.49](https://github.com/visulima/visulima/compare/@visulima/cerebro@1.1.48...@visulima/cerebro@1.1.49) (2025-09-12)
2
26
 
3
27
 
package/dist/index.cjs CHANGED
@@ -1,7 +1 @@
1
- 'use strict';
2
-
3
- const _default = require('./packem_shared/default-Dh6tpT9Q.cjs');
4
-
5
-
6
-
7
- module.exports = _default.Cli;
1
+ "use strict";const e=require("./packem_shared/default-BD7MGssY.cjs");module.exports=e.Cli;
package/dist/index.mjs CHANGED
@@ -1 +1 @@
1
- export { Cli as default } from './packem_shared/default-BkGsvBYT.mjs';
1
+ import{Cli as f}from"./packem_shared/default-DRd7Q7Xw.mjs";export{f as default};
@@ -1,243 +1 @@
1
- 'use strict';
2
-
3
- Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
4
-
5
- const node_fs = require('node:fs');
6
- const findCacheDir = require('@visulima/find-cache-dir');
7
- const node_https = require('node:https');
8
-
9
- var __defProp$4 = Object.defineProperty;
10
- var __name$4 = (target, value) => __defProp$4(target, "name", { value, configurable: true });
11
- const semverGt = /* @__PURE__ */ __name$4((version1, version2) => {
12
- const v1Components = version1.split(".").map(Number);
13
- const v2Components = version2.split(".").map(Number);
14
- for (const [index, v1Component] of v1Components.entries()) {
15
- if (v1Component > v2Components[index]) {
16
- return true;
17
- }
18
- if (v1Component < v2Components[index]) {
19
- return false;
20
- }
21
- }
22
- return false;
23
- }, "semverGt");
24
-
25
- var __defProp$3 = Object.defineProperty;
26
- var __name$3 = (target, value) => __defProp$3(target, "name", { value, configurable: true });
27
- var __defProp$1$1 = Object.defineProperty;
28
- var __name$1$1 = /* @__PURE__ */ __name$3((target, value) => __defProp$1$1(target, "name", { value, configurable: true }), "__name$1");
29
- const DRIVE_LETTER_START_RE = /^[A-Z]:\//i;
30
- const normalizeWindowsPath = /* @__PURE__ */ __name$1$1((input = "") => {
31
- if (!input) {
32
- return input;
33
- }
34
- return input.replaceAll("\\", "/").replace(DRIVE_LETTER_START_RE, (r) => r.toUpperCase());
35
- }, "normalizeWindowsPath");
36
- var __defProp2 = Object.defineProperty;
37
- var __name2 = /* @__PURE__ */ __name$3((target, value) => __defProp2(target, "name", { value, configurable: true }), "__name");
38
- const UNC_REGEX = /^[/\\]{2}/;
39
- const IS_ABSOLUTE_RE = /^[/\\](?![/\\])|^[/\\]{2}(?!\.)|^[A-Z]:[/\\]/i;
40
- const DRIVE_LETTER_RE = /^[A-Z]:$/i;
41
- const normalizeString = /* @__PURE__ */ __name2((path2, allowAboveRoot) => {
42
- let result = "";
43
- let lastSegmentLength = 0;
44
- let lastSlash = -1;
45
- let dots = 0;
46
- let char = null;
47
- for (let index = 0; index <= path2.length; ++index) {
48
- if (index < path2.length) {
49
- char = path2[index];
50
- } else if (char === "/") {
51
- break;
52
- } else {
53
- char = "/";
54
- }
55
- if (char === "/") {
56
- if (lastSlash === index - 1 || dots === 1) ;
57
- else if (dots === 2) {
58
- if (result.length < 2 || lastSegmentLength !== 2 || !result.endsWith(".") || result.at(-2) !== ".") {
59
- if (result.length > 2) {
60
- const lastSlashIndex = result.lastIndexOf("/");
61
- if (lastSlashIndex === -1) {
62
- result = "";
63
- lastSegmentLength = 0;
64
- } else {
65
- result = result.slice(0, lastSlashIndex);
66
- lastSegmentLength = result.length - 1 - result.lastIndexOf("/");
67
- }
68
- lastSlash = index;
69
- dots = 0;
70
- continue;
71
- } else if (result.length > 0) {
72
- result = "";
73
- lastSegmentLength = 0;
74
- lastSlash = index;
75
- dots = 0;
76
- continue;
77
- }
78
- }
79
- if (allowAboveRoot) {
80
- result += result.length > 0 ? "/.." : "..";
81
- lastSegmentLength = 2;
82
- }
83
- } else {
84
- if (result.length > 0) {
85
- result += `/${path2.slice(lastSlash + 1, index)}`;
86
- } else {
87
- result = path2.slice(lastSlash + 1, index);
88
- }
89
- lastSegmentLength = index - lastSlash - 1;
90
- }
91
- lastSlash = index;
92
- dots = 0;
93
- } else if (char === "." && dots !== -1) {
94
- ++dots;
95
- } else {
96
- dots = -1;
97
- }
98
- }
99
- return result;
100
- }, "normalizeString");
101
- const isAbsolute = /* @__PURE__ */ __name2((path2) => IS_ABSOLUTE_RE.test(path2), "isAbsolute");
102
- const normalize = /* @__PURE__ */ __name2(function(path2) {
103
- if (path2.length === 0) {
104
- return ".";
105
- }
106
- path2 = normalizeWindowsPath(path2);
107
- const isUNCPath = UNC_REGEX.exec(path2);
108
- const isPathAbsolute = isAbsolute(path2);
109
- const trailingSeparator = path2.at(-1) === "/";
110
- path2 = normalizeString(path2, !isPathAbsolute);
111
- if (path2.length === 0) {
112
- if (isPathAbsolute) {
113
- return "/";
114
- }
115
- return trailingSeparator ? "./" : ".";
116
- }
117
- if (trailingSeparator) {
118
- path2 += "/";
119
- }
120
- if (DRIVE_LETTER_RE.test(path2)) {
121
- path2 += "/";
122
- }
123
- if (isUNCPath) {
124
- if (!isPathAbsolute) {
125
- return `//./${path2}`;
126
- }
127
- return `//${path2}`;
128
- }
129
- return isPathAbsolute && !isAbsolute(path2) ? `/${path2}` : path2;
130
- }, "normalize");
131
- const join = /* @__PURE__ */ __name2((...segments) => {
132
- let path2 = "";
133
- for (const seg of segments) {
134
- if (!seg) {
135
- continue;
136
- }
137
- if (path2.length > 0) {
138
- const pathTrailing = path2[path2.length - 1] === "/";
139
- const segLeading = seg[0] === "/";
140
- const both = pathTrailing && segLeading;
141
- if (both) {
142
- path2 += seg.slice(1);
143
- } else {
144
- path2 += pathTrailing || segLeading ? seg : `/${seg}`;
145
- }
146
- } else {
147
- path2 += seg;
148
- }
149
- }
150
- return normalize(path2);
151
- }, "join");
152
- const dirname = /* @__PURE__ */ __name2((path2) => {
153
- const segments = normalizeWindowsPath(path2).replace(/\/$/, "").split("/").slice(0, -1);
154
- if (segments.length === 1 && DRIVE_LETTER_RE.test(segments[0])) {
155
- segments[0] += "/";
156
- }
157
- return segments.join("/") || (isAbsolute(path2) ? "/" : ".");
158
- }, "dirname");
159
-
160
- var __defProp$2 = Object.defineProperty;
161
- var __name$2 = (target, value) => __defProp$2(target, "name", { value, configurable: true });
162
- const FILE_NAME = "last-update-check.json";
163
- const getConfigFile = /* @__PURE__ */ __name$2((packageName) => {
164
- const cacheDirectory = findCacheDir.findCacheDirSync(packageName);
165
- if (cacheDirectory === void 0) {
166
- throw new Error("Could not find cache directory");
167
- }
168
- return join(cacheDirectory, FILE_NAME);
169
- }, "getConfigFile");
170
- const getLastUpdate = /* @__PURE__ */ __name$2((packageName) => {
171
- const configFile = getConfigFile(packageName);
172
- try {
173
- if (!node_fs.existsSync(configFile)) {
174
- return void 0;
175
- }
176
- const { lastUpdateCheck } = JSON.parse(node_fs.readFileSync(configFile, "utf8"));
177
- return lastUpdateCheck;
178
- } catch {
179
- return void 0;
180
- }
181
- }, "getLastUpdate");
182
- const saveLastUpdate = /* @__PURE__ */ __name$2((packageName) => {
183
- const configFile = getConfigFile(packageName);
184
- const configDirectory = dirname(configFile);
185
- if (!node_fs.existsSync(configDirectory)) {
186
- node_fs.mkdirSync(configDirectory, { recursive: true });
187
- }
188
- node_fs.writeFileSync(configFile, JSON.stringify({ lastUpdateCheck: Date.now() }));
189
- }, "saveLastUpdate");
190
-
191
- var __defProp$1 = Object.defineProperty;
192
- var __name$1 = (target, value) => __defProp$1(target, "name", { value, configurable: true });
193
- const getDistributionVersion = /* @__PURE__ */ __name$1(async (packageName, distributionTag, registryUrl) => {
194
- const url = registryUrl.replace("__NAME__", packageName);
195
- return await new Promise((resolve, reject) => {
196
- node_https.get(url, (message) => {
197
- let body = "";
198
- message.on("data", (chunk) => body += chunk);
199
- message.on("end", () => {
200
- try {
201
- const json = JSON.parse(body);
202
- const version = json[distributionTag];
203
- if (!version) {
204
- reject(new Error("Error getting version"));
205
- }
206
- resolve(version);
207
- } catch {
208
- reject(new Error("Could not parse version response"));
209
- }
210
- });
211
- }).on("error", (error) => reject(error));
212
- });
213
- }, "getDistributionVersion");
214
-
215
- var __defProp = Object.defineProperty;
216
- var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
217
- const hasNewVersion = /* @__PURE__ */ __name(async ({
218
- alwaysRun,
219
- debug,
220
- distTag: distributionTag = "latest",
221
- pkg,
222
- registryUrl = "https://registry.npmjs.org/-/package/__NAME__/dist-tags",
223
- updateCheckInterval = 1e3 * 60 * 60 * 24
224
- }) => {
225
- const lastUpdateCheck = getLastUpdate(pkg.name);
226
- if (alwaysRun || !lastUpdateCheck || lastUpdateCheck < Date.now() - updateCheckInterval) {
227
- const latestVersion = await getDistributionVersion(pkg.name, distributionTag, registryUrl);
228
- saveLastUpdate(pkg.name);
229
- if (semverGt(latestVersion, pkg.version)) {
230
- return latestVersion;
231
- }
232
- if (debug) {
233
- console.error(`Latest version (${latestVersion}) not newer than current version (${pkg.version})`);
234
- }
235
- } else if (debug) {
236
- console.error(
237
- `Too recent to check for a new update. simpleUpdateNotifier() interval set to ${updateCheckInterval}ms but only ${Date.now() - lastUpdateCheck}ms since last check.`
238
- );
239
- }
240
- return null;
241
- }, "hasNewVersion");
242
-
243
- exports.default = hasNewVersion;
1
+ "use strict";var kt=Object.defineProperty;var A=(n,o)=>kt(n,"name",{value:o,configurable:!0});Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const S=require("node:fs"),Mt=require("@visulima/find-cache-dir"),At=require("node:https");var zt=Object.defineProperty,Pt=A((n,o)=>zt(n,"name",{value:o,configurable:!0}),"o$1");const St=Pt((n,o)=>{const i=n.split(".").map(Number),u=o.split(".").map(Number);for(const[d,h]of i.entries()){if(h>u[d])return!0;if(h<u[d])return!1}return!1},"semverGt");var Ct=Object.defineProperty,B=A((n,o)=>Ct(n,"name",{value:o,configurable:!0}),"I"),Et=Object.defineProperty,c=B((n,o)=>Et(n,"name",{value:o,configurable:!0}),"__name$2");let ue=c(()=>{var n=(()=>{var o=Object.defineProperty,i=Object.getOwnPropertyDescriptor,u=Object.getOwnPropertyNames,d=Object.prototype.hasOwnProperty,h=c((e,t)=>{for(var r in t)o(e,r,{get:t[r],enumerable:!0})},"J"),x=c((e,t,r,a)=>{if(t&&typeof t=="object"||typeof t=="function")for(let s of u(t))!d.call(e,s)&&s!==r&&o(e,s,{get:c(()=>t[s],"get"),enumerable:!(a=i(t,s))||a.enumerable});return e},"T"),g=c(e=>x(o({},"__esModule",{value:!0}),e),"W"),y={};h(y,{zeptomatch:c(()=>bt,"zeptomatch")});var F=c(e=>Array.isArray(e),"k"),z=c(e=>typeof e=="function","x"),ge=c(e=>e.length===0,"K"),me=(()=>{const{toString:e}=Function.prototype,t=/(?:^\(\s*(?:[^,.()]|\.(?!\.\.))*\s*\)\s*=>|^\s*[a-zA-Z$_][a-zA-Z0-9$_]*\s*=>)/;return r=>(r.length===0||r.length===1)&&t.test(e.call(r))})(),xe=c(e=>typeof e=="number","Y"),ve=c(e=>typeof e=="object"&&e!==null,"rr"),$e=c(e=>e instanceof RegExp,"er"),ye=(()=>{const e=/\\\(|\((?!\?(?::|=|!|<=|<!))/;return t=>e.test(t.source)})(),be=(()=>{const e=/^[a-zA-Z0-9_-]+$/;return t=>e.test(t.source)&&!t.flags.includes("i")})(),T=c(e=>typeof e=="string","M"),O=c(e=>e===void 0,"f"),we=c(e=>{const t=new Map;return r=>{const a=t.get(r);if(a!==void 0)return a;const s=e(r);return t.set(r,s),s}},"ar"),je=c((e,t,r={})=>{const a={cache:{},input:e,index:0,indexBacktrackMax:0,options:r,output:[]},s=_(t)(a),f=Math.max(a.index,a.indexBacktrackMax);if(s&&a.index===e.length)return a.output;throw new Error(`Failed to parse at index ${f}`)},"or"),l=c((e,t)=>F(e)?Oe(e,t):T(e)?J(e,t):_e(e,t),"o"),Oe=c((e,t)=>{const r={};for(const a of e){if(a.length!==1)throw new Error(`Invalid character: "${a}"`);const s=a.charCodeAt(0);r[s]=!0}return a=>{const s=a.input;let f=a.index,p=f;for(;p<s.length&&s.charCodeAt(p)in r;)p+=1;if(p>f){if(!O(t)&&!a.options.silent){const m=s.slice(f,p),$=z(t)?t(m,s,`${f}`):t;O($)||a.output.push($)}a.index=p}return!0}},"ir"),_e=c((e,t)=>{if(be(e))return J(e.source,t);{const r=e.source,a=e.flags.replace(/y|$/,"y"),s=new RegExp(r,a);return ye(e)&&z(t)&&!me(t)?ke(s,t):Me(s,t)}},"ur"),ke=c((e,t)=>r=>{const a=r.index,s=r.input;e.lastIndex=a;const f=e.exec(s);if(f){const p=e.lastIndex;if(!r.options.silent){const m=t(...f,s,`${a}`);O(m)||r.output.push(m)}return r.index=p,!0}else return!1},"sr"),Me=c((e,t)=>r=>{const a=r.index,s=r.input;if(e.lastIndex=a,e.test(s)){const f=e.lastIndex;if(!O(t)&&!r.options.silent){const p=z(t)?t(s.slice(a,f),s,`${a}`):t;O(p)||r.output.push(p)}return r.index=f,!0}else return!1},"cr"),J=c((e,t)=>r=>{const a=r.index,s=r.input;if(s.startsWith(e,a)){if(!O(t)&&!r.options.silent){const f=z(t)?t(e,s,`${a}`):t;O(f)||r.output.push(f)}return r.index+=e.length,!0}else return!1},"R"),G=c((e,t,r,a)=>{const s=_(e),f=t>1;return Z(I(V(p=>{let m=0;for(;m<r;){const $=p.index;if(!s(p)||(m+=1,p.index===$))break}return m>=t},f),a))},"O"),Ae=c((e,t)=>G(e,0,1,t),"lr"),E=c((e,t)=>G(e,0,1/0,t),"m"),N=c((e,t)=>{const r=e.map(_);return Z(I(V(a=>{for(let s=0,f=r.length;s<f;s++)if(!r[s](a))return!1;return!0}),t))},"_"),w=c((e,t)=>{const r=e.map(_);return Z(I(a=>{for(let s=0,f=r.length;s<f;s++)if(r[s](a))return!0;return!1},t))},"p"),V=c((e,t=!0,r=!1)=>{const a=_(e);return t?s=>{const f=s.index,p=s.output.length,m=a(s);return!m&&!r&&(s.indexBacktrackMax=Math.max(s.indexBacktrackMax,s.index)),(!m||r)&&(s.index=f,s.output.length!==p&&(s.output.length=p)),m}:a},"P"),I=c((e,t)=>{const r=_(e);return t?a=>{if(a.options.silent)return r(a);const s=a.output.length;if(r(a)){const f=a.output.splice(s,1/0),p=t(f);return O(p)||a.output.push(p),!0}else return!1}:r},"C"),Z=(()=>{let e=0;return t=>{const r=_(t),a=e+=1;return s=>{var f;if(s.options.memoization===!1)return r(s);const p=s.index,m=(f=s.cache)[a]||(f[a]={indexMax:-1,queue:[]}),$=m.queue;if(p<=m.indexMax){const P=m.store||(m.store=new Map);if($.length){for(let M=0,jt=$.length;M<jt;M+=2){const Ot=$[M*2],_t=$[M*2+1];P.set(Ot,_t)}$.length=0}const b=P.get(p);if(b===!1)return!1;if(xe(b))return s.index=b,!0;if(b)return s.index=b.index,b.output?.length&&s.output.push(...b.output),!0}const ae=s.output.length,wt=r(s);if(m.indexMax=Math.max(m.indexMax,p),wt){const P=s.index,b=s.output.length;if(b>ae){const M=s.output.slice(ae,b);$.push(p,{index:P,output:M})}else $.push(p,P);return!0}else return $.push(p,!1),!1}}})(),K=c(e=>{let t;return r=>(t||(t=_(e())),t(r))},"A"),_=we(e=>{if(z(e))return ge(e)?K(e):e;if(T(e)||$e(e))return l(e);if(F(e))return N(e);if(ve(e))return w(Object.values(e));throw new Error("Invalid rule")}),j=c(e=>e,"v"),Y=c(e=>t=>je(t,e,{memoization:!1}).join(""),"z"),ze=c(e=>{const t={};return r=>t[r]??(t[r]=e(r))},"pr"),H="abcdefghijklmnopqrstuvwxyz",Pe=c(e=>{let t="";for(;e>0;){const r=(e-1)%26;t=H[r]+t,e=Math.floor((e-1)/26)}return t},"vr"),Q=c(e=>{let t=0;for(let r=0,a=e.length;r<a;r++)t=t*26+H.indexOf(e[r])+1;return t},"N"),D=c((e,t)=>{if(t<e)return D(t,e);const r=[];for(;e<=t;)r.push(e++);return r},"$"),Se=c((e,t,r)=>D(e,t).map(a=>String(a).padStart(r,"0")),"fr"),X=c((e,t)=>D(Q(e),Q(t)).map(Pe),"j"),L=l(/\\./,j),Ce=l(/[$.*+?^(){}[\]\|]/,e=>`\\${e}`),Ee=l(/./,j),Ne=l(/^(?:!!)*!(.*)$/,(e,t)=>`(?!^${ie(t)}$).*?`),Ue=l(/^(!!)+/,""),Ie=w([Ne,Ue]),Ze=l(/\/(\*\*\/)+/,"(?:[\\\\/].+[\\\\/]|[\\\\/])"),De=l(/^(\*\*\/)+/,"(?:^|.*[\\\\/])"),Le=l(/\/(\*\*)$/,"(?:[\\\\/].*|$)"),Re=l(/\*\*/,".*"),ee=w([Ze,De,Le,Re]),qe=l(/\*\/(?!\*\*\/|\*$)/,"[^\\\\/]*[\\\\/]"),Be=l(/\*/,"[^\\\\/]*"),te=w([qe,Be]),ne=l("?","[^\\\\/]"),We=l("[",j),Fe=l("]",j),Te=l(/[!^]/,"^\\\\/"),Je=l(/[a-z]-[a-z]|[0-9]-[0-9]/i,j),Ge=l(/[$.*+?^(){}[\|]/,e=>`\\${e}`),Ve=l(/[^\]]/,j),Ke=w([L,Ge,Je,Ve]),re=N([We,Ae(Te),E(Ke),Fe]),Ye=l("{","(?:"),He=l("}",")"),Qe=l(/(\d+)\.\.(\d+)/,(e,t,r)=>Se(+t,+r,Math.min(t.length,r.length)).join("|")),Xe=l(/([a-z]+)\.\.([a-z]+)/,(e,t,r)=>X(t,r).join("|")),et=l(/([A-Z]+)\.\.([A-Z]+)/,(e,t,r)=>X(t.toLowerCase(),r.toLowerCase()).join("|").toUpperCase()),tt=w([Qe,Xe,et]),oe=N([Ye,tt,He]),nt=l("{","(?:"),rt=l("}",")"),ot=l(",","|"),st=l(/[$.*+?^(){[\]\|]/,e=>`\\${e}`),it=l(/[^}]/,j),at=K(()=>se),ut=w([ee,te,ne,re,oe,at,L,st,ot,it]),se=N([nt,E(ut),rt]),ct=E(w([Ie,ee,te,ne,re,oe,se,L,Ce,Ee])),lt=ct,ft=Y(lt),ie=ft,pt=l(/\\./,j),dt=l(/./,j),ht=l(/\*\*\*+/,"*"),gt=l(/([^/{[(!])\*\*/,(e,t)=>`${t}*`),mt=l(/(^|.)\*\*(?=[^*/)\]}])/,(e,t)=>`${t}*`),xt=E(w([pt,ht,gt,mt,dt])),vt=xt,$t=Y(vt),yt=$t,U=c((e,t)=>Array.isArray(e)?e.map(U.compile).some(r=>r.test(t)):U.compile(e).test(t),"S");U.compile=ze(e=>new RegExp(`^${ie(yt(e))}[\\\\/]?$`,"s"));var bt=U;return g(y)})();return n.default||n},"_lazyMatch"),R;const Nt=c((n,o)=>(R||(R=ue(),ue=null),R(n,o)),"default");var Ut=Object.defineProperty,It=B((n,o)=>Ut(n,"name",{value:o,configurable:!0}),"__name$1");const Zt=/^[A-Z]:\//i,k=It((n="")=>n&&n.replaceAll("\\","/").replace(Zt,o=>o.toUpperCase()),"normalizeWindowsPath");var Dt=Object.defineProperty,v=B((n,o)=>Dt(n,"name",{value:o,configurable:!0}),"__name");const Lt=/^[/\\]{2}/,Rt=/^[/\\](?![/\\])|^[/\\]{2}(?!\.)|^[A-Z]:[/\\]/i,le=/^[A-Z]:$/i,ce=/^\/([A-Z]:)?$/i,qt=/.(\.[^./]+)$/,Bt=/^[/\\]|^[a-z]:[/\\]/i,Wt=v(()=>typeof process.cwd=="function"?process.cwd().replaceAll("\\","/"):"/","cwd"),fe=v((n,o)=>{let i="",u=0,d=-1,h=0,x=null;for(let g=0;g<=n.length;++g){if(g<n.length)x=n[g];else{if(x==="/")break;x="/"}if(x==="/"){if(!(d===g-1||h===1))if(h===2){if(i.length<2||u!==2||!i.endsWith(".")||i.at(-2)!=="."){if(i.length>2){const y=i.lastIndexOf("/");y===-1?(i="",u=0):(i=i.slice(0,y),u=i.length-1-i.lastIndexOf("/")),d=g,h=0;continue}else if(i.length>0){i="",u=0,d=g,h=0;continue}}o&&(i+=i.length>0?"/..":"..",u=2)}else i.length>0?i+=`/${n.slice(d+1,g)}`:i=n.slice(d+1,g),u=g-d-1;d=g,h=0}else x==="."&&h!==-1?++h:h=-1}return i},"normalizeString"),C=v(n=>Rt.test(n),"isAbsolute"),pe=v(function(n){if(n.length===0)return".";n=k(n);const o=Lt.exec(n),i=C(n),u=n.at(-1)==="/";return n=fe(n,!i),n.length===0?i?"/":u?"./":".":(u&&(n+="/"),le.test(n)&&(n+="/"),o?i?`//${n}`:`//./${n}`:i&&!C(n)?`/${n}`:n)},"normalize"),Ft=v((...n)=>{let o="";for(const i of n)if(i)if(o.length>0){const u=o[o.length-1]==="/",d=i[0]==="/";u&&d?o+=i.slice(1):o+=u||d?i:`/${i}`}else o+=i;return pe(o)},"join"),q=v(function(...n){n=n.map(u=>k(u));let o="",i=!1;for(let u=n.length-1;u>=-1&&!i;u--){const d=u>=0?n[u]:Wt();!d||d.length===0||(o=`${d}/${o}`,i=C(d))}return o=fe(o,!i),i&&!C(o)?`/${o}`:o.length>0?o:"."},"resolve");v(function(n){return k(n)},"toNamespacedPath");const Tt=v(function(n){return qt.exec(k(n))?.[1]??""},"extname");v(function(n,o){const i=q(n).replace(ce,"$1").split("/"),u=q(o).replace(ce,"$1").split("/");if(u[0][1]===":"&&i[0][1]===":"&&i[0]!==u[0])return u.join("/");const d=[...i];for(const h of d){if(u[0]!==h)break;i.shift(),u.shift()}return[...i.map(()=>".."),...u].join("/")},"relative");const de=v(n=>{const o=k(n).replace(/\/$/,"").split("/").slice(0,-1);return o.length===1&&le.test(o[0])&&(o[0]+="/"),o.join("/")||(C(n)?"/":".")},"dirname");v(function(n){const o=[n.root,n.dir,n.base??n.name+n.ext].filter(Boolean);return k(n.root?q(...o):o.join("/"))},"format");const Jt=v((n,o)=>{const i=k(n).split("/").pop();return o&&i.endsWith(o)?i.slice(0,-o.length):i},"basename");v(function(n){const o=Bt.exec(n)?.[0]?.replace(/\\/g,"/")??"",i=Jt(n),u=Tt(i);return{base:i,dir:de(n),ext:u,name:i.slice(0,i.length-u.length),root:o}},"parse");v((n,o)=>Nt(o,pe(n)),"matchesGlob");var Gt=Object.defineProperty,W=A((n,o)=>Gt(n,"name",{value:o,configurable:!0}),"r");const Vt="last-update-check.json",he=W(n=>{const o=Mt.findCacheDirSync(n);if(o===void 0)throw new Error("Could not find cache directory");return Ft(o,Vt)},"getConfigFile"),Kt=W(n=>{const o=he(n);try{if(!S.existsSync(o))return;const{lastUpdateCheck:i}=JSON.parse(S.readFileSync(o,"utf8"));return i}catch{return}},"getLastUpdate"),Yt=W(n=>{const o=he(n),i=de(o);S.existsSync(i)||S.mkdirSync(i,{recursive:!0}),S.writeFileSync(o,JSON.stringify({lastUpdateCheck:Date.now()}))},"saveLastUpdate");var Ht=Object.defineProperty,Qt=A((n,o)=>Ht(n,"name",{value:o,configurable:!0}),"g");const Xt=Qt(async(n,o,i)=>{const u=i.replace("__NAME__",n);return await new Promise((d,h)=>{At.get(u,x=>{let g="";x.on("data",y=>g+=y),x.on("end",()=>{try{const y=JSON.parse(g)[o];y||h(new Error("Error getting version")),d(y)}catch{h(new Error("Could not parse version response"))}})}).on("error",x=>h(x))})},"getDistributionVersion");var en=Object.defineProperty,tn=A((n,o)=>en(n,"name",{value:o,configurable:!0}),"i");const nn=tn(async({alwaysRun:n,debug:o,distTag:i="latest",pkg:u,registryUrl:d="https://registry.npmjs.org/-/package/__NAME__/dist-tags",updateCheckInterval:h=1e3*60*60*24})=>{const x=Kt(u.name);if(n||!x||x<Date.now()-h){const g=await Xt(u.name,i,d);if(Yt(u.name),St(g,u.version))return g;o&&console.error(`Latest version (${g}) not newer than current version (${u.version})`)}else o&&console.error(`Too recent to check for a new update. simpleUpdateNotifier() interval set to ${h}ms but only ${Date.now()-x}ms since last check.`);return null},"hasNewVersion");exports.default=nn;
@@ -1,239 +1 @@
1
- import { existsSync, mkdirSync, writeFileSync, readFileSync } from 'node:fs';
2
- import { findCacheDirSync } from '@visulima/find-cache-dir';
3
- import { get } from 'node:https';
4
-
5
- var __defProp$4 = Object.defineProperty;
6
- var __name$4 = (target, value) => __defProp$4(target, "name", { value, configurable: true });
7
- const semverGt = /* @__PURE__ */ __name$4((version1, version2) => {
8
- const v1Components = version1.split(".").map(Number);
9
- const v2Components = version2.split(".").map(Number);
10
- for (const [index, v1Component] of v1Components.entries()) {
11
- if (v1Component > v2Components[index]) {
12
- return true;
13
- }
14
- if (v1Component < v2Components[index]) {
15
- return false;
16
- }
17
- }
18
- return false;
19
- }, "semverGt");
20
-
21
- var __defProp$3 = Object.defineProperty;
22
- var __name$3 = (target, value) => __defProp$3(target, "name", { value, configurable: true });
23
- var __defProp$1$1 = Object.defineProperty;
24
- var __name$1$1 = /* @__PURE__ */ __name$3((target, value) => __defProp$1$1(target, "name", { value, configurable: true }), "__name$1");
25
- const DRIVE_LETTER_START_RE = /^[A-Z]:\//i;
26
- const normalizeWindowsPath = /* @__PURE__ */ __name$1$1((input = "") => {
27
- if (!input) {
28
- return input;
29
- }
30
- return input.replaceAll("\\", "/").replace(DRIVE_LETTER_START_RE, (r) => r.toUpperCase());
31
- }, "normalizeWindowsPath");
32
- var __defProp2 = Object.defineProperty;
33
- var __name2 = /* @__PURE__ */ __name$3((target, value) => __defProp2(target, "name", { value, configurable: true }), "__name");
34
- const UNC_REGEX = /^[/\\]{2}/;
35
- const IS_ABSOLUTE_RE = /^[/\\](?![/\\])|^[/\\]{2}(?!\.)|^[A-Z]:[/\\]/i;
36
- const DRIVE_LETTER_RE = /^[A-Z]:$/i;
37
- const normalizeString = /* @__PURE__ */ __name2((path2, allowAboveRoot) => {
38
- let result = "";
39
- let lastSegmentLength = 0;
40
- let lastSlash = -1;
41
- let dots = 0;
42
- let char = null;
43
- for (let index = 0; index <= path2.length; ++index) {
44
- if (index < path2.length) {
45
- char = path2[index];
46
- } else if (char === "/") {
47
- break;
48
- } else {
49
- char = "/";
50
- }
51
- if (char === "/") {
52
- if (lastSlash === index - 1 || dots === 1) ;
53
- else if (dots === 2) {
54
- if (result.length < 2 || lastSegmentLength !== 2 || !result.endsWith(".") || result.at(-2) !== ".") {
55
- if (result.length > 2) {
56
- const lastSlashIndex = result.lastIndexOf("/");
57
- if (lastSlashIndex === -1) {
58
- result = "";
59
- lastSegmentLength = 0;
60
- } else {
61
- result = result.slice(0, lastSlashIndex);
62
- lastSegmentLength = result.length - 1 - result.lastIndexOf("/");
63
- }
64
- lastSlash = index;
65
- dots = 0;
66
- continue;
67
- } else if (result.length > 0) {
68
- result = "";
69
- lastSegmentLength = 0;
70
- lastSlash = index;
71
- dots = 0;
72
- continue;
73
- }
74
- }
75
- if (allowAboveRoot) {
76
- result += result.length > 0 ? "/.." : "..";
77
- lastSegmentLength = 2;
78
- }
79
- } else {
80
- if (result.length > 0) {
81
- result += `/${path2.slice(lastSlash + 1, index)}`;
82
- } else {
83
- result = path2.slice(lastSlash + 1, index);
84
- }
85
- lastSegmentLength = index - lastSlash - 1;
86
- }
87
- lastSlash = index;
88
- dots = 0;
89
- } else if (char === "." && dots !== -1) {
90
- ++dots;
91
- } else {
92
- dots = -1;
93
- }
94
- }
95
- return result;
96
- }, "normalizeString");
97
- const isAbsolute = /* @__PURE__ */ __name2((path2) => IS_ABSOLUTE_RE.test(path2), "isAbsolute");
98
- const normalize = /* @__PURE__ */ __name2(function(path2) {
99
- if (path2.length === 0) {
100
- return ".";
101
- }
102
- path2 = normalizeWindowsPath(path2);
103
- const isUNCPath = UNC_REGEX.exec(path2);
104
- const isPathAbsolute = isAbsolute(path2);
105
- const trailingSeparator = path2.at(-1) === "/";
106
- path2 = normalizeString(path2, !isPathAbsolute);
107
- if (path2.length === 0) {
108
- if (isPathAbsolute) {
109
- return "/";
110
- }
111
- return trailingSeparator ? "./" : ".";
112
- }
113
- if (trailingSeparator) {
114
- path2 += "/";
115
- }
116
- if (DRIVE_LETTER_RE.test(path2)) {
117
- path2 += "/";
118
- }
119
- if (isUNCPath) {
120
- if (!isPathAbsolute) {
121
- return `//./${path2}`;
122
- }
123
- return `//${path2}`;
124
- }
125
- return isPathAbsolute && !isAbsolute(path2) ? `/${path2}` : path2;
126
- }, "normalize");
127
- const join = /* @__PURE__ */ __name2((...segments) => {
128
- let path2 = "";
129
- for (const seg of segments) {
130
- if (!seg) {
131
- continue;
132
- }
133
- if (path2.length > 0) {
134
- const pathTrailing = path2[path2.length - 1] === "/";
135
- const segLeading = seg[0] === "/";
136
- const both = pathTrailing && segLeading;
137
- if (both) {
138
- path2 += seg.slice(1);
139
- } else {
140
- path2 += pathTrailing || segLeading ? seg : `/${seg}`;
141
- }
142
- } else {
143
- path2 += seg;
144
- }
145
- }
146
- return normalize(path2);
147
- }, "join");
148
- const dirname = /* @__PURE__ */ __name2((path2) => {
149
- const segments = normalizeWindowsPath(path2).replace(/\/$/, "").split("/").slice(0, -1);
150
- if (segments.length === 1 && DRIVE_LETTER_RE.test(segments[0])) {
151
- segments[0] += "/";
152
- }
153
- return segments.join("/") || (isAbsolute(path2) ? "/" : ".");
154
- }, "dirname");
155
-
156
- var __defProp$2 = Object.defineProperty;
157
- var __name$2 = (target, value) => __defProp$2(target, "name", { value, configurable: true });
158
- const FILE_NAME = "last-update-check.json";
159
- const getConfigFile = /* @__PURE__ */ __name$2((packageName) => {
160
- const cacheDirectory = findCacheDirSync(packageName);
161
- if (cacheDirectory === void 0) {
162
- throw new Error("Could not find cache directory");
163
- }
164
- return join(cacheDirectory, FILE_NAME);
165
- }, "getConfigFile");
166
- const getLastUpdate = /* @__PURE__ */ __name$2((packageName) => {
167
- const configFile = getConfigFile(packageName);
168
- try {
169
- if (!existsSync(configFile)) {
170
- return void 0;
171
- }
172
- const { lastUpdateCheck } = JSON.parse(readFileSync(configFile, "utf8"));
173
- return lastUpdateCheck;
174
- } catch {
175
- return void 0;
176
- }
177
- }, "getLastUpdate");
178
- const saveLastUpdate = /* @__PURE__ */ __name$2((packageName) => {
179
- const configFile = getConfigFile(packageName);
180
- const configDirectory = dirname(configFile);
181
- if (!existsSync(configDirectory)) {
182
- mkdirSync(configDirectory, { recursive: true });
183
- }
184
- writeFileSync(configFile, JSON.stringify({ lastUpdateCheck: Date.now() }));
185
- }, "saveLastUpdate");
186
-
187
- var __defProp$1 = Object.defineProperty;
188
- var __name$1 = (target, value) => __defProp$1(target, "name", { value, configurable: true });
189
- const getDistributionVersion = /* @__PURE__ */ __name$1(async (packageName, distributionTag, registryUrl) => {
190
- const url = registryUrl.replace("__NAME__", packageName);
191
- return await new Promise((resolve, reject) => {
192
- get(url, (message) => {
193
- let body = "";
194
- message.on("data", (chunk) => body += chunk);
195
- message.on("end", () => {
196
- try {
197
- const json = JSON.parse(body);
198
- const version = json[distributionTag];
199
- if (!version) {
200
- reject(new Error("Error getting version"));
201
- }
202
- resolve(version);
203
- } catch {
204
- reject(new Error("Could not parse version response"));
205
- }
206
- });
207
- }).on("error", (error) => reject(error));
208
- });
209
- }, "getDistributionVersion");
210
-
211
- var __defProp = Object.defineProperty;
212
- var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
213
- const hasNewVersion = /* @__PURE__ */ __name(async ({
214
- alwaysRun,
215
- debug,
216
- distTag: distributionTag = "latest",
217
- pkg,
218
- registryUrl = "https://registry.npmjs.org/-/package/__NAME__/dist-tags",
219
- updateCheckInterval = 1e3 * 60 * 60 * 24
220
- }) => {
221
- const lastUpdateCheck = getLastUpdate(pkg.name);
222
- if (alwaysRun || !lastUpdateCheck || lastUpdateCheck < Date.now() - updateCheckInterval) {
223
- const latestVersion = await getDistributionVersion(pkg.name, distributionTag, registryUrl);
224
- saveLastUpdate(pkg.name);
225
- if (semverGt(latestVersion, pkg.version)) {
226
- return latestVersion;
227
- }
228
- if (debug) {
229
- console.error(`Latest version (${latestVersion}) not newer than current version (${pkg.version})`);
230
- }
231
- } else if (debug) {
232
- console.error(
233
- `Too recent to check for a new update. simpleUpdateNotifier() interval set to ${updateCheckInterval}ms but only ${Date.now() - lastUpdateCheck}ms since last check.`
234
- );
235
- }
236
- return null;
237
- }, "hasNewVersion");
238
-
239
- export { hasNewVersion as default };
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};
@@ -0,0 +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$3");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
+ ${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
+
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
+ ${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
7
+ - ${V.join(` \r
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="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
+ `))}}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;