@visulima/vis 5.0.0 → 6.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (125) hide show
  1. package/CHANGELOG.md +139 -0
  2. package/LICENSE.md +1 -1
  3. package/README.md +2 -2
  4. package/dist/bin.js +1 -1
  5. package/dist/binx.js +1 -1
  6. package/dist/config/index.d.ts +16 -18
  7. package/dist/packem_chunks/bloom-status.js +1 -1
  8. package/dist/packem_chunks/bloom-sync.js +1 -1
  9. package/dist/packem_chunks/catalog.js +49 -48
  10. package/dist/packem_chunks/cli-exec.js +1 -1
  11. package/dist/packem_chunks/cli-main.js +200 -176
  12. package/dist/packem_chunks/doctor-probe.js +1 -1
  13. package/dist/packem_chunks/fix.js +1 -1
  14. package/dist/packem_chunks/handler.js +1 -1
  15. package/dist/packem_chunks/handler10.js +1 -1
  16. package/dist/packem_chunks/handler11.js +1 -1
  17. package/dist/packem_chunks/handler12.js +1 -1
  18. package/dist/packem_chunks/handler13.js +1 -1
  19. package/dist/packem_chunks/handler14.js +1 -1
  20. package/dist/packem_chunks/handler15.js +1 -1
  21. package/dist/packem_chunks/handler16.js +1 -1
  22. package/dist/packem_chunks/handler17.js +1 -1
  23. package/dist/packem_chunks/handler18.js +1 -1
  24. package/dist/packem_chunks/handler19.js +1 -1
  25. package/dist/packem_chunks/handler2.js +1 -1
  26. package/dist/packem_chunks/handler20.js +1 -1
  27. package/dist/packem_chunks/handler21.js +1 -1
  28. package/dist/packem_chunks/handler23.js +1 -1
  29. package/dist/packem_chunks/handler24.js +1 -1
  30. package/dist/packem_chunks/handler26.js +3 -3
  31. package/dist/packem_chunks/handler27.js +1 -1
  32. package/dist/packem_chunks/handler28.js +1 -1
  33. package/dist/packem_chunks/handler29.js +1 -1
  34. package/dist/packem_chunks/handler3.js +1 -1
  35. package/dist/packem_chunks/handler30.js +1 -1
  36. package/dist/packem_chunks/handler39.js +6 -6
  37. package/dist/packem_chunks/handler5.js +1 -1
  38. package/dist/packem_chunks/handler50.js +1 -1
  39. package/dist/packem_chunks/handler51.js +1 -1
  40. package/dist/packem_chunks/handler53.js +1 -1
  41. package/dist/packem_chunks/handler54.js +1 -1
  42. package/dist/packem_chunks/handler59.js +1 -1
  43. package/dist/packem_chunks/handler6.js +1 -1
  44. package/dist/packem_chunks/handler60.js +1 -1
  45. package/dist/packem_chunks/handler61.js +2 -2
  46. package/dist/packem_chunks/handler62.js +1 -1
  47. package/dist/packem_chunks/handler65.js +3 -3
  48. package/dist/packem_chunks/handler66.js +2 -2
  49. package/dist/packem_chunks/handler67.js +9 -9
  50. package/dist/packem_chunks/handler68.js +1 -1
  51. package/dist/packem_chunks/handler69.js +4 -4
  52. package/dist/packem_chunks/handler7.js +1 -1
  53. package/dist/packem_chunks/handler70.js +1 -1
  54. package/dist/packem_chunks/handler71.js +1 -1
  55. package/dist/packem_chunks/handler72.js +1 -1
  56. package/dist/packem_chunks/handler73.js +1 -1
  57. package/dist/packem_chunks/handler74.js +1 -1
  58. package/dist/packem_chunks/handler75.js +32 -32
  59. package/dist/packem_chunks/handler76.js +1 -1
  60. package/dist/packem_chunks/handler77.js +3 -3
  61. package/dist/packem_chunks/handler78.js +26 -26
  62. package/dist/packem_chunks/handler9.js +1 -1
  63. package/dist/packem_chunks/heal-accept.js +1 -1
  64. package/dist/packem_chunks/heal.js +1 -1
  65. package/dist/packem_chunks/help-command.js +1 -1
  66. package/dist/packem_chunks/index2.js +32 -32
  67. package/dist/packem_chunks/index6.js +1 -1
  68. package/dist/packem_chunks/keys-refresh.js +1 -1
  69. package/dist/packem_chunks/lean.js +3 -4
  70. package/dist/packem_chunks/list.js +1 -1
  71. package/dist/packem_chunks/loader.js +1 -1
  72. package/dist/packem_chunks/prompts.js +1 -1
  73. package/dist/packem_chunks/status.js +1 -1
  74. package/dist/packem_chunks/sync.js +1 -1
  75. package/dist/packem_chunks/sync2.js +1 -1
  76. package/dist/packem_chunks/tripwire.js +1 -1
  77. package/dist/packem_chunks/verify-lockfile.js +1 -1
  78. package/dist/packem_shared/Table-Bo1JKNCN-CGGet8ES.js +34 -0
  79. package/dist/packem_shared/{affected-selection-BJXJW_3Q.js → affected-selection-CrW7fWEd.js} +1 -1
  80. package/dist/packem_shared/{ai-fix-BC6aIRJT.js → ai-fix-D9MxigBQ.js} +1 -1
  81. package/dist/packem_shared/{bin-Dx8mjl3g.js → bin-D3TtXgz6.js} +1 -1
  82. package/dist/packem_shared/command-runtime-HSsYGCQd.js +1 -0
  83. package/dist/packem_shared/{ecosystem-gate-CeV20GSB.js → ecosystem-gate-ByxWtzPE.js} +1 -1
  84. package/dist/packem_shared/{failure-log-D2x5BT8S.js → failure-log-BP-gCUb5.js} +1 -1
  85. package/dist/packem_shared/{formatBytes-BHAzNIrn-CrusHOew.js → formatBytes-_HvjOy8a-B_qQr4Hw.js} +3 -3
  86. package/dist/packem_shared/{getRandomSpinner-4ZEcbTYv-DCyIuj19.js → getRandomSpinner-DX11qCB2-CoIsn7ZU.js} +1 -1
  87. package/dist/packem_shared/{index-C_ScJMpb.js → index-BKbMnn8K.js} +1 -1
  88. package/dist/packem_shared/{index-nEyN71oX.js → index-DGdD4w-b.js} +1 -1
  89. package/dist/packem_shared/index.server-Ca_EEVfw.js +2 -0
  90. package/dist/packem_shared/{lifecycle-D6PMPor-.js → lifecycle-DvmDIRbb.js} +1 -1
  91. package/dist/packem_shared/package-version-QFmE9anh.js +4 -0
  92. package/dist/packem_shared/{packument-Df46y5MY.js → packument-zb18Jnlw.js} +1 -1
  93. package/dist/packem_shared/pm-runner-RM72mDZg.js +1 -0
  94. package/dist/packem_shared/{project-name-filter-CH8Ih7Qr.js → project-name-filter-DIqpdsvP.js} +1 -1
  95. package/dist/packem_shared/{provenance-DKeR0Ig1.js → provenance-L1M2FPy_.js} +1 -1
  96. package/dist/packem_shared/{registry-keys-DwB3ZXS_.js → registry-keys-DxdqMzyp.js} +1 -1
  97. package/dist/packem_shared/{resolve-explicit-BmV8YBE-.js → resolve-explicit-CQa37JSq.js} +1 -1
  98. package/dist/packem_shared/resolve-runtime-DNukUjIr.js +1 -0
  99. package/dist/packem_shared/{s1ngularity-DZhkIqL4.js → s1ngularity-CO5GkkqX.js} +1 -1
  100. package/dist/packem_shared/{scan-progress-CkumcBG-.js → scan-progress-RwCRxJdX.js} +1 -1
  101. package/dist/packem_shared/{signatures-BxTMck2l.js → signatures-DIqFUOfs.js} +1 -1
  102. package/dist/packem_shared/spinner-BJjbNl1F.js +1 -0
  103. package/dist/packem_shared/toolchain-Bz70UIcp.js +5 -0
  104. package/dist/packem_shared/{typosquats-8u0drCqQ.js → typosquats-D4DEHhFy.js} +1 -1
  105. package/dist/packem_shared/{vis-update-app-BCIccZfA.js → vis-update-app-9b2kSk9f.js} +1 -1
  106. package/dist/packem_shared/{vis-user-error-Dd7hwxlW.js → vis-user-error-S0Fesz5y.js} +11 -11
  107. package/dist/packem_shared/watch-loop-BEnGuMBn.js +11 -0
  108. package/dist/release/core/version-actions/index.d.ts +1 -1
  109. package/dist/release/presets.d.ts +1 -55
  110. package/dist/release/presets.js +1 -1
  111. package/dist/release/types.d.ts +1 -18
  112. package/index.d.ts +204 -204
  113. package/index.js +26 -26
  114. package/package.json +13 -13
  115. package/schemas/vis-config.schema.json +6 -28
  116. package/schemas/vis-release-config.schema.json +1 -12
  117. package/dist/packem_shared/Table-BB8xHTU5-BLPS917D.js +0 -11
  118. package/dist/packem_shared/command-runtime-p4IXiIf6.js +0 -1
  119. package/dist/packem_shared/index.server-sXNQYpsl.js +0 -2
  120. package/dist/packem_shared/package-version-CiRZecQu.js +0 -4
  121. package/dist/packem_shared/pm-runner-3iiQayy-.js +0 -1
  122. package/dist/packem_shared/resolve-runtime-CNiHcVtx.js +0 -1
  123. package/dist/packem_shared/spinner-ukDEdGvp.js +0 -1
  124. package/dist/packem_shared/toolchain-BRdpaAC4.js +0 -5
  125. package/dist/packem_shared/watch-loop-BBkg02-Q.js +0 -11
@@ -1,4 +1,4 @@
1
- import{createRequire as $}from"node:module";import{O as j,R as E,q as I}from"./catalog.js";import{d as P}from"../packem_shared/pm-runner-3iiQayy-.js";import{l as C}from"../packem_shared/dependency-scan-B8jroa1D.js";import{r as T}from"../packem_shared/provenance-DKeR0Ig1.js";import{r as D}from"../packem_shared/signatures-BxTMck2l.js";import{loadOptionalSigstore as R}from"./loader.js";let y;const O=s=>(y??=$(import.meta.url))(s),m=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,_=s=>{if(typeof m<"u"&&m.versions&&m.versions.node){const[t,r]=m.versions.node.split(".").map(Number);if(t>22||t===22&&r>=3||t===20&&r>=16)return m.getBuiltinModule(s)}return O(s)},{createHash:N}=_("node:crypto"),{isAbsolute:k,resolve:S,basename:v}=_("node:path"),q=s=>(s??"").split(",").map(t=>t.trim()).filter(t=>t.length>0),G=async({logger:s,options:t,workspaceRoot:r})=>{if(!r)throw new Error("Could not determine workspace root. Run this command inside a monorepo.");const n=t.format??"table",c=t.prodOnly??!1,u=t.failOn==="error"?"error":"warning",d=q(t.allowlist),a=P(r),l=C(r,a.name,{includeDev:!c}).map(({name:e,version:o})=>({name:e,version:o})),[f,p]=await Promise.all([T(l,{allowlist:d,workspaceRoot:r}),D(l,{allowlist:d,workspaceRoot:r})]),i=[...f.map(e=>({code:"provenance-regression",message:`Resolved ${e.packageName}@${e.version} has no published provenance attestation, but ${e.packageName}@${e.priorVersionWithProvenance} did — a provenance regression.`,packageName:e.packageName,severity:"warning",version:e.version})),...p.map(e=>({code:e.code,message:e.message,packageName:e.packageName,severity:e.severity,version:e.version}))],g=i.filter(e=>u==="error"?e.severity==="error":!0);if(n==="json")process.stdout.write(`${JSON.stringify({findings:i,ok:g.length===0},void 0,2)}
1
+ import{createRequire as $}from"node:module";import{O as j,R as E,q as I}from"./catalog.js";import{d as P}from"../packem_shared/pm-runner-RM72mDZg.js";import{l as C}from"../packem_shared/dependency-scan-B8jroa1D.js";import{r as T}from"../packem_shared/provenance-L1M2FPy_.js";import{r as D}from"../packem_shared/signatures-DIqFUOfs.js";import{loadOptionalSigstore as R}from"./loader.js";let y;const O=s=>(y??=$(import.meta.url))(s),m=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,_=s=>{if(typeof m<"u"&&m.versions&&m.versions.node){const[t,r]=m.versions.node.split(".").map(Number);if(t>22||t===22&&r>=3||t===20&&r>=16)return m.getBuiltinModule(s)}return O(s)},{createHash:N}=_("node:crypto"),{isAbsolute:k,resolve:S,basename:v}=_("node:path"),q=s=>(s??"").split(",").map(t=>t.trim()).filter(t=>t.length>0),G=async({logger:s,options:t,workspaceRoot:r})=>{if(!r)throw new Error("Could not determine workspace root. Run this command inside a monorepo.");const n=t.format??"table",c=t.prodOnly??!1,u=t.failOn==="error"?"error":"warning",d=q(t.allowlist),a=P(r),l=C(r,a.name,{includeDev:!c}).map(({name:e,version:o})=>({name:e,version:o})),[f,p]=await Promise.all([T(l,{allowlist:d,workspaceRoot:r}),D(l,{allowlist:d,workspaceRoot:r})]),i=[...f.map(e=>({code:"provenance-regression",message:`Resolved ${e.packageName}@${e.version} has no published provenance attestation, but ${e.packageName}@${e.priorVersionWithProvenance} did — a provenance regression.`,packageName:e.packageName,severity:"warning",version:e.version})),...p.map(e=>({code:e.code,message:e.message,packageName:e.packageName,severity:e.severity,version:e.version}))],g=i.filter(e=>u==="error"?e.severity==="error":!0);if(n==="json")process.stdout.write(`${JSON.stringify({findings:i,ok:g.length===0},void 0,2)}
2
2
  `);else if(n==="ndjson")for(const e of i)process.stdout.write(`${JSON.stringify(e)}
3
3
  `);else if(i.length===0)s.info(`No provenance regressions or signature problems across ${String(l.length)} locked packages.`);else{const e=process.stdout.columns||80;s.info(j(E.createElement(I,{data:i.map(o=>({code:o.code,package:`${o.packageName}@${o.version}`,severity:o.severity}))}),{columns:e}));for(const o of i)s.warn(`${o.packageName}@${o.version}: ${o.message}`)}g.length>0&&(process.exitCode=1)},x=()=>process.env.CI==="true"||typeof process.env.ACTIONS_ID_TOKEN_REQUEST_URL=="string"||typeof process.env.SIGSTORE_ID_TOKEN=="string",J=(s,t,r)=>({_type:"https://in-toto.io/Statement/v1",predicate:{buildDefinition:{buildType:"https://visulima.com/vis/attest/v1",externalParameters:{workspaceRoot:r},internalParameters:{},resolvedDependencies:[]},runDetails:{builder:{id:"https://visulima.com/vis"},metadata:{invocationId:process.env.GITHUB_RUN_ID??"",startedOn:new Date().toISOString()}}},predicateType:"https://slsa.dev/provenance/v1",subject:[{digest:{sha256:t},name:s}]}),H=async({argument:s,fs:t,logger:r,options:n,workspaceRoot:c})=>{if(!c)throw new Error("Could not determine workspace root. Run this command inside a monorepo.");const u=s[0];if(!u)throw new Error("Missing subject. Usage: vis attest <path-to-artifact>");const d=n.predicate??"slsaProvenance";if(d!=="slsaProvenance")throw new Error(`Unsupported predicate '${d}'. Only 'slsaProvenance' is supported.`);const a=k(u)?u:S(c,u),w=n.requireSigning??!1,l=n.format??"table";let f;try{f=await t.readFile(a)}catch{throw new Error(`Cannot read subject artifact at ${a}.`)}const p=N("sha256").update(f).digest("hex");if(!x()){const b="No ambient OIDC token (not running in CI). Keyless signing needs a Fulcio identity from CI OIDC.";if(w)throw new Error(`${b} Re-run in CI or drop --require-signing.`);if(l==="json"){process.stdout.write(`${JSON.stringify({ok:!1,reason:"no-ambient-oidc",sha256:p,skipped:!0,subject:v(a)},void 0,2)}
4
4
  `);return}r.warn(`${b} Skipping signing (subject sha256: ${p}). Pass --require-signing to make this fatal.`);return}const i=J(v(a),p,c),g=Buffer.from(JSON.stringify(i)),o=await(await R({workspaceRoot:c})).attest(g,"application/vnd.in-toto+json"),h=n.output?k(n.output)?n.output:S(c,n.output):`${a}.sigstore`;if(await t.writeFile(h,`${JSON.stringify(o,void 0,2)}
@@ -1,4 +1,4 @@
1
- import{c as $,a as l,D as d,T as y}from"../packem_shared/ai-analysis-pldoS_N4.js";import{O as g,R as x,q as S}from"./catalog.js";import{j as w,F as u,q as E,J as I,b as A}from"../packem_shared/index.server-sXNQYpsl.js";const p={command:"ai",description:"AI-assisted commands: provider detection, cache management, and failure-fix proposals."},D=e=>{if(typeof e!="function")return String(e);const{name:t}=e;return t==="Boolean"?"boolean":t==="Number"?"number":t==="String"?"string":t??"unknown"},O=e=>e===void 0?[]:Array.isArray(e)?e.map(t=>[t.name,t]):Object.entries(e),R=e=>{const t=[...e.commandPath??[],e.name].join(" "),a=(e.examples??[]).map(([n,o])=>({command:n??"",description:o??""})),s=O(e.options).map(([n,o])=>({defaultValue:o.defaultValue,description:o.description,name:n,type:D(o.type)}));return{argument:e.argument?{description:e.argument.description,name:e.argument.name}:void 0,description:e.description??"",examples:a,name:e.name,options:s,path:t}},f=(e,t=p)=>({command:t.command,description:t.description,subcommands:e.map(a=>R(a))}),P=(e,t=p)=>`${JSON.stringify(f(e,t),void 0,2)}
1
+ import{c as $,a as l,D as d,T as y}from"../packem_shared/ai-analysis-pldoS_N4.js";import{O as g,R as x,q as S}from"./catalog.js";import{j as w,F as u,q as E,J as I,b as A}from"../packem_shared/index.server-Ca_EEVfw.js";const p={command:"ai",description:"AI-assisted commands: provider detection, cache management, and failure-fix proposals."},D=e=>{if(typeof e!="function")return String(e);const{name:t}=e;return t==="Boolean"?"boolean":t==="Number"?"number":t==="String"?"string":t??"unknown"},O=e=>e===void 0?[]:Array.isArray(e)?e.map(t=>[t.name,t]):Object.entries(e),R=e=>{const t=[...e.commandPath??[],e.name].join(" "),a=(e.examples??[]).map(([n,o])=>({command:n??"",description:o??""})),s=O(e.options).map(([n,o])=>({defaultValue:o.defaultValue,description:o.description,name:n,type:D(o.type)}));return{argument:e.argument?{description:e.argument.description,name:e.argument.name}:void 0,description:e.description??"",examples:a,name:e.name,options:s,path:t}},f=(e,t=p)=>({command:t.command,description:t.description,subcommands:e.map(a=>R(a))}),P=(e,t=p)=>`${JSON.stringify(f(e,t),void 0,2)}
2
2
  `,T=(e,t=p)=>{const a=f(e,t),s=[w(`vis ${a.command} — ${a.description}`),"",u("Subcommands:")];for(const n of a.subcommands){const o=n.argument?` ${E(`<${n.argument.name}>`)}`:"";if(s.push(""),s.push(` ${I(`vis ${n.path}`)}${o}`),n.description&&s.push(` ${n.description}`),n.options.length>0){const i=n.options.map(c=>`--${c.name}${c.type==="boolean"?"":`=<${c.type}>`}`).join(", ");s.push(u(` options: ${i}`))}if(n.examples.length>0){s.push(u(" examples:"));for(const i of n.examples){const c=i.description?u(` — ${i.description}`):"";s.push(` ${A(i.command)}${c}`)}}}return s.push(""),s.push(u(`Run \`vis ${a.command} discover-help\` for the machine-readable JSON catalogue (designed for AI agents).`)),s.push(u(`Run \`vis ${a.command} <subcommand> --help\` for full usage of a specific subcommand.`)),`${s.join(`
3
3
  `)}
4
4
  `},h=async()=>{const{default:e}=await import("./cli-main.js").then(t=>t.aw);return e.filter(t=>t.name!=="ai")},J=async()=>{const e=await h();process.stderr.write(T(e))},F=async()=>{const e=await h();process.stdout.write(P(e))},M=async({logger:e,visConfig:t})=>{const a=t?.ai,s=l(a);if(!s){e.error("No AI provider available to test."),process.exitCode=1;return}e.info(`Testing ${s.name}...`);try{const n=await y(s,"Reply with exactly: OK",{timeoutMs:3e4});e.info(`Provider ${s.name} responded: ${n.stdout.trim().slice(0,200)}`)}catch(n){const o=n instanceof Error?n.message:String(n);e.error(`Provider ${s.name} failed: ${o}`),process.exitCode=1}},q=({logger:e,options:t,visConfig:a})=>{const s=t.format??"table",n=a?.ai,o=$(),i=l(n);if(s==="json"){const r=o.map(m=>({available:m.available,method:m.detectionMethod,name:m.name,path:m.path,priority:d[m.name]??0,selected:m.name===i?.name,version:m.version}));process.stdout.write(`${JSON.stringify(r,void 0,2)}
@@ -1,4 +1,4 @@
1
- import{createRequire as B}from"node:module";import{z as E}from"../packem_shared/index-BzhrR_iC.js";import{findVisConfigFile as D}from"./CONFIG_FILES.js";import{y as V}from"../packem_shared/isAccessibleSync-DYKTrrvc-C-_5cgwu.js";import{U as w}from"../packem_shared/writeFileSync-DJoHk3Ks-BPRoepNw.js";import{p as e}from"./cli-main.js";import{d as C}from"../packem_shared/pm-runner-3iiQayy-.js";import{a as F}from"../packem_shared/build-scripts-CEDx_nJp.js";import{s as O}from"../packem_shared/native-config-sync-TdTWjVgI.js";let N;const M=c=>(N??=B(import.meta.url))(c),$=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,T=c=>{if(typeof $<"u"&&$.versions&&$.versions.node){const[t,s]=$.versions.node.split(".").map(Number);if(t>22||t===22&&s>=3||t===20&&s>=16)return $.getBuiltinModule(c)}return M(c)},{spawnSync:A}=T("node:child_process"),P=/(defineConfig\s*\(\s*\{)/,q=/(export\s+default\s+\{)/,y=(c,t)=>`${t}${JSON.stringify(c)}: true,`,z=(c,t)=>{if(t.length===0)return{added:[],skipped:[],status:"noop"};const s=D(c);if(!s)return{added:[],skipped:t,status:"no-config"};if(!V(s))return{added:[],skipped:t,status:"no-config"};const n=E(s),h=n.search(/installScripts\s*:\s*\{/);let l=null,r=0;if(h!==-1){const a=n.slice(h),d=/(allow\s*:\s*\{)([^}]*)(\})/.exec(a);d?.index!==void 0&&(l=d,r=h+d.index)}if(l){const a=l[2]??"",f=new Set;for(const g of a.matchAll(/["']([^"']+)["']\s*:/g))f.add(g[1]);for(const g of a.matchAll(/(?:^|,|\{)\s*([a-z_$][\w-]*)\s*:/gi))f.add(g[1]);const d=[],k=[];for(const g of t)f.has(g)?k.push(g):d.push(g);if(d.length===0)return{added:[],configPath:s,skipped:k,status:"noop"};const x=/\n([ \t]+)\S/.exec(a)?.[1]??" ",_=`
1
+ import{createRequire as B}from"node:module";import{z as E}from"../packem_shared/index-BzhrR_iC.js";import{findVisConfigFile as D}from"./CONFIG_FILES.js";import{y as V}from"../packem_shared/isAccessibleSync-DYKTrrvc-C-_5cgwu.js";import{U as w}from"../packem_shared/writeFileSync-DJoHk3Ks-BPRoepNw.js";import{p as e}from"./cli-main.js";import{d as C}from"../packem_shared/pm-runner-RM72mDZg.js";import{a as F}from"../packem_shared/build-scripts-CEDx_nJp.js";import{s as O}from"../packem_shared/native-config-sync-TdTWjVgI.js";let N;const M=c=>(N??=B(import.meta.url))(c),$=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,T=c=>{if(typeof $<"u"&&$.versions&&$.versions.node){const[t,s]=$.versions.node.split(".").map(Number);if(t>22||t===22&&s>=3||t===20&&s>=16)return $.getBuiltinModule(c)}return M(c)},{spawnSync:A}=T("node:child_process"),P=/(defineConfig\s*\(\s*\{)/,q=/(export\s+default\s+\{)/,y=(c,t)=>`${t}${JSON.stringify(c)}: true,`,z=(c,t)=>{if(t.length===0)return{added:[],skipped:[],status:"noop"};const s=D(c);if(!s)return{added:[],skipped:t,status:"no-config"};if(!V(s))return{added:[],skipped:t,status:"no-config"};const n=E(s),h=n.search(/installScripts\s*:\s*\{/);let l=null,r=0;if(h!==-1){const a=n.slice(h),d=/(allow\s*:\s*\{)([^}]*)(\})/.exec(a);d?.index!==void 0&&(l=d,r=h+d.index)}if(l){const a=l[2]??"",f=new Set;for(const g of a.matchAll(/["']([^"']+)["']\s*:/g))f.add(g[1]);for(const g of a.matchAll(/(?:^|,|\{)\s*([a-z_$][\w-]*)\s*:/gi))f.add(g[1]);const d=[],k=[];for(const g of t)f.has(g)?k.push(g):d.push(g);if(d.length===0)return{added:[],configPath:s,skipped:k,status:"noop"};const x=/\n([ \t]+)\S/.exec(a)?.[1]??" ",_=`
2
2
  ${d.map(g=>y(g,x)).join(`
3
3
  `)}`,v=a.replace(/\s+$/,""),S=a.slice(v.length),R=`${v}${v.endsWith(",")||v===""?"":","}${_}${S.length>0?S:`
4
4
  `}`,j=`${n.slice(0,r)}${l[1]}${R}${l[3]}${n.slice(r+l[0].length)}`;return w(s,j),{added:d,configPath:s,skipped:k,status:"updated"}}const i=/(installScripts\s*:\s*\{)/;if(i.test(n)){const a=`
@@ -1,4 +1,4 @@
1
- import{F as p}from"../packem_shared/index.server-sXNQYpsl.js";import{e as f}from"../packem_shared/index-BzhrR_iC.js";const g={docker:".dockerignore",npm:".npmignore",slug:".slugignore",vercel:".vercelignore"},m=[".git",".gitattributes",".gitignore",".editorconfig",".vscode/",".idea/",".DS_Store","*.md","LICENSE*","LICENCE*","CHANGELOG*","CONTRIBUTING*","AUTHORS*","docs/","doc/","examples/","example/",".github/",".gitlab-ci.yml",".circleci/","appveyor.yml",".eslintrc*","eslint.config.*",".prettierrc*","prettier.config.*","*.log","npm-debug.log*","*.d.ts","*.map","*.flow","tsconfig*.json","__tests__/","__mocks__/","test/","tests/","*.test.*","*.spec.*","coverage/",".nyc_output/"],w={docker:["node_modules",".vis/","Dockerfile*",".dockerignore"],npm:[],slug:["node_modules"],vercel:["node_modules",".vercel/"]},E=e=>{const r=new Set,o=[];for(const t of[...m,...w[e]])r.has(t)||(r.add(t),o.push(t));return o},_=e=>e.trim(),h="# Added by vis ignore",$=(e,r)=>{const o=new Set;for(const n of e.split(/\r?\n/u)){const i=_(n);i!==""&&!i.startsWith("#")&&o.add(i)}const t=[];for(const n of r)o.has(n)||(o.add(n),t.push(n));if(t.length===0)return{added:t,content:e};const s=e.includes(`\r
1
+ import{F as p}from"../packem_shared/index.server-Ca_EEVfw.js";import{e as f}from"../packem_shared/index-BzhrR_iC.js";const g={docker:".dockerignore",npm:".npmignore",slug:".slugignore",vercel:".vercelignore"},m=[".git",".gitattributes",".gitignore",".editorconfig",".vscode/",".idea/",".DS_Store","*.md","LICENSE*","LICENCE*","CHANGELOG*","CONTRIBUTING*","AUTHORS*","docs/","doc/","examples/","example/",".github/",".gitlab-ci.yml",".circleci/","appveyor.yml",".eslintrc*","eslint.config.*",".prettierrc*","prettier.config.*","*.log","npm-debug.log*","*.d.ts","*.map","*.flow","tsconfig*.json","__tests__/","__mocks__/","test/","tests/","*.test.*","*.spec.*","coverage/",".nyc_output/"],w={docker:["node_modules",".vis/","Dockerfile*",".dockerignore"],npm:[],slug:["node_modules"],vercel:["node_modules",".vercel/"]},E=e=>{const r=new Set,o=[];for(const t of[...m,...w[e]])r.has(t)||(r.add(t),o.push(t));return o},_=e=>e.trim(),h="# Added by vis ignore",$=(e,r)=>{const o=new Set;for(const n of e.split(/\r?\n/u)){const i=_(n);i!==""&&!i.startsWith("#")&&o.add(i)}const t=[];for(const n of r)o.has(n)||(o.add(n),t.push(n));if(t.length===0)return{added:t,content:e};const s=e.includes(`\r
2
2
  `)?`\r
3
3
  `:`
4
4
  `,d=[h,...t].join(s);if(e.trim()==="")return{added:t,content:`${d}${s}`};const c=e.endsWith(`
@@ -1,4 +1,4 @@
1
- import{F as p}from"../packem_shared/index.server-sXNQYpsl.js";import{e as l,z as k}from"../packem_shared/index-BzhrR_iC.js";import{a as y,b as h,f as w}from"../packem_shared/subtree-DtmcKAJK.js";import{n as u}from"../packem_shared/utils-DQFHJn72.js";import{z as $,l as x}from"./catalog.js";import{y as A}from"../packem_shared/isAccessibleSync-DYKTrrvc-C-_5cgwu.js";import{U as b}from"../packem_shared/writeFileSync-DJoHk3Ks-BPRoepNw.js";import{p as E}from"../packem_shared/readJsonSync-CbryXYxN-EWl7_7KX.js";import{T as m}from"../packem_shared/target-merge-DVJl-7Qz.js";const P=["aube-workspace.yaml","pnpm-workspace.yaml"],v=/^\s*packages\s*:\s*$/,I=/^(\s*)-\s/,j=(c,i)=>{const s=c.includes(`\r
1
+ import{F as p}from"../packem_shared/index.server-Ca_EEVfw.js";import{e as l,z as k}from"../packem_shared/index-BzhrR_iC.js";import{a as y,b as h,f as w}from"../packem_shared/subtree-DtmcKAJK.js";import{n as u}from"../packem_shared/utils-DQFHJn72.js";import{z as $,l as x}from"./catalog.js";import{y as A}from"../packem_shared/isAccessibleSync-DYKTrrvc-C-_5cgwu.js";import{U as b}from"../packem_shared/writeFileSync-DJoHk3Ks-BPRoepNw.js";import{p as E}from"../packem_shared/readJsonSync-CbryXYxN-EWl7_7KX.js";import{T as m}from"../packem_shared/target-merge-DVJl-7Qz.js";const P=["aube-workspace.yaml","pnpm-workspace.yaml"],v=/^\s*packages\s*:\s*$/,I=/^(\s*)-\s/,j=(c,i)=>{const s=c.includes(`\r
2
2
  `)?`\r
3
3
  `:`
4
4
  `,e=c.split(/\r?\n/),n=e.findIndex(r=>v.test(r));if(n===-1)return;let t=" ";for(let r=n+1;r<e.length;r++){const o=I.exec(e[r]);if(o){t=o[1];break}if(e[r].trim().length>0)break}return e.splice(n+1,0,`${t}- "${i}"`),e.join(s)},q=(c,i,s)=>{const e=l(c,"package.json");let n;try{n=E(e)}catch{return!1}const{workspaces:t}=n;return Array.isArray(t)?t.includes(i)?!1:(s||m(e,{...n,workspaces:[...t,i]},{detectIndent:!0}),!0):t&&typeof t=="object"&&Array.isArray(t.packages)?t.packages.includes(i)?!1:(s||m(e,{...n,workspaces:{...t,packages:[...t.packages,i]}},{detectIndent:!0}),!0):!1},M=({dryRun:c=!1,prefix:i,workspaceRoot:s})=>{const e=u(i),n=$(s);if(!n)return{status:"no-config"};if(x(s,n).some(r=>u(r)===e))return{status:"already-covered"};for(const r of P){const o=l(s,r);if(!A(o))continue;const a=j(k(o),e);if(a!==void 0)return c||b(o,a),{entry:e,file:r,status:"added"}}return q(s,e,c)?{entry:e,file:"package.json",status:"added"}:{status:"no-config"}},N=async({argument:c,fs:i,logger:s,options:e,process:n,workspaceRoot:t})=>{const r=c[0];if(!r)throw new Error("Missing <source>. Pass a git repository URL or local path to import.");if(!e.prefix)throw new Error("Missing --prefix <dir>. Pass the target directory in the monorepo (e.g. packages/tooling/foo).");const o=t??n.cwd,a=u(e.prefix),d=e.ref??"HEAD";if(y(o),await(async f=>{try{return await i.access(f),!0}catch{return!1}})(l(o,a)))throw new Error(`Target "${a}" already exists. git subtree add requires a non-existent prefix.`);if(e.dryRun){const f=e.squash?" --squash":"",g=e.message?` -m "${e.message}"`:"";s.info("Dry run — no changes will be made. Planned steps:"),s.info(` git subtree add --prefix=${a}${f}${g} ${r} ${d}`),e.register&&s.info(` register ${a} into the workspace config (skipped if already covered by an existing glob)`);return}if(h(o),s.info(`Importing ${p(r)}@${d} → ${a} ...`),w({cwd:o,message:e.message,prefix:a,ref:d,repo:r,squash:e.squash}),s.info(`✓ Imported ${r} into ${a} (history preserved).`),e.register){const f=M({prefix:a,workspaceRoot:o});f.status==="already-covered"?s.info(`✓ ${a} is already covered by an existing workspace glob.`):f.status==="added"?s.info(`✓ Registered ${f.entry} in ${f.file}.`):s.warn(`Could not auto-register ${a}: no workspace config found. Add it to pnpm-workspace.yaml or package.json#workspaces manually.`)}else s.info(p(`Skipped workspace registration (--no-register). Add ${a} to your workspace config manually.`));s.info(p("Note: project.json / nx tags are not generated. Add them if your tooling needs them."))};export{N as default};
@@ -1,4 +1,4 @@
1
- import{createRequire as D}from"node:module";import{V as q}from"../packem_shared/vis-user-error-Dd7hwxlW.js";let W;const L=e=>(W??=D(import.meta.url))(e),R=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,E=e=>{if(typeof R<"u"&&R.versions&&R.versions.node){const[t,n]=R.versions.node.split(".").map(Number);if(t>22||t===22&&n>=3||t===20&&n>=16)return R.getBuiltinModule(e)}return L(e)},{relative:h,join:u,dirname:_}=E("node:path"),{lstat:G}=E("node:fs/promises"),U=new Set(["ENOENT","ENOTDIR"]),$=e=>U.has(e?.code??""),T=async(e,t)=>{const n=e.lstat;try{return(typeof n=="function"?await n.call(e,t):await G(t)).isSymbolicLink()}catch(i){if($(i))return!1;throw i}},v=async(e,t,n)=>{if(await T(e,t))throw new q(`Refusing to write ${t}: it is a symlink, and following it would write somewhere else. Remove or replace the link, then re-run.`);await e.writeFile(t,n)},g=async(e,t)=>{try{return await e.access(t),!0}catch(n){if($(n))return!1;throw n}},Y=async(e,t)=>{try{return(await e.stat(t)).isDirectory()}catch(n){if($(n))return!1;throw n}},b=async(e,t)=>{try{return await e.readFile(t,"utf8")}catch(n){if($(n))return;throw n}},K=e=>{const t=/\n([\t ]+)\S/.exec(e);return t?.[1]!==void 0?t[1]:e.includes(`
1
+ import{createRequire as D}from"node:module";import{V as q}from"../packem_shared/vis-user-error-S0Fesz5y.js";let W;const L=e=>(W??=D(import.meta.url))(e),R=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,E=e=>{if(typeof R<"u"&&R.versions&&R.versions.node){const[t,n]=R.versions.node.split(".").map(Number);if(t>22||t===22&&n>=3||t===20&&n>=16)return R.getBuiltinModule(e)}return L(e)},{relative:h,join:u,dirname:_}=E("node:path"),{lstat:G}=E("node:fs/promises"),U=new Set(["ENOENT","ENOTDIR"]),$=e=>U.has(e?.code??""),T=async(e,t)=>{const n=e.lstat;try{return(typeof n=="function"?await n.call(e,t):await G(t)).isSymbolicLink()}catch(i){if($(i))return!1;throw i}},v=async(e,t,n)=>{if(await T(e,t))throw new q(`Refusing to write ${t}: it is a symlink, and following it would write somewhere else. Remove or replace the link, then re-run.`);await e.writeFile(t,n)},g=async(e,t)=>{try{return await e.access(t),!0}catch(n){if($(n))return!1;throw n}},Y=async(e,t)=>{try{return(await e.stat(t)).isDirectory()}catch(n){if($(n))return!1;throw n}},b=async(e,t)=>{try{return await e.readFile(t,"utf8")}catch(n){if($(n))return;throw n}},K=e=>{const t=/\n([\t ]+)\S/.exec(e);return t?.[1]!==void 0?t[1]:e.includes(`
2
2
  `)?" ":""},V=(e,t)=>{const n=t.includes(`\r
3
3
  `)?`\r
4
4
  `:`
@@ -1,4 +1,4 @@
1
- import{a as L,b as J,p as f,O as G,c as O,q as T}from"./cli-main.js";import{m as H,a as K,t as m,i as Q,n as W,R as c,O as X,o as y,u as P,v as Z,w as _}from"./catalog.js";import{i as ee}from"../packem_shared/index-BjdW45xX.js";import{v as te,r as se,f as re}from"../packem_shared/ai-analysis-pldoS_N4.js";import{V as ae}from"../packem_shared/vis-user-error-Dd7hwxlW.js";import{d as ne}from"../packem_shared/pm-runner-3iiQayy-.js";import{s as oe}from"../packem_shared/formatBytes-BHAzNIrn-CrusHOew.js";import{U as ce,V as ie,C as j}from"../packem_shared/vis-update-app-BCIccZfA.js";const ke=async({argument:R,logger:s,options:e,visConfig:o,workspaceRoot:C})=>{if(!C)throw new Error("Could not determine workspace root. Run this command inside a monorepo.");const d=C;if(e.sync&&!e.securityConfig)throw new ae("--sync requires --security-config. Run `vis check --security-config --sync`.");if(e.securityConfig){const t=ne(d);if(L(o??{},t.name),e.sync&&t.name==="pnpm"){const r=J(o??{});if(r.length>0){f.info(`
1
+ import{a as L,b as J,p as f,O as G,c as O,q as T}from"./cli-main.js";import{m as H,a as K,t as m,i as Q,n as W,R as c,O as X,o as y,u as P,v as Z,w as _}from"./catalog.js";import{i as ee}from"../packem_shared/index-BjdW45xX.js";import{v as te,r as se,f as re}from"../packem_shared/ai-analysis-pldoS_N4.js";import{V as ae}from"../packem_shared/vis-user-error-S0Fesz5y.js";import{d as ne}from"../packem_shared/pm-runner-RM72mDZg.js";import{s as oe}from"../packem_shared/formatBytes-_HvjOy8a-B_qQr4Hw.js";import{U as ce,V as ie,C as j}from"../packem_shared/vis-update-app-9b2kSk9f.js";const ke=async({argument:R,logger:s,options:e,visConfig:o,workspaceRoot:C})=>{if(!C)throw new Error("Could not determine workspace root. Run this command inside a monorepo.");const d=C;if(e.sync&&!e.securityConfig)throw new ae("--sync requires --security-config. Run `vis check --security-config --sync`.");if(e.securityConfig){const t=ne(d);if(L(o??{},t.name),e.sync&&t.name==="pnpm"){const r=J(o??{});if(r.length>0){f.info(`
2
2
  Settings that would sync to pnpm-workspace.yaml:`);for(const E of r)f.success(` ${E}`)}else f.info("No security settings to sync.")}else e.sync&&t.name!=="pnpm"&&(f.info(`--sync is only available for pnpm projects. Your project uses ${t.name}.`),f.info("vis enforces security settings at the vis layer for non-pnpm projects."));if(!e.security&&!R?.length)return}const{packageManager:N}=G(d),U=H(d),i=o?.update??{},h=K(d,N,{dev:e.dev,includeInternal:e["include-internal"],peer:e.peer,prod:e.prod});if(h.size===0){s.info("No catalogs found.");return}const w=e.target??i.target??"latest";if(!["latest","minor","patch"].includes(w))throw new Error(`Invalid target "${w}". Use: latest, minor, or patch.`);const D={exclude:[...m(e.exclude),...m(i.exclude)],ignore:m(i.ignore),include:[...m(e.include),...m(i.include),...R],includeLocked:!!e.includeLocked,includePrerelease:e.prerelease||i.prerelease||!1,security:e.security!==!1,target:w};let x=0;for(const t of h.values())x+=t.size;const k=!!process.stdout.isTTY&&!ee;let l;const I=k?(t,r)=>{l?l.rerender(c.createElement(j,{current:t,total:r})):l=T(c.createElement(j,{current:t,total:r}),{interactive:!0,patchConsole:!1})}:(t,r)=>{s.info(`Checking ${String(t)}/${String(r)} dependencies...`)};k||s.info(`Checking ${String(x)} catalog dependencies against npm registry...
3
3
  `);const v=new Set;O("socket")&&v.add("socket"),O("depsDev")&&v.add("deps-dev");const g=o?.security?.policies?.score?.minimum,M=Q(o?.security,{disabled:v,minimumScore:g}),{failed:$,outdated:n}=await W(h,D,U,I,d,M,o?.security?.acceptedRisks);if(l&&(l.clear(),l.unmount()),$.length>0&&s.warn(`Failed to fetch: ${$.join(", ")}`),n.length===0){s.info("All catalog dependencies are up to date.");return}const S=e.format??i.format??"table",V=te(e.aiType??"impact"),u=e.ai?await se(n,s,o?.ai,V):void 0;if(k&&S==="table"){const t=new ce(n,u??null),r=o?.tui?.autoExit??!1,E=r===!0?3:typeof r=="number"?r:0;await T(c.createElement(ie,{autoExitSeconds:E,isDryRun:!0,store:t}),{alternateScreen:!0,exitOnCtrlC:!1,interactive:!0,patchConsole:!0}).waitUntilExit();const q=process.stdout.columns||80;process.stdout.write(`
4
4
  `);for(const a of n){const B=a.vulnerabilities?.length||a.socketReport&&a.socketReport.alerts.length>0,b=!!a.acceptedRisk,Y=B?b?"✓":"⚠":"✓",z=b?"gray":a.updateType==="major"?"red":a.updateType==="minor"?"yellow":"green",p=a.socketReport?.score.overall,F=p===void 0?"":` [${String(Math.round(p*100))}%]`,A=p===void 0?void 0:oe(p);process.stdout.write(`${X(c.createElement(y,null," ",c.createElement(y,{color:z},Y),` ${a.packageName} ${a.currentRange} → ${a.newRange}`,c.createElement(y,{dimColor:!0},` ${a.updateType}`),A?c.createElement(y,{color:A},F):null),{columns:q})}
@@ -1,4 +1,4 @@
1
- import{createRequire as K}from"node:module";import{j as g,F as m,q as v,J as N,X as P,b as j}from"../packem_shared/index.server-sXNQYpsl.js";import{e as h,v as U}from"../packem_shared/index-BzhrR_iC.js";import{d as F,b as Y}from"./catalog.js";import{d as J}from"../packem_shared/lockfile-CiUtEbnt.js";import{p as z,s as X}from"../packem_shared/docker-DXqV-07f.js";import{i as ne}from"../packem_shared/index-BjdW45xX.js";import{g as B}from"../packem_shared/formatBytes-BHAzNIrn-CrusHOew.js";import{h as oe}from"../packem_shared/writeFileSync-DJoHk3Ks-BPRoepNw.js";import{y as re}from"../packem_shared/isAccessibleSync-DYKTrrvc-C-_5cgwu.js";let G;const W=e=>(G??=K(import.meta.url))(e),b=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,y=e=>{if(typeof b<"u"&&b.versions&&b.versions.node){const[t,n]=b.versions.node.split(".").map(Number);if(t>22||t===22&&n>=3||t===20&&n>=16)return b.getBuiltinModule(e)}return W(e)},{createInterface:O}=y("node:readline"),{spawn:Q}=y("node:child_process"),{createHash:Z}=y("node:crypto"),{existsSync:I,writeFileSync:ee,chmodSync:te}=y("node:fs"),S={aube:{base:["RUN corepack enable"],build:e=>e?`RUN aube run --filter ${e} build`:"RUN aube run build",install:"RUN aube install --frozen-lockfile"},bun:{base:["RUN npm install -g bun"],build:e=>e?`RUN bun run --filter ${e} build`:"RUN bun run build",install:"RUN --mount=type=cache,target=/root/.bun/install/cache bun install --frozen-lockfile"},npm:{base:[],build:e=>e?`RUN npm run build --workspace ${e}`:"RUN npm run build",install:"RUN --mount=type=cache,target=/root/.npm npm ci"},pnpm:{base:["ENV PNPM_HOME=/pnpm","ENV PATH=$PNPM_HOME:$PATH","RUN corepack enable"],build:e=>e?`RUN pnpm --filter ${e} build`:"RUN pnpm build",install:"RUN --mount=type=cache,id=pnpm,target=/pnpm/store pnpm install --frozen-lockfile"},yarn:{base:["RUN corepack enable"],build:e=>e?`RUN yarn workspace ${e} build`:"RUN yarn build",install:"RUN --mount=type=cache,target=/usr/local/share/.cache/yarn yarn install --immutable"}},se=e=>{const{focus:t,manager:n,nodeVersion:r}=e,o=S[n]??S.npm;return["# syntax=docker/dockerfile:1","","# Generated by 'vis docker init'. Before building, scaffold the context:",`# vis docker scaffold${t?` --focus=${t}`:""} --include-sources`,"# then build with BuildKit enabled (DOCKER_BUILDKIT=1).","",`FROM node:${r}-slim AS base`,"WORKDIR /app",...o.base,"","# --- install dependencies from the scaffolded manifests only ---","FROM base AS deps","COPY .vis/docker/workspace/ ./",o.install,"","# --- build the focus project, then drop unfocused workspace projects ---","FROM deps AS build","COPY .vis/docker/sources/ ./",o.build(t),"RUN npx vis docker prune --context=.vis/docker","","# --- minimal runtime image ---",`FROM node:${r}-slim AS runtime`,"WORKDIR /app","ENV NODE_ENV=production","COPY --from=build /app ./","USER node","# TODO: point this at your app's entrypoint",'CMD ["node", "index.js"]',""].join(`
1
+ import{createRequire as K}from"node:module";import{j as g,F as m,q as v,J as N,X as P,b as j}from"../packem_shared/index.server-Ca_EEVfw.js";import{e as h,v as U}from"../packem_shared/index-BzhrR_iC.js";import{d as F,b as Y}from"./catalog.js";import{d as J}from"../packem_shared/lockfile-CiUtEbnt.js";import{p as z,s as X}from"../packem_shared/docker-DXqV-07f.js";import{i as ne}from"../packem_shared/index-BjdW45xX.js";import{g as B}from"../packem_shared/formatBytes-_HvjOy8a-B_qQr4Hw.js";import{h as oe}from"../packem_shared/writeFileSync-DJoHk3Ks-BPRoepNw.js";import{y as re}from"../packem_shared/isAccessibleSync-DYKTrrvc-C-_5cgwu.js";let G;const W=e=>(G??=K(import.meta.url))(e),b=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,y=e=>{if(typeof b<"u"&&b.versions&&b.versions.node){const[t,n]=b.versions.node.split(".").map(Number);if(t>22||t===22&&n>=3||t===20&&n>=16)return b.getBuiltinModule(e)}return W(e)},{createInterface:O}=y("node:readline"),{spawn:Q}=y("node:child_process"),{createHash:Z}=y("node:crypto"),{existsSync:I,writeFileSync:ee,chmodSync:te}=y("node:fs"),S={aube:{base:["RUN corepack enable"],build:e=>e?`RUN aube run --filter ${e} build`:"RUN aube run build",install:"RUN aube install --frozen-lockfile"},bun:{base:["RUN npm install -g bun"],build:e=>e?`RUN bun run --filter ${e} build`:"RUN bun run build",install:"RUN --mount=type=cache,target=/root/.bun/install/cache bun install --frozen-lockfile"},npm:{base:[],build:e=>e?`RUN npm run build --workspace ${e}`:"RUN npm run build",install:"RUN --mount=type=cache,target=/root/.npm npm ci"},pnpm:{base:["ENV PNPM_HOME=/pnpm","ENV PATH=$PNPM_HOME:$PATH","RUN corepack enable"],build:e=>e?`RUN pnpm --filter ${e} build`:"RUN pnpm build",install:"RUN --mount=type=cache,id=pnpm,target=/pnpm/store pnpm install --frozen-lockfile"},yarn:{base:["RUN corepack enable"],build:e=>e?`RUN yarn workspace ${e} build`:"RUN yarn build",install:"RUN --mount=type=cache,target=/usr/local/share/.cache/yarn yarn install --immutable"}},se=e=>{const{focus:t,manager:n,nodeVersion:r}=e,o=S[n]??S.npm;return["# syntax=docker/dockerfile:1","","# Generated by 'vis docker init'. Before building, scaffold the context:",`# vis docker scaffold${t?` --focus=${t}`:""} --include-sources`,"# then build with BuildKit enabled (DOCKER_BUILDKIT=1).","",`FROM node:${r}-slim AS base`,"WORKDIR /app",...o.base,"","# --- install dependencies from the scaffolded manifests only ---","FROM base AS deps","COPY .vis/docker/workspace/ ./",o.install,"","# --- build the focus project, then drop unfocused workspace projects ---","FROM deps AS build","COPY .vis/docker/sources/ ./",o.build(t),"RUN npx vis docker prune --context=.vis/docker","","# --- minimal runtime image ---",`FROM node:${r}-slim AS runtime`,"WORKDIR /app","ENV NODE_ENV=production","COPY --from=build /app ./","USER node","# TODO: point this at your app's entrypoint",'CMD ["node", "index.js"]',""].join(`
2
2
  `)},$="v2.14.0",D=`https://github.com/hadolint/hadolint/releases/download/${$}`,ie={"hadolint-linux-arm64":"331f1d3511b84a4f1e3d18d52fec284723e4019552f4f47b19322a53ce9a40ed","hadolint-linux-x86_64":"6bf226944684f56c84dd014e8b979d27425c0148f61b3bd99bcc6f39e9dc5a47","hadolint-macos-arm64":"3625e2e9f43dcfe7bd38738a5f5520ed50ce39ed28485266e6803dd7bc197b10","hadolint-macos-x86_64":"2b69a853433f1eca522ffb921cd490bd1321424d03331fd8390f93b7fb4a02e9","hadolint-windows-x86_64.exe":"8e0ee174f88edb14f207a68430c7a53c2883ed509cdbde9a3a26fffa140fa5e4"},ae=e=>ie[e],ce=(e=process.platform,t=process.arch)=>{const n=e==="darwin"?"macos":e==="linux"?"linux":e==="win32"?"windows":void 0;if(n===void 0)return;const r=t==="arm64"?"arm64":t==="x64"?"x86_64":void 0;if(n==="windows")return"hadolint-windows-x86_64.exe";if(r!==void 0)return`hadolint-${n}-${r}`},L=e=>h(B(),"hadolint",$,e.endsWith(".exe")?"hadolint.exe":"hadolint"),le=()=>{const e=process.platform==="win32"?"hadolint.exe":"hadolint",t=(process.env.PATH??"").split(process.platform==="win32"?";":":");for(const n of t)if(n!==""&&I(h(n,e)))return e},de=e=>e.trim().split(/\s+/u)[0]??"",E=async e=>{const t=await fetch(e,{redirect:"follow"});if(!t.ok)throw new Error(`download failed (${String(t.status)} ${t.statusText}) for ${e}`);return Buffer.from(await t.arrayBuffer())},ue=async e=>{const t=L(e),n=ae(e),r=await E(`${D}/${e}`),o=Z("sha256").update(r).digest("hex");if(n===void 0){const s=await E(`${D}/${e}.sha256`),i=de(s.toString("utf8")).toLowerCase();if(i==="")throw new Error("hadolint checksum sidecar was empty or unparseable. Refusing to use the download.");if(i!==o)throw new Error(`hadolint checksum mismatch (expected ${i}, got ${o}). Refusing to use the download.`)}else if(n.toLowerCase()!==o)throw new Error(`hadolint checksum mismatch (expected ${n.toLowerCase()}, got ${o}). Refusing to use the download.`);return oe(h(B(),"hadolint",$)),ee(t,r),process.platform!=="win32"&&te(t,493),t},fe=async()=>{const e=O({input:process.stdin,output:process.stderr}),t=await new Promise(n=>{e.question(` Download hadolint ${v($)} now? ${m("[y/N]")} `,r=>{n(r.trim().toLowerCase())})});return e.close(),t==="y"||t==="yes"},pe=async e=>{const{autoInstall:t=!1,log:n}=e,r=le();if(r!==void 0)return r;const o=ce();if(o===void 0){n(`hadolint has no prebuilt binary for ${process.platform}/${process.arch}. Install it manually: https://github.com/hadolint/hadolint`);return}const s=L(o);if(I(s))return s;if(!t){if(!(!!process.stdin.isTTY&&!ne)){n(`hadolint is not installed. Re-run with ${g("--install")} (or install hadolint on PATH) to enable Dockerfile linting.`);return}if(n(`${g("hadolint")} is required to lint Dockerfiles but was not found on your PATH.`),!await fe()){n(`Skipped. Install it yourself or re-run with ${g("--install")}.`);return}}n(`Downloading hadolint ${$} (${o})…`);try{const i=await ue(o);return n(`Installed hadolint to ${m(i)}`),i}catch(i){n(`Failed to download hadolint: ${i.message}`);return}},_=async(e,t,n)=>{if(t.length===0)return[];const r=["--format","json","--no-fail",...n!==void 0&&n!==""?["--config",n]:[],...t],o=await new Promise((i,l)=>{const a=Q(e,r,{stdio:["ignore","pipe","pipe"],windowsHide:!0});let d="",u="";a.stdout?.on("data",c=>{d+=c.toString("utf8")}),a.stderr?.on("data",c=>{u+=c.toString("utf8")}),a.on("error",l),a.on("close",()=>{if(d.trim()===""&&u.trim()!==""){l(new Error(u.trim()));return}i(d)})});if(o.trim()==="")return[];let s;try{s=JSON.parse(o)}catch{throw new Error("Could not parse hadolint JSON output.")}return Array.isArray(s)?s:[]},C=(e,t,n)=>{if(!(!/\bapt-get\b/u.test(e)||!/\binstall\b/u.test(e)||n.test(e)))return e.replace(/\binstall\b/u,`install ${t}`)},k={DL3014:e=>C(e,"-y",/(?:^|\s)(?:-y|--yes|--assume-yes|-qq?)\b/u),DL3015:e=>C(e,"--no-install-recommends",/--no-install-recommends\b/u),DL3020:e=>/^\s*ADD\b/u.test(e)?e.replace(/^(\s*)ADD\b/u,"$1COPY"):void 0,DL3027:e=>/(?:^|\s)apt\s/u.test(e)&&!/\bapt-get\b/u.test(e)?e.replace(/(^|\s)apt(\s)/u,"$1apt-get$2"):void 0},T=new Set(Object.keys(k)),me=(e,t)=>{const n=e.includes(`\r
3
3
  `)?`\r
4
4
  `:`
@@ -1,3 +1,3 @@
1
- import{createRequire as H}from"node:module";import{J as A,q as U,j as W,F as E}from"../packem_shared/index.server-sXNQYpsl.js";import{a as P}from"../packem_shared/index-BzhrR_iC.js";import{Z as I}from"./cli-main.js";import{d as F,f as C,r as Z,a as Q,b as X,s as Y,c as ee,e as te,g as se,h as ie,i as ne,j as re,k as ae,l as oe,m as ce,n as de,o as fe,p as le,q as ue,t as pe}from"../packem_shared/watch-loop-BBkg02-Q.js";import{T as h}from"./catalog.js";let J;const D=t=>(J??=H(import.meta.url))(t),k=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,G=t=>{if(typeof k<"u"&&k.versions&&k.versions.node){const[e,s]=k.versions.node.split(".").map(Number);if(e>22||e===22&&s>=3||e===20&&s>=16)return k.getBuiltinModule(t)}return D(t)},{createHash:_}=G("node:crypto"),ge=t=>t.startsWith("/")||/^[a-z]:[\\/]/i.test(t),q=(t,e)=>ge(e)?e:`${t}/${e}`,me={argsCheck:(t,e)=>O(t,e,"check"),argsFix:(t,e)=>O(t,e,"fix"),bin:()=>["pnpm","exec","dprint"],cacheKey:(t,e)=>{const s=["dprint",t.declaredVersion??"unknown",t.configFile??"no-config",e.quiet?"q":"",...e.extraArgs??[]];return _("sha256").update(s.join("|")).digest("hex").slice(0,16)},detect:(t,e)=>{const s=F(e,h.dprint.packageNames[0]),i=C(t,h.dprint.configFiles);if(!(!s&&!i))return{adapter:"dprint",configFile:i,declared:!!s,declaredVersion:s,root:t}},extensions:["cjs","css","cts","dockerfile","html","js","json","jsonc","jsx","md","mdx","mjs","mts","toml","ts","tsx","yaml","yml"],id:"dprint",kind:"fmt",parse:(t,e)=>{if(t.exitCode===0)return[];const s=[];for(const i of t.stdout.split(/\r?\n/)){const n=i.trim();!n||n.startsWith("[")||n.startsWith("Checked ")||n.startsWith("Error:")||s.push({adapter:"dprint",file:q(e.root,n),fixable:!0,message:"Code style issues would be auto-fixed",severity:"info"})}return s}},O=(t,e,s)=>{const i=s==="fix"?["fmt"]:["check","--list-different"];return e.extraArgs?.length&&i.push(...e.extraArgs),i.push(...t),i},he={argsCheck:(t,e)=>V(t,e,"check"),argsFix:(t,e)=>V(t,e,"fix"),bin:()=>["pnpm","exec","oxfmt"],cacheKey:(t,e)=>{const s=["oxfmt",t.declaredVersion??"unknown",t.configFile??"no-config",e.quiet?"q":"",...e.extraArgs??[]];return _("sha256").update(s.join("|")).digest("hex").slice(0,16)},detect:(t,e)=>{const s=F(e,h.oxfmt.packageNames[0]),i=C(t,h.oxfmt.configFiles);if(!(!s&&!i))return{adapter:"oxfmt",configFile:i,declared:!!s,declaredVersion:s,root:t}},extensions:["cjs","cts","js","json","jsonc","jsx","mjs","mts","ts","tsx"],id:"oxfmt",kind:"fmt",parse:(t,e)=>{if(t.exitCode===0)return[];const s=[];for(const i of t.stdout.split(/\r?\n/)){const n=i.trim();!n||n.startsWith("[")||s.push({adapter:"oxfmt",file:q(e.root,n),fixable:!0,message:"Code style issues would be auto-fixed",severity:"info"})}return s}},V=(t,e,s)=>{const i=s==="fix"?["--write"]:["--list-different"];return e.extraArgs?.length&&i.push(...e.extraArgs),i.push(...t),i},xe={argsCheck:(t,e)=>N(t,e,"check"),argsFix:(t,e)=>N(t,e,"fix"),bin:()=>["pnpm","exec","prettier"],cacheKey:(t,e)=>{const s=["prettier",t.declaredVersion??"unknown",t.configFile??"no-config",e.quiet?"q":"",...e.extraArgs??[]];return _("sha256").update(s.join("|")).digest("hex").slice(0,16)},detect:(t,e)=>{const s=F(e,h.prettier.packageNames[0]),i=C(t,h.prettier.configFiles);if(!(!s&&!i))return{adapter:"prettier",configFile:i,declared:!!s,declaredVersion:s,root:t}},extensions:["cjs","css","cts","html","js","json","jsx","less","md","mdx","mjs","mts","scss","ts","tsx","vue","yaml","yml"],id:"prettier",kind:"fmt",parse:(t,e)=>{if(t.exitCode===0)return[];const s=[];for(const i of t.stdout.split(/\r?\n/)){const n=i.trim();n&&(n.startsWith("[")||s.push({adapter:"prettier",file:q(e.root,n),fixable:!0,message:"Code style issues would be auto-fixed",severity:"info"}))}return s}},N=(t,e,s)=>{const i=s==="fix"?["--write"]:["--list-different"];return e.quiet&&i.push("--log-level","warn"),e.extraArgs?.length&&i.push(...e.extraArgs),i.push(...t),i},ke=[he,se,me,xe,ie,ne],Re=async({logger:t,options:e,visConfig:s,workspaceRoot:i})=>{const n=i??process.cwd(),p=s?.fmt,w=Z(ke,p?.order),L=Q(n,w),x=X(L,w,"fmt").filter(({adapter:l})=>p?.adapters?.[l.id]?.enabled!==!1);if(x.length===0){t.warn("vis fmt: no formatter detected in this workspace (looked for: oxfmt, biome, dprint, prettier, ruff, deno-fmt).");return}const R=l=>{const a=p?.adapters?.[l]?.extraArgs;return a&&a.length>0?[...a]:void 0},v={quiet:e.quiet??!1},$=we(e),b=e.check?"check":"fix";let c;if(e.staged){if(c=Y(n),c===void 0)t.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){t.info(A("✓ fmt: no staged files"));return}}else if(typeof e.since=="string"&&e.since.length>0){if(c=ee(n,e.since),c===void 0)t.warn(`vis fmt: could not resolve --since ${e.since} (not a git repo or unknown ref). Falling back to a workspace-wide run.`);else if(c.length===0){t.info(A(`✓ fmt: no files changed since ${e.since}`));return}}const K=I(n,void 0,void 0,!0),y=e.format??"human";y==="human"&&e.output!==void 0&&t.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 l=>{const a=$.length>0?$:l,g=[];if(a){const r=re(a,x,p?.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 ae(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}}),u=oe(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:ce({cwd:n,target:e.output});try{switch(y){case"github":{m.write(le({runs:j.map(r=>({findings:r.findings})),workspaceRoot:n}));break}case"json":{m.write(`${JSON.stringify({findings:u.findings,mode:b,runs:u.runs},null,2)}
2
- `);break}case"junit":{m.write(fe({runs:j.map(r=>({adapter:r.adapter.id,durationMs:r.durationMs,findings:r.findings})),workspaceRoot:n}));break}case"minimal":{je(u.findings,n,m);break}case"sarif":{m.write(de({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(u.findings,n,b,t)}}finally{m?.close()}const S=b==="fix"?u.hadProcessFailure?1:0:ue({...u,maxSeverity:u.findings.length>0?"error":void 0});S!==0&&(process.exitCode=S)};if(e.watch){const l=[...new Set(x.flatMap(({adapter:a})=>a.extensions))];await te({extensions:l,initialFiles:c,label:"fmt",log:a=>{t.info(a)},runCycle:M,workspaceRoot:n});return}await M(c)},we=t=>{const e=t;return[...e._??e.args??[]]},be=(t,e,s,i)=>{if(t.length===0){i.info(A(s==="fix"?"✓ fmt: nothing to change":"✓ fmt: all files already formatted"));return}const n=pe(t),p=s==="fix"?U(W("Formatted:")):W("Would change:");i.info(p);for(const w of n.keys())i.info(` ${E("·")} ${P(e,w)}`);s==="check"&&(i.info(""),i.info(E(`Run \`vis fmt\` to apply changes (${String(n.size)} file${n.size===1?"":"s"}).`)))},je=(t,e,s)=>{for(const i of t)s.write(`${i.adapter} ${P(e,i.file)}
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-BzhrR_iC.js";import{Z as I}from"./cli-main.js";import{d as F,f as C,w as Z,r as Q,a as X,b as Y,s as ee,c as te,e as se,g as ie,h as ne,i as re,j as ae,k as oe,l as ce,m as de,n as fe,o as le,p as ue,q as pe}from"../packem_shared/watch-loop-BEnGuMBn.js";import{T as h}from"./catalog.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:_}=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 _("sha256").update(s.join("|")).digest("hex").slice(0,16)},detect:(e,t)=>{const s=F(t,h.dprint.packageNames[0]),i=C(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 _("sha256").update(s.join("|")).digest("hex").slice(0,16)},detect:(e,t)=>{const s=F(t,h.oxfmt.packageNames[0]),i=C(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 _("sha256").update(s.join("|")).digest("hex").slice(0,16)},detect:(e,t)=>{const s=F(t,h.prettier.packageNames[0]),i=C(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,ie,me,xe,ne],Re=async({logger:e,options:t,visConfig:s,workspaceRoot:i})=>{const n=i??process.cwd(),l=s?.fmt;Z(e,"fmt",l);const k=Q(we,l?.order),L=X(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=ee(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=te(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=re(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 ae(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=oe(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:ce({cwd:n,target:t.output});try{switch(y){case"github":{m.write(le({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
+ `);break}case"junit":{m.write(fe({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(de({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:ue({...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 se({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=pe(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{Re as default};
@@ -1,4 +1,4 @@
1
- import{createRequire as re}from"node:module";import{F as d,j as y,q as v}from"../packem_shared/index.server-sXNQYpsl.js";import{e as E,m as J,a as z,v as F,l as oe,U as ie}from"../packem_shared/index-BzhrR_iC.js";import{y as _}from"../packem_shared/isAccessibleSync-DYKTrrvc-C-_5cgwu.js";import{L as K}from"./catalog.js";import{p as f}from"./cli-main.js";import{d as de}from"../packem_shared/git-source-DExWbfN0.js";import{h as X,U as me}from"../packem_shared/writeFileSync-DJoHk3Ks-BPRoepNw.js";let se;const ne=t=>(se??=re(import.meta.url))(t),O=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,k=t=>{if(typeof O<"u"&&O.versions&&O.versions.node){const[e,r]=O.versions.node.split(".").map(Number);if(e>22||e===22&&r>=3||e===20&&r>=16)return O.getBuiltinModule(t)}return ne(t)},{fileURLToPath:ae}=k("node:url"),{createInterface:ce}=k("node:readline"),{mkdtempSync:le,rmSync:fe}=k("node:fs"),{tmpdir:ue}=k("node:os"),{spawnSync:pe}=k("node:child_process"),Y=[".ts",".mts",".cts",".js",".mjs",".cjs"],he="template.yml",ge=[".d",".test",".spec",".config",".bench",".stories"],we=[".d.ts",".d.mts",".d.cts",".js.map",".mjs.map",".cjs.map",".ts.map"],G=t=>{for(const e of Y)if(t.endsWith(e))return t.slice(0,-e.length);return t},$e=t=>{if(we.some(r=>t.endsWith(r))||!Y.some(r=>t.endsWith(r)))return!1;const e=G(t);return!ge.some(r=>e.endsWith(r))},U=(t,e)=>{const r=[];if(!_(t))return r;for(const n of K(t,{includeDirs:!1,includeSymlinks:!1,maxDepth:1})){if(!$e(n.name))continue;const s=G(n.name);r.push({load:()=>ve(n.path),name:s,path:n.path,source:e})}return r},R=(t,e)=>{const r=[];if(!_(t))return r;for(const n of K(t,{includeFiles:!1,includeSymlinks:!1,maxDepth:1})){if(n.path===t)continue;const s=E(n.path,he);_(s)&&r.push({load:()=>be(n.path,n.name),name:n.name,path:n.path,source:e})}return r},ye=()=>{try{const t=ae(import.meta.url),e=E(J(t),"..","..","templates");return _(e)?e:void 0}catch{return}},I=t=>{const{extraDirectories:e=[],onWarning:r,workspaceRoot:n}=t,s=[...U(E(n,".vis","templates"),"native"),...R(E(n,".vis","templates"),"moon"),...R(E(n,".moon","templates"),"moon")];for(const c of e)s.push(...R(c,"config")),s.push(...U(c,"config"));const i=ye();i&&s.push(...R(i,"builtin"));const a=new Map;for(const c of s){const o=a.get(c.name);if(!o){a.set(c.name,c);continue}r&&r(`Template "${c.name}" exists in multiple sources — using ${o.source} (${o.path}), ignoring ${c.source} (${c.path}).`)}return[...a.values()].sort((c,o)=>c.name.localeCompare(o.name))},ve=async t=>{const{loadNativeTemplate:e}=await import("./loader2.js");return e(t)},be=async(t,e)=>{const{loadMoonTemplate:r}=await import("./index6.js");return r(t,e)},q=(t,e)=>new Promise(r=>{t.question(e,n=>{r(n.trim())})}),Se=async(t,e,r)=>{const s=await q(t,` ${e} ${d(r?"[Y/n]":"[y/N]")} `);return s===""?r:s.toLowerCase()==="y"||s.toLowerCase()==="yes"},Ee=async(t,e,r,n)=>{process.stderr.write(` ${e}
1
+ import{createRequire as re}from"node:module";import{F as d,j as y,q as v}from"../packem_shared/index.server-Ca_EEVfw.js";import{e as E,m as J,a as z,v as F,l as oe,U as ie}from"../packem_shared/index-BzhrR_iC.js";import{y as _}from"../packem_shared/isAccessibleSync-DYKTrrvc-C-_5cgwu.js";import{L as K}from"./catalog.js";import{p as f}from"./cli-main.js";import{d as de}from"../packem_shared/git-source-DExWbfN0.js";import{h as X,U as me}from"../packem_shared/writeFileSync-DJoHk3Ks-BPRoepNw.js";let se;const ne=t=>(se??=re(import.meta.url))(t),O=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,k=t=>{if(typeof O<"u"&&O.versions&&O.versions.node){const[e,r]=O.versions.node.split(".").map(Number);if(e>22||e===22&&r>=3||e===20&&r>=16)return O.getBuiltinModule(t)}return ne(t)},{fileURLToPath:ae}=k("node:url"),{createInterface:ce}=k("node:readline"),{mkdtempSync:le,rmSync:fe}=k("node:fs"),{tmpdir:ue}=k("node:os"),{spawnSync:pe}=k("node:child_process"),Y=[".ts",".mts",".cts",".js",".mjs",".cjs"],he="template.yml",ge=[".d",".test",".spec",".config",".bench",".stories"],we=[".d.ts",".d.mts",".d.cts",".js.map",".mjs.map",".cjs.map",".ts.map"],G=t=>{for(const e of Y)if(t.endsWith(e))return t.slice(0,-e.length);return t},$e=t=>{if(we.some(r=>t.endsWith(r))||!Y.some(r=>t.endsWith(r)))return!1;const e=G(t);return!ge.some(r=>e.endsWith(r))},U=(t,e)=>{const r=[];if(!_(t))return r;for(const n of K(t,{includeDirs:!1,includeSymlinks:!1,maxDepth:1})){if(!$e(n.name))continue;const s=G(n.name);r.push({load:()=>ve(n.path),name:s,path:n.path,source:e})}return r},R=(t,e)=>{const r=[];if(!_(t))return r;for(const n of K(t,{includeFiles:!1,includeSymlinks:!1,maxDepth:1})){if(n.path===t)continue;const s=E(n.path,he);_(s)&&r.push({load:()=>be(n.path,n.name),name:n.name,path:n.path,source:e})}return r},ye=()=>{try{const t=ae(import.meta.url),e=E(J(t),"..","..","templates");return _(e)?e:void 0}catch{return}},I=t=>{const{extraDirectories:e=[],onWarning:r,workspaceRoot:n}=t,s=[...U(E(n,".vis","templates"),"native"),...R(E(n,".vis","templates"),"moon"),...R(E(n,".moon","templates"),"moon")];for(const c of e)s.push(...R(c,"config")),s.push(...U(c,"config"));const i=ye();i&&s.push(...R(i,"builtin"));const a=new Map;for(const c of s){const o=a.get(c.name);if(!o){a.set(c.name,c);continue}r&&r(`Template "${c.name}" exists in multiple sources — using ${o.source} (${o.path}), ignoring ${c.source} (${c.path}).`)}return[...a.values()].sort((c,o)=>c.name.localeCompare(o.name))},ve=async t=>{const{loadNativeTemplate:e}=await import("./loader2.js");return e(t)},be=async(t,e)=>{const{loadMoonTemplate:r}=await import("./index6.js");return r(t,e)},q=(t,e)=>new Promise(r=>{t.question(e,n=>{r(n.trim())})}),Se=async(t,e,r)=>{const s=await q(t,` ${e} ${d(r?"[Y/n]":"[y/N]")} `);return s===""?r:s.toLowerCase()==="y"||s.toLowerCase()==="yes"},Ee=async(t,e,r,n)=>{process.stderr.write(` ${e}
2
2
  `);for(const[s,i]of r.entries()){const a=y(v(` ${String(s+1)}.`)),c=i===n?d(" (default)"):"";process.stderr.write(`${a} ${i}${c}
3
3
  `)}for(;;){const s=await q(t,`
4
4
  ${d(`Enter choice (1-${String(r.length)}):`)} `);if(s===""&&n!==void 0)return n;const i=Number.parseInt(s,10);if(Number.isInteger(i)&&i>=1&&i<=r.length)return r[i-1];const a=r.find(c=>c===s);if(a)return a;process.stderr.write(` ${d("Invalid choice. Try again.")}
@@ -1,8 +1,8 @@
1
- import{createRequire as Q}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-sXNQYpsl.js";import{a as S}from"../packem_shared/index-BzhrR_iC.js";import{Z as se}from"./cli-main.js";import{d as f,f as b,u as ae,r as oe,a as ce,b as le,s as de,c as ue,e as fe,g as ge,v as pe,w as me,x as P,k as he,l as xe,m as we,n as ve,o as ye,p as ke,t as be,q as $e}from"../packem_shared/watch-loop-BBkg02-Q.js";import{T as d}from"./catalog.js";import{R as Ae}from"./ts-loader.js";let ee;const te=e=>(ee??=Q(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=ae(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 Q}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-BzhrR_iC.js";import{Z as se}from"./cli-main.js";import{d as f,f as b,t as ae,w as oe,r as ce,a as le,b as de,s as ue,c as fe,e as ge,g as pe,u as me,v as P,j as he,k as xe,l as we,m as ve,n as ye,o as ke,q as be,p as $e}from"../packem_shared/watch-loop-BEnGuMBn.js";import{T as d}from"./catalog.js";import{R as Ae}from"./ts-loader.js";let ee;const te=e=>(ee??=Q(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=ae(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?`:
5
5
  ${r}`:""}`:`type-check failed (exit ${String(e.exitCode)}) with unrecognised output:
6
- ${r}`,severity:"error"})}return n},scope:"project"},K=e=>e.extraArgs?.length?[...e.extraArgs]:[],De=[Ie,ge,Fe,Pe,pe,Ne,Ee,me,Ue],st=async({logger:e,options:t,visConfig:n,workspaceRoot:r})=>{const i=r??process.cwd(),s=n?.lint,c=oe(De,s?.order),$=ce(i,c),x=le($,c,"lint").filter(({adapter:o})=>{const l=s?.adapters?.[o.id]?.enabled;return o.optIn?l===!0:l!==!1});for(const o of c)o.optIn&&s?.adapters?.[o.id]?.enabled===!0&&!$.has(o.id)&&e.warn(`vis lint: adapters.${o.id}.enabled is set, but ${o.id} was not detected (needs a tsconfig.json and a typescript dependency at the workspace root). Skipping it.`);if(x.length===0){e.warn("vis lint: no linter detected in this workspace (looked for: oxlint, biome, eslint, stylelint, ruff, markdownlint, shellcheck, deno; typecheck runs only when enabled).");return}const j=o=>{const l=s?.adapters?.[o]?.extraArgs;return l&&l.length>0?[...l]:void 0},A={extraArgs:void 0,maxWarnings:typeof t.maxWarnings=="number"?t.maxWarnings:void 0,quiet:t.quiet??!1},W=Ge(t),H=t.fix?"fix":"check";let g;if(t.staged){if(g=de(i),g===void 0)e.warn("vis lint: could not resolve --staged (not a git repo or git unavailable). Falling back to a workspace-wide run.");else if(g.length===0){e.info(I("✓ lint: no staged files"));return}}else if(typeof t.since=="string"&&t.since.length>0){if(g=ue(i,t.since),g===void 0)e.warn(`vis lint: could not resolve --since ${t.since} (not a git repo or unknown ref). Falling back to a workspace-wide run.`);else if(g.length===0){e.info(I(`✓ lint: no files changed since ${t.since}`));return}}const _=W.length>0?W:void 0,X=se(i,void 0,void 0,!0),N=t.format??"human";N==="human"&&t.output!==void 0&&e.warn("vis lint: --output is ignored for the human format; pass --format json|minimal|sarif|junit|github to redirect findings to a file.");const R=async o=>{const l=o!==void 0&&o.length>0&&_===void 0,w=[];for(const{adapter:a,presence:y}of x){let u;if(a.scope==="project"){const q=_??o;if(q&&q.length>0&&P(q,a.extensions).length===0)continue;u=["."]}else if(l){if(u=P(o,a.extensions),u.length===0)continue}else u=_??o??["."];const F=j(a.id),E={adapter:a,files:u,presence:y};F&&(E.options={...A,extraArgs:F}),w.push(E)}if(w.length===0)return;const Z=await he(w,A,H,{cacheRoot:X}),C=w.map((a,y)=>{const u=Z[y],F=a.adapter.parse(u,a.presence);return{adapter:a.adapter,durationMs:u.durationMs,exitCode:u.exitCode,findings:F}}),v=xe(C.map(a=>({adapter:a.adapter.id,durationMs:a.durationMs,exitCode:a.exitCode,findingCount:a.findings.length,findings:a.findings}))),m=N==="human"?void 0:we({cwd:i,target:t.output});try{switch(N){case"github":{m.write(ke({runs:C.map(a=>({findings:a.findings})),workspaceRoot:i}));break}case"json":{m.write(`${JSON.stringify({findings:v.findings,runs:v.runs},null,2)}
7
- `);break}case"junit":{m.write(ye({runs:C.map(a=>({adapter:a.adapter.id,durationMs:a.durationMs,findings:a.findings})),workspaceRoot:i}));break}case"minimal":{ze(v.findings,i,m);break}case"sarif":{m.write(ve({runs:C.map(a=>({adapter:a.adapter.id,findings:a.findings,presence:w.find(y=>y.adapter.id===a.adapter.id)?.presence})),workspaceRoot:i}));break}default:Ye(v.findings,i,e)}}finally{m?.close()}const T=$e(v);T!==0&&(process.exitCode=T)};if(t.watch){const o=[...new Set(x.flatMap(({adapter:l})=>l.extensions))];await fe({extensions:o,initialFiles:g,label:"lint",log:l=>{e.info(l)},runCycle:R,workspaceRoot:i});return}await R(g)},Ge=e=>{const t=e;return[...t._??t.args??[]]},Ye=(e,t,n)=>{if(e.length===0){n.info(I("✓ lint: no findings"));return}const r=be(e);for(const[c,$]of r){n.info(re(S(t,c)));for(const p of $){const x=He(p),j=Xe(p.severity),A=p.ruleId?O(` ${p.ruleId}`):"";n.info(` ${O(x)} ${j} ${p.message}${A}`)}}const i=e.filter(c=>c.severity==="error").length,s=e.filter(c=>c.severity==="warning").length;n.info(""),n.info(`${U(`${String(i)} error${i===1?"":"s"}`)}, ${D(`${String(s)} warning${s===1?"":"s"}`)}`)},ze=(e,t,n)=>{for(const r of e){const i=S(t,r.file),s=r.line??"",c=r.column??"";n.write(`${r.adapter} ${i} ${String(s)} ${String(c)} ${r.severity} ${r.ruleId??""} ${r.message}
6
+ ${r}`,severity:"error"})}return n},scope:"project"},K=e=>e.extraArgs?.length?[...e.extraArgs]:[],De=[Ie,pe,Fe,Pe,me,Ne,Ee,Ue],st=async({logger:e,options:t,visConfig:n,workspaceRoot:r})=>{const i=r??process.cwd(),s=n?.lint;oe(e,"lint",s);const c=ce(De,s?.order),$=le(i,c),x=de($,c,"lint").filter(({adapter:o})=>{const l=s?.adapters?.[o.id]?.enabled;return o.optIn?l===!0:l!==!1});for(const o of c)o.optIn&&s?.adapters?.[o.id]?.enabled===!0&&!$.has(o.id)&&e.warn(`vis lint: adapters.${o.id}.enabled is set, but ${o.id} was not detected (needs a tsconfig.json and a typescript dependency at the workspace root). Skipping it.`);if(x.length===0){e.warn("vis lint: no linter detected in this workspace (looked for: oxlint, biome, eslint, stylelint, ruff, markdownlint, shellcheck; typecheck runs only when enabled).");return}const j=o=>{const l=s?.adapters?.[o]?.extraArgs;return l&&l.length>0?[...l]:void 0},A={extraArgs:void 0,maxWarnings:typeof t.maxWarnings=="number"?t.maxWarnings:void 0,quiet:t.quiet??!1},W=Ge(t),H=t.fix?"fix":"check";let g;if(t.staged){if(g=ue(i),g===void 0)e.warn("vis lint: could not resolve --staged (not a git repo or git unavailable). Falling back to a workspace-wide run.");else if(g.length===0){e.info(I("✓ lint: no staged files"));return}}else if(typeof t.since=="string"&&t.since.length>0){if(g=fe(i,t.since),g===void 0)e.warn(`vis lint: could not resolve --since ${t.since} (not a git repo or unknown ref). Falling back to a workspace-wide run.`);else if(g.length===0){e.info(I(`✓ lint: no files changed since ${t.since}`));return}}const _=W.length>0?W:void 0,X=se(i,void 0,void 0,!0),N=t.format??"human";N==="human"&&t.output!==void 0&&e.warn("vis lint: --output is ignored for the human format; pass --format json|minimal|sarif|junit|github to redirect findings to a file.");const R=async o=>{const l=o!==void 0&&o.length>0&&_===void 0,w=[];for(const{adapter:a,presence:y}of x){let u;if(a.scope==="project"){const q=_??o;if(q&&q.length>0&&P(q,a.extensions).length===0)continue;u=["."]}else if(l){if(u=P(o,a.extensions),u.length===0)continue}else u=_??o??["."];const F=j(a.id),E={adapter:a,files:u,presence:y};F&&(E.options={...A,extraArgs:F}),w.push(E)}if(w.length===0)return;const Z=await he(w,A,H,{cacheRoot:X}),C=w.map((a,y)=>{const u=Z[y],F=a.adapter.parse(u,a.presence);return{adapter:a.adapter,durationMs:u.durationMs,exitCode:u.exitCode,findings:F}}),v=xe(C.map(a=>({adapter:a.adapter.id,durationMs:a.durationMs,exitCode:a.exitCode,findingCount:a.findings.length,findings:a.findings}))),m=N==="human"?void 0:we({cwd:i,target:t.output});try{switch(N){case"github":{m.write(ke({runs:C.map(a=>({findings:a.findings})),workspaceRoot:i}));break}case"json":{m.write(`${JSON.stringify({findings:v.findings,runs:v.runs},null,2)}
7
+ `);break}case"junit":{m.write(ye({runs:C.map(a=>({adapter:a.adapter.id,durationMs:a.durationMs,findings:a.findings})),workspaceRoot:i}));break}case"minimal":{ze(v.findings,i,m);break}case"sarif":{m.write(ve({runs:C.map(a=>({adapter:a.adapter.id,findings:a.findings,presence:w.find(y=>y.adapter.id===a.adapter.id)?.presence})),workspaceRoot:i}));break}default:Ye(v.findings,i,e)}}finally{m?.close()}const T=$e(v);T!==0&&(process.exitCode=T)};if(t.watch){const o=[...new Set(x.flatMap(({adapter:l})=>l.extensions))];await ge({extensions:o,initialFiles:g,label:"lint",log:l=>{e.info(l)},runCycle:R,workspaceRoot:i});return}await R(g)},Ge=e=>{const t=e;return[...t._??t.args??[]]},Ye=(e,t,n)=>{if(e.length===0){n.info(I("✓ lint: no findings"));return}const r=be(e);for(const[c,$]of r){n.info(re(S(t,c)));for(const p of $){const x=He(p),j=Xe(p.severity),A=p.ruleId?O(` ${p.ruleId}`):"";n.info(` ${O(x)} ${j} ${p.message}${A}`)}}const i=e.filter(c=>c.severity==="error").length,s=e.filter(c=>c.severity==="warning").length;n.info(""),n.info(`${U(`${String(i)} error${i===1?"":"s"}`)}, ${D(`${String(s)} warning${s===1?"":"s"}`)}`)},ze=(e,t,n)=>{for(const r of e){const i=S(t,r.file),s=r.line??"",c=r.column??"";n.write(`${r.adapter} ${i} ${String(s)} ${String(c)} ${r.severity} ${r.ruleId??""} ${r.message}
8
8
  `)}},He=e=>e.line===void 0?"":e.column===void 0?String(e.line):`${String(e.line)}:${String(e.column)}`,Xe=e=>e==="error"?U("error"):e==="warning"?D("warn "):ie("info ");export{st as default};
@@ -1,2 +1,2 @@
1
- import{createRequire as F}from"node:module";import{i as W}from"../packem_shared/index-BjdW45xX.js";import{p as Y}from"../packem_shared/prompt-DMzaQEVa.js";import{e as U}from"../packem_shared/index-BzhrR_iC.js";import{l as B,m as X,n as J,D as Q,o as Z,$ as ee,k as _}from"../packem_shared/formatBytes-BHAzNIrn-CrusHOew.js";import{y as te}from"../packem_shared/isAccessibleSync-DYKTrrvc-C-_5cgwu.js";import{p as se}from"../packem_shared/readJsonSync-CbryXYxN-EWl7_7KX.js";import{h as re,U as oe}from"../packem_shared/writeFileSync-DJoHk3Ks-BPRoepNw.js";import{g as ne,r as ce}from"../packem_shared/packument-Df46y5MY.js";import{q as ie,j as ae,F as v,b as S,X as E,J as A}from"../packem_shared/index.server-sXNQYpsl.js";import{a as le,o as fe}from"../packem_shared/pm-runner-3iiQayy-.js";import{r as ue,a as pe}from"../packem_shared/command-runtime-p4IXiIf6.js";let V;const z=e=>(V??=F(import.meta.url))(e),$=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,M=e=>{if(typeof $<"u"&&$.versions&&$.versions.node){const[t,s]=$.versions.node.split(".").map(Number);if(t>22||t===22&&s>=3||t===20&&s>=16)return $.getBuiltinModule(e)}return z(e)},{renameSync:q}=M("node:fs"),{stripVTControlCharacters:G}=M("node:util"),de=(e={})=>{const t=e.isCi??W;return(e.isTty??!!(process.stdin.isTTY&&process.stdout.isTTY))&&!t},k=U(B(),"dlx-seen.json"),H=(e,t)=>`${e}@${t}`,me=e=>{if(typeof e!="object"||e===null)return!1;const t=e;return Array.isArray(t.alertKeys)&&t.alertKeys.every(s=>typeof s=="string")&&typeof t.seenAt=="number"},P=()=>{try{if(te(k)){const e=se(k);if(e&&typeof e=="object"&&e.packages&&typeof e.packages=="object"&&e.version===1){const t={};for(const[s,r]of Object.entries(e.packages))me(r)&&(t[s]=r);return{packages:t,version:1}}}}catch{}return{packages:{},version:1}},he=e=>{try{re(B());const t=`${k}.${String(process.pid)}.tmp`;oe(t,JSON.stringify(e)),q(t,k)}catch{}},ge=(e,t,s)=>e.packages[H(t,s)],ye=(e,t)=>{if(!e)return!0;const s=new Set(Array.isArray(e.alertKeys)?e.alertKeys:[]);return t.some(r=>!s.has(r))},R=(e,t,s,r)=>{const o=P();o.packages[H(e,t)]={alertKeys:[...s].sort(),seenAt:r},he(o)},ve=/[\u0000-\u0008\u000B-\u001F\u007F]/g,K=e=>G(e).replaceAll(" "," ").replaceAll(ve,""),x=["CHANGELOG.md","CHANGELOG","changelog.md","CHANGES.md","HISTORY.md"],be=4e3,C=async(e,t,s)=>{if(t?.aborted)return;const r=new AbortController,o=setTimeout(()=>{r.abort()},be),a=()=>{r.abort()};t?.addEventListener("abort",a,{once:!0});try{const n=await fetch(e,{headers:s,signal:r.signal});return n.ok?await n.text():void 0}catch{return}finally{clearTimeout(o),t?.removeEventListener("abort",a)}},$e=e=>{const t=typeof e=="string"?e:e?.url;if(!t)return;const s=/github\.com[/:]([^/]+)\/([^/#]+?)(?:\.git)?(?:[/#]|$)/i.exec(t)??/^github:([^/]+)\/([^/#]+)/i.exec(t);return s?{directory:typeof e=="object"?e?.directory:void 0,owner:s[1],repo:s[2].replace(/\.git$/,"")}:void 0},O=(e,t)=>{const s=e.split(/\r?\n/),r=/^(#{1,4})\s+(.*)$/,o=t.replaceAll(/[$()*+.?[\\\]^{|}]/g,String.raw`\$&`),a=new RegExp(String.raw`(?<![\w.])${o}(?![\w.])`);let n=-1,u=0;for(const[c,l]of s.entries()){const f=r.exec(l);if(f&&a.test(f[2])){n=c,u=f[1].length;break}}if(n===-1)return;const i=[];for(let c=n+1;c<s.length;c+=1){const l=r.exec(s[c]);if(l&&l[1].length<=u)break;i.push(s[c])}return i},I=(e,t=4)=>e.map(r=>r.trim()).filter(r=>r.length>0).map(r=>K(r.replace(/^#{1,6}\s+/,"").replace(/^[*-]\s+/,"- ")).trim()).filter(r=>r.length>0&&!/^\[.*\]:/.test(r)).slice(0,t),L=(e,t)=>{if(!e)return"";const s=Date.parse(e);if(Number.isNaN(s))return"";const r=Math.floor((t-s)/(1440*60*1e3));if(r<=0)return"today";if(r===1)return"1d ago";if(r<30)return`${String(r)}d ago`;const o=Math.floor(r/30);return o<12?`${String(o)}mo ago`:`${String(Math.floor(o/12))}y ago`},N=(e,t,s)=>{const r=e.time??{},o=L(r[t],s),a=[o?`${e.name}@${t} — published ${o}`:`${e.name}@${t}`],n=Date.parse(r[t]??""),i=Object.entries(r).filter(([c])=>c!=="created"&&c!=="modified"&&c!==t).sort((c,l)=>Date.parse(l[1])-Date.parse(c[1])).filter(([,c])=>Date.parse(c)<n).slice(0,3);for(const[c,l]of i)a.push(`- ${c} (${L(l,s)})`);return{lines:a,source:"npm-diff",version:t}},Se=async e=>{const{name:t,now:s,offline:r,packument:o,signal:a,version:n}=e;if(r)return o?N(o,n,s):void 0;for(const c of x){const l=`https://cdn.jsdelivr.net/npm/${t}@${n}/${c}`,f=await C(l,a);if(f){const y=O(f,n),p=I(y??f.split(/\r?\n/));if(p.length>0)return{lines:p,source:"package-file",url:l,version:n}}}const u=o?.versions[n],i=$e(u?.repository);if(i){const c=i.directory?`${i.directory.replaceAll(/^\/+|\/+$/g,"")}/`:"";for(const l of["HEAD","main","master"])for(const f of x){const y=`https://raw.githubusercontent.com/${i.owner}/${i.repo}/${l}/${c}${f}`,p=await C(y,a);if(p){const m=O(p,n),h=I(m??p.split(/\r?\n/));if(h.length>0){const d=`https://github.com/${i.owner}/${i.repo}/blob/${l}/${c}${f}`;return{lines:h,source:"repo-file",url:d,version:n}}}}}if(o)return N(o,n,s)},we={dynamicRequire:"dynamic require",envVars:"env access",filesystemAccess:"filesystem",networkAccess:"network",shellAccess:"shell",telemetry:"telemetry",unsafe:"eval/unsafe",usesEval:"eval/unsafe"},ke=["preinstall","install","postinstall"],Te=(e,t)=>({fileCount:e?.dist?.fileCount,tarballBytes:t?.size,unpackedBytes:e?.dist?.unpackedSize}),Ee=(e,t)=>{const s=ke.filter(n=>!!e?.scripts?.[n]),r=e?.bin,o=typeof r=="string"?["(default)"]:Object.keys(r??{}).map(n=>K(n)),a=[...new Set(t.map(n=>we[n.type]).filter(n=>n!==void 0))];return{bins:o,capabilities:a,lifecycleScripts:s}},_e=(e,t,s)=>{const r=e.get(`${t}@${s}`);if(r)return r;for(const o of e.values())if(o.name===t&&o.version===s)return o},Ae=async e=>{const{name:t,now:s,offline:r,signal:o,socketToken:a,spec:n,workspaceRoot:u}=e;let i;try{i=await ne(t,{offline:r,signal:o,workspaceRoot:u})}catch{i=void 0}const c=i?ce(i,n):void 0;if(!c)return;const l=i?.versions[c],f=async()=>{if(!(r||!a))try{const g=await J([{name:t,version:c}],{apiToken:a,minimumScore:Q});return _e(g,t,c)}catch{return}},y=Se({name:t,now:s,offline:r,packument:i,signal:o,version:c}).catch(()=>{}),[p,m]=await Promise.all([f(),y]),h=p?.alerts??[],d=[...new Set(h.filter(g=>g.severity==="critical"||g.severity==="high").map(g=>g.key))].sort(),b=p?Math.round((p.score.overall??X(p.score))*100):void 0;return{changelog:m,name:t,permissions:Ee(l,h),security:{alerts:h,available:!!p,highSeverityKeys:d,score:b},size:Te(l,p),version:c}},w=e=>Z(G(e)),Re={critical:E,high:E,low:v,medium:S},D=e=>{if(!(e===void 0||e<0))return ee(e,{decimals:1,space:!0})},xe=e=>{const{fileCount:t,tarballBytes:s,unpackedBytes:r}=e.size,o=D(r),a=D(s);if(o&&a){const n=t===void 0?"":`, ${String(t)} files`;return`${o} unpacked (${a} tarball${n})`}if(o)return`${o} unpacked`;if(a)return`${a} tarball`},Ce=e=>{const{alerts:t,available:s,score:r}=e.security;if(!s)return v("unavailable — set VIS_SOCKET_TOKEN for a Socket.dev score");const o=r===void 0?v:r>=70?A:r>=40?S:E,a=r===void 0?"n/a":`${String(r)}/100`,n=new Map;for(const l of t)n.set(l.severity,(n.get(l.severity)??0)+1);const u=[],i=["critical","high","medium","low"];for(const l of i){const f=n.get(l);f&&u.push(Re[l](`${String(f)} ${l}`))}const c=u.length>0?` ${S("!")} ${u.join(", ")}`:` ${A("no alerts")}`;return`${o(a)} ${v("(Socket.dev)")}${c}`},Oe=e=>{const{bins:t,capabilities:s,lifecycleScripts:r}=e.permissions,o=[];for(const a of r)o.push(S(`${a} script`));for(const a of s)o.push(S(a));return t.length>0&&o.push(v(`bins: ${t.join(", ")}`)),o.length>0?o.join(v(" · ")):void 0},Ie=e=>{const t=[],s=xe(e);s&&t.push({label:"size",values:[s]}),t.push({label:"score",values:[Ce(e)]});const r=Oe(e);if(r&&t.push({label:"perms",values:[r]}),e.changelog){const o=e.changelog.source==="npm-diff"?"registry":e.changelog.source==="repo-file"?"repo CHANGELOG":"CHANGELOG";t.push({label:"latest",values:[...e.changelog.lines,v(`source: ${o}`)]})}return t},j=6,Le=e=>{const t=Ie(e),s=` first run: ${e.name}@${e.version} `,r=[];for(const i of t)i.values.forEach((c,l)=>{const f=l===0?ie(i.label.padEnd(j)):" ".repeat(j);r.push(`${f} ${c}`)});const o=Math.max(w(s),...r.map(i=>w(i))),a=i=>`${i}${" ".repeat(Math.max(0,o-w(i)))}`,n=`┌─${ae(s)}${"─".repeat(Math.max(0,o-w(s)))}─┐`,u=`└─${"─".repeat(o)}─┘`;return[n,...r.map(i=>`│ ${a(i)} │`),u]},Ne=e=>{if(e.startsWith("@")){const s=e.indexOf("@",1);return s===-1?{name:e}:{name:e.slice(0,s),spec:e.slice(s+1)}}const t=e.indexOf("@");return t<=0?{name:e}:{name:e.slice(0,t),spec:e.slice(t+1)}},De=e=>e===""||e.startsWith(".")||e.startsWith("/")||e.startsWith("~")?!1:!(e.startsWith("@")?e.slice(1):e).includes(":"),je=6e3,Me=e=>{process.stdout.write(e)},Be=async e=>{const{forceInfo:t=!1,noInfo:s=!1,offline:r=!1,pkg:o,socketToken:a,workspaceRoot:n,yes:u=!1}=e;if(s||!De(o))return{proceed:!0};const i=e.now??Date.now(),c=u||!de({isCi:e.isCi,isTty:e.isTty}),l=e.output??Me;if(c&&!t)return{proceed:!0};const{name:f,spec:y}=Ne(o),p=new AbortController;let m;const h=new Promise(T=>{m=setTimeout(()=>{p.abort(),T(void 0)},je)}),d=await Promise.race([Ae({name:f,now:i,offline:r,signal:p.signal,socketToken:a,spec:y,workspaceRoot:n}).catch(()=>{}),h]);if(m&&clearTimeout(m),!d)return{proceed:!0};const b=ge(P(),d.name,d.version);if(!t&&!ye(b,d.security.highSeverityKeys))return{proceed:!0};for(const T of Le(d))l(`${T}
2
- `);if(c)return R(d.name,d.version,d.security.highSeverityKeys,i),{proceed:!0};const g=await Y("? Ok to proceed? (y/N) ",e.readline);return g&&R(d.name,d.version,d.security.highSeverityKeys,i),{proceed:g}},Je=async({argument:e,logger:t,options:s,process:r,visConfig:o,workspaceRoot:a})=>{const n=e;if(!n||n.length===0)throw new Error("No package specified. Usage: vis dlx <package[@version]> [args...]");const[u,...i]=n,c=a??r.cwd,l=s.package?Array.isArray(s.package)?s.package:[s.package]:[],f=s.shellMode?l:[u,...l];for(const h of f){const d=!s.info||_(r.env.VIS_DLX_NO_INFO),b=!d&&s.info;if(!(await Be({forceInfo:b,noInfo:d,offline:s.offline||!1,pkg:h,socketToken:o?.security?.socket?.apiToken??r.env.VIS_SOCKET_TOKEN,workspaceRoot:c,yes:s.yes||_(r.env.VIS_DLX_YES)})).proceed){t.info("Aborted."),process.exitCode=1;return}}const y=ue({logger:t,options:s,visConfig:o},c),p=le(c,{backend:pe(y),configBackend:o?.install?.backend,configCorepack:o?.install?.corepack}),m=fe(p,{additionalPackages:l,args:i,package:u,shellMode:s.shellMode||!1,silent:s.silent||!1},c,t,{offline:s.offline||!1});m!==0&&(process.exitCode=m)};export{Je as default};
1
+ import{createRequire as F}from"node:module";import{i as W}from"../packem_shared/index-BjdW45xX.js";import{p as Y}from"../packem_shared/prompt-DMzaQEVa.js";import{e as U}from"../packem_shared/index-BzhrR_iC.js";import{l as B,m as X,n as J,D as Q,o as Z,z as ee,k as _}from"../packem_shared/formatBytes-_HvjOy8a-B_qQr4Hw.js";import{y as te}from"../packem_shared/isAccessibleSync-DYKTrrvc-C-_5cgwu.js";import{p as se}from"../packem_shared/readJsonSync-CbryXYxN-EWl7_7KX.js";import{h as re,U as oe}from"../packem_shared/writeFileSync-DJoHk3Ks-BPRoepNw.js";import{g as ne,r as ce}from"../packem_shared/packument-zb18Jnlw.js";import{q as ie,j as ae,F as v,b as S,X as E,J as A}from"../packem_shared/index.server-Ca_EEVfw.js";import{a as le,o as fe}from"../packem_shared/pm-runner-RM72mDZg.js";import{r as ue,a as pe}from"../packem_shared/command-runtime-HSsYGCQd.js";let z;const V=e=>(z??=F(import.meta.url))(e),$=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,M=e=>{if(typeof $<"u"&&$.versions&&$.versions.node){const[t,s]=$.versions.node.split(".").map(Number);if(t>22||t===22&&s>=3||t===20&&s>=16)return $.getBuiltinModule(e)}return V(e)},{renameSync:q}=M("node:fs"),{stripVTControlCharacters:G}=M("node:util"),de=(e={})=>{const t=e.isCi??W;return(e.isTty??!!(process.stdin.isTTY&&process.stdout.isTTY))&&!t},k=U(B(),"dlx-seen.json"),H=(e,t)=>`${e}@${t}`,me=e=>{if(typeof e!="object"||e===null)return!1;const t=e;return Array.isArray(t.alertKeys)&&t.alertKeys.every(s=>typeof s=="string")&&typeof t.seenAt=="number"},P=()=>{try{if(te(k)){const e=se(k);if(e&&typeof e=="object"&&e.packages&&typeof e.packages=="object"&&e.version===1){const t={};for(const[s,r]of Object.entries(e.packages))me(r)&&(t[s]=r);return{packages:t,version:1}}}}catch{}return{packages:{},version:1}},he=e=>{try{re(B());const t=`${k}.${String(process.pid)}.tmp`;oe(t,JSON.stringify(e)),q(t,k)}catch{}},ge=(e,t,s)=>e.packages[H(t,s)],ye=(e,t)=>{if(!e)return!0;const s=new Set(Array.isArray(e.alertKeys)?e.alertKeys:[]);return t.some(r=>!s.has(r))},R=(e,t,s,r)=>{const o=P();o.packages[H(e,t)]={alertKeys:[...s].sort(),seenAt:r},he(o)},ve=/[\u0000-\u0008\u000B-\u001F\u007F]/g,K=e=>G(e).replaceAll(" "," ").replaceAll(ve,""),x=["CHANGELOG.md","CHANGELOG","changelog.md","CHANGES.md","HISTORY.md"],be=4e3,C=async(e,t,s)=>{if(t?.aborted)return;const r=new AbortController,o=setTimeout(()=>{r.abort()},be),a=()=>{r.abort()};t?.addEventListener("abort",a,{once:!0});try{const n=await fetch(e,{headers:s,signal:r.signal});return n.ok?await n.text():void 0}catch{return}finally{clearTimeout(o),t?.removeEventListener("abort",a)}},$e=e=>{const t=typeof e=="string"?e:e?.url;if(!t)return;const s=/github\.com[/:]([^/]+)\/([^/#]+?)(?:\.git)?(?:[/#]|$)/i.exec(t)??/^github:([^/]+)\/([^/#]+)/i.exec(t);return s?{directory:typeof e=="object"?e?.directory:void 0,owner:s[1],repo:s[2].replace(/\.git$/,"")}:void 0},O=(e,t)=>{const s=e.split(/\r?\n/),r=/^(#{1,4})\s+(.*)$/,o=t.replaceAll(/[$()*+.?[\\\]^{|}]/g,String.raw`\$&`),a=new RegExp(String.raw`(?<![\w.])${o}(?![\w.])`);let n=-1,u=0;for(const[c,l]of s.entries()){const f=r.exec(l);if(f&&a.test(f[2])){n=c,u=f[1].length;break}}if(n===-1)return;const i=[];for(let c=n+1;c<s.length;c+=1){const l=r.exec(s[c]);if(l&&l[1].length<=u)break;i.push(s[c])}return i},I=(e,t=4)=>e.map(r=>r.trim()).filter(r=>r.length>0).map(r=>K(r.replace(/^#{1,6}\s+/,"").replace(/^[*-]\s+/,"- ")).trim()).filter(r=>r.length>0&&!/^\[.*\]:/.test(r)).slice(0,t),L=(e,t)=>{if(!e)return"";const s=Date.parse(e);if(Number.isNaN(s))return"";const r=Math.floor((t-s)/(1440*60*1e3));if(r<=0)return"today";if(r===1)return"1d ago";if(r<30)return`${String(r)}d ago`;const o=Math.floor(r/30);return o<12?`${String(o)}mo ago`:`${String(Math.floor(o/12))}y ago`},N=(e,t,s)=>{const r=e.time??{},o=L(r[t],s),a=[o?`${e.name}@${t} — published ${o}`:`${e.name}@${t}`],n=Date.parse(r[t]??""),i=Object.entries(r).filter(([c])=>c!=="created"&&c!=="modified"&&c!==t).sort((c,l)=>Date.parse(l[1])-Date.parse(c[1])).filter(([,c])=>Date.parse(c)<n).slice(0,3);for(const[c,l]of i)a.push(`- ${c} (${L(l,s)})`);return{lines:a,source:"npm-diff",version:t}},Se=async e=>{const{name:t,now:s,offline:r,packument:o,signal:a,version:n}=e;if(r)return o?N(o,n,s):void 0;for(const c of x){const l=`https://cdn.jsdelivr.net/npm/${t}@${n}/${c}`,f=await C(l,a);if(f){const y=O(f,n),p=I(y??f.split(/\r?\n/));if(p.length>0)return{lines:p,source:"package-file",url:l,version:n}}}const u=o?.versions[n],i=$e(u?.repository);if(i){const c=i.directory?`${i.directory.replaceAll(/^\/+|\/+$/g,"")}/`:"";for(const l of["HEAD","main","master"])for(const f of x){const y=`https://raw.githubusercontent.com/${i.owner}/${i.repo}/${l}/${c}${f}`,p=await C(y,a);if(p){const m=O(p,n),h=I(m??p.split(/\r?\n/));if(h.length>0){const d=`https://github.com/${i.owner}/${i.repo}/blob/${l}/${c}${f}`;return{lines:h,source:"repo-file",url:d,version:n}}}}}if(o)return N(o,n,s)},we={dynamicRequire:"dynamic require",envVars:"env access",filesystemAccess:"filesystem",networkAccess:"network",shellAccess:"shell",telemetry:"telemetry",unsafe:"eval/unsafe",usesEval:"eval/unsafe"},ke=["preinstall","install","postinstall"],Te=(e,t)=>({fileCount:e?.dist?.fileCount,tarballBytes:t?.size,unpackedBytes:e?.dist?.unpackedSize}),Ee=(e,t)=>{const s=ke.filter(n=>!!e?.scripts?.[n]),r=e?.bin,o=typeof r=="string"?["(default)"]:Object.keys(r??{}).map(n=>K(n)),a=[...new Set(t.map(n=>we[n.type]).filter(n=>n!==void 0))];return{bins:o,capabilities:a,lifecycleScripts:s}},_e=(e,t,s)=>{const r=e.get(`${t}@${s}`);if(r)return r;for(const o of e.values())if(o.name===t&&o.version===s)return o},Ae=async e=>{const{name:t,now:s,offline:r,signal:o,socketToken:a,spec:n,workspaceRoot:u}=e;let i;try{i=await ne(t,{offline:r,signal:o,workspaceRoot:u})}catch{i=void 0}const c=i?ce(i,n):void 0;if(!c)return;const l=i?.versions[c],f=async()=>{if(!(r||!a))try{const g=await J([{name:t,version:c}],{apiToken:a,minimumScore:Q});return _e(g,t,c)}catch{return}},y=Se({name:t,now:s,offline:r,packument:i,signal:o,version:c}).catch(()=>{}),[p,m]=await Promise.all([f(),y]),h=p?.alerts??[],d=[...new Set(h.filter(g=>g.severity==="critical"||g.severity==="high").map(g=>g.key))].sort(),b=p?Math.round((p.score.overall??X(p.score))*100):void 0;return{changelog:m,name:t,permissions:Ee(l,h),security:{alerts:h,available:!!p,highSeverityKeys:d,score:b},size:Te(l,p),version:c}},w=e=>Z(G(e)),Re={critical:E,high:E,low:v,medium:S},D=e=>{if(!(e===void 0||e<0))return ee(e,{decimals:1,space:!0})},xe=e=>{const{fileCount:t,tarballBytes:s,unpackedBytes:r}=e.size,o=D(r),a=D(s);if(o&&a){const n=t===void 0?"":`, ${String(t)} files`;return`${o} unpacked (${a} tarball${n})`}if(o)return`${o} unpacked`;if(a)return`${a} tarball`},Ce=e=>{const{alerts:t,available:s,score:r}=e.security;if(!s)return v("unavailable — set VIS_SOCKET_TOKEN for a Socket.dev score");const o=r===void 0?v:r>=70?A:r>=40?S:E,a=r===void 0?"n/a":`${String(r)}/100`,n=new Map;for(const l of t)n.set(l.severity,(n.get(l.severity)??0)+1);const u=[],i=["critical","high","medium","low"];for(const l of i){const f=n.get(l);f&&u.push(Re[l](`${String(f)} ${l}`))}const c=u.length>0?` ${S("!")} ${u.join(", ")}`:` ${A("no alerts")}`;return`${o(a)} ${v("(Socket.dev)")}${c}`},Oe=e=>{const{bins:t,capabilities:s,lifecycleScripts:r}=e.permissions,o=[];for(const a of r)o.push(S(`${a} script`));for(const a of s)o.push(S(a));return t.length>0&&o.push(v(`bins: ${t.join(", ")}`)),o.length>0?o.join(v(" · ")):void 0},Ie=e=>{const t=[],s=xe(e);s&&t.push({label:"size",values:[s]}),t.push({label:"score",values:[Ce(e)]});const r=Oe(e);if(r&&t.push({label:"perms",values:[r]}),e.changelog){const o=e.changelog.source==="npm-diff"?"registry":e.changelog.source==="repo-file"?"repo CHANGELOG":"CHANGELOG";t.push({label:"latest",values:[...e.changelog.lines,v(`source: ${o}`)]})}return t},j=6,Le=e=>{const t=Ie(e),s=` first run: ${e.name}@${e.version} `,r=[];for(const i of t)i.values.forEach((c,l)=>{const f=l===0?ie(i.label.padEnd(j)):" ".repeat(j);r.push(`${f} ${c}`)});const o=Math.max(w(s),...r.map(i=>w(i))),a=i=>`${i}${" ".repeat(Math.max(0,o-w(i)))}`,n=`┌─${ae(s)}${"─".repeat(Math.max(0,o-w(s)))}─┐`,u=`└─${"─".repeat(o)}─┘`;return[n,...r.map(i=>`│ ${a(i)} │`),u]},Ne=e=>{if(e.startsWith("@")){const s=e.indexOf("@",1);return s===-1?{name:e}:{name:e.slice(0,s),spec:e.slice(s+1)}}const t=e.indexOf("@");return t<=0?{name:e}:{name:e.slice(0,t),spec:e.slice(t+1)}},De=e=>e===""||e.startsWith(".")||e.startsWith("/")||e.startsWith("~")?!1:!(e.startsWith("@")?e.slice(1):e).includes(":"),je=6e3,Me=e=>{process.stdout.write(e)},Be=async e=>{const{forceInfo:t=!1,noInfo:s=!1,offline:r=!1,pkg:o,socketToken:a,workspaceRoot:n,yes:u=!1}=e;if(s||!De(o))return{proceed:!0};const i=e.now??Date.now(),c=u||!de({isCi:e.isCi,isTty:e.isTty}),l=e.output??Me;if(c&&!t)return{proceed:!0};const{name:f,spec:y}=Ne(o),p=new AbortController;let m;const h=new Promise(T=>{m=setTimeout(()=>{p.abort(),T(void 0)},je)}),d=await Promise.race([Ae({name:f,now:i,offline:r,signal:p.signal,socketToken:a,spec:y,workspaceRoot:n}).catch(()=>{}),h]);if(m&&clearTimeout(m),!d)return{proceed:!0};const b=ge(P(),d.name,d.version);if(!t&&!ye(b,d.security.highSeverityKeys))return{proceed:!0};for(const T of Le(d))l(`${T}
2
+ `);if(c)return R(d.name,d.version,d.security.highSeverityKeys,i),{proceed:!0};const g=await Y("? Ok to proceed? (y/N) ",e.readline);return g&&R(d.name,d.version,d.security.highSeverityKeys,i),{proceed:g}},Je=async({argument:e,logger:t,options:s,process:r,visConfig:o,workspaceRoot:a})=>{const n=e;if(!n||n.length===0)throw new Error("No package specified. Usage: vis dlx <package[@version]> [args...]");const[u,...i]=n,c=a??r.cwd,l=s.package?Array.isArray(s.package)?s.package:[s.package]:[],f=s.shellMode?l:[u,...l];for(const h of f){const d=!s.info||_(r.env.VIS_DLX_NO_INFO),b=!d&&s.info;if(!(await Be({forceInfo:b,noInfo:d,offline:s.offline||!1,pkg:h,socketToken:o?.security?.socket?.apiToken??r.env.VIS_SOCKET_TOKEN,workspaceRoot:c,yes:s.yes||_(r.env.VIS_DLX_YES)})).proceed){t.info("Aborted."),process.exitCode=1;return}}const y=ue({options:s,visConfig:o},c),p=le(c,{backend:pe(y),configBackend:o?.install?.backend,configCorepack:o?.install?.corepack}),m=fe(p,{additionalPackages:l,args:i,package:u,shellMode:s.shellMode||!1,silent:s.silent||!1},c,t,{offline:s.offline||!1});m!==0&&(process.exitCode=m)};export{Je as default};
@@ -1,15 +1,15 @@
1
- import{createRequire as be}from"node:module";import{F as $,b as L,X as ce,J,q as ae}from"../packem_shared/index.server-sXNQYpsl.js";import{v as T,a as G,U as I,z as Se,e as M}from"../packem_shared/index-BzhrR_iC.js";import{fingerprint as E,scan as le,scanFiles as Ee,inspectRuleset as Ie,listRules as K,listRequiredValidators as Te,scanGitHistory as Re}from"@visulima/secret-scanner";import{a4 as Ae,a5 as Q,p as y}from"./cli-main.js";import{I as je,W as Ne}from"../packem_shared/getRandomSpinner-4ZEcbTYv-DCyIuj19.js";import{U as Fe}from"../packem_shared/writeFileSync-DJoHk3Ks-BPRoepNw.js";import{y as X}from"../packem_shared/isAccessibleSync-DYKTrrvc-C-_5cgwu.js";import{p as Me}from"../packem_shared/readJsonSync-CbryXYxN-EWl7_7KX.js";let ve;const ke=e=>(ve??=be(import.meta.url))(e),j=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,W=e=>{if(typeof j<"u"&&j.versions&&j.versions.node){const[t,n]=j.versions.node.split(".").map(Number);if(t>22||t===22&&n>=3||t===20&&n>=16)return j.getBuiltinModule(e)}return ke(e)},{createRequire:Ce}=W("node:module"),{pathToFileURL:ue}=W("node:url"),{execFileSync:Le}=W("node:child_process");let Oe;const _e=e=>(Oe??=Ce(import.meta.url))(e),N=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,Be=e=>{if(typeof N<"u"&&N.versions&&N.versions.node){const[t,n]=N.versions.node.split(".").map(Number);if(t>22||t===22&&n>=3||t===20&&n>=16)return N.getBuiltinModule(e)}return _e(e)},{styleText:qe}=Be("node:util"),Ue={error:"✖",info:"ℹ",success:"✓",warning:"⚠"},De=()=>{const{env:e}=process;return!!e.CI||e.CONTINUOUS_INTEGRATION==="true"||"BUILD_NUMBER"in e||"RUN_ID"in e},Pe=/\u001B\[[\d;]*[a-z]/gi,He=e=>[...e.replaceAll(Pe,"")].length,ze=e=>{const t=[];return e.bold&&t.push("bold"),e.dim&&t.push("dim"),e.italic&&t.push("italic"),e.underline&&t.push("underline"),e.strikethrough&&t.push("strikethrough"),e.color&&t.push(e.color),e.bgColor&&t.push(e.bgColor),t.length===0?n=>n:n=>qe(t,n)};let Ve=class{#i=0;#l;#e=!1;#r="";#o="";#m=0;#u=0;#t;#n;#f="";#c;#p;#s;#x;#d=0;#a;#b;constructor(t={},n){if(t.frames)this.#c=t.frames;else{const s=t.name??"dots",r=Ne(s);if(!r)throw new Error(`Unknown spinner "${s}". Pass a custom \`frames\` set or use one of: ${je().join(", ")}.`);this.#c=r}this.#p=t.verbose!==!1,this.#r=t.prefixText??"",this.#t=n,this.#s=t.stream??process.stderr,this.#x=n?!0:this.#s.isTTY&&!De(),this.#b={...Ue,...t.icons},typeof t.style=="function"?this.#a=t.style:t.style&&(this.#a=ze(t.style))}get elapsedTime(){return this.#m===0?0:(this.#u||Date.now())-this.#m}get text(){return this.#o}set text(t){this.#o=t,this.#e&&this.#w()}get prefixText(){return this.#r}set prefixText(t){this.#r=t,this.#e&&this.#w()}get isRunning(){return this.#e}setInteractiveManager(t){this.#t=t}setMultiSpinner(t){this.#n=t}tick(){this.#e&&(this.#i=(this.#i+1)%this.#c.frames.length)}start(t,n){return this.#e?this:this.#p?(this.#e=!0,this.#m=Date.now(),this.#u=0,this.#i=0,this.#f="",t&&(this.#o=t),n?.prefixText&&(this.#r=n.prefixText),this.#n?(this.#n.renderAll(),this):(this.#t?(this.#t.hook(),this.#v(),this.#y()):(this.#k(),this.#y()),this)):this}stop(){if(this.#e){if(this.#h(),this.#e=!1,this.#u=Date.now(),this.#f="",this.#n){this.#n.renderAll();return}this.#t?(this.#t.erase("stdout"),this.#t.unhook(!1)):this.#$()}}stopAndPersist(t){if(!this.#e||(this.#h(),this.#e=!1,this.#u=Date.now(),!this.#p))return;const n=t?.prefixText??this.#r,s=t?.text??this.#o;let r=t?.symbol??"";n&&(r=r?`${n} ${r}`:n),s&&(r=r?`${r} ${s}`:s),this.#S(r)}succeed(t){this.#g("success",t)}failed(t){this.#g("error",t)}warn(t){this.#g("warning",t)}info(t){this.#g("info",t)}pause(){this.#h()}resume(){this.#e&&(this.#h(),this.#n||this.#y())}getFrameOutput(){if(!this.#e&&this.#f)return this.#f;const t=this.#c.frames[this.#i];let n=this.#a?this.#a(t):t;return this.#r&&(n=`${this.#r} ${n}`),this.#o&&(n=`${n} ${this.#o}`),n}#y(){this.#x&&(this.#l=setInterval(()=>{this.#e&&(this.#i=(this.#i+1)%this.#c.frames.length,this.#w())},this.#c.interval),this.#l.unref())}#h(){this.#l&&(clearInterval(this.#l),this.#l=void 0)}#w(){this.#n?this.#n.renderAll():this.#t?this.#v():this.#k()}#v(){this.#t&&this.#t.update("stdout",[this.getFrameOutput()])}#k(){const t=this.getFrameOutput();if(this.#$(),this.#s.isTTY){this.#s.write(t);const n=this.#s.columns||80;this.#d=Math.max(1,Math.ceil(He(t)/n))}else this.#s.write(`${t}
1
+ import{createRequire as be}from"node:module";import{F as $,b as L,X as ce,J as W,q as ae}from"../packem_shared/index.server-Ca_EEVfw.js";import{v as R,a as G,U as I,z as Se,e as M}from"../packem_shared/index-BzhrR_iC.js";import{fingerprint as E,scan as le,scanFiles as Ee,inspectRuleset as Ie,listRules as K,listRequiredValidators as Re,scanGitHistory as Te}from"@visulima/secret-scanner";import{a4 as Ae,a5 as Q,p as y}from"./cli-main.js";import{E as je,A as Ne}from"../packem_shared/getRandomSpinner-DX11qCB2-CoIsn7ZU.js";import{U as Fe}from"../packem_shared/writeFileSync-DJoHk3Ks-BPRoepNw.js";import{y as X}from"../packem_shared/isAccessibleSync-DYKTrrvc-C-_5cgwu.js";import{p as Me}from"../packem_shared/readJsonSync-CbryXYxN-EWl7_7KX.js";let ve;const ke=e=>(ve??=be(import.meta.url))(e),j=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,J=e=>{if(typeof j<"u"&&j.versions&&j.versions.node){const[t,n]=j.versions.node.split(".").map(Number);if(t>22||t===22&&n>=3||t===20&&n>=16)return j.getBuiltinModule(e)}return ke(e)},{createRequire:Ce}=J("node:module"),{pathToFileURL:ue}=J("node:url"),{execFileSync:Le}=J("node:child_process");let Oe;const _e=e=>(Oe??=Ce(import.meta.url))(e),N=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,Be=e=>{if(typeof N<"u"&&N.versions&&N.versions.node){const[t,n]=N.versions.node.split(".").map(Number);if(t>22||t===22&&n>=3||t===20&&n>=16)return N.getBuiltinModule(e)}return _e(e)},{styleText:qe}=Be("node:util"),Ue={error:"✖",info:"ℹ",success:"✓",warning:"⚠"},De=()=>{const{env:e}=process;return!!e.CI||e.CONTINUOUS_INTEGRATION==="true"||"BUILD_NUMBER"in e||"RUN_ID"in e},Pe=/\u001B\[[\d;]*[a-z]/gi,He=e=>[...e.replaceAll(Pe,"")].length,ze=e=>{const t=[];return e.bold&&t.push("bold"),e.dim&&t.push("dim"),e.italic&&t.push("italic"),e.underline&&t.push("underline"),e.strikethrough&&t.push("strikethrough"),e.color&&t.push(e.color),e.bgColor&&t.push(e.bgColor),t.length===0?n=>n:n=>qe(t,n)};let Ve=class{#i=0;#l;#e=!1;#r="";#o="";#m=0;#u=0;#t;#n;#f="";#c;#p;#s;#x;#d=0;#a;#b;constructor(t={},n){if(t.frames)this.#c=t.frames;else{const s=t.name??"dots",r=Ne(s);if(!r)throw new Error(`Unknown spinner "${s}". Pass a custom \`frames\` set or use one of: ${je().join(", ")}.`);this.#c=r}this.#p=t.verbose!==!1,this.#r=t.prefixText??"",this.#t=n,this.#s=t.stream??process.stderr,this.#x=n?!0:this.#s.isTTY&&!De(),this.#b={...Ue,...t.icons},typeof t.style=="function"?this.#a=t.style:t.style&&(this.#a=ze(t.style))}get elapsedTime(){return this.#m===0?0:(this.#u||Date.now())-this.#m}get text(){return this.#o}set text(t){this.#o=t,this.#e&&this.#w()}get prefixText(){return this.#r}set prefixText(t){this.#r=t,this.#e&&this.#w()}get isRunning(){return this.#e}setInteractiveManager(t){this.#t=t}setMultiSpinner(t){this.#n=t}tick(){this.#e&&(this.#i=(this.#i+1)%this.#c.frames.length)}start(t,n){return this.#e?this:this.#p?(this.#e=!0,this.#m=Date.now(),this.#u=0,this.#i=0,this.#f="",t&&(this.#o=t),n?.prefixText&&(this.#r=n.prefixText),this.#n?(this.#n.renderAll(),this):(this.#t?(this.#t.hook(),this.#v(),this.#y()):(this.#k(),this.#y()),this)):this}stop(){if(this.#e){if(this.#h(),this.#e=!1,this.#u=Date.now(),this.#f="",this.#n){this.#n.renderAll();return}this.#t?(this.#t.erase("stdout"),this.#t.unhook(!1)):this.#$()}}stopAndPersist(t){if(!this.#e||(this.#h(),this.#e=!1,this.#u=Date.now(),!this.#p))return;const n=t?.prefixText??this.#r,s=t?.text??this.#o;let r=t?.symbol??"";n&&(r=r?`${n} ${r}`:n),s&&(r=r?`${r} ${s}`:s),this.#S(r)}succeed(t){this.#g("success",t)}failed(t){this.#g("error",t)}warn(t){this.#g("warning",t)}info(t){this.#g("info",t)}pause(){this.#h()}resume(){this.#e&&(this.#h(),this.#n||this.#y())}getFrameOutput(){if(!this.#e&&this.#f)return this.#f;const t=this.#c.frames[this.#i];let n=this.#a?this.#a(t):t;return this.#r&&(n=`${this.#r} ${n}`),this.#o&&(n=`${n} ${this.#o}`),n}#y(){this.#x&&(this.#l=setInterval(()=>{this.#e&&(this.#i=(this.#i+1)%this.#c.frames.length,this.#w())},this.#c.interval),this.#l.unref())}#h(){this.#l&&(clearInterval(this.#l),this.#l=void 0)}#w(){this.#n?this.#n.renderAll():this.#t?this.#v():this.#k()}#v(){this.#t&&this.#t.update("stdout",[this.getFrameOutput()])}#k(){const t=this.getFrameOutput();if(this.#$(),this.#s.isTTY){this.#s.write(t);const n=this.#s.columns||80;this.#d=Math.max(1,Math.ceil(He(t)/n))}else this.#s.write(`${t}
2
2
  `),this.#d=0}#$(){if(this.#d>0&&this.#s.isTTY){for(let t=1;t<this.#d;t+=1)this.#s.write("\x1B[1A\x1B[2K");this.#s.write("\r\x1B[K")}this.#d=0}#S(t){this.#f=t,this.#n?this.#n.renderAll():this.#t?(this.#t.update("stdout",[t]),this.#t.unhook(!1)):(this.#$(),this.#s.write(`${t}
3
- `))}#g(t,n){if(!this.#e||(this.#h(),this.#e=!1,this.#u=Date.now(),!this.#p))return;let s="";const r=this.#b[t];r&&(s=this.#a?this.#a(r):r),this.#r&&(s=`${this.#r} ${s}`),n&&(s=`${s} ${n}`),this.#S(s)}};const We=(e,t,n)=>{const s=n.toLowerCase();e[s]??=new Map;const r=e[s].get(t);if(r!==void 0)return r;const{size:i}=e[s],c=`<${n.toUpperCase()}${i>0?String(i):""}>`;return e[s].set(t,c),c},Z=(e,t)=>{const{replacement:n,tag:s,text:r}=t;return typeof n=="function"?String(n(r,void 0)):typeof n=="string"?n:We(e,r,s)},Je=(e,t)=>{const n={};let s="",r=0;for(const i of e){const{start:c,text:o}=i;if(o==="")continue;if(Number.isInteger(c)&&c>=0&&t.slice(c,c+o.length)===o){if(c<r)continue;s+=t.slice(r,c)+Z(n,i),r=c+o.length;continue}let a=t.indexOf(o,r);if(a===-1)continue;const l=Z(n,i);for(;a!==-1;)s+=t.slice(r,a)+l,r=a+o.length,a=t.indexOf(o,r)}return s+t.slice(r)},Ge=e=>[...e.reduce((t,n)=>t.set(n.text+String(n.start)+n.tag,n),new Map).values()].toSorted((t,n)=>{const s=t.start-n.start;return s!==0?s:n.text.length-t.text.length}),Ke=(e,t)=>{const n=[];for(const s of e){const{key:r,pattern:i}=s,c=s.compiledPattern??new RegExp(i,"giu");c.lastIndex=0;let o;for(;(o=c.exec(t))!==null;){const a=s;n.push({replacement:a.userReplacement??a.replacement!==void 0?a.replacement:void 0,start:o.index,tag:r,text:o[0]}),o.index===c.lastIndex&&(c.lastIndex+=1)}}return n},Xe=(e,t,n,s)=>Ge([...Ke(n,e)]),fe=(e,t,n)=>{const s=[],r=[];for(const o of t)typeof o=="object"&&o.pattern&&s.push(o),r.push((typeof o=="object"?o.key:String(o)).toLowerCase());let i=e;const c=Xe(e,r,s);return i=Je(c,i),i},k=e=>{const t=typeof e;return e!==null&&(t==="object"||t==="function")},q=new Set(["__proto__","prototype","constructor"]),Ye=Math.max(...[...q].map(e=>e.length)),de=1e6,Qe=e=>e>="0"&&e<="9";function he(e){if(e==="0")return!0;if(/^[1-9]\d*$/.test(e)){const t=Number.parseInt(e,10);return t<=Number.MAX_SAFE_INTEGER&&t<=de}return!1}function D(e,t){return q.has(e)?!1:(e&&he(e)?t.push(Number.parseInt(e,10)):t.push(e),!0)}function Ze(e){if(typeof e!="string")throw new TypeError(`Expected a string, got ${typeof e}`);const t=[];let n="",s="",r=!1,i="start",c=!1,o=0;for(const a of e){if(o++,c){n+=a,c=!1;continue}if(a==="\\"){if(i==="index")throw new Error(`Invalid character '${a}' in an index at position ${o}`);if(i==="indexEnd")throw new Error(`Invalid character '${a}' after an index at position ${o}`);c=!0,i=i==="start"?"property":i;continue}switch(a){case".":{if(i==="index")throw new Error(`Invalid character '${a}' in an index at position ${o}`);if(i==="indexEnd"){i="property";break}if(!D(n,t))return[];n="",i="property";break}case"[":{if(i==="index")throw new Error(`Invalid character '${a}' in an index at position ${o}`);if(i==="indexEnd"){i="index";break}if(i==="property"&&n.length<=Ye&&q.has(n))return[];r=i==="property",i="index";break}case"]":{if(i==="indexEnd")throw new Error(`Invalid character '${a}' after an index at position ${o}`);if(i!=="index"){i==="start"&&(i="property"),n+=a;break}if(s===""){n+="[]",i="property";break}if((n!==""||r)&&!D(n,t))return[];n="",r=!1;const l=Number.parseInt(s,10),f=l<=de&&s===String(l);t.push(f?l:s),s="",i="indexEnd";break}default:{if(i==="index"){if(!Qe(a))throw new Error(`Invalid character '${a}' in an index at position ${o}`);s+=a;break}if(i==="indexEnd")throw new Error(`Invalid character '${a}' after an index at position ${o}`);i==="start"&&(i="property"),n+=a}}}switch(c&&(n+="\\"),i){case"property":{if(!D(n,t))return[];break}case"index":throw new Error("Index was not closed");case"start":{t.push("");break}}return t}function U(e){if(typeof e=="string")return Ze(e);if(Array.isArray(e)){const t=[];for(const[n,s]of e.entries()){if(typeof s!="string"&&typeof s!="number")throw new TypeError(`Expected a string or number for path segment at index ${n}, got ${typeof s}`);if(typeof s=="number"&&!Number.isFinite(s))throw new TypeError(`Path segment at index ${n} must be a finite number, got ${s}`);if(q.has(s))return[];typeof s=="string"&&he(s)?t.push(Number.parseInt(s,10)):t.push(s)}return t}return[]}function et(e,t,n){if(!k(e)||typeof t!="string"&&!Array.isArray(t))return e;const s=U(t);if(s.length===0)return n;for(let r=0;r<s.length;r++){const i=s[r];if(e=e[i],e==null){if(r!==s.length-1)return n;break}}return e===void 0?n:e}function tt(e,t,n){if(!k(e)||typeof t!="string"&&!Array.isArray(t))return e;const s=e,r=U(t);if(r.length===0)return e;for(let i=0;i<r.length;i++){const c=r[i];if(i===r.length-1){e[c]=n;continue}const o=e[c];if(k(o)){e=o;continue}const a=typeof r[i+1]=="number";e[c]=a?[]:{},e=e[c]}return s}function nt(e,t){if(!k(e)||typeof t!="string"&&!Array.isArray(t))return!1;const n=U(t);if(n.length===0)return!1;for(let s=0;s<n.length;s++){const r=n[s];if(s===n.length-1)return Object.hasOwn(e,r)?(delete e[r],!0):!1;const i=e[r];if(!k(i))return!1;e=i}}function ee(e,t){if(!k(e)||typeof t!="string"&&!Array.isArray(t))return!1;const n=U(t);if(n.length===0)return!1;for(const s of n){if(!k(e)||!(s in e))return!1;e=e[s]}return!0}const P="#;/?:@&",H=new RegExp(String.raw`([${P}][^${P}=\s]+=[^${P}=\s]*)`,"g"),st=e=>{const t=[];let n=0;H.lastIndex=0;let s=H.exec(e);for(;s!==null;){const{0:i,index:c}=s;t.push({key:void 0,value:e.slice(n,c+1)}),n=c+i.length,t.push({key:i.slice(1,i.indexOf("=")),value:i.slice(i.indexOf("=")+1)}),s=H.exec(e)}const r=e.slice(n);return r.length>0&&t.push({key:void 0,value:r}),t},te=(e,t)=>{for(let n=0;n<e.length;n+=1){let s=e[n].string,r=e[n].index;for(;r<t.length;){const i=t[r];if(!s.includes(i))break;const c=s.slice(1);for(e.push({index:r,string:c}),c.includes(i)||e.pop(),s=s.slice(s.indexOf(i)+i.length),r+=1;t[r]==="";)r+=1;if(r>=t.length){if(t.at(-1)!==""&&s.length>0)break;return!0}}}return!1},z=(e,t)=>{if(!t.includes("*"))return t===e;const n=t.split("*");let s=0,r=e;for(;n[s]==="";)if(s+=1,s===t.length)return!0;if(s===0&&!e.startsWith(n[0]))return!1;const i=[];for(;s<n.length;){const c=n[s];if(!r.includes(c))return te(i,n);const o=r.slice(1);for(i.push({index:s,string:o}),o.includes(c)||i.pop(),r=r.slice(r.indexOf(c)+c.length),s+=1;n[s]==="";)s+=1}return s>=n.length&&n.at(-1)!==""&&r.length>0?r===e?!1:te(i,n):!0},rt=/(?:http|https):\/\/?/,R=(e,t,n)=>typeof e.replacement=="function"?e.replacement(t,n):e.replacement,pe=(e,t,n)=>e.wildcard?z(t,e.key)||z(n,e.key):t===e.key||n===e.key,it=(e,t,n,s)=>{n.remove?delete e[t]:e[t]=R(n,e[t],s)},ne=(e,t,n,s,r,i)=>{const c=[],o=[];for(const l of s)!l.wildcard&&!l.deep&&ee(e,l.key)?o.push(l):c.push(l);const a=Object.keys(e);for(const l of a){if(!Object.hasOwn(e,l))continue;const f=l.toLowerCase(),u=i?`${i}.${f}`:f;let h;for(const g of c)pe(g,f,u)&&(h=g);h?it(e,l,h,u):e[l]=x(e[l],t,n,c,r,u)}for(const l of o)if(ee(e,l.key))if(l.remove)nt(e,l.key);else{const f=i?`${i}.${l.key}`:l.key;tt(e,l.key,R(l,et(e,l.key),f))}},se=(e,t)=>{const n=t.toLowerCase();return e.find(s=>s.key===n||!!s.wildcard&&z(n,s.key))},ot=(e,t,n)=>{const s=st(e),r=[];for(const i of s){const{key:c,value:o}=i;if(c===void 0){const a=se(t,o);r.push(a?String(R(a,o,void 0)):fe(o,t))}else{const a=se(t,c);a?r.push(`${c}=${String(R(a,o,void 0))}`):r.push(`${c}=${o}`)}}return r.join("")},x=(e,t,n,s,r,i)=>{if(e==null)return e;if(typeof e=="object"&&e.constructor===String)return x(String(e),t,n,s,r,i);if(typeof e=="object"&&t.has(e))return t.get(e);if(typeof e=="object"&&!Array.isArray(e)){if(e instanceof Error){const o=new Error(e.message);Object.defineProperties(o,{name:{configurable:!0,enumerable:!1,value:e.name,writable:!0},stack:{configurable:!0,enumerable:!1,value:e.stack,writable:!0}}),e.code!==void 0&&(o.code=e.code);const a=Object.keys(e);for(const l of a)o[l]=e[l];return n(e,o),ne(o,t,n,s,r,i),o}if(e instanceof Map){const o=new Map;n(e,o);const a=e.entries();let l=a.next();for(;!l.done;){const[f,u]=l.value;if(typeof f=="string"||typeof f=="object"&&f!==null&&f.constructor===String){const h=f.toLowerCase(),g=i?`${i}.${h}`:h;let p;for(const m of s)pe(m,h,g)&&(p=m);p?p.remove||o.set(f,R(p,u,g)):o.set(f,x(u,t,n,s,r,g))}else o.set(x(f,t,n,s,r),x(u,t,n,s,r));l=a.next()}return o}if(e instanceof Set){const o=new Set;n(e,o);const a=e.values();let l=a.next();for(;!l.done;)o.add(x(l.value,t,n,s,r,i)),l=a.next();return o}const c={...e};return n(e,c),ne(c,t,n,s,r,i),c}if(typeof e=="string"){const c=e;try{const o=JSON.parse(c);if(typeof o=="object"&&o!==null){const a=x(o,t,n,s,r,i);return JSON.stringify(a)}}catch{}return rt.test(c)?ot(c,s):fe(c,s)}if(Array.isArray(e)){const c=[];n(e,c);for(const[o,a]of e.entries()){const l=o.toString().toLowerCase(),f=i?`${i}.${l}`.toLowerCase():l,u=s.find(h=>h.key===l||h.key===f);u?c.push(R(u,a,f)):c.push(x(a,t,n,s,r,f))}return c}return e},ct=(e,t)=>{const n=[];for(const s of e)if(typeof s=="string"){const r=s.includes("*");n.push({deep:!1,key:s.toLowerCase(),replacement:`<${s.toUpperCase()}>`,userReplacement:!1,wildcard:r})}else if(typeof s=="number")n.push({deep:!1,key:s.toString(),replacement:"<REDACTED>"});else{const r=s.key.toLowerCase(),i={...s,key:r,replacement:s.replacement??`<${r.toUpperCase()}>`,userReplacement:s.replacement!==void 0,wildcard:r.includes("*")?!0:s.wildcard};if(i.pattern!==void 0){const c=i.pattern instanceof RegExp?i.pattern.source:i.pattern;i.compiledPattern=new RegExp(c,"giu")}n.push(i)}return n},at=(e,t,n)=>{if(e==null||typeof e=="number"||typeof e=="boolean")return e;const s=new WeakMap;return x(e,s,(r,i)=>{s.set(r,i)},t,n)},ge=(e,t,n)=>{const s=ct(t);return at(e,s,n)},Y=(e={})=>{const t=new Ae(new Q(process.stdout),new Q(process.stderr));return new Ve(e,t)},lt=(e,t)=>{if(!T(e))return e;const n=G(t,e);return n===""||n.startsWith("..")?e:n},A=(e,t)=>{const n=lt(e.file,t);return n===e.file?e:{...e,file:n}},me=e=>{if(!X(e))return[];try{const t=Me(e);return Array.isArray(t)?t:[]}catch{return[]}},ut=(e,t,n)=>{const s=me(t).map(o=>A(o,n)),r=new Set(s.map(o=>E(o))),i=e.map(o=>A(o,n)),c=new Set(i.map(o=>E(o)));return{fresh:i.filter(o=>!r.has(E(o))),resolved:s.filter(o=>!c.has(E(o))),surviving:i.filter(o=>r.has(E(o)))}},ye=(e,t,n,s={})=>{const r=e.map(c=>A(c,n));let i;if(s.replace)i=r;else{const c=me(t).map(a=>A(a,n)),o=new Set;i=[];for(const a of[...c,...r]){const l=E(a);o.has(l)||(o.add(l),i.push(a))}}return Fe(t,`${JSON.stringify(i,null,4)}
4
- `),i.length},re=1,ft=e=>{const t=new Map;for(const n of e){const s=t.get(n.file);s?s.push(n):t.set(n.file,[n])}return t},dt=e=>{try{return Se(e).split(/\r?\n/)}catch{return}},ht=(e,t,n)=>{const s=Math.max(1,t);return`${e.slice(0,s-1).replaceAll(/[^\t]/g," ")}${"^".repeat(Math.max(1,n))}`},pt=(e,t,n,s={})=>{if(e.length===0)return n?$("No secrets detected."):"No secrets detected.";const r=n?{cyan:ae,dim:$,green:J,red:ce,yellow:L}:{cyan:o=>o,dim:o=>o,green:o=>o,red:o=>o,yellow:o=>o},i=[],c=ft(e);for(const[o,a]of c){const l=G(t,o)||o;i.push(r.cyan(l));const f=s.redact?void 0:dt(o);for(const u of a){const h=[u.source,u.confidence].filter(Boolean).join(", "),g=h?` ${r.dim(`(${h})`)}`:"",p=u.alternateMatches&&u.alternateMatches.length>0?` ${r.dim(`also: ${u.alternateMatches.join(", ")}`)}`:"";let m="";switch(u.validation){case"error":{m=` ${r.yellow("! error")}`;break}case"rejected":{m=` ${r.red("✗ rejected")}`;break}case"skipped":{m=` ${r.dim("— unverifiable")}`;break}case"verified":{m=` ${r.green("✓ verified")}`;break}}if(i.push(` ${r.red("✖")} ${r.yellow(`[${u.ruleId}]`)}${g}${m} ${r.dim(`line ${String(u.startLine)}:${String(u.startColumn)}`)}${p}`),f){const C=Math.max(0,u.startLine-1-re),b=Math.min(f.length,u.startLine+re);for(let d=C;d<b;d+=1){const S=String(d+1).padStart(4," "),v=d+1===u.startLine,w=v?r.red("▶"):" ";if(i.push(` ${w} ${r.dim(S)} │ ${f[d]??""}`),v){const O=Math.max(1,(u.endColumn??u.startColumn+1)-u.startColumn),xe=ht(f[d]??"",u.startColumn,O);i.push(` ${r.dim(" │ ")}${r.red(xe)}`)}}}i.push("")}}return i.join(`
5
- `).trimEnd()},gt=(e,t,n={})=>{if(e.length===0)return t?$("No secrets detected in git history."):"No secrets detected in git history.";const s=t?{cyan:ae,dim:$,green:J,red:ce,yellow:L}:{cyan:c=>c,dim:c=>c,green:c=>c,red:c=>c,yellow:c=>c},r=new Map;for(const c of e){const o=r.get(c.commit.sha);o?o.push(c):r.set(c.commit.sha,[c])}const i=[];for(const[c,o]of r){const{authorName:a,date:l,message:f}=o[0].commit;i.push(`${s.yellow(c.slice(0,10))} ${f}`),i.push(` ${s.dim(`${a} · ${l}`)}`);for(const u of o){const h=[u.source,u.confidence].filter(Boolean).join(", "),g=h?` ${s.dim(`(${h})`)}`:"",p=n.redact?"":` ${s.dim(u.match)}`;i.push(` ${s.red("✖")} ${s.yellow(`[${u.ruleId}]`)}${g} ${s.cyan(u.file)} ${s.dim(`line ${String(u.startLine)}:${String(u.startColumn)}`)}${p}`)}i.push("")}return i.join(`
6
- `).trimEnd()},mt=(e,t)=>{if(!T(e))return e.replaceAll("\\","/");try{return ue(e).toString()}catch{return`file://${I(t,e).replaceAll("\\","/")}`}},yt=(e,t=100)=>e.length<=t?e:`${e.slice(0,t-1).trimEnd()}…`,we=(e,t,n=process.cwd(),s=[])=>{const r=new Map(s.map(a=>[a.id,a])),i=new Set;for(const a of e)i.add(a.ruleId);const c=[...new Set([...r.keys(),...i])].sort((a,l)=>a.localeCompare(l)),o=new Map(c.map((a,l)=>[a,l]));return JSON.stringify({$schema:"https://schemastore.azurewebsites.net/schemas/json/sarif-2.1.0.json",runs:[{originalUriBaseIds:{SRCROOT:{uri:ue(n).toString()}},results:e.map(a=>{const l={};return a.source&&(l.source=a.source),a.confidence&&(l.confidence=a.confidence),a.alternateMatches&&a.alternateMatches.length>0&&(l.alternateRules=a.alternateMatches),a.validation&&(l.validation=a.validation),{level:"error",locations:[{physicalLocation:{artifactLocation:{uri:mt(a.file,n),uriBaseId:T(a.file)?void 0:"SRCROOT"},region:{endColumn:a.endColumn,endLine:a.endLine,snippet:{text:a.match},startColumn:a.startColumn,startLine:a.startLine}}}],message:{text:a.description||a.ruleId},properties:Object.keys(l).length>0?l:void 0,ruleId:a.ruleId,ruleIndex:o.get(a.ruleId)??-1}}),tool:{driver:{informationUri:"https://visulima.com/packages/secret-scanner",name:"visulima-secret-scanner",rules:c.map(a=>{const l=r.get(a),f=l?.description??`Detected by rule \`${a}\``,u={};return l?.tags&&l.tags.length>0&&(u.tags=l.tags),l?.source&&(u.source=l.source),l?.confidence&&(u.confidence=l.confidence),{defaultConfiguration:{level:"error"},fullDescription:{text:f},helpUri:"https://visulima.com/packages/secret-scanner",id:a,name:a,properties:Object.keys(u).length>0?u:void 0,shortDescription:{text:yt(f)}}}),version:t}}}],version:"2.1.0"},void 0,2)},B=(e,t)=>{try{return Le("git",t,{cwd:e,encoding:"utf8",stdio:["ignore","pipe","pipe"]}).trim()}catch{return""}},V=e=>e.split(/\r?\n/).map(t=>t.trim()).filter(Boolean),wt=e=>V(B(e,["diff","--cached","--name-only","--diff-filter=ACMR"])).map(t=>T(t)?t:M(e,t)),ie=(e,t)=>{const n=B(e,["diff","--name-only","--diff-filter=ACMR",`${t}...HEAD`]),s=V(n);if(s.length===0){const r=B(e,["diff","--name-only","--diff-filter=ACMR",t]);return V(r).map(i=>T(i)?i:M(e,i))}return s.map(r=>T(r)?r:M(e,r))},_=e=>B(e,["rev-parse","--show-toplevel"]).length>0,F=".secrets-baseline.json",oe=e=>e?Array.isArray(e)?e:[e]:[],$e=e=>{const t=new Set(["json","sarif","text"]);if(e&&!t.has(e))throw new Error(`--format must be one of: ${[...t].join(", ")} (got "${e}")`);return e??"text"},$t=e=>{if(e===void 0)return;const t=new Set(["high","low","medium"]);if(!t.has(e))throw new Error(`--min-confidence must be one of: ${[...t].join(", ")} (got "${e}")`);return e},xt=async(e,t)=>{const n=await K(e);process.stdout.write(`${String(n.length)} rules loaded
3
+ `))}#g(t,n){if(!this.#e||(this.#h(),this.#e=!1,this.#u=Date.now(),!this.#p))return;let s="";const r=this.#b[t];r&&(s=this.#a?this.#a(r):r),this.#r&&(s=`${this.#r} ${s}`),n&&(s=`${s} ${n}`),this.#S(s)}};const Je=(e,t,n)=>{const s=n.toLowerCase();e[s]??=new Map;const r=e[s].get(t);if(r!==void 0)return r;const{size:i}=e[s],c=`<${n.toUpperCase()}${i>0?String(i):""}>`;return e[s].set(t,c),c},Z=(e,t)=>{const{replacement:n,tag:s,text:r}=t;return typeof n=="function"?String(n(r,void 0)):typeof n=="string"?n:Je(e,r,s)},We=(e,t)=>{const n={};let s="",r=0;for(const i of e){const{start:c,text:o}=i;if(o==="")continue;if(Number.isInteger(c)&&c>=0&&t.slice(c,c+o.length)===o){if(c<r)continue;s+=t.slice(r,c)+Z(n,i),r=c+o.length;continue}let a=t.indexOf(o,r);if(a===-1)continue;const l=Z(n,i);for(;a!==-1;)s+=t.slice(r,a)+l,r=a+o.length,a=t.indexOf(o,r)}return s+t.slice(r)},Ge=e=>[...e.reduce((t,n)=>t.set(n.text+String(n.start)+n.tag,n),new Map).values()].toSorted((t,n)=>{const s=t.start-n.start;return s!==0?s:n.text.length-t.text.length}),Ke=(e,t)=>{const n=[];for(const s of e){const{key:r,pattern:i}=s,c=s.compiledPattern??new RegExp(i,"giu");c.lastIndex=0;let o;for(;(o=c.exec(t))!==null;){const a=s;n.push({replacement:a.userReplacement??a.replacement!==void 0?a.replacement:void 0,start:o.index,tag:r,text:o[0]}),o.index===c.lastIndex&&(c.lastIndex+=1)}}return n},Xe=(e,t,n,s)=>Ge([...Ke(n,e)]),fe=(e,t,n)=>{const s=[],r=[];for(const o of t)typeof o=="object"&&o.pattern&&s.push(o),r.push((typeof o=="object"?o.key:String(o)).toLowerCase());let i=e;const c=Xe(e,r,s);return i=We(c,i),i},k=e=>{const t=typeof e;return e!==null&&(t==="object"||t==="function")},q=new Set(["__proto__","prototype","constructor"]),Ye=Math.max(...[...q].map(e=>e.length)),de=1e6,Qe=e=>e>="0"&&e<="9";function he(e){if(e==="0")return!0;if(/^[1-9]\d*$/.test(e)){const t=Number.parseInt(e,10);return t<=Number.MAX_SAFE_INTEGER&&t<=de}return!1}function D(e,t){return q.has(e)?!1:(e&&he(e)?t.push(Number.parseInt(e,10)):t.push(e),!0)}function Ze(e){if(typeof e!="string")throw new TypeError(`Expected a string, got ${typeof e}`);const t=[];let n="",s="",r=!1,i="start",c=!1,o=0;for(const a of e){if(o++,c){n+=a,c=!1;continue}if(a==="\\"){if(i==="index")throw new Error(`Invalid character '${a}' in an index at position ${o}`);if(i==="indexEnd")throw new Error(`Invalid character '${a}' after an index at position ${o}`);c=!0,i=i==="start"?"property":i;continue}switch(a){case".":{if(i==="index")throw new Error(`Invalid character '${a}' in an index at position ${o}`);if(i==="indexEnd"){i="property";break}if(!D(n,t))return[];n="",i="property";break}case"[":{if(i==="index")throw new Error(`Invalid character '${a}' in an index at position ${o}`);if(i==="indexEnd"){i="index";break}if(i==="property"&&n.length<=Ye&&q.has(n))return[];r=i==="property",i="index";break}case"]":{if(i==="indexEnd")throw new Error(`Invalid character '${a}' after an index at position ${o}`);if(i!=="index"){i==="start"&&(i="property"),n+=a;break}if(s===""){n+="[]",i="property";break}if((n!==""||r)&&!D(n,t))return[];n="",r=!1;const l=Number.parseInt(s,10),f=l<=de&&s===String(l);t.push(f?l:s),s="",i="indexEnd";break}default:{if(i==="index"){if(!Qe(a))throw new Error(`Invalid character '${a}' in an index at position ${o}`);s+=a;break}if(i==="indexEnd")throw new Error(`Invalid character '${a}' after an index at position ${o}`);i==="start"&&(i="property"),n+=a}}}switch(c&&(n+="\\"),i){case"property":{if(!D(n,t))return[];break}case"index":throw new Error("Index was not closed");case"start":{t.push("");break}}return t}function U(e){if(typeof e=="string")return Ze(e);if(Array.isArray(e)){const t=[];for(const[n,s]of e.entries()){if(typeof s!="string"&&typeof s!="number")throw new TypeError(`Expected a string or number for path segment at index ${n}, got ${typeof s}`);if(typeof s=="number"&&!Number.isFinite(s))throw new TypeError(`Path segment at index ${n} must be a finite number, got ${s}`);if(q.has(s))return[];typeof s=="string"&&he(s)?t.push(Number.parseInt(s,10)):t.push(s)}return t}return[]}function et(e,t,n){if(!k(e)||typeof t!="string"&&!Array.isArray(t))return e;const s=U(t);if(s.length===0)return n;for(let r=0;r<s.length;r++){const i=s[r];if(e=e[i],e==null){if(r!==s.length-1)return n;break}}return e===void 0?n:e}function tt(e,t,n){if(!k(e)||typeof t!="string"&&!Array.isArray(t))return e;const s=e,r=U(t);if(r.length===0)return e;for(let i=0;i<r.length;i++){const c=r[i];if(i===r.length-1){e[c]=n;continue}const o=e[c];if(k(o)){e=o;continue}const a=typeof r[i+1]=="number";e[c]=a?[]:{},e=e[c]}return s}function nt(e,t){if(!k(e)||typeof t!="string"&&!Array.isArray(t))return!1;const n=U(t);if(n.length===0)return!1;for(let s=0;s<n.length;s++){const r=n[s];if(s===n.length-1)return Object.hasOwn(e,r)?(delete e[r],!0):!1;const i=e[r];if(!k(i))return!1;e=i}}function ee(e,t){if(!k(e)||typeof t!="string"&&!Array.isArray(t))return!1;const n=U(t);if(n.length===0)return!1;for(const s of n){if(!k(e)||!(s in e))return!1;e=e[s]}return!0}const P="#;/?:@&",H=new RegExp(String.raw`([${P}][^${P}=\s]+=[^${P}=\s]*)`,"g"),st=e=>{const t=[];let n=0;H.lastIndex=0;let s=H.exec(e);for(;s!==null;){const{0:i,index:c}=s;t.push({key:void 0,value:e.slice(n,c+1)}),n=c+i.length,t.push({key:i.slice(1,i.indexOf("=")),value:i.slice(i.indexOf("=")+1)}),s=H.exec(e)}const r=e.slice(n);return r.length>0&&t.push({key:void 0,value:r}),t},te=(e,t)=>{for(let n=0;n<e.length;n+=1){let s=e[n].string,r=e[n].index;for(;r<t.length;){const i=t[r];if(!s.includes(i))break;const c=s.slice(1);for(e.push({index:r,string:c}),c.includes(i)||e.pop(),s=s.slice(s.indexOf(i)+i.length),r+=1;t[r]==="";)r+=1;if(r>=t.length){if(t.at(-1)!==""&&s.length>0)break;return!0}}}return!1},z=(e,t)=>{if(!t.includes("*"))return t===e;const n=t.split("*");let s=0,r=e;for(;n[s]==="";)if(s+=1,s===t.length)return!0;if(s===0&&!e.startsWith(n[0]))return!1;const i=[];for(;s<n.length;){const c=n[s];if(!r.includes(c))return te(i,n);const o=r.slice(1);for(i.push({index:s,string:o}),o.includes(c)||i.pop(),r=r.slice(r.indexOf(c)+c.length),s+=1;n[s]==="";)s+=1}return s>=n.length&&n.at(-1)!==""&&r.length>0?r===e?!1:te(i,n):!0},rt=/(?:http|https):\/\/?/,T=(e,t,n)=>typeof e.replacement=="function"?e.replacement(t,n):e.replacement,pe=(e,t,n)=>e.wildcard?z(t,e.key)||z(n,e.key):t===e.key||n===e.key,it=(e,t,n,s)=>{n.remove?delete e[t]:e[t]=T(n,e[t],s)},ne=(e,t,n,s,r,i)=>{const c=[],o=[];for(const l of s)!l.wildcard&&!l.deep&&ee(e,l.key)?o.push(l):c.push(l);const a=Object.keys(e);for(const l of a){if(!Object.hasOwn(e,l))continue;const f=l.toLowerCase(),u=i?`${i}.${f}`:f;let h;for(const g of c)pe(g,f,u)&&(h=g);h?it(e,l,h,u):e[l]=x(e[l],t,n,c,r,u)}for(const l of o)if(ee(e,l.key))if(l.remove)nt(e,l.key);else{const f=i?`${i}.${l.key}`:l.key;tt(e,l.key,T(l,et(e,l.key),f))}},se=(e,t)=>{const n=t.toLowerCase();return e.find(s=>s.key===n||!!s.wildcard&&z(n,s.key))},ot=(e,t,n)=>{const s=st(e),r=[];for(const i of s){const{key:c,value:o}=i;if(c===void 0){const a=se(t,o);r.push(a?String(T(a,o,void 0)):fe(o,t))}else{const a=se(t,c);a?r.push(`${c}=${String(T(a,o,void 0))}`):r.push(`${c}=${o}`)}}return r.join("")},x=(e,t,n,s,r,i)=>{if(e==null)return e;if(typeof e=="object"&&e.constructor===String)return x(String(e),t,n,s,r,i);if(typeof e=="object"&&t.has(e))return t.get(e);if(typeof e=="object"&&!Array.isArray(e)){if(e instanceof Error){const o=new Error(e.message);Object.defineProperties(o,{name:{configurable:!0,enumerable:!1,value:e.name,writable:!0},stack:{configurable:!0,enumerable:!1,value:e.stack,writable:!0}}),e.code!==void 0&&(o.code=e.code);const a=Object.keys(e);for(const l of a)o[l]=e[l];return n(e,o),ne(o,t,n,s,r,i),o}if(e instanceof Map){const o=new Map;n(e,o);const a=e.entries();let l=a.next();for(;!l.done;){const[f,u]=l.value;if(typeof f=="string"||typeof f=="object"&&f!==null&&f.constructor===String){const h=f.toLowerCase(),g=i?`${i}.${h}`:h;let p;for(const m of s)pe(m,h,g)&&(p=m);p?p.remove||o.set(f,T(p,u,g)):o.set(f,x(u,t,n,s,r,g))}else o.set(x(f,t,n,s,r),x(u,t,n,s,r));l=a.next()}return o}if(e instanceof Set){const o=new Set;n(e,o);const a=e.values();let l=a.next();for(;!l.done;)o.add(x(l.value,t,n,s,r,i)),l=a.next();return o}const c={...e};return n(e,c),ne(c,t,n,s,r,i),c}if(typeof e=="string"){const c=e;try{const o=JSON.parse(c);if(typeof o=="object"&&o!==null){const a=x(o,t,n,s,r,i);return JSON.stringify(a)}}catch{}return rt.test(c)?ot(c,s):fe(c,s)}if(Array.isArray(e)){const c=[];n(e,c);for(const[o,a]of e.entries()){const l=o.toString().toLowerCase(),f=i?`${i}.${l}`.toLowerCase():l,u=s.find(h=>h.key===l||h.key===f);u?c.push(T(u,a,f)):c.push(x(a,t,n,s,r,f))}return c}return e},ct=(e,t)=>{const n=[];for(const s of e)if(typeof s=="string"){const r=s.includes("*");n.push({deep:!1,key:s.toLowerCase(),replacement:`<${s.toUpperCase()}>`,userReplacement:!1,wildcard:r})}else if(typeof s=="number")n.push({deep:!1,key:s.toString(),replacement:"<REDACTED>"});else{const r=s.key.toLowerCase(),i={...s,key:r,replacement:s.replacement??`<${r.toUpperCase()}>`,userReplacement:s.replacement!==void 0,wildcard:r.includes("*")?!0:s.wildcard};if(i.pattern!==void 0){const c=i.pattern instanceof RegExp?i.pattern.source:i.pattern;i.compiledPattern=new RegExp(c,"giu")}n.push(i)}return n},at=(e,t,n)=>{if(e==null||typeof e=="number"||typeof e=="boolean")return e;const s=new WeakMap;return x(e,s,(r,i)=>{s.set(r,i)},t,n)},ge=(e,t,n)=>{const s=ct(t);return at(e,s,n)},Y=(e={})=>{const t=new Ae(new Q(process.stdout),new Q(process.stderr));return new Ve(e,t)},lt=(e,t)=>{if(!R(e))return e;const n=G(t,e);return n===""||n.startsWith("..")?e:n},A=(e,t)=>{const n=lt(e.file,t);return n===e.file?e:{...e,file:n}},me=e=>{if(!X(e))return[];try{const t=Me(e);return Array.isArray(t)?t:[]}catch{return[]}},ut=(e,t,n)=>{const s=me(t).map(o=>A(o,n)),r=new Set(s.map(o=>E(o))),i=e.map(o=>A(o,n)),c=new Set(i.map(o=>E(o)));return{fresh:i.filter(o=>!r.has(E(o))),resolved:s.filter(o=>!c.has(E(o))),surviving:i.filter(o=>r.has(E(o)))}},ye=(e,t,n,s={})=>{const r=e.map(c=>A(c,n));let i;if(s.replace)i=r;else{const c=me(t).map(a=>A(a,n)),o=new Set;i=[];for(const a of[...c,...r]){const l=E(a);o.has(l)||(o.add(l),i.push(a))}}return Fe(t,`${JSON.stringify(i,null,4)}
4
+ `),i.length},re=1,ft=e=>{const t=new Map;for(const n of e){const s=t.get(n.file);s?s.push(n):t.set(n.file,[n])}return t},dt=e=>{try{return Se(e).split(/\r?\n/)}catch{return}},ht=(e,t,n)=>{const s=Math.max(1,t);return`${e.slice(0,s-1).replaceAll(/[^\t]/g," ")}${"^".repeat(Math.max(1,n))}`},pt=(e,t,n,s={})=>{if(e.length===0)return n?$("No secrets detected."):"No secrets detected.";const r=n?{cyan:ae,dim:$,green:W,red:ce,yellow:L}:{cyan:o=>o,dim:o=>o,green:o=>o,red:o=>o,yellow:o=>o},i=[],c=ft(e);for(const[o,a]of c){const l=G(t,o)||o;i.push(r.cyan(l));const f=s.redact?void 0:dt(o);for(const u of a){const h=[u.source,u.confidence].filter(Boolean).join(", "),g=h?` ${r.dim(`(${h})`)}`:"",p=u.alternateMatches&&u.alternateMatches.length>0?` ${r.dim(`also: ${u.alternateMatches.join(", ")}`)}`:"";let m="";switch(u.validation){case"error":{m=` ${r.yellow("! error")}`;break}case"rejected":{m=` ${r.red("✗ rejected")}`;break}case"skipped":{m=` ${r.dim("— unverifiable")}`;break}case"verified":{m=` ${r.green("✓ verified")}`;break}}if(i.push(` ${r.red("✖")} ${r.yellow(`[${u.ruleId}]`)}${g}${m} ${r.dim(`line ${String(u.startLine)}:${String(u.startColumn)}`)}${p}`),f){const C=Math.max(0,u.startLine-1-re),b=Math.min(f.length,u.startLine+re);for(let d=C;d<b;d+=1){const S=String(d+1).padStart(4," "),v=d+1===u.startLine,w=v?r.red("▶"):" ";if(i.push(` ${w} ${r.dim(S)} │ ${f[d]??""}`),v){const O=Math.max(1,(u.endColumn??u.startColumn+1)-u.startColumn),xe=ht(f[d]??"",u.startColumn,O);i.push(` ${r.dim(" │ ")}${r.red(xe)}`)}}}i.push("")}}return i.join(`
5
+ `).trimEnd()},gt=(e,t,n={})=>{if(e.length===0)return t?$("No secrets detected in git history."):"No secrets detected in git history.";const s=t?{cyan:ae,dim:$,green:W,red:ce,yellow:L}:{cyan:c=>c,dim:c=>c,green:c=>c,red:c=>c,yellow:c=>c},r=new Map;for(const c of e){const o=r.get(c.commit.sha);o?o.push(c):r.set(c.commit.sha,[c])}const i=[];for(const[c,o]of r){const{authorName:a,date:l,message:f}=o[0].commit;i.push(`${s.yellow(c.slice(0,10))} ${f}`),i.push(` ${s.dim(`${a} · ${l}`)}`);for(const u of o){const h=[u.source,u.confidence].filter(Boolean).join(", "),g=h?` ${s.dim(`(${h})`)}`:"",p=n.redact?"":` ${s.dim(u.match)}`;i.push(` ${s.red("✖")} ${s.yellow(`[${u.ruleId}]`)}${g} ${s.cyan(u.file)} ${s.dim(`line ${String(u.startLine)}:${String(u.startColumn)}`)}${p}`)}i.push("")}return i.join(`
6
+ `).trimEnd()},mt=(e,t)=>{if(!R(e))return e.replaceAll("\\","/");try{return ue(e).toString()}catch{return`file://${I(t,e).replaceAll("\\","/")}`}},yt=(e,t=100)=>e.length<=t?e:`${e.slice(0,t-1).trimEnd()}…`,we=(e,t,n=process.cwd(),s=[])=>{const r=new Map(s.map(a=>[a.id,a])),i=new Set;for(const a of e)i.add(a.ruleId);const c=[...new Set([...r.keys(),...i])].sort((a,l)=>a.localeCompare(l)),o=new Map(c.map((a,l)=>[a,l]));return JSON.stringify({$schema:"https://schemastore.azurewebsites.net/schemas/json/sarif-2.1.0.json",runs:[{originalUriBaseIds:{SRCROOT:{uri:ue(n).toString()}},results:e.map(a=>{const l={};return a.source&&(l.source=a.source),a.confidence&&(l.confidence=a.confidence),a.alternateMatches&&a.alternateMatches.length>0&&(l.alternateRules=a.alternateMatches),a.validation&&(l.validation=a.validation),{level:"error",locations:[{physicalLocation:{artifactLocation:{uri:mt(a.file,n),uriBaseId:R(a.file)?void 0:"SRCROOT"},region:{endColumn:a.endColumn,endLine:a.endLine,snippet:{text:a.match},startColumn:a.startColumn,startLine:a.startLine}}}],message:{text:a.description||a.ruleId},properties:Object.keys(l).length>0?l:void 0,ruleId:a.ruleId,ruleIndex:o.get(a.ruleId)??-1}}),tool:{driver:{informationUri:"https://visulima.com/packages/secret-scanner",name:"visulima-secret-scanner",rules:c.map(a=>{const l=r.get(a),f=l?.description??`Detected by rule \`${a}\``,u={};return l?.tags&&l.tags.length>0&&(u.tags=l.tags),l?.source&&(u.source=l.source),l?.confidence&&(u.confidence=l.confidence),{defaultConfiguration:{level:"error"},fullDescription:{text:f},helpUri:"https://visulima.com/packages/secret-scanner",id:a,name:a,properties:Object.keys(u).length>0?u:void 0,shortDescription:{text:yt(f)}}}),version:t}}}],version:"2.1.0"},void 0,2)},B=(e,t)=>{try{return Le("git",t,{cwd:e,encoding:"utf8",stdio:["ignore","pipe","pipe"]}).trim()}catch{return""}},V=e=>e.split(/\r?\n/).map(t=>t.trim()).filter(Boolean),wt=e=>V(B(e,["diff","--cached","--name-only","--diff-filter=ACMR"])).map(t=>R(t)?t:M(e,t)),ie=(e,t)=>{const n=B(e,["diff","--name-only","--diff-filter=ACMR",`${t}...HEAD`]),s=V(n);if(s.length===0){const r=B(e,["diff","--name-only","--diff-filter=ACMR",t]);return V(r).map(i=>R(i)?i:M(e,i))}return s.map(r=>R(r)?r:M(e,r))},_=e=>B(e,["rev-parse","--show-toplevel"]).length>0,F=".secrets-baseline.json",oe=e=>e?Array.isArray(e)?e:[e]:[],$e=e=>{const t=new Set(["json","sarif","text"]);if(e&&!t.has(e))throw new Error(`--format must be one of: ${[...t].join(", ")} (got "${e}")`);return e??"text"},$t=e=>{if(e===void 0)return;const t=new Set(["high","low","medium"]);if(!t.has(e))throw new Error(`--min-confidence must be one of: ${[...t].join(", ")} (got "${e}")`);return e},xt=async(e,t)=>{const n=await K(e);process.stdout.write(`${String(n.length)} rules loaded
7
7
 
8
8
  `);for(const s of n){const r=t?L(s.id):s.id,i=s.tags.length>0?` ${t?$(`[${s.tags.join(", ")}]`):`[${s.tags.join(", ")}]`}`:"";if(process.stdout.write(`${r}${i}
9
9
  ${s.description}
10
10
  `),s.keywords.length>0){const c=`keywords: ${s.keywords.slice(0,6).join(", ")}${s.keywords.length>6?", ...":""}`;process.stdout.write(` ${t?$(c):c}
11
11
  `)}process.stdout.write(`
12
- `)}},bt=async(e,t)=>{const n=await Te(e);if(n.length===0){process.stdout.write(t?`${$("No non-HTTP validators required by the current ruleset.")}
12
+ `)}},bt=async(e,t)=>{const n=await Re(e);if(n.length===0){process.stdout.write(t?`${$("No non-HTTP validators required by the current ruleset.")}
13
13
  `:`No non-HTTP validators required by the current ruleset.
14
14
  `);return}process.stdout.write(`${String(n.length)} non-HTTP validator type(s) referenced by the current ruleset:
15
15
 
@@ -17,12 +17,12 @@ import{createRequire as be}from"node:module";import{F as $,b as L,X as ce,J,q as
17
17
  `),process.stdout.write(` ${s.summary}
18
18
  `);const c=s.packageName?`install: npm add ${s.packageName}`:"no driver — bespoke implementation required";process.stdout.write(` ${t?$(c):c}
19
19
 
20
- `)}},vt=async(e,t,n)=>{const s=M(e,F);if(!n&&X(s)){y.warn(`Detected existing ${F} — refusing to overwrite. Delete it first to re-init.`),process.exitCode=1;return}y.info(n?"[dry-run] Previewing init — no files will be written.":"Scanning workspace to seed baseline…");const r=Y();r.start("scanning");let i;try{i=await le([e],t),r.succeed()}catch(o){throw r.failed(),o}if(n){y.info(`[dry-run] Would create ${F} with ${String(i.length)} finding(s).`);return}const c=ye(i,s,e,{replace:!0});y.success(`Wrote ${F} (${String(c)} findings).`),y.notice("Commit it. Use `vis secrets --baseline .secrets-baseline.json` in CI. Add path patterns to .gitignore to exclude directories from scanning.")},kt=(e,t,n)=>{const s=t??{},r=d=>d?I(n,d):void 0,i=(d,S)=>{const v=oe(d);return v.length>0?v:S},c=(s.config?.presets??[]).map(d=>`tag:preset:${d}`),o=i(e.enableRule,s.rules?.enable)??[],a=[...o,...c.filter(d=>!o.includes(d))],l=a.length>0?a:void 0,f=i(e.excludeRule,s.rules?.exclude),u=i(e.includeRule,s.rules?.include),h=i(e.exclude,s.walk?.excludePatterns),g=oe(e.excludeFrom).map(d=>I(n,d)),p=g.length>0?g:s.walk?.excludeFromFiles?.map(d=>I(n,d)),m=r(e.baseline)??r(s.baseline),C=r(e.config)??r(s.config?.path),b=$t(e.minConfidence??s.config?.minConfidence);return{baseline:m,concurrency:e.concurrency,config:{extendBundled:e.extendBundled===!1?!1:s.config?.extendBundled,inline:s.config?.inline,minConfidence:b,onlyVerified:e.onlyVerified??s.config?.onlyVerified??!1,path:C,validate:e.validate??s.config?.validate??!1},redact:e.redact??s.redact,rules:{enable:l,exclude:f,include:u},verbose:e.verbose??!1,walk:{excludeFromFiles:p,excludePatterns:h,gitignore:e.gitignore===!1?!1:s.walk?.gitignore??!0,includeHidden:e.includeHidden??s.walk?.includeHidden,maxFileSize:e.maxSize??s.walk?.maxFileSize}}},St=e=>{process.stderr.write(`${$("baseline diff: ")}${J(`+${String(e.fresh.length)} new`)} · ${L(`${String(e.surviving.length)} unchanged`)} · ${$(`-${String(e.resolved.length)} resolved`)}
20
+ `)}},vt=async(e,t,n)=>{const s=M(e,F);if(!n&&X(s)){y.warn(`Detected existing ${F} — refusing to overwrite. Delete it first to re-init.`),process.exitCode=1;return}y.info(n?"[dry-run] Previewing init — no files will be written.":"Scanning workspace to seed baseline…");const r=Y();r.start("scanning");let i;try{i=await le([e],t),r.succeed()}catch(o){throw r.failed(),o}if(n){y.info(`[dry-run] Would create ${F} with ${String(i.length)} finding(s).`);return}const c=ye(i,s,e,{replace:!0});y.success(`Wrote ${F} (${String(c)} findings).`),y.notice("Commit it. Use `vis secrets --baseline .secrets-baseline.json` in CI. Add path patterns to .gitignore to exclude directories from scanning.")},kt=(e,t,n)=>{const s=t??{},r=d=>d?I(n,d):void 0,i=(d,S)=>{const v=oe(d);return v.length>0?v:S},c=(s.config?.presets??[]).map(d=>`tag:preset:${d}`),o=i(e.enableRule,s.rules?.enable)??[],a=[...o,...c.filter(d=>!o.includes(d))],l=a.length>0?a:void 0,f=i(e.excludeRule,s.rules?.exclude),u=i(e.includeRule,s.rules?.include),h=i(e.exclude,s.walk?.excludePatterns),g=oe(e.excludeFrom).map(d=>I(n,d)),p=g.length>0?g:s.walk?.excludeFromFiles?.map(d=>I(n,d)),m=r(e.baseline)??r(s.baseline),C=r(e.config)??r(s.config?.path),b=$t(e.minConfidence??s.config?.minConfidence);return{baseline:m,concurrency:e.concurrency,config:{extendBundled:e.extendBundled===!1?!1:s.config?.extendBundled,inline:s.config?.inline,minConfidence:b,onlyVerified:e.onlyVerified??s.config?.onlyVerified??!1,path:C,validate:e.validate??s.config?.validate??!1},redact:e.redact??s.redact,rules:{enable:l,exclude:f,include:u},verbose:e.verbose??!1,walk:{excludeFromFiles:p,excludePatterns:h,gitignore:e.gitignore===!1?!1:s.walk?.gitignore??!0,includeHidden:e.includeHidden??s.walk?.includeHidden,maxFileSize:e.maxSize??s.walk?.maxFileSize}}},St=e=>{process.stderr.write(`${$("baseline diff: ")}${W(`+${String(e.fresh.length)} new`)} · ${L(`${String(e.surviving.length)} unchanged`)} · ${$(`-${String(e.resolved.length)} resolved`)}
21
21
  `)},Et=async(e,t,n)=>{if(e.staged){if(!_(n))throw new Error("--staged requires a git working tree, and none was detected.");return{files:wt(n)}}if(e.since){if(!_(n))throw new Error("--since requires a git working tree, and none was detected.");return{files:ie(n,e.since)}}if(e.affected){if(!_(n))return y.warn("--affected requires git; falling back to full scan"),{paths:t&&t.length>0?t.map(r=>I(n,r)):[n]};const s=process.env.VIS_BASE??"HEAD~1";return{files:ie(n,s)}}return{paths:t&&t.length>0?t.map(s=>I(n,s)):[n]}},It=(e,t,n,s,r,i,c)=>{switch(t){case"json":{const o=e.map(a=>A(a,n));process.stdout.write(`${JSON.stringify(o,null,2)}
22
22
  `);break}case"sarif":{process.stdout.write(`${we(e,r,n,i)}
23
23
  `);break}default:process.stdout.write(`${pt(e,n,s,{redact:c})}
24
- `)}},Tt=async(e,t,n,s,r)=>{if(e.staged||e.since||e.affected)throw new Error("--history scans commit history and can't be combined with --staged / --since / --affected (those scan the working tree).");if(!_(t))throw new Error("--history requires a git working tree, and none was detected.");const i=$e(e.format),c=!e.quiet&&i==="text",o=Y({verbose:c});o.start("scanning git history for secrets");let a;try{a=await Re({...n,cwd:t,maxCommits:e.maxCommits,range:e.historyRange}),o.succeed()}catch(u){throw o.failed(),new Error(`git-history secret scan failed: ${u instanceof Error?u.message:String(u)}`,{cause:u})}const l=n.redact===!0,f=l?ge(a,["match","secret"]):a;switch(i){case"json":{process.stdout.write(`${JSON.stringify(f.map(u=>A(u,t)),null,2)}
24
+ `)}},Rt=async(e,t,n,s,r)=>{if(e.staged||e.since||e.affected)throw new Error("--history scans commit history and can't be combined with --staged / --since / --affected (those scan the working tree).");if(!_(t))throw new Error("--history requires a git working tree, and none was detected.");const i=$e(e.format),c=!e.quiet&&i==="text",o=Y({verbose:c});o.start("scanning git history for secrets");let a;try{a=await Te({...n,cwd:t,maxCommits:e.maxCommits,range:e.historyRange}),o.succeed()}catch(u){throw o.failed(),new Error(`git-history secret scan failed: ${u instanceof Error?u.message:String(u)}`,{cause:u})}const l=n.redact===!0,f=l?ge(a,["match","secret"]):a;switch(i){case"json":{process.stdout.write(`${JSON.stringify(f.map(u=>A(u,t)),null,2)}
25
25
  `);break}case"sarif":{const u=await K(n).catch(()=>[]);process.stdout.write(`${we(f,r,t,u)}
26
26
  `);break}default:process.stdout.write(`${gt(f,s,{redact:l})}
27
- `)}if(a.length>0){e.quiet||(y.warn(`${String(a.length)} potential secret(s) found across git history`),y.notice("Findings reference the commit that introduced them — rotate the credential and rewrite history (e.g. git filter-repo) if it is still reachable.")),process.exitCode=1;return}e.quiet||y.success("No secrets detected in git history.")},Bt=async({argument:e,options:t,visConfig:n,workspaceRoot:s})=>{const r=t,i=e,c=s??process.cwd(),o=!r.quiet&&process.stdout.isTTY,a=n?.secrets,l=kt(r,a,c),f="0.0.0-alpha";if(r.listRules){await xt(l,o);return}if(r.listValidators){await bt(l,o);return}if(r.init){await vt(c,l,r.dryRun??!1);return}if(r.history){await Tt(r,c,l,o,f);return}const u=await Et(r,i??[],c);if(u.files?.length===0){r.quiet||y.success("No files to scan.");return}const h=!r.quiet&&!["json","sarif"].includes(r.format??"text"),g=Y({verbose:h});g.start("scanning for secrets");let p;try{p=u.files===void 0?await le(u.paths??[c],l):await Ee(u.files,l),g.succeed()}catch(w){throw g.failed(),new Error(`secret scan failed: ${w instanceof Error?w.message:String(w)}`,{cause:w})}if(r.verbose){const w=await Ie(l);if(w.length>0){y.warn(`${String(w.length)} rule(s) skipped due to invalid regex. First few:`);for(const O of w.slice(0,5))process.stderr.write(` - ${O.ruleId}: ${O.reason}
27
+ `)}if(a.length>0){e.quiet||(y.warn(`${String(a.length)} potential secret(s) found across git history`),y.notice("Findings reference the commit that introduced them — rotate the credential and rewrite history (e.g. git filter-repo) if it is still reachable.")),process.exitCode=1;return}e.quiet||y.success("No secrets detected in git history.")},Bt=async({argument:e,options:t,visConfig:n,workspaceRoot:s})=>{const r=t,i=e,c=s??process.cwd(),o=!r.quiet&&process.stdout.isTTY,a=n?.secrets,l=kt(r,a,c),f="0.0.0-alpha";if(r.listRules){await xt(l,o);return}if(r.listValidators){await bt(l,o);return}if(r.init){await vt(c,l,r.dryRun??!1);return}if(r.history){await Rt(r,c,l,o,f);return}const u=await Et(r,i??[],c);if(u.files?.length===0){r.quiet||y.success("No files to scan.");return}const h=!r.quiet&&!["json","sarif"].includes(r.format??"text"),g=Y({verbose:h});g.start("scanning for secrets");let p;try{p=u.files===void 0?await le(u.paths??[c],l):await Ee(u.files,l),g.succeed()}catch(w){throw g.failed(),new Error(`secret scan failed: ${w instanceof Error?w.message:String(w)}`,{cause:w})}if(r.verbose){const w=await Ie(l);if(w.length>0){y.warn(`${String(w.length)} rule(s) skipped due to invalid regex. First few:`);for(const O of w.slice(0,5))process.stderr.write(` - ${O.ruleId}: ${O.reason}
28
28
  `)}}const m=typeof l.baseline=="string"?l.baseline:M(c,F),C=!r.quiet&&X(m);if(r.updateBaseline){const w=ye(p,m,c,{replace:r.replaceBaseline});y.success(`Baseline updated: ${G(c,m)||m} now contains ${String(w)} entries.`);return}const b=$e(r.format),d=b==="sarif"?await K(l).catch(()=>[]):[],S=l.redact===!0,v=S?ge(p,["match","secret"]):p;if(It(v,b,c,o,f,d,S),b==="text"&&C&&St(ut(p,m,c)),p.length>0){r.quiet||(y.warn(`${String(p.length)} potential secret(s) found`),y.notice("Suppress individual lines with `gitleaks:allow` / `secret-scanner:allow`, or run `vis secrets --update-baseline`.")),process.exitCode=1;return}r.quiet||y.success("No secrets detected.")};export{Bt as default,kt as resolveScanOptions};
@@ -1,4 +1,4 @@
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-sXNQYpsl.js";import{e as I,z as se,a as $}from"../packem_shared/index-BzhrR_iC.js";import U from"./index.js";import{y as _}from"../packem_shared/isAccessibleSync-DYKTrrvc-C-_5cgwu.js";import{$ as oe,_ as F,v as ne,a6 as ae,a7 as ie,a8 as re,a9 as ce}from"./cli-main.js";import{k as pe,l as z,E as W,p as L,N as K,a as fe}from"./catalog.js";import{p as S}from"../packem_shared/readJsonSync-CbryXYxN-EWl7_7KX.js";import{U as le}from"../packem_shared/writeFileSync-DJoHk3Ks-BPRoepNw.js";import{T as j}from"../packem_shared/target-merge-DVJl-7Qz.js";import{l as ue}from"../packem_shared/missing-package-json-Cu5YVAot.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=>U(s,a)),G=(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&&G(s,e))return{pattern:e.depName,rule:s};for(const[t,r]of Object.entries(a))if(de(t)&&U(t,e.depName)&&G(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
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-BzhrR_iC.js";import U from"./index.js";import{y as _}from"../packem_shared/isAccessibleSync-DYKTrrvc-C-_5cgwu.js";import{$ as oe,_ as F,v as ne,a6 as ae,a7 as ie,a8 as re,a9 as ce}from"./cli-main.js";import{k as pe,l as z,E as W,p as L,N as K,a as fe}from"./catalog.js";import{p as S}from"../packem_shared/readJsonSync-CbryXYxN-EWl7_7KX.js";import{U as le}from"../packem_shared/writeFileSync-DJoHk3Ks-BPRoepNw.js";import{T as j}from"../packem_shared/target-merge-DVJl-7Qz.js";import{l as ue}from"../packem_shared/missing-package-json-Cu5YVAot.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=>U(s,a)),G=(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&&G(s,e))return{pattern:e.depName,rule:s};for(const[t,r]of Object.entries(a))if(de(t)&&U(t,e.depName)&&G(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
2
  `)?`\r
3
3
  `:`
4
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