Spaces:
Runtime error
Runtime error
File size: 1,127 Bytes
a6b96c2 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 | 'use strict';
/**
* Pure renderer for the changeset-fragment workflow (#2975).
*
* Returns a typed Changelog IR — no file I/O. The IR is the contract that
* tests assert on; the markdown serializer is a separate concern.
*
* IR shape: {
* releaseHeader: { version: string, date: string },
* sections: [{ type: string, bullets: [{ pr: number, body: string }] }],
* priorChangelog: string | null,
* }
*/
// Keep a Changelog (https://keepachangelog.com) standard section order.
const SECTION_ORDER = ['Added', 'Changed', 'Deprecated', 'Removed', 'Fixed', 'Security'];
function renderChangelog({ fragments, version, date, priorChangelog }) {
const byType = new Map();
for (const f of fragments) {
if (!byType.has(f.type)) byType.set(f.type, []);
byType.get(f.type).push({ pr: f.pr, body: f.body });
}
const sections = SECTION_ORDER
.filter((type) => byType.has(type))
.map((type) => ({ type, bullets: byType.get(type) }));
return {
releaseHeader: { version, date },
sections,
priorChangelog: priorChangelog || null,
};
}
module.exports = { renderChangelog };
|