From ea645da3cbc4f49d203497fb4554e904f1073b0f Mon Sep 17 00:00:00 2001 From: Hornwitser Date: Mon, 3 May 2021 21:38:05 +0200 Subject: [PATCH 1/6] Fix chalk dependency being in the wrong package --- packages/ctl/package.json | 1 - packages/lib/package.json | 1 + 2 files changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/ctl/package.json b/packages/ctl/package.json index 8a16d3ee..41e6fd59 100644 --- a/packages/ctl/package.json +++ b/packages/ctl/package.json @@ -20,7 +20,6 @@ "dependencies": { "@clusterio/lib": "^2.0.0-alpha.5", "as-table": "^1.0.31", - "chalk": "^3.0.0", "fs-extra": "^8.1.0", "phin": "^3.5.1", "winston": "^3.3.3", diff --git a/packages/lib/package.json b/packages/lib/package.json index 9a939244..3b193537 100644 --- a/packages/lib/package.json +++ b/packages/lib/package.json @@ -12,6 +12,7 @@ }, "dependencies": { "ajv": "^6.12.6", + "chalk": "^4.1.0", "fs-extra": "^8.1.0", "ini": "^1.3.5", "isomorphic-ws": "^4.0.1", From ef0218ddfe886cb6c332f1cd477f0af15fce2b22 Mon Sep 17 00:00:00 2001 From: Hornwitser Date: Fri, 7 May 2021 17:22:13 +0200 Subject: [PATCH 2/6] Move test dependencies to separate package Move the depenedncies needed to run the tests into test/package.json and manage it using lerna. This should make it easier to selectively install only what's needed to run the software. --- lerna.json | 3 ++- package.json | 18 +++--------------- packages/master/package.json | 5 +++-- packages/slave/package.json | 2 +- packages/web_ui/package.json | 3 ++- plugins/global_chat/package.json | 9 +++++++-- plugins/player_auth/package.json | 11 ++++++++--- plugins/research_sync/package.json | 9 +++++++-- plugins/statistics_exporter/package.json | 9 +++++++-- plugins/subspace_storage/package.json | 9 +++++++-- test/package.json | 15 +++++++++++++++ 11 files changed, 62 insertions(+), 31 deletions(-) create mode 100644 test/package.json diff --git a/lerna.json b/lerna.json index fa71e1ce..37e443a1 100644 --- a/lerna.json +++ b/lerna.json @@ -1,7 +1,8 @@ { "packages": [ "packages/*", - "plugins/*" + "plugins/*", + "test" ], "version": "2.0.0-alpha.5" } diff --git a/package.json b/package.json index 091a03b4..ce16a81f 100644 --- a/package.json +++ b/package.json @@ -2,7 +2,7 @@ "name": "root", "private": true, "scripts": { - "test": "mocha --check-leaks -R spec --recursive test plugins/global_chat/test plugins/research_sync/test plugins/statistics_exporter/test plugins/subspace_storage/test plugins/player_auth/test", + "test": "mocha --check-leaks -R spec --exclude \"**/node_modules/**\" --recursive test plugins/global_chat/test plugins/research_sync/test plugins/statistics_exporter/test plugins/subspace_storage/test plugins/player_auth/test", "fast-test": "FAST_TEST=y npm test", "cover": "nyc npm test", "fast-cover": "FAST_TEST=y nyc npm test", @@ -21,22 +21,10 @@ "node": ">=10.16 <11 || >= 12" }, "devDependencies": { - "@clusterio/ctl": "file:./packages/ctl", - "@clusterio/lib": "file:./packages/lib", - "@clusterio/master": "file:packages/master", - "@clusterio/slave": "file:./packages/slave", - "body-parser": "^1.18.2", "eslint": "^7.2.0", - "express": "^4.16.2", - "fs-extra": "^8.1.0", "jsdoc": "^3.6.3", - "jsonwebtoken": "^8.2.1", - "jszip": "^3.2.2", - "lerna": "^3.22.1", + "lerna": "^4.0.0", "mocha": "^6.2.0", - "node-forge": "^0.10.0", - "nyc": "^14.1.1", - "phin": "^3.4.1", - "webpack": "^5.0.0" + "nyc": "^14.1.1" } } diff --git a/packages/master/package.json b/packages/master/package.json index 1e1e57dd..0ceff75e 100644 --- a/packages/master/package.json +++ b/packages/master/package.json @@ -6,7 +6,7 @@ "version": "2.0.0-alpha.5", "main": "master.js", "scripts": { - "build": "webpack-cli --env.production", + "build": "webpack-cli --env production", "test": "echo \"Error: no test specified\" && exit 1" }, "bin": { @@ -40,7 +40,8 @@ "react": "^16.13.1", "react-dom": "^16.13.1", "react-router-dom": "^5.2.0", - "webpack-cli": "^3.3.12", + "webpack": "^5.36.2", + "webpack-cli": "^4.7.0", "webpack-dev-middleware": "^4.1.0", "webpack-merge": "^5.2.0" }, diff --git a/packages/slave/package.json b/packages/slave/package.json index e19303c4..0ec58391 100644 --- a/packages/slave/package.json +++ b/packages/slave/package.json @@ -20,7 +20,7 @@ "dependencies": { "@clusterio/lib": "^2.0.0-alpha.5", "fs-extra": "^8.1.0", - "phin": "^3.4.1", + "phin": "^3.5.1", "pidusage": "^2.0.18", "set-blocking": "^2.0.0", "winston": "^3.3.3", diff --git a/packages/web_ui/package.json b/packages/web_ui/package.json index c9649974..f7ca7056 100644 --- a/packages/web_ui/package.json +++ b/packages/web_ui/package.json @@ -34,7 +34,8 @@ "react-dom": "^16.13.1", "react-router-dom": "^5.2.0", "style-loader": "^2.0.0", - "util": "^0.12.3" + "util": "^0.12.3", + "webpack": "^5.36.2" }, "publishConfig": { "access": "public" diff --git a/plugins/global_chat/package.json b/plugins/global_chat/package.json index 594fec72..cf128391 100644 --- a/plugins/global_chat/package.json +++ b/plugins/global_chat/package.json @@ -7,18 +7,23 @@ "license": "MIT", "repository": "clusterio/factorioClusterio", "scripts": { - "build": "webpack-cli --env.production", + "build": "webpack-cli --env production", "test": "echo \"Error: run tests from root\" && exit 1" }, "bugs": { "url": "https://github.com/clusterio/factorioClusterio/issues" }, + "engines": { + "node": ">=10.16 <11 || >= 12" + }, "peerDependencies": { "@clusterio/lib": "^2.0.0-alpha.0" }, "devDependencies": { + "@clusterio/lib": "^2.0.0-alpha.5", "@clusterio/web_ui": "^2.0.0-alpha.5", - "webpack-cli": "^3.3.12", + "webpack": "^5.36.2", + "webpack-cli": "^4.7.0", "webpack-merge": "^5.2.0" }, "publishConfig": { diff --git a/plugins/player_auth/package.json b/plugins/player_auth/package.json index a83f8041..8d7a141e 100644 --- a/plugins/player_auth/package.json +++ b/plugins/player_auth/package.json @@ -7,12 +7,15 @@ "license": "MIT", "repository": "clusterio/factorioClusterio", "scripts": { - "build": "webpack-cli --env.production", + "build": "webpack-cli --env production", "test": "echo \"Error: run tests from root\" && exit 1" }, "bugs": { "url": "https://github.com/clusterio/factorioClusterio/issues" }, + "engines": { + "node": ">=10.16 <11 || >= 12" + }, "peerDependencies": { "@clusterio/lib": "^2.0.0-alpha.0" }, @@ -20,12 +23,14 @@ "jsonwebtoken": "^8.2.1" }, "devDependencies": { + "@clusterio/lib": "^2.0.0-alpha.5", "@clusterio/web_ui": "^2.0.0-alpha.5", "antd": "^4.6.5", - "phin": "^3.4.1", + "phin": "^3.5.1", "react": "^16.13.1", "react-dom": "^16.13.1", - "webpack-cli": "^3.3.12", + "webpack": "^5.36.2", + "webpack-cli": "^4.7.0", "webpack-merge": "^5.2.0" }, "publishConfig": { diff --git a/plugins/research_sync/package.json b/plugins/research_sync/package.json index a672a29a..fbc21d5f 100644 --- a/plugins/research_sync/package.json +++ b/plugins/research_sync/package.json @@ -7,12 +7,15 @@ "license": "MIT", "repository": "clusterio/factorioClusterio", "scripts": { - "build": "webpack-cli --env.production", + "build": "webpack-cli --env production", "test": "echo \"Error: run tests from root\" && exit 1" }, "bugs": { "url": "https://github.com/clusterio/factorioClusterio/issues" }, + "engines": { + "node": ">=10.16 <11 || >= 12" + }, "peerDependencies": { "@clusterio/lib": "^2.0.0-alpha.0" }, @@ -20,8 +23,10 @@ "fs-extra": "^8.1.0" }, "devDependencies": { + "@clusterio/lib": "^2.0.0-alpha.5", "@clusterio/web_ui": "^2.0.0-alpha.5", - "webpack-cli": "^3.3.12", + "webpack": "^5.36.2", + "webpack-cli": "^4.7.0", "webpack-merge": "^5.2.0" }, "publishConfig": { diff --git a/plugins/statistics_exporter/package.json b/plugins/statistics_exporter/package.json index b74fdb36..24b8865a 100644 --- a/plugins/statistics_exporter/package.json +++ b/plugins/statistics_exporter/package.json @@ -7,18 +7,23 @@ "license": "MIT", "repository": "clusterio/factorioClusterio", "scripts": { - "build": "webpack-cli --env.production", + "build": "webpack-cli --env production", "test": "echo \"Error: run tests from root\" && exit 1" }, "bugs": { "url": "https://github.com/clusterio/factorioClusterio/issues" }, + "engines": { + "node": ">=10.16 <11 || >= 12" + }, "peerDependencies": { "@clusterio/lib": "^2.0.0-alpha.0" }, "devDependencies": { + "@clusterio/lib": "^2.0.0-alpha.5", "@clusterio/web_ui": "^2.0.0-alpha.5", - "webpack-cli": "^3.3.12", + "webpack": "^5.36.2", + "webpack-cli": "^4.7.0", "webpack-merge": "^5.2.0" }, "publishConfig": { diff --git a/plugins/subspace_storage/package.json b/plugins/subspace_storage/package.json index f19c62c4..a29c638c 100644 --- a/plugins/subspace_storage/package.json +++ b/plugins/subspace_storage/package.json @@ -7,12 +7,15 @@ "license": "MIT", "repository": "clusterio/factorioClusterio", "scripts": { - "build": "webpack-cli --env.production", + "build": "webpack-cli --env production", "test": "echo \"Error: run tests from root\" && exit 1" }, "bugs": { "url": "https://github.com/clusterio/factorioClusterio/issues" }, + "engines": { + "node": ">=10.16 <11 || >= 12" + }, "peerDependencies": { "@clusterio/lib": "^2.0.0-alpha.0" }, @@ -20,11 +23,13 @@ "fs-extra": "^8.1.0" }, "devDependencies": { + "@clusterio/lib": "^2.0.0-alpha.5", "@clusterio/web_ui": "^2.0.0-alpha.5", "antd": "^4.6.5", "react": "^16.13.1", "react-dom": "^16.13.1", - "webpack-cli": "^3.3.12", + "webpack": "^5.36.2", + "webpack-cli": "^4.7.0", "webpack-merge": "^5.2.0" }, "publishConfig": { diff --git a/test/package.json b/test/package.json new file mode 100644 index 00000000..b1e3fc98 --- /dev/null +++ b/test/package.json @@ -0,0 +1,15 @@ +{ + "name": "test", + "private": true, + "engines": { + "node": ">=10.16 <11 || >= 12" + }, + "dependencies": { + "@clusterio/ctl": "2.0.0-alpha.5", + "@clusterio/lib": "2.0.0-alpha.5", + "@clusterio/master": "2.0.0-alpha.5", + "@clusterio/slave": "2.0.0-alpha.5", + "node-forge": "^0.10.0", + "phin": "^3.5.1" + } +} From c2e7a02e5acfae1ce683bee8f326ea005934ccf1 Mon Sep 17 00:00:00 2001 From: Hornwitser Date: Fri, 7 May 2021 14:56:01 +0200 Subject: [PATCH 3/6] Use --hoist Save time installing dependencies by recommending the usage of --hoist. --- .travis.yml | 2 +- docs/contributing.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index 9ffbf028..9b4eac86 100644 --- a/.travis.yml +++ b/.travis.yml @@ -6,7 +6,7 @@ before_install: - tar -xf factorio.tar.gz - npm install -g codecov script: - - npx lerna bootstrap --no-ci + - npx lerna bootstrap --hoist --no-ci - 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 diff --git a/docs/contributing.md b/docs/contributing.md index 7b6067dd..7b9677f5 100644 --- a/docs/contributing.md +++ b/docs/contributing.md @@ -53,7 +53,7 @@ The project is organized into several packages that are all managed through Lern In order to get the development environment up and running you will need to run the following commands: npm install - npx lerna bootstrap + npx lerna bootstrap --hoist This installs dependencies needed by tests and links the packages up so they work from the git work tree. From a6ce755743fdd474f7280ffc0437fa153d6e31eb Mon Sep 17 00:00:00 2001 From: Hornwitser Date: Fri, 7 May 2021 18:04:13 +0200 Subject: [PATCH 4/6] Update development tools --- package.json | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/package.json b/package.json index ce16a81f..09e875ae 100644 --- a/package.json +++ b/package.json @@ -21,10 +21,10 @@ "node": ">=10.16 <11 || >= 12" }, "devDependencies": { - "eslint": "^7.2.0", - "jsdoc": "^3.6.3", + "eslint": "^7.25.0", + "jsdoc": "^3.6.6", "lerna": "^4.0.0", - "mocha": "^6.2.0", - "nyc": "^14.1.1" + "mocha": "^8.4.0", + "nyc": "^15.1.0" } } From 65c6fd592c75c3cd64e4f7a09e1b98cb1796be43 Mon Sep 17 00:00:00 2001 From: Hornwitser Date: Fri, 7 May 2021 18:31:24 +0200 Subject: [PATCH 5/6] Log stderr instead of writing to test log During Travis integration tests a BrokenPipeError is emitted on stderr after the Factorio server has quit. I have no idea what's going on here so for now just log it and ignore it. --- test/integration/server.js | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/test/integration/server.js b/test/integration/server.js index e2796ea8..5d375e38 100644 --- a/test/integration/server.js +++ b/test/integration/server.js @@ -6,6 +6,7 @@ const path = require("path"); const libFactorio = require("@clusterio/lib/factorio"); const libErrors = require("@clusterio/lib/errors"); +const { logger } = require("@clusterio/lib/logging"); const { slowTest } = require("./index"); @@ -34,6 +35,15 @@ describe("Integration of lib/factorio/server", function() { await fs.ensureDir(writePath); logFile = fs.createWriteStream(path.join(writePath, "log.txt"), "utf8"); server.on("output", function(output) { + if (output.source === "stderr") { + // Factorio doesn't print on stderr but sometimes on + // Travis a BrokenPipeError is printed on stderr after + // the server has closed for mysterious reasons. + // I have no idea what causes it, but it causes a write + // after end error if not handled. + logger.error(`Factorio stderr: ${JSON.stringify(output)}`); + return; + } logFile.write(`${JSON.stringify(output)}\n`); }); From 0a469a0524a12d49c1948323c23604924ba5d89d Mon Sep 17 00:00:00 2001 From: Hornwitser Date: Wed, 12 May 2021 19:57:19 +0200 Subject: [PATCH 6/6] Add missing test dependencies The usage of lerna bootstrap --hoist meant these dependencies being missing went unnoticed. --- test/package.json | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/test/package.json b/test/package.json index b1e3fc98..74e3207b 100644 --- a/test/package.json +++ b/test/package.json @@ -9,6 +9,11 @@ "@clusterio/lib": "2.0.0-alpha.5", "@clusterio/master": "2.0.0-alpha.5", "@clusterio/slave": "2.0.0-alpha.5", + "body-parser": "^1.18.2", + "express": "^4.16.2", + "fs-extra": "^8.1.0", + "jsonwebtoken": "^8.2.1", + "jszip": "^3.2.2", "node-forge": "^0.10.0", "phin": "^3.5.1" }