Release notes: a story for big releases, and the 2.0 story
A CHANGELOG section may open with prose before its first bullet. The build bakes it into the page and version.json, and "What's new" tells it in full with a link to every change on GitHub instead of the first sentences of five bullets. The 2.0.0 section gets its story and every change grouped under headings, Architect runs included.
This commit is contained in:
parent
dbd2fa7b55
commit
abd55c0846
8 changed files with 150 additions and 49 deletions
|
|
@ -41,8 +41,11 @@ if (process.env.REQUIRE_NOTES === '1' && notes === '[]') die(`CHANGELOG.md has n
|
|||
const page = path.join(OUT, 'index.html'), PH = '/*__RELEASE_NOTES__*/[]', html = fs.readFileSync(page, 'utf8');
|
||||
if (!html.includes(PH)) die('release-notes placeholder missing from the page');
|
||||
// Function replacer: no $& / $$ expansion. Escape "<" so a note can never close the <script>.
|
||||
fs.writeFileSync(page, html.replace(PH, () => notes.replace(/</g, '\\u003c')));
|
||||
fs.writeFileSync(path.join(OUT, 'version.json'), JSON.stringify({ version: VERSION, date: BUILD_DATE, notes: JSON.parse(notes) }, null, 2) + '\n');
|
||||
// A release can also open with a story (prose before its first bullet), shown in full in "What's new".
|
||||
const story = execFileSync(process.execPath, [path.join(__dirname, 'release-notes.js'), VERSION, '--story'], { encoding: 'utf8' }), PS = '/*__RELEASE_STORY__*/[]';
|
||||
if (!html.includes(PS)) die('release-story placeholder missing from the page');
|
||||
fs.writeFileSync(page, html.replace(PH, () => notes.replace(/</g, '\\u003c')).replace(PS, () => story.replace(/</g, '\\u003c')));
|
||||
fs.writeFileSync(path.join(OUT, 'version.json'), JSON.stringify({ version: VERSION, date: BUILD_DATE, notes: JSON.parse(notes), story: JSON.parse(story) }, null, 2) + '\n');
|
||||
|
||||
// Nothing may ship half-stamped.
|
||||
const left = [];
|
||||
|
|
|
|||
|
|
@ -1,10 +1,12 @@
|
|||
#!/usr/bin/env node
|
||||
// Prints the CHANGELOG.md bullets for one version as a JSON array of strings.
|
||||
// Usage: node scripts/release-notes.js 1.2.0
|
||||
// node scripts/release-notes.js 2.0.0 --story the release's story instead: the paragraphs of prose between
|
||||
// its heading and its first bullet or ### heading (often none)
|
||||
const fs = require('node:fs');
|
||||
const path = require('node:path');
|
||||
|
||||
const version = process.argv[2];
|
||||
const version = process.argv[2], story = process.argv.includes('--story');
|
||||
const text = fs.readFileSync(path.join(__dirname, '..', 'CHANGELOG.md'), 'utf8');
|
||||
const lines = text.split('\n');
|
||||
const start = lines.findIndex((l) => l.startsWith(`## [${version}]`));
|
||||
|
|
@ -16,4 +18,15 @@ if (start >= 0) {
|
|||
else if (/^\s{2,}\S/.test(l) && notes.length) notes[notes.length - 1] += ' ' + l.trim();
|
||||
}
|
||||
}
|
||||
process.stdout.write(JSON.stringify(notes));
|
||||
if (story) {
|
||||
const paras = [];
|
||||
if (start >= 0) {
|
||||
let cur = [];
|
||||
for (let i = start + 1; i < lines.length && !lines[i].startsWith('## [') && !/^\s*-\s+/.test(lines[i]) && !lines[i].startsWith('###'); i++) {
|
||||
const l = lines[i].trim();
|
||||
if (l) cur.push(l); else if (cur.length) { paras.push(cur.join(' ')); cur = []; }
|
||||
}
|
||||
if (cur.length) paras.push(cur.join(' '));
|
||||
}
|
||||
process.stdout.write(JSON.stringify(paras));
|
||||
} else process.stdout.write(JSON.stringify(notes));
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue