feat(launcher): add map adaptation pack updates
This commit is contained in:
1 parent
9ba92f289d
commit
036a479aab
24 files changed
+770
-86
No files matched your search
@@ -3,7 +3,9 @@ import { cp, lstat, mkdir, mkdtemp, readdir, readFile, realpath, rm, writeFile }
|
||||
import { tmpdir } from 'node:os';
|
||||
import { dirname, join, relative, resolve, sep } from 'node:path';
|
||||
import { Arch, build, Platform } from 'electron-builder';
|
||||
import { installerDigest } from '../apps/launcher/src/main/services/app-update/installer-integrity.ts';
|
||||
import { launcherReleaseFiles, portableLauncherReleaseFiles } from '../apps/launcher/src/shared/schemas/app-update.ts';
|
||||
import { MapNavManifestSchema } from '../apps/launcher/src/shared/schemas/map-nav-pack.ts';
|
||||
import { formatManifest, MANIFEST_FILE, PATCH_PACK_FORMAT, recordedGameVersions } from '../packages/patcher/src/index.ts';
|
||||
|
||||
const repository = resolve(import.meta.dirname, '..');
|
||||
@@ -72,6 +74,7 @@ async function stageInstaller(stage: string, manifest: LauncherManifest): Promis
|
||||
await cp(join(native, 'wto_ws.dll'), join(resources, 'native', 'wto_ws.dll'));
|
||||
await cp(join(repository, 'mod-dev-docs', 'templates'), join(resources, 'mod-templates'), { recursive: true });
|
||||
await cp(join(repository, 'game-ai', 'ground'), join(resources, 'game-ai', 'ground'), { recursive: true });
|
||||
await stageMapNavBundle(resources);
|
||||
for (const folder of ['exe', 'gui', 'native', 'versions']) {
|
||||
await cp(join(repository, 'patches', folder), join(resources, 'patches', folder), { recursive: true });
|
||||
}
|
||||
@@ -91,6 +94,26 @@ async function stageInstaller(stage: string, manifest: LauncherManifest): Promis
|
||||
}
|
||||
}
|
||||
|
||||
async function stageMapNavBundle(resources: string): Promise<void> {
|
||||
const source = join(buildFolder, 'map-nav');
|
||||
const text = await readFile(join(source, 'manifest.json'), 'utf8').catch((error: NodeJS.ErrnoException) => {
|
||||
if (error.code === 'ENOENT') return null;
|
||||
throw error;
|
||||
});
|
||||
if (!text) return;
|
||||
const manifest = MapNavManifestSchema.parse(JSON.parse(text));
|
||||
const destination = join(resources, 'map-nav');
|
||||
await mkdir(join(destination, 'maps'), { recursive: true });
|
||||
for (const { level, size, sha256 } of manifest.maps) {
|
||||
const filename = level + '.wtonav';
|
||||
const target = join(destination, 'maps', filename);
|
||||
await cp(join(source, 'maps', filename), target, { dereference: true });
|
||||
const digest = await installerDigest(target, size);
|
||||
if (digest.size !== size || digest.sha256 !== sha256) throw new Error('The bundled map file does not match its manifest: ' + filename);
|
||||
}
|
||||
await writeFile(join(destination, 'manifest.json'), text, 'utf8');
|
||||
}
|
||||
|
||||
async function cleanInstallerOutput(version: string): Promise<void> {
|
||||
await mkdir(buildFolder, { recursive: true });
|
||||
if (relative(buildFolder, await realpath(buildFolder)) !== '') throw new Error('The build directory is redirected.');
|
||||
|
||||
Reference in new issue
Block a user