mirror of
https://github.com/blitzkit/blitzkit.git
synced 2026-10-21 10:47:04 +02:00
steam downloader
This commit is contained in:
1 parent
a438eb704f
commit
d3202e8607
7 files changed
+95
-42
No files matched your search
@@ -4,7 +4,8 @@
|
||||
"scripts": {
|
||||
"discover-ids": "bun src/discoverIds/index.ts",
|
||||
"build-protos": "bun src/protos.ts",
|
||||
"record-performance": "bun src/recordPerformance/index.ts"
|
||||
"record-performance": "bun src/recordPerformance/index.ts",
|
||||
"download-client": "bun src/downloadClient/index.ts"
|
||||
},
|
||||
"dependencies": {
|
||||
"@blitzkit/closed": "workspace:*",
|
||||
|
||||
@@ -0,0 +1,4 @@
|
||||
// dava engine has a lot of tiny files, this is faster
|
||||
export const DEPOT_DOWNLOADER_MAX_DOWNLOADS = 256;
|
||||
export const DEPOT_DOWNLOADER_OUTPUT = "../../temp/depotdownloader";
|
||||
export const DEPOT_DOWNLOADER_EXECUTABLE = `${DEPOT_DOWNLOADER_OUTPUT}/DepotDownloader`;
|
||||
@@ -0,0 +1,50 @@
|
||||
import { assertSecret } from "@blitzkit/core";
|
||||
import { $ } from "bun";
|
||||
import { rm } from "node:fs/promises";
|
||||
import {
|
||||
DEPOT_DOWNLOADER_EXECUTABLE,
|
||||
DEPOT_DOWNLOADER_MAX_DOWNLOADS,
|
||||
DEPOT_DOWNLOADER_OUTPUT,
|
||||
} from "./constants";
|
||||
import { QuickGitHubRelease } from "./types";
|
||||
|
||||
const provider = assertSecret(import.meta.env.CLIENT_PROVIDER);
|
||||
const source = assertSecret(import.meta.env.CLIENT_SOURCE);
|
||||
const dir = assertSecret(import.meta.env.CLIENT_DIR);
|
||||
|
||||
if (provider === "steam") {
|
||||
const [id, platform] = source.split("/");
|
||||
|
||||
console.log("Downloading Depot Downloader...");
|
||||
|
||||
const releases = await fetch(
|
||||
"https://api.github.com/repos/SteamRE/DepotDownloader/releases/latest",
|
||||
).then((response) => response.json() as Promise<QuickGitHubRelease>);
|
||||
const asset = releases.assets.find((asset) =>
|
||||
asset.name.includes("linux-x64"),
|
||||
);
|
||||
|
||||
if (!asset) {
|
||||
throw new Error("No linux-x64 asset found for Steam DepotDownloader");
|
||||
}
|
||||
|
||||
await rm(dir, { recursive: true, force: true });
|
||||
await rm(DEPOT_DOWNLOADER_OUTPUT, { recursive: true, force: true });
|
||||
|
||||
await $`curl -L "${asset.browser_download_url}" -o "${DEPOT_DOWNLOADER_OUTPUT}.zip"`;
|
||||
await $`unzip "${DEPOT_DOWNLOADER_OUTPUT}.zip" -d "${DEPOT_DOWNLOADER_OUTPUT}"`;
|
||||
await $`chmod +x "${DEPOT_DOWNLOADER_EXECUTABLE}"`;
|
||||
|
||||
console.log("Downloading client...");
|
||||
|
||||
const username = assertSecret(import.meta.env.STEAM_USERNAME);
|
||||
const password = assertSecret(import.meta.env.STEAM_PASSWORD);
|
||||
|
||||
await $`${DEPOT_DOWNLOADER_EXECUTABLE} -os ${
|
||||
platform
|
||||
} -app ${id} -username ${username} -password ${
|
||||
password
|
||||
} -dir ${dir} -max-downloads ${DEPOT_DOWNLOADER_MAX_DOWNLOADS}`;
|
||||
} else {
|
||||
throw new Error(`Unknown provider: ${provider}`);
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
export interface QuickGitHubRelease {
|
||||
assets: Asset[];
|
||||
}
|
||||
|
||||
interface Asset {
|
||||
name: string;
|
||||
browser_download_url: string;
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
import { assertSecret } from "@blitzkit/core";
|
||||
import { LocalVFS } from "@blitzkit/core/src/blitzkit/vfs/local";
|
||||
|
||||
export const vfs = new LocalVFS(assertSecret(import.meta.env.GAME_DIR));
|
||||
export const vfs = new LocalVFS(assertSecret(import.meta.env.CLIENT_DIR));
|
||||
Reference in new issue
Block a user