fix(scripts): fetch-assets ESM + native Windows tar
Some checks failed
CI / Lint (push) Failing after 15s
CI / Build (push) Failing after 12s
CI / Secret scan (push) Successful in 2m26s
CI / PR size check (push) Has been skipped

This commit is contained in:
МИН 2026-05-28 15:13:56 +03:00
parent cc3eb8d0be
commit 7709bd9f74

View File

@ -4,11 +4,16 @@
// //
// Архив весит ~43МБ, содержит модели (.glb), текстуры (.png) и скины. // Архив весит ~43МБ, содержит модели (.glb), текстуры (.png) и скины.
// В Git они НЕ лежат — занимают много места и редко меняются. // В Git они НЕ лежат — занимают много места и редко меняются.
//
// ES-модуль (в package.json "type": "module").
const fs = require('fs'); import fs from 'node:fs';
const path = require('path'); import path from 'node:path';
const https = require('https'); import https from 'node:https';
const { execSync } = require('child_process'); import { execSync } from 'node:child_process';
import { fileURLToPath } from 'node:url';
const __dirname = path.dirname(fileURLToPath(import.meta.url));
const RELEASE_URL = const RELEASE_URL =
'https://git.rublox.pro/rublox/player/releases/download/assets-v1/kubikon-assets.tar.gz'; 'https://git.rublox.pro/rublox/player/releases/download/assets-v1/kubikon-assets.tar.gz';
@ -68,7 +73,14 @@ async function main() {
await download(RELEASE_URL, TMP_TAR); await download(RELEASE_URL, TMP_TAR);
console.log('Распаковка...'); console.log('Распаковка...');
execSync(`tar -xzf "${TMP_TAR}" -C "${PUBLIC_DIR}"`, { stdio: 'inherit' }); // На Windows используем native tar.exe из System32 — Git Bash-овский
// BSD-tar ломается на путях с двоеточием (`C:` интерпретируется как
// ssh-хост). На *nix просто `tar` в $PATH.
const tarBin =
process.platform === 'win32' && fs.existsSync('C:\\Windows\\System32\\tar.exe')
? 'C:\\Windows\\System32\\tar.exe'
: 'tar';
execSync(`"${tarBin}" -xzf "${TMP_TAR}" -C "${PUBLIC_DIR}"`, { stdio: 'inherit' });
fs.unlinkSync(TMP_TAR); fs.unlinkSync(TMP_TAR);
console.log('Готово! Ассеты в public/kubikon-assets/'); console.log('Готово! Ассеты в public/kubikon-assets/');