-
Notifications
You must be signed in to change notification settings - Fork 0
/
cli-questions.js
73 lines (67 loc) · 1.97 KB
/
cli-questions.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
72
73
const inquirer = require('inquirer');
const { isEmptyOrNewDirectory } = require('./files');
const path = require('path');
const intro = {
name: `intro`,
type: `list`,
message: `Hello how are you? Let's create our scaffold. Shall we?`,
choices: ['Yes', 'No'],
default: 'Yes'
};
const projectName = {
name: `projectName`,
type: `input`,
message: `What is the project name?`,
default: `app-sire`,
validate: answer => {
const ONLY_ALPHANUMERIC_REGEX = /^([a-zA-Z0-9-_]){3,20}$/;
if (!ONLY_ALPHANUMERIC_REGEX.test(answer))
return `Please inform a valid project name (only alphanumeric; 3-20 length max)`;
if (!isEmptyOrNewDirectory(path.join(process.cwd(), answer)))
return `The directory ${answer} contains files/folders that could conflict. You should provide an empty folder`;
return true;
}
};
const monorepo = {
name: 'monorepo',
type: 'confirm',
message: 'Would you like a monorepo? (2 folders will be created (backend and frontend) and frontend will be empty):',
default: true
};
const moduleSystem = {
name: `moduleSystem`,
type: `list`,
message: `ESM or CJS ?`,
choices: ['cjs', 'esm'],
default: 'cjs'
};
const git = {
name: `git`,
message: `Would you like Git?`,
type: `checkbox`,
choices: [
{ name: 'git', value: true, checked: true },
{ name: '.gitignore', value: true, checked: true }
]
};
const compression = {
name: `compression`,
message: `(Extra) Would you like to add compression?`,
type: `confirm`,
default: true
};
const helmet = {
name: `helmet`,
type: `confirm`,
message: `(Extra) Would you like to add helmet?`,
default: true
};
const sequelize = {
name: `sequelize`,
type: `confirm`,
message: `(Extra) Would you like to add sequelize with postgres support?`,
default: true
};
const questions = [intro, projectName, monorepo, moduleSystem, git, compression, helmet, sequelize];
const prompt = async _questions => await inquirer.prompt(_questions);
module.exports = { questions, prompt };