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:
bbassieandClaude Fable 5.1 committed 2026-09-10 00:16:29 +00:00
1 parent 7987a5d925
commit c419f3e9b2
10 files changed
+349 -41

No files matched your search

+11
View File
@@ -24,6 +24,7 @@ import * as lib from "@clusterio/lib";
import { ConsoleTransport, levels, logger } from "@clusterio/lib";
import Host from "./src/Host";
import { createScenarioCommand, handleCreateScenarioCommand } from "./src/create_scenario";
let host: Host | undefined;
@@ -113,6 +114,11 @@ async function startHost() {
.option("bypass-lock-file", { hidden: true, type: "boolean", nargs: 0, default: false })
.command("plugin", "Manage available plugins", lib.pluginCommand)
.command("config", "Manage Host config", lib.configCommand)
.command(
"create-scenario <output>",
"Create a scenario patched with modules for use outside Clusterio",
createScenarioCommand,
)
.command("run", "Run host", yargs => {
yargs.option("can-restart", {
type: "boolean", nargs: 0, default: false,
@@ -194,6 +200,11 @@ async function startHost() {
return;
}
if (command === "create-scenario") {
await handleCreateScenarioCommand(args, hostConfig, pluginInfos);
return;
}
// From this point on the host should run
await hostConfigLock.acquire();