@visulima/vis 6.1.0 → 6.1.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 (175) hide show
  1. package/CHANGELOG.md +49 -0
  2. package/dist/bin.js +1 -1
  3. package/dist/binx.js +1 -1
  4. package/dist/config/index.d.ts +1226 -1216
  5. package/dist/packem_chunks/bloom-sync.js +1 -1
  6. package/dist/packem_chunks/cargo-lock.js +5 -0
  7. package/dist/packem_chunks/cargo-plan.js +3 -3
  8. package/dist/packem_chunks/catalog-detector.js +1 -1
  9. package/dist/packem_chunks/catalog.js +1 -94
  10. package/dist/packem_chunks/catalog2.js +11 -0
  11. package/dist/packem_chunks/cli-exec.js +1 -1
  12. package/dist/packem_chunks/cli-main.js +156 -174
  13. package/dist/packem_chunks/context.js +8 -0
  14. package/dist/packem_chunks/fix.js +1 -1
  15. package/dist/packem_chunks/handler10.js +1 -1
  16. package/dist/packem_chunks/handler12.js +1 -1
  17. package/dist/packem_chunks/handler13.js +1 -1
  18. package/dist/packem_chunks/handler14.js +1 -1
  19. package/dist/packem_chunks/handler15.js +1 -1
  20. package/dist/packem_chunks/handler19.js +5 -5
  21. package/dist/packem_chunks/handler2.js +1 -1
  22. package/dist/packem_chunks/handler20.js +1 -1
  23. package/dist/packem_chunks/handler21.js +1 -1
  24. package/dist/packem_chunks/handler23.js +1 -1
  25. package/dist/packem_chunks/handler24.js +1 -1
  26. package/dist/packem_chunks/handler25.js +1 -1
  27. package/dist/packem_chunks/handler28.js +1 -1
  28. package/dist/packem_chunks/handler3.js +1 -1
  29. package/dist/packem_chunks/handler31.js +1 -1
  30. package/dist/packem_chunks/handler32.js +1 -1
  31. package/dist/packem_chunks/handler33.js +1 -1
  32. package/dist/packem_chunks/handler34.js +3 -3
  33. package/dist/packem_chunks/handler35.js +1 -1
  34. package/dist/packem_chunks/handler36.js +1 -1
  35. package/dist/packem_chunks/handler38.js +2 -2
  36. package/dist/packem_chunks/handler39.js +5 -5
  37. package/dist/packem_chunks/handler4.js +4 -4
  38. package/dist/packem_chunks/handler40.js +1 -1
  39. package/dist/packem_chunks/handler41.js +1 -1
  40. package/dist/packem_chunks/handler42.js +1 -1
  41. package/dist/packem_chunks/handler43.js +1 -1
  42. package/dist/packem_chunks/handler44.js +1 -1
  43. package/dist/packem_chunks/handler45.js +1 -1
  44. package/dist/packem_chunks/handler46.js +1 -1
  45. package/dist/packem_chunks/handler47.js +1 -1
  46. package/dist/packem_chunks/handler48.js +1 -1
  47. package/dist/packem_chunks/handler49.js +1 -1
  48. package/dist/packem_chunks/handler5.js +4 -4
  49. package/dist/packem_chunks/handler50.js +5 -5
  50. package/dist/packem_chunks/handler52.js +1 -1
  51. package/dist/packem_chunks/handler54.js +2 -2
  52. package/dist/packem_chunks/handler55.js +1 -1
  53. package/dist/packem_chunks/handler56.js +3 -3
  54. package/dist/packem_chunks/handler57.js +4 -4
  55. package/dist/packem_chunks/handler58.js +4 -4
  56. package/dist/packem_chunks/handler59.js +2 -2
  57. package/dist/packem_chunks/handler6.js +7 -7
  58. package/dist/packem_chunks/handler60.js +1 -1
  59. package/dist/packem_chunks/handler61.js +2 -2
  60. package/dist/packem_chunks/handler62.js +1 -1
  61. package/dist/packem_chunks/handler63.js +3 -3
  62. package/dist/packem_chunks/handler64.js +3 -3
  63. package/dist/packem_chunks/handler65.js +2 -2
  64. package/dist/packem_chunks/handler66.js +2 -2
  65. package/dist/packem_chunks/handler67.js +5 -5
  66. package/dist/packem_chunks/handler68.js +12 -25
  67. package/dist/packem_chunks/handler69.js +25 -22
  68. package/dist/packem_chunks/handler70.js +22 -10
  69. package/dist/packem_chunks/handler71.js +10 -133
  70. package/dist/packem_chunks/handler72.js +133 -23
  71. package/dist/packem_chunks/handler73.js +23 -323
  72. package/dist/packem_chunks/handler74.js +274 -659
  73. package/dist/packem_chunks/handler75.js +708 -48
  74. package/dist/packem_chunks/handler76.js +48 -27
  75. package/dist/packem_chunks/handler77.js +27 -3
  76. package/dist/packem_chunks/handler78.js +3 -191
  77. package/dist/packem_chunks/handler79.js +191 -0
  78. package/dist/packem_chunks/handler8.js +1 -1
  79. package/dist/packem_chunks/heal.js +2 -2
  80. package/dist/packem_chunks/help-command.js +1 -1
  81. package/dist/packem_chunks/index2.js +3 -58
  82. package/dist/packem_chunks/index3.js +40 -3
  83. package/dist/packem_chunks/index6.js +135 -7
  84. package/dist/packem_chunks/index7.js +7 -135
  85. package/dist/packem_chunks/keys-refresh.js +1 -1
  86. package/dist/packem_chunks/list.js +2 -2
  87. package/dist/packem_chunks/prune.js +1 -1
  88. package/dist/packem_chunks/python-plan.js +3 -3
  89. package/dist/packem_chunks/python-projects.js +1 -1
  90. package/dist/packem_chunks/python.js +1 -0
  91. package/dist/packem_chunks/run.js +1 -1
  92. package/dist/packem_chunks/snapshot.js +2 -2
  93. package/dist/packem_chunks/state.js +2 -2
  94. package/dist/packem_chunks/status.js +1 -1
  95. package/dist/packem_chunks/sync.js +1 -1
  96. package/dist/packem_chunks/verify-lockfile.js +1 -1
  97. package/dist/packem_chunks/version-resolver.js +1 -1
  98. package/dist/packem_chunks/workspace.js +2 -2
  99. package/dist/packem_shared/ReleaseClient-CWD9BC5w.js +1 -0
  100. package/dist/packem_shared/advisories-DO-P0V1_.js +1 -0
  101. package/dist/packem_shared/{affected-selection-DGb6Xu5K.js → affected-selection-CeeZo7Uy.js} +1 -1
  102. package/dist/packem_shared/{ai-analysis-pldoS_N4.js → ai-analysis-BCJ1kuDM.js} +3 -3
  103. package/dist/packem_shared/ai-cache-iSIyY3So.js +1 -0
  104. package/dist/packem_shared/{ai-fix-D9MxigBQ.js → ai-fix-DIMErSws.js} +6 -6
  105. package/dist/packem_shared/apply-DoeQAAGm.js +6 -0
  106. package/dist/packem_shared/apply-release-plan-BalHtK-g.js +15 -0
  107. package/dist/packem_shared/{bin-AZQv95jh.js → bin-BcLTer1k.js} +1 -1
  108. package/dist/packem_shared/clean-package-json-rutwkKl-.js +1 -0
  109. package/dist/packem_shared/createAdapter-DMK4bBET.js +1 -0
  110. package/dist/packem_shared/createVersionActions-DXo4z8VN.js +1 -0
  111. package/dist/packem_shared/dependency-scan-D_v3KM59.js +1 -0
  112. package/dist/packem_shared/{ecosystem-gate-DiqQj0LJ.js → ecosystem-gate-CwsTc7YW.js} +1 -1
  113. package/dist/packem_shared/env-BSXG3QKH.js +4 -0
  114. package/dist/packem_shared/failure-log-DIsKBKaI.js +2 -0
  115. package/dist/packem_shared/formatBytes-_HvjOy8a-iHCer6uX.js +1 -0
  116. package/dist/packem_shared/glob-Cyk1H9ZL-CL9optrn.js +1 -0
  117. package/dist/packem_shared/{index-JRb5wabN.js → index-9Ot7jTd4.js} +1 -1
  118. package/dist/packem_shared/index-BS6A9QR_.js +1 -0
  119. package/dist/packem_shared/lifecycle-CQjeMPY0.js +2 -0
  120. package/dist/packem_shared/missing-package-json-1BIoWQq0.js +1 -0
  121. package/dist/packem_shared/multi-eco-lockfiles-fgkpeHJv.js +1 -0
  122. package/dist/packem_shared/npmrc-CHsOyMvA.js +2 -0
  123. package/dist/packem_shared/osv-Do9PMOea.js +1 -0
  124. package/dist/packem_shared/{package-version-KLwH0Ivy.js → package-version-Bq6Cne_7.js} +1 -1
  125. package/dist/packem_shared/packument-CbTmbHU4.js +1 -0
  126. package/dist/packem_shared/{project-name-filter-B1ZCsbOW.js → project-name-filter-ZQaLgytG.js} +1 -1
  127. package/dist/packem_shared/{provenance-L1M2FPy_.js → provenance-SX1MxPUZ.js} +1 -1
  128. package/dist/packem_shared/publish-Dc0XGH3K.js +34 -0
  129. package/dist/packem_shared/registry-Dg9XI6RT.js +81 -0
  130. package/dist/packem_shared/registry-keys-z038Ecb4.js +1 -0
  131. package/dist/packem_shared/removeSync-g1D5kONg-LbjATA8v.js +1 -0
  132. package/dist/packem_shared/renderToString-DR0zDUjh-DXppT6AM.js +3 -0
  133. package/dist/packem_shared/{resolve-explicit-CQa37JSq.js → resolve-explicit-D9kdTNvl.js} +1 -1
  134. package/dist/packem_shared/{run-D-uVGHQ4.js → run-DLvd3RIZ.js} +1 -1
  135. package/dist/packem_shared/run-summary-utils-CMeURYtS.js +1 -0
  136. package/dist/packem_shared/s1ngularity-BuU9Cxpy.js +1 -0
  137. package/dist/packem_shared/{scaffold-files-DVyfB0yz.js → scaffold-files-DJlz36Mu.js} +1 -1
  138. package/dist/packem_shared/scan-progress-DymX71_5.js +2 -0
  139. package/dist/packem_shared/{signatures-DIqFUOfs.js → signatures-CeL0bOEo.js} +1 -1
  140. package/dist/packem_shared/spinner-CPoBymcv.js +1 -0
  141. package/dist/packem_shared/table-oA7p7-yP.js +1 -0
  142. package/dist/packem_shared/tabs-BiSifphV.js +1 -0
  143. package/dist/packem_shared/{task-env-DzR4RkOj.js → task-env-C2lmxvzA.js} +1 -1
  144. package/dist/packem_shared/typosquats-BFKus_aM.js +1 -0
  145. package/dist/packem_shared/use-measured-height-BHm-HiSF.js +1 -0
  146. package/dist/packem_shared/vis-update-app-6QOYxnNx.js +1 -0
  147. package/dist/packem_shared/{vis-user-error-CRmrBaD1.js → vis-user-error-3YS7sPYy.js} +1 -1
  148. package/dist/packem_shared/{watch-loop-D1_e-qIl.js → watch-loop-CGi66Fs0.js} +1 -1
  149. package/dist/packem_shared/xxh3-BLHlvhgT.js +1 -0
  150. package/dist/release/core/package-managers/index.js +1 -1
  151. package/dist/release/core/version-actions/index.js +1 -1
  152. package/dist/release/index.js +1 -1
  153. package/index.js +26 -26
  154. package/package.json +9 -9
  155. package/dist/packem_chunks/orchestrator.js +0 -46
  156. package/dist/packem_shared/ReleaseClient-DAvbxCdo.js +0 -1
  157. package/dist/packem_shared/createAdapter-F7GidOzU.js +0 -1
  158. package/dist/packem_shared/createVersionActions-ByaJ1Nbv.js +0 -1
  159. package/dist/packem_shared/dependency-scan-CawAKoU_.js +0 -1
  160. package/dist/packem_shared/failure-log-BP-gCUb5.js +0 -2
  161. package/dist/packem_shared/formatBytes-_HvjOy8a-B_qQr4Hw.js +0 -4
  162. package/dist/packem_shared/glob-Cyk1H9ZL-Dxlf9Swz.js +0 -1
  163. package/dist/packem_shared/index-CDHP1kby.js +0 -1
  164. package/dist/packem_shared/lifecycle-DvmDIRbb.js +0 -2
  165. package/dist/packem_shared/missing-package-json-Cu5YVAot.js +0 -1
  166. package/dist/packem_shared/multi-eco-lockfiles-B2X3yhyo.js +0 -1
  167. package/dist/packem_shared/packument-zb18Jnlw.js +0 -1
  168. package/dist/packem_shared/registry-keys-DxdqMzyp.js +0 -1
  169. package/dist/packem_shared/s1ngularity-CO5GkkqX.js +0 -1
  170. package/dist/packem_shared/scan-progress-RwCRxJdX.js +0 -2
  171. package/dist/packem_shared/spinner-BJjbNl1F.js +0 -1
  172. package/dist/packem_shared/tabs--uxJGL8N.js +0 -1
  173. package/dist/packem_shared/typosquats-D4DEHhFy.js +0 -1
  174. package/dist/packem_shared/use-measured-height-DUZyyias.js +0 -1
  175. package/dist/packem_shared/vis-update-app-9b2kSk9f.js +0 -1
@@ -1,11 +1,11 @@
1
- import{createRequire as S}from"node:module";import{b as I}from"./orchestrator.js";let U;const j=e=>(U??=S(import.meta.url))(e),w=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,C=e=>{if(typeof w<"u"&&w.versions&&w.versions.node){const[t,r]=w.versions.node.split(".").map(Number);if(t>22||t===22&&r>=3||t===20&&r>=16)return w.getBuiltinModule(e)}return j(e)},{mkdtemp:F,writeFile:_,rm:D,readdir:M,readFile:N}=C("node:fs/promises"),{tmpdir:A}=C("node:os"),{join:g}=C("node:path"),O="https://www.npmjs.com",P=(e,t)=>t&&!/registry\.npmjs\.org/.test(t)?void 0:`${O}/package/${encodeURIComponent(e)}/access`,q=e=>`# ${e}
1
+ import{createRequire as S}from"node:module";import{b as A}from"./context.js";let U;const j=e=>(U??=S(import.meta.url))(e),w=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,C=e=>{if(typeof w<"u"&&w.versions&&w.versions.node){const[t,r]=w.versions.node.split(".").map(Number);if(t>22||t===22&&r>=3||t===20&&r>=16)return w.getBuiltinModule(e)}return j(e)},{mkdtemp:I,writeFile:_,rm:F,readdir:D,readFile:M}=C("node:fs/promises"),{tmpdir:N}=C("node:os"),{join:g}=C("node:path"),O="https://www.npmjs.com",P=(e,t)=>t&&!/registry\.npmjs\.org/.test(t)?void 0:`${O}/package/${encodeURIComponent(e)}/access`,q=e=>`# ${e}
2
2
 
3
3
  > ⚠️ **Placeholder package — do not use.**
4
4
 
5
5
  This version contains **no code** and is **not functional**. It was published by [\`vis release pretrust\`](https://visulima.com/packages/vis) only to register the package name on the registry so that **npm Trusted Publishing (OIDC)** can be configured before the first real release.
6
6
 
7
7
  Do **not** add this as a dependency. A functional version will replace it when the package is first released.
8
- `,B=(e,t,r,a)=>{const i={description:"Placeholder published by `vis release pretrust` to enable npm trusted publishing (OIDC). Not functional — do not use.",files:["README.md"],license:typeof e.manifest.license=="string"?e.manifest.license:"MIT",name:t,publishConfig:{access:a},version:r};return e.manifest.repository!==void 0&&(i.repository=e.manifest.repository),i},L=(e,t)=>{const r=["trust",t.provider,e,"--file",t.workflow];return t.repo&&r.push(t.provider==="gitlab"?"--project":"--repo",t.repo),t.env&&r.push("--env",t.env),r.push("--allow-publish"),t.allowStagePublish&&r.push("--allow-stage-publish"),r.push("-y"),r},T=(e,t)=>{if(e.includes("gitlab"))return{provider:"gitlab",repo:t};if(e.includes("github"))return{provider:"github",repo:t}},W=e=>{const t=e.trim().replace(/\.git$/,"");if(t.startsWith("ssh://"))try{const a=new URL(t);return T(a.hostname,a.pathname.replace(/^\/+/,""))}catch{return}const r=/(?:https?:\/\/|git@)([^/:]+)[/:](\S+)/.exec(t);if(r)return T(r[1]??"",r[2]??"")},H=async(e,t)=>{try{const r=await e.run("git",["config","--get","remote.origin.url"],{cwd:t,silent:!0});return r.exitCode!==0?void 0:W(r.stdout.trim())}catch{return}},z=async(e,t)=>{if(t==="gitlab")return".gitlab-ci.yml";const r=g(e,".github","workflows");let a;try{a=await M(r)}catch{return}const i=a.filter(u=>/\.ya?ml$/.test(u)),c=[];for(const u of i)try{const h=await N(g(r,u),"utf8");/vis\s+release/.test(h)&&/publish/.test(h)&&c.push(u)}catch{}if(c.length===1)return c[0];if(c.length>1)return;const l=i.filter(u=>/release/i.test(u));return l.length===1?l[0]:void 0},G=async(e,t,r,a,i)=>{const c=L(r,a);i&&c.push("--registry",i);try{const l=await e.run("npm",c,{cwd:t,silent:!0});return l.exitCode===0?{trusted:!0}:{reason:`${l.stdout}
9
- ${l.stderr}`.trim()||`npm trust exited ${l.exitCode}`,trusted:!1}}catch(l){return{reason:l.message,trusted:!1}}},J=async(e,t,r,a)=>{const i=["view",t,"version","--silent"];a&&i.push("--registry",a);try{const c=await e.run("npm",i,{cwd:r,silent:!0});return c.exitCode===0&&c.stdout.trim().length>0}catch{return!1}},Y=async e=>{const{context:t,dryRun:r=!1,force:a=!1,registry:i}=e,c=e.access??"public",l=e.tag??"placeholder",u=e.version??"0.0.0",{createShellRunner:h}=await import("./shell-runner.js"),o=e.runner??h();let m=t.packages.filter(n=>!n.private);if(e.filter){const{default:n}=await import("./index.js"),d=e.filter.split(",").map(f=>f.trim()).filter(Boolean);m=m.filter(f=>d.some(b=>f.name===b||n(b,f.name)))}const v=[],s=[],R=[],E=e.trust!==!1&&!r;let x,y;if(E){const n=e.provider&&e.repo?{provider:e.provider,repo:e.repo}:await H(o,t.cwd),d=e.provider??n?.provider;if(d){const f=e.workflow??await z(t.cwd,d);f?x={allowStagePublish:e.allowStagePublish,env:e.env,provider:d,repo:e.repo??n?.repo,workflow:f}:y="could not find a release workflow file (pass --workflow)"}else y="could not detect a github/gitlab remote (pass --provider + --repo)"}for(const n of m){if(!a&&await J(o,n.name,t.cwd,i)){s.push({name:n.name,reason:"already-on-registry"});continue}if(r){v.push({accessUrl:P(n.name,i),name:n.name,version:u});continue}let d;try{d=await F(g(A(),"vis-pretrust-"));const f=B(n,n.name,u,c);await _(g(d,"package.json"),`${JSON.stringify(f,null,2)}
8
+ `,B=(e,t,r,a)=>{const i={description:"Placeholder published by `vis release pretrust` to enable npm trusted publishing (OIDC). Not functional — do not use.",files:["README.md"],license:typeof e.manifest.license=="string"?e.manifest.license:"MIT",name:t,publishConfig:{access:a},version:r};return e.manifest.repository!==void 0&&(i.repository=e.manifest.repository),i},L=(e,t)=>{const r=["trust",t.provider,e,"--file",t.workflow];return t.repo&&r.push(t.provider==="gitlab"?"--project":"--repo",t.repo),t.env&&r.push("--env",t.env),r.push("--allow-publish"),t.allowStagePublish&&r.push("--allow-stage-publish"),r.push("-y"),r},T=(e,t)=>{if(e.includes("gitlab"))return{provider:"gitlab",repo:t};if(e.includes("github"))return{provider:"github",repo:t}},W=e=>{const t=e.trim().replace(/\.git$/,"");if(t.startsWith("ssh://"))try{const a=new URL(t);return T(a.hostname,a.pathname.replace(/^\/+/,""))}catch{return}const r=/(?:https?:\/\/|git@)([^/:]+)[/:](\S+)/.exec(t);if(r)return T(r[1]??"",r[2]??"")},H=async(e,t)=>{try{const r=await e.run("git",["config","--get","remote.origin.url"],{cwd:t,silent:!0});return r.exitCode!==0?void 0:W(r.stdout.trim())}catch{return}},z=async(e,t)=>{if(t==="gitlab")return".gitlab-ci.yml";const r=g(e,".github","workflows");let a;try{a=await D(r)}catch{return}const i=a.filter(u=>/\.ya?ml$/.test(u)),c=[];for(const u of i)try{const h=await M(g(r,u),"utf8");/vis\s+release/.test(h)&&/publish/.test(h)&&c.push(u)}catch{}if(c.length===1)return c[0];if(c.length>1)return;const l=i.filter(u=>/release/i.test(u));return l.length===1?l[0]:void 0},G=async(e,t,r,a,i)=>{const c=L(r,a);i&&c.push("--registry",i);try{const l=await e.run("npm",c,{cwd:t,silent:!0});return l.exitCode===0?{trusted:!0}:{reason:`${l.stdout}
9
+ ${l.stderr}`.trim()||`npm trust exited ${l.exitCode}`,trusted:!1}}catch(l){return{reason:l.message,trusted:!1}}},J=async(e,t,r,a)=>{const i=["view",t,"version","--silent"];a&&i.push("--registry",a);try{const c=await e.run("npm",i,{cwd:r,silent:!0});return c.exitCode===0&&c.stdout.trim().length>0}catch{return!1}},Y=async e=>{const{context:t,dryRun:r=!1,force:a=!1,registry:i}=e,c=e.access??"public",l=e.tag??"placeholder",u=e.version??"0.0.0",{createShellRunner:h}=await import("./shell-runner.js"),o=e.runner??h();let m=t.packages.filter(n=>!n.private);if(e.filter){const{default:n}=await import("./index.js"),d=e.filter.split(",").map(f=>f.trim()).filter(Boolean);m=m.filter(f=>d.some(b=>f.name===b||n(b,f.name)))}const v=[],s=[],R=[],E=e.trust!==!1&&!r;let x,y;if(E){const n=e.provider&&e.repo?{provider:e.provider,repo:e.repo}:await H(o,t.cwd),d=e.provider??n?.provider;if(d){const f=e.workflow??await z(t.cwd,d);f?x={allowStagePublish:e.allowStagePublish,env:e.env,provider:d,repo:e.repo??n?.repo,workflow:f}:y="could not find a release workflow file (pass --workflow)"}else y="could not detect a github/gitlab remote (pass --provider + --repo)"}for(const n of m){if(!a&&await J(o,n.name,t.cwd,i)){s.push({name:n.name,reason:"already-on-registry"});continue}if(r){v.push({accessUrl:P(n.name,i),name:n.name,version:u});continue}let d;try{d=await I(g(N(),"vis-pretrust-"));const f=B(n,n.name,u,c);await _(g(d,"package.json"),`${JSON.stringify(f,null,2)}
10
10
  `),await _(g(d,"README.md"),q(n.name));const b=["publish","--tag",l,"--access",c];i&&b.push("--registry",i);const $=await o.run("npm",b,{cwd:d,silent:!0});if($.exitCode===0){const p={accessUrl:P(n.name,i),name:n.name,version:u};if(x){const k=await G(o,t.cwd,n.name,x,i);p.trusted=k.trusted,k.trusted||(p.trustReason=k.reason)}else y&&(p.trusted=!1,p.trustReason=y);v.push(p)}else{const p=`${$.stdout}
11
- ${$.stderr}`;/EPUBLISHCONFLICT|cannot publish over|previously published/i.test(p)?s.push({name:n.name,reason:"already-on-registry"}):R.push({name:n.name,reason:p.trim()||`npm publish exited ${$.exitCode}`})}}catch(f){R.push({name:n.name,reason:f.message})}finally{d&&await D(d,{force:!0,recursive:!0}).catch(()=>{})}}return{failed:R,published:v,skipped:s}},V=async({logger:e,options:t,workspaceRoot:r})=>{const a=r??process.cwd(),i=t.dryRun===!0;if(t.access!==void 0&&t.access!=="public"&&t.access!=="restricted"){e.error(`Invalid --access value: "${t.access}". Expected "public" or "restricted".`),process.exitCode=1;return}if(t.provider!==void 0&&t.provider!=="github"&&t.provider!=="gitlab"){e.error(`Invalid --provider value: "${t.provider}". Expected "github" or "gitlab".`),process.exitCode=1;return}const c=t.access??"public",{provider:l}=t,u=await I({cwd:a}),{printConfigIfRequested:h}=await import("./print-config.js");if(h(t,u,e))return;let o;try{o=await Y({access:c,allowStagePublish:t.allowStagePublish===!0,context:u,dryRun:i,env:t.env,filter:t.filter,force:t.force===!0,provider:l,registry:t.registry,repo:t.repo,tag:t.tag,trust:t.trust,version:t.version,workflow:t.workflow})}catch(s){e.error(`Pretrust failed: ${s.message}`),process.exitCode=1;return}for(const s of o.published)e.info(` ${i?"[dry-run] ":"[published]"} ${s.name}@${s.version}`),!i&&(s.trusted===!0?e.info(" ✓ trusted publisher configured (npm trust)"):s.trustReason?(e.warn(` ⚠ trust not configured: ${s.trustReason}`),s.accessUrl&&e.info(` finish manually → ${s.accessUrl}`)):s.accessUrl&&e.info(` configure trusted publishing → ${s.accessUrl}`));for(const s of o.skipped)e.info(` [skipped] ${s.name} (${s.reason})`);for(const s of o.failed)e.error(` [failed] ${s.name}: ${s.reason}`);const m=o.published.filter(s=>s.trusted===!0).length,v=o.published.filter(s=>s.trusted===!1).length;e.info(""),e.info(`Placeholders: ${o.published.length} | Trusted: ${m} | Skipped: ${o.skipped.length} | Failed: ${o.failed.length}`),o.published.length>0&&!i&&(e.info(""),v>0?e.info("Next: finish trusted-publisher setup for the packages above (the first `npm trust` call may need a 2FA OTP), then run `vis release publish`."):e.info("Next: run `vis release publish` — trusted publishing is configured.")),process.exitCode=o.failed.length>0?2:0};export{V as default};
11
+ ${$.stderr}`;/EPUBLISHCONFLICT|cannot publish over|previously published/i.test(p)?s.push({name:n.name,reason:"already-on-registry"}):R.push({name:n.name,reason:p.trim()||`npm publish exited ${$.exitCode}`})}}catch(f){R.push({name:n.name,reason:f.message})}finally{d&&await F(d,{force:!0,recursive:!0}).catch(()=>{})}}return{failed:R,published:v,skipped:s}},V=async({logger:e,options:t,workspaceRoot:r})=>{const a=r??process.cwd(),i=t.dryRun===!0;if(t.access!==void 0&&t.access!=="public"&&t.access!=="restricted"){e.error(`Invalid --access value: "${t.access}". Expected "public" or "restricted".`),process.exitCode=1;return}if(t.provider!==void 0&&t.provider!=="github"&&t.provider!=="gitlab"){e.error(`Invalid --provider value: "${t.provider}". Expected "github" or "gitlab".`),process.exitCode=1;return}const c=t.access??"public",{provider:l}=t,u=await A({cwd:a}),{printConfigIfRequested:h}=await import("./print-config.js");if(h(t,u,e))return;let o;try{o=await Y({access:c,allowStagePublish:t.allowStagePublish===!0,context:u,dryRun:i,env:t.env,filter:t.filter,force:t.force===!0,provider:l,registry:t.registry,repo:t.repo,tag:t.tag,trust:t.trust,version:t.version,workflow:t.workflow})}catch(s){e.error(`Pretrust failed: ${s.message}`),process.exitCode=1;return}for(const s of o.published)e.info(` ${i?"[dry-run] ":"[published]"} ${s.name}@${s.version}`),!i&&(s.trusted===!0?e.info(" ✓ trusted publisher configured (npm trust)"):s.trustReason?(e.warn(` ⚠ trust not configured: ${s.trustReason}`),s.accessUrl&&e.info(` finish manually → ${s.accessUrl}`)):s.accessUrl&&e.info(` configure trusted publishing → ${s.accessUrl}`));for(const s of o.skipped)e.info(` [skipped] ${s.name} (${s.reason})`);for(const s of o.failed)e.error(` [failed] ${s.name}: ${s.reason}`);const m=o.published.filter(s=>s.trusted===!0).length,v=o.published.filter(s=>s.trusted===!1).length;e.info(""),e.info(`Placeholders: ${o.published.length} | Trusted: ${m} | Skipped: ${o.skipped.length} | Failed: ${o.failed.length}`),o.published.length>0&&!i&&(e.info(""),v>0?e.info("Next: finish trusted-publisher setup for the packages above (the first `npm trust` call may need a 2FA OTP), then run `vis release publish`."):e.info("Next: run `vis release publish` — trusted publishing is configured.")),process.exitCode=o.failed.length>0?2:0};export{V as default};
@@ -1,5 +1,5 @@
1
- import{createRequire as G}from"node:module";import{y as N,z as q,A as z,B as f,D as J,E as W,F as Y,G as H,H as Q,I as V,J as U,K as X,L as Z,M as tt,N as nt,P as et,Q as P,R as st}from"./cli-main.js";import{e as p,z as j,$ as rt}from"../packem_shared/index-BzhrR_iC.js";import{l as ct}from"./ts-loader.js";import{loadVisConfig as at}from"./CONFIG_FILES.js";import{y as x}from"../packem_shared/isAccessibleSync-DYKTrrvc-C-_5cgwu.js";import{U as O}from"../packem_shared/writeFileSync-DJoHk3Ks-BPRoepNw.js";import{L as dt}from"./catalog.js";import{v as pt}from"../packem_shared/verify-B_MblU_Q.js";let K;const L=t=>(K??=G(import.meta.url))(t),E=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,B=t=>{if(typeof E<"u"&&E.versions&&E.versions.node){const[n,s]=E.versions.node.split(".").map(Number);if(n>22||n===22&&s>=3||n===20&&s>=16)return E.getBuiltinModule(t)}return L(t)},{readdirSync:it,statSync:ot}=B("node:fs"),{stdin:T,stdout:ut}=E,{createInterface:ft}=B("node:readline/promises"),k="__global__",b=t=>[...new Set(t)].sort((n,s)=>n.localeCompare(s)),mt=t=>`{${Object.keys(t).sort().map(i=>`${i}=${JSON.stringify(t[i])}`).join(",")}}`,h=t=>{if(!Array.isArray(t))return[];const n=[];for(const s of t)typeof s=="string"?n.push(s):s&&typeof s=="object"&&n.push(mt(s));return b(n)},v=t=>({cache:void 0,dependsOn:[],env:[],id:t,inputs:[],outputs:[]}),g=(t,n,s)=>s?`^${n}`:t&&t!=="self"&&t!=="~"?`${t}#${n}`:n,lt=(t,n)=>{const s=t.trim();if(n==="moon"){if(s.startsWith("^:"))return g(void 0,s.slice(2),!0);if(s.startsWith("~:"))return g(void 0,s.slice(2),!1);if(s.includes(":")){const[i,e]=s.split(":");return g(i,e??"",!1)}return s}if(s.startsWith("^"))return g(void 0,s.slice(1),!0);if(s.includes("#")){const[i,e]=s.split("#");return g(i,e??"",!1)}return s},R=(t,n)=>{if(!Array.isArray(t))return[];const s=[];for(const i of t){if(typeof i=="string"){s.push(lt(i,n));continue}if(!i||typeof i!="object")continue;const e=i,{target:o}=e;if(!o)continue;if(e.dependencies===!0){s.push(g(void 0,o,!0));continue}if(e.projects===void 0){s.push(g(void 0,o,!1));continue}const r=Array.isArray(e.projects)?e.projects:[e.projects];for(const a of r)s.push(a==="^"?g(void 0,o,!0):g(a,o,!1))}return b(s)},M=t=>{if(x(t))try{return JSON.parse(j(t))}catch{return}},yt=t=>{const n=new Map,s=M(p(t,"turbo.json"));if(!s)return n;const i=s.tasks??s.pipeline??{};for(const[o,r]of Object.entries(i)){const a=o.includes("#")?o:`*#${o}`,c=v(a);c.dependsOn=R(r.dependsOn,"turbo"),c.inputs=h(r.inputs),c.outputs=h(r.outputs),c.env=b([...r.env??[],...r.passThroughEnv??[]]),c.cache=r.cache===!1?!1:void 0,n.set(a,c)}const e=v(k);return e.inputs=h(s.globalDependencies),e.env=b([...s.globalEnv??[],...s.globalPassThroughEnv??[]]),(e.inputs.length>0||e.env.length>0)&&n.set(k,e),n},ht=new Set([".git",".nx",".turbo",".vis","build","coverage","dist","node_modules"]),C=(t,n,s=8)=>{const i=[],e=(o,r)=>{if(r>s)return;let a;try{a=it(o)}catch{return}for(const c of a.toSorted()){if(c===n){i.push(p(o,c));continue}if(c.startsWith(".")&&c!==".moon"||ht.has(c))continue;const u=p(o,c);try{ot(u).isDirectory()&&e(u,r+1)}catch{}}};return e(t,0),i},I=(t,n)=>{t.dependsOn=R(n.dependsOn,"nx"),t.inputs=h(n.inputs),t.outputs=h(n.outputs),t.cache=typeof n.cache=="boolean"?n.cache:void 0},gt=t=>{const n=new Map,s=M(p(t,"nx.json"));for(const[i,e]of Object.entries(s?.targetDefaults??{})){const o=`*#${i}`,r=v(o);I(r,e),n.set(o,r)}for(const i of C(t,"project.json")){const e=M(i);if(!(!e?.name||!e.targets))for(const[o,r]of Object.entries(e.targets)){const a=`${e.name}#${o}`,c=v(a);I(c,r),n.set(a,c)}}return n},_=(t,n)=>{t.dependsOn=R(n.deps,"moon"),t.inputs=h(n.inputs),t.outputs=h(n.outputs),t.cache=typeof n.options?.cache=="boolean"?n.options.cache:void 0},A=t=>{if(x(t))try{return ct(t)}catch{return}},vt=t=>{const n=new Map,s=p(t,".moon"),i=[p(s,"tasks.yml"),p(s,"tasks.yaml")];for(const e of i){const o=A(e);if(o){for(const[r,a]of Object.entries(o.tasks??{})){const c=`*#${r}`,u=v(c);_(u,a),n.set(c,u)}if(o.implicitInputs&&o.implicitInputs.length>0){const r=v(k);r.inputs=h(o.implicitInputs),n.set(k,r)}}}for(const e of[...C(t,"moon.yml"),...C(t,"moon.yaml")]){const o=A(e);if(!o?.tasks)continue;const a=e.split(/[/\\]/).at(-2)??"*";for(const[c,u]of Object.entries(o.tasks)){const w=`${a}#${c}`,d=v(w);_(d,u),n.set(w,d)}}return n},xt=(t,n)=>{t.dependsOn=R(n.dependsOn,"vis"),t.inputs=h(n.inputs),t.outputs=h(n.outputs),t.env=b([...n.env??[],...n.passThroughEnv??[],...n.options?.passThroughEnv??[]]),t.cache=n.cache===!1?!1:typeof n.cache=="boolean"?n.cache:void 0},kt=async t=>{const n=new Map,s=await at(t);for(const[o,r]of Object.entries(s.tasks??{})){const a=`*#${o}`,c=v(a);xt(c,r??{}),n.set(a,c)}const i=s.taskRunner??{},e=v(k);return e.inputs=h(i.globalInputs),e.env=b([...i.globalEnv??[],...i.globalPassThroughEnv??[]]),(e.inputs.length>0||e.env.length>0)&&n.set(k,e),n},bt=(t,n)=>{switch(n){case"moon":return vt(t);case"nx":return gt(t);default:return yt(t)}},wt=t=>{const n=[];return x(p(t,"turbo.json"))&&n.push("turbo"),x(p(t,"nx.json"))&&n.push("nx"),(x(p(t,".moon","tasks.yml"))||x(p(t,".moon","tasks.yaml")))&&n.push("moon"),n.length===1?n[0]:void 0},S=(t,n,s,i,e)=>{const o=i.filter(c=>!e.includes(c)),r=e.filter(c=>!i.includes(c));if(o.length===0&&r.length===0)return;const a=[];o.length>0&&a.push(`dropped [${o.join(", ")}]`),r.length>0&&a.push(`added [${r.join(", ")}]`),t.push({axis:s,detail:`${s} diverged: ${a.join("; ")}`,node:n,severity:o.length>0?"error":"warning"})},Et=(t,n,s)=>{const i=[],e=b([...t.keys(),...n.keys()]);for(const o of e){const r=t.get(o),a=n.get(o);if(r&&!a){const c=s==="turbo"&&o.includes("#")&&!o.startsWith("*#")&&o!==k;i.push({axis:"target-set",detail:c?`source target \`${o}\` was skipped by design (turbo project#task is migrated into per-project project.json — move it there and re-verify)`:`source target \`${o}\` has no equivalent in the migrated vis config`,node:o,severity:c?"warning":"error"});continue}if(!r&&a){i.push({axis:"target-set",detail:`migrated vis config defines \`${o}\` with no source equivalent (extra target — not a regression, but review)`,node:o,severity:"warning"});continue}!r||!a||(S(i,o,"dependsOn",r.dependsOn,a.dependsOn),S(i,o,"inputs",r.inputs,a.inputs),S(i,o,"outputs",r.outputs,a.outputs),S(i,o,"env",r.env,a.env),r.cache!==void 0&&a.cache!==void 0&&r.cache!==a.cache&&i.push({axis:"cache",detail:`cache flag diverged: source=${String(r.cache)} vis=${String(a.cache)} (changes what invalidates the cache)`,node:o,severity:"error"}))}return i.sort((o,r)=>o.node.localeCompare(r.node)||o.axis.localeCompare(r.axis)),{findings:i,source:s,sourceNodeCount:t.size,visNodeCount:n.size}},$t=new Set(["json","ndjson","table"]),St=t=>({equivalent:t.findings.every(n=>n.severity!=="error"),findings:t.findings,source:t.source,sourceNodeCount:t.sourceNodeCount,visNodeCount:t.visNodeCount}),Rt=(t,n,s)=>{if(n==="json"){process.stdout.write(`${JSON.stringify(St(t),void 0,2)}
1
+ import{createRequire as P}from"node:module";import{n as T,o as K,s as L,t as f,u as J,v as W,w as Y,x as H,y as U,z as V,A as Q,B as X,D as Z,E as tt,F as nt,G as et,H as F,I as st}from"./cli-main.js";import{e as p,z as j,$ as rt}from"../packem_shared/index-BzhrR_iC.js";import{l as ct}from"./ts-loader.js";import{loadVisConfig as at}from"./CONFIG_FILES.js";import{y as x}from"../packem_shared/isAccessibleSync-DYKTrrvc-C-_5cgwu.js";import{U as O}from"../packem_shared/writeFileSync-DJoHk3Ks-BPRoepNw.js";import{L as dt}from"../packem_shared/registry-Dg9XI6RT.js";import{v as pt}from"../packem_shared/verify-B_MblU_Q.js";let q;const z=t=>(q??=P(import.meta.url))(t),E=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,B=t=>{if(typeof E<"u"&&E.versions&&E.versions.node){const[n,s]=E.versions.node.split(".").map(Number);if(n>22||n===22&&s>=3||n===20&&s>=16)return E.getBuiltinModule(t)}return z(t)},{readdirSync:it,statSync:ot}=B("node:fs"),{stdin:N,stdout:ut}=E,{createInterface:ft}=B("node:readline/promises"),k="__global__",w=t=>[...new Set(t)].sort((n,s)=>n.localeCompare(s)),mt=t=>`{${Object.keys(t).sort().map(i=>`${i}=${JSON.stringify(t[i])}`).join(",")}}`,h=t=>{if(!Array.isArray(t))return[];const n=[];for(const s of t)typeof s=="string"?n.push(s):s&&typeof s=="object"&&n.push(mt(s));return w(n)},g=t=>({cache:void 0,dependsOn:[],env:[],id:t,inputs:[],outputs:[]}),v=(t,n,s)=>s?`^${n}`:t&&t!=="self"&&t!=="~"?`${t}#${n}`:n,lt=(t,n)=>{const s=t.trim();if(n==="moon"){if(s.startsWith("^:"))return v(void 0,s.slice(2),!0);if(s.startsWith("~:"))return v(void 0,s.slice(2),!1);if(s.includes(":")){const[i,e]=s.split(":");return v(i,e??"",!1)}return s}if(s.startsWith("^"))return v(void 0,s.slice(1),!0);if(s.includes("#")){const[i,e]=s.split("#");return v(i,e??"",!1)}return s},R=(t,n)=>{if(!Array.isArray(t))return[];const s=[];for(const i of t){if(typeof i=="string"){s.push(lt(i,n));continue}if(!i||typeof i!="object")continue;const e=i,{target:o}=e;if(!o)continue;if(e.dependencies===!0){s.push(v(void 0,o,!0));continue}if(e.projects===void 0){s.push(v(void 0,o,!1));continue}const r=Array.isArray(e.projects)?e.projects:[e.projects];for(const a of r)s.push(a==="^"?v(void 0,o,!0):v(a,o,!1))}return w(s)},M=t=>{if(x(t))try{return JSON.parse(j(t))}catch{return}},yt=t=>{const n=new Map,s=M(p(t,"turbo.json"));if(!s)return n;const i=s.tasks??s.pipeline??{};for(const[o,r]of Object.entries(i)){const a=o.includes("#")?o:`*#${o}`,c=g(a);c.dependsOn=R(r.dependsOn,"turbo"),c.inputs=h(r.inputs),c.outputs=h(r.outputs),c.env=w([...r.env??[],...r.passThroughEnv??[]]),c.cache=r.cache===!1?!1:void 0,n.set(a,c)}const e=g(k);return e.inputs=h(s.globalDependencies),e.env=w([...s.globalEnv??[],...s.globalPassThroughEnv??[]]),(e.inputs.length>0||e.env.length>0)&&n.set(k,e),n},ht=new Set([".git",".nx",".turbo",".vis","build","coverage","dist","node_modules"]),C=(t,n,s=8)=>{const i=[],e=(o,r)=>{if(r>s)return;let a;try{a=it(o)}catch{return}for(const c of a.toSorted()){if(c===n){i.push(p(o,c));continue}if(c.startsWith(".")&&c!==".moon"||ht.has(c))continue;const u=p(o,c);try{ot(u).isDirectory()&&e(u,r+1)}catch{}}};return e(t,0),i},I=(t,n)=>{t.dependsOn=R(n.dependsOn,"nx"),t.inputs=h(n.inputs),t.outputs=h(n.outputs),t.cache=typeof n.cache=="boolean"?n.cache:void 0},vt=t=>{const n=new Map,s=M(p(t,"nx.json"));for(const[i,e]of Object.entries(s?.targetDefaults??{})){const o=`*#${i}`,r=g(o);I(r,e),n.set(o,r)}for(const i of C(t,"project.json")){const e=M(i);if(!(!e?.name||!e.targets))for(const[o,r]of Object.entries(e.targets)){const a=`${e.name}#${o}`,c=g(a);I(c,r),n.set(a,c)}}return n},_=(t,n)=>{t.dependsOn=R(n.deps,"moon"),t.inputs=h(n.inputs),t.outputs=h(n.outputs),t.cache=typeof n.options?.cache=="boolean"?n.options.cache:void 0},A=t=>{if(x(t))try{return ct(t)}catch{return}},gt=t=>{const n=new Map,s=p(t,".moon"),i=[p(s,"tasks.yml"),p(s,"tasks.yaml")];for(const e of i){const o=A(e);if(o){for(const[r,a]of Object.entries(o.tasks??{})){const c=`*#${r}`,u=g(c);_(u,a),n.set(c,u)}if(o.implicitInputs&&o.implicitInputs.length>0){const r=g(k);r.inputs=h(o.implicitInputs),n.set(k,r)}}}for(const e of[...C(t,"moon.yml"),...C(t,"moon.yaml")]){const o=A(e);if(!o?.tasks)continue;const a=e.split(/[/\\]/).at(-2)??"*";for(const[c,u]of Object.entries(o.tasks)){const b=`${a}#${c}`,d=g(b);_(d,u),n.set(b,d)}}return n},xt=(t,n)=>{t.dependsOn=R(n.dependsOn,"vis"),t.inputs=h(n.inputs),t.outputs=h(n.outputs),t.env=w([...n.env??[],...n.passThroughEnv??[],...n.options?.passThroughEnv??[]]),t.cache=n.cache===!1?!1:typeof n.cache=="boolean"?n.cache:void 0},kt=async t=>{const n=new Map,s=await at(t);for(const[o,r]of Object.entries(s.tasks??{})){const a=`*#${o}`,c=g(a);xt(c,r??{}),n.set(a,c)}const i=s.taskRunner??{},e=g(k);return e.inputs=h(i.globalInputs),e.env=w([...i.globalEnv??[],...i.globalPassThroughEnv??[]]),(e.inputs.length>0||e.env.length>0)&&n.set(k,e),n},wt=(t,n)=>{switch(n){case"moon":return gt(t);case"nx":return vt(t);default:return yt(t)}},bt=t=>{const n=[];return x(p(t,"turbo.json"))&&n.push("turbo"),x(p(t,"nx.json"))&&n.push("nx"),(x(p(t,".moon","tasks.yml"))||x(p(t,".moon","tasks.yaml")))&&n.push("moon"),n.length===1?n[0]:void 0},S=(t,n,s,i,e)=>{const o=i.filter(c=>!e.includes(c)),r=e.filter(c=>!i.includes(c));if(o.length===0&&r.length===0)return;const a=[];o.length>0&&a.push(`dropped [${o.join(", ")}]`),r.length>0&&a.push(`added [${r.join(", ")}]`),t.push({axis:s,detail:`${s} diverged: ${a.join("; ")}`,node:n,severity:o.length>0?"error":"warning"})},Et=(t,n,s)=>{const i=[],e=w([...t.keys(),...n.keys()]);for(const o of e){const r=t.get(o),a=n.get(o);if(r&&!a){const c=s==="turbo"&&o.includes("#")&&!o.startsWith("*#")&&o!==k;i.push({axis:"target-set",detail:c?`source target \`${o}\` was skipped by design (turbo project#task is migrated into per-project project.json — move it there and re-verify)`:`source target \`${o}\` has no equivalent in the migrated vis config`,node:o,severity:c?"warning":"error"});continue}if(!r&&a){i.push({axis:"target-set",detail:`migrated vis config defines \`${o}\` with no source equivalent (extra target — not a regression, but review)`,node:o,severity:"warning"});continue}!r||!a||(S(i,o,"dependsOn",r.dependsOn,a.dependsOn),S(i,o,"inputs",r.inputs,a.inputs),S(i,o,"outputs",r.outputs,a.outputs),S(i,o,"env",r.env,a.env),r.cache!==void 0&&a.cache!==void 0&&r.cache!==a.cache&&i.push({axis:"cache",detail:`cache flag diverged: source=${String(r.cache)} vis=${String(a.cache)} (changes what invalidates the cache)`,node:o,severity:"error"}))}return i.sort((o,r)=>o.node.localeCompare(r.node)||o.axis.localeCompare(r.axis)),{findings:i,source:s,sourceNodeCount:t.size,visNodeCount:n.size}},$t=new Set(["json","ndjson","table"]),St=t=>({equivalent:t.findings.every(n=>n.severity!=="error"),findings:t.findings,source:t.source,sourceNodeCount:t.sourceNodeCount,visNodeCount:t.visNodeCount}),Rt=(t,n,s)=>{if(n==="json"){process.stdout.write(`${JSON.stringify(St(t),void 0,2)}
2
2
  `);return}if(n==="ndjson"){for(const i of t.findings)process.stdout.write(`${JSON.stringify(i)}
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 i of t.findings){const e=` [${i.severity}] ${i.node} (${i.axis}) — ${i.detail}`;i.severity==="error"?s.warn(e):s.info(e)}},jt=(t,n)=>t.findings.some(i=>n==="warning"?!0:i.severity==="error")?1:0,F=async t=>{if(!T.isTTY)return!0;const n=ft({input:T,output:ut});try{const i=(await n.question(`${t} [Y/n] `)).trim().toLowerCase();return i===""||i==="y"||i==="yes"}finally{n.close()}},Mt=[{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"}],Ct=[{description:"VisTaskConfig.targets → VisTaskConfig.tasks",next:"tasks",previous:"targets"}],Nt=t=>new RegExp(String.raw`(^|[\s,{(\[])(["']?)${t}\2(\s*:)`,"gmu"),Tt=(t,n)=>{let s=t;const i=[];for(const e of n){const o=Nt(e.previous);o.test(s)&&(o.lastIndex=0,s=s.replace(o,(r,a,c,u)=>`${a}${c}${e.next}${c}${u}`),i.push(e))}return{applied:i,output:s}},D=(t,n)=>Tt(t,n),Ot=["vis.config.ts","vis.config.mts","vis.config.cts","vis.config.js","vis.config.mjs","vis.config.cjs"],It=new Set(["vis.task.cjs","vis.task.cts","vis.task.js","vis.task.mjs","vis.task.mts","vis.task.ts"]),_t=t=>{for(const n of Ot){const s=p(t,n);if(x(s))return s}},At=t=>{const n=[];try{for(const s of dt(t,{includeDirs:!1,includeFiles:!0,includeSymlinks:!1,skip:[/node_modules/,/\.git/,/\.vis\b/,/dist\b/,/\.next\b/,/\.nuxt\b/]}))It.has(rt(s.path))&&n.push(s.path)}catch{}return n},Dt=(t,n,s,i)=>{const e=_t(t);if(e){const r=j(e),{applied:a,output:c}=D(r,Mt);if(a.length===0)s.info(`${e} already uses the current schema — no rewrite needed.`);else if(n.dryRun)s.info(`── ${e} (preview) ──`),s.info(c),s.info("── end preview ──"),s.info(`Would apply ${String(a.length)} rename(s): ${a.map(u=>u.description).join(", ")}`);else{N(e,i),O(e,c),s.info(`Rewrote ${e} (backup at ${e}.bak). Applied ${String(a.length)} rename(s).`);for(const u of a)i.manualSteps.push(`Renamed ${u.description} in ${e}`)}}else s.warn("No vis.config.ts found at workspace root — nothing to migrate."),i.warnings.push("No vis.config.{ts,mts,cts,js,mjs,cjs} at workspace root.");const o=n.taskConfigPaths??At(t);for(const r of o){if(!x(r))continue;const a=j(r),c=D(a,Ct);if(c.applied.length!==0)if(n.dryRun)s.info(`── ${r} (preview) ──`),s.info(c.output),s.info("── end preview ──"),s.info(`Would apply ${String(c.applied.length)} rename(s): ${c.applied.map(u=>u.description).join(", ")}`);else{N(r,i),O(r,c.output),s.info(`Rewrote ${r} (backup at ${r}.bak). Applied ${String(c.applied.length)} rename(s).`);for(const u of c.applied)i.manualSteps.push(`Renamed ${u.description} in ${r}`)}}},m=t=>{const n=t.workspaceRoot??process.cwd(),s=t.visConfig??{};return{config:s,dryRun:!!t.options.dryRun,logger:t.logger,packageManager:st(n),report:P(),root:n,useEditorconfig:typeof s.editorconfig=="boolean"?s.editorconfig:!0}},l=async(t,n,s)=>{if(n.yes||n.dryRun)return!0;const i=await F(`This will edit files, scripts, and hooks for "${t}". Backups (.bak) will be created. Continue?`);return i||s.info("Aborted."),i},y=t=>{t.dryRun&&t.logger.info(`Running in dry-run mode — no changes will be made.
4
- `)},Bt=async({logger:t,options:n,visConfig:s,workspaceRoot:i})=>{if(!await l("deps",n,t))return;const e=m({logger:t,options:n,visConfig:s,workspaceRoot:i});y(e),t.info("── Migrating dependencies and scripts ──"),J(e.root,e.packageManager,e.config,{dryRun:e.dryRun},t,e.report),t.info(""),f(e.report,t)},Vt=async({logger:t,options:n,visConfig:s,workspaceRoot:i})=>{if(!await l("lint-staged",n,t))return;const e=m({logger:t,options:n,visConfig:s,workspaceRoot:i});y(e),t.info("── Migrating lint-staged ──"),H(e.root,{dryRun:e.dryRun,useEditorconfig:e.useEditorconfig},t,e.report),t.info(""),f(e.report,t)},Pt=async({logger:t,options:n,visConfig:s,workspaceRoot:i})=>{if(!await l("nano-staged",n,t))return;const e=m({logger:t,options:n,visConfig:s,workspaceRoot:i});y(e),t.info("── Migrating nano-staged ──"),U(e.root,{dryRun:e.dryRun,useEditorconfig:e.useEditorconfig},t,e.report),t.info(""),f(e.report,t)},Ft=async({logger:t,options:n,visConfig:s,workspaceRoot:i})=>{if(!await l("turborepo",n,t))return;const e=m({logger:t,options:n,visConfig:s,workspaceRoot:i});y(e),t.info("── Migrating turborepo ──"),et(e.root,{dryRun:e.dryRun,useEditorconfig:e.useEditorconfig},t,e.report),V(e.root,{dryRun:e.dryRun},t),t.info(""),f(e.report,t)},Gt=async({logger:t,options:n,visConfig:s,workspaceRoot:i})=>{if(!await l("nx",n,t))return;const e=m({logger:t,options:n,visConfig:s,workspaceRoot:i});y(e),t.info("── Migrating nx ──");const o=!!n.aggressive;X(e.root,{aggressive:o,dryRun:e.dryRun,force:o||!!n.force,rewriteSyncGenerators:o||!!n.rewriteSyncGenerators,useEditorconfig:e.useEditorconfig},t,e.report),t.info(""),f(e.report,t)},Kt=async({logger:t,options:n,visConfig:s,workspaceRoot:i})=>{if(!await l("moon",n,t))return;const e=m({logger:t,options:n,visConfig:s,workspaceRoot:i});y(e),t.info("── Migrating moon ──"),Q(e.root,{copyTemplates:!!n.copyTemplates,dryRun:e.dryRun,useEditorconfig:e.useEditorconfig},t,e.report),V(e.root,{dryRun:e.dryRun},t),t.info(""),f(e.report,t)},Lt=async({logger:t,options:n,visConfig:s,workspaceRoot:i})=>{if(!await l("gitleaks",n,t))return;const e=m({logger:t,options:n,visConfig:s,workspaceRoot:i});y(e),t.info("── Migrating gitleaks ──"),W(e.root,{dryRun:e.dryRun,useEditorconfig:e.useEditorconfig},t,e.report),t.info(""),f(e.report,t)},qt=async({logger:t,options:n,visConfig:s,workspaceRoot:i})=>{if(!await l("kingfisher",n,t))return;const e=m({logger:t,options:n,visConfig:s,workspaceRoot:i});y(e),t.info("── Migrating Kingfisher ──"),Y(e.root,{dryRun:e.dryRun,useEditorconfig:e.useEditorconfig},t,e.report),t.info(""),f(e.report,t)},zt=async({logger:t,options:n,visConfig:s,workspaceRoot:i})=>{if(!await l("secretlint",n,t))return;const e=m({logger:t,options:n,visConfig:s,workspaceRoot:i});y(e),t.info("── Migrating secretlint ──"),Z(e.root,{dryRun:e.dryRun,useEditorconfig:e.useEditorconfig},t,e.report),t.info(""),f(e.report,t)},Jt=async({logger:t,options:n,visConfig:s,workspaceRoot:i})=>{if(!await l("syncpack",n,t))return;const e=m({logger:t,options:n,visConfig:s,workspaceRoot:i});y(e),t.info("── Migrating syncpack ──"),nt(e.root,{dryRun:e.dryRun,useEditorconfig:e.useEditorconfig},t,e.report),t.info(""),f(e.report,t)},Wt=async({logger:t,options:n,visConfig:s,workspaceRoot:i})=>{if(!await l("sherif",n,t))return;const e=m({logger:t,options:n,visConfig:s,workspaceRoot:i});y(e),t.info("── Migrating sherif ──"),tt(e.root,{dryRun:e.dryRun,useEditorconfig:e.useEditorconfig},t,e.report),t.info(""),f(e.report,t)},Yt=async({logger:t,options:n,visConfig:s,workspaceRoot:i})=>{if(!await l("self",n,t))return;const e=m({logger:t,options:n,visConfig:s,workspaceRoot:i});y(e),t.info("── Migrating vis.config.ts to current schema ──"),Dt(e.root,{dryRun:e.dryRun},t,e.report),t.info(""),f(e.report,t)},Ht=({logger:t,workspaceRoot:n})=>{const s=n??process.cwd();pt(s,t).length>0&&(process.exitCode=1)},Qt=async({logger:t,options:n,workspaceRoot:s})=>{const i=s??process.cwd(),e=n.format??"table";if(!$t.has(e)){t.warn(`Invalid --format: ${String(n.format)}. Expected table | json | ndjson.`),process.exitCode=1;return}const o=n.failOn==="warning"?"warning":"error";let r;if(n.from){if(n.from!=="turbo"&&n.from!=="nx"&&n.from!=="moon"){t.warn(`Invalid --from: ${n.from}. Expected turbo | nx | moon.`),process.exitCode=1;return}r=n.from}else if(r=wt(i),!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 a=bt(i,r);if(a.size===0){t.warn(`No ${r} task graph found at ${i} — nothing to verify.`),process.exitCode=1;return}const c=await kt(i);if(c.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=Et(a,c,r);Rt(u,e,t),process.exitCode=jt(u,o)},Ut=async({logger:t,options:n,visConfig:s,workspaceRoot:i})=>{const e=i??process.cwd(),r=q(e,s??{}),a=z(r);if(a.length===0){t.info("No applicable migrations detected in this workspace.");return}const c=!!n.dryRun;t.info(`Detected ${String(a.length)} migration(s):`);for(const d of a)t.info(` • ${d.title} — ${d.description}`);if(t.info(""),!n.yes&&!c&&!await F("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.
5
- `);const u=P(),w=[];for(const d of a)try{if(t.info(`── Applying ${d.title} ──`),c)for(const $ of d.probe(r))t.info($);else d.apply(r,u,t);t.info("")}catch($){w.push({error:$,id:d.id}),t.warn(`Failed to apply ${d.title}: ${$.message}`)}f(u,t),w.length>0&&(t.warn(""),t.warn(`${String(w.length)} migration(s) failed — see messages above.`),process.exitCode=1)},an=Bt,un=Vt,fn=Pt,dn=Ft,pn=Gt,mn=Kt,ln=Lt,yn=qt,hn=zt,gn=Jt,vn=Wt,xn=Yt,kn=Ht,bn=Qt,wn=Ut;export{wn as migrateAllExecute,an as migrateDepsExecute,ln as migrateGitleaksExecute,yn as migrateKingfisherExecute,un as migrateLintStagedExecute,mn as migrateMoonExecute,fn as migrateNanoStagedExecute,pn as migrateNxExecute,hn as migrateSecretlintExecute,xn as migrateSelfExecute,vn as migrateSherifExecute,gn as migrateSyncpackExecute,dn as migrateTurborepoExecute,kn as migrateVerifyExecute,bn as migrateVerifyGraphExecute};
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 i of t.findings){const e=` [${i.severity}] ${i.node} (${i.axis}) — ${i.detail}`;i.severity==="error"?s.warn(e):s.info(e)}},jt=(t,n)=>t.findings.some(i=>n==="warning"?!0:i.severity==="error")?1:0,G=async t=>{if(!N.isTTY)return!0;const n=ft({input:N,output:ut});try{const i=(await n.question(`${t} [Y/n] `)).trim().toLowerCase();return i===""||i==="y"||i==="yes"}finally{n.close()}},Mt=[{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"}],Ct=[{description:"VisTaskConfig.targets → VisTaskConfig.tasks",next:"tasks",previous:"targets"}],Tt=t=>new RegExp(String.raw`(^|[\s,{(\[])(["']?)${t}\2(\s*:)`,"gmu"),Nt=(t,n)=>{let s=t;const i=[];for(const e of n){const o=Tt(e.previous);o.test(s)&&(o.lastIndex=0,s=s.replace(o,(r,a,c,u)=>`${a}${c}${e.next}${c}${u}`),i.push(e))}return{applied:i,output:s}},D=(t,n)=>Nt(t,n),Ot=["vis.config.ts","vis.config.mts","vis.config.cts","vis.config.js","vis.config.mjs","vis.config.cjs"],It=new Set(["vis.task.cjs","vis.task.cts","vis.task.js","vis.task.mjs","vis.task.mts","vis.task.ts"]),_t=t=>{for(const n of Ot){const s=p(t,n);if(x(s))return s}},At=t=>{const n=[];try{for(const s of dt(t,{includeDirs:!1,includeFiles:!0,includeSymlinks:!1,skip:[/node_modules/,/\.git/,/\.vis\b/,/dist\b/,/\.next\b/,/\.nuxt\b/]}))It.has(rt(s.path))&&n.push(s.path)}catch{}return n},Dt=(t,n,s,i)=>{const e=_t(t);if(e){const r=j(e),{applied:a,output:c}=D(r,Mt);if(a.length===0)s.info(`${e} already uses the current schema — no rewrite needed.`);else if(n.dryRun)s.info(`── ${e} (preview) ──`),s.info(c),s.info("── end preview ──"),s.info(`Would apply ${String(a.length)} rename(s): ${a.map(u=>u.description).join(", ")}`);else{T(e,i),O(e,c),s.info(`Rewrote ${e} (backup at ${e}.bak). Applied ${String(a.length)} rename(s).`);for(const u of a)i.manualSteps.push(`Renamed ${u.description} in ${e}`)}}else s.warn("No vis.config.ts found at workspace root — nothing to migrate."),i.warnings.push("No vis.config.{ts,mts,cts,js,mjs,cjs} at workspace root.");const o=n.taskConfigPaths??At(t);for(const r of o){if(!x(r))continue;const a=j(r),c=D(a,Ct);if(c.applied.length!==0)if(n.dryRun)s.info(`── ${r} (preview) ──`),s.info(c.output),s.info("── end preview ──"),s.info(`Would apply ${String(c.applied.length)} rename(s): ${c.applied.map(u=>u.description).join(", ")}`);else{T(r,i),O(r,c.output),s.info(`Rewrote ${r} (backup at ${r}.bak). Applied ${String(c.applied.length)} rename(s).`);for(const u of c.applied)i.manualSteps.push(`Renamed ${u.description} in ${r}`)}}},m=t=>{const n=t.workspaceRoot??process.cwd(),s=t.visConfig??{};return{config:s,dryRun:!!t.options.dryRun,logger:t.logger,packageManager:st(n),report:F(),root:n,useEditorconfig:typeof s.editorconfig=="boolean"?s.editorconfig:!0}},l=async(t,n,s)=>{if(n.yes||n.dryRun)return!0;const i=await G(`This will edit files, scripts, and hooks for "${t}". Backups (.bak) will be created. Continue?`);return i||s.info("Aborted."),i},y=t=>{t.dryRun&&t.logger.info(`Running in dry-run mode — no changes will be made.
4
+ `)},Bt=async({logger:t,options:n,visConfig:s,workspaceRoot:i})=>{if(!await l("deps",n,t))return;const e=m({logger:t,options:n,visConfig:s,workspaceRoot:i});y(e),t.info("── Migrating dependencies and scripts ──"),J(e.root,e.packageManager,e.config,{dryRun:e.dryRun},t,e.report),t.info(""),f(e.report,t)},Vt=async({logger:t,options:n,visConfig:s,workspaceRoot:i})=>{if(!await l("lint-staged",n,t))return;const e=m({logger:t,options:n,visConfig:s,workspaceRoot:i});y(e),t.info("── Migrating lint-staged ──"),H(e.root,{dryRun:e.dryRun,useEditorconfig:e.useEditorconfig},t,e.report),t.info(""),f(e.report,t)},Ft=async({logger:t,options:n,visConfig:s,workspaceRoot:i})=>{if(!await l("nano-staged",n,t))return;const e=m({logger:t,options:n,visConfig:s,workspaceRoot:i});y(e),t.info("── Migrating nano-staged ──"),Q(e.root,{dryRun:e.dryRun,useEditorconfig:e.useEditorconfig},t,e.report),t.info(""),f(e.report,t)},Gt=async({logger:t,options:n,visConfig:s,workspaceRoot:i})=>{if(!await l("turborepo",n,t))return;const e=m({logger:t,options:n,visConfig:s,workspaceRoot:i});y(e),t.info("── Migrating turborepo ──"),et(e.root,{dryRun:e.dryRun,useEditorconfig:e.useEditorconfig},t,e.report),V(e.root,{dryRun:e.dryRun},t),t.info(""),f(e.report,t)},Pt=async({logger:t,options:n,visConfig:s,workspaceRoot:i})=>{if(!await l("nx",n,t))return;const e=m({logger:t,options:n,visConfig:s,workspaceRoot:i});y(e),t.info("── Migrating nx ──");const o=!!n.aggressive;X(e.root,{aggressive:o,dryRun:e.dryRun,force:o||!!n.force,rewriteSyncGenerators:o||!!n.rewriteSyncGenerators,useEditorconfig:e.useEditorconfig},t,e.report),t.info(""),f(e.report,t)},qt=async({logger:t,options:n,visConfig:s,workspaceRoot:i})=>{if(!await l("moon",n,t))return;const e=m({logger:t,options:n,visConfig:s,workspaceRoot:i});y(e),t.info("── Migrating moon ──"),U(e.root,{copyTemplates:!!n.copyTemplates,dryRun:e.dryRun,useEditorconfig:e.useEditorconfig},t,e.report),V(e.root,{dryRun:e.dryRun},t),t.info(""),f(e.report,t)},zt=async({logger:t,options:n,visConfig:s,workspaceRoot:i})=>{if(!await l("gitleaks",n,t))return;const e=m({logger:t,options:n,visConfig:s,workspaceRoot:i});y(e),t.info("── Migrating gitleaks ──"),W(e.root,{dryRun:e.dryRun,useEditorconfig:e.useEditorconfig},t,e.report),t.info(""),f(e.report,t)},Kt=async({logger:t,options:n,visConfig:s,workspaceRoot:i})=>{if(!await l("kingfisher",n,t))return;const e=m({logger:t,options:n,visConfig:s,workspaceRoot:i});y(e),t.info("── Migrating Kingfisher ──"),Y(e.root,{dryRun:e.dryRun,useEditorconfig:e.useEditorconfig},t,e.report),t.info(""),f(e.report,t)},Lt=async({logger:t,options:n,visConfig:s,workspaceRoot:i})=>{if(!await l("secretlint",n,t))return;const e=m({logger:t,options:n,visConfig:s,workspaceRoot:i});y(e),t.info("── Migrating secretlint ──"),Z(e.root,{dryRun:e.dryRun,useEditorconfig:e.useEditorconfig},t,e.report),t.info(""),f(e.report,t)},Jt=async({logger:t,options:n,visConfig:s,workspaceRoot:i})=>{if(!await l("syncpack",n,t))return;const e=m({logger:t,options:n,visConfig:s,workspaceRoot:i});y(e),t.info("── Migrating syncpack ──"),nt(e.root,{dryRun:e.dryRun,useEditorconfig:e.useEditorconfig},t,e.report),t.info(""),f(e.report,t)},Wt=async({logger:t,options:n,visConfig:s,workspaceRoot:i})=>{if(!await l("sherif",n,t))return;const e=m({logger:t,options:n,visConfig:s,workspaceRoot:i});y(e),t.info("── Migrating sherif ──"),tt(e.root,{dryRun:e.dryRun,useEditorconfig:e.useEditorconfig},t,e.report),t.info(""),f(e.report,t)},Yt=async({logger:t,options:n,visConfig:s,workspaceRoot:i})=>{if(!await l("self",n,t))return;const e=m({logger:t,options:n,visConfig:s,workspaceRoot:i});y(e),t.info("── Migrating vis.config.ts to current schema ──"),Dt(e.root,{dryRun:e.dryRun},t,e.report),t.info(""),f(e.report,t)},Ht=({logger:t,workspaceRoot:n})=>{const s=n??process.cwd();pt(s,t).length>0&&(process.exitCode=1)},Ut=async({logger:t,options:n,workspaceRoot:s})=>{const i=s??process.cwd(),e=n.format??"table";if(!$t.has(e)){t.warn(`Invalid --format: ${String(n.format)}. Expected table | json | ndjson.`),process.exitCode=1;return}const o=n.failOn==="warning"?"warning":"error";let r;if(n.from){if(n.from!=="turbo"&&n.from!=="nx"&&n.from!=="moon"){t.warn(`Invalid --from: ${n.from}. Expected turbo | nx | moon.`),process.exitCode=1;return}r=n.from}else if(r=bt(i),!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 a=wt(i,r);if(a.size===0){t.warn(`No ${r} task graph found at ${i} — nothing to verify.`),process.exitCode=1;return}const c=await kt(i);if(c.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=Et(a,c,r);Rt(u,e,t),process.exitCode=jt(u,o)},Qt=async({logger:t,options:n,visConfig:s,workspaceRoot:i})=>{const e=i??process.cwd(),r=K(e,s??{}),a=L(r);if(a.length===0){t.info("No applicable migrations detected in this workspace.");return}const c=!!n.dryRun;t.info(`Detected ${String(a.length)} migration(s):`);for(const d of a)t.info(` • ${d.title} — ${d.description}`);if(t.info(""),!n.yes&&!c&&!await G("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.
5
+ `);const u=F(),b=[];for(const d of a)try{if(t.info(`── Applying ${d.title} ──`),c)for(const $ of d.probe(r))t.info($);else d.apply(r,u,t);t.info("")}catch($){b.push({error:$,id:d.id}),t.warn(`Failed to apply ${d.title}: ${$.message}`)}f(u,t),b.length>0&&(t.warn(""),t.warn(`${String(b.length)} migration(s) failed — see messages above.`),process.exitCode=1)},an=Bt,un=Vt,fn=Ft,dn=Gt,pn=Pt,mn=qt,ln=zt,yn=Kt,hn=Lt,vn=Jt,gn=Wt,xn=Yt,kn=Ht,wn=Ut,bn=Qt;export{bn as migrateAllExecute,an as migrateDepsExecute,ln as migrateGitleaksExecute,yn as migrateKingfisherExecute,un as migrateLintStagedExecute,mn as migrateMoonExecute,fn as migrateNanoStagedExecute,pn as migrateNxExecute,hn as migrateSecretlintExecute,xn as migrateSelfExecute,gn as migrateSherifExecute,vn as migrateSyncpackExecute,dn as migrateTurborepoExecute,kn as migrateVerifyExecute,wn as migrateVerifyGraphExecute};
@@ -1,4 +1,4 @@
1
- import{createRequire as D}from"node:module";import{V as q}from"../packem_shared/vis-user-error-CRmrBaD1.js";let W;const L=e=>(W??=D(import.meta.url))(e),R=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,E=e=>{if(typeof R<"u"&&R.versions&&R.versions.node){const[t,n]=R.versions.node.split(".").map(Number);if(t>22||t===22&&n>=3||t===20&&n>=16)return R.getBuiltinModule(e)}return L(e)},{relative:h,join:u,dirname:_}=E("node:path"),{lstat:G}=E("node:fs/promises"),U=new Set(["ENOENT","ENOTDIR"]),$=e=>U.has(e?.code??""),T=async(e,t)=>{const n=e.lstat;try{return(typeof n=="function"?await n.call(e,t):await G(t)).isSymbolicLink()}catch(i){if($(i))return!1;throw i}},v=async(e,t,n)=>{if(await T(e,t))throw new q(`Refusing to write ${t}: it is a symlink, and following it would write somewhere else. Remove or replace the link, then re-run.`);await e.writeFile(t,n)},g=async(e,t)=>{try{return await e.access(t),!0}catch(n){if($(n))return!1;throw n}},Y=async(e,t)=>{try{return(await e.stat(t)).isDirectory()}catch(n){if($(n))return!1;throw n}},b=async(e,t)=>{try{return await e.readFile(t,"utf8")}catch(n){if($(n))return;throw n}},K=e=>{const t=/\n([\t ]+)\S/.exec(e);return t?.[1]!==void 0?t[1]:e.includes(`
1
+ import{createRequire as D}from"node:module";import{V as q}from"../packem_shared/vis-user-error-3YS7sPYy.js";let W;const L=e=>(W??=D(import.meta.url))(e),R=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,E=e=>{if(typeof R<"u"&&R.versions&&R.versions.node){const[t,n]=R.versions.node.split(".").map(Number);if(t>22||t===22&&n>=3||t===20&&n>=16)return R.getBuiltinModule(e)}return L(e)},{relative:h,join:u,dirname:_}=E("node:path"),{lstat:G}=E("node:fs/promises"),U=new Set(["ENOENT","ENOTDIR"]),$=e=>U.has(e?.code??""),T=async(e,t)=>{const n=e.lstat;try{return(typeof n=="function"?await n.call(e,t):await G(t)).isSymbolicLink()}catch(i){if($(i))return!1;throw i}},v=async(e,t,n)=>{if(await T(e,t))throw new q(`Refusing to write ${t}: it is a symlink, and following it would write somewhere else. Remove or replace the link, then re-run.`);await e.writeFile(t,n)},g=async(e,t)=>{try{return await e.access(t),!0}catch(n){if($(n))return!1;throw n}},Y=async(e,t)=>{try{return(await e.stat(t)).isDirectory()}catch(n){if($(n))return!1;throw n}},b=async(e,t)=>{try{return await e.readFile(t,"utf8")}catch(n){if($(n))return;throw n}},K=e=>{const t=/\n([\t ]+)\S/.exec(e);return t?.[1]!==void 0?t[1]:e.includes(`
2
2
  `)?" ":""},V=(e,t)=>{const n=t.includes(`\r
3
3
  `)?`\r
4
4
  `:`
@@ -60,7 +60,7 @@ ${f.join(`
60
60
  `).map(f=>` ${f}`).join(`
61
61
  `),{found:l,preserved:c}=await B(e,t,r,n,i);i.info(`Found ${l} pending .bumpy/*.md file(s); ${c>0?`copied ${c} to .vis/release/`:"(dry-run)"}.`),i.info(""),i.info("Suggested vis.config.ts release block (bumpy config translates 1:1):"),i.info(""),i.info(` release: ${s.trimStart()},`),i.info(""),i.info("After confirming, delete `.bumpy/`.")},Re=async(e,t,n,i,r)=>{const o=u(t,".husky","pre-commit");if(!await g(e,o))return;const a=await b(e,o)??"";if(a.includes("vis release check"))return;const s="vis release check --hook pre-commit --no-fail";if(!await(async()=>{if(!process.stdout.isTTY||process.env.CI==="true")return!1;if(i)return!0;try{const{confirmPrompt:c}=await import("./prompts.js");return await c(`Wire \`${s}\` into your .husky/pre-commit hook?`,!0)}catch{return!1}})()){r.info(""),r.info("Optional: add this line to .husky/pre-commit:"),r.info(` ${s}`);return}if(n){r.info(`[dry-run] would append \`${s}\` to .husky/pre-commit`);return}await v(e,o,`${a.replace(/\n*$/,`
62
62
  `)}${s}
63
- `),r.info("Wired vis release check into .husky/pre-commit.")},Ae=async(e,t,n,i,r)=>{const o=i.workflows===!0,a=i.yes===!0;if(!o&&(!process.stdout.isTTY||process.env.CI==="true"))return;if(!(o||a||await(async()=>{try{const{confirmPrompt:y}=await import("./prompts.js");return await y("Generate CI workflow files for the active provider?",!0)}catch{return!1}})())){r.info(""),r.info("Skipped workflow generation. Re-run with `vis release init --workflows` later.");return}const{detectRemoteProvider:l}=await import("./detect.js"),{generateWorkflowFiles:c}=await import("./workflow-templates.js"),{detectPackageManager:f}=await import("../packem_shared/createAdapter-F7GidOzU.js"),{createShellRunner:d}=await import("./shell-runner.js"),p=d(),w=await l(t,p,void 0),m=await f(t,p),A=i.packageManager??m;let x={};try{const{loadVisConfig:y}=await import("./CONFIG_FILES.js"),S=await y(t);S.release&&(x=S.release)}catch{}const C=c(x,{packageManager:A,provider:w});r.info(""),r.info(`Generating ${C.length} workflow file(s) for ${w}:`);for(const y of C){const S=u(t,y.path);if(await g(e,S)){r.warn(` ${y.path} — already exists, skipping`);continue}if(n){r.info(` ${y.path} — [dry-run] would write ${y.content.length} bytes`);continue}await e.mkdir(_(S),{recursive:!0}),await v(e,S,y.content),r.info(` ${y.path} — wrote ${y.content.length} bytes`)}},Ce=e=>{e.info(""),e.info("Suggested vis.config.ts release block:"),e.info(""),e.info(` release: {
63
+ `),r.info("Wired vis release check into .husky/pre-commit.")},Ae=async(e,t,n,i,r)=>{const o=i.workflows===!0,a=i.yes===!0;if(!o&&(!process.stdout.isTTY||process.env.CI==="true"))return;if(!(o||a||await(async()=>{try{const{confirmPrompt:y}=await import("./prompts.js");return await y("Generate CI workflow files for the active provider?",!0)}catch{return!1}})())){r.info(""),r.info("Skipped workflow generation. Re-run with `vis release init --workflows` later.");return}const{detectRemoteProvider:l}=await import("./detect.js"),{generateWorkflowFiles:c}=await import("./workflow-templates.js"),{detectPackageManager:f}=await import("../packem_shared/createAdapter-DMK4bBET.js"),{createShellRunner:d}=await import("./shell-runner.js"),p=d(),w=await l(t,p,void 0),m=await f(t,p),A=i.packageManager??m;let x={};try{const{loadVisConfig:y}=await import("./CONFIG_FILES.js"),S=await y(t);S.release&&(x=S.release)}catch{}const C=c(x,{packageManager:A,provider:w});r.info(""),r.info(`Generating ${C.length} workflow file(s) for ${w}:`);for(const y of C){const S=u(t,y.path);if(await g(e,S)){r.warn(` ${y.path} — already exists, skipping`);continue}if(n){r.info(` ${y.path} — [dry-run] would write ${y.content.length} bytes`);continue}await e.mkdir(_(S),{recursive:!0}),await v(e,S,y.content),r.info(` ${y.path} — wrote ${y.content.length} bytes`)}},Ce=e=>{e.info(""),e.info("Suggested vis.config.ts release block:"),e.info(""),e.info(` release: {
64
64
  baseBranch: "main",
65
65
  defaultManaged: true,
66
66
  channels: {
@@ -1,8 +1,8 @@
1
- import{a as L,b as J,p as f,O as G,c as O,q as T}from"./cli-main.js";import{m as H,a as K,t as m,i as Q,n as W,R as c,O as X,o as y,u as P,v as Z,w as _}from"./catalog.js";import{i as ee}from"../packem_shared/index-BjdW45xX.js";import{v as te,r as se,f as re}from"../packem_shared/ai-analysis-pldoS_N4.js";import{V as ae}from"../packem_shared/vis-user-error-CRmrBaD1.js";import{d as ne}from"../packem_shared/pm-runner-RM72mDZg.js";import{s as oe}from"../packem_shared/formatBytes-_HvjOy8a-B_qQr4Hw.js";import{U as ce,V as ie,C as j}from"../packem_shared/vis-update-app-9b2kSk9f.js";const ke=async({argument:R,logger:s,options:e,visConfig:o,workspaceRoot:C})=>{if(!C)throw new Error("Could not determine workspace root. Run this command inside a monorepo.");const d=C;if(e.sync&&!e.securityConfig)throw new ae("--sync requires --security-config. Run `vis check --security-config --sync`.");if(e.securityConfig){const t=ne(d);if(L(o??{},t.name),e.sync&&t.name==="pnpm"){const r=J(o??{});if(r.length>0){f.info(`
2
- Settings that would sync to pnpm-workspace.yaml:`);for(const E of r)f.success(` ${E}`)}else f.info("No security settings to sync.")}else e.sync&&t.name!=="pnpm"&&(f.info(`--sync is only available for pnpm projects. Your project uses ${t.name}.`),f.info("vis enforces security settings at the vis layer for non-pnpm projects."));if(!e.security&&!R?.length)return}const{packageManager:N}=G(d),U=H(d),i=o?.update??{},h=K(d,N,{dev:e.dev,includeInternal:e["include-internal"],peer:e.peer,prod:e.prod});if(h.size===0){s.info("No catalogs found.");return}const w=e.target??i.target??"latest";if(!["latest","minor","patch"].includes(w))throw new Error(`Invalid target "${w}". Use: latest, minor, or patch.`);const D={exclude:[...m(e.exclude),...m(i.exclude)],ignore:m(i.ignore),include:[...m(e.include),...m(i.include),...R],includeLocked:!!e.includeLocked,includePrerelease:e.prerelease||i.prerelease||!1,security:e.security!==!1,target:w};let x=0;for(const t of h.values())x+=t.size;const k=!!process.stdout.isTTY&&!ee;let l;const I=k?(t,r)=>{l?l.rerender(c.createElement(j,{current:t,total:r})):l=T(c.createElement(j,{current:t,total:r}),{interactive:!0,patchConsole:!1})}:(t,r)=>{s.info(`Checking ${String(t)}/${String(r)} dependencies...`)};k||s.info(`Checking ${String(x)} catalog dependencies against npm registry...
3
- `);const v=new Set;O("socket")&&v.add("socket"),O("depsDev")&&v.add("deps-dev");const g=o?.security?.policies?.score?.minimum,M=Q(o?.security,{disabled:v,minimumScore:g}),{failed:$,outdated:n}=await W(h,D,U,I,d,M,o?.security?.acceptedRisks);if(l&&(l.clear(),l.unmount()),$.length>0&&s.warn(`Failed to fetch: ${$.join(", ")}`),n.length===0){s.info("All catalog dependencies are up to date.");return}const S=e.format??i.format??"table",V=te(e.aiType??"impact"),u=e.ai?await se(n,s,o?.ai,V):void 0;if(k&&S==="table"){const t=new ce(n,u??null),r=o?.tui?.autoExit??!1,E=r===!0?3:typeof r=="number"?r:0;await T(c.createElement(ie,{autoExitSeconds:E,isDryRun:!0,store:t}),{alternateScreen:!0,exitOnCtrlC:!1,interactive:!0,patchConsole:!0}).waitUntilExit();const q=process.stdout.columns||80;process.stdout.write(`
4
- `);for(const a of n){const B=a.vulnerabilities?.length||a.socketReport&&a.socketReport.alerts.length>0,b=!!a.acceptedRisk,Y=B?b?"✓":"⚠":"✓",z=b?"gray":a.updateType==="major"?"red":a.updateType==="minor"?"yellow":"green",p=a.socketReport?.score.overall,F=p===void 0?"":` [${String(Math.round(p*100))}%]`,A=p===void 0?void 0:oe(p);process.stdout.write(`${X(c.createElement(y,null," ",c.createElement(y,{color:z},Y),` ${a.packageName} ${a.currentRange} → ${a.newRange}`,c.createElement(y,{dimColor:!0},` ${a.updateType}`),A?c.createElement(y,{color:A},F):null),{columns:q})}
1
+ import{a as L,b as J,p as m,O as G,c as A,q as T}from"./cli-main.js";import{O as H}from"../packem_shared/renderToString-DR0zDUjh-DXppT6AM.js";import{a as K,R as c,O as y}from"../packem_shared/registry-Dg9XI6RT.js";import{i as Q}from"../packem_shared/index-BjdW45xX.js";import{v as W,r as X,f as Z}from"../packem_shared/ai-analysis-BCJ1kuDM.js";import{V as _}from"../packem_shared/vis-user-error-3YS7sPYy.js";import{d as ee}from"../packem_shared/pm-runner-RM72mDZg.js";import{s as te}from"../packem_shared/env-BSXG3QKH.js";import{U as se,V as re,C as P}from"../packem_shared/vis-update-app-6QOYxnNx.js";import{readCatalogs as ae,toFilterArray as f,checkOutdated as ne,formatSummary as j,formatOutdatedMinimal as oe,formatOutdatedTable as ce}from"./catalog2.js";import{l as ie}from"../packem_shared/npmrc-CHsOyMvA.js";const $e=async({argument:R,logger:s,options:e,visConfig:o,workspaceRoot:C})=>{if(!C)throw new Error("Could not determine workspace root. Run this command inside a monorepo.");const d=C;if(e.sync&&!e.securityConfig)throw new _("--sync requires --security-config. Run `vis check --security-config --sync`.");if(e.securityConfig){const t=ee(d);if(L(o??{},t.name),e.sync&&t.name==="pnpm"){const r=J(o??{});if(r.length>0){m.info(`
2
+ Settings that would sync to pnpm-workspace.yaml:`);for(const E of r)m.success(` ${E}`)}else m.info("No security settings to sync.")}else e.sync&&t.name!=="pnpm"&&(m.info(`--sync is only available for pnpm projects. Your project uses ${t.name}.`),m.info("vis enforces security settings at the vis layer for non-pnpm projects."));if(!e.security&&!R?.length)return}const{packageManager:N}=G(d),U=ie(d),i=o?.update??{},h=ae(d,N,{dev:e.dev,includeInternal:e["include-internal"],peer:e.peer,prod:e.prod});if(h.size===0){s.info("No catalogs found.");return}const w=e.target??i.target??"latest";if(!["latest","minor","patch"].includes(w))throw new Error(`Invalid target "${w}". Use: latest, minor, or patch.`);const D={exclude:[...f(e.exclude),...f(i.exclude)],ignore:f(i.ignore),include:[...f(e.include),...f(i.include),...R],includeLocked:!!e.includeLocked,includePrerelease:e.prerelease||i.prerelease||!1,security:e.security!==!1,target:w};let x=0;for(const t of h.values())x+=t.size;const k=!!process.stdout.isTTY&&!Q;let l;const I=k?(t,r)=>{l?l.rerender(c.createElement(P,{current:t,total:r})):l=T(c.createElement(P,{current:t,total:r}),{interactive:!0,patchConsole:!1})}:(t,r)=>{s.info(`Checking ${String(t)}/${String(r)} dependencies...`)};k||s.info(`Checking ${String(x)} catalog dependencies against npm registry...
3
+ `);const g=new Set;A("socket")&&g.add("socket"),A("depsDev")&&g.add("deps-dev");const v=o?.security?.policies?.score?.minimum,M=K(o?.security,{disabled:g,minimumScore:v}),{failed:$,outdated:n}=await ne(h,D,U,I,d,M,o?.security?.acceptedRisks);if(l&&(l.clear(),l.unmount()),$.length>0&&s.warn(`Failed to fetch: ${$.join(", ")}`),n.length===0){s.info("All catalog dependencies are up to date.");return}const S=e.format??i.format??"table",V=W(e.aiType??"impact"),u=e.ai?await X(n,s,o?.ai,V):void 0;if(k&&S==="table"){const t=new se(n,u??null),r=o?.tui?.autoExit??!1,E=r===!0?3:typeof r=="number"?r:0;await T(c.createElement(re,{autoExitSeconds:E,isDryRun:!0,store:t}),{alternateScreen:!0,exitOnCtrlC:!1,interactive:!0,patchConsole:!0}).waitUntilExit();const q=process.stdout.columns||80;process.stdout.write(`
4
+ `);for(const a of n){const B=a.vulnerabilities?.length||a.socketReport&&a.socketReport.alerts.length>0,b=!!a.acceptedRisk,Y=B?b?"✓":"⚠":"✓",z=b?"gray":a.updateType==="major"?"red":a.updateType==="minor"?"yellow":"green",p=a.socketReport?.score.overall,F=p===void 0?"":` [${String(Math.round(p*100))}%]`,O=p===void 0?void 0:te(p);process.stdout.write(`${H(c.createElement(y,null," ",c.createElement(y,{color:z},Y),` ${a.packageName} ${a.currentRange} → ${a.newRange}`,c.createElement(y,{dimColor:!0},` ${a.updateType}`),O?c.createElement(y,{color:O},F):null),{columns:q})}
5
5
  `)}process.stdout.write(`
6
- `),s.info(P(n,g))}else if(S==="json"){const t={failed:$,outdated:n};u&&(t.aiAnalysis=u),process.stdout.write(`${JSON.stringify(t,void 0,2)}
7
- `)}else S==="minimal"?process.stdout.write(`${Z(n)}
8
- `):(_(n,s),s.info(P(n,g)),u&&(s.info(""),s.info(re(u))));e.exitCode&&n.length>0&&(process.exitCode=1)};export{ke as default};
6
+ `),s.info(j(n,v))}else if(S==="json"){const t={failed:$,outdated:n};u&&(t.aiAnalysis=u),process.stdout.write(`${JSON.stringify(t,void 0,2)}
7
+ `)}else S==="minimal"?process.stdout.write(`${oe(n)}
8
+ `):(ce(n,s),s.info(j(n,v)),u&&(s.info(""),s.info(Z(u))));e.exitCode&&n.length>0&&(process.exitCode=1)};export{$e as default};
@@ -1,4 +1,4 @@
1
- import{createRequire as K}from"node:module";import{j as g,F as m,q as v,J as N,X as P,b as j}from"../packem_shared/index.server-Ca_EEVfw.js";import{e as h,v as U}from"../packem_shared/index-BzhrR_iC.js";import{d as F,b as Y}from"./catalog.js";import{d as J}from"../packem_shared/lockfile-CiUtEbnt.js";import{p as z,s as X}from"../packem_shared/docker-DXqV-07f.js";import{i as ne}from"../packem_shared/index-BjdW45xX.js";import{g as B}from"../packem_shared/formatBytes-_HvjOy8a-B_qQr4Hw.js";import{h as oe}from"../packem_shared/writeFileSync-DJoHk3Ks-BPRoepNw.js";import{y as re}from"../packem_shared/isAccessibleSync-DYKTrrvc-C-_5cgwu.js";let G;const W=e=>(G??=K(import.meta.url))(e),b=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,y=e=>{if(typeof b<"u"&&b.versions&&b.versions.node){const[t,n]=b.versions.node.split(".").map(Number);if(t>22||t===22&&n>=3||t===20&&n>=16)return b.getBuiltinModule(e)}return W(e)},{createInterface:O}=y("node:readline"),{spawn:Q}=y("node:child_process"),{createHash:Z}=y("node:crypto"),{existsSync:I,writeFileSync:ee,chmodSync:te}=y("node:fs"),S={aube:{base:["RUN corepack enable"],build:e=>e?`RUN aube run --filter ${e} build`:"RUN aube run build",install:"RUN aube install --frozen-lockfile"},bun:{base:["RUN npm install -g bun"],build:e=>e?`RUN bun run --filter ${e} build`:"RUN bun run build",install:"RUN --mount=type=cache,target=/root/.bun/install/cache bun install --frozen-lockfile"},npm:{base:[],build:e=>e?`RUN npm run build --workspace ${e}`:"RUN npm run build",install:"RUN --mount=type=cache,target=/root/.npm npm ci"},pnpm:{base:["ENV PNPM_HOME=/pnpm","ENV PATH=$PNPM_HOME:$PATH","RUN corepack enable"],build:e=>e?`RUN pnpm --filter ${e} build`:"RUN pnpm build",install:"RUN --mount=type=cache,id=pnpm,target=/pnpm/store pnpm install --frozen-lockfile"},yarn:{base:["RUN corepack enable"],build:e=>e?`RUN yarn workspace ${e} build`:"RUN yarn build",install:"RUN --mount=type=cache,target=/usr/local/share/.cache/yarn yarn install --immutable"}},se=e=>{const{focus:t,manager:n,nodeVersion:r}=e,o=S[n]??S.npm;return["# syntax=docker/dockerfile:1","","# Generated by 'vis docker init'. Before building, scaffold the context:",`# vis docker scaffold${t?` --focus=${t}`:""} --include-sources`,"# then build with BuildKit enabled (DOCKER_BUILDKIT=1).","",`FROM node:${r}-slim AS base`,"WORKDIR /app",...o.base,"","# --- install dependencies from the scaffolded manifests only ---","FROM base AS deps","COPY .vis/docker/workspace/ ./",o.install,"","# --- build the focus project, then drop unfocused workspace projects ---","FROM deps AS build","COPY .vis/docker/sources/ ./",o.build(t),"RUN npx vis docker prune --context=.vis/docker","","# --- minimal runtime image ---",`FROM node:${r}-slim AS runtime`,"WORKDIR /app","ENV NODE_ENV=production","COPY --from=build /app ./","USER node","# TODO: point this at your app's entrypoint",'CMD ["node", "index.js"]',""].join(`
1
+ import{createRequire as K}from"node:module";import{j as g,F as m,q as v,J as N,X as P,b as j}from"../packem_shared/index.server-Ca_EEVfw.js";import{e as h,v as U}from"../packem_shared/index-BzhrR_iC.js";import{d as F,b as Y}from"../packem_shared/registry-Dg9XI6RT.js";import{d as J}from"../packem_shared/lockfile-CiUtEbnt.js";import{p as z,s as X}from"../packem_shared/docker-DXqV-07f.js";import{i as ne}from"../packem_shared/index-BjdW45xX.js";import{g as B}from"../packem_shared/env-BSXG3QKH.js";import{h as oe}from"../packem_shared/writeFileSync-DJoHk3Ks-BPRoepNw.js";import{y as re}from"../packem_shared/isAccessibleSync-DYKTrrvc-C-_5cgwu.js";let G;const W=e=>(G??=K(import.meta.url))(e),b=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,y=e=>{if(typeof b<"u"&&b.versions&&b.versions.node){const[t,n]=b.versions.node.split(".").map(Number);if(t>22||t===22&&n>=3||t===20&&n>=16)return b.getBuiltinModule(e)}return W(e)},{createInterface:O}=y("node:readline"),{spawn:Q}=y("node:child_process"),{createHash:Z}=y("node:crypto"),{existsSync:I,writeFileSync:ee,chmodSync:te}=y("node:fs"),S={aube:{base:["RUN corepack enable"],build:e=>e?`RUN aube run --filter ${e} build`:"RUN aube run build",install:"RUN aube install --frozen-lockfile"},bun:{base:["RUN npm install -g bun"],build:e=>e?`RUN bun run --filter ${e} build`:"RUN bun run build",install:"RUN --mount=type=cache,target=/root/.bun/install/cache bun install --frozen-lockfile"},npm:{base:[],build:e=>e?`RUN npm run build --workspace ${e}`:"RUN npm run build",install:"RUN --mount=type=cache,target=/root/.npm npm ci"},pnpm:{base:["ENV PNPM_HOME=/pnpm","ENV PATH=$PNPM_HOME:$PATH","RUN corepack enable"],build:e=>e?`RUN pnpm --filter ${e} build`:"RUN pnpm build",install:"RUN --mount=type=cache,id=pnpm,target=/pnpm/store pnpm install --frozen-lockfile"},yarn:{base:["RUN corepack enable"],build:e=>e?`RUN yarn workspace ${e} build`:"RUN yarn build",install:"RUN --mount=type=cache,target=/usr/local/share/.cache/yarn yarn install --immutable"}},se=e=>{const{focus:t,manager:n,nodeVersion:r}=e,o=S[n]??S.npm;return["# syntax=docker/dockerfile:1","","# Generated by 'vis docker init'. Before building, scaffold the context:",`# vis docker scaffold${t?` --focus=${t}`:""} --include-sources`,"# then build with BuildKit enabled (DOCKER_BUILDKIT=1).","",`FROM node:${r}-slim AS base`,"WORKDIR /app",...o.base,"","# --- install dependencies from the scaffolded manifests only ---","FROM base AS deps","COPY .vis/docker/workspace/ ./",o.install,"","# --- build the focus project, then drop unfocused workspace projects ---","FROM deps AS build","COPY .vis/docker/sources/ ./",o.build(t),"RUN npx vis docker prune --context=.vis/docker","","# --- minimal runtime image ---",`FROM node:${r}-slim AS runtime`,"WORKDIR /app","ENV NODE_ENV=production","COPY --from=build /app ./","USER node","# TODO: point this at your app's entrypoint",'CMD ["node", "index.js"]',""].join(`
2
2
  `)},$="v2.14.0",D=`https://github.com/hadolint/hadolint/releases/download/${$}`,ie={"hadolint-linux-arm64":"331f1d3511b84a4f1e3d18d52fec284723e4019552f4f47b19322a53ce9a40ed","hadolint-linux-x86_64":"6bf226944684f56c84dd014e8b979d27425c0148f61b3bd99bcc6f39e9dc5a47","hadolint-macos-arm64":"3625e2e9f43dcfe7bd38738a5f5520ed50ce39ed28485266e6803dd7bc197b10","hadolint-macos-x86_64":"2b69a853433f1eca522ffb921cd490bd1321424d03331fd8390f93b7fb4a02e9","hadolint-windows-x86_64.exe":"8e0ee174f88edb14f207a68430c7a53c2883ed509cdbde9a3a26fffa140fa5e4"},ae=e=>ie[e],ce=(e=process.platform,t=process.arch)=>{const n=e==="darwin"?"macos":e==="linux"?"linux":e==="win32"?"windows":void 0;if(n===void 0)return;const r=t==="arm64"?"arm64":t==="x64"?"x86_64":void 0;if(n==="windows")return"hadolint-windows-x86_64.exe";if(r!==void 0)return`hadolint-${n}-${r}`},L=e=>h(B(),"hadolint",$,e.endsWith(".exe")?"hadolint.exe":"hadolint"),le=()=>{const e=process.platform==="win32"?"hadolint.exe":"hadolint",t=(process.env.PATH??"").split(process.platform==="win32"?";":":");for(const n of t)if(n!==""&&I(h(n,e)))return e},de=e=>e.trim().split(/\s+/u)[0]??"",E=async e=>{const t=await fetch(e,{redirect:"follow"});if(!t.ok)throw new Error(`download failed (${String(t.status)} ${t.statusText}) for ${e}`);return Buffer.from(await t.arrayBuffer())},ue=async e=>{const t=L(e),n=ae(e),r=await E(`${D}/${e}`),o=Z("sha256").update(r).digest("hex");if(n===void 0){const s=await E(`${D}/${e}.sha256`),i=de(s.toString("utf8")).toLowerCase();if(i==="")throw new Error("hadolint checksum sidecar was empty or unparseable. Refusing to use the download.");if(i!==o)throw new Error(`hadolint checksum mismatch (expected ${i}, got ${o}). Refusing to use the download.`)}else if(n.toLowerCase()!==o)throw new Error(`hadolint checksum mismatch (expected ${n.toLowerCase()}, got ${o}). Refusing to use the download.`);return oe(h(B(),"hadolint",$)),ee(t,r),process.platform!=="win32"&&te(t,493),t},fe=async()=>{const e=O({input:process.stdin,output:process.stderr}),t=await new Promise(n=>{e.question(` Download hadolint ${v($)} now? ${m("[y/N]")} `,r=>{n(r.trim().toLowerCase())})});return e.close(),t==="y"||t==="yes"},pe=async e=>{const{autoInstall:t=!1,log:n}=e,r=le();if(r!==void 0)return r;const o=ce();if(o===void 0){n(`hadolint has no prebuilt binary for ${process.platform}/${process.arch}. Install it manually: https://github.com/hadolint/hadolint`);return}const s=L(o);if(I(s))return s;if(!t){if(!(!!process.stdin.isTTY&&!ne)){n(`hadolint is not installed. Re-run with ${g("--install")} (or install hadolint on PATH) to enable Dockerfile linting.`);return}if(n(`${g("hadolint")} is required to lint Dockerfiles but was not found on your PATH.`),!await fe()){n(`Skipped. Install it yourself or re-run with ${g("--install")}.`);return}}n(`Downloading hadolint ${$} (${o})…`);try{const i=await ue(o);return n(`Installed hadolint to ${m(i)}`),i}catch(i){n(`Failed to download hadolint: ${i.message}`);return}},_=async(e,t,n)=>{if(t.length===0)return[];const r=["--format","json","--no-fail",...n!==void 0&&n!==""?["--config",n]:[],...t],o=await new Promise((i,l)=>{const a=Q(e,r,{stdio:["ignore","pipe","pipe"],windowsHide:!0});let d="",u="";a.stdout?.on("data",c=>{d+=c.toString("utf8")}),a.stderr?.on("data",c=>{u+=c.toString("utf8")}),a.on("error",l),a.on("close",()=>{if(d.trim()===""&&u.trim()!==""){l(new Error(u.trim()));return}i(d)})});if(o.trim()==="")return[];let s;try{s=JSON.parse(o)}catch{throw new Error("Could not parse hadolint JSON output.")}return Array.isArray(s)?s:[]},C=(e,t,n)=>{if(!(!/\bapt-get\b/u.test(e)||!/\binstall\b/u.test(e)||n.test(e)))return e.replace(/\binstall\b/u,`install ${t}`)},k={DL3014:e=>C(e,"-y",/(?:^|\s)(?:-y|--yes|--assume-yes|-qq?)\b/u),DL3015:e=>C(e,"--no-install-recommends",/--no-install-recommends\b/u),DL3020:e=>/^\s*ADD\b/u.test(e)?e.replace(/^(\s*)ADD\b/u,"$1COPY"):void 0,DL3027:e=>/(?:^|\s)apt\s/u.test(e)&&!/\bapt-get\b/u.test(e)?e.replace(/(^|\s)apt(\s)/u,"$1apt-get$2"):void 0},T=new Set(Object.keys(k)),me=(e,t)=>{const n=e.includes(`\r
3
3
  `)?`\r
4
4
  `:`
@@ -1,3 +1,3 @@
1
- import{createRequire as H}from"node:module";import{J as A,q as G,j as W,F as E}from"../packem_shared/index.server-Ca_EEVfw.js";import{a as P}from"../packem_shared/index-BzhrR_iC.js";import{Z as I}from"./cli-main.js";import{w as Z,r as Q,a as X,s as Y,c as ee,b as te,d as se,e as ie,f as ne,g as re,h as ae,i as oe,j as ce,k as de,l as fe,m as le,n as ue}from"../packem_shared/watch-loop-D1_e-qIl.js";import{T as h}from"./catalog.js";import{d as C,f as _,a as pe}from"../packem_shared/detect-CbMRSXkM.js";let J;const U=e=>(J??=H(import.meta.url))(e),w=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,D=e=>{if(typeof w<"u"&&w.versions&&w.versions.node){const[t,s]=w.versions.node.split(".").map(Number);if(t>22||t===22&&s>=3||t===20&&s>=16)return w.getBuiltinModule(e)}return U(e)},{createHash:F}=D("node:crypto"),ge=e=>e.startsWith("/")||/^[a-z]:[\\/]/i.test(e),q=(e,t)=>ge(t)?t:`${e}/${t}`,me={argsCheck:(e,t)=>O(e,t,"check"),argsFix:(e,t)=>O(e,t,"fix"),bin:()=>["pnpm","exec","dprint"],cacheKey:(e,t)=>{const s=["dprint",e.declaredVersion??"unknown",e.configFile??"no-config",t.quiet?"q":"",...t.extraArgs??[]];return F("sha256").update(s.join("|")).digest("hex").slice(0,16)},detect:(e,t)=>{const s=C(t,h.dprint.packageNames[0]),i=_(e,h.dprint.configFiles);if(!(!s&&!i))return{adapter:"dprint",configFile:i,declared:!!s,declaredVersion:s,root:e}},extensions:["cjs","css","cts","dockerfile","html","js","json","jsonc","jsx","md","mdx","mjs","mts","toml","ts","tsx","yaml","yml"],id:"dprint",kind:"fmt",parse:(e,t)=>{if(e.exitCode===0)return[];const s=[];for(const i of e.stdout.split(/\r?\n/)){const n=i.trim();!n||n.startsWith("[")||n.startsWith("Checked ")||n.startsWith("Error:")||s.push({adapter:"dprint",file:q(t.root,n),fixable:!0,message:"Code style issues would be auto-fixed",severity:"info"})}return s}},O=(e,t,s)=>{const i=s==="fix"?["fmt"]:["check","--list-different"];return t.extraArgs?.length&&i.push(...t.extraArgs),i.push(...e),i},he={argsCheck:(e,t)=>V(e,t,"check"),argsFix:(e,t)=>V(e,t,"fix"),bin:()=>["pnpm","exec","oxfmt"],cacheKey:(e,t)=>{const s=["oxfmt",e.declaredVersion??"unknown",e.configFile??"no-config",t.quiet?"q":"",...t.extraArgs??[]];return F("sha256").update(s.join("|")).digest("hex").slice(0,16)},detect:(e,t)=>{const s=C(t,h.oxfmt.packageNames[0]),i=_(e,h.oxfmt.configFiles);if(!(!s&&!i))return{adapter:"oxfmt",configFile:i,declared:!!s,declaredVersion:s,root:e}},extensions:["cjs","cts","js","json","jsonc","jsx","mjs","mts","ts","tsx"],id:"oxfmt",kind:"fmt",parse:(e,t)=>{if(e.exitCode===0)return[];const s=[];for(const i of e.stdout.split(/\r?\n/)){const n=i.trim();!n||n.startsWith("[")||s.push({adapter:"oxfmt",file:q(t.root,n),fixable:!0,message:"Code style issues would be auto-fixed",severity:"info"})}return s}},V=(e,t,s)=>{const i=s==="fix"?["--write"]:["--list-different"];return t.extraArgs?.length&&i.push(...t.extraArgs),i.push(...e),i},xe={argsCheck:(e,t)=>N(e,t,"check"),argsFix:(e,t)=>N(e,t,"fix"),bin:()=>["pnpm","exec","prettier"],cacheKey:(e,t)=>{const s=["prettier",e.declaredVersion??"unknown",e.configFile??"no-config",t.quiet?"q":"",...t.extraArgs??[]];return F("sha256").update(s.join("|")).digest("hex").slice(0,16)},detect:(e,t)=>{const s=C(t,h.prettier.packageNames[0]),i=_(e,h.prettier.configFiles);if(!(!s&&!i))return{adapter:"prettier",configFile:i,declared:!!s,declaredVersion:s,root:e}},extensions:["cjs","css","cts","html","js","json","jsx","less","md","mdx","mjs","mts","scss","ts","tsx","vue","yaml","yml"],id:"prettier",kind:"fmt",parse:(e,t)=>{if(e.exitCode===0)return[];const s=[];for(const i of e.stdout.split(/\r?\n/)){const n=i.trim();n&&(n.startsWith("[")||s.push({adapter:"prettier",file:q(t.root,n),fixable:!0,message:"Code style issues would be auto-fixed",severity:"info"}))}return s}},N=(e,t,s)=>{const i=s==="fix"?["--write"]:["--list-different"];return t.quiet&&i.push("--log-level","warn"),t.extraArgs?.length&&i.push(...t.extraArgs),i.push(...e),i},we=[he,se,me,xe,ie],$e=async({logger:e,options:t,visConfig:s,workspaceRoot:i})=>{const n=i??process.cwd(),l=s?.fmt;Z(e,"fmt",l);const k=Q(we,l?.order),L=pe(n,k),x=X(L,k,"fmt").filter(({adapter:u})=>l?.adapters?.[u.id]?.enabled!==!1);if(x.length===0){e.warn("vis fmt: no formatter detected in this workspace (looked for: oxfmt, biome, dprint, prettier, ruff).");return}const R=u=>{const a=l?.adapters?.[u]?.extraArgs;return a&&a.length>0?[...a]:void 0},v={quiet:t.quiet??!1},$=ke(t),b=t.check?"check":"fix";let c;if(t.staged){if(c=Y(n),c===void 0)e.warn("vis fmt: could not resolve --staged (not a git repo or git unavailable). Falling back to a workspace-wide run.");else if(c.length===0){e.info(A("✓ fmt: no staged files"));return}}else if(typeof t.since=="string"&&t.since.length>0){if(c=ee(n,t.since),c===void 0)e.warn(`vis fmt: could not resolve --since ${t.since} (not a git repo or unknown ref). Falling back to a workspace-wide run.`);else if(c.length===0){e.info(A(`✓ fmt: no files changed since ${t.since}`));return}}const K=I(n,void 0,void 0,!0),y=t.format??"human";y==="human"&&t.output!==void 0&&e.warn("vis fmt: --output is ignored for the human format; pass --format json|minimal|sarif|junit|github to redirect findings to a file.");const M=async u=>{const a=$.length>0?$:u,g=[];if(a){const r=ne(a,x,l?.extensionOverrides);for(const{adapter:o,presence:d}of x){const f=r.get(o.id);if(!f||f.length===0)continue;const B=R(o.id),T={adapter:o,files:f,presence:d};B&&(T.options={...v,extraArgs:B}),g.push(T)}}else for(const{adapter:r,presence:o}of x){const d=R(r.id),f={adapter:r,files:["."],presence:o};d&&(f.options={...v,extraArgs:d}),g.push(f)}if(g.length===0)return;const z=await re(g,v,b,{cacheRoot:K}),j=g.map((r,o)=>{const d=z[o],f=r.adapter.parse(d,r.presence);return{adapter:r.adapter,durationMs:d.durationMs,exitCode:d.exitCode,findings:f}}),p=ae(j.map(r=>({adapter:r.adapter.id,durationMs:r.durationMs,exitCode:r.exitCode,findingCount:r.findings.length,findings:r.findings}))),m=y==="human"?void 0:oe({cwd:n,target:t.output});try{switch(y){case"github":{m.write(fe({runs:j.map(r=>({findings:r.findings})),workspaceRoot:n}));break}case"json":{m.write(`${JSON.stringify({findings:p.findings,mode:b,runs:p.runs},null,2)}
2
- `);break}case"junit":{m.write(de({runs:j.map(r=>({adapter:r.adapter.id,durationMs:r.durationMs,findings:r.findings})),workspaceRoot:n}));break}case"minimal":{je(p.findings,n,m);break}case"sarif":{m.write(ce({runs:j.map(r=>({adapter:r.adapter.id,findings:r.findings,presence:g.find(o=>o.adapter.id===r.adapter.id)?.presence})),workspaceRoot:n}));break}default:be(p.findings,n,b,e)}}finally{m?.close()}const S=b==="fix"?p.hadProcessFailure?1:0:le({...p,maxSeverity:p.findings.length>0?"error":void 0});S!==0&&(process.exitCode=S)};if(t.watch){const u=[...new Set(x.flatMap(({adapter:a})=>a.extensions))];await te({extensions:u,initialFiles:c,label:"fmt",log:a=>{e.info(a)},runCycle:M,workspaceRoot:n});return}await M(c)},ke=e=>{const t=e;return[...t._??t.args??[]]},be=(e,t,s,i)=>{if(e.length===0){i.info(A(s==="fix"?"✓ fmt: nothing to change":"✓ fmt: all files already formatted"));return}const n=ue(e),l=s==="fix"?G(W("Formatted:")):W("Would change:");i.info(l);for(const k of n.keys())i.info(` ${E("·")} ${P(t,k)}`);s==="check"&&(i.info(""),i.info(E(`Run \`vis fmt\` to apply changes (${String(n.size)} file${n.size===1?"":"s"}).`)))},je=(e,t,s)=>{for(const i of e)s.write(`${i.adapter} ${P(t,i.file)}
1
+ import{createRequire as H}from"node:module";import{J as A,q as G,j as E,F as O}from"../packem_shared/index.server-Ca_EEVfw.js";import{a as N}from"../packem_shared/index-BzhrR_iC.js";import{P as I}from"./cli-main.js";import{w as Q,r as X,a as Y,s as Z,c as ee,b as te,d as se,e as ie,f as ne,g as re,h as ae,i as oe,j as ce,k as de,l as fe,m as le,n as ue}from"../packem_shared/watch-loop-CGi66Fs0.js";import{s as h}from"../packem_shared/registry-Dg9XI6RT.js";import{d as C,f as _,a as pe}from"../packem_shared/detect-CbMRSXkM.js";let J;const U=e=>(J??=H(import.meta.url))(e),w=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,D=e=>{if(typeof w<"u"&&w.versions&&w.versions.node){const[t,s]=w.versions.node.split(".").map(Number);if(t>22||t===22&&s>=3||t===20&&s>=16)return w.getBuiltinModule(e)}return U(e)},{createHash:F}=D("node:crypto"),ge=e=>e.startsWith("/")||/^[a-z]:[\\/]/i.test(e),q=(e,t)=>ge(t)?t:`${e}/${t}`,me={argsCheck:(e,t)=>P(e,t,"check"),argsFix:(e,t)=>P(e,t,"fix"),bin:()=>["pnpm","exec","dprint"],cacheKey:(e,t)=>{const s=["dprint",e.declaredVersion??"unknown",e.configFile??"no-config",t.quiet?"q":"",...t.extraArgs??[]];return F("sha256").update(s.join("|")).digest("hex").slice(0,16)},detect:(e,t)=>{const s=C(t,h.dprint.packageNames[0]),i=_(e,h.dprint.configFiles);if(!(!s&&!i))return{adapter:"dprint",configFile:i,declared:!!s,declaredVersion:s,root:e}},extensions:["cjs","css","cts","dockerfile","html","js","json","jsonc","jsx","md","mdx","mjs","mts","toml","ts","tsx","yaml","yml"],id:"dprint",kind:"fmt",parse:(e,t)=>{if(e.exitCode===0)return[];const s=[];for(const i of e.stdout.split(/\r?\n/)){const n=i.trim();!n||n.startsWith("[")||n.startsWith("Checked ")||n.startsWith("Error:")||s.push({adapter:"dprint",file:q(t.root,n),fixable:!0,message:"Code style issues would be auto-fixed",severity:"info"})}return s}},P=(e,t,s)=>{const i=s==="fix"?["fmt"]:["check","--list-different"];return t.extraArgs?.length&&i.push(...t.extraArgs),i.push(...e),i},he={argsCheck:(e,t)=>T(e,t,"check"),argsFix:(e,t)=>T(e,t,"fix"),bin:()=>["pnpm","exec","oxfmt"],cacheKey:(e,t)=>{const s=["oxfmt",e.declaredVersion??"unknown",e.configFile??"no-config",t.quiet?"q":"",...t.extraArgs??[]];return F("sha256").update(s.join("|")).digest("hex").slice(0,16)},detect:(e,t)=>{const s=C(t,h.oxfmt.packageNames[0]),i=_(e,h.oxfmt.configFiles);if(!(!s&&!i))return{adapter:"oxfmt",configFile:i,declared:!!s,declaredVersion:s,root:e}},extensions:["cjs","cts","js","json","jsonc","jsx","mjs","mts","ts","tsx"],id:"oxfmt",kind:"fmt",parse:(e,t)=>{if(e.exitCode===0)return[];const s=[];for(const i of e.stdout.split(/\r?\n/)){const n=i.trim();!n||n.startsWith("[")||s.push({adapter:"oxfmt",file:q(t.root,n),fixable:!0,message:"Code style issues would be auto-fixed",severity:"info"})}return s}},T=(e,t,s)=>{const i=s==="fix"?["--write"]:["--list-different"];return t.extraArgs?.length&&i.push(...t.extraArgs),i.push(...e),i},xe={argsCheck:(e,t)=>V(e,t,"check"),argsFix:(e,t)=>V(e,t,"fix"),bin:()=>["pnpm","exec","prettier"],cacheKey:(e,t)=>{const s=["prettier",e.declaredVersion??"unknown",e.configFile??"no-config",t.quiet?"q":"",...t.extraArgs??[]];return F("sha256").update(s.join("|")).digest("hex").slice(0,16)},detect:(e,t)=>{const s=C(t,h.prettier.packageNames[0]),i=_(e,h.prettier.configFiles);if(!(!s&&!i))return{adapter:"prettier",configFile:i,declared:!!s,declaredVersion:s,root:e}},extensions:["cjs","css","cts","html","js","json","jsx","less","md","mdx","mjs","mts","scss","ts","tsx","vue","yaml","yml"],id:"prettier",kind:"fmt",parse:(e,t)=>{if(e.exitCode===0)return[];const s=[];for(const i of e.stdout.split(/\r?\n/)){const n=i.trim();n&&(n.startsWith("[")||s.push({adapter:"prettier",file:q(t.root,n),fixable:!0,message:"Code style issues would be auto-fixed",severity:"info"}))}return s}},V=(e,t,s)=>{const i=s==="fix"?["--write"]:["--list-different"];return t.quiet&&i.push("--log-level","warn"),t.extraArgs?.length&&i.push(...t.extraArgs),i.push(...e),i},we=[he,se,me,xe,ie],$e=async({logger:e,options:t,visConfig:s,workspaceRoot:i})=>{const n=i??process.cwd(),l=s?.fmt;Q(e,"fmt",l);const k=X(we,l?.order),L=pe(n,k),x=Y(L,k,"fmt").filter(({adapter:u})=>l?.adapters?.[u.id]?.enabled!==!1);if(x.length===0){e.warn("vis fmt: no formatter detected in this workspace (looked for: oxfmt, biome, dprint, prettier, ruff).");return}const R=u=>{const a=l?.adapters?.[u]?.extraArgs;return a&&a.length>0?[...a]:void 0},v={quiet:t.quiet??!1},$=ke(t),b=t.check?"check":"fix";let c;if(t.staged){if(c=Z(n),c===void 0)e.warn("vis fmt: could not resolve --staged (not a git repo or git unavailable). Falling back to a workspace-wide run.");else if(c.length===0){e.info(A("✓ fmt: no staged files"));return}}else if(typeof t.since=="string"&&t.since.length>0){if(c=ee(n,t.since),c===void 0)e.warn(`vis fmt: could not resolve --since ${t.since} (not a git repo or unknown ref). Falling back to a workspace-wide run.`);else if(c.length===0){e.info(A(`✓ fmt: no files changed since ${t.since}`));return}}const K=I(n,void 0,void 0,!0),y=t.format??"human";y==="human"&&t.output!==void 0&&e.warn("vis fmt: --output is ignored for the human format; pass --format json|minimal|sarif|junit|github to redirect findings to a file.");const M=async u=>{const a=$.length>0?$:u,g=[];if(a){const r=ne(a,x,l?.extensionOverrides);for(const{adapter:o,presence:d}of x){const f=r.get(o.id);if(!f||f.length===0)continue;const B=R(o.id),W={adapter:o,files:f,presence:d};B&&(W.options={...v,extraArgs:B}),g.push(W)}}else for(const{adapter:r,presence:o}of x){const d=R(r.id),f={adapter:r,files:["."],presence:o};d&&(f.options={...v,extraArgs:d}),g.push(f)}if(g.length===0)return;const z=await re(g,v,b,{cacheRoot:K}),j=g.map((r,o)=>{const d=z[o],f=r.adapter.parse(d,r.presence);return{adapter:r.adapter,durationMs:d.durationMs,exitCode:d.exitCode,findings:f}}),p=ae(j.map(r=>({adapter:r.adapter.id,durationMs:r.durationMs,exitCode:r.exitCode,findingCount:r.findings.length,findings:r.findings}))),m=y==="human"?void 0:oe({cwd:n,target:t.output});try{switch(y){case"github":{m.write(fe({runs:j.map(r=>({findings:r.findings})),workspaceRoot:n}));break}case"json":{m.write(`${JSON.stringify({findings:p.findings,mode:b,runs:p.runs},null,2)}
2
+ `);break}case"junit":{m.write(de({runs:j.map(r=>({adapter:r.adapter.id,durationMs:r.durationMs,findings:r.findings})),workspaceRoot:n}));break}case"minimal":{je(p.findings,n,m);break}case"sarif":{m.write(ce({runs:j.map(r=>({adapter:r.adapter.id,findings:r.findings,presence:g.find(o=>o.adapter.id===r.adapter.id)?.presence})),workspaceRoot:n}));break}default:be(p.findings,n,b,e)}}finally{m?.close()}const S=b==="fix"?p.hadProcessFailure?1:0:le({...p,maxSeverity:p.findings.length>0?"error":void 0});S!==0&&(process.exitCode=S)};if(t.watch){const u=[...new Set(x.flatMap(({adapter:a})=>a.extensions))];await te({extensions:u,initialFiles:c,label:"fmt",log:a=>{e.info(a)},runCycle:M,workspaceRoot:n});return}await M(c)},ke=e=>{const t=e;return[...t._??t.args??[]]},be=(e,t,s,i)=>{if(e.length===0){i.info(A(s==="fix"?"✓ fmt: nothing to change":"✓ fmt: all files already formatted"));return}const n=ue(e),l=s==="fix"?G(E("Formatted:")):E("Would change:");i.info(l);for(const k of n.keys())i.info(` ${O("·")} ${N(t,k)}`);s==="check"&&(i.info(""),i.info(O(`Run \`vis fmt\` to apply changes (${String(n.size)} file${n.size===1?"":"s"}).`)))},je=(e,t,s)=>{for(const i of e)s.write(`${i.adapter} ${N(t,i.file)}
3
3
  `)};export{$e as default};
@@ -1,4 +1,4 @@
1
- import{createRequire as re}from"node:module";import{F as d,j as y,q as v}from"../packem_shared/index.server-Ca_EEVfw.js";import{e as E,m as J,a as z,v as F,l as oe,U as ie}from"../packem_shared/index-BzhrR_iC.js";import{y as _}from"../packem_shared/isAccessibleSync-DYKTrrvc-C-_5cgwu.js";import{L as K}from"./catalog.js";import{p as f}from"./cli-main.js";import{d as de}from"../packem_shared/git-source-DExWbfN0.js";import{h as X,U as me}from"../packem_shared/writeFileSync-DJoHk3Ks-BPRoepNw.js";let se;const ne=t=>(se??=re(import.meta.url))(t),O=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,k=t=>{if(typeof O<"u"&&O.versions&&O.versions.node){const[e,r]=O.versions.node.split(".").map(Number);if(e>22||e===22&&r>=3||e===20&&r>=16)return O.getBuiltinModule(t)}return ne(t)},{fileURLToPath:ae}=k("node:url"),{createInterface:ce}=k("node:readline"),{mkdtempSync:le,rmSync:fe}=k("node:fs"),{tmpdir:ue}=k("node:os"),{spawnSync:pe}=k("node:child_process"),Y=[".ts",".mts",".cts",".js",".mjs",".cjs"],he="template.yml",ge=[".d",".test",".spec",".config",".bench",".stories"],we=[".d.ts",".d.mts",".d.cts",".js.map",".mjs.map",".cjs.map",".ts.map"],G=t=>{for(const e of Y)if(t.endsWith(e))return t.slice(0,-e.length);return t},$e=t=>{if(we.some(r=>t.endsWith(r))||!Y.some(r=>t.endsWith(r)))return!1;const e=G(t);return!ge.some(r=>e.endsWith(r))},U=(t,e)=>{const r=[];if(!_(t))return r;for(const n of K(t,{includeDirs:!1,includeSymlinks:!1,maxDepth:1})){if(!$e(n.name))continue;const s=G(n.name);r.push({load:()=>ve(n.path),name:s,path:n.path,source:e})}return r},R=(t,e)=>{const r=[];if(!_(t))return r;for(const n of K(t,{includeFiles:!1,includeSymlinks:!1,maxDepth:1})){if(n.path===t)continue;const s=E(n.path,he);_(s)&&r.push({load:()=>be(n.path,n.name),name:n.name,path:n.path,source:e})}return r},ye=()=>{try{const t=ae(import.meta.url),e=E(J(t),"..","..","templates");return _(e)?e:void 0}catch{return}},I=t=>{const{extraDirectories:e=[],onWarning:r,workspaceRoot:n}=t,s=[...U(E(n,".vis","templates"),"native"),...R(E(n,".vis","templates"),"moon"),...R(E(n,".moon","templates"),"moon")];for(const c of e)s.push(...R(c,"config")),s.push(...U(c,"config"));const i=ye();i&&s.push(...R(i,"builtin"));const a=new Map;for(const c of s){const o=a.get(c.name);if(!o){a.set(c.name,c);continue}r&&r(`Template "${c.name}" exists in multiple sources — using ${o.source} (${o.path}), ignoring ${c.source} (${c.path}).`)}return[...a.values()].sort((c,o)=>c.name.localeCompare(o.name))},ve=async t=>{const{loadNativeTemplate:e}=await import("./loader2.js");return e(t)},be=async(t,e)=>{const{loadMoonTemplate:r}=await import("./index6.js");return r(t,e)},q=(t,e)=>new Promise(r=>{t.question(e,n=>{r(n.trim())})}),Se=async(t,e,r)=>{const s=await q(t,` ${e} ${d(r?"[Y/n]":"[y/N]")} `);return s===""?r:s.toLowerCase()==="y"||s.toLowerCase()==="yes"},Ee=async(t,e,r,n)=>{process.stderr.write(` ${e}
1
+ import{createRequire as re}from"node:module";import{F as d,j as y,q as v}from"../packem_shared/index.server-Ca_EEVfw.js";import{e as E,m as J,a as z,v as F,l as oe,U as ie}from"../packem_shared/index-BzhrR_iC.js";import{y as _}from"../packem_shared/isAccessibleSync-DYKTrrvc-C-_5cgwu.js";import{L as K}from"../packem_shared/registry-Dg9XI6RT.js";import{p as f}from"./cli-main.js";import{d as de}from"../packem_shared/git-source-DExWbfN0.js";import{h as X,U as me}from"../packem_shared/writeFileSync-DJoHk3Ks-BPRoepNw.js";let se;const ne=t=>(se??=re(import.meta.url))(t),O=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,k=t=>{if(typeof O<"u"&&O.versions&&O.versions.node){const[e,r]=O.versions.node.split(".").map(Number);if(e>22||e===22&&r>=3||e===20&&r>=16)return O.getBuiltinModule(t)}return ne(t)},{fileURLToPath:ae}=k("node:url"),{createInterface:ce}=k("node:readline"),{mkdtempSync:le,rmSync:fe}=k("node:fs"),{tmpdir:ue}=k("node:os"),{spawnSync:pe}=k("node:child_process"),Y=[".ts",".mts",".cts",".js",".mjs",".cjs"],he="template.yml",ge=[".d",".test",".spec",".config",".bench",".stories"],we=[".d.ts",".d.mts",".d.cts",".js.map",".mjs.map",".cjs.map",".ts.map"],G=t=>{for(const e of Y)if(t.endsWith(e))return t.slice(0,-e.length);return t},$e=t=>{if(we.some(r=>t.endsWith(r))||!Y.some(r=>t.endsWith(r)))return!1;const e=G(t);return!ge.some(r=>e.endsWith(r))},U=(t,e)=>{const r=[];if(!_(t))return r;for(const n of K(t,{includeDirs:!1,includeSymlinks:!1,maxDepth:1})){if(!$e(n.name))continue;const s=G(n.name);r.push({load:()=>ve(n.path),name:s,path:n.path,source:e})}return r},R=(t,e)=>{const r=[];if(!_(t))return r;for(const n of K(t,{includeFiles:!1,includeSymlinks:!1,maxDepth:1})){if(n.path===t)continue;const s=E(n.path,he);_(s)&&r.push({load:()=>be(n.path,n.name),name:n.name,path:n.path,source:e})}return r},ye=()=>{try{const t=ae(import.meta.url),e=E(J(t),"..","..","templates");return _(e)?e:void 0}catch{return}},I=t=>{const{extraDirectories:e=[],onWarning:r,workspaceRoot:n}=t,s=[...U(E(n,".vis","templates"),"native"),...R(E(n,".vis","templates"),"moon"),...R(E(n,".moon","templates"),"moon")];for(const c of e)s.push(...R(c,"config")),s.push(...U(c,"config"));const i=ye();i&&s.push(...R(i,"builtin"));const a=new Map;for(const c of s){const o=a.get(c.name);if(!o){a.set(c.name,c);continue}r&&r(`Template "${c.name}" exists in multiple sources — using ${o.source} (${o.path}), ignoring ${c.source} (${c.path}).`)}return[...a.values()].sort((c,o)=>c.name.localeCompare(o.name))},ve=async t=>{const{loadNativeTemplate:e}=await import("./loader2.js");return e(t)},be=async(t,e)=>{const{loadMoonTemplate:r}=await import("./index7.js");return r(t,e)},q=(t,e)=>new Promise(r=>{t.question(e,n=>{r(n.trim())})}),Se=async(t,e,r)=>{const s=await q(t,` ${e} ${d(r?"[Y/n]":"[y/N]")} `);return s===""?r:s.toLowerCase()==="y"||s.toLowerCase()==="yes"},Ee=async(t,e,r,n)=>{process.stderr.write(` ${e}
2
2
  `);for(const[s,i]of r.entries()){const a=y(v(` ${String(s+1)}.`)),c=i===n?d(" (default)"):"";process.stderr.write(`${a} ${i}${c}
3
3
  `)}for(;;){const s=await q(t,`
4
4
  ${d(`Enter choice (1-${String(r.length)}):`)} `);if(s===""&&n!==void 0)return n;const i=Number.parseInt(s,10);if(Number.isInteger(i)&&i>=1&&i<=r.length)return r[i-1];const a=r.find(c=>c===s);if(a)return a;process.stderr.write(` ${d("Invalid choice. Try again.")}
@@ -1,9 +1,9 @@
1
- import{z as A,m as G,a as I,e as b}from"../packem_shared/index-BzhrR_iC.js";import x from"./index.js";import{d as U,E as F}from"./catalog.js";import{n as B}from"../packem_shared/manifests-Du4yKlf_.js";import{_ as E,$ as J}from"./cli-main.js";import{l as K}from"../packem_shared/glob-Cyk1H9ZL-Dxlf9Swz.js";import{U as R,h as M}from"../packem_shared/writeFileSync-DJoHk3Ks-BPRoepNw.js";import{T as q}from"../packem_shared/target-merge-DVJl-7Qz.js";const H=(e,t)=>{const n=t.replace(/^\.?\//,"");return n===""||n==="."?`/${e}/`:e===""||e==="."?`/${n}`:`/${e}/${n}`},N=(e,t,n=[])=>{const s=[],o=new Set;for(const[c,r]of Object.entries(t?.globalPaths??{}))s.push({owners:r,path:c,source:"project-json"}),o.add(c);for(const[c,r]of Object.entries(e.projects)){const a=r.owners??[];for(const f of a){const l=H(r.root??c,f.path);s.push({channel:f.channel,owners:f.owners,path:l,projectId:c,source:"project-json"}),o.add(l)}}for(const c of n)o.has(c.path)||(s.push(c),o.add(c.path));return(t?.orderBy??"file-source")==="project-id"?s.sort((c,r)=>(c.projectId??"").localeCompare(r.projectId??"")||c.path.localeCompare(r.path)):s.sort((c,r)=>c.path.localeCompare(r.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}`,""],D=e=>{const t=[];for(const n of e){const s=n.owners.join(" "),o=n.channel?` # notify: ${n.channel}`:"";t.push(`${n.path} ${s}${o}`)}return t},Q=(e,t={})=>[...Y(t.regenerationCommand),...D(e),""].join(`
1
+ import{z as _,m as G,a as R,e as b}from"../packem_shared/index-BzhrR_iC.js";import x from"./index.js";import{d as U,q as F}from"../packem_shared/registry-Dg9XI6RT.js";import{n as B}from"../packem_shared/manifests-Du4yKlf_.js";import{R as E,T as J}from"./cli-main.js";import{l as K}from"../packem_shared/glob-Cyk1H9ZL-CL9optrn.js";import{U as I,h as q}from"../packem_shared/writeFileSync-DJoHk3Ks-BPRoepNw.js";import{T as M}from"../packem_shared/target-merge-DVJl-7Qz.js";const H=(e,t)=>{const n=t.replace(/^\.?\//,"");return n===""||n==="."?`/${e}/`:e===""||e==="."?`/${n}`:`/${e}/${n}`},N=(e,t,n=[])=>{const s=[],o=new Set;for(const[c,r]of Object.entries(t?.globalPaths??{}))s.push({owners:r,path:c,source:"project-json"}),o.add(c);for(const[c,r]of Object.entries(e.projects)){const a=r.owners??[];for(const f of a){const l=H(r.root??c,f.path);s.push({channel:f.channel,owners:f.owners,path:l,projectId:c,source:"project-json"}),o.add(l)}}for(const c of n)o.has(c.path)||(s.push(c),o.add(c.path));return(t?.orderBy??"file-source")==="project-id"?s.sort((c,r)=>(c.projectId??"").localeCompare(r.projectId??"")||c.path.localeCompare(r.path)):s.sort((c,r)=>c.path.localeCompare(r.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}`,""],D=e=>{const t=[];for(const n of e){const s=n.owners.join(" "),o=n.channel?` # notify: ${n.channel}`:"";t.push(`${n.path} ${s}${o}`)}return t},Q=(e,t={})=>[...Y(t.regenerationCommand),...D(e),""].join(`
2
2
  `),O={begin:"# BEGIN vis-codeowners",end:"# END vis-codeowners"},X=(e,t=O,n={})=>{const s=n.regenerationCommand?`# Generated by vis sync codeowners — re-run with: ${n.regenerationCommand}`:"# Generated by `vis sync codeowners` — do not edit by hand.";return[t.begin,s,...D(e),t.end].join(`
3
3
  `)},Z=(e,t,n=O)=>{const s=e.indexOf(n.begin),o=e.indexOf(n.end);if(s!==-1&&o!==-1&&o>s){const r=e.slice(0,s),a=o+n.end.length,f=e.slice(a);return`${r}${t}${f}`}const i=e.replace(/\s+$/u,"");return`${i.length===0?"":`${i}
4
4
 
5
5
  `}${t}
6
- `},V=["**/CODEOWNERS"],ee=["**/node_modules/**","**/dist/**","**/build/**","**/coverage/**","**/.git/**","**/.next/**","**/.nuxt/**"],te=e=>{const t=[];for(const n of e.split(/\r?\n/u)){const s=n.indexOf("#"),o=(s===-1?n:n.slice(0,s)).trim();if(o.length===0)continue;const i=o.split(/\s+/u);if(i.length<2)continue;const[c,...r]=i,a=r.filter(f=>f.length>0);!c||a.length===0||t.push({owners:a,path:c})}return t},ne=(e,t)=>{const n=t.replace(/^\.\/?/,"").replace(/\/$/,"");return e.startsWith("/")?n===""?e:`/${n}${e}`:n===""?`/${e}`:`/${n}/${e}`},oe=async(e,t,n)=>{const s=t&&t.length>0?[...t]:[...V],o=[...ee];if(n){const r=n.replace(/^\.\/?/,"").replace(/^\/+/,"");r.length>0&&o.push(r)}const i=await K(s,{absolute:!0,cwd:e,ignore:o}),c=[];for(const r of i){let a;try{a=A(r)}catch{continue}const f=G(r),l=I(e,f);for(const p of te(a))c.push({owners:p.owners,path:ne(p.path,l)})}return c},re=/^(?:https?:\/\/)?(?:www\.)?github\.com\/([^/?#]+)/iu,se=e=>{if(!e)return;const t=e.match(re);if(!t?.[1])return;const n=t[1].trim();if(!(n===""||n.includes(" ")))return`@${n.replace(/^@/,"")}`},ce=(e,t)=>{const n=[];for(const[s,o]of Object.entries(e.projects)){if(o.owners&&o.owners.length>0)continue;const i=o.root??s,c=b(t,i,"package.json"),r=E(c);if(!r)continue;const a=B(r.maintainers);if(!a||a.length===0)continue;const f=[],l=new Set;for(const p of a){const y=se(p.url);y&&!l.has(y)&&(l.add(y),f.push(y))}f.length!==0&&n.push({owners:f,path:i===""||i==="."?"/":`/${i}/`,projectId:s})}return n},ie=["author","bugs","homepage","license","repository","engines"],v=e=>typeof e=="object"&&e!==null&&!Array.isArray(e),C=(e,t)=>{if(e===t)return!0;if(typeof e!=typeof t||e===null||t===null)return!1;if(Array.isArray(e)){if(!Array.isArray(t)||e.length!==t.length)return!1;for(const[n,s]of e.entries())if(!C(s,t[n]))return!1;return!0}if(typeof e=="object"&&typeof t=="object"){const n=Object.keys(e),s=Object.keys(t);if(n.length!==s.length)return!1;for(const o of n)if(!C(e[o],t[o]))return!1;return!0}return!1},P=e=>e===void 0?e:structuredClone(e),ae=(e,t,n)=>{if(e==="repository"&&v(t)&&v(n)){const s={};for(const[o,i]of Object.entries(t))o!=="directory"&&(s[o]=P(i));return typeof n.directory=="string"&&(s.directory=n.directory),s}return P(t)},de=(e,t,n)=>{const s=[];for(const o of n.fields){if(!Object.hasOwn(e,o))continue;const i=e[o],c=t[o],r=ae(o,i,c);C(r,c)||s.push({after:r,before:c,field:o,packageJsonPath:""})}return s},fe=(e,t)=>{for(const n of t)e[n.field]=n.after},L="Generated by `vis sync codeowners --write-guard`. Do not edit by hand.",le=e=>{const t=e.replace(/^\.?\/+/u,"").replace(/\/+$/u,"");return t===""||t==="."?"**":`${t}/**`},T=e=>{const t=new Set,n=[];for(const s of[...e].sort((o,i)=>o.name.localeCompare(i.name))){const o=le(s.root);t.has(o)||(t.add(o),n.push(o))}return n},ue=e=>{const t=T(e),n=t.map(o=>` - "${o}"`).join(`
6
+ `},V=["**/CODEOWNERS"],ee=["**/node_modules/**","**/dist/**","**/build/**","**/coverage/**","**/.git/**","**/.next/**","**/.nuxt/**"],te=e=>{const t=[];for(const n of e.split(/\r?\n/u)){const s=n.indexOf("#"),o=(s===-1?n:n.slice(0,s)).trim();if(o.length===0)continue;const i=o.split(/\s+/u);if(i.length<2)continue;const[c,...r]=i,a=r.filter(f=>f.length>0);!c||a.length===0||t.push({owners:a,path:c})}return t},ne=(e,t)=>{const n=t.replace(/^\.\/?/,"").replace(/\/$/,"");return e.startsWith("/")?n===""?e:`/${n}${e}`:n===""?`/${e}`:`/${n}/${e}`},oe=async(e,t,n)=>{const s=t&&t.length>0?[...t]:[...V],o=[...ee];if(n){const r=n.replace(/^\.\/?/,"").replace(/^\/+/,"");r.length>0&&o.push(r)}const i=await K(s,{absolute:!0,cwd:e,ignore:o}),c=[];for(const r of i){let a;try{a=_(r)}catch{continue}const f=G(r),l=R(e,f);for(const p of te(a))c.push({owners:p.owners,path:ne(p.path,l)})}return c},re=/^(?:https?:\/\/)?(?:www\.)?github\.com\/([^/?#]+)/iu,se=e=>{if(!e)return;const t=e.match(re);if(!t?.[1])return;const n=t[1].trim();if(!(n===""||n.includes(" ")))return`@${n.replace(/^@/,"")}`},ce=(e,t)=>{const n=[];for(const[s,o]of Object.entries(e.projects)){if(o.owners&&o.owners.length>0)continue;const i=o.root??s,c=b(t,i,"package.json"),r=E(c);if(!r)continue;const a=B(r.maintainers);if(!a||a.length===0)continue;const f=[],l=new Set;for(const p of a){const y=se(p.url);y&&!l.has(y)&&(l.add(y),f.push(y))}f.length!==0&&n.push({owners:f,path:i===""||i==="."?"/":`/${i}/`,projectId:s})}return n},ie=["author","bugs","homepage","license","repository","engines"],v=e=>typeof e=="object"&&e!==null&&!Array.isArray(e),C=(e,t)=>{if(e===t)return!0;if(typeof e!=typeof t||e===null||t===null)return!1;if(Array.isArray(e)){if(!Array.isArray(t)||e.length!==t.length)return!1;for(const[n,s]of e.entries())if(!C(s,t[n]))return!1;return!0}if(typeof e=="object"&&typeof t=="object"){const n=Object.keys(e),s=Object.keys(t);if(n.length!==s.length)return!1;for(const o of n)if(!C(e[o],t[o]))return!1;return!0}return!1},P=e=>e===void 0?e:structuredClone(e),ae=(e,t,n)=>{if(e==="repository"&&v(t)&&v(n)){const s={};for(const[o,i]of Object.entries(t))o!=="directory"&&(s[o]=P(i));return typeof n.directory=="string"&&(s.directory=n.directory),s}return P(t)},de=(e,t,n)=>{const s=[];for(const o of n.fields){if(!Object.hasOwn(e,o))continue;const i=e[o],c=t[o],r=ae(o,i,c);C(r,c)||s.push({after:r,before:c,field:o,packageJsonPath:""})}return s},fe=(e,t)=>{for(const n of t)e[n.field]=n.after},L="Generated by `vis sync codeowners --write-guard`. Do not edit by hand.",le=e=>{const t=e.replace(/^\.?\/+/u,"").replace(/\/+$/u,"");return t===""||t==="."?"**":`${t}/**`},T=e=>{const t=new Set,n=[];for(const s of[...e].sort((o,i)=>o.name.localeCompare(i.name))){const o=le(s.root);t.has(o)||(t.add(o),n.push(o))}return n},ue=e=>{const t=T(e),n=t.map(o=>` - "${o}"`).join(`
7
7
  `),s=t.map(o=>` ${o}`).join(`
8
8
  `);return`# ${L}
9
9
  name: Write Guard
@@ -57,5 +57,5 @@ ${n}
57
57
  code-owner approval. Enable 'Require approval from Code Owners' on the
58
58
  protected branch (GitLab Premium/Ultimate) for a real merge gate:
59
59
  https://docs.gitlab.com/ee/user/project/codeowners/"
60
- `},he=e=>e.length===0?[]:[{content:ue(e),path:".github/workflows/write-guard.yml"},{content:pe(e),path:".gitlab/write-guard.gitlab-ci.yml"}],W=new Set(["nested-codeowners","package-json-maintainers","project-json"]),_=(e,t,n)=>{const s=new Set,o=[];for(const i of e??[])for(const c of i.split(",")){const r=c.trim();if(r.length===0)continue;if(n&&!n(r))throw new Error(`Unknown codeowners source: "${r}". Known: ${[...W].join(", ")}.`);const a=r;s.has(a)||(s.add(a),o.push(a))}return o.length>0?o:[...t]},ge=e=>W.has(e),S=["codeowners","package-json-fields"],me=(e,t)=>t.some(n=>x(n,e)),we=async(e,t,n,s,o)=>{const i=Object.entries(s.projects).filter(([,r])=>r.restricted===!0).map(([r,a])=>({name:r,root:a.root??r})),c=he(i);if(c.length===0){t.info("No projects flagged `restricted: true` in project.json. Skipping Write Guard.");return}if(o){let r=!1;for(const a of c){const f=b(n,a.path);let l="";try{l=await e.readFile(f,"utf8")}catch(p){if(p.code!=="ENOENT")throw p}l.trim()!==a.content.trim()&&(t.error(`${a.path} is out of date. Run \`vis sync codeowners --write-guard\` to update it.`),r=!0)}r?process.exitCode=1:t.info(`Write Guard CI is up to date (${c.length} files, ${i.length} restricted projects).`);return}for(const r of c){const a=b(n,r.path);M(G(a)),R(a,r.content),t.info(`Wrote ${r.path}`)}t.info(`Write Guard CI scoped to ${i.length} restricted project${i.length===1?"":"s"}.`)},ye=async({fs:e,logger:t,options:n,visConfig:s,workspaceRoot:o})=>{const i=o,{workspace:c}=U(i,s),r=s?.codeowners;n.writeGuard&&await we(e,t,i,c,n.check);const a=_(n.from,r?.sources??["project-json"],ge),f=n.regenerationCommand??r?.regenerationCommand,l=n.preserveBlock||r?.preserveBlock===!0,p=r?.blockMarker??O,y=n.nestedIncludes??r?.nestedIncludes,g=n.out??"CODEOWNERS",w=[];if(a.includes("nested-codeowners")){const m=await oe(i,y,g);for(const j of m)w.push({...j,source:"nested"})}if(a.includes("package-json-maintainers")){const m=ce(c,i);for(const j of m)w.push({...j,source:"maintainers"})}const u=a.includes("project-json")?N(c,r,w):N({projects:{}},r,w);if(u.length===0){t.info("No `owners` entries found in any source. Nothing to sync.");return}const $=b(i,g);let d="";try{d=await e.readFile($,"utf8")}catch(m){if(m.code!=="ENOENT")throw m}const h={regenerationCommand:f},k=l?Z(d,X(u,p,h),p):Q(u,h);if(n.check){if(d.trim()!==k.trim()){t.error(`${$} is out of date. Run \`vis sync codeowners\` to update it.`),process.exitCode=1;return}t.info(`${$} is up to date.`);return}R($,k),t.info(`Wrote ${u.length} entries to ${$}`)},ke=({logger:e,options:t,visConfig:n,workspaceRoot:s})=>{const o=s,i=n?.editorconfig??!0,c=E(b(o,"package.json"));if(!c){e.error("Could not read root package.json. Nothing to sync."),process.exitCode=1;return}const r=_(t.fields,ie),a=t.ignorePackageName??[],f=t.check,l=(t.format??"human").toLowerCase(),{quiet:p}=t,y=J(o).filter(d=>d!=="."),g=[];let w=0;for(const d of y){const h=b(o,d,"package.json"),k=E(h);if(!k)continue;const m=typeof k.name=="string"?k.name:void 0;if(m!==void 0&&a.length>0&&me(m,a))continue;w+=1;const j=de(c,k,{fields:r});j.length!==0&&g.push({filePath:h,packageJsonPath:I(o,h),packageName:m,pkg:k,pkgChanges:j})}if(!f)for(const d of g)fe(d.pkg,d.pkgChanges),q(d.filePath,d.pkg,{indent:F(d.filePath,{useEditorconfig:i}),overwrite:!0});const u=g.flatMap(d=>d.pkgChanges.map(h=>({after:h.after,before:h.before,field:h.field,packageJsonPath:d.packageJsonPath,packageName:d.packageName}))),$={changes:u,fields:r,kind:"package-json-fields",mode:f?"check":"write",totalChanges:u.length,totalPackages:w};if(l==="json")process.stdout.write(`${JSON.stringify($,null,4)}
60
+ `},he=e=>e.length===0?[]:[{content:ue(e),path:".github/workflows/write-guard.yml"},{content:pe(e),path:".gitlab/write-guard.gitlab-ci.yml"}],W=new Set(["nested-codeowners","package-json-maintainers","project-json"]),A=(e,t,n)=>{const s=new Set,o=[];for(const i of e??[])for(const c of i.split(",")){const r=c.trim();if(r.length===0)continue;if(n&&!n(r))throw new Error(`Unknown codeowners source: "${r}". Known: ${[...W].join(", ")}.`);const a=r;s.has(a)||(s.add(a),o.push(a))}return o.length>0?o:[...t]},ge=e=>W.has(e),S=["codeowners","package-json-fields"],me=(e,t)=>t.some(n=>x(n,e)),we=async(e,t,n,s,o)=>{const i=Object.entries(s.projects).filter(([,r])=>r.restricted===!0).map(([r,a])=>({name:r,root:a.root??r})),c=he(i);if(c.length===0){t.info("No projects flagged `restricted: true` in project.json. Skipping Write Guard.");return}if(o){let r=!1;for(const a of c){const f=b(n,a.path);let l="";try{l=await e.readFile(f,"utf8")}catch(p){if(p.code!=="ENOENT")throw p}l.trim()!==a.content.trim()&&(t.error(`${a.path} is out of date. Run \`vis sync codeowners --write-guard\` to update it.`),r=!0)}r?process.exitCode=1:t.info(`Write Guard CI is up to date (${c.length} files, ${i.length} restricted projects).`);return}for(const r of c){const a=b(n,r.path);q(G(a)),I(a,r.content),t.info(`Wrote ${r.path}`)}t.info(`Write Guard CI scoped to ${i.length} restricted project${i.length===1?"":"s"}.`)},ye=async({fs:e,logger:t,options:n,visConfig:s,workspaceRoot:o})=>{const i=o,{workspace:c}=U(i,s),r=s?.codeowners;n.writeGuard&&await we(e,t,i,c,n.check);const a=A(n.from,r?.sources??["project-json"],ge),f=n.regenerationCommand??r?.regenerationCommand,l=n.preserveBlock||r?.preserveBlock===!0,p=r?.blockMarker??O,y=n.nestedIncludes??r?.nestedIncludes,g=n.out??"CODEOWNERS",w=[];if(a.includes("nested-codeowners")){const m=await oe(i,y,g);for(const j of m)w.push({...j,source:"nested"})}if(a.includes("package-json-maintainers")){const m=ce(c,i);for(const j of m)w.push({...j,source:"maintainers"})}const u=a.includes("project-json")?N(c,r,w):N({projects:{}},r,w);if(u.length===0){t.info("No `owners` entries found in any source. Nothing to sync.");return}const $=b(i,g);let d="";try{d=await e.readFile($,"utf8")}catch(m){if(m.code!=="ENOENT")throw m}const h={regenerationCommand:f},k=l?Z(d,X(u,p,h),p):Q(u,h);if(n.check){if(d.trim()!==k.trim()){t.error(`${$} is out of date. Run \`vis sync codeowners\` to update it.`),process.exitCode=1;return}t.info(`${$} is up to date.`);return}I($,k),t.info(`Wrote ${u.length} entries to ${$}`)},ke=({logger:e,options:t,visConfig:n,workspaceRoot:s})=>{const o=s,i=n?.editorconfig??!0,c=E(b(o,"package.json"));if(!c){e.error("Could not read root package.json. Nothing to sync."),process.exitCode=1;return}const r=A(t.fields,ie),a=t.ignorePackageName??[],f=t.check,l=(t.format??"human").toLowerCase(),{quiet:p}=t,y=J(o).filter(d=>d!=="."),g=[];let w=0;for(const d of y){const h=b(o,d,"package.json"),k=E(h);if(!k)continue;const m=typeof k.name=="string"?k.name:void 0;if(m!==void 0&&a.length>0&&me(m,a))continue;w+=1;const j=de(c,k,{fields:r});j.length!==0&&g.push({filePath:h,packageJsonPath:R(o,h),packageName:m,pkg:k,pkgChanges:j})}if(!f)for(const d of g)fe(d.pkg,d.pkgChanges),M(d.filePath,d.pkg,{indent:F(d.filePath,{useEditorconfig:i}),overwrite:!0});const u=g.flatMap(d=>d.pkgChanges.map(h=>({after:h.after,before:h.before,field:h.field,packageJsonPath:d.packageJsonPath,packageName:d.packageName}))),$={changes:u,fields:r,kind:"package-json-fields",mode:f?"check":"write",totalChanges:u.length,totalPackages:w};if(l==="json")process.stdout.write(`${JSON.stringify($,null,4)}
61
61
  `);else if(u.length===0)e.info(`All ${w} package${w===1?"":"s"} in sync (fields: ${r.join(", ")}).`);else if(f){if(!p)for(const d of u)e.error(`${d.packageJsonPath}: ${d.field} drifts from root`);e.error(`Found ${u.length} field drift${u.length===1?"":"s"} across ${g.length} package${g.length===1?"":"s"}. Run \`vis sync package-json-fields\` to fix.`)}else{if(!p)for(const d of g)e.info(`${d.packageJsonPath}: synced ${d.pkgChanges.map(h=>h.field).join(", ")}`);e.info(`Synced ${u.length} field${u.length===1?"":"s"} across ${g.length} package${g.length===1?"":"s"}.`)}f&&u.length>0&&(process.exitCode=1)},Pe=async e=>{const t=e.argument[0];if(!t)throw new Error(`Missing sync kind. Usage: vis sync <kind> (known kinds: ${S.join(", ")})`);if(!e.workspaceRoot)throw new Error("Could not determine workspace root. Run inside a monorepo.");if(t==="codeowners"){await ye(e);return}if(t==="package-json-fields"){ke(e);return}throw new Error(`Unknown sync kind: "${t}". Known kinds: ${S.join(", ")}.`)};export{Pe as default};
@@ -1,6 +1,6 @@
1
- import{a as B,z as J,e as I,$ as K,U as q}from"../packem_shared/index-BzhrR_iC.js";import{U as Y,V as z,W as V,T as Z,C as Q,p as E,q as ee}from"./cli-main.js";import{i as re}from"../packem_shared/index-BjdW45xX.js";import{F as t,X as u,o as a,x as R,R as te,z as se,H as ne,J as oe,K as ie,k as ce,l as A}from"./catalog.js";import le from"./index.js";import{sortPackageJsonStringWithOptions as U}from"#native";import{e as C}from"../packem_shared/utils-DQFHJn72.js";import{y as L}from"../packem_shared/isAccessibleSync-DYKTrrvc-C-_5cgwu.js";const _={error:0,rewritten:1,"would-rewrite":1,unchanged:2},ae=e=>[...e].sort((r,s)=>_[r.status]-_[s.status]),de=(e,r)=>r==="all"?e:r==="errors"?e.filter(s=>s.status==="error"):r==="rewritten"?e.filter(s=>s.status==="rewritten"||s.status==="would-rewrite"):e.filter(s=>s.status==="unchanged");class ue{#e;#r=new Set;constructor(r){this.#e={entries:ae(r),filterType:"all",focusedPanel:"list",selectedIndex:0}}getSnapshot=()=>this.#e;subscribe=r=>(this.#r.add(r),()=>{this.#r.delete(r)});getFilteredEntries=()=>de(this.#e.entries,this.#e.filterType);#t(){this.#e={...this.#e};for(const r of this.#r)r()}select(r){const s=this.getFilteredEntries();this.#e.selectedIndex=s.length===0?-1:Math.max(0,Math.min(r,s.length-1)),this.#t()}selectStep(r){this.select(this.#e.selectedIndex+r)}setFilter(r){this.#e.filterType=r,this.#e.selectedIndex=0,this.#t()}setFocusedPanel(r){this.#e.focusedPanel=r,this.#t()}}const fe=({checkMode:e,entry:r,focused:s,scrollRef:c})=>{const o=s?"white":"gray";return r?t.jsxs(u,{borderColor:o,borderStyle:"single",flexDirection:"column",flexGrow:1,children:[t.jsx(u,{flexShrink:0,paddingTop:1,paddingX:2,children:t.jsx(a,{bold:!0,color:"white",children:r.relativePath})}),t.jsxs(Y,{flexGrow:1,flexShrink:1,paddingX:2,ref:c,scrollbar:!0,scrollbarColor:"gray",children:[t.jsx(a,{}),t.jsxs(u,{children:[t.jsx(u,{width:10,children:t.jsx(a,{dimColor:!0,children:"Status:"})}),r.status==="error"?t.jsx(a,{bold:!0,color:"red",children:"error"}):r.status==="unchanged"?t.jsx(a,{bold:!0,color:"green",children:"already sorted"}):r.status==="rewritten"?t.jsx(a,{bold:!0,color:"yellow",children:"rewritten"}):t.jsx(a,{bold:!0,color:"yellow",children:"would rewrite (--check)"})]}),t.jsxs(u,{children:[t.jsx(u,{width:10,children:t.jsx(a,{dimColor:!0,children:"Path:"})}),t.jsx(a,{children:r.filePath})]}),r.error?t.jsxs(t.Fragment,{children:[t.jsxs(u,{flexDirection:"column",marginTop:1,children:[t.jsx(a,{dimColor:!0,children:"── "}),t.jsx(a,{bold:!0,color:"red",children:"ERROR"}),t.jsxs(u,{flexDirection:"column",marginTop:1,paddingLeft:2,children:[t.jsxs(u,{children:[t.jsx(u,{width:10,children:t.jsx(a,{dimColor:!0,children:"Step:"})}),t.jsx(a,{color:"yellow",children:r.error.step})]}),r.error.context&&t.jsxs(u,{children:[t.jsx(u,{width:10,children:t.jsx(a,{dimColor:!0,children:"Position:"})}),t.jsx(a,{children:`line ${String(r.error.context.line)}, column ${String(r.error.context.column)}`})]}),t.jsx(u,{marginTop:1,children:t.jsx(a,{color:"red",children:r.error.message})})]})]}),r.error.context&&r.error.context.snippet.length>0&&t.jsxs(u,{flexDirection:"column",marginTop:1,children:[t.jsx(a,{dimColor:!0,children:"── "}),t.jsx(a,{bold:!0,color:"white",children:"SNIPPET"}),t.jsxs(u,{flexDirection:"column",marginTop:1,paddingLeft:2,children:[r.error.context.snippet.map(n=>{const i=`${n.isErrorLine?"❯":" "} ${String(n.lineNumber).padStart(4)} `;return t.jsxs(u,{children:[t.jsx(a,{color:n.isErrorLine?"red":"gray",children:i}),t.jsx(a,{color:n.isErrorLine?"white":"gray",wrap:"truncate-end",children:n.content||" "})]},n.lineNumber)}),r.error.context.column>0&&t.jsx(u,{children:t.jsx(a,{color:"red",children:`${" ".repeat(7+r.error.context.column-1)}↑`})})]})]})]}):t.jsxs(u,{flexDirection:"column",marginTop:1,children:[t.jsx(a,{dimColor:!0,children:"── "}),t.jsx(a,{bold:!0,color:"white",children:"KEY DIFF"}),t.jsx(u,{flexDirection:"column",marginTop:1,paddingLeft:2,children:r.diff.length===0?t.jsx(a,{dimColor:!0,children:"No top-level keys moved (sub-key reorder only)."}):r.diff.map(n=>{const i=n.toIndex-n.fromIndex,d=i<0?`↑ ${String(Math.abs(i))}`:`↓ ${String(i)}`,f=i<0?"green":"yellow";return t.jsxs(u,{children:[t.jsx(u,{width:28,children:t.jsx(a,{wrap:"truncate",children:n.key})}),t.jsx(u,{width:10,children:t.jsxs(a,{dimColor:!0,children:[String(n.fromIndex)," → ",String(n.toIndex)]})}),t.jsx(a,{color:f,children:d})]},n.key)})}),e&&r.status==="would-rewrite"&&t.jsx(u,{marginTop:1,paddingLeft:2,children:t.jsx(a,{dimColor:!0,children:"--check mode: no write performed."})})]})]})]}):t.jsx(u,{alignItems:"center",borderColor:"gray",borderStyle:"single",flexDirection:"column",flexGrow:1,justifyContent:"center",children:t.jsx(a,{dimColor:!0,children:"No entry selected"})})},he={error:"red",rewritten:"yellow",unchanged:"green","would-rewrite":"yellow"},ge={error:"ERROR",rewritten:"REWROTE",unchanged:"SORTED","would-rewrite":"REWRITE"},W={error:"errors",rewritten:"rewrites",unchanged:"sorted","would-rewrite":"rewrites"},xe={errors:"Errors",rewrites:"Rewrites",sorted:"Sorted"},pe=[{count:e=>e.errors+e.rewrites+e.sorted,key:"all",label:"All",shortcut:"1"},{count:e=>e.rewrites,key:"rewritten",label:"Rewrites",shortcut:"2"},{count:e=>e.errors,key:"errors",label:"Errors",shortcut:"3"},{count:e=>e.sorted,key:"unchanged",label:"Sorted",shortcut:"4"}],H=e=>{const r={errors:0,rewrites:0,sorted:0};for(const s of e)r[W[s.status]]++;return r},me=({entry:e,isSelected:r})=>{const s=he[e.status],c=ge[e.status];return t.jsxs(u,{flexShrink:0,height:1,children:[t.jsx(a,{children:r?">":" "}),t.jsx(a,{children:" "}),t.jsx(a,{bold:!0,color:s,children:`[${c}]`.padEnd(10)}),t.jsx(a,{children:" "}),t.jsx(u,{flexGrow:1,children:t.jsx(a,{bold:r,inverse:r,wrap:"truncate",children:e.relativePath})}),e.status!=="error"&&e.diff.length>0&&t.jsx(a,{dimColor:!0,children:` ${String(e.diff.length)} key${e.diff.length===1?"":"s"}`})]})},je=({color:e,count:r,label:s})=>t.jsx(u,{flexShrink:0,height:1,children:t.jsx(a,{bold:!0,color:e,children:`${s} (${String(r)})`})}),Se=({counts:e,entries:r,filterType:s,focused:c,selectedIndex:o,totalEntries:n,viewportHeight:i})=>{const d=c?"white":"gray",f=H(r),x=(f.errors>0?1:0)+(f.rewrites>0?1:0)+(f.sorted>0?1:0),m=s==="all"&&x>1,h=[];let j;for(const[l,g]of r.entries()){const k=W[g.status];m&&k!==j&&(j!==void 0&&h.push({kind:"spacer"}),h.push({color:k==="errors"?"red":k==="rewrites"?"yellow":"green",count:f[k],kind:"header",label:xe[k]}),j=k),h.push({entry:g,entryIndex:l,kind:"entry"})}const p=h.findIndex(l=>l.kind==="entry"&&l.entryIndex===o),y=p!==-1,S=h.length,w=Math.max(0,S-i);let b=0;y&&i>0&&(b=Math.min(w,Math.max(0,p-i+1)));const O=S>i&&i>0;return t.jsxs(u,{borderColor:d,borderStyle:"single",flexDirection:"column",flexGrow:1,children:[t.jsxs(u,{flexShrink:0,gap:1,paddingX:1,children:[t.jsx(a,{bold:!0,inverse:!0,children:" VIS SORT "}),t.jsxs(a,{wrap:"truncate",children:[n," ","file",n===1?"":"s"]})]}),t.jsx(u,{flexShrink:0,gap:1,paddingX:1,paddingY:1,children:pe.map(l=>{const g=s===l.key,k=l.count(e);return t.jsxs(u,{children:[t.jsx(a,{dimColor:!g,children:"["}),t.jsx(a,{bold:g,color:g?"cyan":"gray",children:l.shortcut}),t.jsx(a,{dimColor:!g,children:"]"}),t.jsxs(a,{color:g?"white":"gray",children:[" ",l.label]}),t.jsxs(a,{dimColor:!0,children:[" ","(",k,")"]})]},l.key)})}),t.jsxs(u,{flexDirection:"row",flexGrow:1,overflow:"hidden",children:[t.jsx(u,{flexDirection:"column",flexGrow:1,overflow:"hidden",paddingLeft:1,children:t.jsx(u,{flexDirection:"column",marginTop:-b,children:h.map((l,g)=>l.kind==="spacer"?t.jsx(u,{flexShrink:0,height:1},`s-${String(g)}`):l.kind==="header"?t.jsx(je,{color:l.color,count:l.count,label:l.label},`h-${l.label}`):t.jsx(me,{entry:l.entry,isSelected:l.entryIndex===o},l.entry.filePath))})}),O&&t.jsx(u,{flexShrink:0,marginLeft:1,marginRight:1,children:t.jsx(z,{contentHeight:S,placement:"inset",scrollOffset:b,style:"block",viewportHeight:i})})]})]})},we=100,D=10,ye=6,ke=1,F={1:"all",2:"rewritten",3:"errors",4:"unchanged"},Ee=({checkMode:e,store:r})=>{const{exit:s}=V(),{columns:c,rows:o}=Z(),n=R.useSyncExternalStore(r.subscribe,r.getSnapshot),i=R.useRef(null),d=r.getFilteredEntries(),f=d[n.selectedIndex]??null,x=H(n.entries),m=c>=we,h=Math.max(0,o-ke),j=m?h:Math.floor(h/2),p=Math.max(0,j-ye),y=R.useCallback(()=>{s()},[s]),S=R.useRef(0),w=R.useRef(void 0),b=R.useRef(!1),O=R.useCallback((l,g)=>{S.current+=g,w.current=l,!b.current&&(b.current=!0,queueMicrotask(()=>{b.current=!1;const k=S.current,N=w.current;S.current=0,w.current=void 0,!(k===0||N===void 0)&&(N==="list"?r.selectStep(Math.sign(k)):i.current?.scrollBy(Math.sign(k)))}))},[r]);return Q((l,g)=>{if(l==="q"||g.escape){y();return}if(F[l]){r.setFilter(F[l]);return}if(g.tab){r.setFocusedPanel(n.focusedPanel==="list"?"detail":"list");return}n.focusedPanel==="list"?g.upArrow||l==="k"?O("list",-1):(g.downArrow||l==="j")&&O("list",1):n.focusedPanel==="detail"&&(g.upArrow||l==="k"?O("detail",-1):(g.downArrow||l==="j")&&O("detail",1))}),o<D?t.jsx(u,{alignItems:"center",justifyContent:"center",children:t.jsxs(a,{color:"yellow",children:["Terminal too small. Resize to at least",D," ","rows."]})}):t.jsxs(u,{flexDirection:"column",height:o,width:c,children:[t.jsxs(u,{flexDirection:m?"row":"column",flexGrow:1,children:[t.jsx(u,{flexBasis:"50%",flexGrow:1,flexShrink:1,children:t.jsx(Se,{counts:x,entries:d,filterType:n.filterType,focused:n.focusedPanel==="list",selectedIndex:n.selectedIndex,totalEntries:n.entries.length,viewportHeight:p})}),t.jsx(u,{flexBasis:"50%",flexGrow:1,flexShrink:1,children:t.jsx(fe,{checkMode:e,entry:f,focused:n.focusedPanel==="detail",scrollRef:i})})]}),t.jsx(u,{flexShrink:0,paddingX:1,children:t.jsx(a,{dimColor:!0,children:"↑/↓ or j/k:navigate | tab:switch panel | 1-4:filter | q:quit"})})]})},M=["types","node-addons","node","import","require","default"],be=/^git\+https:\/\/github\.com\/([^/]+)\/([^/.]+(?:\.git)?)$/,Oe=/^git\+ssh:\/\/git@github\.com\/([^/]+)\/([^/.]+(?:\.git)?)$/,T=e=>typeof e=="object"&&e!==null&&!Array.isArray(e),$=e=>{if(e===null||typeof e!="object")return e;if(Array.isArray(e))return e.map(s=>$(s));const r={};for(const[s,c]of Object.entries(e))r[s]=$(c);return r},Re=e=>{if(!T(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}},Ie=e=>e.endsWith(".git")?e.slice(0,-4):e,Ce=e=>{if(!T(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 c=be.exec(s)??Oe.exec(s);if(!c)return{changed:!1,value:e};const o=c[1],n=Ie(c[2]??"");if(!o||!n)return{changed:!1,value:e};const i=new Set(["type","url"]);for(const d of Object.keys(e))if(!i.has(d))return{changed:!1,value:e};return{changed:!0,value:`${o}/${n}`}},Te=e=>{const r=Object.keys(e),s=[],c=[];for(const d of M)Object.hasOwn(e,d)&&s.push(d);for(const d of r)M.includes(d)||c.push(d);const o=[...s,...c];if(o.length===r.length&&o.every((d,f)=>d===r[f]))return{changed:!1,value:e};const i={};for(const d of o)i[d]=e[d];return{changed:!0,value:i}},X=e=>{if(!T(e))return{changed:!1,value:e};let r=!1;const s={};for(const[o,n]of Object.entries(e)){const i=X(n);s[o]=i.value,i.changed&&(r=!0)}const c=Te(s);return{changed:r||c.changed,value:c.value}},Pe=(e,r)=>{const s=$(e);let c=!1;if(r.formatBugs!==!1&&Object.hasOwn(s,"bugs")){const o=Re(s.bugs);o.changed&&(s.bugs=o.value,c=!0)}if(r.formatRepository!==!1&&Object.hasOwn(s,"repository")){const o=Ce(s.repository);o.changed&&(s.repository=o.value,c=!0)}if(r.sortExports!==!1&&Object.hasOwn(s,"exports")&&T(s.exports)){const o=X(s.exports);o.changed&&(s.exports=o.value,c=!0)}return{changed:c,pkg:s}},$e=/at position (\d+)/,Ne=/\(?line (\d+) column (\d+)\)?/,Ae=e=>{const r=new Set,s=[],c=n=>{const i=q(n);!r.has(i)&&L(i)&&(r.add(i),s.push(i))};c(I(e,"package.json"));const o=ce(e);if(o){const n=A(e,o);for(const i of n)c(I(e,i,"package.json"))}else{const n=I(e,"package.json");if(L(n)){const i=JSON.parse(J(n)),d=Array.isArray(i.workspaces)?i.workspaces:i.workspaces?.packages;if(d){const f=A(e,d);for(const x of f)c(I(e,x,"package.json"))}}}return s},Le=e=>/\n([ \t]+)/.exec(e)?.[1]??" ",_e=e=>{if(!(e===void 0||e===""))return e==="tab"||e===String.raw`\t`?" ":/^\d+$/.test(e)?" ".repeat(Number.parseInt(e,10)):e},P=e=>e===void 0?[]:(Array.isArray(e)?e:[e]).flatMap(s=>s.split(",")).map(s=>s.trim()).filter(s=>s.length>0),De=e=>e.includes(`\r
2
- `)?"crlf":"lf",Fe=new Set(["auto","crlf","lf"]),Me=e=>{if(e===void 0||e==="")return"auto";if(Fe.has(e))return e;throw new Error(`--line-ending must be one of: auto, lf, crlf (got "${e}")`)},Ge=(e,r,s)=>r.length===0?e:e.filter(c=>{const o=B(s,c),n=K(c);return!r.some(i=>{const d=i.includes("/")?o:n;return le(i,d)})}),ve=(e,r)=>{if(r.length===0)return e;const s={},c=new Set;for(const o of r)Object.hasOwn(e,o)&&(s[o]=e[o],c.add(o));for(const o of Object.keys(e))c.has(o)||(s[o]=e[o]);return s},Be=(e,r,s)=>{if(s.length===0)return e;const c={...e};for(const o of s)Object.hasOwn(r,o)&&(c[o]=r[o]);return c},Je=(e,r)=>{let s=1,c=1;const o=Math.min(r,e.length);for(let n=0;n<o;n++)e.codePointAt(n)===10?(s++,c=1):c++;return{column:c,line:s}},G=(e,r,s=2)=>{const c=e.split(`
1
+ import{a as B,z as J,e as I,$ as K,U as q}from"../packem_shared/index-BzhrR_iC.js";import{K as Y,L as z,M as V,J as Z,C as Q,p as E,q as ee}from"./cli-main.js";import{i as re}from"../packem_shared/index-BjdW45xX.js";import{j as t,X as u,O as a,r as R,R as te,l as se,v as ne,x as oe,y as ie,h as ce,i as A}from"../packem_shared/registry-Dg9XI6RT.js";import le from"./index.js";import{sortPackageJsonStringWithOptions as U}from"#native";import{e as C}from"../packem_shared/utils-DQFHJn72.js";import{y as L}from"../packem_shared/isAccessibleSync-DYKTrrvc-C-_5cgwu.js";const _={error:0,rewritten:1,"would-rewrite":1,unchanged:2},ae=e=>[...e].sort((r,s)=>_[r.status]-_[s.status]),de=(e,r)=>r==="all"?e:r==="errors"?e.filter(s=>s.status==="error"):r==="rewritten"?e.filter(s=>s.status==="rewritten"||s.status==="would-rewrite"):e.filter(s=>s.status==="unchanged");class ue{#e;#r=new Set;constructor(r){this.#e={entries:ae(r),filterType:"all",focusedPanel:"list",selectedIndex:0}}getSnapshot=()=>this.#e;subscribe=r=>(this.#r.add(r),()=>{this.#r.delete(r)});getFilteredEntries=()=>de(this.#e.entries,this.#e.filterType);#t(){this.#e={...this.#e};for(const r of this.#r)r()}select(r){const s=this.getFilteredEntries();this.#e.selectedIndex=s.length===0?-1:Math.max(0,Math.min(r,s.length-1)),this.#t()}selectStep(r){this.select(this.#e.selectedIndex+r)}setFilter(r){this.#e.filterType=r,this.#e.selectedIndex=0,this.#t()}setFocusedPanel(r){this.#e.focusedPanel=r,this.#t()}}const fe=({checkMode:e,entry:r,focused:s,scrollRef:c})=>{const o=s?"white":"gray";return r?t.jsxs(u,{borderColor:o,borderStyle:"single",flexDirection:"column",flexGrow:1,children:[t.jsx(u,{flexShrink:0,paddingTop:1,paddingX:2,children:t.jsx(a,{bold:!0,color:"white",children:r.relativePath})}),t.jsxs(Y,{flexGrow:1,flexShrink:1,paddingX:2,ref:c,scrollbar:!0,scrollbarColor:"gray",children:[t.jsx(a,{}),t.jsxs(u,{children:[t.jsx(u,{width:10,children:t.jsx(a,{dimColor:!0,children:"Status:"})}),r.status==="error"?t.jsx(a,{bold:!0,color:"red",children:"error"}):r.status==="unchanged"?t.jsx(a,{bold:!0,color:"green",children:"already sorted"}):r.status==="rewritten"?t.jsx(a,{bold:!0,color:"yellow",children:"rewritten"}):t.jsx(a,{bold:!0,color:"yellow",children:"would rewrite (--check)"})]}),t.jsxs(u,{children:[t.jsx(u,{width:10,children:t.jsx(a,{dimColor:!0,children:"Path:"})}),t.jsx(a,{children:r.filePath})]}),r.error?t.jsxs(t.Fragment,{children:[t.jsxs(u,{flexDirection:"column",marginTop:1,children:[t.jsx(a,{dimColor:!0,children:"── "}),t.jsx(a,{bold:!0,color:"red",children:"ERROR"}),t.jsxs(u,{flexDirection:"column",marginTop:1,paddingLeft:2,children:[t.jsxs(u,{children:[t.jsx(u,{width:10,children:t.jsx(a,{dimColor:!0,children:"Step:"})}),t.jsx(a,{color:"yellow",children:r.error.step})]}),r.error.context&&t.jsxs(u,{children:[t.jsx(u,{width:10,children:t.jsx(a,{dimColor:!0,children:"Position:"})}),t.jsx(a,{children:`line ${String(r.error.context.line)}, column ${String(r.error.context.column)}`})]}),t.jsx(u,{marginTop:1,children:t.jsx(a,{color:"red",children:r.error.message})})]})]}),r.error.context&&r.error.context.snippet.length>0&&t.jsxs(u,{flexDirection:"column",marginTop:1,children:[t.jsx(a,{dimColor:!0,children:"── "}),t.jsx(a,{bold:!0,color:"white",children:"SNIPPET"}),t.jsxs(u,{flexDirection:"column",marginTop:1,paddingLeft:2,children:[r.error.context.snippet.map(n=>{const i=`${n.isErrorLine?"❯":" "} ${String(n.lineNumber).padStart(4)} `;return t.jsxs(u,{children:[t.jsx(a,{color:n.isErrorLine?"red":"gray",children:i}),t.jsx(a,{color:n.isErrorLine?"white":"gray",wrap:"truncate-end",children:n.content||" "})]},n.lineNumber)}),r.error.context.column>0&&t.jsx(u,{children:t.jsx(a,{color:"red",children:`${" ".repeat(7+r.error.context.column-1)}↑`})})]})]})]}):t.jsxs(u,{flexDirection:"column",marginTop:1,children:[t.jsx(a,{dimColor:!0,children:"── "}),t.jsx(a,{bold:!0,color:"white",children:"KEY DIFF"}),t.jsx(u,{flexDirection:"column",marginTop:1,paddingLeft:2,children:r.diff.length===0?t.jsx(a,{dimColor:!0,children:"No top-level keys moved (sub-key reorder only)."}):r.diff.map(n=>{const i=n.toIndex-n.fromIndex,d=i<0?`↑ ${String(Math.abs(i))}`:`↓ ${String(i)}`,f=i<0?"green":"yellow";return t.jsxs(u,{children:[t.jsx(u,{width:28,children:t.jsx(a,{wrap:"truncate",children:n.key})}),t.jsx(u,{width:10,children:t.jsxs(a,{dimColor:!0,children:[String(n.fromIndex)," → ",String(n.toIndex)]})}),t.jsx(a,{color:f,children:d})]},n.key)})}),e&&r.status==="would-rewrite"&&t.jsx(u,{marginTop:1,paddingLeft:2,children:t.jsx(a,{dimColor:!0,children:"--check mode: no write performed."})})]})]})]}):t.jsx(u,{alignItems:"center",borderColor:"gray",borderStyle:"single",flexDirection:"column",flexGrow:1,justifyContent:"center",children:t.jsx(a,{dimColor:!0,children:"No entry selected"})})},he={error:"red",rewritten:"yellow",unchanged:"green","would-rewrite":"yellow"},ge={error:"ERROR",rewritten:"REWROTE",unchanged:"SORTED","would-rewrite":"REWRITE"},W={error:"errors",rewritten:"rewrites",unchanged:"sorted","would-rewrite":"rewrites"},xe={errors:"Errors",rewrites:"Rewrites",sorted:"Sorted"},pe=[{count:e=>e.errors+e.rewrites+e.sorted,key:"all",label:"All",shortcut:"1"},{count:e=>e.rewrites,key:"rewritten",label:"Rewrites",shortcut:"2"},{count:e=>e.errors,key:"errors",label:"Errors",shortcut:"3"},{count:e=>e.sorted,key:"unchanged",label:"Sorted",shortcut:"4"}],X=e=>{const r={errors:0,rewrites:0,sorted:0};for(const s of e)r[W[s.status]]++;return r},me=({entry:e,isSelected:r})=>{const s=he[e.status],c=ge[e.status];return t.jsxs(u,{flexShrink:0,height:1,children:[t.jsx(a,{children:r?">":" "}),t.jsx(a,{children:" "}),t.jsx(a,{bold:!0,color:s,children:`[${c}]`.padEnd(10)}),t.jsx(a,{children:" "}),t.jsx(u,{flexGrow:1,children:t.jsx(a,{bold:r,inverse:r,wrap:"truncate",children:e.relativePath})}),e.status!=="error"&&e.diff.length>0&&t.jsx(a,{dimColor:!0,children:` ${String(e.diff.length)} key${e.diff.length===1?"":"s"}`})]})},je=({color:e,count:r,label:s})=>t.jsx(u,{flexShrink:0,height:1,children:t.jsx(a,{bold:!0,color:e,children:`${s} (${String(r)})`})}),Se=({counts:e,entries:r,filterType:s,focused:c,selectedIndex:o,totalEntries:n,viewportHeight:i})=>{const d=c?"white":"gray",f=X(r),x=(f.errors>0?1:0)+(f.rewrites>0?1:0)+(f.sorted>0?1:0),m=s==="all"&&x>1,h=[];let j;for(const[l,g]of r.entries()){const k=W[g.status];m&&k!==j&&(j!==void 0&&h.push({kind:"spacer"}),h.push({color:k==="errors"?"red":k==="rewrites"?"yellow":"green",count:f[k],kind:"header",label:xe[k]}),j=k),h.push({entry:g,entryIndex:l,kind:"entry"})}const p=h.findIndex(l=>l.kind==="entry"&&l.entryIndex===o),y=p!==-1,S=h.length,w=Math.max(0,S-i);let b=0;y&&i>0&&(b=Math.min(w,Math.max(0,p-i+1)));const O=S>i&&i>0;return t.jsxs(u,{borderColor:d,borderStyle:"single",flexDirection:"column",flexGrow:1,children:[t.jsxs(u,{flexShrink:0,gap:1,paddingX:1,children:[t.jsx(a,{bold:!0,inverse:!0,children:" VIS SORT "}),t.jsxs(a,{wrap:"truncate",children:[n," ","file",n===1?"":"s"]})]}),t.jsx(u,{flexShrink:0,gap:1,paddingX:1,paddingY:1,children:pe.map(l=>{const g=s===l.key,k=l.count(e);return t.jsxs(u,{children:[t.jsx(a,{dimColor:!g,children:"["}),t.jsx(a,{bold:g,color:g?"cyan":"gray",children:l.shortcut}),t.jsx(a,{dimColor:!g,children:"]"}),t.jsxs(a,{color:g?"white":"gray",children:[" ",l.label]}),t.jsxs(a,{dimColor:!0,children:[" ","(",k,")"]})]},l.key)})}),t.jsxs(u,{flexDirection:"row",flexGrow:1,overflow:"hidden",children:[t.jsx(u,{flexDirection:"column",flexGrow:1,overflow:"hidden",paddingLeft:1,children:t.jsx(u,{flexDirection:"column",marginTop:-b,children:h.map((l,g)=>l.kind==="spacer"?t.jsx(u,{flexShrink:0,height:1},`s-${String(g)}`):l.kind==="header"?t.jsx(je,{color:l.color,count:l.count,label:l.label},`h-${l.label}`):t.jsx(me,{entry:l.entry,isSelected:l.entryIndex===o},l.entry.filePath))})}),O&&t.jsx(u,{flexShrink:0,marginLeft:1,marginRight:1,children:t.jsx(z,{contentHeight:S,placement:"inset",scrollOffset:b,style:"block",viewportHeight:i})})]})]})},we=100,D=10,ye=6,ke=1,M={1:"all",2:"rewritten",3:"errors",4:"unchanged"},Ee=({checkMode:e,store:r})=>{const{exit:s}=V(),{columns:c,rows:o}=Z(),n=R.useSyncExternalStore(r.subscribe,r.getSnapshot),i=R.useRef(null),d=r.getFilteredEntries(),f=d[n.selectedIndex]??null,x=X(n.entries),m=c>=we,h=Math.max(0,o-ke),j=m?h:Math.floor(h/2),p=Math.max(0,j-ye),y=R.useCallback(()=>{s()},[s]),S=R.useRef(0),w=R.useRef(void 0),b=R.useRef(!1),O=R.useCallback((l,g)=>{S.current+=g,w.current=l,!b.current&&(b.current=!0,queueMicrotask(()=>{b.current=!1;const k=S.current,N=w.current;S.current=0,w.current=void 0,!(k===0||N===void 0)&&(N==="list"?r.selectStep(Math.sign(k)):i.current?.scrollBy(Math.sign(k)))}))},[r]);return Q((l,g)=>{if(l==="q"||g.escape){y();return}if(M[l]){r.setFilter(M[l]);return}if(g.tab){r.setFocusedPanel(n.focusedPanel==="list"?"detail":"list");return}n.focusedPanel==="list"?g.upArrow||l==="k"?O("list",-1):(g.downArrow||l==="j")&&O("list",1):n.focusedPanel==="detail"&&(g.upArrow||l==="k"?O("detail",-1):(g.downArrow||l==="j")&&O("detail",1))}),o<D?t.jsx(u,{alignItems:"center",justifyContent:"center",children:t.jsxs(a,{color:"yellow",children:["Terminal too small. Resize to at least",D," ","rows."]})}):t.jsxs(u,{flexDirection:"column",height:o,width:c,children:[t.jsxs(u,{flexDirection:m?"row":"column",flexGrow:1,children:[t.jsx(u,{flexBasis:"50%",flexGrow:1,flexShrink:1,children:t.jsx(Se,{counts:x,entries:d,filterType:n.filterType,focused:n.focusedPanel==="list",selectedIndex:n.selectedIndex,totalEntries:n.entries.length,viewportHeight:p})}),t.jsx(u,{flexBasis:"50%",flexGrow:1,flexShrink:1,children:t.jsx(fe,{checkMode:e,entry:f,focused:n.focusedPanel==="detail",scrollRef:i})})]}),t.jsx(u,{flexShrink:0,paddingX:1,children:t.jsx(a,{dimColor:!0,children:"↑/↓ or j/k:navigate | tab:switch panel | 1-4:filter | q:quit"})})]})},F=["types","node-addons","node","import","require","default"],be=/^git\+https:\/\/github\.com\/([^/]+)\/([^/.]+(?:\.git)?)$/,Oe=/^git\+ssh:\/\/git@github\.com\/([^/]+)\/([^/.]+(?:\.git)?)$/,T=e=>typeof e=="object"&&e!==null&&!Array.isArray(e),$=e=>{if(e===null||typeof e!="object")return e;if(Array.isArray(e))return e.map(s=>$(s));const r={};for(const[s,c]of Object.entries(e))r[s]=$(c);return r},Re=e=>{if(!T(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}},Ie=e=>e.endsWith(".git")?e.slice(0,-4):e,Ce=e=>{if(!T(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 c=be.exec(s)??Oe.exec(s);if(!c)return{changed:!1,value:e};const o=c[1],n=Ie(c[2]??"");if(!o||!n)return{changed:!1,value:e};const i=new Set(["type","url"]);for(const d of Object.keys(e))if(!i.has(d))return{changed:!1,value:e};return{changed:!0,value:`${o}/${n}`}},Te=e=>{const r=Object.keys(e),s=[],c=[];for(const d of F)Object.hasOwn(e,d)&&s.push(d);for(const d of r)F.includes(d)||c.push(d);const o=[...s,...c];if(o.length===r.length&&o.every((d,f)=>d===r[f]))return{changed:!1,value:e};const i={};for(const d of o)i[d]=e[d];return{changed:!0,value:i}},H=e=>{if(!T(e))return{changed:!1,value:e};let r=!1;const s={};for(const[o,n]of Object.entries(e)){const i=H(n);s[o]=i.value,i.changed&&(r=!0)}const c=Te(s);return{changed:r||c.changed,value:c.value}},Pe=(e,r)=>{const s=$(e);let c=!1;if(r.formatBugs!==!1&&Object.hasOwn(s,"bugs")){const o=Re(s.bugs);o.changed&&(s.bugs=o.value,c=!0)}if(r.formatRepository!==!1&&Object.hasOwn(s,"repository")){const o=Ce(s.repository);o.changed&&(s.repository=o.value,c=!0)}if(r.sortExports!==!1&&Object.hasOwn(s,"exports")&&T(s.exports)){const o=H(s.exports);o.changed&&(s.exports=o.value,c=!0)}return{changed:c,pkg:s}},$e=/at position (\d+)/,Ne=/\(?line (\d+) column (\d+)\)?/,Ae=e=>{const r=new Set,s=[],c=n=>{const i=q(n);!r.has(i)&&L(i)&&(r.add(i),s.push(i))};c(I(e,"package.json"));const o=ce(e);if(o){const n=A(e,o);for(const i of n)c(I(e,i,"package.json"))}else{const n=I(e,"package.json");if(L(n)){const i=JSON.parse(J(n)),d=Array.isArray(i.workspaces)?i.workspaces:i.workspaces?.packages;if(d){const f=A(e,d);for(const x of f)c(I(e,x,"package.json"))}}}return s},Le=e=>/\n([ \t]+)/.exec(e)?.[1]??" ",_e=e=>{if(!(e===void 0||e===""))return e==="tab"||e===String.raw`\t`?" ":/^\d+$/.test(e)?" ".repeat(Number.parseInt(e,10)):e},P=e=>e===void 0?[]:(Array.isArray(e)?e:[e]).flatMap(s=>s.split(",")).map(s=>s.trim()).filter(s=>s.length>0),De=e=>e.includes(`\r
2
+ `)?"crlf":"lf",Me=new Set(["auto","crlf","lf"]),Fe=e=>{if(e===void 0||e==="")return"auto";if(Me.has(e))return e;throw new Error(`--line-ending must be one of: auto, lf, crlf (got "${e}")`)},Ge=(e,r,s)=>r.length===0?e:e.filter(c=>{const o=B(s,c),n=K(c);return!r.some(i=>{const d=i.includes("/")?o:n;return le(i,d)})}),ve=(e,r)=>{if(r.length===0)return e;const s={},c=new Set;for(const o of r)Object.hasOwn(e,o)&&(s[o]=e[o],c.add(o));for(const o of Object.keys(e))c.has(o)||(s[o]=e[o]);return s},Be=(e,r,s)=>{if(s.length===0)return e;const c={...e};for(const o of s)Object.hasOwn(r,o)&&(c[o]=r[o]);return c},Je=(e,r)=>{let s=1,c=1;const o=Math.min(r,e.length);for(let n=0;n<o;n++)e.codePointAt(n)===10?(s++,c=1):c++;return{column:c,line:s}},G=(e,r,s=2)=>{const c=e.split(`
3
3
  `);if(r<1||r>c.length)return[];const o=Math.max(0,r-1-s),n=Math.min(c.length,r+s),i=[];for(let d=o;d<n;d++)i.push({content:c[d]??"",isErrorLine:d+1===r,lineNumber:d+1});return i},v=(e,r)=>{if(!(e instanceof Error))return;const s=$e.exec(e.message);if(s){const{column:o,line:n}=Je(r,Number.parseInt(s[1]??"0",10));return{column:o,line:n,snippet:G(r,n)}}const c=Ne.exec(e.message);if(c){const o=Number.parseInt(c[1]??"1",10);return{column:Number.parseInt(c[2]??"1",10),line:o,snippet:G(r,o)}}},Ue=(e,r)=>{const s=Object.keys(JSON.parse(e)),c=Object.keys(JSON.parse(r)),o=new Map(s.map((i,d)=>[i,d])),n=[];for(const[i,d]of c.entries()){const f=o.get(d);f!==void 0&&f!==i&&n.push({fromIndex:f,key:d,toIndex:i})}return n},We=(e,r,s)=>{const c=r.indent??s.indent??Le(e),o=r.lineEnding==="auto"?s.lineEnding??De(e):r.lineEnding,n=U(e,{pretty:!1,sortScripts:r.sortScripts});let i=JSON.parse(n);if(r.unsorted.length>0){const m=JSON.parse(e);i=Be(i,m,r.unsorted)}i=ve(i,r.sortOrder);const d={formatBugs:r.formatBugs,formatRepository:r.formatRepository,sortExports:r.sortExports},f=Pe(i,d);let x=JSON.stringify(f.pkg,null,c);return r.finalNewline&&(x+=`
4
4
  `),o==="crlf"&&(x=x.replaceAll(`
5
5
  `,`\r
6
- `)),x},He=(e,r)=>{const s=Ae(e),c=se(e),o=ne({cwd:e,extraPatterns:oe(c)}),n=s.filter(d=>!o.ignores(d)),i=Ge(n,r,e);return{afterGitignore:n,allFiles:s,files:i}},Xe=async(e,{checkMode:r,cwd:s,fs:c,normalized:o})=>{const n=B(s,e)||e;let i;try{i=J(e)}catch(h){return{diff:[],error:{message:C(h),step:"read"},filePath:e,relativePath:n,status:"error"}}let d;try{d=U(i,{pretty:!1,sortScripts:o.sortScripts})}catch(h){const j={message:C(h),step:"native-sort"},p=v(h,i);return p&&(j.context=p),{diff:[],error:j,filePath:e,relativePath:n,status:"error"}}const f=o.editorconfig?ie(e):{};let x;try{x=We(i,o,f)}catch(h){const j={message:C(h),step:"json-parse"},p=v(h,i);return p&&(j.context=p),{diff:[],error:j,filePath:e,relativePath:n,status:"error"}}if(i===x)return{diff:[],filePath:e,relativePath:n,status:"unchanged"};let m;try{m=Ue(i,d)}catch{m=[]}if(r)return{diff:m,filePath:e,relativePath:n,status:"would-rewrite"};try{await c.writeFile(e,x,"utf8")}catch(h){return{diff:m,error:{message:C(h),step:"write"},filePath:e,relativePath:n,status:"error"}}return{diff:m,filePath:e,relativePath:n,status:"rewritten"}},Ke=e=>{if(e.error&&(E.error(`${e.filePath}: ${e.error.message}`),E.info(` step: ${e.error.step}`),e.error.context)){E.info(` at line ${String(e.error.context.line)}, column ${String(e.error.context.column)}`);for(const r of e.error.context.snippet){const s=r.isErrorLine?">":" ";E.info(` ${s} ${String(r.lineNumber).padStart(4)} | ${r.content}`)}}},tr=async({fs:e,options:r,visConfig:s,workspaceRoot:c})=>{const o=c??process.cwd(),n=s?.sortPackageJson,i=r.check||!1,f={editorconfig:r.editorconfig?n?.editorconfig??!0:!1,finalNewline:r.finalNewline??n?.finalNewline??!0,formatBugs:r.formatBugs?n?.formatBugs??!0:!1,formatRepository:r.formatRepository?n?.formatRepository??!0:!1,ignore:[...P(r.ignore),...n?.ignore??[]],indent:_e(r.indent??n?.indent),lineEnding:Me(r.lineEnding??n?.lineEnding),sortExports:r.sortExports?n?.sortExports??!0:!1,sortOrder:[...P(r.sortOrder),...n?.sortOrder??[]],sortScripts:r.sortScripts||n?.sortScripts||!1,unsorted:[...P(r.unsorted),...n?.unsorted??[]]},x=He(o,f.ignore),{afterGitignore:m,allFiles:h,files:j}=x;if(j.length===0){h.length===0?E.info("No package.json files found."):m.length===0?E.info("All package.json files were excluded by .gitignore or workspace exclusions."):E.info("All package.json files were excluded by --ignore.");return}const p=[];for(const l of j)p.push(await Xe(l,{checkMode:i,cwd:o,fs:e,normalized:f}));let y=0,S=0,w=0;for(const l of p)l.status==="error"?w++:l.status==="rewritten"||l.status==="would-rewrite"?y++:S++;const b=y>0||w>0;if(!!process.stdout.isTTY&&!re&&b){const l=new ue(p);await ee(te.createElement(Ee,{checkMode:i,store:l}),{alternateScreen:!0,exitOnCtrlC:!1,interactive:!0,patchConsole:!0}).waitUntilExit()}else for(const l of p)switch(l.status){case"error":{Ke(l);break}case"rewritten":{E.success(`Sorted ${l.filePath}`);break}case"would-rewrite":{E.warn(`${l.filePath} is not sorted`);break}}if(i)y>0?(E.info(`${String(y)} file${y===1?"":"s"} not sorted, ${String(S)} already sorted`),process.exitCode=1):w===0&&E.info(`All ${String(S)} package.json file${S===1?" is":"s are"} sorted`);else{const l=[];y>0&&l.push(`sorted ${String(y)} file${y===1?"":"s"}`),S>0&&l.push(`${String(S)} already sorted`),w>0&&l.push(`${String(w)} error${w===1?"":"s"}`),l.length>0&&E.info(l.join(", "))}w>0&&(process.exitCode=1)};export{G as buildSnippet,Ue as computeKeyDiff,Je as computeLineColumn,tr as default,He as discoverPackageJsonFiles,v as extractParseErrorContext,Xe as processFile};
6
+ `)),x},Xe=(e,r)=>{const s=Ae(e),c=se(e),o=ne({cwd:e,extraPatterns:oe(c)}),n=s.filter(d=>!o.ignores(d)),i=Ge(n,r,e);return{afterGitignore:n,allFiles:s,files:i}},He=async(e,{checkMode:r,cwd:s,fs:c,normalized:o})=>{const n=B(s,e)||e;let i;try{i=J(e)}catch(h){return{diff:[],error:{message:C(h),step:"read"},filePath:e,relativePath:n,status:"error"}}let d;try{d=U(i,{pretty:!1,sortScripts:o.sortScripts})}catch(h){const j={message:C(h),step:"native-sort"},p=v(h,i);return p&&(j.context=p),{diff:[],error:j,filePath:e,relativePath:n,status:"error"}}const f=o.editorconfig?ie(e):{};let x;try{x=We(i,o,f)}catch(h){const j={message:C(h),step:"json-parse"},p=v(h,i);return p&&(j.context=p),{diff:[],error:j,filePath:e,relativePath:n,status:"error"}}if(i===x)return{diff:[],filePath:e,relativePath:n,status:"unchanged"};let m;try{m=Ue(i,d)}catch{m=[]}if(r)return{diff:m,filePath:e,relativePath:n,status:"would-rewrite"};try{await c.writeFile(e,x,"utf8")}catch(h){return{diff:m,error:{message:C(h),step:"write"},filePath:e,relativePath:n,status:"error"}}return{diff:m,filePath:e,relativePath:n,status:"rewritten"}},Ke=e=>{if(e.error&&(E.error(`${e.filePath}: ${e.error.message}`),E.info(` step: ${e.error.step}`),e.error.context)){E.info(` at line ${String(e.error.context.line)}, column ${String(e.error.context.column)}`);for(const r of e.error.context.snippet){const s=r.isErrorLine?">":" ";E.info(` ${s} ${String(r.lineNumber).padStart(4)} | ${r.content}`)}}},tr=async({fs:e,options:r,visConfig:s,workspaceRoot:c})=>{const o=c??process.cwd(),n=s?.sortPackageJson,i=r.check||!1,f={editorconfig:r.editorconfig?n?.editorconfig??!0:!1,finalNewline:r.finalNewline??n?.finalNewline??!0,formatBugs:r.formatBugs?n?.formatBugs??!0:!1,formatRepository:r.formatRepository?n?.formatRepository??!0:!1,ignore:[...P(r.ignore),...n?.ignore??[]],indent:_e(r.indent??n?.indent),lineEnding:Fe(r.lineEnding??n?.lineEnding),sortExports:r.sortExports?n?.sortExports??!0:!1,sortOrder:[...P(r.sortOrder),...n?.sortOrder??[]],sortScripts:r.sortScripts||n?.sortScripts||!1,unsorted:[...P(r.unsorted),...n?.unsorted??[]]},x=Xe(o,f.ignore),{afterGitignore:m,allFiles:h,files:j}=x;if(j.length===0){h.length===0?E.info("No package.json files found."):m.length===0?E.info("All package.json files were excluded by .gitignore or workspace exclusions."):E.info("All package.json files were excluded by --ignore.");return}const p=[];for(const l of j)p.push(await He(l,{checkMode:i,cwd:o,fs:e,normalized:f}));let y=0,S=0,w=0;for(const l of p)l.status==="error"?w++:l.status==="rewritten"||l.status==="would-rewrite"?y++:S++;const b=y>0||w>0;if(!!process.stdout.isTTY&&!re&&b){const l=new ue(p);await ee(te.createElement(Ee,{checkMode:i,store:l}),{alternateScreen:!0,exitOnCtrlC:!1,interactive:!0,patchConsole:!0}).waitUntilExit()}else for(const l of p)switch(l.status){case"error":{Ke(l);break}case"rewritten":{E.success(`Sorted ${l.filePath}`);break}case"would-rewrite":{E.warn(`${l.filePath} is not sorted`);break}}if(i)y>0?(E.info(`${String(y)} file${y===1?"":"s"} not sorted, ${String(S)} already sorted`),process.exitCode=1):w===0&&E.info(`All ${String(S)} package.json file${S===1?" is":"s are"} sorted`);else{const l=[];y>0&&l.push(`sorted ${String(y)} file${y===1?"":"s"}`),S>0&&l.push(`${String(S)} already sorted`),w>0&&l.push(`${String(w)} error${w===1?"":"s"}`),l.length>0&&E.info(l.join(", "))}w>0&&(process.exitCode=1)};export{G as buildSnippet,Ue as computeKeyDiff,Je as computeLineColumn,tr as default,Xe as discoverPackageJsonFiles,v as extractParseErrorContext,He as processFile};
@@ -1,8 +1,8 @@
1
- import{createRequire as Q}from"node:module";import{J as I,j as re,F as O,X as U,b as D,q as ie}from"../packem_shared/index.server-Ca_EEVfw.js";import{a as S}from"../packem_shared/index-BzhrR_iC.js";import{Z as se}from"./cli-main.js";import{w as ae,r as oe,a as ce,s as le,c as de,b as ue,d as fe,o as ge,p as P,g as pe,h as me,i as he,j as xe,k as we,l as ve,n as ye,m as ke}from"../packem_shared/watch-loop-D1_e-qIl.js";import{T as d}from"./catalog.js";import{d as f,f as b,r as be,a as $e}from"../packem_shared/detect-CbMRSXkM.js";import{R as Ae}from"./ts-loader.js";let ee;const te=e=>(ee??=Q(import.meta.url))(e),k=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,ne=e=>{if(typeof k<"u"&&k.versions&&k.versions.node){const[t,n]=k.versions.node.split(".").map(Number);if(t>22||t===22&&n>=3||t===20&&n>=16)return k.getBuiltinModule(e)}return te(e)},{createHash:h}=ne("node:crypto"),Ce={1:"warning",2:"error"},Fe={argsCheck:(e,t)=>V(e,t,!1),argsFix:(e,t)=>V(e,t,!0),bin:()=>["pnpm","exec","eslint"],cacheKey:(e,t)=>{const n=["eslint",e.declaredVersion??"unknown",e.configFile??"no-config",t.maxWarnings===void 0?"":`mw=${t.maxWarnings}`,t.quiet?"q":"",...t.extraArgs??[]];return h("sha256").update(n.join("|")).digest("hex").slice(0,16)},detect:(e,t)=>{const n=f(t,d.eslint.packageNames[0]),r=b(e,d.eslint.configFiles);if(!(!n&&!r))return{adapter:"eslint",configFile:r,declared:!!n,declaredVersion:n,root:e}},extensions:["cjs","cts","js","jsx","mjs","mts","ts","tsx","vue"],id:"eslint",kind:"lint",parse:(e,t)=>{if(!e.stdout.trim())return[];let n;try{n=JSON.parse(e.stdout)}catch{return[{adapter:"eslint",file:t.root,fixable:!1,message:`eslint output was not valid JSON (exit ${e.exitCode})`,severity:"error"}]}const r=[];for(const i of n)for(const s of i.messages)r.push({adapter:"eslint",column:s.column,endColumn:s.endColumn,endLine:s.endLine,file:i.filePath,fixable:!!s.fix,line:s.line,message:s.message,ruleId:s.ruleId??void 0,severity:s.fatal?"error":Ce[s.severity]??"warning"});return r}},V=(e,t,n)=>{const r=["--format","json","--no-error-on-unmatched-pattern"];return n&&r.push("--fix"),t.quiet&&r.push("--quiet"),typeof t.maxWarnings=="number"&&r.push("--max-warnings",String(t.maxWarnings)),t.extraArgs?.length&&r.push(...t.extraArgs),r.push(...e),r},Se=/^([^:]+):(\d+)(?::(\d+))?\s+([\w/-]+)\s+(.+)$/,je=e=>{const t=Se.exec(e);if(!t)return;const[,n,r,i,s,c]=t;return{column:i===void 0?void 0:Number(i),file:n,line:Number(r),message:c,ruleId:s}},_e=e=>e.startsWith("/")||/^[a-z]:[\\/]/i.test(e),Ne={argsCheck:(e,t)=>M(e,t,!1),argsFix:(e,t)=>M(e,t,!0),bin:()=>["pnpm","exec","markdownlint-cli2"],cacheKey:(e,t)=>{const n=["markdownlint",e.declaredVersion??"unknown",e.configFile??"no-config",t.maxWarnings===void 0?"":`mw=${t.maxWarnings}`,t.quiet?"q":"",...t.extraArgs??[]];return h("sha256").update(n.join("|")).digest("hex").slice(0,16)},detect:(e,t)=>{const n=d.markdownlint.packageNames.map(i=>f(t,i)).find(i=>i!==void 0),r=b(e,d.markdownlint.configFiles);if(!(!n&&!r))return{adapter:"markdownlint",configFile:r,declared:!!n,declaredVersion:n,root:e}},extensions:["markdown","md"],id:"markdownlint",kind:"lint",parse:(e,t)=>{const n=(e.stderr||e.stdout||"").trim();if(!n)return[];const r=[];for(const i of n.split(/\r?\n/)){const s=je(i.trim());s&&r.push({adapter:"markdownlint",column:s.column,file:_e(s.file)?s.file:`${t.root}/${s.file}`,fixable:!0,line:s.line,message:s.message,ruleId:s.ruleId,severity:"warning"})}return r}},M=(e,t,n)=>{const r=[];return n&&r.push("--fix"),t.extraArgs?.length&&r.push(...t.extraArgs),e.length===0?r.push("**/*.md"):r.push(...e),r},qe={advice:"info",error:"error",warning:"warning"},Ie={argsCheck:(e,t)=>L(e,t,!1),argsFix:(e,t)=>L(e,t,!0),bin:()=>["pnpm","exec","oxlint"],cacheKey:(e,t)=>{const n=["oxlint",e.declaredVersion??"unknown",e.configFile??"no-config",t.maxWarnings===void 0?"":`mw=${t.maxWarnings}`,t.quiet?"q":"",...t.extraArgs??[]];return h("sha256").update(n.join("|")).digest("hex").slice(0,16)},detect:(e,t)=>{const n=f(t,d.oxlint.packageNames[0]),r=b(e,d.oxlint.configFiles);if(!(!n&&!r))return{adapter:"oxlint",configFile:r,declared:!!n,declaredVersion:n,root:e}},extensions:["astro","cjs","cts","js","jsx","mjs","mts","svelte","ts","tsx","vue"],id:"oxlint",kind:"lint",parse:(e,t)=>{if(!e.stdout.trim())return[];let n;try{n=JSON.parse(e.stdout)}catch{return[{adapter:"oxlint",file:t.root,fixable:!1,message:`oxlint output was not valid JSON (exit ${e.exitCode})`,severity:"error"}]}const r=[];for(const i of n.diagnostics??[]){const s=i.labels?.[0]?.span;r.push({adapter:"oxlint",column:s?.column,file:i.filename??t.root,fixable:!1,line:s?.line,message:i.message??"",ruleId:i.code,severity:qe[i.severity??""]??"warning"})}return r}},L=(e,t,n)=>{const r=["--format","json"];return n&&r.push("--fix"),t.quiet&&r.push("--quiet"),typeof t.maxWarnings=="number"&&r.push(`--max-warnings=${String(t.maxWarnings)}`),t.extraArgs?.length&&r.push(...t.extraArgs),r.push(...e),r},We={error:"error",info:"info",style:"info",warning:"warning"},Re=e=>e.startsWith("/")||/^[a-z]:[\\/]/i.test(e),Te=(e,t)=>e?Re(e)?e:`${t}/${e}`:t,Ee={argsCheck:(e,t)=>B(e,t),argsFix:(e,t)=>B(e,t),bin:()=>["shellcheck"],cacheKey:(e,t)=>{const n=["shellcheck",e.declaredVersion??"unknown",e.configFile??"no-config",t.quiet?"q":"",...t.extraArgs??[]];return h("sha256").update(n.join("|")).digest("hex").slice(0,16)},detect:(e,t)=>{const n=f(t,d.shellcheck.packageNames[0]),r=b(e,d.shellcheck.configFiles);if(!(!n&&!r))return{adapter:"shellcheck",configFile:r,declared:!!n,declaredVersion:n,root:e}},extensions:["bash","ksh","sh"],id:"shellcheck",kind:"lint",parse:(e,t)=>{if(!e.stdout.trim())return[];let n;try{n=JSON.parse(e.stdout)}catch{return[{adapter:"shellcheck",file:t.root,fixable:!1,message:`shellcheck output was not valid JSON (exit ${e.exitCode})`,severity:"error"}]}const r=[];for(const i of n.comments??[])r.push({adapter:"shellcheck",column:i.column,endColumn:i.endColumn,endLine:i.endLine,file:Te(i.file,t.root),fixable:!!i.fix,line:i.line,message:i.message??"",ruleId:i.code===void 0?void 0:`SC${String(i.code)}`,severity:We[i.level??""]??"warning"});return r}},B=(e,t)=>{const n=["--format=json1"];return t.extraArgs?.length&&n.push(...t.extraArgs),n.push(...e),n},Oe={error:"error",warning:"warning"},Pe={argsCheck:(e,t)=>J(e,t,!1),argsFix:(e,t)=>J(e,t,!0),bin:()=>["pnpm","exec","stylelint"],cacheKey:(e,t)=>{const n=["stylelint",e.declaredVersion??"unknown",e.configFile??"no-config",t.maxWarnings===void 0?"":`mw=${t.maxWarnings}`,t.quiet?"q":"",...t.extraArgs??[]];return h("sha256").update(n.join("|")).digest("hex").slice(0,16)},detect:(e,t)=>{const n=f(t,d.stylelint.packageNames[0]),r=b(e,d.stylelint.configFiles);if(!(!n&&!r))return{adapter:"stylelint",configFile:r,declared:!!n,declaredVersion:n,root:e}},extensions:["astro","css","less","sass","scss","svelte","vue"],id:"stylelint",kind:"lint",parse:(e,t)=>{if(!e.stdout.trim())return[];let n;try{n=JSON.parse(e.stdout)}catch{return[{adapter:"stylelint",file:t.root,fixable:!1,message:`stylelint output was not valid JSON (exit ${e.exitCode})`,severity:"error"}]}const r=[];for(const i of n)for(const s of i.warnings??[])r.push({adapter:"stylelint",column:s.column,endColumn:s.endColumn,endLine:s.endLine,file:i.source,fixable:!1,line:s.line,message:s.text??"",ruleId:s.rule,severity:Oe[s.severity??""]??"warning"});return r}},J=(e,t,n)=>{const r=["--formatter","json"];return n&&r.push("--fix"),t.quiet&&r.push("--quiet"),typeof t.maxWarnings=="number"&&r.push("--max-warnings",String(t.maxWarnings)),t.extraArgs?.length&&r.push(...t.extraArgs),r.push(...e),r},G="@typescript/native-preview",Ve=2e3,Me=/^(.*)\((\d+),(\d+)\): (error|warning) (TS\d+): (.*)$/,Le=/^(error|warning) (TS\d+): (.*)$/,Y=e=>e.startsWith("/")||/^[a-z]:[\\/]/i.test(e),Be=(e,t)=>Y(e)?e:`${t}/${e}`,z=e=>{try{return Ae(e)}catch{return}},Je=e=>{const t=z(e);return Array.isArray(t?.config.references)&&t.config.references.length>0},Ke=e=>{const t=be(e);return!f(t,"typescript")&&f(t,G)?"tsgo":"tsc"},Ue={argsCheck:(e,t)=>K(t),argsFix:(e,t)=>K(t),bin:e=>{const t=["pnpm","exec",Ke(e.root)],n=e.configFile?S(e.root,e.configFile):"tsconfig.json";return e.configFile&&Je(e.root)?[...t,"-b","--pretty","false",n]:[...t,"-p",n,"--noEmit","--pretty","false"]},cacheKey:(e,t)=>{const n=["typecheck",e.declaredVersion??"unknown",e.configFile??"no-config",...t.extraArgs??[]];return h("sha256").update(n.join("|")).digest("hex").slice(0,16)},detect:(e,t)=>{const n=f(t,"typescript"),r=f(t,G),i=z(e),s=i?S(e,i.path):void 0;if(!(!n&&!r||!i||!s||s===".."||s.startsWith("../")||Y(s)))return{adapter:"typecheck",configFile:i.path,declared:!0,declaredVersion:n??r,root:e}},extensions:["cts","mts","ts","tsx"],id:"typecheck",kind:"lint",optIn:!0,parse:(e,t)=>{const n=[];for(const r of`${e.stdout}
1
+ import{createRequire as Z}from"node:module";import{J as I,j as re,F as O,X as U,b as D,q as ie}from"../packem_shared/index.server-Ca_EEVfw.js";import{a as S}from"../packem_shared/index-BzhrR_iC.js";import{P as se}from"./cli-main.js";import{w as ae,r as oe,a as ce,s as le,c as de,b as ue,d as fe,o as ge,p as P,g as pe,h as me,i as he,j as xe,k as we,l as ve,n as ye,m as ke}from"../packem_shared/watch-loop-CGi66Fs0.js";import{s as d}from"../packem_shared/registry-Dg9XI6RT.js";import{d as f,f as b,r as be,a as $e}from"../packem_shared/detect-CbMRSXkM.js";import{R as Ae}from"./ts-loader.js";let ee;const te=e=>(ee??=Z(import.meta.url))(e),k=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,ne=e=>{if(typeof k<"u"&&k.versions&&k.versions.node){const[t,n]=k.versions.node.split(".").map(Number);if(t>22||t===22&&n>=3||t===20&&n>=16)return k.getBuiltinModule(e)}return te(e)},{createHash:h}=ne("node:crypto"),Ce={1:"warning",2:"error"},Fe={argsCheck:(e,t)=>V(e,t,!1),argsFix:(e,t)=>V(e,t,!0),bin:()=>["pnpm","exec","eslint"],cacheKey:(e,t)=>{const n=["eslint",e.declaredVersion??"unknown",e.configFile??"no-config",t.maxWarnings===void 0?"":`mw=${t.maxWarnings}`,t.quiet?"q":"",...t.extraArgs??[]];return h("sha256").update(n.join("|")).digest("hex").slice(0,16)},detect:(e,t)=>{const n=f(t,d.eslint.packageNames[0]),r=b(e,d.eslint.configFiles);if(!(!n&&!r))return{adapter:"eslint",configFile:r,declared:!!n,declaredVersion:n,root:e}},extensions:["cjs","cts","js","jsx","mjs","mts","ts","tsx","vue"],id:"eslint",kind:"lint",parse:(e,t)=>{if(!e.stdout.trim())return[];let n;try{n=JSON.parse(e.stdout)}catch{return[{adapter:"eslint",file:t.root,fixable:!1,message:`eslint output was not valid JSON (exit ${e.exitCode})`,severity:"error"}]}const r=[];for(const i of n)for(const s of i.messages)r.push({adapter:"eslint",column:s.column,endColumn:s.endColumn,endLine:s.endLine,file:i.filePath,fixable:!!s.fix,line:s.line,message:s.message,ruleId:s.ruleId??void 0,severity:s.fatal?"error":Ce[s.severity]??"warning"});return r}},V=(e,t,n)=>{const r=["--format","json","--no-error-on-unmatched-pattern"];return n&&r.push("--fix"),t.quiet&&r.push("--quiet"),typeof t.maxWarnings=="number"&&r.push("--max-warnings",String(t.maxWarnings)),t.extraArgs?.length&&r.push(...t.extraArgs),r.push(...e),r},Se=/^([^:]+):(\d+)(?::(\d+))?\s+([\w/-]+)\s+(.+)$/,je=e=>{const t=Se.exec(e);if(!t)return;const[,n,r,i,s,c]=t;return{column:i===void 0?void 0:Number(i),file:n,line:Number(r),message:c,ruleId:s}},_e=e=>e.startsWith("/")||/^[a-z]:[\\/]/i.test(e),Ne={argsCheck:(e,t)=>M(e,t,!1),argsFix:(e,t)=>M(e,t,!0),bin:()=>["pnpm","exec","markdownlint-cli2"],cacheKey:(e,t)=>{const n=["markdownlint",e.declaredVersion??"unknown",e.configFile??"no-config",t.maxWarnings===void 0?"":`mw=${t.maxWarnings}`,t.quiet?"q":"",...t.extraArgs??[]];return h("sha256").update(n.join("|")).digest("hex").slice(0,16)},detect:(e,t)=>{const n=d.markdownlint.packageNames.map(i=>f(t,i)).find(i=>i!==void 0),r=b(e,d.markdownlint.configFiles);if(!(!n&&!r))return{adapter:"markdownlint",configFile:r,declared:!!n,declaredVersion:n,root:e}},extensions:["markdown","md"],id:"markdownlint",kind:"lint",parse:(e,t)=>{const n=(e.stderr||e.stdout||"").trim();if(!n)return[];const r=[];for(const i of n.split(/\r?\n/)){const s=je(i.trim());s&&r.push({adapter:"markdownlint",column:s.column,file:_e(s.file)?s.file:`${t.root}/${s.file}`,fixable:!0,line:s.line,message:s.message,ruleId:s.ruleId,severity:"warning"})}return r}},M=(e,t,n)=>{const r=[];return n&&r.push("--fix"),t.extraArgs?.length&&r.push(...t.extraArgs),e.length===0?r.push("**/*.md"):r.push(...e),r},qe={advice:"info",error:"error",warning:"warning"},Ie={argsCheck:(e,t)=>L(e,t,!1),argsFix:(e,t)=>L(e,t,!0),bin:()=>["pnpm","exec","oxlint"],cacheKey:(e,t)=>{const n=["oxlint",e.declaredVersion??"unknown",e.configFile??"no-config",t.maxWarnings===void 0?"":`mw=${t.maxWarnings}`,t.quiet?"q":"",...t.extraArgs??[]];return h("sha256").update(n.join("|")).digest("hex").slice(0,16)},detect:(e,t)=>{const n=f(t,d.oxlint.packageNames[0]),r=b(e,d.oxlint.configFiles);if(!(!n&&!r))return{adapter:"oxlint",configFile:r,declared:!!n,declaredVersion:n,root:e}},extensions:["astro","cjs","cts","js","jsx","mjs","mts","svelte","ts","tsx","vue"],id:"oxlint",kind:"lint",parse:(e,t)=>{if(!e.stdout.trim())return[];let n;try{n=JSON.parse(e.stdout)}catch{return[{adapter:"oxlint",file:t.root,fixable:!1,message:`oxlint output was not valid JSON (exit ${e.exitCode})`,severity:"error"}]}const r=[];for(const i of n.diagnostics??[]){const s=i.labels?.[0]?.span;r.push({adapter:"oxlint",column:s?.column,file:i.filename??t.root,fixable:!1,line:s?.line,message:i.message??"",ruleId:i.code,severity:qe[i.severity??""]??"warning"})}return r}},L=(e,t,n)=>{const r=["--format","json"];return n&&r.push("--fix"),t.quiet&&r.push("--quiet"),typeof t.maxWarnings=="number"&&r.push(`--max-warnings=${String(t.maxWarnings)}`),t.extraArgs?.length&&r.push(...t.extraArgs),r.push(...e),r},We={error:"error",info:"info",style:"info",warning:"warning"},Re=e=>e.startsWith("/")||/^[a-z]:[\\/]/i.test(e),Te=(e,t)=>e?Re(e)?e:`${t}/${e}`:t,Ee={argsCheck:(e,t)=>B(e,t),argsFix:(e,t)=>B(e,t),bin:()=>["shellcheck"],cacheKey:(e,t)=>{const n=["shellcheck",e.declaredVersion??"unknown",e.configFile??"no-config",t.quiet?"q":"",...t.extraArgs??[]];return h("sha256").update(n.join("|")).digest("hex").slice(0,16)},detect:(e,t)=>{const n=f(t,d.shellcheck.packageNames[0]),r=b(e,d.shellcheck.configFiles);if(!(!n&&!r))return{adapter:"shellcheck",configFile:r,declared:!!n,declaredVersion:n,root:e}},extensions:["bash","ksh","sh"],id:"shellcheck",kind:"lint",parse:(e,t)=>{if(!e.stdout.trim())return[];let n;try{n=JSON.parse(e.stdout)}catch{return[{adapter:"shellcheck",file:t.root,fixable:!1,message:`shellcheck output was not valid JSON (exit ${e.exitCode})`,severity:"error"}]}const r=[];for(const i of n.comments??[])r.push({adapter:"shellcheck",column:i.column,endColumn:i.endColumn,endLine:i.endLine,file:Te(i.file,t.root),fixable:!!i.fix,line:i.line,message:i.message??"",ruleId:i.code===void 0?void 0:`SC${String(i.code)}`,severity:We[i.level??""]??"warning"});return r}},B=(e,t)=>{const n=["--format=json1"];return t.extraArgs?.length&&n.push(...t.extraArgs),n.push(...e),n},Oe={error:"error",warning:"warning"},Pe={argsCheck:(e,t)=>J(e,t,!1),argsFix:(e,t)=>J(e,t,!0),bin:()=>["pnpm","exec","stylelint"],cacheKey:(e,t)=>{const n=["stylelint",e.declaredVersion??"unknown",e.configFile??"no-config",t.maxWarnings===void 0?"":`mw=${t.maxWarnings}`,t.quiet?"q":"",...t.extraArgs??[]];return h("sha256").update(n.join("|")).digest("hex").slice(0,16)},detect:(e,t)=>{const n=f(t,d.stylelint.packageNames[0]),r=b(e,d.stylelint.configFiles);if(!(!n&&!r))return{adapter:"stylelint",configFile:r,declared:!!n,declaredVersion:n,root:e}},extensions:["astro","css","less","sass","scss","svelte","vue"],id:"stylelint",kind:"lint",parse:(e,t)=>{if(!e.stdout.trim())return[];let n;try{n=JSON.parse(e.stdout)}catch{return[{adapter:"stylelint",file:t.root,fixable:!1,message:`stylelint output was not valid JSON (exit ${e.exitCode})`,severity:"error"}]}const r=[];for(const i of n)for(const s of i.warnings??[])r.push({adapter:"stylelint",column:s.column,endColumn:s.endColumn,endLine:s.endLine,file:i.source,fixable:!1,line:s.line,message:s.text??"",ruleId:s.rule,severity:Oe[s.severity??""]??"warning"});return r}},J=(e,t,n)=>{const r=["--formatter","json"];return n&&r.push("--fix"),t.quiet&&r.push("--quiet"),typeof t.maxWarnings=="number"&&r.push("--max-warnings",String(t.maxWarnings)),t.extraArgs?.length&&r.push(...t.extraArgs),r.push(...e),r},G="@typescript/native-preview",Ve=2e3,Me=/^(.*)\((\d+),(\d+)\): (error|warning) (TS\d+): (.*)$/,Le=/^(error|warning) (TS\d+): (.*)$/,Y=e=>e.startsWith("/")||/^[a-z]:[\\/]/i.test(e),Be=(e,t)=>Y(e)?e:`${t}/${e}`,z=e=>{try{return Ae(e)}catch{return}},Je=e=>{const t=z(e);return Array.isArray(t?.config.references)&&t.config.references.length>0},Ke=e=>{const t=be(e);return!f(t,"typescript")&&f(t,G)?"tsgo":"tsc"},Ue={argsCheck:(e,t)=>K(t),argsFix:(e,t)=>K(t),bin:e=>{const t=["pnpm","exec",Ke(e.root)],n=e.configFile?S(e.root,e.configFile):"tsconfig.json";return e.configFile&&Je(e.root)?[...t,"-b","--pretty","false",n]:[...t,"-p",n,"--noEmit","--pretty","false"]},cacheKey:(e,t)=>{const n=["typecheck",e.declaredVersion??"unknown",e.configFile??"no-config",...t.extraArgs??[]];return h("sha256").update(n.join("|")).digest("hex").slice(0,16)},detect:(e,t)=>{const n=f(t,"typescript"),r=f(t,G),i=z(e),s=i?S(e,i.path):void 0;if(!(!n&&!r||!i||!s||s===".."||s.startsWith("../")||Y(s)))return{adapter:"typecheck",configFile:i.path,declared:!0,declaredVersion:n??r,root:e}},extensions:["cts","mts","ts","tsx"],id:"typecheck",kind:"lint",optIn:!0,parse:(e,t)=>{const n=[];for(const r of`${e.stdout}
2
2
  ${e.stderr}`.split(/\r?\n/)){const i=Me.exec(r);if(i){n.push({adapter:"typecheck",column:Number(i[3]),file:Be(i[1],t.root),fixable:!1,line:Number(i[2]),message:i[6],ruleId:i[5],severity:i[4]==="warning"?"warning":"error"});continue}const s=Le.exec(r);if(s){n.push({adapter:"typecheck",file:t.root,fixable:!1,message:s[3],ruleId:s[2],severity:s[1]==="warning"?"warning":"error"});continue}const c=n.at(-1);c&&/^\s+\S/.test(r)&&(c.message+=`
3
3
  ${r.trim()}`)}if(n.length===0&&e.exitCode!==0){const r=`${e.stdout}
4
4
  ${e.stderr}`.trim().slice(0,Ve);n.push({adapter:"typecheck",file:t.root,fixable:!1,message:e.exitCode===null?`type-check did not complete (killed or timed out)${r?`:
5
5
  ${r}`:""}`:`type-check failed (exit ${String(e.exitCode)}) with unrecognised output:
6
- ${r}`,severity:"error"})}return n},scope:"project"},K=e=>e.extraArgs?.length?[...e.extraArgs]:[],De=[Ie,fe,Fe,Pe,ge,Ne,Ee,Ue],at=async({logger:e,options:t,visConfig:n,workspaceRoot:r})=>{const i=r??process.cwd(),s=n?.lint;ae(e,"lint",s);const c=oe(De,s?.order),$=$e(i,c),x=ce($,c,"lint").filter(({adapter:o})=>{const l=s?.adapters?.[o.id]?.enabled;return o.optIn?l===!0:l!==!1});for(const o of c)o.optIn&&s?.adapters?.[o.id]?.enabled===!0&&!$.has(o.id)&&e.warn(`vis lint: adapters.${o.id}.enabled is set, but ${o.id} was not detected (needs a tsconfig.json and a typescript dependency at the workspace root). Skipping it.`);if(x.length===0){e.warn("vis lint: no linter detected in this workspace (looked for: oxlint, biome, eslint, stylelint, ruff, markdownlint, shellcheck; typecheck runs only when enabled).");return}const j=o=>{const l=s?.adapters?.[o]?.extraArgs;return l&&l.length>0?[...l]:void 0},A={extraArgs:void 0,maxWarnings:typeof t.maxWarnings=="number"?t.maxWarnings:void 0,quiet:t.quiet??!1},W=Ge(t),H=t.fix?"fix":"check";let g;if(t.staged){if(g=le(i),g===void 0)e.warn("vis lint: could not resolve --staged (not a git repo or git unavailable). Falling back to a workspace-wide run.");else if(g.length===0){e.info(I("✓ lint: no staged files"));return}}else if(typeof t.since=="string"&&t.since.length>0){if(g=de(i,t.since),g===void 0)e.warn(`vis lint: could not resolve --since ${t.since} (not a git repo or unknown ref). Falling back to a workspace-wide run.`);else if(g.length===0){e.info(I(`✓ lint: no files changed since ${t.since}`));return}}const _=W.length>0?W:void 0,X=se(i,void 0,void 0,!0),N=t.format??"human";N==="human"&&t.output!==void 0&&e.warn("vis lint: --output is ignored for the human format; pass --format json|minimal|sarif|junit|github to redirect findings to a file.");const R=async o=>{const l=o!==void 0&&o.length>0&&_===void 0,w=[];for(const{adapter:a,presence:y}of x){let u;if(a.scope==="project"){const q=_??o;if(q&&q.length>0&&P(q,a.extensions).length===0)continue;u=["."]}else if(l){if(u=P(o,a.extensions),u.length===0)continue}else u=_??o??["."];const F=j(a.id),E={adapter:a,files:u,presence:y};F&&(E.options={...A,extraArgs:F}),w.push(E)}if(w.length===0)return;const Z=await pe(w,A,H,{cacheRoot:X}),C=w.map((a,y)=>{const u=Z[y],F=a.adapter.parse(u,a.presence);return{adapter:a.adapter,durationMs:u.durationMs,exitCode:u.exitCode,findings:F}}),v=me(C.map(a=>({adapter:a.adapter.id,durationMs:a.durationMs,exitCode:a.exitCode,findingCount:a.findings.length,findings:a.findings}))),m=N==="human"?void 0:he({cwd:i,target:t.output});try{switch(N){case"github":{m.write(ve({runs:C.map(a=>({findings:a.findings})),workspaceRoot:i}));break}case"json":{m.write(`${JSON.stringify({findings:v.findings,runs:v.runs},null,2)}
6
+ ${r}`,severity:"error"})}return n},scope:"project"},K=e=>e.extraArgs?.length?[...e.extraArgs]:[],De=[Ie,fe,Fe,Pe,ge,Ne,Ee,Ue],at=async({logger:e,options:t,visConfig:n,workspaceRoot:r})=>{const i=r??process.cwd(),s=n?.lint;ae(e,"lint",s);const c=oe(De,s?.order),$=$e(i,c),x=ce($,c,"lint").filter(({adapter:o})=>{const l=s?.adapters?.[o.id]?.enabled;return o.optIn?l===!0:l!==!1});for(const o of c)o.optIn&&s?.adapters?.[o.id]?.enabled===!0&&!$.has(o.id)&&e.warn(`vis lint: adapters.${o.id}.enabled is set, but ${o.id} was not detected (needs a tsconfig.json and a typescript dependency at the workspace root). Skipping it.`);if(x.length===0){e.warn("vis lint: no linter detected in this workspace (looked for: oxlint, biome, eslint, stylelint, ruff, markdownlint, shellcheck; typecheck runs only when enabled).");return}const j=o=>{const l=s?.adapters?.[o]?.extraArgs;return l&&l.length>0?[...l]:void 0},A={extraArgs:void 0,maxWarnings:typeof t.maxWarnings=="number"?t.maxWarnings:void 0,quiet:t.quiet??!1},W=Ge(t),H=t.fix?"fix":"check";let g;if(t.staged){if(g=le(i),g===void 0)e.warn("vis lint: could not resolve --staged (not a git repo or git unavailable). Falling back to a workspace-wide run.");else if(g.length===0){e.info(I("✓ lint: no staged files"));return}}else if(typeof t.since=="string"&&t.since.length>0){if(g=de(i,t.since),g===void 0)e.warn(`vis lint: could not resolve --since ${t.since} (not a git repo or unknown ref). Falling back to a workspace-wide run.`);else if(g.length===0){e.info(I(`✓ lint: no files changed since ${t.since}`));return}}const _=W.length>0?W:void 0,X=se(i,void 0,void 0,!0),N=t.format??"human";N==="human"&&t.output!==void 0&&e.warn("vis lint: --output is ignored for the human format; pass --format json|minimal|sarif|junit|github to redirect findings to a file.");const R=async o=>{const l=o!==void 0&&o.length>0&&_===void 0,w=[];for(const{adapter:a,presence:y}of x){let u;if(a.scope==="project"){const q=_??o;if(q&&q.length>0&&P(q,a.extensions).length===0)continue;u=["."]}else if(l){if(u=P(o,a.extensions),u.length===0)continue}else u=_??o??["."];const F=j(a.id),E={adapter:a,files:u,presence:y};F&&(E.options={...A,extraArgs:F}),w.push(E)}if(w.length===0)return;const Q=await pe(w,A,H,{cacheRoot:X}),C=w.map((a,y)=>{const u=Q[y],F=a.adapter.parse(u,a.presence);return{adapter:a.adapter,durationMs:u.durationMs,exitCode:u.exitCode,findings:F}}),v=me(C.map(a=>({adapter:a.adapter.id,durationMs:a.durationMs,exitCode:a.exitCode,findingCount:a.findings.length,findings:a.findings}))),m=N==="human"?void 0:he({cwd:i,target:t.output});try{switch(N){case"github":{m.write(ve({runs:C.map(a=>({findings:a.findings})),workspaceRoot:i}));break}case"json":{m.write(`${JSON.stringify({findings:v.findings,runs:v.runs},null,2)}
7
7
  `);break}case"junit":{m.write(we({runs:C.map(a=>({adapter:a.adapter.id,durationMs:a.durationMs,findings:a.findings})),workspaceRoot:i}));break}case"minimal":{ze(v.findings,i,m);break}case"sarif":{m.write(xe({runs:C.map(a=>({adapter:a.adapter.id,findings:a.findings,presence:w.find(y=>y.adapter.id===a.adapter.id)?.presence})),workspaceRoot:i}));break}default:Ye(v.findings,i,e)}}finally{m?.close()}const T=ke(v);T!==0&&(process.exitCode=T)};if(t.watch){const o=[...new Set(x.flatMap(({adapter:l})=>l.extensions))];await ue({extensions:o,initialFiles:g,label:"lint",log:l=>{e.info(l)},runCycle:R,workspaceRoot:i});return}await R(g)},Ge=e=>{const t=e;return[...t._??t.args??[]]},Ye=(e,t,n)=>{if(e.length===0){n.info(I("✓ lint: no findings"));return}const r=ye(e);for(const[c,$]of r){n.info(re(S(t,c)));for(const p of $){const x=He(p),j=Xe(p.severity),A=p.ruleId?O(` ${p.ruleId}`):"";n.info(` ${O(x)} ${j} ${p.message}${A}`)}}const i=e.filter(c=>c.severity==="error").length,s=e.filter(c=>c.severity==="warning").length;n.info(""),n.info(`${U(`${String(i)} error${i===1?"":"s"}`)}, ${D(`${String(s)} warning${s===1?"":"s"}`)}`)},ze=(e,t,n)=>{for(const r of e){const i=S(t,r.file),s=r.line??"",c=r.column??"";n.write(`${r.adapter} ${i} ${String(s)} ${String(c)} ${r.severity} ${r.ruleId??""} ${r.message}
8
8
  `)}},He=e=>e.line===void 0?"":e.column===void 0?String(e.line):`${String(e.line)}:${String(e.column)}`,Xe=e=>e==="error"?U("error"):e==="warning"?D("warn "):ie("info ");export{at as default};