@intentius/chant 0.124.102 → 0.124.104

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 (79) hide show
  1. package/dist/audit/secrets.d.ts +6 -0
  2. package/dist/audit/secrets.js +9 -2
  3. package/dist/cli/commands/import-index.d.ts +15 -0
  4. package/dist/cli/commands/import-index.js +37 -3
  5. package/dist/cli/commands/onboard.js +8 -8
  6. package/dist/cli/handlers/lifecycle.js +6 -0
  7. package/dist/cli/handlers/release-config.d.ts +15 -0
  8. package/dist/cli/handlers/release-config.js +58 -0
  9. package/dist/cli/handlers/release-init.js +3 -1
  10. package/dist/cli/handlers/release.js +36 -3
  11. package/dist/cli/main.js +24 -3
  12. package/dist/cli/parse-args.js +12 -0
  13. package/dist/cli/registry.d.ts +4 -0
  14. package/dist/cli/release-commands/cut.js +3 -0
  15. package/dist/cloud-lister/kubernetes-components.js +1 -2
  16. package/dist/config-import.js +26 -4
  17. package/dist/config.d.ts +14 -0
  18. package/dist/config.js +4 -0
  19. package/dist/floor-table.data.js +13 -11
  20. package/dist/floor-table.js +3 -1
  21. package/dist/graph-refs.d.ts +9 -0
  22. package/dist/graph-refs.js +9 -7
  23. package/dist/lifecycle/cloud-index.d.ts +6 -0
  24. package/dist/lifecycle/cloud-index.js +32 -5
  25. package/dist/lifecycle/identity-match.d.ts +18 -2
  26. package/dist/lifecycle/identity-match.js +10 -5
  27. package/dist/lifecycle/index-drift.d.ts +13 -0
  28. package/dist/lifecycle/index-drift.js +21 -3
  29. package/dist/lifecycle/index-import.d.ts +15 -0
  30. package/dist/lifecycle/index-import.js +25 -2
  31. package/dist/lifecycle/index-join.d.ts +1 -1
  32. package/dist/lifecycle/index-join.js +1 -1
  33. package/dist/lifecycle/publish-declaration.d.ts +6 -0
  34. package/dist/lifecycle/publish-declaration.js +19 -3
  35. package/dist/lifecycle/publish-forge.d.ts +2 -0
  36. package/dist/lifecycle/publish-forge.js +3 -1
  37. package/dist/lifecycle/publish-helm.js +1 -2
  38. package/dist/lifecycle/publish-maven.js +1 -2
  39. package/dist/lifecycle/publish-npm.js +1 -1
  40. package/dist/lifecycle/publish-nuget.js +1 -2
  41. package/dist/lifecycle/publish-oci.d.ts +27 -0
  42. package/dist/lifecycle/publish-oci.js +63 -8
  43. package/dist/lifecycle/publish-rubygems.js +1 -2
  44. package/dist/lifecycle/release-artifacts.js +1 -2
  45. package/dist/lifecycle/release-changelog.d.ts +18 -5
  46. package/dist/lifecycle/release-changelog.js +22 -10
  47. package/dist/lifecycle/release-cut.d.ts +13 -1
  48. package/dist/lifecycle/release-cut.js +3 -0
  49. package/dist/lifecycle/release-images.d.ts +32 -2
  50. package/dist/lifecycle/release-images.js +70 -2
  51. package/dist/lifecycle/release-init-goreleaser-images.d.ts +21 -0
  52. package/dist/lifecycle/release-init-goreleaser-images.js +160 -0
  53. package/dist/lifecycle/release-init.d.ts +22 -0
  54. package/dist/lifecycle/release-init.js +96 -16
  55. package/dist/local-chant.d.ts +3 -0
  56. package/dist/local-chant.js +28 -2
  57. package/dist/release-floors.d.ts +10 -6
  58. package/dist/release-floors.js +10 -6
  59. package/dist/ts-loader.d.ts +12 -3
  60. package/dist/ts-loader.js +27 -11
  61. package/dist/wave-runtime.mjs +291 -290
  62. package/dist/workspace/catalog-edges.d.ts +22 -0
  63. package/dist/workspace/catalog-edges.js +23 -0
  64. package/dist/workspace/release-steps/goreleaser.d.ts +6 -3
  65. package/dist/workspace/release-steps/goreleaser.js +12 -6
  66. package/dist/workspace/release-toolchains.d.ts +6 -0
  67. package/dist/workspace/release-toolchains.js +8 -0
  68. package/dist/workspace/release-train-workflow.d.ts +39 -3
  69. package/dist/workspace/release-train-workflow.js +258 -9
  70. package/dist/workspace/release-train.js +5 -1
  71. package/dist/workspace/release-workflow.d.ts +37 -0
  72. package/dist/workspace/release-workflow.js +97 -16
  73. package/dist/workspace/train-artifacts.d.ts +107 -0
  74. package/dist/workspace/train-artifacts.js +238 -0
  75. package/dist/workspace/train-cut.d.ts +34 -1
  76. package/dist/workspace/train-cut.js +98 -14
  77. package/dist/workspace/train-publish.d.ts +9 -0
  78. package/dist/workspace/train-publish.js +27 -1
  79. package/package.json +2 -2
@@ -99,6 +99,12 @@ export declare const ENTROPY_RULE_ID = "SEC010";
99
99
  * line up with dictionary-shaped alphabetic chunks. Requires at least two
100
100
  * separators so a single hyphen (common inside genuine tokens) doesn't
101
101
  * trigger it.
102
+ *
103
+ * All-digit chunks (a version's numbers, the `64` of `x86_64`) count for
104
+ * neither side, so a release asset's name in a download URL
105
+ * (`0/goreleaser_Linux_x86_64`, the tail of `.../v2.19.0/goreleaser_Linux_x86_64.tar.gz`)
106
+ * reads as the identifier it is (#5268); at least two wordy chunks are still
107
+ * required.
102
108
  */
103
109
  export declare function looksLikeIdentifierSlug(value: string): boolean;
104
110
  /** Is this a dependency lockfile the secrets scan should skip? */
@@ -247,13 +247,20 @@ const HEX_ONLY_RE = /^[0-9a-f]+$/i;
247
247
  * line up with dictionary-shaped alphabetic chunks. Requires at least two
248
248
  * separators so a single hyphen (common inside genuine tokens) doesn't
249
249
  * trigger it.
250
+ *
251
+ * All-digit chunks (a version's numbers, the `64` of `x86_64`) count for
252
+ * neither side, so a release asset's name in a download URL
253
+ * (`0/goreleaser_Linux_x86_64`, the tail of `.../v2.19.0/goreleaser_Linux_x86_64.tar.gz`)
254
+ * reads as the identifier it is (#5268); at least two wordy chunks are still
255
+ * required.
250
256
  */
251
257
  export function looksLikeIdentifierSlug(value) {
252
258
  const parts = value.split(/[-_/]/).filter(Boolean);
253
259
  if (parts.length < 3)
254
260
  return false;
255
- const wordy = parts.filter((p) => /^[a-zA-Z]+$/.test(p) && p.length >= 3).length;
256
- return wordy / parts.length >= 0.5;
261
+ const counted = parts.filter((p) => !/^[0-9]+$/.test(p));
262
+ const wordy = counted.filter((p) => /^[a-zA-Z]+$/.test(p) && p.length >= 3).length;
263
+ return wordy >= 2 && wordy / counted.length >= 0.5;
257
264
  }
258
265
  /** At least 3 of {lower, upper, digit, symbol} present — cuts plain-word / all-hex false positives. */
259
266
  function hasClassDiversity(value) {
@@ -46,6 +46,21 @@ export declare function renderIndexImport(plan: IndexImportPlan, plugins: readon
46
46
  };
47
47
  /** The report as written: two-space JSON and a final newline. */
48
48
  export declare function indexImportReportJson(report: IndexImportReport): string;
49
+ /**
50
+ * The project the declared check reads. It is the project the command runs
51
+ * in: the nearest `chant.config` at or above the working directory (or
52
+ * `projectDir`), wherever `--output` points. Run from outside any project,
53
+ * the project above the output's parent is the fallback. `dir` is where the
54
+ * search started when none is found, and `found` is false.
55
+ */
56
+ export declare function resolveIndexImportProject(opts: {
57
+ cwd: string;
58
+ output?: string;
59
+ projectDir?: string;
60
+ }): {
61
+ dir: string;
62
+ found: boolean;
63
+ };
49
64
  export declare function importFromIndex(options: IndexImportOptions): Promise<IndexImportResult>;
50
65
  /** One line per status: what was imported, declared and left out. */
51
66
  export declare function summarizeIndexImport(report: IndexImportReport): string;
@@ -16,9 +16,10 @@
16
16
  */
17
17
  import { existsSync, mkdirSync, readFileSync, writeFileSync } from "fs";
18
18
  import { dirname, join, relative, resolve } from "path";
19
+ import { findProjectConfigPastFragments } from "../../config.js";
19
20
  import { adoptionFileFromImportReport, adoptionFileJson } from "../../lifecycle/adoption-file.js";
20
21
  import { declaredNodes, indexImportHeader, planIndexImport, selectionIsEmpty, } from "../../lifecycle/index-import.js";
21
- import { generateOrganizedFiles } from "./import.js";
22
+ import { buildErrorWarnings, generateOrganizedFiles } from "./import.js";
22
23
  export const INDEX_IMPORT_REPORT_FILE = "chant-index-import.json";
23
24
  function asDocuments(parsed, from) {
24
25
  const list = Array.isArray(parsed)
@@ -139,9 +140,28 @@ async function pluginsFor(docs, projectDir) {
139
140
  }
140
141
  return plugins;
141
142
  }
143
+ /**
144
+ * The project the declared check reads. It is the project the command runs
145
+ * in: the nearest `chant.config` at or above the working directory (or
146
+ * `projectDir`), wherever `--output` points. Run from outside any project,
147
+ * the project above the output's parent is the fallback. `dir` is where the
148
+ * search started when none is found, and `found` is false.
149
+ */
150
+ export function resolveIndexImportProject(opts) {
151
+ const starts = [resolve(opts.projectDir ?? opts.cwd)];
152
+ if (!opts.projectDir && opts.output)
153
+ starts.push(dirname(resolve(opts.output)));
154
+ for (const start of starts) {
155
+ const { dir, configPath } = findProjectConfigPastFragments(start);
156
+ if (configPath)
157
+ return { dir, found: true };
158
+ }
159
+ return { dir: starts[0], found: false };
160
+ }
142
161
  export async function importFromIndex(options) {
143
162
  const outputDir = resolve(options.output ?? "./infra/");
144
- const projectDir = resolve(options.projectDir ?? (options.output ? dirname(outputDir) : "."));
163
+ const project0 = resolveIndexImportProject({ cwd: process.cwd(), output: options.output, projectDir: options.projectDir });
164
+ const projectDir = project0.dir;
145
165
  const warnings = [];
146
166
  const fail = (error) => ({ success: false, generatedFiles: [], warnings, error });
147
167
  if (selectionIsEmpty(options.selection)) {
@@ -161,7 +181,9 @@ export async function importFromIndex(options) {
161
181
  entities = options.declaredEntities;
162
182
  }
163
183
  else {
164
- const project = await projectEntities(projectDir, options.src, plugins);
184
+ const project = project0.found
185
+ ? await projectEntities(projectDir, options.src, plugins)
186
+ : { entities: new Map(), warning: `no chant.config found at or above ${projectDir}, so no indexed resource was checked against declarations; run the command inside the project` };
165
187
  if (project.warning)
166
188
  warnings.push(project.warning);
167
189
  entities = project.entities;
@@ -210,6 +232,18 @@ export async function importFromIndex(options) {
210
232
  return { success: false, generatedFiles, warnings, error: `no adoption file written: ${err instanceof Error ? err.message : String(err)}`, report: plan.report };
211
233
  }
212
234
  }
235
+ // As `chant import <template>` does: build what was written and name each
236
+ // error-severity post-synth finding that would stop `chant build`. Source
237
+ // that mirrors a resource as the cloud holds it can lack settings a check
238
+ // requires; the person sees the gap here rather than at the first build.
239
+ for (const group of plan.groups) {
240
+ const plugin = plugins.find((p) => p.name === group.lexicon);
241
+ const prefix = group.dir ? `${group.dir}/` : "";
242
+ const written = generatedFiles.filter((f) => f.endsWith(".ts") && f.startsWith(prefix)).map((f) => f.slice(prefix.length));
243
+ if (!plugin || written.length === 0)
244
+ continue;
245
+ warnings.push(...(await buildErrorWarnings(plugin, join(outputDir, group.dir), written)));
246
+ }
213
247
  const lexicons = [...new Set(plan.groups.map((g) => g.lexicon))];
214
248
  return {
215
249
  success: true,
@@ -243,9 +243,9 @@ function patchCiWorkflow(root, name) {
243
243
  /**
244
244
  * Patch publish.yml: add the prepack line to the test job.
245
245
  *
246
- * No publish step is added. scripts/publish-packages.sh enumerates every
247
- * non-private workspace package at run time, so a new lexicon is published
248
- * the moment it exists — that is deliberate. Hand-maintained publish steps
246
+ * No publish step is added. Each publishable package is a release member
247
+ * under release/, written by scripts/generate-release-members.ts from the
248
+ * workspace, and publish.yml publishes the release train — that is deliberate. Hand-maintained publish steps
249
249
  * were how k8s-client (#1177) and fountain (#1253) each shipped a package
250
250
  * the release pipeline could not publish.
251
251
  */
@@ -259,12 +259,12 @@ function patchPublishWorkflow(root, name) {
259
259
  }
260
260
  if (!insertPrepackAfterEach(lines, name)) {
261
261
  // #3227 — not a failure and not "covered by a prepack line": publish.yml
262
- // carries no per-lexicon lines. The run builds every lexicon through
263
- // scripts/ci-lexicon-artifacts.sh and publishes through
264
- // scripts/publish-packages.sh, both of which enumerate the workspace.
262
+ // carries no per-lexicon lines. CI builds every lexicon through
263
+ // scripts/ci-lexicon-artifacts.sh, and publish.yml publishes the release
264
+ // members scripts/generate-release-members.ts writes; both enumerate the workspace.
265
265
  return {
266
266
  patched: false,
267
- reason: "nothing to patch: it has no per-lexicon prepack lines; scripts/ci-lexicon-artifacts.sh and scripts/publish-packages.sh enumerate the workspace",
267
+ reason: "nothing to patch: it has no per-lexicon prepack lines; scripts/ci-lexicon-artifacts.sh and scripts/generate-release-members.ts enumerate the workspace",
268
268
  };
269
269
  }
270
270
  writeFileSync(filePath, lines.join("\n"));
@@ -386,7 +386,7 @@ export async function printOnboardResult(result, name) {
386
386
  console.log(` (must depend on @intentius/chant-lexicon-${name} for workspace resolution)`);
387
387
  console.log(` 2. Add smoke tests to test/integration.sh`);
388
388
  console.log(` 3. Run: npm install (to update workspace links)`);
389
- console.log(` 4. First release: just release-lexicon ${name} patch`);
389
+ console.log(` 4. First release: npx tsx scripts/generate-release-members.ts, commit release/lexicon-${name}/, then just release`);
390
390
  console.log(` 5. Run: chant dev check-lexicon lexicons/${name} (to see completeness status)`);
391
391
  console.log(formatWarning({
392
392
  message: "First-time scoped packages may publish as private despite --access public",
@@ -946,6 +946,12 @@ function runLifecycleDiffIndex(args) {
946
946
  console.log(` ? ${name} ${joinCell(j) ?? ""}${detail}`);
947
947
  }
948
948
  }
949
+ const partial = Object.entries(part.unobservedProperties).sort(([a], [b]) => a.localeCompare(b));
950
+ if (partial.length > 0) {
951
+ console.log(formatBold("\nNOT OBSERVED BY THE INDEX (declared properties its listing does not carry; not compared):"));
952
+ for (const [name, keys] of partial)
953
+ console.log(` ? ${name}: ${keys.join(", ")}`);
954
+ }
949
955
  renderDeepDiff(lexicon, part.deep, provenanceOf, args.projectRoot);
950
956
  }
951
957
  return result;
@@ -0,0 +1,15 @@
1
+ /**
2
+ * #5263: a `chant release` command refuses a `chant.config` it can't load,
3
+ * rather than reading it as one with no `release`. The member's own config
4
+ * and its workspace root's are both read: `release.legacyTags` and
5
+ * `release.breakingOnZero` come from the root too.
6
+ */
7
+ /** The first chant whose `chant release` commands refuse a config they can't load with `release-config-unreadable`, and that reads `chant.config.ts` with the project's tsx when its own install has none (#5263). */
8
+ export declare const RELEASE_CONFIG_UNREADABLE_FLOOR = "0.124.104";
9
+ /** The fix for a config that can't be loaded: for a missing tsx, the ways to give chant one. */
10
+ export declare function unreadableConfigFix(message: string, version: string): string;
11
+ /**
12
+ * Print the refusal and return 1 when the config in `cwd`, or in the
13
+ * workspace root it sits in, can't be loaded; null when both load.
14
+ */
15
+ export declare function refuseUnreadableReleaseConfig(cwd: string): Promise<number | null>;
@@ -0,0 +1,58 @@
1
+ /**
2
+ * #5263: a `chant release` command refuses a `chant.config` it can't load,
3
+ * rather than reading it as one with no `release`. The member's own config
4
+ * and its workspace root's are both read: `release.legacyTags` and
5
+ * `release.breakingOnZero` come from the root too.
6
+ */
7
+ import { existsSync } from "node:fs";
8
+ import { join, resolve } from "node:path";
9
+ import { formatError } from "../format.js";
10
+ /** The first chant whose `chant release` commands refuse a config they can't load with `release-config-unreadable`, and that reads `chant.config.ts` with the project's tsx when its own install has none (#5263). */
11
+ export const RELEASE_CONFIG_UNREADABLE_FLOOR = "0.124.104";
12
+ /** Why the config in `dir` can't be loaded, or null when it loads or there is none. */
13
+ async function loadFailure(dir) {
14
+ const ts = join(dir, "chant.config.ts");
15
+ const path = existsSync(ts) ? ts : join(dir, "chant.config.json");
16
+ if (!existsSync(path))
17
+ return null;
18
+ try {
19
+ const { loadChantConfig } = await import("../../config.js");
20
+ await loadChantConfig(dir);
21
+ return null;
22
+ }
23
+ catch (err) {
24
+ return { path, message: err instanceof Error ? err.message : String(err) };
25
+ }
26
+ }
27
+ /** The fix for a config that can't be loaded: for a missing tsx, the ways to give chant one. */
28
+ export function unreadableConfigFix(message, version) {
29
+ if (message.startsWith("chant needs tsx")) {
30
+ return ("chant reads chant.config.ts with tsx, from its own install or this project's node_modules. " +
31
+ `Install it in the project (npm i -D tsx), run chant beside it (npx -p tsx -p @intentius/chant@${version} chant release ...), ` +
32
+ "or write the config as chant.config.json.");
33
+ }
34
+ return "Fix the config so it loads: chant release reads its release block, and does not guess one.";
35
+ }
36
+ /**
37
+ * Print the refusal and return 1 when the config in `cwd`, or in the
38
+ * workspace root it sits in, can't be loaded; null when both load.
39
+ */
40
+ export async function refuseUnreadableReleaseConfig(cwd) {
41
+ const dirs = [resolve(cwd)];
42
+ const { findWorkspaceRoot } = await import("../../project-root.js");
43
+ const root = findWorkspaceRoot(cwd);
44
+ if (root && resolve(root.dir) !== dirs[0])
45
+ dirs.push(resolve(root.dir));
46
+ for (const dir of dirs) {
47
+ const failed = await loadFailure(dir);
48
+ if (!failed)
49
+ continue;
50
+ const { readerVersion } = await import("../../workspace/declaration.js");
51
+ console.error(formatError({
52
+ message: `${failed.path} could not be loaded: ${failed.message.split("\n")[0]} [release-config-unreadable]`,
53
+ hint: unreadableConfigFix(failed.message, readerVersion()),
54
+ }));
55
+ return 1;
56
+ }
57
+ return null;
58
+ }
@@ -294,7 +294,9 @@ async function runTrainInit(ctx, root, plan, fg, fail) {
294
294
  `chant workspace train cut ${plan.env} # the first train's plan; nothing is cut without --yes`,
295
295
  fg === "github"
296
296
  ? `gh workflow run ${wf} -f levels=auto # each package's level from its commits since its last release`
297
- : `start ${plan.workflowFile} by hand with the levels auto (each package's level from its commits since its last release)`,
297
+ : fg === "gitlab"
298
+ ? "run a pipeline with the variable CHANT_RELEASE_LEVELS=auto (each package's level from its commits since its last release)"
299
+ : `start ${plan.workflowFile} by hand with the levels auto (each package's level from its commits since its last release)`,
298
300
  ];
299
301
  const memberOut = members.map((m) => ({ name: m.name, dir: m.dir, package: m.package, config: rel(m.path), created: m.created, release: m.release }));
300
302
  const out = (dryRun) => ({
@@ -120,7 +120,10 @@ async function releaseBuildJobsOf(cwd) {
120
120
  /** The member's `release.images` (#4657), or none when the config declares none. A Dockerfile entry (#4819) keeps its form, so its prepare command runs. */
121
121
  async function releaseImagesOf(cwd) {
122
122
  const { loadChantConfig } = await import("../../config.js");
123
- return (await loadChantConfig(cwd)).config.release?.images ?? [];
123
+ const { placeReleaseImages } = await import("../../lifecycle/release-images.js");
124
+ const release = (await loadChantConfig(cwd)).config.release;
125
+ // #5269: an archive moved out of goreleaser's dist, which it empties.
126
+ return placeReleaseImages(release?.images ?? [], release?.artifacts ?? []);
124
127
  }
125
128
  /**
126
129
  * The green gate `release.green` names (#5149), or undefined for the default.
@@ -163,6 +166,11 @@ async function releaseTagOf(cwd) {
163
166
  const { loadChantConfig } = await import("../../config.js");
164
167
  return (await loadChantConfig(cwd)).config.release?.tag;
165
168
  }
169
+ /** The member's `release.check` lines (#5261), which a cut runs before it records anything. */
170
+ async function releaseChecksOf(cwd) {
171
+ const { loadChantConfig } = await import("../../config.js");
172
+ return (await loadChantConfig(cwd)).config.release?.check ?? [];
173
+ }
166
174
  async function releaseVersionOf(cwd) {
167
175
  const { loadChantConfig } = await import("../../config.js");
168
176
  return (await loadChantConfig(cwd)).config.release?.version;
@@ -650,9 +658,11 @@ export async function runReleaseCut(ctx) {
650
658
  const compiler = spawnTargetCompiler({ ...compileInputs(ctx, params, cutCwd, label), ...(digestsFile ? { releaseDigests: digestsFile } : {}) });
651
659
  const buildImages = digestsFile
652
660
  ? async (at) => {
653
- const { buildReleaseImages, writeReleaseDigests, ReleaseImageError } = await import("../../lifecycle/release-images.js");
661
+ const { buildReleaseImages, checkImagesOutsideGoreleaser, writeReleaseDigests, ReleaseImageError } = await import("../../lifecycle/release-images.js");
654
662
  const { ociArchiveDigest } = await import("../../lifecycle/publish-oci.js");
655
663
  try {
664
+ // #5269: goreleaser would empty an archive in its dist before the cut records it.
665
+ checkImagesOutsideGoreleaser(declaredImages, declaredArtifacts);
656
666
  const built = buildReleaseImages({ images: declaredImages, cwd: cutCwd, sourceDateEpoch: commitTime(cutCwd, at), label, archiveDigest: ociArchiveDigest, ...(versionConfig ? { versionArg: true } : {}) });
657
667
  writeReleaseDigests(digestsFile, Object.fromEntries(built.map((a) => [a.component, a.digest])));
658
668
  return built;
@@ -660,7 +670,7 @@ export async function runReleaseCut(ctx) {
660
670
  catch (err) {
661
671
  const code = err instanceof ReleaseImageError ? err.code : err.code;
662
672
  const fix = err instanceof ReleaseImageError ? err.fix : undefined;
663
- throw new ReleaseCutError(code === "release-image-name-taken" ? "release-image-name-taken" : "release-image-build-failed", `no release was cut: ${err.message}`, fix);
673
+ throw new ReleaseCutError(code === "release-image-name-taken" || code === "release-image-archive-in-dist" ? code : "release-image-build-failed", `no release was cut: ${err.message}`, fix);
664
674
  }
665
675
  }
666
676
  : undefined;
@@ -723,6 +733,26 @@ export async function runReleaseCut(ctx) {
723
733
  throw new ReleaseCompileError(`the build command exited ${run.status ?? "with a signal"}: ${buildCommand}`);
724
734
  }
725
735
  : undefined;
736
+ // #5261: release.check, run by the cut and its dry run alike once the label is stamped and the builds have run.
737
+ const checkLines = await releaseChecksOf(cutCwd);
738
+ const check = checkLines.length > 0
739
+ ? async (at) => {
740
+ const { runToStderr } = await import("../../workspace/train-shell.js");
741
+ const env = { ...process.env, CHANT_RELEASE_COMMIT: at };
742
+ delete env[RELEASE_LABEL_ENV];
743
+ if (label !== null)
744
+ env[RELEASE_LABEL_ENV] = label;
745
+ if (digestsFile)
746
+ env.CHANT_RELEASE_DIGESTS = digestsFile;
747
+ for (const line of checkLines) {
748
+ console.error(`check: ${line}`);
749
+ const code = await runToStderr(line, { cwd: cutCwd, env });
750
+ if (code !== 0) {
751
+ throw new ReleaseCutError("release-check-failed", `no release was cut: release.check failed (exit ${code}): ${line}`, "Nothing was recorded or tagged. Fix what the check reports, or cut another label, and run the cut again.");
752
+ }
753
+ }
754
+ }
755
+ : undefined;
726
756
  const request = {
727
757
  cwd: cutCwd,
728
758
  compiler,
@@ -740,6 +770,7 @@ export async function runReleaseCut(ctx) {
740
770
  ...(greenSource ? { green: greenSource } : {}),
741
771
  ...(publishes ? { publishes } : {}),
742
772
  ...(build ? { build } : {}),
773
+ ...(check ? { check } : {}),
743
774
  ...(intents.length > 0 ? { intents: intents.map(({ path, added, bump }) => ({ path, added, bump })) } : {}),
744
775
  };
745
776
  if (dryRun) {
@@ -801,6 +832,8 @@ export async function runReleaseCut(ctx) {
801
832
  console.log(` consumes ${i.path} (${i.bump})`);
802
833
  if (plan.green)
803
834
  console.log(` gate: ${describeGreen(plan.green)}`);
835
+ if (checkLines.length > 0)
836
+ console.log(` release.check: ${checkLines.length} line(s) passed`);
804
837
  if (plan.green?.source === "none")
805
838
  console.error(formatWarning({ message: GREEN_NONE_WARNING }));
806
839
  if (plan.publishes)
package/dist/cli/main.js CHANGED
@@ -1207,20 +1207,33 @@ Workspace (level 1, #2524):
1207
1207
  instead; --continue moves on from the member's answer
1208
1208
  in _control/applied.jsonl, after applied or unchanged
1209
1209
  (#5119)
1210
- workspace train cut <env> [--at <sha>] [--levels <levels>] [--yes] [--no-push] [--json]
1210
+ workspace train cut <env> [--at <sha>] [--levels <levels>] [--plan-only] [--planned <member=label ...|none>] [--doctor] [--yes] [--no-push] [--json]
1211
1211
  Cut a train (release.train): the members release
1212
1212
  changed lists, each labelled past every version its
1213
1213
  ledger, tags, packages and npm hold, cut at one
1214
1214
  commit, the train recorded, and the member tags and
1215
1215
  release-train/<env>/<id> pushed in one push. --levels
1216
- types levels (auto, minor, core=major ...). Without
1217
- --yes it plans (#5154)
1216
+ types levels (auto, minor, core=major ...). --doctor
1217
+ runs release doctor in each member first. Without
1218
+ --yes it plans (#5154). --plan-only prints the members
1219
+ and labels with no member's dry run; --planned refuses
1220
+ a cut whose plan differs from the one given (#5237)
1218
1221
  workspace train prepare <env> [<train id|digest>] [--json]
1219
1222
  In a checkout of the train's commit: stamp each member
1220
1223
  cut here (release.version, train ranges) and build the
1221
1224
  workspace packages they depend on that the train does
1222
1225
  not publish here, once each, dependencies first
1223
1226
  (#5154)
1227
+ workspace train artifacts <env> [<train id|digest>] [--from <dir>] [-o <dir>] [--no-build] [--json]
1228
+ In a checkout of the train's commit: check the image
1229
+ archives and release.artifacts files of each member
1230
+ cut here against its release, building a member's
1231
+ again when one is missing. --from copies them from a
1232
+ directory -o staged them in, per member directory
1233
+ (#5216)
1234
+ workspace train verify <env> [<train id|digest>] [--json]
1235
+ release verify for each member the train cut from
1236
+ this commit (#5216)
1224
1237
  workspace train publish <env> [<train id|digest>] [--yes] [--allow-unsigned] [--require-provenance] [--json]
1225
1238
  Publish a train as one set: every member cut from this
1226
1239
  commit stages before any reveals, then each dependency
@@ -2181,6 +2194,14 @@ export const commandRegistry = [
2181
2194
  { name: "release", runsNoConfig: true, handler: async (ctx) => (await import("./handlers/release.js")).runReleaseUnknown(ctx) },
2182
2195
  { name: "workspace", handler: async (ctx) => (await import("../workspace/records-cli.js")).runWorkspaceUnknown(ctx) },
2183
2196
  ];
2197
+ // #5263: every release command but init, which writes the config, refuses a chant.config it can't load
2198
+ // instead of reading it as one with no release block.
2199
+ for (const def of commandRegistry) {
2200
+ if (!def.name.startsWith("release ") || def.name === "release init")
2201
+ continue;
2202
+ const run = def.handler;
2203
+ def.handler = async (ctx) => (await (await import("./handlers/release-config.js")).refuseUnreadableReleaseConfig(resolve("."))) ?? run(ctx);
2204
+ }
2184
2205
  /**
2185
2206
  * Main entry point
2186
2207
  */
@@ -84,6 +84,7 @@ const BOOLEAN_FLAGS = new Set([
84
84
  "--require-runner-start",
85
85
  "--require-clouds",
86
86
  "--no-push",
87
+ "--doctor",
87
88
  "--no-forks",
88
89
  "--list",
89
90
  "--no-require-review",
@@ -1076,6 +1077,13 @@ export function parseArgs(args) {
1076
1077
  throw new Error("--levels needs the levels: --levels auto, --levels minor, or --levels \"core=minor web=patch\"");
1077
1078
  result.levels = value;
1078
1079
  }
1080
+ else if (arg === "--planned") {
1081
+ // `chant workspace train cut <env> --planned "<member>=<label> ..."` (#5237): the plan the cut must match, or `none`.
1082
+ const value = args[++i];
1083
+ if (value === undefined || value.startsWith("-"))
1084
+ throw new Error('--planned needs the members and labels a plan gave: --planned "core=1.4.0 web=2.0.1", or --planned none');
1085
+ result.planned = value;
1086
+ }
1079
1087
  else if (arg === "--bump-member") {
1080
1088
  // `chant release changed --bump-member <member>=<level>` (#5134) is repeatable.
1081
1089
  const value = args[++i];
@@ -1728,6 +1736,10 @@ export function parseArgs(args) {
1728
1736
  // `chant release init --one-release` (#5154): a workspace's packages released together, not as a train.
1729
1737
  result.oneRelease = true;
1730
1738
  }
1739
+ else if (arg === "--doctor") {
1740
+ // `chant workspace train cut <env> --doctor` (#5216): run release doctor in each member before the cut.
1741
+ result.doctor = true;
1742
+ }
1731
1743
  else if (arg === "--no-push") {
1732
1744
  // `chant ci run --no-push` (#4156): keep the run record on the local chant/lifecycle.
1733
1745
  result.noPush = true;
@@ -680,6 +680,8 @@ export interface ParsedArgs {
680
680
  followSquash?: boolean;
681
681
  /** `chant workspace train cut <env> --levels <levels>` (#5154): `auto`, a level for every member, `<member>=<level>`, separated by spaces or commas. */
682
682
  levels?: string;
683
+ /** `chant workspace train cut <env> --planned <member=label ...|none>` (#5237): the members and labels a `--plan-only` run gave, which the cut must plan again. */
684
+ planned?: string;
683
685
  /** `chant release changed --bump-member <member>=<level>` (#5134) — repeatable. */
684
686
  bumpMember?: string[];
685
687
  /** `chant release candidates --forge-issues` and `chant workspace graph --intent --forge-issues` (#4649): ask the forge which issues each squash-merged pull request closes, once per pull request. */
@@ -786,6 +788,8 @@ export interface ParsedArgs {
786
788
  ciJob?: string;
787
789
  /** `chant ci run --no-push` (#4156): write the run record on the local chant/lifecycle and push nothing. */
788
790
  noPush?: boolean;
791
+ /** `chant workspace train cut <env> --doctor` (#5216): `chant release doctor` in each member of the train before anything is cut. */
792
+ doctor?: boolean;
789
793
  /** `chant release init --one-release` (#5154): every package of a workspace in one release, not a train. */
790
794
  oneRelease?: boolean;
791
795
  /** `chant ci serve|run --setup-key --trust --principal <name>` (#4099): the principal the runner key is listed for. */
@@ -30,6 +30,9 @@ export const cutCommand = {
30
30
  " trunk from a temporary worktree instead of HEAD, so",
31
31
  " the checkout need not be clean. The label reaches",
32
32
  " every compile and build as CHANT_RELEASE_LABEL.",
33
+ " release.check's lines run once the label is stamped",
34
+ " and before anything is recorded, in a dry run too;",
35
+ " one that fails refuses the cut.",
33
36
  " --image, repeatable, hands the cut a component's image",
34
37
  " built elsewhere, by digest: the release records it and",
35
38
  " the cut builds nothing for that component (#4694).",
@@ -60,10 +60,9 @@
60
60
  * graph typed without the k8s lexicon gives the same answer.
61
61
  */
62
62
  import { MASKED as TYPED_MASKED } from "../deep-observation.js";
63
- import { NEXT_RELEASE } from "../release-floors.js";
64
63
  import { MASKED as LISTED_MASKED } from "./mask.js";
65
64
  /** The first chant with `inferK8sComponents`, the applications of a live Kubernetes read as a component graph (#5252). */
66
- export const K8S_COMPONENTS_FLOOR = NEXT_RELEASE;
65
+ export const K8S_COMPONENTS_FLOOR = "0.124.102";
67
66
  const WORKLOAD_KINDS = new Set(["Deployment", "StatefulSet", "DaemonSet", "CronJob", "Job", "ReplicaSet", "Pod"]);
68
67
  const WORKLOAD_GROUPS = new Set(["", "apps", "batch"]);
69
68
  const ROLE_OF_KIND = {
@@ -1,5 +1,5 @@
1
1
  import { createRequire } from "node:module";
2
- import { join } from "node:path";
2
+ import { dirname, join } from "node:path";
3
3
  import { pathToFileURL } from "node:url";
4
4
  let freshLoads = 0;
5
5
  import { ensureTypeScriptLoader } from "./ts-loader.js";
@@ -9,10 +9,32 @@ import { ensureTypeScriptLoader } from "./ts-loader.js";
9
9
  * evaluate the file once — the behavior `loadChantConfig` has always had.
10
10
  */
11
11
  export async function importConfigModule(configPath, fresh = false) {
12
- ensureTypeScriptLoader();
12
+ // #5263: with no tsx in chant's install or the project's, node's own type stripping (22.18+, 23.6+) may still read the file.
13
+ let noTsx = null;
14
+ try {
15
+ ensureTypeScriptLoader(dirname(configPath));
16
+ }
17
+ catch (err) {
18
+ if (!(err instanceof Error) || !err.message.startsWith("chant needs tsx") || !nativeTypeScript())
19
+ throw err;
20
+ noTsx = err;
21
+ }
13
22
  // `fresh` re-evaluates the config file itself: a query string makes the specifier a new module. Files it imports stay cached.
14
23
  const specifier = fresh ? `${pathToFileURL(configPath).href}?fresh=${++freshLoads}` : configPath;
15
- return (await import(specifier));
24
+ try {
25
+ return (await import(specifier));
26
+ }
27
+ catch (err) {
28
+ if (noTsx === null)
29
+ throw err;
30
+ const why = String(err instanceof Error ? err.message : err).split("\n")[0];
31
+ throw Object.assign(new Error(`${noTsx.message} (node's own type stripping could not read ${configPath} either: ${why})`), { cause: err });
32
+ }
33
+ }
34
+ /** Whether this node strips TypeScript types itself, so an `import()` of a `.ts` file needs no loader. */
35
+ function nativeTypeScript() {
36
+ const ts = process.features.typescript;
37
+ return ts === "strip" || ts === "transform";
16
38
  }
17
39
  /**
18
40
  * `require()` a `chant.config.ts` into THIS process from `dir`'s resolution
@@ -21,6 +43,6 @@ export async function importConfigModule(configPath, fresh = false) {
21
43
  */
22
44
  export function requireConfigModule(configPath, dir) {
23
45
  const req = createRequire(join(dir, "package.json"));
24
- ensureTypeScriptLoader();
46
+ ensureTypeScriptLoader(dir);
25
47
  return req(configPath);
26
48
  }
package/dist/config.d.ts CHANGED
@@ -91,6 +91,7 @@ export declare const ChantConfigSchema: z.ZodObject<{
91
91
  image: z.ZodString;
92
92
  repository: z.ZodString;
93
93
  tags: z.ZodOptional<z.ZodArray<z.ZodString>>;
94
+ platformTags: z.ZodOptional<z.ZodArray<z.ZodString>>;
94
95
  usernameEnv: z.ZodOptional<z.ZodString>;
95
96
  passwordEnv: z.ZodOptional<z.ZodString>;
96
97
  sbom: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodLiteral<false>]>>;
@@ -113,6 +114,8 @@ export declare const ChantConfigSchema: z.ZodObject<{
113
114
  forge: "forge";
114
115
  }>>;
115
116
  types: z.ZodOptional<z.ZodArray<z.ZodString>>;
117
+ exclude: z.ZodOptional<z.ZodArray<z.ZodString>>;
118
+ nonConventional: z.ZodOptional<z.ZodBoolean>;
116
119
  before: z.ZodOptional<z.ZodString>;
117
120
  after: z.ZodOptional<z.ZodString>;
118
121
  }, z.core.$strict>>;
@@ -294,6 +297,7 @@ export declare const ChantConfigSchema: z.ZodObject<{
294
297
  archive: z.ZodOptional<z.ZodString>;
295
298
  prepare: z.ZodOptional<z.ZodString>;
296
299
  args: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
300
+ labels: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
297
301
  }, z.core.$strict>]>>>;
298
302
  artifacts: z.ZodOptional<z.ZodArray<z.ZodUnion<readonly [z.ZodObject<{
299
303
  name: z.ZodString;
@@ -350,6 +354,7 @@ export declare const ChantConfigSchema: z.ZodObject<{
350
354
  "forge-checks": "forge-checks";
351
355
  none: "none";
352
356
  }>>;
357
+ check: z.ZodOptional<z.ZodArray<z.ZodString>>;
353
358
  verify: z.ZodOptional<z.ZodArray<z.ZodUnion<readonly [z.ZodString, z.ZodObject<{
354
359
  name: z.ZodOptional<z.ZodString>;
355
360
  run: z.ZodString;
@@ -830,6 +835,15 @@ export interface ChantConfig {
830
835
  * the repository holds `ci/green/` tags, else `forge-checks`. See ./lifecycle/release-green.ts.
831
836
  */
832
837
  green?: import("./lifecycle/release-green.js").ReleaseGreenSource;
838
+ /**
839
+ * Shell lines `chant release cut` runs (#5261), with or without `--yes`,
840
+ * once the label is stamped and the release's builds have run, and before
841
+ * any environment is compiled or anything recorded or tagged, with
842
+ * `CHANT_RELEASE_LABEL` and `CHANT_RELEASE_COMMIT` set. One that fails
843
+ * refuses the cut with `release-check-failed`. A train's checks are
844
+ * `release.train.check`.
845
+ */
846
+ check?: string[];
833
847
  /**
834
848
  * Commands `chant release publish` and `chant workspace train publish`
835
849
  * run after every target has staged and before any reveals (#5157), with
package/dist/config.js CHANGED
@@ -113,6 +113,8 @@ export const ChantConfigSchema = z.object({
113
113
  prepare: z.string().min(1).optional(),
114
114
  // #4908: build arguments beside the two chant passes.
115
115
  args: z.record(z.string(), z.string()).optional(),
116
+ // #5269: OCI labels on the image.
117
+ labels: z.record(z.string(), z.string()).optional(),
116
118
  })
117
119
  .strict(),
118
120
  ]))
@@ -178,6 +180,8 @@ export const ChantConfigSchema = z.object({
178
180
  lane: z.string().regex(/^[a-z0-9][a-z0-9-]*$/, "a ci.green lane name: lowercase letters, digits and dashes").optional(),
179
181
  // #5149: what says a commit may be released.
180
182
  green: z.enum(["chant", "forge-checks", "none"]).optional(),
183
+ // #5261: shell lines a single release's cut runs once the label is stamped and before anything is recorded or tagged.
184
+ check: z.array(z.string().min(1)).optional(),
181
185
  // #5157: commands a publish runs after every target has staged and before any reveals.
182
186
  verify: z.array(z.union([z.string().min(1), z.object({ name: z.string().min(1).optional(), run: z.string().min(1) }).strict()])).optional(),
183
187
  // #5165: workspace members a train publish reveals before this one, beside what the targets' names say.