-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathconfig_generator.js
More file actions
50 lines (43 loc) · 1.54 KB
/
config_generator.js
File metadata and controls
50 lines (43 loc) · 1.54 KB
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
import {v4 as genuuid} from "uuid"
import { createInterface } from "readline";
import fs from "fs/promises"
// function to get input from the user
function getInput(prompt) {
const rl = createInterface({
input: process.stdin,
output: process.stdout
});
return new Promise(resolve => {
rl.question(prompt, answer => {
rl.close();
resolve(answer);
});
});
}
function getBoolInput(prompt) {
const rl = createInterface({
input: process.stdin,
output: process.stdout
});
return new Promise(resolve => {
rl.question(prompt, answer => {
rl.close();
resolve(answer.toLowerCase() === "y" || answer.toLowerCase() === "yes" || answer.toLowerCase() === "true" || answer.toLowerCase() === "1");
});
});
}
const username = await getInput("Enter your username: ");
const uuidinput = await getInput("Enter your UUID (or just press enter to generate a new one): ");
const demo = await getBoolInput("Do you want to play in demo mode? (y/n): ");
const backup = await getBoolInput("Do you want to save a backup after every successful run? (y/n): ");
const uuid = uuidinput !== "" ? uuidinput : genuuid();
const config = {
"auth_player_name": username,
"auth_uuid": uuid,
"demo": demo,
"backup": backup,
};
console.log("Your UUID is:", uuid);
console.log("Don't share it with anyone!");
console.log("We recommend you to save it in a safe place.");
await fs.writeFile("./config.json", JSON.stringify(config, null, 4), "utf-8");