@intentius/chant 0.124.100 → 0.124.101
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/action-pins.d.ts +2 -0
- package/dist/action-pins.js +3 -0
- package/dist/ci-detect.d.ts +13 -0
- package/dist/ci-detect.js +12 -0
- package/dist/ci-system.d.ts +66 -0
- package/dist/ci-system.js +61 -0
- package/dist/cli/handlers/build.js +27 -0
- package/dist/cli/handlers/release-doctor.d.ts +12 -0
- package/dist/cli/handlers/release-doctor.js +118 -0
- package/dist/cli/handlers/release-init.d.ts +10 -0
- package/dist/cli/handlers/release-init.js +342 -0
- package/dist/cli/handlers/release.d.ts +42 -1
- package/dist/cli/handlers/release.js +656 -31
- package/dist/cli/handlers/run-generate.js +11 -0
- package/dist/cli/main.d.ts +2 -0
- package/dist/cli/main.js +44 -101
- package/dist/cli/parse-args.js +48 -0
- package/dist/cli/registry.d.ts +16 -0
- package/dist/cli/release-commands/artifacts.d.ts +3 -0
- package/dist/cli/release-commands/artifacts.js +14 -0
- package/dist/cli/release-commands/candidates.d.ts +3 -0
- package/dist/cli/release-commands/candidates.js +16 -0
- package/dist/cli/release-commands/changed.d.ts +3 -0
- package/dist/cli/release-commands/changed.js +14 -0
- package/dist/cli/release-commands/compose.d.ts +3 -0
- package/dist/cli/release-commands/compose.js +16 -0
- package/dist/cli/release-commands/cut.d.ts +3 -0
- package/dist/cli/release-commands/cut.js +49 -0
- package/dist/cli/release-commands/doctor.d.ts +3 -0
- package/dist/cli/release-commands/doctor.js +14 -0
- package/dist/cli/release-commands/export.d.ts +3 -0
- package/dist/cli/release-commands/export.js +12 -0
- package/dist/cli/release-commands/images.d.ts +3 -0
- package/dist/cli/release-commands/images.js +13 -0
- package/dist/cli/release-commands/index.d.ts +8 -0
- package/dist/cli/release-commands/index.js +52 -0
- package/dist/cli/release-commands/init.d.ts +3 -0
- package/dist/cli/release-commands/init.js +16 -0
- package/dist/cli/release-commands/list.d.ts +3 -0
- package/dist/cli/release-commands/list.js +10 -0
- package/dist/cli/release-commands/next.d.ts +3 -0
- package/dist/cli/release-commands/next.js +13 -0
- package/dist/cli/release-commands/publish.d.ts +3 -0
- package/dist/cli/release-commands/publish.js +22 -0
- package/dist/cli/release-commands/stamp.d.ts +3 -0
- package/dist/cli/release-commands/stamp.js +15 -0
- package/dist/cli/release-commands/status.d.ts +3 -0
- package/dist/cli/release-commands/status.js +17 -0
- package/dist/cli/release-commands/tag.d.ts +3 -0
- package/dist/cli/release-commands/tag.js +12 -0
- package/dist/cli/release-commands/types.d.ts +20 -0
- package/dist/cli/release-commands/types.js +1 -0
- package/dist/cli/release-commands/verify.d.ts +3 -0
- package/dist/cli/release-commands/verify.js +15 -0
- package/dist/cli/release-commands/workflow.d.ts +3 -0
- package/dist/cli/release-commands/workflow.js +13 -0
- package/dist/components/cli-support.d.ts +1 -1
- package/dist/components/cli-support.js +1 -1
- package/dist/config-environments.d.ts +8 -1
- package/dist/config-environments.js +2 -0
- package/dist/config.d.ts +294 -9
- package/dist/config.js +100 -5
- package/dist/floor-table.data.js +15 -1
- package/dist/forge-remote.d.ts +13 -0
- package/dist/forge-remote.js +15 -0
- package/dist/lexicon.d.ts +41 -2
- package/dist/lifecycle/__fixtures__/publish-fakes.d.ts +62 -0
- package/dist/lifecycle/__fixtures__/publish-fakes.js +270 -3
- package/dist/lifecycle/publish-attachments.d.ts +2 -1
- package/dist/lifecycle/publish-attachments.js +19 -2
- package/dist/lifecycle/publish-cargo.d.ts +99 -0
- package/dist/lifecycle/publish-cargo.js +412 -0
- package/dist/lifecycle/publish-credentials.d.ts +1 -1
- package/dist/lifecycle/publish-credentials.js +8 -0
- package/dist/lifecycle/publish-declaration.d.ts +199 -4
- package/dist/lifecycle/publish-declaration.js +200 -9
- package/dist/lifecycle/publish-forge.d.ts +45 -2
- package/dist/lifecycle/publish-forge.js +434 -34
- package/dist/lifecycle/publish-git-ssh.d.ts +15 -0
- package/dist/lifecycle/publish-git-ssh.js +30 -4
- package/dist/lifecycle/publish-github.d.ts +40 -2
- package/dist/lifecycle/publish-github.js +100 -3
- package/dist/lifecycle/publish-homebrew.d.ts +7 -9
- package/dist/lifecycle/publish-homebrew.js +34 -197
- package/dist/lifecycle/publish-index.d.ts +141 -0
- package/dist/lifecycle/publish-index.js +719 -0
- package/dist/lifecycle/publish-marketplace.js +77 -0
- package/dist/lifecycle/publish-mcp-registry.d.ts +66 -0
- package/dist/lifecycle/publish-mcp-registry.js +306 -0
- package/dist/lifecycle/publish-npm.js +165 -2
- package/dist/lifecycle/publish-oci.d.ts +34 -1
- package/dist/lifecycle/publish-oci.js +246 -7
- package/dist/lifecycle/publish-pypi.d.ts +136 -0
- package/dist/lifecycle/publish-pypi.js +657 -0
- package/dist/lifecycle/publish-record.d.ts +6 -3
- package/dist/lifecycle/publish-record.js +6 -3
- package/dist/lifecycle/publish-signing.d.ts +147 -0
- package/dist/lifecycle/publish-signing.js +257 -0
- package/dist/lifecycle/publish-targets.d.ts +27 -1
- package/dist/lifecycle/publish-targets.js +80 -0
- package/dist/lifecycle/publish-tauri.js +43 -0
- package/dist/lifecycle/publish-train-names.d.ts +54 -0
- package/dist/lifecycle/publish-train-names.js +118 -0
- package/dist/lifecycle/publish-verify.d.ts +121 -0
- package/dist/lifecycle/publish-verify.js +130 -0
- package/dist/lifecycle/query.js +8 -0
- package/dist/lifecycle/release-artifacts.d.ts +212 -0
- package/dist/lifecycle/release-artifacts.js +571 -0
- package/dist/lifecycle/release-changelog.d.ts +13 -1
- package/dist/lifecycle/release-changelog.js +35 -2
- package/dist/lifecycle/release-cut.d.ts +58 -3
- package/dist/lifecycle/release-cut.js +132 -34
- package/dist/lifecycle/release-doctor.d.ts +113 -0
- package/dist/lifecycle/release-doctor.js +996 -0
- package/dist/lifecycle/release-green.d.ts +86 -0
- package/dist/lifecycle/release-green.js +286 -0
- package/dist/lifecycle/release-init.d.ts +255 -0
- package/dist/lifecycle/release-init.js +859 -0
- package/dist/lifecycle/release-intents.d.ts +73 -0
- package/dist/lifecycle/release-intents.js +128 -0
- package/dist/lifecycle/release-next.d.ts +111 -0
- package/dist/lifecycle/release-next.js +252 -0
- package/dist/lifecycle/release-prerelease.d.ts +19 -0
- package/dist/lifecycle/release-prerelease.js +30 -0
- package/dist/lifecycle/release-publish.d.ts +256 -10
- package/dist/lifecycle/release-publish.js +246 -34
- package/dist/lifecycle/release-status-change.d.ts +226 -0
- package/dist/lifecycle/release-status-change.js +478 -0
- package/dist/lifecycle/release-status.d.ts +11 -0
- package/dist/lifecycle/release-status.js +1 -1
- package/dist/lifecycle/release-store.d.ts +73 -2
- package/dist/lifecycle/release-store.js +32 -1
- package/dist/lifecycle/release-tag.d.ts +142 -0
- package/dist/lifecycle/release-tag.js +323 -0
- package/dist/lifecycle/release-verify.d.ts +73 -1
- package/dist/lifecycle/release-verify.js +117 -2
- package/dist/lifecycle/release-version-formats.d.ts +73 -0
- package/dist/lifecycle/release-version-formats.js +570 -0
- package/dist/lifecycle/release-version.d.ts +58 -10
- package/dist/lifecycle/release-version.js +164 -36
- package/dist/lifecycle/release-workstation.d.ts +3 -2
- package/dist/lifecycle/release-workstation.js +3 -2
- package/dist/op/generate-pipeline.js +1 -1
- package/dist/pr-forge-base.js +4 -2
- package/dist/pr-forge.d.ts +20 -2
- package/dist/pr-forge.js +46 -10
- package/dist/release-floors.d.ts +8 -1
- package/dist/release-floors.js +9 -2
- package/dist/tool-pins.d.ts +38 -0
- package/dist/tool-pins.js +54 -0
- package/dist/wave-runtime.mjs +337 -334
- package/dist/workspace/ci-forge.d.ts +17 -0
- package/dist/workspace/ci-forge.js +17 -0
- package/dist/workspace/ci-init.js +1 -1
- package/dist/workspace/composites.schema.json +1 -0
- package/dist/workspace/declaration.d.ts +8 -0
- package/dist/workspace/declaration.js +12 -0
- package/dist/workspace/declaration.schema.json +8 -0
- package/dist/workspace/environments.d.ts +2 -0
- package/dist/workspace/environments.js +1 -1
- package/dist/workspace/identity-gate-rule.d.ts +61 -5
- package/dist/workspace/identity-gate-rule.js +81 -12
- package/dist/workspace/member-pipeline.d.ts +2 -1
- package/dist/workspace/member-pipeline.js +5 -2
- package/dist/workspace/reason-codes.d.ts +2 -0
- package/dist/workspace/reason-codes.js +3 -1
- package/dist/workspace/release-changed.d.ts +75 -4
- package/dist/workspace/release-changed.js +205 -34
- package/dist/workspace/release-changed.schema.json +20 -2
- package/dist/workspace/release-steps/artifacts.d.ts +7 -0
- package/dist/workspace/release-steps/artifacts.js +45 -0
- package/dist/workspace/release-steps/builds.d.ts +12 -0
- package/dist/workspace/release-steps/builds.js +38 -0
- package/dist/workspace/release-steps/doctor.d.ts +8 -0
- package/dist/workspace/release-steps/doctor.js +14 -0
- package/dist/workspace/release-steps/goreleaser.d.ts +16 -0
- package/dist/workspace/release-steps/goreleaser.js +36 -0
- package/dist/workspace/release-steps/green.d.ts +3 -0
- package/dist/workspace/release-steps/green.js +6 -0
- package/dist/workspace/release-steps/images.d.ts +22 -0
- package/dist/workspace/release-steps/images.js +59 -0
- package/dist/workspace/release-steps/index.d.ts +9 -0
- package/dist/workspace/release-steps/index.js +46 -0
- package/dist/workspace/release-steps/pypi.d.ts +15 -0
- package/dist/workspace/release-steps/pypi.js +21 -0
- package/dist/workspace/release-steps/qemu.d.ts +21 -0
- package/dist/workspace/release-steps/qemu.js +35 -0
- package/dist/workspace/release-steps/signing.d.ts +18 -0
- package/dist/workspace/release-steps/signing.js +30 -0
- package/dist/workspace/release-steps/stamp.d.ts +3 -0
- package/dist/workspace/release-steps/stamp.js +4 -0
- package/dist/workspace/release-steps/targets.d.ts +31 -0
- package/dist/workspace/release-steps/targets.js +40 -0
- package/dist/workspace/release-steps/types.d.ts +104 -0
- package/dist/workspace/release-steps/types.js +2 -0
- package/dist/workspace/release-steps/verify.d.ts +3 -0
- package/dist/workspace/release-steps/verify.js +4 -0
- package/dist/workspace/release-toolchains.d.ts +59 -0
- package/dist/workspace/release-toolchains.js +133 -0
- package/dist/workspace/release-train-workflow.d.ts +29 -0
- package/dist/workspace/release-train-workflow.js +85 -0
- package/dist/workspace/release-train.d.ts +3 -1
- package/dist/workspace/release-train.js +20 -3
- package/dist/workspace/release-workflow.d.ts +160 -61
- package/dist/workspace/release-workflow.js +539 -193
- package/dist/workspace/releases.schema.json +70 -1
- package/dist/workspace/search-contract.d.ts +1 -1
- package/dist/workspace/security.js +9 -2
- package/dist/workspace/train-cut.d.ts +182 -0
- package/dist/workspace/train-cut.js +482 -0
- package/dist/workspace/train-prepare.d.ts +61 -0
- package/dist/workspace/train-prepare.js +267 -0
- package/dist/workspace/train-publish.d.ts +177 -0
- package/dist/workspace/train-publish.js +575 -0
- package/dist/workspace/train-range-labels.d.ts +33 -0
- package/dist/workspace/train-range-labels.js +109 -0
- package/dist/workspace/trust/seal.d.ts +13 -3
- package/dist/workspace/trust/seal.js +14 -4
- package/dist/workspace/work-cli.d.ts +3 -2
- package/dist/workspace/work-cli.js +3 -2
- package/dist/workspace/workspace-ledger.d.ts +14 -1
- package/dist/workspace/workspace-ledger.js +33 -7
- package/package.json +1 -1
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The labels a release train gives workspace packages (#5155), for
|
|
3
|
+
* `release.version.ranges: "train"`: `chant release stamp <label> --train
|
|
4
|
+
* <id|digest>` rewrites each workspace dependency's range to `^` and the
|
|
5
|
+
* label the train pins for the member that owns that package.
|
|
6
|
+
*
|
|
7
|
+
* A package belongs to the member whose `release.version.packages` names its
|
|
8
|
+
* directory. A member that declares no `release.version` owns no package a
|
|
9
|
+
* range can follow, so a dependency on it keeps its committed range.
|
|
10
|
+
*/
|
|
11
|
+
import { existsSync, readFileSync } from "node:fs";
|
|
12
|
+
import { join, posix, resolve } from "node:path";
|
|
13
|
+
import { readDeclaration } from "./declaration.js";
|
|
14
|
+
import { readReleaseTrains, findTrain } from "./release-train.js";
|
|
15
|
+
import { locateWorkspace } from "./which-chant.js";
|
|
16
|
+
/** A train problem with a stable code, shown as the stamp's refusal. */
|
|
17
|
+
export class TrainLabelsError extends Error {
|
|
18
|
+
constructor(code, message, fix) {
|
|
19
|
+
super(message);
|
|
20
|
+
this.code = code;
|
|
21
|
+
this.fix = fix;
|
|
22
|
+
this.name = "TrainLabelsError";
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
async function environmentsOf(cwd) {
|
|
26
|
+
const { loadChantConfig } = await import("../config.js");
|
|
27
|
+
return (await loadChantConfig(cwd)).config.environments ?? [];
|
|
28
|
+
}
|
|
29
|
+
/** Every train recorded for the environments `cwd`'s config declares, and for the workspace root's `release.train` (#5154), oldest first. */
|
|
30
|
+
async function trainsOf(cwd) {
|
|
31
|
+
const root = locateWorkspace(cwd).rootOnDisk;
|
|
32
|
+
const trains = [];
|
|
33
|
+
const { loadChantConfig } = await import("../config.js");
|
|
34
|
+
const rootEnv = await loadChantConfig(root)
|
|
35
|
+
.then((c) => c.config.release?.train?.env)
|
|
36
|
+
.catch(() => undefined);
|
|
37
|
+
for (const env of new Set([...(await environmentsOf(cwd)), ...(rootEnv ? [rootEnv] : [])]))
|
|
38
|
+
trains.push(...(await readReleaseTrains(root, env)).records);
|
|
39
|
+
return { trains, rootOnDisk: root };
|
|
40
|
+
}
|
|
41
|
+
/** Package name to the train's label for the member that owns it. */
|
|
42
|
+
export async function trainPackageLabels(train, rootOnDisk) {
|
|
43
|
+
return labelsOf(train, rootOnDisk);
|
|
44
|
+
}
|
|
45
|
+
async function labelsOf(train, rootOnDisk) {
|
|
46
|
+
const located = locateWorkspace(rootOnDisk);
|
|
47
|
+
const declaration = readDeclaration(located.tree, "", { rootChant: true });
|
|
48
|
+
const { loadChantConfig } = await import("../config.js");
|
|
49
|
+
const labels = {};
|
|
50
|
+
for (const pinned of train.members) {
|
|
51
|
+
const member = declaration.members.find((m) => m.name === pinned.member && m.kind === "chant");
|
|
52
|
+
if (!member)
|
|
53
|
+
continue;
|
|
54
|
+
const dir = resolve(rootOnDisk, member.dir);
|
|
55
|
+
const packages = (await loadChantConfig(dir)).config.release?.version?.packages ?? [];
|
|
56
|
+
for (const p of packages) {
|
|
57
|
+
const file = join(dir, posix.normalize(p.split("\\").join("/")), "package.json");
|
|
58
|
+
if (!existsSync(file))
|
|
59
|
+
continue;
|
|
60
|
+
const name = JSON.parse(readFileSync(file, "utf-8")).name;
|
|
61
|
+
if (typeof name === "string")
|
|
62
|
+
labels[name] = pinned.label;
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
return labels;
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* The labels train `ref` (an id or a digest) gives workspace packages, for
|
|
69
|
+
* the release of `own` (the package names the member stamps) at `label`.
|
|
70
|
+
* Refuses a train that does not exist and one that pins none of the member's
|
|
71
|
+
* packages at the release's label.
|
|
72
|
+
*/
|
|
73
|
+
export async function trainLabels(cwd, ref, own, label) {
|
|
74
|
+
const { trains, rootOnDisk } = await trainsOf(cwd);
|
|
75
|
+
const train = findTrain(trains, ref);
|
|
76
|
+
if (!train)
|
|
77
|
+
throw new TrainLabelsError("release-train-unknown", `no release train ${ref} is recorded for this member's environments`, "List them with chant workspace train list <env> --json.");
|
|
78
|
+
const labels = await labelsOf(train, rootOnDisk);
|
|
79
|
+
const pinned = own.filter((n) => n in labels);
|
|
80
|
+
if (pinned.length === 0)
|
|
81
|
+
throw new TrainLabelsError("release-train-not-pinned", `train ${ref} pins no release of this member's packages`, "Stamp from a train that pins this member: the member's release.version.packages name its packages.");
|
|
82
|
+
const wrong = pinned.find((n) => labels[n] !== label);
|
|
83
|
+
if (wrong !== undefined)
|
|
84
|
+
throw new TrainLabelsError("release-train-not-pinned", `train ${ref} pins ${wrong} at ${labels[wrong] ?? "no release"}, not ${label}`, `Stamp the label the train pins.`);
|
|
85
|
+
return labels;
|
|
86
|
+
}
|
|
87
|
+
/**
|
|
88
|
+
* The label tables of every train that pins a release at `label`, newest
|
|
89
|
+
* first, for the publish's check that a stamped tree is the release's. A
|
|
90
|
+
* train that cannot be read is left out.
|
|
91
|
+
*/
|
|
92
|
+
export async function trainLabelCandidates(cwd, label) {
|
|
93
|
+
try {
|
|
94
|
+
const { trains, rootOnDisk } = await trainsOf(cwd);
|
|
95
|
+
const out = [];
|
|
96
|
+
for (const t of [...trains].reverse().filter((x) => x.members.some((m) => m.label === label))) {
|
|
97
|
+
try {
|
|
98
|
+
out.push(await labelsOf(t, rootOnDisk));
|
|
99
|
+
}
|
|
100
|
+
catch {
|
|
101
|
+
// Left out.
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
return out;
|
|
105
|
+
}
|
|
106
|
+
catch {
|
|
107
|
+
return [];
|
|
108
|
+
}
|
|
109
|
+
}
|
|
@@ -24,6 +24,7 @@
|
|
|
24
24
|
import type { SealCode } from "../records.js";
|
|
25
25
|
import { type TrustPolicy } from "./policy.js";
|
|
26
26
|
import { type SealedGateApproval } from "../../lifecycle/gate-seal.js";
|
|
27
|
+
import { type SignedReleaseCut } from "../identity-gate-rule.js";
|
|
27
28
|
export { GATE_SEAL_NAMESPACE, gateSealPayload, gateSealVersion, sealedFieldsOf, type SealedGateApproval } from "../../lifecycle/gate-seal.js";
|
|
28
29
|
/** The ssh signature namespace of a verdict seal. */
|
|
29
30
|
export declare const REVIEW_SEAL_NAMESPACE = "chant-review";
|
|
@@ -139,12 +140,21 @@ export declare function sealRecord(keyFile: string, r: {
|
|
|
139
140
|
export declare function sealGateApproval(keyFile: string, a: SealedGateApproval): VerdictSeal;
|
|
140
141
|
/**
|
|
141
142
|
* Sign a release cut (#4031) with the key in `keyFile`, over
|
|
142
|
-
* `
|
|
143
|
-
*
|
|
143
|
+
* `releaseGateSealPayload` in the `chant-release` namespace: the release
|
|
144
|
+
* digest, label, actor and time, and the green-gate record the cut line
|
|
145
|
+
* carries (#5177). The cut line keeps the armored signature and
|
|
146
|
+
* `sealVersion: 2`; its actor is the signer. Throws a {@link SealError}.
|
|
144
147
|
*/
|
|
145
|
-
export declare function sealReleaseCut(keyFile: string, cut:
|
|
148
|
+
export declare function sealReleaseCut(keyFile: string, cut: Omit<SignedReleaseCut, "signature" | "sealVersion">): VerdictSeal;
|
|
149
|
+
/**
|
|
150
|
+
* Sign a release status change (#5163) with the key in `keyFile`, over
|
|
151
|
+
* `releaseStatusSealPayload` in the `chant-release` namespace. Throws a
|
|
152
|
+
* {@link SealError}.
|
|
153
|
+
*/
|
|
154
|
+
export declare function sealReleaseStatus(keyFile: string, s: {
|
|
146
155
|
releaseDigest: string;
|
|
147
156
|
label: string | null;
|
|
148
157
|
actor: string;
|
|
149
158
|
timestamp: string;
|
|
159
|
+
status: string;
|
|
150
160
|
}): VerdictSeal;
|
|
@@ -27,7 +27,7 @@ import { homedir, tmpdir } from "node:os";
|
|
|
27
27
|
import { join, resolve } from "node:path";
|
|
28
28
|
import { sshKeygen, verifySshSignature } from "./ssh-commit.js";
|
|
29
29
|
import { checkGateSignature, GATE_SEAL_NAMESPACE, gateSealPayload, sshSignatureKey, verifySshSignatureWith, WEBAUTHN_SEAL_KIND } from "../../lifecycle/gate-seal.js";
|
|
30
|
-
import { RELEASE_SEAL_NAMESPACE,
|
|
30
|
+
import { RELEASE_SEAL_NAMESPACE, releaseGateSealPayload, releaseStatusSealPayload } from "../identity-gate-rule.js";
|
|
31
31
|
export { GATE_SEAL_NAMESPACE, gateSealPayload, gateSealVersion, sealedFieldsOf } from "../../lifecycle/gate-seal.js";
|
|
32
32
|
/** The ssh signature namespace of a verdict seal. */
|
|
33
33
|
export const REVIEW_SEAL_NAMESPACE = "chant-review";
|
|
@@ -282,11 +282,21 @@ export function sealGateApproval(keyFile, a) {
|
|
|
282
282
|
}
|
|
283
283
|
/**
|
|
284
284
|
* Sign a release cut (#4031) with the key in `keyFile`, over
|
|
285
|
-
* `
|
|
286
|
-
*
|
|
285
|
+
* `releaseGateSealPayload` in the `chant-release` namespace: the release
|
|
286
|
+
* digest, label, actor and time, and the green-gate record the cut line
|
|
287
|
+
* carries (#5177). The cut line keeps the armored signature and
|
|
288
|
+
* `sealVersion: 2`; its actor is the signer. Throws a {@link SealError}.
|
|
287
289
|
*/
|
|
288
290
|
export function sealReleaseCut(keyFile, cut) {
|
|
289
|
-
return sign(keyFile,
|
|
291
|
+
return sign(keyFile, releaseGateSealPayload(cut), RELEASE_SEAL_NAMESPACE, cut.actor);
|
|
292
|
+
}
|
|
293
|
+
/**
|
|
294
|
+
* Sign a release status change (#5163) with the key in `keyFile`, over
|
|
295
|
+
* `releaseStatusSealPayload` in the `chant-release` namespace. Throws a
|
|
296
|
+
* {@link SealError}.
|
|
297
|
+
*/
|
|
298
|
+
export function sealReleaseStatus(keyFile, s) {
|
|
299
|
+
return sign(keyFile, releaseStatusSealPayload(s), RELEASE_SEAL_NAMESPACE, s.actor);
|
|
290
300
|
}
|
|
291
301
|
function sign(keyFile, payload, namespace, signer) {
|
|
292
302
|
const signed = sshKeygen(["-q", "-Y", "sign", "-n", namespace, "-f", keyFile], payload);
|
|
@@ -19,8 +19,9 @@
|
|
|
19
19
|
* (#2524 D7), whatever directory the command runs in: `records --json`
|
|
20
20
|
* reports it from there too.
|
|
21
21
|
*
|
|
22
|
-
* Exit codes: 0 when the lease was written,
|
|
23
|
-
* holds it
|
|
22
|
+
* Exit codes (#4585): 0 when the lease was written, 5 when it was refused
|
|
23
|
+
* because another worker holds it or another writer or clone got there first,
|
|
24
|
+
* 1 when nobody holds it (it expired, or the token is stale) or the command
|
|
24
25
|
* could not run (usage, an unreadable kind, an unknown item).
|
|
25
26
|
*/
|
|
26
27
|
import type { CommandContext } from "../cli/registry.js";
|
|
@@ -19,8 +19,9 @@
|
|
|
19
19
|
* (#2524 D7), whatever directory the command runs in: `records --json`
|
|
20
20
|
* reports it from there too.
|
|
21
21
|
*
|
|
22
|
-
* Exit codes: 0 when the lease was written,
|
|
23
|
-
* holds it
|
|
22
|
+
* Exit codes (#4585): 0 when the lease was written, 5 when it was refused
|
|
23
|
+
* because another worker holds it or another writer or clone got there first,
|
|
24
|
+
* 1 when nobody holds it (it expired, or the token is stale) or the command
|
|
24
25
|
* could not run (usage, an unreadable kind, an unknown item).
|
|
25
26
|
*/
|
|
26
27
|
import { dirname, relative } from "node:path";
|
|
@@ -16,15 +16,28 @@
|
|
|
16
16
|
* `chant` member, with a digest over those releases (`./release-train.ts`).
|
|
17
17
|
* A train's promote is a run in `<env>/runs.jsonl` that names the train.
|
|
18
18
|
*
|
|
19
|
+
* A nested workspace (a member of kind `workspace`) keeps its own workspace
|
|
20
|
+
* ledger inside the outer member's, as its members' ledgers are: the nested
|
|
21
|
+
* workspace in the outer member `npm` writes under
|
|
22
|
+
* `_members/npm/_members/_workspace/`. Two nested workspaces, and a nested
|
|
23
|
+
* one and the outer one, never share a file, whatever their environments
|
|
24
|
+
* are called (#5136).
|
|
25
|
+
*
|
|
19
26
|
* A malformed line is skipped and counted, never thrown on.
|
|
20
27
|
*/
|
|
21
28
|
/** The reserved member name the workspace's own ledger sits under. */
|
|
22
29
|
export declare const WORKSPACE_LEDGER_NAME = "_workspace";
|
|
23
|
-
/** The branch prefix of
|
|
30
|
+
/** The branch prefix of a top-level workspace's ledger; a nested one's sits under its outer member's prefix ({@link workspaceLedgerPrefix}). */
|
|
24
31
|
export declare const WORKSPACE_LEDGER_PREFIX = "_members/_workspace/";
|
|
25
32
|
/** The environment directory a run with no `--env` records under, as a member Op run does. */
|
|
26
33
|
export declare const DEFAULT_WORKSPACE_ENV = "local";
|
|
27
34
|
export declare const WORKSPACE_GATES_DIR = "_gates";
|
|
35
|
+
/**
|
|
36
|
+
* The branch prefix of the ledger of the workspace holding `cwd`:
|
|
37
|
+
* {@link WORKSPACE_LEDGER_PREFIX} for a top-level workspace, and inside the
|
|
38
|
+
* outer member's ledger for a nested one (#5136).
|
|
39
|
+
*/
|
|
40
|
+
export declare function workspaceLedgerPrefix(cwd: string): Promise<string>;
|
|
28
41
|
/** Append one line to `<dir>/<file>` in the workspace ledger. Returns the ledger commit. */
|
|
29
42
|
export declare function appendWorkspaceLine(cwd: string, dir: string, file: string, value: unknown, message: string): Promise<string>;
|
|
30
43
|
/** Read every line of `<dir>/<file>` that `accept` takes, oldest first. */
|
|
@@ -16,22 +16,47 @@
|
|
|
16
16
|
* `chant` member, with a digest over those releases (`./release-train.ts`).
|
|
17
17
|
* A train's promote is a run in `<env>/runs.jsonl` that names the train.
|
|
18
18
|
*
|
|
19
|
+
* A nested workspace (a member of kind `workspace`) keeps its own workspace
|
|
20
|
+
* ledger inside the outer member's, as its members' ledgers are: the nested
|
|
21
|
+
* workspace in the outer member `npm` writes under
|
|
22
|
+
* `_members/npm/_members/_workspace/`. Two nested workspaces, and a nested
|
|
23
|
+
* one and the outer one, never share a file, whatever their environments
|
|
24
|
+
* are called (#5136).
|
|
25
|
+
*
|
|
19
26
|
* A malformed line is skipped and counted, never thrown on.
|
|
20
27
|
*/
|
|
21
28
|
import { createHash } from "node:crypto";
|
|
29
|
+
import { existsSync } from "node:fs";
|
|
30
|
+
import { dirname, join } from "node:path";
|
|
22
31
|
import { readBlobBySha, readBlobFromPath, readPathSha, RefCASConflictError, writeBlobToPath } from "../lifecycle/git.js";
|
|
23
|
-
import { MEMBERS_DIR } from "../lifecycle/member-ledger.js";
|
|
32
|
+
import { MEMBERS_DIR, resolveMemberLedger } from "../lifecycle/member-ledger.js";
|
|
33
|
+
import { findWorkspaceRoot } from "../project-root.js";
|
|
24
34
|
import { sortedJsonReplacer } from "../utils.js";
|
|
25
35
|
/** The reserved member name the workspace's own ledger sits under. */
|
|
26
36
|
export const WORKSPACE_LEDGER_NAME = "_workspace";
|
|
27
|
-
/** The branch prefix of
|
|
37
|
+
/** The branch prefix of a top-level workspace's ledger; a nested one's sits under its outer member's prefix ({@link workspaceLedgerPrefix}). */
|
|
28
38
|
export const WORKSPACE_LEDGER_PREFIX = `${MEMBERS_DIR}/${WORKSPACE_LEDGER_NAME}/`;
|
|
29
39
|
/** The environment directory a run with no `--env` records under, as a member Op run does. */
|
|
30
40
|
export const DEFAULT_WORKSPACE_ENV = "local";
|
|
31
41
|
export const WORKSPACE_GATES_DIR = "_gates";
|
|
32
42
|
const APPEND_RETRY_ATTEMPTS = 5;
|
|
33
|
-
|
|
34
|
-
|
|
43
|
+
/**
|
|
44
|
+
* The branch prefix of the ledger of the workspace holding `cwd`:
|
|
45
|
+
* {@link WORKSPACE_LEDGER_PREFIX} for a top-level workspace, and inside the
|
|
46
|
+
* outer member's ledger for a nested one (#5136).
|
|
47
|
+
*/
|
|
48
|
+
export async function workspaceLedgerPrefix(cwd) {
|
|
49
|
+
const found = findWorkspaceRoot(cwd);
|
|
50
|
+
if (!found)
|
|
51
|
+
return WORKSPACE_LEDGER_PREFIX;
|
|
52
|
+
// A root at the git top, or with no workspace above it, is top-level: no declaration is read.
|
|
53
|
+
const parent = dirname(found.dir);
|
|
54
|
+
if (parent === found.dir || existsSync(join(found.dir, ".git")) || !findWorkspaceRoot(parent))
|
|
55
|
+
return WORKSPACE_LEDGER_PREFIX;
|
|
56
|
+
return `${(await resolveMemberLedger(found.dir)).prefix}${WORKSPACE_LEDGER_PREFIX}`;
|
|
57
|
+
}
|
|
58
|
+
async function at(cwd) {
|
|
59
|
+
return { cwd, ledgerPrefix: await workspaceLedgerPrefix(cwd) };
|
|
35
60
|
}
|
|
36
61
|
/** Append one line to `<dir>/<file>` in the workspace ledger. Returns the ledger commit. */
|
|
37
62
|
export async function appendWorkspaceLine(cwd, dir, file, value, message) {
|
|
@@ -39,10 +64,11 @@ export async function appendWorkspaceLine(cwd, dir, file, value, message) {
|
|
|
39
64
|
let lastErr;
|
|
40
65
|
for (let attempt = 1; attempt <= APPEND_RETRY_ATTEMPTS; attempt++) {
|
|
41
66
|
try {
|
|
42
|
-
const
|
|
67
|
+
const where = await at(cwd);
|
|
68
|
+
const priorSha = await readPathSha(dir, file, where);
|
|
43
69
|
const existing = priorSha ? await readBlobBySha(priorSha, { cwd }) : null;
|
|
44
70
|
const content = `${existing ? `${existing.replace(/\n$/, "")}\n` : ""}${json}\n`;
|
|
45
|
-
return await writeBlobToPath(dir, file, content, message, { ...
|
|
71
|
+
return await writeBlobToPath(dir, file, content, message, { ...where, expectPriorPathSha: priorSha });
|
|
46
72
|
}
|
|
47
73
|
catch (err) {
|
|
48
74
|
if (!(err instanceof RefCASConflictError))
|
|
@@ -54,7 +80,7 @@ export async function appendWorkspaceLine(cwd, dir, file, value, message) {
|
|
|
54
80
|
}
|
|
55
81
|
/** Read every line of `<dir>/<file>` that `accept` takes, oldest first. */
|
|
56
82
|
export async function readWorkspaceLines(cwd, dir, file, accept) {
|
|
57
|
-
const content = await readBlobFromPath(dir, file, at(cwd));
|
|
83
|
+
const content = await readBlobFromPath(dir, file, await at(cwd));
|
|
58
84
|
if (!content)
|
|
59
85
|
return { records: [], malformed: 0 };
|
|
60
86
|
const records = [];
|
package/package.json
CHANGED