Files
blitzkit/packages/scripts/src/setupDepotDownloader.ts
T

39 lines
1.1 KiB
TypeScript
Raw Normal View History

2025-11-26 13:18:44 -06:00
import decompress from "decompress";
import { existsSync } from "fs";
import { mkdir, readdir, writeFile } from "fs/promises";
2024-01-22 13:40:37 -06:00
2025-11-26 13:18:44 -06:00
if (!existsSync("../../temp")) {
console.log("Creating temp directory...");
await mkdir("../../temp");
2024-01-22 13:40:37 -06:00
}
2025-11-26 13:18:44 -06:00
console.log("Downloading depot downloader...");
2024-01-22 13:40:37 -06:00
await fetch(
2025-11-26 13:18:44 -06:00
"https://api.github.com/repos/SteamRE/DepotDownloader/releases/latest"
2024-01-22 13:40:37 -06:00
)
.then(
(response) =>
response.json() as Promise<{
2024-02-19 20:42:30 -06:00
assets: { browser_download_url: string; name: string }[];
2025-11-26 13:18:44 -06:00
}>
2024-01-22 13:40:37 -06:00
)
2024-02-19 20:42:30 -06:00
.then(({ assets }) => {
2025-11-26 13:18:44 -06:00
const asset = assets.find(({ name }) => name.includes("linux-x64"));
if (!asset) throw new Error("No asset found");
2024-02-19 20:42:30 -06:00
return fetch(asset.browser_download_url);
})
2024-01-22 13:40:37 -06:00
.then((response) => response.arrayBuffer())
.then((arrayBuffer) =>
2025-11-26 13:18:44 -06:00
writeFile("../../temp/depotDownloader.zip", new Uint8Array(arrayBuffer))
2024-01-22 13:40:37 -06:00
);
2025-11-26 13:18:44 -06:00
console.log("Unzipping...");
2024-10-21 11:11:25 -05:00
await decompress(
2025-11-26 13:18:44 -06:00
"../../temp/depotDownloader.zip",
"../../temp/depotDownloader"
2024-10-21 11:11:25 -05:00
);
2024-02-19 20:32:12 -06:00
2024-10-21 11:11:25 -05:00
console.log(
2025-11-26 13:18:44 -06:00
"Download complete; files:",
await readdir("../../temp/depotDownloader")
2024-10-21 11:11:25 -05:00
);