@releasekit/notes 0.43.0 → 0.44.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/README.md CHANGED
@@ -57,45 +57,7 @@ releasekit-notes --input version-data.json \
57
57
 
58
58
  ## CLI Reference
59
59
 
60
- ### `releasekit-notes generate` (default)
61
-
62
- | Flag | Description | Default |
63
- |------|-------------|---------|
64
- | `-i, --input <file>` | Input file path | stdin |
65
- | `--changelog-mode <mode>` | Changelog location: `root`, `packages`, `both` | `root` |
66
- | `--changelog-file <name>` | Changelog file name override | `CHANGELOG.md` |
67
- | `--no-changelog` | Disable changelog generation | — |
68
- | `--release-notes-dir <dir>` | Write per-version release-notes files to this directory | — |
69
- | `--no-release-notes` | Disable release notes generation | — |
70
- | `-t, --template <path>` | Template file or directory | built-in |
71
- | `-e, --engine <engine>` | Template engine: `handlebars`, `liquid`, `ejs` | `liquid` |
72
- | `--monorepo <mode>` | Monorepo mode: `root`, `packages`, `both` | — |
73
- | `--llm-provider <name>` | LLM provider | — |
74
- | `--llm-model <model>` | LLM model | — |
75
- | `--llm-base-url <url>` | Base URL for openai-compatible providers | — |
76
- | `--llm-tasks <tasks>` | Comma-separated tasks: `enhance`, `summarize`, `categorize`, `release-notes` | — |
77
- | `--no-llm` | Disable LLM processing | — |
78
- | `--target <package>` | Filter to a specific package name | — |
79
- | `--config <path>` | Config file path | `releasekit.config.json` |
80
- | `--regenerate` | Regenerate entire file instead of prepending | `false` |
81
- | `--dry-run` | Preview without writing | `false` |
82
- | `-v, --verbose` | Verbose logging (repeat for more: `-vv`) | — |
83
- | `-q, --quiet` | Suppress non-error output | — |
84
-
85
- ### `releasekit-notes auth <provider>`
86
-
87
- Store an API key for an LLM provider.
88
-
89
- ```bash
90
- releasekit-notes auth openai
91
- releasekit-notes auth anthropic --key sk-ant-...
92
- ```
93
-
94
- Keys are saved to `~/.config/releasekit/auth.json`.
95
-
96
- ### `releasekit-notes providers`
97
-
98
- List available LLM providers.
60
+ The commands are in the [CLI reference](../../docs/cli.md#releasekit-notes): [`generate`](../../docs/cli.md#releasekit-notes-generate) (the default), [`auth`](../../docs/cli.md#releasekit-notes-auth-provider) and [`providers`](../../docs/cli.md#releasekit-notes-providers).
99
61
 
100
62
  ## Configuration
101
63
 
@@ -242,7 +204,7 @@ const result = await runPipeline(input, config, false);
242
204
  ## Documentation
243
205
 
244
206
  **Getting Started**
245
- - [Configuration reference](./docs/configuration.md) — all `notes.*` options
207
+ - [Configuration reference](../../docs/configuration.md#notes) — all `notes.*` options
246
208
  - [LLM providers](./docs/llm-providers.md) — provider setup, auth, tasks, prompt customisation
247
209
 
248
210
  **Guides**
@@ -2,8 +2,8 @@ import {
2
2
  aggregateToRoot,
3
3
  detectMonorepo,
4
4
  writeMonorepoChangelogs
5
- } from "./chunk-YNGSEWF6.js";
6
- import "./chunk-TNTTAFQ4.js";
5
+ } from "./chunk-ZY4HXAQV.js";
6
+ import "./chunk-ECBA67PM.js";
7
7
  export {
8
8
  aggregateToRoot,
9
9
  detectMonorepo,
@@ -8,6 +8,15 @@ import { fileURLToPath } from "url";
8
8
  import chalk from "chalk";
9
9
  import { minimatch } from "minimatch";
10
10
  import * as path3 from "path";
11
+ var CODE_SPAN_OR_COMMENT_OPEN = /(?<!(?<!\\)\\(?:\\\\)*)`[^`]*`|<!--/g;
12
+ function escapeCommentOpeners(text, opts) {
13
+ return text.replace(CODE_SPAN_OR_COMMENT_OPEN, (match) => {
14
+ if (!match.startsWith("`")) {
15
+ return "&lt;!--";
16
+ }
17
+ return opts?.keepCodeSpans ? match : match.replaceAll("<!--", "<!\u200B--");
18
+ });
19
+ }
11
20
  function parseGitHubOwnerRepo(repoUrl) {
12
21
  const [, scpOwner, scpRepo] = repoUrl.match(/^git@github\.com:([^/]+)\/(.+?)(?:\.git)?$/) ?? [];
13
22
  if (scpOwner && scpRepo) {
@@ -85,6 +94,71 @@ function removeDescriptionRefs(text, refs) {
85
94
  return num !== void 0 && remove.has(Number(num)) ? "" : match;
86
95
  }).trim();
87
96
  }
97
+ var BREAKING_SECTION = "Breaking";
98
+ var DEMOTED_SECTION = "Dependencies & version bumps";
99
+ var CHANGELOG_TYPE_LABELS = {
100
+ feat: "Added",
101
+ fix: "Fixed",
102
+ added: "Added",
103
+ changed: "Changed",
104
+ deprecated: "Deprecated",
105
+ removed: "Removed",
106
+ fixed: "Fixed",
107
+ perf: "Performance",
108
+ refactor: "Refactored",
109
+ security: "Security",
110
+ docs: "Documentation",
111
+ chore: "Chores",
112
+ test: "Tests",
113
+ build: "Build",
114
+ ci: "CI",
115
+ revert: "Reverts",
116
+ style: "Styles"
117
+ };
118
+ var CHANGELOG_LABEL_ORDER = [...new Set(Object.values(CHANGELOG_TYPE_LABELS))];
119
+ function changelogTypeLabel(type) {
120
+ return Object.hasOwn(CHANGELOG_TYPE_LABELS, type) ? CHANGELOG_TYPE_LABELS[type] : type.charAt(0).toUpperCase() + type.slice(1);
121
+ }
122
+ function groupChangelogSections(items, entryOf, { labelOrder = CHANGELOG_LABEL_ORDER, demoteScopes = [] } = {}) {
123
+ const demote = new Set(demoteScopes);
124
+ const breaking = [];
125
+ const demoted = [];
126
+ const byLabel = /* @__PURE__ */ new Map();
127
+ for (const item of items) {
128
+ const entry = entryOf(item);
129
+ if (entry.breaking) {
130
+ breaking.push(item);
131
+ } else if (entry.scope !== void 0 && demote.has(entry.scope)) {
132
+ demoted.push(item);
133
+ } else {
134
+ const label = changelogTypeLabel(entry.type);
135
+ const list = byLabel.get(label);
136
+ if (list) {
137
+ list.push(item);
138
+ } else {
139
+ byLabel.set(label, [item]);
140
+ }
141
+ }
142
+ }
143
+ const sections = [];
144
+ if (breaking.length > 0) {
145
+ sections.push({ label: BREAKING_SECTION, items: breaking });
146
+ }
147
+ for (const label of labelOrder) {
148
+ const list = byLabel.get(label);
149
+ if (list) {
150
+ sections.push({ label, items: list });
151
+ byLabel.delete(label);
152
+ }
153
+ }
154
+ for (const [label, list] of byLabel) {
155
+ sections.push({ label, items: list });
156
+ }
157
+ if (demoted.length > 0) {
158
+ sections.push({ label: DEMOTED_SECTION, items: demoted });
159
+ }
160
+ return sections;
161
+ }
88
162
  var LOG_LEVELS = {
89
163
  error: 0,
90
164
  warn: 1,
@@ -303,35 +377,15 @@ function firstReleaseLine(context, config) {
303
377
  const template = config?.text ?? DEFAULT_FIRST_RELEASE_TEXT;
304
378
  return template.replaceAll("${packageName}", context.packageName).replaceAll("${version}", context.version);
305
379
  }
306
- var TYPE_ORDER = ["added", "changed", "deprecated", "removed", "fixed", "security"];
307
- var TYPE_LABELS = {
308
- added: "Added",
309
- changed: "Changed",
310
- deprecated: "Deprecated",
311
- removed: "Removed",
312
- fixed: "Fixed",
313
- security: "Security"
314
- };
315
- function groupEntriesByType(entries) {
316
- const grouped = /* @__PURE__ */ new Map();
317
- for (const type of TYPE_ORDER) {
318
- grouped.set(type, []);
319
- }
320
- for (const entry of entries) {
321
- const existing = grouped.get(entry.type) ?? [];
322
- existing.push(entry);
323
- grouped.set(entry.type, existing);
324
- }
325
- return grouped;
380
+ var SECTION_ORDER = ["Added", "Changed", "Deprecated", "Removed", "Fixed", "Security"];
381
+ function escapeCommitText(text) {
382
+ return escapeCommentOpeners(escapeChangelogMentions(text), { keepCodeSpans: true });
326
383
  }
327
384
  function formatEntry(entry, opts) {
328
385
  const refsMode = opts?.refs ?? "link";
329
386
  const appendedRefs = [...entry.issueIds ?? [], entry.prNumber];
330
- const description = escapeChangelogMentions(
331
- neutralizeDescriptionRefs(entry.description, appendedRefs, refsMode, opts?.repoUrl ?? null)
332
- );
333
- const scope = entry.scope ? escapeChangelogMentions(entry.scope) : void 0;
334
- const leadIn = entry.leadIn ? escapeChangelogMentions(entry.leadIn) : void 0;
387
+ const description = neutralizeDescriptionRefs(entry.description, appendedRefs, refsMode, opts?.repoUrl ?? null);
388
+ const { scope, leadIn } = entry;
335
389
  let line;
336
390
  if (leadIn && entry.breaking) {
337
391
  line = `- **BREAKING** **${leadIn}**: ${description}`;
@@ -350,11 +404,10 @@ function formatEntry(entry, opts) {
350
404
  if (refs) {
351
405
  line += ` ${refs}`;
352
406
  }
353
- return line;
407
+ return escapeCommitText(line);
354
408
  }
355
409
  function formatCategorySection(name, entries, refOpts) {
356
- const lines = [];
357
- lines.push(`### ${name}`);
410
+ const blocks = [`### ${name}`];
358
411
  const scopeCounts = /* @__PURE__ */ new Map();
359
412
  for (const entry of entries) {
360
413
  if (entry.scope) {
@@ -367,36 +420,27 @@ function formatCategorySection(name, entries, refOpts) {
367
420
  groupedScopes.add(scope);
368
421
  }
369
422
  }
370
- if (groupedScopes.size === 0) {
371
- for (const entry of entries) {
372
- lines.push(formatEntry(entry, refOpts));
373
- }
374
- } else {
375
- const byScope = /* @__PURE__ */ new Map();
376
- for (const entry of entries) {
377
- if (entry.scope && groupedScopes.has(entry.scope)) {
378
- const group = byScope.get(entry.scope) ?? [];
379
- group.push(entry);
380
- byScope.set(entry.scope, group);
381
- }
382
- }
383
- const renderedScopes = /* @__PURE__ */ new Set();
384
- for (const entry of entries) {
385
- if (entry.scope && groupedScopes.has(entry.scope)) {
386
- if (!renderedScopes.has(entry.scope)) {
387
- renderedScopes.add(entry.scope);
388
- lines.push(`**${escapeChangelogMentions(entry.scope)}**:`);
389
- for (const e of byScope.get(entry.scope) ?? []) {
390
- lines.push(formatEntry(e, { ...refOpts, hideScope: true }));
391
- }
392
- }
393
- } else {
394
- lines.push(formatEntry(entry, refOpts));
395
- }
423
+ const ungrouped = [];
424
+ const byScope = /* @__PURE__ */ new Map();
425
+ for (const entry of entries) {
426
+ if (entry.scope && groupedScopes.has(entry.scope)) {
427
+ const group = byScope.get(entry.scope) ?? [];
428
+ group.push(entry);
429
+ byScope.set(entry.scope, group);
430
+ } else {
431
+ ungrouped.push(entry);
396
432
  }
397
433
  }
398
- lines.push("");
399
- return lines;
434
+ if (ungrouped.length > 0) {
435
+ blocks.push(ungrouped.map((entry) => formatEntry(entry, refOpts)).join("\n"));
436
+ }
437
+ for (const [scope, group] of byScope) {
438
+ blocks.push(
439
+ `**${escapeCommitText(scope)}**:`,
440
+ group.map((entry) => formatEntry(entry, { ...refOpts, hideScope: true })).join("\n")
441
+ );
442
+ }
443
+ return blocks;
400
444
  }
401
445
  function rerouteBreakingEntries(categories) {
402
446
  const hasBreaking = categories.some((c) => c.entries.some((e) => e.breaking));
@@ -414,11 +458,11 @@ function rerouteBreakingEntries(categories) {
414
458
  return true;
415
459
  })
416
460
  }));
417
- const breakingCatIdx = stripped.findIndex((c) => c.name === "Breaking");
461
+ const breakingCatIdx = stripped.findIndex((c) => c.name === BREAKING_SECTION);
418
462
  if (breakingCatIdx >= 0) {
419
463
  return stripped.map((c, i) => i === breakingCatIdx ? { ...c, entries: [...breakingEntries, ...c.entries] } : c);
420
464
  }
421
- return [{ name: "Breaking", entries: breakingEntries }, ...stripped.filter((c) => c.entries.length > 0)];
465
+ return [{ name: BREAKING_SECTION, entries: breakingEntries }, ...stripped.filter((c) => c.entries.length > 0)];
422
466
  }
423
467
  function applyOrder(categories, order) {
424
468
  if (order.length === 0) {
@@ -427,7 +471,7 @@ function applyOrder(categories, order) {
427
471
  return [...categories].sort((a, b) => {
428
472
  const ai = order.indexOf(a.name);
429
473
  const bi = order.indexOf(b.name);
430
- const rank = (name, idx) => idx === -1 ? name === "Breaking" ? -1 : order.length : idx;
474
+ const rank = (name, idx) => idx === -1 ? name === BREAKING_SECTION ? -1 : order.length : idx;
431
475
  return rank(a.name, ai) - rank(b.name, bi);
432
476
  });
433
477
  }
@@ -505,24 +549,19 @@ function resolveLinks(entries, linksConfig) {
505
549
  return merged;
506
550
  }
507
551
  function formatVersion(context, options) {
508
- const lines = [];
509
552
  const refOpts = { refs: options?.refs ?? "link", repoUrl: context.repoUrl };
510
553
  const versionLabel = options?.includePackageName && context.packageName ? `${context.packageName}@${context.version}` : context.version;
511
554
  const versionHeader = context.previousVersion ? `## [${versionLabel}]` : `## ${versionLabel}`;
512
- lines.push(`${versionHeader} - ${context.date}`);
513
- lines.push("");
555
+ const blocks = [`${versionHeader} - ${context.date}`];
514
556
  const introLine = firstReleaseLine(context, options?.firstRelease);
515
557
  if (introLine) {
516
- lines.push(introLine);
517
- lines.push("");
558
+ blocks.push(introLine);
518
559
  }
519
560
  if (context.compareUrl) {
520
- lines.push(`[Full Changelog](${context.compareUrl})`);
521
- lines.push("");
561
+ blocks.push(`[Full Changelog](${context.compareUrl})`);
522
562
  }
523
563
  if (context.enhanced?.summary) {
524
- lines.push(context.enhanced.summary);
525
- lines.push("");
564
+ blocks.push(context.enhanced.summary);
526
565
  }
527
566
  if (context.enhanced?.categories && context.enhanced.categories.length > 0) {
528
567
  let categories = rerouteBreakingEntries(context.enhanced.categories);
@@ -531,30 +570,22 @@ function formatVersion(context, options) {
531
570
  if (category.entries.length === 0) {
532
571
  continue;
533
572
  }
534
- lines.push(...formatCategorySection(category.name, category.entries, refOpts));
573
+ blocks.push(...formatCategorySection(category.name, category.entries, refOpts));
535
574
  }
536
575
  const links = resolveLinks(context.entries, options?.links);
537
576
  if (links.length > 0) {
538
- lines.push(`### ${options?.links?.title ?? "Links"}`);
539
- for (const link of links) {
540
- lines.push(`- [${link.label}](${link.url})`);
541
- }
542
- lines.push("");
577
+ blocks.push(
578
+ `### ${options?.links?.title ?? "Links"}`,
579
+ links.map((link) => `- [${link.label}](${link.url})`).join("\n")
580
+ );
543
581
  }
544
582
  } else {
545
- const grouped = groupEntriesByType(context.entries);
546
- for (const [type, entries] of grouped) {
547
- if (entries.length === 0) {
548
- continue;
549
- }
550
- lines.push(`### ${TYPE_LABELS[type]}`);
551
- for (const entry of entries) {
552
- lines.push(formatEntry(entry, refOpts));
553
- }
554
- lines.push("");
583
+ for (const section of groupChangelogSections(context.entries, (e) => e, { labelOrder: SECTION_ORDER })) {
584
+ blocks.push(`### ${section.label}`, section.items.map((entry) => formatEntry(entry, refOpts)).join("\n"));
555
585
  }
556
586
  }
557
- return lines.join("\n");
587
+ return `${blocks.join("\n\n")}
588
+ `;
558
589
  }
559
590
  function formatHeader() {
560
591
  return `# Changelog
@@ -563,7 +594,6 @@ All notable changes to this project will be documented in this file.
563
594
 
564
595
  The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
565
596
  and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
566
-
567
597
  `;
568
598
  }
569
599
  function renderMarkdown(contexts, options) {
@@ -587,10 +617,9 @@ ${existing}`;
587
617
  if (headerEnd === -1) {
588
618
  return `${existing.trimEnd()}
589
619
 
590
-
591
620
  ${sections}`;
592
621
  }
593
- return `${existing.slice(0, headerEnd)}
622
+ return `${existing.slice(0, headerEnd).trimEnd()}
594
623
 
595
624
  ${sections}
596
625
  ${existing.slice(headerEnd + 1)}`;