From a4ee9cf2bd1b8cd9b838fc339a35f1c936b93f25 Mon Sep 17 00:00:00 2001 From: tresabhi <43380238+tresabhi@users.noreply.github.com> Date: Sun, 25 Oct 2026 12:50:48 -0500 Subject: [PATCH] automatic url --- .../scripts/src/downloadSmartDLC/index.ts | 29 +++++++++---------- packages/scripts/src/types/regionsPublish.ts | 7 +++++ packages/scripts/src/vfs/index.ts | 3 ++ 3 files changed, 23 insertions(+), 16 deletions(-) create mode 100644 packages/scripts/src/types/regionsPublish.ts diff --git a/packages/scripts/src/downloadSmartDLC/index.ts b/packages/scripts/src/downloadSmartDLC/index.ts index 494f2b2a7..24b13f068 100644 --- a/packages/scripts/src/downloadSmartDLC/index.ts +++ b/packages/scripts/src/downloadSmartDLC/index.ts @@ -3,10 +3,16 @@ import { assertSecret } from "@blitzkit/core"; import { mkdir, writeFile } from "fs/promises"; import { parse as parsePath } from "path"; import { parse as parseYaml, stringify as stringifyYaml } from "yaml"; +import { RegionsPublish } from "../types/regionsPublish"; import { vfs } from "../vfs/vfs"; const CLIENT_DIR = assertSecret(import.meta.env.CLIENT_DIR); +const regionsPublish = await vfs.yaml( + "Data/regions_publish.yaml", +); +const [smartDlcUrl] = regionsPublish.Common.smartDlcUrls; + const versionTextFile = await vfs.text(`Data/version.txt`); const currentVersion = versionTextFile .split(" ")[0] @@ -19,9 +25,7 @@ console.log(`Installing patches for ${currentVersion}...`); let patchIndex = 1; while (true) { const response = await fetch( - `${assertSecret( - import.meta.env.WOTB_DLC_CDN, - )}/dlc/s${currentVersion}_${patchIndex}.yaml`, + `${smartDlcUrl}/s${currentVersion}_${patchIndex}.yaml`, ); console.log(patchIndex, response.status); @@ -31,14 +35,11 @@ while (true) { console.log(`Applying patch ${patchIndex}...`); const data = parseYaml(await response.text()); - const dvpm = await fetch( - `${assertSecret(import.meta.env.WOTB_DLC_CDN)}/dlc/${data.dx11}`, - ).then((response) => response.arrayBuffer()); + const dvpm = await fetch(`${smartDlcUrl}/${data.dx11}`).then((response) => + response.arrayBuffer(), + ); const dvpd = await fetch( - `${assertSecret(import.meta.env.WOTB_DLC_CDN)}/dlc/${data.dx11.replace( - ".dvpm", - ".dvpd", - )}`, + `${smartDlcUrl}/${data.dx11.replace(".dvpm", ".dvpd")}`, ).then((response) => response.arrayBuffer()); const files = await dvp(dvpm, dvpd); @@ -58,14 +59,10 @@ while (true) { if ("dynamicContentLocalizationsDir" in data) { console.log( - `${assertSecret(import.meta.env.WOTB_DLC_CDN)}/dlc/${ - data.dynamicContentLocalizationsDir - }/en.yaml`, + `${smartDlcUrl}/${data.dynamicContentLocalizationsDir}/en.yaml`, ); const localizationsResponse = await fetch( - `${assertSecret(import.meta.env.WOTB_DLC_CDN)}/dlc/${ - data.dynamicContentLocalizationsDir - }/en.yaml`, + `${smartDlcUrl}/${data.dynamicContentLocalizationsDir}/en.yaml`, ); console.log("fetched"); const newStrings = parseYaml(await localizationsResponse.text()); diff --git a/packages/scripts/src/types/regionsPublish.ts b/packages/scripts/src/types/regionsPublish.ts new file mode 100644 index 000000000..728de0f14 --- /dev/null +++ b/packages/scripts/src/types/regionsPublish.ts @@ -0,0 +1,7 @@ +export interface RegionsPublish { + Common: Common; +} + +interface Common { + smartDlcUrls: string[]; +} diff --git a/packages/scripts/src/vfs/index.ts b/packages/scripts/src/vfs/index.ts index 5875cff59..cdf8b1fe8 100644 --- a/packages/scripts/src/vfs/index.ts +++ b/packages/scripts/src/vfs/index.ts @@ -17,4 +17,7 @@ if (command === "cat") { for (const file of files) { console.log(file); } +} else if (command === "yaml") { + const content = await vfs.yaml(path); + await Bun.write(Bun.stdout, JSON.stringify(content, null, 2)); }