Split up into multiple packages with Lerna

Split up codebase into the packages @clsterio/lib, @clusterio/master,
@clusterio/slave, and @clusterio/ctl using lerna to manage them.  This
will allow deployment to use only the parts needed reducing install
size, and better separate the code into shared library, master, slave
and control.
This commit is contained in:
Hornwitser committed 2020-09-21 18:00:07 +02:00
1 parent 198d5c344b
commit bf5a4a8a9c
133 files changed
+367 -259

No files matched your search

+2 -2
View File
@@ -5,7 +5,7 @@ const path = require("path");
const validateHTML = require("html5-validator");
const parallel = require("mocha.parallel");
const link = require("lib/link");
const link = require("@clusterio/lib/link");
const { slowTest, get, execCtl, sendRcon, getControl, instancesDir } = require("./index");
@@ -18,7 +18,7 @@ describe("Integration of Clusterio", function() {
for (let path of paths) {
it(`sends some HTML when accessing ${path}`, async function() {
let res = await get(path);
let validation = await validateHTML(res.body);
let validation = await validateHTML(res.body.toString());
let filtered = validation.messages.filter(msg => msg.type !== "info");
assert(
filtered.length === 0,
+1 -1
View File
@@ -2,7 +2,7 @@
const assert = require("assert").strict;
const path = require("path");
const factorio = require("lib/factorio");
const factorio = require("@clusterio/lib/factorio");
describe("Integration of lib/factorio/export", function() {
+23 -19
View File
@@ -3,12 +3,12 @@ const path = require("path");
const fs = require("fs-extra");
const child_process = require("child_process");
const jwt = require("jsonwebtoken");
const needle = require("needle");
const phin = require("phin");
const util = require("util");
const events = require("events");
const link = require("lib/link");
const server = require("lib/factorio/server");
const link = require("@clusterio/lib/link");
const server = require("@clusterio/lib/factorio/server");
class TestControl extends link.Link {
@@ -45,7 +45,11 @@ function slowTest(test) {
}
async function get(path) {
let res = await needle("get", `https://localhost:4443${path}`, { rejectUnauthorized: false });
let res = await phin({
method: "GET",
url: `https://localhost:4443${path}`,
core: { rejectUnauthorized: false },
});
if (res.statusCode != 200) {
throw new Error(`Got response code ${res.statusCode}, content: ${res.body}`);
}
@@ -70,7 +74,7 @@ async function exec(...args) {
}
async function execCtl(...args) {
args[0] = `node clusterctl --config ${controlConfigPath} ${args[0]}`;
args[0] = `node packages/ctl --config ${controlConfigPath} ${args[0]}`;
return await exec(...args);
}
@@ -113,26 +117,26 @@ before(async function() {
await fs.remove(slaveConfigPath);
await fs.remove(controlConfigPath);
await exec(`node master --config ${masterConfigPath} config set master.database_directory ${databaseDir}`);
await exec(`node master --config ${masterConfigPath} config set master.auth_secret TestSecretDoNotUse`);
await exec(`node master --config ${masterConfigPath} config set master.http_port 8880`);
await exec(`node master --config ${masterConfigPath} config set master.https_port 4443`);
await exec(`node master --config ${masterConfigPath} config set master.tls_certificate ${path.join(databaseDir, "cert.crt")}`);
await exec(`node master --config ${masterConfigPath} config set master.tls_private_key ${path.join(databaseDir, "cert.key")}`);
await exec(`node master --config ${masterConfigPath} config set master.tls_bits 1024`);
await exec(`node master --config ${masterConfigPath} config set master.heartbeat_interval 0.25`);
await exec(`node master --config ${masterConfigPath} config set master.connector_shutdown_timeout 2`);
await exec(`node packages/master --config ${masterConfigPath} config set master.database_directory ${databaseDir}`);
await exec(`node packages/master --config ${masterConfigPath} config set master.auth_secret TestSecretDoNotUse`);
await exec(`node packages/master --config ${masterConfigPath} config set master.http_port 8880`);
await exec(`node packages/master --config ${masterConfigPath} config set master.https_port 4443`);
await exec(`node packages/master --config ${masterConfigPath} config set master.tls_certificate ${path.join(databaseDir, "cert.crt")}`);
await exec(`node packages/master --config ${masterConfigPath} config set master.tls_private_key ${path.join(databaseDir, "cert.key")}`);
await exec(`node packages/master --config ${masterConfigPath} config set master.tls_bits 1024`);
await exec(`node packages/master --config ${masterConfigPath} config set master.heartbeat_interval 0.25`);
await exec(`node packages/master --config ${masterConfigPath} config set master.connector_shutdown_timeout 2`);
await exec(`node master --config ${masterConfigPath} bootstrap create-admin test`);
await exec(`node master --config ${masterConfigPath} bootstrap create-ctl-config test --output ${controlConfigPath}`);
await exec(`node packages/master --config ${masterConfigPath} bootstrap create-admin test`);
await exec(`node packages/master --config ${masterConfigPath} bootstrap create-ctl-config test --output ${controlConfigPath}`);
masterProcess = await spawn("master:", `node master --config ${masterConfigPath} run`, "All plugins loaded");
masterProcess = await spawn("master:", `node packages/master --config ${masterConfigPath} run`, "All plugins loaded");
let createArgs = `--id 4 --name slave --generate-token --output ${slaveConfigPath}`;
await execCtl(`slave create-config ${createArgs}`);
await exec(`node slave --config ${slaveConfigPath} config set slave.instances_directory ${instancesDir}`);
await exec(`node packages/slave --config ${slaveConfigPath} config set slave.instances_directory ${instancesDir}`);
slaveProcess = await spawn("slave:", `node slave --config ${slaveConfigPath} run`, "SOCKET | received ready from master");
slaveProcess = await spawn("slave:", `node packages/slave --config ${slaveConfigPath} run`, "SOCKET | received ready from master");
let controlConnector = new TestControlConnector(url, 2);
controlConnector.token = controlToken;
+1 -1
View File
@@ -4,7 +4,7 @@ const fs = require("fs-extra");
const jszip = require("jszip");
const path = require("path");
const factorio = require("lib/factorio");
const factorio = require("@clusterio/lib/factorio");
const { slowTest } = require("./index");
+2 -2
View File
@@ -4,8 +4,8 @@ const events = require("events");
const fs = require("fs-extra");
const path = require("path");
const factorio = require("lib/factorio");
const errors = require("lib/errors");
const factorio = require("@clusterio/lib/factorio");
const errors = require("@clusterio/lib/errors");
const { slowTest } = require("./index");