-
Notifications
You must be signed in to change notification settings - Fork 0
/
generate-table.js
executable file
·59 lines (49 loc) · 1.82 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
57
58
59
#!/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/nirre7/ignite-bowser-diff-purge'
const generateTable = async () => {
const isBig = R.contains('--big', process.argv)
const input = await getStdin()
const releases = R.dropLast(1, R.split('\n')(input))
// words or phrases of length 12
const comments = [
'react native',
'this is cool',
'purge time!!',
'i love diffs',
'Infinite Red',
'diffs == fun',
'IgniteBowser',
'rn core 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}) [ignite-bowser core](https://github.com/infinitered/ignite-bowser/compare/v${fromRelease}...v${toRelease})`
: `[->${toRelease}](${RepoUrl}/compare/release/${fromRelease}..release/${toRelease})`
}),
)(R.range(0, length)),
]
}, releases),
]
console.log(table(diffTable))
}
(async () => {
await generateTable()
})()