tegami 0.1.6 → 0.2.1

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-DEaKjB3O.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, filterPackage) {
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 (filterPackage && !filterPackage(pkg)) 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, (pkg) => pkg.preflight.publish);
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, (pkg) => pkg.publishResult.type === "published");
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-DEaKjB3O.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,82 @@ 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 requiredTags = /* @__PURE__ */ new Set();
65
+ for (const pkg of plan.packages.values()) if (pkg.preflight.publish && pkg.git) requiredTags.add(pkg.git.tag);
66
+ try {
67
+ await Promise.all(Array.from(requiredTags, async (tag) => {
68
+ if (!await releaseExistsByTag(repo, tag, token)) throw "pending";
69
+ }));
70
+ } catch (e) {
71
+ if (e === "pending") return "pending";
72
+ throw e;
73
+ }
74
+ },
75
+ async afterPublishAll({ plan }) {
76
+ const { repo, token } = this.github;
77
+ if (!repo || !token || releaseOptions === false) return;
78
+ const { eager = false, create, createGrouped } = releaseOptions === true ? {} : releaseOptions;
79
+ const groups = /* @__PURE__ */ new Map();
80
+ for (const [id, packagePlan] of plan.packages) {
81
+ const pkg = this.graph.get(id);
82
+ if (!eager && packagePlan.publishResult.type === "failed") return;
83
+ const tag = packagePlan.git?.tag;
84
+ if (!tag) continue;
85
+ const group = groups.get(tag);
86
+ if (group) group.push(pkg);
87
+ else groups.set(tag, [pkg]);
88
+ }
89
+ await Promise.all(Array.from(groups, async ([tag, packages]) => {
90
+ let hasFailed = false;
91
+ let hasPublished = false;
92
+ for (const member of packages) switch (plan.packages.get(member.id).publishResult.type) {
93
+ case "published":
94
+ hasPublished = true;
95
+ break;
96
+ case "failed":
97
+ hasFailed = true;
98
+ break;
99
+ }
100
+ if (hasFailed || !hasPublished) return;
101
+ if (await releaseExistsByTag(repo, tag, token)) return;
102
+ let release;
103
+ if (packages.length > 1) {
104
+ const overrides = await createGrouped?.call(this, {
105
+ tag,
106
+ packages,
107
+ plan
108
+ }) ?? {};
109
+ release = {
110
+ title: overrides.title ?? tag,
111
+ notes: overrides.notes ?? await defaultGroupedNotes(getRenderer(this), plan, packages),
112
+ prerelease: overrides.prerelease ?? packages.some((pkg) => prerelease(pkg.version) !== null)
113
+ };
114
+ } else {
115
+ const pkg = packages[0];
116
+ const overrides = await create?.call(this, {
117
+ tag,
118
+ pkg,
119
+ plan
120
+ }) ?? {};
121
+ const packagePlan = plan.packages.get(pkg.id);
122
+ release = {
123
+ title: overrides.title ?? formatPackageVersion(pkg.name, pkg.version, packagePlan?.npm?.distTag),
124
+ notes: overrides.notes ?? await defaultNotes(getRenderer(this), pkg, packagePlan),
125
+ prerelease: overrides.prerelease ?? prerelease(pkg.version) !== null
126
+ };
127
+ }
128
+ await createRelease(repo, {
129
+ tag,
130
+ title: release.title,
131
+ notes: release.notes,
132
+ prerelease: release.prerelease,
133
+ token
134
+ });
135
+ }));
136
+ },
78
137
  cli: {
79
138
  async init() {
80
139
  if (!isCI()) return;
@@ -88,17 +147,16 @@ function github(options = {}) {
88
147
  ], { nodeOptions: { cwd: this.cwd } });
89
148
  if (result.exitCode !== 0) throw execFailure("Failed to configure git remote for GitHub Actions.", result);
90
149
  },
91
- publishPlanCreated() {
150
+ draftCreated() {
92
151
  for (const pkg of this.graph.getPackages()) cliOriginalPackageVersions.set(pkg.id, pkg.version);
93
152
  },
94
- async publishPlanApplied(draft) {
153
+ async draftApplied(draft) {
95
154
  const { cwd } = this;
96
155
  const [enabled, config] = resolvePROptions();
97
- const repo = this.github?.repo;
98
156
  if (!enabled || !await hasGitChanges(cwd)) return;
157
+ const repo = this.github?.repo;
99
158
  const { branch = "tegami/version-packages", base = "main" } = config;
100
- const basePR = await onCreateVersionPullRequest?.call(this, draft);
101
- if (basePR === false) return;
159
+ const basePR = await config.create?.call(this, { draft });
102
160
  const pr = {
103
161
  title: basePR?.title ?? "Version Packages",
104
162
  body: basePR?.body ?? defaultVersionPRBody(draft, this)
@@ -126,148 +184,86 @@ function github(options = {}) {
126
184
  branch
127
185
  ], gitOptions);
128
186
  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);
187
+ const token = this.github?.token;
188
+ if (!repo) return;
189
+ const openPr = await findOpenPullRequest(repo, branch, token);
130
190
  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);
191
+ await updatePullRequest(repo, openPr, {
192
+ title: pr.title,
193
+ body: pr.body,
194
+ token
195
+ });
143
196
  return;
144
197
  }
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);
198
+ await createPullRequest(repo, {
199
+ title: pr.title,
200
+ body: pr.body,
201
+ head: branch,
202
+ base,
203
+ token
204
+ });
160
205
  }
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
206
  }
191
207
  }];
192
208
  }
193
209
  async function hasGitChanges(cwd) {
194
210
  return (await x("git", ["status", "--porcelain"], { nodeOptions: { cwd } })).stdout.trim().length > 0;
195
211
  }
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) {
213
- 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);
217
- if (group) group.push(pkg);
218
- else groups.set(pkg.git.tag, [pkg]);
212
+ function createChangelogRenderer(context) {
213
+ const cache = /* @__PURE__ */ new Map();
214
+ async function resolveFileCommit(filename) {
215
+ const result = await x("git", [
216
+ "log",
217
+ "--diff-filter=A",
218
+ "-1",
219
+ "--format=%H",
220
+ "--",
221
+ relative(context.cwd, join(context.changelogDir, filename))
222
+ ], { nodeOptions: { cwd: context.cwd } });
223
+ if (result.exitCode !== 0) return;
224
+ return result.stdout.trim() || void 0;
219
225
  }
220
- return groups;
221
- }
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;
247
- }
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, "");
226
+ function formatCommitLink(commit) {
227
+ const short = commit.slice(0, 7);
228
+ const repo = context.github?.repo;
229
+ if (!repo) return `\`${short}\``;
230
+ return `[${short}](https://github.com/${repo}/commit/${commit})`;
256
231
  }
257
- return lines.join("\n").trim();
232
+ return async (entry) => {
233
+ let commitPromise = cache.get(entry.filename);
234
+ if (!commitPromise) {
235
+ commitPromise = resolveFileCommit(entry.filename);
236
+ cache.set(entry.filename, commitPromise);
237
+ }
238
+ const commit = await commitPromise;
239
+ const commitSuffix = commit ? ` (${formatCommitLink(commit)})` : "";
240
+ const lines = [];
241
+ for (const section of entry.sections) {
242
+ lines.push(`### ${section.title}${commitSuffix}`, "");
243
+ if (section.content) lines.push(section.content, "");
244
+ }
245
+ return lines.join("\n").trim();
246
+ };
258
247
  }
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)}.`;
248
+ async function defaultNotes(renderer, pkg, packagePlan) {
249
+ if (packagePlan && packagePlan.changelogs.length > 0) return (await Promise.all(packagePlan.changelogs.map(renderer))).join("\n\n");
250
+ return `Published ${formatPackageVersion(pkg.name, pkg.version, packagePlan?.npm?.distTag)}.`;
262
251
  }
263
- async function defaultGroupedNotes(context, packages) {
252
+ async function defaultGroupedNotes(renderer, plan, packages) {
264
253
  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")];
254
+ for (const pkg of packages) {
255
+ const packagePlan = plan.packages.get(pkg.id);
256
+ if (!packagePlan) continue;
257
+ for (const entry of packagePlan.changelogs) changelogs.set(entry.id, entry);
258
+ }
259
+ const sections = [packages.map((pkg) => {
260
+ const packagePlan = plan.packages.get(pkg.id);
261
+ return `- ${formatPackageVersion(pkg.name, pkg.version, packagePlan?.npm?.distTag)}`;
262
+ }).join("\n")];
267
263
  if (changelogs.size > 0) {
268
- const notes = await Promise.all(Array.from(changelogs.values()).map((entry) => renderChangelogEntryNotes(context, entry)));
264
+ const notes = await Promise.all(Array.from(changelogs.values(), renderer));
269
265
  sections.push("", notes.join("\n\n"));
270
- } else sections.push("", `Published ${packages[0].git.tag}.`);
266
+ }
271
267
  return sections.join("\n");
272
268
  }
273
269
  //#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-DEaKjB3O.js";
2
+ export { CargoPackage, CargoPluginOptions, cargo };