feat: Implement application bootstrap and window management

- Added bootstrap functionality to initialize the Electron application.
- Created a new paths module to manage application paths and URLs.
- Introduced a shutdown service to handle graceful application shutdowns.
- Refactored error logging to use a dedicated logger module.
- Implemented process killing logic for NodeCG processes across platforms.
- Established navigation policies for internal and external URL handling in windows.
- Developed window service for creating and managing application windows.
- Added tests for application paths, application controller, navigation policies, process killer, and shutdown service.
This commit is contained in:
2026-05-24 16:14:23 +02:00
parent c168c3b84a
commit e3d3936156
17 changed files with 1067 additions and 264 deletions
+47
View File
@@ -0,0 +1,47 @@
import assert from "node:assert/strict";
import path from "node:path";
import test from "node:test";
import {
getApplicationPaths,
getDashboardUrl,
getNodecgBaseUrl,
getRootPath,
getSourceNodecgRuntimePath,
getUserDataPath,
} from "../main/app/paths";
test("app path helpers build deterministic development paths and URLs", () => {
const compiledMainDir = path.join("repo", "dist", "main");
const rootPath = getRootPath(true, compiledMainDir, "/resources");
assert.equal(rootPath, path.resolve(compiledMainDir, "../.."));
assert.equal(getSourceNodecgRuntimePath(rootPath), path.resolve(rootPath, "lib", "nodecg"));
assert.equal(getUserDataPath("/app-data", "scoreko"), path.join("/app-data", "scoreko"));
assert.equal(getNodecgBaseUrl("9090"), "http://127.0.0.1:9090");
assert.equal(
getDashboardUrl("9090", "scoreko-dev", "dashboard/main.html?standalone=true"),
"http://localhost:9090/bundles/scoreko-dev/dashboard/main.html?standalone=true",
);
});
test("getApplicationPaths keeps packaged root under Electron resources", () => {
const paths = getApplicationPaths({
appConfig: {
userDataDirectoryName: "scoreko",
nodecgPort: "9090",
bundleName: "scoreko-dev",
mainDashboardRoute: "dashboard/scoreko-dev/main.html?standalone=true",
loadingDashboardRoute: "dashboard/loading/main.html?standalone=true",
},
appDataPath: "/users/test/AppData/Roaming",
compiledMainDir: "/app/dist/main",
isDev: false,
resourcesPath: "/opt/Scoreko/resources",
});
assert.equal(paths.rootPath, "/opt/Scoreko/resources");
assert.equal(paths.sourceNodecgRuntimePath, path.resolve("/opt/Scoreko/resources", "lib", "nodecg"));
assert.equal(paths.userDataPath, path.join("/users/test/AppData/Roaming", "scoreko"));
assert.equal(paths.nodecgBaseUrl, "http://127.0.0.1:9090");
});