@intentius/chant 0.124.101 → 0.124.103

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 (109) hide show
  1. package/dist/ci-evidence-claims.d.ts +12 -0
  2. package/dist/ci-evidence-claims.js +12 -0
  3. package/dist/cli/commands/onboard.js +8 -8
  4. package/dist/cli/handlers/release-init.js +53 -19
  5. package/dist/cli/handlers/release.d.ts +1 -1
  6. package/dist/cli/handlers/release.js +12 -9
  7. package/dist/cli/main.js +13 -2
  8. package/dist/cli/parse-args.js +5 -0
  9. package/dist/cli/registry.d.ts +2 -0
  10. package/dist/cli/release-commands/cut.js +4 -3
  11. package/dist/cli/release-commands/init.js +4 -1
  12. package/dist/cli/release-commands/workflow.js +4 -2
  13. package/dist/cloud-lister/index.d.ts +4 -1
  14. package/dist/cloud-lister/index.js +2 -1
  15. package/dist/cloud-lister/kubernetes-components.d.ts +56 -0
  16. package/dist/cloud-lister/kubernetes-components.js +641 -0
  17. package/dist/cloud-lister/kubernetes.d.ts +18 -0
  18. package/dist/cloud-lister/kubernetes.js +26 -1
  19. package/dist/cloud-lister/mask.d.ts +5 -1
  20. package/dist/cloud-lister/mask.js +14 -5
  21. package/dist/config-import.d.ts +1 -1
  22. package/dist/config-import.js +6 -2
  23. package/dist/config-sandbox.d.ts +1 -1
  24. package/dist/config-sandbox.js +3 -3
  25. package/dist/config.d.ts +75 -1
  26. package/dist/config.js +27 -2
  27. package/dist/deep-observation.js +9 -3
  28. package/dist/floor-table.data.js +13 -6
  29. package/dist/lexicon.d.ts +4 -2
  30. package/dist/lifecycle/__fixtures__/package-files.d.ts +32 -0
  31. package/dist/lifecycle/__fixtures__/package-files.js +72 -0
  32. package/dist/lifecycle/__fixtures__/publish-fakes.js +5 -0
  33. package/dist/lifecycle/publish-credentials.d.ts +1 -1
  34. package/dist/lifecycle/publish-credentials.js +5 -0
  35. package/dist/lifecycle/publish-declaration.d.ts +123 -0
  36. package/dist/lifecycle/publish-declaration.js +141 -2
  37. package/dist/lifecycle/publish-helm.d.ts +83 -0
  38. package/dist/lifecycle/publish-helm.js +451 -0
  39. package/dist/lifecycle/publish-maven.d.ts +79 -0
  40. package/dist/lifecycle/publish-maven.js +363 -0
  41. package/dist/lifecycle/publish-mcp-registry.js +1 -2
  42. package/dist/lifecycle/publish-npm.d.ts +27 -1
  43. package/dist/lifecycle/publish-npm.js +52 -2
  44. package/dist/lifecycle/publish-nuget.d.ts +93 -0
  45. package/dist/lifecycle/publish-nuget.js +376 -0
  46. package/dist/lifecycle/publish-oci.d.ts +57 -1
  47. package/dist/lifecycle/publish-oci.js +1 -1
  48. package/dist/lifecycle/publish-package-files.d.ts +16 -0
  49. package/dist/lifecycle/publish-package-files.js +39 -0
  50. package/dist/lifecycle/publish-pypi.d.ts +2 -0
  51. package/dist/lifecycle/publish-pypi.js +1 -1
  52. package/dist/lifecycle/publish-rubygems.d.ts +84 -0
  53. package/dist/lifecycle/publish-rubygems.js +365 -0
  54. package/dist/lifecycle/publish-targets.d.ts +10 -0
  55. package/dist/lifecycle/publish-targets.js +22 -0
  56. package/dist/lifecycle/publish-train-names.d.ts +4 -1
  57. package/dist/lifecycle/publish-train-names.js +5 -0
  58. package/dist/lifecycle/release-artifacts.d.ts +80 -2
  59. package/dist/lifecycle/release-artifacts.js +241 -5
  60. package/dist/lifecycle/release-cut.d.ts +6 -1
  61. package/dist/lifecycle/release-cut.js +15 -0
  62. package/dist/lifecycle/release-doctor.js +208 -6
  63. package/dist/lifecycle/release-init-registries.d.ts +48 -0
  64. package/dist/lifecycle/release-init-registries.js +97 -0
  65. package/dist/lifecycle/release-init.d.ts +22 -2
  66. package/dist/lifecycle/release-init.js +139 -13
  67. package/dist/lifecycle/release-next.js +1 -2
  68. package/dist/lifecycle/release-publish.d.ts +1 -1
  69. package/dist/lifecycle/release-publish.js +1 -1
  70. package/dist/lifecycle/release-tag.js +1 -2
  71. package/dist/op/local-executor.d.ts +1 -1
  72. package/dist/op/local-executor.js +2 -2
  73. package/dist/op/op-waves-evidence.js +9 -2
  74. package/dist/release-floors.d.ts +1 -1
  75. package/dist/release-floors.js +1 -1
  76. package/dist/sensitive-key.d.ts +12 -0
  77. package/dist/sensitive-key.js +52 -0
  78. package/dist/tool-pins.d.ts +2 -0
  79. package/dist/tool-pins.js +12 -0
  80. package/dist/ts-loader.d.ts +8 -0
  81. package/dist/ts-loader.js +19 -0
  82. package/dist/wave-runtime.mjs +325 -325
  83. package/dist/workspace/lexicon-outputs.d.ts +1 -1
  84. package/dist/workspace/lexicon-outputs.js +1 -1
  85. package/dist/workspace/release-steps/index.js +4 -0
  86. package/dist/workspace/release-steps/nfpm.d.ts +13 -0
  87. package/dist/workspace/release-steps/nfpm.js +29 -0
  88. package/dist/workspace/release-steps/nuget.d.ts +14 -0
  89. package/dist/workspace/release-steps/nuget.js +16 -0
  90. package/dist/workspace/release-steps/targets.d.ts +2 -2
  91. package/dist/workspace/release-steps/targets.js +3 -3
  92. package/dist/workspace/release-train-workflow.d.ts +27 -2
  93. package/dist/workspace/release-train-workflow.js +171 -14
  94. package/dist/workspace/release-train.js +5 -1
  95. package/dist/workspace/release-workflow.d.ts +39 -3
  96. package/dist/workspace/release-workflow.js +80 -24
  97. package/dist/workspace/train-artifacts.d.ts +107 -0
  98. package/dist/workspace/train-artifacts.js +239 -0
  99. package/dist/workspace/train-cut.d.ts +14 -2
  100. package/dist/workspace/train-cut.js +49 -7
  101. package/dist/workspace/train-prepare.d.ts +6 -3
  102. package/dist/workspace/train-prepare.js +54 -8
  103. package/dist/workspace/train-publish.d.ts +9 -0
  104. package/dist/workspace/train-publish.js +29 -4
  105. package/dist/workspace/train-shell.d.ts +5 -0
  106. package/dist/workspace/train-shell.js +17 -0
  107. package/dist/workspace/trust/check-evidence-report.d.ts +3 -7
  108. package/dist/workspace/trust/check-evidence-report.js +3 -7
  109. package/package.json +1 -1
@@ -28,6 +28,18 @@ export declare const EVIDENCE_SOURCES_ENV = "CHANT_EVIDENCE_SOURCES";
28
28
  * did (#4870). See ./op/op-waves-evidence.ts.
29
29
  */
30
30
  export declare const WAVE_EVIDENCE_ENV = "CHANT_WAVE_EVIDENCE";
31
+ /**
32
+ * The variable a generated job hands the runner key in, as PEM (the same one
33
+ * the tick and `chant ci run` read). Kept here rather than in
34
+ * ./workspace/trust/ so the wave runner can ask whether it signs without
35
+ * loading a workspace module (#5219).
36
+ */
37
+ export declare const CHECK_EVIDENCE_KEY_ENV = "CHANT_RUNNER_KEY";
38
+ /**
39
+ * The variable a generated job sets to `oidc` when it signs keyless from
40
+ * its OIDC identity (#4869) instead of with a runner key.
41
+ */
42
+ export declare const RUNNER_IDENTITY_ENV = "CHANT_RUNNER_IDENTITY";
31
43
  /** Where one check's pass is read from (#4926). */
32
44
  export interface EvidenceSourceSpec {
33
45
  /** The job's name in the run. Default: `--from-job`'s. */
@@ -30,6 +30,18 @@ export const EVIDENCE_SOURCES_ENV = "CHANT_EVIDENCE_SOURCES";
30
30
  * did (#4870). See ./op/op-waves-evidence.ts.
31
31
  */
32
32
  export const WAVE_EVIDENCE_ENV = "CHANT_WAVE_EVIDENCE";
33
+ /**
34
+ * The variable a generated job hands the runner key in, as PEM (the same one
35
+ * the tick and `chant ci run` read). Kept here rather than in
36
+ * ./workspace/trust/ so the wave runner can ask whether it signs without
37
+ * loading a workspace module (#5219).
38
+ */
39
+ export const CHECK_EVIDENCE_KEY_ENV = "CHANT_RUNNER_KEY";
40
+ /**
41
+ * The variable a generated job sets to `oidc` when it signs keyless from
42
+ * its OIDC identity (#4869) instead of with a runner key.
43
+ */
44
+ export const RUNNER_IDENTITY_ENV = "CHANT_RUNNER_IDENTITY";
33
45
  /** The file name a check's claim is kept under: `plan:dev` is `plan-dev.json`. */
34
46
  export function checkClaimFileName(check) {
35
47
  return `${check.replace(/[^A-Za-z0-9._-]/g, "-")}.json`;
@@ -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",
@@ -6,7 +6,7 @@
6
6
  * and `release.train` at the root, unless `--one-release`. See
7
7
  * ../../lifecycle/release-init.ts.
8
8
  */
9
- import { appendFileSync, existsSync, readFileSync, writeFileSync } from "node:fs";
9
+ import { appendFileSync, existsSync, readdirSync, readFileSync, writeFileSync } from "node:fs";
10
10
  import { join, relative, resolve, sep } from "node:path";
11
11
  import { formatBold, formatError, formatSuccess, formatWarning } from "../format.js";
12
12
  const USAGE = "chant release init [--yes] [--force] [--one-release] [--forge github|gitlab|forgejo] [--json]";
@@ -14,7 +14,7 @@ export async function runReleaseInit(ctx) {
14
14
  const { args } = ctx;
15
15
  const root = resolve(".");
16
16
  const json = args.json === true;
17
- const write = args.yes === true;
17
+ const write = args.yes === true && args.dryRun !== true;
18
18
  const force = args.force === true;
19
19
  const { detectProject, planRelease, planTrain, trainFit, releaseBlockSource, } = await import("../../lifecycle/release-init.js");
20
20
  const fail = (code, message, fix, block) => {
@@ -27,8 +27,8 @@ export async function runReleaseInit(ctx) {
27
27
  }
28
28
  return 1;
29
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.");
30
+ if (!["package.json", "go.mod", "Cargo.toml", "pyproject.toml", "setup.py", "pom.xml", "Dockerfile", "chant.config.ts", "chant.config.json"].some((f) => existsSync(join(root, f))) && !readdirSync(root).some((f) => f.endsWith(".csproj") || f.endsWith(".gemspec")) && !existsSync(join(root, ".git"))) {
31
+ return fail("release-init-not-a-project", "this directory holds no package.json, go.mod, Cargo.toml, pyproject.toml, pom.xml, .csproj, .gemspec, Dockerfile or git repository", "Run chant release init in the project's root.");
32
32
  }
33
33
  const facts = detectProject(root);
34
34
  if (args.forge !== undefined) {
@@ -46,14 +46,21 @@ export async function runReleaseInit(ctx) {
46
46
  plan.notes.push(`One release for every package, not a release train: ${fit.why}.`);
47
47
  if (fit.train)
48
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);
49
+ const { typeScriptLoaderAvailable } = await import("../../ts-loader.js");
50
+ const canLoadTs = typeScriptLoaderAvailable();
51
+ const prepared = await prepareConfig(root, plan.release, force, canLoadTs);
50
52
  if ("error" in prepared)
51
53
  return fail(prepared.error.code, prepared.error.message, prepared.error.fix, block);
52
54
  const { configPath, configText, configName, created } = prepared;
53
- // The workflow file: one chant generated is regenerated; any other is left alone without --force.
55
+ if (created && configName === "chant.config.json")
56
+ plan.reasons.unshift(TSX_REASON);
57
+ // The workflow file: one chant generated is regenerated; any other is left alone without --force,
58
+ // unless it is the npm publish workflow the plan adopts, which the release workflow replaces.
54
59
  const { gitTop } = await import("../../workspace/tree.js");
55
60
  const top = gitTop(root) ?? root;
56
- if (!force && !(await workflowIsOurs(join(top, plan.workflowFile)))) {
61
+ const adopted = adoptedWorkflow(plan.release);
62
+ const handWritten = !(await workflowIsOurs(join(top, plan.workflowFile)));
63
+ if (handWritten && !force && !adopted) {
57
64
  return fail("release-init-workflow-exists", `${plan.workflowFile} exists and chant did not write it`, "Run again with --force to replace it.");
58
65
  }
59
66
  const gr = plan.goreleaserPatch;
@@ -110,7 +117,7 @@ export async function runReleaseInit(ctx) {
110
117
  console.log = console.error;
111
118
  let code;
112
119
  try {
113
- code = await runReleaseWorkflow({ ...ctx, args: { ...ctx.args, forge: facts.workflowForge } });
120
+ code = await runReleaseWorkflow({ ...ctx, args: { ...ctx.args, forge: facts.workflowForge, ...(adopted ? { force: true } : {}) } });
114
121
  }
115
122
  finally {
116
123
  console.log = log;
@@ -119,7 +126,7 @@ export async function runReleaseInit(ctx) {
119
126
  return code;
120
127
  }
121
128
  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}` : ""}.`);
129
+ console.log(`\nWould write ${configName} and ${plan.workflowFile} (with chant release workflow${handWritten ? `, replacing the ${plan.workflowFile} there` : ""})${gr?.append ? `, and add snapshot.version_template to ${gr.file}` : ""}.`);
123
130
  }
124
131
  if (gr?.manual && !json)
125
132
  console.log(formatWarning({ message: gr.manual }));
@@ -137,6 +144,13 @@ export async function runReleaseInit(ctx) {
137
144
  console.log(` ${n}`);
138
145
  return 0;
139
146
  }
147
+ /** Why init writes chant.config.json: the reason line a plan carries for it. */
148
+ const TSX_REASON = "chant.config.json, not chant.config.ts: tsx, which chant needs to read a TypeScript config, is not installed here, so the release block is written as JSON that this run and the workflow's jobs read without it";
149
+ /** The `release.workflow.file` init set to adopt the project's npm publish workflow, or null. */
150
+ function adoptedWorkflow(release) {
151
+ const file = release.workflow?.file;
152
+ return typeof file === "string" ? file : null;
153
+ }
140
154
  /** Whether the workflow file is absent or one chant generated, so writing it replaces nothing a person wrote. */
141
155
  async function workflowIsOurs(path) {
142
156
  if (!existsSync(path))
@@ -147,9 +161,11 @@ async function workflowIsOurs(path) {
147
161
  /**
148
162
  * The config of the project at `dir` with `release` written in: its
149
163
  * chant.config.ts edited in place, its chant.config.json rewritten, or a new
150
- * chant.config.ts.
164
+ * chant.config.ts. Without tsx (`canLoadTs` false) the new config is
165
+ * chant.config.json, and an existing chant.config.ts is refused, since
166
+ * nothing could read it back.
151
167
  */
152
- async function prepareConfig(dir, release, force) {
168
+ async function prepareConfig(dir, release, force, canLoadTs) {
153
169
  const { insertReleaseBlock, newConfigSource, ReleaseInitError } = await import("../../lifecycle/release-init.js");
154
170
  const tsPath = join(dir, "chant.config.ts");
155
171
  const jsonPath = join(dir, "chant.config.json");
@@ -157,6 +173,8 @@ async function prepareConfig(dir, release, force) {
157
173
  let configText;
158
174
  try {
159
175
  if (existsSync(tsPath)) {
176
+ if (!canLoadTs)
177
+ throw new ReleaseInitError("release-init-tsx-missing", "chant.config.ts is TypeScript, and chant needs tsx to read it, which is not installed here", "Add tsx as a dev dependency (npm i -D tsx) and run again, so this run and the release workflow's jobs can read the config.");
160
178
  configPath = tsPath;
161
179
  const before = readFileSync(tsPath, "utf-8");
162
180
  configText = insertReleaseBlock(before, release, force);
@@ -182,10 +200,14 @@ async function prepareConfig(dir, release, force) {
182
200
  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
201
  configText = `${JSON.stringify({ ...parsed, release }, null, 2)}\n`;
184
202
  }
185
- else {
203
+ else if (canLoadTs) {
186
204
  configPath = tsPath;
187
205
  configText = newConfigSource(release);
188
206
  }
207
+ else {
208
+ configPath = jsonPath;
209
+ configText = `${JSON.stringify({ release }, null, 2)}\n`;
210
+ }
189
211
  }
190
212
  catch (err) {
191
213
  if (err instanceof ReleaseInitError)
@@ -202,23 +224,31 @@ async function prepareConfig(dir, release, force) {
202
224
  async function runTrainInit(ctx, root, plan, fg, fail) {
203
225
  const { args } = ctx;
204
226
  const json = args.json === true;
205
- const write = args.yes === true;
227
+ const write = args.yes === true && args.dryRun !== true;
206
228
  const force = args.force === true;
207
229
  const lib = await import("../../lifecycle/release-init.js");
208
230
  const rel = (p) => relative(root, p).split(sep).join("/");
209
231
  // Each member's config, then the root's.
232
+ const { typeScriptLoaderAvailable } = await import("../../ts-loader.js");
233
+ const canLoadTs = typeScriptLoaderAvailable();
210
234
  const members = [];
211
235
  for (const m of plan.members) {
212
- const prepared = await prepareConfig(join(root, m.dir), m.release, force);
236
+ const prepared = await prepareConfig(join(root, m.dir), m.release, force, canLoadTs);
213
237
  const block = lib.releaseBlockSource(m.release, " ");
214
238
  if ("error" in prepared)
215
239
  return fail(prepared.error.code, `${m.dir}: ${prepared.error.message}`, prepared.error.fix, block);
216
240
  members.push({ name: m.name, dir: m.dir, package: m.package, release: m.release, path: prepared.configPath, text: prepared.configText, created: prepared.created });
217
241
  }
218
242
  const rootBlock = lib.releaseBlockSource(plan.release, " ");
219
- const prepared = await prepareConfig(root, plan.release, force);
243
+ const prepared = await prepareConfig(root, plan.release, force, canLoadTs);
220
244
  if ("error" in prepared)
221
245
  return fail(prepared.error.code, prepared.error.message, prepared.error.fix, rootBlock);
246
+ if (!canLoadTs) {
247
+ plan.reasons.unshift(TSX_REASON);
248
+ for (const m of members)
249
+ if (m.path.endsWith(".json"))
250
+ plan.reasons = plan.reasons.map((r) => r.replace(`${m.dir}/chant.config.ts, member`, `${m.dir}/chant.config.json, member`));
251
+ }
222
252
  // chant.workspace.json: a new one, or the members added to the one there.
223
253
  const wsPath = join(root, "chant.workspace.json");
224
254
  const wsCreated = !existsSync(wsPath);
@@ -251,7 +281,9 @@ async function runTrainInit(ctx, root, plan, fg, fail) {
251
281
  const wsText = `${JSON.stringify(ws, null, 2)}\n`;
252
282
  const { gitTop } = await import("../../workspace/tree.js");
253
283
  const top = gitTop(root) ?? root;
254
- if (!force && !(await workflowIsOurs(join(top, plan.workflowFile)))) {
284
+ const adopted = adoptedWorkflow(plan.release);
285
+ const handWritten = !(await workflowIsOurs(join(top, plan.workflowFile)));
286
+ if (handWritten && !force && !adopted) {
255
287
  return fail("release-init-workflow-exists", `${plan.workflowFile} exists and chant did not write it`, "Run again with --force to replace it.");
256
288
  }
257
289
  const wf = plan.workflowFile.split("/").pop();
@@ -262,7 +294,9 @@ async function runTrainInit(ctx, root, plan, fg, fail) {
262
294
  `chant workspace train cut ${plan.env} # the first train's plan; nothing is cut without --yes`,
263
295
  fg === "github"
264
296
  ? `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)`,
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)`,
266
300
  ];
267
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 }));
268
302
  const out = (dryRun) => ({
@@ -315,7 +349,7 @@ async function runTrainInit(ctx, root, plan, fg, fail) {
315
349
  console.log = console.error;
316
350
  let code;
317
351
  try {
318
- code = await runReleaseWorkflow({ ...ctx, args: { ...ctx.args, forge: fg } });
352
+ code = await runReleaseWorkflow({ ...ctx, args: { ...ctx.args, forge: fg, ...(adopted ? { force: true } : {}) } });
319
353
  }
320
354
  finally {
321
355
  console.log = log;
@@ -324,7 +358,7 @@ async function runTrainInit(ctx, root, plan, fg, fail) {
324
358
  return code;
325
359
  }
326
360
  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.`);
361
+ console.log(`\nWould write chant.workspace.json, ${prepared.configName}, ${members.map((m) => rel(m.path)).join(", ")} and ${plan.workflowFile} (with chant release workflow${handWritten ? `, replacing the ${plan.workflowFile} there` : ""}). Run with --one-release to release every package together under one label instead.`);
328
362
  }
329
363
  if (json) {
330
364
  console.log(JSON.stringify(out(false), null, 2));
@@ -57,7 +57,7 @@ export declare function nextCommands(req: {
57
57
  /** A project with no components deploys with `release export`, not promote (#4046). */
58
58
  noComponents: boolean;
59
59
  }): string[];
60
- /** The command line that ran, without `--json`, with `--yes` added: what a dry run says to run next. */
60
+ /** The command line that ran, without `--json` or `--dry-run`, with `--yes` added: what a dry run says to run next. */
61
61
  export declare function sameWithYes(argv: readonly string[]): string;
62
62
  /** How a cut's green gate reads in a line (#5149). */
63
63
  export declare function describeGreen(green: import("../../lifecycle/release-store.js").ReleaseCutGreen | undefined | null): string;
@@ -83,10 +83,10 @@ export function nextCommands(req) {
83
83
  return [publish, ...(deploy ? [deploy] : [])];
84
84
  return [...(req.tag ? [`git push origin ${req.tag}`] : []), publish, ...(deploy ? [deploy] : [])];
85
85
  }
86
- /** The command line that ran, without `--json`, with `--yes` added: what a dry run says to run next. */
86
+ /** The command line that ran, without `--json` or `--dry-run`, with `--yes` added: what a dry run says to run next. */
87
87
  export function sameWithYes(argv) {
88
88
  const quote = (a) => (/^[\w@%+=:,./-]+$/.test(a) ? a : `'${a.replace(/'/g, `'\\''`)}'`);
89
- return ["chant", ...argv.filter((a) => a !== "--json" && a !== "--yes"), "--yes"].map(quote).join(" ");
89
+ return ["chant", ...argv.filter((a) => a !== "--json" && a !== "--yes" && a !== "--dry-run"), "--yes"].map(quote).join(" ");
90
90
  }
91
91
  /**
92
92
  * The green lane a cut or a candidates read checks (#4692): `--lane`, else
@@ -497,7 +497,8 @@ export async function runReleaseCut(ctx) {
497
497
  }));
498
498
  return 1;
499
499
  }
500
- const dryRun = args.yes !== true;
500
+ // --dry-run is the default without --yes, and keeps a run with --yes a dry run.
501
+ const dryRun = args.yes !== true || args.dryRun === true;
501
502
  const cwd = resolve(".");
502
503
  const { spawnTargetCompiler, ReleaseCompileError, RELEASE_LABEL_ENV } = await import("../../components/release-compile.js");
503
504
  const { cutRelease, planRelease, ReleaseCutError } = await import("../../lifecycle/release-cut.js");
@@ -986,7 +987,8 @@ export async function runReleasePublish(ctx) {
986
987
  console.error(formatError({ message: "release publish needs a release", hint: USAGE }));
987
988
  return 1;
988
989
  }
989
- const dryRun = args.yes !== true;
990
+ // --dry-run is the default without --yes, and keeps a run with --yes a dry run.
991
+ const dryRun = args.yes !== true || args.dryRun === true;
990
992
  const cwd = resolve(".");
991
993
  const fail = (code, message, fix) => {
992
994
  console.error(formatError({ message: `${message} [${code}]`, ...(fix ? { hint: fix } : {}) }));
@@ -1462,7 +1464,8 @@ export async function runReleaseStatusChange(ctx, verb) {
1462
1464
  if (args.replacement !== undefined && verb === "restore")
1463
1465
  return fail("release-status-flag-invalid", "--replacement names the release to use instead of a deprecated or yanked one, and a restore sets neither");
1464
1466
  const cwd = resolve(".");
1465
- const dryRun = args.yes !== true;
1467
+ // --dry-run is the default without --yes, and keeps a run with --yes a dry run.
1468
+ const dryRun = args.yes !== true || args.dryRun === true;
1466
1469
  const { fetchLifecycle } = await import("../../lifecycle/git.js");
1467
1470
  await fetchLifecycle({ cwd }).catch(() => false);
1468
1471
  // The actor, as a cut finds it: --actor, the signer of --sign's key, the CI's actor, git, $USER.
@@ -1713,14 +1716,14 @@ export async function runReleaseCompose(ctx) {
1713
1716
  ...(args.base !== undefined ? { base: args.base } : {}),
1714
1717
  prs: args.prs ?? [],
1715
1718
  works: args.works ?? [],
1716
- yes: args.yes === true,
1719
+ yes: args.yes === true && args.dryRun !== true,
1717
1720
  trunk,
1718
1721
  });
1719
1722
  if (args.json) {
1720
- console.log(JSON.stringify({ dryRun: args.yes !== true, ...r, next: r.written || r.pushed ? [`chant release cut <label> --at ${r.tip}`] : [sameWithYes(process.argv.slice(2))] }, null, 2));
1723
+ console.log(JSON.stringify({ dryRun: args.yes !== true || args.dryRun === true, ...r, next: r.written || r.pushed ? [`chant release cut <label> --at ${r.tip}`] : [sameWithYes(process.argv.slice(2))] }, null, 2));
1721
1724
  return 0;
1722
1725
  }
1723
- const verb = args.yes === true ? "Composed" : "Dry run: would compose";
1726
+ const verb = args.yes === true && args.dryRun !== true ? "Composed" : "Dry run: would compose";
1724
1727
  console.log(`${verb} ${formatBold(r.branch)} on ${r.base.slice(0, 12)}${r.from ? `, after ${r.from.slice(0, 12)}` : ""}`);
1725
1728
  for (const s of r.picked)
1726
1729
  console.log(` pick ${s.commit.slice(0, 12)} ${s.subject} [${s.chosenBy.join(", ")}]`);
@@ -1729,7 +1732,7 @@ export async function runReleaseCompose(ctx) {
1729
1732
  if (r.picked.length === 0)
1730
1733
  console.log(" nothing new to pick");
1731
1734
  console.log(` tip ${r.tip.slice(0, 12)}${r.pushed ? `, pushed to ${trunk.remote}` : ""}`);
1732
- if (args.yes !== true)
1735
+ if (args.yes !== true || args.dryRun === true)
1733
1736
  console.error(`Dry run: no branch was moved or pushed. Run again with --yes: ${sameWithYes(process.argv.slice(2))}`);
1734
1737
  else
1735
1738
  console.error(`Next: once CI tags ${r.tip.slice(0, 12)} green, cut it: chant release cut <label> --at ${r.tip} --channel <channel>`);
package/dist/cli/main.js CHANGED
@@ -1207,13 +1207,14 @@ 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>] [--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
1216
+ types levels (auto, minor, core=major ...). --doctor
1217
+ runs release doctor in each member first. Without
1217
1218
  --yes it plans (#5154)
1218
1219
  workspace train prepare <env> [<train id|digest>] [--json]
1219
1220
  In a checkout of the train's commit: stamp each member
@@ -1221,6 +1222,16 @@ Workspace (level 1, #2524):
1221
1222
  workspace packages they depend on that the train does
1222
1223
  not publish here, once each, dependencies first
1223
1224
  (#5154)
1225
+ workspace train artifacts <env> [<train id|digest>] [--from <dir>] [-o <dir>] [--no-build] [--json]
1226
+ In a checkout of the train's commit: check the image
1227
+ archives and release.artifacts files of each member
1228
+ cut here against its release, building a member's
1229
+ again when one is missing. --from copies them from a
1230
+ directory -o staged them in, per member directory
1231
+ (#5216)
1232
+ workspace train verify <env> [<train id|digest>] [--json]
1233
+ release verify for each member the train cut from
1234
+ this commit (#5216)
1224
1235
  workspace train publish <env> [<train id|digest>] [--yes] [--allow-unsigned] [--require-provenance] [--json]
1225
1236
  Publish a train as one set: every member cut from this
1226
1237
  commit stages before any reveals, then each dependency
@@ -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",
@@ -1728,6 +1729,10 @@ export function parseArgs(args) {
1728
1729
  // `chant release init --one-release` (#5154): a workspace's packages released together, not as a train.
1729
1730
  result.oneRelease = true;
1730
1731
  }
1732
+ else if (arg === "--doctor") {
1733
+ // `chant workspace train cut <env> --doctor` (#5216): run release doctor in each member before the cut.
1734
+ result.doctor = true;
1735
+ }
1731
1736
  else if (arg === "--no-push") {
1732
1737
  // `chant ci run --no-push` (#4156): keep the run record on the local chant/lifecycle.
1733
1738
  result.noPush = true;
@@ -786,6 +786,8 @@ export interface ParsedArgs {
786
786
  ciJob?: string;
787
787
  /** `chant ci run --no-push` (#4156): write the run record on the local chant/lifecycle and push nothing. */
788
788
  noPush?: boolean;
789
+ /** `chant workspace train cut <env> --doctor` (#5216): `chant release doctor` in each member of the train before anything is cut. */
790
+ doctor?: boolean;
789
791
  /** `chant release init --one-release` (#5154): every package of a workspace in one release, not a train. */
790
792
  oneRelease?: boolean;
791
793
  /** `chant ci serve|run --setup-key --trust --principal <name>` (#4099): the principal the runner key is listed for. */
@@ -3,7 +3,7 @@ export const cutCommand = {
3
3
  name: "cut",
4
4
  helpOrder: 10,
5
5
  help: [
6
- " release cut [<label>|auto] [--pre <id>] [--at <sha>] [--yes] [--build <command>] [--param <k=v>]",
6
+ " release cut [<label>|auto] [--pre <id>] [--at <sha>] [--yes] [--dry-run] [--build <command>] [--param <k=v>]",
7
7
  " [--params-file <file>] [--src <dir>] [-o <file>] [--lexicon <name>]",
8
8
  " [--actor <name>] [--sign [<key file>]] [--channel <tag>]",
9
9
  " [--lane <name>] [--override-green]",
@@ -12,7 +12,8 @@ export const cutCommand = {
12
12
  " must be clean, on trunk and pushed, and carry a",
13
13
  " ci/green tag: compile every environment in the",
14
14
  " config's environments and print what the cut would",
15
- " build, record and tag, and what publishes where.",
15
+ " build, record and tag, and what publishes where;",
16
+ " --dry-run asks for it by name, even with --yes.",
16
17
  " --yes cuts: builds the artifacts once, stores the",
17
18
  " release on chant/lifecycle under its digest, records",
18
19
  " the actor and run id, tags the commit with the tag",
@@ -45,5 +46,5 @@ export const cutCommand = {
45
46
  " auto cuts the label release next computes, and every",
46
47
  " labelled cut records the intent files it consumed.",
47
48
  ],
48
- usage: { order: 10, text: "release cut [<label>|auto [--pre <id>]] [--at <sha>] [--yes] [--build <command>] [--param <k=v>] [--image <component>=<repository>@sha256:<hex>] [--params-file <file>] [--src <dir>] [-o <file>] [--lexicon <name>] [--actor <name>] [--sign [<key file>]] [--channel <tag>] [--lane <name>] [--override-green] [--json]" },
49
+ usage: { order: 10, text: "release cut [<label>|auto [--pre <id>]] [--at <sha>] [--yes] [--dry-run] [--build <command>] [--param <k=v>] [--image <component>=<repository>@sha256:<hex>] [--params-file <file>] [--src <dir>] [-o <file>] [--lexicon <name>] [--actor <name>] [--sign [<key file>]] [--channel <tag>] [--lane <name>] [--override-green] [--json]" },
49
50
  };
@@ -7,7 +7,10 @@ export const initCommand = {
7
7
  " Set up chant release in a project: detect its packages,",
8
8
  " images and tags, write release in chant.config.ts and",
9
9
  " the release workflow, and list the registry steps to",
10
- " take by hand. A workspace with several npm packages",
10
+ " take by hand (chant.config.json when tsx is not",
11
+ " installed). A workflow that runs npm publish becomes",
12
+ " the release workflow, so npm's trusted publisher",
13
+ " keeps naming it. A workspace with several npm packages",
11
14
  " gets a release train, a member per package, unless",
12
15
  " --one-release. A dry run unless --yes; --force replaces",
13
16
  " an existing release block.",
@@ -4,10 +4,12 @@ export const workflowCommand = {
4
4
  helpOrder: 120,
5
5
  help: [
6
6
  " release workflow [--forge github|gitlab|forgejo] [--install <command>]",
7
- " [--build <command>] [--chant <command>] [--output <file>]",
7
+ " [--build <command>] [--chant <command>] [--output <file>] [--force]",
8
8
  " Write the publish workflow, run on the tags",
9
9
  " release.tag makes (default release/**).",
10
10
  " Under supply-chain it passes --require-provenance, and",
11
- " under verified-releases it runs release verify first",
11
+ " under verified-releases it runs release verify first.",
12
+ " A file there that chant did not write is replaced",
13
+ " only with --force",
12
14
  ],
13
15
  };
@@ -29,11 +29,14 @@ export type { AwsTarget } from "./aws.js";
29
29
  export type { AzureTarget } from "./azure.js";
30
30
  export type { GcpTarget } from "./gcp.js";
31
31
  export type { KubernetesTarget } from "./kubernetes.js";
32
- export { kubeTargetFromKubeconfig } from "./kubernetes.js";
32
+ export { kubeTargetFromKubeconfig, workloadStatusView } from "./kubernetes.js";
33
+ export type { WorkloadStatus } from "./kubernetes.js";
33
34
  export { ListerConfigError } from "./credentials.js";
34
35
  export { MutatingCallRefused, READ_OPERATIONS } from "./guard.js";
35
36
  export { OriginRefused } from "./transport.js";
36
37
  export { listedNodeId, parseListedNodeId } from "./ids.js";
38
+ export { inferK8sComponents, serviceNamesIn, K8S_COMPONENTS_FLOOR } from "./kubernetes-components.js";
39
+ export type { InferredK8sComponents, K8sBoundary, K8sComponentMember, K8sMemberRole, K8sComponentStatus, K8sOutsideName, K8sSharedObject } from "./kubernetes-components.js";
37
40
  /** Where and how to reach the scope's substrate. The variant must match `scope.substrate`. */
38
41
  export type SubstrateTarget = {
39
42
  substrate: "aws";
@@ -24,11 +24,12 @@ import { listGcp } from "./gcp.js";
24
24
  import { listKubernetes } from "./kubernetes.js";
25
25
  import { sdkCredentialChains } from "./credentials.js";
26
26
  import { Transport } from "./transport.js";
27
- export { kubeTargetFromKubeconfig } from "./kubernetes.js";
27
+ export { kubeTargetFromKubeconfig, workloadStatusView } from "./kubernetes.js";
28
28
  export { ListerConfigError } from "./credentials.js";
29
29
  export { MutatingCallRefused, READ_OPERATIONS } from "./guard.js";
30
30
  export { OriginRefused } from "./transport.js";
31
31
  export { listedNodeId, parseListedNodeId } from "./ids.js";
32
+ export { inferK8sComponents, serviceNamesIn, K8S_COMPONENTS_FLOOR } from "./kubernetes-components.js";
32
33
  function sortedUnique(values) {
33
34
  if (values === "*")
34
35
  return "*";
@@ -0,0 +1,56 @@
1
+ import type { GraphIR } from "../graph-ir.js";
2
+ /** The first chant with `inferK8sComponents`, the applications of a live Kubernetes read as a component graph (#5252). */
3
+ export declare const K8S_COMPONENTS_FLOOR = "0.124.102";
4
+ /** What a member is to its application, so a reader can fold without knowing Kubernetes kinds. */
5
+ export type K8sMemberRole = "workload" | "runtime" | "service" | "route" | "policy" | "config" | "storage" | "identity" | "bookkeeping";
6
+ export interface K8sComponentMember {
7
+ /** The node id in the read's graph. */
8
+ id: string;
9
+ role: K8sMemberRole;
10
+ }
11
+ /** A name a member gives for something outside the cluster: a cloud identity or a cloud secret. */
12
+ export interface K8sOutsideName {
13
+ /** The node id that names it. */
14
+ from: string;
15
+ /** Where: an annotation key, or `remoteRef.key`. */
16
+ key: string;
17
+ value: string;
18
+ }
19
+ /** How an application's boundary was drawn. `workload`: no label named a unit, so it is one workload. */
20
+ export interface K8sBoundary {
21
+ by: "part-of" | "argocd" | "helm" | "instance" | "chant" | "workload";
22
+ value: string;
23
+ }
24
+ /**
25
+ * An application's health, from the lister's `workloadStatus` views: ready
26
+ * over desired replicas summed over its workloads (a bare Pod counts as one),
27
+ * absent when none of them has replica counts (a CronJob, a Job), and the
28
+ * restarts summed over every Pod they run.
29
+ */
30
+ export interface K8sComponentStatus {
31
+ readyReplicas?: number;
32
+ desiredReplicas?: number;
33
+ restarts: number;
34
+ }
35
+ /** An object two or more applications use. */
36
+ export interface K8sSharedObject {
37
+ id: string;
38
+ role: K8sMemberRole;
39
+ /** The applications that use it, sorted. */
40
+ usedBy: string[];
41
+ outside?: K8sOutsideName[];
42
+ }
43
+ export interface InferredK8sComponents {
44
+ /** The component graph, in `chant graph --components --format ir`'s shape. */
45
+ ir: GraphIR;
46
+ shared: K8sSharedObject[];
47
+ notes: string[];
48
+ }
49
+ /**
50
+ * The Services a string names: `[namespace, name]` for each cluster DNS name
51
+ * in it, and the bare name in `ns` when the whole string is a name, a
52
+ * `name:port` or a URL whose host is the name. Exported for tests.
53
+ */
54
+ export declare function serviceNamesIn(value: string, ns: string): Array<[string, string]>;
55
+ /** Infer the applications of a live Kubernetes read (an `IndexDocument`'s `graph`). */
56
+ export declare function inferK8sComponents(graph: Pick<GraphIR, "nodes">): InferredK8sComponents;