This repository has been archived by the owner on Mar 27, 2024. It is now read-only.
forked from AgoraIO-Community/app-builder-core
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdevSetup.js
93 lines (86 loc) · 2.25 KB
/
devSetup.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
90
91
92
93
const path = require('path');
const fs = require('fs/promises');
const ROOT = path.join(process.cwd(), 'template');
console.log('\n\n\tConfiguring the project for dev environment');
const dotFiles = [
'_buckconfig',
'_eslintrc.js',
'_gitattributes',
'_prettierrc.js',
'_watchmanconfig',
];
async function processDotfiles() {
try {
let dotPromises = [];
const files = await fs.readdir(ROOT);
files.forEach(async (file) => {
if (dotFiles.includes(file)) {
const baseFileName = file.slice(1);
dotPromises.push(
fs.copyFile(
path.join(ROOT, `_${baseFileName}`),
path.join(ROOT, `.${baseFileName}`),
),
);
}
});
await Promise.all(dotPromises);
console.log('\t✓ Generated dot files\n');
} catch (e) {
console.error(e);
}
}
async function copyConfig() {
try {
const mode = process.argv[2] || 'meeting';
const theme = process.argv[3] || 'dark';
let configFile;
switch (mode) {
case 'meeting':
configFile = theme === 'dark' ? 'config.json' : 'config.light.json';
break;
case 'live-streaming':
configFile =
theme === 'dark'
? 'live-streaming.config.json'
: 'live-streaming.config.light.json';
break;
case 'voice-chat':
configFile =
theme === 'dark'
? 'voice-chat.config.json'
: 'voice-chat.config.light.json';
break;
case 'audio-livecast':
configFile =
theme === 'dark'
? 'audio-livecast.config.json'
: 'audio-livecast.config.light.json';
break;
default:
configFile = theme === 'dark' ? 'config.json' : 'config.light.json';
break;
}
await fs.copyFile(
path.join(process.cwd(), configFile),
path.join(ROOT, 'config.json'),
);
console.log('\t✓ Added dev config in the template');
} catch (e) {
console.error(e);
}
}
async function copyTheme() {
try {
await fs.copyFile(
path.join(process.cwd(), 'theme.json'),
path.join(ROOT, 'theme.json'),
);
console.log('\t✓ Added theme in the template');
} catch (e) {
console.error(e);
}
}
processDotfiles();
copyConfig();
copyTheme();