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