mirror of
https://github.com/clusterio/clusterio.git
synced 2026-11-22 00:13:12 +09:00
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:
commit
187138bec5
297 files changed
+4980
-3274
No files matched your search
@@ -1,14 +1,13 @@
|
||||
"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 {
|
||||
import * as lib from "@clusterio/lib";
|
||||
import {
|
||||
createScenario, createScenarioCommand, handleCreateScenarioCommand,
|
||||
} = require("@clusterio/host/dist/node/src/create_scenario");
|
||||
const { SaveModule, PatchInfo } = require("@clusterio/host/dist/node/src/patch");
|
||||
} from "@clusterio/host/dist/node/src/create_scenario.js";
|
||||
import { SaveModule, PatchInfo } from "@clusterio/host/dist/node/src/patch.js";
|
||||
|
||||
|
||||
describe("host/create_scenario", function() {
|
||||
@@ -71,6 +70,19 @@ describe("host/create_scenario", function() {
|
||||
checkOutput(await readDir(output));
|
||||
});
|
||||
|
||||
it("should write a zip file when asked to", async function() {
|
||||
const output = path.join(tempDir, "zipped.zip");
|
||||
await createScenario(path.join(tempDir, "scenario"), output, [module], true);
|
||||
const zip = await JSZip.loadAsync(await fs.readFile(output));
|
||||
const files = new Map();
|
||||
for (const file of Object.values(zip.files)) {
|
||||
if (!file.dir) {
|
||||
files.set(file.name.replace(/^scenario\//, ""), await file.async("string"));
|
||||
}
|
||||
}
|
||||
checkOutput(files);
|
||||
});
|
||||
|
||||
it("should not modify the input scenario", async function() {
|
||||
const files = await readDir(path.join(tempDir, "scenario"));
|
||||
assert.deepEqual(files, scenarioFiles);
|
||||
@@ -103,7 +115,7 @@ describe("host/create_scenario", function() {
|
||||
};
|
||||
createScenarioCommand(yargs);
|
||||
assert.deepEqual(positionals, ["output"]);
|
||||
assert.deepEqual(options, ["scenario", "factorio-version", "plugins"]);
|
||||
assert.deepEqual(options, ["zip", "scenario", "factorio-version", "plugins"]);
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
Reference in new issue
Block a user