-
Notifications
You must be signed in to change notification settings - Fork 0
/
generate-table.js
executable file
·56 lines (46 loc) · 1.71 KB
/
generate-table.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
51
52
53
54
55
56
#!/usr/bin/env node
const table = require('markdown-table')
const R = require('ramda')
const semver = require('semver')
const getStdin = require('get-stdin')
const RepoUrl='https://github.com/blitz-js/versions-diff'
const generateTable = async () => {
const isBig = R.contains('--big', process.argv)
const input = await getStdin()
const releases = R.dropLast(1, R.split('\n')(input))
const comments = [
'blitz ftw',
'this is cool',
'purge time!!',
'i love diffs',
'diffs == fun',
'blitz team',
]
const diffTable = [
['From->To', ...comments[Math.floor(Math.random() * comments.length)] .toUpperCase() .split('')],
...R.map(fromRelease => {
const length = releases.length
return [
fromRelease,
...R.pipe(
R.map(idx => {
const toRelease = releases[idx]
if (semver.eq(fromRelease, toRelease)) {
return 'X'
}
if (semver.gt(fromRelease, toRelease)) {
return '-'
}
return isBig
? `[->${toRelease}](${RepoUrl}/compare/release/${fromRelease}..release/${toRelease}) [core](https://github.com/blitz-js/blitz/compare/v${fromRelease}...v${toRelease})`
: `[->${toRelease}](${RepoUrl}/compare/release/${fromRelease}..release/${toRelease})`
}),
)(R.range(0, length)),
]
}, releases),
]
console.log(table(diffTable))
}
(async () => {
await generateTable()
})()