This repository has been archived by the owner on Dec 27, 2022. It is now read-only.
/
bin.js
73 lines (71 loc) · 1.93 KB
/
bin.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
63
64
65
66
67
68
69
70
71
72
73
import subcommand from 'subcommand'
import path from 'path'
import os from 'os'
import * as db from './db/index.js'
import { start } from './index.js'
const match = subcommand({
commands: [
{
name: 'start',
command: args => {
start({debugMode: true, port: 3000})
}
},
{
name: 'start-test',
command: args => {
if (!args.port) throw new Error('--port required')
if (!args.configDir) throw new Error('--configDir required')
if (!args.domain) throw new Error('--domain required')
start({
debugMode: true,
simulateHyperspace: true,
port: args.port,
configDir: args.configDir,
domain: args.domain
})
}
},
{
name: 'create-user',
command: async args => {
// TODO- this needs to work without starting the server
await start({debugMode: true, port: 3000})
await db.createUser({
username: args.username,
email: args.email,
profile: {
displayName: args.displayName,
description: args.description
}
})
console.log(args.username, 'created')
process.exit(0)
}
},
{
name: 'create-test-users',
command: async args => {
// TODO- this needs to work without starting the server
await start({debugMode: true, port: 3000})
for (let username of ['alice', 'bob', 'carla', 'dan', 'erica', 'finn']) {
await db.createUser({
username: username,
email: `${username}@email.com`,
profile: {
displayName: username.slice(0, 1).toUpperCase() + username.slice(1)
}
})
console.log(username, 'created')
}
process.exit(0)
}
}
],
root: {
command: args => {
start({debugMode: true, port: 3000})
}
}
})
const cmd = match(process.argv.slice(2))