mirror of
https://github.com/clusterio/clusterio.git
synced 2026-11-20 15:43:13 +09:00
Refuse to start without required mods and download them
requiredMods entries are now Factorio dependency strings, and a mod listed twice gives a version range. The plugin loader validates them. The host refuses to start an instance whose mod pack is missing a required mod of a loaded plugin, has it disabled or has it outside the version range. On start the controller resolves the required mods of its plugins and their dependencies for the default mod pack's Factorio version and downloads the ones missing from the mod store. The resolver and portal download move from the ControlConnection handlers into Controller methods so both paths share them. Subspace Storage requires subspace_storage >= 1.99.0, and the integration tests build a stub of that mod for the test mod pack. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
a845b7ac52
commit
bf33f4f52e
12 files changed
+437
-240
No files matched your search
@@ -9,6 +9,7 @@ import type { PermissionDefinition } from "./permissions.js";
|
||||
import type { PlayerStats, Role } from "./data/index.js";
|
||||
import type { SyncHook } from "./SyncHook.js";
|
||||
import type { ErrorClass } from "./link/index.js";
|
||||
import { ModDependency } from "./data/ModInfo.js";
|
||||
|
||||
export const PluginFeatureFlags = [
|
||||
/** The plugin requires module code to be patched into the save */
|
||||
@@ -41,7 +42,10 @@ export type PluginDeclaration = {
|
||||
migrationEntrypoint?: string;
|
||||
|
||||
features?: (typeof PluginFeatureFlags)[number][];
|
||||
/** Names of Factorio mods the plugin needs in the instance's mod pack */
|
||||
/**
|
||||
* Factorio mods the plugin needs in the instance's mod pack, as Factorio
|
||||
* dependency strings like `"subspace_storage >= 2.3.0"`.
|
||||
*/
|
||||
requiredMods?: string[];
|
||||
|
||||
messages?: any[];
|
||||
@@ -67,6 +71,23 @@ export function pluginNeedsWebBuild(info: PluginDeclaration) {
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Parse the requiredMods of a plugin
|
||||
*
|
||||
* A mod listed more than once must satisfy every entry, which gives a range.
|
||||
*
|
||||
* @throws Error if an entry is invalid or has a dependency prefix.
|
||||
*/
|
||||
export function pluginRequiredMods(pluginInfo: PluginDeclaration) {
|
||||
return (pluginInfo.requiredMods ?? []).map(spec => {
|
||||
const dependency = new ModDependency(spec);
|
||||
if (dependency.type !== "required") {
|
||||
throw new Error(`requiredMods entry "${spec}" can not have a dependency prefix`);
|
||||
}
|
||||
return dependency;
|
||||
});
|
||||
}
|
||||
|
||||
export type PluginNodeEnvInfo = PluginDeclaration & {
|
||||
/**
|
||||
* Path to the folder with the static files that should be hosted on the web
|
||||
|
||||
Reference in new issue
Block a user