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

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 (147) hide show
  1. package/CHANGELOG.md +830 -14
  2. package/LICENSE.md +7667 -0
  3. package/README.md +322 -19
  4. package/dist/bin.js +1 -146
  5. package/dist/config/index.d.ts +2795 -0
  6. package/dist/config/index.js +1 -0
  7. package/dist/generate/index.d.ts +157 -0
  8. package/dist/generate/index.js +1 -0
  9. package/dist/packem_chunks/bin.js +1295 -0
  10. package/dist/packem_chunks/config.js +19 -0
  11. package/dist/packem_chunks/doctor-probe.js +2 -0
  12. package/dist/packem_chunks/fix.js +11 -0
  13. package/dist/packem_chunks/handler.js +1 -0
  14. package/dist/packem_chunks/handler10.js +1 -0
  15. package/dist/packem_chunks/handler11.js +5 -0
  16. package/dist/packem_chunks/handler12.js +1 -0
  17. package/dist/packem_chunks/handler13.js +27 -0
  18. package/dist/packem_chunks/handler14.js +5 -0
  19. package/dist/packem_chunks/handler15.js +1 -0
  20. package/dist/packem_chunks/handler16.js +1 -0
  21. package/dist/packem_chunks/handler17.js +1 -0
  22. package/dist/packem_chunks/handler18.js +1 -0
  23. package/dist/packem_chunks/handler19.js +1 -0
  24. package/dist/packem_chunks/handler2.js +2 -0
  25. package/dist/packem_chunks/handler20.js +5 -0
  26. package/dist/packem_chunks/handler21.js +2 -0
  27. package/dist/packem_chunks/handler22.js +2 -0
  28. package/dist/packem_chunks/handler23.js +18 -0
  29. package/dist/packem_chunks/handler24.js +1 -0
  30. package/dist/packem_chunks/handler25.js +1 -0
  31. package/dist/packem_chunks/handler26.js +5 -0
  32. package/dist/packem_chunks/handler27.js +1 -0
  33. package/dist/packem_chunks/handler28.js +3 -0
  34. package/dist/packem_chunks/handler29.js +1 -0
  35. package/dist/packem_chunks/handler3.js +4 -0
  36. package/dist/packem_chunks/handler30.js +7 -0
  37. package/dist/packem_chunks/handler31.js +33 -0
  38. package/dist/packem_chunks/handler32.js +3 -0
  39. package/dist/packem_chunks/handler33.js +1 -0
  40. package/dist/packem_chunks/handler34.js +26 -0
  41. package/dist/packem_chunks/handler35.js +3 -0
  42. package/dist/packem_chunks/handler36.js +7 -0
  43. package/dist/packem_chunks/handler37.js +22 -0
  44. package/dist/packem_chunks/handler38.js +428 -0
  45. package/dist/packem_chunks/handler39.js +6 -0
  46. package/dist/packem_chunks/handler4.js +8 -0
  47. package/dist/packem_chunks/handler40.js +24 -0
  48. package/dist/packem_chunks/handler41.js +10 -0
  49. package/dist/packem_chunks/handler42.js +153 -0
  50. package/dist/packem_chunks/handler43.js +25 -0
  51. package/dist/packem_chunks/handler44.js +24 -0
  52. package/dist/packem_chunks/handler45.js +213 -0
  53. package/dist/packem_chunks/handler46.js +3 -0
  54. package/dist/packem_chunks/handler47.js +27 -0
  55. package/dist/packem_chunks/handler48.js +167 -0
  56. package/dist/packem_chunks/handler49.js +34 -0
  57. package/dist/packem_chunks/handler5.js +1 -0
  58. package/dist/packem_chunks/handler6.js +1 -0
  59. package/dist/packem_chunks/handler7.js +1 -0
  60. package/dist/packem_chunks/handler8.js +1 -0
  61. package/dist/packem_chunks/handler9.js +2 -0
  62. package/dist/packem_chunks/heal-accept.js +10 -0
  63. package/dist/packem_chunks/heal.js +14 -0
  64. package/dist/packem_chunks/help-command.js +18 -0
  65. package/dist/packem_chunks/index.js +7 -0
  66. package/dist/packem_chunks/keys-refresh.js +4 -0
  67. package/dist/packem_chunks/list.js +3 -0
  68. package/dist/packem_chunks/loader.js +1 -0
  69. package/dist/packem_chunks/prune.js +3 -0
  70. package/dist/packem_chunks/run.js +1 -0
  71. package/dist/packem_chunks/status.js +2 -0
  72. package/dist/packem_chunks/sync.js +2 -0
  73. package/dist/packem_chunks/sync2.js +2 -0
  74. package/dist/packem_chunks/tar.js +3 -0
  75. package/dist/packem_chunks/tripwire.js +2 -0
  76. package/dist/packem_shared/advisories-DsynpacV.js +1 -0
  77. package/dist/packem_shared/ai-analysis-uYuTIIXi.js +68 -0
  78. package/dist/packem_shared/ai-cache-DuwHYx2O.js +1 -0
  79. package/dist/packem_shared/ai-fix-DzrA-dVz.js +43 -0
  80. package/dist/packem_shared/applyDefaults-BOVDw1jD.js +1 -0
  81. package/dist/packem_shared/build-scripts-DsWMSWDs.js +1 -0
  82. package/dist/packem_shared/cache-directory-DQak1Vjc.js +1 -0
  83. package/dist/packem_shared/cyclonedx-CiHXuG8M.js +4 -0
  84. package/dist/packem_shared/definePlugin-CWm4Dv_t.js +1 -0
  85. package/dist/packem_shared/dependency-scan-DC3nAFHS.js +1 -0
  86. package/dist/packem_shared/docker-B-CIN_nj.js +60 -0
  87. package/dist/packem_shared/failure-log-C3LEMmkq.js +2 -0
  88. package/dist/packem_shared/flakiness-Dq6K4ymq.js +1 -0
  89. package/dist/packem_shared/giget-CcEy_Elm.js +2 -0
  90. package/dist/packem_shared/glob-MHJQjR39-CQ2GC0b_.js +1 -0
  91. package/dist/packem_shared/index-DH-5hsrC.js +1 -0
  92. package/dist/packem_shared/lifecycle-Dv3nAtoD.js +2 -0
  93. package/dist/packem_shared/lockfile-C5DYMHVq.js +1 -0
  94. package/dist/packem_shared/manifests-B0fMp872.js +1 -0
  95. package/dist/packem_shared/min-release-age-BFozFonQ.js +34 -0
  96. package/dist/packem_shared/native-config-sync-Dvi1g2nQ.js +21 -0
  97. package/dist/packem_shared/otelPlugin-CJR2T_lk.js +1 -0
  98. package/dist/packem_shared/registry-keys-CewRFW0e.js +1 -0
  99. package/dist/packem_shared/resolve-explicit-CC4Kifk5.js +5 -0
  100. package/dist/packem_shared/run-summary-utils-BaBGP3bo.js +1 -0
  101. package/dist/packem_shared/runtime-check-BusAwPb2.js +1 -0
  102. package/dist/packem_shared/scan-progress-CMynp3eA.js +2 -0
  103. package/dist/packem_shared/selectors-B2ISH581.js +3 -0
  104. package/dist/packem_shared/signatures-5ZdjJ2Pu.js +2 -0
  105. package/dist/packem_shared/symbols-CQmER5MT.js +1 -0
  106. package/dist/packem_shared/toolchain-Cc3cwyLP.js +5 -0
  107. package/dist/packem_shared/typosquats-BCeR-sLf.js +1 -0
  108. package/dist/packem_shared/use-measured-height-DjYgUOKk.js +1 -0
  109. package/dist/packem_shared/utils-DrNg0XTR.js +1 -0
  110. package/dist/packem_shared/verify-07kUNTuP.js +1 -0
  111. package/dist/packem_shared/vis-update-app-CFrlJ3mW.js +1 -0
  112. package/dist/packem_shared/xxh3-DrAUNq4n.js +1 -0
  113. package/index.d.ts +358 -0
  114. package/index.js +609 -0
  115. package/package.json +57 -22
  116. package/schemas/project.schema.json +872 -0
  117. package/schemas/vis-config.schema.json +4306 -0
  118. package/skills/vis/SKILL.md +96 -0
  119. package/templates/buildkite-ci/.buildkite/pipeline.yml.tera +85 -0
  120. package/templates/buildkite-ci/template.yml +20 -0
  121. package/dist/ai-analysis.d.ts +0 -40
  122. package/dist/ai-cache.d.ts +0 -21
  123. package/dist/bin.d.ts +0 -1
  124. package/dist/catalog.d.ts +0 -110
  125. package/dist/commands/affected.d.ts +0 -3
  126. package/dist/commands/ai.d.ts +0 -3
  127. package/dist/commands/analyze.d.ts +0 -3
  128. package/dist/commands/check.d.ts +0 -3
  129. package/dist/commands/graph.d.ts +0 -3
  130. package/dist/commands/hook/constants.d.ts +0 -8
  131. package/dist/commands/hook/index.d.ts +0 -3
  132. package/dist/commands/hook/install.d.ts +0 -7
  133. package/dist/commands/hook/migrate.d.ts +0 -27
  134. package/dist/commands/hook/uninstall.d.ts +0 -3
  135. package/dist/commands/migrate/constants.d.ts +0 -12
  136. package/dist/commands/migrate/deps.d.ts +0 -32
  137. package/dist/commands/migrate/index.d.ts +0 -3
  138. package/dist/commands/migrate/json.d.ts +0 -20
  139. package/dist/commands/migrate/lint-staged.d.ts +0 -62
  140. package/dist/commands/migrate/types.d.ts +0 -20
  141. package/dist/commands/run.d.ts +0 -3
  142. package/dist/commands/staged.d.ts +0 -3
  143. package/dist/commands/update.d.ts +0 -3
  144. package/dist/config.d.ts +0 -40
  145. package/dist/config.js +0 -1
  146. package/dist/package-manager.d.ts +0 -23
  147. package/dist/workspace.d.ts +0 -58
@@ -0,0 +1,5 @@
1
+ var P=Object.defineProperty;var v=(e,n)=>P(e,"name",{value:n,configurable:!0});import{createRequire as R}from"node:module";import{I as S,a as W,e as A,E as d,p as o}from"./bin.js";import{M as N}from"./config.js";import{S as w,g as C,w as M,b as B,p as q,f as j,a as k,c as H,u as y,d as K,e as O,h as D}from"../packem_shared/toolchain-Cc3cwyLP.js";const I=R(import.meta.url),$=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,b=v(e=>{if(typeof $<"u"&&$.versions&&$.versions.node){const[n,i]=$.versions.node.split(".").map(Number);if(n>22||n===22&&i>=3||n===20&&i>=16)return $.getBuiltinModule(e)}return I(e)},"__cjs_getBuiltinModule"),{spawnSync:U}=b("node:child_process"),{writeFileSync:F}=b("node:fs");var L=Object.defineProperty,f=v((e,n)=>L(e,"name",{value:n,configurable:!0}),"d");const x=["bun","deno","go","node","npm","pnpm","python","ruby","rust","yarn"],G=f(e=>x.includes(e),"isKnownTool"),p=f(e=>e?S("✓"):W("✗"),"icon"),T=A("⚠"),J=f(e=>{if(e.installed){const n=e.version?` v${e.version}`:"",i=e.configFiles.length>0?` (${e.configFiles.join(", ")})`:"";return`${p(!0)} ${e.name}${n}${i}`}return`${T} ${e.name} — referenced by ${e.configFiles.join(", ")} but not installed`},"renderManagerLine"),z=f(e=>{if(e.matches)return"";const{manager:n}=e;return n.name==="none"?d("→ (no manager)"):n.name==="self-activate"?"":n.installed?d(`→ ${n.name}`):d(`→ ${n.name} (missing)`)},"renderToolManager"),Q=f(e=>e.matches?p(!0):e.actual?T:p(!1),"toolIcon"),V=f(e=>{if(o.info(""),o.info(d("── Toolchain ───────────────────────")),e.detected.length===0)o.info(` ${p(!1)} No version manager detected`),o.notice(` Install one of: ${w.join(", ")}`);else for(const n of e.detected)o.info(` ${J(n)}`);if(o.info(""),e.tools.length===0){o.info(` ${d("No tool pins found — add engines.node, .nvmrc, or a manager config file.")}`);return}o.info(d("── Tools ───────────────────────────"));for(const n of e.tools){const i=`${n.expected.tool} ${n.expected.version}`,r=n.actual?`actual ${n.actual}`:"not installed",t=n.matches?"":d(` [${n.expected.source}]`),s=z(n),u=s===""?"":` ${s}`;o.info(` ${Q(n)} ${i} — ${r}${t}${u}`),n.manager.note&&o.notice(` ${n.manager.note}`)}},"printStatus"),X=f((e,n,i)=>{const r=C(e,n);if(i.json){process.stdout.write(`${JSON.stringify({detected:r.detected.map(s=>({binPath:s.binPath??null,configFiles:s.configFiles,installed:s.installed,name:s.name,version:s.version??null})),tools:r.tools.map(s=>({actual:s.actual??null,expected:s.expected.version,manager:s.manager.name,managerInstalled:s.manager.installed,matches:s.matches,note:s.manager.note??null,source:s.expected.source,tool:s.expected.tool}))},void 0,2)}
2
+ `);return}V(r);const t=r.tools.filter(s=>!s.matches);t.length>0&&(o.info(""),o.notice(" Run `vis toolchain install` to install pinned versions.")),i.exitCode&&t.length>0&&(process.exitCode=1)},"executeStatus"),Y=f(e=>{const n=new Map;for(const i of e){const r=n.get(i.manager.name);r?r.push(i):n.set(i.manager.name,[i])}return n},"groupByManager"),E=f((e,n,i)=>U(e,n,{cwd:i,stdio:"inherit"}).status??1,"runInvocation"),Z=f((e,n,i)=>{const r=C(e,n),t=r.tools.filter(c=>!c.matches);if(t.length===0){o.success("Everything already matches — nothing to install.");return}const s=t.some(c=>c.manager.name!=="self-activate"&&c.manager.name!=="none");if(r.detected.length===0&&s){o.error(`No version manager detected. Install one of: ${w.join(", ")}.`),process.exitCode=1;return}const u=Y(t);let l=!1,g=0;for(const[c,m]of u){if(c==="self-activate"){for(const{expected:a}of m){if(a.source==="packageManager")o.info(`${d("$")} (${a.tool} will self-activate from packageManager on next invocation)`);else if(o.info(`${d("$")} Writing packageManager=${a.tool}@${a.version}`),i.dryRun)l=!0;else try{M(e,a),l=!0}catch(h){o.error(h.message),g=1}o.notice(` ${a.tool} ${a.version} — no install needed`)}continue}if(c==="none"){for(const{expected:a}of m)o.warn(`Cannot install ${a.tool} ${a.version} — no manager can handle it.`);g=1;continue}if(!r.detected.find(a=>a.name===c)?.installed){o.error(`${c} is referenced but not on PATH — install it first, then rerun \`vis toolchain install\`.`),g=1;continue}const _=m.map(a=>B(c,a.expected)).filter(Boolean);for(const a of _){if(!a)continue;if(a.bin==="nvm"&&a.args.length===0){o.error("nvm is a shell function — run `nvm install` in your shell, then rerun `vis toolchain install`."),a.hint&&o.notice(` ${a.hint}`),g=1;continue}if(o.info(`${d("$")} ${a.bin} ${a.args.join(" ")}`),a.hint&&o.notice(` ${a.hint}`),i.dryRun){l=!0;continue}const h=E(a.bin,a.args,e);if(l=!0,h!==0){g=h;break}}}if(g!==0){process.exitCode=g;return}l&&o.success("Toolchain installed.")},"executeInstall"),ee=f((e,n,i,r)=>{if(!i)throw new Error("Usage: vis toolchain use <tool>@<version> (e.g. vis toolchain use node@22.13.0)");const t=q(i);if(!t)throw new Error(`Could not parse "${i}". Expected "<tool>@<version>" where <tool> is one of ${x.join(", ")}.`);const s=j(e),u=k(t,s,n);if(u.name==="none"){o.error(`No manager can pin ${t.tool}. Install one of: ${w.join(", ")}.`),process.exitCode=1;return}if(!u.installed){o.error(`The best manager for ${t.tool} (${u.name}) is not on PATH. ${u.note??""}`),process.exitCode=1;return}const l=H(u.name,t);if(!l){o.error(`${u.name} cannot pin ${t.tool}. Use a different manager, or set \`toolchain.tools.${t.tool}\` in vis.config.ts.`),process.exitCode=1;return}if(u.name==="self-activate"){if(o.info(`${d("→")} Writing packageManager field to package.json...`),r.dryRun){o.notice(` Would set packageManager: "${t.tool}@${t.version}"`);return}try{const c=M(e,t);if(!c){o.error(`Refusing to pin non-package-manager tool ${t.tool} via the packageManager field.`),process.exitCode=1;return}if(o.success(`Set packageManager: "${c}" — ${t.tool} will activate this version on next invocation.`),r.engines!==!1){const m=y(e,t);m&&o.success(`Updated package.json engines.${t.tool} → ${m}.`)}}catch(c){o.error(c.message),process.exitCode=1}return}if(l.args.length===0&&u.name==="nvm"&&t.tool==="node"){const c=N(e,".nvmrc");if(o.info(`${d("→")} Writing ${c}...`),r.dryRun){o.notice(` Would write ${t.version} to .nvmrc`);return}try{F(c,`${t.version}
3
+ `)}catch(m){o.error(`Failed to write .nvmrc: ${m.message}`),process.exitCode=1;return}o.success(`Wrote ${t.version} to .nvmrc.`),o.notice(" nvm is a shell function — run `nvm use` to activate it in this shell.");return}if(l.args.length===0){o.error(`${u.name} cannot pin ${t.tool} from a subprocess. ${l.configChange?.hint??""}`),l.configChange&&o.notice(` Edit ${l.configChange.file} by hand and rerun \`vis toolchain status\` to verify.`),process.exitCode=1;return}if(o.info(`${d("$")} ${l.bin} ${l.args.join(" ")}`),l.configChange&&o.notice(` Will update ${l.configChange.file} — ${l.configChange.hint}`),r.dryRun)return;const g=E(l.bin,l.args,e);if(g!==0){process.exitCode=g;return}if(o.success(`Pinned ${t.tool} to ${t.version}.`),r.engines!==!1)try{const c=y(e,t);c&&o.success(`Updated package.json engines.${t.tool} → ${c}.`)}catch(c){o.warn(`Could not update engines.${t.tool}: ${c.message}`)}},"executeUse"),ne=f((e,n,i)=>{if(!i)throw new Error("Usage: vis toolchain which <tool> (e.g. vis toolchain which node)");const r=i.toLowerCase();if(!G(r))throw new Error(`Unknown tool "${i}". Known: ${x.join(", ")}.`);const t=j(e),s=k({source:"vis.config.ts",tool:r,version:"*"},t,n),u=s.installed&&s.name!=="self-activate"&&s.name!=="none"?t.find(g=>g.name===s.name):void 0,l=u?K(u,r):O(r);if(!l){o.error(`${i} not found in PATH${u?` or via ${u.name}`:""}.`),process.exitCode=1;return}process.stdout.write(`${l}
4
+ `)},"executeWhich"),oe=f((e,n)=>{const i=D(e,n);process.stdout.write(`${i.name}
5
+ `)},"executeDetect"),ce=f(async({argument:e,options:n,visConfig:i,workspaceRoot:r})=>{if(!r)throw new Error("Could not determine workspace root. Run inside a monorepo.");const t=e[0]??"status",s=i?.toolchain;switch(t){case"detect":{oe(r,s);return}case"install":{Z(r,s,n);return}case"status":{X(r,s,n);return}case"use":{ee(r,s,e[1],n);return}case"which":{ne(r,s,e[1]);return}default:throw new Error(`Unknown toolchain action "${t}". Known: status, detect, install, use, which.`)}},"execute");export{ce as default};
@@ -0,0 +1 @@
1
+ var p=Object.defineProperty;var s=(e,a)=>p(e,"name",{value:a,configurable:!0});import{f,a5 as g}from"./bin.js";var u=Object.defineProperty,d=s((e,a)=>u(e,"name",{value:a,configurable:!0}),"t");const m=d(async({argument:e,logger:a,options:c,visConfig:o,workspaceRoot:t})=>{const i=e||[],n=t??process.cwd(),l=f(n,{configBackend:o?.install?.backend,configCorepack:o?.install?.corepack}),r=g(l,i,c.recursive||!1,n,a);r!==0&&(process.exitCode=r)},"execute");export{m as default};
@@ -0,0 +1,3 @@
1
+ var a=Object.defineProperty;var s=(n,e)=>a(n,"name",{value:e,configurable:!0});import{createRequire as f}from"node:module";import{a6 as v}from"./bin.js";const d=f(import.meta.url),t=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,l=s(n=>{if(typeof t<"u"&&t.versions&&t.versions.node){const[e,r]=t.versions.node.split(".").map(Number);if(e>22||e===22&&r>=3||e===20&&r>=16)return t.getBuiltinModule(n)}return d(n)},"__cjs_getBuiltinModule"),{execSync:p,spawnSync:m}=l("node:child_process");var g=Object.defineProperty,y=s((n,e)=>g(n,"name",{value:e,configurable:!0}),"r");const w=y(async({argument:n,logger:e,options:r})=>{const c=n?.[0];e.info("info: checking for updates...");const o=v.version;let i;try{const u=p("npm view @visulima/vis version",{encoding:"utf8"}).trim();i=c??u}catch{throw new Error("Failed to query npm registry. Check your network connection.")}if(o===i&&!r.force){e.info(`
2
+ ✓ Already up to date (${o})`);return}if(r.check){o===i?e.info(`✓ Already up to date (${o})`):e.info(`info: found @visulima/vis@${i} (current: ${o})`);return}if(e.info(`info: found @visulima/vis@${i} (current: ${o})`),e.info("info: installing..."),m("npm",["install","-g",`@visulima/vis@${i}`],{encoding:"utf8",stdio:"inherit"}).status!==0)throw new Error("Failed to update. Try running with sudo or fix npm permissions.");e.info(`
3
+ ✓ Updated @visulima/vis from ${o} → ${i}`)},"execute");export{w as default};
@@ -0,0 +1 @@
1
+ var p=Object.defineProperty;var t=(a,o)=>p(a,"name",{value:o,configurable:!0});import{f,a7 as d}from"./bin.js";import{o as g}from"../packem_shared/utils-DrNg0XTR.js";var v=Object.defineProperty,u=t((a,o)=>v(a,"name",{value:o,configurable:!0}),"n");const h=u(async({argument:a,logger:o,options:e,visConfig:l,workspaceRoot:c})=>{const s=a;if(!s||s.length===0)throw new Error("No packages specified. Usage: vis why <package...>");const n=c??process.cwd(),i=f(n,{configBackend:l?.install?.backend,configCorepack:l?.install?.corepack}),r=d(i,{depth:e.depth===void 0?void 0:Number(e.depth),dev:e.dev||!1,filter:g(e.filter),global:e.global||!1,json:e.json||!1,long:e.long||!1,noOptional:e.optional===!1,packages:s,parseable:e.parseable||!1,prod:e.prod||!1,recursive:e.recursive||!1},n,o);r!==0&&r!==1&&(process.exitCode=r)},"execute");export{h as default};
@@ -0,0 +1,4 @@
1
+ var N=Object.defineProperty;var h=(n,t)=>N(n,"name",{value:t,configurable:!0});import{U as P,R as T,P as x,S as b,z as U,_ as j,T as z,J as O,N as J}from"./bin.js";import{H as M,e as S,Z as q}from"../packem_shared/ai-analysis-uYuTIIXi.js";var A=Object.defineProperty,F=h((n,t)=>A(n,"name",{value:t,configurable:!0}),"x");const H=/^[\^~>=<]+/,_=F(async({argument:n,logger:t,options:f,visConfig:l,workspaceRoot:g})=>{if(!g)throw new Error("Could not determine workspace root. Run this command inside a monorepo.");const m=n,e=m[0];if(!e)throw new Error("Package name is required. Usage: vis analyze <package> [version]");const p=m[1],{packageManager:R}=P(g);let r,w="default";const E=T(g,R);for(const[o,s]of E){const i=s.get(e);if(i){r=i,w=o;break}}if(!r)throw new Error(`Package "${e}" not found in any catalog or package.json. Make sure it exists in your workspace dependencies.`);let a;if(p)a=p;else{t.info(`Fetching latest version for ${e}...
2
+ `);const o=await x(e);if(!o.latest)throw new Error(`Could not determine latest version for "${e}".`);a=o.latest}const d=b(r),k=b(a);if(!d||!k)throw new Error(`Could not parse versions: current="${r}", target="${a}".`);const v=U(d,k);if(v==="none"){t.info(`${e} is already at ${a}. Nothing to analyze.`);return}const C=j(r),u={catalogName:w,currentRange:r,newRange:`${C}${a}`,packageName:e,targetVersion:a,updateType:v},y=M(f.aiType??"impact");if(y==="security"||f.security){t.info(`Checking for known vulnerabilities...
3
+ `);const o=r.replace(H,""),s=(await z([{name:e,version:o}])).get(e);s&&s.length>0&&(u.vulnerabilities=s);const i=O(l?.security?.socket,l?.security?.policies?.score?.minimum);if(i){const c=(await J([{name:e,version:o}],i)).get(`${e}@${o}`);c&&(u.socketReport={alerts:c.alerts,license:c.license,score:c.score})}}const $=await S([u],t,l?.ai,y);(f.format??"table")==="json"?process.stdout.write(`${JSON.stringify($,void 0,2)}
4
+ `):t.info(q($))},"execute");export{_ as default};
@@ -0,0 +1,7 @@
1
+ var x=Object.defineProperty;var l=(e,o)=>x(e,"name",{value:o,configurable:!0});import{b as g,O as E,_ as S,R as f}from"../packem_shared/ai-analysis-uYuTIIXi.js";import{renderToString as w}from"@visulima/tui";import{Table as D}from"@visulima/tui/components/table";import P from"react";import{j as I,E as d,q as O,I as j,e as N}from"./bin.js";var T=Object.defineProperty,u=l((e,o)=>T(e,"name",{value:o,configurable:!0}),"s");const v={command:"ai",description:"AI-assisted commands: provider detection, cache management, and failure-fix proposals."},R=u(e=>{if(typeof e!="function")return String(e);const{name:o}=e;return o==="Boolean"?"boolean":o==="Number"?"number":o==="String"?"string":o??"unknown"},"typeName"),A=u(e=>{const o=[...e.commandPath??[],e.name].join(" "),i=(e.examples??[]).map(([t,s])=>({command:t??"",description:s??""})),a=(e.options??[]).map(t=>({defaultValue:t.defaultValue,description:t.description,name:t.name,type:R(t.type)}));return{argument:e.argument?{description:e.argument.description,name:e.argument.name}:void 0,description:e.description??"",examples:i,name:e.name,options:a,path:o}},"buildSubcommand"),h=u((e,o=v)=>({command:o.command,description:o.description,subcommands:e.map(i=>A(i))}),"buildDiscoveryPayload"),C=u((e,o=v)=>`${JSON.stringify(h(e,o),void 0,2)}
2
+ `,"renderDiscoveryJson"),J=u((e,o=v)=>{const i=h(e,o),a=[I(`vis ${i.command} — ${i.description}`),"",d("Subcommands:")];for(const t of i.subcommands){const s=t.argument?` ${O(`<${t.argument.name}>`)}`:"";if(a.push(""),a.push(` ${j(`vis ${t.path}`)}${s}`),t.description&&a.push(` ${t.description}`),t.options.length>0){const n=t.options.map(c=>`--${c.name}${c.type==="boolean"?"":`=<${c.type}>`}`).join(", ");a.push(d(` options: ${n}`))}if(t.examples.length>0){a.push(d(" examples:"));for(const n of t.examples){const c=n.description?d(` — ${n.description}`):"";a.push(` ${N(n.command)}${c}`)}}}return a.push(""),a.push(d(`Run \`vis ${i.command} discover-help\` for the machine-readable JSON catalogue (designed for AI agents).`)),a.push(d(`Run \`vis ${i.command} <subcommand> --help\` for full usage of a specific subcommand.`)),`${a.join(`
3
+ `)}
4
+ `},"renderDiscoveryText");var F=Object.defineProperty,p=l((e,o)=>F(e,"name",{value:o,configurable:!0}),"r");const b=p(async()=>{const{default:e}=await import("./bin.js").then(o=>o.bE);return e.filter(o=>o.name!=="ai")},"loadDiscoverableSubcommands"),K=p(async()=>{const e=await b();process.stderr.write(J(e))},"aiRootExecute"),L=p(async()=>{const e=await b();process.stdout.write(C(e))},"aiDiscoverHelpExecute"),_=p(async({logger:e,visConfig:o})=>{const i=o?.ai,a=g(i);if(!a){e.error("No AI provider available to test."),process.exitCode=1;return}e.info(`Testing ${a.name}...`);try{const t=await E(a,"Reply with exactly: OK",{timeoutMs:3e4});e.info(`Provider ${a.name} responded: ${t.stdout.trim().slice(0,200)}`)}catch(t){const s=t instanceof Error?t.message:String(t);e.error(`Provider ${a.name} failed: ${s}`),process.exitCode=1}},"aiTestExecute"),z=p(({logger:e,options:o,visConfig:i})=>{const a=o.format??"table",t=i?.ai,s=S(),n=g(t);if(a==="json"){const r=s.map(m=>({available:m.available,method:m.detectionMethod,name:m.name,path:m.path,priority:f[m.name]??0,selected:m.name===n?.name,version:m.version}));process.stdout.write(`${JSON.stringify(r,void 0,2)}
5
+ `);return}const c=s.map(r=>({method:r.detectionMethod??"-",path:r.path??"-",priority:String(f[r.name]??0),provider:r.name,selected:r.name===n?.name?">>>":"",status:r.available?"available":"not found",version:r.version??"-"})),y=process.stdout.columns||80,$=w(P.createElement(D,{data:c}),{columns:y});e.info($),n?e.info(`
6
+ Selected provider: ${n.name} (priority ${String(f[n.name]??0)})`):e.info(`
7
+ No AI provider available. Install one of the supported AI CLI tools.`)},"aiProvidersExecute"),G=p(async e=>{const{aiFix:o}=await import("./fix.js");await o(e)},"aiFixExecute");export{L as aiDiscoverHelpExecute,G as aiFixExecute,z as aiProvidersExecute,K as aiRootExecute,_ as aiTestExecute};
@@ -0,0 +1,33 @@
1
+ var R=Object.defineProperty;var k=(n,t)=>R(n,"name",{value:t,configurable:!0});import{createRequire as B}from"node:module";import{j as D,i as V,$ as q,B as v}from"./config.js";import{A as E,p as e}from"./bin.js";import{x as M}from"../packem_shared/build-scripts-DsWMSWDs.js";import{N as F}from"../packem_shared/native-config-sync-Dvi1g2nQ.js";const O=B(import.meta.url),m=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,T=k(n=>{if(typeof m<"u"&&m.versions&&m.versions.node){const[t,s]=m.versions.node.split(".").map(Number);if(t>22||t===22&&s>=3||t===20&&s>=16)return m.getBuiltinModule(n)}return O(n)},"__cjs_getBuiltinModule"),{spawnSync:A}=T("node:child_process");var W=Object.defineProperty,x=k((n,t)=>W(n,"name",{value:t,configurable:!0}),"$$1");const z=/(defineConfig\s*\(\s*\{)/,J=/(export\s+default\s+\{)/,w=x((n,t)=>`${t}${JSON.stringify(n)}: true,`,"renderEntry"),G=x((n,t)=>{if(t.length===0)return{added:[],skipped:[],status:"noop"};const s=D(n);if(!s)return{added:[],skipped:t,status:"no-config"};if(!V(s))return{added:[],skipped:t,status:"no-config"};const i=q(s),h=i.search(/installScripts\s*:\s*\{/);let p=null,c=0;if(h!==-1){const a=i.slice(h),d=/(allow\s*:\s*\{)([^}]*)(\})/.exec(a);d?.index!==void 0&&(p=d,c=h+d.index)}if(p){const a=p[2]??"",d=new Set;for(const g of a.matchAll(/["']([^"']+)["']\s*:/g))d.add(g[1]);for(const g of a.matchAll(/(?:^|,|\{)\s*([a-z_$][\w-]*)\s*:/gi))d.add(g[1]);const f=[],S=[];for(const g of t)d.has(g)?S.push(g):f.push(g);if(f.length===0)return{added:[],configPath:s,skipped:S,status:"noop"};const _=/\n([ \t]+)\S/.exec(a)?.[1]??" ",P=`
2
+ ${f.map(g=>w(g,_)).join(`
3
+ `)}`,y=a.replace(/\s+$/,""),b=a.slice(y.length),N=`${y}${y.endsWith(",")||y===""?"":","}${P}${b.length>0?b:`
4
+ `}`,C=`${i.slice(0,c)}${p[1]}${N}${p[3]}${i.slice(c+p[0].length)}`;return v(s,C),{added:f,configPath:s,skipped:S,status:"updated"}}const o=/(installScripts\s*:\s*\{)/;if(o.test(i)){const a=`
5
+ allow: {
6
+ ${t.map(f=>w(f," ")).join(`
7
+ `)}
8
+ },`,d=i.replace(o,`$1${a}`);return v(s,d),{added:t,configPath:s,skipped:[],status:"updated"}}const r=/(policies\s*:\s*\{)/;if(r.test(i)){const a=`
9
+ installScripts: {
10
+ allow: {
11
+ ${t.map(f=>w(f," ")).join(`
12
+ `)}
13
+ },
14
+ },`,d=i.replace(r,`$1${a}`);return v(s,d),{added:t,configPath:s,skipped:[],status:"updated"}}const u=/(security\s*:\s*\{)/;if(u.test(i)){const a=`
15
+ policies: {
16
+ installScripts: {
17
+ allow: {
18
+ ${t.map(f=>w(f," ")).join(`
19
+ `)}
20
+ },
21
+ },
22
+ },`,d=i.replace(u,`$1${a}`);return v(s,d),{added:t,configPath:s,skipped:[],status:"updated"}}const l=z.exec(i)??J.exec(i);if(!l)return{added:[],configPath:s,skipped:t,status:"missing-anchor"};const $=`
23
+ security: {
24
+ policies: {
25
+ installScripts: {
26
+ allow: {
27
+ ${t.map(a=>w(a," ")).join(`
28
+ `)}
29
+ },
30
+ },
31
+ },
32
+ },`,j=`${i.slice(0,l.index+l[0].length)}${$}${i.slice(l.index+l[0].length)}`;return v(s,j),{added:t,configPath:s,skipped:[],status:"updated"}},"writeApprovedBuildsToVisConfig");var H=Object.defineProperty,I=k((n,t)=>H(n,"name",{value:t,configurable:!0}),"d");const Z=I(async({options:n,visConfig:t,workspaceRoot:s})=>{const i=s??process.cwd(),h=E(i);if(h.name==="pnpm"&&!n.scan){e.info("Delegating to pnpm approve-builds...");const p=["approve-builds"];n.all&&p.push("--all");const c=A("pnpm",p,{cwd:i,stdio:"inherit"});if(c.error)throw new Error(`Failed to run pnpm approve-builds: ${c.error.message}`);if(c.status!==0&&c.status!==null&&(e.error(`pnpm approve-builds exited with code ${c.status}`),process.exitCode=c.status),!n.syncNative){e.notice(""),e.notice("Tip: vis.config.ts security.policies.installScripts.allow may now be out of sync with pnpm-workspace.yaml."),e.notice("Run 'vis check --security-config' to compare, or copy the new entries into vis.config.ts.");return}}else{const p=t?.security?.policies?.installScripts?.allow??{},c=t?.security?.pinVersions===!0,o=M(i,p,{pinVersions:c});if(o.unapproved.length===0)e.success("No unapproved build scripts found."),n.write&&(e.info(""),e.info("Nothing to write — there are no unapproved build scripts."));else{e.warn(`Found ${o.unapproved.length} package${o.unapproved.length===1?"":"s"} with unapproved build scripts:
33
+ `);for(const r of o.unapproved)e.info(` ${r.name} (${r.hooks.join(", ")})`);e.notice(""),e.notice("To approve these packages, add them to vis.config.ts:"),e.notice(""),e.notice(" security: {"),e.notice(" policies: {"),e.notice(" installScripts: {"),e.notice(" allow: {");for(const r of o.unapproved){const u=c&&r.version?`${r.name}@${r.version}`:r.name;e.notice(` "${u}": true,`)}if(e.notice(" },"),e.notice(" },"),e.notice(" },"),e.notice(" },"),h.name==="pnpm"&&(e.notice(""),e.notice("Or run 'pnpm approve-builds' to update pnpm-workspace.yaml directly.")),n.write){const r=t?.security?.pinVersions===!0,u=o.unapproved.map($=>r&&$.version?`${$.name}@${$.version}`:$.name),l=G(i,u);switch(e.info(""),l.status){case"missing-anchor":{e.warn(`Could not locate 'defineConfig({' or 'export default {' in ${String(l.configPath)} — please add entries manually.`);break}case"no-config":{e.warn("No vis.config.ts found. Run 'vis init' first, then re-run with --write.");break}case"noop":{e.info(`All ${String(u.length)} entr${u.length===1?"y":"ies"} were already present in vis.config.ts security.policies.installScripts.allow.`);break}default:e.success(`Wrote ${String(l.added.length)} entr${l.added.length===1?"y":"ies"} to ${String(l.configPath)}.`),l.skipped.length>0&&e.info(`Skipped ${String(l.skipped.length)} already-present entr${l.skipped.length===1?"y":"ies"}.`)}}}if(o.excess.length>0){e.notice(""),e.warn(`Stale installScripts.allow entries — ${String(o.excess.length)} pattern${o.excess.length===1?"":"s"} no longer match any installed package:`);for(const r of o.excess)e.info(` ${r}`);e.notice("Consider removing these entries from vis.config.ts security.policies.installScripts.allow.")}if(o.versionDrift.length>0){e.notice(""),e.warn(`Version drift — ${String(o.versionDrift.length)} entr${o.versionDrift.length===1?"y":"ies"} pinned to an outdated version:`);for(const{from:r,to:u}of o.versionDrift)e.info(` ${r} → ${u}`);e.notice("Rename the keys in vis.config.ts security.policies.installScripts.allow to migrate.")}}if(n.syncNative){const p=t?.security?.policies?.installScripts?.allow??{};if(Object.keys(p).length===0)e.warn("No security.policies.installScripts.allow configured in vis.config.ts. Nothing to sync.");else{const c=F(h.name,i,p);e.info("");for(const o of c)e.success(o)}}},"execute");export{Z as default};
@@ -0,0 +1,3 @@
1
+ var I=Object.defineProperty;var y=(e,t)=>I(e,"name",{value:t,configurable:!0});import{createRequire as D}from"node:module";import{getAffectedProjects as G}from"@visulima/task-runner";import{y as q,m as L}from"./bin.js";const T=D(import.meta.url),h=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,A=y(e=>{if(typeof h<"u"&&h.versions&&h.versions.node){const[t,r]=h.versions.node.split(".").map(Number);if(t>22||t===22&&r>=3||t===20&&r>=16)return h.getBuiltinModule(e)}return T(e)},"__cjs_getBuiltinModule"),{execFile:N}=A("node:child_process"),{promisify:U}=A("node:util");var V=Object.defineProperty,i=y((e,t)=>V(e,"name",{value:t,configurable:!0}),"t");const M=U(N),J=["[skip ci]","[ci skip]","[no ci]","[vis skip]","[nx skip]"],z=["[vis deploy]","[nx deploy]"],W=["vis","nx"],Z=["CACHED_COMMIT_REF","VERCEL_GIT_PREVIOUS_SHA","GITHUB_BASE_REF","CI_COMMIT_BEFORE_SHA"],K=/^[\w./~^@{}][\w.\-/~^@{}]*$/,Q=i((e=process.env)=>{for(const t of Z){const r=e[t];if(r&&r.trim().length>0)return r.trim()}},"resolveCiBaseSha"),R=i(e=>{if(!K.test(e))throw new Error(`Invalid git ref: "${e}". Refs must start with an alphanumeric character or one of _ . / ~ ^ @ { } and may only contain letters, digits, dots, dashes, underscores, slashes, tildes, carets, @, and braces.`)},"validateGitRef"),X=i(async(e,t)=>{try{return await M("git",["rev-parse","--verify",`${t}^{commit}`],{cwd:e}),!0}catch{return!1}},"isRefReachable"),Y=i(async e=>{try{const{stdout:t}=await M("git",["log","-1","--pretty=%B"],{cwd:e});return t}catch{return""}},"readLastCommitMessage"),B=i((e,t,r)=>W.some(a=>e.includes(`[${a} ${t} ${r}]`)),"matchesPerProjectToken"),ee=i((e,t)=>J.some(r=>e.includes(r))||B(e,"skip",t),"commitHasSkipMessage"),te=i((e,t)=>z.some(r=>e.includes(r))||B(e,"deploy",t),"commitHasForceDeployMessage"),l=i((e,t,r,a)=>({action:"build",message:r,project:e,reason:t,...a}),"decideBuild"),k=i((e,t,r,a)=>({action:"skip",message:r,project:e,reason:t,...a}),"decideSkip"),re=i(e=>`${e.action==="skip"?"🛑":"✅"} ${e.message}`,"formatDecisionLine"),oe=i((e,t)=>e.action==="skip"||t?0:1,"exitCodeFor");var se=Object.defineProperty,_=y((e,t)=>se(e,"name",{value:t,configurable:!0}),"u");const S=new Set(["deep","direct","none"]),de=_(async({argument:e,logger:t,options:r,visConfig:a,workspaceRoot:p})=>{const o=e[0]??"",E=!!r.json,C=!!r.verbose,O=!!(r["exit-zero-on-build"]??r.exitZeroOnBuild),u=_(s=>{C&&!E&&t.info(`❱ ${s}`)},"debug"),n=_(s=>{E?process.stdout.write(`${JSON.stringify(s)}
2
+ `):t.info(re(s)),process.exit(oe(s,O))},"emit");if(!o)return n(l("","missing-project-argument","Missing project argument. Usage: vis ignore <project>"));if(!p)return n(l(o,"workspace-error","Could not determine workspace root — building defensively"));const g=await Y(p),w=g.trim().split(`
3
+ `)[0]??"";if(u(`commit: ${w}`),g&&te(g,o))return n(l(o,"commit-force-deploy",`Force-deploy keyword in commit: "${w}"`));if(g&&ee(g,o))return n(k(o,"commit-skip",`Skip keyword in commit: "${w}"`));let $,P;try{({packageJsons:P,workspace:$}=q(p,a))}catch(s){const d=s instanceof Error?s.message:String(s);return n(l(o,"workspace-error",`Workspace discovery failed (${d}) — building defensively`))}if(!Object.hasOwn($.projects,o))return n(l(o,"project-unknown",`Project "${o}" not found in workspace — building defensively`));try{const s=r.base?.trim(),d=Q();let c=s||d||"HEAD~1";const m=r.head?.trim()||"HEAD";R(c),R(m),u(`resolved base ref: ${c} (source: ${s?"flag":d?"ci-env":"default"})`);const x=X(p,c),F=L(p,$,P);await x||(u(`base ref ${c} not reachable — falling back to HEAD~1`),c="HEAD~1"),u(`comparing ${c}...${m}`);const j=r.downstream??"deep",b=r.upstream??"none";if(!S.has(j))throw new Error(`Invalid --downstream value: "${j}". Must be "none", "direct", or "deep".`);if(!S.has(b))throw new Error(`Invalid --upstream value: "${b}". Must be "none", "direct", or "deep".`);const H={base:c,downstream:j,head:m,projectGraph:F,projects:$.projects,upstream:b,workspaceRoot:p},f=await G(H);u(`changed files: ${f.changedFiles.length}`),u(`affected projects: ${f.affectedProjects.join(", ")||"(none)"}`);const v={base:c,head:m};return f.changedFiles.length===0?n(k(o,"no-changes",`No files changed between ${c}...${m}`,{...v,affectedProjects:[]})):f.affectedProjects.includes(o)?n(l(o,"project-affected",`Build ${o}: affected by ${f.changedFiles.length} changed file(s)`,{...v,affectedProjects:f.affectedProjects})):n(k(o,"project-not-affected",`Skip ${o}: not affected by changes between ${c}...${m}`,{...v,affectedProjects:f.affectedProjects}))}catch(s){const d=s instanceof Error?s.message:String(s);return t.error(`Affected detection failed: ${d}`),n(l(o,"workspace-error",`Affected detection failed (${d}) — building defensively`))}},"execute");export{de as default};
@@ -0,0 +1 @@
1
+ var C=Object.defineProperty;var T=(e,t)=>C(e,"name",{value:t,configurable:!0});import{z as S}from"./config.js";import{aj as q,y as b}from"./bin.js";import{f as $}from"../packem_shared/selectors-B2ISH581.js";import{o as L}from"../packem_shared/index-DH-5hsrC.js";var M=Object.defineProperty,I=T((e,t)=>M(e,"name",{value:t,configurable:!0}),"p");const D=I((e,t)=>{for(const f of t)if(L(f,e))return!0;return!1},"matchesAny"),z=I((e,t={})=>{const{depTypes:f,excludePatterns:l,externalOnly:y,includePatterns:d,internalOnly:j}=t;if(j&&y)return[];const u=f&&f.length>0?new Set(f):void 0,N=d&&d.length>0?d:void 0,O=l&&l.length>0?l:void 0,w=[];for(const m of e)j&&!m.isInternal||y&&m.isInternal||u&&!u.has(m.depType)||N&&(!m.packageName||!D(m.packageName,N))||O&&m.packageName&&D(m.packageName,O)||w.push(m);return w},"filterDepInstances");var B=Object.defineProperty,v=T((e,t)=>B(e,"name",{value:t,configurable:!0}),"y");const F=new Set(["json","ndjson","table"]),R=v(e=>{if(e===void 0)return"table";const t=e.toLowerCase();if(!F.has(t))throw new Error(`--format must be one of: table, json, ndjson (got "${e}")`);return t},"resolveFormat"),x=v((e,t)=>({depName:e.depName,depType:e.depType,isInternal:e.isInternal,packageDir:e.packageDir,packageJsonPath:S(t,e.packageJsonPath),packageName:e.packageName,specifier:e.specifier}),"toDepRecord"),P=new Set(["dependencies","devDependencies","optionalDependencies","overrides","peerDependencies","pnpm.overrides","resolutions"]),V=v(e=>{if(!e||e.length===0)return;const t=[],f=[];for(const l of e)for(const y of l.split(",")){const d=y.trim();d&&(P.has(d)?t.push(d):f.push(d))}if(f.length>0)throw new Error(`Unknown --dep-type value(s): ${f.join(", ")}. Valid: ${[...P].join(", ")}`);return t.length>0?t:void 0},"parseDepTypes"),H=v(async({logger:e,options:t,visConfig:f,workspaceRoot:l})=>{if(!l)throw new Error("Could not determine workspace root.");const y=R(t.format);if(t.deps===!0){if(t.internalOnly&&t.externalOnly)throw new Error("--internal-only and --external-only are mutually exclusive");const c=V(t.depType),i=q(l);let n=z(i,{depTypes:c,excludePatterns:t.exclude,externalOnly:t.externalOnly,includePatterns:t.include,internalOnly:t.internalOnly});if(t.query){const{workspace:r}=b(l,f),p=new Set($(Object.keys(r.projects),r,t.query));n=n.filter(k=>k.packageName!==void 0&&p.has(k.packageName))}const g=[...n].sort((r,p)=>{const k=`${r.packageName??r.packageDir} ${r.depType} ${r.depName}`,J=`${p.packageName??p.packageDir} ${p.depType} ${p.depName}`;return k.localeCompare(J)});if(y==="ndjson"){for(const r of g)e.info(JSON.stringify(x(r,l)));return}if(y==="json"){const r=g.map(p=>x(p,l));e.info(JSON.stringify(r,null,t.pretty===!0?2:void 0));return}if(g.length===0){e.info("No matching dep-instances.");return}const a=["Package","Block","Dep","Specifier","Internal","Path"],o=g.map(r=>[r.packageName??r.packageDir,r.depType,r.depName,r.specifier,r.isInternal?"yes":"no",S(l,r.packageJsonPath)]),s=a.map((r,p)=>Math.max(r.length,...o.map(k=>(k[p]??"").length))),h=v((r,p)=>r.padEnd(p),"pad");e.info(a.map((r,p)=>h(r,s[p])).join(" ")),e.info(s.map(r=>"─".repeat(r)).join("──"));for(const r of o)e.info(r.map((p,k)=>h(p,s[k])).join(" "));e.info(""),e.info(`${String(g.length)} dep-instance(s)`);return}if(y==="ndjson")throw new Error("--format=ndjson is only supported with --deps");const{projectOptions:d,workspace:j}=b(l,f);let u=Object.keys(j.projects).sort();if(t.query&&(u=$(u,j,t.query)),u.length===0){e.info("No projects found.");return}const N=t.inferred===!0,O=t.targets===!0||N;if(y==="json"){const c=u.map(i=>{const n=j.projects[i],g=d.get(i)??{},a=Object.entries(n.targets??{}).map(([o])=>{const s=g[o],h=s?.inferred===!0;return{aliases:s?.aliases??[],command:s?.command,description:s?.description,...h?{inferred:!0}:{},name:o,type:s?.type}}).filter(o=>!N||o.inferred===!0);return{language:n.language,layer:n.layer,name:i,root:n.root,stack:n.stack,tags:n.tags??[],targets:a,type:n.projectType??"library"}});e.info(JSON.stringify(c,null,2));return}const w=v((c,i)=>{const n=c.map((a,o)=>{let s=0;for(const h of i)s=Math.max(s,(h[o]??"").length);return Math.max(a.length,s)}),g=v((a,o)=>a.padEnd(o),"pad");e.info(c.map((a,o)=>g(a,n[o])).join(" ")),e.info(n.map(a=>"─".repeat(a)).join("──"));for(const a of i)e.info(a.map((o,s)=>g(o,n[s])).join(" "))},"renderTable");if(O){const c=[];for(const i of u){const n=j.projects[i],g=d.get(i)??{};for(const a of Object.keys(n.targets??{}).sort()){const o=g[a],s=o?.inferred===!0;if(N&&!s)continue;const h=n.targets?.[a],r=h?.cache===!1?"no":h?.cache===!0?"yes":"default";c.push([i,a,o?.type??"—",r,s?"yes":"no",o?.description??"—"])}}if(c.length===0){e.info(N?"No inferred targets found.":"No targets found.");return}w(["Project","Target","Type","Cache","Inferred","Description"],c),e.info(""),e.info(`${String(c.length)} target(s) across ${String(u.length)} project(s)`);return}const m=["Project","Type","Layer","Tags","Targets"],E=u.map(c=>{const i=j.projects[c],n=Object.keys(i.targets??{});return[c,i.projectType??"library",i.layer??"—",(i.tags??[]).join(", ")||"—",n.length>4?`${n.slice(0,4).join(", ")}… (${String(n.length)})`:n.join(", ")||"—"]});w(m,E),e.info(""),e.info(`${String(u.length)} project(s)`)},"execute");export{H as default};
@@ -0,0 +1,26 @@
1
+ var Re=Object.defineProperty;var I=(e,t)=>Re(e,"name",{value:t,configurable:!0});import{createRequire as Se}from"node:module";import{am as xe,u as ae,an as Ee,F as N,e as G,ao as Te,d as Ne,G as Me,H as ge,ap as Ue,aq as me,i as se,O as je,R as Fe,J as _e,V as qe,ar as Be,W as Le,as as Oe,s as fe,a as he,U as Pe,at as Ie,au as De,av as We,f as Ge,aw as He}from"./bin.js";import{M as D,i as W,$ as Ve}from"./config.js";import{render as oe,renderToString as X}from"@visulima/tui";import{Text as S}from"@visulima/tui/components/text";import $ from"react";import{H as Ye,e as ze,Z as re}from"../packem_shared/ai-analysis-uYuTIIXi.js";import{r as Ze,b as Je,p as Xe}from"../packem_shared/resolve-explicit-CC4Kifk5.js";import{r as Ke,s as Qe}from"../packem_shared/typosquats-BCeR-sLf.js";import{U as et,C as tt,a as ie}from"../packem_shared/vis-update-app-CFrlJ3mW.js";import{d as nt}from"../packem_shared/utils-DrNg0XTR.js";const Ae=Se(import.meta.url),_=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,de=I(e=>{if(typeof _<"u"&&_.versions&&_.versions.node){const[t,n]=_.versions.node.split(".").map(Number);if(t>22||t===22&&n>=3||t===20&&n>=16)return _.getBuiltinModule(e)}return Ae(e)},"__cjs_getBuiltinModule"),{execFileSync:pe}=de("node:child_process"),{createInterface:Ce}=de("node:readline");var at=Object.defineProperty,x=I((e,t)=>at(e,"name",{value:t,configurable:!0}),"s");const st=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"),ot=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"),rt=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"),it=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"),lt=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"),ct=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"),ut=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=xe(n);o={args:s.args,bin:s.bin},a.push(...s.warnings);break}case"bun":{o=lt(n);break}case"deno":{o=ct(n,a);break}case"npm":{o=it(n,a);break}case"pnpm":{o=st(n);break}case"yarn":{o=t.startsWith("1.")?ot(n):rt(n);break}default:{const s=e;throw new Error(`Unsupported package manager: ${String(s)}`)}}return{command:o,warnings:a}},"resolveUpdateCommand");var dt=Object.defineProperty,k=I((e,t)=>dt(e,"name",{value:t,configurable:!0}),"y");const ve=k(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"),pt=k(e=>{const t=e.trim();return/^\d+(?:\.\d+)?$/.test(t)?Number.parseFloat(t)*1440:ve(t)},"parseNpmReleaseAgeValue"),Nt=k(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"),gt=k((e,t)=>{try{switch(t){case"bun":{const n=D(e,"bunfig.toml");if(W(n)){const a=Ee(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=D(e,".npmrc");if(W(n)){const a=Ve(n),o=/^\s*min-release-age\s*=\s*([^\s#;]+)/m.exec(a);return{minutes:o?pt(o[1]):void 0}}break}case"pnpm":{const n=D(e,"pnpm-workspace.yaml");if(W(n)){const a=ae(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=D(e,".yarnrc.yml");if(W(n)){const a=ae(n)?.npmMinimalAgeGate;if(typeof a=="string")return{minutes:ve(a)};if(typeof a=="number")return{minutes:a}}break}}}catch{}return{}},"readPmNativeMinimumReleaseAge"),mt=k((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,r=typeof e.releaseChannel=="string"?e.releaseChannel.toLowerCase():void 0;if(r!==void 0&&!["any","same","stable"].includes(r))throw new Error(`Invalid --release-channel "${String(e.releaseChannel)}". Use: any, same, or stable.`);const m=r??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:m,security:e.security||e.ai||t.security||!1,target:a}},"buildCatalogCheckOptions"),le=k((e,t)=>{if(e.length!==0){t.info(`
2
+ ${G("⚠")} ${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"),ce=k((e,t,n,a,o)=>{n==="json"?process.stdout.write(`${Te({checkedCount:0,failed:t,filteredByTarget:[],ignored:[],outdated:e})}
3
+ `):n==="minimal"?process.stdout.write(`${Ne(e)}
4
+ `):(Me(e,a),a.info(ge(e,o)))},"writeFormattedOutput"),ue=k(async(e,t,n,a,o,s,r)=>{const m=Ue(e,n,t,!0,{useEditorconfig:r}),u=t==="pnpm"?"pnpm-workspace.yaml":"package.json";if(o.info(`
5
+ Updated ${u}`),m&&o.info(`Backup saved to ${m}`),a.changelog){o.info(`
6
+ Fetching changelogs...`);const p=await me(n,void 0,s);for(const l of p){const f=l.releaseUrl??l.repoUrl??l.npmUrl;o.info(` ${l.packageName}: ${f}`)}}if(a.install??!0){const p=t,l=["install"];o.info(`Running ${p} ${l.join(" ")}...
7
+ `);try{pe(p,l,{cwd:e,env:process.env,stdio:"inherit"})}catch{o.warn(`${p} ${l.join(" ")} failed. You may need to run it manually.`)}}},"applyCatalogAndInstall"),ft=k(async(e,t,n,a,o,s)=>{const r=n.update??{},m=[["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[i,d]of m)a[i]&&s.warn(`${G("⚠")} ${d}, ignoring.`);const u=se("minReleaseAge"),{excludes:p,minutes:l}=u?{excludes:void 0,minutes:void 0}:gt(e,t),f=u?void 0:r.minimumReleaseAge??l,q=u?void 0:r.minimumReleaseAgeExclude??p;if(u&&(r.minimumReleaseAge!==void 0||l!==void 0)&&s.info("minimumReleaseAge gate disabled via MARSHALL_DISABLE_MIN_RELEASE_AGE."),!u&&r.minimumReleaseAge!==void 0&&l!==void 0&&r.minimumReleaseAge!==l){const i=t==="pnpm"?"pnpm-workspace.yaml":"bunfig.toml";s.warn(`${G("⚠")} minimumReleaseAge mismatch: vis config = ${String(r.minimumReleaseAge)} min, ${i} = ${String(l)} min. Consider keeping them in sync.`)}const b=je(e),K=a["include-internal"],Q=a.peer,M=Fe(e,t,{depFields:r.depFields,dev:a.dev,includeInternal:K,peer:Q,prod:a.prod});if(M.size===0){s.info("No catalogs found.");return}const ke={...r,minimumReleaseAge:f,minimumReleaseAgeExclude:q},E=mt(a,ke,o);let H=0;for(const i of M.values())H+=i.size;const B=!!process.stdout.isTTY&&!fe;let T;const $e=B?(i,d)=>{T?T.rerender($.createElement(ie,{current:i,total:d})):(process.stdout.write(`
8
+ `),T=oe($.createElement(ie,{current:i,total:d}),{interactive:!0,patchConsole:!1}))}:(i,d)=>{s.info(`Checking ${String(i)}/${String(d)} dependencies...`)};B||s.info(`Checking ${String(H)} catalog dependencies...
9
+ `);const L=se("socket")?void 0:_e(n.security?.socket,n.security?.policies?.score?.minimum),{checkedCount:w,failed:y,filteredByTarget:h,ignored:A,outdated:g}=await qe(M,E,b,$e,e,L,n.security?.acceptedRisks);T&&(T.clear(),T.unmount());const O=K?{ignored:[],outdated:[]}:Be(e,{depFields:r.depFields,dev:a.dev,exclude:E.exclude,ignore:E.ignore,include:E.include,packageMode:E.packageMode,peer:Q,prod:a.prod,target:E.target});if(O.outdated.length>0){const i=new Set(g.map(d=>`${d.catalogName}|${d.packageName}`));for(const d of O.outdated)i.has(`${d.catalogName}|${d.packageName}`)||g.push(d)}if(O.ignored.length>0)for(const i of O.ignored)A.includes(i)||A.push(i);const ee=w-g.length-y.length;if(y.length>0&&s.warn(`Failed to fetch: ${y.join(", ")}`),A.length>0&&s.info(`Skipped ${String(A.length)} ignored package${A.length===1?"":"s"}: ${A.join(", ")}`),!B&&w>g.length){const i=[...M.values()].reduce((F,Y)=>F+Y.size,0),d=i>w?` (${String(i)} catalog entries, ${String(i-w)} duplicates)`:"";s.info(`Checked ${String(w)} unique packages${d}: ${String(g.length)} outdated, ${String(ee)} up-to-date${y.length>0?`, ${String(y.length)} failed`:""}${h.length>0?`, ${String(h.length)} skipped by target`:""}`)}if(g.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(i=>` ${i.packageName} ${i.currentRange} → ${i.newRange} (${i.updateType})`).join(`
12
+ `)}`):s.info("All catalog dependencies are up to date.");return}const U=a.format??r.format??"table";let R;if(a.ai){const i=Ye(a.aiType??"impact");R=await ze(g,s,n.ai,i)}const V=!!a.dryRun;if(B&&U==="table"){const i=new et(g,R??null);let d;if(a.changelog){s.info("Fetching changelogs...");const c=await me(g,void 0,b);d=new Map;for(const v of c){const C=v.releaseUrl??v.repoUrl??v.npmUrl;C&&d.set(v.packageName,C)}}const F=n.tui?.autoExit??!1,Y=F===!0?3:typeof F=="number"?F:0,te=await oe($.createElement(tt,{autoExitSeconds:Y,changelogUrls:d,checkedCount:w,filteredOutEntries:h,isDryRun:V,store:i,totalCatalogEntries:H}),{alternateScreen:!0,exitOnCtrlC:!1,interactive:!0,patchConsole:!0}).waitUntilExit(),z=process.stdout.columns||80;process.stdout.write(`
13
+ `);for(const c of g){const v=c.vulnerabilities?.length||c.socketReport&&c.socketReport.alerts.length>0,C=!!c.acceptedRisk,J=v?C?"✓":"⚠":"✓",ye=C?"gray":c.updateType==="major"?"red":c.updateType==="minor"?"yellow":"green",P=c.socketReport?.score.overall,be=P===void 0?"":` [${String(Math.round(P*100))}%]`,ne=P===void 0?void 0:Le(P);process.stdout.write(`${X($.createElement(S,null," ",$.createElement(S,{color:ye},J),` ${c.packageName} ${c.currentRange} → ${c.newRange}`,$.createElement(S,{dimColor:!0},` ${c.updateType}`),ne?$.createElement(S,{color:ne},be):null),{columns:z})}
14
+ `)}if(process.stdout.write(`
15
+ `),s.info(ge(g,L?.minimumScore)),w>g.length){const c=[...M.values()].reduce((C,J)=>C+J.size,0),v=c>w?` (${String(c)} catalog entries, ${String(c-w)} duplicates)`:"";s.info(` Checked ${String(w)} unique packages${v}: ${String(ee)} up-to-date${y.length>0?`, ${String(y.length)} failed`:""}`)}if(h.length>0){process.stdout.write(`
16
+ `);const c=`${String(h.length)} package${h.length===1?"":"s"} skipped by target constraint (use --target latest to include):`;process.stdout.write(`${X($.createElement(S,{color:"yellow"},` ${c}`),{columns:z})}
17
+ `);for(const v of h)process.stdout.write(`${X($.createElement(S,null," ",$.createElement(S,{dimColor:!0},v.packageName),` ${v.currentRange} → ${v.newRange}`,$.createElement(S,{dimColor:!0},` ${v.updateType}`)),{columns:z})}
18
+ `)}const Z=Array.isArray(te)?te:[];if(Z.length>0&&!V){s.info(`
19
+ Applying ${String(Z.length)} updates...
20
+ `);const c={...a,install:a.install??r.install};await ue(e,t,Z,c,s,b,n.editorconfig??!0)}return}if(V){if(U==="json"){const i={failed:y,filteredByTarget:h,ignored:A,outdated:g};R&&(i.aiAnalysis=R),process.stdout.write(`${JSON.stringify(i,void 0,2)}
21
+ `)}else s.info(`Would update ${String(g.length)} dependencies:
22
+ `),ce(g,y,U,s,L?.minimumScore),R&&(s.info(""),s.info(re(R))),le(h,s);return}R&&U!=="json"&&(s.info(re(R)),s.info(""));let j=g;if(a.interactive&&(j=await Oe(g),j.length===0)){s.info("No updates selected.");return}s.info(`Updating ${String(j.length)} catalog dependencies...
23
+ `),ce(j,[],U,s,L?.minimumScore),le(h,s);const we={...a,install:a.install??r.install};await ue(e,t,j,we,s,b)},"executeCatalogUpdate"),ht=k((e,t,n,a,o,s)=>{const r={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:m,warnings:u}=ut(t,n,r);for(const l of u)s.warn(l);const p=`${m.bin} ${m.args.join(" ")}`.trim();if(a.dryRun){s.info(`Would run: ${p}`);return}s.info(`Running: ${p}`);try{pe(m.bin,m.args,{cwd:e,env:process.env,stdio:"inherit"})}catch(l){const f=l.status??1;s.error(`
24
+ ${he("✖")} Update failed (exit code ${String(f)})`),s.error(` Command: ${p}`),s.error(` Directory: ${e}
25
+ `),process.exitCode=f}},"executePmWrapper"),vt=k(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&&!fe))return n.error(`${he("✖")} 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=Ce({input:process.stdin,output:process.stdout});try{const s=(await new Promise(r=>{o.question(`${G("⚠")} About to upgrade ALL dependencies to their latest versions. This may include breaking changes.
26
+ Continue? [y/N] `,r)})).trim().toLowerCase();return s==="y"||s==="yes"?!0:(n.info("Aborted."),!1)}finally{o.close()}},"requireBlanketUpdateConfirmation"),Mt=k(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 r=o,{packageManager:m}=Pe(r);if(n.typosquatCheck!==!1){if(s.length>0){const u=s.map(f=>nt(f)),p=a?.security?.typosquatAllowlist,l=await Ke(u.map(f=>f.name),p);if(!l.ok){process.exitCode=1;return}s=u.map((f,q)=>{const b=l.packages[q];return b!==f.name?f.versionSpec?`${b}@${f.versionSpec}`:b??"":s[q]??""})}else if(!await Qe(r,a?.security?.typosquatAllowlist)){process.exitCode=1;return}}if(n.rollback){if(!Ie(r,m)){t.info("No backup found. Run 'vis update' first to create a backup.");return}if(De(r,m))t.info("Restored from backup.");else throw new Error("Failed to restore from backup.");return}if(s.length>0&&n.marshallCheck!==!1){const u=await Ze(s);if(u.length>0){const p=await Je(u,{config:a?.security?.marshalls,workspaceRoot:r});if(!await Xe(p)){process.exitCode=1;return}}}if(await vt(n,s.length>0,t))if(n.catalog!==!1&&We(r,m))await ft(r,m,a??{},n,s,t);else{const u=Ge(r,{configBackend:a?.install?.backend,configCorepack:a?.install?.corepack}),p=u.name==="aube"?"":He(u.name);ht(r,u.name,p,n,s,t)}},"execute");export{Mt as default,Nt as formatMinutesAsTimeString,pt as parseNpmReleaseAgeValue,ve as parseTimeStringToMinutes,gt as readPmNativeMinimumReleaseAge,vt as requireBlanketUpdateConfirmation};
@@ -0,0 +1,3 @@
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};
@@ -0,0 +1,7 @@
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};
@@ -0,0 +1,22 @@
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}
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
+ `)}for(;;){const n=await M(t,`
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.")}
5
+ `)}},"selectOne"),_e=v(async(t,e,r,s)=>{process.stderr.write(` ${e} ${f("(comma-separated numbers)")}
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
+ `)}for(;;){const n=await M(t,`
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(`
11
+ `),l.notice("Next steps:");for(const o of s.suggestions)process.stderr.write(` ${f("•")} ${o}
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
+ `)}},"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")}
14
+
15
+ `);for(const[s,n]of t.entries()){const i=b(T(` ${String(s+1)}.`));process.stderr.write(`${i} ${n.name} ${f(`(${n.source})`)}
16
+ `)}return new Promise((s,n)=>{r.question(`
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
+ `);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
+ `);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};