@visulima/vis 4.1.19 → 4.1.20

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.
Files changed (56) hide show
  1. package/CHANGELOG.md +9 -0
  2. package/dist/bin.js +1 -1
  3. package/dist/binx.js +1 -1
  4. package/dist/packem_chunks/catalog.js +42 -44
  5. package/dist/packem_chunks/cli-exec.js +1 -1
  6. package/dist/packem_chunks/cli-main.js +142 -146
  7. package/dist/packem_chunks/fix.js +1 -1
  8. package/dist/packem_chunks/handler10.js +1 -1
  9. package/dist/packem_chunks/handler13.js +1 -1
  10. package/dist/packem_chunks/handler15.js +1 -1
  11. package/dist/packem_chunks/handler19.js +1 -1
  12. package/dist/packem_chunks/handler2.js +1 -1
  13. package/dist/packem_chunks/handler21.js +1 -1
  14. package/dist/packem_chunks/handler24.js +1 -1
  15. package/dist/packem_chunks/handler28.js +1 -1
  16. package/dist/packem_chunks/handler3.js +1 -1
  17. package/dist/packem_chunks/handler5.js +1 -1
  18. package/dist/packem_chunks/handler59.js +1 -1
  19. package/dist/packem_chunks/handler6.js +1 -1
  20. package/dist/packem_chunks/handler60.js +1 -1
  21. package/dist/packem_chunks/handler66.js +1 -1
  22. package/dist/packem_chunks/handler67.js +10 -10
  23. package/dist/packem_chunks/handler70.js +1 -1
  24. package/dist/packem_chunks/handler72.js +1 -1
  25. package/dist/packem_chunks/handler73.js +1 -1
  26. package/dist/packem_chunks/handler75.js +1 -1
  27. package/dist/packem_chunks/handler78.js +1 -1
  28. package/dist/packem_chunks/heal.js +1 -1
  29. package/dist/packem_chunks/help-command.js +1 -1
  30. package/dist/packem_chunks/index5.js +2 -2
  31. package/dist/packem_chunks/keys-refresh.js +1 -1
  32. package/dist/packem_chunks/verify-lockfile.js +1 -1
  33. package/dist/packem_shared/Table-kgZ-Cd21-DdNsp69H.js +9 -0
  34. package/dist/packem_shared/{affected-selection-BXrRytsU.js → affected-selection-Bt4qkPUb.js} +1 -1
  35. package/dist/packem_shared/{ai-fix-CyUx_ZAB.js → ai-fix-BHyx1F1j.js} +1 -1
  36. package/dist/packem_shared/{bin-x7RPlduv.js → bin-Bq3tJmvE.js} +1 -1
  37. package/dist/packem_shared/{failure-log-DE_MJCzB.js → failure-log-3R522Vb5.js} +1 -1
  38. package/dist/packem_shared/formatBytes-BHAzNIrn-XohRrPdt.js +4 -0
  39. package/dist/packem_shared/{index-CIIKPX4H.js → index-Czrll7SU.js} +1 -1
  40. package/dist/packem_shared/{index-Chv2RJRN.js → index-Vm90Te96.js} +1 -1
  41. package/dist/packem_shared/{lifecycle-DW8KRF5d.js → lifecycle-CAIJbxIa.js} +1 -1
  42. package/dist/packem_shared/{package-version-ZC59HAtH.js → package-version-DFlytdgJ.js} +1 -1
  43. package/dist/packem_shared/{packument-CHdDsn0O.js → packument-DyuhH1Gz.js} +1 -1
  44. package/dist/packem_shared/{project-name-filter-BmszI2_J.js → project-name-filter-CC5FF49q.js} +1 -1
  45. package/dist/packem_shared/{provenance-w-NIPtim.js → provenance-BH80RHXx.js} +1 -1
  46. package/dist/packem_shared/{registry-keys-_IKDLSbu.js → registry-keys-BWHRFWbb.js} +1 -1
  47. package/dist/packem_shared/{resolve-explicit-CsTmALmE.js → resolve-explicit-DuJ3mbzt.js} +1 -1
  48. package/dist/packem_shared/{s1ngularity-BRk_GMUj.js → s1ngularity-BJ5j2vbJ.js} +1 -1
  49. package/dist/packem_shared/{signatures-ijwqxAtF.js → signatures-BP042BlB.js} +1 -1
  50. package/dist/packem_shared/{vis-update-app-DNeU8RBQ.js → vis-update-app-CR21zyht.js} +1 -1
  51. package/dist/packem_shared/{vis-user-error-DFPJeiL5.js → vis-user-error-qqqhLoF6.js} +12 -12
  52. package/index.d.ts +204 -204
  53. package/index.js +52 -52
  54. package/package.json +11 -11
  55. package/dist/packem_shared/Table-DyORjLji-CC9cYgCG.js +0 -11
  56. package/dist/packem_shared/formatBytes-BHAzNIrn-Bkk_uRS-.js +0 -4
@@ -1,4 +1,4 @@
1
- import{createRequire as T}from"node:module";import{j as $,F as R,b as P,q as L,X as S,J as k}from"../packem_shared/index.server-sXNQYpsl.js";import{a as N}from"../packem_shared/index-DHD8wb6Z.js";import{a as B,r as D,b as y,c as M}from"../packem_shared/ai-fix-CyUx_ZAB.js";import{p as c}from"./cli-main.js";import{l as _}from"../packem_shared/failure-log-DE_MJCzB.js";let A;const O=s=>(A??=T(import.meta.url))(s),d=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,q=s=>{if(typeof d<"u"&&d.versions&&d.versions.node){const[t,i]=d.versions.node.split(".").map(Number);if(t>22||t===22&&i>=3||t===20&&i>=16)return d.getBuiltinModule(s)}return O(s)},{createInterface:J}=q("node:readline"),U={"ambiguous-match":"ambiguous match",applied:"applied",error:"error","missing-file":"missing file","no-match":"no match","outside-workspace":"outside workspace"},j=(s,t,i)=>{const e=M(s,t,i),r=N(s,e);return r===""||r.startsWith("..")?e:r},W=(s,t,i)=>{const e=[$(`Fix proposal (${s.provider}, confidence: ${s.confidence})`),"",s.explanation||R("<no explanation>")];if(s.cannotFix)return e.push(""),e.push(P(`Cannot fix automatically: ${s.cannotFix}`)),e.join(`
1
+ import{createRequire as T}from"node:module";import{j as $,F as R,b as P,q as L,X as S,J as k}from"../packem_shared/index.server-sXNQYpsl.js";import{a as N}from"../packem_shared/index-DHD8wb6Z.js";import{a as B,r as D,b as y,c as M}from"../packem_shared/ai-fix-BHyx1F1j.js";import{p as c}from"./cli-main.js";import{l as _}from"../packem_shared/failure-log-3R522Vb5.js";let A;const O=s=>(A??=T(import.meta.url))(s),d=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,q=s=>{if(typeof d<"u"&&d.versions&&d.versions.node){const[t,i]=d.versions.node.split(".").map(Number);if(t>22||t===22&&i>=3||t===20&&i>=16)return d.getBuiltinModule(s)}return O(s)},{createInterface:J}=q("node:readline"),U={"ambiguous-match":"ambiguous match",applied:"applied",error:"error","missing-file":"missing file","no-match":"no match","outside-workspace":"outside workspace"},j=(s,t,i)=>{const e=M(s,t,i),r=N(s,e);return r===""||r.startsWith("..")?e:r},W=(s,t,i)=>{const e=[$(`Fix proposal (${s.provider}, confidence: ${s.confidence})`),"",s.explanation||R("<no explanation>")];if(s.cannotFix)return e.push(""),e.push(P(`Cannot fix automatically: ${s.cannotFix}`)),e.join(`
2
2
  `);if(s.patches.length===0)return e.push(""),e.push(P("No patches were proposed.")),e.join(`
3
3
  `);e.push(""),e.push($(`Patches (${String(s.patches.length)}):`));for(const[r,o]of s.patches.entries()){const a=j(t,i,o.file);e.push(""),e.push(L(`[${String(r+1)}] ${a}`)),o.reason&&e.push(R(` reason: ${o.reason}`));for(const h of o.oldString.split(`
4
4
  `))e.push(S(` - ${h}`));for(const h of o.newString.split(`
@@ -1,4 +1,4 @@
1
- import{createRequire as _}from"node:module";import{z as m,e as t}from"../packem_shared/index-DHD8wb6Z.js";import{b}from"../packem_shared/formatBytes-BHAzNIrn-Bkk_uRS-.js";import{y as a}from"../packem_shared/isAccessibleSync-DYKTrrvc-CSnBISfV.js";import{U as j}from"../packem_shared/writeFileSync-DJoHk3Ks-CgQ-VNNT.js";let v;const w=s=>(v??=_(import.meta.url))(s),c=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,d=s=>{if(typeof c<"u"&&c.versions&&c.versions.node){const[n,o]=c.versions.node.split(".").map(Number);if(n>22||n===22&&o>=3||n===20&&o>=16)return c.getBuiltinModule(s)}return w(s)},{homedir:i}=d("node:os"),{createInterface:y}=d("node:readline"),f=b(),p=[t(i(),".zshrc"),t(i(),".zshenv"),t(i(),".bashrc"),t(i(),".bash_profile"),t(i(),".profile"),t(i(),".config","fish","config.fish")],E=s=>{const n=[];for(const o of p)if(a(o))try{const l=m(o).split(`
1
+ import{createRequire as _}from"node:module";import{z as m,e as t}from"../packem_shared/index-DHD8wb6Z.js";import{b}from"../packem_shared/formatBytes-BHAzNIrn-XohRrPdt.js";import{y as a}from"../packem_shared/isAccessibleSync-DYKTrrvc-CSnBISfV.js";import{U as j}from"../packem_shared/writeFileSync-DJoHk3Ks-CgQ-VNNT.js";let v;const w=s=>(v??=_(import.meta.url))(s),c=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,d=s=>{if(typeof c<"u"&&c.versions&&c.versions.node){const[n,o]=c.versions.node.split(".").map(Number);if(n>22||n===22&&o>=3||n===20&&o>=16)return c.getBuiltinModule(s)}return w(s)},{homedir:i}=d("node:os"),{createInterface:y}=d("node:readline"),f=b(),p=[t(i(),".zshrc"),t(i(),".zshenv"),t(i(),".bashrc"),t(i(),".bash_profile"),t(i(),".profile"),t(i(),".config","fish","config.fish")],E=s=>{const n=[];for(const o of p)if(a(o))try{const l=m(o).split(`
2
2
  `),e=l.filter(r=>!r.includes(".vis/bin")&&!r.includes("VIS_HOME")&&!r.includes("# vis "));e.length!==l.length&&(j(o,e.join(`
3
3
  `)),n.push(o))}catch{s.warn(`warning: could not clean ${o}`)}return n},H=async({fs:s,logger:n,options:o})=>{if(!a(f)){n.info("vis is not installed (no ~/.vis directory found).");return}n.info("This will remove:"),n.info(` ${f}/`);const u=p.filter(e=>a(e)&&m(e).includes(".vis"));for(const e of u)n.info(` Lines in ${e}`);if(!o.yes){if(!process.stdin.isTTY)throw new Error("Non-interactive terminal. Use --yes to confirm.");const e=y({input:process.stdin,output:process.stdout}),r=await new Promise(h=>{e.question(`
4
4
  Type "uninstall" to confirm: `,h)});if(e.close(),r.trim()!=="uninstall"){n.info("Aborted.");return}}const l=E(n);for(const e of l)n.info(`Cleaned ${e}`);try{await s.rm(f,{force:!0,recursive:!0}),n.info(`
@@ -1,4 +1,4 @@
1
- import{J as k,F as v,X as $,b as y}from"../packem_shared/index.server-sXNQYpsl.js";import{p}from"./cli-main.js";import{r as N,M,a as S,b as x,c as A,d as b,e as C,f as R,g as P,h as j}from"../packem_shared/s1ngularity-BRk_GMUj.js";import{g as B,r as D}from"../packem_shared/packument-CHdDsn0O.js";import{r as E}from"../packem_shared/provenance-w-NIPtim.js";import{r as O}from"../packem_shared/signatures-ijwqxAtF.js";const w=new Set(["archivedRepo","author","downloads","expiredDomains","metadata","newBin","provenance","s1ngularity","signatures"]),V=n=>{const s=n.trim();if(s==="")return;if(s.startsWith("@")){const r=s.indexOf("@",1);return r===-1?{name:s,spec:void 0}:{name:s.slice(0,r),spec:s.slice(r+1)||void 0}}const t=s.indexOf("@");return t===-1?{name:s,spec:void 0}:{name:s.slice(0,t),spec:s.slice(t+1)||void 0}},F=n=>{if(n===void 0||n.trim()==="")return;const s=new Set;for(const t of n.split(",")){const r=t.trim();if(!w.has(r))throw new Error(`Unknown marshall in --only: ${r}. Known: ${[...w].sort().join(", ")}.`);s.add(r)}return s},l=(n,s)=>n===void 0||n.has(s),L=n=>n?.has("signatures")??!1,q=async({argument:n,options:s,workspaceRoot:t})=>{if(!n||n.length===0)throw new Error("No package specified. Usage: vis inspect <package>[@<spec>]");const r=V(n[0]);if(r===void 0)throw new Error(`Invalid package argument: "${String(n[0])}". Usage: vis inspect <package>[@<spec>]`);const i=F(s.only),u=await B(r.name,{workspaceRoot:t});if(u===void 0){p.error(`Package ${r.name} not found in the registry.`),process.exitCode=2;return}const g=D(u,r.spec);if(g===void 0){p.error(`Could not resolve ${r.name}@${r.spec??"latest"} to a published version.`),process.exitCode=2;return}const c=[{name:r.name,version:g}],o=new M;if(l(i,"author")){const a=await N(c,{workspaceRoot:t});for(const e of a)o.add({marshall:"author",message:e.message,packageName:e.packageName,severity:e.severity})}if(l(i,"provenance")){const a=await E(c);for(const e of a)o.add({marshall:"provenance",message:`Prior version ${e.priorVersionWithProvenance} had provenance but ${e.version} does not.`,packageName:e.packageName,severity:"error"})}if(l(i,"s1ngularity")){const a=await S(c,{workspaceRoot:t});for(const e of a){const d=e.hookChanges.map(f=>`${f.hook} (${f.kind})`).join(", "),m=e.hookChanges.length===1;o.add({marshall:"s1ngularity",message:`${e.version} ${m?"has an":"has"} install-script ${m?"change":"changes"} [${d}] AND dropped the provenance attestation that ${e.priorVersion} carried — this is the s1ngularity compromised-publish shape.`,packageName:e.packageName,severity:"error"})}}if(l(i,"newBin")){const a=await x(c);for(const e of a){const d=e.newBins.map(m=>m.command).join(", ");o.add({marshall:"newBin",message:`${e.toVersion} adds new bin script${e.newBins.length===1?"":"s"}: ${d} (prior: ${e.fromVersion}).`,packageName:e.packageName,severity:"warning"})}}if(l(i,"metadata")){const a=await A(c,{workspaceRoot:t});for(const e of a)o.add({marshall:"metadata",message:`Missing/invalid metadata: ${e.issues.join(", ")}.`,packageName:e.packageName,severity:"warning"})}if(l(i,"downloads")){const a=await b([r.name]);for(const e of a){const d=e.downloadsLastMonth===void 0?"unknown":String(e.downloadsLastMonth);o.add({marshall:"downloads",message:e.kind==="no-data"?"npm stats API returned no monthly download data.":`Only ${d} downloads in the past month.`,packageName:e.packageName,severity:e.severity})}}if(l(i,"expiredDomains")){const a=await C(c,{workspaceRoot:t});for(const e of a)o.add({marshall:"expiredDomains",message:e.kind==="expired"?`Maintainer email domain ${e.domain} (${e.maintainer}) is unregistered — potential hijack risk.`:`Could not verify maintainer email domain ${e.domain} (${e.maintainer}).`,packageName:e.packageName,severity:e.severity})}if(L(i)){const a=await O(c,{workspaceRoot:t});for(const e of a)o.add({marshall:"signatures",message:e.message,packageName:e.packageName,severity:e.severity})}if(l(i,"archivedRepo")){const a=await R(c,{workspaceRoot:t});for(const e of a)o.add({marshall:"archivedRepo",message:e.kind==="archived"?`Source repo ${e.owner}/${e.repo} is archived${e.archivedAt===void 0?"":` (since ${e.archivedAt})`}.`:`Source repo ${e.owner}/${e.repo} returned 404 from GitHub.`,packageName:e.packageName,severity:"warning"})}const h=o.all();if(s.json)process.stdout.write(`${JSON.stringify(P(h),void 0,2)}
1
+ import{J as k,F as v,X as $,b as y}from"../packem_shared/index.server-sXNQYpsl.js";import{p}from"./cli-main.js";import{r as N,M,a as S,b as x,c as A,d as b,e as C,f as R,g as P,h as j}from"../packem_shared/s1ngularity-BJ5j2vbJ.js";import{g as B,r as D}from"../packem_shared/packument-DyuhH1Gz.js";import{r as E}from"../packem_shared/provenance-BH80RHXx.js";import{r as O}from"../packem_shared/signatures-BP042BlB.js";const w=new Set(["archivedRepo","author","downloads","expiredDomains","metadata","newBin","provenance","s1ngularity","signatures"]),V=n=>{const s=n.trim();if(s==="")return;if(s.startsWith("@")){const r=s.indexOf("@",1);return r===-1?{name:s,spec:void 0}:{name:s.slice(0,r),spec:s.slice(r+1)||void 0}}const t=s.indexOf("@");return t===-1?{name:s,spec:void 0}:{name:s.slice(0,t),spec:s.slice(t+1)||void 0}},F=n=>{if(n===void 0||n.trim()==="")return;const s=new Set;for(const t of n.split(",")){const r=t.trim();if(!w.has(r))throw new Error(`Unknown marshall in --only: ${r}. Known: ${[...w].sort().join(", ")}.`);s.add(r)}return s},l=(n,s)=>n===void 0||n.has(s),L=n=>n?.has("signatures")??!1,q=async({argument:n,options:s,workspaceRoot:t})=>{if(!n||n.length===0)throw new Error("No package specified. Usage: vis inspect <package>[@<spec>]");const r=V(n[0]);if(r===void 0)throw new Error(`Invalid package argument: "${String(n[0])}". Usage: vis inspect <package>[@<spec>]`);const i=F(s.only),u=await B(r.name,{workspaceRoot:t});if(u===void 0){p.error(`Package ${r.name} not found in the registry.`),process.exitCode=2;return}const g=D(u,r.spec);if(g===void 0){p.error(`Could not resolve ${r.name}@${r.spec??"latest"} to a published version.`),process.exitCode=2;return}const c=[{name:r.name,version:g}],o=new M;if(l(i,"author")){const a=await N(c,{workspaceRoot:t});for(const e of a)o.add({marshall:"author",message:e.message,packageName:e.packageName,severity:e.severity})}if(l(i,"provenance")){const a=await E(c);for(const e of a)o.add({marshall:"provenance",message:`Prior version ${e.priorVersionWithProvenance} had provenance but ${e.version} does not.`,packageName:e.packageName,severity:"error"})}if(l(i,"s1ngularity")){const a=await S(c,{workspaceRoot:t});for(const e of a){const d=e.hookChanges.map(f=>`${f.hook} (${f.kind})`).join(", "),m=e.hookChanges.length===1;o.add({marshall:"s1ngularity",message:`${e.version} ${m?"has an":"has"} install-script ${m?"change":"changes"} [${d}] AND dropped the provenance attestation that ${e.priorVersion} carried — this is the s1ngularity compromised-publish shape.`,packageName:e.packageName,severity:"error"})}}if(l(i,"newBin")){const a=await x(c);for(const e of a){const d=e.newBins.map(m=>m.command).join(", ");o.add({marshall:"newBin",message:`${e.toVersion} adds new bin script${e.newBins.length===1?"":"s"}: ${d} (prior: ${e.fromVersion}).`,packageName:e.packageName,severity:"warning"})}}if(l(i,"metadata")){const a=await A(c,{workspaceRoot:t});for(const e of a)o.add({marshall:"metadata",message:`Missing/invalid metadata: ${e.issues.join(", ")}.`,packageName:e.packageName,severity:"warning"})}if(l(i,"downloads")){const a=await b([r.name]);for(const e of a){const d=e.downloadsLastMonth===void 0?"unknown":String(e.downloadsLastMonth);o.add({marshall:"downloads",message:e.kind==="no-data"?"npm stats API returned no monthly download data.":`Only ${d} downloads in the past month.`,packageName:e.packageName,severity:e.severity})}}if(l(i,"expiredDomains")){const a=await C(c,{workspaceRoot:t});for(const e of a)o.add({marshall:"expiredDomains",message:e.kind==="expired"?`Maintainer email domain ${e.domain} (${e.maintainer}) is unregistered — potential hijack risk.`:`Could not verify maintainer email domain ${e.domain} (${e.maintainer}).`,packageName:e.packageName,severity:e.severity})}if(L(i)){const a=await O(c,{workspaceRoot:t});for(const e of a)o.add({marshall:"signatures",message:e.message,packageName:e.packageName,severity:e.severity})}if(l(i,"archivedRepo")){const a=await R(c,{workspaceRoot:t});for(const e of a)o.add({marshall:"archivedRepo",message:e.kind==="archived"?`Source repo ${e.owner}/${e.repo} is archived${e.archivedAt===void 0?"":` (since ${e.archivedAt})`}.`:`Source repo ${e.owner}/${e.repo} returned 404 from GitHub.`,packageName:e.packageName,severity:"warning"})}const h=o.all();if(s.json)process.stdout.write(`${JSON.stringify(P(h),void 0,2)}
2
2
  `);else{const a=`${r.name}@${g}`;if(h.length===0)p.info(`${k("✓")} ${a} — no findings.`);else{p.info(`${v("Inspecting")} ${a}`);for(const m of j(h))process.stdout.write(`${m}
3
3
  `);const e=o.errors().length,d=o.warnings().length;process.stdout.write(`
4
4
  ${v("Summary:")} ${$(`${String(e)} error${e===1?"":"s"}`)}, ${y(`${String(d)} warning${d===1?"":"s"}`)}.
@@ -1 +1 @@
1
- import{createRequire as A}from"node:module";import{J as P,F as _,X as F,b as I}from"../packem_shared/index.server-sXNQYpsl.js";import{e as q}from"../packem_shared/index-DHD8wb6Z.js";import{c as b,p,O as N}from"./cli-main.js";import{c as B,h as z,d as H,r as U,x as W}from"./catalog.js";import{a as G,c as V,n as X}from"../packem_shared/pm-runner-d93_73O6.js";import{r as Y,a as J}from"../packem_shared/command-runtime-CiLVo4ED.js";import{r as j,a as K,p as Q,b as Z}from"../packem_shared/resolve-explicit-CsTmALmE.js";import{D as ee,e as y,f as te,h as S,i as re,j as se,s as ne}from"../packem_shared/formatBytes-BHAzNIrn-Bkk_uRS-.js";import{r as oe}from"../packem_shared/typosquats-CSkIFgF5.js";import{p as R,t as C}from"../packem_shared/utils-DQFHJn72.js";import{p as ae}from"../packem_shared/readJsonSync-CbryXYxN-B2aSeDpC.js";import{T as ce}from"../packem_shared/target-merge-B4No-LHM.js";let L;const T=r=>(L??=A(import.meta.url))(r),w=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,M=r=>{if(typeof w<"u"&&w.versions&&w.versions.node){const[i,e]=w.versions.node.split(".").map(Number);if(i>22||i===22&&e>=3||i===20&&e>=16)return w.getBuiltinModule(r)}return T(r)},{createInterface:O}=M("node:readline"),x=r=>r==="default"?"catalog:":`catalog:${r}`,v=r=>r==="default"?"default catalog":`catalog "${r}"`,ie=(r,i)=>{const e=[];for(const[t,s]of i)t.includes(":")||s.has(r)&&e.push(t);if(e.length===0)return;if(e.length===1){const[t]=e;return{source:v(t),spec:x(t)}}const o=e.find(t=>t==="default")??e[0],a=e.filter(t=>t!==o);return{candidates:[...e],conflict:!0,source:`${v(o)} (also in: ${a.map(t=>v(t)).join(", ")})`,spec:x(o)}},le=(r,i)=>{const e=new Map;for(const[c,u]of i){if(!c.includes(":"))continue;const f=u.get(r);f!==void 0&&e.set(f,(e.get(f)??0)+1)}if(e.size===0)return;const o=[...e.entries()],a=o.reduce((c,[,u])=>c+u,0);if(o.length===1){const[[c]]=o;return{source:`siblings (${String(a)} pkg${a===1?"":"s"} on ${c})`,spec:c}}const t=[...o].sort((c,u)=>u[1]-c[1]),[s,n]=t[0],l=t.slice(1).map(([c,u])=>`${c} (×${String(u)})`);return{candidates:t.map(([c])=>c),conflict:!0,source:`siblings (most common: ${s} ×${String(n)}; conflicts: ${l.join(", ")})`,spec:s}},fe=(r,i)=>{const e=ie(r,i);return e||le(r,i)},pe=(r,i,e)=>{const o=[];for(const a of r.values()){const{overall:t}=a.score,s=ne(t),n=`${String(Math.round(t*100))}%`,l=a.alerts.length,c=y(a),u=te(c,a.version,e),f=s==="red"?F:s==="yellow"?I:P;if(u?p.info(` ${f(n)} ${S(a)} ${_(`[accepted: ${u.reason}]`)}`):p.info(` ${f(n)} ${S(a)}`),l>0){const m=a.alerts.filter(d=>d.severity==="critical"||d.severity==="high").length;m>0&&p.warn(` ${String(m)} critical/high alert${m===1?"":"s"}`)}t<i&&!u&&o.push(a)}return o},ue=async(r,i)=>{const e=O({input:process.stdin,output:process.stdout}),o=n=>new Promise(l=>{e.question(n,c=>{l(c.trim())})}),a=String(Math.round(i*100));p.warn(""),p.warn(`${String(r.length)} package${r.length===1?"":"s"} scored below the minimum threshold (${a}%):`);for(const n of r){const l=y(n),c=`${String(Math.round(n.score.overall*100))}%`;p.warn(` • ${l}@${n.version} — score: ${c} (${re(n.score.overall)})`)}p.warn("");const t=await o("Continue adding these packages? [y/N] ");if(t.toLowerCase()!=="y"&&t.toLowerCase()!=="yes")return e.close(),!1;const s=await o("Remember this decision? (prints config snippet) [y/N] ");if(e.close(),s.toLowerCase()==="y"||s.toLowerCase()==="yes"){p.notice(""),p.notice("Add the following to security.acceptedRisks in vis.config.ts:"),p.notice("");for(const n of r){const l=y(n),c=se(l,n.version,n.score.overall,"Reviewed and accepted");p.notice(c)}p.notice("")}return!0},de=async(r,i,e,o)=>{const a=await j(r);if(a.length===0)return!0;p.info(""),p.info(`${i.map(n=>n.displayName).join(" + ")} security check:`);const t=await z(i,a);if(t.size===0)return p.info(" Could not fetch security data. Proceeding."),!0;const s=pe(t,e,o);return s.length===0?(p.info(""),!0):process.stdin.isTTY?ue(s,e):(p.warn(`Aborting: ${String(s.length)} package${s.length===1?"":"s"} below minimum score. Use --no-socket-check to skip.`),!1)},me=["dependencies","devDependencies","peerDependencies","optionalDependencies"],ge=r=>r.savePeer?"peerDependencies":r.saveOptional?"optionalDependencies":r.saveDev?"devDependencies":"dependencies",D=(r,i)=>r.startsWith("catalog:")||!i?r:r.replace(/^[\^~]/,""),he=async(r,i)=>{const e=[];for(const t of r){const{name:s,versionSpec:n}=R(t);if(!s)continue;if(n!==void 0){e.push({explicit:n,name:s});continue}const l=fe(s,i);if(l){l.conflict&&p.warn(`${s}: ambiguous constraint — picking ${l.spec} (${l.source}). Pass ${s}@<version> to override.`),e.push({entry:{name:s,source:l.source,spec:l.spec},kind:"resolved",name:s});continue}e.push({kind:"missing",name:s})}const o=e.filter(t=>"kind"in t&&t.kind==="missing").map(t=>t.name),a=o.length>0?await Z(o):new Map;return e.map(t=>{if("explicit"in t)return{name:t.name,source:"explicit",spec:t.explicit};if(t.kind==="resolved")return t.entry;const s=a.get(t.name);if(s===void 0)throw new Error(`--to: cannot resolve a version for "${t.name}" (not in any catalog or sibling, and registry lookup failed). Pass ${t.name}@<version> explicitly.`);const n=`^${s}`;return p.info(`${t.name}: no existing constraint — using registry latest (${n}). Add to a catalog to share this version across workspace packages.`),{name:t.name,source:"registry latest",spec:n}})},ke=(r,i,e,o)=>{for(const{name:a,spec:t}of i){const s=D(t,o);for(const l of me){if(l===e)continue;const c=r[l];c?.[a]!==void 0&&(delete c[a],Object.keys(c).length===0&&delete r[l])}let n=r[e];n===void 0&&(n={},r[e]=n),n[a]=s}},we=async({ignoreScripts:r,logger:i,options:e,packages:o,pm:a,target:t,visConfig:s,workspaceRoot:n})=>{const{workspace:l}=H(n,s??{}),c=l.projects[t];if(!c){const g=Object.keys(l.projects).sort();throw new Error(`--to: workspace package "${t}" not found. Available: ${g.length>0?g.slice(0,10).join(", "):"(none)"}${g.length>10?`, ... (${String(g.length-10)} more)`:""}.`)}const u=q(n,c.root,"package.json"),{packageManager:f}=N(n),m=U(n,f),d=ge(e),k=e.exact??!1,h=await he(o,m);if(h.length===0)return 0;const $=ae(u);ke($,h,d,k),ce(u,$,{indent:W(u,{useEditorconfig:s?.editorconfig??!0}),overwrite:!0});for(const g of h){const E=D(g.spec,k);p.info(`${P("+")} ${g.name}@${E} → ${t}/${d} (${_(g.source)})`)}return X(a,{dev:!1,filter:[],force:!1,frozenLockfile:!1,ignoreScripts:r,lockfileOnly:!1,noOptional:!1,offline:!1,prod:!1,recursive:!1,silent:!1,workspaceRoot:!1},n,i)},Ae=async({argument:r,logger:i,options:e,visConfig:o,workspaceRoot:a})=>{let t=r;if(!t||t.length===0)throw new Error("No packages specified. Usage: vis add <packages...>");if(e.typosquatCheck!==!1){const f=t.map(d=>R(d)),m=await oe(f.map(d=>d.name),o?.security?.typosquatAllowlist);if(!m.ok){process.exitCode=1;return}t=f.map((d,k)=>{const h=m.packages[k];return h!==d.name?d.versionSpec?`${h}@${d.versionSpec}`:h??"":t[k]??""})}if(e.marshallCheck!==!1){const f=await j(t);if(f.length>0){const m=await K(f,{config:o?.security?.marshalls,workspaceRoot:a});if(!await Q(m)){process.exitCode=1;return}}}if(e.socketCheck!==!1){const f=new Set;b("socket")&&f.add("socket"),b("depsDev")&&f.add("deps-dev");const m=B(o?.security,{disabled:f,minimumScore:o?.security?.policies?.score?.minimum});if(m.length>0){const d=o?.security?.policies?.score?.minimum??ee;if(!await de(t,m,d,o?.security?.acceptedRisks)){process.exitCode=1;return}}}const s=process.cwd(),n=Y({logger:i,options:e,visConfig:o},a??s),l=G(a??s,{backend:J(n),configBackend:o?.install?.backend,configCorepack:o?.install?.corepack}),c=!e.runScripts;if(e.to){if(e.global||e.workspaceRoot)throw new Error("--to is incompatible with --global / --workspace-root.");if(e.filter&&C(e.filter).length>0)throw new Error("--to and --filter are mutually exclusive — --to already targets one package.");if(!a)throw new Error("--to requires a monorepo workspace. Run from inside a pnpm/bun/yarn/npm workspace.");const f=await we({ignoreScripts:c,logger:i,options:e,packages:t,pm:l,target:e.to,visConfig:o,workspaceRoot:a});f!==0&&(process.exitCode=f);return}const u=V(l,{exact:e.exact||!1,filter:C(e.filter),global:e.global||!1,optional:e.saveOptional||!1,packages:t,peer:e.savePeer||!1,saveDev:e.saveDev||!1,workspace:e.workspace||!1,workspaceRoot:e.workspaceRoot||!1},s,i,{autoInstallPeers:e.autoInstallPeers||!1,ignoreScripts:c});u!==0&&(process.exitCode=u)};export{Ae as default};
1
+ import{createRequire as A}from"node:module";import{J as P,F as _,X as F,b as I}from"../packem_shared/index.server-sXNQYpsl.js";import{e as q}from"../packem_shared/index-DHD8wb6Z.js";import{c as b,p,O as N}from"./cli-main.js";import{c as B,h as z,d as H,r as U,x as W}from"./catalog.js";import{a as G,c as V,n as X}from"../packem_shared/pm-runner-d93_73O6.js";import{r as Y,a as J}from"../packem_shared/command-runtime-CiLVo4ED.js";import{r as j,a as K,p as Q,b as Z}from"../packem_shared/resolve-explicit-DuJ3mbzt.js";import{D as ee,e as y,f as te,h as S,i as re,j as se,s as ne}from"../packem_shared/formatBytes-BHAzNIrn-XohRrPdt.js";import{r as oe}from"../packem_shared/typosquats-CSkIFgF5.js";import{p as R,t as C}from"../packem_shared/utils-DQFHJn72.js";import{p as ae}from"../packem_shared/readJsonSync-CbryXYxN-B2aSeDpC.js";import{T as ce}from"../packem_shared/target-merge-B4No-LHM.js";let L;const T=r=>(L??=A(import.meta.url))(r),w=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,M=r=>{if(typeof w<"u"&&w.versions&&w.versions.node){const[i,e]=w.versions.node.split(".").map(Number);if(i>22||i===22&&e>=3||i===20&&e>=16)return w.getBuiltinModule(r)}return T(r)},{createInterface:O}=M("node:readline"),x=r=>r==="default"?"catalog:":`catalog:${r}`,v=r=>r==="default"?"default catalog":`catalog "${r}"`,ie=(r,i)=>{const e=[];for(const[t,s]of i)t.includes(":")||s.has(r)&&e.push(t);if(e.length===0)return;if(e.length===1){const[t]=e;return{source:v(t),spec:x(t)}}const o=e.find(t=>t==="default")??e[0],a=e.filter(t=>t!==o);return{candidates:[...e],conflict:!0,source:`${v(o)} (also in: ${a.map(t=>v(t)).join(", ")})`,spec:x(o)}},le=(r,i)=>{const e=new Map;for(const[c,u]of i){if(!c.includes(":"))continue;const f=u.get(r);f!==void 0&&e.set(f,(e.get(f)??0)+1)}if(e.size===0)return;const o=[...e.entries()],a=o.reduce((c,[,u])=>c+u,0);if(o.length===1){const[[c]]=o;return{source:`siblings (${String(a)} pkg${a===1?"":"s"} on ${c})`,spec:c}}const t=[...o].sort((c,u)=>u[1]-c[1]),[s,n]=t[0],l=t.slice(1).map(([c,u])=>`${c} (×${String(u)})`);return{candidates:t.map(([c])=>c),conflict:!0,source:`siblings (most common: ${s} ×${String(n)}; conflicts: ${l.join(", ")})`,spec:s}},fe=(r,i)=>{const e=ie(r,i);return e||le(r,i)},pe=(r,i,e)=>{const o=[];for(const a of r.values()){const{overall:t}=a.score,s=ne(t),n=`${String(Math.round(t*100))}%`,l=a.alerts.length,c=y(a),u=te(c,a.version,e),f=s==="red"?F:s==="yellow"?I:P;if(u?p.info(` ${f(n)} ${S(a)} ${_(`[accepted: ${u.reason}]`)}`):p.info(` ${f(n)} ${S(a)}`),l>0){const m=a.alerts.filter(d=>d.severity==="critical"||d.severity==="high").length;m>0&&p.warn(` ${String(m)} critical/high alert${m===1?"":"s"}`)}t<i&&!u&&o.push(a)}return o},ue=async(r,i)=>{const e=O({input:process.stdin,output:process.stdout}),o=n=>new Promise(l=>{e.question(n,c=>{l(c.trim())})}),a=String(Math.round(i*100));p.warn(""),p.warn(`${String(r.length)} package${r.length===1?"":"s"} scored below the minimum threshold (${a}%):`);for(const n of r){const l=y(n),c=`${String(Math.round(n.score.overall*100))}%`;p.warn(` • ${l}@${n.version} — score: ${c} (${re(n.score.overall)})`)}p.warn("");const t=await o("Continue adding these packages? [y/N] ");if(t.toLowerCase()!=="y"&&t.toLowerCase()!=="yes")return e.close(),!1;const s=await o("Remember this decision? (prints config snippet) [y/N] ");if(e.close(),s.toLowerCase()==="y"||s.toLowerCase()==="yes"){p.notice(""),p.notice("Add the following to security.acceptedRisks in vis.config.ts:"),p.notice("");for(const n of r){const l=y(n),c=se(l,n.version,n.score.overall,"Reviewed and accepted");p.notice(c)}p.notice("")}return!0},de=async(r,i,e,o)=>{const a=await j(r);if(a.length===0)return!0;p.info(""),p.info(`${i.map(n=>n.displayName).join(" + ")} security check:`);const t=await z(i,a);if(t.size===0)return p.info(" Could not fetch security data. Proceeding."),!0;const s=pe(t,e,o);return s.length===0?(p.info(""),!0):process.stdin.isTTY?ue(s,e):(p.warn(`Aborting: ${String(s.length)} package${s.length===1?"":"s"} below minimum score. Use --no-socket-check to skip.`),!1)},me=["dependencies","devDependencies","peerDependencies","optionalDependencies"],ge=r=>r.savePeer?"peerDependencies":r.saveOptional?"optionalDependencies":r.saveDev?"devDependencies":"dependencies",D=(r,i)=>r.startsWith("catalog:")||!i?r:r.replace(/^[\^~]/,""),he=async(r,i)=>{const e=[];for(const t of r){const{name:s,versionSpec:n}=R(t);if(!s)continue;if(n!==void 0){e.push({explicit:n,name:s});continue}const l=fe(s,i);if(l){l.conflict&&p.warn(`${s}: ambiguous constraint — picking ${l.spec} (${l.source}). Pass ${s}@<version> to override.`),e.push({entry:{name:s,source:l.source,spec:l.spec},kind:"resolved",name:s});continue}e.push({kind:"missing",name:s})}const o=e.filter(t=>"kind"in t&&t.kind==="missing").map(t=>t.name),a=o.length>0?await Z(o):new Map;return e.map(t=>{if("explicit"in t)return{name:t.name,source:"explicit",spec:t.explicit};if(t.kind==="resolved")return t.entry;const s=a.get(t.name);if(s===void 0)throw new Error(`--to: cannot resolve a version for "${t.name}" (not in any catalog or sibling, and registry lookup failed). Pass ${t.name}@<version> explicitly.`);const n=`^${s}`;return p.info(`${t.name}: no existing constraint — using registry latest (${n}). Add to a catalog to share this version across workspace packages.`),{name:t.name,source:"registry latest",spec:n}})},ke=(r,i,e,o)=>{for(const{name:a,spec:t}of i){const s=D(t,o);for(const l of me){if(l===e)continue;const c=r[l];c?.[a]!==void 0&&(delete c[a],Object.keys(c).length===0&&delete r[l])}let n=r[e];n===void 0&&(n={},r[e]=n),n[a]=s}},we=async({ignoreScripts:r,logger:i,options:e,packages:o,pm:a,target:t,visConfig:s,workspaceRoot:n})=>{const{workspace:l}=H(n,s??{}),c=l.projects[t];if(!c){const g=Object.keys(l.projects).sort();throw new Error(`--to: workspace package "${t}" not found. Available: ${g.length>0?g.slice(0,10).join(", "):"(none)"}${g.length>10?`, ... (${String(g.length-10)} more)`:""}.`)}const u=q(n,c.root,"package.json"),{packageManager:f}=N(n),m=U(n,f),d=ge(e),k=e.exact??!1,h=await he(o,m);if(h.length===0)return 0;const $=ae(u);ke($,h,d,k),ce(u,$,{indent:W(u,{useEditorconfig:s?.editorconfig??!0}),overwrite:!0});for(const g of h){const E=D(g.spec,k);p.info(`${P("+")} ${g.name}@${E} → ${t}/${d} (${_(g.source)})`)}return X(a,{dev:!1,filter:[],force:!1,frozenLockfile:!1,ignoreScripts:r,lockfileOnly:!1,noOptional:!1,offline:!1,prod:!1,recursive:!1,silent:!1,workspaceRoot:!1},n,i)},Ae=async({argument:r,logger:i,options:e,visConfig:o,workspaceRoot:a})=>{let t=r;if(!t||t.length===0)throw new Error("No packages specified. Usage: vis add <packages...>");if(e.typosquatCheck!==!1){const f=t.map(d=>R(d)),m=await oe(f.map(d=>d.name),o?.security?.typosquatAllowlist);if(!m.ok){process.exitCode=1;return}t=f.map((d,k)=>{const h=m.packages[k];return h!==d.name?d.versionSpec?`${h}@${d.versionSpec}`:h??"":t[k]??""})}if(e.marshallCheck!==!1){const f=await j(t);if(f.length>0){const m=await K(f,{config:o?.security?.marshalls,workspaceRoot:a});if(!await Q(m)){process.exitCode=1;return}}}if(e.socketCheck!==!1){const f=new Set;b("socket")&&f.add("socket"),b("depsDev")&&f.add("deps-dev");const m=B(o?.security,{disabled:f,minimumScore:o?.security?.policies?.score?.minimum});if(m.length>0){const d=o?.security?.policies?.score?.minimum??ee;if(!await de(t,m,d,o?.security?.acceptedRisks)){process.exitCode=1;return}}}const s=process.cwd(),n=Y({logger:i,options:e,visConfig:o},a??s),l=G(a??s,{backend:J(n),configBackend:o?.install?.backend,configCorepack:o?.install?.corepack}),c=!e.runScripts;if(e.to){if(e.global||e.workspaceRoot)throw new Error("--to is incompatible with --global / --workspace-root.");if(e.filter&&C(e.filter).length>0)throw new Error("--to and --filter are mutually exclusive — --to already targets one package.");if(!a)throw new Error("--to requires a monorepo workspace. Run from inside a pnpm/bun/yarn/npm workspace.");const f=await we({ignoreScripts:c,logger:i,options:e,packages:t,pm:l,target:e.to,visConfig:o,workspaceRoot:a});f!==0&&(process.exitCode=f);return}const u=V(l,{exact:e.exact||!1,filter:C(e.filter),global:e.global||!1,optional:e.saveOptional||!1,packages:t,peer:e.savePeer||!1,saveDev:e.saveDev||!1,workspace:e.workspace||!1,workspaceRoot:e.workspaceRoot||!1},s,i,{autoInstallPeers:e.autoInstallPeers||!1,ignoreScripts:c});u!==0&&(process.exitCode=u)};export{Ae as default};
@@ -1,4 +1,4 @@
1
- import{readLastRunSummary as S,getLastRunSummaryPath as I}from"@visulima/task-runner";import{p as f,l as x,f as w}from"./cli-main.js";import{c as $,d as m}from"../packem_shared/formatBytes-BHAzNIrn-Bkk_uRS-.js";const T=new Set(["json","table"]),k=(t,e)=>t??e,h=t=>t===void 0?"-":t<1e3?`${String(t)}ms`:`${(t/1e3).toFixed(2)}s`,p=t=>t.exitCode===void 0?t.cacheStatus:t.exitCode===0?t.cacheStatus==="MISS"?"OK":t.cacheStatus:`FAIL(${String(t.exitCode)})`,r=(t,e)=>t.length>=e?t:t+" ".repeat(e-t.length),v=t=>t.exitCode!==void 0&&t.exitCode!==0,l=(t,e)=>{e.info(`Run ${t.id}`),e.info(` start: ${t.startTime}`),e.info(` end: ${t.endTime}`),e.info(` duration: ${h(t.duration)}`),e.info(` totals: ${String(t.stats.total)} total · ${String(t.stats.succeeded)} ok · ${String(t.stats.cached)} cached · ${String(t.stats.skipped)} skipped · ${String(t.stats.failed)} failed`),e.info(` env: node ${t.environment.nodeVersion} · ${t.environment.platform}/${t.environment.arch}`),e.info("")},C=(t,e)=>{if(t.length===0){e.info("(no tasks match the current filter)");return}const i=t.map(n=>({duration:h(n.duration),hash:n.hash?n.hash.slice(0,12):"-",status:p(n),taskId:n.taskId})),a={duration:Math.max(8,...i.map(n=>n.duration.length)),hash:Math.max(4,...i.map(n=>n.hash.length)),status:Math.max(6,...i.map(n=>n.status.length)),taskId:Math.max(4,...i.map(n=>n.taskId.length))};e.info(` ${r("task",a.taskId)} ${r("status",a.status)} ${r("duration",a.duration)} ${r("hash",a.hash)}`),e.info(` ${"-".repeat(a.taskId)} ${"-".repeat(a.status)} ${"-".repeat(a.duration)} ${"-".repeat(a.hash)}`);for(const n of i)e.info(` ${r(n.taskId,a.taskId)} ${r(n.status,a.status)} ${r(n.duration,a.duration)} ${r(n.hash,a.hash)}`)},R=(t,e,i)=>{l(t,i),i.info(`Task ${e.taskId}`),i.info(` status: ${p(e)}`),i.info(` cache: ${e.cacheStatus}`),i.info(` duration: ${h(e.duration)}`),i.info(` exit: ${e.exitCode===void 0?"-":String(e.exitCode)}`),i.info(` hash: ${e.hash??"(none)"}`),i.info(` start: ${e.startTime??"-"}`),i.info(` end: ${e.endTime??"-"}`),e.dependencies.length>0&&i.info(` deps: ${e.dependencies.join(", ")}`),i.info(""),f.info(`Drill into hash inputs with: vis cache why ${e.taskId} --run ${t.id}`)},D=t=>{process.stdout.write(`${JSON.stringify(t.map(e=>({id:e.id,mtime:new Date(e.mtimeMs).toISOString(),path:e.path})),void 0,2)}
1
+ import{readLastRunSummary as S,getLastRunSummaryPath as I}from"@visulima/task-runner";import{p as f,l as x,f as w}from"./cli-main.js";import{c as $,d as m}from"../packem_shared/formatBytes-BHAzNIrn-XohRrPdt.js";const T=new Set(["json","table"]),k=(t,e)=>t??e,h=t=>t===void 0?"-":t<1e3?`${String(t)}ms`:`${(t/1e3).toFixed(2)}s`,p=t=>t.exitCode===void 0?t.cacheStatus:t.exitCode===0?t.cacheStatus==="MISS"?"OK":t.cacheStatus:`FAIL(${String(t.exitCode)})`,r=(t,e)=>t.length>=e?t:t+" ".repeat(e-t.length),v=t=>t.exitCode!==void 0&&t.exitCode!==0,l=(t,e)=>{e.info(`Run ${t.id}`),e.info(` start: ${t.startTime}`),e.info(` end: ${t.endTime}`),e.info(` duration: ${h(t.duration)}`),e.info(` totals: ${String(t.stats.total)} total · ${String(t.stats.succeeded)} ok · ${String(t.stats.cached)} cached · ${String(t.stats.skipped)} skipped · ${String(t.stats.failed)} failed`),e.info(` env: node ${t.environment.nodeVersion} · ${t.environment.platform}/${t.environment.arch}`),e.info("")},C=(t,e)=>{if(t.length===0){e.info("(no tasks match the current filter)");return}const i=t.map(n=>({duration:h(n.duration),hash:n.hash?n.hash.slice(0,12):"-",status:p(n),taskId:n.taskId})),a={duration:Math.max(8,...i.map(n=>n.duration.length)),hash:Math.max(4,...i.map(n=>n.hash.length)),status:Math.max(6,...i.map(n=>n.status.length)),taskId:Math.max(4,...i.map(n=>n.taskId.length))};e.info(` ${r("task",a.taskId)} ${r("status",a.status)} ${r("duration",a.duration)} ${r("hash",a.hash)}`),e.info(` ${"-".repeat(a.taskId)} ${"-".repeat(a.status)} ${"-".repeat(a.duration)} ${"-".repeat(a.hash)}`);for(const n of i)e.info(` ${r(n.taskId,a.taskId)} ${r(n.status,a.status)} ${r(n.duration,a.duration)} ${r(n.hash,a.hash)}`)},R=(t,e,i)=>{l(t,i),i.info(`Task ${e.taskId}`),i.info(` status: ${p(e)}`),i.info(` cache: ${e.cacheStatus}`),i.info(` duration: ${h(e.duration)}`),i.info(` exit: ${e.exitCode===void 0?"-":String(e.exitCode)}`),i.info(` hash: ${e.hash??"(none)"}`),i.info(` start: ${e.startTime??"-"}`),i.info(` end: ${e.endTime??"-"}`),e.dependencies.length>0&&i.info(` deps: ${e.dependencies.join(", ")}`),i.info(""),f.info(`Drill into hash inputs with: vis cache why ${e.taskId} --run ${t.id}`)},D=t=>{process.stdout.write(`${JSON.stringify(t.map(e=>({id:e.id,mtime:new Date(e.mtimeMs).toISOString(),path:e.path})),void 0,2)}
2
2
  `)},M=(t,e,i)=>{if(t.length===0){f.info(`No recorded runs found in ${m(e)}/. Run with --summarize to record a run.`);return}const a={id:Math.max(2,...t.map(n=>n.id.length)),mtime:24};i.info(` ${r("id",a.id)} ${r("mtime",a.mtime)}`),i.info(` ${"-".repeat(a.id)} ${"-".repeat(a.mtime)}`);for(const n of t)i.info(` ${r(n.id,a.id)} ${new Date(n.mtimeMs).toISOString()}`)},O=(t,e)=>{let{tasks:i}=t;return e.task!==void 0&&(i=i.filter(a=>a.taskId===e.task)),e.failed&&(i=i.filter(a=>v(a))),i},j=async(t,e)=>{const{failed:i,format:a,runId:n,task:o,workspaceRoot:d}=t,s=n===void 0?await S(d,{dataDirectory:$(d)}):await w(d,n);if(!s){if(a==="json"){process.stdout.write(`${JSON.stringify({error:"no-summary",runId:n??null},void 0,2)}
3
3
  `),process.exitCode=1;return}n===void 0?f.error(`No previous run summary found. Run a task first to populate \`${I(d,{dataDirectory:$(d)})}\`.`):f.error(`Run summary "${n}" not found in ${m(d)}/.`),process.exitCode=1;return}const c=O(s,{failed:i,task:o});if(o!==void 0&&c.length===0){if(a==="json"){process.stdout.write(`${JSON.stringify({error:"task-not-in-summary",runId:s.id,taskId:o},void 0,2)}
4
4
  `),process.exitCode=1;return}f.error(`Task "${o}" was not part of run ${s.id}.`),process.exitCode=1;return}if(s.stats.failed>0&&(process.exitCode=1),a==="json"){process.stdout.write(`${JSON.stringify({duration:s.duration,endTime:s.endTime,environment:s.environment,runId:s.id,startTime:s.startTime,stats:s.stats,tasks:c.map(u=>({cacheStatus:u.cacheStatus,dependencies:u.dependencies,duration:u.duration,endTime:u.endTime,exitCode:u.exitCode,hash:u.hash??null,startTime:u.startTime,taskId:u.taskId}))},void 0,2)}
@@ -1 +1 @@
1
- import{createTaskGraph as $}from"@visulima/task-runner";import{d as b,b as O}from"./catalog.js";import{f as P}from"../packem_shared/project-name-filter-BmszI2_J.js";import{r as S,f as E,a as G}from"../packem_shared/selectors-B7lSFz7l.js";const T=(l,s,t)=>{const a=[],e=new Set,n=(r,u)=>{if(e.has(r))return;e.add(r);const m=s[r]??[];for(const d of m)n(d,u+1);const o=t[r],h=" ".repeat(u);a.push(`${h}${r}${o?.cache===!1?" (no-cache)":""}`)};for(const r of l)n(r,0);return a},x=(l,s,t)=>({roots:l,tasks:Object.fromEntries(Object.entries(t).map(([a,e])=>[a,{cache:e.cache,dependsOn:s[a]??[],outputs:e.outputs,parallelism:e.parallelism,projectRoot:e.projectRoot,target:e.target}]))}),C=async({argument:l,logger:s,options:t,process:a,visConfig:e,workspaceRoot:n})=>{const r=l[0];if(!r)throw new Error("Missing selector. Usage: vis action-graph <selector>");if(!n)throw new Error("Could not determine workspace root. Run inside a monorepo.");const{config:u,packageJsons:m,workspace:o}=b(n,e),h=O(n,o,m),d=await S(r,o,a.cwd,n),{target:f}=d;let i=d.projects;t.projects!==void 0&&(i=P(i,String(t.projects),Object.keys(o.projects))),t.query&&(i=E(i,o,t.query)),i=G(i,o,t.tag);const k=i.filter(p=>o.projects[p]?.targets?.[f]!==void 0);if(k.length===0){s.info(`No projects have a "${f}" target.`);return}const y=k.map(p=>{const g=o.projects[p],j=g.targets?.[f],v={project:p,target:f};return{cache:j?.cache,id:`${p}:${f}`,outputs:j?.outputs??[],overrides:{command:j?.command},parallelism:j?.parallelism,projectRoot:g.root,target:v}}),c=$(y,{projectGraph:h,targetDefaults:u.tasks,workspace:o});if(t.json){s.info(JSON.stringify(x(c.roots,c.dependencies,c.tasks),null,2));return}const w=T(c.roots,c.dependencies,c.tasks);s.info(`Execution plan (${Object.keys(c.tasks).length} task(s), ${c.roots.length} root(s)):`),s.info("");for(const p of w)s.info(p)};export{C as default};
1
+ import{createTaskGraph as $}from"@visulima/task-runner";import{d as b,b as O}from"./catalog.js";import{f as P}from"../packem_shared/project-name-filter-CC5FF49q.js";import{r as S,f as E,a as G}from"../packem_shared/selectors-B7lSFz7l.js";const T=(l,s,t)=>{const a=[],e=new Set,n=(r,u)=>{if(e.has(r))return;e.add(r);const m=s[r]??[];for(const d of m)n(d,u+1);const o=t[r],h=" ".repeat(u);a.push(`${h}${r}${o?.cache===!1?" (no-cache)":""}`)};for(const r of l)n(r,0);return a},x=(l,s,t)=>({roots:l,tasks:Object.fromEntries(Object.entries(t).map(([a,e])=>[a,{cache:e.cache,dependsOn:s[a]??[],outputs:e.outputs,parallelism:e.parallelism,projectRoot:e.projectRoot,target:e.target}]))}),C=async({argument:l,logger:s,options:t,process:a,visConfig:e,workspaceRoot:n})=>{const r=l[0];if(!r)throw new Error("Missing selector. Usage: vis action-graph <selector>");if(!n)throw new Error("Could not determine workspace root. Run inside a monorepo.");const{config:u,packageJsons:m,workspace:o}=b(n,e),h=O(n,o,m),d=await S(r,o,a.cwd,n),{target:f}=d;let i=d.projects;t.projects!==void 0&&(i=P(i,String(t.projects),Object.keys(o.projects))),t.query&&(i=E(i,o,t.query)),i=G(i,o,t.tag);const k=i.filter(p=>o.projects[p]?.targets?.[f]!==void 0);if(k.length===0){s.info(`No projects have a "${f}" target.`);return}const y=k.map(p=>{const g=o.projects[p],j=g.targets?.[f],v={project:p,target:f};return{cache:j?.cache,id:`${p}:${f}`,outputs:j?.outputs??[],overrides:{command:j?.command},parallelism:j?.parallelism,projectRoot:g.root,target:v}}),c=$(y,{projectGraph:h,targetDefaults:u.tasks,workspace:o});if(t.json){s.info(JSON.stringify(x(c.roots,c.dependencies,c.tasks),null,2));return}const w=T(c.roots,c.dependencies,c.tasks);s.info(`Execution plan (${Object.keys(c.tasks).length} task(s), ${c.roots.length} root(s)):`),s.info("");for(const p of w)s.info(p)};export{C as default};
@@ -1,2 +1,2 @@
1
- import{createRequire as C}from"node:module";import"../packem_shared/index-DHD8wb6Z.js";import{w as A,d as I}from"./catalog.js";import{p as c,j as N}from"./cli-main.js";import{p as L,i as R,r as v,g as H,s as M,a as b,S as W,b as O,c as P,d as U,e as D}from"../packem_shared/lifecycle-DW8KRF5d.js";import{r as q,l as z}from"../packem_shared/target-options-d_rIrLyq.js";let T;const j=s=>(T??=C(import.meta.url))(s),w=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,_=s=>{if(typeof w<"u"&&w.versions&&w.versions.node){const[e,r]=w.versions.node.split(".").map(Number);if(e>22||e===22&&r>=3||e===20&&r>=16)return w.getBuiltinModule(s)}return j(s)},{open:E,stat:$,watch:F}=_("node:fs/promises"),h=async s=>{const e=s?.plugins;if(!e||e.length===0)return;const r=U();return await D(r,e),{callHook:async(d,...o)=>{try{await r.callHook(d,...o)}catch(t){const a=t instanceof Error?t.message:String(t);c.warn(`Plugin error in ${d}: ${a}`)}}}},V=s=>{const e=s.trim(),r=e.lastIndexOf(":");if(!(r<=0||r===e.length-1))return{project:e.slice(0,r),target:e.slice(r+1)}},y=async(s,e,r)=>{const d=V(r);if(!d){c.error(`Invalid target id "${r}". Expected "<project>:<target>", e.g. "@my/api:db".`);return}const o=await A(s),{projectOptions:t,workspace:a}=I(s,e,o),i=a.projects[d.project],n=t.get(d.project)?.[d.target];if(!i||!n){c.error(`Target "${r}" not found in this workspace.`);return}const p=n.options?.service;if(!p){c.error(`Target "${r}" is not a service. Add an \`options.service\` block to make it eligible for \`vis service\`.`);return}if(!n.command){c.error(`Target "${r}" has no command — services must be runnable.`);return}const g=q(s,i.root,n.options?.runFromWorkspaceRoot===!0),u=n.options?.envFile?z(g,n.options.envFile):{};return{command:n.command,cwd:g,env:{...u,...p.env},service:p,target:n,targetId:r}},m=s=>{if(!s)throw new Error("Could not determine workspace root. Run `vis service` inside a workspace.");return s},re=async({argument:s,options:e,visConfig:r,workspaceRoot:d})=>{const o=m(d),t=s[0]?.trim();if(!t){c.error("Missing target id. Usage: vis service start <project>:<target>"),process.exitCode=1;return}const a=await y(o,r,t);if(!a){process.exitCode=1;return}try{const{entry:i}=await b({command:a.command,config:a.service,cwd:a.cwd,env:a.env,id:t,readinessTimeoutMs:e.timeout,skipReadiness:e.readiness===!1,workspaceRoot:o});await(await h(r))?.callHook("service:start",i),c.success(`Started ${t} (pid ${String(i.pid)})`),c.info(` log: ${i.logFile}`)}catch(i){const n=i instanceof Error?i.message:String(i);i instanceof W?c.error(`Readiness probe failed for ${t}: ${n}`):c.error(`Failed to start ${t}: ${n}`),process.exitCode=1}},S=async({graceMs:s,hookSink:e,id:r,workspaceRoot:d})=>{const o=await v(d,r),{stopped:t}=await M({graceMs:s,id:r,workspaceRoot:d});return t?(o&&await e?.callHook("service:stop",o),c.success(`Stopped ${r}`),!0):(c.info(`No running service registered for ${r}`),!1)},se=async({argument:s,options:e,visConfig:r,workspaceRoot:d})=>{const o=m(d),{graceMs:t}=e,a=s[0]?.trim(),i=await h(r);if(e.all){if(a){c.error("Cannot combine --all with a target id. Use one or the other."),process.exitCode=1;return}const p=await P(o);if(p.length===0){c.info("No running services registered for this workspace.");return}for(const g of p)await S({graceMs:t,hookSink:i,id:g.id,workspaceRoot:o});return}if(!a){c.error("Missing target id. Usage: vis service stop <project>:<target> | --all"),process.exitCode=1;return}await S({graceMs:t,hookSink:i,id:a,workspaceRoot:o})||(process.exitCode=1)},B=s=>{const e=s.config.readiness?.tcp.port??s.config.port;return e===void 0?"—":String(e)},x=new Set(["json","table"]),oe=async({logger:s,options:e,workspaceRoot:r})=>{const d=m(r),o=e.format??"table";if(!x.has(o)){c.error(`Invalid --format "${o}". Expected one of: ${[...x].sort().join(", ")}.`),process.exitCode=1;return}const{surviving:t}=await L(d);if(o==="json"){const l=Date.now();process.stdout.write(`${JSON.stringify(t.map(f=>{const k=Date.parse(f.startedAt);return{ageMs:Number.isFinite(k)?l-k:null,alive:R(f.pid),command:f.command,cwd:f.cwd,env:f.env,id:f.id,logFile:f.logFile,pid:f.pid,port:f.config.readiness?.tcp.port??f.config.port??null,startedAt:f.startedAt,visVersion:f.visVersion}}),void 0,2)}
1
+ import{createRequire as C}from"node:module";import"../packem_shared/index-DHD8wb6Z.js";import{w as A,d as I}from"./catalog.js";import{p as c,j as N}from"./cli-main.js";import{p as L,i as R,r as v,g as H,s as M,a as b,S as W,b as O,c as P,d as U,e as D}from"../packem_shared/lifecycle-CAIJbxIa.js";import{r as q,l as z}from"../packem_shared/target-options-d_rIrLyq.js";let T;const j=s=>(T??=C(import.meta.url))(s),w=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,_=s=>{if(typeof w<"u"&&w.versions&&w.versions.node){const[e,r]=w.versions.node.split(".").map(Number);if(e>22||e===22&&r>=3||e===20&&r>=16)return w.getBuiltinModule(s)}return j(s)},{open:E,stat:$,watch:F}=_("node:fs/promises"),h=async s=>{const e=s?.plugins;if(!e||e.length===0)return;const r=U();return await D(r,e),{callHook:async(d,...o)=>{try{await r.callHook(d,...o)}catch(t){const a=t instanceof Error?t.message:String(t);c.warn(`Plugin error in ${d}: ${a}`)}}}},V=s=>{const e=s.trim(),r=e.lastIndexOf(":");if(!(r<=0||r===e.length-1))return{project:e.slice(0,r),target:e.slice(r+1)}},y=async(s,e,r)=>{const d=V(r);if(!d){c.error(`Invalid target id "${r}". Expected "<project>:<target>", e.g. "@my/api:db".`);return}const o=await A(s),{projectOptions:t,workspace:a}=I(s,e,o),i=a.projects[d.project],n=t.get(d.project)?.[d.target];if(!i||!n){c.error(`Target "${r}" not found in this workspace.`);return}const p=n.options?.service;if(!p){c.error(`Target "${r}" is not a service. Add an \`options.service\` block to make it eligible for \`vis service\`.`);return}if(!n.command){c.error(`Target "${r}" has no command — services must be runnable.`);return}const g=q(s,i.root,n.options?.runFromWorkspaceRoot===!0),u=n.options?.envFile?z(g,n.options.envFile):{};return{command:n.command,cwd:g,env:{...u,...p.env},service:p,target:n,targetId:r}},m=s=>{if(!s)throw new Error("Could not determine workspace root. Run `vis service` inside a workspace.");return s},re=async({argument:s,options:e,visConfig:r,workspaceRoot:d})=>{const o=m(d),t=s[0]?.trim();if(!t){c.error("Missing target id. Usage: vis service start <project>:<target>"),process.exitCode=1;return}const a=await y(o,r,t);if(!a){process.exitCode=1;return}try{const{entry:i}=await b({command:a.command,config:a.service,cwd:a.cwd,env:a.env,id:t,readinessTimeoutMs:e.timeout,skipReadiness:e.readiness===!1,workspaceRoot:o});await(await h(r))?.callHook("service:start",i),c.success(`Started ${t} (pid ${String(i.pid)})`),c.info(` log: ${i.logFile}`)}catch(i){const n=i instanceof Error?i.message:String(i);i instanceof W?c.error(`Readiness probe failed for ${t}: ${n}`):c.error(`Failed to start ${t}: ${n}`),process.exitCode=1}},S=async({graceMs:s,hookSink:e,id:r,workspaceRoot:d})=>{const o=await v(d,r),{stopped:t}=await M({graceMs:s,id:r,workspaceRoot:d});return t?(o&&await e?.callHook("service:stop",o),c.success(`Stopped ${r}`),!0):(c.info(`No running service registered for ${r}`),!1)},se=async({argument:s,options:e,visConfig:r,workspaceRoot:d})=>{const o=m(d),{graceMs:t}=e,a=s[0]?.trim(),i=await h(r);if(e.all){if(a){c.error("Cannot combine --all with a target id. Use one or the other."),process.exitCode=1;return}const p=await P(o);if(p.length===0){c.info("No running services registered for this workspace.");return}for(const g of p)await S({graceMs:t,hookSink:i,id:g.id,workspaceRoot:o});return}if(!a){c.error("Missing target id. Usage: vis service stop <project>:<target> | --all"),process.exitCode=1;return}await S({graceMs:t,hookSink:i,id:a,workspaceRoot:o})||(process.exitCode=1)},B=s=>{const e=s.config.readiness?.tcp.port??s.config.port;return e===void 0?"—":String(e)},x=new Set(["json","table"]),oe=async({logger:s,options:e,workspaceRoot:r})=>{const d=m(r),o=e.format??"table";if(!x.has(o)){c.error(`Invalid --format "${o}". Expected one of: ${[...x].sort().join(", ")}.`),process.exitCode=1;return}const{surviving:t}=await L(d);if(o==="json"){const l=Date.now();process.stdout.write(`${JSON.stringify(t.map(f=>{const k=Date.parse(f.startedAt);return{ageMs:Number.isFinite(k)?l-k:null,alive:R(f.pid),command:f.command,cwd:f.cwd,env:f.env,id:f.id,logFile:f.logFile,pid:f.pid,port:f.config.readiness?.tcp.port??f.config.port??null,startedAt:f.startedAt,visVersion:f.visVersion}}),void 0,2)}
2
2
  `);return}if(t.length===0){c.info("No running services registered for this workspace.");return}const a=Date.now(),i=t.map(l=>{const f=Date.parse(l.startedAt);return{age:Number.isFinite(f)?N(f,a):"?",id:l.id,log:l.logFile,pid:String(l.pid),port:B(l)}}),n=Math.max(2,...i.map(l=>l.id.length)),p=Math.max(3,...i.map(l=>l.pid.length)),g=Math.max(4,...i.map(l=>l.port.length)),u=Math.max(3,...i.map(l=>l.age.length));s.info(` ${"id".padEnd(n)} ${"pid".padEnd(p)} ${"port".padEnd(g)} ${"age".padEnd(u)} log`),s.info(` ${"-".repeat(n)} ${"-".repeat(p)} ${"-".repeat(g)} ${"-".repeat(u)} ---`);for(const l of i)s.info(` ${l.id.padEnd(n)} ${l.pid.padEnd(p)} ${l.port.padEnd(g)} ${l.age.padEnd(u)} ${l.log}`)},ie=async({argument:s,options:e,workspaceRoot:r})=>{const d=m(r),o=s[0]?.trim();if(!o){c.error("Missing target id. Usage: vis service status <project>:<target>"),process.exitCode=1;return}const t=await v(d,o);if(!t){c.error(`No service registered for ${o}.`),process.exitCode=1;return}if(!R(t.pid)){c.error(`Service ${o} is not running (pid ${String(t.pid)} is dead). Run \`vis service start ${o}\` to recover.`),process.exitCode=1;return}try{await O(t.config,{timeoutMs:e.timeout}),c.success(`${o} healthy (pid ${String(t.pid)})`)}catch(a){const i=a instanceof Error?a.message:String(a);c.error(`${o} probe failed: ${i}`),process.exitCode=1}},ae=async({argument:s,options:e,visConfig:r,workspaceRoot:d})=>{const o=m(d),t=s[0]?.trim();if(!t){c.error("Missing target id. Usage: vis service restart <project>:<target>"),process.exitCode=1;return}const a=await h(r),i=await v(o,t);(await M({graceMs:e.graceMs,id:t,workspaceRoot:o})).stopped&&i&&await a?.callHook("service:stop",i);const p=await y(o,r,t);if(!p){process.exitCode=1;return}try{const{entry:g}=await b({command:p.command,config:p.service,cwd:p.cwd,env:p.env,id:t,readinessTimeoutMs:e.timeout,skipReadiness:e.readiness===!1,workspaceRoot:o});await a?.callHook("service:start",g),c.success(`Restarted ${t} (pid ${String(g.pid)})`)}catch(g){const u=g instanceof Error?g.message:String(g);c.error(`Failed to restart ${t}: ${u}`),process.exitCode=1}},G=200,J=1024*1024,K=async s=>{let e=0;try{e=(await $(s)).size}catch{e=0}const r=new AbortController;let d=!1;const o=()=>{d=!0,r.abort()},t=()=>{r.abort()};process.on("SIGINT",o),process.on("SIGTERM",t);let a=!1;const i=async()=>{if(!a){a=!0;try{const n=await $(s).catch(()=>{});if(!n||(n.size<e&&(e=0),n.size===e))return;const p=n.size-e,g=Math.min(p,J),u=await E(s,"r");try{const l=Buffer.alloc(g);await u.read(l,0,g,e),process.stdout.write(l),e+=g}finally{await u.close().catch(()=>{})}}finally{a=!1}}};try{const n=(async()=>{try{const p=F(s,{signal:r.signal});for(;!(await p.next()).done;)await i()}catch{}})();for(;!r.signal.aborted;)await i(),await new Promise(p=>{const g=setTimeout(p,G);r.signal.addEventListener("abort",()=>{clearTimeout(g),p()},{once:!0})});await n.catch(()=>{}),await i().catch(()=>{})}finally{process.off("SIGINT",o),process.off("SIGTERM",t)}d&&(process.exitCode=130)},ne=async({argument:s,options:e,workspaceRoot:r})=>{const d=m(r),o=s[0]?.trim();if(!o){c.error("Missing target id. Usage: vis service logs <project>:<target>"),process.exitCode=1;return}const t=await v(d,o);if(!t){c.error(`No service registered for ${o}.`),process.exitCode=1;return}if(!await H(t.logFile)){c.warn(`Log file is missing for ${o}: ${t.logFile}`),process.exitCode=1;return}if(e.follow){await K(t.logFile);return}const a=await E(t.logFile,"r");try{const i=a.createReadStream();await new Promise((n,p)=>{i.on("end",n),i.on("error",p),i.pipe(process.stdout,{end:!1})})}finally{await a.close().catch(()=>{})}};export{oe as serviceListExecute,ne as serviceLogsExecute,ae as serviceRestartExecute,re as serviceStartExecute,ie as serviceStatusExecute,se as serviceStopExecute};
@@ -1 +1 @@
1
- import{F as T,J as a,b as S,X as y}from"../packem_shared/index.server-sXNQYpsl.js";import{e as V}from"../packem_shared/index-DHD8wb6Z.js";import{enforceProjectConstraints as v}from"@visulima/task-runner";import{d as x,b as J}from"./catalog.js";import{k as w}from"./cli-main.js";import{c as z}from"../packem_shared/runtime-check-BklgEMkC.js";import{d as D}from"../packem_shared/formatBytes-BHAzNIrn-Bkk_uRS-.js";import{y as G}from"../packem_shared/isAccessibleSync-DYKTrrvc-CSnBISfV.js";import{p as H}from"../packem_shared/readJsonSync-CbryXYxN-B2aSeDpC.js";const e=c=>c?a("✓"):y("✗"),N=async({fs:c,logger:t,options:b,visConfig:g,workspaceRoot:n})=>{if(!n)throw new Error("Could not determine workspace root.");const{config:h,packageJsons:C,workspace:f}=x(n,g),O=J(n,f,C),k=Object.keys(f.projects).length,d=new Set(Object.values(f.projects).flatMap($=>Object.keys($.targets??{}))).size,i=z(n);let s=0;h.constraints&&(s=v(O,h.constraints).length);const o=w(n,{minRuns:2});let r;const l=D(n);if(G(l)){const F=(await c.readdir(l)).filter(u=>u.endsWith(".json")).sort();let p=0,j=0;for(const u of F.slice(-20))try{const m=H(V(l,u));m.stats&&(p+=m.stats.total??0,j+=m.stats.cached??0)}catch{continue}p>0&&(r=`${(j/p*100).toFixed(0)}%`)}if(b.json){t.info(JSON.stringify({cacheHitRate:r??null,constraintViolations:s,flakyTasks:o.length,projects:k,runtimeIssues:i.length,targets:d},null,2));return}t.info(""),t.info(` ${T("VIS STATUS")}`),t.info(""),t.info(` ${e(!0)} ${String(k)} projects · ${String(d)} unique targets`),t.info(` ${e(i.length===0)} Runtime: ${i.length===0?a("OK"):S(`${String(i.length)} issue(s)`)}`),t.info(` ${e(s===0)} Constraints: ${s===0?a("OK"):y(`${String(s)} violation(s)`)}`),t.info(` ${e(o.length===0)} Flaky tasks: ${o.length===0?a("none"):S(String(o.length))}`),r&&t.info(` ${e(!0)} Cache hit rate: ${r} (last 20 runs)`),t.info("")};export{N as default};
1
+ import{F as T,J as a,b as S,X as y}from"../packem_shared/index.server-sXNQYpsl.js";import{e as V}from"../packem_shared/index-DHD8wb6Z.js";import{enforceProjectConstraints as v}from"@visulima/task-runner";import{d as x,b as J}from"./catalog.js";import{k as w}from"./cli-main.js";import{c as z}from"../packem_shared/runtime-check-BklgEMkC.js";import{d as D}from"../packem_shared/formatBytes-BHAzNIrn-XohRrPdt.js";import{y as G}from"../packem_shared/isAccessibleSync-DYKTrrvc-CSnBISfV.js";import{p as H}from"../packem_shared/readJsonSync-CbryXYxN-B2aSeDpC.js";const e=c=>c?a("✓"):y("✗"),N=async({fs:c,logger:t,options:b,visConfig:g,workspaceRoot:n})=>{if(!n)throw new Error("Could not determine workspace root.");const{config:h,packageJsons:C,workspace:f}=x(n,g),O=J(n,f,C),k=Object.keys(f.projects).length,d=new Set(Object.values(f.projects).flatMap($=>Object.keys($.targets??{}))).size,i=z(n);let s=0;h.constraints&&(s=v(O,h.constraints).length);const o=w(n,{minRuns:2});let r;const l=D(n);if(G(l)){const F=(await c.readdir(l)).filter(u=>u.endsWith(".json")).sort();let p=0,j=0;for(const u of F.slice(-20))try{const m=H(V(l,u));m.stats&&(p+=m.stats.total??0,j+=m.stats.cached??0)}catch{continue}p>0&&(r=`${(j/p*100).toFixed(0)}%`)}if(b.json){t.info(JSON.stringify({cacheHitRate:r??null,constraintViolations:s,flakyTasks:o.length,projects:k,runtimeIssues:i.length,targets:d},null,2));return}t.info(""),t.info(` ${T("VIS STATUS")}`),t.info(""),t.info(` ${e(!0)} ${String(k)} projects · ${String(d)} unique targets`),t.info(` ${e(i.length===0)} Runtime: ${i.length===0?a("OK"):S(`${String(i.length)} issue(s)`)}`),t.info(` ${e(s===0)} Constraints: ${s===0?a("OK"):y(`${String(s)} violation(s)`)}`),t.info(` ${e(o.length===0)} Flaky tasks: ${o.length===0?a("none"):S(String(o.length))}`),r&&t.info(` ${e(!0)} Cache hit rate: ${r} (last 20 runs)`),t.info("")};export{N as default};
@@ -1,3 +1,3 @@
1
- import{createRequire as u}from"node:module";import{g as m}from"../packem_shared/package-version-ZC59HAtH.js";let a;const f=t=>(a??=u(import.meta.url))(t),r=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,d=t=>{if(typeof r<"u"&&r.versions&&r.versions.node){const[e,s]=r.versions.node.split(".").map(Number);if(e>22||e===22&&s>=3||e===20&&s>=16)return r.getBuiltinModule(t)}return f(t)},{execSync:l,spawnSync:p}=d("node:child_process"),y=async({argument:t,logger:e,options:s})=>{const o=t?.[0];e.info("info: checking for updates...");const i=m();let n;try{const c=l("npm view @visulima/vis version",{encoding:"utf8"}).trim();n=o??c}catch{throw new Error("Failed to query npm registry. Check your network connection.")}if(i===n&&!s.force){e.info(`
1
+ import{createRequire as u}from"node:module";import{g as m}from"../packem_shared/package-version-DFlytdgJ.js";let a;const f=t=>(a??=u(import.meta.url))(t),r=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,d=t=>{if(typeof r<"u"&&r.versions&&r.versions.node){const[e,s]=r.versions.node.split(".").map(Number);if(e>22||e===22&&s>=3||e===20&&s>=16)return r.getBuiltinModule(t)}return f(t)},{execSync:l,spawnSync:p}=d("node:child_process"),y=async({argument:t,logger:e,options:s})=>{const o=t?.[0];e.info("info: checking for updates...");const i=m();let n;try{const c=l("npm view @visulima/vis version",{encoding:"utf8"}).trim();n=o??c}catch{throw new Error("Failed to query npm registry. Check your network connection.")}if(i===n&&!s.force){e.info(`
2
2
  ✓ Already up to date (${i})`);return}if(s.check){i===n?e.info(`✓ Already up to date (${i})`):e.info(`info: found @visulima/vis@${n} (current: ${i})`);return}if(e.info(`info: found @visulima/vis@${n} (current: ${i})`),e.info("info: installing..."),p("npm",["install","-g",`@visulima/vis@${n}`],{encoding:"utf8",stdio:"inherit"}).status!==0)throw new Error("Failed to update. Try running with sudo or fix npm permissions.");e.info(`
3
3
  ✓ Updated @visulima/vis from ${i} → ${n}`)};export{y as default};
@@ -1,3 +1,3 @@
1
- import{d as h,b as j}from"./catalog.js";import{V as n}from"../packem_shared/vis-user-error-DFPJeiL5.js";import{s as k}from"../packem_shared/affected-selection-BXrRytsU.js";import{f as P,a as y}from"../packem_shared/selectors-B7lSFz7l.js";const b=(r,e)=>{if(r.length>0)return[...r];const s=e.indexOf("affected",2);return s===-1?[]:e.slice(s+1)},G=async({argument:r,options:e,process:s,rawArgv:u,runtime:g,visConfig:d,workspaceRoot:f})=>{if(!r[0])throw new n("Missing target. Usage: vis affected <target>");if(!f)throw new n("Could not determine workspace root. Run this command inside a monorepo.");if(e.sparseCheckout){const o=f,{packageJsons:p,workspace:t}=h(o,d),l=j(o,t,p),w=await k({base:e.base,downstream:e.downstream,head:e.head,uncommitted:e.uncommitted,upstream:e.upstream},{projectGraph:l,projects:t.projects,workspaceRoot:o},{defaultBase:d?.defaultBase});let c=P(w.affectedProjects,t,e.query);c=y(c,t,e.tag);const i=[...new Set(c.map(m=>t.projects[m]?.root??m))].sort();process.stdout.write(i.length>0?`${i.join(`
1
+ import{d as h,b as j}from"./catalog.js";import{V as n}from"../packem_shared/vis-user-error-qqqhLoF6.js";import{s as k}from"../packem_shared/affected-selection-Bt4qkPUb.js";import{f as P,a as y}from"../packem_shared/selectors-B7lSFz7l.js";const b=(r,e)=>{if(r.length>0)return[...r];const s=e.indexOf("affected",2);return s===-1?[]:e.slice(s+1)},G=async({argument:r,options:e,process:s,rawArgv:u,runtime:g,visConfig:d,workspaceRoot:f})=>{if(!r[0])throw new n("Missing target. Usage: vis affected <target>");if(!f)throw new n("Could not determine workspace root. Run this command inside a monorepo.");if(e.sparseCheckout){const o=f,{packageJsons:p,workspace:t}=h(o,d),l=j(o,t,p),w=await k({base:e.base,downstream:e.downstream,head:e.head,uncommitted:e.uncommitted,upstream:e.upstream},{projectGraph:l,projects:t.projects,workspaceRoot:o},{defaultBase:d?.defaultBase});let c=P(w.affectedProjects,t,e.query);c=y(c,t,e.tag);const i=[...new Set(c.map(m=>t.projects[m]?.root??m))].sort();process.stdout.write(i.length>0?`${i.join(`
2
2
  `)}
3
3
  `:"");return}const a=b(u??[],s?.argv??[]);if(a.length===0)throw new n("Missing target. Usage: vis affected <target>");await g.runCommand("run",{argv:a.includes("--affected")?a:[...a,"--affected"]})};export{G as default,b as forwardedArgv};
@@ -1,4 +1,4 @@
1
- import{createRequire as $}from"node:module";import{E as j,R as E,q as I}from"./catalog.js";import{d as P}from"../packem_shared/pm-runner-d93_73O6.js";import{l as C}from"../packem_shared/dependency-scan-DBH2Qo4I.js";import{r as T}from"../packem_shared/provenance-w-NIPtim.js";import{r as D}from"../packem_shared/signatures-ijwqxAtF.js";import{loadOptionalSigstore as R}from"./loader.js";let y;const N=s=>(y??=$(import.meta.url))(s),m=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,_=s=>{if(typeof m<"u"&&m.versions&&m.versions.node){const[t,r]=m.versions.node.split(".").map(Number);if(t>22||t===22&&r>=3||t===20&&r>=16)return m.getBuiltinModule(s)}return N(s)},{createHash:O}=_("node:crypto"),{isAbsolute:k,resolve:S,basename:v}=_("node:path"),q=s=>(s??"").split(",").map(t=>t.trim()).filter(t=>t.length>0),G=async({logger:s,options:t,workspaceRoot:r})=>{if(!r)throw new Error("Could not determine workspace root. Run this command inside a monorepo.");const n=t.format??"table",c=t.prodOnly??!1,u=t.failOn==="error"?"error":"warning",d=q(t.allowlist),a=P(r),l=C(r,a.name,{includeDev:!c}).map(({name:e,version:o})=>({name:e,version:o})),[f,p]=await Promise.all([T(l,{allowlist:d,workspaceRoot:r}),D(l,{allowlist:d,workspaceRoot:r})]),i=[...f.map(e=>({code:"provenance-regression",message:`Resolved ${e.packageName}@${e.version} has no published provenance attestation, but ${e.packageName}@${e.priorVersionWithProvenance} did — a provenance regression.`,packageName:e.packageName,severity:"warning",version:e.version})),...p.map(e=>({code:e.code,message:e.message,packageName:e.packageName,severity:e.severity,version:e.version}))],g=i.filter(e=>u==="error"?e.severity==="error":!0);if(n==="json")process.stdout.write(`${JSON.stringify({findings:i,ok:g.length===0},void 0,2)}
1
+ import{createRequire as $}from"node:module";import{E as j,R as E,q as I}from"./catalog.js";import{d as P}from"../packem_shared/pm-runner-d93_73O6.js";import{l as C}from"../packem_shared/dependency-scan-DBH2Qo4I.js";import{r as T}from"../packem_shared/provenance-BH80RHXx.js";import{r as D}from"../packem_shared/signatures-BP042BlB.js";import{loadOptionalSigstore as R}from"./loader.js";let y;const N=s=>(y??=$(import.meta.url))(s),m=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,_=s=>{if(typeof m<"u"&&m.versions&&m.versions.node){const[t,r]=m.versions.node.split(".").map(Number);if(t>22||t===22&&r>=3||t===20&&r>=16)return m.getBuiltinModule(s)}return N(s)},{createHash:O}=_("node:crypto"),{isAbsolute:k,resolve:S,basename:v}=_("node:path"),q=s=>(s??"").split(",").map(t=>t.trim()).filter(t=>t.length>0),G=async({logger:s,options:t,workspaceRoot:r})=>{if(!r)throw new Error("Could not determine workspace root. Run this command inside a monorepo.");const n=t.format??"table",c=t.prodOnly??!1,u=t.failOn==="error"?"error":"warning",d=q(t.allowlist),a=P(r),l=C(r,a.name,{includeDev:!c}).map(({name:e,version:o})=>({name:e,version:o})),[f,p]=await Promise.all([T(l,{allowlist:d,workspaceRoot:r}),D(l,{allowlist:d,workspaceRoot:r})]),i=[...f.map(e=>({code:"provenance-regression",message:`Resolved ${e.packageName}@${e.version} has no published provenance attestation, but ${e.packageName}@${e.priorVersionWithProvenance} did — a provenance regression.`,packageName:e.packageName,severity:"warning",version:e.version})),...p.map(e=>({code:e.code,message:e.message,packageName:e.packageName,severity:e.severity,version:e.version}))],g=i.filter(e=>u==="error"?e.severity==="error":!0);if(n==="json")process.stdout.write(`${JSON.stringify({findings:i,ok:g.length===0},void 0,2)}
2
2
  `);else if(n==="ndjson")for(const e of i)process.stdout.write(`${JSON.stringify(e)}
3
3
  `);else if(i.length===0)s.info(`No provenance regressions or signature problems across ${String(l.length)} locked packages.`);else{const e=process.stdout.columns||80;s.info(j(E.createElement(I,{data:i.map(o=>({code:o.code,package:`${o.packageName}@${o.version}`,severity:o.severity}))}),{columns:e}));for(const o of i)s.warn(`${o.packageName}@${o.version}: ${o.message}`)}g.length>0&&(process.exitCode=1)},x=()=>process.env.CI==="true"||typeof process.env.ACTIONS_ID_TOKEN_REQUEST_URL=="string"||typeof process.env.SIGSTORE_ID_TOKEN=="string",J=(s,t,r)=>({_type:"https://in-toto.io/Statement/v1",predicate:{buildDefinition:{buildType:"https://visulima.com/vis/attest/v1",externalParameters:{workspaceRoot:r},internalParameters:{},resolvedDependencies:[]},runDetails:{builder:{id:"https://visulima.com/vis"},metadata:{invocationId:process.env.GITHUB_RUN_ID??"",startedOn:new Date().toISOString()}}},predicateType:"https://slsa.dev/provenance/v1",subject:[{digest:{sha256:t},name:s}]}),H=async({argument:s,fs:t,logger:r,options:n,workspaceRoot:c})=>{if(!c)throw new Error("Could not determine workspace root. Run this command inside a monorepo.");const u=s[0];if(!u)throw new Error("Missing subject. Usage: vis attest <path-to-artifact>");const d=n.predicate??"slsaProvenance";if(d!=="slsaProvenance")throw new Error(`Unsupported predicate '${d}'. Only 'slsaProvenance' is supported.`);const a=k(u)?u:S(c,u),w=n.requireSigning??!1,l=n.format??"table";let f;try{f=await t.readFile(a)}catch{throw new Error(`Cannot read subject artifact at ${a}.`)}const p=O("sha256").update(f).digest("hex");if(!x()){const b="No ambient OIDC token (not running in CI). Keyless signing needs a Fulcio identity from CI OIDC.";if(w)throw new Error(`${b} Re-run in CI or drop --require-signing.`);if(l==="json"){process.stdout.write(`${JSON.stringify({ok:!1,reason:"no-ambient-oidc",sha256:p,skipped:!0,subject:v(a)},void 0,2)}
4
4
  `);return}r.warn(`${b} Skipping signing (subject sha256: ${p}). Pass --require-signing to make this fatal.`);return}const i=J(v(a),p,c),g=Buffer.from(JSON.stringify(i)),o=await(await R({workspaceRoot:c})).attest(g,"application/vnd.in-toto+json"),h=n.output?k(n.output)?n.output:S(c,n.output):`${a}.sigstore`;if(await t.writeFile(h,`${JSON.stringify(o,void 0,2)}
@@ -1,4 +1,4 @@
1
- import{createRequire as D}from"node:module";import{V as q}from"../packem_shared/vis-user-error-DFPJeiL5.js";let W;const L=e=>(W??=D(import.meta.url))(e),R=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,E=e=>{if(typeof R<"u"&&R.versions&&R.versions.node){const[t,n]=R.versions.node.split(".").map(Number);if(t>22||t===22&&n>=3||t===20&&n>=16)return R.getBuiltinModule(e)}return L(e)},{relative:h,join:u,dirname:_}=E("node:path"),{lstat:G}=E("node:fs/promises"),U=new Set(["ENOENT","ENOTDIR"]),$=e=>U.has(e?.code??""),T=async(e,t)=>{const n=e.lstat;try{return(typeof n=="function"?await n.call(e,t):await G(t)).isSymbolicLink()}catch(i){if($(i))return!1;throw i}},v=async(e,t,n)=>{if(await T(e,t))throw new q(`Refusing to write ${t}: it is a symlink, and following it would write somewhere else. Remove or replace the link, then re-run.`);await e.writeFile(t,n)},g=async(e,t)=>{try{return await e.access(t),!0}catch(n){if($(n))return!1;throw n}},Y=async(e,t)=>{try{return(await e.stat(t)).isDirectory()}catch(n){if($(n))return!1;throw n}},b=async(e,t)=>{try{return await e.readFile(t,"utf8")}catch(n){if($(n))return;throw n}},K=e=>{const t=/\n([\t ]+)\S/.exec(e);return t?.[1]!==void 0?t[1]:e.includes(`
1
+ import{createRequire as D}from"node:module";import{V as q}from"../packem_shared/vis-user-error-qqqhLoF6.js";let W;const L=e=>(W??=D(import.meta.url))(e),R=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,E=e=>{if(typeof R<"u"&&R.versions&&R.versions.node){const[t,n]=R.versions.node.split(".").map(Number);if(t>22||t===22&&n>=3||t===20&&n>=16)return R.getBuiltinModule(e)}return L(e)},{relative:h,join:u,dirname:_}=E("node:path"),{lstat:G}=E("node:fs/promises"),U=new Set(["ENOENT","ENOTDIR"]),$=e=>U.has(e?.code??""),T=async(e,t)=>{const n=e.lstat;try{return(typeof n=="function"?await n.call(e,t):await G(t)).isSymbolicLink()}catch(i){if($(i))return!1;throw i}},v=async(e,t,n)=>{if(await T(e,t))throw new q(`Refusing to write ${t}: it is a symlink, and following it would write somewhere else. Remove or replace the link, then re-run.`);await e.writeFile(t,n)},g=async(e,t)=>{try{return await e.access(t),!0}catch(n){if($(n))return!1;throw n}},Y=async(e,t)=>{try{return(await e.stat(t)).isDirectory()}catch(n){if($(n))return!1;throw n}},b=async(e,t)=>{try{return await e.readFile(t,"utf8")}catch(n){if($(n))return;throw n}},K=e=>{const t=/\n([\t ]+)\S/.exec(e);return t?.[1]!==void 0?t[1]:e.includes(`
2
2
  `)?" ":""},V=(e,t)=>{const n=t.includes(`\r
3
3
  `)?`\r
4
4
  `:`
@@ -1,4 +1,4 @@
1
- import{a as q,b as J,p as f,O as G,c as T,d as O}from"./cli-main.js";import{l as H,r as K,t as m,c as Q,k as W,R as c,E as X,m as y,n as P,o as Z,s as _}from"./catalog.js";import{i as ee}from"../packem_shared/index-BjdW45xX.js";import{v as te,r as se,f as re}from"../packem_shared/ai-analysis-DSQQDFU9.js";import{V as ae}from"../packem_shared/vis-user-error-DFPJeiL5.js";import{d as ne}from"../packem_shared/pm-runner-d93_73O6.js";import{s as oe}from"../packem_shared/formatBytes-BHAzNIrn-Bkk_uRS-.js";import{U as ce,V as ie,C as j}from"../packem_shared/vis-update-app-DNeU8RBQ.js";const we=async({argument:$,logger:s,options:e,visConfig:o,workspaceRoot:C})=>{if(!C)throw new Error("Could not determine workspace root. Run this command inside a monorepo.");const d=C;if(e.sync&&!e.securityConfig)throw new ae("--sync requires --security-config. Run `vis check --security-config --sync`.");if(e.securityConfig){const t=ne(d);if(q(o??{},t.name),e.sync&&t.name==="pnpm"){const r=J(o??{});if(r.length>0){f.info(`
1
+ import{a as q,b as J,p as f,O as G,c as T,d as O}from"./cli-main.js";import{l as H,r as K,t as m,c as Q,k as W,R as c,E as X,m as y,n as P,o as Z,s as _}from"./catalog.js";import{i as ee}from"../packem_shared/index-BjdW45xX.js";import{v as te,r as se,f as re}from"../packem_shared/ai-analysis-DSQQDFU9.js";import{V as ae}from"../packem_shared/vis-user-error-qqqhLoF6.js";import{d as ne}from"../packem_shared/pm-runner-d93_73O6.js";import{s as oe}from"../packem_shared/formatBytes-BHAzNIrn-XohRrPdt.js";import{U as ce,V as ie,C as j}from"../packem_shared/vis-update-app-CR21zyht.js";const we=async({argument:$,logger:s,options:e,visConfig:o,workspaceRoot:C})=>{if(!C)throw new Error("Could not determine workspace root. Run this command inside a monorepo.");const d=C;if(e.sync&&!e.securityConfig)throw new ae("--sync requires --security-config. Run `vis check --security-config --sync`.");if(e.securityConfig){const t=ne(d);if(q(o??{},t.name),e.sync&&t.name==="pnpm"){const r=J(o??{});if(r.length>0){f.info(`
2
2
  Settings that would sync to pnpm-workspace.yaml:`);for(const S of r)f.success(` ${S}`)}else f.info("No security settings to sync.")}else e.sync&&t.name!=="pnpm"&&(f.info(`--sync is only available for pnpm projects. Your project uses ${t.name}.`),f.info("vis enforces security settings at the vis layer for non-pnpm projects."));if(!e.security&&!$?.length)return}const{packageManager:N}=G(d),U=H(d),i=o?.update??{},h=K(d,N,{dev:e.dev,includeInternal:e["include-internal"],peer:e.peer,prod:e.prod});if(h.size===0){s.info("No catalogs found.");return}const k=e.target??i.target??"latest";if(!["latest","minor","patch"].includes(k))throw new Error(`Invalid target "${k}". Use: latest, minor, or patch.`);const D={exclude:[...m(e.exclude),...m(i.exclude)],ignore:m(i.ignore),include:[...m(e.include),...m(i.include),...$],includeLocked:!!e.includeLocked,includePrerelease:e.prerelease||i.prerelease||!1,security:e.security!==!1,target:k};let x=0;for(const t of h.values())x+=t.size;const w=!!process.stdout.isTTY&&!ee;let l;const I=w?(t,r)=>{l?l.rerender(c.createElement(j,{current:t,total:r})):l=O(c.createElement(j,{current:t,total:r}),{interactive:!0,patchConsole:!1})}:(t,r)=>{s.info(`Checking ${String(t)}/${String(r)} dependencies...`)};w||s.info(`Checking ${String(x)} catalog dependencies against npm registry...
3
3
  `);const g=new Set;T("socket")&&g.add("socket"),T("depsDev")&&g.add("deps-dev");const v=o?.security?.policies?.score?.minimum,M=Q(o?.security,{disabled:g,minimumScore:v}),{failed:E,outdated:n}=await W(h,D,U,I,d,M,o?.security?.acceptedRisks);if(l&&(l.clear(),l.unmount()),E.length>0&&s.warn(`Failed to fetch: ${E.join(", ")}`),n.length===0){s.info("All catalog dependencies are up to date.");return}const R=e.format??i.format??"table",V=te(e.aiType??"impact"),u=e.ai?await se(n,s,o?.ai,V):void 0;if(w&&R==="table"){const t=new ce(n,u??null),r=o?.tui?.autoExit??!1,S=r===!0?3:typeof r=="number"?r:0;await O(c.createElement(ie,{autoExitSeconds:S,isDryRun:!0,store:t}),{alternateScreen:!0,exitOnCtrlC:!1,interactive:!0,patchConsole:!0}).waitUntilExit();const B=process.stdout.columns||80;process.stdout.write(`
4
4
  `);for(const a of n){const Y=a.vulnerabilities?.length||a.socketReport&&a.socketReport.alerts.length>0,b=!!a.acceptedRisk,z=Y?b?"✓":"⚠":"✓",F=b?"gray":a.updateType==="major"?"red":a.updateType==="minor"?"yellow":"green",p=a.socketReport?.score.overall,L=p===void 0?"":` [${String(Math.round(p*100))}%]`,A=p===void 0?void 0:oe(p);process.stdout.write(`${X(c.createElement(y,null," ",c.createElement(y,{color:F},z),` ${a.packageName} ${a.currentRange} → ${a.newRange}`,c.createElement(y,{dimColor:!0},` ${a.updateType}`),A?c.createElement(y,{color:A},L):null),{columns:B})}
@@ -1,4 +1,4 @@
1
- import{createRequire as K}from"node:module";import{j as g,F as m,q as v,J as N,X as P,b as j}from"../packem_shared/index.server-sXNQYpsl.js";import{e as h,v as U}from"../packem_shared/index-DHD8wb6Z.js";import{d as F,b as Y}from"./catalog.js";import{d as J}from"../packem_shared/lockfile-DVFySxTS.js";import{p as z,s as X}from"../packem_shared/docker-Dy-X_BuM.js";import{i as ne}from"../packem_shared/index-BjdW45xX.js";import{g as B}from"../packem_shared/formatBytes-BHAzNIrn-Bkk_uRS-.js";import{h as oe}from"../packem_shared/writeFileSync-DJoHk3Ks-CgQ-VNNT.js";import{y as re}from"../packem_shared/isAccessibleSync-DYKTrrvc-CSnBISfV.js";let G;const W=e=>(G??=K(import.meta.url))(e),b=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,y=e=>{if(typeof b<"u"&&b.versions&&b.versions.node){const[t,n]=b.versions.node.split(".").map(Number);if(t>22||t===22&&n>=3||t===20&&n>=16)return b.getBuiltinModule(e)}return W(e)},{createInterface:O}=y("node:readline"),{spawn:Q}=y("node:child_process"),{createHash:Z}=y("node:crypto"),{existsSync:I,writeFileSync:ee,chmodSync:te}=y("node:fs"),S={aube:{base:["RUN corepack enable"],build:e=>e?`RUN aube run --filter ${e} build`:"RUN aube run build",install:"RUN aube install --frozen-lockfile"},bun:{base:["RUN npm install -g bun"],build:e=>e?`RUN bun run --filter ${e} build`:"RUN bun run build",install:"RUN --mount=type=cache,target=/root/.bun/install/cache bun install --frozen-lockfile"},npm:{base:[],build:e=>e?`RUN npm run build --workspace ${e}`:"RUN npm run build",install:"RUN --mount=type=cache,target=/root/.npm npm ci"},pnpm:{base:["ENV PNPM_HOME=/pnpm","ENV PATH=$PNPM_HOME:$PATH","RUN corepack enable"],build:e=>e?`RUN pnpm --filter ${e} build`:"RUN pnpm build",install:"RUN --mount=type=cache,id=pnpm,target=/pnpm/store pnpm install --frozen-lockfile"},yarn:{base:["RUN corepack enable"],build:e=>e?`RUN yarn workspace ${e} build`:"RUN yarn build",install:"RUN --mount=type=cache,target=/usr/local/share/.cache/yarn yarn install --immutable"}},se=e=>{const{focus:t,manager:n,nodeVersion:r}=e,o=S[n]??S.npm;return["# syntax=docker/dockerfile:1","","# Generated by 'vis docker init'. Before building, scaffold the context:",`# vis docker scaffold${t?` --focus=${t}`:""} --include-sources`,"# then build with BuildKit enabled (DOCKER_BUILDKIT=1).","",`FROM node:${r}-slim AS base`,"WORKDIR /app",...o.base,"","# --- install dependencies from the scaffolded manifests only ---","FROM base AS deps","COPY .vis/docker/workspace/ ./",o.install,"","# --- build the focus project, then drop unfocused workspace projects ---","FROM deps AS build","COPY .vis/docker/sources/ ./",o.build(t),"RUN npx vis docker prune --context=.vis/docker","","# --- minimal runtime image ---",`FROM node:${r}-slim AS runtime`,"WORKDIR /app","ENV NODE_ENV=production","COPY --from=build /app ./","USER node","# TODO: point this at your app's entrypoint",'CMD ["node", "index.js"]',""].join(`
1
+ import{createRequire as K}from"node:module";import{j as g,F as m,q as v,J as N,X as P,b as j}from"../packem_shared/index.server-sXNQYpsl.js";import{e as h,v as U}from"../packem_shared/index-DHD8wb6Z.js";import{d as F,b as Y}from"./catalog.js";import{d as J}from"../packem_shared/lockfile-DVFySxTS.js";import{p as z,s as X}from"../packem_shared/docker-Dy-X_BuM.js";import{i as ne}from"../packem_shared/index-BjdW45xX.js";import{g as B}from"../packem_shared/formatBytes-BHAzNIrn-XohRrPdt.js";import{h as oe}from"../packem_shared/writeFileSync-DJoHk3Ks-CgQ-VNNT.js";import{y as re}from"../packem_shared/isAccessibleSync-DYKTrrvc-CSnBISfV.js";let G;const W=e=>(G??=K(import.meta.url))(e),b=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,y=e=>{if(typeof b<"u"&&b.versions&&b.versions.node){const[t,n]=b.versions.node.split(".").map(Number);if(t>22||t===22&&n>=3||t===20&&n>=16)return b.getBuiltinModule(e)}return W(e)},{createInterface:O}=y("node:readline"),{spawn:Q}=y("node:child_process"),{createHash:Z}=y("node:crypto"),{existsSync:I,writeFileSync:ee,chmodSync:te}=y("node:fs"),S={aube:{base:["RUN corepack enable"],build:e=>e?`RUN aube run --filter ${e} build`:"RUN aube run build",install:"RUN aube install --frozen-lockfile"},bun:{base:["RUN npm install -g bun"],build:e=>e?`RUN bun run --filter ${e} build`:"RUN bun run build",install:"RUN --mount=type=cache,target=/root/.bun/install/cache bun install --frozen-lockfile"},npm:{base:[],build:e=>e?`RUN npm run build --workspace ${e}`:"RUN npm run build",install:"RUN --mount=type=cache,target=/root/.npm npm ci"},pnpm:{base:["ENV PNPM_HOME=/pnpm","ENV PATH=$PNPM_HOME:$PATH","RUN corepack enable"],build:e=>e?`RUN pnpm --filter ${e} build`:"RUN pnpm build",install:"RUN --mount=type=cache,id=pnpm,target=/pnpm/store pnpm install --frozen-lockfile"},yarn:{base:["RUN corepack enable"],build:e=>e?`RUN yarn workspace ${e} build`:"RUN yarn build",install:"RUN --mount=type=cache,target=/usr/local/share/.cache/yarn yarn install --immutable"}},se=e=>{const{focus:t,manager:n,nodeVersion:r}=e,o=S[n]??S.npm;return["# syntax=docker/dockerfile:1","","# Generated by 'vis docker init'. Before building, scaffold the context:",`# vis docker scaffold${t?` --focus=${t}`:""} --include-sources`,"# then build with BuildKit enabled (DOCKER_BUILDKIT=1).","",`FROM node:${r}-slim AS base`,"WORKDIR /app",...o.base,"","# --- install dependencies from the scaffolded manifests only ---","FROM base AS deps","COPY .vis/docker/workspace/ ./",o.install,"","# --- build the focus project, then drop unfocused workspace projects ---","FROM deps AS build","COPY .vis/docker/sources/ ./",o.build(t),"RUN npx vis docker prune --context=.vis/docker","","# --- minimal runtime image ---",`FROM node:${r}-slim AS runtime`,"WORKDIR /app","ENV NODE_ENV=production","COPY --from=build /app ./","USER node","# TODO: point this at your app's entrypoint",'CMD ["node", "index.js"]',""].join(`
2
2
  `)},$="v2.14.0",D=`https://github.com/hadolint/hadolint/releases/download/${$}`,ie={"hadolint-linux-arm64":"331f1d3511b84a4f1e3d18d52fec284723e4019552f4f47b19322a53ce9a40ed","hadolint-linux-x86_64":"6bf226944684f56c84dd014e8b979d27425c0148f61b3bd99bcc6f39e9dc5a47","hadolint-macos-arm64":"3625e2e9f43dcfe7bd38738a5f5520ed50ce39ed28485266e6803dd7bc197b10","hadolint-macos-x86_64":"2b69a853433f1eca522ffb921cd490bd1321424d03331fd8390f93b7fb4a02e9","hadolint-windows-x86_64.exe":"8e0ee174f88edb14f207a68430c7a53c2883ed509cdbde9a3a26fffa140fa5e4"},ae=e=>ie[e],ce=(e=process.platform,t=process.arch)=>{const n=e==="darwin"?"macos":e==="linux"?"linux":e==="win32"?"windows":void 0;if(n===void 0)return;const r=t==="arm64"?"arm64":t==="x64"?"x86_64":void 0;if(n==="windows")return"hadolint-windows-x86_64.exe";if(r!==void 0)return`hadolint-${n}-${r}`},L=e=>h(B(),"hadolint",$,e.endsWith(".exe")?"hadolint.exe":"hadolint"),le=()=>{const e=process.platform==="win32"?"hadolint.exe":"hadolint",t=(process.env.PATH??"").split(process.platform==="win32"?";":":");for(const n of t)if(n!==""&&I(h(n,e)))return e},de=e=>e.trim().split(/\s+/u)[0]??"",E=async e=>{const t=await fetch(e,{redirect:"follow"});if(!t.ok)throw new Error(`download failed (${String(t.status)} ${t.statusText}) for ${e}`);return Buffer.from(await t.arrayBuffer())},ue=async e=>{const t=L(e),n=ae(e),r=await E(`${D}/${e}`),o=Z("sha256").update(r).digest("hex");if(n===void 0){const s=await E(`${D}/${e}.sha256`),i=de(s.toString("utf8")).toLowerCase();if(i==="")throw new Error("hadolint checksum sidecar was empty or unparseable. Refusing to use the download.");if(i!==o)throw new Error(`hadolint checksum mismatch (expected ${i}, got ${o}). Refusing to use the download.`)}else if(n.toLowerCase()!==o)throw new Error(`hadolint checksum mismatch (expected ${n.toLowerCase()}, got ${o}). Refusing to use the download.`);return oe(h(B(),"hadolint",$)),ee(t,r),process.platform!=="win32"&&te(t,493),t},fe=async()=>{const e=O({input:process.stdin,output:process.stderr}),t=await new Promise(n=>{e.question(` Download hadolint ${v($)} now? ${m("[y/N]")} `,r=>{n(r.trim().toLowerCase())})});return e.close(),t==="y"||t==="yes"},pe=async e=>{const{autoInstall:t=!1,log:n}=e,r=le();if(r!==void 0)return r;const o=ce();if(o===void 0){n(`hadolint has no prebuilt binary for ${process.platform}/${process.arch}. Install it manually: https://github.com/hadolint/hadolint`);return}const s=L(o);if(I(s))return s;if(!t){if(!(!!process.stdin.isTTY&&!ne)){n(`hadolint is not installed. Re-run with ${g("--install")} (or install hadolint on PATH) to enable Dockerfile linting.`);return}if(n(`${g("hadolint")} is required to lint Dockerfiles but was not found on your PATH.`),!await fe()){n(`Skipped. Install it yourself or re-run with ${g("--install")}.`);return}}n(`Downloading hadolint ${$} (${o})…`);try{const i=await ue(o);return n(`Installed hadolint to ${m(i)}`),i}catch(i){n(`Failed to download hadolint: ${i.message}`);return}},_=async(e,t,n)=>{if(t.length===0)return[];const r=["--format","json","--no-fail",...n!==void 0&&n!==""?["--config",n]:[],...t],o=await new Promise((i,l)=>{const a=Q(e,r,{stdio:["ignore","pipe","pipe"],windowsHide:!0});let d="",u="";a.stdout?.on("data",c=>{d+=c.toString("utf8")}),a.stderr?.on("data",c=>{u+=c.toString("utf8")}),a.on("error",l),a.on("close",()=>{if(d.trim()===""&&u.trim()!==""){l(new Error(u.trim()));return}i(d)})});if(o.trim()==="")return[];let s;try{s=JSON.parse(o)}catch{throw new Error("Could not parse hadolint JSON output.")}return Array.isArray(s)?s:[]},C=(e,t,n)=>{if(!(!/\bapt-get\b/u.test(e)||!/\binstall\b/u.test(e)||n.test(e)))return e.replace(/\binstall\b/u,`install ${t}`)},k={DL3014:e=>C(e,"-y",/(?:^|\s)(?:-y|--yes|--assume-yes|-qq?)\b/u),DL3015:e=>C(e,"--no-install-recommends",/--no-install-recommends\b/u),DL3020:e=>/^\s*ADD\b/u.test(e)?e.replace(/^(\s*)ADD\b/u,"$1COPY"):void 0,DL3027:e=>/(?:^|\s)apt\s/u.test(e)&&!/\bapt-get\b/u.test(e)?e.replace(/(^|\s)apt(\s)/u,"$1apt-get$2"):void 0},T=new Set(Object.keys(k)),me=(e,t)=>{const n=e.includes(`\r
3
3
  `)?`\r
4
4
  `:`
@@ -1,2 +1,2 @@
1
- import{createRequire as F}from"node:module";import{i as W}from"../packem_shared/index-BjdW45xX.js";import{p as Y}from"../packem_shared/prompt-DMzaQEVa.js";import{e as U}from"../packem_shared/index-DHD8wb6Z.js";import{l as B,m as X,n as J,D as Q,o as Z,$ as ee,k as _}from"../packem_shared/formatBytes-BHAzNIrn-Bkk_uRS-.js";import{y as te}from"../packem_shared/isAccessibleSync-DYKTrrvc-CSnBISfV.js";import{p as se}from"../packem_shared/readJsonSync-CbryXYxN-B2aSeDpC.js";import{h as re,U as oe}from"../packem_shared/writeFileSync-DJoHk3Ks-CgQ-VNNT.js";import{g as ne,r as ce}from"../packem_shared/packument-CHdDsn0O.js";import{q as ie,j as ae,F as v,b as S,X as E,J as A}from"../packem_shared/index.server-sXNQYpsl.js";import{a as le,o as fe}from"../packem_shared/pm-runner-d93_73O6.js";import{r as ue,a as pe}from"../packem_shared/command-runtime-CiLVo4ED.js";let V;const z=e=>(V??=F(import.meta.url))(e),$=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,M=e=>{if(typeof $<"u"&&$.versions&&$.versions.node){const[t,s]=$.versions.node.split(".").map(Number);if(t>22||t===22&&s>=3||t===20&&s>=16)return $.getBuiltinModule(e)}return z(e)},{renameSync:q}=M("node:fs"),{stripVTControlCharacters:G}=M("node:util"),de=(e={})=>{const t=e.isCi??W;return(e.isTty??!!(process.stdin.isTTY&&process.stdout.isTTY))&&!t},k=U(B(),"dlx-seen.json"),H=(e,t)=>`${e}@${t}`,me=e=>{if(typeof e!="object"||e===null)return!1;const t=e;return Array.isArray(t.alertKeys)&&t.alertKeys.every(s=>typeof s=="string")&&typeof t.seenAt=="number"},P=()=>{try{if(te(k)){const e=se(k);if(e&&typeof e=="object"&&e.packages&&typeof e.packages=="object"&&e.version===1){const t={};for(const[s,r]of Object.entries(e.packages))me(r)&&(t[s]=r);return{packages:t,version:1}}}}catch{}return{packages:{},version:1}},he=e=>{try{re(B());const t=`${k}.${String(process.pid)}.tmp`;oe(t,JSON.stringify(e)),q(t,k)}catch{}},ge=(e,t,s)=>e.packages[H(t,s)],ye=(e,t)=>{if(!e)return!0;const s=new Set(Array.isArray(e.alertKeys)?e.alertKeys:[]);return t.some(r=>!s.has(r))},R=(e,t,s,r)=>{const o=P();o.packages[H(e,t)]={alertKeys:[...s].sort(),seenAt:r},he(o)},ve=/[\u0000-\u0008\u000B-\u001F\u007F]/g,K=e=>G(e).replaceAll(" "," ").replaceAll(ve,""),x=["CHANGELOG.md","CHANGELOG","changelog.md","CHANGES.md","HISTORY.md"],be=4e3,C=async(e,t,s)=>{if(t?.aborted)return;const r=new AbortController,o=setTimeout(()=>{r.abort()},be),a=()=>{r.abort()};t?.addEventListener("abort",a,{once:!0});try{const n=await fetch(e,{headers:s,signal:r.signal});return n.ok?await n.text():void 0}catch{return}finally{clearTimeout(o),t?.removeEventListener("abort",a)}},$e=e=>{const t=typeof e=="string"?e:e?.url;if(!t)return;const s=/github\.com[/:]([^/]+)\/([^/#]+?)(?:\.git)?(?:[/#]|$)/i.exec(t)??/^github:([^/]+)\/([^/#]+)/i.exec(t);return s?{directory:typeof e=="object"?e?.directory:void 0,owner:s[1],repo:s[2].replace(/\.git$/,"")}:void 0},O=(e,t)=>{const s=e.split(/\r?\n/),r=/^(#{1,4})\s+(.*)$/,o=t.replaceAll(/[$()*+.?[\\\]^{|}]/g,String.raw`\$&`),a=new RegExp(String.raw`(?<![\w.])${o}(?![\w.])`);let n=-1,u=0;for(const[c,l]of s.entries()){const f=r.exec(l);if(f&&a.test(f[2])){n=c,u=f[1].length;break}}if(n===-1)return;const i=[];for(let c=n+1;c<s.length;c+=1){const l=r.exec(s[c]);if(l&&l[1].length<=u)break;i.push(s[c])}return i},I=(e,t=4)=>e.map(r=>r.trim()).filter(r=>r.length>0).map(r=>K(r.replace(/^#{1,6}\s+/,"").replace(/^[*-]\s+/,"- ")).trim()).filter(r=>r.length>0&&!/^\[.*\]:/.test(r)).slice(0,t),L=(e,t)=>{if(!e)return"";const s=Date.parse(e);if(Number.isNaN(s))return"";const r=Math.floor((t-s)/(1440*60*1e3));if(r<=0)return"today";if(r===1)return"1d ago";if(r<30)return`${String(r)}d ago`;const o=Math.floor(r/30);return o<12?`${String(o)}mo ago`:`${String(Math.floor(o/12))}y ago`},N=(e,t,s)=>{const r=e.time??{},o=L(r[t],s),a=[o?`${e.name}@${t} — published ${o}`:`${e.name}@${t}`],n=Date.parse(r[t]??""),i=Object.entries(r).filter(([c])=>c!=="created"&&c!=="modified"&&c!==t).sort((c,l)=>Date.parse(l[1])-Date.parse(c[1])).filter(([,c])=>Date.parse(c)<n).slice(0,3);for(const[c,l]of i)a.push(`- ${c} (${L(l,s)})`);return{lines:a,source:"npm-diff",version:t}},Se=async e=>{const{name:t,now:s,offline:r,packument:o,signal:a,version:n}=e;if(r)return o?N(o,n,s):void 0;for(const c of x){const l=`https://cdn.jsdelivr.net/npm/${t}@${n}/${c}`,f=await C(l,a);if(f){const y=O(f,n),p=I(y??f.split(/\r?\n/));if(p.length>0)return{lines:p,source:"package-file",url:l,version:n}}}const u=o?.versions[n],i=$e(u?.repository);if(i){const c=i.directory?`${i.directory.replaceAll(/^\/+|\/+$/g,"")}/`:"";for(const l of["HEAD","main","master"])for(const f of x){const y=`https://raw.githubusercontent.com/${i.owner}/${i.repo}/${l}/${c}${f}`,p=await C(y,a);if(p){const m=O(p,n),h=I(m??p.split(/\r?\n/));if(h.length>0){const d=`https://github.com/${i.owner}/${i.repo}/blob/${l}/${c}${f}`;return{lines:h,source:"repo-file",url:d,version:n}}}}}if(o)return N(o,n,s)},we={dynamicRequire:"dynamic require",envVars:"env access",filesystemAccess:"filesystem",networkAccess:"network",shellAccess:"shell",telemetry:"telemetry",unsafe:"eval/unsafe",usesEval:"eval/unsafe"},ke=["preinstall","install","postinstall"],Te=(e,t)=>({fileCount:e?.dist?.fileCount,tarballBytes:t?.size,unpackedBytes:e?.dist?.unpackedSize}),Ee=(e,t)=>{const s=ke.filter(n=>!!e?.scripts?.[n]),r=e?.bin,o=typeof r=="string"?["(default)"]:Object.keys(r??{}).map(n=>K(n)),a=[...new Set(t.map(n=>we[n.type]).filter(n=>n!==void 0))];return{bins:o,capabilities:a,lifecycleScripts:s}},_e=(e,t,s)=>{const r=e.get(`${t}@${s}`);if(r)return r;for(const o of e.values())if(o.name===t&&o.version===s)return o},Ae=async e=>{const{name:t,now:s,offline:r,signal:o,socketToken:a,spec:n,workspaceRoot:u}=e;let i;try{i=await ne(t,{offline:r,signal:o,workspaceRoot:u})}catch{i=void 0}const c=i?ce(i,n):void 0;if(!c)return;const l=i?.versions[c],f=async()=>{if(!(r||!a))try{const g=await J([{name:t,version:c}],{apiToken:a,minimumScore:Q});return _e(g,t,c)}catch{return}},y=Se({name:t,now:s,offline:r,packument:i,signal:o,version:c}).catch(()=>{}),[p,m]=await Promise.all([f(),y]),h=p?.alerts??[],d=[...new Set(h.filter(g=>g.severity==="critical"||g.severity==="high").map(g=>g.key))].sort(),b=p?Math.round((p.score.overall??X(p.score))*100):void 0;return{changelog:m,name:t,permissions:Ee(l,h),security:{alerts:h,available:!!p,highSeverityKeys:d,score:b},size:Te(l,p),version:c}},w=e=>Z(G(e)),Re={critical:E,high:E,low:v,medium:S},D=e=>{if(!(e===void 0||e<0))return ee(e,{decimals:1,space:!0})},xe=e=>{const{fileCount:t,tarballBytes:s,unpackedBytes:r}=e.size,o=D(r),a=D(s);if(o&&a){const n=t===void 0?"":`, ${String(t)} files`;return`${o} unpacked (${a} tarball${n})`}if(o)return`${o} unpacked`;if(a)return`${a} tarball`},Ce=e=>{const{alerts:t,available:s,score:r}=e.security;if(!s)return v("unavailable — set VIS_SOCKET_TOKEN for a Socket.dev score");const o=r===void 0?v:r>=70?A:r>=40?S:E,a=r===void 0?"n/a":`${String(r)}/100`,n=new Map;for(const l of t)n.set(l.severity,(n.get(l.severity)??0)+1);const u=[],i=["critical","high","medium","low"];for(const l of i){const f=n.get(l);f&&u.push(Re[l](`${String(f)} ${l}`))}const c=u.length>0?` ${S("!")} ${u.join(", ")}`:` ${A("no alerts")}`;return`${o(a)} ${v("(Socket.dev)")}${c}`},Oe=e=>{const{bins:t,capabilities:s,lifecycleScripts:r}=e.permissions,o=[];for(const a of r)o.push(S(`${a} script`));for(const a of s)o.push(S(a));return t.length>0&&o.push(v(`bins: ${t.join(", ")}`)),o.length>0?o.join(v(" · ")):void 0},Ie=e=>{const t=[],s=xe(e);s&&t.push({label:"size",values:[s]}),t.push({label:"score",values:[Ce(e)]});const r=Oe(e);if(r&&t.push({label:"perms",values:[r]}),e.changelog){const o=e.changelog.source==="npm-diff"?"registry":e.changelog.source==="repo-file"?"repo CHANGELOG":"CHANGELOG";t.push({label:"latest",values:[...e.changelog.lines,v(`source: ${o}`)]})}return t},j=6,Le=e=>{const t=Ie(e),s=` first run: ${e.name}@${e.version} `,r=[];for(const i of t)i.values.forEach((c,l)=>{const f=l===0?ie(i.label.padEnd(j)):" ".repeat(j);r.push(`${f} ${c}`)});const o=Math.max(w(s),...r.map(i=>w(i))),a=i=>`${i}${" ".repeat(Math.max(0,o-w(i)))}`,n=`┌─${ae(s)}${"─".repeat(Math.max(0,o-w(s)))}─┐`,u=`└─${"─".repeat(o)}─┘`;return[n,...r.map(i=>`│ ${a(i)} │`),u]},Ne=e=>{if(e.startsWith("@")){const s=e.indexOf("@",1);return s===-1?{name:e}:{name:e.slice(0,s),spec:e.slice(s+1)}}const t=e.indexOf("@");return t<=0?{name:e}:{name:e.slice(0,t),spec:e.slice(t+1)}},De=e=>e===""||e.startsWith(".")||e.startsWith("/")||e.startsWith("~")?!1:!(e.startsWith("@")?e.slice(1):e).includes(":"),je=6e3,Me=e=>{process.stdout.write(e)},Be=async e=>{const{forceInfo:t=!1,noInfo:s=!1,offline:r=!1,pkg:o,socketToken:a,workspaceRoot:n,yes:u=!1}=e;if(s||!De(o))return{proceed:!0};const i=e.now??Date.now(),c=u||!de({isCi:e.isCi,isTty:e.isTty}),l=e.output??Me;if(c&&!t)return{proceed:!0};const{name:f,spec:y}=Ne(o),p=new AbortController;let m;const h=new Promise(T=>{m=setTimeout(()=>{p.abort(),T(void 0)},je)}),d=await Promise.race([Ae({name:f,now:i,offline:r,signal:p.signal,socketToken:a,spec:y,workspaceRoot:n}).catch(()=>{}),h]);if(m&&clearTimeout(m),!d)return{proceed:!0};const b=ge(P(),d.name,d.version);if(!t&&!ye(b,d.security.highSeverityKeys))return{proceed:!0};for(const T of Le(d))l(`${T}
1
+ import{createRequire as F}from"node:module";import{i as W}from"../packem_shared/index-BjdW45xX.js";import{p as Y}from"../packem_shared/prompt-DMzaQEVa.js";import{e as U}from"../packem_shared/index-DHD8wb6Z.js";import{l as B,m as X,n as J,D as Q,o as Z,$ as ee,k as _}from"../packem_shared/formatBytes-BHAzNIrn-XohRrPdt.js";import{y as te}from"../packem_shared/isAccessibleSync-DYKTrrvc-CSnBISfV.js";import{p as se}from"../packem_shared/readJsonSync-CbryXYxN-B2aSeDpC.js";import{h as re,U as oe}from"../packem_shared/writeFileSync-DJoHk3Ks-CgQ-VNNT.js";import{g as ne,r as ce}from"../packem_shared/packument-DyuhH1Gz.js";import{q as ie,j as ae,F as v,b as S,X as E,J as A}from"../packem_shared/index.server-sXNQYpsl.js";import{a as le,o as fe}from"../packem_shared/pm-runner-d93_73O6.js";import{r as ue,a as pe}from"../packem_shared/command-runtime-CiLVo4ED.js";let V;const z=e=>(V??=F(import.meta.url))(e),$=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,M=e=>{if(typeof $<"u"&&$.versions&&$.versions.node){const[t,s]=$.versions.node.split(".").map(Number);if(t>22||t===22&&s>=3||t===20&&s>=16)return $.getBuiltinModule(e)}return z(e)},{renameSync:q}=M("node:fs"),{stripVTControlCharacters:G}=M("node:util"),de=(e={})=>{const t=e.isCi??W;return(e.isTty??!!(process.stdin.isTTY&&process.stdout.isTTY))&&!t},k=U(B(),"dlx-seen.json"),H=(e,t)=>`${e}@${t}`,me=e=>{if(typeof e!="object"||e===null)return!1;const t=e;return Array.isArray(t.alertKeys)&&t.alertKeys.every(s=>typeof s=="string")&&typeof t.seenAt=="number"},P=()=>{try{if(te(k)){const e=se(k);if(e&&typeof e=="object"&&e.packages&&typeof e.packages=="object"&&e.version===1){const t={};for(const[s,r]of Object.entries(e.packages))me(r)&&(t[s]=r);return{packages:t,version:1}}}}catch{}return{packages:{},version:1}},he=e=>{try{re(B());const t=`${k}.${String(process.pid)}.tmp`;oe(t,JSON.stringify(e)),q(t,k)}catch{}},ge=(e,t,s)=>e.packages[H(t,s)],ye=(e,t)=>{if(!e)return!0;const s=new Set(Array.isArray(e.alertKeys)?e.alertKeys:[]);return t.some(r=>!s.has(r))},R=(e,t,s,r)=>{const o=P();o.packages[H(e,t)]={alertKeys:[...s].sort(),seenAt:r},he(o)},ve=/[\u0000-\u0008\u000B-\u001F\u007F]/g,K=e=>G(e).replaceAll(" "," ").replaceAll(ve,""),x=["CHANGELOG.md","CHANGELOG","changelog.md","CHANGES.md","HISTORY.md"],be=4e3,C=async(e,t,s)=>{if(t?.aborted)return;const r=new AbortController,o=setTimeout(()=>{r.abort()},be),a=()=>{r.abort()};t?.addEventListener("abort",a,{once:!0});try{const n=await fetch(e,{headers:s,signal:r.signal});return n.ok?await n.text():void 0}catch{return}finally{clearTimeout(o),t?.removeEventListener("abort",a)}},$e=e=>{const t=typeof e=="string"?e:e?.url;if(!t)return;const s=/github\.com[/:]([^/]+)\/([^/#]+?)(?:\.git)?(?:[/#]|$)/i.exec(t)??/^github:([^/]+)\/([^/#]+)/i.exec(t);return s?{directory:typeof e=="object"?e?.directory:void 0,owner:s[1],repo:s[2].replace(/\.git$/,"")}:void 0},O=(e,t)=>{const s=e.split(/\r?\n/),r=/^(#{1,4})\s+(.*)$/,o=t.replaceAll(/[$()*+.?[\\\]^{|}]/g,String.raw`\$&`),a=new RegExp(String.raw`(?<![\w.])${o}(?![\w.])`);let n=-1,u=0;for(const[c,l]of s.entries()){const f=r.exec(l);if(f&&a.test(f[2])){n=c,u=f[1].length;break}}if(n===-1)return;const i=[];for(let c=n+1;c<s.length;c+=1){const l=r.exec(s[c]);if(l&&l[1].length<=u)break;i.push(s[c])}return i},I=(e,t=4)=>e.map(r=>r.trim()).filter(r=>r.length>0).map(r=>K(r.replace(/^#{1,6}\s+/,"").replace(/^[*-]\s+/,"- ")).trim()).filter(r=>r.length>0&&!/^\[.*\]:/.test(r)).slice(0,t),L=(e,t)=>{if(!e)return"";const s=Date.parse(e);if(Number.isNaN(s))return"";const r=Math.floor((t-s)/(1440*60*1e3));if(r<=0)return"today";if(r===1)return"1d ago";if(r<30)return`${String(r)}d ago`;const o=Math.floor(r/30);return o<12?`${String(o)}mo ago`:`${String(Math.floor(o/12))}y ago`},N=(e,t,s)=>{const r=e.time??{},o=L(r[t],s),a=[o?`${e.name}@${t} — published ${o}`:`${e.name}@${t}`],n=Date.parse(r[t]??""),i=Object.entries(r).filter(([c])=>c!=="created"&&c!=="modified"&&c!==t).sort((c,l)=>Date.parse(l[1])-Date.parse(c[1])).filter(([,c])=>Date.parse(c)<n).slice(0,3);for(const[c,l]of i)a.push(`- ${c} (${L(l,s)})`);return{lines:a,source:"npm-diff",version:t}},Se=async e=>{const{name:t,now:s,offline:r,packument:o,signal:a,version:n}=e;if(r)return o?N(o,n,s):void 0;for(const c of x){const l=`https://cdn.jsdelivr.net/npm/${t}@${n}/${c}`,f=await C(l,a);if(f){const y=O(f,n),p=I(y??f.split(/\r?\n/));if(p.length>0)return{lines:p,source:"package-file",url:l,version:n}}}const u=o?.versions[n],i=$e(u?.repository);if(i){const c=i.directory?`${i.directory.replaceAll(/^\/+|\/+$/g,"")}/`:"";for(const l of["HEAD","main","master"])for(const f of x){const y=`https://raw.githubusercontent.com/${i.owner}/${i.repo}/${l}/${c}${f}`,p=await C(y,a);if(p){const m=O(p,n),h=I(m??p.split(/\r?\n/));if(h.length>0){const d=`https://github.com/${i.owner}/${i.repo}/blob/${l}/${c}${f}`;return{lines:h,source:"repo-file",url:d,version:n}}}}}if(o)return N(o,n,s)},we={dynamicRequire:"dynamic require",envVars:"env access",filesystemAccess:"filesystem",networkAccess:"network",shellAccess:"shell",telemetry:"telemetry",unsafe:"eval/unsafe",usesEval:"eval/unsafe"},ke=["preinstall","install","postinstall"],Te=(e,t)=>({fileCount:e?.dist?.fileCount,tarballBytes:t?.size,unpackedBytes:e?.dist?.unpackedSize}),Ee=(e,t)=>{const s=ke.filter(n=>!!e?.scripts?.[n]),r=e?.bin,o=typeof r=="string"?["(default)"]:Object.keys(r??{}).map(n=>K(n)),a=[...new Set(t.map(n=>we[n.type]).filter(n=>n!==void 0))];return{bins:o,capabilities:a,lifecycleScripts:s}},_e=(e,t,s)=>{const r=e.get(`${t}@${s}`);if(r)return r;for(const o of e.values())if(o.name===t&&o.version===s)return o},Ae=async e=>{const{name:t,now:s,offline:r,signal:o,socketToken:a,spec:n,workspaceRoot:u}=e;let i;try{i=await ne(t,{offline:r,signal:o,workspaceRoot:u})}catch{i=void 0}const c=i?ce(i,n):void 0;if(!c)return;const l=i?.versions[c],f=async()=>{if(!(r||!a))try{const g=await J([{name:t,version:c}],{apiToken:a,minimumScore:Q});return _e(g,t,c)}catch{return}},y=Se({name:t,now:s,offline:r,packument:i,signal:o,version:c}).catch(()=>{}),[p,m]=await Promise.all([f(),y]),h=p?.alerts??[],d=[...new Set(h.filter(g=>g.severity==="critical"||g.severity==="high").map(g=>g.key))].sort(),b=p?Math.round((p.score.overall??X(p.score))*100):void 0;return{changelog:m,name:t,permissions:Ee(l,h),security:{alerts:h,available:!!p,highSeverityKeys:d,score:b},size:Te(l,p),version:c}},w=e=>Z(G(e)),Re={critical:E,high:E,low:v,medium:S},D=e=>{if(!(e===void 0||e<0))return ee(e,{decimals:1,space:!0})},xe=e=>{const{fileCount:t,tarballBytes:s,unpackedBytes:r}=e.size,o=D(r),a=D(s);if(o&&a){const n=t===void 0?"":`, ${String(t)} files`;return`${o} unpacked (${a} tarball${n})`}if(o)return`${o} unpacked`;if(a)return`${a} tarball`},Ce=e=>{const{alerts:t,available:s,score:r}=e.security;if(!s)return v("unavailable — set VIS_SOCKET_TOKEN for a Socket.dev score");const o=r===void 0?v:r>=70?A:r>=40?S:E,a=r===void 0?"n/a":`${String(r)}/100`,n=new Map;for(const l of t)n.set(l.severity,(n.get(l.severity)??0)+1);const u=[],i=["critical","high","medium","low"];for(const l of i){const f=n.get(l);f&&u.push(Re[l](`${String(f)} ${l}`))}const c=u.length>0?` ${S("!")} ${u.join(", ")}`:` ${A("no alerts")}`;return`${o(a)} ${v("(Socket.dev)")}${c}`},Oe=e=>{const{bins:t,capabilities:s,lifecycleScripts:r}=e.permissions,o=[];for(const a of r)o.push(S(`${a} script`));for(const a of s)o.push(S(a));return t.length>0&&o.push(v(`bins: ${t.join(", ")}`)),o.length>0?o.join(v(" · ")):void 0},Ie=e=>{const t=[],s=xe(e);s&&t.push({label:"size",values:[s]}),t.push({label:"score",values:[Ce(e)]});const r=Oe(e);if(r&&t.push({label:"perms",values:[r]}),e.changelog){const o=e.changelog.source==="npm-diff"?"registry":e.changelog.source==="repo-file"?"repo CHANGELOG":"CHANGELOG";t.push({label:"latest",values:[...e.changelog.lines,v(`source: ${o}`)]})}return t},j=6,Le=e=>{const t=Ie(e),s=` first run: ${e.name}@${e.version} `,r=[];for(const i of t)i.values.forEach((c,l)=>{const f=l===0?ie(i.label.padEnd(j)):" ".repeat(j);r.push(`${f} ${c}`)});const o=Math.max(w(s),...r.map(i=>w(i))),a=i=>`${i}${" ".repeat(Math.max(0,o-w(i)))}`,n=`┌─${ae(s)}${"─".repeat(Math.max(0,o-w(s)))}─┐`,u=`└─${"─".repeat(o)}─┘`;return[n,...r.map(i=>`│ ${a(i)} │`),u]},Ne=e=>{if(e.startsWith("@")){const s=e.indexOf("@",1);return s===-1?{name:e}:{name:e.slice(0,s),spec:e.slice(s+1)}}const t=e.indexOf("@");return t<=0?{name:e}:{name:e.slice(0,t),spec:e.slice(t+1)}},De=e=>e===""||e.startsWith(".")||e.startsWith("/")||e.startsWith("~")?!1:!(e.startsWith("@")?e.slice(1):e).includes(":"),je=6e3,Me=e=>{process.stdout.write(e)},Be=async e=>{const{forceInfo:t=!1,noInfo:s=!1,offline:r=!1,pkg:o,socketToken:a,workspaceRoot:n,yes:u=!1}=e;if(s||!De(o))return{proceed:!0};const i=e.now??Date.now(),c=u||!de({isCi:e.isCi,isTty:e.isTty}),l=e.output??Me;if(c&&!t)return{proceed:!0};const{name:f,spec:y}=Ne(o),p=new AbortController;let m;const h=new Promise(T=>{m=setTimeout(()=>{p.abort(),T(void 0)},je)}),d=await Promise.race([Ae({name:f,now:i,offline:r,signal:p.signal,socketToken:a,spec:y,workspaceRoot:n}).catch(()=>{}),h]);if(m&&clearTimeout(m),!d)return{proceed:!0};const b=ge(P(),d.name,d.version);if(!t&&!ye(b,d.security.highSeverityKeys))return{proceed:!0};for(const T of Le(d))l(`${T}
2
2
  `);if(c)return R(d.name,d.version,d.security.highSeverityKeys,i),{proceed:!0};const g=await Y("? Ok to proceed? (y/N) ",e.readline);return g&&R(d.name,d.version,d.security.highSeverityKeys,i),{proceed:g}},Je=async({argument:e,logger:t,options:s,process:r,visConfig:o,workspaceRoot:a})=>{const n=e;if(!n||n.length===0)throw new Error("No package specified. Usage: vis dlx <package[@version]> [args...]");const[u,...i]=n,c=a??r.cwd,l=s.package?Array.isArray(s.package)?s.package:[s.package]:[],f=s.shellMode?l:[u,...l];for(const h of f){const d=!s.info||_(r.env.VIS_DLX_NO_INFO),b=!d&&s.info;if(!(await Be({forceInfo:b,noInfo:d,offline:s.offline||!1,pkg:h,socketToken:o?.security?.socket?.apiToken??r.env.VIS_SOCKET_TOKEN,workspaceRoot:c,yes:s.yes||_(r.env.VIS_DLX_YES)})).proceed){t.info("Aborted."),process.exitCode=1;return}}const y=ue({logger:t,options:s,visConfig:o},c),p=le(c,{backend:pe(y),configBackend:o?.install?.backend,configCorepack:o?.install?.corepack}),m=fe(p,{additionalPackages:l,args:i,package:u,shellMode:s.shellMode||!1,silent:s.silent||!1},c,t,{offline:s.offline||!1});m!==0&&(process.exitCode=m)};export{Je as default};
@@ -1,9 +1,9 @@
1
- import{createRequire as be}from"node:module";import{F as $,b as L,X as ce,J,q as ae}from"../packem_shared/index.server-sXNQYpsl.js";import{v as T,a as G,U as I,z as Se,e as M}from"../packem_shared/index-DHD8wb6Z.js";import{fingerprint as E,scan as le,scanFiles as Ee,inspectRuleset as Ie,listRules as K,listRequiredValidators as Te,scanGitHistory as Re}from"@visulima/secret-scanner";import{a4 as Ae,a5 as Q,p as y}from"./cli-main.js";import{I as je,W as Ne}from"../packem_shared/getRandomSpinner-4ZEcbTYv-DCyIuj19.js";import{U as Fe}from"../packem_shared/writeFileSync-DJoHk3Ks-CgQ-VNNT.js";import{y as X}from"../packem_shared/isAccessibleSync-DYKTrrvc-CSnBISfV.js";import{p as Me}from"../packem_shared/readJsonSync-CbryXYxN-B2aSeDpC.js";let ve;const ke=e=>(ve??=be(import.meta.url))(e),j=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,W=e=>{if(typeof j<"u"&&j.versions&&j.versions.node){const[t,n]=j.versions.node.split(".").map(Number);if(t>22||t===22&&n>=3||t===20&&n>=16)return j.getBuiltinModule(e)}return ke(e)},{createRequire:Ce}=W("node:module"),{pathToFileURL:ue}=W("node:url"),{execFileSync:Le}=W("node:child_process");let Oe;const _e=e=>(Oe??=Ce(import.meta.url))(e),N=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,Be=e=>{if(typeof N<"u"&&N.versions&&N.versions.node){const[t,n]=N.versions.node.split(".").map(Number);if(t>22||t===22&&n>=3||t===20&&n>=16)return N.getBuiltinModule(e)}return _e(e)},{styleText:qe}=Be("node:util"),Ue={error:"✖",info:"ℹ",success:"✓",warning:"⚠"},De=()=>{const{env:e}=process;return!!e.CI||e.CONTINUOUS_INTEGRATION==="true"||"BUILD_NUMBER"in e||"RUN_ID"in e},Pe=/\u001B\[[\d;]*[a-z]/gi,He=e=>[...e.replaceAll(Pe,"")].length,ze=e=>{const t=[];return e.bold&&t.push("bold"),e.dim&&t.push("dim"),e.italic&&t.push("italic"),e.underline&&t.push("underline"),e.strikethrough&&t.push("strikethrough"),e.color&&t.push(e.color),e.bgColor&&t.push(e.bgColor),t.length===0?n=>n:n=>qe(t,n)};let Ve=class{#i=0;#l;#e=!1;#r="";#o="";#m=0;#u=0;#t;#n;#f="";#c;#p;#s;#x;#d=0;#a;#b;constructor(t={},n){if(t.frames)this.#c=t.frames;else{const s=t.name??"dots",r=Ne(s);if(!r)throw new Error(`Unknown spinner "${s}". Pass a custom \`frames\` set or use one of: ${je().join(", ")}.`);this.#c=r}this.#p=t.verbose!==!1,this.#r=t.prefixText??"",this.#t=n,this.#s=t.stream??process.stderr,this.#x=n?!0:this.#s.isTTY&&!De(),this.#b={...Ue,...t.icons},typeof t.style=="function"?this.#a=t.style:t.style&&(this.#a=ze(t.style))}get elapsedTime(){return this.#m===0?0:(this.#u||Date.now())-this.#m}get text(){return this.#o}set text(t){this.#o=t,this.#e&&this.#w()}get prefixText(){return this.#r}set prefixText(t){this.#r=t,this.#e&&this.#w()}get isRunning(){return this.#e}setInteractiveManager(t){this.#t=t}setMultiSpinner(t){this.#n=t}tick(){this.#e&&(this.#i=(this.#i+1)%this.#c.frames.length)}start(t,n){return this.#e?this:this.#p?(this.#e=!0,this.#m=Date.now(),this.#u=0,this.#i=0,this.#f="",t&&(this.#o=t),n?.prefixText&&(this.#r=n.prefixText),this.#n?(this.#n.renderAll(),this):(this.#t?(this.#t.hook(),this.#v(),this.#y()):(this.#k(),this.#y()),this)):this}stop(){if(this.#e){if(this.#h(),this.#e=!1,this.#u=Date.now(),this.#f="",this.#n){this.#n.renderAll();return}this.#t?(this.#t.erase("stdout"),this.#t.unhook(!1)):this.#$()}}stopAndPersist(t){if(!this.#e||(this.#h(),this.#e=!1,this.#u=Date.now(),!this.#p))return;const n=t?.prefixText??this.#r,s=t?.text??this.#o;let r=t?.symbol??"";n&&(r=r?`${n} ${r}`:n),s&&(r=r?`${r} ${s}`:s),this.#S(r)}succeed(t){this.#g("success",t)}failed(t){this.#g("error",t)}warn(t){this.#g("warning",t)}info(t){this.#g("info",t)}pause(){this.#h()}resume(){this.#e&&(this.#h(),this.#n||this.#y())}getFrameOutput(){if(!this.#e&&this.#f)return this.#f;const t=this.#c.frames[this.#i];let n=this.#a?this.#a(t):t;return this.#r&&(n=`${this.#r} ${n}`),this.#o&&(n=`${n} ${this.#o}`),n}#y(){this.#x&&(this.#l=setInterval(()=>{this.#e&&(this.#i=(this.#i+1)%this.#c.frames.length,this.#w())},this.#c.interval),this.#l.unref())}#h(){this.#l&&(clearInterval(this.#l),this.#l=void 0)}#w(){this.#n?this.#n.renderAll():this.#t?this.#v():this.#k()}#v(){this.#t&&this.#t.update("stdout",[this.getFrameOutput()])}#k(){const t=this.getFrameOutput();if(this.#$(),this.#s.isTTY){this.#s.write(t);const n=this.#s.columns||80;this.#d=Math.max(1,Math.ceil(He(t)/n))}else this.#s.write(`${t}
1
+ import{createRequire as be}from"node:module";import{F as $,b as L,X as ce,J,q as ae}from"../packem_shared/index.server-sXNQYpsl.js";import{v as T,a as G,U as I,z as Se,e as M}from"../packem_shared/index-DHD8wb6Z.js";import{fingerprint as E,scan as le,scanFiles as Ee,inspectRuleset as Ie,listRules as K,listRequiredValidators as Te,scanGitHistory as Re}from"@visulima/secret-scanner";import{a4 as Ae,a5 as Q,p as w}from"./cli-main.js";import{I as je,W as Ne}from"../packem_shared/getRandomSpinner-4ZEcbTYv-DCyIuj19.js";import{U as Fe}from"../packem_shared/writeFileSync-DJoHk3Ks-CgQ-VNNT.js";import{y as X}from"../packem_shared/isAccessibleSync-DYKTrrvc-CSnBISfV.js";import{p as Me}from"../packem_shared/readJsonSync-CbryXYxN-B2aSeDpC.js";let ve;const ke=e=>(ve??=be(import.meta.url))(e),j=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,W=e=>{if(typeof j<"u"&&j.versions&&j.versions.node){const[t,n]=j.versions.node.split(".").map(Number);if(t>22||t===22&&n>=3||t===20&&n>=16)return j.getBuiltinModule(e)}return ke(e)},{createRequire:Ce}=W("node:module"),{pathToFileURL:ue}=W("node:url"),{execFileSync:Le}=W("node:child_process");let Oe;const _e=e=>(Oe??=Ce(import.meta.url))(e),N=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,Be=e=>{if(typeof N<"u"&&N.versions&&N.versions.node){const[t,n]=N.versions.node.split(".").map(Number);if(t>22||t===22&&n>=3||t===20&&n>=16)return N.getBuiltinModule(e)}return _e(e)},{styleText:qe}=Be("node:util"),Ue={error:"✖",info:"ℹ",success:"✓",warning:"⚠"},De=()=>{const{env:e}=process;return!!e.CI||e.CONTINUOUS_INTEGRATION==="true"||"BUILD_NUMBER"in e||"RUN_ID"in e},Pe=/\u001B\[[\d;]*[a-z]/gi,He=e=>[...e.replaceAll(Pe,"")].length,ze=e=>{const t=[];return e.bold&&t.push("bold"),e.dim&&t.push("dim"),e.italic&&t.push("italic"),e.underline&&t.push("underline"),e.strikethrough&&t.push("strikethrough"),e.color&&t.push(e.color),e.bgColor&&t.push(e.bgColor),t.length===0?n=>n:n=>qe(t,n)};let Ve=class{#i=0;#l;#e=!1;#r="";#o="";#m=0;#u=0;#t;#n;#f="";#c;#p;#s;#x;#d=0;#a;#b;constructor(t={},n){if(t.frames)this.#c=t.frames;else{const s=t.name??"dots",r=Ne(s);if(!r)throw new Error(`Unknown spinner "${s}". Pass a custom \`frames\` set or use one of: ${je().join(", ")}.`);this.#c=r}this.#p=t.verbose!==!1,this.#r=t.prefixText??"",this.#t=n,this.#s=t.stream??process.stderr,this.#x=n?!0:this.#s.isTTY&&!De(),this.#b={...Ue,...t.icons},typeof t.style=="function"?this.#a=t.style:t.style&&(this.#a=ze(t.style))}get elapsedTime(){return this.#m===0?0:(this.#u||Date.now())-this.#m}get text(){return this.#o}set text(t){this.#o=t,this.#e&&this.#y()}get prefixText(){return this.#r}set prefixText(t){this.#r=t,this.#e&&this.#y()}get isRunning(){return this.#e}setInteractiveManager(t){this.#t=t}setMultiSpinner(t){this.#n=t}tick(){this.#e&&(this.#i=(this.#i+1)%this.#c.frames.length)}start(t,n){return this.#e?this:this.#p?(this.#e=!0,this.#m=Date.now(),this.#u=0,this.#i=0,this.#f="",t&&(this.#o=t),n?.prefixText&&(this.#r=n.prefixText),this.#n?(this.#n.renderAll(),this):(this.#t?(this.#t.hook(),this.#v(),this.#w()):(this.#k(),this.#w()),this)):this}stop(){if(this.#e){if(this.#h(),this.#e=!1,this.#u=Date.now(),this.#f="",this.#n){this.#n.renderAll();return}this.#t?(this.#t.erase("stdout"),this.#t.unhook(!1)):this.#$()}}stopAndPersist(t){if(!this.#e||(this.#h(),this.#e=!1,this.#u=Date.now(),!this.#p))return;const n=t?.prefixText??this.#r,s=t?.text??this.#o;let r=t?.symbol??"";n&&(r=r?`${n} ${r}`:n),s&&(r=r?`${r} ${s}`:s),this.#S(r)}succeed(t){this.#g("success",t)}failed(t){this.#g("error",t)}warn(t){this.#g("warning",t)}info(t){this.#g("info",t)}pause(){this.#h()}resume(){this.#e&&(this.#h(),this.#n||this.#w())}getFrameOutput(){if(!this.#e&&this.#f)return this.#f;const t=this.#c.frames[this.#i];let n=this.#a?this.#a(t):t;return this.#r&&(n=`${this.#r} ${n}`),this.#o&&(n=`${n} ${this.#o}`),n}#w(){this.#x&&(this.#l=setInterval(()=>{this.#e&&(this.#i=(this.#i+1)%this.#c.frames.length,this.#y())},this.#c.interval),this.#l.unref())}#h(){this.#l&&(clearInterval(this.#l),this.#l=void 0)}#y(){this.#n?this.#n.renderAll():this.#t?this.#v():this.#k()}#v(){this.#t&&this.#t.update("stdout",[this.getFrameOutput()])}#k(){const t=this.getFrameOutput();if(this.#$(),this.#s.isTTY){this.#s.write(t);const n=this.#s.columns||80;this.#d=Math.max(1,Math.ceil(He(t)/n))}else this.#s.write(`${t}
2
2
  `),this.#d=0}#$(){if(this.#d>0&&this.#s.isTTY){for(let t=1;t<this.#d;t+=1)this.#s.write("\x1B[1A\x1B[2K");this.#s.write("\r\x1B[K")}this.#d=0}#S(t){this.#f=t,this.#n?this.#n.renderAll():this.#t?(this.#t.update("stdout",[t]),this.#t.unhook(!1)):(this.#$(),this.#s.write(`${t}
3
- `))}#g(t,n){if(!this.#e||(this.#h(),this.#e=!1,this.#u=Date.now(),!this.#p))return;let s="";const r=this.#b[t];r&&(s=this.#a?this.#a(r):r),this.#r&&(s=`${this.#r} ${s}`),n&&(s=`${s} ${n}`),this.#S(s)}};const We=(e,t,n)=>{const s=n.toLowerCase();e[s]??=new Map;const r=e[s].get(t);if(r!==void 0)return r;const{size:i}=e[s],c=`<${n.toUpperCase()}${i>0?String(i):""}>`;return e[s].set(t,c),c},Z=(e,t)=>{const{replacement:n,tag:s,text:r}=t;return typeof n=="function"?String(n(r,void 0)):typeof n=="string"?n:We(e,r,s)},Je=(e,t)=>{const n={};let s="",r=0;for(const i of e){const{start:c,text:o}=i;if(o==="")continue;if(Number.isInteger(c)&&c>=0&&t.slice(c,c+o.length)===o){if(c<r)continue;s+=t.slice(r,c)+Z(n,i),r=c+o.length;continue}let a=t.indexOf(o,r);if(a===-1)continue;const l=Z(n,i);for(;a!==-1;)s+=t.slice(r,a)+l,r=a+o.length,a=t.indexOf(o,r)}return s+t.slice(r)},Ge=e=>[...e.reduce((t,n)=>t.set(n.text+String(n.start)+n.tag,n),new Map).values()].toSorted((t,n)=>{const s=t.start-n.start;return s!==0?s:n.text.length-t.text.length}),Ke=(e,t)=>{const n=[];for(const s of e){const{key:r,pattern:i}=s,c=s.compiledPattern??new RegExp(i,"giu");c.lastIndex=0;let o;for(;(o=c.exec(t))!==null;){const a=s;n.push({replacement:a.userReplacement??a.replacement!==void 0?a.replacement:void 0,start:o.index,tag:r,text:o[0]}),o.index===c.lastIndex&&(c.lastIndex+=1)}}return n},Xe=(e,t,n,s)=>Ge([...Ke(n,e)]),fe=(e,t,n)=>{const s=[],r=[];for(const o of t)typeof o=="object"&&o.pattern&&s.push(o),r.push((typeof o=="object"?o.key:String(o)).toLowerCase());let i=e;const c=Xe(e,r,s);return i=Je(c,i),i},k=e=>{const t=typeof e;return e!==null&&(t==="object"||t==="function")},q=new Set(["__proto__","prototype","constructor"]),Ye=Math.max(...[...q].map(e=>e.length)),de=1e6,Qe=e=>e>="0"&&e<="9";function he(e){if(e==="0")return!0;if(/^[1-9]\d*$/.test(e)){const t=Number.parseInt(e,10);return t<=Number.MAX_SAFE_INTEGER&&t<=de}return!1}function D(e,t){return q.has(e)?!1:(e&&he(e)?t.push(Number.parseInt(e,10)):t.push(e),!0)}function Ze(e){if(typeof e!="string")throw new TypeError(`Expected a string, got ${typeof e}`);const t=[];let n="",s="",r=!1,i="start",c=!1,o=0;for(const a of e){if(o++,c){n+=a,c=!1;continue}if(a==="\\"){if(i==="index")throw new Error(`Invalid character '${a}' in an index at position ${o}`);if(i==="indexEnd")throw new Error(`Invalid character '${a}' after an index at position ${o}`);c=!0,i=i==="start"?"property":i;continue}switch(a){case".":{if(i==="index")throw new Error(`Invalid character '${a}' in an index at position ${o}`);if(i==="indexEnd"){i="property";break}if(!D(n,t))return[];n="",i="property";break}case"[":{if(i==="index")throw new Error(`Invalid character '${a}' in an index at position ${o}`);if(i==="indexEnd"){i="index";break}if(i==="property"&&n.length<=Ye&&q.has(n))return[];r=i==="property",i="index";break}case"]":{if(i==="indexEnd")throw new Error(`Invalid character '${a}' after an index at position ${o}`);if(i!=="index"){i==="start"&&(i="property"),n+=a;break}if(s===""){n+="[]",i="property";break}if((n!==""||r)&&!D(n,t))return[];n="",r=!1;const l=Number.parseInt(s,10),f=l<=de&&s===String(l);t.push(f?l:s),s="",i="indexEnd";break}default:{if(i==="index"){if(!Qe(a))throw new Error(`Invalid character '${a}' in an index at position ${o}`);s+=a;break}if(i==="indexEnd")throw new Error(`Invalid character '${a}' after an index at position ${o}`);i==="start"&&(i="property"),n+=a}}}switch(c&&(n+="\\"),i){case"property":{if(!D(n,t))return[];break}case"index":throw new Error("Index was not closed");case"start":{t.push("");break}}return t}function U(e){if(typeof e=="string")return Ze(e);if(Array.isArray(e)){const t=[];for(const[n,s]of e.entries()){if(typeof s!="string"&&typeof s!="number")throw new TypeError(`Expected a string or number for path segment at index ${n}, got ${typeof s}`);if(typeof s=="number"&&!Number.isFinite(s))throw new TypeError(`Path segment at index ${n} must be a finite number, got ${s}`);if(q.has(s))return[];typeof s=="string"&&he(s)?t.push(Number.parseInt(s,10)):t.push(s)}return t}return[]}function et(e,t,n){if(!k(e)||typeof t!="string"&&!Array.isArray(t))return e;const s=U(t);if(s.length===0)return n;for(let r=0;r<s.length;r++){const i=s[r];if(e=e[i],e==null){if(r!==s.length-1)return n;break}}return e===void 0?n:e}function tt(e,t,n){if(!k(e)||typeof t!="string"&&!Array.isArray(t))return e;const s=e,r=U(t);if(r.length===0)return e;for(let i=0;i<r.length;i++){const c=r[i];if(i===r.length-1){e[c]=n;continue}const o=e[c];if(k(o)){e=o;continue}const a=typeof r[i+1]=="number";e[c]=a?[]:{},e=e[c]}return s}function nt(e,t){if(!k(e)||typeof t!="string"&&!Array.isArray(t))return!1;const n=U(t);if(n.length===0)return!1;for(let s=0;s<n.length;s++){const r=n[s];if(s===n.length-1)return Object.hasOwn(e,r)?(delete e[r],!0):!1;const i=e[r];if(!k(i))return!1;e=i}}function ee(e,t){if(!k(e)||typeof t!="string"&&!Array.isArray(t))return!1;const n=U(t);if(n.length===0)return!1;for(const s of n){if(!k(e)||!(s in e))return!1;e=e[s]}return!0}const P="#;/?:@&",H=new RegExp(String.raw`([${P}][^${P}=\s]+=[^${P}=\s]*)`,"g"),st=e=>{const t=[];let n=0;H.lastIndex=0;let s=H.exec(e);for(;s!==null;){const{0:i,index:c}=s;t.push({key:void 0,value:e.slice(n,c+1)}),n=c+i.length,t.push({key:i.slice(1,i.indexOf("=")),value:i.slice(i.indexOf("=")+1)}),s=H.exec(e)}const r=e.slice(n);return r.length>0&&t.push({key:void 0,value:r}),t},te=(e,t)=>{for(let n=0;n<e.length;n+=1){let s=e[n].string,r=e[n].index;for(;r<t.length;){const i=t[r];if(!s.includes(i))break;const c=s.slice(1);for(e.push({index:r,string:c}),c.includes(i)||e.pop(),s=s.slice(s.indexOf(i)+i.length),r+=1;t[r]==="";)r+=1;if(r>=t.length){if(t.at(-1)!==""&&s.length>0)break;return!0}}}return!1},z=(e,t)=>{if(!t.includes("*"))return t===e;const n=t.split("*");let s=0,r=e;for(;n[s]==="";)if(s+=1,s===t.length)return!0;if(s===0&&!e.startsWith(n[0]))return!1;const i=[];for(;s<n.length;){const c=n[s];if(!r.includes(c))return te(i,n);const o=r.slice(1);for(i.push({index:s,string:o}),o.includes(c)||i.pop(),r=r.slice(r.indexOf(c)+c.length),s+=1;n[s]==="";)s+=1}return s>=n.length&&n.at(-1)!==""&&r.length>0?r===e?!1:te(i,n):!0},rt=/(?:http|https):\/\/?/,R=(e,t,n)=>typeof e.replacement=="function"?e.replacement(t,n):e.replacement,pe=(e,t,n)=>e.wildcard?z(t,e.key)||z(n,e.key):t===e.key||n===e.key,it=(e,t,n,s)=>{n.remove?delete e[t]:e[t]=R(n,e[t],s)},ne=(e,t,n,s,r,i)=>{const c=[],o=[];for(const l of s)!l.wildcard&&!l.deep&&ee(e,l.key)?o.push(l):c.push(l);const a=Object.keys(e);for(const l of a){if(!Object.hasOwn(e,l))continue;const f=l.toLowerCase(),u=i?`${i}.${f}`:f;let h;for(const g of c)pe(g,f,u)&&(h=g);h?it(e,l,h,u):e[l]=x(e[l],t,n,c,r,u)}for(const l of o)if(ee(e,l.key))if(l.remove)nt(e,l.key);else{const f=i?`${i}.${l.key}`:l.key;tt(e,l.key,R(l,et(e,l.key),f))}},se=(e,t)=>{const n=t.toLowerCase();return e.find(s=>s.key===n||!!s.wildcard&&z(n,s.key))},ot=(e,t,n)=>{const s=st(e),r=[];for(const i of s){const{key:c,value:o}=i;if(c===void 0){const a=se(t,o);r.push(a?String(R(a,o,void 0)):fe(o,t))}else{const a=se(t,c);a?r.push(`${c}=${String(R(a,o,void 0))}`):r.push(`${c}=${o}`)}}return r.join("")},x=(e,t,n,s,r,i)=>{if(e==null)return e;if(typeof e=="object"&&e.constructor===String)return x(String(e),t,n,s,r,i);if(typeof e=="object"&&t.has(e))return t.get(e);if(typeof e=="object"&&!Array.isArray(e)){if(e instanceof Error){const o=new Error(e.message);Object.defineProperties(o,{name:{configurable:!0,enumerable:!1,value:e.name,writable:!0},stack:{configurable:!0,enumerable:!1,value:e.stack,writable:!0}}),e.code!==void 0&&(o.code=e.code);const a=Object.keys(e);for(const l of a)o[l]=e[l];return n(e,o),ne(o,t,n,s,r,i),o}if(e instanceof Map){const o=new Map;n(e,o);const a=e.entries();let l=a.next();for(;!l.done;){const[f,u]=l.value;if(typeof f=="string"||typeof f=="object"&&f!==null&&f.constructor===String){const h=f.toLowerCase(),g=i?`${i}.${h}`:h;let p;for(const m of s)pe(m,h,g)&&(p=m);p?p.remove||o.set(f,R(p,u,g)):o.set(f,x(u,t,n,s,r,g))}else o.set(x(f,t,n,s,r),x(u,t,n,s,r));l=a.next()}return o}if(e instanceof Set){const o=new Set;n(e,o);const a=e.values();let l=a.next();for(;!l.done;)o.add(x(l.value,t,n,s,r,i)),l=a.next();return o}const c={...e};return n(e,c),ne(c,t,n,s,r,i),c}if(typeof e=="string"){const c=e;try{const o=JSON.parse(c);if(typeof o=="object"&&o!==null){const a=x(o,t,n,s,r,i);return JSON.stringify(a)}}catch{}return rt.test(c)?ot(c,s):fe(c,s)}if(Array.isArray(e)){const c=[];n(e,c);for(const[o,a]of e.entries()){const l=o.toString().toLowerCase(),f=i?`${i}.${l}`.toLowerCase():l,u=s.find(h=>h.key===l||h.key===f);u?c.push(R(u,a,f)):c.push(x(a,t,n,s,r,f))}return c}return e},ct=(e,t)=>{const n=[];for(const s of e)if(typeof s=="string"){const r=s.includes("*");n.push({deep:!1,key:s.toLowerCase(),replacement:`<${s.toUpperCase()}>`,userReplacement:!1,wildcard:r})}else if(typeof s=="number")n.push({deep:!1,key:s.toString(),replacement:"<REDACTED>"});else{const r=s.key.toLowerCase(),i={...s,key:r,replacement:s.replacement??`<${r.toUpperCase()}>`,userReplacement:s.replacement!==void 0,wildcard:r.includes("*")?!0:s.wildcard};if(i.pattern!==void 0){const c=i.pattern instanceof RegExp?i.pattern.source:i.pattern;i.compiledPattern=new RegExp(c,"giu")}n.push(i)}return n},at=(e,t,n)=>{if(e==null||typeof e=="number"||typeof e=="boolean")return e;const s=new WeakMap;return x(e,s,(r,i)=>{s.set(r,i)},t,n)},ge=(e,t,n)=>{const s=ct(t);return at(e,s,n)},Y=(e={})=>{const t=new Ae(new Q(process.stdout),new Q(process.stderr));return new Ve(e,t)},lt=(e,t)=>{if(!T(e))return e;const n=G(t,e);return n===""||n.startsWith("..")?e:n},A=(e,t)=>{const n=lt(e.file,t);return n===e.file?e:{...e,file:n}},me=e=>{if(!X(e))return[];try{const t=Me(e);return Array.isArray(t)?t:[]}catch{return[]}},ut=(e,t,n)=>{const s=me(t).map(o=>A(o,n)),r=new Set(s.map(o=>E(o))),i=e.map(o=>A(o,n)),c=new Set(i.map(o=>E(o)));return{fresh:i.filter(o=>!r.has(E(o))),resolved:s.filter(o=>!c.has(E(o))),surviving:i.filter(o=>r.has(E(o)))}},ye=(e,t,n,s={})=>{const r=e.map(c=>A(c,n));let i;if(s.replace)i=r;else{const c=me(t).map(a=>A(a,n)),o=new Set;i=[];for(const a of[...c,...r]){const l=E(a);o.has(l)||(o.add(l),i.push(a))}}return Fe(t,`${JSON.stringify(i,null,4)}
4
- `),i.length},re=1,ft=e=>{const t=new Map;for(const n of e){const s=t.get(n.file);s?s.push(n):t.set(n.file,[n])}return t},dt=e=>{try{return Se(e).split(/\r?\n/)}catch{return}},ht=(e,t,n)=>{const s=Math.max(1,t);return`${e.slice(0,s-1).replaceAll(/[^\t]/g," ")}${"^".repeat(Math.max(1,n))}`},pt=(e,t,n,s={})=>{if(e.length===0)return n?$("No secrets detected."):"No secrets detected.";const r=n?{cyan:ae,dim:$,green:J,red:ce,yellow:L}:{cyan:o=>o,dim:o=>o,green:o=>o,red:o=>o,yellow:o=>o},i=[],c=ft(e);for(const[o,a]of c){const l=G(t,o)||o;i.push(r.cyan(l));const f=s.redact?void 0:dt(o);for(const u of a){const h=[u.source,u.confidence].filter(Boolean).join(", "),g=h?` ${r.dim(`(${h})`)}`:"",p=u.alternateMatches&&u.alternateMatches.length>0?` ${r.dim(`also: ${u.alternateMatches.join(", ")}`)}`:"";let m="";switch(u.validation){case"error":{m=` ${r.yellow("! error")}`;break}case"rejected":{m=` ${r.red("✗ rejected")}`;break}case"skipped":{m=` ${r.dim("— unverifiable")}`;break}case"verified":{m=` ${r.green("✓ verified")}`;break}}if(i.push(` ${r.red("✖")} ${r.yellow(`[${u.ruleId}]`)}${g}${m} ${r.dim(`line ${String(u.startLine)}:${String(u.startColumn)}`)}${p}`),f){const C=Math.max(0,u.startLine-1-re),b=Math.min(f.length,u.startLine+re);for(let d=C;d<b;d+=1){const S=String(d+1).padStart(4," "),v=d+1===u.startLine,w=v?r.red("▶"):" ";if(i.push(` ${w} ${r.dim(S)} │ ${f[d]??""}`),v){const O=Math.max(1,(u.endColumn??u.startColumn+1)-u.startColumn),xe=ht(f[d]??"",u.startColumn,O);i.push(` ${r.dim(" │ ")}${r.red(xe)}`)}}}i.push("")}}return i.join(`
3
+ `))}#g(t,n){if(!this.#e||(this.#h(),this.#e=!1,this.#u=Date.now(),!this.#p))return;let s="";const r=this.#b[t];r&&(s=this.#a?this.#a(r):r),this.#r&&(s=`${this.#r} ${s}`),n&&(s=`${s} ${n}`),this.#S(s)}};const We=(e,t,n)=>{const s=n.toLowerCase();e[s]??=new Map;const r=e[s].get(t);if(r!==void 0)return r;const{size:i}=e[s],c=`<${n.toUpperCase()}${i>0?String(i):""}>`;return e[s].set(t,c),c},Z=(e,t)=>{const{replacement:n,tag:s,text:r}=t;return typeof n=="function"?String(n(r,void 0)):typeof n=="string"?n:We(e,r,s)},Je=(e,t)=>{const n={};let s="",r=0;for(const i of e){const{start:c,text:o}=i;if(o==="")continue;if(Number.isInteger(c)&&c>=0&&t.slice(c,c+o.length)===o){if(c<r)continue;s+=t.slice(r,c)+Z(n,i),r=c+o.length;continue}let a=t.indexOf(o,r);if(a===-1)continue;const l=Z(n,i);for(;a!==-1;)s+=t.slice(r,a)+l,r=a+o.length,a=t.indexOf(o,r)}return s+t.slice(r)},Ge=e=>[...e.reduce((t,n)=>t.set(n.text+String(n.start)+n.tag,n),new Map).values()].toSorted((t,n)=>{const s=t.start-n.start;return s!==0?s:n.text.length-t.text.length}),Ke=(e,t)=>{const n=[];for(const s of e){const{key:r,pattern:i}=s,c=s.compiledPattern??new RegExp(i,"giu");c.lastIndex=0;let o;for(;(o=c.exec(t))!==null;){const a=s;n.push({replacement:a.userReplacement??a.replacement!==void 0?a.replacement:void 0,start:o.index,tag:r,text:o[0]}),o.index===c.lastIndex&&(c.lastIndex+=1)}}return n},Xe=(e,t,n,s)=>Ge([...Ke(n,e)]),fe=(e,t,n)=>{const s=[],r=[];for(const o of t)typeof o=="object"&&o.pattern&&s.push(o),r.push((typeof o=="object"?o.key:String(o)).toLowerCase());let i=e;const c=Xe(e,r,s);return i=Je(c,i),i},k=e=>{const t=typeof e;return e!==null&&(t==="object"||t==="function")},q=new Set(["__proto__","prototype","constructor"]),Ye=Math.max(...[...q].map(e=>e.length)),de=1e6,Qe=e=>e>="0"&&e<="9";function he(e){if(e==="0")return!0;if(/^[1-9]\d*$/.test(e)){const t=Number.parseInt(e,10);return t<=Number.MAX_SAFE_INTEGER&&t<=de}return!1}function D(e,t){return q.has(e)?!1:(e&&he(e)?t.push(Number.parseInt(e,10)):t.push(e),!0)}function Ze(e){if(typeof e!="string")throw new TypeError(`Expected a string, got ${typeof e}`);const t=[];let n="",s="",r=!1,i="start",c=!1,o=0;for(const a of e){if(o++,c){n+=a,c=!1;continue}if(a==="\\"){if(i==="index")throw new Error(`Invalid character '${a}' in an index at position ${o}`);if(i==="indexEnd")throw new Error(`Invalid character '${a}' after an index at position ${o}`);c=!0,i=i==="start"?"property":i;continue}switch(a){case".":{if(i==="index")throw new Error(`Invalid character '${a}' in an index at position ${o}`);if(i==="indexEnd"){i="property";break}if(!D(n,t))return[];n="",i="property";break}case"[":{if(i==="index")throw new Error(`Invalid character '${a}' in an index at position ${o}`);if(i==="indexEnd"){i="index";break}if(i==="property"&&n.length<=Ye&&q.has(n))return[];r=i==="property",i="index";break}case"]":{if(i==="indexEnd")throw new Error(`Invalid character '${a}' after an index at position ${o}`);if(i!=="index"){i==="start"&&(i="property"),n+=a;break}if(s===""){n+="[]",i="property";break}if((n!==""||r)&&!D(n,t))return[];n="",r=!1;const l=Number.parseInt(s,10),f=l<=de&&s===String(l);t.push(f?l:s),s="",i="indexEnd";break}default:{if(i==="index"){if(!Qe(a))throw new Error(`Invalid character '${a}' in an index at position ${o}`);s+=a;break}if(i==="indexEnd")throw new Error(`Invalid character '${a}' after an index at position ${o}`);i==="start"&&(i="property"),n+=a}}}switch(c&&(n+="\\"),i){case"property":{if(!D(n,t))return[];break}case"index":throw new Error("Index was not closed");case"start":{t.push("");break}}return t}function U(e){if(typeof e=="string")return Ze(e);if(Array.isArray(e)){const t=[];for(const[n,s]of e.entries()){if(typeof s!="string"&&typeof s!="number")throw new TypeError(`Expected a string or number for path segment at index ${n}, got ${typeof s}`);if(typeof s=="number"&&!Number.isFinite(s))throw new TypeError(`Path segment at index ${n} must be a finite number, got ${s}`);if(q.has(s))return[];typeof s=="string"&&he(s)?t.push(Number.parseInt(s,10)):t.push(s)}return t}return[]}function et(e,t,n){if(!k(e)||typeof t!="string"&&!Array.isArray(t))return e;const s=U(t);if(s.length===0)return n;for(let r=0;r<s.length;r++){const i=s[r];if(e=e[i],e==null){if(r!==s.length-1)return n;break}}return e===void 0?n:e}function tt(e,t,n){if(!k(e)||typeof t!="string"&&!Array.isArray(t))return e;const s=e,r=U(t);if(r.length===0)return e;for(let i=0;i<r.length;i++){const c=r[i];if(i===r.length-1){e[c]=n;continue}const o=e[c];if(k(o)){e=o;continue}const a=typeof r[i+1]=="number";e[c]=a?[]:{},e=e[c]}return s}function nt(e,t){if(!k(e)||typeof t!="string"&&!Array.isArray(t))return!1;const n=U(t);if(n.length===0)return!1;for(let s=0;s<n.length;s++){const r=n[s];if(s===n.length-1)return Object.hasOwn(e,r)?(delete e[r],!0):!1;const i=e[r];if(!k(i))return!1;e=i}}function ee(e,t){if(!k(e)||typeof t!="string"&&!Array.isArray(t))return!1;const n=U(t);if(n.length===0)return!1;for(const s of n){if(!k(e)||!(s in e))return!1;e=e[s]}return!0}const P="#;/?:@&",H=new RegExp(String.raw`([${P}][^${P}=\s]+=[^${P}=\s]*)`,"g"),st=e=>{const t=[];let n=0;H.lastIndex=0;let s=H.exec(e);for(;s!==null;){const{0:i,index:c}=s;t.push({key:void 0,value:e.slice(n,c+1)}),n=c+i.length,t.push({key:i.slice(1,i.indexOf("=")),value:i.slice(i.indexOf("=")+1)}),s=H.exec(e)}const r=e.slice(n);return r.length>0&&t.push({key:void 0,value:r}),t},te=(e,t)=>{for(let n=0;n<e.length;n+=1){let s=e[n].string,r=e[n].index;for(;r<t.length;){const i=t[r];if(!s.includes(i))break;const c=s.slice(1);for(e.push({index:r,string:c}),c.includes(i)||e.pop(),s=s.slice(s.indexOf(i)+i.length),r+=1;t[r]==="";)r+=1;if(r>=t.length){if(t.at(-1)!==""&&s.length>0)break;return!0}}}return!1},z=(e,t)=>{if(!t.includes("*"))return t===e;const n=t.split("*");let s=0,r=e;for(;n[s]==="";)if(s+=1,s===t.length)return!0;if(s===0&&!e.startsWith(n[0]))return!1;const i=[];for(;s<n.length;){const c=n[s];if(!r.includes(c))return te(i,n);const o=r.slice(1);for(i.push({index:s,string:o}),o.includes(c)||i.pop(),r=r.slice(r.indexOf(c)+c.length),s+=1;n[s]==="";)s+=1}return s>=n.length&&n.at(-1)!==""&&r.length>0?r===e?!1:te(i,n):!0},rt=/(?:http|https):\/\/?/,R=(e,t,n)=>typeof e.replacement=="function"?e.replacement(t,n):e.replacement,pe=(e,t,n)=>e.wildcard?z(t,e.key)||z(n,e.key):t===e.key||n===e.key,it=(e,t,n,s)=>{n.remove?delete e[t]:e[t]=R(n,e[t],s)},ne=(e,t,n,s,r,i)=>{const c=[],o=[];for(const l of s)!l.wildcard&&!l.deep&&ee(e,l.key)?o.push(l):c.push(l);const a=Object.keys(e);for(const l of a){if(!Object.hasOwn(e,l))continue;const f=l.toLowerCase(),u=i?`${i}.${f}`:f;let h;for(const g of c)pe(g,f,u)&&(h=g);h?it(e,l,h,u):e[l]=x(e[l],t,n,c,r,u)}for(const l of o)if(ee(e,l.key))if(l.remove)nt(e,l.key);else{const f=i?`${i}.${l.key}`:l.key;tt(e,l.key,R(l,et(e,l.key),f))}},se=(e,t)=>{const n=t.toLowerCase();return e.find(s=>s.key===n||!!s.wildcard&&z(n,s.key))},ot=(e,t,n)=>{const s=st(e),r=[];for(const i of s){const{key:c,value:o}=i;if(c===void 0){const a=se(t,o);r.push(a?String(R(a,o,void 0)):fe(o,t))}else{const a=se(t,c);a?r.push(`${c}=${String(R(a,o,void 0))}`):r.push(`${c}=${o}`)}}return r.join("")},x=(e,t,n,s,r,i)=>{if(e==null)return e;if(typeof e=="object"&&e.constructor===String)return x(String(e),t,n,s,r,i);if(typeof e=="object"&&t.has(e))return t.get(e);if(typeof e=="object"&&!Array.isArray(e)){if(e instanceof Error){const o=new Error(e.message);Object.defineProperties(o,{name:{configurable:!0,enumerable:!1,value:e.name,writable:!0},stack:{configurable:!0,enumerable:!1,value:e.stack,writable:!0}}),e.code!==void 0&&(o.code=e.code);const a=Object.keys(e);for(const l of a)o[l]=e[l];return n(e,o),ne(o,t,n,s,r,i),o}if(e instanceof Map){const o=new Map;n(e,o);const a=e.entries();let l=a.next();for(;!l.done;){const[f,u]=l.value;if(typeof f=="string"||typeof f=="object"&&f!==null&&f.constructor===String){const h=f.toLowerCase(),g=i?`${i}.${h}`:h;let p;for(const m of s)pe(m,h,g)&&(p=m);p?p.remove||o.set(f,R(p,u,g)):o.set(f,x(u,t,n,s,r,g))}else o.set(x(f,t,n,s,r),x(u,t,n,s,r));l=a.next()}return o}if(e instanceof Set){const o=new Set;n(e,o);const a=e.values();let l=a.next();for(;!l.done;)o.add(x(l.value,t,n,s,r,i)),l=a.next();return o}const c={...e};return n(e,c),ne(c,t,n,s,r,i),c}if(typeof e=="string"){const c=e;try{const o=JSON.parse(c);if(typeof o=="object"&&o!==null){const a=x(o,t,n,s,r,i);return JSON.stringify(a)}}catch{}return rt.test(c)?ot(c,s):fe(c,s)}if(Array.isArray(e)){const c=[];n(e,c);for(const[o,a]of e.entries()){const l=o.toString().toLowerCase(),f=i?`${i}.${l}`.toLowerCase():l,u=s.find(h=>h.key===l||h.key===f);u?c.push(R(u,a,f)):c.push(x(a,t,n,s,r,f))}return c}return e},ct=(e,t)=>{const n=[];for(const s of e)if(typeof s=="string"){const r=s.includes("*");n.push({deep:!1,key:s.toLowerCase(),replacement:`<${s.toUpperCase()}>`,userReplacement:!1,wildcard:r})}else if(typeof s=="number")n.push({deep:!1,key:s.toString(),replacement:"<REDACTED>"});else{const r=s.key.toLowerCase(),i={...s,key:r,replacement:s.replacement??`<${r.toUpperCase()}>`,userReplacement:s.replacement!==void 0,wildcard:r.includes("*")?!0:s.wildcard};if(i.pattern!==void 0){const c=i.pattern instanceof RegExp?i.pattern.source:i.pattern;i.compiledPattern=new RegExp(c,"giu")}n.push(i)}return n},at=(e,t,n)=>{if(e==null||typeof e=="number"||typeof e=="boolean")return e;const s=new WeakMap;return x(e,s,(r,i)=>{s.set(r,i)},t,n)},ge=(e,t,n)=>{const s=ct(t);return at(e,s,n)},Y=(e={})=>{const t=new Ae(new Q(process.stdout),new Q(process.stderr));return new Ve(e,t)},lt=(e,t)=>{if(!T(e))return e;const n=G(t,e);return n===""||n.startsWith("..")?e:n},A=(e,t)=>{const n=lt(e.file,t);return n===e.file?e:{...e,file:n}},me=e=>{if(!X(e))return[];try{const t=Me(e);return Array.isArray(t)?t:[]}catch{return[]}},ut=(e,t,n)=>{const s=me(t).map(o=>A(o,n)),r=new Set(s.map(o=>E(o))),i=e.map(o=>A(o,n)),c=new Set(i.map(o=>E(o)));return{fresh:i.filter(o=>!r.has(E(o))),resolved:s.filter(o=>!c.has(E(o))),surviving:i.filter(o=>r.has(E(o)))}},we=(e,t,n,s={})=>{const r=e.map(c=>A(c,n));let i;if(s.replace)i=r;else{const c=me(t).map(a=>A(a,n)),o=new Set;i=[];for(const a of[...c,...r]){const l=E(a);o.has(l)||(o.add(l),i.push(a))}}return Fe(t,`${JSON.stringify(i,null,4)}
4
+ `),i.length},re=1,ft=e=>{const t=new Map;for(const n of e){const s=t.get(n.file);s?s.push(n):t.set(n.file,[n])}return t},dt=e=>{try{return Se(e).split(/\r?\n/)}catch{return}},ht=(e,t,n)=>{const s=Math.max(1,t);return`${e.slice(0,s-1).replaceAll(/[^\t]/g," ")}${"^".repeat(Math.max(1,n))}`},pt=(e,t,n,s={})=>{if(e.length===0)return n?$("No secrets detected."):"No secrets detected.";const r=n?{cyan:ae,dim:$,green:J,red:ce,yellow:L}:{cyan:o=>o,dim:o=>o,green:o=>o,red:o=>o,yellow:o=>o},i=[],c=ft(e);for(const[o,a]of c){const l=G(t,o)||o;i.push(r.cyan(l));const f=s.redact?void 0:dt(o);for(const u of a){const h=[u.source,u.confidence].filter(Boolean).join(", "),g=h?` ${r.dim(`(${h})`)}`:"",p=u.alternateMatches&&u.alternateMatches.length>0?` ${r.dim(`also: ${u.alternateMatches.join(", ")}`)}`:"";let m="";switch(u.validation){case"error":{m=` ${r.yellow("! error")}`;break}case"rejected":{m=` ${r.red("✗ rejected")}`;break}case"skipped":{m=` ${r.dim("— unverifiable")}`;break}case"verified":{m=` ${r.green("✓ verified")}`;break}}if(i.push(` ${r.red("✖")} ${r.yellow(`[${u.ruleId}]`)}${g}${m} ${r.dim(`line ${String(u.startLine)}:${String(u.startColumn)}`)}${p}`),f){const C=Math.max(0,u.startLine-1-re),b=Math.min(f.length,u.startLine+re);for(let d=C;d<b;d+=1){const S=String(d+1).padStart(4," "),v=d+1===u.startLine,y=v?r.red("▶"):" ";if(i.push(` ${y} ${r.dim(S)} │ ${f[d]??""}`),v){const O=Math.max(1,(u.endColumn??u.startColumn+1)-u.startColumn),xe=ht(f[d]??"",u.startColumn,O);i.push(` ${r.dim(" │ ")}${r.red(xe)}`)}}}i.push("")}}return i.join(`
5
5
  `).trimEnd()},gt=(e,t,n={})=>{if(e.length===0)return t?$("No secrets detected in git history."):"No secrets detected in git history.";const s=t?{cyan:ae,dim:$,green:J,red:ce,yellow:L}:{cyan:c=>c,dim:c=>c,green:c=>c,red:c=>c,yellow:c=>c},r=new Map;for(const c of e){const o=r.get(c.commit.sha);o?o.push(c):r.set(c.commit.sha,[c])}const i=[];for(const[c,o]of r){const{authorName:a,date:l,message:f}=o[0].commit;i.push(`${s.yellow(c.slice(0,10))} ${f}`),i.push(` ${s.dim(`${a} · ${l}`)}`);for(const u of o){const h=[u.source,u.confidence].filter(Boolean).join(", "),g=h?` ${s.dim(`(${h})`)}`:"",p=n.redact?"":` ${s.dim(u.match)}`;i.push(` ${s.red("✖")} ${s.yellow(`[${u.ruleId}]`)}${g} ${s.cyan(u.file)} ${s.dim(`line ${String(u.startLine)}:${String(u.startColumn)}`)}${p}`)}i.push("")}return i.join(`
6
- `).trimEnd()},mt=(e,t)=>{if(!T(e))return e.replaceAll("\\","/");try{return ue(e).toString()}catch{return`file://${I(t,e).replaceAll("\\","/")}`}},yt=(e,t=100)=>e.length<=t?e:`${e.slice(0,t-1).trimEnd()}…`,we=(e,t,n=process.cwd(),s=[])=>{const r=new Map(s.map(a=>[a.id,a])),i=new Set;for(const a of e)i.add(a.ruleId);const c=[...new Set([...r.keys(),...i])].sort((a,l)=>a.localeCompare(l)),o=new Map(c.map((a,l)=>[a,l]));return JSON.stringify({$schema:"https://schemastore.azurewebsites.net/schemas/json/sarif-2.1.0.json",runs:[{originalUriBaseIds:{SRCROOT:{uri:ue(n).toString()}},results:e.map(a=>{const l={};return a.source&&(l.source=a.source),a.confidence&&(l.confidence=a.confidence),a.alternateMatches&&a.alternateMatches.length>0&&(l.alternateRules=a.alternateMatches),a.validation&&(l.validation=a.validation),{level:"error",locations:[{physicalLocation:{artifactLocation:{uri:mt(a.file,n),uriBaseId:T(a.file)?void 0:"SRCROOT"},region:{endColumn:a.endColumn,endLine:a.endLine,snippet:{text:a.match},startColumn:a.startColumn,startLine:a.startLine}}}],message:{text:a.description||a.ruleId},properties:Object.keys(l).length>0?l:void 0,ruleId:a.ruleId,ruleIndex:o.get(a.ruleId)??-1}}),tool:{driver:{informationUri:"https://visulima.com/packages/secret-scanner",name:"visulima-secret-scanner",rules:c.map(a=>{const l=r.get(a),f=l?.description??`Detected by rule \`${a}\``,u={};return l?.tags&&l.tags.length>0&&(u.tags=l.tags),l?.source&&(u.source=l.source),l?.confidence&&(u.confidence=l.confidence),{defaultConfiguration:{level:"error"},fullDescription:{text:f},helpUri:"https://visulima.com/packages/secret-scanner",id:a,name:a,properties:Object.keys(u).length>0?u:void 0,shortDescription:{text:yt(f)}}}),version:t}}}],version:"2.1.0"},void 0,2)},B=(e,t)=>{try{return Le("git",t,{cwd:e,encoding:"utf8",stdio:["ignore","pipe","pipe"]}).trim()}catch{return""}},V=e=>e.split(/\r?\n/).map(t=>t.trim()).filter(Boolean),wt=e=>V(B(e,["diff","--cached","--name-only","--diff-filter=ACMR"])).map(t=>T(t)?t:M(e,t)),ie=(e,t)=>{const n=B(e,["diff","--name-only","--diff-filter=ACMR",`${t}...HEAD`]),s=V(n);if(s.length===0){const r=B(e,["diff","--name-only","--diff-filter=ACMR",t]);return V(r).map(i=>T(i)?i:M(e,i))}return s.map(r=>T(r)?r:M(e,r))},_=e=>B(e,["rev-parse","--show-toplevel"]).length>0,F=".secrets-baseline.json",oe=e=>e?Array.isArray(e)?e:[e]:[],$e=e=>{const t=new Set(["json","sarif","text"]);if(e&&!t.has(e))throw new Error(`--format must be one of: ${[...t].join(", ")} (got "${e}")`);return e??"text"},$t=e=>{if(e===void 0)return;const t=new Set(["high","low","medium"]);if(!t.has(e))throw new Error(`--min-confidence must be one of: ${[...t].join(", ")} (got "${e}")`);return e},xt=async(e,t)=>{const n=await K(e);process.stdout.write(`${String(n.length)} rules loaded
6
+ `).trimEnd()},mt=(e,t)=>{if(!T(e))return e.replaceAll("\\","/");try{return ue(e).toString()}catch{return`file://${I(t,e).replaceAll("\\","/")}`}},wt=(e,t=100)=>e.length<=t?e:`${e.slice(0,t-1).trimEnd()}…`,ye=(e,t,n=process.cwd(),s=[])=>{const r=new Map(s.map(a=>[a.id,a])),i=new Set;for(const a of e)i.add(a.ruleId);const c=[...new Set([...r.keys(),...i])].sort((a,l)=>a.localeCompare(l)),o=new Map(c.map((a,l)=>[a,l]));return JSON.stringify({$schema:"https://schemastore.azurewebsites.net/schemas/json/sarif-2.1.0.json",runs:[{originalUriBaseIds:{SRCROOT:{uri:ue(n).toString()}},results:e.map(a=>{const l={};return a.source&&(l.source=a.source),a.confidence&&(l.confidence=a.confidence),a.alternateMatches&&a.alternateMatches.length>0&&(l.alternateRules=a.alternateMatches),a.validation&&(l.validation=a.validation),{level:"error",locations:[{physicalLocation:{artifactLocation:{uri:mt(a.file,n),uriBaseId:T(a.file)?void 0:"SRCROOT"},region:{endColumn:a.endColumn,endLine:a.endLine,snippet:{text:a.match},startColumn:a.startColumn,startLine:a.startLine}}}],message:{text:a.description||a.ruleId},properties:Object.keys(l).length>0?l:void 0,ruleId:a.ruleId,ruleIndex:o.get(a.ruleId)??-1}}),tool:{driver:{informationUri:"https://visulima.com/packages/secret-scanner",name:"visulima-secret-scanner",rules:c.map(a=>{const l=r.get(a),f=l?.description??`Detected by rule \`${a}\``,u={};return l?.tags&&l.tags.length>0&&(u.tags=l.tags),l?.source&&(u.source=l.source),l?.confidence&&(u.confidence=l.confidence),{defaultConfiguration:{level:"error"},fullDescription:{text:f},helpUri:"https://visulima.com/packages/secret-scanner",id:a,name:a,properties:Object.keys(u).length>0?u:void 0,shortDescription:{text:wt(f)}}}),version:t}}}],version:"2.1.0"},void 0,2)},B=(e,t)=>{try{return Le("git",t,{cwd:e,encoding:"utf8",stdio:["ignore","pipe","pipe"]}).trim()}catch{return""}},V=e=>e.split(/\r?\n/).map(t=>t.trim()).filter(Boolean),yt=e=>V(B(e,["diff","--cached","--name-only","--diff-filter=ACMR"])).map(t=>T(t)?t:M(e,t)),ie=(e,t)=>{const n=B(e,["diff","--name-only","--diff-filter=ACMR",`${t}...HEAD`]),s=V(n);if(s.length===0){const r=B(e,["diff","--name-only","--diff-filter=ACMR",t]);return V(r).map(i=>T(i)?i:M(e,i))}return s.map(r=>T(r)?r:M(e,r))},_=e=>B(e,["rev-parse","--show-toplevel"]).length>0,F=".secrets-baseline.json",oe=e=>e?Array.isArray(e)?e:[e]:[],$e=e=>{const t=new Set(["json","sarif","text"]);if(e&&!t.has(e))throw new Error(`--format must be one of: ${[...t].join(", ")} (got "${e}")`);return e??"text"},$t=e=>{if(e===void 0)return;const t=new Set(["high","low","medium"]);if(!t.has(e))throw new Error(`--min-confidence must be one of: ${[...t].join(", ")} (got "${e}")`);return e},xt=async(e,t)=>{const n=await K(e);process.stdout.write(`${String(n.length)} rules loaded
7
7
 
8
8
  `);for(const s of n){const r=t?L(s.id):s.id,i=s.tags.length>0?` ${t?$(`[${s.tags.join(", ")}]`):`[${s.tags.join(", ")}]`}`:"";if(process.stdout.write(`${r}${i}
9
9
  ${s.description}
@@ -17,12 +17,12 @@ import{createRequire as be}from"node:module";import{F as $,b as L,X as ce,J,q as
17
17
  `),process.stdout.write(` ${s.summary}
18
18
  `);const c=s.packageName?`install: npm add ${s.packageName}`:"no driver — bespoke implementation required";process.stdout.write(` ${t?$(c):c}
19
19
 
20
- `)}},vt=async(e,t,n)=>{const s=M(e,F);if(!n&&X(s)){y.warn(`Detected existing ${F} — refusing to overwrite. Delete it first to re-init.`),process.exitCode=1;return}y.info(n?"[dry-run] Previewing init — no files will be written.":"Scanning workspace to seed baseline…");const r=Y();r.start("scanning");let i;try{i=await le([e],t),r.succeed()}catch(o){throw r.failed(),o}if(n){y.info(`[dry-run] Would create ${F} with ${String(i.length)} finding(s).`);return}const c=ye(i,s,e,{replace:!0});y.success(`Wrote ${F} (${String(c)} findings).`),y.notice("Commit it. Use `vis secrets --baseline .secrets-baseline.json` in CI. Add path patterns to .gitignore to exclude directories from scanning.")},kt=(e,t,n)=>{const s=t??{},r=d=>d?I(n,d):void 0,i=(d,S)=>{const v=oe(d);return v.length>0?v:S},c=(s.config?.presets??[]).map(d=>`tag:preset:${d}`),o=i(e.enableRule,s.rules?.enable)??[],a=[...o,...c.filter(d=>!o.includes(d))],l=a.length>0?a:void 0,f=i(e.excludeRule,s.rules?.exclude),u=i(e.includeRule,s.rules?.include),h=i(e.exclude,s.walk?.excludePatterns),g=oe(e.excludeFrom).map(d=>I(n,d)),p=g.length>0?g:s.walk?.excludeFromFiles?.map(d=>I(n,d)),m=r(e.baseline)??r(s.baseline),C=r(e.config)??r(s.config?.path),b=$t(e.minConfidence??s.config?.minConfidence);return{baseline:m,concurrency:e.concurrency,config:{extendBundled:e.extendBundled===!1?!1:s.config?.extendBundled,inline:s.config?.inline,minConfidence:b,onlyVerified:e.onlyVerified??s.config?.onlyVerified??!1,path:C,validate:e.validate??s.config?.validate??!1},redact:e.redact??s.redact,rules:{enable:l,exclude:f,include:u},verbose:e.verbose??!1,walk:{excludeFromFiles:p,excludePatterns:h,gitignore:e.gitignore===!1?!1:s.walk?.gitignore??!0,includeHidden:e.includeHidden??s.walk?.includeHidden,maxFileSize:e.maxSize??s.walk?.maxFileSize}}},St=e=>{process.stderr.write(`${$("baseline diff: ")}${J(`+${String(e.fresh.length)} new`)} · ${L(`${String(e.surviving.length)} unchanged`)} · ${$(`-${String(e.resolved.length)} resolved`)}
21
- `)},Et=async(e,t,n)=>{if(e.staged){if(!_(n))throw new Error("--staged requires a git working tree, and none was detected.");return{files:wt(n)}}if(e.since){if(!_(n))throw new Error("--since requires a git working tree, and none was detected.");return{files:ie(n,e.since)}}if(e.affected){if(!_(n))return y.warn("--affected requires git; falling back to full scan"),{paths:t&&t.length>0?t.map(r=>I(n,r)):[n]};const s=process.env.VIS_BASE??"HEAD~1";return{files:ie(n,s)}}return{paths:t&&t.length>0?t.map(s=>I(n,s)):[n]}},It=(e,t,n,s,r,i,c)=>{switch(t){case"json":{const o=e.map(a=>A(a,n));process.stdout.write(`${JSON.stringify(o,null,2)}
22
- `);break}case"sarif":{process.stdout.write(`${we(e,r,n,i)}
20
+ `)}},vt=async(e,t,n)=>{const s=M(e,F);if(!n&&X(s)){w.warn(`Detected existing ${F} — refusing to overwrite. Delete it first to re-init.`),process.exitCode=1;return}w.info(n?"[dry-run] Previewing init — no files will be written.":"Scanning workspace to seed baseline…");const r=Y();r.start("scanning");let i;try{i=await le([e],t),r.succeed()}catch(o){throw r.failed(),o}if(n){w.info(`[dry-run] Would create ${F} with ${String(i.length)} finding(s).`);return}const c=we(i,s,e,{replace:!0});w.success(`Wrote ${F} (${String(c)} findings).`),w.notice("Commit it. Use `vis secrets --baseline .secrets-baseline.json` in CI. Add path patterns to .gitignore to exclude directories from scanning.")},kt=(e,t,n)=>{const s=t??{},r=d=>d?I(n,d):void 0,i=(d,S)=>{const v=oe(d);return v.length>0?v:S},c=(s.config?.presets??[]).map(d=>`tag:preset:${d}`),o=i(e.enableRule,s.rules?.enable)??[],a=[...o,...c.filter(d=>!o.includes(d))],l=a.length>0?a:void 0,f=i(e.excludeRule,s.rules?.exclude),u=i(e.includeRule,s.rules?.include),h=i(e.exclude,s.walk?.excludePatterns),g=oe(e.excludeFrom).map(d=>I(n,d)),p=g.length>0?g:s.walk?.excludeFromFiles?.map(d=>I(n,d)),m=r(e.baseline)??r(s.baseline),C=r(e.config)??r(s.config?.path),b=$t(e.minConfidence??s.config?.minConfidence);return{baseline:m,concurrency:e.concurrency,config:{extendBundled:e.extendBundled===!1?!1:s.config?.extendBundled,inline:s.config?.inline,minConfidence:b,onlyVerified:e.onlyVerified??s.config?.onlyVerified??!1,path:C,validate:e.validate??s.config?.validate??!1},redact:e.redact??s.redact,rules:{enable:l,exclude:f,include:u},verbose:e.verbose??!1,walk:{excludeFromFiles:p,excludePatterns:h,gitignore:e.gitignore===!1?!1:s.walk?.gitignore??!0,includeHidden:e.includeHidden??s.walk?.includeHidden,maxFileSize:e.maxSize??s.walk?.maxFileSize}}},St=e=>{process.stderr.write(`${$("baseline diff: ")}${J(`+${String(e.fresh.length)} new`)} · ${L(`${String(e.surviving.length)} unchanged`)} · ${$(`-${String(e.resolved.length)} resolved`)}
21
+ `)},Et=async(e,t,n)=>{if(e.staged){if(!_(n))throw new Error("--staged requires a git working tree, and none was detected.");return{files:yt(n)}}if(e.since){if(!_(n))throw new Error("--since requires a git working tree, and none was detected.");return{files:ie(n,e.since)}}if(e.affected){if(!_(n))return w.warn("--affected requires git; falling back to full scan"),{paths:t&&t.length>0?t.map(r=>I(n,r)):[n]};const s=process.env.VIS_BASE??"HEAD~1";return{files:ie(n,s)}}return{paths:t&&t.length>0?t.map(s=>I(n,s)):[n]}},It=(e,t,n,s,r,i,c)=>{switch(t){case"json":{const o=e.map(a=>A(a,n));process.stdout.write(`${JSON.stringify(o,null,2)}
22
+ `);break}case"sarif":{process.stdout.write(`${ye(e,r,n,i)}
23
23
  `);break}default:process.stdout.write(`${pt(e,n,s,{redact:c})}
24
24
  `)}},Tt=async(e,t,n,s,r)=>{if(e.staged||e.since||e.affected)throw new Error("--history scans commit history and can't be combined with --staged / --since / --affected (those scan the working tree).");if(!_(t))throw new Error("--history requires a git working tree, and none was detected.");const i=$e(e.format),c=!e.quiet&&i==="text",o=Y({verbose:c});o.start("scanning git history for secrets");let a;try{a=await Re({...n,cwd:t,maxCommits:e.maxCommits,range:e.historyRange}),o.succeed()}catch(u){throw o.failed(),new Error(`git-history secret scan failed: ${u instanceof Error?u.message:String(u)}`,{cause:u})}const l=n.redact===!0,f=l?ge(a,["match","secret"]):a;switch(i){case"json":{process.stdout.write(`${JSON.stringify(f.map(u=>A(u,t)),null,2)}
25
- `);break}case"sarif":{const u=await K(n).catch(()=>[]);process.stdout.write(`${we(f,r,t,u)}
25
+ `);break}case"sarif":{const u=await K(n).catch(()=>[]);process.stdout.write(`${ye(f,r,t,u)}
26
26
  `);break}default:process.stdout.write(`${gt(f,s,{redact:l})}
27
- `)}if(a.length>0){e.quiet||(y.warn(`${String(a.length)} potential secret(s) found across git history`),y.notice("Findings reference the commit that introduced them — rotate the credential and rewrite history (e.g. git filter-repo) if it is still reachable.")),process.exitCode=1;return}e.quiet||y.success("No secrets detected in git history.")},Bt=async({argument:e,options:t,visConfig:n,workspaceRoot:s})=>{const r=t,i=e,c=s??process.cwd(),o=!r.quiet&&process.stdout.isTTY,a=n?.secrets,l=kt(r,a,c),f="0.0.0-alpha";if(r.listRules){await xt(l,o);return}if(r.listValidators){await bt(l,o);return}if(r.init){await vt(c,l,r.dryRun??!1);return}if(r.history){await Tt(r,c,l,o,f);return}const u=await Et(r,i??[],c);if(u.files?.length===0){r.quiet||y.success("No files to scan.");return}const h=!r.quiet&&!["json","sarif"].includes(r.format??"text"),g=Y({verbose:h});g.start("scanning for secrets");let p;try{p=u.files===void 0?await le(u.paths??[c],l):await Ee(u.files,l),g.succeed()}catch(w){throw g.failed(),new Error(`secret scan failed: ${w instanceof Error?w.message:String(w)}`,{cause:w})}if(r.verbose){const w=await Ie(l);if(w.length>0){y.warn(`${String(w.length)} rule(s) skipped due to invalid regex. First few:`);for(const O of w.slice(0,5))process.stderr.write(` - ${O.ruleId}: ${O.reason}
28
- `)}}const m=typeof l.baseline=="string"?l.baseline:M(c,F),C=!r.quiet&&X(m);if(r.updateBaseline){const w=ye(p,m,c,{replace:r.replaceBaseline});y.success(`Baseline updated: ${G(c,m)||m} now contains ${String(w)} entries.`);return}const b=$e(r.format),d=b==="sarif"?await K(l).catch(()=>[]):[],S=l.redact===!0,v=S?ge(p,["match","secret"]):p;if(It(v,b,c,o,f,d,S),b==="text"&&C&&St(ut(p,m,c)),p.length>0){r.quiet||(y.warn(`${String(p.length)} potential secret(s) found`),y.notice("Suppress individual lines with `gitleaks:allow` / `secret-scanner:allow`, or run `vis secrets --update-baseline`.")),process.exitCode=1;return}r.quiet||y.success("No secrets detected.")};export{Bt as default,kt as resolveScanOptions};
27
+ `)}if(a.length>0){e.quiet||(w.warn(`${String(a.length)} potential secret(s) found across git history`),w.notice("Findings reference the commit that introduced them — rotate the credential and rewrite history (e.g. git filter-repo) if it is still reachable.")),process.exitCode=1;return}e.quiet||w.success("No secrets detected in git history.")},Bt=async({argument:e,options:t,visConfig:n,workspaceRoot:s})=>{const r=t,i=e,c=s??process.cwd(),o=!r.quiet&&process.stdout.isTTY,a=n?.secrets,l=kt(r,a,c),f="0.0.0-alpha";if(r.listRules){await xt(l,o);return}if(r.listValidators){await bt(l,o);return}if(r.init){await vt(c,l,r.dryRun??!1);return}if(r.history){await Tt(r,c,l,o,f);return}const u=await Et(r,i??[],c);if(u.files?.length===0){r.quiet||w.success("No files to scan.");return}const h=!r.quiet&&!["json","sarif"].includes(r.format??"text"),g=Y({verbose:h});g.start("scanning for secrets");let p;try{p=u.files===void 0?await le(u.paths??[c],l):await Ee(u.files,l),g.succeed()}catch(y){throw g.failed(),new Error(`secret scan failed: ${y instanceof Error?y.message:String(y)}`,{cause:y})}if(r.verbose){const y=await Ie(l);if(y.length>0){w.warn(`${String(y.length)} rule(s) skipped due to invalid regex. First few:`);for(const O of y.slice(0,5))process.stderr.write(` - ${O.ruleId}: ${O.reason}
28
+ `)}}const m=typeof l.baseline=="string"?l.baseline:M(c,F),C=!r.quiet&&X(m);if(r.updateBaseline){const y=we(p,m,c,{replace:r.replaceBaseline});w.success(`Baseline updated: ${G(c,m)||m} now contains ${String(y)} entries.`);return}const b=$e(r.format),d=b==="sarif"?await K(l).catch(()=>[]):[],S=l.redact===!0,v=S?ge(p,["match","secret"]):p;if(It(v,b,c,o,f,d,S),b==="text"&&C&&St(ut(p,m,c)),p.length>0){r.quiet||(w.warn(`${String(p.length)} potential secret(s) found`),w.notice("Suppress individual lines with `gitleaks:allow` / `secret-scanner:allow`, or run `vis secrets --update-baseline`.")),process.exitCode=1;return}r.quiet||w.success("No secrets detected.")};export{Bt as default,kt as resolveScanOptions};