mirror of
https://github.com/Pandipipas/scoreko-electron-dev.git
synced 2026-06-05 21:22:07 +00:00
865c3589bd
- Updated paths and configurations in doctor.mjs and prepare-nodecg-runtime.mjs to use new build-config.mjs imports. - Enhanced runtime installation checks and permissions validation. - Introduced new update configuration management in update-config.ts, including loading and validating update settings. - Implemented update service for managing update checks and downloads in update-service.ts. - Replaced update-utils.ts with update-schema.ts for better structure and clarity in update handling. - Added comprehensive tests for update download and settings management. - Ensured secure handling of download URLs and improved error handling in update processes.
82 lines
2.2 KiB
JavaScript
82 lines
2.2 KiB
JavaScript
#!/usr/bin/env node
|
|
import { existsSync, mkdirSync, rmSync } from "node:fs";
|
|
import path from "node:path";
|
|
import { spawnSync } from "node:child_process";
|
|
|
|
import {
|
|
bundleRoot,
|
|
bundleRootMarkers,
|
|
electronRoot,
|
|
generatedBundleEntries,
|
|
getLocalBinPath,
|
|
getPathInside,
|
|
} from "./build-config.mjs";
|
|
|
|
const nodeModulesPath = path.join(bundleRoot, "node_modules");
|
|
|
|
const missingMarkers = bundleRootMarkers
|
|
.map((entry) => path.join(bundleRoot, entry))
|
|
.filter((candidatePath) => !existsSync(candidatePath));
|
|
|
|
if (missingMarkers.length > 0) {
|
|
console.error(
|
|
[
|
|
`Scoreko bundle root was not found at: ${bundleRoot}`,
|
|
"This Electron package expects to live inside the Scoreko repository with the bundle project as its parent.",
|
|
...missingMarkers.map((candidatePath) => `Missing: ${candidatePath}`),
|
|
].join("\n"),
|
|
);
|
|
process.exit(1);
|
|
}
|
|
|
|
if (!existsSync(nodeModulesPath)) {
|
|
console.error(
|
|
[
|
|
"The Scoreko bundle dependencies are not installed.",
|
|
`Run this once from ${bundleRoot}:`,
|
|
" pnpm install",
|
|
].join("\n"),
|
|
);
|
|
process.exit(1);
|
|
}
|
|
|
|
const childEnv = {
|
|
...process.env,
|
|
COREPACK_HOME: process.env.COREPACK_HOME ?? path.join(electronRoot, ".corepack"),
|
|
PATH: `${path.join(bundleRoot, "node_modules", ".bin")}${path.delimiter}${process.env.PATH ?? ""}`,
|
|
};
|
|
|
|
function removeGeneratedOutput(relativePath) {
|
|
const targetPath = getPathInside(bundleRoot, relativePath);
|
|
rmSync(targetPath, { recursive: true, force: true });
|
|
}
|
|
|
|
function runCommand(command, args) {
|
|
const result = spawnSync(command, args, {
|
|
cwd: bundleRoot,
|
|
stdio: "inherit",
|
|
shell: process.platform === "win32",
|
|
env: childEnv,
|
|
});
|
|
|
|
if (result.error) {
|
|
console.error(`Could not run '${command} ${args.join(" ")}': ${result.error.message}`);
|
|
process.exit(1);
|
|
}
|
|
|
|
if (result.status !== 0) {
|
|
process.exit(result.status ?? 1);
|
|
}
|
|
}
|
|
|
|
for (const entry of generatedBundleEntries) {
|
|
removeGeneratedOutput(entry);
|
|
}
|
|
|
|
for (const entry of ["shared/dist", "dashboard", "graphics", "extension"]) {
|
|
mkdirSync(path.join(bundleRoot, entry), { recursive: true });
|
|
}
|
|
|
|
runCommand(getLocalBinPath("vite"), ["build", "--configLoader", "runner"]);
|
|
runCommand(getLocalBinPath("tsc"), ["-b", "tsconfig.extension.json"]);
|