tegami 1.2.1 → 1.2.3
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/{_accessExpressionAsString-QhbUZzwv.js → _accessExpressionAsString-DW_6Xqcp.js} +1 -1
- package/dist/{_assertGuard-BBn2NbSz.js → _assertGuard-CFFC1Up9.js} +2 -2
- package/dist/{_createStandardSchema-BGQyz-uA.js → _createStandardSchema-CrRqJgaE.js} +2 -2
- package/dist/cli/index.d.ts +1 -1
- package/dist/cli/index.js +2 -3
- package/dist/{generate-Cnd8RiKO.js → generate-Cgl2G5ea.js} +2 -2
- package/dist/generators/simple.d.ts +1 -1
- package/dist/generators/simple.js +1 -1
- package/dist/{graph-BmXTJZxx.js → graph-DaJ28Y4f.js} +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +5 -4
- package/dist/{npm-4iA03RvC.js → npm-uJA8deYA.js} +253 -131
- package/dist/plugins/cargo.d.ts +1 -1
- package/dist/plugins/cargo.js +3 -3
- package/dist/plugins/git.d.ts +1 -1
- package/dist/plugins/github.d.ts +2 -2
- package/dist/plugins/github.js +8 -46
- package/dist/plugins/gitlab.d.ts +2 -2
- package/dist/plugins/gitlab.js +8 -45
- package/dist/plugins/go.d.ts +1 -1
- package/dist/plugins/go.js +2 -2
- package/dist/providers/npm.d.ts +1 -1
- package/dist/providers/npm.js +1 -1
- package/dist/{publish-Bt3e1RPs.js → publish-BEYIILK5.js} +6 -12
- package/dist/{semver-EKJ8yK5U.js → semver-DrtaCCZK.js} +15 -3
- package/dist/{shared-C_iSTp_s.js → shared-pTOZU5UZ.js} +11 -3
- package/dist/{types-BbwOrNZ2.d.ts → types-Kj7Nxbjz.d.ts} +27 -23
- package/dist/{version-request-BQwP7EWa.d.ts → version-request-C5vtakPE.d.ts} +1 -1
- package/dist/{version-request-DvWVAYj2.js → version-request-C89RO85i.js} +73 -27
- package/package.json +5 -4
package/dist/plugins/github.js
CHANGED
|
@@ -1,14 +1,13 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { t as changelogFilename } from "../generate-
|
|
1
|
+
import { a as formatPackageVersion } from "../semver-DrtaCCZK.js";
|
|
2
|
+
import { t as changelogFilename } from "../generate-Cgl2G5ea.js";
|
|
3
3
|
import { n as execFailure, o as cached, r as fetchFailure, s as isCI } from "../error-CAsrGb6e.js";
|
|
4
|
-
import { a as createDraft, l as readChangelogEntries } from "../publish-
|
|
4
|
+
import { a as createDraft, l as readChangelogEntries } from "../publish-BEYIILK5.js";
|
|
5
5
|
import { git } from "./git.js";
|
|
6
|
-
import {
|
|
6
|
+
import { n as onVersionRequest, t as formatPreview } from "../version-request-C89RO85i.js";
|
|
7
7
|
import { readFile, writeFile } from "node:fs/promises";
|
|
8
8
|
import { basename, join, relative, resolve } from "node:path";
|
|
9
9
|
import { x } from "tinyexec";
|
|
10
10
|
import semver from "semver";
|
|
11
|
-
import { resolveCommand } from "package-manager-detector";
|
|
12
11
|
import { note, outro } from "@clack/prompts";
|
|
13
12
|
//#region src/plugins/github/api.ts
|
|
14
13
|
function parseGitHubRepo(repo) {
|
|
@@ -172,46 +171,10 @@ function registerPrCli(cli) {
|
|
|
172
171
|
}
|
|
173
172
|
async function buildPrPreview(context, draft, options = {}) {
|
|
174
173
|
const pullRequest = await resolvePullRequest(context, options);
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
const pendingPackages = [];
|
|
180
|
-
const lines = [
|
|
181
|
-
"### Tegami",
|
|
182
|
-
"",
|
|
183
|
-
`This repository uses [Tegami](https://tegami.fuma-nama.dev) to manage releases. When your changes affect published packages, add a changelog file under \`.tegami/\` before merging.`,
|
|
184
|
-
"",
|
|
185
|
-
`[**Create a changelog →**](${createLink}) · [Changelog format](https://tegami.fuma-nama.dev/changelog)`,
|
|
186
|
-
""
|
|
187
|
-
];
|
|
188
|
-
for (const pkg of context.graph.getPackages()) {
|
|
189
|
-
const plan = draft.getPackageDraft(pkg.id);
|
|
190
|
-
if (!plan) continue;
|
|
191
|
-
const bumped = plan.bumpVersion(pkg);
|
|
192
|
-
if (!bumped || !pkg.version || bumped === pkg.version) continue;
|
|
193
|
-
pendingPackages.push({
|
|
194
|
-
name: pkg.name,
|
|
195
|
-
type: plan.type ?? "—",
|
|
196
|
-
from: pkg.version,
|
|
197
|
-
to: bumped,
|
|
198
|
-
distTag: plan.npm?.distTag
|
|
199
|
-
});
|
|
200
|
-
}
|
|
201
|
-
const requestChangelogs = draft.getChangelogs().filter((entry) => changelogFiles.has(entry.filename));
|
|
202
|
-
if (pendingPackages.length > 0) {
|
|
203
|
-
lines.push("#### Release preview", "", "| Package | Bump | Version |", "| --- | --- | --- |");
|
|
204
|
-
for (const { name, type, from, to, distTag } of pendingPackages) lines.push(`| \`${name}\` | ${type} | \`${from}\` → \`${to}\`${formatNpmDistTag(distTag)} |`);
|
|
205
|
-
lines.push("");
|
|
206
|
-
}
|
|
207
|
-
if (requestChangelogs.length > 0) {
|
|
208
|
-
lines.push("#### Changelogs in this PR", "", "| Changelog | Title |", "| --- | --- |");
|
|
209
|
-
for (const entry of requestChangelogs) for (const section of entry.sections) lines.push(`| \`${entry.filename}\` | ${section.title} |`);
|
|
210
|
-
lines.push("");
|
|
211
|
-
} else if (pendingPackages.length === 0) lines.push("#### No changelogs yet", "", "This PR has no pending changelog files. If your changes require a release, add a changelog before merging.", "");
|
|
212
|
-
else if (changelogFiles.size === 0) lines.push("This PR does not add changelog files. Pending changelogs from other branches are included in the preview above.", "");
|
|
213
|
-
lines.push(`Run \`${tegamiCommand}\` locally to create a changelog interactively.`, "", `<sub>Managed by [Tegami](https://tegami.fuma-nama.dev).</sub>`, "");
|
|
214
|
-
return lines.join("\n");
|
|
174
|
+
return formatPreview(context, draft, await listPullRequestChangelogFiles(context, pullRequest.baseSha, pullRequest.headSha), {
|
|
175
|
+
"create-a-changelog-href": createChangelogUrl(context, pullRequest.headRepo, pullRequest.headRef, changelogFilename()),
|
|
176
|
+
pr: "PR"
|
|
177
|
+
});
|
|
215
178
|
}
|
|
216
179
|
async function postPrComment(context, body) {
|
|
217
180
|
const { repo, token } = context.github ?? {};
|
|
@@ -236,7 +199,6 @@ async function resolvePullRequest(context, options) {
|
|
|
236
199
|
const { repo, token } = context.github ?? {};
|
|
237
200
|
if (!repo) throw new Error("GitHub plugin context is required.");
|
|
238
201
|
if (options.number !== void 0) {
|
|
239
|
-
parsePositiveInt(String(options.number), "--number");
|
|
240
202
|
const data = await getPullRequest(repo, options.number, token);
|
|
241
203
|
return {
|
|
242
204
|
headRepo: data.headRepository ? `${data.headRepository.owner.login}/${data.headRepository.name}` : repo,
|
package/dist/plugins/gitlab.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { j as WorkspacePackage, s as TegamiPlugin, t as Awaitable, x as TegamiContext, y as PublishPlan } from "../types-Kj7Nxbjz.js";
|
|
2
2
|
import { GitPluginOptions } from "./git.js";
|
|
3
|
-
import { t as VersionRequestOptions } from "../version-request-
|
|
3
|
+
import { t as VersionRequestOptions } from "../version-request-C5vtakPE.js";
|
|
4
4
|
|
|
5
5
|
//#region src/plugins/gitlab.d.ts
|
|
6
6
|
interface GitlabRelease {
|
package/dist/plugins/gitlab.js
CHANGED
|
@@ -1,13 +1,12 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { t as changelogFilename } from "../generate-
|
|
1
|
+
import { a as formatPackageVersion } from "../semver-DrtaCCZK.js";
|
|
2
|
+
import { t as changelogFilename } from "../generate-Cgl2G5ea.js";
|
|
3
3
|
import { c as joinPath, n as execFailure, o as cached, r as fetchFailure, s as isCI } from "../error-CAsrGb6e.js";
|
|
4
|
-
import { a as createDraft, l as readChangelogEntries } from "../publish-
|
|
4
|
+
import { a as createDraft, l as readChangelogEntries } from "../publish-BEYIILK5.js";
|
|
5
5
|
import { git } from "./git.js";
|
|
6
|
-
import {
|
|
6
|
+
import { n as onVersionRequest, t as formatPreview } from "../version-request-C89RO85i.js";
|
|
7
7
|
import { readFile, writeFile } from "node:fs/promises";
|
|
8
8
|
import { basename, join, relative, resolve } from "node:path";
|
|
9
9
|
import { x } from "tinyexec";
|
|
10
|
-
import { resolveCommand } from "package-manager-detector";
|
|
11
10
|
import { note, outro } from "@clack/prompts";
|
|
12
11
|
//#region src/plugins/gitlab/api.ts
|
|
13
12
|
function parseGitLabRepo(repo) {
|
|
@@ -184,46 +183,10 @@ function registerMrCli(cli) {
|
|
|
184
183
|
}
|
|
185
184
|
async function buildMrPreview(context, draft, options = {}) {
|
|
186
185
|
const mergeRequest = await resolveMergeRequest(context, options);
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
const pendingPackages = [];
|
|
192
|
-
const lines = [
|
|
193
|
-
"### Tegami",
|
|
194
|
-
"",
|
|
195
|
-
`This repository uses [Tegami](https://tegami.fuma-nama.dev) to manage releases. When your changes affect published packages, add a changelog file under \`.tegami/\` before merging.`,
|
|
196
|
-
"",
|
|
197
|
-
`[**Create a changelog →**](${createLink}) · [Changelog format](https://tegami.fuma-nama.dev/changelog)`,
|
|
198
|
-
""
|
|
199
|
-
];
|
|
200
|
-
for (const pkg of context.graph.getPackages()) {
|
|
201
|
-
const plan = draft.getPackageDraft(pkg.id);
|
|
202
|
-
if (!plan) continue;
|
|
203
|
-
const bumped = plan.bumpVersion(pkg);
|
|
204
|
-
if (!bumped || !pkg.version || bumped === pkg.version) continue;
|
|
205
|
-
pendingPackages.push({
|
|
206
|
-
name: pkg.name,
|
|
207
|
-
type: plan.type ?? "—",
|
|
208
|
-
from: pkg.version,
|
|
209
|
-
to: bumped,
|
|
210
|
-
distTag: plan.npm?.distTag
|
|
211
|
-
});
|
|
212
|
-
}
|
|
213
|
-
const requestChangelogs = draft.getChangelogs().filter((entry) => changelogFiles.has(entry.filename));
|
|
214
|
-
if (pendingPackages.length > 0) {
|
|
215
|
-
lines.push("#### Release preview", "", "| Package | Bump | Version |", "| --- | --- | --- |");
|
|
216
|
-
for (const { name, type, from, to, distTag } of pendingPackages) lines.push(`| \`${name}\` | ${type} | \`${from}\` → \`${to}\`${formatNpmDistTag(distTag)} |`);
|
|
217
|
-
lines.push("");
|
|
218
|
-
}
|
|
219
|
-
if (requestChangelogs.length > 0) {
|
|
220
|
-
lines.push("#### Changelogs in this MR", "", "| Changelog | Title |", "| --- | --- |");
|
|
221
|
-
for (const entry of requestChangelogs) for (const section of entry.sections) lines.push(`| \`${entry.filename}\` | ${section.title} |`);
|
|
222
|
-
lines.push("");
|
|
223
|
-
} else if (pendingPackages.length === 0) lines.push("#### No changelogs yet", "", "This MR has no pending changelog files. If your changes require a release, add a changelog before merging.", "");
|
|
224
|
-
else if (changelogFiles.size === 0) lines.push("This MR does not add changelog files. Pending changelogs from other branches are included in the preview above.", "");
|
|
225
|
-
lines.push(`Run \`${tegamiCommand}\` locally to create a changelog interactively.`, "", `<sub>Managed by [Tegami](https://tegami.fuma-nama.dev).</sub>`, "");
|
|
226
|
-
return lines.join("\n");
|
|
186
|
+
return formatPreview(context, draft, await listMergeRequestChangelogFiles(context, mergeRequest.baseSha, mergeRequest.headSha), {
|
|
187
|
+
"create-a-changelog-href": createChangelogUrl(context, mergeRequest.headRepo, mergeRequest.headRef, changelogFilename()),
|
|
188
|
+
pr: "MR"
|
|
189
|
+
});
|
|
227
190
|
}
|
|
228
191
|
async function postMrComment(context, body, options = {}) {
|
|
229
192
|
const { repo, apiUrl, token } = context.gitlab;
|
package/dist/plugins/go.d.ts
CHANGED
package/dist/plugins/go.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { a as isNodeError, n as execFailure, r as fetchFailure } from "../error-CAsrGb6e.js";
|
|
2
|
-
import { n as _validateReport, t as _createStandardSchema } from "../_createStandardSchema-
|
|
3
|
-
import { n as WorkspacePackage } from "../graph-
|
|
2
|
+
import { n as _validateReport, t as _createStandardSchema } from "../_createStandardSchema-CrRqJgaE.js";
|
|
3
|
+
import { n as WorkspacePackage } from "../graph-DaJ28Y4f.js";
|
|
4
4
|
import { relative, resolve } from "node:path";
|
|
5
5
|
import { x } from "tinyexec";
|
|
6
6
|
import * as semver$1 from "semver";
|
package/dist/providers/npm.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { C as
|
|
1
|
+
import { C as NpmGraph, S as DependencySpec, l as NpmPluginOptions, u as npm, w as NpmPackage } from "../types-Kj7Nxbjz.js";
|
|
2
2
|
export { type DependencySpec, type NpmGraph, NpmPackage, NpmPluginOptions, npm };
|
package/dist/providers/npm.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { n as NpmPackage, t as npm } from "../npm-
|
|
1
|
+
import { n as NpmPackage, t as npm } from "../npm-uJA8deYA.js";
|
|
2
2
|
export { NpmPackage, npm };
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { o as maxBump } from "./semver-DrtaCCZK.js";
|
|
2
2
|
import { i as handlePluginError, l as somePromise } from "./error-CAsrGb6e.js";
|
|
3
|
-
import { t as _accessExpressionAsString } from "./_accessExpressionAsString-
|
|
4
|
-
import { n as _validateReport, t as _createStandardSchema } from "./_createStandardSchema-
|
|
5
|
-
import { n as validateChangelogFrontmatter, t as
|
|
3
|
+
import { t as _accessExpressionAsString } from "./_accessExpressionAsString-DW_6Xqcp.js";
|
|
4
|
+
import { n as _validateReport, t as _createStandardSchema } from "./_createStandardSchema-CrRqJgaE.js";
|
|
5
|
+
import { n as renderChangelog, r as validateChangelogFrontmatter, t as getPackageBumps } from "./shared-pTOZU5UZ.js";
|
|
6
6
|
import { simpleGenerator } from "./generators/simple.js";
|
|
7
|
-
import { t as _assertGuard } from "./_assertGuard-
|
|
7
|
+
import { t as _assertGuard } from "./_assertGuard-CFFC1Up9.js";
|
|
8
8
|
import fs, { mkdir, readFile, readdir, rm, writeFile } from "node:fs/promises";
|
|
9
9
|
import path, { basename, dirname, join } from "node:path";
|
|
10
10
|
import * as semver$1 from "semver";
|
|
@@ -450,13 +450,7 @@ var Draft = class {
|
|
|
450
450
|
}
|
|
451
451
|
addChangelog(entry) {
|
|
452
452
|
this.changelogs.set(entry.id, entry);
|
|
453
|
-
const
|
|
454
|
-
const groupPackages = /* @__PURE__ */ new Map();
|
|
455
|
-
for (const [name, config] of entry.packages) {
|
|
456
|
-
if (!config.type) continue;
|
|
457
|
-
for (const pkg of graph.getByName(name)) groupPackages.set(pkg, config.type);
|
|
458
|
-
}
|
|
459
|
-
for (const [pkg, bumpType] of groupPackages) attachChangelog(this.bumpPackage(pkg, { type: bumpType }), entry);
|
|
453
|
+
for (const [pkg, bumpType] of getPackageBumps(this.context.graph, entry)) attachChangelog(this.bumpPackage(pkg, { type: bumpType }), entry);
|
|
460
454
|
}
|
|
461
455
|
deleteChangelog(id) {
|
|
462
456
|
return this.changelogs.delete(id);
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { inc, parse } from "semver";
|
|
1
|
+
import { diff, inc, parse } from "semver";
|
|
2
2
|
//#region src/utils/semver.ts
|
|
3
3
|
function formatNpmDistTag(distTag) {
|
|
4
4
|
return distTag && distTag !== "latest" ? ` (${distTag})` : "";
|
|
@@ -11,8 +11,11 @@ function formatPackageVersion(name, version, distTag) {
|
|
|
11
11
|
}
|
|
12
12
|
const WEIGHTS = {
|
|
13
13
|
major: 3,
|
|
14
|
+
premajor: 3,
|
|
14
15
|
minor: 2,
|
|
15
|
-
|
|
16
|
+
preminor: 2,
|
|
17
|
+
patch: 1,
|
|
18
|
+
prepatch: 1
|
|
16
19
|
};
|
|
17
20
|
const DEPTH = {
|
|
18
21
|
major: 1,
|
|
@@ -24,6 +27,15 @@ const PRE = {
|
|
|
24
27
|
minor: "preminor",
|
|
25
28
|
patch: "prepatch"
|
|
26
29
|
};
|
|
30
|
+
function diffWeight(from, to) {
|
|
31
|
+
const d = diff(from, to);
|
|
32
|
+
if (!d) return 0;
|
|
33
|
+
switch (d) {
|
|
34
|
+
case "release":
|
|
35
|
+
case "prerelease": return 4;
|
|
36
|
+
default: return WEIGHTS[d];
|
|
37
|
+
}
|
|
38
|
+
}
|
|
27
39
|
function maxBump(a, b) {
|
|
28
40
|
if (WEIGHTS[a] > WEIGHTS[b]) return a;
|
|
29
41
|
return b;
|
|
@@ -45,4 +57,4 @@ function bumpVersion(version, type, prerelease) {
|
|
|
45
57
|
return next;
|
|
46
58
|
}
|
|
47
59
|
//#endregion
|
|
48
|
-
export {
|
|
60
|
+
export { formatPackageVersion as a, formatNpmDistTag as i, bumpVersion as n, maxBump as o, diffWeight as r, bumpDepth as t };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { t as _accessExpressionAsString } from "./_accessExpressionAsString-
|
|
2
|
-
import { n as _validateReport, t as _createStandardSchema } from "./_createStandardSchema-
|
|
1
|
+
import { t as _accessExpressionAsString } from "./_accessExpressionAsString-DW_6Xqcp.js";
|
|
2
|
+
import { n as _validateReport, t as _createStandardSchema } from "./_createStandardSchema-CrRqJgaE.js";
|
|
3
3
|
import { stringify } from "yaml";
|
|
4
4
|
//#region src/changelog/shared.ts
|
|
5
5
|
const validateChangelogFrontmatter = (() => {
|
|
@@ -111,5 +111,13 @@ function renderChangelog(frontmatter, body) {
|
|
|
111
111
|
""
|
|
112
112
|
].join("\n");
|
|
113
113
|
}
|
|
114
|
+
function getPackageBumps(graph, entry) {
|
|
115
|
+
const packageBumps = /* @__PURE__ */ new Map();
|
|
116
|
+
for (const [name, config] of entry.packages) {
|
|
117
|
+
if (!config.type) continue;
|
|
118
|
+
for (const pkg of graph.getByName(name)) packageBumps.set(pkg, config.type);
|
|
119
|
+
}
|
|
120
|
+
return packageBumps;
|
|
121
|
+
}
|
|
114
122
|
//#endregion
|
|
115
|
-
export {
|
|
123
|
+
export { renderChangelog as n, validateChangelogFrontmatter as r, getPackageBumps as t };
|
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
import { AgentName } from "package-manager-detector";
|
|
2
|
-
|
|
3
1
|
//#region src/utils/semver.d.ts
|
|
4
2
|
type BumpType = "major" | "minor" | "patch";
|
|
5
3
|
//#endregion
|
|
@@ -183,7 +181,7 @@ interface PackageDraft {
|
|
|
183
181
|
/** npm dist-tag used when publishing. */distTag?: string;
|
|
184
182
|
};
|
|
185
183
|
/** get the bumped version of a package, return `undefined` if the package doesn't have a `version` field */
|
|
186
|
-
bumpVersion: (pkg: WorkspacePackage) => string | undefined;
|
|
184
|
+
bumpVersion: (pkg: WorkspacePackage$1) => string | undefined;
|
|
187
185
|
}
|
|
188
186
|
/** a draft describes all operations to perform before the actual publishing, such as version bumps. */
|
|
189
187
|
declare class Draft {
|
|
@@ -197,15 +195,15 @@ declare class Draft {
|
|
|
197
195
|
constructor(context: TegamiContext);
|
|
198
196
|
getPackageDrafts(): Map<string, PackageDraft>;
|
|
199
197
|
getPackageDraft(id: string): PackageDraft | undefined;
|
|
200
|
-
bumpPackage(pkg: WorkspacePackage, {
|
|
198
|
+
bumpPackage(pkg: WorkspacePackage$1, {
|
|
201
199
|
type,
|
|
202
200
|
reason
|
|
203
201
|
}: {
|
|
204
202
|
type: BumpType;
|
|
205
203
|
reason?: string;
|
|
206
204
|
}): PackageDraft;
|
|
207
|
-
dispatchPackage(pkg: WorkspacePackage, dispatch: (draft: PackageDraft) => void, onUpdate?: (draft: PackageDraft) => void): PackageDraft;
|
|
208
|
-
getOrInitPackage(pkg: WorkspacePackage): PackageDraft;
|
|
205
|
+
dispatchPackage(pkg: WorkspacePackage$1, dispatch: (draft: PackageDraft) => void, onUpdate?: (draft: PackageDraft) => void): PackageDraft;
|
|
206
|
+
getOrInitPackage(pkg: WorkspacePackage$1): PackageDraft;
|
|
209
207
|
hasPending(): boolean;
|
|
210
208
|
/** get all changelogs, note that this includes replay-only changelogs, as long as they are in the `.tegami` folder. */
|
|
211
209
|
getChangelogs(): ChangelogEntry[];
|
|
@@ -229,13 +227,13 @@ interface DraftPolicy {
|
|
|
229
227
|
id: string;
|
|
230
228
|
onUpdate?: (this: Draft, opts: {
|
|
231
229
|
packageDraft: PackageDraft;
|
|
232
|
-
pkg: WorkspacePackage;
|
|
230
|
+
pkg: WorkspacePackage$1;
|
|
233
231
|
}) => void;
|
|
234
232
|
}
|
|
235
233
|
//#endregion
|
|
236
234
|
//#region src/graph.d.ts
|
|
237
235
|
/** Package discovered in the workspace. */
|
|
238
|
-
declare abstract class WorkspacePackage {
|
|
236
|
+
declare abstract class WorkspacePackage$1 {
|
|
239
237
|
abstract readonly name: string;
|
|
240
238
|
/** absolute path */
|
|
241
239
|
abstract readonly path: string;
|
|
@@ -258,7 +256,7 @@ declare abstract class WorkspacePackage {
|
|
|
258
256
|
interface PackageGroup {
|
|
259
257
|
name: string;
|
|
260
258
|
options: GroupOptions;
|
|
261
|
-
packages: WorkspacePackage[];
|
|
259
|
+
packages: WorkspacePackage$1[];
|
|
262
260
|
}
|
|
263
261
|
/**
|
|
264
262
|
* Unified graph for discovered workspace packages.
|
|
@@ -269,14 +267,14 @@ interface PackageGroup {
|
|
|
269
267
|
declare class PackageGraph {
|
|
270
268
|
private readonly packages;
|
|
271
269
|
private readonly groups;
|
|
272
|
-
constructor(packages?: WorkspacePackage[]);
|
|
273
|
-
getPackages(): WorkspacePackage[];
|
|
270
|
+
constructor(packages?: WorkspacePackage$1[]);
|
|
271
|
+
getPackages(): WorkspacePackage$1[];
|
|
274
272
|
/** Get a package by exact id. */
|
|
275
|
-
get(id: string): WorkspacePackage | undefined;
|
|
273
|
+
get(id: string): WorkspacePackage$1 | undefined;
|
|
276
274
|
/** Get packages by id, `group:name`, or every package matching a name. */
|
|
277
|
-
getByName(nameOrId: string): WorkspacePackage[];
|
|
275
|
+
getByName(nameOrId: string): WorkspacePackage$1[];
|
|
278
276
|
/** scan package into graph, if the package id already exists, replace the existing one in graph */
|
|
279
|
-
add(pkg: WorkspacePackage): void;
|
|
277
|
+
add(pkg: WorkspacePackage$1): void;
|
|
280
278
|
delete(id: string): void;
|
|
281
279
|
getPackageGroup(pkgId: string): PackageGroup | undefined;
|
|
282
280
|
getGroups(): PackageGroup[];
|
|
@@ -287,6 +285,10 @@ declare class PackageGraph {
|
|
|
287
285
|
unregisterGroup(name: string): void;
|
|
288
286
|
}
|
|
289
287
|
//#endregion
|
|
288
|
+
//#region ../../node_modules/.pnpm/package-manager-detector@1.7.0/node_modules/package-manager-detector/dist/shared/package-manager-detector.CqsrLAro.d.mts
|
|
289
|
+
type Agent = 'npm' | 'yarn' | 'yarn@berry' | 'pnpm' | 'pnpm@6' | 'bun' | 'deno' | 'nub' | 'aube';
|
|
290
|
+
type AgentName = 'npm' | 'yarn' | 'pnpm' | 'bun' | 'deno' | 'nub' | 'aube';
|
|
291
|
+
//#endregion
|
|
290
292
|
//#region src/plugins/gitlab/api.d.ts
|
|
291
293
|
interface GitLabToken {
|
|
292
294
|
value: string;
|
|
@@ -371,7 +373,7 @@ interface ResolvedDependency {
|
|
|
371
373
|
range?: string;
|
|
372
374
|
setRange?: (v: string) => void;
|
|
373
375
|
}
|
|
374
|
-
declare class CargoPackage extends WorkspacePackage {
|
|
376
|
+
declare class CargoPackage extends WorkspacePackage$1 {
|
|
375
377
|
readonly path: string;
|
|
376
378
|
/** a crate must have `package` field defined, otherwise it is merely a virutal workspace file, and Tegami should not include it. */
|
|
377
379
|
readonly file: CargoToml<RequireFields<CargoManifest, "package">>;
|
|
@@ -415,7 +417,7 @@ interface CargoGraph {
|
|
|
415
417
|
}
|
|
416
418
|
//#endregion
|
|
417
419
|
//#region src/providers/npm/graph.d.ts
|
|
418
|
-
declare class NpmPackage extends WorkspacePackage {
|
|
420
|
+
declare class NpmPackage extends WorkspacePackage$1 {
|
|
419
421
|
readonly path: string;
|
|
420
422
|
readonly manifest: PackageManifest;
|
|
421
423
|
readonly manager = "npm";
|
|
@@ -523,6 +525,7 @@ interface TegamiContext {
|
|
|
523
525
|
};
|
|
524
526
|
/** additional context when npm plugin is configured */
|
|
525
527
|
npm?: {
|
|
528
|
+
agent: Agent;
|
|
526
529
|
client: AgentName; /** available after resolve */
|
|
527
530
|
graph?: NpmGraph;
|
|
528
531
|
};
|
|
@@ -633,6 +636,7 @@ interface GenerateChangelogOptions extends GenerateFromCommitsOptions {
|
|
|
633
636
|
*/
|
|
634
637
|
write?: boolean;
|
|
635
638
|
}
|
|
639
|
+
declare const WorkspacePackage: typeof WorkspacePackage$1;
|
|
636
640
|
interface Tegami {
|
|
637
641
|
/** Create pending changelog files from git commit history. */
|
|
638
642
|
generateChangelog(options?: GenerateChangelogOptions): Promise<CommitChangelog[]>;
|
|
@@ -746,7 +750,7 @@ declare function npm({
|
|
|
746
750
|
/** Generates changelog content for a package release. */
|
|
747
751
|
interface LogGenerator {
|
|
748
752
|
generate(this: TegamiContext, opts: {
|
|
749
|
-
pkg: WorkspacePackage;
|
|
753
|
+
pkg: WorkspacePackage$1;
|
|
750
754
|
packageDraft: PackageDraft;
|
|
751
755
|
draft: Draft;
|
|
752
756
|
}): string | Promise<string>;
|
|
@@ -761,7 +765,7 @@ interface TegamiOptions<Groups extends string = string> {
|
|
|
761
765
|
/** Changelog generator used when applying a draft. */
|
|
762
766
|
generator?: LogGenerator;
|
|
763
767
|
/** Per-package options keyed by package name or a function. */
|
|
764
|
-
packages?: Record<string, PackageOptions<NoInfer<Groups>>> | ((pkg: WorkspacePackage) => PackageOptions<NoInfer<Groups>> | undefined);
|
|
768
|
+
packages?: Record<string, PackageOptions<NoInfer<Groups>>> | ((pkg: WorkspacePackage$1) => PackageOptions<NoInfer<Groups>> | undefined);
|
|
765
769
|
plugins?: TegamiPluginOption[];
|
|
766
770
|
groups?: Record<Groups, GroupOptions>;
|
|
767
771
|
/** Package names, ids, or regex patterns to exclude from the dependency graph. */
|
|
@@ -840,7 +844,7 @@ interface TegamiPlugin {
|
|
|
840
844
|
* If multiple plugins return preflight data for the same package, only the first plugin will be considered.
|
|
841
845
|
*/
|
|
842
846
|
publishPreflight?(this: TegamiContext, opts: {
|
|
843
|
-
pkg: WorkspacePackage;
|
|
847
|
+
pkg: WorkspacePackage$1;
|
|
844
848
|
plan: PublishPlan;
|
|
845
849
|
}): Awaitable<PublishPreflight | void | undefined>;
|
|
846
850
|
/** Called when all preflights finished */
|
|
@@ -849,7 +853,7 @@ interface TegamiPlugin {
|
|
|
849
853
|
}): Awaitable<void>;
|
|
850
854
|
/** Publish package, return a result object indicating if the package is published, skipped, or failed. Return `undefined` if the package is not handled by this plugin. */
|
|
851
855
|
publish?(this: TegamiContext, opts: {
|
|
852
|
-
pkg: WorkspacePackage;
|
|
856
|
+
pkg: WorkspacePackage$1;
|
|
853
857
|
plan: PublishPlan;
|
|
854
858
|
}): Promise<PackagePublishResult | undefined | void>;
|
|
855
859
|
/**
|
|
@@ -866,11 +870,11 @@ interface TegamiPlugin {
|
|
|
866
870
|
}): Awaitable<void>;
|
|
867
871
|
/** Called before a package will be published, return `false` to prevent from publishing. */
|
|
868
872
|
willPublish?(this: TegamiContext, opts: {
|
|
869
|
-
pkg: WorkspacePackage;
|
|
873
|
+
pkg: WorkspacePackage$1;
|
|
870
874
|
}): Awaitable<false | void | undefined>;
|
|
871
875
|
/** Called after a package is published successfully, or failed. */
|
|
872
876
|
afterPublish?(this: TegamiContext, opts: {
|
|
873
|
-
pkg: WorkspacePackage;
|
|
877
|
+
pkg: WorkspacePackage$1;
|
|
874
878
|
plan: PublishPlan;
|
|
875
879
|
}): Awaitable<void>;
|
|
876
880
|
/** Called after all publishing finishes. */
|
|
@@ -905,4 +909,4 @@ interface PublishPreflight {
|
|
|
905
909
|
optionalWait?: string[];
|
|
906
910
|
}
|
|
907
911
|
//#endregion
|
|
908
|
-
export {
|
|
912
|
+
export { type PackageGroup as A, type NpmGraph as C, type CargoPluginOptions as D, CargoPackage as E, BumpType as F, Draft as M, DraftPolicy as N, cargo as O, PackageDraft as P, DependencySpec as S, CargoGraph as T, PackagePublishResult as _, type PublishPreflight as a, type CommitChangelog as b, type TegamiPluginOption as c, type GenerateChangelogOptions as d, Tegami as f, PackagePublishPlan as g, PublishLock as h, PackageOptions as i, WorkspacePackage$1 as j, PackageGraph as k, NpmPluginOptions as l, tegami as m, GroupOptions as n, TegamiOptions as o, WorkspacePackage as p, LogGenerator as r, TegamiPlugin as s, Awaitable as t, npm as u, PublishOptions as v, NpmPackage as w, TegamiContext as x, PublishPlan as y };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { M as Draft, h as PublishLock, t as Awaitable, x as TegamiContext, y as PublishPlan } from "./types-Kj7Nxbjz.js";
|
|
2
2
|
|
|
3
3
|
//#region src/utils/version-request.d.ts
|
|
4
4
|
interface VersionRequestOptions {
|
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { i as formatNpmDistTag, r as diffWeight } from "./semver-DrtaCCZK.js";
|
|
2
2
|
import { n as execFailure, s as isCI } from "./error-CAsrGb6e.js";
|
|
3
|
-
import { t as _accessExpressionAsString } from "./_accessExpressionAsString-
|
|
4
|
-
import { n as _validateReport, t as _createStandardSchema } from "./_createStandardSchema-
|
|
5
|
-
import {
|
|
3
|
+
import { t as _accessExpressionAsString } from "./_accessExpressionAsString-DW_6Xqcp.js";
|
|
4
|
+
import { n as _validateReport, t as _createStandardSchema } from "./_createStandardSchema-CrRqJgaE.js";
|
|
5
|
+
import { t as getPackageBumps } from "./shared-pTOZU5UZ.js";
|
|
6
|
+
import { o as PublishLock, r as runPreflights, s as parsePublishLock, t as initPublishPlan } from "./publish-BEYIILK5.js";
|
|
6
7
|
import { mkdtemp, readFile, rm, writeFile } from "node:fs/promises";
|
|
7
8
|
import { join, relative } from "node:path";
|
|
8
9
|
import { x } from "tinyexec";
|
|
@@ -164,10 +165,15 @@ function onVersionRequest(provider) {
|
|
|
164
165
|
getPreviousVersion: (id) => snapshots.get(id)
|
|
165
166
|
};
|
|
166
167
|
const custom = await config.create?.call(this, ctx);
|
|
167
|
-
const
|
|
168
|
+
const resolved = {
|
|
169
|
+
title: custom?.title ?? (publishGroup ? `Release ${packages.map((pkg) => `${pkg.name} (${pkg.manager})`).join(", ")}` : "Version Packages"),
|
|
170
|
+
body: custom?.body ?? renderRequestBody(this, ctx),
|
|
171
|
+
head: branch,
|
|
172
|
+
base: config.base
|
|
173
|
+
};
|
|
168
174
|
if (publishGroup) {
|
|
169
175
|
parent ??= await resolveHead(this.cwd);
|
|
170
|
-
baseLock ??=
|
|
176
|
+
baseLock ??= parsePublishLock(await readFile(this.lockPath, "utf8"));
|
|
171
177
|
const newGroups = {};
|
|
172
178
|
for (const req of requests) {
|
|
173
179
|
if (!req.publishGroup) continue;
|
|
@@ -180,21 +186,11 @@ function onVersionRequest(provider) {
|
|
|
180
186
|
parent,
|
|
181
187
|
store: { groups: newGroups }
|
|
182
188
|
});
|
|
183
|
-
tasks.push(provider.upsert(this,
|
|
184
|
-
title,
|
|
185
|
-
body: custom?.body ?? renderRequestBody(this, ctx),
|
|
186
|
-
head: branch,
|
|
187
|
-
base: config.base
|
|
188
|
-
}, !inSync));
|
|
189
|
+
tasks.push(provider.upsert(this, resolved, !inSync));
|
|
189
190
|
continue;
|
|
190
191
|
}
|
|
191
192
|
await pushBranch(this.cwd, branch);
|
|
192
|
-
await provider.upsert(this,
|
|
193
|
-
title,
|
|
194
|
-
body: custom?.body ?? renderRequestBody(this, ctx),
|
|
195
|
-
head: branch,
|
|
196
|
-
base: config.base
|
|
197
|
-
}, true);
|
|
193
|
+
await provider.upsert(this, resolved, true);
|
|
198
194
|
}
|
|
199
195
|
await Promise.all(tasks);
|
|
200
196
|
},
|
|
@@ -261,7 +257,7 @@ function onVersionRequest(provider) {
|
|
|
261
257
|
};
|
|
262
258
|
}
|
|
263
259
|
function renderRequestBody(ctx, { draft, getPreviousVersion, plan }) {
|
|
264
|
-
const
|
|
260
|
+
const bumpedPackages = [];
|
|
265
261
|
const changelogLines = [];
|
|
266
262
|
const publishLines = [];
|
|
267
263
|
const changesets = /* @__PURE__ */ new Map();
|
|
@@ -274,19 +270,31 @@ function renderRequestBody(ctx, { draft, getPreviousVersion, plan }) {
|
|
|
274
270
|
else changesets.set(changelog, [pkg]);
|
|
275
271
|
}
|
|
276
272
|
const from = getPreviousVersion(id);
|
|
277
|
-
if (!from || from === pkg.version) continue;
|
|
278
|
-
|
|
273
|
+
if (!from || !pkg.version || from === pkg.version) continue;
|
|
274
|
+
bumpedPackages.push({
|
|
275
|
+
name: pkg.name,
|
|
276
|
+
from,
|
|
277
|
+
to: pkg.version,
|
|
278
|
+
diff: diffWeight(from, pkg.version)
|
|
279
|
+
});
|
|
279
280
|
}
|
|
281
|
+
const packageLines = bumpedPackages.sort((a, b) => b.diff - a.diff).map(({ name, from, to }) => `| \`${name}\` | \`${from}\` | \`${to}\` |`);
|
|
280
282
|
for (const [entry, linkedPackages] of changesets) {
|
|
281
|
-
|
|
282
|
-
changelogLines.push("<details>", `<summary>Show Bumped Packages (${linkedPackages.length})</summary>`, "",
|
|
283
|
+
const bumps = getPackageBumps(ctx.graph, entry);
|
|
284
|
+
changelogLines.push(`### ${entry.subject ?? `\`${entry.filename}\``}`, "", "<details>", `<summary>Show Bumped Packages (${linkedPackages.length})</summary>`, "", "| Package | Bump |", "| --- | --- |");
|
|
285
|
+
for (const pkg of linkedPackages) changelogLines.push(`| \`${pkg.id}\` | ${bumps.get(pkg) ?? ""} |`);
|
|
286
|
+
changelogLines.push("", "</details>", "");
|
|
283
287
|
for (const section of entry.sections) {
|
|
284
288
|
changelogLines.push(`#### ${section.title}`, "");
|
|
285
289
|
if (section.content) changelogLines.push(section.content);
|
|
286
290
|
}
|
|
287
291
|
}
|
|
288
|
-
if (plan) {
|
|
289
|
-
|
|
292
|
+
if (plan) for (const [id, { preflight, npm }] of plan.packages) {
|
|
293
|
+
if (!preflight.shouldPublish) continue;
|
|
294
|
+
const pkg = ctx.graph.get(id);
|
|
295
|
+
let pm = "";
|
|
296
|
+
if (npm?.distTag) pm += ` (dist-tag: ${npm.distTag})`;
|
|
297
|
+
publishLines.push(`| \`${pkg.name}\` | \`${pkg.version}\`${pm} | \`${pkg.manager}\` |`);
|
|
290
298
|
}
|
|
291
299
|
const sections = [
|
|
292
300
|
"## Summary",
|
|
@@ -296,7 +304,7 @@ function renderRequestBody(ctx, { draft, getPreviousVersion, plan }) {
|
|
|
296
304
|
];
|
|
297
305
|
if (packageLines.length > 0) sections.push("| Package | From | To |", "| --- | --- | --- |", ...packageLines);
|
|
298
306
|
if (changelogLines.length > 0) sections.push("", "## Changelogs", ...changelogLines);
|
|
299
|
-
if (publishLines.length > 0) sections.push("", "## Publish", "", "The following packages will be published if merged:", ...publishLines);
|
|
307
|
+
if (publishLines.length > 0) sections.push("", "## Publish", "", "The following packages will be published if merged:", "", "| Package | Version | Registry |", "| --- | --- | --- |", ...publishLines);
|
|
300
308
|
sections.push("");
|
|
301
309
|
return sections.join("\n");
|
|
302
310
|
}
|
|
@@ -423,5 +431,43 @@ function publishGroupId(members) {
|
|
|
423
431
|
if (slugs.length === 0) slugs.push("group");
|
|
424
432
|
return slugs.join("-");
|
|
425
433
|
}
|
|
434
|
+
function formatPreview({ graph, npm }, draft, newChangelogNames, labels) {
|
|
435
|
+
const pendingPackages = [];
|
|
436
|
+
const lines = [
|
|
437
|
+
"### Tegami",
|
|
438
|
+
"",
|
|
439
|
+
`This repository uses [Tegami](https://tegami.fuma-nama.dev) to manage releases. When your changes affect published packages, add a changelog file under \`.tegami/\` before merging.`,
|
|
440
|
+
"",
|
|
441
|
+
`[**Create a changelog →**](${labels["create-a-changelog-href"]}) · [Changelog format](https://tegami.fuma-nama.dev/changelog)`,
|
|
442
|
+
""
|
|
443
|
+
];
|
|
444
|
+
for (const pkg of graph.getPackages()) {
|
|
445
|
+
const plan = draft.getPackageDraft(pkg.id);
|
|
446
|
+
if (!plan) continue;
|
|
447
|
+
const bumped = plan.bumpVersion(pkg);
|
|
448
|
+
if (!bumped || !pkg.version || bumped === pkg.version) continue;
|
|
449
|
+
pendingPackages.push({
|
|
450
|
+
name: pkg.name,
|
|
451
|
+
type: plan.type ?? "—",
|
|
452
|
+
from: pkg.version,
|
|
453
|
+
to: bumped,
|
|
454
|
+
distTag: plan.npm?.distTag
|
|
455
|
+
});
|
|
456
|
+
}
|
|
457
|
+
if (pendingPackages.length > 0) {
|
|
458
|
+
lines.push("#### Release preview", "", "| Package | Bump | Version |", "| --- | --- | --- |");
|
|
459
|
+
for (const { name, type, from, to, distTag } of pendingPackages.sort((a, b) => diffWeight(b.from, b.to) - diffWeight(a.from, a.to))) lines.push(`| \`${name}\` | ${type} | \`${from}\` → \`${to}\`${formatNpmDistTag(distTag)} |`);
|
|
460
|
+
lines.push("");
|
|
461
|
+
}
|
|
462
|
+
const newChangelogs = draft.getChangelogs().filter((entry) => newChangelogNames.has(entry.filename));
|
|
463
|
+
if (newChangelogs.length > 0) {
|
|
464
|
+
lines.push(`#### Changelogs in this ${labels.pr}`, "", "| Changelog | Title |", "| --- | --- |");
|
|
465
|
+
for (const entry of newChangelogs) for (const section of entry.sections) lines.push(`| \`${entry.filename}\` | ${section.title} |`);
|
|
466
|
+
lines.push("");
|
|
467
|
+
} else if (pendingPackages.length === 0) lines.push("#### No changelogs yet", "", `This ${labels.pr} has no pending changelog files. If your changes require a release, add a changelog before merging.`, "");
|
|
468
|
+
else if (newChangelogNames.size === 0) lines.push(`This ${labels.pr} does not add changelog files. Pending changelogs from other branches are included in the preview above.`, "");
|
|
469
|
+
lines.push(`Run \`${npm?.client ?? "npm"} run tegami\` locally to create a changelog interactively.`, "", `<sub>Managed by [Tegami](https://tegami.fuma-nama.dev).</sub>`, "");
|
|
470
|
+
return lines.join("\n");
|
|
471
|
+
}
|
|
426
472
|
//#endregion
|
|
427
|
-
export { onVersionRequest as t };
|
|
473
|
+
export { onVersionRequest as n, formatPreview as t };
|