build: modify SVR.JS configuration in installation script

This commit is contained in:
Dorian Niemiec 2025-01-26 18:11:02 +01:00
parent 95cb12a9f3
commit 770ae5fbd0
3 changed files with 38 additions and 3 deletions

19
package-lock.json generated
View file

@ -31,6 +31,7 @@
"prettier": "^3.3.3",
"rimraf": "^5.0.10",
"wait-on": "^8.0.1",
"yaml": "^2.7.0",
"zip": "^1.2.0"
}
},
@ -5897,6 +5898,18 @@
"url": "https://github.com/sponsors/sindresorhus"
}
},
"node_modules/lint-staged/node_modules/yaml": {
"version": "2.6.1",
"resolved": "https://registry.npmjs.org/yaml/-/yaml-2.6.1.tgz",
"integrity": "sha512-7r0XPzioN/Q9kXBro/XPnA6kznR73DHq+GXh5ON7ZozRO6aMjbmiBuKste2wslTFkC5d1dw0GooOCepZXJ2SAg==",
"dev": true,
"bin": {
"yaml": "bin.mjs"
},
"engines": {
"node": ">= 14"
}
},
"node_modules/listr2": {
"version": "8.2.5",
"resolved": "https://registry.npmjs.org/listr2/-/listr2-8.2.5.tgz",
@ -8021,9 +8034,9 @@
"dev": true
},
"node_modules/yaml": {
"version": "2.6.1",
"resolved": "https://registry.npmjs.org/yaml/-/yaml-2.6.1.tgz",
"integrity": "sha512-7r0XPzioN/Q9kXBro/XPnA6kznR73DHq+GXh5ON7ZozRO6aMjbmiBuKste2wslTFkC5d1dw0GooOCepZXJ2SAg==",
"version": "2.7.0",
"resolved": "https://registry.npmjs.org/yaml/-/yaml-2.7.0.tgz",
"integrity": "sha512-+hSoy/QHluxmC9kCIJyL/uyFmLmc+e5CFR5Wa+bpIhIj85LVb9ZH2nVnqrHoSvKogwODv0ClqZkmiSSaIH5LTA==",
"dev": true,
"bin": {
"yaml": "bin.mjs"

View file

@ -33,6 +33,7 @@
"prettier": "^3.3.3",
"rimraf": "^5.0.10",
"wait-on": "^8.0.1",
"yaml": "^2.7.0",
"zip": "^1.2.0"
},
"dependencies": {

View file

@ -4,6 +4,7 @@ const fs = require("fs");
const https = require("https");
const zip = require("zip");
const zlib = require("zlib");
const YAML = require("yaml");
function downloadSVRJS(version) {
const normalizedVersion = version.toLowerCase().replace(/[^0-9a-z]+/g, ".");
@ -68,6 +69,26 @@ function downloadSVRJS(version) {
fs.unlinkSync(__dirname + "/svrjs/svr.compressed");
fs.writeFileSync(__dirname + "/svrjs/svr.js", script);
}
if (fs.existsSync(__dirname + "/svrjs/svrjs.yaml")) {
console.log("Modifying SVR.JS configuration...");
let svrjsConfig = YAML.parse(fs.readFileSync(__dirname + "/svrjs/svrjs.yaml"));
if (!svrjsConfig) svrjsConfig = {};
if (!svrjsConfig.global) svrjsConfig.global = {};
svrjsConfig.global.enableDirectoryListing = true;
svrjsConfig.global.stackHidden = false;
svrjsConfig.global.exposeServerVersion = true;
svrjsConfig.global.exposeModsInErrorPages = true;
fs.writeFileSync(__dirname + "/svrjs/svrjs.yaml", YAML.stringify(svrjsConfig));
} else if (fs.existsSync(__dirname + "/svrjs/config.json")) {
console.log("Modifying SVR.JS configuration...");
let svrjsConfig = JSON.parse(fs.readFileSync(__dirname + "/svrjs/config.json"));
if (!svrjsConfig) svrjsConfig = {};
svrjsConfig.enableDirectoryListing = true;
svrjsConfig.stackHidden = false;
svrjsConfig.exposeServerVersion = true;
svrjsConfig.exposeModsInErrorPages = true;
fs.writeFileSync(__dirname + "/svrjs/svrjs.yaml", JSON.stringify(svrjsConfig, null, 2));
}
console.log("SVR.JS is installed successfully.");
});
}