-
Notifications
You must be signed in to change notification settings - Fork 0
/
generate-table.mjs
executable file
·59 lines (52 loc) · 1.46 KB
/
generate-table.mjs
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
import { markdownTable } from "markdown-table"
import { map, pipe, range, dropLast, includes, split } from "ramda"
import semver from "semver"
import getStdin from "get-stdin"
const RepoUrl = "https://github.com/react-native-community/rn-diff-lib-purge"
const generateTable = async () => {
const isBig = includes("--big", process.argv)
const input = await getStdin()
const releases = dropLast(1, 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(""),
],
...map((fromRelease) => {
const length = releases.length
return [
fromRelease,
...pipe(
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})`
})
)(range(0, length)),
]
}, releases),
]
console.log(markdownTable(diffTable))
}
;(async () => {
await generateTable()
})()