This repository has been archived by the owner on Nov 1, 2019. It is now read-only.
forked from react-native-community/rn-diff-purge
-
-
Notifications
You must be signed in to change notification settings - Fork 5
/
generate-table.js
executable file
·57 lines (47 loc) · 1.76 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
#!/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/react-native-community/rn-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',
'diffs == fun',
'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}) [core](https://github.com/facebook/react-native/compare/v${fromRelease}...v${toRelease})`
: `[->${toRelease}](${RepoUrl}/compare/release/${fromRelease}..release/${toRelease})`
}),
)(R.range(0, length)),
]
}, releases),
]
console.log(table(diffTable))
}
(async () => {
await generateTable()
})()