@visulima/cerebro 3.0.0-alpha.30 → 3.0.0-alpha.32
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 +42 -0
- package/LICENSE.md +841 -6
- package/README.md +38 -8
- package/dist/commands/completion-command.d.ts +1 -1
- package/dist/commands/completion-command.js +5 -5
- package/dist/commands/help-command.d.ts +1 -1
- package/dist/commands/help-command.js +1 -1
- package/dist/commands/readme-command.d.ts +1 -1
- package/dist/commands/readme-command.js +20 -20
- package/dist/commands/version-command.d.ts +1 -1
- package/dist/commands/version-command.js +1 -1
- package/dist/index.d.ts +18 -3
- package/dist/index.js +1 -1
- package/dist/logger/create-pail-logger.d.ts +29 -4
- package/dist/logger/create-pail-logger.js +1 -1
- package/dist/packem_chunks/has-new-version.js +1 -1
- package/dist/packem_shared/Cerebro-BsroI2VY.js +4 -0
- package/dist/packem_shared/VisulimaError-DTMgXonA-CzaryRgZ.js +1 -0
- package/dist/packem_shared/VisulimaError-DyMHh9O-.js +76 -0
- package/dist/packem_shared/cerebro-error-z8DS5U8c.js +1 -0
- package/dist/packem_shared/{plugin-manager.d-BSQtHbWS.d.ts → command.d-DbhtfXF4.d.ts} +235 -216
- package/dist/packem_shared/index-BSKOOIL6.js +29 -0
- package/dist/packem_shared/{index.d-Br8HpP0A.d.ts → index.d-BL4NtVR3.d.ts} +37 -3
- package/dist/packem_shared/lazyNamed-DMUm8mZe.js +1 -0
- package/dist/packem_shared/renderError-Dqej8k13-BmipVhik.js +25 -0
- package/dist/packem_shared/runtime-process-Dmz0vCJy.js +1 -0
- package/dist/packem_shared/split-by-case-C-dbSFCl.js +1 -0
- package/dist/plugins/error-handler-plugin.d.ts +2 -2
- package/dist/plugins/error-handler-plugin.js +1 -1
- package/dist/plugins/runtime-version-check-plugin.d.ts +1 -1
- package/dist/plugins/runtime-version-check-plugin.js +1 -1
- package/dist/plugins/update-notifier/update-notifier-plugin.d.ts +11 -4
- package/dist/plugins/update-notifier/update-notifier-plugin.js +1 -1
- package/dist/util/general/compile-cache.js +1 -1
- package/dist/util/general/heap-tuning.js +1 -1
- package/package.json +7 -7
- package/dist/packem_shared/Cerebro-BN_nIZ8z.js +0 -4
- package/dist/packem_shared/VisulimaError-WfDZ45Qv.js +0 -76
- package/dist/packem_shared/cerebro-error-BnJTixb2.js +0 -1
- package/dist/packem_shared/constants-DmzZF6_u-BmMwILI_.js +0 -1
- package/dist/packem_shared/index-CkkDAMKi.js +0 -6
- package/dist/packem_shared/isVisulimaError-jVZgumOU-C4fgdbWg.js +0 -1
- package/dist/packem_shared/lazyNamed-DOmefeJM.js +0 -1
- package/dist/packem_shared/renderError-DxgI44AK-DFDWFoCr.js +0 -24
- package/dist/packem_shared/runtime-process-DKHFvYkv.js +0 -1
- /package/dist/packem_shared/{VERBOSITY_QUIET-XPultrIA.js → VERBOSITY_DEBUG-XPultrIA.js} +0 -0
|
@@ -71,7 +71,40 @@ declare class VisulimaError extends Error {
|
|
|
71
71
|
/**
|
|
72
72
|
* Will return an array of all causes in the error in the order they occurred.
|
|
73
73
|
*/
|
|
74
|
-
|
|
74
|
+
/**
|
|
75
|
+
* The compiled position of a stack frame handed to a {@link SourceMapResolver}.
|
|
76
|
+
*/
|
|
77
|
+
interface SourceMapLocation {
|
|
78
|
+
column?: number;
|
|
79
|
+
file: string;
|
|
80
|
+
line: number;
|
|
81
|
+
}
|
|
82
|
+
/**
|
|
83
|
+
* The resolved original position returned by a {@link SourceMapResolver}. Any omitted field falls
|
|
84
|
+
* back to the compiled value. `source`, when provided, is used directly as the code-frame content
|
|
85
|
+
* (e.g. from an inlined `sourcesContent`) instead of reading the resolved file from disk.
|
|
86
|
+
*/
|
|
87
|
+
interface ResolvedSourceLocation {
|
|
88
|
+
column?: number;
|
|
89
|
+
file?: string;
|
|
90
|
+
line?: number;
|
|
91
|
+
source?: string;
|
|
92
|
+
}
|
|
93
|
+
/**
|
|
94
|
+
* Pluggable hook that maps a compiled `*.js:line:col` position back to its original source position
|
|
95
|
+
* (e.g. TS/JSX). Return `undefined` (or throw) to leave the frame untouched. Synchronous so it can
|
|
96
|
+
* be used by the synchronous `renderError`; resolve/inline your maps ahead of time.
|
|
97
|
+
*/
|
|
98
|
+
type SourceMapResolver = (location: SourceMapLocation) => ResolvedSourceLocation | undefined;
|
|
99
|
+
type Options$1 = {
|
|
100
|
+
/**
|
|
101
|
+
* Read source files for code frames from anywhere on disk, including absolute paths outside
|
|
102
|
+
* `cwd`. Defaults to `false`, in which case only files resolving inside `cwd` are read — this
|
|
103
|
+
* prevents local file disclosure when rendering errors whose stack came from untrusted input
|
|
104
|
+
* (e.g. a deserialized error). Enable only for trusted, locally-thrown errors.
|
|
105
|
+
* @default false
|
|
106
|
+
*/
|
|
107
|
+
allowAllFilePaths: boolean;
|
|
75
108
|
color: CodeFrameOptions["color"] & {
|
|
76
109
|
fileLine: ColorizeMethod;
|
|
77
110
|
hint: ColorizeMethod;
|
|
@@ -88,6 +121,7 @@ type Options$1 = Omit<CodeFrameOptions, "message | prefix"> & {
|
|
|
88
121
|
hideErrorTitle: boolean;
|
|
89
122
|
hideMessage: boolean;
|
|
90
123
|
indentation: number | " ";
|
|
91
|
-
prefix: string;
|
|
92
|
-
|
|
124
|
+
prefix: string; /** Optional source-map resolver to map compiled frame positions back to original source. */
|
|
125
|
+
sourceMap?: SourceMapResolver;
|
|
126
|
+
} & Omit<CodeFrameOptions, "message | prefix">;
|
|
93
127
|
export { Options$1 as O, VisulimaError as V };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const e=(a,t)=>async()=>({default:(await a())[t]});export{e as lazyNamed};
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import{createRequire as K}from"node:module";const Q=K(import.meta.url),b=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,X=e=>{if(typeof b<"u"&&b.versions&&b.versions.node){const[r,t]=b.versions.node.split(".").map(Number);if(r>22||r===22&&t>=3||r===20&&t>=16)return b.getBuiltinModule(e)}return Q(e)},{createRequire:_}=X("node:module"),Z=globalThis.process??Object.create(null),L={versions:{}},A=new Proxy(Z,{get(e,r){if(r in e)return e[r];if(r in L)return L[r]}}),ee=e=>e.replaceAll(/\r\n|\r(?!\n)|\n/gu,`
|
|
2
|
+
`),re=(e,r,t,n)=>{const s={column:0,line:-1,...e.start},i={...s,...e.end},o=s.line,d=s.column,l=i.line,c=i.column;let a=Math.max(o-(t+1),0),m=Math.min(r.length,l+n);o===-1&&(a=0),l===-1&&(m=r.length);const p=l-o,f={};if(p)for(let u=0;u<=p;u++){const h=u+o;if(!d)f[h]=!0;else if(u===0){const v=r[h-1]?.length;f[h]=[d,(v??0)-d+1]}else if(u===p)f[h]=[0,c];else{const v=r[h-u]?.length;f[h]=[0,v]}}else d===c?f[o]=d?[d,0]:!0:f[o]=[d,(c??0)-(d??0)];return{end:m,markerLines:f,start:a}},te=A.platform==="win32"&&!A.env?.WT_SESSION?">":"❯",ne=(e,r,t)=>{const n={linesAbove:2,linesBelow:3,prefix:"",showGutter:!0,tabWidth:4,...t,color:{gutter:u=>u,marker:u=>u,message:u=>u,...t?.color}},s=typeof r.start.column=="number";let i=(e.includes("\r")?ee(e):e).split(`
|
|
3
|
+
`);typeof n.tabWidth=="number"&&e.includes(" ")&&(i=i.map(u=>u.replaceAll(" "," ".repeat(n.tabWidth))));const{end:o,markerLines:d,start:l}=re(r,i,n.linesAbove,n.linesBelow),c=String(o).length,{gutter:a,marker:m,message:p}=n.color;let f=i.slice(l,o).map((u,h)=>{const v=l+1+h,E=d[v],z=String(v).padStart(c),D=!d[v+1],N=` ${z}${n.showGutter?" |":""}`;if(E){let k="";if(Array.isArray(E)){const Y=u.replaceAll(/[^\t]/g," ").slice(0,Math.max(E[0]-1,0)),H=E[1]||1;k=[`
|
|
4
|
+
`,n.prefix+a(N.replaceAll(/\d/g," "))," ",Y,m("^").repeat(H)].join(""),D&&n.message&&(k+=` ${p(n.message)}`)}return[n.prefix+m(te),a(N),u.length>0?` ${u}`:"",k].join("")}return`${n.prefix} ${a(N)}${u.length>0?` ${u}`:""}`}).join(`
|
|
5
|
+
`);return n.message&&!s&&(f=`${n.prefix+" ".repeat(c+1)+n.message}
|
|
6
|
+
${f}`),f},S=new Map([["Error",Error],["EvalError",EvalError],["RangeError",RangeError],["ReferenceError",ReferenceError],["SyntaxError",SyntaxError],["TypeError",TypeError],["URIError",URIError]]);typeof AggregateError<"u"&&S.set("AggregateError",AggregateError);const ze=(e,r)=>{let t;try{t=new e}catch(s){throw new Error(`The error constructor "${e.name}" is not compatible`,{cause:s})}const n=r??t.name;if(S.has(n))throw new Error(`The error constructor "${n}" is already known.`);S.set(n,e)},ie=e=>S.get(e),De=e=>e!==null&&typeof e=="object"&&typeof e.name=="string"&&typeof e.message=="string"&&(ie(e.name)!==void 0||e.name==="Error"),oe=_(import.meta.url),x=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,se=e=>{if(typeof x<"u"&&x.versions&&x.versions.node){const[r,t]=x.versions.node.split(".").map(Number);if(r>22||r===22&&t>=3||r===20&&t>=16)return x.getBuiltinModule(e)}return oe(e)},{inspect:le}=se("node:util"),Ye=e=>{const r=new Set,t=[];let n=e;for(;n;){if(r.has(n)){console.error(`Circular reference detected in error causes: ${le(e)}`);break}if(t.push(n),r.add(n),typeof n!="object"||!("cause"in n))break;n=n.cause}return t},ae=()=>A.env?.DEBUG==="true",$=(e,...r)=>{if(ae()){const t=r.map(n=>typeof n=="function"?n():n);console.debug(`error:parse-stacktrace: ${e}`,...t)}},g="<unknown>",ce=/^(?:node:internal\/|node:|internal\/)/,de=e=>e!==void 0&&ce.test(e),ue=/^.*?\s*at\s(?:(.+?\)(?:\s\[.+\])?|\(?.*?)\s?\((?:address\sat\s)?)?(?:async\s)?((?:<anonymous>|[-a-z]+:|.*bundle|\/)?.*?)(?::(\d+))?(?::(\d+))?\)?\s*$/i,fe=/\((\S+)\),\s(<[^>]+>)?:(\d+)?:(\d+)?\)?/,me=/(.*?):(\d+):(\d+)(?:\s<-\s.+:\d+:\d+)?/,pe=/eval\sat\s(<anonymous>)\s\((.*)\)?:(\d+)?:(\d+)\),\s*<anonymous>?:(\d+)?:(\d+)/,he=/^\s*in\s(?:([^\\/]+(?:\s\[as\s\S+\])?)\s\(?)?\(at?\s?(.*?):(\d+)(?::(\d+))?\)?\s*$/,ve=/in\s(.*)\s\(at\s(.+)\)\sat/,$e=/^(?:.*@)?(.*):(\d+):(\d+)$/,ge=/^\s*(.*?)(?:\((.*?)\))?(?:^|@)?((?:[-a-z]+)?:\/.*?|\[native code\]|[^@]*(?:bundle|\d+\.js)|\/[\w\-. \/=]+)(?::(\d+))?(?::(\d+))?\s*$/i,ye=/(\S+) line (\d+)(?: > eval line \d+)* > eval/i,we=/(\S[^\s[]*\[.*\]|.*?)@(.*):(\d+):(\d+)/,j=/\(error: (.*)\)/,be=/at\s/,xe=/^(\S+):(\d+):(\d+)$|^(\S+):(\d+)$/,Ee=/\S*(?:Error: |AggregateError:)/,C=/^Anonymous function$/,Se=/^\s*in\s.*/,Ne=/^.*?\s*at\s.*/,ke=/^.*?\s*@.*|\[native code\]/,R=(e,r)=>{const t=e.includes("safari-extension"),n=e.includes("safari-web-extension");return t||n?[e.includes("@")?e.split("@")[0]:g,t?`safari-extension:${r}`:`safari-web-extension:${r}`]:[e,r]},B=(e,r)=>{const t=me.exec(r);t&&(e.file=t[1],e.line=+t[2],e.column=+t[3])},Ae=e=>{const r=ve.exec(e);if(r){$(`parse nested node error stack line: "${e}"`,()=>`found: ${JSON.stringify(r)}`);const n=r[2].split(":");return{column:n[2]?+n[2]:void 0,file:n[0],line:n[1]?+n[1]:void 0,methodName:r[1]??g,raw:e,type:void 0}}const t=he.exec(e);if(t){$(`parse node error stack line: "${e}"`,()=>`found: ${JSON.stringify(t)}`);const n={column:t[4]?+t[4]:void 0,file:t[2]?t[2].replace(be,""):void 0,line:t[3]?+t[3]:void 0,methodName:t[1]??g,raw:e,type:e.startsWith("internal")?"internal":void 0};return B(n,`${t[2]}:${t[3]}:${t[4]}`),n}},Me=e=>{const r=ue.exec(e);if(r){$(`parse chrome error stack line: "${e}"`,()=>`found: ${JSON.stringify(r)}`);const t=r[2]?.startsWith("native"),n=r[2]?.startsWith("eval")||r[1]?.startsWith("eval");let s,i;if(n){const c=fe.exec(e);if(c){const a=xe.exec(c[1]);a?(r[2]=a[4]??a[1],r[3]=a[5]??a[2],r[4]=a[3]):c[2]&&(r[2]=c[1]),c[2]&&(s={column:c[4]?+c[4]:void 0,file:c[2],line:c[3]?+c[3]:void 0,methodName:"eval",raw:e,type:"eval"})}else{const a=pe.exec(e);a&&(i={column:a[4]?+a[4]:void 0,file:a[2],line:a[3]?+a[3]:void 0},s={column:a[6]?+a[6]:void 0,file:a[1],line:a[5]?+a[5]:void 0,methodName:"eval",raw:a[0],type:"eval"})}}const[o,d]=R(r[1]?r[1].replace(C,"<anonymous>"):g,r[2]),l={column:r[4]?+r[4]:void 0,evalOrigin:s,file:d,line:r[3]?+r[3]:void 0,methodName:o,raw:e,type:n?"eval":t?"native":de(d)?"internal":void 0};return i?(l.column=i.column,l.file=i.file,l.line=i.line):B(l,`${d}:${r[3]}:${r[4]}`),l}},Te=(e,r)=>{const t=ge.exec(e);if(t){$(`parse gecko error stack line: "${e}"`,()=>`found: ${JSON.stringify(t)}`);const n=t[3]?.includes(" > eval"),s=n&&t[3]&&ye.exec(t[3]);let i;n&&s&&(t[3]=s[1],i={column:t[5]?+t[5]:void 0,file:t[3],line:t[4]?+t[4]:void 0,methodName:"eval",raw:e,type:"eval"},t[4]=s[2]);const[o,d]=R(t[1]?t[1].replace(C,"<anonymous>"):g,t[3]);let l;(r?.type==="safari"||!n&&r?.type==="firefox")&&r.column?l=r.column:!n&&t[5]&&(l=+t[5]);let c;return(r?.type==="safari"||!n&&r?.type==="firefox")&&r.line?c=r.line:t[4]&&(c=+t[4]),{column:l,evalOrigin:i,file:d,line:c,methodName:o,raw:e,type:n?"eval":d.includes("[native code]")?"native":void 0}}},Le=(e,r)=>{const t=we.exec(e);if(!(t&&t[2].includes(" > eval"))&&t)return $(`parse firefox error stack line: "${e}"`,()=>`found: ${JSON.stringify(t)}`),{column:t[4]?+t[4]:r?.column??void 0,file:t[2],line:t[3]?+t[3]:r?.line??void 0,methodName:t[1]||g,raw:e,type:void 0}},je=e=>{const r=$e.exec(e);if(r)return $(`parse react android native error stack line: "${e}"`,()=>`found: ${JSON.stringify(r)}`),{column:r[3]?+r[3]:void 0,file:r[1],line:r[2]?+r[2]:void 0,methodName:g,raw:e,type:void 0}},We=/(?:^|[(@\s])(?:node:internal\/|node:|internal\/)/,_e=/node_modules[/\\]/,He={internals:e=>!We.test(e),nodeModules:e=>!_e.test(e)},Ke=(...e)=>r=>e.every(t=>t(r)),O=(e,{filter:r,frameLimit:t=50}={})=>{const n=e;let s=(typeof n.stacktrace=="string"?n.stacktrace:e.stack??"").split(`
|
|
7
|
+
`).map(i=>(j.test(i)?i.replace(j,"$1"):i).trim()).filter(i=>!Ee.test(i)&&i!=="eval code");return r&&(s=s.filter(i=>r(i))),s=s.slice(0,t),s.reduce((i,o,d)=>{if(!o||o.length>1024)return i;let l;if(Se.test(o))l=Ae(o);else if(Ne.test(o))l=Me(o);else if(ke.test(o)){let c;if(d===0){const a=e,m=a.columnNumber,p=a.lineNumber,f=a.line,u=a.column;m||p?c={column:m,line:p,type:"firefox"}:(f||u)&&(c={column:u,line:f,type:"safari"})}l=Le(o,c)??Te(o,c)}else l=je(o);return l?i.push(l):$(`parse error stack line: "${o}"`,"not parser found"),i},[])},Ce=_(import.meta.url),w=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,M=e=>{if(typeof w<"u"&&w.versions&&w.versions.node){const[r,t]=w.versions.node.split(".").map(Number);if(r>22||r===22&&t>=3||r===20&&t>=16)return w.getBuiltinModule(e)}return Ce(e)},{existsSync:Re,readFileSync:Be}=M("node:fs"),{relative:Oe,resolve:W,sep:Ie}=M("node:path"),{cwd:Pe}=w,{fileURLToPath:Ve}=M("node:url"),y=(e,r,t)=>t===0?e:r===" "?e+" ".repeat(t):e+" ".repeat(r*t),I=e=>e.replaceAll("\\","/"),Ge=(e,r)=>{const t=e.replace("async file:","file:");return I(Oe(r,t.startsWith("file:")?Ve(t):t))},Je=(e,r,t)=>{if(r)return t.title(e.message);const n=e.message?`: ${e.message}`:"";return t.title(e.name+n)},P=(e,{color:r,hideErrorTitle:t,indentation:n,prefix:s},i)=>`${y(s,n,i)}${Je(e,t,r)}
|
|
8
|
+
`,V=(e,{color:r,indentation:t,prefix:n},s)=>{if(e.hint===void 0)return;const i=y(n,t,s);let o="";if(Array.isArray(e.hint))for(const d of e.hint)o+=`${i+d}
|
|
9
|
+
`;else o+=i+e.hint;return r.hint(o)},G=(e,r)=>{if(!r||e.file===void 0||e.line===void 0)return{trace:e};try{const t=r({column:e.column,file:e.file,line:e.line});return t?{source:t.source,trace:{...e,column:t.column??e.column,file:t.file??e.file,line:t.line??e.line}}:{trace:e}}catch{return{trace:e}}},T=(e,r,t=0)=>{const{color:n,cwd:s,displayShortPath:i,indentation:o,prefix:d}=r,{trace:l}=G(e,r.sourceMap),c=i?Ge(l.file,s):I(l.file),{fileLine:a,method:m}=n;return`${y(d,o,t)}at ${l.methodName?`${m(l.methodName)} `:""}${a(c)}:${a(l.line?.toString()??"")}`},qe=(e,r)=>{if(r.allowAllFilePaths)return!0;const t=W(r.cwd),n=W(t,e);return n===t||n.startsWith(t+Ie)},J=(e,r,t)=>{const{color:n,indentation:s,linesAbove:i,linesBelow:o,prefix:d,showGutter:l,showLineNumbers:c,tabWidth:a}=r,{source:m,trace:p}=G(e,r.sourceMap);if(p.file===void 0)return;let f;if(m===void 0){const u=p.file.replace("file://","");if(!qe(u,r)||!Re(u))return;f=Be(u,"utf8")}else f=m;return ne(f,{start:{column:p.column,line:p.line}},{color:n,linesAbove:i,linesBelow:o,prefix:y(d,s,t),showGutter:l,showLineNumbers:c,tabWidth:a})},q=(e,r,t)=>{if(e.errors.length===0)return;let n=`${y(r.prefix,r.indentation,t)}Errors:
|
|
10
|
+
|
|
11
|
+
`,s=!0;for(const i of e.errors)s?s=!1:n+=`
|
|
12
|
+
|
|
13
|
+
`,n+=U(i,{...r,framesMaxLimit:1,hideErrorCodeView:r.hideErrorErrorsCodeView},t+1);return`
|
|
14
|
+
${n}`},F=(e,r,t,n=new Set)=>{n.add(e);let s=`${y(r.prefix,r.indentation,t)}Caused by:
|
|
15
|
+
|
|
16
|
+
`;const i=e.cause;s+=P(i,r,t);const o=O(i).shift(),d=V(i,r,t);if(d&&(s+=`${d}
|
|
17
|
+
`),o&&(s+=T(o,r,t),!r.hideErrorCauseCodeView)){const l=J(o,r,t);l!==void 0&&(s+=`
|
|
18
|
+
${l}`)}if(i instanceof AggregateError){const l=q(i,r,t);l!==void 0&&(s+=`
|
|
19
|
+
${l}`)}return i.cause&&(s+=n.has(i)?`
|
|
20
|
+
${y(r.prefix,r.indentation,t+1)}Caused by: [Circular]`:`
|
|
21
|
+
${F(i,r,t+1,n)}`),`
|
|
22
|
+
${s}`},Fe=(e,r)=>(e.length>0?`
|
|
23
|
+
`:"")+e.map(t=>T(t,r)).join(`
|
|
24
|
+
`),U=(e,r,t)=>{const n={allowAllFilePaths:!1,cwd:Pe(),displayShortPath:!1,filterStacktrace:void 0,framesMaxLimit:Number.POSITIVE_INFINITY,hideErrorCauseCodeView:!1,hideErrorCodeView:!1,hideErrorErrorsCodeView:!1,hideErrorTitle:!1,hideMessage:!1,indentation:4,linesAbove:2,linesBelow:3,prefix:"",showGutter:!0,showLineNumbers:!0,tabWidth:4,...r,color:{fileLine:o=>o,gutter:o=>o,hint:o=>o,marker:o=>o,message:o=>o,method:o=>o,title:o=>o,...r.color}},s=O(e,{filter:r.filterStacktrace,frameLimit:n.framesMaxLimit}),i=s.shift();return[r.hideMessage?void 0:P(e,n,t),V(e,n,t),i?T(i,n,t):void 0,i&&!n.hideErrorCodeView?J(i,n,t):void 0,e instanceof AggregateError?q(e,n,t):void 0,e.cause===void 0?void 0:F(e,n,t),s.length>0?Fe(s,n):void 0].filter(Boolean).join(`
|
|
25
|
+
`)},Qe=(e,r={})=>{if(r.framesMaxLimit!==void 0&&r.framesMaxLimit<=0)throw new RangeError("The 'framesMaxLimit' option must be a positive number");return U(e,r,0)};export{He as R,te as S,Qe as U,ne as W,Ke as X,O as Y,Ye as c,De as g,ie as n,ze as s};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const n=s=>"Deno"in s,l=s=>"Bun"in s,i=()=>{if(n(globalThis)){const s=globalThis.Deno,e=s.execPath();let o=e;try{const{importMeta:r}=globalThis;r?.url&&(o=r.url)}catch{}return[e,o,...s.args]}return l(globalThis)?globalThis.Bun.process.argv:process.argv},t=()=>n(globalThis)?globalThis.Deno.cwd():l(globalThis)?globalThis.Bun.process.cwd():process.cwd(),a=()=>{if(n(globalThis)){const s=globalThis.Deno;return new Proxy(s.env.toObject(),{get:(e,o)=>typeof o=="string"?s.env.get(o):e[o],has:(e,o)=>typeof o=="string"?s.env.has(o):o in e,set:(e,o,r)=>typeof o=="string"?(r===void 0||s.env.set(o,r),!0):!1})}return l(globalThis)?globalThis.Bun.process.env:process.env},c=()=>n(globalThis)?[]:l(globalThis)?globalThis.Bun.process.execArgv:process.execArgv,g=()=>n(globalThis)?globalThis.Deno.execPath():l(globalThis)?globalThis.Bun.process.execPath:process.execPath,h=()=>{if(n(globalThis)){const s=globalThis.Deno.build?.os??"unknown";return s==="windows"?"win32":s}return l(globalThis)?globalThis.Bun.platform??"unknown":process.platform},b=()=>{if(n(globalThis)){const s=globalThis.Deno.build?.arch??"unknown";return s==="x86_64"?"x64":s==="aarch64"?"arm64":s}return l(globalThis)?globalThis.Bun.process.arch:process.arch},T=()=>{if(n(globalThis)){const s=globalThis.Deno,e={};return s.version?.deno&&(e.deno=s.version.deno),s.version?.v8&&(e.v8=s.version.v8),s.version?.typescript&&(e.typescript=s.version.typescript),e}if(l(globalThis)){const s=globalThis.Bun,e={...s.process.versions};return s.version&&(e.bun=s.version),e}return process.versions},u=(s=0)=>{if(n(globalThis))throw globalThis.Deno.exit(s),new Error("Deno exit failed");if(l(globalThis))throw globalThis.Bun.process.exit(s),new Error("Bun exit failed");process.exit(s)},p=(s,e)=>{if(n(globalThis))return()=>{};if(l(globalThis)){try{const r=globalThis.Bun;if(r.process?.on)return r.process.on(s,e),()=>{r.process?.removeListener&&r.process.removeListener(s,e)}}catch{}return()=>{}}const o=process;return o.on(s,e),()=>{o.removeListener(s,e)}};export{h as a,b,a as c,i as d,u as e,t as f,T as g,g as h,c as i,p as o};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{createRequire as J}from"node:module";const Q=J(import.meta.url),W=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,X=e=>{if(typeof W<"u"&&W.versions&&W.versions.node){const[t,a]=W.versions.node.split(".").map(Number);if(t>22||t===22&&a>=3||t===20&&a>=16)return W.getBuiltinModule(e)}return Q(e)},{createRequire:Y}=X("node:module"),H=String.raw,T=H`\p{Emoji}(?:\p{EMod}|[\u{E0020}-\u{E007E}]+\u{E007F}|\uFE0F?\u20E3?)`,ee=()=>new RegExp(H`\p{RI}{2}|(?)${T}(?:\u200D${T})*`,"gu");Object.freeze(new Map([[0,0],[1,22],[2,22],[3,23],[4,24],[7,27],[8,28],[9,29],[30,39],[31,39],[32,39],[33,39],[34,39],[35,39],[36,39],[37,39],[40,49],[41,49],[42,49],[43,49],[44,49],[45,49],[46,49],[47,49],[90,39]]));const Be=/^[ \t]*(?:\r\n|\r|\n)/,_e=/(?:\r\n|\r|\n)[ \t]*$/,ve=/^(?:[\r\n]|$)/,Te=/(?:\r\n|\r|\n)([ \t]*)(?:[^ \t\r\n]|$)/,Fe=/^[ \t]*[\r\n][ \t\r\n]*$/,ze=/\r\n|\n|\r/g,Me=/[\u001B\u009B](?:[[()#;?]{0,10}(?:\d{1,4}(?:;\d{0,4})*)?[0-9A-ORZcf-nqry=><]|\]8;;[^\u0007\u001B]{0,100}(?:\u0007|\u001B\\))/g,Ie=/[\u0000-\u0008\n-\u001F\u007F-\u009F]{1,1000}/y,m=ee(),te=/[-_./\s]+/g,$=/(\u001B\[[0-9;]*[a-z])/i,F=new RegExp("\\p{Script=Arabic}","u"),se=new RegExp("\\p{Script=Bengali}","u"),b=new RegExp("\\p{Script=Cyrillic}","u"),ne=new RegExp("\\p{Script=Devanagari}","u"),re=new RegExp("\\p{Script=Ethiopic}","u"),j=new RegExp("\\p{Script=Greek}","u"),z=new RegExp("\\p{Script=Greek}+|\\p{Script=Latin}+|[^\\p{Script=Greek}\\p{Script=Latin}]+","gu"),ie=new RegExp("\\p{Script=Gujarati}","u"),le=new RegExp("\\p{Script=Gurmukhi}","u"),M=new RegExp("\\p{Script=Hangul}","u"),I=new RegExp("\\p{Script=Hebrew}","u"),oe=new RegExp("\\p{Script=Hiragana}","u"),O=new RegExp("\\p{Script=Han}","u"),ce=new RegExp("\\p{Script=Kannada}","u"),ae=new RegExp("\\p{Script=Katakana}","u"),pe=new RegExp("\\p{Script=Khmer}","u"),ue=new RegExp("\\p{Script=Lao}","u"),S=new RegExp("\\p{Script=Latin}","u"),he=new RegExp("\\p{Script=Malayalam}","u"),fe=new RegExp("\\p{Script=Myanmar}","u"),ge=new RegExp("\\p{Script=Oriya}","u"),de=new RegExp("\\p{Script=Sinhala}","u"),xe=new RegExp("\\p{Script=Tamil}","u"),we=new RegExp("\\p{Script=Telugu}","u"),Ee=new RegExp("\\p{Script=Thai}","u"),ke=new RegExp("\\p{Script=Tibetan}","u"),q=/[\u02BB\u02BC\u0027]/u,Se=e=>e.replace(m,"");class Re{capacity;cache;constructor(t){this.capacity=t,this.cache=new Map}get(t){if(!this.cache.has(t))return;const a=this.cache.get(t);return this.cache.delete(t),this.cache.set(t,a),a}has(t){return this.cache.has(t)}set(t,a){if(this.cache.has(t))this.cache.delete(t);else if(this.cache.size>=this.capacity){const f=this.cache.keys().next().value;f!==void 0&&this.cache.delete(f)}this.cache.set(t,a)}delete(t){this.cache.delete(t)}clear(){this.cache.clear()}size(){return this.cache.size}}const Ce=Y(import.meta.url),y=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,Le=e=>{if(typeof y<"u"&&y.versions&&y.versions.node){const[t,a]=y.versions.node.split(".").map(Number);if(t>22||t===22&&a>=3||t===20&&a>=16)return y.getBuiltinModule(e)}return Ce(e)},{stripVTControlCharacters:Ue}=Le("node:util"),A=new Re(1e3),me=/[.*+?^${}()|[\]\\]/g,be=e=>{const t=e.join("");if(A.has(t)){const d=A.get(t);return d.lastIndex=0,d}const a=e.map(d=>d.replaceAll(me,String.raw`\$&`)).join("|"),f=new RegExp(a,"g");return A.set(t,f),f},We=e=>{const t=[];let a=0,f;for(m.lastIndex=0;(f=m.exec(e))!==null;)f.index>a&&t.push(e.slice(a,f.index)),t.push(f[0]),a=m.lastIndex;return a<e.length&&t.push(e.slice(a)),t.filter(Boolean)},ye=/[ČŠŽĐ]/i,P=new Uint8Array(128),D=new Uint8Array(128),K=new Uint8Array(128);for(let e=0;e<128;e++)P[e]=e>=65&&e<=90?1:0,D[e]=e>=97&&e<=122?1:0,K[e]=e>=48&&e<=57?1:0;const B=e=>P[e],G=e=>D[e],_=e=>K[e],U=(e,t,a,f,d)=>{if(e.length===0)return[];let h=!1;const k=Object.values(t);for(const i of k)if(i(e[0])){h=!0;break}if(!h&&!a)return[e];const g=[...e],w=[];let n=g[0],l="other";const p=Object.entries(t);for(const i of p){const[r,c]=i;if(c(g[0])){l=r;break}}let s=a&&f?g[0]===g[0].toLocaleUpperCase(f):!1;for(let i=1;i<g.length;i++){const r=g[i];let c="other";for(const x of p){const[E,R]=x;if(R(r)){c=E;break}}const u=a&&f?r===r.toLocaleUpperCase(f):!1;let o=!1;d?o=d(l,c,s,u,r,i,g):(l!==c&&l!=="other"&&c!=="other"&&(o=!0),a&&c!=="other"&&!s&&u&&(o=!0)),o?(w.push(n),n=r):n+=r,l=c,a&&(s=u)}return n&&n.length>0&&w.push(n),w.length>0?w:[e]},$e=(e,t,a,f)=>{if(a.size===0)return t;for(const d of a)if(e.startsWith(d,t))return f.push(d),t+d.length;return t},N=(e,t=new Set)=>{if(e.length===0)return[];if(e.toUpperCase()===e)return[e];let a=0;const f=[],d=e.length;for(let h=1;h<d;h++){const k=$e(e,a,t,f);if(k!==a){a=k,h=a-1;continue}const g=e.codePointAt(h-1),w=e.codePointAt(h),n=g&&g<128&&B(g),l=w&&w<128&&B(w),p=g&&g<128&&G(g),s=g&&g<128&&_(g),i=w&&w<128&&_(w);if(p&&l){f.push(e.slice(a,h)),a=h;continue}if(s&&!i||!s&&i){f.push(e.slice(a,h)),a=h;continue}if(i&&!s){let r=!1,c=!1;if(h+1<d){const u=e.codePointAt(h+1);r=u&&u<128&&B(u),c=u&&u<128&&_(u)}if(!c&&r){f.push(e.slice(a,h),e.slice(h,h+1)),a=h+1;continue}}if(h+1<d){const r=e.codePointAt(h+1),c=r&&r<128&&G(r);if(n&&l&&c){const u=e.slice(a,h+1);t.has(u)||(f.push(e.slice(a,h)),a=h)}}}return a<d&&f.push(e.slice(a)),f.filter(h=>h!=="")},V=(e,t,a)=>{if(e.length===0)return[];const f=e===e.toLocaleUpperCase(t);if(t.startsWith("de")){if(!f&&e.replaceAll("ß","SS")===e.toLocaleUpperCase(t))return[e];const n=[...e],l=n.length,p=[];let s=n[0],i=n[0]===n[0].toLocaleUpperCase(t),r=i,c=i?0:-1;for(let u=1;u<l;u++){const o=n[u],x=o===o.toLocaleUpperCase(t);if(x===i)s+=o;else if(x)s&&s.length>0&&(p.push(s),s=o),r=!0,c=u;else{if(r&&u-c>1){const E=n[u-1],R=s.slice(0,-1);R&&R.length>0&&p.push(R),s=E+o}else s+=o;r=!1,c=-1}i=x}return s&&s.length>0&&p.push(s),p}if(t.startsWith("uk")||t.startsWith("ru")||t.startsWith("bg")||t.startsWith("sr")||t.startsWith("mk")||t.startsWith("be")){if(!b.test(e)&&!S.test(e))return[e];const n=[...e],l=n.length,p=[];let s=n[0];const i=n[0];let r;b.test(i)?r=1:S.test(i)?r=2:r=0;let c=i===i.toLocaleUpperCase(t);for(let o=1;o<l;o++){const x=n[o];let E;b.test(x)?E=1:S.test(x)?E=2:E=0;const R=x===x.toLocaleUpperCase(t);r!==E&&(r===1||r===2)&&(E===1||E===2)||E===r&&!c&&R?(p.push(s),s=x):s+=x,r=E,c=R}s&&s.length>0&&p.push(s);const u=[];for(let o=0;o<p.length;o++)o<p.length-1&&p[o].length===1&&S.test(p[o])&&b.test(p[o+1][0])?(u.push(p[o]+p[o+1]),o+=1):u.push(p[o]);return u}if(t.startsWith("el")){if(!j.test(e)&&!S.test(e))return[e];const n=[];z.lastIndex=0;let l;for(;(l=z.exec(e))!==null;)n.push(l[0]);n.length===0&&n.push(e);const p=[];if(n.length===1){const s=n[0];if(!s||!j.test(s[0])||s.length===1)return[s??e]}for(const s of n){if(!s)continue;if(!j.test(s[0])||s.length===1){p.push(s);continue}const i=s.length;let r=s[0],c=s[0]===s[0].toLocaleUpperCase(t);for(let u=1;u<i;u++){const o=s[u],x=o===o.toLocaleUpperCase(t);!c&&x?(p.push(r),r=o):r+=o,c=x}r&&p.push(r)}return p}if(t.startsWith("ja")||t.startsWith("ko")){const n=t.startsWith("ja"),l=n?{hiragana:s=>oe.test(s),kanji:s=>O.test(s),katakana:s=>ae.test(s),latin:s=>S.test(s)}:{hangul:s=>M.test(s),latin:s=>S.test(s)},p=new Set(["が","で","と","に","の","は","へ","も","や","を"]);if(n){const s=U(e,l,!1,t,(r,c)=>r==="hiragana"&&c==="katakana"||r==="katakana"&&c==="hiragana"||r==="hiragana"&&c==="latin"||r==="katakana"&&c==="latin"||r==="kanji"&&c==="latin"||r==="latin"&&(c==="hiragana"||c==="katakana"||c==="kanji")),i=[];for(const r of s){const c=r;c.length===1&&p.has(c)&&i.length>0?i[i.length-1]=i.at(-1)+c:i.push(c)}return i.length>0?i:[e]}return U(e,l,!1,t,(s,i)=>s==="hangul"&&i==="latin"||s==="latin"&&i==="hangul")}if(t.startsWith("sl")){const n=[...e],l=n.length,p=[];let s=n[0],i=n[0]===n[0].toLocaleUpperCase(t);for(let r=1;r<l;r++){const c=n[r],u=c===c.toLocaleUpperCase(t),o=ye.test(c),x=r<l-1&&n[r+1]===n[r+1].toLocaleUpperCase(t);!i&&u||o&&x?(p.push(s),s=c,o&&x&&(p.push(s),s="")):s+=c,i=u}return s&&s.length>0&&p.push(s),p}if(t.startsWith("zh"))return U(e,{han:n=>O.test(n),latin:n=>S.test(n)},!1,t);if(["ar","fa","he","ur"].includes(t.split("-")[0])){const n=l=>I.test(l)||F.test(l);return U(e,{latin:l=>S.test(l),rtl:l=>n(l)},!1,t)}if(["am","bn","gu","hi","km","kn","lo","ml","mr","ne","or","pa","si","ta","te","th"].includes(t.split("-")[0])){const n=l=>ne.test(l)||se.test(l)||ie.test(l)||le.test(l)||ce.test(l)||xe.test(l)||we.test(l)||he.test(l)||de.test(l)||Ee.test(l)||ue.test(l)||ke.test(l)||fe.test(l)||re.test(l)||pe.test(l)||ge.test(l);return U(e,{indic:l=>n(l),latin:l=>S.test(l)},!1,t)}if(["be","bg","ru","sr","uk"].includes(t))return U(e,{cyrillic:n=>b.test(n),latin:n=>S.test(n)},!0,t);if(["ar","fa","he"].includes(t))return U(e,{latin:n=>S.test(n),rtl:n=>I.test(n)||F.test(n)},!1,t);if(t.startsWith("ko"))return U(e,{hangul:n=>M.test(n),latin:n=>S.test(n)},!1,t);if(t.startsWith("uz")){if(!b.test(e)&&!S.test(e))return[e];const n=[...e],l=n.length,p=[];let s=n[0],i=n[0]===n[0].toLocaleUpperCase(t);for(let r=1;r<l;r++){const c=n[r],u=c===c.toLocaleUpperCase(t);if(q.test(c)||q.test(n[r-1])){s+=c;continue}!i&&u?(p.push(s),s=c):s+=c,i=u}return s&&s.length>0&&p.push(s),p}const d=[...e],h=d.length,k=[];let g=d[0],w=d[0]===d[0].toLocaleUpperCase(t);for(const n of a)if(e.startsWith(n)){k.push(n),g=d[n.length],w=g===g.toLocaleUpperCase(t);break}for(let n=1;n<h;n++){const l=d[n],p=l===l.toLocaleUpperCase(t);let s=0;for(const i of a)if(e.startsWith(i,n)){k.push(g,i),s=i.length,g="";const r=i.at(-1);r&&(w=r===r.toLocaleUpperCase(t));break}if(s>0){n+=s-1;continue}!w&&p?(k.push(g),g=l):g+=l,w=p}return g&&k.push(g),k},je=(e,t,a)=>{const f=[],d=$.test(e)?e.split($).filter(Boolean):[e];for(const h of d){const k=h;if($.test(k))f.push(k);else{m.lastIndex=0;const g=m.test(k)?We(k).filter(Boolean):[k];for(const w of g)if(m.lastIndex=0,m.test(w))f.push(w);else if(t){const n=t.toLowerCase().split("-")[0];f.push(...V(w,n,a))}else f.push(...N(w,a))}}return f},Oe=(e,t={})=>{if(!e||typeof e!="string")return[];const{handleAnsi:a=!1,handleEmoji:f=!1,knownAcronyms:d=[],locale:h,normalize:k=!1,separators:g,stripAnsi:w=!1,stripEmoji:n=!1}=t,l=new Set([...d].toSorted((o,x)=>x.length-o.length));let p=e;w&&(p=Ue(p)),n&&(p=Se(p));let s;Array.isArray(g)?s=be(g):g instanceof RegExp?s=g:s=te;const i=[];let r=p;const c=s.flags.includes("g")?s:new RegExp(s.source,`${s.flags}g`);for(;r.length>0;){const o=c.exec(r);if(!o){r===".."?i.push(".."):r==="."?i.push("."):r.length>0&&i.push(r);break}const x=o.index,E=o[0],R=E.length,v=r.slice(0,x),Z=r.slice(x+R);if(E.startsWith("../"))i.push(".."),r=r.slice(x+3);else if(E.startsWith("./"))i.push("."),r=r.slice(x+2);else if(x===0&&E==="..")i.push(".."),r=r.slice(2);else if(x===0&&E===".")i.push("."),r=r.slice(1);else{v.length>0&&i.push(v);let C=0;for(;(C=E.indexOf("../",C))!==-1;)i.push(".."),C+=3;for(C=0;(C=E.indexOf("./",C))!==-1;)(C===0||E[C-1]!==".")&&i.push("."),C+=2;let L=Z;for(;L.startsWith("../");)i.push(".."),L=L.slice(3);for(;L.startsWith("./");)i.push("."),L=L.slice(2);if(L===".."){i.push("..");break}else if(L==="."){i.push(".");break}else r=L}c.lastIndex=0}if(i.length===0){const o=p.split(s).filter(Boolean);i.push(...o)}let u=[];for(const o of i)a||f?u.push(...je(o,h,l)):h?u.push(...V(o,h,l)):u.push(...N(o,l));return k&&(u=u.map(o=>l.has(o)?o:h&&o===o.toLocaleUpperCase(h)?o[0]+o.slice(1).toLocaleLowerCase(h):o.toUpperCase()===o&&!l.has(o)?o.slice(0,1)+o.slice(1).toLowerCase():o)),u};export{Oe as A,ve as B,Fe as F,_e as R,Te as d,$ as k,ze as l,Me as m,m as n,Be as x,Ie as y};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { O as Options$1 } from "../packem_shared/index.d-
|
|
2
|
-
import { P as Plugin } from "../packem_shared/
|
|
1
|
+
import { O as Options$1 } from "../packem_shared/index.d-BL4NtVR3.js";
|
|
2
|
+
import { P as Plugin } from "../packem_shared/command.d-DbhtfXF4.js";
|
|
3
3
|
import '@visulima/tabular';
|
|
4
4
|
type ErrorHandlerOptions = {
|
|
5
5
|
/** Show detailed error information including stack traces and code frames (default: false) */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
import{U as g}from"../packem_shared/renderError-Dqej8k13-BmipVhik.js";import{e as m}from"../packem_shared/runtime-process-Dmz0vCJy.js";const E=(i={})=>({description:"Enhanced error handling and reporting with beautiful code frames",name:"error-handler",onError:(e,n)=>{const{logger:r,runtime:s}=n,{detailed:t=!1,exitOnError:l=!0,formatter:o,logErrors:a=!0,renderOptions:d={}}=i;if(a)if(o)r.error(o(e));else if(t){const f=s.getCwd(),c=g(e,{cwd:f,hideErrorCodeView:!1,hideErrorTitle:!1,hideMessage:!1,linesAbove:2,linesBelow:3,...d});r.error(c)}else r.error(e);l&&m(1)},version:"1.0.0"});export{E as errorHandlerPlugin};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
import{c as p,e as c,g as v}from"../packem_shared/runtime-process-Dmz0vCJy.js";const i=r=>{if(!r||typeof r!="string")return 0;const o=r.split(".");if(o.length===0||!o[0])return 0;const e=Number.parseInt(o[0],10);return Number.isNaN(e)?0:e},a=r=>!r||typeof r!="string"?"":r.replace("v",""),d=()=>{if(typeof Bun<"u"){const e=Bun.version||"";return{major:i(e),type:"bun",version:e}}if(typeof Deno<"u"){const e=Deno.version?.deno||"";return{major:i(e),type:"deno",version:e}}const r=v().node??"",o=a(r);return{major:i(o),type:"node",version:o}},y=(r={})=>({description:"Checks if the current runtime version meets the minimum requirement",init:o=>{const e=d(),m={bun:1,deno:1,node:18};let n;try{const s=p().CEREBRO_MIN_NODE_VERSION,u=s===void 0?void 0:Number.parseInt(s,10);n=Number.isNaN(u)?void 0:u}catch{n=void 0}let t;r.runtimes?.[e.type]?.minVersion!==void 0?t=r.runtimes[e.type].minVersion:e.type==="node"&&n!==void 0?t=n:t=m[e.type],e.major<t&&(o.logger.error(`cerebro requires ${e.type} version ${String(t)} or higher. You have ${e.type} ${e.version}. Read our version support policy: https://github.com/visulima/visulima#supported-runtimes`),c(1)),o.logger.debug(`Runtime version check passed: ${e.type} ${e.version} >= ${String(t)}`)},name:"runtime-version-check",version:"1.0.0"});export{y as runtimeVersionCheckPlugin};
|
|
@@ -1,22 +1,29 @@
|
|
|
1
|
-
import { P as Plugin } from "../../packem_shared/
|
|
1
|
+
import { a as CerebroFs, P as Plugin } from "../../packem_shared/command.d-DbhtfXF4.js";
|
|
2
2
|
import '@visulima/tabular';
|
|
3
3
|
type UpdateNotifierOptions = {
|
|
4
4
|
alwaysRun?: boolean;
|
|
5
5
|
debug?: boolean;
|
|
6
6
|
distTag?: string;
|
|
7
|
+
/**
|
|
8
|
+
* Injectable filesystem adapter used to read/write the last-update-check
|
|
9
|
+
* cache. The plugin passes `toolbox.fs` so MCP / sandboxed runtimes can swap
|
|
10
|
+
* the filesystem; defaults to a `node:fs/promises` wrapper when omitted.
|
|
11
|
+
*/
|
|
12
|
+
fs?: Pick<CerebroFs, "access" | "mkdir" | "readFile" | "writeFile">;
|
|
7
13
|
pkg: {
|
|
8
14
|
name: string;
|
|
9
15
|
version: string;
|
|
10
16
|
};
|
|
11
17
|
registryUrl?: string;
|
|
12
|
-
shouldNotifyInNpmScript?: boolean;
|
|
18
|
+
shouldNotifyInNpmScript?: boolean; /** Timeout (ms) for the registry request. Defaults to 5000. */
|
|
19
|
+
timeout?: number;
|
|
13
20
|
updateCheckInterval?: number;
|
|
14
21
|
};
|
|
15
|
-
type UpdateNotifierPluginOptions = Partial<Omit<UpdateNotifierOptions, "debug" | "pkg">>;
|
|
22
|
+
type UpdateNotifierPluginOptions = Partial<Omit<UpdateNotifierOptions, "debug" | "fs" | "pkg">>;
|
|
16
23
|
/**
|
|
17
24
|
* Create an update notifier plugin that checks for package updates.
|
|
18
25
|
* @param options Update notifier configuration options.
|
|
19
26
|
* @returns Plugin instance.
|
|
20
27
|
*/
|
|
21
28
|
declare const updateNotifierPlugin: (options?: UpdateNotifierPluginOptions) => Plugin;
|
|
22
|
-
export { UpdateNotifierPluginOptions, updateNotifierPlugin };
|
|
29
|
+
export { type UpdateNotifierPluginOptions, updateNotifierPlugin };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
import{c as A}from"../../packem_shared/runtime-process-Dmz0vCJy.js";var R={},c,C;function p(){return C||(C=1,c=[{name:"Agola CI",constant:"AGOLA",env:"AGOLA_GIT_REF",pr:"AGOLA_PULL_REQUEST_ID"},{name:"Alpic",constant:"ALPIC",env:"ALPIC_HOST"},{name:"Appcircle",constant:"APPCIRCLE",env:"AC_APPCIRCLE",pr:{env:"AC_GIT_PR",ne:"false"}},{name:"AppVeyor",constant:"APPVEYOR",env:"APPVEYOR",pr:"APPVEYOR_PULL_REQUEST_NUMBER"},{name:"AWS CodeBuild",constant:"CODEBUILD",env:"CODEBUILD_BUILD_ARN",pr:{env:"CODEBUILD_WEBHOOK_EVENT",any:["PULL_REQUEST_CREATED","PULL_REQUEST_UPDATED","PULL_REQUEST_REOPENED"]}},{name:"Azure Pipelines",constant:"AZURE_PIPELINES",env:"TF_BUILD",pr:{BUILD_REASON:"PullRequest"}},{name:"Bamboo",constant:"BAMBOO",env:"bamboo_planKey"},{name:"Bitbucket Pipelines",constant:"BITBUCKET",env:"BITBUCKET_COMMIT",pr:"BITBUCKET_PR_ID"},{name:"Bitrise",constant:"BITRISE",env:"BITRISE_IO",pr:"BITRISE_PULL_REQUEST"},{name:"Buddy",constant:"BUDDY",env:"BUDDY_WORKSPACE_ID",pr:"BUDDY_EXECUTION_PULL_REQUEST_ID"},{name:"Buildkite",constant:"BUILDKITE",env:"BUILDKITE",pr:{env:"BUILDKITE_PULL_REQUEST",ne:"false"}},{name:"CircleCI",constant:"CIRCLE",env:"CIRCLECI",pr:"CIRCLE_PULL_REQUEST"},{name:"Cirrus CI",constant:"CIRRUS",env:"CIRRUS_CI",pr:"CIRRUS_PR"},{name:"Cloudflare Pages",constant:"CLOUDFLARE_PAGES",env:"CF_PAGES"},{name:"Cloudflare Workers",constant:"CLOUDFLARE_WORKERS",env:"WORKERS_CI"},{name:"Codefresh",constant:"CODEFRESH",env:"CF_BUILD_ID",pr:{any:["CF_PULL_REQUEST_NUMBER","CF_PULL_REQUEST_ID"]}},{name:"Codemagic",constant:"CODEMAGIC",env:"CM_BUILD_ID",pr:"CM_PULL_REQUEST"},{name:"Codeship",constant:"CODESHIP",env:{CI_NAME:"codeship"}},{name:"Drone",constant:"DRONE",env:"DRONE",pr:{DRONE_BUILD_EVENT:"pull_request"}},{name:"dsari",constant:"DSARI",env:"DSARI"},{name:"Earthly",constant:"EARTHLY",env:"EARTHLY_CI"},{name:"Expo Application Services",constant:"EAS",env:"EAS_BUILD"},{name:"Gerrit",constant:"GERRIT",env:"GERRIT_PROJECT"},{name:"Gitea Actions",constant:"GITEA_ACTIONS",env:"GITEA_ACTIONS"},{name:"GitHub Actions",constant:"GITHUB_ACTIONS",env:"GITHUB_ACTIONS",pr:{GITHUB_EVENT_NAME:"pull_request"}},{name:"GitLab CI",constant:"GITLAB",env:"GITLAB_CI",pr:"CI_MERGE_REQUEST_ID"},{name:"GoCD",constant:"GOCD",env:"GO_PIPELINE_LABEL"},{name:"Google Cloud Build",constant:"GOOGLE_CLOUD_BUILD",env:"BUILDER_OUTPUT"},{name:"Harness CI",constant:"HARNESS",env:"HARNESS_BUILD_ID"},{name:"Heroku",constant:"HEROKU",env:{env:"NODE",includes:"/app/.heroku/node/bin/node"}},{name:"Hudson",constant:"HUDSON",env:"HUDSON_URL"},{name:"Jenkins",constant:"JENKINS",env:["JENKINS_URL","BUILD_ID"],pr:{any:["ghprbPullId","CHANGE_ID"]}},{name:"LayerCI",constant:"LAYERCI",env:"LAYERCI",pr:"LAYERCI_PULL_REQUEST"},{name:"Magnum CI",constant:"MAGNUM",env:"MAGNUM"},{name:"Netlify CI",constant:"NETLIFY",env:"NETLIFY",pr:{env:"PULL_REQUEST",ne:"false"}},{name:"Nevercode",constant:"NEVERCODE",env:"NEVERCODE",pr:{env:"NEVERCODE_PULL_REQUEST",ne:"false"}},{name:"Prow",constant:"PROW",env:"PROW_JOB_ID"},{name:"ReleaseHub",constant:"RELEASEHUB",env:"RELEASE_BUILD_ID"},{name:"Render",constant:"RENDER",env:"RENDER",pr:{IS_PULL_REQUEST:"true"}},{name:"Sail CI",constant:"SAIL",env:"SAILCI",pr:"SAIL_PULL_REQUEST_NUMBER"},{name:"Screwdriver",constant:"SCREWDRIVER",env:"SCREWDRIVER",pr:{env:"SD_PULL_REQUEST",ne:"false"}},{name:"Semaphore",constant:"SEMAPHORE",env:"SEMAPHORE",pr:"PULL_REQUEST_NUMBER"},{name:"Sourcehut",constant:"SOURCEHUT",env:{CI_NAME:"sourcehut"}},{name:"Strider CD",constant:"STRIDER",env:"STRIDER"},{name:"TaskCluster",constant:"TASKCLUSTER",env:["TASK_ID","RUN_ID"]},{name:"TeamCity",constant:"TEAMCITY",env:"TEAMCITY_VERSION"},{name:"Travis CI",constant:"TRAVIS",env:"TRAVIS",pr:{env:"TRAVIS_PULL_REQUEST",ne:"false"}},{name:"Vela",constant:"VELA",env:"VELA",pr:{VELA_PULL_REQUEST:"1"}},{name:"Vercel",constant:"VERCEL",env:{any:["NOW_BUILDER","VERCEL"]},pr:"VERCEL_GIT_PULL_REQUEST_ID"},{name:"Visual Studio App Center",constant:"APPCENTER",env:"APPCENTER_BUILD_ID"},{name:"Woodpecker",constant:"WOODPECKER",env:{CI:"woodpecker"},pr:{CI_BUILD_EVENT:"pull_request"}},{name:"Xcode Cloud",constant:"XCODE_CLOUD",env:"CI_XCODE_PROJECT",pr:"CI_PULL_REQUEST_NUMBER"},{name:"Xcode Server",constant:"XCODE_SERVER",env:"XCS"}]),c}var U;function m(){return U||(U=1,(function(a){const r=p(),e=process.env;Object.defineProperty(a,"_vendors",{value:r.map(function(n){return n.constant})}),a.name=null,a.isPR=null,a.id=null,e.CI!=="false"&&r.forEach(function(n){const t=(Array.isArray(n.env)?n.env:[n.env]).every(function(o){return E(o)});a[n.constant]=t,t&&(a.name=n.name,a.isPR=I(n),a.id=n.constant)}),a.isCI=!!(e.CI!=="false"&&(e.BUILD_ID||e.BUILD_NUMBER||e.CI||e.CI_APP_ID||e.CI_BUILD_ID||e.CI_BUILD_NUMBER||e.CI_NAME||e.CONTINUOUS_INTEGRATION||e.RUN_ID||a.name));function E(n){return typeof n=="string"?!!e[n]:"env"in n?e[n.env]&&e[n.env].includes(n.includes):"any"in n?n.any.some(function(t){return!!e[t]}):Object.keys(n).every(function(t){return e[t]===n[t]})}function I(n){switch(typeof n.pr){case"string":return!!e[n.pr];case"object":return"env"in n.pr?"any"in n.pr?n.pr.any.some(function(t){return e[n.pr.env]===t}):n.pr.env in e&&e[n.pr.env]!==n.pr.ne:"any"in n.pr?n.pr.any.some(function(t){return!!e[t]}):E(n.pr);default:return null}}})(R)),R}var l=m();const P=5e3,O=(a={})=>({beforeCommand:async r=>{const{fs:e,logger:E,runtime:I}=r,n=I.getPackageName(),t=I.getPackageVersion();if(!n||!t){E.debug("Update notifier: package name or version not provided, skipping...");return}const o=A(),i={alwaysRun:!1,debug:o.CEREBRO_OUTPUT_LEVEL==="256",distTag:"latest",fs:e,pkg:{name:n,version:t},timeout:P,updateCheckInterval:1e3*60*60*24,...a};if(!(i.alwaysRun||!(o.NO_UPDATE_NOTIFIER||o.NODE_ENV==="test"||r.argv.includes("--no-update-notifier")||l.isCI))){E.debug("Update notifier: skipping check (disabled by environment or flags)");return}try{const _=await(await import("../../packem_chunks/has-new-version.js").then(s=>s.default))(i);if(_){const[{boxen:s},{dim:L,green:v,reset:T,yellow:u}]=await Promise.all([import("@visulima/boxen"),import("@visulima/colorize")]),D=`Update available ${L(t)}${T(" → ")}${v(_)}`;E.log(s(D,{borderColor:S=>u(S),borderStyle:"round",margin:1,padding:1,textAlignment:"center"}))}}catch(_){E.debug("Update notifier: failed to check for updates",_)}},description:"Checks for package updates and notifies users",name:"update-notifier",version:"1.0.0"});export{O as updateNotifierPlugin};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
const t=()=>{try{const e=require("node:module");if(typeof e.enableCompileCache=="function"){e.enableCompileCache();return}}catch{}try{require("v8-compile-cache")}catch{}};export{t as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
import{createRequire as g}from"node:module";import{d as x,h as y,c as b,e as d,i as j}from"../../packem_shared/runtime-process-Dmz0vCJy.js";const h=g(import.meta.url),t=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,u=e=>{if(typeof t<"u"&&t.versions&&t.versions.node){const[o,s]=t.versions.node.split(".").map(Number);if(o>22||o===22&&s>=3||o===20&&s>=16)return t.getBuiltinModule(e)}return h(e)},{execFileSync:_}=u("node:child_process"),{totalmem:v}=u("node:os"),M=/--max-old-space-size=(\d+)/,z=/--max-semi-space-size=(\d+)/,E=e=>Math.floor(v()/1024/1024*e),P=e=>e<=512?4:e<=1024?8:e<=2048?16:e<=4096?32:e<=8192?64:Math.floor(Math.log2(e))*8,l=(e,o)=>{for(const s of o){const i=e.exec(s);if(i)return Number.parseInt(i[1],10)}},q=e=>{const o=e?.maxOldSpacePercent??.75,s=[...j()],i=[...x()],n=l(M,s),c=l(z,s);if(n!==void 0&&c!==void 0)return;const a=n??E(o),m=c??P(a),r=[];if(n===void 0&&r.push(`--max-old-space-size=${String(a)}`),c===void 0&&r.push(`--max-semi-space-size=${String(m)}`),r.length!==0)try{_(y(),[...r,...s,...i.slice(1)],{env:b(),stdio:"inherit"}),d(0)}catch(f){const p=f.status;d(typeof p=="number"?p:1)}};export{q as applyHeapTuning};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@visulima/cerebro",
|
|
3
|
-
"version": "3.0.0-alpha.
|
|
3
|
+
"version": "3.0.0-alpha.32",
|
|
4
4
|
"description": "A delightful toolkit for building cross-runtime CLIs for Node.js, Deno, and Bun.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"ansi",
|
|
@@ -109,15 +109,15 @@
|
|
|
109
109
|
"LICENSE.md"
|
|
110
110
|
],
|
|
111
111
|
"dependencies": {
|
|
112
|
-
"@visulima/colorize": "2.0.0-alpha.
|
|
113
|
-
"@visulima/tabular": "4.0.0-alpha.
|
|
112
|
+
"@visulima/colorize": "2.0.0-alpha.14",
|
|
113
|
+
"@visulima/tabular": "4.0.0-alpha.14",
|
|
114
114
|
"fastest-levenshtein": "^1.0.16"
|
|
115
115
|
},
|
|
116
116
|
"peerDependencies": {
|
|
117
|
-
"@bomb.sh/tab": "0.0.
|
|
118
|
-
"@visulima/boxen": "3.0.0-alpha.
|
|
119
|
-
"@visulima/find-cache-dir": "3.0.0-alpha.
|
|
120
|
-
"@visulima/pail": "4.0.0-alpha.
|
|
117
|
+
"@bomb.sh/tab": "0.0.16",
|
|
118
|
+
"@visulima/boxen": "3.0.0-alpha.14",
|
|
119
|
+
"@visulima/find-cache-dir": "3.0.0-alpha.12",
|
|
120
|
+
"@visulima/pail": "4.0.0-alpha.22",
|
|
121
121
|
"github-slugger": "2.0.0"
|
|
122
122
|
},
|
|
123
123
|
"peerDependenciesMeta": {
|
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
var St=Object.defineProperty;var $=(t,e)=>St(t,"name",{value:e,configurable:!0});import{createRequire as Dt}from"node:module";import{VERBOSITY_DEBUG as H,POSITIONALS_KEY as se,VERBOSITY_QUIET as Gt,VERBOSITY_VERBOSE as Kt,VERBOSITY_NORMAL as je}from"./VERBOSITY_QUIET-XPultrIA.js";import{c as P}from"./cerebro-error-BnJTixb2.js";import{d as z,h as ke,e as Y,o as Ue,b as Ht,c as Yt,a as Jt,i as Qt,f as Xt}from"./runtime-process-DKHFvYkv.js";import{p as ue}from"./isVisulimaError-jVZgumOU-C4fgdbWg.js";import{distance as Zt}from"fastest-levenshtein";import{s as en,L as tn,M as ne,E as W,P as G,N as I,C as ye,D as Te,W as nn,U as Me,Q as on,_ as Se,J as De,T as Ve,z as an,K as rn,q as sn,I as ln,V as cn,u as un,r as pn,Y as fn,p as dn,n as hn,Z as mn,i as gn,a as vn,A as wn,X as yn,e as bn,t as Be}from"./constants-DmzZF6_u-BmMwILI_.js";const Vt=Dt(import.meta.url),ee=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,it=$(t=>{if(typeof ee<"u"&&ee.versions&&ee.versions.node){const[e,n]=ee.versions.node.split(".").map(Number);if(e>22||e===22&&n>=3||e===20&&n>=16)return ee.getBuiltinModule(t)}return Vt(t)},"__cjs_getBuiltinModule"),{writeFile:Bt,stat:Rt,rm:zt,readFile:Ie,readdir:Wt,mkdir:Ft,access:qt}=it("node:fs/promises"),{createRequire:$n}=it("node:module"),ae=[{alias:"v",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 On=Object.defineProperty,An=$((t,e)=>On(t,"name",{value:e,configurable:!0}),"t$9");let V=class extends P{static{$(this,"a")}static{An(this,"CommandNotFoundError")}commandName;constructor(e,n=[]){const i=`Command "${e}" not found${n.length>0?`. Did you mean: ${n.join(", ")}?`:""}`;super(i,"COMMAND_NOT_FOUND",{commandName:e,suggestions:n}),this.name="CommandNotFoundError",this.commandName=e,n.length>0&&(this.hint=`Try one of these commands: ${n.join(", ")}`)}};var Pn=Object.defineProperty,Cn=$((t,e)=>Pn(t,"name",{value:e,configurable:!0}),"e$7");let at=class extends P{static{$(this,"o")}static{Cn(this,"ConflictingOptionsError")}option1;option2;constructor(e,n){super(`Options "${e}" and "${n}" cannot be used together`,"CONFLICTING_OPTIONS",{option1:e,option2:n}),this.name="ConflictingOptionsError",this.option1=e,this.option2=n,this.hint=`Remove either --${e} or --${n}`}};var Nn=Object.defineProperty,_n=$((t,e)=>Nn(t,"name",{value:e,configurable:!0}),"e$6");let kn=class extends P{static{$(this,"o")}static{_n(this,"PluginError")}pluginName;constructor(e,n,i){super(`Plugin "${e}" error: ${n}`,"PLUGIN_ERROR",{originalError:i,pluginName:e}),this.name="PluginError",this.pluginName=e,i&&(this.cause=i)}};var En=Object.defineProperty,Re=$((t,e)=>En(t,"name",{value:e,configurable:!0}),"d$6");let xn=class{static{$(this,"p")}static{Re(this,"PluginManager")}logger;plugins=new Map;initialized=!1;cachedDependencyOrder=void 0;constructor(e){this.logger=e}hasPlugins(){return this.plugins.size>0}register(e){if(this.initialized)throw new Error(`Cannot register plugin "${e.name}" after initialization`);if(this.plugins.has(e.name))throw new Error(`Plugin "${e.name}" is already registered`);z().CEREBRO_OUTPUT_LEVEL===String(H)&&this.logger.debug(`registering plugin: ${e.name}`),this.plugins.set(e.name,e),this.cachedDependencyOrder=void 0}async init(e){if(this.initialized)throw new Error("PluginManager already initialized");if(this.plugins.size===0){this.logger.debug("no plugins registered, skipping initialization"),this.initialized=!0;return}this.validateDependencies();const n=this.getDependencyOrder();this.logger.debug(`initializing ${String(n.length)} plugin(s)...`);for(const i of n)if(typeof i.init=="function"){this.logger.debug(`initializing plugin: ${i.name}`);try{await i.init(e)}catch(r){const o=new kn(i.name,`Failed to initialize: ${r instanceof Error?r.message:String(r)}`,r instanceof Error?r:void 0);throw this.logger.error(o.message),o}}this.initialized=!0}async executeLifecycle(e,n,i){if(!this.initialized)throw new Error("PluginManager not initialized");if(this.plugins.size===0)return;const r=this.getDependencyOrder();for(const o of r){const c=o[e];if(typeof c=="function"){this.logger.debug(`executing ${e} hook for plugin: ${o.name}`);try{await(e==="afterCommand"?c(n,i):c(n))}catch(s){throw this.logger.error(`Error in ${e} hook for plugin "${o.name}":`,s),s}}}}async executeErrorHandlers(e,n){if(!this.initialized||this.plugins.size===0)return;const i=this.getDependencyOrder();for(const r of i)if(typeof r.onError=="function"){this.logger.debug(`executing error handler for plugin: ${r.name}`);try{await r.onError(e,n)}catch(o){this.logger.error(`Error in error handler for plugin "${r.name}":`,o)}}}getDependencyOrder(){if(this.cachedDependencyOrder!==void 0)return this.cachedDependencyOrder;const e=[],n=new Set,i=new Set,r=Re(o=>{if(n.has(o))return;if(i.has(o))throw new Error(`Circular dependency detected involving plugin "${o}"`);const c=this.plugins.get(o);if(!c)throw new Error(`Plugin "${o}" not found`);if(i.add(o),c.dependencies)for(const s of c.dependencies)r(s);i.delete(o),n.add(o),e.push(c)},"visit");for(const o of this.plugins.keys())r(o);return this.cachedDependencyOrder=e,e}validateDependencies(){for(const e of this.plugins.values())if(e.dependencies){for(const n of e.dependencies)if(!this.plugins.has(n))throw new Error(`Plugin "${e.name}" depends on "${n}" which is not registered`)}}};var Ln=Object.defineProperty,In=$((t,e)=>Ln(t,"name",{value:e,configurable:!0}),"n$b");const oe=In(t=>t.type?.name==="Boolean","optionIsBoolean");var jn=Object.defineProperty,rt=$((t,e)=>jn(t,"name",{value:e,configurable:!0}),"p$6");const Un=rt(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"),ze=rt(t=>(oe(t)||(t.typeLabel=t.typeLabel??Un(t),t.defaultOption&&(t.typeLabel=`${t.typeLabel} (D)`),t.required&&(t.typeLabel=`${t.typeLabel} (R)`)),t),"mapOptionTypeLabel");var Tn=Object.defineProperty,st=$((t,e)=>Tn(t,"name",{value:e,configurable:!0}),"e$4");const Mn=new RegExp(/^-([^\d-])$/),Sn=new RegExp(/^--(\S+)/),Dn=new RegExp(/^-([^\d-]{2,})$/),Vn=st(t=>Mn.test(t)||Sn.test(t)||Dn.test(t),"isOption"),Bn=st((t,e)=>{const n=e[0]&&Vn(e[0])||e.length===0?null:e.shift()??null;if(!t.includes(n)){const i=new Error(`Command not recognised: ${String(n)}`);throw i.command=n,i.name="INVALID_COMMAND",i}return{argv:e,command:n}},"commandLineCommands");var Rn=Object.defineProperty,lt=$((t,e)=>Rn(t,"name",{value:e,configurable:!0}),"o$b"),zn=Object.defineProperty,ct=lt((t,e)=>zn(t,"name",{value:e,configurable:!0}),"o"),Wn=Object.defineProperty,Fn=ct((t,e)=>Wn(t,"name",{value:e,configurable:!0}),"i");let qn=class ut extends ue{static{$(this,"a")}static{lt(this,"r")}static{ct(this,"t")}static{Fn(this,"AlreadySetError")}optionName;constructor(e){super({cause:void 0,hint:`Remove the duplicate option '${e}' from your command line arguments.`,location:void 0,message:`Option '${e}' is already set`,name:"ALREADY_SET",stack:void 0,title:"Option Already Set"}),this.optionName=e,Object.setPrototypeOf(this,ut.prototype)}};var Gn=Object.defineProperty,pt=$((t,e)=>Gn(t,"name",{value:e,configurable:!0}),"t$7"),Kn=Object.defineProperty,ft=pt((t,e)=>Kn(t,"name",{value:e,configurable:!0}),"e"),Hn=Object.defineProperty,Yn=ft((t,e)=>Hn(t,"name",{value:e,configurable:!0}),"e");let We=class dt extends ue{static{$(this,"n")}static{pt(this,"n")}static{ft(this,"o")}static{Yn(this,"UnknownOptionError")}optionName;constructor(e){super({cause:void 0,hint:`Check your option definitions or remove the unknown option '${e}' from your command line arguments.`,location:void 0,message:`Unknown option: --${e}`,name:"UNKNOWN_OPTION",stack:void 0,title:"Unknown Option"}),this.optionName=`--${e}`,Object.setPrototypeOf(this,dt.prototype)}};var Jn=Object.defineProperty,ht=$((t,e)=>Jn(t,"name",{value:e,configurable:!0}),"a$9"),Qn=Object.defineProperty,mt=ht((t,e)=>Qn(t,"name",{value:e,configurable:!0}),"a"),Xn=Object.defineProperty,Zn=mt((t,e)=>Xn(t,"name",{value:e,configurable:!0}),"o");let eo=class gt extends ue{static{$(this,"o")}static{ht(this,"r")}static{mt(this,"e")}static{Zn(this,"UnknownValueError")}value;constructor(e){super({hint:"Use a defined option or add a defaultOption to capture this value.",message:`Unknown value: ${e}`,name:"UNKNOWN_VALUE",title:"Unknown Value"}),this.value=e,Object.setPrototypeOf(this,gt.prototype)}};var to=Object.defineProperty,vt=$((t,e)=>to(t,"name",{value:e,configurable:!0}),"i$8"),no=Object.defineProperty,wt=vt((t,e)=>no(t,"name",{value:e,configurable:!0}),"i"),oo=Object.defineProperty,io=wt((t,e)=>oo(t,"name",{value:e,configurable:!0}),"i");let j=class yt extends ue{static{$(this,"a")}static{vt(this,"o")}static{wt(this,"e")}static{io(this,"InvalidDefinitionsError")}constructor(e,n){super({cause:void 0,hint:n,location:void 0,message:e,name:"INVALID_DEFINITIONS",stack:void 0,title:"Invalid Option Definition"}),Object.setPrototypeOf(this,yt.prototype)}};var ao=Object.defineProperty,ro=$((t,e)=>ao(t,"name",{value:e,configurable:!0}),"E$3"),so=Object.defineProperty,Q=ro((t,e)=>so(t,"name",{value:e,configurable:!0}),"C"),lo=Object.defineProperty,pe=Q((t,e)=>lo(t,"name",{value:e,configurable:!0}),"o");const Fe=pe(t=>t===Boolean||typeof t=="function"&&t.name==="Boolean","isBooleanType"),qe=pe(t=>t===Number||typeof t=="function"&&t.name==="Number","isNumberType"),Ge=pe(t=>t===String||typeof t=="function"&&t.name==="String","isStringType"),co=pe((t,e)=>Array.isArray(t)?Fe(e)?t.map(Boolean):qe(e)?t.map(Number):Ge(e)?t.map(String):t.map(n=>e(String(n))):t===null?null:Fe(e)?!!t:qe(e)?Number(t):Ge(e)?typeof t=="string"?t:String(t):e(typeof t=="string"?t:String(t)),"convertValue");var uo=Object.defineProperty,po=Q((t,e)=>uo(t,"name",{value:e,configurable:!0}),"e");const x=po((t,e,n,...i)=>{t&&console.debug(`[command-line-args:${n}] ${e}`,...i)},"debug");var fo=Object.defineProperty,q=Q((t,e)=>fo(t,"name",{value:e,configurable:!0}),"x$2");const ho=/-([a-z])/g,mo=/^\d+$/,be=q(t=>t===Boolean||typeof t=="function"&&t.name==="Boolean","isBooleanType"),go=q(t=>t.codePointAt(0)===95,"isSpecialKey"),Ke=q((t,e)=>Array.isArray(t)?[...t,...e]:[t,...e],"appendToArrayMultiple"),He=q(t=>t==="__proto__"||t==="constructor"||t==="prototype","isUnsafeKey"),Ye=q((t,e,n,i=!1)=>{t[e]===void 0?t[e]=i?[n]:n:i&&Array.isArray(t[e])?t[e].push(n):t[e]=[t[e],n]},"createOrAppendArray"),vo=q((t,e,n,i,r)=>{let o=e.get(t)??n.get(t);if(!o&&i){const c=t.toLowerCase();o=i.get(c)??r?.get(c)}return o},"getDefinition"),wo=q((t,e,n,i)=>{const r=n.debug??!1;x(r,"resolveArgs called with options:","resolver",{partial:n.partial,stopAtFirstUnknown:n.stopAtFirstUnknown}),x(r,"Starting argument resolution","resolver"),x(r,"Tokens:","resolver",t),x(r,"Definitions:","resolver",e),x(r,"Processing tokens...","resolver");const o=new Map,c=new Map,s=n.caseInsensitive?new Map:void 0,g=n.caseInsensitive?new Map:void 0,a=n.camelCase?new Map:void 0,u=n.camelCase?new Map:void 0;for(const p of e)if(o.set(p.name,p),p.alias&&c.set(p.alias,p),n.caseInsensitive&&s&&(s.set(p.name.toLowerCase(),p),p.alias&&g&&g.set(p.alias.toLowerCase(),p)),n.camelCase&&a&&u){const m=p.name.replaceAll(ho,(v,O)=>O.toUpperCase());a.set(p.name,m),u.set(m,p.name)}const d={},l={},h=[],f=[],y=new Set;let b=!1;const w=e.find(p=>p.defaultOption),C=e.some(p=>p.group),N=e.some(p=>p.type===Number);for(let p=0;p<t.length;p++){const m=t[p];if(m.kind==="option-terminator"){d._unknown=i.slice(m.index),b=!0;break}if(m.kind==="option"&&m.name){let v=vo(m.name,o,c,s,g);if(!v&&m.value===void 0&&N&&mo.test(m.name)){const _=e.find(M=>M.type===Number);_&&(v=_,m.value=m.name,m.name=_.name)}const O=v?v.name:m.name,A=v?.multiple,U=v?.lazyMultiple;if(l[O]!==void 0&&!A&&!U&&!n.partial)throw new qn(O);if(!v&&n.partial){const _=m.rawName??`--${m.name}${m.value!==void 0&&m.inlineValue?`=${m.value}`:""}`;h.push({index:m.index,value:_});continue}if(!v&&n.stopAtFirstUnknown){d._unknown=i.slice(m.index);break}if(!v&&!n.partial)throw new We(m.name);if(m.value===void 0){const _=t[p+1],M=_?.kind==="option"&&!("name"in _)&&_.value!==void 0,L=_&&v&&!(v.type&&be(v.type))&&(_.kind==="positional"||M),Mt=v&&v.defaultOption&&!v.multiple&&!v.lazyMultiple;if(L&&(!v?.defaultOption||Mt))if(A){let S=p+1;const we=[];for(;S<t.length&&(t[S].kind==="positional"||t[S].kind==="option"&&!("name"in t[S])&&t[S].value!==void 0);)we.push(t[S].value),y.add(t[S].index),S++;l[O]=l[O]===void 0?we:Ke(l[O],we),p=S-1}else U?(Ye(l,O,_.value,!0),y.add(_.index),p++):(l[O]=_.value,y.add(_.index),p++);else v?.type&&be(v.type)?Ye(l,O,!0,A):l[O]=A?[]:null}else{let{value:_}=m;if(v?.type&&be(v.type))switch(_){case"":{if(n.partial){l._unknown??=[];const L=`${m.rawName??`--${m.name}`}${m.value?`=${m.value}`:""}`;l._unknown.push(L),f.push({index:m.index,value:L}),_=!0}else throw new We(m.name);break}case"false":{_=!1;break}case"true":{_=!0;break}default:_=!0}const M=[_];if(A){let L=p+1;for(;L<t.length&&t[L].kind==="positional";)M.push(t[L].value),y.add(t[L].index),L++;p=L-1}l[O]===void 0?l[O]=A||U?M:_:A||U?l[O]=Ke(l[O],M):l[O]=_}}else if(m.kind==="positional"&&n.stopAtFirstUnknown&&!y.has(m.index)&&!w){x(r,`Found unconsumed positional token at index ${String(m.index)}, stopping processing`,"resolver"),d._unknown=i.slice(m.index);break}}for(const[p,m]of Object.entries(l)){const v=o.get(p);v&&(v.multiple||v.lazyMultiple)&&!Array.isArray(m)&&(l[p]=[m])}let E=Number.POSITIVE_INFINITY;if(n.stopAtFirstUnknown&&!b){for(const p of t)if(p.kind==="option"&&!o.has(p.name??"")&&!c.has(p.name??"")&&(!n.caseInsensitive||!s?.has(p.name?.toLowerCase()??"")&&!g?.has(p.name?.toLowerCase()??""))){E=p.index;break}}if(w){const p=[],m=[];for(const v of t)v.kind==="positional"&&!y.has(v.index)&&v.index<E&&(p.push(v.value),m.push(v));if(p.length>0){const v=l[w.name],O=w.multiple??w.lazyMultiple;v===void 0?O?(m.forEach(A=>y.add(A.index)),l[w.name]=p):(y.add(m[0].index),l[w.name]=p[0]):O&&(m.forEach(A=>y.add(A.index)),l[w.name]=Array.isArray(v)?[...p,...v]:[...p,v])}}if(!n.partial){for(const p of t)if(p.kind==="positional"&&!y.has(p.index))throw new eo(i[p.index])}if(n.partial&&!n.stopAtFirstUnknown){const p=[...h];if(l._unknown)for(const m of f)p.push({index:m.index,value:m.value});for(const m of t)m.kind==="positional"&&!y.has(m.index)&&p.push({index:m.index,value:i[m.index]});p.length>0&&(p.sort((m,v)=>m.index-v.index),d._unknown=p.map(m=>m.value))}if(n.stopAtFirstUnknown&&!b){const p=t.findIndex(O=>O.kind==="option"&&!o.has(O.name??"")&&!c.has(O.name??"")&&(!n.caseInsensitive||!s?.has(O.name?.toLowerCase()??"")&&!g?.has(O.name?.toLowerCase()??""))),m=t.findIndex(O=>O.kind==="positional"&&!y.has(O.index));let v=-1;if(p!==-1&&m!==-1?v=Math.min(p,m):p!==-1?v=p:m!==-1&&(v=m),v>=0){const O=t[v].index;d._unknown=i.slice(O)}}else h.length>0&&!n.partial&&(d._unknown=h.map(p=>p.value));for(const[p,m]of Object.entries(l)){const v=n.camelCase?a?.get(p)??p:p,O=o.get(p);d[v]=O?.type?co(m,O.type):m===void 0?null:m}for(const p of e){const m=n.camelCase?a?.get(p.name)??p.name:p.name;!(m in d)&&p.defaultValue!==void 0&&(p.multiple??p.lazyMultiple?d[m]=Array.isArray(p.defaultValue)?[...p.defaultValue]:[p.defaultValue]:d[m]=p.defaultValue)}if(C){const p={},m={},v={};for(const A of e)if(A.group){const U=Array.isArray(A.group)?A.group:[A.group];for(const _ of U)He(_)||(p[_]??={})}for(const A of Object.keys(d))if(!go(A)){m[A]=d[A];let U=A;n.camelCase&&(U=u?.get(A)??A);const _=o.get(U);if(_?.group){const M=Array.isArray(_.group)?_.group:[_.group];for(const L of M)He(L)||p[L]&&(p[L][A]=d[A])}else v[A]=d[A]}const O={_all:m};for(const[A,U]of Object.entries(p))O[A]=U;Object.keys(v).length>0&&(O._none=v),d._unknown&&(O._unknown=d._unknown),Object.keys(d).forEach(A=>delete d[A]),Object.assign(d,O)}return x(r,"Final parsed result:","resolver",d),d},"resolveArgs");var yo=Object.defineProperty,X=Q((t,e)=>yo(t,"name",{value:e,configurable:!0}),"l");const J="-".codePointAt(0),F="=",bo=F.codePointAt(0),$o="--",Oo="-",Ao="--",bt=X(t=>t.length>2&&t.startsWith(Ao),"hasLongOptionPrefix"),Po=X(t=>bt(t)&&!t.includes(F,3),"isLongOption"),Co=X(t=>bt(t)&&t.includes(F,3),"isLongOptionAndValue"),No=X(t=>{if(t.length!==2||t.codePointAt(0)!==J||t.codePointAt(1)===J)return!1;const e=t.codePointAt(1);return e!==void 0&&(e<48||e>57)},"isShortOption"),_o=X(t=>!(t.length<=2||t.codePointAt(0)!==J||t.codePointAt(1)===J),"isShortOptionGroup"),ko=X(t=>{const e=[],n=[...t];let i=-1,r=0;for(;n.length>0;){const o=n.shift();if(o===void 0)break;if(r>0?r--:i++,o===$o){e.push({index:i,kind:"option-terminator"});const c=n.map((s,g)=>({index:i+g+1,kind:"positional",value:s}));e.push(...c),i+=n.length;break}if(No(o)){const c=o.charAt(1);e.push({index:i,kind:"option",name:c,rawName:o});continue}if(_o(o)&&!o.includes(F)){const c=[];let s="",g=!1;for(let a=1;a<o.length;a++){const u=o.charAt(a);g?s+=u:u.codePointAt(0)===bo?g=!0:c.push(`${Oo}${u}`)}if(g)if(c.length>0){const a=c.pop();c.push(`${a}=${s}`)}else c.push(s);n.unshift(...c),r=c.length;continue}if(Po(o)){const c=o.slice(2);e.push({index:i,kind:"option",name:c,rawName:o});continue}if(Co(o)){const c=o.indexOf(F),s=o.slice(2,c),g=o.slice(c+1);e.push({index:i,inlineValue:!0,kind:"option",name:s,rawName:o,value:g});continue}if(o.length>2&&o.codePointAt(0)===J&&o.codePointAt(1)!==J&&o.includes(F)){const c=o.indexOf(F),s=o.charAt(1),g=o.slice(c+1);e.push({index:i,inlineValue:!0,kind:"option",name:s,rawName:o,value:g});continue}e.push({index:i,kind:"positional",value:o})}return e},"parseArgsTokens");var Eo=Object.defineProperty,xe=Q((t,e)=>Eo(t,"name",{value:e,configurable:!0}),"d");const xo=/\d/,Lo=xe(t=>t===Boolean||typeof t=="function"&&t.name==="Boolean","isBooleanType"),Io=xe(t=>typeof t=="function","isValidCustomTypeFunction"),jo=xe((t,e,n)=>{const i=n?.debug??!1;x(i,"Validating definitions:","validation",t,"caseInsensitive:",e);const r=new Set,o=new Set,c=new Set,s=new Set;let g=0;for(const a of t){if(x(i,"Checking definition:","validation",a),!a.name)throw x(i,"Validation failed: name is required","validation"),new j("Invalid option definition: name is required");if(typeof a.name!="string")throw new j("Invalid option definition: name must be a string");if(a.name.trim()==="")throw new j("Invalid option definition: name cannot be empty");const u=e?a.name.toLowerCase():"";if(r.has(a.name)||e&&c.has(u))throw new j(`Invalid option definition: duplicate name '${a.name}'`);if(o.has(a.name)||e&&s.has(u))throw new j(`Invalid option definition: name '${a.name}' conflicts with an existing alias`);if(r.add(a.name),e&&c.add(u),a.alias!==void 0){if(typeof a.alias!="string")throw new j("Invalid option definition: alias must be a string");if(a.alias.length!==1)throw new j("Invalid option definition: alias must be a single character");if(xo.test(a.alias))throw new j("Invalid option definition: alias cannot be numeric");if(a.alias==="-")throw new j('Invalid option definition: alias cannot be "-"');const d=e?a.alias.toLowerCase():"";if(o.has(a.alias)||e&&s.has(d))throw new j(`Invalid option definition: duplicate alias '${a.alias}'`);if(r.has(a.alias)||e&&c.has(d))throw new j(`Invalid option definition: alias '${a.alias}' conflicts with an existing option name`);o.add(a.alias),e&&s.add(d)}if(a.defaultOption&&(g++,a.type!==void 0&&Lo(a.type)))throw new j("Invalid option definition: defaultOption cannot be Boolean type");if(a.type!==void 0&&!(a.type===Boolean||a.type===Number||a.type===String||typeof a.type=="function"&&Io(a.type)))throw new j("Invalid option definition: invalid type")}if(g>1)throw x(i,"Validation failed: multiple defaultOptions not allowed","validation"),new j("Invalid option definition: multiple defaultOptions not allowed");x(i,"Validation completed successfully","validation")},"validateDefinitions");var Uo=Object.defineProperty,To=Q((t,e)=>Uo(t,"name",{value:e,configurable:!0}),"O");const Mo=To((t,e={})=>{const n=e.debug??!1;x(n,"Starting command-line-args parsing","index"),x(n,"Options:","index",e);const i={...e};i.stopAtFirstUnknown&&(i.partial=!0);const r=Array.isArray(t)?t:[t];x(n,"Normalized definitions:","index",r),jo(r,i.caseInsensitive,n?i:void 0);let{argv:o}=i;if(!o&&(o=process.argv.slice(2),process.execArgv.length>0)){const a=new Set(process.execArgv);o=o.filter(u=>!a.has(u))}x(n,"Using argv:","index",o);let c=o;i.caseInsensitive&&(c=o.map(a=>{if(a.startsWith("--")){const u=a.indexOf("="),d=(u===-1?a.slice(2):a.slice(2,u)).toLowerCase();return u===-1?`--${d}`:`--${d}${a.slice(u)}`}if(a.startsWith("-")&&!a.startsWith("--")&&a.length>1){const u=a.slice(1).split("=",2),d=u[0],l=u[1];if(!d)return a;const h=d.toLowerCase();return l===void 0?`-${h}`:`-${h}=${l}`}return a}));const s=ko(c.map(String));x(n,"Tokenized arguments:","index",s);const g=wo(s,r,i,o);return x(n,"Command-line-args parsing completed","index"),g},"commandLineArgs");var So=Object.defineProperty,Do=$((t,e)=>So(t,"name",{value:e,configurable:!0}),"b$2");let Vo=class{static{$(this,"m")}static{Do(this,"EmptyToolbox")}result;argv;options;argument;command;commandName;env;logger;console;fs;process;runtime;rawUnknown;constructor(e,n){this.commandName=e,this.command=n}};var Bo=Object.defineProperty,Ro=$((t,e)=>Bo(t,"name",{value:e,configurable:!0}),"n$7");let $e=class extends P{static{$(this,"i")}static{Ro(this,"CommandLoaderError")}commandName;constructor(e,n,i){super(`Failed to load command "${e}": ${n}`,"COMMAND_LOADER_ERROR",{commandName:e,reason:n}),this.name="CommandLoaderError",this.commandName=e,this.hint="Ensure the loader resolves to a module with a default export that is the command handler function.",i!==void 0&&(this.cause=i)}};var zo=Object.defineProperty,Wo=$((t,e)=>zo(t,"name",{value:e,configurable:!0}),"f$5");const Fo=/^-{1,2}(\w+)(=(.+))?$/,$t=Wo((t,e,n,i)=>{const r=Fo.exec(t);if(r===null)return{};const o=r[1];if(!o)return{};const c=n&&i?n.get(o)??i.get(o):e.find(s=>s.name===o||s.alias===o);return c!==void 0?{argName:c.name,argValue:r[3],option:c}:{}},"getParameterOption");var qo=Object.defineProperty,Ee=$((t,e)=>qo(t,"name",{value:e,configurable:!0}),"e$3");const Je=Ee((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"),Go=new Set(["0","1","false","true"]),Ko=Ee((t,e,n,i)=>{if(e.length===0||t.length===0)return{};const r=Ee((o,c)=>{const{argName:s,argValue:g,option:a}=$t(c,e,n,i),{lastOption:u}=o;return a&&oe(a)&&g&&s?o.partial[s]=Je(g,a):o.lastName&&u&&oe(u)&&Go.has(c)&&(o.partial[o.lastName]=Je(c,u)),{lastName:s,lastOption:a,partial:o.partial}},"getBooleanValue");return t.reduce(r,{partial:{}}).partial},"getBooleanValues");var Ho=Object.defineProperty,Qe=$((t,e)=>Ho(t,"name",{value:e,configurable:!0}),"s$9");const Yo=new Set(["0","1","false","true"]),Jo=Qe((t,e,n,i)=>{if(e.length===0||t.length===0)return t;const r=Qe((o,c)=>{const{argValue:s,option:g}=$t(c,e,n,i),{lastOption:a}=o;if(a&&oe(a)&&Yo.has(c)){const{args:u}=o;return{args:u.slice(0,-1)}}return g&&oe(g)&&s?{args:o.args}:{args:[...o.args,c],lastOption:g}},"removeBooleanArguments");return t.reduce(r,{args:[]}).args},"removeBooleanValues");var Qo=Object.defineProperty,Xo=$((t,e)=>Qo(t,"name",{value:e,configurable:!0}),"o$8");const Xe=Xo(t=>{const e=new Map;for(const n of t){const i=e.get(n.name);i?e.set(n.name,{...i,...n}):e.set(n.name,n)}return[...e.values()]},"mergeArguments");var Zo=Object.defineProperty,fe=$((t,e)=>Zo(t,"name",{value:e,configurable:!0}),"o$7");const ei=fe(t=>{if(t===void 0)return;const e=t.toLowerCase().trim();return e==="true"||e==="1"||e==="yes"||e==="on"},"transformBooleanEnv"),ti=fe((t,e)=>{if(!t.type)return e;if(e!==void 0){if(t.type===Boolean||typeof t.type=="function"&&t.type.name==="Boolean")return ei(e);if(t.type===Number||typeof t.type=="function"&&t.type.name==="Number"){const n=Number.parseFloat(e);return Number.isNaN(n)?void 0:n}return t.type===String||typeof t.type=="function"&&t.type.name==="String"?e:t.type(e)}},"transformEnvValue"),ni=/_./g,oi=/^[A-Z]/,ii=fe(t=>t.toLowerCase().replaceAll(ni,e=>e[1]?.toUpperCase()??e).replace(oi,e=>e.toLowerCase()),"toCamelCase"),ai=fe(t=>{if(!t||t.length===0)return{};const e={},n=z();for(const i of t){const r=n[i.name],o=ti(i,r),c=o===void 0?i.defaultValue:o,s=ii(i.name);e[s]=c}return e},"processEnvVariables");var ri=Object.defineProperty,ie=$((t,e)=>ri(t,"name",{value:e,configurable:!0}),"a$5");const si=ie(t=>{const e=new Map,n=new Map;for(const i of t)if(e.set(i.name,i),i.alias){const r=Array.isArray(i.alias)?i.alias:[i.alias];for(const o of r)n.set(o,i)}return{optionMapByAlias:n,optionMapByName:e}},"buildOptionMaps"),Ot=ie(async t=>{if(typeof t.__resolvedExecute__=="function")return t.__resolvedExecute__;if(typeof t.loader!="function")throw new $e(t.name,"no execute or loader defined");let e;try{e=await t.loader()}catch(i){throw new $e(t.name,i instanceof Error?i.message:String(i),i)}const n=e.default;if(typeof n!="function")throw new $e(t.name,"loader did not return a module with a default-exported handler function");return t.__resolvedExecute__=n,n},"loadLazyHandler"),li=ie((t,e,n,i)=>{const r=new Vo(t.name,t),{_all:o,_unknown:c,positionals:s}=e,g=Object.keys(n).length>0?{...o,...n}:o;se in g&&delete g[se],r.argument=s?.[se]??[],r.rawUnknown=[...c??[]];const a=Object.keys(i).length>0;return r.options=a?{...g,...i}:g,r.env=ai(t.env),r},"prepareToolbox"),ci=ie((t,e,n)=>{const i=t.options??[],r=i.length>0;let o=Xe(r?[...i,...n]:n);if(o.length>0){for(const a of o)if(a.multiple&&a.lazyMultiple)throw new Error(`Argument "${a.name}" cannot have both multiple and lazyMultiple options, please choose one.`)}t.argument&&(o=[{defaultOption:!0,description:t.argument.description,group:"positionals",multiple:!0,name:se,type:t.argument.type,typeLabel:t.argument.typeLabel},...o]);let c,s;if(r){const{optionMapByAlias:a,optionMapByName:u}=si(i);c=Jo(e,i,u,a),s=Ko(e,i,u,a)}else c=e,s={};const g=Mo(o,{argv:c,camelCase:!0,partial:!0,stopAtFirstUnknown:!0});return{arguments_:o,booleanValues:s,parsedArgs:g}},"processCommandArgs"),K=ie(async(t,e,n)=>typeof t.execute=="function"?t.execute(e):(await Ot(t))(e),"executeCommand");var ui=Object.defineProperty,pi=$((t,e)=>ui(t,"name",{value:e,configurable:!0}),"n$6");let fi=class extends P{static{$(this,"s")}static{pi(this,"CommandValidationError")}commandName;missingOptions;constructor(e,n){super(`Command "${e}" is missing required options: ${n.join(", ")}`,"COMMAND_VALIDATION_ERROR",{commandName:e,missingOptions:n}),this.name="CommandValidationError",this.commandName=e,this.missingOptions=n,this.hint=`Provide the following required options: ${n.join(", ")}`}};var di=Object.defineProperty,hi=$((t,e)=>di(t,"name",{value:e,configurable:!0}),"t$5");const Ze=hi((t,e,n=!1)=>{const i=[];for(const r of t)if(!(!n&&!r.required)&&e[r.name]===void 0){if(r.type?.name==="Boolean"){e[r.name]=!1;continue}i.push(r)}return i},"listMissingArguments");var mi=Object.defineProperty,At=$((t,e)=>mi(t,"name",{value:e,configurable:!0}),"n$5");const gi=At((t,e)=>e.includes(t)?!0:Math.abs(t.length-e.length)>t.length/2?!1:Zt(t,e)<=t.length/3,"isSimilar"),R=At((t,e)=>{const n=t.toLowerCase();return e.filter(i=>gi(i.toLowerCase(),n))},"findAlternatives");var vi=Object.defineProperty,de=$((t,e)=>vi(t,"name",{value:e,configurable:!0}),"a$4");const wi=de((t,e)=>{const n=[];if(t._unknown&&t._unknown.forEach(i=>{const r=i.startsWith("--");let o=`Found unknown ${r?"option":"argument"} "${i}"`;if(r){const c=R(i.replace("--",""),(e.options??[]).map(s=>s.name));if(c.length>0){const[s,...g]=c.map(a=>`--${a}`);o+=g.length>0?`, did you mean ${s??""} or ${g.join(", ")}?`:`, did you mean ${s??""}?`}}n.push(o)}),n.length>0)throw new Error(n.join(`
|
|
2
|
-
`))},"validateUnknownOptions"),yi=de((t,e,n)=>{const i=n.__requiredOptions__,r=i?Ze(i,e,!0):Ze(t,e,!1);if(r.length>0)throw new fi(n.name,r.map(o=>o.name));e._unknown&&e._unknown.length>0&&!n.argument&&wi(e,n)},"validateRequiredOptions"),bi=de((t,e,n)=>{const i=n.__conflictingOptions__??t.filter(r=>r.conflicts!==void 0);if(i.length>0){const r=i.find(o=>Array.isArray(o.conflicts)?o.conflicts.some(c=>e[c]!==void 0)&&e[o.name]!==void 0:e[o.conflicts]!==void 0&&e[o.name]!==void 0);if(r)throw new at(r.name,typeof r.conflicts=="string"?r.conflicts:r.conflicts?.[0]??"unknown")}},"validateConflictingOptions"),$i=de(t=>{if(!Array.isArray(t.options))return;const e=new Map,n=new Map;for(const r of t.options){if(r.name){const o=e.get(r.name)??[];o.push(r),e.set(r.name,o)}if(typeof r.alias=="string"&&r.alias.length>0){const o=n.get(r.alias)??[];o.push(r),n.set(r.alias,o)}else if(Array.isArray(r.alias)){for(const o of r.alias)if(o.length>0){const c=n.get(o)??[];c.push(r),n.set(o,c)}}}const i=[];for(const[r,o]of e)o.length>1&&i.push(`Duplicate option name "${r}" in command "${t.name}": ${JSON.stringify(o)}`);for(const[r,o]of n)o.length>1&&i.push(`Duplicate option alias "-${r}" used by options ${o.map(c=>`"${c.name}"`).join(", ")} in command "${t.name}"`);if(i.length>0)throw new Error(i.join(`
|
|
3
|
-
`))},"validateDuplicateOptions");var Oi=Object.defineProperty,Le=$((t,e)=>Oi(t,"name",{value:e,configurable:!0}),"s$5");const Ai=Le((t,e)=>{if(e.length===0)return{argv:[],commandPath:void 0};const n=[];let i;for(let r=1;r<=e.length;r+=1){const o=e[r-1];if(o===void 0||o.startsWith("-"))break;n.push(o);const c=n.join(" ");t.has(c)&&(i={commandPath:[...n],depth:r})}return i?{argv:e.slice(i.depth),commandPath:i.commandPath}:{argv:e,commandPath:void 0}},"parseNestedCommand"),B=Le(t=>t.join(" "),"getCommandPathKey"),et=Le((t,e)=>e&&e.length>0?[...e,t]:[t],"getFullCommandPath");var Pi=Object.defineProperty,Pt=$((t,e)=>Pi(t,"name",{value:e,configurable:!0}),"a$3"),Ci=Object.defineProperty,Ct=Pt((t,e)=>Ci(t,"name",{value:e,configurable:!0}),"a"),Ni=Object.defineProperty,_i=Ct((t,e)=>Ni(t,"name",{value:e,configurable:!0}),"a");let Nt=class{static{$(this,"u")}static{Pt(this,"n")}static{Ct(this,"s")}static{_i(this,"LRUCache")}capacity;cache;constructor(e){this.capacity=e,this.cache=new Map}get(e){if(!this.cache.has(e))return;const n=this.cache.get(e);return this.cache.delete(e),this.cache.set(e,n),n}has(e){return this.cache.has(e)}set(e,n){if(this.cache.has(e))this.cache.delete(e);else if(this.cache.size>=this.capacity){const i=this.cache.keys().next().value;i!==void 0&&this.cache.delete(i)}this.cache.set(e,n)}delete(e){this.cache.delete(e)}clear(){this.cache.clear()}size(){return this.cache.size}};var ki=Object.defineProperty,Ei=$((t,e)=>ki(t,"name",{value:e,configurable:!0}),"r$5"),xi=Object.defineProperty,Li=Ei((t,e)=>xi(t,"name",{value:e,configurable:!0}),"a"),Ii=Object.defineProperty,ji=Li((t,e)=>Ii(t,"name",{value:e,configurable:!0}),"s");const Ui=ji((t,e)=>typeof t!="string"||t===""?"":(e?.locale?t[0].toLocaleLowerCase(e.locale):t[0].toLowerCase())+t.slice(1),"lowerFirst");var Ti=Object.defineProperty,Mi=$((t,e)=>Ti(t,"name",{value:e,configurable:!0}),"T"),Si=Object.defineProperty,he=Mi((t,e)=>Si(t,"name",{value:e,configurable:!0}),"j");const Di=$n(import.meta.url),te=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,Vi=he(t=>{if(typeof te<"u"&&te.versions&&te.versions.node){const[e,n]=te.versions.node.split(".").map(Number);if(e>22||e===22&&n>=3||e===20&&n>=16)return te.getBuiltinModule(t)}return Di(t)},"__cjs_getBuiltinModule"),{stripVTControlCharacters:Bi}=Vi("node:util");var Ri=Object.defineProperty,zi=he((t,e)=>Ri(t,"name",{value:e,configurable:!0}),"a");const Oe=new Nt(1e3),Wi=/[.*+?^${}()|[\]\\]/g,Fi=zi(t=>{const e=t.join("");if(Oe.has(e)){const r=Oe.get(e);return r.lastIndex=0,r}const n=t.map(r=>r.replaceAll(Wi,String.raw`\$&`)).join("|"),i=new RegExp(n,"g");return Oe.set(e,i),i},"getSeparatorsRegex");var qi=Object.defineProperty,Gi=he((t,e)=>qi(t,"name",{value:e,configurable:!0}),"t");const Ki=Gi(t=>{const e=[];let n=0,i;for(W.lastIndex=0;(i=W.exec(t))!==null;)i.index>n&&e.push(t.slice(n,i.index)),e.push(i[0]),n=W.lastIndex;return n<t.length&&e.push(t.slice(n)),e.filter(Boolean)},"splitByEmoji");var Hi=Object.defineProperty,k=he((t,e)=>Hi(t,"name",{value:e,configurable:!0}),"u");const Yi=/[ČŠŽĐ]/i,_t=new Uint8Array(128),kt=new Uint8Array(128),Et=new Uint8Array(128);for(let t=0;t<128;t++)_t[t]=t>=65&&t<=90?1:0,kt[t]=t>=97&&t<=122?1:0,Et[t]=t>=48&&t<=57?1:0;const Ae=k(t=>_t[t],"isUpper"),tt=k(t=>kt[t],"isLower"),Pe=k(t=>Et[t],"isDigit"),D=k((t,e,n,i,r)=>{if(t.length===0)return[];let o=!1;const c=Object.values(e);for(const h of c)if(h(t[0])){o=!0;break}if(!o&&!n)return[t];const s=[...t],g=[];let a=s[0],u="other";const d=Object.entries(e);for(const h of d){const[f,y]=h;if(y(s[0])){u=f;break}}let l=n&&i?s[0]===s[0].toLocaleUpperCase(i):!1;for(let h=1;h<s.length;h++){const f=s[h];let y="other";for(const C of d){const[N,E]=C;if(E(f)){y=N;break}}const b=n&&i?f===f.toLocaleUpperCase(i):!1;let w=!1;r?w=r(u,y,l,b,f,h,s):(u!==y&&u!=="other"&&y!=="other"&&(w=!0),n&&y!=="other"&&!l&&b&&(w=!0)),w?(g.push(a),a=f):a+=f,u=y,n&&(l=b)}return a&&a.length>0&&g.push(a),g.length>0?g:[t]},"handleScriptTransitions"),Ji=k((t,e,n,i)=>{if(n.size===0)return e;for(const r of n)if(t.startsWith(r,e))return i.push(r),e+r.length;return e},"detectAndProcessAcronym"),xt=k((t,e=new Set)=>{if(t.length===0)return[];if(t.toUpperCase()===t)return[t];let n=0;const i=[],r=t.length;for(let o=1;o<r;o++){const c=Ji(t,n,e,i);if(c!==n){n=c,o=n-1;continue}const s=t.codePointAt(o-1),g=t.codePointAt(o),a=s&&s<128&&Ae(s),u=g&&g<128&&Ae(g),d=s&&s<128&&tt(s),l=s&&s<128&&Pe(s),h=g&&g<128&&Pe(g);if(d&&u){i.push(t.slice(n,o)),n=o;continue}if(l&&!h||!l&&h){i.push(t.slice(n,o)),n=o;continue}if(h&&!l){let f=!1,y=!1;if(o+1<r){const b=t.codePointAt(o+1);f=b&&b<128&&Ae(b),y=b&&b<128&&Pe(b)}if(!y&&f){i.push(t.slice(n,o),t.slice(o,o+1)),n=o+1;continue}}if(o+1<r){const f=t.codePointAt(o+1),y=f&&f<128&&tt(f);if(a&&u&&y){const b=t.slice(n,o+1);e.has(b)||(i.push(t.slice(n,o)),n=o)}}}return n<r&&i.push(t.slice(n)),i.filter(o=>o!=="")},"splitCamelCaseFast"),Lt=k((t,e,n)=>{if(t.length===0)return[];const i=t===t.toLocaleUpperCase(e);if(e.startsWith("de")){if(!i&&t.replaceAll("ß","SS")===t.toLocaleUpperCase(e))return[t];const a=[...t],u=a.length,d=[];let l=a[0],h=a[0]===a[0].toLocaleUpperCase(e),f=h,y=h?0:-1;for(let b=1;b<u;b++){const w=a[b],C=w===w.toLocaleUpperCase(e);if(C===h)l+=w;else if(C)l&&l.length>0&&(d.push(l),l=w),f=!0,y=b;else{if(f&&b-y>1){const N=a[b-1],E=l.slice(0,-1);E&&E.length>0&&d.push(E),l=N+w}else l+=w;f=!1,y=-1}h=C}return l&&l.length>0&&d.push(l),d}if(e.startsWith("uk")||e.startsWith("ru")||e.startsWith("bg")||e.startsWith("sr")||e.startsWith("mk")||e.startsWith("be")){if(!G.test(t)&&!I.test(t))return[t];const a=[...t],u=a.length,d=[];let l=a[0];const h=a[0];let f;G.test(h)?f=1:I.test(h)?f=2:f=0;let y=h===h.toLocaleUpperCase(e);for(let w=1;w<u;w++){const C=a[w];let N;G.test(C)?N=1:I.test(C)?N=2:N=0;const E=C===C.toLocaleUpperCase(e);f!==N&&(f===1||f===2)&&(N===1||N===2)||N===f&&!y&&E?(d.push(l),l=C):l+=C,f=N,y=E}l&&l.length>0&&d.push(l);const b=[];for(let w=0;w<d.length;w++)w<d.length-1&&d[w].length===1&&I.test(d[w])&&G.test(d[w+1][0])?(b.push(d[w]+d[w+1]),w+=1):b.push(d[w]);return b}if(e.startsWith("el")){if(!ye.test(t)&&!I.test(t))return[t];const a=[];Te.lastIndex=0;let u;for(;(u=Te.exec(t))!==null;)a.push(u[0]);a.length===0&&a.push(t);const d=[];if(a.length===1){const l=a[0];if(!l||!ye.test(l[0])||l.length===1)return[l??t]}for(const l of a){if(!l)continue;if(!ye.test(l[0])||l.length===1){d.push(l);continue}const h=l.length;let f=l[0],y=l[0]===l[0].toLocaleUpperCase(e);for(let b=1;b<h;b++){const w=l[b],C=w===w.toLocaleUpperCase(e);!y&&C?(d.push(f),f=w):f+=w,y=C}f&&d.push(f)}return d}if(e.startsWith("ja")||e.startsWith("ko")){const a=e.startsWith("ja"),u=a?{hiragana:k(l=>on.test(l),"hiragana"),kanji:k(l=>Me.test(l),"kanji"),katakana:k(l=>nn.test(l),"katakana"),latin:k(l=>I.test(l),"latin")}:{hangul:k(l=>Se.test(l),"hangul"),latin:k(l=>I.test(l),"latin")},d=new Set(["が","で","と","に","の","は","へ","も","や","を"]);if(a){const l=D(t,u,!1,e,(f,y)=>f==="hiragana"&&y==="katakana"||f==="katakana"&&y==="hiragana"||f==="hiragana"&&y==="latin"||f==="katakana"&&y==="latin"||f==="kanji"&&y==="latin"||f==="latin"&&(y==="hiragana"||y==="katakana"||y==="kanji")),h=[];for(const f of l){const y=f;y.length===1&&d.has(y)&&h.length>0?h[h.length-1]=h.at(-1)+y:h.push(y)}return h.length>0?h:[t]}return D(t,u,!1,e,(l,h)=>l==="hangul"&&h==="latin"||l==="latin"&&h==="hangul")}if(e.startsWith("sl")){const a=[...t],u=a.length,d=[];let l=a[0],h=a[0]===a[0].toLocaleUpperCase(e);for(let f=1;f<u;f++){const y=a[f],b=y===y.toLocaleUpperCase(e),w=Yi.test(y),C=f<u-1&&a[f+1]===a[f+1].toLocaleUpperCase(e);!h&&b||w&&C?(d.push(l),l=y,w&&C&&(d.push(l),l="")):l+=y,h=b}return l&&l.length>0&&d.push(l),d}if(e.startsWith("zh"))return D(t,{han:k(a=>Me.test(a),"han"),latin:k(a=>I.test(a),"latin")},!1,e);if(["ar","fa","he","ur"].includes(e.split("-")[0])){const a=k(u=>De.test(u)||Ve.test(u),"isRtlChar");return D(t,{latin:k(u=>I.test(u),"latin"),rtl:k(u=>a(u),"rtl")},!1,e)}if(["am","bn","gu","hi","km","kn","lo","ml","mr","ne","or","pa","si","ta","te","th"].includes(e.split("-")[0])){const a=k(u=>an.test(u)||rn.test(u)||sn.test(u)||ln.test(u)||cn.test(u)||un.test(u)||pn.test(u)||fn.test(u)||dn.test(u)||hn.test(u)||mn.test(u)||gn.test(u)||vn.test(u)||wn.test(u)||yn.test(u)||bn.test(u),"isIndicChar");return D(t,{indic:k(u=>a(u),"indic"),latin:k(u=>I.test(u),"latin")},!1,e)}if(["be","bg","ru","sr","uk"].includes(e))return D(t,{cyrillic:k(a=>G.test(a),"cyrillic"),latin:k(a=>I.test(a),"latin")},!0,e);if(["ar","fa","he"].includes(e))return D(t,{latin:k(a=>I.test(a),"latin"),rtl:k(a=>De.test(a)||Ve.test(a),"rtl")},!1,e);if(e.startsWith("ko"))return D(t,{hangul:k(a=>Se.test(a),"hangul"),latin:k(a=>I.test(a),"latin")},!1,e);if(e.startsWith("uz")){if(!G.test(t)&&!I.test(t))return[t];const a=[...t],u=a.length,d=[];let l=a[0],h=a[0]===a[0].toLocaleUpperCase(e);for(let f=1;f<u;f++){const y=a[f],b=y===y.toLocaleUpperCase(e);if(Be.test(y)||Be.test(a[f-1])){l+=y;continue}!h&&b?(d.push(l),l=y):l+=y,h=b}return l&&l.length>0&&d.push(l),d}const r=[...t],o=r.length,c=[];let s=r[0],g=r[0]===r[0].toLocaleUpperCase(e);for(const a of n)if(t.startsWith(a)){c.push(a),s=r[a.length],g=s===s.toLocaleUpperCase(e);break}for(let a=1;a<o;a++){const u=r[a],d=u===u.toLocaleUpperCase(e);let l=0;for(const h of n)if(t.startsWith(h,a)){c.push(s,h),l=h.length,s="";const f=h.at(-1);f&&(g=f===f.toLocaleUpperCase(e));break}if(l>0){a+=l-1;continue}!g&&d?(c.push(s),s=u):s+=u,g=d}return s&&c.push(s),c},"splitCamelCaseLocale"),Qi=k((t,e,n)=>{const i=[],r=ne.test(t)?t.split(ne).filter(Boolean):[t];for(const o of r){const c=o;if(ne.test(c))i.push(c);else{W.lastIndex=0;const s=W.test(c)?Ki(c).filter(Boolean):[c];for(const g of s)if(W.lastIndex=0,W.test(g))i.push(g);else if(e){const a=e.toLowerCase().split("-")[0];i.push(...Lt(g,a,n))}else i.push(...xt(g,n))}}return i},"processTextWithAnsiEmoji"),Xi=k((t,e={})=>{if(!t||typeof t!="string")return[];const{handleAnsi:n=!1,handleEmoji:i=!1,knownAcronyms:r=[],locale:o,normalize:c=!1,separators:s,stripAnsi:g=!1,stripEmoji:a=!1}=e,u=new Set([...r].toSorted((w,C)=>C.length-w.length));let d=t;g&&(d=Bi(d)),a&&(d=en(d));let l;Array.isArray(s)?l=Fi(s):s instanceof RegExp?l=s:l=tn;const h=[];let f=d;const y=l.flags.includes("g")?l:new RegExp(l.source,`${l.flags}g`);for(;f.length>0;){const w=y.exec(f);if(!w){f===".."?h.push(".."):f==="."?h.push("."):f.length>0&&h.push(f);break}const C=w.index,N=w[0],E=N.length,p=f.slice(0,C),m=f.slice(C+E);if(N.startsWith("../"))h.push(".."),f=f.slice(C+3);else if(N.startsWith("./"))h.push("."),f=f.slice(C+2);else if(C===0&&N==="..")h.push(".."),f=f.slice(2);else if(C===0&&N===".")h.push("."),f=f.slice(1);else{p.length>0&&h.push(p);let v=0;for(;(v=N.indexOf("../",v))!==-1;)h.push(".."),v+=3;for(v=0;(v=N.indexOf("./",v))!==-1;)(v===0||N[v-1]!==".")&&h.push("."),v+=2;let O=m;for(;O.startsWith("../");)h.push(".."),O=O.slice(3);for(;O.startsWith("./");)h.push("."),O=O.slice(2);if(O===".."){h.push("..");break}else if(O==="."){h.push(".");break}else f=O}y.lastIndex=0}if(h.length===0){const w=d.split(l).filter(Boolean);h.push(...w)}let b=[];for(const w of h)n||i?b.push(...Qi(w,o,u)):o?b.push(...Lt(w,o,u)):b.push(...xt(w,u));return c&&(b=b.map(w=>u.has(w)?w:o&&w===w.toLocaleUpperCase(o)?w[0]+w.slice(1).toLocaleLowerCase(o):w.toUpperCase()===w&&!u.has(w)?w.slice(0,1)+w.slice(1).toLowerCase():w)),b},"splitByCase");var Zi=Object.defineProperty,ea=$((t,e)=>Zi(t,"name",{value:e,configurable:!0}),"r$4"),ta=Object.defineProperty,na=ea((t,e)=>ta(t,"name",{value:e,configurable:!0}),"o"),oa=Object.defineProperty,ia=na((t,e)=>oa(t,"name",{value:e,configurable:!0}),"s");const aa=ia((t,e)=>typeof t!="string"||t===""?"":(e?.locale?t[0].toLocaleUpperCase(e.locale):t[0].toUpperCase())+t.slice(1),"upperFirst");var ra=Object.defineProperty,sa=$((t,e)=>ra(t,"name",{value:e,configurable:!0}),"r$3"),la=Object.defineProperty,ca=sa((t,e)=>la(t,"name",{value:e,configurable:!0}),"r"),ua=Object.defineProperty,pa=ca((t,e)=>ua(t,"name",{value:e,configurable:!0}),"n");const fa=pa((t,e)=>`${t}::${e?.joiner??""}::${e?.locale??""}::${e?.knownAcronyms?.join(",")??""}::${e?.normalize?"true":"false"}`,"generateCacheKey");var da=Object.defineProperty,ha=$((t,e)=>da(t,"name",{value:e,configurable:!0}),"i$3"),ma=Object.defineProperty,ga=ha((t,e)=>ma(t,"name",{value:e,configurable:!0}),"f"),va=Object.defineProperty,wa=ga((t,e)=>va(t,"name",{value:e,configurable:!0}),"l");const ya=wa((t,e)=>{const{length:n}=t;if(n===0)return"";if(n===1)return t[0];const i=[];let r="",o="";for(let c=0;c<n;c++){const s=t[c];if(ne.test(s)){r?(i.push(r+o+s),r="",o=""):(i.length>0&&i.push(e),r=s);continue}r?(o&&(o+=e),o+=s):(i.length>0&&i.push(e),i.push(s))}return i.join("")},"joinSegments");var ba=Object.defineProperty,$a=$((t,e)=>ba(t,"name",{value:e,configurable:!0}),"r$2"),Oa=Object.defineProperty,Aa=$a((t,e)=>Oa(t,"name",{value:e,configurable:!0}),"a"),Pa=Object.defineProperty,Ca=Aa((t,e)=>Pa(t,"name",{value:e,configurable:!0}),"e");const Na=/(?<![a-zß])SS(?![a-z])/g,_a=Ca(t=>t.replaceAll(Na,"ß"),"normalizeGermanEszett");var ka=Object.defineProperty,Ea=$((t,e)=>ka(t,"name",{value:e,configurable:!0}),"c$2"),xa=Object.defineProperty,La=Ea((t,e)=>xa(t,"name",{value:e,configurable:!0}),"c"),Ia=Object.defineProperty,ja=La((t,e)=>Ia(t,"name",{value:e,configurable:!0}),"o");const Ua=new Nt(1e3),It=ja((t,e)=>{if(typeof t!="string"||!t)return"";const n=e?.cache??!1,i=e?.cacheStore??Ua;let r;if(n&&(r=fa(t,e)),n&&r&&i.has(r))return i.get(r);let o=!0;const c=ya(Xi(t,{handleAnsi:e?.handleAnsi,handleEmoji:e?.handleEmoji,knownAcronyms:e?.knownAcronyms,locale:e?.locale,normalize:e?.normalize,separators:void 0,stripAnsi:e?.stripAnsi,stripEmoji:e?.stripEmoji}).map(s=>{if(e?.handleAnsi&&ne.test(s))return s;const g=e?.locale?.startsWith("de")?_a(s):s,a=e?.locale?g.toLocaleLowerCase(e.locale):g.toLowerCase();return o?(o=!1,Ui(a,e)):aa(a,e)}),"");return n&&r&&i.set(r,c),c},"camelCase");var Ta=Object.defineProperty,me=$((t,e)=>Ta(t,"name",{value:e,configurable:!0}),"a$2");const Ma=me(t=>{t.options?.forEach(e=>{e.__camelCaseName__=It(e.name)})},"processOptionNames"),Sa=me(t=>{if(!Array.isArray(t.options)||t.options.length===0)return;const e=new Set;for(const i of t.options)e.add(i.name);const n=[];for(const i of t.options)if(i.name.startsWith("no-")){const r=i.name.replace(/^no-/,"");if(!e.has(r)){if(i.type!==Boolean)throw new Error(`Cannot add negated option "${i.name}" to command "${t.name}" because it is not a boolean.`);const o={...i,defaultValue:i.defaultValue===void 0?!0:!i.defaultValue,name:r};n.push(o),e.add(r)}}n.length>0&&t.options.push(...n)},"addNegatableOptions"),Da=me((t,e)=>{if(!e.options||e.options.length===0)return;const{options:n}=t,i=new Map;for(const o of e.options)if(o.name.startsWith("no-")){const c=It(o.name);i.set(c,o)}const r=Object.keys(n).filter(o=>i.has(o));if(r.length!==0)for(const o of r){const c=o.charAt(2);if(!c)continue;const s=c.toLowerCase()+o.slice(3),g=i.get(o);g&&(g.__negated__=!0),n[s]=!n[o],Reflect.deleteProperty(n,o)}},"mapNegatableOptions"),Va=me((t,e)=>{if(!e.options||e.options.length===0)return;const n=new Map;for(const r of e.options)r.__camelCaseName__&&r.__negated__===void 0&&r.implies!==void 0&&n.set(r.__camelCaseName__,r);if(n.size===0)return;const{options:i}=t;for(const r of Object.keys(i)){const o=n.get(r);if(o?.implies){const{implies:c}=o;for(const[s,g]of Object.entries(c))i[s]===void 0&&(i[s]=g)}}},"mapImpliedOptions");var Ba=Object.defineProperty,ge=$((t,e)=>Ba(t,"name",{value:e,configurable:!0}),"e$2");const Ra=ge(()=>!!process.versions.electron,"isElectronApp"),za=ge(()=>Ra()&&!process.defaultApp,"isBundledElectronApp"),Wa=ge(()=>za()?0:1,"getProcessArgvBinIndex"),Fa=ge(t=>t.slice(Wa()+1),"hideBin");var qa=Object.defineProperty,jt=$((t,e)=>qa(t,"name",{value:e,configurable:!0}),"e$1");const Ga=" ",Ka=jt((t,e)=>t===e?!0:t.length!==e.length?!1:t.every((n,i)=>n===e[i]),"equals"),Ha=jt(t=>{if(typeof t=="string")return t.split(Ga);const e=ke();return Ka(t,e)?Fa(t):t},"parseRawCommand");var Ya=Object.defineProperty,Ce=$((t,e)=>Ya(t,"name",{value:e,configurable:!0}),"r");const Ja=Ce(t=>{const e=Ce(o=>{t.error(`Uncaught exception: ${o.message||o}`),o.stack&&t.error(o.stack),Y(1)},"uncaughtExceptionHandler"),n=Ce((o,c)=>{if(o instanceof Error)t.error(`Promise rejection: ${o.message||o}`),o.stack&&t.error(o.stack);else{let s;if(typeof o=="string")s=o;else try{s=JSON.stringify(o)}catch{s=String(o)}t.error(`Promise rejection: ${s}`)}Y(1)},"unhandledRejectionHandler"),i=Ue("uncaughtException",e),r=Ue("unhandledRejection",n);return()=>{i(),r()}},"registerExceptionHandler");var Qa=Object.defineProperty,Z=$((t,e)=>Qa(t,"name",{value:e,configurable:!0}),"e");const le=100,Ut=/^[a-z][\w-]*$/i,ce=Z((t,e)=>{if(typeof t!="string"||t.trim().length===0)throw new P(`${e} must be a non-empty string`,"INVALID_INPUT",{fieldName:e,value:t});return t.trim()},"validateNonEmptyString"),nt=Z((t,e)=>{if(!Array.isArray(t)||!t.every(n=>typeof n=="string"))throw new P(`${e} must be an array of strings`,"INVALID_INPUT",{fieldName:e,value:t});return t},"validateStringArray");Z((t,e)=>{if(typeof t!="function")throw new P(`${e} must be a function`,"INVALID_INPUT",{fieldName:e,value:t});return t},"validateFunction");const Ne=Z((t,e)=>{if(typeof t!="object"||t===null)throw new P(`${e} must be an object`,"INVALID_INPUT",{fieldName:e,value:t});return t},"validateObject"),re=Z(t=>{const e=ce(t,"Command name");if(e.length>le)throw new P(`Command name is too long (maximum ${String(le)} characters)`,"INVALID_COMMAND_NAME",{commandName:e,length:e.length});if(e.includes("..")||e.includes("/")||e.includes("\\")||e.includes(";")||e.includes("|")||e.includes("&"))throw new P(`Command name "${e}" contains invalid characters`,"INVALID_COMMAND_NAME",{commandName:e});if(!Ut.test(e))throw new P(`Command name "${e}" must start with a letter and contain only letters, numbers, hyphens, and underscores`,"INVALID_COMMAND_NAME",{commandName:e});return e},"validateCommandName");Z(t=>{const e=ce(t,"Plugin name");if(e.length>le)throw new P(`Plugin name is too long (maximum ${String(le)} characters)`,"INVALID_PLUGIN_NAME",{length:e.length,pluginName:e});if(e.includes("..")||e.includes("/")||e.includes("\\")||e.includes(";")||e.includes("|")||e.includes("&"))throw new P(`Plugin name "${e}" contains invalid characters`,"INVALID_PLUGIN_NAME",{pluginName:e});if(!Ut.test(e))throw new P(`Plugin name "${e}" must start with a letter and contain only letters, numbers, hyphens, and underscores`,"INVALID_PLUGIN_NAME",{pluginName:e});return e},"validatePluginName");var Xa=Object.defineProperty,ve=$((t,e)=>Xa(t,"name",{value:e,configurable:!0}),"s");const Za=new Set([`
|
|
4
|
-
`,"\r"," ","\0",'"',"$","&","'","(",")",";","<",">","[","\\","]","`","{","|","}"]),er=/^[A-Z]:/i,tr=ve((t,e=!0)=>{if(typeof t!="string")throw new TypeError("Argument must be a string");if(t.length>1e4)throw new Error(`Argument is too long (maximum ${String(1e4)} characters)`);if(e){for(const n of t)if(Za.has(n))throw new Error(`Argument contains dangerous character: ${n}`)}return t.trim()},"sanitizeArgument"),ot=ve((t,e=!0)=>{if(!Array.isArray(t))throw new TypeError("Arguments must be an array");if(t.length>100)throw new Error(`Too many arguments (maximum ${String(100)})`);return t.map(n=>tr(n,e))},"sanitizeArguments");ve(t=>{if(typeof t!="string")throw new TypeError("Path must be a string");const e=t.trim();if(e.split(/[/\\]/).includes(".."))throw new Error("Path contains directory traversal sequences");if(e.startsWith("/")||er.test(e))throw new Error("Absolute paths are not allowed");if(e.length>1e3)throw new Error("Path is too long");return e},"validateSafePath");class Ar{static{$(this,"RateLimiter")}static{ve(this,"RateLimiter")}attempts=new Map;maxAttempts;windowMs;constructor(e=5,n=6e4){if(e<=0||n<=0)throw new Error("maxAttempts and windowMs must be positive numbers");this.maxAttempts=e,this.windowMs=n}checkLimit(e){const n=Date.now(),i=this.attempts.get(e);return!i||n>i.resetTime?(this.attempts.set(e,{count:1,resetTime:n+this.windowMs}),this.cleanup(n),!0):i.count>=this.maxAttempts?!1:(i.count+=1,!0)}reset(e){this.attempts.delete(e)}cleanup(e){for(const[n,i]of this.attempts.entries())e>i.resetTime&&this.attempts.delete(n)}}var nr=Object.defineProperty,T=$((t,e)=>nr(t,"name",{value:e,configurable:!0}),"b");const or=/^-([^\d-])$/,ir=/^--(\S+)/,ar=/^-([^\d-]{2,})$/,_e=T(t=>or.test(t)||ir.test(t)||ar.test(t),"isOption"),rr={access:T((t,e)=>qt(t,e),"access"),mkdir:T((t,e)=>Ft(t,e),"mkdir"),readdir:T(t=>Wt(t),"readdir"),readFile:T((async(t,e)=>e===void 0?Ie(t):Ie(t,e)),"readFile"),rm:T((t,e)=>zt(t,e),"rm"),stat:T(t=>Rt(t),"stat"),writeFile:T((t,e,n)=>Bt(t,e,n),"writeFile")};class Tt{static{$(this,"Cli")}static{T(this,"Cli")}#t;#e;#c;#u;#f;#d;#y;#b;#$;#O;#A;#p;#n;#o;#i;#a;#r;#h=!1;#P;#C=!1;#m;#g;#v;#l=[];#x(){return this.#m===void 0&&(this.#m=[...this.#o.keys()]),this.#m}#N(){return this.#g===void 0&&(this.#g=[...this.#n.keys()]),this.#g}#s(){return this.#v===void 0&&(this.#v=[...this.#x(),...this.#N()]),this.#v}#_(){return this.#l.length===0?ae:[...ae,...this.#l]}#k(){this.#m=void 0,this.#g=void 0,this.#v=void 0}#w(){if(this.#c===void 0){const e=Ha(this.#e.argv);this.#c=ot(e,!1),this.#L()}return this.#c}#L(){if(!this.#c)return;const e=z();let n=!1;for(const i of this.#c){if(i==="--quiet"||i==="-q"){e.CEREBRO_OUTPUT_LEVEL=String(Gt),n=!0;break}if(i==="--verbose"||i==="-v"){e.CEREBRO_OUTPUT_LEVEL=String(Kt),n=!0;break}if(i==="--debug"){e.CEREBRO_OUTPUT_LEVEL=String(H),n=!0;break}}n||(e.CEREBRO_OUTPUT_LEVEL=Object.hasOwn(e,"DEBUG")?String(H):String(je))}#I(){this.#C||(this.#P=Ja(this.#t),this.#C=!0)}#j(){return{arch:Yt(),argv:this.#w(),cwd:this.#u,env:this.#O??z(),exit:this.#$??(e=>Y(e??0)),platform:Ht(),stdin:this.#A}}#E(e,n,i,r){this.#t.debug(`command '${r}' found, parsing command args: ${n.join(", ")}`);const{arguments_:o,booleanValues:c,parsedArgs:s}=ci(e,n,this.#_()),g=Object.keys(c).length>0;let a=s;g&&(a={...s,_all:{...s._all,...c}}),yi(o,a,e);const u=li(e,s,c,i);u.runtime=this,u.argv=this.#w(),u.fs=this.#b??rr,u.process=this.#j(),u.console=this.#t;const d=e.options&&e.options.length>0;if(d&&e.options){const l=e.options.filter(h=>h.name.startsWith("no-"));for(const h of l){const f=h.name.replace(/^no-/,""),y=`--${h.name}`,b=`--${f}`,w=n.includes(y),C=n.includes(b);if(w&&C)throw new at(f,h.name)}}return d&&(Da(u,e),Va(u,e)),bi(o,u.options,e),z().CEREBRO_OUTPUT_LEVEL===String(H)&&(this.#t.debug("command options parsed from options:"),this.#t.debug(JSON.stringify(u.options,null,2)),this.#t.debug("command argument parsed from argument:"),this.#t.debug(JSON.stringify(u.argument,null,2))),{arguments_:o,booleanValues:c,commandArgs:a,parsedArgs:s,toolbox:u}}constructor(e,n={}){if(typeof e!="string"||e.trim().length===0)throw new P("CLI name must be a non-empty string","INVALID_INPUT",{cliName:e});this.#f=e.trim();const i=n.argv??ke(),r=n.cwd??Jt();if(this.#e={...n,argv:i,cwd:r},this.#e.argv&&!Array.isArray(this.#e.argv))throw new P("CLI argv option must be an array of strings","INVALID_INPUT",{argv:this.#e.argv});if(this.#e.cwd&&typeof this.#e.cwd!="string")throw new P("CLI cwd option must be a string","INVALID_INPUT",{cwd:this.#e.cwd});if(this.#e.packageName&&typeof this.#e.packageName!="string")throw new P("CLI packageName option must be a string","INVALID_INPUT",{packageName:this.#e.packageName});if(this.#e.packageVersion&&typeof this.#e.packageVersion!="string")throw new P("CLI packageVersion option must be a string","INVALID_INPUT",{packageVersion:this.#e.packageVersion});const o=z();if(o.CEREBRO_OUTPUT_LEVEL=String(je),typeof this.#e.logger=="object"){const u=["debug","error","info","log","warn"],d=[],l=this.#e.logger;for(const h of u)typeof l[h]!="function"&&d.push(h);if(d.length>0)throw new P(`Logger object is missing required methods: ${d.join(", ")}`,"INVALID_INPUT",{logger:this.#e.logger,missingMethods:d});this.#t=this.#e.logger}else this.#t={...console,debug:T((...u)=>{o.CEREBRO_OUTPUT_LEVEL===String(H)&&console.debug(...u)},"debug")};this.#d=this.#e.packageVersion,this.#y=this.#e.packageName,this.#u=this.#e.cwd,this.#a="help",this.#r={};const c=n.fs;if(c!==void 0&&(typeof c!="object"||c===null))throw new P("CLI fs option must be an object implementing the CerebroFs interface","INVALID_INPUT",{fs:n.fs});const s=n.exit;if(s!==void 0&&typeof s!="function")throw new P("CLI exit option must be a function","INVALID_INPUT",{exit:n.exit});const g=n.env;if(g!==void 0&&(typeof g!="object"||g===null))throw new P("CLI env option must be a record of string keys","INVALID_INPUT",{env:n.env});const a=n.stdin;if(a!==void 0&&typeof a!="string")throw new P("CLI stdin option must be a string","INVALID_INPUT",{stdin:n.stdin});this.#b=n.fs,this.#$=n.exit,this.#O=n.env,this.#A=n.stdin??"",this.#n=new Map,this.#o=new Map,this.#i=new Map}setCommandSection(e){return this.#r=e,this}getCommandSection(){return this.#r.header||(this.#r.header=`${this.#f}${this.#d?` v${this.#d}`:""}`),this.#r}setDefaultCommand(e){return this.#a=e,this}get defaultCommand(){return this.#a}addCommand(e){Ne(e,"Command"),re(e.name);const n=typeof e.execute=="function",i=typeof e.loader=="function";if(n&&i)throw new P(`Command "${e.name}" cannot define both "execute" and "loader" — choose one`,"INVALID_COMMAND",{commandName:e.name});if(!n&&!i)throw new P(`Command "${e.name}" must define either "execute" or "loader"`,"INVALID_COMMAND",{commandName:e.name});e.alias&&(typeof e.alias=="string"?re(e.alias):nt(e.alias,"Command alias").forEach(a=>re(a))),e.argument&&Ne(e.argument,"Command argument"),e.options&&Ne(e.options,"Command options"),e.commandPath&&(nt(e.commandPath,"Command commandPath"),e.commandPath.forEach(a=>{re(a)}));const r=et(e.name,e.commandPath),o=B(r);if(this.#o.has(o))throw new P(`Command with path "${o}" already exists`,"DUPLICATE_COMMAND",{commandName:e.name,commandPath:e.commandPath});const c=Array.isArray(e.commandPath)&&e.commandPath.length>0,s=this.#n.get(e.name),g=s!==void 0&&(s.commandPath===void 0||s.commandPath.length===0);if(!c&&g)throw new P(`Command with name "${e.name}" already exists`,"DUPLICATE_COMMAND",{commandName:e.name});if(e.options)for(const a of e.options)ze(a);if($i(e),Sa(e),Ma(e),e.options&&(e.__conflictingOptions__=e.options.filter(a=>a.conflicts!==void 0),e.__requiredOptions__=e.options.filter(a=>a.required===!0)),c&&s!==void 0)this.#n.set(o,e);else{if(!c&&s!==void 0&&!g){const a=et(s.name,s.commandPath);this.#n.set(B(a),s)}this.#n.set(e.name,e)}if(this.#o.set(o,r),this.#i.set(o,e),this.#k(),e.alias!==void 0){const a=typeof e.alias=="string"?[e.alias]:e.alias;for(const u of a){if(z().CEREBRO_OUTPUT_LEVEL===String(H)&&this.#t.debug("adding alias",u),this.#n.has(u))throw new P(`Command alias "${u}" conflicts with existing command`,"DUPLICATE_COMMAND",{alias:u,commandName:e.name});this.#n.set(u,e)}}return this}addGlobalOption(e){const n=e,i=new Set(ae.map(o=>o.name)),r=new Set(ae.map(o=>o.alias).filter(Boolean));if(i.has(n.name))throw new P(`Cannot add global option "--${n.name}": it conflicts with a built-in global option`,"DUPLICATE_OPTION",{optionName:n.name});if(n.alias&&r.has(n.alias))throw new P(`Cannot add global option with alias "-${n.alias}": it conflicts with a built-in global option alias`,"DUPLICATE_OPTION",{alias:n.alias,optionName:n.name});if(new Set(this.#l.map(o=>o.name)).has(n.name))throw new P(`Global option "--${n.name}" has already been added`,"DUPLICATE_OPTION",{optionName:n.name});return n.group="global",ze(n),this.#l.push(n),this}getGlobalOptions(){return this.#_()}addPlugin(e){return this.getPluginManager().register(e),this}getPluginManager(){return this.#p?this.#p:(this.#p=new xn(this.#t),this.#p.register({description:"Attaches the logger to the toolbox",execute:T(e=>{e.logger=this.#t,e.console=e.logger},"execute"),name:"logger"}),this.#p)}getCliName(){return this.#f}getPackageVersion(){return this.#d}getPackageName(){return this.#y}getCommands(){return this.#n}getCwd(){return this.#u}dispose(){this.#P?.()}async run(e={}){const{autoDispose:n=!0,shouldExitProcess:i=!0,...r}=e;if(!this.#n.has("help")){const{default:p}=await import("../commands/help-command.js");this.addCommand(new p(this.#n))}const o=this.#N(),c=this.#o;this.#I();const s=this.#w();let g,a=[...s];const u=Qt(),d=Xt(),l=ke();this.#t.debug(`process.execPath: ${u}`),this.#t.debug(`process.execArgv: ${d.join(" ")}`),this.#t.debug(`process.argv: ${l.join(" ")}`);const h=Ai(c,[...s]);if(h.commandPath)g=h.commandPath,a=h.argv;else{if(s.length>1&&s[0]&&s[1]&&!_e(s[0])&&!_e(s[1])){const m=[];let v=0;for(;v<s.length;){const A=s[v];if(!A||_e(A))break;m.push(A),v+=1}const O=B(m);if(m[0]&&!o.includes(m[0])){const A=this.#s(),U=R(O,A);throw new V(O,U)}}let p;try{p=Bn([null,...o],[...s])}catch(m){if(m instanceof Error&&m.name==="INVALID_COMMAND"&&"command"in m){const v=m.command,O=this.#s(),A=R(v,O);throw new V(v,A)}throw m}p.command&&(g=[p.command],a=p.argv)}if(!g)if(this.#a)g=[this.#a];else{const p=this.#s();throw new V("",p)}const f=B(g),y=this.#o.get(f);let b;if(y){if(b=this.#i.get(f),!b||B(y)!==f){const p=this.#s(),m=R(f,p);throw new V(f,m)}}else{const p=g.at(-1);if(b=p?this.#n.get(p):void 0,!b){const m=this.#s(),v=R(f,m);throw new V(f,v)}}if(typeof b.execute!="function"&&typeof b.loader!="function")return this.#t.error(`Command "${b.name}" has no function to execute.`),i?Y(1):void 0;const w=a;let C,N;try{({commandArgs:C,toolbox:N}=this.#E(b,w,r,f))}catch(p){if(this.#t.error(p),i)return Y(1);throw p}const E=this.getPluginManager();try{!this.#h&&E.hasPlugins()&&(await E.init({cli:this,cwd:this.#u,logger:this.#t}),this.#h=!0),await E.executeLifecycle("execute",N),await E.executeLifecycle("beforeCommand",N);let p;const m=C.global;if(m?.help){const v=this.#n.get("help");if(!v)throw new P("Help command not found","COMMAND_NOT_FOUND");p=await K(v,N,C)}else if(m?.version??m?.V){const v=this.#n.get("version");if(!v)throw new P("Version command not found","COMMAND_NOT_FOUND");p=await K(v,N,C)}else p=await K(b,N,C);return await E.executeLifecycle("afterCommand",N,p),i?Y(0):void 0}catch(p){throw await E.executeErrorHandlers(p,N),p}finally{n&&this.dispose()}}async runCommand(e,n={}){const{argv:i=[],...r}=n;ce(e,"Command name");const o=e.split(" ").filter(Boolean),c=B(o),s=this.#o.get(c)?this.#i.get(c):this.#n.get(e);if(!s){const l=this.#s(),h=R(c||e,l);throw new V(e,h)}if(typeof s.execute!="function"&&typeof s.loader!="function")throw new P(`Command "${s.name}" has no function to execute`,"INVALID_COMMAND",{commandName:s.name});const g=[...ot(i,!1)];this.#t.debug(`running command '${e}' programmatically with args: ${g.join(", ")}`);const{commandArgs:a,toolbox:u}=this.#E(s,g,r,c||e),d=this.getPluginManager();try{!this.#h&&d.hasPlugins()&&(await d.init({cli:this,cwd:this.#u,logger:this.#t}),this.#h=!0),await d.executeLifecycle("execute",u),await d.executeLifecycle("beforeCommand",u);let l;const h=a.global;if(h?.help){const f=this.#n.get("help");if(!f)throw new P("Help command not found","COMMAND_NOT_FOUND");l=await K(f,u,a)}else if(h?.version??h?.V){const f=this.#n.get("version");if(!f)throw new P("Version command not found","COMMAND_NOT_FOUND");l=await K(f,u,a)}else l=await K(s,u,a);return await d.executeLifecycle("afterCommand",u,l),l}catch(l){throw await d.executeErrorHandlers(l,u),l}}clone(e){const n={...this.#e,...e},i=new Tt(this.#f,n);for(const[r,o]of this.#n)i.#n.set(r,o);for(const[r,o]of this.#o)i.#o.set(r,[...o]);for(const[r,o]of this.#i)i.#i.set(r,o);for(const r of this.#l)i.#l.push(r);return i.#a=this.#a,i.#r={...this.#r},i.#k(),i}async getAction(e){ce(e,"Command name");const n=e.split(" ").filter(Boolean),i=B(n),r=this.#o.get(i)?this.#i.get(i):this.#n.get(e);if(!r){const o=this.#s(),c=R(i||e,o);throw new V(e,c)}if(typeof r.execute=="function")return r.execute;if(typeof r.loader=="function")return Ot(r);throw new P(`Command "${r.name}" has no execute or loader defined`,"INVALID_COMMAND",{commandName:r.name})}}export{Tt as Cli};
|