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

+1
View File
@@ -0,0 +1 @@
packages/master/static
+2 -2
View File
@@ -28,7 +28,7 @@ dist/
# Autogenerated docs output
/docs/api
node_modules/*
node_modules
Factorio*
/factorio
@@ -41,7 +41,7 @@ Factorio*
package-lock.json
mod_cache.json
static/export
static/external
packages/master/static/external
saves
/temp/
+2 -1
View File
@@ -6,7 +6,8 @@ before_install:
- tar -xf factorio.tar.gz
- npm install -g codecov
script:
- node build-mod --bump-patch --factorio-version 0.18 --output-dir sharedMods
- npx lerna bootstrap
- node packages/lib/build_mod --bump-patch --factorio-version 0.18 --output-dir sharedMods
- curl -o sharedMods/subspace_storage_1.99.1.zip -L https://github.com/clusterio/factorioClusterioMod/releases/download/1.99.1/subspace_storage_1.99.1.zip
- npm run-script ci-cover
- cat temp/test/integration/log.txt
+21 -35
View File
@@ -105,12 +105,13 @@ supported on EOL Ubuntu releases so make sure you're on a recent release of Ubun
Master and all slaves:
wget -qO - https://deb.nodesource.com/setup_12.x | sudo -E bash -
sudo apt install -y nodejs python-dev git build-essential
git clone -b master https://github.com/clusterio/factorioClusterio.git
cd factorioClusterio
sudo apt install -y nodejs
mkdir clusterio
cd clusterio
npm init -y
npm install @clusterio/master @clusterio/slave @clusterio/ctl
wget -O factorio.tar.gz https://www.factorio.com/get-download/latest/headless/linux64
tar -xf factorio.tar.gz
npm install --only=production
downloads and installs nodejs, git and clusterio. To specify a version, change "latest" in the link to a version number like 0.14.21.
@@ -136,30 +137,19 @@ The -v flag is used to specify the instance directory. Your instances (save file
**Warning**: These instructions are for the unstable master version and is not
recommended for use, see [the 1.2.x branch][1.2.x] for how to install the stable version.
Clusterio is built up of multiple parts. Here is a quick guide:
Master = master.js
Server host (Slave) = slave.js + factorio server
Game Client = The people connecting to the server
**Requirements**
download and install nodeJS 12 from http://nodejs.org. Clusterio runs on Node.js v12 and
up, v11.13.0+ and v10.16.0+.
download and install git from https://git-scm.com/
reboot when you are done, then proceed to the next steps. *reboots matter*
**Master**
1. Open PowerShell or Command prompt in the directory you want to install to and run the following commands.
git clone -b master https://github.com/clusterio/factorioClusterio
cd factorioClusterio
npm install --only=production
mkdir clusterio
cd clusterio
npm init -y
npm install @clusterio/master @clusterio/slave @clusterio/ctl
2. Obtain Factorio by either of these two methods:
@@ -198,8 +188,8 @@ Before you can manage the cluster you need to bootstrap an admin account
for it. Replace `<username>` with your Factorio username (do not make
up a new username here).
node master bootstrap create-admin <username>
node master bootstrap create-ctl-config <username>
npx clusteriomaster bootstrap create-admin <username>
npx clusteriomaster bootstrap create-ctl-config <username>
The first command creates a user account with the given name and
promotes it to a cluster admin. The second one sets up a
@@ -213,7 +203,7 @@ It's necessary to run the master server in order for anything to work.
Once you've completed the setup run the following command to start it
up:
node master run
npx clusteriomaster run
### Slaves
@@ -223,7 +213,7 @@ master server. In order for slaves to connect to the master server they
need a valid authentication token, you can create a slave config with
a valid token with the following command.
node clusterctl slave create-config --name Local --generate-token
npx clusterctl slave create-config --name Local --generate-token
This will write a new `config-slave.json` file in the current directory
(you can change the location with the `--output` option) with the name,
@@ -232,13 +222,13 @@ the config for a remote slave you will need to have set the
`master.external_address` option to the URL the master server can be
reached on.
You can list the config of a slave on the slave itself with the `node
slave config list` command. Use `node slave config --help` for more
information.
You can list the config of a slave on the slave itself with the `npx
clusterioslave config list` command. Use `npx clusterioslave config
--help` for more information.
Once the config is set up run the slave with
node slave run
npx clusterioslave run
### Instances
@@ -253,9 +243,9 @@ clusterctl control-config set` command:
The basic operations to start a new instance is the following
node clusterctl instance create "My instance"
node clusterctl instance assign "My instance" "Local"
node clusterctl instance start "My instance"
npx clusterctl instance create "My instance"
npx clusterctl instance assign "My instance" "Local"
npx clusterctl instance start "My instance"
The first line creates the instance configuration on the master server.
The second assigns the instance to a slave which creates the instance
@@ -264,7 +254,7 @@ third line starts the instance, which creates a new save if there are no
save games present.
There are many more commands available with clusterctl. See
`node clusterctl --help` for a full list of them.
`npx clusterctl --help` for a full list of them.
## Plugins
@@ -298,7 +288,3 @@ TLDR: the tested fix is:
- select TCP and select specific local ports and type in the ports that you want to open (comma separated) and click next > 3 times
- give the rule a name (like 'web server' or something), give it a description (optionally) and click finish
### Other fixes for other potential problems:
Sometimes the install fails. Try `node ./lib/npmPostinstall` to complete it.
+4 -3
View File
@@ -49,9 +49,10 @@ Message
There's two types of messages currently implemented apart from the
Link builtin close message and that's Request and Event. The builtin
messages are defined in [lib/link/messages.js](../lib/link/messages.js)
and are attached to links via the attachAllMessages function, which is
usally called in the Link subclass constructor.
messages are defined in
[lib/link/messages.js](/package/lib/link/messages.js) and are attached
to links via the attachAllMessages function, which is usally called in
the Link subclass constructor.
The messages define which links they are valid on and only attaches
handlers for those links. There's also a forwarding mechanism for when
+2 -2
View File
@@ -13,8 +13,8 @@ the startup, and the groups and their fields for disabled plugins will
still be created.
The built-in config groups and their fields are defined in
[/lib/config/definitions.js](lib/config/definitions.js) while plugins
can add their own config groups to the `MasterConfigGroup` and
[lib/config/definitions.js](/packages/lib/config/definitions.js) while
plugins can add their own config groups to the `MasterConfigGroup` and
`InstanceConfigGroup` properties of the `info.js` export using
subclasses of `PluginConfigGroup`. The plugin group has the enabled
field pre-defined on it, and it's used to enable/disable plugins.
+14
View File
@@ -11,6 +11,7 @@ Contents
- [Workflow](#workflow)
- [Starting a Feature Branch](#starting-a-feature-branch)
- [Setting up the Development Environment](#setting-up-the-development-environment)
- [Checking your code for errors](#checking-your-code-for-errors)
- [Submitting a Pull Request](#submitting-a-pull-request)
- [Editing your Feature Branch](#editing-your-feature-branch)
@@ -56,6 +57,19 @@ from the main repository. Do not run `git pull upstream` it will mess
thing up!
### Setting up the Development Environment
The project is organized into several packages that are all managed
through Lerna. In order to get the development environment up and
running you will need to run the following commands:
npm install
npx lerna bootstrap
This installs dependencies needed by tests and links the packages up so
they work from the git work tree.
### Starting a Feature Branch
Development is done exclusively in feature branches. This means the
+6 -6
View File
@@ -11,12 +11,12 @@
},
"source": {
"include": [
"master.js",
"slave.js",
"clusterctl.js",
"lib/",
"plugins/",
"routes.js"
"packages/master/src/",
"packages/master/master.js",
"packages/slave/slave.js",
"packages/ctl/clusterctl.js",
"packages/lib/",
"plugins/"
],
"excludePattern": "node_modules"
}
+5 -5
View File
@@ -3,16 +3,16 @@ Managing a Cluster
Clusterio clusers are managed through the master server by using the
`clusterctl` command line interface which is invoked by running
`node clusterctl <command>` in the clusterio directory. This document
uses the shorthand `ctl> foo` to indicate `node clusterctl foo` should
`npx clusterctl <command>` in the clusterio directory. This document
uses the shorthand `ctl> foo` to indicate `npx clusterctl foo` should
be executed. Mandatory parameters are shown in `<angles bracket>` and
optional pameters are in `[square brackets]`.
Before `clusterctl` can be used it needs to be configured for the
cluster it will connect to. The easiest way to do this is to run
`node master bootstrap create-ctl-config <username>` on the master
server, which creates the necessary `config-control.json` for managing
the cluster as the given user.
`npx clusteriomaster bootstrap create-ctl-config <username>` on the
master server, which creates the necessary `config-control.json` for
managing the cluster as the given user.
Slaves
+4 -4
View File
@@ -230,8 +230,8 @@ there's [Requests](#requests). By convention message types ending in
`*_event` are events. The data payload of an event consists solely of
event specific properties.
See [lib/link/messages.js](/lib/link/messages.js) for the recognized
events and their contents.
See [lib/link/messages.js](/packages/lib/link/messages.js) for the
recognized events and their contents.
Requests
@@ -245,8 +245,8 @@ replied to with a corresponding `*_response` message. If an error
occured while processing the request an error response containing an
error property in the data payload is sent instead.
See [lib/link/messages.js](/lib/link/messages.js) for the recognized
requests and their contents.
See [lib/link/messages.js](/packages/lib/link/messages.js) for the
recognized requests and their contents.
### `*_response`
+8 -8
View File
@@ -42,7 +42,7 @@ The basic file structure of a plugin is the following.
The most important file is the `info.js` file. Without it the plugin
will not recognized by Clusterio. Here's an example of it:
const link = require('lib/link'); // For messages
const link = require('@clusterio/lib/link'); // For messages
module.exports = {
name: "foo_frobber",
@@ -129,7 +129,7 @@ The plugin class should derive from its respective base class defined in
`lib/plugin`. For example, to define a MasterPlugin class the following
code can be used:
const plugin = require('lib/plugin');
const plugin = require('@clusterio/lib/plugin');
class MasterPlugin extends plugin.BaseMasterPlugin {
async init() {
@@ -147,7 +147,7 @@ code can be used:
For the instance plugin it's exactly the same except "Master" is
replaced with "Instance", and for the clusterctl plugin "Control" is
used. The available hooks that you can override are documented in the
base class [in lib/plugin.js](../lib/plugin.js).
base class [in lib/plugin.js](/packages/lib/plugin.js).
It's best to avoid defining a constructor, but if you insist on defining
one, forward all arguments to the base class. E.g.:
@@ -173,7 +173,7 @@ take advantage of it by subclassing `PluginConfigGroup`, setting the
and passing it as either `MasterConfigGroup` or `InstanceConfigGroup` in
the `info.js` export. For example in info.js:
const config = require("lib/config");
const config = require("@clusterio/lib/config");
class MasterConfigGroup extends config.PluginConfigGroup { }
MasterConfigGroup.groupName = "foo_frobber";
@@ -550,7 +550,7 @@ from plugins optionally loaded at runtime on different computers.
In its simplest form collecting data from plugins consists of defining
the metric and updating it somewhere in the plugin code. For example:
const { Counter } = require('lib/prometheus');
const { Counter } = require('@clusterio/lib/prometheus');
const fooMetric = new Counter(
'clusterio_foo_frobber_foo_metric', "Measures the level of foo",
@@ -567,7 +567,7 @@ naming scheme.
For metrics that are per-instance, you must define an `instance_id` label and
set it accordingly, for example:
const { Counter } = require('lib/prometheus');
const { Counter } = require('@clusterio/lib/prometheus');
const barMetric = new Gauge(
'clusterio_foo_frobber_bar_metric', "Bar instance level",
@@ -598,7 +598,7 @@ The control entrypoint for plugins allows you to extend clustectl with
your own commands. The creation of custom commands typically starts
with defining a command tree for the plugin:
const { Command, CommandTree } = require("lib/command");
const { Command, CommandTree } = require("@clusterio/lib/command");
const fooFrobberCommands = new CommandTree({
name: "foo-frobber", description: "Foo Frobber Plugin commands"
});
@@ -641,7 +641,7 @@ for how to define the messages that can be sent to the master.
To have the command tree become part of clusterctl it needs to be added
to the rootCommand tree in `addCommands` callback of the Control plugin:
const plugin = require("lib/plugin");
const plugin = require("@clusterio/lib/plugin");
class ControlPlugin extends plugin.BaseControlPlugin {
async addCommands(rootCommand) {
+6
View File
@@ -0,0 +1,6 @@
{
"packages": [
"packages/*"
],
"version": "2.0.0-alpha0"
}
-5
View File
@@ -1,5 +0,0 @@
{
"name": "lib",
"description": "Internal library for factorioClusterio"
}
+13 -42
View File
@@ -1,18 +1,14 @@
{
"name": "clusterio",
"version": "2.0.0-alpha",
"description": "Interserver communication for factorio",
"repository": "https://github.com/clusterio/factorioClusterio",
"main": "master.js",
"name": "root",
"private": true,
"scripts": {
"test": "mocha --exit --check-leaks -R spec --recursive test plugins/*/test",
"fast-test": "FAST_TEST=y npm test",
"cover": "nyc npm test",
"fast-cover": "FAST_TEST=y nyc npm test",
"ci-cover": "nyc --reporter=lcovonly npm run-script test",
"lint": "eslint \"*.js\" lib plugins test",
"lint": "eslint \"*.js\" packages plugins test",
"docs": "jsdoc --configure docs/jsdoc.json",
"install": "node lib/npmPostinstall",
"bundle-dependencies": "bundle-dependencies"
},
"nyc": {
@@ -21,49 +17,24 @@
"plugins/*/test/**"
]
},
"keywords": [
"factorio"
],
"author": "Danielv123",
"license": "MIT",
"engines": {
"node": ">=10.16 <11 || >= 11.13"
},
"dependencies": {
"as-table": "^1.0.31",
"body-parser": "^1.18.2",
"chalk": "^3.0.0",
"compression": "^1.7.2",
"cookie-parser": "^1.4.3",
"ejs": "^2.5.7",
"express": "^4.16.2",
"express-fileupload": "1.2.0",
"fs-extra": "^8.1.0",
"ini": "^1.3.5",
"jimp": "^0.12.1",
"jsonwebtoken": "^8.2.1",
"jszip": "^3.2.2",
"lib": "file:./lib",
"moment": "^2.22.2",
"needle": "^2.4.0",
"node-factorio-api": "^0.3.8",
"node-forge": "^0.10.0",
"phin": "^3.4.1",
"pidusage": "^2.0.18",
"rcon-client": "^4.2.0",
"request": "^2.83.0",
"semver": "^7.1.1",
"set-blocking": "^2.0.0",
"ws": "^7.2.3",
"yargs": "^14.2.0"
},
"devDependencies": {
"@clusterio/ctl": "file:./packages/ctl",
"@clusterio/lib": "file:./packages/lib",
"@clusterio/master": "file:packages/master",
"@clusterio/slave": "file:./packages/slave",
"eslint": "^7.2.0",
"fs-extra": "^8.1.0",
"html5-validator": "^1.2.1",
"jsdoc": "^3.6.3",
"klaw": "^3.0.0",
"jsonwebtoken": "^8.2.1",
"jszip": "^3.2.2",
"lerna": "^3.22.1",
"mocha": "^6.2.0",
"mocha.parallel": "^0.15.5",
"nyc": "^14.1.1"
"nyc": "^14.1.1",
"phin": "^3.4.1"
}
}
+11 -7
View File
@@ -1,21 +1,23 @@
#!/usr/bin/env node
/**
* Command line interface for controlling a Clusterio cluster
* @module
*/
"use strict";
const jwt = require("jsonwebtoken");
const fs = require("fs-extra");
const yargs = require("yargs");
const version = require("./package").version;
const asTable = require("as-table").configure({ delimiter: " | " });
const chalk = require("chalk");
const events = require("events");
const path = require("path");
const link = require("lib/link");
const errors = require("lib/errors");
const config = require("lib/config");
const plugin = require("lib/plugin");
const command = require("lib/command");
const link = require("@clusterio/lib/link");
const errors = require("@clusterio/lib/errors");
const config = require("@clusterio/lib/config");
const plugin = require("@clusterio/lib/plugin");
const command = require("@clusterio/lib/command");
/**
@@ -608,7 +610,9 @@ async function startControl() {
continue;
}
let { ControlPlugin } = require(`./plugins/${pluginInfo.name}/${pluginInfo.controlEntrypoint}`);
// XXX Does not work on Windows
let pluginPath = path.relative(__dirname, path.join("plugins", pluginInfo.name));
let { ControlPlugin } = require(path.join(pluginPath, pluginInfo.controlEntrypoint));
let controlPlugin = new ControlPlugin(pluginInfo);
controlPlugins.set(pluginInfo.name, controlPlugin);
await controlPlugin.init();
+27
View File
@@ -0,0 +1,27 @@
{
"name": "@clusterio/ctl",
"description": "Clusterio command line management tool",
"author": "Hornwitser",
"license": "MIT",
"version": "2.0.0-alpha0",
"main": "clusterctl.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"bin": {
"clusterctl": "./clusterctl.js"
},
"keywords": [
"factorio"
],
"engines": {
"node": ">=10.16 <11 || >= 11.13"
},
"dependencies": {
"@clusterio/lib": "=2.0.0-alpha0",
"as-table": "^1.0.31",
"chalk": "^3.0.0",
"fs-extra": "^8.1.0",
"yargs": "^14.2.0"
}
}
File renamed without changes.
+2 -2
View File
@@ -7,8 +7,8 @@
* @module
*/
"use strict";
const link = require("lib/link");
const errors = require("lib/errors");
const link = require("@clusterio/lib/link");
const errors = require("@clusterio/lib/errors");
/**
* Represents a command that can be runned by clusterctl
@@ -4,7 +4,7 @@
const events = require("events");
const util = require("util");
const { basicType } = require("lib/helpers");
const { basicType } = require("@clusterio/lib/helpers");
/**
File renamed without changes.
File renamed without changes.
+1 -1
View File
@@ -8,7 +8,7 @@
"use strict";
const fs = require("fs-extra");
const { basicType } = require("lib/helpers");
const { basicType } = require("@clusterio/lib/helpers");
/**
File renamed without changes.
@@ -6,7 +6,7 @@ const ini = require("ini");
const Jimp = require("jimp");
const JSZip = require("jszip");
const buildMod = require("../../build-mod");
const buildMod = require("@clusterio/lib/build_mod");
/**
* Generate the export mod needed for exportData
@@ -5,7 +5,7 @@
*/
"use strict";
module.exports = {
...require("lib/factorio/export"),
...require("lib/factorio/patch"),
...require("lib/factorio/server"),
...require("./export"),
...require("./patch"),
...require("./server"),
};
@@ -7,7 +7,7 @@ const jszip = require("jszip");
const path = require("path");
const semver = require("semver");
const hash = require("lib/hash");
const hash = require("@clusterio/lib/hash");
const knownScenarios = {
@@ -9,7 +9,7 @@ const crypto = require("crypto");
const ini = require("ini");
const rconClient = require("rcon-client");
const errors = require("lib/errors");
const errors = require("@clusterio/lib/errors");
/**
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
@@ -3,8 +3,8 @@
const events = require("events");
const WebSocket = require("ws");
const schema = require("lib/schema");
const errors = require("lib/errors");
const schema = require("@clusterio/lib/schema");
const errors = require("@clusterio/lib/errors");
/**
@@ -5,7 +5,7 @@
*/
"use strict";
module.exports = {
...require("lib/link/link"),
...require("lib/link/messages"),
...require("lib/link/connectors"),
...require("./link"),
...require("./messages"),
...require("./connectors"),
};
@@ -1,9 +1,9 @@
// Implementation of Link class
"use strict";
const schema = require("lib/schema");
const errors = require("lib/errors");
const messages = require("lib/link/messages");
const schema = require("@clusterio/lib/schema");
const errors = require("@clusterio/lib/errors");
const messages = require("./messages");
// Some definitions for the terminology used here:
// link: Either side of a master - client connection
@@ -1,7 +1,7 @@
// Message definitions for links
"use strict";
const schema = require("lib/schema");
const errors = require("lib/errors");
const schema = require("@clusterio/lib/schema");
const errors = require("@clusterio/lib/errors");
/**
* Represents a message that can be sent over the link
File renamed without changes.
File renamed without changes.
+26
View File
@@ -0,0 +1,26 @@
{
"name": "@clusterio/lib",
"description": "Shared library for Clusterio",
"version": "2.0.0-alpha0",
"repository": "https://github.com/clusterio/factorioClusterio",
"license": "MIT",
"keywords": [
"factorio"
],
"engines": {
"node": ">=10.16 <11 || >= 11.13"
},
"dependencies": {
"fs-extra": "^8.1.0",
"ini": "^1.3.5",
"jimp": "^0.12.1",
"jsonwebtoken": "^8.2.1",
"jszip": "^3.2.2",
"klaw": "^3.0.0",
"node-forge": "^0.10.0",
"rcon-client": "^4.2.0",
"semver": "^7.1.1",
"ws": "^7.2.3",
"yargs": "^14.2.0"
}
}
+4 -2
View File
@@ -6,7 +6,7 @@
const fs = require("fs-extra");
const path = require("path");
const errors = require("lib/errors");
const errors = require("@clusterio/lib/errors");
/**
@@ -392,7 +392,9 @@ async function loadPluginInfos(baseDir) {
try {
// Note: Require path is relative to this module
pluginInfo = require(path.posix.join("..", baseDir, pluginDir, "info"));
// XXX Does not work on Windows
let pluginPath = path.relative(__dirname, path.join(baseDir, pluginDir));
pluginInfo = require(path.join(pluginPath, "info"));
} catch (err) {
if (err.code === "MODULE_NOT_FOUND") {
File renamed without changes.
File renamed without changes.
File renamed without changes.
+18 -13
View File
@@ -1,3 +1,5 @@
#!/usr/bin/env node
/**
* Clusterio master server
*
@@ -9,7 +11,7 @@
* @module
* @author Danielv123, Hornwitser
* @example
* node master run
* npx clusteriomaster run
*/
// Attempt updating
@@ -38,15 +40,15 @@ let debugEvents = new events.EventEmitter();
let pluginList = {};
// homebrew modules
const generateSSLcert = require("lib/generateSSLcert");
const database = require("lib/database");
const schema = require("lib/schema");
const link = require("lib/link");
const errors = require("lib/errors");
const plugin = require("lib/plugin");
const prometheus = require("lib/prometheus");
const config = require("lib/config");
const users = require("lib/users");
const generateSSLcert = require("./src/generate_ssl_cert");
const database = require("@clusterio/lib/database");
const schema = require("@clusterio/lib/schema");
const link = require("@clusterio/lib/link");
const errors = require("@clusterio/lib/errors");
const plugin = require("@clusterio/lib/plugin");
const prometheus = require("@clusterio/lib/prometheus");
const config = require("@clusterio/lib/config");
const users = require("@clusterio/lib/users");
const express = require("express");
const compression = require("compression");
@@ -86,9 +88,10 @@ app.use(function(req, res, next){
next();
});
require("./routes")(app);
require("./src/routes")(app);
// Set folder to serve static content from (the website)
app.use(express.static("static"));
app.use(express.static(path.join(__dirname, "static")));
app.use(express.static("static")); // Used for data export files
const endpointHitCounter = new prometheus.Counter(
"clusterio_master_http_endpoint_hits_total",
@@ -1481,7 +1484,9 @@ async function loadPlugins(pluginInfos) {
let MasterPlugin = plugin.BaseMasterPlugin;
try {
if (pluginInfo.masterEntrypoint) {
({ MasterPlugin } = require(`./plugins/${pluginInfo.name}/${pluginInfo.masterEntrypoint}`));
// XXX Does not work on Windows
let pluginPath = path.relative(__dirname, path.join("plugins", pluginInfo.name));
({ MasterPlugin } = require(path.join(pluginPath, pluginInfo.masterEntrypoint)));
}
let masterPlugin = new MasterPlugin(
File renamed without changes.
+40
View File
@@ -0,0 +1,40 @@
{
"name": "@clusterio/master",
"description": "Implementation of Clusterio master server",
"author": "Hornwitser",
"license": "MIT",
"version": "2.0.0-alpha0",
"main": "master.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"install": "node npm_post_install"
},
"bin": {
"clusteriomaster": "./master.js"
},
"keywords": [
"factorio"
],
"engines": {
"node": ">=10.16 <11 || >= 11.13"
},
"dependencies": {
"@clusterio/lib": "=2.0.0-alpha0",
"body-parser": "^1.18.2",
"compression": "^1.7.2",
"cookie-parser": "^1.4.3",
"ejs": "^2.5.7",
"express": "^4.16.2",
"express-fileupload": "1.2.0",
"fs-extra": "^8.1.0",
"jsonwebtoken": "^8.2.1",
"jszip": "^3.2.2",
"moment": "^2.22.2",
"node-factorio-api": "^0.3.8",
"node-forge": "^0.10.0",
"request": "^2.83.0",
"set-blocking": "^2.0.0",
"ws": "^7.2.3",
"yargs": "^14.2.0"
}
}
@@ -13,7 +13,7 @@ module.exports = async function({
doLogging = false,
} = {}){
function log(t) {
if(doLogging) console.log("lib/generateSSLcert.js | "+t);
if(doLogging) console.log("src/generate_ssl_cert.js | "+t);
}
log("Generating SSL certificate with "+bits+" bits at "+sslCertPath);
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

Before

Width:  |  Height:  |  Size: 3.2 KiB

After

Width:  |  Height:  |  Size: 3.2 KiB

File renamed without changes.

Before

Width:  |  Height:  |  Size: 22 KiB

After

Width:  |  Height:  |  Size: 22 KiB

File renamed without changes.

Before

Width:  |  Height:  |  Size: 34 KiB

After

Width:  |  Height:  |  Size: 34 KiB

File renamed without changes.

Before

Width:  |  Height:  |  Size: 2.8 KiB

After

Width:  |  Height:  |  Size: 2.8 KiB

File renamed without changes.

Before

Width:  |  Height:  |  Size: 4.0 KiB

After

Width:  |  Height:  |  Size: 4.0 KiB

File renamed without changes.

Before

Width:  |  Height:  |  Size: 7.3 KiB

After

Width:  |  Height:  |  Size: 7.3 KiB

File renamed without changes.

Before

Width:  |  Height:  |  Size: 12 KiB

After

Width:  |  Height:  |  Size: 12 KiB

File renamed without changes.

Before

Width:  |  Height:  |  Size: 15 KiB

After

Width:  |  Height:  |  Size: 15 KiB

File renamed without changes.

Before

Width:  |  Height:  |  Size: 16 KiB

After

Width:  |  Height:  |  Size: 16 KiB

File renamed without changes.

Before

Width:  |  Height:  |  Size: 22 KiB

After

Width:  |  Height:  |  Size: 22 KiB

File renamed without changes.

Before

Width:  |  Height:  |  Size: 24 KiB

After

Width:  |  Height:  |  Size: 24 KiB

File renamed without changes.

Before

Width:  |  Height:  |  Size: 32 KiB

After

Width:  |  Height:  |  Size: 32 KiB

File renamed without changes.

Before

Width:  |  Height:  |  Size: 5.2 KiB

After

Width:  |  Height:  |  Size: 5.2 KiB

File renamed without changes.

Before

Width:  |  Height:  |  Size: 5.6 KiB

After

Width:  |  Height:  |  Size: 5.6 KiB

File renamed without changes.

Before

Width:  |  Height:  |  Size: 7.3 KiB

After

Width:  |  Height:  |  Size: 7.3 KiB

File renamed without changes.

Before

Width:  |  Height:  |  Size: 8.0 KiB

After

Width:  |  Height:  |  Size: 8.0 KiB

File renamed without changes.

Before

Width:  |  Height:  |  Size: 35 KiB

After

Width:  |  Height:  |  Size: 35 KiB

File renamed without changes.

Before

Width:  |  Height:  |  Size: 35 KiB

After

Width:  |  Height:  |  Size: 35 KiB

File renamed without changes.

Before

Width:  |  Height:  |  Size: 1.4 KiB

After

Width:  |  Height:  |  Size: 1.4 KiB

File renamed without changes.

Before

Width:  |  Height:  |  Size: 2.4 KiB

After

Width:  |  Height:  |  Size: 2.4 KiB

File renamed without changes.

Before

Width:  |  Height:  |  Size: 12 KiB

After

Width:  |  Height:  |  Size: 12 KiB

File renamed without changes.

Before

Width:  |  Height:  |  Size: 1.1 KiB

After

Width:  |  Height:  |  Size: 1.1 KiB

File renamed without changes.
File renamed without changes.

Before

Width:  |  Height:  |  Size: 22 KiB

After

Width:  |  Height:  |  Size: 22 KiB

File renamed without changes.

Before

Width:  |  Height:  |  Size: 24 KiB

After

Width:  |  Height:  |  Size: 24 KiB

File renamed without changes.

Before

Width:  |  Height:  |  Size: 74 KiB

After

Width:  |  Height:  |  Size: 74 KiB

File renamed without changes.

Before

Width:  |  Height:  |  Size: 7.1 KiB

After

Width:  |  Height:  |  Size: 7.1 KiB

File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

Before

Width:  |  Height:  |  Size: 20 KiB

After

Width:  |  Height:  |  Size: 20 KiB

File renamed without changes.

Before

Width:  |  Height:  |  Size: 23 KiB

After

Width:  |  Height:  |  Size: 23 KiB

File renamed without changes.

Before

Width:  |  Height:  |  Size: 5.6 KiB

After

Width:  |  Height:  |  Size: 5.6 KiB

File renamed without changes.
File renamed without changes.
+28
View File
@@ -0,0 +1,28 @@
{
"name": "@clusterio/slave",
"description": "Implementation of Clusterio slave server",
"author": "Hornwitser",
"license": "MIT",
"version": "2.0.0-alpha0",
"main": "slave.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"bin": {
"clusterioslave": "./slave.js"
},
"keywords": [
"factorio"
],
"engines": {
"node": ">=10.16 <11 || >= 11.13"
},
"dependencies": {
"@clusterio/lib": "=2.0.0-alpha0",
"fs-extra": "^8.1.0",
"phin": "^3.4.1",
"pidusage": "^2.0.18",
"set-blocking": "^2.0.0",
"yargs": "^14.2.0"
}
}
+17 -13
View File
@@ -1,3 +1,5 @@
#!/usr/bin/env node
/**
* Clusterio slave
*
@@ -8,7 +10,7 @@
* @module
* @author Danielv123, Hornwitser
* @example
* node slave run
* npx clusterioslave run
*/
"use strict";
const fs = require("fs-extra");
@@ -22,14 +24,14 @@ const util = require("util");
const version = require("./package").version;
// internal libraries
const fileOps = require("lib/fileOps");
const factorio = require("lib/factorio");
const link = require("lib/link");
const plugin = require("lib/plugin");
const errors = require("lib/errors");
const prometheus = require("lib/prometheus");
const luaTools = require("lib/luaTools");
const config = require("lib/config");
const fileOps = require("@clusterio/lib/fileOps");
const factorio = require("@clusterio/lib/factorio");
const link = require("@clusterio/lib/link");
const plugin = require("@clusterio/lib/plugin");
const errors = require("@clusterio/lib/errors");
const prometheus = require("@clusterio/lib/prometheus");
const luaTools = require("@clusterio/lib/luaTools");
const config = require("@clusterio/lib/config");
const instanceRconCommandsCounter = new prometheus.Counter(
@@ -198,7 +200,9 @@ class Instance extends link.Link{
async _loadPlugin(pluginInfo, slave) {
let pluginLoadStarted = Date.now();
let { InstancePlugin } = require(`./plugins/${pluginInfo.name}/${pluginInfo.instanceEntrypoint}`);
// XXX Does not work on Windows
let pluginPath = path.relative(__dirname, path.join("plugins", pluginInfo.name));
let { InstancePlugin } = require(path.join(pluginPath, pluginInfo.instanceEntrypoint));
let instancePlugin = new InstancePlugin(pluginInfo, this, slave);
this.plugins.set(pluginInfo.name, instancePlugin);
await instancePlugin.init();
@@ -1423,9 +1427,9 @@ async function startSlave() {
console.error("ERROR invalid config!");
console.error(
"Master server requires an access token for socket operations. As clusterio\n"+
"slaves depends upon this, please set your token using the command node slave\n"+
"config set slave.master_token <token>. You can generate an auth token using\n"+
"using node clusterctl generate-slave-token."
"slaves depends upon this, please set your token using the command npx\n"+
"clusterioslave config set slave.master_token <token>. You can generate an\n"+
"auth token using npx clusterctl generate-slave-token."
);
process.exitCode = 1;
return;
+2 -2
View File
@@ -1,7 +1,7 @@
"use strict";
const plugin = require("lib/plugin");
const plugin = require("@clusterio/lib/plugin");
const info = require("./info");
const command = require("lib/command");
const command = require("@clusterio/lib/command");
const globalChatCommands = new command.CommandTree({ name: "global-chat", description: "Global Chat plugin commands" });
+2 -2
View File
@@ -1,6 +1,6 @@
"use strict";
let link = require("lib/link");
let plugin = require("lib/plugin");
let link = require("@clusterio/lib/link");
let plugin = require("@clusterio/lib/plugin");
module.exports = {
name: "global_chat",
+2 -2
View File
@@ -2,8 +2,8 @@
* @module
*/
"use strict";
const plugin = require("lib/plugin");
const luaTools = require("lib/luaTools");
const plugin = require("@clusterio/lib/plugin");
const luaTools = require("@clusterio/lib/luaTools");
/**
+1 -1
View File
@@ -1,5 +1,5 @@
"use strict";
const link = require("lib/link");
const link = require("@clusterio/lib/link");
// schema used for syncing technologies to and from the master
+2 -4
View File
@@ -1,8 +1,6 @@
"use strict";
const needle = require("needle");
const plugin = require("lib/plugin");
const luaTools = require("lib/luaTools");
const plugin = require("@clusterio/lib/plugin");
const luaTools = require("@clusterio/lib/luaTools");
function unexpectedError(err) {
+1 -1
View File
@@ -2,7 +2,7 @@
const fs = require("fs-extra");
const path = require("path");
const plugin = require("lib/plugin");
const plugin = require("@clusterio/lib/plugin");
class MasterPlugin extends plugin.BaseMasterPlugin {
+1 -1
View File
@@ -1,5 +1,5 @@
"use strict";
let link = require("lib/link");
let link = require("@clusterio/lib/link");
module.exports = {
name: "statistics_exporter",
+2 -2
View File
@@ -1,6 +1,6 @@
"use strict";
const plugin = require("lib/plugin");
const { Gauge } = require("lib/prometheus");
const plugin = require("@clusterio/lib/plugin");
const { Gauge } = require("@clusterio/lib/prometheus");
const instancePlayerCount = new Gauge(
+1 -1
View File
@@ -1,7 +1,7 @@
"use strict";
const doleNN = require("./dole_nn_base");
const prometheus = require("lib/prometheus");
const prometheus = require("@clusterio/lib/prometheus");
const prometheusNNDoleGauge = new prometheus.Gauge(
+2 -2
View File
@@ -1,6 +1,6 @@
"use strict";
const link = require("lib/link");
const config = require("lib/config");
const link = require("@clusterio/lib/link");
const config = require("@clusterio/lib/config");
class MasterConfigGroup extends config.PluginConfigGroup {}
MasterConfigGroup.groupName = "subspace_storage";
Loaded 100 of 133 files, more files were not shown because too many files have changed in this diff. Show more