@visulima/vis 1.0.0-alpha.20 → 1.0.0-alpha.22

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 (112) hide show
  1. package/CHANGELOG.md +63 -0
  2. package/LICENSE.md +206 -141
  3. package/README.md +21 -4
  4. package/dist/config/index.d.ts +199 -6
  5. package/dist/packem_chunks/bin.js +318 -318
  6. package/dist/packem_chunks/bloom-status.js +2 -0
  7. package/dist/packem_chunks/bloom-sync.js +2 -0
  8. package/dist/packem_chunks/cache-attestation.js +1 -0
  9. package/dist/packem_chunks/config.js +15 -15
  10. package/dist/packem_chunks/fix.js +1 -1
  11. package/dist/packem_chunks/handler.js +1 -1
  12. package/dist/packem_chunks/handler10.js +2 -1
  13. package/dist/packem_chunks/handler11.js +1 -5
  14. package/dist/packem_chunks/handler12.js +5 -1
  15. package/dist/packem_chunks/handler13.js +1 -27
  16. package/dist/packem_chunks/handler14.js +28 -5
  17. package/dist/packem_chunks/handler15.js +5 -1
  18. package/dist/packem_chunks/handler16.js +1 -1
  19. package/dist/packem_chunks/handler17.js +1 -1
  20. package/dist/packem_chunks/handler18.js +1 -1
  21. package/dist/packem_chunks/handler19.js +1 -1
  22. package/dist/packem_chunks/handler2.js +4 -2
  23. package/dist/packem_chunks/handler20.js +1 -5
  24. package/dist/packem_chunks/handler21.js +5 -2
  25. package/dist/packem_chunks/handler22.js +2 -2
  26. package/dist/packem_chunks/handler23.js +2 -18
  27. package/dist/packem_chunks/handler24.js +18 -1
  28. package/dist/packem_chunks/handler25.js +1 -1
  29. package/dist/packem_chunks/handler26.js +1 -5
  30. package/dist/packem_chunks/handler27.js +5 -1
  31. package/dist/packem_chunks/handler28.js +1 -3
  32. package/dist/packem_chunks/handler29.js +3 -1
  33. package/dist/packem_chunks/handler3.js +4 -4
  34. package/dist/packem_chunks/handler30.js +1 -7
  35. package/dist/packem_chunks/handler31.js +6 -32
  36. package/dist/packem_chunks/handler32.js +33 -3
  37. package/dist/packem_chunks/handler33.js +3 -1
  38. package/dist/packem_chunks/handler34.js +1 -26
  39. package/dist/packem_chunks/handler35.js +26 -3
  40. package/dist/packem_chunks/handler36.js +5 -7
  41. package/dist/packem_chunks/handler37.js +6 -6
  42. package/dist/packem_chunks/handler38.js +1 -1
  43. package/dist/packem_chunks/handler39.js +61 -6
  44. package/dist/packem_chunks/handler4.js +6 -8
  45. package/dist/packem_chunks/handler40.js +6 -24
  46. package/dist/packem_chunks/handler41.js +215 -10
  47. package/dist/packem_chunks/handler42.js +24 -153
  48. package/dist/packem_chunks/handler43.js +153 -25
  49. package/dist/packem_chunks/handler44.js +10 -24
  50. package/dist/packem_chunks/handler45.js +25 -213
  51. package/dist/packem_chunks/handler46.js +24 -3
  52. package/dist/packem_chunks/handler47.js +3 -27
  53. package/dist/packem_chunks/handler48.js +21 -161
  54. package/dist/packem_chunks/handler49.js +173 -33
  55. package/dist/packem_chunks/handler5.js +8 -1
  56. package/dist/packem_chunks/handler50.js +34 -0
  57. package/dist/packem_chunks/handler6.js +1 -1
  58. package/dist/packem_chunks/handler7.js +1 -1
  59. package/dist/packem_chunks/handler8.js +1 -1
  60. package/dist/packem_chunks/handler9.js +1 -2
  61. package/dist/packem_chunks/heal-accept.js +1 -1
  62. package/dist/packem_chunks/heal.js +1 -1
  63. package/dist/packem_chunks/help-command.js +16 -16
  64. package/dist/packem_chunks/index.js +2 -2
  65. package/dist/packem_chunks/keys-refresh.js +1 -1
  66. package/dist/packem_chunks/list.js +1 -1
  67. package/dist/packem_chunks/loader.js +4 -1
  68. package/dist/packem_chunks/loader2.js +1 -0
  69. package/dist/packem_chunks/prune.js +1 -1
  70. package/dist/packem_chunks/run.js +1 -1
  71. package/dist/packem_chunks/status.js +1 -1
  72. package/dist/packem_chunks/sync.js +1 -1
  73. package/dist/packem_chunks/sync2.js +1 -1
  74. package/dist/packem_chunks/verify-lockfile.js +2 -0
  75. package/dist/packem_shared/{advisories-DsynpacV.js → advisories-DS8JEB_g.js} +1 -1
  76. package/dist/packem_shared/{ai-analysis-uYuTIIXi.js → ai-analysis-DGBZYlxF.js} +1 -1
  77. package/dist/packem_shared/{ai-cache-DuwHYx2O.js → ai-cache-BjlXWJtl.js} +1 -1
  78. package/dist/packem_shared/{ai-fix-DzrA-dVz.js → ai-fix-BhcTrkuW.js} +6 -6
  79. package/dist/packem_shared/cyclonedx-CO7-Y1B1.js +4 -0
  80. package/dist/packem_shared/dependency-scan-DPHTzA5r.js +1 -0
  81. package/dist/packem_shared/docker-lk0-5Z-i.js +60 -0
  82. package/dist/packem_shared/{failure-log-C3LEMmkq.js → failure-log-DF7nrFIs.js} +1 -1
  83. package/dist/packem_shared/{flakiness-Dq6K4ymq.js → flakiness-DKCOYwN7.js} +1 -1
  84. package/dist/packem_shared/index-B4gpNmrG.js +1 -0
  85. package/dist/packem_shared/license-zZU7aavK.js +1 -0
  86. package/dist/packem_shared/{lifecycle-Dv3nAtoD.js → lifecycle-boYwVQSE.js} +2 -2
  87. package/dist/packem_shared/{min-release-age-BFozFonQ.js → min-release-age-D462DvYM.js} +1 -1
  88. package/dist/packem_shared/{native-config-sync-Dvi1g2nQ.js → native-config-sync-B0_ef78M.js} +9 -9
  89. package/dist/packem_shared/osv-bloom-QSAn2Dcw.js +2 -0
  90. package/dist/packem_shared/provenance-smHa8efI.js +1 -0
  91. package/dist/packem_shared/{registry-keys-CewRFW0e.js → registry-keys-3qaVog76.js} +1 -1
  92. package/dist/packem_shared/resolve-explicit-BgFQHUEP.js +5 -0
  93. package/dist/packem_shared/{run-summary-utils-BaBGP3bo.js → run-summary-utils-DIJV_dUD.js} +1 -1
  94. package/dist/packem_shared/runtime-check-DrMx4Q9L.js +1 -0
  95. package/dist/packem_shared/s1ngularity-CwSBPB3I.js +1 -0
  96. package/dist/packem_shared/signatures-b-jJYoZd.js +2 -0
  97. package/dist/packem_shared/toolchain-OH1PXwbZ.js +5 -0
  98. package/dist/packem_shared/{typosquats-BCeR-sLf.js → typosquats-CJ4o1l7U.js} +1 -1
  99. package/dist/packem_shared/{verify-07kUNTuP.js → verify-CQbzknur.js} +1 -1
  100. package/dist/packem_shared/{vis-update-app-CFrlJ3mW.js → vis-update-app-Bnu1EIgE.js} +1 -1
  101. package/index.d.ts +78 -0
  102. package/index.js +57 -53
  103. package/package.json +22 -12
  104. package/schemas/project.schema.json +37 -7
  105. package/schemas/vis-config.schema.json +2376 -2026
  106. package/dist/packem_shared/cyclonedx-CiHXuG8M.js +0 -4
  107. package/dist/packem_shared/dependency-scan-DC3nAFHS.js +0 -1
  108. package/dist/packem_shared/docker-B-CIN_nj.js +0 -60
  109. package/dist/packem_shared/resolve-explicit-CC4Kifk5.js +0 -5
  110. package/dist/packem_shared/runtime-check-BusAwPb2.js +0 -1
  111. package/dist/packem_shared/signatures-5ZdjJ2Pu.js +0 -2
  112. package/dist/packem_shared/toolchain-Cc3cwyLP.js +0 -5
@@ -1,3 +1,26 @@
1
- var M=Object.defineProperty;var R=(e,o)=>M(e,"name",{value:o,configurable:!0});import{createRequire as j}from"node:module";import{ay as _,az as v,aA as C,aB as B,aC as A,aD as p,aE as D,aF as V,aG as N,aH as F,aI as P,aJ as K,aK as O,aL as q,aM as Q,aN as G,aO as L,aP as W}from"./bin.js";import{M as J,i as b,Q as Y,$ as E,B as $}from"./config.js";import{v as U}from"../packem_shared/verify-07kUNTuP.js";const T=j(import.meta.url),y=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,I=R(e=>{if(typeof y<"u"&&y.versions&&y.versions.node){const[o,i]=y.versions.node.split(".").map(Number);if(o>22||o===22&&i>=3||o===20&&i>=16)return y.getBuiltinModule(e)}return T(e)},"__cjs_getBuiltinModule"),{stdin:x,stdout:z}=y,{createInterface:H}=I("node:readline/promises");var X=Object.defineProperty,Z=R((e,o)=>X(e,"name",{value:o,configurable:!0}),"n");const S=Z(async e=>{if(!x.isTTY)return!0;const o=H({input:x,output:z});try{const i=(await o.question(`${e} [Y/n] `)).trim().toLowerCase();return i===""||i==="y"||i==="yes"}finally{o.close()}},"confirm");var ee=Object.defineProperty,k=R((e,o)=>ee(e,"name",{value:o,configurable:!0}),"p");const te=[{description:"VisConfig.targetDefaults → VisConfig.tasks",next:"tasks",previous:"targetDefaults"},{description:"VisConfig.taskDefaults → VisConfig.scopedTasks",next:"scopedTasks",previous:"taskDefaults"},{description:"VisConfig.taskRunnerOptions → VisConfig.taskRunner",next:"taskRunner",previous:"taskRunnerOptions"},{description:"ScopedTasksBlock.scope → ScopedTasksBlock.match",next:"match",previous:"scope"},{description:"ScopedTasksBlock.targets ScopedTasksBlock.tasks",next:"tasks",previous:"targets"}],oe=[{description:"VisTaskConfig.targets → VisTaskConfig.tasks",next:"tasks",previous:"targets"}],ie=k(e=>new RegExp(String.raw`(^|[\s,{(\[])(["']?)${e}\2(\s*:)`,"gmu"),"buildKeyRegex"),re=k((e,o)=>{let i=e;const r=[];for(const t of o){const d=ie(t.previous);d.test(i)&&(d.lastIndex=0,i=i.replace(d,(s,c,a,g)=>`${c}${a}${t.next}${a}${g}`),r.push(t))}return{applied:r,output:i}},"applyRenames"),h=k((e,o)=>re(e,o),"rewriteSource"),ne=["vis.config.ts","vis.config.mts","vis.config.cts","vis.config.js","vis.config.mjs","vis.config.cjs"],se=new Set(["vis.task.cjs","vis.task.cts","vis.task.js","vis.task.mjs","vis.task.mts","vis.task.ts"]),ae=k(e=>{for(const o of ne){const i=J(e,o);if(b(i))return i}},"findConfigFile"),ce=k(e=>{const o=[];try{for(const i of _(e,{includeDirs:!1,includeFiles:!0,includeSymlinks:!1,skip:[/node_modules/,/\.git/,/\.vis\b/,/dist\b/,/\.next\b/,/\.nuxt\b/]}))se.has(Y(i.path))&&o.push(i.path)}catch{}return o},"findTaskConfigFiles"),ge=k((e,o,i,r)=>{const t=ae(e);if(t){const s=E(t),{applied:c,output:a}=h(s,te);if(c.length===0)i.info(`${t} already uses the current schema no rewrite needed.`);else if(o.dryRun)i.info(`── ${t} (preview) ──`),i.info(a),i.info("── end preview ──"),i.info(`Would apply ${String(c.length)} rename(s): ${c.map(g=>g.description).join(", ")}`);else{v(t,r),$(t,a),i.info(`Rewrote ${t} (backup at ${t}.bak). Applied ${String(c.length)} rename(s).`);for(const g of c)r.manualSteps.push(`Renamed ${g.description} in ${t}`)}}else i.warn("No vis.config.ts found at workspace root — nothing to migrate."),r.warnings.push("No vis.config.{ts,mts,cts,js,mjs,cjs} at workspace root.");const d=o.taskConfigPaths??ce(e);for(const s of d){if(!b(s))continue;const c=E(s),a=h(c,oe);if(a.applied.length!==0)if(o.dryRun)i.info(`── ${s} (preview) ──`),i.info(a.output),i.info("── end preview ──"),i.info(`Would apply ${String(a.applied.length)} rename(s): ${a.applied.map(g=>g.description).join(", ")}`);else{v(s,r),$(s,a.output),i.info(`Rewrote ${s} (backup at ${s}.bak). Applied ${String(a.applied.length)} rename(s).`);for(const g of a.applied)r.manualSteps.push(`Renamed ${g.description} in ${s}`)}}},"migrateSelf");var pe=Object.defineProperty,n=R((e,o)=>pe(e,"name",{value:o,configurable:!0}),"r");const f=n(e=>{const o=e.workspaceRoot??process.cwd(),i=e.visConfig??{};return{config:i,dryRun:!!e.options.dryRun,logger:e.logger,packageManager:B(o),report:C(),root:o,useEditorconfig:typeof i.editorconfig=="boolean"?i.editorconfig:!0}},"buildContext"),u=n(async(e,o,i)=>{if(o.yes||o.dryRun)return!0;const r=await S(`This will edit files, scripts, and hooks for "${e}". Backups (.bak) will be created. Continue?`);return r||i.info("Aborted."),r},"maybeConfirm"),l=n(e=>{e.dryRun&&e.logger.info(`Running in dry-run mode — no changes will be made.
2
- `)},"announceDryRun"),fe=n(async({logger:e,options:o,visConfig:i,workspaceRoot:r})=>{if(!await u("deps",o,e))return;const t=f({logger:e,options:o,visConfig:i,workspaceRoot:r});l(t),e.info("── Migrating dependencies and scripts ──"),A(t.root,t.packageManager,t.config,{dryRun:t.dryRun},e,t.report),e.info(""),p(t.report,e)},"migrateDepsExecuteImpl"),ue=n(async({logger:e,options:o,visConfig:i,workspaceRoot:r})=>{if(!await u("lint-staged",o,e))return;const t=f({logger:e,options:o,visConfig:i,workspaceRoot:r});l(t),e.info("── Migrating lint-staged ──"),D(t.root,{dryRun:t.dryRun,useEditorconfig:t.useEditorconfig},e,t.report),e.info(""),p(t.report,e)},"migrateLintStagedExecuteImpl"),le=n(async({logger:e,options:o,visConfig:i,workspaceRoot:r})=>{if(!await u("nano-staged",o,e))return;const t=f({logger:e,options:o,visConfig:i,workspaceRoot:r});l(t),e.info("── Migrating nano-staged ──"),V(t.root,{dryRun:t.dryRun,useEditorconfig:t.useEditorconfig},e,t.report),e.info(""),p(t.report,e)},"migrateNanoStagedExecuteImpl"),de=n(async({logger:e,options:o,visConfig:i,workspaceRoot:r})=>{if(!await u("turborepo",o,e))return;const t=f({logger:e,options:o,visConfig:i,workspaceRoot:r});l(t),e.info("── Migrating turborepo ──"),N(t.root,{dryRun:t.dryRun,useEditorconfig:t.useEditorconfig},e,t.report),e.info(""),p(t.report,e)},"migrateTurborepoExecuteImpl"),me=n(async({logger:e,options:o,visConfig:i,workspaceRoot:r})=>{if(!await u("nx",o,e))return;const t=f({logger:e,options:o,visConfig:i,workspaceRoot:r});l(t),e.info("── Migrating nx ──"),F(t.root,{dryRun:t.dryRun,force:!!o.force,useEditorconfig:t.useEditorconfig},e,t.report),e.info(""),p(t.report,e)},"migrateNxExecuteImpl"),ye=n(async({logger:e,options:o,visConfig:i,workspaceRoot:r})=>{if(!await u("moon",o,e))return;const t=f({logger:e,options:o,visConfig:i,workspaceRoot:r});l(t),e.info("── Migrating moon ──"),P(t.root,{copyTemplates:!!o.copyTemplates,dryRun:t.dryRun,useEditorconfig:t.useEditorconfig},e,t.report),e.info(""),p(t.report,e)},"migrateMoonExecuteImpl"),ke=n(async({logger:e,options:o,visConfig:i,workspaceRoot:r})=>{if(!await u("gitleaks",o,e))return;const t=f({logger:e,options:o,visConfig:i,workspaceRoot:r});l(t),e.info("── Migrating gitleaks ──"),K(t.root,{dryRun:t.dryRun,useEditorconfig:t.useEditorconfig},e,t.report),e.info(""),p(t.report,e)},"migrateGitleaksExecuteImpl"),Re=n(async({logger:e,options:o,visConfig:i,workspaceRoot:r})=>{if(!await u("kingfisher",o,e))return;const t=f({logger:e,options:o,visConfig:i,workspaceRoot:r});l(t),e.info("── Migrating Kingfisher ──"),O(t.root,{dryRun:t.dryRun,useEditorconfig:t.useEditorconfig},e,t.report),e.info(""),p(t.report,e)},"migrateKingfisherExecuteImpl"),we=n(async({logger:e,options:o,visConfig:i,workspaceRoot:r})=>{if(!await u("secretlint",o,e))return;const t=f({logger:e,options:o,visConfig:i,workspaceRoot:r});l(t),e.info("── Migrating secretlint ──"),q(t.root,{dryRun:t.dryRun,useEditorconfig:t.useEditorconfig},e,t.report),e.info(""),p(t.report,e)},"migrateSecretlintExecuteImpl"),ve=n(async({logger:e,options:o,visConfig:i,workspaceRoot:r})=>{if(!await u("syncpack",o,e))return;const t=f({logger:e,options:o,visConfig:i,workspaceRoot:r});l(t),e.info("── Migrating syncpack ──"),Q(t.root,{dryRun:t.dryRun,useEditorconfig:t.useEditorconfig},e,t.report),e.info(""),p(t.report,e)},"migrateSyncpackExecuteImpl"),xe=n(async({logger:e,options:o,visConfig:i,workspaceRoot:r})=>{if(!await u("sherif",o,e))return;const t=f({logger:e,options:o,visConfig:i,workspaceRoot:r});l(t),e.info("── Migrating sherif ──"),G(t.root,{dryRun:t.dryRun,useEditorconfig:t.useEditorconfig},e,t.report),e.info(""),p(t.report,e)},"migrateSherifExecuteImpl"),Ee=n(async({logger:e,options:o,visConfig:i,workspaceRoot:r})=>{if(!await u("self",o,e))return;const t=f({logger:e,options:o,visConfig:i,workspaceRoot:r});l(t),e.info("── Migrating vis.config.ts to current schema ──"),ge(t.root,{dryRun:t.dryRun},e,t.report),e.info(""),p(t.report,e)},"migrateSelfExecuteImpl"),$e=n(({logger:e,workspaceRoot:o})=>{const i=o??process.cwd();U(i,e).length>0&&(process.exitCode=1)},"migrateVerifyExecuteImpl"),he=n(async({logger:e,options:o,visConfig:i,workspaceRoot:r})=>{const t=r??process.cwd(),d=L(t,i??{}),s=W(d);if(s.length===0){e.info("No applicable migrations detected in this workspace.");return}const c=!!o.dryRun;e.info(`Detected ${String(s.length)} migration(s):`);for(const m of s)e.info(` • ${m.title} — ${m.description}`);if(e.info(""),!o.yes&&!c&&!await S("Apply all detected migrations? Backups (.bak) will be created.")){e.info("Aborted.");return}c&&e.info(`Running in dry-run mode — no changes will be made.
3
- `);const a=C(),g=[];for(const m of s)try{if(e.info(`── Applying ${m.title} ──`),c)for(const w of m.probe(d))e.info(w);else m.apply(d,a,e);e.info("")}catch(w){g.push({error:w,id:m.id}),e.warn(`Failed to apply ${m.title}: ${w.message}`)}p(a,e),g.length>0&&(e.warn(""),e.warn(`${String(g.length)} migration(s) failed — see messages above.`),process.exitCode=1)},"migrateAllExecuteImpl"),Te=fe,Ie=ue,_e=le,Be=de,Ae=me,De=ye,Ve=ke,Ne=Re,Fe=we,Pe=ve,Ke=xe,Oe=Ee,qe=$e,Qe=he;export{Qe as migrateAllExecute,Te as migrateDepsExecute,Ve as migrateGitleaksExecute,Ne as migrateKingfisherExecute,Ie as migrateLintStagedExecute,De as migrateMoonExecute,_e as migrateNanoStagedExecute,Ae as migrateNxExecute,Fe as migrateSecretlintExecute,Oe as migrateSelfExecute,Ke as migrateSherifExecute,Pe as migrateSyncpackExecute,Be as migrateTurborepoExecute,qe as migrateVerifyExecute};
1
+ var Se=Object.defineProperty;var D=(e,t)=>Se(e,"name",{value:t,configurable:!0});import{createRequire as Ae}from"node:module";import{aq as Te,o as oe,ar as Ne,F as N,e as z,as as Me,W as Ue,G as je,H as me,at as Fe,au as fe,i as X,d as qe,R as _e,b as Be,V as Le,av as Oe,K as Pe,aw as Ie,s as he,a as ve,U as De,ax as We,ay as Ve,az as ze,g as Ge,aA as He}from"./bin.js";import{M as W,i as V,$ as Ye}from"./config.js";import{render as re,renderToString as Q}from"@visulima/tui";import{Text as C}from"@visulima/tui/components/text";import k from"react";import{H as Ze,e as Je,Z as ie}from"../packem_shared/ai-analysis-DGBZYlxF.js";import{r as Ke,b as Xe,p as Qe}from"../packem_shared/resolve-explicit-BgFQHUEP.js";import{r as et,s as tt}from"../packem_shared/typosquats-CJ4o1l7U.js";import{U as nt,C as at,a as le}from"../packem_shared/vis-update-app-Bnu1EIgE.js";import{d as st}from"../packem_shared/utils-DrNg0XTR.js";const xe=Ae(import.meta.url),q=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,pe=D(e=>{if(typeof q<"u"&&q.versions&&q.versions.node){const[t,n]=q.versions.node.split(".").map(Number);if(t>22||t===22&&n>=3||t===20&&n>=16)return q.getBuiltinModule(e)}return xe(e)},"__cjs_getBuiltinModule"),{execFileSync:ge}=pe("node:child_process"),{createInterface:Ee}=pe("node:readline");var ot=Object.defineProperty,x=D((e,t)=>ot(e,"name",{value:t,configurable:!0}),"s");const rt=x(e=>{const t=[];for(const n of e.filters)t.push("--filter",n);return e.workspaceRoot&&t.push("--filter","."),t.push("update"),e.latest&&t.push("--latest"),e.recursive&&t.push("--recursive"),e.interactive&&t.push("--interactive"),e.dev&&t.push("--dev"),e.prod&&t.push("--prod"),e.noOptional&&t.push("--no-optional"),e.noSave&&t.push("--no-save"),t.push(...e.packages),{args:t,bin:"pnpm"}},"resolvePnpm"),it=x(e=>{const t=[];return e.filters.length>0&&t.push("workspace",e.filters[0]),t.push("upgrade"),e.latest&&t.push("--latest"),t.push(...e.packages),{args:t,bin:"yarn"}},"resolveYarnV1"),lt=x(e=>{const t=[];if(e.filters.length>0||e.recursive){t.push("workspaces","foreach","--all");for(const n of e.filters)t.push("--include",n)}return t.push("up"),e.interactive&&t.push("--interactive"),t.push(...e.packages),{args:t,bin:"yarn"}},"resolveYarnBerry"),ct=x((e,t)=>{const n=["update"];e.latest&&t.push("npm does not support --latest flag. Packages will be updated within their semver range."),e.interactive&&t.push("npm does not support --interactive mode.");for(const a of e.filters)n.push("--workspace",a);return e.recursive&&n.push("--workspaces"),e.workspaceRoot&&n.push("--include-workspace-root"),e.dev&&n.push("--dev"),e.prod&&n.push("--production"),e.noOptional&&n.push("--no-optional"),e.noSave&&n.push("--no-save"),n.push(...e.packages),{args:n,bin:"npm"}},"resolveNpm"),ut=x(e=>{const t=["update"];e.latest&&t.push("--latest");for(const n of e.filters)t.push("--filter",n);return t.push(...e.packages),{args:t,bin:"bun"}},"resolveBun"),dt=x((e,t)=>{const n=["outdated","--update"];return e.latest&&n.push("--latest"),e.interactive&&n.push("--interactive"),e.filters.length>0&&t.push("deno outdated has no --filter flag; ignoring."),(e.dev||e.prod)&&t.push("deno outdated has no --dev / --prod flags; dev/prod is governed by deno.json."),e.noOptional&&t.push("deno outdated has no --no-optional flag; ignoring."),e.noSave&&t.push("deno outdated has no --no-save flag; ignoring."),n.push(...e.packages),{args:n,bin:"deno"}},"resolveDeno"),pt=x((e,t,n)=>{const a=[];if(n.global&&e!=="aube"&&e!=="deno")return{command:{args:["update","--global",...n.packages],bin:"npm"},warnings:a};let o;switch(e){case"aube":{const s=Te(n);o={args:s.args,bin:s.bin},a.push(...s.warnings);break}case"bun":{o=ut(n);break}case"deno":{o=dt(n,a);break}case"npm":{o=ct(n,a);break}case"pnpm":{o=rt(n);break}case"yarn":{o=t.startsWith("1.")?it(n):lt(n);break}default:{const s=e;throw new Error(`Unsupported package manager: ${String(s)}`)}}return{command:o,warnings:a}},"resolveUpdateCommand");var gt=Object.defineProperty,$=D((e,t)=>gt(e,"name",{value:t,configurable:!0}),"y");const $e=$(e=>{const t=e.trim();if(t==="")return;const n=/^(\d+(?:\.\d+)?)\s*([mhdw])?$/i.exec(t);if(!n)return;const a=Number.parseFloat(n[1]);if(!(!Number.isFinite(a)||a<0))switch((n[2]??"m").toLowerCase()){case"d":return a*60*24;case"h":return a*60;case"m":return a;case"w":return a*60*24*7;default:return}},"parseTimeStringToMinutes"),mt=$(e=>{const t=e.trim();return/^\d+(?:\.\d+)?$/.test(t)?Number.parseFloat(t)*1440:$e(t)},"parseNpmReleaseAgeValue"),Ut=$(e=>!Number.isFinite(e)||e<=0?"0m":e%1440===0?`${String(e/1440)}d`:e%60===0?`${String(e/60)}h`:`${String(e)}m`,"formatMinutesAsTimeString"),ft=$((e,t)=>{try{switch(t){case"bun":{const n=W(e,"bunfig.toml");if(V(n)){const a=Ne(n),o=a?.install?.minimumReleaseAge;return{excludes:Array.isArray(a?.install?.minimumReleaseAgeExcludes)?a.install.minimumReleaseAgeExcludes:void 0,minutes:typeof o=="number"?Math.round(o/60):void 0}}break}case"npm":{const n=W(e,".npmrc");if(V(n)){const a=Ye(n),o=/^\s*min-release-age\s*=\s*([^\s#;]+)/m.exec(a);return{minutes:o?mt(o[1]):void 0}}break}case"pnpm":{const n=W(e,"pnpm-workspace.yaml");if(V(n)){const a=oe(n);return{excludes:Array.isArray(a?.minimumReleaseAgeExclude)?a.minimumReleaseAgeExclude:void 0,minutes:typeof a?.minimumReleaseAge=="number"?a.minimumReleaseAge:void 0}}break}case"yarn":{const n=W(e,".yarnrc.yml");if(V(n)){const a=oe(n)?.npmMinimalAgeGate;if(typeof a=="string")return{minutes:$e(a)};if(typeof a=="number")return{minutes:a}}break}}}catch{}return{}},"readPmNativeMinimumReleaseAge"),ht=$((e,t,n)=>{const a=e.latest?"latest":e.target??t.target??"latest";if(!["latest","minor","patch"].includes(a))throw new Error(`Invalid target "${a}". Use: latest, minor, or patch.`);const o=e.maxConcurrentRequests,s=typeof o=="number"&&o>0?o:t.maxConcurrentRequests,i=typeof e.releaseChannel=="string"?e.releaseChannel.toLowerCase():void 0;if(i!==void 0&&!["any","same","stable"].includes(i))throw new Error(`Invalid --release-channel "${String(e.releaseChannel)}". Use: any, same, or stable.`);const p=i??t.releaseChannel;return{exclude:[...N(e.exclude),...N(t.exclude)],ignore:N(t.ignore),include:[...N(e.include),...N(t.include),...n],includeLocked:e.includeLocked||t.includeLocked||!1,includePrerelease:e.prerelease||t.prerelease||!1,maxConcurrentRequests:s,minimumReleaseAge:t.minimumReleaseAge,minimumReleaseAgeExclude:t.minimumReleaseAgeExclude,packageMode:t.packageMode,releaseChannel:p,security:e.security===!1?!1:e.ai||(t.security??!0),target:a}},"buildCatalogCheckOptions"),ce=$((e,t)=>{if(e.length!==0){t.info(`
2
+ ${z("")} ${String(e.length)} package${e.length===1?"":"s"} skipped by target constraint (use --target latest to include):`);for(const n of e)t.info(` ${n.packageName} ${n.currentRange} ${n.newRange} (${n.updateType})`)}},"logFilteredByTarget"),ue=$((e,t,n,a,o)=>{n==="json"?process.stdout.write(`${Me({checkedCount:0,failed:t,filteredByTarget:[],ignored:[],outdated:e})}
3
+ `):n==="minimal"?process.stdout.write(`${Ue(e)}
4
+ `):(je(e,a),a.info(me(e,o)))},"writeFormattedOutput"),de=$(async(e,t,n,a,o,s,i)=>{const p=Fe(e,n,t,!0,{useEditorconfig:i}),g=t==="pnpm"?"pnpm-workspace.yaml":"package.json";if(o.info(`
5
+ Updated ${g}`),p&&o.info(`Backup saved to ${p}`),a.changelog){o.info(`
6
+ Fetching changelogs...`);const m=await fe(n,void 0,s);for(const l of m){const f=l.releaseUrl??l.repoUrl??l.npmUrl;o.info(` ${l.packageName}: ${f}`)}}if(a.install??!0){const m=t,l=["install"];o.info(`Running ${m} ${l.join(" ")}...
7
+ `);try{ge(m,l,{cwd:e,env:process.env,stdio:"inherit"})}catch{o.warn(`${m} ${l.join(" ")} failed. You may need to run it manually.`)}}},"applyCatalogAndInstall"),vt=$(async(e,t,n,a,o,s)=>{const i=n.update??{},p=[["global","--global is not supported in catalog mode"],["recursive","--recursive is not needed in catalog mode (catalogs are workspace-level)"],["filter","--filter is not supported in catalog mode (use --include/--exclude instead)"],["no-save","--no-save is not supported in catalog mode"],["workspace-root","--workspace-root is not needed in catalog mode"],["no-optional","--no-optional is not supported in catalog mode"]];for(const[r,c]of p)a[r]&&s.warn(`${z("⚠")} ${c}, ignoring.`);const g=X("minReleaseAge"),{excludes:m,minutes:l}=g?{excludes:void 0,minutes:void 0}:ft(e,t),f=g?void 0:i.minimumReleaseAge??l,_=g?void 0:i.minimumReleaseAgeExclude??m;if(g&&(i.minimumReleaseAge!==void 0||l!==void 0)&&s.info("minimumReleaseAge gate disabled via MARSHALL_DISABLE_MIN_RELEASE_AGE."),!g&&i.minimumReleaseAge!==void 0&&l!==void 0&&i.minimumReleaseAge!==l){const r=t==="pnpm"?"pnpm-workspace.yaml":"bunfig.toml";s.warn(`${z("⚠")} minimumReleaseAge mismatch: vis config = ${String(i.minimumReleaseAge)} min, ${r} = ${String(l)} min. Consider keeping them in sync.`)}const b=qe(e),ee=a["include-internal"],te=a.peer,M=_e(e,t,{depFields:i.depFields,dev:a.dev,includeInternal:ee,peer:te,prod:a.prod});if(M.size===0){s.info("No catalogs found.");return}const ke={...i,minimumReleaseAge:f,minimumReleaseAgeExclude:_},E=ht(a,ke,o);let G=0;for(const r of M.values())G+=r.size;const B=!!process.stdout.isTTY&&!he;let T;const we=B?(r,c)=>{T?T.rerender(k.createElement(le,{current:r,total:c})):(process.stdout.write(`
8
+ `),T=re(k.createElement(le,{current:r,total:c}),{interactive:!0,patchConsole:!1}))}:(r,c)=>{s.info(`Checking ${String(r)}/${String(c)} dependencies...`)};B||s.info(`Checking ${String(G)} catalog dependencies...
9
+ `);const H=new Set;X("socket")&&H.add("socket"),X("depsDev")&&H.add("deps-dev");const L=n.security?.policies?.score?.minimum,ye=Be(n.security,{disabled:H,minimumScore:L}),{checkedCount:w,failed:y,filteredByTarget:h,ignored:S,outdated:d}=await Le(M,E,b,we,e,ye,n.security?.acceptedRisks);T&&(T.clear(),T.unmount());const O=ee?{ignored:[],outdated:[]}:Oe(e,{depFields:i.depFields,dev:a.dev,exclude:E.exclude,ignore:E.ignore,include:E.include,packageMode:E.packageMode,peer:te,prod:a.prod,target:E.target});if(O.outdated.length>0){const r=new Set(d.map(c=>`${c.catalogName}|${c.packageName}`));for(const c of O.outdated)r.has(`${c.catalogName}|${c.packageName}`)||d.push(c)}if(O.ignored.length>0)for(const r of O.ignored)S.includes(r)||S.push(r);const ne=w-d.length-y.length;if(y.length>0&&s.warn(`Failed to fetch: ${y.join(", ")}`),S.length>0&&s.info(`Skipped ${String(S.length)} ignored package${S.length===1?"":"s"}: ${S.join(", ")}`),!B&&w>d.length){const r=[...M.values()].reduce((F,Y)=>F+Y.size,0),c=r>w?` (${String(r)} catalog entries, ${String(r-w)} duplicates)`:"";s.info(`Checked ${String(w)} unique packages${c}: ${String(d.length)} outdated, ${String(ne)} up-to-date${y.length>0?`, ${String(y.length)} failed`:""}${h.length>0?`, ${String(h.length)} skipped by target`:""}`)}if(d.length===0){h.length>0?s.info(`All catalog dependencies are up to date within the current target.
10
+ ${String(h.length)} package${h.length===1?" has":"s have"} newer versions available with --target latest:
11
+ ${h.map(r=>` ${r.packageName} ${r.currentRange} → ${r.newRange} (${r.updateType})`).join(`
12
+ `)}`):s.info("All catalog dependencies are up to date.");return}const U=a.format??i.format??"table";let R;if(a.ai){const r=Ze(a.aiType??"impact");R=await Je(d,s,n.ai,r)}const P=!!a.dryRun;if(!P&&o.length>0&&a.marshallCheck!==!1){const r=await Ke(o);if(r.length>0){const c=await Xe(r,{config:n?.security?.marshalls,workspaceRoot:e});if(!await Qe(c)){process.exitCode=1;return}}}if(B&&U==="table"){const r=new nt(d,R??null);let c;if(a.changelog){s.info("Fetching changelogs...");const u=await fe(d,void 0,b);c=new Map;for(const v of u){const A=v.releaseUrl??v.repoUrl??v.npmUrl;A&&c.set(v.packageName,A)}}const F=n.tui?.autoExit??!1,Y=F===!0?3:typeof F=="number"?F:0,ae=await re(k.createElement(at,{autoExitSeconds:Y,changelogUrls:c,checkedCount:w,filteredOutEntries:h,isDryRun:P,store:r,totalCatalogEntries:G}),{alternateScreen:!0,exitOnCtrlC:!1,interactive:!0,patchConsole:!0}).waitUntilExit(),Z=process.stdout.columns||80;process.stdout.write(`
13
+ `);for(const u of d){const v=u.vulnerabilities?.length||u.socketReport&&u.socketReport.alerts.length>0,A=!!u.acceptedRisk,K=v?A?"✓":"⚠":"✓",Re=A?"gray":u.updateType==="major"?"red":u.updateType==="minor"?"yellow":"green",I=u.socketReport?.score.overall,Ce=I===void 0?"":` [${String(Math.round(I*100))}%]`,se=I===void 0?void 0:Pe(I);process.stdout.write(`${Q(k.createElement(C,null," ",k.createElement(C,{color:Re},K),` ${u.packageName} ${u.currentRange} → ${u.newRange}`,k.createElement(C,{dimColor:!0},` ${u.updateType}`),se?k.createElement(C,{color:se},Ce):null),{columns:Z})}
14
+ `)}if(process.stdout.write(`
15
+ `),s.info(me(d,L)),w>d.length){const u=[...M.values()].reduce((A,K)=>A+K.size,0),v=u>w?` (${String(u)} catalog entries, ${String(u-w)} duplicates)`:"";s.log(),s.info(`Checked ${String(w)} unique packages${v}: ${String(ne)} up-to-date${y.length>0?`, ${String(y.length)} failed`:""}`)}if(h.length>0){process.stdout.write(`
16
+ `);const u=`${String(h.length)} package${h.length===1?"":"s"} skipped by target constraint (use --target latest to include):`;process.stdout.write(`${Q(k.createElement(C,{color:"yellow"},` ${u}`),{columns:Z})}
17
+ `);for(const v of h)process.stdout.write(`${Q(k.createElement(C,null," ",k.createElement(C,{dimColor:!0},v.packageName),` ${v.currentRange} → ${v.newRange}`,k.createElement(C,{dimColor:!0},` ${v.updateType}`)),{columns:Z})}
18
+ `)}const J=Array.isArray(ae)?ae:[];if(J.length>0&&!P){s.info(`
19
+ Applying ${String(J.length)} updates...
20
+ `);const u={...a,install:a.install??i.install};await de(e,t,J,u,s,b,n.editorconfig??!0)}return}if(P){if(U==="json"){const r={failed:y,filteredByTarget:h,ignored:S,outdated:d};R&&(r.aiAnalysis=R),process.stdout.write(`${JSON.stringify(r,void 0,2)}
21
+ `)}else s.info(`Would update ${String(d.length)} dependencies:
22
+ `),ue(d,y,U,s,L),R&&(s.info(""),s.info(ie(R))),ce(h,s);return}R&&U!=="json"&&(s.info(ie(R)),s.info(""));let j=d;if(a.interactive&&(j=await Ie(d),j.length===0)){s.info("No updates selected.");return}s.info(`Updating ${String(j.length)} catalog dependencies...
23
+ `),ue(j,[],U,s,L),ce(h,s);const be={...a,install:a.install??i.install};await de(e,t,j,be,s,b)},"executeCatalogUpdate"),$t=$((e,t,n,a,o,s)=>{const i={dev:a.dev,filters:N(a.filter),global:a.global,interactive:a.interactive,latest:a.latest||a.target==="latest",noOptional:a.optional===!1,noSave:a.save===!1,packages:o,prod:a.prod,recursive:a.recursive,workspaceRoot:a.workspaceRoot},{command:p,warnings:g}=pt(t,n,i);for(const l of g)s.warn(l);const m=`${p.bin} ${p.args.join(" ")}`.trim();if(a.dryRun){s.info(`Would run: ${m}`);return}s.info(`Running: ${m}`);try{ge(p.bin,p.args,{cwd:e,env:process.env,stdio:"inherit"})}catch(l){const f=l.status??1;s.error(`
24
+ ${ve("✖")} Update failed (exit code ${String(f)})`),s.error(` Command: ${m}`),s.error(` Directory: ${e}
25
+ `),process.exitCode=f}},"executePmWrapper"),kt=$(async(e,t,n)=>{const a=e.latest===!0||e.target==="latest";if(t||!a||e.dryRun===!0||e.yes===!0||e.interactive===!0)return!0;if(!(process.stdout.isTTY&&!he))return n.error(`${ve("✖")} Refusing to run blanket --latest update in a non-interactive context.`),n.error(" Re-run with --yes to confirm, --dry-run to preview, or pass explicit package names."),process.exitCode=1,!1;const o=Ee({input:process.stdin,output:process.stdout});try{const s=(await new Promise(i=>{o.question(`${z("⚠")} About to upgrade ALL dependencies to their latest versions. This may include breaking changes.
26
+ Continue? [y/N] `,i)})).trim().toLowerCase();return s==="y"||s==="yes"?!0:(n.info("Aborted."),!1)}finally{o.close()}},"requireBlanketUpdateConfirmation"),jt=$(async({argument:e,logger:t,options:n,visConfig:a,workspaceRoot:o})=>{if(!o)throw new Error("Could not determine workspace root. Run this command inside a monorepo.");let s=e;const i=o,{packageManager:p}=De(i);if(n.typosquatCheck!==!1){if(s.length>0){const g=s.map(f=>st(f)),m=a?.security?.typosquatAllowlist,l=await et(g.map(f=>f.name),m);if(!l.ok){process.exitCode=1;return}s=g.map((f,_)=>{const b=l.packages[_];return b!==f.name?f.versionSpec?`${b}@${f.versionSpec}`:b??"":s[_]??""})}else if(!await tt(i,a?.security?.typosquatAllowlist)){process.exitCode=1;return}}if(n.rollback){if(!We(i,p)){t.info("No backup found. Run 'vis update' first to create a backup.");return}if(Ve(i,p))t.info("Restored from backup.");else throw new Error("Failed to restore from backup.");return}if(await kt(n,s.length>0,t))if(n.catalog!==!1&&ze(i,p))await vt(i,p,a??{},n,s,t);else{const g=Ge(i,{configBackend:a?.install?.backend,configCorepack:a?.install?.corepack}),m=g.name==="aube"?"":He(g.name);$t(i,g.name,m,n,s,t)}},"execute");export{jt as default,Ut as formatMinutesAsTimeString,mt as parseNpmReleaseAgeValue,$e as parseTimeStringToMinutes,ft as readPmNativeMinimumReleaseAge,kt as requireBlanketUpdateConfirmation};
@@ -1,7 +1,5 @@
1
- var J=Object.defineProperty;var $=(e,o)=>J(e,"name",{value:o,configurable:!0});import{createRequire as T}from"node:module";import{$ as U,g as q,z as L,M as P,B as K,w as z}from"./config.js";import{o as V}from"../packem_shared/index-DH-5hsrC.js";import{aR as N,y as Y,aS as Q,ad as X}from"./bin.js";import{i as Z}from"../packem_shared/glob-MHJQjR39-CQ2GC0b_.js";import{n as ee}from"../packem_shared/manifests-B0fMp872.js";const W=T(import.meta.url),E=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,G=$(e=>{if(typeof E<"u"&&E.versions&&E.versions.node){const[o,n]=E.versions.node.split(".").map(Number);if(o>22||o===22&&n>=3||o===20&&n>=16)return E.getBuiltinModule(e)}return W(e)},"__cjs_getBuiltinModule"),{readFileSync:H}=G("node:fs");var oe=Object.defineProperty,j=$((e,o)=>oe(e,"name",{value:o,configurable:!0}),"c");const ne=j((e,o)=>{const n=o.replace(/^\.?\//,"");return n===""||n==="."?`/${e}/`:e===""||e==="."?`/${n}`:`/${e}/${n}`},"toWorkspacePath"),F=j((e,o,n=[])=>{const r=[],t=new Set;for(const[s,i]of Object.entries(o?.globalPaths??{}))r.push({owners:i,path:s,source:"project-json"}),t.add(s);for(const[s,i]of Object.entries(e.projects)){const c=i.owners??[];for(const a of c){const d=ne(i.root??s,a.path);r.push({channel:a.channel,owners:a.owners,path:d,projectId:s,source:"project-json"}),t.add(d)}}for(const s of n)t.has(s.path)||(r.push(s),t.add(s.path));return(o?.orderBy??"file-source")==="project-id"?r.sort((s,i)=>(s.projectId??"").localeCompare(i.projectId??"")||s.path.localeCompare(i.path)):r.sort((s,i)=>s.path.localeCompare(i.path)),r},"buildCodeownersLines"),te="Update each project's project.json `owners` field and re-run the command.",re=j(e=>["# CODEOWNERS generated by `vis sync codeowners`. Do not edit by hand.",e?`# Re-run with: ${e}`:`# ${te}`,""],"buildHeader"),M=j(e=>{const o=[];for(const n of e){const r=n.owners.join(" "),t=n.channel?` # notify: ${n.channel}`:"";o.push(`${n.path} ${r}${t}`)}return o},"renderEntries"),se=j((e,o={})=>[...re(o.regenerationCommand),...M(e),""].join(`
2
- `),"renderCodeowners"),_={begin:"# BEGIN vis-codeowners",end:"# END vis-codeowners"},ie=j((e,o=_,n={})=>{const r=n.regenerationCommand?`# Generated by vis sync codeowners — re-run with: ${n.regenerationCommand}`:"# Generated by `vis sync codeowners` — do not edit by hand.";return[o.begin,r,...M(e),o.end].join(`
3
- `)},"renderCodeownersBlock"),ce=j((e,o,n=_)=>{const r=e.indexOf(n.begin),t=e.indexOf(n.end);if(r!==-1&&t!==-1&&t>r){const i=e.slice(0,r),c=t+n.end.length,a=e.slice(c);return`${i}${o}${a}`}const s=e.replace(/\s+$/u,"");return`${s.length===0?"":`${s}
4
-
5
- `}${o}
6
- `},"mergeIntoExisting");var ae=Object.defineProperty,O=$((e,o)=>ae(e,"name",{value:o,configurable:!0}),"f$1");const le=["**/CODEOWNERS"],de=["**/node_modules/**","**/dist/**","**/build/**","**/coverage/**","**/.git/**","**/.next/**","**/.nuxt/**"],fe=O(e=>{const o=[];for(const n of e.split(/\r?\n/u)){const r=n.indexOf("#"),t=(r===-1?n:n.slice(0,r)).trim();if(t.length===0)continue;const s=t.split(/\s+/u);if(s.length<2)continue;const[i,...c]=s,a=c.filter(d=>d.length>0);!i||a.length===0||o.push({owners:a,path:i})}return o},"parseCodeownersFile"),ue=O((e,o)=>{const n=o.replace(/^\.\/?/,"").replace(/\/$/,"");return e.startsWith("/")?n===""?e:`/${n}${e}`:n===""?`/${e}`:`/${n}/${e}`},"rewriteNestedPath"),pe=O(async(e,o,n)=>{const r=o&&o.length>0?[...o]:[...le],t=[...de];if(n){const c=n.replace(/^\.\/?/,"").replace(/^\/+/,"");c.length>0&&t.push(c)}const s=await Z(r,{absolute:!0,cwd:e,ignore:t}),i=[];for(const c of s){let a;try{a=U(c)}catch{continue}const d=q(c),h=L(e,d);for(const w of fe(a))i.push({owners:w.owners,path:ue(w.path,h)})}return i},"collectNestedCodeownersLines"),ge=/^(?:https?:\/\/)?(?:www\.)?github\.com\/([^/?#]+)/iu,he=O(e=>{if(!e)return;const o=e.match(ge);if(!o?.[1])return;const n=o[1].trim();if(!(n===""||n.includes(" ")))return`@${n.replace(/^@/,"")}`},"extractGitHubHandle"),we=O((e,o)=>{const n=[];for(const[r,t]of Object.entries(e.projects)){if(t.owners&&t.owners.length>0)continue;const s=t.root??r,i=P(o,s,"package.json"),c=N(i);if(!c)continue;const a=ee(c.maintainers);if(!a||a.length===0)continue;const d=[],h=new Set;for(const w of a){const m=he(w.url);m&&!h.has(m)&&(h.add(m),d.push(m))}d.length!==0&&n.push({owners:d,path:s===""||s==="."?"/":`/${s}/`,projectId:r})}return n},"collectMaintainerLines");var me=Object.defineProperty,b=$((e,o)=>me(e,"name",{value:o,configurable:!0}),"s");const ye=["author","bugs","homepage","license","repository","engines"],S=b(e=>typeof e=="object"&&e!==null&&!Array.isArray(e),"isPlainObject"),x=b((e,o)=>{if(e===o)return!0;if(typeof e!=typeof o||e===null||o===null)return!1;if(Array.isArray(e)){if(!Array.isArray(o)||e.length!==o.length)return!1;for(const[n,r]of e.entries())if(!x(r,o[n]))return!1;return!0}if(typeof e=="object"&&typeof o=="object"){const n=Object.keys(e),r=Object.keys(o);if(n.length!==r.length)return!1;for(const t of n)if(!x(e[t],o[t]))return!1;return!0}return!1},"deepEqual"),A=b(e=>e===void 0?e:structuredClone(e),"cloneJson"),ke=b((e,o,n)=>{if(e==="repository"&&S(o)&&S(n)){const r={};for(const[t,s]of Object.entries(o))t!=="directory"&&(r[t]=A(s));return typeof n.directory=="string"&&(r.directory=n.directory),r}return A(o)},"buildTargetValue"),je=b((e,o,n)=>{const r=[];for(const t of n.fields){if(!Object.hasOwn(e,t))continue;const s=e[t],i=o[t],c=ke(t,s,i);x(c,i)||r.push({after:c,before:i,field:t,packageJsonPath:""})}return r},"computeFieldChanges"),$e=b((e,o)=>{for(const n of o)e[n.field]=n.after},"applyFieldChanges");var be=Object.defineProperty,C=$((e,o)=>be(e,"name",{value:o,configurable:!0}),"u");const B=new Set(["nested-codeowners","package-json-maintainers","project-json"]),D=C((e,o,n)=>{const r=new Set,t=[];for(const s of e??[])for(const i of s.split(",")){const c=i.trim();if(c.length===0)continue;if(n&&!n(c))throw new Error(`Unknown codeowners source: "${c}". Known: ${[...B].join(", ")}.`);const a=c;r.has(a)||(r.add(a),t.push(a))}return t.length>0?t:[...o]},"parseCsvOption"),Ce=C(e=>B.has(e),"isCodeownersSource"),I=["codeowners","package-json-fields"],ve=C((e,o)=>o.some(n=>V(n,e)),"matchesAnyGlob"),Ee=C(async({logger:e,options:o,visConfig:n,workspaceRoot:r})=>{const t=r,{workspace:s}=Y(t,n),i=n?.codeowners,c=D(o.from,i?.sources??["project-json"],Ce),a=o.regenerationCommand??i?.regenerationCommand,d=o.preserveBlock===!0||i?.preserveBlock===!0,h=i?.blockMarker??_,w=o.nestedIncludes??i?.nestedIncludes,m=o.out??"CODEOWNERS",u=[];if(c.includes("nested-codeowners")){const g=await pe(t,w,m);for(const k of g)u.push({...k,source:"nested"})}if(c.includes("package-json-maintainers")){const g=we(s,t);for(const k of g)u.push({...k,source:"maintainers"})}const y=c.includes("project-json")?F(s,i,u):F({projects:{}},i,u);if(y.length===0){e.info("No `owners` entries found in any source. Nothing to sync.");return}const f=P(t,m);let v="";try{v=H(f,"utf8")}catch(g){if(g.code!=="ENOENT")throw g}const l={regenerationCommand:a},p=d?ce(v,ie(y,h,l),h):se(y,l);if(o.check){if(v.trim()!==p.trim()){e.error(`${f} is out of date. Run \`vis sync codeowners\` to update it.`),process.exitCode=1;return}e.info(`${f} is up to date.`);return}K(f,p),e.info(`Wrote ${y.length} entries to ${f}`)},"runCodeowners"),Oe=C(({logger:e,options:o,visConfig:n,workspaceRoot:r})=>{const t=r,s=n?.editorconfig??!0,i=N(P(t,"package.json"));if(!i){e.error("Could not read root package.json. Nothing to sync."),process.exitCode=1;return}const c=D(o.fields,ye),a=o.ignorePackageName??[],d=o.check===!0,h=(o.format??"human").toLowerCase(),w=o.quiet===!0,m=Q(t).filter(l=>l!=="."),u=[];let y=0;for(const l of m){const p=P(t,l,"package.json"),g=N(p);if(!g)continue;const k=typeof g.name=="string"?g.name:void 0;if(k!==void 0&&a.length>0&&ve(k,a))continue;y+=1;const R=je(i,g,{fields:c});R.length!==0&&u.push({filePath:p,packageJsonPath:L(t,p),packageName:k,pkg:g,pkgChanges:R})}if(!d)for(const l of u)$e(l.pkg,l.pkgChanges),z(l.filePath,l.pkg,{indent:X(l.filePath,{useEditorconfig:s}),overwrite:!0});const f=u.flatMap(l=>l.pkgChanges.map(p=>({after:p.after,before:p.before,field:p.field,packageJsonPath:l.packageJsonPath,packageName:l.packageName}))),v={changes:f,fields:c,kind:"package-json-fields",mode:d?"check":"write",totalChanges:f.length,totalPackages:y};if(h==="json")process.stdout.write(`${JSON.stringify(v,null,4)}
7
- `);else if(f.length===0)e.info(`All ${y} package${y===1?"":"s"} in sync (fields: ${c.join(", ")}).`);else if(d){if(!w)for(const l of f)e.error(`${l.packageJsonPath}: ${l.field} drifts from root`);e.error(`Found ${f.length} field drift${f.length===1?"":"s"} across ${u.length} package${u.length===1?"":"s"}. Run \`vis sync package-json-fields\` to fix.`)}else{if(!w)for(const l of u)e.info(`${l.packageJsonPath}: synced ${l.pkgChanges.map(p=>p.field).join(", ")}`);e.info(`Synced ${f.length} field${f.length===1?"":"s"} across ${u.length} package${u.length===1?"":"s"}.`)}d&&f.length>0&&(process.exitCode=1)},"runPackageJsonFields"),Ae=C(async e=>{const o=e.argument[0];if(!o)throw new Error(`Missing sync kind. Usage: vis sync <kind> (known kinds: ${I.join(", ")})`);if(!e.workspaceRoot)throw new Error("Could not determine workspace root. Run inside a monorepo.");if(o==="codeowners"){await Ee(e);return}if(o==="package-json-fields"){Oe(e);return}throw new Error(`Unknown sync kind: "${o}". Known kinds: ${I.join(", ")}.`)},"execute");export{Ae as default};
1
+ var J=Object.defineProperty;var R=(e,t)=>J(e,"name",{value:t,configurable:!0});import{createRequire as W}from"node:module";import{o as Q,aD as G,aE as I,aF as B,aG as K,aH as Y,aI as g,aJ as H,aK as U,aL as X,aM as Z,aN as ee,aO as te,aP as oe,aQ as ne,aR as se,aS as ie,aT as re,aU as ae}from"./bin.js";import{i as $,$ as T,M as d,e as pe,Q as fe,B as _}from"./config.js";import{v as le}from"../packem_shared/verify-CQbzknur.js";const L=W(import.meta.url),E=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,z=R(e=>{if(typeof E<"u"&&E.versions&&E.versions.node){const[t,n]=E.versions.node.split(".").map(Number);if(t>22||t===22&&n>=3||t===20&&n>=16)return E.getBuiltinModule(e)}return L(e)},"__cjs_getBuiltinModule"),{readdirSync:ce,statSync:ue}=z("node:fs"),{stdin:A,stdout:ge}=E,{createInterface:de}=z("node:readline/promises");var me=Object.defineProperty,p=R((e,t)=>me(e,"name",{value:t,configurable:!0}),"u");const x="__global__",b=p(e=>[...new Set(e)].sort((t,n)=>t.localeCompare(n)),"sortStrings"),ve=p(e=>`{${Object.keys(e).sort().map(t=>`${t}=${JSON.stringify(e[t])}`).join(",")}}`,"canonicalizeObjectToken"),h=p(e=>{if(!Array.isArray(e))return[];const t=[];for(const n of e)typeof n=="string"?t.push(n):n&&typeof n=="object"&&t.push(ve(n));return b(t)},"normalizeTokenList"),w=p(e=>({cache:void 0,dependsOn:[],env:[],id:e,inputs:[],outputs:[]}),"emptyNode"),k=p((e,t,n)=>n?`^${t}`:e&&e!=="self"&&e!=="~"?`${e}#${t}`:t,"canonicalEdge"),ye=p((e,t)=>{const n=e.trim();if(t==="moon"){if(n.startsWith("^:"))return k(void 0,n.slice(2),!0);if(n.startsWith("~:"))return k(void 0,n.slice(2),!1);if(n.includes(":")){const[s,o]=n.split(":");return k(s,o??"",!1)}return n}if(n.startsWith("^"))return k(void 0,n.slice(1),!0);if(n.includes("#")){const[s,o]=n.split("#");return k(s,o??"",!1)}return n},"normalizeStringEdge"),M=p((e,t)=>{if(!Array.isArray(e))return[];const n=[];for(const s of e){if(typeof s=="string"){n.push(ye(s,t));continue}if(!s||typeof s!="object")continue;const o=s,{target:r}=o;if(!r)continue;if(o.dependencies===!0){n.push(k(void 0,r,!0));continue}if(o.projects===void 0){n.push(k(void 0,r,!1));continue}const i=Array.isArray(o.projects)?o.projects:[o.projects];for(const c of i)n.push(c==="^"?k(void 0,r,!0):k(c,r,!1))}return b(n)},"normalizeDependsOn"),O=p(e=>{if($(e))try{return JSON.parse(T(e))}catch{return}},"readJson"),he=p(e=>{const t=new Map,n=O(d(e,"turbo.json"));if(!n)return t;const s=n.tasks??n.pipeline??{};for(const[r,i]of Object.entries(s)){const c=r.includes("#")?r:`*#${r}`,a=w(c);a.dependsOn=M(i.dependsOn,"turbo"),a.inputs=h(i.inputs),a.outputs=h(i.outputs),a.env=b([...i.env??[],...i.passThroughEnv??[]]),a.cache=i.cache===!1?!1:void 0,t.set(c,a)}const o=w(x);return o.inputs=h(n.globalDependencies),o.env=b([...n.globalEnv??[],...n.globalPassThroughEnv??[]]),(o.inputs.length>0||o.env.length>0)&&t.set(x,o),t},"parseTurboModel"),ke=new Set([".git",".nx",".turbo",".vis","build","coverage","dist","node_modules"]),N=p((e,t,n=8)=>{const s=[],o=p((r,i)=>{if(i>n)return;let c;try{c=ce(r)}catch{return}for(const a of c.toSorted()){if(a===t){s.push(d(r,a));continue}if(a.startsWith(".")&&a!==".moon"||ke.has(a))continue;const u=d(r,a);try{ue(u).isDirectory()&&o(u,i+1)}catch{}}},"walk");return o(e,0),s},"findFiles"),D=p((e,t)=>{e.dependsOn=M(t.dependsOn,"nx"),e.inputs=h(t.inputs),e.outputs=h(t.outputs),e.cache=typeof t.cache=="boolean"?t.cache:void 0},"applyNxTarget"),we=p(e=>{const t=new Map,n=O(d(e,"nx.json"));for(const[s,o]of Object.entries(n?.targetDefaults??{})){const r=`*#${s}`,i=w(r);D(i,o),t.set(r,i)}for(const s of N(e,"project.json")){const o=O(s);if(!(!o?.name||!o.targets))for(const[r,i]of Object.entries(o.targets)){const c=`${o.name}#${r}`,a=w(c);D(a,i),t.set(c,a)}}return t},"parseNxModel"),V=p((e,t)=>{e.dependsOn=M(t.deps,"moon"),e.inputs=h(t.inputs),e.outputs=h(t.outputs),e.cache=typeof t.options?.cache=="boolean"?t.options.cache:void 0},"applyMoonTask"),q=p(e=>{if($(e))try{return Q(e)}catch{return}},"readMoonYaml"),$e=p(e=>{const t=new Map,n=d(e,".moon"),s=[d(n,"tasks.yml"),d(n,"tasks.yaml")];for(const o of s){const r=q(o);if(r){for(const[i,c]of Object.entries(r.tasks??{})){const a=`*#${i}`,u=w(a);V(u,c),t.set(a,u)}if(r.implicitInputs&&r.implicitInputs.length>0){const i=w(x);i.inputs=h(r.implicitInputs),t.set(x,i)}}}for(const o of[...N(e,"moon.yml"),...N(e,"moon.yaml")]){const r=q(o);if(!r?.tasks)continue;const i=o.split(/[/\\]/).at(-2)??"*";for(const[c,a]of Object.entries(r.tasks)){const u=`${i}#${c}`,y=w(u);V(y,a),t.set(u,y)}}return t},"parseMoonModel"),xe=p((e,t)=>{e.dependsOn=M(t.dependsOn,"vis"),e.inputs=h(t.inputs),e.outputs=h(t.outputs),e.env=b([...t.env??[],...t.passThroughEnv??[],...t.options?.passThroughEnv??[]]),e.cache=t.cache===!1?!1:typeof t.cache=="boolean"?t.cache:void 0},"applyVisTask"),be=p(async e=>{const t=new Map,n=await pe(e);for(const[r,i]of Object.entries(n.tasks??{})){const c=`*#${r}`,a=w(c);xe(a,i??{}),t.set(c,a)}const s=n.taskRunner??{},o=w(x);return o.inputs=h(s.globalInputs),o.env=b([...s.globalEnv??[],...s.globalPassThroughEnv??[]]),(o.inputs.length>0||o.env.length>0)&&t.set(x,o),t},"buildVisModel"),Re=p((e,t)=>{switch(t){case"moon":return $e(e);case"nx":return we(e);default:return he(e)}},"buildSourceModel"),Ee=p(e=>{const t=[];return $(d(e,"turbo.json"))&&t.push("turbo"),$(d(e,"nx.json"))&&t.push("nx"),($(d(e,".moon","tasks.yml"))||$(d(e,".moon","tasks.yaml")))&&t.push("moon"),t.length===1?t[0]:void 0},"detectSourceTool"),S=p((e,t,n,s,o)=>{const r=s.filter(a=>!o.includes(a)),i=o.filter(a=>!s.includes(a));if(r.length===0&&i.length===0)return;const c=[];r.length>0&&c.push(`dropped [${r.join(", ")}]`),i.length>0&&c.push(`added [${i.join(", ")}]`),e.push({axis:n,detail:`${n} diverged: ${c.join("; ")}`,node:t,severity:r.length>0?"error":"warning"})},"diffArrayAxis"),Ce=p((e,t,n)=>{const s=[],o=b([...e.keys(),...t.keys()]);for(const r of o){const i=e.get(r),c=t.get(r);if(i&&!c){const a=n==="turbo"&&r.includes("#")&&!r.startsWith("*#")&&r!==x;s.push({axis:"target-set",detail:a?`source target \`${r}\` was skipped by design (turbo project#task is migrated into per-project project.json — move it there and re-verify)`:`source target \`${r}\` has no equivalent in the migrated vis config`,node:r,severity:a?"warning":"error"});continue}if(!i&&c){s.push({axis:"target-set",detail:`migrated vis config defines \`${r}\` with no source equivalent (extra target — not a regression, but review)`,node:r,severity:"warning"});continue}!i||!c||(S(s,r,"dependsOn",i.dependsOn,c.dependsOn),S(s,r,"inputs",i.inputs,c.inputs),S(s,r,"outputs",i.outputs,c.outputs),S(s,r,"env",i.env,c.env),i.cache!==void 0&&c.cache!==void 0&&i.cache!==c.cache&&s.push({axis:"cache",detail:`cache flag diverged: source=${String(i.cache)} vis=${String(c.cache)} (changes what invalidates the cache)`,node:r,severity:"error"}))}return s.sort((r,i)=>r.node.localeCompare(i.node)||r.axis.localeCompare(i.axis)),{findings:s,source:n,sourceNodeCount:e.size,visNodeCount:t.size}},"diffModels"),je=new Set(["json","ndjson","table"]),Se=p(e=>({equivalent:e.findings.every(t=>t.severity!=="error"),findings:e.findings,source:e.source,sourceNodeCount:e.sourceNodeCount,visNodeCount:e.visNodeCount}),"toJsonPayload"),Me=p((e,t,n)=>{if(t==="json"){process.stdout.write(`${JSON.stringify(Se(e),void 0,2)}
2
+ `);return}if(t==="ndjson"){for(const s of e.findings)process.stdout.write(`${JSON.stringify(s)}
3
+ `);return}if(n.info(`Migration equivalence: ${e.source} → vis`),n.info(` source nodes: ${String(e.sourceNodeCount)} vis nodes: ${String(e.visNodeCount)}`),e.findings.length===0){n.info(" ✓ task graph + cache-key surface preserved (no divergence).");return}for(const s of e.findings){const o=` [${s.severity}] ${s.node} (${s.axis}) — ${s.detail}`;s.severity==="error"?n.warn(o):n.info(o)}},"formatEquivalenceReport"),Te=p((e,t)=>e.findings.some(n=>t==="warning"?!0:n.severity==="error")?1:0,"equivalenceExitCode");var Oe=Object.defineProperty,Ne=R((e,t)=>Oe(e,"name",{value:t,configurable:!0}),"n");const F=Ne(async e=>{if(!A.isTTY)return!0;const t=de({input:A,output:ge});try{const n=(await t.question(`${e} [Y/n] `)).trim().toLowerCase();return n===""||n==="y"||n==="yes"}finally{t.close()}},"confirm");var Ie=Object.defineProperty,C=R((e,t)=>Ie(e,"name",{value:t,configurable:!0}),"p");const _e=[{description:"VisConfig.targetDefaults → VisConfig.tasks",next:"tasks",previous:"targetDefaults"},{description:"VisConfig.taskDefaults → VisConfig.scopedTasks",next:"scopedTasks",previous:"taskDefaults"},{description:"VisConfig.taskRunnerOptions → VisConfig.taskRunner",next:"taskRunner",previous:"taskRunnerOptions"},{description:"ScopedTasksBlock.scope → ScopedTasksBlock.match",next:"match",previous:"scope"},{description:"ScopedTasksBlock.targets → ScopedTasksBlock.tasks",next:"tasks",previous:"targets"}],Ae=[{description:"VisTaskConfig.targets → VisTaskConfig.tasks",next:"tasks",previous:"targets"}],De=C(e=>new RegExp(String.raw`(^|[\s,{(\[])(["']?)${e}\2(\s*:)`,"gmu"),"buildKeyRegex"),Ve=C((e,t)=>{let n=e;const s=[];for(const o of t){const r=De(o.previous);r.test(n)&&(r.lastIndex=0,n=n.replace(r,(i,c,a,u)=>`${c}${a}${o.next}${a}${u}`),s.push(o))}return{applied:s,output:n}},"applyRenames"),P=C((e,t)=>Ve(e,t),"rewriteSource"),qe=["vis.config.ts","vis.config.mts","vis.config.cts","vis.config.js","vis.config.mjs","vis.config.cjs"],Pe=new Set(["vis.task.cjs","vis.task.cts","vis.task.js","vis.task.mjs","vis.task.mts","vis.task.ts"]),ze=C(e=>{for(const t of qe){const n=d(e,t);if($(n))return n}},"findConfigFile"),Be=C(e=>{const t=[];try{for(const n of G(e,{includeDirs:!1,includeFiles:!0,includeSymlinks:!1,skip:[/node_modules/,/\.git/,/\.vis\b/,/dist\b/,/\.next\b/,/\.nuxt\b/]}))Pe.has(fe(n.path))&&t.push(n.path)}catch{}return t},"findTaskConfigFiles"),Fe=C((e,t,n,s)=>{const o=ze(e);if(o){const i=T(o),{applied:c,output:a}=P(i,_e);if(c.length===0)n.info(`${o} already uses the current schema — no rewrite needed.`);else if(t.dryRun)n.info(`── ${o} (preview) ──`),n.info(a),n.info("── end preview ──"),n.info(`Would apply ${String(c.length)} rename(s): ${c.map(u=>u.description).join(", ")}`);else{I(o,s),_(o,a),n.info(`Rewrote ${o} (backup at ${o}.bak). Applied ${String(c.length)} rename(s).`);for(const u of c)s.manualSteps.push(`Renamed ${u.description} in ${o}`)}}else n.warn("No vis.config.ts found at workspace root — nothing to migrate."),s.warnings.push("No vis.config.{ts,mts,cts,js,mjs,cjs} at workspace root.");const r=t.taskConfigPaths??Be(e);for(const i of r){if(!$(i))continue;const c=T(i),a=P(c,Ae);if(a.applied.length!==0)if(t.dryRun)n.info(`── ${i} (preview) ──`),n.info(a.output),n.info("── end preview ──"),n.info(`Would apply ${String(a.applied.length)} rename(s): ${a.applied.map(u=>u.description).join(", ")}`);else{I(i,s),_(i,a.output),n.info(`Rewrote ${i} (backup at ${i}.bak). Applied ${String(a.applied.length)} rename(s).`);for(const u of a.applied)s.manualSteps.push(`Renamed ${u.description} in ${i}`)}}},"migrateSelf");var Je=Object.defineProperty,f=R((e,t)=>Je(e,"name",{value:t,configurable:!0}),"r");const l=f(e=>{const t=e.workspaceRoot??process.cwd(),n=e.visConfig??{};return{config:n,dryRun:!!e.options.dryRun,logger:e.logger,packageManager:K(t),report:B(),root:t,useEditorconfig:typeof n.editorconfig=="boolean"?n.editorconfig:!0}},"buildContext"),m=f(async(e,t,n)=>{if(t.yes||t.dryRun)return!0;const s=await F(`This will edit files, scripts, and hooks for "${e}". Backups (.bak) will be created. Continue?`);return s||n.info("Aborted."),s},"maybeConfirm"),v=f(e=>{e.dryRun&&e.logger.info(`Running in dry-run mode — no changes will be made.
4
+ `)},"announceDryRun"),We=f(async({logger:e,options:t,visConfig:n,workspaceRoot:s})=>{if(!await m("deps",t,e))return;const o=l({logger:e,options:t,visConfig:n,workspaceRoot:s});v(o),e.info("── Migrating dependencies and scripts ──"),Y(o.root,o.packageManager,o.config,{dryRun:o.dryRun},e,o.report),e.info(""),g(o.report,e)},"migrateDepsExecuteImpl"),Le=f(async({logger:e,options:t,visConfig:n,workspaceRoot:s})=>{if(!await m("lint-staged",t,e))return;const o=l({logger:e,options:t,visConfig:n,workspaceRoot:s});v(o),e.info("── Migrating lint-staged ──"),H(o.root,{dryRun:o.dryRun,useEditorconfig:o.useEditorconfig},e,o.report),e.info(""),g(o.report,e)},"migrateLintStagedExecuteImpl"),Qe=f(async({logger:e,options:t,visConfig:n,workspaceRoot:s})=>{if(!await m("nano-staged",t,e))return;const o=l({logger:e,options:t,visConfig:n,workspaceRoot:s});v(o),e.info("── Migrating nano-staged ──"),U(o.root,{dryRun:o.dryRun,useEditorconfig:o.useEditorconfig},e,o.report),e.info(""),g(o.report,e)},"migrateNanoStagedExecuteImpl"),Ge=f(async({logger:e,options:t,visConfig:n,workspaceRoot:s})=>{if(!await m("turborepo",t,e))return;const o=l({logger:e,options:t,visConfig:n,workspaceRoot:s});v(o),e.info("── Migrating turborepo ──"),X(o.root,{dryRun:o.dryRun,useEditorconfig:o.useEditorconfig},e,o.report),e.info(""),g(o.report,e)},"migrateTurborepoExecuteImpl"),Ke=f(async({logger:e,options:t,visConfig:n,workspaceRoot:s})=>{if(!await m("nx",t,e))return;const o=l({logger:e,options:t,visConfig:n,workspaceRoot:s});v(o),e.info("── Migrating nx ──"),Z(o.root,{dryRun:o.dryRun,force:!!t.force,useEditorconfig:o.useEditorconfig},e,o.report),e.info(""),g(o.report,e)},"migrateNxExecuteImpl"),Ye=f(async({logger:e,options:t,visConfig:n,workspaceRoot:s})=>{if(!await m("moon",t,e))return;const o=l({logger:e,options:t,visConfig:n,workspaceRoot:s});v(o),e.info("── Migrating moon ──"),ee(o.root,{copyTemplates:!!t.copyTemplates,dryRun:o.dryRun,useEditorconfig:o.useEditorconfig},e,o.report),e.info(""),g(o.report,e)},"migrateMoonExecuteImpl"),He=f(async({logger:e,options:t,visConfig:n,workspaceRoot:s})=>{if(!await m("gitleaks",t,e))return;const o=l({logger:e,options:t,visConfig:n,workspaceRoot:s});v(o),e.info("── Migrating gitleaks ──"),te(o.root,{dryRun:o.dryRun,useEditorconfig:o.useEditorconfig},e,o.report),e.info(""),g(o.report,e)},"migrateGitleaksExecuteImpl"),Ue=f(async({logger:e,options:t,visConfig:n,workspaceRoot:s})=>{if(!await m("kingfisher",t,e))return;const o=l({logger:e,options:t,visConfig:n,workspaceRoot:s});v(o),e.info("── Migrating Kingfisher ──"),oe(o.root,{dryRun:o.dryRun,useEditorconfig:o.useEditorconfig},e,o.report),e.info(""),g(o.report,e)},"migrateKingfisherExecuteImpl"),Xe=f(async({logger:e,options:t,visConfig:n,workspaceRoot:s})=>{if(!await m("secretlint",t,e))return;const o=l({logger:e,options:t,visConfig:n,workspaceRoot:s});v(o),e.info("── Migrating secretlint ──"),ne(o.root,{dryRun:o.dryRun,useEditorconfig:o.useEditorconfig},e,o.report),e.info(""),g(o.report,e)},"migrateSecretlintExecuteImpl"),Ze=f(async({logger:e,options:t,visConfig:n,workspaceRoot:s})=>{if(!await m("syncpack",t,e))return;const o=l({logger:e,options:t,visConfig:n,workspaceRoot:s});v(o),e.info("── Migrating syncpack ──"),se(o.root,{dryRun:o.dryRun,useEditorconfig:o.useEditorconfig},e,o.report),e.info(""),g(o.report,e)},"migrateSyncpackExecuteImpl"),et=f(async({logger:e,options:t,visConfig:n,workspaceRoot:s})=>{if(!await m("sherif",t,e))return;const o=l({logger:e,options:t,visConfig:n,workspaceRoot:s});v(o),e.info("── Migrating sherif ──"),ie(o.root,{dryRun:o.dryRun,useEditorconfig:o.useEditorconfig},e,o.report),e.info(""),g(o.report,e)},"migrateSherifExecuteImpl"),tt=f(async({logger:e,options:t,visConfig:n,workspaceRoot:s})=>{if(!await m("self",t,e))return;const o=l({logger:e,options:t,visConfig:n,workspaceRoot:s});v(o),e.info("── Migrating vis.config.ts to current schema ──"),Fe(o.root,{dryRun:o.dryRun},e,o.report),e.info(""),g(o.report,e)},"migrateSelfExecuteImpl"),ot=f(({logger:e,workspaceRoot:t})=>{const n=t??process.cwd();le(n,e).length>0&&(process.exitCode=1)},"migrateVerifyExecuteImpl"),nt=f(async({logger:e,options:t,workspaceRoot:n})=>{const s=n??process.cwd(),o=t.format??"table";if(!je.has(o)){e.warn(`Invalid --format: ${String(t.format)}. Expected table | json | ndjson.`),process.exitCode=1;return}const r=t.failOn==="warning"?"warning":"error";let i;if(t.from){if(t.from!=="turbo"&&t.from!=="nx"&&t.from!=="moon"){e.warn(`Invalid --from: ${t.from}. Expected turbo | nx | moon.`),process.exitCode=1;return}i=t.from}else if(i=Ee(s),!i){e.warn("Could not auto-detect the source tool (need exactly one of turbo.json / nx.json / .moon/tasks.yml). Pass --from <turbo|nx|moon>."),process.exitCode=1;return}const c=Re(s,i);if(c.size===0){e.warn(`No ${i} task graph found at ${s} — nothing to verify.`),process.exitCode=1;return}const a=await be(s);if(a.size===0){e.warn("No migrated vis task graph found (vis.config.ts has no tasks). Run the migrator first."),process.exitCode=1;return}const u=Ce(c,a,i);Me(u,o,e),process.exitCode=Te(u,r)},"migrateVerifyGraphExecuteImpl"),st=f(async({logger:e,options:t,visConfig:n,workspaceRoot:s})=>{const o=s??process.cwd(),r=re(o,n??{}),i=ae(r);if(i.length===0){e.info("No applicable migrations detected in this workspace.");return}const c=!!t.dryRun;e.info(`Detected ${String(i.length)} migration(s):`);for(const y of i)e.info(` • ${y.title} — ${y.description}`);if(e.info(""),!t.yes&&!c&&!await F("Apply all detected migrations? Backups (.bak) will be created.")){e.info("Aborted.");return}c&&e.info(`Running in dry-run mode — no changes will be made.
5
+ `);const a=B(),u=[];for(const y of i)try{if(e.info(`── Applying ${y.title} ──`),c)for(const j of y.probe(r))e.info(j);else y.apply(r,a,e);e.info("")}catch(j){u.push({error:j,id:y.id}),e.warn(`Failed to apply ${y.title}: ${j.message}`)}g(a,e),u.length>0&&(e.warn(""),e.warn(`${String(u.length)} migration(s) failed — see messages above.`),process.exitCode=1)},"migrateAllExecuteImpl"),pt=We,ft=Le,gt=Qe,dt=Ge,lt=Ke,mt=Ye,vt=He,yt=Ue,ht=Xe,kt=Ze,wt=et,$t=tt,xt=ot,bt=nt,Rt=st;export{Rt as migrateAllExecute,pt as migrateDepsExecute,vt as migrateGitleaksExecute,yt as migrateKingfisherExecute,ft as migrateLintStagedExecute,mt as migrateMoonExecute,gt as migrateNanoStagedExecute,lt as migrateNxExecute,ht as migrateSecretlintExecute,$t as migrateSelfExecute,wt as migrateSherifExecute,kt as migrateSyncpackExecute,dt as migrateTurborepoExecute,xt as migrateVerifyExecute,bt as migrateVerifyGraphExecute};
@@ -1,4 +1,4 @@
1
- var ae=Object.defineProperty;var j=(t,e)=>ae(t,"name",{value:e,configurable:!0});import{createRequire as ce}from"node:module";import{ay as Y,E as f,j as b,q as T,p as l}from"./bin.js";import{i as _,M as N,g as Q,O as L,z as X,f as fe,b as Z,B as pe,C as ue}from"./config.js";import{f as we}from"../packem_shared/giget-CcEy_Elm.js";const le=ce(import.meta.url),x=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,P=j(t=>{if(typeof x<"u"&&x.versions&&x.versions.node){const[e,r]=x.versions.node.split(".").map(Number);if(e>22||e===22&&r>=3||e===20&&r>=16)return x.getBuiltinModule(t)}return le(t)},"__cjs_getBuiltinModule"),{fileURLToPath:de}=P("node:url"),{createInterface:me}=P("node:readline"),{mkdtempSync:he,rmSync:ge}=P("node:fs"),{tmpdir:$e}=P("node:os"),{spawnSync:ye}=P("node:child_process");var ve=Object.defineProperty,y=j((t,e)=>ve(t,"name",{value:e,configurable:!0}),"i");const ee=[".ts",".mts",".cts",".js",".mjs",".cjs"],be="template.yml",Te=[".d",".test",".spec",".config",".bench",".stories"],Se=[".d.ts",".d.mts",".d.cts",".js.map",".mjs.map",".cjs.map",".ts.map"],te=y(t=>{for(const e of ee)if(t.endsWith(e))return t.slice(0,-e.length);return t},"stripExtension"),Oe=y(t=>{if(Se.some(r=>t.endsWith(r))||!ee.some(r=>t.endsWith(r)))return!1;const e=te(t);return!Te.some(r=>e.endsWith(r))},"isNativeFile"),J=y((t,e)=>{const r=[];if(!_(t))return r;for(const s of Y(t,{includeDirs:!1,includeSymlinks:!1,maxDepth:1})){if(!Oe(s.name))continue;const n=te(s.name);r.push({load:y(()=>Ne(s.path),"load"),name:n,path:s.path,source:e})}return r},"scanNativeDirectory"),q=y((t,e)=>{const r=[];if(!_(t))return r;for(const s of Y(t,{includeFiles:!1,includeSymlinks:!1,maxDepth:1})){if(s.path===t)continue;const n=N(s.path,be);_(n)&&r.push({load:y(()=>Re(s.path,s.name),"load"),name:s.name,path:s.path,source:e})}return r},"scanMoonDirectory"),je=y(()=>{try{const t=de(import.meta.url),e=N(Q(t),"..","..","templates");return _(e)?e:void 0}catch{return}},"resolveBuiltinTemplatesDirectory"),I=y(t=>{const{extraDirectories:e=[],onWarning:r,workspaceRoot:s}=t,n=[...J(N(s,".vis","templates"),"native"),...q(N(s,".vis","templates"),"moon"),...q(N(s,".moon","templates"),"moon")];for(const o of e)n.push(...q(o,"config")),n.push(...J(o,"config"));const i=je();i&&n.push(...q(i,"builtin"));const a=new Map;for(const o of n){const c=a.get(o.name);if(!c){a.set(o.name,o);continue}r&&r(`Template "${o.name}" exists in multiple sources — using ${c.source} (${c.path}), ignoring ${o.source} (${o.path}).`)}return[...a.values()].sort((o,c)=>o.name.localeCompare(c.name))},"discoverTemplates"),Ne=y(async t=>{const{loadNativeTemplate:e}=await import("./loader.js");return e(t)},"loadNativeFromPath"),Re=y(async(t,e)=>{const{loadMoonTemplate:r}=await import("./index.js");return r(t,e)},"loadMoonFromPath");var Ee=Object.defineProperty,v=j((t,e)=>Ee(t,"name",{value:e,configurable:!0}),"c");const M=v((t,e)=>new Promise(r=>{t.question(e,s=>{r(s.trim())})}),"ask"),ke=v(async(t,e,r)=>{const s=await M(t,` ${e} ${f(r?"[Y/n]":"[y/N]")} `);return s===""?r:s.toLowerCase()==="y"||s.toLowerCase()==="yes"},"confirm"),xe=v(async(t,e,r,s)=>{process.stderr.write(` ${e}
1
+ var ae=Object.defineProperty;var j=(t,e)=>ae(t,"name",{value:e,configurable:!0});import{createRequire as ce}from"node:module";import{aD as Y,E as f,j as b,q as T,p as l}from"./bin.js";import{i as _,M as N,K as Q,O as L,z as X,f as fe,b as Z,B as pe,C as ue}from"./config.js";import{f as we}from"../packem_shared/giget-CcEy_Elm.js";const le=ce(import.meta.url),x=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,D=j(t=>{if(typeof x<"u"&&x.versions&&x.versions.node){const[e,r]=x.versions.node.split(".").map(Number);if(e>22||e===22&&r>=3||e===20&&r>=16)return x.getBuiltinModule(t)}return le(t)},"__cjs_getBuiltinModule"),{fileURLToPath:de}=D("node:url"),{createInterface:me}=D("node:readline"),{mkdtempSync:he,rmSync:ge}=D("node:fs"),{tmpdir:$e}=D("node:os"),{spawnSync:ye}=D("node:child_process");var ve=Object.defineProperty,y=j((t,e)=>ve(t,"name",{value:e,configurable:!0}),"i");const ee=[".ts",".mts",".cts",".js",".mjs",".cjs"],be="template.yml",Te=[".d",".test",".spec",".config",".bench",".stories"],Se=[".d.ts",".d.mts",".d.cts",".js.map",".mjs.map",".cjs.map",".ts.map"],te=y(t=>{for(const e of ee)if(t.endsWith(e))return t.slice(0,-e.length);return t},"stripExtension"),Oe=y(t=>{if(Se.some(r=>t.endsWith(r))||!ee.some(r=>t.endsWith(r)))return!1;const e=te(t);return!Te.some(r=>e.endsWith(r))},"isNativeFile"),J=y((t,e)=>{const r=[];if(!_(t))return r;for(const s of Y(t,{includeDirs:!1,includeSymlinks:!1,maxDepth:1})){if(!Oe(s.name))continue;const n=te(s.name);r.push({load:y(()=>Ne(s.path),"load"),name:n,path:s.path,source:e})}return r},"scanNativeDirectory"),q=y((t,e)=>{const r=[];if(!_(t))return r;for(const s of Y(t,{includeFiles:!1,includeSymlinks:!1,maxDepth:1})){if(s.path===t)continue;const n=N(s.path,be);_(n)&&r.push({load:y(()=>Re(s.path,s.name),"load"),name:s.name,path:s.path,source:e})}return r},"scanMoonDirectory"),je=y(()=>{try{const t=de(import.meta.url),e=N(Q(t),"..","..","templates");return _(e)?e:void 0}catch{return}},"resolveBuiltinTemplatesDirectory"),I=y(t=>{const{extraDirectories:e=[],onWarning:r,workspaceRoot:s}=t,n=[...J(N(s,".vis","templates"),"native"),...q(N(s,".vis","templates"),"moon"),...q(N(s,".moon","templates"),"moon")];for(const o of e)n.push(...q(o,"config")),n.push(...J(o,"config"));const i=je();i&&n.push(...q(i,"builtin"));const a=new Map;for(const o of n){const c=a.get(o.name);if(!c){a.set(o.name,o);continue}r&&r(`Template "${o.name}" exists in multiple sources — using ${c.source} (${c.path}), ignoring ${o.source} (${o.path}).`)}return[...a.values()].sort((o,c)=>o.name.localeCompare(c.name))},"discoverTemplates"),Ne=y(async t=>{const{loadNativeTemplate:e}=await import("./loader2.js");return e(t)},"loadNativeFromPath"),Re=y(async(t,e)=>{const{loadMoonTemplate:r}=await import("./index.js");return r(t,e)},"loadMoonFromPath");var Ee=Object.defineProperty,v=j((t,e)=>Ee(t,"name",{value:e,configurable:!0}),"c");const M=v((t,e)=>new Promise(r=>{t.question(e,s=>{r(s.trim())})}),"ask"),ke=v(async(t,e,r)=>{const s=await M(t,` ${e} ${f(r?"[Y/n]":"[y/N]")} `);return s===""?r:s.toLowerCase()==="y"||s.toLowerCase()==="yes"},"confirm"),xe=v(async(t,e,r,s)=>{process.stderr.write(` ${e}
2
2
  `);for(const[n,i]of r.entries()){const a=b(T(` ${String(n+1)}.`)),o=i===s?f(" (default)"):"";process.stderr.write(`${a} ${i}${o}
3
3
  `)}for(;;){const n=await M(t,`
4
4
  ${f(`Enter choice (1-${String(r.length)}):`)} `);if(n===""&&s!==void 0)return s;const i=Number.parseInt(n,10);if(Number.isInteger(i)&&i>=1&&i<=r.length)return r[i-1];const a=r.find(o=>o===n);if(a)return a;process.stderr.write(` ${f("Invalid choice. Try again.")}
@@ -6,8 +6,8 @@ var ae=Object.defineProperty;var j=(t,e)=>ae(t,"name",{value:e,configurable:!0})
6
6
  `);for(const[n,i]of r.entries()){const a=b(T(` ${String(n+1)}.`)),o=s.includes(i)?f(" (default)"):"";process.stderr.write(`${a} ${i}${o}
7
7
  `)}for(;;){const n=await M(t,`
8
8
  ${f("Enter choices:")} `);if(n===""&&s.length>0)return s;const i=n.split(",").map(a=>Number.parseInt(a.trim(),10)).filter(a=>Number.isInteger(a)&&a>=1&&a<=r.length);if(i.length>0)return i.map(a=>r[a-1]);process.stderr.write(` ${f("Invalid choice. Try again.")}
9
- `)}},"selectMany"),Pe=v(t=>` ${f(`${t}:`)} `,"promptText"),De=v((t,e)=>e.prompt??t,"variableLabel"),We=v(t=>Object.entries(t).sort(([e,r],[s,n])=>{const i=r.order??0,a=n.order??0;return i!==a?i-a:e.localeCompare(s)}),"sortVariables"),H=v((t,e)=>{switch(t.type){case"array":return e.split(",").map(r=>r.trim()).filter(Boolean);case"boolean":return e==="true"||e==="1"||e==="yes"||e==="y";case"enum":return t.multiple?e.split(",").map(r=>r.trim()).filter(Boolean):e;case"number":{const r=Number(e);if(Number.isNaN(r))throw new TypeError(`Expected a number, got "${e}"`);return r}default:return e}},"parseValue"),F=v((t,e,r)=>{if(e.type==="enum"){const s=Array.isArray(r)?r:[r];for(const n of s)if(typeof n!="string"||!e.values.includes(n))throw new Error(`Variable "${t}" must be one of: ${e.values.join(", ")} (got "${String(n)}")`)}},"validateValue"),Be=v(async t=>{const{defaults:e,interactive:r,overrides:s,variables:n}=t,i={},a=r?me({input:process.stdin,output:process.stderr}):null;try{for(const[o,c]of We(n)){if(Object.hasOwn(s,o)){const $=H(c,s[o]??"");F(o,c,$),i[o]=$;continue}if(e||!r||c.internal){if(c.default!==void 0){F(o,c,c.default),i[o]=c.default;continue}if(c.required)throw new Error(`Required variable "${o}" not provided. Pass --${o}=<value> or remove --defaults.`);continue}const g=De(o,c);let m;if(c.type==="boolean")m=await ke(a,g,!!(c.default??!1));else if(c.type==="enum")if(c.multiple){const $=Array.isArray(c.default)?c.default:[];m=await _e(a,g,c.values,$)}else{const $=typeof c.default=="string"?c.default:void 0;m=await xe(a,g,c.values,$)}else{const $=c.default===void 0?"":` (${String(c.default)})`,S=await M(a,Pe(`${g}${$}`));if(S===""&&c.default!==void 0)m=c.default;else if(S===""){if(c.required)throw new Error(`Variable "${o}" is required`);continue}else m=H(c,S)}F(o,c,m),i[o]=m}return i}finally{a?.close()}},"collectOptions");var qe=Object.defineProperty,V=j((t,e)=>qe(t,"name",{value:e,configurable:!0}),"o");const Ie=["git://","npm://","https://","github:","gitlab:","bitbucket:","sourcehut:"],Me=V(t=>Ie.some(e=>t.startsWith(e)),"isRemoteSource"),Ce=V(async(t,e={})=>{const r=e.targetDirectory===void 0,s=e.targetDirectory??he(N($e(),"vis-generate-")),n=V(()=>{if(r)try{ge(s,{force:!0,recursive:!0})}catch{}},"cleanup");l.info(`Downloading ${t}…`);try{const i=await we(t,{auth:e.auth||process.env.GIGET_AUTH||process.env.GITHUB_TOKEN||process.env.GH_TOKEN||void 0,dir:s,force:!0,preferOffline:e.preferOffline});return{cleanup:n,directory:i.dir}}catch(i){n();const a=i instanceof Error?i.message:String(i);throw l.warn(`Failed to download template: ${a}`),i}},"fetchRemoteTemplate");var Ae=Object.defineProperty,R=j((t,e)=>Ae(t,"name",{value:e,configurable:!0}),"a");const re=R((t,e="")=>{const r=[];for(const[s,n]of Object.entries(t)){const i=e?`${e}/${s}`:s;typeof n=="string"||Buffer.isBuffer(n)?r.push({content:n,path:i}):n&&typeof n=="object"&&r.push(...re(n,i))}return r},"flattenTree"),Fe=R(t=>t<1024?`${t} B`:t<1024*1024?`${(t/1024).toFixed(1)} KB`:`${(t/(1024*1024)).toFixed(1)} MB`,"formatSize"),Le=R((t,e)=>{if(L(e))throw new Error(`Refusing to write outside destination: template produced absolute path "${e}".`);const r=N(t,e),s=X(t,r);if(s===".."||s.startsWith(`..${fe}`)||L(s))throw new Error(`Refusing to write outside destination: "${e}" resolves to "${r}" which escapes "${t}".`);return r},"safeJoinDestination"),Ve=R((t,e)=>{Z(Q(t)),pe(t,e)},"writeOne"),ze=R((t,e,r=!1)=>{const s=typeof t=="string"?[t]:t.commands,n=typeof t=="string"?r:t.silent??r;for(const i of s){n||l.info(`$ ${i}`);const a=ye(i,{cwd:e,shell:!0,stdio:n?"ignore":"inherit"});if(a.status!==0)return l.warn(`Script failed (exit ${String(a.status)}): ${i}`),!1}return!0},"runScript"),Ke=R(t=>{const e=new Map;for(const r of t){const s=typeof r=="string"?0:r.phase??0,n=e.get(s);n?n.push(r):e.set(s,[r])}return[...e.entries()].sort(([r],[s])=>r-s)},"groupByPhase"),Ue=R(async(t,e)=>{const r={builtins:{dest_dir:e.destination,dest_rel_dir:X(e.workspaceRoot,e.destination)||".",working_dir:e.cwd,workspace_root:e.workspaceRoot},options:e.options},s=await t.produce(r),n=s.files?re(s.files):[],i=s.filesMeta??{},a=[];for(const o of n){const c=Le(e.destination,o.path);a.push({file:o,meta:i[o.path]??{},target:c})}if(e.dryRun){l.info(`${b(T("Plan"))} ${f("(dry-run, no files written)")}`);for(const o of a){const c=Buffer.isBuffer(o.file.content)?o.file.content.length:Buffer.byteLength(o.file.content,"utf8");process.stderr.write(` ${f("write")} ${o.file.path} ${f(`(${Fe(c)})`)}
10
- `)}}else{Z(e.destination);let o=0,c=0;for(const g of a){const{file:m,meta:$,target:S}=g,C=_(S),O=e.force||$.force===!0;if(C&&!O){l.warn(`Skipped existing file: ${m.path} (use --force or set frontmatter force: true to overwrite)`),c+=1;continue}Ve(S,m.content),o+=1}l.success(`Wrote ${String(o)} file${o===1?"":"s"}${c>0?`, skipped ${String(c)}`:""}`)}if(!e.dryRun&&!e.skipScripts&&s.scripts&&s.scripts.length>0){const o=Ke(s.scripts);l.info(`Running ${String(s.scripts.length)} script${s.scripts.length===1?"":"s"} across ${String(o.length)} phase${o.length===1?"":"s"}…`);for(const[,c]of o)if((await Promise.all(c.map(g=>Promise.resolve(ze(g,e.destination))))).includes(!1))throw new Error("Script failed — aborting.")}if(s.suggestions&&s.suggestions.length>0){process.stderr.write(`
9
+ `)}},"selectMany"),De=v(t=>` ${f(`${t}:`)} `,"promptText"),Pe=v((t,e)=>e.prompt??t,"variableLabel"),We=v(t=>Object.entries(t).sort(([e,r],[s,n])=>{const i=r.order??0,a=n.order??0;return i!==a?i-a:e.localeCompare(s)}),"sortVariables"),H=v((t,e)=>{switch(t.type){case"array":return e.split(",").map(r=>r.trim()).filter(Boolean);case"boolean":return e==="true"||e==="1"||e==="yes"||e==="y";case"enum":return t.multiple?e.split(",").map(r=>r.trim()).filter(Boolean):e;case"number":{const r=Number(e);if(Number.isNaN(r))throw new TypeError(`Expected a number, got "${e}"`);return r}default:return e}},"parseValue"),F=v((t,e,r)=>{if(e.type==="enum"){const s=Array.isArray(r)?r:[r];for(const n of s)if(typeof n!="string"||!e.values.includes(n))throw new Error(`Variable "${t}" must be one of: ${e.values.join(", ")} (got "${String(n)}")`)}},"validateValue"),Be=v(async t=>{const{defaults:e,interactive:r,overrides:s,variables:n}=t,i={},a=r?me({input:process.stdin,output:process.stderr}):null;try{for(const[o,c]of We(n)){if(Object.hasOwn(s,o)){const $=H(c,s[o]??"");F(o,c,$),i[o]=$;continue}if(e||!r||c.internal){if(c.default!==void 0){F(o,c,c.default),i[o]=c.default;continue}if(c.required)throw new Error(`Required variable "${o}" not provided. Pass --${o}=<value> or remove --defaults.`);continue}const g=Pe(o,c);let m;if(c.type==="boolean")m=await ke(a,g,!!(c.default??!1));else if(c.type==="enum")if(c.multiple){const $=Array.isArray(c.default)?c.default:[];m=await _e(a,g,c.values,$)}else{const $=typeof c.default=="string"?c.default:void 0;m=await xe(a,g,c.values,$)}else{const $=c.default===void 0?"":` (${String(c.default)})`,S=await M(a,De(`${g}${$}`));if(S===""&&c.default!==void 0)m=c.default;else if(S===""){if(c.required)throw new Error(`Variable "${o}" is required`);continue}else m=H(c,S)}F(o,c,m),i[o]=m}return i}finally{a?.close()}},"collectOptions");var qe=Object.defineProperty,V=j((t,e)=>qe(t,"name",{value:e,configurable:!0}),"o");const Ie=["git://","npm://","https://","github:","gitlab:","bitbucket:","sourcehut:"],Me=V(t=>Ie.some(e=>t.startsWith(e)),"isRemoteSource"),Ce=V(async(t,e={})=>{const r=e.targetDirectory===void 0,s=e.targetDirectory??he(N($e(),"vis-generate-")),n=V(()=>{if(r)try{ge(s,{force:!0,recursive:!0})}catch{}},"cleanup");l.info(`Downloading ${t}…`);try{const i=await we(t,{auth:e.auth||process.env.GIGET_AUTH||process.env.GITHUB_TOKEN||process.env.GH_TOKEN||void 0,dir:s,force:!0,preferOffline:e.preferOffline});return{cleanup:n,directory:i.dir}}catch(i){n();const a=i instanceof Error?i.message:String(i);throw l.warn(`Failed to download template: ${a}`),i}},"fetchRemoteTemplate");var Ae=Object.defineProperty,R=j((t,e)=>Ae(t,"name",{value:e,configurable:!0}),"a");const re=R((t,e="")=>{const r=[];for(const[s,n]of Object.entries(t)){const i=e?`${e}/${s}`:s;typeof n=="string"||Buffer.isBuffer(n)?r.push({content:n,path:i}):n&&typeof n=="object"&&r.push(...re(n,i))}return r},"flattenTree"),Fe=R(t=>t<1024?`${t} B`:t<1024*1024?`${(t/1024).toFixed(1)} KB`:`${(t/(1024*1024)).toFixed(1)} MB`,"formatSize"),Le=R((t,e)=>{if(L(e))throw new Error(`Refusing to write outside destination: template produced absolute path "${e}".`);const r=N(t,e),s=X(t,r);if(s===".."||s.startsWith(`..${fe}`)||L(s))throw new Error(`Refusing to write outside destination: "${e}" resolves to "${r}" which escapes "${t}".`);return r},"safeJoinDestination"),Ve=R((t,e)=>{Z(Q(t)),pe(t,e)},"writeOne"),Ke=R((t,e,r=!1)=>{const s=typeof t=="string"?[t]:t.commands,n=typeof t=="string"?r:t.silent??r;for(const i of s){n||l.info(`$ ${i}`);const a=ye(i,{cwd:e,shell:!0,stdio:n?"ignore":"inherit"});if(a.status!==0)return l.warn(`Script failed (exit ${String(a.status)}): ${i}`),!1}return!0},"runScript"),ze=R(t=>{const e=new Map;for(const r of t){const s=typeof r=="string"?0:r.phase??0,n=e.get(s);n?n.push(r):e.set(s,[r])}return[...e.entries()].sort(([r],[s])=>r-s)},"groupByPhase"),Ue=R(async(t,e)=>{const r={builtins:{dest_dir:e.destination,dest_rel_dir:X(e.workspaceRoot,e.destination)||".",working_dir:e.cwd,workspace_root:e.workspaceRoot},options:e.options},s=await t.produce(r),n=s.files?re(s.files):[],i=s.filesMeta??{},a=[];for(const o of n){const c=Le(e.destination,o.path);a.push({file:o,meta:i[o.path]??{},target:c})}if(e.dryRun){l.info(`${b(T("Plan"))} ${f("(dry-run, no files written)")}`);for(const o of a){const c=Buffer.isBuffer(o.file.content)?o.file.content.length:Buffer.byteLength(o.file.content,"utf8");process.stderr.write(` ${f("write")} ${o.file.path} ${f(`(${Fe(c)})`)}
10
+ `)}}else{Z(e.destination);let o=0,c=0;for(const g of a){const{file:m,meta:$,target:S}=g,C=_(S),O=e.force||$.force===!0;if(C&&!O){l.warn(`Skipped existing file: ${m.path} (use --force or set frontmatter force: true to overwrite)`),c+=1;continue}Ve(S,m.content),o+=1}l.success(`Wrote ${String(o)} file${o===1?"":"s"}${c>0?`, skipped ${String(c)}`:""}`)}if(!e.dryRun&&!e.skipScripts&&s.scripts&&s.scripts.length>0){const o=ze(s.scripts);l.info(`Running ${String(s.scripts.length)} script${s.scripts.length===1?"":"s"} across ${String(o.length)} phase${o.length===1?"":"s"}…`);for(const[,c]of o)if((await Promise.all(c.map(g=>Promise.resolve(Ke(g,e.destination))))).includes(!1))throw new Error("Script failed — aborting.")}if(s.suggestions&&s.suggestions.length>0){process.stderr.write(`
11
11
  `),l.notice("Next steps:");for(const o of s.suggestions)process.stderr.write(` ${f("•")} ${o}
12
12
  `)}},"runTemplate");var Ge=Object.defineProperty,w=j((t,e)=>Ge(t,"name",{value:e,configurable:!0}),"u");const Je=w(async t=>{let e;try{e=(await t.load()).about?.description}catch{}return{description:e,name:t.name,path:t.path,source:t.source}},"toListEntry"),He=w((t,e)=>{const r={default:e.default,name:t,order:e.order,prompt:e.prompt,required:e.required,type:e.type};return e.type==="enum"&&(r.multiple=e.multiple,r.values=e.values),r},"summarizeVariable"),Ye=w(async t=>{const e=await t.load(),r=Object.entries(e.options??{}).sort(([s,n],[i,a])=>{const o=n.order??0,c=a.order??0;return o===c?s.localeCompare(i):o-c}).map(([s,n])=>He(s,n));return{description:e.about?.description??"",destination:e.destination,name:t.name,path:t.path,source:t.source,variables:r}},"describeTemplate"),Qe=w(t=>{if(t.length===0){l.info("No templates found."),l.notice("Create one at .vis/templates/<name>.ts (programmatic) or .vis/templates/<name>/ (moon-format with template.yml).");return}l.info("Available templates:");for(const e of t){const r=f(`(${e.source})`);process.stderr.write(` ${b(T(e.name))} ${r}
13
13
  `)}},"printList"),Xe=w(t=>{const e={},r=[];for(const s of t){if(!s.startsWith("--")){r.push(s);continue}const n=s.indexOf("=");if(n===-1){const o=s.slice(2);o.startsWith("no-")?e[o.slice(3)]="false":e[o]="true";continue}const i=s.slice(2,n),a=s.slice(n+1);e[i]=a}return{overrides:e,remaining:r}},"parsePassthroughOverrides"),Ze=w(async t=>{const{createInterface:e}=await import("node:readline"),r=e({input:process.stdin,output:process.stderr});try{process.stderr.write(` ${b(T("vis generate"))} ${f("— pick a template")}
@@ -17,6 +17,6 @@ var ae=Object.defineProperty;var j=(t,e)=>ae(t,"name",{value:e,configurable:!0})
17
17
  ${f(`Enter choice (1-${String(t.length)}):`)} `,i=>{const a=Number.parseInt(i.trim(),10);Number.isInteger(a)&&a>=1&&a<=t.length?s(t[a-1].name):n(new Error("Invalid choice."))})})}finally{r.close()}},"pickInteractive"),nt=w(async({argument:t,options:e,rawUnknown:r,visConfig:s,workspaceRoot:n})=>{const i=e.cwd||n||process.cwd(),a=n??i,o=s?.generator,c=Array.isArray(t)?t:t?[t]:[];if(e.list){const u=I({extraDirectories:o?.templates??[],onWarning:w(p=>{l.warn(p)},"onWarning"),workspaceRoot:a});if(e.json){const p=await Promise.all(u.map(d=>Je(d)));process.stdout.write(`${JSON.stringify(p,null,2)}
18
18
  `);return}Qe(u);return}if(e.describe){const u=c[0];if(!u)throw new Error("`--describe` requires a template name. Run `vis generate --list` to see available templates.");const p=I({extraDirectories:o?.templates??[],onWarning:w(h=>{l.warn(h)},"onWarning"),workspaceRoot:a}).find(h=>h.name===u);if(!p)throw new Error(`Template "${u}" not found. Run \`vis generate --list\` to see available templates.`);const d=await Ye(p);if(e.json){process.stdout.write(`${JSON.stringify(d,null,2)}
19
19
  `);return}if(l.info(`Template: ${b(T(d.name))} ${f(`(${d.source})`)}`),d.description&&l.info(d.description),d.destination&&l.info(`Destination: ${f(d.destination)}`),d.variables.length===0)l.info("No variables.");else{l.info("Variables:");for(const h of d.variables){const B=[h.type];h.required&&B.push("required"),h.default!==void 0&&B.push(`default=${JSON.stringify(h.default)}`),h.values&&B.push(`values=${h.values.join("|")}`),process.stderr.write(` ${b(T(h.name))} ${f(`(${B.join(", ")})`)}
20
- `)}}return}let g=[...r??[]];if(g.length===0){const u=process.argv.slice(2),p=u.indexOf("--");p!==-1&&(g=u.slice(p+1))}const m=c.indexOf("--"),$=m===-1?[]:c.slice(m+1),S=m===-1?c:c.slice(0,m),{overrides:C}=Xe([...$,...g]);let O,D,W;const k=S[0];let A;if(k&&Me(k)){const u=await Ce(k,{auth:o?.auth,preferOffline:!!e.preferOffline||o?.preferOffline});A=u.cleanup;try{const p=I({extraDirectories:[u.directory],workspaceRoot:a}).find(d=>d.path.startsWith(u.directory));if(!p)throw new Error(`Downloaded template at ${u.directory} contains no template.yml or *.ts entrypoint.`);O=await p.load(),D=p.name,W=O.destination}catch(p){throw A(),p}}else{const u=I({extraDirectories:o?.templates??[],onWarning:w(h=>{l.warn(h)},"onWarning"),workspaceRoot:a});if(u.length===0)throw new Error("No templates found. Create one at .vis/templates/<name>.ts or .vis/templates/<name>/template.yml.");let p;if(k)p=k;else{if(e.interactive===!1||!process.stdin.isTTY)throw new Error("No template specified. Pass a template name (see `vis generate --list`) or run interactively in a terminal.");p=await Ze(u)}const d=u.find(h=>h.name===p);if(!d)throw new Error(`Template "${p}" not found. Run 'vis generate --list' to see available templates.`);O=await d.load(),D=d.name,W=O.destination}const z=e.to,K=!!e.dryRun,se=!!e.force,U=!!e.defaults,oe=!!e.skipScripts,ne=e.interactive!==!1&&!!process.stdin.isTTY&&!U;let E;z?E=z:W?E=W:E=".";const G=L(E)?E:ue(i,E);l.info(`Template: ${b(T(D))}`),l.info(`Target: ${f(G)}`),process.stderr.write(`
21
- `);const ie=await Be({defaults:U,interactive:ne,overrides:C,variables:O.options??{}});try{await Ue(O,{cwd:i,destination:G,dryRun:K,force:se,options:ie,skipScripts:oe,workspaceRoot:a}),K||(process.stderr.write(`
22
- `),l.success(`Template '${D}' applied.`))}finally{A?.()}},"execute");export{nt as default};
20
+ `)}}return}let g=[...r??[]];if(g.length===0){const u=process.argv.slice(2),p=u.indexOf("--");p!==-1&&(g=u.slice(p+1))}const m=c.indexOf("--"),$=m===-1?[]:c.slice(m+1),S=m===-1?c:c.slice(0,m),{overrides:C}=Xe([...$,...g]);let O,P,W;const k=S[0];let A;if(k&&Me(k)){const u=await Ce(k,{auth:o?.auth,preferOffline:!!e.preferOffline||o?.preferOffline});A=u.cleanup;try{const p=I({extraDirectories:[u.directory],workspaceRoot:a}).find(d=>d.path.startsWith(u.directory));if(!p)throw new Error(`Downloaded template at ${u.directory} contains no template.yml or *.ts entrypoint.`);O=await p.load(),P=p.name,W=O.destination}catch(p){throw A(),p}}else{const u=I({extraDirectories:o?.templates??[],onWarning:w(h=>{l.warn(h)},"onWarning"),workspaceRoot:a});if(u.length===0)throw new Error("No templates found. Create one at .vis/templates/<name>.ts or .vis/templates/<name>/template.yml.");let p;if(k)p=k;else{if(e.interactive===!1||!process.stdin.isTTY)throw new Error("No template specified. Pass a template name (see `vis generate --list`) or run interactively in a terminal.");p=await Ze(u)}const d=u.find(h=>h.name===p);if(!d)throw new Error(`Template "${p}" not found. Run 'vis generate --list' to see available templates.`);O=await d.load(),P=d.name,W=O.destination}const K=e.to,z=!!e.dryRun,se=!!e.force,U=!!e.defaults,oe=!!e.skipScripts,ne=e.interactive!==!1&&!!process.stdin.isTTY&&!U;let E;K?E=K:W?E=W:E=".";const G=L(E)?E:ue(i,E);l.info(`Template: ${b(T(P))}`),l.info(`Target: ${f(G)}`),process.stderr.write(`
21
+ `);const ie=await Be({defaults:U,interactive:ne,overrides:C,variables:O.options??{}});try{await Ue(O,{cwd:i,destination:G,dryRun:z,force:se,options:ie,skipScripts:oe,workspaceRoot:a}),z||(process.stderr.write(`
22
+ `),l.success(`Template '${P}' applied.`))}finally{A?.()}},"execute");export{nt as default};
@@ -1,4 +1,4 @@
1
- var ie=Object.defineProperty;var k=(o,e)=>ie(o,"name",{value:e,configurable:!0});import{createRequire as le}from"node:module";import{aT as G,E,j as S,q as z,y as ae,m as pe,s as he}from"./bin.js";import{projectGraphToDot as ue}from"@visulima/task-runner";import{render as fe}from"@visulima/tui";import ge,{useSyncExternalStore as me,useState as $,useRef as W,useMemo as P,useCallback as q,useEffect as xe}from"react";import{jsx as n,jsxs as r}from"react/jsx-runtime";import{Box as i}from"@visulima/tui/components/box";import{Dialog as be}from"@visulima/tui/components/dialog";import{Text as t}from"@visulima/tui/components/text";import{useApp as ye}from"@visulima/tui/hooks/use-app";import{useInput as we}from"@visulima/tui/hooks/use-input";import{useWindowSize as ve}from"@visulima/tui/hooks/use-window-size";import{ScrollView as Ce}from"@visulima/tui/components/scroll-view";import{ScrollBar as Ae}from"@visulima/tui/components/scroll-bar";const de=le(import.meta.url),N=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,se=k(o=>{if(typeof N<"u"&&N.versions&&N.versions.node){const[e,l]=N.versions.node.split(".").map(Number);if(e>22||e===22&&l>=3||e===20&&l>=16)return N.getBuiltinModule(o)}return de(o)},"__cjs_getBuiltinModule"),{writeFileSync:ce}=se("node:fs");var Ee=Object.defineProperty,T=k((o,e)=>Ee(o,"name",{value:e,configurable:!0}),"l");const ke={application:0,library:3,service:1,tool:2},_=T(o=>ke[o]??Number.MAX_SAFE_INTEGER,"typeRank"),Me=T(o=>{const e=new Map;for(const[l,d]of Object.entries(o.dependencies))for(const c of d){const s=e.get(c.target)??[];s.push(l),e.set(c.target,s)}return Object.values(o.nodes).map(l=>({deps:o.dependencies[l.name]??[],name:l.name,reverseDeps:e.get(l.name)??[],type:l.type})).sort((l,d)=>l.type!==d.type?_(l.type)-_(d.type):l.name.localeCompare(d.name))},"buildNodes"),Se=T((o,e,l)=>{let d=o;if(e==="app"?d=d.filter(c=>c.type==="application"):e==="lib"&&(d=d.filter(c=>c.type!=="application")),l){const c=l.toLowerCase();d=d.filter(s=>s.name.toLowerCase().includes(c))}return d},"filterNodes");class Te{static{k(this,"GraphStore")}static{T(this,"GraphStore")}#e;#n=new Set;#r;constructor(e){this.#r=e;const l=Me(e);this.#e={allNodes:l,filterActive:!1,filterText:"",filterType:"all",focusedPanel:"list",selectedIndex:0}}getSnapshot=T(()=>this.#e,"getSnapshot");subscribe=T(e=>(this.#n.add(e),()=>{this.#n.delete(e)}),"subscribe");getFilteredNodes(){return Se(this.#e.allNodes,this.#e.filterType,this.#e.filterText)}getStats(){const e=this.#e.allNodes.filter(c=>c.type==="application").length,l=this.#e.allNodes.length,d=Object.values(this.#r.dependencies).reduce((c,s)=>c+s.length,0);return{apps:e,deps:d,libs:l-e,total:l}}setSelectedIndex(e){const l=this.getFilteredNodes(),d=l.length===0?-1:Math.max(0,Math.min(e,l.length-1));d!==this.#e.selectedIndex&&this.#t({...this.#e,selectedIndex:d})}setFocusedPanel(e){e!==this.#e.focusedPanel&&this.#t({...this.#e,focusedPanel:e})}setFilterType(e){e!==this.#e.filterType&&this.#t({...this.#e,filterType:e,selectedIndex:0})}setFilter(e){this.#t({...this.#e,filterText:e,selectedIndex:0})}setFilterActive(e){e!==this.#e.filterActive&&this.#t({...this.#e,filterActive:e,filterText:e?this.#e.filterText:"",selectedIndex:e?this.#e.selectedIndex:0})}#t(e){this.#e=e;for(const l of this.#n)try{l()}catch{}}}var je=Object.defineProperty,De=k((o,e)=>je(o,"name",{value:e,configurable:!0}),"p");const Ne=De(({focused:o,node:e,scrollRef:l})=>{const d=o?"white":"gray";if(!e)return n(i,{alignItems:"center",borderColor:"gray",borderStyle:"single",flexDirection:"column",flexGrow:1,justifyContent:"center",children:n(t,{dimColor:!0,children:"No project selected"})});const c=e.type==="application",s=c?"yellow":"cyan",f=c?"Application":"Library";return n(i,{borderColor:d,borderStyle:"single",borderTopRightTitle:` ${f} `,borderTopTitle:` ${e.name} `,flexDirection:"column",flexGrow:1,children:r(Ce,{flexGrow:1,flexShrink:1,paddingX:2,ref:l,scrollbar:!0,scrollbarColor:"gray",children:[r(i,{flexDirection:"column",marginTop:1,children:[r(i,{children:[n(t,{dimColor:!0,children:"── "}),n(t,{bold:!0,color:"white",children:"DEPENDS ON"}),r(t,{dimColor:!0,children:[" ","(",e.deps.length,")"]})]}),e.deps.length===0?n(i,{marginTop:1,paddingLeft:2,children:n(t,{dimColor:!0,children:"No dependencies"})}):n(i,{flexDirection:"column",marginTop:1,children:e.deps.map(a=>r(i,{gap:1,paddingLeft:2,children:[n(t,{color:"cyan",children:"→"}),n(t,{children:a.target}),a.type!=="static"&&r(t,{dimColor:!0,children:["(",a.type,")"]})]},a.target))})]}),r(i,{flexDirection:"column",marginTop:1,children:[r(i,{children:[n(t,{dimColor:!0,children:"── "}),n(t,{bold:!0,color:"white",children:"REQUIRED BY"}),r(t,{dimColor:!0,children:[" ","(",e.reverseDeps.length,")"]})]}),e.reverseDeps.length===0?n(i,{marginTop:1,paddingLeft:2,children:n(t,{dimColor:!0,children:"No reverse dependencies"})}):n(i,{flexDirection:"column",marginTop:1,children:e.reverseDeps.map(a=>r(i,{gap:1,paddingLeft:2,children:[n(t,{color:"magenta",children:"←"}),n(t,{children:a})]},a))})]}),r(i,{flexDirection:"column",marginTop:1,children:[r(i,{children:[n(t,{dimColor:!0,children:"── "}),n(t,{bold:!0,color:"white",children:"INFO"})]}),r(i,{flexDirection:"column",marginTop:1,paddingLeft:2,children:[r(i,{children:[n(i,{width:16,children:n(t,{dimColor:!0,children:"Type:"})}),n(t,{color:s,children:f})]}),r(i,{children:[n(i,{width:16,children:n(t,{dimColor:!0,children:"Dependencies:"})}),n(t,{children:String(e.deps.length)})]}),r(i,{children:[n(i,{width:16,children:n(t,{dimColor:!0,children:"Required by:"})}),n(t,{children:String(e.reverseDeps.length)})]}),r(i,{children:[n(i,{width:16,children:n(t,{dimColor:!0,children:"Connectivity:"})}),n(t,{children:String(e.deps.length+e.reverseDeps.length)})]})]})]})]})})},"ProjectDetailPanel");var Ie=Object.defineProperty,L=k((o,e)=>Ie(o,"name",{value:e,configurable:!0}),"m");const $e=[{key:"all",label:"All",shortcut:"1"},{key:"app",label:"Apps",shortcut:"2"},{key:"lib",label:"Libs",shortcut:"3"}],U=L(({isSelected:o,node:e})=>{const l=e.type==="application",d=l?"yellow":"cyan",c=l?"app":"lib";return r(i,{flexShrink:0,height:1,children:[r(t,{children:[o?"▶":" "," "]}),n(i,{flexGrow:1,children:n(t,{bold:o,inverse:o,wrap:"truncate",children:e.name})}),r(t,{color:d,children:[" ",c]}),r(t,{dimColor:!0,children:[" ","→",e.deps.length," ","←",e.reverseDeps.length]})]})},"ProjectRow"),Y=L(({count:o,label:e})=>r(i,{flexShrink:0,height:1,marginTop:1,children:[r(t,{dimColor:!0,children:["▼"," "]}),n(t,{bold:!0,color:"white",children:e.toUpperCase()}),r(t,{dimColor:!0,children:[" ","(",o,")"]})]}),"TypeHeader"),Pe=L(({filterActive:o,filterText:e,filterType:l,focused:d,nodes:c,scrollOffset:s,selectedIndex:f,stats:a,viewportHeight:y})=>{const m=d?"white":"gray",v=c.filter(w=>w.type==="application"),h=c.filter(w=>w.type!=="application"),g=[];let x=0;if(v.length>0){g.push(n(Y,{count:v.length,label:"Applications"},"hdr-apps"));for(const w of v){const A=x;g.push(n(U,{isSelected:A===f,node:w},w.name)),x++}}if(h.length>0){g.push(n(Y,{count:h.length,label:"Libraries"},"hdr-libs"));for(const w of h){const A=x;g.push(n(U,{isSelected:A===f,node:w},w.name)),x++}}let C=0;v.length>0&&(C+=2+v.length),h.length>0&&(C+=2+h.length);const M=C>y&&y>0;return r(i,{borderColor:m,borderStyle:"single",flexDirection:"column",flexGrow:1,children:[r(i,{flexShrink:0,gap:1,paddingX:1,children:[n(t,{bold:!0,inverse:!0,children:" VIS "}),r(t,{wrap:"truncate",children:[a.total," ","packages"]}),r(t,{dimColor:!0,children:["(",a.apps," ","apps,"," ",a.libs," ","libs,"," ",a.deps," ","deps)"]})]}),n(i,{flexShrink:0,gap:1,paddingX:1,paddingY:1,children:$e.map(w=>{const A=l===w.key;return r(i,{children:[n(t,{dimColor:!A,children:"["}),n(t,{bold:A,color:A?"cyan":"gray",children:w.shortcut}),n(t,{dimColor:!A,children:"]"}),r(t,{color:A?"white":"gray",children:[" ",w.label]})]},w.key)})}),o&&r(i,{flexShrink:0,paddingX:1,children:[n(t,{bold:!0,color:"white",children:"/ "}),n(t,{children:e}),n(t,{inverse:!0,children:" "})]}),r(i,{flexDirection:"row",flexGrow:1,overflow:"hidden",children:[n(i,{flexDirection:"column",flexGrow:1,overflow:"hidden",paddingLeft:1,children:n(i,{flexDirection:"column",marginTop:-s,children:g})}),M&&n(i,{flexShrink:0,marginLeft:1,marginRight:1,children:n(Ae,{contentHeight:C,placement:"inset",scrollOffset:s,style:"block",viewportHeight:y})})]})]})},"ProjectListPanel");var Le=Object.defineProperty,Oe=k((o,e)=>Le(o,"name",{value:e,configurable:!0}),"E");const Re=100,Be=40,Fe=10,X={1:"all",2:"app",3:"lib"},He=Oe(({autoExitSeconds:o=0,store:e})=>{const{exit:l}=ye(),{columns:d,rows:c}=ve(),s=me(e.subscribe,e.getSnapshot),[f,a]=$(!1),y=W(null),m=W(null),[v,h]=$(0),[g,x]=$(!1),C=P(()=>e.getFilteredNodes(),[s.allNodes,s.filterType,s.filterText]),M=P(()=>e.getStats(),[s.allNodes]),w=C[s.selectedIndex]??null,A=P(()=>{let u=0,p=0;for(const b of C)b.type==="application"?u+=1:p+=1;return{appsCount:u,libsCount:p}},[C]),O=q(u=>{const{appsCount:p,libsCount:b}=A;if(u<p)return(p>0?2:0)+u;const re=p>0?2+p:0,oe=b>0?2:0;return re+oe+(u-p)},[A]),I=Math.max(1,c-8-(s.filterActive?1:0)),D=q(u=>{const p=O(u);h(b=>p>b+I-2?Math.max(0,p-I+2):p<b+1?Math.max(0,p-1):b)},[O,I]);if(xe(()=>{m.current?.scrollToTop()},[w?.name]),we((u,p)=>{if(u==="c"&&p.ctrl){l();return}if(!g){if(f){p.escape||u==="?"?a(!1):u==="q"?(a(!1),x(!0)):p.downArrow||u==="j"?y.current?.scrollBy(1):(p.upArrow||u==="k")&&y.current?.scrollBy(-1);return}if(u==="?"){a(!0);return}if(u==="q"){x(!0);return}if(p.tab){e.setFocusedPanel(s.focusedPanel==="list"?"detail":"list");return}if(X[u]){e.setFilterType(X[u]);return}if(s.filterActive){if(p.escape){e.setFilterActive(!1);return}if(p.return){e.setFilterActive(!1);return}if(p.backspace){e.setFilter(s.filterText.slice(0,-1));return}if(u&&!p.ctrl&&!p.meta){e.setFilter(s.filterText+u);return}return}if(s.focusedPanel==="list"){if(C.length===0){u==="/"&&e.setFilterActive(!0);return}if(p.downArrow||u==="j"){const b=Math.min(s.selectedIndex+1,C.length-1);e.setSelectedIndex(b),D(b);return}if(p.upArrow||u==="k"){const b=Math.max(s.selectedIndex-1,0);e.setSelectedIndex(b),D(b);return}if(p.pageDown){const b=Math.min(s.selectedIndex+10,C.length-1);e.setSelectedIndex(b),D(b);return}if(p.pageUp){const b=Math.max(s.selectedIndex-10,0);e.setSelectedIndex(b),D(b);return}if(p.home){e.setSelectedIndex(0),h(0);return}if(p.end){const b=C.length-1;e.setSelectedIndex(b),D(b);return}if(u==="/"){e.setFilterActive(!0);return}if(p.rightArrow){e.setFocusedPanel("detail");return}return}if(s.focusedPanel==="detail"){if(p.escape||p.leftArrow){e.setFocusedPanel("list");return}if(p.downArrow||u==="j"){m.current?.scrollBy(1);return}if(p.upArrow||u==="k"){m.current?.scrollBy(-1);return}if(p.pageDown){m.current?.scrollBy(10);return}if(p.pageUp){m.current?.scrollBy(-10);return}if(p.home){m.current?.scrollToTop();return}p.end&&m.current?.scrollToBottom()}}},{isActive:!0}),d<Be||c<Fe)return n(i,{alignItems:"center",height:c,justifyContent:"center",width:d,children:r(t,{color:"yellow",children:["Terminal too small (",d,"x",c,")"]})});const te=d>=Re,R=n(i,{borderBottom:!1,borderColor:"gray",borderLeft:!1,borderRight:!1,borderStyle:"single",flexShrink:0,children:r(i,{flexWrap:"wrap",gap:2,paddingX:1,children:[r(i,{gap:1,children:[n(t,{bold:!0,color:"white",children:"q"}),n(t,{dimColor:!0,children:"QUIT"})]},"q"),r(i,{gap:1,children:[n(t,{bold:!0,color:"white",children:"?"}),n(t,{dimColor:!0,children:"HELP"})]},"?"),r(i,{gap:1,children:[n(t,{bold:!0,color:"white",children:"↑↓"}),n(t,{dimColor:!0,children:"NAV"})]},"nav"),r(i,{gap:1,children:[n(t,{bold:!0,color:"white",children:"1-3 /"}),n(t,{dimColor:!0,children:"FILTER"})]},"f"),r(i,{gap:1,children:[n(t,{bold:!0,color:"white",children:"Tab"}),n(t,{dimColor:!0,children:"PANEL"})]},"t")]})}),B=r(be,{footer:r(t,{dimColor:!0,children:[n(t,{bold:!0,color:"white",children:"↑↓"})," ","scroll"," ",n(t,{bold:!0,color:"white",children:"?"}),"/",n(t,{bold:!0,color:"white",children:"Esc"})," ","close"]}),scrollRef:y,title:"KEYBOARD SHORTCUTS",visible:f,width:52,children:[r(i,{flexDirection:"column",marginBottom:1,children:[r(i,{marginBottom:1,children:[n(t,{dimColor:!0,children:"── "}),n(t,{bold:!0,color:"white",children:"NAVIGATION"})]}),r(i,{children:[n(i,{width:24,children:r(t,{children:[r(t,{bold:!0,color:"white",children:[" ","↑","/k"]}),n(t,{dimColor:!0,children:" Move up"})]})}),r(t,{children:[r(t,{bold:!0,color:"white",children:[" ","↓","/j"]}),n(t,{dimColor:!0,children:" Move down"})]})]}),r(t,{children:[r(t,{bold:!0,color:"white",children:[" ","Tab"]}),n(t,{dimColor:!0,children:" Switch panel"})]}),r(t,{children:[r(t,{bold:!0,color:"white",children:[" ","→","/","←"]}),n(t,{dimColor:!0,children:" Focus detail/list"})]}),r(t,{children:[r(t,{bold:!0,color:"white",children:[" ","PgUp/PgDn"]}),n(t,{dimColor:!0,children:" Jump 10 items"})]}),r(t,{children:[r(t,{bold:!0,color:"white",children:[" ","Home/End"]}),n(t,{dimColor:!0,children:" Jump to start/end"})]})]}),r(i,{flexDirection:"column",marginBottom:1,children:[r(i,{marginBottom:1,children:[n(t,{dimColor:!0,children:"── "}),n(t,{bold:!0,color:"white",children:"FILTERS"})]}),r(i,{children:[n(i,{width:24,children:r(t,{children:[r(t,{bold:!0,color:"white",children:[" ","1"]}),n(t,{dimColor:!0,children:" All"})]})}),r(t,{children:[r(t,{bold:!0,color:"white",children:[" ","2"]}),n(t,{dimColor:!0,children:" Apps only"})]})]}),r(t,{children:[r(t,{bold:!0,color:"white",children:[" ","3"]}),n(t,{dimColor:!0,children:" Libraries only"})]}),r(t,{children:[r(t,{bold:!0,color:"white",children:[" ","/"]}),n(t,{dimColor:!0,children:" Text filter"})]})]}),r(i,{flexDirection:"column",children:[r(i,{marginBottom:1,children:[n(t,{dimColor:!0,children:"── "}),n(t,{bold:!0,color:"white",children:"ACTIONS"})]}),r(t,{children:[r(t,{bold:!0,color:"white",children:[" ","q"]}),n(t,{dimColor:!0,children:" Quit"})]}),r(t,{children:[r(t,{bold:!0,color:"white",children:[" ","?"]}),n(t,{dimColor:!0,children:" Toggle help"})]})]})]}),F=n(Pe,{filterActive:s.filterActive,filterText:s.filterText,filterType:s.filterType,focused:s.focusedPanel==="list",nodes:C,scrollOffset:v,selectedIndex:s.selectedIndex,stats:M,viewportHeight:I}),H=n(Ne,{focused:s.focusedPanel==="detail",node:w,scrollRef:m});if(te){const u=Math.floor(d*.35);return r(i,{flexDirection:"column",height:c,width:d,children:[r(i,{flexDirection:"row",flexGrow:1,children:[n(i,{flexGrow:1,children:F}),n(i,{width:u,children:H})]}),R,n(G,{autoExitSeconds:o??3,onCancel:k(()=>{x(!1)},"onCancel"),visible:g}),B]})}const ne=Math.floor(c*.55);return r(i,{flexDirection:"column",height:c,width:d,children:[n(i,{height:ne,children:F}),n(i,{flexGrow:1,children:H}),R,n(G,{autoExitSeconds:o??3,onCancel:k(()=>{x(!1)},"onCancel"),visible:g}),B]})},"VisGraphApp");var J=Object.freeze,Z=Object.defineProperty,j=k((o,e)=>Z(o,"name",{value:e,configurable:!0}),"x"),Ge=k((o,e)=>J(Z(o,"raw",{value:J(e||o.slice())})),"C");const ee=j((o,e,l,d,c,s,f,a)=>{const y=l?E("└── "):E("├── "),m=c.has(o),v=m?E(" (*)"):"",h=d.get(o),g=h?.type==="application"?S(o):o;if(s.push(`${e}${y}${g}${v}`),m)return;c.add(o);const x=h?.deps??[],C=l?`${e} `:`${e}${E("│")} `;if(a>=f&&x.length>0){s.push(`${C}${E(`... ${x.length} more`)}`);return}for(let M=0;M<x.length;M++){const w=x[M];w&&ee(w.target,C,M===x.length-1,d,c,s,f,a+1)}},"printDepsTree"),V=j((o,e,l,d,c,s)=>{const f=e.get(o),a=f?.type==="application"?S(o):o;d.push(`${s}${a}`),l.add(o);const y=f?.deps??[];if(y.length===0){d.push(`${s} ${E("(no dependencies)")}`);return}if(c<=0){d.push(`${s} ${E(`... ${y.length} dependencies`)}`);return}for(let m=0;m<y.length;m++){const v=y[m];v&&ee(v.target,s,m===y.length-1,e,l,d,c,1)}},"printRootProject"),Q=j((o,e)=>{const l=new Map;for(const[h,g]of Object.entries(o.nodes))l.set(h,{deps:(o.dependencies[h]??[]).map(x=>({target:x.target,type:x.type})),name:h,type:g.type});const d=[],c=[];for(const[h,g]of l)g.type==="application"?d.push(h):c.push(h);d.sort(),c.sort();const s=d.length+c.length,f=Object.values(o.dependencies).reduce((h,g)=>h+g.length,0),a=[S("Project Dependency Graph"),""];if(d.length>0){a.push(` ${S(z(`Applications (${d.length})`))}`,"");for(const h of d)V(h,l,new Set,a,e," "),a.push("")}if(c.length>0){a.push(` ${S(z(`Libraries (${c.length})`))}`,"");for(const h of c)V(h,l,new Set,a,e," "),a.push("")}const y=process.stdout.columns||80;a.push(E("─".repeat(Math.min(y,60)))),a.push(`${S(String(s))} packages ${E("·")} ${S(String(f))} dependencies ${E("·")} ${S(String(d.length))} apps${E(",")} ${S(String(c.length))} libraries`);const m=new Set;let v=!1;for(const h of[...d,...c]){const g=l.get(h)?.deps??[];for(const x of g)m.has(x.target)&&(v=!0),m.add(x.target);m.add(h)}return v&&a.push(E("(*) = already shown above")),a.join(`
1
+ var ie=Object.defineProperty;var k=(o,e)=>ie(o,"name",{value:e,configurable:!0});import{createRequire as le}from"node:module";import{aV as G,E,j as S,q as z,C as ae,O as pe,s as he}from"./bin.js";import{projectGraphToDot as ue}from"@visulima/task-runner";import{render as fe}from"@visulima/tui";import ge,{useSyncExternalStore as me,useState as $,useRef as W,useMemo as O,useCallback as q,useEffect as xe}from"react";import{jsx as n,jsxs as r}from"react/jsx-runtime";import{Box as i}from"@visulima/tui/components/box";import{Dialog as be}from"@visulima/tui/components/dialog";import{Text as t}from"@visulima/tui/components/text";import{useApp as ye}from"@visulima/tui/hooks/use-app";import{useInput as we}from"@visulima/tui/hooks/use-input";import{useWindowSize as ve}from"@visulima/tui/hooks/use-window-size";import{ScrollView as Ce}from"@visulima/tui/components/scroll-view";import{ScrollBar as Ae}from"@visulima/tui/components/scroll-bar";const de=le(import.meta.url),N=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,se=k(o=>{if(typeof N<"u"&&N.versions&&N.versions.node){const[e,l]=N.versions.node.split(".").map(Number);if(e>22||e===22&&l>=3||e===20&&l>=16)return N.getBuiltinModule(o)}return de(o)},"__cjs_getBuiltinModule"),{writeFileSync:ce}=se("node:fs");var Ee=Object.defineProperty,T=k((o,e)=>Ee(o,"name",{value:e,configurable:!0}),"l");const ke={application:0,library:3,service:1,tool:2},_=T(o=>ke[o]??Number.MAX_SAFE_INTEGER,"typeRank"),Me=T(o=>{const e=new Map;for(const[l,d]of Object.entries(o.dependencies))for(const c of d){const s=e.get(c.target)??[];s.push(l),e.set(c.target,s)}return Object.values(o.nodes).map(l=>({deps:o.dependencies[l.name]??[],name:l.name,reverseDeps:e.get(l.name)??[],type:l.type})).sort((l,d)=>l.type!==d.type?_(l.type)-_(d.type):l.name.localeCompare(d.name))},"buildNodes"),Se=T((o,e,l)=>{let d=o;if(e==="app"?d=d.filter(c=>c.type==="application"):e==="lib"&&(d=d.filter(c=>c.type!=="application")),l){const c=l.toLowerCase();d=d.filter(s=>s.name.toLowerCase().includes(c))}return d},"filterNodes");class Te{static{k(this,"GraphStore")}static{T(this,"GraphStore")}#e;#n=new Set;#r;constructor(e){this.#r=e;const l=Me(e);this.#e={allNodes:l,filterActive:!1,filterText:"",filterType:"all",focusedPanel:"list",selectedIndex:0}}getSnapshot=T(()=>this.#e,"getSnapshot");subscribe=T(e=>(this.#n.add(e),()=>{this.#n.delete(e)}),"subscribe");getFilteredNodes(){return Se(this.#e.allNodes,this.#e.filterType,this.#e.filterText)}getStats(){const e=this.#e.allNodes.filter(c=>c.type==="application").length,l=this.#e.allNodes.length,d=Object.values(this.#r.dependencies).reduce((c,s)=>c+s.length,0);return{apps:e,deps:d,libs:l-e,total:l}}setSelectedIndex(e){const l=this.getFilteredNodes(),d=l.length===0?-1:Math.max(0,Math.min(e,l.length-1));d!==this.#e.selectedIndex&&this.#t({...this.#e,selectedIndex:d})}setFocusedPanel(e){e!==this.#e.focusedPanel&&this.#t({...this.#e,focusedPanel:e})}setFilterType(e){e!==this.#e.filterType&&this.#t({...this.#e,filterType:e,selectedIndex:0})}setFilter(e){this.#t({...this.#e,filterText:e,selectedIndex:0})}setFilterActive(e){e!==this.#e.filterActive&&this.#t({...this.#e,filterActive:e,filterText:e?this.#e.filterText:"",selectedIndex:e?this.#e.selectedIndex:0})}#t(e){this.#e=e;for(const l of this.#n)try{l()}catch{}}}var je=Object.defineProperty,De=k((o,e)=>je(o,"name",{value:e,configurable:!0}),"p");const Ne=De(({focused:o,node:e,scrollRef:l})=>{const d=o?"white":"gray";if(!e)return n(i,{alignItems:"center",borderColor:"gray",borderStyle:"single",flexDirection:"column",flexGrow:1,justifyContent:"center",children:n(t,{dimColor:!0,children:"No project selected"})});const c=e.type==="application",s=c?"yellow":"cyan",f=c?"Application":"Library";return n(i,{borderColor:d,borderStyle:"single",borderTopRightTitle:` ${f} `,borderTopTitle:` ${e.name} `,flexDirection:"column",flexGrow:1,children:r(Ce,{flexGrow:1,flexShrink:1,paddingX:2,ref:l,scrollbar:!0,scrollbarColor:"gray",children:[r(i,{flexDirection:"column",marginTop:1,children:[r(i,{children:[n(t,{dimColor:!0,children:"── "}),n(t,{bold:!0,color:"white",children:"DEPENDS ON"}),r(t,{dimColor:!0,children:[" ","(",e.deps.length,")"]})]}),e.deps.length===0?n(i,{marginTop:1,paddingLeft:2,children:n(t,{dimColor:!0,children:"No dependencies"})}):n(i,{flexDirection:"column",marginTop:1,children:e.deps.map(a=>r(i,{gap:1,paddingLeft:2,children:[n(t,{color:"cyan",children:"→"}),n(t,{children:a.target}),a.type!=="static"&&r(t,{dimColor:!0,children:["(",a.type,")"]})]},a.target))})]}),r(i,{flexDirection:"column",marginTop:1,children:[r(i,{children:[n(t,{dimColor:!0,children:"── "}),n(t,{bold:!0,color:"white",children:"REQUIRED BY"}),r(t,{dimColor:!0,children:[" ","(",e.reverseDeps.length,")"]})]}),e.reverseDeps.length===0?n(i,{marginTop:1,paddingLeft:2,children:n(t,{dimColor:!0,children:"No reverse dependencies"})}):n(i,{flexDirection:"column",marginTop:1,children:e.reverseDeps.map(a=>r(i,{gap:1,paddingLeft:2,children:[n(t,{color:"magenta",children:"←"}),n(t,{children:a})]},a))})]}),r(i,{flexDirection:"column",marginTop:1,children:[r(i,{children:[n(t,{dimColor:!0,children:"── "}),n(t,{bold:!0,color:"white",children:"INFO"})]}),r(i,{flexDirection:"column",marginTop:1,paddingLeft:2,children:[r(i,{children:[n(i,{width:16,children:n(t,{dimColor:!0,children:"Type:"})}),n(t,{color:s,children:f})]}),r(i,{children:[n(i,{width:16,children:n(t,{dimColor:!0,children:"Dependencies:"})}),n(t,{children:String(e.deps.length)})]}),r(i,{children:[n(i,{width:16,children:n(t,{dimColor:!0,children:"Required by:"})}),n(t,{children:String(e.reverseDeps.length)})]}),r(i,{children:[n(i,{width:16,children:n(t,{dimColor:!0,children:"Connectivity:"})}),n(t,{children:String(e.deps.length+e.reverseDeps.length)})]})]})]})]})})},"ProjectDetailPanel");var Ie=Object.defineProperty,P=k((o,e)=>Ie(o,"name",{value:e,configurable:!0}),"m");const $e=[{key:"all",label:"All",shortcut:"1"},{key:"app",label:"Apps",shortcut:"2"},{key:"lib",label:"Libs",shortcut:"3"}],U=P(({isSelected:o,node:e})=>{const l=e.type==="application",d=l?"yellow":"cyan",c=l?"app":"lib";return r(i,{flexShrink:0,height:1,children:[r(t,{children:[o?"▶":" "," "]}),n(i,{flexGrow:1,children:n(t,{bold:o,inverse:o,wrap:"truncate",children:e.name})}),r(t,{color:d,children:[" ",c]}),r(t,{dimColor:!0,children:[" ","→",e.deps.length," ","←",e.reverseDeps.length]})]})},"ProjectRow"),Y=P(({count:o,label:e})=>r(i,{flexShrink:0,height:1,marginTop:1,children:[r(t,{dimColor:!0,children:["▼"," "]}),n(t,{bold:!0,color:"white",children:e.toUpperCase()}),r(t,{dimColor:!0,children:[" ","(",o,")"]})]}),"TypeHeader"),Oe=P(({filterActive:o,filterText:e,filterType:l,focused:d,nodes:c,scrollOffset:s,selectedIndex:f,stats:a,viewportHeight:y})=>{const m=d?"white":"gray",v=c.filter(w=>w.type==="application"),h=c.filter(w=>w.type!=="application"),g=[];let x=0;if(v.length>0){g.push(n(Y,{count:v.length,label:"Applications"},"hdr-apps"));for(const w of v){const A=x;g.push(n(U,{isSelected:A===f,node:w},w.name)),x++}}if(h.length>0){g.push(n(Y,{count:h.length,label:"Libraries"},"hdr-libs"));for(const w of h){const A=x;g.push(n(U,{isSelected:A===f,node:w},w.name)),x++}}let C=0;v.length>0&&(C+=2+v.length),h.length>0&&(C+=2+h.length);const M=C>y&&y>0;return r(i,{borderColor:m,borderStyle:"single",flexDirection:"column",flexGrow:1,children:[r(i,{flexShrink:0,gap:1,paddingX:1,children:[n(t,{bold:!0,inverse:!0,children:" VIS "}),r(t,{wrap:"truncate",children:[a.total," ","packages"]}),r(t,{dimColor:!0,children:["(",a.apps," ","apps,"," ",a.libs," ","libs,"," ",a.deps," ","deps)"]})]}),n(i,{flexShrink:0,gap:1,paddingX:1,paddingY:1,children:$e.map(w=>{const A=l===w.key;return r(i,{children:[n(t,{dimColor:!A,children:"["}),n(t,{bold:A,color:A?"cyan":"gray",children:w.shortcut}),n(t,{dimColor:!A,children:"]"}),r(t,{color:A?"white":"gray",children:[" ",w.label]})]},w.key)})}),o&&r(i,{flexShrink:0,paddingX:1,children:[n(t,{bold:!0,color:"white",children:"/ "}),n(t,{children:e}),n(t,{inverse:!0,children:" "})]}),r(i,{flexDirection:"row",flexGrow:1,overflow:"hidden",children:[n(i,{flexDirection:"column",flexGrow:1,overflow:"hidden",paddingLeft:1,children:n(i,{flexDirection:"column",marginTop:-s,children:g})}),M&&n(i,{flexShrink:0,marginLeft:1,marginRight:1,children:n(Ae,{contentHeight:C,placement:"inset",scrollOffset:s,style:"block",viewportHeight:y})})]})]})},"ProjectListPanel");var Pe=Object.defineProperty,Le=k((o,e)=>Pe(o,"name",{value:e,configurable:!0}),"E");const Re=100,Be=40,Fe=10,X={1:"all",2:"app",3:"lib"},He=Le(({autoExitSeconds:o=0,store:e})=>{const{exit:l}=ye(),{columns:d,rows:c}=ve(),s=me(e.subscribe,e.getSnapshot),[f,a]=$(!1),y=W(null),m=W(null),[v,h]=$(0),[g,x]=$(!1),C=O(()=>e.getFilteredNodes(),[s.allNodes,s.filterType,s.filterText]),M=O(()=>e.getStats(),[s.allNodes]),w=C[s.selectedIndex]??null,A=O(()=>{let u=0,p=0;for(const b of C)b.type==="application"?u+=1:p+=1;return{appsCount:u,libsCount:p}},[C]),L=q(u=>{const{appsCount:p,libsCount:b}=A;if(u<p)return(p>0?2:0)+u;const re=p>0?2+p:0,oe=b>0?2:0;return re+oe+(u-p)},[A]),I=Math.max(1,c-8-(s.filterActive?1:0)),D=q(u=>{const p=L(u);h(b=>p>b+I-2?Math.max(0,p-I+2):p<b+1?Math.max(0,p-1):b)},[L,I]);if(xe(()=>{m.current?.scrollToTop()},[w?.name]),we((u,p)=>{if(u==="c"&&p.ctrl){l();return}if(!g){if(f){p.escape||u==="?"?a(!1):u==="q"?(a(!1),x(!0)):p.downArrow||u==="j"?y.current?.scrollBy(1):(p.upArrow||u==="k")&&y.current?.scrollBy(-1);return}if(u==="?"){a(!0);return}if(u==="q"){x(!0);return}if(p.tab){e.setFocusedPanel(s.focusedPanel==="list"?"detail":"list");return}if(X[u]){e.setFilterType(X[u]);return}if(s.filterActive){if(p.escape){e.setFilterActive(!1);return}if(p.return){e.setFilterActive(!1);return}if(p.backspace){e.setFilter(s.filterText.slice(0,-1));return}if(u&&!p.ctrl&&!p.meta){e.setFilter(s.filterText+u);return}return}if(s.focusedPanel==="list"){if(C.length===0){u==="/"&&e.setFilterActive(!0);return}if(p.downArrow||u==="j"){const b=Math.min(s.selectedIndex+1,C.length-1);e.setSelectedIndex(b),D(b);return}if(p.upArrow||u==="k"){const b=Math.max(s.selectedIndex-1,0);e.setSelectedIndex(b),D(b);return}if(p.pageDown){const b=Math.min(s.selectedIndex+10,C.length-1);e.setSelectedIndex(b),D(b);return}if(p.pageUp){const b=Math.max(s.selectedIndex-10,0);e.setSelectedIndex(b),D(b);return}if(p.home){e.setSelectedIndex(0),h(0);return}if(p.end){const b=C.length-1;e.setSelectedIndex(b),D(b);return}if(u==="/"){e.setFilterActive(!0);return}if(p.rightArrow){e.setFocusedPanel("detail");return}return}if(s.focusedPanel==="detail"){if(p.escape||p.leftArrow){e.setFocusedPanel("list");return}if(p.downArrow||u==="j"){m.current?.scrollBy(1);return}if(p.upArrow||u==="k"){m.current?.scrollBy(-1);return}if(p.pageDown){m.current?.scrollBy(10);return}if(p.pageUp){m.current?.scrollBy(-10);return}if(p.home){m.current?.scrollToTop();return}p.end&&m.current?.scrollToBottom()}}},{isActive:!0}),d<Be||c<Fe)return n(i,{alignItems:"center",height:c,justifyContent:"center",width:d,children:r(t,{color:"yellow",children:["Terminal too small (",d,"x",c,")"]})});const te=d>=Re,R=n(i,{borderBottom:!1,borderColor:"gray",borderLeft:!1,borderRight:!1,borderStyle:"single",flexShrink:0,children:r(i,{flexWrap:"wrap",gap:2,paddingX:1,children:[r(i,{gap:1,children:[n(t,{bold:!0,color:"white",children:"q"}),n(t,{dimColor:!0,children:"QUIT"})]},"q"),r(i,{gap:1,children:[n(t,{bold:!0,color:"white",children:"?"}),n(t,{dimColor:!0,children:"HELP"})]},"?"),r(i,{gap:1,children:[n(t,{bold:!0,color:"white",children:"↑↓"}),n(t,{dimColor:!0,children:"NAV"})]},"nav"),r(i,{gap:1,children:[n(t,{bold:!0,color:"white",children:"1-3 /"}),n(t,{dimColor:!0,children:"FILTER"})]},"f"),r(i,{gap:1,children:[n(t,{bold:!0,color:"white",children:"Tab"}),n(t,{dimColor:!0,children:"PANEL"})]},"t")]})}),B=r(be,{footer:r(t,{dimColor:!0,children:[n(t,{bold:!0,color:"white",children:"↑↓"})," ","scroll"," ",n(t,{bold:!0,color:"white",children:"?"}),"/",n(t,{bold:!0,color:"white",children:"Esc"})," ","close"]}),scrollRef:y,title:"KEYBOARD SHORTCUTS",visible:f,width:52,children:[r(i,{flexDirection:"column",marginBottom:1,children:[r(i,{marginBottom:1,children:[n(t,{dimColor:!0,children:"── "}),n(t,{bold:!0,color:"white",children:"NAVIGATION"})]}),r(i,{children:[n(i,{width:24,children:r(t,{children:[r(t,{bold:!0,color:"white",children:[" ","↑","/k"]}),n(t,{dimColor:!0,children:" Move up"})]})}),r(t,{children:[r(t,{bold:!0,color:"white",children:[" ","↓","/j"]}),n(t,{dimColor:!0,children:" Move down"})]})]}),r(t,{children:[r(t,{bold:!0,color:"white",children:[" ","Tab"]}),n(t,{dimColor:!0,children:" Switch panel"})]}),r(t,{children:[r(t,{bold:!0,color:"white",children:[" ","→","/","←"]}),n(t,{dimColor:!0,children:" Focus detail/list"})]}),r(t,{children:[r(t,{bold:!0,color:"white",children:[" ","PgUp/PgDn"]}),n(t,{dimColor:!0,children:" Jump 10 items"})]}),r(t,{children:[r(t,{bold:!0,color:"white",children:[" ","Home/End"]}),n(t,{dimColor:!0,children:" Jump to start/end"})]})]}),r(i,{flexDirection:"column",marginBottom:1,children:[r(i,{marginBottom:1,children:[n(t,{dimColor:!0,children:"── "}),n(t,{bold:!0,color:"white",children:"FILTERS"})]}),r(i,{children:[n(i,{width:24,children:r(t,{children:[r(t,{bold:!0,color:"white",children:[" ","1"]}),n(t,{dimColor:!0,children:" All"})]})}),r(t,{children:[r(t,{bold:!0,color:"white",children:[" ","2"]}),n(t,{dimColor:!0,children:" Apps only"})]})]}),r(t,{children:[r(t,{bold:!0,color:"white",children:[" ","3"]}),n(t,{dimColor:!0,children:" Libraries only"})]}),r(t,{children:[r(t,{bold:!0,color:"white",children:[" ","/"]}),n(t,{dimColor:!0,children:" Text filter"})]})]}),r(i,{flexDirection:"column",children:[r(i,{marginBottom:1,children:[n(t,{dimColor:!0,children:"── "}),n(t,{bold:!0,color:"white",children:"ACTIONS"})]}),r(t,{children:[r(t,{bold:!0,color:"white",children:[" ","q"]}),n(t,{dimColor:!0,children:" Quit"})]}),r(t,{children:[r(t,{bold:!0,color:"white",children:[" ","?"]}),n(t,{dimColor:!0,children:" Toggle help"})]})]})]}),F=n(Oe,{filterActive:s.filterActive,filterText:s.filterText,filterType:s.filterType,focused:s.focusedPanel==="list",nodes:C,scrollOffset:v,selectedIndex:s.selectedIndex,stats:M,viewportHeight:I}),H=n(Ne,{focused:s.focusedPanel==="detail",node:w,scrollRef:m});if(te){const u=Math.floor(d*.35);return r(i,{flexDirection:"column",height:c,width:d,children:[r(i,{flexDirection:"row",flexGrow:1,children:[n(i,{flexGrow:1,children:F}),n(i,{width:u,children:H})]}),R,n(G,{autoExitSeconds:o??3,onCancel:k(()=>{x(!1)},"onCancel"),visible:g}),B]})}const ne=Math.floor(c*.55);return r(i,{flexDirection:"column",height:c,width:d,children:[n(i,{height:ne,children:F}),n(i,{flexGrow:1,children:H}),R,n(G,{autoExitSeconds:o??3,onCancel:k(()=>{x(!1)},"onCancel"),visible:g}),B]})},"VisGraphApp");var J=Object.freeze,Z=Object.defineProperty,j=k((o,e)=>Z(o,"name",{value:e,configurable:!0}),"x"),Ge=k((o,e)=>J(Z(o,"raw",{value:J(e||o.slice())})),"C");const ee=j((o,e,l,d,c,s,f,a)=>{const y=l?E("└── "):E("├── "),m=c.has(o),v=m?E(" (*)"):"",h=d.get(o),g=h?.type==="application"?S(o):o;if(s.push(`${e}${y}${g}${v}`),m)return;c.add(o);const x=h?.deps??[],C=l?`${e} `:`${e}${E("│")} `;if(a>=f&&x.length>0){s.push(`${C}${E(`... ${x.length} more`)}`);return}for(let M=0;M<x.length;M++){const w=x[M];w&&ee(w.target,C,M===x.length-1,d,c,s,f,a+1)}},"printDepsTree"),V=j((o,e,l,d,c,s)=>{const f=e.get(o),a=f?.type==="application"?S(o):o;d.push(`${s}${a}`),l.add(o);const y=f?.deps??[];if(y.length===0){d.push(`${s} ${E("(no dependencies)")}`);return}if(c<=0){d.push(`${s} ${E(`... ${y.length} dependencies`)}`);return}for(let m=0;m<y.length;m++){const v=y[m];v&&ee(v.target,s,m===y.length-1,e,l,d,c,1)}},"printRootProject"),Q=j((o,e)=>{const l=new Map;for(const[h,g]of Object.entries(o.nodes))l.set(h,{deps:(o.dependencies[h]??[]).map(x=>({target:x.target,type:x.type})),name:h,type:g.type});const d=[],c=[];for(const[h,g]of l)g.type==="application"?d.push(h):c.push(h);d.sort(),c.sort();const s=d.length+c.length,f=Object.values(o.dependencies).reduce((h,g)=>h+g.length,0),a=[S("Project Dependency Graph"),""];if(d.length>0){a.push(` ${S(z(`Applications (${d.length})`))}`,"");for(const h of d)V(h,l,new Set,a,e," "),a.push("")}if(c.length>0){a.push(` ${S(z(`Libraries (${c.length})`))}`,"");for(const h of c)V(h,l,new Set,a,e," "),a.push("")}const y=process.stdout.columns||80;a.push(E("─".repeat(Math.min(y,60)))),a.push(`${S(String(s))} packages ${E("·")} ${S(String(f))} dependencies ${E("·")} ${S(String(d.length))} apps${E(",")} ${S(String(c.length))} libraries`);const m=new Set;let v=!1;for(const h of[...d,...c]){const g=l.get(h)?.deps??[];for(const x of g)m.has(x.target)&&(v=!0),m.add(x.target);m.add(h)}return v&&a.push(E("(*) = already shown above")),a.join(`
2
2
  `)},"projectGraphToAscii"),ze=j(o=>{const e=Object.values(o.nodes).map(l=>({name:l.name,type:l.type}));return{edges:Object.values(o.dependencies).flat(),nodes:e}},"projectGraphToJson");var K;const We=j(o=>{const e=Object.values(o.nodes).map(f=>({name:f.name,type:f.type})),l=[];for(const f of Object.values(o.dependencies))for(const a of f)l.push({source:a.source,target:a.target,type:a.type});const d=e.filter(f=>f.type==="application"),c=e.filter(f=>f.type!=="application"),s={apps:d.length,edges:l,libs:c.length,nodes:e};return String.raw(K||(K=Ge([`<!DOCTYPE html>
3
3
  <html lang="en">
4
4
  <head>
@@ -1,6 +1,61 @@
1
- var re=Object.defineProperty;var E=(e,r)=>re(e,"name",{value:r,configurable:!0});import{createRequire as te}from"node:module";import{C as se,i as G,M,$ as K,z as Q,Q as le}from"./config.js";import{render as ce}from"@visulima/tui";import{h as ae,k as J,aU as de,aV as ue,aW as fe,aX as he,p as k,s as ge}from"./bin.js";import pe,{useSyncExternalStore as me,useRef as F,useCallback as _}from"react";import{o as we}from"../packem_shared/index-DH-5hsrC.js";import{sortPackageJsonStringWithOptions as U}from"#native";import{jsxs as f,jsx as s,Fragment as ye}from"react/jsx-runtime";import{Box as a}from"@visulima/tui/components/box";import{Text as c}from"@visulima/tui/components/text";import{useApp as xe}from"@visulima/tui/hooks/use-app";import{useInput as be}from"@visulima/tui/hooks/use-input";import{useWindowSize as Se}from"@visulima/tui/hooks/use-window-size";import{ScrollView as ke}from"@visulima/tui/components/scroll-view";import{ScrollBar as ve}from"@visulima/tui/components/scroll-bar";import{f as N}from"../packem_shared/utils-DrNg0XTR.js";const oe=te(import.meta.url),T=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,ne=E(e=>{if(typeof T<"u"&&T.versions&&T.versions.node){const[r,t]=T.versions.node.split(".").map(Number);if(r>22||r===22&&t>=3||r===20&&t>=16)return T.getBuiltinModule(e)}return oe(e)},"__cjs_getBuiltinModule"),{writeFileSync:ie}=ne("node:fs");var $e=Object.defineProperty,I=E((e,r)=>$e(e,"name",{value:r,configurable:!0}),"i$1");const q={error:0,rewritten:1,"would-rewrite":1,unchanged:2},Pe=I(e=>[...e].sort((r,t)=>q[r.status]-q[t.status]),"sortByStatusRank"),Ee=I((e,r)=>r==="all"?e:r==="errors"?e.filter(t=>t.status==="error"):r==="rewritten"?e.filter(t=>t.status==="rewritten"||t.status==="would-rewrite"):e.filter(t=>t.status==="unchanged"),"filterEntries");class Oe{static{E(this,"a")}static{I(this,"SortPackageJsonStore")}#e;#r=new Set;constructor(r){this.#e={entries:Pe(r),filterType:"all",focusedPanel:"list",selectedIndex:0}}getSnapshot=I(()=>this.#e,"getSnapshot");subscribe=I(r=>(this.#r.add(r),()=>{this.#r.delete(r)}),"subscribe");getFilteredEntries=I(()=>Ee(this.#e.entries,this.#e.filterType),"getFilteredEntries");#t(){this.#e={...this.#e};for(const r of this.#r)r()}select(r){const t=this.getFilteredEntries();this.#e.selectedIndex=t.length===0?-1:Math.max(0,Math.min(r,t.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()}}var je=Object.defineProperty,Ce=E((e,r)=>je(e,"name",{value:r,configurable:!0}),"c$2");const Re=Ce(({checkMode:e,entry:r,focused:t,scrollRef:l})=>r?f(a,{borderColor:t?"white":"gray",borderStyle:"single",flexDirection:"column",flexGrow:1,children:[s(a,{flexShrink:0,paddingTop:1,paddingX:2,children:s(c,{bold:!0,color:"white",children:r.relativePath})}),f(ke,{flexGrow:1,flexShrink:1,paddingX:2,ref:l,scrollbar:!0,scrollbarColor:"gray",children:[s(c,{}),f(a,{children:[s(a,{width:10,children:s(c,{dimColor:!0,children:"Status:"})}),r.status==="error"?s(c,{bold:!0,color:"red",children:"error"}):r.status==="unchanged"?s(c,{bold:!0,color:"green",children:"already sorted"}):r.status==="rewritten"?s(c,{bold:!0,color:"yellow",children:"rewritten"}):s(c,{bold:!0,color:"yellow",children:"would rewrite (--check)"})]}),f(a,{children:[s(a,{width:10,children:s(c,{dimColor:!0,children:"Path:"})}),s(c,{children:r.filePath})]}),r.error?f(ye,{children:[f(a,{flexDirection:"column",marginTop:1,children:[s(c,{dimColor:!0,children:"── "}),s(c,{bold:!0,color:"red",children:"ERROR"}),f(a,{flexDirection:"column",marginTop:1,paddingLeft:2,children:[f(a,{children:[s(a,{width:10,children:s(c,{dimColor:!0,children:"Step:"})}),s(c,{color:"yellow",children:r.error.step})]}),r.error.context&&f(a,{children:[s(a,{width:10,children:s(c,{dimColor:!0,children:"Position:"})}),s(c,{children:`line ${String(r.error.context.line)}, column ${String(r.error.context.column)}`})]}),s(a,{marginTop:1,children:s(c,{color:"red",children:r.error.message})})]})]}),r.error.context&&r.error.context.snippet.length>0&&f(a,{flexDirection:"column",marginTop:1,children:[s(c,{dimColor:!0,children:"── "}),s(c,{bold:!0,color:"white",children:"SNIPPET"}),f(a,{flexDirection:"column",marginTop:1,paddingLeft:2,children:[r.error.context.snippet.map(n=>{const i=`${n.isErrorLine?"❯":" "} ${String(n.lineNumber).padStart(4)} `;return f(a,{children:[s(c,{color:n.isErrorLine?"red":"gray",children:i}),s(c,{color:n.isErrorLine?"white":"gray",wrap:"truncate-end",children:n.content||" "})]},n.lineNumber)}),r.error.context.column>0&&s(a,{children:s(c,{color:"red",children:`${" ".repeat(7+r.error.context.column-1)}↑`})})]})]})]}):f(a,{flexDirection:"column",marginTop:1,children:[s(c,{dimColor:!0,children:"── "}),s(c,{bold:!0,color:"white",children:"KEY DIFF"}),s(a,{flexDirection:"column",marginTop:1,paddingLeft:2,children:r.diff.length===0?s(c,{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)}`,g=i<0?"green":"yellow";return f(a,{children:[s(a,{width:28,children:s(c,{wrap:"truncate",children:n.key})}),s(a,{width:10,children:f(c,{dimColor:!0,children:[String(n.fromIndex)," → ",String(n.toIndex)]})}),s(c,{color:g,children:d})]},n.key)})}),e&&r.status==="would-rewrite"&&s(a,{marginTop:1,paddingLeft:2,children:s(c,{dimColor:!0,children:"--check mode: no write performed."})})]})]})]}):s(a,{alignItems:"center",borderColor:"gray",borderStyle:"single",flexDirection:"column",flexGrow:1,justifyContent:"center",children:s(c,{dimColor:!0,children:"No entry selected"})}),"SortDetailPanel");var Ie=Object.defineProperty,O=E((e,r)=>Ie(e,"name",{value:r,configurable:!0}),"i");const Te={error:"red",rewritten:"yellow",unchanged:"green","would-rewrite":"yellow"},Me={error:"ERROR",rewritten:"REWROTE",unchanged:"SORTED","would-rewrite":"REWRITE"},Y={error:"errors",rewritten:"rewrites",unchanged:"sorted","would-rewrite":"rewrites"},Fe={errors:"Errors",rewrites:"Rewrites",sorted:"Sorted"},Ne=[{count:O(e=>e.errors+e.rewrites+e.sorted,"count"),key:"all",label:"All",shortcut:"1"},{count:O(e=>e.rewrites,"count"),key:"rewritten",label:"Rewrites",shortcut:"2"},{count:O(e=>e.errors,"count"),key:"errors",label:"Errors",shortcut:"3"},{count:O(e=>e.sorted,"count"),key:"unchanged",label:"Sorted",shortcut:"4"}],Z=O(e=>{const r={errors:0,rewrites:0,sorted:0};for(const t of e)r[Y[t.status]]++;return r},"computeGroupCounts"),Ae=O(({entry:e,isSelected:r})=>{const t=Te[e.status],l=Me[e.status];return f(a,{flexShrink:0,height:1,children:[s(c,{children:r?">":" "}),s(c,{children:" "}),s(c,{bold:!0,color:t,children:`[${l}]`.padEnd(10)}),s(c,{children:" "}),s(a,{flexGrow:1,children:s(c,{bold:r,inverse:r,wrap:"truncate",children:e.relativePath})}),e.status!=="error"&&e.diff.length>0&&s(c,{dimColor:!0,children:` ${String(e.diff.length)} key${e.diff.length===1?"":"s"}`})]})},"EntryRow"),De=O(({color:e,count:r,label:t})=>s(a,{flexShrink:0,height:1,children:s(c,{bold:!0,color:e,children:`${t} (${String(r)})`})}),"SectionHeader"),Le=O(({counts:e,entries:r,filterType:t,focused:l,selectedIndex:o,totalEntries:n,viewportHeight:i})=>{const d=l?"white":"gray",g=Z(r),b=(g.errors>0?1:0)+(g.rewrites>0?1:0)+(g.sorted>0?1:0),w=t==="all"&&b>1,p=[];let m;for(const[u,y]of r.entries()){const S=Y[y.status];w&&S!==m&&(m!==void 0&&p.push({kind:"spacer"}),p.push({color:S==="errors"?"red":S==="rewrites"?"yellow":"green",count:g[S],kind:"header",label:Fe[S]}),m=S),p.push({entry:y,entryIndex:u,kind:"entry"})}const v=p.findIndex(u=>u.kind==="entry"&&u.entryIndex===o),$=v!==-1,P=p.length,h=Math.max(0,P-i);let C=0;$&&i>0&&(C=Math.min(h,Math.max(0,v-i+1)));const R=P>i&&i>0;return f(a,{borderColor:d,borderStyle:"single",flexDirection:"column",flexGrow:1,children:[f(a,{flexShrink:0,gap:1,paddingX:1,children:[s(c,{bold:!0,inverse:!0,children:" VIS SORT "}),f(c,{wrap:"truncate",children:[n," ","file",n===1?"":"s"]})]}),s(a,{flexShrink:0,gap:1,paddingX:1,paddingY:1,children:Ne.map(u=>{const y=t===u.key,S=u.count(e);return f(a,{children:[s(c,{dimColor:!y,children:"["}),s(c,{bold:y,color:y?"cyan":"gray",children:u.shortcut}),s(c,{dimColor:!y,children:"]"}),f(c,{color:y?"white":"gray",children:[" ",u.label]}),f(c,{dimColor:!0,children:[" ","(",S,")"]})]},u.key)})}),f(a,{flexDirection:"row",flexGrow:1,overflow:"hidden",children:[s(a,{flexDirection:"column",flexGrow:1,overflow:"hidden",paddingLeft:1,children:s(a,{flexDirection:"column",marginTop:-C,children:p.map((u,y)=>u.kind==="spacer"?s(a,{flexShrink:0,height:1},`s-${String(y)}`):u.kind==="header"?s(De,{color:u.color,count:u.count,label:u.label},`h-${u.label}`):s(Ae,{entry:u.entry,isSelected:u.entryIndex===o},u.entry.filePath))})}),R&&s(a,{flexShrink:0,marginLeft:1,marginRight:1,children:s(ve,{contentHeight:P,placement:"inset",scrollOffset:C,style:"block",viewportHeight:i})})]})]})},"SortListPanel");var Be=Object.defineProperty,Ge=E((e,r)=>Be(e,"name",{value:r,configurable:!0}),"T");const Je=100,H=10,_e=6,qe=1,z={1:"all",2:"rewritten",3:"errors",4:"unchanged"},He=Ge(({checkMode:e,store:r})=>{const{exit:t}=xe(),{columns:l,rows:o}=Se(),n=me(r.subscribe,r.getSnapshot),i=F(null),d=r.getFilteredEntries(),g=d[n.selectedIndex]??null,b=Z(n.entries),w=l>=Je,p=Math.max(0,o-qe),m=w?p:Math.floor(p/2),v=Math.max(0,m-_e),$=_(()=>{t()},[t]),P=F(0),h=F(void 0),C=F(!1),R=_((u,y)=>{P.current+=y,h.current=u,!C.current&&(C.current=!0,queueMicrotask(()=>{C.current=!1;const S=P.current,B=h.current;P.current=0,h.current=void 0,!(S===0||B===void 0)&&(B==="list"?r.selectStep(Math.sign(S)):i.current?.scrollBy(Math.sign(S)))}))},[r]);return be((u,y)=>{if(u==="q"||y.escape){$();return}if(z[u]){r.setFilter(z[u]);return}if(y.tab){r.setFocusedPanel(n.focusedPanel==="list"?"detail":"list");return}n.focusedPanel==="list"?y.upArrow||u==="k"?R("list",-1):(y.downArrow||u==="j")&&R("list",1):n.focusedPanel==="detail"&&(y.upArrow||u==="k"?R("detail",-1):(y.downArrow||u==="j")&&R("detail",1))}),o<H?s(a,{alignItems:"center",justifyContent:"center",children:f(c,{color:"yellow",children:["Terminal too small. Resize to at least",H," ","rows."]})}):f(a,{flexDirection:"column",height:o,width:l,children:[f(a,{flexDirection:w?"row":"column",flexGrow:1,children:[s(a,{flexBasis:"50%",flexGrow:1,flexShrink:1,children:s(Le,{counts:b,entries:d,filterType:n.filterType,focused:n.focusedPanel==="list",selectedIndex:n.selectedIndex,totalEntries:n.entries.length,viewportHeight:v})}),s(a,{flexBasis:"50%",flexGrow:1,flexShrink:1,children:s(Re,{checkMode:e,entry:g,focused:n.focusedPanel==="detail",scrollRef:i})})]}),s(a,{flexShrink:0,paddingX:1,children:s(c,{dimColor:!0,children:"↑/↓ or j/k:navigate | tab:switch panel | 1-4:filter | q:quit"})})]})},"VisSortPackageJsonApp");var ze=Object.defineProperty,j=E((e,r)=>ze(e,"name",{value:r,configurable:!0}),"c$1");const W=["types","node-addons","node","import","require","default"],We=/^git\+https:\/\/github\.com\/([^/]+)\/([^/.]+(?:\.git)?)$/,Xe=/^git\+ssh:\/\/git@github\.com\/([^/]+)\/([^/.]+(?:\.git)?)$/,A=j(e=>typeof e=="object"&&e!==null&&!Array.isArray(e),"isPlainObject"),L=j(e=>{if(e===null||typeof e!="object")return e;if(Array.isArray(e))return e.map(t=>L(t));const r={};for(const[t,l]of Object.entries(e))r[t]=L(l);return r},"cloneDeep"),Ve=j(e=>{if(!A(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}},"tryFormatBugs"),Ke=j(e=>e.endsWith(".git")?e.slice(0,-4):e,"stripGitSuffix"),Qe=j(e=>{if(!A(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:t}=e;if(typeof t!="string")return{changed:!1,value:e};const l=We.exec(t)??Xe.exec(t);if(!l)return{changed:!1,value:e};const o=l[1],n=Ke(l[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}`}},"tryFormatRepository"),Ue=j(e=>{const r=Object.keys(e),t=[],l=[];for(const i of W)Object.hasOwn(e,i)&&t.push(i);for(const i of r)W.includes(i)||l.push(i);const o=[...t,...l];if(o.length===r.length&&o.every((i,d)=>i===r[d]))return{changed:!1,value:e};const n={};for(const i of o)n[i]=e[i];return{changed:!0,value:n}},"orderConditions"),ee=j(e=>{if(!A(e))return{changed:!1,value:e};let r=!1;const t={};for(const[o,n]of Object.entries(e)){const i=ee(n);t[o]=i.value,i.changed&&(r=!0)}const l=Ue(t);return{changed:r||l.changed,value:l.value}},"sortExportsRecursive"),Ye=j((e,r)=>{const t=L(e);let l=!1;if(r.formatBugs!==!1&&Object.hasOwn(t,"bugs")){const o=Ve(t.bugs);o.changed&&(t.bugs=o.value,l=!0)}if(r.formatRepository!==!1&&Object.hasOwn(t,"repository")){const o=Qe(t.repository);o.changed&&(t.repository=o.value,l=!0)}if(r.sortExports!==!1&&Object.hasOwn(t,"exports")&&A(t.exports)){const o=ee(t.exports);o.changed&&(t.exports=o.value,l=!0)}return{changed:l,pkg:t}},"formatPackageJsonFields");var Ze=Object.defineProperty,x=E((e,r)=>Ze(e,"name",{value:r,configurable:!0}),"c");const er=/at position (\d+)/,rr=/\(?line (\d+) column (\d+)\)?/,tr=x(e=>{const r=new Set,t=[],l=x(n=>{const i=se(n);!r.has(i)&&G(i)&&(r.add(i),t.push(i))},"addFile");l(M(e,"package.json"));const o=ae(e);if(o){const n=J(e,o);for(const i of n)l(M(e,i,"package.json"))}else{const n=M(e,"package.json");if(G(n)){const i=JSON.parse(K(n)),d=Array.isArray(i.workspaces)?i.workspaces:i.workspaces?.packages;if(d){const g=J(e,d);for(const b of g)l(M(e,b,"package.json"))}}}return t},"findPackageJsonFiles"),or=x(e=>/\n([ \t]+)/.exec(e)?.[1]??" ","detectIndent"),nr=x(e=>{if(!(e===void 0||e===""))return e==="tab"||e===String.raw`\t`?" ":/^\d+$/.test(e)?" ".repeat(Number.parseInt(e,10)):e},"resolveIndentOverride"),D=x(e=>e===void 0?[]:(Array.isArray(e)?e:[e]).flatMap(r=>r.split(",")).map(r=>r.trim()).filter(r=>r.length>0),"splitList"),ir=x(e=>e.includes(`\r
2
- `)?"crlf":"lf","detectLineEnding"),sr=new Set(["auto","crlf","lf"]),lr=x(e=>{if(e===void 0||e==="")return"auto";if(sr.has(e))return e;throw new Error(`--line-ending must be one of: auto, lf, crlf (got "${e}")`)},"validateLineEnding"),cr=x((e,r,t)=>r.length===0?e:e.filter(l=>{const o=Q(t,l),n=le(l);return!r.some(i=>{const d=i.includes("/")?o:n;return we(i,d)})}),"filterByIgnore"),ar=x((e,r)=>{if(r.length===0)return e;const t={},l=new Set;for(const o of r)Object.hasOwn(e,o)&&(t[o]=e[o],l.add(o));for(const o of Object.keys(e))l.has(o)||(t[o]=e[o]);return t},"applySortOrder"),dr=x((e,r,t)=>{if(t.length===0)return e;const l={...e};for(const o of t)Object.hasOwn(r,o)&&(l[o]=r[o]);return l},"restoreUnsortedSections"),ur=x((e,r)=>{let t=1,l=1;const o=Math.min(r,e.length);for(let n=0;n<o;n++)e.codePointAt(n)===10?(t++,l=1):l++;return{column:l,line:t}},"computeLineColumn"),X=x((e,r,t=2)=>{const l=e.split(`
3
- `);if(r<1||r>l.length)return[];const o=Math.max(0,r-1-t),n=Math.min(l.length,r+t),i=[];for(let d=o;d<n;d++)i.push({content:l[d]??"",isErrorLine:d+1===r,lineNumber:d+1});return i},"buildSnippet"),V=x((e,r)=>{if(!(e instanceof Error))return;const t=er.exec(e.message);if(t){const{column:o,line:n}=ur(r,Number.parseInt(t[1]??"0",10));return{column:o,line:n,snippet:X(r,n)}}const l=rr.exec(e.message);if(l){const o=Number.parseInt(l[1]??"1",10);return{column:Number.parseInt(l[2]??"1",10),line:o,snippet:X(r,o)}}},"extractParseErrorContext"),fr=x((e,r)=>{const t=Object.keys(JSON.parse(e)),l=Object.keys(JSON.parse(r)),o=new Map(t.map((i,d)=>[i,d])),n=[];for(const[i,d]of l.entries()){const g=o.get(d);g!==void 0&&g!==i&&n.push({fromIndex:g,key:d,toIndex:i})}return n},"computeKeyDiff"),hr=x((e,r,t)=>{const l=r.indent??t.indent??or(e),o=r.lineEnding==="auto"?t.lineEnding??ir(e):r.lineEnding,n=U(e,{pretty:!1,sortScripts:r.sortScripts});let i=JSON.parse(n);if(r.unsorted.length>0){const w=JSON.parse(e);i=dr(i,w,r.unsorted)}i=ar(i,r.sortOrder);const d={formatBugs:r.formatBugs,formatRepository:r.formatRepository,sortExports:r.sortExports},g=Ye(i,d);let b=JSON.stringify(g.pkg,null,l);return r.finalNewline&&(b+=`
4
- `),o==="crlf"&&(b=b.replaceAll(`
5
- `,`\r
6
- `)),b},"sortContents"),gr=x((e,r)=>{const t=tr(e),l=de(e),o=ue({cwd:e,extraPatterns:fe(l)}),n=t.filter(d=>!o.ignores(d)),i=cr(n,r,e);return{afterGitignore:n,allFiles:t,files:i}},"discoverPackageJsonFiles"),pr=x((e,{checkMode:r,cwd:t,normalized:l})=>{const o=Q(t,e)||e;let n;try{n=K(e)}catch(w){return{diff:[],error:{message:N(w),step:"read"},filePath:e,relativePath:o,status:"error"}}let i;try{i=U(n,{pretty:!1,sortScripts:l.sortScripts})}catch(w){const p={message:N(w),step:"native-sort"},m=V(w,n);return m&&(p.context=m),{diff:[],error:p,filePath:e,relativePath:o,status:"error"}}const d=l.editorconfig?he(e):{};let g;try{g=hr(n,l,d)}catch(w){const p={message:N(w),step:"json-parse"},m=V(w,n);return m&&(p.context=m),{diff:[],error:p,filePath:e,relativePath:o,status:"error"}}if(n===g)return{diff:[],filePath:e,relativePath:o,status:"unchanged"};let b;try{b=fr(n,i)}catch{b=[]}if(r)return{diff:b,filePath:e,relativePath:o,status:"would-rewrite"};try{ie(e,g,"utf8")}catch(w){return{diff:b,error:{message:N(w),step:"write"},filePath:e,relativePath:o,status:"error"}}return{diff:b,filePath:e,relativePath:o,status:"rewritten"}},"processFile"),mr=x(e=>{if(e.error&&(k.error(`${e.filePath}: ${e.error.message}`),k.info(` step: ${e.error.step}`),e.error.context)){k.info(` at line ${String(e.error.context.line)}, column ${String(e.error.context.column)}`);for(const r of e.error.context.snippet){const t=r.isErrorLine?">":" ";k.info(` ${t} ${String(r.lineNumber).padStart(4)} | ${r.content}`)}}},"printStaticError"),Fr=x(async({options:e,visConfig:r,workspaceRoot:t})=>{const l=t??process.cwd(),o=r?.sortPackageJson,n=e.check||!1,i={editorconfig:e.editorconfig===!1?!1:o?.editorconfig??!0,finalNewline:e.finalNewline??o?.finalNewline??!0,formatBugs:e.formatBugs===!1?!1:o?.formatBugs??!0,formatRepository:e.formatRepository===!1?!1:o?.formatRepository??!0,ignore:[...D(e.ignore),...o?.ignore??[]],indent:nr(e.indent??o?.indent),lineEnding:lr(e.lineEnding??o?.lineEnding),sortExports:e.sortExports===!1?!1:o?.sortExports??!0,sortOrder:[...D(e.sortOrder),...o?.sortOrder??[]],sortScripts:e.sortScripts||o?.sortScripts||!1,unsorted:[...D(e.unsorted),...o?.unsorted??[]]},d=gr(l,i.ignore),{afterGitignore:g,allFiles:b,files:w}=d;if(w.length===0){b.length===0?k.info("No package.json files found."):g.length===0?k.info("All package.json files were excluded by .gitignore or workspace exclusions."):k.info("All package.json files were excluded by --ignore.");return}const p=[];for(const h of w)p.push(pr(h,{checkMode:n,cwd:l,normalized:i}));let m=0,v=0,$=0;for(const h of p)h.status==="error"?$++:h.status==="rewritten"||h.status==="would-rewrite"?m++:v++;const P=m>0||$>0;if(process.stdout.isTTY&&!ge&&P){const h=new Oe(p);await ce(pe.createElement(He,{checkMode:n,store:h}),{alternateScreen:!0,exitOnCtrlC:!1,interactive:!0,patchConsole:!0}).waitUntilExit()}else for(const h of p)switch(h.status){case"error":{mr(h);break}case"rewritten":{k.success(`Sorted ${h.filePath}`);break}case"would-rewrite":{k.warn(`${h.filePath} is not sorted`);break}}if(n)m>0?(k.info(`${String(m)} file${m===1?"":"s"} not sorted, ${String(v)} already sorted`),process.exitCode=1):$===0&&k.info(`All ${String(v)} package.json file${v===1?" is":"s are"} sorted`);else{const h=[];m>0&&h.push(`sorted ${String(m)} file${m===1?"":"s"}`),v>0&&h.push(`${String(v)} already sorted`),$>0&&h.push(`${String($)} error${$===1?"":"s"}`),h.length>0&&k.info(h.join(", "))}$>0&&(process.exitCode=1)},"execute");export{X as buildSnippet,fr as computeKeyDiff,ur as computeLineColumn,Fr as default,gr as discoverPackageJsonFiles,V as extractParseErrorContext,pr as processFile};
1
+ var H=Object.defineProperty;var j=(e,t)=>H(e,"name",{value:t,configurable:!0});import{createRequire as K}from"node:module";import{$ as V,K as A,z as D,M as C,b as X,B as T,w as Y}from"./config.js";import{o as Z}from"../packem_shared/index-DH-5hsrC.js";import{aW as P,C as ee,aX as te,ae as oe}from"./bin.js";import{i as re}from"../packem_shared/glob-MHJQjR39-CQ2GC0b_.js";import{n as ne}from"../packem_shared/manifests-B0fMp872.js";const z=K(import.meta.url),O=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,Q=j(e=>{if(typeof O<"u"&&O.versions&&O.versions.node){const[t,o]=O.versions.node.split(".").map(Number);if(t>22||t===22&&o>=3||t===20&&o>=16)return O.getBuiltinModule(e)}return z(e)},"__cjs_getBuiltinModule"),{readFileSync:F}=Q("node:fs");var se=Object.defineProperty,y=j((e,t)=>se(e,"name",{value:t,configurable:!0}),"c");const ie=y((e,t)=>{const o=t.replace(/^\.?\//,"");return o===""||o==="."?`/${e}/`:e===""||e==="."?`/${o}`:`/${e}/${o}`},"toWorkspacePath"),_=y((e,t,o=[])=>{const s=[],r=new Set;for(const[i,n]of Object.entries(t?.globalPaths??{}))s.push({owners:n,path:i,source:"project-json"}),r.add(i);for(const[i,n]of Object.entries(e.projects)){const a=n.owners??[];for(const c of a){const l=ie(n.root??i,c.path);s.push({channel:c.channel,owners:c.owners,path:l,projectId:i,source:"project-json"}),r.add(l)}}for(const i of o)r.has(i.path)||(s.push(i),r.add(i.path));return(t?.orderBy??"file-source")==="project-id"?s.sort((i,n)=>(i.projectId??"").localeCompare(n.projectId??"")||i.path.localeCompare(n.path)):s.sort((i,n)=>i.path.localeCompare(n.path)),s},"buildCodeownersLines"),ae="Update each project's project.json `owners` field and re-run the command.",ce=y(e=>["# CODEOWNERS — generated by `vis sync codeowners`. Do not edit by hand.",e?`# Re-run with: ${e}`:`# ${ae}`,""],"buildHeader"),M=y(e=>{const t=[];for(const o of e){const s=o.owners.join(" "),r=o.channel?` # notify: ${o.channel}`:"";t.push(`${o.path} ${s}${r}`)}return t},"renderEntries"),de=y((e,t={})=>[...ce(t.regenerationCommand),...M(e),""].join(`
2
+ `),"renderCodeowners"),W={begin:"# BEGIN vis-codeowners",end:"# END vis-codeowners"},le=y((e,t=W,o={})=>{const s=o.regenerationCommand?`# Generated by vis sync codeowners re-run with: ${o.regenerationCommand}`:"# Generated by `vis sync codeowners` do not edit by hand.";return[t.begin,s,...M(e),t.end].join(`
3
+ `)},"renderCodeownersBlock"),ue=y((e,t,o=W)=>{const s=e.indexOf(o.begin),r=e.indexOf(o.end);if(s!==-1&&r!==-1&&r>s){const n=e.slice(0,s),a=r+o.end.length,c=e.slice(a);return`${n}${t}${c}`}const i=e.replace(/\s+$/u,"");return`${i.length===0?"":`${i}
4
+
5
+ `}${t}
6
+ `},"mergeIntoExisting");var fe=Object.defineProperty,N=j((e,t)=>fe(e,"name",{value:t,configurable:!0}),"f$1");const pe=["**/CODEOWNERS"],he=["**/node_modules/**","**/dist/**","**/build/**","**/coverage/**","**/.git/**","**/.next/**","**/.nuxt/**"],ge=N(e=>{const t=[];for(const o of e.split(/\r?\n/u)){const s=o.indexOf("#"),r=(s===-1?o:o.slice(0,s)).trim();if(r.length===0)continue;const i=r.split(/\s+/u);if(i.length<2)continue;const[n,...a]=i,c=a.filter(l=>l.length>0);!n||c.length===0||t.push({owners:c,path:n})}return t},"parseCodeownersFile"),me=N((e,t)=>{const o=t.replace(/^\.\/?/,"").replace(/\/$/,"");return e.startsWith("/")?o===""?e:`/${o}${e}`:o===""?`/${e}`:`/${o}/${e}`},"rewriteNestedPath"),we=N(async(e,t,o)=>{const s=t&&t.length>0?[...t]:[...pe],r=[...he];if(o){const a=o.replace(/^\.\/?/,"").replace(/^\/+/,"");a.length>0&&r.push(a)}const i=await re(s,{absolute:!0,cwd:e,ignore:r}),n=[];for(const a of i){let c;try{c=V(a)}catch{continue}const l=A(a),p=D(e,l);for(const m of ge(c))n.push({owners:m.owners,path:me(m.path,p)})}return n},"collectNestedCodeownersLines"),be=/^(?:https?:\/\/)?(?:www\.)?github\.com\/([^/?#]+)/iu,$e=N(e=>{if(!e)return;const t=e.match(be);if(!t?.[1])return;const o=t[1].trim();if(!(o===""||o.includes(" ")))return`@${o.replace(/^@/,"")}`},"extractGitHubHandle"),je=N((e,t)=>{const o=[];for(const[s,r]of Object.entries(e.projects)){if(r.owners&&r.owners.length>0)continue;const i=r.root??s,n=C(t,i,"package.json"),a=P(n);if(!a)continue;const c=ne(a.maintainers);if(!c||c.length===0)continue;const l=[],p=new Set;for(const m of c){const w=$e(m.url);w&&!p.has(w)&&(p.add(w),l.push(w))}l.length!==0&&o.push({owners:l,path:i===""||i==="."?"/":`/${i}/`,projectId:s})}return o},"collectMaintainerLines");var ye=Object.defineProperty,v=j((e,t)=>ye(e,"name",{value:t,configurable:!0}),"s");const ke=["author","bugs","homepage","license","repository","engines"],I=v(e=>typeof e=="object"&&e!==null&&!Array.isArray(e),"isPlainObject"),R=v((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[o,s]of e.entries())if(!R(s,t[o]))return!1;return!0}if(typeof e=="object"&&typeof t=="object"){const o=Object.keys(e),s=Object.keys(t);if(o.length!==s.length)return!1;for(const r of o)if(!R(e[r],t[r]))return!1;return!0}return!1},"deepEqual"),x=v(e=>e===void 0?e:structuredClone(e),"cloneJson"),Ce=v((e,t,o)=>{if(e==="repository"&&I(t)&&I(o)){const s={};for(const[r,i]of Object.entries(t))r!=="directory"&&(s[r]=x(i));return typeof o.directory=="string"&&(s.directory=o.directory),s}return x(t)},"buildTargetValue"),ve=v((e,t,o)=>{const s=[];for(const r of o.fields){if(!Object.hasOwn(e,r))continue;const i=e[r],n=t[r],a=Ce(r,i,n);R(a,n)||s.push({after:a,before:n,field:r,packageJsonPath:""})}return s},"computeFieldChanges"),Ee=v((e,t)=>{for(const o of t)e[o.field]=o.after},"applyFieldChanges");var Oe=Object.defineProperty,G=j((e,t)=>Oe(e,"name",{value:t,configurable:!0}),"n");const U="Generated by `vis sync codeowners --write-guard`. Do not edit by hand.",Ne=G(e=>{const t=e.replace(/^\.?\/+/u,"").replace(/\/+$/u,"");return t===""||t==="."?"**":`${t}/**`},"toPathGlob"),q=G(e=>{const t=new Set,o=[];for(const s of[...e].sort((r,i)=>r.name.localeCompare(i.name))){const r=Ne(s.root);t.has(r)||(t.add(r),o.push(r))}return o},"resolveGlobs"),Ge=G(e=>{const t=q(e),o=t.map(r=>` - "${r}"`).join(`
7
+ `),s=t.map(r=>` ${r}`).join(`
8
+ `);return`# ${U}
9
+ name: Write Guard
10
+
11
+ on:
12
+ pull_request:
13
+ paths:
14
+ ${o}
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
+ `},"renderGithubWriteGuard"),Pe=G(e=>{const t=q(e).map(o=>` - "${o}/*"`).join(`
33
+ `);return`# ${U}
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
+ ${t}
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
+ `},"renderGitlabWriteGuard"),Re=G(e=>e.length===0?[]:[{content:Ge(e),path:".github/workflows/write-guard.yml"},{content:Pe(e),path:".gitlab/write-guard.gitlab-ci.yml"}],"buildWriteGuardArtifacts");var We=Object.defineProperty,k=j((e,t)=>We(e,"name",{value:t,configurable:!0}),"m");const B=new Set(["nested-codeowners","package-json-maintainers","project-json"]),J=k((e,t,o)=>{const s=new Set,r=[];for(const i of e??[])for(const n of i.split(",")){const a=n.trim();if(a.length===0)continue;if(o&&!o(a))throw new Error(`Unknown codeowners source: "${a}". Known: ${[...B].join(", ")}.`);const c=a;s.has(c)||(s.add(c),r.push(c))}return r.length>0?r:[...t]},"parseCsvOption"),Se=k(e=>B.has(e),"isCodeownersSource"),L=["codeowners","package-json-fields"],_e=k((e,t)=>t.some(o=>Z(o,e)),"matchesAnyGlob"),Ie=k((e,t,o,s)=>{const r=Object.entries(o.projects).filter(([,n])=>n.restricted===!0).map(([n,a])=>({name:n,root:a.root??n})),i=Re(r);if(i.length===0){e.info("No projects flagged `restricted: true` in project.json. Skipping Write Guard.");return}if(s){let n=!1;for(const a of i){const c=C(t,a.path);let l="";try{l=F(c,"utf8")}catch(p){if(p.code!=="ENOENT")throw p}l.trim()!==a.content.trim()&&(e.error(`${a.path} is out of date. Run \`vis sync codeowners --write-guard\` to update it.`),n=!0)}n?process.exitCode=1:e.info(`Write Guard CI is up to date (${i.length} files, ${r.length} restricted projects).`);return}for(const n of i){const a=C(t,n.path);X(A(a)),T(a,n.content),e.info(`Wrote ${n.path}`)}e.info(`Write Guard CI scoped to ${r.length} restricted project${r.length===1?"":"s"}.`)},"handleWriteGuard"),xe=k(async({logger:e,options:t,visConfig:o,workspaceRoot:s})=>{const r=s,{workspace:i}=ee(r,o),n=o?.codeowners;t.writeGuard===!0&&Ie(e,r,i,t.check===!0);const a=J(t.from,n?.sources??["project-json"],Se),c=t.regenerationCommand??n?.regenerationCommand,l=t.preserveBlock===!0||n?.preserveBlock===!0,p=n?.blockMarker??W,m=t.nestedIncludes??n?.nestedIncludes,w=t.out??"CODEOWNERS",f=[];if(a.includes("nested-codeowners")){const g=await we(r,m,w);for(const $ of g)f.push({...$,source:"nested"})}if(a.includes("package-json-maintainers")){const g=je(i,r);for(const $ of g)f.push({...$,source:"maintainers"})}const b=a.includes("project-json")?_(i,n,f):_({projects:{}},n,f);if(b.length===0){e.info("No `owners` entries found in any source. Nothing to sync.");return}const u=C(r,w);let E="";try{E=F(u,"utf8")}catch(g){if(g.code!=="ENOENT")throw g}const d={regenerationCommand:c},h=l?ue(E,le(b,p,d),p):de(b,d);if(t.check){if(E.trim()!==h.trim()){e.error(`${u} is out of date. Run \`vis sync codeowners\` to update it.`),process.exitCode=1;return}e.info(`${u} is up to date.`);return}T(u,h),e.info(`Wrote ${b.length} entries to ${u}`)},"runCodeowners"),Le=k(({logger:e,options:t,visConfig:o,workspaceRoot:s})=>{const r=s,i=o?.editorconfig??!0,n=P(C(r,"package.json"));if(!n){e.error("Could not read root package.json. Nothing to sync."),process.exitCode=1;return}const a=J(t.fields,ke),c=t.ignorePackageName??[],l=t.check===!0,p=(t.format??"human").toLowerCase(),m=t.quiet===!0,w=te(r).filter(d=>d!=="."),f=[];let b=0;for(const d of w){const h=C(r,d,"package.json"),g=P(h);if(!g)continue;const $=typeof g.name=="string"?g.name:void 0;if($!==void 0&&c.length>0&&_e($,c))continue;b+=1;const S=ve(n,g,{fields:a});S.length!==0&&f.push({filePath:h,packageJsonPath:D(r,h),packageName:$,pkg:g,pkgChanges:S})}if(!l)for(const d of f)Ee(d.pkg,d.pkgChanges),Y(d.filePath,d.pkg,{indent:oe(d.filePath,{useEditorconfig:i}),overwrite:!0});const u=f.flatMap(d=>d.pkgChanges.map(h=>({after:h.after,before:h.before,field:h.field,packageJsonPath:d.packageJsonPath,packageName:d.packageName}))),E={changes:u,fields:a,kind:"package-json-fields",mode:l?"check":"write",totalChanges:u.length,totalPackages:b};if(p==="json")process.stdout.write(`${JSON.stringify(E,null,4)}
61
+ `);else if(u.length===0)e.info(`All ${b} package${b===1?"":"s"} in sync (fields: ${a.join(", ")}).`);else if(l){if(!m)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 ${f.length} package${f.length===1?"":"s"}. Run \`vis sync package-json-fields\` to fix.`)}else{if(!m)for(const d of f)e.info(`${d.packageJsonPath}: synced ${d.pkgChanges.map(h=>h.field).join(", ")}`);e.info(`Synced ${u.length} field${u.length===1?"":"s"} across ${f.length} package${f.length===1?"":"s"}.`)}l&&u.length>0&&(process.exitCode=1)},"runPackageJsonFields"),Be=k(async e=>{const t=e.argument[0];if(!t)throw new Error(`Missing sync kind. Usage: vis sync <kind> (known kinds: ${L.join(", ")})`);if(!e.workspaceRoot)throw new Error("Could not determine workspace root. Run inside a monorepo.");if(t==="codeowners"){await xe(e);return}if(t==="package-json-fields"){Le(e);return}throw new Error(`Unknown sync kind: "${t}". Known kinds: ${L.join(", ")}.`)},"execute");export{Be as default};