mirror of
https://github.com/clusterio/clusterio.git
synced 2026-11-22 16:13:12 +09:00
Merge pull request #343 from Hornwitser/factorio-1.1
Add support for Factorio 1.1
This commit is contained in:
5 files changed
+44
-28
No files matched your search
+2
-2
@@ -7,8 +7,8 @@ before_install:
|
|||||||
- npm install -g codecov
|
- npm install -g codecov
|
||||||
script:
|
script:
|
||||||
- npx lerna bootstrap --no-ci
|
- 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
|
- 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.1.zip -L https://github.com/clusterio/factorioClusterioMod/releases/download/1.99.1/subspace_storage_1.99.1.zip
|
- 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
|
- npx lerna run build
|
||||||
- npm run-script ci-cover
|
- npm run-script ci-cover
|
||||||
- codecov -f coverage/lcov.info
|
- codecov -f coverage/lcov.info
|
||||||
|
|||||||
+21
-13
@@ -13,11 +13,10 @@ async function main() {
|
|||||||
.scriptName("build")
|
.scriptName("build")
|
||||||
.options({
|
.options({
|
||||||
"clean": { describe: "Remove previous builds", type: "boolean", default: false },
|
"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 },
|
"pack": { describe: "Pack into zip file", type: "boolean", default: true },
|
||||||
"source-dir": { describe: "Path to mod source files", nargs: 1, type: "string", demandOption: 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" },
|
"output-dir": { describe: "Path to output built mod(s)", nargs: 1, type: "string", default: "dist" },
|
||||||
"bump-patch": { describe: "Increment patch number of build", type: "boolean", default: false },
|
|
||||||
"factorio-version": { describe: "Override factorio_version", type: "string" },
|
"factorio-version": { describe: "Override factorio_version", type: "string" },
|
||||||
})
|
})
|
||||||
.strict()
|
.strict()
|
||||||
@@ -30,12 +29,6 @@ async function main() {
|
|||||||
async function build(args) {
|
async function build(args) {
|
||||||
let info = JSON.parse(await fs.readFile(path.join(args.sourceDir, "info.json")));
|
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) {
|
if (args.factorioVersion) {
|
||||||
info.factorio_version = 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) {
|
if (args.build) {
|
||||||
await fs.ensureDir(args.outputDir);
|
await fs.ensureDir(args.outputDir);
|
||||||
let modName = `${info.name}_${info.version}`;
|
let modName = `${info.name}_${info.version}`;
|
||||||
@@ -78,12 +86,12 @@ async function build(args) {
|
|||||||
;
|
;
|
||||||
await events.once(walker, "end");
|
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);
|
let filePath = path.join(args.sourceDir, ...pathParts);
|
||||||
if (!await fs.pathExists(filePath)) {
|
if (!await fs.pathExists(filePath)) {
|
||||||
throw new Error(`Additional file ${filePath} does not exist`);
|
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;
|
delete info.additional_files;
|
||||||
|
|
||||||
@@ -102,9 +110,9 @@ async function build(args) {
|
|||||||
}
|
}
|
||||||
console.log(`Building ${modDir}`);
|
console.log(`Building ${modDir}`);
|
||||||
await fs.copy(args.sourceDir, 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);
|
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;
|
delete info.additional_files;
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,8 @@
|
|||||||
---------------------------------------------------------------------------------------------------
|
---------------------------------------------------------------------------------------------------
|
||||||
|
Version: 0.1.2
|
||||||
|
Features:
|
||||||
|
- Added support for Factorio 1.1.
|
||||||
|
---------------------------------------------------------------------------------------------------
|
||||||
Version: 0.1.1
|
Version: 0.1.1
|
||||||
Features:
|
Features:
|
||||||
- Added support for Factorio 0.18.x
|
- Added support for Factorio 0.18.x
|
||||||
|
|||||||
@@ -1,12 +1,24 @@
|
|||||||
{
|
{
|
||||||
"name": "clusterio_lib",
|
"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)",
|
"title": "Clusterio Library (Alpha)",
|
||||||
"author": "Clusterio Team",
|
"author": "Clusterio Team",
|
||||||
"homepage": "https://github.com/clusterio/factorioClusterio",
|
"homepage": "https://github.com/clusterio/factorioClusterio",
|
||||||
"description": "Library for interfacing with Clusterio. Warning: work in progress alpha.",
|
"description": "Library for interfacing with Clusterio. Warning: work in progress alpha.",
|
||||||
"factorio_version": "0.17",
|
"additional_files": {
|
||||||
"additional_files": [
|
"serialize.lua": ["..", "..", "modules", "clusterio", "serialize.lua"]
|
||||||
["..", "..", "modules", "clusterio", "serialize.lua"]
|
}
|
||||||
]
|
|
||||||
}
|
}
|
||||||
@@ -73,14 +73,6 @@ class InstancePlugin extends libPlugin.BaseInstancePlugin {
|
|||||||
async updateStorageEventHandler(message, event) {
|
async updateStorageEventHandler(message, event) {
|
||||||
let items = message.data.items;
|
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
|
// XXX this should be moved to instance/clusterio api
|
||||||
items.push(["signal-unixtime", Math.floor(Date.now()/1000)]);
|
items.push(["signal-unixtime", Math.floor(Date.now()/1000)]);
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user