-
-
Notifications
You must be signed in to change notification settings - Fork 3.6k
/
questions.ts
75 lines (65 loc) · 1.63 KB
/
questions.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
import path from 'path';
const filename = ({ filepath }: { filepath: string }): Record<string, string> => ({
type: 'input',
name: 'filename',
message: 'Database File Path:',
default: path.join(filepath, 'data.db'),
});
const host = (): Record<string, string> => ({
type: 'input',
name: 'host',
message: 'Database Host:',
default: '127.0.0.1',
});
const port = ({ client }: { client: string }): Record<string, any> => ({
type: 'input',
name: 'port',
message: 'Port:',
default() {
const ports: Record<string, number> = {
pg: 5432,
cockroachdb: 26257,
mysql: 3306,
oracledb: 1521,
mssql: 1433,
};
return ports[client];
},
});
const database = (): Record<string, string> => ({
type: 'input',
name: 'database',
message: 'Database Name:',
default: 'directus',
});
const user = (): Record<string, string> => ({
type: 'input',
name: 'user',
message: 'Database User:',
});
const password = (): Record<string, string> => ({
type: 'password',
name: 'password',
message: 'Database Password:',
mask: '*',
});
const encrypt = (): Record<string, string | boolean> => ({
type: 'confirm',
name: 'options__encrypt',
message: 'Encrypt Connection:',
default: false,
});
const ssl = (): Record<string, string | boolean> => ({
type: 'confirm',
name: 'ssl',
message: 'Enable SSL:',
default: false,
});
export const databaseQuestions = {
sqlite3: [filename],
mysql: [host, port, database, user, password],
pg: [host, port, database, user, password, ssl],
cockroachdb: [host, port, database, user, password, ssl],
oracledb: [host, port, database, user, password],
mssql: [host, port, database, user, password, encrypt],
};