@visulima/vis 7.1.0-next.6 → 7.1.0-next.7

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 (158) hide show
  1. package/CHANGELOG.md +59 -0
  2. package/README.md +1 -1
  3. package/dist/bin.js +1 -1
  4. package/dist/binx.js +1 -1
  5. package/dist/config/index.d.ts +227 -12
  6. package/dist/packem_chunks/CONFIG_FILES.js +1 -1
  7. package/dist/packem_chunks/bloom-sync.js +1 -1
  8. package/dist/packem_chunks/catalog.js +1 -1
  9. package/dist/packem_chunks/cli-exec.js +1 -1
  10. package/dist/packem_chunks/cli-main.js +57 -57
  11. package/dist/packem_chunks/detect.js +4 -4
  12. package/dist/packem_chunks/dispatch.js +1 -1
  13. package/dist/packem_chunks/fix.js +1 -1
  14. package/dist/packem_chunks/handler.js +1 -1
  15. package/dist/packem_chunks/handler10.js +1 -1
  16. package/dist/packem_chunks/handler11.js +1 -1
  17. package/dist/packem_chunks/handler12.js +1 -1
  18. package/dist/packem_chunks/handler13.js +1 -1
  19. package/dist/packem_chunks/handler14.js +1 -1
  20. package/dist/packem_chunks/handler15.js +1 -1
  21. package/dist/packem_chunks/handler16.js +1 -1
  22. package/dist/packem_chunks/handler17.js +1 -1
  23. package/dist/packem_chunks/handler18.js +1 -1
  24. package/dist/packem_chunks/handler19.js +1 -1
  25. package/dist/packem_chunks/handler2.js +1 -1
  26. package/dist/packem_chunks/handler20.js +1 -1
  27. package/dist/packem_chunks/handler21.js +1 -1
  28. package/dist/packem_chunks/handler22.js +1 -1
  29. package/dist/packem_chunks/handler23.js +1 -1
  30. package/dist/packem_chunks/handler24.js +1 -1
  31. package/dist/packem_chunks/handler25.js +1 -1
  32. package/dist/packem_chunks/handler26.js +1 -1
  33. package/dist/packem_chunks/handler27.js +1 -1
  34. package/dist/packem_chunks/handler28.js +1 -1
  35. package/dist/packem_chunks/handler29.js +1 -1
  36. package/dist/packem_chunks/handler3.js +2 -2
  37. package/dist/packem_chunks/handler30.js +1 -1
  38. package/dist/packem_chunks/handler4.js +1 -1
  39. package/dist/packem_chunks/handler5.js +1 -1
  40. package/dist/packem_chunks/handler50.js +1 -1
  41. package/dist/packem_chunks/handler51.js +1 -1
  42. package/dist/packem_chunks/handler52.js +1 -1
  43. package/dist/packem_chunks/handler53.js +1 -1
  44. package/dist/packem_chunks/handler54.js +1 -1
  45. package/dist/packem_chunks/handler55.js +1 -1
  46. package/dist/packem_chunks/handler58.js +1 -1
  47. package/dist/packem_chunks/handler59.js +1 -1
  48. package/dist/packem_chunks/handler6.js +1 -1
  49. package/dist/packem_chunks/handler60.js +1 -1
  50. package/dist/packem_chunks/handler61.js +22 -3
  51. package/dist/packem_chunks/handler62.js +2 -22
  52. package/dist/packem_chunks/handler63.js +6 -2
  53. package/dist/packem_chunks/handler64.js +8 -61
  54. package/dist/packem_chunks/handler65.js +2 -6
  55. package/dist/packem_chunks/handler66.js +12 -8
  56. package/dist/packem_chunks/handler67.js +5 -2
  57. package/dist/packem_chunks/handler68.js +25 -12
  58. package/dist/packem_chunks/handler69.js +50 -25
  59. package/dist/packem_chunks/handler7.js +1 -1
  60. package/dist/packem_chunks/handler70.js +153 -50
  61. package/dist/packem_chunks/handler71.js +1 -1
  62. package/dist/packem_chunks/handler72.js +1 -1
  63. package/dist/packem_chunks/handler73.js +1 -1
  64. package/dist/packem_chunks/handler74.js +1 -1
  65. package/dist/packem_chunks/handler75.js +1 -1
  66. package/dist/packem_chunks/handler76.js +1 -1
  67. package/dist/packem_chunks/handler77.js +1 -1
  68. package/dist/packem_chunks/handler78.js +1 -1
  69. package/dist/packem_chunks/handler79.js +64 -64
  70. package/dist/packem_chunks/handler8.js +1 -1
  71. package/dist/packem_chunks/handler9.js +1 -1
  72. package/dist/packem_chunks/heal-accept.js +1 -1
  73. package/dist/packem_chunks/heal.js +1 -1
  74. package/dist/packem_chunks/help-command.js +1 -1
  75. package/dist/packem_chunks/index7.js +1 -1
  76. package/dist/packem_chunks/keys-refresh.js +1 -1
  77. package/dist/packem_chunks/lean.js +1 -1
  78. package/dist/packem_chunks/list.js +1 -1
  79. package/dist/packem_chunks/loader.js +1 -1
  80. package/dist/packem_chunks/prune.js +1 -1
  81. package/dist/packem_chunks/status.js +1 -1
  82. package/dist/packem_chunks/sync.js +1 -1
  83. package/dist/packem_chunks/sync2.js +1 -1
  84. package/dist/packem_chunks/tripwire.js +1 -1
  85. package/dist/packem_chunks/ts-loader.js +2 -2
  86. package/dist/packem_chunks/verify-lockfile.js +1 -1
  87. package/dist/packem_chunks/workflow-templates.js +29 -32
  88. package/dist/packem_shared/{advisories-BnFPhsl1.js → advisories-CyXUdibZ.js} +1 -1
  89. package/dist/packem_shared/{affected-selection-Bd03KJU3.js → affected-selection-CJnDzyIK.js} +1 -1
  90. package/dist/packem_shared/affected-shas-CJLirD2O.js +1 -0
  91. package/dist/packem_shared/{ai-analysis-GjV2rF4U.js → ai-analysis-DHlzow2O.js} +1 -1
  92. package/dist/packem_shared/{ai-cache-DFKUyj11.js → ai-cache-D-BSLcuJ.js} +1 -1
  93. package/dist/packem_shared/{ai-fix-DpBEXHZT.js → ai-fix-CyExJC_c.js} +1 -1
  94. package/dist/packem_shared/{augment-BSeqaai8.js → augment-Ub6PCwbh.js} +1 -1
  95. package/dist/packem_shared/{bin-D1zq7wxi.js → bin-BaReRSyo.js} +1 -1
  96. package/dist/packem_shared/{build-scripts-mKGcgTzp.js → build-scripts-BeJkep8z.js} +1 -1
  97. package/dist/packem_shared/ci-commands-4W9d2six.js +1 -0
  98. package/dist/packem_shared/{command-runtime-DG49t2MT.js → command-runtime-DdnpiUmN.js} +1 -1
  99. package/dist/packem_shared/{dependency-scan-BGKZYS_i.js → dependency-scan-CyByCwef.js} +1 -1
  100. package/dist/packem_shared/{detect-CaA92iu_.js → detect-xqoTANJb.js} +1 -1
  101. package/dist/packem_shared/{docker-Cs174Imq.js → docker-CJXAt5Au.js} +1 -1
  102. package/dist/packem_shared/{ecosystem-gate-DcpvfgEi.js → ecosystem-gate-DEnubRcS.js} +1 -1
  103. package/dist/packem_shared/{env-sb3SOT-b.js → env-NauRSSEC.js} +1 -1
  104. package/dist/packem_shared/{env-consistency-nSuzisQe.js → env-consistency-Cl1Rg65z.js} +1 -1
  105. package/dist/packem_shared/{failure-log-AtaeZOrx.js → failure-log-DwroazKs.js} +1 -1
  106. package/dist/packem_shared/glob-Cyk1H9ZL-BtN6Zzwg.js +1 -0
  107. package/dist/packem_shared/{index-CclzWrJ5.js → index-BCEhCrLl.js} +1 -1
  108. package/dist/packem_shared/{index-C_7lOmB0.js → index-OmE1O0Ys.js} +1 -1
  109. package/dist/packem_shared/{index-0dnGN3GP.js → index-zq6Ehql6.js} +1 -1
  110. package/dist/packem_shared/{isAccessibleSync-DYKTrrvc-CBsMZhj-.js → isAccessibleSync-DYKTrrvc-CKahNmLy.js} +1 -1
  111. package/dist/packem_shared/{lifecycle-BzenugED.js → lifecycle-Cn1mSP5f.js} +1 -1
  112. package/dist/packem_shared/{lockfile-DEWjBrlY.js → lockfile-Cx2Ny3um.js} +1 -1
  113. package/dist/packem_shared/{manifests-DPwVdkqB.js → manifests-BEGTH1ZG.js} +1 -1
  114. package/dist/packem_shared/{min-release-age-BH4JKSXA.js → min-release-age-DLAERxRt.js} +1 -1
  115. package/dist/packem_shared/{missing-package-json-ByjsDBbk.js → missing-package-json-w74qGfyh.js} +1 -1
  116. package/dist/packem_shared/{multi-eco-lockfiles-Bz9ViPBV.js → multi-eco-lockfiles-SATPXx6-.js} +1 -1
  117. package/dist/packem_shared/{native-config-sync-DI7_xs-Q.js → native-config-sync-DDFn6Zsf.js} +1 -1
  118. package/dist/packem_shared/{npmrc-CIvOb61L.js → npmrc-DONprxrc.js} +1 -1
  119. package/dist/packem_shared/{osv-DaMZpVWl.js → osv-dvIA_vX3.js} +1 -1
  120. package/dist/packem_shared/{package-version-VdULnxr1.js → package-version-BOK3IncQ.js} +2 -2
  121. package/dist/packem_shared/{packument-zeKEhTaX.js → packument-B678kHJO.js} +1 -1
  122. package/dist/packem_shared/{pm-runner-BXRi4ZM9.js → pm-runner-CYsiSHYa.js} +1 -1
  123. package/dist/packem_shared/{project-name-filter-BklluD5Y.js → project-name-filter-CBEoY08a.js} +1 -1
  124. package/dist/packem_shared/{provenance-CwyZDw8A.js → provenance-D4ioWGBq.js} +1 -1
  125. package/dist/packem_shared/reachable-DX8FPErP.js +1 -0
  126. package/dist/packem_shared/{registry-TXpTtpgS.js → registry-ClmannRw.js} +2 -2
  127. package/dist/packem_shared/{registry-keys-B4CNE38T.js → registry-keys-CF45rOur.js} +1 -1
  128. package/dist/packem_shared/{removeSync-g1D5kONg-jOsRSIIv.js → removeSync-g1D5kONg-DcG75b0G.js} +1 -1
  129. package/dist/packem_shared/{renderToString-DR0zDUjh-CdBv7J9a.js → renderToString-DR0zDUjh-CBDmAXxb.js} +1 -1
  130. package/dist/packem_shared/{resolve-explicit-Cg3eqSqr.js → resolve-explicit-C5-y-xEU.js} +1 -1
  131. package/dist/packem_shared/{resolve-runtime-D8rxuo3J.js → resolve-runtime-DBDozrmt.js} +1 -1
  132. package/dist/packem_shared/{run-file-D1mlOnd8.js → run-file-BKXvoVj2.js} +1 -1
  133. package/dist/packem_shared/{run-summary-utils-CZ2pIIOZ.js → run-summary-utils-75paIrLB.js} +1 -1
  134. package/dist/packem_shared/{runtime-check-By5NHR00.js → runtime-check-Yl8-Awkf.js} +1 -1
  135. package/dist/packem_shared/{s1ngularity-CXTWGOvX.js → s1ngularity-B2bqwE0C.js} +1 -1
  136. package/dist/packem_shared/{scaffold-files-CC1M9Gje.js → scaffold-files-UiCBBCT5.js} +1 -1
  137. package/dist/packem_shared/{scan-progress-BaCJp5nr.js → scan-progress-Dws7Gif1.js} +1 -1
  138. package/dist/packem_shared/{selectors-DdvjAetv.js → selectors-DZ4HDnlD.js} +1 -1
  139. package/dist/packem_shared/{signatures-Bm-ySKmD.js → signatures-DNqgsRp7.js} +1 -1
  140. package/dist/packem_shared/{spinner-D8Eugb6Y.js → spinner-BQ9mLz8X.js} +1 -1
  141. package/dist/packem_shared/{table-Dc3wOjzc.js → table-D1CpySxU.js} +1 -1
  142. package/dist/packem_shared/{tabs-Ch5hj2ow.js → tabs-BYtpIN5b.js} +1 -1
  143. package/dist/packem_shared/{target-options-rIthWS4M.js → target-options-CsevVc7U.js} +1 -1
  144. package/dist/packem_shared/{task-env-Cl4jNMCR.js → task-env-BftNOR00.js} +1 -1
  145. package/dist/packem_shared/{toolchain-DQIOCPht.js → toolchain-BvluBdrw.js} +1 -1
  146. package/dist/packem_shared/{typosquats-Dw02Q55Q.js → typosquats-XrArH9TO.js} +1 -1
  147. package/dist/packem_shared/{use-measured-height-wtekNTLa.js → use-measured-height-hHis1NaB.js} +1 -1
  148. package/dist/packem_shared/{verify-3WE9U_Bv.js → verify-Dic2G0nQ.js} +1 -1
  149. package/dist/packem_shared/{vis-update-app-it6zkxW1.js → vis-update-app-BNnbDZ--.js} +1 -1
  150. package/dist/packem_shared/{vis-user-error-6sSghaC9.js → vis-user-error-DhgW3DzD.js} +2 -2
  151. package/dist/packem_shared/{watch-C-9-PD2m.js → watch-BLHtUgfb.js} +1 -1
  152. package/dist/packem_shared/{watch-loop-q7f9ukDX.js → watch-loop-Dh4GHUVS.js} +7 -7
  153. package/dist/runtime/preload.js +1 -1
  154. package/index.js +54 -54
  155. package/package.json +11 -10
  156. package/schemas/vis-config.schema.json +1419 -80
  157. package/dist/packem_shared/affected-shas-CycHU3nr.js +0 -1
  158. package/dist/packem_shared/glob-Cyk1H9ZL-QtJl508G.js +0 -1
@@ -1,61 +1,8 @@
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-TXpTtpgS.js";import{n as J}from"../packem_shared/manifests-DPwVdkqB.js";import{U as E,V as K}from"./cli-main.js";import{l as q}from"../packem_shared/glob-Cyk1H9ZL-QtJl508G.js";import{U as R,h as M}from"../packem_shared/env-sb3SOT-b.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
- `),O={begin:"# BEGIN vis-codeowners",end:"# END vis-codeowners"},V=(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
- `)},X=(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
-
5
- `}${t}
6
- `},Z=["**/CODEOWNERS"],ee=["**/node_modules/**","**/dist/**","**/build/**","**/coverage/**","**/.git/**","**/.next/**","**/.nuxt/**"],te=e=>{const t=[];for(const n of e.split(/\r?\n/u)){const s=n.indexOf("#"),o=(s===-1?n:n.slice(0,s)).trim();if(o.length===0)continue;const i=o.split(/\s+/u);if(i.length<2)continue;const[c,...r]=i,a=r.filter(f=>f.length>0);!c||a.length===0||t.push({owners:a,path:c})}return t},ne=(e,t)=>{const n=t.replace(/^\.\/?/,"").replace(/\/$/,"");return e.startsWith("/")?n===""?e:`/${n}${e}`:n===""?`/${e}`:`/${n}/${e}`},oe=async(e,t,n)=>{const s=t&&t.length>0?[...t]:[...Z],o=[...ee];if(n){const r=n.replace(/^\.\/?/,"").replace(/^\/+/,"");r.length>0&&o.push(r)}const i=await q(s,{absolute:!0,cwd:e,ignore:o}),c=[];for(const r of i){let a;try{a=_(r)}catch{continue}const f=G(r),l=I(e,f);for(const p of te(a))c.push({owners:p.owners,path:ne(p.path,l)})}return c},re=/^(?:https?:\/\/)?(?:www\.)?github\.com\/([^/?#]+)/iu,se=e=>{if(!e)return;const t=e.match(re);if(!t?.[1])return;const n=t[1].trim();if(!(n===""||n.includes(" ")))return`@${n.replace(/^@/,"")}`},ce=(e,t)=>{const n=[];for(const[s,o]of Object.entries(e.projects)){if(o.owners&&o.owners.length>0)continue;const i=o.root??s,c=b(t,i,"package.json"),r=E(c);if(!r)continue;const a=J(r.maintainers);if(!a||a.length===0)continue;const f=[],l=new Set;for(const p of a){const y=se(p.url);y&&!l.has(y)&&(l.add(y),f.push(y))}f.length!==0&&n.push({owners:f,path:i===""||i==="."?"/":`/${i}/`,projectId:s})}return n},ie=["author","bugs","homepage","license","repository","engines"],v=e=>typeof e=="object"&&e!==null&&!Array.isArray(e),C=(e,t)=>{if(e===t)return!0;if(typeof e!=typeof t||e===null||t===null)return!1;if(Array.isArray(e)){if(!Array.isArray(t)||e.length!==t.length)return!1;for(const[n,s]of e.entries())if(!C(s,t[n]))return!1;return!0}if(typeof e=="object"&&typeof t=="object"){const n=Object.keys(e),s=Object.keys(t);if(n.length!==s.length)return!1;for(const o of n)if(!C(e[o],t[o]))return!1;return!0}return!1},P=e=>e===void 0?e:structuredClone(e),ae=(e,t,n)=>{if(e==="repository"&&v(t)&&v(n)){const s={};for(const[o,i]of Object.entries(t))o!=="directory"&&(s[o]=P(i));return typeof n.directory=="string"&&(s.directory=n.directory),s}return P(t)},de=(e,t,n)=>{const s=[];for(const o of n.fields){if(!Object.hasOwn(e,o))continue;const i=e[o],c=t[o],r=ae(o,i,c);C(r,c)||s.push({after:r,before:c,field:o,packageJsonPath:""})}return s},fe=(e,t)=>{for(const n of t)e[n.field]=n.after},L="Generated by `vis sync codeowners --write-guard`. Do not edit by hand.",le=e=>{const t=e.replace(/^\.?\/+/u,"").replace(/\/+$/u,"");return t===""||t==="."?"**":`${t}/**`},T=e=>{const t=new Set,n=[];for(const s of[...e].sort((o,i)=>o.name.localeCompare(i.name))){const o=le(s.root);t.has(o)||(t.add(o),n.push(o))}return n},ue=e=>{const t=T(e),n=t.map(o=>` - "${o}"`).join(`
7
- `),s=t.map(o=>` ${o}`).join(`
8
- `);return`# ${L}
9
- name: Write Guard
10
-
11
- on:
12
- pull_request:
13
- paths:
14
- ${n}
15
-
16
- permissions:
17
- contents: read
18
- pull-requests: read
19
-
20
- jobs:
21
- write-guard:
22
- runs-on: ubuntu-latest
23
- steps:
24
- - uses: actions/checkout@v4
25
- with:
26
- fetch-depth: 0
27
- - uses: geritol/write-guard@v1
28
- with:
29
- codeowners: CODEOWNERS
30
- paths: |
31
- ${s}
32
- `},pe=e=>{const n=T(e).map(s=>` - "${s}/*"`).join(`
33
- `);return`# ${L}
34
- #
35
- # SOFT GUARD ONLY — this job does NOT block a merge by itself.
36
- # It verifies the generated CODEOWNERS is in sync and flags that a
37
- # restricted path changed. GitLab CI cannot portably gate a merge on
38
- # code-owner *approval* from a job, so REAL ENFORCEMENT REQUIRES the
39
- # native GitLab setting:
40
- # Settings -> Repository -> Protected branches ->
41
- # "Require approval from Code Owners" (GitLab Premium / Ultimate)
42
- # https://docs.gitlab.com/ee/user/project/codeowners/
43
- # Without that setting enabled, this job is advisory only.
44
- write-guard:
45
- stage: test
46
- image: node:22-alpine
47
- rules:
48
- - if: '$CI_PIPELINE_SOURCE == "merge_request_event"'
49
- changes:
50
- ${n}
51
- script:
52
- - corepack enable
53
- - pnpm install --frozen-lockfile
54
- - pnpm vis sync codeowners --check
55
- - >-
56
- echo "SOFT GUARD: a restricted path changed. This job does NOT enforce
57
- code-owner approval. Enable 'Require approval from Code Owners' on the
58
- protected branch (GitLab Premium/Ultimate) for a real merge gate:
59
- https://docs.gitlab.com/ee/user/project/codeowners/"
60
- `},he=e=>e.length===0?[]:[{content:ue(e),path:".github/workflows/write-guard.yml"},{content:pe(e),path:".gitlab/write-guard.gitlab-ci.yml"}],W=new Set(["nested-codeowners","package-json-maintainers","project-json"]),A=(e,t,n)=>{const s=new Set,o=[];for(const i of e??[])for(const c of i.split(",")){const r=c.trim();if(r.length===0)continue;if(n&&!n(r))throw new Error(`Unknown codeowners source: "${r}". Known: ${[...W].join(", ")}.`);const a=r;s.has(a)||(s.add(a),o.push(a))}return o.length>0?o:[...t]},ge=e=>W.has(e),S=["codeowners","package-json-fields"],me=(e,t)=>t.some(n=>U(n,e)),we=async(e,t,n,s,o)=>{const i=Object.entries(s.projects).filter(([,r])=>r.restricted===!0).map(([r,a])=>({name:r,root:a.root??r})),c=he(i);if(c.length===0){t.info("No projects flagged `restricted: true` in project.json. Skipping Write Guard.");return}if(o){let r=!1;for(const a of c){const f=b(n,a.path);let l="";try{l=await e.readFile(f,"utf8")}catch(p){if(p.code!=="ENOENT")throw p}l.trim()!==a.content.trim()&&(t.error(`${a.path} is out of date. Run \`vis sync codeowners --write-guard\` to update it.`),r=!0)}r?process.exitCode=1:t.info(`Write Guard CI is up to date (${c.length} files, ${i.length} restricted projects).`);return}for(const r of c){const a=b(n,r.path);M(G(a)),R(a,r.content),t.info(`Wrote ${r.path}`)}t.info(`Write Guard CI scoped to ${i.length} restricted project${i.length===1?"":"s"}.`)},ye=async({fs:e,logger:t,options:n,visConfig:s,workspaceRoot:o})=>{const i=o,{workspace:c}=x(i,s),r=s?.codeowners;n.writeGuard&&await we(e,t,i,c,n.check);const a=A(n.from,r?.sources??["project-json"],ge),f=n.regenerationCommand??r?.regenerationCommand,l=n.preserveBlock||r?.preserveBlock===!0,p=r?.blockMarker??O,y=n.nestedIncludes??r?.nestedIncludes,g=n.out??"CODEOWNERS",w=[];if(a.includes("nested-codeowners")){const m=await oe(i,y,g);for(const j of m)w.push({...j,source:"nested"})}if(a.includes("package-json-maintainers")){const m=ce(c,i);for(const j of m)w.push({...j,source:"maintainers"})}const u=a.includes("project-json")?N(c,r,w):N({projects:{}},r,w);if(u.length===0){t.info("No `owners` entries found in any source. Nothing to sync.");return}const $=b(i,g);let d="";try{d=await e.readFile($,"utf8")}catch(m){if(m.code!=="ENOENT")throw m}const h={regenerationCommand:f},k=l?X(d,V(u,p,h),p):Q(u,h);if(n.check){if(d.trim()!==k.trim()){t.error(`${$} is out of date. Run \`vis sync codeowners\` to update it.`),process.exitCode=1;return}t.info(`${$} is up to date.`);return}R($,k),t.info(`Wrote ${u.length} entries to ${$}`)},ke=({logger:e,options:t,visConfig:n,workspaceRoot:s})=>{const o=s,i=n?.editorconfig??!0,c=E(b(o,"package.json"));if(!c){e.error("Could not read root package.json. Nothing to sync."),process.exitCode=1;return}const r=A(t.fields,ie),a=t.ignorePackageName??[],f=t.check,l=(t.format??"human").toLowerCase(),{quiet:p}=t,y=K(o).filter(d=>d!=="."),g=[];let w=0;for(const d of y){const h=b(o,d,"package.json"),k=E(h);if(!k)continue;const m=typeof k.name=="string"?k.name:void 0;if(m!==void 0&&a.length>0&&me(m,a))continue;w+=1;const j=de(c,k,{fields:r});j.length!==0&&g.push({filePath:h,packageJsonPath:I(o,h),packageName:m,pkg:k,pkgChanges:j})}if(!f)for(const d of g)fe(d.pkg,d.pkgChanges),F(d.filePath,d.pkg,{indent:B(d.filePath,{useEditorconfig:i}),overwrite:!0});const u=g.flatMap(d=>d.pkgChanges.map(h=>({after:h.after,before:h.before,field:h.field,packageJsonPath:d.packageJsonPath,packageName:d.packageName}))),$={changes:u,fields:r,kind:"package-json-fields",mode:f?"check":"write",totalChanges:u.length,totalPackages:w};if(l==="json")process.stdout.write(`${JSON.stringify($,null,4)}
61
- `);else if(u.length===0)e.info(`All ${w} package${w===1?"":"s"} in sync (fields: ${r.join(", ")}).`);else if(f){if(!p)for(const d of u)e.error(`${d.packageJsonPath}: ${d.field} drifts from root`);e.error(`Found ${u.length} field drift${u.length===1?"":"s"} across ${g.length} package${g.length===1?"":"s"}. Run \`vis sync package-json-fields\` to fix.`)}else{if(!p)for(const d of g)e.info(`${d.packageJsonPath}: synced ${d.pkgChanges.map(h=>h.field).join(", ")}`);e.info(`Synced ${u.length} field${u.length===1?"":"s"} across ${g.length} package${g.length===1?"":"s"}.`)}f&&u.length>0&&(process.exitCode=1)},ve=async e=>{const t=e.argument[0];if(!t)throw new Error(`Missing sync kind. Usage: vis sync <kind> (known kinds: ${S.join(", ")})`);if(!e.workspaceRoot)throw new Error("Could not determine workspace root. Run inside a monorepo.");if(t==="codeowners"){await ye(e);return}if(t==="package-json-fields"){ke(e);return}throw new Error(`Unknown sync kind: "${t}". Known kinds: ${S.join(", ")}.`)};export{ve as default};
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-zq6Ehql6.js";import{T 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,e as ge,f as P,g as pe,h as me,i as he,j as xe,k as we,l as ve,m as ye,n as ke}from"../packem_shared/watch-loop-Dh4GHUVS.js";import{A as d}from"../packem_shared/registry-ClmannRw.js";import{d as f,f as b,r as be,a as $e}from"../packem_shared/detect-xqoTANJb.js";import{R as Ae}from"./ts-loader.js";let ee;const te=e=>(ee??=Z(import.meta.url))(e),k=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,ne=e=>{if(typeof k<"u"&&k.versions&&k.versions.node){const[t,n]=k.versions.node.split(".").map(Number);if(t>22||t===22&&n>=3||t===20&&n>=16)return k.getBuiltinModule(e)}return te(e)},{createHash:h}=ne("node:crypto"),Ce={1:"warning",2:"error"},Fe={argsCheck:(e,t)=>V(e,t,!1),argsFix:(e,t)=>V(e,t,!0),bin:()=>["pnpm","exec","eslint"],cacheKey:(e,t)=>{const n=["eslint",e.declaredVersion??"unknown",e.configFile??"no-config",t.maxWarnings===void 0?"":`mw=${t.maxWarnings}`,t.quiet?"q":"",...t.extraArgs??[]];return h("sha256").update(n.join("|")).digest("hex").slice(0,16)},detect:(e,t)=>{const n=f(t,d.eslint.packageNames[0]),r=b(e,d.eslint.configFiles);if(!(!n&&!r))return{adapter:"eslint",configFile:r,declared:!!n,declaredVersion:n,root:e}},extensions:["cjs","cts","js","jsx","mjs","mts","ts","tsx","vue"],id:"eslint",kind:"lint",parse:(e,t)=>{if(!e.stdout.trim())return[];let n;try{n=JSON.parse(e.stdout)}catch{return[{adapter:"eslint",file:t.root,fixable:!1,message:`eslint output was not valid JSON (exit ${e.exitCode})`,severity:"error"}]}const r=[];for(const i of n)for(const s of i.messages)r.push({adapter:"eslint",column:s.column,endColumn:s.endColumn,endLine:s.endLine,file:i.filePath,fixable:!!s.fix,line:s.line,message:s.message,ruleId:s.ruleId??void 0,severity:s.fatal?"error":Ce[s.severity]??"warning"});return r}},V=(e,t,n)=>{const r=["--format","json","--no-error-on-unmatched-pattern"];return n&&r.push("--fix"),t.quiet&&r.push("--quiet"),typeof t.maxWarnings=="number"&&r.push("--max-warnings",String(t.maxWarnings)),t.extraArgs?.length&&r.push(...t.extraArgs),r.push(...e),r},Se=/^([^:]+):(\d+)(?::(\d+))?\s+([\w/-]+)\s+(.+)$/,je=e=>{const t=Se.exec(e);if(!t)return;const[,n,r,i,s,c]=t;return{column:i===void 0?void 0:Number(i),file:n,line:Number(r),message:c,ruleId:s}},_e=e=>e.startsWith("/")||/^[a-z]:[\\/]/i.test(e),Ne={argsCheck:(e,t)=>M(e,t,!1),argsFix:(e,t)=>M(e,t,!0),bin:()=>["pnpm","exec","markdownlint-cli2"],cacheKey:(e,t)=>{const n=["markdownlint",e.declaredVersion??"unknown",e.configFile??"no-config",t.maxWarnings===void 0?"":`mw=${t.maxWarnings}`,t.quiet?"q":"",...t.extraArgs??[]];return h("sha256").update(n.join("|")).digest("hex").slice(0,16)},detect:(e,t)=>{const n=d.markdownlint.packageNames.map(i=>f(t,i)).find(i=>i!==void 0),r=b(e,d.markdownlint.configFiles);if(!(!n&&!r))return{adapter:"markdownlint",configFile:r,declared:!!n,declaredVersion:n,root:e}},extensions:["markdown","md"],id:"markdownlint",kind:"lint",parse:(e,t)=>{const n=(e.stderr||e.stdout||"").trim();if(!n)return[];const r=[];for(const i of n.split(/\r?\n/)){const s=je(i.trim());s&&r.push({adapter:"markdownlint",column:s.column,file:_e(s.file)?s.file:`${t.root}/${s.file}`,fixable:!0,line:s.line,message:s.message,ruleId:s.ruleId,severity:"warning"})}return r}},M=(e,t,n)=>{const r=[];return n&&r.push("--fix"),t.extraArgs?.length&&r.push(...t.extraArgs),e.length===0?r.push("**/*.md"):r.push(...e),r},qe={advice:"info",error:"error",warning:"warning"},Ie={argsCheck:(e,t)=>L(e,t,!1),argsFix:(e,t)=>L(e,t,!0),bin:()=>["pnpm","exec","oxlint"],cacheKey:(e,t)=>{const n=["oxlint",e.declaredVersion??"unknown",e.configFile??"no-config",t.maxWarnings===void 0?"":`mw=${t.maxWarnings}`,t.quiet?"q":"",...t.extraArgs??[]];return h("sha256").update(n.join("|")).digest("hex").slice(0,16)},detect:(e,t)=>{const n=f(t,d.oxlint.packageNames[0]),r=b(e,d.oxlint.configFiles);if(!(!n&&!r))return{adapter:"oxlint",configFile:r,declared:!!n,declaredVersion:n,root:e}},extensions:["astro","cjs","cts","js","jsx","mjs","mts","svelte","ts","tsx","vue"],id:"oxlint",kind:"lint",parse:(e,t)=>{if(!e.stdout.trim())return[];let n;try{n=JSON.parse(e.stdout)}catch{return[{adapter:"oxlint",file:t.root,fixable:!1,message:`oxlint output was not valid JSON (exit ${e.exitCode})`,severity:"error"}]}const r=[];for(const i of n.diagnostics??[]){const s=i.labels?.[0]?.span;r.push({adapter:"oxlint",column:s?.column,file:i.filename??t.root,fixable:!1,line:s?.line,message:i.message??"",ruleId:i.code,severity:qe[i.severity??""]??"warning"})}return r}},L=(e,t,n)=>{const r=["--format","json"];return n&&r.push("--fix"),t.quiet&&r.push("--quiet"),typeof t.maxWarnings=="number"&&r.push(`--max-warnings=${String(t.maxWarnings)}`),t.extraArgs?.length&&r.push(...t.extraArgs),r.push(...e),r},We={error:"error",info:"info",style:"info",warning:"warning"},Re=e=>e.startsWith("/")||/^[a-z]:[\\/]/i.test(e),Te=(e,t)=>e?Re(e)?e:`${t}/${e}`:t,Ee={argsCheck:(e,t)=>B(e,t),argsFix:(e,t)=>B(e,t),bin:()=>["shellcheck"],cacheKey:(e,t)=>{const n=["shellcheck",e.declaredVersion??"unknown",e.configFile??"no-config",t.quiet?"q":"",...t.extraArgs??[]];return h("sha256").update(n.join("|")).digest("hex").slice(0,16)},detect:(e,t)=>{const n=f(t,d.shellcheck.packageNames[0]),r=b(e,d.shellcheck.configFiles);if(!(!n&&!r))return{adapter:"shellcheck",configFile:r,declared:!!n,declaredVersion:n,root:e}},extensions:["bash","ksh","sh"],id:"shellcheck",kind:"lint",parse:(e,t)=>{if(!e.stdout.trim())return[];let n;try{n=JSON.parse(e.stdout)}catch{return[{adapter:"shellcheck",file:t.root,fixable:!1,message:`shellcheck output was not valid JSON (exit ${e.exitCode})`,severity:"error"}]}const r=[];for(const i of n.comments??[])r.push({adapter:"shellcheck",column:i.column,endColumn:i.endColumn,endLine:i.endLine,file:Te(i.file,t.root),fixable:!!i.fix,line:i.line,message:i.message??"",ruleId:i.code===void 0?void 0:`SC${String(i.code)}`,severity:We[i.level??""]??"warning"});return r}},B=(e,t)=>{const n=["--format=json1"];return t.extraArgs?.length&&n.push(...t.extraArgs),n.push(...e),n},Oe={error:"error",warning:"warning"},Pe={argsCheck:(e,t)=>J(e,t,!1),argsFix:(e,t)=>J(e,t,!0),bin:()=>["pnpm","exec","stylelint"],cacheKey:(e,t)=>{const n=["stylelint",e.declaredVersion??"unknown",e.configFile??"no-config",t.maxWarnings===void 0?"":`mw=${t.maxWarnings}`,t.quiet?"q":"",...t.extraArgs??[]];return h("sha256").update(n.join("|")).digest("hex").slice(0,16)},detect:(e,t)=>{const n=f(t,d.stylelint.packageNames[0]),r=b(e,d.stylelint.configFiles);if(!(!n&&!r))return{adapter:"stylelint",configFile:r,declared:!!n,declaredVersion:n,root:e}},extensions:["astro","css","less","sass","scss","svelte","vue"],id:"stylelint",kind:"lint",parse:(e,t)=>{if(!e.stdout.trim())return[];let n;try{n=JSON.parse(e.stdout)}catch{return[{adapter:"stylelint",file:t.root,fixable:!1,message:`stylelint output was not valid JSON (exit ${e.exitCode})`,severity:"error"}]}const r=[];for(const i of n)for(const s of i.warnings??[])r.push({adapter:"stylelint",column:s.column,endColumn:s.endColumn,endLine:s.endLine,file:i.source,fixable:!1,line:s.line,message:s.text??"",ruleId:s.rule,severity:Oe[s.severity??""]??"warning"});return r}},J=(e,t,n)=>{const r=["--formatter","json"];return n&&r.push("--fix"),t.quiet&&r.push("--quiet"),typeof t.maxWarnings=="number"&&r.push("--max-warnings",String(t.maxWarnings)),t.extraArgs?.length&&r.push(...t.extraArgs),r.push(...e),r},G="@typescript/native-preview",Ve=2e3,Me=/^(.*)\((\d+),(\d+)\): (error|warning) (TS\d+): (.*)$/,Le=/^(error|warning) (TS\d+): (.*)$/,Y=e=>e.startsWith("/")||/^[a-z]:[\\/]/i.test(e),Be=(e,t)=>Y(e)?e:`${t}/${e}`,z=e=>{try{return Ae(e)}catch{return}},Je=e=>{const t=z(e);return Array.isArray(t?.config.references)&&t.config.references.length>0},Ke=e=>{const t=be(e);return!f(t,"typescript")&&f(t,G)?"tsgo":"tsc"},Ue={argsCheck:(e,t)=>K(t),argsFix:(e,t)=>K(t),bin:e=>{const t=["pnpm","exec",Ke(e.root)],n=e.configFile?S(e.root,e.configFile):"tsconfig.json";return e.configFile&&Je(e.root)?[...t,"-b","--pretty","false",n]:[...t,"-p",n,"--noEmit","--pretty","false"]},cacheKey:(e,t)=>{const n=["typecheck",e.declaredVersion??"unknown",e.configFile??"no-config",...t.extraArgs??[]];return h("sha256").update(n.join("|")).digest("hex").slice(0,16)},detect:(e,t)=>{const n=f(t,"typescript"),r=f(t,G),i=z(e),s=i?S(e,i.path):void 0;if(!(!n&&!r||!i||!s||s===".."||s.startsWith("../")||Y(s)))return{adapter:"typecheck",configFile:i.path,declared:!0,declaredVersion:n??r,root:e}},extensions:["cts","mts","ts","tsx"],id:"typecheck",kind:"lint",optIn:!0,parse:(e,t)=>{const n=[];for(const r of`${e.stdout}
2
+ ${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
+ ${r.trim()}`)}if(n.length===0&&e.exitCode!==0){const r=`${e.stdout}
4
+ ${e.stderr}`.trim().slice(0,Ve);n.push({adapter:"typecheck",file:t.root,fixable:!1,message:e.exitCode===null?`type-check did not complete (killed or timed out)${r?`:
5
+ ${r}`:""}`:`type-check failed (exit ${String(e.exitCode)}) with unrecognised output:
6
+ ${r}`,severity:"error"})}return n},scope:"project"},K=e=>e.extraArgs?.length?[...e.extraArgs]:[],De=[Ie,fe,Fe,Pe,ge,Ne,Ee,Ue],at=async({logger:e,options:t,visConfig:n,workspaceRoot:r})=>{const i=r??process.cwd(),s=n?.lint;ae(e,"lint",s);const c=oe(De,s?.order),$=$e(i,c),x=ce($,c,"lint").filter(({adapter:o})=>{const l=s?.adapters?.[o.id]?.enabled;return o.optIn?l===!0:l!==!1});for(const o of c)o.optIn&&s?.adapters?.[o.id]?.enabled===!0&&!$.has(o.id)&&e.warn(`vis lint: adapters.${o.id}.enabled is set, but ${o.id} was not detected (needs a tsconfig.json and a typescript dependency at the workspace root). Skipping it.`);if(x.length===0){e.warn("vis lint: no linter detected in this workspace (looked for: oxlint, biome, eslint, stylelint, ruff, markdownlint, shellcheck; typecheck runs only when enabled).");return}const j=o=>{const l=s?.adapters?.[o]?.extraArgs;return l&&l.length>0?[...l]:void 0},A={extraArgs:void 0,maxWarnings:typeof t.maxWarnings=="number"?t.maxWarnings:void 0,quiet:t.quiet??!1},W=Ge(t),H=t.fix?"fix":"check";let g;if(t.staged){if(g=le(i),g===void 0)e.warn("vis lint: could not resolve --staged (not a git repo or git unavailable). Falling back to a workspace-wide run.");else if(g.length===0){e.info(I("✓ lint: no staged files"));return}}else if(typeof t.since=="string"&&t.since.length>0){if(g=de(i,t.since),g===void 0)e.warn(`vis lint: could not resolve --since ${t.since} (not a git repo or unknown ref). Falling back to a workspace-wide run.`);else if(g.length===0){e.info(I(`✓ lint: no files changed since ${t.since}`));return}}const _=W.length>0?W:void 0,X=se(i,void 0,void 0,!0),N=t.format??"human";N==="human"&&t.output!==void 0&&e.warn("vis lint: --output is ignored for the human format; pass --format json|minimal|sarif|junit|github to redirect findings to a file.");const R=async o=>{const l=o!==void 0&&o.length>0&&_===void 0,w=[];for(const{adapter:a,presence:y}of x){let u;if(a.scope==="project"){const q=_??o;if(q&&q.length>0&&P(q,a.extensions).length===0)continue;u=["."]}else if(l){if(u=P(o,a.extensions),u.length===0)continue}else u=_??o??["."];const F=j(a.id),E={adapter:a,files:u,presence:y};F&&(E.options={...A,extraArgs:F}),w.push(E)}if(w.length===0)return;const Q=await pe(w,A,H,{cacheRoot:X}),C=w.map((a,y)=>{const u=Q[y],F=a.adapter.parse(u,a.presence);return{adapter:a.adapter,durationMs:u.durationMs,exitCode:u.exitCode,findings:F}}),v=me(C.map(a=>({adapter:a.adapter.id,durationMs:a.durationMs,exitCode:a.exitCode,findingCount:a.findings.length,findings:a.findings}))),m=N==="human"?void 0:he({cwd:i,target:t.output});try{switch(N){case"github":{m.write(ve({runs:C.map(a=>({findings:a.findings})),workspaceRoot:i}));break}case"json":{m.write(`${JSON.stringify({findings:v.findings,runs:v.runs},null,2)}
7
+ `);break}case"junit":{m.write(we({runs:C.map(a=>({adapter:a.adapter.id,durationMs:a.durationMs,findings:a.findings})),workspaceRoot:i}));break}case"minimal":{ze(v.findings,i,m);break}case"sarif":{m.write(xe({runs:C.map(a=>({adapter:a.adapter.id,findings:a.findings,presence:w.find(y=>y.adapter.id===a.adapter.id)?.presence})),workspaceRoot:i}));break}default:Ye(v.findings,i,e)}}finally{m?.close()}const T=ke(v);T!==0&&(process.exitCode=T)};if(t.watch){const o=[...new Set(x.flatMap(({adapter:l})=>l.extensions))];await ue({extensions:o,initialFiles:g,label:"lint",log:l=>{e.info(l)},runCycle:R,workspaceRoot:i});return}await R(g)},Ge=e=>{const t=e;return[...t._??t.args??[]]},Ye=(e,t,n)=>{if(e.length===0){n.info(I("✓ lint: no findings"));return}const r=ye(e);for(const[c,$]of r){n.info(re(S(t,c)));for(const p of $){const x=He(p),j=Xe(p.severity),A=p.ruleId?O(` ${p.ruleId}`):"";n.info(` ${O(x)} ${j} ${p.message}${A}`)}}const i=e.filter(c=>c.severity==="error").length,s=e.filter(c=>c.severity==="warning").length;n.info(""),n.info(`${U(`${String(i)} error${i===1?"":"s"}`)}, ${D(`${String(s)} warning${s===1?"":"s"}`)}`)},ze=(e,t,n)=>{for(const r of e){const i=S(t,r.file),s=r.line??"",c=r.column??"";n.write(`${r.adapter} ${i} ${String(s)} ${String(c)} ${r.severity} ${r.ruleId??""} ${r.message}
8
+ `)}},He=e=>e.line===void 0?"":e.column===void 0?String(e.line):`${String(e.line)}:${String(e.column)}`,Xe=e=>e==="error"?U("error"):e==="warning"?D("warn "):ie("info ");export{at as default};
@@ -1,6 +1,2 @@
1
- import{a as B,z as J,e as I,$ as q,U as K}from"../packem_shared/index-0dnGN3GP.js";import{M as Y,N as z,P as V,L 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-TXpTtpgS.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=K(n);!r.has(i)&&L(i)&&(r.add(i),s.push(i))};c(I(e,"package.json"));const o=ce(e);if(o){const n=A(e,o);for(const i of n)c(I(e,i,"package.json"))}else{const n=I(e,"package.json");if(L(n)){const i=JSON.parse(J(n)),d=Array.isArray(i.workspaces)?i.workspaces:i.workspaces?.packages;if(d){const f=A(e,d);for(const x of f)c(I(e,x,"package.json"))}}}return s},Le=e=>/\n([ \t]+)/.exec(e)?.[1]??" ",_e=e=>{if(!(e===void 0||e===""))return e==="tab"||e===String.raw`\t`?" ":/^\d+$/.test(e)?" ".repeat(Number.parseInt(e,10)):e},P=e=>e===void 0?[]:(Array.isArray(e)?e:[e]).flatMap(s=>s.split(",")).map(s=>s.trim()).filter(s=>s.length>0),De=e=>e.includes(`\r
2
- `)?"crlf":"lf",Me=new Set(["auto","crlf","lf"]),Fe=e=>{if(e===void 0||e==="")return"auto";if(Me.has(e))return e;throw new Error(`--line-ending must be one of: auto, lf, crlf (got "${e}")`)},Ge=(e,r,s)=>r.length===0?e:e.filter(c=>{const o=B(s,c),n=q(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
- `);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
- `),o==="crlf"&&(x=x.replaceAll(`
5
- `,`\r
6
- `)),x},Xe=(e,r)=>{const s=Ae(e),c=se(e),o=ne({cwd:e,extraPatterns:oe(c)}),n=s.filter(d=>!o.ignores(d)),i=Ge(n,r,e);return{afterGitignore:n,allFiles:s,files:i}},He=async(e,{checkMode:r,cwd:s,fs:c,normalized:o})=>{const n=B(s,e)||e;let i;try{i=J(e)}catch(h){return{diff:[],error:{message:C(h),step:"read"},filePath:e,relativePath:n,status:"error"}}let d;try{d=U(i,{pretty:!1,sortScripts:o.sortScripts})}catch(h){const j={message:C(h),step:"native-sort"},p=v(h,i);return p&&(j.context=p),{diff:[],error:j,filePath:e,relativePath:n,status:"error"}}const f=o.editorconfig?ie(e):{};let x;try{x=We(i,o,f)}catch(h){const j={message:C(h),step:"json-parse"},p=v(h,i);return p&&(j.context=p),{diff:[],error:j,filePath:e,relativePath:n,status:"error"}}if(i===x)return{diff:[],filePath:e,relativePath:n,status:"unchanged"};let m;try{m=Ue(i,d)}catch{m=[]}if(r)return{diff:m,filePath:e,relativePath:n,status:"would-rewrite"};try{await c.writeFile(e,x,"utf8")}catch(h){return{diff:m,error:{message:C(h),step:"write"},filePath:e,relativePath:n,status:"error"}}return{diff:m,filePath:e,relativePath:n,status:"rewritten"}},qe=e=>{if(e.error&&(E.error(`${e.filePath}: ${e.error.message}`),E.info(` step: ${e.error.step}`),e.error.context)){E.info(` at line ${String(e.error.context.line)}, column ${String(e.error.context.column)}`);for(const r of e.error.context.snippet){const s=r.isErrorLine?">":" ";E.info(` ${s} ${String(r.lineNumber).padStart(4)} | ${r.content}`)}}},tr=async({fs:e,options:r,visConfig:s,workspaceRoot:c})=>{const o=c??process.cwd(),n=s?.sortPackageJson,i=r.check||!1,f={editorconfig:r.editorconfig?n?.editorconfig??!0:!1,finalNewline:r.finalNewline??n?.finalNewline??!0,formatBugs:r.formatBugs?n?.formatBugs??!0:!1,formatRepository:r.formatRepository?n?.formatRepository??!0:!1,ignore:[...P(r.ignore),...n?.ignore??[]],indent:_e(r.indent??n?.indent),lineEnding:Fe(r.lineEnding??n?.lineEnding),sortExports:r.sortExports?n?.sortExports??!0:!1,sortOrder:[...P(r.sortOrder),...n?.sortOrder??[]],sortScripts:r.sortScripts||n?.sortScripts||!1,unsorted:[...P(r.unsorted),...n?.unsorted??[]]},x=Xe(o,f.ignore),{afterGitignore:m,allFiles:h,files:j}=x;if(j.length===0){h.length===0?E.info("No package.json files found."):m.length===0?E.info("All package.json files were excluded by .gitignore or workspace exclusions."):E.info("All package.json files were excluded by --ignore.");return}const p=[];for(const l of j)p.push(await He(l,{checkMode:i,cwd:o,fs:e,normalized:f}));let y=0,S=0,w=0;for(const l of p)l.status==="error"?w++:l.status==="rewritten"||l.status==="would-rewrite"?y++:S++;const b=y>0||w>0;if(!!process.stdout.isTTY&&!re&&b){const l=new ue(p);await ee(te.createElement(Ee,{checkMode:i,store:l}),{alternateScreen:!0,exitOnCtrlC:!1,interactive:!0,patchConsole:!0}).waitUntilExit()}else for(const l of p)switch(l.status){case"error":{qe(l);break}case"rewritten":{E.success(`Sorted ${l.filePath}`);break}case"would-rewrite":{E.warn(`${l.filePath} is not sorted`);break}}if(i)y>0?(E.info(`${String(y)} file${y===1?"":"s"} not sorted, ${String(S)} already sorted`),process.exitCode=1):w===0&&E.info(`All ${String(S)} package.json file${S===1?" is":"s are"} sorted`);else{const l=[];y>0&&l.push(`sorted ${String(y)} file${y===1?"":"s"}`),S>0&&l.push(`${String(S)} already sorted`),w>0&&l.push(`${String(w)} error${w===1?"":"s"}`),l.length>0&&E.info(l.join(", "))}w>0&&(process.exitCode=1)};export{G as buildSnippet,Ue as computeKeyDiff,Je as computeLineColumn,tr as default,Xe as discoverPackageJsonFiles,v as extractParseErrorContext,He as processFile};
1
+ 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-zq6Ehql6.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-NauRSSEC.js";import{y as se}from"../packem_shared/isAccessibleSync-DYKTrrvc-CKahNmLy.js";import{p as re}from"../packem_shared/package-version-BOK3IncQ.js";import{g as oe,r as ne}from"../packem_shared/packument-B678kHJO.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-CYsiSHYa.js";import{r as ue,a as pe}from"../packem_shared/command-runtime-DdnpiUmN.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
+ `);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,8 +1,12 @@
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{T 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-q7f9ukDX.js";import{v as d}from"../packem_shared/registry-TXpTtpgS.js";import{d as f,f as b,r as be,a as $e}from"../packem_shared/detect-CaA92iu_.js";import{R as Ae}from"./ts-loader.js";let ee;const te=e=>(ee??=Z(import.meta.url))(e),k=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,ne=e=>{if(typeof k<"u"&&k.versions&&k.versions.node){const[t,n]=k.versions.node.split(".").map(Number);if(t>22||t===22&&n>=3||t===20&&n>=16)return k.getBuiltinModule(e)}return te(e)},{createHash:h}=ne("node:crypto"),Ce={1:"warning",2:"error"},Fe={argsCheck:(e,t)=>V(e,t,!1),argsFix:(e,t)=>V(e,t,!0),bin:()=>["pnpm","exec","eslint"],cacheKey:(e,t)=>{const n=["eslint",e.declaredVersion??"unknown",e.configFile??"no-config",t.maxWarnings===void 0?"":`mw=${t.maxWarnings}`,t.quiet?"q":"",...t.extraArgs??[]];return h("sha256").update(n.join("|")).digest("hex").slice(0,16)},detect:(e,t)=>{const n=f(t,d.eslint.packageNames[0]),r=b(e,d.eslint.configFiles);if(!(!n&&!r))return{adapter:"eslint",configFile:r,declared:!!n,declaredVersion:n,root:e}},extensions:["cjs","cts","js","jsx","mjs","mts","ts","tsx","vue"],id:"eslint",kind:"lint",parse:(e,t)=>{if(!e.stdout.trim())return[];let n;try{n=JSON.parse(e.stdout)}catch{return[{adapter:"eslint",file:t.root,fixable:!1,message:`eslint output was not valid JSON (exit ${e.exitCode})`,severity:"error"}]}const r=[];for(const i of n)for(const s of i.messages)r.push({adapter:"eslint",column:s.column,endColumn:s.endColumn,endLine:s.endLine,file:i.filePath,fixable:!!s.fix,line:s.line,message:s.message,ruleId:s.ruleId??void 0,severity:s.fatal?"error":Ce[s.severity]??"warning"});return r}},V=(e,t,n)=>{const r=["--format","json","--no-error-on-unmatched-pattern"];return n&&r.push("--fix"),t.quiet&&r.push("--quiet"),typeof t.maxWarnings=="number"&&r.push("--max-warnings",String(t.maxWarnings)),t.extraArgs?.length&&r.push(...t.extraArgs),r.push(...e),r},Se=/^([^:]+):(\d+)(?::(\d+))?\s+([\w/-]+)\s+(.+)$/,je=e=>{const t=Se.exec(e);if(!t)return;const[,n,r,i,s,c]=t;return{column:i===void 0?void 0:Number(i),file:n,line:Number(r),message:c,ruleId:s}},_e=e=>e.startsWith("/")||/^[a-z]:[\\/]/i.test(e),Ne={argsCheck:(e,t)=>M(e,t,!1),argsFix:(e,t)=>M(e,t,!0),bin:()=>["pnpm","exec","markdownlint-cli2"],cacheKey:(e,t)=>{const n=["markdownlint",e.declaredVersion??"unknown",e.configFile??"no-config",t.maxWarnings===void 0?"":`mw=${t.maxWarnings}`,t.quiet?"q":"",...t.extraArgs??[]];return h("sha256").update(n.join("|")).digest("hex").slice(0,16)},detect:(e,t)=>{const n=d.markdownlint.packageNames.map(i=>f(t,i)).find(i=>i!==void 0),r=b(e,d.markdownlint.configFiles);if(!(!n&&!r))return{adapter:"markdownlint",configFile:r,declared:!!n,declaredVersion:n,root:e}},extensions:["markdown","md"],id:"markdownlint",kind:"lint",parse:(e,t)=>{const n=(e.stderr||e.stdout||"").trim();if(!n)return[];const r=[];for(const i of n.split(/\r?\n/)){const s=je(i.trim());s&&r.push({adapter:"markdownlint",column:s.column,file:_e(s.file)?s.file:`${t.root}/${s.file}`,fixable:!0,line:s.line,message:s.message,ruleId:s.ruleId,severity:"warning"})}return r}},M=(e,t,n)=>{const r=[];return n&&r.push("--fix"),t.extraArgs?.length&&r.push(...t.extraArgs),e.length===0?r.push("**/*.md"):r.push(...e),r},qe={advice:"info",error:"error",warning:"warning"},Ie={argsCheck:(e,t)=>L(e,t,!1),argsFix:(e,t)=>L(e,t,!0),bin:()=>["pnpm","exec","oxlint"],cacheKey:(e,t)=>{const n=["oxlint",e.declaredVersion??"unknown",e.configFile??"no-config",t.maxWarnings===void 0?"":`mw=${t.maxWarnings}`,t.quiet?"q":"",...t.extraArgs??[]];return h("sha256").update(n.join("|")).digest("hex").slice(0,16)},detect:(e,t)=>{const n=f(t,d.oxlint.packageNames[0]),r=b(e,d.oxlint.configFiles);if(!(!n&&!r))return{adapter:"oxlint",configFile:r,declared:!!n,declaredVersion:n,root:e}},extensions:["astro","cjs","cts","js","jsx","mjs","mts","svelte","ts","tsx","vue"],id:"oxlint",kind:"lint",parse:(e,t)=>{if(!e.stdout.trim())return[];let n;try{n=JSON.parse(e.stdout)}catch{return[{adapter:"oxlint",file:t.root,fixable:!1,message:`oxlint output was not valid JSON (exit ${e.exitCode})`,severity:"error"}]}const r=[];for(const i of n.diagnostics??[]){const s=i.labels?.[0]?.span;r.push({adapter:"oxlint",column:s?.column,file:i.filename??t.root,fixable:!1,line:s?.line,message:i.message??"",ruleId:i.code,severity:qe[i.severity??""]??"warning"})}return r}},L=(e,t,n)=>{const r=["--format","json"];return n&&r.push("--fix"),t.quiet&&r.push("--quiet"),typeof t.maxWarnings=="number"&&r.push(`--max-warnings=${String(t.maxWarnings)}`),t.extraArgs?.length&&r.push(...t.extraArgs),r.push(...e),r},We={error:"error",info:"info",style:"info",warning:"warning"},Re=e=>e.startsWith("/")||/^[a-z]:[\\/]/i.test(e),Te=(e,t)=>e?Re(e)?e:`${t}/${e}`:t,Ee={argsCheck:(e,t)=>B(e,t),argsFix:(e,t)=>B(e,t),bin:()=>["shellcheck"],cacheKey:(e,t)=>{const n=["shellcheck",e.declaredVersion??"unknown",e.configFile??"no-config",t.quiet?"q":"",...t.extraArgs??[]];return h("sha256").update(n.join("|")).digest("hex").slice(0,16)},detect:(e,t)=>{const n=f(t,d.shellcheck.packageNames[0]),r=b(e,d.shellcheck.configFiles);if(!(!n&&!r))return{adapter:"shellcheck",configFile:r,declared:!!n,declaredVersion:n,root:e}},extensions:["bash","ksh","sh"],id:"shellcheck",kind:"lint",parse:(e,t)=>{if(!e.stdout.trim())return[];let n;try{n=JSON.parse(e.stdout)}catch{return[{adapter:"shellcheck",file:t.root,fixable:!1,message:`shellcheck output was not valid JSON (exit ${e.exitCode})`,severity:"error"}]}const r=[];for(const i of n.comments??[])r.push({adapter:"shellcheck",column:i.column,endColumn:i.endColumn,endLine:i.endLine,file:Te(i.file,t.root),fixable:!!i.fix,line:i.line,message:i.message??"",ruleId:i.code===void 0?void 0:`SC${String(i.code)}`,severity:We[i.level??""]??"warning"});return r}},B=(e,t)=>{const n=["--format=json1"];return t.extraArgs?.length&&n.push(...t.extraArgs),n.push(...e),n},Oe={error:"error",warning:"warning"},Pe={argsCheck:(e,t)=>J(e,t,!1),argsFix:(e,t)=>J(e,t,!0),bin:()=>["pnpm","exec","stylelint"],cacheKey:(e,t)=>{const n=["stylelint",e.declaredVersion??"unknown",e.configFile??"no-config",t.maxWarnings===void 0?"":`mw=${t.maxWarnings}`,t.quiet?"q":"",...t.extraArgs??[]];return h("sha256").update(n.join("|")).digest("hex").slice(0,16)},detect:(e,t)=>{const n=f(t,d.stylelint.packageNames[0]),r=b(e,d.stylelint.configFiles);if(!(!n&&!r))return{adapter:"stylelint",configFile:r,declared:!!n,declaredVersion:n,root:e}},extensions:["astro","css","less","sass","scss","svelte","vue"],id:"stylelint",kind:"lint",parse:(e,t)=>{if(!e.stdout.trim())return[];let n;try{n=JSON.parse(e.stdout)}catch{return[{adapter:"stylelint",file:t.root,fixable:!1,message:`stylelint output was not valid JSON (exit ${e.exitCode})`,severity:"error"}]}const r=[];for(const i of n)for(const s of i.warnings??[])r.push({adapter:"stylelint",column:s.column,endColumn:s.endColumn,endLine:s.endLine,file:i.source,fixable:!1,line:s.line,message:s.text??"",ruleId:s.rule,severity:Oe[s.severity??""]??"warning"});return r}},J=(e,t,n)=>{const r=["--formatter","json"];return n&&r.push("--fix"),t.quiet&&r.push("--quiet"),typeof t.maxWarnings=="number"&&r.push("--max-warnings",String(t.maxWarnings)),t.extraArgs?.length&&r.push(...t.extraArgs),r.push(...e),r},G="@typescript/native-preview",Ve=2e3,Me=/^(.*)\((\d+),(\d+)\): (error|warning) (TS\d+): (.*)$/,Le=/^(error|warning) (TS\d+): (.*)$/,Y=e=>e.startsWith("/")||/^[a-z]:[\\/]/i.test(e),Be=(e,t)=>Y(e)?e:`${t}/${e}`,z=e=>{try{return Ae(e)}catch{return}},Je=e=>{const t=z(e);return Array.isArray(t?.config.references)&&t.config.references.length>0},Ke=e=>{const t=be(e);return!f(t,"typescript")&&f(t,G)?"tsgo":"tsc"},Ue={argsCheck:(e,t)=>K(t),argsFix:(e,t)=>K(t),bin:e=>{const t=["pnpm","exec",Ke(e.root)],n=e.configFile?S(e.root,e.configFile):"tsconfig.json";return e.configFile&&Je(e.root)?[...t,"-b","--pretty","false",n]:[...t,"-p",n,"--noEmit","--pretty","false"]},cacheKey:(e,t)=>{const n=["typecheck",e.declaredVersion??"unknown",e.configFile??"no-config",...t.extraArgs??[]];return h("sha256").update(n.join("|")).digest("hex").slice(0,16)},detect:(e,t)=>{const n=f(t,"typescript"),r=f(t,G),i=z(e),s=i?S(e,i.path):void 0;if(!(!n&&!r||!i||!s||s===".."||s.startsWith("../")||Y(s)))return{adapter:"typecheck",configFile:i.path,declared:!0,declaredVersion:n??r,root:e}},extensions:["cts","mts","ts","tsx"],id:"typecheck",kind:"lint",optIn:!0,parse:(e,t)=>{const n=[];for(const r of`${e.stdout}
2
- ${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
- ${r.trim()}`)}if(n.length===0&&e.exitCode!==0){const r=`${e.stdout}
4
- ${e.stderr}`.trim().slice(0,Ve);n.push({adapter:"typecheck",file:t.root,fixable:!1,message:e.exitCode===null?`type-check did not complete (killed or timed out)${r?`:
5
- ${r}`:""}`:`type-check failed (exit ${String(e.exitCode)}) with unrecognised output:
6
- ${r}`,severity:"error"})}return n},scope:"project"},K=e=>e.extraArgs?.length?[...e.extraArgs]:[],De=[Ie,fe,Fe,Pe,ge,Ne,Ee,Ue],at=async({logger:e,options:t,visConfig:n,workspaceRoot:r})=>{const i=r??process.cwd(),s=n?.lint;ae(e,"lint",s);const c=oe(De,s?.order),$=$e(i,c),x=ce($,c,"lint").filter(({adapter:o})=>{const l=s?.adapters?.[o.id]?.enabled;return o.optIn?l===!0:l!==!1});for(const o of c)o.optIn&&s?.adapters?.[o.id]?.enabled===!0&&!$.has(o.id)&&e.warn(`vis lint: adapters.${o.id}.enabled is set, but ${o.id} was not detected (needs a tsconfig.json and a typescript dependency at the workspace root). Skipping it.`);if(x.length===0){e.warn("vis lint: no linter detected in this workspace (looked for: oxlint, biome, eslint, stylelint, ruff, markdownlint, shellcheck; typecheck runs only when enabled).");return}const j=o=>{const l=s?.adapters?.[o]?.extraArgs;return l&&l.length>0?[...l]:void 0},A={extraArgs:void 0,maxWarnings:typeof t.maxWarnings=="number"?t.maxWarnings:void 0,quiet:t.quiet??!1},W=Ge(t),H=t.fix?"fix":"check";let g;if(t.staged){if(g=le(i),g===void 0)e.warn("vis lint: could not resolve --staged (not a git repo or git unavailable). Falling back to a workspace-wide run.");else if(g.length===0){e.info(I("✓ lint: no staged files"));return}}else if(typeof t.since=="string"&&t.since.length>0){if(g=de(i,t.since),g===void 0)e.warn(`vis lint: could not resolve --since ${t.since} (not a git repo or unknown ref). Falling back to a workspace-wide run.`);else if(g.length===0){e.info(I(`✓ lint: no files changed since ${t.since}`));return}}const _=W.length>0?W:void 0,X=se(i,void 0,void 0,!0),N=t.format??"human";N==="human"&&t.output!==void 0&&e.warn("vis lint: --output is ignored for the human format; pass --format json|minimal|sarif|junit|github to redirect findings to a file.");const R=async o=>{const l=o!==void 0&&o.length>0&&_===void 0,w=[];for(const{adapter:a,presence:y}of x){let u;if(a.scope==="project"){const q=_??o;if(q&&q.length>0&&P(q,a.extensions).length===0)continue;u=["."]}else if(l){if(u=P(o,a.extensions),u.length===0)continue}else u=_??o??["."];const F=j(a.id),E={adapter:a,files:u,presence:y};F&&(E.options={...A,extraArgs:F}),w.push(E)}if(w.length===0)return;const Q=await pe(w,A,H,{cacheRoot:X}),C=w.map((a,y)=>{const u=Q[y],F=a.adapter.parse(u,a.presence);return{adapter:a.adapter,durationMs:u.durationMs,exitCode:u.exitCode,findings:F}}),v=me(C.map(a=>({adapter:a.adapter.id,durationMs:a.durationMs,exitCode:a.exitCode,findingCount:a.findings.length,findings:a.findings}))),m=N==="human"?void 0:he({cwd:i,target:t.output});try{switch(N){case"github":{m.write(ve({runs:C.map(a=>({findings:a.findings})),workspaceRoot:i}));break}case"json":{m.write(`${JSON.stringify({findings:v.findings,runs:v.runs},null,2)}
7
- `);break}case"junit":{m.write(we({runs:C.map(a=>({adapter:a.adapter.id,durationMs:a.durationMs,findings:a.findings})),workspaceRoot:i}));break}case"minimal":{ze(v.findings,i,m);break}case"sarif":{m.write(xe({runs:C.map(a=>({adapter:a.adapter.id,findings:a.findings,presence:w.find(y=>y.adapter.id===a.adapter.id)?.presence})),workspaceRoot:i}));break}default:Ye(v.findings,i,e)}}finally{m?.close()}const T=ke(v);T!==0&&(process.exitCode=T)};if(t.watch){const o=[...new Set(x.flatMap(({adapter:l})=>l.extensions))];await ue({extensions:o,initialFiles:g,label:"lint",log:l=>{e.info(l)},runCycle:R,workspaceRoot:i});return}await R(g)},Ge=e=>{const t=e;return[...t._??t.args??[]]},Ye=(e,t,n)=>{if(e.length===0){n.info(I("✓ lint: no findings"));return}const r=ye(e);for(const[c,$]of r){n.info(re(S(t,c)));for(const p of $){const x=He(p),j=Xe(p.severity),A=p.ruleId?O(` ${p.ruleId}`):"";n.info(` ${O(x)} ${j} ${p.message}${A}`)}}const i=e.filter(c=>c.severity==="error").length,s=e.filter(c=>c.severity==="warning").length;n.info(""),n.info(`${U(`${String(i)} error${i===1?"":"s"}`)}, ${D(`${String(s)} warning${s===1?"":"s"}`)}`)},ze=(e,t,n)=>{for(const r of e){const i=S(t,r.file),s=r.line??"",c=r.column??"";n.write(`${r.adapter} ${i} ${String(s)} ${String(c)} ${r.severity} ${r.ruleId??""} ${r.message}
8
- `)}},He=e=>e.line===void 0?"":e.column===void 0?String(e.line):`${String(e.line)}:${String(e.column)}`,Xe=e=>e==="error"?U("error"):e==="warning"?D("warn "):ie("info ");export{at as default};
1
+ import{createRequire as ee}from"node:module";import{e as A,a as re}from"../packem_shared/index-zq6Ehql6.js";import{f as ae,h as M}from"../packem_shared/ai-cache-D-BSLcuJ.js";import{p as c,U as V,V as k,W as ne,T as P,X as L,Y 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-ClmannRw.js";import{r as he,d as x,a as U,t as I}from"../packem_shared/env-NauRSSEC.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-CKahNmLy.js";import{r as G,f as F,a as ye,d as Se}from"../packem_shared/run-summary-utils-75paIrLB.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:$e}=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}`)},K=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 S=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,S)))],scope:o,sharedWorktreeCache:n.sharedWorktreeCache,workspaceRoot:r}},H=16,Q=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)} ${Q(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
+ `),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
+ `),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
+ `);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: ${Q(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."))},$=e=>{process.stdout.write(`${e}
5
+ `)},C=e=>{process.stdout.write(`${JSON.stringify(e,void 0,2)}
6
+ `)},Be=async(e,s,t)=>{if(!R(e)){if(s==="json"){process.stdout.write(`${JSON.stringify({directory:e,entries:[],totalBytes:0,totalCount:0},void 0,2)}
7
+ `);return}c.info(`No cache directory found at ${e}`);return}const r=await k(e);if(r.length===0){if(s==="json"){process.stdout.write(`${JSON.stringify({directory:e,entries:[],totalBytes:0,totalCount:0},void 0,2)}
8
+ `);return}c.info(`Cache directory is empty: ${e}`);return}const n=r.reduce((h,u)=>h+u.sizeBytes,0);if(s==="json"){const h=Date.now();process.stdout.write(`${JSON.stringify({directory:e,entries:r.map(u=>({ageMs:h-u.mtimeMs,hash:u.hash,mtimeIso:new Date(u.mtimeMs).toISOString(),sizeBytes:u.sizeBytes})),totalBytes:n,totalCount:r.length},void 0,2)}
9
+ `);return}$(`Cache directory: ${e}`),$(`Entries: ${String(r.length)} (${b(n,{decimals:1,space:!1})})`),t.info("");const a=Date.now(),o=r.map(h=>({age:ie(h.mtimeMs,a),hash:h.hash.slice(0,12),size:b(h.sizeBytes,{decimals:1,space:!1})})),i=Math.max(4,...o.map(h=>h.hash.length)),d=Math.max(4,...o.map(h=>h.size.length)),f=Math.max(3,...o.map(h=>h.age.length));t.info(` ${"hash".padEnd(i)} ${"size".padEnd(d)} ${"age".padEnd(f)}`),t.info(` ${"-".repeat(i)} ${"-".repeat(d)} ${"-".repeat(f)}`);for(const h of o)t.info(` ${h.hash.padEnd(i)} ${h.size.padEnd(d)} ${h.age.padEnd(f)}`)},Me=async(e,s,t)=>{if(!R(e)){c.info(`No cache directory to prune at ${e}`);return}if(t.maxCacheAgeDays!==void 0&&(!Number.isFinite(t.maxCacheAgeDays)||t.maxCacheAgeDays<0)){c.error(`Invalid --max-age-days value: expected a finite number >= 0, got ${String(t.maxCacheAgeDays)}`),process.exitCode=1;return}if(t.keepLast!==void 0&&(!Number.isFinite(t.keepLast)||t.keepLast<0||!Number.isInteger(t.keepLast))){c.error(`Invalid --keep-last value: expected a non-negative integer, got ${String(t.keepLast)}`),process.exitCode=1;return}if(t.maxCacheSize!==void 0){let u;try{u=me(t.maxCacheSize)}catch(l){c.error(`Invalid --max-size value: ${l instanceof Error?l.message:String(l)}`),process.exitCode=1;return}if(!Number.isFinite(u)||u<=0){c.error(`Invalid --max-size value: expected a positive size, got "${t.maxCacheSize}" (${String(u)} bytes)`),process.exitCode=1;return}}const r=t.maxCacheAgeDays===void 0?void 0:t.maxCacheAgeDays*24*60*60*1e3,n=await k(e),a=n.reduce((u,l)=>u+l.sizeBytes,0);if(t.keepLast!==void 0&&n.length>t.keepLast){const u=n.slice(t.keepLast);await Promise.all(u.map(l=>W(l.path,{force:!0,recursive:!0})))}await new E({cacheDirectory:e,maxCacheAge:r,maxCacheSize:t.maxCacheSize,workspaceRoot:s}).removeOldEntries();const i=await k(e),d=i.reduce((u,l)=>u+l.sizeBytes,0),f=n.length-i.length,h=a-d;if(f<=0){c.info("Nothing to prune — all entries are within the configured limits.");return}c.success(`Pruned ${String(f)} entr${f===1?"y":"ies"}, freed ${b(h,{decimals:1,space:!1})}.`)},y=e=>e===void 0?null:new Date(e).toISOString(),D=(e,s)=>{$(`${e}:`),s.directory!==void 0&&$(` Directory: ${s.directory}`),$(` Entries: ${String(s.entries)}`),$(` Total size: ${b(s.totalSizeBytes,{decimals:1,space:!1})}`),$(` Oldest: ${s.oldestEntry?new Date(s.oldestEntry).toISOString():"N/A"}`),$(` Newest: ${s.newestEntry?new Date(s.newestEntry).toISOString():"N/A"}`)},Ne=async(e,s)=>{if(!R(e)){if(s==="json"){process.stdout.write(`${JSON.stringify({directory:e,exists:!1,totalBytes:0,totalCount:0})}
10
+ `);return}c.info(`No cache directory at ${e}`);return}const t=await k(e),r=t.reduce((n,a)=>n+a.sizeBytes,0);if(s==="json"){process.stdout.write(`${JSON.stringify({directory:e,exists:!0,totalBytes:r,totalCount:t.length})}
11
+ `);return}D("Task cache",{directory:e,entries:t.length,newestEntry:t[0]?.mtimeMs,oldestEntry:t.at(-1)?.mtimeMs,totalSizeBytes:r})},ze=async e=>{const s=[],t=async r=>{const a=(await ue(r,{withFileTypes:!0})).toSorted((o,i)=>o.name.localeCompare(i.name));for(const o of a){const i=A(r,o.name);if(o.isDirectory()){await t(i);continue}if(!o.isFile())continue;const[d,f]=await Promise.all([Y(i),X(i)]);s.push({hash:f?.hash??"",mode:d.mode&4095,mtimeMs:d.mtimeMs,relativePath:re(e,i).replaceAll("\\","/"),sizeBytes:d.size})}};return await t(e),s},Ie=(e,s)=>Math.floor(e/1e3)===Math.floor(s/1e3),J=16,Fe=async(e,s)=>{const t=A(s,e.relativePath),r=await Y(t).catch(()=>{});if(!r)return{expected:{hash:e.hash,mode:e.mode,mtimeMs:e.mtimeMs},issues:["missing"],relativePath:e.relativePath};const n=await X(t),a=[];(n?.hash??"")!==e.hash&&a.push("content");const o=r.mode&4095;if(process.platform!=="win32"&&o!==e.mode&&a.push("mode"),Ie(r.mtimeMs,e.mtimeMs)||a.push("mtime"),a.length!==0)return{actual:{hash:n?.hash,mode:o,mtimeMs:r.mtimeMs},expected:{hash:e.hash,mode:e.mode,mtimeMs:e.mtimeMs},issues:a,relativePath:e.relativePath}},je=async(e,s,t)=>{for(const r of s){const n=await new E({cacheDirectory:r,workspaceRoot:t}).getByTaskId(e);if(n)return{cached:n,cacheDirectory:r}}},B=(e,s,t)=>{e==="json"?C(s):c.error(t),process.exitCode=1},Ae=async(e,s)=>{const t=Array.from({length:e.length});for(let r=0;r<e.length;r+=J){const n=e.slice(r,r+J),a=await Promise.all(n.map(async o=>Fe(o,s)));for(const[o,i]of a.entries())t[r+o]=i}return t.filter(r=>r!==void 0)},We=(e,s,t)=>{t.info(` expected hash: ${e.hash||"(none)"}`),t.info(` actual hash: ${s.hash??"(unreadable)"}`)},Te=(e,s,t)=>{t.info(` expected mode: ${e.mode.toString(8)}`),t.info(` actual mode: ${(s.mode??0).toString(8)}`)},Oe=(e,s,t)=>{t.info(` expected mtime: ${new Date(e.mtimeMs).toISOString()}`),t.info(` actual mtime: ${s.mtimeMs===void 0?"(unreadable)":new Date(s.mtimeMs).toISOString()}`)},Pe=(e,s)=>{const t=e.issues.includes("missing")?"MISSING":e.issues.join(",").toUpperCase();s.info(` [${t}] ${e.relativePath}`);const{expected:r}=e,{actual:n}=e;e.issues.includes("missing")||!r||!n||(e.issues.includes("content")&&We(r,n,s),e.issues.includes("mode")&&Te(r,n,s),e.issues.includes("mtime")&&Oe(r,n,s))},Le=(e,s,t,r,n,a)=>{if(c.info(`Verify ${e} (hash ${s})`),a.info(""),a.info(` cache: ${t}`),a.info(` files: ${String(r)}`),n.length===0){a.info(""),c.success("Cache restore is faithful — all files match content, mode, and mtime.");return}a.info(` drift: ${String(n.length)} file(s)`),a.info("");for(const o of n)Pe(o,a);process.exitCode=1},_e=async(e,s,t)=>{const{cacheDirectories:r,format:n,workspaceRoot:a}=s;if(r.length===0){B(n,{error:"no-cache-directory",taskId:e},"No cache directory resolved — pass --cache-dir or run inside a workspace.");return}const o=await je(e,r,a);if(!o){B(n,{error:"no-cached-entry",searchedCaches:r,taskId:e},`No cached entry found for task "${e}". Run it once before verifying.`);return}const{cached:i,cacheDirectory:d}=o,f=await fe(A($e(),"vis-cache-verify-"));try{if(!await new E({cacheDirectory:d,workspaceRoot:f}).restoreOutputs(i.hash)){B(n,{error:"restore-failed",hash:i.hash,taskId:e},`Cache restore failed for ${e} (hash ${i.hash}).`);return}const l=await ze(f);if(l.length===0){n==="json"?C({diffs:[],hash:i.hash,status:"no-outputs",taskId:e}):c.info(`Cached entry for ${e} has no recorded outputs — nothing to verify.`);return}const S=await Ae(l,a);if(n==="json"){C({cachedFileCount:l.length,cacheDirectory:d,diffs:S,hash:i.hash,status:S.length===0?"ok":"drift",taskId:e}),S.length>0&&(process.exitCode=1);return}Le(e,i.hash,d,l.length,S,t)}finally{await W(f,{force:!0,recursive:!0}).catch(()=>{})}},He=(e,s,t,r)=>{e==="json"?C({error:"no-summary",runId:t??null,taskId:s}):t===void 0?c.error(`No previous run summary found. Run a task first to populate \`${T(r,{dataDirectory:x(r)})}\`.`):c.error(`Run summary "${t}" not found in ${U(r)}/.`),process.exitCode=1},Je=(e,s,t)=>{e==="json"?C({error:"task-not-in-summary",runId:t.id,taskId:s}):(c.error(`Task "${s}" was not part of run ${t.id}.`),c.info(`Tasks in this run: ${t.tasks.map(r=>r.taskId).join(", ")||"(none)"}`)),process.exitCode=1},Ve=(e,s,t,r,n)=>({diff:n,previousRunId:t?.id??null,previousTask:r?{cacheStatus:r.cacheStatus,hash:r.hash??null,hashDetails:r.hashDetails??null}:null,runId:e.id,task:{cacheMissReasons:s.cacheMissReasons??null,cacheStatus:s.cacheStatus,hash:s.hash??null,hashDetails:s.hashDetails??null,hashSource:s.hashSource??null,taskId:s.taskId}}),Ue=(e,s,t,r,n,a)=>{c.info(`Why ${e}? (run ${s.id})`),a.info(""),a.info(` status: ${t.cacheStatus}`),a.info(` hash: ${t.hash??"(none)"}`),t.hashSource==="declared-fallback"&&a.info(" key: declared-fallback (tracker observed no workspace access; keyed on declared inputs)"),n?a.info(` prev: ${n.hash??"(none)"} [run ${r?.id??"?"}]`):a.info(" prev: (no prior run found)"),a.info("")},Ye=(e,s,t,r)=>{if(t.cacheMissReasons&&t.cacheMissReasons.length>0){r.info("Cache miss reasons (trace-mode fingerprint):");for(const n of t.cacheMissReasons)r.info(` - ${pe(n)}`)}else c.info("No hash inputs recorded for this run (trace-mode tasks record a miss reason only when the cache misses).");r.info(""),c.info(`Tracked files and env of this run: vis cache hash ${e} --run ${s.id}`)},qe=e=>!e.commandChanged&&[e.nodes,e.runtime,e.implicitDeps].every(s=>s.added.length===0&&s.changed.length===0&&s.removed.length===0),Xe=(e,s)=>{s.info("Hash inputs that changed since the previous run:"),s.info(""),e.commandChanged&&s.info(" command: changed");for(const t of["nodes","runtime","implicitDeps"]){const r=e[t];if(!(r.added.length===0&&r.changed.length===0&&r.removed.length===0)){s.info(` ${t}:`);for(const n of r.added)s.info(` + ${n}`);for(const n of r.changed)s.info(` ~ ${n}`);for(const n of r.removed)s.info(` - ${n}`)}}},Ge=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){He(r,e,n,a);return}const i=F(o,e);if(!i){Je(r,e,o);return}const d=await ye(a,o.id),f=d?F(d,e):void 0,h=Se(i.hashDetails,f?.hashDetails);if(r==="json"){C(Ve(o,i,d,f,h));return}if(Ue(e,o,i,d,f,t),i.hashDetails===void 0){Ye(e,o,i,t);return}if(!f){c.info("No previous run to diff against — first time this task was recorded.");return}if(qe(h)){c.success("No hash inputs changed since the previous run.");return}Xe(h,t),t.info(""),c.info(`Last summary file: ${T(a,{dataDirectory:x(a)})}`)},it=async({logger:e,options:s,visConfig:t,workspaceRoot:r})=>{const{directoriesFor:n}=w(r,s,t),a=n("read"),o=s.format??"table";for(const i of a)a.length>1&&c.info(`# ${i}`),await Be(i,o,e)},ct=async({options:e,visConfig:s,workspaceRoot:t})=>{const r=K(e.type),n=!!e.dryRun;if(m(r,"task")){const{directoriesFor:a,workspaceRoot:o}=w(t,e,s);for(const i of a("wipe"))await De(i,o,{dryRun:n,force:!!e.force})}if(m(r,"ai"))if(n){const a=M();c.info(`Would clear ${String(a.entries)} cached AI response${a.entries===1?"":"s"}.`)}else ve();if(m(r,"socket"))if(n){const a=I();c.info(`Would clear ${String(a.entries)} cached Socket.dev report${a.entries===1?"":"s"}.`)}else ke();if(m(r,"deps-dev"))if(n){const a=N();c.info(`Would clear ${String(a.entries)} cached deps.dev record${a.entries===1?"":"s"}.`)}else Ce();if(m(r,"snyk"))if(n){const a=z();c.info(`Would clear ${String(a.entries)} cached Snyk record${a.entries===1?"":"s"}.`)}else ge()},dt=async({options:e,visConfig:s,workspaceRoot:t})=>{const{directoriesFor:r,workspaceRoot:n}=w(t,e,s),a=r("evict");for(const o of a)a.length>1&&c.info(`# ${o}`),await Me(o,n,{keepLast:typeof e.keepLast=="number"?e.keepLast:void 0,maxCacheAgeDays:typeof e.maxAgeDays=="number"?e.maxAgeDays:void 0,maxCacheSize:e.maxSize})},Z=e=>e??process.cwd(),ht=async({argument:e,logger:s,options:t,workspaceRoot:r})=>{const n=e[0];if(!n){c.error("No task ID specified. Usage: vis cache why <project>:<target>"),process.exitCode=1;return}await Ge(n,{format:t.format??"table",runId:t.run,workspaceRoot:Z(r)},s)},ft=async({argument:e,logger:s,options:t,visConfig:r,workspaceRoot:n})=>{const a=e[0];if(!a){c.error("No task ID specified. Usage: vis cache hash <project>:<target>"),process.exitCode=1;return}const{directoriesFor:o}=w(n,t,r);await Re(a,{cacheDirectories:o("read"),format:t.format??"table",runId:t.run,workspaceRoot:Z(n)},s)},ut=async({options:e,visConfig:s,workspaceRoot:t})=>{const r=K(e.type);if((e.format??"table")==="json"){const a={};if(m(r,"task")){const{directoriesFor:o}=w(t,e,s),i=o("read");a.task=await Promise.all(i.map(async d=>{const f=R(d),h=f?await k(d):[],u=h.reduce((l,S)=>l+S.sizeBytes,0);return{directory:d,entries:h.length,exists:f,newestEntry:y(h[0]?.mtimeMs),oldestEntry:y(h.at(-1)?.mtimeMs),totalBytes:u}}))}if(m(r,"ai")){const o=M();a.ai={entries:o.entries,newestEntry:y(o.newestEntry),oldestEntry:y(o.oldestEntry),totalBytes:o.totalSizeBytes}}if(m(r,"socket")){const o=I();a.socket={entries:o.entries,newestEntry:y(o.newestEntry),oldestEntry:y(o.oldestEntry),totalBytes:o.totalSizeBytes}}if(m(r,"deps-dev")){const o=N();a["deps-dev"]={entries:o.entries,newestEntry:y(o.newestEntry),oldestEntry:y(o.oldestEntry),totalBytes:o.totalSizeBytes}}if(m(r,"snyk")){const o=z();a.snyk={entries:o.entries,newestEntry:y(o.newestEntry),oldestEntry:y(o.oldestEntry),totalBytes:o.totalSizeBytes}}process.stdout.write(`${JSON.stringify(a,void 0,2)}
12
+ `);return}if(m(r,"task")){const{directoriesFor:a}=w(t,e,s),o=a("read");for(const i of o)o.length>1&&c.info(`# ${i}`),await Ne(i,"table")}m(r,"ai")&&D("AI response cache",M()),m(r,"socket")&&D("Socket.dev report cache",I()),m(r,"deps-dev")&&D("deps.dev cache",N()),m(r,"snyk")&&D("Snyk issue cache",z())},lt=async({argument:e,logger:s,options:t,visConfig:r,workspaceRoot:n})=>{const a=e[0];if(!a){c.error("No task ID specified. Usage: vis cache verify <project>:<target>"),process.exitCode=1;return}const{directoriesFor:o,workspaceRoot:i}=w(n,t,r),d=o("read");await _e(a,{cacheDirectories:d,format:t.format??"table",workspaceRoot:i},s)};export{ct as cacheCleanExecute,ft as cacheHashExecute,it as cacheListExecute,dt as cachePruneExecute,ut as cacheSizeExecute,lt as cacheVerifyExecute,ht as cacheWhyExecute,ve as clearAiCacheSafe,Ce as clearDepsDevCacheSafe,ge as clearSnykCacheSafe,ke as clearSocketCacheSafe,k as collectCacheEntries,ie as formatAge,De as runClean,Re as runHash,Be as runList,Me as runPrune,Ne as runSize,_e as runVerify,Ge as runWhy};
@@ -1,2 +1,5 @@
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-sb3SOT-b.js";import{y as se}from"../packem_shared/isAccessibleSync-DYKTrrvc-CBsMZhj-.js";import{p as re}from"../packem_shared/package-version-VdULnxr1.js";import{g as oe,r as ne}from"../packem_shared/packument-zeKEhTaX.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
- `);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
+ import{createRequire as Oe}from"node:module";import{J as U,F as X,q as Te,j as ie}from"../packem_shared/index.server-Ca_EEVfw.js";import{e as y,x as z,$ as D,a as C,m as xe}from"../packem_shared/index-zq6Ehql6.js";import{T as Ie}from"./cli-main.js";import{V as T}from"../packem_shared/vis-user-error-DhgW3DzD.js";import{y as qe,f as De,l as Ge,i as Be}from"./ts-loader.js";import{y as B}from"../packem_shared/isAccessibleSync-DYKTrrvc-CKahNmLy.js";import{p as He}from"../packem_shared/package-version-BOK3IncQ.js";import{w as Je,r as Ke,a as Ue,s as Xe,c as ze,b as Qe,d as Ye,o as Ze,p as et,g as tt,h as st,i as nt,j as rt,k as it,l as ot,n as at,m as ct}from"../packem_shared/watch-loop-Dh4GHUVS.js";import{A as E}from"../packem_shared/registry-ClmannRw.js";import{d as Q,f as Y,a as dt}from"../packem_shared/detect-xqoTANJb.js";let _e;const Ce=e=>(_e??=Oe(import.meta.url))(e),N=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,q=e=>{if(typeof N<"u"&&N.versions&&N.versions.node){const[t,s]=N.versions.node.split(".").map(Number);if(t>22||t===22&&s>=3||t===20&&s>=16)return N.getBuiltinModule(e)}return Ce(e)},{spawn:Ee,spawnSync:Ne}=q("node:child_process"),{readFileSync:G,readdirSync:ve,writeFileSync:we,existsSync:Re,mkdirSync:We,renameSync:Me,unlinkSync:Le}=q("node:fs"),{createRequire:ye}=q("node:module"),{randomBytes:Ve,createHash:H}=q("node:crypto"),ft=["biome","dprint","ruff-fmt"],lt=({builtin:e,detected:t,engine:s="auto",oxfmtEnabled:n})=>{if(s==="oxfmt"){if(!n)throw new T('vis.config fmt: `engine: "oxfmt"` and `adapters.oxfmt.enabled: false` contradict each other.');if(e===!1)throw new T('vis.config fmt: `engine: "oxfmt"` and `adapters.oxfmt.builtin: false` contradict each other.');return"bundled"}return s==="prettier"||e===!1||!n||ft.some(r=>t.includes(r))?"adapters":"bundled"},pt=[".oxfmtrc.json",".oxfmtrc.jsonc","oxfmt.config.ts","oxfmt.config.mts"],be=["package.json",".prettierrc",".prettierrc.json",".prettierrc.yaml",".prettierrc.yml",".prettierrc.json5",".prettierrc.js",".prettierrc.ts",".prettierrc.mjs",".prettierrc.mts",".prettierrc.cjs",".prettierrc.cts","prettier.config.js","prettier.config.ts","prettier.config.mjs","prettier.config.mts","prettier.config.cjs","prettier.config.cts",".prettierrc.toml"],Se=new Set([".cjs",".cts",".js",".mjs",".mts",".ts"]),L=e=>typeof e=="object"&&e!==null&&!Array.isArray(e),Z=e=>{try{const t=He(e);return L(t)?t:void 0}catch{return}},je=e=>{for(const t of be){const s=y(e,t);if(B(s)&&!(t==="package.json"&&Z(s)?.prettier===void 0))return s}},ut=e=>{const t=D(e),s=z(e);return t==="package.json"?Z(e)?.prettier:s===".json"?JSON.parse(G(e,"utf8")):s===".json5"?qe(e):s===".toml"?De(e):Ge(e)},oe=async(e,t)=>{const s=await t(e);return"default"in s?s.default:s},mt=new Set([".git",".vis","build","coverage","dist","node_modules"]),gt=6,ht=2e3,xt=e=>{const t=new Set(be),s=[],n=[{depth:0,directory:e}];let r=0;for(let i=n.shift();i!==void 0&&r<ht;i=n.shift()){r+=1;let f;try{f=ve(i.directory,{withFileTypes:!0})}catch{continue}for(const o of f){const a=y(i.directory,o.name);o.isDirectory()?i.depth<gt&&!mt.has(o.name)&&n.push({depth:i.depth+1,directory:a}):i.depth>0&&t.has(o.name)&&(o.name!=="package.json"||Z(a)?.prettier!==void 0)&&s.push(a)}}return s},vt=async(e,t)=>{const s=je(e);if(s===void 0)return;let n;try{n=Se.has(z(s))?await oe(s,t):ut(s),typeof n=="string"&&(n=await oe(ye(s).resolve(n),t))}catch(r){throw new T(`Could not read the Prettier config ${s}: ${r instanceof Error?r.message:String(r)}`,{cause:r})}if(!L(n))throw new T(`The Prettier config ${s} must be an object.`);return{config:n,file:s}},wt=e=>{const t=y(e,".prettierignore");return B(t)?G(t,"utf8").split(/\r?\n/).map(s=>s.trim()).filter(s=>s!==""&&!s.startsWith("#")):[]},yt=e=>{const t={scoped:[]};let s;for(const n of e.split(/\r?\n/)){const r=n.trim();if(r.startsWith("#")||r.startsWith(";"))continue;const i=/^\[(.+)\]$/.exec(r);if(i){[,s]=i;continue}const f=/^max_line_length\s*[=:]\s*(\S+)$/i.exec(r);if(!f||s===void 0)continue;const o=Number.parseInt(f[1],10);!Number.isInteger(o)||o<=0||(s==="*"||s==="**"?t.universal=o:t.scoped.push(s))}return t},ae=e=>{const t=y(e,".editorconfig");return B(t)?yt(G(t,"utf8")):{scoped:[]}},bt=new Set(["arrowParens","bracketSameLine","bracketSpacing","embeddedLanguageFormatting","endOfLine","experimentalOperatorPosition","htmlWhitespaceSensitivity","jsxSingleQuote","objectWrap","printWidth","proseWrap","quoteProps","semi","singleAttributePerLine","singleQuote","tabWidth","trailingComma","useTabs","vueIndentScriptAndStyle"]),St=(e,t,s)=>e!=="tailwindFunctions"&&e!=="tailwindAttributes"||!Array.isArray(t)?t:t.filter(n=>{if(typeof n!="string")return!1;const r=n.startsWith("/")&&n.endsWith("/");return r&&s.push(`"${e}": the regular expression ${n} is not supported by oxfmt and was dropped.`),!r}),jt=(e,t)=>e!=="astroCompressHTML"||typeof t!="boolean"?t:t?"html":"none",ee=[{mapping:{attributes:"tailwindAttributes",config:"tailwindConfig",functions:"tailwindFunctions",preserveDuplicates:"tailwindPreserveDuplicates",preserveWhitespace:"tailwindPreserveWhitespace",stylesheet:"tailwindStylesheet"},oxfmtKey:"sortTailwindcss",plugin:"prettier-plugin-tailwindcss",transform:St},{mapping:{allowShorthand:"svelteAllowShorthand",indentScriptAndStyle:"svelteIndentScriptAndStyle",sortOrder:"svelteSortOrder"},oxfmtKey:"svelte",plugin:"prettier-plugin-svelte"},{mapping:{allowShorthand:"astroAllowShorthand",compressHTML:"astroCompressHTML",skipFrontmatter:"astroSkipFrontmatter"},oxfmtKey:"astro",plugin:"prettier-plugin-astro",transform:jt}],kt=new Set(["prettier-plugin-packagejson",...ee.map(({plugin:e})=>e)]),At=new Set(ee.flatMap(({mapping:e})=>Object.values(e))),Pt=new Map([["acorn","javascript"],["angular","angular-html"],["astro","astro"],["babel","javascript"],["babel-ts","typescript"],["css","css"],["espree","javascript"],["glimmer","handlebars"],["graphql","graphql"],["html","html"],["json5","json5"],["json","json"],["jsonc","jsonc"],["less","less"],["markdown","markdown"],["mdx","mdx"],["meriyah","javascript"],["oxc","javascript"],["oxc-ts","typescript"],["remark","markdown"],["scss","scss"],["svelte","svelte"],["typescript","typescript"],["vue","vue"],["yaml","yaml"],["yuku","javascript"],["yuku-ts","typescript"]]),ce=(e,t,s)=>{const n={};for(const[r,i]of Object.entries(e))if(!At.has(r)){if(!bt.has(r)){t.push(`${s}"${r}" is not supported by oxfmt and was dropped.`);continue}if(r==="endOfLine"&&i==="auto"){t.push(`${s}"endOfLine": "auto" is not supported by oxfmt and was dropped.`);continue}n[r]=i}return n},de=(e,t,s,n)=>{const r={};for(const{mapping:i,oxfmtKey:f,plugin:o,transform:a}of ee){if(!t.has(o))continue;const c={};for(const[l,u]of Object.entries(i)){const x=e[u];x!==void 0&&(c[l]=a?a(u,x,s):x)}(n||Object.keys(c).length>0)&&(r[f]=c)}return r},fe=e=>Array.isArray(e)?e:[e],le=(e,t={})=>{const s=[],{overrides:n,plugins:r,...i}=e;delete i.$schema;const f=new Set;for(const a of Array.isArray(r)?r:[])typeof a=="string"&&kt.has(a)?f.add(a):typeof a=="string"?s.push(`The plugin "${a}" is not supported by oxfmt and was dropped.`):s.push("A custom plugin module is not supported by oxfmt and was dropped.");const o=ce(i,s,"");if(typeof o.printWidth!="number"&&(o.printWidth=t.editorconfigPrintWidth??80,t.editorconfigPrintWidth===void 0&&s.push('"printWidth" is not set in the Prettier config; it is pinned to 80 (the oxfmt default is 100).')),o.sortPackageJson=f.has("prettier-plugin-packagejson")?{}:!1,Object.assign(o,de(i,f,s,!0)),Array.isArray(n)){const a=[],c=[];for(const l of n){if(!L(l))continue;const u={files:fe(l.files),...l.excludeFiles===void 0?{}:{excludeFiles:fe(l.excludeFiles)}},{parser:x,...h}=L(l.options)?l.options:{},g=typeof x=="string"?Pt.get(x):void 0;g?c.push({...u,language:g}):x!==void 0&&s.push(`overrides: "parser": ${JSON.stringify(x)} is not supported by oxfmt and was dropped.`);const S={...ce(h,s,"overrides: "),...de(h,f,s,!1)};Object.keys(S).length>0&&a.push({...u,options:S})}a.length>0&&(o.overrides=a),c.length>0&&(o.associations=c)}return o.ignorePatterns=[...t.ignorePatterns??[]],t.sourceFile!==void 0&&Se.has(z(t.sourceFile))&&s.push(`${D(t.sourceFile)} was evaluated and mapped as static values; logic in it is not preserved.`),{config:o,warnings:s}},Ft=e=>e!==void 0&&(e.options!==void 0||e.overrides!==void 0||e.ignorePatterns!==void 0),J=(e,t)=>{for(const s of t)if(s.replace(/^!/,"").split(/[/\\]/).includes(".."))throw new T(`vis.config ${e}: "${s}" must not contain "..". Patterns are relative to the workspace root.`)},$t=e=>{J("fmt.ignorePatterns",e.ignorePatterns??[]);for(const[t,s]of(e.overrides??[]).entries())J(`fmt.overrides[${String(t)}].files`,[s.files].flat()),J(`fmt.overrides[${String(t)}].excludeFiles`,[s.excludeFiles??[]].flat())},Ot=e=>{const t=pt.find(s=>B(y(e,s)));return t===void 0?void 0:y(e,t)},_t=async({fmtConfig:e,loadModule:t,prettierDeclared:s=!1,root:n})=>{const r=Ot(n),i=je(n),f=o=>C(n,o);if(Ft(e)){$t(e);const o=[r,i].filter(c=>c!==void 0).map(c=>f(c)),a={...e.options};return e.overrides!==void 0&&(a.overrides=[...e.overrides]),e.ignorePatterns!==void 0&&(a.ignorePatterns=[...e.ignorePatterns]),{config:a,source:"vis.config",warnings:o.length>0?[ue("vis.config fmt.options",o)]:[]}}if(r!==void 0)return{file:r,source:"oxfmtrc",warnings:i===void 0?[]:[ue(f(r),[f(i)])]};if(i!==void 0){const o=await vt(n,t),{scoped:a,universal:c}=ae(n),{config:l,warnings:u}=le(o.config,{editorconfigPrintWidth:c,ignorePatterns:wt(n),sourceFile:o.file});return u.push(...K(n)),u.push(...pe(a)),{config:l,file:o.file,source:"prettier",warnings:u}}if(s){const{scoped:o,universal:a}=ae(n),{config:c}=le({},{editorconfigPrintWidth:a});return{config:c,source:"prettier-defaults",warnings:[...pe(o),...K(n)]}}return{source:"defaults",warnings:K(n)}},pe=e=>e.length>0?[`.editorconfig sets max_line_length only for ${e.join(", ")}; those sections are not applied.`]:[],K=e=>{const t=xt(e);if(t.length===0)return[];const s=t.length>1?` and ${String(t.length-1)} more`:"";return[`Only the root Prettier config is read; ${C(e,t[0])}${s} in a subdirectory ${t.length>1?"are":"is"} ignored.`]},ue=(e,t)=>`Formatting options come from ${e}; ${t.join(" and ")} found but not used (the first source that exists is used whole: vis.config fmt.options, then .oxfmtrc.json / oxfmt.config.ts, then the Prettier config).`,Ct=(e,t)=>{switch(e.source){case"defaults":return"oxfmt defaults";case"oxfmtrc":return C(t,e.file);case"prettier":return`${C(t,e.file)} (mapped to oxfmt options)`;case"prettier-defaults":return"Prettier's defaults (Prettier is declared but has no config)";default:return"vis.config fmt.options"}},V=".vis-fmt-",Et="node_modules/.cache/vis/fmt",ke=`${V}*.json`,Nt=()=>{const e=ye(import.meta.url).resolve("oxfmt/package.json"),{bin:t}=JSON.parse(G(e,"utf8"));return y(xe(e),typeof t=="string"?t:t.oxfmt)},Tt=({configPath:e,extraArgs:t=[],files:s,mode:n})=>[n==="fix"?"--write":"--list-different","--no-error-on-unmatched-pattern",...e===void 0?[]:["-c",e,"--disable-nested-config"],...t,...s],It=["SIGINT","SIGTERM"],Ae=e=>(e.ignorePatterns?.length??0)>0||(e.overrides?.length??0)>0,Rt=(e,t)=>{const s=`${JSON.stringify(t,null,2)}
2
+ `,n=y(Et,`${H("sha256").update(s).digest("hex").slice(0,16)}.json`),r=y(e,n);if(!Re(r)){We(xe(r),{recursive:!0});const i=`${r}.${String(process.pid)}.tmp`;we(i,s),Me(i,r)}return n},Wt=(e,t)=>{const s=y(e,`${V}${String(process.pid)}-${Ve(3).toString("hex")}.json`),n=[...t.ignorePatterns??[],ke];return we(s,`${JSON.stringify({...t,ignorePatterns:n},null,2)}
3
+ `),s},Pe=e=>{try{Le(e)}catch{}},Mt=/^\.vis-fmt-(\d+)-[0-9a-f]{6}\.json$/,Lt=e=>{try{return process.kill(e,0),!0}catch(t){return t.code==="EPERM"}},qt=e=>{let t;try{t=ve(e)}catch{return}for(const s of t){const n=Mt.exec(s)?.[1];n!==void 0&&!Lt(Number(n))&&Pe(y(e,s))}},Dt=async e=>{const{binPath:t=Nt(),config:s,extraArgs:n,files:r,mode:i,reRaiseSignal:f,root:o}=e,a=Date.now();let c,l;const u=()=>{c!==void 0&&Pe(c)};qt(o);try{s!==void 0&&(Ae(s)?(c=Wt(o,s),l=D(c)):l=Rt(o,s));const x=Tt({configPath:l,extraArgs:n,files:r,mode:i});return await new Promise(h=>{const g=Ee(process.execPath,[t,...x],{cwd:o,windowsHide:!0}),S=[],O=[],I=p=>{g.kill(p),u(),v(),process.listenerCount(p)===0&&(f??(k=>process.kill(process.pid,k)))(p)},j=It.map(p=>[p,()=>{I(p)}]);process.on("exit",u);for(const[p,k]of j)process.on(p,k);const v=()=>{process.off("exit",u);for(const[p,k]of j)process.off(p,k)};g.stdout.on("data",p=>S.push(p)),g.stderr.on("data",p=>O.push(p)),g.on("error",p=>{v(),h({durationMs:Date.now()-a,exitCode:null,stderr:p.message,stdout:""})}),g.on("close",p=>{v(),h({durationMs:Date.now()-a,exitCode:p,stderr:Buffer.concat(O).toString("utf8"),stdout:Buffer.concat(S).toString("utf8")})})})}finally{u()}},Gt=e=>e.startsWith("/")||/^[a-z]:[\\/]/i.test(e),te=(e,t)=>Gt(t)?t:`${e}/${t}`,Bt={argsCheck:(e,t)=>me(e,t,"check"),argsFix:(e,t)=>me(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 H("sha256").update(s.join("|")).digest("hex").slice(0,16)},detect:(e,t)=>{const s=Q(t,E.dprint.packageNames[0]),n=Y(e,E.dprint.configFiles);if(!(!s&&!n))return{adapter:"dprint",configFile:n,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 n of e.stdout.split(/\r?\n/)){const r=n.trim();!r||r.startsWith("[")||r.startsWith("Checked ")||r.startsWith("Error:")||s.push({adapter:"dprint",file:te(t.root,r),fixable:!0,message:"Code style issues would be auto-fixed",severity:"info"})}return s}},me=(e,t,s)=>{const n=s==="fix"?["fmt"]:["check","--list-different"];return t.extraArgs?.length&&n.push(...t.extraArgs),n.push(...e),n},Fe={argsCheck:(e,t)=>ge(e,t,"check"),argsFix:(e,t)=>ge(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 H("sha256").update(s.join("|")).digest("hex").slice(0,16)},detect:(e,t)=>{const s=Q(t,E.oxfmt.packageNames[0]),n=Y(e,E.oxfmt.configFiles);if(!(!s&&!n))return{adapter:"oxfmt",configFile:n,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 n of e.stdout.split(/\r?\n/)){const r=n.trim();!r||r.startsWith("[")||s.push({adapter:"oxfmt",file:te(t.root,r),fixable:!0,message:"Code style issues would be auto-fixed",severity:"info"})}return s}},Ht=["astro","cjs","css","cts","gql","graphql","handlebars","hbs","htm","html","js","json","json5","jsonc","jsx","less","markdown","md","mdx","mjs","mts","pcss","postcss","scss","svelte","toml","ts","tsx","vue","yaml","yml"],ge=(e,t,s)=>{const n=s==="fix"?["--write"]:["--list-different"];return t.extraArgs?.length&&n.push(...t.extraArgs),n.push(...e),n},Vt={argsCheck:(e,t)=>he(e,t,"check"),argsFix:(e,t)=>he(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 H("sha256").update(s.join("|")).digest("hex").slice(0,16)},detect:(e,t)=>{const s=Q(t,E.prettier.packageNames[0]),n=Y(e,E.prettier.configFiles);if(!(!s&&!n))return{adapter:"prettier",configFile:n,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 n of e.stdout.split(/\r?\n/)){const r=n.trim();r&&(r.startsWith("[")||s.push({adapter:"prettier",file:te(t.root,r),fixable:!0,message:"Code style issues would be auto-fixed",severity:"info"}))}return s}},he=(e,t,s)=>{const n=s==="fix"?["--write"]:["--list-different"];return t.quiet&&n.push("--log-level","warn"),t.extraArgs?.length&&n.push(...t.extraArgs),n.push(...e),n},Jt=[Fe,Ye,Bt,Vt,Ze],ds=async({logger:e,options:t,visConfig:s,workspaceRoot:n})=>{const r=n??process.cwd(),i=s?.fmt;Je(e,"fmt",i);const f=Ke(Jt,i?.order),o=dt(r,f),c=Ue(o,f,"fmt").filter(({adapter:m})=>i?.adapters?.[m.id]?.enabled!==!1),l=lt({builtin:i?.adapters?.oxfmt?.builtin,detected:c.map(({adapter:m})=>m.id),engine:i?.engine,oxfmtEnabled:i?.adapters?.oxfmt?.enabled!==!1})==="bundled",u=t.format??"human",x=u==="human"&&!t.quiet;let h,g=c;if(l){h=await _t({fmtConfig:i,loadModule:Be,prettierDeclared:c.some(({adapter:m})=>m.id==="prettier"),root:r}),g=[{adapter:Fe,presence:o.get("oxfmt")??{adapter:"oxfmt",declared:!1,root:r}}];for(const m of h.warnings)e.warn(`vis fmt: ${m}`);i?.engine!=="oxfmt"&&(h.source==="prettier"||c.some(({adapter:m})=>m.id==="prettier"))&&e.warn('vis fmt: formatting with the bundled oxfmt instead of Prettier; the output can differ. Set `fmt.engine: "prettier"` in vis.config to keep running Prettier.'),x&&(e.info(h.source==="defaults"?"vis fmt: no config found, using oxfmt defaults":`vis fmt: formatting with ${Ct(h,r)}`),h.config!==void 0&&Ae(h.config)&&Ut(r,e))}else if(g.length===0){e.warn("vis fmt: no formatter detected in this workspace (looked for: oxfmt, biome, dprint, prettier, ruff).");return}const S=m=>{const w=i?.adapters?.[m]?.extraArgs;return w&&w.length>0?[...w]:void 0},O={quiet:t.quiet??!1},I=Xt(t),j=t.check?"check":"fix";let v;if(t.staged){if(v=Xe(r)?.filter(m=>!M(m)),v===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(v.length===0){e.info(U("✓ fmt: no staged files"));return}}else if(typeof t.since=="string"&&t.since.length>0){if(v=ze(r,t.since)?.filter(m=>!M(m)),v===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(v.length===0){e.info(U(`✓ fmt: no files changed since ${t.since}`));return}}const p=Ie(r,void 0,void 0,!0);u==="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 k=async m=>{const w=I.length>0?I:m,A=[];if(w){const d=l?new Map([["oxfmt",w]]):et(w,g,i?.extensionOverrides);for(const{adapter:b,presence:P}of g){const F=d.get(b.id);if(!F||F.length===0)continue;const W=S(b.id),re={adapter:b,files:F,presence:P};W&&(re.options={...O,extraArgs:W}),A.push(re)}}else for(const{adapter:d,presence:b}of g){const P=S(d.id),F={adapter:d,files:["."],presence:b};P&&(F.options={...O,extraArgs:P}),A.push(F)}if(A.length===0)return;const se=l?[await Dt({config:h?.config,extraArgs:A[0].options?.extraArgs,files:A[0].files,mode:j,root:r})]:await tt(A,O,j,{cacheRoot:p}),$e=l?Kt(se[0],e):!1,R=A.map((d,b)=>{const P=se[b],F=d.adapter.parse(P,d.presence).filter(W=>!l||!M(W.file));return{adapter:d.adapter,durationMs:P.durationMs,exitCode:P.exitCode,findings:F}}),$=st(R.map(d=>({adapter:d.adapter.id,durationMs:d.durationMs,exitCode:d.exitCode,findingCount:d.findings.length,findings:d.findings}))),_=u==="human"?void 0:nt({cwd:r,target:t.output});try{switch(u){case"github":{_.write(ot({runs:R.map(d=>({findings:d.findings})),workspaceRoot:r}));break}case"json":{_.write(`${JSON.stringify({findings:$.findings,mode:j,runs:$.runs},null,2)}
4
+ `);break}case"junit":{_.write(it({runs:R.map(d=>({adapter:d.adapter.id,durationMs:d.durationMs,findings:d.findings})),workspaceRoot:r}));break}case"minimal":{Qt($.findings,r,_);break}case"sarif":{_.write(rt({runs:R.map(d=>({adapter:d.adapter.id,findings:d.findings,presence:A.find(b=>b.adapter.id===d.adapter.id)?.presence})),workspaceRoot:r}));break}default:zt($.findings,r,j,e,l)}}finally{_?.close()}const ne=$e?1:j==="fix"?$.hadProcessFailure?1:0:at({...$,maxSeverity:$.findings.length>0?"error":void 0});ne!==0&&(process.exitCode=ne)};if(t.watch){const m=l?[...Ht]:[...new Set(g.flatMap(({adapter:w})=>w.extensions))];await Qe({extensions:m,ignore:M,initialFiles:v,label:"fmt",log:w=>{e.info(w)},runCycle:k,workspaceRoot:r});return}await k(v)},M=e=>D(e).startsWith(V),Kt=(e,t)=>e.exitCode===0||e.exitCode===1?!1:(t.error(e.stderr.trim()||`vis fmt: oxfmt exited with ${e.exitCode===null?"no exit code":`code ${String(e.exitCode)}`}.`),!0),Ut=(e,t)=>{Ne("git",["check-ignore","-q",`${V}x.json`],{cwd:e}).status===1&&t.info(X(`vis fmt: a temporary ${ke} is written to the workspace root while it runs; add it to .gitignore.`))},Xt=e=>{const t=e;return[...t._??t.args??[]]},zt=(e,t,s,n,r)=>{if(e.length===0){n.info(U(s==="check"?"✓ fmt: all files already formatted":r?"✓ fmt: formatted with oxfmt":"✓ fmt: nothing to change"));return}const i=ct(e),f=s==="fix"?Te(ie("Formatted:")):ie("Would change:");n.info(f);for(const o of i.keys())n.info(` ${X("·")} ${C(t,o)}`);s==="check"&&(n.info(""),n.info(X(`Run \`vis fmt\` to apply changes (${String(i.size)} file${i.size===1?"":"s"}).`)))},Qt=(e,t,s)=>{for(const n of e)s.write(`${n.adapter} ${C(t,n.file)}
5
+ `)};export{ds as default};