-
Notifications
You must be signed in to change notification settings - Fork 2
/
index.js
executable file
·73 lines (65 loc) · 1.96 KB
/
index.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
#!/usr/bin/env node
const program = require('commander');
const { prompt } = require('inquirer');
const {
newSigningKey,
signingKeyChangePW,
streamDApp,
buildDApp,
} = require('./src/cliActions');
const {
newSigningKeySchema,
changePasswordSigningKeySchema,
streamDAppSchema,
buildDAppSchema,
} = require('./src/promtSchema');
const { loggerProtocolFactory } = require('./src/protocols');
program.version(require(`./package.json`).version, '-v, --version');
program
.command('sk:new')
.description('Generate new signing key')
.action(() => {
prompt(newSigningKeySchema)
.then(newSigningKey)
.then(console.log)
.catch(err => console.error(err.message));
});
program
.command('sk:pw <signing-key-file>')
.description('Change password of encrypted singing key')
.action(signingKeyFile => {
prompt(changePasswordSigningKeySchema)
.then(answers => {
return signingKeyChangePW(answers, signingKeyFile);
})
.then(console.log)
.catch(err => console.error(err.message));
});
program
.command('dapp:stream <signing-key-file>')
.option('-d, --dev', 'Development build mode')
.description('Stream DApp to pangea')
.action((signingKeyFile, cmd) => {
prompt(streamDAppSchema)
.then(answers => streamDApp(answers, signingKeyFile, cmd.dev))
.then(console.log)
.catch(err => console.error(err.message));
});
program
.command('dapp:build <signing-key-file>')
.option('-d, --dev', 'Development build mode')
.description('Bundle DApp')
.action((signingKeyFile, cmd) => {
prompt(buildDAppSchema)
.then(answers => buildDApp(answers, signingKeyFile, cmd.dev))
.then(console.log)
.catch(err => console.error(err.message));
});
program
.command('pangea:log')
.description('Create node that receives logs from panthalassa')
.action(() => loggerProtocolFactory().catch(console.log));
program.parse(process.argv);
if (!process.argv.slice(2).length) {
program.help();
}