-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcli.js
executable file
·58 lines (50 loc) · 1.48 KB
/
cli.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
#!/usr/bin/env node
const { Command, Argument } = require('commander');
const { migrateApp } = require('./controllers/app')();
const { migrate } = require('./controllers/admin');
const { decrypt, encrypt } = require('./lib/security');
const program = new Command();
program
.name('ti2-cli')
.description('TI2 Command line interface utilities')
.version((require('./package.json')).version);
program.command('dbapp')
.description('Handle database migrations for apps')
.argument('<string>', 'integration to operate on')
.addArgument(
new Argument('<action>', 'action to take', 'migrate')
.choices(['migrate', 'revert']),
)
.action(async (integration, action) => {
await migrateApp({ integrationId: integration, action });
process.exit(0);
});
program.command('db')
.description('Handle database migrations for integrations')
.addArgument(
new Argument('<action>', 'action to take', 'migrate')
.choices(['migrate', 'revert']),
)
.action(async action => {
await migrate({ action });
process.exit(0);
});
program.command('decrypt')
.description('decrypt a string')
.addArgument(
new Argument('<key>', 'key to decrypt'),
)
.action(async key => {
console.log(await decrypt(key));
process.exit(0);
});
program.command('encrypt')
.description('encrypt a string')
.addArgument(
new Argument('<key>', 'key to encrypt'),
)
.action(async key => {
console.log(await encrypt(key));
process.exit(0);
});
program.parse();