-
-
Notifications
You must be signed in to change notification settings - Fork 528
/
yargs.js
71 lines (66 loc) · 1.81 KB
/
yargs.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
import fs from 'fs';
import yargs from 'yargs';
import path from 'path';
import process from 'process';
function loadRCFile(optionsPath) {
const rcFile = optionsPath || path.resolve(process.cwd(), '.sequelizerc');
const rcFileResolved = path.resolve(rcFile);
return fs.existsSync(rcFileResolved)
? JSON.parse(JSON.stringify(require(rcFileResolved)))
: {};
}
const args = yargs
.help(false)
.version(false)
.config(loadRCFile(yargs.argv.optionsPath));
export default function getYArgs() {
return args;
}
export function _baseOptions(yargs) {
return yargs
.option('env', {
describe: 'The environment to run the command in',
default: 'development',
type: 'string',
})
.option('config', {
describe: 'The path to the config file',
type: 'string',
})
.option('options-path', {
describe: 'The path to a JSON file with additional options',
type: 'string',
})
.option('migrations-path', {
describe: 'The path to the migrations folder',
default: 'migrations',
type: 'string',
})
.option('seeders-path', {
describe: 'The path to the seeders folder',
default: 'seeders',
type: 'string',
})
.option('models-path', {
describe: 'The path to the models folder',
default: 'models',
type: 'string',
})
.option('url', {
describe:
'The database connection string to use. Alternative to using --config files',
type: 'string',
})
.option('debug', {
describe: 'When available show various debug information',
default: false,
type: 'boolean',
});
}
export function _underscoreOption(yargs) {
return yargs.option('underscored', {
describe: "Use snake case for the timestamp's attribute names",
default: false,
type: 'boolean',
});
}