diff --git a/.travis.yml b/.travis.yml index b75fb52d..9ffbf028 100644 --- a/.travis.yml +++ b/.travis.yml @@ -7,8 +7,8 @@ before_install: - npm install -g codecov script: - npx lerna bootstrap --no-ci - - node packages/lib/build_mod --source-dir packages/slave/lua/clusterio_lib --bump-patch --factorio-version 0.18 --output-dir temp/test/sharedMods - - curl -o temp/test/sharedMods/subspace_storage_1.99.1.zip -L https://github.com/clusterio/factorioClusterioMod/releases/download/1.99.1/subspace_storage_1.99.1.zip + - node packages/lib/build_mod --source-dir packages/slave/lua/clusterio_lib --output-dir temp/test/sharedMods + - curl -o temp/test/sharedMods/subspace_storage_1.99.8.zip -L https://github.com/clusterio/factorioClusterioMod/releases/download/1.99.6/subspace_storage_1.99.8.zip - npx lerna run build - npm run-script ci-cover - codecov -f coverage/lcov.info diff --git a/packages/lib/build_mod.js b/packages/lib/build_mod.js index 6fa8822f..4ea89c51 100644 --- a/packages/lib/build_mod.js +++ b/packages/lib/build_mod.js @@ -13,11 +13,10 @@ async function main() { .scriptName("build") .options({ "clean": { describe: "Remove previous builds", type: "boolean", default: false }, - "build": { describe: "Build mod", type: "boolean", default: true }, + "build": { describe: "Build mod(s)", type: "boolean", default: true }, "pack": { describe: "Pack into zip file", type: "boolean", default: true }, "source-dir": { describe: "Path to mod source files", nargs: 1, type: "string", demandOption: true }, - "output-dir": { describe: "Path to output built mod", nargs: 1, type: "string", default: "dist" }, - "bump-patch": { describe: "Increment patch number of build", type: "boolean", default: false }, + "output-dir": { describe: "Path to output built mod(s)", nargs: 1, type: "string", default: "dist" }, "factorio-version": { describe: "Override factorio_version", type: "string" }, }) .strict() @@ -30,12 +29,6 @@ async function main() { async function build(args) { let info = JSON.parse(await fs.readFile(path.join(args.sourceDir, "info.json"))); - if (args.bumpPatch) { - let [major, minor, patch] = info.version.split("."); - patch = String(Number.parseInt(patch, 10) + 1); - info.version = [major, minor, patch].join("."); - } - if (args.factorioVersion) { info.factorio_version = args.factorioVersion; } @@ -59,6 +52,21 @@ async function build(args) { } } + if (info.variants) { + for (let [variant, variantOverrides] of Object.entries(info.variants)) { + let variantInfo = { + ...info, + ...variantOverrides, + }; + delete variantInfo.variants; + await buildMod(args, variantInfo); + } + } else { + await buildMod(args, info); + } +} + +async function buildMod(args, info) { if (args.build) { await fs.ensureDir(args.outputDir); let modName = `${info.name}_${info.version}`; @@ -78,12 +86,12 @@ async function build(args) { ; await events.once(walker, "end"); - for (let pathParts of info.additional_files || []) { + for (let [fileName, pathParts] of Object.entries(info.additional_files || {})) { let filePath = path.join(args.sourceDir, ...pathParts); if (!await fs.pathExists(filePath)) { throw new Error(`Additional file ${filePath} does not exist`); } - zip.file(path.posix.join(modName, path.basename(filePath)), fs.createReadStream(filePath)); + zip.file(path.posix.join(modName, fileName), fs.createReadStream(filePath)); } delete info.additional_files; @@ -102,9 +110,9 @@ async function build(args) { } console.log(`Building ${modDir}`); await fs.copy(args.sourceDir, modDir); - for (let pathParts of info.additional_files || []) { + for (let [fileName, pathParts] of Object.entries(info.additional_files) || []) { let filePath = path.join(...pathParts); - await fs.copy(filePath, path.join(modDir, path.basename(filePath))); + await fs.copy(filePath, path.join(modDir, fileName)); } delete info.additional_files; diff --git a/packages/slave/lua/clusterio_lib/changelog.txt b/packages/slave/lua/clusterio_lib/changelog.txt index fdce82ea..e078d229 100644 --- a/packages/slave/lua/clusterio_lib/changelog.txt +++ b/packages/slave/lua/clusterio_lib/changelog.txt @@ -1,4 +1,8 @@ --------------------------------------------------------------------------------------------------- +Version: 0.1.2 + Features: + - Added support for Factorio 1.1. +--------------------------------------------------------------------------------------------------- Version: 0.1.1 Features: - Added support for Factorio 0.18.x diff --git a/packages/slave/lua/clusterio_lib/info.json b/packages/slave/lua/clusterio_lib/info.json index b66e2a2e..1633d6e2 100644 --- a/packages/slave/lua/clusterio_lib/info.json +++ b/packages/slave/lua/clusterio_lib/info.json @@ -1,12 +1,24 @@ { "name": "clusterio_lib", - "version": "0.1.1", + "variants": [ + { + "version": "0.1.0", + "factorio_version": "0.17" + }, + { + "version": "0.1.1", + "factorio_version": "0.18" + }, + { + "version": "0.1.2", + "factorio_version": "1.1" + } + ], "title": "Clusterio Library (Alpha)", "author": "Clusterio Team", "homepage": "https://github.com/clusterio/factorioClusterio", "description": "Library for interfacing with Clusterio. Warning: work in progress alpha.", - "factorio_version": "0.17", - "additional_files": [ - ["..", "..", "modules", "clusterio", "serialize.lua"] - ] + "additional_files": { + "serialize.lua": ["..", "..", "modules", "clusterio", "serialize.lua"] + } } diff --git a/plugins/subspace_storage/instance.js b/plugins/subspace_storage/instance.js index 39a67546..668f0b69 100644 --- a/plugins/subspace_storage/instance.js +++ b/plugins/subspace_storage/instance.js @@ -73,14 +73,6 @@ class InstancePlugin extends libPlugin.BaseInstancePlugin { async updateStorageEventHandler(message, event) { let items = message.data.items; - // XXX this should be done on the lua side - // Ensure counts don't overflow - for (let item of items) { - if (item[1] > 0x7fffffff) { - item[1] = 0x7fffffff; - } - } - // XXX this should be moved to instance/clusterio api items.push(["signal-unixtime", Math.floor(Date.now()/1000)]);