@intentius/chant 0.124.100 → 0.124.102

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 (270) hide show
  1. package/dist/action-pins.d.ts +2 -0
  2. package/dist/action-pins.js +3 -0
  3. package/dist/ci-detect.d.ts +13 -0
  4. package/dist/ci-detect.js +12 -0
  5. package/dist/ci-evidence-claims.d.ts +12 -0
  6. package/dist/ci-evidence-claims.js +12 -0
  7. package/dist/ci-system.d.ts +66 -0
  8. package/dist/ci-system.js +61 -0
  9. package/dist/cli/handlers/build.js +27 -0
  10. package/dist/cli/handlers/release-doctor.d.ts +12 -0
  11. package/dist/cli/handlers/release-doctor.js +118 -0
  12. package/dist/cli/handlers/release-init.d.ts +10 -0
  13. package/dist/cli/handlers/release-init.js +374 -0
  14. package/dist/cli/handlers/release.d.ts +43 -2
  15. package/dist/cli/handlers/release.js +667 -39
  16. package/dist/cli/handlers/run-generate.js +11 -0
  17. package/dist/cli/main.d.ts +2 -0
  18. package/dist/cli/main.js +44 -101
  19. package/dist/cli/parse-args.js +48 -0
  20. package/dist/cli/registry.d.ts +16 -0
  21. package/dist/cli/release-commands/artifacts.d.ts +3 -0
  22. package/dist/cli/release-commands/artifacts.js +14 -0
  23. package/dist/cli/release-commands/candidates.d.ts +3 -0
  24. package/dist/cli/release-commands/candidates.js +16 -0
  25. package/dist/cli/release-commands/changed.d.ts +3 -0
  26. package/dist/cli/release-commands/changed.js +14 -0
  27. package/dist/cli/release-commands/compose.d.ts +3 -0
  28. package/dist/cli/release-commands/compose.js +16 -0
  29. package/dist/cli/release-commands/cut.d.ts +3 -0
  30. package/dist/cli/release-commands/cut.js +50 -0
  31. package/dist/cli/release-commands/doctor.d.ts +3 -0
  32. package/dist/cli/release-commands/doctor.js +14 -0
  33. package/dist/cli/release-commands/export.d.ts +3 -0
  34. package/dist/cli/release-commands/export.js +12 -0
  35. package/dist/cli/release-commands/images.d.ts +3 -0
  36. package/dist/cli/release-commands/images.js +13 -0
  37. package/dist/cli/release-commands/index.d.ts +8 -0
  38. package/dist/cli/release-commands/index.js +52 -0
  39. package/dist/cli/release-commands/init.d.ts +3 -0
  40. package/dist/cli/release-commands/init.js +19 -0
  41. package/dist/cli/release-commands/list.d.ts +3 -0
  42. package/dist/cli/release-commands/list.js +10 -0
  43. package/dist/cli/release-commands/next.d.ts +3 -0
  44. package/dist/cli/release-commands/next.js +13 -0
  45. package/dist/cli/release-commands/publish.d.ts +3 -0
  46. package/dist/cli/release-commands/publish.js +22 -0
  47. package/dist/cli/release-commands/stamp.d.ts +3 -0
  48. package/dist/cli/release-commands/stamp.js +15 -0
  49. package/dist/cli/release-commands/status.d.ts +3 -0
  50. package/dist/cli/release-commands/status.js +17 -0
  51. package/dist/cli/release-commands/tag.d.ts +3 -0
  52. package/dist/cli/release-commands/tag.js +12 -0
  53. package/dist/cli/release-commands/types.d.ts +20 -0
  54. package/dist/cli/release-commands/types.js +1 -0
  55. package/dist/cli/release-commands/verify.d.ts +3 -0
  56. package/dist/cli/release-commands/verify.js +15 -0
  57. package/dist/cli/release-commands/workflow.d.ts +3 -0
  58. package/dist/cli/release-commands/workflow.js +15 -0
  59. package/dist/cloud-lister/index.d.ts +4 -1
  60. package/dist/cloud-lister/index.js +2 -1
  61. package/dist/cloud-lister/kubernetes-components.d.ts +56 -0
  62. package/dist/cloud-lister/kubernetes-components.js +642 -0
  63. package/dist/cloud-lister/kubernetes.d.ts +18 -0
  64. package/dist/cloud-lister/kubernetes.js +26 -1
  65. package/dist/cloud-lister/mask.d.ts +5 -1
  66. package/dist/cloud-lister/mask.js +14 -5
  67. package/dist/components/cli-support.d.ts +1 -1
  68. package/dist/components/cli-support.js +1 -1
  69. package/dist/config-environments.d.ts +8 -1
  70. package/dist/config-environments.js +2 -0
  71. package/dist/config-import.d.ts +1 -1
  72. package/dist/config-import.js +6 -2
  73. package/dist/config-sandbox.d.ts +1 -1
  74. package/dist/config-sandbox.js +3 -3
  75. package/dist/config.d.ts +369 -10
  76. package/dist/config.js +127 -7
  77. package/dist/deep-observation.js +9 -3
  78. package/dist/floor-table.data.js +21 -1
  79. package/dist/forge-remote.d.ts +13 -0
  80. package/dist/forge-remote.js +15 -0
  81. package/dist/lexicon.d.ts +45 -4
  82. package/dist/lifecycle/__fixtures__/package-files.d.ts +32 -0
  83. package/dist/lifecycle/__fixtures__/package-files.js +72 -0
  84. package/dist/lifecycle/__fixtures__/publish-fakes.d.ts +62 -0
  85. package/dist/lifecycle/__fixtures__/publish-fakes.js +275 -3
  86. package/dist/lifecycle/publish-attachments.d.ts +2 -1
  87. package/dist/lifecycle/publish-attachments.js +19 -2
  88. package/dist/lifecycle/publish-cargo.d.ts +99 -0
  89. package/dist/lifecycle/publish-cargo.js +412 -0
  90. package/dist/lifecycle/publish-credentials.d.ts +1 -1
  91. package/dist/lifecycle/publish-credentials.js +13 -0
  92. package/dist/lifecycle/publish-declaration.d.ts +322 -4
  93. package/dist/lifecycle/publish-declaration.js +340 -9
  94. package/dist/lifecycle/publish-forge.d.ts +45 -2
  95. package/dist/lifecycle/publish-forge.js +434 -34
  96. package/dist/lifecycle/publish-git-ssh.d.ts +15 -0
  97. package/dist/lifecycle/publish-git-ssh.js +30 -4
  98. package/dist/lifecycle/publish-github.d.ts +40 -2
  99. package/dist/lifecycle/publish-github.js +100 -3
  100. package/dist/lifecycle/publish-helm.d.ts +83 -0
  101. package/dist/lifecycle/publish-helm.js +452 -0
  102. package/dist/lifecycle/publish-homebrew.d.ts +7 -9
  103. package/dist/lifecycle/publish-homebrew.js +34 -197
  104. package/dist/lifecycle/publish-index.d.ts +141 -0
  105. package/dist/lifecycle/publish-index.js +719 -0
  106. package/dist/lifecycle/publish-marketplace.js +77 -0
  107. package/dist/lifecycle/publish-maven.d.ts +79 -0
  108. package/dist/lifecycle/publish-maven.js +364 -0
  109. package/dist/lifecycle/publish-mcp-registry.d.ts +66 -0
  110. package/dist/lifecycle/publish-mcp-registry.js +305 -0
  111. package/dist/lifecycle/publish-npm.d.ts +27 -1
  112. package/dist/lifecycle/publish-npm.js +216 -3
  113. package/dist/lifecycle/publish-nuget.d.ts +93 -0
  114. package/dist/lifecycle/publish-nuget.js +377 -0
  115. package/dist/lifecycle/publish-oci.d.ts +91 -2
  116. package/dist/lifecycle/publish-oci.js +247 -8
  117. package/dist/lifecycle/publish-package-files.d.ts +16 -0
  118. package/dist/lifecycle/publish-package-files.js +39 -0
  119. package/dist/lifecycle/publish-pypi.d.ts +138 -0
  120. package/dist/lifecycle/publish-pypi.js +657 -0
  121. package/dist/lifecycle/publish-record.d.ts +6 -3
  122. package/dist/lifecycle/publish-record.js +6 -3
  123. package/dist/lifecycle/publish-rubygems.d.ts +84 -0
  124. package/dist/lifecycle/publish-rubygems.js +366 -0
  125. package/dist/lifecycle/publish-signing.d.ts +147 -0
  126. package/dist/lifecycle/publish-signing.js +257 -0
  127. package/dist/lifecycle/publish-targets.d.ts +37 -1
  128. package/dist/lifecycle/publish-targets.js +102 -0
  129. package/dist/lifecycle/publish-tauri.js +43 -0
  130. package/dist/lifecycle/publish-train-names.d.ts +57 -0
  131. package/dist/lifecycle/publish-train-names.js +123 -0
  132. package/dist/lifecycle/publish-verify.d.ts +121 -0
  133. package/dist/lifecycle/publish-verify.js +130 -0
  134. package/dist/lifecycle/query.js +8 -0
  135. package/dist/lifecycle/release-artifacts.d.ts +290 -0
  136. package/dist/lifecycle/release-artifacts.js +808 -0
  137. package/dist/lifecycle/release-changelog.d.ts +13 -1
  138. package/dist/lifecycle/release-changelog.js +35 -2
  139. package/dist/lifecycle/release-cut.d.ts +64 -4
  140. package/dist/lifecycle/release-cut.js +147 -34
  141. package/dist/lifecycle/release-doctor.d.ts +113 -0
  142. package/dist/lifecycle/release-doctor.js +1198 -0
  143. package/dist/lifecycle/release-green.d.ts +86 -0
  144. package/dist/lifecycle/release-green.js +286 -0
  145. package/dist/lifecycle/release-init-registries.d.ts +48 -0
  146. package/dist/lifecycle/release-init-registries.js +97 -0
  147. package/dist/lifecycle/release-init.d.ts +275 -0
  148. package/dist/lifecycle/release-init.js +984 -0
  149. package/dist/lifecycle/release-intents.d.ts +73 -0
  150. package/dist/lifecycle/release-intents.js +128 -0
  151. package/dist/lifecycle/release-next.d.ts +111 -0
  152. package/dist/lifecycle/release-next.js +251 -0
  153. package/dist/lifecycle/release-prerelease.d.ts +19 -0
  154. package/dist/lifecycle/release-prerelease.js +30 -0
  155. package/dist/lifecycle/release-publish.d.ts +256 -10
  156. package/dist/lifecycle/release-publish.js +247 -35
  157. package/dist/lifecycle/release-status-change.d.ts +226 -0
  158. package/dist/lifecycle/release-status-change.js +478 -0
  159. package/dist/lifecycle/release-status.d.ts +11 -0
  160. package/dist/lifecycle/release-status.js +1 -1
  161. package/dist/lifecycle/release-store.d.ts +73 -2
  162. package/dist/lifecycle/release-store.js +32 -1
  163. package/dist/lifecycle/release-tag.d.ts +142 -0
  164. package/dist/lifecycle/release-tag.js +322 -0
  165. package/dist/lifecycle/release-verify.d.ts +73 -1
  166. package/dist/lifecycle/release-verify.js +117 -2
  167. package/dist/lifecycle/release-version-formats.d.ts +73 -0
  168. package/dist/lifecycle/release-version-formats.js +570 -0
  169. package/dist/lifecycle/release-version.d.ts +58 -10
  170. package/dist/lifecycle/release-version.js +164 -36
  171. package/dist/lifecycle/release-workstation.d.ts +3 -2
  172. package/dist/lifecycle/release-workstation.js +3 -2
  173. package/dist/op/generate-pipeline.js +1 -1
  174. package/dist/op/local-executor.d.ts +1 -1
  175. package/dist/op/local-executor.js +2 -2
  176. package/dist/op/op-waves-evidence.js +9 -2
  177. package/dist/pr-forge-base.js +4 -2
  178. package/dist/pr-forge.d.ts +20 -2
  179. package/dist/pr-forge.js +46 -10
  180. package/dist/release-floors.d.ts +8 -1
  181. package/dist/release-floors.js +9 -2
  182. package/dist/sensitive-key.d.ts +12 -0
  183. package/dist/sensitive-key.js +52 -0
  184. package/dist/tool-pins.d.ts +40 -0
  185. package/dist/tool-pins.js +66 -0
  186. package/dist/ts-loader.d.ts +8 -0
  187. package/dist/ts-loader.js +19 -0
  188. package/dist/wave-runtime.mjs +345 -342
  189. package/dist/workspace/ci-forge.d.ts +17 -0
  190. package/dist/workspace/ci-forge.js +17 -0
  191. package/dist/workspace/ci-init.js +1 -1
  192. package/dist/workspace/composites.schema.json +1 -0
  193. package/dist/workspace/declaration.d.ts +8 -0
  194. package/dist/workspace/declaration.js +12 -0
  195. package/dist/workspace/declaration.schema.json +8 -0
  196. package/dist/workspace/environments.d.ts +2 -0
  197. package/dist/workspace/environments.js +1 -1
  198. package/dist/workspace/identity-gate-rule.d.ts +61 -5
  199. package/dist/workspace/identity-gate-rule.js +81 -12
  200. package/dist/workspace/lexicon-outputs.d.ts +1 -1
  201. package/dist/workspace/lexicon-outputs.js +1 -1
  202. package/dist/workspace/member-pipeline.d.ts +2 -1
  203. package/dist/workspace/member-pipeline.js +5 -2
  204. package/dist/workspace/reason-codes.d.ts +2 -0
  205. package/dist/workspace/reason-codes.js +3 -1
  206. package/dist/workspace/release-changed.d.ts +75 -4
  207. package/dist/workspace/release-changed.js +205 -34
  208. package/dist/workspace/release-changed.schema.json +20 -2
  209. package/dist/workspace/release-steps/artifacts.d.ts +7 -0
  210. package/dist/workspace/release-steps/artifacts.js +45 -0
  211. package/dist/workspace/release-steps/builds.d.ts +12 -0
  212. package/dist/workspace/release-steps/builds.js +38 -0
  213. package/dist/workspace/release-steps/doctor.d.ts +8 -0
  214. package/dist/workspace/release-steps/doctor.js +14 -0
  215. package/dist/workspace/release-steps/goreleaser.d.ts +16 -0
  216. package/dist/workspace/release-steps/goreleaser.js +36 -0
  217. package/dist/workspace/release-steps/green.d.ts +3 -0
  218. package/dist/workspace/release-steps/green.js +6 -0
  219. package/dist/workspace/release-steps/images.d.ts +22 -0
  220. package/dist/workspace/release-steps/images.js +59 -0
  221. package/dist/workspace/release-steps/index.d.ts +9 -0
  222. package/dist/workspace/release-steps/index.js +50 -0
  223. package/dist/workspace/release-steps/nfpm.d.ts +13 -0
  224. package/dist/workspace/release-steps/nfpm.js +29 -0
  225. package/dist/workspace/release-steps/nuget.d.ts +14 -0
  226. package/dist/workspace/release-steps/nuget.js +16 -0
  227. package/dist/workspace/release-steps/pypi.d.ts +15 -0
  228. package/dist/workspace/release-steps/pypi.js +21 -0
  229. package/dist/workspace/release-steps/qemu.d.ts +21 -0
  230. package/dist/workspace/release-steps/qemu.js +35 -0
  231. package/dist/workspace/release-steps/signing.d.ts +18 -0
  232. package/dist/workspace/release-steps/signing.js +30 -0
  233. package/dist/workspace/release-steps/stamp.d.ts +3 -0
  234. package/dist/workspace/release-steps/stamp.js +4 -0
  235. package/dist/workspace/release-steps/targets.d.ts +31 -0
  236. package/dist/workspace/release-steps/targets.js +40 -0
  237. package/dist/workspace/release-steps/types.d.ts +104 -0
  238. package/dist/workspace/release-steps/types.js +2 -0
  239. package/dist/workspace/release-steps/verify.d.ts +3 -0
  240. package/dist/workspace/release-steps/verify.js +4 -0
  241. package/dist/workspace/release-toolchains.d.ts +59 -0
  242. package/dist/workspace/release-toolchains.js +133 -0
  243. package/dist/workspace/release-train-workflow.d.ts +36 -0
  244. package/dist/workspace/release-train-workflow.js +121 -0
  245. package/dist/workspace/release-train.d.ts +3 -1
  246. package/dist/workspace/release-train.js +20 -3
  247. package/dist/workspace/release-workflow.d.ts +183 -59
  248. package/dist/workspace/release-workflow.js +570 -201
  249. package/dist/workspace/releases.schema.json +70 -1
  250. package/dist/workspace/search-contract.d.ts +1 -1
  251. package/dist/workspace/security.js +9 -2
  252. package/dist/workspace/train-cut.d.ts +182 -0
  253. package/dist/workspace/train-cut.js +504 -0
  254. package/dist/workspace/train-prepare.d.ts +64 -0
  255. package/dist/workspace/train-prepare.js +313 -0
  256. package/dist/workspace/train-publish.d.ts +177 -0
  257. package/dist/workspace/train-publish.js +574 -0
  258. package/dist/workspace/train-range-labels.d.ts +33 -0
  259. package/dist/workspace/train-range-labels.js +109 -0
  260. package/dist/workspace/train-shell.d.ts +5 -0
  261. package/dist/workspace/train-shell.js +17 -0
  262. package/dist/workspace/trust/check-evidence-report.d.ts +3 -7
  263. package/dist/workspace/trust/check-evidence-report.js +3 -7
  264. package/dist/workspace/trust/seal.d.ts +13 -3
  265. package/dist/workspace/trust/seal.js +14 -4
  266. package/dist/workspace/work-cli.d.ts +3 -2
  267. package/dist/workspace/work-cli.js +3 -2
  268. package/dist/workspace/workspace-ledger.d.ts +14 -1
  269. package/dist/workspace/workspace-ledger.js +33 -7
  270. package/package.json +1 -1
@@ -0,0 +1,73 @@
1
+ /**
2
+ * Release intent files (#5159): `.chant/release/*.md` at the repository
3
+ * root, each naming the members a change releases and the level it bumps
4
+ * them by, with a summary for the release notes.
5
+ *
6
+ * ```md
7
+ * ---
8
+ * core: minor
9
+ * lexicon-aws: patch
10
+ * ---
11
+ * The core reads its config once at start.
12
+ * ```
13
+ *
14
+ * A key is a member's name, as `chant release changed` lists it (or its
15
+ * full ledger name, such as `npm/core`), or `*` for every member and for a
16
+ * project that is no workspace member. A value is `major`, `minor` or
17
+ * `patch`. `README.md` in the directory is not an intent.
18
+ *
19
+ * Files are read from a commit's tree, never from the working tree. An
20
+ * intent is the file's path together with the commit that added it, so a
21
+ * file deleted and written again is a new intent. A cut records the
22
+ * intents it consumed on its cut line (`ReleaseCut.intents`), and a later
23
+ * release of the same member skips them: no commit to the branch is needed
24
+ * to retire one, so the tree never has to hold the version being released.
25
+ */
26
+ import type { ReleaseCut, ReleaseCutIntent } from "./release-store.js";
27
+ export type ReleaseBumpLevel = "major" | "minor" | "patch";
28
+ /** Where intent files live, from the repository root. */
29
+ export declare const INTENT_DIR = ".chant/release";
30
+ /** The higher of two levels; null is lower than any. */
31
+ export declare function maxBump(a: ReleaseBumpLevel | null, b: ReleaseBumpLevel | null): ReleaseBumpLevel | null;
32
+ /** An intent file that can't be read. */
33
+ export declare class ReleaseIntentError extends Error {
34
+ readonly path: string;
35
+ readonly code = "release-intent-invalid";
36
+ constructor(path: string, why: string);
37
+ }
38
+ /** One intent file, read at a commit. */
39
+ export interface ReleaseIntent {
40
+ /** From the repository root. */
41
+ path: string;
42
+ /** The full sha of the commit that added it. */
43
+ added: string;
44
+ /** Member name (or `*`) to level, in the file's order. */
45
+ members: Map<string, ReleaseBumpLevel>;
46
+ /** The text after the front matter, trimmed. */
47
+ summary: string;
48
+ }
49
+ /** The members and summary of an intent file's text. Throws {@link ReleaseIntentError}. */
50
+ export declare function parseIntent(path: string, text: string): {
51
+ members: Map<string, ReleaseBumpLevel>;
52
+ summary: string;
53
+ };
54
+ /** Every intent file in `commit`'s tree, sorted by path. Throws {@link ReleaseIntentError} for one that can't be read. */
55
+ export declare function readIntents(top: string, commit: string): ReleaseIntent[];
56
+ /** The key a consumed intent is known by. */
57
+ export declare const intentKey: (i: {
58
+ path: string;
59
+ added: string;
60
+ }) => string;
61
+ /** The intents the member's cuts consumed, by {@link intentKey}. */
62
+ export declare function consumedIntents(cuts: readonly ReleaseCut[]): Set<string>;
63
+ /** The level `intent` gives a member known by any of `names`, or null when it names none of them. */
64
+ export declare function intentLevel(intent: ReleaseIntent, names: readonly string[]): ReleaseBumpLevel | null;
65
+ /** The intents that name the member (by any of `names`) and that none of its cuts consumed, as a cut records them. */
66
+ export declare function pendingIntents(intents: readonly ReleaseIntent[], names: readonly string[], consumed: ReadonlySet<string>): Array<ReleaseCutIntent & {
67
+ summary: string;
68
+ }>;
69
+ /** Release notes from intent summaries (#5159): one item each, the highest level first, under one heading. Empty when no summary has text. */
70
+ export declare function intentNotes(intents: ReadonlyArray<{
71
+ bump: ReleaseBumpLevel;
72
+ summary: string;
73
+ }>): string;
@@ -0,0 +1,128 @@
1
+ /**
2
+ * Release intent files (#5159): `.chant/release/*.md` at the repository
3
+ * root, each naming the members a change releases and the level it bumps
4
+ * them by, with a summary for the release notes.
5
+ *
6
+ * ```md
7
+ * ---
8
+ * core: minor
9
+ * lexicon-aws: patch
10
+ * ---
11
+ * The core reads its config once at start.
12
+ * ```
13
+ *
14
+ * A key is a member's name, as `chant release changed` lists it (or its
15
+ * full ledger name, such as `npm/core`), or `*` for every member and for a
16
+ * project that is no workspace member. A value is `major`, `minor` or
17
+ * `patch`. `README.md` in the directory is not an intent.
18
+ *
19
+ * Files are read from a commit's tree, never from the working tree. An
20
+ * intent is the file's path together with the commit that added it, so a
21
+ * file deleted and written again is a new intent. A cut records the
22
+ * intents it consumed on its cut line (`ReleaseCut.intents`), and a later
23
+ * release of the same member skips them: no commit to the branch is needed
24
+ * to retire one, so the tree never has to hold the version being released.
25
+ */
26
+ import { execFileSync } from "node:child_process";
27
+ /** Where intent files live, from the repository root. */
28
+ export const INTENT_DIR = ".chant/release";
29
+ const LEVELS = ["patch", "minor", "major"];
30
+ /** The higher of two levels; null is lower than any. */
31
+ export function maxBump(a, b) {
32
+ if (a === null)
33
+ return b;
34
+ if (b === null)
35
+ return a;
36
+ return LEVELS.indexOf(a) >= LEVELS.indexOf(b) ? a : b;
37
+ }
38
+ /** An intent file that can't be read. */
39
+ export class ReleaseIntentError extends Error {
40
+ constructor(path, why) {
41
+ super(`the intent file ${path} ${why}`);
42
+ this.path = path;
43
+ this.code = "release-intent-invalid";
44
+ this.name = "ReleaseIntentError";
45
+ }
46
+ }
47
+ /** The members and summary of an intent file's text. Throws {@link ReleaseIntentError}. */
48
+ export function parseIntent(path, text) {
49
+ const lines = text.replace(/^/, "").split(/\r?\n/);
50
+ if (lines[0]?.trim() !== "---")
51
+ throw new ReleaseIntentError(path, "does not start with a --- line opening its front matter");
52
+ const end = lines.findIndex((l, i) => i > 0 && l.trim() === "---");
53
+ if (end < 0)
54
+ throw new ReleaseIntentError(path, "has no --- line closing its front matter");
55
+ const members = new Map();
56
+ for (const raw of lines.slice(1, end)) {
57
+ const line = raw.trim();
58
+ if (line === "" || line.startsWith("#"))
59
+ continue;
60
+ const m = /^("([^"]+)"|'([^']+)'|([^:\s][^:]*?))\s*:\s*("?|'?)([A-Za-z]+)\5\s*$/.exec(line);
61
+ if (!m)
62
+ throw new ReleaseIntentError(path, `has a front matter line that is not <member>: major|minor|patch: ${JSON.stringify(line)}`);
63
+ const name = (m[2] ?? m[3] ?? m[4]).trim();
64
+ const level = m[6].toLowerCase();
65
+ if (!LEVELS.includes(level))
66
+ throw new ReleaseIntentError(path, `gives ${name} the level ${m[6]}, which is not major, minor or patch`);
67
+ if (members.has(name))
68
+ throw new ReleaseIntentError(path, `names ${name} twice`);
69
+ members.set(name, level);
70
+ }
71
+ if (members.size === 0)
72
+ throw new ReleaseIntentError(path, "names no member in its front matter");
73
+ return { members, summary: lines.slice(end + 1).join("\n").trim() };
74
+ }
75
+ function git(top, args) {
76
+ return execFileSync("git", args, { cwd: top, encoding: "utf-8", stdio: ["ignore", "pipe", "pipe"], maxBuffer: 64 * 1024 * 1024 });
77
+ }
78
+ /** Every intent file in `commit`'s tree, sorted by path. Throws {@link ReleaseIntentError} for one that can't be read. */
79
+ export function readIntents(top, commit) {
80
+ const listed = git(top, ["ls-tree", "--name-only", "-z", commit, "--", `${INTENT_DIR}/`])
81
+ .split("\0")
82
+ .filter((p) => p.endsWith(".md") && !/(^|\/)README\.md$/i.test(p) && p.slice(INTENT_DIR.length + 1).indexOf("/") < 0)
83
+ .sort();
84
+ return listed.map((path) => {
85
+ const { members, summary } = parseIntent(path, git(top, ["show", `${commit}:${path}`]));
86
+ const added = git(top, ["log", "-1", "--diff-filter=A", "--format=%H", commit, "--", path]).trim();
87
+ return { path, added: added || commit, members, summary };
88
+ });
89
+ }
90
+ /** The key a consumed intent is known by. */
91
+ export const intentKey = (i) => `${i.path}@${i.added}`;
92
+ /** The intents the member's cuts consumed, by {@link intentKey}. */
93
+ export function consumedIntents(cuts) {
94
+ const out = new Set();
95
+ for (const c of cuts)
96
+ for (const i of c.intents ?? [])
97
+ out.add(intentKey(i));
98
+ return out;
99
+ }
100
+ /** The level `intent` gives a member known by any of `names`, or null when it names none of them. */
101
+ export function intentLevel(intent, names) {
102
+ let level = null;
103
+ for (const n of [...names, "*"])
104
+ level = maxBump(level, intent.members.get(n) ?? null);
105
+ return level;
106
+ }
107
+ /** The intents that name the member (by any of `names`) and that none of its cuts consumed, as a cut records them. */
108
+ export function pendingIntents(intents, names, consumed) {
109
+ const out = [];
110
+ for (const i of intents) {
111
+ const bump = intentLevel(i, names);
112
+ if (bump === null || consumed.has(intentKey(i)))
113
+ continue;
114
+ out.push({ path: i.path, added: i.added, bump, summary: i.summary });
115
+ }
116
+ return out;
117
+ }
118
+ /** Release notes from intent summaries (#5159): one item each, the highest level first, under one heading. Empty when no summary has text. */
119
+ export function intentNotes(intents) {
120
+ const listed = intents.filter((i) => i.summary.length > 0).sort((a, b) => LEVELS.indexOf(b.bump) - LEVELS.indexOf(a.bump));
121
+ if (listed.length === 0)
122
+ return "";
123
+ const item = (s) => s
124
+ .split("\n")
125
+ .map((l, n) => (n === 0 ? `- ${l}` : l.length > 0 ? ` ${l}` : ""))
126
+ .join("\n");
127
+ return ["### Highlights", "", ...listed.map((i) => item(i.summary))].join("\n");
128
+ }
@@ -0,0 +1,111 @@
1
+ /**
2
+ * The next release's label, chosen from the commits and the intent files
3
+ * since the member's previous release (#5159): `chant release next` prints
4
+ * it, and `chant release cut auto` cuts it.
5
+ *
6
+ * The previous release is found in the member's ledger: the nearest
7
+ * release cut from the commit or an ancestor of it whose label is a semver
8
+ * version without a prerelease part and that is not yanked (#5163:
9
+ * `chant release yank` sets that status in `_releases/release-status.jsonl`).
10
+ * A member whose ledger has none (a project that just adopted
11
+ * `chant release`) falls back to its tag history (#5200): the newest tag on
12
+ * the commit or an ancestor that the member's `release.tag` template or one
13
+ * of its `release.legacyTags` prefixes makes of a stable version that no
14
+ * yanked release holds, matched by `tagHistoryRelease`. The commits are those
15
+ * after it, up to the commit, that touch the member's directory (or, for a
16
+ * release member under a nested workspace, the directory of the outer
17
+ * member of its name). Each is classified as {@link changelogBump} does: a
18
+ * `type!:` subject or a `BREAKING CHANGE` footer is a major, `feat` a minor,
19
+ * anything else a patch. On a 0.x version each commit's level drops one
20
+ * step, a major to a minor and a minor to a patch, unless
21
+ * `release.breakingOnZero` is `major` (#5191). The intent files that name
22
+ * the member and that no cut of it consumed (./release-intents.ts) give
23
+ * their own levels, unshifted, and the bump is the highest of them all.
24
+ *
25
+ * Prereleases (#5166): a prerelease cut since that version whose own
26
+ * version is higher than the bumped one raises it to that version, so
27
+ * `2.0.0-rc.1` is followed by `2.0.0` even when only fixes landed since.
28
+ * With `pre`, the label is `<version>-<pre>.<n>`, `n` one past the highest
29
+ * the member's ledger holds for that version and id, else 0.
30
+ *
31
+ * A yanked stable release passed over still holds its version, which no
32
+ * registry takes twice, so a label at or below it becomes its next patch:
33
+ * `1.1.0` yanked after `1.0.0` is followed by `1.1.1`.
34
+ *
35
+ * A label written with a leading `v` gives labels with one. A commit the
36
+ * member already has a labelled release of answers that label, so a run
37
+ * started again cuts what it cut before.
38
+ */
39
+ import { type ReleaseBumpLevel } from "./release-intents.js";
40
+ import type { ReleaseCutIntent } from "./release-store.js";
41
+ /** The first chant with `chant release next` and `chant release cut auto`, the label from the conventional commits and the `.chant/release/*.md` intent files since the member's previous release; a cut records the intent files it consumed (`intents` on its cut line), `release changed` computes each member's bump from them (`bumpFrom`, `intents`, `intent-pending`), notes generated from commits lead with their summaries, and a dispatched release workflow takes the label `auto` (#5159); with no release in the ledger the previous one is the newest version tag `release.tag` or `release.legacyTags` matches (#5200), and on 0.x a breaking commit bumps minor unless `release.breakingOnZero` is `major` (#5191). */
42
+ export declare const RELEASE_NEXT_FLOOR = "0.124.101";
43
+ export type ReleaseNextCode = "not-a-git-repository" | "revision-unknown" | "release-next-no-previous" | "release-next-unchanged" | "release-next-pre-invalid" | "release-next-history-shallow" | "release-intent-invalid";
44
+ export declare class ReleaseNextError extends Error {
45
+ readonly code: ReleaseNextCode;
46
+ readonly fix?: string | undefined;
47
+ constructor(code: ReleaseNextCode, message: string, fix?: string | undefined);
48
+ }
49
+ /** One commit counted, with the level it implies. */
50
+ export interface NextCommit {
51
+ sha: string;
52
+ subject: string;
53
+ bump: ReleaseBumpLevel;
54
+ }
55
+ export interface NextRelease {
56
+ /** The label the next release carries. */
57
+ label: string;
58
+ /** The full sha it was read at. */
59
+ at: string;
60
+ /** The level applied to `from`, or null when the label is a release already cut at `at`, or a prerelease's version carried on. */
61
+ bump: ReleaseBumpLevel | null;
62
+ /** True when `at` already has a labelled release of the member, whose label this is. */
63
+ alreadyCut: boolean;
64
+ /** The previous release the label follows: a cut in the member's ledger, or a version tag when the ledger has none (#5200), with that tag. */
65
+ from: {
66
+ label: string;
67
+ commit: string;
68
+ source: "ledger" | "tag";
69
+ tag?: string;
70
+ };
71
+ /** The commits after `from` that touch the member, newest first. */
72
+ commits: NextCommit[];
73
+ /** The intent files the release consumes, with their summaries. */
74
+ intents: Array<ReleaseCutIntent & {
75
+ summary: string;
76
+ }>;
77
+ }
78
+ /**
79
+ * The next label from the previous stable label, the bump, the prerelease
80
+ * labels cut since it, and every label the member's ledger holds. Pure.
81
+ */
82
+ export declare function nextLabel(input: {
83
+ stable: string;
84
+ bump: ReleaseBumpLevel | null;
85
+ since: readonly string[];
86
+ labels: readonly string[];
87
+ pre?: string;
88
+ yanked?: readonly string[];
89
+ }): string;
90
+ /** The commits in `from..to` touching `path` (from the repository root), newest first, merges left out. */
91
+ export declare function commitsTouching(top: string, from: string, to: string, path: string): NextCommit[];
92
+ /** The highest level of `commits`, or null when there are none. */
93
+ export declare function commitsBump(commits: readonly NextCommit[]): ReleaseBumpLevel | null;
94
+ /**
95
+ * The intent files at `commit` that name the member at `cwd` and that none
96
+ * of its cuts consumed: what a cut of `commit` consumes. Throws
97
+ * {@link ReleaseNextError} `release-intent-invalid` for a file that can't be read.
98
+ */
99
+ export declare function memberPendingIntents(cwd: string, top: string, commit: string, names?: readonly string[], cuts?: readonly import("./release-store.js").ReleaseCut[]): Promise<NextRelease["intents"]>;
100
+ /**
101
+ * The commits with their levels as they apply to the version `label`
102
+ * (#5191): on 0.x, unless `breakingOnZero` is `major`, a major counts as a
103
+ * minor and a minor as a patch.
104
+ */
105
+ export declare function shiftOnZero(commits: NextCommit[], label: string, breakingOnZero: "minor" | "major"): NextCommit[];
106
+ /** Read the next label of the member at `cwd`, at `at` (default `HEAD`). */
107
+ export declare function nextRelease(req: {
108
+ cwd: string;
109
+ at?: string;
110
+ pre?: string;
111
+ }): Promise<NextRelease>;
@@ -0,0 +1,251 @@
1
+ /**
2
+ * The next release's label, chosen from the commits and the intent files
3
+ * since the member's previous release (#5159): `chant release next` prints
4
+ * it, and `chant release cut auto` cuts it.
5
+ *
6
+ * The previous release is found in the member's ledger: the nearest
7
+ * release cut from the commit or an ancestor of it whose label is a semver
8
+ * version without a prerelease part and that is not yanked (#5163:
9
+ * `chant release yank` sets that status in `_releases/release-status.jsonl`).
10
+ * A member whose ledger has none (a project that just adopted
11
+ * `chant release`) falls back to its tag history (#5200): the newest tag on
12
+ * the commit or an ancestor that the member's `release.tag` template or one
13
+ * of its `release.legacyTags` prefixes makes of a stable version that no
14
+ * yanked release holds, matched by `tagHistoryRelease`. The commits are those
15
+ * after it, up to the commit, that touch the member's directory (or, for a
16
+ * release member under a nested workspace, the directory of the outer
17
+ * member of its name). Each is classified as {@link changelogBump} does: a
18
+ * `type!:` subject or a `BREAKING CHANGE` footer is a major, `feat` a minor,
19
+ * anything else a patch. On a 0.x version each commit's level drops one
20
+ * step, a major to a minor and a minor to a patch, unless
21
+ * `release.breakingOnZero` is `major` (#5191). The intent files that name
22
+ * the member and that no cut of it consumed (./release-intents.ts) give
23
+ * their own levels, unshifted, and the bump is the highest of them all.
24
+ *
25
+ * Prereleases (#5166): a prerelease cut since that version whose own
26
+ * version is higher than the bumped one raises it to that version, so
27
+ * `2.0.0-rc.1` is followed by `2.0.0` even when only fixes landed since.
28
+ * With `pre`, the label is `<version>-<pre>.<n>`, `n` one past the highest
29
+ * the member's ledger holds for that version and id, else 0.
30
+ *
31
+ * A yanked stable release passed over still holds its version, which no
32
+ * registry takes twice, so a label at or below it becomes its next patch:
33
+ * `1.1.0` yanked after `1.0.0` is followed by `1.1.1`.
34
+ *
35
+ * A label written with a leading `v` gives labels with one. A commit the
36
+ * member already has a labelled release of answers that label, so a run
37
+ * started again cuts what it cut before.
38
+ */
39
+ import { execFileSync } from "node:child_process";
40
+ import { realpathSync } from "node:fs";
41
+ import { relative } from "node:path";
42
+ import { classifyCommit } from "./release-changelog.js";
43
+ import { consumedIntents, maxBump, pendingIntents, readIntents } from "./release-intents.js";
44
+ /** The first chant with `chant release next` and `chant release cut auto`, the label from the conventional commits and the `.chant/release/*.md` intent files since the member's previous release; a cut records the intent files it consumed (`intents` on its cut line), `release changed` computes each member's bump from them (`bumpFrom`, `intents`, `intent-pending`), notes generated from commits lead with their summaries, and a dispatched release workflow takes the label `auto` (#5159); with no release in the ledger the previous one is the newest version tag `release.tag` or `release.legacyTags` matches (#5200), and on 0.x a breaking commit bumps minor unless `release.breakingOnZero` is `major` (#5191). */
45
+ export const RELEASE_NEXT_FLOOR = "0.124.101";
46
+ export class ReleaseNextError extends Error {
47
+ constructor(code, message, fix) {
48
+ super(message);
49
+ this.code = code;
50
+ this.fix = fix;
51
+ this.name = "ReleaseNextError";
52
+ }
53
+ }
54
+ const SEMVER = /^(v?)(\d+)\.(\d+)\.(\d+)(?:-([0-9A-Za-z.-]+))?(?:\+[0-9A-Za-z.-]+)?$/;
55
+ const cmp = (a, b) => a[0] - b[0] || a[1] - b[1] || a[2] - b[2];
56
+ function parse(label) {
57
+ const m = SEMVER.exec(label);
58
+ return m ? { v: m[1], core: [Number(m[2]), Number(m[3]), Number(m[4])], pre: m[5] ?? null } : null;
59
+ }
60
+ /** `p` with its links resolved, or as given when it does not exist. */
61
+ function realpathOr(p) {
62
+ try {
63
+ return realpathSync(p);
64
+ }
65
+ catch {
66
+ return p;
67
+ }
68
+ }
69
+ const PRE_ID = /^[A-Za-z][0-9A-Za-z-]*$/;
70
+ /**
71
+ * The next label from the previous stable label, the bump, the prerelease
72
+ * labels cut since it, and every label the member's ledger holds. Pure.
73
+ */
74
+ export function nextLabel(input) {
75
+ const base = parse(input.stable);
76
+ if (!base || base.pre !== null)
77
+ throw new Error(`${input.stable} is not a release version`);
78
+ let core = [...base.core];
79
+ if (input.bump === "major")
80
+ core = [core[0] + 1, 0, 0];
81
+ else if (input.bump === "minor")
82
+ core = [core[0], core[1] + 1, 0];
83
+ else if (input.bump === "patch")
84
+ core = [core[0], core[1], core[2] + 1];
85
+ for (const l of input.since) {
86
+ const p = parse(l);
87
+ if (p && p.pre !== null && cmp(p.core, core) > 0)
88
+ core = p.core;
89
+ }
90
+ // #5163: a yanked version can't be published again, so the label goes past it.
91
+ for (const l of input.yanked ?? []) {
92
+ const p = parse(l);
93
+ if (p && p.pre === null && cmp(p.core, core) >= 0)
94
+ core = [p.core[0], p.core[1], p.core[2] + 1];
95
+ }
96
+ const version = core.join(".");
97
+ if (input.pre === undefined)
98
+ return `${base.v}${version}`;
99
+ let n = -1;
100
+ for (const l of input.labels) {
101
+ const p = parse(l);
102
+ if (!p || cmp(p.core, core) !== 0 || p.pre === null)
103
+ continue;
104
+ const m = new RegExp(`^${input.pre.replace(/[-]/g, "\\-")}\\.(\\d+)$`).exec(p.pre);
105
+ if (m)
106
+ n = Math.max(n, Number(m[1]));
107
+ }
108
+ return `${base.v}${version}-${input.pre}.${n + 1}`;
109
+ }
110
+ function git(top, args) {
111
+ try {
112
+ return execFileSync("git", args, { cwd: top, encoding: "utf-8", stdio: ["ignore", "pipe", "pipe"], maxBuffer: 256 * 1024 * 1024 });
113
+ }
114
+ catch {
115
+ return null;
116
+ }
117
+ }
118
+ /** The commits in `from..to` touching `path` (from the repository root), newest first, merges left out. */
119
+ export function commitsTouching(top, from, to, path) {
120
+ const out = git(top, ["log", "--no-merges", "--format=%H%x00%B%x1e", `${from}..${to}`, "--", path === "" ? "." : `:(top,literal)${path}`]);
121
+ if (out === null)
122
+ throw new ReleaseNextError("revision-unknown", `git could not list the commits ${from.slice(0, 12)}..${to.slice(0, 12)}`, "Fetch the full history of the branch.");
123
+ return out
124
+ .split("\x1e")
125
+ .map((r) => r.replace(/^\n+/, ""))
126
+ .filter((r) => r.includes("\0"))
127
+ .map((r) => {
128
+ const [sha, message] = r.split("\0");
129
+ const { kind } = classifyCommit(message.trim());
130
+ return { sha, subject: message.trim().split("\n", 1)[0], bump: kind === "breaking" ? "major" : kind === "feat" ? "minor" : "patch" };
131
+ });
132
+ }
133
+ /** The highest level of `commits`, or null when there are none. */
134
+ export function commitsBump(commits) {
135
+ let out = null;
136
+ for (const c of commits)
137
+ out = maxBump(out, c.bump);
138
+ return out;
139
+ }
140
+ /**
141
+ * The intent files at `commit` that name the member at `cwd` and that none
142
+ * of its cuts consumed: what a cut of `commit` consumes. Throws
143
+ * {@link ReleaseNextError} `release-intent-invalid` for a file that can't be read.
144
+ */
145
+ export async function memberPendingIntents(cwd, top, commit, names, cuts) {
146
+ if (names === undefined) {
147
+ const { resolveMemberLedger } = await import("./member-ledger.js");
148
+ const ledger = await resolveMemberLedger(cwd);
149
+ names = ledger.members.length > 0 ? [ledger.members.at(-1), ledger.members.join("/")] : [];
150
+ }
151
+ if (cuts === undefined)
152
+ cuts = (await (await import("./release-store.js")).readCuts({ cwd })).cuts;
153
+ try {
154
+ return pendingIntents(readIntents(top, commit), names, consumedIntents(cuts));
155
+ }
156
+ catch (err) {
157
+ if (err instanceof Error && err.code === "release-intent-invalid") {
158
+ throw new ReleaseNextError("release-intent-invalid", err.message, "Write the front matter as lines of <member>: major|minor|patch between two --- lines.");
159
+ }
160
+ throw err;
161
+ }
162
+ }
163
+ /**
164
+ * The commits with their levels as they apply to the version `label`
165
+ * (#5191): on 0.x, unless `breakingOnZero` is `major`, a major counts as a
166
+ * minor and a minor as a patch.
167
+ */
168
+ export function shiftOnZero(commits, label, breakingOnZero) {
169
+ const base = parse(label);
170
+ if (breakingOnZero === "major" || !base || base.core[0] !== 0)
171
+ return commits;
172
+ return commits.map((c) => ({ ...c, bump: c.bump === "major" ? "minor" : "patch" }));
173
+ }
174
+ /** The tag shapes of the member's earlier releases: its `release.tag` template, then each `release.legacyTags` prefix. */
175
+ async function historyShapes(cwd, top, legacyTags) {
176
+ const shapes = [];
177
+ try {
178
+ const t = await import("./release-tag.js");
179
+ const mt = await t.memberTags(cwd, { top });
180
+ shapes.push({ ...t.tagShape(mt.template.name, mt.place), render: (l) => t.renderReleaseTag(mt.template, mt.place, l) });
181
+ }
182
+ catch {
183
+ // A config that can't be read, or a template refused here, is refused by the cut; the legacy prefixes still count.
184
+ }
185
+ for (const prefix of legacyTags)
186
+ shapes.push({ prefix, suffix: "" });
187
+ return shapes;
188
+ }
189
+ /** Read the next label of the member at `cwd`, at `at` (default `HEAD`). */
190
+ export async function nextRelease(req) {
191
+ if (req.pre !== undefined && !PRE_ID.test(req.pre)) {
192
+ throw new ReleaseNextError("release-next-pre-invalid", `--pre ${req.pre} is not a prerelease id: a letter, then letters, digits and -`, "Name it as in --pre rc or --pre beta.");
193
+ }
194
+ const top = git(req.cwd, ["rev-parse", "--show-toplevel"])?.trim();
195
+ if (!top)
196
+ throw new ReleaseNextError("not-a-git-repository", "the next label is read from commits and the ledger, and this directory is not in a git repository");
197
+ const at = git(top, ["rev-parse", "--verify", "--quiet", `${req.at ?? "HEAD"}^{commit}`])?.trim();
198
+ if (!at)
199
+ throw new ReleaseNextError("revision-unknown", `${req.at ?? "HEAD"} names no commit in this clone`);
200
+ if (git(top, ["rev-parse", "--is-shallow-repository"])?.trim() === "true") {
201
+ throw new ReleaseNextError("release-next-history-shallow", "the next label is read from the commits since the previous release, and this clone is shallow", "Fetch the full history: fetch-depth: 0 on actions/checkout, GIT_DEPTH: 0 on GitLab.");
202
+ }
203
+ const { ancestorReleases } = await import("./release-cut.js");
204
+ const { readCuts } = await import("./release-store.js");
205
+ const { resolveMemberLedger } = await import("./member-ledger.js");
206
+ const { memberSourcePath, memberReleaseSettings, tagHistoryRelease } = await import("../workspace/release-changed.js");
207
+ const ledger = await resolveMemberLedger(req.cwd);
208
+ const names = ledger.members.length > 0 ? [ledger.members.at(-1), ledger.members.join("/")] : [];
209
+ const { cuts } = await readCuts({ cwd: req.cwd });
210
+ const ancestors = await ancestorReleases(top, at, req.cwd);
211
+ // #5163: a yanked release is never the previous release.
212
+ const { readReleaseStatus, statusOf } = await import("./release-status.js");
213
+ const statusRecords = (await readReleaseStatus("_releases", { cwd: req.cwd }).catch(() => ({ records: [] }))).records;
214
+ const component = ledger.members.length > 0 ? ledger.members.join("/") : ".";
215
+ const yanked = (a) => statusOf(statusRecords, component, a.release.releaseDigest).status === "yanked";
216
+ const here = ancestors.find((a) => a.release.commit === at && a.label !== null);
217
+ const stableAt = ancestors.findIndex((a) => a.release.commit !== at && a.label !== null && parse(a.label)?.pre === null && !yanked(a));
218
+ const settings = await memberReleaseSettings(req.cwd);
219
+ let stable = stableAt >= 0 ? { label: ancestors[stableAt].label, commit: ancestors[stableAt].release.commit, source: "ledger" } : null;
220
+ // #5200: a member whose ledger has no stable release reads its tag history,
221
+ // passing over the tag of a release the ledger holds as yanked.
222
+ if (!stable && !here) {
223
+ const yankedVersions = ancestors.filter((a) => a.label !== null && yanked(a)).map((a) => a.label.replace(/^v/, ""));
224
+ const hit = tagHistoryRelease(top, await historyShapes(req.cwd, top, settings.legacyTags), { at, stable: true, skip: yankedVersions });
225
+ if (hit)
226
+ stable = { label: hit.label, commit: hit.commit, source: "tag", tag: hit.tag };
227
+ }
228
+ const intents = await memberPendingIntents(req.cwd, top, at, names, cuts);
229
+ const path = relative(realpathSync(top), realpathOr(memberSourcePath(req.cwd))).split("\\").join("/");
230
+ const commits = stable ? shiftOnZero(commitsTouching(top, stable.commit, at, path), stable.label, settings.breakingOnZero) : [];
231
+ if (here) {
232
+ return { label: here.label, at, bump: null, alreadyCut: true, from: stable ?? { label: here.label, commit: at, source: "ledger" }, commits, intents: [] };
233
+ }
234
+ if (!stable) {
235
+ const pre = ancestors.find((a) => a.label !== null && parse(a.label) !== null);
236
+ throw new ReleaseNextError("release-next-no-previous", pre
237
+ ? `the member has no release with a version label before ${at.slice(0, 12)}, only the prerelease ${pre.label}, and no version tag its release.tag or release.legacyTags matches, so there is no version to bump`
238
+ : `the member has no release with a version label before ${at.slice(0, 12)}, and no version tag its release.tag or release.legacyTags matches, so there is no version to bump`, "Cut the first release with the label you choose, such as: chant release cut 1.0.0. If earlier releases were tagged by hand, name their tag prefix in release.legacyTags.");
239
+ }
240
+ // The prerelease labels cut since the stable one: all the ledger holds when the previous release is a tag.
241
+ const since = (stable.source === "ledger" ? ancestors.slice(0, stableAt) : ancestors).map((a) => a.label).filter((l) => l !== null);
242
+ const bump = maxBump(commitsBump(commits), intents.reduce((b, i) => maxBump(b, i.bump), null));
243
+ if (bump === null && !since.some((l) => parse(l)?.pre !== null)) {
244
+ throw new ReleaseNextError("release-next-unchanged", `no commit since ${stable.label} (${stable.commit.slice(0, 12)}) touches ${path || "the repository"}, and no intent file names the member, so there is nothing to release`, "Cut with a label you choose if this commit should still be released.");
245
+ }
246
+ const labels = cuts.map((c) => c.label).filter((l) => l !== null);
247
+ // #5163: the yanked releases passed over; with a tag as the previous release, every yanked one the ledger holds.
248
+ const passed = (stable.source === "ledger" ? ancestors.slice(0, stableAt) : ancestors).filter((a) => a.label !== null && yanked(a)).map((a) => a.label);
249
+ const label = nextLabel({ stable: stable.label, bump, since, labels, yanked: passed, ...(req.pre !== undefined ? { pre: req.pre } : {}) });
250
+ return { label, at, bump, alreadyCut: false, from: stable, commits, intents };
251
+ }
@@ -0,0 +1,19 @@
1
+ /**
2
+ * Prerelease labels. A release whose label is a semver prerelease
3
+ * (`1.4.0-rc.1`, `v2.0.0-beta.3`) is a prerelease on every publish target
4
+ * without a `--channel`: npm moves a dist-tag named for the prerelease id
5
+ * and never `latest`, a GitHub or Forgejo release is marked a prerelease,
6
+ * and an OCI image keeps no `latest` tag. A channel named on the cut still
7
+ * decides the npm dist-tag and the OCI tag.
8
+ */
9
+ /** What a prerelease label says: its id (`rc`) and the npm dist-tag it maps to. */
10
+ export interface Prerelease {
11
+ /** The first dot-separated identifier after the hyphen, such as `rc` or `beta`; null when it is a number. */
12
+ id: string | null;
13
+ /** The npm dist-tag a reveal moves: the id lowercased, or `next` when there is no usable id. */
14
+ distTag: string;
15
+ }
16
+ /** The prerelease a label is, or null for a plain version or no label. */
17
+ export declare function prereleaseOf(label: string | null | undefined): Prerelease | null;
18
+ /** One line for a prerelease label: where a publish sends it. `channel` is the tag a cut named, which wins over the id. */
19
+ export declare function prereleaseNote(label: string | null | undefined, channel?: string | null): string;
@@ -0,0 +1,30 @@
1
+ /**
2
+ * Prerelease labels. A release whose label is a semver prerelease
3
+ * (`1.4.0-rc.1`, `v2.0.0-beta.3`) is a prerelease on every publish target
4
+ * without a `--channel`: npm moves a dist-tag named for the prerelease id
5
+ * and never `latest`, a GitHub or Forgejo release is marked a prerelease,
6
+ * and an OCI image keeps no `latest` tag. A channel named on the cut still
7
+ * decides the npm dist-tag and the OCI tag.
8
+ */
9
+ const SEMVER_PRERELEASE = /^v?\d+\.\d+\.\d+-([0-9A-Za-z-]+(?:\.[0-9A-Za-z-]+)*)(?:\+[0-9A-Za-z.-]+)?$/;
10
+ /** The prerelease a label is, or null for a plain version or no label. */
11
+ export function prereleaseOf(label) {
12
+ if (!label)
13
+ return null;
14
+ const m = SEMVER_PRERELEASE.exec(label);
15
+ if (!m)
16
+ return null;
17
+ const first = m[1].split(".")[0].toLowerCase();
18
+ const numeric = /^[0-9]+$/.test(first);
19
+ const id = numeric ? null : first;
20
+ // `latest` is the tag a prerelease must never move.
21
+ return { id, distTag: id === null || id === "latest" ? "next" : id };
22
+ }
23
+ /** One line for a prerelease label: where a publish sends it. `channel` is the tag a cut named, which wins over the id. */
24
+ export function prereleaseNote(label, channel) {
25
+ const pre = prereleaseOf(label);
26
+ if (!pre)
27
+ return "";
28
+ const tag = channel || pre.distTag;
29
+ return `${label} is a prerelease: npm moves ${tag}, not latest; a GitHub or Forgejo release is marked a prerelease; an OCI image keeps no latest tag`;
30
+ }