feat(launcher): add map adaptation pack updates

This commit is contained in:
N0VAN0M4LY committed 2026-12-06 19:53:45 +08:00
1 parent 9ba92f289d
commit 036a479aab
24 files changed
+770 -86

No files matched your search

+19 -13
View File
@@ -12,6 +12,10 @@ import { mkdir, mkdtemp, readFile, readdir, rename, writeFile } from 'node:fs/pr
import { join, resolve } from 'node:path';
import { parseArgs } from 'node:util';
import { isPackVersion, packSigningPublicKey, signEd25519, verifyEd25519 } from '@wto/patcher';
import { installerDigest } from '../../apps/launcher/src/main/services/app-update/installer-integrity.ts';
import {
MAP_NAV_FORMAT, MapNavManifestSchema, MapNavReleaseManifestSchema, mapNavReleaseFiles, mapNavSignaturePayload,
} from '../../apps/launcher/src/shared/schemas/map-nav-pack.ts';
import { readNavPack } from '../../packages/ground-sim/src/map/wtonav.ts';
const { values } = parseArgs({
@@ -61,31 +65,33 @@ async function main(): Promise<void> {
}
const app = JSON.parse(await readFile(new URL('../../apps/launcher/package.json', import.meta.url), 'utf8')) as { version: string };
const manifest = JSON.stringify({
format: 1,
const manifest = MapNavManifestSchema.parse({
format: MAP_NAV_FORMAT,
version,
minAppVersion: app.version,
gameVersions: [gameVersion],
createdAt: new Date().toISOString(),
maps: entries,
}, null, 2) + '\n';
await writeFile(join(pack, 'manifest.json'), manifest);
const stem = 'wtoffline-map-nav-' + version;
const archive = join(staging, stem + '.zip');
});
await writeFile(join(pack, 'manifest.json'), JSON.stringify(manifest, null, 2) + '\n');
const files = mapNavReleaseFiles(version);
const archive = join(staging, files.zip);
execFileSync('tar', ['-a', '-c', '-f', archive, '-C', staging, 'map-nav'], { stdio: 'inherit', windowsHide: true });
const releaseManifest = MapNavReleaseManifestSchema.parse({ ...manifest, archive: await installerDigest(archive) });
const bytes = Buffer.from(JSON.stringify(releaseManifest, null, 2) + '\n', 'utf8');
if (privateKey) {
const bytes = await readFile(archive);
const signature = signEd25519(bytes, privateKey);
const payload = mapNavSignaturePayload(bytes);
const signature = signEd25519(payload, privateKey);
const publicKey = packSigningPublicKey();
if (!publicKey || !verifyEd25519(bytes, signature, publicKey)) {
throw new Error('The map archive signature did not verify against the project public key.');
if (!publicKey || !verifyEd25519(payload, signature, publicKey)) {
throw new Error('The map release signature did not verify against the project public key.');
}
await writeFile(join(staging, stem + '.zip.sig'), signature);
await writeFile(join(staging, files.signature), signature);
}
await writeFile(join(staging, stem + '.manifest.json'), manifest);
await writeFile(join(staging, files.manifest), bytes);
const release = join(output, version);
await rename(staging, release);
console.log('Packaged ' + entries.length + ' maps in ' + join(release, stem + '.zip'));
console.log('Packaged ' + entries.length + ' maps in ' + join(release, files.zip));
console.log('Unpacked maps: ' + join(release, 'map-nav'));
}