mirror of
https://github.com/clusterio/clusterio.git
synced 2026-11-16 23:30:41 +09:00
Add create-scenario command to clusteriohost
Creates a scenario directory with the Clusterio modules patched into it so the modules can be used outside of Clusterio. The command reuses the save patching by zipping the scenario, running patch() on it and extracting the result. Defaults to the freeplay scenario from the Factorio install in the host config and all plugins enabled there. Module loading in Instance.prepareSave is moved to patch.loadModules so the command and the instance share it, and findVersion is exported from server.ts so the command can find the freeplay scenario. Zipped scenarios were tried as an output form but Factorio does not pick them up from the scenarios folder, so only directories are written. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
This commit is contained in:
1 parent
7987a5d925
commit
c419f3e9b2
10 files changed
+349
-41
No files matched your search
+9
-9
@@ -42,26 +42,26 @@ describe("host/server", function() {
|
||||
describe("direct install", function() {
|
||||
it("should search given directory for latest Factorio install", async function() {
|
||||
const installDir = path.join("test", "file", "factorio", "0.1.2");
|
||||
const [dir, version] = await hostServer._findVersion(installDir, "latest");
|
||||
const [dir, version] = await hostServer.findVersion(installDir, "latest");
|
||||
assert.equal(dir, path.join(installDir, "data"));
|
||||
assert.equal(version, "0.1.2");
|
||||
});
|
||||
it("should search given directory for given Factorio install", async function() {
|
||||
const installDir = path.join("test", "file", "factorio", "0.1.1");
|
||||
const [dir, version] = await hostServer._findVersion(installDir, "0.1.1");
|
||||
const [dir, version] = await hostServer.findVersion(installDir, "0.1.1");
|
||||
assert.equal(dir, path.join(installDir, "data"));
|
||||
assert.equal(version, "0.1.1");
|
||||
});
|
||||
it("should search given directory for partly given Factorio install", async function() {
|
||||
const installDir = path.join("test", "file", "factorio", "0.1.2");
|
||||
const [dir, version] = await hostServer._findVersion(installDir, "0.1");
|
||||
const [dir, version] = await hostServer.findVersion(installDir, "0.1");
|
||||
assert.equal(dir, path.join(installDir, "data"));
|
||||
assert.equal(version, "0.1.2");
|
||||
});
|
||||
it("should reject if the version does not match", async function() {
|
||||
let installDir = path.join("test", "file", "factorio", "0.1.1");
|
||||
await assert.rejects(
|
||||
hostServer._findVersion(installDir, "0.1.2"),
|
||||
hostServer.findVersion(installDir, "0.1.2"),
|
||||
new Error(
|
||||
`Unable to find Factorio version 0.1.2: ${installDir} is a direct (single-version) ` +
|
||||
`install of 0.1.1. Use a versioned layout, where ${installDir} contains a subdirectory ` +
|
||||
@@ -74,33 +74,33 @@ describe("host/server", function() {
|
||||
it("should reject if no factorio install with the given version was found", async function() {
|
||||
let installDir = path.join("test", "file", "factorio");
|
||||
await assert.rejects(
|
||||
hostServer._findVersion(installDir, "0.1.3"),
|
||||
hostServer.findVersion(installDir, "0.1.3"),
|
||||
new Error("Unable to find Factorio version 0.1.3")
|
||||
);
|
||||
});
|
||||
it("should search given directory for given Factorio install", async function() {
|
||||
const installDir = path.join("test", "file", "factorio");
|
||||
const [dir, version] = await hostServer._findVersion(installDir, "0.1.1");
|
||||
const [dir, version] = await hostServer.findVersion(installDir, "0.1.1");
|
||||
assert.equal(dir, path.join(installDir, "0.1.1", "data"));
|
||||
assert.equal(version, "0.1.1");
|
||||
});
|
||||
it("should search given directory for partly given Factorio install", async function() {
|
||||
const installDir = path.join("test", "file", "factorio");
|
||||
const [dir, version] = await hostServer._findVersion(installDir, "0.1");
|
||||
const [dir, version] = await hostServer.findVersion(installDir, "0.1");
|
||||
assert.equal(dir, path.join(installDir, "0.1.2", "data"));
|
||||
assert.equal(version, "0.1.2");
|
||||
});
|
||||
it("should reject if no factorio install with the given version was found", async function() {
|
||||
let installDir = path.join("test", "file", "factorio");
|
||||
await assert.rejects(
|
||||
hostServer._findVersion(installDir, "0.1.3"),
|
||||
hostServer.findVersion(installDir, "0.1.3"),
|
||||
new Error("Unable to find Factorio version 0.1.3")
|
||||
);
|
||||
});
|
||||
it("should reject if no factorio install was found", async function() {
|
||||
let installDir = path.join("test", "file");
|
||||
await assert.rejects(
|
||||
hostServer._findVersion(installDir, "0.0.0"),
|
||||
hostServer.findVersion(installDir, "0.0.0"),
|
||||
new Error(`Unable to find any Factorio install in ${installDir}`)
|
||||
);
|
||||
});
|
||||
|
||||
Reference in new issue
Block a user