@visulima/vis 2.0.2 → 3.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (147) hide show
  1. package/CHANGELOG.md +20 -0
  2. package/LICENSE.md +95 -65
  3. package/dist/bin.js +1 -1
  4. package/dist/binx.js +1 -1
  5. package/dist/packem_chunks/CONFIG_FILES.js +2 -2
  6. package/dist/packem_chunks/bloom-status.js +1 -1
  7. package/dist/packem_chunks/bloom-sync.js +1 -1
  8. package/dist/packem_chunks/catalog.js +47 -47
  9. package/dist/packem_chunks/cli-exec.js +1 -1
  10. package/dist/packem_chunks/cli-main.js +141 -141
  11. package/dist/packem_chunks/dispatch.js +1 -1
  12. package/dist/packem_chunks/fix.js +1 -1
  13. package/dist/packem_chunks/handler.js +1 -1
  14. package/dist/packem_chunks/handler10.js +1 -1
  15. package/dist/packem_chunks/handler11.js +1 -1
  16. package/dist/packem_chunks/handler12.js +1 -1
  17. package/dist/packem_chunks/handler13.js +1 -1
  18. package/dist/packem_chunks/handler14.js +1 -1
  19. package/dist/packem_chunks/handler15.js +1 -1
  20. package/dist/packem_chunks/handler16.js +1 -1
  21. package/dist/packem_chunks/handler17.js +1 -1
  22. package/dist/packem_chunks/handler18.js +1 -1
  23. package/dist/packem_chunks/handler19.js +1 -1
  24. package/dist/packem_chunks/handler2.js +1 -1
  25. package/dist/packem_chunks/handler20.js +1 -1
  26. package/dist/packem_chunks/handler21.js +1 -1
  27. package/dist/packem_chunks/handler22.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 +1 -1
  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/handler4.js +1 -1
  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/handler55.js +1 -1
  43. package/dist/packem_chunks/handler58.js +1 -1
  44. package/dist/packem_chunks/handler59.js +1 -1
  45. package/dist/packem_chunks/handler6.js +1 -1
  46. package/dist/packem_chunks/handler60.js +1 -1
  47. package/dist/packem_chunks/handler61.js +1 -1
  48. package/dist/packem_chunks/handler62.js +1 -1
  49. package/dist/packem_chunks/handler63.js +1 -1
  50. package/dist/packem_chunks/handler64.js +1 -1
  51. package/dist/packem_chunks/handler66.js +1 -1
  52. package/dist/packem_chunks/handler67.js +13 -13
  53. package/dist/packem_chunks/handler68.js +1 -1
  54. package/dist/packem_chunks/handler69.js +1 -1
  55. package/dist/packem_chunks/handler7.js +1 -1
  56. package/dist/packem_chunks/handler70.js +5 -5
  57. package/dist/packem_chunks/handler71.js +1 -1
  58. package/dist/packem_chunks/handler72.js +1 -1
  59. package/dist/packem_chunks/handler73.js +1 -1
  60. package/dist/packem_chunks/handler74.js +15 -15
  61. package/dist/packem_chunks/handler75.js +1 -1
  62. package/dist/packem_chunks/handler76.js +1 -1
  63. package/dist/packem_chunks/handler77.js +1 -1
  64. package/dist/packem_chunks/handler78.js +1 -1
  65. package/dist/packem_chunks/handler8.js +1 -1
  66. package/dist/packem_chunks/handler9.js +1 -1
  67. package/dist/packem_chunks/heal-accept.js +1 -1
  68. package/dist/packem_chunks/heal.js +1 -1
  69. package/dist/packem_chunks/help-command.js +1 -1
  70. package/dist/packem_chunks/index2.js +6 -4
  71. package/dist/packem_chunks/index3.js +1 -1
  72. package/dist/packem_chunks/index4.js +49 -49
  73. package/dist/packem_chunks/keys-refresh.js +1 -1
  74. package/dist/packem_chunks/lean.js +1 -1
  75. package/dist/packem_chunks/list.js +1 -1
  76. package/dist/packem_chunks/loader.js +1 -1
  77. package/dist/packem_chunks/orchestrator.js +2 -2
  78. package/dist/packem_chunks/prune.js +1 -1
  79. package/dist/packem_chunks/registry.js +10 -10
  80. package/dist/packem_chunks/status.js +1 -1
  81. package/dist/packem_chunks/sync.js +1 -1
  82. package/dist/packem_chunks/sync2.js +1 -1
  83. package/dist/packem_chunks/tripwire.js +1 -1
  84. package/dist/packem_chunks/ts-loader.js +1 -1
  85. package/dist/packem_chunks/verify-lockfile.js +1 -1
  86. package/dist/packem_shared/{advisories-CCBGdU8U.js → advisories-DsXRmIA5.js} +1 -1
  87. package/dist/packem_shared/{affected-selection-Dj-ymxhw.js → affected-selection-BE6VFCDV.js} +1 -1
  88. package/dist/packem_shared/{affected-shas-PwkVbPch.js → affected-shas-BKEu4RZc.js} +1 -1
  89. package/dist/packem_shared/{ai-analysis-bGCAc1jR.js → ai-analysis-DikAj6rX.js} +1 -1
  90. package/dist/packem_shared/{ai-fix-DV5-dHBY.js → ai-fix-bfWo0cZX.js} +1 -1
  91. package/dist/packem_shared/{augment-24KX2nkI.js → augment-BkJxi_GW.js} +1 -1
  92. package/dist/packem_shared/{bin-CtzhnYMp.js → bin-B-TytgzW.js} +1 -1
  93. package/dist/packem_shared/{build-scripts-w4SNeR7D.js → build-scripts-DWypBQ--.js} +1 -1
  94. package/dist/packem_shared/{command-runtime-BLFPUYAT.js → command-runtime-DQ7ZpLYL.js} +1 -1
  95. package/dist/packem_shared/{cyclonedx-C4KaVTn1.js → cyclonedx-DLBi65MV.js} +1 -1
  96. package/dist/packem_shared/dependency-scan-ZLOuLkGN.js +1 -0
  97. package/dist/packem_shared/{docker-DaVs-9wK.js → docker-B4zAZCZG.js} +15 -15
  98. package/dist/packem_shared/{en-D3CfXlO7.js → en-BDYMmM2_.js} +1 -1
  99. package/dist/packem_shared/{failure-log-CTneNcio.js → failure-log-DyhWPqno.js} +1 -1
  100. package/dist/packem_shared/glob-BUjyjdE8-Dp_QcayW.js +1 -0
  101. package/dist/packem_shared/index-BLtnel38.js +35 -0
  102. package/dist/packem_shared/index-CuKDxOCI.js +1 -0
  103. package/dist/packem_shared/index-tNFGWxc0.js +39 -0
  104. package/dist/packem_shared/{lifecycle-B8A2T3gx.js → lifecycle-KY9umOg6.js} +1 -1
  105. package/dist/packem_shared/{lockfile-Bccery3L.js → lockfile-YAuZf1gh.js} +1 -1
  106. package/dist/packem_shared/{manifests-BDkwiVbh.js → manifests-BwTn_1ad.js} +1 -1
  107. package/dist/packem_shared/{min-release-age-OaYpLwux.js → min-release-age-6avfn81h.js} +1 -1
  108. package/dist/packem_shared/{missing-package-json-BqS-OnKd.js → missing-package-json-Cl0vdz6K.js} +1 -1
  109. package/dist/packem_shared/{native-config-sync-Ds1FtcrM.js → native-config-sync-CHMCJx7H.js} +7 -7
  110. package/dist/packem_shared/{osv-bloom-pKp7urSB.js → osv-bloom-DdqDnLCt.js} +2 -2
  111. package/dist/packem_shared/package-version-BNRJ3o9C.js +4 -0
  112. package/dist/packem_shared/{packument-HBVbyf7x.js → packument-B9-WqReu.js} +1 -1
  113. package/dist/packem_shared/{pm-runner-C6eTANt1.js → pm-runner-DRybtzOV.js} +1 -1
  114. package/dist/packem_shared/{project-name-filter-CJ3XX2TI.js → project-name-filter-Dw0fC6IO.js} +1 -1
  115. package/dist/packem_shared/{provenance-D4Cza8cp.js → provenance-CLxuqCfL.js} +1 -1
  116. package/dist/packem_shared/{readJsonSync-DweZd5ZA-0eZh9sGm.js → readJsonSync-DweZd5ZA-CtrDlqpb.js} +1 -1
  117. package/dist/packem_shared/{registry-keys-C0ez2VND.js → registry-keys-cTN24144.js} +1 -1
  118. package/dist/packem_shared/{resolve-explicit-BbT764KS.js → resolve-explicit-Uw6WQl9R.js} +1 -1
  119. package/dist/packem_shared/{resolve-runtime-D_vZovbB.js → resolve-runtime-DztanwkZ.js} +1 -1
  120. package/dist/packem_shared/{run-file-DyPFFN9U.js → run-file-CaE5_xBY.js} +1 -1
  121. package/dist/packem_shared/{runtime-check-D4um-yQq.js → runtime-check-C32yE57I.js} +1 -1
  122. package/dist/packem_shared/{s1ngularity-St6dhKiq.js → s1ngularity-BIYhg82u.js} +1 -1
  123. package/dist/packem_shared/{scan-progress-q-N2JtIp.js → scan-progress-DWfY4zkp.js} +1 -1
  124. package/dist/packem_shared/{selectors-Ce_6UAoY.js → selectors-D2j4M9Ul.js} +1 -1
  125. package/dist/packem_shared/{signatures-Dyeyg1q9.js → signatures-C8iQ5fUq.js} +1 -1
  126. package/dist/packem_shared/target-merge-DLxJTcxn.js +11 -0
  127. package/dist/packem_shared/{target-options-7XcbqGDe.js → target-options-3t4-2F-F.js} +1 -1
  128. package/dist/packem_shared/{toolchain-C_pNMBM6.js → toolchain-BPzbahcQ.js} +1 -1
  129. package/dist/packem_shared/{typosquats-xzcAGPiM.js → typosquats-BWrmhh36.js} +1 -1
  130. package/dist/packem_shared/{use-measured-height-CBjN0fle.js → use-measured-height-BwAwGHjw.js} +1 -1
  131. package/dist/packem_shared/verify-CzUPT6Uk.js +1 -0
  132. package/dist/packem_shared/{vis-update-app-DMAC2pPf.js → vis-update-app-D6Wq8ZHM.js} +1 -1
  133. package/dist/packem_shared/{vis-user-error-xmha3L4n.js → vis-user-error-CfM4_ORo.js} +1 -1
  134. package/dist/packem_shared/{watch-BXOOX7lx.js → watch-D_oAxW_Z.js} +1 -1
  135. package/dist/packem_shared/{watch-loop-Q7UpkVbr.js → watch-loop-BrjblOz5.js} +1 -1
  136. package/dist/runtime/preload.js +1 -1
  137. package/index.d.ts +204 -204
  138. package/index.js +26 -26
  139. package/package.json +13 -13
  140. package/dist/packem_shared/dependency-scan-D_ona0Qm.js +0 -1
  141. package/dist/packem_shared/glob-BUjyjdE8-C4M8e02u.js +0 -1
  142. package/dist/packem_shared/index-CTMU29dI.js +0 -1
  143. package/dist/packem_shared/index-uBVnF4ji.js +0 -35
  144. package/dist/packem_shared/package-version-C47v64aB.js +0 -4
  145. package/dist/packem_shared/public-api-WqUCiyIe.js +0 -131
  146. package/dist/packem_shared/target-merge-Cfy7c__2.js +0 -11
  147. package/dist/packem_shared/verify-Dve9PQj3.js +0 -1
@@ -1,4 +1,4 @@
1
- import{createRequire as z}from"node:module";import{m as M,o as F,q as J,s as p,t as P,u as Y,Y as L,x as H,y as D,z as K,C as Q,D as U,E as X,L as Z,F as tt,H as ot,G as I,$ as et}from"./cli-main.js";import{l as w,w as f,z as j,u as it,j as O,c as rt,K as at}from"../packem_shared/index-uBVnF4ji.js";import"../packem_shared/public-api-WqUCiyIe.js";import{loadVisConfig as ct}from"./CONFIG_FILES.js";import{v as ft}from"../packem_shared/verify-Dve9PQj3.js";let W;const G=t=>(W??=z(import.meta.url))(t),$=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,V=t=>{if(typeof $<"u"&&$.versions&&$.versions.node){const[o,s]=$.versions.node.split(".").map(Number);if(o>22||o===22&&s>=3||o===20&&s>=16)return $.getBuiltinModule(t)}return G(t)},{readdirSync:st,statSync:nt}=V("node:fs"),{stdin:T,stdout:ut}=$,{createInterface:pt}=V("node:readline/promises"),k="__global__",R=t=>[...new Set(t)].sort((o,s)=>o.localeCompare(s)),gt=t=>`{${Object.keys(t).sort().map(o=>`${o}=${JSON.stringify(t[o])}`).join(",")}}`,y=t=>{if(!Array.isArray(t))return[];const o=[];for(const s of t)typeof s=="string"?o.push(s):s&&typeof s=="object"&&o.push(gt(s));return R(o)},m=t=>({cache:void 0,dependsOn:[],env:[],id:t,inputs:[],outputs:[]}),h=(t,o,s)=>s?`^${o}`:t&&t!=="self"&&t!=="~"?`${t}#${o}`:o,dt=(t,o)=>{const s=t.trim();if(o==="moon"){if(s.startsWith("^:"))return h(void 0,s.slice(2),!0);if(s.startsWith("~:"))return h(void 0,s.slice(2),!1);if(s.includes(":")){const[n,e]=s.split(":");return h(n,e??"",!1)}return s}if(s.startsWith("^"))return h(void 0,s.slice(1),!0);if(s.includes("#")){const[n,e]=s.split("#");return h(n,e??"",!1)}return s},C=(t,o)=>{if(!Array.isArray(t))return[];const s=[];for(const n of t){if(typeof n=="string"){s.push(dt(n,o));continue}if(!n||typeof n!="object")continue;const e=n,{target:i}=e;if(!i)continue;if(e.dependencies===!0){s.push(h(void 0,i,!0));continue}if(e.projects===void 0){s.push(h(void 0,i,!1));continue}const r=Array.isArray(e.projects)?e.projects:[e.projects];for(const c of r)s.push(c==="^"?h(void 0,i,!0):h(c,i,!1))}return R(s)},E=t=>{if(w(t))try{return JSON.parse(j(t))}catch{return}},lt=t=>{const o=new Map,s=E(f(t,"turbo.json"));if(!s)return o;const n=s.tasks??s.pipeline??{};for(const[i,r]of Object.entries(n)){const c=i.includes("#")?i:`*#${i}`,a=m(c);a.dependsOn=C(r.dependsOn,"turbo"),a.inputs=y(r.inputs),a.outputs=y(r.outputs),a.env=R([...r.env??[],...r.passThroughEnv??[]]),a.cache=r.cache===!1?!1:void 0,o.set(c,a)}const e=m(k);return e.inputs=y(s.globalDependencies),e.env=R([...s.globalEnv??[],...s.globalPassThroughEnv??[]]),(e.inputs.length>0||e.env.length>0)&&o.set(k,e),o},vt=new Set([".git",".nx",".turbo",".vis","build","coverage","dist","node_modules"]),S=(t,o,s=8)=>{const n=[],e=(i,r)=>{if(r>s)return;let c;try{c=st(i)}catch{return}for(const a of c.toSorted()){if(a===o){n.push(f(i,a));continue}if(a.startsWith(".")&&a!==".moon"||vt.has(a))continue;const u=f(i,a);try{nt(u).isDirectory()&&e(u,r+1)}catch{}}};return e(t,0),n},_=(t,o)=>{t.dependsOn=C(o.dependsOn,"nx"),t.inputs=y(o.inputs),t.outputs=y(o.outputs),t.cache=typeof o.cache=="boolean"?o.cache:void 0},yt=t=>{const o=new Map,s=E(f(t,"nx.json"));for(const[n,e]of Object.entries(s?.targetDefaults??{})){const i=`*#${n}`,r=m(i);_(r,e),o.set(i,r)}for(const n of S(t,"project.json")){const e=E(n);if(!(!e?.name||!e.targets))for(const[i,r]of Object.entries(e.targets)){const c=`${e.name}#${i}`,a=m(c);_(a,r),o.set(c,a)}}return o},N=(t,o)=>{t.dependsOn=C(o.deps,"moon"),t.inputs=y(o.inputs),t.outputs=y(o.outputs),t.cache=typeof o.options?.cache=="boolean"?o.options.cache:void 0},A=t=>{if(w(t))try{return it(t)}catch{return}},ht=t=>{const o=new Map,s=f(t,".moon"),n=[f(s,"tasks.yml"),f(s,"tasks.yaml")];for(const e of n){const i=A(e);if(i){for(const[r,c]of Object.entries(i.tasks??{})){const a=`*#${r}`,u=m(a);N(u,c),o.set(a,u)}if(i.implicitInputs&&i.implicitInputs.length>0){const r=m(k);r.inputs=y(i.implicitInputs),o.set(k,r)}}}for(const e of[...S(t,"moon.yml"),...S(t,"moon.yaml")]){const i=A(e);if(!i?.tasks)continue;const r=e.split(/[/\\]/).at(-2)??"*";for(const[c,a]of Object.entries(i.tasks)){const u=`${r}#${c}`,v=m(u);N(v,a),o.set(u,v)}}return o},mt=(t,o)=>{t.dependsOn=C(o.dependsOn,"vis"),t.inputs=y(o.inputs),t.outputs=y(o.outputs),t.env=R([...o.env??[],...o.passThroughEnv??[],...o.options?.passThroughEnv??[]]),t.cache=o.cache===!1?!1:typeof o.cache=="boolean"?o.cache:void 0},wt=async t=>{const o=new Map,s=await ct(t);for(const[i,r]of Object.entries(s.tasks??{})){const c=`*#${i}`,a=m(c);mt(a,r??{}),o.set(c,a)}const n=s.taskRunner??{},e=m(k);return e.inputs=y(n.globalInputs),e.env=R([...n.globalEnv??[],...n.globalPassThroughEnv??[]]),(e.inputs.length>0||e.env.length>0)&&o.set(k,e),o},kt=(t,o)=>{switch(o){case"moon":return ht(t);case"nx":return yt(t);default:return lt(t)}},Rt=t=>{const o=[];return w(f(t,"turbo.json"))&&o.push("turbo"),w(f(t,"nx.json"))&&o.push("nx"),(w(f(t,".moon","tasks.yml"))||w(f(t,".moon","tasks.yaml")))&&o.push("moon"),o.length===1?o[0]:void 0},x=(t,o,s,n,e)=>{const i=n.filter(a=>!e.includes(a)),r=e.filter(a=>!n.includes(a));if(i.length===0&&r.length===0)return;const c=[];i.length>0&&c.push(`dropped [${i.join(", ")}]`),r.length>0&&c.push(`added [${r.join(", ")}]`),t.push({axis:s,detail:`${s} diverged: ${c.join("; ")}`,node:o,severity:i.length>0?"error":"warning"})},$t=(t,o,s)=>{const n=[],e=R([...t.keys(),...o.keys()]);for(const i of e){const r=t.get(i),c=o.get(i);if(r&&!c){const a=s==="turbo"&&i.includes("#")&&!i.startsWith("*#")&&i!==k;n.push({axis:"target-set",detail:a?`source target \`${i}\` was skipped by design (turbo project#task is migrated into per-project project.json — move it there and re-verify)`:`source target \`${i}\` has no equivalent in the migrated vis config`,node:i,severity:a?"warning":"error"});continue}if(!r&&c){n.push({axis:"target-set",detail:`migrated vis config defines \`${i}\` with no source equivalent (extra target — not a regression, but review)`,node:i,severity:"warning"});continue}!r||!c||(x(n,i,"dependsOn",r.dependsOn,c.dependsOn),x(n,i,"inputs",r.inputs,c.inputs),x(n,i,"outputs",r.outputs,c.outputs),x(n,i,"env",r.env,c.env),r.cache!==void 0&&c.cache!==void 0&&r.cache!==c.cache&&n.push({axis:"cache",detail:`cache flag diverged: source=${String(r.cache)} vis=${String(c.cache)} (changes what invalidates the cache)`,node:i,severity:"error"}))}return n.sort((i,r)=>i.node.localeCompare(r.node)||i.axis.localeCompare(r.axis)),{findings:n,source:s,sourceNodeCount:t.size,visNodeCount:o.size}},bt=new Set(["json","ndjson","table"]),xt=t=>({equivalent:t.findings.every(o=>o.severity!=="error"),findings:t.findings,source:t.source,sourceNodeCount:t.sourceNodeCount,visNodeCount:t.visNodeCount}),Ct=(t,o,s)=>{if(o==="json"){process.stdout.write(`${JSON.stringify(xt(t),void 0,2)}
1
+ import{createRequire as z}from"node:module";import{m as M,o as F,q as J,s as p,t as P,u as Y,Y as L,x as H,y as D,z as K,C as Q,D as U,E as X,L as Z,F as tt,H as ot,G as I,$ as et}from"./cli-main.js";import{l as w,w as f,z as j,a as it,j as O,e as rt,K as at}from"../packem_shared/index-BLtnel38.js";import"../packem_shared/index-tNFGWxc0.js";import{loadVisConfig as ct}from"./CONFIG_FILES.js";import{v as ft}from"../packem_shared/verify-CzUPT6Uk.js";let W;const G=t=>(W??=z(import.meta.url))(t),$=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,V=t=>{if(typeof $<"u"&&$.versions&&$.versions.node){const[o,s]=$.versions.node.split(".").map(Number);if(o>22||o===22&&s>=3||o===20&&s>=16)return $.getBuiltinModule(t)}return G(t)},{readdirSync:st,statSync:nt}=V("node:fs"),{stdin:T,stdout:ut}=$,{createInterface:pt}=V("node:readline/promises"),k="__global__",R=t=>[...new Set(t)].sort((o,s)=>o.localeCompare(s)),gt=t=>`{${Object.keys(t).sort().map(o=>`${o}=${JSON.stringify(t[o])}`).join(",")}}`,y=t=>{if(!Array.isArray(t))return[];const o=[];for(const s of t)typeof s=="string"?o.push(s):s&&typeof s=="object"&&o.push(gt(s));return R(o)},m=t=>({cache:void 0,dependsOn:[],env:[],id:t,inputs:[],outputs:[]}),h=(t,o,s)=>s?`^${o}`:t&&t!=="self"&&t!=="~"?`${t}#${o}`:o,dt=(t,o)=>{const s=t.trim();if(o==="moon"){if(s.startsWith("^:"))return h(void 0,s.slice(2),!0);if(s.startsWith("~:"))return h(void 0,s.slice(2),!1);if(s.includes(":")){const[n,e]=s.split(":");return h(n,e??"",!1)}return s}if(s.startsWith("^"))return h(void 0,s.slice(1),!0);if(s.includes("#")){const[n,e]=s.split("#");return h(n,e??"",!1)}return s},C=(t,o)=>{if(!Array.isArray(t))return[];const s=[];for(const n of t){if(typeof n=="string"){s.push(dt(n,o));continue}if(!n||typeof n!="object")continue;const e=n,{target:i}=e;if(!i)continue;if(e.dependencies===!0){s.push(h(void 0,i,!0));continue}if(e.projects===void 0){s.push(h(void 0,i,!1));continue}const r=Array.isArray(e.projects)?e.projects:[e.projects];for(const c of r)s.push(c==="^"?h(void 0,i,!0):h(c,i,!1))}return R(s)},E=t=>{if(w(t))try{return JSON.parse(j(t))}catch{return}},lt=t=>{const o=new Map,s=E(f(t,"turbo.json"));if(!s)return o;const n=s.tasks??s.pipeline??{};for(const[i,r]of Object.entries(n)){const c=i.includes("#")?i:`*#${i}`,a=m(c);a.dependsOn=C(r.dependsOn,"turbo"),a.inputs=y(r.inputs),a.outputs=y(r.outputs),a.env=R([...r.env??[],...r.passThroughEnv??[]]),a.cache=r.cache===!1?!1:void 0,o.set(c,a)}const e=m(k);return e.inputs=y(s.globalDependencies),e.env=R([...s.globalEnv??[],...s.globalPassThroughEnv??[]]),(e.inputs.length>0||e.env.length>0)&&o.set(k,e),o},vt=new Set([".git",".nx",".turbo",".vis","build","coverage","dist","node_modules"]),S=(t,o,s=8)=>{const n=[],e=(i,r)=>{if(r>s)return;let c;try{c=st(i)}catch{return}for(const a of c.toSorted()){if(a===o){n.push(f(i,a));continue}if(a.startsWith(".")&&a!==".moon"||vt.has(a))continue;const u=f(i,a);try{nt(u).isDirectory()&&e(u,r+1)}catch{}}};return e(t,0),n},_=(t,o)=>{t.dependsOn=C(o.dependsOn,"nx"),t.inputs=y(o.inputs),t.outputs=y(o.outputs),t.cache=typeof o.cache=="boolean"?o.cache:void 0},yt=t=>{const o=new Map,s=E(f(t,"nx.json"));for(const[n,e]of Object.entries(s?.targetDefaults??{})){const i=`*#${n}`,r=m(i);_(r,e),o.set(i,r)}for(const n of S(t,"project.json")){const e=E(n);if(!(!e?.name||!e.targets))for(const[i,r]of Object.entries(e.targets)){const c=`${e.name}#${i}`,a=m(c);_(a,r),o.set(c,a)}}return o},N=(t,o)=>{t.dependsOn=C(o.deps,"moon"),t.inputs=y(o.inputs),t.outputs=y(o.outputs),t.cache=typeof o.options?.cache=="boolean"?o.options.cache:void 0},A=t=>{if(w(t))try{return it(t)}catch{return}},ht=t=>{const o=new Map,s=f(t,".moon"),n=[f(s,"tasks.yml"),f(s,"tasks.yaml")];for(const e of n){const i=A(e);if(i){for(const[r,c]of Object.entries(i.tasks??{})){const a=`*#${r}`,u=m(a);N(u,c),o.set(a,u)}if(i.implicitInputs&&i.implicitInputs.length>0){const r=m(k);r.inputs=y(i.implicitInputs),o.set(k,r)}}}for(const e of[...S(t,"moon.yml"),...S(t,"moon.yaml")]){const i=A(e);if(!i?.tasks)continue;const r=e.split(/[/\\]/).at(-2)??"*";for(const[c,a]of Object.entries(i.tasks)){const u=`${r}#${c}`,v=m(u);N(v,a),o.set(u,v)}}return o},mt=(t,o)=>{t.dependsOn=C(o.dependsOn,"vis"),t.inputs=y(o.inputs),t.outputs=y(o.outputs),t.env=R([...o.env??[],...o.passThroughEnv??[],...o.options?.passThroughEnv??[]]),t.cache=o.cache===!1?!1:typeof o.cache=="boolean"?o.cache:void 0},wt=async t=>{const o=new Map,s=await ct(t);for(const[i,r]of Object.entries(s.tasks??{})){const c=`*#${i}`,a=m(c);mt(a,r??{}),o.set(c,a)}const n=s.taskRunner??{},e=m(k);return e.inputs=y(n.globalInputs),e.env=R([...n.globalEnv??[],...n.globalPassThroughEnv??[]]),(e.inputs.length>0||e.env.length>0)&&o.set(k,e),o},kt=(t,o)=>{switch(o){case"moon":return ht(t);case"nx":return yt(t);default:return lt(t)}},Rt=t=>{const o=[];return w(f(t,"turbo.json"))&&o.push("turbo"),w(f(t,"nx.json"))&&o.push("nx"),(w(f(t,".moon","tasks.yml"))||w(f(t,".moon","tasks.yaml")))&&o.push("moon"),o.length===1?o[0]:void 0},x=(t,o,s,n,e)=>{const i=n.filter(a=>!e.includes(a)),r=e.filter(a=>!n.includes(a));if(i.length===0&&r.length===0)return;const c=[];i.length>0&&c.push(`dropped [${i.join(", ")}]`),r.length>0&&c.push(`added [${r.join(", ")}]`),t.push({axis:s,detail:`${s} diverged: ${c.join("; ")}`,node:o,severity:i.length>0?"error":"warning"})},$t=(t,o,s)=>{const n=[],e=R([...t.keys(),...o.keys()]);for(const i of e){const r=t.get(i),c=o.get(i);if(r&&!c){const a=s==="turbo"&&i.includes("#")&&!i.startsWith("*#")&&i!==k;n.push({axis:"target-set",detail:a?`source target \`${i}\` was skipped by design (turbo project#task is migrated into per-project project.json — move it there and re-verify)`:`source target \`${i}\` has no equivalent in the migrated vis config`,node:i,severity:a?"warning":"error"});continue}if(!r&&c){n.push({axis:"target-set",detail:`migrated vis config defines \`${i}\` with no source equivalent (extra target — not a regression, but review)`,node:i,severity:"warning"});continue}!r||!c||(x(n,i,"dependsOn",r.dependsOn,c.dependsOn),x(n,i,"inputs",r.inputs,c.inputs),x(n,i,"outputs",r.outputs,c.outputs),x(n,i,"env",r.env,c.env),r.cache!==void 0&&c.cache!==void 0&&r.cache!==c.cache&&n.push({axis:"cache",detail:`cache flag diverged: source=${String(r.cache)} vis=${String(c.cache)} (changes what invalidates the cache)`,node:i,severity:"error"}))}return n.sort((i,r)=>i.node.localeCompare(r.node)||i.axis.localeCompare(r.axis)),{findings:n,source:s,sourceNodeCount:t.size,visNodeCount:o.size}},bt=new Set(["json","ndjson","table"]),xt=t=>({equivalent:t.findings.every(o=>o.severity!=="error"),findings:t.findings,source:t.source,sourceNodeCount:t.sourceNodeCount,visNodeCount:t.visNodeCount}),Ct=(t,o,s)=>{if(o==="json"){process.stdout.write(`${JSON.stringify(xt(t),void 0,2)}
2
2
  `);return}if(o==="ndjson"){for(const n of t.findings)process.stdout.write(`${JSON.stringify(n)}
3
3
  `);return}if(s.info(`Migration equivalence: ${t.source} → vis`),s.info(` source nodes: ${String(t.sourceNodeCount)} vis nodes: ${String(t.visNodeCount)}`),t.findings.length===0){s.info(" ✓ task graph + cache-key surface preserved (no divergence).");return}for(const n of t.findings){const e=` [${n.severity}] ${n.node} (${n.axis}) — ${n.detail}`;n.severity==="error"?s.warn(e):s.info(e)}},jt=(t,o)=>t.findings.some(s=>o==="warning"?!0:s.severity==="error")?1:0,B=async t=>{if(!T.isTTY)return!0;const o=pt({input:T,output:ut});try{const s=(await o.question(`${t} [Y/n] `)).trim().toLowerCase();return s===""||s==="y"||s==="yes"}finally{o.close()}},Et=[{description:"VisConfig.targetDefaults → VisConfig.tasks",next:"tasks",previous:"targetDefaults"},{description:"VisConfig.taskDefaults → VisConfig.scopedTasks",next:"scopedTasks",previous:"taskDefaults"},{description:"VisConfig.taskRunnerOptions → VisConfig.taskRunner",next:"taskRunner",previous:"taskRunnerOptions"},{description:"ScopedTasksBlock.scope → ScopedTasksBlock.match",next:"match",previous:"scope"},{description:"ScopedTasksBlock.targets → ScopedTasksBlock.tasks",next:"tasks",previous:"targets"}],St=[{description:"VisTaskConfig.targets → VisTaskConfig.tasks",next:"tasks",previous:"targets"}],Mt=t=>new RegExp(String.raw`(^|[\s,{(\[])(["']?)${t}\2(\s*:)`,"gmu"),Ot=(t,o)=>{let s=t;const n=[];for(const e of o){const i=Mt(e.previous);i.test(s)&&(i.lastIndex=0,s=s.replace(i,(r,c,a,u)=>`${c}${a}${e.next}${a}${u}`),n.push(e))}return{applied:n,output:s}},q=(t,o)=>Ot(t,o),Tt=["vis.config.ts","vis.config.mts","vis.config.cts","vis.config.js","vis.config.mjs","vis.config.cjs"],_t=new Set(["vis.task.cjs","vis.task.cts","vis.task.js","vis.task.mjs","vis.task.mts","vis.task.ts"]),Nt=t=>{for(const o of Tt){const s=f(t,o);if(w(s))return s}},At=t=>{const o=[];try{for(const s of rt(t,{includeDirs:!1,includeFiles:!0,includeSymlinks:!1,skip:[/node_modules/,/\.git/,/\.vis\b/,/dist\b/,/\.next\b/,/\.nuxt\b/]}))_t.has(at(s.path))&&o.push(s.path)}catch{}return o},qt=(t,o,s,n)=>{const e=Nt(t);if(e){const r=j(e),{applied:c,output:a}=q(r,Et);if(c.length===0)s.info(`${e} already uses the current schema — no rewrite needed.`);else if(o.dryRun)s.info(`── ${e} (preview) ──`),s.info(a),s.info("── end preview ──"),s.info(`Would apply ${String(c.length)} rename(s): ${c.map(u=>u.description).join(", ")}`);else{M(e,n),O(e,a),s.info(`Rewrote ${e} (backup at ${e}.bak). Applied ${String(c.length)} rename(s).`);for(const u of c)n.manualSteps.push(`Renamed ${u.description} in ${e}`)}}else s.warn("No vis.config.ts found at workspace root — nothing to migrate."),n.warnings.push("No vis.config.{ts,mts,cts,js,mjs,cjs} at workspace root.");const i=o.taskConfigPaths??At(t);for(const r of i){if(!w(r))continue;const c=j(r),a=q(c,St);if(a.applied.length!==0)if(o.dryRun)s.info(`── ${r} (preview) ──`),s.info(a.output),s.info("── end preview ──"),s.info(`Would apply ${String(a.applied.length)} rename(s): ${a.applied.map(u=>u.description).join(", ")}`);else{M(r,n),O(r,a.output),s.info(`Rewrote ${r} (backup at ${r}.bak). Applied ${String(a.applied.length)} rename(s).`);for(const u of a.applied)n.manualSteps.push(`Renamed ${u.description} in ${r}`)}}},g=t=>{const o=t.workspaceRoot??process.cwd(),s=t.visConfig??{};return{config:s,dryRun:!!t.options.dryRun,logger:t.logger,packageManager:et(o),report:I(),root:o,useEditorconfig:typeof s.editorconfig=="boolean"?s.editorconfig:!0}},d=async(t,o,s)=>{if(o.yes||o.dryRun)return!0;const n=await B(`This will edit files, scripts, and hooks for "${t}". Backups (.bak) will be created. Continue?`);return n||s.info("Aborted."),n},l=t=>{t.dryRun&&t.logger.info(`Running in dry-run mode — no changes will be made.
4
4
  `)},Vt=async({logger:t,options:o,visConfig:s,workspaceRoot:n})=>{if(!await d("deps",o,t))return;const e=g({logger:t,options:o,visConfig:s,workspaceRoot:n});l(e),t.info("── Migrating dependencies and scripts ──"),P(e.root,e.packageManager,e.config,{dryRun:e.dryRun},t,e.report),t.info(""),p(e.report,t)},Dt=async({logger:t,options:o,visConfig:s,workspaceRoot:n})=>{if(!await d("lint-staged",o,t))return;const e=g({logger:t,options:o,visConfig:s,workspaceRoot:n});l(e),t.info("── Migrating lint-staged ──"),Y(e.root,{dryRun:e.dryRun,useEditorconfig:e.useEditorconfig},t,e.report),t.info(""),p(e.report,t)},It=async({logger:t,options:o,visConfig:s,workspaceRoot:n})=>{if(!await d("nano-staged",o,t))return;const e=g({logger:t,options:o,visConfig:s,workspaceRoot:n});l(e),t.info("── Migrating nano-staged ──"),L(e.root,{dryRun:e.dryRun,useEditorconfig:e.useEditorconfig},t,e.report),t.info(""),p(e.report,t)},Bt=async({logger:t,options:o,visConfig:s,workspaceRoot:n})=>{if(!await d("turborepo",o,t))return;const e=g({logger:t,options:o,visConfig:s,workspaceRoot:n});l(e),t.info("── Migrating turborepo ──"),H(e.root,{dryRun:e.dryRun,useEditorconfig:e.useEditorconfig},t,e.report),D(e.root,{dryRun:e.dryRun},t),t.info(""),p(e.report,t)},zt=async({logger:t,options:o,visConfig:s,workspaceRoot:n})=>{if(!await d("nx",o,t))return;const e=g({logger:t,options:o,visConfig:s,workspaceRoot:n});l(e),t.info("── Migrating nx ──");const i=!!o.aggressive;K(e.root,{aggressive:i,dryRun:e.dryRun,force:i||!!o.force,rewriteSyncGenerators:i||!!o.rewriteSyncGenerators,useEditorconfig:e.useEditorconfig},t,e.report),t.info(""),p(e.report,t)},Wt=async({logger:t,options:o,visConfig:s,workspaceRoot:n})=>{if(!await d("moon",o,t))return;const e=g({logger:t,options:o,visConfig:s,workspaceRoot:n});l(e),t.info("── Migrating moon ──"),Q(e.root,{copyTemplates:!!o.copyTemplates,dryRun:e.dryRun,useEditorconfig:e.useEditorconfig},t,e.report),D(e.root,{dryRun:e.dryRun},t),t.info(""),p(e.report,t)},Gt=async({logger:t,options:o,visConfig:s,workspaceRoot:n})=>{if(!await d("gitleaks",o,t))return;const e=g({logger:t,options:o,visConfig:s,workspaceRoot:n});l(e),t.info("── Migrating gitleaks ──"),U(e.root,{dryRun:e.dryRun,useEditorconfig:e.useEditorconfig},t,e.report),t.info(""),p(e.report,t)},Ft=async({logger:t,options:o,visConfig:s,workspaceRoot:n})=>{if(!await d("kingfisher",o,t))return;const e=g({logger:t,options:o,visConfig:s,workspaceRoot:n});l(e),t.info("── Migrating Kingfisher ──"),X(e.root,{dryRun:e.dryRun,useEditorconfig:e.useEditorconfig},t,e.report),t.info(""),p(e.report,t)},Jt=async({logger:t,options:o,visConfig:s,workspaceRoot:n})=>{if(!await d("secretlint",o,t))return;const e=g({logger:t,options:o,visConfig:s,workspaceRoot:n});l(e),t.info("── Migrating secretlint ──"),Z(e.root,{dryRun:e.dryRun,useEditorconfig:e.useEditorconfig},t,e.report),t.info(""),p(e.report,t)},Pt=async({logger:t,options:o,visConfig:s,workspaceRoot:n})=>{if(!await d("syncpack",o,t))return;const e=g({logger:t,options:o,visConfig:s,workspaceRoot:n});l(e),t.info("── Migrating syncpack ──"),tt(e.root,{dryRun:e.dryRun,useEditorconfig:e.useEditorconfig},t,e.report),t.info(""),p(e.report,t)},Yt=async({logger:t,options:o,visConfig:s,workspaceRoot:n})=>{if(!await d("sherif",o,t))return;const e=g({logger:t,options:o,visConfig:s,workspaceRoot:n});l(e),t.info("── Migrating sherif ──"),ot(e.root,{dryRun:e.dryRun,useEditorconfig:e.useEditorconfig},t,e.report),t.info(""),p(e.report,t)},Lt=async({logger:t,options:o,visConfig:s,workspaceRoot:n})=>{if(!await d("self",o,t))return;const e=g({logger:t,options:o,visConfig:s,workspaceRoot:n});l(e),t.info("── Migrating vis.config.ts to current schema ──"),qt(e.root,{dryRun:e.dryRun},t,e.report),t.info(""),p(e.report,t)},Ht=({logger:t,workspaceRoot:o})=>{const s=o??process.cwd();ft(s,t).length>0&&(process.exitCode=1)},Kt=async({logger:t,options:o,workspaceRoot:s})=>{const n=s??process.cwd(),e=o.format??"table";if(!bt.has(e)){t.warn(`Invalid --format: ${String(o.format)}. Expected table | json | ndjson.`),process.exitCode=1;return}const i=o.failOn==="warning"?"warning":"error";let r;if(o.from){if(o.from!=="turbo"&&o.from!=="nx"&&o.from!=="moon"){t.warn(`Invalid --from: ${o.from}. Expected turbo | nx | moon.`),process.exitCode=1;return}r=o.from}else if(r=Rt(n),!r){t.warn("Could not auto-detect the source tool (need exactly one of turbo.json / nx.json / .moon/tasks.yml). Pass --from <turbo|nx|moon>."),process.exitCode=1;return}const c=kt(n,r);if(c.size===0){t.warn(`No ${r} task graph found at ${n} — nothing to verify.`),process.exitCode=1;return}const a=await wt(n);if(a.size===0){t.warn("No migrated vis task graph found (vis.config.ts has no tasks). Run the migrator first."),process.exitCode=1;return}const u=$t(c,a,r);Ct(u,e,t),process.exitCode=jt(u,i)},Qt=async({logger:t,options:o,visConfig:s,workspaceRoot:n})=>{const e=n??process.cwd(),i=F(e,s??{}),r=J(i);if(r.length===0){t.info("No applicable migrations detected in this workspace.");return}const c=!!o.dryRun;t.info(`Detected ${String(r.length)} migration(s):`);for(const v of r)t.info(` • ${v.title} — ${v.description}`);if(t.info(""),!o.yes&&!c&&!await B("Apply all detected migrations? Backups (.bak) will be created.")){t.info("Aborted.");return}c&&t.info(`Running in dry-run mode — no changes will be made.
@@ -1,4 +1,4 @@
1
- import{createRequire as K}from"node:module";import{j as b,E as m,q as k,I as N,V as U,s as P}from"../packem_shared/index.server-CusjRLCh.js";import{w as h,d as W,v as A,l as z}from"../packem_shared/index-uBVnF4ji.js";import{v as I,S as G}from"./catalog.js";import{d as X}from"../packem_shared/lockfile-Bccery3L.js";import{p as Q,s as Z}from"../packem_shared/docker-DaVs-9wK.js";import{I as re}from"../packem_shared/index-BWl4DbMp.js";import{g as L}from"../packem_shared/en-D3CfXlO7.js";let Y;const J=e=>(Y??=K(import.meta.url))(e),g=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,y=e=>{if(typeof g<"u"&&g.versions&&g.versions.node){const[o,t]=g.versions.node.split(".").map(Number);if(o>22||o===22&&t>=3||o===20&&t>=16)return g.getBuiltinModule(e)}return J(e)},{createInterface:O}=y("node:readline"),{spawn:ee}=y("node:child_process"),{createHash:oe}=y("node:crypto"),{existsSync:T,writeFileSync:te,chmodSync:ne}=y("node:fs"),D={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:o,manager:t,nodeVersion:r}=e,n=D[t]??D.npm;return["# syntax=docker/dockerfile:1","","# Generated by 'vis docker init'. Before building, scaffold the context:",`# vis docker scaffold${o?` --focus=${o}`:""} --include-sources`,"# then build with BuildKit enabled (DOCKER_BUILDKIT=1).","",`FROM node:${r}-slim AS base`,"WORKDIR /app",...n.base,"","# --- install dependencies from the scaffolded manifests only ---","FROM base AS deps","COPY .vis/docker/workspace/ ./",n.install,"","# --- build the focus project, then drop unfocused workspace projects ---","FROM deps AS build","COPY .vis/docker/sources/ ./",n.build(o),"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 b,E as m,q as k,I as N,V as U,s as P}from"../packem_shared/index.server-CusjRLCh.js";import{w as h,d as W,v as A,l as z}from"../packem_shared/index-BLtnel38.js";import{v as I,S as G}from"./catalog.js";import{d as X}from"../packem_shared/lockfile-YAuZf1gh.js";import{p as Q,s as Z}from"../packem_shared/docker-B4zAZCZG.js";import{I as re}from"../packem_shared/index-BWl4DbMp.js";import{g as L}from"../packem_shared/en-BDYMmM2_.js";let Y;const J=e=>(Y??=K(import.meta.url))(e),g=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,y=e=>{if(typeof g<"u"&&g.versions&&g.versions.node){const[o,t]=g.versions.node.split(".").map(Number);if(o>22||o===22&&t>=3||o===20&&t>=16)return g.getBuiltinModule(e)}return J(e)},{createInterface:O}=y("node:readline"),{spawn:ee}=y("node:child_process"),{createHash:oe}=y("node:crypto"),{existsSync:T,writeFileSync:te,chmodSync:ne}=y("node:fs"),D={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:o,manager:t,nodeVersion:r}=e,n=D[t]??D.npm;return["# syntax=docker/dockerfile:1","","# Generated by 'vis docker init'. Before building, scaffold the context:",`# vis docker scaffold${o?` --focus=${o}`:""} --include-sources`,"# then build with BuildKit enabled (DOCKER_BUILDKIT=1).","",`FROM node:${r}-slim AS base`,"WORKDIR /app",...n.base,"","# --- install dependencies from the scaffolded manifests only ---","FROM base AS deps","COPY .vis/docker/workspace/ ./",n.install,"","# --- build the focus project, then drop unfocused workspace projects ---","FROM deps AS build","COPY .vis/docker/sources/ ./",n.build(o),"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",S=`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,o=process.arch)=>{const t=e==="darwin"?"macos":e==="linux"?"linux":e==="win32"?"windows":void 0;if(t===void 0)return;const r=o==="arm64"?"arm64":o==="x64"?"x86_64":void 0;if(t==="windows")return"hadolint-windows-x86_64.exe";if(r!==void 0)return`hadolint-${t}-${r}`},H=e=>h(L(),"hadolint",$,e.endsWith(".exe")?"hadolint.exe":"hadolint"),le=()=>{const e=process.platform==="win32"?"hadolint.exe":"hadolint",o=(process.env.PATH??"").split(process.platform==="win32"?";":":");for(const t of o)if(t!==""&&T(h(t,e)))return e},de=e=>e.trim().split(/\s+/u)[0]??"",C=async e=>{const o=await fetch(e,{redirect:"follow"});if(!o.ok)throw new Error(`download failed (${String(o.status)} ${o.statusText}) for ${e}`);return Buffer.from(await o.arrayBuffer())},ue=async e=>{const o=H(e),t=ae(e),r=await C(`${S}/${e}`),n=oe("sha256").update(r).digest("hex");if(t===void 0){const s=await C(`${S}/${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!==n)throw new Error(`hadolint checksum mismatch (expected ${i}, got ${n}). Refusing to use the download.`)}else if(t.toLowerCase()!==n)throw new Error(`hadolint checksum mismatch (expected ${t.toLowerCase()}, got ${n}). Refusing to use the download.`);return W(h(L(),"hadolint",$)),te(o,r),process.platform!=="win32"&&ne(o,493),o},fe=async()=>{const e=O({input:process.stdin,output:process.stderr}),o=await new Promise(t=>{e.question(` Download hadolint ${k($)} now? ${m("[y/N]")} `,r=>{t(r.trim().toLowerCase())})});return e.close(),o==="y"||o==="yes"},pe=async e=>{const{autoInstall:o=!1,log:t}=e,r=le();if(r!==void 0)return r;const n=ce();if(n===void 0){t(`hadolint has no prebuilt binary for ${process.platform}/${process.arch}. Install it manually: https://github.com/hadolint/hadolint`);return}const s=H(n);if(T(s))return s;if(!o){if(!(process.stdin.isTTY&&!re)){t(`hadolint is not installed. Re-run with ${b("--install")} (or install hadolint on PATH) to enable Dockerfile linting.`);return}if(t(`${b("hadolint")} is required to lint Dockerfiles but was not found on your PATH.`),!await fe()){t(`Skipped. Install it yourself or re-run with ${b("--install")}.`);return}}t(`Downloading hadolint ${$} (${n})…`);try{const i=await ue(n);return t(`Installed hadolint to ${m(i)}`),i}catch(i){t(`Failed to download hadolint: ${i.message}`);return}},_=async(e,o,t)=>{if(o.length===0)return[];const r=["--format","json","--no-fail",...t!==void 0&&t!==""?["--config",t]:[],...o],n=await new Promise((i,l)=>{const a=ee(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(n.trim()==="")return[];let s;try{s=JSON.parse(n)}catch{throw new Error("Could not parse hadolint JSON output.")}return Array.isArray(s)?s:[]},j=(e,o,t)=>{if(!(!/\bapt-get\b/u.test(e)||!/\binstall\b/u.test(e)||t.test(e)))return e.replace(/\binstall\b/u,`install ${o}`)},R={DL3014:e=>j(e,"-y",/(?:^|\s)(?:-y|--yes|--assume-yes|-qq?)\b/u),DL3015:e=>j(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},M=new Set(Object.keys(R)),me=(e,o)=>{const t=e.includes(`\r
3
3
  `)?`\r
4
4
  `:`
@@ -1,4 +1,4 @@
1
- import{I as O}from"../packem_shared/package-version-C47v64aB.js";import"../packem_shared/index-uBVnF4ji.js";import"../packem_shared/public-api-WqUCiyIe.js";import{g as P,b as K,d as W,U as Z,X as U,R as a,h as q,i as g,j as I,B as H,J as Q,G as p}from"./catalog.js";import{B as V}from"../packem_shared/en-D3CfXlO7.js";import{I as _}from"../packem_shared/index-BWl4DbMp.js";import{K as ee,Z as te,W as oe}from"../packem_shared/ai-analysis-bGCAc1jR.js";import{w as re,k as se,p as m,i as N}from"./cli-main.js";import{A as ne}from"../packem_shared/pm-runner-C6eTANt1.js";import{U as ie,b as ae,u as T}from"../packem_shared/vis-update-app-DMAC2pPf.js";const he=async({argument:C,logger:o,options:e,visConfig:i,workspaceRoot:R})=>{if(!R)throw new Error("Could not determine workspace root. Run this command inside a monorepo.");const d=R;if(e.securityConfig){const t=ne(d);if(re(i??{},t.name),e.sync&&t.name==="pnpm"){const r=se(i??{});if(r.length>0){m.info(`
1
+ import{I as O}from"../packem_shared/package-version-BNRJ3o9C.js";import"../packem_shared/index-BLtnel38.js";import"../packem_shared/index-tNFGWxc0.js";import{g as P,b as K,d as W,U as Z,X as U,R as a,h as q,i as g,j as I,B as H,J as Q,G as p}from"./catalog.js";import{B as V}from"../packem_shared/en-BDYMmM2_.js";import{I as _}from"../packem_shared/index-BWl4DbMp.js";import{K as ee,Z as te,W as oe}from"../packem_shared/ai-analysis-DikAj6rX.js";import{w as re,k as se,p as m,i as N}from"./cli-main.js";import{A as ne}from"../packem_shared/pm-runner-DRybtzOV.js";import{U as ie,b as ae,u as T}from"../packem_shared/vis-update-app-D6Wq8ZHM.js";const he=async({argument:C,logger:o,options:e,visConfig:i,workspaceRoot:R})=>{if(!R)throw new Error("Could not determine workspace root. Run this command inside a monorepo.");const d=R;if(e.securityConfig){const t=ne(d);if(re(i??{},t.name),e.sync&&t.name==="pnpm"){const r=se(i??{});if(r.length>0){m.info(`
2
2
  Settings that would sync to pnpm-workspace.yaml:`);for(const E of r)m.success(` ${E}`)}else m.info("No security settings to sync.")}else e.sync&&t.name!=="pnpm"&&(m.info(`--sync is only available for pnpm projects. Your project uses ${t.name}.`),m.info("vis enforces security settings at the vis layer for non-pnpm projects."));if(!e.security&&!C?.length)return}const{packageManager:B}=O(d),D=P(d),c=i?.update??{},y=K(d,B,{dev:e.dev,includeInternal:e["include-internal"],peer:e.peer,prod:e.prod});if(y.size===0){o.info("No catalogs found.");return}const $=e.target??c.target??"latest";if(!["latest","minor","patch"].includes($))throw new Error(`Invalid target "${$}". Use: latest, minor, or patch.`);const J={exclude:[...p(e.exclude),...p(c.exclude)],ignore:p(c.ignore),include:[...p(e.include),...p(c.include),...C],includeLocked:!!e.includeLocked,includePrerelease:e.prerelease||c.prerelease||!1,security:e.security!==!1,target:$};let x=0;for(const t of y.values())x+=t.size;const h=!!process.stdout.isTTY&&!_;let l;const M=h?(t,r)=>{l?l.rerender(a.createElement(T,{current:t,total:r})):l=U(a.createElement(T,{current:t,total:r}),{interactive:!0,patchConsole:!1})}:(t,r)=>{o.info(`Checking ${String(t)}/${String(r)} dependencies...`)};h||o.info(`Checking ${String(x)} catalog dependencies against npm registry...
3
3
  `);const w=new Set;N("socket")&&w.add("socket"),N("depsDev")&&w.add("deps-dev");const v=i?.security?.policies?.score?.minimum,z=W(i?.security,{disabled:w,minimumScore:v}),{failed:k,outdated:n}=await Z(y,J,D,M,d,z,i?.security?.acceptedRisks);if(l&&(l.clear(),l.unmount()),k.length>0&&o.warn(`Failed to fetch: ${k.join(", ")}`),n.length===0){o.info("All catalog dependencies are up to date.");return}const b=e.format??c.format??"table",A=ee(e.aiType??"impact"),u=e.ai?await te(n,o,i?.ai,A):void 0;if(h&&b==="table"){const t=new ie(n,u??null),r=i?.tui?.autoExit??!1,E=r===!0?3:typeof r=="number"?r:0;await U(a.createElement(ae,{autoExitSeconds:E,isDryRun:!0,store:t}),{alternateScreen:!0,exitOnCtrlC:!1,interactive:!0,patchConsole:!0}).waitUntilExit();const L=process.stdout.columns||80;process.stdout.write(`
4
4
  `);for(const s of n){const X=s.vulnerabilities?.length||s.socketReport&&s.socketReport.alerts.length>0,S=!!s.acceptedRisk,Y=X?S?"✓":"⚠":"✓",F=S?"gray":s.updateType==="major"?"red":s.updateType==="minor"?"yellow":"green",f=s.socketReport?.score.overall,G=f===void 0?"":` [${String(Math.round(f*100))}%]`,j=f===void 0?void 0:V(f);process.stdout.write(`${q(a.createElement(g,null," ",a.createElement(g,{color:F},Y),` ${s.packageName} ${s.currentRange} → ${s.newRange}`,a.createElement(g,{dimColor:!0},` ${s.updateType}`),j?a.createElement(g,{color:j},G):null),{columns:L})}
@@ -1,3 +1,3 @@
1
- import{createRequire as G}from"node:module";import{I as F,q as U,j as N,E as O}from"../packem_shared/index.server-CusjRLCh.js";import{b as E}from"../packem_shared/index-uBVnF4ji.js";import{P as D}from"./cli-main.js";import{d as A,f as C,r as Q,a as X,b as Y,s as Z,c as ee,e as te,g as se,h as re,i as ie,j as ne,k as oe,l as ae,m as de,n as ce,o as fe,p as le,q as pe,t as ue}from"../packem_shared/watch-loop-Q7UpkVbr.js";import{n as h}from"./catalog.js";let H;const I=t=>(H??=G(import.meta.url))(t),k=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,L=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 I(t)},{createHash:_}=L("node:crypto"),ge=t=>t.startsWith("/")||/^[a-z]:[\\/]/i.test(t),q=(t,e)=>ge(e)?e:`${t}/${e}`,me={argsCheck:(t,e)=>P(t,e,"check"),argsFix:(t,e)=>P(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=A(e,h.dprint.packageNames[0]),r=C(t,h.dprint.configFiles);if(!(!s&&!r))return{adapter:"dprint",configFile:r,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 r of t.stdout.split(/\r?\n/)){const i=r.trim();!i||i.startsWith("[")||i.startsWith("Checked ")||i.startsWith("Error:")||s.push({adapter:"dprint",file:q(e.root,i),fixable:!0,message:"Code style issues would be auto-fixed",severity:"info"})}return s}},P=(t,e,s)=>{const r=s==="fix"?["fmt"]:["check","--list-different"];return e.extraArgs?.length&&r.push(...e.extraArgs),r.push(...t),r},he={argsCheck:(t,e)=>T(t,e,"check"),argsFix:(t,e)=>T(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=A(e,h.oxfmt.packageNames[0]),r=C(t,h.oxfmt.configFiles);if(!(!s&&!r))return{adapter:"oxfmt",configFile:r,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 r of t.stdout.split(/\r?\n/)){const i=r.trim();!i||i.startsWith("[")||s.push({adapter:"oxfmt",file:q(e.root,i),fixable:!0,message:"Code style issues would be auto-fixed",severity:"info"})}return s}},T=(t,e,s)=>{const r=s==="fix"?["--write"]:["--list-different"];return e.extraArgs?.length&&r.push(...e.extraArgs),r.push(...t),r},xe={argsCheck:(t,e)=>B(t,e,"check"),argsFix:(t,e)=>B(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=A(e,h.prettier.packageNames[0]),r=C(t,h.prettier.configFiles);if(!(!s&&!r))return{adapter:"prettier",configFile:r,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 r of t.stdout.split(/\r?\n/)){const i=r.trim();i&&(i.startsWith("[")||s.push({adapter:"prettier",file:q(e.root,i),fixable:!0,message:"Code style issues would be auto-fixed",severity:"info"}))}return s}},B=(t,e,s)=>{const r=s==="fix"?["--write"]:["--list-different"];return e.quiet&&r.push("--log-level","warn"),e.extraArgs?.length&&r.push(...e.extraArgs),r.push(...t),r},ke=[he,ce,me,xe,fe,le],qe=async({logger:t,options:e,visConfig:s,workspaceRoot:r})=>{const i=r??process.cwd(),u=s?.fmt,w=Q(ke,u?.order),K=X(i,w),x=Y(K,w,"fmt").filter(({adapter:l})=>u?.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 o=u?.adapters?.[l]?.extraArgs;return o&&o.length>0?[...o]:void 0},y={quiet:e.quiet??!1},$=we(e),b=e.check?"check":"fix";let d;if(e.staged){if(d=Z(i),d===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(d.length===0){t.info(F("✓ fmt: no staged files"));return}}else if(typeof e.since=="string"&&e.since.length>0){if(d=ee(i,e.since),d===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(d.length===0){t.info(F(`✓ fmt: no files changed since ${e.since}`));return}}const z=D(i,void 0,void 0,!0),v=e.format??"human";v==="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 o=$.length>0?$:l,g=[];if(o){const n=se(o,x,u?.extensionOverrides);for(const{adapter:a,presence:c}of x){const f=n.get(a.id);if(!f||f.length===0)continue;const W=R(a.id),V={adapter:a,files:f,presence:c};W&&(V.options={...y,extraArgs:W}),g.push(V)}}else for(const{adapter:n,presence:a}of x){const c=R(n.id),f={adapter:n,files:["."],presence:a};c&&(f.options={...y,extraArgs:c}),g.push(f)}if(g.length===0)return;const J=await re(g,y,b,{cacheRoot:z}),j=g.map((n,a)=>{const c=J[a],f=n.adapter.parse(c,n.presence);return{adapter:n.adapter,durationMs:c.durationMs,exitCode:c.exitCode,findings:f}}),p=ie(j.map(n=>({adapter:n.adapter.id,durationMs:n.durationMs,exitCode:n.exitCode,findingCount:n.findings.length,findings:n.findings}))),m=v==="human"?void 0:ne({cwd:i,target:e.output});try{switch(v){case"github":{m.write(de({runs:j.map(n=>({findings:n.findings})),workspaceRoot:i}));break}case"json":{m.write(`${JSON.stringify({findings:p.findings,mode:b,runs:p.runs},null,2)}
1
+ import{createRequire as G}from"node:module";import{I as F,q as U,j as N,E as O}from"../packem_shared/index.server-CusjRLCh.js";import{b as E}from"../packem_shared/index-BLtnel38.js";import{P as D}from"./cli-main.js";import{d as A,f as C,r as Q,a as X,b as Y,s as Z,c as ee,e as te,g as se,h as re,i as ie,j as ne,k as oe,l as ae,m as de,n as ce,o as fe,p as le,q as pe,t as ue}from"../packem_shared/watch-loop-BrjblOz5.js";import{n as h}from"./catalog.js";let H;const I=t=>(H??=G(import.meta.url))(t),k=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,L=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 I(t)},{createHash:_}=L("node:crypto"),ge=t=>t.startsWith("/")||/^[a-z]:[\\/]/i.test(t),q=(t,e)=>ge(e)?e:`${t}/${e}`,me={argsCheck:(t,e)=>P(t,e,"check"),argsFix:(t,e)=>P(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=A(e,h.dprint.packageNames[0]),r=C(t,h.dprint.configFiles);if(!(!s&&!r))return{adapter:"dprint",configFile:r,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 r of t.stdout.split(/\r?\n/)){const i=r.trim();!i||i.startsWith("[")||i.startsWith("Checked ")||i.startsWith("Error:")||s.push({adapter:"dprint",file:q(e.root,i),fixable:!0,message:"Code style issues would be auto-fixed",severity:"info"})}return s}},P=(t,e,s)=>{const r=s==="fix"?["fmt"]:["check","--list-different"];return e.extraArgs?.length&&r.push(...e.extraArgs),r.push(...t),r},he={argsCheck:(t,e)=>T(t,e,"check"),argsFix:(t,e)=>T(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=A(e,h.oxfmt.packageNames[0]),r=C(t,h.oxfmt.configFiles);if(!(!s&&!r))return{adapter:"oxfmt",configFile:r,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 r of t.stdout.split(/\r?\n/)){const i=r.trim();!i||i.startsWith("[")||s.push({adapter:"oxfmt",file:q(e.root,i),fixable:!0,message:"Code style issues would be auto-fixed",severity:"info"})}return s}},T=(t,e,s)=>{const r=s==="fix"?["--write"]:["--list-different"];return e.extraArgs?.length&&r.push(...e.extraArgs),r.push(...t),r},xe={argsCheck:(t,e)=>B(t,e,"check"),argsFix:(t,e)=>B(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=A(e,h.prettier.packageNames[0]),r=C(t,h.prettier.configFiles);if(!(!s&&!r))return{adapter:"prettier",configFile:r,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 r of t.stdout.split(/\r?\n/)){const i=r.trim();i&&(i.startsWith("[")||s.push({adapter:"prettier",file:q(e.root,i),fixable:!0,message:"Code style issues would be auto-fixed",severity:"info"}))}return s}},B=(t,e,s)=>{const r=s==="fix"?["--write"]:["--list-different"];return e.quiet&&r.push("--log-level","warn"),e.extraArgs?.length&&r.push(...e.extraArgs),r.push(...t),r},ke=[he,ce,me,xe,fe,le],qe=async({logger:t,options:e,visConfig:s,workspaceRoot:r})=>{const i=r??process.cwd(),u=s?.fmt,w=Q(ke,u?.order),K=X(i,w),x=Y(K,w,"fmt").filter(({adapter:l})=>u?.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 o=u?.adapters?.[l]?.extraArgs;return o&&o.length>0?[...o]:void 0},y={quiet:e.quiet??!1},$=we(e),b=e.check?"check":"fix";let d;if(e.staged){if(d=Z(i),d===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(d.length===0){t.info(F("✓ fmt: no staged files"));return}}else if(typeof e.since=="string"&&e.since.length>0){if(d=ee(i,e.since),d===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(d.length===0){t.info(F(`✓ fmt: no files changed since ${e.since}`));return}}const z=D(i,void 0,void 0,!0),v=e.format??"human";v==="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 o=$.length>0?$:l,g=[];if(o){const n=se(o,x,u?.extensionOverrides);for(const{adapter:a,presence:c}of x){const f=n.get(a.id);if(!f||f.length===0)continue;const W=R(a.id),V={adapter:a,files:f,presence:c};W&&(V.options={...y,extraArgs:W}),g.push(V)}}else for(const{adapter:n,presence:a}of x){const c=R(n.id),f={adapter:n,files:["."],presence:a};c&&(f.options={...y,extraArgs:c}),g.push(f)}if(g.length===0)return;const J=await re(g,y,b,{cacheRoot:z}),j=g.map((n,a)=>{const c=J[a],f=n.adapter.parse(c,n.presence);return{adapter:n.adapter,durationMs:c.durationMs,exitCode:c.exitCode,findings:f}}),p=ie(j.map(n=>({adapter:n.adapter.id,durationMs:n.durationMs,exitCode:n.exitCode,findingCount:n.findings.length,findings:n.findings}))),m=v==="human"?void 0:ne({cwd:i,target:e.output});try{switch(v){case"github":{m.write(de({runs:j.map(n=>({findings:n.findings})),workspaceRoot:i}));break}case"json":{m.write(`${JSON.stringify({findings:p.findings,mode:b,runs:p.runs},null,2)}
2
2
  `);break}case"junit":{m.write(ae({runs:j.map(n=>({adapter:n.adapter.id,durationMs:n.durationMs,findings:n.findings})),workspaceRoot:i}));break}case"minimal":{je(p.findings,i,m);break}case"sarif":{m.write(oe({runs:j.map(n=>({adapter:n.adapter.id,findings:n.findings,presence:g.find(a=>a.adapter.id===n.adapter.id)?.presence})),workspaceRoot:i}));break}default:be(p.findings,i,b,t)}}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(e.watch){const l=[...new Set(x.flatMap(({adapter:o})=>o.extensions))];await te({extensions:l,initialFiles:d,label:"fmt",log:o=>{t.info(o)},runCycle:M,workspaceRoot:i});return}await M(d)},we=t=>{const e=t;return[...e._??e.args??[]]},be=(t,e,s,r)=>{if(t.length===0){r.info(F(s==="fix"?"✓ fmt: nothing to change":"✓ fmt: all files already formatted"));return}const i=pe(t),u=s==="fix"?U(N("Formatted:")):N("Would change:");r.info(u);for(const w of i.keys())r.info(` ${O("·")} ${E(e,w)}`);s==="check"&&(r.info(""),r.info(O(`Run \`vis fmt\` to apply changes (${String(i.size)} file${i.size===1?"":"s"}).`)))},je=(t,e,s)=>{for(const r of t)s.write(`${r.adapter} ${E(e,r.file)}
3
3
  `)};export{qe as default};
@@ -1,4 +1,4 @@
1
- import{createRequire as te}from"node:module";import{E as u,j as g,q as y}from"../packem_shared/index.server-CusjRLCh.js";import{w as S,l as N,c as G,J as H,b as J,d as K,v as P,a as ne,j as oe,P as ie}from"../packem_shared/index-uBVnF4ji.js";import{f as pe}from"../packem_shared/giget-CAxjpwew.js";import{p as l}from"./cli-main.js";let re;const se=t=>(re??=te(import.meta.url))(t),R=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,E=t=>{if(typeof R<"u"&&R.versions&&R.versions.node){const[e,r]=R.versions.node.split(".").map(Number);if(e>22||e===22&&r>=3||e===20&&r>=16)return R.getBuiltinModule(t)}return se(t)},{fileURLToPath:ae}=E("node:url"),{createInterface:ce}=E("node:readline"),{mkdtempSync:le,rmSync:fe}=E("node:fs"),{tmpdir:ue}=E("node:os"),{spawnSync:de}=E("node:child_process"),L=[".ts",".mts",".cts",".js",".mjs",".cjs"],me="template.yml",he=[".d",".test",".spec",".config",".bench",".stories"],we=[".d.ts",".d.mts",".d.cts",".js.map",".mjs.map",".cjs.map",".ts.map"],Y=t=>{for(const e of L)if(t.endsWith(e))return t.slice(0,-e.length);return t},$e=t=>{if(we.some(r=>t.endsWith(r))||!L.some(r=>t.endsWith(r)))return!1;const e=Y(t);return!he.some(r=>e.endsWith(r))},U=(t,e)=>{const r=[];if(!N(t))return r;for(const s of G(t,{includeDirs:!1,includeSymlinks:!1,maxDepth:1})){if(!$e(s.name))continue;const n=Y(s.name);r.push({load:()=>ye(s.path),name:n,path:s.path,source:e})}return r},x=(t,e)=>{const r=[];if(!N(t))return r;for(const s of G(t,{includeFiles:!1,includeSymlinks:!1,maxDepth:1})){if(s.path===t)continue;const n=S(s.path,me);N(n)&&r.push({load:()=>ve(s.path,s.name),name:s.name,path:s.path,source:e})}return r},ge=()=>{try{const t=ae(import.meta.url),e=S(H(t),"..","..","templates");return N(e)?e:void 0}catch{return}},q=t=>{const{extraDirectories:e=[],onWarning:r,workspaceRoot:s}=t,n=[...U(S(s,".vis","templates"),"native"),...x(S(s,".vis","templates"),"moon"),...x(S(s,".moon","templates"),"moon")];for(const o of e)n.push(...x(o,"config")),n.push(...U(o,"config"));const i=ge();i&&n.push(...x(i,"builtin"));const a=new Map;for(const o of n){const c=a.get(o.name);if(!c){a.set(o.name,o);continue}r&&r(`Template "${o.name}" exists in multiple sources — using ${c.source} (${c.path}), ignoring ${o.source} (${o.path}).`)}return[...a.values()].sort((o,c)=>o.name.localeCompare(c.name))},ye=async t=>{const{loadNativeTemplate:e}=await import("./loader2.js");return e(t)},ve=async(t,e)=>{const{loadMoonTemplate:r}=await import("./index3.js");return r(t,e)},D=(t,e)=>new Promise(r=>{t.question(e,s=>{r(s.trim())})}),be=async(t,e,r)=>{const s=await D(t,` ${e} ${u(r?"[Y/n]":"[y/N]")} `);return s===""?r:s.toLowerCase()==="y"||s.toLowerCase()==="yes"},Se=async(t,e,r,s)=>{process.stderr.write(` ${e}
1
+ import{createRequire as te}from"node:module";import{E as u,j as g,q as y}from"../packem_shared/index.server-CusjRLCh.js";import{w as S,l as N,e as G,J as H,b as J,d as K,v as P,c as ne,j as oe,P as ie}from"../packem_shared/index-BLtnel38.js";import{f as pe}from"../packem_shared/giget-CAxjpwew.js";import{p as l}from"./cli-main.js";let re;const se=t=>(re??=te(import.meta.url))(t),R=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,E=t=>{if(typeof R<"u"&&R.versions&&R.versions.node){const[e,r]=R.versions.node.split(".").map(Number);if(e>22||e===22&&r>=3||e===20&&r>=16)return R.getBuiltinModule(t)}return se(t)},{fileURLToPath:ae}=E("node:url"),{createInterface:ce}=E("node:readline"),{mkdtempSync:le,rmSync:fe}=E("node:fs"),{tmpdir:ue}=E("node:os"),{spawnSync:de}=E("node:child_process"),L=[".ts",".mts",".cts",".js",".mjs",".cjs"],me="template.yml",he=[".d",".test",".spec",".config",".bench",".stories"],we=[".d.ts",".d.mts",".d.cts",".js.map",".mjs.map",".cjs.map",".ts.map"],Y=t=>{for(const e of L)if(t.endsWith(e))return t.slice(0,-e.length);return t},$e=t=>{if(we.some(r=>t.endsWith(r))||!L.some(r=>t.endsWith(r)))return!1;const e=Y(t);return!he.some(r=>e.endsWith(r))},U=(t,e)=>{const r=[];if(!N(t))return r;for(const s of G(t,{includeDirs:!1,includeSymlinks:!1,maxDepth:1})){if(!$e(s.name))continue;const n=Y(s.name);r.push({load:()=>ye(s.path),name:n,path:s.path,source:e})}return r},x=(t,e)=>{const r=[];if(!N(t))return r;for(const s of G(t,{includeFiles:!1,includeSymlinks:!1,maxDepth:1})){if(s.path===t)continue;const n=S(s.path,me);N(n)&&r.push({load:()=>ve(s.path,s.name),name:s.name,path:s.path,source:e})}return r},ge=()=>{try{const t=ae(import.meta.url),e=S(H(t),"..","..","templates");return N(e)?e:void 0}catch{return}},q=t=>{const{extraDirectories:e=[],onWarning:r,workspaceRoot:s}=t,n=[...U(S(s,".vis","templates"),"native"),...x(S(s,".vis","templates"),"moon"),...x(S(s,".moon","templates"),"moon")];for(const o of e)n.push(...x(o,"config")),n.push(...U(o,"config"));const i=ge();i&&n.push(...x(i,"builtin"));const a=new Map;for(const o of n){const c=a.get(o.name);if(!c){a.set(o.name,o);continue}r&&r(`Template "${o.name}" exists in multiple sources — using ${c.source} (${c.path}), ignoring ${o.source} (${o.path}).`)}return[...a.values()].sort((o,c)=>o.name.localeCompare(c.name))},ye=async t=>{const{loadNativeTemplate:e}=await import("./loader2.js");return e(t)},ve=async(t,e)=>{const{loadMoonTemplate:r}=await import("./index3.js");return r(t,e)},D=(t,e)=>new Promise(r=>{t.question(e,s=>{r(s.trim())})}),be=async(t,e,r)=>{const s=await D(t,` ${e} ${u(r?"[Y/n]":"[y/N]")} `);return s===""?r:s.toLowerCase()==="y"||s.toLowerCase()==="yes"},Se=async(t,e,r,s)=>{process.stderr.write(` ${e}
2
2
  `);for(const[n,i]of r.entries()){const a=g(y(` ${String(n+1)}.`)),o=i===s?u(" (default)"):"";process.stderr.write(`${a} ${i}${o}
3
3
  `)}for(;;){const n=await D(t,`
4
4
  ${u(`Enter choice (1-${String(r.length)}):`)} `);if(n===""&&s!==void 0)return s;const i=Number.parseInt(n,10);if(Number.isInteger(i)&&i>=1&&i<=r.length)return r[i-1];const a=r.find(o=>o===n);if(a)return a;process.stderr.write(` ${u("Invalid choice. Try again.")}
@@ -1,4 +1,4 @@
1
- import{z as F,J as P,b as S,w as b,j as I,q as U,d as T}from"../packem_shared/index-uBVnF4ji.js";import _ from"./index.js";import{v as J,k as q}from"./catalog.js";import{n as M}from"../packem_shared/manifests-BDkwiVbh.js";import{Q as C,T as B}from"./cli-main.js";import{s as z}from"../packem_shared/glob-BUjyjdE8-C4M8e02u.js";const K=(e,t)=>{const o=t.replace(/^\.?\//,"");return o===""||o==="."?`/${e}/`:e===""||e==="."?`/${o}`:`/${e}/${o}`},v=(e,t,o=[])=>{const s=[],n=new Set;for(const[r,a]of Object.entries(t?.globalPaths??{}))s.push({owners:a,path:r,source:"project-json"}),n.add(r);for(const[r,a]of Object.entries(e.projects)){const i=a.owners??[];for(const c of i){const f=K(a.root??r,c.path);s.push({channel:c.channel,owners:c.owners,path:f,projectId:r,source:"project-json"}),n.add(f)}}for(const r of o)n.has(r.path)||(s.push(r),n.add(r.path));return(t?.orderBy??"file-source")==="project-id"?s.sort((r,a)=>(r.projectId??"").localeCompare(a.projectId??"")||r.path.localeCompare(a.path)):s.sort((r,a)=>r.path.localeCompare(a.path)),s},H="Update each project's project.json `owners` field and re-run the command.",Q=e=>["# CODEOWNERS — generated by `vis sync codeowners`. Do not edit by hand.",e?`# Re-run with: ${e}`:`# ${H}`,""],W=e=>{const t=[];for(const o of e){const s=o.owners.join(" "),n=o.channel?` # notify: ${o.channel}`:"";t.push(`${o.path} ${s}${n}`)}return t},Y=(e,t={})=>[...Q(t.regenerationCommand),...W(e),""].join(`
1
+ import{z as F,J as P,b as S,w as b,j as I,q as U,d as T}from"../packem_shared/index-BLtnel38.js";import _ from"./index.js";import{v as J,k as q}from"./catalog.js";import{n as M}from"../packem_shared/manifests-BwTn_1ad.js";import{Q as C,T as B}from"./cli-main.js";import{s as z}from"../packem_shared/glob-BUjyjdE8-Dp_QcayW.js";const K=(e,t)=>{const o=t.replace(/^\.?\//,"");return o===""||o==="."?`/${e}/`:e===""||e==="."?`/${o}`:`/${e}/${o}`},v=(e,t,o=[])=>{const s=[],n=new Set;for(const[r,a]of Object.entries(t?.globalPaths??{}))s.push({owners:a,path:r,source:"project-json"}),n.add(r);for(const[r,a]of Object.entries(e.projects)){const i=a.owners??[];for(const c of i){const f=K(a.root??r,c.path);s.push({channel:c.channel,owners:c.owners,path:f,projectId:r,source:"project-json"}),n.add(f)}}for(const r of o)n.has(r.path)||(s.push(r),n.add(r.path));return(t?.orderBy??"file-source")==="project-id"?s.sort((r,a)=>(r.projectId??"").localeCompare(a.projectId??"")||r.path.localeCompare(a.path)):s.sort((r,a)=>r.path.localeCompare(a.path)),s},H="Update each project's project.json `owners` field and re-run the command.",Q=e=>["# CODEOWNERS — generated by `vis sync codeowners`. Do not edit by hand.",e?`# Re-run with: ${e}`:`# ${H}`,""],W=e=>{const t=[];for(const o of e){const s=o.owners.join(" "),n=o.channel?` # notify: ${o.channel}`:"";t.push(`${o.path} ${s}${n}`)}return t},Y=(e,t={})=>[...Q(t.regenerationCommand),...W(e),""].join(`
2
2
  `),O={begin:"# BEGIN vis-codeowners",end:"# END vis-codeowners"},V=(e,t=O,o={})=>{const s=o.regenerationCommand?`# Generated by vis sync codeowners — re-run with: ${o.regenerationCommand}`:"# Generated by `vis sync codeowners` — do not edit by hand.";return[t.begin,s,...W(e),t.end].join(`
3
3
  `)},X=(e,t,o=O)=>{const s=e.indexOf(o.begin),n=e.indexOf(o.end);if(s!==-1&&n!==-1&&n>s){const a=e.slice(0,s),i=n+o.end.length,c=e.slice(i);return`${a}${t}${c}`}const r=e.replace(/\s+$/u,"");return`${r.length===0?"":`${r}
4
4
 
@@ -1,3 +1,3 @@
1
- import{createRequire as G}from"node:module";import{I as q,j as Q,E as O,V as K,s as T,q as X}from"../packem_shared/index.server-CusjRLCh.js";import{b as B}from"../packem_shared/index-uBVnF4ji.js";import{P as Y}from"./cli-main.js";import{d as k,f as v,r as Z,a as ee,b as ne,s as te,c as ie,e as re,u as se,h as oe,i as ae,j as le,k as ce,l as de,m as ue,n as fe,v as ge,w as pe,q as me,t as he}from"../packem_shared/watch-loop-Q7UpkVbr.js";import{n as c}from"./catalog.js";let H;const U=e=>(H??=G(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[n,t]=w.versions.node.split(".").map(Number);if(n>22||n===22&&t>=3||n===20&&t>=16)return w.getBuiltinModule(e)}return U(e)},{createHash:y}=D("node:crypto"),xe={1:"warning",2:"error"},we={argsCheck:(e,n)=>V(e,n,!1),argsFix:(e,n)=>V(e,n,!0),bin:()=>["pnpm","exec","eslint"],cacheKey:(e,n)=>{const t=["eslint",e.declaredVersion??"unknown",e.configFile??"no-config",n.maxWarnings===void 0?"":`mw=${n.maxWarnings}`,n.quiet?"q":"",...n.extraArgs??[]];return y("sha256").update(t.join("|")).digest("hex").slice(0,16)},detect:(e,n)=>{const t=k(n,c.eslint.packageNames[0]),i=v(e,c.eslint.configFiles);if(!(!t&&!i))return{adapter:"eslint",configFile:i,declared:!!t,declaredVersion:t,root:e}},extensions:["cjs","cts","js","jsx","mjs","mts","ts","tsx","vue"],id:"eslint",kind:"lint",parse:(e,n)=>{if(!e.stdout.trim())return[];let t;try{t=JSON.parse(e.stdout)}catch{return[{adapter:"eslint",file:n.root,fixable:!1,message:`eslint output was not valid JSON (exit ${e.exitCode})`,severity:"error"}]}const i=[];for(const r of t)for(const s of r.messages)i.push({adapter:"eslint",column:s.column,endColumn:s.endColumn,endLine:s.endLine,file:r.filePath,fixable:!!s.fix,line:s.line,message:s.message,ruleId:s.ruleId??void 0,severity:s.fatal?"error":xe[s.severity]??"warning"});return i}},V=(e,n,t)=>{const i=["--format","json","--no-error-on-unmatched-pattern"];return t&&i.push("--fix"),n.quiet&&i.push("--quiet"),typeof n.maxWarnings=="number"&&i.push("--max-warnings",String(n.maxWarnings)),n.extraArgs?.length&&i.push(...n.extraArgs),i.push(...e),i},ke=/^([^:]+):(\d+)(?::(\d+))?\s+([\w/-]+)\s+(.+)$/,ve=e=>{const n=ke.exec(e);if(!n)return;const[,t,i,r,s,a]=n;return{column:r===void 0?void 0:Number(r),file:t,line:Number(i),message:a,ruleId:s}},ye=e=>e.startsWith("/")||/^[a-z]:[\\/]/i.test(e),be={argsCheck:(e,n)=>J(e,n,!1),argsFix:(e,n)=>J(e,n,!0),bin:()=>["pnpm","exec","markdownlint-cli2"],cacheKey:(e,n)=>{const t=["markdownlint",e.declaredVersion??"unknown",e.configFile??"no-config",n.maxWarnings===void 0?"":`mw=${n.maxWarnings}`,n.quiet?"q":"",...n.extraArgs??[]];return y("sha256").update(t.join("|")).digest("hex").slice(0,16)},detect:(e,n)=>{const t=c.markdownlint.packageNames.map(r=>k(n,r)).find(r=>r!==void 0),i=v(e,c.markdownlint.configFiles);if(!(!t&&!i))return{adapter:"markdownlint",configFile:i,declared:!!t,declaredVersion:t,root:e}},extensions:["markdown","md"],id:"markdownlint",kind:"lint",parse:(e,n)=>{const t=(e.stderr||e.stdout||"").trim();if(!t)return[];const i=[];for(const r of t.split(/\r?\n/)){const s=ve(r.trim());s&&i.push({adapter:"markdownlint",column:s.column,file:ye(s.file)?s.file:`${n.root}/${s.file}`,fixable:!0,line:s.line,message:s.message,ruleId:s.ruleId,severity:"warning"})}return i}},J=(e,n,t)=>{const i=[];return t&&i.push("--fix"),n.extraArgs?.length&&i.push(...n.extraArgs),e.length===0?i.push("**/*.md"):i.push(...e),i},$e={advice:"info",error:"error",warning:"warning"},Ae={argsCheck:(e,n)=>R(e,n,!1),argsFix:(e,n)=>R(e,n,!0),bin:()=>["pnpm","exec","oxlint"],cacheKey:(e,n)=>{const t=["oxlint",e.declaredVersion??"unknown",e.configFile??"no-config",n.maxWarnings===void 0?"":`mw=${n.maxWarnings}`,n.quiet?"q":"",...n.extraArgs??[]];return y("sha256").update(t.join("|")).digest("hex").slice(0,16)},detect:(e,n)=>{const t=k(n,c.oxlint.packageNames[0]),i=v(e,c.oxlint.configFiles);if(!(!t&&!i))return{adapter:"oxlint",configFile:i,declared:!!t,declaredVersion:t,root:e}},extensions:["astro","cjs","cts","js","jsx","mjs","mts","svelte","ts","tsx","vue"],id:"oxlint",kind:"lint",parse:(e,n)=>{if(!e.stdout.trim())return[];let t;try{t=JSON.parse(e.stdout)}catch{return[{adapter:"oxlint",file:n.root,fixable:!1,message:`oxlint output was not valid JSON (exit ${e.exitCode})`,severity:"error"}]}const i=[];for(const r of t.diagnostics??[]){const s=r.labels?.[0]?.span;i.push({adapter:"oxlint",column:s?.column,file:r.filename??n.root,fixable:!1,line:s?.line,message:r.message??"",ruleId:r.code,severity:$e[r.severity??""]??"warning"})}return i}},R=(e,n,t)=>{const i=["--format","json"];return t&&i.push("--fix"),n.quiet&&i.push("--quiet"),typeof n.maxWarnings=="number"&&i.push(`--max-warnings=${String(n.maxWarnings)}`),n.extraArgs?.length&&i.push(...n.extraArgs),i.push(...e),i},Fe={error:"error",info:"info",style:"info",warning:"warning"},je=e=>e.startsWith("/")||/^[a-z]:[\\/]/i.test(e),Ce=(e,n)=>e?je(e)?e:`${n}/${e}`:n,Se={argsCheck:(e,n)=>L(e,n),argsFix:(e,n)=>L(e,n),bin:()=>["shellcheck"],cacheKey:(e,n)=>{const t=["shellcheck",e.declaredVersion??"unknown",e.configFile??"no-config",n.quiet?"q":"",...n.extraArgs??[]];return y("sha256").update(t.join("|")).digest("hex").slice(0,16)},detect:(e,n)=>{const t=k(n,c.shellcheck.packageNames[0]),i=v(e,c.shellcheck.configFiles);if(!(!t&&!i))return{adapter:"shellcheck",configFile:i,declared:!!t,declaredVersion:t,root:e}},extensions:["bash","ksh","sh"],id:"shellcheck",kind:"lint",parse:(e,n)=>{if(!e.stdout.trim())return[];let t;try{t=JSON.parse(e.stdout)}catch{return[{adapter:"shellcheck",file:n.root,fixable:!1,message:`shellcheck output was not valid JSON (exit ${e.exitCode})`,severity:"error"}]}const i=[];for(const r of t.comments??[])i.push({adapter:"shellcheck",column:r.column,endColumn:r.endColumn,endLine:r.endLine,file:Ce(r.file,n.root),fixable:!!r.fix,line:r.line,message:r.message??"",ruleId:r.code===void 0?void 0:`SC${String(r.code)}`,severity:Fe[r.level??""]??"warning"});return i}},L=(e,n)=>{const t=["--format=json1"];return n.extraArgs?.length&&t.push(...n.extraArgs),t.push(...e),t},qe={error:"error",warning:"warning"},We={argsCheck:(e,n)=>M(e,n,!1),argsFix:(e,n)=>M(e,n,!0),bin:()=>["pnpm","exec","stylelint"],cacheKey:(e,n)=>{const t=["stylelint",e.declaredVersion??"unknown",e.configFile??"no-config",n.maxWarnings===void 0?"":`mw=${n.maxWarnings}`,n.quiet?"q":"",...n.extraArgs??[]];return y("sha256").update(t.join("|")).digest("hex").slice(0,16)},detect:(e,n)=>{const t=k(n,c.stylelint.packageNames[0]),i=v(e,c.stylelint.configFiles);if(!(!t&&!i))return{adapter:"stylelint",configFile:i,declared:!!t,declaredVersion:t,root:e}},extensions:["astro","css","less","sass","scss","svelte","vue"],id:"stylelint",kind:"lint",parse:(e,n)=>{if(!e.stdout.trim())return[];let t;try{t=JSON.parse(e.stdout)}catch{return[{adapter:"stylelint",file:n.root,fixable:!1,message:`stylelint output was not valid JSON (exit ${e.exitCode})`,severity:"error"}]}const i=[];for(const r of t)for(const s of r.warnings??[])i.push({adapter:"stylelint",column:s.column,endColumn:s.endColumn,endLine:s.endLine,file:r.source,fixable:!1,line:s.line,message:s.text??"",ruleId:s.rule,severity:qe[s.severity??""]??"warning"});return i}},M=(e,n,t)=>{const i=["--formatter","json"];return t&&i.push("--fix"),n.quiet&&i.push("--quiet"),typeof n.maxWarnings=="number"&&i.push("--max-warnings",String(n.maxWarnings)),n.extraArgs?.length&&i.push(...n.extraArgs),i.push(...e),i},Ne=[Ae,fe,we,We,ge,be,Se,pe],Pe=async({logger:e,options:n,visConfig:t,workspaceRoot:i})=>{const r=i??process.cwd(),s=t?.lint,a=Z(Ne,s?.order),j=ee(r,a),d=ne(j,a,"lint").filter(({adapter:l})=>s?.adapters?.[l.id]?.enabled!==!1);if(d.length===0){e.warn("vis lint: no linter detected in this workspace (looked for: oxlint, biome, eslint, stylelint, ruff, markdownlint, shellcheck, deno).");return}const C=l=>{const u=s?.adapters?.[l]?.extraArgs;return u&&u.length>0?[...u]:void 0},b={extraArgs:void 0,maxWarnings:typeof n.maxWarnings=="number"?n.maxWarnings:void 0,quiet:n.quiet??!1},$=_e(n),P=n.fix?"fix":"check";let f;if(n.staged){if(f=te(r),f===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(f.length===0){e.info(q("✓ lint: no staged files"));return}}else if(typeof n.since=="string"&&n.since.length>0){if(f=ie(r,n.since),f===void 0)e.warn(`vis lint: could not resolve --since ${n.since} (not a git repo or unknown ref). Falling back to a workspace-wide run.`);else if(f.length===0){e.info(q(`✓ lint: no files changed since ${n.since}`));return}}const W=$.length>0?$:void 0,E=Y(r,void 0,void 0,!0),S=n.format??"human";S==="human"&&n.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 N=async l=>{const u=l!==void 0&&l.length>0&&W===void 0,m=[];for(const{adapter:o,presence:x}of d){let g;if(u){if(g=se(l,o.extensions),g.length===0)continue}else g=W??l??["."];const F=C(o.id),I={adapter:o,files:g,presence:x};F&&(I.options={...b,extraArgs:F}),m.push(I)}if(m.length===0)return;const z=await oe(m,b,P,{cacheRoot:E}),A=m.map((o,x)=>{const g=z[x],F=o.adapter.parse(g,o.presence);return{adapter:o.adapter,durationMs:g.durationMs,exitCode:g.exitCode,findings:F}}),h=ae(A.map(o=>({adapter:o.adapter.id,durationMs:o.durationMs,exitCode:o.exitCode,findingCount:o.findings.length,findings:o.findings}))),p=S==="human"?void 0:le({cwd:r,target:n.output});try{switch(S){case"github":{p.write(ue({runs:A.map(o=>({findings:o.findings})),workspaceRoot:r}));break}case"json":{p.write(`${JSON.stringify({findings:h.findings,runs:h.runs},null,2)}
1
+ import{createRequire as G}from"node:module";import{I as q,j as Q,E as O,V as K,s as T,q as X}from"../packem_shared/index.server-CusjRLCh.js";import{b as B}from"../packem_shared/index-BLtnel38.js";import{P as Y}from"./cli-main.js";import{d as k,f as v,r as Z,a as ee,b as ne,s as te,c as ie,e as re,u as se,h as oe,i as ae,j as le,k as ce,l as de,m as ue,n as fe,v as ge,w as pe,q as me,t as he}from"../packem_shared/watch-loop-BrjblOz5.js";import{n as c}from"./catalog.js";let H;const U=e=>(H??=G(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[n,t]=w.versions.node.split(".").map(Number);if(n>22||n===22&&t>=3||n===20&&t>=16)return w.getBuiltinModule(e)}return U(e)},{createHash:y}=D("node:crypto"),xe={1:"warning",2:"error"},we={argsCheck:(e,n)=>V(e,n,!1),argsFix:(e,n)=>V(e,n,!0),bin:()=>["pnpm","exec","eslint"],cacheKey:(e,n)=>{const t=["eslint",e.declaredVersion??"unknown",e.configFile??"no-config",n.maxWarnings===void 0?"":`mw=${n.maxWarnings}`,n.quiet?"q":"",...n.extraArgs??[]];return y("sha256").update(t.join("|")).digest("hex").slice(0,16)},detect:(e,n)=>{const t=k(n,c.eslint.packageNames[0]),i=v(e,c.eslint.configFiles);if(!(!t&&!i))return{adapter:"eslint",configFile:i,declared:!!t,declaredVersion:t,root:e}},extensions:["cjs","cts","js","jsx","mjs","mts","ts","tsx","vue"],id:"eslint",kind:"lint",parse:(e,n)=>{if(!e.stdout.trim())return[];let t;try{t=JSON.parse(e.stdout)}catch{return[{adapter:"eslint",file:n.root,fixable:!1,message:`eslint output was not valid JSON (exit ${e.exitCode})`,severity:"error"}]}const i=[];for(const r of t)for(const s of r.messages)i.push({adapter:"eslint",column:s.column,endColumn:s.endColumn,endLine:s.endLine,file:r.filePath,fixable:!!s.fix,line:s.line,message:s.message,ruleId:s.ruleId??void 0,severity:s.fatal?"error":xe[s.severity]??"warning"});return i}},V=(e,n,t)=>{const i=["--format","json","--no-error-on-unmatched-pattern"];return t&&i.push("--fix"),n.quiet&&i.push("--quiet"),typeof n.maxWarnings=="number"&&i.push("--max-warnings",String(n.maxWarnings)),n.extraArgs?.length&&i.push(...n.extraArgs),i.push(...e),i},ke=/^([^:]+):(\d+)(?::(\d+))?\s+([\w/-]+)\s+(.+)$/,ve=e=>{const n=ke.exec(e);if(!n)return;const[,t,i,r,s,a]=n;return{column:r===void 0?void 0:Number(r),file:t,line:Number(i),message:a,ruleId:s}},ye=e=>e.startsWith("/")||/^[a-z]:[\\/]/i.test(e),be={argsCheck:(e,n)=>J(e,n,!1),argsFix:(e,n)=>J(e,n,!0),bin:()=>["pnpm","exec","markdownlint-cli2"],cacheKey:(e,n)=>{const t=["markdownlint",e.declaredVersion??"unknown",e.configFile??"no-config",n.maxWarnings===void 0?"":`mw=${n.maxWarnings}`,n.quiet?"q":"",...n.extraArgs??[]];return y("sha256").update(t.join("|")).digest("hex").slice(0,16)},detect:(e,n)=>{const t=c.markdownlint.packageNames.map(r=>k(n,r)).find(r=>r!==void 0),i=v(e,c.markdownlint.configFiles);if(!(!t&&!i))return{adapter:"markdownlint",configFile:i,declared:!!t,declaredVersion:t,root:e}},extensions:["markdown","md"],id:"markdownlint",kind:"lint",parse:(e,n)=>{const t=(e.stderr||e.stdout||"").trim();if(!t)return[];const i=[];for(const r of t.split(/\r?\n/)){const s=ve(r.trim());s&&i.push({adapter:"markdownlint",column:s.column,file:ye(s.file)?s.file:`${n.root}/${s.file}`,fixable:!0,line:s.line,message:s.message,ruleId:s.ruleId,severity:"warning"})}return i}},J=(e,n,t)=>{const i=[];return t&&i.push("--fix"),n.extraArgs?.length&&i.push(...n.extraArgs),e.length===0?i.push("**/*.md"):i.push(...e),i},$e={advice:"info",error:"error",warning:"warning"},Ae={argsCheck:(e,n)=>R(e,n,!1),argsFix:(e,n)=>R(e,n,!0),bin:()=>["pnpm","exec","oxlint"],cacheKey:(e,n)=>{const t=["oxlint",e.declaredVersion??"unknown",e.configFile??"no-config",n.maxWarnings===void 0?"":`mw=${n.maxWarnings}`,n.quiet?"q":"",...n.extraArgs??[]];return y("sha256").update(t.join("|")).digest("hex").slice(0,16)},detect:(e,n)=>{const t=k(n,c.oxlint.packageNames[0]),i=v(e,c.oxlint.configFiles);if(!(!t&&!i))return{adapter:"oxlint",configFile:i,declared:!!t,declaredVersion:t,root:e}},extensions:["astro","cjs","cts","js","jsx","mjs","mts","svelte","ts","tsx","vue"],id:"oxlint",kind:"lint",parse:(e,n)=>{if(!e.stdout.trim())return[];let t;try{t=JSON.parse(e.stdout)}catch{return[{adapter:"oxlint",file:n.root,fixable:!1,message:`oxlint output was not valid JSON (exit ${e.exitCode})`,severity:"error"}]}const i=[];for(const r of t.diagnostics??[]){const s=r.labels?.[0]?.span;i.push({adapter:"oxlint",column:s?.column,file:r.filename??n.root,fixable:!1,line:s?.line,message:r.message??"",ruleId:r.code,severity:$e[r.severity??""]??"warning"})}return i}},R=(e,n,t)=>{const i=["--format","json"];return t&&i.push("--fix"),n.quiet&&i.push("--quiet"),typeof n.maxWarnings=="number"&&i.push(`--max-warnings=${String(n.maxWarnings)}`),n.extraArgs?.length&&i.push(...n.extraArgs),i.push(...e),i},Fe={error:"error",info:"info",style:"info",warning:"warning"},je=e=>e.startsWith("/")||/^[a-z]:[\\/]/i.test(e),Ce=(e,n)=>e?je(e)?e:`${n}/${e}`:n,Se={argsCheck:(e,n)=>L(e,n),argsFix:(e,n)=>L(e,n),bin:()=>["shellcheck"],cacheKey:(e,n)=>{const t=["shellcheck",e.declaredVersion??"unknown",e.configFile??"no-config",n.quiet?"q":"",...n.extraArgs??[]];return y("sha256").update(t.join("|")).digest("hex").slice(0,16)},detect:(e,n)=>{const t=k(n,c.shellcheck.packageNames[0]),i=v(e,c.shellcheck.configFiles);if(!(!t&&!i))return{adapter:"shellcheck",configFile:i,declared:!!t,declaredVersion:t,root:e}},extensions:["bash","ksh","sh"],id:"shellcheck",kind:"lint",parse:(e,n)=>{if(!e.stdout.trim())return[];let t;try{t=JSON.parse(e.stdout)}catch{return[{adapter:"shellcheck",file:n.root,fixable:!1,message:`shellcheck output was not valid JSON (exit ${e.exitCode})`,severity:"error"}]}const i=[];for(const r of t.comments??[])i.push({adapter:"shellcheck",column:r.column,endColumn:r.endColumn,endLine:r.endLine,file:Ce(r.file,n.root),fixable:!!r.fix,line:r.line,message:r.message??"",ruleId:r.code===void 0?void 0:`SC${String(r.code)}`,severity:Fe[r.level??""]??"warning"});return i}},L=(e,n)=>{const t=["--format=json1"];return n.extraArgs?.length&&t.push(...n.extraArgs),t.push(...e),t},qe={error:"error",warning:"warning"},We={argsCheck:(e,n)=>M(e,n,!1),argsFix:(e,n)=>M(e,n,!0),bin:()=>["pnpm","exec","stylelint"],cacheKey:(e,n)=>{const t=["stylelint",e.declaredVersion??"unknown",e.configFile??"no-config",n.maxWarnings===void 0?"":`mw=${n.maxWarnings}`,n.quiet?"q":"",...n.extraArgs??[]];return y("sha256").update(t.join("|")).digest("hex").slice(0,16)},detect:(e,n)=>{const t=k(n,c.stylelint.packageNames[0]),i=v(e,c.stylelint.configFiles);if(!(!t&&!i))return{adapter:"stylelint",configFile:i,declared:!!t,declaredVersion:t,root:e}},extensions:["astro","css","less","sass","scss","svelte","vue"],id:"stylelint",kind:"lint",parse:(e,n)=>{if(!e.stdout.trim())return[];let t;try{t=JSON.parse(e.stdout)}catch{return[{adapter:"stylelint",file:n.root,fixable:!1,message:`stylelint output was not valid JSON (exit ${e.exitCode})`,severity:"error"}]}const i=[];for(const r of t)for(const s of r.warnings??[])i.push({adapter:"stylelint",column:s.column,endColumn:s.endColumn,endLine:s.endLine,file:r.source,fixable:!1,line:s.line,message:s.text??"",ruleId:s.rule,severity:qe[s.severity??""]??"warning"});return i}},M=(e,n,t)=>{const i=["--formatter","json"];return t&&i.push("--fix"),n.quiet&&i.push("--quiet"),typeof n.maxWarnings=="number"&&i.push("--max-warnings",String(n.maxWarnings)),n.extraArgs?.length&&i.push(...n.extraArgs),i.push(...e),i},Ne=[Ae,fe,we,We,ge,be,Se,pe],Pe=async({logger:e,options:n,visConfig:t,workspaceRoot:i})=>{const r=i??process.cwd(),s=t?.lint,a=Z(Ne,s?.order),j=ee(r,a),d=ne(j,a,"lint").filter(({adapter:l})=>s?.adapters?.[l.id]?.enabled!==!1);if(d.length===0){e.warn("vis lint: no linter detected in this workspace (looked for: oxlint, biome, eslint, stylelint, ruff, markdownlint, shellcheck, deno).");return}const C=l=>{const u=s?.adapters?.[l]?.extraArgs;return u&&u.length>0?[...u]:void 0},b={extraArgs:void 0,maxWarnings:typeof n.maxWarnings=="number"?n.maxWarnings:void 0,quiet:n.quiet??!1},$=_e(n),P=n.fix?"fix":"check";let f;if(n.staged){if(f=te(r),f===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(f.length===0){e.info(q("✓ lint: no staged files"));return}}else if(typeof n.since=="string"&&n.since.length>0){if(f=ie(r,n.since),f===void 0)e.warn(`vis lint: could not resolve --since ${n.since} (not a git repo or unknown ref). Falling back to a workspace-wide run.`);else if(f.length===0){e.info(q(`✓ lint: no files changed since ${n.since}`));return}}const W=$.length>0?$:void 0,E=Y(r,void 0,void 0,!0),S=n.format??"human";S==="human"&&n.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 N=async l=>{const u=l!==void 0&&l.length>0&&W===void 0,m=[];for(const{adapter:o,presence:x}of d){let g;if(u){if(g=se(l,o.extensions),g.length===0)continue}else g=W??l??["."];const F=C(o.id),I={adapter:o,files:g,presence:x};F&&(I.options={...b,extraArgs:F}),m.push(I)}if(m.length===0)return;const z=await oe(m,b,P,{cacheRoot:E}),A=m.map((o,x)=>{const g=z[x],F=o.adapter.parse(g,o.presence);return{adapter:o.adapter,durationMs:g.durationMs,exitCode:g.exitCode,findings:F}}),h=ae(A.map(o=>({adapter:o.adapter.id,durationMs:o.durationMs,exitCode:o.exitCode,findingCount:o.findings.length,findings:o.findings}))),p=S==="human"?void 0:le({cwd:r,target:n.output});try{switch(S){case"github":{p.write(ue({runs:A.map(o=>({findings:o.findings})),workspaceRoot:r}));break}case"json":{p.write(`${JSON.stringify({findings:h.findings,runs:h.runs},null,2)}
2
2
  `);break}case"junit":{p.write(de({runs:A.map(o=>({adapter:o.adapter.id,durationMs:o.durationMs,findings:o.findings})),workspaceRoot:r}));break}case"minimal":{Oe(h.findings,r,p);break}case"sarif":{p.write(ce({runs:A.map(o=>({adapter:o.adapter.id,findings:o.findings,presence:m.find(x=>x.adapter.id===o.adapter.id)?.presence})),workspaceRoot:r}));break}default:Ie(h.findings,r,e)}}finally{p?.close()}const _=he(h);_!==0&&(process.exitCode=_)};if(n.watch){const l=[...new Set(d.flatMap(({adapter:u})=>u.extensions))];await re({extensions:l,initialFiles:f,label:"lint",log:u=>{e.info(u)},runCycle:N,workspaceRoot:r});return}await N(f)},_e=e=>{const n=e;return[...n._??n.args??[]]},Ie=(e,n,t)=>{if(e.length===0){t.info(q("✓ lint: no findings"));return}const i=me(e);for(const[a,j]of i){t.info(Q(B(n,a)));for(const d of j){const C=Ve(d),b=Je(d.severity),$=d.ruleId?O(` ${d.ruleId}`):"";t.info(` ${O(C)} ${b} ${d.message}${$}`)}}const r=e.filter(a=>a.severity==="error").length,s=e.filter(a=>a.severity==="warning").length;t.info(""),t.info(`${K(`${String(r)} error${r===1?"":"s"}`)}, ${T(`${String(s)} warning${s===1?"":"s"}`)}`)},Oe=(e,n,t)=>{for(const i of e){const r=B(n,i.file),s=i.line??"",a=i.column??"";t.write(`${i.adapter} ${r} ${String(s)} ${String(a)} ${i.severity} ${i.ruleId??""} ${i.message}
3
3
  `)}},Ve=e=>e.line===void 0?"":e.column===void 0?String(e.line):`${String(e.line)}:${String(e.column)}`,Je=e=>e==="error"?K("error"):e==="warning"?T("warn "):X("info ");export{Pe as default};
@@ -1,4 +1,4 @@
1
- import{b as J,z as X,w as E,l as M,K as V,P as W}from"../packem_shared/index-uBVnF4ji.js";import{l as t,m as a,i as c,r as v,X as Y,R as Q,P as U,p as Z,o as _,s as ee,x as re,e as N}from"./catalog.js";import"../packem_shared/en-D3CfXlO7.js";import{I as te}from"../packem_shared/index-BWl4DbMp.js";import se from"./index.js";import{sortPackageJsonStringWithOptions as q}from"#native";import{J as oe,I as ne,K as ie,p as S}from"./cli-main.js";import{ScrollView as le}from"@visulima/tui-kit/scroll-view";import{ScrollBar as ce}from"@visulima/tui-kit/scroll-bar";import{o as O}from"../packem_shared/utils-CRueU43T.js";const A={error:0,rewritten:1,"would-rewrite":1,unchanged:2},ae=e=>[...e].sort((r,s)=>A[r.status]-A[s.status]),de=(e,r)=>r==="all"?e:r==="errors"?e.filter(s=>s.status==="error"):r==="rewritten"?e.filter(s=>s.status==="rewritten"||s.status==="would-rewrite"):e.filter(s=>s.status==="unchanged");class ue{#e;#r=new Set;constructor(r){this.#e={entries:ae(r),filterType:"all",focusedPanel:"list",selectedIndex:0}}getSnapshot=()=>this.#e;subscribe=r=>(this.#r.add(r),()=>{this.#r.delete(r)});getFilteredEntries=()=>de(this.#e.entries,this.#e.filterType);#t(){this.#e={...this.#e};for(const r of this.#r)r()}select(r){const s=this.getFilteredEntries();this.#e.selectedIndex=s.length===0?-1:Math.max(0,Math.min(r,s.length-1)),this.#t()}selectStep(r){this.select(this.#e.selectedIndex+r)}setFilter(r){this.#e.filterType=r,this.#e.selectedIndex=0,this.#t()}setFocusedPanel(r){this.#e.focusedPanel=r,this.#t()}}const fe=({checkMode:e,entry:r,focused:s,scrollRef:l})=>{const i=s?"white":"gray";return r?t.jsxs(a,{borderColor:i,borderStyle:"single",flexDirection:"column",flexGrow:1,children:[t.jsx(a,{flexShrink:0,paddingTop:1,paddingX:2,children:t.jsx(c,{bold:!0,color:"white",children:r.relativePath})}),t.jsxs(le,{flexGrow:1,flexShrink:1,paddingX:2,ref:l,scrollbar:!0,scrollbarColor:"gray",children:[t.jsx(c,{}),t.jsxs(a,{children:[t.jsx(a,{width:10,children:t.jsx(c,{dimColor:!0,children:"Status:"})}),r.status==="error"?t.jsx(c,{bold:!0,color:"red",children:"error"}):r.status==="unchanged"?t.jsx(c,{bold:!0,color:"green",children:"already sorted"}):r.status==="rewritten"?t.jsx(c,{bold:!0,color:"yellow",children:"rewritten"}):t.jsx(c,{bold:!0,color:"yellow",children:"would rewrite (--check)"})]}),t.jsxs(a,{children:[t.jsx(a,{width:10,children:t.jsx(c,{dimColor:!0,children:"Path:"})}),t.jsx(c,{children:r.filePath})]}),r.error?t.jsxs(t.Fragment,{children:[t.jsxs(a,{flexDirection:"column",marginTop:1,children:[t.jsx(c,{dimColor:!0,children:"── "}),t.jsx(c,{bold:!0,color:"red",children:"ERROR"}),t.jsxs(a,{flexDirection:"column",marginTop:1,paddingLeft:2,children:[t.jsxs(a,{children:[t.jsx(a,{width:10,children:t.jsx(c,{dimColor:!0,children:"Step:"})}),t.jsx(c,{color:"yellow",children:r.error.step})]}),r.error.context&&t.jsxs(a,{children:[t.jsx(a,{width:10,children:t.jsx(c,{dimColor:!0,children:"Position:"})}),t.jsx(c,{children:`line ${String(r.error.context.line)}, column ${String(r.error.context.column)}`})]}),t.jsx(a,{marginTop:1,children:t.jsx(c,{color:"red",children:r.error.message})})]})]}),r.error.context&&r.error.context.snippet.length>0&&t.jsxs(a,{flexDirection:"column",marginTop:1,children:[t.jsx(c,{dimColor:!0,children:"── "}),t.jsx(c,{bold:!0,color:"white",children:"SNIPPET"}),t.jsxs(a,{flexDirection:"column",marginTop:1,paddingLeft:2,children:[r.error.context.snippet.map(o=>{const n=`${o.isErrorLine?"❯":" "} ${String(o.lineNumber).padStart(4)} `;return t.jsxs(a,{children:[t.jsx(c,{color:o.isErrorLine?"red":"gray",children:n}),t.jsx(c,{color:o.isErrorLine?"white":"gray",wrap:"truncate-end",children:o.content||" "})]},o.lineNumber)}),r.error.context.column>0&&t.jsx(a,{children:t.jsx(c,{color:"red",children:`${" ".repeat(7+r.error.context.column-1)}↑`})})]})]})]}):t.jsxs(a,{flexDirection:"column",marginTop:1,children:[t.jsx(c,{dimColor:!0,children:"── "}),t.jsx(c,{bold:!0,color:"white",children:"KEY DIFF"}),t.jsx(a,{flexDirection:"column",marginTop:1,paddingLeft:2,children:r.diff.length===0?t.jsx(c,{dimColor:!0,children:"No top-level keys moved (sub-key reorder only)."}):r.diff.map(o=>{const n=o.toIndex-o.fromIndex,d=n<0?`↑ ${String(Math.abs(n))}`:`↓ ${String(n)}`,g=n<0?"green":"yellow";return t.jsxs(a,{children:[t.jsx(a,{width:28,children:t.jsx(c,{wrap:"truncate",children:o.key})}),t.jsx(a,{width:10,children:t.jsxs(c,{dimColor:!0,children:[String(o.fromIndex)," → ",String(o.toIndex)]})}),t.jsx(c,{color:g,children:d})]},o.key)})}),e&&r.status==="would-rewrite"&&t.jsx(a,{marginTop:1,paddingLeft:2,children:t.jsx(c,{dimColor:!0,children:"--check mode: no write performed."})})]})]})]}):t.jsx(a,{alignItems:"center",borderColor:"gray",borderStyle:"single",flexDirection:"column",flexGrow:1,justifyContent:"center",children:t.jsx(c,{dimColor:!0,children:"No entry selected"})})},he={error:"red",rewritten:"yellow",unchanged:"green","would-rewrite":"yellow"},ge={error:"ERROR",rewritten:"REWROTE",unchanged:"SORTED","would-rewrite":"REWRITE"},H={error:"errors",rewritten:"rewrites",unchanged:"sorted","would-rewrite":"rewrites"},xe={errors:"Errors",rewrites:"Rewrites",sorted:"Sorted"},pe=[{count:e=>e.errors+e.rewrites+e.sorted,key:"all",label:"All",shortcut:"1"},{count:e=>e.rewrites,key:"rewritten",label:"Rewrites",shortcut:"2"},{count:e=>e.errors,key:"errors",label:"Errors",shortcut:"3"},{count:e=>e.sorted,key:"unchanged",label:"Sorted",shortcut:"4"}],z=e=>{const r={errors:0,rewrites:0,sorted:0};for(const s of e)r[H[s.status]]++;return r},me=({entry:e,isSelected:r})=>{const s=he[e.status],l=ge[e.status];return t.jsxs(a,{flexShrink:0,height:1,children:[t.jsx(c,{children:r?">":" "}),t.jsx(c,{children:" "}),t.jsx(c,{bold:!0,color:s,children:`[${l}]`.padEnd(10)}),t.jsx(c,{children:" "}),t.jsx(a,{flexGrow:1,children:t.jsx(c,{bold:r,inverse:r,wrap:"truncate",children:e.relativePath})}),e.status!=="error"&&e.diff.length>0&&t.jsx(c,{dimColor:!0,children:` ${String(e.diff.length)} key${e.diff.length===1?"":"s"}`})]})},we=({color:e,count:r,label:s})=>t.jsx(a,{flexShrink:0,height:1,children:t.jsx(c,{bold:!0,color:e,children:`${s} (${String(r)})`})}),je=({counts:e,entries:r,filterType:s,focused:l,selectedIndex:i,totalEntries:o,viewportHeight:n})=>{const d=l?"white":"gray",g=z(r),m=(g.errors>0?1:0)+(g.rewrites>0?1:0)+(g.sorted>0?1:0),y=s==="all"&&m>1,h=[];let w;for(const[u,p]of r.entries()){const b=H[p.status];y&&b!==w&&(w!==void 0&&h.push({kind:"spacer"}),h.push({color:b==="errors"?"red":b==="rewrites"?"yellow":"green",count:g[b],kind:"header",label:xe[b]}),w=b),h.push({entry:p,entryIndex:u,kind:"entry"})}const x=h.findIndex(u=>u.kind==="entry"&&u.entryIndex===i),k=x!==-1,j=h.length,$=Math.max(0,j-n);let f=0;k&&n>0&&(f=Math.min($,Math.max(0,x-n+1)));const P=j>n&&n>0;return t.jsxs(a,{borderColor:d,borderStyle:"single",flexDirection:"column",flexGrow:1,children:[t.jsxs(a,{flexShrink:0,gap:1,paddingX:1,children:[t.jsx(c,{bold:!0,inverse:!0,children:" VIS SORT "}),t.jsxs(c,{wrap:"truncate",children:[o," ","file",o===1?"":"s"]})]}),t.jsx(a,{flexShrink:0,gap:1,paddingX:1,paddingY:1,children:pe.map(u=>{const p=s===u.key,b=u.count(e);return t.jsxs(a,{children:[t.jsx(c,{dimColor:!p,children:"["}),t.jsx(c,{bold:p,color:p?"cyan":"gray",children:u.shortcut}),t.jsx(c,{dimColor:!p,children:"]"}),t.jsxs(c,{color:p?"white":"gray",children:[" ",u.label]}),t.jsxs(c,{dimColor:!0,children:[" ","(",b,")"]})]},u.key)})}),t.jsxs(a,{flexDirection:"row",flexGrow:1,overflow:"hidden",children:[t.jsx(a,{flexDirection:"column",flexGrow:1,overflow:"hidden",paddingLeft:1,children:t.jsx(a,{flexDirection:"column",marginTop:-f,children:h.map((u,p)=>u.kind==="spacer"?t.jsx(a,{flexShrink:0,height:1},`s-${String(p)}`):u.kind==="header"?t.jsx(we,{color:u.color,count:u.count,label:u.label},`h-${u.label}`):t.jsx(me,{entry:u.entry,isSelected:u.entryIndex===i},u.entry.filePath))})}),P&&t.jsx(a,{flexShrink:0,marginLeft:1,marginRight:1,children:t.jsx(ce,{contentHeight:j,placement:"inset",scrollOffset:f,style:"block",viewportHeight:n})})]})]})},ye=100,D=10,be=6,Se=1,F={1:"all",2:"rewritten",3:"errors",4:"unchanged"},ke=({checkMode:e,store:r})=>{const{exit:s}=oe(),{columns:l,rows:i}=ne(),o=v.useSyncExternalStore(r.subscribe,r.getSnapshot),n=v.useRef(null),d=r.getFilteredEntries(),g=d[o.selectedIndex]??null,m=z(o.entries),y=l>=ye,h=Math.max(0,i-Se),w=y?h:Math.floor(h/2),x=Math.max(0,w-be),k=v.useCallback(()=>{s()},[s]),j=v.useRef(0),$=v.useRef(void 0),f=v.useRef(!1),P=v.useCallback((u,p)=>{j.current+=p,$.current=u,!f.current&&(f.current=!0,queueMicrotask(()=>{f.current=!1;const b=j.current,T=$.current;j.current=0,$.current=void 0,!(b===0||T===void 0)&&(T==="list"?r.selectStep(Math.sign(b)):n.current?.scrollBy(Math.sign(b)))}))},[r]);return ie((u,p)=>{if(u==="q"||p.escape){k();return}if(F[u]){r.setFilter(F[u]);return}if(p.tab){r.setFocusedPanel(o.focusedPanel==="list"?"detail":"list");return}o.focusedPanel==="list"?p.upArrow||u==="k"?P("list",-1):(p.downArrow||u==="j")&&P("list",1):o.focusedPanel==="detail"&&(p.upArrow||u==="k"?P("detail",-1):(p.downArrow||u==="j")&&P("detail",1))}),i<D?t.jsx(a,{alignItems:"center",justifyContent:"center",children:t.jsxs(c,{color:"yellow",children:["Terminal too small. Resize to at least",D," ","rows."]})}):t.jsxs(a,{flexDirection:"column",height:i,width:l,children:[t.jsxs(a,{flexDirection:y?"row":"column",flexGrow:1,children:[t.jsx(a,{flexBasis:"50%",flexGrow:1,flexShrink:1,children:t.jsx(je,{counts:m,entries:d,filterType:o.filterType,focused:o.focusedPanel==="list",selectedIndex:o.selectedIndex,totalEntries:o.entries.length,viewportHeight:x})}),t.jsx(a,{flexBasis:"50%",flexGrow:1,flexShrink:1,children:t.jsx(fe,{checkMode:e,entry:g,focused:o.focusedPanel==="detail",scrollRef:n})})]}),t.jsx(a,{flexShrink:0,paddingX:1,children:t.jsx(c,{dimColor:!0,children:"↑/↓ or j/k:navigate | tab:switch panel | 1-4:filter | q:quit"})})]})},G=["types","node-addons","node","import","require","default"],$e=/^git\+https:\/\/github\.com\/([^/]+)\/([^/.]+(?:\.git)?)$/,ve=/^git\+ssh:\/\/git@github\.com\/([^/]+)\/([^/.]+(?:\.git)?)$/,C=e=>typeof e=="object"&&e!==null&&!Array.isArray(e),R=e=>{if(e===null||typeof e!="object")return e;if(Array.isArray(e))return e.map(s=>R(s));const r={};for(const[s,l]of Object.entries(e))r[s]=R(l);return r},Pe=e=>{if(!C(e))return{changed:!1,value:e};const r=Object.keys(e);return r.length===1&&r[0]==="url"&&typeof e.url=="string"?{changed:!0,value:e.url}:{changed:!1,value:e}},Ee=e=>e.endsWith(".git")?e.slice(0,-4):e,Oe=e=>{if(!C(e))return{changed:!1,value:e};if(typeof e.directory=="string"&&e.directory.length>0)return{changed:!1,value:e};const{type:r}=e;if(r!==void 0&&r!=="git")return{changed:!1,value:e};const{url:s}=e;if(typeof s!="string")return{changed:!1,value:e};const l=$e.exec(s)??ve.exec(s);if(!l)return{changed:!1,value:e};const i=l[1],o=Ee(l[2]??"");if(!i||!o)return{changed:!1,value:e};const n=new Set(["type","url"]);for(const d of Object.keys(e))if(!n.has(d))return{changed:!1,value:e};return{changed:!0,value:`${i}/${o}`}},Ce=e=>{const r=Object.keys(e),s=[],l=[];for(const n of G)Object.hasOwn(e,n)&&s.push(n);for(const n of r)G.includes(n)||l.push(n);const i=[...s,...l];if(i.length===r.length&&i.every((n,d)=>n===r[d]))return{changed:!1,value:e};const o={};for(const n of i)o[n]=e[n];return{changed:!0,value:o}},K=e=>{if(!C(e))return{changed:!1,value:e};let r=!1;const s={};for(const[i,o]of Object.entries(e)){const n=K(o);s[i]=n.value,n.changed&&(r=!0)}const l=Ce(s);return{changed:r||l.changed,value:l.value}},Ie=(e,r)=>{const s=R(e);let l=!1;if(r.formatBugs!==!1&&Object.hasOwn(s,"bugs")){const i=Pe(s.bugs);i.changed&&(s.bugs=i.value,l=!0)}if(r.formatRepository!==!1&&Object.hasOwn(s,"repository")){const i=Oe(s.repository);i.changed&&(s.repository=i.value,l=!0)}if(r.sortExports!==!1&&Object.hasOwn(s,"exports")&&C(s.exports)){const i=K(s.exports);i.changed&&(s.exports=i.value,l=!0)}return{changed:l,pkg:s}},Re=/at position (\d+)/,Te=/\(?line (\d+) column (\d+)\)?/,Me=e=>{const r=new Set,s=[],l=o=>{const n=W(o);!r.has(n)&&M(n)&&(r.add(n),s.push(n))};l(E(e,"package.json"));const i=re(e);if(i){const o=N(e,i);for(const n of o)l(E(e,n,"package.json"))}else{const o=E(e,"package.json");if(M(o)){const n=JSON.parse(X(o)),d=Array.isArray(n.workspaces)?n.workspaces:n.workspaces?.packages;if(d){const g=N(e,d);for(const m of g)l(E(e,m,"package.json"))}}}return s},Ne=e=>/\n([ \t]+)/.exec(e)?.[1]??" ",Ae=e=>{if(!(e===void 0||e===""))return e==="tab"||e===String.raw`\t`?" ":/^\d+$/.test(e)?" ".repeat(Number.parseInt(e,10)):e},I=e=>e===void 0?[]:(Array.isArray(e)?e:[e]).flatMap(r=>r.split(",")).map(r=>r.trim()).filter(r=>r.length>0),De=e=>e.includes(`\r
1
+ import{b as J,z as X,w as E,l as M,K as V,P as W}from"../packem_shared/index-BLtnel38.js";import{l as t,m as a,i as c,r as v,X as Y,R as Q,P as U,p as Z,o as _,s as ee,x as re,e as N}from"./catalog.js";import"../packem_shared/en-BDYMmM2_.js";import{I as te}from"../packem_shared/index-BWl4DbMp.js";import se from"./index.js";import{sortPackageJsonStringWithOptions as q}from"#native";import{J as oe,I as ne,K as ie,p as S}from"./cli-main.js";import{ScrollView as le}from"@visulima/tui-kit/scroll-view";import{ScrollBar as ce}from"@visulima/tui-kit/scroll-bar";import{o as O}from"../packem_shared/utils-CRueU43T.js";const A={error:0,rewritten:1,"would-rewrite":1,unchanged:2},ae=e=>[...e].sort((r,s)=>A[r.status]-A[s.status]),de=(e,r)=>r==="all"?e:r==="errors"?e.filter(s=>s.status==="error"):r==="rewritten"?e.filter(s=>s.status==="rewritten"||s.status==="would-rewrite"):e.filter(s=>s.status==="unchanged");class ue{#e;#r=new Set;constructor(r){this.#e={entries:ae(r),filterType:"all",focusedPanel:"list",selectedIndex:0}}getSnapshot=()=>this.#e;subscribe=r=>(this.#r.add(r),()=>{this.#r.delete(r)});getFilteredEntries=()=>de(this.#e.entries,this.#e.filterType);#t(){this.#e={...this.#e};for(const r of this.#r)r()}select(r){const s=this.getFilteredEntries();this.#e.selectedIndex=s.length===0?-1:Math.max(0,Math.min(r,s.length-1)),this.#t()}selectStep(r){this.select(this.#e.selectedIndex+r)}setFilter(r){this.#e.filterType=r,this.#e.selectedIndex=0,this.#t()}setFocusedPanel(r){this.#e.focusedPanel=r,this.#t()}}const fe=({checkMode:e,entry:r,focused:s,scrollRef:l})=>{const i=s?"white":"gray";return r?t.jsxs(a,{borderColor:i,borderStyle:"single",flexDirection:"column",flexGrow:1,children:[t.jsx(a,{flexShrink:0,paddingTop:1,paddingX:2,children:t.jsx(c,{bold:!0,color:"white",children:r.relativePath})}),t.jsxs(le,{flexGrow:1,flexShrink:1,paddingX:2,ref:l,scrollbar:!0,scrollbarColor:"gray",children:[t.jsx(c,{}),t.jsxs(a,{children:[t.jsx(a,{width:10,children:t.jsx(c,{dimColor:!0,children:"Status:"})}),r.status==="error"?t.jsx(c,{bold:!0,color:"red",children:"error"}):r.status==="unchanged"?t.jsx(c,{bold:!0,color:"green",children:"already sorted"}):r.status==="rewritten"?t.jsx(c,{bold:!0,color:"yellow",children:"rewritten"}):t.jsx(c,{bold:!0,color:"yellow",children:"would rewrite (--check)"})]}),t.jsxs(a,{children:[t.jsx(a,{width:10,children:t.jsx(c,{dimColor:!0,children:"Path:"})}),t.jsx(c,{children:r.filePath})]}),r.error?t.jsxs(t.Fragment,{children:[t.jsxs(a,{flexDirection:"column",marginTop:1,children:[t.jsx(c,{dimColor:!0,children:"── "}),t.jsx(c,{bold:!0,color:"red",children:"ERROR"}),t.jsxs(a,{flexDirection:"column",marginTop:1,paddingLeft:2,children:[t.jsxs(a,{children:[t.jsx(a,{width:10,children:t.jsx(c,{dimColor:!0,children:"Step:"})}),t.jsx(c,{color:"yellow",children:r.error.step})]}),r.error.context&&t.jsxs(a,{children:[t.jsx(a,{width:10,children:t.jsx(c,{dimColor:!0,children:"Position:"})}),t.jsx(c,{children:`line ${String(r.error.context.line)}, column ${String(r.error.context.column)}`})]}),t.jsx(a,{marginTop:1,children:t.jsx(c,{color:"red",children:r.error.message})})]})]}),r.error.context&&r.error.context.snippet.length>0&&t.jsxs(a,{flexDirection:"column",marginTop:1,children:[t.jsx(c,{dimColor:!0,children:"── "}),t.jsx(c,{bold:!0,color:"white",children:"SNIPPET"}),t.jsxs(a,{flexDirection:"column",marginTop:1,paddingLeft:2,children:[r.error.context.snippet.map(o=>{const n=`${o.isErrorLine?"❯":" "} ${String(o.lineNumber).padStart(4)} `;return t.jsxs(a,{children:[t.jsx(c,{color:o.isErrorLine?"red":"gray",children:n}),t.jsx(c,{color:o.isErrorLine?"white":"gray",wrap:"truncate-end",children:o.content||" "})]},o.lineNumber)}),r.error.context.column>0&&t.jsx(a,{children:t.jsx(c,{color:"red",children:`${" ".repeat(7+r.error.context.column-1)}↑`})})]})]})]}):t.jsxs(a,{flexDirection:"column",marginTop:1,children:[t.jsx(c,{dimColor:!0,children:"── "}),t.jsx(c,{bold:!0,color:"white",children:"KEY DIFF"}),t.jsx(a,{flexDirection:"column",marginTop:1,paddingLeft:2,children:r.diff.length===0?t.jsx(c,{dimColor:!0,children:"No top-level keys moved (sub-key reorder only)."}):r.diff.map(o=>{const n=o.toIndex-o.fromIndex,d=n<0?`↑ ${String(Math.abs(n))}`:`↓ ${String(n)}`,g=n<0?"green":"yellow";return t.jsxs(a,{children:[t.jsx(a,{width:28,children:t.jsx(c,{wrap:"truncate",children:o.key})}),t.jsx(a,{width:10,children:t.jsxs(c,{dimColor:!0,children:[String(o.fromIndex)," → ",String(o.toIndex)]})}),t.jsx(c,{color:g,children:d})]},o.key)})}),e&&r.status==="would-rewrite"&&t.jsx(a,{marginTop:1,paddingLeft:2,children:t.jsx(c,{dimColor:!0,children:"--check mode: no write performed."})})]})]})]}):t.jsx(a,{alignItems:"center",borderColor:"gray",borderStyle:"single",flexDirection:"column",flexGrow:1,justifyContent:"center",children:t.jsx(c,{dimColor:!0,children:"No entry selected"})})},he={error:"red",rewritten:"yellow",unchanged:"green","would-rewrite":"yellow"},ge={error:"ERROR",rewritten:"REWROTE",unchanged:"SORTED","would-rewrite":"REWRITE"},H={error:"errors",rewritten:"rewrites",unchanged:"sorted","would-rewrite":"rewrites"},xe={errors:"Errors",rewrites:"Rewrites",sorted:"Sorted"},pe=[{count:e=>e.errors+e.rewrites+e.sorted,key:"all",label:"All",shortcut:"1"},{count:e=>e.rewrites,key:"rewritten",label:"Rewrites",shortcut:"2"},{count:e=>e.errors,key:"errors",label:"Errors",shortcut:"3"},{count:e=>e.sorted,key:"unchanged",label:"Sorted",shortcut:"4"}],z=e=>{const r={errors:0,rewrites:0,sorted:0};for(const s of e)r[H[s.status]]++;return r},me=({entry:e,isSelected:r})=>{const s=he[e.status],l=ge[e.status];return t.jsxs(a,{flexShrink:0,height:1,children:[t.jsx(c,{children:r?">":" "}),t.jsx(c,{children:" "}),t.jsx(c,{bold:!0,color:s,children:`[${l}]`.padEnd(10)}),t.jsx(c,{children:" "}),t.jsx(a,{flexGrow:1,children:t.jsx(c,{bold:r,inverse:r,wrap:"truncate",children:e.relativePath})}),e.status!=="error"&&e.diff.length>0&&t.jsx(c,{dimColor:!0,children:` ${String(e.diff.length)} key${e.diff.length===1?"":"s"}`})]})},we=({color:e,count:r,label:s})=>t.jsx(a,{flexShrink:0,height:1,children:t.jsx(c,{bold:!0,color:e,children:`${s} (${String(r)})`})}),je=({counts:e,entries:r,filterType:s,focused:l,selectedIndex:i,totalEntries:o,viewportHeight:n})=>{const d=l?"white":"gray",g=z(r),m=(g.errors>0?1:0)+(g.rewrites>0?1:0)+(g.sorted>0?1:0),y=s==="all"&&m>1,h=[];let w;for(const[u,p]of r.entries()){const b=H[p.status];y&&b!==w&&(w!==void 0&&h.push({kind:"spacer"}),h.push({color:b==="errors"?"red":b==="rewrites"?"yellow":"green",count:g[b],kind:"header",label:xe[b]}),w=b),h.push({entry:p,entryIndex:u,kind:"entry"})}const x=h.findIndex(u=>u.kind==="entry"&&u.entryIndex===i),k=x!==-1,j=h.length,$=Math.max(0,j-n);let f=0;k&&n>0&&(f=Math.min($,Math.max(0,x-n+1)));const P=j>n&&n>0;return t.jsxs(a,{borderColor:d,borderStyle:"single",flexDirection:"column",flexGrow:1,children:[t.jsxs(a,{flexShrink:0,gap:1,paddingX:1,children:[t.jsx(c,{bold:!0,inverse:!0,children:" VIS SORT "}),t.jsxs(c,{wrap:"truncate",children:[o," ","file",o===1?"":"s"]})]}),t.jsx(a,{flexShrink:0,gap:1,paddingX:1,paddingY:1,children:pe.map(u=>{const p=s===u.key,b=u.count(e);return t.jsxs(a,{children:[t.jsx(c,{dimColor:!p,children:"["}),t.jsx(c,{bold:p,color:p?"cyan":"gray",children:u.shortcut}),t.jsx(c,{dimColor:!p,children:"]"}),t.jsxs(c,{color:p?"white":"gray",children:[" ",u.label]}),t.jsxs(c,{dimColor:!0,children:[" ","(",b,")"]})]},u.key)})}),t.jsxs(a,{flexDirection:"row",flexGrow:1,overflow:"hidden",children:[t.jsx(a,{flexDirection:"column",flexGrow:1,overflow:"hidden",paddingLeft:1,children:t.jsx(a,{flexDirection:"column",marginTop:-f,children:h.map((u,p)=>u.kind==="spacer"?t.jsx(a,{flexShrink:0,height:1},`s-${String(p)}`):u.kind==="header"?t.jsx(we,{color:u.color,count:u.count,label:u.label},`h-${u.label}`):t.jsx(me,{entry:u.entry,isSelected:u.entryIndex===i},u.entry.filePath))})}),P&&t.jsx(a,{flexShrink:0,marginLeft:1,marginRight:1,children:t.jsx(ce,{contentHeight:j,placement:"inset",scrollOffset:f,style:"block",viewportHeight:n})})]})]})},ye=100,D=10,be=6,Se=1,F={1:"all",2:"rewritten",3:"errors",4:"unchanged"},ke=({checkMode:e,store:r})=>{const{exit:s}=oe(),{columns:l,rows:i}=ne(),o=v.useSyncExternalStore(r.subscribe,r.getSnapshot),n=v.useRef(null),d=r.getFilteredEntries(),g=d[o.selectedIndex]??null,m=z(o.entries),y=l>=ye,h=Math.max(0,i-Se),w=y?h:Math.floor(h/2),x=Math.max(0,w-be),k=v.useCallback(()=>{s()},[s]),j=v.useRef(0),$=v.useRef(void 0),f=v.useRef(!1),P=v.useCallback((u,p)=>{j.current+=p,$.current=u,!f.current&&(f.current=!0,queueMicrotask(()=>{f.current=!1;const b=j.current,T=$.current;j.current=0,$.current=void 0,!(b===0||T===void 0)&&(T==="list"?r.selectStep(Math.sign(b)):n.current?.scrollBy(Math.sign(b)))}))},[r]);return ie((u,p)=>{if(u==="q"||p.escape){k();return}if(F[u]){r.setFilter(F[u]);return}if(p.tab){r.setFocusedPanel(o.focusedPanel==="list"?"detail":"list");return}o.focusedPanel==="list"?p.upArrow||u==="k"?P("list",-1):(p.downArrow||u==="j")&&P("list",1):o.focusedPanel==="detail"&&(p.upArrow||u==="k"?P("detail",-1):(p.downArrow||u==="j")&&P("detail",1))}),i<D?t.jsx(a,{alignItems:"center",justifyContent:"center",children:t.jsxs(c,{color:"yellow",children:["Terminal too small. Resize to at least",D," ","rows."]})}):t.jsxs(a,{flexDirection:"column",height:i,width:l,children:[t.jsxs(a,{flexDirection:y?"row":"column",flexGrow:1,children:[t.jsx(a,{flexBasis:"50%",flexGrow:1,flexShrink:1,children:t.jsx(je,{counts:m,entries:d,filterType:o.filterType,focused:o.focusedPanel==="list",selectedIndex:o.selectedIndex,totalEntries:o.entries.length,viewportHeight:x})}),t.jsx(a,{flexBasis:"50%",flexGrow:1,flexShrink:1,children:t.jsx(fe,{checkMode:e,entry:g,focused:o.focusedPanel==="detail",scrollRef:n})})]}),t.jsx(a,{flexShrink:0,paddingX:1,children:t.jsx(c,{dimColor:!0,children:"↑/↓ or j/k:navigate | tab:switch panel | 1-4:filter | q:quit"})})]})},G=["types","node-addons","node","import","require","default"],$e=/^git\+https:\/\/github\.com\/([^/]+)\/([^/.]+(?:\.git)?)$/,ve=/^git\+ssh:\/\/git@github\.com\/([^/]+)\/([^/.]+(?:\.git)?)$/,C=e=>typeof e=="object"&&e!==null&&!Array.isArray(e),R=e=>{if(e===null||typeof e!="object")return e;if(Array.isArray(e))return e.map(s=>R(s));const r={};for(const[s,l]of Object.entries(e))r[s]=R(l);return r},Pe=e=>{if(!C(e))return{changed:!1,value:e};const r=Object.keys(e);return r.length===1&&r[0]==="url"&&typeof e.url=="string"?{changed:!0,value:e.url}:{changed:!1,value:e}},Ee=e=>e.endsWith(".git")?e.slice(0,-4):e,Oe=e=>{if(!C(e))return{changed:!1,value:e};if(typeof e.directory=="string"&&e.directory.length>0)return{changed:!1,value:e};const{type:r}=e;if(r!==void 0&&r!=="git")return{changed:!1,value:e};const{url:s}=e;if(typeof s!="string")return{changed:!1,value:e};const l=$e.exec(s)??ve.exec(s);if(!l)return{changed:!1,value:e};const i=l[1],o=Ee(l[2]??"");if(!i||!o)return{changed:!1,value:e};const n=new Set(["type","url"]);for(const d of Object.keys(e))if(!n.has(d))return{changed:!1,value:e};return{changed:!0,value:`${i}/${o}`}},Ce=e=>{const r=Object.keys(e),s=[],l=[];for(const n of G)Object.hasOwn(e,n)&&s.push(n);for(const n of r)G.includes(n)||l.push(n);const i=[...s,...l];if(i.length===r.length&&i.every((n,d)=>n===r[d]))return{changed:!1,value:e};const o={};for(const n of i)o[n]=e[n];return{changed:!0,value:o}},K=e=>{if(!C(e))return{changed:!1,value:e};let r=!1;const s={};for(const[i,o]of Object.entries(e)){const n=K(o);s[i]=n.value,n.changed&&(r=!0)}const l=Ce(s);return{changed:r||l.changed,value:l.value}},Ie=(e,r)=>{const s=R(e);let l=!1;if(r.formatBugs!==!1&&Object.hasOwn(s,"bugs")){const i=Pe(s.bugs);i.changed&&(s.bugs=i.value,l=!0)}if(r.formatRepository!==!1&&Object.hasOwn(s,"repository")){const i=Oe(s.repository);i.changed&&(s.repository=i.value,l=!0)}if(r.sortExports!==!1&&Object.hasOwn(s,"exports")&&C(s.exports)){const i=K(s.exports);i.changed&&(s.exports=i.value,l=!0)}return{changed:l,pkg:s}},Re=/at position (\d+)/,Te=/\(?line (\d+) column (\d+)\)?/,Me=e=>{const r=new Set,s=[],l=o=>{const n=W(o);!r.has(n)&&M(n)&&(r.add(n),s.push(n))};l(E(e,"package.json"));const i=re(e);if(i){const o=N(e,i);for(const n of o)l(E(e,n,"package.json"))}else{const o=E(e,"package.json");if(M(o)){const n=JSON.parse(X(o)),d=Array.isArray(n.workspaces)?n.workspaces:n.workspaces?.packages;if(d){const g=N(e,d);for(const m of g)l(E(e,m,"package.json"))}}}return s},Ne=e=>/\n([ \t]+)/.exec(e)?.[1]??" ",Ae=e=>{if(!(e===void 0||e===""))return e==="tab"||e===String.raw`\t`?" ":/^\d+$/.test(e)?" ".repeat(Number.parseInt(e,10)):e},I=e=>e===void 0?[]:(Array.isArray(e)?e:[e]).flatMap(r=>r.split(",")).map(r=>r.trim()).filter(r=>r.length>0),De=e=>e.includes(`\r
2
2
  `)?"crlf":"lf",Fe=new Set(["auto","crlf","lf"]),Ge=e=>{if(e===void 0||e==="")return"auto";if(Fe.has(e))return e;throw new Error(`--line-ending must be one of: auto, lf, crlf (got "${e}")`)},Le=(e,r,s)=>r.length===0?e:e.filter(l=>{const i=J(s,l),o=V(l);return!r.some(n=>{const d=n.includes("/")?i:o;return se(n,d)})}),Be=(e,r)=>{if(r.length===0)return e;const s={},l=new Set;for(const i of r)Object.hasOwn(e,i)&&(s[i]=e[i],l.add(i));for(const i of Object.keys(e))l.has(i)||(s[i]=e[i]);return s},Je=(e,r,s)=>{if(s.length===0)return e;const l={...e};for(const i of s)Object.hasOwn(r,i)&&(l[i]=r[i]);return l},Xe=(e,r)=>{let s=1,l=1;const i=Math.min(r,e.length);for(let o=0;o<i;o++)e.codePointAt(o)===10?(s++,l=1):l++;return{column:l,line:s}},L=(e,r,s=2)=>{const l=e.split(`
3
3
  `);if(r<1||r>l.length)return[];const i=Math.max(0,r-1-s),o=Math.min(l.length,r+s),n=[];for(let d=i;d<o;d++)n.push({content:l[d]??"",isErrorLine:d+1===r,lineNumber:d+1});return n},B=(e,r)=>{if(!(e instanceof Error))return;const s=Re.exec(e.message);if(s){const{column:i,line:o}=Xe(r,Number.parseInt(s[1]??"0",10));return{column:i,line:o,snippet:L(r,o)}}const l=Te.exec(e.message);if(l){const i=Number.parseInt(l[1]??"1",10);return{column:Number.parseInt(l[2]??"1",10),line:i,snippet:L(r,i)}}},qe=(e,r)=>{const s=Object.keys(JSON.parse(e)),l=Object.keys(JSON.parse(r)),i=new Map(s.map((n,d)=>[n,d])),o=[];for(const[n,d]of l.entries()){const g=i.get(d);g!==void 0&&g!==n&&o.push({fromIndex:g,key:d,toIndex:n})}return o},He=(e,r,s)=>{const l=r.indent??s.indent??Ne(e),i=r.lineEnding==="auto"?s.lineEnding??De(e):r.lineEnding,o=q(e,{pretty:!1,sortScripts:r.sortScripts});let n=JSON.parse(o);if(r.unsorted.length>0){const y=JSON.parse(e);n=Je(n,y,r.unsorted)}n=Be(n,r.sortOrder);const d={formatBugs:r.formatBugs,formatRepository:r.formatRepository,sortExports:r.sortExports},g=Ie(n,d);let m=JSON.stringify(g.pkg,null,l);return r.finalNewline&&(m+=`
4
4
  `),i==="crlf"&&(m=m.replaceAll(`
@@ -1,2 +1,2 @@
1
- import{createRequire as H}from"node:module";import{I as W}from"../packem_shared/index-BWl4DbMp.js";import{p as F}from"../packem_shared/prompt-BSAy8SMH.js";import{l as X,w as J,d as U,j as Q}from"../packem_shared/index-uBVnF4ji.js";import{f as D,A as Z,C as ee,r as te,z as se,i as A}from"../packem_shared/en-D3CfXlO7.js";import{a as re}from"../packem_shared/readJsonSync-DweZd5ZA-0eZh9sGm.js";import{g as oe,r as ne}from"../packem_shared/packument-HBVbyf7x.js";import{q as ie,j as ae,E as $,s as k,V as C,I as _}from"../packem_shared/index.server-CusjRLCh.js";import{h as ce,W as le}from"../packem_shared/pm-runner-C6eTANt1.js";import{r as fe,a as pe}from"../packem_shared/command-runtime-BLFPUYAT.js";let L;const q=e=>(L??=H(import.meta.url))(e),v=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,G=e=>{if(typeof v<"u"&&v.versions&&v.versions.node){const[t,s]=v.versions.node.split(".").map(Number);if(t>22||t===22&&s>=3||t===20&&s>=16)return v.getBuiltinModule(e)}return q(e)},{renameSync:Y}=G("node:fs"),{stripVTControlCharacters:z}=G("node:util"),ue=(e={})=>{const t=e.isCi??W;return(e.isTty??!!(process.stdin.isTTY&&process.stdout.isTTY))&&!t},w=J(D(),"dlx-seen.json"),P=(e,t)=>`${e}@${t}`,ge=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"},V=()=>{try{if(X(w)){const e=re(w);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))ge(r)&&(t[s]=r);return{packages:t,version:1}}}}catch{}return{packages:{},version:1}},me=e=>{try{U(D());const t=`${w}.${String(process.pid)}.tmp`;Q(t,JSON.stringify(e)),Y(t,w)}catch{}},de=(e,t,s)=>e.packages[P(t,s)],he=(e,t)=>{if(!e)return!0;const s=new Set(Array.isArray(e.alertKeys)?e.alertKeys:[]);return t.some(r=>!s.has(r))},x=(e,t,s,r)=>{const o=V();o.packages[P(e,t)]={alertKeys:[...s].sort(),seenAt:r},me(o)},ye=/[\u0000-\u0008\u000B-\u001F\u007F]/g,B=e=>z(e).replaceAll(" "," ").replaceAll(ye,""),E=["CHANGELOG.md","CHANGELOG","changelog.md","CHANGES.md","HISTORY.md"],$e=4e3,j=async(e,t,s)=>{if(t?.aborted)return;const r=new AbortController,o=setTimeout(()=>{r.abort()},$e),a=()=>{r.abort()};t?.addEventListener("abort",a,{once:!0});try{const i=await fetch(e,{headers:s,signal:r.signal});return i.ok?await i.text():void 0}catch{return}finally{clearTimeout(o),t?.removeEventListener("abort",a)}},ve=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},R=(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 i=-1,u=0;for(const[c,l]of s.entries()){const f=r.exec(l);if(f&&a.test(f[2])){i=c,u=f[1].length;break}}if(i===-1)return;const n=[];for(let c=i+1;c<s.length;c+=1){const l=r.exec(s[c]);if(l&&l[1].length<=u)break;n.push(s[c])}return n},I=(e,t=4)=>e.map(s=>s.trim()).filter(s=>s.length>0).map(s=>B(s.replace(/^#{1,6}\s+/,"").replace(/^[*-]\s+/,"- ")).trim()).filter(s=>s.length>0&&!/^\[.*\]:/.test(s)).slice(0,t),O=(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=O(r[t],s),a=[o?`${e.name}@${t} — published ${o}`:`${e.name}@${t}`],i=Date.parse(r[t]??""),u=Object.entries(r).filter(([n])=>n!=="created"&&n!=="modified"&&n!==t).sort((n,c)=>Date.parse(c[1])-Date.parse(n[1])).filter(([,n])=>Date.parse(n)<i).slice(0,3);for(const[n,c]of u)a.push(`- ${n} (${O(c,s)})`);return{lines:a,source:"npm-diff",version:t}},ke=async e=>{const{name:t,now:s,offline:r,packument:o,signal:a,version:i}=e;if(r)return o?N(o,i,s):void 0;for(const c of E){const l=`https://cdn.jsdelivr.net/npm/${t}@${i}/${c}`,f=await j(l,a);if(f){const d=R(f,i),p=I(d??f.split(/\r?\n/));if(p.length>0)return{lines:p,source:"package-file",url:l,version:i}}}const u=o?.versions[i],n=ve(u?.repository);if(n){const c=n.directory?`${n.directory.replaceAll(/^\/+|\/+$/g,"")}/`:"";for(const l of["HEAD","main","master"])for(const f of E){const d=`https://raw.githubusercontent.com/${n.owner}/${n.repo}/${l}/${c}${f}`,p=await j(d,a);if(p){const h=R(p,i),m=I(h??p.split(/\r?\n/));if(m.length>0){const g=`https://github.com/${n.owner}/${n.repo}/blob/${l}/${c}${f}`;return{lines:m,source:"repo-file",url:g,version:i}}}}}if(o)return N(o,i,s)},be={dynamicRequire:"dynamic require",envVars:"env access",filesystemAccess:"filesystem",networkAccess:"network",shellAccess:"shell",telemetry:"telemetry",unsafe:"eval/unsafe",usesEval:"eval/unsafe"},we=["preinstall","install","postinstall"],Se=(e,t)=>({fileCount:e?.dist?.fileCount,tarballBytes:t?.size,unpackedBytes:e?.dist?.unpackedSize}),Te=(e,t)=>{const s=we.filter(i=>!!e?.scripts?.[i]),r=e?.bin,o=typeof r=="string"?["(default)"]:Object.keys(r??{}).map(i=>B(i)),a=[...new Set(t.map(i=>be[i.type]).filter(i=>i!==void 0))];return{bins:o,capabilities:a,lifecycleScripts:s}},Ce=(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:i,workspaceRoot:u}=e;let n;try{n=await oe(t,{offline:r,signal:o,workspaceRoot:u})}catch{n=void 0}const c=n?ne(n,i):void 0;if(!c)return;const l=n?.versions[c],f=async()=>{if(!(r||!a))try{const y=await ee([{name:t,version:c}],{apiToken:a});return Ce(y,t,c)}catch{return}},d=ke({name:t,now:s,offline:r,packument:n,signal:o,version:c}).catch(()=>{}),[p,h]=await Promise.all([f(),d]),m=p?.alerts??[],g=[...new Set(m.filter(y=>y.severity==="critical"||y.severity==="high").map(y=>y.key))].sort(),S=p?Math.round((p.score.overall??Z(p.score))*100):void 0;return{changelog:h,name:t,permissions:Te(l,m),security:{alerts:m,available:!!p,highSeverityKeys:g,score:S},size:Se(l,p),version:c}},b=e=>te(z(e)),_e={critical:C,high:C,low:$,medium:k},K=e=>{if(!(e===void 0||e<0))return se(e,{decimals:1,space:!0})},xe=e=>{const{fileCount:t,tarballBytes:s,unpackedBytes:r}=e.size,o=K(r),a=K(s);if(o&&a){const i=t===void 0?"":`, ${String(t)} files`;return`${o} unpacked (${a} tarball${i})`}if(o)return`${o} unpacked`;if(a)return`${a} tarball`},Ee=e=>{const{alerts:t,available:s,score:r}=e.security;if(!s)return $("unavailable — set VIS_SOCKET_TOKEN for a Socket.dev score");const o=r===void 0?$:r>=70?_:r>=40?k:C,a=r===void 0?"n/a":`${String(r)}/100`,i=new Map;for(const l of t)i.set(l.severity,(i.get(l.severity)??0)+1);const u=[],n=["critical","high","medium","low"];for(const l of n){const f=i.get(l);f&&u.push(_e[l](`${String(f)} ${l}`))}const c=u.length>0?` ${k("!")} ${u.join(", ")}`:` ${_("no alerts")}`;return`${o(a)} ${$("(Socket.dev)")}${c}`},je=e=>{const{bins:t,capabilities:s,lifecycleScripts:r}=e.permissions,o=[];for(const a of r)o.push(k(`${a} script`));for(const a of s)o.push(k(a));return t.length>0&&o.push($(`bins: ${t.join(", ")}`)),o.length>0?o.join($(" · ")):void 0},Re=e=>{const t=[],s=xe(e);s&&t.push({label:"size",values:[s]}),t.push({label:"score",values:[Ee(e)]});const r=je(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,$(`source: ${o}`)]})}return t},M=6,Ie=e=>{const t=Re(e),s=` first run: ${e.name}@${e.version} `,r=[];for(const n of t)n.values.forEach((c,l)=>{const f=l===0?ie(n.label.padEnd(M)):" ".repeat(M);r.push(`${f} ${c}`)});const o=Math.max(b(s),...r.map(n=>b(n))),a=n=>`${n}${" ".repeat(Math.max(0,o-b(n)))}`,i=`┌─${ae(s)}${"─".repeat(Math.max(0,o-b(s)))}─┐`,u=`└─${"─".repeat(o)}─┘`;return[i,...r.map(n=>`│ ${a(n)} │`),u]},Oe=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)}},Ne=e=>e===""||e.startsWith(".")||e.startsWith("/")||e.startsWith("~")?!1:!(e.startsWith("@")?e.slice(1):e).includes(":"),Ke=6e3,Me=e=>{process.stdout.write(e)},Ge=async e=>{const{forceInfo:t=!1,noInfo:s=!1,offline:r=!1,pkg:o,socketToken:a,workspaceRoot:i,yes:u=!1}=e;if(s||!Ne(o))return{proceed:!0};const n=e.now??Date.now(),c=u||!ue({isCi:e.isCi,isTty:e.isTty}),l=e.output??Me;if(c&&!t)return{proceed:!0};const{name:f,spec:d}=Oe(o),p=new AbortController;let h;const m=new Promise(T=>{h=setTimeout(()=>{p.abort(),T(void 0)},Ke)}),g=await Promise.race([Ae({name:f,now:n,offline:r,signal:p.signal,socketToken:a,spec:d,workspaceRoot:i}).catch(()=>{}),m]);if(h&&clearTimeout(h),!g)return{proceed:!0};const S=de(V(),g.name,g.version);if(!t&&!he(S,g.security.highSeverityKeys))return{proceed:!0};for(const T of Ie(g))l(`${T}
1
+ import{createRequire as H}from"node:module";import{I as W}from"../packem_shared/index-BWl4DbMp.js";import{p as F}from"../packem_shared/prompt-BSAy8SMH.js";import{l as X,w as J,d as U,j as Q}from"../packem_shared/index-BLtnel38.js";import{f as D,A as Z,C as ee,r as te,z as se,i as A}from"../packem_shared/en-BDYMmM2_.js";import{a as re}from"../packem_shared/readJsonSync-DweZd5ZA-CtrDlqpb.js";import{g as oe,r as ne}from"../packem_shared/packument-B9-WqReu.js";import{q as ie,j as ae,E as $,s as k,V as C,I as _}from"../packem_shared/index.server-CusjRLCh.js";import{h as ce,W as le}from"../packem_shared/pm-runner-DRybtzOV.js";import{r as fe,a as pe}from"../packem_shared/command-runtime-DQ7ZpLYL.js";let L;const q=e=>(L??=H(import.meta.url))(e),v=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,G=e=>{if(typeof v<"u"&&v.versions&&v.versions.node){const[t,s]=v.versions.node.split(".").map(Number);if(t>22||t===22&&s>=3||t===20&&s>=16)return v.getBuiltinModule(e)}return q(e)},{renameSync:Y}=G("node:fs"),{stripVTControlCharacters:z}=G("node:util"),ue=(e={})=>{const t=e.isCi??W;return(e.isTty??!!(process.stdin.isTTY&&process.stdout.isTTY))&&!t},w=J(D(),"dlx-seen.json"),P=(e,t)=>`${e}@${t}`,ge=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"},V=()=>{try{if(X(w)){const e=re(w);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))ge(r)&&(t[s]=r);return{packages:t,version:1}}}}catch{}return{packages:{},version:1}},me=e=>{try{U(D());const t=`${w}.${String(process.pid)}.tmp`;Q(t,JSON.stringify(e)),Y(t,w)}catch{}},de=(e,t,s)=>e.packages[P(t,s)],he=(e,t)=>{if(!e)return!0;const s=new Set(Array.isArray(e.alertKeys)?e.alertKeys:[]);return t.some(r=>!s.has(r))},x=(e,t,s,r)=>{const o=V();o.packages[P(e,t)]={alertKeys:[...s].sort(),seenAt:r},me(o)},ye=/[\u0000-\u0008\u000B-\u001F\u007F]/g,B=e=>z(e).replaceAll(" "," ").replaceAll(ye,""),E=["CHANGELOG.md","CHANGELOG","changelog.md","CHANGES.md","HISTORY.md"],$e=4e3,j=async(e,t,s)=>{if(t?.aborted)return;const r=new AbortController,o=setTimeout(()=>{r.abort()},$e),a=()=>{r.abort()};t?.addEventListener("abort",a,{once:!0});try{const i=await fetch(e,{headers:s,signal:r.signal});return i.ok?await i.text():void 0}catch{return}finally{clearTimeout(o),t?.removeEventListener("abort",a)}},ve=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},R=(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 i=-1,u=0;for(const[c,l]of s.entries()){const f=r.exec(l);if(f&&a.test(f[2])){i=c,u=f[1].length;break}}if(i===-1)return;const n=[];for(let c=i+1;c<s.length;c+=1){const l=r.exec(s[c]);if(l&&l[1].length<=u)break;n.push(s[c])}return n},I=(e,t=4)=>e.map(s=>s.trim()).filter(s=>s.length>0).map(s=>B(s.replace(/^#{1,6}\s+/,"").replace(/^[*-]\s+/,"- ")).trim()).filter(s=>s.length>0&&!/^\[.*\]:/.test(s)).slice(0,t),O=(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=O(r[t],s),a=[o?`${e.name}@${t} — published ${o}`:`${e.name}@${t}`],i=Date.parse(r[t]??""),u=Object.entries(r).filter(([n])=>n!=="created"&&n!=="modified"&&n!==t).sort((n,c)=>Date.parse(c[1])-Date.parse(n[1])).filter(([,n])=>Date.parse(n)<i).slice(0,3);for(const[n,c]of u)a.push(`- ${n} (${O(c,s)})`);return{lines:a,source:"npm-diff",version:t}},ke=async e=>{const{name:t,now:s,offline:r,packument:o,signal:a,version:i}=e;if(r)return o?N(o,i,s):void 0;for(const c of E){const l=`https://cdn.jsdelivr.net/npm/${t}@${i}/${c}`,f=await j(l,a);if(f){const d=R(f,i),p=I(d??f.split(/\r?\n/));if(p.length>0)return{lines:p,source:"package-file",url:l,version:i}}}const u=o?.versions[i],n=ve(u?.repository);if(n){const c=n.directory?`${n.directory.replaceAll(/^\/+|\/+$/g,"")}/`:"";for(const l of["HEAD","main","master"])for(const f of E){const d=`https://raw.githubusercontent.com/${n.owner}/${n.repo}/${l}/${c}${f}`,p=await j(d,a);if(p){const h=R(p,i),m=I(h??p.split(/\r?\n/));if(m.length>0){const g=`https://github.com/${n.owner}/${n.repo}/blob/${l}/${c}${f}`;return{lines:m,source:"repo-file",url:g,version:i}}}}}if(o)return N(o,i,s)},be={dynamicRequire:"dynamic require",envVars:"env access",filesystemAccess:"filesystem",networkAccess:"network",shellAccess:"shell",telemetry:"telemetry",unsafe:"eval/unsafe",usesEval:"eval/unsafe"},we=["preinstall","install","postinstall"],Se=(e,t)=>({fileCount:e?.dist?.fileCount,tarballBytes:t?.size,unpackedBytes:e?.dist?.unpackedSize}),Te=(e,t)=>{const s=we.filter(i=>!!e?.scripts?.[i]),r=e?.bin,o=typeof r=="string"?["(default)"]:Object.keys(r??{}).map(i=>B(i)),a=[...new Set(t.map(i=>be[i.type]).filter(i=>i!==void 0))];return{bins:o,capabilities:a,lifecycleScripts:s}},Ce=(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:i,workspaceRoot:u}=e;let n;try{n=await oe(t,{offline:r,signal:o,workspaceRoot:u})}catch{n=void 0}const c=n?ne(n,i):void 0;if(!c)return;const l=n?.versions[c],f=async()=>{if(!(r||!a))try{const y=await ee([{name:t,version:c}],{apiToken:a});return Ce(y,t,c)}catch{return}},d=ke({name:t,now:s,offline:r,packument:n,signal:o,version:c}).catch(()=>{}),[p,h]=await Promise.all([f(),d]),m=p?.alerts??[],g=[...new Set(m.filter(y=>y.severity==="critical"||y.severity==="high").map(y=>y.key))].sort(),S=p?Math.round((p.score.overall??Z(p.score))*100):void 0;return{changelog:h,name:t,permissions:Te(l,m),security:{alerts:m,available:!!p,highSeverityKeys:g,score:S},size:Se(l,p),version:c}},b=e=>te(z(e)),_e={critical:C,high:C,low:$,medium:k},K=e=>{if(!(e===void 0||e<0))return se(e,{decimals:1,space:!0})},xe=e=>{const{fileCount:t,tarballBytes:s,unpackedBytes:r}=e.size,o=K(r),a=K(s);if(o&&a){const i=t===void 0?"":`, ${String(t)} files`;return`${o} unpacked (${a} tarball${i})`}if(o)return`${o} unpacked`;if(a)return`${a} tarball`},Ee=e=>{const{alerts:t,available:s,score:r}=e.security;if(!s)return $("unavailable — set VIS_SOCKET_TOKEN for a Socket.dev score");const o=r===void 0?$:r>=70?_:r>=40?k:C,a=r===void 0?"n/a":`${String(r)}/100`,i=new Map;for(const l of t)i.set(l.severity,(i.get(l.severity)??0)+1);const u=[],n=["critical","high","medium","low"];for(const l of n){const f=i.get(l);f&&u.push(_e[l](`${String(f)} ${l}`))}const c=u.length>0?` ${k("!")} ${u.join(", ")}`:` ${_("no alerts")}`;return`${o(a)} ${$("(Socket.dev)")}${c}`},je=e=>{const{bins:t,capabilities:s,lifecycleScripts:r}=e.permissions,o=[];for(const a of r)o.push(k(`${a} script`));for(const a of s)o.push(k(a));return t.length>0&&o.push($(`bins: ${t.join(", ")}`)),o.length>0?o.join($(" · ")):void 0},Re=e=>{const t=[],s=xe(e);s&&t.push({label:"size",values:[s]}),t.push({label:"score",values:[Ee(e)]});const r=je(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,$(`source: ${o}`)]})}return t},M=6,Ie=e=>{const t=Re(e),s=` first run: ${e.name}@${e.version} `,r=[];for(const n of t)n.values.forEach((c,l)=>{const f=l===0?ie(n.label.padEnd(M)):" ".repeat(M);r.push(`${f} ${c}`)});const o=Math.max(b(s),...r.map(n=>b(n))),a=n=>`${n}${" ".repeat(Math.max(0,o-b(n)))}`,i=`┌─${ae(s)}${"─".repeat(Math.max(0,o-b(s)))}─┐`,u=`└─${"─".repeat(o)}─┘`;return[i,...r.map(n=>`│ ${a(n)} │`),u]},Oe=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)}},Ne=e=>e===""||e.startsWith(".")||e.startsWith("/")||e.startsWith("~")?!1:!(e.startsWith("@")?e.slice(1):e).includes(":"),Ke=6e3,Me=e=>{process.stdout.write(e)},Ge=async e=>{const{forceInfo:t=!1,noInfo:s=!1,offline:r=!1,pkg:o,socketToken:a,workspaceRoot:i,yes:u=!1}=e;if(s||!Ne(o))return{proceed:!0};const n=e.now??Date.now(),c=u||!ue({isCi:e.isCi,isTty:e.isTty}),l=e.output??Me;if(c&&!t)return{proceed:!0};const{name:f,spec:d}=Oe(o),p=new AbortController;let h;const m=new Promise(T=>{h=setTimeout(()=>{p.abort(),T(void 0)},Ke)}),g=await Promise.race([Ae({name:f,now:n,offline:r,signal:p.signal,socketToken:a,spec:d,workspaceRoot:i}).catch(()=>{}),m]);if(h&&clearTimeout(h),!g)return{proceed:!0};const S=de(V(),g.name,g.version);if(!t&&!he(S,g.security.highSeverityKeys))return{proceed:!0};for(const T of Ie(g))l(`${T}
2
2
  `);if(c)return x(g.name,g.version,g.security.highSeverityKeys,n),{proceed:!0};const y=await F("? Ok to proceed? (y/N) ",e.readline);return y&&x(g.name,g.version,g.security.highSeverityKeys,n),{proceed:y}},Ye=async({argument:e,logger:t,options:s,visConfig:r,workspaceRoot:o})=>{const a=e;if(!a||a.length===0)throw new Error("No package specified. Usage: vis dlx <package[@version]> [args...]");const[i,...u]=a,n=o??process.cwd(),c=s.package?Array.isArray(s.package)?s.package:[s.package]:[],l=s.shellMode?c:[i,...c];for(const h of l){const m=s.info||!1,g=m?!1:s.noInfo||A(process.env.VIS_DLX_NO_INFO);if(!(await Ge({forceInfo:m,noInfo:g,offline:s.offline||!1,pkg:h,socketToken:r?.security?.socket?.apiToken??process.env.VIS_SOCKET_TOKEN,workspaceRoot:n,yes:s.yes||A(process.env.VIS_DLX_YES)})).proceed){t.info("Aborted."),process.exitCode=1;return}}const f=fe({logger:t,options:s,visConfig:r},n),d=ce(n,{backend:pe(f),configBackend:r?.install?.backend,configCorepack:r?.install?.corepack}),p=le(d,{additionalPackages:c,args:u,package:i,shellMode:s.shellMode||!1,silent:s.silent||!1},n,t,{offline:s.offline||!1});p!==0&&(process.exitCode=p)};export{Ye as default};
@@ -1,24 +1,24 @@
1
- import{w as O,z as _,l as B,j as D,u as ce,P as ae}from"../packem_shared/index-uBVnF4ji.js";import{t as le,l as t,m as h,i as a,r as A,X as de,R as pe,x as fe,e as J}from"./catalog.js";import"../packem_shared/en-D3CfXlO7.js";import{I as he}from"../packem_shared/index-BWl4DbMp.js";import me from"module-replacements/manifests/micro-utilities.json"with{type:"json"};import ue from"module-replacements/manifests/native.json"with{type:"json"};import ge from"module-replacements/manifests/preferred.json"with{type:"json"};import{s as Z}from"../packem_shared/index-BAe6e0XE.js";import{J as xe,I as ye,K as je,M as ke,p as y}from"./cli-main.js";import"../packem_shared/public-api-WqUCiyIe.js";import{A as we,y as ve}from"../packem_shared/pm-runner-C6eTANt1.js";import{ScrollView as $e}from"@visulima/tui-kit/scroll-view";import{ScrollBar as be}from"@visulima/tui-kit/scroll-bar";import{a as Q}from"../packem_shared/readJsonSync-DweZd5ZA-0eZh9sGm.js";import{s as Ce}from"../packem_shared/glob-BUjyjdE8-C4M8e02u.js";import __cjs_mod__ from "node:module"; // -- packem CommonJS require shim --
1
+ import{w as O,z as _,l as B,j as D,a as ce,P as ae}from"../packem_shared/index-BLtnel38.js";import{t as le,l as t,m as h,i as a,r as A,X as de,R as pe,x as fe,e as J}from"./catalog.js";import"../packem_shared/en-BDYMmM2_.js";import{I as he}from"../packem_shared/index-BWl4DbMp.js";import me from"module-replacements/manifests/micro-utilities.json"with{type:"json"};import ue from"module-replacements/manifests/native.json"with{type:"json"};import ge from"module-replacements/manifests/preferred.json"with{type:"json"};import{s as Z}from"../packem_shared/index-BAe6e0XE.js";import{J as xe,I as ye,K as je,M as ke,p as y}from"./cli-main.js";import"../packem_shared/index-tNFGWxc0.js";import{A as we,y as ve}from"../packem_shared/pm-runner-DRybtzOV.js";import{ScrollView as $e}from"@visulima/tui-kit/scroll-view";import{ScrollBar as be}from"@visulima/tui-kit/scroll-bar";import{a as Q}from"../packem_shared/readJsonSync-DweZd5ZA-CtrDlqpb.js";import{s as Ce}from"../packem_shared/glob-BUjyjdE8-Dp_QcayW.js";import __cjs_mod__ from "node:module"; // -- packem CommonJS require shim --
2
2
  const require = __cjs_mod__.createRequire(import.meta.url);
3
- const Se=["dependencies","devDependencies","peerDependencies","peerDependenciesMeta","optionalDependencies","bundleDependencies"],Oe=["overrides","pnpm","resolutions"],Ne=["engines","files"],Ee=r=>{const e=Z.coerce(r)?.major;return e!==void 0&&e>=10},Pe=r=>{const e=O(r,"pnpm-workspace.yaml");if(!B(e))return{overrides:{},source:"pnpm-workspace.yaml"};try{return{overrides:ce(e)?.overrides??{},source:"pnpm-workspace.yaml"}}catch{return{overrides:{},source:"pnpm-workspace.yaml"}}},Te=(r,e)=>{let o={};return e==="deno"?{overrides:{},source:"package.json"}:(e==="pnpm"?o=r.pnpm?.overrides??{}:e==="yarn"||e==="bun"?o=r.resolutions??{}:o=r.overrides??{},{overrides:o,source:"package.json"})},Ae=(r,e,o)=>o.name==="pnpm"&&Ee(o.version)?Pe(r):Te(e,o.name),X=(r,e)=>{const o=e;for(const c of Oe){const s=r.indexOf(c);if(s!==-1&&c!==o)return o==="overrides"?s:s+1}let n=-1;for(const c of Se){const s=r.indexOf(c);s>n&&(n=s)}if(n!==-1)return n+1;for(const c of Ne){const s=r.indexOf(c);if(s!==-1)return s}return r.length},De=(r,e)=>{const o=O(r,"pnpm-workspace.yaml");if(!B(o))throw new Error(`pnpm-workspace.yaml not found at ${o}. Cannot write overrides for pnpm v10+.`);let n=_(o);const c=`overrides:
4
- ${Object.entries(e).map(([s,l])=>` '${s}': '${l}'`).join(`
3
+ const Se=["dependencies","devDependencies","peerDependencies","peerDependenciesMeta","optionalDependencies","bundleDependencies"],Oe=["overrides","pnpm","resolutions"],Ne=["engines","files"],Ee=r=>{const e=Z.coerce(r)?.major;return e!==void 0&&e>=10},Pe=r=>{const e=O(r,"pnpm-workspace.yaml");if(!B(e))return{overrides:{},source:"pnpm-workspace.yaml"};try{return{overrides:ce(e)?.overrides??{},source:"pnpm-workspace.yaml"}}catch{return{overrides:{},source:"pnpm-workspace.yaml"}}},Te=(r,e)=>{let o={};return e==="deno"?{overrides:{},source:"package.json"}:(e==="pnpm"?o=r.pnpm?.overrides??{}:e==="yarn"||e==="bun"?o=r.resolutions??{}:o=r.overrides??{},{overrides:o,source:"package.json"})},Ae=(r,e,o)=>o.name==="pnpm"&&Ee(o.version)?Pe(r):Te(e,o.name),X=(r,e)=>{const o=e;for(const c of Oe){const i=r.indexOf(c);if(i!==-1&&c!==o)return o==="overrides"?i:i+1}let n=-1;for(const c of Se){const i=r.indexOf(c);i>n&&(n=i)}if(n!==-1)return n+1;for(const c of Ne){const i=r.indexOf(c);if(i!==-1)return i}return r.length},De=(r,e)=>{const o=O(r,"pnpm-workspace.yaml");if(!B(o))throw new Error(`pnpm-workspace.yaml not found at ${o}. Cannot write overrides for pnpm v10+.`);let n=_(o);const c=`overrides:
4
+ ${Object.entries(e).map(([i,l])=>` '${i}': '${l}'`).join(`
5
5
  `)}
6
6
  `;n=/^overrides:\s*$/m.test(n)||/^overrides:\s*\n/m.test(n)?n.replace(/^overrides:\s*\n(?:(?:[ \t].*)?\n)*/m,c):`${n.trimEnd()}
7
7
 
8
- ${c}`,D(o,n)},_e=(r,e,o,n,c)=>{const s=_(r),l=le(r,s,{useEditorconfig:c});if(n==="pnpm"){const m=e.pnpm??{};if(m.overrides=o,e.pnpm)e.pnpm=m,D(r,`${JSON.stringify(e,null,l)}
9
- `);else{const k=Object.keys(e),i=X(k,"pnpm"),d=Object.entries(e);d.splice(i,0,["pnpm",m]),D(r,`${JSON.stringify(Object.fromEntries(d),null,l)}
8
+ ${c}`,D(o,n)},_e=(r,e,o,n,c)=>{const i=_(r),l=le(r,i,{useEditorconfig:c});if(n==="pnpm"){const m=e.pnpm??{};if(m.overrides=o,e.pnpm)e.pnpm=m,D(r,`${JSON.stringify(e,null,l)}
9
+ `);else{const k=Object.keys(e),s=X(k,"pnpm"),d=Object.entries(e);d.splice(s,0,["pnpm",m]),D(r,`${JSON.stringify(Object.fromEntries(d),null,l)}
10
10
  `)}}else{const m=n==="yarn"||n==="bun"?"resolutions":"overrides";if(e[m])e[m]=o,D(r,`${JSON.stringify(e,null,l)}
11
- `);else{const k=Object.keys(e),i=X(k,m),d=Object.entries(e);d.splice(i,0,[m,o]),D(r,`${JSON.stringify(Object.fromEntries(d),null,l)}
12
- `)}}},Ie=(r,e,o,n,c)=>{if(n.name==="deno")return{added:[],updated:[]};const s=_(e),l=JSON.parse(s),{overrides:m,source:k}=Ae(r,l,n),i=[],d=[],u=new Set;if(n.name==="npm")for(const f of["dependencies","devDependencies"]){const x=l[f];if(x)for(const $ of Object.keys(x))u.add($)}for(const f of o){const x=m[f.original];if(typeof x=="object")continue;let $=f.spec;n.name==="npm"&&u.has(f.original)&&($=`$${f.original}`),x!==$&&(x?d.push(f.original):i.push(f.original),m[f.original]=$)}if(i.length===0&&d.length===0)return{added:i,updated:d};const j=Object.fromEntries(Object.entries(m).sort(([f],[x])=>f.localeCompare(x)));return k==="pnpm-workspace.yaml"?De(r,j):_e(e,l,j,n.name,c),{added:i,updated:d}},Re=(r,e)=>{const o={bun:["bun.lock"],deno:["deno.lock"],npm:["npm-shrinkwrap.json","package-lock.json"],pnpm:["pnpm-lock.yaml"],yarn:["yarn.lock"]};for(const n of o[e]??[]){const c=O(r,n);try{return _(c)}catch{continue}}return""},Fe=(r,e,o)=>{if(!r)return!1;const n=e.replaceAll(/[.*+?^${}()|[\]\\]/g,String.raw`\$&`);switch(o){case"bun":return r.includes(`"${e}":`)||new RegExp(String.raw`(^|\s|[",])${n}@`,"m").test(r);case"deno":return r.includes(`"${e}"`)||r.includes(`"npm:${e}@`)||r.includes(`"jsr:${e}@`);case"npm":return r.includes(`"${e}":`)||r.includes(`"node_modules/${e}":`);case"pnpm":return new RegExp(String.raw`(^|\s|['"/])${n}(@|['"]?:)`,"m").test(r);case"yarn":return new RegExp(String.raw`(^|\s|[",])${n}@`,"m").test(r);default:return!1}};var z={exports:{}},U,H;function K(){if(H)return U;H=1;var r=Object.defineProperty,e=Object.getOwnPropertyDescriptor,o=Object.getOwnPropertyNames,n=Object.prototype.hasOwnProperty,c=(i,d)=>{for(var u in d)r(i,u,{get:d[u],enumerable:!0})},s=(i,d,u,j)=>{if(d&&typeof d=="object"||typeof d=="function")for(let f of o(d))!n.call(i,f)&&f!==u&&r(i,f,{get:()=>d[f],enumerable:!(j=e(d,f))||j.enumerable});return i},l=i=>s(r({},"__esModule",{value:!0}),i),m={};c(m,{PURL_Type:()=>k}),U=l(m);var k=(i=>(i.APK="apk",i.BITBUCKET="bitbucket",i.COCOAPODS="cocoapods",i.CARGO="cargo",i.CHROME="chrome",i.COMPOSER="composer",i.CONAN="conan",i.CONDA="conda",i.CRAN="cran",i.DEB="deb",i.DOCKER="docker",i.GEM="gem",i.GENERIC="generic",i.GITHUB="github",i.GOLANG="golang",i.HACKAGE="hackage",i.HEX="hex",i.HUGGINGFACE="huggingface",i.MAVEN="maven",i.MLFLOW="mlflow",i.NPM="npm",i.NUGET="nuget",i.OCI="oci",i.PUB="pub",i.PYPI="pypi",i.QPKG="qpkg",i.RPM="rpm",i.SWID="swid",i.SWIFT="swift",i.VCS="vcs",i))(k||{});return U}var V;function Me(){return V||(V=1,(function(r){var e=Object.defineProperty,o=Object.getOwnPropertyDescriptor,n=Object.getOwnPropertyNames,c=Object.prototype.hasOwnProperty,s=(d,u)=>{for(var j in u)e(d,j,{get:u[j],enumerable:!0})},l=(d,u,j,f)=>{if(u&&typeof u=="object"||typeof u=="function")for(let x of n(u))!c.call(d,x)&&x!==j&&e(d,x,{get:()=>u[x],enumerable:!(f=o(u,x))||f.enumerable});return d},m=(d,u,j)=>(l(d,u,"default"),j&&l(j,u,"default")),k={};s(k,{getManifestData:()=>i}),m(k,K(),r.exports);function i(d,u){try{const j=require("../manifest.json");if(!d)return j;const f=j[d];if(!f)return;if(!u)return f;const x=f.find(([$,g])=>g.package===u);return x?x[1]:void 0}catch{return}}r.exports={getManifestData:i,...K()}})(z)),z.exports}var Ge=Me();const Le=(r,e,o)=>{let n=r;if(e!=="all"&&(n=n.filter(c=>c.category===e)),o){const c=o.toLowerCase();n=n.filter(s=>s.packageName.toLowerCase().includes(c))}return n};class ze{#e;#t=new Set;constructor(e){this.#e={applyProgress:null,checkedEntries:new Set,entries:e,error:null,filterActive:!1,filterText:"",filterType:"all",focusedPanel:"list",phase:"browsing",selectedIndex:0}}getSnapshot=()=>this.#e;subscribe=e=>(this.#t.add(e),()=>{this.#t.delete(e)});getFilteredEntries=()=>Le(this.#e.entries,this.#e.filterType,this.#e.filterText);#r(){this.#e={...this.#e};for(const e of this.#t)e()}select(e){const o=this.getFilteredEntries();this.#e.selectedIndex=o.length===0?-1:Math.max(0,Math.min(e,o.length-1)),this.#r()}toggleCheck(e){const o=new Set(this.#e.checkedEntries);o.has(e)?o.delete(e):o.add(e),this.#e.checkedEntries=o,this.#r()}toggleAll(){const e=this.getFilteredEntries(),o=new Set(this.#e.checkedEntries);if(e.every(n=>o.has(n.packageName)))for(const n of e)o.delete(n.packageName);else for(const n of e)o.add(n.packageName);this.#e.checkedEntries=o,this.#r()}setFilter(e){this.#e.filterType=e,this.#e.selectedIndex=0,this.#r()}setFilterText(e){this.#e.filterText=e,this.#e.selectedIndex=0,this.#r()}setFilterActive(e){this.#e.filterActive=e,this.#r()}setFocusedPanel(e){this.#e.focusedPanel=e,this.#r()}setPhase(e){this.#e.phase=e,this.#r()}setProgress(e,o){this.#e.applyProgress={current:e,total:o},this.#r()}setError(e){this.#e.error=e,this.#e.phase="error",this.#r()}getCheckedEntries(){return this.#e.entries.filter(e=>this.#e.checkedEntries.has(e.packageName))}}const ee={"micro-utility":"gray",native:"green",preferred:"yellow",socket:"cyan"},Ue={"micro-utility":"MICRO",native:"NATIVE",preferred:"PREF",socket:"SOCKET"},qe={"micro-utility":"Trivial utility package that can be replaced with inline code.",native:"Polyfill for a native JS/Node.js API. Use the built-in instead.",preferred:"A lighter or faster alternative package exists.",socket:"Security-hardened replacement from Socket.dev's @socketregistry."},Be=({entry:r,focused:e,scrollRef:o})=>{const n=e?"white":"gray";if(!r)return t.jsx(h,{alignItems:"center",borderColor:"gray",borderStyle:"single",flexDirection:"column",flexGrow:1,justifyContent:"center",children:t.jsx(a,{dimColor:!0,children:"No entry selected"})});const c=ee[r.category]??"gray";return t.jsxs(h,{borderColor:n,borderStyle:"single",flexDirection:"column",flexGrow:1,children:[t.jsx(h,{flexShrink:0,paddingTop:1,paddingX:2,children:t.jsx(a,{bold:!0,color:"white",children:r.packageName})}),t.jsxs($e,{flexGrow:1,flexShrink:1,paddingX:2,ref:o,scrollbar:!0,scrollbarColor:"gray",children:[t.jsx(a,{}),t.jsxs(h,{children:[t.jsx(h,{width:14,children:t.jsx(a,{dimColor:!0,children:"Category:"})}),t.jsx(a,{bold:!0,color:c,children:r.category})]}),t.jsxs(h,{children:[t.jsx(h,{width:14,children:t.jsx(a,{dimColor:!0,children:"Replace with:"})}),t.jsx(a,{children:r.replacement})]}),r.overrideSpec&&t.jsxs(h,{children:[t.jsx(h,{width:14,children:t.jsx(a,{dimColor:!0,children:"Override:"})}),t.jsx(a,{color:"cyan",children:r.overrideSpec})]}),t.jsxs(h,{children:[t.jsx(h,{width:14,children:t.jsx(a,{dimColor:!0,children:"Codemod:"})}),t.jsx(a,{color:r.hasCodemod?"green":"gray",children:r.hasCodemod?"available ⚙":"not available"})]}),t.jsxs(h,{flexDirection:"column",marginTop:1,children:[t.jsx(a,{dimColor:!0,children:"── "}),t.jsx(a,{bold:!0,color:"white",children:"DESCRIPTION"}),t.jsx(h,{marginTop:1,paddingLeft:2,children:t.jsx(a,{children:qe[r.category]??""})})]}),r.category==="native"&&t.jsxs(h,{flexDirection:"column",marginTop:1,children:[t.jsx(a,{dimColor:!0,children:"── "}),t.jsx(a,{bold:!0,color:"green",children:"ACTION"}),t.jsx(h,{flexDirection:"column",marginTop:1,paddingLeft:2,children:r.hasCodemod?t.jsxs(t.Fragment,{children:[t.jsxs(a,{color:"green",children:["✓"," ","Codemod will rewrite imports to use native API."]}),t.jsx(a,{dimColor:!0,children:" The package can then be removed from dependencies."})]}):t.jsxs(t.Fragment,{children:[t.jsxs(a,{color:"yellow",children:["ℹ"," ","No automated codemod available."]}),t.jsx(a,{dimColor:!0,children:" Manual migration required — replace usage with native equivalent."})]})})]}),r.category==="socket"&&t.jsxs(h,{flexDirection:"column",marginTop:1,children:[t.jsx(a,{dimColor:!0,children:"── "}),t.jsx(a,{bold:!0,color:"cyan",children:"ACTION"}),t.jsxs(h,{flexDirection:"column",marginTop:1,paddingLeft:2,children:[t.jsxs(a,{color:"cyan",children:["✓"," ","Override will redirect resolution to the hardened package."]}),t.jsx(a,{dimColor:!0,children:" No source code changes needed — drop-in replacement."})]})]}),(r.category==="preferred"||r.category==="micro-utility")&&t.jsxs(h,{flexDirection:"column",marginTop:1,children:[t.jsx(a,{dimColor:!0,children:"── "}),t.jsx(a,{bold:!0,color:"yellow",children:"ACTION"}),t.jsx(h,{flexDirection:"column",marginTop:1,paddingLeft:2,children:r.hasCodemod?t.jsxs(t.Fragment,{children:[t.jsxs(a,{color:"green",children:["✓"," ","Codemod will rewrite imports to the recommended alternative."]}),t.jsx(a,{dimColor:!0,children:" The original package can then be removed from dependencies."})]}):t.jsxs(t.Fragment,{children:[t.jsxs(a,{color:"yellow",children:["ℹ"," ","Manual migration required."]}),r.docUrl?t.jsx(a,{dimColor:!0,children:" Open the migration guide below for the recommended alternative and steps."}):t.jsx(a,{dimColor:!0,children:" Consult the package's docs or the e18e module-replacements guide for an alternative."})]})})]}),t.jsxs(h,{flexDirection:"column",marginTop:1,children:[t.jsx(a,{dimColor:!0,children:"── "}),t.jsx(a,{bold:!0,color:"white",children:"LINKS"}),t.jsxs(h,{flexDirection:"column",marginTop:1,paddingLeft:2,children:[t.jsxs(a,{color:"cyan",underline:!0,children:["https://npmx.dev/",r.packageName]}),r.docUrl&&t.jsx(a,{color:"cyan",underline:!0,children:r.docUrl})]})]})]})]})},Je=[{key:"all",label:"All",shortcut:"1"},{key:"native",label:"Native",shortcut:"2"},{key:"preferred",label:"Preferred",shortcut:"3"},{key:"micro-utility",label:"Micro",shortcut:"4"},{key:"socket",label:"Socket",shortcut:"5"}],Xe=({checked:r,entry:e,isSelected:o})=>{const n=ee[e.category]??"white",c=Ue[e.category]??e.category,s=r?"☑":"☐",l=e.hasCodemod?"⚙":" ";return t.jsxs(h,{flexShrink:0,height:1,children:[t.jsx(a,{children:o?">":" "}),t.jsxs(a,{color:r?"white":"gray",children:[" ",s," "]}),t.jsx(a,{bold:!0,color:n,children:`[${c}]`.padEnd(9)}),t.jsxs(a,{children:[" ",l," "]}),t.jsx(h,{flexGrow:1,children:t.jsx(a,{bold:o,inverse:o,wrap:"truncate",children:e.packageName})}),t.jsx(a,{dimColor:!0,children:" → "}),t.jsx(a,{wrap:"truncate",children:e.replacement})]})},He=({checkedEntries:r,entries:e,filterActive:o,filterText:n,filterType:c,focused:s,isDryRun:l,scrollOffset:m,selectedIndex:k,totalEntries:i,viewportHeight:d})=>{const u=s?"white":"gray";let j=0,f=0,x=0,$=0;for(const C of e)switch(C.category){case"micro-utility":{x++;break}case"native":{j++;break}case"preferred":{f++;break}case"socket":{$++;break}}const g=[];j>0&&g.push(`${j} native`),f>0&&g.push(`${f} preferred`),x>0&&g.push(`${x} micro`),$>0&&g.push(`${$} socket`);const w=g.length>0?` (${g.join(", ")})`:"",b=r.size,P=[];for(const[C,p]of e.entries())P.push(t.jsx(Xe,{checked:r.has(p.packageName),entry:p,isSelected:C===k},p.packageName));const N=e.length,T=N>d&&d>0;return t.jsxs(h,{borderColor:u,borderStyle:"single",flexDirection:"column",flexGrow:1,children:[t.jsxs(h,{flexShrink:0,gap:1,paddingX:1,children:[t.jsx(a,{bold:!0,inverse:!0,children:" VIS OPTIMIZE "}),t.jsxs(a,{wrap:"truncate",children:[i," ","optimizations",w]}),!l&&b>0&&t.jsxs(a,{dimColor:!0,children:[" ","—",b," ","selected"]})]}),t.jsx(h,{flexShrink:0,gap:1,paddingX:1,paddingY:1,children:Je.map(C=>{const p=c===C.key;return t.jsxs(h,{children:[t.jsx(a,{dimColor:!p,children:"["}),t.jsx(a,{bold:p,color:p?"cyan":"gray",children:C.shortcut}),t.jsx(a,{dimColor:!p,children:"]"}),t.jsxs(a,{color:p?"white":"gray",children:[" ",C.label]})]},C.key)})}),o&&t.jsxs(h,{flexShrink:0,paddingX:1,children:[t.jsx(a,{bold:!0,color:"white",children:"/ "}),t.jsx(a,{children:n}),t.jsx(a,{inverse:!0,children:" "})]}),t.jsxs(h,{flexDirection:"row",flexGrow:1,overflow:"hidden",children:[t.jsx(h,{flexDirection:"column",flexGrow:1,overflow:"hidden",paddingLeft:1,children:t.jsx(h,{flexDirection:"column",marginTop:-m,children:P})}),T&&t.jsx(h,{flexShrink:0,marginLeft:1,marginRight:1,children:t.jsx(be,{contentHeight:N,placement:"inset",scrollOffset:m,style:"block",viewportHeight:d})})]})]})},Ke=100,W=10,Y={1:"all",2:"native",3:"preferred",4:"micro-utility",5:"socket"},Ve=({isDryRun:r,store:e})=>{const{exit:o}=xe(),{columns:n,rows:c}=ye(),s=A.useSyncExternalStore(e.subscribe,e.getSnapshot),l=A.useRef(null),[m,k]=A.useState(0),[i,d]=A.useState(!1),u=e.getFilteredEntries(),j=u[s.selectedIndex]??null,f=n>=Ke,x=Math.max(0,c-5),$=A.useCallback(g=>{o(g)},[o]);return je((g,w)=>{if(i){g==="y"||g==="Y"?$():d(!1);return}if(s.filterActive){w.escape?(e.setFilterActive(!1),e.setFilterText("")):w.return?e.setFilterActive(!1):w.backspace||w.delete?e.setFilterText(s.filterText.slice(0,-1)):g&&!w.ctrl&&!w.meta&&e.setFilterText(s.filterText+g);return}if(g==="q"){!r&&s.checkedEntries.size>0?d(!0):$();return}if(g==="/"){e.setFilterActive(!0);return}if(Y[g]){e.setFilter(Y[g]);return}if(w.tab){e.setFocusedPanel(s.focusedPanel==="list"?"detail":"list");return}if(s.focusedPanel==="list")if(w.upArrow||g==="k"){const b=Math.max(0,s.selectedIndex-1);e.select(b),b<m&&k(b)}else if(w.downArrow||g==="j"){const b=Math.min(u.length-1,s.selectedIndex+1);e.select(b),b>=m+x&&k(b-x+1)}else g===" "?j&&e.toggleCheck(j.packageName):g==="a"?e.toggleAll():w.return&&!r&&s.checkedEntries.size>0&&$(e.getCheckedEntries());else s.focusedPanel==="detail"&&(w.upArrow||g==="k"?l.current?.scrollBy(-1):(w.downArrow||g==="j")&&l.current?.scrollBy(1))},{isActive:s.phase==="browsing"}),c<W?t.jsx(h,{alignItems:"center",justifyContent:"center",children:t.jsxs(a,{color:"yellow",children:["Terminal too small. Resize to at least",W," ","rows."]})}):t.jsxs(h,{flexDirection:"column",height:c,width:n,children:[t.jsxs(h,{flexDirection:f?"row":"column",flexGrow:1,children:[t.jsx(h,{flexBasis:f?"50%":void 0,flexGrow:1,children:t.jsx(He,{checkedEntries:s.checkedEntries,entries:u,filterActive:s.filterActive,filterText:s.filterText,filterType:s.filterType,focused:s.focusedPanel==="list",isDryRun:r,scrollOffset:m,selectedIndex:s.selectedIndex,totalEntries:s.entries.length,viewportHeight:x})}),t.jsx(h,{flexBasis:f?"50%":void 0,flexGrow:1,children:t.jsx(Be,{entry:j,focused:s.focusedPanel==="detail",scrollRef:l})})]}),t.jsx(h,{flexShrink:0,paddingX:1,children:t.jsxs(a,{dimColor:!0,children:[r?"Preview mode":"space:toggle a:all enter:apply"," ","| tab:switch panel /: filter q:quit |","⚙","=codemod available"]})}),t.jsx(ke,{autoExitSeconds:3,onCancel:()=>{d(!1)},visible:i})]})},q=(r,e)=>{const o=new Set;try{const n=Q(r),c=e?[n.dependencies,n.optionalDependencies]:[n.dependencies,n.devDependencies,n.peerDependencies,n.optionalDependencies];for(const s of c)if(s)for(const l of Object.keys(s))o.add(l)}catch{}return o},re=r=>{const e=fe(r);if(e)return J(r,e);const o=O(r,"package.json");if(!B(o))return[];try{const n=Q(o),c=Array.isArray(n.workspaces)?n.workspaces:n.workspaces?.packages;return c?J(r,c):[]}catch{return[]}},We="https://github.com/es-tooling/module-replacements/blob/main/docs/modules",Ye=r=>`${We}/${r}.md`,Ze=r=>{if(r.type==="simple"&&r.replacement)return r.replacement;if(r.type==="native"){const e=r.nodeVersion?` (Node ${r.nodeVersion}+)`:"";return r.replacement?`${r.replacement}${e}`:`Native API${e}`}return r.type==="documented"&&r.docPath?"see migration guide":""},te=r=>{const e=[],o=(n,c)=>{const s=n.moduleReplacements;if(Array.isArray(s))for(const l of s)r.has(l.moduleName)&&e.push({category:c,docUrl:l.type==="documented"&&l.docPath?Ye(l.docPath):void 0,hasCodemod:!1,overrideSpec:void 0,packageName:l.moduleName,replacement:Ze(l)})};return o(ue,"native"),o(ge,"preferred"),o(me,"micro-utility"),e},oe=(r,e,o,n)=>{const c=Ge.getManifestData("npm")??[],s=[];for(const[,l]of c){if(l.deprecated)continue;const m=r.has(l.package),k=e?Fe(e,l.package,o.name):!1;if(!m&&!k)continue;const i=Z.coerce(l.version)?.major;if(i===void 0)continue;const d=n?`npm:${l.name}@${l.version}`:`npm:${l.name}@^${String(i)}`;s.push({category:"socket",hasCodemod:!1,overrideSpec:d,packageName:l.package,replacement:l.name})}return s};let G;const ne=async()=>{if(G)return G;try{return G=(await import("module-replacements-codemods")).codemods,G}catch{return{}}},ie=async r=>{try{const e=await ne();for(const o of r)o.category!=="socket"&&e[o.packageName]&&(o.hasCodemod=!0)}catch{}},se=async(r,e,o)=>{let n=0;try{const c=(await ne())[o];if(!c)return{filesChanged:0,packageName:o};const s=c({}),l=await Qe(e);for(const m of l){const k=_(m);if(k.includes(o))try{const i=await s.transform({file:{filename:m,source:k}});i!==k&&(await r.writeFile(m,i,"utf8"),n++)}catch(i){process.stderr.write(`warn: codemod transform failed for ${m}: ${i instanceof Error?i.message:String(i)}
13
- `)}}}catch{}return{filesChanged:n,packageName:o}},Qe=async r=>Ce("**/*.{cjs,cts,js,jsx,mjs,mts,ts,tsx}",{absolute:!0,cwd:r,ignore:["**/.*/**","**/.*","**/node_modules/**","**/dist/**","**/coverage/**","**/.git/**","**/.next/**","**/.nuxt/**"]}),er=async({fs:r,logger:e,options:o,visConfig:n,workspaceRoot:c})=>{if(!c)throw new Error("Could not determine workspace root. Run this command inside a monorepo.");const s=we(c),l=!!o.dryRun,m=!!o.prod,k=!!o.pin;y.info(`Detected ${s.name} v${s.version}.`);const i=q(O(c,"package.json"),m),d=re(c),u=new Set(i);for(const p of d){const I=q(O(ae(c,p),"package.json"),m);for(const E of I)u.add(E)}d.length>0&&y.info(`Scanned ${String(d.length)} workspace package${d.length===1?"":"s"}.`),y.info(`Scanning dependencies...
14
- `);const j=Re(c,s.name),f=te(u),x=oe(u,j,s,k),$=new Set(f.map(p=>p.packageName)),g=x.filter(p=>!$.has(p.packageName)),w=[...f,...g];if(await ie(w),w.length===0){y.info("No optimizations found for your dependencies.");return}const b=!!process.stdout.isTTY&&!he,P=o.format==="json"||!!o.json;if(b&&!l&&!P){const p=new ze(w),I=await de(pe.createElement(Ve,{isDryRun:!1,store:p}),{alternateScreen:!0,exitOnCtrlC:!1,interactive:!0,patchConsole:!0}).waitUntilExit(),E=Array.isArray(I)?I:[];if(E.length===0){y.info("No optimizations selected.");return}const R=E.filter(v=>v.category!=="socket"&&v.hasCodemod),F=E.filter(v=>v.category!=="socket"&&!v.hasCodemod),L=E.filter(v=>v.category==="socket");if(R.length>0){y.info(`
11
+ `);else{const k=Object.keys(e),s=X(k,m),d=Object.entries(e);d.splice(s,0,[m,o]),D(r,`${JSON.stringify(Object.fromEntries(d),null,l)}
12
+ `)}}},Ie=(r,e,o,n,c)=>{if(n.name==="deno")return{added:[],updated:[]};const i=_(e),l=JSON.parse(i),{overrides:m,source:k}=Ae(r,l,n),s=[],d=[],u=new Set;if(n.name==="npm")for(const f of["dependencies","devDependencies"]){const x=l[f];if(x)for(const $ of Object.keys(x))u.add($)}for(const f of o){const x=m[f.original];if(typeof x=="object")continue;let $=f.spec;n.name==="npm"&&u.has(f.original)&&($=`$${f.original}`),x!==$&&(x?d.push(f.original):s.push(f.original),m[f.original]=$)}if(s.length===0&&d.length===0)return{added:s,updated:d};const j=Object.fromEntries(Object.entries(m).sort(([f],[x])=>f.localeCompare(x)));return k==="pnpm-workspace.yaml"?De(r,j):_e(e,l,j,n.name,c),{added:s,updated:d}},Re=(r,e)=>{const o={bun:["bun.lock"],deno:["deno.lock"],npm:["npm-shrinkwrap.json","package-lock.json"],pnpm:["pnpm-lock.yaml"],yarn:["yarn.lock"]};for(const n of o[e]??[]){const c=O(r,n);try{return _(c)}catch{continue}}return""},Fe=(r,e,o)=>{if(!r)return!1;const n=e.replaceAll(/[.*+?^${}()|[\]\\]/g,String.raw`\$&`);switch(o){case"bun":return r.includes(`"${e}":`)||new RegExp(String.raw`(^|\s|[",])${n}@`,"m").test(r);case"deno":return r.includes(`"${e}"`)||r.includes(`"npm:${e}@`)||r.includes(`"jsr:${e}@`);case"npm":return r.includes(`"${e}":`)||r.includes(`"node_modules/${e}":`);case"pnpm":return new RegExp(String.raw`(^|\s|['"/])${n}(@|['"]?:)`,"m").test(r);case"yarn":return new RegExp(String.raw`(^|\s|[",])${n}@`,"m").test(r);default:return!1}};var z={exports:{}},U,H;function K(){if(H)return U;H=1;var r=Object.defineProperty,e=Object.getOwnPropertyDescriptor,o=Object.getOwnPropertyNames,n=Object.prototype.hasOwnProperty,c=(s,d)=>{for(var u in d)r(s,u,{get:d[u],enumerable:!0})},i=(s,d,u,j)=>{if(d&&typeof d=="object"||typeof d=="function")for(let f of o(d))!n.call(s,f)&&f!==u&&r(s,f,{get:()=>d[f],enumerable:!(j=e(d,f))||j.enumerable});return s},l=s=>i(r({},"__esModule",{value:!0}),s),m={};c(m,{PURL_Type:()=>k}),U=l(m);var k=(s=>(s.APK="apk",s.BITBUCKET="bitbucket",s.COCOAPODS="cocoapods",s.CARGO="cargo",s.CHROME="chrome",s.COMPOSER="composer",s.CONAN="conan",s.CONDA="conda",s.CRAN="cran",s.DEB="deb",s.DOCKER="docker",s.GEM="gem",s.GENERIC="generic",s.GITHUB="github",s.GOLANG="golang",s.HACKAGE="hackage",s.HEX="hex",s.HUGGINGFACE="huggingface",s.MAVEN="maven",s.MLFLOW="mlflow",s.NPM="npm",s.NUGET="nuget",s.OCI="oci",s.PUB="pub",s.PYPI="pypi",s.QPKG="qpkg",s.RPM="rpm",s.SWID="swid",s.SWIFT="swift",s.VCS="vcs",s))(k||{});return U}var V;function Me(){return V||(V=1,(function(r){var e=Object.defineProperty,o=Object.getOwnPropertyDescriptor,n=Object.getOwnPropertyNames,c=Object.prototype.hasOwnProperty,i=(d,u)=>{for(var j in u)e(d,j,{get:u[j],enumerable:!0})},l=(d,u,j,f)=>{if(u&&typeof u=="object"||typeof u=="function")for(let x of n(u))!c.call(d,x)&&x!==j&&e(d,x,{get:()=>u[x],enumerable:!(f=o(u,x))||f.enumerable});return d},m=(d,u,j)=>(l(d,u,"default"),j&&l(j,u,"default")),k={};i(k,{getManifestData:()=>s}),m(k,K(),r.exports);function s(d,u){try{const j=require("../manifest.json");if(!d)return j;const f=j[d];if(!f)return;if(!u)return f;const x=f.find(([$,g])=>g.package===u);return x?x[1]:void 0}catch{return}}r.exports={getManifestData:s,...K()}})(z)),z.exports}var Ge=Me();const Le=(r,e,o)=>{let n=r;if(e!=="all"&&(n=n.filter(c=>c.category===e)),o){const c=o.toLowerCase();n=n.filter(i=>i.packageName.toLowerCase().includes(c))}return n};class ze{#e;#t=new Set;constructor(e){this.#e={applyProgress:null,checkedEntries:new Set,entries:e,error:null,filterActive:!1,filterText:"",filterType:"all",focusedPanel:"list",phase:"browsing",selectedIndex:0}}getSnapshot=()=>this.#e;subscribe=e=>(this.#t.add(e),()=>{this.#t.delete(e)});getFilteredEntries=()=>Le(this.#e.entries,this.#e.filterType,this.#e.filterText);#r(){this.#e={...this.#e};for(const e of this.#t)e()}select(e){const o=this.getFilteredEntries();this.#e.selectedIndex=o.length===0?-1:Math.max(0,Math.min(e,o.length-1)),this.#r()}toggleCheck(e){const o=new Set(this.#e.checkedEntries);o.has(e)?o.delete(e):o.add(e),this.#e.checkedEntries=o,this.#r()}toggleAll(){const e=this.getFilteredEntries(),o=new Set(this.#e.checkedEntries);if(e.every(n=>o.has(n.packageName)))for(const n of e)o.delete(n.packageName);else for(const n of e)o.add(n.packageName);this.#e.checkedEntries=o,this.#r()}setFilter(e){this.#e.filterType=e,this.#e.selectedIndex=0,this.#r()}setFilterText(e){this.#e.filterText=e,this.#e.selectedIndex=0,this.#r()}setFilterActive(e){this.#e.filterActive=e,this.#r()}setFocusedPanel(e){this.#e.focusedPanel=e,this.#r()}setPhase(e){this.#e.phase=e,this.#r()}setProgress(e,o){this.#e.applyProgress={current:e,total:o},this.#r()}setError(e){this.#e.error=e,this.#e.phase="error",this.#r()}getCheckedEntries(){return this.#e.entries.filter(e=>this.#e.checkedEntries.has(e.packageName))}}const ee={"micro-utility":"gray",native:"green",preferred:"yellow",socket:"cyan"},Ue={"micro-utility":"MICRO",native:"NATIVE",preferred:"PREF",socket:"SOCKET"},qe={"micro-utility":"Trivial utility package that can be replaced with inline code.",native:"Polyfill for a native JS/Node.js API. Use the built-in instead.",preferred:"A lighter or faster alternative package exists.",socket:"Security-hardened replacement from Socket.dev's @socketregistry."},Be=({entry:r,focused:e,scrollRef:o})=>{const n=e?"white":"gray";if(!r)return t.jsx(h,{alignItems:"center",borderColor:"gray",borderStyle:"single",flexDirection:"column",flexGrow:1,justifyContent:"center",children:t.jsx(a,{dimColor:!0,children:"No entry selected"})});const c=ee[r.category]??"gray";return t.jsxs(h,{borderColor:n,borderStyle:"single",flexDirection:"column",flexGrow:1,children:[t.jsx(h,{flexShrink:0,paddingTop:1,paddingX:2,children:t.jsx(a,{bold:!0,color:"white",children:r.packageName})}),t.jsxs($e,{flexGrow:1,flexShrink:1,paddingX:2,ref:o,scrollbar:!0,scrollbarColor:"gray",children:[t.jsx(a,{}),t.jsxs(h,{children:[t.jsx(h,{width:14,children:t.jsx(a,{dimColor:!0,children:"Category:"})}),t.jsx(a,{bold:!0,color:c,children:r.category})]}),t.jsxs(h,{children:[t.jsx(h,{width:14,children:t.jsx(a,{dimColor:!0,children:"Replace with:"})}),t.jsx(a,{children:r.replacement})]}),r.overrideSpec&&t.jsxs(h,{children:[t.jsx(h,{width:14,children:t.jsx(a,{dimColor:!0,children:"Override:"})}),t.jsx(a,{color:"cyan",children:r.overrideSpec})]}),t.jsxs(h,{children:[t.jsx(h,{width:14,children:t.jsx(a,{dimColor:!0,children:"Codemod:"})}),t.jsx(a,{color:r.hasCodemod?"green":"gray",children:r.hasCodemod?"available ⚙":"not available"})]}),t.jsxs(h,{flexDirection:"column",marginTop:1,children:[t.jsx(a,{dimColor:!0,children:"── "}),t.jsx(a,{bold:!0,color:"white",children:"DESCRIPTION"}),t.jsx(h,{marginTop:1,paddingLeft:2,children:t.jsx(a,{children:qe[r.category]??""})})]}),r.category==="native"&&t.jsxs(h,{flexDirection:"column",marginTop:1,children:[t.jsx(a,{dimColor:!0,children:"── "}),t.jsx(a,{bold:!0,color:"green",children:"ACTION"}),t.jsx(h,{flexDirection:"column",marginTop:1,paddingLeft:2,children:r.hasCodemod?t.jsxs(t.Fragment,{children:[t.jsxs(a,{color:"green",children:["✓"," ","Codemod will rewrite imports to use native API."]}),t.jsx(a,{dimColor:!0,children:" The package can then be removed from dependencies."})]}):t.jsxs(t.Fragment,{children:[t.jsxs(a,{color:"yellow",children:["ℹ"," ","No automated codemod available."]}),t.jsx(a,{dimColor:!0,children:" Manual migration required — replace usage with native equivalent."})]})})]}),r.category==="socket"&&t.jsxs(h,{flexDirection:"column",marginTop:1,children:[t.jsx(a,{dimColor:!0,children:"── "}),t.jsx(a,{bold:!0,color:"cyan",children:"ACTION"}),t.jsxs(h,{flexDirection:"column",marginTop:1,paddingLeft:2,children:[t.jsxs(a,{color:"cyan",children:["✓"," ","Override will redirect resolution to the hardened package."]}),t.jsx(a,{dimColor:!0,children:" No source code changes needed — drop-in replacement."})]})]}),(r.category==="preferred"||r.category==="micro-utility")&&t.jsxs(h,{flexDirection:"column",marginTop:1,children:[t.jsx(a,{dimColor:!0,children:"── "}),t.jsx(a,{bold:!0,color:"yellow",children:"ACTION"}),t.jsx(h,{flexDirection:"column",marginTop:1,paddingLeft:2,children:r.hasCodemod?t.jsxs(t.Fragment,{children:[t.jsxs(a,{color:"green",children:["✓"," ","Codemod will rewrite imports to the recommended alternative."]}),t.jsx(a,{dimColor:!0,children:" The original package can then be removed from dependencies."})]}):t.jsxs(t.Fragment,{children:[t.jsxs(a,{color:"yellow",children:["ℹ"," ","Manual migration required."]}),r.docUrl?t.jsx(a,{dimColor:!0,children:" Open the migration guide below for the recommended alternative and steps."}):t.jsx(a,{dimColor:!0,children:" Consult the package's docs or the e18e module-replacements guide for an alternative."})]})})]}),t.jsxs(h,{flexDirection:"column",marginTop:1,children:[t.jsx(a,{dimColor:!0,children:"── "}),t.jsx(a,{bold:!0,color:"white",children:"LINKS"}),t.jsxs(h,{flexDirection:"column",marginTop:1,paddingLeft:2,children:[t.jsxs(a,{color:"cyan",underline:!0,children:["https://npmx.dev/",r.packageName]}),r.docUrl&&t.jsx(a,{color:"cyan",underline:!0,children:r.docUrl})]})]})]})]})},Je=[{key:"all",label:"All",shortcut:"1"},{key:"native",label:"Native",shortcut:"2"},{key:"preferred",label:"Preferred",shortcut:"3"},{key:"micro-utility",label:"Micro",shortcut:"4"},{key:"socket",label:"Socket",shortcut:"5"}],Xe=({checked:r,entry:e,isSelected:o})=>{const n=ee[e.category]??"white",c=Ue[e.category]??e.category,i=r?"☑":"☐",l=e.hasCodemod?"⚙":" ";return t.jsxs(h,{flexShrink:0,height:1,children:[t.jsx(a,{children:o?">":" "}),t.jsxs(a,{color:r?"white":"gray",children:[" ",i," "]}),t.jsx(a,{bold:!0,color:n,children:`[${c}]`.padEnd(9)}),t.jsxs(a,{children:[" ",l," "]}),t.jsx(h,{flexGrow:1,children:t.jsx(a,{bold:o,inverse:o,wrap:"truncate",children:e.packageName})}),t.jsx(a,{dimColor:!0,children:" → "}),t.jsx(a,{wrap:"truncate",children:e.replacement})]})},He=({checkedEntries:r,entries:e,filterActive:o,filterText:n,filterType:c,focused:i,isDryRun:l,scrollOffset:m,selectedIndex:k,totalEntries:s,viewportHeight:d})=>{const u=i?"white":"gray";let j=0,f=0,x=0,$=0;for(const C of e)switch(C.category){case"micro-utility":{x++;break}case"native":{j++;break}case"preferred":{f++;break}case"socket":{$++;break}}const g=[];j>0&&g.push(`${j} native`),f>0&&g.push(`${f} preferred`),x>0&&g.push(`${x} micro`),$>0&&g.push(`${$} socket`);const w=g.length>0?` (${g.join(", ")})`:"",b=r.size,P=[];for(const[C,p]of e.entries())P.push(t.jsx(Xe,{checked:r.has(p.packageName),entry:p,isSelected:C===k},p.packageName));const N=e.length,T=N>d&&d>0;return t.jsxs(h,{borderColor:u,borderStyle:"single",flexDirection:"column",flexGrow:1,children:[t.jsxs(h,{flexShrink:0,gap:1,paddingX:1,children:[t.jsx(a,{bold:!0,inverse:!0,children:" VIS OPTIMIZE "}),t.jsxs(a,{wrap:"truncate",children:[s," ","optimizations",w]}),!l&&b>0&&t.jsxs(a,{dimColor:!0,children:[" ","—",b," ","selected"]})]}),t.jsx(h,{flexShrink:0,gap:1,paddingX:1,paddingY:1,children:Je.map(C=>{const p=c===C.key;return t.jsxs(h,{children:[t.jsx(a,{dimColor:!p,children:"["}),t.jsx(a,{bold:p,color:p?"cyan":"gray",children:C.shortcut}),t.jsx(a,{dimColor:!p,children:"]"}),t.jsxs(a,{color:p?"white":"gray",children:[" ",C.label]})]},C.key)})}),o&&t.jsxs(h,{flexShrink:0,paddingX:1,children:[t.jsx(a,{bold:!0,color:"white",children:"/ "}),t.jsx(a,{children:n}),t.jsx(a,{inverse:!0,children:" "})]}),t.jsxs(h,{flexDirection:"row",flexGrow:1,overflow:"hidden",children:[t.jsx(h,{flexDirection:"column",flexGrow:1,overflow:"hidden",paddingLeft:1,children:t.jsx(h,{flexDirection:"column",marginTop:-m,children:P})}),T&&t.jsx(h,{flexShrink:0,marginLeft:1,marginRight:1,children:t.jsx(be,{contentHeight:N,placement:"inset",scrollOffset:m,style:"block",viewportHeight:d})})]})]})},Ke=100,W=10,Y={1:"all",2:"native",3:"preferred",4:"micro-utility",5:"socket"},Ve=({isDryRun:r,store:e})=>{const{exit:o}=xe(),{columns:n,rows:c}=ye(),i=A.useSyncExternalStore(e.subscribe,e.getSnapshot),l=A.useRef(null),[m,k]=A.useState(0),[s,d]=A.useState(!1),u=e.getFilteredEntries(),j=u[i.selectedIndex]??null,f=n>=Ke,x=Math.max(0,c-5),$=A.useCallback(g=>{o(g)},[o]);return je((g,w)=>{if(s){g==="y"||g==="Y"?$():d(!1);return}if(i.filterActive){w.escape?(e.setFilterActive(!1),e.setFilterText("")):w.return?e.setFilterActive(!1):w.backspace||w.delete?e.setFilterText(i.filterText.slice(0,-1)):g&&!w.ctrl&&!w.meta&&e.setFilterText(i.filterText+g);return}if(g==="q"){!r&&i.checkedEntries.size>0?d(!0):$();return}if(g==="/"){e.setFilterActive(!0);return}if(Y[g]){e.setFilter(Y[g]);return}if(w.tab){e.setFocusedPanel(i.focusedPanel==="list"?"detail":"list");return}if(i.focusedPanel==="list")if(w.upArrow||g==="k"){const b=Math.max(0,i.selectedIndex-1);e.select(b),b<m&&k(b)}else if(w.downArrow||g==="j"){const b=Math.min(u.length-1,i.selectedIndex+1);e.select(b),b>=m+x&&k(b-x+1)}else g===" "?j&&e.toggleCheck(j.packageName):g==="a"?e.toggleAll():w.return&&!r&&i.checkedEntries.size>0&&$(e.getCheckedEntries());else i.focusedPanel==="detail"&&(w.upArrow||g==="k"?l.current?.scrollBy(-1):(w.downArrow||g==="j")&&l.current?.scrollBy(1))},{isActive:i.phase==="browsing"}),c<W?t.jsx(h,{alignItems:"center",justifyContent:"center",children:t.jsxs(a,{color:"yellow",children:["Terminal too small. Resize to at least",W," ","rows."]})}):t.jsxs(h,{flexDirection:"column",height:c,width:n,children:[t.jsxs(h,{flexDirection:f?"row":"column",flexGrow:1,children:[t.jsx(h,{flexBasis:f?"50%":void 0,flexGrow:1,children:t.jsx(He,{checkedEntries:i.checkedEntries,entries:u,filterActive:i.filterActive,filterText:i.filterText,filterType:i.filterType,focused:i.focusedPanel==="list",isDryRun:r,scrollOffset:m,selectedIndex:i.selectedIndex,totalEntries:i.entries.length,viewportHeight:x})}),t.jsx(h,{flexBasis:f?"50%":void 0,flexGrow:1,children:t.jsx(Be,{entry:j,focused:i.focusedPanel==="detail",scrollRef:l})})]}),t.jsx(h,{flexShrink:0,paddingX:1,children:t.jsxs(a,{dimColor:!0,children:[r?"Preview mode":"space:toggle a:all enter:apply"," ","| tab:switch panel /: filter q:quit |","⚙","=codemod available"]})}),t.jsx(ke,{autoExitSeconds:3,onCancel:()=>{d(!1)},visible:s})]})},q=(r,e)=>{const o=new Set;try{const n=Q(r),c=e?[n.dependencies,n.optionalDependencies]:[n.dependencies,n.devDependencies,n.peerDependencies,n.optionalDependencies];for(const i of c)if(i)for(const l of Object.keys(i))o.add(l)}catch{}return o},re=r=>{const e=fe(r);if(e)return J(r,e);const o=O(r,"package.json");if(!B(o))return[];try{const n=Q(o),c=Array.isArray(n.workspaces)?n.workspaces:n.workspaces?.packages;return c?J(r,c):[]}catch{return[]}},We="https://github.com/es-tooling/module-replacements/blob/main/docs/modules",Ye=r=>`${We}/${r}.md`,Ze=r=>{if(r.type==="simple"&&r.replacement)return r.replacement;if(r.type==="native"){const e=r.nodeVersion?` (Node ${r.nodeVersion}+)`:"";return r.replacement?`${r.replacement}${e}`:`Native API${e}`}return r.type==="documented"&&r.docPath?"see migration guide":""},te=r=>{const e=[],o=(n,c)=>{const i=n.moduleReplacements;if(Array.isArray(i))for(const l of i)r.has(l.moduleName)&&e.push({category:c,docUrl:l.type==="documented"&&l.docPath?Ye(l.docPath):void 0,hasCodemod:!1,overrideSpec:void 0,packageName:l.moduleName,replacement:Ze(l)})};return o(ue,"native"),o(ge,"preferred"),o(me,"micro-utility"),e},oe=(r,e,o,n)=>{const c=Ge.getManifestData("npm")??[],i=[];for(const[,l]of c){if(l.deprecated)continue;const m=r.has(l.package),k=e?Fe(e,l.package,o.name):!1;if(!m&&!k)continue;const s=Z.coerce(l.version)?.major;if(s===void 0)continue;const d=n?`npm:${l.name}@${l.version}`:`npm:${l.name}@^${String(s)}`;i.push({category:"socket",hasCodemod:!1,overrideSpec:d,packageName:l.package,replacement:l.name})}return i};let G;const ne=async()=>{if(G)return G;try{return G=(await import("module-replacements-codemods")).codemods,G}catch{return{}}},se=async r=>{try{const e=await ne();for(const o of r)o.category!=="socket"&&e[o.packageName]&&(o.hasCodemod=!0)}catch{}},ie=async(r,e,o)=>{let n=0;try{const c=(await ne())[o];if(!c)return{filesChanged:0,packageName:o};const i=c({}),l=await Qe(e);for(const m of l){const k=_(m);if(k.includes(o))try{const s=await i.transform({file:{filename:m,source:k}});s!==k&&(await r.writeFile(m,s,"utf8"),n++)}catch(s){process.stderr.write(`warn: codemod transform failed for ${m}: ${s instanceof Error?s.message:String(s)}
13
+ `)}}}catch{}return{filesChanged:n,packageName:o}},Qe=async r=>Ce("**/*.{cjs,cts,js,jsx,mjs,mts,ts,tsx}",{absolute:!0,cwd:r,ignore:["**/.*/**","**/.*","**/node_modules/**","**/dist/**","**/coverage/**","**/.git/**","**/.next/**","**/.nuxt/**"]}),er=async({fs:r,logger:e,options:o,visConfig:n,workspaceRoot:c})=>{if(!c)throw new Error("Could not determine workspace root. Run this command inside a monorepo.");const i=we(c),l=!!o.dryRun,m=!!o.prod,k=!!o.pin;y.info(`Detected ${i.name} v${i.version}.`);const s=q(O(c,"package.json"),m),d=re(c),u=new Set(s);for(const p of d){const I=q(O(ae(c,p),"package.json"),m);for(const E of I)u.add(E)}d.length>0&&y.info(`Scanned ${String(d.length)} workspace package${d.length===1?"":"s"}.`),y.info(`Scanning dependencies...
14
+ `);const j=Re(c,i.name),f=te(u),x=oe(u,j,i,k),$=new Set(f.map(p=>p.packageName)),g=x.filter(p=>!$.has(p.packageName)),w=[...f,...g];if(await se(w),w.length===0){y.info("No optimizations found for your dependencies.");return}const b=!!process.stdout.isTTY&&!he,P=o.format==="json"||!!o.json;if(b&&!l&&!P){const p=new ze(w),I=await de(pe.createElement(Ve,{isDryRun:!1,store:p}),{alternateScreen:!0,exitOnCtrlC:!1,interactive:!0,patchConsole:!0}).waitUntilExit(),E=Array.isArray(I)?I:[];if(E.length===0){y.info("No optimizations selected.");return}const R=E.filter(v=>v.category!=="socket"&&v.hasCodemod),F=E.filter(v=>v.category!=="socket"&&!v.hasCodemod),L=E.filter(v=>v.category==="socket");if(R.length>0){y.info(`
15
15
  Running ${String(R.length)} codemod${R.length===1?"":"s"}...
16
- `);for(const v of R){const S=await se(r,c,v.packageName);S.filesChanged>0?y.success(` ${v.packageName}: ${String(S.filesChanged)} file${S.filesChanged===1?"":"s"} updated`):y.info(` ${v.packageName}: no files changed`)}}if(F.length>0){y.warn(`
17
- ${String(F.length)} selected replacement${F.length===1?"":"s"} require manual migration (no codemod available):`);for(const v of F)y.info(` ${v.packageName} → ${v.replacement}`);y.notice(" Replace usage in your source code, then remove from dependencies.")}if(L.length>0){const v=L.filter(M=>M.overrideSpec).map(M=>({original:M.packageName,spec:M.overrideSpec})),S=Ie(c,O(c,"package.json"),v,s,n?.editorconfig??!0);S.added.length>0&&y.success(`
16
+ `);for(const v of R){const S=await ie(r,c,v.packageName);S.filesChanged>0?y.success(` ${v.packageName}: ${String(S.filesChanged)} file${S.filesChanged===1?"":"s"} updated`):y.info(` ${v.packageName}: no files changed`)}}if(F.length>0){y.warn(`
17
+ ${String(F.length)} selected replacement${F.length===1?"":"s"} require manual migration (no codemod available):`);for(const v of F)y.info(` ${v.packageName} → ${v.replacement}`);y.notice(" Replace usage in your source code, then remove from dependencies.")}if(L.length>0){const v=L.filter(M=>M.overrideSpec).map(M=>({original:M.packageName,spec:M.overrideSpec})),S=Ie(c,O(c,"package.json"),v,i,n?.editorconfig??!0);S.added.length>0&&y.success(`
18
18
  Added ${String(S.added.length)} override${S.added.length===1?"":"s"}.`),S.updated.length>0&&y.success(`Updated ${String(S.updated.length)} override${S.updated.length===1?"":"s"}.`)}if(L.length>0&&o.install!==!1){y.info(`
19
- Running ${s.name} install to update lockfile...`);const v=ve(s,{dev:!1,filter:[],force:!1,frozenLockfile:!1,ignoreScripts:!1,lockfileOnly:!1,noOptional:!1,offline:!1,prod:!1,recursive:!1,silent:!1,workspaceRoot:!1},c,e);v!==0&&y.warn(`${s.name} install exited with code ${String(v)}. Run it manually.`)}y.info(""),y.success("Optimization complete.");return}if(P){process.stdout.write(`${JSON.stringify({e18e:f.map(p=>({category:p.category,hasCodemod:p.hasCodemod,packageName:p.packageName,replacement:p.replacement})),packageManager:s.name,socket:g.map(p=>({overrideSpec:p.overrideSpec,packageName:p.packageName,replacement:p.replacement})),total:w.length,workspaces:d.length},void 0,2)}
19
+ Running ${i.name} install to update lockfile...`);const v=ve(i,{dev:!1,filter:[],force:!1,frozenLockfile:!1,ignoreScripts:!1,lockfileOnly:!1,noOptional:!1,offline:!1,prod:!1,recursive:!1,silent:!1,workspaceRoot:!1},c,e);v!==0&&y.warn(`${i.name} install exited with code ${String(v)}. Run it manually.`)}y.info(""),y.success("Optimization complete.");return}if(P){process.stdout.write(`${JSON.stringify({e18e:f.map(p=>({category:p.category,hasCodemod:p.hasCodemod,packageName:p.packageName,replacement:p.replacement})),packageManager:i.name,socket:g.map(p=>({overrideSpec:p.overrideSpec,packageName:p.packageName,replacement:p.replacement})),total:w.length,workspaces:d.length},void 0,2)}
20
20
  `);return}const N=f.filter(p=>p.category==="native"),T=f.filter(p=>p.category==="preferred"),C=f.filter(p=>p.category==="micro-utility");if(N.length>0){y.info(`Native replacements (${String(N.length)}):`);for(const p of N)y.info(` ${p.hasCodemod?"⚙":" "} ${p.packageName} → ${p.replacement}`)}if(T.length>0){y.info(`
21
21
  Preferred alternatives (${String(T.length)}):`);for(const p of T)y.info(` ${p.hasCodemod?"⚙":" "} ${p.packageName} → ${p.replacement}`)}if(C.length>0){y.info(`
22
22
  Micro-utilities (${String(C.length)}):`);for(const p of C)y.info(` ${p.hasCodemod?"⚙":" "} ${p.packageName} → ${p.replacement}`)}if(g.length>0){y.info(`
23
23
  Socket.dev overrides (${String(g.length)}):`);for(const p of g)y.info(` ${p.packageName} → ${p.overrideSpec}`)}y.info(`
24
- Total: ${String(w.length)} optimizations available (⚙ = codemod available).`),l&&y.notice("Run without --dry-run for interactive selection.")},gr=Object.defineProperty({__proto__:null,buildE18eEntries:te,buildSocketEntries:oe,collectDepsFromPkgJson:q,default:er,discoverWorkspacePackages:re,markCodemodAvailability:ie,runCodemod:se},Symbol.toStringTag,{value:"Module"});export{re as A,te as F,se as I,Re as N,oe as T,ie as U,Ie as a,gr as h,q as x};
24
+ Total: ${String(w.length)} optimizations available (⚙ = codemod available).`),l&&y.notice("Run without --dry-run for interactive selection.")},gr=Object.defineProperty({__proto__:null,buildE18eEntries:te,buildSocketEntries:oe,collectDepsFromPkgJson:q,default:er,discoverWorkspacePackages:re,markCodemodAvailability:se,runCodemod:ie},Symbol.toStringTag,{value:"Module"});export{re as A,te as F,ie as I,Re as N,oe as T,se as U,Ie as a,gr as h,q as x};