This repository was archived by the owner on Jan 29, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 18
Expand file tree
/
Copy pathtable.mjs
More file actions
74 lines (62 loc) · 1.53 KB
/
table.mjs
File metadata and controls
74 lines (62 loc) · 1.53 KB
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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
import util from 'util';
import _ from 'lodash/fp';
import fs from 'mz/fs';
import glob from 'glob';
import yaml from 'js-yaml';
import markdownTable from 'markdown-table';
const previousAttendees = new Set([
'Aaron Kirkbride',
'Adam Johnson',
'Amber Wright',
'Benjamin Elis Misell',
'Emmanuel Payet',
'Fabio Natali',
'Jonathan Burman',
'Luca Valentini',
'Mark Einon',
'Michael Aquilina',
'Roger G. Coram',
'Samuel Reynolds',
'Thomas David Newport',
'Thomas Edwards',
'Vipin Ajayakumar',
'William Johnson',
]);
const globP = util.promisify(glob);
const chunkStr = n => _.flow(_.chunk(n), _.map(_.join('')));
const formatFpHalf = _.flow(
chunkStr(4),
_.join(' '),
)
const formatFingerprint = _.flow(
_.replace(/(^0x|\s)/g, ''),
_.toLower,
chunkStr(20),
_.map(formatFpHalf),
_.join(' '),
);
const toTable = _.flow(
_.reject(v => previousAttendees.has(v.name)),
_.sortBy('name'),
_.map(v => ([v.name, v.fingerprint, '', ''])),
)
async function row(filename) {
const content = await fs.readFile(filename);
const { name, fingerprint: rawFingerprint } = yaml.safeLoad(content);
return { name, fingerprint: formatFingerprint(rawFingerprint)};
}
async function go() {
try {
const files = await globP('keys/*');
const rows = await Promise.all(_.map(row, files));
const tableRows = toTable(rows);
console.log(markdownTable([
['name', 'fingerprint', 'fp verified', 'id verified'],
...tableRows,
]));
} catch (e) {
console.error(e);
process.exit(1);
}
}
go();