@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.
- package/dist/ci-evidence-claims.d.ts +12 -0
- package/dist/ci-evidence-claims.js +12 -0
- package/dist/cli/commands/onboard.js +8 -8
- package/dist/cli/handlers/release-init.js +53 -19
- package/dist/cli/handlers/release.d.ts +1 -1
- package/dist/cli/handlers/release.js +12 -9
- package/dist/cli/main.js +13 -2
- package/dist/cli/parse-args.js +5 -0
- package/dist/cli/registry.d.ts +2 -0
- package/dist/cli/release-commands/cut.js +4 -3
- package/dist/cli/release-commands/init.js +4 -1
- package/dist/cli/release-commands/workflow.js +4 -2
- package/dist/cloud-lister/index.d.ts +4 -1
- package/dist/cloud-lister/index.js +2 -1
- package/dist/cloud-lister/kubernetes-components.d.ts +56 -0
- package/dist/cloud-lister/kubernetes-components.js +641 -0
- package/dist/cloud-lister/kubernetes.d.ts +18 -0
- package/dist/cloud-lister/kubernetes.js +26 -1
- package/dist/cloud-lister/mask.d.ts +5 -1
- package/dist/cloud-lister/mask.js +14 -5
- package/dist/config-import.d.ts +1 -1
- package/dist/config-import.js +6 -2
- package/dist/config-sandbox.d.ts +1 -1
- package/dist/config-sandbox.js +3 -3
- package/dist/config.d.ts +75 -1
- package/dist/config.js +27 -2
- package/dist/deep-observation.js +9 -3
- package/dist/floor-table.data.js +13 -6
- package/dist/lexicon.d.ts +4 -2
- package/dist/lifecycle/__fixtures__/package-files.d.ts +32 -0
- package/dist/lifecycle/__fixtures__/package-files.js +72 -0
- package/dist/lifecycle/__fixtures__/publish-fakes.js +5 -0
- package/dist/lifecycle/publish-credentials.d.ts +1 -1
- package/dist/lifecycle/publish-credentials.js +5 -0
- package/dist/lifecycle/publish-declaration.d.ts +123 -0
- package/dist/lifecycle/publish-declaration.js +141 -2
- package/dist/lifecycle/publish-helm.d.ts +83 -0
- package/dist/lifecycle/publish-helm.js +451 -0
- package/dist/lifecycle/publish-maven.d.ts +79 -0
- package/dist/lifecycle/publish-maven.js +363 -0
- package/dist/lifecycle/publish-mcp-registry.js +1 -2
- package/dist/lifecycle/publish-npm.d.ts +27 -1
- package/dist/lifecycle/publish-npm.js +52 -2
- package/dist/lifecycle/publish-nuget.d.ts +93 -0
- package/dist/lifecycle/publish-nuget.js +376 -0
- package/dist/lifecycle/publish-oci.d.ts +57 -1
- package/dist/lifecycle/publish-oci.js +1 -1
- package/dist/lifecycle/publish-package-files.d.ts +16 -0
- package/dist/lifecycle/publish-package-files.js +39 -0
- package/dist/lifecycle/publish-pypi.d.ts +2 -0
- package/dist/lifecycle/publish-pypi.js +1 -1
- package/dist/lifecycle/publish-rubygems.d.ts +84 -0
- package/dist/lifecycle/publish-rubygems.js +365 -0
- package/dist/lifecycle/publish-targets.d.ts +10 -0
- package/dist/lifecycle/publish-targets.js +22 -0
- package/dist/lifecycle/publish-train-names.d.ts +4 -1
- package/dist/lifecycle/publish-train-names.js +5 -0
- package/dist/lifecycle/release-artifacts.d.ts +80 -2
- package/dist/lifecycle/release-artifacts.js +241 -5
- package/dist/lifecycle/release-cut.d.ts +6 -1
- package/dist/lifecycle/release-cut.js +15 -0
- package/dist/lifecycle/release-doctor.js +208 -6
- package/dist/lifecycle/release-init-registries.d.ts +48 -0
- package/dist/lifecycle/release-init-registries.js +97 -0
- package/dist/lifecycle/release-init.d.ts +22 -2
- package/dist/lifecycle/release-init.js +139 -13
- package/dist/lifecycle/release-next.js +1 -2
- package/dist/lifecycle/release-publish.d.ts +1 -1
- package/dist/lifecycle/release-publish.js +1 -1
- package/dist/lifecycle/release-tag.js +1 -2
- package/dist/op/local-executor.d.ts +1 -1
- package/dist/op/local-executor.js +2 -2
- package/dist/op/op-waves-evidence.js +9 -2
- package/dist/release-floors.d.ts +1 -1
- package/dist/release-floors.js +1 -1
- package/dist/sensitive-key.d.ts +12 -0
- package/dist/sensitive-key.js +52 -0
- package/dist/tool-pins.d.ts +2 -0
- package/dist/tool-pins.js +12 -0
- package/dist/ts-loader.d.ts +8 -0
- package/dist/ts-loader.js +19 -0
- package/dist/wave-runtime.mjs +325 -325
- package/dist/workspace/lexicon-outputs.d.ts +1 -1
- package/dist/workspace/lexicon-outputs.js +1 -1
- package/dist/workspace/release-steps/index.js +4 -0
- package/dist/workspace/release-steps/nfpm.d.ts +13 -0
- package/dist/workspace/release-steps/nfpm.js +29 -0
- package/dist/workspace/release-steps/nuget.d.ts +14 -0
- package/dist/workspace/release-steps/nuget.js +16 -0
- package/dist/workspace/release-steps/targets.d.ts +2 -2
- package/dist/workspace/release-steps/targets.js +3 -3
- package/dist/workspace/release-train-workflow.d.ts +27 -2
- package/dist/workspace/release-train-workflow.js +171 -14
- package/dist/workspace/release-train.js +5 -1
- package/dist/workspace/release-workflow.d.ts +39 -3
- package/dist/workspace/release-workflow.js +80 -24
- package/dist/workspace/train-artifacts.d.ts +107 -0
- package/dist/workspace/train-artifacts.js +239 -0
- package/dist/workspace/train-cut.d.ts +14 -2
- package/dist/workspace/train-cut.js +49 -7
- package/dist/workspace/train-prepare.d.ts +6 -3
- package/dist/workspace/train-prepare.js +54 -8
- package/dist/workspace/train-publish.d.ts +9 -0
- package/dist/workspace/train-publish.js +29 -4
- package/dist/workspace/train-shell.d.ts +5 -0
- package/dist/workspace/train-shell.js +17 -0
- package/dist/workspace/trust/check-evidence-report.d.ts +3 -7
- package/dist/workspace/trust/check-evidence-report.js +3 -7
- package/package.json +1 -1
|
@@ -26,6 +26,8 @@
|
|
|
26
26
|
* 4. `release.train.check`: shell lines run once the labels are known and
|
|
27
27
|
* before anything is cut, with `CHANT_RELEASE_COMMIT`, `CHANT_TRAIN_ENV`
|
|
28
28
|
* and `CHANT_TRAIN_PLAN` (a JSON file of the members and labels).
|
|
29
|
+
* With `--doctor` (#5216), `chant release doctor` then runs in each
|
|
30
|
+
* member, and a failed check stops the train with nothing cut.
|
|
29
31
|
* 5. `chant release cut <label> --at <commit> --yes` in each member's
|
|
30
32
|
* directory, in publish order. Each cut pushes its record and tags the
|
|
31
33
|
* commit locally.
|
|
@@ -141,6 +143,8 @@ export type MemberCutter = (m: TrainCutMember, commit: string, o: {
|
|
|
141
143
|
root: string;
|
|
142
144
|
yes: boolean;
|
|
143
145
|
}) => Promise<MemberCutResult>;
|
|
146
|
+
/** The chant this process runs, as a command line. */
|
|
147
|
+
export declare function ownChant(): string[];
|
|
144
148
|
/** The default {@link MemberCutter}: this chant's `release cut` in the member's directory. */
|
|
145
149
|
export declare const spawnMemberCut: MemberCutter;
|
|
146
150
|
export interface TrainCutRun extends TrainCutQuery {
|
|
@@ -152,11 +156,19 @@ export interface TrainCutRun extends TrainCutQuery {
|
|
|
152
156
|
remote?: string;
|
|
153
157
|
actor?: string;
|
|
154
158
|
cutter?: MemberCutter;
|
|
155
|
-
/**
|
|
159
|
+
/**
|
|
160
|
+
* Run `chant release doctor` in each member of the train before anything is
|
|
161
|
+
* cut (#5216): a target that can't publish from here stops the train with
|
|
162
|
+
* nothing cut, tagged or pushed.
|
|
163
|
+
*/
|
|
164
|
+
doctor?: boolean;
|
|
165
|
+
/** Runs the doctor in a member's directory and returns its exit code. Default: this chant's `release doctor`, its stdout sent to stderr. */
|
|
166
|
+
runDoctor?: (dir: string) => number | Promise<number>;
|
|
167
|
+
/** Runs the `release.train.check` lines. Default: `sh -c` each one, its stdout sent to stderr. */
|
|
156
168
|
runCheck?: (line: string, o: {
|
|
157
169
|
cwd: string;
|
|
158
170
|
env: NodeJS.ProcessEnv;
|
|
159
|
-
}) => number
|
|
171
|
+
}) => number | Promise<number>;
|
|
160
172
|
/** A line of progress. */
|
|
161
173
|
say?: (line: string) => void;
|
|
162
174
|
now?: () => Date;
|
|
@@ -26,6 +26,8 @@
|
|
|
26
26
|
* 4. `release.train.check`: shell lines run once the labels are known and
|
|
27
27
|
* before anything is cut, with `CHANT_RELEASE_COMMIT`, `CHANT_TRAIN_ENV`
|
|
28
28
|
* and `CHANT_TRAIN_PLAN` (a JSON file of the members and labels).
|
|
29
|
+
* With `--doctor` (#5216), `chant release doctor` then runs in each
|
|
30
|
+
* member, and a failed check stops the train with nothing cut.
|
|
29
31
|
* 5. `chant release cut <label> --at <commit> --yes` in each member's
|
|
30
32
|
* directory, in publish order. Each cut pushes its record and tags the
|
|
31
33
|
* commit locally.
|
|
@@ -38,6 +40,7 @@
|
|
|
38
40
|
* cut's dry run, and cuts, records, tags and pushes nothing.
|
|
39
41
|
*/
|
|
40
42
|
import { execFileSync, spawnSync } from "node:child_process";
|
|
43
|
+
import { runToStderr } from "./train-shell.js";
|
|
41
44
|
import { randomUUID } from "node:crypto";
|
|
42
45
|
import { existsSync, mkdtempSync, readFileSync, realpathSync, writeFileSync } from "node:fs";
|
|
43
46
|
import { tmpdir } from "node:os";
|
|
@@ -316,7 +319,7 @@ export async function planTrainCut(q) {
|
|
|
316
319
|
return { env: q.env, commit, first: false, released: null, members: out };
|
|
317
320
|
}
|
|
318
321
|
/** The chant this process runs, as a command line. */
|
|
319
|
-
function ownChant() {
|
|
322
|
+
export function ownChant() {
|
|
320
323
|
return [process.execPath, ...process.execArgv, process.argv[1]];
|
|
321
324
|
}
|
|
322
325
|
/** The default {@link MemberCutter}: this chant's `release cut` in the member's directory. */
|
|
@@ -341,7 +344,13 @@ export const spawnMemberCut = async (m, commit, o) => {
|
|
|
341
344
|
throw new TrainCutError("train-cut-failed", `the cut of ${m.member} printed no JSON`);
|
|
342
345
|
}
|
|
343
346
|
};
|
|
344
|
-
|
|
347
|
+
// A check's stdout goes to stderr: under --json, stdout is the cut's JSON document alone.
|
|
348
|
+
const defaultCheck = (line, o) => runToStderr(line, o);
|
|
349
|
+
/** This chant's `release doctor` in a member's directory, its stdout sent to stderr. */
|
|
350
|
+
const defaultDoctor = (dir) => {
|
|
351
|
+
const [bin, ...pre] = ownChant();
|
|
352
|
+
return spawnSync(bin, [...pre, "release", "doctor"], { cwd: dir, stdio: ["ignore", 2, 2] }).status ?? 1;
|
|
353
|
+
};
|
|
345
354
|
/** Plan, and with `yes` cut, record, tag and push, a release train (#5154). */
|
|
346
355
|
export async function cutTrain(q) {
|
|
347
356
|
const root = locateWorkspace(q.cwd).rootOnDisk;
|
|
@@ -358,11 +367,43 @@ export async function cutTrain(q) {
|
|
|
358
367
|
const env = { ...process.env, CHANT_RELEASE_COMMIT: plan.commit, CHANT_TRAIN_ENV: plan.env, CHANT_TRAIN_PLAN: file };
|
|
359
368
|
for (const line of config.check ?? []) {
|
|
360
369
|
say(`check: ${line}`);
|
|
361
|
-
const code = (q.runCheck ?? defaultCheck)(line, { cwd: root, env });
|
|
370
|
+
const code = await (q.runCheck ?? defaultCheck)(line, { cwd: root, env });
|
|
362
371
|
if (code !== 0)
|
|
363
372
|
throw new TrainCutError("train-check-failed", `release.train.check failed (exit ${code}): ${line}`, "Nothing was cut. Fix what the check reports and run the train again.");
|
|
364
373
|
}
|
|
365
374
|
}
|
|
375
|
+
// #5230: a member's package npm has never had can't be published by trusted publishing. Refuse before the first member is cut.
|
|
376
|
+
{
|
|
377
|
+
const read = q.registry ?? npmVersions();
|
|
378
|
+
const { loadChantConfig } = await import("../config.js");
|
|
379
|
+
const { checkPackagesPublished } = await import("../lifecycle/publish-npm.js");
|
|
380
|
+
const { PublishTargetError } = await import("../lifecycle/release-publish.js");
|
|
381
|
+
for (const m of plan.members) {
|
|
382
|
+
if (m.resumed)
|
|
383
|
+
continue;
|
|
384
|
+
const dir = resolve(root, m.dir);
|
|
385
|
+
try {
|
|
386
|
+
checkPackagesPublished((await loadChantConfig(dir)).config.release?.publish ?? [], dir, (name, registry) => read(name, registry) !== null);
|
|
387
|
+
}
|
|
388
|
+
catch (err) {
|
|
389
|
+
if (err instanceof PublishTargetError)
|
|
390
|
+
throw new TrainCutError(err.code, `nothing was cut: ${m.member}: ${err.message}`, err.fix);
|
|
391
|
+
throw err;
|
|
392
|
+
}
|
|
393
|
+
}
|
|
394
|
+
}
|
|
395
|
+
// #5216: each member's doctor, after the checks and before the first cut.
|
|
396
|
+
if (q.doctor) {
|
|
397
|
+
const failed = [];
|
|
398
|
+
for (const m of plan.members) {
|
|
399
|
+
say(`doctor: ${m.member}`);
|
|
400
|
+
const code = await (q.runDoctor ?? defaultDoctor)(resolve(root, m.dir));
|
|
401
|
+
if (code !== 0)
|
|
402
|
+
failed.push(m.member);
|
|
403
|
+
}
|
|
404
|
+
if (failed.length > 0)
|
|
405
|
+
throw new TrainCutError("train-doctor-failed", `release doctor found a target that can't publish from here in ${failed.join(", ")}`, "Nothing was cut. Fix what the doctor reports and run the train again.");
|
|
406
|
+
}
|
|
366
407
|
const cutter = q.cutter ?? spawnMemberCut;
|
|
367
408
|
const tags = {};
|
|
368
409
|
for (const m of plan.members) {
|
|
@@ -412,7 +453,7 @@ export async function cutTrain(q) {
|
|
|
412
453
|
}
|
|
413
454
|
return { ...out, pushed: true };
|
|
414
455
|
}
|
|
415
|
-
const CUT_USAGE = "chant workspace train cut <env> [--at <sha>] [--levels <levels>] [--yes] [--no-push] [--json]";
|
|
456
|
+
const CUT_USAGE = "chant workspace train cut <env> [--at <sha>] [--levels <levels>] [--doctor] [--yes] [--no-push] [--json]";
|
|
416
457
|
/** `chant workspace train cut <env>` (#5154). */
|
|
417
458
|
export async function runTrainCut(ctx, words) {
|
|
418
459
|
const { formatError, formatSuccess, formatWarning } = await import("../cli/format.js");
|
|
@@ -436,8 +477,9 @@ export async function runTrainCut(ctx, words) {
|
|
|
436
477
|
env,
|
|
437
478
|
...(args.at ? { at: args.at } : {}),
|
|
438
479
|
levels: parseTrainLevels(args.levels),
|
|
439
|
-
yes: args.yes === true,
|
|
480
|
+
yes: args.yes === true && args.dryRun !== true,
|
|
440
481
|
noPush: args.noPush === true,
|
|
482
|
+
doctor: args.doctor === true,
|
|
441
483
|
...(args.actor ? { actor: args.actor } : {}),
|
|
442
484
|
say: (line) => (json ? undefined : console.error(line)),
|
|
443
485
|
});
|
|
@@ -456,7 +498,7 @@ export async function runTrainCut(ctx, words) {
|
|
|
456
498
|
throw err;
|
|
457
499
|
}
|
|
458
500
|
if (json) {
|
|
459
|
-
console.log(JSON.stringify({ dryRun: args.yes !== true, ...outcome }, null, 2));
|
|
501
|
+
console.log(JSON.stringify({ dryRun: args.yes !== true || args.dryRun === true, ...outcome }, null, 2));
|
|
460
502
|
return 0;
|
|
461
503
|
}
|
|
462
504
|
const short = outcome.commit.slice(0, 12);
|
|
@@ -471,7 +513,7 @@ export async function runTrainCut(ctx, words) {
|
|
|
471
513
|
console.log(`Release train for ${env} from ${short}${outcome.first ? " (the first: every member at one label)" : ""}:`);
|
|
472
514
|
for (const m of outcome.members)
|
|
473
515
|
console.log(` ${m.member.padEnd(24)} ${m.label.padEnd(12)} ${m.why}${m.bump ? `; ${m.bump} from ${m.bumpFrom}` : ""}${m.floor ? `; floor ${m.floor}` : ""}`);
|
|
474
|
-
if (args.yes !== true) {
|
|
516
|
+
if (args.yes !== true || args.dryRun === true) {
|
|
475
517
|
console.error("Dry run: nothing was cut, recorded, tagged or pushed. Run again with --yes to cut the train.");
|
|
476
518
|
return 0;
|
|
477
519
|
}
|
|
@@ -14,7 +14,10 @@
|
|
|
14
14
|
* - the workspace packages it depends on, directly or not, that this run
|
|
15
15
|
* does not publish are built once each, dependencies first, so a package
|
|
16
16
|
* that builds against another's output finds it. The members this run
|
|
17
|
-
* publishes build when npm packs them, in the train's layer order.
|
|
17
|
+
* publishes build when npm packs them, in the train's layer order. A
|
|
18
|
+
* member cut here whose package an earlier run of the publish already
|
|
19
|
+
* revealed is not packed again, so it builds here like any other
|
|
20
|
+
* dependency (#5222): a resumed publish finds what it left built. The
|
|
18
21
|
* command is `release.train.buildDependencies`, else the package's
|
|
19
22
|
* `prepack` script, else its `build` script.
|
|
20
23
|
*
|
|
@@ -29,8 +32,8 @@ export interface TrainPrepareQuery {
|
|
|
29
32
|
env: string;
|
|
30
33
|
/** The train by id or digest; the newest for `env` when absent. */
|
|
31
34
|
train?: string;
|
|
32
|
-
/** Runs one build command in a package directory and returns its exit code. Default: `sh -c
|
|
33
|
-
run?: (command: string, cwd: string) => number
|
|
35
|
+
/** Runs one build command in a package directory and returns its exit code. Default: `sh -c`, its stdout sent to stderr. */
|
|
36
|
+
run?: (command: string, cwd: string) => number | Promise<number>;
|
|
34
37
|
say?: (line: string) => void;
|
|
35
38
|
}
|
|
36
39
|
export interface TrainPrepareOutcome {
|
|
@@ -14,7 +14,10 @@
|
|
|
14
14
|
* - the workspace packages it depends on, directly or not, that this run
|
|
15
15
|
* does not publish are built once each, dependencies first, so a package
|
|
16
16
|
* that builds against another's output finds it. The members this run
|
|
17
|
-
* publishes build when npm packs them, in the train's layer order.
|
|
17
|
+
* publishes build when npm packs them, in the train's layer order. A
|
|
18
|
+
* member cut here whose package an earlier run of the publish already
|
|
19
|
+
* revealed is not packed again, so it builds here like any other
|
|
20
|
+
* dependency (#5222): a resumed publish finds what it left built. The
|
|
18
21
|
* command is `release.train.buildDependencies`, else the package's
|
|
19
22
|
* `prepack` script, else its `build` script.
|
|
20
23
|
*
|
|
@@ -23,7 +26,7 @@
|
|
|
23
26
|
* target; its dependencies are its `dependencies`, `peerDependencies` and
|
|
24
27
|
* `optionalDependencies` that name another such package.
|
|
25
28
|
*/
|
|
26
|
-
import { execFileSync
|
|
29
|
+
import { execFileSync } from "node:child_process";
|
|
27
30
|
import { existsSync, readdirSync, readFileSync, realpathSync } from "node:fs";
|
|
28
31
|
// @ts-ignore — picomatch has no types declaration
|
|
29
32
|
import picomatch from "picomatch";
|
|
@@ -31,8 +34,10 @@ import { resolve } from "node:path";
|
|
|
31
34
|
import { readDeclaration } from "./declaration.js";
|
|
32
35
|
import { findTrain, readReleaseTrains } from "./release-train.js";
|
|
33
36
|
import { TrainCutError, trainConfigAt } from "./train-cut.js";
|
|
37
|
+
import { runToStderr } from "./train-shell.js";
|
|
34
38
|
import { locateWorkspace } from "./which-chant.js";
|
|
35
|
-
|
|
39
|
+
// A build's stdout goes to stderr: under --json, stdout is the prepare's JSON document alone.
|
|
40
|
+
const defaultRun = (command, cwd) => runToStderr(command, { cwd });
|
|
36
41
|
/** Stamp and build what the train's members cut from this commit need before `train publish` (#5154). */
|
|
37
42
|
export async function prepareTrain(q) {
|
|
38
43
|
const located = locateWorkspace(q.cwd);
|
|
@@ -60,13 +65,20 @@ export async function prepareTrain(q) {
|
|
|
60
65
|
// Every workspace package the members name, by name.
|
|
61
66
|
const packages = new Map();
|
|
62
67
|
const ownedBy = new Map();
|
|
68
|
+
// Per member, each package it owns and the npm targets that pack it (none for a package only release.version names).
|
|
69
|
+
const packedBy = new Map();
|
|
70
|
+
const declsOf = new Map();
|
|
63
71
|
for (const m of members) {
|
|
64
72
|
const dir = resolve(root, m.dir);
|
|
65
73
|
if (!existsSync(dir))
|
|
66
74
|
continue;
|
|
67
75
|
const release = (await loadChantConfig(dir)).config.release;
|
|
68
|
-
|
|
69
|
-
|
|
76
|
+
declsOf.set(m.name, (release?.publish ?? []));
|
|
77
|
+
const dirs = [
|
|
78
|
+
...(release?.version?.packages ?? []).map((p) => ({ p, decl: null })),
|
|
79
|
+
...(release?.publish ?? []).flatMap((t) => (t.type === "npm" ? (t.packages ?? []).map((p) => ({ p, decl: t })) : [])),
|
|
80
|
+
];
|
|
81
|
+
for (const { p, decl } of dirs) {
|
|
70
82
|
const file = resolve(dir, p, "package.json");
|
|
71
83
|
if (!existsSync(file))
|
|
72
84
|
continue;
|
|
@@ -81,7 +93,11 @@ export async function prepareTrain(q) {
|
|
|
81
93
|
if (typeof pkg.name !== "string")
|
|
82
94
|
continue;
|
|
83
95
|
packages.set(pkg.name, { dir: abs, name: pkg.name, needs: Object.keys({ ...pkg.dependencies, ...pkg.peerDependencies, ...pkg.optionalDependencies }), scripts: pkg.scripts ?? {} });
|
|
84
|
-
|
|
96
|
+
if (!(ownedBy.get(m.name) ?? []).includes(pkg.name))
|
|
97
|
+
ownedBy.set(m.name, [...(ownedBy.get(m.name) ?? []), pkg.name]);
|
|
98
|
+
const by = packedBy.get(m.name) ?? new Map();
|
|
99
|
+
by.set(pkg.name, [...(by.get(pkg.name) ?? []), ...(decl ? [decl] : [])]);
|
|
100
|
+
packedBy.set(m.name, by);
|
|
85
101
|
}
|
|
86
102
|
}
|
|
87
103
|
// The repository's other workspace packages (npm, yarn and pnpm workspaces), which a member's package may build against.
|
|
@@ -123,7 +139,7 @@ export async function prepareTrain(q) {
|
|
|
123
139
|
// Build, once each and dependencies first, the packages the published ones need and this run does not publish.
|
|
124
140
|
const built = [];
|
|
125
141
|
if (config.buildDependencies !== false) {
|
|
126
|
-
const published =
|
|
142
|
+
const published = await packedThisRun(here, members, root, ownedBy, packedBy, declsOf);
|
|
127
143
|
const order = [];
|
|
128
144
|
const seen = new Set();
|
|
129
145
|
const visit = (name) => {
|
|
@@ -144,7 +160,7 @@ export async function prepareTrain(q) {
|
|
|
144
160
|
continue;
|
|
145
161
|
const shown = p.dir.startsWith(`${realpathSync(located.top ?? root)}/`) ? p.dir.slice(realpathSync(located.top ?? root).length + 1) : p.dir;
|
|
146
162
|
say(`build ${name} (${shown}), which ${[...published].filter((x) => dependsOn(packages, x, name)).join(", ")} builds against: ${command}`);
|
|
147
|
-
const code = (q.run ?? defaultRun)(command, p.dir);
|
|
163
|
+
const code = await (q.run ?? defaultRun)(command, p.dir);
|
|
148
164
|
if (code !== 0)
|
|
149
165
|
throw new TrainCutError("train-build-failed", `building ${name} in ${shown} failed (exit ${code}): ${command}`, "Fix the build and run the prepare again in a clean checkout of the train's commit.");
|
|
150
166
|
built.push({ dir: shown, command });
|
|
@@ -152,6 +168,36 @@ export async function prepareTrain(q) {
|
|
|
152
168
|
}
|
|
153
169
|
return { train, stamped, built };
|
|
154
170
|
}
|
|
171
|
+
/**
|
|
172
|
+
* The packages the publish packs in this run: those of each member cut here,
|
|
173
|
+
* less the ones an earlier run already revealed (#5222). A package is
|
|
174
|
+
* revealed when every npm target that packs it is; a package no npm target
|
|
175
|
+
* packs, when every target of its member is.
|
|
176
|
+
*/
|
|
177
|
+
async function packedThisRun(here, members, root, ownedBy, packedBy, declsOf) {
|
|
178
|
+
const { publishProgress, readPublishRecords } = await import("../lifecycle/publish-record.js");
|
|
179
|
+
const { publishTargetKey } = await import("../lifecycle/publish-targets.js");
|
|
180
|
+
const out = new Set();
|
|
181
|
+
for (const t of here) {
|
|
182
|
+
const m = members.find((x) => x.name === t.member);
|
|
183
|
+
const owned = ownedBy.get(t.member) ?? [];
|
|
184
|
+
if (!m) {
|
|
185
|
+
owned.forEach((n) => out.add(n));
|
|
186
|
+
continue;
|
|
187
|
+
}
|
|
188
|
+
const progress = publishProgress(await readPublishRecords(t.releaseDigest, { cwd: resolve(root, m.dir) }).catch(() => []));
|
|
189
|
+
const revealed = (d) => progress.revealed.has(publishTargetKey(d));
|
|
190
|
+
const decls = declsOf.get(t.member) ?? [];
|
|
191
|
+
const memberRevealed = decls.length > 0 && decls.every(revealed);
|
|
192
|
+
for (const name of owned) {
|
|
193
|
+
const by = packedBy.get(t.member)?.get(name) ?? [];
|
|
194
|
+
const done = by.length > 0 ? by.every(revealed) : memberRevealed;
|
|
195
|
+
if (!done)
|
|
196
|
+
out.add(name);
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
return out;
|
|
200
|
+
}
|
|
155
201
|
/**
|
|
156
202
|
* The package directories the repository's root declares as workspaces:
|
|
157
203
|
* `workspaces` in its package.json (an array, or `{ packages }` as yarn
|
|
@@ -173,5 +173,14 @@ export declare function trainDependencies(members: ReadonlyArray<{
|
|
|
173
173
|
}>): Map<string, string[]>;
|
|
174
174
|
/** Plan, and with `yes` publish, a release train (#5136). */
|
|
175
175
|
export declare function publishTrain(query: TrainPublishQuery): Promise<TrainPublishOutcome>;
|
|
176
|
+
/** The tag `release.tag` gives `label` in the member at `dir`, or null when it can't be told. */
|
|
177
|
+
/**
|
|
178
|
+
* The environment a member's targets run with (#5216): for a member that
|
|
179
|
+
* declares `release.images`, `CHANT_RELEASE_DIGESTS` names a file of the
|
|
180
|
+
* digests its release records, as `chant release images` writes it for one
|
|
181
|
+
* release, so a package it packs pins its own images. Other members get the
|
|
182
|
+
* environment as it is.
|
|
183
|
+
*/
|
|
184
|
+
export declare function memberDigestsEnv(dir: string, release: import("../lifecycle/release-store.js").Release, env: NodeJS.ProcessEnv): Promise<NodeJS.ProcessEnv>;
|
|
176
185
|
/** `chant workspace train publish <env> [<train>] [--yes]` (#5136). */
|
|
177
186
|
export declare function runTrainPublish(ctx: import("../cli/registry.js").CommandContext, words: string[]): Promise<number>;
|
|
@@ -59,9 +59,8 @@ import { PublishTargetError, revealOrder } from "../lifecycle/release-publish.js
|
|
|
59
59
|
import { readDeclaration } from "./declaration.js";
|
|
60
60
|
import { findTrain, readReleaseTrains } from "./release-train.js";
|
|
61
61
|
import { locateWorkspace } from "./which-chant.js";
|
|
62
|
-
import { NEXT_RELEASE } from "../release-floors.js";
|
|
63
62
|
/** The first chant whose `chant workspace train publish` orders and resumes members of every target kind (#5165): the oci, forge, homebrew, index, marketplace, pypi, cargo, mcp-registry and tauri-updater targets name what they publish and need, say whether a pinned release is published, and wait until a reveal is served before the next layer; a member's `release.dependsOn` names members a manifest doesn't show. */
|
|
64
|
-
export const TRAIN_PUBLISH_TARGETS_FLOOR =
|
|
63
|
+
export const TRAIN_PUBLISH_TARGETS_FLOOR = "0.124.101";
|
|
65
64
|
/** A train publish that stopped, with what it left staged and revealed (`<member>: <target>`), so a run of the same command resumes. */
|
|
66
65
|
export class TrainPublishRunError extends PublishTargetError {
|
|
67
66
|
constructor(code, message, fix, member, step, staged, revealed) {
|
|
@@ -229,7 +228,7 @@ export async function publishTrain(query) {
|
|
|
229
228
|
for (const w of [plan.signatureWarning, plan.warning])
|
|
230
229
|
if (w && !warnings.includes(`${m.member}: ${w}`))
|
|
231
230
|
warnings.push(`${m.member}: ${w}`);
|
|
232
|
-
const ctx = publishContext(plan, { cwd: dir, env, tag: plan.channel, log: memberLog(m.member, plan.redactor) });
|
|
231
|
+
const ctx = publishContext(plan, { cwd: dir, env: await memberDigestsEnv(dir, plan.release, env), tag: plan.channel, log: memberLog(m.member, plan.redactor) });
|
|
233
232
|
prepared.push({ m, dir, plan, ctx });
|
|
234
233
|
}
|
|
235
234
|
const redactor = createRedactor(env, credentialEnv);
|
|
@@ -307,6 +306,32 @@ export async function publishTrain(query) {
|
|
|
307
306
|
return { kind: "published", train, members, warnings, redactor, verify, ...ran, floatingWarnings };
|
|
308
307
|
}
|
|
309
308
|
/** The tag `release.tag` gives `label` in the member at `dir`, or null when it can't be told. */
|
|
309
|
+
/**
|
|
310
|
+
* The environment a member's targets run with (#5216): for a member that
|
|
311
|
+
* declares `release.images`, `CHANT_RELEASE_DIGESTS` names a file of the
|
|
312
|
+
* digests its release records, as `chant release images` writes it for one
|
|
313
|
+
* release, so a package it packs pins its own images. Other members get the
|
|
314
|
+
* environment as it is.
|
|
315
|
+
*/
|
|
316
|
+
export async function memberDigestsEnv(dir, release, env) {
|
|
317
|
+
const { loadChantConfig } = await import("../config.js");
|
|
318
|
+
let images;
|
|
319
|
+
try {
|
|
320
|
+
images = (await loadChantConfig(dir)).config.release?.images ?? [];
|
|
321
|
+
}
|
|
322
|
+
catch {
|
|
323
|
+
return env;
|
|
324
|
+
}
|
|
325
|
+
if (images.length === 0)
|
|
326
|
+
return env;
|
|
327
|
+
const { releaseImageDigests, writeReleaseDigests, RELEASE_DIGESTS_ENV } = await import("../lifecycle/release-images.js");
|
|
328
|
+
const { mkdtempSync } = await import("node:fs");
|
|
329
|
+
const { tmpdir } = await import("node:os");
|
|
330
|
+
const { join } = await import("node:path");
|
|
331
|
+
const file = join(mkdtempSync(join(tmpdir(), "chant-train-digests-")), "release-digests.json");
|
|
332
|
+
writeReleaseDigests(file, releaseImageDigests(release, images.map((i) => i.name)));
|
|
333
|
+
return { ...env, [RELEASE_DIGESTS_ENV]: file };
|
|
334
|
+
}
|
|
310
335
|
async function pinnedReleaseTag(dir, label) {
|
|
311
336
|
try {
|
|
312
337
|
const { memberTags, renderReleaseTag } = await import("../lifecycle/release-tag.js");
|
|
@@ -500,7 +525,7 @@ export async function runTrainPublish(ctx, words) {
|
|
|
500
525
|
cwd,
|
|
501
526
|
env,
|
|
502
527
|
...(ref !== undefined ? { train: ref } : {}),
|
|
503
|
-
yes: args.yes === true,
|
|
528
|
+
yes: args.yes === true && args.dryRun !== true,
|
|
504
529
|
allowUnsigned: args.allowUnsigned === true,
|
|
505
530
|
requireProvenance: args.requireProvenance === true,
|
|
506
531
|
say: (line) => (json ? undefined : console.error(line)),
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The shell lines a train command runs for its user: `release.train.check`
|
|
3
|
+
* in `train cut`, and the builds of `train prepare`. Their stdout goes to
|
|
4
|
+
* this process's stderr, as `release.verify`'s does, so stdout carries only
|
|
5
|
+
* what the command prints itself, and under `--json` that is one JSON
|
|
6
|
+
* document a step can parse.
|
|
7
|
+
*/
|
|
8
|
+
import { spawn } from "node:child_process";
|
|
9
|
+
/** Runs `line` with `sh -c` and returns its exit code; its stdout and stderr both reach this process's stderr. */
|
|
10
|
+
export function runToStderr(line, o) {
|
|
11
|
+
return new Promise((done) => {
|
|
12
|
+
const child = spawn("sh", ["-c", line], { cwd: o.cwd, env: o.env ?? process.env, stdio: ["ignore", "pipe", "inherit"] });
|
|
13
|
+
child.stdout.on("data", (chunk) => process.stderr.write(chunk));
|
|
14
|
+
child.on("error", () => done(1));
|
|
15
|
+
child.on("close", (code) => done(code ?? 1));
|
|
16
|
+
});
|
|
17
|
+
}
|
|
@@ -16,15 +16,11 @@
|
|
|
16
16
|
* Kept apart from ./check-evidence.ts so `pr-post` reads the note file
|
|
17
17
|
* without loading the signer.
|
|
18
18
|
*/
|
|
19
|
-
|
|
20
|
-
|
|
19
|
+
import { CHECK_EVIDENCE_KEY_ENV, RUNNER_IDENTITY_ENV } from "../../ci-evidence-claims.js";
|
|
20
|
+
/** The runner key and runner identity variables live in ../../ci-evidence-claims.ts (#5219). */
|
|
21
|
+
export { CHECK_EVIDENCE_KEY_ENV, RUNNER_IDENTITY_ENV };
|
|
21
22
|
/** The variable a developer's or an agent's local evidence key is read from, as PEM (#4868). A check hook never sees it. */
|
|
22
23
|
export declare const LOCAL_EVIDENCE_KEY_ENV = "CHANT_LOCAL_EVIDENCE_KEY";
|
|
23
|
-
/**
|
|
24
|
-
* The variable a generated job sets to `oidc` when it signs keyless from
|
|
25
|
-
* its OIDC identity (#4869) instead of with a runner key.
|
|
26
|
-
*/
|
|
27
|
-
export declare const RUNNER_IDENTITY_ENV = "CHANT_RUNNER_IDENTITY";
|
|
28
24
|
/** The GitLab `id_tokens` variable a keyless signing job's token comes in (#4869), with the signing audience. */
|
|
29
25
|
export declare const SIGNING_ID_TOKEN_VAR = "CHANT_ID_TOKEN_SIGSTORE";
|
|
30
26
|
/** The file the signing step writes beside the plan report, which `pr-post` reads. */
|
|
@@ -18,15 +18,11 @@
|
|
|
18
18
|
*/
|
|
19
19
|
import { existsSync, readFileSync } from "node:fs";
|
|
20
20
|
import { join } from "node:path";
|
|
21
|
-
|
|
22
|
-
|
|
21
|
+
import { CHECK_EVIDENCE_KEY_ENV, RUNNER_IDENTITY_ENV } from "../../ci-evidence-claims.js";
|
|
22
|
+
/** The runner key and runner identity variables live in ../../ci-evidence-claims.ts (#5219). */
|
|
23
|
+
export { CHECK_EVIDENCE_KEY_ENV, RUNNER_IDENTITY_ENV };
|
|
23
24
|
/** The variable a developer's or an agent's local evidence key is read from, as PEM (#4868). A check hook never sees it. */
|
|
24
25
|
export const LOCAL_EVIDENCE_KEY_ENV = "CHANT_LOCAL_EVIDENCE_KEY";
|
|
25
|
-
/**
|
|
26
|
-
* The variable a generated job sets to `oidc` when it signs keyless from
|
|
27
|
-
* its OIDC identity (#4869) instead of with a runner key.
|
|
28
|
-
*/
|
|
29
|
-
export const RUNNER_IDENTITY_ENV = "CHANT_RUNNER_IDENTITY";
|
|
30
26
|
/** The GitLab `id_tokens` variable a keyless signing job's token comes in (#4869), with the signing audience. */
|
|
31
27
|
export const SIGNING_ID_TOKEN_VAR = "CHANT_ID_TOKEN_SIGSTORE";
|
|
32
28
|
/** The file the signing step writes beside the plan report, which `pr-post` reads. */
|
package/package.json
CHANGED