-
Notifications
You must be signed in to change notification settings - Fork 54
/
entry.js
46 lines (38 loc) · 1011 Bytes
/
entry.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
const fs = require('fs');
const os = require('os');
// 设置前端默认值
const frontEnv = {
VITE_DEFAULT_PLACEHOLDER: 'Send a message to AI',
VITE_DEFAULT_BOTTOM_TIPS: '""',
VITE_API_HOST: 'http://localhost:3000/aios-chat',
VITE_CACHE_TIMES: 10,
// VITE_ONLY_TEXT: true,
VITE_BASE_URL: '/',
VITE_AI_AVATOR_URL: '""',
VITE_LOGO_URL:'""',
VITE_USER_AVATOR_URL:'""',
};
// 设置后端默认值
const backEnv = {
API_KEY: '""',
PORT: 3000,
RETRIES: 3,
}
function getEnvString(obj) {
let envString = '';
for (const key in obj) {
if (process.env[key]) {
obj[key] = process.env[key];
}
envString += `${key}=${obj[key]}${os.EOL}`;
}
return envString;
}
const frontEnvString = getEnvString(frontEnv);
const backEnvString = getEnvString(backEnv);
if (!fs.existsSync('.env.development')) {
fs.writeFileSync('.env.development', frontEnvString);
}
if (!fs.existsSync('./api/.env.development')) {
fs.writeFileSync('./api/.env.development', backEnvString);
}