Merge upstream/master and address review

Resolves the ESM conflicts in patch.ts, Instance.ts and host.ts. The
module gathering in Instance now goes through patch.loadModules with
the instance's loadedPlugins, and imports use explicit extensions.

Review changes: the existing-output check only treats ENOENT as
"does not exist" and rethrows anything else, a --zip option keeps the
output as a zip file for transfer (extracting stays the default), the
--scenario option describes that it takes a path and what the default
is, and the docs note that IPC is not available outside Clusterio.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
This commit is contained in:
bbassieandClaude Fable 5.1 committed 2026-09-12 22:21:46 +00:00
commit 187138bec5
297 files changed
+4980 -3274

No files matched your search

+9 -20
View File
@@ -1,11 +1,10 @@
"use strict";
const assert = require("assert").strict;
const fs = require("node:fs/promises");
const JSZip = require("jszip");
const path = require("path");
import assert from "node:assert/strict";
import fs from "node:fs/promises";
import JSZip from "jszip";
import path from "node:path";
const lib = require("@clusterio/lib");
const patch = require("@clusterio/host/dist/node/src/patch");
import * as lib from "@clusterio/lib";
import * as patch from "@clusterio/host/dist/node/src/patch.js";
describe("host/patch", function() {
@@ -253,24 +252,14 @@ describe("host/patch", function() {
await fs.writeFile(path.join(pluginDir, "package.json"), "{}");
await fs.writeFile(path.join(pluginDir, "module", "module.json"), "{}");
await assert.rejects(
patch.loadModules([{ name: "clusterio", version: "1.0.0", requirePath: path.resolve(pluginDir) }]),
patch.loadModules([{
name: "clusterio", version: "1.0.0", packagePath: path.resolve(pluginDir, "package.json"),
}]),
new Error("Module with name clusterio already exists in a plugin")
);
});
});
describe("class SaveModule", function() {
describe("static fromPlugin()", function() {
it("should load the module of the plugin", async function() {
const [info] = await lib.loadPluginInfos(
new Map([["research_sync", path.resolve("plugins/research_sync")]])
);
const pluginModule = await patch.SaveModule.fromPlugin({ info });
assert.equal(pluginModule.info.name, "research_sync");
});
});
});
describe("patch()", function() {
it("should throw on unknown scenario", async function() {
let zip = new JSZip();