mirror of
https://github.com/blitzkit/blitzkit.git
synced 2026-10-21 02:37:05 +02:00
fix: dvp
This commit is contained in:
1 parent
0f609717d0
commit
5dce234447
3 files changed
+30
-28
No files matched your search
@@ -94,6 +94,7 @@
|
||||
"packages/scripts": {
|
||||
"name": "@blitzkit/scripts",
|
||||
"dependencies": {
|
||||
"@blitzkit/closed": "workspace:*",
|
||||
"@blitzkit/core": "workspace:*",
|
||||
"@blitzkit/i18n": "workspace:*",
|
||||
"@gltf-transform/core": "^4.2.1",
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
},
|
||||
"dependencies": {
|
||||
"@blitzkit/core": "workspace:*",
|
||||
"@blitzkit/closed": "workspace:*",
|
||||
"@blitzkit/i18n": "workspace:*",
|
||||
"@gltf-transform/core": "^4.2.1",
|
||||
"@gltf-transform/extensions": "^4.2.1",
|
||||
|
||||
@@ -1,20 +1,20 @@
|
||||
import { assertSecret } from '@blitzkit/core';
|
||||
import { mkdir, writeFile } from 'fs/promises';
|
||||
import { parse as parsePath } from 'path';
|
||||
import ProgressBar from 'progress';
|
||||
import { parse as parseYaml, stringify as stringifyYaml } from 'yaml';
|
||||
import { dvp } from '../../../submodules/blitzkit-closed/src/dava/dvp';
|
||||
import { readStringDVPL } from '../src/core/blitz/readStringDVPL';
|
||||
import { DATA } from './buildAssets/constants';
|
||||
import { readYAMLDVPL } from './core/blitz/readYAMLDVPL';
|
||||
import { writeDVPL } from './core/blitz/writeDVPL';
|
||||
import { dvp } from "@blitzkit/closed";
|
||||
import { assertSecret } from "@blitzkit/core";
|
||||
import { mkdir, writeFile } from "fs/promises";
|
||||
import { parse as parsePath } from "path";
|
||||
import ProgressBar from "progress";
|
||||
import { parse as parseYaml, stringify as stringifyYaml } from "yaml";
|
||||
import { readStringDVPL } from "../src/core/blitz/readStringDVPL";
|
||||
import { DATA } from "./buildAssets/constants";
|
||||
import { readYAMLDVPL } from "./core/blitz/readYAMLDVPL";
|
||||
import { writeDVPL } from "./core/blitz/writeDVPL";
|
||||
|
||||
const versionTextFile = await readStringDVPL(`${DATA}/version.txt`);
|
||||
const currentVersion = versionTextFile
|
||||
.split(' ')[0]
|
||||
.split('.')
|
||||
.split(" ")[0]
|
||||
.split(".")
|
||||
.slice(0, 3)
|
||||
.join('.');
|
||||
.join(".");
|
||||
|
||||
console.log(`Installing patches for ${currentVersion}...`);
|
||||
|
||||
@@ -22,8 +22,8 @@ let patchIndex = 1;
|
||||
while (true) {
|
||||
const response = await fetch(
|
||||
`${assertSecret(
|
||||
import.meta.env.WOTB_DLC_CDN,
|
||||
)}/dlc/s${currentVersion}_${patchIndex}.yaml`,
|
||||
import.meta.env.WOTB_DLC_CDN
|
||||
)}/dlc/s${currentVersion}_${patchIndex}.yaml`
|
||||
);
|
||||
|
||||
if (response.status === 200) {
|
||||
@@ -31,18 +31,18 @@ while (true) {
|
||||
|
||||
const data = parseYaml(await response.text());
|
||||
const dvpm = await fetch(
|
||||
`${assertSecret(import.meta.env.WOTB_DLC_CDN)}/dlc/${data.dx11}`,
|
||||
`${assertSecret(import.meta.env.WOTB_DLC_CDN)}/dlc/${data.dx11}`
|
||||
).then((response) => response.arrayBuffer());
|
||||
const dvpd = await fetch(
|
||||
`${assertSecret(import.meta.env.WOTB_DLC_CDN)}/dlc/${data.dx11.replace(
|
||||
'.dvpm',
|
||||
'.dvpd',
|
||||
)}`,
|
||||
".dvpm",
|
||||
".dvpd"
|
||||
)}`
|
||||
).then((response) => response.arrayBuffer());
|
||||
const files = await dvp(dvpm, dvpd);
|
||||
const bar = new ProgressBar(
|
||||
`Patching ${files.length} files :bar`,
|
||||
files.length,
|
||||
files.length
|
||||
);
|
||||
|
||||
for (const { path, data } of files) {
|
||||
@@ -56,35 +56,35 @@ while (true) {
|
||||
console.warn(`Failed to make directory "${dir}"`);
|
||||
}
|
||||
|
||||
const isDvpl = path.endsWith('.dvpl');
|
||||
const isDvpl = path.endsWith(".dvpl");
|
||||
const buffer = Buffer.from(data);
|
||||
|
||||
await writeFile(
|
||||
`${DATA}/${path}${isDvpl ? '' : '.dvpl'}`,
|
||||
new Uint8Array(isDvpl ? buffer : writeDVPL(buffer)),
|
||||
`${DATA}/${path}${isDvpl ? "" : ".dvpl"}`,
|
||||
new Uint8Array(isDvpl ? buffer : writeDVPL(buffer))
|
||||
);
|
||||
|
||||
bar.tick();
|
||||
}
|
||||
|
||||
if ('dynamicContentLocalizationsDir' in data) {
|
||||
console.log('Found dynamic content localizations; patching...');
|
||||
if ("dynamicContentLocalizationsDir" in data) {
|
||||
console.log("Found dynamic content localizations; patching...");
|
||||
|
||||
const localizationsResponse = await fetch(
|
||||
`${assertSecret(import.meta.env.WOTB_DLC_CDN)}/dlc/${
|
||||
data.dynamicContentLocalizationsDir
|
||||
}/en.yaml`,
|
||||
}/en.yaml`
|
||||
);
|
||||
const newStrings = parseYaml(await localizationsResponse.text());
|
||||
const oldStrings = await readYAMLDVPL<Record<string, string>>(
|
||||
`${DATA}/Strings/en.yaml`,
|
||||
`${DATA}/Strings/en.yaml`
|
||||
);
|
||||
const patchedStrings = { ...oldStrings, ...newStrings };
|
||||
const patchedContent = stringifyYaml(patchedStrings);
|
||||
|
||||
await writeFile(
|
||||
`${DATA}/Strings/en.yaml`,
|
||||
new Uint8Array(writeDVPL(Buffer.from(patchedContent))),
|
||||
new Uint8Array(writeDVPL(Buffer.from(patchedContent)))
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user