chore: make buildConfig.json optional (#822)

This commit is contained in:
Sainan 2025-01-19 12:28:45 +01:00 committed by GitHub
parent ae832d0125
commit 15f36263cd
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 13 additions and 12 deletions

View File

@ -17,6 +17,5 @@ jobs:
node-version: ${{ matrix.version }}
- run: npm ci
- run: cp config.json.example config.json
- run: echo '{"version":"","buildLabel":"","matchmakingBuildId":""}' > static/data/buildConfig.json
- run: npm run build
- run: npm run lint

View File

@ -19,11 +19,5 @@ do
mv config.tmp config.json
done
if [ ! -f "/app/static/data/buildConfig.json" ]
then
echo "buildConfig not found, refusing to start."
exit 1
fi
npm install
exec npm run dev

View File

@ -1,13 +1,21 @@
import path from "path";
import fs from "fs";
const rootDir = path.join(__dirname, "../..");
const repoDir = path.basename(rootDir) == "build" ? path.join(rootDir, "..") : rootDir;
const buildConfigPath = path.join(repoDir, "static/data/buildConfig.json");
export const buildConfig = JSON.parse(fs.readFileSync(buildConfigPath, "utf-8")) as IBuildConfig;
interface IBuildConfig {
version: string;
buildLabel: string;
matchmakingBuildId: string;
}
export const buildConfig: IBuildConfig = {
version: "",
buildLabel: "",
matchmakingBuildId: ""
};
const rootDir = path.join(__dirname, "../..");
const repoDir = path.basename(rootDir) == "build" ? path.join(rootDir, "..") : rootDir;
const buildConfigPath = path.join(repoDir, "static/data/buildConfig.json");
if (fs.existsSync(buildConfigPath)) {
Object.assign(buildConfig, JSON.parse(fs.readFileSync(buildConfigPath, "utf-8")) as IBuildConfig);
}