mirror of
https://github.com/blitzkit/blitzkit.git
synced 2026-10-29 05:29:52 +01:00
feat: transfer assets
This commit is contained in:
1 parent
c0b437f207
commit
0f38cd8f34
4 files changed
+66
-44
No files matched your search
@@ -13,55 +13,23 @@ concurrency:
|
|||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
build:
|
build:
|
||||||
runs-on: windows-latest
|
runs-on: ubuntu-latest
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout repository
|
- uses: actions/checkout@v4
|
||||||
uses: actions/checkout@v4
|
- uses: oven-sh/setup-bun@v1
|
||||||
with:
|
|
||||||
submodules: recursive
|
|
||||||
token: ${{ secrets.GH_TOKEN }}
|
|
||||||
|
|
||||||
- name: Use node
|
|
||||||
uses: actions/setup-node@v4
|
|
||||||
with:
|
|
||||||
node-version: 18
|
|
||||||
cache: 'npm'
|
|
||||||
|
|
||||||
- name: Install Yarn
|
|
||||||
run: npm install --location=global yarn
|
|
||||||
|
|
||||||
- name: Use node_modules cache
|
|
||||||
uses: actions/cache@v3
|
|
||||||
with:
|
|
||||||
path: '**/node_modules'
|
|
||||||
key: ${{ runner.os }}-modules-${{ hashFiles('**/yarn.lock') }}
|
|
||||||
|
|
||||||
- name: Install dependencies
|
- name: Install dependencies
|
||||||
run: yarn
|
run: bun install
|
||||||
|
|
||||||
- name: Add fixed sharp
|
|
||||||
run: yarn add [email protected] --ignore-engines
|
|
||||||
|
|
||||||
- name: Setup DepotDownloader
|
- name: Setup DepotDownloader
|
||||||
run: yarn setup:depotdownloader
|
run: bun scripts/setupDepotDownloader.ts
|
||||||
|
|
||||||
- name: Run DepotDownloader
|
- name: Run DepotDownloader
|
||||||
run: ./temp/depotDownloader/DepotDownloader.exe -app 444200 -username ${{ secrets.DEPOT_DOWNLOADER_USERNAME }} -password "${{ secrets.DEPOT_DOWNLOADER_PASSWORD }}"
|
run: ./temp/depotDownloader/DepotDownloader.exe -os windows -app 444200 -username ${{ secrets.DEPOT_DOWNLOADER_USERNAME }} -password "${{ secrets.DEPOT_DOWNLOADER_PASSWORD }}"
|
||||||
|
|
||||||
- name: Apply patches
|
- name: Apply patches
|
||||||
run: |
|
run: GH_TOKEN=${{ secrets.GH_TOKEN }} DISCORD_TOKEN=${{ secrets.DISCORD_TOKEN }} DATABASE_URL=${{ secrets.DATABASE_URL }} WOTB_DLC_CDN=${{ secrets.WOTB_DLC_CDN }} bun scripts/applyPatches.ts --depot
|
||||||
$env:GH_TOKEN = "${{ secrets.GH_TOKEN }}"
|
|
||||||
$env:DISCORD_TOKEN = "${{ secrets.DISCORD_TOKEN }}"
|
|
||||||
$env:DATABASE_URL = "${{ secrets.DATABASE_URL }}"
|
|
||||||
$env:WOTB_DLC_CDN = "${{ secrets.WOTB_DLC_CDN }}"
|
|
||||||
yarn setup:patches --depot
|
|
||||||
|
|
||||||
- name: Build assets
|
- name: Build assets
|
||||||
run: |
|
run: GH_TOKEN=${{ secrets.GH_TOKEN }} DISCORD_TOKEN=${{ secrets.DISCORD_TOKEN }} DATABASE_URL=${{ secrets.DATABASE_URL }} VIDEOS_SHEET=${{ secrets.VIDEOS_SHEET }} GOOGLE_APPLICATION_CREDENTIALS=${{ secrets.GOOGLE_APPLICATION_CREDENTIALS }} bun scripts/buildAssets/index.ts --all-targets --depot --production
|
||||||
$env:GH_TOKEN = "${{ secrets.GH_TOKEN }}"
|
|
||||||
$env:DISCORD_TOKEN = "${{ secrets.DISCORD_TOKEN }}"
|
|
||||||
$env:DATABASE_URL = "${{ secrets.DATABASE_URL }}"
|
|
||||||
$env:VIDEOS_SHEET = "${{ secrets.VIDEOS_SHEET }}"
|
|
||||||
$env:GOOGLE_APPLICATION_CREDENTIALS = "${{ secrets.GOOGLE_APPLICATION_CREDENTIALS }}"
|
|
||||||
yarn build:assets --all-targets --depot ${{ github.ref == 'refs/heads/main' && '--production' || '' }}
|
|
||||||
@@ -12,7 +12,6 @@
|
|||||||
"build:sitemap": "vite-node --script scripts/sitemap",
|
"build:sitemap": "vite-node --script scripts/sitemap",
|
||||||
"build:docs": "vitepress build docs",
|
"build:docs": "vitepress build docs",
|
||||||
"build:ratingleaderboard": "vite-node --script scripts/buildRatingLeaderboard",
|
"build:ratingleaderboard": "vite-node --script scripts/buildRatingLeaderboard",
|
||||||
"build:assets": "vite-node --max_old_space_size=16384 --script scripts/buildAssets/index",
|
|
||||||
"test": "vite-node --script scripts/test",
|
"test": "vite-node --script scripts/test",
|
||||||
"test2": "vite-node --script scripts/test2",
|
"test2": "vite-node --script scripts/test2",
|
||||||
"dev:bot": "vite-node --script scripts/build && yarn start:bot",
|
"dev:bot": "vite-node --script scripts/build && yarn start:bot",
|
||||||
@@ -22,14 +21,12 @@
|
|||||||
"start:website": "next start",
|
"start:website": "next start",
|
||||||
"host:docs": "vitepress preview docs",
|
"host:docs": "vitepress preview docs",
|
||||||
"publish:ratingleaderboard": "vite-node --script scripts/buildRatingLeaderboard --publish",
|
"publish:ratingleaderboard": "vite-node --script scripts/buildRatingLeaderboard --publish",
|
||||||
"setup:patches": "vite-node --script scripts/applyPatches",
|
|
||||||
"lint": "npx tsc",
|
"lint": "npx tsc",
|
||||||
"lint:website": "next lint",
|
"lint:website": "next lint",
|
||||||
"format": "prettier --write \"**/*.@(json|js|jsx|css|md|ts|tsx|html|xml|yml|gltf)\"",
|
"format": "prettier --write \"**/*.@(json|js|jsx|css|md|ts|tsx|html|xml|yml|gltf)\"",
|
||||||
"lint:version": "vite-node --script scripts/checkVersionMissMatch",
|
"lint:version": "vite-node --script scripts/checkVersionMissMatch",
|
||||||
"knip": "knip",
|
"knip": "knip",
|
||||||
"update": "yarn upgrade --latest",
|
"update": "yarn upgrade --latest",
|
||||||
"setup:depotdownloader": "vite-node --script scripts/setupDepotDownloader",
|
|
||||||
"tunnel": "cloudflared tunnel --url http://localhost:3000",
|
"tunnel": "cloudflared tunnel --url http://localhost:3000",
|
||||||
"discoverids": "scripts/discoverIds.ts"
|
"discoverids": "scripts/discoverIds.ts"
|
||||||
},
|
},
|
||||||
@@ -106,7 +103,6 @@
|
|||||||
"crc": "^4.3.2",
|
"crc": "^4.3.2",
|
||||||
"fast-xml-parser": "^4.3.2",
|
"fast-xml-parser": "^4.3.2",
|
||||||
"knip": "^3.4.0",
|
"knip": "^3.4.0",
|
||||||
"lz4": "^0.6.5",
|
|
||||||
"prettier": "^3.0.3",
|
"prettier": "^3.0.3",
|
||||||
"prisma": "^5.4.1",
|
"prisma": "^5.4.1",
|
||||||
"typescript": "^5.4.5"
|
"typescript": "^5.4.5"
|
||||||
|
|||||||
@@ -0,0 +1,58 @@
|
|||||||
|
import { crc32 } from 'crc';
|
||||||
|
import { compressBlock } from 'lz4js';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Thanks Maddoxkkm! Modernized heavily.
|
||||||
|
*
|
||||||
|
* https://github.com/Maddoxkkm/dvpl_converter/
|
||||||
|
*/
|
||||||
|
export function writeDVPL(buffer: Buffer) {
|
||||||
|
const source = new Uint8Array(buffer);
|
||||||
|
const destination = new Uint8Array(buffer.length);
|
||||||
|
const compressedBlockSize = compressBlock(
|
||||||
|
source,
|
||||||
|
destination,
|
||||||
|
0,
|
||||||
|
source.length,
|
||||||
|
0,
|
||||||
|
);
|
||||||
|
let output = Buffer.from(destination);
|
||||||
|
|
||||||
|
if (compressedBlockSize === 0 || compressedBlockSize >= buffer.length) {
|
||||||
|
const footerBuffer = toDVPLFooter(
|
||||||
|
buffer.length,
|
||||||
|
buffer.length,
|
||||||
|
crc32(buffer),
|
||||||
|
0,
|
||||||
|
);
|
||||||
|
|
||||||
|
return Buffer.concat([buffer, footerBuffer], buffer.length + 20);
|
||||||
|
} else {
|
||||||
|
output = output.subarray(0, compressedBlockSize);
|
||||||
|
const footerBuffer = toDVPLFooter(
|
||||||
|
buffer.length,
|
||||||
|
compressedBlockSize,
|
||||||
|
crc32(output),
|
||||||
|
2,
|
||||||
|
);
|
||||||
|
|
||||||
|
return Buffer.concat([output, footerBuffer], compressedBlockSize + 20);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function toDVPLFooter(
|
||||||
|
inputSize: number,
|
||||||
|
compressedSize: number,
|
||||||
|
crc32: number,
|
||||||
|
type: number,
|
||||||
|
) {
|
||||||
|
const result = Buffer.alloc(20);
|
||||||
|
|
||||||
|
result.writeUInt32LE(inputSize, 0);
|
||||||
|
result.writeUInt32LE(compressedSize, 4);
|
||||||
|
result.writeUInt32LE(crc32, 8);
|
||||||
|
result.writeUInt32LE(type, 12);
|
||||||
|
result.write('DVPL', 16, 4, 'utf8');
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
Reference in new issue
Block a user