-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsetup.js
69 lines (60 loc) · 1.69 KB
/
setup.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
const fs = require('fs');
const path = require('path');
const config = require('./config');
// Get project root directory
const rootDir = __dirname;
const dirs = [
path.join(rootDir, 'data'),
path.join(rootDir, 'uploads'),
path.join(rootDir, 'uploads/icons'),
path.join(rootDir, 'uploads/projects')
];
// Create directories
dirs.forEach(dir => {
try {
if (!fs.existsSync(dir)) {
fs.mkdirSync(dir, { recursive: true, mode: 0o755 });
console.log(`Created directory: ${dir}`);
}
} catch (error) {
console.error(`Error creating directory ${dir}:`, error);
}
});
// Create projects file
const projectsFile = path.join(rootDir, 'data', 'projects.json');
if (!fs.existsSync(projectsFile)) {
try {
const defaultData = {
projects: []
};
fs.writeFileSync(projectsFile, JSON.stringify(defaultData, null, 2), { mode: 0o644 });
console.log('Created projects.json with default structure');
} catch (error) {
console.error('Error creating projects.json:', error);
}
}
// Create SSL configuration
const sslConfig = `
[req]
default_bits = 2048
prompt = no
default_md = sha256
x509_extensions = v3_req
distinguished_name = dn
[dn]
C = TR
ST = Istanbul
L = Istanbul
O = Mercury App Center
OU = Development
CN = *
[v3_req]
basicConstraints = CA:TRUE
keyUsage = digitalSignature, keyEncipherment, keyCertSign
extendedKeyUsage = serverAuth, clientAuth
subjectAltName = @alt_names
[alt_names]
${config.ssl.domains.map((domain, index) => `DNS.${index + 1} = ${domain}`).join('\n')}
${config.ssl.ips.map((ip, index) => `IP.${index + 1} = ${ip}`).join('\n')}
`;
fs.writeFileSync('ssl.conf', sslConfig);