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
+34 -36
View File
@@ -1,53 +1,51 @@
# scoreko-electron
Desktop app (Electron + TypeScript) to run and package a NodeCG installation with the `scoreko-dev` bundle.
Windows desktop installer for Scoreko. The packaged app includes Electron, NodeCG, the compiled `scoreko-dev` bundle, and the production modules needed to run it, so end users do not need Node.js, pnpm, or a cloned repository.
## Requirements
## Build on a development machine
- Node.js `>=22`
- Dependencies installed with `npm install`
From the repository root:
## Available scripts
```powershell
pnpm install
```
### Development
Then from `scoreko-electron-dev`:
- `npm run dev`: compiles in watch mode and opens Electron.
- `npm run watch`: TypeScript watch mode.
- `npm run dev:electron`: opens Electron when `dist/main/main.js` is ready.
- `npm run start`: full build and local run.
```powershell
npm install
npm run dist:win
```
### Build and distribution
The installer is written to `scoreko-electron-dev/release/Scoreko-setup-0.1.0.exe`.
- `npm run clean`: removes `dist` and `release`.
- `npm run typecheck`: validates types without emitting files.
- `npm run build`: compiles TypeScript and copies assets.
- `npm run pack`: generates the app without an installer (`electron-builder --dir`).
- `npm run dist:win`: builds a Windows installer.
- `npm run dist:linux`: builds a Linux AppImage.
- `npm run dist:mac`: builds a macOS package.
- `npm run dist:all`: builds artifacts for Windows, Linux, and macOS.
## What the build does
### Quality and diagnostics
- Builds the parent `scoreko-dev` bundle with `pnpm build`.
- Creates `scoreko-electron-dev/lib/nodecg` with a small NodeCG runtime.
- Installs production runtime modules into that runtime.
- Rebuilds `better-sqlite3` for Electron before creating the installer.
- Packages the runtime as an Electron extra resource outside the app archive.
- `npm run test`: build and tests (`node:test`).
- `npm run doctor`: environment/configuration diagnostics.
- `npm run lint`: lint with ESLint.
- `npm run lint:fix`: lint with auto-fix.
- `npm run format`: checks formatting with Prettier.
- `npm run format:write`: applies formatting with Prettier.
## Runtime behavior
### Native modules
On first launch, Scoreko copies the packaged NodeCG runtime to the user's app data folder and runs it from there. This keeps `cfg`, `db`, and `logs` writable on Windows even when the app is installed under `Program Files`.
- `npm run rebuild:native`: rebuilds NodeCG native modules.
- `npm run rebuild:better-sqlite3`: rebuilds only `better-sqlite3` for Electron.
## Useful scripts
## Quick setup
- `npm run start`: build everything and run Electron locally.
- `npm run prepare:runtime`: recreate `lib/nodecg` from the parent bundle.
- `npm run rebuild:native`: rebuild NodeCG native modules for Electron.
- `npm run dist:win`: create the Windows installer.
- `npm run doctor`: check the prepared runtime and the configured port.
1. Copy `.env.example` to `.env`.
2. Adjust variables for your environment.
3. Run `npm run doctor` before developing or packaging.
## Configuration
## References
The defaults match the parent bundle:
- Troubleshooting: `docs/troubleshooting.md`
- Architecture: `docs/architecture.md`
- `NODECG_BUNDLE_NAME=scoreko-dev`
- `NODECG_PORT=9090`
- `SCOREKO_DASHBOARD_ROUTE=dashboard/scoreko-dev/main.html?standalone=true`
- `SCOREKO_LOADING_ROUTE=dashboard/loading/main.html?standalone=true`
Copy `.env.example` only if you need local overrides while developing.