-
-
Notifications
You must be signed in to change notification settings - Fork 8
/
index.js
37 lines (33 loc) · 948 Bytes
/
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
#!/usr/bin/env node
const chalk = require('chalk'),
figlet = require('figlet'),
CLI = require('clui'),
Spinner = CLI.Spinner,
inquirer = require('./inquirer'),
replicate = require('./libs/replicate'),
env = require('./env')();
const interactiveMode = args => {
return args && args.length > 0 && args[0] === '-i';
};
const run = async (args) => {
if(!interactiveMode(args)) {
await replicate(env.couchdbUrl, env.postgresqlUrl, env);
} else {
console.log(
chalk.yellow(
figlet.textSync('CHT-Couch2Pg', { horizontalLayout: 'full' })
)
);
const {couchUrl, pgUrl, ...opts} = await inquirer.askAboutConfiguration(args.slice(1));
const spinner = new Spinner('cht-couch2pg:');
spinner.start();
try {
await replicate(couchUrl, pgUrl, opts);
} finally {
spinner.stop();
}
process.exit();
}
};
var args = process.argv.slice(2);
run(args);