feat: add zip abilities

This commit is contained in:
TrèsAbhi committed 2025-12-10 17:13:12 -06:00
1 parent 51226c8503
commit 1aec1b2885
2 files changed
+15 -10

No files matched your search

+11 -7
View File
@@ -3,24 +3,28 @@ import { AbstractVFS } from "../core/vfs/abstract";
import { SteamVFS } from "../core/vfs/steam";
import { ZipVFS } from "../core/vfs/zip";
const steamPattern = /steam:(\d+)\/(\d+)/;
const zipPattern = /zip:(.+)/;
const source = Bun.argv
.find((arg) => arg.startsWith("--source="))
?.split("=")[1];
let resolved: AbstractVFS;
if (source === "steam") {
const APP = 444200;
const DEPOT = 444202;
if (!source) {
throw new Error("No source specified");
} else if (steamPattern.test(source)) {
const [, app, depot] = source.match(steamPattern)!.map(Number);
resolved = await new SteamVFS(
assertSecret(import.meta.env.STEAM_USERNAME),
assertSecret(import.meta.env.STEAM_PASSWORD),
APP,
DEPOT
app,
depot
).init();
} else if (source === "zip") {
const url = assertSecret(import.meta.env.ZIP_URL);
} else if (zipPattern.test(source)) {
const [, url] = source.match(zipPattern)!;
resolved = await new ZipVFS(url).init();
} else {
throw new Error("No valid source specified");