@visulima/vis 6.7.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.
Files changed (130) hide show
  1. package/CHANGELOG.md +68 -0
  2. package/README.md +31 -0
  3. package/bin/route.mjs +256 -0
  4. package/bin/vis +7 -0
  5. package/bin/vis.mjs +25 -31
  6. package/dist/bin.js +1 -1
  7. package/dist/binx.js +1 -1
  8. package/dist/config/index.d.ts +16 -1
  9. package/dist/packem_chunks/bloom-sync.js +1 -1
  10. package/dist/packem_chunks/catalog.js +1 -1
  11. package/dist/packem_chunks/cli-exec.js +1 -1
  12. package/dist/packem_chunks/cli-main.js +88 -88
  13. package/dist/packem_chunks/fix.js +1 -1
  14. package/dist/packem_chunks/handler10.js +1 -1
  15. package/dist/packem_chunks/handler12.js +1 -1
  16. package/dist/packem_chunks/handler13.js +1 -1
  17. package/dist/packem_chunks/handler14.js +1 -1
  18. package/dist/packem_chunks/handler15.js +1 -1
  19. package/dist/packem_chunks/handler19.js +1 -1
  20. package/dist/packem_chunks/handler2.js +1 -1
  21. package/dist/packem_chunks/handler20.js +1 -1
  22. package/dist/packem_chunks/handler21.js +1 -1
  23. package/dist/packem_chunks/handler23.js +1 -1
  24. package/dist/packem_chunks/handler24.js +1 -1
  25. package/dist/packem_chunks/handler25.js +1 -1
  26. package/dist/packem_chunks/handler26.js +1 -1
  27. package/dist/packem_chunks/handler28.js +1 -1
  28. package/dist/packem_chunks/handler3.js +1 -1
  29. package/dist/packem_chunks/handler4.js +1 -1
  30. package/dist/packem_chunks/handler46.js +1 -1
  31. package/dist/packem_chunks/handler5.js +1 -1
  32. package/dist/packem_chunks/handler50.js +1 -1
  33. package/dist/packem_chunks/handler51.js +1 -1
  34. package/dist/packem_chunks/handler52.js +1 -1
  35. package/dist/packem_chunks/handler54.js +1 -1
  36. package/dist/packem_chunks/handler55.js +1 -1
  37. package/dist/packem_chunks/handler56.js +1 -1
  38. package/dist/packem_chunks/handler58.js +1 -1
  39. package/dist/packem_chunks/handler59.js +1 -1
  40. package/dist/packem_chunks/handler6.js +1 -1
  41. package/dist/packem_chunks/handler60.js +1 -1
  42. package/dist/packem_chunks/handler61.js +1 -1
  43. package/dist/packem_chunks/handler62.js +1 -1
  44. package/dist/packem_chunks/handler63.js +1 -1
  45. package/dist/packem_chunks/handler64.js +1 -1
  46. package/dist/packem_chunks/handler65.js +1 -1
  47. package/dist/packem_chunks/handler66.js +1 -1
  48. package/dist/packem_chunks/handler67.js +1 -1
  49. package/dist/packem_chunks/handler68.js +1 -1
  50. package/dist/packem_chunks/handler69.js +25 -37
  51. package/dist/packem_chunks/handler7.js +1 -1
  52. package/dist/packem_chunks/handler70.js +50 -25
  53. package/dist/packem_chunks/handler71.js +1 -1
  54. package/dist/packem_chunks/handler72.js +1 -1
  55. package/dist/packem_chunks/handler73.js +6 -6
  56. package/dist/packem_chunks/handler74.js +1 -1
  57. package/dist/packem_chunks/handler75.js +1 -1
  58. package/dist/packem_chunks/handler76.js +1 -1
  59. package/dist/packem_chunks/handler77.js +1 -1
  60. package/dist/packem_chunks/handler78.js +1 -1
  61. package/dist/packem_chunks/handler79.js +1 -1
  62. package/dist/packem_chunks/handler8.js +1 -1
  63. package/dist/packem_chunks/heal.js +1 -1
  64. package/dist/packem_chunks/help-command.js +1 -1
  65. package/dist/packem_chunks/index7.js +1 -1
  66. package/dist/packem_chunks/keys-refresh.js +1 -1
  67. package/dist/packem_chunks/list.js +1 -1
  68. package/dist/packem_chunks/prune.js +1 -1
  69. package/dist/packem_chunks/status.js +1 -1
  70. package/dist/packem_chunks/sync.js +1 -1
  71. package/dist/packem_chunks/sync2.js +1 -1
  72. package/dist/packem_chunks/tripwire.js +1 -1
  73. package/dist/packem_chunks/verify-lockfile.js +1 -1
  74. package/dist/packem_shared/{advisories-CtqvyYvO.js → advisories-Vd2kwoSf.js} +1 -1
  75. package/dist/packem_shared/{affected-selection-Br8c1wPb.js → affected-selection-Dbbli-Ot.js} +1 -1
  76. package/dist/packem_shared/{ai-analysis-CouDH8gG.js → ai-analysis-DZEjy6lu.js} +1 -1
  77. package/dist/packem_shared/{ai-cache-Dw2Ob8Wr.js → ai-cache-Q7TuGULh.js} +1 -1
  78. package/dist/packem_shared/{ai-fix-C0xvBoNB.js → ai-fix-Cagw3I4D.js} +1 -1
  79. package/dist/packem_shared/{bin-By7Verav.js → bin-gxaewUwv.js} +1 -1
  80. package/dist/packem_shared/{build-scripts-B_9mXJug.js → build-scripts-B5sROJPn.js} +1 -1
  81. package/dist/packem_shared/{dependency-scan-C8znTO5f.js → dependency-scan-Cpk1Z6Wj.js} +1 -1
  82. package/dist/packem_shared/{detect-CyMwuNhc.js → detect-D8zxVYrU.js} +1 -1
  83. package/dist/packem_shared/{docker-CHjGzCjg.js → docker-2ZjBNNeE.js} +1 -1
  84. package/dist/packem_shared/{ecosystem-gate-Dz4eMiQ0.js → ecosystem-gate-BF9glH2Q.js} +1 -1
  85. package/dist/packem_shared/{env-UwvvHfsx.js → env-5cWSxQ96.js} +1 -1
  86. package/dist/packem_shared/{env-consistency-CTM_WJnR.js → env-consistency-DkH7lUU7.js} +1 -1
  87. package/dist/packem_shared/{failure-log-BH4ck8I4.js → failure-log-Dj9b94ax.js} +1 -1
  88. package/dist/packem_shared/github-workflow-command-Bn0MgB78.js +3 -0
  89. package/dist/packem_shared/glob-Cyk1H9ZL-CYVM7sl3.js +1 -0
  90. package/dist/packem_shared/{index-BhcT3PpQ.js → index-Bu_rMPKl.js} +1 -1
  91. package/dist/packem_shared/{index-BhFtXNNB.js → index-Dn_z9DYf.js} +1 -1
  92. package/dist/packem_shared/{lifecycle-DNWes81J.js → lifecycle-BGTRxc9n.js} +1 -1
  93. package/dist/packem_shared/{manifests-B4s51bMW.js → manifests-C1FhhaNX.js} +1 -1
  94. package/dist/packem_shared/{min-release-age-P0ls4pAF.js → min-release-age-BbppxofB.js} +1 -1
  95. package/dist/packem_shared/{missing-package-json-BcKnQERZ.js → missing-package-json-DLTSyp4H.js} +1 -1
  96. package/dist/packem_shared/{multi-eco-lockfiles-CGC9DH_l.js → multi-eco-lockfiles-CxwaJO4v.js} +1 -1
  97. package/dist/packem_shared/{native-config-sync-DnuL1Ck8.js → native-config-sync-Di-76fQc.js} +1 -1
  98. package/dist/packem_shared/{osv-CgEeaSxd.js → osv-DrEbiNXB.js} +1 -1
  99. package/dist/packem_shared/{package-version-CwpMpdja.js → package-version-lWlrF9Wk.js} +1 -1
  100. package/dist/packem_shared/{packument-CzXKq5Uj.js → packument-CW9GbXrT.js} +1 -1
  101. package/dist/packem_shared/{project-name-filter-DXEnW3Uz.js → project-name-filter-DQ323iaJ.js} +1 -1
  102. package/dist/packem_shared/{provenance-Bd0CbKIp.js → provenance-DnK4Z14A.js} +1 -1
  103. package/dist/packem_shared/publish-report-C-f7hkwx.js +1 -0
  104. package/dist/packem_shared/{registry-DBYHez15.js → registry-DqBIZZSL.js} +1 -1
  105. package/dist/packem_shared/{registry-keys-xPdrNru6.js → registry-keys-fVgmcPXl.js} +1 -1
  106. package/dist/packem_shared/{renderToString-DR0zDUjh-DYOVAAfx.js → renderToString-DR0zDUjh-C8HCAyYP.js} +1 -1
  107. package/dist/packem_shared/{resolve-explicit-BiX9lIh4.js → resolve-explicit-B9zDWjx_.js} +1 -1
  108. package/dist/packem_shared/{run-summary-utils-CkEtzBQD.js → run-summary-utils-H2tE2PUC.js} +1 -1
  109. package/dist/packem_shared/{runtime-check-Byzd_Jc9.js → runtime-check-B7ptIHX7.js} +1 -1
  110. package/dist/packem_shared/{s1ngularity-F2Tr5TBZ.js → s1ngularity-27TGL2H3.js} +1 -1
  111. package/dist/packem_shared/{scaffold-files-qM0oCb1Z.js → scaffold-files-BFWgtMR2.js} +1 -1
  112. package/dist/packem_shared/{scan-progress-e2fK9W0r.js → scan-progress-BwacnpFH.js} +1 -1
  113. package/dist/packem_shared/{selectors-BZF_PAg-.js → selectors-BisxDyYw.js} +1 -1
  114. package/dist/packem_shared/{signatures-FAEkrfxp.js → signatures-Bl3Y1qG3.js} +1 -1
  115. package/dist/packem_shared/{spinner-C14Fwarr.js → spinner-OBWz4yeR.js} +1 -1
  116. package/dist/packem_shared/{table-CXYb0Lek.js → table-BwL7to1g.js} +1 -1
  117. package/dist/packem_shared/{tabs-DbxzN8lr.js → tabs-Cr6uwTNJ.js} +1 -1
  118. package/dist/packem_shared/{toolchain-frFbcqqd.js → toolchain-DVLvBR49.js} +1 -1
  119. package/dist/packem_shared/{typosquats-CQMG0xHf.js → typosquats-DpcdyKGi.js} +1 -1
  120. package/dist/packem_shared/{use-measured-height-6ITmRvS-.js → use-measured-height-CVzcGyKB.js} +1 -1
  121. package/dist/packem_shared/{vis-update-app-_vu7O4s-.js → vis-update-app-0dbSUY-u.js} +1 -1
  122. package/dist/packem_shared/{vis-user-error-Dqv0he0c.js → vis-user-error-pMP1p7q1.js} +1 -1
  123. package/dist/packem_shared/watch-loop-ZjcOW5Qx.js +9 -0
  124. package/index.js +54 -54
  125. package/package.json +17 -13
  126. package/schemas/vis-config.schema.json +69 -0
  127. package/scripts/install-native.cjs +250 -0
  128. package/dist/packem_shared/glob-Cyk1H9ZL-CoeGrbCO.js +0 -1
  129. package/dist/packem_shared/publish-report-DOXKGOAj.js +0 -3
  130. package/dist/packem_shared/watch-loop-CgxpnVYG.js +0 -11
@@ -1,37 +1,25 @@
1
- import{createRequire as ye}from"node:module";import{b as C,F as g,X as xe,J as ce,q as ke}from"../packem_shared/index.server-Ca_EEVfw.js";import{m as Ie,v as F,U as k,a as _,e as U,z as Re}from"../packem_shared/index-0dnGN3GP.js";import{wholeMatchFingerprint as Ce,fingerprint as V,baselineKeys as J,legacyFingerprint as Fe,GIT_CONFIG_OVERRIDES as Te,DIFF_HARDENING_FLAGS as je,gitleaksIgnoreFingerprint as q,toSarifUri as Ee,CONFIDENCE_LEVELS as Y,DEFAULT_MAX_FILE_SIZE as Ae,MAX_ARCHIVE_DEPTH as De,listRules as le,listRequiredValidators as Ne,scan as Me,scanGitHistoryDetailed as Le,scanDetailed as _e,scanGitStaged as Be,scanFilesDetailed as Ue,inspectRuleset as Oe}from"@visulima/secret-scanner";import{V as p}from"../packem_shared/vis-user-error-Dqv0he0c.js";import{$ as qe,a0 as X,p as j}from"./cli-main.js";import{E as Pe,A as Ge}from"../packem_shared/getRandomSpinner-DX11qCB2-CoIsn7ZU.js";import{y as H}from"../packem_shared/isAccessibleSync-DYKTrrvc-CBsMZhj-.js";import{p as Ye}from"../packem_shared/package-version-CwpMpdja.js";import{e as B,c as Qe}from"../packem_shared/junit-audit-CuJShWCH.js";let be;const Se=e=>(be??=ye(import.meta.url))(e),A=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,L=e=>{if(typeof A<"u"&&A.versions&&A.versions.node){const[t,s]=A.versions.node.split(".").map(Number);if(t>22||t===22&&s>=3||t===20&&s>=16)return A.getBuiltinModule(e)}return Se(e)},{createRequire:Ve}=L("node:module"),{mkdirSync:He,writeFileSync:Z,openSync:ze,fchmodSync:Ke,closeSync:We,realpathSync:Je}=L("node:fs"),{execFileSync:Xe}=L("node:child_process"),{createHash:Ze}=L("node:crypto"),{pathToFileURL:de}=L("node:url");let et;const tt=e=>(et??=Ve(import.meta.url))(e),D=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,st=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 tt(e)},{styleText:it}=st("node:util"),rt={error:"✖",info:"ℹ",success:"✓",warning:"⚠"},nt=()=>{const{env:e}=process;return!!e.CI||e.CONTINUOUS_INTEGRATION==="true"||"BUILD_NUMBER"in e||"RUN_ID"in e},ot=/\u001B\[[\d;]*[a-z]/gi,at=e=>[...e.replaceAll(ot,"")].length,ct=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=>it(t,s)};class lt{#n=0;#l;#e=!1;#r="";#o="";#g=0;#d=0;#t;#s;#u="";#a;#m;#i;#y;#h=0;#c;#b;constructor(t={},s){if(t.frames)this.#a=t.frames;else{const i=t.name??"dots",n=Ge(i);if(!n)throw new Error(`Unknown spinner "${i}". Pass a custom \`frames\` set or use one of: ${Pe().join(", ")}.`);this.#a=n}this.#m=t.verbose!==!1,this.#r=t.prefixText??"",this.#t=s,this.#i=t.stream??process.stderr,this.#y=s?!0:this.#i.isTTY&&!nt(),this.#b={...rt,...t.icons},typeof t.style=="function"?this.#c=t.style:t.style&&(this.#c=ct(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.#r}set prefixText(t){this.#r=t,this.#e&&this.#w()}get isRunning(){return this.#e}setInteractiveManager(t){this.#t=t}setMultiSpinner(t){this.#s=t}tick(){this.#e&&(this.#n=(this.#n+1)%this.#a.frames.length)}start(t,s){return this.#e?this:this.#m?(this.#e=!0,this.#g=Date.now(),this.#d=0,this.#n=0,this.#u="",t&&(this.#o=t),s?.prefixText&&(this.#r=s.prefixText),this.#s?(this.#s.renderAll(),this):(this.#t?(this.#t.hook(),this.#S(),this.#$()):(this.#x(),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.#m))return;const s=t?.prefixText??this.#r,i=t?.text??this.#o;let n=t?.symbol??"";s&&(n=n?`${s} ${n}`:s),i&&(n=n?`${n} ${i}`:i),this.#k(n)}succeed(t){this.#f("success",t)}failed(t){this.#f("error",t)}warn(t){this.#f("warning",t)}info(t){this.#f("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.#n];let s=this.#c?this.#c(t):t;return this.#r&&(s=`${this.#r} ${s}`),this.#o&&(s=`${s} ${this.#o}`),s}#$(){this.#y&&(this.#l=setInterval(()=>{this.#e&&(this.#n=(this.#n+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.#x()}#S(){this.#t&&this.#t.update("stdout",[this.getFrameOutput()])}#x(){const t=this.getFrameOutput();if(this.#v(),this.#i.isTTY){this.#i.write(t);const s=this.#i.columns||80;this.#h=Math.max(1,Math.ceil(at(t)/s))}else this.#i.write(`${t}
2
- `),this.#h=0}#v(){if(this.#h>0&&this.#i.isTTY){for(let t=1;t<this.#h;t+=1)this.#i.write("\x1B[1A\x1B[2K");this.#i.write("\r\x1B[K")}this.#h=0}#k(t){this.#u=t,this.#s?this.#s.renderAll():this.#t?(this.#t.update("stdout",[t]),this.#t.unhook(!1)):(this.#v(),this.#i.write(`${t}
3
- `))}#f(t,s){if(!this.#e||(this.#p(),this.#e=!1,this.#d=Date.now(),!this.#m))return;let i="";const n=this.#b[t];n&&(i=this.#c?this.#c(n):n),this.#r&&(i=`${this.#r} ${i}`),s&&(i=`${i} ${s}`),this.#k(i)}}const ue=(e={})=>{const t=new qe(new X(process.stdout),new X(process.stderr));return new lt(e,t)},Q=384,he=(e,t,s)=>{if(He(Ie(e),{recursive:!0}),!s){Z(e,t);return}const i=ze(e,"w",Q);try{Ke(i,Q),Z(i,t)}finally{We(i)}},dt=(e,t)=>{if(!F(e))return e;const s=_(t,e);return s===""||s.startsWith("..")?e:s},P=e=>{try{return Je(e)}catch{return e}},pe=(e,t)=>{const s=_(e,t);return s===""||s.startsWith("..")||F(s)?t:s},E=(e,t)=>{const s=dt(e.file,t);return s===e.file?e:{...e,file:s}},z=e=>{if(!H(e))return[];try{const t=Ye(e);return Array.isArray(t)?t:[]}catch{return[]}},ee=(e,t,s)=>{const i=F(e.file)?e.file:k(t,e.file),n=pe(P(s),i);return n===e.file?e:{...e,file:n}},ut=(e,t,s)=>{const i=P(t),n=P(s);return z(e).flatMap(r=>{const a=pe(n,F(r.file)?r.file:k(i,r.file));return a===r.file?[r]:[r,{...r,file:a}]})},te=e=>[V({...e,secret:typeof e.secret=="string"?e.secret:""}),Fe(e)],ht=(e,t,s)=>{const i=z(t).map(o=>E(o,s)),n=new Set(i.flatMap(o=>te(o))),r=e.map(o=>E(o,s)),a=new Set(r.flatMap(o=>J(o))),l=o=>J(o).some(c=>n.has(c));return{fresh:r.filter(o=>!l(o)),resolved:i.filter(o=>!te(o).some(c=>a.has(c))),surviving:r.filter(o=>l(o))}},me=(e,t,s,i={})=>{const n=e.map(a=>E(a,s));let r;if(i.replace)r=n;else{const a=new Set(n.filter(c=>c.secret!==c.match).map(c=>Ce(c))),l=z(t).map(c=>E(c,s)).filter(c=>!a.has(V(c))),o=new Set;r=[];for(const c of[...l,...n]){const u=V(c);o.has(u)||(o.add(u),r.push(c))}}return he(t,`${JSON.stringify(r,null,4)}
4
- `,i.sensitive??!0),r.length},G=(e,t)=>{try{return Xe("git",[...Te,...t],{cwd:e,encoding:"utf8",stdio:["ignore","pipe","pipe"]})}catch{return""}},pt=e=>e.split("\0").filter(Boolean),se=(e,t)=>{if(t.startsWith("-"))throw new p(`--since "${t}" looks like a flag, not a git ref.`);const s=k(e,G(e,["rev-parse","--show-cdup"]).trim()),i=r=>pt(G(e,["diff","-z","--name-only","--diff-filter=ACMR",...je,r,"--"]));let n=i(`${t}...HEAD`);return n.length===0&&(n=i(t)),n.map(r=>F(r)?r:U(s,r))},ie=e=>G(e,["rev-parse","--show-toplevel"]).trim().length>0,mt=/^[\t\r+=@-]/,y=e=>{const t=mt.test(e)?`'${e}`:e;return/[\n\r",]/.test(t)?`"${t.replaceAll('"','""')}"`:t},ft=["RuleID","Commit","File","Secret","Match","StartLine","EndLine","StartColumn","EndColumn","Author","Message","Date","Email","Fingerprint","Tags"],gt=e=>{const t=e.map(s=>[y(s.ruleId),y(s.commit?.sha??""),y(s.file),y(s.secret),y(s.match),String(s.startLine),String(s.endLine),String(s.startColumn),String(s.endColumn),y(s.commit?.authorName??""),y(s.commit?.message??""),y(s.commit?.date??""),y(s.commit?.authorEmail??""),y(q(s)),y(s.tags.join(" "))].join(","));return`${[ft.join(","),...t].join(`\r
5
- `)}\r
6
- `},$t=e=>{const t=[...e];return t.length<=6?"******":`${t.slice(0,3).join("")}${"*".repeat(t.length-6)}${t.slice(-3).join("")}`},wt=(e,t={})=>{const s=(t.now??new Date).toISOString().replace(/\.\d{3}Z$/,""),i=String(e.length),n=e.map(r=>{const a=`${r.file}:${String(r.startLine)}:${String(r.startColumn)}`,l=[`Rule: ${r.ruleId}`,`File: ${a}`,...r.commit===void 0?[]:[`Commit: ${r.commit.sha}`,`Author: ${r.commit.authorName} <${r.commit.authorEmail}>`],`Secret: ${$t(r.secret)}`,`Fingerprint: ${q(r)}`].join(`
7
- `),o=`<failure type="${B(r.ruleId)}" message="${B(r.description||r.ruleId)}">${Qe(l)}</failure>`;return[` <testcase classname="${B(r.file)}" name="${B(`${r.ruleId} at ${a}`)}">`,` ${o}`," </testcase>",""].join(`
8
- `)}).join("");return['<?xml version="1.0" encoding="UTF-8"?>',`<testsuites name="vis-secrets" tests="${i}" failures="${i}" skipped="0" errors="0" time="0">`,` <testsuite name="secrets" tests="${i}" failures="${i}" skipped="0" errors="0" timestamp="${s}" time="0">`,`${n} </testsuite>`,"</testsuites>",""].join(`
9
- `)},vt=e=>{const t=e.map(s=>({categories:["Security"],check_name:s.ruleId,description:`${s.ruleId}: ${s.description||"Potential secret"}`,engine_name:"vis-secrets",fingerprint:Ze("sha256").update(`${q(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
- `},re=1,yt=e=>{const t=new Map;for(const s of e){const i=t.get(s.file);i?i.push(s):t.set(s.file,[s])}return t},bt=e=>{try{return Re(e).split(/\r?\n/)}catch{return}},St=(e,t,s)=>{const i=Math.max(1,t);return`${e.slice(0,i-1).replaceAll(/[^\t]/g," ")}${"^".repeat(Math.max(1,s))}`},N=e=>e,fe=e=>e?{cyan:ke,dim:g,green:ce,red:xe,yellow:C}:{cyan:N,dim:N,green:N,red:N,yellow:N},xt=(e,t,s,i={})=>{if(e.length===0)return s?g("No secrets detected."):"No secrets detected.";const n=fe(s),r=[],a=yt(e);for(const[l,o]of a){const c=_(t,l)||l;r.push(n.cyan(c));const u=i.redact?void 0:bt(l);for(const d of o){const $=[d.source,d.confidence].filter(Boolean).join(", "),b=$?` ${n.dim(`(${$})`)}`:"",w=d.alternateMatches&&d.alternateMatches.length>0?` ${n.dim(`also: ${d.alternateMatches.join(", ")}`)}`:"";let f="";switch(d.validation){case"error":{f=` ${n.yellow("! error")}`;break}case"rejected":{f=` ${n.red("✗ rejected")}`;break}case"skipped":{f=` ${n.dim("— unverifiable")}`;break}case"verified":{f=` ${n.green("✓ verified")}`;break}}if(r.push(` ${n.red("✖")} ${n.yellow(`[${d.ruleId}]`)}${b}${f} ${n.dim(`line ${String(d.startLine)}:${String(d.startColumn)}`)}${w}`),u){const m=Math.max(0,d.startLine-1-re),v=Math.min(u.length,d.startLine+re);for(let h=m;h<v;h+=1){const T=String(h+1).padStart(4," "),S=h+1===d.startLine,R=S?n.red("▶"):" ";if(r.push(` ${R} ${n.dim(T)} │ ${u[h]??""}`),S){const I=Math.max(1,(d.endColumn??d.startColumn+1)-d.startColumn),ve=St(u[h]??"",d.startColumn,I);r.push(` ${n.dim(" │ ")}${n.red(ve)}`)}}}r.push("")}}return r.join(`
11
- `).trimEnd()},kt=(e,t,s={})=>{if(e.length===0)return t?g("No secrets detected in git history."):"No secrets detected in git history.";const i=fe(t),n=new Map;for(const a of e){const l=n.get(a.commit.sha);l?l.push(a):n.set(a.commit.sha,[a])}const r=[];for(const[a,l]of n){const{authorName:o,date:c,message:u}=l[0].commit;r.push(`${i.yellow(a.slice(0,10))} ${u}`),r.push(` ${i.dim(`${o} · ${c}`)}`);for(const d of l){const $=[d.source,d.confidence].filter(Boolean).join(", "),b=$?` ${i.dim(`(${$})`)}`:"",w=s.redact?"":` ${i.dim(d.match)}`;r.push(` ${i.red("✖")} ${i.yellow(`[${d.ruleId}]`)}${b} ${i.cyan(d.file)} ${i.dim(`line ${String(d.startLine)}:${String(d.startColumn)}`)}${w}`)}r.push("")}return r.join(`
12
- `).trimEnd()},It=(e,t,s,i={})=>{const n=new Map;for(const o of e)n.set(o.reason,(n.get(o.reason)??0)+1);const r=[...n].map(([o,c])=>`${o}: ${String(c)}`).join(", "),a=`${String(e.length)} ${t}(s) not scanned (${r})${i.verbose?"":"; use --verbose to list them"}`,l=[s?C(a):a];if(i.verbose)for(const o of e){const c="sha"in o?` ${o.commit===void 0?"":`${o.commit.slice(0,10)} `}${o.sha.slice(0,10)}`:"",u=` - ${o.path} [${o.reason}]${c}`;l.push(s?g(u):u)}return l.join(`
13
- `)},Rt=(e,t)=>{if(!F(e))return Ee(e);try{return de(e).toString()}catch{return`file://${k(t,e).replaceAll("\\","/")}`}},Ct=(e,t=100)=>e.length<=t?e:`${e.slice(0,t-1).trimEnd()}…`,Ft=(e,t,s=process.cwd(),i=[])=>{const n=new Map(i.map(o=>[o.id,o])),r=new Set;for(const o of e)r.add(o.ruleId);const a=[...new Set([...n.keys(),...r])].sort((o,c)=>o.localeCompare(c)),l=new Map(a.map((o,c)=>[o,c]));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 c={};return o.source&&(c.source=o.source),o.confidence&&(c.confidence=o.confidence),o.alternateMatches&&o.alternateMatches.length>0&&(c.alternateRules=o.alternateMatches),o.validation&&(c.validation=o.validation),{level:"error",locations:[{physicalLocation:{artifactLocation:{uri:Rt(o.file,s),uriBaseId:F(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(c).length>0?c:void 0,ruleId:o.ruleId,ruleIndex:l.get(o.ruleId)??-1}}),tool:{driver:{informationUri:"https://visulima.com/packages/secret-scanner",name:"visulima-secret-scanner",rules:a.map(o=>{const c=n.get(o),u=c?.description??`Detected by rule \`${o}\``,d={};return c?.tags&&c.tags.length>0&&(d.tags=c.tags),c?.source&&(d.source=c.source),c?.confidence&&(d.confidence=c.confidence),{defaultConfiguration:{level:"error"},fullDescription:{text:u},helpUri:"https://visulima.com/packages/secret-scanner",id:o,name:o,properties:Object.keys(d).length>0?d:void 0,shortDescription:{text:Ct(u)}}}),version:t}}}],version:"2.1.0"},void 0,2)},K=["text","json","sarif","csv","junit","gitlab-code-quality"],ge=e=>K.includes(e),Tt=e=>{const t=[],s=new Set;for(const i of e){const n=i.indexOf("="),r=n===-1?i:i.slice(0,n),a=n===-1?"":i.slice(n+1);if(!ge(r))throw new p(`--report "${i}": format must be one of ${K.join(", ")}, as <format>=<path> (e.g. sarif=secrets.sarif)`);if(a==="")throw new p(`--report "${i}" needs a file path: ${r}=<path>`);if(s.has(a))throw new p(`--report writes ${a} twice; give each report its own file.`);s.add(a),t.push({format:r,path:a})}return t},ne=(e,t,s)=>{const i=()=>t.map(n=>E(n,s.root));switch(e){case"csv":return gt(i());case"gitlab-code-quality":return vt(i());case"json":return`${JSON.stringify(i(),null,2)}
14
- `;case"junit":return wt(i());case"sarif":return`${Ft(t,s.toolVersion,s.root,s.ruleMetadata)}
15
- `;default:return`${s.history?kt(t,s.useColor,{redact:s.redact}):xt(t,s.root,s.useColor,{redact:s.redact})}
16
- `}},jt=e=>e.kind==="secret"?"<secret-value entry>":e.raw,Et=(e,t,s)=>{const i=`${String(e.length)} unused ${t} entr${e.length===1?"y":"ies"} (no finding matched; remove or update them):`,n=[s?C(i):i];for(const r of e){const a=` - line ${String(r.line)}: ${jt(r)}`;n.push(s?g(a):a)}return n.join(`
17
- `)},At=(e,t,s)=>{const i=`${String(e.length)} finding(s) suppressed:`,n=[s?C(i):i];for(const r of e){const a=E(r,t),l=r.suppressedByEntry===void 0?"":` line ${String(r.suppressedByEntry.line)}`,o=`${r.suppressedBy}${l}`,c=` - [${r.ruleId}] ${q({...a,commit:r.commit})} (${o})`;n.push(s?g(c):c)}return n.join(`
18
- `)},Dt=async(e,t)=>{try{return await e.access(t),!0}catch{return!1}},O=e=>e?Array.isArray(e)?e:[e]:[],Nt=e=>{if(e===void 0)return"text";if(!ge(e))throw new p(`--format must be one of: ${K.join(", ")} (got "${e}")`);return e},oe=(e,t,s)=>{if(e!==void 0){if(!Number.isInteger(e)||e<0||s!==void 0&&e>s){const i=s===void 0?"a non-negative integer":`an integer from 0 to ${String(s)}`;throw new p(`${t} must be ${i} (got ${String(e)}).`)}return e}},Mt=e=>{if(e!==void 0&&(!Number.isInteger(e)||e<1))throw new p(`--max-size must be a positive number of bytes (got ${String(e)}; default ${String(Ae)}).`);return e},Lt=e=>{if(e!==void 0){if(!Y.includes(e))throw new p(`--min-confidence must be one of: ${Y.join(", ")} (got "${e}")`);return e}},_t=(e,t,s)=>{const i=t??{},n=h=>h?k(s,h):void 0,r=(h,T)=>{const S=O(h);return S.length>0?S:T},a=(i.config?.presets??[]).map(h=>`tag:preset:${h}`),l=r(e.enableRule,i.rules?.enable)??[],o=[...l,...a.filter(h=>!l.includes(h))],c=o.length>0?o:void 0,u=r(e.excludeRule,i.rules?.exclude),d=r(e.includeRule,i.rules?.include),$=r(e.exclude,i.walk?.excludePatterns),b=O(e.excludeFrom).map(h=>k(s,h)),w=b.length>0?b:i.walk?.excludeFromFiles?.map(h=>k(s,h)),f=n(e.baseline)??n(i.baseline),m=n(e.config)??n(i.config?.path),v=Lt(e.minConfidence??i.config?.minConfidence);return{baseline:f,concurrency:e.concurrency,config:{extendBundled:e.extendBundled===!1?!1:i.config?.extendBundled,inline:i.config?.inline,minConfidence:v,onlyVerified:e.onlyVerified??i.config?.onlyVerified??!1,path:m,validate:e.validate??i.config?.validate??!1},inlineAllow:e.inlineAllow,maxArchiveDepth:oe(e.maxArchiveDepth,"--max-archive-depth",De),maxDecodeDepth:oe(e.maxDecodeDepth,"--max-decode-depth"),redact:e.redact??i.redact,reportSuppressed:e.logIgnored===!0,rules:{enable:c,exclude:u,include:d},verbose:e.verbose??!1,walk:{excludeFromFiles:w,excludePatterns:$,gitignore:e.gitignore===!1?!1:i.walk?.gitignore??!0,includeHidden:e.includeHidden??i.walk?.includeHidden,maxFileSize:Mt(e.maxSize)??i.walk?.maxFileSize}}},$e=e=>[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),ae=(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),Bt=e=>{const t=$e(e);if(t.length>1)throw new p(`${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(i=>i!==void 0);if(s.length>0)throw new p(`${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 p("--all walks every ref and can't be combined with --history-range. Use one or the other.");if(e.updateBaseline)throw new p("--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 p(`--max-commits must be a positive integer (got ${String(e.maxCommits)}); omit it to walk every commit.`)},Ut=e=>{const t=e.history?"--history":e.staged?"--staged":void 0;if(e.maxArchiveDepth!==void 0&&t!==void 0)throw new p(`--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}.`)},we=(e,t)=>[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),Ot=(e,t)=>{const s=ae(e,!0),i=[O(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].filter(l=>l!==void 0);if(s!==void 0&&i.length>0)throw new p(`${i.join(", ")} only applies to a scan report and can't be combined with ${s}.`);const n=ae(e,!1),r=[...$e(e),...t?["explicit paths"]:[]];if(n!==void 0&&r.length>0)throw new p(`${r.join(", ")} picks what to scan and can't be combined with ${n}.`);if(!e.failOnUnusedIgnores)return;if(e.gitleaksIgnore===!1)throw new p("--fail-on-unused-ignores checks .gitleaksignore, which --no-gitleaks-ignore turns off. Drop one of them.");const a=we(e,t);if(a.length>0)throw new p(`--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.`)},W=".gitleaksignore",x=j.child({stdout:process.stderr}),qt=(e,t)=>{const{flags:s,root:i,useColor:n}=t;s.quiet||(e.skipped.length>0&&process.stderr.write(`${It(e.skipped,e.skippedUnit,n,{verbose:s.verbose})}
19
- `),t.fullScan&&e.unusedIgnores.length>0&&process.stderr.write(`${Et(e.unusedIgnores,W,n)}
20
- `)),s.logIgnored&&process.stderr.write(`${At(e.suppressed,i,n)}
21
- `)},Vt=e=>{process.stderr.write(`${g("baseline diff: ")}${ce(`+${String(e.fresh.length)} new`)} · ${C(`${String(e.surviving.length)} unchanged`)} · ${g(`-${String(e.resolved.length)} resolved`)}
22
- `)},Pt=async(e,t)=>{const{flags:s,format:i,history:n,reports:r,root:a,scanOptions:l,toolbox:o,toolVersion:c,useColor:u}=t,d=l.redact===!0,b=i==="sarif"||r.some(m=>m.format==="sarif")?await le(l).catch(()=>[]):[],w={history:n,redact:d,root:a,ruleMetadata:b,toolVersion:c},f=!d||n;process.stdout.write(ne(i,e.findings,{...w,useColor:u}));for(const m of r){const v=k(o.process.cwd,m.path);he(v,ne(m.format,e.findings,{...w,useColor:!1}),f),s.quiet||x.info(`Wrote ${m.format} report to ${_(o.process.cwd,v)||v}`)}},Gt=(e,t)=>{if(t.failOnUnreadable){const s=e.skipped.filter(i=>i.reason!=="too-large"&&i.reason!=="binary").length;s>0&&(x.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&&(x.error(`${String(e.unusedIgnores.length)} unused ${W} entr${e.unusedIgnores.length===1?"y":"ies"} (--fail-on-unused-ignores).`),process.exitCode=1)},M=".secrets-baseline.json",Ht=async(e,t)=>{const s=await le(e);process.stdout.write(`${String(s.length)} rules loaded
23
-
24
- `);for(const i of s){const n=t?C(i.id):i.id,r=i.tags.length>0?` ${t?g(`[${i.tags.join(", ")}]`):`[${i.tags.join(", ")}]`}`:"";if(process.stdout.write(`${n}${r}
25
- ${i.description}
26
- `),i.keywords.length>0){const a=`keywords: ${i.keywords.slice(0,6).join(", ")}${i.keywords.length>6?", ...":""}`;process.stdout.write(` ${t?g(a):a}
27
- `)}process.stdout.write(`
28
- `)}},zt=async(e,t)=>{const s=await Ne(e);if(s.length===0){process.stdout.write(t?`${g("No non-HTTP validators required by the current ruleset.")}
29
- `:`No non-HTTP validators required by the current ruleset.
30
- `);return}process.stdout.write(`${String(s.length)} non-HTTP validator type(s) referenced by the current ruleset:
31
-
32
- `);for(const i of s){const n=t?C(i.displayName):i.displayName,r=`(${i.type}, ${String(i.ruleCount)} rule${i.ruleCount===1?"":"s"})`;process.stdout.write(`${n} ${t?g(r):r}
33
- `),process.stdout.write(` ${i.summary}
34
- `);const a=i.packageName?`install: npm add ${i.packageName}`:"no driver — bespoke implementation required";process.stdout.write(` ${t?g(a):a}
35
-
36
- `)}},Kt=async(e,t,s)=>{const i=U(e,M);if(!s&&H(i)){j.warn(`Detected existing ${M} — refusing to overwrite. Delete it first to re-init.`),process.exitCode=1;return}j.info(s?"[dry-run] Previewing init — no files will be written.":"Scanning workspace to seed baseline…");const n=ue();n.start("scanning");let r;try{r=await Me([e],t),n.succeed()}catch(l){throw n.failed(),l}if(s){j.info(`[dry-run] Would create ${M} with ${String(r.length)} finding(s).`);return}const a=me(r,i,e,{replace:!0,sensitive:t.redact!==!0});j.success(`Wrote ${M} (${String(a)} findings).`),j.notice("Commit it. Use `vis secrets --baseline .secrets-baseline.json` in CI. Add path patterns to .gitignore to exclude directories from scanning.")},Wt=(e,t,s)=>{const i=t.length>0?t.map(r=>k(s,r)):[s],n=e.history?"--history":e.staged?"--staged":e.since===void 0?void 0:"--since";if(n!==void 0&&!ie(s))throw new p(`${n} requires a git working tree, and none was detected.`);return e.history?{kind:"history"}:e.staged?{kind:"staged"}:e.since!==void 0?{files:se(s,e.since),kind:"files"}:e.affected?ie(s)?{files:se(s,process.env.VIS_BASE??"HEAD~1"),kind:"files"}:(x.warn("--affected requires git; falling back to full scan"),{kind:"paths",paths:i}):{kind:"paths",paths:i}},Jt=async(e,t,s,i)=>{if(e.kind==="history")return{...await Le({...s,all:t.all,cwd:i,maxCommits:t.maxCommits,range:t.historyRange}),skippedUnit:"blob"};if(e.kind==="paths")return{...await _e(e.paths,s),skippedUnit:"file"};const n=process.cwd(),r={...s,baseline:typeof s.baseline=="string"?ut(s.baseline,i,n):s.baseline},a=e.kind==="staged"?await Be({...r,cwd:i}):await Ue(e.files,r);return{findings:a.findings.map(l=>ee(l,n,i)),skipped:a.skipped,skippedUnit:e.kind==="staged"?"blob":"file",suppressed:a.suppressed.map(l=>ee(l,n,i)),unusedIgnores:a.unusedIgnores}},Yt=async e=>{const t=await Oe(e);if(t.length>0){x.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}
37
- `)}},as=async e=>{const{argument:t,options:s,visConfig:i,workspaceRoot:n}=e,r=s,a=t??[],l=n??e.process.cwd,o=!r.quiet&&process.stdout.isTTY,c=i?.secrets,u=_t(r,c,l),d="0.0.0-alpha";Bt(r),Ut(r),Ot(r,a.length>0);const $=Nt(r.format),b=Tt(O(r.report)),w=U(l,W);if(r.gitleaksIgnore!==!1&&await Dt(e.fs,w)&&(u.gitleaksIgnore=w),r.listRules){await Ht(u,o);return}if(r.listValidators){await zt(u,o);return}if(r.init){await Kt(l,u,r.dryRun??!1);return}const f=Wt(r,a,l),m=f.kind==="history";if(f.kind==="files"&&f.files.length===0){r.quiet||x.success("No files to scan.");return}const v=ue({verbose:!r.quiet&&$==="text"});v.start(m?"scanning git history for secrets":"scanning for secrets");let h;try{h=await Jt(f,r,u,l),v.succeed()}catch(I){throw v.failed(),new p(`${m?"git-history secret scan":"secret scan"} failed: ${I instanceof Error?I.message:String(I)}`,{cause:I})}const T={flags:r,format:$,fullScan:we(r,a.length>0).length===0,history:m,reports:b,root:l,scanOptions:u,toolbox:e,toolVersion:d,useColor:o};qt(h,T),r.verbose&&await Yt(u);const{findings:S}=h,R=typeof u.baseline=="string"?u.baseline:U(l,M);if(r.updateBaseline){const I=me(S,R,l,{replace:r.replaceBaseline,sensitive:u.redact!==!0});x.success(`Baseline updated: ${_(l,R)||R} now contains ${String(I)} entries.`);return}await Pt(h,T),$==="text"&&!m&&!r.quiet&&H(R)&&Vt(ht(S,R,l)),S.length>0?(r.quiet||(x.warn(`${String(S.length)} potential secret(s) found${m?" across git history":""}`),x.notice(m?"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):r.quiet||x.success(m?"No secrets detected in git history.":"No secrets detected."),Gt(h,r)};export{as as default};
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,$ as ae,a0 as ie,a1 as re,a2 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 +1 @@
1
- import{r as m}from"../packem_shared/affected-shas-CycHU3nr.js";import{r as u}from"../packem_shared/toolchain-frFbcqqd.js";const $=async({argument:h,logger:r,options:e,runtime:s,visConfig:f,workspaceRoot:n})=>{const o=h[0];if(!o)throw new Error("Missing targets. Usage: vis ci <target>[,<target>…]");const l=o.split(",").map(a=>a.trim()).filter(Boolean);if(l.length===0)throw new Error("Missing targets. Usage: vis ci <target>[,<target>…]");if(!n)throw new Error("Could not determine workspace root. Run this command inside a monorepo.");const i=m({defaultBase:f?.defaultBase,workspaceRoot:n}),c=e.base??i.base,d=e.head??i.head;!e.base&&!e.head&&r.info(`▸ Resolved affected refs from ${i.provider} (${i.notes.join("; ")})`),e.skipToolchain||r.info("▸ Toolchain pre-flight"),await u(n,f?.toolchain,{error:a=>{r.error(a)},info:a=>{r.info(a)},warn:a=>{r.warn(a)}},!!e.skipToolchain),e.install?(r.info("▸ Installing dependencies"),await s.runCommand("install",{argv:["--ci","--frozen-lockfile"]})):r.info("▸ Skipping install (--no-install)");for(const a of l){r.info(`▸ Running affected ${a} (base=${c}, head=${d})`);const t=[a,`--base=${c}`,`--head=${d}`,`--upstream=${String(e.upstream??"none")}`,`--downstream=${String(e.downstream??"deep")}`];Number.isFinite(e.parallel)&&t.push(`--parallel=${String(e.parallel)}`),e.partition&&t.push(`--partition=${String(e.partition)}`),e.query&&t.push(`--query=${String(e.query)}`),e.ifPresent&&t.push("--if-present"),await s.runCommand("affected",{argv:t})}r.info("▸ CI pipeline complete")};export{$ as default};
1
+ import{r as m}from"../packem_shared/affected-shas-CycHU3nr.js";import{r as u}from"../packem_shared/toolchain-DVLvBR49.js";const $=async({argument:h,logger:r,options:e,runtime:s,visConfig:f,workspaceRoot:n})=>{const o=h[0];if(!o)throw new Error("Missing targets. Usage: vis ci <target>[,<target>…]");const l=o.split(",").map(a=>a.trim()).filter(Boolean);if(l.length===0)throw new Error("Missing targets. Usage: vis ci <target>[,<target>…]");if(!n)throw new Error("Could not determine workspace root. Run this command inside a monorepo.");const i=m({defaultBase:f?.defaultBase,workspaceRoot:n}),c=e.base??i.base,d=e.head??i.head;!e.base&&!e.head&&r.info(`▸ Resolved affected refs from ${i.provider} (${i.notes.join("; ")})`),e.skipToolchain||r.info("▸ Toolchain pre-flight"),await u(n,f?.toolchain,{error:a=>{r.error(a)},info:a=>{r.info(a)},warn:a=>{r.warn(a)}},!!e.skipToolchain),e.install?(r.info("▸ Installing dependencies"),await s.runCommand("install",{argv:["--ci","--frozen-lockfile"]})):r.info("▸ Skipping install (--no-install)");for(const a of l){r.info(`▸ Running affected ${a} (base=${c}, head=${d})`);const t=[a,`--base=${c}`,`--head=${d}`,`--upstream=${String(e.upstream??"none")}`,`--downstream=${String(e.downstream??"deep")}`];Number.isFinite(e.parallel)&&t.push(`--parallel=${String(e.parallel)}`),e.partition&&t.push(`--partition=${String(e.partition)}`),e.query&&t.push(`--query=${String(e.query)}`),e.ifPresent&&t.push("--if-present"),await s.runCommand("affected",{argv:t})}r.info("▸ CI pipeline complete")};export{$ as default};
@@ -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-DBYHez15.js";import{p as S}from"../packem_shared/package-version-CwpMpdja.js";import{U as fe}from"../packem_shared/env-UwvvHfsx.js";import{l as le}from"../packem_shared/missing-package-json-BcKnQERZ.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};
@@ -1,4 +1,4 @@
1
- import{e as C,z as P,U as pe}from"../packem_shared/index-0dnGN3GP.js";import{M as ge,N as le,P as de,L as me,C as ye,R as ke,p as m,q as fe}from"./cli-main.js";import{i as ue}from"../packem_shared/index-BjdW45xX.js";import he from"module-replacements/manifests/micro-utilities.json"with{type:"json"};import je from"module-replacements/manifests/native.json"with{type:"json"};import ve from"module-replacements/manifests/preferred.json"with{type:"json"};import{K as be,j as t,X as g,O as c,r as O,R as xe,h as Te,i as W}from"../packem_shared/registry-DBYHez15.js";import{a as ee}from"../packem_shared/index--eV4qIz5.js";import{l as Ie}from"./ts-loader.js";import{y as V}from"../packem_shared/isAccessibleSync-DYKTrrvc-CBsMZhj-.js";import{U as D}from"../packem_shared/env-UwvvHfsx.js";import{d as we,n as Me}from"../packem_shared/pm-runner-BXRi4ZM9.js";import{p as re}from"../packem_shared/package-version-CwpMpdja.js";import{l as Se}from"../packem_shared/glob-Cyk1H9ZL-CoeGrbCO.js";const Ce=["dependencies","devDependencies","peerDependencies","peerDependenciesMeta","optionalDependencies","bundleDependencies"],Ee=["overrides","pnpm","resolutions"],$e=["engines","files"],Oe=r=>{const e=ee.coerce(r)?.major;return e!==void 0&&e>=10},De=r=>{const e=C(r,"pnpm-workspace.yaml");if(!V(e))return{overrides:{},source:"pnpm-workspace.yaml"};try{return{overrides:Ie(e)?.overrides??{},source:"pnpm-workspace.yaml"}}catch{return{overrides:{},source:"pnpm-workspace.yaml"}}},Pe=(r,e)=>{let s={};return e==="pnpm"?s=r.pnpm?.overrides??{}:e==="yarn"||e==="bun"?s=r.resolutions??{}:s=r.overrides??{},{overrides:s,source:"package.json"}},Ne=(r,e,s)=>s.name==="pnpm"&&Oe(s.version)?De(r):Pe(e,s.name),Y=(r,e)=>{const s=e;for(const o of Ee){const n=r.indexOf(o);if(n!==-1&&o!==s)return s==="overrides"?n:n+1}let i=-1;for(const o of Ce){const n=r.indexOf(o);n>i&&(i=n)}if(i!==-1)return i+1;for(const o of $e){const n=r.indexOf(o);if(n!==-1)return n}return r.length},Ae=(r,e)=>{const s=C(r,"pnpm-workspace.yaml");if(!V(s))throw new Error(`pnpm-workspace.yaml not found at ${s}. Cannot write overrides for pnpm v10+.`);let i=P(s);const n=`overrides:
1
+ import{e as C,z as P,U as pe}from"../packem_shared/index-0dnGN3GP.js";import{M as ge,N as le,P as de,L as me,C as ye,R as ke,p as m,q as fe}from"./cli-main.js";import{i as ue}from"../packem_shared/index-BjdW45xX.js";import he from"module-replacements/manifests/micro-utilities.json"with{type:"json"};import je from"module-replacements/manifests/native.json"with{type:"json"};import ve from"module-replacements/manifests/preferred.json"with{type:"json"};import{K as be,j as t,X as g,O as c,r as O,R as xe,h as Te,i as W}from"../packem_shared/registry-DqBIZZSL.js";import{a as ee}from"../packem_shared/index--eV4qIz5.js";import{l as Ie}from"./ts-loader.js";import{y as V}from"../packem_shared/isAccessibleSync-DYKTrrvc-CBsMZhj-.js";import{U as D}from"../packem_shared/env-5cWSxQ96.js";import{d as we,n as Me}from"../packem_shared/pm-runner-BXRi4ZM9.js";import{p as re}from"../packem_shared/package-version-lWlrF9Wk.js";import{l as Se}from"../packem_shared/glob-Cyk1H9ZL-CYVM7sl3.js";const Ce=["dependencies","devDependencies","peerDependencies","peerDependenciesMeta","optionalDependencies","bundleDependencies"],Ee=["overrides","pnpm","resolutions"],$e=["engines","files"],Oe=r=>{const e=ee.coerce(r)?.major;return e!==void 0&&e>=10},De=r=>{const e=C(r,"pnpm-workspace.yaml");if(!V(e))return{overrides:{},source:"pnpm-workspace.yaml"};try{return{overrides:Ie(e)?.overrides??{},source:"pnpm-workspace.yaml"}}catch{return{overrides:{},source:"pnpm-workspace.yaml"}}},Pe=(r,e)=>{let s={};return e==="pnpm"?s=r.pnpm?.overrides??{}:e==="yarn"||e==="bun"?s=r.resolutions??{}:s=r.overrides??{},{overrides:s,source:"package.json"}},Ne=(r,e,s)=>s.name==="pnpm"&&Oe(s.version)?De(r):Pe(e,s.name),Y=(r,e)=>{const s=e;for(const o of Ee){const n=r.indexOf(o);if(n!==-1&&o!==s)return s==="overrides"?n:n+1}let i=-1;for(const o of Ce){const n=r.indexOf(o);n>i&&(i=n)}if(i!==-1)return i+1;for(const o of $e){const n=r.indexOf(o);if(n!==-1)return n}return r.length},Ae=(r,e)=>{const s=C(r,"pnpm-workspace.yaml");if(!V(s))throw new Error(`pnpm-workspace.yaml not found at ${s}. Cannot write overrides for pnpm v10+.`);let i=P(s);const n=`overrides:
2
2
  ${Object.entries(e).map(([p,d])=>` '${p}': '${d}'`).join(`
3
3
  `)}
4
4
  `;i=/^overrides:\s*$/m.test(i)||/^overrides:\s*\n/m.test(i)?i.replace(/^overrides:\s*\n(?:(?:[ \t].*)?\n)*/m,n):`${i.trimEnd()}