@intentius/chant 0.124.100 → 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.
- 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-evidence-claims.d.ts +12 -0
- package/dist/ci-evidence-claims.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 +374 -0
- package/dist/cli/handlers/release.d.ts +43 -2
- package/dist/cli/handlers/release.js +667 -39
- 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 +50 -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 +19 -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 +15 -0
- 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 +642 -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/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-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 +369 -10
- package/dist/config.js +127 -7
- package/dist/deep-observation.js +9 -3
- package/dist/floor-table.data.js +21 -1
- package/dist/forge-remote.d.ts +13 -0
- package/dist/forge-remote.js +15 -0
- package/dist/lexicon.d.ts +45 -4
- 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.d.ts +62 -0
- package/dist/lifecycle/__fixtures__/publish-fakes.js +275 -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 +13 -0
- package/dist/lifecycle/publish-declaration.d.ts +322 -4
- package/dist/lifecycle/publish-declaration.js +340 -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-helm.d.ts +83 -0
- package/dist/lifecycle/publish-helm.js +452 -0
- 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-maven.d.ts +79 -0
- package/dist/lifecycle/publish-maven.js +364 -0
- package/dist/lifecycle/publish-mcp-registry.d.ts +66 -0
- package/dist/lifecycle/publish-mcp-registry.js +305 -0
- package/dist/lifecycle/publish-npm.d.ts +27 -1
- package/dist/lifecycle/publish-npm.js +216 -3
- package/dist/lifecycle/publish-nuget.d.ts +93 -0
- package/dist/lifecycle/publish-nuget.js +377 -0
- package/dist/lifecycle/publish-oci.d.ts +91 -2
- package/dist/lifecycle/publish-oci.js +247 -8
- 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 +138 -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-rubygems.d.ts +84 -0
- package/dist/lifecycle/publish-rubygems.js +366 -0
- package/dist/lifecycle/publish-signing.d.ts +147 -0
- package/dist/lifecycle/publish-signing.js +257 -0
- package/dist/lifecycle/publish-targets.d.ts +37 -1
- package/dist/lifecycle/publish-targets.js +102 -0
- package/dist/lifecycle/publish-tauri.js +43 -0
- package/dist/lifecycle/publish-train-names.d.ts +57 -0
- package/dist/lifecycle/publish-train-names.js +123 -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 +290 -0
- package/dist/lifecycle/release-artifacts.js +808 -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 +64 -4
- package/dist/lifecycle/release-cut.js +147 -34
- package/dist/lifecycle/release-doctor.d.ts +113 -0
- package/dist/lifecycle/release-doctor.js +1198 -0
- package/dist/lifecycle/release-green.d.ts +86 -0
- package/dist/lifecycle/release-green.js +286 -0
- 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 +275 -0
- package/dist/lifecycle/release-init.js +984 -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 +251 -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 +247 -35
- 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 +322 -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/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/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/sensitive-key.d.ts +12 -0
- package/dist/sensitive-key.js +52 -0
- package/dist/tool-pins.d.ts +40 -0
- package/dist/tool-pins.js +66 -0
- package/dist/ts-loader.d.ts +8 -0
- package/dist/ts-loader.js +19 -0
- package/dist/wave-runtime.mjs +345 -342
- 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/lexicon-outputs.d.ts +1 -1
- package/dist/workspace/lexicon-outputs.js +1 -1
- 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 +50 -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/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 +36 -0
- package/dist/workspace/release-train-workflow.js +121 -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 +183 -59
- package/dist/workspace/release-workflow.js +570 -201
- 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 +504 -0
- package/dist/workspace/train-prepare.d.ts +64 -0
- package/dist/workspace/train-prepare.js +313 -0
- package/dist/workspace/train-publish.d.ts +177 -0
- package/dist/workspace/train-publish.js +574 -0
- package/dist/workspace/train-range-labels.d.ts +33 -0
- package/dist/workspace/train-range-labels.js +109 -0
- 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/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
|
@@ -53,6 +53,26 @@ export const TEMPLATES_SUBDIR = "templates";
|
|
|
53
53
|
export const RELEASE_DIGEST_KIND = "release";
|
|
54
54
|
/** The first chant that writes and reads an artifact's `ref` (#4694). */
|
|
55
55
|
export const RELEASE_IMAGE_REF_FLOOR = "0.124.65";
|
|
56
|
+
/** The first chant that writes and reads a release's `publishes` (#5149). */
|
|
57
|
+
export const RELEASE_PUBLISHES_FLOOR = "0.124.101";
|
|
58
|
+
/** The first chant that signs a cut's green-gate record and writes and reads `sealVersion` (#5177). */
|
|
59
|
+
export const RELEASE_GATE_SEAL_FLOOR = "0.124.101";
|
|
60
|
+
/** Whether `v` reads as a list of {@link ReleaseCutIntent}. */
|
|
61
|
+
function isCutIntents(v) {
|
|
62
|
+
return (Array.isArray(v) &&
|
|
63
|
+
v.every((i) => i && typeof i === "object" && typeof i.path === "string" && typeof i.added === "string" && ["major", "minor", "patch"].includes(i.bump)));
|
|
64
|
+
}
|
|
65
|
+
/** Whether `v` reads as a {@link ReleaseCutGreen}. */
|
|
66
|
+
export function isCutGreen(v) {
|
|
67
|
+
if (!v || typeof v !== "object")
|
|
68
|
+
return false;
|
|
69
|
+
const g = v;
|
|
70
|
+
if (g.source === "chant")
|
|
71
|
+
return typeof g.tag === "string";
|
|
72
|
+
if (g.source === "forge-checks")
|
|
73
|
+
return typeof g.forge === "string" && Array.isArray(g.checks) && g.checks.every((c) => typeof c === "string");
|
|
74
|
+
return g.source === "none";
|
|
75
|
+
}
|
|
56
76
|
/** Whether `v` reads as a {@link ReleaseCutOverride}. */
|
|
57
77
|
function isCutOverride(v) {
|
|
58
78
|
if (!v || typeof v !== "object")
|
|
@@ -80,6 +100,8 @@ export function normalizeRelease(release) {
|
|
|
80
100
|
: {}),
|
|
81
101
|
}))
|
|
82
102
|
.sort((a, b) => byString(a.env, b.env)),
|
|
103
|
+
// #5149: the declared order is the publish order, so it is kept.
|
|
104
|
+
...(release.publishes ? { publishes: release.publishes.map(({ target, kind, destination }) => ({ target, kind, destination })) } : {}),
|
|
83
105
|
};
|
|
84
106
|
}
|
|
85
107
|
/** The hash input of ws-104 question 3: a param's `source` is left out. */
|
|
@@ -95,6 +117,7 @@ export function releaseHashInput(release) {
|
|
|
95
117
|
params: t.params.map(({ name, value }) => ({ name, value })),
|
|
96
118
|
...(t.trees ? { trees: t.trees } : {}),
|
|
97
119
|
})),
|
|
120
|
+
...(n.publishes ? { publishes: n.publishes } : {}),
|
|
98
121
|
};
|
|
99
122
|
}
|
|
100
123
|
/** `computePlanDigest("release", input)` over {@link releaseHashInput}. */
|
|
@@ -209,7 +232,9 @@ export function parseRelease(text) {
|
|
|
209
232
|
(x.encoding === undefined || x.encoding === "base64")) &&
|
|
210
233
|
(t.trees === undefined || (Array.isArray(t.trees) && t.trees.every((x) => x && (x.component === null || typeof x.component === "string") && typeof x.path === "string"))) &&
|
|
211
234
|
Array.isArray(t.params) &&
|
|
212
|
-
t.params.every((p) => p && typeof p.name === "string" && ["string", "number", "boolean"].includes(typeof p.value) && typeof p.source === "string"))
|
|
235
|
+
t.params.every((p) => p && typeof p.name === "string" && ["string", "number", "boolean"].includes(typeof p.value) && typeof p.source === "string")) &&
|
|
236
|
+
(r.publishes === undefined ||
|
|
237
|
+
(Array.isArray(r.publishes) && r.publishes.every((p) => p && typeof p.target === "string" && typeof p.kind === "string" && typeof p.destination === "string")));
|
|
213
238
|
return ok ? r : null;
|
|
214
239
|
}
|
|
215
240
|
/** Read one release by digest. Null when none is stored, or when the file is not a release whose content hashes to its digest. */
|
|
@@ -253,10 +278,13 @@ export function parseCuts(text) {
|
|
|
253
278
|
typeof c.timestamp === "string" &&
|
|
254
279
|
(c.runOrigin === null || (typeof c.runOrigin === "object" && typeof c.runOrigin?.forge === "string")) &&
|
|
255
280
|
(c.signature === null || c.signature === undefined || typeof c.signature === "string") &&
|
|
281
|
+
(c.sealVersion === undefined || c.sealVersion === 2) &&
|
|
256
282
|
(c.runId === null || c.runId === undefined || typeof c.runId === "string") &&
|
|
257
283
|
(c.channel === undefined || typeof c.channel === "string") &&
|
|
258
284
|
(c.lane === undefined || typeof c.lane === "string") &&
|
|
259
285
|
(c.override === undefined || isCutOverride(c.override)) &&
|
|
286
|
+
(c.green === undefined || isCutGreen(c.green)) &&
|
|
287
|
+
(c.intents === undefined || isCutIntents(c.intents)) &&
|
|
260
288
|
(c.composed === undefined || (typeof c.composed === "object" && c.composed !== null && typeof c.composed.base === "string" && Array.isArray(c.composed.sources)));
|
|
261
289
|
if (!ok) {
|
|
262
290
|
malformed++;
|
|
@@ -327,10 +355,13 @@ export async function appendCut(input, opts) {
|
|
|
327
355
|
runId: input.runId ?? null,
|
|
328
356
|
runOrigin: input.runOrigin,
|
|
329
357
|
signature: input.signature ?? null,
|
|
358
|
+
...(input.signature && input.sealVersion ? { sealVersion: input.sealVersion } : {}),
|
|
330
359
|
...(input.composed ? { composed: input.composed } : {}),
|
|
331
360
|
...(input.channel ? { channel: input.channel } : {}),
|
|
332
361
|
...(input.lane ? { lane: input.lane } : {}),
|
|
333
362
|
...(input.override ? { override: input.override } : {}),
|
|
363
|
+
...(input.green ? { green: input.green } : {}),
|
|
364
|
+
...(input.intents && input.intents.length > 0 ? { intents: input.intents } : {}),
|
|
334
365
|
};
|
|
335
366
|
const content = `${existing ? `${existing.replace(/\n$/, "")}\n` : ""}${JSON.stringify(cut, sortedJsonReplacer)}\n`;
|
|
336
367
|
try {
|
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The tag a release cut makes, from `release.tag` in the member's
|
|
3
|
+
* `chant.config.ts` (#5150).
|
|
4
|
+
*
|
|
5
|
+
* `release.tag` is a template: `v{version}`, `cli-v{version}`,
|
|
6
|
+
* `{member}/v{version}` or `{path}/v{version}` for a Go module in a
|
|
7
|
+
* subdirectory. Its placeholders:
|
|
8
|
+
*
|
|
9
|
+
* - `{version}`: the label, with one leading `v` dropped when a digit
|
|
10
|
+
* follows it, so `v{version}` gives `v1.4.0` for the labels `1.4.0` and
|
|
11
|
+
* `v1.4.0` alike;
|
|
12
|
+
* - `{label}`: the label as given;
|
|
13
|
+
* - `{member}`: the member's ledger name, outermost first and joined by `/`
|
|
14
|
+
* (`npm/core` for the member `core` of a nested workspace `npm`);
|
|
15
|
+
* - `{path}`: the member's directory from the repository root.
|
|
16
|
+
*
|
|
17
|
+
* The object form adds `floating`, a second template with `{major}` (and
|
|
18
|
+
* `{member}`, `{path}`) for a tag that `chant release publish` moves to the
|
|
19
|
+
* release's commit once every target has revealed, such as `v1` for a
|
|
20
|
+
* GitHub Action. The cut never makes it.
|
|
21
|
+
*
|
|
22
|
+
* A member that sets no `release.tag` gets the tag it always got,
|
|
23
|
+
* `release/<label>`, or `release/<member>/<label>` in a workspace member.
|
|
24
|
+
* That default is written here as the template `release/{label}` or
|
|
25
|
+
* `release/{member}/{label}`, so the rest of the code has one shape.
|
|
26
|
+
*
|
|
27
|
+
* The ledger names a release by its record, not by its tag: a tag is found
|
|
28
|
+
* from a label by rendering the template, and a label from a tag by
|
|
29
|
+
* rendering the template for each label the member's ledger holds
|
|
30
|
+
* ({@link labelOfTag}). Nothing parses a tag.
|
|
31
|
+
*/
|
|
32
|
+
/** The first chant with `release.tag` in `chant.config.ts`: the cut makes the tag the template renders (`{version}`, `{label}`, `{member}`, `{path}`), refuses one another member's template can render (`release-tag-collision`), `chant release tag` reads a release back from its tag through the ledger, `chant release publish` moves a `floating` tag at reveal, and `chant release workflow` triggers on the template's tags (#5150). */
|
|
33
|
+
export declare const RELEASE_TAG_FLOOR = "0.124.101";
|
|
34
|
+
/** `release.tag` in `chant.config.ts`. */
|
|
35
|
+
export type ReleaseTagConfig = string | {
|
|
36
|
+
name: string;
|
|
37
|
+
floating?: string;
|
|
38
|
+
};
|
|
39
|
+
export type ReleaseTagCode = "release-tag-template-invalid" | "release-tag-collision";
|
|
40
|
+
/** A template refused. */
|
|
41
|
+
export declare class ReleaseTagError extends Error {
|
|
42
|
+
readonly code: ReleaseTagCode;
|
|
43
|
+
readonly fix?: string | undefined;
|
|
44
|
+
constructor(code: ReleaseTagCode, message: string, fix?: string | undefined);
|
|
45
|
+
}
|
|
46
|
+
/** A member's tag templates, checked. */
|
|
47
|
+
export interface ReleaseTagTemplate {
|
|
48
|
+
/** The release's own tag. */
|
|
49
|
+
name: string;
|
|
50
|
+
/** The floating tag publish moves, or null. */
|
|
51
|
+
floating: string | null;
|
|
52
|
+
/** True when the config sets no `release.tag` and the tag is the one chant always made. */
|
|
53
|
+
legacy: boolean;
|
|
54
|
+
}
|
|
55
|
+
/** Where a member's templates are rendered: its ledger name and its directory from the repository root. */
|
|
56
|
+
export interface TagPlace {
|
|
57
|
+
member: string | null;
|
|
58
|
+
path: string | null;
|
|
59
|
+
}
|
|
60
|
+
/** The default template for a member that sets no `release.tag`. */
|
|
61
|
+
export declare function legacyTagTemplate(member: string | null): string;
|
|
62
|
+
/**
|
|
63
|
+
* The templates `release.tag` declares, checked, or the legacy default when
|
|
64
|
+
* it declares none. Throws {@link ReleaseTagError} `release-tag-template-invalid`.
|
|
65
|
+
*/
|
|
66
|
+
export declare function resolveTagTemplate(config: ReleaseTagConfig | undefined, member: string | null): ReleaseTagTemplate;
|
|
67
|
+
/** The label as `{version}` gives it: one leading `v` dropped when a digit follows. */
|
|
68
|
+
export declare function versionOfLabel(label: string): string;
|
|
69
|
+
/** The tag a release labelled `label` gets. */
|
|
70
|
+
export declare function renderReleaseTag(t: ReleaseTagTemplate, place: TagPlace, label: string): string;
|
|
71
|
+
/** The stable MAJOR.MINOR.PATCH a label names, or null for a prerelease or anything else. */
|
|
72
|
+
export declare function stableVersionOf(label: string): [number, number, number] | null;
|
|
73
|
+
/**
|
|
74
|
+
* The floating tag of the major line a label belongs to, prerelease or not,
|
|
75
|
+
* or null: no `floating`, or a label that names no MAJOR.MINOR.PATCH.
|
|
76
|
+
*/
|
|
77
|
+
export declare function floatingTagOfLine(t: ReleaseTagTemplate, place: TagPlace, label: string): string | null;
|
|
78
|
+
/**
|
|
79
|
+
* The floating tag a release labelled `label` moves, or null: no `floating`,
|
|
80
|
+
* a prerelease label (#5166, the same check every publish target makes), or
|
|
81
|
+
* a label that is not a stable version.
|
|
82
|
+
*/
|
|
83
|
+
export declare function renderFloatingTag(t: ReleaseTagTemplate, place: TagPlace, label: string): string | null;
|
|
84
|
+
/**
|
|
85
|
+
* Which of `labels` has the tag `tag` (or, for `floating`, moves it), read
|
|
86
|
+
* through the template: the ledger names the release, and the tag is only
|
|
87
|
+
* its rendering. Null when none does.
|
|
88
|
+
*/
|
|
89
|
+
export declare function labelOfTag(t: ReleaseTagTemplate, place: TagPlace, tag: string, labels: Iterable<string>): string | null;
|
|
90
|
+
/** A template with its placeholders other than the variable filled in: the literal before and after the variable. */
|
|
91
|
+
export interface TagShape {
|
|
92
|
+
prefix: string;
|
|
93
|
+
suffix: string;
|
|
94
|
+
}
|
|
95
|
+
/** The literal around a template's one variable (`{version}`, `{label}` or `{major}`), with `{member}` and `{path}` filled in. */
|
|
96
|
+
export declare function tagShape(template: string, place: TagPlace): TagShape;
|
|
97
|
+
/**
|
|
98
|
+
* Whether two shapes can render the same tag: whether some tag is
|
|
99
|
+
* `prefix + x + suffix` for both, with each `x` a non-empty run of label
|
|
100
|
+
* characters (which never hold `/`). Worked as the intersection of two
|
|
101
|
+
* small automata, so `release/{label}` and `release/core/{label}` are
|
|
102
|
+
* apart (the label would need a `/`) and `v{version}` and `v{version}-cli`
|
|
103
|
+
* are not (the label `1.0.0-cli`).
|
|
104
|
+
*/
|
|
105
|
+
export declare function shapesOverlap(a: TagShape, b: TagShape): boolean;
|
|
106
|
+
/** One member's templates, where they render. */
|
|
107
|
+
export interface MemberTags {
|
|
108
|
+
place: TagPlace;
|
|
109
|
+
template: ReleaseTagTemplate;
|
|
110
|
+
}
|
|
111
|
+
/**
|
|
112
|
+
* The first pair of tag templates, across members, that can render the same
|
|
113
|
+
* tag, or null. Each member's release tag and floating tag are checked
|
|
114
|
+
* against every other member's; a member's own two are not, since only a
|
|
115
|
+
* stable version moves the floating tag.
|
|
116
|
+
*/
|
|
117
|
+
export declare function findTagCollision(members: readonly MemberTags[]): {
|
|
118
|
+
a: {
|
|
119
|
+
member: string | null;
|
|
120
|
+
template: string;
|
|
121
|
+
};
|
|
122
|
+
b: {
|
|
123
|
+
member: string | null;
|
|
124
|
+
template: string;
|
|
125
|
+
};
|
|
126
|
+
} | null;
|
|
127
|
+
/** A directory's path from the repository root, or null at the root or outside a repository. */
|
|
128
|
+
export declare function pathFromTop(cwd: string, top?: string | null): string | null;
|
|
129
|
+
/** The member's place and checked templates, from its `chant.config.ts` at `cwd` and its ledger. */
|
|
130
|
+
export declare function memberTags(cwd: string, opts?: {
|
|
131
|
+
config?: ReleaseTagConfig | undefined;
|
|
132
|
+
top?: string | null;
|
|
133
|
+
}): Promise<MemberTags>;
|
|
134
|
+
/**
|
|
135
|
+
* Refuse a member's templates that can render a tag another member's can
|
|
136
|
+
* (`release-tag-collision`). The other members are the `chant` members of
|
|
137
|
+
* the workspace the member sits in, each read from its own `chant.config.ts`;
|
|
138
|
+
* one whose config can't be read is left out. A member that sets no
|
|
139
|
+
* `release.tag` is not checked, since the legacy tags hold the member's name
|
|
140
|
+
* and never collide; the member that sets one checks itself against them.
|
|
141
|
+
*/
|
|
142
|
+
export declare function checkTagCollisions(cwd: string, own: MemberTags): Promise<void>;
|
|
@@ -0,0 +1,322 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The tag a release cut makes, from `release.tag` in the member's
|
|
3
|
+
* `chant.config.ts` (#5150).
|
|
4
|
+
*
|
|
5
|
+
* `release.tag` is a template: `v{version}`, `cli-v{version}`,
|
|
6
|
+
* `{member}/v{version}` or `{path}/v{version}` for a Go module in a
|
|
7
|
+
* subdirectory. Its placeholders:
|
|
8
|
+
*
|
|
9
|
+
* - `{version}`: the label, with one leading `v` dropped when a digit
|
|
10
|
+
* follows it, so `v{version}` gives `v1.4.0` for the labels `1.4.0` and
|
|
11
|
+
* `v1.4.0` alike;
|
|
12
|
+
* - `{label}`: the label as given;
|
|
13
|
+
* - `{member}`: the member's ledger name, outermost first and joined by `/`
|
|
14
|
+
* (`npm/core` for the member `core` of a nested workspace `npm`);
|
|
15
|
+
* - `{path}`: the member's directory from the repository root.
|
|
16
|
+
*
|
|
17
|
+
* The object form adds `floating`, a second template with `{major}` (and
|
|
18
|
+
* `{member}`, `{path}`) for a tag that `chant release publish` moves to the
|
|
19
|
+
* release's commit once every target has revealed, such as `v1` for a
|
|
20
|
+
* GitHub Action. The cut never makes it.
|
|
21
|
+
*
|
|
22
|
+
* A member that sets no `release.tag` gets the tag it always got,
|
|
23
|
+
* `release/<label>`, or `release/<member>/<label>` in a workspace member.
|
|
24
|
+
* That default is written here as the template `release/{label}` or
|
|
25
|
+
* `release/{member}/{label}`, so the rest of the code has one shape.
|
|
26
|
+
*
|
|
27
|
+
* The ledger names a release by its record, not by its tag: a tag is found
|
|
28
|
+
* from a label by rendering the template, and a label from a tag by
|
|
29
|
+
* rendering the template for each label the member's ledger holds
|
|
30
|
+
* ({@link labelOfTag}). Nothing parses a tag.
|
|
31
|
+
*/
|
|
32
|
+
import { execFileSync } from "node:child_process";
|
|
33
|
+
import { existsSync } from "node:fs";
|
|
34
|
+
import { join, relative, resolve, sep } from "node:path";
|
|
35
|
+
import { prereleaseOf } from "./release-prerelease.js";
|
|
36
|
+
/** The first chant with `release.tag` in `chant.config.ts`: the cut makes the tag the template renders (`{version}`, `{label}`, `{member}`, `{path}`), refuses one another member's template can render (`release-tag-collision`), `chant release tag` reads a release back from its tag through the ledger, `chant release publish` moves a `floating` tag at reveal, and `chant release workflow` triggers on the template's tags (#5150). */
|
|
37
|
+
export const RELEASE_TAG_FLOOR = "0.124.101";
|
|
38
|
+
/** A template refused. */
|
|
39
|
+
export class ReleaseTagError extends Error {
|
|
40
|
+
constructor(code, message, fix) {
|
|
41
|
+
super(message);
|
|
42
|
+
this.code = code;
|
|
43
|
+
this.fix = fix;
|
|
44
|
+
this.name = "ReleaseTagError";
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
const NAME_PLACEHOLDERS = ["version", "label", "member", "path"];
|
|
48
|
+
const FLOATING_PLACEHOLDERS = ["major", "member", "path"];
|
|
49
|
+
/** What a label may hold (`release-store.ts` LABEL_PATTERN): letters, digits and `. _ + -`, so never `/`. */
|
|
50
|
+
const LABEL_CHAR = /^[A-Za-z0-9._+-]$/;
|
|
51
|
+
/** The default template for a member that sets no `release.tag`. */
|
|
52
|
+
export function legacyTagTemplate(member) {
|
|
53
|
+
return member ? "release/{member}/{label}" : "release/{label}";
|
|
54
|
+
}
|
|
55
|
+
function placeholdersOf(template) {
|
|
56
|
+
return [...template.matchAll(/\{([^{}]*)\}/g)].map((m) => m[1]);
|
|
57
|
+
}
|
|
58
|
+
function checkTemplate(field, template, allowed, variables) {
|
|
59
|
+
const fail = (why, fix) => {
|
|
60
|
+
throw new ReleaseTagError("release-tag-template-invalid", `${field} "${template}" ${why}`, fix);
|
|
61
|
+
};
|
|
62
|
+
const literal = template.replace(/\{[^{}]*\}/g, "");
|
|
63
|
+
if (/[{}]/.test(literal))
|
|
64
|
+
fail("has a brace that opens or closes no placeholder");
|
|
65
|
+
for (const p of placeholdersOf(template))
|
|
66
|
+
if (!allowed.includes(p))
|
|
67
|
+
fail(`names {${p}}, which is not one of ${allowed.map((a) => `{${a}}`).join(", ")}`);
|
|
68
|
+
const vars = placeholdersOf(template).filter((p) => variables.includes(p));
|
|
69
|
+
if (vars.length !== 1) {
|
|
70
|
+
fail(vars.length === 0 ? `has no ${variables.map((v) => `{${v}}`).join(" or ")}, so every release would get the same tag` : `names ${vars.map((v) => `{${v}}`).join(" and ")}; a tag holds one`, `Name it once, as in ${field.endsWith("floating") ? "v{major}" : "v{version}"}.`);
|
|
71
|
+
}
|
|
72
|
+
if (!/^[A-Za-z0-9._+/{}-]+$/.test(template))
|
|
73
|
+
fail("holds a character a tag name can't: use letters, digits and . _ + - /");
|
|
74
|
+
if (template.startsWith("/") || template.endsWith("/") || template.includes("//"))
|
|
75
|
+
fail("starts or ends with /, or holds //");
|
|
76
|
+
if (template.includes("..") || template.endsWith(".") || template.endsWith(".lock") || /(^|\/)\./.test(template))
|
|
77
|
+
fail("makes a tag name git refuses: no .., no component that starts with a dot, and no trailing . or .lock");
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* The templates `release.tag` declares, checked, or the legacy default when
|
|
81
|
+
* it declares none. Throws {@link ReleaseTagError} `release-tag-template-invalid`.
|
|
82
|
+
*/
|
|
83
|
+
export function resolveTagTemplate(config, member) {
|
|
84
|
+
if (config === undefined)
|
|
85
|
+
return { name: legacyTagTemplate(member), floating: null, legacy: true };
|
|
86
|
+
const name = typeof config === "string" ? config : config.name;
|
|
87
|
+
const floating = typeof config === "string" ? null : (config.floating ?? null);
|
|
88
|
+
checkTemplate("release.tag", name, NAME_PLACEHOLDERS, ["version", "label"]);
|
|
89
|
+
if (floating !== null)
|
|
90
|
+
checkTemplate("release.tag.floating", floating, FLOATING_PLACEHOLDERS, ["major"]);
|
|
91
|
+
return { name, floating, legacy: false };
|
|
92
|
+
}
|
|
93
|
+
/** The label as `{version}` gives it: one leading `v` dropped when a digit follows. */
|
|
94
|
+
export function versionOfLabel(label) {
|
|
95
|
+
return /^v\d/.test(label) ? label.slice(1) : label;
|
|
96
|
+
}
|
|
97
|
+
function fill(template, place, values) {
|
|
98
|
+
return template.replace(/\{([^{}]*)\}/g, (_, p) => {
|
|
99
|
+
if (p === "member") {
|
|
100
|
+
if (!place.member)
|
|
101
|
+
throw new ReleaseTagError("release-tag-template-invalid", `release.tag "${template}" names {member}, and this project is not a workspace member`, "Use a literal prefix, or {path}.");
|
|
102
|
+
return place.member;
|
|
103
|
+
}
|
|
104
|
+
if (p === "path") {
|
|
105
|
+
if (!place.path)
|
|
106
|
+
throw new ReleaseTagError("release-tag-template-invalid", `release.tag "${template}" names {path}, and this project is at the repository root`, "Use a literal prefix, or drop {path}.");
|
|
107
|
+
return place.path;
|
|
108
|
+
}
|
|
109
|
+
const v = values[p];
|
|
110
|
+
if (v === undefined)
|
|
111
|
+
throw new ReleaseTagError("release-tag-template-invalid", `release.tag "${template}" names {${p}}, which has no value here`);
|
|
112
|
+
return v;
|
|
113
|
+
});
|
|
114
|
+
}
|
|
115
|
+
/** The tag a release labelled `label` gets. */
|
|
116
|
+
export function renderReleaseTag(t, place, label) {
|
|
117
|
+
return fill(t.name, place, { version: versionOfLabel(label), label });
|
|
118
|
+
}
|
|
119
|
+
/** The stable MAJOR.MINOR.PATCH a label names, or null for a prerelease or anything else. */
|
|
120
|
+
export function stableVersionOf(label) {
|
|
121
|
+
const m = /^(\d+)\.(\d+)\.(\d+)$/.exec(versionOfLabel(label));
|
|
122
|
+
return m ? [Number(m[1]), Number(m[2]), Number(m[3])] : null;
|
|
123
|
+
}
|
|
124
|
+
/**
|
|
125
|
+
* The floating tag of the major line a label belongs to, prerelease or not,
|
|
126
|
+
* or null: no `floating`, or a label that names no MAJOR.MINOR.PATCH.
|
|
127
|
+
*/
|
|
128
|
+
export function floatingTagOfLine(t, place, label) {
|
|
129
|
+
if (t.floating === null)
|
|
130
|
+
return null;
|
|
131
|
+
const m = /^(\d+)\.\d+\.\d+(?:[-+].*)?$/.exec(versionOfLabel(label));
|
|
132
|
+
return m ? fill(t.floating, place, { major: String(Number(m[1])) }) : null;
|
|
133
|
+
}
|
|
134
|
+
/**
|
|
135
|
+
* The floating tag a release labelled `label` moves, or null: no `floating`,
|
|
136
|
+
* a prerelease label (#5166, the same check every publish target makes), or
|
|
137
|
+
* a label that is not a stable version.
|
|
138
|
+
*/
|
|
139
|
+
export function renderFloatingTag(t, place, label) {
|
|
140
|
+
if (prereleaseOf(label) !== null || stableVersionOf(label) === null)
|
|
141
|
+
return null;
|
|
142
|
+
return floatingTagOfLine(t, place, label);
|
|
143
|
+
}
|
|
144
|
+
/**
|
|
145
|
+
* Which of `labels` has the tag `tag` (or, for `floating`, moves it), read
|
|
146
|
+
* through the template: the ledger names the release, and the tag is only
|
|
147
|
+
* its rendering. Null when none does.
|
|
148
|
+
*/
|
|
149
|
+
export function labelOfTag(t, place, tag, labels) {
|
|
150
|
+
for (const label of labels) {
|
|
151
|
+
try {
|
|
152
|
+
if (renderReleaseTag(t, place, label) === tag)
|
|
153
|
+
return label;
|
|
154
|
+
}
|
|
155
|
+
catch {
|
|
156
|
+
return null;
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
return null;
|
|
160
|
+
}
|
|
161
|
+
/** The literal around a template's one variable (`{version}`, `{label}` or `{major}`), with `{member}` and `{path}` filled in. */
|
|
162
|
+
export function tagShape(template, place) {
|
|
163
|
+
const m = /\{(version|label|major)\}/.exec(template);
|
|
164
|
+
if (!m)
|
|
165
|
+
throw new ReleaseTagError("release-tag-template-invalid", `release.tag "${template}" has no {version}, {label} or {major}`);
|
|
166
|
+
const fillFixed = (s) => fill(s, place, {});
|
|
167
|
+
return { prefix: fillFixed(template.slice(0, m.index)), suffix: fillFixed(template.slice(m.index + m[0].length)) };
|
|
168
|
+
}
|
|
169
|
+
/**
|
|
170
|
+
* Whether two shapes can render the same tag: whether some tag is
|
|
171
|
+
* `prefix + x + suffix` for both, with each `x` a non-empty run of label
|
|
172
|
+
* characters (which never hold `/`). Worked as the intersection of two
|
|
173
|
+
* small automata, so `release/{label}` and `release/core/{label}` are
|
|
174
|
+
* apart (the label would need a `/`) and `v{version}` and `v{version}-cli`
|
|
175
|
+
* are not (the label `1.0.0-cli`).
|
|
176
|
+
*/
|
|
177
|
+
export function shapesOverlap(a, b) {
|
|
178
|
+
const nfa = (s) => {
|
|
179
|
+
const p = s.prefix.length;
|
|
180
|
+
const varState = p + 1;
|
|
181
|
+
const accept = varState + s.suffix.length;
|
|
182
|
+
const step = (state, c) => {
|
|
183
|
+
const out = [];
|
|
184
|
+
if (state < p) {
|
|
185
|
+
if (s.prefix[state] === c)
|
|
186
|
+
out.push(state + 1);
|
|
187
|
+
}
|
|
188
|
+
else if (state === p) {
|
|
189
|
+
if (LABEL_CHAR.test(c))
|
|
190
|
+
out.push(varState);
|
|
191
|
+
}
|
|
192
|
+
else {
|
|
193
|
+
// In the variable (state === varState) or in the suffix (state > varState).
|
|
194
|
+
if (state === varState && LABEL_CHAR.test(c))
|
|
195
|
+
out.push(varState);
|
|
196
|
+
const k = state - varState;
|
|
197
|
+
if (k < s.suffix.length && s.suffix[k] === c)
|
|
198
|
+
out.push(state + 1);
|
|
199
|
+
}
|
|
200
|
+
return out;
|
|
201
|
+
};
|
|
202
|
+
return { step, accept };
|
|
203
|
+
};
|
|
204
|
+
const na = nfa(a);
|
|
205
|
+
const nb = nfa(b);
|
|
206
|
+
const literals = new Set([...a.prefix, ...a.suffix, ...b.prefix, ...b.suffix]);
|
|
207
|
+
const other = [..."abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789._+-"].find((c) => !literals.has(c));
|
|
208
|
+
const alphabet = [...literals, ...(other ? [other] : [])];
|
|
209
|
+
const seen = new Set(["0,0"]);
|
|
210
|
+
const queue = [[0, 0]];
|
|
211
|
+
while (queue.length > 0) {
|
|
212
|
+
const [x, y] = queue.shift();
|
|
213
|
+
if (x === na.accept && y === nb.accept)
|
|
214
|
+
return true;
|
|
215
|
+
for (const c of alphabet) {
|
|
216
|
+
for (const x2 of na.step(x, c)) {
|
|
217
|
+
for (const y2 of nb.step(y, c)) {
|
|
218
|
+
const key = `${x2},${y2}`;
|
|
219
|
+
if (!seen.has(key)) {
|
|
220
|
+
seen.add(key);
|
|
221
|
+
queue.push([x2, y2]);
|
|
222
|
+
}
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
}
|
|
226
|
+
}
|
|
227
|
+
return false;
|
|
228
|
+
}
|
|
229
|
+
/**
|
|
230
|
+
* The first pair of tag templates, across members, that can render the same
|
|
231
|
+
* tag, or null. Each member's release tag and floating tag are checked
|
|
232
|
+
* against every other member's; a member's own two are not, since only a
|
|
233
|
+
* stable version moves the floating tag.
|
|
234
|
+
*/
|
|
235
|
+
export function findTagCollision(members) {
|
|
236
|
+
const shapes = members.flatMap((m) => [m.template.name, ...(m.template.floating ? [m.template.floating] : [])].map((template) => ({ member: m.place.member, template, shape: tagShape(template, m.place) })));
|
|
237
|
+
for (let i = 0; i < shapes.length; i++) {
|
|
238
|
+
for (let j = i + 1; j < shapes.length; j++) {
|
|
239
|
+
const a = shapes[i];
|
|
240
|
+
const b = shapes[j];
|
|
241
|
+
if (a.member === b.member)
|
|
242
|
+
continue;
|
|
243
|
+
if (shapesOverlap(a.shape, b.shape))
|
|
244
|
+
return { a: { member: a.member, template: a.template }, b: { member: b.member, template: b.template } };
|
|
245
|
+
}
|
|
246
|
+
}
|
|
247
|
+
return null;
|
|
248
|
+
}
|
|
249
|
+
function gitTopOf(cwd) {
|
|
250
|
+
try {
|
|
251
|
+
return execFileSync("git", ["rev-parse", "--show-toplevel"], { cwd, encoding: "utf-8", stdio: ["ignore", "pipe", "ignore"] }).trim();
|
|
252
|
+
}
|
|
253
|
+
catch {
|
|
254
|
+
return null;
|
|
255
|
+
}
|
|
256
|
+
}
|
|
257
|
+
/** A directory's path from the repository root, or null at the root or outside a repository. */
|
|
258
|
+
export function pathFromTop(cwd, top = gitTopOf(cwd)) {
|
|
259
|
+
if (!top)
|
|
260
|
+
return null;
|
|
261
|
+
const rel = relative(resolve(top), resolve(cwd)).split(sep).join("/");
|
|
262
|
+
return rel === "" || rel.startsWith("..") ? null : rel;
|
|
263
|
+
}
|
|
264
|
+
/** The member's place and checked templates, from its `chant.config.ts` at `cwd` and its ledger. */
|
|
265
|
+
export async function memberTags(cwd, opts = {}) {
|
|
266
|
+
const { resolveMemberLedger } = await import("./member-ledger.js");
|
|
267
|
+
const ledger = await resolveMemberLedger(cwd);
|
|
268
|
+
const member = ledger.members.length > 0 ? ledger.members.join("/") : null;
|
|
269
|
+
let config = opts.config;
|
|
270
|
+
if (!("config" in opts)) {
|
|
271
|
+
const { loadChantConfig } = await import("../config.js");
|
|
272
|
+
config = (await loadChantConfig(cwd)).config.release?.tag;
|
|
273
|
+
}
|
|
274
|
+
return { place: { member, path: pathFromTop(cwd, opts.top === undefined ? gitTopOf(cwd) : opts.top) }, template: resolveTagTemplate(config, member) };
|
|
275
|
+
}
|
|
276
|
+
/**
|
|
277
|
+
* Refuse a member's templates that can render a tag another member's can
|
|
278
|
+
* (`release-tag-collision`). The other members are the `chant` members of
|
|
279
|
+
* the workspace the member sits in, each read from its own `chant.config.ts`;
|
|
280
|
+
* one whose config can't be read is left out. A member that sets no
|
|
281
|
+
* `release.tag` is not checked, since the legacy tags hold the member's name
|
|
282
|
+
* and never collide; the member that sets one checks itself against them.
|
|
283
|
+
*/
|
|
284
|
+
export async function checkTagCollisions(cwd, own) {
|
|
285
|
+
if (own.template.legacy)
|
|
286
|
+
return;
|
|
287
|
+
const { findWorkspaceRoot } = await import("../project-root.js");
|
|
288
|
+
const found = findWorkspaceRoot(cwd);
|
|
289
|
+
if (!found)
|
|
290
|
+
return;
|
|
291
|
+
const { readDeclaration } = await import("../workspace/declaration.js");
|
|
292
|
+
const { workingTree } = await import("../workspace/tree.js");
|
|
293
|
+
let dirs;
|
|
294
|
+
try {
|
|
295
|
+
dirs = readDeclaration(workingTree(found.dir))
|
|
296
|
+
.members.filter((m) => m.kind === "chant")
|
|
297
|
+
.map((m) => resolve(found.dir, m.dir));
|
|
298
|
+
}
|
|
299
|
+
catch {
|
|
300
|
+
return;
|
|
301
|
+
}
|
|
302
|
+
const self = resolve(cwd);
|
|
303
|
+
const top = gitTopOf(cwd);
|
|
304
|
+
const others = [];
|
|
305
|
+
for (const dir of dirs) {
|
|
306
|
+
if (dir === self || !existsSync(join(dir, "chant.config.ts")))
|
|
307
|
+
continue;
|
|
308
|
+
try {
|
|
309
|
+
const m = await memberTags(dir, { top });
|
|
310
|
+
if (m.place.member !== own.place.member)
|
|
311
|
+
others.push(m);
|
|
312
|
+
}
|
|
313
|
+
catch {
|
|
314
|
+
// A member whose config can't be read, or whose own template is refused, is checked when it cuts.
|
|
315
|
+
}
|
|
316
|
+
}
|
|
317
|
+
const hit = findTagCollision([own, ...others]);
|
|
318
|
+
if (hit) {
|
|
319
|
+
const who = (m) => (m ? `member ${m}` : "the workspace root");
|
|
320
|
+
throw new ReleaseTagError("release-tag-collision", `release.tag "${hit.a.template}" of ${who(hit.a.member)} and "${hit.b.template}" of ${who(hit.b.member)} can make the same tag, so one member's release could take the other's tag`, "Give each member a template the others can't render: put {member} or {path} in it, or a literal prefix of its own, such as cli-v{version}.");
|
|
321
|
+
}
|
|
322
|
+
}
|
|
@@ -12,6 +12,13 @@
|
|
|
12
12
|
* time (`releaseSealPayload`), and, when the declaration at that commit has an
|
|
13
13
|
* `identity.gates.release` entry naming a class, the actor is in it.
|
|
14
14
|
*
|
|
15
|
+
* The gate a cut claims (#5177): a cut signed by chant 0.124.101 or newer
|
|
16
|
+
* signs its green-gate record (`green`, `override`, `lane`) with the digest
|
|
17
|
+
* (`releaseGateSealPayload`, `sealVersion: 2`), so a verified signature
|
|
18
|
+
* vouches for the gate too, and `gate` reads `signed`. An older signature
|
|
19
|
+
* still verifies over its four lines, and its gate reads `unsigned`: the
|
|
20
|
+
* cut line's gate could have been changed after it was signed.
|
|
21
|
+
*
|
|
15
22
|
* Reading the signers at the release's commit means a key added later does
|
|
16
23
|
* not make an old release verify, and one removed later does not unmake it.
|
|
17
24
|
*/
|
|
@@ -39,7 +46,17 @@ export interface ReleaseVerification {
|
|
|
39
46
|
key: string | null;
|
|
40
47
|
} | null;
|
|
41
48
|
reason: string;
|
|
42
|
-
|
|
49
|
+
/**
|
|
50
|
+
* Whether the gate the verified cut records is covered by its signature
|
|
51
|
+
* (#5177): `signed`, or `unsigned` for a cut signed before chant signed the
|
|
52
|
+
* gate, and for a release with no verified cut. `reason` says which.
|
|
53
|
+
*/
|
|
54
|
+
gate: {
|
|
55
|
+
status: "signed" | "unsigned";
|
|
56
|
+
reason: string;
|
|
57
|
+
};
|
|
58
|
+
/** Each cut, with the green gate it passed or the override it ran under (#5149, #4693) when it recorded one. */
|
|
59
|
+
cuts: Array<Pick<ReleaseCut, "label" | "actor" | "timestamp" | "runId" | "green" | "override"> & {
|
|
43
60
|
signatureCheck: ReleaseSignatureCheck;
|
|
44
61
|
}>;
|
|
45
62
|
}
|
|
@@ -58,3 +75,58 @@ export declare function verifyRelease(req: {
|
|
|
58
75
|
}): Promise<ReleaseVerification | {
|
|
59
76
|
error: ReleaseVerifyError;
|
|
60
77
|
}>;
|
|
78
|
+
/** One Sigstore bundle a publish recorded, and how its check went (#5164). */
|
|
79
|
+
export interface SigstoreCheck {
|
|
80
|
+
/** The bundle: `<file>.sigstore.json`, `release.slsa.sigstore.json`, or an image's `cosign signature` or `SLSA provenance`. */
|
|
81
|
+
name: string;
|
|
82
|
+
/** The publish target's kind and name. */
|
|
83
|
+
kind: string;
|
|
84
|
+
target: string;
|
|
85
|
+
attachment: "signature" | "attestation";
|
|
86
|
+
/** What it signs, each name and digest. */
|
|
87
|
+
signs: Array<{
|
|
88
|
+
name: string;
|
|
89
|
+
digest: string;
|
|
90
|
+
}>;
|
|
91
|
+
/** The identity it was checked against. */
|
|
92
|
+
identity: {
|
|
93
|
+
issuer: string;
|
|
94
|
+
identity: string;
|
|
95
|
+
} | null;
|
|
96
|
+
status: "verified" | "failed" | "unchecked";
|
|
97
|
+
reason: string;
|
|
98
|
+
}
|
|
99
|
+
/** What `release verify --sigstore` adds: each bundle's check, and the outcome. */
|
|
100
|
+
export interface SigstoreVerification {
|
|
101
|
+
/** `verified` when every bundle verifies; `failed` when one does not or can't be checked; `none` when the publish record holds none. */
|
|
102
|
+
status: "verified" | "failed" | "none";
|
|
103
|
+
checks: SigstoreCheck[];
|
|
104
|
+
reason: string;
|
|
105
|
+
}
|
|
106
|
+
/**
|
|
107
|
+
* The Sigstore bundles the publish record holds for `releaseDigest` (#5164):
|
|
108
|
+
* each signature or attestation item of the newest revealed line of each
|
|
109
|
+
* target, with its target's kind and name.
|
|
110
|
+
*/
|
|
111
|
+
export declare function recordedSignatures(cwd: string, releaseDigest: string): Promise<Array<{
|
|
112
|
+
kind: string;
|
|
113
|
+
target: string;
|
|
114
|
+
item: import("./release-publish.js").PublishItem;
|
|
115
|
+
}>>;
|
|
116
|
+
/**
|
|
117
|
+
* Check the Sigstore bundles a publish recorded for `releaseDigest`
|
|
118
|
+
* (#5164). An image's are read from its registry by cosign. A forge
|
|
119
|
+
* release's are read from `assetsDir`, where its assets were downloaded
|
|
120
|
+
* (such as `gh release download <tag> -D <dir>`): each bundle must be the
|
|
121
|
+
* bytes the record names, and a file beside it must be the digest it signs.
|
|
122
|
+
* The identity is `release.signing.identity` and `issuer` when the config
|
|
123
|
+
* names them, else the one the publish recorded: a workflow of the
|
|
124
|
+
* repository the publish ran in.
|
|
125
|
+
*/
|
|
126
|
+
export declare function verifySigstore(req: {
|
|
127
|
+
cwd: string;
|
|
128
|
+
releaseDigest: string;
|
|
129
|
+
assetsDir?: string;
|
|
130
|
+
verifier?: import("./publish-signing.js").SigstoreVerifier;
|
|
131
|
+
env?: NodeJS.ProcessEnv;
|
|
132
|
+
}): Promise<SigstoreVerification>;
|