@visulima/vis 6.1.4 → 6.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (136) hide show
  1. package/CHANGELOG.md +17 -0
  2. package/dist/bin.js +1 -1
  3. package/dist/binx.js +1 -1
  4. package/dist/packem_chunks/bloom-sync.js +1 -1
  5. package/dist/packem_chunks/catalog2.js +1 -1
  6. package/dist/packem_chunks/cli-exec.js +1 -1
  7. package/dist/packem_chunks/cli-main.js +13 -13
  8. package/dist/packem_chunks/context.js +4 -4
  9. package/dist/packem_chunks/fix.js +1 -1
  10. package/dist/packem_chunks/git.js +2 -2
  11. package/dist/packem_chunks/handler10.js +1 -1
  12. package/dist/packem_chunks/handler12.js +1 -1
  13. package/dist/packem_chunks/handler13.js +1 -1
  14. package/dist/packem_chunks/handler14.js +1 -1
  15. package/dist/packem_chunks/handler15.js +1 -1
  16. package/dist/packem_chunks/handler19.js +1 -1
  17. package/dist/packem_chunks/handler2.js +1 -1
  18. package/dist/packem_chunks/handler20.js +1 -1
  19. package/dist/packem_chunks/handler21.js +1 -1
  20. package/dist/packem_chunks/handler23.js +1 -1
  21. package/dist/packem_chunks/handler24.js +1 -1
  22. package/dist/packem_chunks/handler25.js +1 -1
  23. package/dist/packem_chunks/handler26.js +1 -1
  24. package/dist/packem_chunks/handler28.js +1 -1
  25. package/dist/packem_chunks/handler3.js +1 -1
  26. package/dist/packem_chunks/handler32.js +1 -1
  27. package/dist/packem_chunks/handler33.js +1 -1
  28. package/dist/packem_chunks/handler4.js +1 -1
  29. package/dist/packem_chunks/handler40.js +1 -1
  30. package/dist/packem_chunks/handler46.js +1 -1
  31. package/dist/packem_chunks/handler5.js +1 -1
  32. package/dist/packem_chunks/handler50.js +1 -1
  33. package/dist/packem_chunks/handler51.js +1 -1
  34. package/dist/packem_chunks/handler52.js +1 -1
  35. package/dist/packem_chunks/handler54.js +1 -1
  36. package/dist/packem_chunks/handler55.js +1 -1
  37. package/dist/packem_chunks/handler56.js +3 -3
  38. package/dist/packem_chunks/handler58.js +1 -1
  39. package/dist/packem_chunks/handler59.js +1 -1
  40. package/dist/packem_chunks/handler6.js +1 -1
  41. package/dist/packem_chunks/handler60.js +1 -1
  42. package/dist/packem_chunks/handler61.js +1 -1
  43. package/dist/packem_chunks/handler62.js +1 -1
  44. package/dist/packem_chunks/handler63.js +1 -1
  45. package/dist/packem_chunks/handler64.js +1 -1
  46. package/dist/packem_chunks/handler65.js +1 -1
  47. package/dist/packem_chunks/handler66.js +1 -1
  48. package/dist/packem_chunks/handler67.js +1 -1
  49. package/dist/packem_chunks/handler68.js +1 -1
  50. package/dist/packem_chunks/handler69.js +1 -1
  51. package/dist/packem_chunks/handler7.js +1 -1
  52. package/dist/packem_chunks/handler70.js +1 -1
  53. package/dist/packem_chunks/handler71.js +1 -1
  54. package/dist/packem_chunks/handler72.js +1 -1
  55. package/dist/packem_chunks/handler73.js +1 -1
  56. package/dist/packem_chunks/handler74.js +1 -1
  57. package/dist/packem_chunks/handler75.js +1 -1
  58. package/dist/packem_chunks/handler76.js +1 -1
  59. package/dist/packem_chunks/handler77.js +1 -1
  60. package/dist/packem_chunks/handler78.js +1 -1
  61. package/dist/packem_chunks/handler79.js +1 -1
  62. package/dist/packem_chunks/handler8.js +1 -1
  63. package/dist/packem_chunks/heal.js +1 -1
  64. package/dist/packem_chunks/help-command.js +1 -1
  65. package/dist/packem_chunks/index7.js +1 -1
  66. package/dist/packem_chunks/keys-refresh.js +1 -1
  67. package/dist/packem_chunks/list.js +1 -1
  68. package/dist/packem_chunks/prune.js +1 -1
  69. package/dist/packem_chunks/status.js +1 -1
  70. package/dist/packem_chunks/sync.js +1 -1
  71. package/dist/packem_chunks/sync2.js +1 -1
  72. package/dist/packem_chunks/tripwire.js +1 -1
  73. package/dist/packem_chunks/verify-lockfile.js +1 -1
  74. package/dist/packem_chunks/version-resolver.js +8 -3
  75. package/dist/packem_shared/ReleaseClient-B4xWga1q.js +1 -0
  76. package/dist/packem_shared/{advisories-DHGJ6XhP.js → advisories-3ZfSV0LH.js} +1 -1
  77. package/dist/packem_shared/{affected-selection-DCT4CLex.js → affected-selection-BkHUfErA.js} +1 -1
  78. package/dist/packem_shared/{ai-analysis-CO4rT3Nd.js → ai-analysis-CbjIaasa.js} +1 -1
  79. package/dist/packem_shared/{ai-cache-Dkb6me20.js → ai-cache-VYBlfP7G.js} +1 -1
  80. package/dist/packem_shared/{ai-fix-C0OBhGDq.js → ai-fix-_ZbH_K45.js} +1 -1
  81. package/dist/packem_shared/{bin-DwACrJUJ.js → bin-KU_2tR-G.js} +1 -1
  82. package/dist/packem_shared/{build-scripts-BeMIA-_q.js → build-scripts-DtqsovcF.js} +1 -1
  83. package/dist/packem_shared/{dependency-scan-D8e370_h.js → dependency-scan-BUs_kdX-.js} +1 -1
  84. package/dist/packem_shared/{detect-C-9o_BPB.js → detect-DSMoIgaH.js} +1 -1
  85. package/dist/packem_shared/{docker-vRDm2lHX.js → docker-52xcbz7D.js} +1 -1
  86. package/dist/packem_shared/{ecosystem-gate-DpO43yAS.js → ecosystem-gate-Fu5__-JA.js} +1 -1
  87. package/dist/packem_shared/{env-BymuoTL8.js → env-CJVZRP-o.js} +1 -1
  88. package/dist/packem_shared/{env-consistency-BDfAa56d.js → env-consistency-cqaZf4xr.js} +1 -1
  89. package/dist/packem_shared/{failure-log-BslhfaEO.js → failure-log-Ba31iSwN.js} +1 -1
  90. package/dist/packem_shared/glob-Cyk1H9ZL-COXzOVwd.js +1 -0
  91. package/dist/packem_shared/{index-Doab17tq.js → index-0YpDONiz.js} +1 -1
  92. package/dist/packem_shared/{index-Cwxbl_pY.js → index-_FIeiL52.js} +1 -1
  93. package/dist/packem_shared/{lifecycle-Gy7mqMGg.js → lifecycle-BUKDvgHs.js} +1 -1
  94. package/dist/packem_shared/{manifests-kE5OweNT.js → manifests-p1zhN8pD.js} +1 -1
  95. package/dist/packem_shared/{min-release-age-yvuPbJ8G.js → min-release-age-D782Z1Yw.js} +1 -1
  96. package/dist/packem_shared/{missing-package-json-CEEPXqYi.js → missing-package-json-BoK5DGmG.js} +1 -1
  97. package/dist/packem_shared/{multi-eco-lockfiles-D5tM7pkg.js → multi-eco-lockfiles-OaHbR4J9.js} +1 -1
  98. package/dist/packem_shared/{native-config-sync-DDGt3vvd.js → native-config-sync-pyH7zbC_.js} +1 -1
  99. package/dist/packem_shared/{osv-4kFhXIoW.js → osv-Cc5Ay6Oh.js} +1 -1
  100. package/dist/packem_shared/{package-version-x7sPg2TM.js → package-version-B-FGASyU.js} +1 -1
  101. package/dist/packem_shared/{packument-Dg8cIDYR.js → packument-q5JfSrU7.js} +1 -1
  102. package/dist/packem_shared/{project-name-filter-B3tKt-Pf.js → project-name-filter-DP4RCrn3.js} +1 -1
  103. package/dist/packem_shared/{provenance-BG5mu0H_.js → provenance-DqvqDJn5.js} +1 -1
  104. package/dist/packem_shared/publish-missing-Hnqkjxov.js +35 -0
  105. package/dist/packem_shared/{registry-CndByNx9.js → registry-acz8_sxm.js} +1 -1
  106. package/dist/packem_shared/{registry-keys-CE-RZlp_.js → registry-keys-BEhcTEZZ.js} +1 -1
  107. package/dist/packem_shared/{renderToString-DR0zDUjh-DeiCwydO.js → renderToString-DR0zDUjh-CWJW0Ktb.js} +1 -1
  108. package/dist/packem_shared/{resolve-explicit-Cge6eKPt.js → resolve-explicit-DlvpbFfx.js} +1 -1
  109. package/dist/packem_shared/run-QPhRQBU4.js +6 -0
  110. package/dist/packem_shared/{run-summary-utils-DbyeUM6f.js → run-summary-utils-BiTJspOl.js} +1 -1
  111. package/dist/packem_shared/{runtime-check-Dw0q3X67.js → runtime-check-DaFcciiJ.js} +1 -1
  112. package/dist/packem_shared/{s1ngularity-BOl0c716.js → s1ngularity-CZT2Pgbl.js} +1 -1
  113. package/dist/packem_shared/{scaffold-files-B8zMyMvq.js → scaffold-files-CkXH8tRQ.js} +1 -1
  114. package/dist/packem_shared/{scan-progress-CY3XIDOY.js → scan-progress-Dd0DYpfJ.js} +1 -1
  115. package/dist/packem_shared/{selectors-BB0yaWyK.js → selectors-DGWSSXWM.js} +1 -1
  116. package/dist/packem_shared/{signatures-r1SeDHLL.js → signatures-DBVHek52.js} +1 -1
  117. package/dist/packem_shared/{spinner-B_rRdoro.js → spinner-BjxtOJJc.js} +1 -1
  118. package/dist/packem_shared/{table-bu4cV-it.js → table-c5KdYeRx.js} +1 -1
  119. package/dist/packem_shared/{tabs-A2EUpTHt.js → tabs-D81GPdC_.js} +1 -1
  120. package/dist/packem_shared/{toolchain-Bt93i37e.js → toolchain-D8qgs8sr.js} +1 -1
  121. package/dist/packem_shared/{typosquats-BbebOgKM.js → typosquats-BxBeFNUo.js} +1 -1
  122. package/dist/packem_shared/{use-measured-height-CwhybDI9.js → use-measured-height-D7d36UUm.js} +1 -1
  123. package/dist/packem_shared/{vis-update-app-PjJWvxqF.js → vis-update-app-C_wcaC7g.js} +1 -1
  124. package/dist/packem_shared/{vis-user-error-BivZDkQD.js → vis-user-error-B73F9C2Z.js} +1 -1
  125. package/dist/packem_shared/{watch-loop-dWYGUQwi.js → watch-loop-BeyVtDyD.js} +1 -1
  126. package/dist/release/index.d.ts +13 -0
  127. package/dist/release/index.js +1 -1
  128. package/dist/release/types.d.ts +6 -0
  129. package/index.js +26 -26
  130. package/package.json +9 -9
  131. package/schemas/vis-config.schema.json +1 -1
  132. package/schemas/vis-release-config.schema.json +1 -1
  133. package/dist/packem_shared/ReleaseClient-CRuCHDsT.js +0 -1
  134. package/dist/packem_shared/glob-Cyk1H9ZL-6yDyaJwk.js +0 -1
  135. package/dist/packem_shared/publish-DkgvB2Lk.js +0 -34
  136. package/dist/packem_shared/run-CKL4VGzQ.js +0 -10
@@ -1,2 +1,2 @@
1
- import{DEFAULT_CHANGES_DIR as F}from"./DEFAULT_CLEAN_KEEP.js";import{b as D,a as b,c as B}from"./context.js";import{createShellRunner as y}from"./shell-runner.js";const T=async({logger:t,options:l,workspaceRoot:w})=>{const a=w??process.cwd(),p=!l.fail,g=l.strict===!0,s=await D({cwd:a}),{printConfigIfRequested:x}=await import("./print-config.js");if(x(l,s,t))return;const{files:o}=await b({changesDir:s.config.changesDir,cwd:a});if(o.length===0){g?(t.error("No change files present and --strict is set."),t.error(`Run \`vis release add\` to author one in ${s.config.changesDir??F}.`),process.exitCode=p?0:1):(t.warn("No change files present. PR will not produce a release."),process.exitCode=0);return}if(!g){t.info(`${o.length} change file(s) present. ✓`),process.exitCode=0;return}const m=s.config.baseBranch??"main",d=await y().run("git",["diff","--name-only",`${m}...HEAD`],{cwd:a,silent:!0});if(d.exitCode!==0){t.warn(`Could not run git diff vs ${m}: ${d.stderr}`),process.exitCode=0;return}const h=d.stdout.split(`
1
+ import{DEFAULT_CHANGES_DIR as F}from"./DEFAULT_CLEAN_KEEP.js";import{b as D,r as b,c as B}from"./context.js";import{createShellRunner as y}from"./shell-runner.js";const T=async({logger:t,options:l,workspaceRoot:w})=>{const a=w??process.cwd(),p=!l.fail,g=l.strict===!0,s=await D({cwd:a}),{printConfigIfRequested:x}=await import("./print-config.js");if(x(l,s,t))return;const{files:o}=await b({changesDir:s.config.changesDir,cwd:a});if(o.length===0){g?(t.error("No change files present and --strict is set."),t.error(`Run \`vis release add\` to author one in ${s.config.changesDir??F}.`),process.exitCode=p?0:1):(t.warn("No change files present. PR will not produce a release."),process.exitCode=0);return}if(!g){t.info(`${o.length} change file(s) present. ✓`),process.exitCode=0;return}const m=s.config.baseBranch??"main",d=await y().run("git",["diff","--name-only",`${m}...HEAD`],{cwd:a,silent:!0});if(d.exitCode!==0){t.warn(`Could not run git diff vs ${m}: ${d.stderr}`),process.exitCode=0;return}const h=d.stdout.split(`
2
2
  `).map(e=>e.trim()).filter(Boolean);if(h.length===0){t.info("No source files changed. ✓"),process.exitCode=0;return}const{default:P}=await import("./index.js"),$=s.config.changedFilePatterns??["**"],v=(e,n,f)=>{if(!e.startsWith(`${n}/`))return!1;const k=e.slice(n.length+1);return f.some(u=>P(u,k))},C=new Set(B(o).keys()),c=new Set;for(const e of h){const n=s.packages.find(i=>{const r=i.dir.startsWith(a)?i.dir.slice(a.length).replace(/^[/\\]/,""):i.dir;return e===`${r}/package.json`||e.startsWith(`${r}/`)});for(const i of s.packages){const r=s.perPackageConfig.get(i.name)?.additionalPaths;!r||r.length===0||r.some(R=>P(R,e))&&!C.has(i.name)&&c.add(i.name)}if(!n)continue;const f=n.dir.startsWith(a)?n.dir.slice(a.length).replace(/^[/\\]/,""):n.dir,u=s.perPackageConfig.get(n.name)?.changedFilePatterns??$;!(e===`${f}/package.json`)&&!v(e,f,u)||C.has(n.name)||c.add(n.name)}if(c.size>0){t.error("The following packages have changes but no covering change file:");for(const e of c)t.error(` - ${e}`);t.error("Run `vis release add` to author one."),process.exitCode=p?0:1;return}t.info(`${o.length} change file(s); ${h.length} changed file(s) all covered. ✓`),process.exitCode=0};export{T as default};
@@ -1,4 +1,4 @@
1
- import{O as R}from"./cli-main.js";import{v as x,r as V,f as N}from"../packem_shared/ai-analysis-CO4rT3Nd.js";import{p as $,g as T,e as M,a as C,f as O}from"../packem_shared/registry-CndByNx9.js";import{readCatalogs as S,fetchPackageVersions as j}from"./catalog2.js";import{f as z}from"../packem_shared/osv-4kFhXIoW.js";const F=/^[\^~>=<]+/,B=async({argument:E,logger:s,options:i,visConfig:c,workspaceRoot:l})=>{if(!l)throw new Error("Could not determine workspace root. Run this command inside a monorepo.");const p=E,e=p[0];if(!e)throw new Error("Package name is required. Usage: vis analyze <package> [version]");const u=p[1],{packageManager:A}=R(l);let r,m="default";const b=S(l,A);for(const[t,h]of b){const n=h.get(e);if(n){r=n,m=t;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(u)a=u;else{s.info(`Fetching latest version for ${e}...
1
+ import{O as R}from"./cli-main.js";import{v as x,r as V,f as N}from"../packem_shared/ai-analysis-CbjIaasa.js";import{p as $,g as T,e as M,a as C,f as O}from"../packem_shared/registry-acz8_sxm.js";import{readCatalogs as S,fetchPackageVersions as j}from"./catalog2.js";import{f as z}from"../packem_shared/osv-Cc5Ay6Oh.js";const F=/^[\^~>=<]+/,B=async({argument:E,logger:s,options:i,visConfig:c,workspaceRoot:l})=>{if(!l)throw new Error("Could not determine workspace root. Run this command inside a monorepo.");const p=E,e=p[0];if(!e)throw new Error("Package name is required. Usage: vis analyze <package> [version]");const u=p[1],{packageManager:A}=R(l);let r,m="default";const b=S(l,A);for(const[t,h]of b){const n=h.get(e);if(n){r=n,m=t;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(u)a=u;else{s.info(`Fetching latest version for ${e}...
2
2
  `);const t=await j(e);if(!t.latest)throw new Error(`Could not determine latest version for "${e}".`);a=t.latest}const d=$(r),g=$(a);if(!d||!g)throw new Error(`Could not parse versions: current="${r}", target="${a}".`);const y=T(d,g);if(y==="none"){s.info(`${e} is already at ${a}. Nothing to analyze.`);return}const P=M(r),f={catalogName:m,currentRange:r,newRange:`${P}${a}`,packageName:e,targetVersion:a,updateType:y},w=x(i.aiType??"impact");if(w==="security"||i.security){s.info(`Checking for known vulnerabilities...
3
3
  `);const t=r.replace(F,""),n=(await z([{name:e,version:t}])).get(e);n&&n.length>0&&(f.vulnerabilities=n);const v=C(c?.security,{minimumScore:c?.security?.policies?.score?.minimum});if(v.length>0){const o=(await O(v,[{name:e,version:t}])).get(`${e}@${t}`);o&&(f.socketReport={alerts:o.alerts,license:o.license,score:o.score})}}const k=await V([f],s,c?.ai,w);(i.format??"table")==="json"?process.stdout.write(`${JSON.stringify(k,void 0,2)}
4
4
  `):s.info(N(k))};export{B as default};
@@ -1 +1 @@
1
- import{createRequire as l}from"node:module";import{r as w}from"../packem_shared/run-CKL4VGzQ.js";import{createShellRunner as y}from"./shell-runner.js";import{b as R}from"./context.js";let d;const p=n=>(d??=l(import.meta.url))(n),o=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,m=n=>{if(typeof o<"u"&&o.versions&&o.versions.node){const[e,r]=o.versions.node.split(".").map(Number);if(e>22||e===22&&r>=3||e===20&&r>=16)return o.getBuiltinModule(n)}return p(n)},{relative:_}=m("node:path"),C=async({fs:n,logger:e,options:r,workspaceRoot:c})=>{const a=c??process.cwd(),i=await R({cwd:a,skipRegistryLookup:!0}),{printConfigIfRequested:u}=await import("./print-config.js");if(u(r,i,e))return;const t=await w({allowFullHistory:r.allowFullHistory===!0,config:i.config,cwd:a,dryRun:r.dryRun===!0,from:r.from,fs:n,name:r.name,packages:i.packages,perPackageConfig:i.perPackageConfig,runner:y(),sinceLastRelease:r.sinceLastRelease===!0});for(const s of t.notes)e.info(s);for(const s of t.warnings)e.warn(s);if(t.status==="failed"){e.error(t.error),process.exitCode=1;return}if(t.status!=="no-changes"){if(t.status==="dry-run"){e.info("[dry-run] would write:"),e.info(t.content);return}e.info(`Created ${_(a,t.createdFile)}`);for(const[s,f]of t.bumps)e.info(` ${s}: ${f}`)}};export{C as default};
1
+ import{createRequire as f}from"node:module";import{r as _}from"../packem_shared/run-QPhRQBU4.js";import{createShellRunner as w}from"./shell-runner.js";import{b as y}from"./context.js";let l;const d=s=>(l??=f(import.meta.url))(s),o=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,p=s=>{if(typeof o<"u"&&o.versions&&o.versions.node){const[e,r]=o.versions.node.split(".").map(Number);if(e>22||e===22&&r>=3||e===20&&r>=16)return o.getBuiltinModule(s)}return d(s)},{relative:m}=p("node:path"),b=async({fs:s,logger:e,options:r,workspaceRoot:c})=>{const i=c??process.cwd(),a=await y({cwd:i,skipRegistryLookup:!0}),{printConfigIfRequested:u}=await import("./print-config.js");if(u(r,a,e))return;const t=await _({allowFullHistory:r.allowFullHistory===!0,config:a.config,cwd:i,dryRun:r.dryRun===!0,from:r.from,fs:s,name:r.name,packages:a.packages,perPackageConfig:a.perPackageConfig,runner:w(),sinceLastRelease:r.sinceLastRelease===!0});for(const n of t.notes)e.info(n);for(const n of t.warnings)e.warn(n);if(t.status==="failed"){e.error(t.error),process.exitCode=1;return}if(t.status!=="no-changes"){if(t.status==="dry-run"){e.info("[dry-run] would write:"),e.info(t.content);return}for(const n of t.files)e.info(`Created ${m(i,n.path)} (${n.package}: ${t.bumps.get(n.package)})`)}};export{b as default};
@@ -1 +1 @@
1
- import{VisReleaseError as $}from"../packem_shared/VisReleaseError-DZtgcKf8.js";import{b as m}from"./context.js";import{p as b}from"../packem_shared/publish-DkgvB2Lk.js";const C=async({logger:t,options:n,workspaceRoot:o})=>{const f=o??process.cwd(),r=n.dryRun===!0;let a;try{a=await m({channel:n.channel,cwd:f,firstRelease:n.firstRelease===!0,projects:n.filter?n.filter.split(",").map(e=>e.trim()).filter(Boolean):void 0})}catch(e){t.error(`Failed to load release context: ${e instanceof Error?e.message:String(e)}`),process.exitCode=1;return}const{printConfigIfRequested:c}=await import("./print-config.js");if(c(n,a,t))return;if(n.checkOnly===!0){if(t.info(`Preflight: ${a.plan.releases.length} pending publish(es)${a.channel?` to dist-tag "${a.channel.tag}"`:""}.`),a.plan.warnings.length>0)for(const e of a.plan.warnings)t.warn(` - ${e}`);process.exitCode=a.plan.releases.length===0?1:0;return}if(a.plan.releases.length===0){t.info("No pending releases — nothing to publish.");return}const i=n.tag??a.channel?.tag;i||t.warn("No --tag provided and no channel matched the current branch. Defaulting to dist-tag 'latest'. Set channels in vis.config.ts to control this."),t.info(`${r?"[dry-run] would publish":"Publishing"} ${a.plan.releases.length} package(s) to dist-tag "${i??"latest"}"${r?"":"..."}`);let s;try{s=await b(a,{dryRun:r,noPush:!n.push,otp:n.otp,resume:n.resume===!0,tag:i})}catch(e){if(e instanceof $&&e.code==="STAGE_PENDING"){t.error(e.message),e.hint&&(t.info(""),t.info(`Next steps: ${e.hint}`)),process.exitCode=1;return}t.error(`Publish failed: ${e instanceof Error?e.message:String(e)}`),process.exitCode=1;return}t.info("");for(const e of s.published)t.info(` [published] ${e.name}@${e.version}`);for(const e of s.skipped)e.reason.startsWith("stage-")?t.warn(` [stage] ${e.name} (${e.reason} — re-run \`vis release publish\` once approved)`):t.info(` [skipped] ${e.name} (${e.reason})`);for(const e of s.failed)t.error(` [failed] ${e.name}: ${e.reason}`);t.info(""),t.info(`Published: ${s.published.length} | Skipped: ${s.skipped.length} | Failed: ${s.failed.length}`),s.tags.length>0&&t.info(`Tags created: ${s.tags.length}${s.tagsPushed?" (pushed)":" (NOT pushed — re-run with --resume to retry)"}`),s.failed.length===0?process.exitCode=0:s.published.length===0&&s.skipped.length===0?process.exitCode=3:process.exitCode=2;const l=s.failed.filter(e=>/\bEOTP\b|one[- ]time password|otp/i.test(e.reason));if(l.length>0){t.info(""),t.warn("Publish failed because the registry required a 2FA OTP. Rerun with:");const e=l.map(p=>p.name).join(","),h=n.channel?` --channel=${n.channel}`:"",d=n.tag?` --tag=${n.tag}`:"",u=` --filter='${e}'`;t.info(` vis release publish --otp=REPLACE_WITH_NEW_OTP --resume${d}${h}${u}`)}};export{C as default};
1
+ import{VisReleaseError as b}from"../packem_shared/VisReleaseError-DZtgcKf8.js";import{b as w}from"./context.js";import{p as x,a as g}from"../packem_shared/publish-missing-Hnqkjxov.js";const k=async({logger:t,options:s,workspaceRoot:d})=>{const u=d??process.cwd(),a=s.dryRun===!0,l=s.missing===!0,f=s.filter?s.filter.split(",").map(e=>e.trim()).filter(Boolean):void 0;if(l&&(s.checkOnly===!0||s.firstRelease===!0)){t.error(`--missing cannot be combined with ${s.checkOnly===!0?"--check-only":"--first-release"}.`),process.exitCode=1;return}let i;try{i=await w({channel:s.channel,cwd:u,firstRelease:s.firstRelease===!0,projects:f})}catch(e){t.error(`Failed to load release context: ${e instanceof Error?e.message:String(e)}`),process.exitCode=1;return}const{printConfigIfRequested:p}=await import("./print-config.js");if(p(s,i,t))return;if(s.checkOnly===!0){if(t.info(`Preflight: ${i.plan.releases.length} pending publish(es)${i.channel?` to dist-tag "${i.channel.tag}"`:""}.`),i.plan.warnings.length>0)for(const e of i.plan.warnings)t.warn(` - ${e}`);process.exitCode=i.plan.releases.length===0?1:0;return}if(!l&&i.plan.releases.length===0){t.info("No pending releases — nothing to publish.");return}const o=s.tag??i.channel?.tag;o||t.warn("No --tag provided and no channel matched the current branch. Defaulting to dist-tag 'latest'. Set channels in vis.config.ts to control this."),l?t.info(`Looking for released versions that never reached dist-tag "${o??"latest"}"...`):t.info(`${a?"[dry-run] would publish":"Publishing"} ${i.plan.releases.length} package(s) to dist-tag "${o??"latest"}"${a?"":"..."}`);let n;try{const e={dryRun:a,noPush:!s.push,otp:s.otp,resume:s.resume===!0,tag:o};if(l){n=await x(i,{...e,projects:f});for(const r of n.missing){const c=r.onRegistry?"tag":"publish";t.info(` [missing] ${r.name}@${r.version} (${a?`would ${c}`:c}, release commit ${r.commit.slice(0,7)})`)}n.missing.length===0&&t.info("No released-but-unpublished versions found.")}else n=await g(i,e)}catch(e){if(e instanceof b&&e.code==="STAGE_PENDING"){t.error(e.message),e.hint&&(t.info(""),t.info(`Next steps: ${e.hint}`)),process.exitCode=1;return}t.error(`Publish failed: ${e instanceof Error?e.message:String(e)}`),process.exitCode=1;return}t.info("");for(const e of n.published)t.info(` [published] ${e.name}@${e.version}`);for(const e of n.skipped)e.reason.startsWith("stage-")?t.warn(` [stage] ${e.name} (${e.reason} — re-run \`vis release publish\` once approved)`):t.info(` [skipped] ${e.name} (${e.reason})`);for(const e of n.failed)t.error(` [failed] ${e.name}: ${e.reason}`);t.info(""),t.info(`Published: ${n.published.length} | Skipped: ${n.skipped.length} | Failed: ${n.failed.length}`),n.tags.length>0&&t.info(`Tags created: ${n.tags.length}${n.tagsPushed?" (pushed)":" (NOT pushed — re-run with --resume to retry)"}`),n.failed.length===0?process.exitCode=0:n.published.length===0&&n.skipped.length===0?process.exitCode=3:process.exitCode=2;const h=n.failed.filter(e=>/\bEOTP\b|one[- ]time password|otp/i.test(e.reason));if(h.length>0){t.info(""),t.warn("Publish failed because the registry required a 2FA OTP. Rerun with:");const e=h.map($=>$.name).join(","),r=s.channel?` --channel=${s.channel}`:"",c=s.tag?` --tag=${s.tag}`:"",m=` --filter='${e}'`;t.info(` vis release publish --otp=REPLACE_WITH_NEW_OTP --resume${c}${r}${m}`)}};export{k as default};
@@ -1,4 +1,4 @@
1
- import{createRequire as $}from"node:module";import{O as j}from"../packem_shared/renderToString-DR0zDUjh-DeiCwydO.js";import{q as E}from"../packem_shared/table-bu4cV-it.js";import{R as I}from"../packem_shared/registry-CndByNx9.js";import{d as P}from"../packem_shared/pm-runner-Dboj-wZG.js";import{l as C}from"../packem_shared/dependency-scan-D8e370_h.js";import{r as T}from"../packem_shared/provenance-BG5mu0H_.js";import{r as D}from"../packem_shared/signatures-r1SeDHLL.js";import{loadOptionalSigstore as R}from"./loader.js";let y;const O=r=>(y??=$(import.meta.url))(r),m=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,_=r=>{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(r)}return O(r)},{createHash:N}=_("node:crypto"),{isAbsolute:k,resolve:S,basename:v}=_("node:path"),q=r=>(r??"").split(",").map(t=>t.trim()).filter(t=>t.length>0),V=async({logger:r,options:t,workspaceRoot:s})=>{if(!s)throw new Error("Could not determine workspace root. Run this command inside a monorepo.");const n=t.format??"table",c=t.prodOnly??!1,u=t.failOn==="error"?"error":"warning",d=q(t.allowlist),a=P(s),l=C(s,a.name,{includeDev:!c}).map(({name:e,version:o})=>({name:e,version:o})),[f,p]=await Promise.all([T(l,{allowlist:d,workspaceRoot:s}),D(l,{allowlist:d,workspaceRoot:s})]),i=[...f.map(e=>({code:"provenance-regression",message:`Resolved ${e.packageName}@${e.version} has no published provenance attestation, but ${e.packageName}@${e.priorVersionWithProvenance} did — a provenance regression.`,packageName:e.packageName,severity:"warning",version:e.version})),...p.map(e=>({code:e.code,message:e.message,packageName:e.packageName,severity:e.severity,version:e.version}))],g=i.filter(e=>u==="error"?e.severity==="error":!0);if(n==="json")process.stdout.write(`${JSON.stringify({findings:i,ok:g.length===0},void 0,2)}
1
+ import{createRequire as $}from"node:module";import{O as j}from"../packem_shared/renderToString-DR0zDUjh-CWJW0Ktb.js";import{q as E}from"../packem_shared/table-c5KdYeRx.js";import{R as I}from"../packem_shared/registry-acz8_sxm.js";import{d as P}from"../packem_shared/pm-runner-Dboj-wZG.js";import{l as C}from"../packem_shared/dependency-scan-BUs_kdX-.js";import{r as T}from"../packem_shared/provenance-DqvqDJn5.js";import{r as D}from"../packem_shared/signatures-DBVHek52.js";import{loadOptionalSigstore as R}from"./loader.js";let y;const O=r=>(y??=$(import.meta.url))(r),m=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,_=r=>{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(r)}return O(r)},{createHash:N}=_("node:crypto"),{isAbsolute:k,resolve:S,basename:v}=_("node:path"),q=r=>(r??"").split(",").map(t=>t.trim()).filter(t=>t.length>0),V=async({logger:r,options:t,workspaceRoot:s})=>{if(!s)throw new Error("Could not determine workspace root. Run this command inside a monorepo.");const n=t.format??"table",c=t.prodOnly??!1,u=t.failOn==="error"?"error":"warning",d=q(t.allowlist),a=P(s),l=C(s,a.name,{includeDev:!c}).map(({name:e,version:o})=>({name:e,version:o})),[f,p]=await Promise.all([T(l,{allowlist:d,workspaceRoot:s}),D(l,{allowlist:d,workspaceRoot:s})]),i=[...f.map(e=>({code:"provenance-regression",message:`Resolved ${e.packageName}@${e.version} has no published provenance attestation, but ${e.packageName}@${e.priorVersionWithProvenance} did — a provenance regression.`,packageName:e.packageName,severity:"warning",version:e.version})),...p.map(e=>({code:e.code,message:e.message,packageName:e.packageName,severity:e.severity,version:e.version}))],g=i.filter(e=>u==="error"?e.severity==="error":!0);if(n==="json")process.stdout.write(`${JSON.stringify({findings:i,ok:g.length===0},void 0,2)}
2
2
  `);else if(n==="ndjson")for(const e of i)process.stdout.write(`${JSON.stringify(e)}
3
3
  `);else if(i.length===0)r.info(`No provenance regressions or signature problems across ${String(l.length)} locked packages.`);else{const e=process.stdout.columns||80;r.info(j(I.createElement(E,{data:i.map(o=>({code:o.code,package:`${o.packageName}@${o.version}`,severity:o.severity}))}),{columns:e}));for(const o of i)r.warn(`${o.packageName}@${o.version}: ${o.message}`)}g.length>0&&(process.exitCode=1)},x=()=>process.env.CI==="true"||typeof process.env.ACTIONS_ID_TOKEN_REQUEST_URL=="string"||typeof process.env.SIGSTORE_ID_TOKEN=="string",J=(r,t,s)=>({_type:"https://in-toto.io/Statement/v1",predicate:{buildDefinition:{buildType:"https://visulima.com/vis/attest/v1",externalParameters:{workspaceRoot:s},internalParameters:{},resolvedDependencies:[]},runDetails:{builder:{id:"https://visulima.com/vis"},metadata:{invocationId:process.env.GITHUB_RUN_ID??"",startedOn:new Date().toISOString()}}},predicateType:"https://slsa.dev/provenance/v1",subject:[{digest:{sha256:t},name:r}]}),Q=async({argument:r,fs:t,logger:s,options:n,workspaceRoot:c})=>{if(!c)throw new Error("Could not determine workspace root. Run this command inside a monorepo.");const u=r[0];if(!u)throw new Error("Missing subject. Usage: vis attest <path-to-artifact>");const d=n.predicate??"slsaProvenance";if(d!=="slsaProvenance")throw new Error(`Unsupported predicate '${d}'. Only 'slsaProvenance' is supported.`);const a=k(u)?u:S(c,u),w=n.requireSigning??!1,l=n.format??"table";let f;try{f=await t.readFile(a)}catch{throw new Error(`Cannot read subject artifact at ${a}.`)}const p=N("sha256").update(f).digest("hex");if(!x()){const b="No ambient OIDC token (not running in CI). Keyless signing needs a Fulcio identity from CI OIDC.";if(w)throw new Error(`${b} Re-run in CI or drop --require-signing.`);if(l==="json"){process.stdout.write(`${JSON.stringify({ok:!1,reason:"no-ambient-oidc",sha256:p,skipped:!0,subject:v(a)},void 0,2)}
4
4
  `);return}s.warn(`${b} Skipping signing (subject sha256: ${p}). Pass --require-signing to make this fatal.`);return}const i=J(v(a),p,c),g=Buffer.from(JSON.stringify(i)),o=await(await R({workspaceRoot:c})).attest(g,"application/vnd.in-toto+json"),h=n.output?k(n.output)?n.output:S(c,n.output):`${a}.sigstore`;if(await t.writeFile(h,`${JSON.stringify(o,void 0,2)}
@@ -1,4 +1,4 @@
1
- import{c as $,a as l,D as d,T as y}from"../packem_shared/ai-analysis-CO4rT3Nd.js";import{O as g}from"../packem_shared/renderToString-DR0zDUjh-DeiCwydO.js";import{q as x}from"../packem_shared/table-bu4cV-it.js";import{R as S}from"../packem_shared/registry-CndByNx9.js";import{j as w,F as u,q as E,J as I,b as A}from"../packem_shared/index.server-Ca_EEVfw.js";const p={command:"ai",description:"AI-assisted commands: provider detection, cache management, and failure-fix proposals."},D=e=>{if(typeof e!="function")return String(e);const{name:t}=e;return t==="Boolean"?"boolean":t==="Number"?"number":t==="String"?"string":t??"unknown"},O=e=>e===void 0?[]:Array.isArray(e)?e.map(t=>[t.name,t]):Object.entries(e),R=e=>{const t=[...e.commandPath??[],e.name].join(" "),s=(e.examples??[]).map(([n,a])=>({command:n??"",description:a??""})),o=O(e.options).map(([n,a])=>({defaultValue:a.defaultValue,description:a.description,name:n,type:D(a.type)}));return{argument:e.argument?{description:e.argument.description,name:e.argument.name}:void 0,description:e.description??"",examples:s,name:e.name,options:o,path:t}},f=(e,t=p)=>({command:t.command,description:t.description,subcommands:e.map(s=>R(s))}),P=(e,t=p)=>`${JSON.stringify(f(e,t),void 0,2)}
1
+ import{c as $,a as l,D as d,T as y}from"../packem_shared/ai-analysis-CbjIaasa.js";import{O as g}from"../packem_shared/renderToString-DR0zDUjh-CWJW0Ktb.js";import{q as x}from"../packem_shared/table-c5KdYeRx.js";import{R as S}from"../packem_shared/registry-acz8_sxm.js";import{j as w,F as u,q as E,J as I,b as A}from"../packem_shared/index.server-Ca_EEVfw.js";const p={command:"ai",description:"AI-assisted commands: provider detection, cache management, and failure-fix proposals."},D=e=>{if(typeof e!="function")return String(e);const{name:t}=e;return t==="Boolean"?"boolean":t==="Number"?"number":t==="String"?"string":t??"unknown"},O=e=>e===void 0?[]:Array.isArray(e)?e.map(t=>[t.name,t]):Object.entries(e),R=e=>{const t=[...e.commandPath??[],e.name].join(" "),s=(e.examples??[]).map(([n,a])=>({command:n??"",description:a??""})),o=O(e.options).map(([n,a])=>({defaultValue:a.defaultValue,description:a.description,name:n,type:D(a.type)}));return{argument:e.argument?{description:e.argument.description,name:e.argument.name}:void 0,description:e.description??"",examples:s,name:e.name,options:o,path:t}},f=(e,t=p)=>({command:t.command,description:t.description,subcommands:e.map(s=>R(s))}),P=(e,t=p)=>`${JSON.stringify(f(e,t),void 0,2)}
2
2
  `,T=(e,t=p)=>{const s=f(e,t),o=[w(`vis ${s.command} — ${s.description}`),"",u("Subcommands:")];for(const n of s.subcommands){const a=n.argument?` ${E(`<${n.argument.name}>`)}`:"";if(o.push(""),o.push(` ${I(`vis ${n.path}`)}${a}`),n.description&&o.push(` ${n.description}`),n.options.length>0){const i=n.options.map(c=>`--${c.name}${c.type==="boolean"?"":`=<${c.type}>`}`).join(", ");o.push(u(` options: ${i}`))}if(n.examples.length>0){o.push(u(" examples:"));for(const i of n.examples){const c=i.description?u(` — ${i.description}`):"";o.push(` ${A(i.command)}${c}`)}}}return o.push(""),o.push(u(`Run \`vis ${s.command} discover-help\` for the machine-readable JSON catalogue (designed for AI agents).`)),o.push(u(`Run \`vis ${s.command} <subcommand> --help\` for full usage of a specific subcommand.`)),`${o.join(`
3
3
  `)}
4
4
  `},h=async()=>{const{default:e}=await import("./cli-main.js").then(t=>t.ao);return e.filter(t=>t.name!=="ai")},M=async()=>{const e=await h();process.stderr.write(T(e))},q=async()=>{const e=await h();process.stdout.write(P(e))},L=async({logger:e,visConfig:t})=>{const s=t?.ai,o=l(s);if(!o){e.error("No AI provider available to test."),process.exitCode=1;return}e.info(`Testing ${o.name}...`);try{const n=await y(o,"Reply with exactly: OK",{timeoutMs:3e4});e.info(`Provider ${o.name} responded: ${n.stdout.trim().slice(0,200)}`)}catch(n){const a=n instanceof Error?n.message:String(n);e.error(`Provider ${o.name} failed: ${a}`),process.exitCode=1}},V=({logger:e,options:t,visConfig:s})=>{const o=t.format??"table",n=s?.ai,a=$(),i=l(n);if(o==="json"){const r=a.map(m=>({available:m.available,method:m.detectionMethod,name:m.name,path:m.path,priority:d[m.name]??0,selected:m.name===i?.name,version:m.version}));process.stdout.write(`${JSON.stringify(r,void 0,2)}
@@ -1,4 +1,4 @@
1
- import{createRequire as B}from"node:module";import{z as E}from"../packem_shared/index-0dnGN3GP.js";import{findVisConfigFile as D}from"./CONFIG_FILES.js";import{y as V}from"../packem_shared/isAccessibleSync-DYKTrrvc-CBsMZhj-.js";import{U as w}from"../packem_shared/env-BymuoTL8.js";import{p as e}from"./cli-main.js";import{d as C}from"../packem_shared/pm-runner-Dboj-wZG.js";import{a as F}from"../packem_shared/build-scripts-BeMIA-_q.js";import{s as O}from"../packem_shared/native-config-sync-DDGt3vvd.js";let N;const M=c=>(N??=B(import.meta.url))(c),$=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,T=c=>{if(typeof $<"u"&&$.versions&&$.versions.node){const[t,s]=$.versions.node.split(".").map(Number);if(t>22||t===22&&s>=3||t===20&&s>=16)return $.getBuiltinModule(c)}return M(c)},{spawnSync:A}=T("node:child_process"),P=/(defineConfig\s*\(\s*\{)/,q=/(export\s+default\s+\{)/,y=(c,t)=>`${t}${JSON.stringify(c)}: true,`,z=(c,t)=>{if(t.length===0)return{added:[],skipped:[],status:"noop"};const s=D(c);if(!s)return{added:[],skipped:t,status:"no-config"};if(!V(s))return{added:[],skipped:t,status:"no-config"};const n=E(s),h=n.search(/installScripts\s*:\s*\{/);let l=null,r=0;if(h!==-1){const a=n.slice(h),d=/(allow\s*:\s*\{)([^}]*)(\})/.exec(a);d?.index!==void 0&&(l=d,r=h+d.index)}if(l){const a=l[2]??"",f=new Set;for(const g of a.matchAll(/["']([^"']+)["']\s*:/g))f.add(g[1]);for(const g of a.matchAll(/(?:^|,|\{)\s*([a-z_$][\w-]*)\s*:/gi))f.add(g[1]);const d=[],k=[];for(const g of t)f.has(g)?k.push(g):d.push(g);if(d.length===0)return{added:[],configPath:s,skipped:k,status:"noop"};const x=/\n([ \t]+)\S/.exec(a)?.[1]??" ",_=`
1
+ import{createRequire as B}from"node:module";import{z as E}from"../packem_shared/index-0dnGN3GP.js";import{findVisConfigFile as D}from"./CONFIG_FILES.js";import{y as V}from"../packem_shared/isAccessibleSync-DYKTrrvc-CBsMZhj-.js";import{U as w}from"../packem_shared/env-CJVZRP-o.js";import{p as e}from"./cli-main.js";import{d as C}from"../packem_shared/pm-runner-Dboj-wZG.js";import{a as F}from"../packem_shared/build-scripts-DtqsovcF.js";import{s as O}from"../packem_shared/native-config-sync-pyH7zbC_.js";let N;const M=c=>(N??=B(import.meta.url))(c),$=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,T=c=>{if(typeof $<"u"&&$.versions&&$.versions.node){const[t,s]=$.versions.node.split(".").map(Number);if(t>22||t===22&&s>=3||t===20&&s>=16)return $.getBuiltinModule(c)}return M(c)},{spawnSync:A}=T("node:child_process"),P=/(defineConfig\s*\(\s*\{)/,q=/(export\s+default\s+\{)/,y=(c,t)=>`${t}${JSON.stringify(c)}: true,`,z=(c,t)=>{if(t.length===0)return{added:[],skipped:[],status:"noop"};const s=D(c);if(!s)return{added:[],skipped:t,status:"no-config"};if(!V(s))return{added:[],skipped:t,status:"no-config"};const n=E(s),h=n.search(/installScripts\s*:\s*\{/);let l=null,r=0;if(h!==-1){const a=n.slice(h),d=/(allow\s*:\s*\{)([^}]*)(\})/.exec(a);d?.index!==void 0&&(l=d,r=h+d.index)}if(l){const a=l[2]??"",f=new Set;for(const g of a.matchAll(/["']([^"']+)["']\s*:/g))f.add(g[1]);for(const g of a.matchAll(/(?:^|,|\{)\s*([a-z_$][\w-]*)\s*:/gi))f.add(g[1]);const d=[],k=[];for(const g of t)f.has(g)?k.push(g):d.push(g);if(d.length===0)return{added:[],configPath:s,skipped:k,status:"noop"};const x=/\n([ \t]+)\S/.exec(a)?.[1]??" ",_=`
2
2
  ${d.map(g=>y(g,x)).join(`
3
3
  `)}`,v=a.replace(/\s+$/,""),S=a.slice(v.length),R=`${v}${v.endsWith(",")||v===""?"":","}${_}${S.length>0?S:`
4
4
  `}`,j=`${n.slice(0,r)}${l[1]}${R}${l[3]}${n.slice(r+l[0].length)}`;return w(s,j),{added:d,configPath:s,skipped:k,status:"updated"}}const i=/(installScripts\s*:\s*\{)/;if(i.test(n)){const a=`
@@ -1,3 +1,3 @@
1
- import{createRequire as M}from"node:module";import{getAffectedProjects as H}from"@visulima/task-runner";import{d as D,b as N}from"../packem_shared/registry-CndByNx9.js";let C;const T=e=>(C??=M(import.meta.url))(e),g=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,P=e=>{if(typeof g<"u"&&g.versions&&g.versions.node){const[t,r]=g.versions.node.split(".").map(Number);if(t>22||t===22&&r>=3||t===20&&r>=16)return g.getBuiltinModule(e)}return T(e)},{execFile:G}=P("node:child_process"),{promisify:V}=P("node:util"),B=V(G),q=["[skip ci]","[ci skip]","[no ci]","[vis skip]","[nx skip]"],J=["[vis deploy]","[nx deploy]"],K=["vis","nx"],L=["CACHED_COMMIT_REF","VERCEL_GIT_PREVIOUS_SHA","GITHUB_BASE_REF","CI_COMMIT_BEFORE_SHA"],U=/^[\w./~^@{}][\w.\-/~^@{}]*$/,W=(e=process.env)=>{for(const t of L){const r=e[t];if(r&&r.trim().length>0)return r.trim()}},S=e=>{if(!U.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.`)},Z=async(e,t)=>{try{return await B("git",["rev-parse","--verify",`${t}^{commit}`],{cwd:e}),!0}catch{return!1}},z=async e=>{try{const{stdout:t}=await B("git",["log","-1","--pretty=%B"],{cwd:e});return t}catch{return""}},O=(e,t,r)=>K.some(i=>e.includes(`[${i} ${t} ${r}]`)),X=(e,t)=>q.some(r=>e.includes(r))||O(e,"skip",t),Q=(e,t)=>J.some(r=>e.includes(r))||O(e,"deploy",t),f=(e,t,r,i)=>({action:"build",message:r,project:e,reason:t,...i}),y=(e,t,r,i)=>({action:"skip",message:r,project:e,reason:t,...i}),Y=e=>`${e.action==="skip"?"🛑":"✅"} ${e.message}`,ee=(e,t)=>e.action==="skip"||t?0:1,k=new Set(["deep","direct","none"]),ne=async({argument:e,logger:t,options:r,visConfig:i,workspaceRoot:l})=>{const s=e[0]??"",E=!!r.json,A=!!r.verbose,R=!!(r["exit-zero-on-build"]??r.exitZeroOnBuild),u=n=>{A&&!E&&t.info(`❱ ${n}`)},o=n=>{E?process.stdout.write(`${JSON.stringify(n)}
1
+ import{createRequire as M}from"node:module";import{getAffectedProjects as H}from"@visulima/task-runner";import{d as D,b as N}from"../packem_shared/registry-acz8_sxm.js";let C;const T=e=>(C??=M(import.meta.url))(e),g=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,P=e=>{if(typeof g<"u"&&g.versions&&g.versions.node){const[t,r]=g.versions.node.split(".").map(Number);if(t>22||t===22&&r>=3||t===20&&r>=16)return g.getBuiltinModule(e)}return T(e)},{execFile:G}=P("node:child_process"),{promisify:V}=P("node:util"),B=V(G),q=["[skip ci]","[ci skip]","[no ci]","[vis skip]","[nx skip]"],J=["[vis deploy]","[nx deploy]"],K=["vis","nx"],L=["CACHED_COMMIT_REF","VERCEL_GIT_PREVIOUS_SHA","GITHUB_BASE_REF","CI_COMMIT_BEFORE_SHA"],U=/^[\w./~^@{}][\w.\-/~^@{}]*$/,W=(e=process.env)=>{for(const t of L){const r=e[t];if(r&&r.trim().length>0)return r.trim()}},S=e=>{if(!U.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.`)},Z=async(e,t)=>{try{return await B("git",["rev-parse","--verify",`${t}^{commit}`],{cwd:e}),!0}catch{return!1}},z=async e=>{try{const{stdout:t}=await B("git",["log","-1","--pretty=%B"],{cwd:e});return t}catch{return""}},O=(e,t,r)=>K.some(i=>e.includes(`[${i} ${t} ${r}]`)),X=(e,t)=>q.some(r=>e.includes(r))||O(e,"skip",t),Q=(e,t)=>J.some(r=>e.includes(r))||O(e,"deploy",t),f=(e,t,r,i)=>({action:"build",message:r,project:e,reason:t,...i}),y=(e,t,r,i)=>({action:"skip",message:r,project:e,reason:t,...i}),Y=e=>`${e.action==="skip"?"🛑":"✅"} ${e.message}`,ee=(e,t)=>e.action==="skip"||t?0:1,k=new Set(["deep","direct","none"]),ne=async({argument:e,logger:t,options:r,visConfig:i,workspaceRoot:l})=>{const s=e[0]??"",E=!!r.json,A=!!r.verbose,R=!!(r["exit-zero-on-build"]??r.exitZeroOnBuild),u=n=>{A&&!E&&t.info(`❱ ${n}`)},o=n=>{E?process.stdout.write(`${JSON.stringify(n)}
2
2
  `):t.info(Y(n)),process.exit(ee(n,R))};if(!s)return o(f("","missing-project-argument","Missing project argument. Usage: vis ci ignore <project>"));if(!l)return o(f(s,"workspace-error","Could not determine workspace root — building defensively"));const m=await z(l),_=m.trim().split(`
3
3
  `)[0]??"";if(u(`commit: ${_}`),m&&Q(m,s))return o(f(s,"commit-force-deploy",`Force-deploy keyword in commit: "${_}"`));if(m&&X(m,s))return o(y(s,"commit-skip",`Skip keyword in commit: "${_}"`));let h,v,w;try{({fileOwners:w,packageJsons:v,workspace:h}=D(l,i))}catch(n){const a=n instanceof Error?n.message:String(n);return o(f(s,"workspace-error",`Workspace discovery failed (${a}) — building defensively`))}if(!Object.hasOwn(h.projects,s))return o(f(s,"project-unknown",`Project "${s}" not found in workspace — building defensively`));try{const n=r.base?.trim(),a=W();let c=n||a||"HEAD~1";const p=r.head?.trim()||"HEAD";S(c),S(p),u(`resolved base ref: ${c} (source: ${n?"flag":a?"ci-env":"default"})`);const x=Z(l,c),F=N(l,h,v);await x||(u(`base ref ${c} not reachable — falling back to HEAD~1`),c="HEAD~1"),u(`comparing ${c}...${p}`);const b=r.downstream??"deep",j=r.upstream??"none";if(!k.has(b))throw new Error(`Invalid --downstream value: "${b}". Must be "none", "direct", or "deep".`);if(!k.has(j))throw new Error(`Invalid --upstream value: "${j}". Must be "none", "direct", or "deep".`);const I={base:c,downstream:b,fileOwners:w,head:p,ignoredFiles:i?.affectedIgnore,projectGraph:F,projects:h.projects,upstream:j,workspaceRoot:l},d=await H(I);u(`changed files: ${d.changedFiles.length}`),u(`affected projects: ${d.affectedProjects.join(", ")||"(none)"}`);const $={base:c,head:p};return d.changedFiles.length===0?o(y(s,"no-changes",`No files changed between ${c}...${p}`,{...$,affectedProjects:[]})):d.affectedProjects.includes(s)?o(f(s,"project-affected",`Build ${s}: affected by ${d.changedFiles.length} changed file(s)`,{...$,affectedProjects:d.affectedProjects})):o(y(s,"project-not-affected",`Skip ${s}: not affected by changes between ${c}...${p}`,{...$,affectedProjects:d.affectedProjects}))}catch(n){const a=n instanceof Error?n.message:String(n);return t.error(`Affected detection failed: ${a}`),o(f(s,"workspace-error",`Affected detection failed (${a}) — building defensively`))}};export{ne as default};
@@ -1,4 +1,4 @@
1
- import{F as p}from"../packem_shared/index.server-Ca_EEVfw.js";import{e as l,z as k}from"../packem_shared/index-0dnGN3GP.js";import{a as y,b as h,f as w}from"../packem_shared/subtree-DtmcKAJK.js";import{n as u}from"../packem_shared/utils-DQFHJn72.js";import{l as $,i as x,q as m}from"../packem_shared/registry-CndByNx9.js";import{y as A}from"../packem_shared/isAccessibleSync-DYKTrrvc-CBsMZhj-.js";import{U as b}from"../packem_shared/env-BymuoTL8.js";import{p as E}from"../packem_shared/package-version-x7sPg2TM.js";const P=["aube-workspace.yaml","pnpm-workspace.yaml"],v=/^\s*packages\s*:\s*$/,I=/^(\s*)-\s/,j=(c,i)=>{const s=c.includes(`\r
1
+ import{F as p}from"../packem_shared/index.server-Ca_EEVfw.js";import{e as l,z as k}from"../packem_shared/index-0dnGN3GP.js";import{a as y,b as h,f as w}from"../packem_shared/subtree-DtmcKAJK.js";import{n as u}from"../packem_shared/utils-DQFHJn72.js";import{l as $,i as x,q as m}from"../packem_shared/registry-acz8_sxm.js";import{y as A}from"../packem_shared/isAccessibleSync-DYKTrrvc-CBsMZhj-.js";import{U as b}from"../packem_shared/env-CJVZRP-o.js";import{p as E}from"../packem_shared/package-version-B-FGASyU.js";const P=["aube-workspace.yaml","pnpm-workspace.yaml"],v=/^\s*packages\s*:\s*$/,I=/^(\s*)-\s/,j=(c,i)=>{const s=c.includes(`\r
2
2
  `)?`\r
3
3
  `:`
4
4
  `,e=c.split(/\r?\n/),n=e.findIndex(r=>v.test(r));if(n===-1)return;let t=" ";for(let r=n+1;r<e.length;r++){const o=I.exec(e[r]);if(o){t=o[1];break}if(e[r].trim().length>0)break}return e.splice(n+1,0,`${t}- "${i}"`),e.join(s)},q=(c,i,s)=>{const e=l(c,"package.json");let n;try{n=E(e)}catch{return!1}const{workspaces:t}=n;return Array.isArray(t)?t.includes(i)?!1:(s||m(e,{...n,workspaces:[...t,i]},{detectIndent:!0}),!0):t&&typeof t=="object"&&Array.isArray(t.packages)?t.packages.includes(i)?!1:(s||m(e,{...n,workspaces:{...t,packages:[...t.packages,i]}},{detectIndent:!0}),!0):!1},M=({dryRun:c=!1,prefix:i,workspaceRoot:s})=>{const e=u(i),n=$(s);if(!n)return{status:"no-config"};if(x(s,n).some(r=>u(r)===e))return{status:"already-covered"};for(const r of P){const o=l(s,r);if(!A(o))continue;const a=j(k(o),e);if(a!==void 0)return c||b(o,a),{entry:e,file:r,status:"added"}}return q(s,e,c)?{entry:e,file:"package.json",status:"added"}:{status:"no-config"}},N=async({argument:c,fs:i,logger:s,options:e,process:n,workspaceRoot:t})=>{const r=c[0];if(!r)throw new Error("Missing <source>. Pass a git repository URL or local path to import.");if(!e.prefix)throw new Error("Missing --prefix <dir>. Pass the target directory in the monorepo (e.g. packages/tooling/foo).");const o=t??n.cwd,a=u(e.prefix),d=e.ref??"HEAD";if(y(o),await(async f=>{try{return await i.access(f),!0}catch{return!1}})(l(o,a)))throw new Error(`Target "${a}" already exists. git subtree add requires a non-existent prefix.`);if(e.dryRun){const f=e.squash?" --squash":"",g=e.message?` -m "${e.message}"`:"";s.info("Dry run — no changes will be made. Planned steps:"),s.info(` git subtree add --prefix=${a}${f}${g} ${r} ${d}`),e.register&&s.info(` register ${a} into the workspace config (skipped if already covered by an existing glob)`);return}if(h(o),s.info(`Importing ${p(r)}@${d} → ${a} ...`),w({cwd:o,message:e.message,prefix:a,ref:d,repo:r,squash:e.squash}),s.info(`✓ Imported ${r} into ${a} (history preserved).`),e.register){const f=M({prefix:a,workspaceRoot:o});f.status==="already-covered"?s.info(`✓ ${a} is already covered by an existing workspace glob.`):f.status==="added"?s.info(`✓ Registered ${f.entry} in ${f.file}.`):s.warn(`Could not auto-register ${a}: no workspace config found. Add it to pnpm-workspace.yaml or package.json#workspaces manually.`)}else s.info(p(`Skipped workspace registration (--no-register). Add ${a} to your workspace config manually.`));s.info(p("Note: project.json / nx tags are not generated. Add them if your tooling needs them."))};export{N as default};
@@ -1 +1 @@
1
- import{a as I}from"../packem_shared/index-0dnGN3GP.js";import{d as O}from"../packem_shared/registry-CndByNx9.js";import{f as D,a as x}from"../packem_shared/selectors-BB0yaWyK.js";import E from"./index.js";import{l as J}from"./cli-main.js";const S=(e,t)=>{for(const l of t)if(E(l,e))return!0;return!1},q=(e,t={})=>{const{depTypes:l,excludePatterns:f,externalOnly:h,includePatterns:m,internalOnly:g}=t;if(g&&h)return[];const d=l&&l.length>0?new Set(l):void 0,k=m&&m.length>0?m:void 0,w=f&&f.length>0?f:void 0,N=[];for(const y of e)g&&!y.isInternal||h&&y.isInternal||d&&!d.has(y.depType)||k&&(!y.packageName||!S(y.packageName,k))||w&&y.packageName&&S(y.packageName,w)||N.push(y);return N},C=new Set(["json","ndjson","table"]),M=e=>{if(e===void 0)return"table";const t=e.toLowerCase();if(!C.has(t))throw new Error(`--format must be one of: table, json, ndjson (got "${e}")`);return t},P=(e,t)=>({depName:e.depName,depType:e.depType,isInternal:e.isInternal,packageDir:e.packageDir,packageJsonPath:I(t,e.packageJsonPath),packageName:e.packageName,specifier:e.specifier}),$=new Set(["dependencies","devDependencies","optionalDependencies","overrides","peerDependencies","pnpm.overrides","resolutions"]),A=e=>{if(!e||e.length===0)return;const t=[],l=[];for(const f of e)for(const h of f.split(",")){const m=h.trim();m&&($.has(m)?t.push(m):l.push(m))}if(l.length>0)throw new Error(`Unknown --dep-type value(s): ${l.join(", ")}. Valid: ${[...$].join(", ")}`);return t.length>0?t:void 0},V=async({logger:e,options:t,visConfig:l,workspaceRoot:f})=>{if(!f)throw new Error("Could not determine workspace root.");const h=M(t.json&&t.format===void 0?"json":t.format);if(t.deps){if(t.internalOnly&&t.externalOnly)throw new Error("--internal-only and --external-only are mutually exclusive");const p=A(t.depType),c=J(f);let r=q(c,{depTypes:p,excludePatterns:t.exclude,externalOnly:t.externalOnly,includePatterns:t.include,internalOnly:t.internalOnly});if(t.query||t.tag&&t.tag.length>0){const{workspace:n}=O(f,l),i=D(Object.keys(n.projects),n,t.query),T=new Set(x(i,n,t.tag));r=r.filter(v=>v.packageName!==void 0&&T.has(v.packageName))}const u=[...r].sort((n,i)=>{const T=`${n.packageName??n.packageDir} ${n.depType} ${n.depName}`,v=`${i.packageName??i.packageDir} ${i.depType} ${i.depName}`;return T.localeCompare(v)});if(h==="ndjson"){for(const n of u)e.info(JSON.stringify(P(n,f)));return}if(h==="json"){const n=u.map(i=>P(i,f));e.info(JSON.stringify(n,null,t.pretty?2:void 0));return}if(u.length===0){e.info("No matching dep-instances.");return}const o=["Package","Block","Dep","Specifier","Internal","Path"],a=u.map(n=>[n.packageName??n.packageDir,n.depType,n.depName,n.specifier,n.isInternal?"yes":"no",I(f,n.packageJsonPath)]),s=o.map((n,i)=>Math.max(n.length,...a.map(T=>(T[i]??"").length))),j=(n,i)=>n.padEnd(i);e.info(o.map((n,i)=>j(n,s[i])).join(" ")),e.info(s.map(n=>"─".repeat(n)).join("──"));for(const n of a)e.info(n.map((i,T)=>j(i,s[T])).join(" "));e.info(""),e.info(`${String(u.length)} dep-instance(s)`);return}if(h==="ndjson")throw new Error("--format=ndjson is only supported with --deps");const{projectOptions:m,workspace:g}=O(f,l);let d=Object.keys(g.projects).sort();if(t.query&&(d=D(d,g,t.query)),d=x(d,g,t.tag),d.length===0){e.info("No projects found.");return}const k=t.inferred,w=t.targets||k;if(h==="json"){const p=d.map(c=>{const r=g.projects[c],u=m.get(c)??{},o=Object.entries(r.targets??{}).map(([a])=>{const s=u[a],j=s?.inferred===!0;return{aliases:s?.aliases??[],command:s?.command,description:s?.description,...j?{inferred:!0}:{},name:a,type:s?.type}}).filter(a=>!k||a.inferred===!0);return{language:r.language,layer:r.layer,name:c,root:r.root,stack:r.stack,tags:r.tags??[],targets:o,type:r.projectType??"library"}});e.info(JSON.stringify(p,null,2));return}const N=(p,c)=>{const r=p.map((o,a)=>{let s=0;for(const j of c)s=Math.max(s,(j[a]??"").length);return Math.max(o.length,s)}),u=(o,a)=>o.padEnd(a);e.info(p.map((o,a)=>u(o,r[a])).join(" ")),e.info(r.map(o=>"─".repeat(o)).join("──"));for(const o of c)e.info(o.map((a,s)=>u(a,r[s])).join(" "))};if(w){const p=[];for(const c of d){const r=g.projects[c],u=m.get(c)??{};for(const o of Object.keys(r.targets??{}).sort()){const a=u[o],s=a?.inferred===!0;if(k&&!s)continue;const j=r.targets?.[o],n=j?.cache===!1?"no":j?.cache===!0?"yes":"default";p.push([c,o,a?.type??"—",n,s?"yes":"no",a?.description??"—"])}}if(p.length===0){e.info(k?"No inferred targets found.":"No targets found.");return}N(["Project","Target","Type","Cache","Inferred","Description"],p),e.info(""),e.info(`${String(p.length)} target(s) across ${String(d.length)} project(s)`);return}const y=["Project","Type","Layer","Tags","Targets"],b=d.map(p=>{const c=g.projects[p],r=Object.keys(c.targets??{});return[p,c.projectType??"library",c.layer??"—",(c.tags??[]).join(", ")||"—",r.length>4?`${r.slice(0,4).join(", ")}… (${String(r.length)})`:r.join(", ")||"—"]});N(y,b),e.info(""),e.info(`${String(d.length)} project(s)`)};export{V as default};
1
+ import{a as I}from"../packem_shared/index-0dnGN3GP.js";import{d as O}from"../packem_shared/registry-acz8_sxm.js";import{f as D,a as x}from"../packem_shared/selectors-DGWSSXWM.js";import E from"./index.js";import{l as J}from"./cli-main.js";const S=(e,t)=>{for(const l of t)if(E(l,e))return!0;return!1},q=(e,t={})=>{const{depTypes:l,excludePatterns:f,externalOnly:h,includePatterns:m,internalOnly:g}=t;if(g&&h)return[];const d=l&&l.length>0?new Set(l):void 0,k=m&&m.length>0?m:void 0,w=f&&f.length>0?f:void 0,N=[];for(const y of e)g&&!y.isInternal||h&&y.isInternal||d&&!d.has(y.depType)||k&&(!y.packageName||!S(y.packageName,k))||w&&y.packageName&&S(y.packageName,w)||N.push(y);return N},C=new Set(["json","ndjson","table"]),M=e=>{if(e===void 0)return"table";const t=e.toLowerCase();if(!C.has(t))throw new Error(`--format must be one of: table, json, ndjson (got "${e}")`);return t},P=(e,t)=>({depName:e.depName,depType:e.depType,isInternal:e.isInternal,packageDir:e.packageDir,packageJsonPath:I(t,e.packageJsonPath),packageName:e.packageName,specifier:e.specifier}),$=new Set(["dependencies","devDependencies","optionalDependencies","overrides","peerDependencies","pnpm.overrides","resolutions"]),A=e=>{if(!e||e.length===0)return;const t=[],l=[];for(const f of e)for(const h of f.split(",")){const m=h.trim();m&&($.has(m)?t.push(m):l.push(m))}if(l.length>0)throw new Error(`Unknown --dep-type value(s): ${l.join(", ")}. Valid: ${[...$].join(", ")}`);return t.length>0?t:void 0},V=async({logger:e,options:t,visConfig:l,workspaceRoot:f})=>{if(!f)throw new Error("Could not determine workspace root.");const h=M(t.json&&t.format===void 0?"json":t.format);if(t.deps){if(t.internalOnly&&t.externalOnly)throw new Error("--internal-only and --external-only are mutually exclusive");const p=A(t.depType),c=J(f);let r=q(c,{depTypes:p,excludePatterns:t.exclude,externalOnly:t.externalOnly,includePatterns:t.include,internalOnly:t.internalOnly});if(t.query||t.tag&&t.tag.length>0){const{workspace:n}=O(f,l),i=D(Object.keys(n.projects),n,t.query),T=new Set(x(i,n,t.tag));r=r.filter(v=>v.packageName!==void 0&&T.has(v.packageName))}const u=[...r].sort((n,i)=>{const T=`${n.packageName??n.packageDir} ${n.depType} ${n.depName}`,v=`${i.packageName??i.packageDir} ${i.depType} ${i.depName}`;return T.localeCompare(v)});if(h==="ndjson"){for(const n of u)e.info(JSON.stringify(P(n,f)));return}if(h==="json"){const n=u.map(i=>P(i,f));e.info(JSON.stringify(n,null,t.pretty?2:void 0));return}if(u.length===0){e.info("No matching dep-instances.");return}const o=["Package","Block","Dep","Specifier","Internal","Path"],a=u.map(n=>[n.packageName??n.packageDir,n.depType,n.depName,n.specifier,n.isInternal?"yes":"no",I(f,n.packageJsonPath)]),s=o.map((n,i)=>Math.max(n.length,...a.map(T=>(T[i]??"").length))),j=(n,i)=>n.padEnd(i);e.info(o.map((n,i)=>j(n,s[i])).join(" ")),e.info(s.map(n=>"─".repeat(n)).join("──"));for(const n of a)e.info(n.map((i,T)=>j(i,s[T])).join(" "));e.info(""),e.info(`${String(u.length)} dep-instance(s)`);return}if(h==="ndjson")throw new Error("--format=ndjson is only supported with --deps");const{projectOptions:m,workspace:g}=O(f,l);let d=Object.keys(g.projects).sort();if(t.query&&(d=D(d,g,t.query)),d=x(d,g,t.tag),d.length===0){e.info("No projects found.");return}const k=t.inferred,w=t.targets||k;if(h==="json"){const p=d.map(c=>{const r=g.projects[c],u=m.get(c)??{},o=Object.entries(r.targets??{}).map(([a])=>{const s=u[a],j=s?.inferred===!0;return{aliases:s?.aliases??[],command:s?.command,description:s?.description,...j?{inferred:!0}:{},name:a,type:s?.type}}).filter(a=>!k||a.inferred===!0);return{language:r.language,layer:r.layer,name:c,root:r.root,stack:r.stack,tags:r.tags??[],targets:o,type:r.projectType??"library"}});e.info(JSON.stringify(p,null,2));return}const N=(p,c)=>{const r=p.map((o,a)=>{let s=0;for(const j of c)s=Math.max(s,(j[a]??"").length);return Math.max(o.length,s)}),u=(o,a)=>o.padEnd(a);e.info(p.map((o,a)=>u(o,r[a])).join(" ")),e.info(r.map(o=>"─".repeat(o)).join("──"));for(const o of c)e.info(o.map((a,s)=>u(a,r[s])).join(" "))};if(w){const p=[];for(const c of d){const r=g.projects[c],u=m.get(c)??{};for(const o of Object.keys(r.targets??{}).sort()){const a=u[o],s=a?.inferred===!0;if(k&&!s)continue;const j=r.targets?.[o],n=j?.cache===!1?"no":j?.cache===!0?"yes":"default";p.push([c,o,a?.type??"—",n,s?"yes":"no",a?.description??"—"])}}if(p.length===0){e.info(k?"No inferred targets found.":"No targets found.");return}N(["Project","Target","Type","Cache","Inferred","Description"],p),e.info(""),e.info(`${String(p.length)} target(s) across ${String(d.length)} project(s)`);return}const y=["Project","Type","Layer","Tags","Targets"],b=d.map(p=>{const c=g.projects[p],r=Object.keys(c.targets??{});return[p,c.projectType??"library",c.layer??"—",(c.tags??[]).join(", ")||"—",r.length>4?`${r.slice(0,4).join(", ")}… (${String(r.length)})`:r.join(", ")||"—"]});N(y,b),e.info(""),e.info(`${String(d.length)} project(s)`)};export{V as default};
@@ -1,12 +1,12 @@
1
- import{createRequire as I}from"node:module";import{DEFAULT_CHANGES_DIR as T}from"./DEFAULT_CLEAN_KEEP.js";import{b as _,a as q}from"./context.js";import{r as V}from"../packem_shared/run-CKL4VGzQ.js";import{toRepoRelativePath as k,listUncommittedPaths as H,getShortSha as U,getCurrentBranch as K,pushBranch as F,stageAndCommit as W}from"./git.js";import{createShellRunner as B}from"./shell-runner.js";import{stateFilePath as z}from"./state.js";import{d as J}from"../packem_shared/sticky-comment-DjhyCIZt.js";import{VisReleaseError as S}from"../packem_shared/VisReleaseError-DZtgcKf8.js";import{a as E}from"../packem_shared/apply-DoeQAAGm.js";import{p as A}from"../packem_shared/publish-DkgvB2Lk.js";let M;const O=r=>(M??=I(import.meta.url))(r),$=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,L=r=>{if(typeof $<"u"&&$.versions&&$.versions.node){const[e,s]=$.versions.node.split(".").map(Number);if(e>22||e===22&&s>=3||e===20&&s>=16)return $.getBuiltinModule(r)}return O(r)},{join:G}=L("node:path"),Q="<!-- vis:user-content -->",X="<!-- /vis:user-content -->",Y=/<!-- vis:user-content -->([\s\S]*?)<!-- \/vis:user-content -->/g,Z=/<!-- vis:user-content -->(?:(?!<!-- \/vis:user-content -->)[\s\S])*?<!-- vis:user-content -->/,ee=r=>`${Q}${r}${X}`,te=(r,e)=>{const s=[],c=/<!-- vis:user-content -->\s*<!-- \/vis:user-content -->/g;let n=c.exec(r);for(;n!==null;)s.push({end:n.index+n[0].length,start:n.index}),n=c.exec(r);if(s.length===0)return{body:r,remaining:e};let i=0;const t=[],u=Math.min(s.length,e.length);for(let d=0;d<u;d+=1){const h=s[d],l=e[d];t.push(r.slice(i,h.start)),t.push(l),i=h.end}return t.push(r.slice(i)),{body:t.join(""),remaining:e.slice(u)}},ne=(r,e)=>{if(r===void 0||r==="")return e;const s=r.replaceAll(/```[\s\S]*?```/g,"").replaceAll(/~~~[\s\S]*?~~~/g,""),c=(s.match(/<!-- vis:user-content -->/g)??[]).length,n=(s.match(/<!-- \/vis:user-content -->/g)??[]).length;if(c!==n)throw new S({code:"CONFIG_INVALID",hint:"Fix the marker pairs in the PR body and re-run.",message:`PR body has unbalanced <!-- vis:user-content --> markers (${c} opens, ${n} closes). Refusing to merge to prevent silent edit loss.`});if(Z.test(s))throw new S({code:"CONFIG_INVALID",hint:"Flatten the nesting in the PR body and re-run.",message:"Nested <!-- vis:user-content --> markers are not allowed in PR body. The merger refuses to operate to prevent silent edit loss."});const i=[];for(const l of r.matchAll(Y)){const g=l[1]??"";g.trim()!==""&&i.push(ee(g))}if(i.length===0)return e;const{body:t,remaining:u}=te(e,i);if(u.length===0)return t;const d=t.replace(/\s+$/u,""),h=u.join(`
1
+ import{createRequire as O}from"node:module";import{DEFAULT_CHANGES_DIR as V}from"./DEFAULT_CLEAN_KEEP.js";import{b as y,r as H}from"./context.js";import{r as U}from"../packem_shared/run-QPhRQBU4.js";import{toRepoRelativePath as E,listUncommittedPaths as K,getShortSha as W,getCurrentBranch as z,pushBranch as F,stageAndCommit as B}from"./git.js";import{createShellRunner as J}from"./shell-runner.js";import{stateFilePath as Q}from"./state.js";import{d as X}from"../packem_shared/sticky-comment-DjhyCIZt.js";import{VisReleaseError as j}from"../packem_shared/VisReleaseError-DZtgcKf8.js";import{p as Y,a as A}from"../packem_shared/publish-missing-Hnqkjxov.js";import{a as N}from"../packem_shared/apply-DoeQAAGm.js";let L;const G=i=>(L??=O(import.meta.url))(i),P=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,T=i=>{if(typeof P<"u"&&P.versions&&P.versions.node){const[e,n]=P.versions.node.split(".").map(Number);if(e>22||e===22&&n>=3||e===20&&n>=16)return P.getBuiltinModule(i)}return G(i)},{join:q}=T("node:path"),Z="<!-- vis:user-content -->",ee="<!-- /vis:user-content -->",te=/<!-- vis:user-content -->([\s\S]*?)<!-- \/vis:user-content -->/g,ne=/<!-- vis:user-content -->(?:(?!<!-- \/vis:user-content -->)[\s\S])*?<!-- vis:user-content -->/,re=i=>`${Z}${i}${ee}`,se=(i,e)=>{const n=[],c=/<!-- vis:user-content -->\s*<!-- \/vis:user-content -->/g;let r=c.exec(i);for(;r!==null;)n.push({end:r.index+r[0].length,start:r.index}),r=c.exec(i);if(n.length===0)return{body:i,remaining:e};let a=0;const t=[],u=Math.min(n.length,e.length);for(let d=0;d<u;d+=1){const h=n[d],l=e[d];t.push(i.slice(a,h.start)),t.push(l),a=h.end}return t.push(i.slice(a)),{body:t.join(""),remaining:e.slice(u)}},ie=(i,e)=>{if(i===void 0||i==="")return e;const n=i.replaceAll(/```[\s\S]*?```/g,"").replaceAll(/~~~[\s\S]*?~~~/g,""),c=(n.match(/<!-- vis:user-content -->/g)??[]).length,r=(n.match(/<!-- \/vis:user-content -->/g)??[]).length;if(c!==r)throw new j({code:"CONFIG_INVALID",hint:"Fix the marker pairs in the PR body and re-run.",message:`PR body has unbalanced <!-- vis:user-content --> markers (${c} opens, ${r} closes). Refusing to merge to prevent silent edit loss.`});if(ne.test(n))throw new j({code:"CONFIG_INVALID",hint:"Flatten the nesting in the PR body and re-run.",message:"Nested <!-- vis:user-content --> markers are not allowed in PR body. The merger refuses to operate to prevent silent edit loss."});const a=[];for(const l of i.matchAll(te)){const g=l[1]??"";g.trim()!==""&&a.push(re(g))}if(a.length===0)return e;const{body:t,remaining:u}=se(e,a);if(u.length===0)return t;const d=t.replace(/\s+$/u,""),h=u.join(`
2
2
 
3
3
  `);return`${d}
4
4
 
5
5
  ${h}
6
- `},re=async(r,e,s)=>{try{return await r.access(z(e,s)),!0}catch{return!1}},se=async(r,e,s,c,n,i,t)=>{const u=await r.run("gh",["pr","list","--head",c,"--state","open","--json","number"],{cwd:s,silent:!0});if(u.exitCode===0&&u.stdout.trim()!==""&&u.stdout.trim()!=="[]")try{const l=JSON.parse(u.stdout);if(l[0]){let g=i,m=!1;try{const b=await r.run("gh",["pr","view",String(l[0].number),"--json","body","-q",".body"],{cwd:s,silent:!0});if(b.exitCode===0)try{g=ne(b.stdout.replace(/\n$/,""),i)}catch(w){m=!0,e.warn(`Skipping PR body update for #${l[0].number} — protected-content blocks are unbalanced, refusing to overwrite operator content. Please clean up markers manually. Cause: ${w.message}`)}}catch(b){e.warn(`Could not read existing body of PR #${l[0].number} for protected-edit merge: ${b.message}. Proceeding with the unmerged body.`)}const v=m?["pr","edit",String(l[0].number),"--title",n]:["pr","edit",String(l[0].number),"--title",n,"--body",g],C=await r.run("gh",v,{cwd:s,silent:!0});if(C.exitCode!==0)throw new Error(`gh pr edit #${l[0].number} failed: ${C.stderr.trim()}`);return{existing:!0,number:l[0].number}}}catch{}const d=await r.run("gh",["pr","create","--head",c,"--base",t,"--title",n,"--body",i],{cwd:s,silent:!0});if(d.exitCode!==0)return;const h=/\/pull\/(\d+)/.exec(d.stdout);return h?{existing:!1,number:Number.parseInt(h[1]??"0",10)}:void 0},ie=async(r,e,s,c)=>{const n=c.labels??["autorelease: pending"];n.length>0&&await r.run("gh",["pr","edit",String(s),...n.flatMap(i=>["--add-label",i])],{cwd:e,silent:!0}),c.reviewers&&c.reviewers.length>0&&await r.run("gh",["pr","edit",String(s),"--add-reviewer",c.reviewers.join(",")],{cwd:e,silent:!0}),c.assignees&&c.assignees.length>0&&await r.run("gh",["pr","edit",String(s),"--add-assignee",c.assignees.join(",")],{cwd:e,silent:!0})},ae=/^ci-(?:head|[\da-f]{4,40})\.md$/,oe=(r,e)=>{const s=e===""?"":`${e}/`;return r.startsWith(s)&&ae.test(r.slice(s.length))},$e=async({fs:r,logger:e,options:s,workspaceRoot:c})=>{const n=c??process.cwd(),i=B();let t=await _({channel:s.channel,cwd:n});const{printConfigIfRequested:u}=await import("./print-config.js");if(u(s,t,e))return;const d=t.config.changesDir??T,h=s.generate===!0,l=h?await k({cwd:n,runner:i},G(n,d)):"",g=await H({cwd:n,runner:i}),m=h?g.filter(o=>oe(o,l)):[],v=g.filter(o=>!m.includes(o));if(v.length>0){const o=v.slice(0,5).join(", "),a=v.length>5?` (+${v.length-5} more)`:"";e.warn(`Working tree has uncommitted changes. CI mode requires a clean tree. Offending paths: ${o}${a}`),process.exitCode=1;return}if(m.length>0&&e.warn(`Keeping ${m.length} change file(s) left behind by an interrupted --generate run: ${m.join(", ")}.`),h){const o=await U({cwd:n,runner:i}),a=await V({allowFullHistory:s.allowFullHistory===!0,config:t.config,cwd:n,from:s.generateFrom,fs:r,name:`ci-${o??"head"}`,packages:t.packages,perPackageConfig:t.perPackageConfig,runner:i,sinceLastRelease:s.generateFrom===void 0});for(const f of a.notes)e.info(f);for(const f of a.warnings)e.warn(f);if(a.status==="failed"){e.error(a.error),process.exitCode=1;return}if(a.status==="written"){const f=await k({cwd:n,runner:i},a.createdFile),P=await i.run("git",["add","--",a.createdFile],{cwd:n,silent:!0});if(P.exitCode!==0){e.error(`Could not stage the generated change file ${f}: ${P.stderr.trim()||`exit ${P.exitCode}`}`);try{await r.rm(a.createdFile,{force:!0})}catch{e.warn(`Could not clean up ${f} after the staging failure — remove it before the next run.`)}process.exitCode=1;return}e.info(`Generated ${f} from ${a.fromRef}..HEAD (${a.bumps.size} package(s)).`),t=await _({channel:s.channel,cwd:n})}else e.info(`--generate derived no bumps from ${a.fromRef}..HEAD.`)}const C=s.autoPublish===!0?"auto-publish":t.channel?.mode??"auto-publish",{files:b}=await q({changesDir:t.config.changesDir,cwd:n});if(C==="auto-publish"){if(b.length===0){e.info("No pending change files. Nothing to release.");return}e.info(`Auto-publish mode — versioning + publishing ${t.plan.releases.length} package(s).`),await E(t,{commit:!0});const o=await A(t,{resume:!0,tag:t.channel?.tag}),a=await K({cwd:n,runner:i});if(a)try{await F({cwd:n,runner:i},a)}catch(f){e.error(`Failed to push branch: ${f.message}`)}e.info(`Published: ${o.published.length} | Skipped: ${o.skipped.length} | Failed: ${o.failed.length}`),process.exitCode=o.failed.length>0?2:0;return}if(b.length===0){const o=await re(r,n,d);o?e.info("No pending change files but `.state.json` is present — resuming the prior wave's publish."):e.info("No pending change files — assuming this push is a merged release PR. Publishing.");const a=await A(t,{resume:o,tag:t.channel?.tag});e.info(`Published: ${a.published.length} | Skipped: ${a.skipped.length} | Failed: ${a.failed.length}`),process.exitCode=a.failed.length>0?2:0;return}e.info(`Version-PR mode — maintaining release PR for ${t.plan.releases.length} package(s).`);const w=s.branch??t.config.versionPr?.branch??"vis-release/version-packages",j=t.config.versionPr?.title??"🚀 Versioned release";if(!await J(i,n)){e.error("Could not detect repository slug via gh CLI. Cannot maintain version PR."),process.exitCode=1;return}const R=await i.run("git",["switch","-C",w],{cwd:n,silent:!0});if(R.exitCode!==0){e.error(`Could not switch to ${w}: ${R.stderr}`),process.exitCode=1;return}const x=await E(t,{commit:!1}),y=[...x.changedFiles,...x.deletedFiles];if(y.length===0){e.warn("Apply produced no file changes. Aborting version PR.");return}await W({cwd:n,runner:i},y,t.config.gitUser?`release(${t.channel?.tag??"main"}): version packages [skip ci]`:"release: version packages [skip ci]",{author:t.config.gitUser});try{await F({cwd:n,runner:i},w,{force:!0})}catch(o){e.error(`Could not push ${w}: ${o.message}`),process.exitCode=1;return}const N=t.branch??t.config.baseBranch??"main",D=`${t.config.versionPr?.preamble??""}
6
+ `},ae=async(i,e,n)=>{try{return await i.access(Q(e,n)),!0}catch{return!1}},oe=async(i,e,n,c,r,a,t)=>{const u=await i.run("gh",["pr","list","--head",c,"--state","open","--json","number"],{cwd:n,silent:!0});if(u.exitCode===0&&u.stdout.trim()!==""&&u.stdout.trim()!=="[]")try{const l=JSON.parse(u.stdout);if(l[0]){let g=a,m=!1;try{const b=await i.run("gh",["pr","view",String(l[0].number),"--json","body","-q",".body"],{cwd:n,silent:!0});if(b.exitCode===0)try{g=ie(b.stdout.replace(/\n$/,""),a)}catch(w){m=!0,e.warn(`Skipping PR body update for #${l[0].number} — protected-content blocks are unbalanced, refusing to overwrite operator content. Please clean up markers manually. Cause: ${w.message}`)}}catch(b){e.warn(`Could not read existing body of PR #${l[0].number} for protected-edit merge: ${b.message}. Proceeding with the unmerged body.`)}const v=m?["pr","edit",String(l[0].number),"--title",r]:["pr","edit",String(l[0].number),"--title",r,"--body",g],$=await i.run("gh",v,{cwd:n,silent:!0});if($.exitCode!==0)throw new Error(`gh pr edit #${l[0].number} failed: ${$.stderr.trim()}`);return{existing:!0,number:l[0].number}}}catch{}const d=await i.run("gh",["pr","create","--head",c,"--base",t,"--title",r,"--body",a],{cwd:n,silent:!0});if(d.exitCode!==0)return;const h=/\/pull\/(\d+)/.exec(d.stdout);return h?{existing:!1,number:Number.parseInt(h[1]??"0",10)}:void 0},ce=async(i,e,n,c)=>{const r=c.labels??["autorelease: pending"];r.length>0&&await i.run("gh",["pr","edit",String(n),...r.flatMap(a=>["--add-label",a])],{cwd:e,silent:!0}),c.reviewers&&c.reviewers.length>0&&await i.run("gh",["pr","edit",String(n),"--add-reviewer",c.reviewers.join(",")],{cwd:e,silent:!0}),c.assignees&&c.assignees.length>0&&await i.run("gh",["pr","edit",String(n),"--add-assignee",c.assignees.join(",")],{cwd:e,silent:!0})},le=/^ci-(?:head|[\da-f]{4,40})(?:-[a-z\d-]+)?\.md$/,ue=(i,e)=>{const n=e===""?"":`${e}/`;return i.startsWith(n)&&le.test(i.slice(n.length))},Re=async({fs:i,logger:e,options:n,workspaceRoot:c})=>{const r=c??process.cwd(),a=J();let t=await y({channel:n.channel,cwd:r});const{printConfigIfRequested:u}=await import("./print-config.js");if(u(n,t,e))return;const d=t.config.changesDir??V,h=n.generate===!0,l=h?await E({cwd:r,runner:a},q(r,d)):"",g=await K({cwd:r,runner:a}),m=h?g.filter(o=>ue(o,l)):[],v=g.filter(o=>!m.includes(o));if(v.length>0){const o=v.slice(0,5).join(", "),s=v.length>5?` (+${v.length-5} more)`:"";e.warn(`Working tree has uncommitted changes. CI mode requires a clean tree. Offending paths: ${o}${s}`),process.exitCode=1;return}m.length>0&&e.warn(`Keeping ${m.length} change file(s) left behind by an interrupted --generate run: ${m.join(", ")}.`);const $=n.autoPublish===!0?"auto-publish":t.channel?.mode??"auto-publish";if($==="auto-publish"&&n.publishMissing){const o=await Y(t,{tag:t.channel?.tag});for(const s of o.missing)e.info(`Recovered ${s.name}@${s.version} from release commit ${s.commit.slice(0,7)} (${s.onRegistry?"tagged":"published"}).`);for(const s of o.skipped.filter(p=>p.reason.includes("untagged")))e.warn(`Not recovering ${s.name}: ${s.reason}.`);for(const s of o.failed)e.error(`Recovering ${s.name} failed: ${s.reason}`);if(o.failed.length>0){e.error("Fix the failed recovery above before a new wave is released (or pass --no-publish-missing)."),process.exitCode=2;return}o.missing.length>0&&(t=await y({channel:n.channel,cwd:r}))}if(h){const o=await W({cwd:r,runner:a}),s=await U({allowFullHistory:n.allowFullHistory===!0,config:t.config,cwd:r,from:n.generateFrom,fs:i,name:`ci-${o??"head"}`,packages:t.packages,perPackageConfig:t.perPackageConfig,runner:a,sinceLastRelease:n.generateFrom===void 0});for(const p of s.notes)e.info(p);for(const p of s.warnings)e.warn(p);if(s.status==="failed"){e.error(s.error),process.exitCode=1;return}if(s.status==="written"){const p=s.files.map(C=>C.path),R=await Promise.all(p.map(async C=>await E({cwd:r,runner:a},C))),x=await a.run("git",["add","--",...p],{cwd:r,silent:!0});if(x.exitCode!==0){e.error(`Could not stage the generated change files ${R.join(", ")}: ${x.stderr.trim()||`exit ${x.exitCode}`}`);try{await Promise.all(p.map(async C=>{await i.rm(C,{force:!0})}))}catch{e.warn(`Could not clean up ${R.join(", ")} after the staging failure — remove them before the next run.`)}process.exitCode=1;return}e.info(`Generated ${R.join(", ")} from ${s.fromRef}..HEAD (${s.bumps.size} package(s)).`),t=await y({channel:n.channel,cwd:r})}else e.info(`--generate derived no bumps from ${s.fromRef}..HEAD.`)}const{files:b}=await H({changesDir:t.config.changesDir,cwd:r});if($==="auto-publish"){if(b.length===0){e.info("No pending change files. Nothing to release.");return}e.info(`Auto-publish mode — versioning + publishing ${t.plan.releases.length} package(s).`),await N(t,{commit:!0});const o=await z({cwd:r,runner:a});if(o)try{await F({cwd:r,runner:a},o)}catch(p){e.error(`Failed to push the version commit, nothing was published: ${p.message}`),process.exitCode=1;return}const s=await A(t,{resume:!0,tag:t.channel?.tag});e.info(`Published: ${s.published.length} | Skipped: ${s.skipped.length} | Failed: ${s.failed.length}`),process.exitCode=s.failed.length>0?2:0;return}if(b.length===0){const o=await ae(i,r,d);o?e.info("No pending change files but `.state.json` is present — resuming the prior wave's publish."):e.info("No pending change files — assuming this push is a merged release PR. Publishing.");const s=await A(t,{resume:o,tag:t.channel?.tag});e.info(`Published: ${s.published.length} | Skipped: ${s.skipped.length} | Failed: ${s.failed.length}`),process.exitCode=s.failed.length>0?2:0;return}e.info(`Version-PR mode — maintaining release PR for ${t.plan.releases.length} package(s).`);const w=n.branch??t.config.versionPr?.branch??"vis-release/version-packages",M=t.config.versionPr?.title??"🚀 Versioned release";if(!await X(a,r)){e.error("Could not detect repository slug via gh CLI. Cannot maintain version PR."),process.exitCode=1;return}const _=await a.run("git",["switch","-C",w],{cwd:r,silent:!0});if(_.exitCode!==0){e.error(`Could not switch to ${w}: ${_.stderr}`),process.exitCode=1;return}const k=await N(t,{commit:!1}),S=[...k.changedFiles,...k.deletedFiles];if(S.length===0){e.warn("Apply produced no file changes. Aborting version PR.");return}await B({cwd:r,runner:a},S,t.config.gitUser?`release(${t.channel?.tag??"main"}): version packages [skip ci]`:"release: version packages [skip ci]",{author:t.config.gitUser});try{await F({cwd:r,runner:a},w,{force:!0})}catch(o){e.error(`Could not push ${w}: ${o.message}`),process.exitCode=1;return}const D=t.branch??t.config.baseBranch??"main",I=`${t.config.versionPr?.preamble??""}
7
7
 
8
8
  ## Pending releases
9
9
 
10
10
  ${t.plan.releases.map(o=>`- \`${o.name}\`: ${o.oldVersion} → **${o.newVersion}**`).join(`
11
11
  `)}
12
- `,p=await se(i,e,n,w,j,D,N);if(p){if(e.info(`${p.existing?"Updated":"Opened"} version PR #${p.number}.`),await ie(i,n,p.number,{assignees:p.existing?void 0:t.config.versionPr?.assignees,labels:t.config.versionPr?.labels,reviewers:p.existing?void 0:t.config.versionPr?.reviewers}),t.config.versionPr?.autoMerge&&!p.existing){const o=t.config.versionPr.autoMergeMethod??"squash",a=await i.run("gh",["pr","merge",String(p.number),"--auto",`--${o}`],{cwd:n,silent:!0});a.exitCode===0?e.info(`Auto-merge enabled (${o}).`):e.warn(`Could not enable auto-merge on PR #${p.number}: ${a.stderr.trim()||`exit ${a.exitCode}`}`)}}else e.error("Failed to create / update version PR."),process.exitCode=1};export{$e as default};
12
+ `,f=await oe(a,e,r,w,M,I,D);if(f){if(e.info(`${f.existing?"Updated":"Opened"} version PR #${f.number}.`),await ce(a,r,f.number,{assignees:f.existing?void 0:t.config.versionPr?.assignees,labels:t.config.versionPr?.labels,reviewers:f.existing?void 0:t.config.versionPr?.reviewers}),t.config.versionPr?.autoMerge&&!f.existing){const o=t.config.versionPr.autoMergeMethod??"squash",s=await a.run("gh",["pr","merge",String(f.number),"--auto",`--${o}`],{cwd:r,silent:!0});s.exitCode===0?e.info(`Auto-merge enabled (${o}).`):e.warn(`Could not enable auto-merge on PR #${f.number}: ${s.stderr.trim()||`exit ${s.exitCode}`}`)}}else e.error("Failed to create / update version PR."),process.exitCode=1};export{Re as default};
@@ -1,4 +1,4 @@
1
- import{createRequire as P}from"node:module";import{o as T,s as K,t as L,u as f,v as J,w as W,x as Y,y as H,z as U,A as V,B as Q,D as X,E as Z,F as tt,G as nt,H as et,I as F,J as st}from"./cli-main.js";import{e as p,z as j,$ as rt}from"../packem_shared/index-0dnGN3GP.js";import{l as ct}from"./ts-loader.js";import{loadVisConfig as at}from"./CONFIG_FILES.js";import{y as x}from"../packem_shared/isAccessibleSync-DYKTrrvc-CBsMZhj-.js";import{U as O}from"../packem_shared/env-BymuoTL8.js";import{L as dt}from"../packem_shared/registry-CndByNx9.js";import{v as pt}from"../packem_shared/verify-3WE9U_Bv.js";let q;const z=t=>(q??=P(import.meta.url))(t),E=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,B=t=>{if(typeof E<"u"&&E.versions&&E.versions.node){const[n,s]=E.versions.node.split(".").map(Number);if(n>22||n===22&&s>=3||n===20&&s>=16)return E.getBuiltinModule(t)}return z(t)},{readdirSync:it,statSync:ot}=B("node:fs"),{stdin:N,stdout:ut}=E,{createInterface:ft}=B("node:readline/promises"),k="__global__",w=t=>[...new Set(t)].sort((n,s)=>n.localeCompare(s)),mt=t=>`{${Object.keys(t).sort().map(i=>`${i}=${JSON.stringify(t[i])}`).join(",")}}`,h=t=>{if(!Array.isArray(t))return[];const n=[];for(const s of t)typeof s=="string"?n.push(s):s&&typeof s=="object"&&n.push(mt(s));return w(n)},g=t=>({cache:void 0,dependsOn:[],env:[],id:t,inputs:[],outputs:[]}),v=(t,n,s)=>s?`^${n}`:t&&t!=="self"&&t!=="~"?`${t}#${n}`:n,lt=(t,n)=>{const s=t.trim();if(n==="moon"){if(s.startsWith("^:"))return v(void 0,s.slice(2),!0);if(s.startsWith("~:"))return v(void 0,s.slice(2),!1);if(s.includes(":")){const[i,e]=s.split(":");return v(i,e??"",!1)}return s}if(s.startsWith("^"))return v(void 0,s.slice(1),!0);if(s.includes("#")){const[i,e]=s.split("#");return v(i,e??"",!1)}return s},R=(t,n)=>{if(!Array.isArray(t))return[];const s=[];for(const i of t){if(typeof i=="string"){s.push(lt(i,n));continue}if(!i||typeof i!="object")continue;const e=i,{target:o}=e;if(!o)continue;if(e.dependencies===!0){s.push(v(void 0,o,!0));continue}if(e.projects===void 0){s.push(v(void 0,o,!1));continue}const r=Array.isArray(e.projects)?e.projects:[e.projects];for(const a of r)s.push(a==="^"?v(void 0,o,!0):v(a,o,!1))}return w(s)},M=t=>{if(x(t))try{return JSON.parse(j(t))}catch{return}},yt=t=>{const n=new Map,s=M(p(t,"turbo.json"));if(!s)return n;const i=s.tasks??s.pipeline??{};for(const[o,r]of Object.entries(i)){const a=o.includes("#")?o:`*#${o}`,c=g(a);c.dependsOn=R(r.dependsOn,"turbo"),c.inputs=h(r.inputs),c.outputs=h(r.outputs),c.env=w([...r.env??[],...r.passThroughEnv??[]]),c.cache=r.cache===!1?!1:void 0,n.set(a,c)}const e=g(k);return e.inputs=h(s.globalDependencies),e.env=w([...s.globalEnv??[],...s.globalPassThroughEnv??[]]),(e.inputs.length>0||e.env.length>0)&&n.set(k,e),n},ht=new Set([".git",".nx",".turbo",".vis","build","coverage","dist","node_modules"]),C=(t,n,s=8)=>{const i=[],e=(o,r)=>{if(r>s)return;let a;try{a=it(o)}catch{return}for(const c of a.toSorted()){if(c===n){i.push(p(o,c));continue}if(c.startsWith(".")&&c!==".moon"||ht.has(c))continue;const u=p(o,c);try{ot(u).isDirectory()&&e(u,r+1)}catch{}}};return e(t,0),i},I=(t,n)=>{t.dependsOn=R(n.dependsOn,"nx"),t.inputs=h(n.inputs),t.outputs=h(n.outputs),t.cache=typeof n.cache=="boolean"?n.cache:void 0},vt=t=>{const n=new Map,s=M(p(t,"nx.json"));for(const[i,e]of Object.entries(s?.targetDefaults??{})){const o=`*#${i}`,r=g(o);I(r,e),n.set(o,r)}for(const i of C(t,"project.json")){const e=M(i);if(!(!e?.name||!e.targets))for(const[o,r]of Object.entries(e.targets)){const a=`${e.name}#${o}`,c=g(a);I(c,r),n.set(a,c)}}return n},_=(t,n)=>{t.dependsOn=R(n.deps,"moon"),t.inputs=h(n.inputs),t.outputs=h(n.outputs),t.cache=typeof n.options?.cache=="boolean"?n.options.cache:void 0},A=t=>{if(x(t))try{return ct(t)}catch{return}},gt=t=>{const n=new Map,s=p(t,".moon"),i=[p(s,"tasks.yml"),p(s,"tasks.yaml")];for(const e of i){const o=A(e);if(o){for(const[r,a]of Object.entries(o.tasks??{})){const c=`*#${r}`,u=g(c);_(u,a),n.set(c,u)}if(o.implicitInputs&&o.implicitInputs.length>0){const r=g(k);r.inputs=h(o.implicitInputs),n.set(k,r)}}}for(const e of[...C(t,"moon.yml"),...C(t,"moon.yaml")]){const o=A(e);if(!o?.tasks)continue;const a=e.split(/[/\\]/).at(-2)??"*";for(const[c,u]of Object.entries(o.tasks)){const b=`${a}#${c}`,d=g(b);_(d,u),n.set(b,d)}}return n},xt=(t,n)=>{t.dependsOn=R(n.dependsOn,"vis"),t.inputs=h(n.inputs),t.outputs=h(n.outputs),t.env=w([...n.env??[],...n.passThroughEnv??[],...n.options?.passThroughEnv??[]]),t.cache=n.cache===!1?!1:typeof n.cache=="boolean"?n.cache:void 0},kt=async t=>{const n=new Map,s=await at(t);for(const[o,r]of Object.entries(s.tasks??{})){const a=`*#${o}`,c=g(a);xt(c,r??{}),n.set(a,c)}const i=s.taskRunner??{},e=g(k);return e.inputs=h(i.globalInputs),e.env=w([...i.globalEnv??[],...i.globalPassThroughEnv??[]]),(e.inputs.length>0||e.env.length>0)&&n.set(k,e),n},wt=(t,n)=>{switch(n){case"moon":return gt(t);case"nx":return vt(t);default:return yt(t)}},bt=t=>{const n=[];return x(p(t,"turbo.json"))&&n.push("turbo"),x(p(t,"nx.json"))&&n.push("nx"),(x(p(t,".moon","tasks.yml"))||x(p(t,".moon","tasks.yaml")))&&n.push("moon"),n.length===1?n[0]:void 0},S=(t,n,s,i,e)=>{const o=i.filter(c=>!e.includes(c)),r=e.filter(c=>!i.includes(c));if(o.length===0&&r.length===0)return;const a=[];o.length>0&&a.push(`dropped [${o.join(", ")}]`),r.length>0&&a.push(`added [${r.join(", ")}]`),t.push({axis:s,detail:`${s} diverged: ${a.join("; ")}`,node:n,severity:o.length>0?"error":"warning"})},Et=(t,n,s)=>{const i=[],e=w([...t.keys(),...n.keys()]);for(const o of e){const r=t.get(o),a=n.get(o);if(r&&!a){const c=s==="turbo"&&o.includes("#")&&!o.startsWith("*#")&&o!==k;i.push({axis:"target-set",detail:c?`source target \`${o}\` was skipped by design (turbo project#task is migrated into per-project project.json — move it there and re-verify)`:`source target \`${o}\` has no equivalent in the migrated vis config`,node:o,severity:c?"warning":"error"});continue}if(!r&&a){i.push({axis:"target-set",detail:`migrated vis config defines \`${o}\` with no source equivalent (extra target — not a regression, but review)`,node:o,severity:"warning"});continue}!r||!a||(S(i,o,"dependsOn",r.dependsOn,a.dependsOn),S(i,o,"inputs",r.inputs,a.inputs),S(i,o,"outputs",r.outputs,a.outputs),S(i,o,"env",r.env,a.env),r.cache!==void 0&&a.cache!==void 0&&r.cache!==a.cache&&i.push({axis:"cache",detail:`cache flag diverged: source=${String(r.cache)} vis=${String(a.cache)} (changes what invalidates the cache)`,node:o,severity:"error"}))}return i.sort((o,r)=>o.node.localeCompare(r.node)||o.axis.localeCompare(r.axis)),{findings:i,source:s,sourceNodeCount:t.size,visNodeCount:n.size}},$t=new Set(["json","ndjson","table"]),St=t=>({equivalent:t.findings.every(n=>n.severity!=="error"),findings:t.findings,source:t.source,sourceNodeCount:t.sourceNodeCount,visNodeCount:t.visNodeCount}),Rt=(t,n,s)=>{if(n==="json"){process.stdout.write(`${JSON.stringify(St(t),void 0,2)}
1
+ import{createRequire as P}from"node:module";import{o as T,s as K,t as L,u as f,v as J,w as W,x as Y,y as H,z as U,A as V,B as Q,D as X,E as Z,F as tt,G as nt,H as et,I as F,J as st}from"./cli-main.js";import{e as p,z as j,$ as rt}from"../packem_shared/index-0dnGN3GP.js";import{l as ct}from"./ts-loader.js";import{loadVisConfig as at}from"./CONFIG_FILES.js";import{y as x}from"../packem_shared/isAccessibleSync-DYKTrrvc-CBsMZhj-.js";import{U as O}from"../packem_shared/env-CJVZRP-o.js";import{L as dt}from"../packem_shared/registry-acz8_sxm.js";import{v as pt}from"../packem_shared/verify-3WE9U_Bv.js";let q;const z=t=>(q??=P(import.meta.url))(t),E=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,B=t=>{if(typeof E<"u"&&E.versions&&E.versions.node){const[n,s]=E.versions.node.split(".").map(Number);if(n>22||n===22&&s>=3||n===20&&s>=16)return E.getBuiltinModule(t)}return z(t)},{readdirSync:it,statSync:ot}=B("node:fs"),{stdin:N,stdout:ut}=E,{createInterface:ft}=B("node:readline/promises"),k="__global__",w=t=>[...new Set(t)].sort((n,s)=>n.localeCompare(s)),mt=t=>`{${Object.keys(t).sort().map(i=>`${i}=${JSON.stringify(t[i])}`).join(",")}}`,h=t=>{if(!Array.isArray(t))return[];const n=[];for(const s of t)typeof s=="string"?n.push(s):s&&typeof s=="object"&&n.push(mt(s));return w(n)},g=t=>({cache:void 0,dependsOn:[],env:[],id:t,inputs:[],outputs:[]}),v=(t,n,s)=>s?`^${n}`:t&&t!=="self"&&t!=="~"?`${t}#${n}`:n,lt=(t,n)=>{const s=t.trim();if(n==="moon"){if(s.startsWith("^:"))return v(void 0,s.slice(2),!0);if(s.startsWith("~:"))return v(void 0,s.slice(2),!1);if(s.includes(":")){const[i,e]=s.split(":");return v(i,e??"",!1)}return s}if(s.startsWith("^"))return v(void 0,s.slice(1),!0);if(s.includes("#")){const[i,e]=s.split("#");return v(i,e??"",!1)}return s},R=(t,n)=>{if(!Array.isArray(t))return[];const s=[];for(const i of t){if(typeof i=="string"){s.push(lt(i,n));continue}if(!i||typeof i!="object")continue;const e=i,{target:o}=e;if(!o)continue;if(e.dependencies===!0){s.push(v(void 0,o,!0));continue}if(e.projects===void 0){s.push(v(void 0,o,!1));continue}const r=Array.isArray(e.projects)?e.projects:[e.projects];for(const a of r)s.push(a==="^"?v(void 0,o,!0):v(a,o,!1))}return w(s)},M=t=>{if(x(t))try{return JSON.parse(j(t))}catch{return}},yt=t=>{const n=new Map,s=M(p(t,"turbo.json"));if(!s)return n;const i=s.tasks??s.pipeline??{};for(const[o,r]of Object.entries(i)){const a=o.includes("#")?o:`*#${o}`,c=g(a);c.dependsOn=R(r.dependsOn,"turbo"),c.inputs=h(r.inputs),c.outputs=h(r.outputs),c.env=w([...r.env??[],...r.passThroughEnv??[]]),c.cache=r.cache===!1?!1:void 0,n.set(a,c)}const e=g(k);return e.inputs=h(s.globalDependencies),e.env=w([...s.globalEnv??[],...s.globalPassThroughEnv??[]]),(e.inputs.length>0||e.env.length>0)&&n.set(k,e),n},ht=new Set([".git",".nx",".turbo",".vis","build","coverage","dist","node_modules"]),C=(t,n,s=8)=>{const i=[],e=(o,r)=>{if(r>s)return;let a;try{a=it(o)}catch{return}for(const c of a.toSorted()){if(c===n){i.push(p(o,c));continue}if(c.startsWith(".")&&c!==".moon"||ht.has(c))continue;const u=p(o,c);try{ot(u).isDirectory()&&e(u,r+1)}catch{}}};return e(t,0),i},I=(t,n)=>{t.dependsOn=R(n.dependsOn,"nx"),t.inputs=h(n.inputs),t.outputs=h(n.outputs),t.cache=typeof n.cache=="boolean"?n.cache:void 0},vt=t=>{const n=new Map,s=M(p(t,"nx.json"));for(const[i,e]of Object.entries(s?.targetDefaults??{})){const o=`*#${i}`,r=g(o);I(r,e),n.set(o,r)}for(const i of C(t,"project.json")){const e=M(i);if(!(!e?.name||!e.targets))for(const[o,r]of Object.entries(e.targets)){const a=`${e.name}#${o}`,c=g(a);I(c,r),n.set(a,c)}}return n},_=(t,n)=>{t.dependsOn=R(n.deps,"moon"),t.inputs=h(n.inputs),t.outputs=h(n.outputs),t.cache=typeof n.options?.cache=="boolean"?n.options.cache:void 0},A=t=>{if(x(t))try{return ct(t)}catch{return}},gt=t=>{const n=new Map,s=p(t,".moon"),i=[p(s,"tasks.yml"),p(s,"tasks.yaml")];for(const e of i){const o=A(e);if(o){for(const[r,a]of Object.entries(o.tasks??{})){const c=`*#${r}`,u=g(c);_(u,a),n.set(c,u)}if(o.implicitInputs&&o.implicitInputs.length>0){const r=g(k);r.inputs=h(o.implicitInputs),n.set(k,r)}}}for(const e of[...C(t,"moon.yml"),...C(t,"moon.yaml")]){const o=A(e);if(!o?.tasks)continue;const a=e.split(/[/\\]/).at(-2)??"*";for(const[c,u]of Object.entries(o.tasks)){const b=`${a}#${c}`,d=g(b);_(d,u),n.set(b,d)}}return n},xt=(t,n)=>{t.dependsOn=R(n.dependsOn,"vis"),t.inputs=h(n.inputs),t.outputs=h(n.outputs),t.env=w([...n.env??[],...n.passThroughEnv??[],...n.options?.passThroughEnv??[]]),t.cache=n.cache===!1?!1:typeof n.cache=="boolean"?n.cache:void 0},kt=async t=>{const n=new Map,s=await at(t);for(const[o,r]of Object.entries(s.tasks??{})){const a=`*#${o}`,c=g(a);xt(c,r??{}),n.set(a,c)}const i=s.taskRunner??{},e=g(k);return e.inputs=h(i.globalInputs),e.env=w([...i.globalEnv??[],...i.globalPassThroughEnv??[]]),(e.inputs.length>0||e.env.length>0)&&n.set(k,e),n},wt=(t,n)=>{switch(n){case"moon":return gt(t);case"nx":return vt(t);default:return yt(t)}},bt=t=>{const n=[];return x(p(t,"turbo.json"))&&n.push("turbo"),x(p(t,"nx.json"))&&n.push("nx"),(x(p(t,".moon","tasks.yml"))||x(p(t,".moon","tasks.yaml")))&&n.push("moon"),n.length===1?n[0]:void 0},S=(t,n,s,i,e)=>{const o=i.filter(c=>!e.includes(c)),r=e.filter(c=>!i.includes(c));if(o.length===0&&r.length===0)return;const a=[];o.length>0&&a.push(`dropped [${o.join(", ")}]`),r.length>0&&a.push(`added [${r.join(", ")}]`),t.push({axis:s,detail:`${s} diverged: ${a.join("; ")}`,node:n,severity:o.length>0?"error":"warning"})},Et=(t,n,s)=>{const i=[],e=w([...t.keys(),...n.keys()]);for(const o of e){const r=t.get(o),a=n.get(o);if(r&&!a){const c=s==="turbo"&&o.includes("#")&&!o.startsWith("*#")&&o!==k;i.push({axis:"target-set",detail:c?`source target \`${o}\` was skipped by design (turbo project#task is migrated into per-project project.json — move it there and re-verify)`:`source target \`${o}\` has no equivalent in the migrated vis config`,node:o,severity:c?"warning":"error"});continue}if(!r&&a){i.push({axis:"target-set",detail:`migrated vis config defines \`${o}\` with no source equivalent (extra target — not a regression, but review)`,node:o,severity:"warning"});continue}!r||!a||(S(i,o,"dependsOn",r.dependsOn,a.dependsOn),S(i,o,"inputs",r.inputs,a.inputs),S(i,o,"outputs",r.outputs,a.outputs),S(i,o,"env",r.env,a.env),r.cache!==void 0&&a.cache!==void 0&&r.cache!==a.cache&&i.push({axis:"cache",detail:`cache flag diverged: source=${String(r.cache)} vis=${String(a.cache)} (changes what invalidates the cache)`,node:o,severity:"error"}))}return i.sort((o,r)=>o.node.localeCompare(r.node)||o.axis.localeCompare(r.axis)),{findings:i,source:s,sourceNodeCount:t.size,visNodeCount:n.size}},$t=new Set(["json","ndjson","table"]),St=t=>({equivalent:t.findings.every(n=>n.severity!=="error"),findings:t.findings,source:t.source,sourceNodeCount:t.sourceNodeCount,visNodeCount:t.visNodeCount}),Rt=(t,n,s)=>{if(n==="json"){process.stdout.write(`${JSON.stringify(St(t),void 0,2)}
2
2
  `);return}if(n==="ndjson"){for(const i of t.findings)process.stdout.write(`${JSON.stringify(i)}
3
3
  `);return}if(s.info(`Migration equivalence: ${t.source} → vis`),s.info(` source nodes: ${String(t.sourceNodeCount)} vis nodes: ${String(t.visNodeCount)}`),t.findings.length===0){s.info(" ✓ task graph + cache-key surface preserved (no divergence).");return}for(const i of t.findings){const e=` [${i.severity}] ${i.node} (${i.axis}) — ${i.detail}`;i.severity==="error"?s.warn(e):s.info(e)}},jt=(t,n)=>t.findings.some(i=>n==="warning"?!0:i.severity==="error")?1:0,G=async t=>{if(!N.isTTY)return!0;const n=ft({input:N,output:ut});try{const i=(await n.question(`${t} [Y/n] `)).trim().toLowerCase();return i===""||i==="y"||i==="yes"}finally{n.close()}},Mt=[{description:"VisConfig.targetDefaults → VisConfig.tasks",next:"tasks",previous:"targetDefaults"},{description:"VisConfig.taskDefaults → VisConfig.scopedTasks",next:"scopedTasks",previous:"taskDefaults"},{description:"VisConfig.taskRunnerOptions → VisConfig.taskRunner",next:"taskRunner",previous:"taskRunnerOptions"},{description:"ScopedTasksBlock.scope → ScopedTasksBlock.match",next:"match",previous:"scope"},{description:"ScopedTasksBlock.targets → ScopedTasksBlock.tasks",next:"tasks",previous:"targets"}],Ct=[{description:"VisTaskConfig.targets → VisTaskConfig.tasks",next:"tasks",previous:"targets"}],Tt=t=>new RegExp(String.raw`(^|[\s,{(\[])(["']?)${t}\2(\s*:)`,"gmu"),Nt=(t,n)=>{let s=t;const i=[];for(const e of n){const o=Tt(e.previous);o.test(s)&&(o.lastIndex=0,s=s.replace(o,(r,a,c,u)=>`${a}${c}${e.next}${c}${u}`),i.push(e))}return{applied:i,output:s}},D=(t,n)=>Nt(t,n),Ot=["vis.config.ts","vis.config.mts","vis.config.cts","vis.config.js","vis.config.mjs","vis.config.cjs"],It=new Set(["vis.task.cjs","vis.task.cts","vis.task.js","vis.task.mjs","vis.task.mts","vis.task.ts"]),_t=t=>{for(const n of Ot){const s=p(t,n);if(x(s))return s}},At=t=>{const n=[];try{for(const s of dt(t,{includeDirs:!1,includeFiles:!0,includeSymlinks:!1,skip:[/node_modules/,/\.git/,/\.vis\b/,/dist\b/,/\.next\b/,/\.nuxt\b/]}))It.has(rt(s.path))&&n.push(s.path)}catch{}return n},Dt=(t,n,s,i)=>{const e=_t(t);if(e){const r=j(e),{applied:a,output:c}=D(r,Mt);if(a.length===0)s.info(`${e} already uses the current schema — no rewrite needed.`);else if(n.dryRun)s.info(`── ${e} (preview) ──`),s.info(c),s.info("── end preview ──"),s.info(`Would apply ${String(a.length)} rename(s): ${a.map(u=>u.description).join(", ")}`);else{T(e,i),O(e,c),s.info(`Rewrote ${e} (backup at ${e}.bak). Applied ${String(a.length)} rename(s).`);for(const u of a)i.manualSteps.push(`Renamed ${u.description} in ${e}`)}}else s.warn("No vis.config.ts found at workspace root — nothing to migrate."),i.warnings.push("No vis.config.{ts,mts,cts,js,mjs,cjs} at workspace root.");const o=n.taskConfigPaths??At(t);for(const r of o){if(!x(r))continue;const a=j(r),c=D(a,Ct);if(c.applied.length!==0)if(n.dryRun)s.info(`── ${r} (preview) ──`),s.info(c.output),s.info("── end preview ──"),s.info(`Would apply ${String(c.applied.length)} rename(s): ${c.applied.map(u=>u.description).join(", ")}`);else{T(r,i),O(r,c.output),s.info(`Rewrote ${r} (backup at ${r}.bak). Applied ${String(c.applied.length)} rename(s).`);for(const u of c.applied)i.manualSteps.push(`Renamed ${u.description} in ${r}`)}}},m=t=>{const n=t.workspaceRoot??process.cwd(),s=t.visConfig??{};return{config:s,dryRun:!!t.options.dryRun,logger:t.logger,packageManager:st(n),report:F(),root:n,useEditorconfig:typeof s.editorconfig=="boolean"?s.editorconfig:!0}},l=async(t,n,s)=>{if(n.yes||n.dryRun)return!0;const i=await G(`This will edit files, scripts, and hooks for "${t}". Backups (.bak) will be created. Continue?`);return i||s.info("Aborted."),i},y=t=>{t.dryRun&&t.logger.info(`Running in dry-run mode — no changes will be made.
4
4
  `)},Bt=async({logger:t,options:n,visConfig:s,workspaceRoot:i})=>{if(!await l("deps",n,t))return;const e=m({logger:t,options:n,visConfig:s,workspaceRoot:i});y(e),t.info("── Migrating dependencies and scripts ──"),J(e.root,e.packageManager,e.config,{dryRun:e.dryRun},t,e.report),t.info(""),f(e.report,t)},Vt=async({logger:t,options:n,visConfig:s,workspaceRoot:i})=>{if(!await l("lint-staged",n,t))return;const e=m({logger:t,options:n,visConfig:s,workspaceRoot:i});y(e),t.info("── Migrating lint-staged ──"),H(e.root,{dryRun:e.dryRun,useEditorconfig:e.useEditorconfig},t,e.report),t.info(""),f(e.report,t)},Ft=async({logger:t,options:n,visConfig:s,workspaceRoot:i})=>{if(!await l("nano-staged",n,t))return;const e=m({logger:t,options:n,visConfig:s,workspaceRoot:i});y(e),t.info("── Migrating nano-staged ──"),Q(e.root,{dryRun:e.dryRun,useEditorconfig:e.useEditorconfig},t,e.report),t.info(""),f(e.report,t)},Gt=async({logger:t,options:n,visConfig:s,workspaceRoot:i})=>{if(!await l("turborepo",n,t))return;const e=m({logger:t,options:n,visConfig:s,workspaceRoot:i});y(e),t.info("── Migrating turborepo ──"),et(e.root,{dryRun:e.dryRun,useEditorconfig:e.useEditorconfig},t,e.report),V(e.root,{dryRun:e.dryRun},t),t.info(""),f(e.report,t)},Pt=async({logger:t,options:n,visConfig:s,workspaceRoot:i})=>{if(!await l("nx",n,t))return;const e=m({logger:t,options:n,visConfig:s,workspaceRoot:i});y(e),t.info("── Migrating nx ──");const o=!!n.aggressive;X(e.root,{aggressive:o,dryRun:e.dryRun,force:o||!!n.force,rewriteSyncGenerators:o||!!n.rewriteSyncGenerators,useEditorconfig:e.useEditorconfig},t,e.report),t.info(""),f(e.report,t)},qt=async({logger:t,options:n,visConfig:s,workspaceRoot:i})=>{if(!await l("moon",n,t))return;const e=m({logger:t,options:n,visConfig:s,workspaceRoot:i});y(e),t.info("── Migrating moon ──"),U(e.root,{copyTemplates:!!n.copyTemplates,dryRun:e.dryRun,useEditorconfig:e.useEditorconfig},t,e.report),V(e.root,{dryRun:e.dryRun},t),t.info(""),f(e.report,t)},zt=async({logger:t,options:n,visConfig:s,workspaceRoot:i})=>{if(!await l("gitleaks",n,t))return;const e=m({logger:t,options:n,visConfig:s,workspaceRoot:i});y(e),t.info("── Migrating gitleaks ──"),W(e.root,{dryRun:e.dryRun,useEditorconfig:e.useEditorconfig},t,e.report),t.info(""),f(e.report,t)},Kt=async({logger:t,options:n,visConfig:s,workspaceRoot:i})=>{if(!await l("kingfisher",n,t))return;const e=m({logger:t,options:n,visConfig:s,workspaceRoot:i});y(e),t.info("── Migrating Kingfisher ──"),Y(e.root,{dryRun:e.dryRun,useEditorconfig:e.useEditorconfig},t,e.report),t.info(""),f(e.report,t)},Lt=async({logger:t,options:n,visConfig:s,workspaceRoot:i})=>{if(!await l("secretlint",n,t))return;const e=m({logger:t,options:n,visConfig:s,workspaceRoot:i});y(e),t.info("── Migrating secretlint ──"),Z(e.root,{dryRun:e.dryRun,useEditorconfig:e.useEditorconfig},t,e.report),t.info(""),f(e.report,t)},Jt=async({logger:t,options:n,visConfig:s,workspaceRoot:i})=>{if(!await l("syncpack",n,t))return;const e=m({logger:t,options:n,visConfig:s,workspaceRoot:i});y(e),t.info("── Migrating syncpack ──"),nt(e.root,{dryRun:e.dryRun,useEditorconfig:e.useEditorconfig},t,e.report),t.info(""),f(e.report,t)},Wt=async({logger:t,options:n,visConfig:s,workspaceRoot:i})=>{if(!await l("sherif",n,t))return;const e=m({logger:t,options:n,visConfig:s,workspaceRoot:i});y(e),t.info("── Migrating sherif ──"),tt(e.root,{dryRun:e.dryRun,useEditorconfig:e.useEditorconfig},t,e.report),t.info(""),f(e.report,t)},Yt=async({logger:t,options:n,visConfig:s,workspaceRoot:i})=>{if(!await l("self",n,t))return;const e=m({logger:t,options:n,visConfig:s,workspaceRoot:i});y(e),t.info("── Migrating vis.config.ts to current schema ──"),Dt(e.root,{dryRun:e.dryRun},t,e.report),t.info(""),f(e.report,t)},Ht=({logger:t,workspaceRoot:n})=>{const s=n??process.cwd();pt(s,t).length>0&&(process.exitCode=1)},Ut=async({logger:t,options:n,workspaceRoot:s})=>{const i=s??process.cwd(),e=n.format??"table";if(!$t.has(e)){t.warn(`Invalid --format: ${String(n.format)}. Expected table | json | ndjson.`),process.exitCode=1;return}const o=n.failOn==="warning"?"warning":"error";let r;if(n.from){if(n.from!=="turbo"&&n.from!=="nx"&&n.from!=="moon"){t.warn(`Invalid --from: ${n.from}. Expected turbo | nx | moon.`),process.exitCode=1;return}r=n.from}else if(r=bt(i),!r){t.warn("Could not auto-detect the source tool (need exactly one of turbo.json / nx.json / .moon/tasks.yml). Pass --from <turbo|nx|moon>."),process.exitCode=1;return}const a=wt(i,r);if(a.size===0){t.warn(`No ${r} task graph found at ${i} — nothing to verify.`),process.exitCode=1;return}const c=await kt(i);if(c.size===0){t.warn("No migrated vis task graph found (vis.config.ts has no tasks). Run the migrator first."),process.exitCode=1;return}const u=Et(a,c,r);Rt(u,e,t),process.exitCode=jt(u,o)},Qt=async({logger:t,options:n,visConfig:s,workspaceRoot:i})=>{const e=i??process.cwd(),r=K(e,s??{}),a=L(r);if(a.length===0){t.info("No applicable migrations detected in this workspace.");return}const c=!!n.dryRun;t.info(`Detected ${String(a.length)} migration(s):`);for(const d of a)t.info(` • ${d.title} — ${d.description}`);if(t.info(""),!n.yes&&!c&&!await G("Apply all detected migrations? Backups (.bak) will be created.")){t.info("Aborted.");return}c&&t.info(`Running in dry-run mode — no changes will be made.
@@ -1,4 +1,4 @@
1
- import{createRequire as D}from"node:module";import{V as q}from"../packem_shared/vis-user-error-BivZDkQD.js";let W;const L=e=>(W??=D(import.meta.url))(e),R=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,E=e=>{if(typeof R<"u"&&R.versions&&R.versions.node){const[t,n]=R.versions.node.split(".").map(Number);if(t>22||t===22&&n>=3||t===20&&n>=16)return R.getBuiltinModule(e)}return L(e)},{relative:h,join:u,dirname:_}=E("node:path"),{lstat:G}=E("node:fs/promises"),U=new Set(["ENOENT","ENOTDIR"]),$=e=>U.has(e?.code??""),T=async(e,t)=>{const n=e.lstat;try{return(typeof n=="function"?await n.call(e,t):await G(t)).isSymbolicLink()}catch(i){if($(i))return!1;throw i}},v=async(e,t,n)=>{if(await T(e,t))throw new q(`Refusing to write ${t}: it is a symlink, and following it would write somewhere else. Remove or replace the link, then re-run.`);await e.writeFile(t,n)},g=async(e,t)=>{try{return await e.access(t),!0}catch(n){if($(n))return!1;throw n}},Y=async(e,t)=>{try{return(await e.stat(t)).isDirectory()}catch(n){if($(n))return!1;throw n}},b=async(e,t)=>{try{return await e.readFile(t,"utf8")}catch(n){if($(n))return;throw n}},K=e=>{const t=/\n([\t ]+)\S/.exec(e);return t?.[1]!==void 0?t[1]:e.includes(`
1
+ import{createRequire as D}from"node:module";import{V as q}from"../packem_shared/vis-user-error-B73F9C2Z.js";let W;const L=e=>(W??=D(import.meta.url))(e),R=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,E=e=>{if(typeof R<"u"&&R.versions&&R.versions.node){const[t,n]=R.versions.node.split(".").map(Number);if(t>22||t===22&&n>=3||t===20&&n>=16)return R.getBuiltinModule(e)}return L(e)},{relative:h,join:u,dirname:_}=E("node:path"),{lstat:G}=E("node:fs/promises"),U=new Set(["ENOENT","ENOTDIR"]),$=e=>U.has(e?.code??""),T=async(e,t)=>{const n=e.lstat;try{return(typeof n=="function"?await n.call(e,t):await G(t)).isSymbolicLink()}catch(i){if($(i))return!1;throw i}},v=async(e,t,n)=>{if(await T(e,t))throw new q(`Refusing to write ${t}: it is a symlink, and following it would write somewhere else. Remove or replace the link, then re-run.`);await e.writeFile(t,n)},g=async(e,t)=>{try{return await e.access(t),!0}catch(n){if($(n))return!1;throw n}},Y=async(e,t)=>{try{return(await e.stat(t)).isDirectory()}catch(n){if($(n))return!1;throw n}},b=async(e,t)=>{try{return await e.readFile(t,"utf8")}catch(n){if($(n))return;throw n}},K=e=>{const t=/\n([\t ]+)\S/.exec(e);return t?.[1]!==void 0?t[1]:e.includes(`
2
2
  `)?" ":""},V=(e,t)=>{const n=t.includes(`\r
3
3
  `)?`\r
4
4
  `:`
@@ -1,4 +1,4 @@
1
- import{a as L,b as J,p as m,O as G,c as A,q as T}from"./cli-main.js";import{O as H}from"../packem_shared/renderToString-DR0zDUjh-DeiCwydO.js";import{a as K,R as c,O as y}from"../packem_shared/registry-CndByNx9.js";import{i as Q}from"../packem_shared/index-BjdW45xX.js";import{v as W,r as X,f as Z}from"../packem_shared/ai-analysis-CO4rT3Nd.js";import{V as _}from"../packem_shared/vis-user-error-BivZDkQD.js";import{d as ee}from"../packem_shared/pm-runner-Dboj-wZG.js";import{s as te}from"../packem_shared/env-BymuoTL8.js";import{U as se,V as re,C as P}from"../packem_shared/vis-update-app-PjJWvxqF.js";import{readCatalogs as ae,toFilterArray as f,checkOutdated as ne,formatSummary as j,formatOutdatedMinimal as oe,formatOutdatedTable as ce}from"./catalog2.js";import{l as ie}from"../packem_shared/npmrc-CIvOb61L.js";const $e=async({argument:R,logger:s,options:e,visConfig:o,workspaceRoot:C})=>{if(!C)throw new Error("Could not determine workspace root. Run this command inside a monorepo.");const d=C;if(e.sync&&!e.securityConfig)throw new _("--sync requires --security-config. Run `vis check --security-config --sync`.");if(e.securityConfig){const t=ee(d);if(L(o??{},t.name),e.sync&&t.name==="pnpm"){const r=J(o??{});if(r.length>0){m.info(`
1
+ import{a as L,b as J,p as m,O as G,c as A,q as T}from"./cli-main.js";import{O as H}from"../packem_shared/renderToString-DR0zDUjh-CWJW0Ktb.js";import{a as K,R as c,O as y}from"../packem_shared/registry-acz8_sxm.js";import{i as Q}from"../packem_shared/index-BjdW45xX.js";import{v as W,r as X,f as Z}from"../packem_shared/ai-analysis-CbjIaasa.js";import{V as _}from"../packem_shared/vis-user-error-B73F9C2Z.js";import{d as ee}from"../packem_shared/pm-runner-Dboj-wZG.js";import{s as te}from"../packem_shared/env-CJVZRP-o.js";import{U as se,V as re,C as P}from"../packem_shared/vis-update-app-C_wcaC7g.js";import{readCatalogs as ae,toFilterArray as f,checkOutdated as ne,formatSummary as j,formatOutdatedMinimal as oe,formatOutdatedTable as ce}from"./catalog2.js";import{l as ie}from"../packem_shared/npmrc-CIvOb61L.js";const $e=async({argument:R,logger:s,options:e,visConfig:o,workspaceRoot:C})=>{if(!C)throw new Error("Could not determine workspace root. Run this command inside a monorepo.");const d=C;if(e.sync&&!e.securityConfig)throw new _("--sync requires --security-config. Run `vis check --security-config --sync`.");if(e.securityConfig){const t=ee(d);if(L(o??{},t.name),e.sync&&t.name==="pnpm"){const r=J(o??{});if(r.length>0){m.info(`
2
2
  Settings that would sync to pnpm-workspace.yaml:`);for(const E of r)m.success(` ${E}`)}else m.info("No security settings to sync.")}else e.sync&&t.name!=="pnpm"&&(m.info(`--sync is only available for pnpm projects. Your project uses ${t.name}.`),m.info("vis enforces security settings at the vis layer for non-pnpm projects."));if(!e.security&&!R?.length)return}const{packageManager:N}=G(d),U=ie(d),i=o?.update??{},h=ae(d,N,{dev:e.dev,includeInternal:e["include-internal"],peer:e.peer,prod:e.prod});if(h.size===0){s.info("No catalogs found.");return}const w=e.target??i.target??"latest";if(!["latest","minor","patch"].includes(w))throw new Error(`Invalid target "${w}". Use: latest, minor, or patch.`);const D={exclude:[...f(e.exclude),...f(i.exclude)],ignore:f(i.ignore),include:[...f(e.include),...f(i.include),...R],includeLocked:!!e.includeLocked,includePrerelease:e.prerelease||i.prerelease||!1,security:e.security!==!1,target:w};let x=0;for(const t of h.values())x+=t.size;const k=!!process.stdout.isTTY&&!Q;let l;const I=k?(t,r)=>{l?l.rerender(c.createElement(P,{current:t,total:r})):l=T(c.createElement(P,{current:t,total:r}),{interactive:!0,patchConsole:!1})}:(t,r)=>{s.info(`Checking ${String(t)}/${String(r)} dependencies...`)};k||s.info(`Checking ${String(x)} catalog dependencies against npm registry...
3
3
  `);const g=new Set;A("socket")&&g.add("socket"),A("depsDev")&&g.add("deps-dev");const v=o?.security?.policies?.score?.minimum,M=K(o?.security,{disabled:g,minimumScore:v}),{failed:$,outdated:n}=await ne(h,D,U,I,d,M,o?.security?.acceptedRisks);if(l&&(l.clear(),l.unmount()),$.length>0&&s.warn(`Failed to fetch: ${$.join(", ")}`),n.length===0){s.info("All catalog dependencies are up to date.");return}const S=e.format??i.format??"table",V=W(e.aiType??"impact"),u=e.ai?await X(n,s,o?.ai,V):void 0;if(k&&S==="table"){const t=new se(n,u??null),r=o?.tui?.autoExit??!1,E=r===!0?3:typeof r=="number"?r:0;await T(c.createElement(re,{autoExitSeconds:E,isDryRun:!0,store:t}),{alternateScreen:!0,exitOnCtrlC:!1,interactive:!0,patchConsole:!0}).waitUntilExit();const q=process.stdout.columns||80;process.stdout.write(`
4
4
  `);for(const a of n){const B=a.vulnerabilities?.length||a.socketReport&&a.socketReport.alerts.length>0,b=!!a.acceptedRisk,Y=B?b?"✓":"⚠":"✓",z=b?"gray":a.updateType==="major"?"red":a.updateType==="minor"?"yellow":"green",p=a.socketReport?.score.overall,F=p===void 0?"":` [${String(Math.round(p*100))}%]`,O=p===void 0?void 0:te(p);process.stdout.write(`${H(c.createElement(y,null," ",c.createElement(y,{color:z},Y),` ${a.packageName} ${a.currentRange} → ${a.newRange}`,c.createElement(y,{dimColor:!0},` ${a.updateType}`),O?c.createElement(y,{color:O},F):null),{columns:q})}
@@ -1,4 +1,4 @@
1
- import{createRequire as K}from"node:module";import{j as g,F as m,q as v,J as N,X as P,b as j}from"../packem_shared/index.server-Ca_EEVfw.js";import{e as h,v as U}from"../packem_shared/index-0dnGN3GP.js";import{d as F,b as Y}from"../packem_shared/registry-CndByNx9.js";import{d as J}from"../packem_shared/lockfile-DEWjBrlY.js";import{p as z,s as X}from"../packem_shared/docker-vRDm2lHX.js";import{i as ne}from"../packem_shared/index-BjdW45xX.js";import{g as B,h as oe}from"../packem_shared/env-BymuoTL8.js";import{y as re}from"../packem_shared/isAccessibleSync-DYKTrrvc-CBsMZhj-.js";let G;const W=e=>(G??=K(import.meta.url))(e),b=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,y=e=>{if(typeof b<"u"&&b.versions&&b.versions.node){const[t,n]=b.versions.node.split(".").map(Number);if(t>22||t===22&&n>=3||t===20&&n>=16)return b.getBuiltinModule(e)}return W(e)},{createInterface:O}=y("node:readline"),{spawn:Q}=y("node:child_process"),{createHash:Z}=y("node:crypto"),{existsSync:I,writeFileSync:ee,chmodSync:te}=y("node:fs"),S={aube:{base:["RUN corepack enable"],build:e=>e?`RUN aube run --filter ${e} build`:"RUN aube run build",install:"RUN aube install --frozen-lockfile"},bun:{base:["RUN npm install -g bun"],build:e=>e?`RUN bun run --filter ${e} build`:"RUN bun run build",install:"RUN --mount=type=cache,target=/root/.bun/install/cache bun install --frozen-lockfile"},npm:{base:[],build:e=>e?`RUN npm run build --workspace ${e}`:"RUN npm run build",install:"RUN --mount=type=cache,target=/root/.npm npm ci"},pnpm:{base:["ENV PNPM_HOME=/pnpm","ENV PATH=$PNPM_HOME:$PATH","RUN corepack enable"],build:e=>e?`RUN pnpm --filter ${e} build`:"RUN pnpm build",install:"RUN --mount=type=cache,id=pnpm,target=/pnpm/store pnpm install --frozen-lockfile"},yarn:{base:["RUN corepack enable"],build:e=>e?`RUN yarn workspace ${e} build`:"RUN yarn build",install:"RUN --mount=type=cache,target=/usr/local/share/.cache/yarn yarn install --immutable"}},se=e=>{const{focus:t,manager:n,nodeVersion:r}=e,o=S[n]??S.npm;return["# syntax=docker/dockerfile:1","","# Generated by 'vis docker init'. Before building, scaffold the context:",`# vis docker scaffold${t?` --focus=${t}`:""} --include-sources`,"# then build with BuildKit enabled (DOCKER_BUILDKIT=1).","",`FROM node:${r}-slim AS base`,"WORKDIR /app",...o.base,"","# --- install dependencies from the scaffolded manifests only ---","FROM base AS deps","COPY .vis/docker/workspace/ ./",o.install,"","# --- build the focus project, then drop unfocused workspace projects ---","FROM deps AS build","COPY .vis/docker/sources/ ./",o.build(t),"RUN npx vis docker prune --context=.vis/docker","","# --- minimal runtime image ---",`FROM node:${r}-slim AS runtime`,"WORKDIR /app","ENV NODE_ENV=production","COPY --from=build /app ./","USER node","# TODO: point this at your app's entrypoint",'CMD ["node", "index.js"]',""].join(`
1
+ import{createRequire as K}from"node:module";import{j as g,F as m,q as v,J as N,X as P,b as j}from"../packem_shared/index.server-Ca_EEVfw.js";import{e as h,v as U}from"../packem_shared/index-0dnGN3GP.js";import{d as F,b as Y}from"../packem_shared/registry-acz8_sxm.js";import{d as J}from"../packem_shared/lockfile-DEWjBrlY.js";import{p as z,s as X}from"../packem_shared/docker-52xcbz7D.js";import{i as ne}from"../packem_shared/index-BjdW45xX.js";import{g as B,h as oe}from"../packem_shared/env-CJVZRP-o.js";import{y as re}from"../packem_shared/isAccessibleSync-DYKTrrvc-CBsMZhj-.js";let G;const W=e=>(G??=K(import.meta.url))(e),b=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,y=e=>{if(typeof b<"u"&&b.versions&&b.versions.node){const[t,n]=b.versions.node.split(".").map(Number);if(t>22||t===22&&n>=3||t===20&&n>=16)return b.getBuiltinModule(e)}return W(e)},{createInterface:O}=y("node:readline"),{spawn:Q}=y("node:child_process"),{createHash:Z}=y("node:crypto"),{existsSync:I,writeFileSync:ee,chmodSync:te}=y("node:fs"),S={aube:{base:["RUN corepack enable"],build:e=>e?`RUN aube run --filter ${e} build`:"RUN aube run build",install:"RUN aube install --frozen-lockfile"},bun:{base:["RUN npm install -g bun"],build:e=>e?`RUN bun run --filter ${e} build`:"RUN bun run build",install:"RUN --mount=type=cache,target=/root/.bun/install/cache bun install --frozen-lockfile"},npm:{base:[],build:e=>e?`RUN npm run build --workspace ${e}`:"RUN npm run build",install:"RUN --mount=type=cache,target=/root/.npm npm ci"},pnpm:{base:["ENV PNPM_HOME=/pnpm","ENV PATH=$PNPM_HOME:$PATH","RUN corepack enable"],build:e=>e?`RUN pnpm --filter ${e} build`:"RUN pnpm build",install:"RUN --mount=type=cache,id=pnpm,target=/pnpm/store pnpm install --frozen-lockfile"},yarn:{base:["RUN corepack enable"],build:e=>e?`RUN yarn workspace ${e} build`:"RUN yarn build",install:"RUN --mount=type=cache,target=/usr/local/share/.cache/yarn yarn install --immutable"}},se=e=>{const{focus:t,manager:n,nodeVersion:r}=e,o=S[n]??S.npm;return["# syntax=docker/dockerfile:1","","# Generated by 'vis docker init'. Before building, scaffold the context:",`# vis docker scaffold${t?` --focus=${t}`:""} --include-sources`,"# then build with BuildKit enabled (DOCKER_BUILDKIT=1).","",`FROM node:${r}-slim AS base`,"WORKDIR /app",...o.base,"","# --- install dependencies from the scaffolded manifests only ---","FROM base AS deps","COPY .vis/docker/workspace/ ./",o.install,"","# --- build the focus project, then drop unfocused workspace projects ---","FROM deps AS build","COPY .vis/docker/sources/ ./",o.build(t),"RUN npx vis docker prune --context=.vis/docker","","# --- minimal runtime image ---",`FROM node:${r}-slim AS runtime`,"WORKDIR /app","ENV NODE_ENV=production","COPY --from=build /app ./","USER node","# TODO: point this at your app's entrypoint",'CMD ["node", "index.js"]',""].join(`
2
2
  `)},$="v2.14.0",D=`https://github.com/hadolint/hadolint/releases/download/${$}`,ie={"hadolint-linux-arm64":"331f1d3511b84a4f1e3d18d52fec284723e4019552f4f47b19322a53ce9a40ed","hadolint-linux-x86_64":"6bf226944684f56c84dd014e8b979d27425c0148f61b3bd99bcc6f39e9dc5a47","hadolint-macos-arm64":"3625e2e9f43dcfe7bd38738a5f5520ed50ce39ed28485266e6803dd7bc197b10","hadolint-macos-x86_64":"2b69a853433f1eca522ffb921cd490bd1321424d03331fd8390f93b7fb4a02e9","hadolint-windows-x86_64.exe":"8e0ee174f88edb14f207a68430c7a53c2883ed509cdbde9a3a26fffa140fa5e4"},ae=e=>ie[e],ce=(e=process.platform,t=process.arch)=>{const n=e==="darwin"?"macos":e==="linux"?"linux":e==="win32"?"windows":void 0;if(n===void 0)return;const r=t==="arm64"?"arm64":t==="x64"?"x86_64":void 0;if(n==="windows")return"hadolint-windows-x86_64.exe";if(r!==void 0)return`hadolint-${n}-${r}`},L=e=>h(B(),"hadolint",$,e.endsWith(".exe")?"hadolint.exe":"hadolint"),le=()=>{const e=process.platform==="win32"?"hadolint.exe":"hadolint",t=(process.env.PATH??"").split(process.platform==="win32"?";":":");for(const n of t)if(n!==""&&I(h(n,e)))return e},de=e=>e.trim().split(/\s+/u)[0]??"",E=async e=>{const t=await fetch(e,{redirect:"follow"});if(!t.ok)throw new Error(`download failed (${String(t.status)} ${t.statusText}) for ${e}`);return Buffer.from(await t.arrayBuffer())},ue=async e=>{const t=L(e),n=ae(e),r=await E(`${D}/${e}`),o=Z("sha256").update(r).digest("hex");if(n===void 0){const s=await E(`${D}/${e}.sha256`),i=de(s.toString("utf8")).toLowerCase();if(i==="")throw new Error("hadolint checksum sidecar was empty or unparseable. Refusing to use the download.");if(i!==o)throw new Error(`hadolint checksum mismatch (expected ${i}, got ${o}). Refusing to use the download.`)}else if(n.toLowerCase()!==o)throw new Error(`hadolint checksum mismatch (expected ${n.toLowerCase()}, got ${o}). Refusing to use the download.`);return oe(h(B(),"hadolint",$)),ee(t,r),process.platform!=="win32"&&te(t,493),t},fe=async()=>{const e=O({input:process.stdin,output:process.stderr}),t=await new Promise(n=>{e.question(` Download hadolint ${v($)} now? ${m("[y/N]")} `,r=>{n(r.trim().toLowerCase())})});return e.close(),t==="y"||t==="yes"},pe=async e=>{const{autoInstall:t=!1,log:n}=e,r=le();if(r!==void 0)return r;const o=ce();if(o===void 0){n(`hadolint has no prebuilt binary for ${process.platform}/${process.arch}. Install it manually: https://github.com/hadolint/hadolint`);return}const s=L(o);if(I(s))return s;if(!t){if(!(!!process.stdin.isTTY&&!ne)){n(`hadolint is not installed. Re-run with ${g("--install")} (or install hadolint on PATH) to enable Dockerfile linting.`);return}if(n(`${g("hadolint")} is required to lint Dockerfiles but was not found on your PATH.`),!await fe()){n(`Skipped. Install it yourself or re-run with ${g("--install")}.`);return}}n(`Downloading hadolint ${$} (${o})…`);try{const i=await ue(o);return n(`Installed hadolint to ${m(i)}`),i}catch(i){n(`Failed to download hadolint: ${i.message}`);return}},_=async(e,t,n)=>{if(t.length===0)return[];const r=["--format","json","--no-fail",...n!==void 0&&n!==""?["--config",n]:[],...t],o=await new Promise((i,l)=>{const a=Q(e,r,{stdio:["ignore","pipe","pipe"],windowsHide:!0});let d="",u="";a.stdout?.on("data",c=>{d+=c.toString("utf8")}),a.stderr?.on("data",c=>{u+=c.toString("utf8")}),a.on("error",l),a.on("close",()=>{if(d.trim()===""&&u.trim()!==""){l(new Error(u.trim()));return}i(d)})});if(o.trim()==="")return[];let s;try{s=JSON.parse(o)}catch{throw new Error("Could not parse hadolint JSON output.")}return Array.isArray(s)?s:[]},C=(e,t,n)=>{if(!(!/\bapt-get\b/u.test(e)||!/\binstall\b/u.test(e)||n.test(e)))return e.replace(/\binstall\b/u,`install ${t}`)},k={DL3014:e=>C(e,"-y",/(?:^|\s)(?:-y|--yes|--assume-yes|-qq?)\b/u),DL3015:e=>C(e,"--no-install-recommends",/--no-install-recommends\b/u),DL3020:e=>/^\s*ADD\b/u.test(e)?e.replace(/^(\s*)ADD\b/u,"$1COPY"):void 0,DL3027:e=>/(?:^|\s)apt\s/u.test(e)&&!/\bapt-get\b/u.test(e)?e.replace(/(^|\s)apt(\s)/u,"$1apt-get$2"):void 0},T=new Set(Object.keys(k)),me=(e,t)=>{const n=e.includes(`\r
3
3
  `)?`\r
4
4
  `:`
@@ -1,3 +1,3 @@
1
- import{createRequire as H}from"node:module";import{J as A,q as G,j as E,F as O}from"../packem_shared/index.server-Ca_EEVfw.js";import{a as P}from"../packem_shared/index-0dnGN3GP.js";import{R as I}from"./cli-main.js";import{w as Q,r as X,a as Y,s as Z,c as ee,b as te,d as se,e as ie,f as ne,g as re,h as ae,i as oe,j as ce,k as de,l as fe,m as le,n as ue}from"../packem_shared/watch-loop-dWYGUQwi.js";import{v as h}from"../packem_shared/registry-CndByNx9.js";import{d as C,f as _,a as pe}from"../packem_shared/detect-C-9o_BPB.js";let J;const U=e=>(J??=H(import.meta.url))(e),w=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,D=e=>{if(typeof w<"u"&&w.versions&&w.versions.node){const[t,s]=w.versions.node.split(".").map(Number);if(t>22||t===22&&s>=3||t===20&&s>=16)return w.getBuiltinModule(e)}return U(e)},{createHash:F}=D("node:crypto"),ge=e=>e.startsWith("/")||/^[a-z]:[\\/]/i.test(e),q=(e,t)=>ge(t)?t:`${e}/${t}`,me={argsCheck:(e,t)=>T(e,t,"check"),argsFix:(e,t)=>T(e,t,"fix"),bin:()=>["pnpm","exec","dprint"],cacheKey:(e,t)=>{const s=["dprint",e.declaredVersion??"unknown",e.configFile??"no-config",t.quiet?"q":"",...t.extraArgs??[]];return F("sha256").update(s.join("|")).digest("hex").slice(0,16)},detect:(e,t)=>{const s=C(t,h.dprint.packageNames[0]),i=_(e,h.dprint.configFiles);if(!(!s&&!i))return{adapter:"dprint",configFile:i,declared:!!s,declaredVersion:s,root:e}},extensions:["cjs","css","cts","dockerfile","html","js","json","jsonc","jsx","md","mdx","mjs","mts","toml","ts","tsx","yaml","yml"],id:"dprint",kind:"fmt",parse:(e,t)=>{if(e.exitCode===0)return[];const s=[];for(const i of e.stdout.split(/\r?\n/)){const n=i.trim();!n||n.startsWith("[")||n.startsWith("Checked ")||n.startsWith("Error:")||s.push({adapter:"dprint",file:q(t.root,n),fixable:!0,message:"Code style issues would be auto-fixed",severity:"info"})}return s}},T=(e,t,s)=>{const i=s==="fix"?["fmt"]:["check","--list-different"];return t.extraArgs?.length&&i.push(...t.extraArgs),i.push(...e),i},he={argsCheck:(e,t)=>V(e,t,"check"),argsFix:(e,t)=>V(e,t,"fix"),bin:()=>["pnpm","exec","oxfmt"],cacheKey:(e,t)=>{const s=["oxfmt",e.declaredVersion??"unknown",e.configFile??"no-config",t.quiet?"q":"",...t.extraArgs??[]];return F("sha256").update(s.join("|")).digest("hex").slice(0,16)},detect:(e,t)=>{const s=C(t,h.oxfmt.packageNames[0]),i=_(e,h.oxfmt.configFiles);if(!(!s&&!i))return{adapter:"oxfmt",configFile:i,declared:!!s,declaredVersion:s,root:e}},extensions:["cjs","cts","js","json","jsonc","jsx","mjs","mts","ts","tsx"],id:"oxfmt",kind:"fmt",parse:(e,t)=>{if(e.exitCode===0)return[];const s=[];for(const i of e.stdout.split(/\r?\n/)){const n=i.trim();!n||n.startsWith("[")||s.push({adapter:"oxfmt",file:q(t.root,n),fixable:!0,message:"Code style issues would be auto-fixed",severity:"info"})}return s}},V=(e,t,s)=>{const i=s==="fix"?["--write"]:["--list-different"];return t.extraArgs?.length&&i.push(...t.extraArgs),i.push(...e),i},xe={argsCheck:(e,t)=>N(e,t,"check"),argsFix:(e,t)=>N(e,t,"fix"),bin:()=>["pnpm","exec","prettier"],cacheKey:(e,t)=>{const s=["prettier",e.declaredVersion??"unknown",e.configFile??"no-config",t.quiet?"q":"",...t.extraArgs??[]];return F("sha256").update(s.join("|")).digest("hex").slice(0,16)},detect:(e,t)=>{const s=C(t,h.prettier.packageNames[0]),i=_(e,h.prettier.configFiles);if(!(!s&&!i))return{adapter:"prettier",configFile:i,declared:!!s,declaredVersion:s,root:e}},extensions:["cjs","css","cts","html","js","json","jsx","less","md","mdx","mjs","mts","scss","ts","tsx","vue","yaml","yml"],id:"prettier",kind:"fmt",parse:(e,t)=>{if(e.exitCode===0)return[];const s=[];for(const i of e.stdout.split(/\r?\n/)){const n=i.trim();n&&(n.startsWith("[")||s.push({adapter:"prettier",file:q(t.root,n),fixable:!0,message:"Code style issues would be auto-fixed",severity:"info"}))}return s}},N=(e,t,s)=>{const i=s==="fix"?["--write"]:["--list-different"];return t.quiet&&i.push("--log-level","warn"),t.extraArgs?.length&&i.push(...t.extraArgs),i.push(...e),i},we=[he,se,me,xe,ie],$e=async({logger:e,options:t,visConfig:s,workspaceRoot:i})=>{const n=i??process.cwd(),l=s?.fmt;Q(e,"fmt",l);const k=X(we,l?.order),L=pe(n,k),x=Y(L,k,"fmt").filter(({adapter:u})=>l?.adapters?.[u.id]?.enabled!==!1);if(x.length===0){e.warn("vis fmt: no formatter detected in this workspace (looked for: oxfmt, biome, dprint, prettier, ruff).");return}const R=u=>{const a=l?.adapters?.[u]?.extraArgs;return a&&a.length>0?[...a]:void 0},v={quiet:t.quiet??!1},$=ke(t),b=t.check?"check":"fix";let c;if(t.staged){if(c=Z(n),c===void 0)e.warn("vis fmt: could not resolve --staged (not a git repo or git unavailable). Falling back to a workspace-wide run.");else if(c.length===0){e.info(A("✓ fmt: no staged files"));return}}else if(typeof t.since=="string"&&t.since.length>0){if(c=ee(n,t.since),c===void 0)e.warn(`vis fmt: could not resolve --since ${t.since} (not a git repo or unknown ref). Falling back to a workspace-wide run.`);else if(c.length===0){e.info(A(`✓ fmt: no files changed since ${t.since}`));return}}const K=I(n,void 0,void 0,!0),y=t.format??"human";y==="human"&&t.output!==void 0&&e.warn("vis fmt: --output is ignored for the human format; pass --format json|minimal|sarif|junit|github to redirect findings to a file.");const M=async u=>{const a=$.length>0?$:u,g=[];if(a){const r=ne(a,x,l?.extensionOverrides);for(const{adapter:o,presence:d}of x){const f=r.get(o.id);if(!f||f.length===0)continue;const B=R(o.id),W={adapter:o,files:f,presence:d};B&&(W.options={...v,extraArgs:B}),g.push(W)}}else for(const{adapter:r,presence:o}of x){const d=R(r.id),f={adapter:r,files:["."],presence:o};d&&(f.options={...v,extraArgs:d}),g.push(f)}if(g.length===0)return;const z=await re(g,v,b,{cacheRoot:K}),j=g.map((r,o)=>{const d=z[o],f=r.adapter.parse(d,r.presence);return{adapter:r.adapter,durationMs:d.durationMs,exitCode:d.exitCode,findings:f}}),p=ae(j.map(r=>({adapter:r.adapter.id,durationMs:r.durationMs,exitCode:r.exitCode,findingCount:r.findings.length,findings:r.findings}))),m=y==="human"?void 0:oe({cwd:n,target:t.output});try{switch(y){case"github":{m.write(fe({runs:j.map(r=>({findings:r.findings})),workspaceRoot:n}));break}case"json":{m.write(`${JSON.stringify({findings:p.findings,mode:b,runs:p.runs},null,2)}
1
+ import{createRequire as H}from"node:module";import{J as A,q as G,j as E,F as O}from"../packem_shared/index.server-Ca_EEVfw.js";import{a as P}from"../packem_shared/index-0dnGN3GP.js";import{R as I}from"./cli-main.js";import{w as Q,r as X,a as Y,s as Z,c as ee,b as te,d as se,e as ie,f as ne,g as re,h as ae,i as oe,j as ce,k as de,l as fe,m as le,n as ue}from"../packem_shared/watch-loop-BeyVtDyD.js";import{v as h}from"../packem_shared/registry-acz8_sxm.js";import{d as C,f as _,a as pe}from"../packem_shared/detect-DSMoIgaH.js";let J;const U=e=>(J??=H(import.meta.url))(e),w=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,D=e=>{if(typeof w<"u"&&w.versions&&w.versions.node){const[t,s]=w.versions.node.split(".").map(Number);if(t>22||t===22&&s>=3||t===20&&s>=16)return w.getBuiltinModule(e)}return U(e)},{createHash:F}=D("node:crypto"),ge=e=>e.startsWith("/")||/^[a-z]:[\\/]/i.test(e),q=(e,t)=>ge(t)?t:`${e}/${t}`,me={argsCheck:(e,t)=>T(e,t,"check"),argsFix:(e,t)=>T(e,t,"fix"),bin:()=>["pnpm","exec","dprint"],cacheKey:(e,t)=>{const s=["dprint",e.declaredVersion??"unknown",e.configFile??"no-config",t.quiet?"q":"",...t.extraArgs??[]];return F("sha256").update(s.join("|")).digest("hex").slice(0,16)},detect:(e,t)=>{const s=C(t,h.dprint.packageNames[0]),i=_(e,h.dprint.configFiles);if(!(!s&&!i))return{adapter:"dprint",configFile:i,declared:!!s,declaredVersion:s,root:e}},extensions:["cjs","css","cts","dockerfile","html","js","json","jsonc","jsx","md","mdx","mjs","mts","toml","ts","tsx","yaml","yml"],id:"dprint",kind:"fmt",parse:(e,t)=>{if(e.exitCode===0)return[];const s=[];for(const i of e.stdout.split(/\r?\n/)){const n=i.trim();!n||n.startsWith("[")||n.startsWith("Checked ")||n.startsWith("Error:")||s.push({adapter:"dprint",file:q(t.root,n),fixable:!0,message:"Code style issues would be auto-fixed",severity:"info"})}return s}},T=(e,t,s)=>{const i=s==="fix"?["fmt"]:["check","--list-different"];return t.extraArgs?.length&&i.push(...t.extraArgs),i.push(...e),i},he={argsCheck:(e,t)=>V(e,t,"check"),argsFix:(e,t)=>V(e,t,"fix"),bin:()=>["pnpm","exec","oxfmt"],cacheKey:(e,t)=>{const s=["oxfmt",e.declaredVersion??"unknown",e.configFile??"no-config",t.quiet?"q":"",...t.extraArgs??[]];return F("sha256").update(s.join("|")).digest("hex").slice(0,16)},detect:(e,t)=>{const s=C(t,h.oxfmt.packageNames[0]),i=_(e,h.oxfmt.configFiles);if(!(!s&&!i))return{adapter:"oxfmt",configFile:i,declared:!!s,declaredVersion:s,root:e}},extensions:["cjs","cts","js","json","jsonc","jsx","mjs","mts","ts","tsx"],id:"oxfmt",kind:"fmt",parse:(e,t)=>{if(e.exitCode===0)return[];const s=[];for(const i of e.stdout.split(/\r?\n/)){const n=i.trim();!n||n.startsWith("[")||s.push({adapter:"oxfmt",file:q(t.root,n),fixable:!0,message:"Code style issues would be auto-fixed",severity:"info"})}return s}},V=(e,t,s)=>{const i=s==="fix"?["--write"]:["--list-different"];return t.extraArgs?.length&&i.push(...t.extraArgs),i.push(...e),i},xe={argsCheck:(e,t)=>N(e,t,"check"),argsFix:(e,t)=>N(e,t,"fix"),bin:()=>["pnpm","exec","prettier"],cacheKey:(e,t)=>{const s=["prettier",e.declaredVersion??"unknown",e.configFile??"no-config",t.quiet?"q":"",...t.extraArgs??[]];return F("sha256").update(s.join("|")).digest("hex").slice(0,16)},detect:(e,t)=>{const s=C(t,h.prettier.packageNames[0]),i=_(e,h.prettier.configFiles);if(!(!s&&!i))return{adapter:"prettier",configFile:i,declared:!!s,declaredVersion:s,root:e}},extensions:["cjs","css","cts","html","js","json","jsx","less","md","mdx","mjs","mts","scss","ts","tsx","vue","yaml","yml"],id:"prettier",kind:"fmt",parse:(e,t)=>{if(e.exitCode===0)return[];const s=[];for(const i of e.stdout.split(/\r?\n/)){const n=i.trim();n&&(n.startsWith("[")||s.push({adapter:"prettier",file:q(t.root,n),fixable:!0,message:"Code style issues would be auto-fixed",severity:"info"}))}return s}},N=(e,t,s)=>{const i=s==="fix"?["--write"]:["--list-different"];return t.quiet&&i.push("--log-level","warn"),t.extraArgs?.length&&i.push(...t.extraArgs),i.push(...e),i},we=[he,se,me,xe,ie],$e=async({logger:e,options:t,visConfig:s,workspaceRoot:i})=>{const n=i??process.cwd(),l=s?.fmt;Q(e,"fmt",l);const k=X(we,l?.order),L=pe(n,k),x=Y(L,k,"fmt").filter(({adapter:u})=>l?.adapters?.[u.id]?.enabled!==!1);if(x.length===0){e.warn("vis fmt: no formatter detected in this workspace (looked for: oxfmt, biome, dprint, prettier, ruff).");return}const R=u=>{const a=l?.adapters?.[u]?.extraArgs;return a&&a.length>0?[...a]:void 0},v={quiet:t.quiet??!1},$=ke(t),b=t.check?"check":"fix";let c;if(t.staged){if(c=Z(n),c===void 0)e.warn("vis fmt: could not resolve --staged (not a git repo or git unavailable). Falling back to a workspace-wide run.");else if(c.length===0){e.info(A("✓ fmt: no staged files"));return}}else if(typeof t.since=="string"&&t.since.length>0){if(c=ee(n,t.since),c===void 0)e.warn(`vis fmt: could not resolve --since ${t.since} (not a git repo or unknown ref). Falling back to a workspace-wide run.`);else if(c.length===0){e.info(A(`✓ fmt: no files changed since ${t.since}`));return}}const K=I(n,void 0,void 0,!0),y=t.format??"human";y==="human"&&t.output!==void 0&&e.warn("vis fmt: --output is ignored for the human format; pass --format json|minimal|sarif|junit|github to redirect findings to a file.");const M=async u=>{const a=$.length>0?$:u,g=[];if(a){const r=ne(a,x,l?.extensionOverrides);for(const{adapter:o,presence:d}of x){const f=r.get(o.id);if(!f||f.length===0)continue;const B=R(o.id),W={adapter:o,files:f,presence:d};B&&(W.options={...v,extraArgs:B}),g.push(W)}}else for(const{adapter:r,presence:o}of x){const d=R(r.id),f={adapter:r,files:["."],presence:o};d&&(f.options={...v,extraArgs:d}),g.push(f)}if(g.length===0)return;const z=await re(g,v,b,{cacheRoot:K}),j=g.map((r,o)=>{const d=z[o],f=r.adapter.parse(d,r.presence);return{adapter:r.adapter,durationMs:d.durationMs,exitCode:d.exitCode,findings:f}}),p=ae(j.map(r=>({adapter:r.adapter.id,durationMs:r.durationMs,exitCode:r.exitCode,findingCount:r.findings.length,findings:r.findings}))),m=y==="human"?void 0:oe({cwd:n,target:t.output});try{switch(y){case"github":{m.write(fe({runs:j.map(r=>({findings:r.findings})),workspaceRoot:n}));break}case"json":{m.write(`${JSON.stringify({findings:p.findings,mode:b,runs:p.runs},null,2)}
2
2
  `);break}case"junit":{m.write(de({runs:j.map(r=>({adapter:r.adapter.id,durationMs:r.durationMs,findings:r.findings})),workspaceRoot:n}));break}case"minimal":{je(p.findings,n,m);break}case"sarif":{m.write(ce({runs:j.map(r=>({adapter:r.adapter.id,findings:r.findings,presence:g.find(o=>o.adapter.id===r.adapter.id)?.presence})),workspaceRoot:n}));break}default:be(p.findings,n,b,e)}}finally{m?.close()}const S=b==="fix"?p.hadProcessFailure?1:0:le({...p,maxSeverity:p.findings.length>0?"error":void 0});S!==0&&(process.exitCode=S)};if(t.watch){const u=[...new Set(x.flatMap(({adapter:a})=>a.extensions))];await te({extensions:u,initialFiles:c,label:"fmt",log:a=>{e.info(a)},runCycle:M,workspaceRoot:n});return}await M(c)},ke=e=>{const t=e;return[...t._??t.args??[]]},be=(e,t,s,i)=>{if(e.length===0){i.info(A(s==="fix"?"✓ fmt: nothing to change":"✓ fmt: all files already formatted"));return}const n=ue(e),l=s==="fix"?G(E("Formatted:")):E("Would change:");i.info(l);for(const k of n.keys())i.info(` ${O("·")} ${P(t,k)}`);s==="check"&&(i.info(""),i.info(O(`Run \`vis fmt\` to apply changes (${String(n.size)} file${n.size===1?"":"s"}).`)))},je=(e,t,s)=>{for(const i of e)s.write(`${i.adapter} ${P(t,i.file)}
3
3
  `)};export{$e as default};
@@ -1,4 +1,4 @@
1
- import{createRequire as re}from"node:module";import{F as d,j as y,q as v}from"../packem_shared/index.server-Ca_EEVfw.js";import{e as E,m as J,a as z,v as F,l as oe,U as ie}from"../packem_shared/index-0dnGN3GP.js";import{y as _}from"../packem_shared/isAccessibleSync-DYKTrrvc-CBsMZhj-.js";import{L as K}from"../packem_shared/registry-CndByNx9.js";import{p as f}from"./cli-main.js";import{d as de}from"../packem_shared/git-source-DExWbfN0.js";import{h as X,U as me}from"../packem_shared/env-BymuoTL8.js";let se;const ne=t=>(se??=re(import.meta.url))(t),O=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,k=t=>{if(typeof O<"u"&&O.versions&&O.versions.node){const[e,r]=O.versions.node.split(".").map(Number);if(e>22||e===22&&r>=3||e===20&&r>=16)return O.getBuiltinModule(t)}return ne(t)},{fileURLToPath:ae}=k("node:url"),{createInterface:ce}=k("node:readline"),{mkdtempSync:le,rmSync:fe}=k("node:fs"),{tmpdir:ue}=k("node:os"),{spawnSync:pe}=k("node:child_process"),Y=[".ts",".mts",".cts",".js",".mjs",".cjs"],he="template.yml",ge=[".d",".test",".spec",".config",".bench",".stories"],we=[".d.ts",".d.mts",".d.cts",".js.map",".mjs.map",".cjs.map",".ts.map"],G=t=>{for(const e of Y)if(t.endsWith(e))return t.slice(0,-e.length);return t},$e=t=>{if(we.some(r=>t.endsWith(r))||!Y.some(r=>t.endsWith(r)))return!1;const e=G(t);return!ge.some(r=>e.endsWith(r))},U=(t,e)=>{const r=[];if(!_(t))return r;for(const n of K(t,{includeDirs:!1,includeSymlinks:!1,maxDepth:1})){if(!$e(n.name))continue;const s=G(n.name);r.push({load:()=>ve(n.path),name:s,path:n.path,source:e})}return r},R=(t,e)=>{const r=[];if(!_(t))return r;for(const n of K(t,{includeFiles:!1,includeSymlinks:!1,maxDepth:1})){if(n.path===t)continue;const s=E(n.path,he);_(s)&&r.push({load:()=>be(n.path,n.name),name:n.name,path:n.path,source:e})}return r},ye=()=>{try{const t=ae(import.meta.url),e=E(J(t),"..","..","templates");return _(e)?e:void 0}catch{return}},I=t=>{const{extraDirectories:e=[],onWarning:r,workspaceRoot:n}=t,s=[...U(E(n,".vis","templates"),"native"),...R(E(n,".vis","templates"),"moon"),...R(E(n,".moon","templates"),"moon")];for(const c of e)s.push(...R(c,"config")),s.push(...U(c,"config"));const i=ye();i&&s.push(...R(i,"builtin"));const a=new Map;for(const c of s){const o=a.get(c.name);if(!o){a.set(c.name,c);continue}r&&r(`Template "${c.name}" exists in multiple sources — using ${o.source} (${o.path}), ignoring ${c.source} (${c.path}).`)}return[...a.values()].sort((c,o)=>c.name.localeCompare(o.name))},ve=async t=>{const{loadNativeTemplate:e}=await import("./loader2.js");return e(t)},be=async(t,e)=>{const{loadMoonTemplate:r}=await import("./index7.js");return r(t,e)},q=(t,e)=>new Promise(r=>{t.question(e,n=>{r(n.trim())})}),Se=async(t,e,r)=>{const s=await q(t,` ${e} ${d(r?"[Y/n]":"[y/N]")} `);return s===""?r:s.toLowerCase()==="y"||s.toLowerCase()==="yes"},Ee=async(t,e,r,n)=>{process.stderr.write(` ${e}
1
+ import{createRequire as re}from"node:module";import{F as d,j as y,q as v}from"../packem_shared/index.server-Ca_EEVfw.js";import{e as E,m as J,a as z,v as F,l as oe,U as ie}from"../packem_shared/index-0dnGN3GP.js";import{y as _}from"../packem_shared/isAccessibleSync-DYKTrrvc-CBsMZhj-.js";import{L as K}from"../packem_shared/registry-acz8_sxm.js";import{p as f}from"./cli-main.js";import{d as de}from"../packem_shared/git-source-DExWbfN0.js";import{h as X,U as me}from"../packem_shared/env-CJVZRP-o.js";let se;const ne=t=>(se??=re(import.meta.url))(t),O=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,k=t=>{if(typeof O<"u"&&O.versions&&O.versions.node){const[e,r]=O.versions.node.split(".").map(Number);if(e>22||e===22&&r>=3||e===20&&r>=16)return O.getBuiltinModule(t)}return ne(t)},{fileURLToPath:ae}=k("node:url"),{createInterface:ce}=k("node:readline"),{mkdtempSync:le,rmSync:fe}=k("node:fs"),{tmpdir:ue}=k("node:os"),{spawnSync:pe}=k("node:child_process"),Y=[".ts",".mts",".cts",".js",".mjs",".cjs"],he="template.yml",ge=[".d",".test",".spec",".config",".bench",".stories"],we=[".d.ts",".d.mts",".d.cts",".js.map",".mjs.map",".cjs.map",".ts.map"],G=t=>{for(const e of Y)if(t.endsWith(e))return t.slice(0,-e.length);return t},$e=t=>{if(we.some(r=>t.endsWith(r))||!Y.some(r=>t.endsWith(r)))return!1;const e=G(t);return!ge.some(r=>e.endsWith(r))},U=(t,e)=>{const r=[];if(!_(t))return r;for(const n of K(t,{includeDirs:!1,includeSymlinks:!1,maxDepth:1})){if(!$e(n.name))continue;const s=G(n.name);r.push({load:()=>ve(n.path),name:s,path:n.path,source:e})}return r},R=(t,e)=>{const r=[];if(!_(t))return r;for(const n of K(t,{includeFiles:!1,includeSymlinks:!1,maxDepth:1})){if(n.path===t)continue;const s=E(n.path,he);_(s)&&r.push({load:()=>be(n.path,n.name),name:n.name,path:n.path,source:e})}return r},ye=()=>{try{const t=ae(import.meta.url),e=E(J(t),"..","..","templates");return _(e)?e:void 0}catch{return}},I=t=>{const{extraDirectories:e=[],onWarning:r,workspaceRoot:n}=t,s=[...U(E(n,".vis","templates"),"native"),...R(E(n,".vis","templates"),"moon"),...R(E(n,".moon","templates"),"moon")];for(const c of e)s.push(...R(c,"config")),s.push(...U(c,"config"));const i=ye();i&&s.push(...R(i,"builtin"));const a=new Map;for(const c of s){const o=a.get(c.name);if(!o){a.set(c.name,c);continue}r&&r(`Template "${c.name}" exists in multiple sources — using ${o.source} (${o.path}), ignoring ${c.source} (${c.path}).`)}return[...a.values()].sort((c,o)=>c.name.localeCompare(o.name))},ve=async t=>{const{loadNativeTemplate:e}=await import("./loader2.js");return e(t)},be=async(t,e)=>{const{loadMoonTemplate:r}=await import("./index7.js");return r(t,e)},q=(t,e)=>new Promise(r=>{t.question(e,n=>{r(n.trim())})}),Se=async(t,e,r)=>{const s=await q(t,` ${e} ${d(r?"[Y/n]":"[y/N]")} `);return s===""?r:s.toLowerCase()==="y"||s.toLowerCase()==="yes"},Ee=async(t,e,r,n)=>{process.stderr.write(` ${e}
2
2
  `);for(const[s,i]of r.entries()){const a=y(v(` ${String(s+1)}.`)),c=i===n?d(" (default)"):"";process.stderr.write(`${a} ${i}${c}
3
3
  `)}for(;;){const s=await q(t,`
4
4
  ${d(`Enter choice (1-${String(r.length)}):`)} `);if(s===""&&n!==void 0)return n;const i=Number.parseInt(s,10);if(Number.isInteger(i)&&i>=1&&i<=r.length)return r[i-1];const a=r.find(c=>c===s);if(a)return a;process.stderr.write(` ${d("Invalid choice. Try again.")}
@@ -1,2 +1,2 @@
1
- import{j as I,q as F,F as S}from"../packem_shared/index.server-Ca_EEVfw.js";import{projectGraphToDot as W}from"@visulima/task-runner";import{L as X,M as Q,N as J,K,C as z,P as Z,Q as L,q as ee}from"./cli-main.js";import{i as te}from"../packem_shared/index-BjdW45xX.js";import{j as e,X as l,O as t,r as C,d as re,b as se,R as le}from"../packem_shared/registry-CndByNx9.js";const ie={application:0,library:3,service:1,tool:2},M=c=>ie[c]??Number.MAX_SAFE_INTEGER,ne=c=>{const r=new Map;for(const[o,s]of Object.entries(c.dependencies))for(const i of s){const n=r.get(i.target)??[];n.push(o),r.set(i.target,n)}return Object.values(c.nodes).map(o=>({deps:c.dependencies[o.name]??[],name:o.name,reverseDeps:r.get(o.name)??[],type:o.type})).sort((o,s)=>o.type!==s.type?M(o.type)-M(s.type):o.name.localeCompare(s.name))},oe=(c,r,o)=>{let s=c;if(r==="app"?s=s.filter(i=>i.type==="application"):r==="lib"&&(s=s.filter(i=>i.type!=="application")),o){const i=o.toLowerCase();s=s.filter(n=>n.name.toLowerCase().includes(i))}return s};class ce{#e;#r=new Set;#s;constructor(r){this.#s=r;const o=ne(r);this.#e={allNodes:o,filterActive:!1,filterText:"",filterType:"all",focusedPanel:"list",selectedIndex:0}}getSnapshot=()=>this.#e;subscribe=r=>(this.#r.add(r),()=>{this.#r.delete(r)});getFilteredNodes(){return oe(this.#e.allNodes,this.#e.filterType,this.#e.filterText)}getStats(){const r=this.#e.allNodes.filter(i=>i.type==="application").length,o=this.#e.allNodes.length,s=Object.values(this.#s.dependencies).reduce((i,n)=>i+n.length,0);return{apps:r,deps:s,libs:o-r,total:o}}setSelectedIndex(r){const o=this.getFilteredNodes(),s=o.length===0?-1:Math.max(0,Math.min(r,o.length-1));s!==this.#e.selectedIndex&&this.#t({...this.#e,selectedIndex:s})}setFocusedPanel(r){r!==this.#e.focusedPanel&&this.#t({...this.#e,focusedPanel:r})}setFilterType(r){r!==this.#e.filterType&&this.#t({...this.#e,filterType:r,selectedIndex:0})}setFilter(r){this.#t({...this.#e,filterText:r,selectedIndex:0})}setFilterActive(r){r!==this.#e.filterActive&&this.#t({...this.#e,filterActive:r,filterText:r?this.#e.filterText:"",selectedIndex:r?this.#e.selectedIndex:0})}#t(r){this.#e=r;for(const o of this.#r)try{o()}catch{}}}const de=({focused:c,node:r,scrollRef:o})=>{const s=c?"white":"gray";if(!r)return e.jsx(l,{alignItems:"center",borderColor:"gray",borderStyle:"single",flexDirection:"column",flexGrow:1,justifyContent:"center",children:e.jsx(t,{dimColor:!0,children:"No project selected"})});const i=r.type==="application",n=i?"yellow":"cyan",T=i?"Application":"Library";return e.jsx(l,{borderColor:s,borderStyle:"single",borderTopRightTitle:` ${T} `,borderTopTitle:` ${r.name} `,flexDirection:"column",flexGrow:1,children:e.jsxs(X,{flexGrow:1,flexShrink:1,paddingX:2,ref:o,scrollbar:!0,scrollbarColor:"gray",children:[e.jsxs(l,{flexDirection:"column",marginTop:1,children:[e.jsxs(l,{children:[e.jsx(t,{dimColor:!0,children:"── "}),e.jsx(t,{bold:!0,color:"white",children:"DEPENDS ON"}),e.jsxs(t,{dimColor:!0,children:[" ","(",r.deps.length,")"]})]}),r.deps.length===0?e.jsx(l,{marginTop:1,paddingLeft:2,children:e.jsx(t,{dimColor:!0,children:"No dependencies"})}):e.jsx(l,{flexDirection:"column",marginTop:1,children:r.deps.map(h=>e.jsxs(l,{gap:1,paddingLeft:2,children:[e.jsx(t,{color:"cyan",children:"→"}),e.jsx(t,{children:h.target}),h.type!=="static"&&e.jsxs(t,{dimColor:!0,children:["(",h.type,")"]})]},h.target))})]}),e.jsxs(l,{flexDirection:"column",marginTop:1,children:[e.jsxs(l,{children:[e.jsx(t,{dimColor:!0,children:"── "}),e.jsx(t,{bold:!0,color:"white",children:"REQUIRED BY"}),e.jsxs(t,{dimColor:!0,children:[" ","(",r.reverseDeps.length,")"]})]}),r.reverseDeps.length===0?e.jsx(l,{marginTop:1,paddingLeft:2,children:e.jsx(t,{dimColor:!0,children:"No reverse dependencies"})}):e.jsx(l,{flexDirection:"column",marginTop:1,children:r.reverseDeps.map(h=>e.jsxs(l,{gap:1,paddingLeft:2,children:[e.jsx(t,{color:"magenta",children:"←"}),e.jsx(t,{children:h})]},h))})]}),e.jsxs(l,{flexDirection:"column",marginTop:1,children:[e.jsxs(l,{children:[e.jsx(t,{dimColor:!0,children:"── "}),e.jsx(t,{bold:!0,color:"white",children:"INFO"})]}),e.jsxs(l,{flexDirection:"column",marginTop:1,paddingLeft:2,children:[e.jsxs(l,{children:[e.jsx(l,{width:16,children:e.jsx(t,{dimColor:!0,children:"Type:"})}),e.jsx(t,{color:n,children:T})]}),e.jsxs(l,{children:[e.jsx(l,{width:16,children:e.jsx(t,{dimColor:!0,children:"Dependencies:"})}),e.jsx(t,{children:String(r.deps.length)})]}),e.jsxs(l,{children:[e.jsx(l,{width:16,children:e.jsx(t,{dimColor:!0,children:"Required by:"})}),e.jsx(t,{children:String(r.reverseDeps.length)})]}),e.jsxs(l,{children:[e.jsx(l,{width:16,children:e.jsx(t,{dimColor:!0,children:"Connectivity:"})}),e.jsx(t,{children:String(r.deps.length+r.reverseDeps.length)})]})]})]})]})})},ae=[{key:"all",label:"All",shortcut:"1"},{key:"app",label:"Apps",shortcut:"2"},{key:"lib",label:"Libs",shortcut:"3"}],O=({isSelected:c,node:r})=>{const o=r.type==="application",s=o?"yellow":"cyan",i=o?"app":"lib";return e.jsxs(l,{flexShrink:0,height:1,children:[e.jsxs(t,{children:[c?"▶":" "," "]}),e.jsx(l,{flexGrow:1,children:e.jsx(t,{bold:c,inverse:c,wrap:"truncate",children:r.name})}),e.jsxs(t,{color:s,children:[" ",i]}),e.jsxs(t,{dimColor:!0,children:[" ","→",r.deps.length," ","←",r.reverseDeps.length]})]})},G=({count:c,label:r})=>e.jsxs(l,{flexShrink:0,height:1,marginTop:1,children:[e.jsxs(t,{dimColor:!0,children:["▼"," "]}),e.jsx(t,{bold:!0,color:"white",children:r.toUpperCase()}),e.jsxs(t,{dimColor:!0,children:[" ","(",c,")"]})]}),he=({filterActive:c,filterText:r,filterType:o,focused:s,nodes:i,scrollOffset:n,selectedIndex:T,stats:h,viewportHeight:w})=>{const u=s?"white":"gray",b=i.filter(f=>f.type==="application"),a=i.filter(f=>f.type!=="application"),j=[];let x=0;if(b.length>0){j.push(e.jsx(G,{count:b.length,label:"Applications"},"hdr-apps"));for(const f of b){const y=x;j.push(e.jsx(O,{isSelected:y===T,node:f},f.name)),x++}}if(a.length>0){j.push(e.jsx(G,{count:a.length,label:"Libraries"},"hdr-libs"));for(const f of a){const y=x;j.push(e.jsx(O,{isSelected:y===T,node:f},f.name)),x++}}let g=0;b.length>0&&(g+=2+b.length),a.length>0&&(g+=2+a.length);const A=g>w&&w>0;return e.jsxs(l,{borderColor:u,borderStyle:"single",flexDirection:"column",flexGrow:1,children:[e.jsxs(l,{flexShrink:0,gap:1,paddingX:1,children:[e.jsx(t,{bold:!0,inverse:!0,children:" VIS "}),e.jsxs(t,{wrap:"truncate",children:[h.total," ","packages"]}),e.jsxs(t,{dimColor:!0,children:["(",h.apps," ","apps,"," ",h.libs," ","libs,"," ",h.deps," ","deps)"]})]}),e.jsx(l,{flexShrink:0,gap:1,paddingX:1,paddingY:1,children:ae.map(f=>{const y=o===f.key;return e.jsxs(l,{children:[e.jsx(t,{dimColor:!y,children:"["}),e.jsx(t,{bold:y,color:y?"cyan":"gray",children:f.shortcut}),e.jsx(t,{dimColor:!y,children:"]"}),e.jsxs(t,{color:y?"white":"gray",children:[" ",f.label]})]},f.key)})}),c&&e.jsxs(l,{flexShrink:0,paddingX:1,children:[e.jsx(t,{bold:!0,color:"white",children:"/ "}),e.jsx(t,{children:r}),e.jsx(t,{inverse:!0,children:" "})]}),e.jsxs(l,{flexDirection:"row",flexGrow:1,overflow:"hidden",children:[e.jsx(l,{flexDirection:"column",flexGrow:1,overflow:"hidden",paddingLeft:1,children:e.jsx(l,{flexDirection:"column",marginTop:-n,children:j})}),A&&e.jsx(l,{flexShrink:0,marginLeft:1,marginRight:1,children:e.jsx(Q,{contentHeight:g,placement:"inset",scrollOffset:n,style:"block",viewportHeight:w})})]})]})},pe=100,ue=40,xe=10,B={1:"all",2:"app",3:"lib"},fe=({autoExitSeconds:c=0,store:r})=>{const{exit:o}=J(),{columns:s,rows:i}=K(),n=C.useSyncExternalStore(r.subscribe,r.getSnapshot),[T,h]=C.useState(!1),w=C.useRef(null),u=C.useRef(null),[b,a]=C.useState(0),[j,x]=C.useState(!1),g=C.useMemo(()=>r.getFilteredNodes(),[n.allNodes,n.filterType,n.filterText]),A=C.useMemo(()=>r.getStats(),[n.allNodes]),f=g[n.selectedIndex]??null,y=C.useMemo(()=>{let p=0,d=0;for(const m of g)m.type==="application"?p+=1:d+=1;return{appsCount:p,libsCount:d}},[g]),R=C.useCallback(p=>{const{appsCount:d,libsCount:m}=y;if(p<d)return(d>0?2:0)+p;const Y=d>0?2+d:0,U=m>0?2:0;return Y+U+(p-d)},[y]),D=Math.max(1,i-8-(n.filterActive?1:0)),v=C.useCallback(p=>{const d=R(p);a(m=>d>m+D-2?Math.max(0,d-D+2):d<m+1?Math.max(0,d-1):m)},[R,D]);if(C.useEffect(()=>{u.current?.scrollToTop()},[f?.name]),z((p,d)=>{if(p==="c"&&d.ctrl){o();return}if(!j){if(T){d.escape||p==="?"?h(!1):p==="q"?(h(!1),x(!0)):d.downArrow||p==="j"?w.current?.scrollBy(1):(d.upArrow||p==="k")&&w.current?.scrollBy(-1);return}if(p==="?"){h(!0);return}if(p==="q"){x(!0);return}if(d.tab){r.setFocusedPanel(n.focusedPanel==="list"?"detail":"list");return}if(B[p]){r.setFilterType(B[p]);return}if(n.filterActive){if(d.escape){r.setFilterActive(!1);return}if(d.return){r.setFilterActive(!1);return}if(d.backspace){r.setFilter(n.filterText.slice(0,-1));return}if(p&&!d.ctrl&&!d.meta){r.setFilter(n.filterText+p);return}return}if(n.focusedPanel==="list"){if(g.length===0){p==="/"&&r.setFilterActive(!0);return}if(d.downArrow||p==="j"){const m=Math.min(n.selectedIndex+1,g.length-1);r.setSelectedIndex(m),v(m);return}if(d.upArrow||p==="k"){const m=Math.max(n.selectedIndex-1,0);r.setSelectedIndex(m),v(m);return}if(d.pageDown){const m=Math.min(n.selectedIndex+10,g.length-1);r.setSelectedIndex(m),v(m);return}if(d.pageUp){const m=Math.max(n.selectedIndex-10,0);r.setSelectedIndex(m),v(m);return}if(d.home){r.setSelectedIndex(0),a(0);return}if(d.end){const m=g.length-1;r.setSelectedIndex(m),v(m);return}if(p==="/"){r.setFilterActive(!0);return}if(d.rightArrow){r.setFocusedPanel("detail");return}return}if(n.focusedPanel==="detail"){if(d.escape||d.leftArrow){r.setFocusedPanel("list");return}if(d.downArrow||p==="j"){u.current?.scrollBy(1);return}if(d.upArrow||p==="k"){u.current?.scrollBy(-1);return}if(d.pageDown){u.current?.scrollBy(10);return}if(d.pageUp){u.current?.scrollBy(-10);return}if(d.home){u.current?.scrollToTop();return}d.end&&u.current?.scrollToBottom()}}},{isActive:!0}),s<ue||i<xe)return e.jsx(l,{alignItems:"center",height:i,justifyContent:"center",width:s,children:e.jsxs(t,{color:"yellow",children:["Terminal too small (",s,"x",i,")"]})});const _=s>=pe,P=e.jsx(l,{borderBottom:!1,borderColor:"gray",borderLeft:!1,borderRight:!1,borderStyle:"single",flexShrink:0,children:e.jsxs(l,{flexWrap:"wrap",gap:2,paddingX:1,children:[e.jsxs(l,{gap:1,children:[e.jsx(t,{bold:!0,color:"white",children:"q"}),e.jsx(t,{dimColor:!0,children:"QUIT"})]},"q"),e.jsxs(l,{gap:1,children:[e.jsx(t,{bold:!0,color:"white",children:"?"}),e.jsx(t,{dimColor:!0,children:"HELP"})]},"?"),e.jsxs(l,{gap:1,children:[e.jsx(t,{bold:!0,color:"white",children:"↑↓"}),e.jsx(t,{dimColor:!0,children:"NAV"})]},"nav"),e.jsxs(l,{gap:1,children:[e.jsx(t,{bold:!0,color:"white",children:"1-3 /"}),e.jsx(t,{dimColor:!0,children:"FILTER"})]},"f"),e.jsxs(l,{gap:1,children:[e.jsx(t,{bold:!0,color:"white",children:"Tab"}),e.jsx(t,{dimColor:!0,children:"PANEL"})]},"t")]})}),N=e.jsxs(Z,{footer:e.jsxs(t,{dimColor:!0,children:[e.jsx(t,{bold:!0,color:"white",children:"↑↓"})," ","scroll"," ",e.jsx(t,{bold:!0,color:"white",children:"?"}),"/",e.jsx(t,{bold:!0,color:"white",children:"Esc"})," ","close"]}),scrollRef:w,title:"KEYBOARD SHORTCUTS",visible:T,width:52,children:[e.jsxs(l,{flexDirection:"column",marginBottom:1,children:[e.jsxs(l,{marginBottom:1,children:[e.jsx(t,{dimColor:!0,children:"── "}),e.jsx(t,{bold:!0,color:"white",children:"NAVIGATION"})]}),e.jsxs(l,{children:[e.jsx(l,{width:24,children:e.jsxs(t,{children:[e.jsxs(t,{bold:!0,color:"white",children:[" ","↑","/k"]}),e.jsx(t,{dimColor:!0,children:" Move up"})]})}),e.jsxs(t,{children:[e.jsxs(t,{bold:!0,color:"white",children:[" ","↓","/j"]}),e.jsx(t,{dimColor:!0,children:" Move down"})]})]}),e.jsxs(t,{children:[e.jsxs(t,{bold:!0,color:"white",children:[" ","Tab"]}),e.jsx(t,{dimColor:!0,children:" Switch panel"})]}),e.jsxs(t,{children:[e.jsxs(t,{bold:!0,color:"white",children:[" ","→","/","←"]}),e.jsx(t,{dimColor:!0,children:" Focus detail/list"})]}),e.jsxs(t,{children:[e.jsxs(t,{bold:!0,color:"white",children:[" ","PgUp/PgDn"]}),e.jsx(t,{dimColor:!0,children:" Jump 10 items"})]}),e.jsxs(t,{children:[e.jsxs(t,{bold:!0,color:"white",children:[" ","Home/End"]}),e.jsx(t,{dimColor:!0,children:" Jump to start/end"})]})]}),e.jsxs(l,{flexDirection:"column",marginBottom:1,children:[e.jsxs(l,{marginBottom:1,children:[e.jsx(t,{dimColor:!0,children:"── "}),e.jsx(t,{bold:!0,color:"white",children:"FILTERS"})]}),e.jsxs(l,{children:[e.jsx(l,{width:24,children:e.jsxs(t,{children:[e.jsxs(t,{bold:!0,color:"white",children:[" ","1"]}),e.jsx(t,{dimColor:!0,children:" All"})]})}),e.jsxs(t,{children:[e.jsxs(t,{bold:!0,color:"white",children:[" ","2"]}),e.jsx(t,{dimColor:!0,children:" Apps only"})]})]}),e.jsxs(t,{children:[e.jsxs(t,{bold:!0,color:"white",children:[" ","3"]}),e.jsx(t,{dimColor:!0,children:" Libraries only"})]}),e.jsxs(t,{children:[e.jsxs(t,{bold:!0,color:"white",children:[" ","/"]}),e.jsx(t,{dimColor:!0,children:" Text filter"})]})]}),e.jsxs(l,{flexDirection:"column",children:[e.jsxs(l,{marginBottom:1,children:[e.jsx(t,{dimColor:!0,children:"── "}),e.jsx(t,{bold:!0,color:"white",children:"ACTIONS"})]}),e.jsxs(t,{children:[e.jsxs(t,{bold:!0,color:"white",children:[" ","q"]}),e.jsx(t,{dimColor:!0,children:" Quit"})]}),e.jsxs(t,{children:[e.jsxs(t,{bold:!0,color:"white",children:[" ","?"]}),e.jsx(t,{dimColor:!0,children:" Toggle help"})]})]})]}),E=e.jsx(he,{filterActive:n.filterActive,filterText:n.filterText,filterType:n.filterType,focused:n.focusedPanel==="list",nodes:g,scrollOffset:b,selectedIndex:n.selectedIndex,stats:A,viewportHeight:D}),$=e.jsx(de,{focused:n.focusedPanel==="detail",node:f,scrollRef:u});if(_){const p=Math.floor(s*.35);return e.jsxs(l,{flexDirection:"column",height:i,width:s,children:[e.jsxs(l,{flexDirection:"row",flexGrow:1,children:[e.jsx(l,{flexGrow:1,children:E}),e.jsx(l,{width:p,children:$})]}),P,e.jsx(L,{autoExitSeconds:c??3,onCancel:()=>{x(!1)},visible:j}),N]})}const q=Math.floor(i*.55);return e.jsxs(l,{flexDirection:"column",height:i,width:s,children:[e.jsx(l,{height:q,children:E}),e.jsx(l,{flexGrow:1,children:$}),P,e.jsx(L,{autoExitSeconds:c??3,onCancel:()=>{x(!1)},visible:j}),N]})},V=(c,r,o,s,i,n,T,h)=>{const w=o?S("└── "):S("├── "),u=i.has(c),b=u?S(" (*)"):"",a=s.get(c),x=a?.type==="application"?I(c):c;if(n.push(`${r}${w}${x}${b}`),u)return;i.add(c);const g=a?.deps??[],A=o?`${r} `:`${r}${S("│")} `;if(h>=T&&g.length>0){n.push(`${A}${S(`... ${g.length} more`)}`);return}for(let f=0;f<g.length;f++){const y=g[f];y&&V(y.target,A,f===g.length-1,s,i,n,T,h+1)}},H=(c,r,o,s,i,n)=>{const T=r.get(c),w=T?.type==="application"?I(c):c;s.push(`${n}${w}`),o.add(c);const u=T?.deps??[];if(u.length===0){s.push(`${n} ${S("(no dependencies)")}`);return}if(i<=0){s.push(`${n} ${S(`... ${u.length} dependencies`)}`);return}for(let b=0;b<u.length;b++){const a=u[b];a&&V(a.target,n,b===u.length-1,r,o,s,i,1)}},k=(c,r)=>{const o=new Map;for(const[a,j]of Object.entries(c.nodes))o.set(a,{deps:(c.dependencies[a]??[]).map(x=>({target:x.target,type:x.type})),name:a,type:j.type});const s=[],i=[];for(const[a,j]of o)j.type==="application"?s.push(a):i.push(a);s.sort(),i.sort();const n=s.length+i.length,T=Object.values(c.dependencies).reduce((a,j)=>a+j.length,0),h=[I("Project Dependency Graph"),""];if(s.length>0){h.push(` ${I(F(`Applications (${s.length})`))}`,"");for(const a of s)H(a,o,new Set,h,r," "),h.push("")}if(i.length>0){h.push(` ${I(F(`Libraries (${i.length})`))}`,"");for(const a of i)H(a,o,new Set,h,r," "),h.push("")}const w=process.stdout.columns||80;h.push(S("─".repeat(Math.min(w,60)))),h.push(`${I(String(n))} packages ${S("·")} ${I(String(T))} dependencies ${S("·")} ${I(String(s.length))} apps${S(",")} ${I(String(i.length))} libraries`);const u=new Set;let b=!1;for(const a of[...s,...i]){const j=o.get(a)?.deps??[];for(const x of j)u.has(x.target)&&(b=!0),u.add(x.target);u.add(a)}return b&&h.push(S("(*) = already shown above")),h.join(`
1
+ import{j as I,q as F,F as S}from"../packem_shared/index.server-Ca_EEVfw.js";import{projectGraphToDot as W}from"@visulima/task-runner";import{L as X,M as Q,N as J,K,C as z,P as Z,Q as L,q as ee}from"./cli-main.js";import{i as te}from"../packem_shared/index-BjdW45xX.js";import{j as e,X as l,O as t,r as C,d as re,b as se,R as le}from"../packem_shared/registry-acz8_sxm.js";const ie={application:0,library:3,service:1,tool:2},M=c=>ie[c]??Number.MAX_SAFE_INTEGER,ne=c=>{const r=new Map;for(const[o,s]of Object.entries(c.dependencies))for(const i of s){const n=r.get(i.target)??[];n.push(o),r.set(i.target,n)}return Object.values(c.nodes).map(o=>({deps:c.dependencies[o.name]??[],name:o.name,reverseDeps:r.get(o.name)??[],type:o.type})).sort((o,s)=>o.type!==s.type?M(o.type)-M(s.type):o.name.localeCompare(s.name))},oe=(c,r,o)=>{let s=c;if(r==="app"?s=s.filter(i=>i.type==="application"):r==="lib"&&(s=s.filter(i=>i.type!=="application")),o){const i=o.toLowerCase();s=s.filter(n=>n.name.toLowerCase().includes(i))}return s};class ce{#e;#r=new Set;#s;constructor(r){this.#s=r;const o=ne(r);this.#e={allNodes:o,filterActive:!1,filterText:"",filterType:"all",focusedPanel:"list",selectedIndex:0}}getSnapshot=()=>this.#e;subscribe=r=>(this.#r.add(r),()=>{this.#r.delete(r)});getFilteredNodes(){return oe(this.#e.allNodes,this.#e.filterType,this.#e.filterText)}getStats(){const r=this.#e.allNodes.filter(i=>i.type==="application").length,o=this.#e.allNodes.length,s=Object.values(this.#s.dependencies).reduce((i,n)=>i+n.length,0);return{apps:r,deps:s,libs:o-r,total:o}}setSelectedIndex(r){const o=this.getFilteredNodes(),s=o.length===0?-1:Math.max(0,Math.min(r,o.length-1));s!==this.#e.selectedIndex&&this.#t({...this.#e,selectedIndex:s})}setFocusedPanel(r){r!==this.#e.focusedPanel&&this.#t({...this.#e,focusedPanel:r})}setFilterType(r){r!==this.#e.filterType&&this.#t({...this.#e,filterType:r,selectedIndex:0})}setFilter(r){this.#t({...this.#e,filterText:r,selectedIndex:0})}setFilterActive(r){r!==this.#e.filterActive&&this.#t({...this.#e,filterActive:r,filterText:r?this.#e.filterText:"",selectedIndex:r?this.#e.selectedIndex:0})}#t(r){this.#e=r;for(const o of this.#r)try{o()}catch{}}}const de=({focused:c,node:r,scrollRef:o})=>{const s=c?"white":"gray";if(!r)return e.jsx(l,{alignItems:"center",borderColor:"gray",borderStyle:"single",flexDirection:"column",flexGrow:1,justifyContent:"center",children:e.jsx(t,{dimColor:!0,children:"No project selected"})});const i=r.type==="application",n=i?"yellow":"cyan",T=i?"Application":"Library";return e.jsx(l,{borderColor:s,borderStyle:"single",borderTopRightTitle:` ${T} `,borderTopTitle:` ${r.name} `,flexDirection:"column",flexGrow:1,children:e.jsxs(X,{flexGrow:1,flexShrink:1,paddingX:2,ref:o,scrollbar:!0,scrollbarColor:"gray",children:[e.jsxs(l,{flexDirection:"column",marginTop:1,children:[e.jsxs(l,{children:[e.jsx(t,{dimColor:!0,children:"── "}),e.jsx(t,{bold:!0,color:"white",children:"DEPENDS ON"}),e.jsxs(t,{dimColor:!0,children:[" ","(",r.deps.length,")"]})]}),r.deps.length===0?e.jsx(l,{marginTop:1,paddingLeft:2,children:e.jsx(t,{dimColor:!0,children:"No dependencies"})}):e.jsx(l,{flexDirection:"column",marginTop:1,children:r.deps.map(h=>e.jsxs(l,{gap:1,paddingLeft:2,children:[e.jsx(t,{color:"cyan",children:"→"}),e.jsx(t,{children:h.target}),h.type!=="static"&&e.jsxs(t,{dimColor:!0,children:["(",h.type,")"]})]},h.target))})]}),e.jsxs(l,{flexDirection:"column",marginTop:1,children:[e.jsxs(l,{children:[e.jsx(t,{dimColor:!0,children:"── "}),e.jsx(t,{bold:!0,color:"white",children:"REQUIRED BY"}),e.jsxs(t,{dimColor:!0,children:[" ","(",r.reverseDeps.length,")"]})]}),r.reverseDeps.length===0?e.jsx(l,{marginTop:1,paddingLeft:2,children:e.jsx(t,{dimColor:!0,children:"No reverse dependencies"})}):e.jsx(l,{flexDirection:"column",marginTop:1,children:r.reverseDeps.map(h=>e.jsxs(l,{gap:1,paddingLeft:2,children:[e.jsx(t,{color:"magenta",children:"←"}),e.jsx(t,{children:h})]},h))})]}),e.jsxs(l,{flexDirection:"column",marginTop:1,children:[e.jsxs(l,{children:[e.jsx(t,{dimColor:!0,children:"── "}),e.jsx(t,{bold:!0,color:"white",children:"INFO"})]}),e.jsxs(l,{flexDirection:"column",marginTop:1,paddingLeft:2,children:[e.jsxs(l,{children:[e.jsx(l,{width:16,children:e.jsx(t,{dimColor:!0,children:"Type:"})}),e.jsx(t,{color:n,children:T})]}),e.jsxs(l,{children:[e.jsx(l,{width:16,children:e.jsx(t,{dimColor:!0,children:"Dependencies:"})}),e.jsx(t,{children:String(r.deps.length)})]}),e.jsxs(l,{children:[e.jsx(l,{width:16,children:e.jsx(t,{dimColor:!0,children:"Required by:"})}),e.jsx(t,{children:String(r.reverseDeps.length)})]}),e.jsxs(l,{children:[e.jsx(l,{width:16,children:e.jsx(t,{dimColor:!0,children:"Connectivity:"})}),e.jsx(t,{children:String(r.deps.length+r.reverseDeps.length)})]})]})]})]})})},ae=[{key:"all",label:"All",shortcut:"1"},{key:"app",label:"Apps",shortcut:"2"},{key:"lib",label:"Libs",shortcut:"3"}],O=({isSelected:c,node:r})=>{const o=r.type==="application",s=o?"yellow":"cyan",i=o?"app":"lib";return e.jsxs(l,{flexShrink:0,height:1,children:[e.jsxs(t,{children:[c?"▶":" "," "]}),e.jsx(l,{flexGrow:1,children:e.jsx(t,{bold:c,inverse:c,wrap:"truncate",children:r.name})}),e.jsxs(t,{color:s,children:[" ",i]}),e.jsxs(t,{dimColor:!0,children:[" ","→",r.deps.length," ","←",r.reverseDeps.length]})]})},G=({count:c,label:r})=>e.jsxs(l,{flexShrink:0,height:1,marginTop:1,children:[e.jsxs(t,{dimColor:!0,children:["▼"," "]}),e.jsx(t,{bold:!0,color:"white",children:r.toUpperCase()}),e.jsxs(t,{dimColor:!0,children:[" ","(",c,")"]})]}),he=({filterActive:c,filterText:r,filterType:o,focused:s,nodes:i,scrollOffset:n,selectedIndex:T,stats:h,viewportHeight:w})=>{const u=s?"white":"gray",b=i.filter(f=>f.type==="application"),a=i.filter(f=>f.type!=="application"),j=[];let x=0;if(b.length>0){j.push(e.jsx(G,{count:b.length,label:"Applications"},"hdr-apps"));for(const f of b){const y=x;j.push(e.jsx(O,{isSelected:y===T,node:f},f.name)),x++}}if(a.length>0){j.push(e.jsx(G,{count:a.length,label:"Libraries"},"hdr-libs"));for(const f of a){const y=x;j.push(e.jsx(O,{isSelected:y===T,node:f},f.name)),x++}}let g=0;b.length>0&&(g+=2+b.length),a.length>0&&(g+=2+a.length);const A=g>w&&w>0;return e.jsxs(l,{borderColor:u,borderStyle:"single",flexDirection:"column",flexGrow:1,children:[e.jsxs(l,{flexShrink:0,gap:1,paddingX:1,children:[e.jsx(t,{bold:!0,inverse:!0,children:" VIS "}),e.jsxs(t,{wrap:"truncate",children:[h.total," ","packages"]}),e.jsxs(t,{dimColor:!0,children:["(",h.apps," ","apps,"," ",h.libs," ","libs,"," ",h.deps," ","deps)"]})]}),e.jsx(l,{flexShrink:0,gap:1,paddingX:1,paddingY:1,children:ae.map(f=>{const y=o===f.key;return e.jsxs(l,{children:[e.jsx(t,{dimColor:!y,children:"["}),e.jsx(t,{bold:y,color:y?"cyan":"gray",children:f.shortcut}),e.jsx(t,{dimColor:!y,children:"]"}),e.jsxs(t,{color:y?"white":"gray",children:[" ",f.label]})]},f.key)})}),c&&e.jsxs(l,{flexShrink:0,paddingX:1,children:[e.jsx(t,{bold:!0,color:"white",children:"/ "}),e.jsx(t,{children:r}),e.jsx(t,{inverse:!0,children:" "})]}),e.jsxs(l,{flexDirection:"row",flexGrow:1,overflow:"hidden",children:[e.jsx(l,{flexDirection:"column",flexGrow:1,overflow:"hidden",paddingLeft:1,children:e.jsx(l,{flexDirection:"column",marginTop:-n,children:j})}),A&&e.jsx(l,{flexShrink:0,marginLeft:1,marginRight:1,children:e.jsx(Q,{contentHeight:g,placement:"inset",scrollOffset:n,style:"block",viewportHeight:w})})]})]})},pe=100,ue=40,xe=10,B={1:"all",2:"app",3:"lib"},fe=({autoExitSeconds:c=0,store:r})=>{const{exit:o}=J(),{columns:s,rows:i}=K(),n=C.useSyncExternalStore(r.subscribe,r.getSnapshot),[T,h]=C.useState(!1),w=C.useRef(null),u=C.useRef(null),[b,a]=C.useState(0),[j,x]=C.useState(!1),g=C.useMemo(()=>r.getFilteredNodes(),[n.allNodes,n.filterType,n.filterText]),A=C.useMemo(()=>r.getStats(),[n.allNodes]),f=g[n.selectedIndex]??null,y=C.useMemo(()=>{let p=0,d=0;for(const m of g)m.type==="application"?p+=1:d+=1;return{appsCount:p,libsCount:d}},[g]),R=C.useCallback(p=>{const{appsCount:d,libsCount:m}=y;if(p<d)return(d>0?2:0)+p;const Y=d>0?2+d:0,U=m>0?2:0;return Y+U+(p-d)},[y]),D=Math.max(1,i-8-(n.filterActive?1:0)),v=C.useCallback(p=>{const d=R(p);a(m=>d>m+D-2?Math.max(0,d-D+2):d<m+1?Math.max(0,d-1):m)},[R,D]);if(C.useEffect(()=>{u.current?.scrollToTop()},[f?.name]),z((p,d)=>{if(p==="c"&&d.ctrl){o();return}if(!j){if(T){d.escape||p==="?"?h(!1):p==="q"?(h(!1),x(!0)):d.downArrow||p==="j"?w.current?.scrollBy(1):(d.upArrow||p==="k")&&w.current?.scrollBy(-1);return}if(p==="?"){h(!0);return}if(p==="q"){x(!0);return}if(d.tab){r.setFocusedPanel(n.focusedPanel==="list"?"detail":"list");return}if(B[p]){r.setFilterType(B[p]);return}if(n.filterActive){if(d.escape){r.setFilterActive(!1);return}if(d.return){r.setFilterActive(!1);return}if(d.backspace){r.setFilter(n.filterText.slice(0,-1));return}if(p&&!d.ctrl&&!d.meta){r.setFilter(n.filterText+p);return}return}if(n.focusedPanel==="list"){if(g.length===0){p==="/"&&r.setFilterActive(!0);return}if(d.downArrow||p==="j"){const m=Math.min(n.selectedIndex+1,g.length-1);r.setSelectedIndex(m),v(m);return}if(d.upArrow||p==="k"){const m=Math.max(n.selectedIndex-1,0);r.setSelectedIndex(m),v(m);return}if(d.pageDown){const m=Math.min(n.selectedIndex+10,g.length-1);r.setSelectedIndex(m),v(m);return}if(d.pageUp){const m=Math.max(n.selectedIndex-10,0);r.setSelectedIndex(m),v(m);return}if(d.home){r.setSelectedIndex(0),a(0);return}if(d.end){const m=g.length-1;r.setSelectedIndex(m),v(m);return}if(p==="/"){r.setFilterActive(!0);return}if(d.rightArrow){r.setFocusedPanel("detail");return}return}if(n.focusedPanel==="detail"){if(d.escape||d.leftArrow){r.setFocusedPanel("list");return}if(d.downArrow||p==="j"){u.current?.scrollBy(1);return}if(d.upArrow||p==="k"){u.current?.scrollBy(-1);return}if(d.pageDown){u.current?.scrollBy(10);return}if(d.pageUp){u.current?.scrollBy(-10);return}if(d.home){u.current?.scrollToTop();return}d.end&&u.current?.scrollToBottom()}}},{isActive:!0}),s<ue||i<xe)return e.jsx(l,{alignItems:"center",height:i,justifyContent:"center",width:s,children:e.jsxs(t,{color:"yellow",children:["Terminal too small (",s,"x",i,")"]})});const _=s>=pe,P=e.jsx(l,{borderBottom:!1,borderColor:"gray",borderLeft:!1,borderRight:!1,borderStyle:"single",flexShrink:0,children:e.jsxs(l,{flexWrap:"wrap",gap:2,paddingX:1,children:[e.jsxs(l,{gap:1,children:[e.jsx(t,{bold:!0,color:"white",children:"q"}),e.jsx(t,{dimColor:!0,children:"QUIT"})]},"q"),e.jsxs(l,{gap:1,children:[e.jsx(t,{bold:!0,color:"white",children:"?"}),e.jsx(t,{dimColor:!0,children:"HELP"})]},"?"),e.jsxs(l,{gap:1,children:[e.jsx(t,{bold:!0,color:"white",children:"↑↓"}),e.jsx(t,{dimColor:!0,children:"NAV"})]},"nav"),e.jsxs(l,{gap:1,children:[e.jsx(t,{bold:!0,color:"white",children:"1-3 /"}),e.jsx(t,{dimColor:!0,children:"FILTER"})]},"f"),e.jsxs(l,{gap:1,children:[e.jsx(t,{bold:!0,color:"white",children:"Tab"}),e.jsx(t,{dimColor:!0,children:"PANEL"})]},"t")]})}),N=e.jsxs(Z,{footer:e.jsxs(t,{dimColor:!0,children:[e.jsx(t,{bold:!0,color:"white",children:"↑↓"})," ","scroll"," ",e.jsx(t,{bold:!0,color:"white",children:"?"}),"/",e.jsx(t,{bold:!0,color:"white",children:"Esc"})," ","close"]}),scrollRef:w,title:"KEYBOARD SHORTCUTS",visible:T,width:52,children:[e.jsxs(l,{flexDirection:"column",marginBottom:1,children:[e.jsxs(l,{marginBottom:1,children:[e.jsx(t,{dimColor:!0,children:"── "}),e.jsx(t,{bold:!0,color:"white",children:"NAVIGATION"})]}),e.jsxs(l,{children:[e.jsx(l,{width:24,children:e.jsxs(t,{children:[e.jsxs(t,{bold:!0,color:"white",children:[" ","↑","/k"]}),e.jsx(t,{dimColor:!0,children:" Move up"})]})}),e.jsxs(t,{children:[e.jsxs(t,{bold:!0,color:"white",children:[" ","↓","/j"]}),e.jsx(t,{dimColor:!0,children:" Move down"})]})]}),e.jsxs(t,{children:[e.jsxs(t,{bold:!0,color:"white",children:[" ","Tab"]}),e.jsx(t,{dimColor:!0,children:" Switch panel"})]}),e.jsxs(t,{children:[e.jsxs(t,{bold:!0,color:"white",children:[" ","→","/","←"]}),e.jsx(t,{dimColor:!0,children:" Focus detail/list"})]}),e.jsxs(t,{children:[e.jsxs(t,{bold:!0,color:"white",children:[" ","PgUp/PgDn"]}),e.jsx(t,{dimColor:!0,children:" Jump 10 items"})]}),e.jsxs(t,{children:[e.jsxs(t,{bold:!0,color:"white",children:[" ","Home/End"]}),e.jsx(t,{dimColor:!0,children:" Jump to start/end"})]})]}),e.jsxs(l,{flexDirection:"column",marginBottom:1,children:[e.jsxs(l,{marginBottom:1,children:[e.jsx(t,{dimColor:!0,children:"── "}),e.jsx(t,{bold:!0,color:"white",children:"FILTERS"})]}),e.jsxs(l,{children:[e.jsx(l,{width:24,children:e.jsxs(t,{children:[e.jsxs(t,{bold:!0,color:"white",children:[" ","1"]}),e.jsx(t,{dimColor:!0,children:" All"})]})}),e.jsxs(t,{children:[e.jsxs(t,{bold:!0,color:"white",children:[" ","2"]}),e.jsx(t,{dimColor:!0,children:" Apps only"})]})]}),e.jsxs(t,{children:[e.jsxs(t,{bold:!0,color:"white",children:[" ","3"]}),e.jsx(t,{dimColor:!0,children:" Libraries only"})]}),e.jsxs(t,{children:[e.jsxs(t,{bold:!0,color:"white",children:[" ","/"]}),e.jsx(t,{dimColor:!0,children:" Text filter"})]})]}),e.jsxs(l,{flexDirection:"column",children:[e.jsxs(l,{marginBottom:1,children:[e.jsx(t,{dimColor:!0,children:"── "}),e.jsx(t,{bold:!0,color:"white",children:"ACTIONS"})]}),e.jsxs(t,{children:[e.jsxs(t,{bold:!0,color:"white",children:[" ","q"]}),e.jsx(t,{dimColor:!0,children:" Quit"})]}),e.jsxs(t,{children:[e.jsxs(t,{bold:!0,color:"white",children:[" ","?"]}),e.jsx(t,{dimColor:!0,children:" Toggle help"})]})]})]}),E=e.jsx(he,{filterActive:n.filterActive,filterText:n.filterText,filterType:n.filterType,focused:n.focusedPanel==="list",nodes:g,scrollOffset:b,selectedIndex:n.selectedIndex,stats:A,viewportHeight:D}),$=e.jsx(de,{focused:n.focusedPanel==="detail",node:f,scrollRef:u});if(_){const p=Math.floor(s*.35);return e.jsxs(l,{flexDirection:"column",height:i,width:s,children:[e.jsxs(l,{flexDirection:"row",flexGrow:1,children:[e.jsx(l,{flexGrow:1,children:E}),e.jsx(l,{width:p,children:$})]}),P,e.jsx(L,{autoExitSeconds:c??3,onCancel:()=>{x(!1)},visible:j}),N]})}const q=Math.floor(i*.55);return e.jsxs(l,{flexDirection:"column",height:i,width:s,children:[e.jsx(l,{height:q,children:E}),e.jsx(l,{flexGrow:1,children:$}),P,e.jsx(L,{autoExitSeconds:c??3,onCancel:()=>{x(!1)},visible:j}),N]})},V=(c,r,o,s,i,n,T,h)=>{const w=o?S("└── "):S("├── "),u=i.has(c),b=u?S(" (*)"):"",a=s.get(c),x=a?.type==="application"?I(c):c;if(n.push(`${r}${w}${x}${b}`),u)return;i.add(c);const g=a?.deps??[],A=o?`${r} `:`${r}${S("│")} `;if(h>=T&&g.length>0){n.push(`${A}${S(`... ${g.length} more`)}`);return}for(let f=0;f<g.length;f++){const y=g[f];y&&V(y.target,A,f===g.length-1,s,i,n,T,h+1)}},H=(c,r,o,s,i,n)=>{const T=r.get(c),w=T?.type==="application"?I(c):c;s.push(`${n}${w}`),o.add(c);const u=T?.deps??[];if(u.length===0){s.push(`${n} ${S("(no dependencies)")}`);return}if(i<=0){s.push(`${n} ${S(`... ${u.length} dependencies`)}`);return}for(let b=0;b<u.length;b++){const a=u[b];a&&V(a.target,n,b===u.length-1,r,o,s,i,1)}},k=(c,r)=>{const o=new Map;for(const[a,j]of Object.entries(c.nodes))o.set(a,{deps:(c.dependencies[a]??[]).map(x=>({target:x.target,type:x.type})),name:a,type:j.type});const s=[],i=[];for(const[a,j]of o)j.type==="application"?s.push(a):i.push(a);s.sort(),i.sort();const n=s.length+i.length,T=Object.values(c.dependencies).reduce((a,j)=>a+j.length,0),h=[I("Project Dependency Graph"),""];if(s.length>0){h.push(` ${I(F(`Applications (${s.length})`))}`,"");for(const a of s)H(a,o,new Set,h,r," "),h.push("")}if(i.length>0){h.push(` ${I(F(`Libraries (${i.length})`))}`,"");for(const a of i)H(a,o,new Set,h,r," "),h.push("")}const w=process.stdout.columns||80;h.push(S("─".repeat(Math.min(w,60)))),h.push(`${I(String(n))} packages ${S("·")} ${I(String(T))} dependencies ${S("·")} ${I(String(s.length))} apps${S(",")} ${I(String(i.length))} libraries`);const u=new Set;let b=!1;for(const a of[...s,...i]){const j=o.get(a)?.deps??[];for(const x of j)u.has(x.target)&&(b=!0),u.add(x.target);u.add(a)}return b&&h.push(S("(*) = already shown above")),h.join(`
2
2
  `)},je=c=>{const r=Object.values(c.nodes).map(s=>({name:s.name,type:s.type}));return{edges:Object.values(c.dependencies).flat(),nodes:r}},me=async c=>{const{emitGraphHtml:r}=await import("./html.js"),o=Object.values(c.nodes).map(i=>({name:i.name,path:i.data?.root,type:i.type})),s=[];for(const i of Object.values(c.dependencies))for(const n of i)s.push({source:n.source,target:n.target,type:n.type});return r({edges:s,nodes:o,tool:{name:"vis-graph",version:"alpha"},workspaceRoot:process.cwd()})},Ce=async({fs:c,logger:r,options:o,visConfig:s,workspaceRoot:i})=>{if(!i)throw new Error("Could not determine workspace root. Run this command inside a monorepo.");const n=i,{packageJsons:T,workspace:h}=re(n,s),w=se(n,h,T),u=!!process.stdout.isTTY&&!te,b=o.format??(u?"tui":"ascii"),a=o.output,j=o.depth??1/0;let x;switch(b){case"dot":{x=W(w);break}case"html":{x=await me(w);break}case"json":{x=JSON.stringify(je(w),void 0,2);break}case"tui":{if(!u){x=k(w,j);break}const g=s?.tui?.autoExit===!0?3:typeof s?.tui?.autoExit=="number"?s.tui.autoExit:0;process.stdin.isTTY&&typeof process.stdin.setRawMode=="function"&&(process.stdin.setRawMode(!0),process.stdin.ref(),process.stdin.resume());const A=setInterval(()=>{},1e3),f=new ce(w);await ee(le.createElement(fe,{autoExitSeconds:g,store:f}),{alternateScreen:!0,exitOnCtrlC:!1,interactive:!0,patchConsole:!0}).waitUntilExit(),clearInterval(A);return}default:x=k(w,j)}a?(await c.writeFile(a,x,"utf8"),r.info(`Graph written to ${a}`)):r.info(x)};export{Ce as default};