XFE Git
XFE Studio Git
Git 首页 全局搜索
XFE 主站 文档 NuGet

XFESpaceNinjaServer

A simple server for a small space ninja game

公开
关注 0 Fork 0 Star 0
返回提交历史

XFEstudio/XFESpaceNinjaServer

chore: make buildConfig.json optional (#822)

15f36263
Sainan <sainan@calamity.inc>
提交于

代码差异

3 个文件 +13 -12
Modified .github/workflows/build.yml +0 -1
@@ -17,6 +17,5 @@ jobs:
17 17 node-version: ${{ matrix.version }}
18 18 - run: npm ci
19 19 - run: cp config.json.example config.json
20 - run: echo '{"version":"","buildLabel":"","matchmakingBuildId":""}' > static/data/buildConfig.json
21 20 - run: npm run build
22 21 - run: npm run lint
Modified docker-entrypoint.sh +0 -6
@@ -19,11 +19,5 @@ do
19 19 mv config.tmp config.json
20 20 done
21 21
22 if [ ! -f "/app/static/data/buildConfig.json" ]
23 then
24 echo "buildConfig not found, refusing to start."
25 exit 1
26 fi
27
28 22 npm install
29 23 exec npm run dev
Modified src/services/buildConfigService.ts +13 -5
@@ -1,13 +1,21 @@
1 1 import path from "path";
2 2 import fs from "fs";
3 3
4 const rootDir = path.join(__dirname, "../..");
5 const repoDir = path.basename(rootDir) == "build" ? path.join(rootDir, "..") : rootDir;
6 const buildConfigPath = path.join(repoDir, "static/data/buildConfig.json");
7 export const buildConfig = JSON.parse(fs.readFileSync(buildConfigPath, "utf-8")) as IBuildConfig;
8
9 4 interface IBuildConfig {
10 5 version: string;
11 6 buildLabel: string;
12 7 matchmakingBuildId: string;
13 8 }
9
10 export const buildConfig: IBuildConfig = {
11 version: "",
12 buildLabel: "",
13 matchmakingBuildId: ""
14 };
15
16 const rootDir = path.join(__dirname, "../..");
17 const repoDir = path.basename(rootDir) == "build" ? path.join(rootDir, "..") : rootDir;
18 const buildConfigPath = path.join(repoDir, "static/data/buildConfig.json");
19 if (fs.existsSync(buildConfigPath)) {
20 Object.assign(buildConfig, JSON.parse(fs.readFileSync(buildConfigPath, "utf-8")) as IBuildConfig);
21 }