@intentius/chant 0.124.99 → 0.124.101

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 (245) hide show
  1. package/bin/chant +3 -3
  2. package/dist/action-pins.d.ts +2 -0
  3. package/dist/action-pins.js +3 -0
  4. package/dist/ci-detect.d.ts +13 -0
  5. package/dist/ci-detect.js +12 -0
  6. package/dist/ci-system.d.ts +66 -0
  7. package/dist/ci-system.js +61 -0
  8. package/dist/cli/commands/carve-emit.js +2 -2
  9. package/dist/cli/commands/check-lexicon-plugin.d.ts +2 -2
  10. package/dist/cli/commands/check-lexicon-plugin.js +3 -3
  11. package/dist/cli/commands/check-lexicon.js +4 -4
  12. package/dist/cli/commands/init-lexicon/templates/project.d.ts +1 -1
  13. package/dist/cli/commands/init-lexicon/templates/project.js +4 -4
  14. package/dist/cli/commands/init.d.ts +13 -0
  15. package/dist/cli/commands/init.js +30 -2
  16. package/dist/cli/handlers/build.js +27 -0
  17. package/dist/cli/handlers/release-doctor.d.ts +12 -0
  18. package/dist/cli/handlers/release-doctor.js +118 -0
  19. package/dist/cli/handlers/release-init.d.ts +10 -0
  20. package/dist/cli/handlers/release-init.js +342 -0
  21. package/dist/cli/handlers/release.d.ts +50 -1
  22. package/dist/cli/handlers/release.js +688 -30
  23. package/dist/cli/handlers/run-generate.js +11 -0
  24. package/dist/cli/main.d.ts +2 -0
  25. package/dist/cli/main.js +45 -97
  26. package/dist/cli/parse-args.js +55 -0
  27. package/dist/cli/registry.d.ts +18 -0
  28. package/dist/cli/release-commands/artifacts.d.ts +3 -0
  29. package/dist/cli/release-commands/artifacts.js +14 -0
  30. package/dist/cli/release-commands/candidates.d.ts +3 -0
  31. package/dist/cli/release-commands/candidates.js +16 -0
  32. package/dist/cli/release-commands/changed.d.ts +3 -0
  33. package/dist/cli/release-commands/changed.js +14 -0
  34. package/dist/cli/release-commands/compose.d.ts +3 -0
  35. package/dist/cli/release-commands/compose.js +16 -0
  36. package/dist/cli/release-commands/cut.d.ts +3 -0
  37. package/dist/cli/release-commands/cut.js +49 -0
  38. package/dist/cli/release-commands/doctor.d.ts +3 -0
  39. package/dist/cli/release-commands/doctor.js +14 -0
  40. package/dist/cli/release-commands/export.d.ts +3 -0
  41. package/dist/cli/release-commands/export.js +12 -0
  42. package/dist/cli/release-commands/images.d.ts +3 -0
  43. package/dist/cli/release-commands/images.js +13 -0
  44. package/dist/cli/release-commands/index.d.ts +8 -0
  45. package/dist/cli/release-commands/index.js +52 -0
  46. package/dist/cli/release-commands/init.d.ts +3 -0
  47. package/dist/cli/release-commands/init.js +16 -0
  48. package/dist/cli/release-commands/list.d.ts +3 -0
  49. package/dist/cli/release-commands/list.js +10 -0
  50. package/dist/cli/release-commands/next.d.ts +3 -0
  51. package/dist/cli/release-commands/next.js +13 -0
  52. package/dist/cli/release-commands/publish.d.ts +3 -0
  53. package/dist/cli/release-commands/publish.js +22 -0
  54. package/dist/cli/release-commands/stamp.d.ts +3 -0
  55. package/dist/cli/release-commands/stamp.js +15 -0
  56. package/dist/cli/release-commands/status.d.ts +3 -0
  57. package/dist/cli/release-commands/status.js +17 -0
  58. package/dist/cli/release-commands/tag.d.ts +3 -0
  59. package/dist/cli/release-commands/tag.js +12 -0
  60. package/dist/cli/release-commands/types.d.ts +20 -0
  61. package/dist/cli/release-commands/types.js +1 -0
  62. package/dist/cli/release-commands/verify.d.ts +3 -0
  63. package/dist/cli/release-commands/verify.js +15 -0
  64. package/dist/cli/release-commands/workflow.d.ts +3 -0
  65. package/dist/cli/release-commands/workflow.js +13 -0
  66. package/dist/codegen/pinned-upgrade.js +1 -1
  67. package/dist/components/capability-plugin.d.ts +1 -1
  68. package/dist/components/capability-plugin.js +1 -1
  69. package/dist/components/cli-support.d.ts +1 -1
  70. package/dist/components/cli-support.js +1 -1
  71. package/dist/config-environments.d.ts +8 -1
  72. package/dist/config-environments.js +2 -0
  73. package/dist/config.d.ts +299 -6
  74. package/dist/config.js +102 -5
  75. package/dist/dead-guards.d.ts +5 -1
  76. package/dist/dead-guards.js +34 -23
  77. package/dist/discovery/sandbox/driver.js +1 -1
  78. package/dist/discovery/specifier-resolve.js +1 -1
  79. package/dist/floor-table.d.ts +3 -1
  80. package/dist/floor-table.data.js +23 -3
  81. package/dist/floor-table.js +4 -3
  82. package/dist/forge-remote.d.ts +13 -0
  83. package/dist/forge-remote.js +15 -0
  84. package/dist/lexicon.d.ts +41 -2
  85. package/dist/lifecycle/__fixtures__/publish-fakes.d.ts +62 -0
  86. package/dist/lifecycle/__fixtures__/publish-fakes.js +270 -3
  87. package/dist/lifecycle/publish-attachments.d.ts +2 -1
  88. package/dist/lifecycle/publish-attachments.js +19 -2
  89. package/dist/lifecycle/publish-cargo.d.ts +99 -0
  90. package/dist/lifecycle/publish-cargo.js +412 -0
  91. package/dist/lifecycle/publish-credentials.d.ts +1 -1
  92. package/dist/lifecycle/publish-credentials.js +8 -0
  93. package/dist/lifecycle/publish-declaration.d.ts +199 -4
  94. package/dist/lifecycle/publish-declaration.js +200 -9
  95. package/dist/lifecycle/publish-forge.d.ts +45 -2
  96. package/dist/lifecycle/publish-forge.js +434 -34
  97. package/dist/lifecycle/publish-git-ssh.d.ts +15 -0
  98. package/dist/lifecycle/publish-git-ssh.js +30 -4
  99. package/dist/lifecycle/publish-github.d.ts +40 -2
  100. package/dist/lifecycle/publish-github.js +100 -3
  101. package/dist/lifecycle/publish-homebrew.d.ts +7 -9
  102. package/dist/lifecycle/publish-homebrew.js +34 -197
  103. package/dist/lifecycle/publish-index.d.ts +141 -0
  104. package/dist/lifecycle/publish-index.js +719 -0
  105. package/dist/lifecycle/publish-marketplace.js +77 -0
  106. package/dist/lifecycle/publish-mcp-registry.d.ts +66 -0
  107. package/dist/lifecycle/publish-mcp-registry.js +306 -0
  108. package/dist/lifecycle/publish-npm.js +165 -2
  109. package/dist/lifecycle/publish-oci.d.ts +34 -1
  110. package/dist/lifecycle/publish-oci.js +246 -7
  111. package/dist/lifecycle/publish-pypi.d.ts +136 -0
  112. package/dist/lifecycle/publish-pypi.js +657 -0
  113. package/dist/lifecycle/publish-record.d.ts +6 -3
  114. package/dist/lifecycle/publish-record.js +6 -3
  115. package/dist/lifecycle/publish-signing.d.ts +147 -0
  116. package/dist/lifecycle/publish-signing.js +257 -0
  117. package/dist/lifecycle/publish-targets.d.ts +27 -1
  118. package/dist/lifecycle/publish-targets.js +80 -0
  119. package/dist/lifecycle/publish-tauri.js +43 -0
  120. package/dist/lifecycle/publish-train-names.d.ts +54 -0
  121. package/dist/lifecycle/publish-train-names.js +118 -0
  122. package/dist/lifecycle/publish-verify.d.ts +121 -0
  123. package/dist/lifecycle/publish-verify.js +130 -0
  124. package/dist/lifecycle/query.js +8 -0
  125. package/dist/lifecycle/release-artifacts.d.ts +212 -0
  126. package/dist/lifecycle/release-artifacts.js +571 -0
  127. package/dist/lifecycle/release-changelog.d.ts +13 -1
  128. package/dist/lifecycle/release-changelog.js +35 -2
  129. package/dist/lifecycle/release-cut.d.ts +58 -3
  130. package/dist/lifecycle/release-cut.js +132 -34
  131. package/dist/lifecycle/release-doctor.d.ts +113 -0
  132. package/dist/lifecycle/release-doctor.js +996 -0
  133. package/dist/lifecycle/release-green.d.ts +86 -0
  134. package/dist/lifecycle/release-green.js +286 -0
  135. package/dist/lifecycle/release-init.d.ts +255 -0
  136. package/dist/lifecycle/release-init.js +859 -0
  137. package/dist/lifecycle/release-intents.d.ts +73 -0
  138. package/dist/lifecycle/release-intents.js +128 -0
  139. package/dist/lifecycle/release-next.d.ts +111 -0
  140. package/dist/lifecycle/release-next.js +252 -0
  141. package/dist/lifecycle/release-prerelease.d.ts +19 -0
  142. package/dist/lifecycle/release-prerelease.js +30 -0
  143. package/dist/lifecycle/release-publish.d.ts +256 -10
  144. package/dist/lifecycle/release-publish.js +246 -34
  145. package/dist/lifecycle/release-status-change.d.ts +226 -0
  146. package/dist/lifecycle/release-status-change.js +478 -0
  147. package/dist/lifecycle/release-status.d.ts +11 -0
  148. package/dist/lifecycle/release-status.js +1 -1
  149. package/dist/lifecycle/release-store.d.ts +73 -2
  150. package/dist/lifecycle/release-store.js +32 -1
  151. package/dist/lifecycle/release-tag.d.ts +142 -0
  152. package/dist/lifecycle/release-tag.js +323 -0
  153. package/dist/lifecycle/release-verify.d.ts +73 -1
  154. package/dist/lifecycle/release-verify.js +117 -2
  155. package/dist/lifecycle/release-version-formats.d.ts +73 -0
  156. package/dist/lifecycle/release-version-formats.js +570 -0
  157. package/dist/lifecycle/release-version.d.ts +58 -10
  158. package/dist/lifecycle/release-version.js +164 -36
  159. package/dist/lifecycle/release-workstation.d.ts +3 -2
  160. package/dist/lifecycle/release-workstation.js +3 -2
  161. package/dist/module-source.d.ts +2 -2
  162. package/dist/module-source.js +8 -8
  163. package/dist/op/generate-pipeline.js +1 -1
  164. package/dist/pr-forge-base.js +4 -2
  165. package/dist/pr-forge.d.ts +20 -2
  166. package/dist/pr-forge.js +46 -10
  167. package/dist/release-floors.d.ts +10 -1
  168. package/dist/release-floors.js +10 -1
  169. package/dist/tool-pins.d.ts +38 -0
  170. package/dist/tool-pins.js +54 -0
  171. package/dist/ts-loader.d.ts +1 -1
  172. package/dist/ts-loader.js +6 -6
  173. package/dist/wave-runtime.mjs +337 -334
  174. package/dist/workspace/ci-forge.d.ts +17 -0
  175. package/dist/workspace/ci-forge.js +17 -0
  176. package/dist/workspace/ci-init.js +1 -1
  177. package/dist/workspace/composites.schema.json +1 -0
  178. package/dist/workspace/declaration.d.ts +8 -0
  179. package/dist/workspace/declaration.js +12 -0
  180. package/dist/workspace/declaration.schema.json +8 -0
  181. package/dist/workspace/environments.d.ts +2 -0
  182. package/dist/workspace/environments.js +1 -1
  183. package/dist/workspace/identity-gate-rule.d.ts +61 -5
  184. package/dist/workspace/identity-gate-rule.js +81 -12
  185. package/dist/workspace/member-pipeline.d.ts +2 -1
  186. package/dist/workspace/member-pipeline.js +5 -2
  187. package/dist/workspace/reason-codes.d.ts +6 -0
  188. package/dist/workspace/reason-codes.js +8 -1
  189. package/dist/workspace/release-changed.d.ts +179 -0
  190. package/dist/workspace/release-changed.js +625 -0
  191. package/dist/workspace/release-changed.schema.json +206 -0
  192. package/dist/workspace/release-steps/artifacts.d.ts +7 -0
  193. package/dist/workspace/release-steps/artifacts.js +45 -0
  194. package/dist/workspace/release-steps/builds.d.ts +12 -0
  195. package/dist/workspace/release-steps/builds.js +38 -0
  196. package/dist/workspace/release-steps/doctor.d.ts +8 -0
  197. package/dist/workspace/release-steps/doctor.js +14 -0
  198. package/dist/workspace/release-steps/goreleaser.d.ts +16 -0
  199. package/dist/workspace/release-steps/goreleaser.js +36 -0
  200. package/dist/workspace/release-steps/green.d.ts +3 -0
  201. package/dist/workspace/release-steps/green.js +6 -0
  202. package/dist/workspace/release-steps/images.d.ts +22 -0
  203. package/dist/workspace/release-steps/images.js +59 -0
  204. package/dist/workspace/release-steps/index.d.ts +9 -0
  205. package/dist/workspace/release-steps/index.js +46 -0
  206. package/dist/workspace/release-steps/pypi.d.ts +15 -0
  207. package/dist/workspace/release-steps/pypi.js +21 -0
  208. package/dist/workspace/release-steps/qemu.d.ts +21 -0
  209. package/dist/workspace/release-steps/qemu.js +35 -0
  210. package/dist/workspace/release-steps/signing.d.ts +18 -0
  211. package/dist/workspace/release-steps/signing.js +30 -0
  212. package/dist/workspace/release-steps/stamp.d.ts +3 -0
  213. package/dist/workspace/release-steps/stamp.js +4 -0
  214. package/dist/workspace/release-steps/targets.d.ts +31 -0
  215. package/dist/workspace/release-steps/targets.js +40 -0
  216. package/dist/workspace/release-steps/types.d.ts +104 -0
  217. package/dist/workspace/release-steps/types.js +2 -0
  218. package/dist/workspace/release-steps/verify.d.ts +3 -0
  219. package/dist/workspace/release-steps/verify.js +4 -0
  220. package/dist/workspace/release-toolchains.d.ts +59 -0
  221. package/dist/workspace/release-toolchains.js +133 -0
  222. package/dist/workspace/release-train-workflow.d.ts +29 -0
  223. package/dist/workspace/release-train-workflow.js +85 -0
  224. package/dist/workspace/release-train.d.ts +3 -1
  225. package/dist/workspace/release-train.js +20 -3
  226. package/dist/workspace/release-workflow.d.ts +160 -61
  227. package/dist/workspace/release-workflow.js +539 -193
  228. package/dist/workspace/releases.schema.json +70 -1
  229. package/dist/workspace/search-contract.d.ts +1 -1
  230. package/dist/workspace/security.js +9 -2
  231. package/dist/workspace/train-cut.d.ts +182 -0
  232. package/dist/workspace/train-cut.js +482 -0
  233. package/dist/workspace/train-prepare.d.ts +61 -0
  234. package/dist/workspace/train-prepare.js +267 -0
  235. package/dist/workspace/train-publish.d.ts +177 -0
  236. package/dist/workspace/train-publish.js +575 -0
  237. package/dist/workspace/train-range-labels.d.ts +33 -0
  238. package/dist/workspace/train-range-labels.js +109 -0
  239. package/dist/workspace/trust/seal.d.ts +13 -3
  240. package/dist/workspace/trust/seal.js +14 -4
  241. package/dist/workspace/work-cli.d.ts +3 -2
  242. package/dist/workspace/work-cli.js +3 -2
  243. package/dist/workspace/workspace-ledger.d.ts +14 -1
  244. package/dist/workspace/workspace-ledger.js +33 -7
  245. package/package.json +26 -26
@@ -18,18 +18,27 @@
18
18
  * publish job runs `chant release stamp <label>` before its build, and
19
19
  * `chant release publish` accepts a tree whose only changes are those files
20
20
  * as the commit's own stamped with the release's label
21
- * ({@link stampedChanges}). Only `version` changes: dependency ranges and
22
- * every other field are left as committed. scripts/release-pack.sh does the
23
- * same for chant itself, and more (the `@intentius/` ranges, the floors, the
24
- * packing in dependency layers), so chant's own release keeps it.
21
+ * ({@link stampedChanges}). By default only `version` changes. With
22
+ * `ranges` (#5155) each workspace dependency's range follows the label the
23
+ * release or a train gives that package: `exact` and `caret` for the
24
+ * packages the release stamps, `train` also for the packages of the other
25
+ * members a release train pins, which `chant workspace train prepare`
26
+ * (#5154) stamps for every member a train cut from one commit. A package
27
+ * path may leave the member as long as it stays inside the repository
28
+ * (#5154), so `release/core` can stamp `../../packages/core`. `files` (#5156) names
29
+ * other manifests the label goes into, by format, field or pattern, edited
30
+ * in place (./release-version-formats.ts).
25
31
  *
26
32
  * This module reaches only Node's built-ins and git.
27
33
  */
28
34
  import { execFileSync } from "node:child_process";
29
35
  import { existsSync, readFileSync, realpathSync, writeFileSync } from "node:fs";
30
36
  import { isAbsolute, posix, relative, resolve } from "node:path";
37
+ import { ManifestStampError, resolveVersionFile, stampVersionFile, versionFilePath } from "./release-version-formats.js";
38
+ export { MANIFEST_FORMATS } from "./release-version-formats.js";
31
39
  /** The first chant with `release.version` and `chant release stamp` (#4840). Products feature-detect on it. */
32
40
  export const RELEASE_VERSION_FLOOR = "0.124.79";
41
+ const RANGE_FIELDS = ["dependencies", "peerDependencies", "optionalDependencies"];
33
42
  export class ReleaseVersionError extends Error {
34
43
  constructor(code, message, fix) {
35
44
  super(message);
@@ -43,36 +52,85 @@ const SEMVER = /^(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(?:-[0-9A-Za-z-]+(?:\.[
43
52
  /** Refuse a label `package.json` can't carry as its version. */
44
53
  export function checkVersionLabel(label) {
45
54
  if (label === null) {
46
- throw new ReleaseVersionError("release-version-no-label", "release.version stamps the release's label into package.json, and this release has no label", "Cut it with a label: chant release cut <version>.");
55
+ throw new ReleaseVersionError("release-version-no-label", "release.version stamps the release's label as the version, and this release has no label", "Cut it with a label: chant release cut <version>.");
47
56
  }
48
57
  if (!SEMVER.test(label)) {
49
- throw new ReleaseVersionError("release-version-label-invalid", `release.version stamps the label into package.json, and "${label}" is not a version npm takes`, `Label the release MAJOR.MINOR.PATCH, such as ${SEMVER.test(label.replace(/^v/, "")) ? label.replace(/^v/, "") : "1.4.0"}${/^v\d/.test(label) ? ", with no v" : ""}.`);
58
+ throw new ReleaseVersionError("release-version-label-invalid", `release.version stamps the label as the version, and "${label}" is not a version npm takes`, `Label the release MAJOR.MINOR.PATCH, such as ${SEMVER.test(label.replace(/^v/, "")) ? label.replace(/^v/, "") : "1.4.0"}${/^v\d/.test(label) ? ", with no v" : ""}.`);
50
59
  }
51
60
  }
52
61
  const norm = (p) => posix.normalize(p.split("\\").join("/")).replace(/\/$/, "") || ".";
53
- const outside = (p) => isAbsolute(p) || norm(p).split("/").includes("..");
54
- /** Check the declaration's paths: at least one package, every path inside the member. */
55
- export function checkReleaseVersion(config) {
56
- if (config.packages.length === 0)
57
- throw new ReleaseVersionError("release-version-invalid", "release.version.packages names no package directory");
58
- for (const p of [...config.packages, ...(typeof config.lockfile === "string" ? [config.lockfile] : [])]) {
59
- if (outside(p))
60
- throw new ReleaseVersionError("release-version-invalid", `release.version: ${p} is not a path inside the member`);
62
+ /**
63
+ * Whether `p` leaves the repository (#5154). A path may climb out of the
64
+ * member with `..`, so a member under `release/<member>` can stamp
65
+ * `../../packages/core`, as long as it stays inside the repository that
66
+ * holds the member. Without `where`, only an absolute path is refused.
67
+ */
68
+ function outside(p, where) {
69
+ if (isAbsolute(p))
70
+ return true;
71
+ if (!where)
72
+ return false;
73
+ const rel = relative(where.top, resolve(where.cwd, norm(p))).split("\\").join("/");
74
+ return rel === ".." || rel.startsWith("../") || isAbsolute(rel);
75
+ }
76
+ /** The repository root that holds `cwd`, or `cwd` itself outside git. */
77
+ function repositoryTop(cwd) {
78
+ try {
79
+ return realpathSync(execFileSync("git", ["rev-parse", "--show-toplevel"], { cwd, encoding: "utf-8", stdio: ["ignore", "pipe", "ignore"] }).trim());
80
+ }
81
+ catch {
82
+ return cwd;
83
+ }
84
+ }
85
+ /**
86
+ * Check the declaration: at least one package or file, every path inside the
87
+ * repository (`where`: the member's directory and the repository root; a path
88
+ * may leave the member, #5154), each file's format known.
89
+ */
90
+ export function checkReleaseVersion(config, where) {
91
+ if (config.ranges !== undefined && !["keep", "exact", "caret", "train"].includes(config.ranges)) {
92
+ throw new ReleaseVersionError("release-version-invalid", `release.version.ranges is "${String(config.ranges)}", not keep, exact, caret or train`);
93
+ }
94
+ const files = config.files ?? [];
95
+ if ((config.packages ?? []).length === 0 && files.length === 0)
96
+ throw new ReleaseVersionError("release-version-invalid", "release.version names no package directory and no file");
97
+ for (const p of [...(config.packages ?? []), ...(typeof config.lockfile === "string" ? [config.lockfile] : []), ...files.map(versionFilePath)]) {
98
+ if (outside(p, where))
99
+ throw new ReleaseVersionError("release-version-invalid", `release.version: ${p} is not a path inside the repository`, "Name the path relative to the member's chant.config.ts; it may leave the member with .., as long as it stays inside the repository.");
100
+ }
101
+ const seen = new Set();
102
+ for (const f of files) {
103
+ const path = norm(versionFilePath(f));
104
+ if (seen.has(path))
105
+ throw new ReleaseVersionError("release-version-invalid", `release.version.files names ${path} twice`, "Stamp a file with one entry: a pattern with several capture groups reaches several places.");
106
+ seen.add(path);
107
+ asVersionError(() => resolveVersionFile(f));
108
+ }
109
+ }
110
+ /** Run `fn`, turning a format's refusal into a {@link ReleaseVersionError}. */
111
+ function asVersionError(fn) {
112
+ try {
113
+ return fn();
114
+ }
115
+ catch (err) {
116
+ if (err instanceof ManifestStampError)
117
+ throw new ReleaseVersionError(err.code, err.message, err.fix);
118
+ throw err;
61
119
  }
62
120
  }
63
121
  /** The lockfile the declaration names, relative to the member, or null. */
64
122
  function lockfileOf(cwd, config) {
65
- if (config.lockfile === false)
123
+ if (config.lockfile === false || (config.packages ?? []).length === 0)
66
124
  return null;
67
125
  if (typeof config.lockfile === "string")
68
126
  return norm(config.lockfile);
69
127
  return existsSync(resolve(cwd, "package-lock.json")) ? "package-lock.json" : null;
70
128
  }
71
- /** The files the release stamps, relative to the member: each package's `package.json`, then the lockfile. */
129
+ /** The files the release stamps, relative to the member: each package's `package.json`, then the lockfile, then `files`. */
72
130
  export function releaseVersionFiles(cwd, config) {
73
- const files = config.packages.map((p) => (norm(p) === "." ? "package.json" : `${norm(p)}/package.json`));
131
+ const files = (config.packages ?? []).map((p) => (norm(p) === "." ? "package.json" : `${norm(p)}/package.json`));
74
132
  const lock = lockfileOf(cwd, config);
75
- return lock ? [...files, lock] : files;
133
+ return [...files, ...(lock ? [lock] : []), ...(config.files ?? []).map((f) => norm(versionFilePath(f)))];
76
134
  }
77
135
  /** The indent a JSON file was written with, so the stamped file differs from it in the version alone. */
78
136
  function indentOf(text) {
@@ -84,18 +142,44 @@ function rewrite(text, edit) {
84
142
  const out = JSON.stringify(doc, null, indentOf(text));
85
143
  return text.endsWith("\n") ? `${out}\n` : out;
86
144
  }
145
+ /** The range a dependency takes under `mode` at `label`. */
146
+ function rangeAt(mode, label) {
147
+ return mode === "exact" ? label : `^${label}`;
148
+ }
149
+ /** The workspace dependencies' ranges in one `dependencies`-bearing object, rewritten in place. A range of `*` is left. */
150
+ function rewriteRanges(holder, mode, table, self) {
151
+ for (const field of RANGE_FIELDS) {
152
+ const deps = holder[field];
153
+ if (!deps || typeof deps !== "object")
154
+ continue;
155
+ const map = deps;
156
+ for (const name of Object.keys(map)) {
157
+ if (name === self || !table.has(name) || map[name] === "*")
158
+ continue;
159
+ const label = table.get(name);
160
+ if (label === null || label === undefined) {
161
+ throw new ReleaseVersionError("release-ranges-unpinned", `${name} is a package of a member the train pins with no label, so its range in ${field} has no version to take`, "Cut that member with a label, record the train again, and stamp from it.");
162
+ }
163
+ map[name] = rangeAt(mode, label);
164
+ }
165
+ }
166
+ }
87
167
  /**
88
168
  * One file's text stamped with `label`: a `package.json`'s `version`, or a
89
169
  * lockfile's entries for `packageDirs` (relative to the lockfile's
90
170
  * directory), with the root entry's `version` beside it for `"."`. A
91
- * lockfile entry that is not there is not added.
171
+ * lockfile entry that is not there is not added. With `ranges` the
172
+ * workspace dependencies' ranges follow (#5155).
92
173
  */
93
- export function stampText(text, label, kind, packageDirs = []) {
174
+ export function stampText(text, label, kind, packageDirs = [], ranges) {
175
+ const active = ranges && ranges.mode !== "keep" ? ranges : undefined;
94
176
  if (kind === "package") {
95
177
  return rewrite(text, (doc) => {
96
178
  if (typeof doc.version !== "string")
97
179
  throw new ReleaseVersionError("release-version-no-package", "package.json has no version to stamp");
98
180
  doc.version = label;
181
+ if (active)
182
+ rewriteRanges(doc, active.mode, active.table, typeof doc.name === "string" ? doc.name : undefined);
99
183
  });
100
184
  }
101
185
  return rewrite(text, (doc) => {
@@ -105,17 +189,51 @@ export function stampText(text, label, kind, packageDirs = []) {
105
189
  const entry = packages[key];
106
190
  if (entry && typeof entry === "object" && typeof entry.version === "string")
107
191
  entry.version = label;
192
+ if (entry && typeof entry === "object" && active)
193
+ rewriteRanges(entry, active.mode, active.table, typeof entry.name === "string" ? entry.name : undefined);
108
194
  if (key === "" && typeof doc.version === "string")
109
195
  doc.version = label;
110
196
  }
111
197
  });
112
198
  }
113
- /** Each stamped file's text, given its committed text. */
114
- function stamper(cwd, config, label) {
199
+ /** The names of the packages `config` stamps, read from their package.json. A file that is missing or has no name is skipped; the stamp refuses it. */
200
+ export function ownNames(cwd, config) {
201
+ const names = [];
202
+ for (const p of config.packages ?? []) {
203
+ try {
204
+ const name = JSON.parse(readFileSync(resolve(cwd, norm(p) === "." ? "package.json" : `${norm(p)}/package.json`), "utf-8")).name;
205
+ if (typeof name === "string")
206
+ names.push(name);
207
+ }
208
+ catch {
209
+ // Refused with its own code when the stamp reads the file.
210
+ }
211
+ }
212
+ return names;
213
+ }
214
+ /** Each stamped file's text, given its committed text. `train` is the labels a train gives other members' packages, for `ranges: "train"`. */
215
+ function stamper(cwd, config, label, train) {
115
216
  const lock = lockfileOf(cwd, config);
116
217
  const lockDir = lock ? posix.dirname(lock) : ".";
117
- const dirs = config.packages.map((p) => norm(posix.relative(lockDir, norm(p))) || ".");
118
- return (file, text) => (file === lock ? stampText(text, label, "lockfile", dirs) : stampText(text, label, "package"));
218
+ const dirs = (config.packages ?? []).map((p) => norm(posix.relative(lockDir, norm(p))) || ".");
219
+ const others = new Map((config.files ?? []).map((f) => [norm(versionFilePath(f)), f]));
220
+ const mode = config.ranges ?? "keep";
221
+ let plan;
222
+ if (mode !== "keep") {
223
+ const table = new Map();
224
+ if (mode === "train")
225
+ for (const [name, l] of Object.entries(train ?? {}))
226
+ table.set(name, l);
227
+ for (const name of ownNames(cwd, config))
228
+ table.set(name, label);
229
+ plan = { mode, table };
230
+ }
231
+ return (file, text) => {
232
+ const other = others.get(file);
233
+ if (other !== undefined)
234
+ return asVersionError(() => stampVersionFile(other, text, label));
235
+ return file === lock ? stampText(text, label, "lockfile", dirs, plan) : stampText(text, label, "package", [], plan);
236
+ };
119
237
  }
120
238
  /**
121
239
  * Stamp the label into each file {@link releaseVersionFiles} names, and
@@ -123,13 +241,16 @@ function stamper(cwd, config, label) {
123
241
  * package directory with no `package.json`, before anything is written.
124
242
  */
125
243
  export function stampReleaseVersion(i) {
126
- checkReleaseVersion(i.config);
244
+ checkReleaseVersion(i.config, { cwd: realpathSync(i.cwd), top: repositoryTop(i.cwd) });
127
245
  checkVersionLabel(i.label);
128
- const stamp = stamper(i.cwd, i.config, i.label);
246
+ const stamp = stamper(i.cwd, i.config, i.label, i.train);
129
247
  const files = releaseVersionFiles(i.cwd, i.config);
248
+ const others = new Set((i.config.files ?? []).map((f) => norm(versionFilePath(f))));
130
249
  const before = new Map();
131
250
  for (const f of files) {
132
251
  const abs = resolve(i.cwd, f);
252
+ if (!existsSync(abs) && others.has(f))
253
+ throw new ReleaseVersionError("release-version-no-file", `release.version.files names ${f}, which does not exist`, "Name the file by its path relative to the member's chant.config.ts.");
133
254
  if (!existsSync(abs))
134
255
  throw new ReleaseVersionError("release-version-no-package", `release.version names ${f}, which does not exist`, "Name the directory that holds the package.json, as the npm target does.");
135
256
  before.set(f, readFileSync(abs, "utf-8"));
@@ -140,8 +261,10 @@ export function stampReleaseVersion(i) {
140
261
  after.set(f, stamp(f, text));
141
262
  }
142
263
  catch (err) {
264
+ if (err instanceof ReleaseVersionError && others.has(f))
265
+ throw err;
143
266
  if (err instanceof ReleaseVersionError)
144
- throw new ReleaseVersionError(err.code, `${f}: ${err.message}`);
267
+ throw new ReleaseVersionError(err.code, `${f}: ${err.message}`, err.fix);
145
268
  throw new ReleaseVersionError("release-version-invalid", `${f} is not JSON: ${err.message}`);
146
269
  }
147
270
  }
@@ -178,7 +301,9 @@ export function stampedChanges(i) {
178
301
  const out = new Set();
179
302
  if (i.label === null || !SEMVER.test(i.label))
180
303
  return out;
181
- const stamp = stamper(i.cwd, i.config, i.label);
304
+ // Under `ranges: "train"` a tree is also the commit's when it was stamped from a train (#5155).
305
+ const label = i.label;
306
+ const stamps = [stamper(i.cwd, i.config, label), ...(i.config.ranges === "train" ? (i.trains ?? []).map((t) => stamper(i.cwd, i.config, label, t)) : [])];
182
307
  const files = new Set(releaseVersionFiles(i.cwd, i.config));
183
308
  // git prints the top as its real path (macOS's /private/var for /var).
184
309
  const cwd = realpathSync(i.cwd);
@@ -194,15 +319,18 @@ export function stampedChanges(i) {
194
319
  const committed = gitShow(i.cwd, i.commit, rel);
195
320
  if (committed === null)
196
321
  continue;
197
- let expected;
198
- try {
199
- expected = stamp(rel, committed);
200
- }
201
- catch {
202
- continue;
322
+ const actual = readFileSync(resolve(i.cwd, rel), "utf-8");
323
+ for (const stamp of stamps) {
324
+ try {
325
+ if (stamp(rel, committed) === actual) {
326
+ out.add(path);
327
+ break;
328
+ }
329
+ }
330
+ catch {
331
+ // This stamp can't be made from the commit's file; try the next.
332
+ }
203
333
  }
204
- if (readFileSync(resolve(i.cwd, rel), "utf-8") === expected)
205
- out.add(path);
206
334
  }
207
335
  return out;
208
336
  }
@@ -17,7 +17,8 @@
17
17
  * - the actor: `--actor`, else the principal the signers file at base lists
18
18
  * for the signing key, else the CI's actor, else git's `user.email`, else
19
19
  * `$USER`.
20
- * - the tag: `release/<label>`, or `release/<member>/<label>` in a workspace
20
+ * - the tag: what `release.tag` renders (./release-tag.ts), by default
21
+ * `release/<label>`, or `release/<member>/<label>` in a workspace
21
22
  * member, an annotated tag on the commit that is created locally and never
22
23
  * pushed by chant.
23
24
  */
@@ -77,7 +78,7 @@ export declare function resolveCutActor(req: {
77
78
  actor: string;
78
79
  source: ActorSource;
79
80
  } | undefined;
80
- /** The tag a labelled release gets: `release/<label>`, or `release/<member>/<label>` for a workspace member. */
81
+ /** The tag a labelled release gets when `release.tag` is unset: `release/<label>`, or `release/<member>/<label>` for a workspace member. See ./release-tag.ts. */
81
82
  export declare function releaseTagName(member: string | null, label: string): string;
82
83
  /**
83
84
  * Whether `tag` can name `commit`: `absent` (the cut creates it), `present`
@@ -17,7 +17,8 @@
17
17
  * - the actor: `--actor`, else the principal the signers file at base lists
18
18
  * for the signing key, else the CI's actor, else git's `user.email`, else
19
19
  * `$USER`.
20
- * - the tag: `release/<label>`, or `release/<member>/<label>` in a workspace
20
+ * - the tag: what `release.tag` renders (./release-tag.ts), by default
21
+ * `release/<label>`, or `release/<member>/<label>` in a workspace
21
22
  * member, an annotated tag on the commit that is created locally and never
22
23
  * pushed by chant.
23
24
  */
@@ -169,7 +170,7 @@ export function resolveCutActor(req) {
169
170
  return { actor: env.USER, source: "user" };
170
171
  return undefined;
171
172
  }
172
- /** The tag a labelled release gets: `release/<label>`, or `release/<member>/<label>` for a workspace member. */
173
+ /** The tag a labelled release gets when `release.tag` is unset: `release/<label>`, or `release/<member>/<label>` for a workspace member. See ./release-tag.ts. */
173
174
  export function releaseTagName(member, label) {
174
175
  return member ? `release/${member}/${label}` : `release/${label}`;
175
176
  }
@@ -52,8 +52,8 @@ export declare function isJavaScriptModule(pathOrUrl: string): boolean;
52
52
  * #3981 — the package export conditions chant adds to `import`, `node` and
53
53
  * `default` when it resolves a package itself (fold's import resolution, the
54
54
  * sandbox bundle), so it lands on the module this process's `import()` would.
55
- * Each chant package maps `development` to `src/*.ts` and `default` to the
56
- * compiled `dist/*.js` it publishes. `["development"]` when the process
55
+ * Each chant package maps `@intentius/chant-source` to `src/*.ts` and `default` to the
56
+ * compiled `dist/*.js` it publishes. `["@intentius/chant-source"]` when the process
57
57
  * resolves with it ({@link resolvesDevelopment}), else empty.
58
58
  */
59
59
  export declare const SOURCE_EXPORT_CONDITIONS: readonly string[];
@@ -83,10 +83,10 @@ export function isJavaScriptModule(pathOrUrl) {
83
83
  }
84
84
  /**
85
85
  * #3981 — whether this process resolves chant's packages through their
86
- * `development` export condition: always when chant runs from source (the
86
+ * `@intentius/chant-source` export condition: always when chant runs from source (the
87
87
  * CLI's `main()` installs a resolve hook that does so, and vitest's resolver
88
88
  * adds the condition outside production mode), and otherwise when node runs
89
- * with `--conditions=development` (or `-C development`, on the command line
89
+ * with `--conditions=@intentius/chant-source` (or `-C @intentius/chant-source`, on the command line
90
90
  * or in `NODE_OPTIONS`). Not from the environment: a compiled CLI that a test
91
91
  * spawns inherits vitest's variables.
92
92
  */
@@ -96,16 +96,16 @@ function resolvesDevelopment() {
96
96
  if (typeof process === "undefined")
97
97
  return false;
98
98
  const flags = [...process.execArgv, ...(process.env.NODE_OPTIONS ?? "").split(/\s+/)];
99
- return flags.some((flag, i) => flag === "--conditions=development" ||
100
- flag === "-C=development" ||
101
- ((flag === "--conditions" || flag === "-C") && flags[i + 1] === "development"));
99
+ return flags.some((flag, i) => flag === "--conditions=@intentius/chant-source" ||
100
+ flag === "-C=@intentius/chant-source" ||
101
+ ((flag === "--conditions" || flag === "-C") && flags[i + 1] === "@intentius/chant-source"));
102
102
  }
103
103
  /**
104
104
  * #3981 — the package export conditions chant adds to `import`, `node` and
105
105
  * `default` when it resolves a package itself (fold's import resolution, the
106
106
  * sandbox bundle), so it lands on the module this process's `import()` would.
107
- * Each chant package maps `development` to `src/*.ts` and `default` to the
108
- * compiled `dist/*.js` it publishes. `["development"]` when the process
107
+ * Each chant package maps `@intentius/chant-source` to `src/*.ts` and `default` to the
108
+ * compiled `dist/*.js` it publishes. `["@intentius/chant-source"]` when the process
109
109
  * resolves with it ({@link resolvesDevelopment}), else empty.
110
110
  */
111
- export const SOURCE_EXPORT_CONDITIONS = resolvesDevelopment() ? ["development"] : [];
111
+ export const SOURCE_EXPORT_CONDITIONS = resolvesDevelopment() ? ["@intentius/chant-source"] : [];
@@ -69,7 +69,7 @@ export async function generateOpsPipeline(ops, lexicon, options, cwd) {
69
69
  if (!plugin?.generateOpPipeline) {
70
70
  return {
71
71
  success: false,
72
- error: `Lexicon "${lexicon}" does not support Op generate mode (no generateOpPipeline). GitLab, GitHub, and Forgejo are supported today.`,
72
+ error: `Lexicon "${lexicon}" does not support Op generate mode (no generateOpPipeline). GitLab, GitHub, Forgejo and Prow are supported today.`,
73
73
  };
74
74
  }
75
75
  const discovered = await discoverOps({ cwd });
@@ -22,8 +22,10 @@ export function pullRequestBaseFromEnv(kind, env = process.env, fetchImpl = (url
22
22
  }
23
23
  const token = env.CHANT_FORGE_TOKEN ?? env.GITHUB_TOKEN ?? env.GH_TOKEN;
24
24
  const api = env.GITHUB_API_URL ?? (kind === "github" ? "https://api.github.com" : undefined);
25
- if (!env.GITHUB_REPOSITORY || !token || !api)
25
+ // #5170: a Prow job names its GitHub repository in Prow's own variables, as `prowJobOf` in ./pr-forge.ts reads them.
26
+ const repo = env.GITHUB_REPOSITORY || (kind === "github" && env.PROW_JOB_ID && env.REPO_OWNER && env.REPO_NAME ? `${env.REPO_OWNER}/${env.REPO_NAME}` : undefined);
27
+ if (!repo || !token || !api)
26
28
  return undefined;
27
29
  const headers = kind === "github" ? { authorization: `Bearer ${token}`, accept: "application/vnd.github+json", "user-agent": "chant" } : { authorization: `token ${token}`, accept: "application/json" };
28
- return (pr) => read(`${api.replace(/\/+$/, "")}/repos/${env.GITHUB_REPOSITORY}/pulls/${pr}`, headers, (b) => (b.base && typeof b.base === "object" ? b.base.ref : undefined));
30
+ return (pr) => read(`${api.replace(/\/+$/, "")}/repos/${repo}/pulls/${pr}`, headers, (b) => (b.base && typeof b.base === "object" ? b.base.ref : undefined));
29
31
  }
@@ -626,11 +626,25 @@ export declare class ForgeEnvironmentError extends Error {
626
626
  */
627
627
  export declare function forgeFromEnv(kind: ForgeKind, env?: Record<string, string | undefined>, fetchImpl?: ForgeFetch): PrForge;
628
628
  type Env = Record<string, string | undefined>;
629
+ /**
630
+ * What a Prow job's pod says about its GitHub repository (#5170), or
631
+ * undefined outside a Prow job. Prow's pod utilities set `PROW_JOB_ID` in
632
+ * every job, `REPO_OWNER` and `REPO_NAME` in a presubmit and a postsubmit
633
+ * (and a periodic with `extra_refs`), `PULL_NUMBER` and `PULL_PULL_SHA` in a
634
+ * presubmit, and `PULL_BASE_SHA` beside them. Prow is the CI system here, and
635
+ * GitHub is still the forge whose API chant reads.
636
+ */
637
+ export declare function prowJobOf(env?: Env): {
638
+ repo?: string;
639
+ pr?: number;
640
+ sha?: string;
641
+ } | undefined;
629
642
  /**
630
643
  * The forge a CI job runs on, from its environment, or undefined outside a
631
- * GitHub Actions, GitLab CI or Forgejo Actions job. Forgejo is told apart by
644
+ * GitHub Actions, GitLab CI, Forgejo Actions or Prow job. Forgejo is told apart by
632
645
  * `FORGEJO_ACTIONS` or `GITEA_ACTIONS`, or by a GitHub-style job whose
633
- * `GITHUB_API_URL` ends in `/api/v1`, which GitHub never serves.
646
+ * `GITHUB_API_URL` ends in `/api/v1`, which GitHub never serves. A Prow job
647
+ * that names its repository ({@link prowJobOf}) is on GitHub (#5170).
634
648
  */
635
649
  export declare function detectForge(env?: Env): ForgeKind | undefined;
636
650
  /** Where a CI job posts: the forge, the repository, the token, and the pull request and commit when there are ones. */
@@ -687,6 +701,10 @@ export declare const FORGE_TOKEN_ORDER: Record<ForgeKind, readonly string[]>;
687
701
  * `GITHUB_REF`, its head from the payload, else `GITHUB_SHA`.
688
702
  * - Forgejo Actions: the same, with `FORGEJO_*` read before `GITHUB_*`,
689
703
  * and the REST base `<server>/api/v1` when no API URL is set.
704
+ * - Prow, for the GitHub forge (#5170): the same `GITHUB_*` names when the
705
+ * job sets them, else `REPO_OWNER`/`REPO_NAME`, `PULL_NUMBER`, and
706
+ * `PULL_PULL_SHA` or `PULL_BASE_SHA` ({@link prowJobOf}). The token comes
707
+ * from the job's own variables, such as a Secret mounted as `GITHUB_TOKEN`.
690
708
  * - GitLab CI: `CI_API_V4_URL` (or `CI_SERVER_URL/api/v4`), the merge
691
709
  * request's project before the pipeline's (a fork's merge request runs in
692
710
  * the fork), `CI_MERGE_REQUEST_IID`, `CI_COMMIT_SHA`, `CI_PIPELINE_URL`.
package/dist/pr-forge.js CHANGED
@@ -1329,8 +1329,11 @@ export function forgeFromEnv(kind, env = process.env, fetchImpl) {
1329
1329
  }
1330
1330
  const token = env.CHANT_FORGE_TOKEN ?? env.GITHUB_TOKEN ?? env.GH_TOKEN;
1331
1331
  const host = hostOf(env.GITHUB_SERVER_URL);
1332
+ // #5170: a Prow job names its GitHub repository in Prow's own variables.
1333
+ const prow = kind === "github" ? prowJobOf(env) : undefined;
1334
+ const repo = env.GITHUB_REPOSITORY || prow?.repo;
1332
1335
  const missing = [
1333
- ...(env.GITHUB_REPOSITORY ? [] : ["GITHUB_REPOSITORY"]),
1336
+ ...(repo ? [] : [prow ? PROW_REPO_MISSING : "GITHUB_REPOSITORY"]),
1334
1337
  ...(token ? [] : ["GITHUB_TOKEN or CHANT_FORGE_TOKEN"]),
1335
1338
  ...(kind === "forgejo" && !host ? ["GITHUB_SERVER_URL"] : []),
1336
1339
  ...(kind === "forgejo" && !env.GITHUB_API_URL ? ["GITHUB_API_URL"] : []),
@@ -1338,11 +1341,11 @@ export function forgeFromEnv(kind, env = process.env, fetchImpl) {
1338
1341
  if (missing.length > 0)
1339
1342
  throw new ForgeEnvironmentError(kind, missing);
1340
1343
  const runUrl = env.GITHUB_SERVER_URL && env.GITHUB_RUN_ID
1341
- ? `${env.GITHUB_SERVER_URL.replace(/\/+$/, "")}/${env.GITHUB_REPOSITORY}/actions/runs/${env.GITHUB_RUN_ID}`
1344
+ ? `${env.GITHUB_SERVER_URL.replace(/\/+$/, "")}/${repo}/actions/runs/${env.GITHUB_RUN_ID}`
1342
1345
  : undefined;
1343
1346
  const opts = {
1344
1347
  apiBase: env.GITHUB_API_URL ?? "https://api.github.com",
1345
- repo: env.GITHUB_REPOSITORY,
1348
+ repo: repo,
1346
1349
  token: token,
1347
1350
  ...(runUrl ? { runUrl } : {}),
1348
1351
  ...f,
@@ -1350,11 +1353,34 @@ export function forgeFromEnv(kind, env = process.env, fetchImpl) {
1350
1353
  return kind === "forgejo" ? forgejoForge({ ...opts, host: host }) : githubForge({ ...opts, host: host ?? "github.com" });
1351
1354
  }
1352
1355
  const truthy = (v) => v === "true" || v === "1";
1356
+ const PROW_REPO_MISSING = "GITHUB_REPOSITORY, or REPO_OWNER and REPO_NAME from Prow";
1357
+ /**
1358
+ * What a Prow job's pod says about its GitHub repository (#5170), or
1359
+ * undefined outside a Prow job. Prow's pod utilities set `PROW_JOB_ID` in
1360
+ * every job, `REPO_OWNER` and `REPO_NAME` in a presubmit and a postsubmit
1361
+ * (and a periodic with `extra_refs`), `PULL_NUMBER` and `PULL_PULL_SHA` in a
1362
+ * presubmit, and `PULL_BASE_SHA` beside them. Prow is the CI system here, and
1363
+ * GitHub is still the forge whose API chant reads.
1364
+ */
1365
+ export function prowJobOf(env = process.env) {
1366
+ if (!env.PROW_JOB_ID?.trim())
1367
+ return undefined;
1368
+ const owner = env.REPO_OWNER?.trim();
1369
+ const name = env.REPO_NAME?.trim();
1370
+ const pr = num(env.PULL_NUMBER?.trim());
1371
+ const sha = env.PULL_PULL_SHA?.trim() || env.PULL_BASE_SHA?.trim();
1372
+ return {
1373
+ ...(owner && name ? { repo: `${owner}/${name}` } : {}),
1374
+ ...(pr !== undefined && pr > 0 ? { pr } : {}),
1375
+ ...(sha ? { sha } : {}),
1376
+ };
1377
+ }
1353
1378
  /**
1354
1379
  * The forge a CI job runs on, from its environment, or undefined outside a
1355
- * GitHub Actions, GitLab CI or Forgejo Actions job. Forgejo is told apart by
1380
+ * GitHub Actions, GitLab CI, Forgejo Actions or Prow job. Forgejo is told apart by
1356
1381
  * `FORGEJO_ACTIONS` or `GITEA_ACTIONS`, or by a GitHub-style job whose
1357
- * `GITHUB_API_URL` ends in `/api/v1`, which GitHub never serves.
1382
+ * `GITHUB_API_URL` ends in `/api/v1`, which GitHub never serves. A Prow job
1383
+ * that names its repository ({@link prowJobOf}) is on GitHub (#5170).
1358
1384
  */
1359
1385
  export function detectForge(env = process.env) {
1360
1386
  if (truthy(env.GITLAB_CI))
@@ -1363,6 +1389,8 @@ export function detectForge(env = process.env) {
1363
1389
  return "forgejo";
1364
1390
  if (truthy(env.GITHUB_ACTIONS))
1365
1391
  return /\/api\/v1\/?$/.test(env.GITHUB_API_URL ?? "") ? "forgejo" : "github";
1392
+ if (prowJobOf(env)?.repo)
1393
+ return "github";
1366
1394
  return undefined;
1367
1395
  }
1368
1396
  /**
@@ -1410,6 +1438,10 @@ function prFromEvent(payload, ref) {
1410
1438
  * `GITHUB_REF`, its head from the payload, else `GITHUB_SHA`.
1411
1439
  * - Forgejo Actions: the same, with `FORGEJO_*` read before `GITHUB_*`,
1412
1440
  * and the REST base `<server>/api/v1` when no API URL is set.
1441
+ * - Prow, for the GitHub forge (#5170): the same `GITHUB_*` names when the
1442
+ * job sets them, else `REPO_OWNER`/`REPO_NAME`, `PULL_NUMBER`, and
1443
+ * `PULL_PULL_SHA` or `PULL_BASE_SHA` ({@link prowJobOf}). The token comes
1444
+ * from the job's own variables, such as a Secret mounted as `GITHUB_TOKEN`.
1413
1445
  * - GitLab CI: `CI_API_V4_URL` (or `CI_SERVER_URL/api/v4`), the merge
1414
1446
  * request's project before the pipeline's (a fork's merge request runs in
1415
1447
  * the fork), `CI_MERGE_REQUEST_IID`, `CI_COMMIT_SHA`, `CI_PIPELINE_URL`.
@@ -1458,7 +1490,9 @@ export function forgeTargetFromEnv(env = process.env, opts = {}) {
1458
1490
  }
1459
1491
  const fj = kind === "forgejo";
1460
1492
  const read = (name) => (fj ? pick(`FORGEJO_${name}`, `GITHUB_${name}`) : pick(`GITHUB_${name}`));
1461
- const repo = read("REPOSITORY");
1493
+ // #5170: in a Prow job, Prow's variables name what GitHub Actions' would; a GITHUB_* one set by the job still wins.
1494
+ const prow = fj ? undefined : prowJobOf(env);
1495
+ const repo = read("REPOSITORY") ?? prow?.repo;
1462
1496
  const server = read("SERVER_URL")?.replace(/\/+$/, "");
1463
1497
  const apiBase = read("API_URL")?.replace(/\/+$/, "") ?? (fj ? (server ? `${server}/api/v1` : undefined) : "https://api.github.com");
1464
1498
  let event;
@@ -1472,18 +1506,20 @@ export function forgeTargetFromEnv(env = process.env, opts = {}) {
1472
1506
  event = undefined;
1473
1507
  }
1474
1508
  }
1475
- const { pr, sha: head } = prFromEvent(event, read("REF"));
1509
+ const fromEvent = prFromEvent(event, read("REF"));
1510
+ const pr = fromEvent.pr ?? prow?.pr;
1511
+ const head = fromEvent.sha;
1476
1512
  if (!repo)
1477
- missing.push(fj ? "FORGEJO_REPOSITORY or GITHUB_REPOSITORY" : "GITHUB_REPOSITORY");
1513
+ missing.push(fj ? "FORGEJO_REPOSITORY or GITHUB_REPOSITORY" : prow ? PROW_REPO_MISSING : "GITHUB_REPOSITORY");
1478
1514
  if (!apiBase)
1479
1515
  missing.push("GITHUB_SERVER_URL or GITHUB_API_URL");
1480
1516
  if (opts.requirePr && !pr)
1481
- missing.push("a pull request (a pull_request event, or refs/pull/<n>/ in GITHUB_REF)");
1517
+ missing.push(`a pull request (a pull_request event, ${prow ? "refs/pull/<n>/ in GITHUB_REF, or PULL_NUMBER from a Prow presubmit" : "or refs/pull/<n>/ in GITHUB_REF"})`);
1482
1518
  if (!token)
1483
1519
  missing.push(tokenMissing);
1484
1520
  if (missing.length > 0)
1485
1521
  throw new ForgeEnvironmentError(kind, missing);
1486
- const sha = head ?? read("SHA");
1522
+ const sha = head ?? read("SHA") ?? prow?.sha;
1487
1523
  const runId = read("RUN_ID");
1488
1524
  const runUrl = server && runId ? `${server}/${repo}/actions/runs/${runId}` : undefined;
1489
1525
  return {
@@ -18,8 +18,15 @@
18
18
  * version into every floor that names this constant as a literal, and moves
19
19
  * this constant to the next patch (#4501). The check fails while a floor
20
20
  * still names this constant after its version shipped.
21
+ *
22
+ * A new floor is declared next to the code it gates, in that feature's own
23
+ * file, as `export const <NAME>_FLOOR = NEXT_RELEASE;` with NEXT_RELEASE
24
+ * imported from here (#5196): scripts/floor-table.ts collects every floor
25
+ * under packages/core/src, so parallel features add floors to different
26
+ * files rather than to the end of this one. The floors below were declared
27
+ * here before that and keep the subpath they shipped under.
21
28
  */
22
- export declare const NEXT_RELEASE = "0.124.99";
29
+ export declare const NEXT_RELEASE = "0.124.101";
23
30
  /** The first chant with `chant dev local` and `chant dev bundle-check`, `@intentius/chant/local-chant` and `@intentius/chant/bundle-check` (`chantRuntimeTarget`, `chantExternalPlugin`, `checkBundle`): a product built against a chant checkout, and its bundle checked, without its own scripts (#4787). */
24
31
  export declare const LOCAL_CHANT_FLOOR = "0.124.86";
25
32
  /** The first chant with `chant workspace ref-gate` (pre-receive, pre-push, check, status, attach, install) and `refs` in `.chant/trust.json`, the checks a ref update needs evidence for (#4867). */
@@ -192,3 +199,5 @@ export declare const GITLAB_WAVE_EVIDENCE_RETRY_FLOOR = "0.124.89";
192
199
  export declare const TERRAFORM_COMMAND_TRACE_FLOOR = "0.124.91";
193
200
  /** The first chant whose product pipeline limits comment commands to logins and teams on GitHub and Forgejo (INTENTIUS/terragucci#1461): `commentAllow: { allow, tokenSecret? }` in `productPipelineJobs`, where `allow` maps `plan`, `apply`, `lock`, `unlock`, `agent` and `default` to logins and `team:<org>/<team>` entries. The map is written as `CHANT_COMMENT_ALLOW` into the comment job, the product plan's re-plan decision and the agent's jobs (a spec's `agent.commentAllow`), so it is read from the workflow on the default branch. `answerProductComment` takes `allow` and replies to a commenter the list leaves out, `ForgeReads.teamMember` reads a team on GitHub and Forgejo, `CHANT_COMMENT_ALLOW_TOKEN` (`tokenSecret`) carries a token that can read teams, and a team the forge cannot answer for fails closed with a message. */
194
201
  export declare const COMMENT_ALLOW_FLOOR = "0.124.98";
202
+ /** The first chant with `chant release changed`, the members to release at a commit with their dependency closure, and `release.legacyTags` in `chant.config.ts` (#5134). */
203
+ export declare const RELEASE_CHANGED_FLOOR = "0.124.100";
@@ -18,8 +18,15 @@
18
18
  * version into every floor that names this constant as a literal, and moves
19
19
  * this constant to the next patch (#4501). The check fails while a floor
20
20
  * still names this constant after its version shipped.
21
+ *
22
+ * A new floor is declared next to the code it gates, in that feature's own
23
+ * file, as `export const <NAME>_FLOOR = NEXT_RELEASE;` with NEXT_RELEASE
24
+ * imported from here (#5196): scripts/floor-table.ts collects every floor
25
+ * under packages/core/src, so parallel features add floors to different
26
+ * files rather than to the end of this one. The floors below were declared
27
+ * here before that and keep the subpath they shipped under.
21
28
  */
22
- export const NEXT_RELEASE = "0.124.99";
29
+ export const NEXT_RELEASE = "0.124.101";
23
30
  /** The first chant with `chant dev local` and `chant dev bundle-check`, `@intentius/chant/local-chant` and `@intentius/chant/bundle-check` (`chantRuntimeTarget`, `chantExternalPlugin`, `checkBundle`): a product built against a chant checkout, and its bundle checked, without its own scripts (#4787). */
24
31
  export const LOCAL_CHANT_FLOOR = "0.124.86";
25
32
  /** The first chant with `chant workspace ref-gate` (pre-receive, pre-push, check, status, attach, install) and `refs` in `.chant/trust.json`, the checks a ref update needs evidence for (#4867). */
@@ -192,3 +199,5 @@ export const GITLAB_WAVE_EVIDENCE_RETRY_FLOOR = "0.124.89";
192
199
  export const TERRAFORM_COMMAND_TRACE_FLOOR = "0.124.91";
193
200
  /** The first chant whose product pipeline limits comment commands to logins and teams on GitHub and Forgejo (INTENTIUS/terragucci#1461): `commentAllow: { allow, tokenSecret? }` in `productPipelineJobs`, where `allow` maps `plan`, `apply`, `lock`, `unlock`, `agent` and `default` to logins and `team:<org>/<team>` entries. The map is written as `CHANT_COMMENT_ALLOW` into the comment job, the product plan's re-plan decision and the agent's jobs (a spec's `agent.commentAllow`), so it is read from the workflow on the default branch. `answerProductComment` takes `allow` and replies to a commenter the list leaves out, `ForgeReads.teamMember` reads a team on GitHub and Forgejo, `CHANT_COMMENT_ALLOW_TOKEN` (`tokenSecret`) carries a token that can read teams, and a team the forge cannot answer for fails closed with a message. */
194
201
  export const COMMENT_ALLOW_FLOOR = "0.124.98";
202
+ /** The first chant with `chant release changed`, the members to release at a commit with their dependency closure, and `release.legacyTags` in `chant.config.ts` (#5134). */
203
+ export const RELEASE_CHANGED_FLOOR = "0.124.100";