-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.ts
84 lines (68 loc) · 2.83 KB
/
index.ts
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
74
75
76
77
78
79
80
81
82
83
84
#!/usr/bin/env node
import inquirer from 'inquirer';
import path from 'path';
// Types
import { FirstsQuestionProps, SeparetedFiles, UserInputProps } from './src/types/index.js';
import { firstQuestion, questions, separetedFiles } from './src/promptArrays/index.js';
import criarEstruturaDePastasReactTsWebpack from './src/templates/react-ts-webpack/index.js';
import createAndInstallTsEslintPrettier from './src/presets/ts-eslint-prettier/index.js';
import simpleHtmlJsCssStructure from './src/templates/simpleHtmlJsCssStructure/index.js';
import createAndInstallJsEslint from './src/presets/js-eslint/index.js';
import jsExpressSequeliseDotenvNodemonSucraseServerFolderStruct from './src/templates/js-express-sequelise-dotenv-nodemon-sucrase/index.js';
import tsExpressSequeliseDotenvNodemonServerFolderStruct from './src/templates/ts-express-sequelise-dotenv-nodemon/index.js';
inquirer.prompt(firstQuestion).then((answer) => {
const userFisrtInput: FirstsQuestionProps = {
firstQuestionChoice: answer.firstQuestionChoice,
packageManager: answer.packageManager,
};
if (userFisrtInput.firstQuestionChoice === 'Complete template') {
inquirer.prompt(questions).then((answers) => {
const currentFolder = path.basename(process.cwd()).replace(/\s+/g, '-');
const userInput: UserInputProps = {
packageManager: userFisrtInput.packageManager,
appName: answers.appName || currentFolder,
appDescription: answers.appDescription || 'App Description',
appAuthor: answers.appAuthor || '',
appLicense: answers.appLicense || 'ISC',
selectedTemplate: answers.template,
};
switch (userInput.selectedTemplate) {
case 'reactjs_ts_webpack_react-router-dom_styled-components_babel':
criarEstruturaDePastasReactTsWebpack(userInput);
break;
case 'simple-Html-Js-Css-Structure':
simpleHtmlJsCssStructure(userInput);
break;
case 'js-express-sequelise-dotenv-nodemon-sucrase':
jsExpressSequeliseDotenvNodemonSucraseServerFolderStruct(userInput);
break;
case 'ts-express-sequelise-dotenv-nodemon-tsnode':
tsExpressSequeliseDotenvNodemonServerFolderStruct(userInput);
break;
default:
console.error("This template doesn't exist");
break;
}
});
} else if (userFisrtInput.firstQuestionChoice === 'Separete files') {
inquirer.prompt(separetedFiles).then((answers) => {
const separetedFiles: SeparetedFiles = {
packageManager: userFisrtInput.packageManager,
filesToInstall: answers.filesToInstall,
};
switch (separetedFiles.filesToInstall) {
case 'ts-eslint-prettier':
createAndInstallTsEslintPrettier(separetedFiles);
break;
case 'js-eslint-generic':
createAndInstallJsEslint(separetedFiles);
break;
default:
console.error("This files doesn't exist");
break;
}
});
} else {
console.error('Exit, Process finished');
}
});