@visulima/vis 6.1.0 → 6.1.2

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 (175) hide show
  1. package/CHANGELOG.md +49 -0
  2. package/dist/bin.js +1 -1
  3. package/dist/binx.js +1 -1
  4. package/dist/config/index.d.ts +1226 -1216
  5. package/dist/packem_chunks/bloom-sync.js +1 -1
  6. package/dist/packem_chunks/cargo-lock.js +5 -0
  7. package/dist/packem_chunks/cargo-plan.js +3 -3
  8. package/dist/packem_chunks/catalog-detector.js +1 -1
  9. package/dist/packem_chunks/catalog.js +1 -94
  10. package/dist/packem_chunks/catalog2.js +11 -0
  11. package/dist/packem_chunks/cli-exec.js +1 -1
  12. package/dist/packem_chunks/cli-main.js +156 -174
  13. package/dist/packem_chunks/context.js +8 -0
  14. package/dist/packem_chunks/fix.js +1 -1
  15. package/dist/packem_chunks/handler10.js +1 -1
  16. package/dist/packem_chunks/handler12.js +1 -1
  17. package/dist/packem_chunks/handler13.js +1 -1
  18. package/dist/packem_chunks/handler14.js +1 -1
  19. package/dist/packem_chunks/handler15.js +1 -1
  20. package/dist/packem_chunks/handler19.js +5 -5
  21. package/dist/packem_chunks/handler2.js +1 -1
  22. package/dist/packem_chunks/handler20.js +1 -1
  23. package/dist/packem_chunks/handler21.js +1 -1
  24. package/dist/packem_chunks/handler23.js +1 -1
  25. package/dist/packem_chunks/handler24.js +1 -1
  26. package/dist/packem_chunks/handler25.js +1 -1
  27. package/dist/packem_chunks/handler28.js +1 -1
  28. package/dist/packem_chunks/handler3.js +1 -1
  29. package/dist/packem_chunks/handler31.js +1 -1
  30. package/dist/packem_chunks/handler32.js +1 -1
  31. package/dist/packem_chunks/handler33.js +1 -1
  32. package/dist/packem_chunks/handler34.js +3 -3
  33. package/dist/packem_chunks/handler35.js +1 -1
  34. package/dist/packem_chunks/handler36.js +1 -1
  35. package/dist/packem_chunks/handler38.js +2 -2
  36. package/dist/packem_chunks/handler39.js +5 -5
  37. package/dist/packem_chunks/handler4.js +4 -4
  38. package/dist/packem_chunks/handler40.js +1 -1
  39. package/dist/packem_chunks/handler41.js +1 -1
  40. package/dist/packem_chunks/handler42.js +1 -1
  41. package/dist/packem_chunks/handler43.js +1 -1
  42. package/dist/packem_chunks/handler44.js +1 -1
  43. package/dist/packem_chunks/handler45.js +1 -1
  44. package/dist/packem_chunks/handler46.js +1 -1
  45. package/dist/packem_chunks/handler47.js +1 -1
  46. package/dist/packem_chunks/handler48.js +1 -1
  47. package/dist/packem_chunks/handler49.js +1 -1
  48. package/dist/packem_chunks/handler5.js +4 -4
  49. package/dist/packem_chunks/handler50.js +5 -5
  50. package/dist/packem_chunks/handler52.js +1 -1
  51. package/dist/packem_chunks/handler54.js +2 -2
  52. package/dist/packem_chunks/handler55.js +1 -1
  53. package/dist/packem_chunks/handler56.js +3 -3
  54. package/dist/packem_chunks/handler57.js +4 -4
  55. package/dist/packem_chunks/handler58.js +4 -4
  56. package/dist/packem_chunks/handler59.js +2 -2
  57. package/dist/packem_chunks/handler6.js +7 -7
  58. package/dist/packem_chunks/handler60.js +1 -1
  59. package/dist/packem_chunks/handler61.js +2 -2
  60. package/dist/packem_chunks/handler62.js +1 -1
  61. package/dist/packem_chunks/handler63.js +3 -3
  62. package/dist/packem_chunks/handler64.js +3 -3
  63. package/dist/packem_chunks/handler65.js +2 -2
  64. package/dist/packem_chunks/handler66.js +2 -2
  65. package/dist/packem_chunks/handler67.js +5 -5
  66. package/dist/packem_chunks/handler68.js +12 -25
  67. package/dist/packem_chunks/handler69.js +25 -22
  68. package/dist/packem_chunks/handler70.js +22 -10
  69. package/dist/packem_chunks/handler71.js +10 -133
  70. package/dist/packem_chunks/handler72.js +133 -23
  71. package/dist/packem_chunks/handler73.js +23 -323
  72. package/dist/packem_chunks/handler74.js +274 -659
  73. package/dist/packem_chunks/handler75.js +708 -48
  74. package/dist/packem_chunks/handler76.js +48 -27
  75. package/dist/packem_chunks/handler77.js +27 -3
  76. package/dist/packem_chunks/handler78.js +3 -191
  77. package/dist/packem_chunks/handler79.js +191 -0
  78. package/dist/packem_chunks/handler8.js +1 -1
  79. package/dist/packem_chunks/heal.js +2 -2
  80. package/dist/packem_chunks/help-command.js +1 -1
  81. package/dist/packem_chunks/index2.js +3 -58
  82. package/dist/packem_chunks/index3.js +40 -3
  83. package/dist/packem_chunks/index6.js +135 -7
  84. package/dist/packem_chunks/index7.js +7 -135
  85. package/dist/packem_chunks/keys-refresh.js +1 -1
  86. package/dist/packem_chunks/list.js +2 -2
  87. package/dist/packem_chunks/prune.js +1 -1
  88. package/dist/packem_chunks/python-plan.js +3 -3
  89. package/dist/packem_chunks/python-projects.js +1 -1
  90. package/dist/packem_chunks/python.js +1 -0
  91. package/dist/packem_chunks/run.js +1 -1
  92. package/dist/packem_chunks/snapshot.js +2 -2
  93. package/dist/packem_chunks/state.js +2 -2
  94. package/dist/packem_chunks/status.js +1 -1
  95. package/dist/packem_chunks/sync.js +1 -1
  96. package/dist/packem_chunks/verify-lockfile.js +1 -1
  97. package/dist/packem_chunks/version-resolver.js +1 -1
  98. package/dist/packem_chunks/workspace.js +2 -2
  99. package/dist/packem_shared/ReleaseClient-CWD9BC5w.js +1 -0
  100. package/dist/packem_shared/advisories-DO-P0V1_.js +1 -0
  101. package/dist/packem_shared/{affected-selection-DGb6Xu5K.js → affected-selection-CeeZo7Uy.js} +1 -1
  102. package/dist/packem_shared/{ai-analysis-pldoS_N4.js → ai-analysis-BCJ1kuDM.js} +3 -3
  103. package/dist/packem_shared/ai-cache-iSIyY3So.js +1 -0
  104. package/dist/packem_shared/{ai-fix-D9MxigBQ.js → ai-fix-DIMErSws.js} +6 -6
  105. package/dist/packem_shared/apply-DoeQAAGm.js +6 -0
  106. package/dist/packem_shared/apply-release-plan-BalHtK-g.js +15 -0
  107. package/dist/packem_shared/{bin-AZQv95jh.js → bin-BcLTer1k.js} +1 -1
  108. package/dist/packem_shared/clean-package-json-rutwkKl-.js +1 -0
  109. package/dist/packem_shared/createAdapter-DMK4bBET.js +1 -0
  110. package/dist/packem_shared/createVersionActions-DXo4z8VN.js +1 -0
  111. package/dist/packem_shared/dependency-scan-D_v3KM59.js +1 -0
  112. package/dist/packem_shared/{ecosystem-gate-DiqQj0LJ.js → ecosystem-gate-CwsTc7YW.js} +1 -1
  113. package/dist/packem_shared/env-BSXG3QKH.js +4 -0
  114. package/dist/packem_shared/failure-log-DIsKBKaI.js +2 -0
  115. package/dist/packem_shared/formatBytes-_HvjOy8a-iHCer6uX.js +1 -0
  116. package/dist/packem_shared/glob-Cyk1H9ZL-CL9optrn.js +1 -0
  117. package/dist/packem_shared/{index-JRb5wabN.js → index-9Ot7jTd4.js} +1 -1
  118. package/dist/packem_shared/index-BS6A9QR_.js +1 -0
  119. package/dist/packem_shared/lifecycle-CQjeMPY0.js +2 -0
  120. package/dist/packem_shared/missing-package-json-1BIoWQq0.js +1 -0
  121. package/dist/packem_shared/multi-eco-lockfiles-fgkpeHJv.js +1 -0
  122. package/dist/packem_shared/npmrc-CHsOyMvA.js +2 -0
  123. package/dist/packem_shared/osv-Do9PMOea.js +1 -0
  124. package/dist/packem_shared/{package-version-KLwH0Ivy.js → package-version-Bq6Cne_7.js} +1 -1
  125. package/dist/packem_shared/packument-CbTmbHU4.js +1 -0
  126. package/dist/packem_shared/{project-name-filter-B1ZCsbOW.js → project-name-filter-ZQaLgytG.js} +1 -1
  127. package/dist/packem_shared/{provenance-L1M2FPy_.js → provenance-SX1MxPUZ.js} +1 -1
  128. package/dist/packem_shared/publish-Dc0XGH3K.js +34 -0
  129. package/dist/packem_shared/registry-Dg9XI6RT.js +81 -0
  130. package/dist/packem_shared/registry-keys-z038Ecb4.js +1 -0
  131. package/dist/packem_shared/removeSync-g1D5kONg-LbjATA8v.js +1 -0
  132. package/dist/packem_shared/renderToString-DR0zDUjh-DXppT6AM.js +3 -0
  133. package/dist/packem_shared/{resolve-explicit-CQa37JSq.js → resolve-explicit-D9kdTNvl.js} +1 -1
  134. package/dist/packem_shared/{run-D-uVGHQ4.js → run-DLvd3RIZ.js} +1 -1
  135. package/dist/packem_shared/run-summary-utils-CMeURYtS.js +1 -0
  136. package/dist/packem_shared/s1ngularity-BuU9Cxpy.js +1 -0
  137. package/dist/packem_shared/{scaffold-files-DVyfB0yz.js → scaffold-files-DJlz36Mu.js} +1 -1
  138. package/dist/packem_shared/scan-progress-DymX71_5.js +2 -0
  139. package/dist/packem_shared/{signatures-DIqFUOfs.js → signatures-CeL0bOEo.js} +1 -1
  140. package/dist/packem_shared/spinner-CPoBymcv.js +1 -0
  141. package/dist/packem_shared/table-oA7p7-yP.js +1 -0
  142. package/dist/packem_shared/tabs-BiSifphV.js +1 -0
  143. package/dist/packem_shared/{task-env-DzR4RkOj.js → task-env-C2lmxvzA.js} +1 -1
  144. package/dist/packem_shared/typosquats-BFKus_aM.js +1 -0
  145. package/dist/packem_shared/use-measured-height-BHm-HiSF.js +1 -0
  146. package/dist/packem_shared/vis-update-app-6QOYxnNx.js +1 -0
  147. package/dist/packem_shared/{vis-user-error-CRmrBaD1.js → vis-user-error-3YS7sPYy.js} +1 -1
  148. package/dist/packem_shared/{watch-loop-D1_e-qIl.js → watch-loop-CGi66Fs0.js} +1 -1
  149. package/dist/packem_shared/xxh3-BLHlvhgT.js +1 -0
  150. package/dist/release/core/package-managers/index.js +1 -1
  151. package/dist/release/core/version-actions/index.js +1 -1
  152. package/dist/release/index.js +1 -1
  153. package/index.js +26 -26
  154. package/package.json +9 -9
  155. package/dist/packem_chunks/orchestrator.js +0 -46
  156. package/dist/packem_shared/ReleaseClient-DAvbxCdo.js +0 -1
  157. package/dist/packem_shared/createAdapter-F7GidOzU.js +0 -1
  158. package/dist/packem_shared/createVersionActions-ByaJ1Nbv.js +0 -1
  159. package/dist/packem_shared/dependency-scan-CawAKoU_.js +0 -1
  160. package/dist/packem_shared/failure-log-BP-gCUb5.js +0 -2
  161. package/dist/packem_shared/formatBytes-_HvjOy8a-B_qQr4Hw.js +0 -4
  162. package/dist/packem_shared/glob-Cyk1H9ZL-Dxlf9Swz.js +0 -1
  163. package/dist/packem_shared/index-CDHP1kby.js +0 -1
  164. package/dist/packem_shared/lifecycle-DvmDIRbb.js +0 -2
  165. package/dist/packem_shared/missing-package-json-Cu5YVAot.js +0 -1
  166. package/dist/packem_shared/multi-eco-lockfiles-B2X3yhyo.js +0 -1
  167. package/dist/packem_shared/packument-zb18Jnlw.js +0 -1
  168. package/dist/packem_shared/registry-keys-DxdqMzyp.js +0 -1
  169. package/dist/packem_shared/s1ngularity-CO5GkkqX.js +0 -1
  170. package/dist/packem_shared/scan-progress-RwCRxJdX.js +0 -2
  171. package/dist/packem_shared/spinner-BJjbNl1F.js +0 -1
  172. package/dist/packem_shared/tabs--uxJGL8N.js +0 -1
  173. package/dist/packem_shared/typosquats-D4DEHhFy.js +0 -1
  174. package/dist/packem_shared/use-measured-height-DUZyyias.js +0 -1
  175. package/dist/packem_shared/vis-update-app-9b2kSk9f.js +0 -1
@@ -0,0 +1,8 @@
1
+ import{createRequire as Ne}from"node:module";import{a as E}from"../packem_shared/index-B4AjSxHU.js";import{VisReleaseError as y}from"../packem_shared/VisReleaseError-DZtgcKf8.js";import{DEFAULT_CHANGES_DIR as Ce,DEFAULT_DEPENDENCY_BUMP_RULES as je,DEFAULT_CONFIG as Ve}from"./DEFAULT_CLEAN_KEEP.js";import{L as Le}from"../packem_shared/index-BisalDCf.js";import{BUMP_LEVELS as Y,maxBump as U,normaliseGroup as q,bumpRank as V}from"../release/types.js";import{isValidPackageName as Fe,assertValidPackageName as Re}from"./security.js";import L from"./index.js";import{d as Be,c as Se}from"./index2.js";import{createShellRunner as xe}from"./shell-runner.js";import{a as Oe}from"./cargo-lock.js";let Ae;const Ie=e=>(Ae??=Ne(import.meta.url))(e),j=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,z=e=>{if(typeof j<"u"&&j.versions&&j.versions.node){const[t,n]=j.versions.node.split(".").map(Number);if(t>22||t===22&&n>=3||t===20&&n>=16)return j.getBuiltinModule(e)}return Ie(e)},{readdir:De,readFile:_e}=z("node:fs/promises"),{dirname:B,resolve:v,sep:_,join:Me}=z("node:path"),{realpathSync:X}=z("node:fs"),Te=e=>{const t="/version.rb";if(!e.endsWith(t))return!1;const n=e.length-t.length;let s;if(e.startsWith("lib/"))s=0;else{const o=e.indexOf("/lib/");if(o===-1)return!1;s=o+1}const a=e.slice(s+4,n);return a.length>0&&!/[\n\r\u2028\u2029]/.test(a)},P=e=>e,I=(e,t)=>(n,s)=>[...s.versionActions===e?[v(n.dir)]:[],...t===void 0?[]:(s.extraFiles??[]).filter(a=>t.test(a.path)).map(a=>B(v(n.dir,a.path)))],Ue=e=>({managed:!0,versionActions:e}),le=e=>t=>({managed:!0,...t.private?{}:{versionActions:e}}),M=e=>async t=>({touched:await e(t),warnings:[]}),Ge=P({claimedDirs:(e,t)=>Oe(e.dir,t).map(n=>B(n)),configKey:"cargo",discover:async e=>{const{discoverCargoCrates:t}=await import("./index3.js").then(n=>n.b);return t(e)},id:"cargo",perPackage:le("cargo"),toPackage:e=>e}),me=P({claimedDirs:(e,t)=>t.versionActions==="python"||t.pythonProjectDir!==void 0?[v(e.dir,t.pythonProjectDir??".")]:[],configKey:"python",discover:async e=>{const{discoverPythonProjects:t}=await import("./python-projects.js");return t(e)},id:"python",perPackage:le("python"),plan:async({context:e,pending:t,releases:n})=>{const{planPythonWorkspace:s}=await import("./python-plan.js"),a=n.flatMap(c=>{const l=e.depGraph.getPackage(c.name);return l?[{manifestPath:l.manifestPath,name:c.name,newVersion:c.newVersion}]:[]}),o=await s({cwd:e.cwd,dependents:e.packages.filter(c=>c.ecosystem==="python").map(c=>({dependencies:c.manifest.dependencies??{},name:c.name})),pending:t,releases:a});return{touched:o.touched,warnings:o.warnings}},toPackage:e=>e}),ue=P({claimedDirs:(e,t)=>[...t.versionActions==="maven"||t.pomPath!==void 0?[t.pomPath??"pom.xml"]:[],...(t.extraFiles??[]).map(s=>s.path).filter(s=>/(?:^|\/)pom\.xml$/.test(s))].map(s=>B(v(e.dir,s))),configKey:"maven",discover:async e=>{const{discoverMavenProjects:t}=await import("./maven-projects.js");return t(e)},id:"maven",plan:M(async({pending:e,projects:t,releases:n})=>{const{planMavenWorkspace:s}=await import("./maven-plan.js");return s({pending:e,projects:t,releases:n})}),toPackage:e=>e.package}),ge=P({claimedDirs:I("gradle",/(?:^|\/)(?:build\.gradle(?:\.kts)?|gradle\.properties)$/),configKey:"gradle",discover:async e=>{const{discoverGradleProjects:t}=await import("./index3.js").then(n=>n.g);return t(e)},id:"gradle",plan:M(async({pending:e,projects:t,releases:n})=>{const{planGradleWorkspace:s}=await import("./gradle-plan.js");return s({pending:e,projects:t,releases:n})}),toPackage:e=>e.package}),We=P({claimedDirs:I("composer",/(?:^|\/)composer\.json$/),configKey:"composer",discover:async e=>{const{discoverComposerProjects:t}=await import("./composer-projects.js");return t(e)},id:"composer",perPackage:e=>e.perPackage,toPackage:e=>e.package}),fe=P({claimedDirs:I("go",/(?:^|\/)go\.mod$/),configKey:"go",discover:async e=>{const{discoverGoProjects:t}=await import("./go-projects.js");return t(e)},id:"go",perPackage:e=>e.perPackage,toPackage:e=>e.package}),Ke=I("swift",/(?:^|\/)Package\.swift$/),ze=P({claimedDirs:(e,t,n)=>[...e.ecosystem===void 0&&v(e.dir)!==v(n)?[v(e.dir)]:[],...Ke(e,t)],configKey:"swift",discover:async e=>{const{discoverSwiftProjects:t}=await import("./swift-projects.js");return t(e)},id:"swift",perPackage:(e,t)=>({currentVersionResolver:"git-tag",managed:!0,versionActions:"swift",...v(e.package.dir)===v(t)?{releaseTagPattern:"{version}"}:{}}),toPackage:e=>e.package}),he=P({claimedDirs:(e,t)=>{const n=t.versionActions==="gem"?[v(e.dir)]:[];for(const s of t.extraFiles??[]){const a=v(e.dir,s.path);if(/\.gemspec$/.test(s.path))n.push(B(a));else if(Te(s.path)){const o=a.lastIndexOf(`${_}lib${_}`);o!==-1&&n.push(a.slice(0,o))}}return n},configKey:"gem",discover:async e=>{const{discoverGemProjects:t}=await import("./gem-projects.js");return t(e)},id:"gem",plan:M(async({pending:e,projects:t,releases:n})=>{const{planGemWorkspace:s}=await import("./gem-plan.js");return s({pending:e,projects:t,releases:n})}),toPackage:e=>e.package}),ye=P({claimedDirs:I("hex",/(?:^|\/)mix\.exs$/),configKey:"hex",discover:async e=>{const{discoverHexProjects:t}=await import("./hex-projects.js");return t(e)},id:"hex",plan:M(async({pending:e,projects:t,releases:n})=>{const{planHexWorkspace:s}=await import("./hex-plan.js");return s({pending:e,projects:t,releases:n})}),toPackage:e=>e.package}),we=P({claimedDirs:I("nuget",/\.(?:cs|fs)proj$|(?:^|\/)Directory\.Build\.props$/),configKey:"nuget",discover:async e=>{const{discoverNuGetProjects:t}=await import("./nuget-projects.js");return t(e)},id:"nuget",plan:M(async({pending:e,projects:t,releases:n})=>{const{planNuGetWorkspace:s}=await import("./nuget-plan.js");return s({pending:e,projects:t,releases:n})}),toPackage:e=>e.package}),ve=P({claimedDirs:I("zig",/(?:^|\/)build\.zig\.zon$/),configKey:"zig",discover:async e=>{const{discoverZigProjects:t}=await import("./zig-projects.js");return t(e)},id:"zig",plan:M(async({pending:e,projects:t,releases:n})=>{const{planZigWorkspace:s}=await import("./zig-plan.js");return s({pending:e,projects:t,releases:n})}),toPackage:e=>e.package}),ke=P({claimedDirs:I("dart",/(?:^|\/)pubspec\.yaml$/),configKey:"dart",discover:async e=>{const{discoverDartProjects:t}=await import("./dart-projects.js");return t(e)},id:"dart",plan:M(async({pending:e,projects:t,releases:n})=>{const{planDartWorkspace:s}=await import("./dart-plan.js");return s({pending:e,projects:t,releases:n})}),toPackage:e=>e.package}),Z=[Ge,me,ue,ge,We,fe,ze,he,ye,we,ve,ke],Ht=[me,ue,fe,ge,he,ye,we,ve,ke],Ye=(e,t,n)=>e.perPackage?e.perPackage(t,n):Ue(e.id),Q=(e,t)=>!!e[t.configKey]?.discover,He=/^exit[\s-]prerelease\s*:\s*(.+)$/i,Je=/^(.+)@(\d+\.\d+\.\d+(?:[-+].*)?)$/,ee=(e,t,n)=>{if(!Fe(e))throw new y({code:"BUMP_FILE_INVALID",file:n,message:`Invalid replay condition "${t}": ${JSON.stringify(e)} is not a valid package name.`,packageName:e||void 0});return e},qe=(e,t)=>{if(typeof e!="string"||e.trim()==="")throw new y({code:"BUMP_FILE_INVALID",file:t,message:`Invalid replay condition: ${JSON.stringify(e)}. Expected "name@1.2.0" or "exit-prerelease:name".`});const n=e.trim(),s=He.exec(n);if(s)return{kind:"exit-prerelease",package:ee((s[1]??"").trim(),n,t)};const a=Je.exec(n);if(a)return{kind:"version",package:ee((a[1]??"").trim(),n,t),version:a[2]??""};throw new y({code:"BUMP_FILE_INVALID",file:t,message:`Invalid replay condition "${n}". Expected "name@1.2.0" or "exit-prerelease:name".`})},Xe=(e,t)=>{if(!Array.isArray(e))throw new y({code:"BUMP_FILE_INVALID",file:t,message:'`replay` must be a list of conditions (e.g. ["name@1.2.0", "exit-prerelease:name"]).'});return e.map(n=>qe(n,t))},G=e=>!("bumps"in e.payload)&&Array.isArray(e.payload.replay)&&e.payload.replay.length>0,te=e=>/^\d+\.\d+\.\d+-/.test(e),Ze=(e,t)=>e.package!==t.name?!1:e.kind==="version"?t.newVersion===e.version:te(t.oldVersion)&&!te(t.newVersion),Qe=(e,t)=>{const n=new Map,s=[],a=[];for(const o of e){if(!G(o))continue;const c=o.payload.replay;let l=!0;for(const r of c){const i=t.find(p=>Ze(r,p));if(i){const p=n.get(i.name)??[];p.some(d=>d.id===o.id)||p.push(o),n.set(i.name,p)}else l=!1}l?s.push(o):a.push(o)}return{consumed:s,injectionsByPackage:n,retained:a}},et=/^---\r?\n([\s\S]*?)\r?\n---\r?\n?([\s\S]*)$/,tt=e=>{const t=et.exec(e);return t?{body:(t[2]??"").trim(),frontmatter:t[1]??""}:null},nt=/^(?:@[a-z0-9-]+\/)?[\w.-]+(?:\/[\w.-]+)*(?::[\w.-]+)?$/i,st=214,at=e=>e.length===0||e.length>st||e.startsWith(".")||e.startsWith("_")||e.startsWith("-")?!1:nt.test(e),W=e=>typeof e=="string"&&Y.includes(e),rt=/^ {0,3}(#{1,3})\s+\S/,ot=/^ {0,3}(?:```|~~~)/,it=e=>{let t,n=0,s=!1;for(const a of e.split(/\r?\n/)){if(ot.test(a)){s=!s;continue}if(s)continue;const o=rt.exec(a);if(!o)continue;const c=(o[1]??"").length,l=4-c;l>n&&(n=l,t=c===1?"major":c===2?"minor":"patch")}return t},ct=/^\s*(pr|commit|author)\s*:\s*(.+?)\s*$/i,pt=e=>{const t=e.split(/\r?\n/),n={};let s=0;for(const o of t){if(o.trim()===""){s+=1;continue}const c=ct.exec(o);if(!c)break;const[,l="",r=""]=c;switch(l.toLowerCase()){case"author":{n.author=r.startsWith("@")?r:`@${r}`;break}case"commit":{n.commit=r;break}case"pr":{const p=Number.parseInt(r,10);!Number.isNaN(p)&&p>0&&(n.pr=p);break}}s+=1}const a=t.slice(s).join(`
2
+ `).trim();return{meta:Object.keys(n).length>0?n:void 0,remainder:a}},ne=e=>typeof e=="object"&&e!==null&&!Array.isArray(e)&&("bump"in e||"replay"in e),dt=(e,t,n)=>{const s=t.replay!==void 0;if(s&&t.bump!==void 0)throw new y({code:"BUMP_FILE_INVALID",file:n,message:`"${e}" sets both \`bump\` and \`replay\`. Replay files are changelog-only and never bump — remove \`bump\`, or drop \`replay\` to make this a normal change file.`,packageName:e});const a=t.bump===void 0&&s?"none":t.bump;if(!W(a))throw new y({code:"BUMP_FILE_INVALID",file:n,message:`Invalid bump level for "${e}": ${JSON.stringify(t.bump)}. Expected one of: ${Y.join(", ")}`,packageName:e});const o={bump:a,package:e};if(s&&(o.replay=Xe(t.replay,n)),t.releaseAs!==void 0){if(typeof t.releaseAs!="string"||!/^\d+\.\d+\.\d+(?:[-+].*)?$/.test(t.releaseAs))throw new y({code:"BUMP_FILE_INVALID",file:n,message:`Invalid releaseAs for "${e}": ${JSON.stringify(t.releaseAs)}. Expected a semver string like "2.0.0" or "2.0.0-rc.1".`,packageName:e});o.releaseAs=t.releaseAs}if(t.cascade!==void 0){if(typeof t.cascade!="object"||t.cascade===null||Array.isArray(t.cascade))throw new y({code:"BUMP_FILE_INVALID",file:n,message:`Cascade block for "${e}" must be an object mapping package globs to bump levels.`,packageName:e});const c={};for(const[l,r]of Object.entries(t.cascade)){if(!W(r))throw new y({code:"BUMP_FILE_INVALID",file:n,message:`Invalid cascade bump level for "${l}": ${JSON.stringify(r)}.`,packageName:e});c[l]=r}o.cascade=c}return o},x=e=>e.replaceAll(/^.*[/\\]/g,"").replace(/\.md$/i,""),lt=(e,t)=>{const n=tt(e);if(!n)throw new y({code:"BUMP_FILE_INVALID",file:t,message:"Change file is missing YAML frontmatter (expected `---` delimiters)."});let s;try{s=Le(n.frontmatter,{strict:!0})}catch(r){throw new y({cause:r,code:"BUMP_FILE_INVALID",file:t,message:`YAML parse failed: ${r.message}`})}if(s==null)return{body:n.body.trim(),id:x(t),path:t,payload:{bumps:{}}};if(typeof s!="object"||Array.isArray(s))throw new y({code:"BUMP_FILE_INVALID",file:t,message:"Frontmatter must be a YAML object mapping package names to bump levels."});const a=Object.entries(s);if(a.length===0)return{body:n.body.trim(),id:x(t),path:t,payload:{bumps:{}}};for(const[r]of a)if(!at(r))throw new y({code:"BUMP_FILE_INVALID",file:t,message:`Invalid package name: ${JSON.stringify(r)}.`,packageName:r});let o;if(a.length===1&&ne(a[0][1])){const[r,i]=a[0];o=dt(r,i,t)}else{const r={},i=[];for(const[p,d]of a){if(ne(d))throw new y({code:"BUMP_FILE_INVALID",file:t,message:`Mixed simple + nested entries are not allowed. Package "${p}" uses the nested shape but the file has multiple top-level entries.`,packageName:p});if(d==null||d===""){i.push(p);continue}if(!W(d))throw new y({code:"BUMP_FILE_INVALID",file:t,message:`Invalid bump level for "${p}": ${JSON.stringify(d)}. Expected one of: ${Y.join(", ")}`,packageName:p});r[p]=d}if(i.length>0){const p=it(n.body);if(!p)throw new y({code:"BUMP_FILE_INVALID",file:t,message:`No bump level for ${i.map(d=>`"${d}"`).join(", ")}: the entry is empty and the body has no markdown heading to infer one from. Add an explicit level (e.g. \`${i[0]}: minor\`) or a heading (\`# major\`, \`## minor\`, \`### patch\`).`,packageName:i[0]});for(const d of i)r[d]=p}o={bumps:r}}const{meta:c,remainder:l}=pt(n.body);return{body:l,id:x(t),meta:c,path:t,payload:o}},Jt=(e,t)=>{let n;if("bumps"in e){const s=Object.entries(e.bumps).map(([a,o])=>`${O(a)}: ${o}`);n=s.length>0?s.join(`
3
+ `):"{}"}else{const s=[`${O(e.package)}:`,` bump: ${e.bump}`];if(e.releaseAs&&s.push(` releaseAs: ${e.releaseAs}`),e.cascade){s.push(" cascade:");for(const[a,o]of Object.entries(e.cascade))s.push(` ${O(a)}: ${o}`)}if(e.replay&&e.replay.length>0){s.push(" replay:");for(const a of e.replay){const o=a.kind==="version"?`${a.package}@${a.version}`:`exit-prerelease:${a.package}`;s.push(` - "${o}"`)}}n=s.join(`
4
+ `)}return`---
5
+ ${n}
6
+ ---
7
+ ${t.trim()===""?"":`${t.trim()}
8
+ `}`},O=e=>/^[a-z0-9-]/.test(e)?e:`"${e}"`,mt=e=>{const t=new Map,n=a=>a==="major"?3:a==="minor"?2:a==="patch"?1:0,s=(a,o)=>{const c=t.get(a);(c===void 0||n(o)>n(c))&&t.set(a,o)};for(const a of e)if("bumps"in a.payload)for(const[o,c]of Object.entries(a.payload.bumps))s(o,c);else s(a.payload.package,a.payload.bump);return t},se=(e,t)=>t.filter(n=>"bumps"in n.payload?Object.hasOwn(n.payload.bumps,e):n.payload.package===e),ut=new Set(["README.md","readme.md"]),gt=async e=>{const t=e.changesDir??Ce,n=v(e.cwd),s=v(e.cwd,t),a=s,o=n.endsWith(_)?n:`${n}${_}`;if(s!==n&&!s.startsWith(o))throw new y({code:"CONFIG_INVALID",message:`changesDir resolves outside the workspace: ${s} (workspace: ${n}). Set release.changesDir to a path inside the repo.`});const c=[];let l;try{l=await De(a)}catch(p){if(p.code==="ENOENT")return{files:[],warnings:[]};throw new y({cause:p,code:"CONFIG_INVALID",message:`Cannot read change-files directory ${a}: ${p.message}`})}const r=l.filter(p=>!ut.has(p)&&p.endsWith(".md"));return{files:await Promise.all(r.map(async p=>{const d=Me(a,p),u=await _e(d,"utf8");return lt(u,d)})),warnings:c}},ft=(e,t)=>{if(!t)return;if(Object.hasOwn(t,e)){const s=Object.keys(t).filter(a=>a!==e&&re(a)&&L(a,e));return ae(e,t[e],s)}const n=[];for(const[s]of Object.entries(t))re(s)&&L(s,e)&&n.push(s);if(n.length>0){const[s,...a]=n;return ae(e,t[s],a)}},ae=(e,t,n=[])=>{let{tag:s}=t;return s==="branch-name"&&(s=ht(e)),{branch:e,mode:t.mode??"auto-publish",...n.length>0?{overlapping:n}:{},prerelease:t.prerelease,range:t.range,tag:s}},ht=e=>e.toLowerCase().replaceAll(/[^a-z0-9.-]/g,"-").replaceAll(/^-+|-+$/g,"")||"branch",yt=/[!()*+?@[\]{|}]/,re=e=>yt.test(e),wt=async(e,t)=>{try{const n=await t.run("git",["rev-parse","--abbrev-ref","HEAD"],{cwd:e,silent:!0});if(n.exitCode!==0)return;const s=n.stdout.trim();return s==="HEAD"||s===""?void 0:s}catch{return}},vt=["dependencies","devDependencies","peerDependencies","optionalDependencies"];class kt{dependents;dependenciesByPackage;packagesByName;constructor(t){this.dependents=new Map,this.dependenciesByPackage=new Map,this.packagesByName=new Map;for(const n of t){if(this.packagesByName.has(n.name))throw new y({code:"DUPLICATE_PACKAGE_NAME",message:`Duplicate package name "${n.name}" — found at ${this.packagesByName.get(n.name).dir} and ${n.dir}.`,packageName:n.name});this.packagesByName.set(n.name,n),this.dependents.set(n.name,[]),this.dependenciesByPackage.set(n.name,[])}for(const n of t)for(const s of vt){const a=n.manifest[s];if(!(!a||typeof a!="object"))for(const[o,c]of Object.entries(a))this.packagesByName.has(o)&&(this.dependents.get(o).push({kind:s,name:n.name,range:c}),this.dependenciesByPackage.get(n.name).push({kind:s,name:o,range:c}))}}getPackage(t){return this.packagesByName.get(t)}allPackages(){return[...this.packagesByName.values()]}isInternal(t){return this.packagesByName.has(t)}getDependents(t){return this.dependents.get(t)??[]}getDependencies(t){return this.dependenciesByPackage.get(t)??[]}topologicalSort(t){const n=t?new Set(t):new Set(this.packagesByName.keys()),s=new Set,a=new Set,o=[],c=(l,r)=>{if(!s.has(l)){if(a.has(l)){const i=r.indexOf(l),p=i===-1?[...r,l]:[...r.slice(i),l];throw new y({code:"CYCLIC_DEPENDENCY",message:`Cyclic dependency detected: ${p.join(" → ")}`})}a.add(l);for(const i of this.getDependencies(l))n.has(i.name)&&i.kind!=="devDependencies"&&c(i.name,[...r,l]);a.delete(l),s.add(l),o.push(l)}};for(const l of n)c(l,[]);return o}get size(){return this.packagesByName.size}}const F=e=>{const{current:t,prerelease:n}=e;let{bump:s}=e;if(!E.valid(t))throw new y({code:"CONFIG_INVALID",message:`Invalid current version: ${JSON.stringify(t)}`});const a=E.parse(t),o=a.prerelease[0],c=a.prerelease.length>0;if(a.major===0&&e.bumpMinorPreMajor&&(s==="major"&&(s="minor"),s==="minor"&&e.bumpPatchForMinorPreMajor&&(s="patch")),s==="none")return(o??void 0)===(n??void 0)?t:!c&&n?`${a.major}.${a.minor}.${a.patch}-${n}.0`:c&&!n?`${a.major}.${a.minor}.${a.patch}`:c&&n?`${a.major}.${a.minor}.${a.patch}-${n}.0`:t;if(c&&n&&o===n){const r=Pt(a);if(oe[s]<=oe[r]){const d=E.inc(t,"prerelease",n);if(!d)throw new y({code:"CONFIG_INVALID",message:`semver.inc returned null for prerelease bump on ${t}`});return d}const i=`${a.major}.${a.minor}.${a.patch}`,p=E.inc(i,s);if(!p)throw new y({code:"CONFIG_INVALID",message:`semver.inc returned null for ${s} bump on ${i}`});return`${p}-${n}.0`}if(n){const r=`${a.major}.${a.minor}.${a.patch}`,i=E.inc(r,s);if(!i)throw new y({code:"CONFIG_INVALID",message:`semver.inc returned null for ${s} bump on ${r}`});return`${i}-${n}.0`}if(c){const r=`${a.major}.${a.minor}.${a.patch}`,i=E.inc(r,s);if(!i)throw new y({code:"CONFIG_INVALID",message:`semver.inc returned null for ${s} bump on ${r}`});return i}const l=E.inc(t,s);if(!l)throw new y({code:"CONFIG_INVALID",message:`semver.inc returned null for ${s} bump on ${t}`});return l},oe={major:3,minor:2,patch:1},Pt=e=>e.minor===0&&e.patch===0?"major":e.patch===0?"minor":"patch",bt=(e,t)=>{const n=Pe(t);return n?E.satisfies(e,n,{includePrerelease:!0}):!0},Pe=e=>{if(!e||e.startsWith("catalog:")||e==="*"||e==="workspace:*"||e==="workspace:^"||e==="workspace:~")return null;if(e.startsWith("workspace:")){const t=e.slice(10);return t==="*"||t==="^"||t==="~"?null:t}if(e.startsWith("npm:")){const t=e.lastIndexOf("@");return t>4?e.slice(t+1):null}return e},T=100,N=(e,t,n,s,{isCascadeBump:a=!1,isDependencyBump:o=!1,isGroupBump:c=!1,source:l}={})=>{const r=e.get(t);if(r){const i=r.type;return r.type=U(r.type,n),r.reasons.add(s),o&&(r.isDependencyBump=!0),c&&(r.isGroupBump=!0),a&&(r.isCascadeBump=!0),l&&r.sources.set(l.name,{bumpType:l.bumpType,newVersion:l.newVersion}),r.type!==i}return e.set(t,{isCascadeBump:a,isDependencyBump:o,isGroupBump:c,name:t,proactiveSeen:!1,reasons:new Set([s]),sources:l?new Map([[l.name,{bumpType:l.bumpType,newVersion:l.newVersion}]]):new Map,type:n}),!0},Et=(e,t,n,s)=>{const a=n?.get(e)?.dependencyBumpRules?.[t];if(a!==void 0)return a;const o=s.dependencyBumpRules?.[t];return o!==void 0?o:je[t]??!1},ie=(e,t)=>V(e)>=V(t),ce=(e,t)=>t==="match"?e:t,$t=(e,t)=>t===!0?!0:Array.isArray(t)?t.includes(e):!1,Nt=10,At=(e,t,n,s,a,o,c)=>{let l=!1;for(const r of e.values()){const i=t.getPackage(r.name);if(!i)continue;const p=s.currentVersions?.get(r.name)??i.version,d=n.get(r.name)??F({bump:r.type,bumpMinorPreMajor:s.bumpMinorPreMajor,bumpPatchForMinorPreMajor:s.bumpPatchForMinorPreMajor,current:p,prerelease:s.prerelease});n.set(r.name,d);for(const u of t.getDependents(r.name)){if(u.kind==="devDependencies"){if(!$t(r.name,o.bumpDevDependencies))continue;if(N(e,u.name,"patch","DEVDEPENDENCY_BUMPED",{isDependencyBump:!0,source:{bumpType:r.type,name:r.name,newVersion:d}})&&(l=!0,n.delete(u.name)),o.bumpDevDependencies===!0){let k=c.get(r.name);k||(k=new Set,c.set(r.name,k)),k.add(u.name)}continue}const m=Pe(u.range);if(m===null||bt(d,m))continue;let g,h="DEPENDENCY_OUT_OF_RANGE";u.kind==="peerDependencies"?(g=r.type==="none"?"patch":r.type,h="PEER_DEP_MATCH",m.startsWith("^0.")&&g!=="patch"&&a.push(`^0.x peer dep "${r.name}" → "${u.name}" produced a ${g} bump. Consider widening the range manually.`)):g="patch",N(e,u.name,g,h,{isDependencyBump:!0,source:{bumpType:r.type,name:r.name,newVersion:d}})&&(l=!0,n.delete(u.name))}}return l},It=(e,t,n)=>{let s=!1;for(const a of n.fixed??[]){const o=q(a),c=R(o.packages,t),l=c.filter(i=>e.has(i));if(l.length===0)continue;let r="none";for(const i of l)r=U(r,e.get(i).type);for(const i of c){if(!t.isInternal(i))continue;N(e,i,r,"FIXED_GROUP",{isGroupBump:!0})&&(s=!0)}}for(const a of n.linked??[]){const o=q(a),l=R(o.packages,t).filter(i=>e.has(i));if(l.length===0)continue;let r="none";for(const i of l)r=U(r,e.get(i).type);for(const i of l)N(e,i,r,"LINKED_GROUP",{isGroupBump:!0})&&(s=!0)}return s},pe=new WeakMap,Dt=/[!()*+?@[\]{|}]/,R=(e,t)=>{let n=pe.get(t);n||(n={allNames:t.allPackages().map(a=>a.name),matched:new Map},pe.set(t,n));const s=new Set;for(const a of e){if(!Dt.test(a)){s.add(a);continue}let o=n.matched.get(a);o||(o=n.allNames.filter(c=>L(a,c)),n.matched.set(a,o));for(const c of o)s.add(c)}return[...s]},_t=(e,t,n,s,a,o)=>{let c=!1;const l=s.updateInternalDependencies??"out-of-range",r=i=>{const p=o.get(i.name);if(p!==void 0)return p;const d=F({bump:i.type,bumpMinorPreMajor:a.bumpMinorPreMajor,bumpPatchForMinorPreMajor:a.bumpPatchForMinorPreMajor,current:a.currentVersions?.get(i.name)??n.getPackage(i.name).version,prerelease:a.prerelease});return o.set(i.name,d),d};for(const i of t){if("bumps"in i.payload||!i.payload.cascade)continue;const p=e.get(i.payload.package);if(!p)continue;const d=o.get(p.name)??F({bump:p.type,bumpMinorPreMajor:a.bumpMinorPreMajor,bumpPatchForMinorPreMajor:a.bumpPatchForMinorPreMajor,current:a.currentVersions?.get(p.name)??n.getPackage(p.name).version,prerelease:a.prerelease});o.set(p.name,d);for(const[u,m]of Object.entries(i.payload.cascade))for(const g of R([u],n)){if(!n.isInternal(g))continue;N(e,g,m,"CASCADE",{isCascadeBump:!0,source:{bumpType:p.type,name:p.name,newVersion:d}})&&(c=!0)}}for(const i of e.values()){const p=a.perPackageConfig?.get(i.name)?.cascadeTo;if(p)for(const[d,u]of Object.entries(p)){if(!ie(i.type,u.trigger))continue;const m=ce(i.type,u.bumpAs),g=r(i);for(const h of R([d],n)){if(!n.isInternal(h))continue;N(e,h,m,"CASCADE_TO",{isCascadeBump:!0,source:{bumpType:i.type,name:i.name,newVersion:g}})&&(c=!0)}}}if(l==="out-of-range")return c;for(const i of e.values())if(!i.proactiveSeen&&!(l==="minor"&&V(i.type)<V("minor"))){for(const p of n.getDependents(i.name)){const d=Et(p.name,p.kind,a.perPackageConfig,s);if(d===!1||!ie(i.type,d.trigger))continue;const u=ce(i.type,d.bumpAs);if(u==="none")continue;const m=r(i);N(e,p.name,u,"DEPENDENCY_BUMPED",{isDependencyBump:!0,source:{bumpType:i.type,name:i.name,newVersion:m}})&&(c=!0)}i.proactiveSeen=!0}return c},Mt=(e,t,n,s={})=>{const a=e.filter(m=>G(m)),o=a.length>0?e.filter(m=>!G(m)):e,c=new Map,l=[],r=new Map;for(const[m,g]of mt(o).entries()){if(!t.isInternal(m)){l.push(`Change file references non-workspace package "${m}" — ignored.`);continue}g!=="none"&&N(c,m,g,"EXPLICIT")}for(const m of s.catalogConsumers??[]){if(!t.isInternal(m.packageName))continue;const g=`catalog:${m.catalog}/${m.dep}`;N(c,m.packageName,"patch","CATALOG_CHANGED",{isDependencyBump:!0,source:{bumpType:"patch",name:g,newVersion:m.newVersion??""}})}const i=new Map,p=m=>{const g=se(m,o).map(f=>"releaseAs"in f.payload?{file:f.path,version:f.payload.releaseAs}:void 0).filter(f=>f!==void 0&&typeof f.version=="string"),h=new Set(g.map(f=>f.version));if(h.size>1)throw new y({code:"BUMP_FILE_INVALID",message:`Conflicting releaseAs values for ${m}: ${[...h].join(", ")}. Found in: ${g.map(f=>f.file).join(", ")}. Consolidate the change files to a single override.`,packageName:m});return g[0]?.version},d=new Map;for(const m of c.values()){if(m.type==="none")continue;const g=p(m.name);g&&(d.set(m.name,g),r.set(m.name,g))}for(let m=0;m<T;m+=1){const g=At(c,t,r,s,l,n,i),h=It(c,t,n),f=_t(c,o,t,n,s,r);if(!g&&!h&&!f)break;m===T-1&&l.push(`Release plan did not converge after ${T} iterations — releasing the current best plan. This usually indicates a config bug (cyclic cascade?).`)}for(const[m,g]of i){const h=g.size;h>Nt&&l.push(`bumpDevDependencies: true triggered ${h} patch-cascades to distinct dependents from a single devdep bump (${m}). Consider scoping with the array form ['only', 'these', 'sources'].`)}const u=[];for(const m of c.values()){if(m.type==="none")continue;const g=t.getPackage(m.name);if(!g)continue;const h=se(m.name,o),f=d.get(m.name),w=s.currentVersions?.get(m.name)??g.version,k=f??r.get(m.name)??F({bump:m.type,bumpMinorPreMajor:s.bumpMinorPreMajor,bumpPatchForMinorPreMajor:s.bumpPatchForMinorPreMajor,current:w,prerelease:s.prerelease});u.push({changeFiles:h,isCascadeBump:m.isCascadeBump,isDependencyBump:m.isDependencyBump,isGroupBump:m.isGroupBump,name:m.name,newVersion:k,oldVersion:w,reasons:[...m.reasons],sources:[...m.sources.entries()].map(([A,$])=>({name:A,...$})),type:m.type})}if(u.sort((m,g)=>m.name.localeCompare(g.name)),a.length>0){const m=Qe(a,u);for(const[g,h]of m.injectionsByPackage){const f=u.find(w=>w.name===g);f&&(f.changeFiles=[...f.changeFiles,...h])}return{consumedChangeFiles:[...o,...m.consumed],releases:u,warnings:l}}return{consumedChangeFiles:o,releases:u,warnings:l}},Ct=async(e,t,n,s,a)=>{const o=[],c=[];if(a)try{const{detectCatalogChanges:l,findCatalogConsumers:r,parseCatalogs:i}=await import("./catalog-detector.js"),p=await e.readCatalogYaml(n),d=i(p);let u;try{const f=await t.run("git",["show","HEAD~1:pnpm-workspace.yaml"],{cwd:n,silent:!0});f.exitCode===0&&(u=f.stdout)}catch{}const m=i(u),h=l(m,d).filter(f=>f.oldVersion!==void 0&&f.newVersion!==void 0);if(h.length>0){const f=r(s,d);for(const w of h){const A=f.get(w.catalog)?.get(w.dep)??[];for(const $ of A)o.push({catalog:w.catalog,dep:w.dep,newVersion:w.newVersion,oldVersion:w.oldVersion,packageName:$.packageName})}o.length>0&&c.push(`Catalog change-detection: ${h.length} catalog dep(s) moved; ${o.length} consumer-package patch bump(s) tagged CATALOG_CHANGED.`)}}catch(l){c.push(`Catalog change-detection skipped: ${l.message}.`)}return{entries:o,warnings:c}},jt=(...e)=>{let t={...Ve};for(const n of e)t={...t,...n};return t},Vt=async(e,t)=>{let n={};try{const{loadVisConfig:s}=await import("./CONFIG_FILES.js"),a=await s(e);a.release&&(n=a.release)}catch(s){const{code:a}=s,o=s.message??"";if(!(a==="ENOENT"||a==="MODULE_NOT_FOUND"||/cannot find module/i.test(o)))throw s}return jt(n,t??{})},be=async(e,t,n={})=>{const s=await e.listPackages(),a=[],o=new Map,c=new Map,l=d=>{const u=v(d);try{return X.native(u)}catch{try{return X(u)}catch{return u}}},r=n.cwd===void 0?void 0:l(n.cwd),i=d=>d.replaceAll("\\","/"),p=[];for(const{manifest:d,manifestPath:u}of s){const m=K(typeof d.name=="string"?d.name:"",d,t);if(d.napi!==void 0||m.versionActions==="native-addon"){const h=i(u.replace(/[/\\]package\.json$/i,""));p.push(`${h}/npm/`)}}for(const{manifest:d,manifestPath:u}of s){if(typeof d.name!="string"||d.name==="")continue;const m=i(u.replace(/[/\\]package\.json$/i,""));if(p.some(f=>m.startsWith(f)))continue;if(Re(d.name),c.has(d.name))throw new y({code:"DUPLICATE_PACKAGE_NAME",message:`Duplicate package name "${d.name}" — at ${c.get(d.name)} and ${u}.`,packageName:d.name});if(c.set(d.name,u),r!==void 0){const f=l(u),w=r.endsWith(_)?r:`${r}${_}`,k=$=>_==="\\"?$.toLowerCase():$,A=k(f);if(A!==k(r)&&!A.startsWith(k(w)))throw new y({code:"CONFIG_INVALID",message:`Package manifest is outside the workspace: ${u} (workspace: ${r}).`,packageName:d.name})}const g=K(d.name,d,t);if(!Ee(d.name,d,g,t))continue;const h=u.replace(/[/\\]package\.json$/i,"");a.push({dir:h,manifest:d,manifestPath:u,name:d.name,private:d.private===!0,version:typeof d.version=="string"?d.version:"0.0.0"}),o.set(d.name,g)}return{packages:a,perPackageConfig:o}},K=(e,t,n)=>{const s=n.packages?.[e]??{},a=t["vis-release"]??{};return{...s,...a}},Ee=(e,t,n,s)=>n.managed===!1?!1:n.managed===!0?!0:de(e,s.ignore??[])?!1:de(e,s.include??[])?!0:t.private===!0&&!(s.privatePackages?.version??!1)?!1:s.defaultManaged??!1,de=(e,t)=>t.some(n=>L(n,e)),Lt=(e,t)=>t.versionActions!==void 0?t.versionActions:e.manifest.napi!==void 0?"native-addon":e.private?"private":"npm",qt=Object.defineProperty({__proto__:null,discoverPackages:be,isPackageManaged:Ee,mergePerPackageConfig:K,resolveVersionActionsId:Lt},Symbol.toStringTag,{value:"Module"}),Ft=async(e,t,n)=>{const s=await import("node:fs/promises"),o=await be({listPackages:async()=>{const i=await e.listWorkspacePackages(n);return(await Promise.all(i.map(async d=>{const u=`${d.path}/package.json`;try{const m=await s.readFile(u,"utf8");return{manifest:JSON.parse(m),manifestPath:u}}catch{return}}))).filter(d=>d!==void 0)}},t,{cwd:n}),{perPackageConfig:c}=o;let{packages:l}=o;const r=new Map;if(Z.some(i=>Q(t,i))){for(const p of Z){if(!Q(t,p))continue;const d=new Set;for(const m of l)for(const g of p.claimedDirs(m,c.get(m.name)??{},n))d.add(g);const u=await p.discover({claimedDirs:d,cwd:n});for(const m of u){const{name:g}=p.toPackage(m);c.set(g,{...Ye(p,m,n),...t.packages?.[g]})}l=[...l,...u.map(m=>p.toPackage(m))],r.set(p.id,u)}const i=new Map;for(const p of l){const d=i.get(p.name);if(d!==void 0&&p.ecosystem!==void 0)throw new y({code:"CONFIG_INVALID",message:`${p.name} is discovered as a ${p.ecosystem} project, but ${d.dir} already has that name. Rename one of them in config.packages.`,packageName:p.name});i.set(p.name,p)}}{const{assertSupportedVersionFiles:i}=await import("./cargo-lock.js").then(p=>p.v);for(const[p,d]of c)i(p,d.versionFiles??[])}return{packages:l,perPackageConfig:c,projectsByEcosystem:r}},Xt=async(e={})=>{const t=e.cwd??process.cwd(),n=xe(),s=await Be(t),a=Se(s,n),o=await a.detectVersion(t);if(o&&!Rt(o,a.minVersion))throw new y({code:"PM_VERSION_TOO_LOW",hint:`pnpm install -g ${a.id}@latest (or your equivalent)`,message:`${a.id} version ${o} is below the required minimum ${a.minVersion}. Upgrade ${a.id} to enable release operations.`});const c=await Vt(t,e.config);!c.acknowledgeUnstable&&process.env.VIS_RELEASE_SUPPRESS_UNSTABLE!=="1"&&process.stderr.write("[vis release] ⚠ This subsystem is flagged unstable. Set `release.acknowledgeUnstable: true` in vis.config.ts to suppress this warning. (RFC §21.2)\n");const l=e.channel??await wt(t,n),r=l?ft(l,c.channels):void 0,{packages:i,perPackageConfig:p,projectsByEcosystem:d}=await Ft(a,c,t),u=new kt(i),{files:m}=await gt({changesDir:c.changesDir,cwd:t}),{readPreMode:g}=await import("./pre-mode.js"),h=await g(t,c.changesDir??".vis/release");let f;h?.mode==="pre"?f=h.tag:h?.mode==="exit-pending"?f=void 0:f=r?.prerelease;const w=e.firstRelease===!0,{resolveCurrentVersionsForWorkspace:k}=await import("./version-resolver.js"),{versions:A,warnings:$}=await k(i,u,c,p,{cwd:t,firstRelease:w,pm:a,runner:n,skipRegistryLookup:e.skipRegistryLookup===!0}),{entries:$e,warnings:H}=await Ct(a,n,t,i,c.detectCatalogChanges===!0),b=Mt(m,u,c,{bumpMinorPreMajor:c.bumpMinorPreMajor,bumpPatchForMinorPreMajor:c.bumpPatchForMinorPreMajor,catalogConsumers:$e,currentVersions:A,perPackageConfig:p,prerelease:f});if(H.length>0&&b.warnings.push(...H),$.length>0&&b.warnings.push(...$),w&&b.warnings.push('First-release mode: currentVersionResolver forced to "disk", remote tag-collision checks skipped. Drop --first-release after the initial wave lands.'),h?.mode==="pre"&&b.warnings.push(`Pre-mode is ACTIVE (tag "${h.tag}"); every version produces a prerelease. Exit with \`vis release pre exit\` when ready to ship stable.`),h?.mode==="exit-pending"&&b.warnings.push(`Pre-mode is EXIT-PENDING (was "${h.tag}"); the next \`vis release version\` will consolidate the prerelease and delete pre.json.`),r?.overlapping&&r.overlapping.length>0&&b.warnings.push(`Branch "${l}" matches multiple channel patterns: "${r.branch}" (active) plus ${r.overlapping.map(C=>`"${C}"`).join(", ")}. Reorder channels in vis.config.ts if this is unintentional.`),e.projects&&e.projects.length>0){const{default:C}=await import("./index.js"),D=e.projects;b.releases=b.releases.filter(S=>D.some(J=>S.name===J||C(J,S.name)))}{const C=b.releases.flatMap(D=>u.getPackage(D.name)?.ecosystem==="go"?[{name:D.name,newVersion:D.newVersion}]:[]);if(C.length>0){const{planGoWorkspace:D}=await import("./go-plan.js");D({projects:d.get("go")??[],releases:C})}}return{branch:l,channel:r?{mode:r.mode,prerelease:r.prerelease,tag:r.tag}:void 0,config:c,cwd:t,depGraph:u,firstRelease:w,packages:i,perPackageConfig:p,plan:b,pm:a,preMode:h,projectsByEcosystem:d}},Rt=(e,t)=>{const n=E.coerce(e)?.version??e;try{return E.gte(n,t)}catch{return!0}};export{Ht as R,gt as a,Xt as b,mt as c,Jt as f,Lt as r,qt as w};
@@ -1,4 +1,4 @@
1
- import{createRequire as T}from"node:module";import{j as $,F as R,b as P,q as L,X as S,J as k}from"../packem_shared/index.server-Ca_EEVfw.js";import{a as N}from"../packem_shared/index-BzhrR_iC.js";import{a as B,r as D,b as y,c as M}from"../packem_shared/ai-fix-D9MxigBQ.js";import{p as c}from"./cli-main.js";import{l as _}from"../packem_shared/failure-log-BP-gCUb5.js";let A;const O=s=>(A??=T(import.meta.url))(s),d=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,q=s=>{if(typeof d<"u"&&d.versions&&d.versions.node){const[t,i]=d.versions.node.split(".").map(Number);if(t>22||t===22&&i>=3||t===20&&i>=16)return d.getBuiltinModule(s)}return O(s)},{createInterface:J}=q("node:readline"),U={"ambiguous-match":"ambiguous match",applied:"applied",error:"error","missing-file":"missing file","no-match":"no match","outside-workspace":"outside workspace"},j=(s,t,i)=>{const e=M(s,t,i),r=N(s,e);return r===""||r.startsWith("..")?e:r},W=(s,t,i)=>{const e=[$(`Fix proposal (${s.provider}, confidence: ${s.confidence})`),"",s.explanation||R("<no explanation>")];if(s.cannotFix)return e.push(""),e.push(P(`Cannot fix automatically: ${s.cannotFix}`)),e.join(`
1
+ import{createRequire as T}from"node:module";import{j as $,F as R,b as P,q as L,X as S,J as k}from"../packem_shared/index.server-Ca_EEVfw.js";import{a as N}from"../packem_shared/index-BzhrR_iC.js";import{a as B,r as D,b as y,c as M}from"../packem_shared/ai-fix-DIMErSws.js";import{p as c}from"./cli-main.js";import{l as _}from"../packem_shared/failure-log-DIsKBKaI.js";let A;const O=s=>(A??=T(import.meta.url))(s),d=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,q=s=>{if(typeof d<"u"&&d.versions&&d.versions.node){const[t,i]=d.versions.node.split(".").map(Number);if(t>22||t===22&&i>=3||t===20&&i>=16)return d.getBuiltinModule(s)}return O(s)},{createInterface:J}=q("node:readline"),U={"ambiguous-match":"ambiguous match",applied:"applied",error:"error","missing-file":"missing file","no-match":"no match","outside-workspace":"outside workspace"},j=(s,t,i)=>{const e=M(s,t,i),r=N(s,e);return r===""||r.startsWith("..")?e:r},W=(s,t,i)=>{const e=[$(`Fix proposal (${s.provider}, confidence: ${s.confidence})`),"",s.explanation||R("<no explanation>")];if(s.cannotFix)return e.push(""),e.push(P(`Cannot fix automatically: ${s.cannotFix}`)),e.join(`
2
2
  `);if(s.patches.length===0)return e.push(""),e.push(P("No patches were proposed.")),e.join(`
3
3
  `);e.push(""),e.push($(`Patches (${String(s.patches.length)}):`));for(const[r,o]of s.patches.entries()){const a=j(t,i,o.file);e.push(""),e.push(L(`[${String(r+1)}] ${a}`)),o.reason&&e.push(R(` reason: ${o.reason}`));for(const h of o.oldString.split(`
4
4
  `))e.push(S(` - ${h}`));for(const h of o.newString.split(`
@@ -1,4 +1,4 @@
1
- import{createRequire as _}from"node:module";import{z as m,e as t}from"../packem_shared/index-BzhrR_iC.js";import{b}from"../packem_shared/formatBytes-_HvjOy8a-B_qQr4Hw.js";import{y as a}from"../packem_shared/isAccessibleSync-DYKTrrvc-C-_5cgwu.js";import{U as j}from"../packem_shared/writeFileSync-DJoHk3Ks-BPRoepNw.js";let v;const w=s=>(v??=_(import.meta.url))(s),c=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,d=s=>{if(typeof c<"u"&&c.versions&&c.versions.node){const[n,o]=c.versions.node.split(".").map(Number);if(n>22||n===22&&o>=3||n===20&&o>=16)return c.getBuiltinModule(s)}return w(s)},{homedir:i}=d("node:os"),{createInterface:y}=d("node:readline"),f=b(),p=[t(i(),".zshrc"),t(i(),".zshenv"),t(i(),".bashrc"),t(i(),".bash_profile"),t(i(),".profile"),t(i(),".config","fish","config.fish")],E=s=>{const n=[];for(const o of p)if(a(o))try{const l=m(o).split(`
1
+ import{createRequire as _}from"node:module";import{z as m,e as t}from"../packem_shared/index-BzhrR_iC.js";import{c as b}from"../packem_shared/env-BSXG3QKH.js";import{y as a}from"../packem_shared/isAccessibleSync-DYKTrrvc-C-_5cgwu.js";import{U as j}from"../packem_shared/writeFileSync-DJoHk3Ks-BPRoepNw.js";let v;const w=s=>(v??=_(import.meta.url))(s),c=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,d=s=>{if(typeof c<"u"&&c.versions&&c.versions.node){const[n,o]=c.versions.node.split(".").map(Number);if(n>22||n===22&&o>=3||n===20&&o>=16)return c.getBuiltinModule(s)}return w(s)},{homedir:i}=d("node:os"),{createInterface:y}=d("node:readline"),f=b(),p=[t(i(),".zshrc"),t(i(),".zshenv"),t(i(),".bashrc"),t(i(),".bash_profile"),t(i(),".profile"),t(i(),".config","fish","config.fish")],E=s=>{const n=[];for(const o of p)if(a(o))try{const l=m(o).split(`
2
2
  `),e=l.filter(r=>!r.includes(".vis/bin")&&!r.includes("VIS_HOME")&&!r.includes("# vis "));e.length!==l.length&&(j(o,e.join(`
3
3
  `)),n.push(o))}catch{s.warn(`warning: could not clean ${o}`)}return n},H=async({fs:s,logger:n,options:o})=>{if(!a(f)){n.info("vis is not installed (no ~/.vis directory found).");return}n.info("This will remove:"),n.info(` ${f}/`);const u=p.filter(e=>a(e)&&m(e).includes(".vis"));for(const e of u)n.info(` Lines in ${e}`);if(!o.yes){if(!process.stdin.isTTY)throw new Error("Non-interactive terminal. Use --yes to confirm.");const e=y({input:process.stdin,output:process.stdout}),r=await new Promise(h=>{e.question(`
4
4
  Type "uninstall" to confirm: `,h)});if(e.close(),r.trim()!=="uninstall"){n.info("Aborted.");return}}const l=E(n);for(const e of l)n.info(`Cleaned ${e}`);try{await s.rm(f,{force:!0,recursive:!0}),n.info(`
@@ -1,4 +1,4 @@
1
- import{createRequire as A}from"node:module";import{e as m,a as O}from"../packem_shared/index-BzhrR_iC.js";import{findVisConfigFile as F,DEFAULT_MIN_RELEASE_AGE_MINUTES as h}from"./CONFIG_FILES.js";import{p as e,e as V}from"./cli-main.js";import{d as q,r as G}from"../packem_shared/detect-CbMRSXkM.js";import{d as K}from"../packem_shared/pm-runner-RM72mDZg.js";import{a as P,g as U,b as L}from"../packem_shared/scaffold-files-DVyfB0yz.js";import{s as Y}from"../packem_shared/build-scripts-CEDx_nJp.js";import{y as S}from"../packem_shared/isAccessibleSync-DYKTrrvc-C-_5cgwu.js";import{U as j}from"../packem_shared/writeFileSync-DJoHk3Ks-BPRoepNw.js";import{s as R}from"../packem_shared/native-config-sync-TdTWjVgI.js";import{s as T}from"../packem_shared/min-release-age-JViyQuBM.js";let M;const N=n=>(M??=A(import.meta.url))(n),g=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,x=n=>{if(typeof g<"u"&&g.versions&&g.versions.node){const[s,t]=g.versions.node.split(".").map(Number);if(s>22||s===22&&t>=3||s===20&&t>=16)return g.getBuiltinModule(n)}return N(n)},{execFileSync:I}=x("node:child_process"),{createInterface:D}=x("node:readline"),W=n=>{const s=[];return S(m(n,"turbo.json"))&&s.push("turborepo"),S(m(n,"nx.json"))&&s.push("nx"),S(m(n,".moon"))&&s.push("moon"),s},B=(n,s)=>new Promise(t=>{n.question(s,i=>{t(i.trim())})}),d=async(n,s,t=!0)=>{const o=await B(n,`${s} ${t?"[Y/n]":"[y/N]"} `);return o===""?t:o.toLowerCase()==="y"||o.toLowerCase()==="yes"},w=(n,s)=>{const t=[],i=Object.entries(s.allowBuilds).filter(([,c])=>c).map(([c])=>` "${c}": true,`).join(`
1
+ import{createRequire as A}from"node:module";import{e as m,a as O}from"../packem_shared/index-BzhrR_iC.js";import{findVisConfigFile as F,DEFAULT_MIN_RELEASE_AGE_MINUTES as h}from"./CONFIG_FILES.js";import{p as e,e as V}from"./cli-main.js";import{d as q,r as G}from"../packem_shared/detect-CbMRSXkM.js";import{d as K}from"../packem_shared/pm-runner-RM72mDZg.js";import{a as P,g as U,b as L}from"../packem_shared/scaffold-files-DJlz36Mu.js";import{s as Y}from"../packem_shared/build-scripts-CEDx_nJp.js";import{y as S}from"../packem_shared/isAccessibleSync-DYKTrrvc-C-_5cgwu.js";import{U as j}from"../packem_shared/writeFileSync-DJoHk3Ks-BPRoepNw.js";import{s as R}from"../packem_shared/native-config-sync-TdTWjVgI.js";import{s as T}from"../packem_shared/min-release-age-JViyQuBM.js";let M;const N=n=>(M??=A(import.meta.url))(n),g=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,x=n=>{if(typeof g<"u"&&g.versions&&g.versions.node){const[s,t]=g.versions.node.split(".").map(Number);if(s>22||s===22&&t>=3||s===20&&t>=16)return g.getBuiltinModule(n)}return N(n)},{execFileSync:I}=x("node:child_process"),{createInterface:D}=x("node:readline"),W=n=>{const s=[];return S(m(n,"turbo.json"))&&s.push("turborepo"),S(m(n,"nx.json"))&&s.push("nx"),S(m(n,".moon"))&&s.push("moon"),s},B=(n,s)=>new Promise(t=>{n.question(s,i=>{t(i.trim())})}),d=async(n,s,t=!0)=>{const o=await B(n,`${s} ${t?"[Y/n]":"[y/N]"} `);return o===""?t:o.toLowerCase()==="y"||o.toLowerCase()==="yes"},w=(n,s)=>{const t=[],i=Object.entries(s.allowBuilds).filter(([,c])=>c).map(([c])=>` "${c}": true,`).join(`
2
2
  `),a=[` installScripts: {
3
3
  allow: ${i?`{
4
4
  ${i}
@@ -1,4 +1,4 @@
1
- import{J as k,F as v,X as $,b as y}from"../packem_shared/index.server-Ca_EEVfw.js";import{p}from"./cli-main.js";import{r as N,M,a as S,b as x,c as A,d as b,e as C,f as R,g as P,h as j}from"../packem_shared/s1ngularity-CO5GkkqX.js";import{g as B,r as D}from"../packem_shared/packument-zb18Jnlw.js";import{r as E}from"../packem_shared/provenance-L1M2FPy_.js";import{r as O}from"../packem_shared/signatures-DIqFUOfs.js";const w=new Set(["archivedRepo","author","downloads","expiredDomains","metadata","newBin","provenance","s1ngularity","signatures"]),V=n=>{const s=n.trim();if(s==="")return;if(s.startsWith("@")){const r=s.indexOf("@",1);return r===-1?{name:s,spec:void 0}:{name:s.slice(0,r),spec:s.slice(r+1)||void 0}}const t=s.indexOf("@");return t===-1?{name:s,spec:void 0}:{name:s.slice(0,t),spec:s.slice(t+1)||void 0}},F=n=>{if(n===void 0||n.trim()==="")return;const s=new Set;for(const t of n.split(",")){const r=t.trim();if(!w.has(r))throw new Error(`Unknown marshall in --only: ${r}. Known: ${[...w].sort().join(", ")}.`);s.add(r)}return s},l=(n,s)=>n===void 0||n.has(s),L=n=>n?.has("signatures")??!1,q=async({argument:n,options:s,workspaceRoot:t})=>{if(!n||n.length===0)throw new Error("No package specified. Usage: vis inspect <package>[@<spec>]");const r=V(n[0]);if(r===void 0)throw new Error(`Invalid package argument: "${String(n[0])}". Usage: vis inspect <package>[@<spec>]`);const i=F(s.only),u=await B(r.name,{workspaceRoot:t});if(u===void 0){p.error(`Package ${r.name} not found in the registry.`),process.exitCode=2;return}const g=D(u,r.spec);if(g===void 0){p.error(`Could not resolve ${r.name}@${r.spec??"latest"} to a published version.`),process.exitCode=2;return}const c=[{name:r.name,version:g}],o=new M;if(l(i,"author")){const a=await N(c,{workspaceRoot:t});for(const e of a)o.add({marshall:"author",message:e.message,packageName:e.packageName,severity:e.severity})}if(l(i,"provenance")){const a=await E(c);for(const e of a)o.add({marshall:"provenance",message:`Prior version ${e.priorVersionWithProvenance} had provenance but ${e.version} does not.`,packageName:e.packageName,severity:"error"})}if(l(i,"s1ngularity")){const a=await S(c,{workspaceRoot:t});for(const e of a){const d=e.hookChanges.map(f=>`${f.hook} (${f.kind})`).join(", "),m=e.hookChanges.length===1;o.add({marshall:"s1ngularity",message:`${e.version} ${m?"has an":"has"} install-script ${m?"change":"changes"} [${d}] AND dropped the provenance attestation that ${e.priorVersion} carried — this is the s1ngularity compromised-publish shape.`,packageName:e.packageName,severity:"error"})}}if(l(i,"newBin")){const a=await x(c);for(const e of a){const d=e.newBins.map(m=>m.command).join(", ");o.add({marshall:"newBin",message:`${e.toVersion} adds new bin script${e.newBins.length===1?"":"s"}: ${d} (prior: ${e.fromVersion}).`,packageName:e.packageName,severity:"warning"})}}if(l(i,"metadata")){const a=await A(c,{workspaceRoot:t});for(const e of a)o.add({marshall:"metadata",message:`Missing/invalid metadata: ${e.issues.join(", ")}.`,packageName:e.packageName,severity:"warning"})}if(l(i,"downloads")){const a=await b([r.name]);for(const e of a){const d=e.downloadsLastMonth===void 0?"unknown":String(e.downloadsLastMonth);o.add({marshall:"downloads",message:e.kind==="no-data"?"npm stats API returned no monthly download data.":`Only ${d} downloads in the past month.`,packageName:e.packageName,severity:e.severity})}}if(l(i,"expiredDomains")){const a=await C(c,{workspaceRoot:t});for(const e of a)o.add({marshall:"expiredDomains",message:e.kind==="expired"?`Maintainer email domain ${e.domain} (${e.maintainer}) is unregistered — potential hijack risk.`:`Could not verify maintainer email domain ${e.domain} (${e.maintainer}).`,packageName:e.packageName,severity:e.severity})}if(L(i)){const a=await O(c,{workspaceRoot:t});for(const e of a)o.add({marshall:"signatures",message:e.message,packageName:e.packageName,severity:e.severity})}if(l(i,"archivedRepo")){const a=await R(c,{workspaceRoot:t});for(const e of a)o.add({marshall:"archivedRepo",message:e.kind==="archived"?`Source repo ${e.owner}/${e.repo} is archived${e.archivedAt===void 0?"":` (since ${e.archivedAt})`}.`:`Source repo ${e.owner}/${e.repo} returned 404 from GitHub.`,packageName:e.packageName,severity:"warning"})}const h=o.all();if(s.json)process.stdout.write(`${JSON.stringify(P(h),void 0,2)}
1
+ import{J as k,F as v,X as $,b as y}from"../packem_shared/index.server-Ca_EEVfw.js";import{p}from"./cli-main.js";import{r as N,M,a as S,b as x,c as A,d as b,e as C,f as R,g as P,h as j}from"../packem_shared/s1ngularity-BuU9Cxpy.js";import{g as B,r as D}from"../packem_shared/packument-CbTmbHU4.js";import{r as E}from"../packem_shared/provenance-SX1MxPUZ.js";import{r as O}from"../packem_shared/signatures-CeL0bOEo.js";const w=new Set(["archivedRepo","author","downloads","expiredDomains","metadata","newBin","provenance","s1ngularity","signatures"]),V=n=>{const s=n.trim();if(s==="")return;if(s.startsWith("@")){const r=s.indexOf("@",1);return r===-1?{name:s,spec:void 0}:{name:s.slice(0,r),spec:s.slice(r+1)||void 0}}const t=s.indexOf("@");return t===-1?{name:s,spec:void 0}:{name:s.slice(0,t),spec:s.slice(t+1)||void 0}},F=n=>{if(n===void 0||n.trim()==="")return;const s=new Set;for(const t of n.split(",")){const r=t.trim();if(!w.has(r))throw new Error(`Unknown marshall in --only: ${r}. Known: ${[...w].sort().join(", ")}.`);s.add(r)}return s},l=(n,s)=>n===void 0||n.has(s),L=n=>n?.has("signatures")??!1,q=async({argument:n,options:s,workspaceRoot:t})=>{if(!n||n.length===0)throw new Error("No package specified. Usage: vis inspect <package>[@<spec>]");const r=V(n[0]);if(r===void 0)throw new Error(`Invalid package argument: "${String(n[0])}". Usage: vis inspect <package>[@<spec>]`);const i=F(s.only),u=await B(r.name,{workspaceRoot:t});if(u===void 0){p.error(`Package ${r.name} not found in the registry.`),process.exitCode=2;return}const g=D(u,r.spec);if(g===void 0){p.error(`Could not resolve ${r.name}@${r.spec??"latest"} to a published version.`),process.exitCode=2;return}const c=[{name:r.name,version:g}],o=new M;if(l(i,"author")){const a=await N(c,{workspaceRoot:t});for(const e of a)o.add({marshall:"author",message:e.message,packageName:e.packageName,severity:e.severity})}if(l(i,"provenance")){const a=await E(c);for(const e of a)o.add({marshall:"provenance",message:`Prior version ${e.priorVersionWithProvenance} had provenance but ${e.version} does not.`,packageName:e.packageName,severity:"error"})}if(l(i,"s1ngularity")){const a=await S(c,{workspaceRoot:t});for(const e of a){const d=e.hookChanges.map(f=>`${f.hook} (${f.kind})`).join(", "),m=e.hookChanges.length===1;o.add({marshall:"s1ngularity",message:`${e.version} ${m?"has an":"has"} install-script ${m?"change":"changes"} [${d}] AND dropped the provenance attestation that ${e.priorVersion} carried — this is the s1ngularity compromised-publish shape.`,packageName:e.packageName,severity:"error"})}}if(l(i,"newBin")){const a=await x(c);for(const e of a){const d=e.newBins.map(m=>m.command).join(", ");o.add({marshall:"newBin",message:`${e.toVersion} adds new bin script${e.newBins.length===1?"":"s"}: ${d} (prior: ${e.fromVersion}).`,packageName:e.packageName,severity:"warning"})}}if(l(i,"metadata")){const a=await A(c,{workspaceRoot:t});for(const e of a)o.add({marshall:"metadata",message:`Missing/invalid metadata: ${e.issues.join(", ")}.`,packageName:e.packageName,severity:"warning"})}if(l(i,"downloads")){const a=await b([r.name]);for(const e of a){const d=e.downloadsLastMonth===void 0?"unknown":String(e.downloadsLastMonth);o.add({marshall:"downloads",message:e.kind==="no-data"?"npm stats API returned no monthly download data.":`Only ${d} downloads in the past month.`,packageName:e.packageName,severity:e.severity})}}if(l(i,"expiredDomains")){const a=await C(c,{workspaceRoot:t});for(const e of a)o.add({marshall:"expiredDomains",message:e.kind==="expired"?`Maintainer email domain ${e.domain} (${e.maintainer}) is unregistered — potential hijack risk.`:`Could not verify maintainer email domain ${e.domain} (${e.maintainer}).`,packageName:e.packageName,severity:e.severity})}if(L(i)){const a=await O(c,{workspaceRoot:t});for(const e of a)o.add({marshall:"signatures",message:e.message,packageName:e.packageName,severity:e.severity})}if(l(i,"archivedRepo")){const a=await R(c,{workspaceRoot:t});for(const e of a)o.add({marshall:"archivedRepo",message:e.kind==="archived"?`Source repo ${e.owner}/${e.repo} is archived${e.archivedAt===void 0?"":` (since ${e.archivedAt})`}.`:`Source repo ${e.owner}/${e.repo} returned 404 from GitHub.`,packageName:e.packageName,severity:"warning"})}const h=o.all();if(s.json)process.stdout.write(`${JSON.stringify(P(h),void 0,2)}
2
2
  `);else{const a=`${r.name}@${g}`;if(h.length===0)p.info(`${k("✓")} ${a} — no findings.`);else{p.info(`${v("Inspecting")} ${a}`);for(const m of j(h))process.stdout.write(`${m}
3
3
  `);const e=o.errors().length,d=o.warnings().length;process.stdout.write(`
4
4
  ${v("Summary:")} ${$(`${String(e)} error${e===1?"":"s"}`)}, ${y(`${String(d)} warning${d===1?"":"s"}`)}.
@@ -1 +1 @@
1
- import{e as w,m as F,b as _}from"../packem_shared/index-BzhrR_iC.js";import{p as r}from"./cli-main.js";import{d as j,a as v,g as N,h as W}from"../packem_shared/pm-runner-RM72mDZg.js";import{a as $,r as K}from"../packem_shared/command-runtime-HSsYGCQd.js";import{s as M}from"../packem_shared/typosquats-D4DEHhFy.js";import{h as T,P as H}from"../packem_shared/peer-warnings-CmYSxvql.js";import{t as G}from"../packem_shared/utils-DQFHJn72.js";import{y as J}from"../packem_shared/isAccessibleSync-DYKTrrvc-C-_5cgwu.js";const Q=["pnpm-lock.yaml","yarn.lock","package-lock.json","npm-shrinkwrap.json","bun.lock","bun.lockb"],U=n=>{let t=n;for(;;){for(const i of Q)if(J(w(t,i)))return!0;const a=F(t);if(a===t||_(t).root===t)return!1;t=a}},g=new Set(["aube","auto","bun","npm","pnpm","yarn"]),re=async n=>{const{argument:t,fs:a,logger:i,options:e,visConfig:c,workspaceRoot:C}=n,s=C??process.cwd();if(t&&t.length>0){const o=e,{default:L}=await import("./handler15.js"),R=o.marshallCheck===!1||o["no-marshall-check"]===!0?!1:void 0,z=o.socketCheck===!1||o["no-socket-check"]===!0?!1:void 0,D=o.typosquatCheck===!1||o["no-typosquat-check"]===!0?!1:void 0,I=o.runScripts===!0||o["run-scripts"]===!0,P=o.workspaceRoot===!0||o["workspace-root"]===!0,q=o.saveOptional===!0||o["save-optional"]===!0,A=e.dev===!0,B={autoInstallPeers:!1,exact:o.exact===!0,filter:e.filter,global:!1,marshallCheck:R,runScripts:I,saveDev:A,saveOptional:q,savePeer:!1,socketCheck:z,to:void 0,typosquatCheck:D,workspace:!1,workspaceRoot:P};await L({...n,argument:t,options:B});return}if(e.typosquatCheck!==!1&&!await M(s,c?.security?.typosquatAllowlist)){process.exitCode=1;return}const l=e.installer;if(l&&!g.has(l)){r.error(`Invalid --installer value: "${l}". Expected one of: ${[...g].join(", ")}.`),process.exitCode=1;return}const y=l,O=e.aube===!1,f=$(K({options:e,visConfig:c},s));let p;try{p=O?f===void 0?j(s):v(s,{backend:f}):v(s,{backend:y??f,configBackend:c?.install?.backend,configCorepack:c?.install?.corepack})}catch(o){r.error(o instanceof Error?o.message:String(o)),process.exitCode=1;return}const k=N(s,p);k&&r.warn(k);const b=G(e.filter),u=e.ci||!1,m=e.frozenLockfile||u,x=!e.frozenLockfile||e.force||e.lockfileOnly,E=U(s),h=m||!x&&E;if(!m&&h&&!e.silent&&r.info("Defaulting to frozen lockfile (pass --no-frozen-lockfile to allow lockfile updates)."),u){r.info("Clean install: removing node_modules...");try{await a.rm(w(s,"node_modules"),{force:!0,recursive:!0})}catch(o){r.error(`Failed to remove node_modules: ${o instanceof Error?o.message:String(o)}`),process.exitCode=1;return}}const{code:d,output:S}=await W(p,{dev:e.dev||!1,filter:b,force:e.force||!1,frozenLockfile:h,ignoreScripts:!e.runScripts,lockfileOnly:e.lockfileOnly||!1,noOptional:e.optional===!1,offline:e.offline||!1,prod:e.prod||!1,recursive:e.recursive||!1,silent:e.silent||!1,workspaceRoot:e.workspaceRoot||!1},s,i,{ciMode:u,preferOffline:e.preferOffline||!1});d!==0&&(process.exitCode=d),d===0&&!e.silent&&T(S)&&r.info(H)};export{re as default};
1
+ import{e as w,m as F,b as _}from"../packem_shared/index-BzhrR_iC.js";import{p as r}from"./cli-main.js";import{d as j,a as v,g as N,h as W}from"../packem_shared/pm-runner-RM72mDZg.js";import{a as $,r as K}from"../packem_shared/command-runtime-HSsYGCQd.js";import{s as M}from"../packem_shared/typosquats-BFKus_aM.js";import{h as T,P as H}from"../packem_shared/peer-warnings-CmYSxvql.js";import{t as G}from"../packem_shared/utils-DQFHJn72.js";import{y as J}from"../packem_shared/isAccessibleSync-DYKTrrvc-C-_5cgwu.js";const Q=["pnpm-lock.yaml","yarn.lock","package-lock.json","npm-shrinkwrap.json","bun.lock","bun.lockb"],U=n=>{let t=n;for(;;){for(const i of Q)if(J(w(t,i)))return!0;const a=F(t);if(a===t||_(t).root===t)return!1;t=a}},g=new Set(["aube","auto","bun","npm","pnpm","yarn"]),re=async n=>{const{argument:t,fs:a,logger:i,options:e,visConfig:c,workspaceRoot:C}=n,s=C??process.cwd();if(t&&t.length>0){const o=e,{default:L}=await import("./handler15.js"),R=o.marshallCheck===!1||o["no-marshall-check"]===!0?!1:void 0,z=o.socketCheck===!1||o["no-socket-check"]===!0?!1:void 0,D=o.typosquatCheck===!1||o["no-typosquat-check"]===!0?!1:void 0,I=o.runScripts===!0||o["run-scripts"]===!0,P=o.workspaceRoot===!0||o["workspace-root"]===!0,q=o.saveOptional===!0||o["save-optional"]===!0,A=e.dev===!0,B={autoInstallPeers:!1,exact:o.exact===!0,filter:e.filter,global:!1,marshallCheck:R,runScripts:I,saveDev:A,saveOptional:q,savePeer:!1,socketCheck:z,to:void 0,typosquatCheck:D,workspace:!1,workspaceRoot:P};await L({...n,argument:t,options:B});return}if(e.typosquatCheck!==!1&&!await M(s,c?.security?.typosquatAllowlist)){process.exitCode=1;return}const l=e.installer;if(l&&!g.has(l)){r.error(`Invalid --installer value: "${l}". Expected one of: ${[...g].join(", ")}.`),process.exitCode=1;return}const y=l,O=e.aube===!1,f=$(K({options:e,visConfig:c},s));let p;try{p=O?f===void 0?j(s):v(s,{backend:f}):v(s,{backend:y??f,configBackend:c?.install?.backend,configCorepack:c?.install?.corepack})}catch(o){r.error(o instanceof Error?o.message:String(o)),process.exitCode=1;return}const k=N(s,p);k&&r.warn(k);const b=G(e.filter),u=e.ci||!1,m=e.frozenLockfile||u,x=!e.frozenLockfile||e.force||e.lockfileOnly,E=U(s),h=m||!x&&E;if(!m&&h&&!e.silent&&r.info("Defaulting to frozen lockfile (pass --no-frozen-lockfile to allow lockfile updates)."),u){r.info("Clean install: removing node_modules...");try{await a.rm(w(s,"node_modules"),{force:!0,recursive:!0})}catch(o){r.error(`Failed to remove node_modules: ${o instanceof Error?o.message:String(o)}`),process.exitCode=1;return}}const{code:d,output:S}=await W(p,{dev:e.dev||!1,filter:b,force:e.force||!1,frozenLockfile:h,ignoreScripts:!e.runScripts,lockfileOnly:e.lockfileOnly||!1,noOptional:e.optional===!1,offline:e.offline||!1,prod:e.prod||!1,recursive:e.recursive||!1,silent:e.silent||!1,workspaceRoot:e.workspaceRoot||!1},s,i,{ciMode:u,preferOffline:e.preferOffline||!1});d!==0&&(process.exitCode=d),d===0&&!e.silent&&T(S)&&r.info(H)};export{re as default};
@@ -1 +1 @@
1
- import{createRequire as A}from"node:module";import{J as P,F as j,X as F,b as I}from"../packem_shared/index.server-Ca_EEVfw.js";import{e as q}from"../packem_shared/index-BzhrR_iC.js";import{c as b,p,O as N}from"./cli-main.js";import{i as B,j as U,d as z,a as H,E as V}from"./catalog.js";import{V as W}from"../packem_shared/vis-user-error-CRmrBaD1.js";import{a as G,c as X,n as Y}from"../packem_shared/pm-runner-RM72mDZg.js";import{r as J,a as K}from"../packem_shared/command-runtime-HSsYGCQd.js";import{r as _,a as Q,p as Z,b as ee}from"../packem_shared/resolve-explicit-CQa37JSq.js";import{D as te,e as y,f as re,h as S,i as se,j as oe,s as ne}from"../packem_shared/formatBytes-_HvjOy8a-B_qQr4Hw.js";import{r as ae}from"../packem_shared/typosquats-D4DEHhFy.js";import{p as E,t as C}from"../packem_shared/utils-DQFHJn72.js";import{y as ce}from"../packem_shared/isAccessibleSync-DYKTrrvc-C-_5cgwu.js";import{p as ie}from"../packem_shared/readJsonSync-CbryXYxN-EWl7_7KX.js";import{T as le}from"../packem_shared/target-merge-DVJl-7Qz.js";let L;const T=r=>(L??=A(import.meta.url))(r),w=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,M=r=>{if(typeof w<"u"&&w.versions&&w.versions.node){const[i,e]=w.versions.node.split(".").map(Number);if(i>22||i===22&&e>=3||i===20&&e>=16)return w.getBuiltinModule(r)}return T(r)},{createInterface:O}=M("node:readline"),x=r=>r==="default"?"catalog:":`catalog:${r}`,v=r=>r==="default"?"default catalog":`catalog "${r}"`,fe=(r,i)=>{const e=[];for(const[t,s]of i)t.includes(":")||s.has(r)&&e.push(t);if(e.length===0)return;if(e.length===1){const[t]=e;return{source:v(t),spec:x(t)}}const n=e.find(t=>t==="default")??e[0],a=e.filter(t=>t!==n);return{candidates:[...e],conflict:!0,source:`${v(n)} (also in: ${a.map(t=>v(t)).join(", ")})`,spec:x(n)}},pe=(r,i)=>{const e=new Map;for(const[c,d]of i){if(!c.includes(":"))continue;const f=d.get(r);f!==void 0&&e.set(f,(e.get(f)??0)+1)}if(e.size===0)return;const n=[...e.entries()],a=n.reduce((c,[,d])=>c+d,0);if(n.length===1){const[[c]]=n;return{source:`siblings (${String(a)} pkg${a===1?"":"s"} on ${c})`,spec:c}}const t=[...n].sort((c,d)=>d[1]-c[1]),[s,o]=t[0],l=t.slice(1).map(([c,d])=>`${c} (×${String(d)})`);return{candidates:t.map(([c])=>c),conflict:!0,source:`siblings (most common: ${s} ×${String(o)}; conflicts: ${l.join(", ")})`,spec:s}},de=(r,i)=>{const e=fe(r,i);return e||pe(r,i)},ue=(r,i,e)=>{const n=[];for(const a of r.values()){const{overall:t}=a.score,s=ne(t),o=`${String(Math.round(t*100))}%`,l=a.alerts.length,c=y(a),d=re(c,a.version,e),f=s==="red"?F:s==="yellow"?I:P;if(d?p.info(` ${f(o)} ${S(a)} ${j(`[accepted: ${d.reason}]`)}`):p.info(` ${f(o)} ${S(a)}`),l>0){const m=a.alerts.filter(u=>u.severity==="critical"||u.severity==="high").length;m>0&&p.warn(` ${String(m)} critical/high alert${m===1?"":"s"}`)}t<i&&!d&&n.push(a)}return n},me=async(r,i)=>{const e=O({input:process.stdin,output:process.stdout}),n=o=>new Promise(l=>{e.question(o,c=>{l(c.trim())})}),a=String(Math.round(i*100));p.warn(""),p.warn(`${String(r.length)} package${r.length===1?"":"s"} scored below the minimum threshold (${a}%):`);for(const o of r){const l=y(o),c=`${String(Math.round(o.score.overall*100))}%`;p.warn(` • ${l}@${o.version} — score: ${c} (${se(o.score.overall)})`)}p.warn("");const t=await n("Continue adding these packages? [y/N] ");if(t.toLowerCase()!=="y"&&t.toLowerCase()!=="yes")return e.close(),!1;const s=await n("Remember this decision? (prints config snippet) [y/N] ");if(e.close(),s.toLowerCase()==="y"||s.toLowerCase()==="yes"){p.notice(""),p.notice("Add the following to security.acceptedRisks in vis.config.ts:"),p.notice("");for(const o of r){const l=y(o),c=oe(l,o.version,o.score.overall,"Reviewed and accepted");p.notice(c)}p.notice("")}return!0},ge=async(r,i,e,n)=>{const a=await _(r);if(a.length===0)return!0;p.info(""),p.info(`${i.map(o=>o.displayName).join(" + ")} security check:`);const t=await U(i,a);if(t.size===0)return p.info(" Could not fetch security data. Proceeding."),!0;const s=ue(t,e,n);return s.length===0?(p.info(""),!0):process.stdin.isTTY?me(s,e):(p.warn(`Aborting: ${String(s.length)} package${s.length===1?"":"s"} below minimum score. Use --no-socket-check to skip.`),!1)},he=["dependencies","devDependencies","peerDependencies","optionalDependencies"],ke=r=>r.savePeer?"peerDependencies":r.saveOptional?"optionalDependencies":r.saveDev?"devDependencies":"dependencies",R=(r,i)=>r.startsWith("catalog:")||!i?r:r.replace(/^[\^~]/,""),we=async(r,i)=>{const e=[];for(const t of r){const{name:s,versionSpec:o}=E(t);if(!s)continue;if(o!==void 0){e.push({explicit:o,name:s});continue}const l=de(s,i);if(l){l.conflict&&p.warn(`${s}: ambiguous constraint — picking ${l.spec} (${l.source}). Pass ${s}@<version> to override.`),e.push({entry:{name:s,source:l.source,spec:l.spec},kind:"resolved",name:s});continue}e.push({kind:"missing",name:s})}const n=e.filter(t=>"kind"in t&&t.kind==="missing").map(t=>t.name),a=n.length>0?await ee(n):new Map;return e.map(t=>{if("explicit"in t)return{name:t.name,source:"explicit",spec:t.explicit};if(t.kind==="resolved")return t.entry;const s=a.get(t.name);if(s===void 0)throw new Error(`--to: cannot resolve a version for "${t.name}" (not in any catalog or sibling, and registry lookup failed). Pass ${t.name}@<version> explicitly.`);const o=`^${s}`;return p.info(`${t.name}: no existing constraint — using registry latest (${o}). Add to a catalog to share this version across workspace packages.`),{name:t.name,source:"registry latest",spec:o}})},ve=(r,i,e,n)=>{for(const{name:a,spec:t}of i){const s=R(t,n);for(const l of he){if(l===e)continue;const c=r[l];c?.[a]!==void 0&&(delete c[a],Object.keys(c).length===0&&delete r[l])}let o=r[e];o===void 0&&(o={},r[e]=o),o[a]=s}},ye=async({ignoreScripts:r,logger:i,options:e,packages:n,pm:a,target:t,visConfig:s,workspaceRoot:o})=>{const{workspace:l}=z(o,s??{}),c=l.projects[t];if(!c){const g=Object.keys(l.projects).sort();throw new Error(`--to: workspace package "${t}" not found. Available: ${g.length>0?g.slice(0,10).join(", "):"(none)"}${g.length>10?`, ... (${String(g.length-10)} more)`:""}.`)}const d=q(o,c.root,"package.json");if(!ce(d))throw new W(`--to: project "${t}" has no package.json (${c.root}), so there is nothing to add npm dependencies to.`);const{packageManager:f}=N(o),m=H(o,f),u=ke(e),k=e.exact??!1,h=await we(n,m);if(h.length===0)return 0;const $=ie(d);ve($,h,u,k),le(d,$,{indent:V(d,{useEditorconfig:s?.editorconfig??!0}),overwrite:!0});for(const g of h){const D=R(g.spec,k);p.info(`${P("+")} ${g.name}@${D} → ${t}/${u} (${j(g.source)})`)}return Y(a,{dev:!1,filter:[],force:!1,frozenLockfile:!1,ignoreScripts:r,lockfileOnly:!1,noOptional:!1,offline:!1,prod:!1,recursive:!1,silent:!1,workspaceRoot:!1},o,i)},Oe=async({argument:r,logger:i,options:e,visConfig:n,workspaceRoot:a})=>{let t=r;if(!t||t.length===0)throw new Error("No packages specified. Usage: vis add <packages...>");if(e.typosquatCheck!==!1){const f=t.map(u=>E(u)),m=await ae(f.map(u=>u.name),n?.security?.typosquatAllowlist);if(!m.ok){process.exitCode=1;return}t=f.map((u,k)=>{const h=m.packages[k];return h!==u.name?u.versionSpec?`${h}@${u.versionSpec}`:h??"":t[k]??""})}if(e.marshallCheck!==!1){const f=await _(t);if(f.length>0){const m=await Q(f,{config:n?.security?.marshalls,workspaceRoot:a});if(!await Z(m)){process.exitCode=1;return}}}if(e.socketCheck!==!1){const f=new Set;b("socket")&&f.add("socket"),b("depsDev")&&f.add("deps-dev");const m=B(n?.security,{disabled:f,minimumScore:n?.security?.policies?.score?.minimum});if(m.length>0){const u=n?.security?.policies?.score?.minimum??te;if(!await ge(t,m,u,n?.security?.acceptedRisks)){process.exitCode=1;return}}}const s=process.cwd(),o=J({options:e,visConfig:n},a??s),l=G(a??s,{backend:K(o),configBackend:n?.install?.backend,configCorepack:n?.install?.corepack}),c=!e.runScripts;if(e.to){if(e.global||e.workspaceRoot)throw new Error("--to is incompatible with --global / --workspace-root.");if(e.filter&&C(e.filter).length>0)throw new Error("--to and --filter are mutually exclusive — --to already targets one package.");if(!a)throw new Error("--to requires a monorepo workspace. Run from inside a pnpm/bun/yarn/npm workspace.");const f=await ye({ignoreScripts:c,logger:i,options:e,packages:t,pm:l,target:e.to,visConfig:n,workspaceRoot:a});f!==0&&(process.exitCode=f);return}const d=X(l,{exact:e.exact||!1,filter:C(e.filter),global:e.global||!1,optional:e.saveOptional||!1,packages:t,peer:e.savePeer||!1,saveDev:e.saveDev||!1,workspace:e.workspace||!1,workspaceRoot:e.workspaceRoot||!1},s,i,{autoInstallPeers:e.autoInstallPeers||!1,ignoreScripts:c});d!==0&&(process.exitCode=d)};export{Oe as default};
1
+ import{createRequire as A}from"node:module";import{J as P,F as j,X as q,b as F}from"../packem_shared/index.server-Ca_EEVfw.js";import{e as I}from"../packem_shared/index-BzhrR_iC.js";import{c as b,p,O as N}from"./cli-main.js";import{a as B,f as U,d as z,q as H}from"../packem_shared/registry-Dg9XI6RT.js";import{V}from"../packem_shared/vis-user-error-3YS7sPYy.js";import{a as W,c as G,n as X}from"../packem_shared/pm-runner-RM72mDZg.js";import{r as Y,a as J}from"../packem_shared/command-runtime-HSsYGCQd.js";import{r as _,a as K,p as Q,b as Z}from"../packem_shared/resolve-explicit-D9kdTNvl.js";import{D as ee,e as y,f as te,h as S,i as re,j as oe,s as se}from"../packem_shared/env-BSXG3QKH.js";import{r as ne}from"../packem_shared/typosquats-BFKus_aM.js";import{readCatalogs as ae}from"./catalog2.js";import{p as E,t as C}from"../packem_shared/utils-DQFHJn72.js";import{y as ce}from"../packem_shared/isAccessibleSync-DYKTrrvc-C-_5cgwu.js";import{p as ie}from"../packem_shared/readJsonSync-CbryXYxN-EWl7_7KX.js";import{T as le}from"../packem_shared/target-merge-DVJl-7Qz.js";let L;const T=r=>(L??=A(import.meta.url))(r),w=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,M=r=>{if(typeof w<"u"&&w.versions&&w.versions.node){const[i,e]=w.versions.node.split(".").map(Number);if(i>22||i===22&&e>=3||i===20&&e>=16)return w.getBuiltinModule(r)}return T(r)},{createInterface:O}=M("node:readline"),x=r=>r==="default"?"catalog:":`catalog:${r}`,v=r=>r==="default"?"default catalog":`catalog "${r}"`,fe=(r,i)=>{const e=[];for(const[t,o]of i)t.includes(":")||o.has(r)&&e.push(t);if(e.length===0)return;if(e.length===1){const[t]=e;return{source:v(t),spec:x(t)}}const n=e.find(t=>t==="default")??e[0],a=e.filter(t=>t!==n);return{candidates:[...e],conflict:!0,source:`${v(n)} (also in: ${a.map(t=>v(t)).join(", ")})`,spec:x(n)}},pe=(r,i)=>{const e=new Map;for(const[c,d]of i){if(!c.includes(":"))continue;const f=d.get(r);f!==void 0&&e.set(f,(e.get(f)??0)+1)}if(e.size===0)return;const n=[...e.entries()],a=n.reduce((c,[,d])=>c+d,0);if(n.length===1){const[[c]]=n;return{source:`siblings (${String(a)} pkg${a===1?"":"s"} on ${c})`,spec:c}}const t=[...n].sort((c,d)=>d[1]-c[1]),[o,s]=t[0],l=t.slice(1).map(([c,d])=>`${c} (×${String(d)})`);return{candidates:t.map(([c])=>c),conflict:!0,source:`siblings (most common: ${o} ×${String(s)}; conflicts: ${l.join(", ")})`,spec:o}},de=(r,i)=>{const e=fe(r,i);return e||pe(r,i)},ue=(r,i,e)=>{const n=[];for(const a of r.values()){const{overall:t}=a.score,o=se(t),s=`${String(Math.round(t*100))}%`,l=a.alerts.length,c=y(a),d=te(c,a.version,e),f=o==="red"?q:o==="yellow"?F:P;if(d?p.info(` ${f(s)} ${S(a)} ${j(`[accepted: ${d.reason}]`)}`):p.info(` ${f(s)} ${S(a)}`),l>0){const m=a.alerts.filter(u=>u.severity==="critical"||u.severity==="high").length;m>0&&p.warn(` ${String(m)} critical/high alert${m===1?"":"s"}`)}t<i&&!d&&n.push(a)}return n},me=async(r,i)=>{const e=O({input:process.stdin,output:process.stdout}),n=s=>new Promise(l=>{e.question(s,c=>{l(c.trim())})}),a=String(Math.round(i*100));p.warn(""),p.warn(`${String(r.length)} package${r.length===1?"":"s"} scored below the minimum threshold (${a}%):`);for(const s of r){const l=y(s),c=`${String(Math.round(s.score.overall*100))}%`;p.warn(` • ${l}@${s.version} — score: ${c} (${re(s.score.overall)})`)}p.warn("");const t=await n("Continue adding these packages? [y/N] ");if(t.toLowerCase()!=="y"&&t.toLowerCase()!=="yes")return e.close(),!1;const o=await n("Remember this decision? (prints config snippet) [y/N] ");if(e.close(),o.toLowerCase()==="y"||o.toLowerCase()==="yes"){p.notice(""),p.notice("Add the following to security.acceptedRisks in vis.config.ts:"),p.notice("");for(const s of r){const l=y(s),c=oe(l,s.version,s.score.overall,"Reviewed and accepted");p.notice(c)}p.notice("")}return!0},ge=async(r,i,e,n)=>{const a=await _(r);if(a.length===0)return!0;p.info(""),p.info(`${i.map(s=>s.displayName).join(" + ")} security check:`);const t=await U(i,a);if(t.size===0)return p.info(" Could not fetch security data. Proceeding."),!0;const o=ue(t,e,n);return o.length===0?(p.info(""),!0):process.stdin.isTTY?me(o,e):(p.warn(`Aborting: ${String(o.length)} package${o.length===1?"":"s"} below minimum score. Use --no-socket-check to skip.`),!1)},he=["dependencies","devDependencies","peerDependencies","optionalDependencies"],ke=r=>r.savePeer?"peerDependencies":r.saveOptional?"optionalDependencies":r.saveDev?"devDependencies":"dependencies",R=(r,i)=>r.startsWith("catalog:")||!i?r:r.replace(/^[\^~]/,""),we=async(r,i)=>{const e=[];for(const t of r){const{name:o,versionSpec:s}=E(t);if(!o)continue;if(s!==void 0){e.push({explicit:s,name:o});continue}const l=de(o,i);if(l){l.conflict&&p.warn(`${o}: ambiguous constraint — picking ${l.spec} (${l.source}). Pass ${o}@<version> to override.`),e.push({entry:{name:o,source:l.source,spec:l.spec},kind:"resolved",name:o});continue}e.push({kind:"missing",name:o})}const n=e.filter(t=>"kind"in t&&t.kind==="missing").map(t=>t.name),a=n.length>0?await Z(n):new Map;return e.map(t=>{if("explicit"in t)return{name:t.name,source:"explicit",spec:t.explicit};if(t.kind==="resolved")return t.entry;const o=a.get(t.name);if(o===void 0)throw new Error(`--to: cannot resolve a version for "${t.name}" (not in any catalog or sibling, and registry lookup failed). Pass ${t.name}@<version> explicitly.`);const s=`^${o}`;return p.info(`${t.name}: no existing constraint — using registry latest (${s}). Add to a catalog to share this version across workspace packages.`),{name:t.name,source:"registry latest",spec:s}})},ve=(r,i,e,n)=>{for(const{name:a,spec:t}of i){const o=R(t,n);for(const l of he){if(l===e)continue;const c=r[l];c?.[a]!==void 0&&(delete c[a],Object.keys(c).length===0&&delete r[l])}let s=r[e];s===void 0&&(s={},r[e]=s),s[a]=o}},ye=async({ignoreScripts:r,logger:i,options:e,packages:n,pm:a,target:t,visConfig:o,workspaceRoot:s})=>{const{workspace:l}=z(s,o??{}),c=l.projects[t];if(!c){const g=Object.keys(l.projects).sort();throw new Error(`--to: workspace package "${t}" not found. Available: ${g.length>0?g.slice(0,10).join(", "):"(none)"}${g.length>10?`, ... (${String(g.length-10)} more)`:""}.`)}const d=I(s,c.root,"package.json");if(!ce(d))throw new V(`--to: project "${t}" has no package.json (${c.root}), so there is nothing to add npm dependencies to.`);const{packageManager:f}=N(s),m=ae(s,f),u=ke(e),k=e.exact??!1,h=await we(n,m);if(h.length===0)return 0;const $=ie(d);ve($,h,u,k),le(d,$,{indent:H(d,{useEditorconfig:o?.editorconfig??!0}),overwrite:!0});for(const g of h){const D=R(g.spec,k);p.info(`${P("+")} ${g.name}@${D} → ${t}/${u} (${j(g.source)})`)}return X(a,{dev:!1,filter:[],force:!1,frozenLockfile:!1,ignoreScripts:r,lockfileOnly:!1,noOptional:!1,offline:!1,prod:!1,recursive:!1,silent:!1,workspaceRoot:!1},s,i)},qe=async({argument:r,logger:i,options:e,visConfig:n,workspaceRoot:a})=>{let t=r;if(!t||t.length===0)throw new Error("No packages specified. Usage: vis add <packages...>");if(e.typosquatCheck!==!1){const f=t.map(u=>E(u)),m=await ne(f.map(u=>u.name),n?.security?.typosquatAllowlist);if(!m.ok){process.exitCode=1;return}t=f.map((u,k)=>{const h=m.packages[k];return h!==u.name?u.versionSpec?`${h}@${u.versionSpec}`:h??"":t[k]??""})}if(e.marshallCheck!==!1){const f=await _(t);if(f.length>0){const m=await K(f,{config:n?.security?.marshalls,workspaceRoot:a});if(!await Q(m)){process.exitCode=1;return}}}if(e.socketCheck!==!1){const f=new Set;b("socket")&&f.add("socket"),b("depsDev")&&f.add("deps-dev");const m=B(n?.security,{disabled:f,minimumScore:n?.security?.policies?.score?.minimum});if(m.length>0){const u=n?.security?.policies?.score?.minimum??ee;if(!await ge(t,m,u,n?.security?.acceptedRisks)){process.exitCode=1;return}}}const o=process.cwd(),s=Y({options:e,visConfig:n},a??o),l=W(a??o,{backend:J(s),configBackend:n?.install?.backend,configCorepack:n?.install?.corepack}),c=!e.runScripts;if(e.to){if(e.global||e.workspaceRoot)throw new Error("--to is incompatible with --global / --workspace-root.");if(e.filter&&C(e.filter).length>0)throw new Error("--to and --filter are mutually exclusive — --to already targets one package.");if(!a)throw new Error("--to requires a monorepo workspace. Run from inside a pnpm/bun/yarn/npm workspace.");const f=await ye({ignoreScripts:c,logger:i,options:e,packages:t,pm:l,target:e.to,visConfig:n,workspaceRoot:a});f!==0&&(process.exitCode=f);return}const d=G(l,{exact:e.exact||!1,filter:C(e.filter),global:e.global||!1,optional:e.saveOptional||!1,packages:t,peer:e.savePeer||!1,saveDev:e.saveDev||!1,workspace:e.workspace||!1,workspaceRoot:e.workspaceRoot||!1},o,i,{autoInstallPeers:e.autoInstallPeers||!1,ignoreScripts:c});d!==0&&(process.exitCode=d)};export{qe as default};
@@ -1,5 +1,5 @@
1
- import{readLastRunSummary as S,getLastRunSummaryPath as I}from"@visulima/task-runner";import{p as f,l as x,d as w}from"./cli-main.js";import{c as $,d as m}from"../packem_shared/formatBytes-_HvjOy8a-B_qQr4Hw.js";const T=new Set(["json","table"]),k=(t,e)=>t??e,h=t=>t===void 0?"-":t<1e3?`${String(t)}ms`:`${(t/1e3).toFixed(2)}s`,p=t=>t.exitCode===void 0?t.cacheStatus:t.exitCode===0?t.cacheStatus==="MISS"?"OK":t.cacheStatus:`FAIL(${String(t.exitCode)})`,r=(t,e)=>t.length>=e?t:t+" ".repeat(e-t.length),v=t=>t.exitCode!==void 0&&t.exitCode!==0,l=(t,e)=>{e.info(`Run ${t.id}`),e.info(` start: ${t.startTime}`),e.info(` end: ${t.endTime}`),e.info(` duration: ${h(t.duration)}`),e.info(` totals: ${String(t.stats.total)} total · ${String(t.stats.succeeded)} ok · ${String(t.stats.cached)} cached · ${String(t.stats.skipped)} skipped · ${String(t.stats.failed)} failed`),e.info(` env: node ${t.environment.nodeVersion} · ${t.environment.platform}/${t.environment.arch}`),e.info("")},C=(t,e)=>{if(t.length===0){e.info("(no tasks match the current filter)");return}const i=t.map(n=>({duration:h(n.duration),hash:n.hash?n.hash.slice(0,12):"-",status:p(n),taskId:n.taskId})),a={duration:Math.max(8,...i.map(n=>n.duration.length)),hash:Math.max(4,...i.map(n=>n.hash.length)),status:Math.max(6,...i.map(n=>n.status.length)),taskId:Math.max(4,...i.map(n=>n.taskId.length))};e.info(` ${r("task",a.taskId)} ${r("status",a.status)} ${r("duration",a.duration)} ${r("hash",a.hash)}`),e.info(` ${"-".repeat(a.taskId)} ${"-".repeat(a.status)} ${"-".repeat(a.duration)} ${"-".repeat(a.hash)}`);for(const n of i)e.info(` ${r(n.taskId,a.taskId)} ${r(n.status,a.status)} ${r(n.duration,a.duration)} ${r(n.hash,a.hash)}`)},R=(t,e,i)=>{l(t,i),i.info(`Task ${e.taskId}`),i.info(` status: ${p(e)}`),i.info(` cache: ${e.cacheStatus}`),i.info(` duration: ${h(e.duration)}`),i.info(` exit: ${e.exitCode===void 0?"-":String(e.exitCode)}`),i.info(` hash: ${e.hash??"(none)"}`),i.info(` start: ${e.startTime??"-"}`),i.info(` end: ${e.endTime??"-"}`),e.dependencies.length>0&&i.info(` deps: ${e.dependencies.join(", ")}`),i.info(""),f.info(`Drill into hash inputs with: vis cache why ${e.taskId} --run ${t.id}`)},D=t=>{process.stdout.write(`${JSON.stringify(t.map(e=>({id:e.id,mtime:new Date(e.mtimeMs).toISOString(),path:e.path})),void 0,2)}
2
- `)},M=(t,e,i)=>{if(t.length===0){f.info(`No recorded runs found in ${m(e)}/. Run with --summarize to record a run.`);return}const a={id:Math.max(2,...t.map(n=>n.id.length)),mtime:24};i.info(` ${r("id",a.id)} ${r("mtime",a.mtime)}`),i.info(` ${"-".repeat(a.id)} ${"-".repeat(a.mtime)}`);for(const n of t)i.info(` ${r(n.id,a.id)} ${new Date(n.mtimeMs).toISOString()}`)},O=(t,e)=>{let{tasks:i}=t;return e.task!==void 0&&(i=i.filter(a=>a.taskId===e.task)),e.failed&&(i=i.filter(a=>v(a))),i},j=async(t,e)=>{const{failed:i,format:a,runId:n,task:o,workspaceRoot:d}=t,s=n===void 0?await S(d,{dataDirectory:$(d)}):await w(d,n);if(!s){if(a==="json"){process.stdout.write(`${JSON.stringify({error:"no-summary",runId:n??null},void 0,2)}
3
- `),process.exitCode=1;return}n===void 0?f.error(`No previous run summary found. Run a task first to populate \`${I(d,{dataDirectory:$(d)})}\`.`):f.error(`Run summary "${n}" not found in ${m(d)}/.`),process.exitCode=1;return}const c=O(s,{failed:i,task:o});if(o!==void 0&&c.length===0){if(a==="json"){process.stdout.write(`${JSON.stringify({error:"task-not-in-summary",runId:s.id,taskId:o},void 0,2)}
4
- `),process.exitCode=1;return}f.error(`Task "${o}" was not part of run ${s.id}.`),process.exitCode=1;return}if(s.stats.failed>0&&(process.exitCode=1),a==="json"){process.stdout.write(`${JSON.stringify({duration:s.duration,endTime:s.endTime,environment:s.environment,runId:s.id,startTime:s.startTime,stats:s.stats,tasks:c.map(u=>({cacheStatus:u.cacheStatus,dependencies:u.dependencies,duration:u.duration,endTime:u.endTime,exitCode:u.exitCode,hash:u.hash??null,startTime:u.startTime,taskId:u.taskId}))},void 0,2)}
5
- `);return}if(o!==void 0){R(s,c[0],e);return}l(s,e),C(c,e)},b=async({logger:t,options:e,process:i,workspaceRoot:a})=>{const n=k(a,i.cwd),o=e.format??"table";if(!T.has(o)){f.error(`Invalid --format: ${o}. Expected "table" or "json".`),process.exitCode=1;return}if(e.list){const d=await x(n);if(o==="json"){D(d);return}M(d,n,t);return}await j({failed:e.failed,format:o,runId:e.run,task:e.task,workspaceRoot:n},t)};export{b as default,b as replayExecute,j as runReplay};
1
+ import{readLastRunSummary as S,getLastRunSummaryPath as I}from"@visulima/task-runner";import{p as f}from"./cli-main.js";import{l as x,r as w}from"../packem_shared/run-summary-utils-CMeURYtS.js";import{d as $,a as m}from"../packem_shared/env-BSXG3QKH.js";const T=new Set(["json","table"]),k=(t,e)=>t??e,h=t=>t===void 0?"-":t<1e3?`${String(t)}ms`:`${(t/1e3).toFixed(2)}s`,p=t=>t.exitCode===void 0?t.cacheStatus:t.exitCode===0?t.cacheStatus==="MISS"?"OK":t.cacheStatus:`FAIL(${String(t.exitCode)})`,s=(t,e)=>t.length>=e?t:t+" ".repeat(e-t.length),v=t=>t.exitCode!==void 0&&t.exitCode!==0,l=(t,e)=>{e.info(`Run ${t.id}`),e.info(` start: ${t.startTime}`),e.info(` end: ${t.endTime}`),e.info(` duration: ${h(t.duration)}`),e.info(` totals: ${String(t.stats.total)} total · ${String(t.stats.succeeded)} ok · ${String(t.stats.cached)} cached · ${String(t.stats.skipped)} skipped · ${String(t.stats.failed)} failed`),e.info(` env: node ${t.environment.nodeVersion} · ${t.environment.platform}/${t.environment.arch}`),e.info("")},C=(t,e)=>{if(t.length===0){e.info("(no tasks match the current filter)");return}const n=t.map(i=>({duration:h(i.duration),hash:i.hash?i.hash.slice(0,12):"-",status:p(i),taskId:i.taskId})),a={duration:Math.max(8,...n.map(i=>i.duration.length)),hash:Math.max(4,...n.map(i=>i.hash.length)),status:Math.max(6,...n.map(i=>i.status.length)),taskId:Math.max(4,...n.map(i=>i.taskId.length))};e.info(` ${s("task",a.taskId)} ${s("status",a.status)} ${s("duration",a.duration)} ${s("hash",a.hash)}`),e.info(` ${"-".repeat(a.taskId)} ${"-".repeat(a.status)} ${"-".repeat(a.duration)} ${"-".repeat(a.hash)}`);for(const i of n)e.info(` ${s(i.taskId,a.taskId)} ${s(i.status,a.status)} ${s(i.duration,a.duration)} ${s(i.hash,a.hash)}`)},R=(t,e,n)=>{l(t,n),n.info(`Task ${e.taskId}`),n.info(` status: ${p(e)}`),n.info(` cache: ${e.cacheStatus}`),n.info(` duration: ${h(e.duration)}`),n.info(` exit: ${e.exitCode===void 0?"-":String(e.exitCode)}`),n.info(` hash: ${e.hash??"(none)"}`),n.info(` start: ${e.startTime??"-"}`),n.info(` end: ${e.endTime??"-"}`),e.dependencies.length>0&&n.info(` deps: ${e.dependencies.join(", ")}`),n.info(""),f.info(`Drill into hash inputs with: vis cache why ${e.taskId} --run ${t.id}`)},D=t=>{process.stdout.write(`${JSON.stringify(t.map(e=>({id:e.id,mtime:new Date(e.mtimeMs).toISOString(),path:e.path})),void 0,2)}
2
+ `)},M=(t,e,n)=>{if(t.length===0){f.info(`No recorded runs found in ${m(e)}/. Run with --summarize to record a run.`);return}const a={id:Math.max(2,...t.map(i=>i.id.length)),mtime:24};n.info(` ${s("id",a.id)} ${s("mtime",a.mtime)}`),n.info(` ${"-".repeat(a.id)} ${"-".repeat(a.mtime)}`);for(const i of t)n.info(` ${s(i.id,a.id)} ${new Date(i.mtimeMs).toISOString()}`)},O=(t,e)=>{let{tasks:n}=t;return e.task!==void 0&&(n=n.filter(a=>a.taskId===e.task)),e.failed&&(n=n.filter(a=>v(a))),n},j=async(t,e)=>{const{failed:n,format:a,runId:i,task:o,workspaceRoot:d}=t,r=i===void 0?await S(d,{dataDirectory:$(d)}):await w(d,i);if(!r){if(a==="json"){process.stdout.write(`${JSON.stringify({error:"no-summary",runId:i??null},void 0,2)}
3
+ `),process.exitCode=1;return}i===void 0?f.error(`No previous run summary found. Run a task first to populate \`${I(d,{dataDirectory:$(d)})}\`.`):f.error(`Run summary "${i}" not found in ${m(d)}/.`),process.exitCode=1;return}const c=O(r,{failed:n,task:o});if(o!==void 0&&c.length===0){if(a==="json"){process.stdout.write(`${JSON.stringify({error:"task-not-in-summary",runId:r.id,taskId:o},void 0,2)}
4
+ `),process.exitCode=1;return}f.error(`Task "${o}" was not part of run ${r.id}.`),process.exitCode=1;return}if(r.stats.failed>0&&(process.exitCode=1),a==="json"){process.stdout.write(`${JSON.stringify({duration:r.duration,endTime:r.endTime,environment:r.environment,runId:r.id,startTime:r.startTime,stats:r.stats,tasks:c.map(u=>({cacheStatus:u.cacheStatus,dependencies:u.dependencies,duration:u.duration,endTime:u.endTime,exitCode:u.exitCode,hash:u.hash??null,startTime:u.startTime,taskId:u.taskId}))},void 0,2)}
5
+ `);return}if(o!==void 0){R(r,c[0],e);return}l(r,e),C(c,e)},F=async({logger:t,options:e,process:n,workspaceRoot:a})=>{const i=k(a,n.cwd),o=e.format??"table";if(!T.has(o)){f.error(`Invalid --format: ${o}. Expected "table" or "json".`),process.exitCode=1;return}if(e.list){const d=await x(i);if(o==="json"){D(d);return}M(d,i,t);return}await j({failed:e.failed,format:o,runId:e.run,task:e.task,workspaceRoot:i},t)};export{F as default,F as replayExecute,j as runReplay};
@@ -1 +1 @@
1
- import{createTaskGraph as $}from"@visulima/task-runner";import{d as b,b as O}from"./catalog.js";import{f as P}from"../packem_shared/project-name-filter-B1ZCsbOW.js";import{r as S,f as E,a as G}from"../packem_shared/selectors-edwcgNl3.js";const T=(l,s,t)=>{const a=[],e=new Set,n=(r,u)=>{if(e.has(r))return;e.add(r);const m=s[r]??[];for(const d of m)n(d,u+1);const o=t[r],h=" ".repeat(u);a.push(`${h}${r}${o?.cache===!1?" (no-cache)":""}`)};for(const r of l)n(r,0);return a},x=(l,s,t)=>({roots:l,tasks:Object.fromEntries(Object.entries(t).map(([a,e])=>[a,{cache:e.cache,dependsOn:s[a]??[],outputs:e.outputs,parallelism:e.parallelism,projectRoot:e.projectRoot,target:e.target}]))}),C=async({argument:l,logger:s,options:t,process:a,visConfig:e,workspaceRoot:n})=>{const r=l[0];if(!r)throw new Error("Missing selector. Usage: vis action-graph <selector>");if(!n)throw new Error("Could not determine workspace root. Run inside a monorepo.");const{config:u,packageJsons:m,workspace:o}=b(n,e),h=O(n,o,m),d=await S(r,o,a.cwd,n),{target:f}=d;let i=d.projects;t.projects!==void 0&&(i=P(i,String(t.projects),Object.keys(o.projects))),t.query&&(i=E(i,o,t.query)),i=G(i,o,t.tag);const k=i.filter(p=>o.projects[p]?.targets?.[f]!==void 0);if(k.length===0){s.info(`No projects have a "${f}" target.`);return}const y=k.map(p=>{const g=o.projects[p],j=g.targets?.[f],v={project:p,target:f};return{cache:j?.cache,id:`${p}:${f}`,outputs:j?.outputs??[],overrides:{command:j?.command},parallelism:j?.parallelism,projectRoot:g.root,target:v}}),c=$(y,{projectGraph:h,targetDefaults:u.tasks,workspace:o});if(t.json){s.info(JSON.stringify(x(c.roots,c.dependencies,c.tasks),null,2));return}const w=T(c.roots,c.dependencies,c.tasks);s.info(`Execution plan (${Object.keys(c.tasks).length} task(s), ${c.roots.length} root(s)):`),s.info("");for(const p of w)s.info(p)};export{C as default};
1
+ import{createTaskGraph as $}from"@visulima/task-runner";import{d as b,b as O}from"../packem_shared/registry-Dg9XI6RT.js";import{f as P}from"../packem_shared/project-name-filter-ZQaLgytG.js";import{r as S,f as E,a as G}from"../packem_shared/selectors-edwcgNl3.js";const T=(l,s,t)=>{const a=[],e=new Set,n=(r,u)=>{if(e.has(r))return;e.add(r);const m=s[r]??[];for(const d of m)n(d,u+1);const o=t[r],h=" ".repeat(u);a.push(`${h}${r}${o?.cache===!1?" (no-cache)":""}`)};for(const r of l)n(r,0);return a},x=(l,s,t)=>({roots:l,tasks:Object.fromEntries(Object.entries(t).map(([a,e])=>[a,{cache:e.cache,dependsOn:s[a]??[],outputs:e.outputs,parallelism:e.parallelism,projectRoot:e.projectRoot,target:e.target}]))}),C=async({argument:l,logger:s,options:t,process:a,visConfig:e,workspaceRoot:n})=>{const r=l[0];if(!r)throw new Error("Missing selector. Usage: vis action-graph <selector>");if(!n)throw new Error("Could not determine workspace root. Run inside a monorepo.");const{config:u,packageJsons:m,workspace:o}=b(n,e),h=O(n,o,m),d=await S(r,o,a.cwd,n),{target:f}=d;let i=d.projects;t.projects!==void 0&&(i=P(i,String(t.projects),Object.keys(o.projects))),t.query&&(i=E(i,o,t.query)),i=G(i,o,t.tag);const k=i.filter(p=>o.projects[p]?.targets?.[f]!==void 0);if(k.length===0){s.info(`No projects have a "${f}" target.`);return}const y=k.map(p=>{const g=o.projects[p],j=g.targets?.[f],v={project:p,target:f};return{cache:j?.cache,id:`${p}:${f}`,outputs:j?.outputs??[],overrides:{command:j?.command},parallelism:j?.parallelism,projectRoot:g.root,target:v}}),c=$(y,{projectGraph:h,targetDefaults:u.tasks,workspace:o});if(t.json){s.info(JSON.stringify(x(c.roots,c.dependencies,c.tasks),null,2));return}const w=T(c.roots,c.dependencies,c.tasks);s.info(`Execution plan (${Object.keys(c.tasks).length} task(s), ${c.roots.length} root(s)):`),s.info("");for(const p of w)s.info(p)};export{C as default};
@@ -1,2 +1,2 @@
1
- import{U as B,m as E}from"../packem_shared/index-BzhrR_iC.js";import{d as $,b as v}from"./catalog.js";import{p as f}from"./cli-main.js";import{o as S,s as g,f as C,b as O,a as D}from"../packem_shared/ecosystem-gate-DiqQj0LJ.js";import{h as F}from"../packem_shared/writeFileSync-DJoHk3Ks-BPRoepNw.js";const w=["json","xml"],G=n=>w.includes(n),T=async({console:n,fs:x,options:e,visConfig:a,workspaceRoot:o})=>{if(!o)throw new Error("Could not determine workspace root. Run inside a monorepo.");const{packageJsons:h,workspace:i}=$(o,a),y=v(o,i,h),m=e.focus,b=m?m.split(",").map(r=>r.trim()).filter(Boolean):void 0,t=(e.format??"json").toLowerCase();if(!G(t))throw new Error(`Unknown --format: "${t}". Expected one of: ${w.join(", ")}.`);const d=S(a),p=g(C(o).filter(({id:r})=>!d.has(r)));p!==void 0&&n.error(p);const s=O({ecosystems:d,focus:b,includeDev:!!e.includeDev,projectGraph:y,workspace:i,workspaceRoot:o}),l=t==="xml"?D(s):`${JSON.stringify(s,void 0,2)}
1
+ import{U as B,m as E}from"../packem_shared/index-BzhrR_iC.js";import{d as $,b as v}from"../packem_shared/registry-Dg9XI6RT.js";import{p as f}from"./cli-main.js";import{o as S,s as g,f as C,b as O,a as D}from"../packem_shared/ecosystem-gate-CwsTc7YW.js";import{h as F}from"../packem_shared/writeFileSync-DJoHk3Ks-BPRoepNw.js";const w=["json","xml"],G=n=>w.includes(n),T=async({console:n,fs:x,options:e,visConfig:a,workspaceRoot:o})=>{if(!o)throw new Error("Could not determine workspace root. Run inside a monorepo.");const{packageJsons:h,workspace:i}=$(o,a),y=v(o,i,h),m=e.focus,b=m?m.split(",").map(r=>r.trim()).filter(Boolean):void 0,t=(e.format??"json").toLowerCase();if(!G(t))throw new Error(`Unknown --format: "${t}". Expected one of: ${w.join(", ")}.`);const d=S(a),p=g(C(o).filter(({id:r})=>!d.has(r)));p!==void 0&&n.error(p);const s=O({ecosystems:d,focus:b,includeDev:!!e.includeDev,projectGraph:y,workspace:i,workspaceRoot:o}),l=t==="xml"?D(s):`${JSON.stringify(s,void 0,2)}
2
2
  `,u=e.output??(t==="xml"?"sbom.cdx.xml":"sbom.cdx.json");if(u==="-"){process.stdout.write(l);return}const c=B(o,u);F(E(c)),await x.writeFile(c,l,"utf8");const k=s.components?.length??0,j=s.dependencies?.length??0;f.success(`SBOM written to ${c}`),f.notice(`${k} components, ${j} dependency edges`)};export{T as default};
@@ -1,2 +1,2 @@
1
- import{createRequire as C}from"node:module";import"../packem_shared/index-BzhrR_iC.js";import{C as A,d as I}from"./catalog.js";import{p as c,h as N}from"./cli-main.js";import{p as L,i as R,r as v,g as H,s as M,a as b,S as W,b as O,c as P,d as U,e as D}from"../packem_shared/lifecycle-DvmDIRbb.js";import{r as q,l as z}from"../packem_shared/target-options-DsHFmRZH.js";let T;const _=s=>(T??=C(import.meta.url))(s),w=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,j=s=>{if(typeof w<"u"&&w.versions&&w.versions.node){const[e,r]=w.versions.node.split(".").map(Number);if(e>22||e===22&&r>=3||e===20&&r>=16)return w.getBuiltinModule(s)}return _(s)},{open:E,stat:$,watch:F}=j("node:fs/promises"),h=async s=>{const e=s?.plugins;if(!e||e.length===0)return;const r=U();return await D(r,e),{callHook:async(d,...o)=>{try{await r.callHook(d,...o)}catch(t){const a=t instanceof Error?t.message:String(t);c.warn(`Plugin error in ${d}: ${a}`)}}}},V=s=>{const e=s.trim(),r=e.lastIndexOf(":");if(!(r<=0||r===e.length-1))return{project:e.slice(0,r),target:e.slice(r+1)}},y=async(s,e,r)=>{const d=V(r);if(!d){c.error(`Invalid target id "${r}". Expected "<project>:<target>", e.g. "@my/api:db".`);return}const o=await A(s,e),{projectOptions:t,workspace:a}=I(s,e,o),i=a.projects[d.project],n=t.get(d.project)?.[d.target];if(!i||!n){c.error(`Target "${r}" not found in this workspace.`);return}const p=n.options?.service;if(!p){c.error(`Target "${r}" is not a service. Add an \`options.service\` block to make it eligible for \`vis service\`.`);return}if(!n.command){c.error(`Target "${r}" has no command — services must be runnable.`);return}const g=q(s,i.root,n.options?.runFromWorkspaceRoot===!0),u=n.options?.envFile?z(g,n.options.envFile):{};return{command:n.command,cwd:g,env:{...u,...p.env},service:p,target:n,targetId:r}},m=s=>{if(!s)throw new Error("Could not determine workspace root. Run `vis service` inside a workspace.");return s},re=async({argument:s,options:e,visConfig:r,workspaceRoot:d})=>{const o=m(d),t=s[0]?.trim();if(!t){c.error("Missing target id. Usage: vis service start <project>:<target>"),process.exitCode=1;return}const a=await y(o,r,t);if(!a){process.exitCode=1;return}try{const{entry:i}=await b({command:a.command,config:a.service,cwd:a.cwd,env:a.env,id:t,readinessTimeoutMs:e.timeout,skipReadiness:e.readiness===!1,workspaceRoot:o});await(await h(r))?.callHook("service:start",i),c.success(`Started ${t} (pid ${String(i.pid)})`),c.info(` log: ${i.logFile}`)}catch(i){const n=i instanceof Error?i.message:String(i);i instanceof W?c.error(`Readiness probe failed for ${t}: ${n}`):c.error(`Failed to start ${t}: ${n}`),process.exitCode=1}},S=async({graceMs:s,hookSink:e,id:r,workspaceRoot:d})=>{const o=await v(d,r),{stopped:t}=await M({graceMs:s,id:r,workspaceRoot:d});return t?(o&&await e?.callHook("service:stop",o),c.success(`Stopped ${r}`),!0):(c.info(`No running service registered for ${r}`),!1)},se=async({argument:s,options:e,visConfig:r,workspaceRoot:d})=>{const o=m(d),{graceMs:t}=e,a=s[0]?.trim(),i=await h(r);if(e.all){if(a){c.error("Cannot combine --all with a target id. Use one or the other."),process.exitCode=1;return}const p=await P(o);if(p.length===0){c.info("No running services registered for this workspace.");return}for(const g of p)await S({graceMs:t,hookSink:i,id:g.id,workspaceRoot:o});return}if(!a){c.error("Missing target id. Usage: vis service stop <project>:<target> | --all"),process.exitCode=1;return}await S({graceMs:t,hookSink:i,id:a,workspaceRoot:o})||(process.exitCode=1)},B=s=>{const e=s.config.readiness?.tcp.port??s.config.port;return e===void 0?"—":String(e)},x=new Set(["json","table"]),oe=async({logger:s,options:e,workspaceRoot:r})=>{const d=m(r),o=e.format??"table";if(!x.has(o)){c.error(`Invalid --format "${o}". Expected one of: ${[...x].sort().join(", ")}.`),process.exitCode=1;return}const{surviving:t}=await L(d);if(o==="json"){const l=Date.now();process.stdout.write(`${JSON.stringify(t.map(f=>{const k=Date.parse(f.startedAt);return{ageMs:Number.isFinite(k)?l-k:null,alive:R(f.pid),command:f.command,cwd:f.cwd,env:f.env,id:f.id,logFile:f.logFile,pid:f.pid,port:f.config.readiness?.tcp.port??f.config.port??null,startedAt:f.startedAt,visVersion:f.visVersion}}),void 0,2)}
1
+ import{createRequire as T}from"node:module";import"../packem_shared/index-BzhrR_iC.js";import{o as A,d as I}from"../packem_shared/registry-Dg9XI6RT.js";import{p as c,g as N}from"./cli-main.js";import{p as L,i as R,r as v,g as H,s as M,a as b,S as W,b as O,c as P,d as U,e as D}from"../packem_shared/lifecycle-CQjeMPY0.js";import{r as q,l as z}from"../packem_shared/target-options-DsHFmRZH.js";let C;const _=s=>(C??=T(import.meta.url))(s),w=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,j=s=>{if(typeof w<"u"&&w.versions&&w.versions.node){const[e,r]=w.versions.node.split(".").map(Number);if(e>22||e===22&&r>=3||e===20&&r>=16)return w.getBuiltinModule(s)}return _(s)},{open:E,stat:$,watch:F}=j("node:fs/promises"),h=async s=>{const e=s?.plugins;if(!e||e.length===0)return;const r=U();return await D(r,e),{callHook:async(d,...o)=>{try{await r.callHook(d,...o)}catch(t){const a=t instanceof Error?t.message:String(t);c.warn(`Plugin error in ${d}: ${a}`)}}}},V=s=>{const e=s.trim(),r=e.lastIndexOf(":");if(!(r<=0||r===e.length-1))return{project:e.slice(0,r),target:e.slice(r+1)}},y=async(s,e,r)=>{const d=V(r);if(!d){c.error(`Invalid target id "${r}". Expected "<project>:<target>", e.g. "@my/api:db".`);return}const o=await A(s,e),{projectOptions:t,workspace:a}=I(s,e,o),i=a.projects[d.project],n=t.get(d.project)?.[d.target];if(!i||!n){c.error(`Target "${r}" not found in this workspace.`);return}const p=n.options?.service;if(!p){c.error(`Target "${r}" is not a service. Add an \`options.service\` block to make it eligible for \`vis service\`.`);return}if(!n.command){c.error(`Target "${r}" has no command — services must be runnable.`);return}const g=q(s,i.root,n.options?.runFromWorkspaceRoot===!0),u=n.options?.envFile?z(g,n.options.envFile):{};return{command:n.command,cwd:g,env:{...u,...p.env},service:p,target:n,targetId:r}},m=s=>{if(!s)throw new Error("Could not determine workspace root. Run `vis service` inside a workspace.");return s},re=async({argument:s,options:e,visConfig:r,workspaceRoot:d})=>{const o=m(d),t=s[0]?.trim();if(!t){c.error("Missing target id. Usage: vis service start <project>:<target>"),process.exitCode=1;return}const a=await y(o,r,t);if(!a){process.exitCode=1;return}try{const{entry:i}=await b({command:a.command,config:a.service,cwd:a.cwd,env:a.env,id:t,readinessTimeoutMs:e.timeout,skipReadiness:e.readiness===!1,workspaceRoot:o});await(await h(r))?.callHook("service:start",i),c.success(`Started ${t} (pid ${String(i.pid)})`),c.info(` log: ${i.logFile}`)}catch(i){const n=i instanceof Error?i.message:String(i);i instanceof W?c.error(`Readiness probe failed for ${t}: ${n}`):c.error(`Failed to start ${t}: ${n}`),process.exitCode=1}},S=async({graceMs:s,hookSink:e,id:r,workspaceRoot:d})=>{const o=await v(d,r),{stopped:t}=await M({graceMs:s,id:r,workspaceRoot:d});return t?(o&&await e?.callHook("service:stop",o),c.success(`Stopped ${r}`),!0):(c.info(`No running service registered for ${r}`),!1)},se=async({argument:s,options:e,visConfig:r,workspaceRoot:d})=>{const o=m(d),{graceMs:t}=e,a=s[0]?.trim(),i=await h(r);if(e.all){if(a){c.error("Cannot combine --all with a target id. Use one or the other."),process.exitCode=1;return}const p=await P(o);if(p.length===0){c.info("No running services registered for this workspace.");return}for(const g of p)await S({graceMs:t,hookSink:i,id:g.id,workspaceRoot:o});return}if(!a){c.error("Missing target id. Usage: vis service stop <project>:<target> | --all"),process.exitCode=1;return}await S({graceMs:t,hookSink:i,id:a,workspaceRoot:o})||(process.exitCode=1)},B=s=>{const e=s.config.readiness?.tcp.port??s.config.port;return e===void 0?"—":String(e)},x=new Set(["json","table"]),oe=async({logger:s,options:e,workspaceRoot:r})=>{const d=m(r),o=e.format??"table";if(!x.has(o)){c.error(`Invalid --format "${o}". Expected one of: ${[...x].sort().join(", ")}.`),process.exitCode=1;return}const{surviving:t}=await L(d);if(o==="json"){const l=Date.now();process.stdout.write(`${JSON.stringify(t.map(f=>{const k=Date.parse(f.startedAt);return{ageMs:Number.isFinite(k)?l-k:null,alive:R(f.pid),command:f.command,cwd:f.cwd,env:f.env,id:f.id,logFile:f.logFile,pid:f.pid,port:f.config.readiness?.tcp.port??f.config.port??null,startedAt:f.startedAt,visVersion:f.visVersion}}),void 0,2)}
2
2
  `);return}if(t.length===0){c.info("No running services registered for this workspace.");return}const a=Date.now(),i=t.map(l=>{const f=Date.parse(l.startedAt);return{age:Number.isFinite(f)?N(f,a):"?",id:l.id,log:l.logFile,pid:String(l.pid),port:B(l)}}),n=Math.max(2,...i.map(l=>l.id.length)),p=Math.max(3,...i.map(l=>l.pid.length)),g=Math.max(4,...i.map(l=>l.port.length)),u=Math.max(3,...i.map(l=>l.age.length));s.info(` ${"id".padEnd(n)} ${"pid".padEnd(p)} ${"port".padEnd(g)} ${"age".padEnd(u)} log`),s.info(` ${"-".repeat(n)} ${"-".repeat(p)} ${"-".repeat(g)} ${"-".repeat(u)} ---`);for(const l of i)s.info(` ${l.id.padEnd(n)} ${l.pid.padEnd(p)} ${l.port.padEnd(g)} ${l.age.padEnd(u)} ${l.log}`)},ie=async({argument:s,options:e,workspaceRoot:r})=>{const d=m(r),o=s[0]?.trim();if(!o){c.error("Missing target id. Usage: vis service status <project>:<target>"),process.exitCode=1;return}const t=await v(d,o);if(!t){c.error(`No service registered for ${o}.`),process.exitCode=1;return}if(!R(t.pid)){c.error(`Service ${o} is not running (pid ${String(t.pid)} is dead). Run \`vis service start ${o}\` to recover.`),process.exitCode=1;return}try{await O(t.config,{timeoutMs:e.timeout}),c.success(`${o} healthy (pid ${String(t.pid)})`)}catch(a){const i=a instanceof Error?a.message:String(a);c.error(`${o} probe failed: ${i}`),process.exitCode=1}},ae=async({argument:s,options:e,visConfig:r,workspaceRoot:d})=>{const o=m(d),t=s[0]?.trim();if(!t){c.error("Missing target id. Usage: vis service restart <project>:<target>"),process.exitCode=1;return}const a=await h(r),i=await v(o,t);(await M({graceMs:e.graceMs,id:t,workspaceRoot:o})).stopped&&i&&await a?.callHook("service:stop",i);const p=await y(o,r,t);if(!p){process.exitCode=1;return}try{const{entry:g}=await b({command:p.command,config:p.service,cwd:p.cwd,env:p.env,id:t,readinessTimeoutMs:e.timeout,skipReadiness:e.readiness===!1,workspaceRoot:o});await a?.callHook("service:start",g),c.success(`Restarted ${t} (pid ${String(g.pid)})`)}catch(g){const u=g instanceof Error?g.message:String(g);c.error(`Failed to restart ${t}: ${u}`),process.exitCode=1}},G=200,J=1024*1024,K=async s=>{let e=0;try{e=(await $(s)).size}catch{e=0}const r=new AbortController;let d=!1;const o=()=>{d=!0,r.abort()},t=()=>{r.abort()};process.on("SIGINT",o),process.on("SIGTERM",t);let a=!1;const i=async()=>{if(!a){a=!0;try{const n=await $(s).catch(()=>{});if(!n||(n.size<e&&(e=0),n.size===e))return;const p=n.size-e,g=Math.min(p,J),u=await E(s,"r");try{const l=Buffer.alloc(g);await u.read(l,0,g,e),process.stdout.write(l),e+=g}finally{await u.close().catch(()=>{})}}finally{a=!1}}};try{const n=(async()=>{try{const p=F(s,{signal:r.signal});for(;!(await p.next()).done;)await i()}catch{}})();for(;!r.signal.aborted;)await i(),await new Promise(p=>{const g=setTimeout(p,G);r.signal.addEventListener("abort",()=>{clearTimeout(g),p()},{once:!0})});await n.catch(()=>{}),await i().catch(()=>{})}finally{process.off("SIGINT",o),process.off("SIGTERM",t)}d&&(process.exitCode=130)},ne=async({argument:s,options:e,workspaceRoot:r})=>{const d=m(r),o=s[0]?.trim();if(!o){c.error("Missing target id. Usage: vis service logs <project>:<target>"),process.exitCode=1;return}const t=await v(d,o);if(!t){c.error(`No service registered for ${o}.`),process.exitCode=1;return}if(!await H(t.logFile)){c.warn(`Log file is missing for ${o}: ${t.logFile}`),process.exitCode=1;return}if(e.follow){await K(t.logFile);return}const a=await E(t.logFile,"r");try{const i=a.createReadStream();await new Promise((n,p)=>{i.on("end",n),i.on("error",p),i.pipe(process.stdout,{end:!1})})}finally{await a.close().catch(()=>{})}};export{oe as serviceListExecute,ne as serviceLogsExecute,ae as serviceRestartExecute,re as serviceStartExecute,ie as serviceStatusExecute,se as serviceStopExecute};
@@ -1 +1 @@
1
- import{F as v}from"../packem_shared/index.server-Ca_EEVfw.js";import{v as R,e as y}from"../packem_shared/index-BzhrR_iC.js";import{d as j}from"./catalog.js";import{a as C,b as g,s as x,i as B,c as D,p as P,d as E,r as N,e as A}from"../packem_shared/subtree-DtmcKAJK.js";import{s as W,n as k}from"../packem_shared/utils-DQFHJn72.js";const z=async(u,m,t)=>{const e=m[u];if(e?.root)return{pkgName:u,relativeDir:k(e.root)};const o=k(u);if(o.length>0&&await t(o))return{pkgName:o.split("/").pop()??o,relativeDir:o}},K=async({argument:u,fs:m,logger:t,options:e,process:o,visConfig:h,workspaceRoot:b})=>{const p=u[0];if(!p)throw new Error("Missing <package>. Pass a project name or a workspace-relative path.");if(!e.dryRun&&!e.output)throw new Error("Missing --output <dir>. Pass the destination directory for the new repo (or use --dry-run).");const r=b??o.cwd;C(r);const{workspace:$}=j(r,h),w=async i=>{try{return await m.access(i),!0}catch{return!1}},l=await z(p,$.projects,i=>w(y(r,i,"package.json")));if(!l){const i=Object.keys($.projects).sort().join(", ");throw new Error(`Unknown package "${p}". Known projects: ${i||"(none)"}.`)}const{pkgName:f,relativeDir:n}=l,s=e.branch??h?.defaultBase??"main",d=`vis/split/${W(n.replaceAll("/","-"))}`,c=e.output?R(e.output)?e.output:y(r,e.output):void 0;if(e.dryRun){t.info("Dry run — no changes will be made. Planned git commands:"),t.info(` git subtree split --prefix=${n}${e.annotate?` --annotate=(${f}) `:""} -b ${d}`),c&&(t.info(` git -C ${c} init -b ${s}`),t.info(` git -C ${c} pull ${r} ${d}`)),e.remote&&t.info(` git -C ${c??"<output>"} remote add origin ${e.remote}`),e.push&&t.info(` git -C ${c??"<output>"} push -u origin ${s}`),e.remove&&t.info(` git rm -r ${n} && git commit (in ${r})`);return}const a=c;if(await w(a)){if((await m.readdir(a)).length>0&&!e.force)throw new Error(`${a} is not empty. Re-run with --force to use it anyway.`)}else await m.mkdir(a,{recursive:!0});e.remove&&g(r),t.info(`Splitting ${v(n)} → ${a} ...`);try{x({annotate:e.annotate?`(${f}) `:void 0,branch:d,cwd:r,prefix:n}),B({branch:s,source:r,sourceBranch:d,target:a}),e.remote?(D("origin",e.remote,a),e.push&&P("origin",s,a)):e.push&&t.warn("--push ignored: no --remote provided.");const i=E(s,a);t.info(`✓ Extracted ${f} with ${i} commit(s) to ${a}`),e.remove&&(N(n,`chore(${f}): split out to standalone repo`,r),t.info(`✓ Removed ${n} from the monorepo (committed).`)),e.remote||t.info(v(`Next: cd ${a} && git remote add origin <url> && git push -u origin ${s}`))}finally{try{A(d,r)}catch{}}};export{K as default,z as resolvePackageDirectory};
1
+ import{F as v}from"../packem_shared/index.server-Ca_EEVfw.js";import{v as R,e as y}from"../packem_shared/index-BzhrR_iC.js";import{d as j}from"../packem_shared/registry-Dg9XI6RT.js";import{a as C,b as g,s as x,i as B,c as D,p as P,d as E,r as N,e as A}from"../packem_shared/subtree-DtmcKAJK.js";import{s as W,n as k}from"../packem_shared/utils-DQFHJn72.js";const z=async(u,m,t)=>{const e=m[u];if(e?.root)return{pkgName:u,relativeDir:k(e.root)};const o=k(u);if(o.length>0&&await t(o))return{pkgName:o.split("/").pop()??o,relativeDir:o}},K=async({argument:u,fs:m,logger:t,options:e,process:o,visConfig:h,workspaceRoot:b})=>{const p=u[0];if(!p)throw new Error("Missing <package>. Pass a project name or a workspace-relative path.");if(!e.dryRun&&!e.output)throw new Error("Missing --output <dir>. Pass the destination directory for the new repo (or use --dry-run).");const r=b??o.cwd;C(r);const{workspace:$}=j(r,h),w=async i=>{try{return await m.access(i),!0}catch{return!1}},l=await z(p,$.projects,i=>w(y(r,i,"package.json")));if(!l){const i=Object.keys($.projects).sort().join(", ");throw new Error(`Unknown package "${p}". Known projects: ${i||"(none)"}.`)}const{pkgName:f,relativeDir:n}=l,s=e.branch??h?.defaultBase??"main",d=`vis/split/${W(n.replaceAll("/","-"))}`,c=e.output?R(e.output)?e.output:y(r,e.output):void 0;if(e.dryRun){t.info("Dry run — no changes will be made. Planned git commands:"),t.info(` git subtree split --prefix=${n}${e.annotate?` --annotate=(${f}) `:""} -b ${d}`),c&&(t.info(` git -C ${c} init -b ${s}`),t.info(` git -C ${c} pull ${r} ${d}`)),e.remote&&t.info(` git -C ${c??"<output>"} remote add origin ${e.remote}`),e.push&&t.info(` git -C ${c??"<output>"} push -u origin ${s}`),e.remove&&t.info(` git rm -r ${n} && git commit (in ${r})`);return}const a=c;if(await w(a)){if((await m.readdir(a)).length>0&&!e.force)throw new Error(`${a} is not empty. Re-run with --force to use it anyway.`)}else await m.mkdir(a,{recursive:!0});e.remove&&g(r),t.info(`Splitting ${v(n)} → ${a} ...`);try{x({annotate:e.annotate?`(${f}) `:void 0,branch:d,cwd:r,prefix:n}),B({branch:s,source:r,sourceBranch:d,target:a}),e.remote?(D("origin",e.remote,a),e.push&&P("origin",s,a)):e.push&&t.warn("--push ignored: no --remote provided.");const i=E(s,a);t.info(`✓ Extracted ${f} with ${i} commit(s) to ${a}`),e.remove&&(N(n,`chore(${f}): split out to standalone repo`,r),t.info(`✓ Removed ${n} from the monorepo (committed).`)),e.remote||t.info(v(`Next: cd ${a} && git remote add origin <url> && git push -u origin ${s}`))}finally{try{A(d,r)}catch{}}};export{K as default,z as resolvePackageDirectory};
@@ -1 +1 @@
1
- import{F as T,J as a,b as S,X as y}from"../packem_shared/index.server-Ca_EEVfw.js";import{e as V}from"../packem_shared/index-BzhrR_iC.js";import{enforceProjectConstraints as v}from"@visulima/task-runner";import{d as x,b as J}from"./catalog.js";import{j as w}from"./cli-main.js";import{c as z}from"../packem_shared/runtime-check-D3cRDuoi.js";import{d as D}from"../packem_shared/formatBytes-_HvjOy8a-B_qQr4Hw.js";import{y as G}from"../packem_shared/isAccessibleSync-DYKTrrvc-C-_5cgwu.js";import{p as H}from"../packem_shared/readJsonSync-CbryXYxN-EWl7_7KX.js";const e=c=>c?a("✓"):y("✗"),N=async({fs:c,logger:t,options:b,visConfig:g,workspaceRoot:n})=>{if(!n)throw new Error("Could not determine workspace root.");const{config:h,packageJsons:C,workspace:f}=x(n,g),O=J(n,f,C),k=Object.keys(f.projects).length,d=new Set(Object.values(f.projects).flatMap($=>Object.keys($.targets??{}))).size,i=z(n);let s=0;h.constraints&&(s=v(O,h.constraints).length);const o=w(n,{minRuns:2});let r;const l=D(n);if(G(l)){const F=(await c.readdir(l)).filter(u=>u.endsWith(".json")).sort();let p=0,j=0;for(const u of F.slice(-20))try{const m=H(V(l,u));m.stats&&(p+=m.stats.total??0,j+=m.stats.cached??0)}catch{continue}p>0&&(r=`${(j/p*100).toFixed(0)}%`)}if(b.json){t.info(JSON.stringify({cacheHitRate:r??null,constraintViolations:s,flakyTasks:o.length,projects:k,runtimeIssues:i.length,targets:d},null,2));return}t.info(""),t.info(` ${T("VIS STATUS")}`),t.info(""),t.info(` ${e(!0)} ${String(k)} projects · ${String(d)} unique targets`),t.info(` ${e(i.length===0)} Runtime: ${i.length===0?a("OK"):S(`${String(i.length)} issue(s)`)}`),t.info(` ${e(s===0)} Constraints: ${s===0?a("OK"):y(`${String(s)} violation(s)`)}`),t.info(` ${e(o.length===0)} Flaky tasks: ${o.length===0?a("none"):S(String(o.length))}`),r&&t.info(` ${e(!0)} Cache hit rate: ${r} (last 20 runs)`),t.info("")};export{N as default};
1
+ import{F as T,J as a,b as S,X as y}from"../packem_shared/index.server-Ca_EEVfw.js";import{e as V}from"../packem_shared/index-BzhrR_iC.js";import{enforceProjectConstraints as v}from"@visulima/task-runner";import{d as x,b as J}from"../packem_shared/registry-Dg9XI6RT.js";import{h as w}from"./cli-main.js";import{c as z}from"../packem_shared/runtime-check-D3cRDuoi.js";import{a as D}from"../packem_shared/env-BSXG3QKH.js";import{y as G}from"../packem_shared/isAccessibleSync-DYKTrrvc-C-_5cgwu.js";import{p as H}from"../packem_shared/readJsonSync-CbryXYxN-EWl7_7KX.js";const e=c=>c?a("✓"):y("✗"),N=async({fs:c,logger:t,options:b,visConfig:g,workspaceRoot:n})=>{if(!n)throw new Error("Could not determine workspace root.");const{config:h,packageJsons:C,workspace:f}=x(n,g),O=J(n,f,C),k=Object.keys(f.projects).length,$=new Set(Object.values(f.projects).flatMap(d=>Object.keys(d.targets??{}))).size,i=z(n);let s=0;h.constraints&&(s=v(O,h.constraints).length);const o=w(n,{minRuns:2});let r;const l=D(n);if(G(l)){const F=(await c.readdir(l)).filter(u=>u.endsWith(".json")).sort();let p=0,j=0;for(const u of F.slice(-20))try{const m=H(V(l,u));m.stats&&(p+=m.stats.total??0,j+=m.stats.cached??0)}catch{continue}p>0&&(r=`${(j/p*100).toFixed(0)}%`)}if(b.json){t.info(JSON.stringify({cacheHitRate:r??null,constraintViolations:s,flakyTasks:o.length,projects:k,runtimeIssues:i.length,targets:$},null,2));return}t.info(""),t.info(` ${T("VIS STATUS")}`),t.info(""),t.info(` ${e(!0)} ${String(k)} projects · ${String($)} unique targets`),t.info(` ${e(i.length===0)} Runtime: ${i.length===0?a("OK"):S(`${String(i.length)} issue(s)`)}`),t.info(` ${e(s===0)} Constraints: ${s===0?a("OK"):y(`${String(s)} violation(s)`)}`),t.info(` ${e(o.length===0)} Flaky tasks: ${o.length===0?a("none"):S(String(o.length))}`),r&&t.info(` ${e(!0)} Cache hit rate: ${r} (last 20 runs)`),t.info("")};export{N as default};
@@ -1 +1 @@
1
- import{createTaskGraph as m}from"@visulima/task-runner";import{d as b,b as v}from"./catalog.js";const y=(a,t)=>{const s=new Map;for(const[i,o]of Object.entries(a.dependencies))for(const p of o){const c=s.get(p)??[];c.push(i),s.set(p,c)}if(!a.tasks[t])return;const r=new Set([t]),e=[{node:t,path:[t]}];for(;e.length>0;){const i=e.shift();if(a.roots.includes(i.node))return i.path;for(const o of s.get(i.node)??[])r.has(o)||(r.add(o),e.push({node:o,path:[o,...i.path]}))}return[t]},E=(a,t)=>{const s=[];for(const[r,e]of Object.entries(a.dependencies))e.includes(t)&&s.push(r);return s.sort()},I=async({argument:a,logger:t,visConfig:s,workspaceRoot:r})=>{if(!r)throw new Error("Could not determine workspace root.");const e=a[0];if(!e)throw new Error("No task ID specified. Usage: vis task-why <project>:<target>");if(!e.includes(":"))throw new Error(`Invalid task ID "${e}" — expected format "project:target".`);const{packageJsons:i,workspace:o}=b(r,s),p=v(r,o,i),[c,j]=e.split(":",2),$=o.projects[c];if(!$)throw new Error(`Unknown project "${c}".`);if(!$.targets?.[j])throw new Error(`Project "${c}" has no target "${j}".`);const l=Object.entries(o.projects).flatMap(([n,w])=>Object.keys(w.targets??{}).map(d=>({id:`${n}:${d}`,outputs:[],overrides:{},target:{project:n,target:d}}))),f=m(l,{projectGraph:p,workspace:o});if(!f.tasks[e])throw new Error(`Task "${e}" is not reachable in the graph.`);const h=y(f,e),u=E(f,e);if(t.info(""),t.info(`Why ${e}?`),t.info(""),h&&h.length>1){t.info("Shortest path from a root to this task:");for(const[n,w]of h.entries()){const d=n===0?" ":`${" ".repeat(n+1)}└─ `;t.info(`${d}${w}`)}t.info("")}else t.info(" This task is itself a root — nothing upstream depends on it."),t.info("");if(u.length>0){t.info(`Directly depended on by ${u.length} task(s):`);for(const n of u)t.info(` - ${n}`);t.info("")}const k=f.dependencies[e]??[];if(k.length>0){t.info(`This task depends on ${k.length} task(s):`);for(const n of[...k].sort())t.info(` - ${n}`);t.info("")}};export{I as default};
1
+ import{createTaskGraph as m}from"@visulima/task-runner";import{d as b,b as v}from"../packem_shared/registry-Dg9XI6RT.js";const y=(a,t)=>{const s=new Map;for(const[i,o]of Object.entries(a.dependencies))for(const p of o){const c=s.get(p)??[];c.push(i),s.set(p,c)}if(!a.tasks[t])return;const r=new Set([t]),e=[{node:t,path:[t]}];for(;e.length>0;){const i=e.shift();if(a.roots.includes(i.node))return i.path;for(const o of s.get(i.node)??[])r.has(o)||(r.add(o),e.push({node:o,path:[o,...i.path]}))}return[t]},E=(a,t)=>{const s=[];for(const[r,e]of Object.entries(a.dependencies))e.includes(t)&&s.push(r);return s.sort()},I=async({argument:a,logger:t,visConfig:s,workspaceRoot:r})=>{if(!r)throw new Error("Could not determine workspace root.");const e=a[0];if(!e)throw new Error("No task ID specified. Usage: vis task-why <project>:<target>");if(!e.includes(":"))throw new Error(`Invalid task ID "${e}" — expected format "project:target".`);const{packageJsons:i,workspace:o}=b(r,s),p=v(r,o,i),[c,j]=e.split(":",2),$=o.projects[c];if(!$)throw new Error(`Unknown project "${c}".`);if(!$.targets?.[j])throw new Error(`Project "${c}" has no target "${j}".`);const l=Object.entries(o.projects).flatMap(([n,w])=>Object.keys(w.targets??{}).map(d=>({id:`${n}:${d}`,outputs:[],overrides:{},target:{project:n,target:d}}))),f=m(l,{projectGraph:p,workspace:o});if(!f.tasks[e])throw new Error(`Task "${e}" is not reachable in the graph.`);const h=y(f,e),u=E(f,e);if(t.info(""),t.info(`Why ${e}?`),t.info(""),h&&h.length>1){t.info("Shortest path from a root to this task:");for(const[n,w]of h.entries()){const d=n===0?" ":`${" ".repeat(n+1)}└─ `;t.info(`${d}${w}`)}t.info("")}else t.info(" This task is itself a root — nothing upstream depends on it."),t.info("");if(u.length>0){t.info(`Directly depended on by ${u.length} task(s):`);for(const n of u)t.info(` - ${n}`);t.info("")}const k=f.dependencies[e]??[];if(k.length>0){t.info(`This task depends on ${k.length} task(s):`);for(const n of[...k].sort())t.info(` - ${n}`);t.info("")}};export{I as default};
@@ -1,3 +1,3 @@
1
- import{createRequire as u}from"node:module";import{g as m}from"../packem_shared/package-version-KLwH0Ivy.js";let a;const f=t=>(a??=u(import.meta.url))(t),r=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,d=t=>{if(typeof r<"u"&&r.versions&&r.versions.node){const[e,s]=r.versions.node.split(".").map(Number);if(e>22||e===22&&s>=3||e===20&&s>=16)return r.getBuiltinModule(t)}return f(t)},{execSync:l,spawnSync:p}=d("node:child_process"),y=async({argument:t,logger:e,options:s})=>{const o=t?.[0];e.info("info: checking for updates...");const i=m();let n;try{const c=l("npm view @visulima/vis version",{encoding:"utf8"}).trim();n=o??c}catch{throw new Error("Failed to query npm registry. Check your network connection.")}if(i===n&&!s.force){e.info(`
1
+ import{createRequire as u}from"node:module";import{g as m}from"../packem_shared/package-version-Bq6Cne_7.js";let a;const f=t=>(a??=u(import.meta.url))(t),r=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,d=t=>{if(typeof r<"u"&&r.versions&&r.versions.node){const[e,s]=r.versions.node.split(".").map(Number);if(e>22||e===22&&s>=3||e===20&&s>=16)return r.getBuiltinModule(t)}return f(t)},{execSync:l,spawnSync:p}=d("node:child_process"),y=async({argument:t,logger:e,options:s})=>{const o=t?.[0];e.info("info: checking for updates...");const i=m();let n;try{const c=l("npm view @visulima/vis version",{encoding:"utf8"}).trim();n=o??c}catch{throw new Error("Failed to query npm registry. Check your network connection.")}if(i===n&&!s.force){e.info(`
2
2
  ✓ Already up to date (${i})`);return}if(s.check){i===n?e.info(`✓ Already up to date (${i})`):e.info(`info: found @visulima/vis@${n} (current: ${i})`);return}if(e.info(`info: found @visulima/vis@${n} (current: ${i})`),e.info("info: installing..."),p("npm",["install","-g",`@visulima/vis@${n}`],{encoding:"utf8",stdio:"inherit"}).status!==0)throw new Error("Failed to update. Try running with sudo or fix npm permissions.");e.info(`
3
3
  ✓ Updated @visulima/vis from ${i} → ${n}`)};export{y as default};
@@ -1,3 +1,3 @@
1
- import{d as j,b as k}from"./catalog.js";import{V as n}from"../packem_shared/vis-user-error-CRmrBaD1.js";import{s as P}from"../packem_shared/affected-selection-DGb6Xu5K.js";import{f as y,a as b}from"../packem_shared/selectors-edwcgNl3.js";const x=(r,e)=>{if(r.length>0)return[...r];const a=e.indexOf("affected",2);return a===-1?[]:e.slice(a+1)},M=async({argument:r,options:e,process:a,rawArgv:u,runtime:g,visConfig:o,workspaceRoot:d})=>{if(!r[0])throw new n("Missing target. Usage: vis affected <target>");if(!d)throw new n("Could not determine workspace root. Run this command inside a monorepo.");if(e.sparseCheckout){const c=d,{fileOwners:p,packageJsons:l,workspace:t}=j(c,o),w=k(c,t,l),h=await P({base:e.base,downstream:e.downstream,head:e.head,uncommitted:e.uncommitted,upstream:e.upstream},{fileOwners:p,projectGraph:w,projects:t.projects,workspaceRoot:c},{affectedIgnore:o?.affectedIgnore,defaultBase:o?.defaultBase});let f=y(h.affectedProjects,t,e.query);f=b(f,t,e.tag);const m=[...new Set(f.map(i=>t.projects[i]?.root??i))].sort();process.stdout.write(m.length>0?`${m.join(`
1
+ import{d as j,b as k}from"../packem_shared/registry-Dg9XI6RT.js";import{V as n}from"../packem_shared/vis-user-error-3YS7sPYy.js";import{s as P}from"../packem_shared/affected-selection-CeeZo7Uy.js";import{f as y,a as b}from"../packem_shared/selectors-edwcgNl3.js";const x=(r,e)=>{if(r.length>0)return[...r];const a=e.indexOf("affected",2);return a===-1?[]:e.slice(a+1)},M=async({argument:r,options:e,process:a,rawArgv:u,runtime:g,visConfig:o,workspaceRoot:d})=>{if(!r[0])throw new n("Missing target. Usage: vis affected <target>");if(!d)throw new n("Could not determine workspace root. Run this command inside a monorepo.");if(e.sparseCheckout){const c=d,{fileOwners:p,packageJsons:l,workspace:t}=j(c,o),w=k(c,t,l),h=await P({base:e.base,downstream:e.downstream,head:e.head,uncommitted:e.uncommitted,upstream:e.upstream},{fileOwners:p,projectGraph:w,projects:t.projects,workspaceRoot:c},{affectedIgnore:o?.affectedIgnore,defaultBase:o?.defaultBase});let f=y(h.affectedProjects,t,e.query);f=b(f,t,e.tag);const m=[...new Set(f.map(i=>t.projects[i]?.root??i))].sort();process.stdout.write(m.length>0?`${m.join(`
2
2
  `)}
3
3
  `:"");return}const s=x(u??[],a?.argv??[]);if(s.length===0)throw new n("Missing target. Usage: vis affected <target>");await g.runCommand("run",{argv:s.includes("--affected")?s:[...s,"--affected"]})};export{M as default,x as forwardedArgv};
@@ -1,2 +1,2 @@
1
- import{createRequire as j}from"node:module";import{DEFAULT_CHANGES_DIR as C}from"./DEFAULT_CLEAN_KEEP.js";import{b as B,f as D}from"./orchestrator.js";import{r as E}from"../packem_shared/slug-OBHcH7wV.js";import{VisReleaseError as g}from"../packem_shared/VisReleaseError-DZtgcKf8.js";let I;const S=e=>(I??=j(import.meta.url))(e),l=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,_=e=>{if(typeof l<"u"&&l.versions&&l.versions.node){const[n,a]=l.versions.node.split(".").map(Number);if(n>22||n===22&&a>=3||n===20&&a>=16)return l.getBuiltinModule(e)}return S(e)},{mkdir:V,writeFile:O}=_("node:fs/promises"),{resolve:k,sep:v,join:T}=_("node:path");let w;const X=e=>{w=e},$=async()=>w||(await import("./shell-runner.js")).createShellRunner(),y=e=>!e||!/^[\dv]/i.test(e)?!1:/^[\d.+\-a-z]+$/i.test(e),A=e=>{const n=e.trim(),t=/^(?:[a-z]+(?:\([^)]+\))?:\s+)?[Bb]ump\s+(?<dep>\S+)\s+from\s+(?<fromVersion>\S+)\s+to\s+(?<toVersion>\S+)(?:\s+in\s+\S+)?$/.exec(n);if(t?.groups){const s=t.groups.toVersion;return y(s)?{dep:t.groups.dep,fromVersion:t.groups.fromVersion,toVersion:s}:void 0}const o=/^(?:[a-z]+(?:\([^)]+\))?:\s+)?[Uu]pdate\s+(?:dependency|module)\s+(?<dep>\S+)\s+to\s+(?<toVersion>\S+)(?:\s+\S.*)?$/.exec(n);if(o?.groups){const s=o.groups.toVersion;return y(s)?{dep:o.groups.dep,fromVersion:"",toVersion:s}:void 0}},F=async e=>{const n=process.env.PR_NUMBER;if(n&&/^\d+$/.test(n))return Number.parseInt(n,10);const a=process.env.GITHUB_REF;if(a){const t=/^refs\/pull\/(\d+)\//.exec(a);if(t)return Number.parseInt(t[1],10)}try{const r=await(await $()).run("gh",["pr","view","--json","number"],{cwd:e,silent:!0});if(r.exitCode===0){const o=JSON.parse(r.stdout.trim());if(typeof o.number=="number")return o.number}}catch{}},L=async(e,n)=>{try{const t=await(await $()).run("gh",["pr","view",String(n),"--json","title,body,author"],{cwd:e,silent:!0});return t.exitCode!==0?void 0:JSON.parse(t.stdout.trim())}catch{return}},U=(e,n)=>{const a=[];for(const t of n){const{manifest:r}=t;(Object.hasOwn(r.dependencies??{},e)||Object.hasOwn(r.devDependencies??{},e)||Object.hasOwn(r.peerDependencies??{},e)||Object.hasOwn(r.optionalDependencies??{},e))&&a.push(t.name)}return a},M=e=>{const n={};for(const a of e.split(",")){const t=a.trim();if(!t)continue;const r=t.lastIndexOf(":");if(r<1)throw new g({code:"BUMP_FILE_INVALID",message:`Invalid --packages entry: ${JSON.stringify(t)}. Expected "package:level".`});const o=t.slice(0,r).trim(),s=t.slice(r+1).trim();if(s!=="major"&&s!=="minor"&&s!=="patch"&&s!=="none")throw new g({code:"BUMP_FILE_INVALID",message:`Invalid bump level: ${JSON.stringify(s)}. Expected major|minor|patch|none.`});n[o]=s}return n},W=async e=>{const{multiSelectPrompt:n,selectPrompt:a,textPrompt:t}=await import("./prompts.js"),r=await n("Which packages to bump?",e.map(p=>({label:p,value:p}))),o={};for(const p of r){const m=await a(`Bump level for ${p}?`,[{label:"patch — bug fixes only",value:"patch"},{label:"minor — new feature, backward-compatible",value:"minor"},{label:"major — breaking change",value:"major"},{label:"none — acknowledged, no direct bump",value:"none"}]);o[p]=m}const s=await t("Changelog entry (markdown):","");return{bumps:o,message:s}},K=async({logger:e,options:n,workspaceRoot:a})=>{const t=a??process.cwd(),r=await B({cwd:t,skipRegistryLookup:!0});let o={},s=n.message??"";if(n.fromBotPr){const c=await F(t);if(c===void 0){e.error("No PR found. Set PR_NUMBER, run inside a GitHub Actions PR workflow, or check `gh pr view` works on this branch."),process.exitCode=1;return}const i=await L(t,c);if(!i||typeof i.title!="string"){e.error(`Could not fetch PR #${c} via \`gh pr view\`. Ensure gh is on PATH and authenticated.`),process.exitCode=1;return}const d=A(i.title);if(!d){e.info(`PR #${c} title is not a recognised Dependabot / Renovate pattern; skipping.`),e.info(`Title: ${i.title}`),process.exitCode=0;return}const b=U(d.dep,r.packages),N=d.fromVersion?`from ${d.fromVersion} to ${d.toVersion}`:`to ${d.toVersion}`;if(s=s||`Updated ${d.dep} ${N}`,b.length===0){const h=r.packages[0]?.name;if(!h){e.error("Workspace has no packages — cannot author an acknowledging change file."),process.exitCode=1;return}o={[h]:"none"},s=`${s} (no workspace package depends on ${d.dep})`}else for(const h of b)o[h]="patch"}else if(n.empty)o={},s=s||"Empty change file (no release).";else if(n.packages){o=M(n.packages);const c=new Set(r.packages.map(i=>i.name));for(const i of Object.keys(o))if(!c.has(i))throw new g({code:"BUMP_FILE_INVALID",message:`Unknown workspace package in --packages: ${JSON.stringify(i)}.`,packageName:i})}else{if(!process.stdout.isTTY){e.error("--packages is required when stdin is not a TTY."),e.error("Example: vis release add --packages '@scope/cerebro:minor' --message 'Add X'"),process.exitCode=1;return}const c=await W(r.packages.map(i=>i.name));o=c.bumps,s=s||c.message}if(Object.keys(o).length===0){e.error("No bumps specified."),process.exitCode=1;return}const p=r.config.changesDir??C,m=(n.name??E()).replaceAll(/[^a-z0-9-]/gi,"-"),u=k(t),x=u.endsWith(v)?u:`${u}${v}`,f=k(t,p);if(f!==u&&!f.startsWith(x))throw new g({code:"CONFIG_INVALID",message:`changesDir resolves outside the workspace: ${f} (workspace: ${u}).`});const R=T(f,`${m}.md`),P=D({bumps:o},s);await V(f,{recursive:!0}),await O(R,P,{flag:"wx"}),e.info(`Created ${p}/${m}.md`),e.info("");for(const[c,i]of Object.entries(o))e.info(` ${c}: ${i}`);s&&(e.info(""),e.info(` Body: ${s.split(`
1
+ import{createRequire as j}from"node:module";import{DEFAULT_CHANGES_DIR as C}from"./DEFAULT_CLEAN_KEEP.js";import{b as B,f as D}from"./context.js";import{r as E}from"../packem_shared/slug-OBHcH7wV.js";import{VisReleaseError as g}from"../packem_shared/VisReleaseError-DZtgcKf8.js";let I;const S=e=>(I??=j(import.meta.url))(e),l=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,_=e=>{if(typeof l<"u"&&l.versions&&l.versions.node){const[n,a]=l.versions.node.split(".").map(Number);if(n>22||n===22&&a>=3||n===20&&a>=16)return l.getBuiltinModule(e)}return S(e)},{mkdir:V,writeFile:O}=_("node:fs/promises"),{resolve:k,sep:v,join:T}=_("node:path");let w;const X=e=>{w=e},$=async()=>w||(await import("./shell-runner.js")).createShellRunner(),y=e=>!e||!/^[\dv]/i.test(e)?!1:/^[\d.+\-a-z]+$/i.test(e),A=e=>{const n=e.trim(),t=/^(?:[a-z]+(?:\([^)]+\))?:\s+)?[Bb]ump\s+(?<dep>\S+)\s+from\s+(?<fromVersion>\S+)\s+to\s+(?<toVersion>\S+)(?:\s+in\s+\S+)?$/.exec(n);if(t?.groups){const s=t.groups.toVersion;return y(s)?{dep:t.groups.dep,fromVersion:t.groups.fromVersion,toVersion:s}:void 0}const o=/^(?:[a-z]+(?:\([^)]+\))?:\s+)?[Uu]pdate\s+(?:dependency|module)\s+(?<dep>\S+)\s+to\s+(?<toVersion>\S+)(?:\s+\S.*)?$/.exec(n);if(o?.groups){const s=o.groups.toVersion;return y(s)?{dep:o.groups.dep,fromVersion:"",toVersion:s}:void 0}},F=async e=>{const n=process.env.PR_NUMBER;if(n&&/^\d+$/.test(n))return Number.parseInt(n,10);const a=process.env.GITHUB_REF;if(a){const t=/^refs\/pull\/(\d+)\//.exec(a);if(t)return Number.parseInt(t[1],10)}try{const r=await(await $()).run("gh",["pr","view","--json","number"],{cwd:e,silent:!0});if(r.exitCode===0){const o=JSON.parse(r.stdout.trim());if(typeof o.number=="number")return o.number}}catch{}},L=async(e,n)=>{try{const t=await(await $()).run("gh",["pr","view",String(n),"--json","title,body,author"],{cwd:e,silent:!0});return t.exitCode!==0?void 0:JSON.parse(t.stdout.trim())}catch{return}},U=(e,n)=>{const a=[];for(const t of n){const{manifest:r}=t;(Object.hasOwn(r.dependencies??{},e)||Object.hasOwn(r.devDependencies??{},e)||Object.hasOwn(r.peerDependencies??{},e)||Object.hasOwn(r.optionalDependencies??{},e))&&a.push(t.name)}return a},M=e=>{const n={};for(const a of e.split(",")){const t=a.trim();if(!t)continue;const r=t.lastIndexOf(":");if(r<1)throw new g({code:"BUMP_FILE_INVALID",message:`Invalid --packages entry: ${JSON.stringify(t)}. Expected "package:level".`});const o=t.slice(0,r).trim(),s=t.slice(r+1).trim();if(s!=="major"&&s!=="minor"&&s!=="patch"&&s!=="none")throw new g({code:"BUMP_FILE_INVALID",message:`Invalid bump level: ${JSON.stringify(s)}. Expected major|minor|patch|none.`});n[o]=s}return n},W=async e=>{const{multiSelectPrompt:n,selectPrompt:a,textPrompt:t}=await import("./prompts.js"),r=await n("Which packages to bump?",e.map(p=>({label:p,value:p}))),o={};for(const p of r){const m=await a(`Bump level for ${p}?`,[{label:"patch — bug fixes only",value:"patch"},{label:"minor — new feature, backward-compatible",value:"minor"},{label:"major — breaking change",value:"major"},{label:"none — acknowledged, no direct bump",value:"none"}]);o[p]=m}const s=await t("Changelog entry (markdown):","");return{bumps:o,message:s}},K=async({logger:e,options:n,workspaceRoot:a})=>{const t=a??process.cwd(),r=await B({cwd:t,skipRegistryLookup:!0});let o={},s=n.message??"";if(n.fromBotPr){const c=await F(t);if(c===void 0){e.error("No PR found. Set PR_NUMBER, run inside a GitHub Actions PR workflow, or check `gh pr view` works on this branch."),process.exitCode=1;return}const i=await L(t,c);if(!i||typeof i.title!="string"){e.error(`Could not fetch PR #${c} via \`gh pr view\`. Ensure gh is on PATH and authenticated.`),process.exitCode=1;return}const d=A(i.title);if(!d){e.info(`PR #${c} title is not a recognised Dependabot / Renovate pattern; skipping.`),e.info(`Title: ${i.title}`),process.exitCode=0;return}const b=U(d.dep,r.packages),N=d.fromVersion?`from ${d.fromVersion} to ${d.toVersion}`:`to ${d.toVersion}`;if(s=s||`Updated ${d.dep} ${N}`,b.length===0){const h=r.packages[0]?.name;if(!h){e.error("Workspace has no packages — cannot author an acknowledging change file."),process.exitCode=1;return}o={[h]:"none"},s=`${s} (no workspace package depends on ${d.dep})`}else for(const h of b)o[h]="patch"}else if(n.empty)o={},s=s||"Empty change file (no release).";else if(n.packages){o=M(n.packages);const c=new Set(r.packages.map(i=>i.name));for(const i of Object.keys(o))if(!c.has(i))throw new g({code:"BUMP_FILE_INVALID",message:`Unknown workspace package in --packages: ${JSON.stringify(i)}.`,packageName:i})}else{if(!process.stdout.isTTY){e.error("--packages is required when stdin is not a TTY."),e.error("Example: vis release add --packages '@scope/cerebro:minor' --message 'Add X'"),process.exitCode=1;return}const c=await W(r.packages.map(i=>i.name));o=c.bumps,s=s||c.message}if(Object.keys(o).length===0){e.error("No bumps specified."),process.exitCode=1;return}const p=r.config.changesDir??C,m=(n.name??E()).replaceAll(/[^a-z0-9-]/gi,"-"),u=k(t),x=u.endsWith(v)?u:`${u}${v}`,f=k(t,p);if(f!==u&&!f.startsWith(x))throw new g({code:"CONFIG_INVALID",message:`changesDir resolves outside the workspace: ${f} (workspace: ${u}).`});const R=T(f,`${m}.md`),P=D({bumps:o},s);await V(f,{recursive:!0}),await O(R,P,{flag:"wx"}),e.info(`Created ${p}/${m}.md`),e.info("");for(const[c,i]of Object.entries(o))e.info(` ${c}: ${i}`);s&&(e.info(""),e.info(` Body: ${s.split(`
2
2
  `)[0]?.slice(0,80)??""}`))};export{X as __setBotPrRunnerForTests,K as default,A as parseBotPrTitle};
@@ -1,2 +1,2 @@
1
- import{releaseChangelog as i}from"../packem_shared/ReleaseClient-DAvbxCdo.js";const f=async({logger:e,options:t,workspaceRoot:r})=>{const s=r??process.cwd(),c=t.filter?t.filter.split(",").map(n=>n.trim()).filter(Boolean):void 0,o=await i({channel:t.channel,cwd:s,projects:c});if(t.json){process.stdout.write(`${JSON.stringify(o,null,2)}
1
+ import{releaseChangelog as i}from"../packem_shared/ReleaseClient-CWD9BC5w.js";const f=async({logger:e,options:t,workspaceRoot:r})=>{const s=r??process.cwd(),c=t.filter?t.filter.split(",").map(n=>n.trim()).filter(Boolean):void 0,o=await i({channel:t.channel,cwd:s,projects:c});if(t.json){process.stdout.write(`${JSON.stringify(o,null,2)}
2
2
  `),o.projectChangelogs.length===0&&(process.exitCode=1);return}if(o.projectChangelogs.length===0){e.info("No pending releases — no changelog entries to render."),process.exitCode=1;return}for(const n of o.projectChangelogs)e.info(`# ${n.package} → ${n.file}`),e.info(""),e.info(n.content),e.info("")};export{f as default};
@@ -1,2 +1,2 @@
1
- import{DEFAULT_CHANGES_DIR as F}from"./DEFAULT_CLEAN_KEEP.js";import{b as D,c as b,d as B}from"./orchestrator.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,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(`
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,3 +1,3 @@
1
- import{b as m}from"./orchestrator.js";import{escapeMarkdown as h}from"./security.js";import{createShellRunner as g}from"./shell-runner.js";import{d as w,a as R,u as $}from"../packem_shared/sticky-comment-DjhyCIZt.js";const C=(n,i)=>{const e=["### 🚀 Release Plan",""];if(i&&(e.push(`Channel: \`${i}\``),e.push("")),n.releases.length===0)return e.push("_No pending releases._ (Add a change file via `vis release add` to mark this PR as releasing.)"),e.join(`
2
- `);const r={major:[],minor:[],patch:[]};for(const s of n.releases)r[s.type].push(s);for(const s of["major","minor","patch"])if(r[s].length!==0){e.push(`#### ${s.charAt(0).toUpperCase()}${s.slice(1)}`),e.push("");for(const t of r[s]){const o=[];t.isCascadeBump&&o.push("cascade"),t.isGroupBump&&o.push("group"),t.isDependencyBump&&!t.isCascadeBump&&o.push("dep-bump");const a=o.length>0?` _(${o.join(", ")})_`:"";e.push(`- \`${t.name}\`: ${t.oldVersion} → **${t.newVersion}**${a}`)}e.push("")}if(n.warnings.length>0){e.push("#### ⚠️ Warnings"),e.push("");for(const s of n.warnings)e.push(`- ${h(s)}`)}return e.join(`
3
- `)},b=async({logger:n,options:i,workspaceRoot:e})=>{const r=e??process.cwd(),s=!i.fail,t=i.strict===!0,o=g(),a=await w(o,r),p=R(process.env);(!a||!p)&&n.warn("Not running in a PR context (GITHUB_REF / PR_NUMBER missing or `gh repo view` failed). Falling back to local print.");const c=await m({cwd:r,skipRegistryLookup:!0}),{printConfigIfRequested:f}=await import("./print-config.js");if(f(i,c,n))return;const d=c.config.versionPr?.commentMarker??"<!-- vis-release-comment -->",l=C(c.plan,c.channel?.tag);if(a&&p){const u=await $({body:l,cwd:r,issueNumber:p,marker:d,repo:a,runner:o});if(u)n.info(`${u.created?"Posted":"Updated"} release-plan comment on PR #${p} (id: ${u.id}).`);else{n.error("Failed to post / update PR comment."),process.exitCode=s?0:1;return}}else n.info(l);t&&c.plan.releases.length===0&&(n.error("--strict and no pending releases."),process.exitCode=s?0:1)};export{b as default};
1
+ import{escapeMarkdown as m}from"./security.js";import{createShellRunner as h}from"./shell-runner.js";import{d as g,a as w,u as R}from"../packem_shared/sticky-comment-DjhyCIZt.js";import{b as $}from"./context.js";const C=(n,i)=>{const e=["### 🚀 Release Plan",""];if(i&&(e.push(`Channel: \`${i}\``),e.push("")),n.releases.length===0)return e.push("_No pending releases._ (Add a change file via `vis release add` to mark this PR as releasing.)"),e.join(`
2
+ `);const r={major:[],minor:[],patch:[]};for(const s of n.releases)r[s.type].push(s);for(const s of["major","minor","patch"])if(r[s].length!==0){e.push(`#### ${s.charAt(0).toUpperCase()}${s.slice(1)}`),e.push("");for(const t of r[s]){const o=[];t.isCascadeBump&&o.push("cascade"),t.isGroupBump&&o.push("group"),t.isDependencyBump&&!t.isCascadeBump&&o.push("dep-bump");const a=o.length>0?` _(${o.join(", ")})_`:"";e.push(`- \`${t.name}\`: ${t.oldVersion} → **${t.newVersion}**${a}`)}e.push("")}if(n.warnings.length>0){e.push("#### ⚠️ Warnings"),e.push("");for(const s of n.warnings)e.push(`- ${m(s)}`)}return e.join(`
3
+ `)},b=async({logger:n,options:i,workspaceRoot:e})=>{const r=e??process.cwd(),s=!i.fail,t=i.strict===!0,o=h(),a=await g(o,r),p=w(process.env);(!a||!p)&&n.warn("Not running in a PR context (GITHUB_REF / PR_NUMBER missing or `gh repo view` failed). Falling back to local print.");const c=await $({cwd:r,skipRegistryLookup:!0}),{printConfigIfRequested:f}=await import("./print-config.js");if(f(i,c,n))return;const d=c.config.versionPr?.commentMarker??"<!-- vis-release-comment -->",l=C(c.plan,c.channel?.tag);if(a&&p){const u=await R({body:l,cwd:r,issueNumber:p,marker:d,repo:a,runner:o});if(u)n.info(`${u.created?"Posted":"Updated"} release-plan comment on PR #${p} (id: ${u.id}).`);else{n.error("Failed to post / update PR comment."),process.exitCode=s?0:1;return}}else n.info(l);t&&c.plan.releases.length===0&&(n.error("--strict and no pending releases."),process.exitCode=s?0:1)};export{b as default};
@@ -1,4 +1,4 @@
1
- import{createRequire as d}from"node:module";import{b as y}from"./orchestrator.js";let m;const f=s=>(m??=d(import.meta.url))(s),t=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,g=s=>{if(typeof t<"u"&&t.versions&&t.versions.node){const[o,r]=t.versions.node.split(".").map(Number);if(o>22||o===22&&r>=3||o===20&&r>=16)return t.getBuiltinModule(s)}return f(s)},{appendFileSync:h}=g("node:fs"),j=async({logger:s,options:o,workspaceRoot:r})=>{const u=r??process.cwd(),n=await y({cwd:u,skipRegistryLookup:!0}),{printConfigIfRequested:l}=await import("./print-config.js");if(l(o,n,s))return;const i=n.plan.releases.length===0?"nothing":n.channel?.mode==="version-pr"?"version-pr":"publish",a=n.plan.releases.map(e=>e.name),c={channel:n.channel?.tag,mode:i,packages:a,plan:n.plan.releases.map(e=>({isCascadeBump:e.isCascadeBump,isDependencyBump:e.isDependencyBump,isGroupBump:e.isGroupBump,name:e.name,newVersion:e.newVersion,oldVersion:e.oldVersion,type:e.type})),prerelease:n.channel?.prerelease,warnings:n.plan.warnings};process.stdout.write(`${JSON.stringify(c,null,2)}
1
+ import{createRequire as d}from"node:module";import{b as y}from"./context.js";let m;const f=s=>(m??=d(import.meta.url))(s),t=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,g=s=>{if(typeof t<"u"&&t.versions&&t.versions.node){const[o,r]=t.versions.node.split(".").map(Number);if(o>22||o===22&&r>=3||o===20&&r>=16)return t.getBuiltinModule(s)}return f(s)},{appendFileSync:h}=g("node:fs"),j=async({logger:s,options:o,workspaceRoot:r})=>{const u=r??process.cwd(),n=await y({cwd:u,skipRegistryLookup:!0}),{printConfigIfRequested:l}=await import("./print-config.js");if(l(o,n,s))return;const i=n.plan.releases.length===0?"nothing":n.channel?.mode==="version-pr"?"version-pr":"publish",a=n.plan.releases.map(e=>e.name),c={channel:n.channel?.tag,mode:i,packages:a,plan:n.plan.releases.map(e=>({isCascadeBump:e.isCascadeBump,isDependencyBump:e.isDependencyBump,isGroupBump:e.isGroupBump,name:e.name,newVersion:e.newVersion,oldVersion:e.oldVersion,type:e.type})),prerelease:n.channel?.prerelease,warnings:n.plan.warnings};process.stdout.write(`${JSON.stringify(c,null,2)}
2
2
  `);const p=process.env.GITHUB_OUTPUT;if(p){const e=[`mode=${i}`,`packages=${a.join(",")}`,`json<<__VIS_RELEASE_EOF__
3
3
  ${JSON.stringify(c)}
4
4
  __VIS_RELEASE_EOF__`];try{h(p,`${e.join(`
@@ -1 +1 @@
1
- import{resolvePushAuthEnv as f}from"./git.js";import{b}from"./orchestrator.js";import{createShellRunner as p}from"./shell-runner.js";const v=async({logger:r,options:n,workspaceRoot:d})=>{const t=d??process.cwd(),i=p(),o=await b({cwd:t}),e=n.branch??o.config.versionPr?.branch??"vis-release/version-packages",s=n.base??o.config.baseBranch??"main";r.info(`Rebasing ${e} onto ${s}...`);const a=await i.run("git",["fetch","origin",`${e}:${e}`,s],{cwd:t,silent:!0});if(a.exitCode!==0){r.info(`No remote branch ${e} to rebase (${a.stderr.trim()||"fetch failed"}). Skipping.`);return}const c=await i.run("git",["switch",e],{cwd:t,silent:!0});if(c.exitCode!==0){r.error(`Could not switch to ${e}: ${c.stderr.trim()}`),process.exitCode=1;return}if((await i.run("git",["rebase",`origin/${s}`],{cwd:t,silent:!0})).exitCode!==0){await i.run("git",["rebase","--abort"],{cwd:t,silent:!0}),r.error("Rebase produced conflicts; aborting. Resolve manually, or let the next `vis release ci release` recompute the version PR from scratch."),process.exitCode=1;return}const u=await i.run("git",["rev-list","--count",`origin/${e}..${e}`],{cwd:t,silent:!0});if(u.exitCode===0&&u.stdout.trim()==="0"){r.info(`${e} is already up to date with ${s}. Nothing to push.`);return}const l=await f({cwd:t,runner:i},"origin"),h=await i.run("git",["push","--force-with-lease","origin",`${e}:${e}`],{cwd:t,env:l,silent:!0});if(h.exitCode!==0){r.error(`Failed to force-push ${e}: ${h.stderr.trim()}`),process.exitCode=1;return}r.info(`Force-pushed ${e} after rebasing onto ${s}.`)};export{v as default};
1
+ import{resolvePushAuthEnv as f}from"./git.js";import{createShellRunner as b}from"./shell-runner.js";import{b as p}from"./context.js";const v=async({logger:r,options:n,workspaceRoot:d})=>{const t=d??process.cwd(),i=b(),o=await p({cwd:t}),e=n.branch??o.config.versionPr?.branch??"vis-release/version-packages",s=n.base??o.config.baseBranch??"main";r.info(`Rebasing ${e} onto ${s}...`);const a=await i.run("git",["fetch","origin",`${e}:${e}`,s],{cwd:t,silent:!0});if(a.exitCode!==0){r.info(`No remote branch ${e} to rebase (${a.stderr.trim()||"fetch failed"}). Skipping.`);return}const c=await i.run("git",["switch",e],{cwd:t,silent:!0});if(c.exitCode!==0){r.error(`Could not switch to ${e}: ${c.stderr.trim()}`),process.exitCode=1;return}if((await i.run("git",["rebase",`origin/${s}`],{cwd:t,silent:!0})).exitCode!==0){await i.run("git",["rebase","--abort"],{cwd:t,silent:!0}),r.error("Rebase produced conflicts; aborting. Resolve manually, or let the next `vis release ci release` recompute the version PR from scratch."),process.exitCode=1;return}const u=await i.run("git",["rev-list","--count",`origin/${e}..${e}`],{cwd:t,silent:!0});if(u.exitCode===0&&u.stdout.trim()==="0"){r.info(`${e} is already up to date with ${s}. Nothing to push.`);return}const l=await f({cwd:t,runner:i},"origin"),h=await i.run("git",["push","--force-with-lease","origin",`${e}:${e}`],{cwd:t,env:l,silent:!0});if(h.exitCode!==0){r.error(`Failed to force-push ${e}: ${h.stderr.trim()}`),process.exitCode=1;return}r.info(`Force-pushed ${e} after rebasing onto ${s}.`)};export{v as default};
@@ -1,8 +1,8 @@
1
- import{b as h}from"./orchestrator.js";import{detectRemoteProvider as $,createRemoteClient as w}from"./detect.js";import{createShellRunner as C}from"./shell-runner.js";import{runSnapshot as R}from"./snapshot.js";const P=(n,r)=>{if(n.length===0)return"_No packages were affected by this PR._";const o=["### 📦 Preview Packages",""];for(const e of n){const t=`${e.name}@${e.version}`;o.push(`- \`${e.name}\` → \`${e.version}\``),r?o.push(` \`\`\`sh
1
+ import{detectRemoteProvider as h,createRemoteClient as $}from"./detect.js";import{createShellRunner as w}from"./shell-runner.js";import{runSnapshot as C}from"./snapshot.js";import{b as R}from"./context.js";const P=(n,r)=>{if(n.length===0)return"_No packages were affected by this PR._";const o=["### 📦 Preview Packages",""];for(const e of n){const t=`${e.name}@${e.version}`;o.push(`- \`${e.name}\` → \`${e.version}\``),r?o.push(` \`\`\`sh
2
2
  npm i ${t} --registry ${r}
3
3
  \`\`\``):o.push(` \`\`\`sh
4
4
  npm i ${t}
5
5
  \`\`\``)}return o.join(`
6
- `)},v=async({logger:n,options:r,workspaceRoot:o})=>{const e=o??process.cwd(),t=C(),l=await $(e,t,void 0),a=w(l),s=a.detectPullRequestNumber(process.env),p=r.tag??(s?`pr-${s}`:void 0);if(!p){n.error("Could not determine snapshot tag. Pass --tag or run in a PR context (GITHUB_REF=refs/pull/<n>/merge)."),process.exitCode=1;return}if(r.onClose){await b(e,t,a,s,n);return}let c,u;try{c=await h({cwd:e});const{printConfigIfRequested:i}=await import("./print-config.js");if(i(r,c,n))return;u=await R({context:c,runner:t,tag:p})}catch(i){n.error(`Snapshot failed: ${i.message}`),process.exitCode=1;return}if(n.info(`Snapshotted ${u.published.length} package(s) at version ${u.snapshotVersion} → tag "${u.tag}"`),!s)return;const d=await a.detectRepoSlug(e,t);if(!d){n.warn("Could not detect repo slug — skipping sticky PR comment.");return}const m="<!-- vis-release-snapshot-comment -->",f=`${m}
6
+ `)},v=async({logger:n,options:r,workspaceRoot:o})=>{const e=o??process.cwd(),t=w(),l=await h(e,t,void 0),a=$(l),s=a.detectPullRequestNumber(process.env),p=r.tag??(s?`pr-${s}`:void 0);if(!p){n.error("Could not determine snapshot tag. Pass --tag or run in a PR context (GITHUB_REF=refs/pull/<n>/merge)."),process.exitCode=1;return}if(r.onClose){await b(e,t,a,s,n);return}let c,u;try{c=await R({cwd:e});const{printConfigIfRequested:i}=await import("./print-config.js");if(i(r,c,n))return;u=await C({context:c,runner:t,tag:p})}catch(i){n.error(`Snapshot failed: ${i.message}`),process.exitCode=1;return}if(n.info(`Snapshotted ${u.published.length} package(s) at version ${u.snapshotVersion} → tag "${u.tag}"`),!s)return;const d=await a.detectRepoSlug(e,t);if(!d){n.warn("Could not detect repo slug — skipping sticky PR comment.");return}const m="<!-- vis-release-snapshot-comment -->",f=`${m}
7
7
 
8
8
  ${P(u.published,c.config.snapshot?.registry)}`;try{const i=await a.upsertStickyComment(t,{body:f,cwd:e,issueNumber:s,marker:m,repo:d});i&&n.info(`${i.created?"Posted":"Updated"} snapshot comment on PR #${s}.`)}catch(i){n.warn(`upsertStickyComment failed (publish already succeeded): ${i.message}`)}},b=async(n,r,o,e,t)=>{if(!e){t.error("PR-close cleanup requires a PR context."),process.exitCode=1;return}const l=await o.detectRepoSlug(n,r);if(!l){t.warn("Could not detect repo slug — skipping cleanup.");return}const a=await r.run("gh",["api",`repos/${l}/pulls/${e}/commits`,"--paginate"],{cwd:n,silent:!0});if(a.exitCode!==0){t.warn(`gh api failed: ${a.stderr}`);return}let s;try{s=JSON.parse(a.stdout)}catch{t.warn("Could not parse gh api output.");return}const p=[`pr-${e}`];for(const c of s)p.push(c.sha,c.sha.slice(0,7));t.info(`Cleanup intent for PR #${e}: ${p.length} tag pattern(s) across ${s.length} commit(s)`),t.info("Default backend (pkg-pr-new) auto-cleans by TTL — no DELETE issued. Implement a custom backend's delete endpoint to enable real cleanup.")};export{v as default};