mirror of
https://github.com/openfrontio/OpenFrontIO.git
synced 2026-06-21 07:40:43 +00:00
vite: fix docker build (#2738)
## Description: The sync-assets wasn't executing on docker-build. so instead just import it from resources/ directory, vite logs a warning but I think that's okay for now. ## 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 - [x] 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: evan
This commit is contained in:
@@ -17,7 +17,6 @@ COPY tailwind.config.js ./
|
||||
COPY postcss.config.js ./
|
||||
COPY eslint.config.js ./
|
||||
COPY index.html ./
|
||||
COPY scripts ./scripts
|
||||
COPY resources ./resources
|
||||
COPY proprietary ./proprietary
|
||||
COPY src ./src
|
||||
|
||||
+1
-8
@@ -20,14 +20,7 @@
|
||||
"lint:fix": "eslint --fix",
|
||||
"prepare": "husky",
|
||||
"gen-maps": "cd map-generator && go run . && npm run format",
|
||||
"inst": "npm ci --ignore-scripts",
|
||||
"sync-assets": "node scripts/sync-assets.mjs",
|
||||
"predev": "npm run sync-assets",
|
||||
"prebuild-dev": "npm run sync-assets",
|
||||
"prebuild-prod": "npm run sync-assets",
|
||||
"prestart:client": "npm run sync-assets",
|
||||
"pretest": "npm run sync-assets",
|
||||
"pretest:coverage": "npm run sync-assets"
|
||||
"inst": "npm ci --ignore-scripts"
|
||||
},
|
||||
"lint-staged": {
|
||||
"**/*": [
|
||||
|
||||
@@ -1,59 +0,0 @@
|
||||
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);
|
||||
});
|
||||
@@ -1,6 +1,6 @@
|
||||
import { LitElement, html } from "lit";
|
||||
import { customElement, query, state } from "lit/decorators.js";
|
||||
import Countries from "../assets/data/countries.json" with { type: "json" };
|
||||
import Countries from "resources/countries.json" with { type: "json" };
|
||||
import { translateText } from "./Utils";
|
||||
|
||||
@customElement("flag-input-modal")
|
||||
|
||||
+34
-34
@@ -2,40 +2,40 @@ import { LitElement, html } from "lit";
|
||||
import { customElement, state } from "lit/decorators.js";
|
||||
import "./LanguageModal";
|
||||
|
||||
import ar from "../assets/lang/ar.json";
|
||||
import bg from "../assets/lang/bg.json";
|
||||
import bn from "../assets/lang/bn.json";
|
||||
import cs from "../assets/lang/cs.json";
|
||||
import da from "../assets/lang/da.json";
|
||||
import de from "../assets/lang/de.json";
|
||||
import el from "../assets/lang/el.json";
|
||||
import en from "../assets/lang/en.json";
|
||||
import eo from "../assets/lang/eo.json";
|
||||
import es from "../assets/lang/es.json";
|
||||
import fa from "../assets/lang/fa.json";
|
||||
import fi from "../assets/lang/fi.json";
|
||||
import fr from "../assets/lang/fr.json";
|
||||
import gl from "../assets/lang/gl.json";
|
||||
import he from "../assets/lang/he.json";
|
||||
import hi from "../assets/lang/hi.json";
|
||||
import hu from "../assets/lang/hu.json";
|
||||
import it from "../assets/lang/it.json";
|
||||
import ja from "../assets/lang/ja.json";
|
||||
import ko from "../assets/lang/ko.json";
|
||||
import mk from "../assets/lang/mk.json";
|
||||
import nl from "../assets/lang/nl.json";
|
||||
import pl from "../assets/lang/pl.json";
|
||||
import pt_BR from "../assets/lang/pt-BR.json";
|
||||
import pt_PT from "../assets/lang/pt-PT.json";
|
||||
import ru from "../assets/lang/ru.json";
|
||||
import sh from "../assets/lang/sh.json";
|
||||
import sk from "../assets/lang/sk.json";
|
||||
import sl from "../assets/lang/sl.json";
|
||||
import sv_SE from "../assets/lang/sv-SE.json";
|
||||
import tp from "../assets/lang/tp.json";
|
||||
import tr from "../assets/lang/tr.json";
|
||||
import uk from "../assets/lang/uk.json";
|
||||
import zh_CN from "../assets/lang/zh-CN.json";
|
||||
import ar from "../../resources/lang/ar.json";
|
||||
import bg from "../../resources/lang/bg.json";
|
||||
import bn from "../../resources/lang/bn.json";
|
||||
import cs from "../../resources/lang/cs.json";
|
||||
import da from "../../resources/lang/da.json";
|
||||
import de from "../../resources/lang/de.json";
|
||||
import el from "../../resources/lang/el.json";
|
||||
import en from "../../resources/lang/en.json";
|
||||
import eo from "../../resources/lang/eo.json";
|
||||
import es from "../../resources/lang/es.json";
|
||||
import fa from "../../resources/lang/fa.json";
|
||||
import fi from "../../resources/lang/fi.json";
|
||||
import fr from "../../resources/lang/fr.json";
|
||||
import gl from "../../resources/lang/gl.json";
|
||||
import he from "../../resources/lang/he.json";
|
||||
import hi from "../../resources/lang/hi.json";
|
||||
import hu from "../../resources/lang/hu.json";
|
||||
import it from "../../resources/lang/it.json";
|
||||
import ja from "../../resources/lang/ja.json";
|
||||
import ko from "../../resources/lang/ko.json";
|
||||
import mk from "../../resources/lang/mk.json";
|
||||
import nl from "../../resources/lang/nl.json";
|
||||
import pl from "../../resources/lang/pl.json";
|
||||
import pt_BR from "../../resources/lang/pt-BR.json";
|
||||
import pt_PT from "../../resources/lang/pt-PT.json";
|
||||
import ru from "../../resources/lang/ru.json";
|
||||
import sh from "../../resources/lang/sh.json";
|
||||
import sk from "../../resources/lang/sk.json";
|
||||
import sl from "../../resources/lang/sl.json";
|
||||
import sv_SE from "../../resources/lang/sv-SE.json";
|
||||
import tp from "../../resources/lang/tp.json";
|
||||
import tr from "../../resources/lang/tr.json";
|
||||
import uk from "../../resources/lang/uk.json";
|
||||
import zh_CN from "../../resources/lang/zh-CN.json";
|
||||
|
||||
@customElement("lang-selector")
|
||||
export class LangSelector extends LitElement {
|
||||
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
import version from "../assets/data/version.txt?raw";
|
||||
import version from "resources/version.txt?raw";
|
||||
import { UserMeResponse } from "../core/ApiSchemas";
|
||||
import { EventBus } from "../core/EventBus";
|
||||
import { GameRecord, GameStartInfo, ID } from "../core/Schemas";
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { LitElement, css, html } from "lit";
|
||||
import { resolveMarkdown } from "lit-markdown";
|
||||
import { customElement, property, query } from "lit/decorators.js";
|
||||
import version from "../assets/data/version.txt?raw";
|
||||
import version from "resources/version.txt?raw";
|
||||
import { translateText } from "../client/Utils";
|
||||
import "./components/baseComponents/Button";
|
||||
import "./components/baseComponents/Modal";
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import version from "../assets/data/version.txt?raw";
|
||||
import version from "resources/version.txt?raw";
|
||||
import { FetchGameMapLoader } from "../core/game/FetchGameMapLoader";
|
||||
|
||||
export const terrainMapFileLoader = new FetchGameMapLoader(`/maps`, version);
|
||||
|
||||
@@ -4,7 +4,7 @@ import { customElement, query } from "lit/decorators.js";
|
||||
import { PlayerType } from "../../../core/game/Game";
|
||||
import { GameView, PlayerView } from "../../../core/game/GameView";
|
||||
|
||||
import quickChatData from "../../../assets/data/QuickChat.json" with { type: "json" };
|
||||
import quickChatData from "resources/QuickChat.json" with { type: "json" };
|
||||
import { EventBus } from "../../../core/EventBus";
|
||||
import { CloseViewEvent } from "../../InputHandler";
|
||||
import { SendQuickChatEvent } from "../../Transport";
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { html, LitElement } from "lit";
|
||||
import { customElement, state } from "lit/decorators.js";
|
||||
import Countries from "../../../assets/data/countries.json" with { type: "json" };
|
||||
import Countries from "resources/countries.json" with { type: "json" };
|
||||
import { EventBus } from "../../../core/EventBus";
|
||||
import {
|
||||
AllPlayers,
|
||||
|
||||
+2
-2
@@ -1,6 +1,6 @@
|
||||
import countries from "resources/countries.json";
|
||||
import quickChatData from "resources/QuickChat.json";
|
||||
import { z } from "zod";
|
||||
import countries from "../assets/data/countries.json" with { type: "json" };
|
||||
import quickChatData from "../assets/data/QuickChat.json" with { type: "json" };
|
||||
import {
|
||||
ColorPaletteSchema,
|
||||
PatternDataSchema,
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import version from "../../assets/data/version.txt?raw";
|
||||
import version from "resources/version.txt?raw";
|
||||
import { createGameRunner, GameRunner } from "../GameRunner";
|
||||
import { FetchGameMapLoader } from "../game/FetchGameMapLoader";
|
||||
import { ErrorUpdate, GameUpdateViewData } from "../game/GameUpdates";
|
||||
|
||||
Reference in New Issue
Block a user