@visulima/vis 6.3.0 → 6.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (139) hide show
  1. package/CHANGELOG.md +6 -0
  2. package/dist/bin.js +1 -1
  3. package/dist/binx.js +1 -1
  4. package/dist/packem_chunks/bloom-sync.js +1 -1
  5. package/dist/packem_chunks/catalog2.js +1 -1
  6. package/dist/packem_chunks/cli-exec.js +1 -1
  7. package/dist/packem_chunks/cli-main.js +1 -1
  8. package/dist/packem_chunks/fix.js +1 -1
  9. package/dist/packem_chunks/git.js +8 -5
  10. package/dist/packem_chunks/handler10.js +1 -1
  11. package/dist/packem_chunks/handler12.js +1 -1
  12. package/dist/packem_chunks/handler13.js +1 -1
  13. package/dist/packem_chunks/handler14.js +1 -1
  14. package/dist/packem_chunks/handler15.js +1 -1
  15. package/dist/packem_chunks/handler19.js +1 -1
  16. package/dist/packem_chunks/handler2.js +1 -1
  17. package/dist/packem_chunks/handler20.js +1 -1
  18. package/dist/packem_chunks/handler21.js +1 -1
  19. package/dist/packem_chunks/handler23.js +1 -1
  20. package/dist/packem_chunks/handler24.js +1 -1
  21. package/dist/packem_chunks/handler25.js +1 -1
  22. package/dist/packem_chunks/handler26.js +1 -1
  23. package/dist/packem_chunks/handler28.js +1 -1
  24. package/dist/packem_chunks/handler3.js +1 -1
  25. package/dist/packem_chunks/handler32.js +1 -1
  26. package/dist/packem_chunks/handler4.js +1 -1
  27. package/dist/packem_chunks/handler46.js +1 -1
  28. package/dist/packem_chunks/handler49.js +1 -1
  29. package/dist/packem_chunks/handler5.js +1 -1
  30. package/dist/packem_chunks/handler50.js +1 -1
  31. package/dist/packem_chunks/handler51.js +1 -1
  32. package/dist/packem_chunks/handler52.js +1 -1
  33. package/dist/packem_chunks/handler54.js +1 -1
  34. package/dist/packem_chunks/handler55.js +1 -1
  35. package/dist/packem_chunks/handler56.js +4 -4
  36. package/dist/packem_chunks/handler58.js +1 -1
  37. package/dist/packem_chunks/handler59.js +1 -1
  38. package/dist/packem_chunks/handler6.js +1 -1
  39. package/dist/packem_chunks/handler60.js +1 -1
  40. package/dist/packem_chunks/handler61.js +1 -1
  41. package/dist/packem_chunks/handler62.js +1 -1
  42. package/dist/packem_chunks/handler63.js +1 -1
  43. package/dist/packem_chunks/handler64.js +1 -1
  44. package/dist/packem_chunks/handler65.js +1 -1
  45. package/dist/packem_chunks/handler66.js +1 -1
  46. package/dist/packem_chunks/handler67.js +1 -1
  47. package/dist/packem_chunks/handler68.js +1 -1
  48. package/dist/packem_chunks/handler69.js +1 -1
  49. package/dist/packem_chunks/handler7.js +1 -1
  50. package/dist/packem_chunks/handler70.js +1 -1
  51. package/dist/packem_chunks/handler71.js +1 -1
  52. package/dist/packem_chunks/handler72.js +1 -1
  53. package/dist/packem_chunks/handler73.js +1 -1
  54. package/dist/packem_chunks/handler74.js +1 -1
  55. package/dist/packem_chunks/handler75.js +1 -1
  56. package/dist/packem_chunks/handler76.js +1 -1
  57. package/dist/packem_chunks/handler77.js +1 -1
  58. package/dist/packem_chunks/handler78.js +1 -1
  59. package/dist/packem_chunks/handler79.js +1 -1
  60. package/dist/packem_chunks/handler8.js +1 -1
  61. package/dist/packem_chunks/heal.js +1 -1
  62. package/dist/packem_chunks/help-command.js +1 -1
  63. package/dist/packem_chunks/index2.js +3 -3
  64. package/dist/packem_chunks/index7.js +1 -1
  65. package/dist/packem_chunks/keys-refresh.js +1 -1
  66. package/dist/packem_chunks/list.js +1 -1
  67. package/dist/packem_chunks/prune.js +1 -1
  68. package/dist/packem_chunks/status.js +1 -1
  69. package/dist/packem_chunks/success-walk.js +7 -7
  70. package/dist/packem_chunks/sync.js +1 -1
  71. package/dist/packem_chunks/sync2.js +1 -1
  72. package/dist/packem_chunks/tripwire.js +1 -1
  73. package/dist/packem_chunks/verify-lockfile.js +1 -1
  74. package/dist/packem_shared/{ReleaseClient-DXlaCQuQ.js → ReleaseClient-1hH9OIcb.js} +1 -1
  75. package/dist/packem_shared/{advisories-DvmoRKco.js → advisories-DyHTz-me.js} +1 -1
  76. package/dist/packem_shared/{affected-selection-BCYW97-p.js → affected-selection-C3eYhoTa.js} +1 -1
  77. package/dist/packem_shared/{ai-analysis-C7JT_zkS.js → ai-analysis-y1glEwHU.js} +1 -1
  78. package/dist/packem_shared/{ai-cache-B-3KMpa9.js → ai-cache-Bq3dQd87.js} +1 -1
  79. package/dist/packem_shared/{ai-fix-PRDGLhGn.js → ai-fix-BQUNIOMp.js} +1 -1
  80. package/dist/packem_shared/apply-DA-Dv8Pq.js +8 -0
  81. package/dist/packem_shared/{bin-Bi_j0gXS.js → bin-DEQ52GkZ.js} +1 -1
  82. package/dist/packem_shared/{build-scripts-Bc8dOvdA.js → build-scripts-wF0ykoin.js} +1 -1
  83. package/dist/packem_shared/{dependency-scan-YbYZyLNf.js → dependency-scan-BNqHSRaA.js} +1 -1
  84. package/dist/packem_shared/{detect-clCqXvt_.js → detect-B9mLzG9L.js} +1 -1
  85. package/dist/packem_shared/{docker-hegwl1I6.js → docker-CpJj7VQ6.js} +1 -1
  86. package/dist/packem_shared/{ecosystem-gate-C9GmY9oJ.js → ecosystem-gate-DI5TKrtm.js} +1 -1
  87. package/dist/packem_shared/{env-DDmZsWBr.js → env-CsENUmRe.js} +1 -1
  88. package/dist/packem_shared/{env-consistency-Bn8a_NXB.js → env-consistency-HvLV2yQ6.js} +1 -1
  89. package/dist/packem_shared/{failure-log-D-YtsYF3.js → failure-log-C8Vh0Vtk.js} +1 -1
  90. package/dist/packem_shared/glob-Cyk1H9ZL-ChoYoZKK.js +1 -0
  91. package/dist/packem_shared/{index-C297jo7X.js → index-CFglig6K.js} +1 -1
  92. package/dist/packem_shared/{index-BRrpyvTT.js → index-CLcQ8Xe4.js} +1 -1
  93. package/dist/packem_shared/{interface.d-CrHOtJc1.d.ts → interface.d-Bb_1pid9.d.ts} +1 -1
  94. package/dist/packem_shared/{interface.d-CRqRz4jt.d.ts → interface.d-BlaMrDqd.d.ts} +7 -0
  95. package/dist/packem_shared/{lifecycle-BBEFEzfq.js → lifecycle-DNz4d7ND.js} +1 -1
  96. package/dist/packem_shared/{manifests-Caf3hlIO.js → manifests-CgyI-i-c.js} +1 -1
  97. package/dist/packem_shared/{min-release-age-BysoCN79.js → min-release-age-BpvYMZuT.js} +1 -1
  98. package/dist/packem_shared/{missing-package-json-Cvjhtrwa.js → missing-package-json-Bg72nt4h.js} +1 -1
  99. package/dist/packem_shared/{multi-eco-lockfiles-g-vAXRj7.js → multi-eco-lockfiles-BCGfTwHy.js} +1 -1
  100. package/dist/packem_shared/{native-config-sync-Bm9PtGpG.js → native-config-sync-em22UAUQ.js} +1 -1
  101. package/dist/packem_shared/{osv-9k7R7LU3.js → osv-CjtVHCRP.js} +1 -1
  102. package/dist/packem_shared/{package-version-CNjr03oy.js → package-version-BzkcrNVE.js} +1 -1
  103. package/dist/packem_shared/{packument-D_qCUp6X.js → packument-BvTjAHsy.js} +1 -1
  104. package/dist/packem_shared/{project-name-filter-D7cvTZtS.js → project-name-filter-DKFmLbwE.js} +1 -1
  105. package/dist/packem_shared/{provenance-DSeGe6vU.js → provenance-DFN3qbB3.js} +1 -1
  106. package/dist/packem_shared/publish-missing-MxqARUPC.js +35 -0
  107. package/dist/packem_shared/{registry-Mb5e6Tf4.js → registry-CIfr2njA.js} +1 -1
  108. package/dist/packem_shared/{registry-keys-CQxcAR-Z.js → registry-keys-Cq92YoCx.js} +1 -1
  109. package/dist/packem_shared/{renderToString-DR0zDUjh-DPXtZSQK.js → renderToString-DR0zDUjh-BUpUCnJt.js} +1 -1
  110. package/dist/packem_shared/{resolve-explicit-YbCvwu7l.js → resolve-explicit-CZlkR05q.js} +1 -1
  111. package/dist/packem_shared/{run-summary-utils-B0K6xaLZ.js → run-summary-utils-BYPm6bUE.js} +1 -1
  112. package/dist/packem_shared/{runtime-check-DDPs78Zv.js → runtime-check-DUxn-Idd.js} +1 -1
  113. package/dist/packem_shared/{s1ngularity-CCkRFMDX.js → s1ngularity-CPXsMMnh.js} +1 -1
  114. package/dist/packem_shared/{scaffold-files-Xt6zE44I.js → scaffold-files-ojq9leuZ.js} +1 -1
  115. package/dist/packem_shared/{scan-progress-BbxXKvTV.js → scan-progress-DBaFUryq.js} +1 -1
  116. package/dist/packem_shared/{selectors-CwKjRLHo.js → selectors-aT_XJTrh.js} +1 -1
  117. package/dist/packem_shared/{signatures-DDD9Iaer.js → signatures-C2HaWfZn.js} +1 -1
  118. package/dist/packem_shared/{spinner-BItORXCk.js → spinner-C23pifwn.js} +1 -1
  119. package/dist/packem_shared/{table-DsmWzLWy.js → table-CAjUuSN2.js} +1 -1
  120. package/dist/packem_shared/{tabs-D61j1uvE.js → tabs-CogGAIWQ.js} +1 -1
  121. package/dist/packem_shared/{toolchain-Z0l12EQs.js → toolchain-BF6NEQJ2.js} +1 -1
  122. package/dist/packem_shared/{typosquats-Da4w5sjI.js → typosquats-MPA4DNWt.js} +1 -1
  123. package/dist/packem_shared/{use-measured-height-UU40gqT7.js → use-measured-height-BHJ8aL73.js} +1 -1
  124. package/dist/packem_shared/{vis-update-app-Bin63opa.js → vis-update-app--aolEPqW.js} +1 -1
  125. package/dist/packem_shared/{vis-user-error-wkTUvlyX.js → vis-user-error-DUyARIaA.js} +1 -1
  126. package/dist/packem_shared/{watch-loop-CGBVtTBl.js → watch-loop-C7VCU587.js} +1 -1
  127. package/dist/release/core/changelog/index.d.ts +1 -1
  128. package/dist/release/core/package-managers/index.d.ts +2 -2
  129. package/dist/release/core/version-actions/index.d.ts +3 -3
  130. package/dist/release/index.js +1 -1
  131. package/dist/release/plugin-sdk.d.ts +3 -3
  132. package/dist/release/types.d.ts +31 -0
  133. package/index.js +26 -26
  134. package/package.json +9 -9
  135. package/schemas/vis-config.schema.json +16 -0
  136. package/schemas/vis-release-config.schema.json +16 -0
  137. package/dist/packem_shared/apply-DBU-Gu24.js +0 -6
  138. package/dist/packem_shared/glob-Cyk1H9ZL-BjuiUjNv.js +0 -1
  139. package/dist/packem_shared/publish-missing-DwaM7zcX.js +0 -35
@@ -1,3 +1,3 @@
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 P}from"../packem_shared/index-0dnGN3GP.js";import{R 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-CGBVtTBl.js";import{v as h}from"../packem_shared/registry-Mb5e6Tf4.js";import{d as C,f as _,a as pe}from"../packem_shared/detect-clCqXvt_.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)=>T(e,t,"check"),argsFix:(e,t)=>T(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}},T=(e,t,s)=>{const i=s==="fix"?["fmt"]:["check","--list-different"];return t.extraArgs?.length&&i.push(...t.extraArgs),i.push(...e),i},he={argsCheck:(e,t)=>V(e,t,"check"),argsFix:(e,t)=>V(e,t,"fix"),bin:()=>["pnpm","exec","oxfmt"],cacheKey:(e,t)=>{const s=["oxfmt",e.declaredVersion??"unknown",e.configFile??"no-config",t.quiet?"q":"",...t.extraArgs??[]];return F("sha256").update(s.join("|")).digest("hex").slice(0,16)},detect:(e,t)=>{const s=C(t,h.oxfmt.packageNames[0]),i=_(e,h.oxfmt.configFiles);if(!(!s&&!i))return{adapter:"oxfmt",configFile:i,declared:!!s,declaredVersion:s,root:e}},extensions:["cjs","cts","js","json","jsonc","jsx","mjs","mts","ts","tsx"],id:"oxfmt",kind:"fmt",parse:(e,t)=>{if(e.exitCode===0)return[];const s=[];for(const i of e.stdout.split(/\r?\n/)){const n=i.trim();!n||n.startsWith("[")||s.push({adapter:"oxfmt",file:q(t.root,n),fixable:!0,message:"Code style issues would be auto-fixed",severity:"info"})}return s}},V=(e,t,s)=>{const i=s==="fix"?["--write"]:["--list-different"];return t.extraArgs?.length&&i.push(...t.extraArgs),i.push(...e),i},xe={argsCheck:(e,t)=>N(e,t,"check"),argsFix:(e,t)=>N(e,t,"fix"),bin:()=>["pnpm","exec","prettier"],cacheKey:(e,t)=>{const s=["prettier",e.declaredVersion??"unknown",e.configFile??"no-config",t.quiet?"q":"",...t.extraArgs??[]];return F("sha256").update(s.join("|")).digest("hex").slice(0,16)},detect:(e,t)=>{const s=C(t,h.prettier.packageNames[0]),i=_(e,h.prettier.configFiles);if(!(!s&&!i))return{adapter:"prettier",configFile:i,declared:!!s,declaredVersion:s,root:e}},extensions:["cjs","css","cts","html","js","json","jsx","less","md","mdx","mjs","mts","scss","ts","tsx","vue","yaml","yml"],id:"prettier",kind:"fmt",parse:(e,t)=>{if(e.exitCode===0)return[];const s=[];for(const i of e.stdout.split(/\r?\n/)){const n=i.trim();n&&(n.startsWith("[")||s.push({adapter:"prettier",file:q(t.root,n),fixable:!0,message:"Code style issues would be auto-fixed",severity:"info"}))}return s}},N=(e,t,s)=>{const i=s==="fix"?["--write"]:["--list-different"];return t.quiet&&i.push("--log-level","warn"),t.extraArgs?.length&&i.push(...t.extraArgs),i.push(...e),i},we=[he,se,me,xe,ie],$e=async({logger:e,options:t,visConfig:s,workspaceRoot:i})=>{const n=i??process.cwd(),l=s?.fmt;Q(e,"fmt",l);const k=X(we,l?.order),L=pe(n,k),x=Y(L,k,"fmt").filter(({adapter:u})=>l?.adapters?.[u.id]?.enabled!==!1);if(x.length===0){e.warn("vis fmt: no formatter detected in this workspace (looked for: oxfmt, biome, dprint, prettier, ruff).");return}const R=u=>{const a=l?.adapters?.[u]?.extraArgs;return a&&a.length>0?[...a]:void 0},v={quiet:t.quiet??!1},$=ke(t),b=t.check?"check":"fix";let c;if(t.staged){if(c=Z(n),c===void 0)e.warn("vis fmt: could not resolve --staged (not a git repo or git unavailable). Falling back to a workspace-wide run.");else if(c.length===0){e.info(A("✓ fmt: no staged files"));return}}else if(typeof t.since=="string"&&t.since.length>0){if(c=ee(n,t.since),c===void 0)e.warn(`vis fmt: could not resolve --since ${t.since} (not a git repo or unknown ref). Falling back to a workspace-wide run.`);else if(c.length===0){e.info(A(`✓ fmt: no files changed since ${t.since}`));return}}const K=I(n,void 0,void 0,!0),y=t.format??"human";y==="human"&&t.output!==void 0&&e.warn("vis fmt: --output is ignored for the human format; pass --format json|minimal|sarif|junit|github to redirect findings to a file.");const M=async u=>{const a=$.length>0?$:u,g=[];if(a){const r=ne(a,x,l?.extensionOverrides);for(const{adapter:o,presence:d}of x){const f=r.get(o.id);if(!f||f.length===0)continue;const B=R(o.id),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)}
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 P}from"../packem_shared/index-0dnGN3GP.js";import{R 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-C7VCU587.js";import{v as h}from"../packem_shared/registry-CIfr2njA.js";import{d as C,f as _,a as pe}from"../packem_shared/detect-B9mLzG9L.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)=>T(e,t,"check"),argsFix:(e,t)=>T(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}},T=(e,t,s)=>{const i=s==="fix"?["fmt"]:["check","--list-different"];return t.extraArgs?.length&&i.push(...t.extraArgs),i.push(...e),i},he={argsCheck:(e,t)=>V(e,t,"check"),argsFix:(e,t)=>V(e,t,"fix"),bin:()=>["pnpm","exec","oxfmt"],cacheKey:(e,t)=>{const s=["oxfmt",e.declaredVersion??"unknown",e.configFile??"no-config",t.quiet?"q":"",...t.extraArgs??[]];return F("sha256").update(s.join("|")).digest("hex").slice(0,16)},detect:(e,t)=>{const s=C(t,h.oxfmt.packageNames[0]),i=_(e,h.oxfmt.configFiles);if(!(!s&&!i))return{adapter:"oxfmt",configFile:i,declared:!!s,declaredVersion:s,root:e}},extensions:["cjs","cts","js","json","jsonc","jsx","mjs","mts","ts","tsx"],id:"oxfmt",kind:"fmt",parse:(e,t)=>{if(e.exitCode===0)return[];const s=[];for(const i of e.stdout.split(/\r?\n/)){const n=i.trim();!n||n.startsWith("[")||s.push({adapter:"oxfmt",file:q(t.root,n),fixable:!0,message:"Code style issues would be auto-fixed",severity:"info"})}return s}},V=(e,t,s)=>{const i=s==="fix"?["--write"]:["--list-different"];return t.extraArgs?.length&&i.push(...t.extraArgs),i.push(...e),i},xe={argsCheck:(e,t)=>N(e,t,"check"),argsFix:(e,t)=>N(e,t,"fix"),bin:()=>["pnpm","exec","prettier"],cacheKey:(e,t)=>{const s=["prettier",e.declaredVersion??"unknown",e.configFile??"no-config",t.quiet?"q":"",...t.extraArgs??[]];return F("sha256").update(s.join("|")).digest("hex").slice(0,16)},detect:(e,t)=>{const s=C(t,h.prettier.packageNames[0]),i=_(e,h.prettier.configFiles);if(!(!s&&!i))return{adapter:"prettier",configFile:i,declared:!!s,declaredVersion:s,root:e}},extensions:["cjs","css","cts","html","js","json","jsx","less","md","mdx","mjs","mts","scss","ts","tsx","vue","yaml","yml"],id:"prettier",kind:"fmt",parse:(e,t)=>{if(e.exitCode===0)return[];const s=[];for(const i of e.stdout.split(/\r?\n/)){const n=i.trim();n&&(n.startsWith("[")||s.push({adapter:"prettier",file:q(t.root,n),fixable:!0,message:"Code style issues would be auto-fixed",severity:"info"}))}return s}},N=(e,t,s)=>{const i=s==="fix"?["--write"]:["--list-different"];return t.quiet&&i.push("--log-level","warn"),t.extraArgs?.length&&i.push(...t.extraArgs),i.push(...e),i},we=[he,se,me,xe,ie],$e=async({logger:e,options:t,visConfig:s,workspaceRoot:i})=>{const n=i??process.cwd(),l=s?.fmt;Q(e,"fmt",l);const k=X(we,l?.order),L=pe(n,k),x=Y(L,k,"fmt").filter(({adapter:u})=>l?.adapters?.[u.id]?.enabled!==!1);if(x.length===0){e.warn("vis fmt: no formatter detected in this workspace (looked for: oxfmt, biome, dprint, prettier, ruff).");return}const R=u=>{const a=l?.adapters?.[u]?.extraArgs;return a&&a.length>0?[...a]:void 0},v={quiet:t.quiet??!1},$=ke(t),b=t.check?"check":"fix";let c;if(t.staged){if(c=Z(n),c===void 0)e.warn("vis fmt: could not resolve --staged (not a git repo or git unavailable). Falling back to a workspace-wide run.");else if(c.length===0){e.info(A("✓ fmt: no staged files"));return}}else if(typeof t.since=="string"&&t.since.length>0){if(c=ee(n,t.since),c===void 0)e.warn(`vis fmt: could not resolve --since ${t.since} (not a git repo or unknown ref). Falling back to a workspace-wide run.`);else if(c.length===0){e.info(A(`✓ fmt: no files changed since ${t.since}`));return}}const K=I(n,void 0,void 0,!0),y=t.format??"human";y==="human"&&t.output!==void 0&&e.warn("vis fmt: --output is ignored for the human format; pass --format json|minimal|sarif|junit|github to redirect findings to a file.");const M=async u=>{const a=$.length>0?$:u,g=[];if(a){const r=ne(a,x,l?.extensionOverrides);for(const{adapter:o,presence:d}of x){const f=r.get(o.id);if(!f||f.length===0)continue;const B=R(o.id),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
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("·")} ${P(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} ${P(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-0dnGN3GP.js";import{y as _}from"../packem_shared/isAccessibleSync-DYKTrrvc-CBsMZhj-.js";import{L as K}from"../packem_shared/registry-Mb5e6Tf4.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/env-DDmZsWBr.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}
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-0dnGN3GP.js";import{y as _}from"../packem_shared/isAccessibleSync-DYKTrrvc-CBsMZhj-.js";import{L as K}from"../packem_shared/registry-CIfr2njA.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/env-CsENUmRe.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,2 +1,2 @@
1
- import{j as I,q as F,F as S}from"../packem_shared/index.server-Ca_EEVfw.js";import{projectGraphToDot as W}from"@visulima/task-runner";import{L as X,M as Q,N as J,K,C as z,P as Z,Q as L,q as ee}from"./cli-main.js";import{i as te}from"../packem_shared/index-BjdW45xX.js";import{j as e,X as l,O as t,r as C,d as re,b as se,R as le}from"../packem_shared/registry-Mb5e6Tf4.js";const ie={application:0,library:3,service:1,tool:2},M=c=>ie[c]??Number.MAX_SAFE_INTEGER,ne=c=>{const r=new Map;for(const[o,s]of Object.entries(c.dependencies))for(const i of s){const n=r.get(i.target)??[];n.push(o),r.set(i.target,n)}return Object.values(c.nodes).map(o=>({deps:c.dependencies[o.name]??[],name:o.name,reverseDeps:r.get(o.name)??[],type:o.type})).sort((o,s)=>o.type!==s.type?M(o.type)-M(s.type):o.name.localeCompare(s.name))},oe=(c,r,o)=>{let s=c;if(r==="app"?s=s.filter(i=>i.type==="application"):r==="lib"&&(s=s.filter(i=>i.type!=="application")),o){const i=o.toLowerCase();s=s.filter(n=>n.name.toLowerCase().includes(i))}return s};class ce{#e;#r=new Set;#s;constructor(r){this.#s=r;const o=ne(r);this.#e={allNodes:o,filterActive:!1,filterText:"",filterType:"all",focusedPanel:"list",selectedIndex:0}}getSnapshot=()=>this.#e;subscribe=r=>(this.#r.add(r),()=>{this.#r.delete(r)});getFilteredNodes(){return oe(this.#e.allNodes,this.#e.filterType,this.#e.filterText)}getStats(){const r=this.#e.allNodes.filter(i=>i.type==="application").length,o=this.#e.allNodes.length,s=Object.values(this.#s.dependencies).reduce((i,n)=>i+n.length,0);return{apps:r,deps:s,libs:o-r,total:o}}setSelectedIndex(r){const o=this.getFilteredNodes(),s=o.length===0?-1:Math.max(0,Math.min(r,o.length-1));s!==this.#e.selectedIndex&&this.#t({...this.#e,selectedIndex:s})}setFocusedPanel(r){r!==this.#e.focusedPanel&&this.#t({...this.#e,focusedPanel:r})}setFilterType(r){r!==this.#e.filterType&&this.#t({...this.#e,filterType:r,selectedIndex:0})}setFilter(r){this.#t({...this.#e,filterText:r,selectedIndex:0})}setFilterActive(r){r!==this.#e.filterActive&&this.#t({...this.#e,filterActive:r,filterText:r?this.#e.filterText:"",selectedIndex:r?this.#e.selectedIndex:0})}#t(r){this.#e=r;for(const o of this.#r)try{o()}catch{}}}const de=({focused:c,node:r,scrollRef:o})=>{const s=c?"white":"gray";if(!r)return e.jsx(l,{alignItems:"center",borderColor:"gray",borderStyle:"single",flexDirection:"column",flexGrow:1,justifyContent:"center",children:e.jsx(t,{dimColor:!0,children:"No project selected"})});const i=r.type==="application",n=i?"yellow":"cyan",T=i?"Application":"Library";return e.jsx(l,{borderColor:s,borderStyle:"single",borderTopRightTitle:` ${T} `,borderTopTitle:` ${r.name} `,flexDirection:"column",flexGrow:1,children:e.jsxs(X,{flexGrow:1,flexShrink:1,paddingX:2,ref:o,scrollbar:!0,scrollbarColor:"gray",children:[e.jsxs(l,{flexDirection:"column",marginTop:1,children:[e.jsxs(l,{children:[e.jsx(t,{dimColor:!0,children:"── "}),e.jsx(t,{bold:!0,color:"white",children:"DEPENDS ON"}),e.jsxs(t,{dimColor:!0,children:[" ","(",r.deps.length,")"]})]}),r.deps.length===0?e.jsx(l,{marginTop:1,paddingLeft:2,children:e.jsx(t,{dimColor:!0,children:"No dependencies"})}):e.jsx(l,{flexDirection:"column",marginTop:1,children:r.deps.map(h=>e.jsxs(l,{gap:1,paddingLeft:2,children:[e.jsx(t,{color:"cyan",children:"→"}),e.jsx(t,{children:h.target}),h.type!=="static"&&e.jsxs(t,{dimColor:!0,children:["(",h.type,")"]})]},h.target))})]}),e.jsxs(l,{flexDirection:"column",marginTop:1,children:[e.jsxs(l,{children:[e.jsx(t,{dimColor:!0,children:"── "}),e.jsx(t,{bold:!0,color:"white",children:"REQUIRED BY"}),e.jsxs(t,{dimColor:!0,children:[" ","(",r.reverseDeps.length,")"]})]}),r.reverseDeps.length===0?e.jsx(l,{marginTop:1,paddingLeft:2,children:e.jsx(t,{dimColor:!0,children:"No reverse dependencies"})}):e.jsx(l,{flexDirection:"column",marginTop:1,children:r.reverseDeps.map(h=>e.jsxs(l,{gap:1,paddingLeft:2,children:[e.jsx(t,{color:"magenta",children:"←"}),e.jsx(t,{children:h})]},h))})]}),e.jsxs(l,{flexDirection:"column",marginTop:1,children:[e.jsxs(l,{children:[e.jsx(t,{dimColor:!0,children:"── "}),e.jsx(t,{bold:!0,color:"white",children:"INFO"})]}),e.jsxs(l,{flexDirection:"column",marginTop:1,paddingLeft:2,children:[e.jsxs(l,{children:[e.jsx(l,{width:16,children:e.jsx(t,{dimColor:!0,children:"Type:"})}),e.jsx(t,{color:n,children:T})]}),e.jsxs(l,{children:[e.jsx(l,{width:16,children:e.jsx(t,{dimColor:!0,children:"Dependencies:"})}),e.jsx(t,{children:String(r.deps.length)})]}),e.jsxs(l,{children:[e.jsx(l,{width:16,children:e.jsx(t,{dimColor:!0,children:"Required by:"})}),e.jsx(t,{children:String(r.reverseDeps.length)})]}),e.jsxs(l,{children:[e.jsx(l,{width:16,children:e.jsx(t,{dimColor:!0,children:"Connectivity:"})}),e.jsx(t,{children:String(r.deps.length+r.reverseDeps.length)})]})]})]})]})})},ae=[{key:"all",label:"All",shortcut:"1"},{key:"app",label:"Apps",shortcut:"2"},{key:"lib",label:"Libs",shortcut:"3"}],O=({isSelected:c,node:r})=>{const o=r.type==="application",s=o?"yellow":"cyan",i=o?"app":"lib";return e.jsxs(l,{flexShrink:0,height:1,children:[e.jsxs(t,{children:[c?"▶":" "," "]}),e.jsx(l,{flexGrow:1,children:e.jsx(t,{bold:c,inverse:c,wrap:"truncate",children:r.name})}),e.jsxs(t,{color:s,children:[" ",i]}),e.jsxs(t,{dimColor:!0,children:[" ","→",r.deps.length," ","←",r.reverseDeps.length]})]})},G=({count:c,label:r})=>e.jsxs(l,{flexShrink:0,height:1,marginTop:1,children:[e.jsxs(t,{dimColor:!0,children:["▼"," "]}),e.jsx(t,{bold:!0,color:"white",children:r.toUpperCase()}),e.jsxs(t,{dimColor:!0,children:[" ","(",c,")"]})]}),he=({filterActive:c,filterText:r,filterType:o,focused:s,nodes:i,scrollOffset:n,selectedIndex:T,stats:h,viewportHeight:w})=>{const u=s?"white":"gray",b=i.filter(f=>f.type==="application"),a=i.filter(f=>f.type!=="application"),j=[];let x=0;if(b.length>0){j.push(e.jsx(G,{count:b.length,label:"Applications"},"hdr-apps"));for(const f of b){const y=x;j.push(e.jsx(O,{isSelected:y===T,node:f},f.name)),x++}}if(a.length>0){j.push(e.jsx(G,{count:a.length,label:"Libraries"},"hdr-libs"));for(const f of a){const y=x;j.push(e.jsx(O,{isSelected:y===T,node:f},f.name)),x++}}let g=0;b.length>0&&(g+=2+b.length),a.length>0&&(g+=2+a.length);const A=g>w&&w>0;return e.jsxs(l,{borderColor:u,borderStyle:"single",flexDirection:"column",flexGrow:1,children:[e.jsxs(l,{flexShrink:0,gap:1,paddingX:1,children:[e.jsx(t,{bold:!0,inverse:!0,children:" VIS "}),e.jsxs(t,{wrap:"truncate",children:[h.total," ","packages"]}),e.jsxs(t,{dimColor:!0,children:["(",h.apps," ","apps,"," ",h.libs," ","libs,"," ",h.deps," ","deps)"]})]}),e.jsx(l,{flexShrink:0,gap:1,paddingX:1,paddingY:1,children:ae.map(f=>{const y=o===f.key;return e.jsxs(l,{children:[e.jsx(t,{dimColor:!y,children:"["}),e.jsx(t,{bold:y,color:y?"cyan":"gray",children:f.shortcut}),e.jsx(t,{dimColor:!y,children:"]"}),e.jsxs(t,{color:y?"white":"gray",children:[" ",f.label]})]},f.key)})}),c&&e.jsxs(l,{flexShrink:0,paddingX:1,children:[e.jsx(t,{bold:!0,color:"white",children:"/ "}),e.jsx(t,{children:r}),e.jsx(t,{inverse:!0,children:" "})]}),e.jsxs(l,{flexDirection:"row",flexGrow:1,overflow:"hidden",children:[e.jsx(l,{flexDirection:"column",flexGrow:1,overflow:"hidden",paddingLeft:1,children:e.jsx(l,{flexDirection:"column",marginTop:-n,children:j})}),A&&e.jsx(l,{flexShrink:0,marginLeft:1,marginRight:1,children:e.jsx(Q,{contentHeight:g,placement:"inset",scrollOffset:n,style:"block",viewportHeight:w})})]})]})},pe=100,ue=40,xe=10,B={1:"all",2:"app",3:"lib"},fe=({autoExitSeconds:c=0,store:r})=>{const{exit:o}=J(),{columns:s,rows:i}=K(),n=C.useSyncExternalStore(r.subscribe,r.getSnapshot),[T,h]=C.useState(!1),w=C.useRef(null),u=C.useRef(null),[b,a]=C.useState(0),[j,x]=C.useState(!1),g=C.useMemo(()=>r.getFilteredNodes(),[n.allNodes,n.filterType,n.filterText]),A=C.useMemo(()=>r.getStats(),[n.allNodes]),f=g[n.selectedIndex]??null,y=C.useMemo(()=>{let p=0,d=0;for(const m of g)m.type==="application"?p+=1:d+=1;return{appsCount:p,libsCount:d}},[g]),R=C.useCallback(p=>{const{appsCount:d,libsCount:m}=y;if(p<d)return(d>0?2:0)+p;const Y=d>0?2+d:0,U=m>0?2:0;return Y+U+(p-d)},[y]),D=Math.max(1,i-8-(n.filterActive?1:0)),v=C.useCallback(p=>{const d=R(p);a(m=>d>m+D-2?Math.max(0,d-D+2):d<m+1?Math.max(0,d-1):m)},[R,D]);if(C.useEffect(()=>{u.current?.scrollToTop()},[f?.name]),z((p,d)=>{if(p==="c"&&d.ctrl){o();return}if(!j){if(T){d.escape||p==="?"?h(!1):p==="q"?(h(!1),x(!0)):d.downArrow||p==="j"?w.current?.scrollBy(1):(d.upArrow||p==="k")&&w.current?.scrollBy(-1);return}if(p==="?"){h(!0);return}if(p==="q"){x(!0);return}if(d.tab){r.setFocusedPanel(n.focusedPanel==="list"?"detail":"list");return}if(B[p]){r.setFilterType(B[p]);return}if(n.filterActive){if(d.escape){r.setFilterActive(!1);return}if(d.return){r.setFilterActive(!1);return}if(d.backspace){r.setFilter(n.filterText.slice(0,-1));return}if(p&&!d.ctrl&&!d.meta){r.setFilter(n.filterText+p);return}return}if(n.focusedPanel==="list"){if(g.length===0){p==="/"&&r.setFilterActive(!0);return}if(d.downArrow||p==="j"){const m=Math.min(n.selectedIndex+1,g.length-1);r.setSelectedIndex(m),v(m);return}if(d.upArrow||p==="k"){const m=Math.max(n.selectedIndex-1,0);r.setSelectedIndex(m),v(m);return}if(d.pageDown){const m=Math.min(n.selectedIndex+10,g.length-1);r.setSelectedIndex(m),v(m);return}if(d.pageUp){const m=Math.max(n.selectedIndex-10,0);r.setSelectedIndex(m),v(m);return}if(d.home){r.setSelectedIndex(0),a(0);return}if(d.end){const m=g.length-1;r.setSelectedIndex(m),v(m);return}if(p==="/"){r.setFilterActive(!0);return}if(d.rightArrow){r.setFocusedPanel("detail");return}return}if(n.focusedPanel==="detail"){if(d.escape||d.leftArrow){r.setFocusedPanel("list");return}if(d.downArrow||p==="j"){u.current?.scrollBy(1);return}if(d.upArrow||p==="k"){u.current?.scrollBy(-1);return}if(d.pageDown){u.current?.scrollBy(10);return}if(d.pageUp){u.current?.scrollBy(-10);return}if(d.home){u.current?.scrollToTop();return}d.end&&u.current?.scrollToBottom()}}},{isActive:!0}),s<ue||i<xe)return e.jsx(l,{alignItems:"center",height:i,justifyContent:"center",width:s,children:e.jsxs(t,{color:"yellow",children:["Terminal too small (",s,"x",i,")"]})});const _=s>=pe,P=e.jsx(l,{borderBottom:!1,borderColor:"gray",borderLeft:!1,borderRight:!1,borderStyle:"single",flexShrink:0,children:e.jsxs(l,{flexWrap:"wrap",gap:2,paddingX:1,children:[e.jsxs(l,{gap:1,children:[e.jsx(t,{bold:!0,color:"white",children:"q"}),e.jsx(t,{dimColor:!0,children:"QUIT"})]},"q"),e.jsxs(l,{gap:1,children:[e.jsx(t,{bold:!0,color:"white",children:"?"}),e.jsx(t,{dimColor:!0,children:"HELP"})]},"?"),e.jsxs(l,{gap:1,children:[e.jsx(t,{bold:!0,color:"white",children:"↑↓"}),e.jsx(t,{dimColor:!0,children:"NAV"})]},"nav"),e.jsxs(l,{gap:1,children:[e.jsx(t,{bold:!0,color:"white",children:"1-3 /"}),e.jsx(t,{dimColor:!0,children:"FILTER"})]},"f"),e.jsxs(l,{gap:1,children:[e.jsx(t,{bold:!0,color:"white",children:"Tab"}),e.jsx(t,{dimColor:!0,children:"PANEL"})]},"t")]})}),N=e.jsxs(Z,{footer:e.jsxs(t,{dimColor:!0,children:[e.jsx(t,{bold:!0,color:"white",children:"↑↓"})," ","scroll"," ",e.jsx(t,{bold:!0,color:"white",children:"?"}),"/",e.jsx(t,{bold:!0,color:"white",children:"Esc"})," ","close"]}),scrollRef:w,title:"KEYBOARD SHORTCUTS",visible:T,width:52,children:[e.jsxs(l,{flexDirection:"column",marginBottom:1,children:[e.jsxs(l,{marginBottom:1,children:[e.jsx(t,{dimColor:!0,children:"── "}),e.jsx(t,{bold:!0,color:"white",children:"NAVIGATION"})]}),e.jsxs(l,{children:[e.jsx(l,{width:24,children:e.jsxs(t,{children:[e.jsxs(t,{bold:!0,color:"white",children:[" ","↑","/k"]}),e.jsx(t,{dimColor:!0,children:" Move up"})]})}),e.jsxs(t,{children:[e.jsxs(t,{bold:!0,color:"white",children:[" ","↓","/j"]}),e.jsx(t,{dimColor:!0,children:" Move down"})]})]}),e.jsxs(t,{children:[e.jsxs(t,{bold:!0,color:"white",children:[" ","Tab"]}),e.jsx(t,{dimColor:!0,children:" Switch panel"})]}),e.jsxs(t,{children:[e.jsxs(t,{bold:!0,color:"white",children:[" ","→","/","←"]}),e.jsx(t,{dimColor:!0,children:" Focus detail/list"})]}),e.jsxs(t,{children:[e.jsxs(t,{bold:!0,color:"white",children:[" ","PgUp/PgDn"]}),e.jsx(t,{dimColor:!0,children:" Jump 10 items"})]}),e.jsxs(t,{children:[e.jsxs(t,{bold:!0,color:"white",children:[" ","Home/End"]}),e.jsx(t,{dimColor:!0,children:" Jump to start/end"})]})]}),e.jsxs(l,{flexDirection:"column",marginBottom:1,children:[e.jsxs(l,{marginBottom:1,children:[e.jsx(t,{dimColor:!0,children:"── "}),e.jsx(t,{bold:!0,color:"white",children:"FILTERS"})]}),e.jsxs(l,{children:[e.jsx(l,{width:24,children:e.jsxs(t,{children:[e.jsxs(t,{bold:!0,color:"white",children:[" ","1"]}),e.jsx(t,{dimColor:!0,children:" All"})]})}),e.jsxs(t,{children:[e.jsxs(t,{bold:!0,color:"white",children:[" ","2"]}),e.jsx(t,{dimColor:!0,children:" Apps only"})]})]}),e.jsxs(t,{children:[e.jsxs(t,{bold:!0,color:"white",children:[" ","3"]}),e.jsx(t,{dimColor:!0,children:" Libraries only"})]}),e.jsxs(t,{children:[e.jsxs(t,{bold:!0,color:"white",children:[" ","/"]}),e.jsx(t,{dimColor:!0,children:" Text filter"})]})]}),e.jsxs(l,{flexDirection:"column",children:[e.jsxs(l,{marginBottom:1,children:[e.jsx(t,{dimColor:!0,children:"── "}),e.jsx(t,{bold:!0,color:"white",children:"ACTIONS"})]}),e.jsxs(t,{children:[e.jsxs(t,{bold:!0,color:"white",children:[" ","q"]}),e.jsx(t,{dimColor:!0,children:" Quit"})]}),e.jsxs(t,{children:[e.jsxs(t,{bold:!0,color:"white",children:[" ","?"]}),e.jsx(t,{dimColor:!0,children:" Toggle help"})]})]})]}),E=e.jsx(he,{filterActive:n.filterActive,filterText:n.filterText,filterType:n.filterType,focused:n.focusedPanel==="list",nodes:g,scrollOffset:b,selectedIndex:n.selectedIndex,stats:A,viewportHeight:D}),$=e.jsx(de,{focused:n.focusedPanel==="detail",node:f,scrollRef:u});if(_){const p=Math.floor(s*.35);return e.jsxs(l,{flexDirection:"column",height:i,width:s,children:[e.jsxs(l,{flexDirection:"row",flexGrow:1,children:[e.jsx(l,{flexGrow:1,children:E}),e.jsx(l,{width:p,children:$})]}),P,e.jsx(L,{autoExitSeconds:c??3,onCancel:()=>{x(!1)},visible:j}),N]})}const q=Math.floor(i*.55);return e.jsxs(l,{flexDirection:"column",height:i,width:s,children:[e.jsx(l,{height:q,children:E}),e.jsx(l,{flexGrow:1,children:$}),P,e.jsx(L,{autoExitSeconds:c??3,onCancel:()=>{x(!1)},visible:j}),N]})},V=(c,r,o,s,i,n,T,h)=>{const w=o?S("└── "):S("├── "),u=i.has(c),b=u?S(" (*)"):"",a=s.get(c),x=a?.type==="application"?I(c):c;if(n.push(`${r}${w}${x}${b}`),u)return;i.add(c);const g=a?.deps??[],A=o?`${r} `:`${r}${S("│")} `;if(h>=T&&g.length>0){n.push(`${A}${S(`... ${g.length} more`)}`);return}for(let f=0;f<g.length;f++){const y=g[f];y&&V(y.target,A,f===g.length-1,s,i,n,T,h+1)}},H=(c,r,o,s,i,n)=>{const T=r.get(c),w=T?.type==="application"?I(c):c;s.push(`${n}${w}`),o.add(c);const u=T?.deps??[];if(u.length===0){s.push(`${n} ${S("(no dependencies)")}`);return}if(i<=0){s.push(`${n} ${S(`... ${u.length} dependencies`)}`);return}for(let b=0;b<u.length;b++){const a=u[b];a&&V(a.target,n,b===u.length-1,r,o,s,i,1)}},k=(c,r)=>{const o=new Map;for(const[a,j]of Object.entries(c.nodes))o.set(a,{deps:(c.dependencies[a]??[]).map(x=>({target:x.target,type:x.type})),name:a,type:j.type});const s=[],i=[];for(const[a,j]of o)j.type==="application"?s.push(a):i.push(a);s.sort(),i.sort();const n=s.length+i.length,T=Object.values(c.dependencies).reduce((a,j)=>a+j.length,0),h=[I("Project Dependency Graph"),""];if(s.length>0){h.push(` ${I(F(`Applications (${s.length})`))}`,"");for(const a of s)H(a,o,new Set,h,r," "),h.push("")}if(i.length>0){h.push(` ${I(F(`Libraries (${i.length})`))}`,"");for(const a of i)H(a,o,new Set,h,r," "),h.push("")}const w=process.stdout.columns||80;h.push(S("─".repeat(Math.min(w,60)))),h.push(`${I(String(n))} packages ${S("·")} ${I(String(T))} dependencies ${S("·")} ${I(String(s.length))} apps${S(",")} ${I(String(i.length))} libraries`);const u=new Set;let b=!1;for(const a of[...s,...i]){const j=o.get(a)?.deps??[];for(const x of j)u.has(x.target)&&(b=!0),u.add(x.target);u.add(a)}return b&&h.push(S("(*) = already shown above")),h.join(`
1
+ import{j as I,q as F,F as S}from"../packem_shared/index.server-Ca_EEVfw.js";import{projectGraphToDot as W}from"@visulima/task-runner";import{L as X,M as Q,N as J,K,C as z,P as Z,Q as L,q as ee}from"./cli-main.js";import{i as te}from"../packem_shared/index-BjdW45xX.js";import{j as e,X as l,O as t,r as C,d as re,b as se,R as le}from"../packem_shared/registry-CIfr2njA.js";const ie={application:0,library:3,service:1,tool:2},M=c=>ie[c]??Number.MAX_SAFE_INTEGER,ne=c=>{const r=new Map;for(const[o,s]of Object.entries(c.dependencies))for(const i of s){const n=r.get(i.target)??[];n.push(o),r.set(i.target,n)}return Object.values(c.nodes).map(o=>({deps:c.dependencies[o.name]??[],name:o.name,reverseDeps:r.get(o.name)??[],type:o.type})).sort((o,s)=>o.type!==s.type?M(o.type)-M(s.type):o.name.localeCompare(s.name))},oe=(c,r,o)=>{let s=c;if(r==="app"?s=s.filter(i=>i.type==="application"):r==="lib"&&(s=s.filter(i=>i.type!=="application")),o){const i=o.toLowerCase();s=s.filter(n=>n.name.toLowerCase().includes(i))}return s};class ce{#e;#r=new Set;#s;constructor(r){this.#s=r;const o=ne(r);this.#e={allNodes:o,filterActive:!1,filterText:"",filterType:"all",focusedPanel:"list",selectedIndex:0}}getSnapshot=()=>this.#e;subscribe=r=>(this.#r.add(r),()=>{this.#r.delete(r)});getFilteredNodes(){return oe(this.#e.allNodes,this.#e.filterType,this.#e.filterText)}getStats(){const r=this.#e.allNodes.filter(i=>i.type==="application").length,o=this.#e.allNodes.length,s=Object.values(this.#s.dependencies).reduce((i,n)=>i+n.length,0);return{apps:r,deps:s,libs:o-r,total:o}}setSelectedIndex(r){const o=this.getFilteredNodes(),s=o.length===0?-1:Math.max(0,Math.min(r,o.length-1));s!==this.#e.selectedIndex&&this.#t({...this.#e,selectedIndex:s})}setFocusedPanel(r){r!==this.#e.focusedPanel&&this.#t({...this.#e,focusedPanel:r})}setFilterType(r){r!==this.#e.filterType&&this.#t({...this.#e,filterType:r,selectedIndex:0})}setFilter(r){this.#t({...this.#e,filterText:r,selectedIndex:0})}setFilterActive(r){r!==this.#e.filterActive&&this.#t({...this.#e,filterActive:r,filterText:r?this.#e.filterText:"",selectedIndex:r?this.#e.selectedIndex:0})}#t(r){this.#e=r;for(const o of this.#r)try{o()}catch{}}}const de=({focused:c,node:r,scrollRef:o})=>{const s=c?"white":"gray";if(!r)return e.jsx(l,{alignItems:"center",borderColor:"gray",borderStyle:"single",flexDirection:"column",flexGrow:1,justifyContent:"center",children:e.jsx(t,{dimColor:!0,children:"No project selected"})});const i=r.type==="application",n=i?"yellow":"cyan",T=i?"Application":"Library";return e.jsx(l,{borderColor:s,borderStyle:"single",borderTopRightTitle:` ${T} `,borderTopTitle:` ${r.name} `,flexDirection:"column",flexGrow:1,children:e.jsxs(X,{flexGrow:1,flexShrink:1,paddingX:2,ref:o,scrollbar:!0,scrollbarColor:"gray",children:[e.jsxs(l,{flexDirection:"column",marginTop:1,children:[e.jsxs(l,{children:[e.jsx(t,{dimColor:!0,children:"── "}),e.jsx(t,{bold:!0,color:"white",children:"DEPENDS ON"}),e.jsxs(t,{dimColor:!0,children:[" ","(",r.deps.length,")"]})]}),r.deps.length===0?e.jsx(l,{marginTop:1,paddingLeft:2,children:e.jsx(t,{dimColor:!0,children:"No dependencies"})}):e.jsx(l,{flexDirection:"column",marginTop:1,children:r.deps.map(h=>e.jsxs(l,{gap:1,paddingLeft:2,children:[e.jsx(t,{color:"cyan",children:"→"}),e.jsx(t,{children:h.target}),h.type!=="static"&&e.jsxs(t,{dimColor:!0,children:["(",h.type,")"]})]},h.target))})]}),e.jsxs(l,{flexDirection:"column",marginTop:1,children:[e.jsxs(l,{children:[e.jsx(t,{dimColor:!0,children:"── "}),e.jsx(t,{bold:!0,color:"white",children:"REQUIRED BY"}),e.jsxs(t,{dimColor:!0,children:[" ","(",r.reverseDeps.length,")"]})]}),r.reverseDeps.length===0?e.jsx(l,{marginTop:1,paddingLeft:2,children:e.jsx(t,{dimColor:!0,children:"No reverse dependencies"})}):e.jsx(l,{flexDirection:"column",marginTop:1,children:r.reverseDeps.map(h=>e.jsxs(l,{gap:1,paddingLeft:2,children:[e.jsx(t,{color:"magenta",children:"←"}),e.jsx(t,{children:h})]},h))})]}),e.jsxs(l,{flexDirection:"column",marginTop:1,children:[e.jsxs(l,{children:[e.jsx(t,{dimColor:!0,children:"── "}),e.jsx(t,{bold:!0,color:"white",children:"INFO"})]}),e.jsxs(l,{flexDirection:"column",marginTop:1,paddingLeft:2,children:[e.jsxs(l,{children:[e.jsx(l,{width:16,children:e.jsx(t,{dimColor:!0,children:"Type:"})}),e.jsx(t,{color:n,children:T})]}),e.jsxs(l,{children:[e.jsx(l,{width:16,children:e.jsx(t,{dimColor:!0,children:"Dependencies:"})}),e.jsx(t,{children:String(r.deps.length)})]}),e.jsxs(l,{children:[e.jsx(l,{width:16,children:e.jsx(t,{dimColor:!0,children:"Required by:"})}),e.jsx(t,{children:String(r.reverseDeps.length)})]}),e.jsxs(l,{children:[e.jsx(l,{width:16,children:e.jsx(t,{dimColor:!0,children:"Connectivity:"})}),e.jsx(t,{children:String(r.deps.length+r.reverseDeps.length)})]})]})]})]})})},ae=[{key:"all",label:"All",shortcut:"1"},{key:"app",label:"Apps",shortcut:"2"},{key:"lib",label:"Libs",shortcut:"3"}],O=({isSelected:c,node:r})=>{const o=r.type==="application",s=o?"yellow":"cyan",i=o?"app":"lib";return e.jsxs(l,{flexShrink:0,height:1,children:[e.jsxs(t,{children:[c?"▶":" "," "]}),e.jsx(l,{flexGrow:1,children:e.jsx(t,{bold:c,inverse:c,wrap:"truncate",children:r.name})}),e.jsxs(t,{color:s,children:[" ",i]}),e.jsxs(t,{dimColor:!0,children:[" ","→",r.deps.length," ","←",r.reverseDeps.length]})]})},G=({count:c,label:r})=>e.jsxs(l,{flexShrink:0,height:1,marginTop:1,children:[e.jsxs(t,{dimColor:!0,children:["▼"," "]}),e.jsx(t,{bold:!0,color:"white",children:r.toUpperCase()}),e.jsxs(t,{dimColor:!0,children:[" ","(",c,")"]})]}),he=({filterActive:c,filterText:r,filterType:o,focused:s,nodes:i,scrollOffset:n,selectedIndex:T,stats:h,viewportHeight:w})=>{const u=s?"white":"gray",b=i.filter(f=>f.type==="application"),a=i.filter(f=>f.type!=="application"),j=[];let x=0;if(b.length>0){j.push(e.jsx(G,{count:b.length,label:"Applications"},"hdr-apps"));for(const f of b){const y=x;j.push(e.jsx(O,{isSelected:y===T,node:f},f.name)),x++}}if(a.length>0){j.push(e.jsx(G,{count:a.length,label:"Libraries"},"hdr-libs"));for(const f of a){const y=x;j.push(e.jsx(O,{isSelected:y===T,node:f},f.name)),x++}}let g=0;b.length>0&&(g+=2+b.length),a.length>0&&(g+=2+a.length);const A=g>w&&w>0;return e.jsxs(l,{borderColor:u,borderStyle:"single",flexDirection:"column",flexGrow:1,children:[e.jsxs(l,{flexShrink:0,gap:1,paddingX:1,children:[e.jsx(t,{bold:!0,inverse:!0,children:" VIS "}),e.jsxs(t,{wrap:"truncate",children:[h.total," ","packages"]}),e.jsxs(t,{dimColor:!0,children:["(",h.apps," ","apps,"," ",h.libs," ","libs,"," ",h.deps," ","deps)"]})]}),e.jsx(l,{flexShrink:0,gap:1,paddingX:1,paddingY:1,children:ae.map(f=>{const y=o===f.key;return e.jsxs(l,{children:[e.jsx(t,{dimColor:!y,children:"["}),e.jsx(t,{bold:y,color:y?"cyan":"gray",children:f.shortcut}),e.jsx(t,{dimColor:!y,children:"]"}),e.jsxs(t,{color:y?"white":"gray",children:[" ",f.label]})]},f.key)})}),c&&e.jsxs(l,{flexShrink:0,paddingX:1,children:[e.jsx(t,{bold:!0,color:"white",children:"/ "}),e.jsx(t,{children:r}),e.jsx(t,{inverse:!0,children:" "})]}),e.jsxs(l,{flexDirection:"row",flexGrow:1,overflow:"hidden",children:[e.jsx(l,{flexDirection:"column",flexGrow:1,overflow:"hidden",paddingLeft:1,children:e.jsx(l,{flexDirection:"column",marginTop:-n,children:j})}),A&&e.jsx(l,{flexShrink:0,marginLeft:1,marginRight:1,children:e.jsx(Q,{contentHeight:g,placement:"inset",scrollOffset:n,style:"block",viewportHeight:w})})]})]})},pe=100,ue=40,xe=10,B={1:"all",2:"app",3:"lib"},fe=({autoExitSeconds:c=0,store:r})=>{const{exit:o}=J(),{columns:s,rows:i}=K(),n=C.useSyncExternalStore(r.subscribe,r.getSnapshot),[T,h]=C.useState(!1),w=C.useRef(null),u=C.useRef(null),[b,a]=C.useState(0),[j,x]=C.useState(!1),g=C.useMemo(()=>r.getFilteredNodes(),[n.allNodes,n.filterType,n.filterText]),A=C.useMemo(()=>r.getStats(),[n.allNodes]),f=g[n.selectedIndex]??null,y=C.useMemo(()=>{let p=0,d=0;for(const m of g)m.type==="application"?p+=1:d+=1;return{appsCount:p,libsCount:d}},[g]),R=C.useCallback(p=>{const{appsCount:d,libsCount:m}=y;if(p<d)return(d>0?2:0)+p;const Y=d>0?2+d:0,U=m>0?2:0;return Y+U+(p-d)},[y]),D=Math.max(1,i-8-(n.filterActive?1:0)),v=C.useCallback(p=>{const d=R(p);a(m=>d>m+D-2?Math.max(0,d-D+2):d<m+1?Math.max(0,d-1):m)},[R,D]);if(C.useEffect(()=>{u.current?.scrollToTop()},[f?.name]),z((p,d)=>{if(p==="c"&&d.ctrl){o();return}if(!j){if(T){d.escape||p==="?"?h(!1):p==="q"?(h(!1),x(!0)):d.downArrow||p==="j"?w.current?.scrollBy(1):(d.upArrow||p==="k")&&w.current?.scrollBy(-1);return}if(p==="?"){h(!0);return}if(p==="q"){x(!0);return}if(d.tab){r.setFocusedPanel(n.focusedPanel==="list"?"detail":"list");return}if(B[p]){r.setFilterType(B[p]);return}if(n.filterActive){if(d.escape){r.setFilterActive(!1);return}if(d.return){r.setFilterActive(!1);return}if(d.backspace){r.setFilter(n.filterText.slice(0,-1));return}if(p&&!d.ctrl&&!d.meta){r.setFilter(n.filterText+p);return}return}if(n.focusedPanel==="list"){if(g.length===0){p==="/"&&r.setFilterActive(!0);return}if(d.downArrow||p==="j"){const m=Math.min(n.selectedIndex+1,g.length-1);r.setSelectedIndex(m),v(m);return}if(d.upArrow||p==="k"){const m=Math.max(n.selectedIndex-1,0);r.setSelectedIndex(m),v(m);return}if(d.pageDown){const m=Math.min(n.selectedIndex+10,g.length-1);r.setSelectedIndex(m),v(m);return}if(d.pageUp){const m=Math.max(n.selectedIndex-10,0);r.setSelectedIndex(m),v(m);return}if(d.home){r.setSelectedIndex(0),a(0);return}if(d.end){const m=g.length-1;r.setSelectedIndex(m),v(m);return}if(p==="/"){r.setFilterActive(!0);return}if(d.rightArrow){r.setFocusedPanel("detail");return}return}if(n.focusedPanel==="detail"){if(d.escape||d.leftArrow){r.setFocusedPanel("list");return}if(d.downArrow||p==="j"){u.current?.scrollBy(1);return}if(d.upArrow||p==="k"){u.current?.scrollBy(-1);return}if(d.pageDown){u.current?.scrollBy(10);return}if(d.pageUp){u.current?.scrollBy(-10);return}if(d.home){u.current?.scrollToTop();return}d.end&&u.current?.scrollToBottom()}}},{isActive:!0}),s<ue||i<xe)return e.jsx(l,{alignItems:"center",height:i,justifyContent:"center",width:s,children:e.jsxs(t,{color:"yellow",children:["Terminal too small (",s,"x",i,")"]})});const _=s>=pe,P=e.jsx(l,{borderBottom:!1,borderColor:"gray",borderLeft:!1,borderRight:!1,borderStyle:"single",flexShrink:0,children:e.jsxs(l,{flexWrap:"wrap",gap:2,paddingX:1,children:[e.jsxs(l,{gap:1,children:[e.jsx(t,{bold:!0,color:"white",children:"q"}),e.jsx(t,{dimColor:!0,children:"QUIT"})]},"q"),e.jsxs(l,{gap:1,children:[e.jsx(t,{bold:!0,color:"white",children:"?"}),e.jsx(t,{dimColor:!0,children:"HELP"})]},"?"),e.jsxs(l,{gap:1,children:[e.jsx(t,{bold:!0,color:"white",children:"↑↓"}),e.jsx(t,{dimColor:!0,children:"NAV"})]},"nav"),e.jsxs(l,{gap:1,children:[e.jsx(t,{bold:!0,color:"white",children:"1-3 /"}),e.jsx(t,{dimColor:!0,children:"FILTER"})]},"f"),e.jsxs(l,{gap:1,children:[e.jsx(t,{bold:!0,color:"white",children:"Tab"}),e.jsx(t,{dimColor:!0,children:"PANEL"})]},"t")]})}),N=e.jsxs(Z,{footer:e.jsxs(t,{dimColor:!0,children:[e.jsx(t,{bold:!0,color:"white",children:"↑↓"})," ","scroll"," ",e.jsx(t,{bold:!0,color:"white",children:"?"}),"/",e.jsx(t,{bold:!0,color:"white",children:"Esc"})," ","close"]}),scrollRef:w,title:"KEYBOARD SHORTCUTS",visible:T,width:52,children:[e.jsxs(l,{flexDirection:"column",marginBottom:1,children:[e.jsxs(l,{marginBottom:1,children:[e.jsx(t,{dimColor:!0,children:"── "}),e.jsx(t,{bold:!0,color:"white",children:"NAVIGATION"})]}),e.jsxs(l,{children:[e.jsx(l,{width:24,children:e.jsxs(t,{children:[e.jsxs(t,{bold:!0,color:"white",children:[" ","↑","/k"]}),e.jsx(t,{dimColor:!0,children:" Move up"})]})}),e.jsxs(t,{children:[e.jsxs(t,{bold:!0,color:"white",children:[" ","↓","/j"]}),e.jsx(t,{dimColor:!0,children:" Move down"})]})]}),e.jsxs(t,{children:[e.jsxs(t,{bold:!0,color:"white",children:[" ","Tab"]}),e.jsx(t,{dimColor:!0,children:" Switch panel"})]}),e.jsxs(t,{children:[e.jsxs(t,{bold:!0,color:"white",children:[" ","→","/","←"]}),e.jsx(t,{dimColor:!0,children:" Focus detail/list"})]}),e.jsxs(t,{children:[e.jsxs(t,{bold:!0,color:"white",children:[" ","PgUp/PgDn"]}),e.jsx(t,{dimColor:!0,children:" Jump 10 items"})]}),e.jsxs(t,{children:[e.jsxs(t,{bold:!0,color:"white",children:[" ","Home/End"]}),e.jsx(t,{dimColor:!0,children:" Jump to start/end"})]})]}),e.jsxs(l,{flexDirection:"column",marginBottom:1,children:[e.jsxs(l,{marginBottom:1,children:[e.jsx(t,{dimColor:!0,children:"── "}),e.jsx(t,{bold:!0,color:"white",children:"FILTERS"})]}),e.jsxs(l,{children:[e.jsx(l,{width:24,children:e.jsxs(t,{children:[e.jsxs(t,{bold:!0,color:"white",children:[" ","1"]}),e.jsx(t,{dimColor:!0,children:" All"})]})}),e.jsxs(t,{children:[e.jsxs(t,{bold:!0,color:"white",children:[" ","2"]}),e.jsx(t,{dimColor:!0,children:" Apps only"})]})]}),e.jsxs(t,{children:[e.jsxs(t,{bold:!0,color:"white",children:[" ","3"]}),e.jsx(t,{dimColor:!0,children:" Libraries only"})]}),e.jsxs(t,{children:[e.jsxs(t,{bold:!0,color:"white",children:[" ","/"]}),e.jsx(t,{dimColor:!0,children:" Text filter"})]})]}),e.jsxs(l,{flexDirection:"column",children:[e.jsxs(l,{marginBottom:1,children:[e.jsx(t,{dimColor:!0,children:"── "}),e.jsx(t,{bold:!0,color:"white",children:"ACTIONS"})]}),e.jsxs(t,{children:[e.jsxs(t,{bold:!0,color:"white",children:[" ","q"]}),e.jsx(t,{dimColor:!0,children:" Quit"})]}),e.jsxs(t,{children:[e.jsxs(t,{bold:!0,color:"white",children:[" ","?"]}),e.jsx(t,{dimColor:!0,children:" Toggle help"})]})]})]}),E=e.jsx(he,{filterActive:n.filterActive,filterText:n.filterText,filterType:n.filterType,focused:n.focusedPanel==="list",nodes:g,scrollOffset:b,selectedIndex:n.selectedIndex,stats:A,viewportHeight:D}),$=e.jsx(de,{focused:n.focusedPanel==="detail",node:f,scrollRef:u});if(_){const p=Math.floor(s*.35);return e.jsxs(l,{flexDirection:"column",height:i,width:s,children:[e.jsxs(l,{flexDirection:"row",flexGrow:1,children:[e.jsx(l,{flexGrow:1,children:E}),e.jsx(l,{width:p,children:$})]}),P,e.jsx(L,{autoExitSeconds:c??3,onCancel:()=>{x(!1)},visible:j}),N]})}const q=Math.floor(i*.55);return e.jsxs(l,{flexDirection:"column",height:i,width:s,children:[e.jsx(l,{height:q,children:E}),e.jsx(l,{flexGrow:1,children:$}),P,e.jsx(L,{autoExitSeconds:c??3,onCancel:()=>{x(!1)},visible:j}),N]})},V=(c,r,o,s,i,n,T,h)=>{const w=o?S("└── "):S("├── "),u=i.has(c),b=u?S(" (*)"):"",a=s.get(c),x=a?.type==="application"?I(c):c;if(n.push(`${r}${w}${x}${b}`),u)return;i.add(c);const g=a?.deps??[],A=o?`${r} `:`${r}${S("│")} `;if(h>=T&&g.length>0){n.push(`${A}${S(`... ${g.length} more`)}`);return}for(let f=0;f<g.length;f++){const y=g[f];y&&V(y.target,A,f===g.length-1,s,i,n,T,h+1)}},H=(c,r,o,s,i,n)=>{const T=r.get(c),w=T?.type==="application"?I(c):c;s.push(`${n}${w}`),o.add(c);const u=T?.deps??[];if(u.length===0){s.push(`${n} ${S("(no dependencies)")}`);return}if(i<=0){s.push(`${n} ${S(`... ${u.length} dependencies`)}`);return}for(let b=0;b<u.length;b++){const a=u[b];a&&V(a.target,n,b===u.length-1,r,o,s,i,1)}},k=(c,r)=>{const o=new Map;for(const[a,j]of Object.entries(c.nodes))o.set(a,{deps:(c.dependencies[a]??[]).map(x=>({target:x.target,type:x.type})),name:a,type:j.type});const s=[],i=[];for(const[a,j]of o)j.type==="application"?s.push(a):i.push(a);s.sort(),i.sort();const n=s.length+i.length,T=Object.values(c.dependencies).reduce((a,j)=>a+j.length,0),h=[I("Project Dependency Graph"),""];if(s.length>0){h.push(` ${I(F(`Applications (${s.length})`))}`,"");for(const a of s)H(a,o,new Set,h,r," "),h.push("")}if(i.length>0){h.push(` ${I(F(`Libraries (${i.length})`))}`,"");for(const a of i)H(a,o,new Set,h,r," "),h.push("")}const w=process.stdout.columns||80;h.push(S("─".repeat(Math.min(w,60)))),h.push(`${I(String(n))} packages ${S("·")} ${I(String(T))} dependencies ${S("·")} ${I(String(s.length))} apps${S(",")} ${I(String(i.length))} libraries`);const u=new Set;let b=!1;for(const a of[...s,...i]){const j=o.get(a)?.deps??[];for(const x of j)u.has(x.target)&&(b=!0),u.add(x.target);u.add(a)}return b&&h.push(S("(*) = already shown above")),h.join(`
2
2
  `)},je=c=>{const r=Object.values(c.nodes).map(s=>({name:s.name,type:s.type}));return{edges:Object.values(c.dependencies).flat(),nodes:r}},me=async c=>{const{emitGraphHtml:r}=await import("./html.js"),o=Object.values(c.nodes).map(i=>({name:i.name,path:i.data?.root,type:i.type})),s=[];for(const i of Object.values(c.dependencies))for(const n of i)s.push({source:n.source,target:n.target,type:n.type});return r({edges:s,nodes:o,tool:{name:"vis-graph",version:"alpha"},workspaceRoot:process.cwd()})},Ce=async({fs:c,logger:r,options:o,visConfig:s,workspaceRoot:i})=>{if(!i)throw new Error("Could not determine workspace root. Run this command inside a monorepo.");const n=i,{packageJsons:T,workspace:h}=re(n,s),w=se(n,h,T),u=!!process.stdout.isTTY&&!te,b=o.format??(u?"tui":"ascii"),a=o.output,j=o.depth??1/0;let x;switch(b){case"dot":{x=W(w);break}case"html":{x=await me(w);break}case"json":{x=JSON.stringify(je(w),void 0,2);break}case"tui":{if(!u){x=k(w,j);break}const g=s?.tui?.autoExit===!0?3:typeof s?.tui?.autoExit=="number"?s.tui.autoExit:0;process.stdin.isTTY&&typeof process.stdin.setRawMode=="function"&&(process.stdin.setRawMode(!0),process.stdin.ref(),process.stdin.resume());const A=setInterval(()=>{},1e3),f=new ce(w);await ee(le.createElement(fe,{autoExitSeconds:g,store:f}),{alternateScreen:!0,exitOnCtrlC:!1,interactive:!0,patchConsole:!0}).waitUntilExit(),clearInterval(A);return}default:x=k(w,j)}a?(await c.writeFile(a,x,"utf8"),r.info(`Graph written to ${a}`)):r.info(x)};export{Ce as default};
@@ -1,4 +1,4 @@
1
- import{z as _,m as G,a as I,e as b}from"../packem_shared/index-0dnGN3GP.js";import U from"./index.js";import{d as x,q as F,u as B}from"../packem_shared/registry-Mb5e6Tf4.js";import{n as J}from"../packem_shared/manifests-Caf3hlIO.js";import{T as E,U as K}from"./cli-main.js";import{l as q}from"../packem_shared/glob-Cyk1H9ZL-BjuiUjNv.js";import{U as R,h as M}from"../packem_shared/env-DDmZsWBr.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 I,e as b}from"../packem_shared/index-0dnGN3GP.js";import U from"./index.js";import{d as x,q as F,u as B}from"../packem_shared/registry-CIfr2njA.js";import{n as J}from"../packem_shared/manifests-CgyI-i-c.js";import{T as E,U as K}from"./cli-main.js";import{l as q}from"../packem_shared/glob-Cyk1H9ZL-ChoYoZKK.js";import{U as R,h as M}from"../packem_shared/env-CsENUmRe.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
 
@@ -1,4 +1,4 @@
1
- import{a as B,z as J,e as I,$ as K,U as q}from"../packem_shared/index-0dnGN3GP.js";import{L as Y,M as z,N as V,K 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,y as ne,z as oe,A as ie,h as ce,i as A}from"../packem_shared/registry-Mb5e6Tf4.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-CBsMZhj-.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
1
+ import{a as B,z as J,e as I,$ as K,U as q}from"../packem_shared/index-0dnGN3GP.js";import{L as Y,M as z,N as V,K 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,y as ne,z as oe,A as ie,h as ce,i as A}from"../packem_shared/registry-CIfr2njA.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-CBsMZhj-.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
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(`
@@ -1,4 +1,4 @@
1
- import{createRequire as Z}from"node:module";import{J as I,j as re,F as O,X as U,b as D,q as ie}from"../packem_shared/index.server-Ca_EEVfw.js";import{a as S}from"../packem_shared/index-0dnGN3GP.js";import{R 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-CGBVtTBl.js";import{v as d}from"../packem_shared/registry-Mb5e6Tf4.js";import{d as f,f as b,r as be,a as $e}from"../packem_shared/detect-clCqXvt_.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},Re={error:"error",info:"info",style:"info",warning:"warning"},We=e=>e.startsWith("/")||/^[a-z]:[\\/]/i.test(e),Te=(e,t)=>e?We(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:Re[i.level??""]??"warning"});return r}},B=(e,t)=>{const n=["--format=json1"];return t.extraArgs?.length&&n.push(...t.extraArgs),n.push(...e),n},Oe={error:"error",warning:"warning"},Pe={argsCheck:(e,t)=>J(e,t,!1),argsFix:(e,t)=>J(e,t,!0),bin:()=>["pnpm","exec","stylelint"],cacheKey:(e,t)=>{const n=["stylelint",e.declaredVersion??"unknown",e.configFile??"no-config",t.maxWarnings===void 0?"":`mw=${t.maxWarnings}`,t.quiet?"q":"",...t.extraArgs??[]];return h("sha256").update(n.join("|")).digest("hex").slice(0,16)},detect:(e,t)=>{const n=f(t,d.stylelint.packageNames[0]),r=b(e,d.stylelint.configFiles);if(!(!n&&!r))return{adapter:"stylelint",configFile:r,declared:!!n,declaredVersion:n,root:e}},extensions:["astro","css","less","sass","scss","svelte","vue"],id:"stylelint",kind:"lint",parse:(e,t)=>{if(!e.stdout.trim())return[];let n;try{n=JSON.parse(e.stdout)}catch{return[{adapter:"stylelint",file:t.root,fixable:!1,message:`stylelint output was not valid JSON (exit ${e.exitCode})`,severity:"error"}]}const r=[];for(const i of n)for(const s of i.warnings??[])r.push({adapter:"stylelint",column:s.column,endColumn:s.endColumn,endLine:s.endLine,file:i.source,fixable:!1,line:s.line,message:s.text??"",ruleId:s.rule,severity:Oe[s.severity??""]??"warning"});return r}},J=(e,t,n)=>{const r=["--formatter","json"];return n&&r.push("--fix"),t.quiet&&r.push("--quiet"),typeof t.maxWarnings=="number"&&r.push("--max-warnings",String(t.maxWarnings)),t.extraArgs?.length&&r.push(...t.extraArgs),r.push(...e),r},G="@typescript/native-preview",Ve=2e3,Me=/^(.*)\((\d+),(\d+)\): (error|warning) (TS\d+): (.*)$/,Le=/^(error|warning) (TS\d+): (.*)$/,Y=e=>e.startsWith("/")||/^[a-z]:[\\/]/i.test(e),Be=(e,t)=>Y(e)?e:`${t}/${e}`,z=e=>{try{return Ae(e)}catch{return}},Je=e=>{const t=z(e);return Array.isArray(t?.config.references)&&t.config.references.length>0},Ke=e=>{const t=be(e);return!f(t,"typescript")&&f(t,G)?"tsgo":"tsc"},Ue={argsCheck:(e,t)=>K(t),argsFix:(e,t)=>K(t),bin:e=>{const t=["pnpm","exec",Ke(e.root)],n=e.configFile?S(e.root,e.configFile):"tsconfig.json";return e.configFile&&Je(e.root)?[...t,"-b","--pretty","false",n]:[...t,"-p",n,"--noEmit","--pretty","false"]},cacheKey:(e,t)=>{const n=["typecheck",e.declaredVersion??"unknown",e.configFile??"no-config",...t.extraArgs??[]];return h("sha256").update(n.join("|")).digest("hex").slice(0,16)},detect:(e,t)=>{const n=f(t,"typescript"),r=f(t,G),i=z(e),s=i?S(e,i.path):void 0;if(!(!n&&!r||!i||!s||s===".."||s.startsWith("../")||Y(s)))return{adapter:"typecheck",configFile:i.path,declared:!0,declaredVersion:n??r,root:e}},extensions:["cts","mts","ts","tsx"],id:"typecheck",kind:"lint",optIn:!0,parse:(e,t)=>{const n=[];for(const r of`${e.stdout}
1
+ import{createRequire as Z}from"node:module";import{J as I,j as re,F as O,X as U,b as D,q as ie}from"../packem_shared/index.server-Ca_EEVfw.js";import{a as S}from"../packem_shared/index-0dnGN3GP.js";import{R 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-C7VCU587.js";import{v as d}from"../packem_shared/registry-CIfr2njA.js";import{d as f,f as b,r as be,a as $e}from"../packem_shared/detect-B9mLzG9L.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},Re={error:"error",info:"info",style:"info",warning:"warning"},We=e=>e.startsWith("/")||/^[a-z]:[\\/]/i.test(e),Te=(e,t)=>e?We(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:Re[i.level??""]??"warning"});return r}},B=(e,t)=>{const n=["--format=json1"];return t.extraArgs?.length&&n.push(...t.extraArgs),n.push(...e),n},Oe={error:"error",warning:"warning"},Pe={argsCheck:(e,t)=>J(e,t,!1),argsFix:(e,t)=>J(e,t,!0),bin:()=>["pnpm","exec","stylelint"],cacheKey:(e,t)=>{const n=["stylelint",e.declaredVersion??"unknown",e.configFile??"no-config",t.maxWarnings===void 0?"":`mw=${t.maxWarnings}`,t.quiet?"q":"",...t.extraArgs??[]];return h("sha256").update(n.join("|")).digest("hex").slice(0,16)},detect:(e,t)=>{const n=f(t,d.stylelint.packageNames[0]),r=b(e,d.stylelint.configFiles);if(!(!n&&!r))return{adapter:"stylelint",configFile:r,declared:!!n,declaredVersion:n,root:e}},extensions:["astro","css","less","sass","scss","svelte","vue"],id:"stylelint",kind:"lint",parse:(e,t)=>{if(!e.stdout.trim())return[];let n;try{n=JSON.parse(e.stdout)}catch{return[{adapter:"stylelint",file:t.root,fixable:!1,message:`stylelint output was not valid JSON (exit ${e.exitCode})`,severity:"error"}]}const r=[];for(const i of n)for(const s of i.warnings??[])r.push({adapter:"stylelint",column:s.column,endColumn:s.endColumn,endLine:s.endLine,file:i.source,fixable:!1,line:s.line,message:s.text??"",ruleId:s.rule,severity:Oe[s.severity??""]??"warning"});return r}},J=(e,t,n)=>{const r=["--formatter","json"];return n&&r.push("--fix"),t.quiet&&r.push("--quiet"),typeof t.maxWarnings=="number"&&r.push("--max-warnings",String(t.maxWarnings)),t.extraArgs?.length&&r.push(...t.extraArgs),r.push(...e),r},G="@typescript/native-preview",Ve=2e3,Me=/^(.*)\((\d+),(\d+)\): (error|warning) (TS\d+): (.*)$/,Le=/^(error|warning) (TS\d+): (.*)$/,Y=e=>e.startsWith("/")||/^[a-z]:[\\/]/i.test(e),Be=(e,t)=>Y(e)?e:`${t}/${e}`,z=e=>{try{return Ae(e)}catch{return}},Je=e=>{const t=z(e);return Array.isArray(t?.config.references)&&t.config.references.length>0},Ke=e=>{const t=be(e);return!f(t,"typescript")&&f(t,G)?"tsgo":"tsc"},Ue={argsCheck:(e,t)=>K(t),argsFix:(e,t)=>K(t),bin:e=>{const t=["pnpm","exec",Ke(e.root)],n=e.configFile?S(e.root,e.configFile):"tsconfig.json";return e.configFile&&Je(e.root)?[...t,"-b","--pretty","false",n]:[...t,"-p",n,"--noEmit","--pretty","false"]},cacheKey:(e,t)=>{const n=["typecheck",e.declaredVersion??"unknown",e.configFile??"no-config",...t.extraArgs??[]];return h("sha256").update(n.join("|")).digest("hex").slice(0,16)},detect:(e,t)=>{const n=f(t,"typescript"),r=f(t,G),i=z(e),s=i?S(e,i.path):void 0;if(!(!n&&!r||!i||!s||s===".."||s.startsWith("../")||Y(s)))return{adapter:"typecheck",configFile:i.path,declared:!0,declaredVersion:n??r,root:e}},extensions:["cts","mts","ts","tsx"],id:"typecheck",kind:"lint",optIn:!0,parse:(e,t)=>{const n=[];for(const r of`${e.stdout}
2
2
  ${e.stderr}`.split(/\r?\n/)){const i=Me.exec(r);if(i){n.push({adapter:"typecheck",column:Number(i[3]),file:Be(i[1],t.root),fixable:!1,line:Number(i[2]),message:i[6],ruleId:i[5],severity:i[4]==="warning"?"warning":"error"});continue}const s=Le.exec(r);if(s){n.push({adapter:"typecheck",file:t.root,fixable:!1,message:s[3],ruleId:s[2],severity:s[1]==="warning"?"warning":"error"});continue}const c=n.at(-1);c&&/^\s+\S/.test(r)&&(c.message+=`
3
3
  ${r.trim()}`)}if(n.length===0&&e.exitCode!==0){const r=`${e.stdout}
4
4
  ${e.stderr}`.trim().slice(0,Ve);n.push({adapter:"typecheck",file:t.root,fixable:!1,message:e.exitCode===null?`type-check did not complete (killed or timed out)${r?`:
@@ -1,2 +1,2 @@
1
- import{createRequire as F}from"node:module";import{i as W}from"../packem_shared/index-BjdW45xX.js";import{p as Y}from"../packem_shared/prompt-DMzaQEVa.js";import{e as U}from"../packem_shared/index-0dnGN3GP.js";import{n as B,h as X,U as J,o as Q,p as Z,e as ee,q as te,m as _}from"../packem_shared/env-DDmZsWBr.js";import{y as se}from"../packem_shared/isAccessibleSync-DYKTrrvc-CBsMZhj-.js";import{p as re}from"../packem_shared/package-version-CNjr03oy.js";import{g as oe,r as ne}from"../packem_shared/packument-D_qCUp6X.js";import{q as ce,j as ie,F as v,b as S,X as E,J as A}from"../packem_shared/index.server-Ca_EEVfw.js";import{z as ae}from"../packem_shared/formatBytes-_HvjOy8a-iHCer6uX.js";import{a as le,o as fe}from"../packem_shared/pm-runner-BXRi4ZM9.js";import{r as ue,a as pe}from"../packem_shared/command-runtime-DG49t2MT.js";let z;const V=e=>(z??=F(import.meta.url))(e),$=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,M=e=>{if(typeof $<"u"&&$.versions&&$.versions.node){const[t,s]=$.versions.node.split(".").map(Number);if(t>22||t===22&&s>=3||t===20&&s>=16)return $.getBuiltinModule(e)}return V(e)},{renameSync:q}=M("node:fs"),{stripVTControlCharacters:G}=M("node:util"),de=(e={})=>{const t=e.isCi??W;return(e.isTty??!!(process.stdin.isTTY&&process.stdout.isTTY))&&!t},k=U(B(),"dlx-seen.json"),H=(e,t)=>`${e}@${t}`,me=e=>{if(typeof e!="object"||e===null)return!1;const t=e;return Array.isArray(t.alertKeys)&&t.alertKeys.every(s=>typeof s=="string")&&typeof t.seenAt=="number"},P=()=>{try{if(se(k)){const e=re(k);if(e&&typeof e=="object"&&e.packages&&typeof e.packages=="object"&&e.version===1){const t={};for(const[s,r]of Object.entries(e.packages))me(r)&&(t[s]=r);return{packages:t,version:1}}}}catch{}return{packages:{},version:1}},he=e=>{try{X(B());const t=`${k}.${String(process.pid)}.tmp`;J(t,JSON.stringify(e)),q(t,k)}catch{}},ge=(e,t,s)=>e.packages[H(t,s)],ye=(e,t)=>{if(!e)return!0;const s=new Set(Array.isArray(e.alertKeys)?e.alertKeys:[]);return t.some(r=>!s.has(r))},R=(e,t,s,r)=>{const o=P();o.packages[H(e,t)]={alertKeys:[...s].sort(),seenAt:r},he(o)},ve=/[\u0000-\u0008\u000B-\u001F\u007F]/g,K=e=>G(e).replaceAll(" "," ").replaceAll(ve,""),x=["CHANGELOG.md","CHANGELOG","changelog.md","CHANGES.md","HISTORY.md"],be=4e3,C=async(e,t,s)=>{if(t?.aborted)return;const r=new AbortController,o=setTimeout(()=>{r.abort()},be),a=()=>{r.abort()};t?.addEventListener("abort",a,{once:!0});try{const n=await fetch(e,{headers:s,signal:r.signal});return n.ok?await n.text():void 0}catch{return}finally{clearTimeout(o),t?.removeEventListener("abort",a)}},$e=e=>{const t=typeof e=="string"?e:e?.url;if(!t)return;const s=/github\.com[/:]([^/]+)\/([^/#]+?)(?:\.git)?(?:[/#]|$)/i.exec(t)??/^github:([^/]+)\/([^/#]+)/i.exec(t);return s?{directory:typeof e=="object"?e?.directory:void 0,owner:s[1],repo:s[2].replace(/\.git$/,"")}:void 0},O=(e,t)=>{const s=e.split(/\r?\n/),r=/^(#{1,4})\s+(.*)$/,o=t.replaceAll(/[$()*+.?[\\\]^{|}]/g,String.raw`\$&`),a=new RegExp(String.raw`(?<![\w.])${o}(?![\w.])`);let n=-1,u=0;for(const[c,l]of s.entries()){const f=r.exec(l);if(f&&a.test(f[2])){n=c,u=f[1].length;break}}if(n===-1)return;const i=[];for(let c=n+1;c<s.length;c+=1){const l=r.exec(s[c]);if(l&&l[1].length<=u)break;i.push(s[c])}return i},I=(e,t=4)=>e.map(r=>r.trim()).filter(r=>r.length>0).map(r=>K(r.replace(/^#{1,6}\s+/,"").replace(/^[*-]\s+/,"- ")).trim()).filter(r=>r.length>0&&!/^\[.*\]:/.test(r)).slice(0,t),L=(e,t)=>{if(!e)return"";const s=Date.parse(e);if(Number.isNaN(s))return"";const r=Math.floor((t-s)/(1440*60*1e3));if(r<=0)return"today";if(r===1)return"1d ago";if(r<30)return`${String(r)}d ago`;const o=Math.floor(r/30);return o<12?`${String(o)}mo ago`:`${String(Math.floor(o/12))}y ago`},N=(e,t,s)=>{const r=e.time??{},o=L(r[t],s),a=[o?`${e.name}@${t} — published ${o}`:`${e.name}@${t}`],n=Date.parse(r[t]??""),i=Object.entries(r).filter(([c])=>c!=="created"&&c!=="modified"&&c!==t).sort((c,l)=>Date.parse(l[1])-Date.parse(c[1])).filter(([,c])=>Date.parse(c)<n).slice(0,3);for(const[c,l]of i)a.push(`- ${c} (${L(l,s)})`);return{lines:a,source:"npm-diff",version:t}},Se=async e=>{const{name:t,now:s,offline:r,packument:o,signal:a,version:n}=e;if(r)return o?N(o,n,s):void 0;for(const c of x){const l=`https://cdn.jsdelivr.net/npm/${t}@${n}/${c}`,f=await C(l,a);if(f){const y=O(f,n),p=I(y??f.split(/\r?\n/));if(p.length>0)return{lines:p,source:"package-file",url:l,version:n}}}const u=o?.versions[n],i=$e(u?.repository);if(i){const c=i.directory?`${i.directory.replaceAll(/^\/+|\/+$/g,"")}/`:"";for(const l of["HEAD","main","master"])for(const f of x){const y=`https://raw.githubusercontent.com/${i.owner}/${i.repo}/${l}/${c}${f}`,p=await C(y,a);if(p){const m=O(p,n),h=I(m??p.split(/\r?\n/));if(h.length>0){const d=`https://github.com/${i.owner}/${i.repo}/blob/${l}/${c}${f}`;return{lines:h,source:"repo-file",url:d,version:n}}}}}if(o)return N(o,n,s)},we={dynamicRequire:"dynamic require",envVars:"env access",filesystemAccess:"filesystem",networkAccess:"network",shellAccess:"shell",telemetry:"telemetry",unsafe:"eval/unsafe",usesEval:"eval/unsafe"},ke=["preinstall","install","postinstall"],Te=(e,t)=>({fileCount:e?.dist?.fileCount,tarballBytes:t?.size,unpackedBytes:e?.dist?.unpackedSize}),Ee=(e,t)=>{const s=ke.filter(n=>!!e?.scripts?.[n]),r=e?.bin,o=typeof r=="string"?["(default)"]:Object.keys(r??{}).map(n=>K(n)),a=[...new Set(t.map(n=>we[n.type]).filter(n=>n!==void 0))];return{bins:o,capabilities:a,lifecycleScripts:s}},_e=(e,t,s)=>{const r=e.get(`${t}@${s}`);if(r)return r;for(const o of e.values())if(o.name===t&&o.version===s)return o},Ae=async e=>{const{name:t,now:s,offline:r,signal:o,socketToken:a,spec:n,workspaceRoot:u}=e;let i;try{i=await oe(t,{offline:r,signal:o,workspaceRoot:u})}catch{i=void 0}const c=i?ne(i,n):void 0;if(!c)return;const l=i?.versions[c],f=async()=>{if(!(r||!a))try{const g=await Z([{name:t,version:c}],{apiToken:a,minimumScore:ee});return _e(g,t,c)}catch{return}},y=Se({name:t,now:s,offline:r,packument:i,signal:o,version:c}).catch(()=>{}),[p,m]=await Promise.all([f(),y]),h=p?.alerts??[],d=[...new Set(h.filter(g=>g.severity==="critical"||g.severity==="high").map(g=>g.key))].sort(),b=p?Math.round((p.score.overall??Q(p.score))*100):void 0;return{changelog:m,name:t,permissions:Ee(l,h),security:{alerts:h,available:!!p,highSeverityKeys:d,score:b},size:Te(l,p),version:c}},w=e=>te(G(e)),Re={critical:E,high:E,low:v,medium:S},j=e=>{if(!(e===void 0||e<0))return ae(e,{decimals:1,space:!0})},xe=e=>{const{fileCount:t,tarballBytes:s,unpackedBytes:r}=e.size,o=j(r),a=j(s);if(o&&a){const n=t===void 0?"":`, ${String(t)} files`;return`${o} unpacked (${a} tarball${n})`}if(o)return`${o} unpacked`;if(a)return`${a} tarball`},Ce=e=>{const{alerts:t,available:s,score:r}=e.security;if(!s)return v("unavailable — set VIS_SOCKET_TOKEN for a Socket.dev score");const o=r===void 0?v:r>=70?A:r>=40?S:E,a=r===void 0?"n/a":`${String(r)}/100`,n=new Map;for(const l of t)n.set(l.severity,(n.get(l.severity)??0)+1);const u=[],i=["critical","high","medium","low"];for(const l of i){const f=n.get(l);f&&u.push(Re[l](`${String(f)} ${l}`))}const c=u.length>0?` ${S("!")} ${u.join(", ")}`:` ${A("no alerts")}`;return`${o(a)} ${v("(Socket.dev)")}${c}`},Oe=e=>{const{bins:t,capabilities:s,lifecycleScripts:r}=e.permissions,o=[];for(const a of r)o.push(S(`${a} script`));for(const a of s)o.push(S(a));return t.length>0&&o.push(v(`bins: ${t.join(", ")}`)),o.length>0?o.join(v(" · ")):void 0},Ie=e=>{const t=[],s=xe(e);s&&t.push({label:"size",values:[s]}),t.push({label:"score",values:[Ce(e)]});const r=Oe(e);if(r&&t.push({label:"perms",values:[r]}),e.changelog){const o=e.changelog.source==="npm-diff"?"registry":e.changelog.source==="repo-file"?"repo CHANGELOG":"CHANGELOG";t.push({label:"latest",values:[...e.changelog.lines,v(`source: ${o}`)]})}return t},D=6,Le=e=>{const t=Ie(e),s=` first run: ${e.name}@${e.version} `,r=[];for(const i of t)i.values.forEach((c,l)=>{const f=l===0?ce(i.label.padEnd(D)):" ".repeat(D);r.push(`${f} ${c}`)});const o=Math.max(w(s),...r.map(i=>w(i))),a=i=>`${i}${" ".repeat(Math.max(0,o-w(i)))}`,n=`┌─${ie(s)}${"─".repeat(Math.max(0,o-w(s)))}─┐`,u=`└─${"─".repeat(o)}─┘`;return[n,...r.map(i=>`│ ${a(i)} │`),u]},Ne=e=>{if(e.startsWith("@")){const s=e.indexOf("@",1);return s===-1?{name:e}:{name:e.slice(0,s),spec:e.slice(s+1)}}const t=e.indexOf("@");return t<=0?{name:e}:{name:e.slice(0,t),spec:e.slice(t+1)}},je=e=>e===""||e.startsWith(".")||e.startsWith("/")||e.startsWith("~")?!1:!(e.startsWith("@")?e.slice(1):e).includes(":"),De=6e3,Me=e=>{process.stdout.write(e)},Be=async e=>{const{forceInfo:t=!1,noInfo:s=!1,offline:r=!1,pkg:o,socketToken:a,workspaceRoot:n,yes:u=!1}=e;if(s||!je(o))return{proceed:!0};const i=e.now??Date.now(),c=u||!de({isCi:e.isCi,isTty:e.isTty}),l=e.output??Me;if(c&&!t)return{proceed:!0};const{name:f,spec:y}=Ne(o),p=new AbortController;let m;const h=new Promise(T=>{m=setTimeout(()=>{p.abort(),T(void 0)},De)}),d=await Promise.race([Ae({name:f,now:i,offline:r,signal:p.signal,socketToken:a,spec:y,workspaceRoot:n}).catch(()=>{}),h]);if(m&&clearTimeout(m),!d)return{proceed:!0};const b=ge(P(),d.name,d.version);if(!t&&!ye(b,d.security.highSeverityKeys))return{proceed:!0};for(const T of Le(d))l(`${T}
1
+ import{createRequire as F}from"node:module";import{i as W}from"../packem_shared/index-BjdW45xX.js";import{p as Y}from"../packem_shared/prompt-DMzaQEVa.js";import{e as U}from"../packem_shared/index-0dnGN3GP.js";import{n as B,h as X,U as J,o as Q,p as Z,e as ee,q as te,m as _}from"../packem_shared/env-CsENUmRe.js";import{y as se}from"../packem_shared/isAccessibleSync-DYKTrrvc-CBsMZhj-.js";import{p as re}from"../packem_shared/package-version-BzkcrNVE.js";import{g as oe,r as ne}from"../packem_shared/packument-BvTjAHsy.js";import{q as ce,j as ie,F as v,b as S,X as E,J as A}from"../packem_shared/index.server-Ca_EEVfw.js";import{z as ae}from"../packem_shared/formatBytes-_HvjOy8a-iHCer6uX.js";import{a as le,o as fe}from"../packem_shared/pm-runner-BXRi4ZM9.js";import{r as ue,a as pe}from"../packem_shared/command-runtime-DG49t2MT.js";let z;const V=e=>(z??=F(import.meta.url))(e),$=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,M=e=>{if(typeof $<"u"&&$.versions&&$.versions.node){const[t,s]=$.versions.node.split(".").map(Number);if(t>22||t===22&&s>=3||t===20&&s>=16)return $.getBuiltinModule(e)}return V(e)},{renameSync:q}=M("node:fs"),{stripVTControlCharacters:G}=M("node:util"),de=(e={})=>{const t=e.isCi??W;return(e.isTty??!!(process.stdin.isTTY&&process.stdout.isTTY))&&!t},k=U(B(),"dlx-seen.json"),H=(e,t)=>`${e}@${t}`,me=e=>{if(typeof e!="object"||e===null)return!1;const t=e;return Array.isArray(t.alertKeys)&&t.alertKeys.every(s=>typeof s=="string")&&typeof t.seenAt=="number"},P=()=>{try{if(se(k)){const e=re(k);if(e&&typeof e=="object"&&e.packages&&typeof e.packages=="object"&&e.version===1){const t={};for(const[s,r]of Object.entries(e.packages))me(r)&&(t[s]=r);return{packages:t,version:1}}}}catch{}return{packages:{},version:1}},he=e=>{try{X(B());const t=`${k}.${String(process.pid)}.tmp`;J(t,JSON.stringify(e)),q(t,k)}catch{}},ge=(e,t,s)=>e.packages[H(t,s)],ye=(e,t)=>{if(!e)return!0;const s=new Set(Array.isArray(e.alertKeys)?e.alertKeys:[]);return t.some(r=>!s.has(r))},R=(e,t,s,r)=>{const o=P();o.packages[H(e,t)]={alertKeys:[...s].sort(),seenAt:r},he(o)},ve=/[\u0000-\u0008\u000B-\u001F\u007F]/g,K=e=>G(e).replaceAll(" "," ").replaceAll(ve,""),x=["CHANGELOG.md","CHANGELOG","changelog.md","CHANGES.md","HISTORY.md"],be=4e3,C=async(e,t,s)=>{if(t?.aborted)return;const r=new AbortController,o=setTimeout(()=>{r.abort()},be),a=()=>{r.abort()};t?.addEventListener("abort",a,{once:!0});try{const n=await fetch(e,{headers:s,signal:r.signal});return n.ok?await n.text():void 0}catch{return}finally{clearTimeout(o),t?.removeEventListener("abort",a)}},$e=e=>{const t=typeof e=="string"?e:e?.url;if(!t)return;const s=/github\.com[/:]([^/]+)\/([^/#]+?)(?:\.git)?(?:[/#]|$)/i.exec(t)??/^github:([^/]+)\/([^/#]+)/i.exec(t);return s?{directory:typeof e=="object"?e?.directory:void 0,owner:s[1],repo:s[2].replace(/\.git$/,"")}:void 0},O=(e,t)=>{const s=e.split(/\r?\n/),r=/^(#{1,4})\s+(.*)$/,o=t.replaceAll(/[$()*+.?[\\\]^{|}]/g,String.raw`\$&`),a=new RegExp(String.raw`(?<![\w.])${o}(?![\w.])`);let n=-1,u=0;for(const[c,l]of s.entries()){const f=r.exec(l);if(f&&a.test(f[2])){n=c,u=f[1].length;break}}if(n===-1)return;const i=[];for(let c=n+1;c<s.length;c+=1){const l=r.exec(s[c]);if(l&&l[1].length<=u)break;i.push(s[c])}return i},I=(e,t=4)=>e.map(r=>r.trim()).filter(r=>r.length>0).map(r=>K(r.replace(/^#{1,6}\s+/,"").replace(/^[*-]\s+/,"- ")).trim()).filter(r=>r.length>0&&!/^\[.*\]:/.test(r)).slice(0,t),L=(e,t)=>{if(!e)return"";const s=Date.parse(e);if(Number.isNaN(s))return"";const r=Math.floor((t-s)/(1440*60*1e3));if(r<=0)return"today";if(r===1)return"1d ago";if(r<30)return`${String(r)}d ago`;const o=Math.floor(r/30);return o<12?`${String(o)}mo ago`:`${String(Math.floor(o/12))}y ago`},N=(e,t,s)=>{const r=e.time??{},o=L(r[t],s),a=[o?`${e.name}@${t} — published ${o}`:`${e.name}@${t}`],n=Date.parse(r[t]??""),i=Object.entries(r).filter(([c])=>c!=="created"&&c!=="modified"&&c!==t).sort((c,l)=>Date.parse(l[1])-Date.parse(c[1])).filter(([,c])=>Date.parse(c)<n).slice(0,3);for(const[c,l]of i)a.push(`- ${c} (${L(l,s)})`);return{lines:a,source:"npm-diff",version:t}},Se=async e=>{const{name:t,now:s,offline:r,packument:o,signal:a,version:n}=e;if(r)return o?N(o,n,s):void 0;for(const c of x){const l=`https://cdn.jsdelivr.net/npm/${t}@${n}/${c}`,f=await C(l,a);if(f){const y=O(f,n),p=I(y??f.split(/\r?\n/));if(p.length>0)return{lines:p,source:"package-file",url:l,version:n}}}const u=o?.versions[n],i=$e(u?.repository);if(i){const c=i.directory?`${i.directory.replaceAll(/^\/+|\/+$/g,"")}/`:"";for(const l of["HEAD","main","master"])for(const f of x){const y=`https://raw.githubusercontent.com/${i.owner}/${i.repo}/${l}/${c}${f}`,p=await C(y,a);if(p){const m=O(p,n),h=I(m??p.split(/\r?\n/));if(h.length>0){const d=`https://github.com/${i.owner}/${i.repo}/blob/${l}/${c}${f}`;return{lines:h,source:"repo-file",url:d,version:n}}}}}if(o)return N(o,n,s)},we={dynamicRequire:"dynamic require",envVars:"env access",filesystemAccess:"filesystem",networkAccess:"network",shellAccess:"shell",telemetry:"telemetry",unsafe:"eval/unsafe",usesEval:"eval/unsafe"},ke=["preinstall","install","postinstall"],Te=(e,t)=>({fileCount:e?.dist?.fileCount,tarballBytes:t?.size,unpackedBytes:e?.dist?.unpackedSize}),Ee=(e,t)=>{const s=ke.filter(n=>!!e?.scripts?.[n]),r=e?.bin,o=typeof r=="string"?["(default)"]:Object.keys(r??{}).map(n=>K(n)),a=[...new Set(t.map(n=>we[n.type]).filter(n=>n!==void 0))];return{bins:o,capabilities:a,lifecycleScripts:s}},_e=(e,t,s)=>{const r=e.get(`${t}@${s}`);if(r)return r;for(const o of e.values())if(o.name===t&&o.version===s)return o},Ae=async e=>{const{name:t,now:s,offline:r,signal:o,socketToken:a,spec:n,workspaceRoot:u}=e;let i;try{i=await oe(t,{offline:r,signal:o,workspaceRoot:u})}catch{i=void 0}const c=i?ne(i,n):void 0;if(!c)return;const l=i?.versions[c],f=async()=>{if(!(r||!a))try{const g=await Z([{name:t,version:c}],{apiToken:a,minimumScore:ee});return _e(g,t,c)}catch{return}},y=Se({name:t,now:s,offline:r,packument:i,signal:o,version:c}).catch(()=>{}),[p,m]=await Promise.all([f(),y]),h=p?.alerts??[],d=[...new Set(h.filter(g=>g.severity==="critical"||g.severity==="high").map(g=>g.key))].sort(),b=p?Math.round((p.score.overall??Q(p.score))*100):void 0;return{changelog:m,name:t,permissions:Ee(l,h),security:{alerts:h,available:!!p,highSeverityKeys:d,score:b},size:Te(l,p),version:c}},w=e=>te(G(e)),Re={critical:E,high:E,low:v,medium:S},j=e=>{if(!(e===void 0||e<0))return ae(e,{decimals:1,space:!0})},xe=e=>{const{fileCount:t,tarballBytes:s,unpackedBytes:r}=e.size,o=j(r),a=j(s);if(o&&a){const n=t===void 0?"":`, ${String(t)} files`;return`${o} unpacked (${a} tarball${n})`}if(o)return`${o} unpacked`;if(a)return`${a} tarball`},Ce=e=>{const{alerts:t,available:s,score:r}=e.security;if(!s)return v("unavailable — set VIS_SOCKET_TOKEN for a Socket.dev score");const o=r===void 0?v:r>=70?A:r>=40?S:E,a=r===void 0?"n/a":`${String(r)}/100`,n=new Map;for(const l of t)n.set(l.severity,(n.get(l.severity)??0)+1);const u=[],i=["critical","high","medium","low"];for(const l of i){const f=n.get(l);f&&u.push(Re[l](`${String(f)} ${l}`))}const c=u.length>0?` ${S("!")} ${u.join(", ")}`:` ${A("no alerts")}`;return`${o(a)} ${v("(Socket.dev)")}${c}`},Oe=e=>{const{bins:t,capabilities:s,lifecycleScripts:r}=e.permissions,o=[];for(const a of r)o.push(S(`${a} script`));for(const a of s)o.push(S(a));return t.length>0&&o.push(v(`bins: ${t.join(", ")}`)),o.length>0?o.join(v(" · ")):void 0},Ie=e=>{const t=[],s=xe(e);s&&t.push({label:"size",values:[s]}),t.push({label:"score",values:[Ce(e)]});const r=Oe(e);if(r&&t.push({label:"perms",values:[r]}),e.changelog){const o=e.changelog.source==="npm-diff"?"registry":e.changelog.source==="repo-file"?"repo CHANGELOG":"CHANGELOG";t.push({label:"latest",values:[...e.changelog.lines,v(`source: ${o}`)]})}return t},D=6,Le=e=>{const t=Ie(e),s=` first run: ${e.name}@${e.version} `,r=[];for(const i of t)i.values.forEach((c,l)=>{const f=l===0?ce(i.label.padEnd(D)):" ".repeat(D);r.push(`${f} ${c}`)});const o=Math.max(w(s),...r.map(i=>w(i))),a=i=>`${i}${" ".repeat(Math.max(0,o-w(i)))}`,n=`┌─${ie(s)}${"─".repeat(Math.max(0,o-w(s)))}─┐`,u=`└─${"─".repeat(o)}─┘`;return[n,...r.map(i=>`│ ${a(i)} │`),u]},Ne=e=>{if(e.startsWith("@")){const s=e.indexOf("@",1);return s===-1?{name:e}:{name:e.slice(0,s),spec:e.slice(s+1)}}const t=e.indexOf("@");return t<=0?{name:e}:{name:e.slice(0,t),spec:e.slice(t+1)}},je=e=>e===""||e.startsWith(".")||e.startsWith("/")||e.startsWith("~")?!1:!(e.startsWith("@")?e.slice(1):e).includes(":"),De=6e3,Me=e=>{process.stdout.write(e)},Be=async e=>{const{forceInfo:t=!1,noInfo:s=!1,offline:r=!1,pkg:o,socketToken:a,workspaceRoot:n,yes:u=!1}=e;if(s||!je(o))return{proceed:!0};const i=e.now??Date.now(),c=u||!de({isCi:e.isCi,isTty:e.isTty}),l=e.output??Me;if(c&&!t)return{proceed:!0};const{name:f,spec:y}=Ne(o),p=new AbortController;let m;const h=new Promise(T=>{m=setTimeout(()=>{p.abort(),T(void 0)},De)}),d=await Promise.race([Ae({name:f,now:i,offline:r,signal:p.signal,socketToken:a,spec:y,workspaceRoot:n}).catch(()=>{}),h]);if(m&&clearTimeout(m),!d)return{proceed:!0};const b=ge(P(),d.name,d.version);if(!t&&!ye(b,d.security.highSeverityKeys))return{proceed:!0};for(const T of Le(d))l(`${T}
2
2
  `);if(c)return R(d.name,d.version,d.security.highSeverityKeys,i),{proceed:!0};const g=await Y("? Ok to proceed? (y/N) ",e.readline);return g&&R(d.name,d.version,d.security.highSeverityKeys,i),{proceed:g}},Je=async({argument:e,logger:t,options:s,process:r,visConfig:o,workspaceRoot:a})=>{const n=e;if(!n||n.length===0)throw new Error("No package specified. Usage: vis dlx <package[@version]> [args...]");const[u,...i]=n,c=a??r.cwd,l=s.package?Array.isArray(s.package)?s.package:[s.package]:[],f=s.shellMode?l:[u,...l];for(const h of f){const d=!s.info||_(r.env.VIS_DLX_NO_INFO),b=!d&&s.info;if(!(await Be({forceInfo:b,noInfo:d,offline:s.offline||!1,pkg:h,socketToken:o?.security?.socket?.apiToken??r.env.VIS_SOCKET_TOKEN,workspaceRoot:c,yes:s.yes||_(r.env.VIS_DLX_YES)})).proceed){t.info("Aborted."),process.exitCode=1;return}}const y=ue({options:s,visConfig:o},c),p=le(c,{backend:pe(y),configBackend:o?.install?.backend,configCorepack:o?.install?.corepack}),m=fe(p,{additionalPackages:l,args:i,package:u,shellMode:s.shellMode||!1,silent:s.silent||!1},c,t,{offline:s.offline||!1});m!==0&&(process.exitCode=m)};export{Je as default};
@@ -1,4 +1,4 @@
1
- import{createRequire as be}from"node:module";import{F as $,b as L,X as ce,J,q as ae}from"../packem_shared/index.server-Ca_EEVfw.js";import{v as R,a as G,U as I,z as Se,e as M}from"../packem_shared/index-0dnGN3GP.js";import{fingerprint as E,scan as le,scanFiles as Ee,inspectRuleset as Ie,listRules as K,listRequiredValidators as Re,scanGitHistory as Te}from"@visulima/secret-scanner";import{V as Ae,W as Q,p as y}from"./cli-main.js";import{E as je,A as Ne}from"../packem_shared/getRandomSpinner-DX11qCB2-CoIsn7ZU.js";import{U as Fe}from"../packem_shared/env-DDmZsWBr.js";import{y as X}from"../packem_shared/isAccessibleSync-DYKTrrvc-CBsMZhj-.js";import{p as Me}from"../packem_shared/package-version-CNjr03oy.js";let ve;const ke=e=>(ve??=be(import.meta.url))(e),j=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,W=e=>{if(typeof j<"u"&&j.versions&&j.versions.node){const[t,n]=j.versions.node.split(".").map(Number);if(t>22||t===22&&n>=3||t===20&&n>=16)return j.getBuiltinModule(e)}return ke(e)},{createRequire:Ce}=W("node:module"),{pathToFileURL:ue}=W("node:url"),{execFileSync:Le}=W("node:child_process");let Oe;const _e=e=>(Oe??=Ce(import.meta.url))(e),N=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,Be=e=>{if(typeof N<"u"&&N.versions&&N.versions.node){const[t,n]=N.versions.node.split(".").map(Number);if(t>22||t===22&&n>=3||t===20&&n>=16)return N.getBuiltinModule(e)}return _e(e)},{styleText:qe}=Be("node:util"),Ue={error:"✖",info:"ℹ",success:"✓",warning:"⚠"},De=()=>{const{env:e}=process;return!!e.CI||e.CONTINUOUS_INTEGRATION==="true"||"BUILD_NUMBER"in e||"RUN_ID"in e},Pe=/\u001B\[[\d;]*[a-z]/gi,He=e=>[...e.replaceAll(Pe,"")].length,Ve=e=>{const t=[];return e.bold&&t.push("bold"),e.dim&&t.push("dim"),e.italic&&t.push("italic"),e.underline&&t.push("underline"),e.strikethrough&&t.push("strikethrough"),e.color&&t.push(e.color),e.bgColor&&t.push(e.bgColor),t.length===0?n=>n:n=>qe(t,n)};let ze=class{#i=0;#l;#e=!1;#r="";#o="";#m=0;#u=0;#t;#n;#f="";#c;#p;#s;#x;#d=0;#a;#b;constructor(t={},n){if(t.frames)this.#c=t.frames;else{const s=t.name??"dots",r=Ne(s);if(!r)throw new Error(`Unknown spinner "${s}". Pass a custom \`frames\` set or use one of: ${je().join(", ")}.`);this.#c=r}this.#p=t.verbose!==!1,this.#r=t.prefixText??"",this.#t=n,this.#s=t.stream??process.stderr,this.#x=n?!0:this.#s.isTTY&&!De(),this.#b={...Ue,...t.icons},typeof t.style=="function"?this.#a=t.style:t.style&&(this.#a=Ve(t.style))}get elapsedTime(){return this.#m===0?0:(this.#u||Date.now())-this.#m}get text(){return this.#o}set text(t){this.#o=t,this.#e&&this.#w()}get prefixText(){return this.#r}set prefixText(t){this.#r=t,this.#e&&this.#w()}get isRunning(){return this.#e}setInteractiveManager(t){this.#t=t}setMultiSpinner(t){this.#n=t}tick(){this.#e&&(this.#i=(this.#i+1)%this.#c.frames.length)}start(t,n){return this.#e?this:this.#p?(this.#e=!0,this.#m=Date.now(),this.#u=0,this.#i=0,this.#f="",t&&(this.#o=t),n?.prefixText&&(this.#r=n.prefixText),this.#n?(this.#n.renderAll(),this):(this.#t?(this.#t.hook(),this.#v(),this.#y()):(this.#k(),this.#y()),this)):this}stop(){if(this.#e){if(this.#h(),this.#e=!1,this.#u=Date.now(),this.#f="",this.#n){this.#n.renderAll();return}this.#t?(this.#t.erase("stdout"),this.#t.unhook(!1)):this.#$()}}stopAndPersist(t){if(!this.#e||(this.#h(),this.#e=!1,this.#u=Date.now(),!this.#p))return;const n=t?.prefixText??this.#r,s=t?.text??this.#o;let r=t?.symbol??"";n&&(r=r?`${n} ${r}`:n),s&&(r=r?`${r} ${s}`:s),this.#S(r)}succeed(t){this.#g("success",t)}failed(t){this.#g("error",t)}warn(t){this.#g("warning",t)}info(t){this.#g("info",t)}pause(){this.#h()}resume(){this.#e&&(this.#h(),this.#n||this.#y())}getFrameOutput(){if(!this.#e&&this.#f)return this.#f;const t=this.#c.frames[this.#i];let n=this.#a?this.#a(t):t;return this.#r&&(n=`${this.#r} ${n}`),this.#o&&(n=`${n} ${this.#o}`),n}#y(){this.#x&&(this.#l=setInterval(()=>{this.#e&&(this.#i=(this.#i+1)%this.#c.frames.length,this.#w())},this.#c.interval),this.#l.unref())}#h(){this.#l&&(clearInterval(this.#l),this.#l=void 0)}#w(){this.#n?this.#n.renderAll():this.#t?this.#v():this.#k()}#v(){this.#t&&this.#t.update("stdout",[this.getFrameOutput()])}#k(){const t=this.getFrameOutput();if(this.#$(),this.#s.isTTY){this.#s.write(t);const n=this.#s.columns||80;this.#d=Math.max(1,Math.ceil(He(t)/n))}else this.#s.write(`${t}
1
+ import{createRequire as be}from"node:module";import{F as $,b as L,X as ce,J,q as ae}from"../packem_shared/index.server-Ca_EEVfw.js";import{v as R,a as G,U as I,z as Se,e as M}from"../packem_shared/index-0dnGN3GP.js";import{fingerprint as E,scan as le,scanFiles as Ee,inspectRuleset as Ie,listRules as K,listRequiredValidators as Re,scanGitHistory as Te}from"@visulima/secret-scanner";import{V as Ae,W as Q,p as y}from"./cli-main.js";import{E as je,A as Ne}from"../packem_shared/getRandomSpinner-DX11qCB2-CoIsn7ZU.js";import{U as Fe}from"../packem_shared/env-CsENUmRe.js";import{y as X}from"../packem_shared/isAccessibleSync-DYKTrrvc-CBsMZhj-.js";import{p as Me}from"../packem_shared/package-version-BzkcrNVE.js";let ve;const ke=e=>(ve??=be(import.meta.url))(e),j=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,W=e=>{if(typeof j<"u"&&j.versions&&j.versions.node){const[t,n]=j.versions.node.split(".").map(Number);if(t>22||t===22&&n>=3||t===20&&n>=16)return j.getBuiltinModule(e)}return ke(e)},{createRequire:Ce}=W("node:module"),{pathToFileURL:ue}=W("node:url"),{execFileSync:Le}=W("node:child_process");let Oe;const _e=e=>(Oe??=Ce(import.meta.url))(e),N=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,Be=e=>{if(typeof N<"u"&&N.versions&&N.versions.node){const[t,n]=N.versions.node.split(".").map(Number);if(t>22||t===22&&n>=3||t===20&&n>=16)return N.getBuiltinModule(e)}return _e(e)},{styleText:qe}=Be("node:util"),Ue={error:"✖",info:"ℹ",success:"✓",warning:"⚠"},De=()=>{const{env:e}=process;return!!e.CI||e.CONTINUOUS_INTEGRATION==="true"||"BUILD_NUMBER"in e||"RUN_ID"in e},Pe=/\u001B\[[\d;]*[a-z]/gi,He=e=>[...e.replaceAll(Pe,"")].length,Ve=e=>{const t=[];return e.bold&&t.push("bold"),e.dim&&t.push("dim"),e.italic&&t.push("italic"),e.underline&&t.push("underline"),e.strikethrough&&t.push("strikethrough"),e.color&&t.push(e.color),e.bgColor&&t.push(e.bgColor),t.length===0?n=>n:n=>qe(t,n)};let ze=class{#i=0;#l;#e=!1;#r="";#o="";#m=0;#u=0;#t;#n;#f="";#c;#p;#s;#x;#d=0;#a;#b;constructor(t={},n){if(t.frames)this.#c=t.frames;else{const s=t.name??"dots",r=Ne(s);if(!r)throw new Error(`Unknown spinner "${s}". Pass a custom \`frames\` set or use one of: ${je().join(", ")}.`);this.#c=r}this.#p=t.verbose!==!1,this.#r=t.prefixText??"",this.#t=n,this.#s=t.stream??process.stderr,this.#x=n?!0:this.#s.isTTY&&!De(),this.#b={...Ue,...t.icons},typeof t.style=="function"?this.#a=t.style:t.style&&(this.#a=Ve(t.style))}get elapsedTime(){return this.#m===0?0:(this.#u||Date.now())-this.#m}get text(){return this.#o}set text(t){this.#o=t,this.#e&&this.#w()}get prefixText(){return this.#r}set prefixText(t){this.#r=t,this.#e&&this.#w()}get isRunning(){return this.#e}setInteractiveManager(t){this.#t=t}setMultiSpinner(t){this.#n=t}tick(){this.#e&&(this.#i=(this.#i+1)%this.#c.frames.length)}start(t,n){return this.#e?this:this.#p?(this.#e=!0,this.#m=Date.now(),this.#u=0,this.#i=0,this.#f="",t&&(this.#o=t),n?.prefixText&&(this.#r=n.prefixText),this.#n?(this.#n.renderAll(),this):(this.#t?(this.#t.hook(),this.#v(),this.#y()):(this.#k(),this.#y()),this)):this}stop(){if(this.#e){if(this.#h(),this.#e=!1,this.#u=Date.now(),this.#f="",this.#n){this.#n.renderAll();return}this.#t?(this.#t.erase("stdout"),this.#t.unhook(!1)):this.#$()}}stopAndPersist(t){if(!this.#e||(this.#h(),this.#e=!1,this.#u=Date.now(),!this.#p))return;const n=t?.prefixText??this.#r,s=t?.text??this.#o;let r=t?.symbol??"";n&&(r=r?`${n} ${r}`:n),s&&(r=r?`${r} ${s}`:s),this.#S(r)}succeed(t){this.#g("success",t)}failed(t){this.#g("error",t)}warn(t){this.#g("warning",t)}info(t){this.#g("info",t)}pause(){this.#h()}resume(){this.#e&&(this.#h(),this.#n||this.#y())}getFrameOutput(){if(!this.#e&&this.#f)return this.#f;const t=this.#c.frames[this.#i];let n=this.#a?this.#a(t):t;return this.#r&&(n=`${this.#r} ${n}`),this.#o&&(n=`${n} ${this.#o}`),n}#y(){this.#x&&(this.#l=setInterval(()=>{this.#e&&(this.#i=(this.#i+1)%this.#c.frames.length,this.#w())},this.#c.interval),this.#l.unref())}#h(){this.#l&&(clearInterval(this.#l),this.#l=void 0)}#w(){this.#n?this.#n.renderAll():this.#t?this.#v():this.#k()}#v(){this.#t&&this.#t.update("stdout",[this.getFrameOutput()])}#k(){const t=this.getFrameOutput();if(this.#$(),this.#s.isTTY){this.#s.write(t);const n=this.#s.columns||80;this.#d=Math.max(1,Math.ceil(He(t)/n))}else this.#s.write(`${t}
2
2
  `),this.#d=0}#$(){if(this.#d>0&&this.#s.isTTY){for(let t=1;t<this.#d;t+=1)this.#s.write("\x1B[1A\x1B[2K");this.#s.write("\r\x1B[K")}this.#d=0}#S(t){this.#f=t,this.#n?this.#n.renderAll():this.#t?(this.#t.update("stdout",[t]),this.#t.unhook(!1)):(this.#$(),this.#s.write(`${t}
3
3
  `))}#g(t,n){if(!this.#e||(this.#h(),this.#e=!1,this.#u=Date.now(),!this.#p))return;let s="";const r=this.#b[t];r&&(s=this.#a?this.#a(r):r),this.#r&&(s=`${this.#r} ${s}`),n&&(s=`${s} ${n}`),this.#S(s)}};const We=(e,t,n)=>{const s=n.toLowerCase();e[s]??=new Map;const r=e[s].get(t);if(r!==void 0)return r;const{size:i}=e[s],c=`<${n.toUpperCase()}${i>0?String(i):""}>`;return e[s].set(t,c),c},Z=(e,t)=>{const{replacement:n,tag:s,text:r}=t;return typeof n=="function"?String(n(r,void 0)):typeof n=="string"?n:We(e,r,s)},Je=(e,t)=>{const n={};let s="",r=0;for(const i of e){const{start:c,text:o}=i;if(o==="")continue;if(Number.isInteger(c)&&c>=0&&t.slice(c,c+o.length)===o){if(c<r)continue;s+=t.slice(r,c)+Z(n,i),r=c+o.length;continue}let a=t.indexOf(o,r);if(a===-1)continue;const l=Z(n,i);for(;a!==-1;)s+=t.slice(r,a)+l,r=a+o.length,a=t.indexOf(o,r)}return s+t.slice(r)},Ge=e=>[...e.reduce((t,n)=>t.set(n.text+String(n.start)+n.tag,n),new Map).values()].toSorted((t,n)=>{const s=t.start-n.start;return s!==0?s:n.text.length-t.text.length}),Ke=(e,t)=>{const n=[];for(const s of e){const{key:r,pattern:i}=s,c=s.compiledPattern??new RegExp(i,"giu");c.lastIndex=0;let o;for(;(o=c.exec(t))!==null;){const a=s;n.push({replacement:a.userReplacement??a.replacement!==void 0?a.replacement:void 0,start:o.index,tag:r,text:o[0]}),o.index===c.lastIndex&&(c.lastIndex+=1)}}return n},Xe=(e,t,n,s)=>Ge([...Ke(n,e)]),fe=(e,t,n)=>{const s=[],r=[];for(const o of t)typeof o=="object"&&o.pattern&&s.push(o),r.push((typeof o=="object"?o.key:String(o)).toLowerCase());let i=e;const c=Xe(e,r,s);return i=Je(c,i),i},k=e=>{const t=typeof e;return e!==null&&(t==="object"||t==="function")},q=new Set(["__proto__","prototype","constructor"]),Ye=Math.max(...[...q].map(e=>e.length)),de=1e6,Qe=e=>e>="0"&&e<="9";function he(e){if(e==="0")return!0;if(/^[1-9]\d*$/.test(e)){const t=Number.parseInt(e,10);return t<=Number.MAX_SAFE_INTEGER&&t<=de}return!1}function D(e,t){return q.has(e)?!1:(e&&he(e)?t.push(Number.parseInt(e,10)):t.push(e),!0)}function Ze(e){if(typeof e!="string")throw new TypeError(`Expected a string, got ${typeof e}`);const t=[];let n="",s="",r=!1,i="start",c=!1,o=0;for(const a of e){if(o++,c){n+=a,c=!1;continue}if(a==="\\"){if(i==="index")throw new Error(`Invalid character '${a}' in an index at position ${o}`);if(i==="indexEnd")throw new Error(`Invalid character '${a}' after an index at position ${o}`);c=!0,i=i==="start"?"property":i;continue}switch(a){case".":{if(i==="index")throw new Error(`Invalid character '${a}' in an index at position ${o}`);if(i==="indexEnd"){i="property";break}if(!D(n,t))return[];n="",i="property";break}case"[":{if(i==="index")throw new Error(`Invalid character '${a}' in an index at position ${o}`);if(i==="indexEnd"){i="index";break}if(i==="property"&&n.length<=Ye&&q.has(n))return[];r=i==="property",i="index";break}case"]":{if(i==="indexEnd")throw new Error(`Invalid character '${a}' after an index at position ${o}`);if(i!=="index"){i==="start"&&(i="property"),n+=a;break}if(s===""){n+="[]",i="property";break}if((n!==""||r)&&!D(n,t))return[];n="",r=!1;const l=Number.parseInt(s,10),f=l<=de&&s===String(l);t.push(f?l:s),s="",i="indexEnd";break}default:{if(i==="index"){if(!Qe(a))throw new Error(`Invalid character '${a}' in an index at position ${o}`);s+=a;break}if(i==="indexEnd")throw new Error(`Invalid character '${a}' after an index at position ${o}`);i==="start"&&(i="property"),n+=a}}}switch(c&&(n+="\\"),i){case"property":{if(!D(n,t))return[];break}case"index":throw new Error("Index was not closed");case"start":{t.push("");break}}return t}function U(e){if(typeof e=="string")return Ze(e);if(Array.isArray(e)){const t=[];for(const[n,s]of e.entries()){if(typeof s!="string"&&typeof s!="number")throw new TypeError(`Expected a string or number for path segment at index ${n}, got ${typeof s}`);if(typeof s=="number"&&!Number.isFinite(s))throw new TypeError(`Path segment at index ${n} must be a finite number, got ${s}`);if(q.has(s))return[];typeof s=="string"&&he(s)?t.push(Number.parseInt(s,10)):t.push(s)}return t}return[]}function et(e,t,n){if(!k(e)||typeof t!="string"&&!Array.isArray(t))return e;const s=U(t);if(s.length===0)return n;for(let r=0;r<s.length;r++){const i=s[r];if(e=e[i],e==null){if(r!==s.length-1)return n;break}}return e===void 0?n:e}function tt(e,t,n){if(!k(e)||typeof t!="string"&&!Array.isArray(t))return e;const s=e,r=U(t);if(r.length===0)return e;for(let i=0;i<r.length;i++){const c=r[i];if(i===r.length-1){e[c]=n;continue}const o=e[c];if(k(o)){e=o;continue}const a=typeof r[i+1]=="number";e[c]=a?[]:{},e=e[c]}return s}function nt(e,t){if(!k(e)||typeof t!="string"&&!Array.isArray(t))return!1;const n=U(t);if(n.length===0)return!1;for(let s=0;s<n.length;s++){const r=n[s];if(s===n.length-1)return Object.hasOwn(e,r)?(delete e[r],!0):!1;const i=e[r];if(!k(i))return!1;e=i}}function ee(e,t){if(!k(e)||typeof t!="string"&&!Array.isArray(t))return!1;const n=U(t);if(n.length===0)return!1;for(const s of n){if(!k(e)||!(s in e))return!1;e=e[s]}return!0}const P="#;/?:@&",H=new RegExp(String.raw`([${P}][^${P}=\s]+=[^${P}=\s]*)`,"g"),st=e=>{const t=[];let n=0;H.lastIndex=0;let s=H.exec(e);for(;s!==null;){const{0:i,index:c}=s;t.push({key:void 0,value:e.slice(n,c+1)}),n=c+i.length,t.push({key:i.slice(1,i.indexOf("=")),value:i.slice(i.indexOf("=")+1)}),s=H.exec(e)}const r=e.slice(n);return r.length>0&&t.push({key:void 0,value:r}),t},te=(e,t)=>{for(let n=0;n<e.length;n+=1){let s=e[n].string,r=e[n].index;for(;r<t.length;){const i=t[r];if(!s.includes(i))break;const c=s.slice(1);for(e.push({index:r,string:c}),c.includes(i)||e.pop(),s=s.slice(s.indexOf(i)+i.length),r+=1;t[r]==="";)r+=1;if(r>=t.length){if(t.at(-1)!==""&&s.length>0)break;return!0}}}return!1},V=(e,t)=>{if(!t.includes("*"))return t===e;const n=t.split("*");let s=0,r=e;for(;n[s]==="";)if(s+=1,s===t.length)return!0;if(s===0&&!e.startsWith(n[0]))return!1;const i=[];for(;s<n.length;){const c=n[s];if(!r.includes(c))return te(i,n);const o=r.slice(1);for(i.push({index:s,string:o}),o.includes(c)||i.pop(),r=r.slice(r.indexOf(c)+c.length),s+=1;n[s]==="";)s+=1}return s>=n.length&&n.at(-1)!==""&&r.length>0?r===e?!1:te(i,n):!0},rt=/(?:http|https):\/\/?/,T=(e,t,n)=>typeof e.replacement=="function"?e.replacement(t,n):e.replacement,pe=(e,t,n)=>e.wildcard?V(t,e.key)||V(n,e.key):t===e.key||n===e.key,it=(e,t,n,s)=>{n.remove?delete e[t]:e[t]=T(n,e[t],s)},ne=(e,t,n,s,r,i)=>{const c=[],o=[];for(const l of s)!l.wildcard&&!l.deep&&ee(e,l.key)?o.push(l):c.push(l);const a=Object.keys(e);for(const l of a){if(!Object.hasOwn(e,l))continue;const f=l.toLowerCase(),u=i?`${i}.${f}`:f;let h;for(const g of c)pe(g,f,u)&&(h=g);h?it(e,l,h,u):e[l]=x(e[l],t,n,c,r,u)}for(const l of o)if(ee(e,l.key))if(l.remove)nt(e,l.key);else{const f=i?`${i}.${l.key}`:l.key;tt(e,l.key,T(l,et(e,l.key),f))}},se=(e,t)=>{const n=t.toLowerCase();return e.find(s=>s.key===n||!!s.wildcard&&V(n,s.key))},ot=(e,t,n)=>{const s=st(e),r=[];for(const i of s){const{key:c,value:o}=i;if(c===void 0){const a=se(t,o);r.push(a?String(T(a,o,void 0)):fe(o,t))}else{const a=se(t,c);a?r.push(`${c}=${String(T(a,o,void 0))}`):r.push(`${c}=${o}`)}}return r.join("")},x=(e,t,n,s,r,i)=>{if(e==null)return e;if(typeof e=="object"&&e.constructor===String)return x(String(e),t,n,s,r,i);if(typeof e=="object"&&t.has(e))return t.get(e);if(typeof e=="object"&&!Array.isArray(e)){if(e instanceof Error){const o=new Error(e.message);Object.defineProperties(o,{name:{configurable:!0,enumerable:!1,value:e.name,writable:!0},stack:{configurable:!0,enumerable:!1,value:e.stack,writable:!0}}),e.code!==void 0&&(o.code=e.code);const a=Object.keys(e);for(const l of a)o[l]=e[l];return n(e,o),ne(o,t,n,s,r,i),o}if(e instanceof Map){const o=new Map;n(e,o);const a=e.entries();let l=a.next();for(;!l.done;){const[f,u]=l.value;if(typeof f=="string"||typeof f=="object"&&f!==null&&f.constructor===String){const h=f.toLowerCase(),g=i?`${i}.${h}`:h;let p;for(const m of s)pe(m,h,g)&&(p=m);p?p.remove||o.set(f,T(p,u,g)):o.set(f,x(u,t,n,s,r,g))}else o.set(x(f,t,n,s,r),x(u,t,n,s,r));l=a.next()}return o}if(e instanceof Set){const o=new Set;n(e,o);const a=e.values();let l=a.next();for(;!l.done;)o.add(x(l.value,t,n,s,r,i)),l=a.next();return o}const c={...e};return n(e,c),ne(c,t,n,s,r,i),c}if(typeof e=="string"){const c=e;try{const o=JSON.parse(c);if(typeof o=="object"&&o!==null){const a=x(o,t,n,s,r,i);return JSON.stringify(a)}}catch{}return rt.test(c)?ot(c,s):fe(c,s)}if(Array.isArray(e)){const c=[];n(e,c);for(const[o,a]of e.entries()){const l=o.toString().toLowerCase(),f=i?`${i}.${l}`.toLowerCase():l,u=s.find(h=>h.key===l||h.key===f);u?c.push(T(u,a,f)):c.push(x(a,t,n,s,r,f))}return c}return e},ct=(e,t)=>{const n=[];for(const s of e)if(typeof s=="string"){const r=s.includes("*");n.push({deep:!1,key:s.toLowerCase(),replacement:`<${s.toUpperCase()}>`,userReplacement:!1,wildcard:r})}else if(typeof s=="number")n.push({deep:!1,key:s.toString(),replacement:"<REDACTED>"});else{const r=s.key.toLowerCase(),i={...s,key:r,replacement:s.replacement??`<${r.toUpperCase()}>`,userReplacement:s.replacement!==void 0,wildcard:r.includes("*")?!0:s.wildcard};if(i.pattern!==void 0){const c=i.pattern instanceof RegExp?i.pattern.source:i.pattern;i.compiledPattern=new RegExp(c,"giu")}n.push(i)}return n},at=(e,t,n)=>{if(e==null||typeof e=="number"||typeof e=="boolean")return e;const s=new WeakMap;return x(e,s,(r,i)=>{s.set(r,i)},t,n)},ge=(e,t,n)=>{const s=ct(t);return at(e,s,n)},Y=(e={})=>{const t=new Ae(new Q(process.stdout),new Q(process.stderr));return new ze(e,t)},lt=(e,t)=>{if(!R(e))return e;const n=G(t,e);return n===""||n.startsWith("..")?e:n},A=(e,t)=>{const n=lt(e.file,t);return n===e.file?e:{...e,file:n}},me=e=>{if(!X(e))return[];try{const t=Me(e);return Array.isArray(t)?t:[]}catch{return[]}},ut=(e,t,n)=>{const s=me(t).map(o=>A(o,n)),r=new Set(s.map(o=>E(o))),i=e.map(o=>A(o,n)),c=new Set(i.map(o=>E(o)));return{fresh:i.filter(o=>!r.has(E(o))),resolved:s.filter(o=>!c.has(E(o))),surviving:i.filter(o=>r.has(E(o)))}},ye=(e,t,n,s={})=>{const r=e.map(c=>A(c,n));let i;if(s.replace)i=r;else{const c=me(t).map(a=>A(a,n)),o=new Set;i=[];for(const a of[...c,...r]){const l=E(a);o.has(l)||(o.add(l),i.push(a))}}return Fe(t,`${JSON.stringify(i,null,4)}
4
4
  `),i.length},re=1,ft=e=>{const t=new Map;for(const n of e){const s=t.get(n.file);s?s.push(n):t.set(n.file,[n])}return t},dt=e=>{try{return Se(e).split(/\r?\n/)}catch{return}},ht=(e,t,n)=>{const s=Math.max(1,t);return`${e.slice(0,s-1).replaceAll(/[^\t]/g," ")}${"^".repeat(Math.max(1,n))}`},pt=(e,t,n,s={})=>{if(e.length===0)return n?$("No secrets detected."):"No secrets detected.";const r=n?{cyan:ae,dim:$,green:J,red:ce,yellow:L}:{cyan:o=>o,dim:o=>o,green:o=>o,red:o=>o,yellow:o=>o},i=[],c=ft(e);for(const[o,a]of c){const l=G(t,o)||o;i.push(r.cyan(l));const f=s.redact?void 0:dt(o);for(const u of a){const h=[u.source,u.confidence].filter(Boolean).join(", "),g=h?` ${r.dim(`(${h})`)}`:"",p=u.alternateMatches&&u.alternateMatches.length>0?` ${r.dim(`also: ${u.alternateMatches.join(", ")}`)}`:"";let m="";switch(u.validation){case"error":{m=` ${r.yellow("! error")}`;break}case"rejected":{m=` ${r.red("✗ rejected")}`;break}case"skipped":{m=` ${r.dim("— unverifiable")}`;break}case"verified":{m=` ${r.green("✓ verified")}`;break}}if(i.push(` ${r.red("✖")} ${r.yellow(`[${u.ruleId}]`)}${g}${m} ${r.dim(`line ${String(u.startLine)}:${String(u.startColumn)}`)}${p}`),f){const C=Math.max(0,u.startLine-1-re),b=Math.min(f.length,u.startLine+re);for(let d=C;d<b;d+=1){const S=String(d+1).padStart(4," "),v=d+1===u.startLine,w=v?r.red("▶"):" ";if(i.push(` ${w} ${r.dim(S)} │ ${f[d]??""}`),v){const O=Math.max(1,(u.endColumn??u.startColumn+1)-u.startColumn),xe=ht(f[d]??"",u.startColumn,O);i.push(` ${r.dim(" │ ")}${r.red(xe)}`)}}}i.push("")}}return i.join(`
@@ -1,4 +1,4 @@
1
- import{createRequire as ee}from"node:module";import{e as A,a as re}from"../packem_shared/index-0dnGN3GP.js";import{f as ae,h as M}from"../packem_shared/ai-cache-B-3KMpa9.js";import{p as c,X as V,Y as k,Z as ne,R as P,_ as L,$ as oe,h as ie}from"./cli-main.js";import{B as ce,C as de,D as N,E as z}from"../packem_shared/registry-Mb5e6Tf4.js";import{r as he,d as x,a as U,t as I}from"../packem_shared/env-DDmZsWBr.js";import{z as b}from"../packem_shared/formatBytes-_HvjOy8a-iHCer6uX.js";import{Cache as E,readLastRunSummary as q,getLastRunSummaryPath as T,parseCacheSize as me,digestFile as X,describeCacheMissReason as pe}from"@visulima/task-runner";import{y as R}from"../packem_shared/isAccessibleSync-DYKTrrvc-CBsMZhj-.js";import{r as G,f as F,a as ye,d as $e}from"../packem_shared/run-summary-utils-B0K6xaLZ.js";let te;const se=e=>(te??=ee(import.meta.url))(e),g=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,j=e=>{if(typeof g<"u"&&g.versions&&g.versions.node){const[s,t]=g.versions.node.split(".").map(Number);if(s>22||s===22&&t>=3||s===20&&t>=16)return g.getBuiltinModule(e)}return se(e)},{realpath:_,rm:W,mkdtemp:fe,readdir:ue,stat:Y}=j("node:fs/promises"),{createInterface:le}=j("node:readline"),{tmpdir:Se}=j("node:os"),we=e=>new Promise(s=>{const t=le({input:process.stdin,output:process.stderr});t.question(`${e} (y/N) `,r=>{t.close();const n=r.trim().toLowerCase();s(n==="y"||n==="yes")})}),ve=()=>{try{const e=ae();e>0&&c.info(`Cleared ${String(e)} cached AI response${e===1?"":"s"}.`)}catch(e){c.warn(`Failed to clear AI response cache: ${e instanceof Error?e.message:String(e)}`)}},ke=()=>{try{const e=he();e>0&&c.info(`Cleared ${String(e)} cached Socket.dev report${e===1?"":"s"}.`)}catch(e){c.warn(`Failed to clear Socket.dev cache: ${e instanceof Error?e.message:String(e)}`)}},Ce=()=>{try{const e=ce();e>0&&c.info(`Cleared ${String(e)} cached deps.dev record${e===1?"":"s"}.`)}catch(e){c.warn(`Failed to clear deps.dev cache: ${e instanceof Error?e.message:String(e)}`)}},ge=()=>{try{const e=de();e>0&&c.info(`Cleared ${String(e)} cached Snyk record${e===1?"":"s"}.`)}catch(e){c.warn(`Failed to clear Snyk cache: ${e instanceof Error?e.message:String(e)}`)}},De=async(e,s,t)=>{if(!R(e)){c.info(`No cache directory to clean at ${e}`);return}if(t.dryRun){const a=(await Promise.all(V(e,!0).map(async i=>k(i)))).flat(),o=a.reduce((i,d)=>i+d.sizeBytes,0);c.info(`Would remove ${String(a.length)} cache entr${a.length===1?"y":"ies"} (${b(o,{decimals:1,space:!1})}) from ${e}`);return}const r=ne(e,s);try{const n=await _(e),a=await _(s);if(n===a){c.error("Refusing to delete the workspace root. The cache directory resolved to the same path as the workspace."),process.exitCode=1;return}}catch{}if(!r&&!t.force){if(c.warn(`Cache directory is outside the workspace root: ${e}`),c.warn("This will recursively delete the entire directory, including anything stored there by other tools."),!process.stdin.isTTY){c.error("Refusing to clean an out-of-workspace cache without --force (stdin is not a TTY)."),process.exitCode=1;return}if(!await we(" Continue?")){c.info("Aborted.");return}}r?await new E({cacheDirectory:e,workspaceRoot:s}).clear():await W(e,{force:!0,recursive:!0}),c.success(`Cleared cache: ${e}`)},Z=e=>e==="task"||e==="ai"||e==="socket"||e==="deps-dev"||e==="snyk"||e==="all"?e:(e&&e.length>0&&c.warn(`Unknown --type value '${e}'; falling back to 'all'.`),"all"),m=(e,s)=>e==="all"||e===s,xe=e=>e==="worktree"||e==="shared"||e==="all"?e:(e&&e.length>0&&c.warn(`Unknown --scope value '${e}'; falling back to 'shared'.`),"shared"),w=(e,s,t)=>{const r=e??process.cwd(),n=t??{},a=n.taskRunner??{},o=xe(s.scope),i=s.cacheDir,d=P(r,i,a.cacheDirectory,!1),f=P(r,i,a.cacheDirectory,n.sharedWorktreeCache),h=L(d,r,n.branchScopedCache),u=L(f,r,n.branchScopedCache);let l;switch(o){case"all":{l=u===h?[{base:f,scoped:u}]:[{base:f,scoped:u},{base:d,scoped:h}];break}case"worktree":{l=[{base:d,scoped:h}];break}default:l=[{base:f,scoped:u}]}const $=n.branchScopedCache===!0;return{directoriesFor:O=>O==="read"?[...new Set(l.flatMap(p=>p.scoped!==p.base&&oe(p.base)?[p.scoped,p.base]:[p.scoped]))]:O==="wipe"?[...new Set(l.map(p=>p.base))]:[...new Set(l.flatMap(p=>V(p.base,$)))],scope:o,sharedWorktreeCache:n.sharedWorktreeCache,workspaceRoot:r}},H=16,K=e=>e.length>H?`${e.slice(0,H)}…`:e,v=(e,s,t)=>{const r=Object.entries(s??{});if(r.length!==0){t.info(` ${e}:`),r.sort(([n],[a])=>n.localeCompare(a));for(const[n,a]of r)t.info(` ${n.padEnd(40)} ${K(a)}`)}},be=async(e,s,t)=>{if(e!==void 0)for(const r of s){const n=await new E({cacheDirectory:r,workspaceRoot:t}).get(e);if(n?.fingerprint)return n.fingerprint}},Ee=(e,s)=>{v("tracked files",e.fileHashes,s),v("tracked env",e.envHashes,s),v("missing files",Object.fromEntries(e.missingFiles.map(t=>[t,"absent"])),s)},Re=async(e,s,t)=>{const{format:r,runId:n,workspaceRoot:a}=s,o=n===void 0?await q(a,{dataDirectory:x(a)}):await G(a,n);if(!o){if(r==="json"){process.stdout.write(`${JSON.stringify({error:"no-summary",runId:n??null,taskId:e},void 0,2)}
1
+ import{createRequire as ee}from"node:module";import{e as A,a as re}from"../packem_shared/index-0dnGN3GP.js";import{f as ae,h as M}from"../packem_shared/ai-cache-Bq3dQd87.js";import{p as c,X as V,Y as k,Z as ne,R as P,_ as L,$ as oe,h as ie}from"./cli-main.js";import{B as ce,C as de,D as N,E as z}from"../packem_shared/registry-CIfr2njA.js";import{r as he,d as x,a as U,t as I}from"../packem_shared/env-CsENUmRe.js";import{z as b}from"../packem_shared/formatBytes-_HvjOy8a-iHCer6uX.js";import{Cache as E,readLastRunSummary as q,getLastRunSummaryPath as T,parseCacheSize as me,digestFile as X,describeCacheMissReason as pe}from"@visulima/task-runner";import{y as R}from"../packem_shared/isAccessibleSync-DYKTrrvc-CBsMZhj-.js";import{r as G,f as F,a as ye,d as $e}from"../packem_shared/run-summary-utils-BYPm6bUE.js";let te;const se=e=>(te??=ee(import.meta.url))(e),g=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,j=e=>{if(typeof g<"u"&&g.versions&&g.versions.node){const[s,t]=g.versions.node.split(".").map(Number);if(s>22||s===22&&t>=3||s===20&&t>=16)return g.getBuiltinModule(e)}return se(e)},{realpath:_,rm:W,mkdtemp:fe,readdir:ue,stat:Y}=j("node:fs/promises"),{createInterface:le}=j("node:readline"),{tmpdir:Se}=j("node:os"),we=e=>new Promise(s=>{const t=le({input:process.stdin,output:process.stderr});t.question(`${e} (y/N) `,r=>{t.close();const n=r.trim().toLowerCase();s(n==="y"||n==="yes")})}),ve=()=>{try{const e=ae();e>0&&c.info(`Cleared ${String(e)} cached AI response${e===1?"":"s"}.`)}catch(e){c.warn(`Failed to clear AI response cache: ${e instanceof Error?e.message:String(e)}`)}},ke=()=>{try{const e=he();e>0&&c.info(`Cleared ${String(e)} cached Socket.dev report${e===1?"":"s"}.`)}catch(e){c.warn(`Failed to clear Socket.dev cache: ${e instanceof Error?e.message:String(e)}`)}},Ce=()=>{try{const e=ce();e>0&&c.info(`Cleared ${String(e)} cached deps.dev record${e===1?"":"s"}.`)}catch(e){c.warn(`Failed to clear deps.dev cache: ${e instanceof Error?e.message:String(e)}`)}},ge=()=>{try{const e=de();e>0&&c.info(`Cleared ${String(e)} cached Snyk record${e===1?"":"s"}.`)}catch(e){c.warn(`Failed to clear Snyk cache: ${e instanceof Error?e.message:String(e)}`)}},De=async(e,s,t)=>{if(!R(e)){c.info(`No cache directory to clean at ${e}`);return}if(t.dryRun){const a=(await Promise.all(V(e,!0).map(async i=>k(i)))).flat(),o=a.reduce((i,d)=>i+d.sizeBytes,0);c.info(`Would remove ${String(a.length)} cache entr${a.length===1?"y":"ies"} (${b(o,{decimals:1,space:!1})}) from ${e}`);return}const r=ne(e,s);try{const n=await _(e),a=await _(s);if(n===a){c.error("Refusing to delete the workspace root. The cache directory resolved to the same path as the workspace."),process.exitCode=1;return}}catch{}if(!r&&!t.force){if(c.warn(`Cache directory is outside the workspace root: ${e}`),c.warn("This will recursively delete the entire directory, including anything stored there by other tools."),!process.stdin.isTTY){c.error("Refusing to clean an out-of-workspace cache without --force (stdin is not a TTY)."),process.exitCode=1;return}if(!await we(" Continue?")){c.info("Aborted.");return}}r?await new E({cacheDirectory:e,workspaceRoot:s}).clear():await W(e,{force:!0,recursive:!0}),c.success(`Cleared cache: ${e}`)},Z=e=>e==="task"||e==="ai"||e==="socket"||e==="deps-dev"||e==="snyk"||e==="all"?e:(e&&e.length>0&&c.warn(`Unknown --type value '${e}'; falling back to 'all'.`),"all"),m=(e,s)=>e==="all"||e===s,xe=e=>e==="worktree"||e==="shared"||e==="all"?e:(e&&e.length>0&&c.warn(`Unknown --scope value '${e}'; falling back to 'shared'.`),"shared"),w=(e,s,t)=>{const r=e??process.cwd(),n=t??{},a=n.taskRunner??{},o=xe(s.scope),i=s.cacheDir,d=P(r,i,a.cacheDirectory,!1),f=P(r,i,a.cacheDirectory,n.sharedWorktreeCache),h=L(d,r,n.branchScopedCache),u=L(f,r,n.branchScopedCache);let l;switch(o){case"all":{l=u===h?[{base:f,scoped:u}]:[{base:f,scoped:u},{base:d,scoped:h}];break}case"worktree":{l=[{base:d,scoped:h}];break}default:l=[{base:f,scoped:u}]}const $=n.branchScopedCache===!0;return{directoriesFor:O=>O==="read"?[...new Set(l.flatMap(p=>p.scoped!==p.base&&oe(p.base)?[p.scoped,p.base]:[p.scoped]))]:O==="wipe"?[...new Set(l.map(p=>p.base))]:[...new Set(l.flatMap(p=>V(p.base,$)))],scope:o,sharedWorktreeCache:n.sharedWorktreeCache,workspaceRoot:r}},H=16,K=e=>e.length>H?`${e.slice(0,H)}…`:e,v=(e,s,t)=>{const r=Object.entries(s??{});if(r.length!==0){t.info(` ${e}:`),r.sort(([n],[a])=>n.localeCompare(a));for(const[n,a]of r)t.info(` ${n.padEnd(40)} ${K(a)}`)}},be=async(e,s,t)=>{if(e!==void 0)for(const r of s){const n=await new E({cacheDirectory:r,workspaceRoot:t}).get(e);if(n?.fingerprint)return n.fingerprint}},Ee=(e,s)=>{v("tracked files",e.fileHashes,s),v("tracked env",e.envHashes,s),v("missing files",Object.fromEntries(e.missingFiles.map(t=>[t,"absent"])),s)},Re=async(e,s,t)=>{const{format:r,runId:n,workspaceRoot:a}=s,o=n===void 0?await q(a,{dataDirectory:x(a)}):await G(a,n);if(!o){if(r==="json"){process.stdout.write(`${JSON.stringify({error:"no-summary",runId:n??null,taskId:e},void 0,2)}
2
2
  `),process.exitCode=1;return}n===void 0?c.error(`No previous run summary found. Run a task first to populate \`${T(a,{dataDirectory:x(a)})}\`.`):c.error(`Run summary "${n}" not found in ${U(a)}/.`),process.exitCode=1;return}const i=F(o,e);if(!i){if(r==="json"){process.stdout.write(`${JSON.stringify({error:"task-not-in-summary",runId:o.id,taskId:e},void 0,2)}
3
3
  `),process.exitCode=1;return}c.error(`Task "${e}" was not part of run ${o.id}.`),process.exitCode=1;return}const d=i.hashDetails===void 0?await be(i.hash,s.cacheDirectories??[],a):void 0;if(r==="json"){process.stdout.write(`${JSON.stringify({cacheStatus:i.cacheStatus,hash:i.hash??null,hashDetails:i.hashDetails??null,hashSource:i.hashSource??null,runId:o.id,taskId:i.taskId,trackedFingerprint:d??null},void 0,2)}
4
4
  `);return}c.info(`Hash for ${e} (run ${o.id})`),t.info(""),t.info(` status: ${i.cacheStatus}`),t.info(` hash: ${i.hash??"(none)"}`),i.hashSource==="declared-fallback"&&t.info(" key: declared-fallback (no files were tracked; the entry is keyed on the declared inputs below)"),i.hashDetails?(t.info(""),t.info(` command: ${K(i.hashDetails.command)}`),v("nodes",i.hashDetails.nodes,t),v("runtime",i.hashDetails.runtime,t),v("implicitDeps",i.hashDetails.implicitDeps,t)):d?(t.info(""),Ee(d,t)):(t.info(""),c.info("No hash details recorded for this task."))},S=e=>{process.stdout.write(`${e}
@@ -1 +1 @@
1
- import{r as m}from"../packem_shared/affected-shas-CycHU3nr.js";import{r as u}from"../packem_shared/toolchain-Z0l12EQs.js";const $=async({argument:h,logger:r,options:e,runtime:s,visConfig:f,workspaceRoot:n})=>{const o=h[0];if(!o)throw new Error("Missing targets. Usage: vis ci <target>[,<target>…]");const l=o.split(",").map(a=>a.trim()).filter(Boolean);if(l.length===0)throw new Error("Missing targets. Usage: vis ci <target>[,<target>…]");if(!n)throw new Error("Could not determine workspace root. Run this command inside a monorepo.");const i=m({defaultBase:f?.defaultBase,workspaceRoot:n}),c=e.base??i.base,d=e.head??i.head;!e.base&&!e.head&&r.info(`▸ Resolved affected refs from ${i.provider} (${i.notes.join("; ")})`),e.skipToolchain||r.info("▸ Toolchain pre-flight"),await u(n,f?.toolchain,{error:a=>{r.error(a)},info:a=>{r.info(a)},warn:a=>{r.warn(a)}},!!e.skipToolchain),e.install?(r.info("▸ Installing dependencies"),await s.runCommand("install",{argv:["--ci","--frozen-lockfile"]})):r.info("▸ Skipping install (--no-install)");for(const a of l){r.info(`▸ Running affected ${a} (base=${c}, head=${d})`);const t=[a,`--base=${c}`,`--head=${d}`,`--upstream=${String(e.upstream??"none")}`,`--downstream=${String(e.downstream??"deep")}`];Number.isFinite(e.parallel)&&t.push(`--parallel=${String(e.parallel)}`),e.partition&&t.push(`--partition=${String(e.partition)}`),e.query&&t.push(`--query=${String(e.query)}`),e.ifPresent&&t.push("--if-present"),await s.runCommand("affected",{argv:t})}r.info("▸ CI pipeline complete")};export{$ as default};
1
+ import{r as m}from"../packem_shared/affected-shas-CycHU3nr.js";import{r as u}from"../packem_shared/toolchain-BF6NEQJ2.js";const $=async({argument:h,logger:r,options:e,runtime:s,visConfig:f,workspaceRoot:n})=>{const o=h[0];if(!o)throw new Error("Missing targets. Usage: vis ci <target>[,<target>…]");const l=o.split(",").map(a=>a.trim()).filter(Boolean);if(l.length===0)throw new Error("Missing targets. Usage: vis ci <target>[,<target>…]");if(!n)throw new Error("Could not determine workspace root. Run this command inside a monorepo.");const i=m({defaultBase:f?.defaultBase,workspaceRoot:n}),c=e.base??i.base,d=e.head??i.head;!e.base&&!e.head&&r.info(`▸ Resolved affected refs from ${i.provider} (${i.notes.join("; ")})`),e.skipToolchain||r.info("▸ Toolchain pre-flight"),await u(n,f?.toolchain,{error:a=>{r.error(a)},info:a=>{r.info(a)},warn:a=>{r.warn(a)}},!!e.skipToolchain),e.install?(r.info("▸ Installing dependencies"),await s.runCommand("install",{argv:["--ci","--frozen-lockfile"]})):r.info("▸ Skipping install (--no-install)");for(const a of l){r.info(`▸ Running affected ${a} (base=${c}, head=${d})`);const t=[a,`--base=${c}`,`--head=${d}`,`--upstream=${String(e.upstream??"none")}`,`--downstream=${String(e.downstream??"deep")}`];Number.isFinite(e.parallel)&&t.push(`--parallel=${String(e.parallel)}`),e.partition&&t.push(`--partition=${String(e.partition)}`),e.query&&t.push(`--query=${String(e.query)}`),e.ifPresent&&t.push("--if-present"),await s.runCommand("affected",{argv:t})}r.info("▸ CI pipeline complete")};export{$ as default};
@@ -1,4 +1,4 @@
1
- import{createRequire as Q}from"node:module";import{J as v,j as w,F as g,q as x,b,X as D}from"../packem_shared/index.server-Ca_EEVfw.js";import{e as I,z as se,a as $}from"../packem_shared/index-0dnGN3GP.js";import G from"./index.js";import{y as _}from"../packem_shared/isAccessibleSync-DYKTrrvc-CBsMZhj-.js";import{U as oe,T as F,l as ne,a0 as ae,a1 as ie,a2 as re,a3 as ce}from"./cli-main.js";import{h as pe,i as z,q as W,u as j,p as L,J as K}from"../packem_shared/registry-Mb5e6Tf4.js";import{p as S}from"../packem_shared/package-version-CNjr03oy.js";import{U as fe}from"../packem_shared/env-DDmZsWBr.js";import{l as le}from"../packem_shared/missing-package-json-Cvjhtrwa.js";import{readCatalogs as ue}from"./catalog2.js";let Z;const ee=e=>(Z??=Q(import.meta.url))(e),V=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,te=e=>{if(typeof V<"u"&&V.versions&&V.versions.node){const[a,s]=V.versions.node.split(".").map(Number);if(a>22||a===22&&s>=3||a===20&&s>=16)return V.getBuiltinModule(e)}return ee(e)},{readFileSync:Y,writeFileSync:H}=te("node:fs"),de=e=>/[*?[\]{}!]/.test(e),ge=e=>typeof e=="string"?e:e.reason,me=e=>typeof e=="string"?void 0:e.replacement,q=(e,a)=>e.some(s=>G(s,a)),U=(e,a)=>{if(typeof e=="string")return!0;const s=Array.isArray(e.packages)&&e.packages.length>0,t=Array.isArray(e.paths)&&e.paths.length>0;return!!(!s&&!t||s&&a.packageName!==void 0&&q(e.packages,a.packageName)||t&&q(e.paths,a.packageDir))},he=(e,a)=>{const s=a[e.depName];if(s!==void 0&&U(s,e))return{pattern:e.depName,rule:s};for(const[t,r]of Object.entries(a))if(de(t)&&G(t,e.depName)&&U(r,e))return{pattern:t,rule:r}},ke=(e,a)=>{if(Object.keys(a).length===0)return[];const s=[];for(const t of e){if(t.isInternal)continue;const r=he(t,a);r&&s.push({depName:t.depName,depType:t.depType,matchedPattern:r.pattern,packageDir:t.packageDir,packageJsonPath:t.packageJsonPath,packageName:t.packageName,reason:ge(r.rule),replacement:me(r.rule),specifier:t.specifier})}return s},ye=new Set(["dependencies","devDependencies","peerDependencies"]),Pe=e=>e.startsWith("catalog:"),$e=e=>e.startsWith("workspace:"),we=(e,a)=>{if(!e)return!1;for(const s of e.values())if(s.has(a))return!0;return!1},ve=(e,a={})=>{const s=a.min??3,t=new Set(a.ignoreDeps),r=e.filter(i=>i.isInternal||!ye.has(i.depType)||$e(i.specifier)||a.dep!==void 0&&i.depName!==a.dep?!1:!t.has(i.depName)),n=new Map;for(const i of r){const c=n.get(i.depName);c?c.push(i):n.set(i.depName,[i])}const o=[];for(const[i,c]of n){if(we(a.catalogs,i)||c.some(h=>Pe(h.specifier)))continue;const p=new Map;for(const h of c){let d=p.get(h.specifier);d||(d=new Set,p.set(h.specifier,d)),d.add(h.packageJsonPath)}const m=[...p.entries()].sort((h,d)=>h[1].size!==d[1].size?d[1].size-h[1].size:h[0].localeCompare(d[0]))[0];!m||m[1].size<s||o.push({catalogName:"default",depName:i,instanceCount:m[1].size,specifier:m[0]})}return o.sort((i,c)=>i.depName.localeCompare(c.depName))},De=(e,a)=>{if(a.length===0)return;const s=I(e,"pnpm-workspace.yaml"),r=_(s)?Y(s,"utf8"):"",n=r.includes(`\r
1
+ import{createRequire as Q}from"node:module";import{J as v,j as w,F as g,q as x,b,X as D}from"../packem_shared/index.server-Ca_EEVfw.js";import{e as I,z as se,a as $}from"../packem_shared/index-0dnGN3GP.js";import G from"./index.js";import{y as _}from"../packem_shared/isAccessibleSync-DYKTrrvc-CBsMZhj-.js";import{U as oe,T as F,l as ne,a0 as ae,a1 as ie,a2 as re,a3 as ce}from"./cli-main.js";import{h as pe,i as z,q as W,u as j,p as L,J as K}from"../packem_shared/registry-CIfr2njA.js";import{p as S}from"../packem_shared/package-version-BzkcrNVE.js";import{U as fe}from"../packem_shared/env-CsENUmRe.js";import{l as le}from"../packem_shared/missing-package-json-Bg72nt4h.js";import{readCatalogs as ue}from"./catalog2.js";let Z;const ee=e=>(Z??=Q(import.meta.url))(e),V=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,te=e=>{if(typeof V<"u"&&V.versions&&V.versions.node){const[a,s]=V.versions.node.split(".").map(Number);if(a>22||a===22&&s>=3||a===20&&s>=16)return V.getBuiltinModule(e)}return ee(e)},{readFileSync:Y,writeFileSync:H}=te("node:fs"),de=e=>/[*?[\]{}!]/.test(e),ge=e=>typeof e=="string"?e:e.reason,me=e=>typeof e=="string"?void 0:e.replacement,q=(e,a)=>e.some(s=>G(s,a)),U=(e,a)=>{if(typeof e=="string")return!0;const s=Array.isArray(e.packages)&&e.packages.length>0,t=Array.isArray(e.paths)&&e.paths.length>0;return!!(!s&&!t||s&&a.packageName!==void 0&&q(e.packages,a.packageName)||t&&q(e.paths,a.packageDir))},he=(e,a)=>{const s=a[e.depName];if(s!==void 0&&U(s,e))return{pattern:e.depName,rule:s};for(const[t,r]of Object.entries(a))if(de(t)&&G(t,e.depName)&&U(r,e))return{pattern:t,rule:r}},ke=(e,a)=>{if(Object.keys(a).length===0)return[];const s=[];for(const t of e){if(t.isInternal)continue;const r=he(t,a);r&&s.push({depName:t.depName,depType:t.depType,matchedPattern:r.pattern,packageDir:t.packageDir,packageJsonPath:t.packageJsonPath,packageName:t.packageName,reason:ge(r.rule),replacement:me(r.rule),specifier:t.specifier})}return s},ye=new Set(["dependencies","devDependencies","peerDependencies"]),Pe=e=>e.startsWith("catalog:"),$e=e=>e.startsWith("workspace:"),we=(e,a)=>{if(!e)return!1;for(const s of e.values())if(s.has(a))return!0;return!1},ve=(e,a={})=>{const s=a.min??3,t=new Set(a.ignoreDeps),r=e.filter(i=>i.isInternal||!ye.has(i.depType)||$e(i.specifier)||a.dep!==void 0&&i.depName!==a.dep?!1:!t.has(i.depName)),n=new Map;for(const i of r){const c=n.get(i.depName);c?c.push(i):n.set(i.depName,[i])}const o=[];for(const[i,c]of n){if(we(a.catalogs,i)||c.some(h=>Pe(h.specifier)))continue;const p=new Map;for(const h of c){let d=p.get(h.specifier);d||(d=new Set,p.set(h.specifier,d)),d.add(h.packageJsonPath)}const m=[...p.entries()].sort((h,d)=>h[1].size!==d[1].size?d[1].size-h[1].size:h[0].localeCompare(d[0]))[0];!m||m[1].size<s||o.push({catalogName:"default",depName:i,instanceCount:m[1].size,specifier:m[0]})}return o.sort((i,c)=>i.depName.localeCompare(c.depName))},De=(e,a)=>{if(a.length===0)return;const s=I(e,"pnpm-workspace.yaml"),r=_(s)?Y(s,"utf8"):"",n=r.includes(`\r
2
2
  `)?`\r
3
3
  `:`
4
4
  `,o=a.filter(d=>d.catalogName==="default").sort((d,u)=>d.depName.localeCompare(u.depName));if(o.length===0)return;const i=r.length>0?r.split(n):[],c=i.findIndex(d=>/^catalog\s*:\s*$/.test(d));if(c===-1){const d=["catalog:"];for(const J of o)d.push(` ${J.depName}: "${J.specifier}"`);let u=0;for(;u<i.length&&(i[u]??"").trim().length===0;)u+=1;const k=[...i.slice(0,u),...d,"",...i.slice(u)].join(n);return H(s,k.endsWith(n)?k:`${k}${n}`),s}let p=i.length;const f=new Set;for(let d=c+1;d<i.length;d+=1){const u=i[d]??"",k=u.trimStart();if(u.length===0)continue;if(u.length-k.length===0&&k.length>0&&!k.startsWith("#")){p=d;break}const P=/^([\w./@-]+)\s*:/.exec(k);P?.[1]&&f.add(P[1])}const m=[];for(const d of o)f.has(d.depName)||m.push(` ${d.depName}: "${d.specifier}"`);if(m.length===0)return;const h=[...i.slice(0,p),...m,...i.slice(p)].join(n);return H(s,h.endsWith(n)?h:`${h}${n}`),s},be=(e,a)=>{if(a.length===0)return"";const s=I(e,"pnpm-workspace.yaml"),r=_(s)?Y(s,"utf8"):"",n=[...a].sort((f,m)=>f.depName.localeCompare(m.depName)),o=["--- pnpm-workspace.yaml","+++ pnpm-workspace.yaml"],i=r.includes(`\r
@@ -1,4 +1,4 @@
1
- import{e as C,z as P,U as pe}from"../packem_shared/index-0dnGN3GP.js";import{L as ge,M as le,N as de,K as me,C as ye,Q as ke,p as m,q as fe}from"./cli-main.js";import{i as ue}from"../packem_shared/index-BjdW45xX.js";import he from"module-replacements/manifests/micro-utilities.json"with{type:"json"};import je from"module-replacements/manifests/native.json"with{type:"json"};import ve from"module-replacements/manifests/preferred.json"with{type:"json"};import{K as be,j as t,X as g,O as c,r as O,R as xe,h as Te,i as W}from"../packem_shared/registry-Mb5e6Tf4.js";import{a as ee}from"../packem_shared/index--eV4qIz5.js";import{l as Ie}from"./ts-loader.js";import{y as V}from"../packem_shared/isAccessibleSync-DYKTrrvc-CBsMZhj-.js";import{U as D}from"../packem_shared/env-DDmZsWBr.js";import{d as we,n as Me}from"../packem_shared/pm-runner-BXRi4ZM9.js";import{p as re}from"../packem_shared/package-version-CNjr03oy.js";import{l as Se}from"../packem_shared/glob-Cyk1H9ZL-BjuiUjNv.js";const Ce=["dependencies","devDependencies","peerDependencies","peerDependenciesMeta","optionalDependencies","bundleDependencies"],Ee=["overrides","pnpm","resolutions"],$e=["engines","files"],Oe=r=>{const e=ee.coerce(r)?.major;return e!==void 0&&e>=10},De=r=>{const e=C(r,"pnpm-workspace.yaml");if(!V(e))return{overrides:{},source:"pnpm-workspace.yaml"};try{return{overrides:Ie(e)?.overrides??{},source:"pnpm-workspace.yaml"}}catch{return{overrides:{},source:"pnpm-workspace.yaml"}}},Pe=(r,e)=>{let s={};return e==="pnpm"?s=r.pnpm?.overrides??{}:e==="yarn"||e==="bun"?s=r.resolutions??{}:s=r.overrides??{},{overrides:s,source:"package.json"}},Ne=(r,e,s)=>s.name==="pnpm"&&Oe(s.version)?De(r):Pe(e,s.name),Y=(r,e)=>{const s=e;for(const o of Ee){const n=r.indexOf(o);if(n!==-1&&o!==s)return s==="overrides"?n:n+1}let i=-1;for(const o of Ce){const n=r.indexOf(o);n>i&&(i=n)}if(i!==-1)return i+1;for(const o of $e){const n=r.indexOf(o);if(n!==-1)return n}return r.length},Ae=(r,e)=>{const s=C(r,"pnpm-workspace.yaml");if(!V(s))throw new Error(`pnpm-workspace.yaml not found at ${s}. Cannot write overrides for pnpm v10+.`);let i=P(s);const n=`overrides:
1
+ import{e as C,z as P,U as pe}from"../packem_shared/index-0dnGN3GP.js";import{L as ge,M as le,N as de,K as me,C as ye,Q as ke,p as m,q as fe}from"./cli-main.js";import{i as ue}from"../packem_shared/index-BjdW45xX.js";import he from"module-replacements/manifests/micro-utilities.json"with{type:"json"};import je from"module-replacements/manifests/native.json"with{type:"json"};import ve from"module-replacements/manifests/preferred.json"with{type:"json"};import{K as be,j as t,X as g,O as c,r as O,R as xe,h as Te,i as W}from"../packem_shared/registry-CIfr2njA.js";import{a as ee}from"../packem_shared/index--eV4qIz5.js";import{l as Ie}from"./ts-loader.js";import{y as V}from"../packem_shared/isAccessibleSync-DYKTrrvc-CBsMZhj-.js";import{U as D}from"../packem_shared/env-CsENUmRe.js";import{d as we,n as Me}from"../packem_shared/pm-runner-BXRi4ZM9.js";import{p as re}from"../packem_shared/package-version-BzkcrNVE.js";import{l as Se}from"../packem_shared/glob-Cyk1H9ZL-ChoYoZKK.js";const Ce=["dependencies","devDependencies","peerDependencies","peerDependenciesMeta","optionalDependencies","bundleDependencies"],Ee=["overrides","pnpm","resolutions"],$e=["engines","files"],Oe=r=>{const e=ee.coerce(r)?.major;return e!==void 0&&e>=10},De=r=>{const e=C(r,"pnpm-workspace.yaml");if(!V(e))return{overrides:{},source:"pnpm-workspace.yaml"};try{return{overrides:Ie(e)?.overrides??{},source:"pnpm-workspace.yaml"}}catch{return{overrides:{},source:"pnpm-workspace.yaml"}}},Pe=(r,e)=>{let s={};return e==="pnpm"?s=r.pnpm?.overrides??{}:e==="yarn"||e==="bun"?s=r.resolutions??{}:s=r.overrides??{},{overrides:s,source:"package.json"}},Ne=(r,e,s)=>s.name==="pnpm"&&Oe(s.version)?De(r):Pe(e,s.name),Y=(r,e)=>{const s=e;for(const o of Ee){const n=r.indexOf(o);if(n!==-1&&o!==s)return s==="overrides"?n:n+1}let i=-1;for(const o of Ce){const n=r.indexOf(o);n>i&&(i=n)}if(i!==-1)return i+1;for(const o of $e){const n=r.indexOf(o);if(n!==-1)return n}return r.length},Ae=(r,e)=>{const s=C(r,"pnpm-workspace.yaml");if(!V(s))throw new Error(`pnpm-workspace.yaml not found at ${s}. Cannot write overrides for pnpm v10+.`);let i=P(s);const n=`overrides:
2
2
  ${Object.entries(e).map(([p,d])=>` '${p}': '${d}'`).join(`
3
3
  `)}
4
4
  `;i=/^overrides:\s*$/m.test(i)||/^overrides:\s*\n/m.test(i)?i.replace(/^overrides:\s*\n(?:(?:[ \t].*)?\n)*/m,n):`${i.trimEnd()}