add command line --configPath and --dev arguments
All checks were successful
Build / build (pull_request) Successful in 1m28s

This commit is contained in:
Sainan 2025-06-21 00:06:30 +02:00
parent c2ee66896f
commit 3c1b621f3f
6 changed files with 26 additions and 8 deletions

View File

@ -5,4 +5,4 @@ if [ ! -f conf/config.json ]; then
jq --arg value "mongodb://openwfagent:spaceninjaserver@mongodb:27017/" '.mongodbUrl = $value' /app/config.json.example > /app/conf/config.json
fi
exec npm run start conf/config.json
exec npm run start -- --configPath conf/config.json

View File

@ -20,11 +20,11 @@ function run(changedFile) {
runproc = undefined;
}
buildproc = spawn("npm", ["run", "build", ...args], { stdio: "inherit", shell: true });
buildproc = spawn("npm", ["run", "build"], { stdio: "inherit", shell: true });
buildproc.on("exit", code => {
buildproc = undefined;
if (code === 0) {
runproc = spawn("npm", ["run", "start", ...args], { stdio: "inherit", shell: true });
runproc = spawn("npm", ["run", "start", "--", "--dev", ...args], { stdio: "inherit", shell: true });
runproc.on("exit", () => {
runproc = undefined;
});

View File

@ -0,0 +1,18 @@
interface IArguments {
configPath?: string;
dev?: boolean;
}
export const args: IArguments = {};
for (let i = 2; i < process.argv.length; ) {
switch (process.argv[i++]) {
case "--configPath":
args.configPath = process.argv[i++];
break;
case "--dev":
args.dev = true;
break;
}
}

View File

@ -1,5 +1,4 @@
import path from "path";
export const rootDir = path.join(__dirname, "../..");
export const isDev = path.basename(rootDir) != "build";
export const repoDir = isDev ? rootDir : path.join(rootDir, "..");
export const repoDir = path.basename(rootDir) != "build" ? rootDir : path.join(rootDir, "..");

View File

@ -1,6 +1,7 @@
import fs from "fs";
import path from "path";
import { repoDir } from "@/src/helpers/pathHelper";
import { args } from "@/src/helpers/commandLineArguments";
export interface IConfig {
mongodbUrl: string;
@ -79,7 +80,7 @@ export interface IConfig {
};
}
export const configPath = path.join(repoDir, process.argv[2] ?? "config.json");
export const configPath = path.join(repoDir, args.configPath ?? "config.json");
export const config: IConfig = {
mongodbUrl: "mongodb://127.0.0.1:27017/openWF",

View File

@ -1,5 +1,5 @@
import { unixTimesInMs } from "@/src/constants/timeConstants";
import { isDev } from "@/src/helpers/pathHelper";
import { args } from "@/src/helpers/commandLineArguments";
import { catBreadHash } from "@/src/helpers/stringHelpers";
import { TInventoryDatabaseDocument } from "@/src/models/inventoryModels/inventoryModel";
import { mixSeeds, SRng } from "@/src/services/rngService";
@ -421,7 +421,7 @@ const generateVendorManifest = (vendorInfo: IGeneratableVendorInfo): IVendorMani
return cacheEntry;
};
if (isDev) {
if (args.dev) {
if (
getCycleDuration(ExportVendors["/Lotus/Types/Game/VendorManifests/Hubs/TeshinHardModeVendorManifest"]) !=
unixTimesInMs.week