Add update all for the controller, hosts and plugins

Updating a single plugin can leave the installation with multiple
versions of @clusterio/lib. Passing the core package and every npm
installed plugin to a single npm update call lets npm resolve them
together.

UpdateAllRequest targets the controller or a host, requires both the
core update permission and core.plugin.update, and is gated by both
allow_remote_updates and allow_plugin_updates. The web UI Updates modal
gets an Update All action and ctl gets --all on the update commands.

Closes #910

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
This commit is contained in:
bbassieandClaude Fable 5.1 committed 2026-09-09 22:40:32 +00:00
1 parent 7987a5d925
commit 7ff2092547
11 files changed
+158 -7

No files matched your search

+13
View File
@@ -1,6 +1,8 @@
import { Type, Static } from "@sinclair/typebox";
import { jsonArray } from "./composites";
import { PluginNodeEnvInfo } from "../plugin";
import { Address, MessageRequest } from "./messages_core";
import type { IUser } from "./UserDetails";
/* This is similar to other plugin definitions but with lots removed */
export class PluginDetails {
@@ -91,3 +93,14 @@ export class PluginInstallRequest {
return this.pluginPackage;
}
}
export class UpdateAllRequest {
declare ["constructor"]: typeof UpdateAllRequest;
static type = "request" as const;
static src = "control" as const;
static dst = ["controller", "host"] as const;
static permission(user: IUser, message: MessageRequest) {
user.checkPermission(message.dst.type === Address.host ? "core.host.update" : "core.controller.update");
user.checkPermission("core.plugin.update");
}
}
+1
View File
@@ -140,4 +140,5 @@ export const dataClasses: (RequestClass<unknown, unknown> | EventClass<unknown>)
plugin.PluginListRequest,
plugin.PluginUpdateRequest,
plugin.PluginInstallRequest,
plugin.UpdateAllRequest,
];
+9 -2
View File
@@ -19,8 +19,8 @@ async function logExec(cmd: string) {
}
}
export async function updatePackage(name: string) {
return logExec(`npm update --save ${name}`);
export async function updatePackage(...names: string[]) {
return logExec(`npm update --save ${names.join(" ")}`);
}
export async function installPackage(name: string) {
@@ -35,6 +35,13 @@ export async function handlePluginUpdate(pluginName: string, pluginInfos: Plugin
return await updatePackage(pluginName);
}
export async function handleUpdateAll(corePackage: string, pluginInfos: PluginNodeEnvInfo[]) {
const pluginPackages = pluginInfos
.map(plugin => plugin.npmPackage)
.filter((name): name is string => name !== undefined);
return await updatePackage(corePackage, ...pluginPackages);
}
export async function handlePluginInstall(pluginName: string) {
if (pluginName.length > 214 || /[^a-zA-Z0-9\-_.+@\/]/.test(pluginName)) {
// https://docs.npmjs.com/cli/v11/configuring-npm/package-json#name