feat: enhance NodeCG runtime management and packaging

- Update .gitignore and .prettierignore to exclude additional cache and configuration files.
- Revise README.md for clarity on build processes and runtime behavior.
- Improve architecture documentation to reflect changes in startup flow and module responsibilities.
- Modify troubleshooting guide to address common runtime issues and installation steps.
- Enhance ESLint configuration to ignore more directories.
- Update package.json scripts for better build and distribution processes.
- Introduce build-scoreko-bundle.mjs for building the Scoreko bundle.
- Implement prepare-nodecg-runtime.mjs for managing NodeCG runtime installation and updates.
- Add runtime-provisioner.ts to handle user-specific NodeCG runtime provisioning.
- Create tests for runtime provisioning to ensure correct behavior.
- Refactor process-manager.ts and main.ts to integrate new runtime management logic.
This commit is contained in:
2026-05-09 17:45:36 +02:00
parent b10b8adb98
commit 41e4e91c4b
16 changed files with 737 additions and 100 deletions
+21 -20
View File
@@ -1,15 +1,20 @@
import { existsSync } from "node:fs";
import { existsSync, readFileSync } from "node:fs";
import path from "node:path";
import { spawn } from "node:child_process";
const root = process.cwd();
const nodecgDir = path.join(root, "lib", "nodecg");
const sqliteLegacyDir = path.join(nodecgDir, "workspaces", "database-adapter-sqlite-legacy");
const packageJson = JSON.parse(readFileSync(path.join(root, "package.json"), "utf8"));
const electronVersion = packageJson.devDependencies?.electron ?? packageJson.dependencies?.electron;
const npmCommand = process.platform === "win32" ? "npm.cmd" : "npm";
const moduleDirs = [nodecgDir, sqliteLegacyDir].filter((dir) => existsSync(path.join(dir, "package.json")));
if (!electronVersion) {
console.error("Could not determine Electron version from package.json.");
process.exit(1);
}
if (moduleDirs.length === 0) {
console.error("No NodeCG package folders found. Expected lib/nodecg and/or workspaces.");
if (!existsSync(path.join(nodecgDir, "package.json"))) {
console.error("No packaged NodeCG runtime found. Run npm run prepare:runtime first.");
process.exit(1);
}
@@ -23,8 +28,10 @@ function run(command, args, cwd) {
env: {
...process.env,
npm_config_runtime: "electron",
npm_config_target: "39.5.1",
npm_config_target: electronVersion,
npm_config_disturl: "https://electronjs.org/headers",
npm_config_cache: process.env.npm_config_cache ?? path.join(root, ".npm-runtime-cache"),
ELECTRON_CACHE: process.env.ELECTRON_CACHE ?? path.join(root, ".electron-cache"),
},
});
@@ -38,19 +45,13 @@ function run(command, args, cwd) {
});
}
for (const dir of moduleDirs) {
if (dir === sqliteLegacyDir) {
console.log(`\n[rebuild-native] Ensuring sqlite legacy workspace deps in: ${dir}`);
await run("npm", ["install"], dir);
await run("npm", ["install", "bindings", "--no-save"], dir);
}
console.log(`\n[rebuild-native] Rebuilding better-sqlite3 in: ${dir}`);
await run(
"npm",
["rebuild", "better-sqlite3", "--runtime=electron", "--target=39.5.1", "--dist-url=https://electronjs.org/headers"],
dir,
);
}
console.log(`\n[rebuild-native] Rebuilding better-sqlite3 for Electron ${electronVersion} in: ${nodecgDir}`);
await run(npmCommand, [
"rebuild",
"better-sqlite3",
"--runtime=electron",
`--target=${electronVersion}`,
"--dist-url=https://electronjs.org/headers",
], nodecgDir);
console.log("\n[rebuild-native] Done.");