@visulima/vis 3.0.2 → 3.0.3
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 +12 -0
- package/LICENSE.md +1 -130
- package/dist/bin.js +1 -1
- package/dist/binx.js +1 -1
- package/dist/packem_chunks/CONFIG_FILES.js +1 -1
- package/dist/packem_chunks/bloom-status.js +1 -1
- package/dist/packem_chunks/bloom-sync.js +1 -1
- package/dist/packem_chunks/catalog.js +1 -1
- package/dist/packem_chunks/cli-exec.js +1 -1
- package/dist/packem_chunks/cli-main.js +168 -170
- package/dist/packem_chunks/fix.js +1 -1
- package/dist/packem_chunks/handler15.js +1 -1
- package/dist/packem_chunks/handler19.js +1 -1
- package/dist/packem_chunks/handler2.js +1 -1
- package/dist/packem_chunks/handler21.js +1 -1
- package/dist/packem_chunks/handler24.js +1 -1
- package/dist/packem_chunks/handler28.js +1 -1
- package/dist/packem_chunks/handler3.js +1 -1
- package/dist/packem_chunks/handler54.js +1 -1
- package/dist/packem_chunks/handler55.js +1 -1
- package/dist/packem_chunks/handler58.js +1 -1
- package/dist/packem_chunks/handler6.js +5 -5
- package/dist/packem_chunks/handler62.js +1 -1
- package/dist/packem_chunks/handler64.js +2 -2
- package/dist/packem_chunks/handler67.js +1 -1
- package/dist/packem_chunks/handler69.js +1 -1
- package/dist/packem_chunks/handler70.js +1 -1
- package/dist/packem_chunks/handler72.js +1 -1
- package/dist/packem_chunks/handler73.js +1 -1
- package/dist/packem_chunks/handler74.js +1 -1
- package/dist/packem_chunks/handler75.js +1 -1
- package/dist/packem_chunks/handler76.js +1 -1
- package/dist/packem_chunks/handler77.js +40 -40
- package/dist/packem_chunks/heal.js +1 -1
- package/dist/packem_chunks/help-command.js +1 -1
- package/dist/packem_chunks/list.js +1 -1
- package/dist/packem_chunks/prune.js +1 -1
- package/dist/packem_chunks/run.js +1 -1
- package/dist/packem_chunks/status.js +1 -1
- package/dist/packem_chunks/sync.js +1 -1
- package/dist/packem_shared/{advisories-DZd1uGqa.js → advisories-0ScpWAHV.js} +1 -1
- package/dist/packem_shared/{affected-selection-CoRXp5H4.js → affected-selection-BMoQWuHl.js} +1 -1
- package/dist/packem_shared/{ai-fix-6nXZbecQ.js → ai-fix-CKN1JGRh.js} +1 -1
- package/dist/packem_shared/{bin-C2eYtJ_N.js → bin-CN4heKmb.js} +1 -1
- package/dist/packem_shared/{osv-bloom-1JS__1or.js → osv-bloom-JYIWcH3F.js} +1 -1
- package/dist/packem_shared/{package-version-Bb7KGF36.js → package-version-CJxZ_B7G.js} +3 -3
- package/dist/packem_shared/{project-name-filter-DYaIbrXa.js → project-name-filter-DsrVo0MY.js} +1 -1
- package/dist/packem_shared/{scan-progress-aVHGZYWf.js → scan-progress-5uTRdC1G.js} +2 -2
- package/dist/packem_shared/{spinner-CbJfWYwB.js → spinner-BM_0Bj6x.js} +1 -1
- package/dist/packem_shared/{tabs-BilwonkM.js → tabs-UDYQ3tqt.js} +1 -1
- package/dist/packem_shared/target-merge-B4No-LHM.js +4 -0
- package/dist/packem_shared/{vis-update-app-ngwL2mRv.js → vis-update-app-zqSa2clT.js} +1 -1
- package/dist/packem_shared/{vis-user-error-CAu9wIbe.js → vis-user-error-Dkc97rGY.js} +1 -1
- package/index.js +26 -26
- package/package.json +11 -11
- package/dist/packem_shared/target-merge-DCGow6Kw.js +0 -4
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{createRequire as E}from"node:module";import{b as U,j as x,F as g,X as A,J as L}from"../packem_shared/index.server-BAjDJSEu.js";import{a as O}from"../packem_shared/index-DHD8wb6Z.js";import{readLastRunSummary as G}from"@visulima/task-runner";import{a as j,r as F,b as D,c as K}from"../packem_shared/ai-fix-
|
|
1
|
+
import{createRequire as E}from"node:module";import{b as U,j as x,F as g,X as A,J as L}from"../packem_shared/index.server-BAjDJSEu.js";import{a as O}from"../packem_shared/index-DHD8wb6Z.js";import{readLastRunSummary as G}from"@visulima/task-runner";import{a as j,r as F,b as D,c as K}from"../packem_shared/ai-fix-CKN1JGRh.js";import{p,f as H}from"./cli-main.js";let B;const P=e=>(B??=E(import.meta.url))(e),m=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,I=e=>{if(typeof m<"u"&&m.versions&&m.versions.node){const[t,o]=m.versions.node.split(".").map(Number);if(t>22||t===22&&o>=3||t===20&&o>=16)return m.getBuiltinModule(e)}return P(e)},{spawn:h}=I("node:child_process"),{readFile:M}=I("node:fs/promises"),V=e=>{if(!e)return;const t=/^refs\/pull\/(\d+)\//.exec(e);return t?Number.parseInt(t[1],10):void 0},J=async e=>{if(!e)return{prNumber:void 0,sha:void 0};try{const t=await M(e,"utf8"),o=JSON.parse(t),r=o.pull_request?.number??o.issue?.number??o.number,s=o.pull_request?.head?.sha;return{prNumber:r,sha:s}}catch{return{prNumber:void 0,sha:void 0}}},q=async e=>{const t=V(e.GITHUB_REF),{prNumber:o,sha:r}=t===void 0?await J(e.GITHUB_EVENT_PATH):{prNumber:t,sha:void 0};return{apiBaseUrl:void 0,buildId:void 0,buildNumber:void 0,prNumber:t??o,provider:"github-actions",repo:e.GITHUB_REPOSITORY,sha:r??e.GITHUB_SHA,token:e.GITHUB_TOKEN}},z=e=>{const t=e.CI_MERGE_REQUEST_IID,o=t!==void 0&&t!==""?Number.parseInt(t,10):void 0,r=e.CI_API_V4_URL,s=e.GITLAB_TOKEN??e.CI_TOKEN;return{apiBaseUrl:r,buildId:void 0,buildNumber:void 0,prNumber:Number.isFinite(o)?o:void 0,provider:"gitlab-ci",repo:e.CI_PROJECT_ID??e.CI_PROJECT_PATH,sha:e.CI_COMMIT_SHA,token:s}},X=e=>{const t=e.BUILDKITE_PULL_REQUEST,o=t!==void 0&&t!==""&&t!=="false"?Number.parseInt(t,10):void 0,r=e.BUILDKITE_BUILD_NUMBER,s=r!==void 0&&r!==""?Number.parseInt(r,10):void 0,n=e.BUILDKITE_ORGANIZATION_SLUG,i=e.BUILDKITE_PIPELINE_SLUG,a=n!==void 0&&n!==""&&i!==void 0&&i!==""?`${n}/${i}`:void 0;return{apiBaseUrl:(e.BUILDKITE_API_BASE_URL??"https://api.buildkite.com").replace(/\/+$/,""),buildId:e.BUILDKITE_BUILD_ID,buildNumber:Number.isFinite(s)?s:void 0,prNumber:Number.isFinite(o)?o:void 0,provider:"buildkite",repo:a,sha:e.BUILDKITE_COMMIT,token:e.BUILDKITE_API_TOKEN}},Y=async(e=process.env)=>e.GITHUB_ACTIONS==="true"?await q(e):e.GITLAB_CI==="true"?z(e):e.BUILDKITE==="true"?X(e):{apiBaseUrl:void 0,buildId:void 0,buildNumber:void 0,prNumber:void 0,provider:"unknown",repo:void 0,sha:void 0,token:void 0},Q=(e,t,o,r)=>new Promise(s=>{const n=["pr","comment",String(t),"--body-file","-"];r&&n.push("--repo",r);const i=h(e,n,{stdio:["pipe","ignore","pipe"]});let a="";i.stderr?.setEncoding("utf8"),i.stderr?.on("data",d=>{a+=d}),i.once("error",()=>{s({exitCode:127,stderr:a})}),i.once("close",d=>{s({exitCode:d??-1,stderr:a})}),i.stdin?.on("error",()=>{}),i.stdin?.end(o)}),Z=async(e,t,o,r,s)=>{const n=`https://api.github.com/repos/${t}/issues/${String(o)}/comments`;try{const i=await e(n,{body:JSON.stringify({body:r}),headers:{Accept:"application/vnd.github+json",Authorization:`Bearer ${s}`,"Content-Type":"application/json","X-GitHub-Api-Version":"2022-11-28"},method:"POST"});if(!i.ok){const a=await i.text().catch(()=>"");return{error:`GitHub REST returned ${String(i.status)}: ${a.slice(0,500)}`,ok:!1}}return{ok:!0}}catch(i){return{error:i instanceof Error?i.message:String(i),ok:!1}}},W=async(e,t,o,r,s,n)=>{const i=encodeURIComponent(o),a=`${t.replace(/\/+$/,"")}/projects/${i}/merge_requests/${String(r)}/notes`;try{const d=await e(a,{body:JSON.stringify({body:s}),headers:{"Content-Type":"application/json","PRIVATE-TOKEN":n},method:"POST"});if(!d.ok){const c=await d.text().catch(()=>"");return{error:`GitLab REST returned ${String(d.status)}: ${c.slice(0,500)}`,ok:!1}}return{ok:!0}}catch(d){return{error:d instanceof Error?d.message:String(d),ok:!1}}},tt=(e,t,o,r)=>new Promise(s=>{const i=h(e,["annotate","--style",o,"--context",r],{stdio:["pipe","ignore","pipe"]});let a="";i.stderr?.setEncoding("utf8"),i.stderr?.on("data",d=>{a+=d}),i.once("error",()=>{s({exitCode:127,stderr:a})}),i.once("close",d=>{s({exitCode:d??-1,stderr:a})}),i.stdin?.on("error",()=>{}),i.stdin?.end(t)}),et=async(e,t,o,r,s,n,i,a)=>{const[d,c]=o.split("/",2);if(!d||!c)return{error:`Buildkite repo identifier \`${o}\` is not in {org}/{pipeline} form.`,ok:!1};const f=`${t}/v2/organizations/${encodeURIComponent(d)}/pipelines/${encodeURIComponent(c)}/builds/${String(r)}/annotations`;try{const u=await e(f,{body:JSON.stringify({body:s,context:i,style:n}),headers:{Authorization:`Bearer ${a}`,"Content-Type":"application/json"},method:"POST"});if(!u.ok){const l=await u.text().catch(()=>"");return{error:`Buildkite REST returned ${String(u.status)}: ${l.slice(0,500)}`,ok:!1}}return{ok:!0}}catch(u){return{error:u instanceof Error?u.message:String(u),ok:!1}}},ot=async(e,t,o,r)=>{const s=t.buildId?`vis-ai-heal-${t.buildId}`:"vis-ai-heal",n="info",i=await tt(o,e,n,s);if(i.exitCode===0)return{method:"buildkite-cli",posted:!0};if(!t.apiBaseUrl||!t.repo||t.buildNumber===void 0||!t.token){const d=[];return t.repo||d.push("BUILDKITE_ORGANIZATION_SLUG / BUILDKITE_PIPELINE_SLUG"),t.buildNumber===void 0&&d.push("BUILDKITE_BUILD_NUMBER"),t.token||d.push("BUILDKITE_API_TOKEN (with `write_build_annotations` scope)"),{error:`buildkite-agent annotate exited ${String(i.exitCode)} (${i.stderr.trim().slice(0,200)}); cannot fall back to REST without ${d.join(", ")}`,method:"buildkite-cli",posted:!1}}const a=await et(r,t.apiBaseUrl,t.repo,t.buildNumber,e,n,s,t.token);return a.ok?{method:"rest",posted:!0}:{error:`buildkite-agent annotate exited ${String(i.exitCode)}; REST fallback also failed: ${a.error??"unknown"}`,method:"rest",posted:!1}},rt=async(e,t,o,r)=>{if(t.prNumber===void 0)return{method:"skipped",posted:!1};const s=await Q(o,t.prNumber,e,t.repo);if(s.exitCode===0)return{method:"gh-cli",posted:!0};if(!t.repo||!t.token)return{error:`gh exited ${String(s.exitCode)} (${s.stderr.trim().slice(0,200)}); cannot fall back to REST without GITHUB_REPOSITORY + GITHUB_TOKEN`,method:"gh-cli",posted:!1};const n=await Z(r,t.repo,t.prNumber,e,t.token);return n.ok?{method:"rest",posted:!0}:{error:`gh exited ${String(s.exitCode)}; REST fallback also failed: ${n.error??"unknown"}`,method:"rest",posted:!1}},it=async(e,t,o)=>{if(t.prNumber===void 0)return{method:"skipped",posted:!1};if(!t.apiBaseUrl||!t.repo)return{error:"GitLab CI context is missing CI_API_V4_URL or CI_PROJECT_ID; cannot post note.",method:"rest",posted:!1};if(!t.token)return{error:"GitLab CI context has no token. CI_JOB_TOKEN cannot post MR notes — set GITLAB_TOKEN to a personal/project access token with `api` scope.",method:"rest",posted:!1};const r=await W(o,t.apiBaseUrl,t.repo,t.prNumber,e,t.token);return r.ok?{method:"rest",posted:!0}:{error:r.error,method:"rest",posted:!1}},nt=async e=>{const{body:t,buildkiteAgentBin:o="buildkite-agent",context:r,fetchImpl:s=globalThis.fetch,ghBin:n="gh"}=e;return r.provider==="github-actions"?await rt(t,r,n,s):r.provider==="gitlab-ci"?await it(t,r,s):r.provider==="buildkite"?await ot(t,r,o,s):{method:"skipped",posted:!1}},b=e=>{let t=0,o=0;for(const r of e)r.status==="applied"?t+=1:o+=1;return{applied:t,failed:o}},k=(e,t,o)=>{const r=K(e,t,o),s=O(e,r);return s===""||s.startsWith("..")?r:s},st=(e,t,o,r)=>new Promise(s=>{const n=process.argv[1];if(!n){s({exitCode:-1,stderr:"Cannot locate vis bin (process.argv[1] missing).",stdout:""});return}const i=[n,"run",o,"--projects",t,"--no-cache","--summarize","--fail-fast"],a=h(process.execPath,i,{cwd:e,env:{...process.env,NO_COLOR:"1"},stdio:["ignore","pipe","pipe"]});let d="",c="";const f=setTimeout(()=>{a.kill("SIGTERM"),setTimeout(()=>a.kill("SIGKILL"),2e3).unref()},r);a.stdout?.setEncoding("utf8"),a.stdout?.on("data",u=>{d+=u}),a.stderr?.setEncoding("utf8"),a.stderr?.on("data",u=>{c+=u}),a.once("error",u=>{clearTimeout(f),s({exitCode:-1,stderr:u.message,stdout:d})}),a.once("close",u=>{clearTimeout(f),s({exitCode:u??-1,stderr:c,stdout:d})})}),at=6e4,T=e=>{let t=0;const o=e.match(/`{3,}/g);if(o)for(const r of o)t=Math.max(t,r.length);return"`".repeat(Math.max(3,t+1))},_=(e,t,o)=>{if(e.patches.length===0)return"_No patches proposed._";const r=[];for(const[s,n]of e.patches.entries()){const i=k(t,o,n.file),a=[`**[${String(s+1)}] \`${i}\`**`];n.reason&&a.push(`_${n.reason}_`);const d=T(`${n.oldString}
|
|
2
2
|
${n.newString}`);a.push(`${d}diff`);for(const c of n.oldString.split(`
|
|
3
3
|
`))a.push(`- ${c}`);for(const c of n.newString.split(`
|
|
4
4
|
`))a.push(`+ ${c}`);a.push(d),r.push(a.join(`
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{createRequire as St}from"node:module";import{w as Et,$ as It,e as Wt,j as C,P as b,q as x,J as N,b as L}from"../packem_shared/index.server-BAjDJSEu.js";import{u as ct,a as B,c as Bt}from"../packem_shared/vis-user-error-
|
|
1
|
+
import{createRequire as St}from"node:module";import{w as Et,$ as It,e as Wt,j as C,P as b,q as x,J as N,b as L}from"../packem_shared/index.server-BAjDJSEu.js";import{u as ct,a as B,c as Bt}from"../packem_shared/vis-user-error-Dkc97rGY.js";import{N as _,a as R}from"../packem_shared/Table-DyORjLji-CC9cYgCG.js";import{b as Mt}from"../packem_shared/package-version-CJxZ_B7G.js";let At;const Ot=t=>(At??=St(import.meta.url))(t),E=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,xt=t=>{if(typeof E<"u"&&E.versions&&E.versions.node){const[e,n]=E.versions.node.split(".").map(Number);if(e>22||e===22&&n>=3||e===20&&n>=16)return E.getBuiltinModule(t)}return Ot(t)},{createRequire:kt}=xt("node:module"),jt=/^#?([a-f\d]{3}|[a-f\d]{6})$/i,z=t=>{let[,e]=jt.exec(t)??[];const n=e?e.length:0;if(n===3){const s=e.charAt(0),i=e.charAt(1),o=e.charAt(2);e=s+s+i+i+o+o}else if(n!==6)return globalThis.process?.env?.NODE_ENV!=="production"&&console.warn(`[@visulima/colorize] Invalid hex color "${t}"; expected a 3- or 6-digit hex string (e.g. "#96C" or "#E0115F"). Falling back to black.`),[0,0,0];const r=Number.parseInt(e,16);return[r>>16&255,r>>8&255,r&255]},dt=(t,e,n)=>t===e&&e===n?t<8?16:t>248?231:Math.round((t-8)/247*24)+232:16+36*Math.round(t/51)+6*Math.round(e/51)+Math.round(n/51),H=t=>{let e,n,r;if(t<8)return 30+t;if(t<16)return 90+(t-8);if(t>=232)e=n=r=((t-232)*10+8)/255;else{t-=16;const o=t%36;e=Math.floor(t/36)/5,n=Math.floor(o/6)/5,r=o%6/5}const s=Math.max(e,n,r)*2;if(s===0)return 30;const i=30+(Math.round(r)<<2|Math.round(n)<<1|Math.round(e));return s===2?i+60:i},Q=(t,e,n)=>H(dt(t,e,n));function Ct({onlyFirst:t=!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,t?void 0:"g")}const S=(t,e,n)=>e>t?e:Math.min(t,n),m=39,f=49,X=10,tt={close:"",open:""},ut=t=>{const e=t>0?(d,p)=>({close:`\x1B[${String(p)}m`,open:`\x1B[${String(d)}m`}):()=>tt,n=d=>(p,h,g)=>d(dt(Number(p),Number(h),Number(g))),r=d=>p=>{const[h,g,w]=z(p);return d(h,g,w)};let s=d=>e(`38;5;${String(d)}`,m),i=d=>e(`48;5;${String(d)}`,f),o=(d,p,h)=>e(`38;2;${String(d)};${String(p)};${String(h)}`,m),a=(d,p,h)=>e(`48;2;${String(d)};${String(p)};${String(h)}`,f);t===1?(s=d=>e(H(Number(d)),m),i=d=>e(H(Number(d))+X,f),o=(d,p,h)=>e(Q(Number(d),Number(p),Number(h)),m),a=(d,p,h)=>e(Q(Number(d),Number(p),Number(h))+X,f)):t===2&&(o=n(s),a=n(i));const c={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),underlineCurly:e("4:3",24),underlineDashed:e("4:5",24),underlineDotted:e("4:4",24),underlineDouble:e("4:2",24),visible:tt},l={bgBlack:e(40,f),bgBlackBright:e(100,f),bgBlue:e(44,f),bgBlueBright:e(104,f),bgCyan:e(46,f),bgCyanBright:e(106,f),bgGray:e(100,f),bgGreen:e(42,f),bgGreenBright:e(102,f),bgGrey:e(100,f),bgMagenta:e(45,f),bgMagentaBright:e(105,f),bgRed:e(41,f),bgRedBright:e(101,f),bgWhite:e(47,f),bgWhiteBright:e(107,f),bgYellow:e(43,f),bgYellowBright:e(103,f),black:e(30,m),blackBright:e(90,m),blue:e(34,m),blueBright:e(94,m),cyan:e(36,m),cyanBright:e(96,m),gray:e(90,m),green:e(32,m),greenBright:e(92,m),grey:e(90,m),magenta:e(35,m),magentaBright:e(95,m),red:e(31,m),redBright:e(91,m),white:e(37,m),whiteBright:e(97,m),yellow:e(33,m),yellowBright:e(93,m)},u={bg:d=>i(S(d,0,255)),bgHex:r(a),bgRgb:(d,p,h)=>a(S(d,0,255),S(p,0,255),S(h,0,255)),fg:d=>s(S(d,0,255)),hex:r(o),rgb:(d,p,h)=>o(S(d,0,255),S(p,0,255),S(h,0,255))};return{baseColors:l,baseStyles:c,styleMethods:u}},ht=Et();It();ut(ht);const _t=(t,e,n)=>{if(e==="")return t;let r=t.indexOf(e);if(r<0)return t;const s=e.length;let i=0,o="";for(;~r;)o+=t.slice(i,r)+n,i=r+s,r=t.indexOf(e,i);return o+t.slice(i)},Rt=(t,e,n)=>{if(t==null||t==="")return"";let r;if(t.raw===void 0?r=String(t):r=String.raw(t,...e),r.includes("\x1B"))for(let s=n;s;s=s.props)r=_t(r,s.close,s.open);return r.includes(`
|
|
2
2
|
`)&&(r=r.replace(/(\r*\n)/g,`${n.closeStack}$1${n.openStack}`)),n.openStack+r+n.closeStack},Pt=function(t){const e=t?.level??ht,{baseColors:n,baseStyles:r,styleMethods:s}=ut(e),i={};let o=null;const a=({props:l},{close:u,open:d})=>{const p=(l?.openStack??"")+d,h=u+(l?.closeStack??""),g=(w,...y)=>Rt(w,y,g.props);return Object.setPrototypeOf(g,o),g.props={close:u,closeStack:h,open:d,openStack:p,props:l},g.open=p,g.close=h,g},c=l=>String(l);c.strip=l=>l.replaceAll(Ct(),"");for(const l in n)i[l]={get(){const u=a(this,n[l]);return Object.defineProperty(this,l,{value:u}),u}};for(const l in r)i[l]={get(){const u=a(this,r[l]);return Object.defineProperty(this,l,{value:u}),u}};for(const l in s)i[l]={get(){return(...u)=>a(this,s[l](...u))}};return i.ansi256=i.fg,i.bgAnsi256=i.bg,o=Object.defineProperties({},i),Object.setPrototypeOf(c,o),c},Tt=t=>(e,...n)=>{if(!Array.isArray(e)||!Array.isArray(e.raw))throw new TypeError("A tagged template literal must be provided");const r=[e.raw[0]];for(let s=1;s<e.raw.length;s+=1)r.push(String(n[s-1]).replaceAll(/[{}\\]/g,String.raw`\$&`),String(e.raw[s]));return t(r.join(""))},Lt=new Map([["0","\0"],["\\","\\"],["a","\x07"],["b","\b"],["e","\x1B"],["f","\f"],["n",`
|
|
3
3
|
`],["r","\r"],["t"," "],["v","\v"]]),pt=t=>{const e=t.startsWith("u"),n=t[1]==="{";return e&&!n&&t.length===5||t.startsWith("x")&&t.length===3?String.fromCodePoint(Number.parseInt(t.slice(1),16)):e&&n?String.fromCodePoint(Number.parseInt(t.slice(2,-1),16)):Lt.get(t)??t},Ft=/\\(u(?:[a-f\d]{4}|\{[a-f\d]{1,6}\})|x[a-f\d]{2}|.)|\{(~)?(#?[\w:]+(?:\([^)]*\))?(?:\.#?[\w:]+(?:\([^)]*\))?)*)(?:[ \t]|(?=\r?\n))|(\})|((?:.|[\r\n\f])+?)/gi,et=/(?:^|\.)(?:(\w+)(?:\(([^)]*)\))?|#(?=[:a-f\d]{2,})([a-f\d]{6})?(?::([a-f\d]{6}))?)/gi,Dt=/^(['"])((?:\\.|(?!\1)[^\\])*)\1$/,Vt=/\\(u(?:[a-f\d]{4}|\{[a-f\d]{1,6}\})|x[a-f\d]{2}|.)|([^\\])/gi,Ut=/\s*,\s*/,Gt=(t,e)=>{const n=[],r=e.trim().split(Ut);let s;for(const i of r){const o=Number(i);if(!Number.isNaN(o))n.push(o);else if(s=Dt.exec(i))n.push(s[2].replaceAll(Vt,(a,c,l)=>c?pt(c):l));else throw new Error(`Invalid template style argument: ${i} (in style '${t}')`)}return n},qt=t=>{et.lastIndex=0;const e=[];let n;for(;(n=et.exec(t))!==null;){const r=n[1];n[2]?e.push([r,...Gt(r,n[2])]):n[3]||n[4]?(n[3]&&e.push(["rgb",...z(n[3])]),n[4]&&e.push(["bgRgb",...z(n[4])])):e.push([r])}return e},nt=(t,e)=>{const n={};for(const s of e)for(const i of s.styles)n[i[0]]=s.inverse?void 0:i.slice(1);let r=t;for(const[s,i]of Object.entries(n))if(Array.isArray(i)){if(!(s in r))throw new Error(`Unknown style: ${s}`);r=i.length>0?r[s](...i):r[s]}return r},zt=t=>e=>{const n=[],r=[];let s=[];if(e.replaceAll(Ft,(i,o,a,c,l,u)=>{if(o)s.push(pt(o));else if(c){const d=s.join("");s=[],r.push(n.length===0?d:nt(t,n)(d)),n.push({inverse:a,styles:qt(c)})}else if(l){if(n.length===0)throw new Error("Found extraneous } in template literal");r.push(nt(t,n)(s.join(""))),s=[],n.pop()}else s.push(u)}),r.push(s.join("")),n.length>0)throw new Error(`template literal is missing ${String(n.length)} closing bracket${n.length===1?"":"s"} (\`}\`)`);return r.join("")},Ht=new Pt,Yt=zt(Ht),Jt=Tt(Yt);let Kt;const Zt=t=>(Kt??=kt(import.meta.url))(t),O=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:A,F=t=>{if(typeof O<"u"&&O.versions&&O.versions.node){const[e,n]=O.versions.node.split(".").map(Number);if(e>22||e===22&&n>=3||e===20&&n>=16)return O.getBuiltinModule(t)}return Zt(t)},A=O,{execFileSync:Qt}=F("node:child_process"),W=F("node:fs"),Xt=F("node:tty"),te=F("node:os"),ee=[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],ne=12288,re=65510,oe=[12288,12288,65281,65376,65504,65510],ie=8361,se=65518,ae=[8361,8361,65377,65470,65474,65479,65482,65487,65490,65495,65498,65500,65512,65518],le=32,ce=10630,de=[32,126,162,163,165,166,172,172,175,175,10214,10221,10629,10630],ue=4352,he=262141,mt=[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],k=(t,e)=>{let n=0,r=Math.floor(t.length/2)-1;for(;n<=r;){const s=Math.floor((n+r)/2),i=s*2;if(e<t[i])r=s-1;else if(e>t[i+1])n=s+1;else return!0}return!1},rt=19968,[pe,me]=fe(mt);function fe(t){let e=t[0],n=t[1];for(let r=0;r<t.length;r+=2){const s=t[r],i=t[r+1];if(rt>=s&&rt<=i)return[s,i];i-s>n-e&&(e=s,n=i)}return[e,n]}const ge=t=>t<161||t>1114109?!1:k(ee,t),we=t=>t<ne||t>re?!1:k(oe,t),be=t=>t<ie||t>se?!1:k(ae,t),ye=t=>t<le||t>ce?!1:k(de,t),$e=t=>t>=pe&&t<=me?!0:t<ue||t>he?!1:k(mt,t);function Ne(t){return ge(t)?"ambiguous":we(t)?"fullwidth":be(t)?"halfwidth":ye(t)?"narrow":$e(t)?"wide":"neutral"}function ve(t){if(!Number.isSafeInteger(t))throw new TypeError(`Expected a code point, got \`${typeof t}\`.`)}function ft(t){return ve(t),Ne(t)}const ot=new Map,Se=t=>[t.ambiguousIsNarrow?1:0,t.control,t.fullWidth,t.regular,t.wide].join("|"),Ae=t=>{const e=Se(t.width);let n=ot.get(e);return n||(n=new Map,ot.set(e,n)),n},M=new RegExp(ct.source,"y"),G=new RegExp(Bt.source,"uy"),j=/(?:[\u0020-\u007E\u00A0-\u00FF](?!\uFE0F)){1,1000}/y,gt=t=>t>=32&&t<=126?"latin":t===8203||t===8204||t===8205||t===8288?"zero":t<=31||t>=127&&t<=159?"control":t>=160&&t<=255||t>=9472&&t<=9599?"latin":t>=4352&&t<=4607||t>=11904&&t<=40959||t>=44032&&t<=55215||t>=63744&&t<=64255||t>=65280&&t<=65519&&!(t>=65377&&t<=65439)||t>=12352&&t<=12543?"wide":t===8230?"latin":"other",Oe=(t,e)=>{const n=Ae(e),r=Math.floor(t/65536),s=t%65536;let i=n.get(r);if(i||(i=new Map,n.set(r,i)),i.has(s))return i.get(s);let o;switch(gt(t)){case"control":{o=e.width.control;break}case"latin":{o=e.width.regular;break}case"wide":{o=e.width.wide;break}case"zero":{o=0;break}default:switch(ft(t)){case"ambiguous":{o=e.width.ambiguousIsNarrow?e.width.regular:e.width.wide;break}case"fullwidth":{o=e.width.fullWidth;break}case"wide":{o=e.width.wide;break}default:o=e.width.regular}}return i.set(s,o),o},xe=t=>t>=768&&t<=879||t>=6832&&t<=6911||t>=7616&&t<=7679||t>=8400&&t<=8447||t>=65056&&t<=65071||t>=917760&&t<=917999||t>=65024&&t<=65039||t>=3633&&t<=3642||t>=3655&&t<=3662||t>=3761&&t<=3769||t>=3771&&t<=3772||t>=3784&&t<=3789||t>=2304&&t<=2307||t>=2362&&t<=2383||t>=2385&&t<=2391||t>=2402&&t<=2403||t>=2433&&t<=2435||t>=2492&&t<=2500||t>=2509&&t<=2509||t>=2561&&t<=2563||t>=2620&&t<=2637||t>=1611&&t<=1631||t>=1648&&t<=1648||t>=1750&&t<=1773||t>=2276&&t<=2302||t>=1425&&t<=1469||t>=1471&&t<=1471||t>=1473&&t<=1474||t>=1476&&t<=1477||t>=1479&&t<=1479||t>=3893&&t<=3893||t>=3895&&t<=3895||t>=3897&&t<=3897||t>=3953&&t<=3966||t>=3968&&t<=3972||t>=3974&&t<=3975?!0:t>=768&&t<=777||t>=803&&t<=803,Y=(t,e={})=>{if(!t||t.length===0)return{ellipsed:!1,index:0,truncated:!1,width:0};const n={truncation:{countAnsiEscapeCodes:e.countAnsiEscapeCodes??!1,ellipsis:e.ellipsis??"",ellipsisWidth:e.ellipsisWidth??(e.ellipsis?Y(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}},r=Math.max(0,n.truncation.limit-n.truncation.ellipsisWidth),{length:s}=t,i=s>1e4;let o=0,a=0,c=s,l=!1;const u=t.includes("\x1B")||t.includes("");for(;o<s;){if(u&&(t[o]==="\x1B"||t[o]==="")){if(t.startsWith("\x1B]8;;",o)){const y="\x1B]8;;\x07",v=y.length,D=t.indexOf("\x07",o+5);if(D!==-1){const V=t.indexOf(y,D+1);if(V!==-1){const Nt=V+v,vt=t.slice(D+1,V).replace(ct,""),Z=Y(vt,{ambiguousIsNarrow:n.width.ambiguousIsNarrow,ansiWidth:n.width.ansi,controlWidth:n.width.control,countAnsiEscapeCodes:!1,ellipsis:n.truncation.ellipsis,ellipsisWidth:n.truncation.ellipsisWidth,emojiWidth:n.width.emoji,fullWidth:n.width.fullWidth,halfWidth:n.width.halfWidth,limit:Math.max(0,r-a),regularWidth:n.width.regular,tabWidth:n.width.tab,wideWidth:n.width.wide}),U=Z.width;if(Z.truncated)l=!0,c=Math.min(c,o);else if(a+U>r&&(c=Math.min(c,o),l=!0,a+U>n.truncation.limit))break;if(a+=U,o=Nt,l&&a>=n.truncation.limit)break;continue}}}if(M.lastIndex=o,M.test(t)){const y=M.lastIndex-o,v=n.truncation.countAnsiEscapeCodes?y:n.width.ansi;if(a+v>r&&(c=Math.min(c,o),a+v>n.truncation.limit)){l=!0;break}a+=v,o=M.lastIndex;continue}}const h=t.codePointAt(o);if(h===8203||h===65279||h>=8288&&h<=8292){o+=1;continue}if(h===9){if(a+n.width.tab>r&&(c=Math.min(c,o),a+n.width.tab>n.truncation.limit)){l=!0;break}a+=n.width.tab,o+=1;continue}if(j.lastIndex=o,j.test(t)){const y=(j.lastIndex-o)*n.width.regular;if(a+y>r){const v=n.width.regular>0?Math.floor((r-a)/n.width.regular):0;if(c=Math.min(c,o+v),a+y>n.truncation.limit){l=!0;break}}a+=y,o=j.lastIndex;continue}if((h<=31||h>=127&&h<=159)&&(B.lastIndex=o,B.test(t))){const y=(B.lastIndex-o)*n.width.control;if(a+y>r){const v=n.width.control>0?Math.floor((r-a)/n.width.control):0;if(c=Math.min(c,o+v),a+y>n.truncation.limit){l=!0;break}}a+=y,o=B.lastIndex;continue}if(G.lastIndex=o,G.test(t)){if(a+n.width.emoji>r&&(c=Math.min(c,o),a+n.width.emoji>n.truncation.limit)){l=!0;break}a+=n.width.emoji,o=G.lastIndex;continue}const g=t.codePointAt(o)??0;if(xe(g)){o+=g>65535?2:1;continue}let w;if(i)w=Oe(g,n);else switch(gt(g)){case"control":{w=n.width.control;break}case"latin":{w=n.width.regular;break}case"wide":{w=n.width.wide;break}case"zero":{w=0;break}default:switch(ft(g)){case"ambiguous":{w=n.width.ambiguousIsNarrow?n.width.regular:n.width.wide;break}case"fullwidth":{w=n.width.fullWidth;break}case"wide":{w=n.width.wide;break}default:w=n.width.regular}}if(a+w>r&&(c=Math.min(c,o),a+w>n.truncation.limit)){l=!0;break}a+=w,o+=g>65535?2:1}let d=a,p=!1;return l&&n.truncation.limit>=n.truncation.ellipsisWidth&&(d=n.truncation.limit,p=!0),{ellipsed:p,index:l?c:s,truncated:l,width:d}},Ee=(t,e={})=>Y(t,{...e,ellipsis:"",ellipsisWidth:0,limit:Number.POSITIVE_INFINITY}).width,wt=80,bt=24,J=(t,e,{shell:n,env:r}={})=>Qt(t,e,{encoding:"utf8",stdio:["ignore","pipe","ignore"],timeout:500,shell:n,env:r}).trim(),P=(t,e)=>({columns:Number.parseInt(t,10),rows:Number.parseInt(e,10)}),yt=(t,e)=>{const{columns:n,rows:r}=P(t,e);if(!(Number.isNaN(n)||Number.isNaN(r))&&!(n===wt&&r===bt))return{columns:n,rows:r}},Ie=()=>{if(A.platform!=="linux")return!0;try{const t=W.readFileSync("/proc/self/stat","utf8"),e=t.lastIndexOf(") ");if(e===-1)return!1;const n=t.slice(e+2).trim().split(/\s+/),r=Number.parseInt(n[2],10),s=Number.parseInt(n[5],10);return Number.isNaN(r)||Number.isNaN(s)||s<=0?!1:r===s}catch{return!1}};function We(){const{env:t,stdout:e,stderr:n}=A;if(e?.columns&&e?.rows)return P(e.columns,e.rows);if(n?.columns&&n?.rows)return P(n.columns,n.rows);if(t.COLUMNS&&t.LINES)return P(t.COLUMNS,t.LINES);const r={columns:wt,rows:bt};return A.platform==="win32"?q()??r:A.platform==="darwin"?it()??q()??r:it()??q()??ke()??r}const it=()=>{try{const t=A.platform==="darwin"?W.constants.O_EVTONLY|W.constants.O_NONBLOCK:W.constants.O_NONBLOCK,{columns:e,rows:n}=Xt.WriteStream(W.openSync("/dev/tty",t));return{columns:e,rows:n}}catch{}},q=()=>{try{const t=J("tput",["cols"],{env:{TERM:"dumb",...A.env}}),e=J("tput",["lines"],{env:{TERM:"dumb",...A.env}});if(t&&e)return yt(t,e)}catch{}},ke=()=>{try{if(!Ie())return;const t=J("resize",["-u"]).match(/\d+/g);if(t.length===2)return yt(t[0],t[1])}catch{}},I=new Map,Be=500,$=t=>{if(!t||t==="")return"";const e=I.get(t);if(e!==void 0)return e;let n;try{n=Jt(Object.assign([],{raw:[t]}))}catch{n=t}if(I.size>=Be){const r=I.keys().next().value;r!==void 0&&I.delete(r)}return I.set(t,n),n},T=()=>{const t=Mt().CEREBRO_TERMINAL_WIDTH;if(t===void 0)return;const e=Number.parseInt(t,10);if(!(Number.isNaN(e)||e<=0))return e};class $t{lines;constructor(){this.lines=[]}add(e){this.lines.push(e)}toString(){return this.lines.join(te.EOL)}header(e){this.add(C(e)),this.lines.push("")}}const Me=t=>t!==void 0&&t>0?t:We().columns,je=(t,e,n,r)=>{if(t.length===0||t.some(l=>l.length!==2))return;let s=0;for(const l of t){const u=l[0];if(u===void 0)continue;const d=Ee(u);d>s&&(s=d)}if(s===0)return;const i=n+r,o=s+i,a=20+i;if(o+a>e)return;const c=e-o;return[o,c]};class Ce extends $t{constructor(e){if(super(),e.header&&this.header($(e.header)),e.content){if(e.raw)if(Array.isArray(e.content)&&e.content.every(n=>typeof n=="string"))e.content.forEach(n=>{Array.isArray(n)?n.forEach(r=>{this.add($(r))}):this.add($(n))});else if(typeof e.content=="string")this.add($(e.content));else throw new TypeError("Invalid raw content, must be a string or array of strings.");else this.add(this.getContentLines(e.content));this.add("")}}getContentLines(e){if(typeof e=="string"){const n=_({showHeader:!1,style:{border:R,paddingLeft:4,paddingRight:1},terminalWidth:T(),truncateOverflow:!1,wordWrap:!0});return n.addRow([$(e)]),n.toString()}if(Array.isArray(e)&&e.every(n=>typeof n=="string"||Array.isArray(n)&&n.every(r=>typeof r=="string"))){const n=Me(T()),r=a=>Array.isArray(a)?a.map(c=>$(c)):[$(a)],s=e.map(a=>r(a)),i=je(s,n,4,1),o=_({columnWidths:i,showHeader:!1,style:{border:R,paddingLeft:4,paddingRight:1},terminalWidth:n,truncateOverflow:!1,wordWrap:!0});return s.forEach(a=>{i!==void 0&&a.length===2?o.addRow([{content:a[0],wordWrap:!1},a[1]]):o.addRow(a)}),o.toString()}if(typeof e=="object"){const n=e;if(!n.options||!n.data)throw new Error(`Must have an "options" or "data" property
|
|
4
4
|
${JSON.stringify(e)}`);const r=_({showHeader:!1,style:{border:R,paddingLeft:4,paddingRight:1},terminalWidth:T(),truncateOverflow:!1,wordWrap:!0});return n.data.forEach(s=>{Array.isArray(s)?r.addRow(s.map(i=>$(i))):r.addRow([$(s)])}),r.toString()}throw new Error(`invalid input - 'content' must be a string, array of strings or a object:
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import{createRequire as _}from"node:module";import{
|
|
1
|
+
import{createRequire as _}from"node:module";import{x,p as t,y as R}from"./cli-main.js";import{d as P}from"../packem_shared/pm-runner-de-jCq8q.js";import{a as M}from"../packem_shared/build-scripts-pdVmqXRm.js";import{e as v}from"../packem_shared/index-DHD8wb6Z.js";import{y as k}from"../packem_shared/isAccessibleSync-DYKTrrvc-CSnBISfV.js";import{p as q}from"../packem_shared/readJsonSync-CbryXYxN-B2aSeDpC.js";let j;const B=c=>(j??=_(import.meta.url))(c),y=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,D=c=>{if(typeof y<"u"&&y.versions&&y.versions.node){const[i,f]=y.versions.node.split(".").map(Number);if(i>22||i===22&&f>=3||i===20&&f>=16)return y.getBuiltinModule(c)}return B(c)},{readdirSync:S,statSync:N}=D("node:fs"),T=(c,i={})=>{const f=v(c,"node_modules");if(!k(f))return[];const l=new Map,p=new Set,b=(n,o,r)=>{const e=`${o}@${r}`;if(p.has(e))return;p.add(e);const s=r.startsWith(c)?r.slice(c.length+1):r;let u=l.get(n);u||(u=[],l.set(n,u)),u.some($=>$.name===o)||u.push({name:o,relativePath:s})},m=(n,o="")=>{let r;try{r=S(n)}catch{return}for(const e of r){const s=v(n,e);if(e.startsWith("@")){m(s,`${e}/`);continue}if(e===".pnpm"&&o===""){let a;try{a=S(s)}catch{continue}for(const d of a){const g=v(s,d,"node_modules");k(g)&&m(g)}continue}if(e.startsWith("."))continue;const u=o+e,$=v(s,"package.json");try{if(!N(s).isDirectory()||!k($))continue;const a=q($),d=typeof a.name=="string"?a.name:u;if(typeof a.bin=="string"){const w=d.includes("/")?d.split("/").pop():d;b(w,d,s)}else if(a.bin&&typeof a.bin=="object")for(const w of Object.keys(a.bin))b(w,d,s);const g=v(s,"node_modules");k(g)&&m(g)}catch{}}};m(f);const h=[];for(const[n,o]of l)o.length<2||i[n]===!0||o.every(e=>i[`${e.name}#${n}`]===!0)||h.push({bin:n,packages:o});return h.sort((n,o)=>n.bin.localeCompare(o.bin))},V=new Set(["bun","npm","pnpm","yarn"]),F=({options:c,visConfig:i,workspaceRoot:f})=>{const l=f??process.cwd(),p=P(l),b=i?.security?.policies?.installScripts?.allow??{},m=i?.security?.allowBins??{},h=i?.security?.pinVersions===!0,n=M(l,b,{pinVersions:h}),o=T(l,m),r=i&&V.has(p.name)?x(i,p.name,l):void 0;if(c.json){process.stdout.write(`${JSON.stringify({binConflicts:o,drift:r,excess:n.excess,installed:n.installed.map(e=>({hooks:e.hooks,name:e.name,version:e.version})),packageManager:p.name,pinVersions:h,unapproved:n.unapproved.map(e=>({hooks:e.hooks,name:e.name,version:e.version})),versionDrift:n.versionDrift},void 0,2)}
|
|
2
2
|
`);return}if(t.info(`Build-script status (${p.name}):
|
|
3
3
|
`),n.installed.length===0&&n.unapproved.length===0&&t.success(" No installed packages declare lifecycle scripts."),n.installed.length>0){t.success(` Approved (${String(n.installed.length)}):`);for(const e of n.installed)t.info(` ✓ ${e.name} — ${e.hooks.join(", ")}`)}if(n.unapproved.length>0){t.info(""),t.warn(` Unapproved (${String(n.unapproved.length)}):`);for(const e of n.unapproved)t.info(` ✗ ${e.name} — ${e.hooks.join(", ")}`);t.notice(" Run 'vis approve-builds' to review.")}if(n.excess.length>0){t.info(""),t.warn(` Stale allowlist entries (${String(n.excess.length)}):`);for(const e of n.excess)t.info(` ! ${e}`);t.notice(" Remove these from vis.config.ts security.policies.installScripts.allow.")}if(n.versionDrift.length>0){t.info(""),t.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:s}of n.versionDrift)t.info(` ${e} → ${s}`);t.notice(" Update vis.config.ts security.policies.installScripts.allow keys to migrate.")}if(o.length>0){t.info(""),t.warn(` Bin conflicts (${String(o.length)}) — multiple packages expose the same bin name:`);for(const e of o)t.info(` ${e.bin} ← ${e.packages.map(s=>s.name).join(", ")}`);t.notice(" Add the bin (or 'pkg#bin') to vis.config.ts security.allowBins to silence this.")}if(r?.hasDrift){t.info("");for(const e of R(r))t.warn(e)}};export{F as default};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import{p as o}from"./cli-main.js";import{r as f}from"../packem_shared/advisories-
|
|
1
|
+
import{p as o}from"./cli-main.js";import{r as f}from"../packem_shared/advisories-0ScpWAHV.js";const d=async({fs:c,logger:u,options:r,workspaceRoot:t})=>{if(!t)throw new Error("Could not determine workspace root. Run this command inside a workspace.");const e=r.db??f(t),s=r.format==="json";if(!r.force){o.warn(`Prune is destructive. Will remove: ${e}`),o.info("Re-run with --force to proceed."),s&&process.stdout.write(`${JSON.stringify({dbPath:e,reason:"needs --force",removed:!1})}
|
|
2
2
|
`);return}const a=[e,`${e}-wal`,`${e}-shm`,`${e}-journal`],i=[];for(const n of a)try{await c.rm(n,{force:!0}),i.push(n)}catch{}if(s){process.stdout.write(`${JSON.stringify({dbPath:e,files:i,removed:!0})}
|
|
3
3
|
`);return}o.success(`Removed ${e}.`)},v=d;export{v as advisoriesPruneExecute};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{p as s,
|
|
1
|
+
import{p as s,g as a,h as p}from"./cli-main.js";const u=({options:t,visConfig:i,workspaceRoot:c})=>{const r=c??process.cwd(),l=i?.security?.policies?.installScripts?.allow??{},e=Object.entries(l).filter(([,o])=>o).map(([o])=>o);e.length===0&&!t.rootOnly&&(s.warn("No approved packages in security.policies.installScripts.allow — nothing to run."),!t.withRoot)||(t.rootOnly||a(r,e),(t.withRoot||t.rootOnly)&&p(r))};export{u as default};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{b as d,F as i,J as l}from"../packem_shared/index.server-BAjDJSEu.js";import{p as a}from"./cli-main.js";import{r as y,g}from"../packem_shared/advisories-
|
|
1
|
+
import{b as d,F as i,J as l}from"../packem_shared/index.server-BAjDJSEu.js";import{p as a}from"./cli-main.js";import{r as y,g}from"../packem_shared/advisories-0ScpWAHV.js";const h=n=>{if(n===0)return"0 B";const r=["B","KB","MB","GB"],o=Math.min(Math.floor(Math.log(n)/Math.log(1024)),r.length-1),s=n/1024**o;return`${s.toFixed(s<10&&o>0?1:0)} ${r[o]}`},v=n=>{if(!n)return"never";const r=Date.parse(n);if(Number.isNaN(r))return n;const o=Date.now()-r;if(o<0)return n;const s=Math.floor(o/6e4);if(s<1)return"just now";if(s<60)return`${s}m ago`;const t=Math.floor(s/60);return t<24?`${t}h ago`:`${Math.floor(t/24)}d ago`},$=async({logger:n,options:r,workspaceRoot:o})=>{if(!o)throw new Error("Could not determine workspace root. Run this command inside a workspace.");const s=r.db??y(o),t=await g(o,s);if(r.format==="json"){process.stdout.write(`${JSON.stringify({dbPath:s,ecosystems:t.ecosystems.map(e=>({advisoryCount:e.advisoryCount,lastSyncIso:e.lastSyncIso,manifestEtag:e.manifestEtag??null,name:e.name})),exists:t.exists,schemaVersion:t.schemaVersion,sizeBytes:t.sizeBytes},void 0,2)}
|
|
2
2
|
`);return}if(a.info(`DB: ${s}`),!t.exists){a.warn(`No advisory DB yet. Run ${d("vis advisories sync")} to populate.`);return}if(a.info(`Schema: v${t.schemaVersion} Size: ${h(t.sizeBytes)}`),t.ecosystems.length===0){a.warn("DB exists but contains no ecosystems. Run `vis advisories sync`.");return}a.info(""),a.info("Ecosystem Advisories Last sync ETag"),a.info(i("────────── ────────── ───────────────── ──────"));for(const e of t.ecosystems){const c=e.name.padEnd(10),u=e.advisoryCount.toLocaleString().padStart(10),m=`${e.lastSyncIso||"never"} (${v(e.lastSyncIso)})`.padEnd(19),f=e.manifestEtag??i("—");a.info(`${l(c)} ${u} ${m} ${f}`)}},E=$;export{E as advisoriesStatusExecute};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{F as p}from"../packem_shared/index.server-BAjDJSEu.js";import{p as c}from"./cli-main.js";import{s as v}from"../packem_shared/scan-progress-
|
|
1
|
+
import{F as p}from"../packem_shared/index.server-BAjDJSEu.js";import{p as c}from"./cli-main.js";import{s as v}from"../packem_shared/scan-progress-5uTRdC1G.js";import{D as $,s as D}from"../packem_shared/advisories-0ScpWAHV.js";const S=o=>o?.security?.audit?.advisories??{},w=o=>o?o.split(",").map(r=>r.trim()).filter(r=>r.length>0):["npm"],b=async({logger:o,options:r,visConfig:y,workspaceRoot:l})=>{if(!l)throw new Error("Could not determine workspace root. Run this command inside a workspace.");const d=r.format==="json",u=S(y),f=r.source??u.source??$,m=w(r.ecosystem),h=m.map(s=>({id:s,label:`Sync ${s} advisories`})),a=v(h,{live:!d}),i=[];try{for(const s of m){a.start(s);const e=Date.now();try{const t=await D({allowedHosts:u.allowedHosts,dbPath:r.db,ecosystem:s,force:!!r.force,source:f,workspaceRoot:l});i.push({ecosystem:s,result:t}),t.upToDate?a.finish(s,"ok",`up to date · ${g(Date.now()-e)}`):a.finish(s,"ok",`${t.advisoriesIngested.toLocaleString()} advisories · ${g(t.durationMs)}`)}catch(t){const n=t instanceof Error?t.message:String(t);i.push({ecosystem:s,error:n}),a.finish(s,"error",n)}}}finally{a.stop()}if(d){const s={ecosystems:i.map(e=>({advisoriesIngested:e.result?.advisoriesIngested??0,dbPath:e.result?.dbPath??null,durationMs:e.result?.durationMs??0,ecosystem:e.ecosystem,error:e.error??null,upToDate:e.result?.upToDate??!1})),source:f};process.stdout.write(`${JSON.stringify(s,void 0,2)}
|
|
2
2
|
`)}else{const s=i.filter(n=>n.error),e=i.filter(n=>n.result),t=e[0];t?.result?.dbPath&&c.info(p(`DB: ${t.result.dbPath}`)),s.length===0?c.success(`Synced ${e.length} ecosystem${e.length===1?"":"s"}.`):c.error(`${s.length} ecosystem${s.length===1?"":"s"} failed to sync.`)}i.some(s=>s.error)&&(process.exitCode=1)},g=o=>o>=1e3?`${(o/1e3).toFixed(1)}s`:`${Math.round(o)}ms`,C=b;export{C as advisoriesSyncExecute};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{createRequire as D}from"node:module";import{
|
|
1
|
+
import{createRequire as D}from"node:module";import{L as q}from"./target-merge-B4No-LHM.js";import{advisoriesQuery as C,advisoriesIngest as M,advisoriesStatus as S,NATIVE_BINDING_VERSION as w}from"#native";let I;const R=e=>(I??=D(import.meta.url))(e),u=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,l=e=>{if(typeof u<"u"&&u.versions&&u.versions.node){const[t,s]=u.versions.node.split(".").map(Number);if(t>22||t===22&&s>=3||t===20&&s>=16)return u.getBuiltinModule(e)}return R(e)},{randomUUID:T}=l("node:crypto"),{existsSync:O,createWriteStream:L}=l("node:fs"),{mkdir:$,unlink:U,stat:x}=l("node:fs/promises"),{join:g,dirname:P}=l("node:path"),{Readable:k}=l("node:stream"),{pipeline:B}=l("node:stream/promises"),p=6;if(w!==p)throw new Error(`vis native binding ABI mismatch in advisories: expected ${p}, got ${w}. Rebuild via \`pnpm --filter @visulima/vis run build:native\` or reinstall the platform binding package.`);const X="https://osv-vulnerabilities.storage.googleapis.com",W=new Set(["osv-vulnerabilities.storage.googleapis.com"]);class j extends Error{cause="DB_NOT_FOUND";constructor(t){super(`No local advisory DB at ${t}. Run 'vis advisories sync' first.`),this.name="AdvisoryDbNotFoundError"}}class y extends Error{cause="SOURCE_NOT_ALLOWED";constructor(t){super(`Advisory source host '${t}' is not in the built-in allowlist. Add it to \`security.audit.advisories.allowedHosts\` if intentional.`),this.name="AdvisorySourceNotAllowedError"}}class _ extends Error{cause="SYNC_NETWORK";constructor(t,s){super(`Advisory sync failed for ${t}: ${s}. Check connectivity, proxy env vars, or --source.`),this.name="AdvisorySyncNetworkError"}}const v=e=>{const s=q("vis",{create:!0,cwd:e})??g(e,"node_modules",".cache","vis");return g(s,"advisories","db.sqlite")},V=(e,t)=>{let s;try{s=new URL(e)}catch{throw new y(e)}if(s.protocol!=="https:")throw new y(`${s.protocol}//${s.host}`);if(!new Set([...W,...t??[]]).has(s.host))throw new y(s.host);return s},J=async e=>{const t=e.dbPath??v(e.workspaceRoot);await $(P(t),{recursive:!0});const s=V(e.source,e.allowedHosts),n=new URL(`${e.ecosystem}/all.zip`,G(s.toString())),a=await H(t,e.ecosystem);let o=null;if(!e.force){const i=await E(n,{method:"HEAD"});if(i.ok&&(o=i.headers.get("etag"),o&&a&&o===a))return{advisoriesIngested:0,dbPath:t,durationMs:0,upToDate:!0}}const c=`${t}.${e.ecosystem}.${process.pid}.${T()}.zip.tmp`,r=await E(n,{method:"GET"});if(!r.ok||!r.body)throw new _(n.toString(),r.status);o||(o=r.headers.get("etag"));const m=r.headers.get("content-length"),d=m?Number.parseInt(m,10):null;let h=0;const b=L(c),f=k.fromWeb(r.body);e.onProgress&&d&&f.on("data",i=>{h+=i.byteLength,e.onProgress?.(h,d,"download")}),await B(f,b);try{const i=await M({dbPath:t,ecosystem:e.ecosystem,manifestEtag:o??void 0,zipPath:c},(A,N)=>e.onProgress?.(A,N,"ingest"));return{advisoriesIngested:i.advisoriesIngested,dbPath:t,durationMs:i.durationMs,upToDate:!1}}finally{await U(c).catch(()=>{})}},Z=(e,t)=>{if(e.length===0)return new Map;const s=t.dbPath??v(t.workspaceRoot),n=t.ecosystem??"npm";if(!O(s))throw new j(s);const a=e.map(r=>({ecosystem:n,name:r.name,version:r.version})),o=C(s,a),c=new Map;for(const[r,m]of e.entries()){const d=o[r];!d||d.vulnerabilities.length===0||c.set(m.name,d.vulnerabilities.map(h=>z(h)))}return c},ee=async(e,t)=>{const s=t??v(e);return S(s)},H=async(e,t)=>{try{await x(e)}catch{return null}return S(e).ecosystems.find(a=>a.name===t)?.manifestEtag??null},z=e=>({aliases:e.aliases.length>0?e.aliases:void 0,cvssScore:e.cvssScore??void 0,fixedVersions:e.fixedVersions,id:e.id,severity:F(e.severity),summary:e.summary}),F=e=>{const t=e.toUpperCase();return t==="CRITICAL"||t==="HIGH"||t==="MODERATE"||t==="LOW"?t:"UNKNOWN"},G=e=>e.endsWith("/")?e:`${e}/`,E=async(e,t)=>{try{return await fetch(e,t)}catch(s){throw new _(e.toString(),s instanceof Error?s.message:String(s))}};export{j as A,X as D,ee as g,Z as q,v as r,J as s};
|
package/dist/packem_shared/{affected-selection-CoRXp5H4.js → affected-selection-BMoQWuHl.js}
RENAMED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{createRequire as C}from"node:module";import{getAffectedProjects as S}from"@visulima/task-runner";import{i as W}from"./index-BjdW45xX.js";import{V as j}from"./vis-user-error-
|
|
1
|
+
import{createRequire as C}from"node:module";import{getAffectedProjects as S}from"@visulima/task-runner";import{i as W}from"./index-BjdW45xX.js";import{V as j}from"./vis-user-error-Dkc97rGY.js";import{r as A}from"./affected-shas-Dd0P7fGD.js";let T;const $=e=>(T??=C(import.meta.url))(e),f=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,R=e=>{if(typeof f<"u"&&f.versions&&f.versions.node){const[t,s]=f.versions.node.split(".").map(Number);if(t>22||t===22&&s>=3||t===20&&s>=16)return f.getBuiltinModule(e)}return $(e)},{spawnSync:I}=R("node:child_process"),v=new Set(["deep","direct","none"]),B=e=>{const t=[],s=e.split("\0");for(let n=0;n<s.length;n++){const o=s[n];if(!o||o.length<4)continue;const p=o.slice(0,2),d=o.slice(3);if(d&&t.push(d),p.includes("R")||p.includes("C")){n+=1;const c=s[n];c&&t.push(c)}}return t},P=e=>{const t=I("git",["status","--porcelain","-z"],{cwd:e,encoding:"utf8"});return t.error||t.status!==0||typeof t.stdout!="string"?[]:B(t.stdout)},D=async(e,t,s={})=>{const n=e.downstream??"deep",o=e.upstream??"none";if(!v.has(n))throw new j(`Invalid --downstream value: "${n}". Must be "none", "direct", or "deep".`);if(!v.has(o))throw new j(`Invalid --upstream value: "${o}". Must be "none", "direct", or "deep".`);const{projectGraph:p,projects:d,workspaceRoot:c}=t,u=[];let{base:m}=e,{head:r}=e;if(!m||!r){const l=A({defaultBase:s.defaultBase,workspaceRoot:c});m=m||l.base,r=r||l.head,u.push(`Resolved affected refs from ${l.provider} (${l.notes.join("; ")})`)}const k=s.runningInCi??W,h=r==="HEAD"||r==="",b=e.uncommitted??(!k&&h);let a=[];if(b)if(h){const g=(s.readWorkingTreeChanges??P)(c),y=Object.values(d).map(i=>i.root?.replace(/\/$/,"")).filter(i=>!!i&&i!==".");a=g.filter(i=>y.some(_=>i===_||i.startsWith(`${_}/`)));const w=g.length-a.length;a.length>0&&u.push(`including ${a.length} uncommitted working-tree file(s)`),w>0&&u.push(`ignoring ${w} uncommitted path(s) outside any project (untracked scratch would otherwise mark every project affected)`)}else u.push(`ignoring --uncommitted: --head=${r} pins the comparison to a commit, not the working tree`);return{...await S({additionalChangedFiles:a,base:m,downstream:n,head:r,projectGraph:p,projects:d,upstream:o,workspaceRoot:c}),notes:u,uncommittedFileCount:a.length}};export{D as s};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{createRequire as T}from"node:module";import{readLastRunSummary as _}from"@visulima/task-runner";import{a as $}from"./failure-log-D92tM0ie.js";import{
|
|
1
|
+
import{createRequire as T}from"node:module";import{readLastRunSummary as _}from"@visulima/task-runner";import{a as $}from"./failure-log-D92tM0ie.js";import{n as v,o as P,q as D,f as j,s as E,t as N,u as A}from"../packem_chunks/cli-main.js";import{c as R}from"./formatBytes-BHAzNIrn-DFIppnY0.js";import{v as x,U as y,e as B,a as H}from"./index-DHD8wb6Z.js";import{a as q,b as C,e as U}from"./ai-analysis-DSQQDFU9.js";let I;const F=e=>(I??=T(import.meta.url))(e),h=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,O=e=>{if(typeof h<"u"&&h.versions&&h.versions.node){const[t,n]=h.versions.node.split(".").map(Number);if(t>22||t===22&&n>=3||t===20&&n>=16)return h.getBuiltinModule(e)}return F(e)},{readFile:L,writeFile:M}=O("node:fs/promises"),k=32*1024,W=(e,t)=>{if(e.length<=t)return e;const n=e.slice(-t),o=e.length-n.length;return`[…${String(o)} bytes truncated from head…]
|
|
2
2
|
${n}`},J=async(e,t)=>t===void 0?_(e,{dataDirectory:R(e)}):j(e,t),pe=async(e,t,n={})=>{const o=n.terminalOutputLimit??k,[r,i]=await Promise.all([$(e,t),J(e,n.runId)]),s=i?v(i,t):void 0;if(!r&&!s)return;let a,c;if(i&&s){const u=await P(e,i.id),f=u?v(u,t):void 0;a=D(s.hashDetails,f?.hashDetails),c=u?.id}const d=r?.terminalOutput??"";return{command:r?.command??void 0,cwd:r?.cwd??void 0,dependencies:s?.dependencies??[],duration:s?.duration,exitCode:r?.exitCode??s?.exitCode,hash:s?.hash??r?.hash,hashDetails:s?.hashDetails,hashDiff:a,previousRunId:c,project:s?.target.project,runId:i?.id??r?.runId,status:r?.status??(s?K(s):void 0),target:s?.target.target,taskId:t,terminalOutput:W(d,o),terminalOutputCaptured:!!r,timestamp:r?.timestamp??s?.endTime??s?.startTime}},K=e=>{if(e.exitCode!==void 0&&e.exitCode!==0)return"failure";switch(e.cacheStatus){case"HIT":return"local-cache";case"REMOTE_HIT":return"remote-cache";case"SKIPPED":return"skipped";default:return e.exitCode===0?"success":void 0}},Y=3600*1e3,w=80,V=new Set(["high","low","medium"]),X=()=>`You are an expert software engineer helping fix a failing build/test/lint task.
|
|
3
3
|
|
|
4
4
|
You will be given:
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{createRequire as v}from"node:module";import{t as T}from"./compile-cache-DoMHRsRZ.js";import{l as y,i as R,a as j,b as M,c as m,g as S}from"./package-version-
|
|
1
|
+
import{createRequire as v}from"node:module";import{t as T}from"./compile-cache-DoMHRsRZ.js";import{l as y,i as R,a as j,b as M,c as m,g as S}from"./package-version-CJxZ_B7G.js";import{i as $}from"./index-BjdW45xX.js";let _;const x=s=>(_??=v(import.meta.url))(s),t=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,b=s=>{if(typeof t<"u"&&t.versions&&t.versions.node){const[e,o]=t.versions.node.split(".").map(Number);if(e>22||e===22&&o>=3||e===20&&o>=16)return t.getBuiltinModule(s)}return x(s)},{createRequire:w}=b("node:module");let N;const O=s=>(N??=w(import.meta.url))(s),r=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,f=s=>{if(typeof r<"u"&&r.versions&&r.versions.node){const[e,o]=r.versions.node.split(".").map(Number);if(e>22||e===22&&o>=3||e===20&&o>=16)return r.getBuiltinModule(s)}return O(s)},{execFileSync:C}=f("node:child_process"),{totalmem:I}=f("node:os"),q=/--max-old-space-size=(\d+)/,z=/--max-semi-space-size=(\d+)/,E=s=>Math.floor(I()/1024/1024*s),P=s=>s<=512?4:s<=1024?8:s<=2048?16:s<=4096?32:s<=8192?64:Math.floor(Math.log2(s))*8,d=(s,e)=>{for(const o of e){const n=s.exec(o);if(n)return Number.parseInt(n[1],10)}},B=s=>{const o=[...y()],n=[...R()],a=d(q,o),p=d(z,o);if(a!==void 0&&p!==void 0)return;const l=a??E(.75),g=p??P(l),c=[];if(a===void 0&&c.push(`--max-old-space-size=${String(l)}`),p===void 0&&c.push(`--max-semi-space-size=${String(g)}`),c.length!==0)try{C(j(),[...c,...o,...n.slice(1)],{env:M(),stdio:"inherit"}),m(0)}catch(h){const u=h.status;m(typeof u=="number"?u:1)}},V=()=>{process.env.VIS_VERSION=S()},H=s=>{!process.stdout.isTTY||$||process.env.TERM==="dumb"||process.stdout.write(`\x1B]0;${s}\x07`)},L=new Set(["","--help","--version","-h","-v","completion","dlx","exec","x"]),i=process.argv[2]??"";!L.has(i)&&!process.argv.includes("--help")&&!process.argv.includes("-h")&&B();process.argv.includes("--no-color")&&(process.env.NO_COLOR="1",process.env.FORCE_COLOR="0");V();T();(async()=>{if(i==="__pm-shim"){const{dispatchShim:e}=await import("../packem_chunks/dispatch.js");e(process.argv[3]??"",process.argv.slice(4));return}if(i==="x"){const{runLeanX:e}=await import("../packem_chunks/lean.js");await e(process.argv.slice(3));return}if(i==="exec"||i==="dlx"){const{runExecCli:e}=await import("../packem_chunks/cli-exec.js");await e();return}const{runCli:s}=await import("../packem_chunks/cli-main.js").then(e=>e.aw);await s()})();export{H as s};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{createRequire as j}from"node:module";import{
|
|
1
|
+
import{createRequire as j}from"node:module";import{L as J}from"./target-merge-B4No-LHM.js";import{osvBloomDecode as z,osvBloomProbeBatch as K,NATIVE_BINDING_VERSION as D}from"#native";let k;const V=e=>(k??=j(import.meta.url))(e),h=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,v=e=>{if(typeof h<"u"&&h.versions&&h.versions.node){const[s,t]=h.versions.node.split(".").map(Number);if(s>22||s===22&&t>=3||s===20&&t>=16)return h.getBuiltinModule(e)}return V(e)},{createHash:H,randomUUID:P}=v("node:crypto"),{existsSync:g}=v("node:fs"),{readFile:O,mkdir:T,stat:B,writeFile:F,rename:q,unlink:G}=v("node:fs/promises"),{join:d,dirname:W}=v("node:path"),I=6;if(D!==I)throw new Error(`vis native binding ABI mismatch in osv-bloom: expected ${I}, got ${D}. Rebuild via \`pnpm --filter @visulima/vis run build:native\` or reinstall the platform binding package.`);const nt="https://endevco.github.io/osv-bloom",X=new Set(["endevco.github.io"]);class w extends Error{cause="OSV_BLOOM_SOURCE_NOT_ALLOWED";constructor(s){super(`osv-bloom source host '${s}' is not in the built-in allowlist. Add it to \`security.audit.advisories.bloom.allowedHosts\` if intentional.`),this.name="OsvBloomSourceNotAllowedError"}}class b extends Error{cause="OSV_BLOOM_NETWORK";constructor(s,t){super(`osv-bloom fetch failed for ${s}: ${t}. Check connectivity, proxy env vars, or --source.`),this.name="OsvBloomNetworkError"}}class Y extends Error{cause="OSV_BLOOM_INTEGRITY";constructor(s,t){super(`osv-bloom filter.bin sha256 mismatch (expected ${s}, got ${t}). Refusing to install a corrupted filter.`),this.name="OsvBloomIntegrityError"}}class m extends Error{cause="OSV_BLOOM_MANIFEST";constructor(s){super(`osv-bloom manifest invalid: ${s}`),this.name="OsvBloomManifestError"}}class Q extends Error{cause="OSV_BLOOM_CACHE_MISS";constructor(s){super(`No osv-bloom cache at ${s}. Run 'vis advisories bloom sync' first.`),this.name="OsvBloomCacheMissError"}}const p=e=>{const t=J("vis",{create:!0,cwd:e})??d(e,"node_modules",".cache","vis");return d(t,"osv-bloom")},l=e=>d(e,"filter.bin"),L=e=>d(e,"manifest.json"),$=e=>d(e,"state.json"),Z=(e,s)=>{let t;try{t=new URL(e)}catch{throw new w(e)}if(!t.host)throw new w(e);if(t.protocol!=="https:")throw new w(`${t.protocol}//${t.host}`);if(!new Set([...X,...s??[]]).has(t.host))throw new w(t.host);return t},at=async e=>{const s=Date.now(),t=e.cacheDir??p(e.workspaceRoot);await T(t,{recursive:!0});const r=Z(e.source,e.allowedHosts),n=new URL("manifest.json",M(r.toString())),o=new URL("filter.bin",M(r.toString())),a=await A(n,{method:"GET"});if(!a.ok)throw new b(n.toString(),a.status);const _=await a.text(),i=R(_),u=await x(t);if(!e.force&&u?.setDigestSha256===i.setDigestSha256&&g(l(t)))return{bytesOnDisk:(await B(l(t))).size,cacheDir:t,durationMs:Date.now()-s,manifest:i,upToDate:!0};const E={};!e.force&&u?.filterEtag&&(E.headers={"if-none-match":u.filterEtag});const f=await A(o,{...E,method:"GET"});if(f.status===304&&u&&g(l(t)))return await N(t,_,{fetchedAtIso:new Date().toISOString(),filterEtag:u.filterEtag,setDigestSha256:i.setDigestSha256}),{bytesOnDisk:(await B(l(t))).size,cacheDir:t,durationMs:Date.now()-s,manifest:i,upToDate:!0};if(!f.ok||!f.body)throw new b(o.toString(),f.status);const c=Buffer.from(await f.arrayBuffer());e.onProgress&&e.onProgress(c.length,c.length);const y=tt(c);if(y!==i.filterSha256)throw new Y(i.filterSha256,y);if(c.length!==i.bloomByteLen)throw new m(`filter.bin length ${c.length} does not match manifest.bloom_byte_len ${i.bloomByteLen}`);const U=f.headers.get("etag")??void 0;return await S(l(t),c),await N(t,_,{fetchedAtIso:new Date().toISOString(),filterEtag:U,setDigestSha256:i.setDigestSha256}),{bytesOnDisk:c.length,cacheDir:t,durationMs:Date.now()-s,manifest:i,upToDate:!1}},it=async(e,s)=>{const t=s?.cacheDir??p(e),r=l(t);if(!g(r)){if(s?.softFail)return null;throw new Q(t)}const n=await O(r);return z(n)},ct=(e,s)=>K(e,s),lt=async(e,s)=>{const t=s??p(e);if(!g(l(t)))return{cacheDir:t,present:!1};let n,o;try{n=R(await O(L(t),"utf8"))}catch{}try{o=await x(t)}catch{}return{cacheDir:t,fetchedAtIso:o?.fetchedAtIso,manifest:n,present:!0}},R=e=>{let s;try{s=JSON.parse(e)}catch(o){throw new m(o instanceof Error?o.message:String(o))}const t=o=>{const a=s[o];if(typeof a!="number"||Number.isNaN(a))throw new m(`field '${o}' missing or non-numeric`);return a},r=o=>{const a=s[o];if(typeof a!="string"||a.length===0)throw new m(`field '${o}' missing or empty`);return a},n=t("format_version");if(n!==1)throw new m(`unsupported format_version ${n} (this build expects v1)`);return{advisoryCount:t("advisory_count"),bloomByteLen:t("bloom_byte_len"),bloomKHashes:t("bloom_k_hashes"),bloomMBits:t("bloom_m_bits"),builtAtRfc3339:r("built_at_rfc3339"),builtAtUnix:t("built_at_unix"),entryCount:t("entry_count"),filterSha256:r("filter_sha256"),formatVersion:n,setDigestSha256:r("set_digest_sha256"),sourceUrl:r("source_url"),targetFpr:t("target_fpr")}},x=async e=>{try{const s=await O($(e),"utf8"),t=JSON.parse(s);return typeof t.setDigestSha256!="string"||typeof t.fetchedAtIso!="string"?void 0:{fetchedAtIso:t.fetchedAtIso,filterEtag:typeof t.filterEtag=="string"?t.filterEtag:void 0,setDigestSha256:t.setDigestSha256}}catch{return}},N=async(e,s,t)=>{await S(L(e),Buffer.from(s,"utf8")),await S($(e),Buffer.from(`${JSON.stringify(t,void 0,2)}
|
|
2
2
|
`,"utf8"))},S=async(e,s)=>{await T(W(e),{recursive:!0});const t=`${e}.${process.pid}.${P()}.tmp`;try{await F(t,s),await q(t,e)}catch(r){throw await G(t).catch(()=>{}),r}},tt=e=>H("sha256").update(e).digest("hex"),M=e=>e.endsWith("/")?e:`${e}/`,et=3e4,A=async(e,s)=>{try{return await fetch(e,{...s,signal:AbortSignal.timeout(et)})}catch(t){throw new b(e.toString(),t instanceof Error?t.message:String(t))}};export{nt as D,Q as O,lt as g,it as l,ct as p,at as s};
|