From ff28357d7a6b347512898c379b534c032950d2a0 Mon Sep 17 00:00:00 2001 From: Cooldude2606 <25043174+Cooldude2606@users.noreply.github.com> Date: Fri, 10 Jul 2026 21:42:45 +0100 Subject: [PATCH] Remove hard coded versions --- packages/host/src/Host.ts | 6 ++---- packages/host/src/Instance.ts | 4 +--- test/integration/index.js | 13 ++++++++++--- 3 files changed, 13 insertions(+), 10 deletions(-) diff --git a/packages/host/src/Host.ts b/packages/host/src/Host.ts index 6f2a193a..b99392dc 100644 --- a/packages/host/src/Host.ts +++ b/packages/host/src/Host.ts @@ -659,10 +659,8 @@ export default class Host extends lib.Link { return await this.downloadMod(mod); } - async fetchMods(mods: Iterable) { - // This is better than the previous hard coded names - // But it really shouldn't be a hard coded version either - const builtinModNames = lib.ModPack.getBuiltinModNames("2.1"); + async fetchMods(mods: Iterable, factorioVersion: lib.PartialVersion) { + const builtinModNames = lib.ModPack.getBuiltinModNames(factorioVersion); const modInfos: Promise[] = []; for (const mod of mods) { if (builtinModNames.includes(mod.name)) { diff --git a/packages/host/src/Instance.ts b/packages/host/src/Instance.ts index ac72da58..19f10032 100644 --- a/packages/host/src/Instance.ts +++ b/packages/host/src/Instance.ts @@ -797,9 +797,7 @@ end`.replace(/\r?\n/g, " "); } this.activeModPack = modPack; - // TODO validate factorioVersion - - const mods = await this._host.fetchMods(modPack.mods.values()); + const mods = await this._host.fetchMods(modPack.mods.values(), modPack.factorioVersion); await fs.mkdir(this.path("mods"), { recursive: true }); diff --git a/test/integration/index.js b/test/integration/index.js index 2f990f19..4a529471 100644 --- a/test/integration/index.js +++ b/test/integration/index.js @@ -363,7 +363,11 @@ before(async function() { controllerProcess = await spawnNode("controller:", "../../packages/controller run", /Started controller/); - haveFactorioInstall = (await _listFactorioVersions(factorioDir)).versions.size > 0; + const factorioVersions = (await _listFactorioVersions(factorioDir)).versions; + const latestFactorioVersion = [...factorioVersions.values()] + .sort((a, b) => lib.integerFullVersion(b) - lib.integerFullVersion(a))[0]; + haveFactorioInstall = factorioVersions.size > 0; + const relativeFactorioDir = path.isAbsolute(factorioDir) ? factorioDir : path.join("..", "..", factorioDir); await execCtlProcess("host create-config --id 4 --name host --generate-token"); await execHost(`config set host.factorio_directory ${relativeFactorioDir}`); @@ -382,8 +386,11 @@ before(async function() { const testPack = lib.ModPack.fromJSON({}); testPack.id = 12; testPack.name = "subspace_storage-pack"; - testPack.factorioVersion = "2.1"; - testPack.mods.set("clusterio_lib", { name: "clusterio_lib", enabled: true, version: "2.0.21" }); + testPack.factorioVersion = latestFactorioVersion; + + const [major, minor] = lib.normaliseMajorMinorVersion(latestFactorioVersion).split("."); + testPack.mods.set("clusterio_lib", { name: "clusterio_lib", enabled: true, version: `2.0.${major}${minor}` }); + await control.sendTo("controller", new lib.ModPackCreateRequest(testPack)); await control.sendTo( "controller",