-
Notifications
You must be signed in to change notification settings - Fork 0
/
cli.js
65 lines (58 loc) · 1.39 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
59
60
61
62
63
64
65
const chalk = require('chalk');
const { textSync } = require('figlet');
const { prompt } = require('./cli-questions');
const minimist = require('minimist');
const interactiveCLI = async (introQuestion, questions) => {
console.log(chalk.green(textSync('Express-Sire', { horizontalLayout: 'full' })));
const { intro } = await prompt([introQuestion]);
if (intro === 'No') process.exit(1);
return prompt(questions);
};
const cli = _args => {
const args = minimist(_args, {
alias: {
a: 'all',
n: 'name',
mn: 'monorepo',
ms: 'modsystem',
gi: 'gitignore',
gf: 'gitfolder',
c: 'compression',
h: 'helmet',
s: 'sequelize'
},
string: ['name', 'modsystem']
});
const {
all,
name: projectName,
monorepo = false,
modsystem: moduleSystem,
gitignore = false,
gitfolder = false,
compression = false,
helmet = false,
sequelize = false
} = args;
if (!(projectName && projectName.trim())) return false;
if (all)
return {
projectName,
monorepo: true,
moduleSystem: moduleSystem || 'cjs',
compression: true,
helmet: true,
sequelize: true,
git: [true, true]
};
return {
projectName,
monorepo,
moduleSystem: moduleSystem || 'cjs',
compression,
helmet,
sequelize,
git: [gitignore, gitfolder]
};
};
module.exports = { interactiveCLI, cli };