@visulima/vis 6.8.0 → 7.0.0

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.
@@ -1,25 +1,50 @@
1
- import{createRequire as Q}from"node:module";import{J as v,j as w,F as g,q as x,b,X as D}from"../packem_shared/index.server-Ca_EEVfw.js";import{e as I,z as se,a as $}from"../packem_shared/index-0dnGN3GP.js";import G from"./index.js";import{y as _}from"../packem_shared/isAccessibleSync-DYKTrrvc-CBsMZhj-.js";import{V as oe,U as F,l as ne,a1 as ae,a2 as ie,a3 as re,a4 as ce}from"./cli-main.js";import{h as pe,i as z,q as W,u as j,p as L,J as K}from"../packem_shared/registry-DqBIZZSL.js";import{p as S}from"../packem_shared/package-version-lWlrF9Wk.js";import{U as fe}from"../packem_shared/env-5cWSxQ96.js";import{l as le}from"../packem_shared/missing-package-json-DLTSyp4H.js";import{readCatalogs as ue}from"./catalog.js";let Z;const ee=e=>(Z??=Q(import.meta.url))(e),V=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,te=e=>{if(typeof V<"u"&&V.versions&&V.versions.node){const[a,s]=V.versions.node.split(".").map(Number);if(a>22||a===22&&s>=3||a===20&&s>=16)return V.getBuiltinModule(e)}return ee(e)},{readFileSync:Y,writeFileSync:H}=te("node:fs"),de=e=>/[*?[\]{}!]/.test(e),ge=e=>typeof e=="string"?e:e.reason,me=e=>typeof e=="string"?void 0:e.replacement,q=(e,a)=>e.some(s=>G(s,a)),U=(e,a)=>{if(typeof e=="string")return!0;const s=Array.isArray(e.packages)&&e.packages.length>0,t=Array.isArray(e.paths)&&e.paths.length>0;return!!(!s&&!t||s&&a.packageName!==void 0&&q(e.packages,a.packageName)||t&&q(e.paths,a.packageDir))},he=(e,a)=>{const s=a[e.depName];if(s!==void 0&&U(s,e))return{pattern:e.depName,rule:s};for(const[t,r]of Object.entries(a))if(de(t)&&G(t,e.depName)&&U(r,e))return{pattern:t,rule:r}},ke=(e,a)=>{if(Object.keys(a).length===0)return[];const s=[];for(const t of e){if(t.isInternal)continue;const r=he(t,a);r&&s.push({depName:t.depName,depType:t.depType,matchedPattern:r.pattern,packageDir:t.packageDir,packageJsonPath:t.packageJsonPath,packageName:t.packageName,reason:ge(r.rule),replacement:me(r.rule),specifier:t.specifier})}return s},ye=new Set(["dependencies","devDependencies","peerDependencies"]),Pe=e=>e.startsWith("catalog:"),$e=e=>e.startsWith("workspace:"),we=(e,a)=>{if(!e)return!1;for(const s of e.values())if(s.has(a))return!0;return!1},ve=(e,a={})=>{const s=a.min??3,t=new Set(a.ignoreDeps),r=e.filter(i=>i.isInternal||!ye.has(i.depType)||$e(i.specifier)||a.dep!==void 0&&i.depName!==a.dep?!1:!t.has(i.depName)),n=new Map;for(const i of r){const c=n.get(i.depName);c?c.push(i):n.set(i.depName,[i])}const o=[];for(const[i,c]of n){if(we(a.catalogs,i)||c.some(h=>Pe(h.specifier)))continue;const p=new Map;for(const h of c){let d=p.get(h.specifier);d||(d=new Set,p.set(h.specifier,d)),d.add(h.packageJsonPath)}const m=[...p.entries()].sort((h,d)=>h[1].size!==d[1].size?d[1].size-h[1].size:h[0].localeCompare(d[0]))[0];!m||m[1].size<s||o.push({catalogName:"default",depName:i,instanceCount:m[1].size,specifier:m[0]})}return o.sort((i,c)=>i.depName.localeCompare(c.depName))},De=(e,a)=>{if(a.length===0)return;const s=I(e,"pnpm-workspace.yaml"),r=_(s)?Y(s,"utf8"):"",n=r.includes(`\r
2
- `)?`\r
3
- `:`
4
- `,o=a.filter(d=>d.catalogName==="default").sort((d,u)=>d.depName.localeCompare(u.depName));if(o.length===0)return;const i=r.length>0?r.split(n):[],c=i.findIndex(d=>/^catalog\s*:\s*$/.test(d));if(c===-1){const d=["catalog:"];for(const J of o)d.push(` ${J.depName}: "${J.specifier}"`);let u=0;for(;u<i.length&&(i[u]??"").trim().length===0;)u+=1;const k=[...i.slice(0,u),...d,"",...i.slice(u)].join(n);return H(s,k.endsWith(n)?k:`${k}${n}`),s}let p=i.length;const f=new Set;for(let d=c+1;d<i.length;d+=1){const u=i[d]??"",k=u.trimStart();if(u.length===0)continue;if(u.length-k.length===0&&k.length>0&&!k.startsWith("#")){p=d;break}const P=/^([\w./@-]+)\s*:/.exec(k);P?.[1]&&f.add(P[1])}const m=[];for(const d of o)f.has(d.depName)||m.push(` ${d.depName}: "${d.specifier}"`);if(m.length===0)return;const h=[...i.slice(0,p),...m,...i.slice(p)].join(n);return H(s,h.endsWith(n)?h:`${h}${n}`),s},be=(e,a)=>{if(a.length===0)return"";const s=I(e,"pnpm-workspace.yaml"),r=_(s)?Y(s,"utf8"):"",n=[...a].sort((f,m)=>f.depName.localeCompare(m.depName)),o=["--- pnpm-workspace.yaml","+++ pnpm-workspace.yaml"],i=r.includes(`\r
5
- `)?`\r
6
- `:`
7
- `;if((r.length>0?r.split(i):[]).findIndex(f=>/^catalog\s*:\s*$/.test(f))===-1){o.push("@@ +1 @@","+catalog:");for(const f of n)o.push(`+ ${f.depName}: "${f.specifier}"`)}else{o.push("@@ catalog: @@");for(const f of n)o.push(`+ ${f.depName}: "${f.specifier}"`)}return o.join(i)},Ne=e=>{const a=[],s=pe(e);if(s){const r=I(e,"pnpm-workspace.yaml");for(const n of s)n.startsWith("!")||z(e,[n]).length===0&&a.push({pattern:n,source:"pnpm-workspace.yaml",sourcePath:r})}const t=I(e,"package.json");if(_(t)){const n=S(t).workspaces,o=Array.isArray(n)?n:n?.packages;if(o)for(const i of o)typeof i!="string"||i.startsWith("!")||z(e,[i]).length===0&&a.push({pattern:i,source:"package.json",sourcePath:t})}return a},Te=(e,a={})=>{const{useEditorconfig:s}=a,t=new Map;for(const n of e){const o=t.get(n.sourcePath);o?o.push(n):t.set(n.sourcePath,[n])}const r=[];for(const[n,o]of t){const i=new Set(o.map(m=>m.pattern));if(n.endsWith(".yaml")||n.endsWith(".yml")){const h=se(n).split(`
8
- `).filter(d=>{const u=d.trim();if(!u.startsWith("- "))return!0;const k=u.slice(2).replaceAll(/^['"]|['"]$/g,"");return!i.has(k)}).join(`
9
- `);fe(n,h,{overwrite:!0}),r.push(n);continue}const p=S(n),f=p.workspaces;Array.isArray(f)?p.workspaces=f.filter(m=>typeof m!="string"||!i.has(m)):f&&Array.isArray(f.packages)&&(f.packages=f.packages.filter(m=>typeof m!="string"||!i.has(m))),W(n,p,{indent:j(n,{useEditorconfig:s}),overwrite:!0}),r.push(n)}return r},xe=["dependencies","devDependencies","peerDependencies","optionalDependencies"],Je=(e,a={})=>{const s=new Set(a.ignoreBlocks),t=oe(e),r=[];for(const n of t){const o=I(e,n,"package.json"),i=F(o);if(!i)continue;const c=typeof i.name=="string"?i.name:void 0;for(const p of xe){if(s.has(p))continue;const f=i[p];typeof f=="object"&&f!==null&&!Array.isArray(f)&&Object.keys(f).length===0&&r.push({depType:p,packageDir:n,packageJsonPath:o,packageName:c})}}return r},Se=(e,a={})=>{const{useEditorconfig:s}=a,t=new Map;for(const n of e){const o=t.get(n.packageJsonPath);o?o.push(n):t.set(n.packageJsonPath,[n])}const r=[];for(const[n,o]of t){const i=S(n);for(const c of o){const p=i[c.depType];typeof p=="object"&&p!==null&&!Array.isArray(p)&&Object.keys(p).length===0&&Reflect.deleteProperty(i,c.depType)}W(n,i,{indent:j(n,{useEditorconfig:s}),overwrite:!0}),r.push(n)}return r},Ie=["dependencies","devDependencies","optionalDependencies","peerDependencies"],Me=(e,a={})=>{const s=new Set(a.depTypes??Ie),t=new Set(a.ignoreDeps),r=new Map;for(const o of e)o.packageDir!=="."||!s.has(o.depType)||r.set(o.depName,{depType:o.depType,specifier:o.specifier});if(r.size===0)return[];const n=[];for(const o of e){if(o.packageDir==="."||!s.has(o.depType)||t.has(o.depName))continue;const i=r.get(o.depName);i&&n.push({childSpecifier:o.specifier,depName:o.depName,depType:o.depType,packageDir:o.packageDir,packageJsonPath:o.packageJsonPath,packageName:o.packageName,rootDepType:i.depType,rootSpecifier:i.specifier})}return n},We=(e,a)=>{if(!a)return[];const s=I(e,"package.json"),t=F(s);if(!t)return[];if(t.private!==!0)return[];const r=t.dependencies;if(typeof r!="object"||r===null||Array.isArray(r))return[];const n=Object.keys(r);return n.length===0?[]:[{depNames:n,packageJsonPath:s}]},je=(e,a={})=>{const{useEditorconfig:s}=a,t=[];for(const r of e){const n=S(r.packageJsonPath),o=n.dependencies;if(typeof o!="object"||o===null)continue;const i=o;n.devDependencies??={};const c=n.devDependencies;for(const p of r.depNames){const f=i[p];typeof f=="string"&&(p in c||(c[p]=f),Reflect.deleteProperty(i,p))}Object.keys(i).length===0&&Reflect.deleteProperty(n,"dependencies"),W(r.packageJsonPath,n,{indent:j(r.packageJsonPath,{useEditorconfig:s}),overwrite:!0}),t.push(r.packageJsonPath)}return t},Ae=/^[a-z][\w-]*@\S+$/i,Ee=(e,a,s={})=>{if(!a)return[];const t=I(e,"package.json"),r=F(t);if(!r)return[];const n=r.packageManager;return typeof n=="string"&&Ae.test(n)?[]:[{packageJsonPath:t,suggested:s.suggested}]},Re=(e,a={})=>{const{useEditorconfig:s}=a,t=[];for(const r of e){if(!r.suggested)continue;const n=S(r.packageJsonPath);n.packageManager=r.suggested,W(r.packageJsonPath,n,{indent:j(r.packageJsonPath,{useEditorconfig:s}),overwrite:!0}),t.push(r.packageJsonPath)}return t},Ce=(e,a)=>{if(!a)return[];const s=I(e,"package.json"),t=F(s);return t?t.private===!0?[]:[{packageJsonPath:s,rawValue:t.private}]:[]},Ve=(e,a={})=>{const{useEditorconfig:s}=a,t=[];for(const r of e){const n=S(r.packageJsonPath);let o=n;if("private"in n)n.private=!0;else{const{name:i,version:c,...p}=n,f={};i!==void 0&&(f.name=i),c!==void 0&&(f.version=c),f.private=!0;for(const[m,h]of Object.entries(p))f[m]=h;o=f}W(r.packageJsonPath,o,{indent:j(r.packageJsonPath,{useEditorconfig:s}),overwrite:!0}),t.push(r.packageJsonPath)}return t},_e=[{id:"react",label:"React",members:["react","react-dom","react-test-renderer"]},{id:"next",label:"Next.js",members:["next","@next/font","@next/bundle-analyzer","@next/mdx","@next/third-parties","@next/eslint-plugin-next","eslint-config-next"]},{id:"babel",label:"Babel",prefixes:["@babel/"]},{id:"storybook",label:"Storybook",members:["storybook","sb"],prefixes:["@storybook/"]},{id:"vitest",label:"Vitest",members:["vitest"],prefixes:["@vitest/"]},{id:"playwright",label:"Playwright",members:["playwright","@playwright/test"]},{id:"trpc",label:"tRPC",prefixes:["@trpc/"]},{id:"prisma",label:"Prisma",members:["prisma"],prefixes:["@prisma/"]},{id:"turborepo",label:"Turborepo",members:["turbo","turbo-ignore","@turbo/gen","eslint-config-turbo","eslint-plugin-turbo"]},{id:"typescript-eslint",label:"typescript-eslint",members:["typescript-eslint"],prefixes:["@typescript-eslint/"]},{id:"eslint-stylistic",label:"ESLint Stylistic",prefixes:["@stylistic/"]},{id:"lexical",label:"Lexical",members:["lexical"],prefixes:["@lexical/"]},{id:"nx",label:"Nx",prefixes:["@nx/","@nrwl/"]}],Fe=new Set(["dependencies","devDependencies","peerDependencies"]),Oe=(e,a)=>{for(const s of e)if(s.members?.includes(a)||s.prefixes?.some(t=>a.startsWith(t)))return s},Be=e=>e.startsWith("workspace:")||e.startsWith("catalog:"),He=(e,a={})=>{const s=new Set(a.ignoreFamilies),t=new Map;for(const i of _e)t.set(i.id,i);for(const i of a.extraFamilies??[])t.set(i.id,i);const r=[...t.values()],n=new Map;for(const i of e){if(i.isInternal||!Fe.has(i.depType)||Be(i.specifier))continue;const c=Oe(r,i.depName);if(!c||s.has(c.id))continue;const p=n.get(c.id),f={depName:i.depName,depType:i.depType,packageDir:i.packageDir,packageJsonPath:i.packageJsonPath,packageName:i.packageName,specifier:i.specifier};p?p.push(f):n.set(c.id,[f])}const o=[];for(const[i,c]of n){const p=[...new Set(c.map(m=>m.specifier))];if(p.length<2)continue;const f=t.get(i);f&&o.push({family:i,familyLabel:f.label??i,members:c,specifiers:p})}return o},ze=e=>e.startsWith("@types/"),Le=(e,a={})=>{const s=new Set(a.ignoreDeps),t=new Map,r=o=>{const i=t.get(o);if(i!==void 0)return i;try{const p=S(o).private===!0;return t.set(o,p),p}catch{return t.set(o,!1),!1}},n=[];for(const o of e)o.depType==="dependencies"&&ze(o.depName)&&(s.has(o.depName)||r(o.packageJsonPath)&&n.push({childSpecifier:o.specifier,depName:o.depName,packageDir:o.packageDir,packageJsonPath:o.packageJsonPath,packageName:o.packageName}));return n},Ke=(e,a={})=>{const{useEditorconfig:s}=a,t=new Map;for(const n of e){const o=t.get(n.packageJsonPath);o?o.push(n):t.set(n.packageJsonPath,[n])}const r=[];for(const[n,o]of t){const i=S(n),c=i.dependencies;if(typeof c!="object"||c===null)continue;const p=c;i.devDependencies??={};const f=i.devDependencies;for(const m of o){const h=p[m.depName];typeof h=="string"&&(m.depName in f||(f[m.depName]=h),Reflect.deleteProperty(p,m.depName))}Object.keys(p).length===0&&Reflect.deleteProperty(i,"dependencies"),W(n,i,{indent:j(n,{useEditorconfig:s}),overwrite:!0}),r.push(n)}return r},qe=e=>e.startsWith("workspace:"),Ue=(e,a={})=>{const s=a.fixSpecifier??"workspace:*",t=[];for(const r of e)r.isInternal&&(qe(r.specifier)||t.push({depName:r.depName,depType:r.depType,fix:s,packageDir:r.packageDir,packageJsonPath:r.packageJsonPath,packageName:r.packageName,specifier:r.specifier}));return t},Ge=(e,a,s,t)=>{const r=a.split(".");let n=e;for(let c=0;c<r.length-1;c+=1){const p=r[c],f=n[p];(typeof f!="object"||f===null)&&(n[p]={}),n=n[p]}const o=r.at(-1);let i=n[o];(typeof i!="object"||i===null)&&(i={},n[o]=i),i[s]=t},Ye=(e,a={})=>{const{useEditorconfig:s}=a,t=new Map;for(const n of e){const o=t.get(n.packageJsonPath);o?o.push(n):t.set(n.packageJsonPath,[n])}const r=[];for(const[n,o]of t){const i=S(n);for(const c of o)if(c.depType.includes("."))Ge(i,c.depType,c.depName,c.fix);else{const p=i[c.depType];typeof p=="object"&&p!==null&&(p[c.depName]=c.fix)}W(n,i,{indent:j(n,{useEditorconfig:s}),overwrite:!0}),r.push(n)}return r},Xe=new Set(["dependencies","devDependencies","peerDependencies"]),Qe=e=>e.startsWith("catalog:"),Ze=e=>e.startsWith("workspace:"),et=e=>{if(!e.startsWith("catalog:"))return;const a=e.slice(8);return a===""?"default":a},tt=(e,a)=>{if(e.get("default")?.has(a))return"default";const s=[...e.keys()].filter(t=>t!=="default").sort();for(const t of s)if(e.get(t)?.has(a))return t},st=e=>e==="default"?"catalog:":`catalog:${e}`,ot=(e,a)=>{const s=[...e].sort((r,n)=>(r.packageName??r.packageDir).localeCompare(n.packageName??n.packageDir));let t;for(const r of s){const n=L(r.specifier);if(!n)continue;if(!t){t=r;continue}const o=L(t.specifier);if(!o){t=r;continue}const i=K(o,n),c=K(n,o);(a==="highest"&&i||a==="lowest"&&c)&&(t=r)}if(t)return{canonical:t,canonicalSource:t.packageName??t.packageDir}},nt=(e,a={})=>{const s=a.resolve??"highest",t=new Set(a.ignoreDeps),r=[],n=e.filter(i=>i.isInternal||!Xe.has(i.depType)||Ze(i.specifier)||a.dep!==void 0&&i.depName!==a.dep?!1:!t.has(i.depName)),o=new Map;for(const i of n){const c=o.get(i.depName);c?c.push(i):o.set(i.depName,[i])}for(const[i,c]of o){const p=a.pinned?.get(i);if(p!==void 0){for(const u of c)u.specifier!==p&&r.push({canonicalSource:"cli:--pin",depName:i,depType:u.depType,fix:p,packageDir:u.packageDir,packageJsonPath:u.packageJsonPath,packageName:u.packageName,specifier:u.specifier});continue}if(s==="catalog"){const{catalogs:u}=a;if(!u)continue;const k=tt(u,i);if(!k)continue;const J=st(k);for(const P of c)et(P.specifier)!==k&&r.push({canonicalSource:`catalog:${k}`,depName:i,depType:P.depType,fix:J,packageDir:P.packageDir,packageJsonPath:P.packageJsonPath,packageName:P.packageName,specifier:P.specifier});continue}const f=c.filter(u=>!Qe(u.specifier));if(f.length<2||new Set(f.map(u=>u.specifier)).size<=1)continue;const h=ot(f,s);if(!h)continue;const d=h.canonical.specifier;for(const u of f)u.specifier!==d&&r.push({canonicalSource:h.canonicalSource,depName:i,depType:u.depType,fix:d,packageDir:u.packageDir,packageJsonPath:u.packageJsonPath,packageName:u.packageName,specifier:u.specifier})}return r},at=(e,a={})=>{const{useEditorconfig:s}=a,t=new Map;for(const n of e){const o=t.get(n.packageJsonPath);o?o.push(n):t.set(n.packageJsonPath,[n])}const r=[];for(const[n,o]of t){const i=S(n);for(const c of o){const p=i[c.depType];typeof p=="object"&&p!==null&&(p[c.depName]=c.fix)}W(n,i,{indent:j(n,{useEditorconfig:s}),overwrite:!0}),r.push(n)}return r},it=e=>{if(_(I(e,"pnpm-workspace.yaml")))return!0;const a=I(e,"package.json");if(!_(a))return!1;try{return S(a).workspaces!==void 0}catch{return!1}},A=(e,a)=>{const s=new Map;for(const t of e){const r=a(t),n=s.get(r);n?n.push(t):s.set(r,[t])}return s},rt=(e,a,s,t)=>{if(e.length===0){t.info(v("✓ workspace-protocol: no violations"));return}const r=s?"Fixed":"Found",n=s?x:b;t.info(n(w(`${r} ${String(e.length)} workspace-protocol violation${e.length===1?"":"s"}`)));for(const[o,i]of A(e,c=>c.packageName??c.packageJsonPath)){const c=$(a,i[0].packageJsonPath);t.info(` ${w(o)} ${g(`(${c})`)}`);for(const p of i){const f=s?x("→"):b("→");t.info(` ${g(p.depType)} ${p.depName}: ${D(p.specifier)} ${f} ${v(p.fix)}`)}}s||t.info(g(" Run with --fix to rewrite specifiers in place."))},ct=(e,a,s)=>{if(e.length===0){s.info(v("✓ redefine-root: no violations"));return}s.info(b(w(`Found ${String(e.length)} dep${e.length===1?"":"s"} re-declared from root`)));for(const[t,r]of A(e,n=>n.packageName??n.packageJsonPath)){const n=$(a,r[0].packageJsonPath);s.info(` ${w(t)} ${g(`(${n})`)}`);for(const o of r)s.info(` ${g(o.depType)} ${o.depName}: ${D(o.childSpecifier)} ${g(`(root ${o.rootDepType}: ${o.rootSpecifier})`)}`)}s.info(g(" Remove these from child package.json files — root pin will resolve."))},pt=(e,a,s,t)=>{if(e.length===0){t.info(v("✓ workspace-versions: no drift"));return}const r=s?"Fixed":"Found",n=s?x:b;t.info(n(w(`${r} ${String(e.length)} workspace-version drift${e.length===1?"":"s"}`)));for(const[o,i]of A(e,c=>c.depName)){const c=i[0].fix,p=i[0].canonicalSource;t.info(` ${w(o)} ${g(`canonical: ${c} (from ${p})`)}`);for(const f of i){const m=$(a,f.packageJsonPath),h=f.packageName??m,d=s?x("→"):b("→");t.info(` ${h} ${g(`(${m})`)} ${g(f.depType)}: ${D(f.specifier)} ${d} ${v(f.fix)}`)}}s||t.info(g(" Run with --fix to align drifting specifiers."))},ft=(e,a,s)=>{if(e.length===0){s.info(v("✓ banned-deps: no violations"));return}s.info(D(w(`Found ${String(e.length)} banned dep${e.length===1?"":"s"}`)));for(const[t,r]of A(e,n=>n.packageName??n.packageJsonPath)){const n=$(a,r[0].packageJsonPath);s.info(` ${w(t)} ${g(`(${n})`)}`);for(const o of r){const i=o.replacement?` ${g("→")} ${v(o.replacement)}`:"";s.info(` ${g(o.depType)} ${D(o.depName)}${i}`),s.info(` ${g(o.reason)}`)}}},lt=(e,a,s,t)=>{if(e.length===0){t.info(v("✓ catalog-proposals: nothing worth promoting"));return}const r=s?"Added":"Would add",n=s?x:b;t.info(n(w(`${r} ${String(e.length)} catalog entr${e.length===1?"y":"ies"}`)));for(const o of e)t.info(` ${w(o.depName)}: ${v(o.specifier)} ${g(`(${String(o.instanceCount)} packages agree)`)}`);if(!s){const o=be(a,e);if(o){t.info(""),t.info(g("Proposed pnpm-workspace.yaml changes:"));for(const i of o.split(`
10
- `))i.startsWith("+")?t.info(v(i)):i.startsWith("-")?t.info(D(i)):t.info(g(i))}t.info(g(" Run with --fix to write these entries to pnpm-workspace.yaml."))}},ut=(e,a,s,t)=>{if(e.length===0){t.info(v("✓ custom-types: no engines / packageManager / volta drift"));return}const r=s?"Fixed":"Found",n=s?x:b;t.info(n(w(`${r} ${String(e.length)} custom-type drift${e.length===1?"":"s"}`)));for(const[o,i]of A(e,c=>`${c.customType} ${c.depName}`)){const c=i[0].fix,p=i[0].canonicalSource;t.info(` ${w(o)} ${g(`canonical: ${c} (from ${p})`)}`);for(const f of i){const m=$(a,f.packageJsonPath),h=f.packageName??m,d=s?x("→"):b("→");t.info(` ${h} ${g(`(${m})`)}: ${D(f.specifier)} ${d} ${v(f.fix)}`)}}s||t.info(g(" Run with --fix to align engines/packageManager/volta versions."))},dt=(e,a,s,t)=>{if(e.length===0){t.info(v("✓ empty-deps: no empty dependency blocks"));return}const r=s?"Removed":"Found",n=s?x:b;t.info(n(w(`${r} ${String(e.length)} empty dependency block${e.length===1?"":"s"}`)));for(const[o,i]of A(e,c=>c.packageName??c.packageJsonPath)){const c=$(a,i[0].packageJsonPath);t.info(` ${w(o)} ${g(`(${c})`)}`);for(const p of i)t.info(` ${g(p.depType)}: ${D("{}")}`)}s||t.info(g(" Run with --fix to drop empty blocks."))},gt=(e,a,s,t)=>{if(e.length===0){t.info(v('✓ root-private: root package.json is "private": true'));return}const r=s?"Set":"Missing",n=s?x:D;for(const o of e){const i=$(a,o.packageJsonPath);if(t.info(n(w(`${r} "private": true on root ${g(`(${i})`)}`))),!s){const c=o.rawValue===void 0?"absent":JSON.stringify(o.rawValue);t.info(` ${g("current:")} ${D(c)}`)}}s||t.info(g(' Run with --fix to set "private": true.'))},mt=(e,a,s,t)=>{if(e.length===0){t.info(v("✓ root-package-manager: packageManager field present"));return}const r=s?"Set":"Missing",n=s?x:D;for(const o of e){const i=$(a,o.packageJsonPath);t.info(n(w(`${r} packageManager on root ${g(`(${i})`)}`))),!s&&!o.suggested&&t.info(g(" no canonical specifier configured (set policy.rootPackageManager.suggested to enable --fix)"))}s||t.info(g(' e.g. "packageManager": "pnpm@10.32.1"'))},ht=(e,a,s,t)=>{if(e.length===0){t.info(v("✓ root-deps: no runtime dependencies on private root"));return}const r=s?"Moved":"Found",n=s?x:b;for(const o of e){const i=$(a,o.packageJsonPath);t.info(n(w(`${r} ${String(o.depNames.length)} runtime dep${o.depNames.length===1?"":"s"} on private root ${g(`(${i})`)}`)));for(const c of o.depNames)t.info(` ${D(c)}`)}s||t.info(g(" Run with --fix to move them to devDependencies."))},kt=(e,a)=>{if(e.length===0){a.info(v("✓ missing-package-json: every workspace dir has a package.json"));return}a.info(b(w(`Found ${String(e.length)} workspace dir${e.length===1?"":"s"} without a package.json`)));for(const s of e)a.info(` ${D(s.packageDir)}`);a.info(g(" Either delete the directory or scaffold a package.json (vis create)."))},yt=(e,a,s)=>{if(e.length===0){s.info(v("✓ dead-workspace-pattern: every workspace pattern matches at least one package"));return}const t=a?"Removed":"Found",r=a?x:b;s.info(r(w(`${t} ${String(e.length)} unmatched workspace pattern${e.length===1?"":"s"}`)));for(const[n,o]of A(e,i=>i.source)){s.info(` ${w(n)}`);for(const i of o)s.info(` ${D(i.pattern)}`)}a||s.info(g(" Run with --fix to drop dead patterns."))},Pt=(e,a,s,t)=>{if(e.length===0){t.info(v("✓ types-in-deps: no @types/* in dependencies of private packages"));return}const r=s?"Moved":"Found",n=s?x:b;t.info(n(w(`${r} ${String(e.length)} @types/* dep${e.length===1?"":"s"} in dependencies`)));for(const[o,i]of A(e,c=>c.packageName??c.packageJsonPath)){const c=$(a,i[0].packageJsonPath);t.info(` ${w(o)} ${g(`(${c})`)}`);for(const p of i)t.info(` ${D(p.depName)} ${g(p.childSpecifier)}`)}s||t.info(g(" Run with --fix to move them to devDependencies."))},$t=(e,a,s)=>{if(e.length===0){s.info(v("✓ similar-deps: every related dep family is in sync"));return}s.info(b(w(`Found ${String(e.length)} family${e.length===1?"":" families"} with version drift`)));for(const t of e){s.info(` ${w(t.familyLabel)} ${g(`(${t.specifiers.join(", ")})`)}`);for(const r of t.members){const n=$(a,r.packageJsonPath),o=r.packageName??n;s.info(` ${o} ${g(`(${n})`)} ${g(r.depType)}: ${D(r.depName)}@${b(r.specifier)}`)}}s.info(g(" Pick a single specifier per family and align by hand — auto-fix is unsafe across name boundaries."))},wt=(e,a,s,t,r)=>{let n=!0;const o=i=>{n||r.info(""),n=!1,i()};t.workspaceProtocol&&o(()=>{rt(e.workspaceProtocol??[],a,s.workspaceProtocol,r)}),t.redefineRoot&&o(()=>{ct(e.redefineRoot??[],a,r)}),t.workspaceVersions&&o(()=>{pt(e.workspaceVersions??[],a,s.workspaceVersions,r)}),t.customTypes&&o(()=>{ut(e.customTypes??[],a,s.customTypes,r)}),e.catalogProposals!==void 0&&o(()=>{lt(e.catalogProposals??[],a,s.catalogProposals,r)}),t.bannedDeps&&o(()=>{ft(e.bannedDeps??[],a,r)}),t.emptyDeps&&o(()=>{dt(e.emptyDeps??[],a,s.emptyDeps,r)}),t.rootPrivate&&o(()=>{gt(e.rootPrivate??[],a,s.rootPrivate,r)}),t.rootPackageManager&&o(()=>{mt(e.rootPackageManager??[],a,s.rootPackageManager,r)}),t.rootDeps&&o(()=>{ht(e.rootDeps??[],a,s.rootDeps,r)}),t.missingPackageJson&&o(()=>{kt(e.missingPackageJson??[],r)}),t.deadWorkspacePatterns&&o(()=>{yt(e.deadWorkspacePatterns??[],s.deadWorkspacePatterns,r)}),t.typesInDeps&&o(()=>{Pt(e.typesInDeps??[],a,s.typesInDeps,r)}),t.similarDeps&&o(()=>{$t(e.similarDeps??[],a,r)})},vt=(e,a)=>{for(const s of e.workspaceProtocol??[]){const t=$(a,s.packageJsonPath);process.stdout.write(`workspace-protocol ${t} ${s.depType} ${s.depName} ${s.specifier} → ${s.fix}
11
- `)}for(const s of e.redefineRoot??[]){const t=$(a,s.packageJsonPath);process.stdout.write(`redefine-root ${t} ${s.depType} ${s.depName} ${s.childSpecifier}
12
- `)}for(const s of e.workspaceVersions??[]){const t=$(a,s.packageJsonPath);process.stdout.write(`workspace-versions ${t} ${s.depType} ${s.depName} ${s.specifier} → ${s.fix}
13
- `)}for(const s of e.customTypes??[]){const t=$(a,s.packageJsonPath);process.stdout.write(`custom-types ${t} ${s.customType} ${s.depName} ${s.specifier} → ${s.fix}
14
- `)}for(const s of e.bannedDeps??[]){const t=$(a,s.packageJsonPath);process.stdout.write(`banned-deps ${t} ${s.depType} ${s.depName} ${s.reason}
15
- `)}for(const s of e.catalogProposals??[])process.stdout.write(`catalog-proposal ${s.catalogName} ${s.depName} ${s.specifier} ${String(s.instanceCount)}
16
- `);for(const s of e.emptyDeps??[]){const t=$(a,s.packageJsonPath);process.stdout.write(`empty-deps ${t} ${s.depType}
17
- `)}for(const s of e.rootPrivate??[]){const t=$(a,s.packageJsonPath);process.stdout.write(`root-private ${t}
18
- `)}for(const s of e.rootPackageManager??[]){const t=$(a,s.packageJsonPath);process.stdout.write(`root-package-manager ${t} ${s.suggested??""}
19
- `)}for(const s of e.rootDeps??[]){const t=$(a,s.packageJsonPath);for(const r of s.depNames)process.stdout.write(`root-deps ${t} ${r}
20
- `)}for(const s of e.missingPackageJson??[])process.stdout.write(`missing-package-json ${s.packageDir}
21
- `);for(const s of e.deadWorkspacePatterns??[])process.stdout.write(`dead-workspace-pattern ${s.source} ${s.pattern}
22
- `);for(const s of e.typesInDeps??[]){const t=$(a,s.packageJsonPath);process.stdout.write(`types-in-deps ${t} ${s.depName} ${s.childSpecifier}
23
- `)}for(const s of e.similarDeps??[])for(const t of s.members){const r=$(a,t.packageJsonPath);process.stdout.write(`similar-deps ${s.family} ${r} ${t.depType} ${t.depName} ${t.specifier}
24
- `)}},Dt=(e,a,s,t)=>{const r=o=>({...o,packageJsonPath:$(a,o.packageJsonPath)}),n={fixed:s};if(t.workspaceProtocol){const o=(e.workspaceProtocol??[]).map(i=>r(i));n.workspaceProtocol={issues:o,total:o.length}}if(t.redefineRoot){const o=(e.redefineRoot??[]).map(i=>r(i));n.redefineRoot={issues:o,total:o.length}}if(t.workspaceVersions){const o=(e.workspaceVersions??[]).map(i=>r(i));n.workspaceVersions={issues:o,total:o.length}}if(t.customTypes){const o=(e.customTypes??[]).map(i=>r(i));n.customTypes={issues:o,total:o.length}}if(t.bannedDeps){const o=(e.bannedDeps??[]).map(i=>r(i));n.bannedDeps={issues:o,total:o.length}}if(e.catalogProposals!==void 0){const o=e.catalogProposals;n.catalogProposals={proposals:o,total:o.length}}if(t.emptyDeps){const o=(e.emptyDeps??[]).map(i=>r(i));n.emptyDeps={issues:o,total:o.length}}if(t.rootPrivate){const o=(e.rootPrivate??[]).map(i=>r(i));n.rootPrivate={issues:o,total:o.length}}if(t.rootPackageManager){const o=(e.rootPackageManager??[]).map(i=>r(i));n.rootPackageManager={issues:o,total:o.length}}if(t.rootDeps){const o=(e.rootDeps??[]).map(i=>r(i));n.rootDeps={issues:o,total:o.length}}if(t.missingPackageJson){const o=e.missingPackageJson??[];n.missingPackageJson={issues:o,total:o.length}}if(t.deadWorkspacePatterns){const o=e.deadWorkspacePatterns??[];n.deadWorkspacePatterns={issues:o,total:o.length}}if(t.typesInDeps){const o=(e.typesInDeps??[]).map(i=>r(i));n.typesInDeps={issues:o,total:o.length}}if(t.similarDeps){const o=(e.similarDeps??[]).map(i=>({...i,members:i.members.map(c=>({...c,packageJsonPath:$(a,c.packageJsonPath)}))}));n.similarDeps={issues:o,total:o.length}}process.stdout.write(`${JSON.stringify(n,void 0,2)}
25
- `)},T=(e,a,s)=>{const t=e[a];return typeof t=="boolean"?t:e[s]===!0},bt=e=>{const a=e,s=(e.ban?.length??0)>0,t=(e.pin?.length??0)>0,r=T(a,"workspaceProtocol","workspace-protocol"),n=T(a,"redefineRoot","redefine-root"),o=T(a,"bannedDeps","banned-deps"),i=T(a,"workspaceVersions","workspace-versions"),c=T(a,"customTypes","custom-types"),p=T(a,"emptyDeps","empty-deps"),f=T(a,"rootPrivate","root-private"),m=T(a,"rootPackageManager","root-package-manager"),h=T(a,"rootDeps","root-deps"),d=T(a,"missingPackageJson","missing-package-json"),u=T(a,"deadWorkspacePatterns","dead-workspace-patterns"),k=T(a,"typesInDeps","types-in-deps"),J=T(a,"similarDeps","similar-deps");return r||n||o||i||c||p||f||m||h||d||u||k||J||s||t?{bannedDeps:o||s,customTypes:c,deadWorkspacePatterns:u,emptyDeps:p,missingPackageJson:d,redefineRoot:n,rootDeps:h,rootPackageManager:m,rootPrivate:f,similarDeps:J,typesInDeps:k,workspaceProtocol:r,workspaceVersions:i||t}:{bannedDeps:!0,customTypes:!0,deadWorkspacePatterns:!0,emptyDeps:!0,missingPackageJson:!0,redefineRoot:!0,rootDeps:!0,rootPackageManager:!0,rootPrivate:!0,similarDeps:!0,typesInDeps:!0,workspaceProtocol:!0,workspaceVersions:!0}},Nt=e=>{const a=new Map;for(const s of e??[]){const t=s.lastIndexOf("@");if(t<=0||t===s.length-1)throw new Error(`Invalid --pin "${s}". Use: name@<specifier> (e.g. react@^18.2.0).`);const r=s.slice(0,t),n=s.slice(t+1);a.set(r,n)}return a},Tt=new Set(["catalog","highest","lowest"]),xt=e=>{if(e===void 0)return"highest";if(!Tt.has(e))throw new Error(`Invalid --resolve "${e}". Use: highest, lowest, or catalog.`);return e},M=(e,a)=>e?a===void 0||a===!0:!1,Jt={"custom-types":"policy.customTypes.autofix","workspace-protocol":"policy.workspaceProtocol.autofix","workspace-versions":"policy.workspaceVersions.autofix"},B=(e,a,s,t)=>{const r=Jt[a],n=s==="prompt"?`${r} = "prompt" (interactive mode not yet implemented; report-only)`:`${r} = false`,o=`Set "${r}": true (or remove it) to enable rewrites.`;e.warn(`${a}: ${String(t)} issue${t===1?"":"s"} not rewritten — ${n}. ${o}`)},Ft=async({logger:e,options:a,visConfig:s,workspaceRoot:t})=>{if(!t)throw new Error("Could not determine workspace root. Run this command inside a monorepo.");const r=t,n=a.fix??!1,o=a.format??"human",i=a.quiet??!1;if(!["human","json","minimal"].includes(o))throw new Error(`Invalid --format "${o}". Use: human, json, or minimal.`);const c=bt(a),p=s?.policy??{},f=s?.editorconfig??!0,m=Nt(a.pin),h=a.ban??[];(a.dep!==void 0||a.resolve!==void 0)&&!c.workspaceVersions&&!i&&e.warn("--dep / --resolve only apply to --workspace-versions; ignored.");const d=ne(r),u={},k={catalogProposals:!1,customTypes:!1,deadWorkspacePatterns:!1,emptyDeps:!1,rootDeps:!1,rootPackageManager:!1,rootPrivate:!1,typesInDeps:!1,workspaceProtocol:!1,workspaceVersions:!1},J=it(r);let P=0;if(c.workspaceProtocol){const l=Ue(d,{fixSpecifier:a.fixSpecifier}),y=M(n,p.workspaceProtocol?.autofix);y&&l.length>0&&(Ye(l,{useEditorconfig:f}),k.workspaceProtocol=!0),u.workspaceProtocol=l,y||(P+=l.length),n&&!y&&l.length>0&&!i&&B(e,"workspace-protocol",p.workspaceProtocol?.autofix,l.length)}if(c.redefineRoot){const l=Me(d,{ignoreDeps:p.redefineRoot?.ignore});u.redefineRoot=l,P+=l.length}if(c.workspaceVersions){const l=xt(a.resolve??p.workspaceVersions?.resolve),y=l==="catalog"?ue(r):void 0;l==="catalog"&&(!y||y.size===0)&&!i&&e.warn("--resolve catalog: no catalog found in pnpm-workspace.yaml or root package.json — nothing to align.");const N=nt(d,{catalogs:y,dep:a.dep,ignoreDeps:p.workspaceVersions?.ignore,pinned:m.size>0?m:void 0,resolve:l}),R=M(n,p.workspaceVersions?.autofix);if(R&&N.length>0&&(at(N,{useEditorconfig:f}),k.workspaceVersions=!0),u.workspaceVersions=N,R||(P+=N.length),n&&!R&&N.length>0&&!i&&B(e,"workspace-versions",p.workspaceVersions?.autofix,N.length),a.proposeMin!==void 0){if(l!=="catalog"&&!i)e.warn("--propose-min only runs under --resolve catalog; ignored.");else if(l==="catalog"){const C=ve(d,{catalogs:y,ignoreDeps:p.workspaceVersions?.ignore,min:a.proposeMin});R&&C.length>0&&(De(r,C),k.catalogProposals=!0),u.catalogProposals=C}}}if(c.customTypes){const l=p.customTypes?.extraTypes,y=ae(l);if(y.length>0){for(const X of y)e.error(`policy.customTypes.${X}`);process.exitCode=1;return}const N=ie(r,l),C=(a.resolve??p.customTypes?.resolve)==="lowest"?"lowest":"highest",E=re(N,{dep:a.dep,ignoreDeps:p.customTypes?.ignore,resolve:C}),O=M(n,p.customTypes?.autofix);O&&E.length>0&&(ce(E,{useEditorconfig:f}),k.customTypes=!0),u.customTypes=E,O||(P+=E.length),n&&!O&&E.length>0&&!i&&B(e,"custom-types",p.customTypes?.autofix,E.length)}if(c.bannedDeps){const l={...p.bannedDeps};for(const N of h)l[N]={reason:"banned via --ban CLI flag"};Object.keys(l).length===0&&a.bannedDeps&&!i&&e.warn("--banned-deps: no policy.bannedDeps in vis config, nothing to check.");const y=ke(d,l);u.bannedDeps=y,P+=y.length}if(c.emptyDeps){const l=Je(r,{ignoreBlocks:p.emptyDeps?.ignoreBlocks}),y=M(n,p.emptyDeps?.autofix);y&&l.length>0&&(Se(l,{useEditorconfig:f}),k.emptyDeps=!0),u.emptyDeps=l,y||(P+=l.length)}if(c.rootPrivate){const l=Ce(r,J),y=M(n,p.rootPrivate?.autofix);y&&l.length>0&&(Ve(l,{useEditorconfig:f}),k.rootPrivate=!0),u.rootPrivate=l,y||(P+=l.length)}if(c.rootPackageManager){const l=Ee(r,J,{suggested:p.rootPackageManager?.suggested}),y=M(n,p.rootPackageManager?.autofix);y&&l.some(N=>N.suggested!==void 0)&&(Re(l,{useEditorconfig:f}),k.rootPackageManager=!0),u.rootPackageManager=l,(!y||!k.rootPackageManager)&&(P+=l.filter(N=>N.suggested===void 0||!k.rootPackageManager).length)}if(c.rootDeps){const l=We(r,J),y=M(n,p.rootDeps?.autofix);y&&l.length>0&&(je(l,{useEditorconfig:f}),k.rootDeps=!0),u.rootDeps=l,y||(P+=l.length)}if(c.missingPackageJson){const l=le(r);u.missingPackageJson=l,P+=l.length}if(c.deadWorkspacePatterns){const l=Ne(r),y=M(n,p.deadWorkspacePatterns?.autofix);y&&l.length>0&&(Te(l,{useEditorconfig:f}),k.deadWorkspacePatterns=!0),u.deadWorkspacePatterns=l,y||(P+=l.length)}if(c.typesInDeps){const l=Le(d,{ignoreDeps:p.typesInDeps?.ignore}),y=M(n,p.typesInDeps?.autofix);y&&l.length>0&&(Ke(l,{useEditorconfig:f}),k.typesInDeps=!0),u.typesInDeps=l,y||(P+=l.length)}if(c.similarDeps){const l=He(d,{extraFamilies:p.similarDeps?.extraFamilies,ignoreFamilies:p.similarDeps?.ignoreFamilies});u.similarDeps=l,P+=l.length}i||(o==="json"?Dt(u,r,k,c):o==="minimal"?vt(u,r):wt(u,r,k,c,e)),P>0&&(process.exitCode=1)};export{Ft as default};
1
+ import{createRequire as Ke}from"node:module";import{b as C,F as x,X as Xe,J as Ee,q as Ze}from"../packem_shared/index.server-Ca_EEVfw.js";import{m as Qe,v as E,U as I,a as M,e as V,z as et}from"../packem_shared/index-0dnGN3GP.js";import{wholeMatchFingerprint as tt,maskFinding as ee,fingerprint as H,legacyFingerprint as st,baselineKeys as ce,GIT_CONFIG_OVERRIDES as nt,DIFF_HARDENING_FLAGS as it,gitleaksIgnoreFingerprint as K,toSarifUri as rt,CONFIDENCE_LEVELS as le,DEFAULT_MAX_FILE_SIZE as O,MAX_ARCHIVE_DEPTH as ot,listRules as Te,listRequiredValidators as at,scan as ct,isPathExcluded as lt,scanStringDetailed as dt,scanGitHistoryDetailed as ut,scanDetailed as ht,scanGitStaged as pt,scanFilesDetailed as ft,inspectRuleset as mt}from"@visulima/secret-scanner";import{V as $}from"../packem_shared/vis-user-error-pMP1p7q1.js";import{a3 as gt,a4 as de,p as T}from"./cli-main.js";import{E as wt,A as vt}from"../packem_shared/getRandomSpinner-DX11qCB2-CoIsn7ZU.js";import{y as te}from"../packem_shared/isAccessibleSync-DYKTrrvc-CBsMZhj-.js";import{p as Rt}from"../packem_shared/package-version-lWlrF9Wk.js";import{w as z}from"../packem_shared/github-workflow-command-Bn0MgB78.js";import{e as W,c as Dt}from"../packem_shared/junit-audit-CuJShWCH.js";let Ye;const Je=e=>(Ye??=Ke(import.meta.url))(e),N=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,L=e=>{if(typeof N<"u"&&N.versions&&N.versions.node){const[t,s]=N.versions.node.split(".").map(Number);if(t>22||t===22&&s>=3||t===20&&s>=16)return N.getBuiltinModule(e)}return Je(e)},{createRequire:$t}=L("node:module"),{mkdirSync:yt,writeFileSync:X,openSync:Ae,fchmodSync:je,closeSync:Le,realpathSync:G,lstatSync:Me,fstatSync:bt,fchownSync:St,fsyncSync:kt,renameSync:xt,rmSync:It,readFileSync:Ft}=L("node:fs"),{randomUUID:Ct,createHash:Et}=L("node:crypto"),{resolve:ue,relative:Ne,join:Tt,dirname:At,basename:jt,sep:Lt,isAbsolute:Mt}=L("node:path"),{execFileSync:Nt}=L("node:child_process"),{pathToFileURL:De}=L("node:url");let Bt;const _t=e=>(Bt??=$t(import.meta.url))(e),D=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,Ut=e=>{if(typeof D<"u"&&D.versions&&D.versions.node){const[t,s]=D.versions.node.split(".").map(Number);if(t>22||t===22&&s>=3||t===20&&s>=16)return D.getBuiltinModule(e)}return _t(e)},{styleText:Ot}=Ut("node:util"),qt={error:"✖",info:"ℹ",success:"✓",warning:"⚠"},Pt=()=>{const{env:e}=process;return!!e.CI||e.CONTINUOUS_INTEGRATION==="true"||"BUILD_NUMBER"in e||"RUN_ID"in e},zt=/\u001B\[[\d;]*[a-z]/gi,Wt=e=>[...e.replaceAll(zt,"")].length,Vt=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?s=>s:s=>Ot(t,s)};class Ht{#r=0;#l;#e=!1;#i="";#o="";#g=0;#d=0;#t;#s;#u="";#a;#f;#n;#y;#h=0;#c;#b;constructor(t={},s){if(t.frames)this.#a=t.frames;else{const n=t.name??"dots",r=vt(n);if(!r)throw new Error(`Unknown spinner "${n}". Pass a custom \`frames\` set or use one of: ${wt().join(", ")}.`);this.#a=r}this.#f=t.verbose!==!1,this.#i=t.prefixText??"",this.#t=s,this.#n=t.stream??process.stderr,this.#y=s?!0:this.#n.isTTY&&!Pt(),this.#b={...qt,...t.icons},typeof t.style=="function"?this.#c=t.style:t.style&&(this.#c=Vt(t.style))}get elapsedTime(){return this.#g===0?0:(this.#d||Date.now())-this.#g}get text(){return this.#o}set text(t){this.#o=t,this.#e&&this.#w()}get prefixText(){return this.#i}set prefixText(t){this.#i=t,this.#e&&this.#w()}get isRunning(){return this.#e}setInteractiveManager(t){this.#t=t}setMultiSpinner(t){this.#s=t}tick(){this.#e&&(this.#r=(this.#r+1)%this.#a.frames.length)}start(t,s){return this.#e?this:this.#f?(this.#e=!0,this.#g=Date.now(),this.#d=0,this.#r=0,this.#u="",t&&(this.#o=t),s?.prefixText&&(this.#i=s.prefixText),this.#s?(this.#s.renderAll(),this):(this.#t?(this.#t.hook(),this.#S(),this.#$()):(this.#k(),this.#$()),this)):this}stop(){if(this.#e){if(this.#p(),this.#e=!1,this.#d=Date.now(),this.#u="",this.#s){this.#s.renderAll();return}this.#t?(this.#t.erase("stdout"),this.#t.unhook(!1)):this.#v()}}stopAndPersist(t){if(!this.#e||(this.#p(),this.#e=!1,this.#d=Date.now(),!this.#f))return;const s=t?.prefixText??this.#i,n=t?.text??this.#o;let r=t?.symbol??"";s&&(r=r?`${s} ${r}`:s),n&&(r=r?`${r} ${n}`:n),this.#x(r)}succeed(t){this.#m("success",t)}failed(t){this.#m("error",t)}warn(t){this.#m("warning",t)}info(t){this.#m("info",t)}pause(){this.#p()}resume(){this.#e&&(this.#p(),this.#s||this.#$())}getFrameOutput(){if(!this.#e&&this.#u)return this.#u;const t=this.#a.frames[this.#r];let s=this.#c?this.#c(t):t;return this.#i&&(s=`${this.#i} ${s}`),this.#o&&(s=`${s} ${this.#o}`),s}#$(){this.#y&&(this.#l=setInterval(()=>{this.#e&&(this.#r=(this.#r+1)%this.#a.frames.length,this.#w())},this.#a.interval),this.#l.unref())}#p(){this.#l&&(clearInterval(this.#l),this.#l=void 0)}#w(){this.#s?this.#s.renderAll():this.#t?this.#S():this.#k()}#S(){this.#t&&this.#t.update("stdout",[this.getFrameOutput()])}#k(){const t=this.getFrameOutput();if(this.#v(),this.#n.isTTY){this.#n.write(t);const s=this.#n.columns||80;this.#h=Math.max(1,Math.ceil(Wt(t)/s))}else this.#n.write(`${t}
2
+ `),this.#h=0}#v(){if(this.#h>0&&this.#n.isTTY){for(let t=1;t<this.#h;t+=1)this.#n.write("\x1B[1A\x1B[2K");this.#n.write("\r\x1B[K")}this.#h=0}#x(t){this.#u=t,this.#s?this.#s.renderAll():this.#t?(this.#t.update("stdout",[t]),this.#t.unhook(!1)):(this.#v(),this.#n.write(`${t}
3
+ `))}#m(t,s){if(!this.#e||(this.#p(),this.#e=!1,this.#d=Date.now(),!this.#f))return;let n="";const r=this.#b[t];r&&(n=this.#c?this.#c(r):r),this.#i&&(n=`${this.#i} ${n}`),s&&(n=`${n} ${s}`),this.#x(n)}}const Be=(e={})=>{const t=new gt(new de(process.stdout),new de(process.stderr));return new Ht(e,t)},he=384,_e=(e,t,s)=>{if(yt(Qe(e),{recursive:!0}),!s){X(e,t);return}const n=Ae(e,"w",he);try{je(n,he),X(n,t)}finally{Le(n)}},Ue=(e,t)=>{if(!E(e))return e;const s=M(t,e);return s===""||s.startsWith("..")?e:s},Z=e=>{try{return G(e)}catch{return e}},Oe=(e,t)=>{const s=M(e,t);return s===""||s.startsWith("..")||E(s)?t:s},j=(e,t)=>{const s={...e,file:Ue(e.file,t)};return delete s.root,s},se=e=>{if(!te(e))return[];try{const t=Rt(e);return Array.isArray(t)?t:[]}catch{return[]}},ne=(e,t,s)=>{const n=E(e)?e:I(t,e);return Oe(Z(s),n)},pe=(e,t,s)=>{const n=ne(e.file,t,s);return n===e.file?e:{...e,file:n}},Gt=(e,t,s)=>{const n=e.files.map(r=>({...r,file:ne(r.file,t,s)}));return{...e,files:n}},Kt=(e,t,s)=>{const n=Z(t),r=Z(s);return se(e).flatMap(i=>{const a=Oe(r,E(i.file)?i.file:I(n,i.file));return a===i.file?[i]:[i,{...i,file:a}]})},fe=e=>[...ce(e),...ce(ee(e))],_=e=>typeof e=="string"?e:"",ie=e=>{const t={...e,match:_(e.match),secret:_(e.secret)};return Array.isArray(e.requiredFindings)?t.requiredFindings=e.requiredFindings.map(s=>({...s,match:_(s.match),secret:_(s.secret)})):delete t.requiredFindings,t},re=e=>ee(ie(e)),me=e=>[H(ie(e)),st(e),H(re(e))],Yt=(e,t,s)=>{const n=se(t).map(o=>j(o,s)),r=new Set(n.flatMap(o=>me(o))),i=e.map(o=>j(o,s)),a=new Set(i.flatMap(o=>fe(o))),c=o=>fe(o).some(d=>r.has(d));return{fresh:i.filter(o=>!c(o)),resolved:n.filter(o=>!me(o).some(d=>a.has(d))),surviving:i.filter(o=>c(o))}},ge=e=>H(re(e)),Jt=e=>{const t=_(e.secret);return re(e).secret===t},qe=(e,t,s,n={})=>{const r=e.map(a=>j(a,s));let i;if(n.replace)i=r;else{const a=new Set(r.filter(l=>l.secret!==l.match).map(l=>tt(ee(l)))),c=se(t).map(l=>j(l,s)).filter(l=>!a.has(ge(l))),o=new Set,d=new Set,p=new Set;i=[];for(const l of[...c,...r]){const b=H(ie(l)),h=ge(l),u=Jt(l);o.has(b)||(u?d.has(h):p.has(h))||(o.add(b),d.add(h),u&&p.add(h),i.push(l))}}return _e(t,`${JSON.stringify(i,null,4)}
4
+ `,!0),i.length},Xt="********",Pe="<REDACTED>",Zt=Buffer.from(Pe,"utf8"),$e=(e,t)=>{const s=Ne(e,t);return s===".."||s.startsWith(`..${Lt}`)||Mt(s)},Qt=(e,t)=>{let s=1;for(let n=0;n<t;n++)e[n]===10&&s++;return s},es=(e,t,{gid:s,mode:n,uid:r})=>{const i=Tt(At(e),`.${jt(e)}.vis-fix-${process.pid}-${Ct()}`);try{const a=Ae(i,"wx",n);try{const c=bt(a);(c.uid!==r||c.gid!==s)&&St(a,r,s),je(a,n),X(a,t),kt(a)}finally{Le(a)}xt(i,e)}catch(a){throw It(i,{force:!0}),a}},we=(e,t)=>Ne(e,t)||t,ze=e=>{try{const t=Me(e);return t.isSymbolicLink()?{reason:"symbolic link"}:t.isFile()?t.nlink>1?{reason:"hard-linked file"}:(t.mode&146)===0?{reason:"read-only file"}:{bytes:Ft(e),dev:t.dev,gid:t.gid,ino:t.ino,mode:t.mode%4096,mtimeMs:t.mtimeMs,size:t.size,uid:t.uid}:{reason:"not a regular file"}}catch{return{reason:"file unavailable"}}},ts=(e,t)=>{try{const s=ze(e);return!("reason"in s)&&G(e)===e&&s.dev===t.dev&&s.ino===t.ino&&s.mode===t.mode&&s.uid===t.uid&&s.gid===t.gid&&s.size===t.size&&s.mtimeMs===t.mtimeMs&&s.bytes.equals(t.bytes)}catch{return!1}},ss=({matchEnd:e,matchStart:t,secretEnd:s,secretStart:n},r,i)=>Number.isInteger(t)&&Number.isInteger(e)&&Number.isInteger(n)&&Number.isInteger(s)&&t>=0&&n>=t&&s>n&&s<=e&&e<=r.length&&r.subarray(n,s).equals(i),ns=e=>{const t=[];for(const{end:s,ruleId:n,start:r}of[...e].sort((i,a)=>i.start-a.start||i.end-a.end)){const i=t.at(-1);i!==void 0&&r<i.end?(i.end=Math.max(i.end,s),i.ruleIds.add(n)):t.push({end:s,ruleIds:new Set([n]),start:r})}return t},is=(e,t)=>{const s=[];let n=0;for(const{end:r,start:i}of t)s.push(e.subarray(n,i),Zt),n=r;return s.push(e.subarray(n)),Buffer.concat(s)},rs=(e,t,s,n=t)=>{const r=[],i=new Map,a=new Map,c=ue(t,n);let o;try{o=G(t)}catch{o=t}const d=h=>{const u=ue(c,h),f=we(t,u);if($e(t,u))return{display:f,reason:"outside workspace"};let g;try{if(Me(u).isSymbolicLink())return{display:f,reason:"symbolic link"};g=G(u)}catch{return{display:f,reason:"file unavailable"}}if($e(o,g))return{display:f,reason:"outside workspace"};let w=a.get(g);return w===void 0&&(w=ze(g),a.set(g,w)),"reason"in w?{display:f,reason:w.reason}:{display:f,file:w,path:g}};for(const h of e){if(h.sourceSpan===void 0){r.push({file:h.file,line:h.startLine,reason:h.spanUnavailableReason??"no trusted byte span",ruleId:h.ruleId});continue}const u=d(h.file);for(const f of[h,...h.requiredFindings??[]]){const g=(S,y)=>{r.push({file:y,line:f.startLine,reason:S,ruleId:f.ruleId})},{sourceSpan:w}=f;if(w===void 0){g(f.spanUnavailableReason??"no trusted byte span",h.file);continue}if(f.secret.length===0){g("empty secret",h.file);continue}if("reason"in u){g(u.reason,u.display);continue}if(!ss(w,u.file.bytes,Buffer.from(f.secret,"utf8"))){g("span does not match file",u.display);continue}const v=i.get(u.path)??{file:u.file,spans:[]};v.spans.push({end:w.secretEnd,ruleId:f.ruleId,start:w.secretStart}),i.set(u.path,v)}}const p=[];let l=0,b=0;for(const[h,{file:u,spans:f}]of i){const g=ns(f),w=we(t,h),v=g.map(({ruleIds:y,start:m})=>({line:Qt(u.bytes,m),ruleIds:y}));if(!s){let y;if(ts(h,u))try{es(h,is(u.bytes,g),u)}catch{y="write failed"}else y="file changed during scan";if(y!==void 0){for(const{line:m,ruleIds:k}of v)r.push({file:w,line:m,reason:y,ruleId:[...k].sort().join(", ")});continue}}l++,b+=g.length;const S=new Map;for(const{line:y,ruleIds:m}of v)S.set(y,new Set([...S.get(y)??[],...m]));for(const[y,m]of S)p.push({file:w,line:y,ruleId:[...m].sort().join(", ")})}return p.sort((h,u)=>h.file.localeCompare(u.file)||h.line-u.line),r.sort((h,u)=>h.file.localeCompare(u.file)||h.line-u.line||h.reason.localeCompare(u.reason)),{changedFiles:l,edits:p,replacements:b,skipped:r}},Q=(e,t)=>{try{return Nt("git",[...nt,...t],{cwd:e,encoding:"utf8",stdio:["ignore","pipe","pipe"]})}catch{return""}},os=e=>e.split("\0").filter(Boolean),ve=(e,t)=>{if(t.startsWith("-"))throw new $(`--since "${t}" looks like a flag, not a git ref.`);const s=I(e,Q(e,["rev-parse","--show-cdup"]).trim()),n=i=>os(Q(e,["diff","-z","--name-only","--diff-filter=ACMR",...it,i,"--"]));let r=n(`${t}...HEAD`);return r.length===0&&(r=n(t)),r.map(i=>E(i)?i:V(s,i))},ye=e=>Q(e,["rev-parse","--show-toplevel"]).trim().length>0,as=/^[\t\r+=@-]/,F=e=>{const t=as.test(e)?`'${e}`:e;return/[\n\r",]/.test(t)?`"${t.replaceAll('"','""')}"`:t},cs=["RuleID","Commit","File","Secret","Match","StartLine","EndLine","StartColumn","EndColumn","Author","Message","Date","Email","Fingerprint","Tags"],ls=e=>{const t=e.map(s=>[F(s.ruleId),F(s.commit?.sha??""),F(s.file),F(s.secret),F(s.match),String(s.startLine),String(s.endLine),String(s.startColumn),String(s.endColumn),F(s.commit?.authorName??""),F(s.commit?.message??""),F(s.commit?.date??""),F(s.commit?.authorEmail??""),F(K(s)),F(s.tags.join(" "))].join(","));return`${[cs.join(","),...t].join(`\r
5
+ `)}\r
6
+ `},ds=e=>{const t=[...e];return t.length<=6?"******":`${t.slice(0,3).join("")}${"*".repeat(t.length-6)}${t.slice(-3).join("")}`},us=(e,t={})=>{const s=(t.now??new Date).toISOString().replace(/\.\d{3}Z$/,""),n=String(e.length),r=e.map(i=>{const a=`${i.file}:${String(i.startLine)}:${String(i.startColumn)}`,c=[`Rule: ${i.ruleId}`,`File: ${a}`,...i.commit===void 0?[]:[`Commit: ${i.commit.sha}`,`Author: ${i.commit.authorName} <${i.commit.authorEmail}>`],`Secret: ${ds(i.secret)}`,`Fingerprint: ${K(i)}`].join(`
7
+ `),o=`<failure type="${W(i.ruleId)}" message="${W(i.description||i.ruleId)}">${Dt(c)}</failure>`;return[` <testcase classname="${W(i.file)}" name="${W(`${i.ruleId} at ${a}`)}">`,` ${o}`," </testcase>",""].join(`
8
+ `)}).join("");return['<?xml version="1.0" encoding="UTF-8"?>',`<testsuites name="vis-secrets" tests="${n}" failures="${n}" skipped="0" errors="0" time="0">`,` <testsuite name="secrets" tests="${n}" failures="${n}" skipped="0" errors="0" timestamp="${s}" time="0">`,`${r} </testsuite>`,"</testsuites>",""].join(`
9
+ `)},hs=e=>{const t=e.map(s=>({categories:["Security"],check_name:s.ruleId,description:`${s.ruleId}: ${s.description||"Potential secret"}`,engine_name:"vis-secrets",fingerprint:Et("sha256").update(`${K(s)}\0${String(s.startColumn)}\0${String(s.endLine)}\0${String(s.endColumn)}`).digest("hex"),location:{lines:{begin:s.startLine,end:s.endLine},path:s.file},severity:"critical",type:"issue"}));return`${JSON.stringify(t,void 0,2)}
10
+ `},ps=/\.(?:zip|jar|war|ear|tar|tgz|gz)!/iu,fs=(e,t={})=>e.map(s=>{const n=s.description||s.ruleId,r=`${s.file}:${String(s.startLine)}`;return s.commit?z("error",{title:s.ruleId},`${n}
11
+ ${r} in commit ${s.commit.sha.slice(0,7)}`):t.staged?z("error",{title:s.ruleId},`${n}
12
+ ${r} (staged)`):ps.test(s.file)?z("error",{title:s.ruleId},`${n}
13
+ ${r}`):z("error",{col:s.startColumn,endColumn:s.endColumn,endLine:s.endLine,file:s.file,line:s.startLine,title:s.ruleId},n)}).join(""),be=1,ms=e=>{const t=new Map;for(const s of e){const n=t.get(s.file);n?n.push(s):t.set(s.file,[s])}return t},gs=e=>{try{return et(e).split(/\r?\n/)}catch{return}},$s=(e,t,s)=>{const n=Math.max(1,t);return`${e.slice(0,n-1).replaceAll(/[^\t]/g," ")}${"^".repeat(Math.max(1,s))}`},B=e=>e,We=e=>e?{cyan:Ze,dim:x,green:Ee,red:Xe,yellow:C}:{cyan:B,dim:B,green:B,red:B,yellow:B},ws=(e,t,s,n={})=>{if(e.length===0)return s?x("No secrets detected."):"No secrets detected.";const r=We(s),i=[],a=ms(e);for(const[c,o]of a){const d=M(t,c)||c;i.push(r.cyan(d));const p=n.redact?void 0:gs(c);for(const l of o){const b=[l.source,l.confidence].filter(Boolean).join(", "),h=b?` ${r.dim(`(${b})`)}`:"",u=l.alternateMatches&&l.alternateMatches.length>0?` ${r.dim(`also: ${l.alternateMatches.join(", ")}`)}`:"";let f="";switch(l.validation){case"error":{f=` ${r.yellow("! error")}`;break}case"rejected":{f=` ${r.red("✗ rejected")}`;break}case"skipped":{f=` ${r.dim("— unverifiable")}`;break}case"verified":{f=` ${r.green("✓ verified")}`;break}}if(i.push(` ${r.red("✖")} ${r.yellow(`[${l.ruleId}]`)}${h}${f} ${r.dim(`line ${String(l.startLine)}:${String(l.startColumn)}`)}${u}`),p){const g=Math.max(0,l.startLine-1-be),w=Math.min(p.length,l.startLine+be);for(let v=g;v<w;v+=1){const S=String(v+1).padStart(4," "),y=v+1===l.startLine,m=y?r.red("▶"):" ";if(i.push(` ${m} ${r.dim(S)} │ ${p[v]??""}`),y){const k=Math.max(1,(l.endColumn??l.startColumn+1)-l.startColumn),P=$s(p[v]??"",l.startColumn,k);i.push(` ${r.dim(" │ ")}${r.red(P)}`)}}}i.push("")}}return i.join(`
14
+ `).trimEnd()},vs=(e,t,s={})=>{if(e.length===0)return t?x("No secrets detected in git history."):"No secrets detected in git history.";const n=We(t),r=new Map;for(const a of e){const c=r.get(a.commit.sha);c?c.push(a):r.set(a.commit.sha,[a])}const i=[];for(const[a,c]of r){const{authorName:o,date:d,message:p}=c[0].commit;i.push(`${n.yellow(a.slice(0,10))} ${p}`),i.push(` ${n.dim(`${o} · ${d}`)}`);for(const l of c){const b=[l.source,l.confidence].filter(Boolean).join(", "),h=b?` ${n.dim(`(${b})`)}`:"",u=s.redact?"":` ${n.dim(l.match)}`;i.push(` ${n.red("✖")} ${n.yellow(`[${l.ruleId}]`)}${h} ${n.cyan(l.file)} ${n.dim(`line ${String(l.startLine)}:${String(l.startColumn)}`)}${u}`)}i.push("")}return i.join(`
15
+ `).trimEnd()},ys=(e,t,s,n={})=>{const r=new Map;for(const o of e)r.set(o.reason,(r.get(o.reason)??0)+1);const i=[...r].map(([o,d])=>`${o}: ${String(d)}`).join(", "),a=`${String(e.length)} ${t}(s) not scanned (${i})${n.verbose?"":"; use --verbose to list them"}`,c=[s?C(a):a];if(n.verbose)for(const o of e){const d="sha"in o?` ${o.commit===void 0?"":`${o.commit.slice(0,10)} `}${o.sha.slice(0,10)}`:"",p=` - ${o.path} [${o.reason}]${d}`;c.push(s?x(p):p)}return c.join(`
16
+ `)},bs=(e,t,s)=>{const n=`${String(e.length)} allow marker(s) name unknown rule ids and still suppress every rule (rename or remove the ids):`,r=[s?C(n):n];for(const i of e){const a=` - ${Ue(i.file,t)}:${String(i.line)} unknown: ${i.unknownRuleIds.join(", ")}`;r.push(s?x(a):a)}return r.join(`
17
+ `)},Ss=(e,t)=>{if(!E(e))return rt(e);try{return De(e).toString()}catch{return`file://${I(t,e).replaceAll("\\","/")}`}},ks=(e,t=100)=>e.length<=t?e:`${e.slice(0,t-1).trimEnd()}…`,xs=(e,t,s=process.cwd(),n=[])=>{const r=new Map(n.map(o=>[o.id,o])),i=new Set;for(const o of e)i.add(o.ruleId);const a=[...new Set([...r.keys(),...i])].sort((o,d)=>o.localeCompare(d)),c=new Map(a.map((o,d)=>[o,d]));return JSON.stringify({$schema:"https://schemastore.azurewebsites.net/schemas/json/sarif-2.1.0.json",runs:[{originalUriBaseIds:{SRCROOT:{uri:De(s).toString()}},results:e.map(o=>{const d={};return o.source&&(d.source=o.source),o.confidence&&(d.confidence=o.confidence),o.alternateMatches&&o.alternateMatches.length>0&&(d.alternateRules=o.alternateMatches),o.validation&&(d.validation=o.validation),{level:"error",locations:[{physicalLocation:{artifactLocation:{uri:Ss(o.file,s),uriBaseId:E(o.file)?void 0:"SRCROOT"},region:{endColumn:o.endColumn,endLine:o.endLine,snippet:{text:o.match},startColumn:o.startColumn,startLine:o.startLine}}}],message:{text:o.description||o.ruleId},properties:Object.keys(d).length>0?d:void 0,ruleId:o.ruleId,ruleIndex:c.get(o.ruleId)??-1}}),tool:{driver:{informationUri:"https://visulima.com/packages/secret-scanner",name:"visulima-secret-scanner",rules:a.map(o=>{const d=r.get(o),p=d?.description??`Detected by rule \`${o}\``,l={};return d?.tags&&d.tags.length>0&&(l.tags=d.tags),d?.source&&(l.source=d.source),d?.confidence&&(l.confidence=d.confidence),{defaultConfiguration:{level:"error"},fullDescription:{text:p},helpUri:"https://visulima.com/packages/secret-scanner",id:o,name:o,properties:Object.keys(l).length>0?l:void 0,shortDescription:{text:ks(p)}}}),version:t}}}],version:"2.1.0"},void 0,2)},oe=["text","json","sarif","csv","junit","gitlab-code-quality","github"],Ve=e=>oe.includes(e),Is=e=>{const t=[],s=new Set;for(const n of e){const r=n.indexOf("="),i=r===-1?n:n.slice(0,r),a=r===-1?"":n.slice(r+1);if(!Ve(i))throw new $(`--report "${n}": format must be one of ${oe.join(", ")}, as <format>=<path> (e.g. sarif=secrets.sarif)`);if(a==="")throw new $(`--report "${n}" needs a file path: ${i}=<path>`);if(s.has(a))throw new $(`--report writes ${a} twice; give each report its own file.`);s.add(a),t.push({format:i,path:a})}return t},Se=(e,t,s)=>{const n=()=>t.map(r=>j(r,s.root));switch(e){case"csv":return ls(n());case"github":return fs(n(),{staged:s.staged});case"gitlab-code-quality":return hs(n());case"json":return`${JSON.stringify(n(),null,2)}
18
+ `;case"junit":return us(n());case"sarif":return`${xs(t,s.toolVersion,s.root,s.ruleMetadata)}
19
+ `;default:return`${s.history?vs(t,s.useColor,{redact:s.redact}):ws(t,s.root,s.useColor,{redact:s.redact})}
20
+ `}},Fs=e=>e.kind==="secret"?"<secret-value entry>":e.raw,Rs=(e,t,s)=>{const n=`${String(e.length)} unused ${t} entr${e.length===1?"y":"ies"} (no finding matched; remove or update them):`,r=[s?C(n):n];for(const i of e){const a=` - line ${String(i.line)}: ${Fs(i)}`;r.push(s?x(a):a)}return r.join(`
21
+ `)},Cs=(e,t,s)=>{const n=`${String(e.length)} finding(s) suppressed:`,r=[s?C(n):n];for(const i of e){const a=j(i,t),c=i.suppressedByEntry===void 0?"":` line ${String(i.suppressedByEntry.line)}`,o=`${i.suppressedBy}${c}`,d=` - [${i.ruleId}] ${K({...a,commit:i.commit})} (${o})`;r.push(s?x(d):d)}return r.join(`
22
+ `)},Es=async(e,t)=>{try{return await e.access(t),!0}catch{return!1}},A=e=>e?Array.isArray(e)?e:[e]:[],Ts=e=>{if(e===void 0)return"text";if(!Ve(e))throw new $(`--format must be one of: ${oe.join(", ")} (got "${e}")`);return e},ke=(e,t,s)=>{if(e!==void 0){if(!Number.isInteger(e)||e<0||s!==void 0&&e>s){const n=s===void 0?"a non-negative integer":`an integer from 0 to ${String(s)}`;throw new $(`${t} must be ${n} (got ${String(e)}).`)}return e}},As=e=>{if(e!==void 0&&(!Number.isInteger(e)||e<1))throw new $(`--max-size must be a positive number of bytes (got ${String(e)}; default ${String(O)}).`);return e},js=e=>{if(e!==void 0){if(!le.includes(e))throw new $(`--min-confidence must be one of: ${le.join(", ")} (got "${e}")`);return e}},Ls=(e,t,s)=>{const n=t??{},r=m=>m?I(s,m):void 0,i=(m,k)=>{const P=A(m);return P.length>0?P:k},a=(n.config?.presets??[]).map(m=>`tag:preset:${m}`),c=i(e.enableRule,n.rules?.enable)??[],o=[...c,...a.filter(m=>!c.includes(m))],d=o.length>0?o:void 0,p=i(e.excludeRule,n.rules?.exclude),l=i(e.includeRule,n.rules?.include),b=i(e.exclude,n.walk?.excludePatterns),h=A(e.excludeFrom).map(m=>I(s,m)),u=n.walk?.excludeFromFiles?.map(m=>I(s,m)),f=r(e.baseline)??r(n.baseline),g=r(e.config)??r(n.config?.path),w=js(e.minConfidence??n.config?.minConfidence),v=A(e.secretlintignore).map(m=>I(s,m));let S,y=h.length>0?h:u;if(e.secretlintignore===!1)S=!1;else if(v.length>0&&n.secretlintIgnore===!1)S=!1,y=[...y??[],...v];else if(v.length>0){const m=Array.isArray(n.secretlintIgnore)?n.secretlintIgnore.map(k=>I(s,k)):[];S=[...new Set([...m,...v])]}else n.secretlintIgnore===!1?S=!1:S=n.secretlintIgnore?.map(m=>I(s,m));return{baseline:f,concurrency:e.concurrency,config:{extendBundled:e.extendBundled===!1?!1:n.config?.extendBundled,inline:n.config?.inline,minConfidence:w,onlyVerified:e.onlyVerified??n.config?.onlyVerified??!1,path:g,validate:e.validate??n.config?.validate??!1},inlineAllow:e.inlineAllow,maxArchiveDepth:ke(e.maxArchiveDepth,"--max-archive-depth",ot),maxDecodeDepth:ke(e.maxDecodeDepth,"--max-decode-depth"),overrides:n.overrides,overridesRoot:s,profile:e.profile===!0,redact:e.redact??n.redact??!0,reportSuppressed:e.logIgnored===!0,rules:{enable:d,exclude:p,include:l},secretlintIgnore:S,verbose:e.verbose??!1,walk:{excludeFromFiles:y,excludePatterns:b,gitignore:e.gitignore===!1?!1:n.walk?.gitignore??!0,includeHidden:e.includeHidden??n.walk?.includeHidden,maxFileSize:As(e.maxSize)??n.walk?.maxFileSize}}},q=e=>{if(e.stdin!==void 0){if(e.stdin===null||e.stdin==="")throw new $("--stdin needs a filename used for rule and path matching, e.g. `cat .env | vis secrets --stdin .env`.");return e.stdin}},He=e=>[q(e)===void 0?void 0:"--stdin",e.history?"--history":void 0,e.staged?"--staged":void 0,e.since===void 0?void 0:"--since",e.affected?"--affected":void 0].filter(t=>t!==void 0),xe=(e,t)=>[e.listRules?"--list-rules":void 0,e.listValidators?"--list-validators":void 0,e.init?"--init":void 0,t&&e.updateBaseline?"--update-baseline":void 0].find(s=>s!==void 0),Ms=e=>{const t=He(e);if(t.length>1)throw new $(`${t.join(", ")} each pick what to scan and can't be combined. Use one of them.`);if(!e.history){const s=[e.all?"--all":void 0,e.historyRange===void 0?void 0:"--history-range",e.maxCommits===void 0?void 0:"--max-commits"].filter(n=>n!==void 0);if(s.length>0)throw new $(`${s.join(", ")} only applies to git history scans. Did you mean \`vis secrets --history ${s.join(" ")}\`?`);return}if(e.all&&e.historyRange!==void 0)throw new $("--all walks every ref and can't be combined with --history-range. Use one or the other.");if(e.updateBaseline)throw new $("--update-baseline records working-tree findings and can't be combined with --history.");if(e.maxCommits!==void 0&&(!Number.isInteger(e.maxCommits)||e.maxCommits<1))throw new $(`--max-commits must be a positive integer (got ${String(e.maxCommits)}); omit it to walk every commit.`)},Ns=e=>{const t=e.history?"--history":e.staged?"--staged":void 0;if(e.maxArchiveDepth!==void 0&&t!==void 0)throw new $(`--max-archive-depth only applies to working-tree scans; ${t} scans git blobs as text and doesn't open archives. Drop --max-archive-depth or ${t}.`)},Ge=(e,t)=>[q(e)===void 0?void 0:"--stdin",e.staged?"--staged":void 0,e.since===void 0?void 0:"--since",e.affected?"--affected":void 0,e.historyRange===void 0?void 0:"--history-range",e.maxCommits===void 0?void 0:"--max-commits",t?"explicit paths":void 0].filter(s=>s!==void 0),Ds=(e,t)=>{if(q(e)!==void 0){if(t)throw new $("--stdin scans piped content and can't be combined with explicit paths.");const c=[e.updateBaseline?"--update-baseline":void 0,e.replaceBaseline?"--replace-baseline":void 0,e.logIgnored?"--log-ignored":void 0,e.maxSize===void 0?void 0:"--max-size",e.maxArchiveDepth===void 0?void 0:"--max-archive-depth",e.failOnUnreadable?"--fail-on-unreadable":void 0].filter(o=>o!==void 0);if(c.length>0)throw new $(`${c.join(", ")} can't be combined with --stdin: a single piped buffer can't seed a baseline, and there are no files to size-check, skip, list or open as archives.`)}const s=xe(e,!0),n=[A(e.report).length>0?"--report":void 0,e.logIgnored?"--log-ignored":void 0,e.profile?"--profile":void 0,e.failOnUnreadable?"--fail-on-unreadable":void 0,e.failOnUnusedIgnores?"--fail-on-unused-ignores":void 0].filter(c=>c!==void 0);if(s!==void 0&&n.length>0)throw new $(`${n.join(", ")} only applies to a scan report and can't be combined with ${s}.`);const r=xe(e,!1),i=[...He(e),...t?["explicit paths"]:[]];if(r!==void 0&&i.length>0)throw new $(`${i.join(", ")} picks what to scan and can't be combined with ${r}.`);if(!e.failOnUnusedIgnores)return;if(e.gitleaksIgnore===!1)throw new $("--fail-on-unused-ignores checks .gitleaksignore, which --no-gitleaks-ignore turns off. Drop one of them.");const a=Ge(e,t);if(a.length>0)throw new $(`--fail-on-unused-ignores needs a full scan: with ${a.join(", ")}, entries for files outside the scan would be reported as unused. Run it on a full \`vis secrets\` or \`vis secrets --history\` scan.`)},Bs=e=>{if(e.dryRun&&!e.fix&&!e.init)throw new $("--dry-run needs --fix (to preview rewrites) or --init (to preview a baseline).")},_s=(e,t,s)=>{if(!e.fix)return;const n=e.format??"text",r=[e.redact===!0?"--redact":void 0,e.history?"--history":void 0,e.staged?"--staged":void 0,e.init?"--init":void 0,q(e)===void 0?void 0:"--stdin",e.profile?"--profile":void 0,e.listRules?"--list-rules":void 0,e.listValidators?"--list-validators":void 0,e.updateBaseline?"--update-baseline":void 0,e.replaceBaseline?"--replace-baseline":void 0,A(e.report).length>0?"--report":void 0,e.logIgnored?"--log-ignored":void 0,e.failOnUnreadable?"--fail-on-unreadable":void 0,e.failOnUnusedIgnores?"--fail-on-unused-ignores":void 0,e.validate||t.config?.validate?"--validate":void 0,n==="text"?void 0:`--format ${n}`].filter(i=>i!==void 0);if(r.length>0)throw new $(`${r.join(", ")} cannot be combined with --fix. Fix mode rewrites working-tree files in place and prints only a masked summary.`);if(s>1)throw new $("--fix accepts at most one path; run one scan per path so rewrite targets stay unambiguous.")},ae=".gitleaksignore",R=T.child({stdout:process.stderr}),Us=(e,t)=>{const{flags:s,root:n,useColor:r}=t;s.quiet||(e.skipped.length>0&&process.stderr.write(`${ys(e.skipped,e.skippedUnit,r,{verbose:s.verbose})}
23
+ `),e.allowWarnings.length>0&&process.stderr.write(`${bs(e.allowWarnings,n,r)}
24
+ `),t.fullScan&&e.unusedIgnores.length>0&&process.stderr.write(`${Rs(e.unusedIgnores,ae,r)}
25
+ `)),s.logIgnored&&process.stderr.write(`${Cs(e.suppressed,n,r)}
26
+ `)},Y=44,J=(e,t,s="start")=>{const n=e.replaceAll(/\s+/gu," ").trim();return n.length<=t?n.padEnd(t):s==="end"?`…${n.slice(n.length-t+1)}`:`${n.slice(0,t-1)}…`},Ie=(e,t,s,n="")=>` ${e} ${t.toFixed(1).padStart(7)} ms ×${String(s)}${n}`,Os=()=>({files:[],phases:[],rules:[],totalMs:0}),qs=(e,t=!1)=>{const s=i=>t?x(i):i,n=[`${s("profile:")} ${e.totalMs.toFixed(1)} ms total, ${String(e.files.length)} file(s)`],r=(i,a)=>{n.push(s(`${i}:`),...a.length>0?a:[" (none)"])};return r("phases",e.phases.slice(0,10).map(i=>Ie(J(i.name,Y),i.ms,i.count))),r("rules",e.rules.slice(0,10).map(i=>Ie(J(i.ruleId,Y),i.ms,i.count,` ${String(i.matches)} match(es)`))),r("files",e.files.slice(0,10).map(i=>` ${J(i.file,Y,"end")} ${i.ms.toFixed(1).padStart(7)} ms`)),n.join(`
27
+ `)},Fe=(e,t)=>{e!==void 0&&process.stderr.write(`${qs(e,t)}
28
+ `)},Ps=e=>{process.stderr.write(`${x("baseline diff: ")}${Ee(`+${String(e.fresh.length)} new`)} · ${C(`${String(e.surviving.length)} unchanged`)} · ${x(`-${String(e.resolved.length)} resolved`)}
29
+ `)},zs=async(e,t)=>{const{flags:s,format:n,history:r,reports:i,root:a,scanOptions:c,toolbox:o,toolVersion:d,useColor:p}=t,l=c.redact,h=n==="sarif"||i.some(g=>g.format==="sarif")?await Te(c).catch(()=>[]):[],u={history:r,redact:l,root:a,ruleMetadata:h,staged:s.staged===!0,toolVersion:d},f=!l||r;process.stdout.write(Se(n,e.findings,{...u,useColor:p}));for(const g of i){const w=I(o.process.cwd,g.path);_e(w,Se(g.format,e.findings,{...u,useColor:!1}),f),s.quiet||R.info(`Wrote ${g.format} report to ${M(o.process.cwd,w)||w}`)}},Ws=(e,t)=>{if(t.failOnUnreadable){const s=e.skipped.filter(n=>n.reason!=="too-large"&&n.reason!=="binary").length;s>0&&(R.error(`${String(s)} ${e.skippedUnit}(s) could not be read; the scan is incomplete (--fail-on-unreadable).`),process.exitCode=1)}t.failOnUnusedIgnores&&e.unusedIgnores.length>0&&(R.error(`${String(e.unusedIgnores.length)} unused ${ae} entr${e.unusedIgnores.length===1?"y":"ies"} (--fail-on-unused-ignores).`),process.exitCode=1)},Vs=(e,t,s,n)=>{if(e.replacements===0&&e.skipped.length===0){n||process.stderr.write(t>0?`No secrets detected, but ${String(t)} file(s) were not scanned.
30
+ `:`No secrets detected.
31
+ `);return}for(const r of e.edits)process.stderr.write(`${r.file}:${String(r.line)} ${r.ruleId}: ${Xt} -> ${Pe}${s?" (dry-run)":""}
32
+ `);for(const r of e.skipped)process.stderr.write(`Skipped ${r.file}:${String(r.line)} ${r.ruleId}: ${r.reason}
33
+ `);n||(process.stderr.write(`${s?"Would replace":"Replaced"} ${String(e.replacements)} secret(s) in ${String(e.changedFiles)} file(s).
34
+ `),t>0&&process.stderr.write(`${String(t)} file(s) were not scanned.
35
+ `))},U=".secrets-baseline.json",Hs=async(e,t)=>{const s=await Te(e);process.stdout.write(`${String(s.length)} rules loaded
36
+
37
+ `);for(const n of s){const r=t?C(n.id):n.id,i=n.tags.length>0?` ${t?x(`[${n.tags.join(", ")}]`):`[${n.tags.join(", ")}]`}`:"";if(process.stdout.write(`${r}${i}
38
+ ${n.description}
39
+ `),n.keywords.length>0){const a=`keywords: ${n.keywords.slice(0,6).join(", ")}${n.keywords.length>6?", ...":""}`;process.stdout.write(` ${t?x(a):a}
40
+ `)}process.stdout.write(`
41
+ `)}},Gs=async(e,t)=>{const s=await at(e);if(s.length===0){process.stdout.write(t?`${x("No non-HTTP validators required by the current ruleset.")}
42
+ `:`No non-HTTP validators required by the current ruleset.
43
+ `);return}process.stdout.write(`${String(s.length)} non-HTTP validator type(s) referenced by the current ruleset:
44
+
45
+ `);for(const n of s){const r=t?C(n.displayName):n.displayName,i=`(${n.type}, ${String(n.ruleCount)} rule${n.ruleCount===1?"":"s"})`;process.stdout.write(`${r} ${t?x(i):i}
46
+ `),process.stdout.write(` ${n.summary}
47
+ `);const a=n.packageName?`install: npm add ${n.packageName}`:"no driver — bespoke implementation required";process.stdout.write(` ${t?x(a):a}
48
+
49
+ `)}},Ks=async(e,t,s)=>{const n=V(e,U);if(!s&&te(n)){T.warn(`Detected existing ${U} — refusing to overwrite. Delete it first to re-init.`),process.exitCode=1;return}T.info(s?"[dry-run] Previewing init — no files will be written.":"Scanning workspace to seed baseline…");const r=Be();r.start("scanning");let i;try{i=await ct([e],t),r.succeed()}catch(c){throw r.failed(),c}if(s){T.info(`[dry-run] Would create ${U} with ${String(i.length)} finding(s).`);return}const a=qe(i,n,e,{replace:!0});T.success(`Wrote ${U} (${String(a)} findings).`),T.notice("Commit it. Use `vis secrets --baseline .secrets-baseline.json` in CI. Add path patterns to .gitignore to exclude directories from scanning.")},Re={files:{failure:"secret scan",spinner:"scanning for secrets"},history:{failure:"git-history secret scan",spinner:"scanning git history for secrets"},paths:{failure:"secret scan",spinner:"scanning for secrets"},staged:{failure:"secret scan",spinner:"scanning for secrets"},stdin:{failure:"piped-input secret scan",spinner:"scanning piped input"}},Ce=(e,t,s)=>{const n=I(s,e),r=M(t,n);return r===""||r===".."||r.startsWith("../")||E(r)?n:r},Ys=async()=>{const e=[];let t=0;for await(const s of process.stdin){if(t+=s.length,t>O)throw new $(`--stdin input exceeds ${String(O)} bytes, the largest file the scanner reads. Scan it as a file instead.`);e.push(s)}return Buffer.concat(e).toString("utf8")},Js=async(e,t,s,n,r)=>{const i=q(e);if(i!==void 0){if(r!==""){if(Buffer.byteLength(r)>O)throw new $(`--stdin input exceeds ${String(O)} bytes, the largest file the scanner reads. Scan it as a file instead.`);return{content:r,filename:Ce(i,s,n),kind:"stdin"}}if(process.stdin.isTTY)throw new $("--stdin expects piped input, but stdin is a terminal. Pipe content in, e.g. `cat .env | vis secrets --stdin .env`.");return{content:await Ys(),filename:Ce(i,s,n),kind:"stdin"}}const a=t.length>0?t.map(o=>I(s,o)):[s],c=e.history?"--history":e.staged?"--staged":e.since===void 0?void 0:"--since";if(c!==void 0&&!ye(s))throw new $(`${c} requires a git working tree, and none was detected.`);return e.history?{kind:"history"}:e.staged?{kind:"staged"}:e.since!==void 0?{files:ve(s,e.since),kind:"files"}:e.affected?ye(s)?{files:ve(s,process.env.VIS_BASE??"HEAD~1"),kind:"files"}:(R.warn("--affected requires git; falling back to full scan"),{kind:"paths",paths:a}):{kind:"paths",paths:a}},Xs=async(e,t,s,n)=>{if(e.kind==="stdin"){const{allowWarnings:c,findings:o}=lt(e.filename,s,n)?{allowWarnings:[],findings:[]}:await dt(e.content,e.filename,s);return{allowWarnings:c,findings:o,skipped:[],skippedUnit:"file",suppressed:[],unusedIgnores:[]}}if(e.kind==="history")return{...await ut({...s,all:t.all,cwd:n,maxCommits:t.maxCommits,range:t.historyRange}),skippedUnit:"blob"};if(e.kind==="paths")return{...await ht(e.paths,s),skippedUnit:"file"};const r=process.cwd(),i={...s,baseline:typeof s.baseline=="string"?Kt(s.baseline,n,r):s.baseline},a=e.kind==="staged"?await pt({...i,cwd:n}):await ft(e.files,{...i,ignoreRoot:n});return{allowWarnings:a.allowWarnings.map(c=>({...c,file:ne(c.file,r,n)})),findings:a.findings.map(c=>pe(c,r,n)),profile:a.profile&&Gt(a.profile,r,n),skipped:a.skipped,skippedUnit:e.kind==="staged"?"blob":"file",suppressed:a.suppressed.map(c=>pe(c,r,n)),unusedIgnores:a.unusedIgnores}},Zs=async e=>{const t=await mt(e);if(t.length>0){R.warn(`${String(t.length)} rule(s) skipped due to invalid regex. First few:`);for(const s of t.slice(0,5))process.stderr.write(` - ${s.ruleId}: ${s.reason}
50
+ `)}},un=async e=>{const{argument:t,options:s,visConfig:n,workspaceRoot:r}=e,i=s,a=t??[],c=r??e.process.cwd,o=!i.quiet&&process.stdout.isTTY,d=n?.secrets,p=Ls(i,d,c),l="0.0.0-alpha";Ms(i),Ns(i),Ds(i,a.length>0),Bs(i),_s(i,p,a.length),i.fix&&(p.redact=!1);const b=Ts(i.format),h=Is(A(i.report)),u=V(c,ae);if(i.gitleaksIgnore!==!1&&await Es(e.fs,u)&&(p.gitleaksIgnore=u),i.listRules){await Hs(p,o);return}if(i.listValidators){await Gs(p,o);return}if(i.init){await Ks(c,p,i.dryRun??!1);return}const f=await Js(i,a,c,e.process.cwd,e.process.stdin),g=f.kind==="history";if(f.kind==="files"&&f.files.length===0){i.quiet||R.success("No files to scan."),i.profile&&Fe(Os(),o);return}const w=Be({verbose:!i.quiet&&b==="text"&&!i.fix});w.start(Re[f.kind].spinner);let v;try{v=await Xs(f,i,p,c),w.succeed()}catch(k){throw w.failed(),new $(`${Re[f.kind].failure} failed: ${k instanceof Error?k.message:String(k)}`,{cause:k})}if(i.fix){const k=rs(v.findings,c,i.dryRun===!0,f.kind==="paths"?f.paths[0]:c);Vs(k,v.skipped.length,i.dryRun===!0,i.quiet===!0),k.skipped.length>0&&(process.exitCode=1);return}const S={flags:i,format:b,fullScan:Ge(i,a.length>0).length===0,history:g,reports:h,root:c,scanOptions:p,toolbox:e,toolVersion:l,useColor:o};Us(v,S),Fe(v.profile,o),i.verbose&&await Zs(p);const{findings:y}=v,m=typeof p.baseline=="string"?p.baseline:V(c,U);if(i.updateBaseline){const k=qe(y,m,c,{replace:i.replaceBaseline});R.success(`Baseline updated: ${M(c,m)||m} now contains ${String(k)} entries.`);return}await zs(v,S),b==="text"&&!g&&!i.quiet&&te(m)&&Ps(Yt(y,m,c)),y.length>0?(i.quiet||(R.warn(`${String(y.length)} potential secret(s) found${g?" across git history":""}`),R.notice(g?"Findings reference the commit that introduced them — rotate the credential and rewrite history (e.g. git filter-repo) if it is still reachable.":"Suppress individual lines with `gitleaks:allow` / `secret-scanner:allow`, or run `vis secrets --update-baseline`.")),process.exitCode=1):i.quiet||R.success(g?"No secrets detected in git history.":"No secrets detected."),Ws(v,i)};export{un as default};
@@ -0,0 +1,3 @@
1
+ const d=e=>e.replaceAll("%","%25").replaceAll("\r","%0D").replaceAll(`
2
+ `,"%0A"),s=e=>d(e).replaceAll(":","%3A").replaceAll(",","%2C"),r=["file","line","endLine","col","endColumn","title"],c=e=>{const l=r.indexOf(e);return l===-1?r.length:l},a=(e,l,i)=>{const t=Object.entries(l).toSorted(([n],[o])=>c(n)-c(o)).filter(n=>n[1]!==void 0).map(([n,o])=>`${n}=${s(String(o))}`).join(",");return`::${e}${t?` ${t}`:""}::${d(i)}
3
+ `};export{a as w};
@@ -0,0 +1 @@
1
+ import{w as s}from"./github-workflow-command-Bn0MgB78.js";const o=(r,n)=>{process.env.GITHUB_ACTIONS==="true"&&process.stdout.write(s(r,{},n))},t=(r,n)=>{r.warn(n),o("warning",n)},p=(r,n)=>{r.error(n),o("error",n)},f=(r,n,a)=>{for(const e of n.published)r.info(` [published] ${e.name}@${e.version} (dist-tag ${a})`);for(const e of n.skipped)e.reason.startsWith("stage-")?(r.warn(` [stage] ${e.name} (${e.reason} — re-run \`vis release publish\` once approved)`),o("warning",`${e.name}: ${e.reason} — re-run \`vis release publish\` once approved`)):r.info(` [skipped] ${e.name} (${e.reason})`);for(const e of n.failed)r.error(` [failed] ${e.name}: ${e.reason}`),o("error",`${e.name}: ${e.reason}`);r.info(""),r.info(`Published: ${n.published.length} | Skipped: ${n.skipped.length} | Failed: ${n.failed.length}`),n.tags.length>0&&r.info(`Tags created: ${n.tags.length}${n.tagsPushed?" (pushed)":" (NOT pushed — re-run with --resume to retry)"}`)},d=(r,n)=>{const a=[...new Set(n)];if(a.length!==0){r.warn(`${a.length} warning(s):`);for(const e of a)r.warn(` - ${e}`),o("warning",e)}};export{f as a,p as b,t as l,d as r};
@@ -0,0 +1,9 @@
1
+ import{createRequire as W}from"node:module";import{e as h,z as B,v as S,U as V,m as U}from"./index-0dnGN3GP.js";import{v as A}from"./registry-DqBIZZSL.js";import{d as E,f as L}from"./detect-D8zxVYrU.js";import{y as J}from"./isAccessibleSync-DYKTrrvc-CBsMZhj-.js";import{h as ee}from"./env-5cWSxQ96.js";import{w as te}from"./github-workflow-command-Bn0MgB78.js";import{s as re}from"./watch-C-9-PD2m.js";let D;const q=e=>(D??=W(import.meta.url))(e),y=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,x=e=>{if(typeof y<"u"&&y.versions&&y.versions.node){const[t,n]=y.versions.node.split(".").map(Number);if(t>22||t===22&&n>=3||t===20&&n>=16)return y.getBuiltinModule(e)}return q(e)},{createHash:v}=x("node:crypto"),{spawnSync:z,spawn:K}=x("node:child_process"),{openSync:G,writeSync:H,closeSync:Y,statSync:Q,readFileSync:M,mkdirSync:X,writeFileSync:Z}=x("node:fs"),{pathToFileURL:ne}=x("node:url"),{availableParallelism:F}=x("node:os"),se={error:"error",info:"info",information:"info",warning:"warning"},Ye={argsCheck:(e,t)=>k(e,t,!1),argsFix:(e,t)=>k(e,t,!0),bin:()=>["pnpm","exec","biome"],cacheKey:(e,t)=>{const n=["biome",e.declaredVersion??"unknown",e.configFile??"no-config",t.maxWarnings===void 0?"":`mw=${t.maxWarnings}`,t.quiet?"q":"",...t.extraArgs??[]];return v("sha256").update(n.join("|")).digest("hex").slice(0,16)},detect:(e,t)=>{const n=E(t,A.biome.packageNames[0]),r=L(e,A.biome.configFiles);if(!(!n&&!r))return{adapter:"biome",configFile:r,declared:!!n,declaredVersion:n,root:e}},extensions:["astro","cjs","css","cts","js","json","jsonc","jsx","mjs","mts","svelte","ts","tsx","vue"],id:"biome",kind:"both",parse:(e,t)=>{if(!e.stdout.trim())return[];let n;try{n=JSON.parse(e.stdout)}catch{return[{adapter:"biome",file:t.root,fixable:!1,message:`biome output was not valid JSON (exit ${e.exitCode})`,severity:"error"}]}const r=[];for(const s of n.diagnostics??[]){const o=s.location?.start,i=s.location?.end,c=oe(t.root,s.location?.path),l=s.category??"",a=l==="format"||l.startsWith("format/");r.push({adapter:"biome",column:o?.column&&o.column>0?o.column:void 0,endColumn:i?.column&&i.column>0?i.column:void 0,endLine:i?.line&&i.line>0?i.line:void 0,file:c,fixable:!0,line:o?.line&&o.line>0?o.line:void 0,message:a?"Code style issues would be auto-fixed":s.message??"",ruleId:l||void 0,severity:se[s.severity??""]??"warning"})}return r}},k=(e,t,n)=>{const r=["check","--reporter=json"];return n&&r.push("--write"),typeof t.maxWarnings=="number"&&r.push(`--max-diagnostics=${String(t.maxWarnings)}`),t.extraArgs?.length&&r.push(...t.extraArgs),r.push(...e),r},oe=(e,t)=>{const n=typeof t=="string"?t:t?.file;return n?n.startsWith("/")||/^[a-z]:[\\/]/i.test(n)?n:h(e,n):e},O="pyproject.toml",ie=/^\[tool\.ruff(?:\.[\w-]+)*\]\s*$/m,ce=/^Would reformat:?\s+(.+)$/,ae=e=>{const t=h(e,O);if(!J(t))return!1;try{const n=B(t);return ie.test(n)}catch{return!1}},N=e=>(t,n)=>{const r=A.ruff.packageNames.map(c=>E(n,c)).find(c=>c!==void 0),s=L(t,A.ruff.configFiles),o=s?void 0:ae(t)?h(t,O):void 0,i=s??o;if(!(!r&&!i))return{adapter:e,configFile:i,declared:!!r,declaredVersion:r,root:t}},ue=e=>e.startsWith("/")||/^[a-z]:[\\/]/i.test(e),j=(e,t)=>e?ue(e)?e:h(t,e):t,le=e=>ce.exec(e)?.[1]?.trim(),Qe={argsCheck:(e,t)=>I(e,t,!1),argsFix:(e,t)=>I(e,t,!0),bin:()=>["ruff","check"],cacheKey:(e,t)=>{const n=["ruff-check",e.declaredVersion??"unknown",e.configFile??"no-config",t.maxWarnings===void 0?"":`mw=${t.maxWarnings}`,t.quiet?"q":"",...t.extraArgs??[]];return v("sha256").update(n.join("|")).digest("hex").slice(0,16)},detect:N("ruff-check"),extensions:["py","pyi"],id:"ruff-check",kind:"lint",parse:(e,t)=>{if(!e.stdout.trim())return[];let n;try{n=JSON.parse(e.stdout)}catch{return[{adapter:"ruff-check",file:t.root,fixable:!1,message:`ruff check output was not valid JSON (exit ${e.exitCode})`,severity:"error"}]}const r=[];for(const s of n){const o=s.location,i=s.end_location;r.push({adapter:"ruff-check",column:o?.column,endColumn:i?.column,endLine:i?.row,file:j(s.filename,t.root),fixable:!!s.fix,line:o?.row,message:s.message??"",ruleId:s.code,severity:"warning"})}return r}},Xe={argsCheck:(e,t)=>R(e,t,!1),argsFix:(e,t)=>R(e,t,!0),bin:()=>["ruff","format"],cacheKey:(e,t)=>{const n=["ruff-fmt",e.declaredVersion??"unknown",e.configFile??"no-config",t.quiet?"q":"",...t.extraArgs??[]];return v("sha256").update(n.join("|")).digest("hex").slice(0,16)},detect:N("ruff-fmt"),extensions:["py","pyi"],id:"ruff-fmt",kind:"fmt",parse:(e,t)=>{if(e.exitCode===0)return[];const n=[],r=new Set;for(const s of e.stdout.split(/\r?\n/)){const o=le(s);!o||r.has(o)||(r.add(o),n.push({adapter:"ruff-fmt",file:j(o,t.root),fixable:!0,message:"Code style issues would be auto-fixed",severity:"info"}))}return n}},I=(e,t,n)=>{const r=["--output-format=json"];return n&&r.push("--fix"),t.quiet&&r.push("--quiet"),t.extraArgs?.length&&r.push(...t.extraArgs),r.push(...e),r},R=(e,t,n)=>{const r=[];return n||r.push("--check"),t.quiet&&r.push("--quiet"),t.extraArgs?.length&&r.push(...t.extraArgs),r.push(...e),r},Ze=(e,t)=>{const n=w(e,["diff","--name-only","--diff-filter=ACMR","-z",`${t}...HEAD`]);if(n===void 0)return;const r=w(e,["diff","--name-only","--diff-filter=ACMR","-z"]),s=w(e,["diff","--name-only","--diff-filter=ACMR","--cached","-z"]),o=w(e,["ls-files","--others","--exclude-standard","-z"]),i=new Set;for(const c of[n,r??"",s??"",o??""])for(const l of c.split("\0"))l.length!==0&&i.add(S(l)?l:h(e,l));return[...i].sort()},et=e=>{const t=w(e,["diff","--name-only","--diff-filter=ACMR","--cached","-z"]);if(t===void 0)return;const n=new Set;for(const r of t.split("\0"))r.length!==0&&n.add(S(r)?r:h(e,r));return[...n].sort()},w=(e,t)=>{const n=z("git",[...t],{cwd:e,encoding:"utf8",timeout:1e4});if(n.status===0)return n.stdout},tt=(e,t)=>{const n=new Set(t.map(o=>o.toLowerCase())),r=[],s=new Set;for(const o of e){const i=o.lastIndexOf(".");if(i===-1||i===o.length-1)continue;const c=o.slice(i+1).toLowerCase();n.has(c)&&(s.has(o)||(s.add(o),r.push(o)))}return r},fe=new Set(["-","stdout"]),T=e=>({close:()=>{},write:t=>{e.write(t)}}),de=e=>{ee(U(e));const t=G(e,"w");let n=[];return{close:()=>{n.length>0&&(H(t,n.join("")),n=[]),Y(t)},write:r=>{n.push(r)}}},nt=e=>{const{cwd:t,target:n}=e;if(n===void 0||fe.has(n))return T(process.stdout);if(n==="stderr")return T(process.stderr);const r=S(n)?n:V(t,n);return de(r)},$=["oxlint","oxfmt","biome","eslint","dprint","prettier","stylelint","ruff-check","ruff-fmt","markdownlint","shellcheck","typecheck"],rt=(e,t)=>{const n=new Map(e.map(i=>[i.id,i])),r=[],s=new Set,o=t&&t.length>0?t:$;for(const i of o){const c=n.get(i);c&&!s.has(i)&&(r.push(c),s.add(i))}if(t&&t.length>0)for(const i of $){const c=n.get(i);c&&!s.has(i)&&(r.push(c),s.add(i))}for(const i of e)s.has(i.id)||(r.push(i),s.add(i.id));return r},st=(e,t,n)=>{const r=[];for(const s of t){const o=e.get(s.id);o&&me(s.kind,n)&&r.push({adapter:s,presence:o})}return r},me=(e,t)=>e===t||e==="both",ot=(e,t,n={})=>{const r=new Map;for(const s of e){const o=he(s),i=pe(o,t,n);if(!i)continue;const c=r.get(i);c?c.push(s):r.set(i,[s])}return r},he=e=>{const t=e.lastIndexOf(".");return t===-1||t===e.length-1?"":e.slice(t+1).toLowerCase()},pe=(e,t,n)=>{const r=n[e];if(r&&t.some(s=>s.adapter.id===r))return r;for(const{adapter:s}of t)if(s.extensions.includes(e))return s.id},it=(e,t,n)=>{const r=new Set($),s=new Set([...n?.order??[],...Object.keys(n?.adapters??{})]);for(const o of s)r.has(o)||e.warn(`vis.config ${t}: unknown adapter "${o}" is ignored.`)},ge=e=>e==="error"?"error":e==="warning"?"warning":"notice",ye=(e,t)=>t&&e.startsWith(`${t}/`)?e.slice(t.length+1):e,we=(e,t)=>e.file!==t.file?e.file<t.file?-1:1:(e.line??0)-(t.line??0)||(e.column??0)-(t.column??0),xe=(e,t)=>{const n=ge(e.severity),r=ye(e.file,t),s=e.ruleId?`${e.adapter}(${e.ruleId})`:e.adapter;return te(n,{col:e.column,endColumn:e.endColumn,endLine:e.endLine,file:r,line:e.line,title:s},e.message)},ct=e=>e.runs.flatMap(n=>[...n.findings]).sort(we).map(n=>xe(n,e.workspaceRoot)).join(""),g=e=>e.replaceAll("&","&amp;").replaceAll("<","&lt;").replaceAll(">","&gt;").replaceAll('"',"&quot;").replaceAll("'","&apos;"),ve=e=>`<![CDATA[${e.replaceAll("]]>","]]]]><![CDATA[>")}]]>`,Se=(e,t)=>e.file!==t.file?e.file<t.file?-1:1:(e.line??0)-(t.line??0)||(e.column??0)-(t.column??0),Ae=e=>e==="error"?"error":e==="warning"?"warning":"info",Ce=(e,t)=>{let{file:n}=e;return t&&e.file.startsWith(`${t}/`)&&(n=e.file.slice(t.length+1)),e.line===void 0?n:e.column===void 0?`${n}:${String(e.line)}`:`${n}:${String(e.line)}:${String(e.column)}`},$e=(e,t,n)=>{const r=Ce(e,n),s=Ae(e.severity),o=e.ruleId?`[${e.ruleId}] ${e.message}`:e.message;return[` <testcase classname="${g(t)}" name="${g(r)}">`,` <failure type="${g(s)}" message="${g(o)}">${ve(e.message)}</failure>`," </testcase>",""].join(`
2
+ `)},Fe=(e,t,n)=>{const r=[...e.findings].sort(Se),s=r.filter(f=>f.severity==="error").length,o=r.filter(f=>f.severity==="warning").length,i=r.length,c=(e.durationMs/1e3).toFixed(3),l=r.map(f=>$e(f,e.adapter,n)).join("");return` <testsuite ${[`name="${g(e.adapter)}"`,`tests="${String(i)}"`,`failures="${String(s)}"`,'errors="0"',`skipped="${String(o)}"`,`time="${c}"`,`timestamp="${t}"`].join(" ")}>
3
+ ${l} </testsuite>
4
+ `},at=e=>{const t=(e.now??new Date).toISOString(),n=e.suiteName??"vis-lint-fmt",r=e.runs.map(a=>Fe(a,t,e.workspaceRoot)).join(""),s=e.runs.reduce((a,f)=>a+f.findings.length,0),o=e.runs.reduce((a,f)=>a+f.findings.filter(u=>u.severity==="error").length,0),i=e.runs.reduce((a,f)=>a+f.findings.filter(u=>u.severity==="warning").length,0),c=(e.runs.reduce((a,f)=>a+f.durationMs,0)/1e3).toFixed(3);return`<?xml version="1.0" encoding="UTF-8"?>
5
+ <testsuites ${[`name="${g(n)}"`,`tests="${String(s)}"`,`failures="${String(o)}"`,'errors="0"',`skipped="${String(i)}"`,`time="${c}"`].join(" ")}>
6
+ ${r}</testsuites>
7
+ `},ke="2.1.0",Ie="https://json.schemastore.org/sarif-2.1.0.json",Re=e=>e==="error"?"error":e==="warning"?"warning":"note",Te=(e,t)=>t&&e.startsWith(`${t}/`)?{uri:e.slice(t.length+1),uriBaseId:"SRCROOT"}:{uri:e},_e=e=>{const{href:t}=ne(e);return t.endsWith("/")?t:`${t}/`},be=(e,t)=>e.file!==t.file?e.file<t.file?-1:1:(e.line??0)-(t.line??0)||(e.column??0)-(t.column??0),Ee=e=>{const t=new Map;for(const n of e)n.ruleId&&(t.has(n.ruleId)||t.set(n.ruleId,{id:n.ruleId,name:n.ruleId}));return[...t.values()]},Le=(e,t)=>{const{uri:n,uriBaseId:r}=Te(e.file,t),s={artifactLocation:r?{uri:n,uriBaseId:r}:{uri:n}};if(e.line!==void 0){const i={startLine:e.line};e.column!==void 0&&(i.startColumn=e.column),e.endLine!==void 0&&(i.endLine=e.endLine),e.endColumn!==void 0&&(i.endColumn=e.endColumn),s.region=i}const o={level:Re(e.severity),locations:[{physicalLocation:s}],message:{text:e.message}};return e.ruleId&&(o.ruleId=e.ruleId),o},Me=(e,t)=>{const n=[...e.findings].sort(be),r=Ee(n),s={name:e.adapter,rules:r};e.presence?.declaredVersion&&(s.version=e.presence.declaredVersion);const o={results:n.map(i=>Le(i,t)),tool:{driver:s}};return t&&(o.originalUriBaseIds={SRCROOT:{uri:_e(t)}}),o},ut=e=>{const t={$schema:Ie,runs:e.runs.map(n=>Me(n,e.workspaceRoot)),version:ke};return`${JSON.stringify(t,void 0,2)}
8
+ `},_={error:3,info:1,warning:2},lt=e=>{const t=[],n=[];let r,s=!1;for(const o of e){n.push({adapter:o.adapter,durationMs:o.durationMs,exitCode:o.exitCode,findingCount:o.findings.length}),o.exitCode!==0&&o.exitCode!==null&&o.findings.length===0&&(s=!0);for(const i of o.findings)t.push(i),(!r||_[i.severity]>_[r])&&(r=i.severity)}return{findings:t,hadProcessFailure:s,maxSeverity:r,runs:n}},ft=e=>{const t=new Map;for(const n of e){const r=t.get(n.file);r?r.push(n):t.set(n.file,[n])}return t},dt=e=>e.hadProcessFailure||e.maxSeverity==="error"?1:0,Oe=(e,t)=>{if(t==="fix"||process.env.VIS_NO_CACHE==="1"||e.length===0)return!1;for(const n of e)if(n==="."||n==="./"||n==="..")return!1;return!0},Ne=e=>{try{const t=M(e);return v("sha256").update(t).digest("hex")}catch{return}},je=(e,t,n,r,s)=>{const o=e.cacheKey(t,r),i=[];for(const l of[...n].sort()){const a=S(l)?l:h(t.root,l);try{Q(a)}catch{return}const f=Ne(a);if(!f)return;i.push({hash:f,path:a})}const c=v("sha256");c.update(e.id),c.update("\0"),c.update(o),c.update("\0"),c.update(s);for(const l of i)c.update("\0"),c.update(l.path),c.update("\0"),c.update(l.hash);return{fileHashes:i,key:c.digest("hex")}},P=(e,t)=>h(e,"lint-fmt",t),Pe=(e,t,n)=>{const r=h(P(e,t.id),`${n}.json`);try{const s=M(r,"utf8"),o=JSON.parse(s);return o.schema!==1?void 0:o}catch{return}},We=(e,t,n,r,s)=>{const o=P(e,t.id),i={fileHashes:s,result:r,savedAt:Date.now(),schema:1};try{X(o,{recursive:!0}),Z(h(o,`${n}.json`),JSON.stringify(i))}catch{}},b=async(e,t,n,r,s)=>{const o=e.bin(t),i=[...o.slice(1),...s==="fix"?e.argsFix(n,r):e.argsCheck(n,r)];return new Promise(c=>{const l=Date.now(),a=K(o[0],i,{cwd:t.root}),f=[],u=[];let p=!1;const m=setTimeout(()=>{p=!0,a.kill("SIGKILL")},6e4);a.stdout.on("data",d=>f.push(d)),a.stderr.on("data",d=>u.push(d)),a.on("error",d=>{clearTimeout(m),c({durationMs:Date.now()-l,exitCode:null,stderr:d.message,stdout:""})}),a.on("close",d=>{clearTimeout(m),c({durationMs:Date.now()-l,exitCode:p?null:d,stderr:Buffer.concat(u).toString("utf8"),stdout:Buffer.concat(f).toString("utf8")})})})},mt=async(e,t,n,r=F())=>{if(e.length===0)return[];const{cacheRoot:s,concurrency:o}=typeof r=="number"?{concurrency:r}:{cacheRoot:r.cacheRoot,concurrency:r.concurrency??F()},i=async u=>{const p=u.options??t;if(s&&Oe(u.files,n)){const m=je(u.adapter,u.presence,u.files,p,n);if(m){const d=Pe(s,u.adapter,m.key);if(d)return d.result;const C=await b(u.adapter,u.presence,u.files,p,n);return C.exitCode!==null&&We(s,u.adapter,m.key,C,m.fileHashes),C}}return b(u.adapter,u.presence,u.files,p,n)};if(process.env.VIS_LINT_FMT_SERIAL==="1"){const u=[];for(const p of e)u.push(await i(p));return u}const c=Math.max(1,Math.min(o,e.length)),l=Array.from({length:e.length});let a=0;const f=async()=>{for(;;){const u=a;if(a+=1,u>=e.length)return;l[u]=await i(e[u])}};return await Promise.all(Array.from({length:c},()=>f())),l},De=e=>{const t=new Set;for(const n of e)t.add(n.toLowerCase());return t},qe=(e,t)=>{const n=e.lastIndexOf(".");return n===-1||n===e.length-1?!1:t.has(e.slice(n+1).toLowerCase())},ht=async e=>{const{extensions:t,initialFiles:n,label:r,log:s,runCycle:o,workspaceRoot:i}=e,c=s??(m=>{process.stdout.write(`${m}
9
+ `)}),l=De(t);await o(n),c(`▸ ${r}: watching workspace — press Ctrl-C to exit`);let a=new Set,f=!1;const u=async()=>{for(;a.size>0;){const m=[...a];a=new Set;try{await o(m)}catch(d){c(`✗ ${r}: watch cycle failed — ${d.message}`)}}},p=re({debounceMs:200,filter:m=>qe(m,l),onChange:async m=>{for(const d of m)a.add(S(d)?d:h(i,d));if(!f){f=!0;try{await u()}finally{f=!1}}},paths:[i]});await new Promise(m=>{const d=()=>{p.close(),process.off("SIGINT",d),process.off("SIGTERM",d),m()};process.once("SIGINT",d),process.once("SIGTERM",d)})};export{st as a,ht as b,Ze as c,Ye as d,Xe as e,ot as f,mt as g,lt as h,nt as i,ut as j,at as k,ct as l,dt as m,ft as n,Qe as o,tt as p,rt as r,et as s,it as w};