Release adaptation packs and let the launcher install them
An adaptation pack is the patch set (exe, GUI, native definitions and version records) released on its own, so a new game build can be adapted without a new offline version. It is a zip with a manifest, signed with Ed25519, published as a GitHub release tagged patches-<YYYY.MM.DD[.N]>. - packages/patcher/src/patch-pack: manifest and version numbers, zip writing and reading with path and size checks, signatures, a check that a patch set reads as a whole; tuning/patch-pack.jsonc holds the repository and the limits. - scripts/generate-patch-signing-key.ts writes the public key for the repository and the private key outside it; scripts/build-patch-pack.ts packs only committed files and signs with PATCH_SIGNING_KEY. - .github/workflows/patch-pack.yml packs, signs and publishes on a patches-* tag or a manual run. - Launcher main process: find the newest pack release, download, verify, unpack into user data and make it active; resource paths use the active pack when it is usable (a repository checkout only with WTO_USE_PATCH_PACK=1). The pages that show and start this come later.
This commit is contained in:
1 parent
19990fc9de
commit
3e2acc5a17
18 files changed
+1097
-2
No files matched your search
@@ -0,0 +1,48 @@
|
||||
/**
|
||||
* The adaptation pack settings in packages/patcher/tuning/patch-pack.jsonc.
|
||||
*/
|
||||
import { readFileSync } from 'node:fs';
|
||||
import { parseJsonc } from '@wto/jsonc';
|
||||
import { PatchPackError } from './patch-pack-error.ts';
|
||||
|
||||
export interface PatchPackTuning {
|
||||
/** `owner/repo` on GitHub. */
|
||||
readonly repository: string;
|
||||
readonly releasesPerCheck: number;
|
||||
readonly maxPackBytes: number;
|
||||
readonly maxUnpackedBytes: number;
|
||||
readonly requestTimeoutMs: number;
|
||||
}
|
||||
|
||||
const TUNING_FILE = new URL('../../tuning/patch-pack.jsonc', import.meta.url);
|
||||
|
||||
let cached: PatchPackTuning | null = null;
|
||||
|
||||
export function patchPackTuning(): PatchPackTuning {
|
||||
if (cached) return cached;
|
||||
const value = parseJsonc(readFileSync(TUNING_FILE, 'utf8'));
|
||||
if (typeof value !== 'object' || value === null || Array.isArray(value)) throw tuningError('the file is not an object');
|
||||
const fields = value as Record<string, unknown>;
|
||||
const repository = fields['repository'];
|
||||
if (typeof repository !== 'string' || !/^[A-Za-z0-9._-]+\/[A-Za-z0-9._-]+$/.test(repository)) {
|
||||
throw tuningError('"repository" must be "owner/repo"');
|
||||
}
|
||||
cached = {
|
||||
repository,
|
||||
releasesPerCheck: positiveInteger(fields, 'releases_per_check'),
|
||||
maxPackBytes: positiveInteger(fields, 'max_pack_bytes'),
|
||||
maxUnpackedBytes: positiveInteger(fields, 'max_unpacked_bytes'),
|
||||
requestTimeoutMs: positiveInteger(fields, 'request_timeout_ms'),
|
||||
};
|
||||
return cached;
|
||||
}
|
||||
|
||||
function positiveInteger(fields: Record<string, unknown>, key: string): number {
|
||||
const value = fields[key];
|
||||
if (typeof value !== 'number' || !Number.isInteger(value) || value <= 0) throw tuningError(`"${key}" must be a positive integer`);
|
||||
return value;
|
||||
}
|
||||
|
||||
function tuningError(detail: string): PatchPackError {
|
||||
return new PatchPackError('tuning', `tuning/patch-pack.jsonc: ${detail}`);
|
||||
}
|
||||
Reference in new issue
Block a user