-
Notifications
You must be signed in to change notification settings - Fork 1
/
setup.js
33 lines (29 loc) · 1.23 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
const fs = require('fs');
const readline = require('readline');
const { promisify } = require('util');
const writeFileAsync = promisify(fs.writeFile);
const rl = readline.createInterface({
input: process.stdin,
output: process.stdout
});
const questions = [
{ key: 'PLESKKEY', question: 'Enter your Plesk API Key: ' },
{ key: 'PLESKURL', question: 'Enter your Plesk URL: ' },
{ key: 'CLOUDKEY', question: 'Enter your Cloudflare API Key: ' },
{ key: 'CLOUDEMAIL', question: 'Enter your Cloudflare Email: ' },
{ key: 'CLOUDACCOUNTID', question: 'Enter your Cloudflare Account ID: ' },
{ key: 'EMAIL', question: 'Enter your email for notifications: ' },
{ key: 'SENDER', question: 'Enter the sender email address: ' },
{ key: 'SPASS', question: 'Enter the sender email password: ' },
{ key: 'HOST', question: 'Enter the SMTP host: ' },
];
(async () => {
const answers = {};
for (const { key, question } of questions) {
answers[key] = await new Promise(resolve => rl.question(question, resolve));
}
rl.close();
const envContent = Object.entries(answers).map(([key, value]) => `${key}=${value}`).join('\n');
await writeFileAsync('.env', envContent);
console.log('Environment variables set up successfully.');
})();