fix: use jsonc-parser in config merge and make updater reliably restart all services
merge-config.cjs loaded json5 (not installed, and unable to parse JSONC comments), so sync_configs crashed mid-update and do_restart never ran — leaving the emulator running the old JAR. - merge-config.cjs: switch from json5 to jsonc-parser (already a dependency) to parse .jsonc configs including comments - update-Nitrov3.sh: always run renderer/client parallel builds instead of gating them on the emulator's update status - update-Nitrov3.sh: isolate each repo's yarn cache (--cache-folder) so parallel installs can't corrupt a shared cache and silently drop vite/pixi.js; replace invalid --no-cache flag with per-repo cache reset - update-Nitrov3.sh: fix misleading [DRY-RUN] label on real updates
This commit is contained in:
1 parent
abc06e438c
commit
9e453666e5
2 files changed
+104
-46
No files matched your search
+31
-12
@@ -1,5 +1,5 @@
|
|||||||
const fs = require("node:fs");
|
const fs = require("node:fs");
|
||||||
const JSON5 = require("json5");
|
const { parse, printParseErrorCode } = require("jsonc-parser");
|
||||||
|
|
||||||
const exampleFile = process.argv[2];
|
const exampleFile = process.argv[2];
|
||||||
const targetFile = process.argv[3];
|
const targetFile = process.argv[3];
|
||||||
@@ -26,28 +26,47 @@ function deepMerge(target, source) {
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function parseJsonc(file) {
|
||||||
|
if (!fs.existsSync(file)) {
|
||||||
|
return undefined;
|
||||||
|
}
|
||||||
|
const content = fs.readFileSync(file, "utf-8");
|
||||||
|
const errors = [];
|
||||||
|
const value = parse(content, errors, {
|
||||||
|
allowTrailingComma: true,
|
||||||
|
allowEmptyContent: true,
|
||||||
|
});
|
||||||
|
if (errors.length > 0) {
|
||||||
|
console.error(
|
||||||
|
`[merge-config] parse error in ${file}: ${errors
|
||||||
|
.map((e) => printParseErrorCode(e.error))
|
||||||
|
.join(", ")}`,
|
||||||
|
);
|
||||||
|
return undefined;
|
||||||
|
}
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
|
||||||
let example;
|
let example;
|
||||||
try {
|
try {
|
||||||
const content = fs.readFileSync(exampleFile, "utf-8");
|
example = parseJsonc(exampleFile);
|
||||||
example = JSON5.parse(content);
|
|
||||||
} catch {
|
} catch {
|
||||||
process.exit(1);
|
process.exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (example === undefined) {
|
||||||
|
process.exit(1);
|
||||||
|
}
|
||||||
|
|
||||||
let current = {};
|
let current = {};
|
||||||
try {
|
try {
|
||||||
if (fs.existsSync(targetFile)) {
|
const parsed = parseJsonc(targetFile);
|
||||||
const content = fs.readFileSync(targetFile, "utf-8");
|
if (parsed !== undefined && parsed !== null) {
|
||||||
current = JSON5.parse(content);
|
current = parsed;
|
||||||
}
|
}
|
||||||
} catch {
|
} catch {
|
||||||
current = {};
|
current = {};
|
||||||
}
|
}
|
||||||
|
|
||||||
const merged = deepMerge(current, example);
|
const merged = deepMerge(current, example);
|
||||||
|
fs.writeFileSync(targetFile, `${JSON.stringify(merged, null, 4)}\n`);
|
||||||
const isJson5 = targetFile.endsWith(".json5");
|
|
||||||
const output = isJson5
|
|
||||||
? JSON5.stringify(merged, null, 4)
|
|
||||||
: JSON.stringify(merged, null, 4);
|
|
||||||
fs.writeFileSync(targetFile, `${output}\n`);
|
|
||||||
+73
-34
File diff suppressed because it is too large.
Load diff
Reference in new issue
Block a user