Generate release notes in feeds (#3423)

This commit is contained in:
Peter Hedenskog 2021-07-16 09:01:39 +02:00 committed by GitHub
parent 078e347cca
commit 243e77de18
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 126 additions and 74 deletions

22
npm-shrinkwrap.json generated
View File

@ -1191,6 +1191,16 @@
"supports-color": "^2.0.0"
}
},
"changelog-parser": {
"version": "2.8.0",
"resolved": "https://registry.npmjs.org/changelog-parser/-/changelog-parser-2.8.0.tgz",
"integrity": "sha512-ZtSwN0hY7t+WpvaXqqXz98RHCNhWX9HsvCRAv1aBLlqJ7BpKtqdM6Nu6JOiUhRAWR7Gov0aN0fUnmflTz0WgZg==",
"dev": true,
"requires": {
"line-reader": "^0.2.4",
"remove-markdown": "^0.2.2"
}
},
"character-parser": {
"version": "2.2.0",
"resolved": "https://registry.npmjs.org/character-parser/-/character-parser-2.2.0.tgz",
@ -3691,6 +3701,12 @@
"immediate": "~3.0.5"
}
},
"line-reader": {
"version": "0.2.4",
"resolved": "https://registry.npmjs.org/line-reader/-/line-reader-0.2.4.tgz",
"integrity": "sha1-xDkrWH3qOFgMlnhXDm6OSfzlJiI=",
"dev": true
},
"linkify-it": {
"version": "2.0.3",
"resolved": "https://registry.npmjs.org/linkify-it/-/linkify-it-2.0.3.tgz",
@ -4923,6 +4939,12 @@
"integrity": "sha512-lv0M6+TkDVniA3aD1Eg0DVpfU/booSu7Eev3TDO/mZKHBfVjgCGTV4t4buppESEYDtkArYFOxTJWv6S5C+iaNw==",
"dev": true
},
"remove-markdown": {
"version": "0.2.2",
"resolved": "https://registry.npmjs.org/remove-markdown/-/remove-markdown-0.2.2.tgz",
"integrity": "sha1-ZrDO66n7d8qWNrsbAwfOIaMqEqY=",
"dev": true
},
"request": {
"version": "2.87.0",
"resolved": "https://registry.npmjs.org/request/-/request-2.87.0.tgz",

View File

@ -54,6 +54,7 @@
"bluebird": "3.5.5",
"chai": "4.2.0",
"chai-as-promised": "7.1.1",
"changelog-parser": "2.8.0",
"clean-css-cli": "4.3.0",
"cz-customizable": "^6.2.0",
"eslint": "6.2.2",

View File

@ -1,6 +1,7 @@
const Feed = require('feed').Feed;
const fs = require('fs');
const path = require('path');
const parseChangelog = require('changelog-parser');
const getSortedFiles = dir => {
const files = fs.readdirSync(dir);
@ -15,81 +16,109 @@ const getSortedFiles = dir => {
.sort((a, b) => b.time - a.time);
};
const versionDir = './docs/_includes/version/';
const sortedVersionFiles = getSortedFiles(versionDir);
const feed = new Feed({
title: 'sitespeed.io release feed',
description: 'Follow new releases of sitespeed.io tools',
id: 'https://www.sitespeed.io',
link: 'https://www.sitespeed.io',
language: 'en', // optional, used only in RSS 2.0, possible values: http://www.w3.org/TR/REC-html40/struct/dirlang.html#langcodes
image: 'https://www.sitespeed.io/img/logos/sitespeed.io.png',
favicon: 'http://www.sitespeed.io/favicon.ico',
copyright: 'All rights reserved 2021, Peter Hedenskog and team',
updated: new Date(sortedVersionFiles[0].time), // use the date from the latest updated version file
feedLinks: {
atom: 'https://www.sitespeed.io/feed/atom.xml',
rss: 'https://www.sitespeed.io/feed/rss.xml'
},
author: {
name: 'Peter Hedenskog',
email: 'peter@soulgalore.com',
link: 'https://www.peterhedenskog.com'
}
});
const descriptions = {
'sitespeed.io':
'Sitespeed.io is the complete toolbox to test the web performance of your web site. Use it to monitor your performance or checkout how your competition is doing.',
browsertime:
'Browsertime is the heart of sitespeed.io that handles everything with the browser. At the moment we support Chrome, Firefox, Edge and Safari on desktop, Chrome on Android and limited support for Safari on iOS',
'coach-core':
'The coach helps you find performance problems on your web page.',
pagexray:
'We love HAR files but its hard to actually see how the page is composed only looking at the file. PageXray converts a HAR file to a JSON format that is easier to read and easier to use.',
throttle:
'Throttle lets you simulate slow network connections on Linux and Mac OS X.',
coach: 'The coach helps you find performance problems on your web page.',
'chrome-har': 'Create HAR files based on Chrome Debugging Protocol data.',
'chrome-trace': '',
compare: 'Make it easier to find regressions by comparing your HAR files.'
};
const content = {};
const images = {
'sitespeed.io': 'https://www.sitespeed.io/img/logos/sitespeed.io.png',
browsertime: 'https://www.sitespeed.io/img/logos/browsertime.png',
'coach-core': 'https://www.sitespeed.io/img/logos/coach.png',
pagexray: 'https://www.sitespeed.io/img/logos/pagexray.png',
throttle: '',
coach: 'https://www.sitespeed.io/img/logos/coach.png',
'chrome-har': '',
'chrome-trace': '',
compare: 'https://www.sitespeed.io/img/logos/compare.png'
};
sortedVersionFiles.forEach(file => {
feed.addItem({
title: `${file.name} ${file.version}`,
id: `https://github.com/sitespeedio/${file.name}/blob/main/CHANGELOG.md#${
file.version
}`,
link: `https://github.com/sitespeedio/${file.name}/blob/main/CHANGELOG.md#`,
description: descriptions[file.name],
content: content[file.name],
author: [
{
name: 'Sitespeed.io',
link: 'https://www.sitespeed.io'
function getResult(result) {
let allData = '';
if (result.parsed) {
if (result.parsed.Added) {
for (let added of result.parsed.Added) {
allData += ' ' + added;
}
],
date: new Date(file.time),
image: images[file.name]
}
if (result.parsed.Fixed) {
for (let fixed of result.parsed.Fixed) {
allData += ' ' + fixed;
}
}
return allData;
}
}
async function generateFeed() {
const versionDir = './docs/_includes/version/';
const sortedVersionFiles = getSortedFiles(versionDir);
const feed = new Feed({
title: 'sitespeed.io release feed',
description: 'Follow new releases of sitespeed.io tools',
id: 'https://www.sitespeed.io',
link: 'https://www.sitespeed.io',
language: 'en', // optional, used only in RSS 2.0, possible values: http://www.w3.org/TR/REC-html40/struct/dirlang.html#langcodes
image: 'https://www.sitespeed.io/img/logos/sitespeed.io.png',
favicon: 'http://www.sitespeed.io/favicon.ico',
copyright: 'All rights reserved 2021, Peter Hedenskog and team',
updated: new Date(sortedVersionFiles[0].time), // use the date from the latest updated version file
feedLinks: {
atom: 'https://www.sitespeed.io/feed/atom.xml',
rss: 'https://www.sitespeed.io/feed/rss.xml'
},
author: {
name: 'Peter Hedenskog',
email: 'peter@soulgalore.com',
link: 'https://www.peterhedenskog.com'
}
});
});
feed.addCategory('Performance');
const getContent = async () => {
const content = {};
for (let tool of sortedVersionFiles) {
const changelog =
tool.name === 'sitespeed.io'
? './CHANGELOG.md'
: '../' + tool.name + '/CHANGELOG.md';
const result = await parseChangelog(changelog);
if (result.versions[0].date !== null) {
content[tool.name] = getResult(result.versions[0]);
} else if (result.versions[1]) {
content[tool.name] = getResult(result.versions[1]);
} else {
// skip missing data
console.log(`Missing data for tool ${tool.name}`);
}
}
return content;
};
const docPath = './docs/';
fs.writeFileSync(path.join(docPath, 'feed', 'rss.xml'), feed.rss2());
fs.writeFileSync(path.join(docPath, 'feed', 'atom.xml'), feed.atom1());
const descriptions = await getContent();
const images = {
'sitespeed.io': 'https://www.sitespeed.io/img/logos/sitespeed.io.png',
browsertime: 'https://www.sitespeed.io/img/logos/browsertime.png',
'coach-core': 'https://www.sitespeed.io/img/logos/coach.png',
pagexray: 'https://www.sitespeed.io/img/logos/pagexray.png',
throttle: '',
coach: 'https://www.sitespeed.io/img/logos/coach.png',
'chrome-har': '',
'chrome-trace': '',
compare: 'https://www.sitespeed.io/img/logos/compare.png'
};
sortedVersionFiles.forEach(file => {
feed.addItem({
title: `${file.name} ${file.version}`,
id: `https://github.com/sitespeedio/${file.name}/blob/main/CHANGELOG.md#${
file.version
}`,
link: `https://github.com/sitespeedio/${
file.name
}/blob/main/CHANGELOG.md#`,
description: descriptions[file.name],
// content: content[file.name],
author: [
{
name: 'Sitespeed.io',
link: 'https://www.sitespeed.io'
}
],
date: new Date(file.time),
image: images[file.name]
});
});
feed.addCategory('Performance');
const docPath = './docs/';
fs.writeFileSync(path.join(docPath, 'feed', 'rss.xml'), feed.rss2());
fs.writeFileSync(path.join(docPath, 'feed', 'atom.xml'), feed.atom1());
}
generateFeed();