mirror of
https://github.com/Pandipipas/scoreko-electron-dev.git
synced 2026-06-06 05:32:06 +00:00
chore: clean NodeCG install validation checks
This commit is contained in:
@@ -37,6 +37,7 @@ function parseIntInRange(name, fallback, min, max) {
|
|||||||
|
|
||||||
function checkNodecgInstall() {
|
function checkNodecgInstall() {
|
||||||
const packageJsonPath = path.join(scorekoRootPath, "package.json");
|
const packageJsonPath = path.join(scorekoRootPath, "package.json");
|
||||||
|
const nodecgDependencyPath = path.join(scorekoRootPath, "node_modules", "nodecg", "package.json");
|
||||||
const nodecgCliPath = path.join(
|
const nodecgCliPath = path.join(
|
||||||
scorekoRootPath,
|
scorekoRootPath,
|
||||||
"node_modules",
|
"node_modules",
|
||||||
@@ -49,6 +50,7 @@ function checkNodecgInstall() {
|
|||||||
|
|
||||||
addCheck(fs.existsSync(scorekoRootPath), "Scoreko root", scorekoRootPath);
|
addCheck(fs.existsSync(scorekoRootPath), "Scoreko root", scorekoRootPath);
|
||||||
addCheck(fs.existsSync(packageJsonPath), "scoreko-dev package.json", packageJsonPath);
|
addCheck(fs.existsSync(packageJsonPath), "scoreko-dev package.json", packageJsonPath);
|
||||||
|
addCheck(fs.existsSync(nodecgDependencyPath), "NodeCG dependency", nodecgDependencyPath);
|
||||||
addCheck(fs.existsSync(nodecgCliPath), "NodeCG CLI", nodecgCliPath);
|
addCheck(fs.existsSync(nodecgCliPath), "NodeCG CLI", nodecgCliPath);
|
||||||
addCheck(
|
addCheck(
|
||||||
bundleAssetPaths.some((candidatePath) => fs.existsSync(candidatePath)),
|
bundleAssetPaths.some((candidatePath) => fs.existsSync(candidatePath)),
|
||||||
|
|||||||
@@ -52,12 +52,7 @@ export function createNodecgProcessManager({
|
|||||||
let lastStderrLine: string | null = null;
|
let lastStderrLine: string | null = null;
|
||||||
|
|
||||||
const startNodecgProcess = async (): Promise<ChildProcess> => {
|
const startNodecgProcess = async (): Promise<ChildProcess> => {
|
||||||
validateNodecgInstall(
|
validateNodecgInstall(nodecgRootPath, resolvedDeps.platform, resolvedDeps.pathExists, resolvedDeps.hasReadWriteAccess);
|
||||||
nodecgRootPath,
|
|
||||||
appConfig.bundleName,
|
|
||||||
resolvedDeps.pathExists,
|
|
||||||
resolvedDeps.hasReadWriteAccess,
|
|
||||||
);
|
|
||||||
|
|
||||||
const portAsNumber = Number.parseInt(appConfig.nodecgPort, 10);
|
const portAsNumber = Number.parseInt(appConfig.nodecgPort, 10);
|
||||||
const isPortAvailable = await resolvedDeps.probePortAvailable(portAsNumber);
|
const isPortAvailable = await resolvedDeps.probePortAvailable(portAsNumber);
|
||||||
@@ -211,17 +206,13 @@ function resolveDeps(deps?: Partial<NodecgProcessManagerDeps>): NodecgProcessMan
|
|||||||
|
|
||||||
function validateNodecgInstall(
|
function validateNodecgInstall(
|
||||||
nodecgRootPath: string,
|
nodecgRootPath: string,
|
||||||
bundleName: string,
|
platform: NodeJS.Platform,
|
||||||
pathExists: (candidatePath: string) => boolean,
|
pathExists: (candidatePath: string) => boolean,
|
||||||
hasReadWriteAccessToPath: (candidatePath: string) => boolean,
|
hasReadWriteAccessToPath: (candidatePath: string) => boolean,
|
||||||
): void {
|
): void {
|
||||||
const packageJsonPath = path.join(nodecgRootPath, "package.json");
|
const packageJsonPath = path.join(nodecgRootPath, "package.json");
|
||||||
const nodecgCliPath = path.join(
|
const nodecgDependencyPath = path.join(nodecgRootPath, "node_modules", "nodecg", "package.json");
|
||||||
nodecgRootPath,
|
const nodecgCliPath = path.join(nodecgRootPath, "node_modules", ".bin", platform === "win32" ? "nodecg.cmd" : "nodecg");
|
||||||
"node_modules",
|
|
||||||
".bin",
|
|
||||||
process.platform === "win32" ? "nodecg.cmd" : "nodecg",
|
|
||||||
);
|
|
||||||
const bundleAssetDirs = ["dashboard", "graphics", "extension", "extensions"].map((dir) =>
|
const bundleAssetDirs = ["dashboard", "graphics", "extension", "extensions"].map((dir) =>
|
||||||
path.join(nodecgRootPath, dir),
|
path.join(nodecgRootPath, dir),
|
||||||
);
|
);
|
||||||
@@ -238,11 +229,11 @@ function validateNodecgInstall(
|
|||||||
throw new Error(`${packageJsonPath} was not found. Expected a NodeCG bundle app at lib/scoreko-dev.`);
|
throw new Error(`${packageJsonPath} was not found. Expected a NodeCG bundle app at lib/scoreko-dev.`);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!pathExists(nodecgCliPath)) {
|
if (!pathExists(nodecgDependencyPath) || !pathExists(nodecgCliPath)) {
|
||||||
throw new Error(
|
throw new Error(
|
||||||
[
|
[
|
||||||
"NodeCG dependency is missing in lib/scoreko-dev.",
|
"NodeCG dependency is missing in lib/scoreko-dev.",
|
||||||
`Not found: ${nodecgCliPath}`,
|
`Not found: ${nodecgDependencyPath} and/or ${nodecgCliPath}`,
|
||||||
"Solution: enter lib/scoreko-dev and install dependencies:",
|
"Solution: enter lib/scoreko-dev and install dependencies:",
|
||||||
" npm install",
|
" npm install",
|
||||||
].join("\n"),
|
].join("\n"),
|
||||||
@@ -252,7 +243,7 @@ function validateNodecgInstall(
|
|||||||
if (!bundleAssetDirs.some((candidatePath) => pathExists(candidatePath))) {
|
if (!bundleAssetDirs.some((candidatePath) => pathExists(candidatePath))) {
|
||||||
throw new Error(
|
throw new Error(
|
||||||
[
|
[
|
||||||
`Bundle '${bundleName}' appears incomplete.`,
|
"scoreko-dev bundle appears incomplete.",
|
||||||
`Expected one of: ${bundleAssetDirs.join(", ")}`,
|
`Expected one of: ${bundleAssetDirs.join(", ")}`,
|
||||||
"Ensure extensions/dashboard/graphics assets exist inside lib/scoreko-dev.",
|
"Ensure extensions/dashboard/graphics assets exist inside lib/scoreko-dev.",
|
||||||
].join("\n"),
|
].join("\n"),
|
||||||
|
|||||||
Reference in New Issue
Block a user