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

+4 -3
View File
@@ -16,10 +16,11 @@ on:
- blitzkit/assets-dev - blitzkit/assets-dev
default: blitzkit/assets default: blitzkit/assets
archive_url: asset_source:
type: string type: string
required: false required: false
description: Archive URL to download instead of Steam client description: "Archive URL or Steam to download (example: steam:APP_ID/DEPOT_ID or zip:URL_TO_ZIP)"
default: "steam:444200/444202"
schedule: schedule:
- cron: "0 2 * * *" - cron: "0 2 * * *"
@@ -78,4 +79,4 @@ jobs:
run: echo 0 | sudo tee /proc/sys/kernel/apparmor_restrict_unprivileged_userns run: echo 0 | sudo tee /proc/sys/kernel/apparmor_restrict_unprivileged_userns
- name: Build assets - name: Build assets
run: bun run build:assets --all-targets --manual run: bun run build:assets --all-targets --source=${{ github.event.inputs.asset_source }}
+11 -7
View File
@@ -3,24 +3,28 @@ import { AbstractVFS } from "../core/vfs/abstract";
import { SteamVFS } from "../core/vfs/steam"; import { SteamVFS } from "../core/vfs/steam";
import { ZipVFS } from "../core/vfs/zip"; import { ZipVFS } from "../core/vfs/zip";
const steamPattern = /steam:(\d+)\/(\d+)/;
const zipPattern = /zip:(.+)/;
const source = Bun.argv const source = Bun.argv
.find((arg) => arg.startsWith("--source=")) .find((arg) => arg.startsWith("--source="))
?.split("=")[1]; ?.split("=")[1];
let resolved: AbstractVFS; let resolved: AbstractVFS;
if (source === "steam") { if (!source) {
const APP = 444200; throw new Error("No source specified");
const DEPOT = 444202; } else if (steamPattern.test(source)) {
const [, app, depot] = source.match(steamPattern)!.map(Number);
resolved = await new SteamVFS( resolved = await new SteamVFS(
assertSecret(import.meta.env.STEAM_USERNAME), assertSecret(import.meta.env.STEAM_USERNAME),
assertSecret(import.meta.env.STEAM_PASSWORD), assertSecret(import.meta.env.STEAM_PASSWORD),
APP, app,
DEPOT depot
).init(); ).init();
} else if (source === "zip") { } else if (zipPattern.test(source)) {
const url = assertSecret(import.meta.env.ZIP_URL); const [, url] = source.match(zipPattern)!;
resolved = await new ZipVFS(url).init(); resolved = await new ZipVFS(url).init();
} else { } else {
throw new Error("No valid source specified"); throw new Error("No valid source specified");