mirror of
https://github.com/blitzkit/blitzkit.git
synced 2026-10-27 12:39:49 +01:00
automatic url
This commit is contained in:
1 parent
b3ad122542
commit
a4ee9cf2bd
3 files changed
+23
-16
No files matched your search
@@ -3,10 +3,16 @@ import { assertSecret } from "@blitzkit/core";
|
|||||||
import { mkdir, writeFile } from "fs/promises";
|
import { mkdir, writeFile } from "fs/promises";
|
||||||
import { parse as parsePath } from "path";
|
import { parse as parsePath } from "path";
|
||||||
import { parse as parseYaml, stringify as stringifyYaml } from "yaml";
|
import { parse as parseYaml, stringify as stringifyYaml } from "yaml";
|
||||||
|
import { RegionsPublish } from "../types/regionsPublish";
|
||||||
import { vfs } from "../vfs/vfs";
|
import { vfs } from "../vfs/vfs";
|
||||||
|
|
||||||
const CLIENT_DIR = assertSecret(import.meta.env.CLIENT_DIR);
|
const CLIENT_DIR = assertSecret(import.meta.env.CLIENT_DIR);
|
||||||
|
|
||||||
|
const regionsPublish = await vfs.yaml<RegionsPublish>(
|
||||||
|
"Data/regions_publish.yaml",
|
||||||
|
);
|
||||||
|
const [smartDlcUrl] = regionsPublish.Common.smartDlcUrls;
|
||||||
|
|
||||||
const versionTextFile = await vfs.text(`Data/version.txt`);
|
const versionTextFile = await vfs.text(`Data/version.txt`);
|
||||||
const currentVersion = versionTextFile
|
const currentVersion = versionTextFile
|
||||||
.split(" ")[0]
|
.split(" ")[0]
|
||||||
@@ -19,9 +25,7 @@ console.log(`Installing patches for ${currentVersion}...`);
|
|||||||
let patchIndex = 1;
|
let patchIndex = 1;
|
||||||
while (true) {
|
while (true) {
|
||||||
const response = await fetch(
|
const response = await fetch(
|
||||||
`${assertSecret(
|
`${smartDlcUrl}/s${currentVersion}_${patchIndex}.yaml`,
|
||||||
import.meta.env.WOTB_DLC_CDN,
|
|
||||||
)}/dlc/s${currentVersion}_${patchIndex}.yaml`,
|
|
||||||
);
|
);
|
||||||
|
|
||||||
console.log(patchIndex, response.status);
|
console.log(patchIndex, response.status);
|
||||||
@@ -31,14 +35,11 @@ while (true) {
|
|||||||
console.log(`Applying patch ${patchIndex}...`);
|
console.log(`Applying patch ${patchIndex}...`);
|
||||||
|
|
||||||
const data = parseYaml(await response.text());
|
const data = parseYaml(await response.text());
|
||||||
const dvpm = await fetch(
|
const dvpm = await fetch(`${smartDlcUrl}/${data.dx11}`).then((response) =>
|
||||||
`${assertSecret(import.meta.env.WOTB_DLC_CDN)}/dlc/${data.dx11}`,
|
response.arrayBuffer(),
|
||||||
).then((response) => response.arrayBuffer());
|
);
|
||||||
const dvpd = await fetch(
|
const dvpd = await fetch(
|
||||||
`${assertSecret(import.meta.env.WOTB_DLC_CDN)}/dlc/${data.dx11.replace(
|
`${smartDlcUrl}/${data.dx11.replace(".dvpm", ".dvpd")}`,
|
||||||
".dvpm",
|
|
||||||
".dvpd",
|
|
||||||
)}`,
|
|
||||||
).then((response) => response.arrayBuffer());
|
).then((response) => response.arrayBuffer());
|
||||||
const files = await dvp(dvpm, dvpd);
|
const files = await dvp(dvpm, dvpd);
|
||||||
|
|
||||||
@@ -58,14 +59,10 @@ while (true) {
|
|||||||
|
|
||||||
if ("dynamicContentLocalizationsDir" in data) {
|
if ("dynamicContentLocalizationsDir" in data) {
|
||||||
console.log(
|
console.log(
|
||||||
`${assertSecret(import.meta.env.WOTB_DLC_CDN)}/dlc/${
|
`${smartDlcUrl}/${data.dynamicContentLocalizationsDir}/en.yaml`,
|
||||||
data.dynamicContentLocalizationsDir
|
|
||||||
}/en.yaml`,
|
|
||||||
);
|
);
|
||||||
const localizationsResponse = await fetch(
|
const localizationsResponse = await fetch(
|
||||||
`${assertSecret(import.meta.env.WOTB_DLC_CDN)}/dlc/${
|
`${smartDlcUrl}/${data.dynamicContentLocalizationsDir}/en.yaml`,
|
||||||
data.dynamicContentLocalizationsDir
|
|
||||||
}/en.yaml`,
|
|
||||||
);
|
);
|
||||||
console.log("fetched");
|
console.log("fetched");
|
||||||
const newStrings = parseYaml(await localizationsResponse.text());
|
const newStrings = parseYaml(await localizationsResponse.text());
|
||||||
|
|||||||
@@ -0,0 +1,7 @@
|
|||||||
|
export interface RegionsPublish {
|
||||||
|
Common: Common;
|
||||||
|
}
|
||||||
|
|
||||||
|
interface Common {
|
||||||
|
smartDlcUrls: string[];
|
||||||
|
}
|
||||||
@@ -17,4 +17,7 @@ if (command === "cat") {
|
|||||||
for (const file of files) {
|
for (const file of files) {
|
||||||
console.log(file);
|
console.log(file);
|
||||||
}
|
}
|
||||||
|
} else if (command === "yaml") {
|
||||||
|
const content = await vfs.yaml(path);
|
||||||
|
await Bun.write(Bun.stdout, JSON.stringify(content, null, 2));
|
||||||
}
|
}
|
||||||
Reference in new issue
Block a user