-
Notifications
You must be signed in to change notification settings - Fork 25
Expand file tree
/
Copy pathprompts.js
More file actions
128 lines (107 loc) · 2.64 KB
/
prompts.js
File metadata and controls
128 lines (107 loc) · 2.64 KB
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
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
import inquirer from "inquirer";
export async function promptProjectName() {
const ans = await inquirer.prompt([
{
type: "input",
name: "projectName",
message: "Enter project name:",
},
]);
return ans.projectName;
}
export async function promptProjectStack() {
const ans = await inquirer.prompt([
{
type: "list",
name: "projectStack",
message: "Choose your stack:",
choices: ["Frontend", "Backend"],
},
]);
return ans.projectStack.toLowerCase();
}
export async function promptFrontendFramework() {
const ans = await inquirer.prompt([
{
type: "list",
name: "framework",
message: "Choose a framework:",
choices: ["ReactJs"],
},
]);
return ans.framework.toLowerCase().replace(/ /g, "-");
}
export async function promptFrontendLanguage() {
const ans = await inquirer.prompt([
{
type: "list",
name: "language",
message: "Choose Your Preferred Language:",
choices: ["JavaScript", "TypeScript"],
},
]);
return ans.language.toLowerCase().replace(/ /g, "-");
}
export async function promptStylingOption() {
const ans = await inquirer.prompt([
{
type: "list",
name: "styling_option",
message: "Choose Your Preferred Styling Option:",
choices: ["CSS", "TailwindCSS"],
},
]);
return ans.styling_option.toLowerCase().replace(/ /g, "-");
}
export async function promptBackendFramework() {
const ans = await inquirer.prompt([
{
type: "list",
name: "framework",
message: "Choose a framework:",
choices: ["NestJS", "ExpressJs", "Django"],
},
]);
return ans.framework.toLowerCase().replace(/ /g, "-");
}
export async function promptDatabase(framework) {
const choices = framework === "django" ? ["SQLite3"] : ["MongoDB"];
const ans = await inquirer.prompt([
{
type: "list",
name: "database",
message: "select a database",
choices,
},
]);
return ans.database.toLowerCase();
}
export async function promptInitDatabase() {
const ans = await inquirer.prompt([
{
type: "confirm",
name: "initDB",
message: "Initialize Database?",
default: false,
},
]);
return ans.initDB;
}
export async function promptOrm(database) {
database = database?.toLowerCase() ?? "";
let ormChoices = [];
if (database === "mongodb") {
ormChoices = ["Mongoose"];
} else {
ormChoices = ["Typeorm"];
}
const ans = await inquirer.prompt([
{
type: "list",
name: "database",
message: "select your preferred ORM",
choices: ormChoices,
},
]);
return ans.database.toLowerCase();
}