@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
@@ -0,0 +1,342 @@
1
+ /**
2
+ * `chant release init [--yes] [--force] [--one-release] [--forge github|gitlab|forgejo] [--json]`
3
+ * (#5160): set up `chant release` in a project that has never used chant. A
4
+ * dry run unless `--yes`. An npm, pnpm or yarn workspace with several
5
+ * publishable packages gets a release train (#5154): a member per package
6
+ * and `release.train` at the root, unless `--one-release`. See
7
+ * ../../lifecycle/release-init.ts.
8
+ */
9
+ import { appendFileSync, existsSync, readFileSync, writeFileSync } from "node:fs";
10
+ import { join, relative, resolve, sep } from "node:path";
11
+ import { formatBold, formatError, formatSuccess, formatWarning } from "../format.js";
12
+ const USAGE = "chant release init [--yes] [--force] [--one-release] [--forge github|gitlab|forgejo] [--json]";
13
+ export async function runReleaseInit(ctx) {
14
+ const { args } = ctx;
15
+ const root = resolve(".");
16
+ const json = args.json === true;
17
+ const write = args.yes === true;
18
+ const force = args.force === true;
19
+ const { detectProject, planRelease, planTrain, trainFit, releaseBlockSource, } = await import("../../lifecycle/release-init.js");
20
+ const fail = (code, message, fix, block) => {
21
+ if (json)
22
+ console.log(JSON.stringify({ error: { code, message, ...(fix ? { fix } : {}) } }, null, 2));
23
+ else {
24
+ console.error(formatError({ message: `${message} [${code}]`, ...(fix ? { hint: fix } : {}) }));
25
+ if (block)
26
+ console.error(`\n ${block}\n`);
27
+ }
28
+ return 1;
29
+ };
30
+ if (!["package.json", "go.mod", "Cargo.toml", "pyproject.toml", "setup.py", "Dockerfile", "chant.config.ts", "chant.config.json"].some((f) => existsSync(join(root, f))) && !existsSync(join(root, ".git"))) {
31
+ return fail("release-init-not-a-project", "this directory holds no package.json, go.mod, Cargo.toml, pyproject.toml, Dockerfile or git repository", "Run chant release init in the project's root.");
32
+ }
33
+ const facts = detectProject(root);
34
+ if (args.forge !== undefined) {
35
+ if (!["github", "gitlab", "forgejo"].includes(args.forge))
36
+ return fail("release-init-forge-invalid", `--forge ${JSON.stringify(args.forge)} is not one of github, gitlab, forgejo`, USAGE);
37
+ facts.workflowForge = args.forge;
38
+ }
39
+ const { readerVersion } = await import("../../workspace/declaration.js");
40
+ const plan = planRelease(facts, { chantVersion: readerVersion() });
41
+ const block = releaseBlockSource(plan.release, " ");
42
+ const fit = trainFit(facts);
43
+ if (fit.train && args.oneRelease !== true)
44
+ return runTrainInit(ctx, root, planTrain(facts, { chantVersion: readerVersion() }), facts.workflowForge, fail);
45
+ if (!fit.train && fit.why)
46
+ plan.notes.push(`One release for every package, not a release train: ${fit.why}.`);
47
+ if (fit.train)
48
+ plan.reasons.unshift("--one-release: every package is released together, at one label under one tag");
49
+ const prepared = await prepareConfig(root, plan.release, force);
50
+ if ("error" in prepared)
51
+ return fail(prepared.error.code, prepared.error.message, prepared.error.fix, block);
52
+ const { configPath, configText, configName, created } = prepared;
53
+ // The workflow file: one chant generated is regenerated; any other is left alone without --force.
54
+ const { gitTop } = await import("../../workspace/tree.js");
55
+ const top = gitTop(root) ?? root;
56
+ if (!force && !(await workflowIsOurs(join(top, plan.workflowFile)))) {
57
+ return fail("release-init-workflow-exists", `${plan.workflowFile} exists and chant did not write it`, "Run again with --force to replace it.");
58
+ }
59
+ const gr = plan.goreleaserPatch;
60
+ // The first label: `auto` when release next reads the previous release
61
+ // from the tag history (#5200), else a patch after the newest tag, else 0.1.0.
62
+ const newest = facts.tags.newest ? /(\d+)\.(\d+)\.(\d+)(?:[-+].*)?$/.exec(facts.tags.newest) : null;
63
+ const label = plan.readsHistory ? "auto" : newest ? `${newest[1]}.${newest[2]}.${Number(newest[3]) + 1}` : "0.1.0";
64
+ const wf = plan.workflowFile.split("/").pop();
65
+ const next = [
66
+ ...(write ? [] : ["chant release init --yes"]),
67
+ `git add ${configName} ${plan.workflowFile}${gr?.append ? ` ${gr.file}` : ""} && git commit -m "ci: release with chant" && git push`,
68
+ // #5161: what the registries say of the targets, once their setup is done.
69
+ "chant release doctor",
70
+ facts.workflowForge === "github"
71
+ ? `gh workflow run ${wf} -f label=${label}${plan.readsHistory ? ` # the label from the commits since ${facts.tags.newest}` : ""}`
72
+ : `start ${plan.workflowFile} by hand with the label ${label}${plan.readsHistory ? ` (the label from the commits since ${facts.tags.newest})` : ""}`,
73
+ facts.workflowForge === "github"
74
+ ? `# each later release: gh workflow run ${wf} -f label=auto (the label from the commits since the previous release)`
75
+ : `# each later release: start ${plan.workflowFile} with the label auto (the label from the commits since the previous release)`,
76
+ ];
77
+ if (json) {
78
+ const out = { dryRun: !write, layout: "one-release", config: configName, created, release: plan.release, reasons: plan.reasons, notes: plan.notes, registry: plan.registry, workflow: plan.workflowFile, goreleaser: gr, next };
79
+ if (!write) {
80
+ console.log(JSON.stringify(out, null, 2));
81
+ return 0;
82
+ }
83
+ }
84
+ else {
85
+ console.log(formatBold(`${write ? "" : "Dry run: "}release block for ${configName}${created ? " (a new file)" : ""}`));
86
+ console.log(`\n ${block}\n`);
87
+ console.log(formatBold("Why"));
88
+ for (const r of plan.reasons)
89
+ console.log(` - ${r}`);
90
+ if (plan.notes.length > 0) {
91
+ console.log(formatBold("\nNot covered"));
92
+ for (const n of plan.notes)
93
+ console.log(` - ${n}`);
94
+ }
95
+ }
96
+ if (write) {
97
+ writeFileSync(configPath, configText);
98
+ if (!json)
99
+ console.log(formatSuccess(`${created ? "Wrote" : "Updated"} ${configName}.`));
100
+ if (gr?.append) {
101
+ const grPath = join(root, gr.file);
102
+ const text = readFileSync(grPath, "utf-8");
103
+ appendFileSync(grPath, `${text.endsWith("\n") ? "" : "\n"}${gr.append}`);
104
+ if (!json)
105
+ console.log(formatSuccess(`Added snapshot.version_template to ${gr.file}, so the snapshot build carries the release's label.`));
106
+ }
107
+ const { runReleaseWorkflow } = await import("../../workspace/release-workflow.js");
108
+ const log = console.log;
109
+ if (json)
110
+ console.log = console.error;
111
+ let code;
112
+ try {
113
+ code = await runReleaseWorkflow({ ...ctx, args: { ...ctx.args, forge: facts.workflowForge } });
114
+ }
115
+ finally {
116
+ console.log = log;
117
+ }
118
+ if (code !== 0)
119
+ return code;
120
+ }
121
+ else if (!json) {
122
+ console.log(`\nWould write ${configName} and ${plan.workflowFile} (with chant release workflow)${gr?.append ? `, and add snapshot.version_template to ${gr.file}` : ""}.`);
123
+ }
124
+ if (gr?.manual && !json)
125
+ console.log(formatWarning({ message: gr.manual }));
126
+ if (json) {
127
+ console.log(JSON.stringify({ dryRun: false, layout: "one-release", config: configName, created, release: plan.release, reasons: plan.reasons, notes: plan.notes, registry: plan.registry, workflow: plan.workflowFile, goreleaser: gr, next }, null, 2));
128
+ return 0;
129
+ }
130
+ if (plan.registry.length > 0) {
131
+ console.log(formatBold("\nOn the registries, by hand"));
132
+ for (const r of plan.registry)
133
+ console.log(` - ${r}`);
134
+ }
135
+ console.log(formatBold("\nNext"));
136
+ for (const n of next)
137
+ console.log(` ${n}`);
138
+ return 0;
139
+ }
140
+ /** Whether the workflow file is absent or one chant generated, so writing it replaces nothing a person wrote. */
141
+ async function workflowIsOurs(path) {
142
+ if (!existsSync(path))
143
+ return true;
144
+ const { GENERATED_MARKER } = await import("../../discovery/files.js");
145
+ return readFileSync(path, "utf-8").includes(GENERATED_MARKER);
146
+ }
147
+ /**
148
+ * The config of the project at `dir` with `release` written in: its
149
+ * chant.config.ts edited in place, its chant.config.json rewritten, or a new
150
+ * chant.config.ts.
151
+ */
152
+ async function prepareConfig(dir, release, force) {
153
+ const { insertReleaseBlock, newConfigSource, ReleaseInitError } = await import("../../lifecycle/release-init.js");
154
+ const tsPath = join(dir, "chant.config.ts");
155
+ const jsonPath = join(dir, "chant.config.json");
156
+ let configPath;
157
+ let configText;
158
+ try {
159
+ if (existsSync(tsPath)) {
160
+ configPath = tsPath;
161
+ const before = readFileSync(tsPath, "utf-8");
162
+ configText = insertReleaseBlock(before, release, force);
163
+ // A release the text scan can't see, such as one spread in from elsewhere, is still a release block.
164
+ if (!force && !/\brelease\s*:/.test(before)) {
165
+ try {
166
+ const { loadChantConfig } = await import("../../config.js");
167
+ const loaded = (await loadChantConfig(dir)).config.release;
168
+ if (loaded && Object.keys(loaded).length > 0)
169
+ throw new ReleaseInitError("release-init-release-exists", "chant.config.ts already declares release", "Add the fields shown here to it by hand.");
170
+ }
171
+ catch (err) {
172
+ if (err instanceof ReleaseInitError)
173
+ throw err;
174
+ // A config that can't be loaded here is edited by its text alone.
175
+ }
176
+ }
177
+ }
178
+ else if (existsSync(jsonPath)) {
179
+ configPath = jsonPath;
180
+ const parsed = JSON.parse(readFileSync(jsonPath, "utf-8"));
181
+ if (parsed.release !== undefined && !force)
182
+ throw new ReleaseInitError("release-init-release-exists", "chant.config.json already has a release block", "Run again with --force to replace it, or add the fields shown here to it by hand.");
183
+ configText = `${JSON.stringify({ ...parsed, release }, null, 2)}\n`;
184
+ }
185
+ else {
186
+ configPath = tsPath;
187
+ configText = newConfigSource(release);
188
+ }
189
+ }
190
+ catch (err) {
191
+ if (err instanceof ReleaseInitError)
192
+ return { error: { code: err.code, message: err.message, ...(err.fix ? { fix: err.fix } : {}) } };
193
+ return { error: { code: "release-init-config-unreadable", message: `the config could not be read: ${err instanceof Error ? err.message : String(err)}` } };
194
+ }
195
+ return { configPath, configText, configName: configPath === tsPath ? "chant.config.ts" : "chant.config.json", created: !existsSync(configPath) };
196
+ }
197
+ /**
198
+ * The release train (#5154): `chant.workspace.json` with a member per
199
+ * package, each member's `chant.config.ts`, the root's `release.train`, and
200
+ * the train workflow.
201
+ */
202
+ async function runTrainInit(ctx, root, plan, fg, fail) {
203
+ const { args } = ctx;
204
+ const json = args.json === true;
205
+ const write = args.yes === true;
206
+ const force = args.force === true;
207
+ const lib = await import("../../lifecycle/release-init.js");
208
+ const rel = (p) => relative(root, p).split(sep).join("/");
209
+ // Each member's config, then the root's.
210
+ const members = [];
211
+ for (const m of plan.members) {
212
+ const prepared = await prepareConfig(join(root, m.dir), m.release, force);
213
+ const block = lib.releaseBlockSource(m.release, " ");
214
+ if ("error" in prepared)
215
+ return fail(prepared.error.code, `${m.dir}: ${prepared.error.message}`, prepared.error.fix, block);
216
+ members.push({ name: m.name, dir: m.dir, package: m.package, release: m.release, path: prepared.configPath, text: prepared.configText, created: prepared.created });
217
+ }
218
+ const rootBlock = lib.releaseBlockSource(plan.release, " ");
219
+ const prepared = await prepareConfig(root, plan.release, force);
220
+ if ("error" in prepared)
221
+ return fail(prepared.error.code, prepared.error.message, prepared.error.fix, rootBlock);
222
+ // chant.workspace.json: a new one, or the members added to the one there.
223
+ const wsPath = join(root, "chant.workspace.json");
224
+ const wsCreated = !existsSync(wsPath);
225
+ let ws;
226
+ try {
227
+ ws = wsCreated ? { name: plan.workspaceName, schema: 1, members: [] } : JSON.parse(readFileSync(wsPath, "utf-8"));
228
+ }
229
+ catch (err) {
230
+ return fail("release-init-config-unreadable", `chant.workspace.json could not be read: ${err instanceof Error ? err.message : String(err)}`);
231
+ }
232
+ const declared = Array.isArray(ws.members) ? [...ws.members] : [];
233
+ const added = [];
234
+ for (const m of members) {
235
+ const at = declared.findIndex((d) => d.dir === m.dir || d.name === m.name);
236
+ const entry = { name: m.name, dir: m.dir, kind: "chant" };
237
+ if (at < 0) {
238
+ declared.push(entry);
239
+ added.push(m.name);
240
+ continue;
241
+ }
242
+ const d = declared[at];
243
+ if (d.dir === m.dir && d.name === m.name && d.kind === "chant")
244
+ continue;
245
+ if (!force)
246
+ return fail("release-init-member-exists", `chant.workspace.json already declares ${JSON.stringify(d.name)} at ${JSON.stringify(d.dir)}${d.kind === undefined ? "" : ` (kind ${String(d.kind)})`}, and the train needs ${m.name} at ${m.dir} as a chant member`, "Run again with --force to replace that entry, or declare the member by hand.");
247
+ declared[at] = entry;
248
+ added.push(m.name);
249
+ }
250
+ ws.members = declared;
251
+ const wsText = `${JSON.stringify(ws, null, 2)}\n`;
252
+ const { gitTop } = await import("../../workspace/tree.js");
253
+ const top = gitTop(root) ?? root;
254
+ if (!force && !(await workflowIsOurs(join(top, plan.workflowFile)))) {
255
+ return fail("release-init-workflow-exists", `${plan.workflowFile} exists and chant did not write it`, "Run again with --force to replace it.");
256
+ }
257
+ const wf = plan.workflowFile.split("/").pop();
258
+ const files = ["chant.workspace.json", prepared.configName, ...members.map((m) => rel(m.path)), plan.workflowFile];
259
+ const next = [
260
+ ...(write ? [] : ["chant release init --yes"]),
261
+ `git add ${files.join(" ")} && git commit -m "ci: release with chant" && git push`,
262
+ `chant workspace train cut ${plan.env} # the first train's plan; nothing is cut without --yes`,
263
+ fg === "github"
264
+ ? `gh workflow run ${wf} -f levels=auto # each package's level from its commits since its last release`
265
+ : `start ${plan.workflowFile} by hand with the levels auto (each package's level from its commits since its last release)`,
266
+ ];
267
+ const memberOut = members.map((m) => ({ name: m.name, dir: m.dir, package: m.package, config: rel(m.path), created: m.created, release: m.release }));
268
+ const out = (dryRun) => ({
269
+ dryRun,
270
+ layout: "train",
271
+ workspace: { file: "chant.workspace.json", created: wsCreated, added },
272
+ config: prepared.configName,
273
+ created: prepared.created,
274
+ release: plan.release,
275
+ members: memberOut,
276
+ reasons: plan.reasons,
277
+ notes: plan.notes,
278
+ registry: plan.registry,
279
+ workflow: plan.workflowFile,
280
+ next,
281
+ });
282
+ if (json && !write) {
283
+ console.log(JSON.stringify(out(true), null, 2));
284
+ return 0;
285
+ }
286
+ if (!json) {
287
+ console.log(formatBold(`${write ? "" : "Dry run: "}a release train of ${members.length} packages, each released at its own version`));
288
+ console.log(formatBold(`\nchant.workspace.json${wsCreated ? " (a new file)" : added.length > 0 ? ` (adds ${added.join(", ")})` : ""}`));
289
+ console.log(`\n${wsText.replace(/^/gm, " ").trimEnd()}\n`);
290
+ console.log(formatBold(`${prepared.configName}${prepared.created ? " (a new file)" : ""}`));
291
+ console.log(`\n ${rootBlock}\n`);
292
+ for (const m of members) {
293
+ console.log(formatBold(`${rel(m.path)}${m.created ? " (a new file)" : ""}`));
294
+ console.log(`\n ${lib.releaseBlockSource(m.release, " ")}\n`);
295
+ }
296
+ console.log(formatBold("Why"));
297
+ for (const r of plan.reasons)
298
+ console.log(` - ${r}`);
299
+ if (plan.notes.length > 0) {
300
+ console.log(formatBold("\nNot covered"));
301
+ for (const n of plan.notes)
302
+ console.log(` - ${n}`);
303
+ }
304
+ }
305
+ if (write) {
306
+ writeFileSync(wsPath, wsText);
307
+ for (const m of members)
308
+ writeFileSync(m.path, m.text);
309
+ writeFileSync(prepared.configPath, prepared.configText);
310
+ if (!json)
311
+ console.log(formatSuccess(`Wrote chant.workspace.json, ${prepared.configName} and ${members.length} member configs.`));
312
+ const { runReleaseWorkflow } = await import("../../workspace/release-workflow.js");
313
+ const log = console.log;
314
+ if (json)
315
+ console.log = console.error;
316
+ let code;
317
+ try {
318
+ code = await runReleaseWorkflow({ ...ctx, args: { ...ctx.args, forge: fg } });
319
+ }
320
+ finally {
321
+ console.log = log;
322
+ }
323
+ if (code !== 0)
324
+ return code;
325
+ }
326
+ else {
327
+ console.log(`\nWould write chant.workspace.json, ${prepared.configName}, ${members.map((m) => rel(m.path)).join(", ")} and ${plan.workflowFile} (with chant release workflow). Run with --one-release to release every package together under one label instead.`);
328
+ }
329
+ if (json) {
330
+ console.log(JSON.stringify(out(false), null, 2));
331
+ return 0;
332
+ }
333
+ if (plan.registry.length > 0) {
334
+ console.log(formatBold("\nOn the registries, by hand"));
335
+ for (const r of plan.registry)
336
+ console.log(` - ${r}`);
337
+ }
338
+ console.log(formatBold("\nNext"));
339
+ for (const n of next)
340
+ console.log(` ${n}`);
341
+ return 0;
342
+ }
@@ -16,9 +16,11 @@
16
16
  * --allow-unsigned (#4049), and with a target a checkout that is not
17
17
  * the release's commit; warns with no OIDC provenance, and refuses
18
18
  * under --require-provenance; attaches SBOMs and provenance (#4049)
19
- * release verify <label|digest> [--json]
19
+ * release verify <label|digest> [--sigstore [--assets <dir>]] [--json]
20
20
  * check the release's signature offline against .chant/allowed_signers
21
21
  * at the release's commit (#4049)
22
+ * release changed [--at <sha>] [--bump-member <member>=<level>]... [--json]
23
+ * the members to release at a commit, with their dependency closure (#5134)
22
24
  * release candidates [--env <env>] [--lane <name>] [--forge-issues] [--json]
23
25
  * the green commits of trunk a release can be cut from, each with what it
24
26
  * would ship, and what each environment runs (#4168 4.2)
@@ -32,6 +34,9 @@
32
34
  * `--json` prints the read contract's `releases` document
33
35
  * release export <label|digest> --env <env> [-o <dir>] [--json]
34
36
  * write the files the release recorded for <env>, checked against their digests (#4046)
37
+ * release deprecate|yank|restore <label|digest> [--yes] [--reason <text>] [--replacement <label>] [--forge-release prerelease|draft|delete] [--actor <name>] [--sign [<key file>]] [--json]
38
+ * set a published release's status and act on each target that can
39
+ * (#5163, ../../lifecycle/release-status-change.ts): a dry run unless --yes
35
40
  * release compile --env <env> [--build <command>] [--artifacts --component <a,b>] --json
36
41
  * internal: what the cut runs in a child process per environment
37
42
  *
@@ -41,6 +46,8 @@
41
46
  * names a `release` gate requires a signed cut by an actor in its class (#4031).
42
47
  */
43
48
  import type { CommandContext } from "../registry.js";
49
+ /** The usage line printed with a refusal, built from ../release-commands (#5196). */
50
+ export declare const USAGE: string;
44
51
  /** What to run after a cut (#4027): publish from CI, or push the tag so CI publishes, or deploy the first environment. */
45
52
  export declare function nextCommands(req: {
46
53
  ref: string;
@@ -52,6 +59,8 @@ export declare function nextCommands(req: {
52
59
  }): string[];
53
60
  /** The command line that ran, without `--json`, with `--yes` added: what a dry run says to run next. */
54
61
  export declare function sameWithYes(argv: readonly string[]): string;
62
+ /** How a cut's green gate reads in a line (#5149). */
63
+ export declare function describeGreen(green: import("../../lifecycle/release-store.js").ReleaseCutGreen | undefined | null): string;
55
64
  /** Copy each `release.images` archive from the directory the cut built it in to the same path under `to`. */
56
65
  export declare function copyImageArchives(images: ReadonlyArray<{
57
66
  archive: string;
@@ -65,6 +74,17 @@ export declare function copyImageArchives(images: ReadonlyArray<{
65
74
  * publish job runs it before the build that packs the package.
66
75
  */
67
76
  export declare function runReleaseImages(ctx: CommandContext): Promise<number>;
77
+ /**
78
+ * `release artifacts <label|digest> [--no-build] [--from <dir>] [-o <dir>] [--json]`
79
+ * (#5151): the files `release.artifacts` declares, checked against the
80
+ * digests the release records, from the release's commit checked out here.
81
+ * Without a flag it builds them again; `--no-build` checks the files on
82
+ * disk; `--from <dir>` first copies them from a directory where the cut job
83
+ * staged them. `-o <dir>` stages the checked files in a directory, at their
84
+ * paths in the member, for the next job. A file missing or with another
85
+ * digest is refused.
86
+ */
87
+ export declare function runReleaseArtifacts(ctx: CommandContext): Promise<number>;
68
88
  /**
69
89
  * `release stamp <label> [--json]` (#4840): write the label into the files
70
90
  * `release.version` names, as the cut does before its build, and leave them
@@ -73,6 +93,15 @@ export declare function runReleaseImages(ctx: CommandContext): Promise<number>;
73
93
  * `git checkout -- <files>` puts them back.
74
94
  */
75
95
  export declare function runReleaseStamp(ctx: CommandContext): Promise<number>;
96
+ /**
97
+ * `release tag <label|digest|tag> [--json]` (#5150): the tag `release.tag`
98
+ * gives a release of this member, found by its label, its digest, or the tag
99
+ * itself. The ledger names the release: a tag is matched by rendering the
100
+ * template for each label the member's ledger holds, never parsed. The
101
+ * publish job of `chant release workflow` reads the label of the tag that
102
+ * started it this way.
103
+ */
104
+ export declare function runReleaseTag(ctx: CommandContext): Promise<number>;
76
105
  /**
77
106
  * `release cut [<label>]` (#4026, #4027). A dry run unless `--yes`: it
78
107
  * refuses a dirty tree, a commit that is not on trunk and pushed, and one
@@ -121,7 +150,27 @@ export declare function runReleaseVerify(ctx: CommandContext): Promise<number>;
121
150
  * prints the read contract's `release-candidates` document.
122
151
  */
123
152
  export declare function runReleaseCandidates(ctx: CommandContext): Promise<number>;
153
+ /**
154
+ * `release next [--at <sha>] [--pre <id>] [--json]` (#5159): the label the
155
+ * next release of this member carries, from the conventional commits and
156
+ * the intent files since its previous release. The label alone goes to
157
+ * stdout, so a script can read it; why goes to stderr.
158
+ */
159
+ export declare function runReleaseNext(ctx: CommandContext): Promise<number>;
160
+ /**
161
+ * `release changed [--at <sha>] [--bump-member <member>=<level>]... [--json]`
162
+ * (#5134): the members a release at a commit has to cut, in publish order,
163
+ * each with why. `--json` prints the read contract's `release-changed` document.
164
+ */
165
+ export declare function runReleaseChanged(ctx: CommandContext): Promise<number>;
124
166
  export declare function runReleaseList(ctx: CommandContext): Promise<number>;
167
+ /**
168
+ * `release deprecate|yank|restore <label|digest> [--yes] ...` (#5163): plan
169
+ * the status change and what each publish target does about it, print it,
170
+ * and with `--yes` write the status record and act, resumably. A target that
171
+ * can't do something says so with a code, as a warning, and the rest go on.
172
+ */
173
+ export declare function runReleaseStatusChange(ctx: CommandContext, verb: import("../../lifecycle/release-status-change.js").StatusVerb): Promise<number>;
125
174
  /**
126
175
  * `release export <label|digest> --env <env> [-o <dir>]` (#4046): write each
127
176
  * file the release's target for <env> records, at the path it was compiled to,