@visulima/vis 6.8.0 → 7.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1 +1 @@
1
- import{VisReleaseError as x}from"../packem_shared/VisReleaseError-DZtgcKf8.js";import{r as d,a as g}from"../packem_shared/publish-report-DOXKGOAj.js";import{b as y}from"./context.js";import{p as C,a as P}from"../packem_shared/publish-missing-CZK1BpWt.js";const k=async({logger:t,options:s,workspaceRoot:p})=>{const m=p??process.cwd(),l=s.dryRun===!0,c=s.missing===!0,h=s.filter?s.filter.split(",").map(e=>e.trim()).filter(Boolean):void 0;if(c&&(s.checkOnly===!0||s.firstRelease===!0)){t.error(`--missing cannot be combined with ${s.checkOnly===!0?"--check-only":"--first-release"}.`),process.exitCode=1;return}let n;try{n=await y({channel:s.channel,cwd:m,firstRelease:s.firstRelease===!0,projects:h})}catch(e){t.error(`Failed to load release context: ${e instanceof Error?e.message:String(e)}`),process.exitCode=1;return}const{printConfigIfRequested:$}=await import("./print-config.js");if($(s,n,t))return;if(s.checkOnly===!0){if(t.info(`Preflight: ${n.plan.releases.length} pending publish(es)${n.channel?` to dist-tag "${n.channel.tag}"`:""}.`),n.plan.warnings.length>0)for(const e of n.plan.warnings)t.warn(` - ${e}`);process.exitCode=n.plan.releases.length===0?1:0;return}if(!c&&n.plan.releases.length===0){t.info("No pending releases — nothing to publish.");return}const a=s.tag??n.channel?.tag;a||t.warn("No --tag provided and no channel matched the current branch. Defaulting to dist-tag 'latest'. Set channels in vis.config.ts to control this."),c?t.info(`Looking for released versions that never reached dist-tag "${a??"latest"}"...`):t.info(`${l?"[dry-run] would publish":"Publishing"} ${n.plan.releases.length} package(s) to dist-tag "${a??"latest"}"${l?"":"..."}`);let i,{warnings:f}=n.plan;try{const e={dryRun:l,noPush:!s.push,otp:s.otp,resume:s.resume===!0,tag:a};if(c){i=await C(n,{...e,projects:h}),{warnings:f}=i;for(const r of i.missing){const o=r.onRegistry?"tag":"publish";t.info(` [missing] ${r.name}@${r.version} (${l?`would ${o}`:o}, release commit ${r.commit.slice(0,7)})`)}i.missing.length===0&&t.info("No released-but-unpublished versions found.")}else i=await P(n,e)}catch(e){if(d(t,f),e instanceof x&&e.code==="STAGE_PENDING"){t.error(e.message),e.hint&&(t.info(""),t.info(`Next steps: ${e.hint}`)),process.exitCode=1;return}t.error(`Publish failed: ${e instanceof Error?e.message:String(e)}`),process.exitCode=1;return}t.info(""),g(t,i,a??"latest"),d(t,f),i.failed.length===0?process.exitCode=0:i.published.length===0&&i.skipped.length===0?process.exitCode=3:process.exitCode=2;const u=i.failed.filter(e=>/\bEOTP\b|one[- ]time password|otp/i.test(e.reason));if(u.length>0){t.info(""),t.warn("Publish failed because the registry required a 2FA OTP. Rerun with:");const e=u.map(w=>w.name).join(","),r=s.channel?` --channel=${s.channel}`:"",o=s.tag?` --tag=${s.tag}`:"",b=` --filter='${e}'`;t.info(` vis release publish --otp=REPLACE_WITH_NEW_OTP --resume${o}${r}${b}`)}};export{k as default};
1
+ import{VisReleaseError as x}from"../packem_shared/VisReleaseError-DZtgcKf8.js";import{r as d,a as g}from"../packem_shared/publish-report-C-f7hkwx.js";import{b as y}from"./context.js";import{p as C,a as P}from"../packem_shared/publish-missing-CZK1BpWt.js";const k=async({logger:t,options:s,workspaceRoot:p})=>{const m=p??process.cwd(),l=s.dryRun===!0,c=s.missing===!0,h=s.filter?s.filter.split(",").map(e=>e.trim()).filter(Boolean):void 0;if(c&&(s.checkOnly===!0||s.firstRelease===!0)){t.error(`--missing cannot be combined with ${s.checkOnly===!0?"--check-only":"--first-release"}.`),process.exitCode=1;return}let n;try{n=await y({channel:s.channel,cwd:m,firstRelease:s.firstRelease===!0,projects:h})}catch(e){t.error(`Failed to load release context: ${e instanceof Error?e.message:String(e)}`),process.exitCode=1;return}const{printConfigIfRequested:$}=await import("./print-config.js");if($(s,n,t))return;if(s.checkOnly===!0){if(t.info(`Preflight: ${n.plan.releases.length} pending publish(es)${n.channel?` to dist-tag "${n.channel.tag}"`:""}.`),n.plan.warnings.length>0)for(const e of n.plan.warnings)t.warn(` - ${e}`);process.exitCode=n.plan.releases.length===0?1:0;return}if(!c&&n.plan.releases.length===0){t.info("No pending releases — nothing to publish.");return}const a=s.tag??n.channel?.tag;a||t.warn("No --tag provided and no channel matched the current branch. Defaulting to dist-tag 'latest'. Set channels in vis.config.ts to control this."),c?t.info(`Looking for released versions that never reached dist-tag "${a??"latest"}"...`):t.info(`${l?"[dry-run] would publish":"Publishing"} ${n.plan.releases.length} package(s) to dist-tag "${a??"latest"}"${l?"":"..."}`);let i,{warnings:f}=n.plan;try{const e={dryRun:l,noPush:!s.push,otp:s.otp,resume:s.resume===!0,tag:a};if(c){i=await C(n,{...e,projects:h}),{warnings:f}=i;for(const r of i.missing){const o=r.onRegistry?"tag":"publish";t.info(` [missing] ${r.name}@${r.version} (${l?`would ${o}`:o}, release commit ${r.commit.slice(0,7)})`)}i.missing.length===0&&t.info("No released-but-unpublished versions found.")}else i=await P(n,e)}catch(e){if(d(t,f),e instanceof x&&e.code==="STAGE_PENDING"){t.error(e.message),e.hint&&(t.info(""),t.info(`Next steps: ${e.hint}`)),process.exitCode=1;return}t.error(`Publish failed: ${e instanceof Error?e.message:String(e)}`),process.exitCode=1;return}t.info(""),g(t,i,a??"latest"),d(t,f),i.failed.length===0?process.exitCode=0:i.published.length===0&&i.skipped.length===0?process.exitCode=3:process.exitCode=2;const u=i.failed.filter(e=>/\bEOTP\b|one[- ]time password|otp/i.test(e.reason));if(u.length>0){t.info(""),t.warn("Publish failed because the registry required a 2FA OTP. Rerun with:");const e=u.map(w=>w.name).join(","),r=s.channel?` --channel=${s.channel}`:"",o=s.tag?` --tag=${s.tag}`:"",b=` --filter='${e}'`;t.info(` vis release publish --otp=REPLACE_WITH_NEW_OTP --resume${o}${r}${b}`)}};export{k as default};
@@ -1,4 +1,4 @@
1
- import{createRequire as W}from"node:module";import{DEFAULT_CHANGES_DIR as X}from"./DEFAULT_CLEAN_KEEP.js";import{b as A,r as Y,n as Z}from"./context.js";import{r as ee}from"../packem_shared/run-BvhcgfRq.js";import{toRepoRelativePath as I,listUncommittedPaths as te,getCurrentSha as F,getCurrentBranch as ne,getShortSha as se,pushBranchWithRebase as O,stageAndCommit as re,pushBranch as ie}from"./git.js";import{createShellRunner as ae}from"./shell-runner.js";import{stateFilePath as oe}from"./state.js";import{d as ce}from"../packem_shared/sticky-comment-DjhyCIZt.js";import{g as le}from"./native-addon.js";import{VisReleaseError as L}from"../packem_shared/VisReleaseError-DZtgcKf8.js";import{r as ue,l as g,b as he,a as U}from"../packem_shared/publish-report-DOXKGOAj.js";import{f as de,w as fe,p as pe,b as me,d as ge,a as G}from"../packem_shared/publish-missing-CZK1BpWt.js";import{a as q,s as be}from"../packem_shared/apply-C6qxfMqZ.js";let K;const z=s=>(K??=W(import.meta.url))(s),S=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,J=s=>{if(typeof S<"u"&&S.versions&&S.versions.node){const[e,r]=S.versions.node.split(".").map(Number);if(e>22||e===22&&r>=3||e===20&&r>=16)return S.getBuiltinModule(s)}return z(s)},{join:Q}=J("node:path"),ve="<!-- vis:user-content -->",we="<!-- /vis:user-content -->",$e=/<!-- vis:user-content -->([\s\S]*?)<!-- \/vis:user-content -->/g,Ce=/<!-- vis:user-content -->(?:(?!<!-- \/vis:user-content -->)[\s\S])*?<!-- vis:user-content -->/,ye=s=>`${ve}${s}${we}`,Re=(s,e)=>{const r=[],l=/<!-- vis:user-content -->\s*<!-- \/vis:user-content -->/g;let u=l.exec(s);for(;u!==null;)r.push({end:u.index+u[0].length,start:u.index}),u=l.exec(s);if(r.length===0)return{body:s,remaining:e};let n=0;const o=[],t=Math.min(r.length,e.length);for(let p=0;p<t;p+=1){const m=r[p],h=e[p];o.push(s.slice(n,m.start)),o.push(h),n=m.end}return o.push(s.slice(n)),{body:o.join(""),remaining:e.slice(t)}},Pe=(s,e)=>{if(s===void 0||s==="")return e;const r=s.replaceAll(/```[\s\S]*?```/g,"").replaceAll(/~~~[\s\S]*?~~~/g,""),l=(r.match(/<!-- vis:user-content -->/g)??[]).length,u=(r.match(/<!-- \/vis:user-content -->/g)??[]).length;if(l!==u)throw new L({code:"CONFIG_INVALID",hint:"Fix the marker pairs in the PR body and re-run.",message:`PR body has unbalanced <!-- vis:user-content --> markers (${l} opens, ${u} closes). Refusing to merge to prevent silent edit loss.`});if(Ce.test(r))throw new L({code:"CONFIG_INVALID",hint:"Flatten the nesting in the PR body and re-run.",message:"Nested <!-- vis:user-content --> markers are not allowed in PR body. The merger refuses to operate to prevent silent edit loss."});const n=[];for(const h of s.matchAll($e)){const v=h[1]??"";v.trim()!==""&&n.push(ye(v))}if(n.length===0)return e;const{body:o,remaining:t}=Re(e,n);if(t.length===0)return o;const p=o.replace(/\s+$/u,""),m=t.join(`
1
+ import{createRequire as W}from"node:module";import{DEFAULT_CHANGES_DIR as X}from"./DEFAULT_CLEAN_KEEP.js";import{b as A,r as Y,n as Z}from"./context.js";import{r as ee}from"../packem_shared/run-BvhcgfRq.js";import{toRepoRelativePath as I,listUncommittedPaths as te,getCurrentSha as F,getCurrentBranch as ne,getShortSha as se,pushBranchWithRebase as O,stageAndCommit as re,pushBranch as ie}from"./git.js";import{createShellRunner as ae}from"./shell-runner.js";import{stateFilePath as oe}from"./state.js";import{d as ce}from"../packem_shared/sticky-comment-DjhyCIZt.js";import{g as le}from"./native-addon.js";import{VisReleaseError as L}from"../packem_shared/VisReleaseError-DZtgcKf8.js";import{r as ue,l as g,b as he,a as U}from"../packem_shared/publish-report-C-f7hkwx.js";import{f as de,w as fe,p as pe,b as me,d as ge,a as G}from"../packem_shared/publish-missing-CZK1BpWt.js";import{a as q,s as be}from"../packem_shared/apply-C6qxfMqZ.js";let K;const z=s=>(K??=W(import.meta.url))(s),S=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,J=s=>{if(typeof S<"u"&&S.versions&&S.versions.node){const[e,r]=S.versions.node.split(".").map(Number);if(e>22||e===22&&r>=3||e===20&&r>=16)return S.getBuiltinModule(s)}return z(s)},{join:Q}=J("node:path"),ve="<!-- vis:user-content -->",we="<!-- /vis:user-content -->",$e=/<!-- vis:user-content -->([\s\S]*?)<!-- \/vis:user-content -->/g,Ce=/<!-- vis:user-content -->(?:(?!<!-- \/vis:user-content -->)[\s\S])*?<!-- vis:user-content -->/,ye=s=>`${ve}${s}${we}`,Re=(s,e)=>{const r=[],l=/<!-- vis:user-content -->\s*<!-- \/vis:user-content -->/g;let u=l.exec(s);for(;u!==null;)r.push({end:u.index+u[0].length,start:u.index}),u=l.exec(s);if(r.length===0)return{body:s,remaining:e};let n=0;const o=[],t=Math.min(r.length,e.length);for(let p=0;p<t;p+=1){const m=r[p],h=e[p];o.push(s.slice(n,m.start)),o.push(h),n=m.end}return o.push(s.slice(n)),{body:o.join(""),remaining:e.slice(t)}},Pe=(s,e)=>{if(s===void 0||s==="")return e;const r=s.replaceAll(/```[\s\S]*?```/g,"").replaceAll(/~~~[\s\S]*?~~~/g,""),l=(r.match(/<!-- vis:user-content -->/g)??[]).length,u=(r.match(/<!-- \/vis:user-content -->/g)??[]).length;if(l!==u)throw new L({code:"CONFIG_INVALID",hint:"Fix the marker pairs in the PR body and re-run.",message:`PR body has unbalanced <!-- vis:user-content --> markers (${l} opens, ${u} closes). Refusing to merge to prevent silent edit loss.`});if(Ce.test(r))throw new L({code:"CONFIG_INVALID",hint:"Flatten the nesting in the PR body and re-run.",message:"Nested <!-- vis:user-content --> markers are not allowed in PR body. The merger refuses to operate to prevent silent edit loss."});const n=[];for(const h of s.matchAll($e)){const v=h[1]??"";v.trim()!==""&&n.push(ye(v))}if(n.length===0)return e;const{body:o,remaining:t}=Re(e,n);if(t.length===0)return o;const p=o.replace(/\s+$/u,""),m=t.join(`
2
2
 
3
3
  `);return`${p}
4
4
 
@@ -1,3 +1,3 @@
1
- import{createRequire as H}from"node:module";import{J as A,q as G,j as W,F as E}from"../packem_shared/index.server-Ca_EEVfw.js";import{a as P}from"../packem_shared/index-0dnGN3GP.js";import{T as I}from"./cli-main.js";import{w as Q,r as X,a as Y,s as Z,c as ee,b as te,d as se,e as ie,f as ne,g as re,h as ae,i as oe,j as ce,k as de,l as fe,m as le,n as ue}from"../packem_shared/watch-loop-CpqHmDCt.js";import{v as h}from"../packem_shared/registry-DqBIZZSL.js";import{d as C,f as _,a as pe}from"../packem_shared/detect-D8zxVYrU.js";let J;const U=e=>(J??=H(import.meta.url))(e),w=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,D=e=>{if(typeof w<"u"&&w.versions&&w.versions.node){const[t,s]=w.versions.node.split(".").map(Number);if(t>22||t===22&&s>=3||t===20&&s>=16)return w.getBuiltinModule(e)}return U(e)},{createHash:F}=D("node:crypto"),ge=e=>e.startsWith("/")||/^[a-z]:[\\/]/i.test(e),q=(e,t)=>ge(t)?t:`${e}/${t}`,me={argsCheck:(e,t)=>O(e,t,"check"),argsFix:(e,t)=>O(e,t,"fix"),bin:()=>["pnpm","exec","dprint"],cacheKey:(e,t)=>{const s=["dprint",e.declaredVersion??"unknown",e.configFile??"no-config",t.quiet?"q":"",...t.extraArgs??[]];return F("sha256").update(s.join("|")).digest("hex").slice(0,16)},detect:(e,t)=>{const s=C(t,h.dprint.packageNames[0]),i=_(e,h.dprint.configFiles);if(!(!s&&!i))return{adapter:"dprint",configFile:i,declared:!!s,declaredVersion:s,root:e}},extensions:["cjs","css","cts","dockerfile","html","js","json","jsonc","jsx","md","mdx","mjs","mts","toml","ts","tsx","yaml","yml"],id:"dprint",kind:"fmt",parse:(e,t)=>{if(e.exitCode===0)return[];const s=[];for(const i of e.stdout.split(/\r?\n/)){const n=i.trim();!n||n.startsWith("[")||n.startsWith("Checked ")||n.startsWith("Error:")||s.push({adapter:"dprint",file:q(t.root,n),fixable:!0,message:"Code style issues would be auto-fixed",severity:"info"})}return s}},O=(e,t,s)=>{const i=s==="fix"?["fmt"]:["check","--list-different"];return t.extraArgs?.length&&i.push(...t.extraArgs),i.push(...e),i},he={argsCheck:(e,t)=>V(e,t,"check"),argsFix:(e,t)=>V(e,t,"fix"),bin:()=>["pnpm","exec","oxfmt"],cacheKey:(e,t)=>{const s=["oxfmt",e.declaredVersion??"unknown",e.configFile??"no-config",t.quiet?"q":"",...t.extraArgs??[]];return F("sha256").update(s.join("|")).digest("hex").slice(0,16)},detect:(e,t)=>{const s=C(t,h.oxfmt.packageNames[0]),i=_(e,h.oxfmt.configFiles);if(!(!s&&!i))return{adapter:"oxfmt",configFile:i,declared:!!s,declaredVersion:s,root:e}},extensions:["cjs","cts","js","json","jsonc","jsx","mjs","mts","ts","tsx"],id:"oxfmt",kind:"fmt",parse:(e,t)=>{if(e.exitCode===0)return[];const s=[];for(const i of e.stdout.split(/\r?\n/)){const n=i.trim();!n||n.startsWith("[")||s.push({adapter:"oxfmt",file:q(t.root,n),fixable:!0,message:"Code style issues would be auto-fixed",severity:"info"})}return s}},V=(e,t,s)=>{const i=s==="fix"?["--write"]:["--list-different"];return t.extraArgs?.length&&i.push(...t.extraArgs),i.push(...e),i},xe={argsCheck:(e,t)=>N(e,t,"check"),argsFix:(e,t)=>N(e,t,"fix"),bin:()=>["pnpm","exec","prettier"],cacheKey:(e,t)=>{const s=["prettier",e.declaredVersion??"unknown",e.configFile??"no-config",t.quiet?"q":"",...t.extraArgs??[]];return F("sha256").update(s.join("|")).digest("hex").slice(0,16)},detect:(e,t)=>{const s=C(t,h.prettier.packageNames[0]),i=_(e,h.prettier.configFiles);if(!(!s&&!i))return{adapter:"prettier",configFile:i,declared:!!s,declaredVersion:s,root:e}},extensions:["cjs","css","cts","html","js","json","jsx","less","md","mdx","mjs","mts","scss","ts","tsx","vue","yaml","yml"],id:"prettier",kind:"fmt",parse:(e,t)=>{if(e.exitCode===0)return[];const s=[];for(const i of e.stdout.split(/\r?\n/)){const n=i.trim();n&&(n.startsWith("[")||s.push({adapter:"prettier",file:q(t.root,n),fixable:!0,message:"Code style issues would be auto-fixed",severity:"info"}))}return s}},N=(e,t,s)=>{const i=s==="fix"?["--write"]:["--list-different"];return t.quiet&&i.push("--log-level","warn"),t.extraArgs?.length&&i.push(...t.extraArgs),i.push(...e),i},we=[he,se,me,xe,ie],$e=async({logger:e,options:t,visConfig:s,workspaceRoot:i})=>{const n=i??process.cwd(),l=s?.fmt;Q(e,"fmt",l);const k=X(we,l?.order),L=pe(n,k),x=Y(L,k,"fmt").filter(({adapter:u})=>l?.adapters?.[u.id]?.enabled!==!1);if(x.length===0){e.warn("vis fmt: no formatter detected in this workspace (looked for: oxfmt, biome, dprint, prettier, ruff).");return}const R=u=>{const a=l?.adapters?.[u]?.extraArgs;return a&&a.length>0?[...a]:void 0},v={quiet:t.quiet??!1},$=ke(t),b=t.check?"check":"fix";let c;if(t.staged){if(c=Z(n),c===void 0)e.warn("vis fmt: could not resolve --staged (not a git repo or git unavailable). Falling back to a workspace-wide run.");else if(c.length===0){e.info(A("✓ fmt: no staged files"));return}}else if(typeof t.since=="string"&&t.since.length>0){if(c=ee(n,t.since),c===void 0)e.warn(`vis fmt: could not resolve --since ${t.since} (not a git repo or unknown ref). Falling back to a workspace-wide run.`);else if(c.length===0){e.info(A(`✓ fmt: no files changed since ${t.since}`));return}}const K=I(n,void 0,void 0,!0),y=t.format??"human";y==="human"&&t.output!==void 0&&e.warn("vis fmt: --output is ignored for the human format; pass --format json|minimal|sarif|junit|github to redirect findings to a file.");const M=async u=>{const a=$.length>0?$:u,g=[];if(a){const r=ne(a,x,l?.extensionOverrides);for(const{adapter:o,presence:d}of x){const f=r.get(o.id);if(!f||f.length===0)continue;const B=R(o.id),T={adapter:o,files:f,presence:d};B&&(T.options={...v,extraArgs:B}),g.push(T)}}else for(const{adapter:r,presence:o}of x){const d=R(r.id),f={adapter:r,files:["."],presence:o};d&&(f.options={...v,extraArgs:d}),g.push(f)}if(g.length===0)return;const z=await re(g,v,b,{cacheRoot:K}),j=g.map((r,o)=>{const d=z[o],f=r.adapter.parse(d,r.presence);return{adapter:r.adapter,durationMs:d.durationMs,exitCode:d.exitCode,findings:f}}),p=ae(j.map(r=>({adapter:r.adapter.id,durationMs:r.durationMs,exitCode:r.exitCode,findingCount:r.findings.length,findings:r.findings}))),m=y==="human"?void 0:oe({cwd:n,target:t.output});try{switch(y){case"github":{m.write(fe({runs:j.map(r=>({findings:r.findings})),workspaceRoot:n}));break}case"json":{m.write(`${JSON.stringify({findings:p.findings,mode:b,runs:p.runs},null,2)}
1
+ import{createRequire as H}from"node:module";import{J as A,q as G,j as W,F as E}from"../packem_shared/index.server-Ca_EEVfw.js";import{a as P}from"../packem_shared/index-0dnGN3GP.js";import{T as I}from"./cli-main.js";import{w as Q,r as X,a as Y,s as Z,c as ee,b as te,d as se,e as ie,f as ne,g as re,h as ae,i as oe,j as ce,k as de,l as fe,m as le,n as ue}from"../packem_shared/watch-loop-ZjcOW5Qx.js";import{v as h}from"../packem_shared/registry-DqBIZZSL.js";import{d as C,f as _,a as pe}from"../packem_shared/detect-D8zxVYrU.js";let J;const U=e=>(J??=H(import.meta.url))(e),w=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,D=e=>{if(typeof w<"u"&&w.versions&&w.versions.node){const[t,s]=w.versions.node.split(".").map(Number);if(t>22||t===22&&s>=3||t===20&&s>=16)return w.getBuiltinModule(e)}return U(e)},{createHash:F}=D("node:crypto"),ge=e=>e.startsWith("/")||/^[a-z]:[\\/]/i.test(e),q=(e,t)=>ge(t)?t:`${e}/${t}`,me={argsCheck:(e,t)=>O(e,t,"check"),argsFix:(e,t)=>O(e,t,"fix"),bin:()=>["pnpm","exec","dprint"],cacheKey:(e,t)=>{const s=["dprint",e.declaredVersion??"unknown",e.configFile??"no-config",t.quiet?"q":"",...t.extraArgs??[]];return F("sha256").update(s.join("|")).digest("hex").slice(0,16)},detect:(e,t)=>{const s=C(t,h.dprint.packageNames[0]),i=_(e,h.dprint.configFiles);if(!(!s&&!i))return{adapter:"dprint",configFile:i,declared:!!s,declaredVersion:s,root:e}},extensions:["cjs","css","cts","dockerfile","html","js","json","jsonc","jsx","md","mdx","mjs","mts","toml","ts","tsx","yaml","yml"],id:"dprint",kind:"fmt",parse:(e,t)=>{if(e.exitCode===0)return[];const s=[];for(const i of e.stdout.split(/\r?\n/)){const n=i.trim();!n||n.startsWith("[")||n.startsWith("Checked ")||n.startsWith("Error:")||s.push({adapter:"dprint",file:q(t.root,n),fixable:!0,message:"Code style issues would be auto-fixed",severity:"info"})}return s}},O=(e,t,s)=>{const i=s==="fix"?["fmt"]:["check","--list-different"];return t.extraArgs?.length&&i.push(...t.extraArgs),i.push(...e),i},he={argsCheck:(e,t)=>V(e,t,"check"),argsFix:(e,t)=>V(e,t,"fix"),bin:()=>["pnpm","exec","oxfmt"],cacheKey:(e,t)=>{const s=["oxfmt",e.declaredVersion??"unknown",e.configFile??"no-config",t.quiet?"q":"",...t.extraArgs??[]];return F("sha256").update(s.join("|")).digest("hex").slice(0,16)},detect:(e,t)=>{const s=C(t,h.oxfmt.packageNames[0]),i=_(e,h.oxfmt.configFiles);if(!(!s&&!i))return{adapter:"oxfmt",configFile:i,declared:!!s,declaredVersion:s,root:e}},extensions:["cjs","cts","js","json","jsonc","jsx","mjs","mts","ts","tsx"],id:"oxfmt",kind:"fmt",parse:(e,t)=>{if(e.exitCode===0)return[];const s=[];for(const i of e.stdout.split(/\r?\n/)){const n=i.trim();!n||n.startsWith("[")||s.push({adapter:"oxfmt",file:q(t.root,n),fixable:!0,message:"Code style issues would be auto-fixed",severity:"info"})}return s}},V=(e,t,s)=>{const i=s==="fix"?["--write"]:["--list-different"];return t.extraArgs?.length&&i.push(...t.extraArgs),i.push(...e),i},xe={argsCheck:(e,t)=>N(e,t,"check"),argsFix:(e,t)=>N(e,t,"fix"),bin:()=>["pnpm","exec","prettier"],cacheKey:(e,t)=>{const s=["prettier",e.declaredVersion??"unknown",e.configFile??"no-config",t.quiet?"q":"",...t.extraArgs??[]];return F("sha256").update(s.join("|")).digest("hex").slice(0,16)},detect:(e,t)=>{const s=C(t,h.prettier.packageNames[0]),i=_(e,h.prettier.configFiles);if(!(!s&&!i))return{adapter:"prettier",configFile:i,declared:!!s,declaredVersion:s,root:e}},extensions:["cjs","css","cts","html","js","json","jsx","less","md","mdx","mjs","mts","scss","ts","tsx","vue","yaml","yml"],id:"prettier",kind:"fmt",parse:(e,t)=>{if(e.exitCode===0)return[];const s=[];for(const i of e.stdout.split(/\r?\n/)){const n=i.trim();n&&(n.startsWith("[")||s.push({adapter:"prettier",file:q(t.root,n),fixable:!0,message:"Code style issues would be auto-fixed",severity:"info"}))}return s}},N=(e,t,s)=>{const i=s==="fix"?["--write"]:["--list-different"];return t.quiet&&i.push("--log-level","warn"),t.extraArgs?.length&&i.push(...t.extraArgs),i.push(...e),i},we=[he,se,me,xe,ie],$e=async({logger:e,options:t,visConfig:s,workspaceRoot:i})=>{const n=i??process.cwd(),l=s?.fmt;Q(e,"fmt",l);const k=X(we,l?.order),L=pe(n,k),x=Y(L,k,"fmt").filter(({adapter:u})=>l?.adapters?.[u.id]?.enabled!==!1);if(x.length===0){e.warn("vis fmt: no formatter detected in this workspace (looked for: oxfmt, biome, dprint, prettier, ruff).");return}const R=u=>{const a=l?.adapters?.[u]?.extraArgs;return a&&a.length>0?[...a]:void 0},v={quiet:t.quiet??!1},$=ke(t),b=t.check?"check":"fix";let c;if(t.staged){if(c=Z(n),c===void 0)e.warn("vis fmt: could not resolve --staged (not a git repo or git unavailable). Falling back to a workspace-wide run.");else if(c.length===0){e.info(A("✓ fmt: no staged files"));return}}else if(typeof t.since=="string"&&t.since.length>0){if(c=ee(n,t.since),c===void 0)e.warn(`vis fmt: could not resolve --since ${t.since} (not a git repo or unknown ref). Falling back to a workspace-wide run.`);else if(c.length===0){e.info(A(`✓ fmt: no files changed since ${t.since}`));return}}const K=I(n,void 0,void 0,!0),y=t.format??"human";y==="human"&&t.output!==void 0&&e.warn("vis fmt: --output is ignored for the human format; pass --format json|minimal|sarif|junit|github to redirect findings to a file.");const M=async u=>{const a=$.length>0?$:u,g=[];if(a){const r=ne(a,x,l?.extensionOverrides);for(const{adapter:o,presence:d}of x){const f=r.get(o.id);if(!f||f.length===0)continue;const B=R(o.id),T={adapter:o,files:f,presence:d};B&&(T.options={...v,extraArgs:B}),g.push(T)}}else for(const{adapter:r,presence:o}of x){const d=R(r.id),f={adapter:r,files:["."],presence:o};d&&(f.options={...v,extraArgs:d}),g.push(f)}if(g.length===0)return;const z=await re(g,v,b,{cacheRoot:K}),j=g.map((r,o)=>{const d=z[o],f=r.adapter.parse(d,r.presence);return{adapter:r.adapter,durationMs:d.durationMs,exitCode:d.exitCode,findings:f}}),p=ae(j.map(r=>({adapter:r.adapter.id,durationMs:r.durationMs,exitCode:r.exitCode,findingCount:r.findings.length,findings:r.findings}))),m=y==="human"?void 0:oe({cwd:n,target:t.output});try{switch(y){case"github":{m.write(fe({runs:j.map(r=>({findings:r.findings})),workspaceRoot:n}));break}case"json":{m.write(`${JSON.stringify({findings:p.findings,mode:b,runs:p.runs},null,2)}
2
2
  `);break}case"junit":{m.write(de({runs:j.map(r=>({adapter:r.adapter.id,durationMs:r.durationMs,findings:r.findings})),workspaceRoot:n}));break}case"minimal":{je(p.findings,n,m);break}case"sarif":{m.write(ce({runs:j.map(r=>({adapter:r.adapter.id,findings:r.findings,presence:g.find(o=>o.adapter.id===r.adapter.id)?.presence})),workspaceRoot:n}));break}default:be(p.findings,n,b,e)}}finally{m?.close()}const S=b==="fix"?p.hadProcessFailure?1:0:le({...p,maxSeverity:p.findings.length>0?"error":void 0});S!==0&&(process.exitCode=S)};if(t.watch){const u=[...new Set(x.flatMap(({adapter:a})=>a.extensions))];await te({extensions:u,initialFiles:c,label:"fmt",log:a=>{e.info(a)},runCycle:M,workspaceRoot:n});return}await M(c)},ke=e=>{const t=e;return[...t._??t.args??[]]},be=(e,t,s,i)=>{if(e.length===0){i.info(A(s==="fix"?"✓ fmt: nothing to change":"✓ fmt: all files already formatted"));return}const n=ue(e),l=s==="fix"?G(W("Formatted:")):W("Would change:");i.info(l);for(const k of n.keys())i.info(` ${E("·")} ${P(t,k)}`);s==="check"&&(i.info(""),i.info(E(`Run \`vis fmt\` to apply changes (${String(n.size)} file${n.size===1?"":"s"}).`)))},je=(e,t,s)=>{for(const i of e)s.write(`${i.adapter} ${P(t,i.file)}
3
3
  `)};export{$e as default};
@@ -1,4 +1,4 @@
1
- import{createRequire as Z}from"node:module";import{J as I,j as re,F as O,X as U,b as D,q as ie}from"../packem_shared/index.server-Ca_EEVfw.js";import{a as S}from"../packem_shared/index-0dnGN3GP.js";import{T as se}from"./cli-main.js";import{w as ae,r as oe,a as ce,s as le,c as de,b as ue,d as fe,o as ge,p as P,g as pe,h as me,i as he,j as xe,k as we,l as ve,n as ye,m as ke}from"../packem_shared/watch-loop-CpqHmDCt.js";import{v as d}from"../packem_shared/registry-DqBIZZSL.js";import{d as f,f as b,r as be,a as $e}from"../packem_shared/detect-D8zxVYrU.js";import{R as Ae}from"./ts-loader.js";let ee;const te=e=>(ee??=Z(import.meta.url))(e),k=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,ne=e=>{if(typeof k<"u"&&k.versions&&k.versions.node){const[t,n]=k.versions.node.split(".").map(Number);if(t>22||t===22&&n>=3||t===20&&n>=16)return k.getBuiltinModule(e)}return te(e)},{createHash:h}=ne("node:crypto"),Ce={1:"warning",2:"error"},Fe={argsCheck:(e,t)=>V(e,t,!1),argsFix:(e,t)=>V(e,t,!0),bin:()=>["pnpm","exec","eslint"],cacheKey:(e,t)=>{const n=["eslint",e.declaredVersion??"unknown",e.configFile??"no-config",t.maxWarnings===void 0?"":`mw=${t.maxWarnings}`,t.quiet?"q":"",...t.extraArgs??[]];return h("sha256").update(n.join("|")).digest("hex").slice(0,16)},detect:(e,t)=>{const n=f(t,d.eslint.packageNames[0]),r=b(e,d.eslint.configFiles);if(!(!n&&!r))return{adapter:"eslint",configFile:r,declared:!!n,declaredVersion:n,root:e}},extensions:["cjs","cts","js","jsx","mjs","mts","ts","tsx","vue"],id:"eslint",kind:"lint",parse:(e,t)=>{if(!e.stdout.trim())return[];let n;try{n=JSON.parse(e.stdout)}catch{return[{adapter:"eslint",file:t.root,fixable:!1,message:`eslint output was not valid JSON (exit ${e.exitCode})`,severity:"error"}]}const r=[];for(const i of n)for(const s of i.messages)r.push({adapter:"eslint",column:s.column,endColumn:s.endColumn,endLine:s.endLine,file:i.filePath,fixable:!!s.fix,line:s.line,message:s.message,ruleId:s.ruleId??void 0,severity:s.fatal?"error":Ce[s.severity]??"warning"});return r}},V=(e,t,n)=>{const r=["--format","json","--no-error-on-unmatched-pattern"];return n&&r.push("--fix"),t.quiet&&r.push("--quiet"),typeof t.maxWarnings=="number"&&r.push("--max-warnings",String(t.maxWarnings)),t.extraArgs?.length&&r.push(...t.extraArgs),r.push(...e),r},Se=/^([^:]+):(\d+)(?::(\d+))?\s+([\w/-]+)\s+(.+)$/,je=e=>{const t=Se.exec(e);if(!t)return;const[,n,r,i,s,c]=t;return{column:i===void 0?void 0:Number(i),file:n,line:Number(r),message:c,ruleId:s}},_e=e=>e.startsWith("/")||/^[a-z]:[\\/]/i.test(e),Ne={argsCheck:(e,t)=>M(e,t,!1),argsFix:(e,t)=>M(e,t,!0),bin:()=>["pnpm","exec","markdownlint-cli2"],cacheKey:(e,t)=>{const n=["markdownlint",e.declaredVersion??"unknown",e.configFile??"no-config",t.maxWarnings===void 0?"":`mw=${t.maxWarnings}`,t.quiet?"q":"",...t.extraArgs??[]];return h("sha256").update(n.join("|")).digest("hex").slice(0,16)},detect:(e,t)=>{const n=d.markdownlint.packageNames.map(i=>f(t,i)).find(i=>i!==void 0),r=b(e,d.markdownlint.configFiles);if(!(!n&&!r))return{adapter:"markdownlint",configFile:r,declared:!!n,declaredVersion:n,root:e}},extensions:["markdown","md"],id:"markdownlint",kind:"lint",parse:(e,t)=>{const n=(e.stderr||e.stdout||"").trim();if(!n)return[];const r=[];for(const i of n.split(/\r?\n/)){const s=je(i.trim());s&&r.push({adapter:"markdownlint",column:s.column,file:_e(s.file)?s.file:`${t.root}/${s.file}`,fixable:!0,line:s.line,message:s.message,ruleId:s.ruleId,severity:"warning"})}return r}},M=(e,t,n)=>{const r=[];return n&&r.push("--fix"),t.extraArgs?.length&&r.push(...t.extraArgs),e.length===0?r.push("**/*.md"):r.push(...e),r},qe={advice:"info",error:"error",warning:"warning"},Ie={argsCheck:(e,t)=>L(e,t,!1),argsFix:(e,t)=>L(e,t,!0),bin:()=>["pnpm","exec","oxlint"],cacheKey:(e,t)=>{const n=["oxlint",e.declaredVersion??"unknown",e.configFile??"no-config",t.maxWarnings===void 0?"":`mw=${t.maxWarnings}`,t.quiet?"q":"",...t.extraArgs??[]];return h("sha256").update(n.join("|")).digest("hex").slice(0,16)},detect:(e,t)=>{const n=f(t,d.oxlint.packageNames[0]),r=b(e,d.oxlint.configFiles);if(!(!n&&!r))return{adapter:"oxlint",configFile:r,declared:!!n,declaredVersion:n,root:e}},extensions:["astro","cjs","cts","js","jsx","mjs","mts","svelte","ts","tsx","vue"],id:"oxlint",kind:"lint",parse:(e,t)=>{if(!e.stdout.trim())return[];let n;try{n=JSON.parse(e.stdout)}catch{return[{adapter:"oxlint",file:t.root,fixable:!1,message:`oxlint output was not valid JSON (exit ${e.exitCode})`,severity:"error"}]}const r=[];for(const i of n.diagnostics??[]){const s=i.labels?.[0]?.span;r.push({adapter:"oxlint",column:s?.column,file:i.filename??t.root,fixable:!1,line:s?.line,message:i.message??"",ruleId:i.code,severity:qe[i.severity??""]??"warning"})}return r}},L=(e,t,n)=>{const r=["--format","json"];return n&&r.push("--fix"),t.quiet&&r.push("--quiet"),typeof t.maxWarnings=="number"&&r.push(`--max-warnings=${String(t.maxWarnings)}`),t.extraArgs?.length&&r.push(...t.extraArgs),r.push(...e),r},We={error:"error",info:"info",style:"info",warning:"warning"},Re=e=>e.startsWith("/")||/^[a-z]:[\\/]/i.test(e),Te=(e,t)=>e?Re(e)?e:`${t}/${e}`:t,Ee={argsCheck:(e,t)=>B(e,t),argsFix:(e,t)=>B(e,t),bin:()=>["shellcheck"],cacheKey:(e,t)=>{const n=["shellcheck",e.declaredVersion??"unknown",e.configFile??"no-config",t.quiet?"q":"",...t.extraArgs??[]];return h("sha256").update(n.join("|")).digest("hex").slice(0,16)},detect:(e,t)=>{const n=f(t,d.shellcheck.packageNames[0]),r=b(e,d.shellcheck.configFiles);if(!(!n&&!r))return{adapter:"shellcheck",configFile:r,declared:!!n,declaredVersion:n,root:e}},extensions:["bash","ksh","sh"],id:"shellcheck",kind:"lint",parse:(e,t)=>{if(!e.stdout.trim())return[];let n;try{n=JSON.parse(e.stdout)}catch{return[{adapter:"shellcheck",file:t.root,fixable:!1,message:`shellcheck output was not valid JSON (exit ${e.exitCode})`,severity:"error"}]}const r=[];for(const i of n.comments??[])r.push({adapter:"shellcheck",column:i.column,endColumn:i.endColumn,endLine:i.endLine,file:Te(i.file,t.root),fixable:!!i.fix,line:i.line,message:i.message??"",ruleId:i.code===void 0?void 0:`SC${String(i.code)}`,severity:We[i.level??""]??"warning"});return r}},B=(e,t)=>{const n=["--format=json1"];return t.extraArgs?.length&&n.push(...t.extraArgs),n.push(...e),n},Oe={error:"error",warning:"warning"},Pe={argsCheck:(e,t)=>J(e,t,!1),argsFix:(e,t)=>J(e,t,!0),bin:()=>["pnpm","exec","stylelint"],cacheKey:(e,t)=>{const n=["stylelint",e.declaredVersion??"unknown",e.configFile??"no-config",t.maxWarnings===void 0?"":`mw=${t.maxWarnings}`,t.quiet?"q":"",...t.extraArgs??[]];return h("sha256").update(n.join("|")).digest("hex").slice(0,16)},detect:(e,t)=>{const n=f(t,d.stylelint.packageNames[0]),r=b(e,d.stylelint.configFiles);if(!(!n&&!r))return{adapter:"stylelint",configFile:r,declared:!!n,declaredVersion:n,root:e}},extensions:["astro","css","less","sass","scss","svelte","vue"],id:"stylelint",kind:"lint",parse:(e,t)=>{if(!e.stdout.trim())return[];let n;try{n=JSON.parse(e.stdout)}catch{return[{adapter:"stylelint",file:t.root,fixable:!1,message:`stylelint output was not valid JSON (exit ${e.exitCode})`,severity:"error"}]}const r=[];for(const i of n)for(const s of i.warnings??[])r.push({adapter:"stylelint",column:s.column,endColumn:s.endColumn,endLine:s.endLine,file:i.source,fixable:!1,line:s.line,message:s.text??"",ruleId:s.rule,severity:Oe[s.severity??""]??"warning"});return r}},J=(e,t,n)=>{const r=["--formatter","json"];return n&&r.push("--fix"),t.quiet&&r.push("--quiet"),typeof t.maxWarnings=="number"&&r.push("--max-warnings",String(t.maxWarnings)),t.extraArgs?.length&&r.push(...t.extraArgs),r.push(...e),r},G="@typescript/native-preview",Ve=2e3,Me=/^(.*)\((\d+),(\d+)\): (error|warning) (TS\d+): (.*)$/,Le=/^(error|warning) (TS\d+): (.*)$/,Y=e=>e.startsWith("/")||/^[a-z]:[\\/]/i.test(e),Be=(e,t)=>Y(e)?e:`${t}/${e}`,z=e=>{try{return Ae(e)}catch{return}},Je=e=>{const t=z(e);return Array.isArray(t?.config.references)&&t.config.references.length>0},Ke=e=>{const t=be(e);return!f(t,"typescript")&&f(t,G)?"tsgo":"tsc"},Ue={argsCheck:(e,t)=>K(t),argsFix:(e,t)=>K(t),bin:e=>{const t=["pnpm","exec",Ke(e.root)],n=e.configFile?S(e.root,e.configFile):"tsconfig.json";return e.configFile&&Je(e.root)?[...t,"-b","--pretty","false",n]:[...t,"-p",n,"--noEmit","--pretty","false"]},cacheKey:(e,t)=>{const n=["typecheck",e.declaredVersion??"unknown",e.configFile??"no-config",...t.extraArgs??[]];return h("sha256").update(n.join("|")).digest("hex").slice(0,16)},detect:(e,t)=>{const n=f(t,"typescript"),r=f(t,G),i=z(e),s=i?S(e,i.path):void 0;if(!(!n&&!r||!i||!s||s===".."||s.startsWith("../")||Y(s)))return{adapter:"typecheck",configFile:i.path,declared:!0,declaredVersion:n??r,root:e}},extensions:["cts","mts","ts","tsx"],id:"typecheck",kind:"lint",optIn:!0,parse:(e,t)=>{const n=[];for(const r of`${e.stdout}
1
+ import{createRequire as Z}from"node:module";import{J as I,j as re,F as O,X as U,b as D,q as ie}from"../packem_shared/index.server-Ca_EEVfw.js";import{a as S}from"../packem_shared/index-0dnGN3GP.js";import{T as se}from"./cli-main.js";import{w as ae,r as oe,a as ce,s as le,c as de,b as ue,d as fe,o as ge,p as P,g as pe,h as me,i as he,j as xe,k as we,l as ve,n as ye,m as ke}from"../packem_shared/watch-loop-ZjcOW5Qx.js";import{v as d}from"../packem_shared/registry-DqBIZZSL.js";import{d as f,f as b,r as be,a as $e}from"../packem_shared/detect-D8zxVYrU.js";import{R as Ae}from"./ts-loader.js";let ee;const te=e=>(ee??=Z(import.meta.url))(e),k=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,ne=e=>{if(typeof k<"u"&&k.versions&&k.versions.node){const[t,n]=k.versions.node.split(".").map(Number);if(t>22||t===22&&n>=3||t===20&&n>=16)return k.getBuiltinModule(e)}return te(e)},{createHash:h}=ne("node:crypto"),Ce={1:"warning",2:"error"},Fe={argsCheck:(e,t)=>V(e,t,!1),argsFix:(e,t)=>V(e,t,!0),bin:()=>["pnpm","exec","eslint"],cacheKey:(e,t)=>{const n=["eslint",e.declaredVersion??"unknown",e.configFile??"no-config",t.maxWarnings===void 0?"":`mw=${t.maxWarnings}`,t.quiet?"q":"",...t.extraArgs??[]];return h("sha256").update(n.join("|")).digest("hex").slice(0,16)},detect:(e,t)=>{const n=f(t,d.eslint.packageNames[0]),r=b(e,d.eslint.configFiles);if(!(!n&&!r))return{adapter:"eslint",configFile:r,declared:!!n,declaredVersion:n,root:e}},extensions:["cjs","cts","js","jsx","mjs","mts","ts","tsx","vue"],id:"eslint",kind:"lint",parse:(e,t)=>{if(!e.stdout.trim())return[];let n;try{n=JSON.parse(e.stdout)}catch{return[{adapter:"eslint",file:t.root,fixable:!1,message:`eslint output was not valid JSON (exit ${e.exitCode})`,severity:"error"}]}const r=[];for(const i of n)for(const s of i.messages)r.push({adapter:"eslint",column:s.column,endColumn:s.endColumn,endLine:s.endLine,file:i.filePath,fixable:!!s.fix,line:s.line,message:s.message,ruleId:s.ruleId??void 0,severity:s.fatal?"error":Ce[s.severity]??"warning"});return r}},V=(e,t,n)=>{const r=["--format","json","--no-error-on-unmatched-pattern"];return n&&r.push("--fix"),t.quiet&&r.push("--quiet"),typeof t.maxWarnings=="number"&&r.push("--max-warnings",String(t.maxWarnings)),t.extraArgs?.length&&r.push(...t.extraArgs),r.push(...e),r},Se=/^([^:]+):(\d+)(?::(\d+))?\s+([\w/-]+)\s+(.+)$/,je=e=>{const t=Se.exec(e);if(!t)return;const[,n,r,i,s,c]=t;return{column:i===void 0?void 0:Number(i),file:n,line:Number(r),message:c,ruleId:s}},_e=e=>e.startsWith("/")||/^[a-z]:[\\/]/i.test(e),Ne={argsCheck:(e,t)=>M(e,t,!1),argsFix:(e,t)=>M(e,t,!0),bin:()=>["pnpm","exec","markdownlint-cli2"],cacheKey:(e,t)=>{const n=["markdownlint",e.declaredVersion??"unknown",e.configFile??"no-config",t.maxWarnings===void 0?"":`mw=${t.maxWarnings}`,t.quiet?"q":"",...t.extraArgs??[]];return h("sha256").update(n.join("|")).digest("hex").slice(0,16)},detect:(e,t)=>{const n=d.markdownlint.packageNames.map(i=>f(t,i)).find(i=>i!==void 0),r=b(e,d.markdownlint.configFiles);if(!(!n&&!r))return{adapter:"markdownlint",configFile:r,declared:!!n,declaredVersion:n,root:e}},extensions:["markdown","md"],id:"markdownlint",kind:"lint",parse:(e,t)=>{const n=(e.stderr||e.stdout||"").trim();if(!n)return[];const r=[];for(const i of n.split(/\r?\n/)){const s=je(i.trim());s&&r.push({adapter:"markdownlint",column:s.column,file:_e(s.file)?s.file:`${t.root}/${s.file}`,fixable:!0,line:s.line,message:s.message,ruleId:s.ruleId,severity:"warning"})}return r}},M=(e,t,n)=>{const r=[];return n&&r.push("--fix"),t.extraArgs?.length&&r.push(...t.extraArgs),e.length===0?r.push("**/*.md"):r.push(...e),r},qe={advice:"info",error:"error",warning:"warning"},Ie={argsCheck:(e,t)=>L(e,t,!1),argsFix:(e,t)=>L(e,t,!0),bin:()=>["pnpm","exec","oxlint"],cacheKey:(e,t)=>{const n=["oxlint",e.declaredVersion??"unknown",e.configFile??"no-config",t.maxWarnings===void 0?"":`mw=${t.maxWarnings}`,t.quiet?"q":"",...t.extraArgs??[]];return h("sha256").update(n.join("|")).digest("hex").slice(0,16)},detect:(e,t)=>{const n=f(t,d.oxlint.packageNames[0]),r=b(e,d.oxlint.configFiles);if(!(!n&&!r))return{adapter:"oxlint",configFile:r,declared:!!n,declaredVersion:n,root:e}},extensions:["astro","cjs","cts","js","jsx","mjs","mts","svelte","ts","tsx","vue"],id:"oxlint",kind:"lint",parse:(e,t)=>{if(!e.stdout.trim())return[];let n;try{n=JSON.parse(e.stdout)}catch{return[{adapter:"oxlint",file:t.root,fixable:!1,message:`oxlint output was not valid JSON (exit ${e.exitCode})`,severity:"error"}]}const r=[];for(const i of n.diagnostics??[]){const s=i.labels?.[0]?.span;r.push({adapter:"oxlint",column:s?.column,file:i.filename??t.root,fixable:!1,line:s?.line,message:i.message??"",ruleId:i.code,severity:qe[i.severity??""]??"warning"})}return r}},L=(e,t,n)=>{const r=["--format","json"];return n&&r.push("--fix"),t.quiet&&r.push("--quiet"),typeof t.maxWarnings=="number"&&r.push(`--max-warnings=${String(t.maxWarnings)}`),t.extraArgs?.length&&r.push(...t.extraArgs),r.push(...e),r},We={error:"error",info:"info",style:"info",warning:"warning"},Re=e=>e.startsWith("/")||/^[a-z]:[\\/]/i.test(e),Te=(e,t)=>e?Re(e)?e:`${t}/${e}`:t,Ee={argsCheck:(e,t)=>B(e,t),argsFix:(e,t)=>B(e,t),bin:()=>["shellcheck"],cacheKey:(e,t)=>{const n=["shellcheck",e.declaredVersion??"unknown",e.configFile??"no-config",t.quiet?"q":"",...t.extraArgs??[]];return h("sha256").update(n.join("|")).digest("hex").slice(0,16)},detect:(e,t)=>{const n=f(t,d.shellcheck.packageNames[0]),r=b(e,d.shellcheck.configFiles);if(!(!n&&!r))return{adapter:"shellcheck",configFile:r,declared:!!n,declaredVersion:n,root:e}},extensions:["bash","ksh","sh"],id:"shellcheck",kind:"lint",parse:(e,t)=>{if(!e.stdout.trim())return[];let n;try{n=JSON.parse(e.stdout)}catch{return[{adapter:"shellcheck",file:t.root,fixable:!1,message:`shellcheck output was not valid JSON (exit ${e.exitCode})`,severity:"error"}]}const r=[];for(const i of n.comments??[])r.push({adapter:"shellcheck",column:i.column,endColumn:i.endColumn,endLine:i.endLine,file:Te(i.file,t.root),fixable:!!i.fix,line:i.line,message:i.message??"",ruleId:i.code===void 0?void 0:`SC${String(i.code)}`,severity:We[i.level??""]??"warning"});return r}},B=(e,t)=>{const n=["--format=json1"];return t.extraArgs?.length&&n.push(...t.extraArgs),n.push(...e),n},Oe={error:"error",warning:"warning"},Pe={argsCheck:(e,t)=>J(e,t,!1),argsFix:(e,t)=>J(e,t,!0),bin:()=>["pnpm","exec","stylelint"],cacheKey:(e,t)=>{const n=["stylelint",e.declaredVersion??"unknown",e.configFile??"no-config",t.maxWarnings===void 0?"":`mw=${t.maxWarnings}`,t.quiet?"q":"",...t.extraArgs??[]];return h("sha256").update(n.join("|")).digest("hex").slice(0,16)},detect:(e,t)=>{const n=f(t,d.stylelint.packageNames[0]),r=b(e,d.stylelint.configFiles);if(!(!n&&!r))return{adapter:"stylelint",configFile:r,declared:!!n,declaredVersion:n,root:e}},extensions:["astro","css","less","sass","scss","svelte","vue"],id:"stylelint",kind:"lint",parse:(e,t)=>{if(!e.stdout.trim())return[];let n;try{n=JSON.parse(e.stdout)}catch{return[{adapter:"stylelint",file:t.root,fixable:!1,message:`stylelint output was not valid JSON (exit ${e.exitCode})`,severity:"error"}]}const r=[];for(const i of n)for(const s of i.warnings??[])r.push({adapter:"stylelint",column:s.column,endColumn:s.endColumn,endLine:s.endLine,file:i.source,fixable:!1,line:s.line,message:s.text??"",ruleId:s.rule,severity:Oe[s.severity??""]??"warning"});return r}},J=(e,t,n)=>{const r=["--formatter","json"];return n&&r.push("--fix"),t.quiet&&r.push("--quiet"),typeof t.maxWarnings=="number"&&r.push("--max-warnings",String(t.maxWarnings)),t.extraArgs?.length&&r.push(...t.extraArgs),r.push(...e),r},G="@typescript/native-preview",Ve=2e3,Me=/^(.*)\((\d+),(\d+)\): (error|warning) (TS\d+): (.*)$/,Le=/^(error|warning) (TS\d+): (.*)$/,Y=e=>e.startsWith("/")||/^[a-z]:[\\/]/i.test(e),Be=(e,t)=>Y(e)?e:`${t}/${e}`,z=e=>{try{return Ae(e)}catch{return}},Je=e=>{const t=z(e);return Array.isArray(t?.config.references)&&t.config.references.length>0},Ke=e=>{const t=be(e);return!f(t,"typescript")&&f(t,G)?"tsgo":"tsc"},Ue={argsCheck:(e,t)=>K(t),argsFix:(e,t)=>K(t),bin:e=>{const t=["pnpm","exec",Ke(e.root)],n=e.configFile?S(e.root,e.configFile):"tsconfig.json";return e.configFile&&Je(e.root)?[...t,"-b","--pretty","false",n]:[...t,"-p",n,"--noEmit","--pretty","false"]},cacheKey:(e,t)=>{const n=["typecheck",e.declaredVersion??"unknown",e.configFile??"no-config",...t.extraArgs??[]];return h("sha256").update(n.join("|")).digest("hex").slice(0,16)},detect:(e,t)=>{const n=f(t,"typescript"),r=f(t,G),i=z(e),s=i?S(e,i.path):void 0;if(!(!n&&!r||!i||!s||s===".."||s.startsWith("../")||Y(s)))return{adapter:"typecheck",configFile:i.path,declared:!0,declaredVersion:n??r,root:e}},extensions:["cts","mts","ts","tsx"],id:"typecheck",kind:"lint",optIn:!0,parse:(e,t)=>{const n=[];for(const r of`${e.stdout}
2
2
  ${e.stderr}`.split(/\r?\n/)){const i=Me.exec(r);if(i){n.push({adapter:"typecheck",column:Number(i[3]),file:Be(i[1],t.root),fixable:!1,line:Number(i[2]),message:i[6],ruleId:i[5],severity:i[4]==="warning"?"warning":"error"});continue}const s=Le.exec(r);if(s){n.push({adapter:"typecheck",file:t.root,fixable:!1,message:s[3],ruleId:s[2],severity:s[1]==="warning"?"warning":"error"});continue}const c=n.at(-1);c&&/^\s+\S/.test(r)&&(c.message+=`
3
3
  ${r.trim()}`)}if(n.length===0&&e.exitCode!==0){const r=`${e.stdout}
4
4
  ${e.stderr}`.trim().slice(0,Ve);n.push({adapter:"typecheck",file:t.root,fixable:!1,message:e.exitCode===null?`type-check did not complete (killed or timed out)${r?`:
@@ -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-pMP1p7q1.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-lWlrF9Wk.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};