-
Notifications
You must be signed in to change notification settings - Fork 1
/
changelog.js
executable file
·35 lines (31 loc) · 1012 Bytes
/
changelog.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
#!/usr/bin/env node
const {execSync} = require('child_process');
const semverSort = require('semver-sort');
let repo = 'https://github.com/senx/node-warp10';
let md =
`Warp 10 js lib
---
`;
let tagList = execSync('git tag -l --sort=-v:refname | head -n 1000');
tagList = tagList.toString().split('\n').filter(i => i !== '');
tagList = semverSort.desc(tagList);
let lastTag = tagList[0];
tagList = tagList.slice(1, -1);
tagList.forEach(tag => {
md += `## ${lastTag}
`;
execSync(`git log --no-merges --date=iso --format="> + ts%ct | %s %N" ${tag}..${lastTag}`)
.toString().split('\n').forEach(l => {
let timestamp = /ts([0-9]+)/.exec(l);
if (timestamp) {
l = l.replace('ts' + timestamp[1], new Date(timestamp[1] * 1000).toISOString().split('T')[0].replace(/\-/gi, '/'));
}
let issue = /#([0-9]+)/.exec(l);
if (issue) {
l = l.replace('#' + issue[1], `[#${issue[1]}](${repo}/issues/${issue[1]})`);
}
md += l + '\n';
});
lastTag = tag;
});
console.log(md);