Files
blitzkit/packages/scripts/src/buildAssets/constants.ts
T

33 lines
924 B
TypeScript
Raw Normal View History

2025-11-26 19:27:58 -06:00
import { assertSecret } from "@blitzkit/core";
2025-11-29 15:16:09 -06:00
import { AbstractVFS } from "../core/vfs/abstract";
import { SteamVFS } from "../core/vfs/steam";
import { ZipVFS } from "../core/vfs/zip";
2024-02-20 11:21:01 -06:00
2025-12-10 17:13:12 -06:00
const steamPattern = /steam:(\d+)\/(\d+)/;
const zipPattern = /zip:(.+)/;
2025-11-29 15:16:09 -06:00
const source = Bun.argv
.find((arg) => arg.startsWith("--source="))
?.split("=")[1];
2025-01-14 19:22:41 -06:00
2025-11-29 15:16:09 -06:00
let resolved: AbstractVFS;
2025-12-10 17:13:12 -06:00
if (!source) {
throw new Error("No source specified");
} else if (steamPattern.test(source)) {
const [, app, depot] = source.match(steamPattern)!.map(Number);
2025-11-29 15:16:09 -06:00
resolved = await new SteamVFS(
assertSecret(import.meta.env.STEAM_USERNAME),
assertSecret(import.meta.env.STEAM_PASSWORD),
2025-12-10 17:13:12 -06:00
app,
depot
2025-11-29 15:16:09 -06:00
).init();
2025-12-10 17:13:12 -06:00
} else if (zipPattern.test(source)) {
const [, url] = source.match(zipPattern)!;
2025-11-29 15:16:09 -06:00
resolved = await new ZipVFS(url).init();
} else {
throw new Error("No valid source specified");
}
export const vfs = resolved;