-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathprompts.js
89 lines (78 loc) · 1.85 KB
/
prompts.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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
const prompts = require('prompts');
const onCancel = prompt => {
console.log('Exited Bunsoir!');
process.exit(1)
}
const projectNamePrompt = async (name) => {
return await prompts({
type: 'text',
name: 'value',
initial: name,
message: 'Project name',
}, { onCancel });
}
const frameworkPrompt = async () => {
return await prompts({
type: 'select',
name: 'value',
message: 'Select your preferred framework',
choices: [
{ title: '🦊 ElysiaJS', value: 'elysia' },
{ title: '🔥 Hono', value: 'hono' },
{ title: 'No framework', value: false },
],
max: 1,
}, { onCancel });
}
const ormPrompt = async () => {
return await prompts({
type: 'select',
name: 'value',
message: 'Select your preferred ORM',
choices: [
{ title: 'Drizzle', value: 'drizzle' },
{ title: '🚧 Prisma', value: 'prisma', disabled: true },
{ title: 'No ORM', value: false },
],
max: 1,
}, { onCancel });
}
const databasePrompt = async (orm) => {
let dbs = []
if (orm === 'drizzle') {
dbs = [
{ title: 'PostgreSQL', value: 'postgresql' },
{ title: 'MySQL', value: 'mysql' },
{ title: 'SQLite', value: 'sqlite' },
]
}
if (orm === 'prisma') {
dbs = [
{ title: 'PostgreSQL', value: 'postgresql' },
{ title: 'MySQL', value: 'mysql' },
{ title: 'mongoDB', value: 'mongodb' },
]
}
return await prompts({
type: 'select',
name: 'value',
message: 'Select your preferred database',
choices: dbs,
max: 1,
}, { onCancel })
}
const dockerPrompt = async () => {
return await prompts({
type: 'confirm',
name: 'value',
message: '🐳 Do you want to include Docker?',
initial: true
}, { onCancel });
}
module.exports = {
projectNamePrompt,
frameworkPrompt,
ormPrompt,
databasePrompt,
dockerPrompt
}