@visulima/vis 1.0.0-alpha.4 → 1.0.0-alpha.40

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 (345) hide show
  1. package/CHANGELOG.md +1216 -78
  2. package/LICENSE.md +13068 -6
  3. package/README.md +388 -26
  4. package/dashboard/dist/index.html +152 -0
  5. package/dist/bin.js +1 -853
  6. package/dist/binx.js +3 -0
  7. package/dist/config/index.d.ts +3258 -0
  8. package/dist/config/index.js +1 -0
  9. package/dist/generate/index.d.ts +157 -0
  10. package/dist/generate/index.js +1 -0
  11. package/dist/packem_chunks/DEFAULT_CLEAN_KEEP.js +1 -0
  12. package/dist/packem_chunks/bin.js +1198 -0
  13. package/dist/packem_chunks/bloom-status.js +2 -0
  14. package/dist/packem_chunks/bloom-sync.js +2 -0
  15. package/dist/packem_chunks/cache-attestation.js +1 -0
  16. package/dist/packem_chunks/catalog-detector.js +1 -0
  17. package/dist/packem_chunks/config.js +21 -0
  18. package/dist/packem_chunks/detect.js +3 -0
  19. package/dist/packem_chunks/detect2.js +8 -0
  20. package/dist/packem_chunks/devtools.js +81 -0
  21. package/dist/packem_chunks/discord.js +4 -0
  22. package/dist/packem_chunks/doctor-probe.js +2 -0
  23. package/dist/packem_chunks/dynamic-import.js +1 -0
  24. package/dist/packem_chunks/extra-files.js +3 -0
  25. package/dist/packem_chunks/fix.js +11 -0
  26. package/dist/packem_chunks/git.js +3 -0
  27. package/dist/packem_chunks/handler.js +1 -0
  28. package/dist/packem_chunks/handler10.js +1 -0
  29. package/dist/packem_chunks/handler11.js +5 -0
  30. package/dist/packem_chunks/handler12.js +1 -0
  31. package/dist/packem_chunks/handler13.js +27 -0
  32. package/dist/packem_chunks/handler14.js +5 -0
  33. package/dist/packem_chunks/handler15.js +1 -0
  34. package/dist/packem_chunks/handler16.js +1 -0
  35. package/dist/packem_chunks/handler17.js +1 -0
  36. package/dist/packem_chunks/handler18.js +1 -0
  37. package/dist/packem_chunks/handler19.js +1 -0
  38. package/dist/packem_chunks/handler2.js +4 -0
  39. package/dist/packem_chunks/handler20.js +5 -0
  40. package/dist/packem_chunks/handler21.js +2 -0
  41. package/dist/packem_chunks/handler22.js +2 -0
  42. package/dist/packem_chunks/handler23.js +1 -0
  43. package/dist/packem_chunks/handler24.js +1 -0
  44. package/dist/packem_chunks/handler25.js +1 -0
  45. package/dist/packem_chunks/handler26.js +5 -0
  46. package/dist/packem_chunks/handler27.js +1 -0
  47. package/dist/packem_chunks/handler28.js +3 -0
  48. package/dist/packem_chunks/handler29.js +1 -0
  49. package/dist/packem_chunks/handler3.js +4 -0
  50. package/dist/packem_chunks/handler30.js +2 -0
  51. package/dist/packem_chunks/handler31.js +2 -0
  52. package/dist/packem_chunks/handler32.js +2 -0
  53. package/dist/packem_chunks/handler33.js +3 -0
  54. package/dist/packem_chunks/handler34.js +6 -0
  55. package/dist/packem_chunks/handler35.js +1 -0
  56. package/dist/packem_chunks/handler36.js +42 -0
  57. package/dist/packem_chunks/handler37.js +8 -0
  58. package/dist/packem_chunks/handler38.js +9 -0
  59. package/dist/packem_chunks/handler39.js +75 -0
  60. package/dist/packem_chunks/handler4.js +6 -0
  61. package/dist/packem_chunks/handler40.js +5 -0
  62. package/dist/packem_chunks/handler41.js +4 -0
  63. package/dist/packem_chunks/handler42.js +3 -0
  64. package/dist/packem_chunks/handler43.js +2 -0
  65. package/dist/packem_chunks/handler44.js +1 -0
  66. package/dist/packem_chunks/handler45.js +1 -0
  67. package/dist/packem_chunks/handler46.js +1 -0
  68. package/dist/packem_chunks/handler47.js +3 -0
  69. package/dist/packem_chunks/handler48.js +1 -0
  70. package/dist/packem_chunks/handler49.js +7 -0
  71. package/dist/packem_chunks/handler5.js +8 -0
  72. package/dist/packem_chunks/handler50.js +33 -0
  73. package/dist/packem_chunks/handler51.js +3 -0
  74. package/dist/packem_chunks/handler52.js +8 -0
  75. package/dist/packem_chunks/handler53.js +4 -0
  76. package/dist/packem_chunks/handler54.js +1 -0
  77. package/dist/packem_chunks/handler55.js +12 -0
  78. package/dist/packem_chunks/handler56.js +7 -0
  79. package/dist/packem_chunks/handler57.js +5 -0
  80. package/dist/packem_chunks/handler58.js +11 -0
  81. package/dist/packem_chunks/handler59.js +3 -0
  82. package/dist/packem_chunks/handler6.js +1 -0
  83. package/dist/packem_chunks/handler60.js +22 -0
  84. package/dist/packem_chunks/handler61.js +61 -0
  85. package/dist/packem_chunks/handler62.js +3 -0
  86. package/dist/packem_chunks/handler63.js +6 -0
  87. package/dist/packem_chunks/handler64.js +708 -0
  88. package/dist/packem_chunks/handler65.js +24 -0
  89. package/dist/packem_chunks/handler66.js +25 -0
  90. package/dist/packem_chunks/handler67.js +153 -0
  91. package/dist/packem_chunks/handler68.js +10 -0
  92. package/dist/packem_chunks/handler69.js +24 -0
  93. package/dist/packem_chunks/handler7.js +1 -0
  94. package/dist/packem_chunks/handler70.js +322 -0
  95. package/dist/packem_chunks/handler71.js +48 -0
  96. package/dist/packem_chunks/handler72.js +27 -0
  97. package/dist/packem_chunks/handler73.js +3 -0
  98. package/dist/packem_chunks/handler74.js +190 -0
  99. package/dist/packem_chunks/handler75.js +38 -0
  100. package/dist/packem_chunks/handler8.js +1 -0
  101. package/dist/packem_chunks/handler9.js +1 -0
  102. package/dist/packem_chunks/heal-accept.js +10 -0
  103. package/dist/packem_chunks/heal.js +14 -0
  104. package/dist/packem_chunks/help-command.js +31 -0
  105. package/dist/packem_chunks/index.js +1 -0
  106. package/dist/packem_chunks/index2.js +7 -0
  107. package/dist/packem_chunks/interface.js +2 -0
  108. package/dist/packem_chunks/keys-refresh.js +4 -0
  109. package/dist/packem_chunks/list.js +3 -0
  110. package/dist/packem_chunks/loader.js +4 -0
  111. package/dist/packem_chunks/loader2.js +1 -0
  112. package/dist/packem_chunks/orchestrator.js +39 -0
  113. package/dist/packem_chunks/pre-mode.js +2 -0
  114. package/dist/packem_chunks/print-config.js +2 -0
  115. package/dist/packem_chunks/prompts.js +7 -0
  116. package/dist/packem_chunks/prune.js +3 -0
  117. package/dist/packem_chunks/publish-guards.js +1 -0
  118. package/dist/packem_chunks/registry.js +48 -0
  119. package/dist/packem_chunks/resolveFormatter.js +9 -0
  120. package/dist/packem_chunks/run.js +1 -0
  121. package/dist/packem_chunks/security.js +1 -0
  122. package/dist/packem_chunks/shell-runner.js +1 -0
  123. package/dist/packem_chunks/slack.js +2 -0
  124. package/dist/packem_chunks/snapshot.js +2 -0
  125. package/dist/packem_chunks/stage-publisher.js +1 -0
  126. package/dist/packem_chunks/staged-registry.js +2 -0
  127. package/dist/packem_chunks/state.js +3 -0
  128. package/dist/packem_chunks/status.js +2 -0
  129. package/dist/packem_chunks/success-walk.js +8 -0
  130. package/dist/packem_chunks/sync.js +2 -0
  131. package/dist/packem_chunks/sync2.js +2 -0
  132. package/dist/packem_chunks/tar.js +3 -0
  133. package/dist/packem_chunks/tripwire.js +2 -0
  134. package/dist/packem_chunks/verify-lockfile.js +2 -0
  135. package/dist/packem_chunks/version-resolver.js +2 -0
  136. package/dist/packem_chunks/webhook.js +1 -0
  137. package/dist/packem_chunks/workflow-templates.js +167 -0
  138. package/dist/packem_chunks/workspace.js +2 -0
  139. package/dist/packem_shared/AfterAllProjectsVersioned-CAKI2nWf.js +1 -0
  140. package/dist/packem_shared/CONFIG_FILES-BfaR0jKT.js +1 -0
  141. package/dist/packem_shared/MultiSpinner-B9U0-aE3-B-gIXhFk.js +3 -0
  142. package/dist/packem_shared/ReleaseClient-YHzBIxYS.js +1 -0
  143. package/dist/packem_shared/Table-CcVkyULl-B_ef6zfS.js +35 -0
  144. package/dist/packem_shared/VisReleaseError-DMGRBTNO.js +1 -0
  145. package/dist/packem_shared/_commonjsHelpers-B5Y90VFO.js +1 -0
  146. package/dist/packem_shared/advisories-DLeO5KMN.js +1 -0
  147. package/dist/packem_shared/affected-shas-cVnX8-zs.js +1 -0
  148. package/dist/packem_shared/ai-analysis-BUeX2J2H.js +68 -0
  149. package/dist/packem_shared/ai-fix-9Vzlp6XU.js +43 -0
  150. package/dist/packem_shared/anolilab-text-CAM_E6uK.js +13 -0
  151. package/dist/packem_shared/api.d-BPftyU9r.d.ts +27 -0
  152. package/dist/packem_shared/build-scripts-CCCi8U66.js +1 -0
  153. package/dist/packem_shared/createAdapter-bU4DIP3F.js +1 -0
  154. package/dist/packem_shared/createVersionActions-BK43SNDH.js +1 -0
  155. package/dist/packem_shared/cyclonedx-kYozDyxp.js +4 -0
  156. package/dist/packem_shared/defineFormatter-D5dCp6Kv.js +1 -0
  157. package/dist/packem_shared/definePlugin-DoUcoYSy.js +1 -0
  158. package/dist/packem_shared/dependency-scan-DnTgYleU.js +1 -0
  159. package/dist/packem_shared/docker-BMLrNtWm.js +59 -0
  160. package/dist/packem_shared/failure-log-CEWP3bP0.js +2 -0
  161. package/dist/packem_shared/giget-DHY1sQZC.js +2 -0
  162. package/dist/packem_shared/glob-fqg4KepW-B7EjLRvw.js +1 -0
  163. package/dist/packem_shared/index-BDmTbWX1.js +19 -0
  164. package/dist/packem_shared/index-CgcF6_wo.js +1 -0
  165. package/dist/packem_shared/index-Du8RWawQ.js +1 -0
  166. package/dist/packem_shared/index-yBikBkHT.js +30 -0
  167. package/dist/packem_shared/interface.d-B7VK2rcH.d.ts +148 -0
  168. package/dist/packem_shared/interface.d-Cezzifoh.d.ts +106 -0
  169. package/dist/packem_shared/license-t5KnNX6v.js +1 -0
  170. package/dist/packem_shared/lifecycle-4z9hHE5b.js +2 -0
  171. package/dist/packem_shared/lockfile-C8Q1_4KK.js +1 -0
  172. package/dist/packem_shared/manifests-Dj3pRKBT.js +1 -0
  173. package/dist/packem_shared/min-release-age-D1alDE3K.js +34 -0
  174. package/dist/packem_shared/missing-package-json-8vNHwbqw.js +1 -0
  175. package/dist/packem_shared/native-config-sync-BEkJW7g3.js +21 -0
  176. package/dist/packem_shared/osv-bloom-B03tUWf3.js +2 -0
  177. package/dist/packem_shared/otelPlugin-DmKDBaPo.js +1 -0
  178. package/dist/packem_shared/peer-warnings-BXAzXqY3.js +1 -0
  179. package/dist/packem_shared/pm-runner-OGResYrA.js +1 -0
  180. package/dist/packem_shared/provenance-_CJjMKwu.js +1 -0
  181. package/dist/packem_shared/public-api-WqUCiyIe.js +131 -0
  182. package/dist/packem_shared/registry-keys-BfFto6vI.js +1 -0
  183. package/dist/packem_shared/resolve-explicit-CMDl55Nz.js +5 -0
  184. package/dist/packem_shared/runtime-check-Stc9AI78.js +1 -0
  185. package/dist/packem_shared/s1ngularity-Dhr3bPk0.js +1 -0
  186. package/dist/packem_shared/scan-progress-CFhc0CMj.js +2 -0
  187. package/dist/packem_shared/selectors-GCJIe342.js +3 -0
  188. package/dist/packem_shared/signatures-C730vkyK.js +2 -0
  189. package/dist/packem_shared/slug-DoueYuLo.js +1 -0
  190. package/dist/packem_shared/spinner-CV3WVJLv.js +1 -0
  191. package/dist/packem_shared/sticky-comment-D6_7-w8T.js +1 -0
  192. package/dist/packem_shared/subtree-C7bZuiSQ.js +2 -0
  193. package/dist/packem_shared/symbols-DPTlrJ3B.js +1 -0
  194. package/dist/packem_shared/tabs-BuTy5gPV.js +1 -0
  195. package/dist/packem_shared/toolchain-pR7AJ-tB.js +5 -0
  196. package/dist/packem_shared/typosquats-DN78xx1x.js +1 -0
  197. package/dist/packem_shared/use-measured-height-_eVGWtWt.js +1 -0
  198. package/dist/packem_shared/utils-Cxree603.js +1 -0
  199. package/dist/packem_shared/verify-6WCmFmy8.js +1 -0
  200. package/dist/packem_shared/vis-update-app-k3fDxech.js +1 -0
  201. package/dist/packem_shared/watch-BvIwLG4N.js +1 -0
  202. package/dist/packem_shared/watch-loop-DWkvv2tK.js +11 -0
  203. package/dist/release/core/changelog/index.d.ts +5 -0
  204. package/dist/release/core/changelog/index.js +1 -0
  205. package/dist/release/core/package-managers/index.d.ts +6 -0
  206. package/dist/release/core/package-managers/index.js +1 -0
  207. package/dist/release/core/version-actions/index.d.ts +14 -0
  208. package/dist/release/core/version-actions/index.js +1 -0
  209. package/dist/release/index.d.ts +196 -0
  210. package/dist/release/index.js +1 -0
  211. package/dist/release/plugin-sdk.d.ts +127 -0
  212. package/dist/release/plugin-sdk.js +1 -0
  213. package/dist/release/presets.d.ts +225 -0
  214. package/dist/release/presets.js +1 -0
  215. package/dist/release/types.d.ts +1377 -0
  216. package/dist/release/types.js +1 -0
  217. package/index.d.ts +436 -0
  218. package/index.js +80 -57
  219. package/package.json +109 -45
  220. package/schemas/project.schema.json +991 -0
  221. package/schemas/vis-config.schema.json +6377 -0
  222. package/schemas/vis-release-config.schema.json +1390 -0
  223. package/skills/vis/SKILL.md +96 -0
  224. package/templates/buildkite-ci/.buildkite/pipeline.yml.tera +85 -0
  225. package/templates/buildkite-ci/template.yml +20 -0
  226. package/dist/ai-analysis.d.ts +0 -40
  227. package/dist/ai-cache.d.ts +0 -21
  228. package/dist/audit-config.d.ts +0 -24
  229. package/dist/bin.d.ts +0 -1
  230. package/dist/catalog.d.ts +0 -118
  231. package/dist/commands/add.d.ts +0 -3
  232. package/dist/commands/affected.d.ts +0 -3
  233. package/dist/commands/ai.d.ts +0 -3
  234. package/dist/commands/analyze.d.ts +0 -3
  235. package/dist/commands/approve-builds.d.ts +0 -3
  236. package/dist/commands/audit.d.ts +0 -23
  237. package/dist/commands/check.d.ts +0 -3
  238. package/dist/commands/clean.d.ts +0 -3
  239. package/dist/commands/create/discovery.d.ts +0 -42
  240. package/dist/commands/create/index.d.ts +0 -13
  241. package/dist/commands/create/prompts.d.ts +0 -31
  242. package/dist/commands/create/random-name.d.ts +0 -15
  243. package/dist/commands/create/templates/builtin.d.ts +0 -15
  244. package/dist/commands/create/templates/generator.d.ts +0 -14
  245. package/dist/commands/create/templates/index.d.ts +0 -13
  246. package/dist/commands/create/templates/monorepo.d.ts +0 -16
  247. package/dist/commands/create/templates/remote.d.ts +0 -41
  248. package/dist/commands/create/templates/types.d.ts +0 -46
  249. package/dist/commands/create/utils.d.ts +0 -42
  250. package/dist/commands/dedupe.d.ts +0 -3
  251. package/dist/commands/devcontainer.d.ts +0 -3
  252. package/dist/commands/dlx.d.ts +0 -3
  253. package/dist/commands/doctor.d.ts +0 -15
  254. package/dist/commands/exec.d.ts +0 -3
  255. package/dist/commands/graph.d.ts +0 -3
  256. package/dist/commands/hook/constants.d.ts +0 -8
  257. package/dist/commands/hook/index.d.ts +0 -3
  258. package/dist/commands/hook/install.d.ts +0 -7
  259. package/dist/commands/hook/migrate.d.ts +0 -27
  260. package/dist/commands/hook/uninstall.d.ts +0 -3
  261. package/dist/commands/implode.d.ts +0 -3
  262. package/dist/commands/init.d.ts +0 -14
  263. package/dist/commands/install.d.ts +0 -3
  264. package/dist/commands/link.d.ts +0 -3
  265. package/dist/commands/migrate/constants.d.ts +0 -12
  266. package/dist/commands/migrate/deps.d.ts +0 -32
  267. package/dist/commands/migrate/index.d.ts +0 -3
  268. package/dist/commands/migrate/json.d.ts +0 -20
  269. package/dist/commands/migrate/lint-staged.d.ts +0 -62
  270. package/dist/commands/migrate/types.d.ts +0 -20
  271. package/dist/commands/optimize.d.ts +0 -38
  272. package/dist/commands/pm.d.ts +0 -3
  273. package/dist/commands/remove.d.ts +0 -3
  274. package/dist/commands/run.d.ts +0 -3
  275. package/dist/commands/sort-package-json.d.ts +0 -3
  276. package/dist/commands/staged.d.ts +0 -3
  277. package/dist/commands/unlink.d.ts +0 -3
  278. package/dist/commands/update.d.ts +0 -3
  279. package/dist/commands/upgrade.d.ts +0 -3
  280. package/dist/commands/why.d.ts +0 -3
  281. package/dist/config.d.ts +0 -67
  282. package/dist/config.js +0 -1
  283. package/dist/native-binding.d.ts +0 -151
  284. package/dist/output.d.ts +0 -40
  285. package/dist/overrides.d.ts +0 -82
  286. package/dist/package-manager.d.ts +0 -23
  287. package/dist/plugins/config-loader.d.ts +0 -3
  288. package/dist/plugins/post-command.d.ts +0 -3
  289. package/dist/plugins/security-enforcement.d.ts +0 -3
  290. package/dist/pm-runner.d.ts +0 -23
  291. package/dist/security.d.ts +0 -64
  292. package/dist/socket-security.d.ts +0 -129
  293. package/dist/tips.d.ts +0 -41
  294. package/dist/tui/components/CheckProgressApp.d.ts +0 -6
  295. package/dist/tui/components/CommandSummary.d.ts +0 -17
  296. package/dist/tui/components/Header.d.ts +0 -13
  297. package/dist/tui/components/OutputPanel.d.ts +0 -16
  298. package/dist/tui/components/QuitDialog.d.ts +0 -15
  299. package/dist/tui/components/TaskListPanel.d.ts +0 -19
  300. package/dist/tui/components/TaskRow.d.ts +0 -12
  301. package/dist/tui/components/TaskStore.d.ts +0 -80
  302. package/dist/tui/components/VisTaskRunnerApp.d.ts +0 -17
  303. package/dist/tui/components/devcontainer/DevcontainerStore.d.ts +0 -66
  304. package/dist/tui/components/devcontainer/VisDevcontainerApp.d.ts +0 -9
  305. package/dist/tui/components/devcontainer/catalogs/extensions.d.ts +0 -8
  306. package/dist/tui/components/devcontainer/catalogs/features.d.ts +0 -8
  307. package/dist/tui/components/devcontainer/catalogs/filters.d.ts +0 -4
  308. package/dist/tui/components/devcontainer/catalogs/mount-suggestions.d.ts +0 -19
  309. package/dist/tui/components/devcontainer/catalogs/templates.d.ts +0 -8
  310. package/dist/tui/components/devcontainer/devcontainer-io.d.ts +0 -14
  311. package/dist/tui/components/devcontainer/sections/DockerComposeSection.d.ts +0 -11
  312. package/dist/tui/components/devcontainer/sections/EnvironmentSection.d.ts +0 -16
  313. package/dist/tui/components/devcontainer/sections/ExtensionsSection.d.ts +0 -11
  314. package/dist/tui/components/devcontainer/sections/FeaturesSection.d.ts +0 -11
  315. package/dist/tui/components/devcontainer/sections/GeneralSection.d.ts +0 -12
  316. package/dist/tui/components/devcontainer/sections/LifecycleSection.d.ts +0 -13
  317. package/dist/tui/components/devcontainer/sections/MountsSection.d.ts +0 -16
  318. package/dist/tui/components/devcontainer/sections/PortsSection.d.ts +0 -10
  319. package/dist/tui/components/devcontainer/sections/PreviewPanel.d.ts +0 -11
  320. package/dist/tui/components/devcontainer/types.d.ts +0 -53
  321. package/dist/tui/components/devcontainer/validate.d.ts +0 -16
  322. package/dist/tui/components/graph/GraphStore.d.ts +0 -42
  323. package/dist/tui/components/graph/ProjectDetailPanel.d.ts +0 -10
  324. package/dist/tui/components/graph/ProjectListPanel.d.ts +0 -20
  325. package/dist/tui/components/graph/VisGraphApp.d.ts +0 -8
  326. package/dist/tui/components/optimize/OptimizeDetailPanel.d.ts +0 -9
  327. package/dist/tui/components/optimize/OptimizeListPanel.d.ts +0 -16
  328. package/dist/tui/components/optimize/OptimizeStore.d.ts +0 -50
  329. package/dist/tui/components/optimize/VisOptimizeApp.d.ts +0 -8
  330. package/dist/tui/components/optimize/constants.d.ts +0 -7
  331. package/dist/tui/components/update/PackageDetailPanel.d.ts +0 -12
  332. package/dist/tui/components/update/PackageListPanel.d.ts +0 -18
  333. package/dist/tui/components/update/UpdateStore.d.ts +0 -62
  334. package/dist/tui/components/update/VisUpdateApp.d.ts +0 -11
  335. package/dist/tui/dynamic-life-cycle.d.ts +0 -21
  336. package/dist/tui/formatting-utils.d.ts +0 -17
  337. package/dist/tui/pretty-time.d.ts +0 -8
  338. package/dist/tui/static-life-cycle.d.ts +0 -22
  339. package/dist/tui/status-utils.d.ts +0 -20
  340. package/dist/tui/symbols.d.ts +0 -7
  341. package/dist/tui/types.d.ts +0 -11
  342. package/dist/typosquats.d.ts +0 -70
  343. package/dist/upgrade-check.d.ts +0 -30
  344. package/dist/utils.d.ts +0 -22
  345. package/dist/workspace.d.ts +0 -315
@@ -0,0 +1 @@
1
+ const b=t=>{const e=new Set,n=[t];for(let r=0;r<n.length;r++){const o=n[r];if(e.has(o))continue;e.add(o);const{children:s}=o;if(s?.length)for(let u=0,c=s.length;u<c;u++)n.push(s[u])}return Array.from(e)},tt=t=>{let e="";const n=b(t);for(let r=0,o=n.length;r<o;r++){const s=n[r];if(!s.regex)continue;const u=s.regex.flags;if(e||(e=u),e!==u)throw new Error(`Inconsistent RegExp flags used: "${e}" and "${u}"`)}return e},Z=(t,e,n)=>{const r=n.get(t);if(r!==void 0)return r;const o=t.partial??e;let s="";if(t.regex&&(s+=o?"(?:$|":"",s+=t.regex.source),t.children?.length){const u=nt(t.children.map(c=>Z(c,e,n)).filter(Boolean));if(u?.length){const c=t.children.some(M=>!M.regex||!(M.partial??e)),a=u.length>1||o&&(!s.length||c);s+=a?o?"(?:$|":"(?:":"",s+=u.join("|"),s+=a?")":""}}return t.regex&&(s+=o?")":""),n.set(t,s),s},et=(t,e)=>{const n=new Map,r=b(t);for(let o=r.length-1;o>=0;o--){const s=Z(r[o],e,n);if(!(o>0))return s}return""},nt=t=>Array.from(new Set(t)),j=(t,e,n)=>j.compile(t,n).test(e);j.compile=(t,e)=>{const n=e?.partial??!1,r=et(t,n),o=tt(t);return new RegExp(`^(?:${r})$`,o)};const rt=(t,e)=>{const n=j.compile(t,e),r=`${n.source.slice(0,-1)}[\\\\/]?$`,o=n.flags;return new RegExp(r,o)},ot=t=>{const e=t.map(r=>r.source).join("|")||"$^",n=t[0]?.flags;return new RegExp(e,n)},q=t=>Array.isArray(t),k=t=>typeof t=="function",st=t=>t.length===0,ut=(()=>{const{toString:t}=Function.prototype,e=/(?:^\(\s*(?:[^,.()]|\.(?!\.\.))*\s*\)\s*=>|^\s*[a-zA-Z$_][a-zA-Z0-9$_]*\s*=>)/;return n=>(n.length===0||n.length===1)&&e.test(t.call(n))})(),it=t=>typeof t=="number",ct=t=>typeof t=="object"&&t!==null,lt=t=>t instanceof RegExp,at=(()=>{const t=/\\\(|\((?!\?(?::|=|!|<=|<!))/;return e=>t.test(e.source)})(),ft=(()=>{const t=/^[a-zA-Z0-9_-]+$/;return e=>t.test(e.source)&&!e.flags.includes("i")})(),O=t=>typeof t=="string",h=t=>t===void 0,pt=t=>{const e=new Map;return n=>{const r=e.get(n);if(r!==void 0)return r;const o=t(n);return e.set(n,o),o}},W=(t,e,n={})=>{const r={cache:{},input:t,index:0,indexBacktrackMax:0,options:n,output:[]},o=d(e)(r),s=Math.max(r.index,r.indexBacktrackMax);if(o&&r.index===t.length)return r.output;throw new Error(`Failed to parse at index ${s}`)},i=(t,e)=>q(t)?$t(t,e):O(t)?_(t,e):ht(t,e),$t=(t,e)=>{const n={};for(const r of t){if(r.length!==1)throw new Error(`Invalid character: "${r}"`);const o=r.charCodeAt(0);n[o]=!0}return r=>{const o=r.input;let s=r.index,u=s;for(;u<o.length&&o.charCodeAt(u)in n;)u+=1;if(u>s){if(!h(e)&&!r.options.silent){const c=o.slice(s,u),a=k(e)?e(c,o,`${s}`):e;h(a)||r.output.push(a)}r.index=u}return!0}},ht=(t,e)=>{if(ft(t))return _(t.source,e);{const n=t.source,r=t.flags.replace(/y|$/,"y"),o=new RegExp(n,r);return at(t)&&k(e)&&!ut(e)?dt(o,e):gt(o,e)}},dt=(t,e)=>n=>{const r=n.index,o=n.input;t.lastIndex=r;const s=t.exec(o);if(s){const u=t.lastIndex;if(!n.options.silent){const c=e(...s,o,`${r}`);h(c)||n.output.push(c)}return n.index=u,!0}else return!1},gt=(t,e)=>n=>{const r=n.index,o=n.input;if(t.lastIndex=r,t.test(o)){const s=t.lastIndex;if(!h(e)&&!n.options.silent){const u=k(e)?e(o.slice(r,s),o,`${r}`):e;h(u)||n.output.push(u)}return n.index=s,!0}else return!1},_=(t,e)=>n=>{const r=n.index,o=n.input;if(o.startsWith(t,r)){if(!h(e)&&!n.options.silent){const s=k(e)?e(t,o,`${r}`):e;h(s)||n.output.push(s)}return n.index+=t.length,!0}else return!1},v=(t,e,n,r)=>{const o=d(t),s=e>1;return R(z(L(u=>{let c=0;for(;c<n;){const a=u.index;if(!o(u)||(c+=1,u.index===a))break}return c>=e},s),r))},F=(t,e)=>v(t,0,1,e),E=(t,e)=>v(t,0,1/0,e),xt=(t,e)=>v(t,1,1/0,e),m=(t,e)=>{const n=t.map(d);return R(z(L(r=>{for(let o=0,s=n.length;o<s;o++)if(!n[o](r))return!1;return!0}),e))},p=(t,e)=>{const n=t.map(d);return R(z(r=>{for(let o=0,s=n.length;o<s;o++)if(n[o](r))return!0;return!1},e))},L=(t,e=!0,n=!1)=>{const r=d(t);return e?o=>{const s=o.index,u=o.output.length,c=r(o);return!c&&!n&&(o.indexBacktrackMax=Math.max(o.indexBacktrackMax,o.index)),(!c||n)&&(o.index=s,o.output.length!==u&&(o.output.length=u)),c}:r},z=(t,e)=>{const n=d(t);return e?r=>{if(r.options.silent)return n(r);const o=r.output.length;if(n(r)){const s=r.output.splice(o,1/0),u=e(s);return h(u)||r.output.push(u),!0}else return!1}:n},R=(()=>{let t=0;return e=>{const n=d(e),r=t+=1;return o=>{var s;if(o.options.memoization===!1)return n(o);const u=o.index,c=(s=o.cache)[r]||(s[r]={indexMax:-1,queue:[]}),a=c.queue;if(u<=c.indexMax){const y=c.store||(c.store=new Map);if(a.length){for(let x=0,P=a.length;x<P;x+=2){const Q=a[x*2],N=a[x*2+1];y.set(Q,N)}a.length=0}const f=y.get(u);if(f===!1)return!1;if(it(f))return o.index=f,!0;if(f)return o.index=f.index,f.output?.length&&o.output.push(...f.output),!0}const M=o.output.length,K=n(o);if(c.indexMax=Math.max(c.indexMax,u),K){const y=o.index,f=o.output.length;if(f>M){const x=o.output.slice(M,f);a.push(u,{index:y,output:x})}else a.push(u,y);return!0}else return a.push(u,!1),!1}}})(),U=t=>{let e;return n=>(e||(e=d(t())),e(n))},d=pt(t=>{if(k(t))return st(t)?U(t):t;if(O(t)||lt(t))return i(t);if(q(t))return m(t);if(ct(t))return p(Object.values(t));throw new Error("Invalid rule")}),g=t=>t,mt=t=>typeof t=="string",wt=t=>{const e=new WeakMap,n=new WeakMap;return(r,o)=>{const s=o?.partial?n:e,u=s.get(r);if(u!==void 0)return u;const c=t(r,o);return s.set(r,c),c}},Mt=t=>{const e={},n={};return(r,o)=>{const s=o?.partial?n:e;return s[r]??(s[r]=t(r,o))}},yt=i(/\\./,g),kt=i(/./,g),At=i(/\*\*\*+/,"*"),Et=i(/([^/{[(!])\*\*/,(t,e)=>`${e}*`),jt=i(/(^|.)\*\*(?=[^*/)\]}])/,(t,e)=>`${e}*`),vt=E(p([yt,At,Et,jt,kt])),zt=t=>W(t,vt,{memoization:!1}).join(""),J="abcdefghijklmnopqrstuvwxyz",Rt=t=>{let e="";for(;t>0;){const n=(t-1)%26;e=J[n]+e,t=Math.floor((t-1)/26)}return e},B=t=>{let e=0;for(let n=0,r=t.length;n<r;n++)e=e*26+J.indexOf(t[n])+1;return e},I=(t,e)=>{if(e<t)return I(e,t);const n=[];for(;t<=e;)n.push(t++);return n},It=(t,e,n)=>I(t,e).map(r=>String(r).padStart(n,"0")),T=(t,e)=>I(B(t),B(e)).map(Rt),l=t=>({partial:!1,regex:new RegExp(t,"s"),children:[]}),A=t=>({children:t}),w=(()=>{const t=(e,n,r)=>{if(r.has(e))return;r.add(e);const{children:o}=e;if(!o.length)o.push(n);else for(let s=0,u=o.length;s<u;s++)t(o[s],n,r)};return e=>{if(!e.length)return A([]);for(let n=e.length-1;n>=1;n--){const r=new Set,o=e[n-1],s=e[n];t(o,s,r)}return e[0]}})(),$=()=>({regex:new RegExp("[\\\\/]","s"),children:[]}),St=i(/\\./,l),Bt=i(/[$.*+?^(){}[\]\|]/,t=>l(`\\${t}`)),Ct=i(/[\\\/]/,$),bt=i(/[^$.*+?^(){}[\]\|\\\/]+/,l),Zt=i(/^(?:!!)*!(.*)$/,(t,e)=>l(`(?!^${S.compile(e).source}$).*?`)),qt=i(/^(!!)+/),Ot=p([Zt,qt]),Wt=i(/\/(\*\*\/)+/,()=>A([w([$(),l(".+?"),$()]),$()])),_t=i(/^(\*\*\/)+/,()=>A([l("^"),w([l(".*?"),$()])])),Ft=i(/\/(\*\*)$/,()=>A([w([$(),l(".*?")]),l("$")])),Lt=i(/\*\*/,()=>l(".*?")),V=p([Wt,_t,Ft,Lt]),Ut=i(/\*\/(?!\*\*\/|\*$)/,()=>w([l("[^\\\\/]*?"),$()])),Jt=i(/\*/,()=>l("[^\\\\/]*")),X=p([Ut,Jt]),Y=i("?",()=>l("[^\\\\/]")),Tt=i("[",g),Vt=i("]",g),Xt=i(/[!^]/,"^\\\\/"),Yt=i(/[a-z]-[a-z]|[0-9]-[0-9]/i,g),Dt=i(/\\./,g),Gt=i(/[$.*+?^(){}[\|]/,t=>`\\${t}`),Ht=i(/[\\\/]/,"\\\\/"),Kt=i(/[^$.*+?^(){}[\]\|\\\/]+/,g),Pt=p([Dt,Gt,Ht,Yt,Kt]),D=m([Tt,F(Xt),E(Pt),Vt],t=>l(t.join(""))),Qt=i("{","(?:"),Nt=i("}",")"),te=i(/(\d+)\.\.(\d+)/,(t,e,n)=>It(+e,+n,Math.min(e.length,n.length)).join("|")),ee=i(/([a-z]+)\.\.([a-z]+)/,(t,e,n)=>T(e,n).join("|")),ne=i(/([A-Z]+)\.\.([A-Z]+)/,(t,e,n)=>T(e.toLowerCase(),n.toLowerCase()).join("|").toUpperCase()),re=p([te,ee,ne]),G=m([Qt,re,Nt],t=>l(t.join(""))),oe=i("{"),se=i("}"),ue=i(","),ie=i(/\\./,l),ce=i(/[$.*+?^(){[\]\|]/,t=>l(`\\${t}`)),le=i(/[\\\/]/,$),ae=i(/[^$.*+?^(){}[\]\|\\\/,]+/,l),fe=U(()=>H),pe=i("",()=>l("(?:)")),$e=xt(p([V,X,Y,D,G,fe,ie,ce,le,ae]),w),C=p([$e,pe]),H=m([oe,F(m([C,E(m([ue,C]))])),se],A),he=E(p([Ot,V,X,Y,D,G,H,St,Bt,Ct,bt]),w),de=t=>W(t,he,{memoization:!1})[0],S=(t,e,n)=>S.compile(t,n).test(e);S.compile=(()=>{const t=Mt((n,r)=>rt(de(zt(n)),r)),e=wt((n,r)=>ot(n.map(o=>t(o,r))));return(n,r)=>mt(n)?t(n,r):e(n,r)})();export{S as default};
@@ -0,0 +1,7 @@
1
+ import{y as U,m as I,I as K,v as b}from"../packem_shared/index-BDmTbWX1.js";import{E as Q}from"../packem_shared/public-api-WqUCiyIe.js";import{b7 as N,b8 as A,b9 as x,u as X,p as Z}from"./bin.js";const ee=(e,t)=>typeof e!="string"||e===""?"":e[0].toLowerCase()+e.slice(1),k=(e,t)=>typeof e!="string"||e===""?"":(t?.locale?e[0].toLocaleUpperCase(t.locale):e[0].toUpperCase())+e.slice(1),te=(e,t)=>`${e}::${t?.joiner??""}::${t?.locale??""}::${t?.knownAcronyms?.join(",")??""}::${t?.normalize?"true":"false"}`,$=(e,t)=>{const{length:r}=e;if(r===0)return"";if(r===1)return e[0];const n=[];let i="",o="";for(let s=0;s<r;s++){const l=e[s];if(N.test(l)){i?(n.push(i+o+l),i="",o=""):(n.length>0&&n.push(t),i=l);continue}i?(o&&(o+=t),o+=l):(n.length>0&&n.push(t),n.push(l))}return n.join("")},ne=/(?<![a-zß])SS(?![a-z])/g,re=e=>e.replaceAll(ne,"ß"),ie=(e,t)=>{if(typeof e!="string"||!e)return"";let r=!0;return $(A(e,{handleAnsi:t?.handleAnsi,handleEmoji:t?.handleEmoji,knownAcronyms:t?.knownAcronyms,locale:t?.locale,normalize:t?.normalize,separators:void 0,stripAnsi:t?.stripAnsi,stripEmoji:t?.stripEmoji}).map(i=>{const o=i,s=o.toLowerCase();return r?(r=!1,ee(s)):k(s,t)}),"")},oe=new x(1e3),S=(e,t)=>{if(typeof e!="string")return"";const r=t?.cache??!1,n=t?.cacheStore??oe;let i;if(r&&(i=te(e,t)),r&&i&&n.has(i))return n.get(i);const o=A(e,{handleAnsi:t?.handleAnsi,handleEmoji:t?.handleEmoji,knownAcronyms:t?.knownAcronyms,locale:t?.locale,normalize:t?.normalize,separators:void 0,stripAnsi:t?.stripAnsi,stripEmoji:t?.stripEmoji}).map(l=>{if(t?.handleAnsi&&N.test(l))return l;if(t?.toUpperCase)return t.locale?l.toLocaleUpperCase(t.locale):l.toUpperCase();const a=t?.locale?.startsWith("de")?re(l):l;return t?.locale?a.toLocaleLowerCase(t.locale):a.toLowerCase()}),s=$(o,t?.joiner??"-");return r&&i&&n.set(i,s),s},se=new x(1e3),le=(e,t)=>S(e,{cacheStore:se,...t,joiner:"_",toUpperCase:!0}),ae=(e,t)=>typeof e!="string"||!e?"":$(A(e,{handleAnsi:t?.handleAnsi,handleEmoji:t?.handleEmoji,knownAcronyms:t?.knownAcronyms,locale:t?.locale,normalize:t?.normalize,separators:void 0,stripAnsi:t?.stripAnsi,stripEmoji:t?.stripEmoji}).map(n=>k(n.toLowerCase(),{locale:t?.locale})),""),ce=new x(1e3),fe=(e,t)=>S(e,{cacheStore:ce,...t,joiner:"_"}),ue=(e,t)=>typeof e!="string"?"":$(A(e,{handleAnsi:t?.handleAnsi,handleEmoji:t?.handleEmoji,knownAcronyms:t?.knownAcronyms,locale:t?.locale,normalize:t?.normalize,separators:void 0,stripAnsi:t?.stripAnsi,stripEmoji:t?.stripEmoji}).map(n=>k(n,{locale:t?.locale})),"-"),m=e=>e==null?"":typeof e=="string"?e:typeof e=="number"||typeof e=="boolean"||typeof e=="bigint"?String(e):JSON.stringify(e),T={camel_case:e=>ie(m(e)),kebab_case:e=>S(m(e)),lower_case:e=>m(e).toLowerCase(),pascal_case:e=>ae(m(e)),path_join:(e,...t)=>{const r=[m(e),...t.map(n=>m(n))];return I(...r)},path_relative:(e,t)=>U(m(t),m(e)),snake_case:e=>fe(m(e)),upper_case:e=>m(e).toUpperCase(),upper_kebab_case:e=>ue(m(e)),upper_snake_case:e=>le(m(e))},z=(e,t,r=[])=>{const n=T[e];if(!n)throw new Error(`Unknown filter "${e}". Known filters: ${Object.keys(T).sort().join(", ")}.`);return n(t,...r)},R=e=>{const t=[];let r=0,n=0,i,o=-1;for(const s of e){if(o+=1,i){s===i&&(i=void 0);continue}if(s==='"'||s==="'"){i=s;continue}s==="("?r+=1:s===")"?r-=1:s===","&&r===0&&(t.push(e.slice(n,o)),n=o+1)}return t.push(e.slice(n)),t},pe=e=>{if(e.startsWith('"')&&e.endsWith('"')||e.startsWith("'")&&e.endsWith("'"))return e.slice(1,-1)},me=/\[([^\]]+)\]/g,de=e=>{const t=e.trim(),r=t.indexOf("(");if(r===-1)return{args:[],name:t};if(!t.endsWith(")"))throw new Error(`Filter call "${e}" missing closing ")"`);const n=t.slice(0,r).trim(),i=t.slice(r+1,-1).trim();return i===""?{args:[],name:n}:{args:R(i).map(o=>{const s=o.trim();return pe(s)??s}),name:n}},he=e=>{const t=e.split("|").map(n=>n.trim()),r=t[0]??"";if(!r)throw new Error(`Empty variable name in expression "${e}"`);return{filters:t.slice(1).map(n=>de(n)),name:r}},ye=e=>e==null?"":typeof e=="string"?e:typeof e=="number"||typeof e=="boolean"||typeof e=="bigint"?String(e):JSON.stringify(e),ge=(e,t)=>{const r=e.replaceAll(me,(n,i)=>{const{filters:o,name:s}=he(i);if(!Object.hasOwn(t,s))throw new Error(`Variable "${s}" used in filename "${e}" but not defined`);let l=t[s];for(const a of o)l=z(a.name,l,a.args);return ye(l)});return P(r)},P=e=>e.split("/").map(t=>t.endsWith(".tera")||t.endsWith(".twig")?t.slice(0,-5):t).join("/"),we=e=>e.endsWith(".raw")?e.slice(0,-4):e,be=e=>{const t=e.split("/");return(t.at(-1)??"").startsWith("_")?!0:t.slice(0,-1).includes("partials")},Ee=(e,t)=>{if(!e.startsWith(`---
2
+ `)&&!e.startsWith(`---\r
3
+ `))return{body:e};const r=e.indexOf(`
4
+ ---`,3);if(r===-1)return{body:e};let n=r+1+3;e[n]==="\r"&&(n+=1),e[n]===`
5
+ `&&(n+=1);const i=e.startsWith(`---\r
6
+ `)?5:4,o=e.slice(i,r).replaceAll("\r","");let s;try{s=t(o)}catch(l){const a=l instanceof Error?l.message:String(l);throw new Error(`Failed to parse frontmatter YAML: ${a}`,{cause:l})}if(s==null)return{body:e.slice(n)};if(typeof s!="object"||Array.isArray(s))throw new TypeError(`Frontmatter must be a YAML mapping, got ${Array.isArray(s)?"array":typeof s}`);return{body:e.slice(n),frontmatter:s}},ve=/\{\{-?(.+?)-?\}\}|\{%-?(.+?)-?%\}/gs,q=e=>{const t=[];let r=0,n=1;const i=o=>{for(const s of o)s===`
7
+ `&&(n+=1)};for(const o of e.matchAll(ve)){const s=o.index??0;if(s>r){const c=e.slice(r,s);t.push({line:n,type:"text",value:c}),i(c)}const l=n,a=o[0];a.startsWith("{{")?t.push({line:l,type:"expr",value:(o[1]??"").trim()}):t.push({line:l,type:"stmt",value:(o[2]??"").trim()}),i(a),r=s+a.length}if(r<e.length){const o=e.slice(r);t.push({line:n,type:"text",value:o})}return t},Ae=new Set(["block","endblock","endfilter","endmacro","extends","filter","import","macro","set"]),F=(e,t)=>{let r=0;const n=(o,s)=>{throw new Error(`${t}:${o}: ${s}`)},i=o=>{const s=[];for(;r<e.length;){const l=e[r];if(l.type==="text"){s.push({type:"text",value:l.value}),r+=1;continue}if(l.type==="expr"){s.push({expression:l.value,line:l.line,type:"expr"}),r+=1;continue}const a=l.value.split(/\s+/)[0]??"";if(o.includes(a))return s;if(Ae.has(a)&&n(l.line,`Tera feature "{% ${a} %}" is not supported. Supported: if/else/endif, for/endfor, include. Rewrite the template to avoid macros, set, extends, block, and import.`),a==="if"){r+=1;const c=l.value.slice(2).trim(),p=i(["else","endif"]);let f;r<e.length&&e[r].type==="stmt"&&e[r].value.split(/\s+/)[0]==="else"&&(r+=1,f=i(["endif"])),(r>=e.length||e[r].type!=="stmt"||e[r].value.split(/\s+/)[0]!=="endif")&&n(l.line,"Unterminated {% if %} — missing {% endif %}"),r+=1,s.push({alternate:f,condition:c,consequent:p,line:l.line,type:"if"});continue}if(a==="for"){r+=1;const c=l.value.slice(3).trim(),p=c.indexOf(" in ");p===-1&&n(l.line,"Malformed {% for %} — expected `for <name> in <collection>`");const f=c.slice(0,p).trim(),d=c.slice(p+4).trim();(!f||!d)&&n(l.line,"Malformed {% for %} — missing binding or collection");const u=i(["endfor"]);(r>=e.length||e[r].type!=="stmt"||e[r].value.split(/\s+/)[0]!=="endfor")&&n(l.line,"Unterminated {% for %} — missing {% endfor %}"),r+=1,s.push({binding:f,body:u,collection:d,line:l.line,type:"for"});continue}if(a==="include"){r+=1;const c=l.value.slice(7).trim(),p=G(c);p===void 0&&n(l.line,"Malformed {% include %} — expected a quoted partial name"),s.push({line:l.line,name:p,type:"include"});continue}n(l.line,`Unknown tag "{% ${a} %}". Supported: if, for, include.`)}return s};return i([])},G=e=>{if(e.startsWith('"')&&e.endsWith('"')||e.startsWith("'")&&e.endsWith("'"))return e.slice(1,-1)},$e=e=>e==null?"":typeof e=="boolean"||typeof e=="number"?String(e):typeof e=="string"?e:JSON.stringify(e),je=e=>e==null||e===!1||e===0||e===""?!1:Array.isArray(e)?e.length>0:!0,B=(e,t,r,n,i=!0)=>{const o=e.split(".");if(i&&o.length>0&&!Object.hasOwn(t,o[0]))throw new Error(`${n}:${r}: Variable "${e}" is not defined`);let s=t;for(const l of o){if(s==null)return;if(typeof s!="object")throw new TypeError(`${n}:${r}: Cannot read "${l}" on non-object value`);s=s[l]}return s},xe=e=>{const t=[];let r=0,n=0,i;for(let o=0;o<e.length;o+=1){const s=e[o];if(i){s===i&&(i=void 0);continue}if(s==='"'||s==="'"){i=s;continue}s==="("?r+=1:s===")"?r-=1:s==="|"&&r===0&&(t.push(e.slice(n,o)),n=o+1)}return t.push(e.slice(n)),t},ke=e=>{const t=e.trim(),r=t.indexOf("(");if(r===-1)return{args:[],name:t};if(!t.endsWith(")"))throw new Error(`Filter call "${e}" missing closing ")"`);const n=t.slice(0,r).trim(),i=t.slice(r+1,-1).trim();return i?{args:R(i).map(o=>o.trim()),name:n}:{args:[],name:n}},v=(e,t,r,n,i=!0)=>{const o=e.trim();if(o==="true")return!0;if(o==="false")return!1;if(o==="null"||o==="none")return null;const s=G(o);return s!==void 0?s:/^-?\d+(?:\.\d+)?$/.test(o)?Number(o):B(o,t,r,n,i)},D=(e,t,r,n,i=!0)=>{const o=xe(e),s=o[0].trim();let l=v(s,t,r,n,i);for(let a=1;a<o.length;a+=1){const c=o[a].trim(),{args:p,name:f}=ke(c),d=p.map(u=>v(u,t,r,n,i));try{l=z(f,l,d)}catch(u){const y=u instanceof Error?u.message:String(u);throw new Error(`${n}:${r}: ${y}`,{cause:u})}}return l},Y=(e,t)=>{let r,n=0;for(let i=0;i<=e.length-t.length;i+=1){const o=e[i];if(r){o===r&&(r=void 0);continue}if(o==='"'||o==="'"){r=o;continue}if(o==="("){n+=1;continue}if(o===")"){n-=1;continue}if(n===0&&e.slice(i,i+t.length)===t)return i}return-1},_=(e,t)=>{const r=[];let n=0,i=0;for(;i<=e.length-t.length;){const o=Y(e.slice(i),t);if(o===-1)break;r.push(e.slice(n,i+o)),i+=o+t.length,n=i}return r.push(e.slice(n)),r},g=(e,t,r,n)=>{const i=e.trim();if(i==="")return!1;if(i.startsWith("(")&&i.endsWith(")")&&Se(i)===i.length-1)return g(i.slice(1,-1),t,r,n);const o=_(i," or ");if(o.length>1)return o.some(l=>g(l,t,r,n));const s=_(i," and ");if(s.length>1)return s.every(l=>g(l,t,r,n));if(i.startsWith("not "))return!g(i.slice(4),t,r,n);for(const l of["==","!="]){const a=Y(i,l);if(a!==-1){const c=v(i.slice(0,a),t,n,r,!1),p=v(i.slice(a+l.length),t,n,r,!1),f=c===p;return l==="=="?f:!f}}return je(D(i,t,n,r,!1))},Se=e=>{if(e[0]!=="(")return-1;let t=0,r,n=-1;for(const i of e){if(n+=1,r){i===r&&(r=void 0);continue}if(i==='"'||i==="'"){r=i;continue}if(i==="(")t+=1;else if(i===")"&&(t-=1,t===0))return n}return-1},E=(e,t)=>{let r="";for(const n of e){if(n.type==="text"){r+=n.value;continue}if(n.type==="expr"){r+=$e(D(n.expression,t.scope,n.line,t.filename));continue}if(n.type==="if"){const i=g(n.condition,t.scope,t.filename,n.line)?n.consequent:n.alternate??[];r+=E(i,t);continue}if(n.type==="for"){const i=B(n.collection,t.scope,n.line,t.filename,!1);if(i==null)continue;if(!Array.isArray(i))throw new TypeError(`${t.filename}:${n.line}: {% for %} expected an array, got ${typeof i}`);for(const o of i){const s={...t.scope,[n.binding]:o};r+=E(n.body,{...t,scope:s})}continue}if(n.type==="include"){const i=t.partials?.get(n.name);if(!i)throw new Error(`${t.filename}:${n.line}: Partial "${n.name}" not found. Available: ${[...t.partials?.keys()??[]].join(", ")||"(none)"}`);const o=t.includeStack??new Set;if(o.has(n.name)){const s=[...o,n.name].join(" → ");throw new Error(`${t.filename}:${n.line}: Circular partial include detected: ${s}`)}o.add(n.name);try{r+=E(i,{...t,filename:`<partial:${n.name}>`,includeStack:o})}finally{o.delete(n.name)}}}return r},Ce=(e,t)=>F(q(e),t),j=(e,t)=>E(F(q(e),t.filename),t),L="template.yml",Oe=".raw",We=new Set([".cjs",".css",".env",".gitattributes",".gitignore",".graphql",".html",".ini",".js",".json",".json5",".jsonc",".jsx",".lock",".md",".mdx",".mjs",".prettierrc",".raw",".rs",".scss",".sh",".sql",".svg",".tera",".toml",".ts",".tsx",".twig",".txt",".vue",".xml",".yaml",".yml"]),Te=new Set(["Brewfile","CHANGELOG","CODEOWNERS","CONTRIBUTING","COPYING","Dockerfile","Gemfile","LICENCE","LICENSE","Makefile","NOTICE","Procfile","Rakefile","README","VERSION"]),_e=e=>{const t=Math.max(e.lastIndexOf("/"),e.lastIndexOf("\\")),r=t===-1?e:e.slice(t+1),n=r.lastIndexOf(".");return n===-1||n===0?"":r.slice(n).toLowerCase()},J=e=>{const t=Math.max(e.lastIndexOf("/"),e.lastIndexOf("\\"));return t===-1?e:e.slice(t+1)},Le=e=>{const t=_e(e);if(t!=="")return We.has(t);const r=J(e);return Te.has(r)},Me=e=>{const t={default:e.default,internal:e.internal,order:e.order,prompt:e.prompt,required:e.required};switch(e.type){case"array":return{...t,type:"array"};case"boolean":return{...t,default:typeof t.default=="boolean"?t.default:void 0,type:"boolean"};case"enum":return{...t,multiple:e.multiple,type:"enum",values:e.values??[]};case"number":return{...t,type:"number"};case"string":return{...t,type:"string"};default:throw new Error(`Unsupported variable type "${String(e.type)}"`)}},Ue=e=>e.replaceAll("\\","/").replace(/^\.\//,"").replaceAll(/\/+/g,"/"),Ie=(e,t,r)=>{const n=t.split("/").filter(Boolean);if(n.length===0)throw new Error("Empty destination path for value");let i=e;for(let o=0;o<n.length-1;o+=1){const s=n[o],l=i[s];if(l===void 0){const a={};i[s]=a,i=a}else if(typeof l=="object"&&!Buffer.isBuffer(l))i=l;else throw new TypeError(`Path conflict: "${n.slice(0,o+1).join("/")}" is both a file and a directory`)}i[n.at(-1)]=r},M=(e,t,r)=>{if(typeof e!="string")return Ne(e);const n=e.includes("{{")||e.includes("{%")?j(e,{filename:`${r}#frontmatter`,scope:t}):e;return g(n,t,`${r}#frontmatter`,1)},Ne=e=>e==null||e===!1||e===0||e===""?!1:Array.isArray(e)?e.length>0:typeof e=="string"?e!=="false"&&e!=="0":!0,Fe=(e,t)=>{const r=I(e,L),n=X(r);if(!n||typeof n!="object")throw new Error(`${r}: must contain a YAML mapping`);const i={};if(n.variables)for(const[a,c]of Object.entries(n.variables))i[a]=Me(c);const o=new Map,s=[];for(const a of K(e,{includeDirs:!1,includeSymlinks:!1})){if(a.path===r)continue;const c=U(e,a.path).replaceAll("\\","/");if(c===L)continue;if(be(c)){const f=b(a.path),d=Ce(f,c);for(const u of ze(c))o.has(u)&&o.get(u)!==d&&Z.warn(`partial name "${u}" is declared by multiple files — last one wins. Use distinct names or fully-qualified includes.`),o.set(u,d);continue}if(c.endsWith(Oe)){const f=b(a.path);s.push({binary:null,isRaw:!0,rawText:f,relativePath:c});continue}if(Le(c)){const f=b(a.path);s.push({binary:null,isRaw:!1,rawText:f,relativePath:c});continue}const p=b(a.path,{buffer:!0});s.push({binary:p,isRaw:!1,rawText:null,relativePath:c})}const l=a=>{const c={...a.builtins,...a.options},p={},f={};for(const u of s){const y=u.relativePath;let w,C,O=!1;if(u.binary)w=u.binary;else if(u.isRaw)w=u.rawText??"";else{const V=u.rawText??"",h=Ee(V,H=>Q(H));if(h.frontmatter){if(h.frontmatter.skip!==void 0&&M(h.frontmatter.skip,c,y)||h.frontmatter.if!==void 0&&!M(h.frontmatter.if,c,y))continue;typeof h.frontmatter.to=="string"&&(C=j(h.frontmatter.to,{filename:`${y}#frontmatter.to`,partials:o,scope:c})),h.frontmatter.force===!0&&(O=!0)}w=j(h.body,{filename:y,partials:o,scope:c})}const W=Ue(C??ge(we(y),c));Ie(p,W,w),O&&(f[W]={force:!0})}const d={files:p};return Object.keys(f).length>0&&(d.filesMeta=f),d};return{about:{description:n.description??`Moon-format template at ${e}`,name:n.title??t},destination:n.destination,options:i,produce:l}},ze=e=>{const t=P(e),r=J(t),n=new Set([r,t]);if(r.startsWith("_")){n.add(r.replace(/^_+/,""));const i=t.slice(0,t.length-r.length);n.add(`${i}${r.replace(/^_+/,"")}`)}return[...n]};export{Fe as loadMoonTemplate};
@@ -0,0 +1,2 @@
1
+ const u=e=>e==null?[]:Array.isArray(e)?e:[e],y=e=>e.length===0?!1:e.every(t=>/-/.test(t.version)),g=async(e,t,c)=>{const a=c??{warn:o=>process.stderr.write(`${o}
2
+ `)},n={failed:[],succeeded:[]};if(!e||t.published.length===0||(e.skipPrerelease??!0)&&y(t.published))return n;const i=[],{redactTokens:p}=await import("./security.js"),{SlackNotificationChannel:r}=await import("./slack.js");for(const o of u(e.slack))i.push(new r(o));const{DiscordNotificationChannel:l}=await import("./discord.js");for(const o of u(e.discord))i.push(new l(o));const{WebhookNotificationChannel:w}=await import("./webhook.js");for(const o of u(e.webhook))i.push(new w(o));for(const o of e.plugins??[])try{const s=await m(o);i.push(s)}catch(s){const f=typeof o=="string"?o:o[0],d=s.message,h=p(d);n.failed.push({error:`plugin load failed: ${h}`,id:f}),a.warn(`[notifications:${f}] could not load plugin: ${h}`)}return i.length===0||await Promise.all(i.map(async o=>{try{await o.send(t),n.succeeded.push(o.id)}catch(s){const f=s instanceof Error?s.message:String(s),d=p(f);n.failed.push({error:d,id:o.id}),a.warn(`[notifications:${o.id}] ${d}`)}})),n},m=async e=>{const[t,c]=Array.isArray(e)?e:[e,void 0],{pathToFileURL:a}=await import("node:url"),n=t.startsWith(".")?a(`${process.cwd()}/${t}`).href:t,{dynamicEsmImport:i}=await import("./dynamic-import.js"),p=await i(n),r=p.default??p;if(typeof r=="function"){const l=r(c);if(l&&typeof l=="object"&&typeof l.send=="function")return l}if(r&&typeof r=="object"&&typeof r.send=="function")return r;throw new TypeError(`Notification plugin at ${t} did not export a NotificationChannel (object with .send) or a factory returning one.`)},A=(e,t)=>{if(typeof e!="string")return String(e??"");const c=t.published[0];return e.replaceAll("{count}",String(t.published.length)).replaceAll("{packages}",t.published.map(a=>`${a.name}@${a.version}`).join(", ")).replaceAll("{firstName}",c?.name??"").replaceAll("{firstVersion}",c?.version??"").replaceAll("{channel}",t.channel??"").replaceAll("{repo}",t.repo??"").replaceAll("{date}",t.completedAt.slice(0,10))};export{g as dispatchNotifications,A as expandNotificationTemplate};
@@ -0,0 +1,4 @@
1
+ import{p as r}from"./bin.js";import{c as i,f as a}from"../packem_shared/registry-keys-BfFto6vI.js";const n=async({options:s})=>{if(s.clear){const t=i();if(s.json){process.stdout.write(`${JSON.stringify({cleared:t,refetched:!1},void 0,2)}
2
+ `);return}r.success(t?"Cleared cached npm signing keys.":"No cached npm signing keys to clear.");return}const e=await a({forceRefresh:!0});if(e===void 0){if(s.json){process.stdout.write(`${JSON.stringify({cleared:!1,error:"fetch-failed",refetched:!1},void 0,2)}
3
+ `),process.exitCode=1;return}r.error("Failed to fetch npm signing keys (network error and no cached keys available)."),process.exitCode=1;return}if(s.json){process.stdout.write(`${JSON.stringify({cleared:!1,fromCache:e.fromCache,keyCount:e.keys.length,refetched:!e.fromCache,stale:e.stale??!1},void 0,2)}
4
+ `);return}if(e.fromCache&&e.stale===!0){r.warn(`Network fetch failed — falling back to expired cache (${String(e.keys.length)} keys).`);return}r.success(`Refreshed npm signing keys (${String(e.keys.length)} keys).`)};export{n as default};
@@ -0,0 +1,3 @@
1
+ import{createRequire as _}from"node:module";import{ag as x,p as o,ah as B}from"./bin.js";import{w as R}from"../packem_shared/pm-runner-OGResYrA.js";import{W as V}from"../packem_shared/build-scripts-CCCi8U66.js";import{m as y,f as w}from"../packem_shared/index-BDmTbWX1.js";import{a as W}from"./config.js";const j=_(import.meta.url),v=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,D=c=>{if(typeof v<"u"&&v.versions&&v.versions.node){const[r,f]=v.versions.node.split(".").map(Number);if(r>22||r===22&&f>=3||r===20&&f>=16)return v.getBuiltinModule(c)}return j(c)},{readdirSync:S,statSync:M}=D("node:fs"),q=(c,r={})=>{const f=y(c,"node_modules");if(!w(f))return[];const l=new Map,p=new Set,$=(n,s,t)=>{const e=`${s}@${t}`;if(p.has(e))return;p.add(e);const i=t.startsWith(c)?t.slice(c.length+1):t;let u=l.get(n);u||(u=[],l.set(n,u)),u.some(b=>b.name===s)||u.push({name:s,relativePath:i})},d=(n,s="")=>{let t;try{t=S(n)}catch{return}for(const e of t){const i=y(n,e);if(e.startsWith("@")){d(i,`${e}/`);continue}if(e===".pnpm"&&s===""){let a;try{a=S(i)}catch{continue}for(const m of a){const h=y(i,m,"node_modules");w(h)&&d(h)}continue}if(e.startsWith("."))continue;const u=s+e,b=y(i,"package.json");try{if(!M(i).isDirectory()||!w(b))continue;const a=W(b),m=typeof a.name=="string"?a.name:u;if(typeof a.bin=="string"){const k=m.includes("/")?m.split("/").pop():m;$(k,m,i)}else if(a.bin&&typeof a.bin=="object")for(const k of Object.keys(a.bin))$(k,m,i);const h=y(i,"node_modules");w(h)&&d(h)}catch{}}};d(f);const g=[];for(const[n,s]of l)s.length<2||r[n]===!0||s.every(t=>r[`${t.name}#${n}`]===!0)||g.push({bin:n,packages:s});return g.sort((n,s)=>n.bin.localeCompare(s.bin))},C=new Set(["bun","npm","pnpm","yarn"]),J=({options:c,visConfig:r,workspaceRoot:f})=>{const l=f??process.cwd(),p=R(l),$=r?.security?.policies?.installScripts?.allow??{},d=r?.security?.allowBins??{},g=r?.security?.pinVersions===!0,n=V(l,$,{pinVersions:g}),s=q(l,d),t=r&&C.has(p.name)?x(r,p.name,l):void 0;if(c.json){process.stdout.write(`${JSON.stringify({binConflicts:s,drift:t,excess:n.excess,installed:n.installed.map(e=>({hooks:e.hooks,name:e.name,version:e.version})),packageManager:p.name,pinVersions:g,unapproved:n.unapproved.map(e=>({hooks:e.hooks,name:e.name,version:e.version})),versionDrift:n.versionDrift},void 0,2)}
2
+ `);return}if(o.info(`Build-script status (${p.name}):
3
+ `),n.installed.length===0&&n.unapproved.length===0&&o.success(" No installed packages declare lifecycle scripts."),n.installed.length>0){o.success(` Approved (${String(n.installed.length)}):`);for(const e of n.installed)o.info(` ✓ ${e.name} — ${e.hooks.join(", ")}`)}if(n.unapproved.length>0){o.info(""),o.warn(` Unapproved (${String(n.unapproved.length)}):`);for(const e of n.unapproved)o.info(` ✗ ${e.name} — ${e.hooks.join(", ")}`);o.notice(" Run 'vis approve-builds' to review.")}if(n.excess.length>0){o.info(""),o.warn(` Stale allowlist entries (${String(n.excess.length)}):`);for(const e of n.excess)o.info(` ! ${e}`);o.notice(" Remove these from vis.config.ts security.policies.installScripts.allow.")}if(n.versionDrift.length>0){o.info(""),o.warn(` Version drift (pinVersions: true) — ${String(n.versionDrift.length)} entr${n.versionDrift.length===1?"y":"ies"} point at outdated versions:`);for(const{from:e,to:i}of n.versionDrift)o.info(` ${e} → ${i}`);o.notice(" Update vis.config.ts security.policies.installScripts.allow keys to migrate.")}if(s.length>0){o.info(""),o.warn(` Bin conflicts (${String(s.length)}) — multiple packages expose the same bin name:`);for(const e of s)o.info(` ${e.bin} ← ${e.packages.map(i=>i.name).join(", ")}`);o.notice(" Add the bin (or 'pkg#bin') to vis.config.ts security.allowBins to silence this.")}if(t?.hasDrift){o.info("");for(const e of B(t))o.warn(e)}};export{J as default};
@@ -0,0 +1,4 @@
1
+ import{createRequire as m}from"node:module";import{w as d,M as _}from"../packem_shared/pm-runner-OGResYrA.js";const w=m(import.meta.url),o=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,g=e=>{if(typeof o<"u"&&o.versions&&o.versions.node){const[t,r]=o.versions.node.split(".").map(Number);if(t>22||t===22&&r>=3||t===20&&r>=16)return o.getBuiltinModule(e)}return w(e)},{createInterface:y}=g("node:readline"),s="sigstore",$=()=>!!process.stdout.isTTY&&process.env.CI!=="true",v=e=>new Promise(t=>{const r=y({input:process.stdin,output:process.stderr});r.question(`${e} (Y/n) `,i=>{r.close();const n=i.trim().toLowerCase();t(n===""||n==="y"||n==="yes")})}),h=e=>{const t=d(e),r=_(t,{exact:!1,filter:[],global:!1,optional:!1,packages:[s],peer:!1,saveDev:!0,workspace:!1,workspaceRoot:!1},e,console);return Promise.resolve({exitCode:r})},R=()=>{try{return import.meta.resolve(s),!0}catch{return!1}},I=e=>{let t="pnpm";try{t=d(e).name}catch{}switch(t){case"bun":return`bun add -d ${s}`;case"npm":return`npm install -D ${s}`;case"yarn":return`yarn add -D ${s}`;default:return`pnpm add -D ${s}`}},D=()=>import("sigstore"),T=async(e={})=>{const t=e.interactive??$(),r=e.prompt??v,i=e.runInstall??h,n=e.importImpl??D,l=e.workspaceRoot??process.cwd(),a=I(l);try{return await n()}catch(p){const{code:u,message:f}=p;if(!(u==="ERR_MODULE_NOT_FOUND"||u==="MODULE_NOT_FOUND")||!f.includes(s))throw p}if(!t)throw new Error(`${s} is not installed. \`vis attest\` needs it for keyless signing/verification. Install it in your repo first:
2
+ ${a}`);if(!await r(`${s} isn't installed. Install it now?`))throw new Error(`${s} install declined. Re-run \`vis attest\` after installing manually:
3
+ ${a}`);const c=await i(l);if(c.exitCode!==0)throw new Error(`Install of ${s} failed (exit ${String(c.exitCode)}). Install manually and retry:
4
+ ${a}`);return await n()};export{I as installCommandFor,R as isSigstoreInstalled,T as loadOptionalSigstore};
@@ -0,0 +1 @@
1
+ import{H as r}from"../packem_shared/index-BDmTbWX1.js";import{createJiti as u}from"jiti";const a=(t,e)=>{if(!e||typeof e!="object")throw new TypeError(`${t}: default export must be an object (got ${e===null?"null":typeof e}). Use createTemplate({ ... }).`);const o=e;if(typeof o.about!="object"||o.about===null)throw new TypeError(`${t}: default export missing required "about" object`);if(typeof o.produce!="function")throw new TypeError(`${t}: default export missing required "produce" function`);return e},f=async t=>{const e=await u(r(t),{fsCache:!1,moduleCache:!1}).import(t,{default:!0,try:!0})??null;return a(t,e)};export{f as loadNativeTemplate};
@@ -0,0 +1,39 @@
1
+ import{createRequire as De}from"node:module";import{p as x}from"../packem_shared/index-CgcF6_wo.js";import{DEFAULT_CHANGES_DIR as q,DEFAULT_DEPENDENCY_BUMP_RULES as Oe,DEFAULT_CONFIG as Be}from"./DEFAULT_CLEAN_KEEP.js";import{VisReleaseError as R}from"../packem_shared/VisReleaseError-DMGRBTNO.js";import{e as Le,p as Te,c as xe}from"./registry.js";import{E as Ue}from"../packem_shared/public-api-WqUCiyIe.js";import{BUMP_LEVELS as le,maxBump as oe,bumpRank as Q,normaliseGroup as ge}from"../release/types.js";import Z from"./index.js";import{d as He,c as We}from"./detect.js";import{escapeMarkdown as Ye,assertValidPackageName as Je}from"./security.js";import{createShellRunner as J}from"./shell-runner.js";const Se=De(import.meta.url),W=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,pe=e=>{if(typeof W<"u"&&W.versions&&W.versions.node){const[a,t]=W.versions.node.split(".").map(Number);if(a>22||a===22&&t>=3||a===20&&t>=16)return W.getBuiltinModule(e)}return Se(e)},{readdir:Ve,readFile:Ee,writeFile:Fe,unlink:_e}=pe("node:fs/promises"),{resolve:X,sep:K,join:Ge}=pe("node:path"),{realpathSync:ze}=pe("node:fs"),qe=/^---\r?\n([\s\S]*?)\r?\n---\r?\n?([\s\S]*)$/,Xe=e=>{const a=qe.exec(e);return a?{body:(a[2]??"").trim(),frontmatter:a[1]??""}:null},Ke=/^(?:@[a-z0-9-]+\/)?[\w.-]+$/i,Qe=214,Ze=e=>e.length===0||e.length>Qe||e.startsWith(".")||e.startsWith("_")||e.startsWith("-")?!1:Ke.test(e),ie=e=>typeof e=="string"&&le.includes(e),ea=/^\s*(pr|commit|author)\s*:\s*(.+?)\s*$/i,aa=e=>{const a=e.split(/\r?\n/),t={};let n=0;for(const c of a){if(c.trim()===""){n+=1;continue}const d=ea.exec(c);if(!d)break;const[,l="",i=""]=d;switch(l.toLowerCase()){case"author":{t.author=i.startsWith("@")?i:`@${i}`;break}case"commit":{t.commit=i;break}case"pr":{const r=Number.parseInt(i,10);!Number.isNaN(r)&&r>0&&(t.pr=r);break}}n+=1}const s=a.slice(n).join(`
2
+ `).trim();return{meta:Object.keys(t).length>0?t:void 0,remainder:s}},me=e=>typeof e=="object"&&e!==null&&!Array.isArray(e)&&"bump"in e,ta=(e,a,t)=>{if(!ie(a.bump))throw new R({code:"BUMP_FILE_INVALID",file:t,message:`Invalid bump level for "${e}": ${JSON.stringify(a.bump)}. Expected one of: ${le.join(", ")}`,packageName:e});const n={bump:a.bump,package:e};if(a.releaseAs!==void 0){if(typeof a.releaseAs!="string"||!/^\d+\.\d+\.\d+(?:[-+].*)?$/.test(a.releaseAs))throw new R({code:"BUMP_FILE_INVALID",file:t,message:`Invalid releaseAs for "${e}": ${JSON.stringify(a.releaseAs)}. Expected a semver string like "2.0.0" or "2.0.0-rc.1".`,packageName:e});n.releaseAs=a.releaseAs}if(a.cascade!==void 0){if(typeof a.cascade!="object"||a.cascade===null||Array.isArray(a.cascade))throw new R({code:"BUMP_FILE_INVALID",file:t,message:`Cascade block for "${e}" must be an object mapping package globs to bump levels.`,packageName:e});const s={};for(const[c,d]of Object.entries(a.cascade)){if(!ie(d))throw new R({code:"BUMP_FILE_INVALID",file:t,message:`Invalid cascade bump level for "${c}": ${JSON.stringify(d)}.`,packageName:e});s[c]=d}n.cascade=s}return n},ne=e=>e.replaceAll(/^.*[/\\]/g,"").replace(/\.md$/i,""),na=(e,a)=>{const t=Xe(e);if(!t)throw new R({code:"BUMP_FILE_INVALID",file:a,message:"Change file is missing YAML frontmatter (expected `---` delimiters)."});let n;try{n=Ue(t.frontmatter,{schema:"core",strict:!0})}catch(i){throw new R({cause:i,code:"BUMP_FILE_INVALID",file:a,message:`YAML parse failed: ${i.message}`})}if(n==null)return{body:t.body.trim(),id:ne(a),path:a,payload:{bumps:{}}};if(typeof n!="object"||Array.isArray(n))throw new R({code:"BUMP_FILE_INVALID",file:a,message:"Frontmatter must be a YAML object mapping package names to bump levels."});const s=Object.entries(n);if(s.length===0)return{body:t.body.trim(),id:ne(a),path:a,payload:{bumps:{}}};for(const[i]of s)if(!Ze(i))throw new R({code:"BUMP_FILE_INVALID",file:a,message:`Invalid package name: ${JSON.stringify(i)}.`,packageName:i});let c;if(s.length===1&&me(s[0][1])){const[i,r]=s[0];c=ta(i,r,a)}else{const i={};for(const[r,m]of s){if(me(m))throw new R({code:"BUMP_FILE_INVALID",file:a,message:`Mixed simple + nested entries are not allowed. Package "${r}" uses the nested shape but the file has multiple top-level entries.`,packageName:r});if(!ie(m))throw new R({code:"BUMP_FILE_INVALID",file:a,message:`Invalid bump level for "${r}": ${JSON.stringify(m)}. Expected one of: ${le.join(", ")}`,packageName:r});i[r]=m}c={bumps:i}}const{meta:d,remainder:l}=aa(t.body);return{body:l,id:ne(a),meta:d,path:a,payload:c}},Ya=(e,a)=>{let t;if("bumps"in e){const n=Object.entries(e.bumps).map(([s,c])=>`${se(s)}: ${c}`);t=n.length>0?n.join(`
3
+ `):"{}"}else{const n=[`${se(e.package)}:`,` bump: ${e.bump}`];if(e.releaseAs&&n.push(` releaseAs: ${e.releaseAs}`),e.cascade){n.push(" cascade:");for(const[s,c]of Object.entries(e.cascade))n.push(` ${se(s)}: ${c}`)}t=n.join(`
4
+ `)}return`---
5
+ ${t}
6
+ ---
7
+ ${a.trim()===""?"":`${a.trim()}
8
+ `}`},se=e=>/^[a-z0-9-]/.test(e)?e:`"${e}"`,sa=e=>{const a=new Map,t=s=>s==="major"?3:s==="minor"?2:s==="patch"?1:0,n=(s,c)=>{const d=a.get(s);(d===void 0||t(c)>t(d))&&a.set(s,c)};for(const s of e)if("bumps"in s.payload)for(const[c,d]of Object.entries(s.payload.bumps))n(c,d);else n(s.payload.package,s.payload.bump);return a},ue=(e,a)=>a.filter(t=>"bumps"in t.payload?Object.hasOwn(t.payload.bumps,e):t.payload.package===e),ra=new Set(["README.md","readme.md"]),oa=async e=>{const a=e.changesDir??q,t=X(e.cwd),n=X(e.cwd,a),s=n,c=t.endsWith(K)?t:`${t}${K}`;if(n!==t&&!n.startsWith(c))throw new R({code:"CONFIG_INVALID",message:`changesDir resolves outside the workspace: ${n} (workspace: ${t}). Set release.changesDir to a path inside the repo.`});const d=[];let l;try{l=await Ve(s)}catch(r){if(r.code==="ENOENT")return{files:[],warnings:[]};throw new R({cause:r,code:"CONFIG_INVALID",message:`Cannot read change-files directory ${s}: ${r.message}`})}const i=l.filter(r=>!ra.has(r)&&r.endsWith(".md"));return{files:await Promise.all(i.map(async r=>{const m=Ge(s,r),o=await Ee(m,"utf8");return na(o,m)})),warnings:d}},ia=(e,a)=>{if(!a)return;if(Object.hasOwn(a,e)){const n=Object.keys(a).filter(s=>s!==e&&he(s)&&Z(s,e));return fe(e,a[e],n)}const t=[];for(const[n]of Object.entries(a))he(n)&&Z(n,e)&&t.push(n);if(t.length>0){const[n,...s]=t;return fe(e,a[n],s)}},fe=(e,a,t=[])=>{let{tag:n}=a;return n==="branch-name"&&(n=ca(e)),{branch:e,mode:a.mode??"auto-publish",...t.length>0?{overlapping:t}:{},prerelease:a.prerelease,range:a.range,tag:n}},ca=e=>e.toLowerCase().replaceAll(/[^a-z0-9.-]/g,"-").replaceAll(/^-+|-+$/g,"")||"branch",pa=/[!()*+?@[\]{|}]/,he=e=>pa.test(e),la=async(e,a)=>{try{const t=await a.run("git",["rev-parse","--abbrev-ref","HEAD"],{cwd:e,silent:!0});if(t.exitCode!==0)return;const n=t.stdout.trim();return n==="HEAD"||n===""?void 0:n}catch{return}},da=["dependencies","devDependencies","peerDependencies","optionalDependencies"];class ga{dependents;dependenciesByPackage;packagesByName;constructor(a){this.dependents=new Map,this.dependenciesByPackage=new Map,this.packagesByName=new Map;for(const t of a){if(this.packagesByName.has(t.name))throw new R({code:"DUPLICATE_PACKAGE_NAME",message:`Duplicate package name "${t.name}" — found at ${this.packagesByName.get(t.name).dir} and ${t.dir}.`,packageName:t.name});this.packagesByName.set(t.name,t),this.dependents.set(t.name,[]),this.dependenciesByPackage.set(t.name,[])}for(const t of a)for(const n of da){const s=t.manifest[n];if(!(!s||typeof s!="object"))for(const[c,d]of Object.entries(s))this.packagesByName.has(c)&&(this.dependents.get(c).push({kind:n,name:t.name,range:d}),this.dependenciesByPackage.get(t.name).push({kind:n,name:c,range:d}))}}getPackage(a){return this.packagesByName.get(a)}allPackages(){return[...this.packagesByName.values()]}isInternal(a){return this.packagesByName.has(a)}getDependents(a){return this.dependents.get(a)??[]}getDependencies(a){return this.dependenciesByPackage.get(a)??[]}topologicalSort(a){const t=a?new Set(a):new Set(this.packagesByName.keys()),n=new Set,s=new Set,c=[],d=(l,i)=>{if(!n.has(l)){if(s.has(l)){const r=i.indexOf(l),m=r===-1?[...i,l]:[...i.slice(r),l];throw new R({code:"CYCLIC_DEPENDENCY",message:`Cyclic dependency detected: ${m.join(" → ")}`})}s.add(l);for(const r of this.getDependencies(l))t.has(r.name)&&r.kind!=="devDependencies"&&d(r.name,[...i,l]);s.delete(l),n.add(l),c.push(l)}};for(const l of t)d(l,[]);return c}get size(){return this.packagesByName.size}}const ma=/\{(name|version|previousVersion|date|repo|contributors)\}/g,ua=(e,a)=>e.replaceAll(ma,(t,n)=>a[n]??""),fa=(e,a={})=>{const t=new Set;for(const c of a.internalAuthors??[]){const d=c.trim().toLowerCase().replace(/^@/,"");d.length>0&&t.add(d)}const n=new Set,s=[];for(const c of e){const d=c.meta?.author;if(d)for(const l of d.split(",")){const i=l.trim();if(!i)continue;const r=i.replace(/^@/,"");if(r.length===0)continue;const m=r.toLowerCase();n.has(m)||t.has(m)||(n.add(m),s.push(Ye(i)))}}return s.length===0?"":s.map(c=>`- ${c}`).join(`
9
+ `)},ee=e=>{const{current:a,prerelease:t}=e;let{bump:n}=e;if(!x.valid(a))throw new R({code:"CONFIG_INVALID",message:`Invalid current version: ${JSON.stringify(a)}`});const s=x.parse(a),c=s.prerelease[0],d=s.prerelease.length>0;if(s.major===0&&e.bumpMinorPreMajor&&(n==="major"&&(n="minor"),n==="minor"&&e.bumpPatchForMinorPreMajor&&(n="patch")),n==="none")return(c??void 0)===(t??void 0)?a:!d&&t?`${s.major}.${s.minor}.${s.patch}-${t}.0`:d&&!t?`${s.major}.${s.minor}.${s.patch}`:d&&t?`${s.major}.${s.minor}.${s.patch}-${t}.0`:a;if(d&&t&&c===t){const i=ha(s);if(we[n]<=we[i]){const o=x.inc(a,"prerelease",t);if(!o)throw new R({code:"CONFIG_INVALID",message:`semver.inc returned null for prerelease bump on ${a}`});return o}const r=`${s.major}.${s.minor}.${s.patch}`,m=x.inc(r,n);if(!m)throw new R({code:"CONFIG_INVALID",message:`semver.inc returned null for ${n} bump on ${r}`});return`${m}-${t}.0`}if(t){const i=`${s.major}.${s.minor}.${s.patch}`,r=x.inc(i,n);if(!r)throw new R({code:"CONFIG_INVALID",message:`semver.inc returned null for ${n} bump on ${i}`});return`${r}-${t}.0`}if(d){const i=`${s.major}.${s.minor}.${s.patch}`,r=x.inc(i,n);if(!r)throw new R({code:"CONFIG_INVALID",message:`semver.inc returned null for ${n} bump on ${i}`});return r}const l=x.inc(a,n);if(!l)throw new R({code:"CONFIG_INVALID",message:`semver.inc returned null for ${n} bump on ${a}`});return l},we={major:3,minor:2,patch:1},ha=e=>e.minor===0&&e.patch===0?"major":e.patch===0?"minor":"patch",wa=(e,a)=>{const t=ke(a);return t?x.satisfies(e,t,{includePrerelease:!0}):!0},ke=e=>{if(!e||e.startsWith("catalog:")||e==="*"||e==="workspace:*"||e==="workspace:^"||e==="workspace:~")return null;if(e.startsWith("workspace:")){const a=e.slice(10);return a==="*"||a==="^"||a==="~"?null:a}if(e.startsWith("npm:")){const a=e.lastIndexOf("@");return a>4?e.slice(a+1):null}return e},re=100,G=(e,a,t,n,{isCascadeBump:s=!1,isDependencyBump:c=!1,isGroupBump:d=!1,source:l}={})=>{const i=e.get(a);if(i){const r=i.type;return i.type=oe(i.type,t),i.reasons.add(n),c&&(i.isDependencyBump=!0),d&&(i.isGroupBump=!0),s&&(i.isCascadeBump=!0),l&&i.sources.set(l.name,{bumpType:l.bumpType,newVersion:l.newVersion}),i.type!==r}return e.set(a,{isCascadeBump:s,isDependencyBump:c,isGroupBump:d,name:a,proactiveSeen:!1,reasons:new Set([n]),sources:l?new Map([[l.name,{bumpType:l.bumpType,newVersion:l.newVersion}]]):new Map,type:t}),!0},ya=(e,a,t,n)=>{const s=t?.get(e)?.dependencyBumpRules?.[a];if(s!==void 0)return s;const c=n.dependencyBumpRules?.[a];return c!==void 0?c:Oe[a]??!1},ye=(e,a)=>Q(e)>=Q(a),be=(e,a)=>a==="match"?e:a,ba=(e,a)=>a===!0?!0:Array.isArray(a)?a.includes(e):!1,$a=10,va=(e,a,t,n,s,c,d)=>{let l=!1;for(const i of e.values()){const r=a.getPackage(i.name);if(!r)continue;const m=n.currentVersions?.get(i.name)??r.version,o=t.get(i.name)??ee({bump:i.type,bumpMinorPreMajor:n.bumpMinorPreMajor,bumpPatchForMinorPreMajor:n.bumpPatchForMinorPreMajor,current:m,prerelease:n.prerelease});t.set(i.name,o);for(const p of a.getDependents(i.name)){if(p.kind==="devDependencies"){if(!ba(i.name,c.bumpDevDependencies))continue;if(G(e,p.name,"patch","DEVDEPENDENCY_BUMPED",{isDependencyBump:!0,source:{bumpType:i.type,name:i.name,newVersion:o}})&&(l=!0,t.delete(p.name)),c.bumpDevDependencies===!0){let w=d.get(i.name);w||(w=new Set,d.set(i.name,w)),w.add(p.name)}continue}const h=ke(p.range);if(h===null||wa(o,h))continue;let u,k="DEPENDENCY_OUT_OF_RANGE";p.kind==="peerDependencies"?(u=i.type==="none"?"patch":i.type,k="PEER_DEP_MATCH",h.startsWith("^0.")&&u!=="patch"&&s.push(`^0.x peer dep "${i.name}" → "${p.name}" produced a ${u} bump. Consider widening the range manually.`)):u="patch",G(e,p.name,u,k,{isDependencyBump:!0,source:{bumpType:i.type,name:i.name,newVersion:o}})&&(l=!0,t.delete(p.name))}}return l},ka=(e,a,t)=>{let n=!1;for(const s of t.fixed??[]){const c=ge(s),d=ae(c.packages,a),l=d.filter(r=>e.has(r));if(l.length===0)continue;let i="none";for(const r of l)i=oe(i,e.get(r).type);for(const r of d)a.isInternal(r)&&G(e,r,i,"FIXED_GROUP",{isGroupBump:!0})&&(n=!0)}for(const s of t.linked??[]){const c=ge(s),d=ae(c.packages,a).filter(i=>e.has(i));if(d.length===0)continue;let l="none";for(const i of d)l=oe(l,e.get(i).type);for(const i of d)G(e,i,l,"LINKED_GROUP",{isGroupBump:!0})&&(n=!0)}return n},$e=new WeakMap,Pa=/[!()*+?@[\]{|}]/,ae=(e,a)=>{let t=$e.get(a);t||(t={allNames:a.allPackages().map(s=>s.name),matched:new Map},$e.set(a,t));const n=new Set;for(const s of e){if(!Pa.test(s)){n.add(s);continue}let c=t.matched.get(s);c||(c=t.allNames.filter(d=>Z(s,d)),t.matched.set(s,c));for(const d of c)n.add(d)}return[...n]},Ca=(e,a,t,n,s,c)=>{let d=!1;const l=n.updateInternalDependencies??"out-of-range",i=r=>{const m=c.get(r.name);if(m!==void 0)return m;const o=ee({bump:r.type,bumpMinorPreMajor:s.bumpMinorPreMajor,bumpPatchForMinorPreMajor:s.bumpPatchForMinorPreMajor,current:s.currentVersions?.get(r.name)??t.getPackage(r.name).version,prerelease:s.prerelease});return c.set(r.name,o),o};for(const r of a){if("bumps"in r.payload||!r.payload.cascade)continue;const m=e.get(r.payload.package);if(!m)continue;const o=c.get(m.name)??ee({bump:m.type,bumpMinorPreMajor:s.bumpMinorPreMajor,bumpPatchForMinorPreMajor:s.bumpPatchForMinorPreMajor,current:s.currentVersions?.get(m.name)??t.getPackage(m.name).version,prerelease:s.prerelease});c.set(m.name,o);for(const[p,h]of Object.entries(r.payload.cascade))for(const u of ae([p],t))t.isInternal(u)&&G(e,u,h,"CASCADE",{isCascadeBump:!0,source:{bumpType:m.type,name:m.name,newVersion:o}})&&(d=!0)}for(const r of e.values()){const m=s.perPackageConfig?.get(r.name)?.cascadeTo;if(m)for(const[o,p]of Object.entries(m)){if(!ye(r.type,p.trigger))continue;const h=be(r.type,p.bumpAs),u=i(r);for(const k of ae([o],t))t.isInternal(k)&&G(e,k,h,"CASCADE_TO",{isCascadeBump:!0,source:{bumpType:r.type,name:r.name,newVersion:u}})&&(d=!0)}}if(l==="out-of-range")return d;for(const r of e.values())if(!r.proactiveSeen&&!(l==="minor"&&Q(r.type)<Q("minor"))){for(const m of t.getDependents(r.name)){const o=ya(m.name,m.kind,s.perPackageConfig,n);if(o===!1||!ye(r.type,o.trigger))continue;const p=be(r.type,o.bumpAs);if(p==="none")continue;const h=i(r);G(e,m.name,p,"DEPENDENCY_BUMPED",{isDependencyBump:!0,source:{bumpType:r.type,name:r.name,newVersion:h}})&&(d=!0)}r.proactiveSeen=!0}return d},Na=(e,a,t,n={})=>{const s=new Map,c=[],d=new Map;for(const[o,p]of sa(e).entries()){if(!a.isInternal(o)){c.push(`Change file references non-workspace package "${o}" — ignored.`);continue}p!=="none"&&G(s,o,p,"EXPLICIT")}for(const o of n.catalogConsumers??[]){if(!a.isInternal(o.packageName))continue;const p=`catalog:${o.catalog}/${o.dep}`;G(s,o.packageName,"patch","CATALOG_CHANGED",{isDependencyBump:!0,source:{bumpType:"patch",name:p,newVersion:o.newVersion??""}})}const l=new Map,i=o=>{const p=ue(o,e).map(u=>"releaseAs"in u.payload?{file:u.path,version:u.payload.releaseAs}:void 0).filter(u=>u!==void 0&&typeof u.version=="string"),h=new Set(p.map(u=>u.version));if(h.size>1)throw new R({code:"BUMP_FILE_INVALID",message:`Conflicting releaseAs values for ${o}: ${[...h].join(", ")}. Found in: ${p.map(u=>u.file).join(", ")}. Consolidate the change files to a single override.`,packageName:o});return p[0]?.version},r=new Map;for(const o of s.values()){if(o.type==="none")continue;const p=i(o.name);p&&(r.set(o.name,p),d.set(o.name,p))}for(let o=0;o<re;o+=1){const p=va(s,a,d,n,c,t,l),h=ka(s,a,t),u=Ca(s,e,a,t,n,d);if(!p&&!h&&!u)break;o===re-1&&c.push(`Release plan did not converge after ${re} iterations — releasing the current best plan. This usually indicates a config bug (cyclic cascade?).`)}for(const[o,p]of l){const h=p.size;h>$a&&c.push(`bumpDevDependencies: true triggered ${h} patch-cascades to distinct dependents from a single devdep bump (${o}). Consider scoping with the array form ['only', 'these', 'sources'].`)}const m=[];for(const o of s.values()){if(o.type==="none")continue;const p=a.getPackage(o.name);if(!p)continue;const h=ue(o.name,e),u=r.get(o.name),k=n.currentVersions?.get(o.name)??p.version,w=u??d.get(o.name)??ee({bump:o.type,bumpMinorPreMajor:n.bumpMinorPreMajor,bumpPatchForMinorPreMajor:n.bumpPatchForMinorPreMajor,current:k,prerelease:n.prerelease});m.push({changeFiles:h,isCascadeBump:o.isCascadeBump,isDependencyBump:o.isDependencyBump,isGroupBump:o.isGroupBump,name:o.name,newVersion:w,oldVersion:k,reasons:[...o.reasons],sources:[...o.sources.entries()].map(([$,b])=>({name:$,...b})),type:o.type})}return m.sort((o,p)=>o.name.localeCompare(p.name)),{consumedChangeFiles:e,releases:m,warnings:c}},Pe=async(e,a,t={})=>{const n=await e.listPackages(),s=[],c=new Map,d=new Map,l=o=>{try{return ze(X(o))}catch{return X(o)}},i=t.cwd===void 0?void 0:l(t.cwd),r=o=>o.replaceAll("\\","/"),m=[];for(const{manifest:o,manifestPath:p}of n){const h=ce(typeof o.name=="string"?o.name:"",o,a);if(o.napi!==void 0||h.versionActions==="native-addon"){const u=r(p.replace(/[/\\]package\.json$/i,""));m.push(`${u}/npm/`)}}for(const{manifest:o,manifestPath:p}of n){if(typeof o.name!="string"||o.name==="")continue;const h=r(p.replace(/[/\\]package\.json$/i,""));if(m.some(w=>h.startsWith(w)))continue;if(Je(o.name),d.has(o.name))throw new R({code:"DUPLICATE_PACKAGE_NAME",message:`Duplicate package name "${o.name}" — at ${d.get(o.name)} and ${p}.`,packageName:o.name});if(d.set(o.name,p),i!==void 0){const w=l(p),$=i.endsWith(K)?i:`${i}${K}`;if(w!==i&&!w.startsWith($))throw new R({code:"CONFIG_INVALID",message:`Package manifest is outside the workspace: ${p} (workspace: ${i}).`,packageName:o.name})}const u=ce(o.name,o,a);if(!Ce(o.name,o,u,a))continue;const k=p.replace(/[/\\]package\.json$/i,"");s.push({dir:k,manifest:o,manifestPath:p,name:o.name,private:o.private===!0,version:typeof o.version=="string"?o.version:"0.0.0"}),c.set(o.name,u)}return{packages:s,perPackageConfig:c}},ce=(e,a,t)=>{const n=t.packages?.[e]??{},s=a["vis-release"]??{};return{...n,...s}},Ce=(e,a,t,n)=>t.managed===!1?!1:t.managed===!0?!0:ve(e,n.ignore??[])?!1:ve(e,n.include??[])?!0:a.private===!0&&!(n.privatePackages?.version??!1)?!1:n.defaultManaged??!1,ve=(e,a)=>a.some(t=>Z(t,e)),Ne=(e,a)=>a.versionActions!==void 0?a.versionActions:e.manifest.napi!==void 0?"native-addon":e.private?"private":"npm",Ja=Object.defineProperty({__proto__:null,discoverPackages:Pe,isPackageManaged:Ce,mergePerPackageConfig:ce,resolveVersionActionsId:Ne},Symbol.toStringTag,{value:"Module"}),za=async(e={})=>{const a=e.cwd??process.cwd(),t=J(),n=await He(a),s=We(n,t),c=await s.detectVersion(a);if(c&&!Ia(c,s.minVersion))throw new R({code:"PM_VERSION_TOO_LOW",hint:`pnpm install -g ${s.id}@latest (or your equivalent)`,message:`${s.id} version ${c} is below the required minimum ${s.minVersion}. Upgrade ${s.id} to enable release operations.`});let d={};try{const{loadVisConfig:A}=await import("../packem_shared/CONFIG_FILES-BfaR0jKT.js"),C=await A(a);C.release&&(d=C.release)}catch(A){const{code:C}=A,g=A.message??"";if(!(C==="ENOENT"||C==="MODULE_NOT_FOUND"||/cannot find module/i.test(g)))throw A}const l=Aa(d,e.config??{});!l.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 i=e.channel??await la(a,t),r=i?ia(i,l.channels):void 0,m=await import("node:fs/promises"),o={listPackages:async()=>{const A=await s.listWorkspacePackages(a);return(await Promise.all(A.map(async C=>{const g=`${C.path}/package.json`;try{const y=await m.readFile(g,"utf8");return{manifest:JSON.parse(y),manifestPath:g}}catch{return}}))).filter(C=>C!==void 0)}},{packages:p,perPackageConfig:h}=await Pe(o,l,{cwd:a}),u=new ga(p),{files:k}=await oa({changesDir:l.changesDir,cwd:a}),{readPreMode:w}=await import("./pre-mode.js"),$=await w(a,l.changesDir??".vis/release");let b;$?.mode==="pre"?b=$.tag:$?.mode==="exit-pending"?b=void 0:b=r?.prerelease;const P=e.firstRelease===!0,{resolveCurrentVersionsForWorkspace:v}=await import("./version-resolver.js"),{versions:L,warnings:V}=await v(p,u,l,h,{cwd:a,firstRelease:P,pm:s,runner:t,skipRegistryLookup:e.skipRegistryLookup===!0}),T=[],N=[];if(l.detectCatalogChanges===!0)try{const{detectCatalogChanges:A,findCatalogConsumers:C,parseCatalogs:g}=await import("./catalog-detector.js"),y=await s.readCatalogYaml(a),j=g(y);let B;try{const _=await t.run("git",["show","HEAD~1:pnpm-workspace.yaml"],{cwd:a,silent:!0});_.exitCode===0&&(B=_.stdout)}catch{}const S=g(B),D=A(S,j).filter(_=>_.oldVersion!==void 0&&_.newVersion!==void 0);if(D.length>0){const _=C(p,j);for(const M of D){const I=_.get(M.catalog)?.get(M.dep)??[];for(const f of I)T.push({catalog:M.catalog,dep:M.dep,newVersion:M.newVersion,oldVersion:M.oldVersion,packageName:f.packageName})}T.length>0&&N.push(`Catalog change-detection: ${D.length} catalog dep(s) moved; ${T.length} consumer-package patch bump(s) tagged CATALOG_CHANGED.`)}}catch(A){N.push(`Catalog change-detection skipped: ${A.message}.`)}const E=Na(k,u,l,{bumpMinorPreMajor:l.bumpMinorPreMajor,bumpPatchForMinorPreMajor:l.bumpPatchForMinorPreMajor,catalogConsumers:T,currentVersions:L,perPackageConfig:h,prerelease:b});if(N.length>0&&E.warnings.push(...N),V.length>0&&E.warnings.push(...V),P&&E.warnings.push('First-release mode: currentVersionResolver forced to "disk", remote tag-collision checks skipped. Drop --first-release after the initial wave lands.'),$?.mode==="pre"&&E.warnings.push(`Pre-mode is ACTIVE (tag "${$.tag}"); every version produces a prerelease. Exit with \`vis release pre exit\` when ready to ship stable.`),$?.mode==="exit-pending"&&E.warnings.push(`Pre-mode is EXIT-PENDING (was "${$.tag}"); the next \`vis release version\` will consolidate the prerelease and delete pre.json.`),r?.overlapping&&r.overlapping.length>0&&E.warnings.push(`Branch "${i}" matches multiple channel patterns: "${r.branch}" (active) plus ${r.overlapping.map(A=>`"${A}"`).join(", ")}. Reorder channels in vis.config.ts if this is unintentional.`),e.projects&&e.projects.length>0){const{default:A}=await import("./index.js"),C=e.projects;E.releases=E.releases.filter(g=>C.some(y=>g.name===y||A(y,g.name)))}return{branch:i,channel:r?{mode:r.mode,prerelease:r.prerelease,tag:r.tag}:void 0,config:l,cwd:a,depGraph:u,firstRelease:P,packages:p,perPackageConfig:h,plan:E,pm:s,preMode:$}},Aa=(...e)=>{let a={...Be};for(const t of e)a={...a,...t};return a},Ia=(e,a)=>{const t=x.coerce(e)?.version??e;try{return x.gte(t,a)}catch{return!0}},Y=async(e,a,t)=>{if(!a||a.trim()==="")return;const n=J(),s=process.platform==="win32",c=s?"cmd":"sh",d=s?["/c",a]:["-c",a],l=await n.run(c,d,{cwd:e,silent:!1});if(l.exitCode!==0)throw new Error(`${t} failed (exit ${l.exitCode}): ${a}`)},Ae=async(e,a,t,n={})=>{const{findConflictingPendingStages:s,readStagedRegistry:c,removePendingStages:d,writeStagedRegistry:l}=await import("./staged-registry.js"),i=e.config.changesDir??q;let r=t??await c(e.cwd,i);if(r.pending.length===0)return;const m=new Map(e.plan.releases.map(w=>[w.name,w.newVersion])),o=[...m.keys()];let p=s(r,o).filter(w=>m.get(w.name)!==w.version);if(p.length===0)return;let h=[];if(!n.skipSelfHeal){const w=n.runner??J();h=(await Promise.all(p.map(async $=>{const b=await w.run("npm",["view",`${$.name}@${$.version}`,"dist.tarball","--silent"],{cwd:e.cwd,silent:!0});return b.exitCode===0&&b.stdout.trim().length>0?$.id:void 0}))).filter($=>$!==void 0)}if(h.length>0){if(r=d(r,h),n.persistSelfHeal!==!1)try{await l(e.cwd,i,r)}catch{}if(p=s(r,o).filter(w=>m.get(w.name)!==w.version),p.length===0)return}const u=p.map(w=>` • ${w.name}@${w.version} — stage ${w.id} (${w.reason}, recorded ${w.stagedAt})`).join(`
10
+ `),k=a==="version"?"version":"publish";throw new R({code:"STAGE_PENDING",hint:"Resolve via `vis release stage approve <id>` / `--all` or `vis release stage reject <id>`, commit the updated staged.json, then retry.",message:`Refusing to ${k} — ${p.length} package(s) have a pending stage from a prior wave:
11
+ ${u}`})},qa=async(e,a={})=>{if(e.plan.releases.length===0)return{changedFiles:[],deletedFiles:[],plan:e.plan};if(await Ae(e,"version",void 0,{persistSelfHeal:!1}),!a.dryRun&&e.config.preVersionCommand&&await Y(e.cwd,e.config.preVersionCommand,"preVersionCommand"),!a.dryRun&&e.config.groupPreVersionCommands){const{normaliseGroup:p}=await import("../release/types.js"),h=[...e.config.fixed??[],...e.config.linked??[]].map(k=>p(k)),{default:u}=await import("./index.js");for(const[k,w]of Object.entries(e.config.groupPreVersionCommands)){const $=Number.parseInt(k.replace(/^group-/,""),10),b=h[$];!b||!e.plan.releases.some(P=>b.packages.some(v=>P.name===v||u(v,P.name)))||await Y(e.cwd,w,`groupPreVersionCommand[${k}]`)}}const t=await import("node:fs/promises"),{readFileSync:n}=await import("node:fs"),{resolveFormatter:s}=await import("./resolveFormatter.js"),{resolveGroupChangelogRouting:c}=await import("./workspace.js"),d=await s(e.config.changelog,e.cwd),l=new Date().toISOString().slice(0,10),i=c(e.config,e.packages,e.cwd),r=await Le(e.plan,e.depGraph,{changelogPath:p=>i.get(p.name)??`${p.dir}/CHANGELOG.md`,readChangelog:p=>{try{return n(p,"utf8")}catch{return}},readManifest:p=>{try{return n(p,"utf8")}catch{return}},renderChangelogEntry:p=>d({changeFiles:p.changeFiles,date:l,release:p,target:"changelog"})}),m=[];{const{applyExtraFilesForRelease:p}=await import("./extra-files.js"),h=await Promise.all(e.plan.releases.map(async u=>{const k=e.depGraph.getPackage(u.name);if(!k)return{warnings:[],writes:[]};const w=e.perPackageConfig.get(u.name)?.extraFiles??[],$=e.config.publish?.extraFiles??[];return w.length===0&&$.length===0?{warnings:[],writes:[]}:p(e.cwd,k.dir,u.newVersion,u.name,$,w)}));for(const u of h){for(const k of u.writes)r.writes.push({content:k.content,path:k.path});m.push(...u.warnings)}m.length>0&&e.plan.warnings.push(...m)}if(a.dryRun)return{changedFiles:r.writes.map(p=>p.path),deletedFiles:r.deletions,plan:e.plan};await Promise.all([...r.writes.map(p=>Fe(p.path,p.content)),...r.deletions.map(async p=>{try{await _e(p)}catch{}})]);try{await e.pm.installLockfileOnly({cwd:e.cwd,silent:!0})}catch{}!a.dryRun&&e.config.formatChangedFiles&&await Ra(r.writes.map(p=>p.path),e.cwd);let o;if(a.commit){const{stageAndCommit:p}=await import("./git.js"),h=J(),u=["pnpm-lock.yaml","package-lock.json","yarn.lock","bun.lock","bun.lockb"],k=await import("node:path"),w=[];for(const b of u)try{await t.access(k.join(e.cwd,b)),w.push(k.join(e.cwd,b))}catch{}const $=e.config.aggregateRelease===!0||typeof e.config.aggregateRelease=="object"&&e.config.aggregateRelease.enabled;if(e.config.oneCommitPerPackage===!0&&!$&&e.plan.releases.length>0){const b=e.channel?.tag??e.branch??"main",P=r.writes.map(V=>V.path),v=new Set,{releases:L}=e.plan;for(let V=0;V<L.length;V+=1){const T=L[V],N=e.depGraph.getPackage(T.name),E=N?`${N.dir}${k.sep}`:void 0,A=E?P.filter(y=>y.startsWith(E)):[];for(const y of A)v.add(y);const C=V===L.length-1?[...P.filter(y=>!v.has(y)),...r.deletions,...w]:[],g=[...A,...C];g.length!==0&&(o=await p({cwd:e.cwd,runner:h},g,`release(${b}): ${T.name}@${T.newVersion} [skip ci]`,{author:e.config.gitUser}))}}else{const b=a.commitMessage??ja(e),P=[...r.writes.map(v=>v.path),...r.deletions,...w];o=await p({cwd:e.cwd,runner:h},P,b,{author:e.config.gitUser})}}if(!a.dryRun&&e.config.postVersionCommand&&await Y(e.cwd,e.config.postVersionCommand,"postVersionCommand"),!a.dryRun&&e.preMode?.mode==="exit-pending"){const{deletePreMode:p,preModeFilePath:h}=await import("./pre-mode.js"),u=e.config.changesDir??".vis/release";await p(e.cwd,u)&&e.plan.warnings.push(`Pre-mode exited: \`${h(e.cwd,u)}\` was deleted. Commit the deletion so the registry stays consistent across CI runs.`)}return{changedFiles:r.writes.map(p=>p.path),commitSha:o,deletedFiles:r.deletions,plan:e.plan}},Ra=async(e,a)=>{if(e.length===0)return;const{join:t}=await import("node:path");let n;try{const{createRequire:c}=await import("node:module"),{pathToFileURL:d}=await import("node:url"),l=c(t(a,"package.json"));n=await import(d(l.resolve("prettier")).href)}catch{return}const s=await import("node:fs/promises");for(const c of e)try{const d=await n.getFileInfo(c);if(d.ignored||!d.inferredParser)continue;const l=await s.readFile(c,"utf8"),i=await n.resolveConfig(c),r=await n.format(l,{...i,filepath:c});r!==l&&await s.writeFile(c,r)}catch{}},ja=e=>{const a=e.channel?.tag??e.branch??"main",{releases:t}=e.plan,n=t.length<=3?t.map(c=>`${c.name}@${c.newVersion}`).join(", "):`version ${t.length} packages`,s=t.map(c=>`- ${c.name}: ${c.oldVersion} → ${c.newVersion}`).join(`
12
+ `);return`release(${a}): ${n} [skip ci]
13
+
14
+ ${s}`},Xa=async(e,a={})=>{const t={failed:[],published:[],skipped:[],tags:[],tagsPushed:!1},n=J();if(e.plan.releases.length===0)return t;if(!a.dryRun&&e.channel?.mode==="version-pr"){const{createRemoteClient:i,detectRemoteProvider:r}=await import("./detect2.js"),m=await r(e.cwd,n,e.config.provider),o=await i(m,{githubHost:e.config.githubHost,gitlabHost:e.config.gitlabHost,httpProxy:e.config.httpProxy}).detectRepoSlug(e.cwd,n),p=e.config.versionPr?.branch??"vis-release/version-packages";if(o)try{const h=await n.run("gh",["pr","list","--head",p,"--state","open","--json","number"],{cwd:e.cwd,silent:!0});if(h.exitCode===0&&h.stdout.trim()&&h.stdout.trim()!=="[]"){const u=JSON.parse(h.stdout);if(u[0])return t.failed.push({name:"_preflight",reason:`Open release PR #${u[0].number} exists. Merge or close it before publishing locally. (Override: --no-push then \`git push --tags\` manually.)`}),t}}catch{}}if(!a.dryRun&&e.config.prePublishCommand)try{await Y(e.cwd,e.config.prePublishCommand,"prePublishCommand")}catch(i){return t.failed.push({name:"_prePublishCommand",reason:i.message}),t}const s=e.config.changesDir??q,{acquireLock:c,releaseLock:d}=await import("./state.js");let l=!1;if(!a.dryRun)try{await c(e.cwd,s),l=!0}catch(i){return t.failed.push({name:"_lock",reason:i.message}),t}try{const{clearState:i,filterPlanByState:r,newState:m,readState:o,writeState:p}=await import("./state.js"),{readStagedRegistry:h,removePendingStages:u,upsertPendingStages:k,writeStagedRegistry:w}=await import("./staged-registry.js"),$=e.config.changesDir??q;let b=a.resume?await o(e.cwd,$):void 0,P=await h(e.cwd,$);await Ae(e,"publish",P,{runner:n}),P=await h(e.cwd,$);const v={pending:[...P.pending]};let{releases:L}=e.plan;b?L=r(L,b):(b=m(e.channel?.tag,e.plan.releases),a.dryRun||await p(e.cwd,$,b));const V=await e.pm.readCatalogYaml(e.cwd),T=Te(V),N=e.depGraph.topologicalSort(L.map(g=>g.name)),E=new Map(L.map(g=>[g.name,g])),A=new Set,C=new Map;for(const g of e.plan.releases){const y=e.depGraph.getPackage(g.name);y&&C.set(g.name,{...y.manifest,version:g.newVersion})}for(const g of N){const y=E.get(g);if(!y){t.skipped.push({name:g,reason:"topo-sort returned a name not in the release plan (internal bug)"});continue}const j=e.depGraph.getPackage(g);if(!j)continue;const B=[...new Set(e.depGraph.getDependencies(g).filter(f=>f.kind!=="devDependencies"&&A.has(f.name)).map(f=>f.name))];if(B.length>0){t.skipped.push({name:g,reason:`dependency-failed: not published because ${B.join(", ")} failed to publish (publishing would orphan this package's dependency range)`}),A.add(g);continue}const S=e.perPackageConfig.get(g)??{},D=Ne(j,S),_=a.publishActionsOverride??xe(D),M=a.tag??e.channel?.tag,I=P.pending.find(f=>f.name===g&&f.version===y.newVersion);try{const f=await _.publish({catalogs:T,cleanPackageJsonConfig:e.config.publish?.cleanPackageJson,dryRun:a.dryRun,otp:a.otp,perPackageConfig:S,pkg:j,pm:e.pm,provenance:Ea(e),registry:S.registry,release:y,resumeStageId:I?.id,tag:M,versionedManifestByName:C,workspaceConfig:e.config});if(f.published||f.alreadyPublished){const O=P.pending.filter(F=>F.name===g&&F.version===y.newVersion).map(F=>F.id);O.length>0&&(P=u(P,O))}if(f.published)t.published.push({name:g,stageId:f.stageId,tarball:f.tarball,version:y.newVersion}),b.published.push(`${g}@${y.newVersion}`);else if(f.alreadyPublished)t.skipped.push({name:g,reason:"already-published"}),b.published.push(`${g}@${y.newVersion}`);else if(t.skipped.push({name:g,reason:f.output??"skipped"}),f.stageId){const O=(f.output??"").startsWith("stage-rejected")?"rejected":"timeout";P=k(P,[{id:f.stageId,name:g,reason:O,stagedAt:new Date().toISOString(),tag:M??"latest",version:y.newVersion}])}a.dryRun||await p(e.cwd,$,b)}catch(f){t.failed.push({name:g,reason:f.message}),A.add(g)}}if(!a.dryRun&&!a.noTag&&t.published.length>0){const{createOrUpdateFloatingTag:g,createTag:y,defaultTagFor:j,pushTags:B,renderTagPattern:S}=await import("./git.js"),D=e.config.releaseTagPattern,_=e.channel?.tag,M=e.config.floatingMajorTag===!0,I=!!e.channel?.prerelease||!!e.preMode;for(const{name:f,version:O}of t.published){const F=e.perPackageConfig.get(f)?.releaseTagPattern??D,U=F?S(F,{channel:_,name:f,version:O}):j(f,O);try{await y({cwd:e.cwd,runner:n},U,`Release ${f}@${O}`,{signing:e.config.signing,skipRemoteCheck:e.firstRelease}),t.tags.push(U)}catch(H){e.firstRelease&&H instanceof R&&H.code==="TAG_COLLISION"?t.skipped.push({name:U,reason:"tag-creation: tag already exists (first-release — skipped)"}):t.skipped.push({name:U,reason:`tag-creation: ${H.message}`})}const z=e.depGraph.getPackage(f),Ie=e.perPackageConfig.get(f),Re=z?.manifest?.private===!0,je=Ie?.skipNpmPublish===!0;if(M&&!I&&!F?.includes("{major}")&&!Re&&!je){const H=O.split(/[-+]/,1)[0].split(".")[0];if(H!==void 0&&H!==""){const de=f.replace(/^@/,"").replaceAll("/","-");if(de!==""){const te=`${de}-v${H}`;try{await g({cwd:e.cwd,runner:n},te,{push:!a.noPush,signing:e.config.signing}),t.tags.push(te)}catch(Me){t.skipped.push({name:te,reason:`floating-major-tag: ${Me.message}`})}}}}}if(!a.noPush&&t.tags.length>0)try{await B({cwd:e.cwd,runner:n}),t.tagsPushed=!0}catch(f){t.tagsPushed=!1,t.failed.push({name:"_pushTags",reason:`git push --tags failed: ${f.message}. Retry with: git push --tags`})}b.tagged=[...t.tags],b.pushed=t.tagsPushed,a.dryRun||await p(e.cwd,$,b),t.failed.length===0&&t.published.length>0&&!a.dryRun&&await i(e.cwd,$)}if(!a.dryRun){const g=v.pending.length,y=P.pending.length,j=await w(e.cwd,$,P);if(j.changed){const{stageAndCommitFile:B}=await import("./git.js");let S;if(j.removed)S="chore(release): clear pending stage registry [skip ci]";else if(y>g){const D=y-g;S=`chore(release): record ${D} new pending stage${D===1?"":"s"} [skip ci]`}else if(y<g){const D=g-y;S=`chore(release): drain ${D} resolved stage${D===1?"":"s"} [skip ci]`}else S=`chore(release): update pending stage registry (${y} pending) [skip ci]`;try{await B({cwd:e.cwd,runner:n},j.path,S,{author:e.config.gitUser,push:!a.noPush,sign:e.config.gitSignCommits===!0})}catch(D){process.stderr.write(`[vis release] Warning: could not commit ${j.path}: ${D.message}
15
+ `)}}}if(!a.dryRun&&t.published.length>0&&e.config.workspaceChangelog!==!1){const g=e.config.workspaceChangelog,y=typeof g=="object"?g:void 0,j=typeof e.config.aggregateRelease=="object"?e.config.aggregateRelease.enabled:e.config.aggregateRelease===!0;if(y!==void 0||j)try{const{writeWorkspaceChangelogWave:B}=await import("./workspace.js"),S=new Set(t.published.map(M=>M.name)),D=e.plan.releases.filter(M=>S.has(M.name)),_=await B({changelogConfig:e.config.changelog,cwd:e.cwd,workspaceChangelog:e.config.workspaceChangelog},D);if(_)try{const{stageAndCommitFile:M}=await import("./git.js");await M({cwd:e.cwd,runner:n},_,"chore(release): record wave [skip ci]",{author:e.config.gitUser,push:!a.noPush,sign:e.config.gitSignCommits===!0})}catch(M){process.stderr.write(`[vis release] Warning: could not commit workspace CHANGELOG.md: ${M.message}
16
+ `)}}catch(B){process.stderr.write(`[vis release] Warning: could not write workspace CHANGELOG.md wave entry: ${B.message}
17
+ `)}}if(!a.dryRun&&t.published.length>0&&t.tagsPushed){e.config.publish?.noRelease!==!0&&await Va(e,t,n);try{const{walkSuccessfulRelease:g}=await import("./success-walk.js"),{createRemoteClient:y,detectRemoteProvider:j}=await import("./detect2.js"),{resolveFormatter:B}=await import("./resolveFormatter.js"),S=await j(e.cwd,n,e.config.provider),D=y(S,{githubHost:e.config.githubHost,gitlabHost:e.config.gitlabHost,httpProxy:e.config.httpProxy}),_=await D.detectRepoSlug(e.cwd,n),M=await B(e.config.changelog,e.cwd),{recordRecentlyWalked:I}=await import("./staged-registry.js"),f=new Set([...b.walked??[],...(P.recentlyWalked??[]).map(F=>F.key)]),O={...t,published:t.published.filter(F=>!f.has(`${F.name}@${F.version}`))};if(O.published.length>0){const F=await g(e,O,n,{client:D,formatter:M,repo:_}),U=O.published.map(z=>`${z.name}@${z.version}`);b.walked=[...b.walked??[],...U],await p(e.cwd,$,b),P=I(P,U),F.warnings.length>0&&e.plan.warnings.push(...F.warnings)}}catch(g){e.plan.warnings.push(`successWalk: could not run post-release walk: ${g.message}`)}if(e.config.notifications)try{const{dispatchNotifications:g}=await import("./interface.js"),{createRemoteClient:y,detectRemoteProvider:j}=await import("./detect2.js"),B=await j(e.cwd,n,e.config.provider),S=await y(B,{githubHost:e.config.githubHost,gitlabHost:e.config.gitlabHost,httpProxy:e.config.httpProxy}).detectRepoSlug(e.cwd,n);let D;try{const I=`${e.cwd}/package.json`,f=await import("node:fs/promises");D=JSON.parse(await f.readFile(I,"utf8")).name}catch{}const _=new Set([...b.notified??[],...(P.recentlyNotified??[]).map(I=>I.key)]),M=t.published.filter(I=>!_.has(`${I.name}@${I.version}`));if(M.length>0){const I=await g(e.config.notifications,{channel:e.channel?.tag,completedAt:new Date().toISOString(),...D===void 0?{}:{monorepoName:D},published:M.map(f=>({name:f.name,tag:e.channel?.tag,...f.url===void 0?{}:{url:f.url},version:f.version})),...S===void 0?{}:{repo:S},skipped:t.skipped.map(f=>({name:f.name,reason:f.reason}))},{warn:f=>e.plan.warnings.push(f)});if(I.succeeded.length>0){const f=M.map(F=>`${F.name}@${F.version}`);b.notified=[...b.notified??[],...f],await p(e.cwd,$,b);const{recordRecentlyNotified:O}=await import("./staged-registry.js");P=O(P,f)}if(I.failed.length>0||I.succeeded.length>0){const f=I.succeeded.length+I.failed.length;if(I.failed.length>0){e.plan.warnings.push(`[notifications] dispatched ${I.succeeded.length}/${f} channels${I.succeeded.length>0?` (succeeded: ${I.succeeded.join(", ")})`:""}; ${I.failed.length} failed.`);for(const O of I.failed)e.plan.warnings.push(`[notifications:${O.id}] ${O.error}`)}}}}catch(g){e.plan.warnings.push(`notifications: dispatch failed: ${g.message}`)}if(!a.dryRun)try{const g=await w(e.cwd,$,P);if(g.changed){const{stageAndCommitFile:y}=await import("./git.js");try{await y({cwd:e.cwd,runner:n},g.path,"chore(release): record cross-runner notify/walk dedupe [skip ci]",{author:e.config.gitUser,push:!a.noPush,sign:e.config.gitSignCommits===!0})}catch(j){process.stderr.write(`[vis release] Warning: could not commit ${g.path} (notify/walk dedupe): ${j.message}
18
+ `)}}}catch(g){process.stderr.write(`[vis release] Warning: could not update cross-runner dedupe registry: ${g.message}
19
+ `)}}if(!a.dryRun&&e.config.postPublishCommand)try{await Y(e.cwd,e.config.postPublishCommand,"postPublishCommand")}catch(g){t.failed.push({name:"_postPublishCommand",reason:g.message})}return t}finally{l&&await d(e.cwd,s)}},Ma=e=>e.length===0?"":`## Related releases
20
+
21
+ ${e.map(a=>`- [${a.name}](${a.url})`).join(`
22
+ `)}`,Da=(e,a,t)=>{if(!a||!a.header&&!a.footer)return e;const n=c=>ua(c,{contributors:t.contributors??"",date:t.date,name:t.name,previousVersion:t.previousVersion,repo:t.repo,version:t.version}).replaceAll(/\n{3,}/g,`
23
+
24
+ `).replace(/\s+$/,""),s=[];if(a.header){const c=n(a.header);c.length>0&&s.push(c)}if(s.push(e),a.footer){const c=n(a.footer);c.length>0&&s.push(c)}return s.join(`
25
+
26
+ `)},Sa=e=>{if(!Array.isArray(e))return;const[a,t]=e;if(a!=="github"||typeof t!="object"||t===null)return;const{internalAuthors:n}=t;if(Array.isArray(n))return n.filter(s=>typeof s=="string")},Va=async(e,a,t)=>{const{createRemoteClient:n,detectRemoteProvider:s}=await import("./detect2.js"),c=await s(e.cwd,t,e.config.provider),d=n(c,{githubHost:e.config.githubHost,gitlabHost:e.config.gitlabHost,httpProxy:e.config.httpProxy}),l=await d.detectRepoSlug(e.cwd,t);if(!l)return;const i=typeof e.config.aggregateRelease=="object"?e.config.aggregateRelease:{enabled:e.config.aggregateRelease===!0},r=e.config.publish?.draftRelease===!0,m=e.config.publish?.discussionCategory,o=e.config.publish?.addReleases;if(i.enabled){const v=new Date().toISOString().slice(0,10),L=(i.title??"Release {date}").replaceAll("{date}",v),V=`release-${v}`,T=a.published.map(N=>`- \`${N.name}\` → ${N.version}`).join(`
27
+ `);try{const N=await d.createRelease(t,{body:T,cwd:e.cwd,discussionCategory:m,draft:r,repo:l,tag:V,title:L});if(N?.url)for(const E of a.published)E.url=N.url}catch{}return}const{defaultTagFor:p,renderTagPattern:h}=await import("./git.js"),u=e.config.releaseTagPattern,k=e.channel?.tag,w=e.config.publish?.releaseAssets??{},$=new Date().toISOString().slice(0,10),b=Sa(e.config.changelog),P=fa(e.plan.consumedChangeFiles??[],{internalAuthors:b});for(const v of a.published){const L=e.perPackageConfig.get(v.name)?.releaseTagPattern??u,V=L?h(L,{channel:k,name:v.name,version:v.version}):p(v.name,v.version),T=v.version.includes("-");let N=`Release of ${v.name}@${v.version}.`;if(v.stageId&&(N=`${N}
28
+
29
+ > ⏳ **Staged — not yet installable.** Approve via \`vis release stage approve ${v.stageId}\` or the npmjs.com web UI.`),w.stampHashes&&v.tarball&&(N=`${N}
30
+
31
+ ### Tarball integrity
32
+
33
+ - size: \`${v.tarball.size}\` bytes
34
+ - sha256: \`${v.tarball.sha256}\`
35
+ - sha512: \`${v.tarball.sha512}\``),o!==void 0&&o!==!1)try{const C=V.lastIndexOf("@"),g=C>0?V.slice(0,C+1):"",y=await d.listRecentReleases(t,{cwd:e.cwd,excludeTag:V,limit:5,repo:l,tagPrefix:g}),j=Ma(y);j&&(N=o==="top"?`${j}
36
+
37
+ ${N}`:`${N}
38
+
39
+ ${j}`)}catch{}const{releaseNoteTemplate:E}=e.config;if(E){const C=e.plan.releases.find(g=>g.name===v.name)?.oldVersion??"";N=Da(N,E,{contributors:P,date:$,name:v.name,previousVersion:C,repo:l,version:v.version})}const A=[];w.uploadTarball&&v.tarball&&A.push(v.tarball.path);try{const C=await d.createRelease(t,{assets:A.length>0?A:void 0,body:N,cwd:e.cwd,discussionCategory:m,draft:r,prerelease:T,repo:l,tag:V,title:`${v.name} v${v.version}`});C?.url&&(v.url=C.url)}catch(C){console.warn(`createRelease failed for ${v.name}@${v.version} (tag ${V}): ${C.message}`)}}},Ea=e=>(e.config.publish?.publishArgs??[]).includes("--provenance")&&e.pm.id!=="bun";export{qa as a,za as b,sa as c,Ne as d,Ya as f,Xa as p,oa as r,Ja as w};
@@ -0,0 +1,2 @@
1
+ import{createRequire as l}from"node:module";import{VisReleaseError as a}from"../packem_shared/VisReleaseError-DMGRBTNO.js";const m=l(import.meta.url),n=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,c=t=>{if(typeof n<"u"&&n.versions&&n.versions.node){const[r,e]=n.versions.node.split(".").map(Number);if(r>22||r===22&&e>=3||r===20&&e>=16)return n.getBuiltinModule(t)}return m(t)},{readFile:u,mkdir:f,writeFile:g,unlink:p}=c("node:fs/promises"),{dirname:_,join:T}=c("node:path"),d=(t,r)=>T(t,r,"pre.json"),E=async(t,r)=>{const e=d(t,r);let o;try{o=await u(e,"utf8")}catch(i){if(i.code==="ENOENT")return;throw new a({cause:i,code:"STATE_FILE_CORRUPT",message:`Failed to read pre-mode file at ${e}: ${i.message}`})}let s;try{s=JSON.parse(o)}catch(i){throw new a({cause:i,code:"STATE_FILE_CORRUPT",message:`Pre-mode file at ${e} is not valid JSON: ${i.message}.`})}if(s.version!==1)throw new a({code:"STATE_FILE_CORRUPT",message:`Pre-mode file at ${e} reports unknown version ${s.version}.`});if(s.mode!=="pre"&&s.mode!=="exit-pending")throw new a({code:"STATE_FILE_CORRUPT",message:`Pre-mode file at ${e} has invalid mode ${JSON.stringify(s.mode)}.`});if(typeof s.tag!="string"||s.tag.length===0)throw new a({code:"STATE_FILE_CORRUPT",message:`Pre-mode file at ${e} is missing a tag.`});return s},P=async(t,r,e)=>{const o=d(t,r);return await f(_(o),{recursive:!0}),await g(o,`${JSON.stringify(e,null,2)}
2
+ `),o},R=async(t,r)=>{const e=d(t,r);try{return await p(e),!0}catch(o){if(o.code==="ENOENT")return!1;throw o}},y=(t,r)=>{const e={};for(const o of r)e[o.name]=o.version;return{enteredAt:new Date().toISOString(),initialVersions:e,mode:"pre",tag:t,version:1}};export{y as buildEnterFile,R as deletePreMode,d as preModeFilePath,E as readPreMode,P as writePreMode};
@@ -0,0 +1,2 @@
1
+ import{normaliseGroup as p}from"../release/types.js";const d=o=>o==="debug",m=o=>/[\\/]/.test(o)||/\.(?:pem|gpg|key|asc|p12|pfx)$/i.test(o)||o.length<8?"(key: configured)":`…${o.slice(-4)}`,i=o=>{try{const a=new URL(o);a.username="",a.password="";const s=a.pathname!==""&&a.pathname!=="/"?"/…REDACTED…":"";return`${a.origin}${s}`}catch{return o.replace(/(:\/\/)[^@/]+@/,"$1")||"[REDACTED]"}},h=o=>{if(!o)return o;const a={};for(const s of Object.keys(o))a[s]="[REDACTED]";return a},u=o=>{const a=structuredClone(o);if(a.signing?.key&&(a.signing={...a.signing,key:m(a.signing.key)}),a.httpProxy&&(a.httpProxy=i(a.httpProxy)),a.notifications){const s=a.notifications,n=r=>({...r,webhook:i(r.webhook)}),t=r=>({...r,webhook:i(r.webhook)}),e=r=>({...r,headers:h(r.headers),url:i(r.url)});s.slack&&(s.slack=Array.isArray(s.slack)?s.slack.map(r=>n(r)):n(s.slack)),s.discord&&(s.discord=Array.isArray(s.discord)?s.discord.map(r=>t(r)):t(s.discord)),s.webhook&&(s.webhook=Array.isArray(s.webhook)?s.webhook.map(r=>e(r)):e(s.webhook))}return a},g=o=>o&&o.map(a=>p(a)),b=(o,a,s)=>{const n=o.printConfig;if(n===void 0||n===!1||n==="")return!1;const t=d(n),e=u(a.config),r=e.gitUser?{...e.gitUser,email:e.gitUser.email?"[REDACTED]":e.gitUser.email}:e.gitUser,c={access:e.access,aggregateRelease:e.aggregateRelease,allowCustomCommands:e.allowCustomCommands,baseBranch:e.baseBranch,bumpDevDependencies:e.bumpDevDependencies,bumpMinorPreMajor:e.bumpMinorPreMajor,bumpPatchForMinorPreMajor:e.bumpPatchForMinorPreMajor,changelog:e.changelog,changesDir:e.changesDir,channels:e.channels,defaultManaged:e.defaultManaged,detectCatalogChanges:e.detectCatalogChanges,fixed:g(e.fixed),floatingMajorTag:e.floatingMajorTag,githubHost:e.githubHost,gitlabHost:e.gitlabHost,gitUser:r,httpProxy:e.httpProxy,ignore:e.ignore,include:e.include,linked:g(e.linked),notifications:e.notifications,postPublishCommand:e.postPublishCommand,postVersionCommand:e.postVersionCommand,prePublishCommand:e.prePublishCommand,preVersionCommand:e.preVersionCommand,privatePackages:e.privatePackages,provider:e.provider,publish:e.publish,releaseNoteTemplate:e.releaseNoteTemplate,releaseTagPattern:e.releaseTagPattern,signing:e.signing,snapshot:e.snapshot,successWalk:e.successWalk,updateInternalDependencies:e.updateInternalDependencies,versionPr:e.versionPr};return t&&(c.__resolved__={branch:a.branch,channel:a.channel,cwd:a.cwd,packageCount:a.packages.length,packageManager:a.pm.id,packageNames:a.packages.map(l=>l.name).sort(),perPackageConfigKeys:[...a.perPackageConfig.keys()].sort()}),process.stdout.write(`${JSON.stringify(c,null,2)}
2
+ `),!0};export{b as printConfigIfRequested};
@@ -0,0 +1,7 @@
1
+ import{createRequire as l}from"node:module";import{E as n}from"../packem_shared/Table-CcVkyULl-B_ef6zfS.js";const u=l(import.meta.url),i=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,p=o=>{if(typeof i<"u"&&i.versions&&i.versions.node){const[e,s]=i.versions.node.split(".").map(Number);if(e>22||e===22&&s>=3||e===20&&s>=16)return i.getBuiltinModule(o)}return u(o)},{createInterface:c}=p("node:readline"),a=(o,e)=>new Promise(s=>{o.question(e,r=>{s(r.trim())})}),f=async(o,e=!0)=>{const s=c({input:process.stdin,output:process.stdout});try{const r=await a(s,`${o} ${n(e?"[Y/n]":"[y/N]")} `);return r===""?e:/^y(?:es)?$/i.test(r)}finally{s.close()}},w=async(o,e="")=>{const s=c({input:process.stdin,output:process.stdout});try{const r=e?` ${n(`(${e})`)}`:"",t=await a(s,`${o}${r} `);return t===""?e:t}finally{s.close()}},y=async(o,e)=>{if(e.length===0)throw new Error("selectPrompt called with no options.");const s=c({input:process.stdin,output:process.stdout});try{process.stdout.write(`${o}
2
+ `);for(const[r,t]of e.entries())process.stdout.write(` ${r+1}) ${t.label}
3
+ `);for(;;){const r=await a(s,n(` [1-${e.length}] `)),t=Number.parseInt(r,10);if(!Number.isNaN(t)&&t>=1&&t<=e.length)return e[t-1].value;process.stdout.write(n(` Please enter a number between 1 and ${e.length}.
4
+ `))}}finally{s.close()}},$=async(o,e)=>{if(e.length===0)throw new Error("multiSelectPrompt called with no options.");const s=c({input:process.stdin,output:process.stdout});try{process.stdout.write(`${o}
5
+ `);for(const[r,t]of e.entries())process.stdout.write(` ${r+1}) ${t.label}
6
+ `);for(;;){const r=(await a(s,n(" Comma-separated indices (e.g. 1,3,4): "))).split(",").map(t=>t.trim()).filter(Boolean).map(t=>Number.parseInt(t,10));if(r.every(t=>!Number.isNaN(t)&&t>=1&&t<=e.length))return r.map(t=>e[t-1].value);process.stdout.write(n(` Please enter comma-separated numbers between 1 and ${e.length}.
7
+ `))}}finally{s.close()}};export{f as confirmPrompt,$ as multiSelectPrompt,y as selectPrompt,w as textPrompt};
@@ -0,0 +1,3 @@
1
+ import{p as o}from"./bin.js";import{r as d}from"../packem_shared/advisories-DLeO5KMN.js";const f=async({fs:c,logger:u,options:e,workspaceRoot:s})=>{if(!s)throw new Error("Could not determine workspace root. Run this command inside a workspace.");const r=e.db??d(s),t=e.format==="json";if(!e.force){o.warn(`Prune is destructive. Will remove: ${r}`),o.info("Re-run with --force to proceed."),t&&process.stdout.write(`${JSON.stringify({dbPath:r,reason:"needs --force",removed:!1})}
2
+ `);return}const a=[r,`${r}-wal`,`${r}-shm`,`${r}-journal`],i=[];for(const n of a)try{await c.rm(n,{force:!0}),i.push(n)}catch{}if(t){process.stdout.write(`${JSON.stringify({dbPath:r,files:i,removed:!0})}
3
+ `);return}o.success(`Removed ${r}.`)},w=f;export{w as advisoriesPruneExecute};
@@ -0,0 +1 @@
1
+ import{createRequire as v}from"node:module";const _=v(import.meta.url),d=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,g=t=>{if(typeof d<"u"&&d.versions&&d.versions.node){const[e,s]=d.versions.node.split(".").map(Number);if(e>22||e===22&&s>=3||e===20&&s>=16)return d.getBuiltinModule(t)}return _(t)},{createHash:S}=g("node:crypto"),{createReadStream:j}=g("node:fs"),{lstat:P,realpath:A,stat:D}=g("node:fs/promises"),{resolve:h,isAbsolute:E,join:x,sep:k}=g("node:path"),m=(t,e)=>{const s=h(t),i=h(e),r=s.endsWith(k)?s:`${s}${k}`;return i===s||i.startsWith(r)},C=t=>{const e=Array.isArray(t)?t[0]:t;if(e===null||typeof e!="object")return;const{files:s}=e;if(!Array.isArray(s))return;const i=[];for(const r of s)r&&typeof r.path=="string"&&i.push(r.path);return i},R=["**/*.test.*","**/__tests__/**","**/__fixtures__/**"],T=async t=>{const e=[];let s;try{({scanFiles:s}=await import("@visulima/secret-scanner"))}catch{return{findings:[{hint:"pnpm add -D @visulima/secret-scanner, or set publish.guards.packSecretScan: false.",id:"packSecretScan:dep-missing",message:"publish.guards.packSecretScan is enabled but @visulima/secret-scanner is not installed."}],gate:"packSecretScan",passed:!1}}const i=[];for(const a of t.files){const o=E(a)?a:x(t.pkgDir,a);m(t.pkgDir,o)&&i.push(o)}const r=t.ignore??R,n=await s(i,{walk:{excludePatterns:[...r]}});for(const a of n)e.push({hint:"Add the file to .npmignore / package.json#files, or rotate the credential.",id:`packSecretScan:${a.ruleId}:${a.file}`,message:`${a.ruleId} match in ${a.file} (line ${a.startLine}, ${a.confidence} confidence).`});return{findings:e,gate:"packSecretScan",passed:e.length===0}},F=t=>typeof t=="string",y=(t,e,s)=>{if(t!==null){if(F(t)){s.push({keyPath:e,target:t});return}if(Array.isArray(t)){for(const[i,r]of t.entries())y(r,`${e}[${i}]`,s);return}if(typeof t=="object")for(const[i,r]of Object.entries(t))y(r,e===""?i:`${e}.${i}`,s)}},L=async(t,e)=>{if(!e.startsWith("./"))return!0;const s=e.replace(/^\.\//,""),i=s.includes("*"),r=i?s.split("*",1)[0].replace(/\/$/,""):s,n=x(t,r);if(!m(t,n))return!1;try{const a=await P(n);if(a.isSymbolicLink()){const o=await A(n);if(!m(t,o))return!1;const c=await D(o);return i?c.isDirectory():!0}return i?a.isDirectory():!0}catch{return!1}},M=async(t,e)=>{const s=[],i=[];for(const r of["main","module","types","typings","browser"]){const n=e[r];typeof n=="string"&&i.push({keyPath:r,target:n})}if(typeof e.bin=="string")i.push({keyPath:"bin",target:e.bin});else if(e.bin&&typeof e.bin=="object")for(const[r,n]of Object.entries(e.bin))typeof n=="string"&&i.push({keyPath:`bin.${r}`,target:n});e.exports!==void 0&&y(e.exports,"exports",i);for(const{keyPath:r,target:n}of i)await L(t,n)||s.push({hint:"Run the build before publishing, or remove the dangling export.",id:`exportsExist:${r}:${n}`,message:`Manifest field \`${r}\` points at \`${n}\` which does not exist in the pack root.`});return{findings:s,gate:"exportsExist",passed:s.length===0}},O=["preinstall","install","postinstall"],q=t=>t===void 0||t==="off"?{allow:{},mode:"off"}:typeof t=="string"?{allow:{},mode:t}:{allow:t.allow??{},mode:t.mode},N=(t,e)=>{const s=[],i=q(e);if(i.mode==="off")return{findings:s,gate:"lifecycleScripts",passed:!0};const r=t.scripts??{};for(const n of O){const a=r[n];a===void 0||i.allow[n]===a||s.push({hint:`Add to publish.guards.lifecycleScripts.allow.${n}, or set the gate to "warn"/"off".`,id:`lifecycleScripts:${n}`,message:`Lifecycle script \`${n}\` is set to \`${a}\` but is not in the allow-list.`})}return{findings:s,gate:"lifecycleScripts",passed:s.length===0}},w={critical:4,high:3,low:1,moderate:2},$=9e4,W=async(t,e,s)=>{const i=[];if(s===void 0||s==="off")return{findings:i,gate:"audit",passed:!0};const r=w[s]??4,n=Symbol("audit-timeout");let a;const o=new Promise(u=>{a=setTimeout(u,$,n)});let c;try{const u=await Promise.race([e.run("npm",["audit","--omit=dev","--json"],{cwd:t,silent:!0}),o]);if(u===n)return{findings:[{hint:'Network or registry outage — re-run later, or set publish.guards.audit: "off".',id:"audit:timeout",message:`\`npm audit\` exceeded ${$}ms and was aborted.`}],gate:"audit",passed:!1};c=u}finally{a&&clearTimeout(a)}let p;try{p=JSON.parse(c.stdout)}catch{return{findings:[{hint:c.stderr.trim()||"Re-run npm audit manually to inspect.",id:"audit:parse",message:`Could not parse \`npm audit\` output for ${t}.`}],gate:"audit",passed:!1}}const l=p.metadata?.vulnerabilities??{};for(const[u,f]of Object.entries(l)){if(f<=0)continue;const b=w[u];b!==void 0&&b>=r&&i.push({hint:"npm audit fix --omit=dev, or raise the threshold via publish.guards.audit.",id:`audit:${u}`,message:`${f} runtime ${u}-severity advisory(s) reported by npm audit.`})}return{findings:i,gate:"audit",passed:i.length===0}},G=async t=>{const e=h(t),s=S("sha256"),i=S("sha512");let r=0;return await new Promise((n,a)=>{const o=j(e);o.on("data",c=>{s.update(c),i.update(c),r+=c.length}),o.on("end",()=>{n()}),o.on("error",a)}),{path:e,sha256:s.digest("hex"),sha512:i.digest("hex"),size:r}},I=async t=>{const e=t.config??{},s=[],i=(l,u)=>u.catch(f=>({findings:[{hint:"Re-run with --debug to capture the stack, or disable this gate.",id:`${l}:internal-error`,message:`Guard "${l}" threw: ${f instanceof Error?f.message:String(f)}`}],gate:l,passed:!1}));if(e.packSecretScan){const l=typeof e.packSecretScan=="object"?e.packSecretScan.ignore:void 0;s.push(i("packSecretScan",T({files:t.packFiles,ignore:l,pkgDir:t.pkgDir})))}e.exportsExist&&s.push(i("exportsExist",M(t.pkgDir,t.manifest))),e.audit&&e.audit!=="off"&&s.push(i("audit",W(t.pkgDir,t.runner,e.audit)));const r=await Promise.all(s),n=N(t.sourceManifest??t.manifest,e.lifecycleScripts),a=[...r];n.gate&&e.lifecycleScripts!==void 0&&e.lifecycleScripts!=="off"&&a.push(n);const o=typeof e.lifecycleScripts=="string"?e.lifecycleScripts:e.lifecycleScripts?.mode??"off",c=[],p=[];for(const l of a)l.passed||(l.gate==="lifecycleScripts"&&o==="warn"?p.push(l):c.push(l));return{blockers:c,results:a,warnings:p}};export{C as extractPackFilesFromRaw,G as hashTarball,M as runExportsExist,N as runLifecycleScripts,T as runPackSecretScan,I as runPublishGuards,W as runRuntimeAudit};
@@ -0,0 +1,48 @@
1
+ import{createRequire as Ne}from"node:module";import{VisReleaseError as l}from"../packem_shared/VisReleaseError-DMGRBTNO.js";import{VersionActions as N}from"../packem_shared/AfterAllProjectsVersioned-CAKI2nWf.js";import{E as Re}from"../packem_shared/public-api-WqUCiyIe.js";import{resolveCleanStripList as Me}from"./DEFAULT_CLEAN_KEEP.js";import{assertValidPackageName as F,resolveCustomCommands as W,interpolateCommand as J}from"./security.js";const _e=Ne(import.meta.url),x=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,V=t=>{if(typeof x<"u"&&x.versions&&x.versions.node){const[e,n]=x.versions.node.split(".").map(Number);if(e>22||e===22&&n>=3||e===20&&n>=16)return x.getBuiltinModule(t)}return _e(t)},{readFile:A,writeFile:O,rm:je,readdir:xe}=V("node:fs/promises"),{dirname:U,join:h}=V("node:path"),{fileURLToPath:Ve}=V("node:url"),{mkdtempSync:G,writeFileSync:Oe}=V("node:fs"),{tmpdir:B}=V("node:os"),Ee=["dependencies","devDependencies","peerDependencies","optionalDependencies"],fe=(t,e)=>{if(t.startsWith("catalog:")||t==="*"||t==="workspace:*"||t==="workspace:^"||t==="workspace:~")return t;if(t.startsWith("workspace:")){const n=t.slice(10);return`workspace:${L(n)}${e}`}if(t.startsWith("npm:")){const n=t.lastIndexOf("@");if(n<=4)return t;const r=t.slice(4,n),s=t.slice(n+1),a=L(s);return`npm:${r}@${a}${e}`}return`${L(t)}${e}`},De=/^([\^~=]|>=?|<=?)/,L=t=>{const e=De.exec(t);return e?e[1]??"^":"^"},Tt=async(t,e,n={})=>{const r=n.serializeManifest??Ge,s=n.changelogPath??We,a=n.renderChangelogEntry??Je,i=new Map(t.releases.map(p=>[p.name,p.newVersion])),o=await Promise.all(t.releases.map(async p=>{const m=e.getPackage(p.name);if(!m)return;const y=Fe(m.manifest,p.newVersion,i),b=n.readManifest?.(m.manifestPath),w=s(m);return{changelogEntry:await a(p),changelogPath:w,manifestWrite:{content:r(y,b),path:m.manifestPath}}})),c=[],d=new Map;for(const p of o){if(!p)continue;c.push(p.manifestWrite);const m=d.get(p.changelogPath);m?m.push(p.changelogEntry):d.set(p.changelogPath,[p.changelogEntry])}for(const[p,m]of d){const y=m.join(`
2
+
3
+ `),b=n.readChangelog?.(p);c.push({content:Ue(y,b),path:p})}return{deletions:t.consumedChangeFiles.map(p=>p.path),writes:c}},Fe=(t,e,n)=>{const r={...t,version:e};for(const s of Ee){const a=t[s];if(!a||typeof a!="object")continue;const i={...a};let o=!1;for(const[c,d]of Object.entries(a)){const p=n.get(c);if(p===void 0)continue;const m=fe(d,p);m!==d&&(i[c]=m,o=!0)}o&&(r[s]=i)}return r},Le=/^# .+/,Te=/^## /m,Ue=(t,e)=>{const n=t.trim();if(!e||e.trim()==="")return`# Changelog
4
+
5
+ ${n}
6
+ `;const r=e.split(/\r?\n/);if(r[0]&&Le.test(r[0])){let s=1;for(;s<r.length&&!(r[s]??"").startsWith("## ");)s+=1;const a=r.slice(0,s),i=r.slice(s);return a.length>0&&a[a.length-1]!==""&&a.push(""),[...a,n,"",...i].join(`
7
+ `).replaceAll(/\n{3,}/g,`
8
+
9
+ `)}return Te.test(e)?`${n}
10
+
11
+ ${e.trimStart()}`:`${n}
12
+
13
+ ${e.trimStart()}`},Ge=(t,e)=>{const n=Be(e);return`${JSON.stringify(t,null,n)}
14
+ `},Be=t=>{if(!t)return 4;const e=/\n(\s+)"/.exec(t);if(!e)return 4;const n=(e[1]??"").length;return n===2||n===4?n:4},We=t=>`${t.dir}/CHANGELOG.md`,Je=t=>{const e=new Date().toISOString().slice(0,10),n=[`## ${t.newVersion}`,`<sub>${e}</sub>`,""];if(t.isCascadeBump||t.isGroupBump)for(const r of t.sources)n.push(`- Version bump from ${r.name}@${r.newVersion}`);else if(t.isDependencyBump&&t.changeFiles.length===0)for(const r of t.sources)r.newVersion===""?n.push(`- Removed dependency ${r.name}`):n.push(`- Updated dependency ${r.name}@${r.newVersion}`);else for(const r of t.changeFiles)for(const s of r.body.split(/\r?\n/)){if(s.trim()===""){n.push("");continue}n.push(s.startsWith("-")||s.startsWith("*")?s:`- ${s}`)}return n.join(`
15
+ `)},He=["dependencies","devDependencies","peerDependencies","optionalDependencies"],Q={default:{},named:{}},Ke=t=>{if(!t)return Q;let e;try{e=Re(t,{schema:"core",strict:!0})}catch(s){throw new l({cause:s,code:"CONFIG_INVALID",message:`Failed to parse pnpm-workspace.yaml: ${s.message}`})}if(typeof e!="object"||e===null||Array.isArray(e))return Q;const n=e,r={default:{},named:{}};if(typeof n.catalog=="object"&&n.catalog!==null&&!Array.isArray(n.catalog))for(const[s,a]of Object.entries(n.catalog))typeof a=="string"&&(r.default[s]=a);if(typeof n.catalogs=="object"&&n.catalogs!==null&&!Array.isArray(n.catalogs))for(const[s,a]of Object.entries(n.catalogs)){if(typeof a!="object"||a===null||Array.isArray(a))continue;const i={};for(const[o,c]of Object.entries(a))typeof c=="string"&&(i[o]=c);r.named[s]=i}return r},we=(t,e,n)=>{if(!t.startsWith("catalog:"))return t;const r=t.slice(8),s=r===""?n.default:n.named[r];if(s)return s[e]},Y=(t,e)=>{const n={...t};for(const r of He){const s=t[r];if(!s||typeof s!="object")continue;const a={...s};for(const[i,o]of Object.entries(s)){if(!o.startsWith("catalog:"))continue;const c=we(o,i,e);if(c===void 0)throw new l({code:"CONFIG_INVALID",message:`Cannot resolve "${o}" for dependency "${i}" in package "${t.name}". Add it to pnpm-workspace.yaml's "catalog" or "catalogs" block.`,packageName:t.name});a[i]=c}n[r]=a}return n},Ut=Object.defineProperty({__proto__:null,parseCatalogs:Ke,resolveCatalogRef:we,rewriteCatalogRefs:Y},Symbol.toStringTag,{value:"Module"}),qe="ACTIONS_ID_TOKEN_REQUEST_URL",z=t=>{const e=!!t.env[qe],n=!!t.env[t.staticTokenVar],r=t.workspaceConfig?.publish?.preferStaticToken===!0;return e&&!(r&&n)?"oidc":n?"token":"missing"};let T;const Ye="https://github.com/visulima/visulima",ze=async()=>{try{let t=U(Ve(import.meta.url));for(let e=0;e<6;e+=1){const n=h(t,"package.json");try{const s=await A(n,"utf8"),a=JSON.parse(s);if(a.name==="@visulima/vis"&&typeof a.version=="string")return a.version}catch{}const r=U(t);if(r===t)break;t=r}}catch{}return"unknown"},Qe=async()=>(T!==void 0||(T=`vis-release/${await ze()} (+${Ye})`),T),X=new Map,Xe=async t=>{const e=X.get(t);if(e!==void 0)return e;try{const n=await import("undici"),r=new n.ProxyAgent(t);return X.set(t,r),r}catch{return}},Ze=t=>t===301||t===302||t===303||t===307||t===308,et=(t,e)=>{try{const n=new URL(t),r=new URL(e);return n.host===r.host&&n.protocol===r.protocol}catch{return!1}},j=async(t,e={})=>{const n=e.maxRedirects??2,r={"User-Agent":await Qe(),...e.headers};e.headers?.["User-Agent"]&&(r["User-Agent"]=e.headers["User-Agent"]);let s=t,a=0;const i=e.httpProxy?await Xe(e.httpProxy):void 0;for(;;){let o;try{const p=e.fetchImpl??globalThis.fetch,m={headers:r,method:e.method??"GET",redirect:"manual"};i&&(m.dispatcher=i),o=await p(s,m)}catch{return{json:async()=>{},ok:!1,status:0,text:async()=>""}}if(!Ze(o.status))return{json:async()=>{try{return await o.json()}catch{return}},ok:o.ok,status:o.status,text:async()=>{try{return await o.text()}catch{return""}}};const c=o.headers.get("location")??o.headers.get("Location");if(!c||a>=n)return{json:async()=>{},ok:!1,status:0,text:async()=>""};let d;try{d=new URL(c,s).toString()}catch{return{json:async()=>{},ok:!1,status:0,text:async()=>""}}if(!et(t,d))return{json:async()=>{},ok:!1,status:0,text:async()=>""};s=d,a+=1}},tt="https://crates.io/api/v1/crates",nt="Cargo.toml",Z=async t=>{let e;try{e=await A(t,"utf8")}catch(o){throw new l({cause:o,code:"CONFIG_INVALID",file:t,message:`Failed to read Cargo.toml at ${t}: ${o.message}`})}const{parse:n}=await import("smol-toml");let r;try{r=n(e)}catch(o){throw new l({cause:o,code:"CONFIG_INVALID",file:t,message:`Failed to parse Cargo.toml at ${t}: ${o.message}`})}if(!r.package)throw new l({code:"CONFIG_INVALID",file:t,hint:"CargoVersionActions only supports publishable crates with a [package] table. For workspace roots, point per-package config at the member crate directory.",message:`Cargo.toml at ${t} has no [package] table.`});const{name:s}=r.package;if(typeof s!="string"||s.length===0)throw new l({code:"CONFIG_INVALID",file:t,message:`Cargo.toml at ${t} is missing [package].name.`});const a=r.package.version;let i;if(typeof a=="string"?i=a:a&&typeof a=="object"&&a.workspace===!0&&(i=r.workspace?.package?.version),typeof i!="string"||i.length===0)throw new l({code:"CONFIG_INVALID",file:t,hint:"Set [package].version explicitly, or — for workspace-inherited versions — ensure the root Cargo.toml carries [workspace.package].version and point per-package config at it.",message:`Cargo.toml at ${t} has no resolvable [package].version.`});return{name:s,version:i}},ee=async(t,e)=>{const n=`${tt}/${encodeURIComponent(t)}`;try{const r=await j(n,{headers:{Accept:"application/json"},httpProxy:e});if(r.status===404||!r.ok)return;const s=await r.json();return s?.crate?.max_stable_version??s?.crate?.max_version??void 0}catch{return}},rt=(t,e)=>z({env:t,staticTokenVar:"CARGO_REGISTRY_TOKEN",workspaceConfig:e})==="oidc",st=async(t,e)=>{const n=await t.run("cargo",["package","--list","--allow-dirty"],{cwd:e,silent:!0});return n.exitCode!==0?[]:n.stdout.split(/\r?\n/).map(r=>r.trim()).filter(r=>r.length>0)};class at extends N{id="cargo";async readPublishedVersion(e){const n=H(e.pkg);try{const{name:r}=await Z(n);return await ee(r)}catch{return}}async publish(e){if(e.dryRun)return{output:`[dry-run / cargo] would publish ${e.pkg.name}@${e.release.newVersion}`,published:!0};const n=H(e.pkg,e.perPackageConfig),r=ot(e.pkg,e.perPackageConfig),{name:s,version:a}=await Z(n);if(a!==e.release.newVersion)throw new l({code:"CONFIG_INVALID",file:n,hint:`Confirm the cargo() preset's crateDir points at the directory containing this Cargo.toml. Expected ${e.release.newVersion} on disk after the extra-files bump.`,message:`Cargo.toml version (${a}) does not match planned release version (${e.release.newVersion}) for ${e.pkg.name}.`,packageName:e.pkg.name});if(await ee(s,e.workspaceConfig?.httpProxy)===e.release.newVersion)return{alreadyPublished:!0,output:`[cargo] ${s}@${e.release.newVersion} already on crates.io`,published:!1};const i=rt(process.env,e.workspaceConfig);if(!i&&!process.env.CARGO_REGISTRY_TOKEN)throw new l({code:"AUTH_MISSING",hint:"Set CARGO_REGISTRY_TOKEN, or run from a GH-Actions job with `permissions: id-token: write` for OIDC trusted publishing.",message:`Cannot publish ${s}@${e.release.newVersion}: neither CARGO_REGISTRY_TOKEN nor OIDC trusted publishing is available.`,packageName:e.pkg.name});const o=e.workspaceConfig?.publish?.guards;if(o?.packSecretScan){const p=await st(e.pm.runner,r);if(p.length>0){const{runPackSecretScan:m}=await import("./publish-guards.js"),y=typeof o.packSecretScan=="object"?o.packSecretScan.ignore:void 0,b=await m({files:p,ignore:y,pkgDir:r});if(!b.passed){const{redactTokens:w}=await import("./security.js"),C=b.findings.map(_=>` • [packSecretScan] ${w(_.message)}${_.hint?`
16
+ → ${w(_.hint)}`:""}`).join(`
17
+ `);throw new l({code:"PUBLISH_FAILED",message:`Pre-publish secret scan failed for ${s}@${e.release.newVersion}:
18
+ ${C}`,packageName:e.pkg.name})}}}const c=["publish","--allow-dirty"];e.registry&&e.registry!=="https://crates.io"&&c.push("--registry",e.registry);const d=await e.pm.runner.run("cargo",c,{cwd:r,silent:!1});if(d.exitCode!==0)throw new l({code:"PUBLISH_FAILED",hint:"Inspect the cargo output above. Common causes: missing CARGO_REGISTRY_TOKEN, OIDC permission misconfigured, version already published, crates.io rate limit. Re-runs are safe — the published-version probe short-circuits subsequent runs.",message:`cargo publish failed for ${s}@${e.release.newVersion}: exit ${d.exitCode}. stderr: ${d.stderr.trim().slice(0,500)}`,packageName:e.pkg.name});return{output:`[cargo] published ${s}@${e.release.newVersion}${i?" (trusted publishing)":""}`,published:!0}}}const H=(t,e)=>{const n=e?.cargoTomlPath??nt;return h(t.dir,n)},ot=(t,e)=>U(H(t,e)),it=["linux/amd64","linux/arm64"],ct=t=>{const e=t.indexOf("/");if(e===-1)return{registry:"docker.io",repository:`library/${t}`};const n=t.slice(0,e),r=t.slice(e+1);return n==="localhost"||n.includes(".")||n.includes(":")?{registry:n,repository:r}:r.includes("/")?{registry:"docker.io",repository:t}:{registry:"docker.io",repository:`${n}/${r}`}},te=(t,e)=>{const{registry:n,repository:r}=ct(t);return`https://${n==="docker.io"?"registry-1.docker.io":n}/v2/${r}/manifests/${encodeURIComponent(e)}`},ke=t=>{const e=t??{};return{buildContext:e.buildContext,containerBuildArgs:e.containerBuildArgs,containerImage:e.containerImage,containerPlatforms:e.containerPlatforms,containerSigning:e.containerSigning,containerSkipLatest:e.containerSkipLatest}},pt=(t,e)=>{const n=ke(t);if(typeof n.containerImage!="string"||n.containerImage.length===0)throw new l({code:"CONFIG_INVALID",hint:["Container packages must declare `containerImage` in their per-pkg release config:","",' release.packages["<pkg>"] = container({',' image: "ghcr.io/scope/foo",',' platforms: ["linux/amd64", "linux/arm64"],',' signing: "cosign", // optional'," })","",'Or set `versionActions: "container"` + `containerImage` directly.'].join(`
19
+ `),message:`containerImage is required for versionActions: "container" on ${e}`,packageName:e});return{buildContext:n.buildContext,containerBuildArgs:n.containerBuildArgs,containerImage:n.containerImage,containerPlatforms:n.containerPlatforms,containerSigning:n.containerSigning,containerSkipLatest:n.containerSkipLatest}};class lt extends N{id="container";async readPublishedVersion(e){const n=ke(e.perPackageConfig);if(!n.containerImage)return;const r=e.pkg.version,s=te(n.containerImage,r);try{return(await j(s,{headers:{Accept:["application/vnd.oci.image.manifest.v1+json","application/vnd.oci.image.index.v1+json","application/vnd.docker.distribution.manifest.v2+json","application/vnd.docker.distribution.manifest.list.v2+json"].join(",")},httpProxy:e.workspaceConfig?.httpProxy,method:"HEAD"})).status===200?r:void 0}catch{return}}async publish(e){const n=pt(e.perPackageConfig,e.pkg.name);if(e.dryRun){const{command:a}=ne(e,n);return{output:`[dry-run / container] would run: ${a.join(" ")}`,published:!0}}try{const a=te(n.containerImage,e.release.newVersion);if((await j(a,{httpProxy:e.workspaceConfig?.httpProxy,method:"HEAD"})).status===200)return{alreadyPublished:!0,output:`[container] ${n.containerImage}:${e.release.newVersion} already published`,published:!1}}catch{}const{command:r}=ne(e,n),s=await e.pm.runner.run(r[0],r.slice(1),{cwd:e.pkg.dir,silent:!1});if(s.exitCode!==0)throw new l({code:"PUBLISH_FAILED",hint:["docker buildx build failed. Common causes:"," • Not authenticated to the registry — run `docker login <registry>` first."," For ECR: `aws ecr get-login-password --region <r> | docker login --username AWS --password-stdin <account>.dkr.ecr.<r>.amazonaws.com`"," For GCR/GAR: `gcloud auth configure-docker <region>-docker.pkg.dev`"," For GHCR: `echo $GITHUB_TOKEN | docker login ghcr.io -u <user> --password-stdin`"," • Buildx not installed / configured — `docker buildx create --use` (one-time setup)."," • Multi-arch build needs QEMU registered — `docker run --privileged --rm tonistiigi/binfmt --install all`."].join(`
20
+ `),message:`docker buildx failed for ${e.pkg.name}@${e.release.newVersion}: exit ${s.exitCode}. stderr: ${s.stderr.trim().slice(0,500)}`,packageName:e.pkg.name});if(n.containerSigning==="cosign"){const a=`${n.containerImage}:${e.release.newVersion}`,i=await e.pm.runner.run("cosign",["sign","--yes",a],{cwd:e.pkg.dir,silent:!1});if(i.exitCode!==0)throw new l({code:"PUBLISH_FAILED",hint:"cosign signing failed. For keyless cosign, ensure COSIGN_EXPERIMENTAL=1 (cosign <2.0) and the CI runner has the OIDC token (`id-token: write` permission on GH Actions).",message:`cosign sign failed for ${a}: exit ${i.exitCode}. stderr: ${i.stderr.trim().slice(0,500)}`,packageName:e.pkg.name})}return{output:`[container] published ${n.containerImage}:${e.release.newVersion}${n.containerSkipLatest?"":" + :latest"}${n.containerSigning==="cosign"?" (signed via cosign)":""}`,published:!0}}}const ne=(t,e)=>{if(!e.containerImage)throw new Error("buildBuildxCommand requires config.containerImage");const n=(e.containerPlatforms??it).join(","),r=`${e.containerImage}:${t.release.newVersion}`,s=`${e.containerImage}:latest`,a=e.buildContext??".",i=["docker","buildx","build","--platform",n,"-t",r];e.containerSkipLatest||i.push("-t",s);for(const[o,c]of Object.entries(e.containerBuildArgs??{}))i.push("--build-arg",`${o}=${c}`);return i.push("--label",`org.opencontainers.image.version=${t.release.newVersion}`),i.push("--label",`org.opencontainers.image.title=${t.pkg.name}`),i.push("--push",a),{command:i}},ut="https://jsr.io",dt=/^@[a-z0-9-]+\/[a-z0-9-]+$/i,re=async t=>{let e;try{e=await A(t,"utf8")}catch(r){throw new l({cause:r,code:"CONFIG_INVALID",file:t,message:`Failed to read JSR manifest at ${t}: ${r.message}`})}let n;try{n=JSON.parse(e)}catch(r){throw new l({cause:r,code:"CONFIG_INVALID",file:t,message:`Failed to parse JSR manifest at ${t}: ${r.message}`})}if(typeof n.name!="string"||n.name.length===0)throw new l({code:"CONFIG_INVALID",file:t,hint:"JSR manifests must declare a `name` field with the `@scope/name` form.",message:`JSR manifest at ${t} is missing the \`name\` field.`});if(!dt.test(n.name))throw new l({code:"CONFIG_INVALID",file:t,hint:"JSR requires every package to publish under `@scope/name`. Add the `@scope/` prefix and lowercase the name (a-z, 0-9, hyphen).",message:`JSR manifest at ${t} declares an invalid \`name\`: "${n.name}". JSR requires the @scope/name form.`});if(typeof n.version!="string"||n.version.length===0)throw new l({code:"CONFIG_INVALID",file:t,hint:"Add a `version` literal to the JSR manifest, or wire the `jsr()` preset so vis bumps it for you.",message:`JSR manifest at ${t} is missing the \`version\` field.`});return{name:n.name,version:n.version}},se=async(t,e)=>{const n=`${ut}/${t}/meta.json`;try{const r=await j(n,{headers:{Accept:"application/json"},httpProxy:e});if(r.status===404||!r.ok)return;const s=await r.json();return typeof s?.latest=="string"?s.latest:void 0}catch{return}},mt=(t,e)=>z({env:t,staticTokenVar:"JSR_API_KEY",workspaceConfig:e})==="oidc",ae=(t,e)=>{const n=e?.jsrConfigPath??"jsr.json";return h(t.dir,n)};class gt extends N{id="jsr";async readPublishedVersion(e){const n=ae(e.pkg,e.perPackageConfig);try{const{name:r}=await re(n);return await se(r,e.workspaceConfig?.httpProxy)}catch{return}}async publish(e){if(e.dryRun)return{output:`[dry-run / jsr] would publish ${e.pkg.name}@${e.release.newVersion}`,published:!0};const n=ae(e.pkg,e.perPackageConfig),{name:r,version:s}=await re(n);if(s!==e.release.newVersion)throw new l({code:"CONFIG_INVALID",file:n,hint:`Confirm the jsr() preset's manifestPath points at the JSR config file the extra-files rule rewrites. Expected ${e.release.newVersion} on disk after the bump.`,message:`JSR manifest version (${s}) does not match planned release version (${e.release.newVersion}) for ${e.pkg.name}.`,packageName:e.pkg.name});if(await se(r,e.workspaceConfig?.httpProxy)===e.release.newVersion)return{alreadyPublished:!0,output:`[jsr] ${r}@${e.release.newVersion} already on jsr.io`,published:!1};const a=mt(process.env,e.workspaceConfig);if(!a&&!process.env.JSR_API_KEY)throw new l({code:"AUTH_MISSING",hint:"Set JSR_API_KEY for static-token auth, or run from a GH-Actions job with `permissions: id-token: write` so ACTIONS_ID_TOKEN_REQUEST_URL is exposed for OIDC trusted publishing.",message:`Cannot publish ${r}@${e.release.newVersion}: neither JSR_API_KEY nor OIDC trusted publishing is available.`,packageName:e.pkg.name});const i=["jsr","publish","--allow-dirty"],o=e.perPackageConfig?.jsrConfigPath;o!==void 0&&o!=="jsr.json"&&i.push("--config",o);for(const d of e.perPackageConfig?.jsrPublishArgs??[])i.push(d);const c=await e.pm.runner.run("npx",i,{cwd:e.pkg.dir,silent:!1});if(c.exitCode!==0)throw new l({code:"PUBLISH_FAILED",hint:"Inspect the jsr CLI output above. Common causes: invalid JSR_API_KEY, OIDC permission misconfigured, version already published, slow-mode rate limit. Re-runs are safe — the published-version probe short-circuits subsequent runs.",message:`jsr publish failed for ${r}@${e.release.newVersion}: exit ${c.exitCode}. stderr: ${c.stderr.trim().slice(0,500)}`,packageName:e.pkg.name});return{output:`[jsr] published ${r}@${e.release.newVersion}${a?" (trusted publishing)":""}`,published:!0}}}const ht=/<!--[\s\S]*?-->/g,ft=/<project\b[^>]*>([\s\S]*)/i,oe=/<version>\s*([^<]+?)\s*<\/version>/i,ie=/<groupId>\s*([^<]+?)\s*<\/groupId>/i,ce=/<artifactId>\s*([^<]+?)\s*<\/artifactId>/i,wt=/<modules\b[^>]*>[\s\S]*?<module\b/i,pe=t=>{const e=t.replaceAll(ht,""),n=ft.exec(e)?.[1]??e,r=n.replaceAll(/<parent\b[\s\S]*?<\/parent>/gi,"").replaceAll(/<dependencyManagement\b[\s\S]*?<\/dependencyManagement>/gi,"").replaceAll(/<dependencies\b[\s\S]*?<\/dependencies>/gi,"").replaceAll(/<build\b[\s\S]*?<\/build>/gi,"").replaceAll(/<profiles\b[\s\S]*?<\/profiles>/gi,"").replaceAll(/<pluginRepositories\b[\s\S]*?<\/pluginRepositories>/gi,"").replaceAll(/<repositories\b[\s\S]*?<\/repositories>/gi,""),s=oe.exec(r)??oe.exec(n),a=ie.exec(r)??ie.exec(n),i=ce.exec(r)??ce.exec(n),o=wt.test(n);return{artifactId:i?.[1],groupId:a?.[1],hasModules:o,version:s?.[1]}},kt=t=>{const e=/<latest>\s*([^<]+?)\s*<\/latest>/i.exec(t);if(e?.[1])return e[1];const n=/<versions>([\s\S]*?)<\/versions>/i.exec(t);return n?[...n[1].matchAll(/<version>\s*([^<]+?)\s*<\/version>/gi)].map(r=>r[1]).at(-1):void 0},bt=(t,e)=>{const n=t.split(".").map(s=>encodeURIComponent(s)).join("/"),r=encodeURIComponent(e);return`https://repo1.maven.org/maven2/${n}/${r}/maven-metadata.xml`},yt=["Native Maven publishing isn't implemented yet. Drop to the generic shell path:","",' release.packages["<your-pkg>"] = {',' ...pomXml({ pomDir: "jvm/sdk" }),',' versionActions: "shell",',' publishCommand: "mvn -B -ntp deploy",',' checkPublished: "",'," }","","Configure either `central-publishing-maven-plugin` (recommended for","Sonatype Central Portal) or `nexus-staging-maven-plugin` (legacy OSSRH)","in your pom.xml, plus credentials in ~/.m2/settings.xml.","","Maven Central does not (yet) support OIDC trusted publishing —","static credentials are required. See docs/guides/release-maven.mdx","for the full setup walkthrough."].join(`
21
+ `);class $t extends N{id="maven";warnedMultiModule=new WeakSet;warnIfMultiModule(e,n){!n.hasModules||this.warnedMultiModule.has(e)||(this.warnedMultiModule.add(e),process.stderr.write(`[vis release] ⚠ ${e.name} (${n.groupId??"?"}:${n.artifactId??"?"}) is a multi-module Maven project (<modules> present). vis treats it as a single artifact for version-read + already-published checks. For proper reactor handling, use \`versionActions: "shell"\` with \`mvn -B -ntp deploy\`.
22
+ `))}async readPublishedVersion(e){const n=e.perPackageConfig??{},r=h(e.pkg.dir,n.pomPath??"pom.xml");let s;try{s=await A(r,"utf8")}catch{return}const a=pe(s);if(this.warnIfMultiModule(e.pkg,a),!a.groupId||!a.artifactId||n.mavenMetadataUrl==="")return;const i=n.mavenMetadataUrl??bt(a.groupId,a.artifactId);try{const o=await j(i,{headers:{Accept:"text/xml,application/xml;q=0.9,*/*;q=0.8"},httpProxy:e.workspaceConfig?.httpProxy});if(o.status===404||!o.ok)return;const c=await o.text();return kt(c)}catch{return}}async publish(e){const n=e.perPackageConfig??{},r=h(e.pkg.dir,n.pomPath??"pom.xml");let s;try{const o=await A(r,"utf8");s=pe(o)}catch{s=void 0}const a=s?.groupId&&s?.artifactId?`${s.groupId}:${s.artifactId}`:e.pkg.name;if(e.dryRun)return{output:`[dry-run / maven] would publish ${e.pkg.name}@${e.release.newVersion} (${a}) (native publish not yet implemented — would use shell path)`,published:!0};const i=`Failing artifact: ${a}
23
+ Pom: ${r}
24
+
25
+ ${yt}`;throw new l({code:"CONFIG_INVALID",hint:i,message:`Native Maven publishing is not implemented for ${e.pkg.name}@${e.release.newVersion} (${a}). Use \`versionActions: "shell"\` with \`mvn deploy\` until the Sonatype Central Portal client lands.`,packageName:e.pkg.name})}}const be=(t,e)=>{if(e===!1)return{...t};const n=new Set(Me(e)),r={name:t.name,version:t.version};for(const[s,a]of Object.entries(t))n.has(s)||(r[s]=a);return r},ye="https://registry.npmjs.org/",vt="npm:registry.npmjs.org",le=async t=>{const e=h(t,"npm");try{return(await xe(e,{withFileTypes:!0})).filter(n=>n.isDirectory()).map(n=>n.name)}catch{return[]}},It=async t=>{const e=t.ACTIONS_ID_TOKEN_REQUEST_URL,n=t.ACTIONS_ID_TOKEN_REQUEST_TOKEN;if(!e||!n)return;const r=`${e}${e.includes("?")?"&":"?"}audience=${encodeURIComponent(vt)}`,s=await fetch(r,{headers:{Authorization:`Bearer ${n}`}});if(!s.ok)return;const a=await s.json().catch(()=>({}));return typeof a.value=="string"?a.value:void 0},Ct=async(t,e)=>{const n=await fetch(`${ye}-/npm/v1/oidc/token/exchange/package/${encodeURIComponent(t)}`,{headers:{Authorization:`Bearer ${e}`},method:"POST"});if(!n.ok)return;const r=await n.json().catch(()=>({}));return typeof r.token=="string"?r.token:void 0},ue=async(t,e,n)=>{if(e){const s=await Ct(t,e);if(s)return{source:"oidc",token:s}}const r=n.NPM_TOKEN;if(r)return{source:"NPM_TOKEN",token:r};throw new l({code:"AUTH_MISSING",message:`Cannot publish ${t}: OIDC exchange did not succeed and NPM_TOKEN is not set.`,packageName:t})},de=(t,e)=>{Oe(t,`//registry.npmjs.org/:_authToken=${e}
26
+ registry=${ye}
27
+ `)};class Pt extends N{id="native-addon";async readPublishedVersion(e){try{F(e.pkg.name);const{execFileSync:n}=await import("node:child_process");return n("npm",["view",e.pkg.name,"version"],{stdio:["ignore","pipe","ignore"]}).toString().trim()||void 0}catch{return}}async publish(e){if(e.dryRun){const c=await le(e.pkg.dir);return{output:`[dry-run] would publish ${e.pkg.name}@${e.release.newVersion} + ${c.length} platform package(s)`,published:!0}}const n=await le(e.pkg.dir);if(n.length===0){const{NpmVersionActions:c}=await Promise.resolve().then(()=>_t);return new c().publish(e)}const{env:r}=process,s=await It(r),a=e.release.newVersion,i=new Map,o=[];try{await Promise.all(n.map(async g=>{const u=h(e.pkg.dir,"npm",g,"package.json"),f=await A(u,"utf8");i.set(u,f);const $=JSON.parse(f);$.version=a,await O(u,`${JSON.stringify($,null,4)}
28
+ `)}));const{execFileSync:c}=await import("node:child_process"),d=await Promise.all(n.map(async g=>{const u=h(e.pkg.dir,"npm",g),f=h(u,"package.json"),$=await A(f,"utf8"),k=JSON.parse($);F(k.name);const P=await ue(k.name,s,r),v=G(h(B(),"vis-release-napi-"));o.push(v);const S=h(v,".npmrc");return de(S,P.token),{manifest:k,npmrcPath:S,platform:g,platformDir:u}})),p=e.workspaceConfig?.publish?.guards;if(p&&Object.values(p).some(g=>g!==void 0&&g!==!1&&g!=="off")){const{runPublishGuards:g}=await import("./publish-guards.js");for(const{manifest:u,platformDir:f}of d){const $=c("npm",["pack","--dry-run","--json"],{cwd:f,stdio:["ignore","pipe","ignore"]}).toString();let k=[];try{k=JSON.parse($)[0]?.files?.map(v=>v.path)??[]}catch{}const P=await g({config:p,manifest:u,packFiles:k,pkgDir:f,runner:e.pm.runner,sourceManifest:u});if(P.blockers.length>0){const v=P.blockers.flatMap(S=>S.findings.map(D=>` • [${S.gate}] ${D.message}${D.hint?`
29
+ → ${D.hint}`:""}`)).join(`
30
+ `);throw new l({code:"PUBLISH_FAILED",message:`Pre-publish guards failed for ${u.name}@${a} (platform package):
31
+ ${v}`,packageName:u.name})}}}const m=e.tag??"latest",y=(g,u)=>{const f=["publish",g,"--tag",m,"--access","public","--userconfig",u];return e.provenance&&f.push("--provenance"),f};for(const{manifest:g,npmrcPath:u,platformDir:f}of d)try{c("npm",y(f,u),{env:{...r,NPM_CONFIG_USERCONFIG:u},stdio:"inherit"})}catch($){const k=$.message;if(!k.includes("EPUBLISHCONFLICT")&&!k.includes("cannot publish over"))throw new l({cause:$,code:"PUBLISH_FAILED",message:`Failed to publish platform package ${g.name}@${a}: ${k}`,packageName:g.name})}const b=e.versionedManifestByName.get(e.pkg.name)??e.pkg.manifest,w={...b},C={...b.optionalDependencies};for(const{manifest:g}of d)Object.hasOwn(C,g.name)&&(C[g.name]=a);w.optionalDependencies=C;const _=Y(w,e.catalogs),I=be(_,e.cleanPackageJsonConfig),E=await A(e.pkg.manifestPath,"utf8");try{await O(e.pkg.manifestPath,`${JSON.stringify(I,null,4)}
32
+ `),F(e.pkg.name);const g=await ue(e.pkg.name,s,r),u=G(h(B(),"vis-release-napi-parent-"));o.push(u);const f=h(u,".npmrc");de(f,g.token);const $=c("npm",["pack","--pack-destination",u,"--json"],{cwd:e.pkg.dir,env:r,stdio:["ignore","pipe","ignore"]}).toString();let k;try{const v=JSON.parse($);v[0]?.filename&&(k=h(u,v[0].filename))}catch{}const P=["publish",k??e.pkg.dir,"--tag",m,"--access","public","--userconfig",f];if(e.provenance&&P.push("--provenance"),c("npm",P,{env:{...r,NPM_CONFIG_USERCONFIG:f},stdio:"inherit"}),k){const{hashTarball:v}=await import("./publish-guards.js");return{published:!0,tarball:await v(k)}}return{published:!0}}finally{await O(e.pkg.manifestPath,E)}}finally{for(const[c,d]of i)try{await O(c,d)}catch{}for(const c of o)try{await je(c,{force:!0,recursive:!0})}catch{}}}}const St=async(t,e)=>{const{extractPackFilesFromRaw:n}=await import("./publish-guards.js"),r=n(e.raw);if(r!==void 0)return r;const s=await t.pm.runner.run("npm",["pack","--dry-run","--json"],{cwd:t.pkg.dir,silent:!0});if(s.exitCode!==0)return[];try{return n(JSON.parse(s.stdout))??[]}catch{return[]}},me=1800*1e3,ge=15*1e3,he=t=>{if(t===!0)return{enabled:!0,pollIntervalMs:ge,timeoutMs:me};if(t&&typeof t=="object"){const e=t;return{enabled:!0,pollIntervalMs:e.pollIntervalMs??ge,timeoutMs:e.timeoutMs??me}}return{enabled:!1,pollIntervalMs:0,timeoutMs:0}};class $e extends N{id="npm";async readPublishedVersion(e){try{const n=await e.pm.runner.run("npm",["view",e.pkg.name,"version","--silent"],{cwd:e.pkg.dir,silent:!0});return n.exitCode!==0?void 0:n.stdout.trim()||void 0}catch{return}}async publish(e){if(e.dryRun)return{output:`[dry-run] would publish ${e.pkg.name}@${e.release.newVersion}`,published:!0};if(e.resumeStageId){const d=he(e.workspaceConfig?.publish?.stage);if(!d.enabled)throw new l({code:"CONFIG_INVALID",message:`Cannot resume stage ${e.resumeStageId} for ${e.pkg.name}@${e.release.newVersion}: publish.stage is now disabled. Resolve the stage manually via \`vis release stage approve|reject ${e.resumeStageId}\`.`,packageName:e.pkg.name});return this.resumeStagedPublish(e,d)}const n=e.perPackageConfig&&e.workspaceConfig?W(e.pkg.name,e.perPackageConfig,e.workspaceConfig):{};if(n.buildCommand){const d=J(n.buildCommand,{name:e.pkg.name,version:e.release.newVersion}),p=await e.pm.runner.run(process.platform==="win32"?"cmd":"sh",process.platform==="win32"?["/c",d]:["-c",d],{cwd:e.pkg.dir,silent:!1});if(p.exitCode!==0)throw new Error(`buildCommand failed for ${e.pkg.name}: exit ${p.exitCode}`)}const r=e.versionedManifestByName.get(e.pkg.name)??e.pkg.manifest,s=Nt(r,e.versionedManifestByName),a=Y(s,e.catalogs),i=be(a,e.cleanPackageJsonConfig),o=await import("node:fs/promises"),c=await o.readFile(e.pkg.manifestPath,"utf8");try{if(await o.writeFile(e.pkg.manifestPath,`${JSON.stringify(i,null,4)}
33
+ `),n.publishCommand){const p={name:e.pkg.name,version:e.release.newVersion},m=Array.isArray(n.publishCommand)?n.publishCommand:[n.publishCommand];for(const y of m){const b=J(y,p),w=await e.pm.runner.run(process.platform==="win32"?"cmd":"sh",process.platform==="win32"?["/c",b]:["-c",b],{cwd:e.pkg.dir,silent:!1});if(w.exitCode!==0)throw new Error(`publishCommand failed for ${e.pkg.name}: exit ${w.exitCode}`)}return{output:`[custom] published ${e.pkg.name}@${e.release.newVersion}`,published:!0}}const d=G(h(B(),"vis-release-pack-"));try{const p=await e.pm.pack({cwd:e.pkg.dir,destination:d}),m=e.workspaceConfig?.publish?.guards;if(m&&Object.values(m).some(u=>u!==void 0&&u!==!1&&u!=="off")){const{runPublishGuards:u}=await import("./publish-guards.js"),f=await St(e,p),$=await u({config:m,manifest:i,packFiles:f,pkgDir:e.pkg.dir,runner:e.pm.runner,sourceManifest:e.pkg.manifest});if($.blockers.length>0){const{redactTokens:k}=await import("./security.js"),P=$.blockers.flatMap(v=>v.findings.map(S=>` • [${v.gate}] ${k(S.message)}${S.hint?`
34
+ → ${k(S.hint)}`:""}`)).join(`
35
+ `);throw new l({code:"PUBLISH_FAILED",message:`Pre-publish guards failed for ${e.pkg.name}@${e.release.newVersion}:
36
+ ${P}`,packageName:e.pkg.name})}}const{hashTarball:y}=await import("./publish-guards.js"),b=await y(p.tarball);if((e.workspaceConfig?.publish?.publishStrategy??"npm-publish-tarball")==="native"){const u=e.pm.id;return e.provenance&&u==="bun"&&process.stderr.write(`[vis release] ⚠ publishStrategy "native": bun has no --provenance/OIDC support; ${e.pkg.name}@${e.release.newVersion} publishes without provenance.
37
+ `),e.otp&&u==="yarn"&&process.stderr.write(`[vis release] ⚠ publishStrategy "native": \`yarn npm publish\` ignores --otp; configure 2FA via .yarnrc.yml for ${e.pkg.name}.
38
+ `),{...await e.pm.publishNative({access:"public",cwd:e.pkg.dir,otp:e.otp,provenance:e.provenance,registry:e.registry,tag:e.tag}),tarball:b}}const w=he(e.workspaceConfig?.publish?.stage);if(w.enabled){const{refuseRestrictedOidc:u}=await import("./stage-publisher.js"),f=e.pkg.manifest.publishConfig?.access;u(f)}const C=await e.pm.publish({access:"public",otp:e.otp,provenance:e.provenance,registry:e.registry,stage:w.enabled,tag:e.tag,tarball:p.tarball});if(!w.enabled||!C.stageId)return{...C,tarball:b};const{waitForStageDecision:_}=await import("./stage-publisher.js"),{stageId:I}=C,E=Date.now();process.stderr.write(`[vis release] ⏳ ${e.pkg.name}@${e.release.newVersion} staged (id ${I}). Waiting up to ${Math.round(w.timeoutMs/6e4)}m for a maintainer to approve via npmjs.com or \`npm stage approve ${I}\`...
39
+ `);const g=await _({cwd:e.pkg.dir,onProgress:u=>{u>0&&u%3e5<w.pollIntervalMs&&process.stderr.write(`[vis release] still waiting for ${e.pkg.name} stage decision (${Math.round(u/6e4)}m elapsed)...
40
+ `)},packageName:e.pkg.name,pollIntervalMs:w.pollIntervalMs,runner:e.pm.runner,stageId:I,timeoutMs:w.timeoutMs,version:e.release.newVersion});return g==="approved"?(process.stderr.write(`[vis release] ✓ ${e.pkg.name}@${e.release.newVersion} approved + promoted (${Math.round((Date.now()-E)/1e3)}s).
41
+ `),{...C,stageId:void 0,tarball:b}):g==="rejected"?(process.stdout.write(`::warning::Stage rejected for ${e.pkg.name}@${e.release.newVersion} (id ${I}). Re-stage by re-running the release once the review feedback is addressed.
42
+ `),{alreadyPublished:!1,output:`stage-rejected: ${I}`,published:!1,stageId:I}):(process.stdout.write(`::warning::Stage timeout for ${e.pkg.name}@${e.release.newVersion} (id ${I}) after ${Math.round(w.timeoutMs/6e4)}m. Re-run \`vis release publish\` once a maintainer can approve, or run \`vis release stage approve ${I}\` manually.
43
+ `),{alreadyPublished:!1,output:`stage-timeout: ${I}`,published:!1,stageId:I})}finally{await o.rm(d,{force:!0,recursive:!0})}}finally{await o.writeFile(e.pkg.manifestPath,c)}}async resumeStagedPublish(e,n){const r=e.resumeStageId,s=Date.now();process.stderr.write(`[vis release] ↻ Resuming wait on staged ${e.pkg.name}@${e.release.newVersion} (id ${r}) — tarball already uploaded; not re-publishing.
44
+ `);const{waitForStageDecision:a}=await import("./stage-publisher.js"),i=await a({cwd:e.pkg.dir,onProgress:o=>{o>0&&o%3e5<n.pollIntervalMs&&process.stderr.write(`[vis release] still waiting for ${e.pkg.name} stage decision (resume, ${Math.round(o/6e4)}m elapsed)...
45
+ `)},packageName:e.pkg.name,pollIntervalMs:n.pollIntervalMs,runner:e.pm.runner,stageId:r,timeoutMs:n.timeoutMs,version:e.release.newVersion});return i==="approved"?(process.stderr.write(`[vis release] ✓ ${e.pkg.name}@${e.release.newVersion} approved + promoted on resume (${Math.round((Date.now()-s)/1e3)}s).
46
+ `),{output:`[resumed] published ${e.pkg.name}@${e.release.newVersion}`,published:!0}):i==="rejected"?(process.stdout.write(`::warning::Stage rejected on resume for ${e.pkg.name}@${e.release.newVersion} (id ${r}).
47
+ `),{alreadyPublished:!1,output:`stage-rejected: ${r}`,published:!1,stageId:r}):(process.stdout.write(`::warning::Stage timeout on resume for ${e.pkg.name}@${e.release.newVersion} (id ${r}) after ${Math.round(n.timeoutMs/6e4)}m.
48
+ `),{alreadyPublished:!1,output:`stage-timeout: ${r}`,published:!1,stageId:r})}}const At=["dependencies","devDependencies","peerDependencies","optionalDependencies"],Nt=(t,e)=>{const n={...t};for(const r of At){const s=t[r];if(!s||typeof s!="object")continue;const a={...s};for(const[i,o]of Object.entries(s)){if(!o.startsWith("workspace:"))continue;const c=e.get(i);c&&(a[i]=fe(o.slice(10)==="*"?"*":o,c.version),a[i].startsWith("workspace:")&&(a[i]=a[i].slice(10)))}n[r]=a}return n},_t=Object.defineProperty({__proto__:null,NpmVersionActions:$e},Symbol.toStringTag,{value:"Module"});class jt extends N{id="private";async readPublishedVersion(e){}async publish(e){return{output:`[private] skipped publish for ${e.pkg.name}@${e.release.newVersion}`,published:!1}}}const ve=t=>`https://pypi.org/pypi/${encodeURIComponent(t.toLowerCase())}/json`,xt=(t,e)=>e?.uvLockPath?h(t.dir,e.uvLockPath):h(t.dir,"uv.lock"),Vt=async(t,e)=>{let n;try{n=await M(t)}catch{return"no-root-pyproject"}if(n===void 0)return"no-root-pyproject";const r=n.tool?.uv?.workspace?.members;if(!Array.isArray(r)||r.length===0)return"no-workspace";const s=e.replace(/^\.\//,"").replaceAll("\\","/");for(const a of r){if(typeof a!="string")continue;const i=a.replace(/^\.\//,"").replaceAll("\\","/");if(i===s)return"member";if(i.endsWith("/*")){const o=i.slice(0,-2);if(s.startsWith(`${o}/`)&&!s.slice(o.length+1).includes("/"))return"member"}if(i.endsWith("/**")){const o=i.slice(0,-3);if(s===o||s.startsWith(`${o}/`))return"member"}}return"missing"},M=async t=>{const e=h(t,"pyproject.toml");let n;try{n=await A(e,"utf8")}catch(s){const{code:a}=s;if(a==="ENOENT")return;throw new l({cause:s,code:"BUMP_FILE_INVALID",file:e,message:`Failed to read ${e}: ${s.message}`})}const{parse:r}=await import("smol-toml");try{return r(n)}catch(s){throw new l({cause:s,code:"BUMP_FILE_INVALID",file:e,message:`Failed to parse ${e}: ${s.message}`})}},Ie=async(t,e)=>{try{return(await t.run("uv",["--version"],{cwd:e,silent:!0})).exitCode===0}catch{return!1}},Ce=t=>{const e=t?.["build-system"]?.["build-backend"];return e?e.startsWith("hatchling")?"hatch":e.startsWith("poetry.core")||e.startsWith("poetry_core")?"poetry":e.startsWith("pdm.backend")||e.startsWith("pdm_backend")?"pdm":e.startsWith("setuptools")?"setuptools":e.startsWith("uv_build")||e.startsWith("uv.build")?"uv":"unknown":"unknown"},Pe=(t,e)=>t==="uv"||t==="unknown"&&e?{backend:t,buildCommand:{args:["build"],binary:"uv"},hasUv:e,publishCommand:{args:["publish"],binary:"uv"}}:{backend:t,buildCommand:{args:["-m","build"],binary:"python"},hasUv:e,publishCommand:{args:["upload","dist/*"],binary:"twine"}},Se=(t,e)=>z({env:t,staticTokenVar:"TWINE_PASSWORD",workspaceConfig:e}),K=async(t,e)=>{try{const n=await j(ve(t),{headers:{Accept:"application/json"},httpProxy:e});return n.status===404||!n.ok?void 0:(await n.json())?.info?.version}catch{return}},q=(t,e)=>e?.pythonProjectDir?h(t.dir,e.pythonProjectDir):t.dir;class Ae extends N{id="python";async readPublishedVersion(e){const n=q(e.pkg,e.perPackageConfig),r=(await M(n).catch(()=>{}))?.project?.name??e.pkg.name.replace(/^@[^/]+\//,"");return K(r)}async publish(e){if(e.dryRun)return{output:`[dry-run / python] would publish ${e.pkg.name}@${e.release.newVersion}`,published:!0};const n=e.perPackageConfig??{},r=q(e.pkg,n),s=await M(r);if(s?.project?.dynamic?.includes("version"))throw new l({code:"CONFIG_INVALID",file:h(r,"pyproject.toml"),hint:"Dynamic versioning isn't supported by PythonVersionActions yet; use versionActions: 'shell' with your build backend's version-bump tool (e.g. `hatch version` or `poetry version` for non-vcs setups).",message:`${e.pkg.name}: pyproject.toml declares dynamic = ["version", ...]; PythonVersionActions requires a static [project] version.`,packageName:e.pkg.name});if(s?.project?.version&&s.project.version!==e.release.newVersion)throw new l({code:"BUMP_FILE_INVALID",file:h(r,"pyproject.toml"),hint:`Ensure the pyproject() preset is wired up for this package so the version literal in [project] is bumped before publish. Expected ${e.release.newVersion}, found ${s.project.version}.`,message:`${e.pkg.name}: pyproject.toml version ${s.project.version} differs from planned ${e.release.newVersion}.`,packageName:e.pkg.name});const a=s?.project?.name??e.pkg.name.replace(/^@[^/]+\//,"");if(await K(a,e.workspaceConfig?.httpProxy)===e.release.newVersion)return{alreadyPublished:!0,output:`[python] ${a}@${e.release.newVersion} already on PyPI`,published:!1};const i=await Ie(e.pm.runner,e.pkg.dir),o=Ce(s),c=Pe(o,i),d=Se(process.env,e.workspaceConfig);if(d==="missing")throw new l({code:"AUTH_MISSING",hint:["Set TWINE_PASSWORD to a PyPI API token (`TWINE_USERNAME=__token__` is injected automatically), OR","configure trusted publishing on PyPI and grant the workflow `permissions: id-token: write` so ACTIONS_ID_TOKEN_REQUEST_URL is exposed.","See https://docs.pypi.org/trusted-publishers/"].join(" "),message:`${e.pkg.name}: no PyPI credentials detected (neither TWINE_PASSWORD nor OIDC trusted-publishing env).`,packageName:e.pkg.name});const p=await e.pm.runner.run(c.buildCommand.binary,c.buildCommand.args,{cwd:r,silent:!1});if(p.exitCode!==0)throw new l({code:"PUBLISH_FAILED",hint:`Inspect the ${c.buildCommand.binary} ${c.buildCommand.args.join(" ")} output above. Common causes: missing ${c.backend==="uv"?"uv":"build/setuptools/wheel"} dependency, broken pyproject.toml, source files missing from \`include\`.`,message:`${e.pkg.name}: build failed (${c.buildCommand.binary} ${c.buildCommand.args.join(" ")}): exit ${p.exitCode}. stderr: ${p.stderr.trim().slice(0,500)}`,packageName:e.pkg.name});const m={...process.env};d==="token"&&!m.TWINE_USERNAME&&(m.TWINE_USERNAME="__token__");const y=await e.pm.runner.run(c.publishCommand.binary,c.publishCommand.args,{cwd:r,env:m,silent:!1});if(y.exitCode!==0)throw new l({code:"PUBLISH_FAILED",hint:`Inspect the ${c.publishCommand.binary} output above. Common causes: invalid API token, version already published (this should have been caught by readPublishedVersion — file a vis bug), 2FA required without a token.`,message:`${e.pkg.name}: publish failed (${c.publishCommand.binary} ${c.publishCommand.args.join(" ")}): exit ${y.exitCode}. stderr: ${y.stderr.trim().slice(0,500)}`,packageName:e.pkg.name});return{output:`[python/${c.backend}${c.hasUv?"+uv":""}] published ${a}@${e.release.newVersion}`,published:!0}}}const Gt=Object.defineProperty({__proto__:null,PYPI_PROJECT_URL:ve,PythonVersionActions:Ae,checkUvWorkspaceMembership:Vt,detectAuthMode:Se,detectBackend:Ce,detectUv:Ie,fetchPyPiVersion:K,readPyProject:M,resolveBuildEnv:Pe,resolveProjectDir:q,resolveUvLockPath:xt},Symbol.toStringTag,{value:"Module"}),R=async(t,e,n,r)=>{const s=J(n,r),a=process.platform==="win32",i=a?"cmd":"sh",o=a?["/c",s]:["-c",s];return t.run(i,o,{cwd:e,silent:!1})};class Ot extends N{id="shell";async readPublishedVersion(e){const n=e.perPackageConfig??{},{workspaceConfig:r}=e;if(!r)return;const s=W(e.pkg.name,n,r);if(!s.checkPublished)return;const a=await R(e.pm.runner,e.pkg.dir,s.checkPublished,{name:e.pkg.name,version:e.pkg.version});if(a.exitCode!==0)return;const i=a.stdout.trim();return/\b\d+\.\d+\.\d+(?:[-+][\w.+-]+)?\b/.exec(i)?.[0]}async publish(e){if(e.dryRun)return{output:`[dry-run / shell] would publish ${e.pkg.name}@${e.release.newVersion}`,published:!0};const{workspaceConfig:n}=e,r=e.perPackageConfig??{};if(!n)throw new l({code:"CONFIG_INVALID",message:`Shell publish actions for ${e.pkg.name} require a workspace config (release.allowCustomCommands gate).`,packageName:e.pkg.name});const s=W(e.pkg.name,r,n);if(!s.publishCommand)throw new l({code:"CONFIG_INVALID",hint:`Set release.allowCustomCommands (workspace-wide boolean or an allow-list including "${e.pkg.name}") and configure release.packages["${e.pkg.name}"].publishCommand.`,message:`Shell publish actions for ${e.pkg.name} require a publishCommand AND the trust gate to permit it.`,packageName:e.pkg.name});const a={name:e.pkg.name,registry:e.registry,tag:e.tag,version:e.release.newVersion};if(s.checkPublished){const o=await R(e.pm.runner,e.pkg.dir,s.checkPublished,a);if(o.exitCode===0&&/\b\d+\.\d+\.\d+(?:[-+][\w.+-]+)?\b/.exec(o.stdout.trim())?.[0]===e.release.newVersion)return{alreadyPublished:!0,output:`[shell] ${e.pkg.name}@${e.release.newVersion} already on the registry`,published:!1}}if(s.buildCommand){const o=await R(e.pm.runner,e.pkg.dir,s.buildCommand,a);if(o.exitCode!==0)throw new l({code:"PUBLISH_FAILED",message:`buildCommand failed for ${e.pkg.name}: exit ${o.exitCode}. stderr: ${o.stderr.trim().slice(0,500)}`,packageName:e.pkg.name})}const i=Array.isArray(s.publishCommand)?s.publishCommand:[s.publishCommand];for(const o of i){const c=await R(e.pm.runner,e.pkg.dir,o,a);if(c.exitCode!==0)throw new l({code:"PUBLISH_FAILED",hint:"Inspect the publishCommand output above. Common causes: missing auth token, registry unreachable, version already published (re-run safe — `checkPublished` short-circuits subsequent runs).",message:`publishCommand failed for ${e.pkg.name}@${e.release.newVersion}: exit ${c.exitCode}. stderr: ${c.stderr.trim().slice(0,500)}`,packageName:e.pkg.name})}return{output:`[shell] published ${e.pkg.name}@${e.release.newVersion}`,published:!0}}}const Bt=t=>{switch(t){case"cargo":return new at;case"container":return new lt;case"jsr":return new gt;case"maven":return new $t;case"native-addon":return new Pt;case"private":return new jt;case"python":return new Ae;case"shell":return new Ot;default:return new $e}};export{be as a,fe as b,Bt as c,Ue as d,Tt as e,Ut as f,Gt as g,Ke as p,Y as r};
@@ -0,0 +1,9 @@
1
+ import{createRequire as V}from"node:module";import{createShellRunner as G}from"./shell-runner.js";const _=V(import.meta.url),y=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,j=e=>{if(typeof y<"u"&&y.versions&&y.versions.node){const[n,s]=y.versions.node.split(".").map(Number);if(n>22||n===22&&s>=3||n===20&&s>=16)return y.getBuiltinModule(e)}return _(e)},{pathToFileURL:k}=j("node:url"),S=[{section:"Breaking Changes",type:"breaking"},{section:"Features",type:"feat"},{section:"Bug Fixes",type:"fix"},{section:"Performance Improvements",type:"perf"},{section:"Reverts",type:"revert"},{section:"Documentation",type:"docs"},{hidden:!0,section:"Styles",type:"style"},{hidden:!0,section:"Code Refactoring",type:"refactor"},{hidden:!0,section:"Tests",type:"test"},{hidden:!0,section:"Build System",type:"build"},{hidden:!0,section:"Continuous Integration",type:"ci"},{hidden:!0,section:"Miscellaneous Chores",type:"chore"}],W=/^(?<type>[a-z]+)(?:\([^)]+\))?!?:\s+/,E=/^(?:[\p{Emoji_Presentation}\p{Extended_Pictographic}]|:\w+:)\s+/u,D=e=>{const n=e.replace(E,""),s=W.exec(n);if(s?.groups?.type)return n.includes("!:")&&n.split("!:")[0]?.match(/^[a-z]+(?:\([^)]+\))?$/)?"breaking":s.groups.type},P=e=>`(${e.startsWith("@")?e:`@${e}`})`,T=(e,n)=>{for(const s of n){const o=s.line.startsWith("-")||s.line.startsWith("*")?s.line:`- ${s.line}`;e.push(`${o}${s.suffix}`)}},z=(e,n,s)=>{const o=new Map;for(const t of n){const c=t.type??"other",i=o.get(c)??[];i.push({line:t.line,suffix:t.suffix}),o.set(c,i)}for(const t of s){const c=o.get(t.type);if(t.hidden){o.delete(t.type);continue}if(!(!c||c.length===0)){e.push(`### ${t.section}`),e.push("");for(const i of c){const u=i.line.startsWith("-")||i.line.startsWith("*")?i.line:`- ${i.line}`;e.push(`${u}${i.suffix}`)}e.push(""),o.delete(t.type)}}if(!s.some(t=>t.type==="other"&&t.hidden)&&o.size>0){e.push("### Miscellaneous"),e.push("");for(const t of o.values())for(const c of t){const i=c.line.startsWith("-")||c.line.startsWith("*")?c.line:`- ${c.line}`;e.push(`${i}${c.suffix}`)}}},B=(e={})=>n=>{const{changeFiles:s,date:o,release:t,target:c}=n,i=[];c!=="github-release"&&(i.push(`## ${t.newVersion}`),i.push(`<sub>${o}</sub>`),i.push(""));const u=[];for(const r of s){const a=r.body.trim();if(!a)continue;const p=e.authorCredit?r.meta?.author:void 0,h=p?` ${P(p)}`:"";for(const d of a.split(/\r?\n/)){const m=d.trim();m&&u.push({line:m,suffix:h,type:D(m)})}}const f=e.sections===void 0?void 0:e.sections.length===0?S:e.sections;if(f?z(i,u,f):T(i,u),t.isCascadeBump||t.isGroupBump)for(const r of t.sources){const a=t.isCascadeBump?"Cascade from":"Group bump with";i.push(`- ${a} ${r.name}@${r.newVersion}`)}else if(t.isDependencyBump&&s.length===0)for(const r of t.sources)r.newVersion===""?i.push(`- Removed dependency ${r.name}`):i.push(`- Updated dependency ${r.name}@${r.newVersion}`);return i.join(`
2
+ `).replaceAll(/\n{3,}/g,`
3
+
4
+ `).trim()},L=B(),N={includeCommitLink:!0,internalAuthors:[],thankContributors:!0},I=async(e,n,s)=>{if(e)return e;const{createRemoteClient:o,detectRemoteProvider:t}=await import("./detect2.js"),c=await t(s,n,void 0);return o(c).detectRepoSlug(s,n)},M=async(e,n,s)=>{const o=await e.run("git",["log","--diff-filter=A","--pretty=format:%aN%n%aE","--",s],{cwd:n,silent:!0});return o.exitCode!==0?void 0:o.stdout.split(`
5
+ `)[0]?.trim()||void 0},U=(e,n)=>n?e.replaceAll(/(?<!\[)#(\d+)/g,(s,o)=>`[#${o}](https://github.com/${n}/issues/${o})`):e,x=(e={})=>{const n={...N,...e},s=e.runner??G();let o;return async t=>{const{changeFiles:c,date:i,release:u,target:f}=t,r=[],a=new Set,p=process.cwd();o||(o=I(e.repo,s,p));const h=await o;f!=="github-release"&&(r.push(`## ${u.newVersion}`),r.push(`<sub>${i}</sub>`),r.push(""));for(const d of c){const m=d.body.trim(),l=d.meta??{},$=l.author??await M(s,p,d.path);$&&n.thankContributors&&!n.internalAuthors.includes($.replace(/^@/,""))&&a.add($.startsWith("@")?$:`@${$}`);const g=[];if(l.pr&&h?g.push(`[#${l.pr}](https://github.com/${h}/pull/${l.pr})`):l.pr&&g.push(`#${l.pr}`),l.commit&&n.includeCommitLink&&h){const b=l.commit.slice(0,7);g.push(`[\`${b}\`](https://github.com/${h}/commit/${l.commit})`)}const w=g.length>0?` (${g.join(", ")})`:"";if(m)for(const b of m.split(/\r?\n/)){const C=b.trim();if(!C)continue;const v=U(C,h);C.startsWith("-")||C.startsWith("*")?r.push(`${v}${w}`):r.push(`- ${v}${w}`)}}if(u.isCascadeBump||u.isGroupBump)for(const d of u.sources){const m=u.isCascadeBump?"Cascade from":"Group bump with";r.push(`- ${m} ${d.name}@${d.newVersion}`)}else if(u.isDependencyBump&&c.length===0)for(const d of u.sources)d.newVersion===""?r.push(`- Removed dependency ${d.name}`):r.push(`- Updated dependency ${d.name}@${d.newVersion}`);return n.thankContributors&&a.size>0&&(r.push(""),r.push(`Thanks ${[...a].join(", ")}!`)),r.join(`
6
+ `)}},F=["Added","Changed","Deprecated","Removed","Fixed","Security"],q=e=>{const n=e.toLowerCase();return F.find(s=>s.toLowerCase()===n)},K={add:"Added",bugfix:"Fixed",change:"Changed",changed:"Changed",chore:"Changed",deprecate:"Deprecated",deprecated:"Deprecated",feat:"Added",feature:"Added",fix:"Fixed",perf:"Changed",refactor:"Changed",remove:"Removed",removed:"Removed",sec:"Security",security:"Security"},H=/^\s*\[(added|changed|deprecated|removed|fixed|security)\]\s*:?\s*(.*)$/i,J=e=>e.replace(/^[-*]\s+/,"").trim(),O=e=>{const n=/^([a-z]+)(?:\([^)]+\))?!?\s*:\s*(.*)$/i.exec(e.trim());if(!n)return;const s=n[1].toLowerCase(),o=K[s];if(o)return{rest:n[2].trim(),section:o}},Q=e=>e==="major"?"Changed":e==="minor"?"Added":"Fixed",A=(e,n)=>/\bBREAKING(?:\s+CHANGE)?\b/.test(e)||/^\s*[a-z]+(?:\([^)]+\))?!\s*:/i.test(e)||n==="major",X=(e,n,s,o)=>{const t=J(e);if(!t)return;const c=H.exec(t);if(c){const u=q(c[1]);if(u){s[u].push(`- ${c[2].trim()}`);return}}const i=O(t);if(i){A(t,n)&&o.push(`- ${i.rest||t}`),s[i.section].push(`- ${i.rest||t}`);return}A(t,n)&&o.push(`- ${t}`),s[Q(n)].push(`- ${t}`)},Y=(e,n,s,o,t)=>{if(n)return`${n}/compare/${o}...${t}`;if(e)return`https://github.com/${e}/compare/${o}...${t}`},R=(e={})=>n=>{const{changeFiles:s,date:o,release:t,target:c}=n,i={Added:[],Changed:[],Deprecated:[],Fixed:[],Removed:[],Security:[]},u=[],f=t.type;for(const a of s)for(const p of a.body.trim().split(/\r?\n/))p.trim()&&X(p,f,i,u);if(t.isCascadeBump||t.isGroupBump)for(const a of t.sources){const p=t.isCascadeBump?"Cascade from":"Group bump with";i.Changed.push(`- ${p} \`${a.name}\`@${a.newVersion}`)}else if(t.isDependencyBump&&s.length===0)for(const a of t.sources)a.newVersion===""?i.Removed.push(`- Removed dependency \`${a.name}\``):i.Changed.push(`- Updated dependency \`${a.name}\`@${a.newVersion}`);const r=[];if(c!=="github-release"&&(r.push(`## [${t.newVersion}] - ${o}`),r.push("")),u.length>0){r.push("### ⚠ BREAKING CHANGES"),r.push("");for(const a of u)r.push(a);r.push("")}for(const a of F){const p=i[a];if(p.length!==0){r.push(`### ${a}`),r.push("");for(const h of p)r.push(h);r.push("")}}if(c!=="github-release"){const a=`${t.name}@${t.oldVersion}`,p=`${t.name}@${t.newVersion}`,h=Y(e.repo,e.compareUrlPrefix,t.name,a,p);h&&r.push(`[${t.newVersion}]: ${h}`)}return r.join(`
7
+ `).replaceAll(/\n{3,}/g,`
8
+
9
+ `).trimEnd()},te=async(e,n)=>{if(e===!1)return()=>"";if(e===void 0||e==="default")return L;if(e==="github")return x();if(e==="keep-a-changelog"||e==="keepachangelog")return R();let s,o={};if(Array.isArray(e)?[s,o={}]=e:s=e,s==="default")return B(o);if(s==="github")return x(o);if(s==="keep-a-changelog"||s==="keepachangelog")return R(o);const t=s.startsWith(".")?`${n}/${s}`:s,c=k(t).href,{dynamicEsmImport:i}=await import("./dynamic-import.js"),u=await i(c),f=typeof u=="function"?u:u.default;if(typeof f!="function")throw new TypeError(`Custom changelog formatter at ${s} did not export a default function or a callable module.`);if(Array.isArray(e))try{const r=f(o);if(typeof r=="function")return r}catch{}return f};export{te as resolveFormatter};
@@ -0,0 +1 @@
1
+ import{p as e,J as n,K as p}from"./bin.js";const w=({options:o,visConfig:l,workspaceRoot:r})=>{const i=r??process.cwd(),a=l?.security?.policies?.installScripts?.allow??{},s=Object.entries(a).filter(([,t])=>t).map(([t])=>t);s.length===0&&!o.rootOnly&&(e.warn("No approved packages in security.policies.installScripts.allow — nothing to run."),!o.withRoot)||(o.rootOnly||n(i,s),(o.withRoot||o.rootOnly)&&p(i))};export{w as default};
@@ -0,0 +1 @@
1
+ import o from"./index.js";import{VisReleaseError as r}from"../packem_shared/VisReleaseError-DMGRBTNO.js";const g=/^(?:@[a-z0-9-]{1,39}\/)?[a-z0-9._-]{1,214}$/,n=a=>typeof a!="string"||a.length===0||a.length>214||a.startsWith(".")||a.startsWith("_")?!1:g.test(a),h=a=>{if(!n(a))throw new r({code:"CONFIG_INVALID",message:`Invalid package name: ${JSON.stringify(a)}. Must match ^(@scope/)?[a-z0-9._-]+$ and be ≤ 214 chars (npm spec).`,packageName:typeof a=="string"?a:void 0})},c=a=>`'${a.replaceAll("'",String.raw`'\''`)}'`,m=a=>`"${a.replaceAll('"','""')}"`,l=(a,e=process.platform==="win32")=>e?m(a):c(a),i=(a,e)=>{const s=e.allowCustomCommands;return s===void 0||s===!1?!1:s===!0?!0:Array.isArray(s)?s.some(t=>a===t||o(t,a)):!1},u=(a,e,s=process.platform==="win32")=>a.replaceAll("{{name}}",l(e.name,s)).replaceAll("{{version}}",l(e.version,s)).replaceAll("{{tag}}",l(e.tag??"",s)).replaceAll("{{registry}}",l(e.registry??"",s)),p=[/\bnpm_[A-Za-z0-9]{20,}/g,/\bghp_[A-Za-z0-9]{20,}/g,/\bgho_[A-Za-z0-9]{20,}/g,/\bghs_[A-Za-z0-9]{20,}/g,/\bghu_[A-Za-z0-9]{20,}/g,/\bgithub_pat_\w{70,}/g,/\bglpat-[\w-]{20,}/g,/\bAKIA[0-9A-Z]{16}\b/g,/\bASIA[0-9A-Z]{16}\b/g,/\bcio[A-Za-z0-9]{40,}/g,/\bpypi-AgEIcHlwaS5vcmcCJ[\w-]+/g,/ACTIONS_ID_TOKEN_REQUEST_TOKEN=\S+/g,/\b_authToken=\S+/g,/\bBasic\s+[A-Za-z0-9+/=]{16,}/g,/--otp[= ]\S+/g,/\bone[- ]time password:?\s*\d{6,}/gi,/\bEOTP\s+\d{6,}/g,/Bearer (?!\[REDACTED\])[^\s"']+/g],C=a=>{let e=a;for(const s of p)e=e.replaceAll(s,"[REDACTED]");return e},A={"&":"&amp;","<":"&lt;",">":"&gt;"},_=a=>{let e=a.replaceAll(/[<>&]/g,s=>A[s]??s);return e=e.replaceAll("`","\\`"),e},f=(a,e,s)=>i(a,s)?{buildCommand:e.buildCommand,checkPublished:e.checkPublished,publishCommand:e.publishCommand}:{};export{h as assertValidPackageName,m as cmdq,_ as escapeMarkdown,u as interpolateCommand,i as isCustomCommandAllowed,n as isValidPackageName,C as redactTokens,f as resolveCustomCommands,l as shellQuote,c as sq};
@@ -0,0 +1 @@
1
+ import{x as c}from"tinyexec";import{redactTokens as o}from"./security.js";const h=()=>({run:async(s,t,r)=>{try{const e=await c(s,[...t],{nodeOptions:{cwd:r.cwd,env:{...process.env,...r.env},stdio:r.silent?["ignore","pipe","pipe"]:"inherit"},throwOnError:!1});return{exitCode:typeof e.exitCode=="number"?e.exitCode:-1,stderr:o(e.stderr??""),stdout:o(e.stdout??"")}}catch(e){return{exitCode:-1,stderr:o(e.message),stdout:""}}}}),f=()=>new a;class a{handlers=[];on(t,r,e){this.handlers.push({argsPrefix:r,command:t,respond:e})}async run(t,r,e){for(const n of this.handlers)if(!(n.command!==t||r.length<n.argsPrefix.length)&&n.argsPrefix.every((d,i)=>d===r[i]))return n.respond(e.cwd);return{exitCode:0,stderr:"",stdout:""}}}export{a as MockRunner,f as createMockRunner,h as createShellRunner};
@@ -0,0 +1,2 @@
1
+ import{expandNotificationTemplate as r}from"./interface.js";const l=n=>n.url?`• <${n.url}|${n.name}@${n.version}>`:`• ${n.name}@${n.version}`;class m{constructor(t){this.config=t,this.id=t.id?`slack:${t.id}`:"slack"}config;id;async send(t){const c=this.config.title?r(this.config.title,t):`🚀 Released ${t.published.length} package${t.published.length===1?"":"s"}`,i=[{text:{text:c,type:"plain_text"},type:"header"}];t.published.length>0&&i.push({text:{text:t.published.map(e=>l(e)).join(`
2
+ `),type:"mrkdwn"},type:"section"});const o=[];t.channel&&o.push(`channel: \`${t.channel}\``),t.repo&&o.push(`<https://github.com/${t.repo}|${t.repo}>`);const a=Date.parse(t.completedAt);Number.isFinite(a)?o.push(`<!date^${Math.floor(a/1e3)}^{date_short_pretty} at {time}|${t.completedAt}>`):o.push(t.completedAt),i.push({elements:[{text:o.join(" • "),type:"mrkdwn"}],type:"context"}),t.skipped.length>0&&this.config.includeSkipped!==!1&&(i.push({type:"divider"}),i.push({text:{text:`*Skipped (${t.skipped.length}):* ${t.skipped.map(e=>`\`${e.name}\` (${e.reason})`).join(", ")}`,type:"mrkdwn"},type:"section"}));const h={blocks:i,text:c,...this.config.channelOverride?{channel:this.config.channelOverride}:{},...this.config.username?{username:this.config.username}:{},...this.config.iconEmoji?{icon_emoji:this.config.iconEmoji}:{}};let s;try{s=await fetch(this.config.webhook,{body:JSON.stringify(h),headers:{"Content-Type":"application/json"},method:"POST"})}catch(e){const p=e instanceof Error?e.name:"NetworkError";throw new Error(`Slack webhook fetch failed (${p})`,{cause:e})}if(!s.ok){const e=await s.text().catch(()=>"");throw new Error(`Slack webhook returned ${s.status} ${s.statusText}${e?`: ${e.slice(0,200)}`:""}`)}}}export{m as SlackNotificationChannel};
@@ -0,0 +1,2 @@
1
+ import{createRequire as O}from"node:module";import{DEFAULT_CHANGES_DIR as G}from"./DEFAULT_CLEAN_KEEP.js";import{p as $,r as Q,a as X,b as Y}from"./registry.js";import{getCurrentSha as z,getShortSha as K}from"./git.js";import{N as Z}from"./detect.js";const J=O(import.meta.url),u=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,U=s=>{if(typeof u<"u"&&u.versions&&u.versions.node){const[e,r]=u.versions.node.split(".").map(Number);if(e>22||e===22&&r>=3||e===20&&r>=16)return u.getBuiltinModule(s)}return J(s)},{readFile:W,writeFile:N}=U("node:fs/promises"),ee=(s,e)=>s.replaceAll("{tag}",e.tag).replaceAll("{sha}",e.sha).replaceAll("{shortSha}",e.shortSha).replaceAll("{branch}",e.branch??"").replaceAll("{pr}",e.pr??"").replaceAll("{timestamp}",e.timestamp),ce=async s=>{const{context:e,dryRun:r=!1,registry:g,tag:n}=s,{createShellRunner:c}=await import("./shell-runner.js"),o=s.runner??c(),l=await z({cwd:e.cwd,runner:o}),i=await K({cwd:e.cwd,runner:o});if(!l||!i)throw new Error("Could not resolve git HEAD. Snapshot requires a git workspace.");const w=e.config.snapshot?.versionTemplate??"0.0.0-{tag}-{shortSha}",A=new Date().toISOString().replaceAll(/[:.]/g,"").slice(0,14),m=e.config.snapshot?.tags??[],p=await o.run("git",["rev-parse","--abbrev-ref","HEAD"],{cwd:e.cwd,silent:!0}).then(t=>t.exitCode===0?t.stdout.trim():void 0).catch(()=>{}),S=process.env.VIS_PR_NUMBER??process.env.PR_NUMBER,R=[n];for(const t of m){let a;switch(t){case"branch":{a=p&&p!=="HEAD"?p:void 0;break}case"pr":{a=S?`pr-${S}`:void 0;break}case"sha":{a=l;break}case"short-sha":{a=i;break}default:a=void 0}a&&a!==n&&!R.includes(a)&&R.push(a)}let f=e.packages;if(s.filter){const{default:t}=await import("./index.js"),a=s.filter.split(",").map(h=>h.trim()).filter(Boolean);f=f.filter(h=>a.some(y=>h.name===y||t(y,h.name)))}f=f.filter(t=>!t.private);const d=ee(w,{branch:p&&p!=="HEAD"?p:void 0,pr:S,sha:l,shortSha:i,tag:n,timestamp:A}),P=new Map;for(const t of f)P.set(t.name,{...t.manifest,version:d});const F=$(await e.pm.readCatalogYaml(e.cwd)),H=new Z(o),b=[],v=[],k=[],j=e.config.changesDir??G,{acquireLock:T,releaseLock:q}=await import("./state.js");let C=!1;if(!r)try{await T(e.cwd,j),C=!0}catch(t){return k.push({name:"_lock",reason:t.message}),{failed:k,published:b,skipped:v,snapshotVersion:d,tag:n}}try{for(const t of f){const a=ae(t,P),h=Q(a,F),y=X(h,e.config.publish?.cleanPackageJson);if(r){b.push({name:t.name,version:d});continue}let D;try{D=await W(t.manifestPath,"utf8"),await N(t.manifestPath,`${JSON.stringify(y,null,4)}
2
+ `);const{mkdtempSync:E}=await import("node:fs"),{tmpdir:x}=await import("node:os"),{join:B}=await import("node:path"),M=E(B(x(),"vis-snapshot-")),V=await e.pm.pack({cwd:t.dir,destination:M});let _;for(const I of R){const L=await H.publish({access:"public",extraArgs:["--no-git-checks"],registry:g,tag:I,tarball:V.tarball});_??=L}_?.published?b.push({name:t.name,version:d}):_?.alreadyPublished?v.push({name:t.name,reason:"already-published"}):v.push({name:t.name,reason:_?.output??"unknown"})}catch(E){k.push({name:t.name,reason:E.message})}finally{if(D!==void 0)try{await N(t.manifestPath,D)}catch{}}}}finally{C&&await q(e.cwd,j)}return{failed:k,published:b,skipped:v,snapshotVersion:d,tag:n}},te=["dependencies","devDependencies","peerDependencies","optionalDependencies"],ae=(s,e)=>{const r=e.get(s.name)??s.manifest,g={...r};for(const n of te){const c=r[n];if(!c||typeof c!="object")continue;const o={...c};for(const[l,i]of Object.entries(c)){const w=e.get(l);if(w&&i.startsWith("workspace:")){const A=i.slice(10),m=Y(A==="*"?"*":i,w.version);o[l]=m.startsWith("workspace:")?m.slice(10):m}}g[n]=o}return g};export{ce as runSnapshot};
@@ -0,0 +1 @@
1
+ import{createRequire as n}from"node:module";import{VisReleaseError as d}from"../packem_shared/VisReleaseError-DMGRBTNO.js";const a=n(import.meta.url),o=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,c=e=>{if(typeof o<"u"&&o.versions&&o.versions.node){const[t,s]=o.versions.node.split(".").map(Number);if(t>22||t===22&&s>=3||t===20&&s>=16)return o.getBuiltinModule(e)}return a(e)},{setTimeout:u}=c("node:timers/promises"),f=async e=>{const t=Date.now(),s=r=>{const i=r.trim();if(!i)return!1;try{return typeof JSON.parse(i).id=="string"}catch{return!1}};for(;Date.now()-t<e.timeoutMs;){const r=await e.runner.run("npm",["stage","view",e.stageId,"--json"],{cwd:e.cwd,silent:!0});if(!(r.exitCode===0&&s(r.stdout))){const i=await e.runner.run("npm",["view",`${e.packageName}@${e.version}`,"dist.tarball","--silent"],{cwd:e.cwd,silent:!0});return i.exitCode===0&&i.stdout.trim()?"approved":"rejected"}e.onProgress?.(Date.now()-t),await u(e.pollIntervalMs)}return"timeout"},m=(e,t=process.env)=>{const s=e==="restricted",r=!!t.ACTIONS_ID_TOKEN_REQUEST_URL&&!t.NPM_TOKEN;if(s&&r)throw new d({code:"CONFIG_INVALID",hint:"Either set publish.stage: false, or fall back to NPM_TOKEN authentication (export NPM_TOKEN; trusted publishing on restricted packages is tracked for a future release).",message:"publish.stage with OIDC trusted publishing is not supported for restricted-access packages in v1."})};export{m as refuseRestrictedOidc,f as waitForStageDecision};
@@ -0,0 +1,2 @@
1
+ import{createRequire as S}from"node:module";import{VisReleaseError as l}from"../packem_shared/VisReleaseError-DMGRBTNO.js";const w=S(import.meta.url),o=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,p=e=>{if(typeof o<"u"&&o.versions&&o.versions.node){const[n,r]=o.versions.node.split(".").map(Number);if(n>22||n===22&&r>=3||n===20&&r>=16)return o.getBuiltinModule(e)}return w(e)},{readFile:h,unlink:v,mkdir:_,writeFile:N}=p("node:fs/promises"),{dirname:k,join:O}=p("node:path"),y=(e,n)=>O(e,n,"staged.json"),R=()=>({pending:[],recentlyNotified:[],recentlyWalked:[],updatedAt:new Date().toISOString(),version:1}),c=100,T=720*60*60*1e3,u=(e,n=Date.now())=>{if(!e||e.length===0)return[];const r=n-T,t=e.filter(i=>{const a=Date.parse(i.at);return Number.isFinite(a)&&a>=r});return t.length<=c?t:[...t].sort((i,a)=>Date.parse(a.at)-Date.parse(i.at)).slice(0,c)},P=async(e,n)=>{const r=y(e,n);let t;try{t=await h(r,"utf8")}catch(a){if(a.code==="ENOENT")return R();throw new l({cause:a,code:"STATE_FILE_CORRUPT",message:`Failed to read staged registry at ${r}: ${a.message}`})}let i;try{i=JSON.parse(t)}catch(a){throw new l({cause:a,code:"STATE_FILE_CORRUPT",message:`Staged registry at ${r} is not valid JSON: ${a.message}. Remove the file or fix it manually.`})}if(i.version!==1)throw new l({code:"STATE_FILE_CORRUPT",message:`Staged registry at ${r} reports unknown version ${i.version}. Upgrade vis or remove the file.`});if(!Array.isArray(i.pending))throw new l({code:"STATE_FILE_CORRUPT",message:`Staged registry at ${r} is missing the "pending" array.`});return i},F=async(e,n,r)=>{const t=y(e,n);let i;try{const d=await h(t,"utf8");i=JSON.parse(d)}catch{i=void 0}const a=u(r.recentlyNotified),s=u(r.recentlyWalked),g={...r,recentlyNotified:a,recentlyWalked:s};if(g.pending.length===0&&a.length===0&&s.length===0){if(i===void 0)return{changed:!1,path:t,removed:!1};try{await v(t)}catch(d){if(d.code!=="ENOENT")throw d}return{changed:!0,path:t,removed:!0}}if(i&&E(i,g))return{changed:!1,path:t,removed:!1};await _(k(t),{recursive:!0});const m=`${JSON.stringify({...g,updatedAt:new Date().toISOString()},null,2)}
2
+ `;return await N(t,m),{changed:!0,path:t,removed:!1}},W=(e,n,r=new Date().toISOString())=>{if(n.length===0)return e;const t=e.recentlyNotified??[],i=new Set(t.map(s=>s.key)),a=n.filter(s=>!i.has(s)).map(s=>({at:r,key:s}));return a.length===0?e:{...e,recentlyNotified:[...t,...a],updatedAt:r}},$=(e,n,r=new Date().toISOString())=>{if(n.length===0)return e;const t=e.recentlyWalked??[],i=new Set(t.map(s=>s.key)),a=n.filter(s=>!i.has(s)).map(s=>({at:r,key:s}));return a.length===0?e:{...e,recentlyWalked:[...t,...a],updatedAt:r}},j=(e,n)=>{if(n.length===0)return e;const r=new Map(e.pending.map(t=>[t.id,t]));for(const t of n)r.set(t.id,t);return{...e,pending:[...r.values()],updatedAt:new Date().toISOString()}},C=(e,n)=>{if(n.length===0||e.pending.length===0)return e;const r=new Set(n),t=e.pending.filter(i=>!r.has(i.id));return t.length===e.pending.length?e:{...e,pending:t,updatedAt:new Date().toISOString()}},b=(e,n)=>{if(e.pending.length===0||n.length===0)return[];const r=new Set(n);return e.pending.filter(t=>r.has(t.name))},f=(e,n)=>{const r=e??[],t=n??[];if(r.length!==t.length)return!1;if(r.length===0)return!0;const i=new Map(r.map(a=>[a.key,a]));for(const a of t)if(i.get(a.key)?.at!==a.at)return!1;return!0},E=(e,n)=>A(e.pending,n.pending)&&f(e.recentlyNotified,n.recentlyNotified)&&f(e.recentlyWalked,n.recentlyWalked),A=(e,n)=>{if(e.length!==n.length)return!1;if(e.length===0)return!0;const r=new Map(e.map(t=>[t.id,t]));for(const t of n){const i=r.get(t.id);if(!i||i.name!==t.name||i.version!==t.version||i.reason!==t.reason||(i.tag??"latest")!==(t.tag??"latest"))return!1}return!0};export{b as findConflictingPendingStages,A as pendingSetsEqual,u as pruneOldEntries,P as readStagedRegistry,W as recordRecentlyNotified,$ as recordRecentlyWalked,E as registryContentsEqual,C as removePendingStages,y as stagedRegistryPath,j as upsertPendingStages,F as writeStagedRegistry};
@@ -0,0 +1,3 @@
1
+ import{createRequire as E}from"node:module";import{VisReleaseError as o}from"../packem_shared/VisReleaseError-DMGRBTNO.js";const S=E(import.meta.url),i=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,l=t=>{if(typeof i<"u"&&i.versions&&i.versions.node){const[a,e]=i.versions.node.split(".").map(Number);if(a>22||a===22&&e>=3||a===20&&e>=16)return i.getBuiltinModule(t)}return S(t)},{constants:u}=l("node:fs"),{mkdir:w,readFile:p,unlink:d,open:R,writeFile:O}=l("node:fs/promises"),{platform:$,hostname:h}=l("node:os"),{dirname:m,join:y}=l("node:path"),c=(t,a)=>y(t,a,".state.json"),N=async(t,a)=>{try{const e=await p(c(t,a),"utf8"),s=JSON.parse(e);if(s.version!==1)throw new o({code:"STATE_FILE_CORRUPT",message:`Unknown state file version: ${s.version}. Delete ${c(t,a)} to start fresh.`});return s}catch(e){if(e.code==="ENOENT")return;throw e instanceof o?e:new o({cause:e,code:"STATE_FILE_CORRUPT",message:`Failed to read state file: ${e.message}`})}},P=async(t,a,e)=>{const s=c(t,a);await w(m(s),{recursive:!0}),await O(s,`${JSON.stringify(e,null,2)}
2
+ `)},C=async(t,a)=>{try{await d(c(t,a))}catch(e){if(e.code!=="ENOENT")throw new o({cause:e,code:"STATE_FILE_CORRUPT",message:`Could not clear state file at ${c(t,a)}: ${e.message}. Remove it manually before the next run.`})}},I=(t,a)=>({applied:[],channel:t,notified:[],plan:[...a],published:[],pushed:!1,startedAt:new Date().toISOString(),tagged:[],version:1,walked:[]}),L=(t,a)=>{const e=new Set(a.published);return t.filter(s=>!e.has(`${s.name}@${s.newVersion}`))},k=3600*1e3,_=(t,a)=>y(t,a,".lock"),v=t=>{try{return process.kill(t,0),!0}catch{return!1}},b=async(t,a)=>{const e=_(t,a);await w(m(e),{recursive:!0});const s={acquiredAt:new Date().toISOString(),hostname:h(),pid:process.pid,platform:$()},T=`${JSON.stringify(s,null,2)}
3
+ `,f=async()=>{try{const n=await R(e,u.O_WRONLY|u.O_CREAT|u.O_EXCL,384);try{await n.writeFile(T)}finally{await n.close()}return!0}catch(n){if(n.code==="EEXIST")return!1;throw n}};if(await f())return e;let r;try{r=JSON.parse(await p(e,"utf8"))}catch{}if(r){const n=Date.now()-new Date(r.acquiredAt).getTime();if((!r.hostname||r.hostname===h())&&v(r.pid)&&n<k){const g=r.hostname?`${r.hostname}:${r.pid}`:`PID ${r.pid}`;throw new o({code:"STATE_FILE_CORRUPT",message:`Release lock held by ${g} (acquired ${Math.round(n/1e3)}s ago). Wait for the other run, or remove ${e} if you're sure it's stale.`})}}try{await d(e)}catch{}if(await f())return e;throw new o({code:"STATE_FILE_CORRUPT",message:`Could not acquire release lock at ${e} after clearing a stale entry. Another process took it. Retry in a few seconds.`})},q=async(t,a)=>{try{await d(_(t,a))}catch{}};export{b as acquireLock,C as clearState,L as filterPlanByState,_ as lockFilePath,I as newState,N as readState,q as releaseLock,c as stateFilePath,P as writeState};