@releasekit/notes 0.37.0 → 0.38.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.
@@ -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-WTOR47NP.js";
7
+ import "./chunk-EWEPFCCT.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-EWEPFCCT.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. Applies to the whole entry \u2014 both the appended label and any bare `#N` carried over from the commit subject into the description (a description ref that also appears in the appended label is de-duplicated away). '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-74VELOCJ.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-74VELOCJ.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,60 @@ 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
+ }
46
+ var CODE_SPAN_OR_DESC_REF = /`[^`]*`|( ?)(?:\(#(\d+)\)|(?<![\\[/\w])#(\d+)\b)/g;
47
+ function neutralizeDescriptionRefs(text, appendedRefs, mode, repoUrl) {
48
+ const appended = new Set(appendedRefs.filter((r) => !!r).map((r) => Number(r.replace(/^#/, ""))));
49
+ const ownerRepo = mode === "link" && repoUrl ? parseGitHubOwnerRepo(repoUrl) : null;
50
+ const out = text.replace(
51
+ CODE_SPAN_OR_DESC_REF,
52
+ (match, lead, parenNum, bareNum) => {
53
+ const num = parenNum ?? bareNum;
54
+ if (num === void 0) return match;
55
+ const ws = lead ?? "";
56
+ if (appended.has(Number(num)) || mode === "strip") return "";
57
+ const inner = ownerRepo ? `[#${num}](https://github.com/${ownerRepo.owner}/${ownerRepo.repo}/issues/${num})` : `\\#${num}`;
58
+ return parenNum !== void 0 ? `${ws}(${inner})` : `${ws}${inner}`;
59
+ }
60
+ );
61
+ return out.trim();
62
+ }
9
63
  function readPackageVersion(importMetaUrl) {
10
64
  try {
11
65
  const dir = path2.dirname(fileURLToPath(importMetaUrl));
@@ -138,26 +192,34 @@ function groupEntriesByType(entries) {
138
192
  return grouped;
139
193
  }
140
194
  function formatEntry(entry, opts) {
195
+ const refsMode = opts?.refs ?? "link";
196
+ const appendedRefs = [...entry.issueIds ?? [], entry.prNumber];
197
+ const description = escapeChangelogMentions(
198
+ neutralizeDescriptionRefs(entry.description, appendedRefs, refsMode, opts?.repoUrl ?? null)
199
+ );
200
+ const scope = entry.scope ? escapeChangelogMentions(entry.scope) : void 0;
201
+ const leadIn = entry.leadIn ? escapeChangelogMentions(entry.leadIn) : void 0;
141
202
  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}`;
203
+ if (leadIn && entry.breaking) {
204
+ line = `- **BREAKING** **${leadIn}**: ${description}`;
205
+ } else if (leadIn) {
206
+ line = `- **${leadIn}**: ${description}`;
207
+ } else if (entry.breaking && scope && !opts?.hideScope) {
208
+ line = `- **BREAKING** **${scope}**: ${description}`;
148
209
  } else if (entry.breaking) {
149
- line = `- **BREAKING** ${entry.description}`;
150
- } else if (entry.scope && !opts?.hideScope) {
151
- line = `- **${entry.scope}**: ${entry.description}`;
210
+ line = `- **BREAKING** ${description}`;
211
+ } else if (scope && !opts?.hideScope) {
212
+ line = `- **${scope}**: ${description}`;
152
213
  } else {
153
- line = `- ${entry.description}`;
214
+ line = `- ${description}`;
154
215
  }
155
- if (entry.issueIds && entry.issueIds.length > 0) {
156
- line += ` (${entry.issueIds.join(", ")})`;
216
+ const refs = renderIssueRefs(entry.issueIds ?? [], refsMode, opts?.repoUrl ?? null, entry.prNumber);
217
+ if (refs) {
218
+ line += ` ${refs}`;
157
219
  }
158
220
  return line;
159
221
  }
160
- function formatCategorySection(name, entries) {
222
+ function formatCategorySection(name, entries, refOpts) {
161
223
  const lines = [];
162
224
  lines.push(`### ${name}`);
163
225
  const scopeCounts = /* @__PURE__ */ new Map();
@@ -170,7 +232,7 @@ function formatCategorySection(name, entries) {
170
232
  }
171
233
  if (groupedScopes.size === 0) {
172
234
  for (const entry of entries) {
173
- lines.push(formatEntry(entry));
235
+ lines.push(formatEntry(entry, refOpts));
174
236
  }
175
237
  } else {
176
238
  const byScope = /* @__PURE__ */ new Map();
@@ -186,13 +248,13 @@ function formatCategorySection(name, entries) {
186
248
  if (entry.scope && groupedScopes.has(entry.scope)) {
187
249
  if (!renderedScopes.has(entry.scope)) {
188
250
  renderedScopes.add(entry.scope);
189
- lines.push(`**${entry.scope}**:`);
251
+ lines.push(`**${escapeChangelogMentions(entry.scope)}**:`);
190
252
  for (const e of byScope.get(entry.scope) ?? []) {
191
- lines.push(formatEntry(e, { hideScope: true }));
253
+ lines.push(formatEntry(e, { ...refOpts, hideScope: true }));
192
254
  }
193
255
  }
194
256
  } else {
195
- lines.push(formatEntry(entry));
257
+ lines.push(formatEntry(entry, refOpts));
196
258
  }
197
259
  }
198
260
  }
@@ -291,6 +353,7 @@ function resolveLinks(entries, linksConfig) {
291
353
  }
292
354
  function formatVersion(context, options) {
293
355
  const lines = [];
356
+ const refOpts = { refs: options?.refs ?? "link", repoUrl: context.repoUrl };
294
357
  const versionLabel = options?.includePackageName && context.packageName ? `${context.packageName}@${context.version}` : context.version;
295
358
  const versionHeader = context.previousVersion ? `## [${versionLabel}]` : `## ${versionLabel}`;
296
359
  lines.push(`${versionHeader} - ${context.date}`);
@@ -313,7 +376,7 @@ function formatVersion(context, options) {
313
376
  categories = applyOrder(categories, options?.categoryOrder ?? []);
314
377
  for (const category of categories) {
315
378
  if (category.entries.length === 0) continue;
316
- lines.push(...formatCategorySection(category.name, category.entries));
379
+ lines.push(...formatCategorySection(category.name, category.entries, refOpts));
317
380
  }
318
381
  const links = resolveLinks(context.entries, options?.links);
319
382
  if (links.length > 0) {
@@ -329,7 +392,7 @@ function formatVersion(context, options) {
329
392
  if (entries.length === 0) continue;
330
393
  lines.push(`### ${TYPE_LABELS[type]}`);
331
394
  for (const entry of entries) {
332
- lines.push(formatEntry(entry));
395
+ lines.push(formatEntry(entry, refOpts));
333
396
  }
334
397
  lines.push("");
335
398
  }
@@ -399,6 +462,7 @@ function writeMarkdown(outputPath, contexts, config, dryRun, options) {
399
462
  }
400
463
 
401
464
  export {
465
+ parseGitHubOwnerRepo,
402
466
  readPackageVersion,
403
467
  setLogLevel,
404
468
  setQuietMode,
@@ -5,7 +5,7 @@ import {
5
5
  prependVersion,
6
6
  renderMarkdown,
7
7
  success
8
- } from "./chunk-AUIBJ4MF.js";
8
+ } from "./chunk-EWEPFCCT.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-2FU6P7SA.js";
5
5
  import {
6
6
  readPackageVersion
7
- } from "./chunk-AUIBJ4MF.js";
7
+ } from "./chunk-EWEPFCCT.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-2FU6P7SA.js";
22
22
  import {
23
23
  aggregateToRoot,
24
24
  detectMonorepo,
25
25
  writeMonorepoChangelogs
26
- } from "./chunk-4ABTRCZA.js";
26
+ } from "./chunk-WTOR47NP.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-EWEPFCCT.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.1",
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",