@intentius/chant 0.124.101 → 0.124.102

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (101) 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/handlers/release-init.js +50 -18
  4. package/dist/cli/handlers/release.d.ts +1 -1
  5. package/dist/cli/handlers/release.js +12 -9
  6. package/dist/cli/release-commands/cut.js +4 -3
  7. package/dist/cli/release-commands/init.js +4 -1
  8. package/dist/cli/release-commands/workflow.js +4 -2
  9. package/dist/cloud-lister/index.d.ts +4 -1
  10. package/dist/cloud-lister/index.js +2 -1
  11. package/dist/cloud-lister/kubernetes-components.d.ts +56 -0
  12. package/dist/cloud-lister/kubernetes-components.js +642 -0
  13. package/dist/cloud-lister/kubernetes.d.ts +18 -0
  14. package/dist/cloud-lister/kubernetes.js +26 -1
  15. package/dist/cloud-lister/mask.d.ts +5 -1
  16. package/dist/cloud-lister/mask.js +14 -5
  17. package/dist/config-import.d.ts +1 -1
  18. package/dist/config-import.js +6 -2
  19. package/dist/config-sandbox.d.ts +1 -1
  20. package/dist/config-sandbox.js +3 -3
  21. package/dist/config.d.ts +75 -1
  22. package/dist/config.js +27 -2
  23. package/dist/deep-observation.js +9 -3
  24. package/dist/floor-table.data.js +12 -6
  25. package/dist/lexicon.d.ts +4 -2
  26. package/dist/lifecycle/__fixtures__/package-files.d.ts +32 -0
  27. package/dist/lifecycle/__fixtures__/package-files.js +72 -0
  28. package/dist/lifecycle/__fixtures__/publish-fakes.js +5 -0
  29. package/dist/lifecycle/publish-credentials.d.ts +1 -1
  30. package/dist/lifecycle/publish-credentials.js +5 -0
  31. package/dist/lifecycle/publish-declaration.d.ts +123 -0
  32. package/dist/lifecycle/publish-declaration.js +140 -0
  33. package/dist/lifecycle/publish-helm.d.ts +83 -0
  34. package/dist/lifecycle/publish-helm.js +452 -0
  35. package/dist/lifecycle/publish-maven.d.ts +79 -0
  36. package/dist/lifecycle/publish-maven.js +364 -0
  37. package/dist/lifecycle/publish-mcp-registry.js +1 -2
  38. package/dist/lifecycle/publish-npm.d.ts +27 -1
  39. package/dist/lifecycle/publish-npm.js +51 -1
  40. package/dist/lifecycle/publish-nuget.d.ts +93 -0
  41. package/dist/lifecycle/publish-nuget.js +377 -0
  42. package/dist/lifecycle/publish-oci.d.ts +57 -1
  43. package/dist/lifecycle/publish-oci.js +1 -1
  44. package/dist/lifecycle/publish-package-files.d.ts +16 -0
  45. package/dist/lifecycle/publish-package-files.js +39 -0
  46. package/dist/lifecycle/publish-pypi.d.ts +2 -0
  47. package/dist/lifecycle/publish-pypi.js +1 -1
  48. package/dist/lifecycle/publish-rubygems.d.ts +84 -0
  49. package/dist/lifecycle/publish-rubygems.js +366 -0
  50. package/dist/lifecycle/publish-targets.d.ts +10 -0
  51. package/dist/lifecycle/publish-targets.js +22 -0
  52. package/dist/lifecycle/publish-train-names.d.ts +4 -1
  53. package/dist/lifecycle/publish-train-names.js +5 -0
  54. package/dist/lifecycle/release-artifacts.d.ts +80 -2
  55. package/dist/lifecycle/release-artifacts.js +242 -5
  56. package/dist/lifecycle/release-cut.d.ts +6 -1
  57. package/dist/lifecycle/release-cut.js +15 -0
  58. package/dist/lifecycle/release-doctor.js +208 -6
  59. package/dist/lifecycle/release-init-registries.d.ts +48 -0
  60. package/dist/lifecycle/release-init-registries.js +97 -0
  61. package/dist/lifecycle/release-init.d.ts +22 -2
  62. package/dist/lifecycle/release-init.js +132 -7
  63. package/dist/lifecycle/release-next.js +1 -2
  64. package/dist/lifecycle/release-publish.d.ts +1 -1
  65. package/dist/lifecycle/release-publish.js +1 -1
  66. package/dist/lifecycle/release-tag.js +1 -2
  67. package/dist/op/local-executor.d.ts +1 -1
  68. package/dist/op/local-executor.js +2 -2
  69. package/dist/op/op-waves-evidence.js +9 -2
  70. package/dist/release-floors.d.ts +1 -1
  71. package/dist/release-floors.js +1 -1
  72. package/dist/sensitive-key.d.ts +12 -0
  73. package/dist/sensitive-key.js +52 -0
  74. package/dist/tool-pins.d.ts +2 -0
  75. package/dist/tool-pins.js +12 -0
  76. package/dist/ts-loader.d.ts +8 -0
  77. package/dist/ts-loader.js +19 -0
  78. package/dist/wave-runtime.mjs +325 -325
  79. package/dist/workspace/lexicon-outputs.d.ts +1 -1
  80. package/dist/workspace/lexicon-outputs.js +1 -1
  81. package/dist/workspace/release-steps/index.js +4 -0
  82. package/dist/workspace/release-steps/nfpm.d.ts +13 -0
  83. package/dist/workspace/release-steps/nfpm.js +29 -0
  84. package/dist/workspace/release-steps/nuget.d.ts +14 -0
  85. package/dist/workspace/release-steps/nuget.js +16 -0
  86. package/dist/workspace/release-steps/targets.d.ts +2 -2
  87. package/dist/workspace/release-steps/targets.js +3 -3
  88. package/dist/workspace/release-train-workflow.d.ts +7 -0
  89. package/dist/workspace/release-train-workflow.js +46 -10
  90. package/dist/workspace/release-workflow.d.ts +28 -3
  91. package/dist/workspace/release-workflow.js +38 -15
  92. package/dist/workspace/train-cut.d.ts +2 -2
  93. package/dist/workspace/train-cut.js +27 -5
  94. package/dist/workspace/train-prepare.d.ts +6 -3
  95. package/dist/workspace/train-prepare.js +54 -8
  96. package/dist/workspace/train-publish.js +2 -3
  97. package/dist/workspace/train-shell.d.ts +5 -0
  98. package/dist/workspace/train-shell.js +17 -0
  99. package/dist/workspace/trust/check-evidence-report.d.ts +3 -7
  100. package/dist/workspace/trust/check-evidence-report.js +3 -7
  101. 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`;
@@ -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();
@@ -315,7 +347,7 @@ async function runTrainInit(ctx, root, plan, fg, fail) {
315
347
  console.log = console.error;
316
348
  let code;
317
349
  try {
318
- code = await runReleaseWorkflow({ ...ctx, args: { ...ctx.args, forge: fg } });
350
+ code = await runReleaseWorkflow({ ...ctx, args: { ...ctx.args, forge: fg, ...(adopted ? { force: true } : {}) } });
319
351
  }
320
352
  finally {
321
353
  console.log = log;
@@ -324,7 +356,7 @@ async function runTrainInit(ctx, root, plan, fg, fail) {
324
356
  return code;
325
357
  }
326
358
  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.`);
359
+ 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
360
  }
329
361
  if (json) {
330
362
  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>`);
@@ -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;