forked from rdmtc/RedMatic
-
Notifications
You must be signed in to change notification settings - Fork 0
/
update_change_history.js
50 lines (46 loc) · 1.38 KB
/
update_change_history.js
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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
const request = require('request');
let page = 1;
function req() {
request({
url: `https://api.github.com/repos/rdmtc/RedMatic/releases?page=${page}&per_page=100`,
headers: {
'User-Agent': 'node-request',
'Authorization': `token ${process.env.GITHUB_OAUTH_TOKEN}`
}
}, (err, res, body) => {
if (!err) {
parse(JSON.parse(body));
} else {
console.error(err.message);
}
});
}
function parse(data) {
if (!data.forEach) {
console.error(data);
}
data.forEach(release => {
console.log(`# [${release.tag_name}](https://github.com/rdmtc/RedMatic/releases/${release.tag_name}) ${release.published_at}`);
let include = false;
release.body.split('\n').forEach(line => {
if (line.startsWith('Module | Version')) {
include = false;
}
if (line.startsWith('[Release History]') || line.startsWith('**[Change History]')) {
include = false;
}
if (include && line !== '') {
console.log(line.replace(/^\s*\* [0-9a-f]{7} /, '* '));
}
if (line.startsWith('### Change')) {
include = true;
}
});
console.log('\n');
});
if (data.length === 100) {
page += 1;
req();
}
}
req();