@visulima/vis 1.0.0-alpha.40 → 1.0.0-alpha.41
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 +27 -0
- package/dist/bin.js +1 -1
- package/dist/binx.js +2 -2
- package/dist/config/index.d.ts +18 -0
- package/dist/packem_chunks/bin.js +202 -202
- package/dist/packem_chunks/handler10.js +1 -1
- package/dist/packem_chunks/handler12.js +1 -1
- package/dist/packem_chunks/handler13.js +1 -1
- package/dist/packem_chunks/handler14.js +1 -1
- package/dist/packem_chunks/handler15.js +1 -1
- package/dist/packem_chunks/handler16.js +1 -1
- package/dist/packem_chunks/handler17.js +1 -1
- package/dist/packem_chunks/handler18.js +1 -1
- package/dist/packem_chunks/handler19.js +1 -1
- package/dist/packem_chunks/handler21.js +1 -1
- package/dist/packem_chunks/handler27.js +1 -1
- package/dist/packem_chunks/handler28.js +1 -1
- package/dist/packem_chunks/handler29.js +1 -1
- package/dist/packem_chunks/handler30.js +1 -2
- package/dist/packem_chunks/handler31.js +2 -2
- package/dist/packem_chunks/handler32.js +2 -2
- package/dist/packem_chunks/handler33.js +2 -3
- package/dist/packem_chunks/handler34.js +3 -6
- package/dist/packem_chunks/handler35.js +6 -1
- package/dist/packem_chunks/handler36.js +1 -42
- package/dist/packem_chunks/handler37.js +42 -8
- package/dist/packem_chunks/handler38.js +8 -9
- package/dist/packem_chunks/handler39.js +9 -75
- package/dist/packem_chunks/handler4.js +1 -1
- package/dist/packem_chunks/handler40.js +75 -5
- package/dist/packem_chunks/handler41.js +5 -4
- package/dist/packem_chunks/handler42.js +4 -3
- package/dist/packem_chunks/handler43.js +3 -2
- package/dist/packem_chunks/handler44.js +2 -1
- package/dist/packem_chunks/handler45.js +1 -1
- package/dist/packem_chunks/handler46.js +1 -1
- package/dist/packem_chunks/handler47.js +1 -3
- package/dist/packem_chunks/handler48.js +3 -1
- package/dist/packem_chunks/handler49.js +1 -7
- package/dist/packem_chunks/handler5.js +1 -1
- package/dist/packem_chunks/handler50.js +6 -32
- package/dist/packem_chunks/handler51.js +33 -3
- package/dist/packem_chunks/handler52.js +3 -8
- package/dist/packem_chunks/handler53.js +6 -2
- package/dist/packem_chunks/handler54.js +4 -1
- package/dist/packem_chunks/handler55.js +1 -12
- package/dist/packem_chunks/handler56.js +11 -6
- package/dist/packem_chunks/handler57.js +7 -5
- package/dist/packem_chunks/handler58.js +5 -11
- package/dist/packem_chunks/handler59.js +11 -3
- package/dist/packem_chunks/handler60.js +3 -22
- package/dist/packem_chunks/handler61.js +21 -60
- package/dist/packem_chunks/handler62.js +61 -3
- package/dist/packem_chunks/handler63.js +3 -6
- package/dist/packem_chunks/handler64.js +6 -708
- package/dist/packem_chunks/handler65.js +708 -24
- package/dist/packem_chunks/handler66.js +24 -25
- package/dist/packem_chunks/handler67.js +25 -153
- package/dist/packem_chunks/handler68.js +153 -10
- package/dist/packem_chunks/handler69.js +10 -24
- package/dist/packem_chunks/handler70.js +24 -322
- package/dist/packem_chunks/handler71.js +322 -48
- package/dist/packem_chunks/handler72.js +48 -27
- package/dist/packem_chunks/handler73.js +27 -3
- package/dist/packem_chunks/handler74.js +3 -190
- package/dist/packem_chunks/handler75.js +189 -37
- package/dist/packem_chunks/handler76.js +38 -0
- package/dist/packem_chunks/handler8.js +1 -1
- package/dist/packem_chunks/handler9.js +1 -1
- package/dist/packem_chunks/heal-accept.js +1 -1
- package/dist/packem_chunks/help-command.js +1 -1
- package/dist/packem_chunks/list.js +1 -1
- package/dist/packem_chunks/loader.js +1 -1
- package/dist/packem_chunks/orchestrator.js +1 -1
- package/dist/packem_chunks/sync2.js +1 -1
- package/dist/packem_chunks/tripwire.js +1 -1
- package/dist/packem_chunks/verify-lockfile.js +1 -1
- package/dist/packem_chunks/version-resolver.js +1 -1
- package/dist/packem_shared/command-runtime-CR70qSUM.js +1 -0
- package/dist/packem_shared/{cyclonedx-kYozDyxp.js → cyclonedx-Cadls41z.js} +1 -1
- package/dist/packem_shared/{index-Du8RWawQ.js → index-3jMNqQom.js} +1 -1
- package/dist/packem_shared/index-Bt521H5J.js +30 -0
- package/dist/packem_shared/{index-CgcF6_wo.js → index-DGSsjmpV.js} +1 -1
- package/dist/packem_shared/{pm-runner-OGResYrA.js → pm-runner-BKZQo7Ts.js} +1 -1
- package/dist/packem_shared/{provenance-_CJjMKwu.js → provenance-BFEwKgI3.js} +1 -1
- package/dist/packem_shared/{resolve-explicit-CMDl55Nz.js → resolve-explicit-C6WM-I2u.js} +1 -1
- package/dist/packem_shared/{s1ngularity-Dhr3bPk0.js → s1ngularity-DCPmPE5M.js} +1 -1
- package/dist/packem_shared/{signatures-C730vkyK.js → signatures-Xpd6HjG_.js} +1 -1
- package/index.d.ts +201 -201
- package/index.js +26 -26
- package/package.json +13 -13
- package/schemas/vis-config.schema.json +12 -0
- package/dist/packem_shared/index-yBikBkHT.js +0 -30
|
@@ -1 +1 @@
|
|
|
1
|
-
import{I as t,x as
|
|
1
|
+
import{I as t,x as l}from"../packem_shared/pm-runner-BKZQo7Ts.js";import{r as p,a as m}from"../packem_shared/command-runtime-CR70qSUM.js";const g=async({logger:n,options:a,visConfig:o,workspaceRoot:c})=>{const s=c??process.cwd(),i=p({logger:n,options:a,visConfig:o},s),r=t(s,{backend:m(i),configBackend:o?.install?.backend,configCorepack:o?.install?.corepack}),e=l(r,a.check||!1,s,n);e!==0&&(process.exitCode=e)};export{g as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{I as
|
|
1
|
+
import{I as k,$ as d}from"../packem_shared/pm-runner-BKZQo7Ts.js";import{r as m,a as u}from"../packem_shared/command-runtime-CR70qSUM.js";const h=async({argument:c,logger:n,options:a,visConfig:e,workspaceRoot:r})=>{const o=c;if(!o||o.length===0)throw new Error("No package specified. Usage: vis dlx <package[@version]> [args...]");const[l,...t]=o,s=r??process.cwd(),g=m({logger:n,options:a,visConfig:e},s),p=k(s,{backend:u(g),configBackend:e?.install?.backend,configCorepack:e?.install?.corepack}),f=a.package?Array.isArray(a.package)?a.package:[a.package]:[],i=d(p,{additionalPackages:f,args:t,package:l,shellMode:a.shellMode||!1,silent:a.silent||!1},s,n,{offline:a.offline||!1});i!==0&&(process.exitCode=i)};export{h as default};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{createRequire as G}from"node:module";import{B as y,y as N}from"../packem_shared/index-BDmTbWX1.js";import{d as O,k as U,P as H,R as F,p as P}from"./heal.js";import{w as D,M as S}from"../packem_shared/pm-runner-
|
|
1
|
+
import{createRequire as G}from"node:module";import{B as y,y as N}from"../packem_shared/index-BDmTbWX1.js";import{d as O,k as U,P as H,R as F,p as P}from"./heal.js";import{w as D,M as S}from"../packem_shared/pm-runner-BKZQo7Ts.js";import{p as a}from"./bin.js";const L=G(import.meta.url),_=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,x=e=>{if(typeof _<"u"&&_.versions&&_.versions.node){const[t,o]=_.versions.node.split(".").map(Number);if(t>22||t===22&&o>=3||t===20&&o>=16)return _.getBuiltinModule(e)}return L(e)},{readFile:$}=x("node:fs/promises"),{createInterface:K}=x("node:readline"),j=()=>!!process.stdout.isTTY&&process.env.CI!=="true",V=e=>new Promise(t=>{const o=K({input:process.stdin,output:process.stderr});o.question(`${e} (Y/n) `,i=>{o.close();const s=i.trim().toLowerCase();t(s===""||s==="y"||s==="yes")})}),M=(e,t)=>{const o=D(t),i=S(o,{exact:!1,filter:[],global:!1,optional:!1,packages:[e],peer:!1,saveDev:!1,workspace:!1,workspaceRoot:!1},t,console);return Promise.resolve({exitCode:i})},R=e=>`pnpm add ${e}`,q=e=>e==="@gitbeaker/rest"?import("@gitbeaker/rest"):import("@octokit/rest"),B=async(e,t={})=>{const o=t.interactive??j(),i=t.prompt??V,s=t.runInstall??M,l=t.importImpl??q,d=t.workspaceRoot??process.cwd();try{return await l(e)}catch(n){const{code:p}=n;if(p!=="ERR_MODULE_NOT_FOUND"&&p!=="MODULE_NOT_FOUND")throw n}if(!o)throw new Error(`${e} is not installed. \`vis ai heal accept\` needs it to talk to the host. Install it in your repo first:
|
|
2
2
|
${R(e)}`);if(!await i(`${e} isn't installed. Install it now?`))throw new Error(`${e} install declined. Re-run \`vis ai heal accept\` after installing manually:
|
|
3
3
|
${R(e)}`);const r=await s(e,d);if(r.exitCode!==0)throw new Error(`Install of ${e} failed (exit ${String(r.exitCode)}). Install manually and retry:
|
|
4
4
|
${R(e)}`);return await l(e)},Y=e=>{const t=e.indexOf("/");if(t<=0||t===e.length-1)throw new Error(`Expected GITHUB_REPOSITORY in "owner/repo" form, got: ${e}`);return{owner:e.slice(0,t),repo:e.slice(t+1)}},J=async(e,t)=>{if(t.githubClient)return t.githubClient;const o=(await(t.loadSdk??B)("@octokit/rest")).Octokit;if(!o)throw new TypeError("Loaded `@octokit/rest` but no `Octokit` export was found. Reinstall the package or pin to a supported major.");return new o({auth:e})},W=async(e,t,o)=>{if(o.gitlabClient)return o.gitlabClient;const i=(await(o.loadSdk??B)("@gitbeaker/rest")).Gitlab;if(!i)throw new TypeError("Loaded `@gitbeaker/rest` but no `Gitlab` export was found. Reinstall the package or pin to a supported major.");return new i({host:t,token:e})},z=e=>e.replace(/\/api\/v\d+\/?$/,""),X=async e=>{const{branch:t,ciContext:o,files:i,message:s,workspaceRoot:l}=e,d=e.readFile??(w=>$(w,"utf8"));if(!o.repo)throw new Error("Cannot commit on GitHub: GITHUB_REPOSITORY (owner/repo) is not set.");if(!o.token)throw new Error("Cannot commit on GitHub: GITHUB_TOKEN is not set. Grant the workflow `contents: write` and pass the token through.");const{owner:r,repo:n}=Y(o.repo),p=await J(o.token,e),u=(await p.rest.git.getRef({owner:r,ref:`heads/${t}`,repo:n})).data.object.sha,h=(await p.rest.git.getCommit({commit_sha:u,owner:r,repo:n})).data.tree.sha,m=await Promise.all(i.map(async w=>{const C=y(l,w),k=await d(C),b=await p.rest.git.createBlob({content:Buffer.from(k,"utf8").toString("base64"),encoding:"base64",owner:r,repo:n});return{mode:"100644",path:w,sha:b.data.sha,type:"blob"}})),f=await p.rest.git.createTree({base_tree:h,owner:r,repo:n,tree:m}),g=await p.rest.git.createCommit({message:s,owner:r,parents:[u],repo:n,tree:f.data.sha});return await p.rest.git.updateRef({owner:r,ref:`heads/${t}`,repo:n,sha:g.data.sha}),{sha:g.data.sha,url:g.data.html_url}},Q=async e=>{const{branch:t,ciContext:o,files:i,message:s,workspaceRoot:l}=e,d=e.readFile??(m=>$(m,"utf8"));if(!o.repo)throw new Error("Cannot commit on GitLab: CI_PROJECT_ID / CI_PROJECT_PATH is not set.");if(!o.token)throw new Error("Cannot commit on GitLab: no token. CI_JOB_TOKEN cannot push commits — set GITLAB_TOKEN to a PAT/project-token with `api` scope.");if(!o.apiBaseUrl)throw new Error("Cannot commit on GitLab: CI_API_V4_URL is not set.");const r=z(o.apiBaseUrl),n=await W(o.token,r,e),p=await Promise.all(i.map(async m=>{const f=y(l,m);return{action:"update",content:await d(f),filePath:m}})),u=await n.Commits.create(o.repo,t,s,p),h=u.id??u.sha;if(!h)throw new Error("GitLab Commits.create returned no commit ID — cannot reference the new commit.");return{sha:h,url:u.web_url??u.webUrl}},Z=async e=>{if(e.files.length===0)throw new Error("Cannot commit: no files to include.");if(e.ciContext.provider==="github-actions")return await X(e);if(e.ciContext.provider==="gitlab-ci")return await Q(e);throw new Error(`Cannot commit: unsupported CI provider \`${e.ciContext.provider}\`. Run \`vis ai heal accept\` from a recognised CI environment.`)},v="/vis heal accept",ee=async e=>{if(!e)return;let t;try{t=await $(e,"utf8")}catch{return}const o=JSON.parse(t),i=o.comment?.body??"",s=o.comment?.user?.login??"",l=o.pull_request?.head?.repo?.full_name,d=o.pull_request?.base?.repo?.full_name??o.repository?.full_name,r=l!==void 0&&d!==void 0&&l!==d;return{actor:s,body:i,headRef:o.pull_request?.head?.ref,isFork:r}},te=e=>{const t=e.VIS_HEAL_TRIGGER_BODY,o=e.VIS_HEAL_TRIGGER_ACTOR;if(!(!t||!o))return{actor:o,body:t,headRef:e.VIS_HEAL_HEAD_REF,isFork:!1}},oe=e=>{const t=e.BUILDKITE_UNBLOCKER_EMAIL??e.BUILDKITE_UNBLOCKER;if(t)return{actor:t,body:v,headRef:e.BUILDKITE_BRANCH,isFork:!1}},re=async(e,t)=>{if(e.provider==="github-actions")return await ee(t.GITHUB_EVENT_PATH);if(e.provider==="gitlab-ci")return te(t);if(e.provider==="buildkite")return oe(t)},ie=(e,t)=>{const o=t.BUILDKITE_REPO;if(!o)return;const i=/(?:^|@|\/\/)github\.com[:/]([^/]+)\/([^/]+?)(?:\.git)?\/?$/i.exec(o);if(i&&t.GITHUB_TOKEN)return{apiBaseUrl:void 0,buildId:void 0,buildNumber:void 0,prNumber:e.prNumber,provider:"github-actions",repo:`${i[1]}/${i[2]}`,sha:e.sha,token:t.GITHUB_TOKEN};const s=/\/\/([^/]*gitlab[^/]*)\/([^/]+)\/(.+?)(?:\.git)?\/?$/i.exec(o),l=s?null:/@([^/:]*gitlab[^/:]*):([^/]+)\/(.+?)(?:\.git)?\/?$/i.exec(o),d=s??l;if(d&&t.GITLAB_TOKEN){const r=d[1];return{apiBaseUrl:t.CI_API_V4_URL??`https://${r}/api/v4`,buildId:void 0,buildNumber:void 0,prNumber:e.prNumber,provider:"gitlab-ci",repo:`${d[2]}/${d[3]}`,sha:e.sha,token:t.GITLAB_TOKEN}}},ae=async e=>{const t=e.fetchImpl??globalThis.fetch,o=`${(e.apiBaseUrl??"https://api.github.com").replace(/\/+$/,"")}/repos/${e.repo}/pulls/${String(e.prNumber)}`;try{const i=await t(o,{headers:{Accept:"application/vnd.github+json",Authorization:`Bearer ${e.token}`,"X-GitHub-Api-Version":"2022-11-28"}});return i.ok?(await i.json()).head?.ref:void 0}catch{return}},ne=(e,t,o,i)=>{const s=t.map(l=>`- \`${l}\``).join(`
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{createRequire as nt}from"node:module";import{U as gt,$ as dt,N as Ke,j as tt,r as Oe,O as U,q as oe,I as mi,s as Ie}from"../packem_shared/Table-CcVkyULl-B_ef6zfS.js";import{t as st,o as pe,p as We,L as Jo,b as ht,s as lt,i as vt,n as yt,d as ct,r as bt}from"../packem_shared/index-
|
|
1
|
+
import{createRequire as nt}from"node:module";import{U as gt,$ as dt,N as Ke,j as tt,r as Oe,O as U,q as oe,I as mi,s as Ie}from"../packem_shared/Table-CcVkyULl-B_ef6zfS.js";import{t as st,o as pe,p as We,L as Jo,b as ht,s as lt,i as vt,n as yt,d as ct,r as bt}from"../packem_shared/index-Bt521H5J.js";const at=nt(import.meta.url),be=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,ut=i=>{if(typeof be<"u"&&be.versions&&be.versions.node){const[e,o]=be.versions.node.split(".").map(Number);if(e>22||e===22&&o>=3||e===20&&o>=16)return be.getBuiltinModule(i)}return at(i)},{createRequire:rt}=ut("node:module"),pt=/^#?([a-f\d]{3}|[a-f\d]{6})$/i,Fo=i=>{let[,e]=pt.exec(i)??[];const o=e?e.length:0;if(o===3){const a=e.charAt(0),u=e.charAt(1),g=e.charAt(2);e=a+a+u+u+g+g}else if(o!==6)return globalThis.process?.env?.NODE_ENV!=="production"&&console.warn(`[@visulima/colorize] Invalid hex color "${i}"; expected a 3- or 6-digit hex string (e.g. "#96C" or "#E0115F"). Falling back to black.`),[0,0,0];const n=Number.parseInt(e,16);return[n>>16&255,n>>8&255,n&255]},ku=(i,e,o)=>i===e&&e===o?i<8?16:i>248?231:Math.round((i-8)/247*24)+232:16+36*Math.round(i/51)+6*Math.round(e/51)+Math.round(o/51),Ko=i=>{let e,o,n;if(i<8)return 30+i;if(i<16)return 90+(i-8);if(i>=232)e=o=n=((i-232)*10+8)/255;else{i-=16;const g=i%36;e=Math.floor(i/36)/5,o=Math.floor(g/6)/5,n=g%6/5}const a=Math.max(e,o,n)*2;if(a===0)return 30;const u=30+(Math.round(n)<<2|Math.round(o)<<1|Math.round(e));return a===2?u+60:u},na=(i,e,o)=>Ko(ku(i,e,o));function wt({onlyFirst:i=!1}={}){const e="(?:\\u001B\\][\\s\\S]*?(?:\\u0007|\\u001B\\u005C|\\u009C))|[\\u001B\\u009B][[\\]()#;?]*(?:\\d{1,4}(?:[;:]\\d{0,4})*)?[\\dA-PR-TZcf-nq-uy=><~]";return new RegExp(e,i?void 0:"g")}const Mi=(i,e,o)=>e>i?e:Math.min(i,o),N=39,W=49,aa=10,ua={close:"",open:""},Lu=i=>{const e=i>0?(h,v)=>({close:`\x1B[${String(v)}m`,open:`\x1B[${String(h)}m`}):()=>ua,o=h=>(v,y,c)=>h(ku(Number(v),Number(y),Number(c))),n=h=>v=>{const[y,c,b]=Fo(v);return h(y,c,b)};let a=h=>e(`38;5;${String(h)}`,N),u=h=>e(`48;5;${String(h)}`,W),g=(h,v,y)=>e(`38;2;${String(h)};${String(v)};${String(y)}`,N),d=(h,v,y)=>e(`48;2;${String(h)};${String(v)};${String(y)}`,W);i===1?(a=h=>e(Ko(Number(h)),N),u=h=>e(Ko(Number(h))+aa,W),g=(h,v,y)=>e(na(Number(h),Number(v),Number(y)),N),d=(h,v,y)=>e(na(Number(h),Number(v),Number(y))+aa,W)):i===2&&(g=o(a),d=o(u));const r={bold:e(1,22),dim:e(2,22),hidden:e(8,28),inverse:e(7,27),italic:e(3,23),overline:e(53,55),reset:e(0,0),strike:e(9,29),strikethrough:e(9,29),underline:e(4,24),visible:ua},s={bgBlack:e(40,W),bgBlackBright:e(100,W),bgBlue:e(44,W),bgBlueBright:e(104,W),bgCyan:e(46,W),bgCyanBright:e(106,W),bgGray:e(100,W),bgGreen:e(42,W),bgGreenBright:e(102,W),bgGrey:e(100,W),bgMagenta:e(45,W),bgMagentaBright:e(105,W),bgRed:e(41,W),bgRedBright:e(101,W),bgWhite:e(47,W),bgWhiteBright:e(107,W),bgYellow:e(43,W),bgYellowBright:e(103,W),black:e(30,N),blackBright:e(90,N),blue:e(34,N),blueBright:e(94,N),cyan:e(36,N),cyanBright:e(96,N),gray:e(90,N),green:e(32,N),greenBright:e(92,N),grey:e(90,N),magenta:e(35,N),magentaBright:e(95,N),red:e(31,N),redBright:e(91,N),white:e(37,N),whiteBright:e(97,N),yellow:e(33,N),yellowBright:e(93,N)},l={bg:h=>u(Mi(h,0,255)),bgHex:n(d),bgRgb:(h,v,y)=>d(Mi(h,0,255),Mi(v,0,255),Mi(y,0,255)),fg:h=>a(Mi(h,0,255)),hex:n(g),rgb:(h,v,y)=>g(Mi(h,0,255),Mi(v,0,255),Mi(y,0,255))};return{baseColors:s,baseStyles:r,styleMethods:l}},Zu=gt();dt();Lu(Zu);const jt=(i,e,o)=>{if(e==="")return i;let n=i.indexOf(e);if(n<0)return i;const a=e.length;let u=0,g="";for(;~n;)g+=i.slice(u,n)+o,u=n+a,n=i.indexOf(e,u);return g+i.slice(u)},mt=(i,e,o)=>{if(!i)return"";let n;if(i.raw===void 0?n=String(i):n=String.raw(i,...e),n.includes("\x1B"))for(let a=o;a;a=a.props)n=jt(n,a.close,a.open);return n.includes(`
|
|
2
2
|
`)&&(n=n.replace(/(\r*\n)/g,`${o.closeStack}$1${o.openStack}`)),o.openStack+n+o.closeStack},ft=function(i){const e=i?.level??Zu,{baseColors:o,baseStyles:n,styleMethods:a}=Lu(e),u={};let g=null;const d=({props:s},{close:l,open:h})=>{const v=(s?.openStack??"")+h,y=l+(s?.closeStack??""),c=(b,...p)=>mt(b,p,c.props);return Object.setPrototypeOf(c,g),c.props={close:l,closeStack:y,open:h,openStack:v,props:s},c.open=v,c.close=y,c},r=s=>String(s);r.strip=s=>s.replaceAll(wt(),"");for(const s in o)u[s]={get(){const l=d(this,o[s]);return Object.defineProperty(this,s,{value:l}),l}};for(const s in n)u[s]={get(){const l=d(this,n[s]);return Object.defineProperty(this,s,{value:l}),l}};for(const s in a)u[s]={get(){return(...l)=>d(this,a[s](...l))}};return u.ansi256=u.fg,u.bgAnsi256=u.bg,g=Object.defineProperties({},u),Object.setPrototypeOf(r,g),r},Yt=i=>(e,...o)=>{if(!Array.isArray(e)||!Array.isArray(e.raw))throw new TypeError("A tagged template literal must be provided");const n=[e.raw[0]];for(let a=1;a<e.raw.length;a+=1)n.push(String(o[a-1]).replaceAll(/[{}\\]/g,String.raw`\$&`),String(e.raw[a]));return i(n.join(""))},kt=new Map([["0","\0"],["\\","\\"],["a","\x07"],["b","\b"],["e","\x1B"],["f","\f"],["n",`
|
|
3
3
|
`],["r","\r"],["t"," "],["v","\v"]]),Su=i=>{const e=i.startsWith("u"),o=i[1]==="{";return e&&!o&&i.length===5||i.startsWith("x")&&i.length===3?String.fromCodePoint(Number.parseInt(i.slice(1),16)):e&&o?String.fromCodePoint(Number.parseInt(i.slice(2,-1),16)):kt.get(i)??i},Lt=/\\(u(?:[a-f\d]{4}|\{[a-f\d]{1,6}\})|x[a-f\d]{2}|.)|\{(~)?(#?[\w:]+(?:\([^)]*\))?(?:\.#?[\w:]+(?:\([^)]*\))?)*)(?:[ \t]|(?=\r?\n))|(\})|((?:.|[\r\n\f])+?)/gi,ga=/(?:^|\.)(?:(\w+)(?:\(([^)]*)\))?|#(?=[:a-f\d]{2,})([a-f\d]{6})?(?::([a-f\d]{6}))?)/gi,Zt=/^(['"])((?:\\.|(?!\1)[^\\])*)\1$/,St=/\\(u(?:[a-f\d]{4}|\{[a-f\d]{1,6}\})|x[a-f\d]{2}|.)|([^\\])/gi,Jt=/\s*,\s*/,Ct=(i,e)=>{const o=[],n=e.trim().split(Jt);let a;for(const u of n){const g=Number(u);if(!Number.isNaN(g))o.push(g);else if(a=Zt.exec(u))o.push(a[2].replaceAll(St,(d,r,s)=>r?Su(r):s));else throw new Error(`Invalid template style argument: ${u} (in style '${i}')`)}return o},Xt=i=>{ga.lastIndex=0;const e=[];let o;for(;(o=ga.exec(i))!==null;){const n=o[1];o[2]?e.push([n,...Ct(n,o[2])]):o[3]||o[4]?(o[3]&&e.push(["rgb",...Fo(o[3])]),o[4]&&e.push(["bgRgb",...Fo(o[4])])):e.push([n])}return e},da=(i,e)=>{const o={};for(const a of e)for(const u of a.styles)o[u[0]]=a.inverse?void 0:u.slice(1);let n=i;for(const[a,u]of Object.entries(o))if(Array.isArray(u)){if(!(a in n))throw new Error(`Unknown style: ${a}`);n=u.length>0?n[a](...u):n[a]}return n},Ht=i=>e=>{const o=[],n=[];let a=[];if(e.replaceAll(Lt,(u,g,d,r,s,l)=>{if(g)a.push(Su(g));else if(r){const h=a.join("");a=[],n.push(o.length===0?h:da(i,o)(h)),o.push({inverse:d,styles:Xt(r)})}else if(s){if(o.length===0)throw new Error("Found extraneous } in template literal");n.push(da(i,o)(a.join(""))),a=[],o.pop()}else a.push(l)}),n.push(a.join("")),o.length>0)throw new Error(`template literal is missing ${String(o.length)} closing bracket${o.length===1?"":"s"} (\`}\`)`);return n.join("")},Dt=new ft,Tt=Ht(Dt),Bt=Yt(Tt),Qt=rt(import.meta.url),Vi=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,Xe=i=>{if(typeof Vi<"u"&&Vi.versions&&Vi.versions.node){const[e,o]=Vi.versions.node.split(".").map(Number);if(e>22||e===22&&o>=3||e===20&&o>=16)return Vi.getBuiltinModule(i)}return Qt(i)},{createRequire:Mt}=Xe("node:module"),Ri=Vi,{execFileSync:Gt}=Xe("node:child_process"),Ye=Xe("node:fs"),Nt=Xe("node:tty"),Wt=Xe("node:os"),xt=[161,161,164,164,167,168,170,170,173,174,176,180,182,186,188,191,198,198,208,208,215,216,222,225,230,230,232,234,236,237,240,240,242,243,247,250,252,252,254,254,257,257,273,273,275,275,283,283,294,295,299,299,305,307,312,312,319,322,324,324,328,331,333,333,338,339,358,359,363,363,462,462,464,464,466,466,468,468,470,470,472,472,474,474,476,476,593,593,609,609,708,708,711,711,713,715,717,717,720,720,728,731,733,733,735,735,768,879,913,929,931,937,945,961,963,969,1025,1025,1040,1103,1105,1105,8208,8208,8211,8214,8216,8217,8220,8221,8224,8226,8228,8231,8240,8240,8242,8243,8245,8245,8251,8251,8254,8254,8308,8308,8319,8319,8321,8324,8364,8364,8451,8451,8453,8453,8457,8457,8467,8467,8470,8470,8481,8482,8486,8486,8491,8491,8531,8532,8539,8542,8544,8555,8560,8569,8585,8585,8592,8601,8632,8633,8658,8658,8660,8660,8679,8679,8704,8704,8706,8707,8711,8712,8715,8715,8719,8719,8721,8721,8725,8725,8730,8730,8733,8736,8739,8739,8741,8741,8743,8748,8750,8750,8756,8759,8764,8765,8776,8776,8780,8780,8786,8786,8800,8801,8804,8807,8810,8811,8814,8815,8834,8835,8838,8839,8853,8853,8857,8857,8869,8869,8895,8895,8978,8978,9312,9449,9451,9547,9552,9587,9600,9615,9618,9621,9632,9633,9635,9641,9650,9651,9654,9655,9660,9661,9664,9665,9670,9672,9675,9675,9678,9681,9698,9701,9711,9711,9733,9734,9737,9737,9742,9743,9756,9756,9758,9758,9792,9792,9794,9794,9824,9825,9827,9829,9831,9834,9836,9837,9839,9839,9886,9887,9919,9919,9926,9933,9935,9939,9941,9953,9955,9955,9960,9961,9963,9969,9972,9972,9974,9977,9979,9980,9982,9983,10045,10045,10102,10111,11094,11097,12872,12879,57344,63743,65024,65039,65533,65533,127232,127242,127248,127277,127280,127337,127344,127373,127375,127376,127387,127404,917760,917999,983040,1048573,1048576,1114109],Pt=12288,Ft=65510,Kt=[12288,12288,65281,65376,65504,65510],Ot=8361,At=65518,Rt=[8361,8361,65377,65470,65474,65479,65482,65487,65490,65495,65498,65500,65512,65518],_t=32,zt=10630,Et=[32,126,162,163,165,166,172,172,175,175,10214,10221,10629,10630],qt=4352,It=262141,Ju=[4352,4447,8986,8987,9001,9002,9193,9196,9200,9200,9203,9203,9725,9726,9748,9749,9776,9783,9800,9811,9855,9855,9866,9871,9875,9875,9889,9889,9898,9899,9917,9918,9924,9925,9934,9934,9940,9940,9962,9962,9970,9971,9973,9973,9978,9978,9981,9981,9989,9989,9994,9995,10024,10024,10060,10060,10062,10062,10067,10069,10071,10071,10133,10135,10160,10160,10175,10175,11035,11036,11088,11088,11093,11093,11904,11929,11931,12019,12032,12245,12272,12287,12289,12350,12353,12438,12441,12543,12549,12591,12593,12686,12688,12773,12783,12830,12832,12871,12880,42124,42128,42182,43360,43388,44032,55203,63744,64255,65040,65049,65072,65106,65108,65126,65128,65131,94176,94180,94192,94198,94208,101589,101631,101662,101760,101874,110576,110579,110581,110587,110589,110590,110592,110882,110898,110898,110928,110930,110933,110933,110948,110951,110960,111355,119552,119638,119648,119670,126980,126980,127183,127183,127374,127374,127377,127386,127488,127490,127504,127547,127552,127560,127568,127569,127584,127589,127744,127776,127789,127797,127799,127868,127870,127891,127904,127946,127951,127955,127968,127984,127988,127988,127992,128062,128064,128064,128066,128252,128255,128317,128331,128334,128336,128359,128378,128378,128405,128406,128420,128420,128507,128591,128640,128709,128716,128716,128720,128722,128725,128728,128732,128735,128747,128748,128756,128764,128992,129003,129008,129008,129292,129338,129340,129349,129351,129535,129648,129660,129664,129674,129678,129734,129736,129736,129741,129756,129759,129770,129775,129784,131072,196605,196608,262141],He=(i,e)=>{let o=0,n=Math.floor(i.length/2)-1;for(;o<=n;){const a=Math.floor((o+n)/2),u=a*2;if(e<i[u])n=a-1;else if(e>i[u+1])o=a+1;else return!0}return!1},ta=19968,[Ut,$t]=Vt(Ju);function Vt(i){let e=i[0],o=i[1];for(let n=0;n<i.length;n+=2){const a=i[n],u=i[n+1];if(ta>=a&&ta<=u)return[a,u];u-a>o-e&&(e=a,o=u)}return[e,o]}const ir=i=>i<161||i>1114109?!1:He(xt,i),er=i=>i<Pt||i>Ft?!1:He(Kt,i),or=i=>i<Ot||i>At?!1:He(Rt,i),nr=i=>i<_t||i>zt?!1:He(Et,i),ar=i=>i>=Ut&&i<=$t?!0:i<qt||i>It?!1:He(Ju,i);function ur(i){return ir(i)?"ambiguous":er(i)?"fullwidth":or(i)?"halfwidth":nr(i)?"narrow":ar(i)?"wide":"neutral"}function gr(i){if(!Number.isSafeInteger(i))throw new TypeError(`Expected a code point, got \`${typeof i}\`.`)}function Cu(i){return gr(i),ur(i)}const ra=new Map,dr=i=>[i.ambiguousIsNarrow?1:0,i.control,i.fullWidth,i.regular,i.wide].join("|"),tr=i=>{const e=dr(i.width);let o=ra.get(e);return o||(o=new Map,ra.set(e,o)),o},xe=/(?:[\u0020-\u007E\u00A0-\u00FF](?!\uFE0F)){1,1000}/y,Xu=i=>i>=32&&i<=126?"latin":i===8203||i===8204||i===8205||i===8288?"zero":i<=31||i>=127&&i<=159?"control":i>=160&&i<=255||i>=9472&&i<=9599?"latin":i>=4352&&i<=4607||i>=11904&&i<=40959||i>=44032&&i<=55215||i>=63744&&i<=64255||i>=65280&&i<=65519&&!(i>=65377&&i<=65439)||i>=12352&&i<=12543?"wide":i===8230?"latin":"other",rr=(i,e)=>{const o=tr(e),n=Math.floor(i/65536),a=i%65536;let u=o.get(n);if(u||(u=new Map,o.set(n,u)),u.has(a))return u.get(a);let g;switch(Xu(i)){case"control":{g=e.width.control;break}case"latin":{g=e.width.regular;break}case"wide":{g=e.width.wide;break}case"zero":{g=0;break}default:switch(Cu(i)){case"ambiguous":{g=e.width.ambiguousIsNarrow?e.width.regular:e.width.wide;break}case"fullwidth":{g=e.width.fullWidth;break}case"wide":{g=e.width.wide;break}default:g=e.width.regular}}return u.set(a,g),g},sr=i=>i>=768&&i<=879||i>=6832&&i<=6911||i>=7616&&i<=7679||i>=8400&&i<=8447||i>=65056&&i<=65071||i>=917760&&i<=917999||i>=65024&&i<=65039||i>=3633&&i<=3642||i>=3655&&i<=3662||i>=3761&&i<=3769||i>=3771&&i<=3772||i>=3784&&i<=3789||i>=2304&&i<=2307||i>=2362&&i<=2383||i>=2385&&i<=2391||i>=2402&&i<=2403||i>=2433&&i<=2435||i>=2492&&i<=2500||i>=2509&&i<=2509||i>=2561&&i<=2563||i>=2620&&i<=2637||i>=1611&&i<=1631||i>=1648&&i<=1648||i>=1750&&i<=1773||i>=2276&&i<=2302||i>=1425&&i<=1469||i>=1471&&i<=1471||i>=1473&&i<=1474||i>=1476&&i<=1477||i>=1479&&i<=1479||i>=3893&&i<=3893||i>=3895&&i<=3895||i>=3897&&i<=3897||i>=3953&&i<=3966||i>=3968&&i<=3972||i>=3974&&i<=3975?!0:i>=768&&i<=777||i>=803&&i<=803,Oo=(i,e={})=>{if(!i||i.length===0)return{ellipsed:!1,index:0,truncated:!1,width:0};const o={truncation:{countAnsiEscapeCodes:e.countAnsiEscapeCodes??!1,ellipsis:e.ellipsis??"",ellipsisWidth:e.ellipsisWidth??(e.ellipsis?Oo(e.ellipsis,{...e,ellipsis:"",ellipsisWidth:0,limit:Number.POSITIVE_INFINITY}).width:0),limit:e.limit??Number.POSITIVE_INFINITY},width:{ambiguousIsNarrow:e.ambiguousIsNarrow??!1,ansi:e.ansiWidth??0,control:e.controlWidth??0,emoji:e.emojiWidth??2,fullWidth:e.fullWidth??2,halfWidth:e.halfWidth??1,regular:e.regularWidth??1,tab:e.tabWidth??8,wide:e.wideWidth??2}},n=Math.max(0,o.truncation.limit-o.truncation.ellipsisWidth),{length:a}=i,u=a>1e4;let g=0,d=0,r=a,s=!1;const l=i.includes("\x1B")||i.includes("");for(;g<a;){if(l&&(i[g]==="\x1B"||i[g]==="")){if(i.startsWith("\x1B]8;;",g)){const p="\x1B]8;;\x07",j=p.length,L=i.indexOf("\x07",g+5);if(L!==-1){const R=i.indexOf(p,L+1);if(R!==-1){const _=R+j,q=i.slice(L+1,R).replace(pe,""),Q=Oo(q,{ambiguousIsNarrow:o.width.ambiguousIsNarrow,ansiWidth:o.width.ansi,controlWidth:o.width.control,countAnsiEscapeCodes:!1,ellipsis:o.truncation.ellipsis,ellipsisWidth:o.truncation.ellipsisWidth,emojiWidth:o.width.emoji,fullWidth:o.width.fullWidth,halfWidth:o.width.halfWidth,limit:Math.max(0,n-d),regularWidth:o.width.regular,tabWidth:o.width.tab,wideWidth:o.width.wide}),I=Q.width;if(Q.truncated)s=!0,r=Math.min(r,g);else if(d+I>n&&(r=Math.min(r,g),s=!0,d+I>o.truncation.limit))break;if(d+=I,g=_,s&&d>=o.truncation.limit)break;continue}}}if(pe.lastIndex=g,pe.test(i)){const p=pe.lastIndex-g,j=o.truncation.countAnsiEscapeCodes?p:o.width.ansi;if(d+j>n&&(r=Math.min(r,g),d+j>o.truncation.limit)){s=!0;break}d+=j,g=pe.lastIndex;continue}}const y=i.codePointAt(g);if(y===8203||y===65279||y>=8288&&y<=8292){g+=1;continue}if(y===9){if(d+o.width.tab>n&&(r=Math.min(r,g),d+o.width.tab>o.truncation.limit)){s=!0;break}d+=o.width.tab,g+=1;continue}if(xe.lastIndex=g,xe.test(i)){const p=(xe.lastIndex-g)*o.width.regular;if(d+p>n){const j=Math.floor((n-d)/o.width.regular);if(r=Math.min(r,g+j),d+p>o.truncation.limit){s=!0;break}}d+=p,g=xe.lastIndex;continue}if((y<=31||y>=127&&y<=159)&&(We.lastIndex=g,We.test(i))){const p=(We.lastIndex-g)*o.width.control;if(d+p>n&&(r=Math.min(r,g+Math.floor((n-d)/o.width.control)),d+p>o.truncation.limit)){s=!0;break}d+=p,g=We.lastIndex;continue}if(Jo.lastIndex=g,Jo.test(i)){if(d+o.width.emoji>n&&(r=Math.min(r,g),d+o.width.emoji>o.truncation.limit)){s=!0;break}d+=o.width.emoji,g=Jo.lastIndex;continue}const c=i.codePointAt(g)??0;if(sr(c)){g+=c>65535?2:1;continue}let b;if(u)b=rr(c,o);else switch(Xu(c)){case"control":{b=o.width.control;break}case"latin":{b=o.width.regular;break}case"wide":{b=o.width.wide;break}case"zero":{b=0;break}default:switch(Cu(c)){case"ambiguous":{b=o.width.ambiguousIsNarrow?o.width.regular:o.width.wide;break}case"fullwidth":{b=o.width.fullWidth;break}case"wide":{b=o.width.wide;break}default:b=o.width.regular}}if(d+b>n&&(r=Math.min(r,g),d+b>o.truncation.limit)){s=!0;break}d+=b,g+=c>65535?2:1}let h=d,v=!1;return s&&o.truncation.limit>=o.truncation.ellipsisWidth&&(h=o.truncation.limit,v=!0),{ellipsed:v,index:s?r:a,truncated:s,width:h}},hr=(i,e={})=>Oo(i,{...e,ellipsis:"",ellipsisWidth:0,limit:Number.POSITIVE_INFINITY}).width,lr=Mt(import.meta.url),we=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,vr=i=>{if(typeof we<"u"&&we.versions&&we.versions.node){const[e,o]=we.versions.node.split(".").map(Number);if(e>22||e===22&&o>=3||e===20&&o>=16)return we.getBuiltinModule(i)}return lr(i)};vr("node:util");function yr(i){return i&&i.__esModule&&Object.prototype.hasOwnProperty.call(i,"default")?i.default:i}var Co,sa;function cr(){if(sa)return Co;sa=1,Co=e;function i(n){return n instanceof Buffer?Buffer.from(n):new n.constructor(n.buffer.slice(),n.byteOffset,n.length)}function e(n){if(n=n||{},n.circles)return o(n);const a=new Map;if(a.set(Date,s=>new Date(s)),a.set(Map,(s,l)=>new Map(g(Array.from(s),l))),a.set(Set,(s,l)=>new Set(g(Array.from(s),l))),n.constructorHandlers)for(const s of n.constructorHandlers)a.set(s[0],s[1]);let u=null;return n.proto?r:d;function g(s,l){const h=Object.keys(s),v=new Array(h.length);for(let y=0;y<h.length;y++){const c=h[y],b=s[c];typeof b!="object"||b===null?v[c]=b:b.constructor!==Object&&(u=a.get(b.constructor))?v[c]=u(b,l):ArrayBuffer.isView(b)?v[c]=i(b):v[c]=l(b)}return v}function d(s){if(typeof s!="object"||s===null)return s;if(Array.isArray(s))return g(s,d);if(s.constructor!==Object&&(u=a.get(s.constructor)))return u(s,d);const l={};for(const h in s){if(Object.hasOwnProperty.call(s,h)===!1)continue;const v=s[h];typeof v!="object"||v===null?l[h]=v:v.constructor!==Object&&(u=a.get(v.constructor))?l[h]=u(v,d):ArrayBuffer.isView(v)?l[h]=i(v):l[h]=d(v)}return l}function r(s){if(typeof s!="object"||s===null)return s;if(Array.isArray(s))return g(s,r);if(s.constructor!==Object&&(u=a.get(s.constructor)))return u(s,r);const l={};for(const h in s){const v=s[h];typeof v!="object"||v===null?l[h]=v:v.constructor!==Object&&(u=a.get(v.constructor))?l[h]=u(v,r):ArrayBuffer.isView(v)?l[h]=i(v):l[h]=r(v)}return l}}function o(n){const a=[],u=[],g=new Map;if(g.set(Date,h=>new Date(h)),g.set(Map,(h,v)=>new Map(r(Array.from(h),v))),g.set(Set,(h,v)=>new Set(r(Array.from(h),v))),n.constructorHandlers)for(const h of n.constructorHandlers)g.set(h[0],h[1]);let d=null;return n.proto?l:s;function r(h,v){const y=Object.keys(h),c=new Array(y.length);for(let b=0;b<y.length;b++){const p=y[b],j=h[p];if(typeof j!="object"||j===null)c[p]=j;else if(j.constructor!==Object&&(d=g.get(j.constructor)))c[p]=d(j,v);else if(ArrayBuffer.isView(j))c[p]=i(j);else{const L=a.indexOf(j);L!==-1?c[p]=u[L]:c[p]=v(j)}}return c}function s(h){if(typeof h!="object"||h===null)return h;if(Array.isArray(h))return r(h,s);if(h.constructor!==Object&&(d=g.get(h.constructor)))return d(h,s);const v={};a.push(h),u.push(v);for(const y in h){if(Object.hasOwnProperty.call(h,y)===!1)continue;const c=h[y];if(typeof c!="object"||c===null)v[y]=c;else if(c.constructor!==Object&&(d=g.get(c.constructor)))v[y]=d(c,s);else if(ArrayBuffer.isView(c))v[y]=i(c);else{const b=a.indexOf(c);b!==-1?v[y]=u[b]:v[y]=s(c)}}return a.pop(),u.pop(),v}function l(h){if(typeof h!="object"||h===null)return h;if(Array.isArray(h))return r(h,l);if(h.constructor!==Object&&(d=g.get(h.constructor)))return d(h,l);const v={};a.push(h),u.push(v);for(const y in h){const c=h[y];if(typeof c!="object"||c===null)v[y]=c;else if(c.constructor!==Object&&(d=g.get(c.constructor)))v[y]=d(c,l);else if(ArrayBuffer.isView(c))v[y]=i(c);else{const b=a.indexOf(c);b!==-1?v[y]=u[b]:v[y]=l(c)}}return a.pop(),u.pop(),v}}return Co}var br=cr();const Hu=yr(br);Hu();var Du=typeof global=="object"&&global&&global.Object===Object&&global,pr=typeof self=="object"&&self&&self.Object===Object&&self,O=Du||pr||Function("return this")(),E=O.Symbol,Tu=Object.prototype,wr=Tu.hasOwnProperty,jr=Tu.toString,je=E?E.toStringTag:void 0;function mr(i){var e=wr.call(i,je),o=i[je];try{i[je]=void 0;var n=!0}catch{}var a=jr.call(i);return n&&(e?i[je]=o:delete i[je]),a}var fr=Object.prototype,Yr=fr.toString;function kr(i){return Yr.call(i)}var Lr="[object Null]",Zr="[object Undefined]",ha=E?E.toStringTag:void 0;function V(i){return i==null?i===void 0?Zr:Lr:ha&&ha in Object(i)?mr(i):kr(i)}function x(i){return i!=null&&typeof i=="object"}var Sr="[object Symbol]";function ui(i){return typeof i=="symbol"||x(i)&&V(i)==Sr}var Jr=NaN;function la(i){return typeof i=="number"?i:ui(i)?Jr:+i}function M(i,e){for(var o=-1,n=i==null?0:i.length,a=Array(n);++o<n;)a[o]=e(i[o],o,i);return a}var k=Array.isArray,va=E?E.prototype:void 0,ya=va?va.toString:void 0;function gi(i){if(typeof i=="string")return i;if(k(i))return M(i,gi)+"";if(ui(i))return ya?ya.call(i):"";var e=i+"";return e=="0"&&1/i==-1/0?"-0":e}function eo(i,e){return function(o,n){var a;if(o===void 0&&n===void 0)return e;if(o!==void 0&&(a=o),n!==void 0){if(a===void 0)return n;typeof o=="string"||typeof n=="string"?(o=gi(o),n=gi(n)):(o=la(o),n=la(n)),a=i(o,n)}return a}}var Cr=eo(function(i,e){return i+e},0),Xr=/\s/;function Bu(i){for(var e=i.length;e--&&Xr.test(i.charAt(e)););return e}var Hr=/^\s+/;function Qu(i){return i&&i.slice(0,Bu(i)+1).replace(Hr,"")}function G(i){var e=typeof i;return i!=null&&(e=="object"||e=="function")}var ca=NaN,Dr=/^[-+]0x[0-9a-f]+$/i,Tr=/^0b[01]+$/i,Br=/^0o[0-7]+$/i,Qr=parseInt;function si(i){if(typeof i=="number")return i;if(ui(i))return ca;if(G(i)){var e=typeof i.valueOf=="function"?i.valueOf():i;i=G(e)?e+"":e}if(typeof i!="string")return i===0?i:+i;i=Qu(i);var o=Tr.test(i);return o||Br.test(i)?Qr(i.slice(2),o?2:8):Dr.test(i)?ca:+i}var ba=1/0,Mr=17976931348623157e292;function Ci(i){if(!i)return i===0?i:0;if(i=si(i),i===ba||i===-ba){var e=i<0?-1:1;return e*Mr}return i===i?i:0}function Z(i){var e=Ci(i),o=e%1;return e===e?o?e-o:e:0}var Gr="Expected a function";function Nr(i,e){if(typeof e!="function")throw new TypeError(Gr);return i=Z(i),function(){if(--i<1)return e.apply(this,arguments)}}function oi(i){return i}var Wr="[object AsyncFunction]",xr="[object Function]",Pr="[object GeneratorFunction]",Fr="[object Proxy]";function Xi(i){if(!G(i))return!1;var e=V(i);return e==xr||e==Pr||e==Wr||e==Fr}var Ae=O["__core-js_shared__"],pa=(function(){var i=/[^.]+$/.exec(Ae&&Ae.keys&&Ae.keys.IE_PROTO||"");return i?"Symbol(src)_1."+i:""})();function Kr(i){return!!pa&&pa in i}var Or=Function.prototype,Ar=Or.toString;function qi(i){if(i!=null){try{return Ar.call(i)}catch{}try{return i+""}catch{}}return""}var Rr=/[\\^$.*+?()[\]{}|]/g,_r=/^\[object .+?Constructor\]$/,zr=Function.prototype,Er=Object.prototype,qr=zr.toString,Ir=Er.hasOwnProperty,Ur=RegExp("^"+qr.call(Ir).replace(Rr,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function Mu(i){if(!G(i)||Kr(i))return!1;var e=Xi(i)?Ur:_r;return e.test(qi(i))}function $r(i,e){return i?.[e]}function Ii(i,e){var o=$r(i,e);return Mu(o)?o:void 0}var Le=Ii(O,"WeakMap"),Ue=Le&&new Le,Gu=Ue?function(i,e){return Ue.set(i,e),i}:oi,wa=Object.create,de=(function(){function i(){}return function(e){if(!G(e))return{};if(wa)return wa(e);i.prototype=e;var o=new i;return i.prototype=void 0,o}})();function Ze(i){return function(){var e=arguments;switch(e.length){case 0:return new i;case 1:return new i(e[0]);case 2:return new i(e[0],e[1]);case 3:return new i(e[0],e[1],e[2]);case 4:return new i(e[0],e[1],e[2],e[3]);case 5:return new i(e[0],e[1],e[2],e[3],e[4]);case 6:return new i(e[0],e[1],e[2],e[3],e[4],e[5]);case 7:return new i(e[0],e[1],e[2],e[3],e[4],e[5],e[6])}var o=de(i.prototype),n=i.apply(o,e);return G(n)?n:o}}var Vr=1;function is(i,e,o){var n=e&Vr,a=Ze(i);function u(){var g=this&&this!==O&&this instanceof u?a:i;return g.apply(n?o:this,arguments)}return u}function di(i,e,o){switch(o.length){case 0:return i.call(e);case 1:return i.call(e,o[0]);case 2:return i.call(e,o[0],o[1]);case 3:return i.call(e,o[0],o[1],o[2])}return i.apply(e,o)}var es=Math.max;function Nu(i,e,o,n){for(var a=-1,u=i.length,g=o.length,d=-1,r=e.length,s=es(u-g,0),l=Array(r+s),h=!n;++d<r;)l[d]=e[d];for(;++a<g;)(h||a<u)&&(l[o[a]]=i[a]);for(;s--;)l[d++]=i[a++];return l}var os=Math.max;function Wu(i,e,o,n){for(var a=-1,u=i.length,g=-1,d=o.length,r=-1,s=e.length,l=os(u-d,0),h=Array(l+s),v=!n;++a<l;)h[a]=i[a];for(var y=a;++r<s;)h[y+r]=e[r];for(;++g<d;)(v||a<u)&&(h[y+o[g]]=i[a++]);return h}function ns(i,e){for(var o=i.length,n=0;o--;)i[o]===e&&++n;return n}function oo(){}var as=4294967295;function J(i){this.__wrapped__=i,this.__actions__=[],this.__dir__=1,this.__filtered__=!1,this.__iteratees__=[],this.__takeCount__=as,this.__views__=[]}J.prototype=de(oo.prototype);J.prototype.constructor=J;function gn(){}var dn=Ue?function(i){return Ue.get(i)}:gn,ne={},us=Object.prototype,gs=us.hasOwnProperty;function Re(i){for(var e=i.name+"",o=ne[e],n=gs.call(ne,e)?o.length:0;n--;){var a=o[n],u=a.func;if(u==null||u==i)return a.name}return e}function li(i,e){this.__wrapped__=i,this.__actions__=[],this.__chain__=!!e,this.__index__=0,this.__values__=void 0}li.prototype=de(oo.prototype);li.prototype.constructor=li;function ei(i,e){var o=-1,n=i.length;for(e||(e=Array(n));++o<n;)e[o]=i[o];return e}function xu(i){if(i instanceof J)return i.clone();var e=new li(i.__wrapped__,i.__chain__);return e.__actions__=ei(i.__actions__),e.__index__=i.__index__,e.__values__=i.__values__,e}var ds=Object.prototype,ts=ds.hasOwnProperty;function t(i){if(x(i)&&!k(i)&&!(i instanceof J)){if(i instanceof li)return i;if(ts.call(i,"__wrapped__"))return xu(i)}return new li(i)}t.prototype=oo.prototype;t.prototype.constructor=t;function Ao(i){var e=Re(i),o=t[e];if(typeof o!="function"||!(e in J.prototype))return!1;if(i===o)return!0;var n=dn(o);return!!n&&i===n[0]}var rs=800,ss=16,hs=Date.now;function Pu(i){var e=0,o=0;return function(){var n=hs(),a=ss-(n-o);if(o=n,a>0){if(++e>=rs)return arguments[0]}else e=0;return i.apply(void 0,arguments)}}var Fu=Pu(Gu),ls=/\{\n\/\* \[wrapped with (.+)\] \*/,vs=/,? & /;function ys(i){var e=i.match(ls);return e?e[1].split(vs):[]}var cs=/\{(?:\n\/\* \[wrapped with .+\] \*\/)?\n?/;function bs(i,e){var o=e.length;if(!o)return i;var n=o-1;return e[n]=(o>1?"& ":"")+e[n],e=e.join(o>2?", ":" "),i.replace(cs,`{
|
|
4
4
|
/* [wrapped with `+e+`] */
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import{createRequire as _}from"node:module";import{ag as x,p as o,ah as B}from"./bin.js";import{w as R}from"../packem_shared/pm-runner-
|
|
1
|
+
import{createRequire as _}from"node:module";import{ag as x,p as o,ah as B}from"./bin.js";import{w as R}from"../packem_shared/pm-runner-BKZQo7Ts.js";import{W as V}from"../packem_shared/build-scripts-CCCi8U66.js";import{m as y,f as w}from"../packem_shared/index-BDmTbWX1.js";import{a as W}from"./config.js";const j=_(import.meta.url),v=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,D=c=>{if(typeof v<"u"&&v.versions&&v.versions.node){const[r,f]=v.versions.node.split(".").map(Number);if(r>22||r===22&&f>=3||r===20&&f>=16)return v.getBuiltinModule(c)}return j(c)},{readdirSync:S,statSync:M}=D("node:fs"),q=(c,r={})=>{const f=y(c,"node_modules");if(!w(f))return[];const l=new Map,p=new Set,$=(n,s,t)=>{const e=`${s}@${t}`;if(p.has(e))return;p.add(e);const i=t.startsWith(c)?t.slice(c.length+1):t;let u=l.get(n);u||(u=[],l.set(n,u)),u.some(b=>b.name===s)||u.push({name:s,relativePath:i})},d=(n,s="")=>{let t;try{t=S(n)}catch{return}for(const e of t){const i=y(n,e);if(e.startsWith("@")){d(i,`${e}/`);continue}if(e===".pnpm"&&s===""){let a;try{a=S(i)}catch{continue}for(const m of a){const h=y(i,m,"node_modules");w(h)&&d(h)}continue}if(e.startsWith("."))continue;const u=s+e,b=y(i,"package.json");try{if(!M(i).isDirectory()||!w(b))continue;const a=W(b),m=typeof a.name=="string"?a.name:u;if(typeof a.bin=="string"){const k=m.includes("/")?m.split("/").pop():m;$(k,m,i)}else if(a.bin&&typeof a.bin=="object")for(const k of Object.keys(a.bin))$(k,m,i);const h=y(i,"node_modules");w(h)&&d(h)}catch{}}};d(f);const g=[];for(const[n,s]of l)s.length<2||r[n]===!0||s.every(t=>r[`${t.name}#${n}`]===!0)||g.push({bin:n,packages:s});return g.sort((n,s)=>n.bin.localeCompare(s.bin))},C=new Set(["bun","npm","pnpm","yarn"]),J=({options:c,visConfig:r,workspaceRoot:f})=>{const l=f??process.cwd(),p=R(l),$=r?.security?.policies?.installScripts?.allow??{},d=r?.security?.allowBins??{},g=r?.security?.pinVersions===!0,n=V(l,$,{pinVersions:g}),s=q(l,d),t=r&&C.has(p.name)?x(r,p.name,l):void 0;if(c.json){process.stdout.write(`${JSON.stringify({binConflicts:s,drift:t,excess:n.excess,installed:n.installed.map(e=>({hooks:e.hooks,name:e.name,version:e.version})),packageManager:p.name,pinVersions:g,unapproved:n.unapproved.map(e=>({hooks:e.hooks,name:e.name,version:e.version})),versionDrift:n.versionDrift},void 0,2)}
|
|
2
2
|
`);return}if(o.info(`Build-script status (${p.name}):
|
|
3
3
|
`),n.installed.length===0&&n.unapproved.length===0&&o.success(" No installed packages declare lifecycle scripts."),n.installed.length>0){o.success(` Approved (${String(n.installed.length)}):`);for(const e of n.installed)o.info(` ✓ ${e.name} — ${e.hooks.join(", ")}`)}if(n.unapproved.length>0){o.info(""),o.warn(` Unapproved (${String(n.unapproved.length)}):`);for(const e of n.unapproved)o.info(` ✗ ${e.name} — ${e.hooks.join(", ")}`);o.notice(" Run 'vis approve-builds' to review.")}if(n.excess.length>0){o.info(""),o.warn(` Stale allowlist entries (${String(n.excess.length)}):`);for(const e of n.excess)o.info(` ! ${e}`);o.notice(" Remove these from vis.config.ts security.policies.installScripts.allow.")}if(n.versionDrift.length>0){o.info(""),o.warn(` Version drift (pinVersions: true) — ${String(n.versionDrift.length)} entr${n.versionDrift.length===1?"y":"ies"} point at outdated versions:`);for(const{from:e,to:i}of n.versionDrift)o.info(` ${e} → ${i}`);o.notice(" Update vis.config.ts security.policies.installScripts.allow keys to migrate.")}if(s.length>0){o.info(""),o.warn(` Bin conflicts (${String(s.length)}) — multiple packages expose the same bin name:`);for(const e of s)o.info(` ${e.bin} ← ${e.packages.map(i=>i.name).join(", ")}`);o.notice(" Add the bin (or 'pkg#bin') to vis.config.ts security.allowBins to silence this.")}if(t?.hasDrift){o.info("");for(const e of B(t))o.warn(e)}};export{J as default};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{createRequire as m}from"node:module";import{w as d,M as _}from"../packem_shared/pm-runner-
|
|
1
|
+
import{createRequire as m}from"node:module";import{w as d,M as _}from"../packem_shared/pm-runner-BKZQo7Ts.js";const w=m(import.meta.url),o=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,g=e=>{if(typeof o<"u"&&o.versions&&o.versions.node){const[t,r]=o.versions.node.split(".").map(Number);if(t>22||t===22&&r>=3||t===20&&r>=16)return o.getBuiltinModule(e)}return w(e)},{createInterface:y}=g("node:readline"),s="sigstore",$=()=>!!process.stdout.isTTY&&process.env.CI!=="true",v=e=>new Promise(t=>{const r=y({input:process.stdin,output:process.stderr});r.question(`${e} (Y/n) `,i=>{r.close();const n=i.trim().toLowerCase();t(n===""||n==="y"||n==="yes")})}),h=e=>{const t=d(e),r=_(t,{exact:!1,filter:[],global:!1,optional:!1,packages:[s],peer:!1,saveDev:!0,workspace:!1,workspaceRoot:!1},e,console);return Promise.resolve({exitCode:r})},R=()=>{try{return import.meta.resolve(s),!0}catch{return!1}},I=e=>{let t="pnpm";try{t=d(e).name}catch{}switch(t){case"bun":return`bun add -d ${s}`;case"npm":return`npm install -D ${s}`;case"yarn":return`yarn add -D ${s}`;default:return`pnpm add -D ${s}`}},D=()=>import("sigstore"),T=async(e={})=>{const t=e.interactive??$(),r=e.prompt??v,i=e.runInstall??h,n=e.importImpl??D,l=e.workspaceRoot??process.cwd(),a=I(l);try{return await n()}catch(p){const{code:u,message:f}=p;if(!(u==="ERR_MODULE_NOT_FOUND"||u==="MODULE_NOT_FOUND")||!f.includes(s))throw p}if(!t)throw new Error(`${s} is not installed. \`vis attest\` needs it for keyless signing/verification. Install it in your repo first:
|
|
2
2
|
${a}`);if(!await r(`${s} isn't installed. Install it now?`))throw new Error(`${s} install declined. Re-run \`vis attest\` after installing manually:
|
|
3
3
|
${a}`);const c=await i(l);if(c.exitCode!==0)throw new Error(`Install of ${s} failed (exit ${String(c.exitCode)}). Install manually and retry:
|
|
4
4
|
${a}`);return await n()};export{I as installCommandFor,R as isSigstoreInstalled,T as loadOptionalSigstore};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{createRequire as De}from"node:module";import{p as x}from"../packem_shared/index-
|
|
1
|
+
import{createRequire as De}from"node:module";import{p as x}from"../packem_shared/index-DGSsjmpV.js";import{DEFAULT_CHANGES_DIR as q,DEFAULT_DEPENDENCY_BUMP_RULES as Oe,DEFAULT_CONFIG as Be}from"./DEFAULT_CLEAN_KEEP.js";import{VisReleaseError as R}from"../packem_shared/VisReleaseError-DMGRBTNO.js";import{e as Le,p as Te,c as xe}from"./registry.js";import{E as Ue}from"../packem_shared/public-api-WqUCiyIe.js";import{BUMP_LEVELS as le,maxBump as oe,bumpRank as Q,normaliseGroup as ge}from"../release/types.js";import Z from"./index.js";import{d as He,c as We}from"./detect.js";import{escapeMarkdown as Ye,assertValidPackageName as Je}from"./security.js";import{createShellRunner as J}from"./shell-runner.js";const Se=De(import.meta.url),W=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,pe=e=>{if(typeof W<"u"&&W.versions&&W.versions.node){const[a,t]=W.versions.node.split(".").map(Number);if(a>22||a===22&&t>=3||a===20&&t>=16)return W.getBuiltinModule(e)}return Se(e)},{readdir:Ve,readFile:Ee,writeFile:Fe,unlink:_e}=pe("node:fs/promises"),{resolve:X,sep:K,join:Ge}=pe("node:path"),{realpathSync:ze}=pe("node:fs"),qe=/^---\r?\n([\s\S]*?)\r?\n---\r?\n?([\s\S]*)$/,Xe=e=>{const a=qe.exec(e);return a?{body:(a[2]??"").trim(),frontmatter:a[1]??""}:null},Ke=/^(?:@[a-z0-9-]+\/)?[\w.-]+$/i,Qe=214,Ze=e=>e.length===0||e.length>Qe||e.startsWith(".")||e.startsWith("_")||e.startsWith("-")?!1:Ke.test(e),ie=e=>typeof e=="string"&&le.includes(e),ea=/^\s*(pr|commit|author)\s*:\s*(.+?)\s*$/i,aa=e=>{const a=e.split(/\r?\n/),t={};let n=0;for(const c of a){if(c.trim()===""){n+=1;continue}const d=ea.exec(c);if(!d)break;const[,l="",i=""]=d;switch(l.toLowerCase()){case"author":{t.author=i.startsWith("@")?i:`@${i}`;break}case"commit":{t.commit=i;break}case"pr":{const r=Number.parseInt(i,10);!Number.isNaN(r)&&r>0&&(t.pr=r);break}}n+=1}const s=a.slice(n).join(`
|
|
2
2
|
`).trim();return{meta:Object.keys(t).length>0?t:void 0,remainder:s}},me=e=>typeof e=="object"&&e!==null&&!Array.isArray(e)&&"bump"in e,ta=(e,a,t)=>{if(!ie(a.bump))throw new R({code:"BUMP_FILE_INVALID",file:t,message:`Invalid bump level for "${e}": ${JSON.stringify(a.bump)}. Expected one of: ${le.join(", ")}`,packageName:e});const n={bump:a.bump,package:e};if(a.releaseAs!==void 0){if(typeof a.releaseAs!="string"||!/^\d+\.\d+\.\d+(?:[-+].*)?$/.test(a.releaseAs))throw new R({code:"BUMP_FILE_INVALID",file:t,message:`Invalid releaseAs for "${e}": ${JSON.stringify(a.releaseAs)}. Expected a semver string like "2.0.0" or "2.0.0-rc.1".`,packageName:e});n.releaseAs=a.releaseAs}if(a.cascade!==void 0){if(typeof a.cascade!="object"||a.cascade===null||Array.isArray(a.cascade))throw new R({code:"BUMP_FILE_INVALID",file:t,message:`Cascade block for "${e}" must be an object mapping package globs to bump levels.`,packageName:e});const s={};for(const[c,d]of Object.entries(a.cascade)){if(!ie(d))throw new R({code:"BUMP_FILE_INVALID",file:t,message:`Invalid cascade bump level for "${c}": ${JSON.stringify(d)}.`,packageName:e});s[c]=d}n.cascade=s}return n},ne=e=>e.replaceAll(/^.*[/\\]/g,"").replace(/\.md$/i,""),na=(e,a)=>{const t=Xe(e);if(!t)throw new R({code:"BUMP_FILE_INVALID",file:a,message:"Change file is missing YAML frontmatter (expected `---` delimiters)."});let n;try{n=Ue(t.frontmatter,{schema:"core",strict:!0})}catch(i){throw new R({cause:i,code:"BUMP_FILE_INVALID",file:a,message:`YAML parse failed: ${i.message}`})}if(n==null)return{body:t.body.trim(),id:ne(a),path:a,payload:{bumps:{}}};if(typeof n!="object"||Array.isArray(n))throw new R({code:"BUMP_FILE_INVALID",file:a,message:"Frontmatter must be a YAML object mapping package names to bump levels."});const s=Object.entries(n);if(s.length===0)return{body:t.body.trim(),id:ne(a),path:a,payload:{bumps:{}}};for(const[i]of s)if(!Ze(i))throw new R({code:"BUMP_FILE_INVALID",file:a,message:`Invalid package name: ${JSON.stringify(i)}.`,packageName:i});let c;if(s.length===1&&me(s[0][1])){const[i,r]=s[0];c=ta(i,r,a)}else{const i={};for(const[r,m]of s){if(me(m))throw new R({code:"BUMP_FILE_INVALID",file:a,message:`Mixed simple + nested entries are not allowed. Package "${r}" uses the nested shape but the file has multiple top-level entries.`,packageName:r});if(!ie(m))throw new R({code:"BUMP_FILE_INVALID",file:a,message:`Invalid bump level for "${r}": ${JSON.stringify(m)}. Expected one of: ${le.join(", ")}`,packageName:r});i[r]=m}c={bumps:i}}const{meta:d,remainder:l}=aa(t.body);return{body:l,id:ne(a),meta:d,path:a,payload:c}},Ya=(e,a)=>{let t;if("bumps"in e){const n=Object.entries(e.bumps).map(([s,c])=>`${se(s)}: ${c}`);t=n.length>0?n.join(`
|
|
3
3
|
`):"{}"}else{const n=[`${se(e.package)}:`,` bump: ${e.bump}`];if(e.releaseAs&&n.push(` releaseAs: ${e.releaseAs}`),e.cascade){n.push(" cascade:");for(const[s,c]of Object.entries(e.cascade))n.push(` ${se(s)}: ${c}`)}t=n.join(`
|
|
4
4
|
`)}return`---
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{p as e}from"./bin.js";import{w as u}from"../packem_shared/pm-runner-
|
|
1
|
+
import{p as e}from"./bin.js";import{w as u}from"../packem_shared/pm-runner-BKZQo7Ts.js";import{O as g}from"../packem_shared/native-config-sync-BEkJW7g3.js";import{S as l}from"../packem_shared/min-release-age-D1alDE3K.js";const y=new Set(["bun","npm","pnpm","yarn"]),k=({options:r,visConfig:c,workspaceRoot:f})=>{const s=f??process.cwd(),n=u(s);if(!y.has(n.name)){e.warn(`Package manager '${n.name}' has no native security config to sync.`);return}if(!c?.security){e.warn("vis.config has no `security` block — nothing to sync.");return}const t=c.security.policies??{},a=Object.fromEntries(Object.entries(t.installScripts?.allow??{}).filter(([,o])=>o)),m=t.firstSeen?.minutes,p=t.firstSeen?.exclude??[],i=[];if(Object.keys(a).length>0&&!r.skipAllowBuilds&&i.push(...g(n.name,s,a)),r.skipMinReleaseAge||i.push(...l(n.name,s,m,p)),i.length===0){e.success("Nothing to sync — vis.config and native PM config are aligned.");return}e.info(`Syncing vis.config security settings to ${n.name} native config…
|
|
2
2
|
`);for(const o of i)e.success(` ${o}`)};export{k as default};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{createRequire as m}from"node:module";import{m as d,f as p,T as v}from"../packem_shared/index-BDmTbWX1.js";import{p as e}from"./bin.js";import{w as $}from"../packem_shared/pm-runner-
|
|
1
|
+
import{createRequire as m}from"node:module";import{m as d,f as p,T as v}from"../packem_shared/index-BDmTbWX1.js";import{p as e}from"./bin.js";import{w as $}from"../packem_shared/pm-runner-BKZQo7Ts.js";import{a as u}from"./config.js";const g=m(import.meta.url),c=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,w=o=>{if(typeof c<"u"&&c.versions&&c.versions.node){const[t,s]=c.versions.node.split(".").map(Number);if(t>22||t===22&&s>=3||t===20&&s>=16)return c.getBuiltinModule(o)}return g(o)},{spawnSync:y}=w("node:child_process"),n="@lavamoat/preinstall-always-fail",l=o=>{const t=d(o,"package.json");if(!p(t))return"no-package-json";try{const s=u(t);if(s.devDependencies?.[n]||s.dependencies?.[n])return"installed"}catch{}return"missing"},h=o=>{const t=d(o,"package.json");if(!p(t))return!1;try{const s=u(t);let i=!1;const a=r=>!r||!(n in r)?r:(i=!0,Object.fromEntries(Object.entries(r).filter(([f])=>f!==n)));return s.devDependencies=a(s.devDependencies),s.dependencies=a(s.dependencies),i&&v(t,`${JSON.stringify(s,null,2)}
|
|
2
2
|
`),i}catch{return!1}},D=({options:o,workspaceRoot:t})=>{const s=t??process.cwd();if(o.status){switch(l(s)){case"installed":{e.success(`Preinstall tripwire is installed (${n}).`),e.info("Removing 'ignore-scripts=true' will cause future installs to fail loudly.");break}case"missing":{e.warn("Preinstall tripwire is not installed."),e.info(`Run 'vis security tripwire' to add ${n} as a devDependency.`);break}default:e.error("No package.json found at the workspace root."),process.exitCode=1}return}if(o.remove){h(s)?e.success(`Removed ${n} from package.json. Run your PM's install to clean node_modules.`):e.info(`${n} was not present in package.json.`);return}if(l(s)==="installed"){e.info(`${n} is already installed.`);return}const i=$(s),a={bun:["add","-d",n],npm:["install","--save-dev",n],pnpm:["add","-D","-w",n],yarn:["add","-D",n]}[i.name];if(!a){e.error(`Cannot install tripwire — unsupported package manager '${i.name}'.`),process.exitCode=1;return}e.info(`Installing ${n} via ${i.name}…`);const r=y(i.name,a,{cwd:s,stdio:"inherit"});if(r.error){e.error(`Failed to install tripwire: ${r.error.message}`),process.exitCode=1;return}if(r.signal!==null){e.error(`${i.name} was terminated by signal ${r.signal}`),process.exitCode=1;return}if(r.status!==0){e.error(`${i.name} exited with code ${String(r.status)}`),process.exitCode=r.status??1;return}e.success(`Installed ${n} as a devDependency.`),e.notice(""),e.notice("How the tripwire works:"),e.notice(` ${n} declares a preinstall script that always fails.`),e.notice(" When 'ignore-scripts=true' is set (.npmrc / bunfig.toml / .yarnrc.yml),"),e.notice(" the script is skipped and installs succeed normally. If someone deletes"),e.notice(" that setting, the next install fails — loudly — instead of silently"),e.notice(" running every dependency's lifecycle scripts.")};export{D as default};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{D as b,p}from"./bin.js";import{w}from"../packem_shared/pm-runner-
|
|
1
|
+
import{D as b,p}from"./bin.js";import{w}from"../packem_shared/pm-runner-BKZQo7Ts.js";import{r as y,l as $,L as v}from"../packem_shared/dependency-scan-DnTgYleU.js";import{v as C,m,f as S}from"../packem_shared/index-BDmTbWX1.js";import"../packem_shared/public-api-WqUCiyIe.js";import{e as x}from"../packem_shared/index-3jMNqQom.js";const M=e=>{const s=e.trim();return s===""?!1:/^(?:git\+|git:\/\/|git@|ssh:\/\/)/i.test(s)||/^(?:github|gitlab|bitbucket|gist):/i.test(s)||/^[\w.-]+\/[\w.-]+(?:#.+)?$/.test(s)&&!s.includes("@")?!0:/^https?:\/\//i.test(s)},L=(e,s)=>{for(const t of s)if(t===e||t.endsWith("*")&&e.startsWith(t.slice(0,-1)))return!0;return!1},D=(e,s,t={})=>{const o=y(e,s);if(!o)return[];let i;try{i=C(m(e,o.file))}catch{return[]}const n=b(i,o.type);if(n.length===0)return[];const c=t.allow??[],l=[],f=new Set;for(const r of n){const a=`${r.name}@${r.version}`;for(const d of[r.dependencies,r.optionalDependencies])if(d){for(const[u,h]of Object.entries(d))if(!L(u,c))for(const k of h){if(!M(k))continue;const g=`${a}->${u}@${k}`;f.has(g)||(f.add(g),l.push({declaredBy:a,packageName:u,source:k}))}}}return l.sort((r,a)=>r.packageName.localeCompare(a.packageName)||r.declaredBy.localeCompare(a.declaredBy))},E=new Set(["firstSeen","publisherChange"]),N=e=>e.severity==="block"&&e.acceptedRisk===void 0,R=e=>{const s=e.security?.policies?.firstSeen?.minutes,t=typeof s=="number"&&s>0,o=e.security?.policies?.publisherChange?.mode==="no-downgrade",i=e.security?.blockExoticSubdeps===!0;return t||o||i},V=async e=>{const{offline:s=!1,packageManager:t,visConfig:o,workspaceRoot:i}=e,n=Date.now();if(!R(o))return{decisions:[],durationMs:Date.now()-n,entryCount:0,exoticViolations:[],lockfileMissing:!1,status:"skipped"};const c=y(i,t);if(!c||!S(m(i,c.file)))return{decisions:[],durationMs:Date.now()-n,entryCount:0,exoticViolations:[],lockfileMissing:!0,status:"fail"};const l=$(i,t,{includeDev:!0}),f=l.length,r=await x({offline:s,packageManager:t,packages:l,workspaceRoot:i},"install",{enabledPolicies:new Set(E),visConfig:o}),a=o.security?.blockExoticSubdeps===!0?D(i,t,{allow:o.security.exoticSubdepsAllow}):[],d=r.some(u=>N(u))||a.length>0;return{decisions:r,durationMs:Date.now()-n,entryCount:f,exoticViolations:a,lockfileMissing:!1,status:d?"fail":"pass"}},B=e=>e<1e3?`${String(e)}ms`:`${(e/1e3).toFixed(1)}s`,P=e=>{if(e.status==="skipped")return["– Lockfile supply-chain verification skipped (no firstSeen / publisherChange / blockExoticSubdeps policy configured)"];if(e.lockfileMissing)return["✗ Lockfile supply-chain verification failed — no lockfile found, the resolved closure cannot be attested"];const s=`(${String(e.entryCount)} ${e.entryCount===1?"entry":"entries"}, ${B(e.durationMs)})`;if(e.status==="pass")return[`✓ Lockfile passes supply-chain policies ${s}`];const t=[`✗ Lockfile failed supply-chain policy check ${s}`];for(const o of e.decisions)o.severity==="block"&&o.acceptedRisk===void 0&&t.push(` [${o.policy}] ${o.reason}`);for(const o of e.exoticViolations)t.push(` [blockExoticSubdeps] ${o.packageName} pulled from exotic source by ${o.declaredBy}: ${o.source}`);return t},J=async({options:e,visConfig:s,workspaceRoot:t})=>{const o=t??process.cwd(),i=w(o);if(!v[i.name]){p.warn(`Package manager '${i.name}' has no lockfile vis can verify.`);return}const n=await V({offline:!!e.offline,packageManager:i.name,visConfig:s??{},workspaceRoot:o});if(e.json){process.stdout.write(`${JSON.stringify(n,void 0,2)}
|
|
2
2
|
`),n.status==="fail"&&(process.exitCode=1);return}const[c,...l]=P(n);if(n.status==="skipped"){p.info(c);return}if(n.status==="pass"){p.success(c);return}p.error(c);for(const f of l)p.error(f);process.exitCode=1};export{J as default};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{p as k}from"../packem_shared/index-
|
|
1
|
+
import{p as k}from"../packem_shared/index-DGSsjmpV.js";import{c as $}from"./registry.js";import{d as w}from"./orchestrator.js";import{defaultTagFor as T,renderTagPattern as E}from"./git.js";const R=e=>{let t=0;const i=[],r=()=>{if(t>=e)return;const s=i.shift();s&&(t+=1,s())};return async s=>new Promise((c,a)=>{const m=()=>{t-=1,r()},d=()=>{s().then(c,a).finally(m)};i.push(d),r()})},b=4,p=new Map,h=(e,t)=>{const i=m=>m.replaceAll(/[$()*+.?[\\\]^{|}]/g,String.raw`\$&`);let r="^",s=0;const c=/\{(name|unscopedName|version|major|minor|patch|date|channel)\}/g;let a;for(;(a=c.exec(e))!==null;){switch(r+=i(e.slice(s,a.index)),a[1]){case"name":{r+=i(t.name);break}case"unscopedName":{r+=i(t.name.replace(/^@[^/]+\//,""));break}case"version":{r+=String.raw`(\d+\.\d+\.\d+(?:-[0-9A-Za-z.-]+)?(?:\+[0-9A-Za-z.-]+)?)`;break}default:r+="[^/]+"}s=a.index+a[0].length}return r+=`${i(e.slice(s))}$`,new RegExp(r)},y=async(e,t,i,r)=>{if(t==="disk")return{resolvedFrom:"disk",version:e.version};if(t==="registry"){const l=w(e,r.perPackageConfig??{}),n=await $(l).readPublishedVersion({pkg:e,pm:r.pm,workspaceConfig:r.workspaceConfig});return n&&k.valid(n)?{resolvedFrom:"registry",version:n}:{fallbackReason:n===void 0?`registry returned no version for ${e.name} (likely a 404 / not-yet-published); falling back to manifest version ${e.version}.`:`registry returned an invalid semver "${n}" for ${e.name}; falling back to manifest version ${e.version}.`,resolvedFrom:"disk",version:e.version}}const s=r.perPackageConfig?.releaseTagPattern??r.workspaceConfig?.releaseTagPattern??"{name}@{version}",c=s.replaceAll(/\{(name|unscopedName|version|major|minor|patch|date|channel)\}/g,(l,n)=>n==="name"?e.name:n==="unscopedName"?e.name.replace(/^@[^/]+\//,""):"*"),a=await r.runner.run("git",["tag","--list",c,"--sort=-v:refname"],{cwd:r.cwd,silent:!0});if(a.exitCode!==0)return{fallbackReason:`git tag --list ${c} failed (exit ${a.exitCode}); falling back to manifest version ${e.version}.`,resolvedFrom:"disk",version:e.version};const m=a.stdout.split(`
|
|
2
2
|
`).map(l=>l.trim()).filter(Boolean);if(m.length===0)return{fallbackReason:`no git tag matched pattern "${s}" for ${e.name}; falling back to manifest version ${e.version}. (Pass --first-release to bootstrap.)`,resolvedFrom:"disk",version:e.version};const d=h(s,e),o=[];for(const l of m){const n=d.exec(l);n?.[1]&&k.valid(n[1])&&o.push(n[1])}return o.length===0?{fallbackReason:`git tag pattern "${s}" matched tags but none yielded a valid semver for ${e.name}; falling back to manifest version ${e.version}.`,resolvedFrom:"disk",version:e.version}:(o.sort(k.rcompare),{resolvedFrom:"git-tag",version:o[0]})},C=(e,t,i)=>i?"disk":t?.currentVersionResolver??e?.currentVersionResolver??"disk",V=async(e,t,i,r,s)=>{const c=new Map,a=[],m=R(b),d=await Promise.all(e.map(async o=>m(async()=>{const l=r.get(o.name),n=C(i,l,s.firstRelease),g=s.skipRegistryLookup?"disk":n,v=`${o.name}@${g}@${o.version}`,u=p.get(v);if(u)return{mode:g,pkg:o,result:await u};const f=y(o,g,t,{...s,perPackageConfig:l,workspaceConfig:i});return p.set(v,f),f.catch(()=>{p.get(v)===f&&p.delete(v)}),{mode:g,pkg:o,result:await f}})));for(const{mode:o,pkg:l,result:n}of d)c.set(l.name,n.version),n.fallbackReason&&o!=="disk"&&a.push(`currentVersionResolver (${o}): ${n.fallbackReason}`);return{versions:c,warnings:a}};export{b as REGISTRY_LOOKUP_CONCURRENCY,h as compileReleaseTagRegex,T as defaultTagFor,E as renderTagPattern,y as resolveCurrentVersion,V as resolveCurrentVersionsForWorkspace,C as resolveModeForPackage};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{f,m as s,H as k,j as b}from"./index-BDmTbWX1.js";const v={id:"bun",label:"Bun",lockfiles:["bun.lock","bun.lockb"],scriptSource:"package.json"},j={id:"node",label:"Node.js",lockfiles:["pnpm-lock.yaml","yarn.lock","package-lock.json","npm-shrinkwrap.json"],scriptSource:"package.json"},a={bun:v,node:j},l=["node","bun"],d={"deno.lock":"deno"},$=l.flatMap(e=>a[e].lockfiles.map(o=>[o,e])),m="Deno is not supported yet (deferred — see rfc/design-runtime-multitool.md).",u=(e,o)=>{if(e==="node"||e==="bun")return e;throw e in d||e==="deno"?new Error(`${o} requested runtime "${e}", but ${m}`):new Error(`${o} requested unknown runtime "${e}". Supported: ${l.join(", ")}.`)},w=e=>{let o=e;for(;;){for(const[r,t]of $)if(f(s(o,r)))return{runtime:t};for(const r of Object.keys(d))if(f(s(o,r)))return{deferred:d[r]};const n=k(o);if(n===o||b(o).root===o)return{};o=n}},y=(e,o={})=>{const n=o.env??process.env,r=(c,p,g)=>({adapter:a[c],deferredNotice:g,runtime:c,source:p});if(o.flag!==void 0&&o.flag!=="")return r(u(o.flag,"--runtime"),"flag");const t=n.VIS_RUNTIME;if(t!==void 0&&t!=="")return r(u(t,"VIS_RUNTIME"),"env");if(o.config!==void 0)return r(u(o.config,"config runtime:"),"config");const i=w(e);return i.runtime!==void 0?r(i.runtime,"lockfile"):i.deferred!==void 0?r("node","default",`Detected a ${i.deferred} project but ${m} Falling back to node.`):r("node","default")},N=e=>{if(e!==null&&typeof e=="object"&&"runtime"in e){const o=e.runtime;if(typeof o=="string")return o}},I=(e,o)=>{const n=y(o,{config:e.visConfig?.runtime,flag:N(e.options)});return n.deferredNotice!==void 0&&e.logger?.warn?.(n.deferredNotice),n},R=e=>e.runtime==="bun"?"bun":void 0;export{R as a,I as r};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{createRequire as ie}from"node:module";import{m as E,v as ue}from"./index-BDmTbWX1.js";import{r as le}from"./docker-BMLrNtWm.js";import{a as oe}from"../packem_chunks/config.js";import{e as fe}from"./license-t5KnNX6v.js";import{D as de}from"../packem_chunks/bin.js";import"./public-api-WqUCiyIe.js";import{p as he}from"./index-
|
|
1
|
+
import{createRequire as ie}from"node:module";import{m as E,v as ue}from"./index-BDmTbWX1.js";import{r as le}from"./docker-BMLrNtWm.js";import{a as oe}from"../packem_chunks/config.js";import{e as fe}from"./license-t5KnNX6v.js";import{D as de}from"../packem_chunks/bin.js";import"./public-api-WqUCiyIe.js";import{p as he}from"./index-DGSsjmpV.js";const ae=ie(import.meta.url),P=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,se=e=>{if(typeof P<"u"&&P.versions&&P.versions.node){const[n,t]=P.versions.node.split(".").map(Number);if(n>22||n===22&&t>=3||n===20&&t>=16)return P.getBuiltinModule(e)}return ae(e)},{randomUUID:pe}=se("node:crypto"),{readdirSync:me}=se("node:fs"),X=e=>e.replaceAll(/[^\w.~-]/g,n=>`%${(n.codePointAt(0)??0).toString(16).toUpperCase().padStart(2,"0")}`),C=(e,n)=>{const t=e.toLowerCase();if(t.startsWith("@")){const s=t.indexOf("/");if(s>0){const r=t.slice(0,s),p=t.slice(s+1);return`pkg:npm/${X(r)}/${X(p)}@${X(n)}`}}return`pkg:npm/${X(t)}@${X(n)}`},m={ARRAY:"array",BOOLEAN:"boolean",DATE:"date",FUNCTION:"function",JSTOXML_OBJECT:"jstoxml-object",NULL:"null",NUMBER:"number",OBJECT:"object",STRING:"string"},_e=[m.STRING,m.NUMBER,m.BOOLEAN],ge='<?xml version="1.0" encoding="UTF-8"?>',ee=["_selfCloseTag","_attrs"],ye=(e="",n=0)=>e.repeat(n),Y=e=>Array.isArray(e)&&m.ARRAY||typeof e===m.OBJECT&&e!==null&&e._name&&m.JSTOXML_OBJECT||e instanceof Date&&m.DATE||e===null&&m.NULL||typeof e,re=e=>e.startsWith("<![CDATA["),ce=(e="",n={},t)=>{let s=e;if(typeof e===m.STRING){if(re(e))return e;const r=new RegExp(`(${Object.keys(n).join("|")})(?!(\\w|#)*;)`,"g");s=String(e).replace(r,(p,h)=>n[h]||"")}return typeof t=="function"?t(s):s},be=(e={},n,t,s)=>(Array.isArray(e)?e:Object.entries(e).map(([r,p])=>({[r]:p}))).reduce((r,p)=>{const h=Object.keys(p)[0],_=p[h];if(typeof t===m.FUNCTION&&t(h,_))return r;const y=n?ce(_,n):_,$=!s&&y===!0?"":`="${y}"`;return r.push(`${h}${$}`),r},[]),$e=(e={},n,t,s)=>{const r=be(e,n,t,s);return r.length===0?"":` ${r.join(" ")}`},Oe=(e={})=>Object.keys(e).map(n=>({_name:n,_content:e[n]})),ve=e=>_e.includes(Y(e)),je=e=>!e.match("<"),ke=({header:e,isOutputStart:n})=>e&&n?typeof e===m.BOOLEAN?ge:e:"",ne={"<":"<",">":">","&":"&",'"':"""},U=(e={},n={})=>{const{depth:t=0,indent:s,_isFirstItem:r,_isOutputStart:p=!0,header:h,attributeReplacements:_={},attributeFilter:y,attributeExplicitTrue:$=!1,contentReplacements:F={},contentMap:M,selfCloseTags:B=!0}=n,J=typeof _=="boolean"&&!_?{}:{...ne,..._},G=typeof F=="boolean"&&!F?{}:{...ne,...F},D=typeof s=="string",k=ye(s,t),W=Y(e),L=ke({header:h,isOutputStart:p}),N=p&&!L&&r&&t===0,R=D&&!N?`
|
|
2
2
|
`:"";let b="";switch(W){case m.JSTOXML_OBJECT:{const{_name:f,_content:u}=e;if(u===null&&typeof M!="function"){b=`${R}${k}${f}`;break}if(Array.isArray(u)&&u.every(ve))return u.map(j=>U({_name:f,_content:j},{...n,depth:t,_isOutputStart:!1})).join("");if(ee.includes(f))break;const g=U(u,{...n,depth:t+1,_isOutputStart:N}),w=Y(g),O=je(g),v=re(g),x=`${R}${k}`;if(f==="_comment"){b+=`${x}<!-- ${u} -->`;break}const H=w==="undefined"||g==="",c=B,o=e._selfCloseTag,a=typeof o===m.BOOLEAN?H&&o:H&&c,i=a?"/":"",l=$e(e._attrs,J,y,$),d=`<${f}${l}${i}>`,T=D&&!O&&!v?`
|
|
3
3
|
${k}`:"",S=a?"":`${g}${T}</${f}>`;b+=`${x}${d}${S}`;break}case m.OBJECT:{const f=Object.keys(e);b=f.map((u,g)=>{const w={...n,_isFirstItem:g===0,_isLastItem:g+1===f.length,_isOutputStart:N},O={_name:u};if(Y(e[u])===m.OBJECT&&(ee.forEach(v=>{const x=e[u][v];typeof x<"u"&&(O[v]=x,delete e[u][v])}),typeof e[u]._content<"u"&&Object.keys(e[u]).length>1)){const v=Object.assign({},e[u]);delete v._content,O._content=[...Oe(v),e[u]._content]}return typeof O._content>"u"&&(O._content=e[u]),U(O,w)},n).join("");break}case m.FUNCTION:{const f=e(n);b=U(f,n);break}case m.ARRAY:{b=e.map((f,u)=>{const g={...n,_isFirstItem:u===0,_isLastItem:u+1===e.length,_isOutputStart:N};return U(f,g)}).join("");break}default:{b=ce(e,G,M);break}}return`${L}${b}`},Q=e=>{try{return oe(e)}catch{return}},Te=e=>{if(e.length===0||e.includes("..")||e.startsWith(".")||e.includes("\0")||e.includes("\\"))return!1;if(e.startsWith("@")){const n=e.indexOf("/");return n>1&&!e.includes("/",n+1)}return!e.includes("/")},Se=e=>e.length>0&&!e.includes("/")&&!e.includes("\\")&&!e.includes("..")&&!e.includes("\0"),Ae=(e,n,t)=>{const s=`${n.replaceAll("/","+")}@${t}`,r=E(e,"node_modules",".pnpm"),p=Q(E(r,s,"node_modules",n,"package.json"));if(p)return p;let h;try{h=me(r)}catch{return}const _=`${s}_`;for(const y of h){if(!y.startsWith(_))continue;const $=Q(E(r,y,"node_modules",n,"package.json"));if($)return $}},we=(e,n,t)=>{const s=Q(E(e,"node_modules",n,"package.json"));return s?.version===t?s:void 0},xe=(e,n,t)=>{if(!(!Te(n)||!Se(t)))return Ae(e,n,t)??we(e,n,t)},De={sha256:"SHA-256",sha384:"SHA-384",sha512:"SHA-512"},Ne={sha256:64,sha384:96,sha512:128},Re=e=>{const n={name:e.name,version:e.version},{integrity:t}=e;return t&&t.hex.length===Ne[t.algorithm]&&(n.hash={alg:De[t.algorithm],content:t.hex}),e.dependencies&&(n.dependencies=e.dependencies),e.peerDependencies&&(n.peerDependencies=e.peerDependencies),e.optionalDependencies&&(n.optionalDependencies=e.optionalDependencies),n},Ce=[{file:"pnpm-lock.yaml",type:"pnpm"},{file:"npm-shrinkwrap.json",type:"npm"},{file:"package-lock.json",type:"npm"},{file:"yarn.lock",type:"yarn"},{file:"bun.lock",type:"bun"}],Ee=e=>{for(const{file:n,type:t}of Ce){let s;try{s=ue(E(e,n))}catch{continue}const r=new Map;for(const p of de(s,t))r.set(`${p.name}@${p.version}`,Re(p));return{packages:r,type:t}}},Me=e=>{const n=e.indexOf(":");return n<=0?e:e.slice(0,n)==="npm"?e.slice(n+1):e},V=(e,n,t)=>{const s=t.get(e);if(!s||s.size===0)return;if(s.has(n))return n;const r=Me(n);if(r!==n&&s.has(r))return r;const p=[...s];return he.maxSatisfying(p,r,{includePrerelease:!0})||p[0]},Be="1.7",Le="CycloneDX",Ie="http://cyclonedx.org/schema/bom-1.7.schema.json",Ue="@visulima/vis",te=e=>{try{return oe(e)}catch{return}},Fe=e=>{if(e){if(typeof e=="string")return e;if(typeof e=="object"&&e.name)return e.email?`${e.name} <${e.email}>`:e.name}},Je=e=>{if(e)return typeof e=="string"?e:e.url},qe=e=>{if(e)return typeof e=="string"?e:e.url},Pe=e=>{const n=[];e.homepage&&n.push({type:"website",url:e.homepage});const t=Je(e.repository);t&&n.push({type:"vcs",url:t});const s=qe(e.bugs);return s&&n.push({type:"issue-tracker",url:s}),n.length>0?n:void 0},Xe=e=>e==="application"||e==="service"||e==="tool"?"application":"library",K=(e,n)=>{if(!n)return;n.description&&(e.description=n.description);const t=Fe(n.author);t&&(e.author=t);const s=fe(n);s&&(e.licenses=s);const r=Pe(n);r&&(e.externalReferences=r)},tn=e=>{const{focus:n,generatorVersion:t,includeDev:s=!1,now:r=new Date,projectGraph:p,serialNumber:h,workspace:_,workspaceRoot:y}=e,$=n&&n.length>0?[...le(n,p)].sort():Object.keys(_.projects).sort(),F=new Set($),M=new Map;for(const c of $){const o=_.projects[c];o&&M.set(c,te(E(y,o.root,"package.json")))}const B=[],J=new Map;for(const c of $){const o=_.projects[c];if(!o)continue;const a=M.get(c),i=a?.version??"0.0.0",l=C(c,i);J.set(c,l);const d={"bom-ref":l,name:c,purl:l,type:Xe(o.projectType),version:i};K(d,a),B.push(d)}const G=Ee(y),D=new Map,k=new Map;if(G)for(const c of G.packages.values()){D.set(`${c.name}@${c.version}`,c);let o=k.get(c.name);o||(o=new Set,k.set(c.name,o)),o.add(c.version)}const W=[],L=[],N=new Map;for(const c of $){const o=M.get(c);if(!o)continue;const a=[o.dependencies,o.peerDependencies];s&&a.push(o.devDependencies);const i=new Set,l=(d,T)=>{if(T)for(const[S,j]of Object.entries(T)){if(F.has(S)){const I=J.get(S);I&&i.add(I);continue}const A=V(S,j,k);A&&(i.add(C(S,A)),d.push(`${S}@${A}`))}};for(const d of a)l(W,d);l(L,o.optionalDependencies),N.set(c,i)}const R=new Map,b=new Map,f=(c,o)=>{const a=[...c];for(;a.length>0;){const i=a.pop(),l=R.get(i);if(l==="required"||l==="optional"&&o==="optional")continue;R.set(i,o);const d=D.get(i);if(!d)continue;const T=b.get(i)??new Set,S=[d.dependencies,d.peerDependencies];for(const j of S)if(j)for(const[A,I]of Object.entries(j))for(const q of I){const z=V(A,q,k);z&&(T.add(C(A,z)),a.push(`${A}@${z}`))}if(d.optionalDependencies)for(const[j,A]of Object.entries(d.optionalDependencies))for(const I of A){const q=V(j,I,k);q&&(T.add(C(j,q)),L.push(`${j}@${q}`))}T.size>0&&b.set(i,T)}};f(W,"required"),f(L,"optional");const u=[],g=[...R.keys()].sort();for(const c of g){const o=D.get(c);if(!o)continue;const a=C(o.name,o.version),i={"bom-ref":a,name:o.name,purl:a,scope:R.get(c)??"required",type:"library",version:o.version};o.hash&&(i.hashes=[o.hash]),K(i,xe(y,o.name,o.version)),u.push(i)}const w=[];for(const[c,o]of N){const a=J.get(c);if(!a)continue;const i=[...o].sort();w.push(i.length>0?{dependsOn:i,ref:a}:{ref:a})}for(const c of g){const o=D.get(c);if(!o)continue;const a=C(o.name,o.version),i=b.get(c),l=i?[...i].sort():[];w.push(l.length>0?{dependsOn:l,ref:a}:{ref:a})}w.sort((c,o)=>c.ref.localeCompare(o.ref));const O=te(E(y,"package.json")),v=(()=>{if(n?.length===1){const l=B.find(d=>d.name===n[0]);if(l)return{"bom-ref":l["bom-ref"],name:l.name,purl:l.purl,type:l.type,version:l.version}}const c=O?.name??"workspace",o=O?.version??"0.0.0",a=C(c,o),i={"bom-ref":a,name:c,purl:a,type:"application",version:o};return K(i,O),i})(),x=v["bom-ref"],H=x?B.filter(c=>c["bom-ref"]!==x):B;return{$schema:Ie,bomFormat:Le,components:[...H,...u],dependencies:w,metadata:{component:v,lifecycles:[{phase:"build"}],timestamp:r.toISOString(),tools:{components:[{name:Ue,type:"application",...t?{version:t}:{}}]}},serialNumber:h??`urn:uuid:${pe()}`,specVersion:Be,version:1}},sn=e=>{const n={version:e.version??1,xmlns:"http://cyclonedx.org/schema/bom/1.7"};e.serialNumber&&(n.serialNumber=e.serialNumber);const t=[];return e.metadata&&t.push(Ge(e.metadata)),e.components&&e.components.length>0&&t.push({_content:e.components.map(s=>Z(s)),_name:"components"}),e.dependencies&&e.dependencies.length>0&&t.push({_content:e.dependencies.map(s=>He(s)),_name:"dependencies"}),`${U({_attrs:n,_content:t,_name:"bom"},{header:!0,indent:" ",selfCloseTags:!0})}
|
|
4
4
|
`},Ge=e=>{const n=[];return e.timestamp&&n.push({timestamp:e.timestamp}),e.lifecycles&&e.lifecycles.length>0&&n.push({_content:e.lifecycles.map(t=>{const s=[];return t.phase&&s.push({phase:t.phase}),t.name&&s.push({name:t.name}),t.description&&s.push({description:t.description}),{_content:s,_name:"lifecycle"}}),_name:"lifecycles"}),e.tools?.components&&n.push({_content:[{_content:e.tools.components.map(t=>Z(t)),_name:"components"}],_name:"tools"}),e.component&&n.push(Z(e.component)),{_content:n,_name:"metadata"}},Z=e=>{const n={type:e.type};e["bom-ref"]&&(n["bom-ref"]=e["bom-ref"]);const t=[];e.group&&t.push({group:e.group}),t.push({name:e.name}),e.version&&t.push({version:e.version}),e.description&&t.push({description:e.description}),e.author&&t.push({author:e.author}),e.hashes&&e.hashes.length>0&&t.push({_content:e.hashes.map(r=>({_attrs:{alg:r.alg},_content:r.content,_name:"hash"})),_name:"hashes"});const s=We(e.licenses);return s&&t.push(s),e.purl&&t.push({purl:e.purl}),e.scope&&t.push({scope:e.scope}),e.externalReferences&&e.externalReferences.length>0&&t.push({_content:e.externalReferences.map(r=>({_attrs:{type:r.type},_content:[{url:r.url}],_name:"reference"})),_name:"externalReferences"}),{_attrs:n,_content:t,_name:"component"}},We=e=>{if(!e||e.length===0)return;const n=[];for(const t of e){if("expression"in t){n.push({expression:t.expression});continue}const s=[];"id"in t.license&&t.license.id?s.push({id:t.license.id}):"name"in t.license&&t.license.name&&s.push({name:t.license.name}),n.push({_content:s,_name:"license"})}return{_content:n,_name:"licenses"}},He=e=>e.dependsOn&&e.dependsOn.length>0?{_attrs:{ref:e.ref},_content:e.dependsOn.map(n=>({_attrs:{ref:n},_name:"dependency"})),_name:"dependency"}:{_attrs:{ref:e.ref},_name:"dependency"};export{tn as b,sn as s,C as t};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{m as h,g as k,D as $,f as S}from"./provenance-
|
|
1
|
+
import{m as h,g as k,D as $,f as S}from"./provenance-BFEwKgI3.js";import{Z as d,D as N}from"../packem_chunks/bin.js";import{W as R}from"./build-scripts-CCCi8U66.js";import{n as v}from"./license-t5KnNX6v.js";import{A as L,B as D,v as A}from"./index-BDmTbWX1.js";import"./public-api-WqUCiyIe.js";import{L as w}from"./dependency-scan-DnTgYleU.js";const m={CRITICAL:0,HIGH:1,LOW:3,MODERATE:2,UNKNOWN:4},se=(t,e)=>{const n=m[(t.vulnerability.severity??"UNKNOWN").toUpperCase()]??4,s=m[(e.vulnerability.severity??"UNKNOWN").toUpperCase()]??4;return n-s||t.packageName.localeCompare(e.packageName)||t.packageVersion.localeCompare(e.packageVersion)},P=(t,e)=>{const n=m[e.toUpperCase()]??2;return(m[t.toUpperCase()]??4)<=n},b=["firstSeen","installScripts","license","malware","publisherChange","score","unexpectedDeps","vulnerability"],g=6e4,W=(t,e,n)=>{for(const s of n)if(s===t||s===`${t}@${e}`||s.endsWith("*")&&t.startsWith(s.slice(0,-1)))return!0;return!1},x=async(t,e)=>{const n=e.security?.policies?.firstSeen;if(n?.minutes===void 0||n.minutes<=0)return[];const{minutes:s}=n,a=n.exclude??[],r=e.security?.acceptedRisks,c=s*g,i=Date.now();return(await h(t.packages,$,async o=>{if(W(o.name,o.version,a))return;const l=await k(o.name,{workspaceRoot:t.workspaceRoot});if(l===void 0)return;const p=l.time?.[o.version];if(p===void 0)return;const u=Date.parse(p);if(Number.isNaN(u))return;const f=i-u;if(f>=c)return;const y=Math.max(0,Math.floor(f/g));return{acceptedRisk:d(o.name,o.version,r,"firstSeen"),data:{ageMinutes:y,minimumMinutes:s,publishedAt:p},packageName:o.name,policy:"firstSeen",reason:`${o.name}@${o.version} was published ${String(y)} min ago — below the ${String(s)} min firstSeen cooldown.`,severity:"block",version:o.version}})).filter(o=>o!==void 0)},O=(t,e)=>{const n=e.security?.policies?.installScripts;if(!n)return[];const s=n.allow??{},a=n.strict===!0;if(!a&&Object.keys(s).length===0)return[];const r=R(t.workspaceRoot,s,{pinVersions:e.security?.pinVersions===!0});if(r.unapproved.length===0)return[];const c=e.security?.acceptedRisks,i=a?"block":"warn";return r.unapproved.map(o=>({acceptedRisk:d(o.name,o.version??"*",c,"installScripts"),data:{hooks:o.hooks},packageName:o.name,policy:"installScripts",reason:`${o.name}${o.version?`@${o.version}`:""} declares unapproved build script(s): ${o.hooks.join(", ")}`,severity:i,version:o.version??"*"}))},U=new Set(["AND","OR"]),E=t=>{const e=t.replaceAll("("," ").replaceAll(")"," ").split(/\s+/).map(a=>a.trim()).filter(a=>a.length>0),n=[];let s=!1;for(const a of e){const r=a.toUpperCase();if(s){s=!1;continue}if(r==="WITH"){s=!0;continue}if(U.has(r))continue;const c=a.endsWith("+"),i=c?a.slice(0,-1):a,o=v(i)??i;n.push(o),c&&n.push(`${o}-or-later`)}return n},F=t=>{if(typeof t.license=="string"){const e=t.license.trim();return e.length>0?e:void 0}if(t.license&&typeof t.license=="object"&&typeof t.license.type=="string"){const e=t.license.type.trim();if(e.length>0)return e}if(Array.isArray(t.licenses)&&t.licenses.length>0){const e=t.licenses.map(n=>n&&typeof n.type=="string"?n.type.trim():"").filter(n=>n.length>0);if(e.length>0)return e.length===1?e[0]:`(${e.join(" OR ")})`}},I=(t,e)=>{if(e.length===0)return;const n=new Set(e.map(s=>v(s)??s).map(s=>s.toLowerCase()));for(const s of t)if(n.has(s.toLowerCase()))return s},M=(t,e)=>{if(e.length===0)return;const n=new Set(e.map(s=>v(s)??s).map(s=>s.toLowerCase()));for(const s of t)if(!n.has(s.toLowerCase()))return s},V=(t,e)=>{const n=e.security?.policies?.license;if(!n)return[];const s=n.allow??[],a=n.deny??[];if(s.length===0&&a.length===0)return[];const r=e.security?.acceptedRisks,c=[];for(const i of t.packages){const o=t.manifestData?.get(`${i.name}@${i.version}`),l=o?F(o):void 0;if(!l){s.length>0&&c.push({acceptedRisk:d(i.name,i.version,r,"license"),data:{declaredLicense:null},packageName:i.name,policy:"license",reason:`${i.name}@${i.version} declares no license; allow-list mode requires one of: ${s.join(", ")}`,severity:"block",version:i.version});continue}const p=E(l),u=I(p,a);if(u){c.push({acceptedRisk:d(i.name,i.version,r,"license"),data:{declaredLicense:l,deniedLicense:u},packageName:i.name,policy:"license",reason:`${i.name}@${i.version} uses denied license '${u}' (declared: ${l})`,severity:"block",version:i.version});continue}const f=M(p,s);f&&c.push({acceptedRisk:d(i.name,i.version,r,"license"),data:{allowList:s,declaredLicense:l,unallowedLicense:f},packageName:i.name,policy:"license",reason:`${i.name}@${i.version} uses license '${f}' which is not on the allow-list (declared: ${l})`,severity:"block",version:i.version})}return c},j=6e4,_=(t,e,n)=>{for(const s of n)if(s===t||s===`${t}@${e}`||s.endsWith("*")&&t.startsWith(s.slice(0,-1)))return!0;return!1},H=async(t,e)=>{const n=e.security?.policies?.publisherChange;if(n?.mode!=="no-downgrade")return[];const s=n.exclude??[],a=typeof n.ignoreAfter=="number"?n.ignoreAfter*j:void 0,r=e.security?.acceptedRisks,c=Date.now();return(await h(t.packages,$,async i=>{if(_(i.name,i.version,s))return;const o=await k(i.name,{workspaceRoot:t.workspaceRoot});if(o===void 0)return;if(a!==void 0){const p=o.time?.[i.version],u=p===void 0?Number.NaN:Date.parse(p);if(!Number.isNaN(u)&&c-u>a)return}if(o.versions[i.version]?.dist?.attestations?.provenance!==void 0)return;const l=S(o,i.version);if(l!==void 0)return{acceptedRisk:d(i.name,i.version,r,"publisherChange"),data:{priorVersionWithProvenance:l},packageName:i.name,policy:"publisherChange",reason:`${i.name}@${i.version} dropped the provenance attestation that ${i.name}@${l} carried — publisher trust downgrade.`,severity:"block",version:i.version}})).filter(i=>i!==void 0)},T=t=>{for(const e of Object.values(w))for(const n of[e.file,...e.aliases??[]])if(t===n||t.endsWith(`/${n}`)||t.endsWith(`.${n}`))return e.type},K=(t,e,n)=>{const s=L(e)?e:D(t,e);let a;try{a=A(s)}catch{return}const r=T(s)??w[n]?.type;if(!r)return;const c=N(a,r);if(c.length===0)return;const i=new Set;for(const o of c)i.add(`${o.name}@${o.version}`);return i},z=(t,e)=>{for(const n of e)if(n===t||n.endsWith("*")&&t.startsWith(n.slice(0,-1)))return!0;return!1},Y=(t,e)=>{const n=e.security?.policies?.unexpectedDeps;if(!n)return[];const s=n.allow??[],a=n.baselineLockfile;if(s.length===0&&!a)return[];const r=a?K(t.workspaceRoot,a,t.packageManager):void 0,c=e.security?.acceptedRisks,i=[];for(const o of t.packages){const l=s.length===0||z(o.name,s),p=r?r.has(`${o.name}@${o.version}`):!0;if(l&&p)continue;const u=[],f={};l||(u.push(`not on allow-list (${s.length} entr${s.length===1?"y":"ies"})`),f.allowList=s),!p&&r&&(u.push(`not present in baseline lockfile (${a})`),f.baselineLockfile=a),i.push({acceptedRisk:d(o.name,o.version,c,"unexpectedDeps"),data:f,packageName:o.name,policy:"unexpectedDeps",reason:`${o.name}@${o.version} is unexpected: ${u.join("; ")}`,severity:"block",version:o.version})}return i},q=(t,e)=>{if(!t.osvFindings||t.osvFindings.size===0)return[];const n=e.security?.policies?.vulnerability?.failOn,s=e.security?.acceptedRisks,a=[];for(const r of t.packages){const c=t.osvFindings.get(r.name);if(!(!c||c.length===0))for(const i of c){const o=n?P(i.severity,n)?"block":"warn":"info";a.push({acceptedRisk:d(r.name,r.version,s,"vulnerability"),data:{advisoryId:i.id,aliases:i.aliases??[],cvssScore:i.cvssScore,fixedVersions:i.fixedVersions,severity:i.severity,summary:i.summary},packageName:r.name,policy:"vulnerability",reason:`${i.severity} ${i.id} affects ${r.name}@${r.version}: ${i.summary}`,severity:o,version:r.version})}}return a},C=[{evaluate:q,isConfigured:t=>t.security?.policies?.vulnerability!==void 0,name:"vulnerability",offlineSupported:!0,surfaces:["audit","doctor"]},{evaluate:V,isConfigured:t=>{const e=t.security?.policies?.license;return!!(e&&(e.allow&&e.allow.length>0||e.deny&&e.deny.length>0))},name:"license",offlineSupported:!0,surfaces:["audit","doctor","install"]},{evaluate:O,isConfigured:t=>{const e=t.security?.policies?.installScripts;return!!(e&&(e.allow&&Object.keys(e.allow).length>0||e.strict===!0))},name:"installScripts",offlineSupported:!0,surfaces:["audit","doctor","install"]},{evaluate:Y,isConfigured:t=>{const e=t.security?.policies?.unexpectedDeps;return!!(e&&(e.allow&&e.allow.length>0||typeof e.baselineLockfile=="string"))},name:"unexpectedDeps",offlineSupported:!0,surfaces:["audit","doctor","install"]},{evaluate:x,isConfigured:t=>{const e=t.security?.policies?.firstSeen?.minutes;return typeof e=="number"&&e>0},name:"firstSeen",offlineSupported:!1,surfaces:["audit","doctor","install"]},{evaluate:H,isConfigured:t=>t.security?.policies?.publisherChange?.mode==="no-downgrade",name:"publisherChange",offlineSupported:!1,surfaces:["audit","doctor","install"]}],B=(t,e,n)=>C.filter(s=>s.surfaces.includes(t)?n!==void 0?n.has(s.name):s.isConfigured(e):!1),ie=async(t,e,n)=>{const s=B(e,n.visConfig,n.enabledPolicies),a=[];for(const r of s){if(t.offline&&!r.offlineSupported){a.push({packageName:"*",policy:r.name,reason:`policy.${r.name} skipped: requires network (--offline)`,severity:"info",version:"*"});continue}try{const c=await r.evaluate(t,n.visConfig);a.push(...c)}catch(c){const i=c instanceof Error?c.message:String(c);a.push({packageName:"*",policy:r.name,reason:`policy.${r.name} failed: ${i}`,severity:"info",version:"*"})}}return a},G=(()=>{const t=new Map;for(const e of b)t.set(e.toLowerCase(),e);return t})(),oe=()=>C.map(t=>t.name),re=(t,e)=>{if(t===void 0)return;const n=t.trim().toLowerCase();if(n===""||n==="none")return new Set;if(n==="all")return new Set(b);const s=new Set;for(const a of t.split(",").map(r=>r.trim()).filter(r=>r.length>0)){const r=a.replace(/^_+/,"").replaceAll(/_+([a-z])/g,(i,o)=>o.toUpperCase()),c=G.get(r.toLowerCase());c===void 0?e?.(a):s.add(c)}return s};export{se as c,ie as e,oe as g,re as p,P as s};
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import{createRequire as Ut}from"node:module";import __cjs_mod__ from "node:module"; // -- packem CommonJS require shim --
|
|
2
|
+
const require = __cjs_mod__.createRequire(import.meta.url);
|
|
3
|
+
const jt=Ut(import.meta.url),oe=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,Vt=t=>{if(typeof oe<"u"&&oe.versions&&oe.versions.node){const[e,n]=oe.versions.node.split(".").map(Number);if(e>22||e===22&&n>=3||e===20&&n>=16)return oe.getBuiltinModule(t)}return jt(t)},{createRequire:_e}=Vt("node:module"),Bt=16,ye=32,Rt=64,V=128,fe="positionals",Wt=_e(import.meta.url),se=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,zt=t=>{if(typeof se<"u"&&se.versions&&se.versions.node){const[e,n]=se.versions.node.split(".").map(Number);if(e>22||e===22&&n>=3||e===20&&n>=16)return se.getBuiltinModule(t)}return Wt(t)},{createRequire:ct}=zt("node:module"),Ft=globalThis.process??Object.create(null),Me={versions:{}},Ee=new Proxy(Ft,{get(t,e){if(e in t)return t[e];if(e in Me)return Me[e]}}),qt=t=>t.replaceAll(/\r\n|\r(?!\n)|\n/gu,`
|
|
4
|
+
`),Gt=(t,e,n,i)=>{const s={column:0,line:-1,...t.start},o={...s,...t.end},c=s.line,a=s.column,u=o.line,r=o.column;let l=Math.max(c-(n+1),0),d=Math.min(e.length,u+i);c===-1&&(l=0),u===-1&&(d=e.length);const h=u-c,f={};if(h)for(let p=0;p<=h;p++){const g=p+c;if(!a)f[g]=!0;else if(p===0){const $=e[g-1]?.length;f[g]=[a,($??0)-a+1]}else if(p===h)f[g]=[0,r];else{const $=e[g-p]?.length;f[g]=[0,$]}}else a===r?f[c]=a?[a,0]:!0:f[c]=[a,(r??0)-(a??0)];return{end:d,markerLines:f,start:l}},Ht=Ee.platform==="win32"&&!Ee.env?.WT_SESSION?">":"❯",Jt=(t,e,n)=>{const i={linesAbove:2,linesBelow:3,prefix:"",showGutter:!0,tabWidth:4,...n,color:{gutter:p=>p,marker:p=>p,message:p=>p,...n?.color}},s=typeof e.start.column=="number";let o=(t.includes("\r")?qt(t):t).split(`
|
|
5
|
+
`);typeof i.tabWidth=="number"&&t.includes(" ")&&(o=o.map(p=>p.replaceAll(" "," ".repeat(i.tabWidth))));const{end:c,markerLines:a,start:u}=Gt(e,o,i.linesAbove,i.linesBelow),r=String(c).length,{gutter:l,marker:d,message:h}=i.color;let f=o.slice(u,c).map((p,g)=>{const $=u+1+g,w=a[$],y=String($).padStart(r),b=!a[$+1],N=` ${y}${i.showGutter?" |":""}`;if(w){let E="";if(Array.isArray(w)){const I=p.replaceAll(/[^\t]/g," ").slice(0,Math.max(w[0]-1,0)),O=w[1]||1;E=[`
|
|
6
|
+
`,i.prefix+l(N.replaceAll(/\d/g," "))," ",I,d("^").repeat(O)].join(""),b&&i.message&&(E+=` ${h(i.message)}`)}return[i.prefix+d(Ht),l(N),p.length>0?` ${p}`:"",E].join("")}return`${i.prefix} ${l(N)}${p.length>0?` ${p}`:""}`}).join(`
|
|
7
|
+
`);return i.message&&!s&&(f=`${i.prefix+" ".repeat(r+1)+i.message}
|
|
8
|
+
${f}`),f},Kt=new Map([["Error",Error],["EvalError",EvalError],["RangeError",RangeError],["ReferenceError",ReferenceError],["SyntaxError",SyntaxError],["TypeError",TypeError],["URIError",URIError]]);typeof AggregateError<"u"&&Kt.set("AggregateError",AggregateError);const Yt=ct(import.meta.url),re=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,Qt=t=>{if(typeof re<"u"&&re.versions&&re.versions.node){const[e,n]=re.versions.node.split(".").map(Number);if(e>22||e===22&&n>=3||e===20&&n>=16)return re.getBuiltinModule(t)}return Yt(t)};Qt("node:util");const Zt=()=>Ee.env?.DEBUG==="true",Y=(t,...e)=>{if(Zt()){const n=e.map(i=>typeof i=="function"?i():i);console.debug(`error:parse-stacktrace: ${t}`,...n)}},Q="<unknown>",Xt=/^(?:node:internal\/|node:|internal\/)/,en=t=>t!==void 0&&Xt.test(t),tn=/^.*?\s*at\s(?:(.+?\)(?:\s\[.+\])?|\(?.*?)\s?\((?:address\sat\s)?)?(?:async\s)?((?:<anonymous>|[-a-z]+:|.*bundle|\/)?.*?)(?::(\d+))?(?::(\d+))?\)?\s*$/i,nn=/\((\S+)\),\s(<[^>]+>)?:(\d+)?:(\d+)?\)?/,on=/(.*?):(\d+):(\d+)(?:\s<-\s.+:\d+:\d+)?/,sn=/eval\sat\s(<anonymous>)\s\((.*)\)?:(\d+)?:(\d+)\),\s*<anonymous>?:(\d+)?:(\d+)/,rn=/^\s*in\s(?:([^\\/]+(?:\s\[as\s\S+\])?)\s\(?)?\(at?\s?(.*?):(\d+)(?::(\d+))?\)?\s*$/,an=/in\s(.*)\s\(at\s(.+)\)\sat/,ln=/^(?:.*@)?(.*):(\d+):(\d+)$/,cn=/^\s*(.*?)(?:\((.*?)\))?(?:^|@)?((?:[-a-z]+)?:\/.*?|\[native code\]|[^@]*(?:bundle|\d+\.js)|\/[\w\-. \/=]+)(?::(\d+))?(?::(\d+))?\s*$/i,un=/(\S+) line (\d+)(?: > eval line \d+)* > eval/i,hn=/(\S[^\s[]*\[.*\]|.*?)@(.*):(\d+):(\d+)/,Pe=/\(error: (.*)\)/,pn=/at\s/,dn=/^(\S+):(\d+):(\d+)$|^(\S+):(\d+)$/,fn=/\S*(?:Error: |AggregateError:)/,ut=/^Anonymous function$/,mn=/^\s*in\s.*/,gn=/^.*?\s*at\s.*/,wn=/^.*?\s*@.*|\[native code\]/,ht=(t,e)=>{const n=t.includes("safari-extension"),i=t.includes("safari-web-extension");return n||i?[t.includes("@")?t.split("@")[0]:Q,n?`safari-extension:${e}`:`safari-web-extension:${e}`]:[t,e]},pt=(t,e)=>{const n=on.exec(e);n&&(t.file=n[1],t.line=+n[2],t.column=+n[3])},yn=t=>{const e=an.exec(t);if(e){Y(`parse nested node error stack line: "${t}"`,()=>`found: ${JSON.stringify(e)}`);const i=e[2].split(":");return{column:i[2]?+i[2]:void 0,file:i[0],line:i[1]?+i[1]:void 0,methodName:e[1]??Q,raw:t,type:void 0}}const n=rn.exec(t);if(n){Y(`parse node error stack line: "${t}"`,()=>`found: ${JSON.stringify(n)}`);const i={column:n[4]?+n[4]:void 0,file:n[2]?n[2].replace(pn,""):void 0,line:n[3]?+n[3]:void 0,methodName:n[1]??Q,raw:t,type:t.startsWith("internal")?"internal":void 0};return pt(i,`${n[2]}:${n[3]}:${n[4]}`),i}},vn=t=>{const e=tn.exec(t);if(e){Y(`parse chrome error stack line: "${t}"`,()=>`found: ${JSON.stringify(e)}`);const n=e[2]?.startsWith("native"),i=e[2]?.startsWith("eval")||e[1]?.startsWith("eval");let s,o;if(i){const r=nn.exec(t);if(r){const l=dn.exec(r[1]);l?(e[2]=l[4]??l[1],e[3]=l[5]??l[2],e[4]=l[3]):r[2]&&(e[2]=r[1]),r[2]&&(s={column:r[4]?+r[4]:void 0,file:r[2],line:r[3]?+r[3]:void 0,methodName:"eval",raw:t,type:"eval"})}else{const l=sn.exec(t);l&&(o={column:l[4]?+l[4]:void 0,file:l[2],line:l[3]?+l[3]:void 0},s={column:l[6]?+l[6]:void 0,file:l[1],line:l[5]?+l[5]:void 0,methodName:"eval",raw:l[0],type:"eval"})}}const[c,a]=ht(e[1]?e[1].replace(ut,"<anonymous>"):Q,e[2]),u={column:e[4]?+e[4]:void 0,evalOrigin:s,file:a,line:e[3]?+e[3]:void 0,methodName:c,raw:t,type:i?"eval":n?"native":en(a)?"internal":void 0};return o?(u.column=o.column,u.file=o.file,u.line=o.line):pt(u,`${a}:${e[3]}:${e[4]}`),u}},$n=(t,e)=>{const n=cn.exec(t);if(n){Y(`parse gecko error stack line: "${t}"`,()=>`found: ${JSON.stringify(n)}`);const i=n[3]?.includes(" > eval"),s=i&&n[3]&&un.exec(n[3]);let o;i&&s&&(n[3]=s[1],o={column:n[5]?+n[5]:void 0,file:n[3],line:n[4]?+n[4]:void 0,methodName:"eval",raw:t,type:"eval"},n[4]=s[2]);const[c,a]=ht(n[1]?n[1].replace(ut,"<anonymous>"):Q,n[3]);let u;(e?.type==="safari"||!i&&e?.type==="firefox")&&e.column?u=e.column:!i&&n[5]&&(u=+n[5]);let r;return(e?.type==="safari"||!i&&e?.type==="firefox")&&e.line?r=e.line:n[4]&&(r=+n[4]),{column:u,evalOrigin:o,file:a,line:r,methodName:c,raw:t,type:i?"eval":a.includes("[native code]")?"native":void 0}}},bn=(t,e)=>{const n=hn.exec(t);if(!(n&&n[2].includes(" > eval"))&&n)return Y(`parse firefox error stack line: "${t}"`,()=>`found: ${JSON.stringify(n)}`),{column:n[4]?+n[4]:e?.column??void 0,file:n[2],line:n[3]?+n[3]:e?.line??void 0,methodName:n[1]||Q,raw:t,type:void 0}},xn=t=>{const e=ln.exec(t);if(e)return Y(`parse react android native error stack line: "${t}"`,()=>`found: ${JSON.stringify(e)}`),{column:e[3]?+e[3]:void 0,file:e[1],line:e[2]?+e[2]:void 0,methodName:Q,raw:t,type:void 0}},dt=(t,{filter:e,frameLimit:n=50}={})=>{const i=t;let s=(typeof i.stacktrace=="string"?i.stacktrace:t.stack??"").split(`
|
|
9
|
+
`).map(o=>(Pe.test(o)?o.replace(Pe,"$1"):o).trim()).filter(o=>!fn.test(o)&&o!=="eval code");return e&&(s=s.filter(o=>e(o))),s=s.slice(0,n),s.reduce((o,c,a)=>{if(!c||c.length>1024)return o;let u;if(mn.test(c))u=yn(c);else if(gn.test(c))u=vn(c);else if(wn.test(c)){let r;if(a===0){const l=t,d=l.columnNumber,h=l.lineNumber,f=l.line,p=l.column;d||h?r={column:d,line:h,type:"firefox"}:(f||p)&&(r={column:p,line:f,type:"safari"})}u=bn(c,r)??$n(c,r)}else u=xn(c);return u?o.push(u):Y(`parse error stack line: "${c}"`,"not parser found"),o},[])},Nn=ct(import.meta.url),te=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,Ie=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 Nn(t)},{existsSync:An,readFileSync:kn}=Ie("node:fs"),{relative:En,resolve:De,sep:Cn}=Ie("node:path"),{cwd:On}=te,{fileURLToPath:_n}=Ie("node:url"),Z=(t,e,n)=>n===0?t:e===" "?t+" ".repeat(n):t+" ".repeat(e*n),ft=t=>t.replaceAll("\\","/"),In=(t,e)=>{const n=t.replace("async file:","file:");return ft(En(e,n.startsWith("file:")?_n(n):n))},Ln=(t,e,n)=>{if(e)return n.title(t.message);const i=t.message?`: ${t.message}`:"";return n.title(t.name+i)},mt=(t,{color:e,hideErrorTitle:n,indentation:i,prefix:s},o)=>`${Z(s,i,o)}${Ln(t,n,e)}
|
|
10
|
+
`,gt=(t,{color:e,indentation:n,prefix:i},s)=>{if(t.hint===void 0)return;const o=Z(i,n,s);let c="";if(Array.isArray(t.hint))for(const a of t.hint)c+=`${o+a}
|
|
11
|
+
`;else c+=o+t.hint;return e.hint(c)},wt=(t,e)=>{if(!e||t.file===void 0||t.line===void 0)return{trace:t};try{const n=e({column:t.column,file:t.file,line:t.line});return n?{source:n.source,trace:{...t,column:n.column??t.column,file:n.file??t.file,line:n.line??t.line}}:{trace:t}}catch{return{trace:t}}},Le=(t,e,n=0)=>{const{color:i,cwd:s,displayShortPath:o,indentation:c,prefix:a}=e,{trace:u}=wt(t,e.sourceMap),r=o?In(u.file,s):ft(u.file),{fileLine:l,method:d}=i;return`${Z(a,c,n)}at ${u.methodName?`${d(u.methodName)} `:""}${l(r)}:${l(u.line?.toString()??"")}`},Sn=(t,e)=>{if(e.allowAllFilePaths)return!0;const n=De(e.cwd),i=De(n,t);return i===n||i.startsWith(n+Cn)},yt=(t,e,n)=>{const{color:i,indentation:s,linesAbove:o,linesBelow:c,prefix:a,showGutter:u,showLineNumbers:r,tabWidth:l}=e,{source:d,trace:h}=wt(t,e.sourceMap);if(h.file===void 0)return;let f;if(d===void 0){const p=h.file.replace("file://","");if(!Sn(p,e)||!An(p))return;f=kn(p,"utf8")}else f=d;return Jt(f,{start:{column:h.column,line:h.line}},{color:i,linesAbove:o,linesBelow:c,prefix:Z(a,s,n),showGutter:u,showLineNumbers:r,tabWidth:l})},vt=(t,e,n)=>{if(t.errors.length===0)return;let i=`${Z(e.prefix,e.indentation,n)}Errors:
|
|
12
|
+
|
|
13
|
+
`,s=!0;for(const o of t.errors)s?s=!1:i+=`
|
|
14
|
+
|
|
15
|
+
`,i+=bt(o,{...e,framesMaxLimit:1,hideErrorCodeView:e.hideErrorErrorsCodeView},n+1);return`
|
|
16
|
+
${i}`},$t=(t,e,n,i=new Set)=>{i.add(t);let s=`${Z(e.prefix,e.indentation,n)}Caused by:
|
|
17
|
+
|
|
18
|
+
`;const o=t.cause;s+=mt(o,e,n);const c=dt(o).shift(),a=gt(o,e,n);if(a&&(s+=`${a}
|
|
19
|
+
`),c&&(s+=Le(c,e,n),!e.hideErrorCauseCodeView)){const u=yt(c,e,n);u!==void 0&&(s+=`
|
|
20
|
+
${u}`)}if(o instanceof AggregateError){const u=vt(o,e,n);u!==void 0&&(s+=`
|
|
21
|
+
${u}`)}return o.cause&&(s+=i.has(o)?`
|
|
22
|
+
${Z(e.prefix,e.indentation,n+1)}Caused by: [Circular]`:`
|
|
23
|
+
${$t(o,e,n+1,i)}`),`
|
|
24
|
+
${s}`},Tn=(t,e)=>(t.length>0?`
|
|
25
|
+
`:"")+t.map(n=>Le(n,e)).join(`
|
|
26
|
+
`),bt=(t,e,n)=>{const i={allowAllFilePaths:!1,cwd:On(),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,...e,color:{fileLine:c=>c,gutter:c=>c,hint:c=>c,marker:c=>c,message:c=>c,method:c=>c,title:c=>c,...e.color}},s=dt(t,{filter:e.filterStacktrace,frameLimit:i.framesMaxLimit}),o=s.shift();return[e.hideMessage?void 0:mt(t,i,n),gt(t,i,n),o?Le(o,i,n):void 0,o&&!i.hideErrorCodeView?yt(o,i,n):void 0,t instanceof AggregateError?vt(t,i,n):void 0,t.cause===void 0?void 0:$t(t,i,n),s.length>0?Tn(s,i):void 0].filter(Boolean).join(`
|
|
27
|
+
`)},Mn=(t,e={})=>{if(e.framesMaxLimit!==void 0&&e.framesMaxLimit<=0)throw new RangeError("The 'framesMaxLimit' option must be a positive number");return bt(t,e,0)};class ie extends Error{loc;title;hint;type="VisulimaError";constructor({cause:e,hint:n,location:i,message:s,name:o,stack:c,title:a}){super(s,{cause:e}),this.title=a,this.name=o,this.stack=c??this.stack,this.loc=i,this.hint=n}setLocation(e){this.loc=e}setName(e){this.name=e}setMessage(e){this.message=e}setHint(e){this.hint=e}}class k extends ie{code;context;constructor(e,n,i){super({message:e,name:"CerebroError"}),this.code=n,this.context=i}}const R=t=>"Deno"in t,W=t=>"Bun"in t,Ce=()=>{if(R(globalThis)){const t=globalThis.Deno,e=t.execPath();let n=e;try{const{importMeta:i}=globalThis;i?.url&&(n=i.url)}catch{}return[e,n,...t.args]}return W(globalThis)?globalThis.Bun.process.argv:process.argv},Pn=()=>R(globalThis)?globalThis.Deno.cwd():W(globalThis)?globalThis.Bun.process.cwd():process.cwd(),ge=()=>{if(R(globalThis)){const t=globalThis.Deno;return new Proxy(t.env.toObject(),{get:(e,n)=>typeof n=="string"?t.env.get(n):e[n],has:(e,n)=>typeof n=="string"?t.env.has(n):n in e,set:(e,n,i)=>typeof n=="string"?(i===void 0||t.env.set(n,i),!0):!1})}return W(globalThis)?globalThis.Bun.process.env:process.env},Dn=()=>R(globalThis)?[]:W(globalThis)?globalThis.Bun.process.execArgv:process.execArgv,Un=()=>R(globalThis)?globalThis.Deno.execPath():W(globalThis)?globalThis.Bun.process.execPath:process.execPath,jn=()=>{if(R(globalThis)){const t=globalThis.Deno.build?.os??"unknown";return t==="windows"?"win32":t}return W(globalThis)?globalThis.Bun.platform??"unknown":process.platform},Vn=()=>{if(R(globalThis)){const t=globalThis.Deno.build?.arch??"unknown";return t==="x86_64"?"x64":t==="aarch64"?"arm64":t}return W(globalThis)?globalThis.Bun.process.arch:process.arch},J=(t=0)=>{if(R(globalThis))throw globalThis.Deno.exit(t),new Error("Deno exit failed");if(W(globalThis))throw globalThis.Bun.process.exit(t),new Error("Bun exit failed");process.exit(t)},Ue=(t,e)=>{if(R(globalThis))return()=>{};if(W(globalThis)){try{const i=globalThis.Bun;if(i.process?.on)return i.process.on(t,e),()=>{i.process?.removeListener&&i.process.removeListener(t,e)}}catch{}return()=>{}}const n=process;return n.on(t,e),()=>{n.removeListener(t,e)}},B=new Uint32Array(65536),Bn=(t,e)=>{const n=t.length,i=e.length,s=1<<n-1;let o=-1,c=0,a=n,u=n;for(;u--;)B[t.charCodeAt(u)]|=1<<u;for(u=0;u<i;u++){let r=B[e.charCodeAt(u)];const l=r|c;r|=(r&o)+o^o,c|=~(r|o),o&=r,c&s&&a++,o&s&&a--,c=c<<1|1,o=o<<1|~(l|c),c&=l}for(u=n;u--;)B[t.charCodeAt(u)]=0;return a},Rn=(t,e)=>{const n=e.length,i=t.length,s=[],o=[],c=Math.ceil(n/32),a=Math.ceil(i/32);for(let p=0;p<c;p++)o[p]=-1,s[p]=0;let u=0;for(;u<a-1;u++){let p=0,g=-1;const $=u*32,w=Math.min(32,i)+$;for(let y=$;y<w;y++)B[t.charCodeAt(y)]|=1<<y;for(let y=0;y<n;y++){const b=B[e.charCodeAt(y)],N=o[y/32|0]>>>y&1,E=s[y/32|0]>>>y&1,I=b|p,O=((b|E)&g)+g^g|b|E;let m=p|~(O|g),v=g&O;m>>>31^N&&(o[y/32|0]^=1<<y),v>>>31^E&&(s[y/32|0]^=1<<y),m=m<<1|N,v=v<<1|E,g=v|~(I|m),p=m&I}for(let y=$;y<w;y++)B[t.charCodeAt(y)]=0}let r=0,l=-1;const d=u*32,h=Math.min(32,i-d)+d;for(let p=d;p<h;p++)B[t.charCodeAt(p)]|=1<<p;let f=i;for(let p=0;p<n;p++){const g=B[e.charCodeAt(p)],$=o[p/32|0]>>>p&1,w=s[p/32|0]>>>p&1,y=g|r,b=((g|w)&l)+l^l|g|w;let N=r|~(b|l),E=l&b;f+=N>>>i-1&1,f-=E>>>i-1&1,N>>>31^$&&(o[p/32|0]^=1<<p),E>>>31^w&&(s[p/32|0]^=1<<p),N=N<<1|$,E=E<<1|w,l=E|~(y|N),r=N&y}for(let p=d;p<h;p++)B[t.charCodeAt(p)]=0;return f},Wn=(t,e)=>{if(t.length<e.length){const n=e;e=t,t=n}return e.length===0?t.length:t.length<=32?Bn(t,e):Rn(t,e)},zn=_e(import.meta.url),ae=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,Fn=t=>{if(typeof ae<"u"&&ae.versions&&ae.versions.node){const[e,n]=ae.versions.node.split(".").map(Number);if(e>22||e===22&&n>=3||e===20&&n>=16)return ae.getBuiltinModule(t)}return zn(t)},{createRequire:qn}=Fn("node:module"),xt=String.raw,je=xt`\p{Emoji}(?:\p{EMod}|[\u{E0020}-\u{E007E}]+\u{E007F}|\uFE0F?\u20E3?)`,Gn=()=>new RegExp(xt`\p{RI}{2}|(?)${je}(?:\u200D${je})*`,"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 rs=/^[ \t]*(?:\r\n|\r|\n)/,as=/(?:\r\n|\r|\n)[ \t]*$/,ls=/^(?:[\r\n]|$)/,cs=/(?:\r\n|\r|\n)([ \t]*)(?:[^ \t\r\n]|$)/,us=/^[ \t]*[\r\n][ \t\r\n]*$/,hs=/\r\n|\n|\r/g,ps=/[\u001B\u009B](?:[[()#;?]{0,10}(?:\d{1,4}(?:;\d{0,4})*)?[0-9A-ORZcf-nqry=><]|\]8;;[^\u0007\u001B]{0,100}(?:\u0007|\u001B\\))/g,ds=/[\u0000-\u0008\n-\u001F\u007F-\u009F]{1,1000}/y,q=Gn(),Hn=/[-_./\s]+/g,me=/(\u001B\[[0-9;]*[a-z])/i,Ve=new RegExp("\\p{Script=Arabic}","u"),Jn=new RegExp("\\p{Script=Bengali}","u"),X=new RegExp("\\p{Script=Cyrillic}","u"),Kn=new RegExp("\\p{Script=Devanagari}","u"),Yn=new RegExp("\\p{Script=Ethiopic}","u"),ve=new RegExp("\\p{Script=Greek}","u"),Be=new RegExp("\\p{Script=Greek}+|\\p{Script=Latin}+|[^\\p{Script=Greek}\\p{Script=Latin}]+","gu"),Qn=new RegExp("\\p{Script=Gujarati}","u"),Zn=new RegExp("\\p{Script=Gurmukhi}","u"),Re=new RegExp("\\p{Script=Hangul}","u"),We=new RegExp("\\p{Script=Hebrew}","u"),Xn=new RegExp("\\p{Script=Hiragana}","u"),ze=new RegExp("\\p{Script=Han}","u"),ei=new RegExp("\\p{Script=Kannada}","u"),ti=new RegExp("\\p{Script=Katakana}","u"),ni=new RegExp("\\p{Script=Khmer}","u"),ii=new RegExp("\\p{Script=Lao}","u"),M=new RegExp("\\p{Script=Latin}","u"),oi=new RegExp("\\p{Script=Malayalam}","u"),si=new RegExp("\\p{Script=Myanmar}","u"),ri=new RegExp("\\p{Script=Oriya}","u"),ai=new RegExp("\\p{Script=Sinhala}","u"),li=new RegExp("\\p{Script=Tamil}","u"),ci=new RegExp("\\p{Script=Telugu}","u"),ui=new RegExp("\\p{Script=Thai}","u"),hi=new RegExp("\\p{Script=Tibetan}","u"),Fe=/[\u02BB\u02BC\u0027]/u,pi=t=>t.replace(q,"");let di=class{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}};const fi=qn(import.meta.url),le=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,mi=t=>{if(typeof le<"u"&&le.versions&&le.versions.node){const[e,n]=le.versions.node.split(".").map(Number);if(e>22||e===22&&n>=3||e===20&&n>=16)return le.getBuiltinModule(t)}return fi(t)},{stripVTControlCharacters:gi}=mi("node:util"),$e=new di(1e3),wi=/[.*+?^${}()|[\]\\]/g,yi=t=>{const e=t.join("");if($e.has(e)){const s=$e.get(e);return s.lastIndex=0,s}const n=t.map(s=>s.replaceAll(wi,String.raw`\$&`)).join("|"),i=new RegExp(n,"g");return $e.set(e,i),i},vi=t=>{const e=[];let n=0,i;for(q.lastIndex=0;(i=q.exec(t))!==null;)i.index>n&&e.push(t.slice(n,i.index)),e.push(i[0]),n=q.lastIndex;return n<t.length&&e.push(t.slice(n)),e.filter(Boolean)},$i=/[ČŠŽĐ]/i,Nt=new Uint8Array(128),At=new Uint8Array(128),kt=new Uint8Array(128);for(let t=0;t<128;t++)Nt[t]=t>=65&&t<=90?1:0,At[t]=t>=97&&t<=122?1:0,kt[t]=t>=48&&t<=57?1:0;const be=t=>Nt[t],qe=t=>At[t],xe=t=>kt[t],z=(t,e,n,i,s)=>{if(t.length===0)return[];let o=!1;const c=Object.values(e);for(const f of c)if(f(t[0])){o=!0;break}if(!o&&!n)return[t];const a=[...t],u=[];let r=a[0],l="other";const d=Object.entries(e);for(const f of d){const[p,g]=f;if(g(a[0])){l=p;break}}let h=n&&i?a[0]===a[0].toLocaleUpperCase(i):!1;for(let f=1;f<a.length;f++){const p=a[f];let g="other";for(const y of d){const[b,N]=y;if(N(p)){g=b;break}}const $=n&&i?p===p.toLocaleUpperCase(i):!1;let w=!1;s?w=s(l,g,h,$,p,f,a):(l!==g&&l!=="other"&&g!=="other"&&(w=!0),n&&g!=="other"&&!h&&$&&(w=!0)),w?(u.push(r),r=p):r+=p,l=g,n&&(h=$)}return r&&r.length>0&&u.push(r),u.length>0?u:[t]},bi=(t,e,n,i)=>{if(n.size===0)return e;for(const s of n)if(t.startsWith(s,e))return i.push(s),e+s.length;return e},Et=(t,e=new Set)=>{if(t.length===0)return[];if(t.toUpperCase()===t)return[t];let n=0;const i=[],s=t.length;for(let o=1;o<s;o++){const c=bi(t,n,e,i);if(c!==n){n=c,o=n-1;continue}const a=t.codePointAt(o-1),u=t.codePointAt(o),r=a&&a<128&&be(a),l=u&&u<128&&be(u),d=a&&a<128&&qe(a),h=a&&a<128&&xe(a),f=u&&u<128&&xe(u);if(d&&l){i.push(t.slice(n,o)),n=o;continue}if(h&&!f||!h&&f){i.push(t.slice(n,o)),n=o;continue}if(f&&!h){let p=!1,g=!1;if(o+1<s){const $=t.codePointAt(o+1);p=$&&$<128&&be($),g=$&&$<128&&xe($)}if(!g&&p){i.push(t.slice(n,o),t.slice(o,o+1)),n=o+1;continue}}if(o+1<s){const p=t.codePointAt(o+1),g=p&&p<128&&qe(p);if(r&&l&&g){const $=t.slice(n,o+1);e.has($)||(i.push(t.slice(n,o)),n=o)}}}return n<s&&i.push(t.slice(n)),i.filter(o=>o!=="")},Ct=(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 r=[...t],l=r.length,d=[];let h=r[0],f=r[0]===r[0].toLocaleUpperCase(e),p=f,g=f?0:-1;for(let $=1;$<l;$++){const w=r[$],y=w===w.toLocaleUpperCase(e);if(y===f)h+=w;else if(y)h&&h.length>0&&(d.push(h),h=w),p=!0,g=$;else{if(p&&$-g>1){const b=r[$-1],N=h.slice(0,-1);N&&N.length>0&&d.push(N),h=b+w}else h+=w;p=!1,g=-1}f=y}return h&&h.length>0&&d.push(h),d}if(e.startsWith("uk")||e.startsWith("ru")||e.startsWith("bg")||e.startsWith("sr")||e.startsWith("mk")||e.startsWith("be")){if(!X.test(t)&&!M.test(t))return[t];const r=[...t],l=r.length,d=[];let h=r[0];const f=r[0];let p;X.test(f)?p=1:M.test(f)?p=2:p=0;let g=f===f.toLocaleUpperCase(e);for(let w=1;w<l;w++){const y=r[w];let b;X.test(y)?b=1:M.test(y)?b=2:b=0;const N=y===y.toLocaleUpperCase(e);p!==b&&(p===1||p===2)&&(b===1||b===2)||b===p&&!g&&N?(d.push(h),h=y):h+=y,p=b,g=N}h&&h.length>0&&d.push(h);const $=[];for(let w=0;w<d.length;w++)w<d.length-1&&d[w].length===1&&M.test(d[w])&&X.test(d[w+1][0])?($.push(d[w]+d[w+1]),w+=1):$.push(d[w]);return $}if(e.startsWith("el")){if(!ve.test(t)&&!M.test(t))return[t];const r=[];Be.lastIndex=0;let l;for(;(l=Be.exec(t))!==null;)r.push(l[0]);r.length===0&&r.push(t);const d=[];if(r.length===1){const h=r[0];if(!h||!ve.test(h[0])||h.length===1)return[h??t]}for(const h of r){if(!h)continue;if(!ve.test(h[0])||h.length===1){d.push(h);continue}const f=h.length;let p=h[0],g=h[0]===h[0].toLocaleUpperCase(e);for(let $=1;$<f;$++){const w=h[$],y=w===w.toLocaleUpperCase(e);!g&&y?(d.push(p),p=w):p+=w,g=y}p&&d.push(p)}return d}if(e.startsWith("ja")||e.startsWith("ko")){const r=e.startsWith("ja"),l=r?{hiragana:h=>Xn.test(h),kanji:h=>ze.test(h),katakana:h=>ti.test(h),latin:h=>M.test(h)}:{hangul:h=>Re.test(h),latin:h=>M.test(h)},d=new Set(["が","で","と","に","の","は","へ","も","や","を"]);if(r){const h=z(t,l,!1,e,(p,g)=>p==="hiragana"&&g==="katakana"||p==="katakana"&&g==="hiragana"||p==="hiragana"&&g==="latin"||p==="katakana"&&g==="latin"||p==="kanji"&&g==="latin"||p==="latin"&&(g==="hiragana"||g==="katakana"||g==="kanji")),f=[];for(const p of h){const g=p;g.length===1&&d.has(g)&&f.length>0?f[f.length-1]=f.at(-1)+g:f.push(g)}return f.length>0?f:[t]}return z(t,l,!1,e,(h,f)=>h==="hangul"&&f==="latin"||h==="latin"&&f==="hangul")}if(e.startsWith("sl")){const r=[...t],l=r.length,d=[];let h=r[0],f=r[0]===r[0].toLocaleUpperCase(e);for(let p=1;p<l;p++){const g=r[p],$=g===g.toLocaleUpperCase(e),w=$i.test(g),y=p<l-1&&r[p+1]===r[p+1].toLocaleUpperCase(e);!f&&$||w&&y?(d.push(h),h=g,w&&y&&(d.push(h),h="")):h+=g,f=$}return h&&h.length>0&&d.push(h),d}if(e.startsWith("zh"))return z(t,{han:r=>ze.test(r),latin:r=>M.test(r)},!1,e);if(["ar","fa","he","ur"].includes(e.split("-")[0])){const r=l=>We.test(l)||Ve.test(l);return z(t,{latin:l=>M.test(l),rtl:l=>r(l)},!1,e)}if(["am","bn","gu","hi","km","kn","lo","ml","mr","ne","or","pa","si","ta","te","th"].includes(e.split("-")[0])){const r=l=>Kn.test(l)||Jn.test(l)||Qn.test(l)||Zn.test(l)||ei.test(l)||li.test(l)||ci.test(l)||oi.test(l)||ai.test(l)||ui.test(l)||ii.test(l)||hi.test(l)||si.test(l)||Yn.test(l)||ni.test(l)||ri.test(l);return z(t,{indic:l=>r(l),latin:l=>M.test(l)},!1,e)}if(["be","bg","ru","sr","uk"].includes(e))return z(t,{cyrillic:r=>X.test(r),latin:r=>M.test(r)},!0,e);if(["ar","fa","he"].includes(e))return z(t,{latin:r=>M.test(r),rtl:r=>We.test(r)||Ve.test(r)},!1,e);if(e.startsWith("ko"))return z(t,{hangul:r=>Re.test(r),latin:r=>M.test(r)},!1,e);if(e.startsWith("uz")){if(!X.test(t)&&!M.test(t))return[t];const r=[...t],l=r.length,d=[];let h=r[0],f=r[0]===r[0].toLocaleUpperCase(e);for(let p=1;p<l;p++){const g=r[p],$=g===g.toLocaleUpperCase(e);if(Fe.test(g)||Fe.test(r[p-1])){h+=g;continue}!f&&$?(d.push(h),h=g):h+=g,f=$}return h&&h.length>0&&d.push(h),d}const s=[...t],o=s.length,c=[];let a=s[0],u=s[0]===s[0].toLocaleUpperCase(e);for(const r of n)if(t.startsWith(r)){c.push(r),a=s[r.length],u=a===a.toLocaleUpperCase(e);break}for(let r=1;r<o;r++){const l=s[r],d=l===l.toLocaleUpperCase(e);let h=0;for(const f of n)if(t.startsWith(f,r)){c.push(a,f),h=f.length,a="";const p=f.at(-1);p&&(u=p===p.toLocaleUpperCase(e));break}if(h>0){r+=h-1;continue}!u&&d?(c.push(a),a=l):a+=l,u=d}return a&&c.push(a),c},xi=(t,e,n)=>{const i=[],s=me.test(t)?t.split(me).filter(Boolean):[t];for(const o of s){const c=o;if(me.test(c))i.push(c);else{q.lastIndex=0;const a=q.test(c)?vi(c).filter(Boolean):[c];for(const u of a)if(q.lastIndex=0,q.test(u))i.push(u);else if(e){const r=e.toLowerCase().split("-")[0];i.push(...Ct(u,r,n))}else i.push(...Et(u,n))}}return i},Ni=(t,e={})=>{if(!t||typeof t!="string")return[];const{handleAnsi:n=!1,handleEmoji:i=!1,knownAcronyms:s=[],locale:o,normalize:c=!1,separators:a,stripAnsi:u=!1,stripEmoji:r=!1}=e,l=new Set([...s].toSorted((w,y)=>y.length-w.length));let d=t;u&&(d=gi(d)),r&&(d=pi(d));let h;Array.isArray(a)?h=yi(a):a instanceof RegExp?h=a:h=Hn;const f=[];let p=d;const g=h.flags.includes("g")?h:new RegExp(h.source,`${h.flags}g`);for(;p.length>0;){const w=g.exec(p);if(!w){p===".."?f.push(".."):p==="."?f.push("."):p.length>0&&f.push(p);break}const y=w.index,b=w[0],N=b.length,E=p.slice(0,y),I=p.slice(y+N);if(b.startsWith("../"))f.push(".."),p=p.slice(y+3);else if(b.startsWith("./"))f.push("."),p=p.slice(y+2);else if(y===0&&b==="..")f.push(".."),p=p.slice(2);else if(y===0&&b===".")f.push("."),p=p.slice(1);else{E.length>0&&f.push(E);let O=0;for(;(O=b.indexOf("../",O))!==-1;)f.push(".."),O+=3;for(O=0;(O=b.indexOf("./",O))!==-1;)(O===0||b[O-1]!==".")&&f.push("."),O+=2;let m=I;for(;m.startsWith("../");)f.push(".."),m=m.slice(3);for(;m.startsWith("./");)f.push("."),m=m.slice(2);if(m===".."){f.push("..");break}else if(m==="."){f.push(".");break}else p=m}g.lastIndex=0}if(f.length===0){const w=d.split(h).filter(Boolean);f.push(...w)}let $=[];for(const w of f)n||i?$.push(...xi(w,o,l)):o?$.push(...Ct(w,o,l)):$.push(...Et(w,l));return c&&($=$.map(w=>l.has(w)?w:o&&w===w.toLocaleUpperCase(o)?w[0]+w.slice(1).toLocaleLowerCase(o):w.toUpperCase()===w&&!l.has(w)?w.slice(0,1)+w.slice(1).toLowerCase():w)),$},Ai=_e(import.meta.url),ce=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,ki=t=>{if(typeof ce<"u"&&ce.versions&&ce.versions.node){const[e,n]=ce.versions.node.split(".").map(Number);if(e>22||e===22&&n>=3||e===20&&n>=16)return ce.getBuiltinModule(t)}return Ai(t)},{writeFile:Ei,stat:Ci,rm:Oi,readFile:Ge,readdir:_i,mkdir:Ii,access:Li}=ki("node:fs/promises"),he=[{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}];let G=class extends k{commandName;constructor(t,e=[]){const n=`Command "${t}" not found${e.length>0?`. Did you mean: ${e.join(", ")}?`:""}`;super(n,"COMMAND_NOT_FOUND",{commandName:t,suggestions:e}),this.name="CommandNotFoundError",this.commandName=t,e.length>0&&(this.hint=`Try one of these commands: ${e.join(", ")}`)}},Ot=class extends k{option1;option2;constructor(t,e){super(`Options "${t}" and "${e}" cannot be used together`,"CONFLICTING_OPTIONS",{option1:t,option2:e}),this.name="ConflictingOptionsError",this.option1=t,this.option2=e,this.hint=`Remove either --${t} or --${e}`}},Si=class extends k{unknownOptions;constructor(t,e){const n=t.join(", "),i=`Found unknown ${t.length===1?"option":"options"}: ${n}`;super(i,"UNKNOWN_OPTION",{suggestions:e,unknownOptions:t}),this.name="UnknownOptionError",this.unknownOptions=t,e&&e.length>0&&(this.hint=`Did you mean: ${e.join(", ")}?`)}},Ti=class extends k{pluginName;constructor(t,e,n){super(`Plugin "${t}" error: ${e}`,"PLUGIN_ERROR",{originalError:n,pluginName:t}),this.name="PluginError",this.pluginName=t,n&&(this.cause=n)}},Mi=class{logger;plugins=new Map;initialized=!1;cachedDependencyOrder=void 0;constructor(t){this.logger=t}hasPlugins(){return this.plugins.size>0}register(t){if(this.initialized)throw new Error(`Cannot register plugin "${t.name}" after initialization`);if(this.plugins.has(t.name))throw new Error(`Plugin "${t.name}" is already registered`);ge().CEREBRO_OUTPUT_LEVEL===String(V)&&this.logger.debug(`registering plugin: ${t.name}`),this.plugins.set(t.name,t),this.cachedDependencyOrder=void 0}async init(t){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 e=this.getDependencyOrder();this.logger.debug(`initializing ${String(e.length)} plugin(s)...`);for(const n of e)if(typeof n.init=="function"){this.logger.debug(`initializing plugin: ${n.name}`);try{await n.init(t)}catch(i){const s=new Ti(n.name,`Failed to initialize: ${i instanceof Error?i.message:String(i)}`,i instanceof Error?i:void 0);throw this.logger.error(s.message),s}}this.initialized=!0}async executeLifecycle(t,e,n){if(!this.initialized)throw new Error("PluginManager not initialized");if(this.plugins.size===0)return;const i=this.getDependencyOrder();for(const s of i){const o=s[t];if(typeof o=="function"){this.logger.debug(`executing ${t} hook for plugin: ${s.name}`);try{await(t==="afterCommand"?o(e,n):o(e))}catch(c){throw this.logger.error(`Error in ${t} hook for plugin "${s.name}":`,c),c}}}}async executeErrorHandlers(t,e){if(!this.initialized||this.plugins.size===0)return;const n=this.getDependencyOrder();for(const i of n)if(typeof i.onError=="function"){this.logger.debug(`executing error handler for plugin: ${i.name}`);try{await i.onError(t,e)}catch(s){this.logger.error(`Error in error handler for plugin "${i.name}":`,s)}}}getDependencyOrder(){if(this.cachedDependencyOrder!==void 0)return this.cachedDependencyOrder;const t=[],e=new Set,n=new Set,i=s=>{if(e.has(s))return;if(n.has(s))throw new Error(`Circular dependency detected involving plugin "${s}"`);const o=this.plugins.get(s);if(!o)throw new Error(`Plugin "${s}" not found`);if(n.add(s),o.dependencies)for(const c of o.dependencies)i(c);n.delete(s),e.add(s),t.push(o)};for(const s of this.plugins.keys())i(s);return this.cachedDependencyOrder=t,t}validateDependencies(){for(const t of this.plugins.values())if(t.dependencies){for(const e of t.dependencies)if(!this.plugins.has(e))throw new Error(`Plugin "${t.name}" depends on "${e}" which is not registered`)}}};const ue=t=>t.type?.name==="Boolean",Pi=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},He=t=>(ue(t)||(t.typeLabel=t.typeLabel??Pi(t),t.defaultOption&&(t.typeLabel=`${t.typeLabel} (D)`),t.required&&(t.typeLabel=`${t.typeLabel} (R)`)),t),Di=new RegExp(/^-([^\d-])$/),Ui=new RegExp(/^--(\S+)/),ji=new RegExp(/^-([^\d-]{2,})$/),Vi=t=>Di.test(t)||Ui.test(t)||ji.test(t),Bi=(t,e)=>{const n=e[0]&&Vi(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}};class Se extends ie{optionName;value;constructor(e,n,i){super({hint:`Pass a valid ${i} value for '${e}'.`,message:`Invalid ${i} value '${n}' for option '${e}'`,name:"INVALID_VALUE",title:"Invalid Value"}),this.optionName=e,this.value=n,Object.setPrototypeOf(this,Se.prototype)}}let Ri=class _t extends ie{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,_t.prototype)}},Je=class It extends ie{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,It.prototype)}},Wi=class Lt extends ie{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,Lt.prototype)}};class S extends ie{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,S.prototype)}}const Ke=(t,e,n)=>{const i=Number(t);if(e&&Number.isNaN(i)&&String(t).trim().toLowerCase()!=="nan")throw new Se(n??"",String(t),"Number");return i},Ye=t=>t===Boolean||typeof t=="function"&&t.name==="Boolean",Qe=t=>t===Number||typeof t=="function"&&t.name==="Number",Ze=t=>t===String||typeof t=="function"&&t.name==="String",zi=(t,e,n={})=>{const{optionName:i,strictTypes:s}=n;return Array.isArray(t)?Ye(e)?t.map(Boolean):Qe(e)?t.map(o=>Ke(o,s,i)):Ze(e)?t.map(String):t.map(o=>e(String(o))):t===null?null:Ye(e)?!!t:Qe(e)?Ke(t,s,i):Ze(e)?typeof t=="string"?t:String(t):e(typeof t=="string"?t:String(t))},_=(t,e,n,...i)=>{t&&console.debug(`[command-line-args:${n}] ${e}`,...i)},Fi=/-([a-z])/g,qi=/^\d+$/,pe=t=>t===Boolean||typeof t=="function"&&t.name==="Boolean",Gi=t=>t.codePointAt(0)===95,Xe=(t,e)=>Array.isArray(t)?[...t,...e]:[t,...e],et=t=>t==="__proto__"||t==="constructor"||t==="prototype",tt=(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]},nt=(t,e,n,i,s)=>{let o=e.get(t)??n.get(t);if(!o&&i){const c=t.toLowerCase();o=i.get(c)??s?.get(c)}return o},Hi=(t,e,n,i)=>{const s=n.debug??!1;_(s,"resolveArgs called with options:","resolver",{partial:n.partial,stopAtFirstUnknown:n.stopAtFirstUnknown}),_(s,"Starting argument resolution","resolver"),_(s,"Tokens:","resolver",t),_(s,"Definitions:","resolver",e),_(s,"Processing tokens...","resolver");const o=new Map,c=new Map,a=n.caseInsensitive?new Map:void 0,u=n.caseInsensitive?new Map:void 0,r=n.camelCase?new Map:void 0,l=n.camelCase?new Map:void 0;for(const m of e)if(o.set(m.name,m),m.alias&&c.set(m.alias,m),n.caseInsensitive&&a&&(a.set(m.name.toLowerCase(),m),m.alias&&u&&u.set(m.alias.toLowerCase(),m)),n.camelCase&&r&&l){const v=m.name.replaceAll(Fi,(x,L)=>L.toUpperCase());r.set(m.name,v),l.set(v,m.name)}const d=Object.create(null),h=Object.create(null),f=[],p=[],g=new Set;let $=!1;const w=e.find(m=>m.defaultOption),y=e.some(m=>m.group),b=e.find(m=>m.type===Number);for(let m=0;m<t.length;m++){const v=t[m];if(v.kind==="option-terminator"){d._unknown=i.slice(v.index),$=!0;break}if(v.kind==="option"&&v.name){let x=nt(v.name,o,c,a,u);!x&&v.value===void 0&&b&&qi.test(v.name)&&(x=b,v.value=v.name,v.name=b.name);let L=!1;if(!x&&n.negation&&v.value===void 0&&v.name.startsWith("no-")){const C=v.name.slice(3),P=nt(C,o,c,a,u);P?.type&&pe(P.type)&&(x=P,L=!0)}const A=x?x.name:v.name,T=x?.multiple,D=x?.lazyMultiple;if(Object.hasOwn(h,A)&&h[A]!==void 0&&!T&&!D&&!n.partial)throw new Ri(A);if(!x&&n.partial){const C=v.rawName??`--${v.name}${v.value!==void 0&&v.inlineValue?`=${v.value}`:""}`;f.push({index:v.index,value:C});continue}if(!x&&n.stopAtFirstUnknown){d._unknown=i.slice(v.index);break}if(!x&&!n.partial)throw new Je(v.name);if(v.value===void 0){const C=t[m+1],P=C?.kind==="option"&&!("name"in C)&&C.value!==void 0,U=C&&x&&!(x.type&&pe(x.type))&&(C.kind==="positional"||P),Dt=x&&x.defaultOption&&!x.multiple&&!x.lazyMultiple;if(U&&(!x?.defaultOption||Dt))if(T){let j=m+1;const we=[];for(;j<t.length&&(t[j].kind==="positional"||t[j].kind==="option"&&!("name"in t[j])&&t[j].value!==void 0);)we.push(t[j].value),g.add(t[j].index),j++;h[A]=h[A]===void 0?we:Xe(h[A],we),m=j-1}else D?(tt(h,A,C.value,!0),g.add(C.index),m++):(h[A]=C.value,g.add(C.index),m++);else x?.type&&pe(x.type)?tt(h,A,!L,T):h[A]=T?[]:null}else{let{value:C}=v;if(x?.type&&pe(x.type))switch(C){case"":{if(n.partial){h._unknown??=[];const U=`${v.rawName??`--${v.name}`}${v.value?`=${v.value}`:""}`;h._unknown.push(U),p.push({index:v.index,value:U}),C=!0}else throw new Je(v.name);break}case"false":{C=!1;break}case"true":{C=!0;break}default:C=!0}const P=[C];if(T){let U=m+1;for(;U<t.length&&t[U].kind==="positional";)P.push(t[U].value),g.add(t[U].index),U++;m=U-1}h[A]===void 0?h[A]=T||D?P:C:T||D?h[A]=Xe(h[A],P):h[A]=C}}else if(v.kind==="positional"&&n.stopAtFirstUnknown&&!g.has(v.index)&&!w){_(s,`Found unconsumed positional token at index ${String(v.index)}, stopping processing`,"resolver"),d._unknown=i.slice(v.index);break}}for(const[m,v]of Object.entries(h)){const x=o.get(m);x&&(x.multiple||x.lazyMultiple)&&!Array.isArray(v)&&(h[m]=[v])}const N=m=>m.kind==="option"&&!o.has(m.name??"")&&!c.has(m.name??"")&&(!n.caseInsensitive||!a?.has(m.name?.toLowerCase()??"")&&!u?.has(m.name?.toLowerCase()??""));let E=-1,I=Number.POSITIVE_INFINITY;if(n.stopAtFirstUnknown&&!$&&(E=t.findIndex(m=>N(m)),E!==-1&&(I=t[E].index)),w){const m=[],v=[];for(const x of t)x.kind==="positional"&&!g.has(x.index)&&x.index<I&&(m.push(x.value),v.push(x));if(m.length>0){const x=h[w.name],L=w.multiple??w.lazyMultiple;x===void 0?L?(v.forEach(A=>g.add(A.index)),h[w.name]=m):(g.add(v[0].index),h[w.name]=m[0]):L&&(v.forEach(A=>g.add(A.index)),h[w.name]=Array.isArray(x)?[...m,...x]:[...m,x])}}if(!n.partial){for(const m of t)if(m.kind==="positional"&&!g.has(m.index))throw new Wi(i[m.index])}if(n.partial&&!n.stopAtFirstUnknown){const m=[...f];if(h._unknown)for(const v of p)m.push({index:v.index,value:v.value});for(const v of t)v.kind==="positional"&&!g.has(v.index)&&m.push({index:v.index,value:i[v.index]});m.length>0&&(m.sort((v,x)=>v.index-x.index),d._unknown=m.map(v=>v.value))}if(n.stopAtFirstUnknown&&!$){const m=t.findIndex(x=>x.kind==="positional"&&!g.has(x.index));let v=-1;if(E!==-1&&m!==-1?v=Math.min(E,m):E!==-1?v=E:m!==-1&&(v=m),v>=0){const x=t[v].index;d._unknown=i.slice(x)}}else f.length>0&&!n.partial&&(d._unknown=f.map(m=>m.value));for(const[m,v]of Object.entries(h)){const x=n.camelCase?r?.get(m)??m:m,L=o.get(m);L?.type?d[x]=zi(v,L.type,{optionName:L.name,strictTypes:n.strictTypes}):d[x]=v===void 0?null:v}for(const m of e){const v=n.camelCase?r?.get(m.name)??m.name:m.name;!(v in d)&&m.defaultValue!==void 0&&(m.multiple??m.lazyMultiple?d[v]=Array.isArray(m.defaultValue)?[...m.defaultValue]:[m.defaultValue]:d[v]=m.defaultValue)}if(y){const m={},v={},x={};for(const A of e)if(A.group){const T=Array.isArray(A.group)?A.group:[A.group];for(const D of T)et(D)||(m[D]??={})}for(const A of Object.keys(d))if(!Gi(A)){v[A]=d[A];let T=A;n.camelCase&&(T=l?.get(A)??A);const D=o.get(T);if(D?.group){const C=Array.isArray(D.group)?D.group:[D.group];for(const P of C)et(P)||m[P]&&(m[P][A]=d[A])}else x[A]=d[A]}const L={_all:v};for(const[A,T]of Object.entries(m))L[A]=T;Object.keys(x).length>0&&(L._none=x),d._unknown&&(L._unknown=d._unknown),Object.keys(d).forEach(A=>delete d[A]),Object.assign(d,L)}const O=Object.defineProperties({},Object.getOwnPropertyDescriptors(d));return _(s,"Final parsed result:","resolver",O),O},ne="-".codePointAt(0),K="=",Ji=K.codePointAt(0),Ki="--",Yi="-",Qi="--",St=t=>t.length>2&&t.startsWith(Qi),Zi=t=>St(t)&&!t.includes(K,3),Xi=t=>St(t)&&t.includes(K,3),eo=t=>{if(t.length!==2||t.codePointAt(0)!==ne||t.codePointAt(1)===ne)return!1;const e=t.codePointAt(1);return e!==void 0&&(e<48||e>57)},to=t=>!(t.length<=2||t.codePointAt(0)!==ne||t.codePointAt(1)===ne),no=t=>{const e=[];let n=0,i=[],s=0,o=-1,c=0;for(;s<i.length||n<t.length;){let a;if(s<i.length?(a=i[s],s++):(a=t[n],n++),c>0?c--:o++,a===Ki){e.push({index:o,kind:"option-terminator"});const u=[...i.slice(s),...t.slice(n)],r=u.map((l,d)=>({index:o+d+1,kind:"positional",value:l}));e.push(...r),o+=u.length;break}if(eo(a)){const u=a.charAt(1);e.push({index:o,kind:"option",name:u,rawName:a});continue}if(to(a)&&!a.includes(K)){const u=[];let r="",l=!1;for(let d=1;d<a.length;d++){const h=a.charAt(d);l?r+=h:h.codePointAt(0)===Ji?l=!0:u.push(`${Yi}${h}`)}if(l)if(u.length>0){const d=u.pop();u.push(`${d}=${r}`)}else u.push(r);i=s<i.length?[...u,...i.slice(s)]:u,s=0,c=u.length;continue}if(Zi(a)){const u=a.slice(2);e.push({index:o,kind:"option",name:u,rawName:a});continue}if(Xi(a)){const u=a.indexOf(K),r=a.slice(2,u),l=a.slice(u+1);e.push({index:o,inlineValue:!0,kind:"option",name:r,rawName:a,value:l});continue}if(a.length>2&&a.codePointAt(0)===ne&&a.codePointAt(1)!==ne&&a.includes(K)){const u=a.indexOf(K),r=a.charAt(1),l=a.slice(u+1);e.push({index:o,inlineValue:!0,kind:"option",name:r,rawName:a,value:l});continue}e.push({index:o,kind:"positional",value:a})}return e},io=/\d/,oo=t=>t===Boolean||typeof t=="function"&&t.name==="Boolean",so=t=>typeof t=="function",ro=(t,e,n)=>{const i=n?.debug??!1;_(i,"Validating definitions:","validation",t,"caseInsensitive:",e);const s=new Set,o=new Set,c=new Set,a=new Set;let u=0;for(const r of t){if(_(i,"Checking definition:","validation",r),!r.name)throw _(i,"Validation failed: name is required","validation"),new S("Invalid option definition: name is required");if(typeof r.name!="string")throw new S("Invalid option definition: name must be a string");if(r.name.trim()==="")throw new S("Invalid option definition: name cannot be empty");const l=e?r.name.toLowerCase():"";if(s.has(r.name)||e&&c.has(l))throw new S(`Invalid option definition: duplicate name '${r.name}'`);if(o.has(r.name)||e&&a.has(l))throw new S(`Invalid option definition: name '${r.name}' conflicts with an existing alias`);if(s.add(r.name),e&&c.add(l),r.alias!==void 0){if(typeof r.alias!="string")throw new S("Invalid option definition: alias must be a string");if(r.alias.length!==1)throw new S("Invalid option definition: alias must be a single character");if(io.test(r.alias))throw new S("Invalid option definition: alias cannot be numeric");if(r.alias==="-")throw new S('Invalid option definition: alias cannot be "-"');const d=e?r.alias.toLowerCase():"";if(o.has(r.alias)||e&&a.has(d))throw new S(`Invalid option definition: duplicate alias '${r.alias}'`);if(s.has(r.alias)||e&&c.has(d))throw new S(`Invalid option definition: alias '${r.alias}' conflicts with an existing option name`);o.add(r.alias),e&&a.add(d)}if(r.defaultOption&&(u++,r.type!==void 0&&oo(r.type)))throw new S("Invalid option definition: defaultOption cannot be Boolean type");if(r.type!==void 0&&!(r.type===Boolean||r.type===Number||r.type===String||typeof r.type=="function"&&so(r.type)))throw new S("Invalid option definition: invalid type")}if(u>1)throw _(i,"Validation failed: multiple defaultOptions not allowed","validation"),new S("Invalid option definition: multiple defaultOptions not allowed");_(i,"Validation completed successfully","validation")};function ao(t,e={}){const n=e.debug??!1;_(n,"Starting command-line-args parsing","index"),_(n,"Options:","index",e);const i={...e};i.stopAtFirstUnknown&&(i.partial=!0);const s=Array.isArray(t)?t:[t];_(n,"Normalized definitions:","index",s),ro(s,i.caseInsensitive,n?i:void 0);let{argv:o}=i;if(!o&&(o=process.argv.slice(2),process.execArgv.length>0)){const r=new Set(process.execArgv);o=o.filter(l=>!r.has(l))}_(n,"Using argv:","index",o);let c=o;i.caseInsensitive&&(c=o.map(r=>{if(r.startsWith("--")){const l=r.indexOf("="),d=(l===-1?r.slice(2):r.slice(2,l)).toLowerCase();return l===-1?`--${d}`:`--${d}${r.slice(l)}`}if(r.startsWith("-")&&!r.startsWith("--")&&r.length>1){const l=r.slice(1).split("=",2),d=l[0],h=l[1];if(!d)return r;const f=d.toLowerCase();return h===void 0?`-${f}`:`-${f}=${h}`}return r}));const a=no(c.map(String));_(n,"Tokenized arguments:","index",a);const u=Hi(a,s,i,o);return _(n,"Command-line-args parsing completed","index"),u}class lo{result;argv;options;argument;command;commandName;env;logger;console;fs;process;runtime;rawUnknown;constructor(e,n){this.commandName=e,this.command=n}}let Ne=class extends k{commandName;constructor(t,e,n){super(`Failed to load command "${t}": ${e}`,"COMMAND_LOADER_ERROR",{commandName:t,reason:e}),this.name="CommandLoaderError",this.commandName=t,this.hint="Ensure the loader resolves to a module with a default export that is the command handler function.",n!==void 0&&(this.cause=n)}};const co=/^-{1,2}(\w+)(=(.+))?$/,Tt=(t,e,n,i)=>{const s=co.exec(t);if(s===null)return{};const o=s[1];if(!o)return{};const c=n&&i?n.get(o)??i.get(o):e.find(a=>a.name===o||a.alias===o);return c!==void 0?{argName:c.name,argValue:s[3],option:c}:{}},it=(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)},uo=new Set(["0","1","false","true"]),ho=(t,e,n,i)=>{if(e.length===0||t.length===0)return{};const s=(o,c)=>{const{argName:a,argValue:u,option:r}=Tt(c,e,n,i),{lastOption:l}=o;return r&&ue(r)&&u&&a?o.partial[a]=it(u,r):o.lastName&&l&&ue(l)&&uo.has(c)&&(o.partial[o.lastName]=it(c,l)),{lastName:a,lastOption:r,partial:o.partial}};return t.reduce(s,{partial:{}}).partial},po=new Set(["0","1","false","true"]),fo=(t,e,n,i)=>{if(e.length===0||t.length===0)return t;const s=(o,c)=>{const{argValue:a,option:u}=Tt(c,e,n,i),{lastOption:r}=o;if(r&&ue(r)&&po.has(c)){const{args:l}=o;return{args:l.slice(0,-1)}}return u&&ue(u)&&a?{args:o.args}:{args:[...o.args,c],lastOption:u}};return t.reduce(s,{args:[]}).args},mo=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()]},go=t=>{if(t===void 0)return;const e=t.toLowerCase().trim();return e==="true"||e==="1"||e==="yes"||e==="on"},wo=(t,e)=>{if(!t.type)return e;if(e!==void 0){if(t.type===Boolean||typeof t.type=="function"&&t.type.name==="Boolean")return go(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)}},yo=/_./g,vo=/^[A-Z]/,$o=t=>t.toLowerCase().replaceAll(yo,e=>e[1]?.toUpperCase()??e).replace(vo,e=>e.toLowerCase()),bo=t=>{if(!t||t.length===0)return{};const e={},n=ge();for(const i of t){const s=n[i.name],o=wo(i,s),c=o===void 0?i.defaultValue:o,a=$o(i.name);e[a]=c}return e},xo=t=>{const e=new Map,n=new Map;for(const i of t)if(e.set(i.name,i),i.alias){const s=Array.isArray(i.alias)?i.alias:[i.alias];for(const o of s)n.set(o,i)}return{optionMapByAlias:n,optionMapByName:e}},Mt=async t=>{if(typeof t.__resolvedExecute__=="function")return t.__resolvedExecute__;if(typeof t.loader!="function")throw new Ne(t.name,"no execute or loader defined");let e;try{e=await t.loader()}catch(i){throw new Ne(t.name,i instanceof Error?i.message:String(i),i)}const n=e.default;if(typeof n!="function")throw new Ne(t.name,"loader did not return a module with a default-exported handler function");return t.__resolvedExecute__=n,n},No=(t,e,n,i)=>{const s=new lo(t.name,t),{_all:o,_unknown:c,positionals:a}=e,u=Object.keys(n).length>0?{...o,...n}:o;fe in u&&delete u[fe],s.argument=a?.[fe]??[],s.rawUnknown=[...c??[]];const r=Object.keys(i).length>0;return s.options=r?{...u,...i}:u,s.env=bo(t.env),s},Ao=(t,e,n)=>{const i=t.options??[],s=i.length>0;let o=mo(s?[...i,...n]:n);if(o.length>0){for(const r of o)if(r.multiple&&r.lazyMultiple)throw new Error(`Argument "${r.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:fe,type:t.argument.type,typeLabel:t.argument.typeLabel},...o]);let c,a;if(s){const{optionMapByAlias:r,optionMapByName:l}=xo(i);c=fo(e,i,l,r),a=ho(e,i,l,r)}else c=e,a={};const u=ao(o,{argv:c,camelCase:!0,partial:!0,stopAtFirstUnknown:!0});return{arguments_:o,booleanValues:a,parsedArgs:u}},ee=async(t,e,n)=>typeof t.execute=="function"?t.execute(e):(await Mt(t))(e);let ko=class extends k{commandName;missingOptions;constructor(t,e){super(`Command "${t}" is missing required options: ${e.join(", ")}`,"COMMAND_VALIDATION_ERROR",{commandName:t,missingOptions:e}),this.name="CommandValidationError",this.commandName=t,this.missingOptions=e,this.hint=`Provide the following required options: ${e.join(", ")}`}},Eo=class extends k{choices;option;value;constructor(t,e,n){super(`Invalid value "${e}" for option "${t}". Allowed values: ${n.join(", ")}`,"INVALID_CHOICE",{choices:n,option:t,value:e}),this.name="InvalidChoiceError",this.option=t,this.value=e,this.choices=n,this.hint=`Use one of: ${n.map(i=>`--${t} ${i}`).join(", ")}`}};const ot=(t,e,n=!1)=>{const i=[];for(const s of t)if(!(!n&&!s.required)&&e[s.name]===void 0){if(s.type?.name==="Boolean"){e[s.name]=!1;continue}i.push(s)}return i},Co=(t,e)=>e.includes(t)?!0:Math.abs(t.length-e.length)>t.length/2?!1:Wn(t,e)<=t.length/3,F=(t,e)=>{const n=t.toLowerCase();return e.filter(i=>Co(i.toLowerCase(),n))},Oo=(t,e)=>{const n=[];if(t._unknown&&t._unknown.forEach(i=>{const s=i.startsWith("--");let o=`Found unknown ${s?"option":"argument"} "${i}"`;if(s){const c=F(i.replace("--",""),(e.options??[]).map(a=>a.name));if(c.length>0){const[a,...u]=c.map(r=>`--${r}`);o+=u.length>0?`, did you mean ${a??""} or ${u.join(", ")}?`:`, did you mean ${a??""}?`}}n.push(o)}),n.length>0)throw new Error(n.join(`
|
|
28
|
+
`))},_o=(t,e,n)=>{const i=n.__requiredOptions__,s=i?ot(i,e,!0):ot(t,e,!1);if(s.length>0)throw new ko(n.name,s.map(o=>o.name));e._unknown&&e._unknown.length>0&&!n.argument&&Oo(e,n)},Io=(t,e,n)=>{const i=n.__conflictingOptions__??t.filter(s=>s.conflicts!==void 0);if(i.length>0){const s=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(s)throw new Ot(s.name,typeof s.conflicts=="string"?s.conflicts:s.conflicts?.[0]??"unknown")}},Lo=(t,e)=>{const n=e.options;if(n)for(const i of n){if(!i.choices||i.choices.length===0)continue;const s=t[i.name];if(s==null)continue;const o=Array.isArray(s)?s:[s];for(const c of o){const a=String(c);if(!i.choices.includes(a))throw new Eo(i.name,a,i.choices)}}},So=t=>{if(!Array.isArray(t.options))return;const e=new Map,n=new Map;for(const s of t.options){if(s.name){const o=e.get(s.name)??[];o.push(s),e.set(s.name,o)}if(typeof s.alias=="string"&&s.alias.length>0){const o=n.get(s.alias)??[];o.push(s),n.set(s.alias,o)}else if(Array.isArray(s.alias)){for(const o of s.alias)if(o.length>0){const c=n.get(o)??[];c.push(s),n.set(o,c)}}}const i=[];for(const[s,o]of e)o.length>1&&i.push(`Duplicate option name "${s}" in command "${t.name}": ${JSON.stringify(o)}`);for(const[s,o]of n)o.length>1&&i.push(`Duplicate option alias "-${s}" used by options ${o.map(c=>`"${c.name}"`).join(", ")} in command "${t.name}"`);if(i.length>0)throw new Error(i.join(`
|
|
29
|
+
`))},To=(t,e)=>{if(e.length===0)return{argv:[],commandPath:void 0};const n=[];let i;for(let s=1;s<=e.length;s+=1){const o=e[s-1];if(o===void 0||o.startsWith("-"))break;n.push(o);const c=n.join(" ");t.has(c)&&(i={commandPath:[...n],depth:s})}return i?{argv:e.slice(i.depth),commandPath:i.commandPath}:{argv:e,commandPath:void 0}},H=t=>t.join(" "),st=(t,e)=>e&&e.length>0?[...e,t]:[t],Mo=(t,e)=>typeof t!="string"||t===""?"":t[0].toLowerCase()+t.slice(1),Po=(t,e)=>typeof t!="string"||t===""?"":t[0].toUpperCase()+t.slice(1),Do=(t,e)=>{const{length:n}=t;if(n===0)return"";if(n===1)return t[0];const i=[];let s="",o="";for(let c=0;c<n;c++){const a=t[c];if(me.test(a)){s?(i.push(s+o+a),s="",o=""):(i.length>0&&i.push(e),s=a);continue}s?(o&&(o+=e),o+=a):(i.length>0&&i.push(e),i.push(a))}return i.join("")},Pt=(t,e)=>{if(typeof t!="string"||!t)return"";let n=!0;return Do(Ni(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(i=>{const s=i,o=s.toLowerCase();return n?(n=!1,Mo(o)):Po(o)}),"")},Uo=/^no-/,jo=t=>{t.options?.forEach(e=>{e.__camelCaseName__=Pt(e.name)})},Vo=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 s=i.name.replace(Uo,"");if(!e.has(s)){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:s};n.push(o),e.add(s)}}n.length>0&&t.options.push(...n)},Bo=(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=Pt(o.name);i.set(c,o)}const s=Object.keys(n).filter(o=>i.has(o));if(s.length!==0)for(const o of s){const c=o.charAt(2);if(!c)continue;const a=c.toLowerCase()+o.slice(3),u=i.get(o);u&&(u.__negated__=!0),n[a]=!n[o],Reflect.deleteProperty(n,o)}},Ro=(t,e)=>{if(!e.options||e.options.length===0)return;const n=new Map;for(const s of e.options)s.__camelCaseName__&&s.__negated__===void 0&&s.implies!==void 0&&n.set(s.__camelCaseName__,s);if(n.size===0)return;const{options:i}=t;for(const s of Object.keys(i)){const o=n.get(s);if(o?.implies){const{implies:c}=o;for(const[a,u]of Object.entries(c))i[a]===void 0&&(i[a]=u)}}},Wo=()=>!!process.versions.electron,zo=()=>Wo()&&!process.defaultApp,Fo=()=>zo()?0:1,qo=t=>t.slice(Fo()+1),Go=" ",Ho=(t,e)=>t===e?!0:t.length!==e.length?!1:t.every((n,i)=>n===e[i]),Jo=t=>{if(typeof t=="string")return t.split(Go);const e=Ce();return Ho(t,e)?qo(t):t},Ko=t=>{const e=o=>{t.error(`Uncaught exception: ${o.message||o}`),o.stack&&t.error(o.stack),J(1)},n=(o,c)=>{if(o instanceof Error)t.error(`Promise rejection: ${o.message||o}`),o.stack&&t.error(o.stack);else{let a;if(typeof o=="string")a=o;else try{a=JSON.stringify(o)}catch{a=String(o)}t.error(`Promise rejection: ${a}`)}J(1)},i=Ue("uncaughtException",e),s=Ue("unhandledRejection",n);return()=>{i(),s()}},rt=100,Yo=/^[a-z][\w-]*$/i,Oe=(t,e)=>{if(typeof t!="string"||t.trim().length===0)throw new k(`${e} must be a non-empty string`,"INVALID_INPUT",{fieldName:e,value:t});return t.trim()},at=(t,e)=>{if(!Array.isArray(t)||!t.every(n=>typeof n=="string"))throw new k(`${e} must be an array of strings`,"INVALID_INPUT",{fieldName:e,value:t});return t},Ae=(t,e)=>{if(typeof t!="object"||t===null)throw new k(`${e} must be an object`,"INVALID_INPUT",{fieldName:e,value:t});return t},de=t=>{const e=Oe(t,"Command name");if(e.length>rt)throw new k(`Command name is too long (maximum ${String(rt)} characters)`,"INVALID_COMMAND_NAME",{commandName:e,length:e.length});if(e.includes("..")||e.includes("/")||e.includes("\\")||e.includes(";")||e.includes("|")||e.includes("&"))throw new k(`Command name "${e}" contains invalid characters`,"INVALID_COMMAND_NAME",{commandName:e});if(!Yo.test(e))throw new k(`Command name "${e}" must start with a letter and contain only letters, numbers, hyphens, and underscores`,"INVALID_COMMAND_NAME",{commandName:e});return e},Qo=new Set([`
|
|
30
|
+
`,"\r"," ","\0",'"',"$","&","'","(",")",";","<",">","[","\\","]","`","{","|","}"]),Zo=(t,e={})=>{if(typeof t!="string")throw new TypeError("Argument must be a string");const n=typeof e=="boolean"?{checkDangerousChars:e}:e,i=n.maxArgumentLength??1e6;if(Number.isFinite(i)&&i>0&&t.length>i)throw new Error(`Argument is too long (maximum ${String(i)} characters)`);if(n.checkDangerousChars){for(const s of t)if(Qo.has(s))throw new Error(`Argument contains dangerous character: ${s}`)}return n.trim?t.trim():t},lt=(t,e={})=>{if(!Array.isArray(t))throw new TypeError("Arguments must be an array");const n=typeof e=="boolean"?{checkDangerousChars:e}:e,i=n.maxArguments??1e5;if(Number.isFinite(i)&&i>0&&t.length>i)throw new Error(`Too many arguments (maximum ${String(i)})`);return t.map(s=>Zo(s,n))},Xo=/^-([^\d-])$/,es=/^--(\S+)/,ts=/^-([^\d-]{2,})$/,ke=t=>Xo.test(t)||es.test(t)||ts.test(t),ns={access:(t,e)=>Li(t,e),mkdir:(t,e)=>Ii(t,e),readdir:t=>_i(t),readFile:(async(t,e)=>e===void 0?Ge(t):Ge(t,e)),rm:(t,e)=>Oi(t,e),stat:t=>Ci(t),writeFile:(t,e,n)=>Ei(t,e,n)},is=(t,e,n)=>{const i=e.indexOf("--"),s=i===-1?new Set:new Set(e.slice(i+1)),o=n.filter(u=>u.startsWith("--")&&u!=="--"&&!s.has(u));if(o.length===0)return;const c=(t.options??[]).map(u=>u.name),a=o.flatMap(u=>F(u.slice(2),c).map(r=>`--${r}`));throw new Si(o,a)};class Te{#t;#e;#u;#h;#f;#m;#A;#k;#E;#$;#C;#b;#O;#_=ye;#p;#n;#i;#o;#s;#r;#g=!1;#I;#L=!1;#w;#y;#v;#l=[];#D(){return this.#w===void 0&&(this.#w=[...this.#i.keys()]),this.#w}#S(){return this.#y===void 0&&(this.#y=[...this.#n.keys()]),this.#y}#a(){return this.#v===void 0&&(this.#v=[...this.#D(),...this.#S()]),this.#v}#T(){return this.#l.length===0?he:[...he,...this.#l]}#M(){this.#w=void 0,this.#y=void 0,this.#v=void 0}#x(){if(this.#u===void 0){const e=Jo(this.#e.argv);this.#u=lt(e,{maxArguments:this.#b}),this.#U()}return this.#u}#N(){return this.#$??ge()}#d(e){this.#_=e,this.#N().CEREBRO_OUTPUT_LEVEL=String(e)}#c(){const e=this.#N().CEREBRO_OUTPUT_LEVEL,n=e===void 0?Number.NaN:Number(e);return Number.isNaN(n)?this.#_:n}#U(){if(!this.#u)return;let e=!1;for(const n of this.#u){if(n==="--quiet"||n==="-q"){this.#d(Bt),e=!0;break}if(n==="--verbose"||n==="-v"){this.#d(Rt),e=!0;break}if(n==="--debug"){this.#d(V),e=!0;break}}e||this.#d(Object.hasOwn(this.#N(),"DEBUG")?V:ye)}#j(){this.#L||(this.#I=Ko(this.#t),this.#L=!0)}#V(){return{arch:Vn(),argv:this.#x(),cwd:this.#h,env:this.#$??ge(),exit:this.#E??(e=>J(e??0)),platform:jn(),stdin:this.#C}}#P(e,n,i,s){this.#c()===V&&this.#t.debug(`command '${s}' found, parsing command args: ${n.join(", ")}`);const{arguments_:o,booleanValues:c,parsedArgs:a}=Ao(e,n,this.#T()),u=Object.keys(c).length>0;let r=a;u&&(r={...a,_all:{...a._all,...c}}),_o(o,r,e);const l=No(e,a,c,i);l.runtime=this,l.argv=this.#x(),l.fs=this.#k??ns,l.process=this.#V(),l.console=this.#t;const d=e.options&&e.options.length>0;if(d&&e.options){const h=e.options.filter(f=>f.name.startsWith("no-"));for(const f of h){const p=f.name.slice(3),g=`--${f.name}`,$=`--${p}`,w=n.includes(g),y=n.includes($);if(w&&y)throw new Ot(p,f.name)}}return d&&(Bo(l,e),Ro(l,e)),Io(o,l.options,e),Lo(l.options,e),this.#O&&is(e,n,l.rawUnknown),this.#c()===V&&(this.#t.debug("command options parsed from options:"),this.#t.debug(JSON.stringify(l.options,null,2)),this.#t.debug("command argument parsed from argument:"),this.#t.debug(JSON.stringify(l.argument,null,2))),{arguments_:o,booleanValues:c,commandArgs:r,parsedArgs:a,toolbox:l}}constructor(e,n={}){if(typeof e!="string"||e.trim().length===0)throw new k("CLI name must be a non-empty string","INVALID_INPUT",{cliName:e});this.#f=e.trim();const i=n.argv??Ce(),s=n.cwd??Pn();if(this.#e={...n,argv:i,cwd:s},this.#e.argv&&!Array.isArray(this.#e.argv))throw new k("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 k("CLI cwd option must be a string","INVALID_INPUT",{cwd:this.#e.cwd});if(this.#e.packageName&&typeof this.#e.packageName!="string")throw new k("CLI packageName option must be a string","INVALID_INPUT",{packageName:this.#e.packageName});if(this.#e.packageVersion&&typeof this.#e.packageVersion!="string")throw new k("CLI packageVersion option must be a string","INVALID_INPUT",{packageVersion:this.#e.packageVersion});if(typeof this.#e.logger=="object"){const r=["debug","error","info","log","warn"],l=[],d=this.#e.logger;for(const h of r)typeof d[h]!="function"&&l.push(h);if(l.length>0)throw new k(`Logger object is missing required methods: ${l.join(", ")}`,"INVALID_INPUT",{logger:this.#e.logger,missingMethods:l});this.#t=this.#e.logger}else this.#t={...console,debug:(...r)=>{this.#c()===V&&console.debug(...r)}};this.#m=this.#e.packageVersion,this.#A=this.#e.packageName,this.#h=this.#e.cwd,this.#s="help",this.#r={};const o=n.fs;if(o!==void 0&&(typeof o!="object"||o===null))throw new k("CLI fs option must be an object implementing the CerebroFs interface","INVALID_INPUT",{fs:n.fs});const c=n.exit;if(c!==void 0&&typeof c!="function")throw new k("CLI exit option must be a function","INVALID_INPUT",{exit:n.exit});const a=n.env;if(a!==void 0&&(typeof a!="object"||a===null))throw new k("CLI env option must be a record of string keys","INVALID_INPUT",{env:n.env});const u=n.stdin;if(u!==void 0&&typeof u!="string")throw new k("CLI stdin option must be a string","INVALID_INPUT",{stdin:n.stdin});this.#k=n.fs,this.#E=n.exit,this.#$=n.env,this.#C=n.stdin??"",this.#b=n.maxArguments,this.#O=n.strictOptions??!1,this.#d(ye),this.#n=new Map,this.#i=new Map,this.#o=new Map}setCommandSection(e){return this.#r=e,this}getCommandSection(){return this.#r.header||(this.#r.header=`${this.#f}${this.#m?` v${this.#m}`:""}`),this.#r}setDefaultCommand(e){return this.#s=e,this}get defaultCommand(){return this.#s}addCommand(e){Ae(e,"Command"),de(e.name);const n=typeof e.execute=="function",i=typeof e.loader=="function";if(n&&i)throw new k(`Command "${e.name}" cannot define both "execute" and "loader" — choose one`,"INVALID_COMMAND",{commandName:e.name});if(!n&&!i)throw new k(`Command "${e.name}" must define either "execute" or "loader"`,"INVALID_COMMAND",{commandName:e.name});e.alias&&(typeof e.alias=="string"?de(e.alias):at(e.alias,"Command alias").forEach(r=>de(r))),e.argument&&Ae(e.argument,"Command argument"),e.options&&Ae(e.options,"Command options"),e.commandPath&&(at(e.commandPath,"Command commandPath"),e.commandPath.forEach(r=>{de(r)}));const s=st(e.name,e.commandPath),o=H(s);if(this.#i.has(o))throw new k(`Command with path "${o}" already exists`,"DUPLICATE_COMMAND",{commandName:e.name,commandPath:e.commandPath});const c=Array.isArray(e.commandPath)&&e.commandPath.length>0,a=this.#n.get(e.name),u=a!==void 0&&(a.commandPath===void 0||a.commandPath.length===0);if(!c&&u)throw new k(`Command with name "${e.name}" already exists`,"DUPLICATE_COMMAND",{commandName:e.name});if(e.options)for(const r of e.options)He(r);if(So(e),Vo(e),jo(e),e.options&&(e.__conflictingOptions__=e.options.filter(r=>r.conflicts!==void 0),e.__requiredOptions__=e.options.filter(r=>r.required===!0)),c&&a!==void 0)this.#n.set(o,e);else{if(!c&&a!==void 0&&!u){const r=st(a.name,a.commandPath);this.#n.set(H(r),a)}this.#n.set(e.name,e)}if(this.#i.set(o,s),this.#o.set(o,e),this.#M(),e.alias!==void 0){const r=typeof e.alias=="string"?[e.alias]:e.alias;for(const l of r){if(this.#c()===V&&this.#t.debug("adding alias",l),this.#n.has(l))throw new k(`Command alias "${l}" conflicts with existing command`,"DUPLICATE_COMMAND",{alias:l,commandName:e.name});this.#n.set(l,e)}}return this}addGlobalOption(e){const n=e,i=new Set(he.map(o=>o.name)),s=new Set(he.map(o=>o.alias).filter(Boolean));if(i.has(n.name))throw new k(`Cannot add global option "--${n.name}": it conflicts with a built-in global option`,"DUPLICATE_OPTION",{optionName:n.name});if(n.alias&&s.has(n.alias))throw new k(`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 k(`Global option "--${n.name}" has already been added`,"DUPLICATE_OPTION",{optionName:n.name});return n.group="global",He(n),this.#l.push(n),this}getGlobalOptions(){return this.#T()}addPlugin(e){return this.getPluginManager().register(e),this}getPluginManager(){return this.#p?this.#p:(this.#p=new Mi(this.#t),this.#p.register({description:"Attaches the logger to the toolbox",execute:e=>{e.logger=this.#t,e.console=e.logger},name:"logger"}),this.#p)}getCliName(){return this.#f}getPackageVersion(){return this.#m}getPackageName(){return this.#A}getCommands(){return this.#n}getCwd(){return this.#h}dispose(){this.#I?.()}async run(e={}){const{autoDispose:n=!0,shouldExitProcess:i=!0,...s}=e;if(!this.#n.has("help")){const{default:y}=await import("../packem_chunks/help-command.js");this.addCommand(new y(this.#n))}const o=this.#S(),c=this.#i;this.#j();const a=this.#x();let u,r=[...a];this.#c()===V&&(this.#t.debug(`process.execPath: ${Un()}`),this.#t.debug(`process.execArgv: ${Dn().join(" ")}`),this.#t.debug(`process.argv: ${Ce().join(" ")}`));const l=To(c,[...a]);if(l.commandPath)u=l.commandPath,r=l.argv;else{if(a.length>1&&a[0]&&a[1]&&!ke(a[0])&&!ke(a[1])){const b=[];let N=0;for(;N<a.length;){const I=a[N];if(!I||ke(I))break;b.push(I),N+=1}const E=H(b);if(b[0]&&!o.includes(b[0])){const I=this.#a(),O=F(E,I);throw new G(E,O)}}let y;try{y=Bi([null,...o],[...a])}catch(b){if(b instanceof Error&&b.name==="INVALID_COMMAND"&&"command"in b){const N=b.command,E=this.#a(),I=F(N,E);throw new G(N,I)}throw b}y.command&&(u=[y.command],r=y.argv)}if(!u)if(this.#s)u=[this.#s];else{const y=this.#a();throw new G("",y)}const d=H(u),h=this.#i.get(d);let f;if(h){if(f=this.#o.get(d),!f||H(h)!==d){const y=this.#a(),b=F(d,y);throw new G(d,b)}}else{const y=u.at(-1);if(f=y?this.#n.get(y):void 0,!f){const b=this.#a(),N=F(d,b);throw new G(d,N)}}if(typeof f.execute!="function"&&typeof f.loader!="function")return this.#t.error(`Command "${f.name}" has no function to execute.`),i?J(1):void 0;const p=r;let g,$;try{({commandArgs:g,toolbox:$}=this.#P(f,p,s,d))}catch(y){if(this.#t.error(y),i)return J(1);throw y}const w=this.getPluginManager();try{!this.#g&&w.hasPlugins()&&(await w.init({cli:this,cwd:this.#h,logger:this.#t}),this.#g=!0),await w.executeLifecycle("execute",$),await w.executeLifecycle("beforeCommand",$);let y;const b=g.global;if(b?.help){const N=this.#n.get("help");if(!N)throw new k("Help command not found","COMMAND_NOT_FOUND");y=await ee(N,$)}else if(b?.version??b?.V){const N=this.#n.get("version");if(!N)throw new k("Version command not found","COMMAND_NOT_FOUND");y=await ee(N,$)}else y=await ee(f,$);return await w.executeLifecycle("afterCommand",$,y),i?J(0):void 0}catch(y){throw await w.executeErrorHandlers(y,$),y}finally{n&&this.dispose()}}async runCommand(e,n={}){const{argv:i=[],...s}=n;Oe(e,"Command name");const o=e.split(" ").filter(Boolean),c=H(o),a=this.#i.get(c)?this.#o.get(c):this.#n.get(e);if(!a){const h=this.#a(),f=F(c||e,h);throw new G(e,f)}if(typeof a.execute!="function"&&typeof a.loader!="function")throw new k(`Command "${a.name}" has no function to execute`,"INVALID_COMMAND",{commandName:a.name});const u=[...lt(i,{maxArguments:this.#b})];this.#c()===V&&this.#t.debug(`running command '${e}' programmatically with args: ${u.join(", ")}`);const{commandArgs:r,toolbox:l}=this.#P(a,u,s,c||e),d=this.getPluginManager();try{!this.#g&&d.hasPlugins()&&(await d.init({cli:this,cwd:this.#h,logger:this.#t}),this.#g=!0),await d.executeLifecycle("execute",l),await d.executeLifecycle("beforeCommand",l);let h;const f=r.global;if(f?.help){const p=this.#n.get("help");if(!p)throw new k("Help command not found","COMMAND_NOT_FOUND");h=await ee(p,l)}else if(f?.version??f?.V){const p=this.#n.get("version");if(!p)throw new k("Version command not found","COMMAND_NOT_FOUND");h=await ee(p,l)}else h=await ee(a,l);return await d.executeLifecycle("afterCommand",l,h),h}catch(h){throw await d.executeErrorHandlers(h,l),h}}clone(e){const n={...this.#e,...e},i=new Te(this.#f,n);for(const[s,o]of this.#n)i.#n.set(s,o);for(const[s,o]of this.#i)i.#i.set(s,[...o]);for(const[s,o]of this.#o)i.#o.set(s,o);for(const s of this.#l)i.#l.push(s);return i.#s=this.#s,i.#r={...this.#r},i.#M(),i}async getAction(e){Oe(e,"Command name");const n=e.split(" ").filter(Boolean),i=H(n),s=this.#i.get(i)?this.#o.get(i):this.#n.get(e);if(!s){const o=this.#a(),c=F(i||e,o);throw new G(e,c)}if(typeof s.execute=="function")return s.execute;if(typeof s.loader=="function")return Mt(s);throw new k(`Command "${s.name}" has no execute or loader defined`,"INVALID_COMMAND",{commandName:s.name})}}const ms=(t,e)=>new Te(t,e),gs=()=>{try{const t=require("node:module");if(typeof t.enableCompileCache=="function"){t.enableCompileCache();return}}catch{}try{require("v8-compile-cache")}catch{}},ws=(t={})=>({description:"Enhanced error handling and reporting with beautiful code frames",name:"error-handler",onError:(e,n)=>{const{logger:i,runtime:s}=n,{detailed:o=!1,exitOnError:c=!0,formatter:a,logErrors:u=!0,renderOptions:r={}}=t;if(u)if(a)i.error(a(e));else if(o){const l=s.getCwd(),d=Mn(e,{cwd:l,hideErrorCodeView:!1,hideErrorTitle:!1,hideMessage:!1,linesAbove:2,linesBelow:3,...r});i.error(d)}else i.error(e);c&&J(1)},version:"1.0.0"});var os="1.0.0-alpha.40";const ys={version:os},vs={argument:{description:"Package to execute (optionally with @version)",name:"package",type:String},description:"Execute a remote package without permanent installation",examples:[["vis dlx create-vite my-app","Scaffold a new project"],["vis dlx typescript@5.5.4 tsc --version","Run specific version"],["vis dlx -p cowsay -p lolcatjs -c 'echo hi | cowsay | lolcatjs'","Multiple packages with shell"],["vis install && vis dlx --offline typescript tsc --version","Hardened: pre-install + offline (no registry fetch on dlx)"]],group:"Run & Execute",loader:()=>import("../packem_chunks/handler9.js"),name:"dlx",options:[{alias:"p",description:"Additional packages to install (repeatable)",multiple:!0,name:"package",type:String},{alias:"c",defaultValue:!1,description:"Execute within shell environment",name:"shell-mode",type:Boolean},{alias:"s",defaultValue:!1,description:"Suppress output except command results",name:"silent",type:Boolean},{defaultValue:!1,description:"Resolve from local store only — fail rather than fetch from the registry. Pair with `vis install` for hardened npx-style workflows.",name:"offline",type:Boolean}]};export{q as L,ms as V,gs as a,rs as b,ys as c,hs as d,vs as e,k as f,Ce as g,ws as h,us as i,Un as j,J as k,Dn as l,ls as n,ps as o,ds as p,cs as r,as as s,ge as t};
|