@releasekit/notes 0.37.0 → 0.38.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.
@@ -3,8 +3,8 @@ import {
3
3
  detectMonorepo,
4
4
  splitByPackage,
5
5
  writeMonorepoChangelogs
6
- } from "./chunk-4ABTRCZA.js";
7
- import "./chunk-AUIBJ4MF.js";
6
+ } from "./chunk-SY2YT6H3.js";
7
+ import "./chunk-JIYLIQQ6.js";
8
8
  export {
9
9
  aggregateToRoot,
10
10
  detectMonorepo,
@@ -5,12 +5,13 @@ import {
5
5
  error,
6
6
  formatVersion,
7
7
  info,
8
+ parseGitHubOwnerRepo,
8
9
  setLogLevel,
9
10
  setQuietMode,
10
11
  success,
11
12
  warn,
12
13
  writeMarkdown
13
- } from "./chunk-AUIBJ4MF.js";
14
+ } from "./chunk-JIYLIQQ6.js";
14
15
 
15
16
  // ../config/dist/index.js
16
17
  import * as fs from "fs";
@@ -282,7 +283,10 @@ var ChangelogConfigSchema = z.object({
282
283
  "Where to write changelog files. root: repo root only. packages: per-package (monorepos). both: repo root and per-package. When omitted entirely (no changelog config), defaults to root."
283
284
  ),
284
285
  file: z.string().optional().describe("Changelog file name override (default: CHANGELOG.md)"),
285
- templates: TemplateConfigSchema.optional().describe("Template configuration for changelog")
286
+ templates: TemplateConfigSchema.optional().describe("Template configuration for changelog"),
287
+ refs: z.enum(["strip", "escape", "link"]).default("link").describe(
288
+ "How `#NNN` issue/PR refs in the changelog are rendered. 'link' (default): the PR and the issues it closed are labelled as `(PR #503 \xB7 closes #500)`, where the PR links to its canonical /pull/ URL with `PR #503` as the visible text \u2014 this keeps the GitHub hovercard but stops the bare-token rich inline card that duplicated the entry; closed issues link to /issues/. An entry with no identifiable PR (a non-squash commit, or a non-GitHub repo) falls back to a plain ref list. 'escape': plain text \\#NNN (no link, no hovercard, no PR/closes labelling). 'strip': refs are removed entirely. Scoped-package / @user mentions in entry text are always neutralised regardless of this setting."
289
+ )
286
290
  }).describe("Changelog file configuration");
287
291
  var LLMOptionsSchema = z.object({
288
292
  timeout: z.number().int().optional().describe("Request timeout in ms"),
@@ -781,6 +785,7 @@ function versionOutputToChangelogInput(data) {
781
785
  type: normalizeEntryType(entry.type),
782
786
  description: entry.description,
783
787
  issueIds: entry.issueIds,
788
+ prNumber: entry.prNumber,
784
789
  scope: entry.scope,
785
790
  originalType: entry.originalType,
786
791
  breaking: entry.breaking ?? entry.originalType?.includes("!") ?? false
@@ -2610,18 +2615,6 @@ async function withRetry(fn, options = {}) {
2610
2615
  }
2611
2616
 
2612
2617
  // src/core/pipeline.ts
2613
- function parseOwnerRepo(repoUrl) {
2614
- const scpMatch = repoUrl.match(/^git@github\.com:([^/]+)\/(.+?)(?:\.git)?$/);
2615
- if (scpMatch) return { owner: scpMatch[1], repo: scpMatch[2] };
2616
- try {
2617
- const url = new URL(repoUrl);
2618
- if (url.hostname !== "github.com") return null;
2619
- const parts = url.pathname.replace(/^\//, "").replace(/\.git$/, "").split("/");
2620
- if (parts.length >= 2) return { owner: parts[0], repo: parts[1] };
2621
- } catch {
2622
- }
2623
- return null;
2624
- }
2625
2618
  function findCompoundTagSepPos(tag) {
2626
2619
  let pos = tag.lastIndexOf("-");
2627
2620
  while (pos > 0) {
@@ -2849,7 +2842,7 @@ async function runPipeline(input, config, dryRun, pipelineOptions) {
2849
2842
  info("Processing with LLM enhancement");
2850
2843
  const examplesCount = llmConfig.examples ?? 3;
2851
2844
  const repoUrl = contexts[0]?.repoUrl ?? input.metadata?.repoUrl;
2852
- const ownerRepo = repoUrl ? parseOwnerRepo(repoUrl) : null;
2845
+ const ownerRepo = repoUrl ? parseGitHubOwnerRepo(repoUrl) : null;
2853
2846
  const examplesByPackage = /* @__PURE__ */ new Map();
2854
2847
  if (examplesCount > 0 && ownerRepo) {
2855
2848
  await Promise.all(
@@ -2906,7 +2899,8 @@ async function runPipeline(input, config, dryRun, pipelineOptions) {
2906
2899
  includePackageName: contexts.length > 1 || contexts.some((c) => c.packageName.includes("/")),
2907
2900
  categoryOrder: llmConfig?.categoryOrder,
2908
2901
  links: releaseNotesConfig?.links,
2909
- firstRelease: releaseNotesConfig?.firstRelease
2902
+ firstRelease: releaseNotesConfig?.firstRelease,
2903
+ refs: (changelogConfig !== false ? changelogConfig.refs : void 0) ?? "link"
2910
2904
  };
2911
2905
  if (!pipelineOptions?.skipChangelogs && changelogConfig !== false && changelogConfig.mode) {
2912
2906
  const fileName = changelogConfig.file ?? "CHANGELOG.md";
@@ -2928,7 +2922,13 @@ async function runPipeline(input, config, dryRun, pipelineOptions) {
2928
2922
  if (!dryRun) files.push(fileName);
2929
2923
  }
2930
2924
  if (mode === "packages" || mode === "both") {
2931
- const monoFiles = await writeMonorepoFiles(contexts, config, dryRun, changelogConfig.file ?? "CHANGELOG.md");
2925
+ const monoFiles = await writeMonorepoFiles(
2926
+ contexts,
2927
+ config,
2928
+ dryRun,
2929
+ changelogConfig.file ?? "CHANGELOG.md",
2930
+ fmtOpts.refs ?? "link"
2931
+ );
2932
2932
  files.push(...monoFiles);
2933
2933
  }
2934
2934
  } catch (error2) {
@@ -2939,7 +2939,7 @@ async function runPipeline(input, config, dryRun, pipelineOptions) {
2939
2939
  const dir = releaseNotesConfig.file.dir;
2940
2940
  info(`Generating release notes \u2192 ${dir}`);
2941
2941
  try {
2942
- const { detectMonorepo } = await import("./aggregator-BYOHELNX.js");
2942
+ const { detectMonorepo } = await import("./aggregator-GQ55YUGA.js");
2943
2943
  const nested = detectMonorepo(process.cwd()).isMonorepo || contexts.length > 1;
2944
2944
  const renderContent = (ctx) => {
2945
2945
  if (releaseNotesConfig.templates?.path) {
@@ -3000,8 +3000,8 @@ async function processInput(inputJson, config, dryRun, pipelineOptions) {
3000
3000
  const input = parseVersionOutput(inputJson);
3001
3001
  return runPipeline(input, config, dryRun, pipelineOptions);
3002
3002
  }
3003
- async function writeMonorepoFiles(contexts, config, dryRun, fileName) {
3004
- const { detectMonorepo, writeMonorepoChangelogs } = await import("./aggregator-BYOHELNX.js");
3003
+ async function writeMonorepoFiles(contexts, config, dryRun, fileName, refs) {
3004
+ const { detectMonorepo, writeMonorepoChangelogs } = await import("./aggregator-GQ55YUGA.js");
3005
3005
  const cwd = process.cwd();
3006
3006
  const detected = detectMonorepo(cwd);
3007
3007
  if (!detected.isMonorepo) return [];
@@ -3014,7 +3014,8 @@ async function writeMonorepoFiles(contexts, config, dryRun, fileName) {
3014
3014
  fileName
3015
3015
  },
3016
3016
  config,
3017
- dryRun
3017
+ dryRun,
3018
+ refs
3018
3019
  );
3019
3020
  return monoFiles;
3020
3021
  }
@@ -6,6 +6,43 @@ import * as path2 from "path";
6
6
  import { fileURLToPath } from "url";
7
7
  import chalk from "chalk";
8
8
  import { minimatch } from "minimatch";
9
+ function parseGitHubOwnerRepo(repoUrl) {
10
+ const scpMatch = repoUrl.match(/^git@github\.com:([^/]+)\/(.+?)(?:\.git)?$/);
11
+ if (scpMatch) return { owner: scpMatch[1], repo: scpMatch[2] };
12
+ try {
13
+ const url = new URL(repoUrl);
14
+ if (url.hostname !== "github.com") return null;
15
+ const parts = url.pathname.replace(/^\//, "").replace(/\.git$/, "").split("/");
16
+ if (parts.length >= 2 && parts[0] && parts[1]) return { owner: parts[0], repo: parts[1] };
17
+ } catch {
18
+ }
19
+ return null;
20
+ }
21
+ function renderIssueRefs(issueIds, mode, repoUrl, prNumber) {
22
+ if (mode === "strip") return "";
23
+ const ids = issueIds ?? [];
24
+ const allIds = prNumber && !ids.some((id) => Number(id.replace(/^#/, "")) === Number(prNumber.replace(/^#/, ""))) ? [prNumber, ...ids] : ids;
25
+ if (allIds.length === 0) return "";
26
+ const ownerRepo = mode === "link" && repoUrl ? parseGitHubOwnerRepo(repoUrl) : null;
27
+ if (ownerRepo && prNumber) {
28
+ const { owner, repo } = ownerRepo;
29
+ const pr = prNumber.replace(/^#/, "");
30
+ const prPart = `PR [#${pr}](https://github.com/${owner}/${repo}/pull/${pr})`;
31
+ const closes = allIds.map((raw) => raw.replace(/^#/, "")).filter((num) => Number(num) !== Number(pr));
32
+ if (closes.length === 0) return `(${prPart})`;
33
+ const closesPart = closes.map((num) => `[#${num}](https://github.com/${owner}/${repo}/issues/${num})`).join(", ");
34
+ return `(${prPart} \xB7 closes ${closesPart})`;
35
+ }
36
+ const rendered = allIds.map((raw) => {
37
+ const num = raw.replace(/^#/, "");
38
+ return ownerRepo ? `[#${num}](https://github.com/${ownerRepo.owner}/${ownerRepo.repo}/issues/${num})` : `\\#${num}`;
39
+ }).join(", ");
40
+ return rendered ? `(${rendered})` : "";
41
+ }
42
+ var CODE_SPAN_OR_MENTION = /`[^`]*`|(?<![0-9A-Za-z_@\\/])@[A-Za-z0-9][A-Za-z0-9-]*(?:\/[A-Za-z0-9._-]+)?/g;
43
+ function escapeChangelogMentions(text) {
44
+ return text.replace(CODE_SPAN_OR_MENTION, (match) => match.startsWith("`") ? match : `\\${match}`);
45
+ }
9
46
  function readPackageVersion(importMetaUrl) {
10
47
  try {
11
48
  const dir = path2.dirname(fileURLToPath(importMetaUrl));
@@ -138,26 +175,30 @@ function groupEntriesByType(entries) {
138
175
  return grouped;
139
176
  }
140
177
  function formatEntry(entry, opts) {
178
+ const description = escapeChangelogMentions(entry.description);
179
+ const scope = entry.scope ? escapeChangelogMentions(entry.scope) : void 0;
180
+ const leadIn = entry.leadIn ? escapeChangelogMentions(entry.leadIn) : void 0;
141
181
  let line;
142
- if (entry.leadIn && entry.breaking) {
143
- line = `- **BREAKING** **${entry.leadIn}**: ${entry.description}`;
144
- } else if (entry.leadIn) {
145
- line = `- **${entry.leadIn}**: ${entry.description}`;
146
- } else if (entry.breaking && entry.scope && !opts?.hideScope) {
147
- line = `- **BREAKING** **${entry.scope}**: ${entry.description}`;
182
+ if (leadIn && entry.breaking) {
183
+ line = `- **BREAKING** **${leadIn}**: ${description}`;
184
+ } else if (leadIn) {
185
+ line = `- **${leadIn}**: ${description}`;
186
+ } else if (entry.breaking && scope && !opts?.hideScope) {
187
+ line = `- **BREAKING** **${scope}**: ${description}`;
148
188
  } else if (entry.breaking) {
149
- line = `- **BREAKING** ${entry.description}`;
150
- } else if (entry.scope && !opts?.hideScope) {
151
- line = `- **${entry.scope}**: ${entry.description}`;
189
+ line = `- **BREAKING** ${description}`;
190
+ } else if (scope && !opts?.hideScope) {
191
+ line = `- **${scope}**: ${description}`;
152
192
  } else {
153
- line = `- ${entry.description}`;
193
+ line = `- ${description}`;
154
194
  }
155
- if (entry.issueIds && entry.issueIds.length > 0) {
156
- line += ` (${entry.issueIds.join(", ")})`;
195
+ const refs = renderIssueRefs(entry.issueIds ?? [], opts?.refs ?? "link", opts?.repoUrl ?? null, entry.prNumber);
196
+ if (refs) {
197
+ line += ` ${refs}`;
157
198
  }
158
199
  return line;
159
200
  }
160
- function formatCategorySection(name, entries) {
201
+ function formatCategorySection(name, entries, refOpts) {
161
202
  const lines = [];
162
203
  lines.push(`### ${name}`);
163
204
  const scopeCounts = /* @__PURE__ */ new Map();
@@ -170,7 +211,7 @@ function formatCategorySection(name, entries) {
170
211
  }
171
212
  if (groupedScopes.size === 0) {
172
213
  for (const entry of entries) {
173
- lines.push(formatEntry(entry));
214
+ lines.push(formatEntry(entry, refOpts));
174
215
  }
175
216
  } else {
176
217
  const byScope = /* @__PURE__ */ new Map();
@@ -186,13 +227,13 @@ function formatCategorySection(name, entries) {
186
227
  if (entry.scope && groupedScopes.has(entry.scope)) {
187
228
  if (!renderedScopes.has(entry.scope)) {
188
229
  renderedScopes.add(entry.scope);
189
- lines.push(`**${entry.scope}**:`);
230
+ lines.push(`**${escapeChangelogMentions(entry.scope)}**:`);
190
231
  for (const e of byScope.get(entry.scope) ?? []) {
191
- lines.push(formatEntry(e, { hideScope: true }));
232
+ lines.push(formatEntry(e, { ...refOpts, hideScope: true }));
192
233
  }
193
234
  }
194
235
  } else {
195
- lines.push(formatEntry(entry));
236
+ lines.push(formatEntry(entry, refOpts));
196
237
  }
197
238
  }
198
239
  }
@@ -291,6 +332,7 @@ function resolveLinks(entries, linksConfig) {
291
332
  }
292
333
  function formatVersion(context, options) {
293
334
  const lines = [];
335
+ const refOpts = { refs: options?.refs ?? "link", repoUrl: context.repoUrl };
294
336
  const versionLabel = options?.includePackageName && context.packageName ? `${context.packageName}@${context.version}` : context.version;
295
337
  const versionHeader = context.previousVersion ? `## [${versionLabel}]` : `## ${versionLabel}`;
296
338
  lines.push(`${versionHeader} - ${context.date}`);
@@ -313,7 +355,7 @@ function formatVersion(context, options) {
313
355
  categories = applyOrder(categories, options?.categoryOrder ?? []);
314
356
  for (const category of categories) {
315
357
  if (category.entries.length === 0) continue;
316
- lines.push(...formatCategorySection(category.name, category.entries));
358
+ lines.push(...formatCategorySection(category.name, category.entries, refOpts));
317
359
  }
318
360
  const links = resolveLinks(context.entries, options?.links);
319
361
  if (links.length > 0) {
@@ -329,7 +371,7 @@ function formatVersion(context, options) {
329
371
  if (entries.length === 0) continue;
330
372
  lines.push(`### ${TYPE_LABELS[type]}`);
331
373
  for (const entry of entries) {
332
- lines.push(formatEntry(entry));
374
+ lines.push(formatEntry(entry, refOpts));
333
375
  }
334
376
  lines.push("");
335
377
  }
@@ -399,6 +441,7 @@ function writeMarkdown(outputPath, contexts, config, dryRun, options) {
399
441
  }
400
442
 
401
443
  export {
444
+ parseGitHubOwnerRepo,
402
445
  readPackageVersion,
403
446
  setLogLevel,
404
447
  setQuietMode,
@@ -5,7 +5,7 @@ import {
5
5
  prependVersion,
6
6
  renderMarkdown,
7
7
  success
8
- } from "./chunk-AUIBJ4MF.js";
8
+ } from "./chunk-JIYLIQQ6.js";
9
9
 
10
10
  // src/monorepo/aggregator.ts
11
11
  import * as fs from "fs";
@@ -54,11 +54,11 @@ function aggregateToRoot(contexts) {
54
54
  }
55
55
  return aggregated;
56
56
  }
57
- function writeMonorepoChangelogs(contexts, options, config, dryRun) {
57
+ function writeMonorepoChangelogs(contexts, options, config, dryRun, refs = "link") {
58
58
  const files = [];
59
59
  if (options.mode === "root" || options.mode === "both") {
60
60
  const rootPath = path.join(options.rootPath, options.fileName ?? "CHANGELOG.md");
61
- const fmtOpts = { includePackageName: true };
61
+ const fmtOpts = { includePackageName: true, refs };
62
62
  info(`Writing root changelog to ${rootPath}`);
63
63
  let rootContent;
64
64
  if (config.updateStrategy !== "regenerate" && fs.existsSync(rootPath)) {
@@ -89,7 +89,7 @@ ${existing.slice(headerEnd + 1)}`;
89
89
  if (packageDir) {
90
90
  const changelogPath = path.join(packageDir, options.fileName ?? "CHANGELOG.md");
91
91
  info(`Writing changelog for ${packageName} to ${changelogPath}`);
92
- const pkgContent = config.updateStrategy !== "regenerate" && fs.existsSync(changelogPath) ? prependVersion(changelogPath, ctx) : renderMarkdown([ctx]);
92
+ const pkgContent = config.updateStrategy !== "regenerate" && fs.existsSync(changelogPath) ? prependVersion(changelogPath, ctx, { refs }) : renderMarkdown([ctx], { refs });
93
93
  if (writeFile(changelogPath, pkgContent, dryRun)) {
94
94
  files.push(changelogPath);
95
95
  }
package/dist/cli.js CHANGED
@@ -1,10 +1,10 @@
1
1
  #!/usr/bin/env node
2
2
  import {
3
3
  createNotesCommand
4
- } from "./chunk-MZKMCO2M.js";
4
+ } from "./chunk-J2CKYTB2.js";
5
5
  import {
6
6
  readPackageVersion
7
- } from "./chunk-AUIBJ4MF.js";
7
+ } from "./chunk-JIYLIQQ6.js";
8
8
 
9
9
  // src/cli.ts
10
10
  import * as fs from "fs";
package/dist/index.js CHANGED
@@ -18,12 +18,12 @@ import {
18
18
  runPipeline,
19
19
  saveAuth,
20
20
  versionOutputToChangelogInput
21
- } from "./chunk-MZKMCO2M.js";
21
+ } from "./chunk-J2CKYTB2.js";
22
22
  import {
23
23
  aggregateToRoot,
24
24
  detectMonorepo,
25
25
  writeMonorepoChangelogs
26
- } from "./chunk-4ABTRCZA.js";
26
+ } from "./chunk-SY2YT6H3.js";
27
27
  import {
28
28
  debug,
29
29
  formatVersion,
@@ -31,7 +31,7 @@ import {
31
31
  renderMarkdown,
32
32
  success,
33
33
  writeMarkdown
34
- } from "./chunk-AUIBJ4MF.js";
34
+ } from "./chunk-JIYLIQQ6.js";
35
35
 
36
36
  // src/output/json.ts
37
37
  import * as fs from "fs";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@releasekit/notes",
3
- "version": "0.37.0",
3
+ "version": "0.38.0",
4
4
  "description": "Release notes and changelog generation with LLM-powered enhancement and flexible templating",
5
5
  "type": "module",
6
6
  "module": "./dist/index.js",
@@ -69,9 +69,9 @@
69
69
  "tsup": "^8.5.1",
70
70
  "typescript": "^5.9.3",
71
71
  "vitest": "^4.1.9",
72
- "@releasekit/config": "0.0.0",
73
- "@releasekit/core": "0.0.0",
74
72
  "@releasekit/forge": "0.0.0",
73
+ "@releasekit/core": "0.0.0",
74
+ "@releasekit/config": "0.0.0",
75
75
  "@releasekit/git": "0.0.0"
76
76
  },
77
77
  "engines": {