tegami 0.1.1 → 0.1.4
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/checks-Cwz-Ezkq.js +277 -0
- package/dist/cli/index.d.ts +1 -1
- package/dist/cli/index.js +210 -211
- package/dist/error-DNy8R5ue.js +45 -0
- package/dist/generators/simple.d.ts +1 -1
- package/dist/generators/simple.js +1 -1
- package/dist/{graph-CUgwuRW5.js → graph-DLKPUXSD.js} +17 -12
- package/dist/index.d.ts +2 -2
- package/dist/index.js +233 -294
- package/dist/plugins/git.d.ts +1 -1
- package/dist/plugins/git.js +4 -5
- package/dist/plugins/github.d.ts +7 -1
- package/dist/plugins/github.js +24 -24
- package/dist/providers/cargo.d.ts +1 -1
- package/dist/providers/cargo.js +6 -6
- package/dist/providers/npm.d.ts +1 -1
- package/dist/providers/npm.js +34 -20
- package/dist/{semver-mWK2Khi2.js → semver-C4vJ4SK8.js} +16 -5
- package/dist/{types-Diwnh8Tn.d.ts → types-BXk2fMqa.d.ts} +52 -23
- package/package.json +1 -1
- package/dist/checks-Bz3Rf2OX.js +0 -98
- package/dist/constants-B9qjNfvr.js +0 -4
- package/dist/error-BaOQJtvf.js +0 -22
package/dist/plugins/github.js
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import { t as isCI } from "../constants-B9qjNfvr.js";
|
|
1
|
+
import { i as formatPackageVersion, r as formatNpmDistTag } from "../semver-C4vJ4SK8.js";
|
|
2
|
+
import { a as isCI, n as execFailure } from "../error-DNy8R5ue.js";
|
|
4
3
|
import { git } from "./git.js";
|
|
5
4
|
import { join, relative } from "node:path";
|
|
6
5
|
import { x } from "tinyexec";
|
|
@@ -8,7 +7,8 @@ import { prerelease } from "semver";
|
|
|
8
7
|
//#region src/plugins/github.ts
|
|
9
8
|
/** Create GitHub releases for successfully published packages after the whole plan succeeds. */
|
|
10
9
|
function github(options = {}) {
|
|
11
|
-
|
|
10
|
+
const { eagerRelease = false, onCreateGroupedRelease, onCreateRelease, onCreateVersionPullRequest, cli: cliOptions = {} } = options;
|
|
11
|
+
async function runGithubRelease(gitTag, title, notes, prerelease, repo) {
|
|
12
12
|
const args = [
|
|
13
13
|
"release",
|
|
14
14
|
"create",
|
|
@@ -18,26 +18,27 @@ function github(options = {}) {
|
|
|
18
18
|
"--notes",
|
|
19
19
|
notes
|
|
20
20
|
];
|
|
21
|
-
if (
|
|
21
|
+
if (repo) args.push("--repo", repo);
|
|
22
22
|
if (prerelease) args.push("--prerelease");
|
|
23
23
|
const result = await x("gh", args);
|
|
24
24
|
if (result.exitCode !== 0) throw execFailure(`Failed to create GitHub release for ${gitTag}.`, result);
|
|
25
25
|
}
|
|
26
26
|
async function createRelease(context, pkg) {
|
|
27
|
-
if (!pkg.gitTag) return;
|
|
28
|
-
const release = await
|
|
27
|
+
if (!pkg.gitTag || pkg.state === "failed") return;
|
|
28
|
+
const release = await onCreateRelease?.call(context, pkg) ?? {};
|
|
29
29
|
if (release === false) return;
|
|
30
|
-
await runGithubRelease(pkg.gitTag, release.title ?? defaultTitle(pkg), release.notes ?? await defaultNotes(context, pkg), release.prerelease ?? prerelease(pkg.version) !== null);
|
|
30
|
+
await runGithubRelease(pkg.gitTag, release.title ?? defaultTitle(pkg), release.notes ?? await defaultNotes(context, pkg), release.prerelease ?? prerelease(pkg.version) !== null, context.github?.repo);
|
|
31
31
|
}
|
|
32
32
|
async function createGroupedRelease(context, packages) {
|
|
33
33
|
const primary = packages[0];
|
|
34
34
|
if (!primary?.gitTag) return;
|
|
35
|
-
|
|
35
|
+
if (packages.some((member) => member.state === "failed")) return;
|
|
36
|
+
const release = await onCreateGroupedRelease?.call(context, packages) ?? {};
|
|
36
37
|
if (release === false) return;
|
|
37
|
-
await runGithubRelease(primary.gitTag, release.title ?? defaultGroupedTitle(packages), release.notes ?? await defaultGroupedNotes(context, packages), release.prerelease ?? packages.some((pkg) => prerelease(pkg.version) !== null));
|
|
38
|
+
await runGithubRelease(primary.gitTag, release.title ?? defaultGroupedTitle(packages), release.notes ?? await defaultGroupedNotes(context, packages), release.prerelease ?? packages.some((pkg) => prerelease(pkg.version) !== null), context.github?.repo);
|
|
38
39
|
}
|
|
39
40
|
function resolvePROptions() {
|
|
40
|
-
const setting =
|
|
41
|
+
const setting = cliOptions.versionPr ?? isCI();
|
|
41
42
|
if (setting === false) return [false];
|
|
42
43
|
if (setting === true) return [true, {}];
|
|
43
44
|
if (setting.forceCreate || isCI()) return [true, setting];
|
|
@@ -77,24 +78,21 @@ function github(options = {}) {
|
|
|
77
78
|
return [git(options), {
|
|
78
79
|
name: "github",
|
|
79
80
|
init() {
|
|
80
|
-
const repository = options.repo ?? process.env.GITHUB_REPOSITORY;
|
|
81
|
-
const token = options.token ?? process.env.GITHUB_TOKEN ?? process.env.GH_TOKEN;
|
|
82
81
|
this.github = {
|
|
83
|
-
repo:
|
|
84
|
-
token
|
|
82
|
+
repo: options.repo ?? process.env.GITHUB_REPOSITORY,
|
|
83
|
+
token: options.token ?? process.env.GITHUB_TOKEN ?? process.env.GH_TOKEN
|
|
85
84
|
};
|
|
86
85
|
},
|
|
87
86
|
cli: {
|
|
88
87
|
async init() {
|
|
89
88
|
if (!isCI()) return;
|
|
90
|
-
const
|
|
91
|
-
|
|
92
|
-
if (!token || !repository) return;
|
|
89
|
+
const { repo, token } = this.github ?? {};
|
|
90
|
+
if (!token || !repo) return;
|
|
93
91
|
const result = await x("git", [
|
|
94
92
|
"remote",
|
|
95
93
|
"set-url",
|
|
96
94
|
"origin",
|
|
97
|
-
`https://x-access-token:${token}@github.com/${
|
|
95
|
+
`https://x-access-token:${token}@github.com/${repo}.git`
|
|
98
96
|
], { nodeOptions: { cwd: this.cwd } });
|
|
99
97
|
if (result.exitCode !== 0) throw execFailure("Failed to configure git remote for GitHub Actions.", result);
|
|
100
98
|
},
|
|
@@ -104,9 +102,10 @@ function github(options = {}) {
|
|
|
104
102
|
async publishPlanApplied(draft) {
|
|
105
103
|
const { cwd } = this;
|
|
106
104
|
const [enabled, config] = resolvePROptions();
|
|
105
|
+
const repo = this.github?.repo;
|
|
107
106
|
if (!enabled || !await hasGitChanges(cwd)) return;
|
|
108
107
|
const { branch = "tegami/version-packages", base = "main" } = config;
|
|
109
|
-
const basePR = await
|
|
108
|
+
const basePR = await onCreateVersionPullRequest?.call(this, draft);
|
|
110
109
|
if (basePR === false) return;
|
|
111
110
|
const pr = {
|
|
112
111
|
title: basePR?.title ?? "Version Packages",
|
|
@@ -135,7 +134,7 @@ function github(options = {}) {
|
|
|
135
134
|
branch
|
|
136
135
|
], gitOptions);
|
|
137
136
|
if (result.exitCode !== 0) throw execFailure("Failed to push the version branch to origin. Ensure `origin` is configured and you have push access.", result);
|
|
138
|
-
const openPr = await findOpenPullRequest(branch,
|
|
137
|
+
const openPr = await findOpenPullRequest(branch, repo);
|
|
139
138
|
if (openPr !== void 0) {
|
|
140
139
|
const editArgs = [
|
|
141
140
|
"pr",
|
|
@@ -146,7 +145,7 @@ function github(options = {}) {
|
|
|
146
145
|
"--body",
|
|
147
146
|
pr.body
|
|
148
147
|
];
|
|
149
|
-
if (
|
|
148
|
+
if (repo) editArgs.push("--repo", repo);
|
|
150
149
|
const editResult = await x("gh", editArgs);
|
|
151
150
|
if (editResult.exitCode !== 0) throw execFailure("Failed to update the version pull request.", editResult);
|
|
152
151
|
return;
|
|
@@ -163,13 +162,14 @@ function github(options = {}) {
|
|
|
163
162
|
"--base",
|
|
164
163
|
base
|
|
165
164
|
];
|
|
166
|
-
if (
|
|
165
|
+
if (repo) args.push("--repo", repo);
|
|
167
166
|
const prResult = await x("gh", args);
|
|
168
167
|
if (prResult.exitCode !== 0) throw execFailure("Failed to create the version pull request.", prResult);
|
|
169
168
|
}
|
|
170
169
|
},
|
|
171
170
|
async afterPublishAll(result) {
|
|
172
|
-
if (result.state
|
|
171
|
+
if (!eagerRelease && result.state === "failed") return;
|
|
172
|
+
if (result.state === "skipped") return;
|
|
173
173
|
for (const packages of groupPackagesByGitTag(result.packages).values()) if (packages.length > 1) await createGroupedRelease(this, packages);
|
|
174
174
|
else await createRelease(this, packages[0]);
|
|
175
175
|
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { d as CargoPluginOptions, f as CargoRegistryClient, p as cargo, u as CargoPackage } from "../types-
|
|
1
|
+
import { d as CargoPluginOptions, f as CargoRegistryClient, p as cargo, u as CargoPackage } from "../types-BXk2fMqa.js";
|
|
2
2
|
export { CargoPackage, CargoPluginOptions, CargoRegistryClient, cargo };
|
package/dist/providers/cargo.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { n as WorkspacePackage } from "../graph-
|
|
1
|
+
import { i as isNodeError, n as execFailure } from "../error-DNy8R5ue.js";
|
|
2
|
+
import { n as WorkspacePackage } from "../graph-DLKPUXSD.js";
|
|
3
3
|
import { readFile, writeFile } from "node:fs/promises";
|
|
4
4
|
import { join, normalize } from "node:path";
|
|
5
5
|
import { x } from "tinyexec";
|
|
6
|
-
import initToml, { edit, parse } from "@rainbowatcher/toml-edit-js";
|
|
7
6
|
import * as semver from "semver";
|
|
7
|
+
import initToml, { edit, parse as parse$1 } from "@rainbowatcher/toml-edit-js";
|
|
8
8
|
import { glob } from "tinyglobby";
|
|
9
9
|
//#region src/providers/cargo.ts
|
|
10
10
|
const DEP_FIELDS = [
|
|
@@ -31,8 +31,8 @@ var CargoPackage = class extends WorkspacePackage {
|
|
|
31
31
|
get version() {
|
|
32
32
|
return stringValue(this.packageInfo.version) ?? this.workspaceVersion ?? "0.0.0";
|
|
33
33
|
}
|
|
34
|
-
|
|
35
|
-
const defaults = super.
|
|
34
|
+
initPlan() {
|
|
35
|
+
const defaults = super.initPlan();
|
|
36
36
|
defaults.publish ??= this.packageInfo.publish !== false;
|
|
37
37
|
return defaults;
|
|
38
38
|
}
|
|
@@ -267,7 +267,7 @@ function parseSpec(v) {
|
|
|
267
267
|
async function readCargoManifest(path) {
|
|
268
268
|
const content = await readFile(join(path, "Cargo.toml"), "utf8");
|
|
269
269
|
return {
|
|
270
|
-
manifest: parse(content),
|
|
270
|
+
manifest: parse$1(content),
|
|
271
271
|
content
|
|
272
272
|
};
|
|
273
273
|
}
|
package/dist/providers/npm.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { _ as npm, g as NpmRegistryClient, h as NpmPluginOptions, m as NpmPackage } from "../types-
|
|
1
|
+
import { _ as npm, g as NpmRegistryClient, h as NpmPluginOptions, m as NpmPackage } from "../types-BXk2fMqa.js";
|
|
2
2
|
export { NpmPackage, NpmPluginOptions, NpmRegistryClient, npm };
|
package/dist/providers/npm.js
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { n as WorkspacePackage } from "../graph-CUgwuRW5.js";
|
|
1
|
+
import { i as isNodeError, n as execFailure } from "../error-DNy8R5ue.js";
|
|
3
2
|
import { i as pnpmWorkspaceSchema, r as packageManifestSchema } from "../schemas-CurBAaW5.js";
|
|
3
|
+
import { n as WorkspacePackage } from "../graph-DLKPUXSD.js";
|
|
4
4
|
import { readFile, writeFile } from "node:fs/promises";
|
|
5
5
|
import path from "node:path";
|
|
6
6
|
import { x } from "tinyexec";
|
|
7
7
|
import * as semver from "semver";
|
|
8
|
-
import { glob } from "tinyglobby";
|
|
9
8
|
import { load } from "js-yaml";
|
|
9
|
+
import { glob } from "tinyglobby";
|
|
10
10
|
import { detect } from "package-manager-detector";
|
|
11
11
|
//#region src/providers/npm.ts
|
|
12
12
|
const DEP_FIELDS = [
|
|
@@ -33,8 +33,8 @@ var NpmPackage = class extends WorkspacePackage {
|
|
|
33
33
|
async write() {
|
|
34
34
|
await writeFile(path.join(this.path, "package.json"), `${JSON.stringify(this.manifest, null, 2)}\n`);
|
|
35
35
|
}
|
|
36
|
-
|
|
37
|
-
const defaults = super.
|
|
36
|
+
initPlan() {
|
|
37
|
+
const defaults = super.initPlan();
|
|
38
38
|
defaults.publish ??= this.manifest.private !== true;
|
|
39
39
|
if (this.manifest.publishConfig?.tag) {
|
|
40
40
|
defaults.npm ??= {};
|
|
@@ -70,7 +70,7 @@ var NpmRegistryClient = class {
|
|
|
70
70
|
if (registry) args.push("--registry", registry);
|
|
71
71
|
const result = await x(this.client === "pnpm" ? "pnpm" : "npm", args, { nodeOptions: { cwd: this.cwd } });
|
|
72
72
|
if (result.exitCode === 0) return true;
|
|
73
|
-
if (isMissingRegistryEntry(
|
|
73
|
+
if (isMissingRegistryEntry(result.stderr) || isMissingRegistryEntry(result.stdout)) return false;
|
|
74
74
|
throw execFailure(`Unable to validate ${pkg.name}@${pkg.version} against the npm registry${registry ? ` "${registry}"` : ""}.`, result);
|
|
75
75
|
};
|
|
76
76
|
info = run();
|
|
@@ -79,18 +79,34 @@ var NpmRegistryClient = class {
|
|
|
79
79
|
return info;
|
|
80
80
|
}
|
|
81
81
|
async publish(pkg, { packageStore }) {
|
|
82
|
-
const args = ["publish"];
|
|
83
82
|
const distTag = packageStore.npm?.distTag;
|
|
83
|
+
if (this.client === "bun") {
|
|
84
|
+
const tarball = "pkg.tgz";
|
|
85
|
+
const packResult = await x("bun", [
|
|
86
|
+
"pm",
|
|
87
|
+
"pack",
|
|
88
|
+
"--filename",
|
|
89
|
+
tarball
|
|
90
|
+
], { nodeOptions: { cwd: pkg.path } });
|
|
91
|
+
if (packResult.exitCode !== 0) throw execFailure(`Failed to pack ${pkg.name}@${pkg.version}.`, packResult);
|
|
92
|
+
const publishArgs = ["publish", tarball];
|
|
93
|
+
if (distTag) publishArgs.push("--tag", distTag);
|
|
94
|
+
const publishResult = await x("npm", publishArgs, { nodeOptions: { cwd: pkg.path } });
|
|
95
|
+
if (publishResult.exitCode !== 0) throw execFailure(`Failed to publish ${pkg.name}@${pkg.version}${distTag ? ` with dist-tag "${distTag}"` : ""}.`, publishResult);
|
|
96
|
+
return;
|
|
97
|
+
}
|
|
98
|
+
const args = ["publish"];
|
|
84
99
|
if (distTag) args.push("--tag", distTag);
|
|
85
|
-
|
|
86
|
-
if (client === "pnpm")
|
|
100
|
+
let client;
|
|
101
|
+
if (this.client === "pnpm") {
|
|
102
|
+
client = "pnpm";
|
|
103
|
+
args.push("--no-git-checks");
|
|
104
|
+
} else if (this.client === "yarn") client = "yarn";
|
|
105
|
+
else client = "npm";
|
|
87
106
|
const result = await x(client, args, { nodeOptions: { cwd: pkg.path } });
|
|
88
107
|
if (result.exitCode !== 0) throw execFailure(`Failed to publish ${pkg.name}@${pkg.version}${distTag ? ` with dist-tag "${distTag}"` : ""}.`, result);
|
|
89
108
|
}
|
|
90
109
|
};
|
|
91
|
-
function commandOutput(result) {
|
|
92
|
-
return [result.stdout, result.stderr].filter(Boolean).join("\n");
|
|
93
|
-
}
|
|
94
110
|
function isMissingRegistryEntry(output) {
|
|
95
111
|
const normalized = output.toLowerCase();
|
|
96
112
|
return normalized.includes("e404") || normalized.includes("404") || normalized.includes("no match") || normalized.includes("no matching version") || normalized.includes("not found");
|
|
@@ -195,12 +211,9 @@ function npm({ client: defaultClient, onBreakPeerDep = "set", updateLockFile = f
|
|
|
195
211
|
name: "npm",
|
|
196
212
|
enforce: "pre",
|
|
197
213
|
async init() {
|
|
198
|
-
if (defaultClient)
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
}
|
|
202
|
-
if ((await detect({ cwd: this.cwd }))?.name === "pnpm") client = "pnpm";
|
|
203
|
-
else client = "npm";
|
|
214
|
+
if (defaultClient) client = defaultClient;
|
|
215
|
+
else client = (await detect({ cwd: this.cwd }))?.name ?? "npm";
|
|
216
|
+
this.npm = { client };
|
|
204
217
|
},
|
|
205
218
|
async resolve() {
|
|
206
219
|
await discoverNpmPackages(this.cwd, (pkg) => this.graph.add(pkg));
|
|
@@ -252,6 +265,7 @@ function npm({ client: defaultClient, onBreakPeerDep = "set", updateLockFile = f
|
|
|
252
265
|
let args;
|
|
253
266
|
if (client === "npm") args = ["ci"];
|
|
254
267
|
else if (client === "yarn") args = ["install", "--immutable"];
|
|
268
|
+
else if (client === "bun") args = ["install", "--frozen-lockfile"];
|
|
255
269
|
else args = ["install", "--frozen-lockfile"];
|
|
256
270
|
const result = await x(client, args, { nodeOptions: { cwd: this.cwd } });
|
|
257
271
|
if (result.exitCode !== 0) throw execFailure("Failed to update lockfile.", result);
|
|
@@ -272,9 +286,9 @@ async function discoverNpmPackages(cwd, add) {
|
|
|
272
286
|
path,
|
|
273
287
|
manifest
|
|
274
288
|
})).catch(() => void 0)));
|
|
275
|
-
if (rootManifest) add(new NpmPackage(cwd, rootManifest));
|
|
289
|
+
if (rootManifest?.version) add(new NpmPackage(cwd, rootManifest));
|
|
276
290
|
for (const entry of manifests) {
|
|
277
|
-
if (!entry?.manifest) continue;
|
|
291
|
+
if (!entry?.manifest.version) continue;
|
|
278
292
|
add(new NpmPackage(entry.path, entry.manifest));
|
|
279
293
|
}
|
|
280
294
|
}
|
|
@@ -11,6 +11,11 @@ const WEIGHTS = {
|
|
|
11
11
|
minor: 2,
|
|
12
12
|
patch: 1
|
|
13
13
|
};
|
|
14
|
+
const DEPTH = {
|
|
15
|
+
major: 1,
|
|
16
|
+
minor: 2,
|
|
17
|
+
patch: 3
|
|
18
|
+
};
|
|
14
19
|
const PRE = {
|
|
15
20
|
major: "premajor",
|
|
16
21
|
minor: "preminor",
|
|
@@ -20,14 +25,20 @@ function maxBump(a, b) {
|
|
|
20
25
|
if (WEIGHTS[a] > WEIGHTS[b]) return a;
|
|
21
26
|
return b;
|
|
22
27
|
}
|
|
28
|
+
function bumpDepth(type) {
|
|
29
|
+
return DEPTH[type];
|
|
30
|
+
}
|
|
23
31
|
function bumpVersion(version, type, prerelease) {
|
|
24
32
|
let next = version;
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
33
|
+
const parsed = parse(version);
|
|
34
|
+
if (!parsed) next = null;
|
|
35
|
+
else if (prerelease) {
|
|
36
|
+
if (parsed.prerelease[0] === prerelease && type) next = inc(parsed, "prerelease", prerelease);
|
|
37
|
+
else if (type) next = inc(parsed, PRE[type], prerelease);
|
|
38
|
+
} else if (type) next = inc(parsed, type);
|
|
39
|
+
else if (parsed.prerelease.length > 0) next = inc(parsed, "release");
|
|
29
40
|
if (!next) throw new Error(`Invalid semver version: ${version}`);
|
|
30
41
|
return next;
|
|
31
42
|
}
|
|
32
43
|
//#endregion
|
|
33
|
-
export { maxBump as i,
|
|
44
|
+
export { maxBump as a, formatPackageVersion as i, bumpVersion as n, formatNpmDistTag as r, bumpDepth as t };
|
|
@@ -4,19 +4,31 @@ import { AgentName } from "package-manager-detector";
|
|
|
4
4
|
//#region src/utils/semver.d.ts
|
|
5
5
|
type BumpType = "major" | "minor" | "patch";
|
|
6
6
|
//#endregion
|
|
7
|
+
//#region src/changelog/shared.d.ts
|
|
8
|
+
declare const changelogPackageConfigSchema: z$1.ZodObject<{
|
|
9
|
+
type: z$1.ZodOptional<z$1.ZodEnum<{
|
|
10
|
+
major: "major";
|
|
11
|
+
minor: "minor";
|
|
12
|
+
patch: "patch";
|
|
13
|
+
}>>;
|
|
14
|
+
replay: z$1.ZodOptional<z$1.ZodArray<z$1.ZodString>>;
|
|
15
|
+
}, z$1.core.$strip>;
|
|
16
|
+
type ChangelogPackageConfig = z$1.output<typeof changelogPackageConfigSchema>;
|
|
17
|
+
//#endregion
|
|
7
18
|
//#region src/changelog/parse.d.ts
|
|
8
19
|
interface ChangelogEntry {
|
|
9
20
|
id: string;
|
|
10
21
|
/** file name like `my-change.md` */
|
|
11
22
|
filename: string;
|
|
12
23
|
subject?: string;
|
|
13
|
-
packages: Map<string,
|
|
24
|
+
packages: Map<string, ChangelogPackageConfig>;
|
|
14
25
|
/** will not be empty */
|
|
15
26
|
sections: {
|
|
16
27
|
depth: number;
|
|
17
28
|
title: string;
|
|
18
29
|
content: string;
|
|
19
30
|
}[];
|
|
31
|
+
getRawContent: () => string;
|
|
20
32
|
}
|
|
21
33
|
//#endregion
|
|
22
34
|
//#region src/plans/draft.d.ts
|
|
@@ -48,17 +60,20 @@ declare class DraftPlan {
|
|
|
48
60
|
type: BumpType;
|
|
49
61
|
reason?: string;
|
|
50
62
|
}): PackagePlan;
|
|
63
|
+
dispatchPackage(pkg: WorkspacePackage, dispatch: (plan: PackagePlan) => void, onUpdate?: (plan: PackagePlan) => void): PackagePlan;
|
|
64
|
+
getOrInitPackage(pkg: WorkspacePackage): PackagePlan;
|
|
51
65
|
hasPending(): boolean;
|
|
52
66
|
getChangelogs(): ChangelogEntry[];
|
|
53
67
|
getChangelog(id: string): ChangelogEntry | undefined;
|
|
54
68
|
addChangelog(entry: ChangelogEntry): void;
|
|
55
69
|
deleteChangelog(id: string): boolean;
|
|
56
|
-
private initPackagePlan;
|
|
57
70
|
/** Apply the publish plan: update package versions, write the plan file, and consume changelog files. */
|
|
58
71
|
applyPlan(): Promise<void>;
|
|
59
72
|
addPolicy(policy: PlanPolicy): void;
|
|
60
73
|
removePolicy(policy: PlanPolicy): void;
|
|
61
74
|
canApply(): boolean;
|
|
75
|
+
/** Attach replaying changelog entries to packages (already bumped), and return the updated changelog entries. */
|
|
76
|
+
private applyReplays;
|
|
62
77
|
private appendChangelog;
|
|
63
78
|
/** {@link applyPlan} but for `await using` syntax */
|
|
64
79
|
[Symbol.asyncDispose](): Promise<void>;
|
|
@@ -89,8 +104,10 @@ declare abstract class WorkspacePackage {
|
|
|
89
104
|
/** note: this will only be available after package graph is resolved */
|
|
90
105
|
getPackageOptions(): PackageOptions;
|
|
91
106
|
setPackageOptions(options: PackageOptions): void;
|
|
92
|
-
/** create
|
|
93
|
-
|
|
107
|
+
/** create the initial draft plan. */
|
|
108
|
+
initPlan(): PackagePlan;
|
|
109
|
+
/** configure an initial draft plan to match script-level configs. */
|
|
110
|
+
configurePlan(plan: PackagePlan, group?: PackageGroup): void;
|
|
94
111
|
}
|
|
95
112
|
interface PackageGroup {
|
|
96
113
|
name: string;
|
|
@@ -137,6 +154,10 @@ interface TegamiContext {
|
|
|
137
154
|
repo?: string;
|
|
138
155
|
token?: string;
|
|
139
156
|
};
|
|
157
|
+
/** additional context when npm plugin is configured */
|
|
158
|
+
npm?: {
|
|
159
|
+
client: AgentName;
|
|
160
|
+
};
|
|
140
161
|
}
|
|
141
162
|
//#endregion
|
|
142
163
|
//#region src/plans/store.d.ts
|
|
@@ -160,17 +181,7 @@ declare const planStoreSchema: z$1.ZodCodec<z$1.ZodString, z$1.ZodObject<{
|
|
|
160
181
|
version: z$1.ZodDefault<z$1.ZodLiteral<"0.0.0">>;
|
|
161
182
|
changelogs: z$1.ZodRecord<z$1.ZodString, z$1.ZodObject<{
|
|
162
183
|
filename: z$1.ZodString;
|
|
163
|
-
|
|
164
|
-
packages: z$1.ZodRecord<z$1.ZodString, z$1.ZodEnum<{
|
|
165
|
-
major: "major";
|
|
166
|
-
minor: "minor";
|
|
167
|
-
patch: "patch";
|
|
168
|
-
}>>;
|
|
169
|
-
sections: z$1.ZodArray<z$1.ZodObject<{
|
|
170
|
-
depth: z$1.ZodNumber;
|
|
171
|
-
title: z$1.ZodString;
|
|
172
|
-
content: z$1.ZodString;
|
|
173
|
-
}, z$1.core.$strip>>;
|
|
184
|
+
content: z$1.ZodString;
|
|
174
185
|
}, z$1.core.$strip>>;
|
|
175
186
|
packages: z$1.ZodRecord<z$1.ZodString, z$1.ZodObject<{
|
|
176
187
|
type: z$1.ZodOptional<z$1.ZodEnum<{
|
|
@@ -223,23 +234,37 @@ type PackagePublishResult = ({
|
|
|
223
234
|
};
|
|
224
235
|
//#endregion
|
|
225
236
|
//#region src/changelog/generate.d.ts
|
|
226
|
-
interface
|
|
237
|
+
interface GenerateChangelogOptions {
|
|
227
238
|
/** Start revision. Defaults to the latest reachable git tag, or all history if none exists. */
|
|
228
239
|
from?: string;
|
|
229
240
|
/** End revision. Defaults to HEAD. */
|
|
230
241
|
to?: string;
|
|
242
|
+
/**
|
|
243
|
+
* Write changelog files to disk.
|
|
244
|
+
*
|
|
245
|
+
* @default true
|
|
246
|
+
*/
|
|
247
|
+
write?: boolean;
|
|
231
248
|
}
|
|
232
|
-
interface
|
|
249
|
+
interface GeneratedChangelog {
|
|
233
250
|
filename: string;
|
|
234
|
-
|
|
251
|
+
content: string;
|
|
252
|
+
packages: Record<string, BumpType | ChangelogPackageConfig>;
|
|
253
|
+
changes: CommitChange[];
|
|
254
|
+
}
|
|
255
|
+
interface CommitChange {
|
|
256
|
+
hash: string;
|
|
257
|
+
subject: string;
|
|
258
|
+
body: string;
|
|
235
259
|
packages: string[];
|
|
236
|
-
|
|
260
|
+
type: BumpType;
|
|
261
|
+
title: string;
|
|
237
262
|
}
|
|
238
263
|
//#endregion
|
|
239
264
|
//#region src/index.d.ts
|
|
240
265
|
interface Tegami {
|
|
241
266
|
/** Create pending changelog files from git commit history. */
|
|
242
|
-
generateChangelog(options?:
|
|
267
|
+
generateChangelog(options?: GenerateChangelogOptions): Promise<GeneratedChangelog[]>;
|
|
243
268
|
/** Build a draft from pending changelog files. */
|
|
244
269
|
draft(): Promise<DraftPlan>;
|
|
245
270
|
/** Publish the current publish plan. */
|
|
@@ -287,7 +312,7 @@ declare class NpmPackage extends WorkspacePackage {
|
|
|
287
312
|
get name(): string;
|
|
288
313
|
get version(): string;
|
|
289
314
|
write(): Promise<void>;
|
|
290
|
-
|
|
315
|
+
initPlan(): PackagePlan;
|
|
291
316
|
}
|
|
292
317
|
declare class NpmRegistryClient implements RegistryClient {
|
|
293
318
|
#private;
|
|
@@ -368,7 +393,7 @@ declare class CargoPackage extends WorkspacePackage {
|
|
|
368
393
|
constructor(path: string, manifest: TomlTable, content: string, workspaceManifest?: TomlTable | undefined);
|
|
369
394
|
get name(): string;
|
|
370
395
|
get version(): string;
|
|
371
|
-
|
|
396
|
+
initPlan(): PackagePlan;
|
|
372
397
|
setVersion(version: string): void;
|
|
373
398
|
write(): Promise<void>;
|
|
374
399
|
patch(path: string, value: unknown): void;
|
|
@@ -447,6 +472,10 @@ interface GroupOptions {
|
|
|
447
472
|
syncBump?: boolean;
|
|
448
473
|
/** when multiple packages in the group are published, only one git tag will be created (as well as GitHub release) */
|
|
449
474
|
syncGitTag?: boolean;
|
|
475
|
+
/** npm-specific options. */
|
|
476
|
+
npm?: {
|
|
477
|
+
/** npm dist-tag used when publishing. */distTag?: string;
|
|
478
|
+
};
|
|
450
479
|
}
|
|
451
480
|
interface PackageOptions<Group extends string = string> {
|
|
452
481
|
/** Prerelease identifier appended to bumped versions (e.g. `alpha` → `1.1.0-alpha.0`). */
|
|
@@ -520,4 +549,4 @@ interface RegistryClient {
|
|
|
520
549
|
}): Promise<void>;
|
|
521
550
|
}
|
|
522
551
|
//#endregion
|
|
523
|
-
export { PackagePlan as A, PublishOptions as C, PackageGroup as D, PackageGraph as E, WorkspacePackage as O, PackagePublishResult as S, TegamiContext as T, npm as _, PublishPreflight as a,
|
|
552
|
+
export { PackagePlan as A, PublishOptions as C, PackageGroup as D, PackageGraph as E, WorkspacePackage as O, PackagePublishResult as S, TegamiContext as T, npm as _, PublishPreflight as a, GenerateChangelogOptions as b, TegamiPlugin as c, CargoPluginOptions as d, CargoRegistryClient as f, NpmRegistryClient as g, NpmPluginOptions as h, PackageOptions as i, DraftPlan as k, TegamiPluginOption as l, NpmPackage as m, GroupOptions as n, RegistryClient as o, cargo as p, LogGenerator as r, TegamiOptions as s, Awaitable as t, CargoPackage as u, Tegami as v, PublishResult as w, GeneratedChangelog as x, tegami as y };
|
package/package.json
CHANGED
package/dist/checks-Bz3Rf2OX.js
DELETED
|
@@ -1,98 +0,0 @@
|
|
|
1
|
-
import { n as handlePluginError } from "./error-BaOQJtvf.js";
|
|
2
|
-
import { n as jsonCodec, t as bumpTypeSchema } from "./schemas-CurBAaW5.js";
|
|
3
|
-
import z$1 from "zod";
|
|
4
|
-
import { readFile } from "fs/promises";
|
|
5
|
-
//#region src/utils/changelog.ts
|
|
6
|
-
function changelogFilename(disambiguator = 0) {
|
|
7
|
-
const date = /* @__PURE__ */ new Date();
|
|
8
|
-
return `${date.getFullYear()}-${String(date.getMonth() + 1).padStart(2, "0")}-${String(date.getDate()).padStart(2, "0")}-${(Date.now() + disambiguator).toString(36)}.md`;
|
|
9
|
-
}
|
|
10
|
-
//#endregion
|
|
11
|
-
//#region src/plans/store.ts
|
|
12
|
-
const packagePlanStoreSchema = z$1.object({
|
|
13
|
-
type: bumpTypeSchema.optional(),
|
|
14
|
-
changelogIds: z$1.array(z$1.string()).optional(),
|
|
15
|
-
bumpReasons: z$1.array(z$1.string()).optional(),
|
|
16
|
-
npm: z$1.object({ distTag: z$1.string().optional() }).optional(),
|
|
17
|
-
publish: z$1.boolean()
|
|
18
|
-
});
|
|
19
|
-
/** the persisted plan data for actual publishing */
|
|
20
|
-
const planStoreSchema = jsonCodec(z$1.object({
|
|
21
|
-
id: z$1.string(),
|
|
22
|
-
createdAt: z$1.iso.datetime(),
|
|
23
|
-
version: z$1.literal("0.0.0").default("0.0.0"),
|
|
24
|
-
/** release note entries */
|
|
25
|
-
changelogs: z$1.record(z$1.string(), z$1.object({
|
|
26
|
-
filename: z$1.string(),
|
|
27
|
-
subject: z$1.string().optional(),
|
|
28
|
-
packages: z$1.record(z$1.string(), bumpTypeSchema),
|
|
29
|
-
sections: z$1.array(z$1.object({
|
|
30
|
-
depth: z$1.number(),
|
|
31
|
-
title: z$1.string(),
|
|
32
|
-
content: z$1.string()
|
|
33
|
-
}))
|
|
34
|
-
})),
|
|
35
|
-
/** package id -> package info */
|
|
36
|
-
packages: z$1.record(z$1.string(), packagePlanStoreSchema)
|
|
37
|
-
}));
|
|
38
|
-
function createPlanStore(draft, context) {
|
|
39
|
-
const store = {
|
|
40
|
-
version: "0.0.0",
|
|
41
|
-
id: `tegami-${Date.now().toString(36)}`,
|
|
42
|
-
createdAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
43
|
-
changelogs: {},
|
|
44
|
-
packages: {}
|
|
45
|
-
};
|
|
46
|
-
for (const entry of draft.getChangelogs()) store.changelogs[entry.id] = {
|
|
47
|
-
filename: entry.filename,
|
|
48
|
-
subject: entry.subject,
|
|
49
|
-
packages: Object.fromEntries(entry.packages.entries()),
|
|
50
|
-
sections: entry.sections
|
|
51
|
-
};
|
|
52
|
-
for (const pkg of context.graph.getPackages()) {
|
|
53
|
-
const plan = draft.getPackagePlan(pkg.id);
|
|
54
|
-
if (plan) store.packages[pkg.id] = {
|
|
55
|
-
publish: plan.publish ?? false,
|
|
56
|
-
type: plan.type,
|
|
57
|
-
npm: plan.npm,
|
|
58
|
-
changelogIds: plan.changelogs?.map((entry) => entry.id),
|
|
59
|
-
bumpReasons: plan.bumpReasons ? Array.from(plan.bumpReasons) : void 0
|
|
60
|
-
};
|
|
61
|
-
}
|
|
62
|
-
return planStoreSchema.encode(store);
|
|
63
|
-
}
|
|
64
|
-
async function readPlanStore(context) {
|
|
65
|
-
try {
|
|
66
|
-
return planStoreSchema.decode(await readFile(context.planPath, "utf8"));
|
|
67
|
-
} catch {}
|
|
68
|
-
}
|
|
69
|
-
//#endregion
|
|
70
|
-
//#region src/plans/checks.ts
|
|
71
|
-
async function publishPlanStatus(store, context) {
|
|
72
|
-
async function defaultStatus() {
|
|
73
|
-
try {
|
|
74
|
-
await Promise.all(Object.entries(store.packages).map(async ([id, plan]) => {
|
|
75
|
-
const pkg = context.graph.get(id);
|
|
76
|
-
if (!pkg || !plan.publish) return;
|
|
77
|
-
if (!await context.getRegistryClient(pkg).isPackagePublished(pkg)) throw "pending";
|
|
78
|
-
}));
|
|
79
|
-
return { state: "success" };
|
|
80
|
-
} catch (err) {
|
|
81
|
-
if (err === "pending") return { state: "pending" };
|
|
82
|
-
throw err;
|
|
83
|
-
}
|
|
84
|
-
}
|
|
85
|
-
let status = await defaultStatus();
|
|
86
|
-
for (const plugin of context.plugins) {
|
|
87
|
-
const resolved = await handlePluginError(plugin, "resolvePlanStatus", () => plugin.resolvePlanStatus?.call(context, status, { plan: store }));
|
|
88
|
-
if (resolved) status = resolved;
|
|
89
|
-
}
|
|
90
|
-
return status;
|
|
91
|
-
}
|
|
92
|
-
async function assertPublishPlanFinished(context) {
|
|
93
|
-
const store = await readPlanStore(context);
|
|
94
|
-
if (!store) return;
|
|
95
|
-
if ((await publishPlanStatus(store, context)).state === "pending") throw new Error(`Publish plan already exists at ${context.planPath} and is pending. Publish it before applying a new plan.`);
|
|
96
|
-
}
|
|
97
|
-
//#endregion
|
|
98
|
-
export { changelogFilename as a, readPlanStore as i, publishPlanStatus as n, createPlanStore as r, assertPublishPlanFinished as t };
|
package/dist/error-BaOQJtvf.js
DELETED
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
//#region src/utils/error.ts
|
|
2
|
-
function execFailure(context, result) {
|
|
3
|
-
const lines = [context, `(exit ${result.exitCode})`];
|
|
4
|
-
const out = result.stdout.trim();
|
|
5
|
-
const err = result.stderr.trim();
|
|
6
|
-
if (out) lines.push(out);
|
|
7
|
-
if (err) lines.push(err);
|
|
8
|
-
return new Error(lines.join("\n"));
|
|
9
|
-
}
|
|
10
|
-
function isNodeError(error) {
|
|
11
|
-
return error instanceof Error && "code" in error;
|
|
12
|
-
}
|
|
13
|
-
async function handlePluginError(plugin, hookName, callback) {
|
|
14
|
-
try {
|
|
15
|
-
return await callback();
|
|
16
|
-
} catch (error) {
|
|
17
|
-
const details = error instanceof Error ? error.message : String(error);
|
|
18
|
-
throw new Error(`Plugin "${plugin.name}" failed during ${hookName}:\n${details}`, { cause: error });
|
|
19
|
-
}
|
|
20
|
-
}
|
|
21
|
-
//#endregion
|
|
22
|
-
export { handlePluginError as n, isNodeError as r, execFailure as t };
|