@intentius/chant 0.124.99 → 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/bin/chant +3 -3
- 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/commands/carve-emit.js +2 -2
- package/dist/cli/commands/check-lexicon-plugin.d.ts +2 -2
- package/dist/cli/commands/check-lexicon-plugin.js +3 -3
- package/dist/cli/commands/check-lexicon.js +4 -4
- package/dist/cli/commands/init-lexicon/templates/project.d.ts +1 -1
- package/dist/cli/commands/init-lexicon/templates/project.js +4 -4
- package/dist/cli/commands/init.d.ts +13 -0
- package/dist/cli/commands/init.js +30 -2
- 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 +50 -1
- package/dist/cli/handlers/release.js +688 -30
- package/dist/cli/handlers/run-generate.js +11 -0
- package/dist/cli/main.d.ts +2 -0
- package/dist/cli/main.js +45 -97
- package/dist/cli/parse-args.js +55 -0
- package/dist/cli/registry.d.ts +18 -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/codegen/pinned-upgrade.js +1 -1
- package/dist/components/capability-plugin.d.ts +1 -1
- package/dist/components/capability-plugin.js +1 -1
- 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 +299 -6
- package/dist/config.js +102 -5
- package/dist/dead-guards.d.ts +5 -1
- package/dist/dead-guards.js +34 -23
- package/dist/discovery/sandbox/driver.js +1 -1
- package/dist/discovery/specifier-resolve.js +1 -1
- package/dist/floor-table.d.ts +3 -1
- package/dist/floor-table.data.js +23 -3
- package/dist/floor-table.js +4 -3
- 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/module-source.d.ts +2 -2
- package/dist/module-source.js +8 -8
- 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 +10 -1
- package/dist/release-floors.js +10 -1
- package/dist/tool-pins.d.ts +38 -0
- package/dist/tool-pins.js +54 -0
- package/dist/ts-loader.d.ts +1 -1
- package/dist/ts-loader.js +6 -6
- 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 +6 -0
- package/dist/workspace/reason-codes.js +8 -1
- package/dist/workspace/release-changed.d.ts +179 -0
- package/dist/workspace/release-changed.js +625 -0
- package/dist/workspace/release-changed.schema.json +206 -0
- 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 +26 -26
|
@@ -0,0 +1,570 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Stamping the release's label into manifests other than package.json (#5156).
|
|
3
|
+
*
|
|
4
|
+
* `release.version.files` names the files, each with a format chant knows
|
|
5
|
+
* (Cargo.toml, Cargo.lock, pyproject.toml, Chart.yaml, an MCP server.json,
|
|
6
|
+
* a krew plugin manifest, artifacthub-pkg.yml), a field path in a JSON, YAML
|
|
7
|
+
* or TOML file, or a regular expression. Every stamp is an edit in place:
|
|
8
|
+
* the file is scanned for the scalars it holds and only the text of the
|
|
9
|
+
* version scalars changes, so comments, key order, quoting and layout stay
|
|
10
|
+
* as committed. Nothing is parsed into a document and written back.
|
|
11
|
+
*
|
|
12
|
+
* The scanners below read the subset of each syntax a manifest uses: JSON
|
|
13
|
+
* in full, TOML in full but for multi-line inline tables, and YAML's block
|
|
14
|
+
* style (maps, sequences, plain and quoted scalars, block scalars skipped).
|
|
15
|
+
* A YAML flow collection is skipped, so a version inside one is reached
|
|
16
|
+
* with a `pattern` instead.
|
|
17
|
+
*
|
|
18
|
+
* This module reaches only Node's built-ins.
|
|
19
|
+
*/
|
|
20
|
+
import { posix } from "node:path";
|
|
21
|
+
/** The manifest formats chant stamps by name. */
|
|
22
|
+
export const MANIFEST_FORMATS = ["cargo", "cargo-lock", "pyproject", "helm", "mcp-server", "krew", "artifacthub"];
|
|
23
|
+
export class ManifestStampError extends Error {
|
|
24
|
+
constructor(code, message, fix) {
|
|
25
|
+
super(message);
|
|
26
|
+
this.code = code;
|
|
27
|
+
this.fix = fix;
|
|
28
|
+
this.name = "ManifestStampError";
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
const BY_NAME = {
|
|
32
|
+
"Cargo.toml": "cargo",
|
|
33
|
+
"Cargo.lock": "cargo-lock",
|
|
34
|
+
"pyproject.toml": "pyproject",
|
|
35
|
+
"Chart.yaml": "helm",
|
|
36
|
+
"server.json": "mcp-server",
|
|
37
|
+
"artifacthub-pkg.yml": "artifacthub",
|
|
38
|
+
"artifacthub-pkg.yaml": "artifacthub",
|
|
39
|
+
};
|
|
40
|
+
/** The path a `files` entry names. */
|
|
41
|
+
export function versionFilePath(entry) {
|
|
42
|
+
return typeof entry === "string" ? entry : entry.path;
|
|
43
|
+
}
|
|
44
|
+
function syntaxOf(path) {
|
|
45
|
+
const ext = posix.extname(path).toLowerCase();
|
|
46
|
+
if (ext === ".json")
|
|
47
|
+
return "json";
|
|
48
|
+
if (ext === ".yaml" || ext === ".yml")
|
|
49
|
+
return "yaml";
|
|
50
|
+
if (ext === ".toml" || posix.basename(path) === "Cargo.lock")
|
|
51
|
+
return "toml";
|
|
52
|
+
return null;
|
|
53
|
+
}
|
|
54
|
+
/** What an entry stamps, checked: a format known by name, a field in a file whose syntax the extension gives, or a pattern with a capture group. */
|
|
55
|
+
export function resolveVersionFile(entry) {
|
|
56
|
+
const path = versionFilePath(entry);
|
|
57
|
+
if (typeof entry === "string" || (!("field" in entry) && !("pattern" in entry))) {
|
|
58
|
+
const e = typeof entry === "string" ? { path } : entry;
|
|
59
|
+
const format = e.format ?? BY_NAME[posix.basename(path)];
|
|
60
|
+
if (!format) {
|
|
61
|
+
throw new ManifestStampError("release-version-format-unknown", `release.version.files: chant can't tell what ${path} is from its name`, `Name its format, one of ${MANIFEST_FORMATS.join(", ")} ({ path: "${path}", format: "krew" }), or the field to stamp ({ path: "${path}", field: "version" }), or a pattern ({ path: "${path}", pattern: "version = \\"([^\\"]+)\\"" }).`);
|
|
62
|
+
}
|
|
63
|
+
if (!MANIFEST_FORMATS.includes(format))
|
|
64
|
+
throw new ManifestStampError("release-version-invalid", `release.version.files: ${path} has format "${String(format)}", not one of ${MANIFEST_FORMATS.join(", ")}`);
|
|
65
|
+
return { kind: "manifest", format, entry: e };
|
|
66
|
+
}
|
|
67
|
+
if ("field" in entry) {
|
|
68
|
+
const syntax = syntaxOf(path);
|
|
69
|
+
if (!syntax)
|
|
70
|
+
throw new ManifestStampError("release-version-format-unknown", `release.version.files: ${path} names a field, and chant reads fields only in .json, .yaml, .yml and .toml files`, `Stamp it with a pattern: { path: "${path}", pattern: "..." }.`);
|
|
71
|
+
if (parseField(entry.field).length === 0)
|
|
72
|
+
throw new ManifestStampError("release-version-invalid", `release.version.files: ${path} names an empty field`);
|
|
73
|
+
return { kind: "field", entry, syntax };
|
|
74
|
+
}
|
|
75
|
+
let re;
|
|
76
|
+
try {
|
|
77
|
+
re = new RegExp(entry.pattern, "gm");
|
|
78
|
+
}
|
|
79
|
+
catch (err) {
|
|
80
|
+
throw new ManifestStampError("release-version-invalid", `release.version.files: the pattern for ${path} is not a regular expression: ${err.message}`);
|
|
81
|
+
}
|
|
82
|
+
if (new RegExp(`${entry.pattern}|`).exec("").length < 2) {
|
|
83
|
+
throw new ManifestStampError("release-version-invalid", `release.version.files: the pattern for ${path} has no capture group, so nothing in it names where the label goes`, `Put the version in parentheses: "version: ([0-9.]+)".`);
|
|
84
|
+
}
|
|
85
|
+
return { kind: "pattern", entry, re };
|
|
86
|
+
}
|
|
87
|
+
/** `a.b[].c` to `["a", "b", "[]", "c"]`. */
|
|
88
|
+
function parseField(field) {
|
|
89
|
+
const out = [];
|
|
90
|
+
for (const part of field.split(".")) {
|
|
91
|
+
const m = /^([^[\]]*)((?:\[\])*)$/.exec(part);
|
|
92
|
+
if (!m)
|
|
93
|
+
return [];
|
|
94
|
+
if (m[1])
|
|
95
|
+
out.push(m[1]);
|
|
96
|
+
for (let i = 0; i < m[2].length / 2; i++)
|
|
97
|
+
out.push("[]");
|
|
98
|
+
}
|
|
99
|
+
return out;
|
|
100
|
+
}
|
|
101
|
+
const isItem = (s) => /^\[\d+\]$/.test(s);
|
|
102
|
+
/** Does a scalar's path match a pattern, where `[]` matches any item? */
|
|
103
|
+
function matches(path, pattern) {
|
|
104
|
+
return path.length === pattern.length && pattern.every((p, i) => (p === "[]" ? isItem(path[i]) : p === path[i]));
|
|
105
|
+
}
|
|
106
|
+
/* JSON ------------------------------------------------------------- */
|
|
107
|
+
function jsonScalars(text) {
|
|
108
|
+
JSON.parse(text);
|
|
109
|
+
const out = [];
|
|
110
|
+
let i = 0;
|
|
111
|
+
const ws = () => {
|
|
112
|
+
while (i < text.length && /\s/.test(text[i]))
|
|
113
|
+
i++;
|
|
114
|
+
};
|
|
115
|
+
const str = () => {
|
|
116
|
+
const start = i + 1;
|
|
117
|
+
i++;
|
|
118
|
+
while (text[i] !== '"')
|
|
119
|
+
i += text[i] === "\\" ? 2 : 1;
|
|
120
|
+
const end = i;
|
|
121
|
+
i++;
|
|
122
|
+
return { value: JSON.parse(text.slice(start - 1, end + 1)), start, end };
|
|
123
|
+
};
|
|
124
|
+
const value = (path) => {
|
|
125
|
+
ws();
|
|
126
|
+
const c = text[i];
|
|
127
|
+
if (c === "{") {
|
|
128
|
+
i++;
|
|
129
|
+
ws();
|
|
130
|
+
if (text[i] === "}")
|
|
131
|
+
return void i++;
|
|
132
|
+
for (;;) {
|
|
133
|
+
ws();
|
|
134
|
+
const key = str().value;
|
|
135
|
+
ws();
|
|
136
|
+
i++; // :
|
|
137
|
+
value([...path, key]);
|
|
138
|
+
ws();
|
|
139
|
+
if (text[i++] === "}")
|
|
140
|
+
return;
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
if (c === "[") {
|
|
144
|
+
i++;
|
|
145
|
+
ws();
|
|
146
|
+
if (text[i] === "]")
|
|
147
|
+
return void i++;
|
|
148
|
+
for (let n = 0;; n++) {
|
|
149
|
+
value([...path, `[${n}]`]);
|
|
150
|
+
ws();
|
|
151
|
+
if (text[i++] === "]")
|
|
152
|
+
return;
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
if (c === '"') {
|
|
156
|
+
const s = str();
|
|
157
|
+
out.push({ path, ...s, string: true });
|
|
158
|
+
return;
|
|
159
|
+
}
|
|
160
|
+
const start = i;
|
|
161
|
+
while (i < text.length && !/[\s,\]}]/.test(text[i]))
|
|
162
|
+
i++;
|
|
163
|
+
out.push({ path, value: text.slice(start, i), start, end: i, string: false });
|
|
164
|
+
};
|
|
165
|
+
value([]);
|
|
166
|
+
return out;
|
|
167
|
+
}
|
|
168
|
+
/* TOML ------------------------------------------------------------- */
|
|
169
|
+
const BARE = /[A-Za-z0-9_-]+/y;
|
|
170
|
+
function tomlScalars(text) {
|
|
171
|
+
const out = [];
|
|
172
|
+
const counts = new Map();
|
|
173
|
+
let i = 0;
|
|
174
|
+
const fail = (what) => {
|
|
175
|
+
const line = text.slice(0, i).split("\n").length;
|
|
176
|
+
throw new SyntaxError(`${what} on line ${line}`);
|
|
177
|
+
};
|
|
178
|
+
/** Spaces, tabs, and with `nl` newlines and comments. */
|
|
179
|
+
const ws = (nl) => {
|
|
180
|
+
for (;;) {
|
|
181
|
+
while (i < text.length && (text[i] === " " || text[i] === "\t" || (nl && (text[i] === "\n" || text[i] === "\r"))))
|
|
182
|
+
i++;
|
|
183
|
+
if (nl && text[i] === "#") {
|
|
184
|
+
while (i < text.length && text[i] !== "\n")
|
|
185
|
+
i++;
|
|
186
|
+
continue;
|
|
187
|
+
}
|
|
188
|
+
return;
|
|
189
|
+
}
|
|
190
|
+
};
|
|
191
|
+
const quoted = () => {
|
|
192
|
+
const q = text[i];
|
|
193
|
+
const triple = text.startsWith(q.repeat(3), i);
|
|
194
|
+
const open = triple ? 3 : 1;
|
|
195
|
+
const start = i + open;
|
|
196
|
+
i = start;
|
|
197
|
+
if (triple) {
|
|
198
|
+
const close = text.indexOf(q.repeat(3), i);
|
|
199
|
+
if (close < 0)
|
|
200
|
+
fail("an unclosed string");
|
|
201
|
+
let end = close;
|
|
202
|
+
while (text[end + 3] === q)
|
|
203
|
+
end++; // up to two quotes may end the content
|
|
204
|
+
i = end + 3;
|
|
205
|
+
return { value: text.slice(start, end), start, end };
|
|
206
|
+
}
|
|
207
|
+
while (i < text.length && text[i] !== q && text[i] !== "\n")
|
|
208
|
+
i += q === '"' && text[i] === "\\" ? 2 : 1;
|
|
209
|
+
if (text[i] !== q)
|
|
210
|
+
fail("an unclosed string");
|
|
211
|
+
const end = i;
|
|
212
|
+
i++;
|
|
213
|
+
return { value: q === '"' ? JSON.parse(`"${text.slice(start, end)}"`) : text.slice(start, end), start, end };
|
|
214
|
+
};
|
|
215
|
+
const key = () => {
|
|
216
|
+
const parts = [];
|
|
217
|
+
for (;;) {
|
|
218
|
+
ws(false);
|
|
219
|
+
if (text[i] === '"' || text[i] === "'")
|
|
220
|
+
parts.push(quoted().value);
|
|
221
|
+
else {
|
|
222
|
+
BARE.lastIndex = i;
|
|
223
|
+
const m = BARE.exec(text);
|
|
224
|
+
if (!m)
|
|
225
|
+
fail("a key was expected");
|
|
226
|
+
parts.push(m[0]);
|
|
227
|
+
i += m[0].length;
|
|
228
|
+
}
|
|
229
|
+
ws(false);
|
|
230
|
+
if (text[i] !== ".")
|
|
231
|
+
return parts;
|
|
232
|
+
i++;
|
|
233
|
+
}
|
|
234
|
+
};
|
|
235
|
+
const value = (path) => {
|
|
236
|
+
ws(false);
|
|
237
|
+
const c = text[i];
|
|
238
|
+
if (c === '"' || c === "'") {
|
|
239
|
+
out.push({ path, ...quoted(), string: true });
|
|
240
|
+
return;
|
|
241
|
+
}
|
|
242
|
+
if (c === "[") {
|
|
243
|
+
i++;
|
|
244
|
+
for (let n = 0;; n++) {
|
|
245
|
+
ws(true);
|
|
246
|
+
if (text[i] === "]")
|
|
247
|
+
return void i++;
|
|
248
|
+
value([...path, `[${n}]`]);
|
|
249
|
+
ws(true);
|
|
250
|
+
if (text[i] === ",")
|
|
251
|
+
i++;
|
|
252
|
+
}
|
|
253
|
+
}
|
|
254
|
+
if (c === "{") {
|
|
255
|
+
i++;
|
|
256
|
+
for (;;) {
|
|
257
|
+
ws(true);
|
|
258
|
+
if (text[i] === "}")
|
|
259
|
+
return void i++;
|
|
260
|
+
const k = key();
|
|
261
|
+
if (text[i] !== "=")
|
|
262
|
+
fail("= was expected");
|
|
263
|
+
i++;
|
|
264
|
+
value([...path, ...k]);
|
|
265
|
+
ws(true);
|
|
266
|
+
if (text[i] === ",")
|
|
267
|
+
i++;
|
|
268
|
+
}
|
|
269
|
+
}
|
|
270
|
+
const start = i;
|
|
271
|
+
while (i < text.length && !/[\s,\]}#]/.test(text[i]))
|
|
272
|
+
i++;
|
|
273
|
+
if (i === start)
|
|
274
|
+
fail("a value was expected");
|
|
275
|
+
out.push({ path, value: text.slice(start, i), start, end: i, string: false });
|
|
276
|
+
};
|
|
277
|
+
let table = [];
|
|
278
|
+
for (;;) {
|
|
279
|
+
ws(true);
|
|
280
|
+
if (i >= text.length)
|
|
281
|
+
return out;
|
|
282
|
+
if (text.startsWith("[[", i)) {
|
|
283
|
+
i += 2;
|
|
284
|
+
const k = key();
|
|
285
|
+
if (!text.startsWith("]]", i))
|
|
286
|
+
fail("]] was expected");
|
|
287
|
+
i += 2;
|
|
288
|
+
const id = k.join("\0");
|
|
289
|
+
const n = counts.get(id) ?? 0;
|
|
290
|
+
counts.set(id, n + 1);
|
|
291
|
+
table = [...k, `[${n}]`];
|
|
292
|
+
}
|
|
293
|
+
else if (text[i] === "[") {
|
|
294
|
+
i++;
|
|
295
|
+
table = key();
|
|
296
|
+
if (text[i] !== "]")
|
|
297
|
+
fail("] was expected");
|
|
298
|
+
i++;
|
|
299
|
+
}
|
|
300
|
+
else {
|
|
301
|
+
const k = key();
|
|
302
|
+
if (text[i] !== "=")
|
|
303
|
+
fail("= was expected");
|
|
304
|
+
i++;
|
|
305
|
+
value([...table, ...k]);
|
|
306
|
+
}
|
|
307
|
+
}
|
|
308
|
+
}
|
|
309
|
+
/* YAML (block style) ----------------------------------------------- */
|
|
310
|
+
function yamlScalars(text) {
|
|
311
|
+
const out = [];
|
|
312
|
+
const stack = [];
|
|
313
|
+
const counts = new Map();
|
|
314
|
+
let blockAbove = null;
|
|
315
|
+
let offset = 0;
|
|
316
|
+
for (const raw of text.split("\n")) {
|
|
317
|
+
const lineStart = offset;
|
|
318
|
+
offset += raw.length + 1;
|
|
319
|
+
const line = raw.replace(/\r$/, "");
|
|
320
|
+
const indent = /^ */.exec(line)[0].length;
|
|
321
|
+
const body = line.slice(indent);
|
|
322
|
+
if (blockAbove !== null) {
|
|
323
|
+
if (body === "" || indent > blockAbove)
|
|
324
|
+
continue;
|
|
325
|
+
blockAbove = null;
|
|
326
|
+
}
|
|
327
|
+
if (body === "" || body.startsWith("#") || body === "---" || body === "...")
|
|
328
|
+
continue;
|
|
329
|
+
let col = indent;
|
|
330
|
+
let rest = body;
|
|
331
|
+
let keyIndent = indent;
|
|
332
|
+
while (/^-( |$)/.test(rest)) {
|
|
333
|
+
while (stack.length && (stack[stack.length - 1].indent > col || (stack[stack.length - 1].indent === col && stack[stack.length - 1].item)))
|
|
334
|
+
stack.pop();
|
|
335
|
+
const parent = stack.map((s) => s.seg).join("\0");
|
|
336
|
+
const n = counts.get(`${parent}\0@${col}`) ?? 0;
|
|
337
|
+
counts.set(`${parent}\0@${col}`, n + 1);
|
|
338
|
+
stack.push({ indent: col, seg: `[${n}]`, item: true });
|
|
339
|
+
const step = /^-( +|$)/.exec(rest)[0].length;
|
|
340
|
+
col += step;
|
|
341
|
+
rest = rest.slice(step);
|
|
342
|
+
keyIndent = col;
|
|
343
|
+
}
|
|
344
|
+
if (rest === "")
|
|
345
|
+
continue;
|
|
346
|
+
const km = /^("(?:[^"\\]|\\.)*"|'(?:[^']|'')*'|[^\s#'"{[][^:#]*?)\s*:(?: +|$)/.exec(rest);
|
|
347
|
+
if (!km) {
|
|
348
|
+
// A scalar list item: "- value".
|
|
349
|
+
if (stack[stack.length - 1]?.item && stack[stack.length - 1].indent < keyIndent)
|
|
350
|
+
pushValue(stack.map((s) => s.seg), rest, lineStart + keyIndent);
|
|
351
|
+
continue;
|
|
352
|
+
}
|
|
353
|
+
while (stack.length && stack[stack.length - 1].indent >= keyIndent)
|
|
354
|
+
stack.pop();
|
|
355
|
+
const k = km[1].startsWith('"') ? JSON.parse(km[1]) : km[1].startsWith("'") ? km[1].slice(1, -1).replace(/''/g, "'") : km[1];
|
|
356
|
+
stack.push({ indent: keyIndent, seg: k, item: false });
|
|
357
|
+
const after = rest.slice(km[0].length);
|
|
358
|
+
const valueAt = lineStart + keyIndent + km[0].length;
|
|
359
|
+
if (after === "" || after.startsWith("#"))
|
|
360
|
+
continue;
|
|
361
|
+
if (/^[|>]/.test(after)) {
|
|
362
|
+
blockAbove = keyIndent;
|
|
363
|
+
continue;
|
|
364
|
+
}
|
|
365
|
+
pushValue(stack.map((s) => s.seg), after, valueAt);
|
|
366
|
+
}
|
|
367
|
+
return out;
|
|
368
|
+
function pushValue(path, v, at) {
|
|
369
|
+
if (/^[{[&*!]/.test(v))
|
|
370
|
+
return;
|
|
371
|
+
if (v.startsWith('"')) {
|
|
372
|
+
const m = /^"((?:[^"\\]|\\.)*)"/.exec(v);
|
|
373
|
+
if (m)
|
|
374
|
+
out.push({ path, value: JSON.parse(m[0]), start: at + 1, end: at + 1 + m[1].length, string: true });
|
|
375
|
+
return;
|
|
376
|
+
}
|
|
377
|
+
if (v.startsWith("'")) {
|
|
378
|
+
const m = /^'((?:[^']|'')*)'/.exec(v);
|
|
379
|
+
if (m)
|
|
380
|
+
out.push({ path, value: m[1].replace(/''/g, "'"), start: at + 1, end: at + 1 + m[1].length, string: true });
|
|
381
|
+
return;
|
|
382
|
+
}
|
|
383
|
+
const plain = v.replace(/\s+#.*$/, "").trimEnd();
|
|
384
|
+
out.push({ path, value: plain, start: at, end: at + plain.length, string: !/^(true|false|null|~|[-+]?\d+(\.\d+)?)$/.test(plain) });
|
|
385
|
+
}
|
|
386
|
+
}
|
|
387
|
+
function scalars(syntax, text, file) {
|
|
388
|
+
try {
|
|
389
|
+
return syntax === "json" ? jsonScalars(text) : syntax === "toml" ? tomlScalars(text) : yamlScalars(text);
|
|
390
|
+
}
|
|
391
|
+
catch (err) {
|
|
392
|
+
throw new ManifestStampError("release-version-invalid", `${file} is not ${syntax.toUpperCase()} chant can read: ${err.message}`);
|
|
393
|
+
}
|
|
394
|
+
}
|
|
395
|
+
function apply(text, edits) {
|
|
396
|
+
let out = text;
|
|
397
|
+
for (const e of [...edits].sort((a, b) => b.start - a.start))
|
|
398
|
+
out = out.slice(0, e.start) + e.text + out.slice(e.end);
|
|
399
|
+
return out;
|
|
400
|
+
}
|
|
401
|
+
const find = (all, field) => all.filter((s) => matches(s.path, parseField(field)));
|
|
402
|
+
const set = (s, text) => ({ start: s.start, end: s.end, text });
|
|
403
|
+
function noField(file, what, fix) {
|
|
404
|
+
return new ManifestStampError("release-version-no-field", `${file} has no ${what} to stamp`, fix);
|
|
405
|
+
}
|
|
406
|
+
/** A Cargo version requirement with its operator kept: `=0.1.0` to `=1.4.0`. A requirement of several comparators or a wildcard is left. */
|
|
407
|
+
function cargoRequirement(req, label) {
|
|
408
|
+
const m = /^(\s*(?:=|\^|~|>=)?\s*)(\d[^,*\s]*)\s*$/.exec(req);
|
|
409
|
+
return m ? `${m[1]}${label}` : null;
|
|
410
|
+
}
|
|
411
|
+
const DEP_TABLES = new Set(["dependencies", "dev-dependencies", "build-dependencies"]);
|
|
412
|
+
/** The dependency a Cargo.toml scalar belongs to: its table's path and the crate's name, or null. */
|
|
413
|
+
function depOf(path) {
|
|
414
|
+
// [dependencies] foo = { ... }, [workspace.dependencies], [target.'cfg(..)'.dependencies], and [dependencies.foo] tables.
|
|
415
|
+
for (let d = 0; d < path.length - 2; d++) {
|
|
416
|
+
if (!DEP_TABLES.has(path[d]))
|
|
417
|
+
continue;
|
|
418
|
+
const scope = path.slice(0, d);
|
|
419
|
+
const ok = scope.length === 0 || (scope.length === 1 && scope[0] === "workspace") || (scope.length === 2 && scope[0] === "target");
|
|
420
|
+
if (ok && path.length === d + 3)
|
|
421
|
+
return { at: path.slice(0, d + 2).join("\0"), field: path[d + 2] };
|
|
422
|
+
}
|
|
423
|
+
return null;
|
|
424
|
+
}
|
|
425
|
+
function stampCargo(text, label, file) {
|
|
426
|
+
const all = scalars("toml", text, file);
|
|
427
|
+
const edits = [];
|
|
428
|
+
for (const field of ["package.version", "workspace.package.version"])
|
|
429
|
+
for (const s of find(all, field))
|
|
430
|
+
if (s.string)
|
|
431
|
+
edits.push(set(s, label));
|
|
432
|
+
const inherits = all.some((s) => matches(s.path, ["package", "version", "workspace"]));
|
|
433
|
+
if (edits.length === 0 && !inherits)
|
|
434
|
+
throw noField(file, "[package] version or [workspace.package] version", "Give the crate a version, or name the workspace's Cargo.toml, whose [workspace.package] version its crates inherit.");
|
|
435
|
+
// A path dependency inside the member carries a version requirement cargo checks against the crate at that path.
|
|
436
|
+
const fileDir = posix.dirname(file);
|
|
437
|
+
const deps = new Map();
|
|
438
|
+
for (const s of all) {
|
|
439
|
+
const d = depOf(s.path);
|
|
440
|
+
if (!d || (d.field !== "path" && d.field !== "version") || !s.string)
|
|
441
|
+
continue;
|
|
442
|
+
const e = deps.get(d.at) ?? {};
|
|
443
|
+
e[d.field] = s;
|
|
444
|
+
deps.set(d.at, e);
|
|
445
|
+
}
|
|
446
|
+
for (const { path, version } of deps.values()) {
|
|
447
|
+
if (!path || !version)
|
|
448
|
+
continue;
|
|
449
|
+
const target = posix.normalize(posix.join(fileDir, path.value));
|
|
450
|
+
if (target === ".." || target.startsWith("../") || posix.isAbsolute(path.value))
|
|
451
|
+
continue;
|
|
452
|
+
const req = cargoRequirement(version.value, label);
|
|
453
|
+
if (req !== null)
|
|
454
|
+
edits.push(set(version, req));
|
|
455
|
+
}
|
|
456
|
+
return apply(text, edits);
|
|
457
|
+
}
|
|
458
|
+
function stampCargoLock(text, label, file, crates) {
|
|
459
|
+
const all = scalars("toml", text, file);
|
|
460
|
+
const items = new Map();
|
|
461
|
+
for (const s of all) {
|
|
462
|
+
if (s.path.length !== 3 || s.path[0] !== "package" || !isItem(s.path[1]))
|
|
463
|
+
continue;
|
|
464
|
+
const f = s.path[2];
|
|
465
|
+
if (f !== "name" && f !== "version" && f !== "source")
|
|
466
|
+
continue;
|
|
467
|
+
const e = items.get(s.path[1]) ?? {};
|
|
468
|
+
e[f] = s;
|
|
469
|
+
items.set(s.path[1], e);
|
|
470
|
+
}
|
|
471
|
+
const edits = [];
|
|
472
|
+
for (const { name, version, source } of items.values()) {
|
|
473
|
+
if (!name || !version)
|
|
474
|
+
continue;
|
|
475
|
+
if (crates ? crates.includes(name.value) : !source)
|
|
476
|
+
edits.push(set(version, label));
|
|
477
|
+
}
|
|
478
|
+
if (edits.length === 0)
|
|
479
|
+
throw noField(file, crates ? `entry for ${crates.join(", ")}` : "crate of the workspace (an entry with no source)");
|
|
480
|
+
return apply(text, edits);
|
|
481
|
+
}
|
|
482
|
+
function stampPyproject(text, label, file) {
|
|
483
|
+
const all = scalars("toml", text, file);
|
|
484
|
+
const edits = [...find(all, "project.version"), ...find(all, "tool.poetry.version")].filter((s) => s.string).map((s) => set(s, label));
|
|
485
|
+
if (edits.length === 0) {
|
|
486
|
+
const dynamic = find(all, "project.dynamic[]").some((s) => s.value === "version");
|
|
487
|
+
throw noField(file, "[project] version or [tool.poetry] version", dynamic ? "The version is dynamic: stamp the file the build backend reads it from, with a pattern." : undefined);
|
|
488
|
+
}
|
|
489
|
+
return apply(text, edits);
|
|
490
|
+
}
|
|
491
|
+
function stampYamlTop(text, label, file, appVersion) {
|
|
492
|
+
const all = scalars("yaml", text, file);
|
|
493
|
+
const version = find(all, "version");
|
|
494
|
+
if (version.length === 0)
|
|
495
|
+
throw noField(file, "top-level version");
|
|
496
|
+
const edits = version.map((s) => set(s, label));
|
|
497
|
+
if (appVersion) {
|
|
498
|
+
const app = find(all, "appVersion");
|
|
499
|
+
if (app.length === 0)
|
|
500
|
+
throw noField(file, "appVersion", "Add appVersion to the file, or leave appVersion out of its release.version.files entry.");
|
|
501
|
+
edits.push(...app.map((s) => set(s, label)));
|
|
502
|
+
}
|
|
503
|
+
return apply(text, edits);
|
|
504
|
+
}
|
|
505
|
+
function stampMcpServer(text, label, file) {
|
|
506
|
+
const all = scalars("json", text, file);
|
|
507
|
+
const top = find(all, "version").filter((s) => s.string);
|
|
508
|
+
if (top.length === 0)
|
|
509
|
+
throw noField(file, "top-level version");
|
|
510
|
+
return apply(text, [...top, ...find(all, "packages[].version").filter((s) => s.string)].map((s) => set(s, label)));
|
|
511
|
+
}
|
|
512
|
+
/** krew wants `v` and the version; each platform's `uri` names the committed version, which follows. */
|
|
513
|
+
function stampKrew(text, label, file) {
|
|
514
|
+
const all = scalars("yaml", text, file);
|
|
515
|
+
const version = find(all, "spec.version");
|
|
516
|
+
if (version.length === 0)
|
|
517
|
+
throw noField(file, "spec.version");
|
|
518
|
+
const was = version[0].value.replace(/^v/, "");
|
|
519
|
+
const edits = version.map((s) => set(s, `v${label}`));
|
|
520
|
+
if (was)
|
|
521
|
+
for (const uri of find(all, "spec.platforms[].uri"))
|
|
522
|
+
if (uri.value.includes(was))
|
|
523
|
+
edits.push(set(uri, uri.value.split(was).join(label)));
|
|
524
|
+
return apply(text, edits);
|
|
525
|
+
}
|
|
526
|
+
function stampField(text, label, file, syntax, entry) {
|
|
527
|
+
const found = find(scalars(syntax, text, file), entry.field);
|
|
528
|
+
if (found.length === 0)
|
|
529
|
+
throw noField(file, `field ${entry.field}`);
|
|
530
|
+
const notString = found.find((s) => !s.string);
|
|
531
|
+
if (notString)
|
|
532
|
+
throw new ManifestStampError("release-version-invalid", `${file}: ${entry.field} is ${notString.value}, not a string, so a version can't take its place`);
|
|
533
|
+
return apply(text, found.map((s) => set(s, `${entry.prefix ?? ""}${label}`)));
|
|
534
|
+
}
|
|
535
|
+
function stampPattern(text, label, file, re, prefix) {
|
|
536
|
+
const edits = [];
|
|
537
|
+
for (const m of text.matchAll(new RegExp(re.source, "gmd"))) {
|
|
538
|
+
for (const span of m.indices.slice(1)) {
|
|
539
|
+
if (span)
|
|
540
|
+
edits.push({ start: span[0], end: span[1], text: `${prefix}${label}` });
|
|
541
|
+
}
|
|
542
|
+
}
|
|
543
|
+
if (edits.length === 0)
|
|
544
|
+
throw noField(file, `match for the pattern ${re.source}`);
|
|
545
|
+
return apply(text, edits);
|
|
546
|
+
}
|
|
547
|
+
/** One `files` entry's file, given its text, stamped with `label`. `file` is the path relative to the member. */
|
|
548
|
+
export function stampVersionFile(entry, text, label) {
|
|
549
|
+
const r = resolveVersionFile(entry);
|
|
550
|
+
const file = posix.normalize(versionFilePath(entry));
|
|
551
|
+
if (r.kind === "field")
|
|
552
|
+
return stampField(text, label, file, r.syntax, r.entry);
|
|
553
|
+
if (r.kind === "pattern")
|
|
554
|
+
return stampPattern(text, label, file, r.re, r.entry.prefix ?? "");
|
|
555
|
+
switch (r.format) {
|
|
556
|
+
case "cargo":
|
|
557
|
+
return stampCargo(text, label, file);
|
|
558
|
+
case "cargo-lock":
|
|
559
|
+
return stampCargoLock(text, label, file, r.entry.crates);
|
|
560
|
+
case "pyproject":
|
|
561
|
+
return stampPyproject(text, label, file);
|
|
562
|
+
case "helm":
|
|
563
|
+
case "artifacthub":
|
|
564
|
+
return stampYamlTop(text, label, file, r.entry.appVersion === true);
|
|
565
|
+
case "mcp-server":
|
|
566
|
+
return stampMcpServer(text, label, file);
|
|
567
|
+
case "krew":
|
|
568
|
+
return stampKrew(text, label, file);
|
|
569
|
+
}
|
|
570
|
+
}
|
|
@@ -18,21 +18,52 @@
|
|
|
18
18
|
* publish job runs `chant release stamp <label>` before its build, and
|
|
19
19
|
* `chant release publish` accepts a tree whose only changes are those files
|
|
20
20
|
* as the commit's own stamped with the release's label
|
|
21
|
-
* ({@link stampedChanges}).
|
|
22
|
-
*
|
|
23
|
-
*
|
|
24
|
-
*
|
|
21
|
+
* ({@link stampedChanges}). By default only `version` changes. With
|
|
22
|
+
* `ranges` (#5155) each workspace dependency's range follows the label the
|
|
23
|
+
* release or a train gives that package: `exact` and `caret` for the
|
|
24
|
+
* packages the release stamps, `train` also for the packages of the other
|
|
25
|
+
* members a release train pins, which `chant workspace train prepare`
|
|
26
|
+
* (#5154) stamps for every member a train cut from one commit. A package
|
|
27
|
+
* path may leave the member as long as it stays inside the repository
|
|
28
|
+
* (#5154), so `release/core` can stamp `../../packages/core`. `files` (#5156) names
|
|
29
|
+
* other manifests the label goes into, by format, field or pattern, edited
|
|
30
|
+
* in place (./release-version-formats.ts).
|
|
25
31
|
*
|
|
26
32
|
* This module reaches only Node's built-ins and git.
|
|
27
33
|
*/
|
|
34
|
+
import { type ReleaseVersionFile } from "./release-version-formats.js";
|
|
35
|
+
export { MANIFEST_FORMATS, type ManifestFormat, type ManifestFile, type FieldFile, type PatternFile, type ReleaseVersionFile } from "./release-version-formats.js";
|
|
28
36
|
/** The first chant with `release.version` and `chant release stamp` (#4840). Products feature-detect on it. */
|
|
29
37
|
export declare const RELEASE_VERSION_FLOOR = "0.124.79";
|
|
38
|
+
/**
|
|
39
|
+
* How `release.version` treats the ranges of workspace dependencies (#5155).
|
|
40
|
+
* A workspace dependency is a dependency named like a package the release
|
|
41
|
+
* stamps or, under `train`, like a package of a member the train pins.
|
|
42
|
+
*
|
|
43
|
+
* - `keep` (the default): every range stays as committed.
|
|
44
|
+
* - `exact`: a dependency on a package this release stamps becomes the label, `1.4.0`.
|
|
45
|
+
* - `caret`: the same, as `^1.4.0`.
|
|
46
|
+
* - `train`: `^<label>` for every workspace dependency, where a package of another member takes the label the train gives that member (`chant release stamp <label> --train <id>`). The cut, which runs before any train exists, stamps the packages of its own release only.
|
|
47
|
+
*/
|
|
48
|
+
export type ReleaseRanges = "keep" | "exact" | "caret" | "train";
|
|
49
|
+
/** A package name to the label a train gives it; null for a member the train pins with no label. */
|
|
50
|
+
export type RangeLabels = Record<string, string | null>;
|
|
30
51
|
/** `release.version` in `chant.config.ts`. */
|
|
31
52
|
export interface ReleaseVersionConfig {
|
|
32
53
|
/** The package directories, relative to the member, whose `package.json` takes the label as its `version`: `"."` for the member's own. */
|
|
33
|
-
packages
|
|
54
|
+
packages?: string[];
|
|
34
55
|
/** The lockfile whose entries for those packages take it too. Default `package-lock.json` when the member has one; `false` for none. */
|
|
35
56
|
lockfile?: string | false;
|
|
57
|
+
/** What happens to the ranges of workspace dependencies: `keep` (default), `exact`, `caret` or `train`. */
|
|
58
|
+
ranges?: ReleaseRanges;
|
|
59
|
+
/**
|
|
60
|
+
* Other files the label goes into (#5156): a path whose name says its
|
|
61
|
+
* format (`Cargo.toml`, `Cargo.lock`, `pyproject.toml`, `Chart.yaml`,
|
|
62
|
+
* `server.json`, `artifacthub-pkg.yml`), `{ path, format }` for one that
|
|
63
|
+
* doesn't (`krew`), `{ path, field }` for a field of a JSON, YAML or TOML
|
|
64
|
+
* file, or `{ path, pattern }` for a regular expression.
|
|
65
|
+
*/
|
|
66
|
+
files?: ReleaseVersionFile[];
|
|
36
67
|
}
|
|
37
68
|
export declare class ReleaseVersionError extends Error {
|
|
38
69
|
readonly code: string;
|
|
@@ -41,17 +72,32 @@ export declare class ReleaseVersionError extends Error {
|
|
|
41
72
|
}
|
|
42
73
|
/** Refuse a label `package.json` can't carry as its version. */
|
|
43
74
|
export declare function checkVersionLabel(label: string | null): asserts label is string;
|
|
44
|
-
/**
|
|
45
|
-
|
|
46
|
-
|
|
75
|
+
/**
|
|
76
|
+
* Check the declaration: at least one package or file, every path inside the
|
|
77
|
+
* repository (`where`: the member's directory and the repository root; a path
|
|
78
|
+
* may leave the member, #5154), each file's format known.
|
|
79
|
+
*/
|
|
80
|
+
export declare function checkReleaseVersion(config: ReleaseVersionConfig, where?: {
|
|
81
|
+
cwd: string;
|
|
82
|
+
top: string;
|
|
83
|
+
}): void;
|
|
84
|
+
/** The files the release stamps, relative to the member: each package's `package.json`, then the lockfile, then `files`. */
|
|
47
85
|
export declare function releaseVersionFiles(cwd: string, config: ReleaseVersionConfig): string[];
|
|
86
|
+
/** How the ranges are rewritten: the mode and the package name to label table. */
|
|
87
|
+
interface RangePlan {
|
|
88
|
+
mode: ReleaseRanges;
|
|
89
|
+
table: ReadonlyMap<string, string | null>;
|
|
90
|
+
}
|
|
48
91
|
/**
|
|
49
92
|
* One file's text stamped with `label`: a `package.json`'s `version`, or a
|
|
50
93
|
* lockfile's entries for `packageDirs` (relative to the lockfile's
|
|
51
94
|
* directory), with the root entry's `version` beside it for `"."`. A
|
|
52
|
-
* lockfile entry that is not there is not added.
|
|
95
|
+
* lockfile entry that is not there is not added. With `ranges` the
|
|
96
|
+
* workspace dependencies' ranges follow (#5155).
|
|
53
97
|
*/
|
|
54
|
-
export declare function stampText(text: string, label: string, kind: "package" | "lockfile", packageDirs?: readonly string[]): string;
|
|
98
|
+
export declare function stampText(text: string, label: string, kind: "package" | "lockfile", packageDirs?: readonly string[], ranges?: RangePlan): string;
|
|
99
|
+
/** The names of the packages `config` stamps, read from their package.json. A file that is missing or has no name is skipped; the stamp refuses it. */
|
|
100
|
+
export declare function ownNames(cwd: string, config: ReleaseVersionConfig): string[];
|
|
55
101
|
export interface Stamped {
|
|
56
102
|
/** The files stamped, relative to the member. */
|
|
57
103
|
files: string[];
|
|
@@ -67,6 +113,7 @@ export declare function stampReleaseVersion(i: {
|
|
|
67
113
|
cwd: string;
|
|
68
114
|
config: ReleaseVersionConfig;
|
|
69
115
|
label: string | null;
|
|
116
|
+
train?: RangeLabels;
|
|
70
117
|
}): Stamped;
|
|
71
118
|
/**
|
|
72
119
|
* Of `git status --porcelain` lines, the paths (relative to the member)
|
|
@@ -82,4 +129,5 @@ export declare function stampedChanges(i: {
|
|
|
82
129
|
config: ReleaseVersionConfig;
|
|
83
130
|
label: string | null;
|
|
84
131
|
status: string;
|
|
132
|
+
trains?: readonly RangeLabels[];
|
|
85
133
|
}): Set<string>;
|