tegami 0.1.5 → 0.2.0
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/api-D-jf_8xY.js +116 -0
- package/dist/cli/index.d.ts +4 -4
- package/dist/cli/index.js +124 -133
- package/dist/{checks-Cwz-Ezkq.js → generate-BMlrn-2e.js} +18 -106
- package/dist/generators/simple.d.ts +1 -1
- package/dist/generators/simple.js +3 -3
- package/dist/{graph-DLKPUXSD.js → graph-DrzluXw8.js} +17 -10
- package/dist/index.d.ts +2 -2
- package/dist/index.js +317 -210
- package/dist/plugins/git.d.ts +1 -1
- package/dist/plugins/git.js +47 -35
- package/dist/plugins/github.d.ts +28 -15
- package/dist/plugins/github.js +158 -142
- package/dist/providers/cargo.d.ts +2 -2
- package/dist/providers/cargo.js +86 -100
- package/dist/providers/npm.d.ts +2 -2
- package/dist/providers/npm.js +132 -129
- package/dist/schemas-B7N6EE2k.js +26 -0
- package/dist/{types-BXk2fMqa.d.ts → types-CurHqnWl.d.ts} +199 -226
- package/package.json +6 -7
- package/dist/schemas-CurBAaW5.js +0 -42
package/dist/plugins/git.d.ts
CHANGED
package/dist/plugins/git.js
CHANGED
|
@@ -9,12 +9,15 @@ import { x } from "tinyexec";
|
|
|
9
9
|
*/
|
|
10
10
|
function git(options = {}) {
|
|
11
11
|
const { createTags = true, pushTags = isCI() } = options;
|
|
12
|
-
function
|
|
13
|
-
const
|
|
14
|
-
|
|
15
|
-
const
|
|
16
|
-
|
|
17
|
-
|
|
12
|
+
function getPendingTags(plan) {
|
|
13
|
+
const pendingTags = /* @__PURE__ */ new Set();
|
|
14
|
+
if ((plan.options.dryRun ?? false) || !createTags) return pendingTags;
|
|
15
|
+
for (const pkg of plan.packages.values()) {
|
|
16
|
+
if (pkg.publishResult.type !== "published") continue;
|
|
17
|
+
const tag = pkg.git?.tag;
|
|
18
|
+
if (tag) pendingTags.add(tag);
|
|
19
|
+
}
|
|
20
|
+
return pendingTags;
|
|
18
21
|
}
|
|
19
22
|
return {
|
|
20
23
|
name: "git",
|
|
@@ -35,39 +38,48 @@ function git(options = {}) {
|
|
|
35
38
|
if (result.exitCode !== 0) throw execFailure("Failed to configure git user for GitHub Actions.", result);
|
|
36
39
|
}
|
|
37
40
|
} },
|
|
38
|
-
|
|
39
|
-
const {
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
41
|
+
initPublishPlan({ plan }) {
|
|
42
|
+
const { graph } = this;
|
|
43
|
+
for (const [id, packagePlan] of plan.packages) {
|
|
44
|
+
const pkg = graph.get(id);
|
|
45
|
+
const group = pkg && graph.getPackageGroup(pkg.id);
|
|
46
|
+
let tag;
|
|
47
|
+
if (group?.options.syncGitTag) tag = `${group.name}@${pkg.version}`;
|
|
48
|
+
else tag = `${pkg.name}@${pkg.version}`;
|
|
49
|
+
packagePlan.git = { tag };
|
|
46
50
|
}
|
|
51
|
+
},
|
|
52
|
+
async resolvePlanStatus({ plan }) {
|
|
53
|
+
const pendingTags = getPendingTags(plan);
|
|
54
|
+
if (pendingTags.size === 0) return;
|
|
47
55
|
try {
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
if (await gitTagExists(cwd, tag)) return;
|
|
51
|
-
const gitOut = await x("git", ["tag", tag], { nodeOptions: { cwd } });
|
|
52
|
-
if (gitOut.exitCode !== 0) throw execFailure(`Failed to create Git tag "${tag}" for release`, gitOut);
|
|
53
|
-
createdTags.push(tag);
|
|
56
|
+
await Promise.all(Array.from(pendingTags, async (tag) => {
|
|
57
|
+
if (!await gitTagExists(this.cwd, tag)) throw "pending";
|
|
54
58
|
}));
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
};
|
|
59
|
+
} catch (e) {
|
|
60
|
+
if (e === "pending") return "pending";
|
|
61
|
+
throw e;
|
|
62
|
+
}
|
|
63
|
+
},
|
|
64
|
+
async afterPublishAll({ plan }) {
|
|
65
|
+
const { cwd } = this;
|
|
66
|
+
const createdTags = [];
|
|
67
|
+
const pendingTags = getPendingTags(plan);
|
|
68
|
+
if (pendingTags.size === 0) return;
|
|
69
|
+
await Promise.all(Array.from(pendingTags, async (tag) => {
|
|
70
|
+
if (await gitTagExists(cwd, tag)) return;
|
|
71
|
+
const gitOut = await x("git", ["tag", tag], { nodeOptions: { cwd } });
|
|
72
|
+
if (gitOut.exitCode !== 0) throw execFailure(`Failed to create Git tag "${tag}" for release`, gitOut);
|
|
73
|
+
createdTags.push(tag);
|
|
74
|
+
}));
|
|
75
|
+
if (pushTags && createdTags.length > 0) {
|
|
76
|
+
const gitOut = await x("git", [
|
|
77
|
+
"push",
|
|
78
|
+
"origin",
|
|
79
|
+
...createdTags
|
|
80
|
+
], { nodeOptions: { cwd } });
|
|
81
|
+
if (gitOut.exitCode !== 0) throw execFailure(`Failed to push Git tags to origin: ${createdTags.join(", ")}`, gitOut);
|
|
69
82
|
}
|
|
70
|
-
return result;
|
|
71
83
|
}
|
|
72
84
|
};
|
|
73
85
|
}
|
package/dist/plugins/github.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { D as WorkspacePackage, O as Draft, S as PublishPlan, s as TegamiPlugin, t as Awaitable, w as TegamiContext } from "../types-CurHqnWl.js";
|
|
2
2
|
import { GitPluginOptions } from "./git.js";
|
|
3
3
|
|
|
4
4
|
//#region src/plugins/github.d.ts
|
|
@@ -35,6 +35,10 @@ interface VersionPullRequestOptions {
|
|
|
35
35
|
* @default "main"
|
|
36
36
|
*/
|
|
37
37
|
base?: string;
|
|
38
|
+
/** Override details for "Version Packages" PR. */
|
|
39
|
+
create?: (this: TegamiContext, opts: {
|
|
40
|
+
draft: Draft;
|
|
41
|
+
}) => Awaitable<VersionPullRequest>;
|
|
38
42
|
}
|
|
39
43
|
/** Options for creating GitHub releases after a successful publish. */
|
|
40
44
|
interface GitHubPluginOptions extends GitPluginOptions {
|
|
@@ -43,25 +47,34 @@ interface GitHubPluginOptions extends GitPluginOptions {
|
|
|
43
47
|
/** Optional GitHub token for Git & GitHub operations. */
|
|
44
48
|
token?: string;
|
|
45
49
|
/**
|
|
46
|
-
* Create GitHub release
|
|
50
|
+
* Create GitHub release for published packages.
|
|
47
51
|
*
|
|
48
|
-
* @default
|
|
52
|
+
* @default true
|
|
49
53
|
*/
|
|
50
|
-
|
|
51
|
-
/** Override release details for a single package, return `false` to skip. */
|
|
52
|
-
onCreateRelease?: (this: TegamiContext, result: PackagePublishResult) => Awaitable<GithubRelease | false>;
|
|
53
|
-
/** Override release details when multiple packages share a git tag, return `false` to skip. */
|
|
54
|
-
onCreateGroupedRelease?: (this: TegamiContext, packages: PackagePublishResult[]) => Awaitable<GithubRelease | false>;
|
|
55
|
-
/** Override details for "Version Packages" PR. */
|
|
56
|
-
onCreateVersionPullRequest?: (this: TegamiContext, publishPlan: DraftPlan) => Awaitable<VersionPullRequest | false>;
|
|
57
|
-
cli?: {
|
|
54
|
+
release?: boolean | {
|
|
58
55
|
/**
|
|
59
|
-
*
|
|
60
|
-
*
|
|
61
|
-
*
|
|
56
|
+
* Create GitHub release immediately after successful publish, without waiting for others.
|
|
57
|
+
*
|
|
58
|
+
* @default false
|
|
62
59
|
*/
|
|
63
|
-
|
|
60
|
+
eager?: boolean; /** Override release details for a single package. */
|
|
61
|
+
create?: (this: TegamiContext, opts: {
|
|
62
|
+
tag: string;
|
|
63
|
+
pkg: WorkspacePackage;
|
|
64
|
+
plan: PublishPlan;
|
|
65
|
+
}) => Awaitable<GithubRelease>; /** Override release details when multiple packages share a git tag. */
|
|
66
|
+
createGrouped?: (this: TegamiContext, opts: {
|
|
67
|
+
tag: string;
|
|
68
|
+
packages: WorkspacePackage[];
|
|
69
|
+
plan: PublishPlan;
|
|
70
|
+
}) => Awaitable<GithubRelease>;
|
|
64
71
|
};
|
|
72
|
+
/**
|
|
73
|
+
* (CLI only) Open a version pull request after versioning.
|
|
74
|
+
*
|
|
75
|
+
* Defaults to enabled in CI and disabled locally.
|
|
76
|
+
*/
|
|
77
|
+
versionPr?: VersionPullRequestOptions | false;
|
|
65
78
|
}
|
|
66
79
|
/** Create GitHub releases for successfully published packages after the whole plan succeeds. */
|
|
67
80
|
declare function github(options?: GitHubPluginOptions): TegamiPlugin[];
|
package/dist/plugins/github.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { i as formatPackageVersion, r as formatNpmDistTag } from "../semver-C4vJ4SK8.js";
|
|
2
2
|
import { a as isCI, n as execFailure } from "../error-DNy8R5ue.js";
|
|
3
|
+
import { a as findOpenPullRequest, l as updatePullRequest, n as createPullRequest, r as createRelease, s as releaseExistsByTag } from "../api-D-jf_8xY.js";
|
|
3
4
|
import { git } from "./git.js";
|
|
4
5
|
import { join, relative } from "node:path";
|
|
5
6
|
import { x } from "tinyexec";
|
|
@@ -7,53 +8,27 @@ import { prerelease } from "semver";
|
|
|
7
8
|
//#region src/plugins/github.ts
|
|
8
9
|
/** Create GitHub releases for successfully published packages after the whole plan succeeds. */
|
|
9
10
|
function github(options = {}) {
|
|
10
|
-
const {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
"create",
|
|
15
|
-
gitTag,
|
|
16
|
-
"--title",
|
|
17
|
-
title,
|
|
18
|
-
"--notes",
|
|
19
|
-
notes
|
|
20
|
-
];
|
|
21
|
-
if (repo) args.push("--repo", repo);
|
|
22
|
-
if (prerelease) args.push("--prerelease");
|
|
23
|
-
const result = await x("gh", args);
|
|
24
|
-
if (result.exitCode !== 0) throw execFailure(`Failed to create GitHub release for ${gitTag}.`, result);
|
|
25
|
-
}
|
|
26
|
-
async function createRelease(context, pkg) {
|
|
27
|
-
if (!pkg.gitTag || pkg.state === "failed") return;
|
|
28
|
-
const release = await onCreateRelease?.call(context, pkg) ?? {};
|
|
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, context.github?.repo);
|
|
31
|
-
}
|
|
32
|
-
async function createGroupedRelease(context, packages) {
|
|
33
|
-
const primary = packages[0];
|
|
34
|
-
if (!primary?.gitTag) return;
|
|
35
|
-
if (packages.some((member) => member.state === "failed")) return;
|
|
36
|
-
const release = await onCreateGroupedRelease?.call(context, packages) ?? {};
|
|
37
|
-
if (release === false) return;
|
|
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);
|
|
11
|
+
const { release: releaseOptions = true } = options;
|
|
12
|
+
let renderer;
|
|
13
|
+
function getRenderer(context) {
|
|
14
|
+
return renderer ??= createChangelogRenderer(context);
|
|
39
15
|
}
|
|
40
16
|
function resolvePROptions() {
|
|
41
|
-
const
|
|
42
|
-
if (
|
|
43
|
-
if (
|
|
44
|
-
if (setting.forceCreate || isCI()) return [true, setting];
|
|
17
|
+
const config = options.versionPr ?? {};
|
|
18
|
+
if (config === false) return [false];
|
|
19
|
+
if (config.forceCreate || isCI()) return [true, config];
|
|
45
20
|
return [false];
|
|
46
21
|
}
|
|
47
22
|
function defaultVersionPRBody(draft, context) {
|
|
48
23
|
const packageLines = [];
|
|
49
24
|
for (const pkg of context.graph.getPackages()) {
|
|
50
|
-
const
|
|
51
|
-
if (!
|
|
25
|
+
const packageDraft = draft.getPackageDraft(pkg.id);
|
|
26
|
+
if (!packageDraft) continue;
|
|
52
27
|
const originalVersion = cliOriginalPackageVersions.get(pkg.id) ?? pkg.version;
|
|
53
28
|
if (originalVersion === pkg.version) continue;
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
packageLines.push(
|
|
29
|
+
let line = `- **${pkg.name}**: ${originalVersion} → ${pkg.version}`;
|
|
30
|
+
line += formatNpmDistTag(packageDraft.npm?.distTag);
|
|
31
|
+
packageLines.push(line);
|
|
57
32
|
}
|
|
58
33
|
const changelogLines = [];
|
|
59
34
|
for (const entry of draft.getChangelogs()) {
|
|
@@ -83,6 +58,74 @@ function github(options = {}) {
|
|
|
83
58
|
token: options.token ?? process.env.GITHUB_TOKEN ?? process.env.GH_TOKEN
|
|
84
59
|
};
|
|
85
60
|
},
|
|
61
|
+
async resolvePlanStatus({ plan }) {
|
|
62
|
+
const { repo, token } = this.github;
|
|
63
|
+
if (!repo || !token || releaseOptions === false) return;
|
|
64
|
+
const tags = groupPackagesByTag(this, plan);
|
|
65
|
+
try {
|
|
66
|
+
await Promise.all(Array.from(tags.keys(), async (tag) => {
|
|
67
|
+
if (!await releaseExistsByTag(repo, tag, token)) throw "pending";
|
|
68
|
+
}));
|
|
69
|
+
} catch (e) {
|
|
70
|
+
if (e === "pending") return "pending";
|
|
71
|
+
throw e;
|
|
72
|
+
}
|
|
73
|
+
},
|
|
74
|
+
async afterPublishAll({ plan }) {
|
|
75
|
+
const { repo, token } = this.github;
|
|
76
|
+
if (!repo || !token || releaseOptions === false) return;
|
|
77
|
+
const { eager = false, create, createGrouped } = releaseOptions === true ? {} : releaseOptions;
|
|
78
|
+
if (!eager) {
|
|
79
|
+
for (const pkg of plan.packages.values()) if (pkg.publishResult.type === "failed") return;
|
|
80
|
+
}
|
|
81
|
+
await Promise.all(Array.from(groupPackagesByTag(this, plan), async ([tag, packages]) => {
|
|
82
|
+
let hasFailed = false;
|
|
83
|
+
let hasPublished = false;
|
|
84
|
+
for (const member of packages) switch (plan.packages.get(member.id).publishResult.type) {
|
|
85
|
+
case "published":
|
|
86
|
+
hasPublished = true;
|
|
87
|
+
break;
|
|
88
|
+
case "failed":
|
|
89
|
+
hasFailed = true;
|
|
90
|
+
break;
|
|
91
|
+
}
|
|
92
|
+
if (hasFailed || !hasPublished) return;
|
|
93
|
+
if (await releaseExistsByTag(repo, tag, token)) return;
|
|
94
|
+
let release;
|
|
95
|
+
if (packages.length > 1) {
|
|
96
|
+
const overrides = await createGrouped?.call(this, {
|
|
97
|
+
tag,
|
|
98
|
+
packages,
|
|
99
|
+
plan
|
|
100
|
+
}) ?? {};
|
|
101
|
+
release = {
|
|
102
|
+
title: overrides.title ?? tag,
|
|
103
|
+
notes: overrides.notes ?? await defaultGroupedNotes(getRenderer(this), plan, packages),
|
|
104
|
+
prerelease: overrides.prerelease ?? packages.some((pkg) => prerelease(pkg.version) !== null)
|
|
105
|
+
};
|
|
106
|
+
} else {
|
|
107
|
+
const pkg = packages[0];
|
|
108
|
+
const overrides = await create?.call(this, {
|
|
109
|
+
tag,
|
|
110
|
+
pkg,
|
|
111
|
+
plan
|
|
112
|
+
}) ?? {};
|
|
113
|
+
const packagePlan = plan.packages.get(pkg.id);
|
|
114
|
+
release = {
|
|
115
|
+
title: overrides.title ?? formatPackageVersion(pkg.name, pkg.version, packagePlan?.npm?.distTag),
|
|
116
|
+
notes: overrides.notes ?? await defaultNotes(getRenderer(this), pkg, packagePlan),
|
|
117
|
+
prerelease: overrides.prerelease ?? prerelease(pkg.version) !== null
|
|
118
|
+
};
|
|
119
|
+
}
|
|
120
|
+
await createRelease(repo, {
|
|
121
|
+
tag,
|
|
122
|
+
title: release.title,
|
|
123
|
+
notes: release.notes,
|
|
124
|
+
prerelease: release.prerelease,
|
|
125
|
+
token
|
|
126
|
+
});
|
|
127
|
+
}));
|
|
128
|
+
},
|
|
86
129
|
cli: {
|
|
87
130
|
async init() {
|
|
88
131
|
if (!isCI()) return;
|
|
@@ -96,17 +139,16 @@ function github(options = {}) {
|
|
|
96
139
|
], { nodeOptions: { cwd: this.cwd } });
|
|
97
140
|
if (result.exitCode !== 0) throw execFailure("Failed to configure git remote for GitHub Actions.", result);
|
|
98
141
|
},
|
|
99
|
-
|
|
142
|
+
draftCreated() {
|
|
100
143
|
for (const pkg of this.graph.getPackages()) cliOriginalPackageVersions.set(pkg.id, pkg.version);
|
|
101
144
|
},
|
|
102
|
-
async
|
|
145
|
+
async draftApplied(draft) {
|
|
103
146
|
const { cwd } = this;
|
|
104
147
|
const [enabled, config] = resolvePROptions();
|
|
105
|
-
const repo = this.github?.repo;
|
|
106
148
|
if (!enabled || !await hasGitChanges(cwd)) return;
|
|
149
|
+
const repo = this.github?.repo;
|
|
107
150
|
const { branch = "tegami/version-packages", base = "main" } = config;
|
|
108
|
-
const basePR = await
|
|
109
|
-
if (basePR === false) return;
|
|
151
|
+
const basePR = await config.create?.call(this, { draft });
|
|
110
152
|
const pr = {
|
|
111
153
|
title: basePR?.title ?? "Version Packages",
|
|
112
154
|
body: basePR?.body ?? defaultVersionPRBody(draft, this)
|
|
@@ -134,124 +176,98 @@ function github(options = {}) {
|
|
|
134
176
|
branch
|
|
135
177
|
], gitOptions);
|
|
136
178
|
if (result.exitCode !== 0) throw execFailure("Failed to push the version branch to origin. Ensure `origin` is configured and you have push access.", result);
|
|
137
|
-
const
|
|
179
|
+
const token = this.github?.token;
|
|
180
|
+
if (!repo) return;
|
|
181
|
+
const openPr = await findOpenPullRequest(repo, branch, token);
|
|
138
182
|
if (openPr !== void 0) {
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
pr.title,
|
|
145
|
-
"--body",
|
|
146
|
-
pr.body
|
|
147
|
-
];
|
|
148
|
-
if (repo) editArgs.push("--repo", repo);
|
|
149
|
-
const editResult = await x("gh", editArgs);
|
|
150
|
-
if (editResult.exitCode !== 0) throw execFailure("Failed to update the version pull request.", editResult);
|
|
183
|
+
await updatePullRequest(repo, openPr, {
|
|
184
|
+
title: pr.title,
|
|
185
|
+
body: pr.body,
|
|
186
|
+
token
|
|
187
|
+
});
|
|
151
188
|
return;
|
|
152
189
|
}
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
"--head",
|
|
161
|
-
branch,
|
|
162
|
-
"--base",
|
|
163
|
-
base
|
|
164
|
-
];
|
|
165
|
-
if (repo) args.push("--repo", repo);
|
|
166
|
-
const prResult = await x("gh", args);
|
|
167
|
-
if (prResult.exitCode !== 0) throw execFailure("Failed to create the version pull request.", prResult);
|
|
190
|
+
await createPullRequest(repo, {
|
|
191
|
+
title: pr.title,
|
|
192
|
+
body: pr.body,
|
|
193
|
+
head: branch,
|
|
194
|
+
base,
|
|
195
|
+
token
|
|
196
|
+
});
|
|
168
197
|
}
|
|
169
|
-
},
|
|
170
|
-
async afterPublishAll(result) {
|
|
171
|
-
if (!eagerRelease && result.state === "failed") return;
|
|
172
|
-
if (result.state === "skipped") return;
|
|
173
|
-
for (const packages of groupPackagesByGitTag(result.packages).values()) if (packages.length > 1) await createGroupedRelease(this, packages);
|
|
174
|
-
else await createRelease(this, packages[0]);
|
|
175
198
|
}
|
|
176
199
|
}];
|
|
177
200
|
}
|
|
178
|
-
|
|
179
|
-
return (await x("git", ["status", "--porcelain"], { nodeOptions: { cwd } })).stdout.trim().length > 0;
|
|
180
|
-
}
|
|
181
|
-
async function findOpenPullRequest(branch, repo) {
|
|
182
|
-
const args = [
|
|
183
|
-
"pr",
|
|
184
|
-
"list",
|
|
185
|
-
"--head",
|
|
186
|
-
branch,
|
|
187
|
-
"--state",
|
|
188
|
-
"open",
|
|
189
|
-
"--json",
|
|
190
|
-
"number"
|
|
191
|
-
];
|
|
192
|
-
if (repo) args.push("--repo", repo);
|
|
193
|
-
const result = await x("gh", args);
|
|
194
|
-
if (result.exitCode !== 0) throw execFailure("Failed to check for an existing version pull request.", result);
|
|
195
|
-
return JSON.parse(result.stdout)[0]?.number;
|
|
196
|
-
}
|
|
197
|
-
function groupPackagesByGitTag(packages) {
|
|
201
|
+
function groupPackagesByTag({ graph }, plan) {
|
|
198
202
|
const groups = /* @__PURE__ */ new Map();
|
|
199
|
-
for (const
|
|
200
|
-
|
|
201
|
-
const
|
|
203
|
+
for (const [id, packagePlan] of plan.packages) {
|
|
204
|
+
const pkg = graph.get(id);
|
|
205
|
+
const tag = packagePlan.git?.tag;
|
|
206
|
+
if (!tag) continue;
|
|
207
|
+
const group = groups.get(tag);
|
|
202
208
|
if (group) group.push(pkg);
|
|
203
|
-
else groups.set(
|
|
209
|
+
else groups.set(tag, [pkg]);
|
|
204
210
|
}
|
|
205
211
|
return groups;
|
|
206
212
|
}
|
|
207
|
-
function
|
|
208
|
-
return
|
|
209
|
-
}
|
|
210
|
-
function defaultGroupedTitle(packages) {
|
|
211
|
-
const primary = packages[0];
|
|
212
|
-
const distTag = packages.every((pkg) => pkg.npm?.distTag === primary.npm?.distTag) ? primary.npm?.distTag : void 0;
|
|
213
|
-
return formatPackageVersion(primary.gitTag.slice(0, primary.gitTag.lastIndexOf("@")), primary.version, distTag);
|
|
214
|
-
}
|
|
215
|
-
function formatCommitLink(commit, repo) {
|
|
216
|
-
const short = commit.slice(0, 7);
|
|
217
|
-
if (!repo) return `\`${short}\``;
|
|
218
|
-
return `[${short}](https://github.com/${repo}/commit/${commit})`;
|
|
219
|
-
}
|
|
220
|
-
async function resolveChangelogEntryCommit(context, filename) {
|
|
221
|
-
const result = await x("git", [
|
|
222
|
-
"log",
|
|
223
|
-
"--diff-filter=A",
|
|
224
|
-
"-1",
|
|
225
|
-
"--format=%H",
|
|
226
|
-
"--",
|
|
227
|
-
relative(context.cwd, join(context.changelogDir, filename))
|
|
228
|
-
], { nodeOptions: { cwd: context.cwd } });
|
|
229
|
-
if (result.exitCode !== 0) return;
|
|
230
|
-
return result.stdout.trim() || void 0;
|
|
213
|
+
async function hasGitChanges(cwd) {
|
|
214
|
+
return (await x("git", ["status", "--porcelain"], { nodeOptions: { cwd } })).stdout.trim().length > 0;
|
|
231
215
|
}
|
|
232
|
-
|
|
233
|
-
const
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
216
|
+
function createChangelogRenderer(context) {
|
|
217
|
+
const cache = /* @__PURE__ */ new Map();
|
|
218
|
+
async function resolveFileCommit(filename) {
|
|
219
|
+
const result = await x("git", [
|
|
220
|
+
"log",
|
|
221
|
+
"--diff-filter=A",
|
|
222
|
+
"-1",
|
|
223
|
+
"--format=%H",
|
|
224
|
+
"--",
|
|
225
|
+
relative(context.cwd, join(context.changelogDir, filename))
|
|
226
|
+
], { nodeOptions: { cwd: context.cwd } });
|
|
227
|
+
if (result.exitCode !== 0) return;
|
|
228
|
+
return result.stdout.trim() || void 0;
|
|
229
|
+
}
|
|
230
|
+
function formatCommitLink(commit) {
|
|
231
|
+
const short = commit.slice(0, 7);
|
|
232
|
+
const repo = context.github?.repo;
|
|
233
|
+
if (!repo) return `\`${short}\``;
|
|
234
|
+
return `[${short}](https://github.com/${repo}/commit/${commit})`;
|
|
240
235
|
}
|
|
241
|
-
return
|
|
236
|
+
return async (entry) => {
|
|
237
|
+
let commitPromise = cache.get(entry.filename);
|
|
238
|
+
if (!commitPromise) {
|
|
239
|
+
commitPromise = resolveFileCommit(entry.filename);
|
|
240
|
+
cache.set(entry.filename, commitPromise);
|
|
241
|
+
}
|
|
242
|
+
const commit = await commitPromise;
|
|
243
|
+
const commitSuffix = commit ? ` (${formatCommitLink(commit)})` : "";
|
|
244
|
+
const lines = [];
|
|
245
|
+
for (const section of entry.sections) {
|
|
246
|
+
lines.push(`### ${section.title}${commitSuffix}`, "");
|
|
247
|
+
if (section.content) lines.push(section.content, "");
|
|
248
|
+
}
|
|
249
|
+
return lines.join("\n").trim();
|
|
250
|
+
};
|
|
242
251
|
}
|
|
243
|
-
async function defaultNotes(
|
|
244
|
-
if (
|
|
245
|
-
return `Published ${formatPackageVersion(pkg.name, pkg.version,
|
|
252
|
+
async function defaultNotes(renderer, pkg, packagePlan) {
|
|
253
|
+
if (packagePlan && packagePlan.changelogs.length > 0) return (await Promise.all(packagePlan.changelogs.map(renderer))).join("\n\n");
|
|
254
|
+
return `Published ${formatPackageVersion(pkg.name, pkg.version, packagePlan?.npm?.distTag)}.`;
|
|
246
255
|
}
|
|
247
|
-
async function defaultGroupedNotes(
|
|
256
|
+
async function defaultGroupedNotes(renderer, plan, packages) {
|
|
248
257
|
const changelogs = /* @__PURE__ */ new Map();
|
|
249
|
-
for (const pkg of packages)
|
|
250
|
-
|
|
258
|
+
for (const pkg of packages) {
|
|
259
|
+
const packagePlan = plan.packages.get(pkg.id);
|
|
260
|
+
if (!packagePlan) continue;
|
|
261
|
+
for (const entry of packagePlan.changelogs) changelogs.set(entry.id, entry);
|
|
262
|
+
}
|
|
263
|
+
const sections = [packages.map((pkg) => {
|
|
264
|
+
const packagePlan = plan.packages.get(pkg.id);
|
|
265
|
+
return `- ${formatPackageVersion(pkg.name, pkg.version, packagePlan?.npm?.distTag)}`;
|
|
266
|
+
}).join("\n")];
|
|
251
267
|
if (changelogs.size > 0) {
|
|
252
|
-
const notes = await Promise.all(Array.from(changelogs.values()
|
|
268
|
+
const notes = await Promise.all(Array.from(changelogs.values(), renderer));
|
|
253
269
|
sections.push("", notes.join("\n\n"));
|
|
254
|
-
}
|
|
270
|
+
}
|
|
255
271
|
return sections.join("\n");
|
|
256
272
|
}
|
|
257
273
|
//#endregion
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { d as
|
|
2
|
-
export { CargoPackage, CargoPluginOptions,
|
|
1
|
+
import { d as cargo, l as CargoPackage, u as CargoPluginOptions } from "../types-CurHqnWl.js";
|
|
2
|
+
export { CargoPackage, CargoPluginOptions, cargo };
|