-
-
Notifications
You must be signed in to change notification settings - Fork 530
/
Copy pathdatabase_info.js
65 lines (52 loc) · 1.36 KB
/
database_info.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
import process from 'process';
import { _baseOptions } from '../core/yargs';
import helpers from '../helpers';
import { pick } from 'lodash';
import clc from 'cli-color';
exports.builder = (yargs) => {
_baseOptions(yargs)
.option('show-password', {
describe: 'Will show password as plain text',
type: 'boolean',
default: false,
})
.option('raw', {
describe: 'Display the raw object',
type: 'boolean',
default: false,
}).argv;
};
exports.handler = async function (args) {
const command = args._[0];
// legacy, gulp used to do this
await helpers.config.init();
const options = pick(args, ['showPassword', 'raw']);
switch (command) {
case 'db:info':
displayConfigObject(options);
break;
}
process.exit(0);
};
function displayConfigObject(options) {
let config = null;
try {
config = helpers.config.readConfig();
} catch (e) {
helpers.view.error(e);
}
if (!options.showPassword) {
config.password = '***';
}
helpers.view.log();
helpers.view.log(clc.bold('Sequelize configuration:'));
options.raw
? helpers.view.log(JSON.stringify(config, null, 2))
: display(config);
}
function display(i, p = '') {
Object.entries(i).forEach(([k, v]) => {
if (typeof v == 'object' && v !== null) display(v, `${p}${k}.`);
else helpers.view.log(`${p}${k}:`, v);
});
}