Add default mod packs (#735)

This commit is contained in:
Cooldude2606 authored and GitHub committed 2025-02-14 14:47:26 +00:00
1 parent 7b8945ff15
commit 8996671bea
6 files changed
+72 -1

No files matched your search

+4
View File
@@ -127,6 +127,10 @@ export default class Controller {
lib.ModPack.fromJSON.bind(lib.ModPack)
).bootstrap());
if (modPacks.size === 0) {
modPacks.setMany(lib.ModPack.defaultModPacks);
}
const userManager = new UserManager(config);
await userManager.load(path.join(databaseDirectory, "users.json"));
+21
View File
@@ -383,6 +383,27 @@ export default class ModPack {
}
}
/** Array of default mod packs which should exist on a newly installed cluster */
static defaultModPacks = [
...["0.17", "0.18", "1.0", "1.1", "2.0"]
.map(version => this.fromJSON({
name: `Base Game ${version}`,
description: `Factorio ${version} with no extra mods.`,
factorio_version: version,
} as any)),
...["2.0"]
.map(version => this.fromJSON({
name: `Space Age ${version}`,
description: `Factorio ${version} with Space Age expansion.`,
factorio_version: version,
mods: [
{ name: "elevated-rails", enabled: true, version },
{ name: "quality", enabled: true, version },
{ name: "space-age", enabled: true, version },
],
} as any)),
];
/**
* Returns an array of ModInfo containing all mods included in factorio
*
+5
View File
@@ -189,6 +189,11 @@ export abstract class Datastore<
return this.data.get(key);
}
// Allow getting the size of the datastore
get size() {
return this.data.size;
}
// Allow iterating through the datastore like a Map.
[Symbol.iterator](): IterableIterator<[K, Readonly<V>]> {
return this.data.entries();
+8 -1
View File
@@ -1072,8 +1072,15 @@ describe("Integration of Clusterio", function() {
});
describe("mod-pack list", function() {
let result = null;
it("runs", async function() {
await execCtl("mod-pack list");
result = await execCtl("mod-pack list");
});
it("contains defaults", function() {
assert(result !== null, "Failed to return a value");
const stdout = result.stdout.trim();
assert(stdout.indexOf("Base Game") >= 0, "No base game pack");
assert(stdout.indexOf("Space Age") >= 0, "No space age pack");
});
});
+18
View File
@@ -378,6 +378,24 @@ describe("lib/data/ModPack", function() {
/* eslint-enable indent */
});
});
describe("defaultModPacks", function() {
it("should contain at least one base game only", function() {
const modPack = ModPack.defaultModPacks.find(pack => {
const base = pack.mods.get("base");
const spaceAge = pack.mods.get("space-age");
return base && base.enabled && (!spaceAge || !spaceAge.enabled);
});
assert(modPack, "Does not contain base game only");
});
it("should contain at least one space age expansion", function() {
const modPack = ModPack.defaultModPacks.find(pack => {
const base = pack.mods.get("base");
const spaceAge = pack.mods.get("space-age");
return base && base.enabled && spaceAge && spaceAge.enabled;
});
assert(modPack, "Does not contain space age expansion");
});
});
describe("getBuiltinMods()", function() {
it("should work with versions before 2.0", function() {
const builtinMods = ModPack.getBuiltinMods("1.1");
+16
View File
@@ -413,6 +413,22 @@ describe("lib/datastore", function() {
});
});
describe("size", function() {
it("returns the correct size", function() {
assert.equal(datastore.size, 3);
});
});
describe("iterator", function() {
it("iterates all values", function() {
const entries = [];
for (const entry of datastore) {
entries.push(entry);
}
assert.deepEqual(entries, [...datastoreProvider.value.entries()]);
});
});
describe("values", function() {
it("returns all values", function() {
assert.deepEqual([...datastore.values()], [...datastoreProvider.value.values()]);