mirror of
https://github.com/openfrontio/OpenFrontIO.git
synced 2026-06-21 09:20:47 +00:00
26f5d40819
- Replace Webpack with Vite for faster client bundling and HMR. - Migrate tests from Jest to Vitest and update configuration. - Update Web Worker instantiation to standard ESM syntax. - Implement Env utility in `src/core` for safe, hybrid environment variable access (Vite vs Node). - Refactor configuration loaders to remove direct `process.env` dependencies in shared code. - Update TypeScript environment definitions and project scripts for the new toolchain. - Remove the [depracated usage of the husky](https://github.com/typicode/husky/releases/tag/v9.0.1). ## Description: migrate build system to Vite and test runner to Vitest & Remove depracated husky usage ## Please complete the following: - [X] I have added screenshots for all UI updates - [X] I process any text displayed to the user through translateText() and I've added it to the en.json file - [ ] I have added relevant tests to the test directory - [X] I confirm I have thoroughly tested these changes and take full responsibility for any bugs introduced ## Please put your Discord username so you can be contacted if a bug or regression is found: wraith4081 --------- Co-authored-by: evanpelle <evanpelle@gmail.com>
60 lines
1.5 KiB
JavaScript
60 lines
1.5 KiB
JavaScript
import { promises as fs } from "node:fs";
|
|
import path from "node:path";
|
|
import { fileURLToPath } from "node:url";
|
|
|
|
const __filename = fileURLToPath(import.meta.url);
|
|
const __dirname = path.dirname(__filename);
|
|
const root = path.resolve(__dirname, "..");
|
|
|
|
const resourcesDir = path.join(root, "resources");
|
|
const assetsDir = path.join(root, "src", "assets");
|
|
const dataDir = path.join(assetsDir, "data");
|
|
const langDir = path.join(assetsDir, "lang");
|
|
|
|
const dataFiles = ["version.txt", "countries.json", "QuickChat.json"];
|
|
|
|
async function ensureDir(dir) {
|
|
await fs.mkdir(dir, { recursive: true });
|
|
}
|
|
|
|
async function copyFile(src, dest) {
|
|
await ensureDir(path.dirname(dest));
|
|
await fs.copyFile(src, dest);
|
|
}
|
|
|
|
async function copyDataFiles() {
|
|
await Promise.all(
|
|
dataFiles.map((name) =>
|
|
copyFile(path.join(resourcesDir, name), path.join(dataDir, name)),
|
|
),
|
|
);
|
|
}
|
|
|
|
async function copyLangFiles() {
|
|
const sourceDir = path.join(resourcesDir, "lang");
|
|
const entries = await fs.readdir(sourceDir, { withFileTypes: true });
|
|
await Promise.all(
|
|
entries
|
|
.filter((entry) => entry.isFile() && entry.name.endsWith(".json"))
|
|
.map((entry) =>
|
|
copyFile(
|
|
path.join(sourceDir, entry.name),
|
|
path.join(langDir, entry.name),
|
|
),
|
|
),
|
|
);
|
|
}
|
|
|
|
async function main() {
|
|
await ensureDir(dataDir);
|
|
await ensureDir(langDir);
|
|
await copyDataFiles();
|
|
await copyLangFiles();
|
|
console.log("Synced resources to src/assets.");
|
|
}
|
|
|
|
main().catch((error) => {
|
|
console.error("sync-assets failed:", error);
|
|
process.exit(1);
|
|
});
|