@visulima/vis 1.0.0 → 1.0.2

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 (137) hide show
  1. package/CHANGELOG.md +20 -0
  2. package/LICENSE.md +1 -1
  3. package/dashboard/dist/index.html +10 -10
  4. package/dist/bin.js +1 -1
  5. package/dist/binx.js +1 -1
  6. package/dist/packem_chunks/CONFIG_FILES.js +1 -1
  7. package/dist/packem_chunks/bloom-sync.js +1 -1
  8. package/dist/packem_chunks/catalog.js +1 -1
  9. package/dist/packem_chunks/cli-exec.js +1 -1
  10. package/dist/packem_chunks/cli-main.js +2 -2
  11. package/dist/packem_chunks/dispatch.js +1 -1
  12. package/dist/packem_chunks/fix.js +1 -1
  13. package/dist/packem_chunks/group-tags.js +1 -1
  14. package/dist/packem_chunks/handler.js +1 -1
  15. package/dist/packem_chunks/handler10.js +1 -1
  16. package/dist/packem_chunks/handler11.js +1 -1
  17. package/dist/packem_chunks/handler12.js +1 -1
  18. package/dist/packem_chunks/handler13.js +1 -1
  19. package/dist/packem_chunks/handler14.js +1 -1
  20. package/dist/packem_chunks/handler15.js +1 -1
  21. package/dist/packem_chunks/handler16.js +1 -1
  22. package/dist/packem_chunks/handler17.js +1 -1
  23. package/dist/packem_chunks/handler18.js +1 -1
  24. package/dist/packem_chunks/handler19.js +1 -1
  25. package/dist/packem_chunks/handler2.js +1 -1
  26. package/dist/packem_chunks/handler20.js +1 -1
  27. package/dist/packem_chunks/handler21.js +1 -1
  28. package/dist/packem_chunks/handler22.js +1 -1
  29. package/dist/packem_chunks/handler23.js +1 -1
  30. package/dist/packem_chunks/handler24.js +1 -1
  31. package/dist/packem_chunks/handler26.js +1 -1
  32. package/dist/packem_chunks/handler27.js +1 -1
  33. package/dist/packem_chunks/handler28.js +1 -1
  34. package/dist/packem_chunks/handler29.js +1 -1
  35. package/dist/packem_chunks/handler3.js +1 -1
  36. package/dist/packem_chunks/handler30.js +1 -1
  37. package/dist/packem_chunks/handler4.js +1 -1
  38. package/dist/packem_chunks/handler5.js +1 -1
  39. package/dist/packem_chunks/handler50.js +1 -1
  40. package/dist/packem_chunks/handler51.js +1 -1
  41. package/dist/packem_chunks/handler53.js +1 -1
  42. package/dist/packem_chunks/handler54.js +1 -1
  43. package/dist/packem_chunks/handler55.js +1 -1
  44. package/dist/packem_chunks/handler58.js +1 -1
  45. package/dist/packem_chunks/handler59.js +1 -1
  46. package/dist/packem_chunks/handler6.js +1 -1
  47. package/dist/packem_chunks/handler60.js +1 -1
  48. package/dist/packem_chunks/handler61.js +1 -1
  49. package/dist/packem_chunks/handler62.js +1 -1
  50. package/dist/packem_chunks/handler63.js +1 -1
  51. package/dist/packem_chunks/handler64.js +1 -1
  52. package/dist/packem_chunks/handler65.js +6 -6
  53. package/dist/packem_chunks/handler66.js +1 -1
  54. package/dist/packem_chunks/handler67.js +1 -1
  55. package/dist/packem_chunks/handler68.js +1 -1
  56. package/dist/packem_chunks/handler69.js +1 -1
  57. package/dist/packem_chunks/handler7.js +1 -1
  58. package/dist/packem_chunks/handler70.js +1 -1
  59. package/dist/packem_chunks/handler71.js +1 -1
  60. package/dist/packem_chunks/handler72.js +41 -41
  61. package/dist/packem_chunks/handler73.js +2 -2
  62. package/dist/packem_chunks/handler74.js +1 -1
  63. package/dist/packem_chunks/handler75.js +1 -1
  64. package/dist/packem_chunks/handler76.js +1 -1
  65. package/dist/packem_chunks/handler77.js +1 -1
  66. package/dist/packem_chunks/handler78.js +1 -1
  67. package/dist/packem_chunks/handler8.js +1 -1
  68. package/dist/packem_chunks/handler9.js +1 -1
  69. package/dist/packem_chunks/heal-accept.js +1 -1
  70. package/dist/packem_chunks/heal.js +1 -1
  71. package/dist/packem_chunks/help-command.js +1 -1
  72. package/dist/packem_chunks/index3.js +1 -1
  73. package/dist/packem_chunks/index4.js +46 -46
  74. package/dist/packem_chunks/index5.js +22 -23
  75. package/dist/packem_chunks/keys-refresh.js +1 -1
  76. package/dist/packem_chunks/lean.js +1 -1
  77. package/dist/packem_chunks/list.js +1 -1
  78. package/dist/packem_chunks/loader.js +1 -1
  79. package/dist/packem_chunks/orchestrator.js +1 -1
  80. package/dist/packem_chunks/sync.js +1 -1
  81. package/dist/packem_chunks/sync2.js +1 -1
  82. package/dist/packem_chunks/tripwire.js +1 -1
  83. package/dist/packem_chunks/ts-loader.js +1 -1
  84. package/dist/packem_chunks/verify-lockfile.js +1 -1
  85. package/dist/packem_chunks/version-resolver.js +1 -1
  86. package/dist/packem_shared/{Table-CcVkyULl-DLWu6XHL.js → Table-BGIHvenQ-D2oJtNQj.js} +1 -1
  87. package/dist/packem_shared/{affected-shas-CCxG4tvm.js → affected-shas-BfO3PDJq.js} +1 -1
  88. package/dist/packem_shared/ai-analysis-CO7No4rt.js +68 -0
  89. package/dist/packem_shared/{ai-fix-CeGzAT9m.js → ai-fix-B4u2zlVG.js} +1 -1
  90. package/dist/packem_shared/{augment-DaSS2Lgs.js → augment-8z86AwtF.js} +1 -1
  91. package/dist/packem_shared/{bin-BlGVEhl8.js → bin-Cv8vsMEo.js} +1 -1
  92. package/dist/packem_shared/{build-scripts-q__dKE2y.js → build-scripts-D477Ou-x.js} +1 -1
  93. package/dist/packem_shared/{command-runtime-3FTGuUsK.js → command-runtime-EWjmSxPj.js} +1 -1
  94. package/dist/packem_shared/{cyclonedx-CmrYQ0vx.js → cyclonedx-CDWHbD9s.js} +1 -1
  95. package/dist/packem_shared/{dependency-scan-DpOFiZuI.js → dependency-scan-P52jY0pU.js} +1 -1
  96. package/dist/packem_shared/{docker-BYqiD711.js → docker-CD7o1D1o.js} +1 -1
  97. package/dist/packem_shared/{env-DdQRnEIy.js → env-Cpxa_7UE.js} +1 -1
  98. package/dist/packem_shared/{failure-log-CKMhqLWr.js → failure-log-MOhz-TBv.js} +1 -1
  99. package/dist/packem_shared/glob-DMbPwGSj-uzODoE-1.js +1 -0
  100. package/dist/packem_shared/index-BAUIIRZJ.js +1 -0
  101. package/dist/packem_shared/index-BVuCxe14.js +22 -0
  102. package/dist/packem_shared/{index-jJNulo5i.js → index-CTRMi3jL.js} +1 -1
  103. package/dist/packem_shared/{index-Cg71MisW.js → index-CdTXvj-V.js} +1 -1
  104. package/dist/packem_shared/{lifecycle-aDTZ8dW1.js → lifecycle-hzwghh5a.js} +1 -1
  105. package/dist/packem_shared/{lockfile-C1qCKGH6.js → lockfile-CWcVTdRc.js} +1 -1
  106. package/dist/packem_shared/{manifests-DSBr3-dw.js → manifests-CaPqgQxW.js} +1 -1
  107. package/dist/packem_shared/{min-release-age-C71MO72F.js → min-release-age-skpcnlpk.js} +1 -1
  108. package/dist/packem_shared/{missing-package-json-CTF71tE5.js → missing-package-json-_hOp4AW5.js} +1 -1
  109. package/dist/packem_shared/{native-config-sync-D-z2Uwqu.js → native-config-sync-CFi1iQNG.js} +1 -1
  110. package/dist/packem_shared/{packument-aGzYwXKn.js → packument-CYxvm590.js} +1 -1
  111. package/dist/packem_shared/{pm-runner-CQcraCcu.js → pm-runner-mVFjedM6.js} +1 -1
  112. package/dist/packem_shared/{provenance-S7y0BRAt.js → provenance-CI_WQx7G.js} +1 -1
  113. package/dist/packem_shared/{readJsonSync-DuMMeB3s-ihoybKvs.js → readJsonSync-DuMMeB3s-Cx08VBQg.js} +1 -1
  114. package/dist/packem_shared/{registry-keys-CRnXATt2.js → registry-keys-AGlSEY6R.js} +1 -1
  115. package/dist/packem_shared/{resolve-explicit-CJGazevw.js → resolve-explicit-DVE9cfkm.js} +1 -1
  116. package/dist/packem_shared/{resolve-runtime-QRaQucfL.js → resolve-runtime-CGHf-wHz.js} +1 -1
  117. package/dist/packem_shared/{run-file-DD7Ne23Z.js → run-file-Bs_E9O6O.js} +1 -1
  118. package/dist/packem_shared/{runtime-check-qnrPTlma.js → runtime-check-pS2XH4BO.js} +1 -1
  119. package/dist/packem_shared/{s1ngularity-BLj4Jy8z.js → s1ngularity-xmrq5T5r.js} +1 -1
  120. package/dist/packem_shared/{scan-progress-BDcl7Kty.js → scan-progress-DQ4TMXcb.js} +1 -1
  121. package/dist/packem_shared/{selectors-D4iCvITE.js → selectors-CRgS4bU9.js} +1 -1
  122. package/dist/packem_shared/{signatures-DoNG2hEr.js → signatures-Dp3th1DB.js} +1 -1
  123. package/dist/packem_shared/{target-options-CR0OuYJr.js → target-options-TM6ETDAS.js} +1 -1
  124. package/dist/packem_shared/{toolchain-Zb3VzZb4.js → toolchain-B5KwUZfq.js} +1 -1
  125. package/dist/packem_shared/{typosquats-C12CP_2G.js → typosquats-C0layQsP.js} +1 -1
  126. package/dist/packem_shared/{use-measured-height-CjS7Tks7.js → use-measured-height-Drobr4fe.js} +1 -1
  127. package/dist/packem_shared/{verify-DStfg3nb.js → verify-Cjo4EBFZ.js} +1 -1
  128. package/dist/packem_shared/{vis-update-app-BlocL713.js → vis-update-app-qIkyvrd1.js} +1 -1
  129. package/dist/packem_shared/{watch-BXNI7dC6.js → watch-BnE1TzYn.js} +1 -1
  130. package/dist/packem_shared/{watch-loop-BZudYfcl.js → watch-loop-Irf3Pm-1.js} +1 -1
  131. package/dist/runtime/preload.js +1 -1
  132. package/index.js +654 -570
  133. package/package.json +37 -37
  134. package/dist/packem_shared/ai-analysis-BpVdn20h.js +0 -68
  135. package/dist/packem_shared/glob-fqg4KepW-1S3z30c8.js +0 -1
  136. package/dist/packem_shared/index-CE6MsgcV.js +0 -22
  137. package/dist/packem_shared/index-Cg0IHaFI.js +0 -1
@@ -1,4 +1,4 @@
1
- import{createRequire as B}from"node:module";import{j as M,m as W,o as F,q as p,s as z,t as G,Y as P,u as Y,x as L,z as H,C as K,E as Q,L as U,F as X,H as Z,G as I,$ as tt}from"./cli-main.js";import{f as k,m as f,v as j,T as O,I as st,J as nt}from"../packem_shared/index-CE6MsgcV.js";import"../packem_shared/public-api-WqUCiyIe.js";import{u as it}from"./ts-loader.js";import{loadVisConfig as rt}from"./CONFIG_FILES.js";import{v as ut}from"../packem_shared/verify-DStfg3nb.js";const J=B(import.meta.url),$=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 J(t)},{readdirSync:ot,statSync:et}=V("node:fs"),{stdin:T,stdout:at}=$,{createInterface:ct}=V("node:readline/promises"),w="__global__",R=t=>[...new Set(t)].sort((o,s)=>o.localeCompare(s)),pt=t=>`{${Object.keys(t).sort().map(o=>`${o}=${JSON.stringify(t[o])}`).join(",")}}`,m=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(pt(s));return R(o)},y=t=>({cache:void 0,dependsOn:[],env:[],id:t,inputs:[],outputs:[]}),h=(t,o,s)=>s?`^${o}`:t&&t!=="self"&&t!=="~"?`${t}#${o}`:o,ft=(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(ft(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(k(t))try{return JSON.parse(j(t))}catch{return}},gt=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=y(c);a.dependsOn=C(r.dependsOn,"turbo"),a.inputs=m(r.inputs),a.outputs=m(r.outputs),a.env=R([...r.env??[],...r.passThroughEnv??[]]),a.cache=r.cache===!1?!1:void 0,o.set(c,a)}const e=y(w);return e.inputs=m(s.globalDependencies),e.env=R([...s.globalEnv??[],...s.globalPassThroughEnv??[]]),(e.inputs.length>0||e.env.length>0)&&o.set(w,e),o},dt=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=ot(i)}catch{return}for(const a of c.toSorted()){if(a===o){n.push(f(i,a));continue}if(a.startsWith(".")&&a!==".moon"||dt.has(a))continue;const u=f(i,a);try{et(u).isDirectory()&&e(u,r+1)}catch{}}};return e(t,0),n},N=(t,o)=>{t.dependsOn=C(o.dependsOn,"nx"),t.inputs=m(o.inputs),t.outputs=m(o.outputs),t.cache=typeof o.cache=="boolean"?o.cache:void 0},lt=t=>{const o=new Map,s=E(f(t,"nx.json"));for(const[n,e]of Object.entries(s?.targetDefaults??{})){const i=`*#${n}`,r=y(i);N(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=y(c);N(a,r),o.set(c,a)}}return o},_=(t,o)=>{t.dependsOn=C(o.deps,"moon"),t.inputs=m(o.inputs),t.outputs=m(o.outputs),t.cache=typeof o.options?.cache=="boolean"?o.options.cache:void 0},A=t=>{if(k(t))try{return it(t)}catch{return}},vt=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=y(a);_(u,c),o.set(a,u)}if(i.implicitInputs&&i.implicitInputs.length>0){const r=y(w);r.inputs=m(i.implicitInputs),o.set(w,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=y(u);_(v,a),o.set(u,v)}}return o},mt=(t,o)=>{t.dependsOn=C(o.dependsOn,"vis"),t.inputs=m(o.inputs),t.outputs=m(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},ht=async t=>{const o=new Map,s=await rt(t);for(const[i,r]of Object.entries(s.tasks??{})){const c=`*#${i}`,a=y(c);mt(a,r??{}),o.set(c,a)}const n=s.taskRunner??{},e=y(w);return e.inputs=m(n.globalInputs),e.env=R([...n.globalEnv??[],...n.globalPassThroughEnv??[]]),(e.inputs.length>0||e.env.length>0)&&o.set(w,e),o},yt=(t,o)=>{switch(o){case"moon":return vt(t);case"nx":return lt(t);default:return gt(t)}},kt=t=>{const o=[];return k(f(t,"turbo.json"))&&o.push("turbo"),k(f(t,"nx.json"))&&o.push("nx"),(k(f(t,".moon","tasks.yml"))||k(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"})},wt=(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!==w;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}},Rt=new Set(["json","ndjson","table"]),$t=t=>({equivalent:t.findings.every(o=>o.severity!=="error"),findings:t.findings,source:t.source,sourceNodeCount:t.sourceNodeCount,visNodeCount:t.visNodeCount}),bt=(t,o,s)=>{if(o==="json"){process.stdout.write(`${JSON.stringify($t(t),void 0,2)}
1
+ import{createRequire as B}from"node:module";import{j as M,m as W,o as F,q as p,s as z,t as G,Y as P,u as Y,x as L,z as H,C as K,E as Q,L as U,F as X,H as Z,G as I,$ as tt}from"./cli-main.js";import{f as k,m as f,v as j,T as O,I as st,J as nt}from"../packem_shared/index-BVuCxe14.js";import"../packem_shared/public-api-WqUCiyIe.js";import{u as it}from"./ts-loader.js";import{loadVisConfig as rt}from"./CONFIG_FILES.js";import{v as ut}from"../packem_shared/verify-Cjo4EBFZ.js";const J=B(import.meta.url),$=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 J(t)},{readdirSync:ot,statSync:et}=V("node:fs"),{stdin:T,stdout:at}=$,{createInterface:ct}=V("node:readline/promises"),w="__global__",R=t=>[...new Set(t)].sort((o,s)=>o.localeCompare(s)),pt=t=>`{${Object.keys(t).sort().map(o=>`${o}=${JSON.stringify(t[o])}`).join(",")}}`,m=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(pt(s));return R(o)},y=t=>({cache:void 0,dependsOn:[],env:[],id:t,inputs:[],outputs:[]}),h=(t,o,s)=>s?`^${o}`:t&&t!=="self"&&t!=="~"?`${t}#${o}`:o,ft=(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(ft(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(k(t))try{return JSON.parse(j(t))}catch{return}},gt=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=y(c);a.dependsOn=C(r.dependsOn,"turbo"),a.inputs=m(r.inputs),a.outputs=m(r.outputs),a.env=R([...r.env??[],...r.passThroughEnv??[]]),a.cache=r.cache===!1?!1:void 0,o.set(c,a)}const e=y(w);return e.inputs=m(s.globalDependencies),e.env=R([...s.globalEnv??[],...s.globalPassThroughEnv??[]]),(e.inputs.length>0||e.env.length>0)&&o.set(w,e),o},dt=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=ot(i)}catch{return}for(const a of c.toSorted()){if(a===o){n.push(f(i,a));continue}if(a.startsWith(".")&&a!==".moon"||dt.has(a))continue;const u=f(i,a);try{et(u).isDirectory()&&e(u,r+1)}catch{}}};return e(t,0),n},N=(t,o)=>{t.dependsOn=C(o.dependsOn,"nx"),t.inputs=m(o.inputs),t.outputs=m(o.outputs),t.cache=typeof o.cache=="boolean"?o.cache:void 0},lt=t=>{const o=new Map,s=E(f(t,"nx.json"));for(const[n,e]of Object.entries(s?.targetDefaults??{})){const i=`*#${n}`,r=y(i);N(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=y(c);N(a,r),o.set(c,a)}}return o},_=(t,o)=>{t.dependsOn=C(o.deps,"moon"),t.inputs=m(o.inputs),t.outputs=m(o.outputs),t.cache=typeof o.options?.cache=="boolean"?o.options.cache:void 0},A=t=>{if(k(t))try{return it(t)}catch{return}},vt=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=y(a);_(u,c),o.set(a,u)}if(i.implicitInputs&&i.implicitInputs.length>0){const r=y(w);r.inputs=m(i.implicitInputs),o.set(w,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=y(u);_(v,a),o.set(u,v)}}return o},mt=(t,o)=>{t.dependsOn=C(o.dependsOn,"vis"),t.inputs=m(o.inputs),t.outputs=m(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},ht=async t=>{const o=new Map,s=await rt(t);for(const[i,r]of Object.entries(s.tasks??{})){const c=`*#${i}`,a=y(c);mt(a,r??{}),o.set(c,a)}const n=s.taskRunner??{},e=y(w);return e.inputs=m(n.globalInputs),e.env=R([...n.globalEnv??[],...n.globalPassThroughEnv??[]]),(e.inputs.length>0||e.env.length>0)&&o.set(w,e),o},yt=(t,o)=>{switch(o){case"moon":return vt(t);case"nx":return lt(t);default:return gt(t)}},kt=t=>{const o=[];return k(f(t,"turbo.json"))&&o.push("turbo"),k(f(t,"nx.json"))&&o.push("nx"),(k(f(t,".moon","tasks.yml"))||k(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"})},wt=(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!==w;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}},Rt=new Set(["json","ndjson","table"]),$t=t=>({equivalent:t.findings.every(o=>o.severity!=="error"),findings:t.findings,source:t.source,sourceNodeCount:t.sourceNodeCount,visNodeCount:t.visNodeCount}),bt=(t,o,s)=>{if(o==="json"){process.stdout.write(`${JSON.stringify($t(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)}},xt=(t,o)=>t.findings.some(s=>o==="warning"?!0:s.severity==="error")?1:0,D=async t=>{if(!T.isTTY)return!0;const o=ct({input:T,output:at});try{const s=(await o.question(`${t} [Y/n] `)).trim().toLowerCase();return s===""||s==="y"||s==="yes"}finally{o.close()}},Ct=[{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"}],jt=[{description:"VisTaskConfig.targets → VisTaskConfig.tasks",next:"tasks",previous:"targets"}],Et=t=>new RegExp(String.raw`(^|[\s,{(\[])(["']?)${t}\2(\s*:)`,"gmu"),St=(t,o)=>{let s=t;const n=[];for(const e of o){const i=Et(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)=>St(t,o),Mt=["vis.config.ts","vis.config.mts","vis.config.cts","vis.config.js","vis.config.mjs","vis.config.cjs"],Ot=new Set(["vis.task.cjs","vis.task.cts","vis.task.js","vis.task.mjs","vis.task.mts","vis.task.ts"]),Tt=t=>{for(const o of Mt){const s=f(t,o);if(k(s))return s}},Nt=t=>{const o=[];try{for(const s of st(t,{includeDirs:!1,includeFiles:!0,includeSymlinks:!1,skip:[/node_modules/,/\.git/,/\.vis\b/,/dist\b/,/\.next\b/,/\.nuxt\b/]}))Ot.has(nt(s.path))&&o.push(s.path)}catch{}return o},_t=(t,o,s,n)=>{const e=Tt(t);if(e){const r=j(e),{applied:c,output:a}=q(r,Ct);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??Nt(t);for(const r of i){if(!k(r))continue;const c=j(r),a=q(c,jt);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:tt(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 D(`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
  `)},At=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 ──"),z(e.root,e.packageManager,e.config,{dryRun:e.dryRun},t,e.report),t.info(""),p(e.report,t)},qt=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 ──"),G(e.root,{dryRun:e.dryRun,useEditorconfig:e.useEditorconfig},t,e.report),t.info(""),p(e.report,t)},Vt=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 ──"),P(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("turborepo",o,t))return;const e=g({logger:t,options:o,visConfig:s,workspaceRoot:n});l(e),t.info("── Migrating turborepo ──"),Y(e.root,{dryRun:e.dryRun,useEditorconfig:e.useEditorconfig},t,e.report),t.info(""),p(e.report,t)},Dt=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;L(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)},Bt=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 ──"),H(e.root,{copyTemplates:!!o.copyTemplates,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("gitleaks",o,t))return;const e=g({logger:t,options:o,visConfig:s,workspaceRoot:n});l(e),t.info("── Migrating gitleaks ──"),K(e.root,{dryRun:e.dryRun,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("kingfisher",o,t))return;const e=g({logger:t,options:o,visConfig:s,workspaceRoot:n});l(e),t.info("── Migrating Kingfisher ──"),Q(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("secretlint",o,t))return;const e=g({logger:t,options:o,visConfig:s,workspaceRoot:n});l(e),t.info("── Migrating secretlint ──"),U(e.root,{dryRun:e.dryRun,useEditorconfig:e.useEditorconfig},t,e.report),t.info(""),p(e.report,t)},zt=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 ──"),X(e.root,{dryRun:e.dryRun,useEditorconfig:e.useEditorconfig},t,e.report),t.info(""),p(e.report,t)},Gt=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 ──"),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("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 ──"),_t(e.root,{dryRun:e.dryRun},t,e.report),t.info(""),p(e.report,t)},Yt=({logger:t,workspaceRoot:o})=>{const s=o??process.cwd();ut(s,t).length>0&&(process.exitCode=1)},Lt=async({logger:t,options:o,workspaceRoot:s})=>{const n=s??process.cwd(),e=o.format??"table";if(!Rt.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=kt(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=yt(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 ht(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=wt(c,a,r);bt(u,e,t),process.exitCode=xt(u,i)},Ht=async({logger:t,options:o,visConfig:s,workspaceRoot:n})=>{const e=n??process.cwd(),i=W(e,s??{}),r=F(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 D("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-J83sowC4.js";import{m as h,a as J,A,f as W}from"../packem_shared/index-CE6MsgcV.js";import{b as I,O as z}from"./catalog.js";import{d as G}from"../packem_shared/lockfile-C1qCKGH6.js";import{p as X,s as Q}from"../packem_shared/docker-BYqiD711.js";import{I as ne}from"../packem_shared/index-B0EsgdzO.js";import{g as L}from"../packem_shared/env-DdQRnEIy.js";const Y=K(import.meta.url),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 Y(e)},{createInterface:_}=y("node:readline"),{spawn:Z}=y("node:child_process"),{createHash:ee}=y("node:crypto"),{existsSync:T,writeFileSync:oe,chmodSync:te}=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"}},re=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-J83sowC4.js";import{m as h,a as J,A,f as W}from"../packem_shared/index-BVuCxe14.js";import{b as I,O as z}from"./catalog.js";import{d as G}from"../packem_shared/lockfile-CWcVTdRc.js";import{p as X,s as Q}from"../packem_shared/docker-CD7o1D1o.js";import{I as ne}from"../packem_shared/index-B0EsgdzO.js";import{g as L}from"../packem_shared/env-Cpxa_7UE.js";const Y=K(import.meta.url),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 Y(e)},{createInterface:_}=y("node:readline"),{spawn:Z}=y("node:child_process"),{createHash:ee}=y("node:crypto"),{existsSync:T,writeFileSync:oe,chmodSync:te}=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"}},re=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/${$}`,se={"hadolint-linux-arm64":"331f1d3511b84a4f1e3d18d52fec284723e4019552f4f47b19322a53ce9a40ed","hadolint-linux-x86_64":"6bf226944684f56c84dd014e8b979d27425c0148f61b3bd99bcc6f39e9dc5a47","hadolint-macos-arm64":"3625e2e9f43dcfe7bd38738a5f5520ed50ce39ed28485266e6803dd7bc197b10","hadolint-macos-x86_64":"2b69a853433f1eca522ffb921cd490bd1321424d03331fd8390f93b7fb4a02e9","hadolint-windows-x86_64.exe":"8e0ee174f88edb14f207a68430c7a53c2883ed509cdbde9a3a26fffa140fa5e4"},ie=e=>se[e],ae=(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"),ce=()=>{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},le=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())},de=async e=>{const o=H(e),t=ie(e),r=await C(`${S}/${e}`),n=ee("sha256").update(r).digest("hex");if(t===void 0){const s=await C(`${S}/${e}.sha256`),i=le(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 J(h(L(),"hadolint",$)),oe(o,r),process.platform!=="win32"&&te(o,493),o},ue=async()=>{const e=_({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"},fe=async e=>{const{autoInstall:o=!1,log:t}=e,r=ce();if(r!==void 0)return r;const n=ae();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&&!ne)){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 ue()){t(`Skipped. Install it yourself or re-run with ${b("--install")}.`);return}}t(`Downloading hadolint ${$} (${n})…`);try{const i=await de(n);return t(`Installed hadolint to ${m(i)}`),i}catch(i){t(`Failed to download hadolint: ${i.message}`);return}},O=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=Z(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:[]},E=(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=>E(e,"-y",/(?:^|\s)(?:-y|--yes|--assume-yes|-qq?)\b/u),DL3015:e=>E(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)),pe=(e,o)=>{const t=e.includes(`\r
3
3
  `)?`\r
4
4
  `:`
@@ -1,4 +1,4 @@
1
- import{createRequire as G}from"node:module";import{w as H,k as J,p,P as O,i as S}from"./cli-main.js";import"../packem_shared/index-CE6MsgcV.js";import"../packem_shared/public-api-WqUCiyIe.js";import{g as V,R as W,c as K,V as Z,$ as T,d as a,h as Q,i as g,H as M,j as X,G as ee,F as m}from"./catalog.js";import{B as te}from"../packem_shared/env-DdQRnEIy.js";import{I as oe}from"../packem_shared/index-B0EsgdzO.js";import{K as re,Z as se,W as ne}from"../packem_shared/ai-analysis-BpVdn20h.js";import{A as ie}from"../packem_shared/pm-runner-CQcraCcu.js";import{U as ae,b as ce,u as N}from"../packem_shared/vis-update-app-BlocL713.js";const de=G(import.meta.url),ue=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process;const ke=async({argument:E,logger:o,options:e,visConfig:i,workspaceRoot:C})=>{if(!C)throw new Error("Could not determine workspace root. Run this command inside a monorepo.");const d=C;if(e.securityConfig){const t=ie(d);if(H(i??{},t.name),e.sync&&t.name==="pnpm"){const r=J(i??{});if(r.length>0){p.info(`
1
+ import{createRequire as G}from"node:module";import{w as H,k as J,p,P as O,i as S}from"./cli-main.js";import"../packem_shared/index-BVuCxe14.js";import"../packem_shared/public-api-WqUCiyIe.js";import{g as V,R as W,c as K,V as Z,$ as T,d as a,h as Q,i as g,H as M,j as X,G as ee,F as m}from"./catalog.js";import{B as te}from"../packem_shared/env-Cpxa_7UE.js";import{I as oe}from"../packem_shared/index-B0EsgdzO.js";import{K as re,Z as se,W as ne}from"../packem_shared/ai-analysis-CO7No4rt.js";import{A as ie}from"../packem_shared/pm-runner-mVFjedM6.js";import{U as ae,b as ce,u as N}from"../packem_shared/vis-update-app-qIkyvrd1.js";const de=G(import.meta.url),ue=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process;const ke=async({argument:E,logger:o,options:e,visConfig:i,workspaceRoot:C})=>{if(!C)throw new Error("Could not determine workspace root. Run this command inside a monorepo.");const d=C;if(e.securityConfig){const t=ie(d);if(H(i??{},t.name),e.sync&&t.name==="pnpm"){const r=J(i??{});if(r.length>0){p.info(`
2
2
  Settings that would sync to pnpm-workspace.yaml:`);for(const b of r)p.success(` ${b}`)}else p.info("No security settings to sync.")}else e.sync&&t.name!=="pnpm"&&(p.info(`--sync is only available for pnpm projects. Your project uses ${t.name}.`),p.info("vis enforces security settings at the vis layer for non-pnpm projects."));if(!e.security&&!E?.length)return}const{packageManager:U}=O(d),B=V(d),c=i?.update??{},y=W(d,U,{dev:e.dev,includeInternal:e["include-internal"],peer:e.peer,prod:e.prod});if(y.size===0){o.info("No catalogs found.");return}const h=e.target??c.target??"latest";if(!["latest","minor","patch"].includes(h))throw new Error(`Invalid target "${h}". Use: latest, minor, or patch.`);const D={exclude:[...m(e.exclude),...m(c.exclude)],ignore:m(c.ignore),include:[...m(e.include),...m(c.include),...E],includeLocked:!!e.includeLocked,includePrerelease:e.prerelease||c.prerelease||!1,security:e.security!==!1,target:h};let j=0;for(const t of y.values())j+=t.size;const $=!!process.stdout.isTTY&&!oe;let l;const F=$?(t,r)=>{l?l.rerender(a.createElement(N,{current:t,total:r})):l=T(a.createElement(N,{current:t,total:r}),{interactive:!0,patchConsole:!1})}:(t,r)=>{o.info(`Checking ${String(t)}/${String(r)} dependencies...`)};$||o.info(`Checking ${String(j)} catalog dependencies against npm registry...
3
3
  `);const v=new Set;S("socket")&&v.add("socket"),S("depsDev")&&v.add("deps-dev");const w=i?.security?.policies?.score?.minimum,I=K(i?.security,{disabled:v,minimumScore:w}),{failed:k,outdated:n}=await Z(y,D,B,F,d,I,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 R=e.format??c.format??"table",P=re(e.aiType??"impact"),u=e.ai?await se(n,o,i?.ai,P):void 0;if($&&R==="table"){const t=new ae(n,u??null),r=i?.tui?.autoExit??!1,b=r===!0?3:typeof r=="number"?r:0;await T(a.createElement(ce,{autoExitSeconds:b,isDryRun:!0,store:t}),{alternateScreen:!0,exitOnCtrlC:!1,interactive:!0,patchConsole:!0}).waitUntilExit();const q=process.stdout.columns||80;process.stdout.write(`
4
4
  `);for(const s of n){const z=s.vulnerabilities?.length||s.socketReport&&s.socketReport.alerts.length>0,_=!!s.acceptedRisk,A=z?_?"✓":"⚠":"✓",L=_?"gray":s.updateType==="major"?"red":s.updateType==="minor"?"yellow":"green",f=s.socketReport?.score.overall,Y=f===void 0?"":` [${String(Math.round(f*100))}%]`,x=f===void 0?void 0:te(f);process.stdout.write(`${Q(a.createElement(g,null," ",a.createElement(g,{color:L},A),` ${s.packageName} ${s.currentRange} → ${s.newRange}`,a.createElement(g,{dimColor:!0},` ${s.updateType}`),x?a.createElement(g,{color:x},Y):null),{columns:q})}
@@ -1,3 +1,3 @@
1
- import{createRequire as G}from"node:module";import{I as F,q as L,j as V,E as N}from"../packem_shared/index.server-J83sowC4.js";import{y as E}from"../packem_shared/index-CE6MsgcV.js";import{T as U}from"./cli-main.js";import{d as A,f as C,r as D,a as Q,b as X,s as Y,c as Z,e as ee,g as te,h as se,i as re,j as ie,k as ne,l as oe,m as ae,n as de,o as ce,p as fe,q as pe,t as le}from"../packem_shared/watch-loop-BZudYfcl.js";import{p as h}from"./catalog.js";const H=G(import.meta.url),k=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,I=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 H(t)},{createHash:q}=I("node:crypto"),ue=t=>t.startsWith("/")||/^[a-z]:[\\/]/i.test(t),_=(t,e)=>ue(e)?e:`${t}/${e}`,ge={argsCheck:(t,e)=>O(t,e,"check"),argsFix:(t,e)=>O(t,e,"fix"),bin:()=>["pnpm","exec","dprint"],cacheKey:(t,e)=>{const s=["dprint",t.declaredVersion??"unknown",t.configFile??"no-config",e.quiet?"q":"",...e.extraArgs??[]];return q("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:_(e.root,i),fixable:!0,message:"Code style issues would be auto-fixed",severity:"info"})}return s}},O=(t,e,s)=>{const r=s==="fix"?["fmt"]:["check","--list-different"];return e.extraArgs?.length&&r.push(...e.extraArgs),r.push(...t),r},me={argsCheck:(t,e)=>B(t,e,"check"),argsFix:(t,e)=>B(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 q("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:_(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.extraArgs?.length&&r.push(...e.extraArgs),r.push(...t),r},he={argsCheck:(t,e)=>P(t,e,"check"),argsFix:(t,e)=>P(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 q("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:_(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"?["--write"]:["--list-different"];return e.quiet&&r.push("--log-level","warn"),e.extraArgs?.length&&r.push(...e.extraArgs),r.push(...t),r},xe=[me,de,ge,he,ce,fe],qe=async({logger:t,options:e,visConfig:s,workspaceRoot:r})=>{const i=r??process.cwd(),u=s?.fmt,w=D(xe,u?.order),K=Q(i,w),x=X(K,w,"fmt").filter(({adapter:p})=>u?.adapters?.[p.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 $=p=>{const o=u?.adapters?.[p]?.extraArgs;return o&&o.length>0?[...o]:void 0},j={quiet:e.quiet??!1},R=ke(e),y=e.check?"check":"fix";let d;if(e.staged){if(d=Y(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=Z(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=U(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 p=>{const o=R.length>0?R:p,g=[];if(o){const n=te(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=$(a.id),T={adapter:a,files:f,presence:c};W&&(T.options={...j,extraArgs:W}),g.push(T)}}else for(const{adapter:n,presence:a}of x){const c=$(n.id),f={adapter:n,files:["."],presence:a};c&&(f.options={...j,extraArgs:c}),g.push(f)}if(g.length===0)return;const J=await se(g,j,y,{cacheRoot:z}),b=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}}),l=re(b.map(n=>({adapter:n.adapter.id,durationMs:n.durationMs,exitCode:n.exitCode,findingCount:n.findings.length,findings:n.findings}))),m=v==="human"?void 0:ie({cwd:i,target:e.output});try{switch(v){case"github":{m.write(ae({runs:b.map(n=>({findings:n.findings})),workspaceRoot:i}));break}case"json":{m.write(`${JSON.stringify({findings:l.findings,mode:y,runs:l.runs},null,2)}
1
+ import{createRequire as G}from"node:module";import{I as F,q as L,j as V,E as N}from"../packem_shared/index.server-J83sowC4.js";import{y as E}from"../packem_shared/index-BVuCxe14.js";import{T as U}from"./cli-main.js";import{d as A,f as C,r as D,a as Q,b as X,s as Y,c as Z,e as ee,g as te,h as se,i as re,j as ie,k as ne,l as oe,m as ae,n as de,o as ce,p as fe,q as pe,t as le}from"../packem_shared/watch-loop-Irf3Pm-1.js";import{p as h}from"./catalog.js";const H=G(import.meta.url),k=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,I=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 H(t)},{createHash:q}=I("node:crypto"),ue=t=>t.startsWith("/")||/^[a-z]:[\\/]/i.test(t),_=(t,e)=>ue(e)?e:`${t}/${e}`,ge={argsCheck:(t,e)=>O(t,e,"check"),argsFix:(t,e)=>O(t,e,"fix"),bin:()=>["pnpm","exec","dprint"],cacheKey:(t,e)=>{const s=["dprint",t.declaredVersion??"unknown",t.configFile??"no-config",e.quiet?"q":"",...e.extraArgs??[]];return q("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:_(e.root,i),fixable:!0,message:"Code style issues would be auto-fixed",severity:"info"})}return s}},O=(t,e,s)=>{const r=s==="fix"?["fmt"]:["check","--list-different"];return e.extraArgs?.length&&r.push(...e.extraArgs),r.push(...t),r},me={argsCheck:(t,e)=>B(t,e,"check"),argsFix:(t,e)=>B(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 q("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:_(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.extraArgs?.length&&r.push(...e.extraArgs),r.push(...t),r},he={argsCheck:(t,e)=>P(t,e,"check"),argsFix:(t,e)=>P(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 q("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:_(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"?["--write"]:["--list-different"];return e.quiet&&r.push("--log-level","warn"),e.extraArgs?.length&&r.push(...e.extraArgs),r.push(...t),r},xe=[me,de,ge,he,ce,fe],qe=async({logger:t,options:e,visConfig:s,workspaceRoot:r})=>{const i=r??process.cwd(),u=s?.fmt,w=D(xe,u?.order),K=Q(i,w),x=X(K,w,"fmt").filter(({adapter:p})=>u?.adapters?.[p.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 $=p=>{const o=u?.adapters?.[p]?.extraArgs;return o&&o.length>0?[...o]:void 0},j={quiet:e.quiet??!1},R=ke(e),y=e.check?"check":"fix";let d;if(e.staged){if(d=Y(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=Z(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=U(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 p=>{const o=R.length>0?R:p,g=[];if(o){const n=te(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=$(a.id),T={adapter:a,files:f,presence:c};W&&(T.options={...j,extraArgs:W}),g.push(T)}}else for(const{adapter:n,presence:a}of x){const c=$(n.id),f={adapter:n,files:["."],presence:a};c&&(f.options={...j,extraArgs:c}),g.push(f)}if(g.length===0)return;const J=await se(g,j,y,{cacheRoot:z}),b=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}}),l=re(b.map(n=>({adapter:n.adapter.id,durationMs:n.durationMs,exitCode:n.exitCode,findingCount:n.findings.length,findings:n.findings}))),m=v==="human"?void 0:ie({cwd:i,target:e.output});try{switch(v){case"github":{m.write(ae({runs:b.map(n=>({findings:n.findings})),workspaceRoot:i}));break}case"json":{m.write(`${JSON.stringify({findings:l.findings,mode:y,runs:l.runs},null,2)}
2
2
  `);break}case"junit":{m.write(oe({runs:b.map(n=>({adapter:n.adapter.id,durationMs:n.durationMs,findings:n.findings})),workspaceRoot:i}));break}case"minimal":{ye(l.findings,i,m);break}case"sarif":{m.write(ne({runs:b.map(n=>({adapter:n.adapter.id,findings:n.findings,presence:g.find(a=>a.adapter.id===n.adapter.id)?.presence})),workspaceRoot:i}));break}default:we(l.findings,i,y,t)}}finally{m?.close()}const S=y==="fix"?l.hadProcessFailure?1:0:le({...l,maxSeverity:l.findings.length>0?"error":void 0});S!==0&&(process.exitCode=S)};if(e.watch){const p=[...new Set(x.flatMap(({adapter:o})=>o.extensions))];await ee({extensions:p,initialFiles:d,label:"fmt",log:o=>{t.info(o)},runCycle:M,workspaceRoot:i});return}await M(d)},ke=t=>{const e=t;return[...e._??e.args??[]]},we=(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"?L(V("Formatted:")):V("Would change:");r.info(u);for(const w of i.keys())r.info(` ${N("·")} ${E(e,w)}`);s==="check"&&(r.info(""),r.info(N(`Run \`vis fmt\` to apply changes (${String(i.size)} file${i.size===1?"":"s"}).`)))},ye=(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-J83sowC4.js";import{m as T,f as j,I as V,H as G,y as K,a as L,A as P,o as se,T as ne,B as oe}from"../packem_shared/index-CE6MsgcV.js";import{f as ue}from"../packem_shared/giget-DVTFJlbR.js";import{p as l}from"./cli-main.js";const re=te(import.meta.url),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 re(t)},{fileURLToPath:ie}=E("node:url"),{createInterface:ae}=E("node:readline"),{mkdtempSync:ce,rmSync:le}=E("node:fs"),{tmpdir:fe}=E("node:os"),{spawnSync:pe}=E("node:child_process"),J=[".ts",".mts",".cts",".js",".mjs",".cjs"],de="template.yml",me=[".d",".test",".spec",".config",".bench",".stories"],he=[".d.ts",".d.mts",".d.cts",".js.map",".mjs.map",".cjs.map",".ts.map"],Y=t=>{for(const e of J)if(t.endsWith(e))return t.slice(0,-e.length);return t},$e=t=>{if(he.some(r=>t.endsWith(r))||!J.some(r=>t.endsWith(r)))return!1;const e=Y(t);return!me.some(r=>e.endsWith(r))},H=(t,e)=>{const r=[];if(!j(t))return r;for(const s of V(t,{includeDirs:!1,includeSymlinks:!1,maxDepth:1})){if(!$e(s.name))continue;const n=Y(s.name);r.push({load:()=>ge(s.path),name:n,path:s.path,source:e})}return r},x=(t,e)=>{const r=[];if(!j(t))return r;for(const s of V(t,{includeFiles:!1,includeSymlinks:!1,maxDepth:1})){if(s.path===t)continue;const n=T(s.path,de);j(n)&&r.push({load:()=>ye(s.path,s.name),name:s.name,path:s.path,source:e})}return r},we=()=>{try{const t=ie(import.meta.url),e=T(G(t),"..","..","templates");return j(e)?e:void 0}catch{return}},I=t=>{const{extraDirectories:e=[],onWarning:r,workspaceRoot:s}=t,n=[...H(T(s,".vis","templates"),"native"),...x(T(s,".vis","templates"),"moon"),...x(T(s,".moon","templates"),"moon")];for(const o of e)n.push(...x(o,"config")),n.push(...H(o,"config"));const i=we();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))},ge=async t=>{const{loadNativeTemplate:e}=await import("./loader2.js");return e(t)},ye=async(t,e)=>{const{loadMoonTemplate:r}=await import("./index3.js");return r(t,e)},q=(t,e)=>new Promise(r=>{t.question(e,s=>{r(s.trim())})}),ve=async(t,e,r)=>{const s=await q(t,` ${e} ${u(r?"[Y/n]":"[y/N]")} `);return s===""?r:s.toLowerCase()==="y"||s.toLowerCase()==="yes"},be=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-J83sowC4.js";import{m as T,f as j,I as V,H as G,y as K,a as L,A as P,o as se,T as ne,B as oe}from"../packem_shared/index-BVuCxe14.js";import{f as ue}from"../packem_shared/giget-DVTFJlbR.js";import{p as l}from"./cli-main.js";const re=te(import.meta.url),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 re(t)},{fileURLToPath:ie}=E("node:url"),{createInterface:ae}=E("node:readline"),{mkdtempSync:ce,rmSync:le}=E("node:fs"),{tmpdir:fe}=E("node:os"),{spawnSync:pe}=E("node:child_process"),J=[".ts",".mts",".cts",".js",".mjs",".cjs"],de="template.yml",me=[".d",".test",".spec",".config",".bench",".stories"],he=[".d.ts",".d.mts",".d.cts",".js.map",".mjs.map",".cjs.map",".ts.map"],Y=t=>{for(const e of J)if(t.endsWith(e))return t.slice(0,-e.length);return t},$e=t=>{if(he.some(r=>t.endsWith(r))||!J.some(r=>t.endsWith(r)))return!1;const e=Y(t);return!me.some(r=>e.endsWith(r))},H=(t,e)=>{const r=[];if(!j(t))return r;for(const s of V(t,{includeDirs:!1,includeSymlinks:!1,maxDepth:1})){if(!$e(s.name))continue;const n=Y(s.name);r.push({load:()=>ge(s.path),name:n,path:s.path,source:e})}return r},x=(t,e)=>{const r=[];if(!j(t))return r;for(const s of V(t,{includeFiles:!1,includeSymlinks:!1,maxDepth:1})){if(s.path===t)continue;const n=T(s.path,de);j(n)&&r.push({load:()=>ye(s.path,s.name),name:s.name,path:s.path,source:e})}return r},we=()=>{try{const t=ie(import.meta.url),e=T(G(t),"..","..","templates");return j(e)?e:void 0}catch{return}},I=t=>{const{extraDirectories:e=[],onWarning:r,workspaceRoot:s}=t,n=[...H(T(s,".vis","templates"),"native"),...x(T(s,".vis","templates"),"moon"),...x(T(s,".moon","templates"),"moon")];for(const o of e)n.push(...x(o,"config")),n.push(...H(o,"config"));const i=we();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))},ge=async t=>{const{loadNativeTemplate:e}=await import("./loader2.js");return e(t)},ye=async(t,e)=>{const{loadMoonTemplate:r}=await import("./index3.js");return r(t,e)},q=(t,e)=>new Promise(r=>{t.question(e,s=>{r(s.trim())})}),ve=async(t,e,r)=>{const s=await q(t,` ${e} ${u(r?"[Y/n]":"[y/N]")} `);return s===""?r:s.toLowerCase()==="y"||s.toLowerCase()==="yes"},be=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 q(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{v as F,H as P,y as S,m as b,T as I,O as U,a as T}from"../packem_shared/index-CE6MsgcV.js";import _ from"./index.js";import{b as J,l as M}from"./catalog.js";import{n as q}from"../packem_shared/manifests-DSBr3-dw.js";import{U as C,V as B}from"./cli-main.js";import{s as H}from"../packem_shared/glob-fqg4KepW-1S3z30c8.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},z="Update each project's project.json `owners` field and re-run the command.",Y=e=>["# CODEOWNERS — generated by `vis sync codeowners`. Do not edit by hand.",e?`# Re-run with: ${e}`:`# ${z}`,""],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},Q=(e,t={})=>[...Y(t.regenerationCommand),...W(e),""].join(`
1
+ import{v as F,H as P,y as S,m as b,T as I,O as U,a as T}from"../packem_shared/index-BVuCxe14.js";import _ from"./index.js";import{b as J,l as M}from"./catalog.js";import{n as q}from"../packem_shared/manifests-CaPqgQxW.js";import{U as C,V as B}from"./cli-main.js";import{s as H}from"../packem_shared/glob-DMbPwGSj-uzODoE-1.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},z="Update each project's project.json `owners` field and re-run the command.",Y=e=>["# CODEOWNERS — generated by `vis sync codeowners`. Do not edit by hand.",e?`# Re-run with: ${e}`:`# ${z}`,""],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},Q=(e,t={})=>[...Y(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 D,E as O,V as T,s as K,q as Q}from"../packem_shared/index.server-J83sowC4.js";import{y as B}from"../packem_shared/index-CE6MsgcV.js";import{T as X}from"./cli-main.js";import{d as k,f as v,r as Y,a as Z,b as ee,s as ne,c as te,e as ie,u as re,h as se,i as oe,j as ae,k as le,l as ce,m as de,n as ue,v as fe,w as ge,q as pe,t as me}from"../packem_shared/watch-loop-BZudYfcl.js";import{p as c}from"./catalog.js";const H=G(import.meta.url),w=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,U=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 H(e)},{createHash:y}=U("node:crypto"),he={1:"warning",2:"error"},xe={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":he[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},we=/^([^:]+):(\d+)(?::(\d+))?\s+([\w/-]+)\s+(.+)$/,ke=e=>{const n=we.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}},ve=e=>e.startsWith("/")||/^[a-z]:[\\/]/i.test(e),ye={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=ke(r.trim());s&&i.push({adapter:"markdownlint",column:s.column,file:ve(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"},be={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},Ae={error:"error",info:"info",style:"info",warning:"warning"},Fe=e=>e.startsWith("/")||/^[a-z]:[\\/]/i.test(e),je=(e,n)=>e?Fe(e)?e:`${n}/${e}`:n,Ce={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:je(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:Ae[r.level??""]??"warning"});return i}},L=(e,n)=>{const t=["--format=json1"];return n.extraArgs?.length&&t.push(...n.extraArgs),t.push(...e),t},Se={error:"error",warning:"warning"},qe={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:Se[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},We=[be,ue,xe,qe,fe,ye,Ce,ge],Be=async({logger:e,options:n,visConfig:t,workspaceRoot:i})=>{const r=i??process.cwd(),s=t?.lint,a=Y(We,s?.order),j=Z(r,a),d=ee(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},$={extraArgs:void 0,maxWarnings:typeof n.maxWarnings=="number"?n.maxWarnings:void 0,quiet:n.quiet??!1},b=Ne(n),P=n.fix?"fix":"check";let f;if(n.staged){if(f=ne(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=te(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=b.length>0?b:void 0,E=X(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=re(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={...$,extraArgs:F}),m.push(I)}if(m.length===0)return;const z=await se(m,$,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=oe(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:ae({cwd:r,target:n.output});try{switch(S){case"github":{p.write(de({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 D,E as O,V as T,s as K,q as Q}from"../packem_shared/index.server-J83sowC4.js";import{y as B}from"../packem_shared/index-BVuCxe14.js";import{T as X}from"./cli-main.js";import{d as k,f as v,r as Y,a as Z,b as ee,s as ne,c as te,e as ie,u as re,h as se,i as oe,j as ae,k as le,l as ce,m as de,n as ue,v as fe,w as ge,q as pe,t as me}from"../packem_shared/watch-loop-Irf3Pm-1.js";import{p as c}from"./catalog.js";const H=G(import.meta.url),w=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,U=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 H(e)},{createHash:y}=U("node:crypto"),he={1:"warning",2:"error"},xe={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":he[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},we=/^([^:]+):(\d+)(?::(\d+))?\s+([\w/-]+)\s+(.+)$/,ke=e=>{const n=we.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}},ve=e=>e.startsWith("/")||/^[a-z]:[\\/]/i.test(e),ye={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=ke(r.trim());s&&i.push({adapter:"markdownlint",column:s.column,file:ve(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"},be={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},Ae={error:"error",info:"info",style:"info",warning:"warning"},Fe=e=>e.startsWith("/")||/^[a-z]:[\\/]/i.test(e),je=(e,n)=>e?Fe(e)?e:`${n}/${e}`:n,Ce={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:je(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:Ae[r.level??""]??"warning"});return i}},L=(e,n)=>{const t=["--format=json1"];return n.extraArgs?.length&&t.push(...n.extraArgs),t.push(...e),t},Se={error:"error",warning:"warning"},qe={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:Se[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},We=[be,ue,xe,qe,fe,ye,Ce,ge],Be=async({logger:e,options:n,visConfig:t,workspaceRoot:i})=>{const r=i??process.cwd(),s=t?.lint,a=Y(We,s?.order),j=Z(r,a),d=ee(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},$={extraArgs:void 0,maxWarnings:typeof n.maxWarnings=="number"?n.maxWarnings:void 0,quiet:n.quiet??!1},b=Ne(n),P=n.fix?"fix":"check";let f;if(n.staged){if(f=ne(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=te(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=b.length>0?b:void 0,E=X(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=re(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={...$,extraArgs:F}),m.push(I)}if(m.length===0)return;const z=await se(m,$,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=oe(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:ae({cwd:r,target:n.output});try{switch(S){case"github":{p.write(de({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(ce({runs:A.map(o=>({adapter:o.adapter.id,durationMs:o.durationMs,findings:o.findings})),workspaceRoot:r}));break}case"minimal":{Ie(h.findings,r,p);break}case"sarif":{p.write(le({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:_e(h.findings,r,e)}}finally{p?.close()}const _=me(h);_!==0&&(process.exitCode=_)};if(n.watch){const l=[...new Set(d.flatMap(({adapter:u})=>u.extensions))];await ie({extensions:l,initialFiles:f,label:"lint",log:u=>{e.info(u)},runCycle:N,workspaceRoot:r});return}await N(f)},Ne=e=>{const n=e;return[...n._??n.args??[]]},_e=(e,n,t)=>{if(e.length===0){t.info(q("✓ lint: no findings"));return}const i=pe(e);for(const[a,j]of i){t.info(D(B(n,a)));for(const d of j){const C=Oe(d),$=Ve(d.severity),b=d.ruleId?O(` ${d.ruleId}`):"";t.info(` ${O(C)} ${$} ${d.message}${b}`)}}const r=e.filter(a=>a.severity==="error").length,s=e.filter(a=>a.severity==="warning").length;t.info(""),t.info(`${T(`${String(r)} error${r===1?"":"s"}`)}, ${K(`${String(s)} warning${s===1?"":"s"}`)}`)},Ie=(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
  `)}},Oe=e=>e.line===void 0?"":e.column===void 0?String(e.line):`${String(e.line)}:${String(e.column)}`,Ve=e=>e==="error"?T("error"):e==="warning"?K("warn "):Q("info ");export{Be as default};
@@ -1,4 +1,4 @@
1
- import{createRequire as z}from"node:module";import{y as _,v as L,m as P,f as M,J as K,B as V}from"../packem_shared/index-CE6MsgcV.js";import{m as t,n as a,i as c,r as v,$ as Y,d as Q,k as U,s as Z,t as ee,u as re,e as te,W as N}from"./catalog.js";import"../packem_shared/env-DdQRnEIy.js";import{I as se}from"../packem_shared/index-B0EsgdzO.js";import oe from"./index.js";import{sortPackageJsonStringWithOptions as q}from"#native";import{J as ne,_ as ie,K as le,I as ce,y as ae,p as k}from"./cli-main.js";import{o as O}from"../packem_shared/utils-CRueU43T.js";const Ye=z(import.meta.url),Qe=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process;const A={error:0,rewritten:1,"would-rewrite":1,unchanged:2},de=e=>[...e].sort((r,s)=>A[r.status]-A[s.status]),ue=(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 fe{#e;#r=new Set;constructor(r){this.#e={entries:de(r),filterType:"all",focusedPanel:"list",selectedIndex:0}}getSnapshot=()=>this.#e;subscribe=r=>(this.#r.add(r),()=>{this.#r.delete(r)});getFilteredEntries=()=>ue(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 he=({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(ne,{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"})})},ge={error:"red",rewritten:"yellow",unchanged:"green","would-rewrite":"yellow"},pe={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"},me=[{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"}],X=e=>{const r={errors:0,rewrites:0,sorted:0};for(const s of e)r[H[s.status]]++;return r},we=({entry:e,isSelected:r})=>{const s=ge[e.status],l=pe[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"}`})]})},je=({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)})`})}),ye=({counts:e,entries:r,filterType:s,focused:l,selectedIndex:i,totalEntries:o,viewportHeight:n})=>{const d=l?"white":"gray",g=X(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,x]of r.entries()){const b=H[x.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:x,entryIndex:u,kind:"entry"})}const p=h.findIndex(u=>u.kind==="entry"&&u.entryIndex===i),S=p!==-1,j=h.length,$=Math.max(0,j-n);let f=0;S&&n>0&&(f=Math.min($,Math.max(0,p-n+1)));const E=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:me.map(u=>{const x=s===u.key,b=u.count(e);return t.jsxs(a,{children:[t.jsx(c,{dimColor:!x,children:"["}),t.jsx(c,{bold:x,color:x?"cyan":"gray",children:u.shortcut}),t.jsx(c,{dimColor:!x,children:"]"}),t.jsxs(c,{color:x?"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,x)=>u.kind==="spacer"?t.jsx(a,{flexShrink:0,height:1},`s-${String(x)}`):u.kind==="header"?t.jsx(je,{color:u.color,count:u.count,label:u.label},`h-${u.label}`):t.jsx(we,{entry:u.entry,isSelected:u.entryIndex===i},u.entry.filePath))})}),E&&t.jsx(a,{flexShrink:0,marginLeft:1,marginRight:1,children:t.jsx(ie,{contentHeight:j,placement:"inset",scrollOffset:f,style:"block",viewportHeight:n})})]})]})},be=100,D=10,ke=6,Se=1,F={1:"all",2:"rewritten",3:"errors",4:"unchanged"},$e=({checkMode:e,store:r})=>{const{exit:s}=le(),{columns:l,rows:i}=ce(),o=v.useSyncExternalStore(r.subscribe,r.getSnapshot),n=v.useRef(null),d=r.getFilteredEntries(),g=d[o.selectedIndex]??null,m=X(o.entries),y=l>=be,h=Math.max(0,i-Se),w=y?h:Math.floor(h/2),p=Math.max(0,w-ke),S=v.useCallback(()=>{s()},[s]),j=v.useRef(0),$=v.useRef(void 0),f=v.useRef(!1),E=v.useCallback((u,x)=>{j.current+=x,$.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 ae((u,x)=>{if(u==="q"||x.escape){S();return}if(F[u]){r.setFilter(F[u]);return}if(x.tab){r.setFocusedPanel(o.focusedPanel==="list"?"detail":"list");return}o.focusedPanel==="list"?x.upArrow||u==="k"?E("list",-1):(x.downArrow||u==="j")&&E("list",1):o.focusedPanel==="detail"&&(x.upArrow||u==="k"?E("detail",-1):(x.downArrow||u==="j")&&E("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(ye,{counts:m,entries:d,filterType:o.filterType,focused:o.focusedPanel==="list",selectedIndex:o.selectedIndex,totalEntries:o.entries.length,viewportHeight:p})}),t.jsx(a,{flexBasis:"50%",flexGrow:1,flexShrink:1,children:t.jsx(he,{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"})})]})},B=["types","node-addons","node","import","require","default"],ve=/^git\+https:\/\/github\.com\/([^/]+)\/([^/.]+(?:\.git)?)$/,Ee=/^git\+ssh:\/\/git@github\.com\/([^/]+)\/([^/.]+(?:\.git)?)$/,C=e=>typeof e=="object"&&e!==null&&!Array.isArray(e),I=e=>{if(e===null||typeof e!="object")return e;if(Array.isArray(e))return e.map(s=>I(s));const r={};for(const[s,l]of Object.entries(e))r[s]=I(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}},Oe=e=>e.endsWith(".git")?e.slice(0,-4):e,Ce=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=ve.exec(s)??Ee.exec(s);if(!l)return{changed:!1,value:e};const i=l[1],o=Oe(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}`}},Re=e=>{const r=Object.keys(e),s=[],l=[];for(const n of B)Object.hasOwn(e,n)&&s.push(n);for(const n of r)B.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}},W=e=>{if(!C(e))return{changed:!1,value:e};let r=!1;const s={};for(const[i,o]of Object.entries(e)){const n=W(o);s[i]=n.value,n.changed&&(r=!0)}const l=Re(s);return{changed:r||l.changed,value:l.value}},Ie=(e,r)=>{const s=I(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=Ce(s.repository);i.changed&&(s.repository=i.value,l=!0)}if(r.sortExports!==!1&&Object.hasOwn(s,"exports")&&C(s.exports)){const i=W(s.exports);i.changed&&(s.exports=i.value,l=!0)}return{changed:l,pkg:s}},Te=/at position (\d+)/,Me=/\(?line (\d+) column (\d+)\)?/,Ne=e=>{const r=new Set,s=[],l=o=>{const n=V(o);!r.has(n)&&M(n)&&(r.add(n),s.push(n))};l(P(e,"package.json"));const i=te(e);if(i){const o=N(e,i);for(const n of o)l(P(e,n,"package.json"))}else{const o=P(e,"package.json");if(M(o)){const n=JSON.parse(L(o)),d=Array.isArray(n.workspaces)?n.workspaces:n.workspaces?.packages;if(d){const g=N(e,d);for(const m of g)l(P(e,m,"package.json"))}}}return s},Ae=e=>/\n([ \t]+)/.exec(e)?.[1]??" ",De=e=>{if(!(e===void 0||e===""))return e==="tab"||e===String.raw`\t`?" ":/^\d+$/.test(e)?" ".repeat(Number.parseInt(e,10)):e},R=e=>e===void 0?[]:(Array.isArray(e)?e:[e]).flatMap(r=>r.split(",")).map(r=>r.trim()).filter(r=>r.length>0),Fe=e=>e.includes(`\r
1
+ import{createRequire as z}from"node:module";import{y as _,v as L,m as P,f as M,J as K,B as V}from"../packem_shared/index-BVuCxe14.js";import{m as t,n as a,i as c,r as v,$ as Y,d as Q,k as U,s as Z,t as ee,u as re,e as te,W as N}from"./catalog.js";import"../packem_shared/env-Cpxa_7UE.js";import{I as se}from"../packem_shared/index-B0EsgdzO.js";import oe from"./index.js";import{sortPackageJsonStringWithOptions as q}from"#native";import{J as ne,_ as ie,K as le,I as ce,y as ae,p as k}from"./cli-main.js";import{o as O}from"../packem_shared/utils-CRueU43T.js";const Ye=z(import.meta.url),Qe=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process;const A={error:0,rewritten:1,"would-rewrite":1,unchanged:2},de=e=>[...e].sort((r,s)=>A[r.status]-A[s.status]),ue=(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 fe{#e;#r=new Set;constructor(r){this.#e={entries:de(r),filterType:"all",focusedPanel:"list",selectedIndex:0}}getSnapshot=()=>this.#e;subscribe=r=>(this.#r.add(r),()=>{this.#r.delete(r)});getFilteredEntries=()=>ue(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 he=({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(ne,{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"})})},ge={error:"red",rewritten:"yellow",unchanged:"green","would-rewrite":"yellow"},pe={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"},me=[{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"}],X=e=>{const r={errors:0,rewrites:0,sorted:0};for(const s of e)r[H[s.status]]++;return r},we=({entry:e,isSelected:r})=>{const s=ge[e.status],l=pe[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"}`})]})},je=({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)})`})}),ye=({counts:e,entries:r,filterType:s,focused:l,selectedIndex:i,totalEntries:o,viewportHeight:n})=>{const d=l?"white":"gray",g=X(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,x]of r.entries()){const b=H[x.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:x,entryIndex:u,kind:"entry"})}const p=h.findIndex(u=>u.kind==="entry"&&u.entryIndex===i),S=p!==-1,j=h.length,$=Math.max(0,j-n);let f=0;S&&n>0&&(f=Math.min($,Math.max(0,p-n+1)));const E=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:me.map(u=>{const x=s===u.key,b=u.count(e);return t.jsxs(a,{children:[t.jsx(c,{dimColor:!x,children:"["}),t.jsx(c,{bold:x,color:x?"cyan":"gray",children:u.shortcut}),t.jsx(c,{dimColor:!x,children:"]"}),t.jsxs(c,{color:x?"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,x)=>u.kind==="spacer"?t.jsx(a,{flexShrink:0,height:1},`s-${String(x)}`):u.kind==="header"?t.jsx(je,{color:u.color,count:u.count,label:u.label},`h-${u.label}`):t.jsx(we,{entry:u.entry,isSelected:u.entryIndex===i},u.entry.filePath))})}),E&&t.jsx(a,{flexShrink:0,marginLeft:1,marginRight:1,children:t.jsx(ie,{contentHeight:j,placement:"inset",scrollOffset:f,style:"block",viewportHeight:n})})]})]})},be=100,D=10,ke=6,Se=1,F={1:"all",2:"rewritten",3:"errors",4:"unchanged"},$e=({checkMode:e,store:r})=>{const{exit:s}=le(),{columns:l,rows:i}=ce(),o=v.useSyncExternalStore(r.subscribe,r.getSnapshot),n=v.useRef(null),d=r.getFilteredEntries(),g=d[o.selectedIndex]??null,m=X(o.entries),y=l>=be,h=Math.max(0,i-Se),w=y?h:Math.floor(h/2),p=Math.max(0,w-ke),S=v.useCallback(()=>{s()},[s]),j=v.useRef(0),$=v.useRef(void 0),f=v.useRef(!1),E=v.useCallback((u,x)=>{j.current+=x,$.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 ae((u,x)=>{if(u==="q"||x.escape){S();return}if(F[u]){r.setFilter(F[u]);return}if(x.tab){r.setFocusedPanel(o.focusedPanel==="list"?"detail":"list");return}o.focusedPanel==="list"?x.upArrow||u==="k"?E("list",-1):(x.downArrow||u==="j")&&E("list",1):o.focusedPanel==="detail"&&(x.upArrow||u==="k"?E("detail",-1):(x.downArrow||u==="j")&&E("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(ye,{counts:m,entries:d,filterType:o.filterType,focused:o.focusedPanel==="list",selectedIndex:o.selectedIndex,totalEntries:o.entries.length,viewportHeight:p})}),t.jsx(a,{flexBasis:"50%",flexGrow:1,flexShrink:1,children:t.jsx(he,{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"})})]})},B=["types","node-addons","node","import","require","default"],ve=/^git\+https:\/\/github\.com\/([^/]+)\/([^/.]+(?:\.git)?)$/,Ee=/^git\+ssh:\/\/git@github\.com\/([^/]+)\/([^/.]+(?:\.git)?)$/,C=e=>typeof e=="object"&&e!==null&&!Array.isArray(e),I=e=>{if(e===null||typeof e!="object")return e;if(Array.isArray(e))return e.map(s=>I(s));const r={};for(const[s,l]of Object.entries(e))r[s]=I(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}},Oe=e=>e.endsWith(".git")?e.slice(0,-4):e,Ce=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=ve.exec(s)??Ee.exec(s);if(!l)return{changed:!1,value:e};const i=l[1],o=Oe(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}`}},Re=e=>{const r=Object.keys(e),s=[],l=[];for(const n of B)Object.hasOwn(e,n)&&s.push(n);for(const n of r)B.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}},W=e=>{if(!C(e))return{changed:!1,value:e};let r=!1;const s={};for(const[i,o]of Object.entries(e)){const n=W(o);s[i]=n.value,n.changed&&(r=!0)}const l=Re(s);return{changed:r||l.changed,value:l.value}},Ie=(e,r)=>{const s=I(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=Ce(s.repository);i.changed&&(s.repository=i.value,l=!0)}if(r.sortExports!==!1&&Object.hasOwn(s,"exports")&&C(s.exports)){const i=W(s.exports);i.changed&&(s.exports=i.value,l=!0)}return{changed:l,pkg:s}},Te=/at position (\d+)/,Me=/\(?line (\d+) column (\d+)\)?/,Ne=e=>{const r=new Set,s=[],l=o=>{const n=V(o);!r.has(n)&&M(n)&&(r.add(n),s.push(n))};l(P(e,"package.json"));const i=te(e);if(i){const o=N(e,i);for(const n of o)l(P(e,n,"package.json"))}else{const o=P(e,"package.json");if(M(o)){const n=JSON.parse(L(o)),d=Array.isArray(n.workspaces)?n.workspaces:n.workspaces?.packages;if(d){const g=N(e,d);for(const m of g)l(P(e,m,"package.json"))}}}return s},Ae=e=>/\n([ \t]+)/.exec(e)?.[1]??" ",De=e=>{if(!(e===void 0||e===""))return e==="tab"||e===String.raw`\t`?" ":/^\d+$/.test(e)?" ".repeat(Number.parseInt(e,10)):e},R=e=>e===void 0?[]:(Array.isArray(e)?e:[e]).flatMap(r=>r.split(",")).map(r=>r.trim()).filter(r=>r.length>0),Fe=e=>e.includes(`\r
2
2
  `)?"crlf":"lf",Be=new Set(["auto","crlf","lf"]),Ge=e=>{if(e===void 0||e==="")return"auto";if(Be.has(e))return e;throw new Error(`--line-ending must be one of: auto, lf, crlf (got "${e}")`)},Je=(e,r,s)=>r.length===0?e:e.filter(l=>{const i=_(s,l),o=K(l);return!r.some(n=>{const d=n.includes("/")?i:o;return oe(n,d)})}),_e=(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},Le=(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},qe=(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}},G=(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},J=(e,r)=>{if(!(e instanceof Error))return;const s=Te.exec(e.message);if(s){const{column:i,line:o}=qe(r,Number.parseInt(s[1]??"0",10));return{column:i,line:o,snippet:G(r,o)}}const l=Me.exec(e.message);if(l){const i=Number.parseInt(l[1]??"1",10);return{column:Number.parseInt(l[2]??"1",10),line:i,snippet:G(r,i)}}},He=(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},Xe=(e,r,s)=>{const l=r.indent??s.indent??Ae(e),i=r.lineEnding==="auto"?s.lineEnding??Fe(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=Le(n,y,r.unsorted)}n=_e(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,9 +1,9 @@
1
- import{createRequire as q}from"node:module";import{DEFAULT_CHANGES_DIR as Z}from"./DEFAULT_CLEAN_KEEP.js";import{b as J,f as Q}from"./orchestrator.js";import{createShellRunner as X}from"./shell-runner.js";import{r as ee}from"../packem_shared/slug-DoueYuLo.js";import{maxBump as te}from"../release/types.js";const V=q(import.meta.url),P=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,U=s=>{if(typeof P<"u"&&P.versions&&P.versions.node){const[e,t]=P.versions.node.split(".").map(Number);if(e>22||e===22&&t>=3||e===20&&t>=16)return P.getBuiltinModule(s)}return V(s)},{join:M,relative:Y}=U("node:path"),D=/(?!.*)/;function re(s){return s.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function S(s){return s.map(e=>typeof e=="string"?re(e.trim()):e.source).filter(Boolean).join("|")}function ne(s,e){if(!s)return D;const t=S(s);return e?e(t):new RegExp(`^[\\s|*]*(${t})[:\\s]+(.*)`,"i")}function se(s,e){if(!s)return D;const t=e?"g":"gi";return new RegExp(`(?:.*?)??\\s*([\\w-\\.\\/]*?)??(${S(s)})([\\w-]+)(?=\\s|$|[,;)\\]])`,t)}function ie(s){if(!s)return/()(.+)/gi;const e=S(s);return new RegExp(`(${e})(?:\\s+(.*?))(?=(?:${e})|$)`,"gi")}function oe(s={}){const e=ne(s.noteKeywords,s.notesPattern),t=se(s.issuePrefixes,s.issuePrefixesCaseSensitive),r=ie(s.referenceActions);return{notes:e,referenceParts:t,references:r,mentions:/@([\w-]+)/g,url:/\b(?:https?):\/\/(?:www\.)?([-a-zA-Z0-9@:%_+.~#?&//=])+\b/}}const ce="------------------------ >8 ------------------------";function j(s){const e=s.match(/[^\r\n]/);if(typeof e?.index!="number")return"";const t=e.index;let r=s.length-1;for(;s[r]==="\r"||s[r]===`
1
+ import{createRequire as q}from"node:module";import{DEFAULT_CHANGES_DIR as Z}from"./DEFAULT_CLEAN_KEEP.js";import{b as J,f as Q}from"./orchestrator.js";import{createShellRunner as X}from"./shell-runner.js";import{r as ee}from"../packem_shared/slug-DoueYuLo.js";import{maxBump as te}from"../release/types.js";const V=q(import.meta.url),P=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,U=s=>{if(typeof P<"u"&&P.versions&&P.versions.node){const[e,t]=P.versions.node.split(".").map(Number);if(e>22||e===22&&t>=3||e===20&&t>=16)return P.getBuiltinModule(s)}return V(s)},{join:M,relative:Y}=U("node:path"),D=/(?!.*)/;function re(s){return s.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function _(s){return s.map(e=>typeof e=="string"?re(e.trim()):e.source).filter(Boolean).join("|")}function ne(s,e){if(!s)return D;const t=_(s);return e?e(t):new RegExp(`^[\\s|*]*(${t})[:\\s]+(.*)`,"i")}function se(s,e){if(!s)return D;const t=e?"g":"gi";return new RegExp(`(?:.*?)??\\s*([\\w-\\.\\/]*?)??(${_(s)})([\\w-]+)(?=\\s|$|[,;.)\\]])`,t)}function ie(s){if(!s)return/()(.+)/gi;const e=_(s);return new RegExp(`(${e})(?:\\s+(.*?))(?=(?:${e})|$)`,"gi")}function oe(s){const e=s?`|\\s+(?:${_(s)})`:"";return new RegExp(`^\\s*(?:BREAKING CHANGE|[\\w-]+)(?::\\s+${e}).+`,"i")}function ce(s={}){const e=ne(s.noteKeywords,s.notesPattern),t=se(s.issuePrefixes,s.issuePrefixesCaseSensitive),r=ie(s.referenceActions),n=oe(s.issuePrefixes);return{notes:e,referenceParts:t,references:r,footerToken:n,mentions:/@([\w-]+)/g,url:/\b(?:https?):\/\/(?:www\.)?([-a-zA-Z0-9@:%_+.~#?&//=])+\b/}}const ae="------------------------ >8 ------------------------";function j(s){const e=s.match(/[^\r\n]/);if(typeof e?.index!="number")return"";const t=e.index;let r=s.length-1;for(;s[r]==="\r"||s[r]===`
2
2
  `;)r--;return s.substring(t,r+1)}function A(s,e){return s?`${s}
3
- ${e||""}`:e||""}function ae(s){return s?e=>!e.startsWith(s):()=>!0}function le(s,e){const t=s.indexOf(`${e} ${ce}`);return t===-1?s:s.slice(0,t)}function I(s){return!s.match(/^\s*gpg:/)}function _(s,e,t){const{groups:r}=e;for(let n=0,i=t.length,c;n<i;n++)c=t[n],s[c]=(r?r[c]:e[n+1])||null;return s}const fe={noteKeywords:["BREAKING CHANGE","BREAKING-CHANGE"],issuePrefixes:["#"],referenceActions:["close","closes","closed","fix","fixes","fixed","resolve","resolves","resolved"],headerPattern:/^(\w*)(?:\(([\w$@.\-*/ ]*)\))?: (.*)$/,headerCorrespondence:["type","scope","subject"],revertPattern:/^Revert\s"([\s\S]*)"\s*This reverts commit (\w*)\.?/,revertCorrespondence:["header","hash"],fieldPattern:/^-(.*?)-$/};function T(s={}){return{merge:null,revert:null,header:null,body:null,footer:null,notes:[],mentions:[],references:[],...s}}class he{options;regexes;lines=[];lineIndex=0;commit=T();constructor(e={}){this.options={...fe,...e},this.regexes=oe(this.options)}currentLine(){return this.lines[this.lineIndex]}nextLine(){return this.lines[this.lineIndex++]}isLineAvailable(){return this.lineIndex<this.lines.length}parseReference(e,t){const{regexes:r}=this;if(r.url.test(e))return null;const n=r.referenceParts.exec(e);if(!n)return null;let[i,c=null,u,p]=n,x=null;if(c){const b=c.indexOf("/");b!==-1&&(x=c.slice(0,b),c=c.slice(b+1))}return{raw:i,action:t,owner:x,repository:c,prefix:u,issue:p}}parseReferences(e){const{regexes:t}=this,r=e.match(t.references)?t.references:/()(.+)/gi,n=[];let i,c,u,p;for(;i=r.exec(e),!!i;)for(c=i[1]||null,u=i[2]||"";p=this.parseReference(u,c),!!p;)n.push(p);return n}skipEmptyLines(){let e=this.currentLine();for(;e!==void 0&&!e.trim();)this.nextLine(),e=this.currentLine()}parseMerge(){const{commit:e,options:t}=this,r=t.mergeCorrespondence||[],n=this.currentLine(),i=n&&t.mergePattern?n.match(t.mergePattern):null;return i?(this.nextLine(),e.merge=i[0]||null,_(e,i,r),!0):!1}parseHeader(e){e&&this.skipEmptyLines();const{commit:t,options:r}=this,n=r.headerCorrespondence||[],i=t.header??this.nextLine();let c=null;i&&(r.breakingHeaderPattern&&(c=i.match(r.breakingHeaderPattern)),!c&&r.headerPattern&&(c=i.match(r.headerPattern))),i&&(t.header=i),c&&_(t,c,n)}parseMeta(){const{options:e,commit:t}=this;if(!e.fieldPattern||!this.isLineAvailable())return!1;let r,n=null,i=!1;for(;this.isLineAvailable();){if(r=this.currentLine().match(e.fieldPattern),r){n=r[1]||null,this.nextLine();continue}if(n)i=!0,t[n]=A(t[n],this.currentLine()),this.nextLine();else break}return i}parseNotes(){const{regexes:e,commit:t}=this;if(!this.isLineAvailable())return!1;const r=this.currentLine().match(e.notes);let n=[];if(r){const i={title:r[1],text:r[2]};for(t.notes.push(i),t.footer=A(t.footer,this.currentLine()),this.nextLine();this.isLineAvailable();){if(this.parseMeta()||this.parseNotes())return!0;if(n=this.parseReferences(this.currentLine()),n.length?t.references.push(...n):i.text=A(i.text,this.currentLine()),t.footer=A(t.footer,this.currentLine()),this.nextLine(),n.length)break}return!0}return!1}parseBodyAndFooter(e){const{commit:t}=this;if(!this.isLineAvailable())return e;const r=this.parseReferences(this.currentLine()),n=!r.length&&e;return n?t.body=A(t.body,this.currentLine()):(t.references.push(...r),t.footer=A(t.footer,this.currentLine())),this.nextLine(),n}parseBreakingHeader(){const{commit:e,options:t}=this;if(!t.breakingHeaderPattern||e.notes.length||!e.header)return;const r=e.header.match(t.breakingHeaderPattern);r&&e.notes.push({title:"BREAKING CHANGE",text:r[3]})}parseMentions(e){const{commit:t,regexes:r}=this;let n;for(;n=r.mentions.exec(e),!!n;)t.mentions.push(n[1])}parseRevert(e){const{commit:t,options:r}=this,n=r.revertCorrespondence||[],i=r.revertPattern?e.match(r.revertPattern):null;i&&(t.revert=_({},i,n))}cleanupCommit(){const{commit:e}=this;e.body&&(e.body=j(e.body)),e.footer&&(e.footer=j(e.footer)),e.notes.forEach(r=>{r.text=j(r.text)});const t=new Set;e.references=e.references.filter(r=>{const n=`${r.action} ${r.raw}`.toLocaleLowerCase(),i=!t.has(n);return i&&t.add(n),i})}parse(e){if(!e.trim())throw new TypeError("Expected a raw commit");const{commentChar:t}=this.options,r=ae(t),n=j(e).split(/\r?\n/),i=t?le(n,t).filter(x=>r(x)&&I(x)):n.filter(x=>I(x)),c=T();this.lines=i,this.lineIndex=0,this.commit=c;const u=this.parseMerge();this.parseHeader(u),c.header&&(c.references=this.parseReferences(c.header));let p=!0;for(;this.isLineAvailable();)this.parseMeta(),this.parseNotes()&&(p=!1),this.parseBodyAndFooter(p)||(p=!1);return this.parseBreakingHeader(),this.parseMentions(e),this.parseRevert(e),this.cleanupCommit(),c}}const N={build:"patch",chore:"patch",ci:"patch",docs:"patch",feat:"minor",fix:"patch",perf:"patch",refactor:"patch",style:"patch",test:"patch"},ue=new he,pe=/^Revert\s+"(.+)"\s*$/,de=/This reverts commit\s+([0-9a-f]{7,40})/i,me=/^(?:[\p{Emoji_Presentation}\p{Extended_Pictographic}]|:\w+:)\s+/u,ge=(s,e)=>{const t=s.replace(me,""),r=ue.parse(`${t}
3
+ ${e||""}`:e||""}function le(s){return s?e=>!e.startsWith(s):()=>!0}function fe(s,e){const t=s.indexOf(`${e} ${ae}`);return t===-1?s:s.slice(0,t)}function T(s){return!s.match(/^\s*gpg:/)}function S(s,e,t){const{groups:r}=e;for(let n=0,i=t.length,c;n<i;n++)c=t[n],s[c]=(r?r[c]:e[n+1])||null;return s}const ue={noteKeywords:["BREAKING CHANGE","BREAKING-CHANGE"],issuePrefixes:["#"],referenceActions:["close","closes","closed","fix","fixes","fixed","resolve","resolves","resolved"],headerPattern:/^(\w*)(?:\(([\w$@.\-*/ ]*)\))?: (.*)$/,headerCorrespondence:["type","scope","subject"],revertPattern:/^Revert\s"([\s\S]*)"\s*This reverts commit (\w*)\.?/,revertCorrespondence:["header","hash"],fieldPattern:/^-(.*?)-$/};function I(s={}){return{merge:null,revert:null,header:null,body:null,footer:null,notes:[],mentions:[],references:[],...s}}class he{options;regexes;lines=[];lineIndex=0;commit=I();constructor(e={}){this.options={...ue,...e},this.regexes=ce(this.options)}currentLine(){return this.lines[this.lineIndex]}nextLine(){return this.lines[this.lineIndex++]}isLineAvailable(){return this.lineIndex<this.lines.length}parseReference(e,t){const{regexes:r}=this;if(r.url.test(e))return null;const n=r.referenceParts.exec(e);if(!n)return null;let[i,c=null,h,p]=n,x=null;if(c){const b=c.indexOf("/");b!==-1&&(x=c.slice(0,b),c=c.slice(b+1))}return{raw:i,action:t,owner:x,repository:c,prefix:h,issue:p}}parseReferences(e){const{regexes:t}=this,r=e.match(t.references)?t.references:/()(.+)/gi,n=[];let i,c,h,p;for(;i=r.exec(e),!!i;)for(c=i[1]||null,h=i[2]||"";p=this.parseReference(h,c),!!p;)n.push(p);return n}skipEmptyLines(){let e=this.currentLine();for(;e!==void 0&&!e.trim();)this.nextLine(),e=this.currentLine()}parseMerge(){const{commit:e,options:t}=this,r=t.mergeCorrespondence||[],n=this.currentLine(),i=n&&t.mergePattern?n.match(t.mergePattern):null;return i?(this.nextLine(),e.merge=i[0]||null,S(e,i,r),!0):!1}parseHeader(e){e&&this.skipEmptyLines();const{commit:t,options:r}=this,n=r.headerCorrespondence||[],i=t.header??this.nextLine();let c=null;i&&(r.breakingHeaderPattern&&(c=i.match(r.breakingHeaderPattern)),!c&&r.headerPattern&&(c=i.match(r.headerPattern))),i&&(t.header=i),c&&S(t,c,n)}parseMeta(){const{options:e,commit:t}=this;if(!e.fieldPattern||!this.isLineAvailable())return!1;let r,n=null,i=!1;for(;this.isLineAvailable();){if(r=this.currentLine().match(e.fieldPattern),r){n=r[1]||null,this.nextLine();continue}if(n)i=!0,t[n]=A(t[n],this.currentLine()),this.nextLine();else break}return i}parseNotes(){const{regexes:e,commit:t}=this;if(!this.isLineAvailable())return!1;const r=this.currentLine().match(e.notes);let n;if(r){const i={title:r[1],text:r[2]};for(t.notes.push(i),t.footer=A(t.footer,this.currentLine()),this.nextLine();this.isLineAvailable();){if(this.parseMeta()||this.parseNotes())return!0;if(n=e.footerToken.test(this.currentLine()),t.references.push(...this.parseReferences(this.currentLine())),n||(i.text=A(i.text,this.currentLine())),t.footer=A(t.footer,this.currentLine()),this.nextLine(),n)break}return!0}return!1}parseBodyAndFooter(e){const{commit:t,regexes:r}=this;if(!this.isLineAvailable())return e;const n=!r.footerToken.test(this.currentLine())&&e;return t.references.push(...this.parseReferences(this.currentLine())),n?t.body=A(t.body,this.currentLine()):t.footer=A(t.footer,this.currentLine()),this.nextLine(),n}parseBreakingHeader(){const{commit:e,options:t}=this;if(!t.breakingHeaderPattern||e.notes.length||!e.header)return;const r=e.header.match(t.breakingHeaderPattern);r&&e.notes.push({title:"BREAKING CHANGE",text:r[3]})}parseMentions(e){const{commit:t,regexes:r}=this;let n;for(;n=r.mentions.exec(e),!!n;)t.mentions.push(n[1])}parseRevert(e){const{commit:t,options:r}=this,n=r.revertCorrespondence||[],i=r.revertPattern?e.match(r.revertPattern):null;i&&(t.revert=S({},i,n))}cleanupCommit(){const{commit:e}=this;e.body&&=j(e.body),e.footer&&=j(e.footer),e.notes.forEach(r=>{r.text=j(r.text)});const t=new Set;e.references=e.references.filter(r=>{const n=`${r.action} ${r.raw}`.toLocaleLowerCase(),i=!t.has(n);return i&&t.add(n),i})}parse(e){if(!e.trim())throw new TypeError("Expected a raw commit");const{commentChar:t}=this.options,r=le(t),n=j(e).split(/\r?\n/),i=t?fe(n,t).filter(x=>r(x)&&T(x)):n.filter(x=>T(x)),c=I();this.lines=i,this.lineIndex=0,this.commit=c;const h=this.parseMerge();this.parseHeader(h),c.header&&(c.references=this.parseReferences(c.header));let p=!0;for(;this.isLineAvailable();)this.parseMeta(),this.parseNotes()&&(p=!1),this.parseBodyAndFooter(p)||(p=!1);return this.parseBreakingHeader(),this.parseMentions(e),this.parseRevert(e),this.cleanupCommit(),c}}const N={build:"patch",chore:"patch",ci:"patch",docs:"patch",feat:"minor",fix:"patch",perf:"patch",refactor:"patch",style:"patch",test:"patch"},pe=new he,de=/^Revert\s+"(.+)"\s*$/,me=/This reverts commit\s+([0-9a-f]{7,40})/i,ge=/^(?:[\p{Emoji_Presentation}\p{Extended_Pictographic}]|:\w+:)\s+/u,xe=(s,e)=>{const t=s.replace(ge,""),r=pe.parse(`${t}
4
4
 
5
- ${e}`);return{breaking:r.notes.some(n=>/BREAKING/i.test(n.title)),scope:r.scope??void 0,type:r.type??void 0}},xe=(s,e,t)=>{let r,n=!1;if(t.type==="revert"){n=!0;const u=s.indexOf(":");u!==-1&&(r=s.slice(u+1).trim())}else{const u=pe.exec(s.trim());u&&(n=!0,r=u[1]?.trim())}let i;const c=de.exec(e);return c&&(i=c[1]?.toLowerCase()),{isRevert:n,targetSha:i,targetSubject:r}},ve=(s,e=new Set,t)=>{const r=s.map(o=>{const l=ge(o.subject,o.body),{isRevert:a,targetSha:f,targetSubject:d}=xe(o.subject,o.body,l);return{...o,cancelled:!1,parsed:l,revert:a,revertSubject:d,revertTargetSha:f}}),n=r.toReversed(),i=12,c=new Map;for(const o of n)if(c.set(o.hash,o),o.hash.length>=7){const l=Math.min(o.hash.length-1,i);for(let a=7;a<=l;a+=1){const f=o.hash.slice(0,a);if(c.has(f)){const d=c.get(f);d!==null&&d!==o&&c.set(f,null)}else c.set(f,o)}}const u=(o,l)=>{if(o.revertTargetSha){const a=o.revertTargetSha.toLowerCase();let f=c.get(a)??void 0;if(f||(f=n.find(d=>d.hash.startsWith(a))),f&&f!==o)return f}if(o.revertSubject)for(let a=l.length-1;a>=0;a-=1){const f=l[a];if(f.subject===o.revertSubject)return f}},p=64,x=o=>{let l=o;for(let a=0;a<p;a+=1){if(!l.revert)return l;const f=l.cancelledBy;let d;if(f&&(d=c.get(f)??void 0,d||(d=c.get(f.slice(0,7))??void 0)),!d||d===l)return l;l=d}},b=[],w=[];for(const o of n){if(o.revert){const l=u(o,w);if(l){if(e.has(l.hash)){w.push(o);continue}const a=x(l);if(a===void 0){b.push(`Revert chain at ${o.hash} exceeded depth limit (${p}) — skipping cancellation`),w.push(o);continue}if(e.has(a.hash)){w.push(o);continue}a.cancelled=!a.cancelled,a.cancelledBy=a.cancelled?o.hash:void 0,o.cancelled=!0,o.cancelledBy=l.hash}}w.push(o)}const L=r.filter(o=>!o.cancelled&&!o.revert&&!o.subject?.startsWith("Merge ")),C=L.filter(o=>!o.parsed.type);if(L.length>0&&C.length/L.length>.5){const o=t??"<from>..HEAD";b.push(`${C.length}/${L.length} commits in ${o} have no conventional-commits prefix. Consider enabling commit-message linting.`)}return{commits:r,warnings:b}},Ae=async({fs:s,logger:e,options:t,workspaceRoot:r})=>{const n=r??process.cwd(),i=await J({cwd:n,skipRegistryLookup:!0}),{printConfigIfRequested:c}=await import("./print-config.js");if(c(t,i,e))return;const u=X();let p=t.from;if(!p){const h=i.config.baseBranch??"main",m=await u.run("git",["merge-base",`origin/${h}`,"HEAD"],{cwd:n,silent:!0});if(m.exitCode===0&&m.stdout.trim())p=m.stdout.trim();else{const g=await u.run("git",["merge-base",h,"HEAD"],{cwd:n,silent:!0});p=g.exitCode===0?g.stdout.trim():"HEAD~10"}}const x=new Map;for(const h of i.packages){const m=(h.dir.startsWith(n)?h.dir.slice(n.length):h.dir).replaceAll("\\","/").replace(/^\/+/,"");x.set(m,h.name)}const b=h=>{for(const[m,g]of x)if(h.startsWith(`${m}/`)||h===`${m}/package.json`)return g},w=Math.random().toString(16).slice(2,10),L=`@@VIS_RELEASE_COMMIT_${w}@@`,C=`@@VIS_RELEASE_FILES_${w}@@`,o=await u.run("git",["log",`${p}..HEAD`,`--pretty=format:${L}%n%H%n%s%n%b%n${C}`,"--name-only"],{cwd:n,silent:!0});if(o.exitCode!==0){e.error(`git log failed: ${o.stderr}`),process.exitCode=1;return}const l=new Map,a=[],f=[],d=o.stdout.split(L).map(h=>h.trim()).filter(Boolean);for(const h of d){const[m,g=""]=h.split(C).toReversed(),E=g.split(`
6
- `),$=E[0]?.trim()??"",y=E[1]?.trim()??"",v=E.slice(2).join(`
5
+ ${e}`);return{breaking:r.notes.some(n=>/BREAKING/i.test(n.title)),scope:r.scope??void 0,type:r.type??void 0}},ve=(s,e,t)=>{let r,n=!1;if(t.type==="revert"){n=!0;const h=s.indexOf(":");h!==-1&&(r=s.slice(h+1).trim())}else{const h=de.exec(s.trim());h&&(n=!0,r=h[1]?.trim())}let i;const c=me.exec(e);return c&&(i=c[1]?.toLowerCase()),{isRevert:n,targetSha:i,targetSubject:r}},be=(s,e=new Set,t)=>{const r=s.map(o=>{const l=xe(o.subject,o.body),{isRevert:a,targetSha:f,targetSubject:d}=ve(o.subject,o.body,l);return{...o,cancelled:!1,parsed:l,revert:a,revertSubject:d,revertTargetSha:f}}),n=r.toReversed(),i=12,c=new Map;for(const o of n)if(c.set(o.hash,o),o.hash.length>=7){const l=Math.min(o.hash.length-1,i);for(let a=7;a<=l;a+=1){const f=o.hash.slice(0,a);if(c.has(f)){const d=c.get(f);d!==null&&d!==o&&c.set(f,null)}else c.set(f,o)}}const h=(o,l)=>{if(o.revertTargetSha){const a=o.revertTargetSha.toLowerCase();let f=c.get(a)??void 0;if(f||(f=n.find(d=>d.hash.startsWith(a))),f&&f!==o)return f}if(o.revertSubject)for(let a=l.length-1;a>=0;a-=1){const f=l[a];if(f.subject===o.revertSubject)return f}},p=64,x=o=>{let l=o;for(let a=0;a<p;a+=1){if(!l.revert)return l;const f=l.cancelledBy;let d;if(f&&(d=c.get(f)??void 0,d||(d=c.get(f.slice(0,7))??void 0)),!d||d===l)return l;l=d}},b=[],w=[];for(const o of n){if(o.revert){const l=h(o,w);if(l){if(e.has(l.hash)){w.push(o);continue}const a=x(l);if(a===void 0){b.push(`Revert chain at ${o.hash} exceeded depth limit (${p}) — skipping cancellation`),w.push(o);continue}if(e.has(a.hash)){w.push(o);continue}a.cancelled=!a.cancelled,a.cancelledBy=a.cancelled?o.hash:void 0,o.cancelled=!0,o.cancelledBy=l.hash}}w.push(o)}const L=r.filter(o=>!o.cancelled&&!o.revert&&!o.subject?.startsWith("Merge ")),E=L.filter(o=>!o.parsed.type);if(L.length>0&&E.length/L.length>.5){const o=t??"<from>..HEAD";b.push(`${E.length}/${L.length} commits in ${o} have no conventional-commits prefix. Consider enabling commit-message linting.`)}return{commits:r,warnings:b}},Ee=async({fs:s,logger:e,options:t,workspaceRoot:r})=>{const n=r??process.cwd(),i=await J({cwd:n,skipRegistryLookup:!0}),{printConfigIfRequested:c}=await import("./print-config.js");if(c(t,i,e))return;const h=X();let p=t.from;if(!p){const u=i.config.baseBranch??"main",m=await h.run("git",["merge-base",`origin/${u}`,"HEAD"],{cwd:n,silent:!0});if(m.exitCode===0&&m.stdout.trim())p=m.stdout.trim();else{const g=await h.run("git",["merge-base",u,"HEAD"],{cwd:n,silent:!0});p=g.exitCode===0?g.stdout.trim():"HEAD~10"}}const x=new Map;for(const u of i.packages){const m=(u.dir.startsWith(n)?u.dir.slice(n.length):u.dir).replaceAll("\\","/").replace(/^\/+/,"");x.set(m,u.name)}const b=u=>{for(const[m,g]of x)if(u.startsWith(`${m}/`)||u===`${m}/package.json`)return g},w=Math.random().toString(16).slice(2,10),L=`@@VIS_RELEASE_COMMIT_${w}@@`,E=`@@VIS_RELEASE_FILES_${w}@@`,o=await h.run("git",["log",`${p}..HEAD`,`--pretty=format:${L}%n%H%n%s%n%b%n${E}`,"--name-only"],{cwd:n,silent:!0});if(o.exitCode!==0){e.error(`git log failed: ${o.stderr}`),process.exitCode=1;return}const l=new Map,a=[],f=[],d=o.stdout.split(L).map(u=>u.trim()).filter(Boolean);for(const u of d){const[m,g=""]=u.split(E).toReversed(),C=g.split(`
6
+ `),$=C[0]?.trim()??"",y=C[1]?.trim()??"",v=C.slice(2).join(`
7
7
  `).trim(),R=(m??"").split(`
8
- `).map(z=>z.trim()).filter(Boolean);$&&f.push({body:v,files:R,hash:$,subject:y})}const{commits:F,warnings:G}=ve(f,void 0,`${p}..HEAD`);for(const h of G)e.warn(h);for(const{cancelled:h,files:m,parsed:g,subject:E}of F){if(h)continue;let $="patch";g.breaking?$="major":g.type&&N[g.type]&&($=N[g.type]??"patch");const y=new Set;if(g.scope)for(const v of i.packages)(v.name===g.scope||v.name.endsWith(`/${g.scope}`))&&y.add(v.name);if(y.size===0)for(const v of m){const R=b(v);R&&y.add(R)}for(const v of y){const R=l.get(v);l.set(v,R?te(R,$):$)}y.size>0&&a.push(`- ${E}`)}if(l.size===0){e.info("No commits affected workspace packages — nothing to generate.");return}const O={bumps:Object.fromEntries(l)},K=a.length>0?a.join(`
9
- `):"Auto-generated change file.",k=Q(O,K);if(t.dryRun){e.info("[dry-run] would write:"),e.info(k);return}const B=i.config.changesDir??Z,W=(t.name??ee()).replaceAll(/[^a-z0-9-]/gi,"-"),H=M(n,B,`${W}.md`);await s.mkdir(M(n,B),{recursive:!0}),await s.writeFile(H,k),e.info(`Created ${Y(n,H)}`);for(const[h,m]of l)e.info(` ${h}: ${m}`)};export{Ae as default};
8
+ `).map(z=>z.trim()).filter(Boolean);$&&f.push({body:v,files:R,hash:$,subject:y})}const{commits:G,warnings:F}=be(f,void 0,`${p}..HEAD`);for(const u of F)e.warn(u);for(const{cancelled:u,files:m,parsed:g,subject:C}of G){if(u)continue;let $="patch";g.breaking?$="major":g.type&&N[g.type]&&($=N[g.type]??"patch");const y=new Set;if(g.scope)for(const v of i.packages)(v.name===g.scope||v.name.endsWith(`/${g.scope}`))&&y.add(v.name);if(y.size===0)for(const v of m){const R=b(v);R&&y.add(R)}for(const v of y){const R=l.get(v);l.set(v,R?te(R,$):$)}y.size>0&&a.push(`- ${C}`)}if(l.size===0){e.info("No commits affected workspace packages — nothing to generate.");return}const O={bumps:Object.fromEntries(l)},K=a.length>0?a.join(`
9
+ `):"Auto-generated change file.",k=Q(O,K);if(t.dryRun){e.info("[dry-run] would write:"),e.info(k);return}const B=i.config.changesDir??Z,W=(t.name??ee()).replaceAll(/[^a-z0-9-]/gi,"-"),H=M(n,B,`${W}.md`);await s.mkdir(M(n,B),{recursive:!0}),await s.writeFile(H,k),e.info(`Created ${Y(n,H)}`);for(const[u,m]of l)e.info(` ${u}: ${m}`)};export{Ee as default};
@@ -1,2 +1,2 @@
1
- import{createRequire as H}from"node:module";import{I as W}from"../packem_shared/index-B0EsgdzO.js";import{p as q}from"../packem_shared/prompt-DjXHVgYU.js";import{f as Y,m as X,a as J,T as U}from"../packem_shared/index-CE6MsgcV.js";import{f as D,A as Q,C as Z,r as ee,_ as te,i as A}from"../packem_shared/env-DdQRnEIy.js";import{a as se}from"../packem_shared/readJsonSync-DuMMeB3s-ihoybKvs.js";import{g as re,r as oe}from"../packem_shared/packument-aGzYwXKn.js";import{q as ne,j as ie,E as $,s as k,V as C,I as x}from"../packem_shared/index.server-J83sowC4.js";import{h as ae,W as ce}from"../packem_shared/pm-runner-CQcraCcu.js";import{r as le,a as fe}from"../packem_shared/command-runtime-3FTGuUsK.js";const L=H(import.meta.url),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 L(e)},{renameSync:F}=G("node:fs"),{stripVTControlCharacters:P}=G("node:util"),pe=(e={})=>{const t=e.isCi??W;return(e.isTty??!!(process.stdin.isTTY&&process.stdout.isTTY))&&!t},w=X(D(),"dlx-seen.json"),V=(e,t)=>`${e}@${t}`,ue=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"},B=()=>{try{if(Y(w)){const e=se(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))ue(r)&&(t[s]=r);return{packages:t,version:1}}}}catch{}return{packages:{},version:1}},ge=e=>{try{J(D());const t=`${w}.${String(process.pid)}.tmp`;U(t,JSON.stringify(e)),F(t,w)}catch{}},me=(e,t,s)=>e.packages[V(t,s)],de=(e,t)=>{if(!e)return!0;const s=new Set(Array.isArray(e.alertKeys)?e.alertKeys:[]);return t.some(r=>!s.has(r))},E=(e,t,s,r)=>{const o=B();o.packages[V(e,t)]={alertKeys:[...s].sort(),seenAt:r},ge(o)},he=/[\u0000-\u0008\u000B-\u001F\u007F]/g,z=e=>P(e).replaceAll(" "," ").replaceAll(he,""),_=["CHANGELOG.md","CHANGELOG","changelog.md","CHANGES.md","HISTORY.md"],ye=4e3,R=async(e,t,s)=>{if(t?.aborted)return;const r=new AbortController,o=setTimeout(()=>{r.abort()},ye),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)}},$e=e=>{const t=typeof e=="string"?e:e?.url;if(!t)return;const s=/github\.com[/:]([^/]+)\/([^/#]+?)(?:\.git)?(?:[/#]|$)/i.exec(t)??/^github:([^/]+)\/([^/#]+)/i.exec(t);return s?{directory:typeof e=="object"?e?.directory:void 0,owner:s[1],repo:s[2].replace(/\.git$/,"")}:void 0},I=(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},O=(e,t=4)=>e.map(s=>s.trim()).filter(s=>s.length>0).map(s=>z(s.replace(/^#{1,6}\s+/,"").replace(/^[*-]\s+/,"- ")).trim()).filter(s=>s.length>0&&!/^\[.*\]:/.test(s)).slice(0,t),j=(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=j(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} (${j(c,s)})`);return{lines:a,source:"npm-diff",version:t}},ve=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 _){const l=`https://cdn.jsdelivr.net/npm/${t}@${i}/${c}`,f=await R(l,a);if(f){const d=I(f,i),p=O(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=$e(u?.repository);if(n){const c=n.directory?`${n.directory.replaceAll(/^\/+|\/+$/g,"")}/`:"";for(const l of["HEAD","main","master"])for(const f of _){const d=`https://raw.githubusercontent.com/${n.owner}/${n.repo}/${l}/${c}${f}`,p=await R(d,a);if(p){const h=I(p,i),m=O(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)},ke={dynamicRequire:"dynamic require",envVars:"env access",filesystemAccess:"filesystem",networkAccess:"network",shellAccess:"shell",telemetry:"telemetry",unsafe:"eval/unsafe",usesEval:"eval/unsafe"},be=["preinstall","install","postinstall"],we=(e,t)=>({fileCount:e?.dist?.fileCount,tarballBytes:t?.size,unpackedBytes:e?.dist?.unpackedSize}),Se=(e,t)=>{const s=be.filter(i=>!!e?.scripts?.[i]),r=e?.bin,o=typeof r=="string"?["(default)"]:Object.keys(r??{}).map(i=>z(i)),a=[...new Set(t.map(i=>ke[i.type]).filter(i=>i!==void 0))];return{bins:o,capabilities:a,lifecycleScripts:s}},Te=(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},Ce=async e=>{const{name:t,now:s,offline:r,signal:o,socketToken:a,spec:i,workspaceRoot:u}=e;let n;try{n=await re(t,{offline:r,signal:o,workspaceRoot:u})}catch{n=void 0}const c=n?oe(n,i):void 0;if(!c)return;const l=n?.versions[c],f=async()=>{if(!(r||!a))try{const y=await Z([{name:t,version:c}],{apiToken:a});return Te(y,t,c)}catch{return}},d=ve({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??Q(p.score))*100):void 0;return{changelog:h,name:t,permissions:Se(l,m),security:{alerts:m,available:!!p,highSeverityKeys:g,score:S},size:we(l,p),version:c}},b=e=>ee(P(e)),Ae={critical:C,high:C,low:$,medium:k},K=e=>{if(!(e===void 0||e<0))return te(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?x: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(Ae[l](`${String(f)} ${l}`))}const c=u.length>0?` ${k("!")} ${u.join(", ")}`:` ${x("no alerts")}`;return`${o(a)} ${$("(Socket.dev)")}${c}`},_e=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=_e(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?ne(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=`┌─${ie(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)}},je=e=>e===""||e.startsWith(".")||e.startsWith("/")||e.startsWith("~")?!1:!(e.startsWith("@")?e.slice(1):e).includes(":"),Ne=6e3,Ke=e=>{process.stdout.write(e)},Me=async e=>{const{forceInfo:t=!1,noInfo:s=!1,offline:r=!1,pkg:o,socketToken:a,workspaceRoot:i,yes:u=!1}=e;if(s||!je(o))return{proceed:!0};const n=e.now??Date.now(),c=u||!pe({isCi:e.isCi,isTty:e.isTty}),l=e.output??Ke;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)},Ne)}),g=await Promise.race([Ce({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=me(B(),g.name,g.version);if(!t&&!de(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-B0EsgdzO.js";import{p as q}from"../packem_shared/prompt-DjXHVgYU.js";import{f as Y,m as X,a as J,T as U}from"../packem_shared/index-BVuCxe14.js";import{f as D,A as Q,C as Z,r as ee,_ as te,i as A}from"../packem_shared/env-Cpxa_7UE.js";import{a as se}from"../packem_shared/readJsonSync-DuMMeB3s-Cx08VBQg.js";import{g as re,r as oe}from"../packem_shared/packument-CYxvm590.js";import{q as ne,j as ie,E as $,s as k,V as C,I as x}from"../packem_shared/index.server-J83sowC4.js";import{h as ae,W as ce}from"../packem_shared/pm-runner-mVFjedM6.js";import{r as le,a as fe}from"../packem_shared/command-runtime-EWjmSxPj.js";const L=H(import.meta.url),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 L(e)},{renameSync:F}=G("node:fs"),{stripVTControlCharacters:P}=G("node:util"),pe=(e={})=>{const t=e.isCi??W;return(e.isTty??!!(process.stdin.isTTY&&process.stdout.isTTY))&&!t},w=X(D(),"dlx-seen.json"),V=(e,t)=>`${e}@${t}`,ue=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"},B=()=>{try{if(Y(w)){const e=se(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))ue(r)&&(t[s]=r);return{packages:t,version:1}}}}catch{}return{packages:{},version:1}},ge=e=>{try{J(D());const t=`${w}.${String(process.pid)}.tmp`;U(t,JSON.stringify(e)),F(t,w)}catch{}},me=(e,t,s)=>e.packages[V(t,s)],de=(e,t)=>{if(!e)return!0;const s=new Set(Array.isArray(e.alertKeys)?e.alertKeys:[]);return t.some(r=>!s.has(r))},E=(e,t,s,r)=>{const o=B();o.packages[V(e,t)]={alertKeys:[...s].sort(),seenAt:r},ge(o)},he=/[\u0000-\u0008\u000B-\u001F\u007F]/g,z=e=>P(e).replaceAll(" "," ").replaceAll(he,""),_=["CHANGELOG.md","CHANGELOG","changelog.md","CHANGES.md","HISTORY.md"],ye=4e3,R=async(e,t,s)=>{if(t?.aborted)return;const r=new AbortController,o=setTimeout(()=>{r.abort()},ye),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)}},$e=e=>{const t=typeof e=="string"?e:e?.url;if(!t)return;const s=/github\.com[/:]([^/]+)\/([^/#]+?)(?:\.git)?(?:[/#]|$)/i.exec(t)??/^github:([^/]+)\/([^/#]+)/i.exec(t);return s?{directory:typeof e=="object"?e?.directory:void 0,owner:s[1],repo:s[2].replace(/\.git$/,"")}:void 0},I=(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},O=(e,t=4)=>e.map(s=>s.trim()).filter(s=>s.length>0).map(s=>z(s.replace(/^#{1,6}\s+/,"").replace(/^[*-]\s+/,"- ")).trim()).filter(s=>s.length>0&&!/^\[.*\]:/.test(s)).slice(0,t),j=(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=j(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} (${j(c,s)})`);return{lines:a,source:"npm-diff",version:t}},ve=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 _){const l=`https://cdn.jsdelivr.net/npm/${t}@${i}/${c}`,f=await R(l,a);if(f){const d=I(f,i),p=O(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=$e(u?.repository);if(n){const c=n.directory?`${n.directory.replaceAll(/^\/+|\/+$/g,"")}/`:"";for(const l of["HEAD","main","master"])for(const f of _){const d=`https://raw.githubusercontent.com/${n.owner}/${n.repo}/${l}/${c}${f}`,p=await R(d,a);if(p){const h=I(p,i),m=O(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)},ke={dynamicRequire:"dynamic require",envVars:"env access",filesystemAccess:"filesystem",networkAccess:"network",shellAccess:"shell",telemetry:"telemetry",unsafe:"eval/unsafe",usesEval:"eval/unsafe"},be=["preinstall","install","postinstall"],we=(e,t)=>({fileCount:e?.dist?.fileCount,tarballBytes:t?.size,unpackedBytes:e?.dist?.unpackedSize}),Se=(e,t)=>{const s=be.filter(i=>!!e?.scripts?.[i]),r=e?.bin,o=typeof r=="string"?["(default)"]:Object.keys(r??{}).map(i=>z(i)),a=[...new Set(t.map(i=>ke[i.type]).filter(i=>i!==void 0))];return{bins:o,capabilities:a,lifecycleScripts:s}},Te=(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},Ce=async e=>{const{name:t,now:s,offline:r,signal:o,socketToken:a,spec:i,workspaceRoot:u}=e;let n;try{n=await re(t,{offline:r,signal:o,workspaceRoot:u})}catch{n=void 0}const c=n?oe(n,i):void 0;if(!c)return;const l=n?.versions[c],f=async()=>{if(!(r||!a))try{const y=await Z([{name:t,version:c}],{apiToken:a});return Te(y,t,c)}catch{return}},d=ve({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??Q(p.score))*100):void 0;return{changelog:h,name:t,permissions:Se(l,m),security:{alerts:m,available:!!p,highSeverityKeys:g,score:S},size:we(l,p),version:c}},b=e=>ee(P(e)),Ae={critical:C,high:C,low:$,medium:k},K=e=>{if(!(e===void 0||e<0))return te(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?x: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(Ae[l](`${String(f)} ${l}`))}const c=u.length>0?` ${k("!")} ${u.join(", ")}`:` ${x("no alerts")}`;return`${o(a)} ${$("(Socket.dev)")}${c}`},_e=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=_e(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?ne(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=`┌─${ie(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)}},je=e=>e===""||e.startsWith(".")||e.startsWith("/")||e.startsWith("~")?!1:!(e.startsWith("@")?e.slice(1):e).includes(":"),Ne=6e3,Ke=e=>{process.stdout.write(e)},Me=async e=>{const{forceInfo:t=!1,noInfo:s=!1,offline:r=!1,pkg:o,socketToken:a,workspaceRoot:i,yes:u=!1}=e;if(s||!je(o))return{proceed:!0};const n=e.now??Date.now(),c=u||!pe({isCi:e.isCi,isTty:e.isTty}),l=e.output??Ke;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)},Ne)}),g=await Promise.race([Ce({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=me(B(),g.name,g.version);if(!t&&!de(S,g.security.highSeverityKeys))return{proceed:!0};for(const T of Ie(g))l(`${T}
2
2
  `);if(c)return E(g.name,g.version,g.security.highSeverityKeys,n),{proceed:!0};const y=await q("? Ok to proceed? (y/N) ",e.readline);return y&&E(g.name,g.version,g.security.highSeverityKeys,n),{proceed:y}},Fe=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 Me({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=le({logger:t,options:s,visConfig:r},n),d=ae(n,{backend:fe(f),configBackend:r?.install?.backend,configCorepack:r?.install?.corepack}),p=ce(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{Fe as default};
@@ -1,4 +1,4 @@
1
- import{createRequire as ce}from"node:module";import{m as O,v as D,f as z,T as A,B as ae}from"../packem_shared/index-CE6MsgcV.js";import{v as le,m as t,n as m,i as a,r as _,$ as de,d as pe,e as fe,W as J}from"./catalog.js";import"../packem_shared/env-DdQRnEIy.js";import{I as me}from"../packem_shared/index-B0EsgdzO.js";import he 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 Q}from"../packem_shared/index-Cg0IHaFI.js";import{J as xe,_ as ye,K as je,I as ke,y as ve,Q as we,p as y}from"./cli-main.js";import"../packem_shared/public-api-WqUCiyIe.js";import{u as be}from"./ts-loader.js";import{A as $e,y as Ce}from"../packem_shared/pm-runner-CQcraCcu.js";import{a as Z}from"../packem_shared/readJsonSync-DuMMeB3s-ihoybKvs.js";import{s as Se}from"../packem_shared/glob-fqg4KepW-1S3z30c8.js";import __cjs_mod__ from "node:module"; // -- packem CommonJS require shim --
1
+ import{createRequire as ce}from"node:module";import{m as O,v as D,f as z,T as A,B as ae}from"../packem_shared/index-BVuCxe14.js";import{v as le,m as t,n as m,i as a,r as _,$ as de,d as pe,e as fe,W as J}from"./catalog.js";import"../packem_shared/env-Cpxa_7UE.js";import{I as me}from"../packem_shared/index-B0EsgdzO.js";import he 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 Q}from"../packem_shared/index-BAUIIRZJ.js";import{J as xe,_ as ye,K as je,I as ke,y as ve,Q as we,p as y}from"./cli-main.js";import"../packem_shared/public-api-WqUCiyIe.js";import{u as be}from"./ts-loader.js";import{A as $e,y as Ce}from"../packem_shared/pm-runner-mVFjedM6.js";import{a as Z}from"../packem_shared/readJsonSync-DuMMeB3s-Cx08VBQg.js";import{s as Se}from"../packem_shared/glob-DMbPwGSj-uzODoE-1.js";import __cjs_mod__ from "node:module"; // -- packem CommonJS require shim --
2
2
  const require = __cjs_mod__.createRequire(import.meta.url);
3
3
  const or=ce(import.meta.url),nr=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process;const Oe=["dependencies","devDependencies","peerDependencies","peerDependenciesMeta","optionalDependencies","bundleDependencies"],Ne=["overrides","pnpm","resolutions"],Ee=["engines","files"],Te=r=>{const e=Q.coerce(r)?.major;return e!==void 0&&e>=10},Pe=r=>{const e=O(r,"pnpm-workspace.yaml");if(!z(e))return{overrides:{},source:"pnpm-workspace.yaml"};try{return{overrides:be(e)?.overrides??{},source:"pnpm-workspace.yaml"}}catch{return{overrides:{},source:"pnpm-workspace.yaml"}}},_e=(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"&&Te(o.version)?Pe(r):_e(e,o.name),H=(r,e)=>{const o=e;for(const c of Ne){const i=r.indexOf(c);if(i!==-1&&c!==o)return o==="overrides"?i:i+1}let n=-1;for(const c of Oe){const i=r.indexOf(c);i>n&&(n=i)}if(n!==-1)return n+1;for(const c of Ee){const i=r.indexOf(c);if(i!==-1)return i}return r.length},De=(r,e)=>{const o=O(r,"pnpm-workspace.yaml");if(!z(o))throw new Error(`pnpm-workspace.yaml not found at ${o}. Cannot write overrides for pnpm v10+.`);let n=D(o);const c=`overrides:
4
4
  ${Object.entries(e).map(([i,l])=>` '${i}': '${l}'`).join(`
@@ -1,4 +1,4 @@
1
- import{createRequire as X}from"node:module";import{I as w,j as P,E as u,q as T,s as v,V as D}from"../packem_shared/index.server-J83sowC4.js";import{m as j,f as A,v as ee,T as te,O as R,y as $}from"../packem_shared/index-CE6MsgcV.js";import H from"./index.js";import{V as oe,U as C,g as se,a1 as ne,a2 as ae,a3 as re,a4 as ie}from"./cli-main.js";import{e as pe,W as B,l as I,a as L,U,R as ce}from"./catalog.js";import{a as S}from"../packem_shared/readJsonSync-DuMMeB3s-ihoybKvs.js";import{l as fe}from"../packem_shared/missing-package-json-CTF71tE5.js";const Y=X(import.meta.url),V=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,Z=e=>{if(typeof V<"u"&&V.versions&&V.versions.node){const[a,o]=V.versions.node.split(".").map(Number);if(a>22||a===22&&o>=3||a===20&&o>=16)return V.getBuiltinModule(e)}return Y(e)},{readFileSync:K,writeFileSync:z}=Z("node:fs"),le=e=>/[*?[\]{}!]/.test(e),ge=e=>typeof e=="string"?e:e.reason,de=e=>typeof e=="string"?void 0:e.replacement,q=(e,a)=>e.some(o=>H(o,a)),G=(e,a)=>{if(typeof e=="string")return!0;const o=Array.isArray(e.packages)&&e.packages.length>0,t=Array.isArray(e.paths)&&e.paths.length>0;return!!(!o&&!t||o&&a.packageName!==void 0&&q(e.packages,a.packageName)||t&&q(e.paths,a.packageDir))},ue=(e,a)=>{const o=a[e.depName];if(o!==void 0&&G(o,e))return{pattern:e.depName,rule:o};for(const[t,r]of Object.entries(a))if(le(t)&&H(t,e.depName)&&G(r,e))return{pattern:t,rule:r}},me=(e,a)=>{if(Object.keys(a).length===0)return[];const o=[];for(const t of e){if(t.isInternal)continue;const r=ue(t,a);r&&o.push({depName:t.depName,depType:t.depType,matchedPattern:r.pattern,packageDir:t.packageDir,packageJsonPath:t.packageJsonPath,packageName:t.packageName,reason:ge(r.rule),replacement:de(r.rule),specifier:t.specifier})}return o},he=new Set(["dependencies","devDependencies","peerDependencies"]),ke=e=>e.startsWith("catalog:"),ye=e=>e.startsWith("workspace:"),$e=(e,a)=>{if(!e)return!1;for(const o of e.values())if(o.has(a))return!0;return!1},Pe=(e,a={})=>{const o=a.min??3,t=new Set(a.ignoreDeps),r=e.filter(i=>i.isInternal||!he.has(i.depType)||ye(i.specifier)||a.dep!==void 0&&i.depName!==a.dep?!1:!t.has(i.depName)),n=new Map;for(const i of r){const p=n.get(i.depName);p?p.push(i):n.set(i.depName,[i])}const s=[];for(const[i,p]of n){if($e(a.catalogs,i)||p.some(m=>ke(m.specifier)))continue;const c=new Map;for(const m of p){let d=c.get(m.specifier);d||(d=new Set,c.set(m.specifier,d)),d.add(m.packageJsonPath)}const f=[...c.entries()].sort((m,d)=>m[1].size!==d[1].size?d[1].size-m[1].size:m[0].localeCompare(d[0]))[0];!f||f[1].size<o||s.push({catalogName:"default",depName:i,instanceCount:f[1].size,specifier:f[0]})}return s.sort((i,p)=>i.depName.localeCompare(p.depName))},we=(e,a)=>{if(a.length===0)return;const o=j(e,"pnpm-workspace.yaml"),t=A(o)?K(o,"utf8"):"",r=t.includes(`\r
1
+ import{createRequire as X}from"node:module";import{I as w,j as P,E as u,q as T,s as v,V as D}from"../packem_shared/index.server-J83sowC4.js";import{m as j,f as A,v as ee,T as te,O as R,y as $}from"../packem_shared/index-BVuCxe14.js";import H from"./index.js";import{V as oe,U as C,g as se,a1 as ne,a2 as ae,a3 as re,a4 as ie}from"./cli-main.js";import{e as pe,W as B,l as I,a as L,U,R as ce}from"./catalog.js";import{a as S}from"../packem_shared/readJsonSync-DuMMeB3s-Cx08VBQg.js";import{l as fe}from"../packem_shared/missing-package-json-_hOp4AW5.js";const Y=X(import.meta.url),V=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,Z=e=>{if(typeof V<"u"&&V.versions&&V.versions.node){const[a,o]=V.versions.node.split(".").map(Number);if(a>22||a===22&&o>=3||a===20&&o>=16)return V.getBuiltinModule(e)}return Y(e)},{readFileSync:K,writeFileSync:z}=Z("node:fs"),le=e=>/[*?[\]{}!]/.test(e),ge=e=>typeof e=="string"?e:e.reason,de=e=>typeof e=="string"?void 0:e.replacement,q=(e,a)=>e.some(o=>H(o,a)),G=(e,a)=>{if(typeof e=="string")return!0;const o=Array.isArray(e.packages)&&e.packages.length>0,t=Array.isArray(e.paths)&&e.paths.length>0;return!!(!o&&!t||o&&a.packageName!==void 0&&q(e.packages,a.packageName)||t&&q(e.paths,a.packageDir))},ue=(e,a)=>{const o=a[e.depName];if(o!==void 0&&G(o,e))return{pattern:e.depName,rule:o};for(const[t,r]of Object.entries(a))if(le(t)&&H(t,e.depName)&&G(r,e))return{pattern:t,rule:r}},me=(e,a)=>{if(Object.keys(a).length===0)return[];const o=[];for(const t of e){if(t.isInternal)continue;const r=ue(t,a);r&&o.push({depName:t.depName,depType:t.depType,matchedPattern:r.pattern,packageDir:t.packageDir,packageJsonPath:t.packageJsonPath,packageName:t.packageName,reason:ge(r.rule),replacement:de(r.rule),specifier:t.specifier})}return o},he=new Set(["dependencies","devDependencies","peerDependencies"]),ke=e=>e.startsWith("catalog:"),ye=e=>e.startsWith("workspace:"),$e=(e,a)=>{if(!e)return!1;for(const o of e.values())if(o.has(a))return!0;return!1},Pe=(e,a={})=>{const o=a.min??3,t=new Set(a.ignoreDeps),r=e.filter(i=>i.isInternal||!he.has(i.depType)||ye(i.specifier)||a.dep!==void 0&&i.depName!==a.dep?!1:!t.has(i.depName)),n=new Map;for(const i of r){const p=n.get(i.depName);p?p.push(i):n.set(i.depName,[i])}const s=[];for(const[i,p]of n){if($e(a.catalogs,i)||p.some(m=>ke(m.specifier)))continue;const c=new Map;for(const m of p){let d=c.get(m.specifier);d||(d=new Set,c.set(m.specifier,d)),d.add(m.packageJsonPath)}const f=[...c.entries()].sort((m,d)=>m[1].size!==d[1].size?d[1].size-m[1].size:m[0].localeCompare(d[0]))[0];!f||f[1].size<o||s.push({catalogName:"default",depName:i,instanceCount:f[1].size,specifier:f[0]})}return s.sort((i,p)=>i.depName.localeCompare(p.depName))},we=(e,a)=>{if(a.length===0)return;const o=j(e,"pnpm-workspace.yaml"),t=A(o)?K(o,"utf8"):"",r=t.includes(`\r
2
2
  `)?`\r
3
3
  `:`
4
4
  `,n=a.filter(d=>d.catalogName==="default").sort((d,g)=>d.depName.localeCompare(g.depName));if(n.length===0)return;const s=t.length>0?t.split(r):[],i=s.findIndex(d=>/^catalog\s*:\s*$/.test(d));if(i===-1){const d=["catalog:"];for(const y of n)d.push(` ${y.depName}: "${y.specifier}"`);let g=0;for(;g<s.length&&(s[g]??"").trim().length===0;)g+=1;const h=[...s.slice(0,g),...d,"",...s.slice(g)].join(r);return z(o,h.endsWith(r)?h:`${h}${r}`),o}let p=s.length;const c=new Set;for(let d=i+1;d<s.length;d+=1){const g=s[d]??"",h=g.trimStart();if(g.length===0)continue;if(g.length-h.length===0&&h.length>0&&!h.startsWith("#")){p=d;break}const y=/^([\w./@-]+)\s*:/.exec(h);y?.[1]&&c.add(y[1])}const f=[];for(const d of n)c.has(d.depName)||f.push(` ${d.depName}: "${d.specifier}"`);if(f.length===0)return;const m=[...s.slice(0,p),...f,...s.slice(p)].join(r);return z(o,m.endsWith(r)?m:`${m}${r}`),o},De=(e,a)=>{if(a.length===0)return"";const o=j(e,"pnpm-workspace.yaml"),t=A(o)?K(o,"utf8"):"",r=[...a].sort((i,p)=>i.depName.localeCompare(p.depName)),n=["--- pnpm-workspace.yaml","+++ pnpm-workspace.yaml"],s=t.includes(`\r