-
Notifications
You must be signed in to change notification settings - Fork 126
/
Copy pathupdate-data.js
62 lines (59 loc) · 1.53 KB
/
update-data.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
60
61
62
// Exports data from real redis to data/*.json
const Redis = require('ioredis')
const writeFile = require('write-file-atomic')
const path = require('path')
const sortBy = require('lodash.sortby')
async function main() {
const redis = new Redis()
const dir = path.resolve(__dirname, '..', 'data')
const results = await Promise.all([
redis.info(),
redis.command('info'),
redis.command('docs'),
redis.command('list'),
redis.command('count'),
])
const [info, commandInfo, commandDocs, commandList, commandCount] = results
await Promise.all(
[
[
'info.json',
info.replace(
/executable:.*\/redis-server/,
'executable:/tmp/redis-server'
),
],
[
'command-info.json',
sortBy(commandInfo, ([cmd]) => cmd).map(
([_0, _1, _2, _3, _4, _5, _6, _7, _8, subcommands, ...rest]) => [
_0,
_1,
_2,
_3,
_4,
_5,
_6,
_7,
_8,
subcommands?.length
? sortBy(subcommands, ([cmd]) => cmd)
: subcommands,
...rest,
]
),
],
['command-docs.json', commandDocs],
['command-list.json', { list: sortBy(commandList), count: commandCount }],
].map(([file, data]) =>
writeFile(path.resolve(dir, file), JSON.stringify(data))
)
)
}
main()
.then(process.exit)
.catch(err => {
// eslint-disable-next-line no-console
console.error(err)
process.exit(1)
})