@releasekit/notes 0.45.0 → 0.46.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/dist/{aggregator-T5ZE72Y6.js → aggregator-XM2XIYDF.js} +1 -1
- package/dist/{chunk-66BANKM3.js → chunk-EI7LLVJN.js} +155 -128
- package/dist/{chunk-CJRSZUD4.js → chunk-JOA56Y7A.js} +131 -36
- package/dist/cli.js +2 -2
- package/dist/index.d.ts +90 -16
- package/dist/index.js +2 -2
- package/docs/llm-providers.md +2 -2
- package/docs/llm-release-notes.md +12 -38
- package/docs/monorepo.md +41 -0
- package/docs/templates.md +62 -53
- package/package.json +1 -1
- package/templates/angular/document.hbs +12 -0
- package/templates/angular/entry.hbs +1 -2
- package/templates/angular/version.hbs +14 -4
- package/templates/github-release/release.md.ejs +40 -15
- package/templates/keep-a-changelog/document.liquid +11 -0
- package/templates/keep-a-changelog/entry.liquid +1 -2
- package/templates/keep-a-changelog/version.liquid +19 -52
|
@@ -16,13 +16,11 @@ import * as fs3 from "fs";
|
|
|
16
16
|
import * as os from "os";
|
|
17
17
|
import * as path4 from "path";
|
|
18
18
|
var CODE_SPAN_OR_COMMENT_OPEN = /(?<!(?<!\\)\\(?:\\\\)*)`[^`]*`|<!--/g;
|
|
19
|
-
function escapeCommentOpeners(text
|
|
20
|
-
return text.replace(
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
return opts?.keepCodeSpans ? match : match.replaceAll("<!--", "<!\u200B--");
|
|
25
|
-
});
|
|
19
|
+
function escapeCommentOpeners(text) {
|
|
20
|
+
return text.replace(
|
|
21
|
+
CODE_SPAN_OR_COMMENT_OPEN,
|
|
22
|
+
(match) => match.startsWith("`") ? match.replaceAll("<!--", "<!\u200B--") : "<!--"
|
|
23
|
+
);
|
|
26
24
|
}
|
|
27
25
|
function parseGitHubOwnerRepo(repoUrl) {
|
|
28
26
|
const [, scpOwner, scpRepo] = repoUrl.match(/^git@github\.com:([^/]+)\/(.+?)(?:\.git)?$/) ?? [];
|
|
@@ -101,6 +99,18 @@ function removeDescriptionRefs(text, refs) {
|
|
|
101
99
|
return num !== void 0 && remove.has(Number(num)) ? "" : match;
|
|
102
100
|
}).trim();
|
|
103
101
|
}
|
|
102
|
+
function renderChangelogEntryLine(entry, mode, repoUrl, suffix = "") {
|
|
103
|
+
const description = neutralizeDescriptionRefs(
|
|
104
|
+
entry.description,
|
|
105
|
+
[...entry.issueIds ?? [], entry.prNumber],
|
|
106
|
+
mode,
|
|
107
|
+
repoUrl
|
|
108
|
+
);
|
|
109
|
+
const label = entry.leadIn || entry.scope;
|
|
110
|
+
const refs = renderIssueRefs(entry.issueIds ?? [], mode, repoUrl, entry.prNumber);
|
|
111
|
+
const line = `- ${label ? `**${label}**: ` : ""}${description}${refs ? ` ${refs}` : ""}${suffix}`;
|
|
112
|
+
return escapeCommentOpeners(escapeChangelogMentions(line));
|
|
113
|
+
}
|
|
104
114
|
var BREAKING_SECTION = "Breaking";
|
|
105
115
|
var DEMOTED_SECTION = "Dependencies & version bumps";
|
|
106
116
|
var CHANGELOG_TYPE_LABELS = {
|
|
@@ -126,8 +136,11 @@ var CHANGELOG_LABEL_ORDER = [...new Set(Object.values(CHANGELOG_TYPE_LABELS))];
|
|
|
126
136
|
function changelogTypeLabel(type) {
|
|
127
137
|
return Object.hasOwn(CHANGELOG_TYPE_LABELS, type) ? CHANGELOG_TYPE_LABELS[type] : type.charAt(0).toUpperCase() + type.slice(1);
|
|
128
138
|
}
|
|
129
|
-
|
|
130
|
-
|
|
139
|
+
var DEMOTED_SCOPES = /* @__PURE__ */ new Set(["deps", "deps-dev"]);
|
|
140
|
+
function groupChangelogSections(items, entryOf, categorized) {
|
|
141
|
+
if (categorized && categorized.categories.length > 0) {
|
|
142
|
+
return groupByCategory(categorized, entryOf);
|
|
143
|
+
}
|
|
131
144
|
const breaking = [];
|
|
132
145
|
const demoted = [];
|
|
133
146
|
const byLabel = /* @__PURE__ */ new Map();
|
|
@@ -135,7 +148,7 @@ function groupChangelogSections(items, entryOf, { demoteScopes = [] } = {}) {
|
|
|
135
148
|
const entry = entryOf(item);
|
|
136
149
|
if (entry.breaking) {
|
|
137
150
|
breaking.push(item);
|
|
138
|
-
} else if (entry.scope !== void 0 &&
|
|
151
|
+
} else if (entry.scope !== void 0 && DEMOTED_SCOPES.has(entry.scope)) {
|
|
139
152
|
demoted.push(item);
|
|
140
153
|
} else {
|
|
141
154
|
const label = changelogTypeLabel(entry.type);
|
|
@@ -166,6 +179,87 @@ function groupChangelogSections(items, entryOf, { demoteScopes = [] } = {}) {
|
|
|
166
179
|
}
|
|
167
180
|
return sections;
|
|
168
181
|
}
|
|
182
|
+
function groupByCategory({ categories, order = [] }, entryOf) {
|
|
183
|
+
const breaking = [];
|
|
184
|
+
const sections = categories.map(({ name, entries }) => ({
|
|
185
|
+
label: name,
|
|
186
|
+
items: entries.filter((item) => {
|
|
187
|
+
if (entryOf(item).breaking) {
|
|
188
|
+
breaking.push(item);
|
|
189
|
+
return false;
|
|
190
|
+
}
|
|
191
|
+
return true;
|
|
192
|
+
})
|
|
193
|
+
}));
|
|
194
|
+
const llmBreaking = sections.find((s) => s.label === BREAKING_SECTION);
|
|
195
|
+
if (llmBreaking) {
|
|
196
|
+
llmBreaking.items.unshift(...breaking);
|
|
197
|
+
} else {
|
|
198
|
+
sections.push({ label: BREAKING_SECTION, items: breaking });
|
|
199
|
+
}
|
|
200
|
+
const rank = (label) => {
|
|
201
|
+
const index = order.indexOf(label);
|
|
202
|
+
if (index !== -1) {
|
|
203
|
+
return index;
|
|
204
|
+
}
|
|
205
|
+
return label === BREAKING_SECTION ? -1 : order.length;
|
|
206
|
+
};
|
|
207
|
+
return sections.filter((s) => s.items.length > 0).sort((a, b) => rank(a.label) - rank(b.label));
|
|
208
|
+
}
|
|
209
|
+
var PROJECT_WIDE_HEADING = "Project-wide changes";
|
|
210
|
+
var entryKey = (e) => `${e.type}:${e.description}`;
|
|
211
|
+
function unlistedEntries(entries, listed) {
|
|
212
|
+
const keys = new Set(listed.map(entryKey));
|
|
213
|
+
return entries.filter((e) => !keys.has(entryKey(e)));
|
|
214
|
+
}
|
|
215
|
+
function sharedPackageEntriesFor(shared, own) {
|
|
216
|
+
return unlistedEntries(
|
|
217
|
+
shared.filter((e) => e.sharedPackage),
|
|
218
|
+
own
|
|
219
|
+
);
|
|
220
|
+
}
|
|
221
|
+
function sharedPackageEntriesOf(changelog, sharedEntries) {
|
|
222
|
+
return changelog.sharedPackageEntries ? [...changelog.sharedPackageEntries] : sharedPackageEntriesFor(sharedEntries, changelog.entries);
|
|
223
|
+
}
|
|
224
|
+
function renderChangelogSections(entries, level, mode, repoUrl) {
|
|
225
|
+
const hashes = "#".repeat(level);
|
|
226
|
+
return groupChangelogSections(entries, (e) => e).map(
|
|
227
|
+
(section) => `${hashes} ${section.label}
|
|
228
|
+
|
|
229
|
+
${section.items.map((e) => renderChangelogEntryLine(e, mode, repoUrl)).join("\n")}`
|
|
230
|
+
);
|
|
231
|
+
}
|
|
232
|
+
function renderChangelogBlock(heading, level, entries, mode, repoUrl) {
|
|
233
|
+
return [`${"#".repeat(level)} ${heading}`, ...renderChangelogSections(entries, level + 1, mode, repoUrl)].join(
|
|
234
|
+
"\n\n"
|
|
235
|
+
);
|
|
236
|
+
}
|
|
237
|
+
function resolveBundled(bundled, releases) {
|
|
238
|
+
return (bundled ?? []).flatMap(({ packageName, versions }) => {
|
|
239
|
+
const entries = versions.flatMap(
|
|
240
|
+
(version) => (releases.find((r) => r.packageName === packageName && r.version === version)?.entries ?? []).filter(
|
|
241
|
+
(e) => !e.synthetic && e.description !== `Update version to ${version}`
|
|
242
|
+
)
|
|
243
|
+
);
|
|
244
|
+
const first = versions[0];
|
|
245
|
+
const last = versions.at(-1);
|
|
246
|
+
if (last === void 0 || entries.length === 0) {
|
|
247
|
+
return [];
|
|
248
|
+
}
|
|
249
|
+
return [{ packageName, ...versions.length > 1 ? { firstVersion: first } : {}, version: last, entries }];
|
|
250
|
+
});
|
|
251
|
+
}
|
|
252
|
+
function renderBundledBlocks(packages, level, mode, repoUrl) {
|
|
253
|
+
return packages.map(
|
|
254
|
+
(p) => renderChangelogBlock(
|
|
255
|
+
`${p.packageName} ${p.firstVersion ? `${p.firstVersion} \u2192 ` : ""}${p.version}`,
|
|
256
|
+
level,
|
|
257
|
+
p.entries,
|
|
258
|
+
mode,
|
|
259
|
+
repoUrl
|
|
260
|
+
)
|
|
261
|
+
);
|
|
262
|
+
}
|
|
169
263
|
var LOG_LEVELS = {
|
|
170
264
|
error: 0,
|
|
171
265
|
warn: 1,
|
|
@@ -379,103 +473,6 @@ function firstReleaseLine(context, config) {
|
|
|
379
473
|
const template = config?.text ?? DEFAULT_FIRST_RELEASE_TEXT;
|
|
380
474
|
return template.replaceAll("${packageName}", context.packageName).replaceAll("${version}", context.version);
|
|
381
475
|
}
|
|
382
|
-
function escapeCommitText(text) {
|
|
383
|
-
return escapeCommentOpeners(escapeChangelogMentions(text), { keepCodeSpans: true });
|
|
384
|
-
}
|
|
385
|
-
function formatEntry(entry, opts) {
|
|
386
|
-
const refsMode = opts?.refs ?? "link";
|
|
387
|
-
const appendedRefs = [...entry.issueIds ?? [], entry.prNumber];
|
|
388
|
-
const description = neutralizeDescriptionRefs(entry.description, appendedRefs, refsMode, opts?.repoUrl ?? null);
|
|
389
|
-
const { scope, leadIn } = entry;
|
|
390
|
-
let line;
|
|
391
|
-
if (leadIn && entry.breaking) {
|
|
392
|
-
line = `- **BREAKING** **${leadIn}**: ${description}`;
|
|
393
|
-
} else if (leadIn) {
|
|
394
|
-
line = `- **${leadIn}**: ${description}`;
|
|
395
|
-
} else if (entry.breaking && scope && !opts?.hideScope) {
|
|
396
|
-
line = `- **BREAKING** **${scope}**: ${description}`;
|
|
397
|
-
} else if (entry.breaking) {
|
|
398
|
-
line = `- **BREAKING** ${description}`;
|
|
399
|
-
} else if (scope && !opts?.hideScope) {
|
|
400
|
-
line = `- **${scope}**: ${description}`;
|
|
401
|
-
} else {
|
|
402
|
-
line = `- ${description}`;
|
|
403
|
-
}
|
|
404
|
-
const refs = renderIssueRefs(entry.issueIds ?? [], refsMode, opts?.repoUrl ?? null, entry.prNumber);
|
|
405
|
-
if (refs) {
|
|
406
|
-
line += ` ${refs}`;
|
|
407
|
-
}
|
|
408
|
-
return escapeCommitText(line);
|
|
409
|
-
}
|
|
410
|
-
function formatCategorySection(name, entries, refOpts) {
|
|
411
|
-
const blocks = [`### ${name}`];
|
|
412
|
-
const scopeCounts = /* @__PURE__ */ new Map();
|
|
413
|
-
for (const entry of entries) {
|
|
414
|
-
if (entry.scope) {
|
|
415
|
-
scopeCounts.set(entry.scope, (scopeCounts.get(entry.scope) ?? 0) + 1);
|
|
416
|
-
}
|
|
417
|
-
}
|
|
418
|
-
const groupedScopes = /* @__PURE__ */ new Set();
|
|
419
|
-
for (const [scope, count] of scopeCounts) {
|
|
420
|
-
if (count > 1) {
|
|
421
|
-
groupedScopes.add(scope);
|
|
422
|
-
}
|
|
423
|
-
}
|
|
424
|
-
const ungrouped = [];
|
|
425
|
-
const byScope = /* @__PURE__ */ new Map();
|
|
426
|
-
for (const entry of entries) {
|
|
427
|
-
if (entry.scope && groupedScopes.has(entry.scope)) {
|
|
428
|
-
const group = byScope.get(entry.scope) ?? [];
|
|
429
|
-
group.push(entry);
|
|
430
|
-
byScope.set(entry.scope, group);
|
|
431
|
-
} else {
|
|
432
|
-
ungrouped.push(entry);
|
|
433
|
-
}
|
|
434
|
-
}
|
|
435
|
-
if (ungrouped.length > 0) {
|
|
436
|
-
blocks.push(ungrouped.map((entry) => formatEntry(entry, refOpts)).join("\n"));
|
|
437
|
-
}
|
|
438
|
-
for (const [scope, group] of byScope) {
|
|
439
|
-
blocks.push(
|
|
440
|
-
`**${escapeCommitText(scope)}**:`,
|
|
441
|
-
group.map((entry) => formatEntry(entry, { ...refOpts, hideScope: true })).join("\n")
|
|
442
|
-
);
|
|
443
|
-
}
|
|
444
|
-
return blocks;
|
|
445
|
-
}
|
|
446
|
-
function rerouteBreakingEntries(categories) {
|
|
447
|
-
const hasBreaking = categories.some((c) => c.entries.some((e) => e.breaking));
|
|
448
|
-
if (!hasBreaking) {
|
|
449
|
-
return categories;
|
|
450
|
-
}
|
|
451
|
-
const breakingEntries = [];
|
|
452
|
-
const stripped = categories.map((c) => ({
|
|
453
|
-
...c,
|
|
454
|
-
entries: c.entries.filter((e) => {
|
|
455
|
-
if (e.breaking) {
|
|
456
|
-
breakingEntries.push(e);
|
|
457
|
-
return false;
|
|
458
|
-
}
|
|
459
|
-
return true;
|
|
460
|
-
})
|
|
461
|
-
}));
|
|
462
|
-
const breakingCatIdx = stripped.findIndex((c) => c.name === BREAKING_SECTION);
|
|
463
|
-
if (breakingCatIdx >= 0) {
|
|
464
|
-
return stripped.map((c, i) => i === breakingCatIdx ? { ...c, entries: [...breakingEntries, ...c.entries] } : c);
|
|
465
|
-
}
|
|
466
|
-
return [{ name: BREAKING_SECTION, entries: breakingEntries }, ...stripped.filter((c) => c.entries.length > 0)];
|
|
467
|
-
}
|
|
468
|
-
function applyOrder(categories, order) {
|
|
469
|
-
if (order.length === 0) {
|
|
470
|
-
return categories;
|
|
471
|
-
}
|
|
472
|
-
return [...categories].sort((a, b) => {
|
|
473
|
-
const ai = order.indexOf(a.name);
|
|
474
|
-
const bi = order.indexOf(b.name);
|
|
475
|
-
const rank = (name, idx) => idx === -1 ? name === BREAKING_SECTION ? -1 : order.length : idx;
|
|
476
|
-
return rank(a.name, ai) - rank(b.name, bi);
|
|
477
|
-
});
|
|
478
|
-
}
|
|
479
476
|
function parseMdLink(text) {
|
|
480
477
|
let search = 0;
|
|
481
478
|
while (search < text.length) {
|
|
@@ -549,8 +546,19 @@ function resolveLinks(entries, linksConfig) {
|
|
|
549
546
|
}
|
|
550
547
|
return merged;
|
|
551
548
|
}
|
|
549
|
+
function versionSections(context, categoryOrder) {
|
|
550
|
+
const categories = context.enhanced?.categories;
|
|
551
|
+
return groupChangelogSections(
|
|
552
|
+
context.entries,
|
|
553
|
+
(e) => e,
|
|
554
|
+
categories ? { categories, order: categoryOrder } : void 0
|
|
555
|
+
);
|
|
556
|
+
}
|
|
557
|
+
function sharedPackageBlock(context, refs) {
|
|
558
|
+
return context.sharedEntries?.length ? renderChangelogBlock(PROJECT_WIDE_HEADING, 3, context.sharedEntries, refs, context.repoUrl) : void 0;
|
|
559
|
+
}
|
|
552
560
|
function formatVersion(context, options) {
|
|
553
|
-
const
|
|
561
|
+
const refs = options?.refs ?? "link";
|
|
554
562
|
const versionLabel = options?.includePackageName && context.packageName ? `${context.packageName}@${context.version}` : context.version;
|
|
555
563
|
const versionHeader = context.previousVersion ? `## [${versionLabel}]` : `## ${versionLabel}`;
|
|
556
564
|
const blocks = [`${versionHeader} - ${context.date}`];
|
|
@@ -564,15 +572,14 @@ function formatVersion(context, options) {
|
|
|
564
572
|
if (context.enhanced?.summary) {
|
|
565
573
|
blocks.push(context.enhanced.summary);
|
|
566
574
|
}
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
}
|
|
575
|
+
const categories = context.enhanced?.categories;
|
|
576
|
+
for (const section of versionSections(context, options?.categoryOrder)) {
|
|
577
|
+
blocks.push(
|
|
578
|
+
`### ${section.label}`,
|
|
579
|
+
section.items.map((entry) => renderChangelogEntryLine(entry, refs, context.repoUrl)).join("\n")
|
|
580
|
+
);
|
|
581
|
+
}
|
|
582
|
+
if (categories && categories.length > 0) {
|
|
576
583
|
const links = resolveLinks(context.entries, options?.links);
|
|
577
584
|
if (links.length > 0) {
|
|
578
585
|
blocks.push(
|
|
@@ -580,10 +587,10 @@ function formatVersion(context, options) {
|
|
|
580
587
|
links.map((link) => `- [${link.label}](${link.url})`).join("\n")
|
|
581
588
|
);
|
|
582
589
|
}
|
|
583
|
-
}
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
590
|
+
}
|
|
591
|
+
const shared = sharedPackageBlock(context, refs);
|
|
592
|
+
if (shared) {
|
|
593
|
+
blocks.push(shared);
|
|
587
594
|
}
|
|
588
595
|
return `${blocks.join("\n\n")}
|
|
589
596
|
`;
|
|
@@ -597,19 +604,28 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
|
|
|
597
604
|
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
598
605
|
`;
|
|
599
606
|
}
|
|
600
|
-
function renderMarkdown(contexts, options) {
|
|
607
|
+
function renderMarkdown(contexts, options, sharedEntries = []) {
|
|
601
608
|
const sections = [formatHeader()];
|
|
602
609
|
for (const context of contexts) {
|
|
603
610
|
sections.push(formatVersion(context, options));
|
|
604
611
|
}
|
|
612
|
+
const first = contexts[0];
|
|
613
|
+
if (first && sharedEntries.length > 0) {
|
|
614
|
+
const heading = `${PROJECT_WIDE_HEADING} - ${first.date}`;
|
|
615
|
+
sections.push(`${renderChangelogBlock(heading, 2, sharedEntries, options?.refs ?? "link", first.repoUrl)}
|
|
616
|
+
`);
|
|
617
|
+
}
|
|
605
618
|
return sections.join("\n");
|
|
606
619
|
}
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
620
|
+
var HEADING_RE = /^#{1,3} (.*)$/gm;
|
|
621
|
+
var LINK_TARGET_RE = /\]\([^()[\]]*\)/g;
|
|
622
|
+
function versionSectionsStart(markdown) {
|
|
623
|
+
for (const heading of markdown.matchAll(HEADING_RE)) {
|
|
624
|
+
if (/\d\.\d+\.\d/.test((heading[1] ?? "").replace(LINK_TARGET_RE, "]"))) {
|
|
625
|
+
return heading.index;
|
|
626
|
+
}
|
|
610
627
|
}
|
|
611
|
-
|
|
612
|
-
return index === -1 ? -1 : index + 1;
|
|
628
|
+
return -1;
|
|
613
629
|
}
|
|
614
630
|
function prependChangelog(existingPath, rendered) {
|
|
615
631
|
const existing = fs4.existsSync(existingPath) ? fs4.readFileSync(existingPath, "utf-8") : "";
|
|
@@ -618,7 +634,9 @@ function prependChangelog(existingPath, rendered) {
|
|
|
618
634
|
}
|
|
619
635
|
const sectionsStart = versionSectionsStart(rendered);
|
|
620
636
|
if (sectionsStart === -1) {
|
|
621
|
-
warn(
|
|
637
|
+
warn(
|
|
638
|
+
`Rendered changelog has no version heading (a "#", "##" or "###" heading with a version); nothing added to ${existingPath}`
|
|
639
|
+
);
|
|
622
640
|
return existing;
|
|
623
641
|
}
|
|
624
642
|
const sections = `${rendered.slice(sectionsStart).trimEnd()}
|
|
@@ -770,6 +788,13 @@ function detectMonorepo(cwd) {
|
|
|
770
788
|
export {
|
|
771
789
|
parseGitHubOwnerRepo,
|
|
772
790
|
removeDescriptionRefs,
|
|
791
|
+
renderChangelogEntryLine,
|
|
792
|
+
BREAKING_SECTION,
|
|
793
|
+
groupChangelogSections,
|
|
794
|
+
unlistedEntries,
|
|
795
|
+
sharedPackageEntriesOf,
|
|
796
|
+
resolveBundled,
|
|
797
|
+
renderBundledBlocks,
|
|
773
798
|
setLogLevel,
|
|
774
799
|
setQuietMode,
|
|
775
800
|
error,
|
|
@@ -782,6 +807,8 @@ export {
|
|
|
782
807
|
unwrapEnvelope,
|
|
783
808
|
readPackageVersion,
|
|
784
809
|
isPathWithinRoot,
|
|
810
|
+
versionSections,
|
|
811
|
+
sharedPackageBlock,
|
|
785
812
|
formatVersion,
|
|
786
813
|
renderMarkdown,
|
|
787
814
|
writeChangelog,
|