diff --git a/CHANGELOG.md b/CHANGELOG.md index e99a2e73..aae40add 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -15,7 +15,7 @@ Version 2.0.0 - Daemonized slaves. Slaves now have the ability to run multiple Factorio instances, starting and stopping them individually. To manage this the local command line interface has been replaced with a remote interface on - the master server that can be accessed through the clusterctl cli tool. + the master server that can be accessed through the clusterioctl cli tool. - Rewritten the communication between slaves and the master from scratch. The new system is based on a WebSocket connection between the slaves and the master server and provides efficient validated bi-directonal communication. diff --git a/README.md b/README.md index 233751fa..ae3e136e 100644 --- a/README.md +++ b/README.md @@ -193,7 +193,7 @@ up a new username here). The first command creates a user account with the given name and promotes it to a cluster admin. The second one sets up a -`config-control.json` config for clusterctl to connect to the master +`config-control.json` config for clusterioctl to connect to the master server under the given user account. @@ -213,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. - npx clusterctl slave create-config --name Local --generate-token + npx clusterioctl 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, @@ -234,18 +234,18 @@ Once the config is set up run the slave with ### Instances Instances are created, managed and started from the master server. For -now the only interface available is the `clusterctl` command line tool +now the only interface available is the `clusterioctl` command line tool included in Clusterio. You can run this tool from any slave, or the master server without having to set up a config, if you want to manage the cluster from somewhere else you will need to set the `control.master_url` and `control.master_token` options with the `node -clusterctl control-config set` command: +clusterioctl control-config set` command: The basic operations to start a new instance is the following - npx clusterctl instance create "My instance" - npx clusterctl instance assign "My instance" "Local" - npx clusterctl instance start "My instance" + npx clusterioctl instance create "My instance" + npx clusterioctl instance assign "My instance" "Local" + npx clusterioctl 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 @@ -253,8 +253,8 @@ directory and files needed to run the instance on the given slave. The 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 -`npx clusterctl --help` for a full list of them. +There are many more commands available with clusterioctl. See +`npx clusterioctl --help` for a full list of them. ## Plugins diff --git a/docs/config-system.md b/docs/config-system.md index 31b65406..dd7a1b30 100644 --- a/docs/config-system.md +++ b/docs/config-system.md @@ -6,7 +6,7 @@ configuration system in Clusterio, and unless you're developing Clusterio it's probably not going to be very useful for you. Clusterio uses a group based configuration system to manage settings for -the master server, instances, slaves, and the clusterctl utility. +the master server, instances, slaves, and the clusterioctl utility. Plugins get their own config group for the master server and instances which they can add their own fields to. The fields are defined early in the startup, and the groups and their fields for disabled plugins will diff --git a/docs/jsdoc.json b/docs/jsdoc.json index 4974fc3b..8752694b 100644 --- a/docs/jsdoc.json +++ b/docs/jsdoc.json @@ -14,7 +14,7 @@ "packages/master/src/", "packages/master/master.js", "packages/slave/slave.js", - "packages/ctl/clusterctl.js", + "packages/ctl/ctl.js", "packages/lib/", "plugins/" ], diff --git a/docs/maniging-a-cluster.md b/docs/maniging-a-cluster.md index b1d74abe..d8e45881 100644 --- a/docs/maniging-a-cluster.md +++ b/docs/maniging-a-cluster.md @@ -2,13 +2,13 @@ Managing a Cluster ================== Clusterio clusers are managed through the master server by using the -`clusterctl` command line interface which is invoked by running -`npx clusterctl ` in the clusterio directory. This document -uses the shorthand `ctl> foo` to indicate `npx clusterctl foo` should +`clusterioctl` command line interface which is invoked by running +`npx clusterioctl ` in the clusterio directory. This document +uses the shorthand `ctl> foo` to indicate `npx clusterioctl foo` should be executed. Mandatory parameters are shown in `` and optional pameters are in `[square brackets]`. -Before `clusterctl` can be used it needs to be configured for the +Before `clusterioctl` can be used it needs to be configured for the cluster it will connect to. The easiest way to do this is to run `npx clusteriomaster bootstrap create-ctl-config ` on the master server, which creates the necessary `config-control.json` for diff --git a/docs/writing-plugins.md b/docs/writing-plugins.md index 6ac1a6cb..60f6ecec 100644 --- a/docs/writing-plugins.md +++ b/docs/writing-plugins.md @@ -19,7 +19,7 @@ Contents - [Sending Link Messages](#sending-link-messages) - [Handling connection events](#handling-connection-events) - [Collecting Statistics](#collecting-statistics) -- [Adding Custom Commands to clusterctl](#adding-custom-commands-to-clusterctl) +- [Adding Custom Commands to clusterioctl](#adding-custom-commands-to-clusterioctl) Plugin Structure @@ -100,7 +100,7 @@ The following properties are recognized: Path to a Node.js module relative to the plugin directory which contains the ControlPlugin class definition for this plugin. This is an optional paramater. A plugin can be made that only runs on - the clusterctl side. + the clusterioctl side. **messages**: Object with link messages definitions for this plugin. See guide @@ -145,7 +145,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 +replaced with "Instance", and for the clusterioctl plugin "Control" is used. The available hooks that you can override are documented in the base class [in lib/plugin.js](/packages/lib/plugin.js). @@ -591,8 +591,8 @@ hook on both master and instance plugins that is run before the metrics in the default registry are collected. -Adding Custom Commands to clusterctl ------------------------------------- +Adding Custom Commands to clusterioctl +-------------------------------------- The control entrypoint for plugins allows you to extend clustectl with your own commands. The creation of custom commands typically starts @@ -630,15 +630,15 @@ and for setting up positional and optional arguments to commands). The `handler` is an async function that's invoked when the command is executed and it's passed the parsed command line arguments and a -reference to the `Control` class of clusterctl. It's possible to optain +reference to the `Control` class of clusterioctl. It's possible to optain a reference to the plugin class with `control.plugins.get(info.name)`. -Note that messages sent from clusterctl needs to have +Note that messages sent from clusterioctl needs to have `"control-master"` as a part of the links array for it to be accepted by the master server, see [Defining Link Messages](#defining-link-messages) 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 have the command tree become part of clusterioctl it needs to be added to the rootCommand tree in `addCommands` callback of the Control plugin: const plugin = require("@clusterio/lib/plugin"); diff --git a/packages/ctl/clusterctl.js b/packages/ctl/ctl.js similarity index 98% rename from packages/ctl/clusterctl.js rename to packages/ctl/ctl.js index d55c986c..72031d88 100755 --- a/packages/ctl/clusterctl.js +++ b/packages/ctl/ctl.js @@ -522,7 +522,7 @@ class ControlConnector extends link.WebSocketClientConnector { console.log("SOCKET | registering control"); this.sendHandshake("register_control", { token: this._token, - agent: "clusterctl", + agent: "clusterioctl", version: version, }); } @@ -577,7 +577,7 @@ class Control extends link.Link { async function startControl() { yargs - .scriptName("clusterctl") + .scriptName("clusterioctl") .usage("$0 [options]") .option("config", { nargs: 1, @@ -591,7 +591,7 @@ async function startControl() { .strict() ; - const rootCommands = new command.CommandTree({ name: "clusterctl", description: "Manage cluster" }); + const rootCommands = new command.CommandTree({ name: "clusterioctl", description: "Manage cluster" }); rootCommands.add(slaveCommands); rootCommands.add(instanceCommands); rootCommands.add(permissionCommands); @@ -741,9 +741,9 @@ I version of clusterio. Expect things to break. I ); } else { console.error(` -+-------------------------------+ -| Unable to to start clusterctl | -+-------------------------------+` ++---------------------------------+ +| Unable to to start clusterioctl | ++---------------------------------+` ); } diff --git a/packages/ctl/package.json b/packages/ctl/package.json index dd9e37e4..a74d5fb2 100644 --- a/packages/ctl/package.json +++ b/packages/ctl/package.json @@ -4,12 +4,12 @@ "author": "Hornwitser", "license": "MIT", "version": "2.0.0-alpha0", - "main": "clusterctl.js", + "main": "ctl.js", "scripts": { "test": "echo \"Error: no test specified\" && exit 1" }, "bin": { - "clusterctl": "./clusterctl.js" + "clusterioctl": "./ctl.js" }, "keywords": [ "factorio" diff --git a/packages/lib/command.js b/packages/lib/command.js index a2062a64..cb38c9b8 100644 --- a/packages/lib/command.js +++ b/packages/lib/command.js @@ -1,7 +1,7 @@ /** * Command library * - * Data types and utilites for commands to clusterctl's CLI. + * Data types and utilites for commands to clusterioctl's CLI. * * @author Hornwitser * @module @@ -11,7 +11,7 @@ const link = require("@clusterio/lib/link"); const errors = require("@clusterio/lib/errors"); /** - * Represents a command that can be runned by clusterctl + * Represents a command that can be runned by clusterioctl * @static */ class Command { @@ -52,7 +52,7 @@ class Command { * A node in the command tree that can hold commands and sub trees * * Container which can contain {@link module:lib/command.Command}s and other - * CommandTrees. This is used by clusterctl to hold the full tree of + * CommandTrees. This is used by clusterioctl to hold the full tree of * available commands, you may extend this tree by using a control plugin, * see {@link module:lib/plugin.BaseControlPlugin#addCommands} * diff --git a/packages/lib/plugin.js b/packages/lib/plugin.js index 233760ef..fe9222f7 100644 --- a/packages/lib/plugin.js +++ b/packages/lib/plugin.js @@ -339,10 +339,10 @@ class BaseMasterPlugin { } /** - * Base class for clusterctl plugins + * Base class for clusterioctl plugins * * Control plugins are subclasses of this class which get instantiated by - * clusterctl in order to extend its functionallity. To be discovered the + * clusterioctl in order to extend its functionallity. To be discovered the * class must be exported under the name `ControlPlugin` in the module * specified by the `controlEntrypoint` in the plugin's info.js file. * @@ -364,7 +364,7 @@ class BaseControlPlugin { /** * Called to add commands to the command line interface. * - * Invoked by clusterctl to let plugins add commands. `rootCommand` is + * Invoked by clusterioctl to let plugins add commands. `rootCommand` is * the top level command node which the plugin should add its own {@link * module:lib/command.CommandTree} to. * diff --git a/packages/master/master.js b/packages/master/master.js index 4685b9d1..be0d4c30 100755 --- a/packages/master/master.js +++ b/packages/master/master.js @@ -6,7 +6,7 @@ * Facilitates communication between slaves and control of the cluster * through WebSocet connections, and hosts a webserver for browser * interfaces and Prometheus statistics export. It is remotely controlled - * by {@link module:clusterctl}. + * by {@link module:@clusterio/ctl/ctl}. * * @module * @author Danielv123, Hornwitser @@ -1582,7 +1582,7 @@ async function startServer() { .command("bootstrap", "Bootstrap access to cluster", yargs => { yargs .command("create-admin ", "Create a cluster admin") - .command("create-ctl-config ", "Create clusterctl config for the given user", yargs => { + .command("create-ctl-config ", "Create clusterioctl config for the given user", yargs => { yargs.option("output", { describe: "Path to output config (- for stdout)", type: "string", nargs: 1, default: "config-control.json", diff --git a/packages/slave/slave.js b/packages/slave/slave.js index b14727ea..bb575dc3 100755 --- a/packages/slave/slave.js +++ b/packages/slave/slave.js @@ -1429,7 +1429,7 @@ async function startSlave() { "Master server requires an access token for socket operations. As clusterio\n"+ "slaves depends upon this, please set your token using the command npx\n"+ "clusterioslave config set slave.master_token . You can generate an\n"+ - "auth token using npx clusterctl generate-slave-token." + "auth token using npx clusterioctl generate-slave-token." ); process.exitCode = 1; return; diff --git a/test/clusterctl.js b/test/ctl.js similarity index 71% rename from test/clusterctl.js rename to test/ctl.js index b9e97bd0..e293d294 100644 --- a/test/clusterctl.js +++ b/test/ctl.js @@ -2,14 +2,14 @@ const assert = require("assert").strict; const { testLines } = require("./lib/factorio/lines"); -const clusterctl = require("@clusterio/ctl/clusterctl.js"); +const clusterioctl = require("@clusterio/ctl/ctl.js"); -describe("clusterctl", function() { +describe("clusterioctl", function() { describe("formatOutputColored()", function() { it("should pass the test lines", function() { for (let [reference, output] of testLines) { - let line = clusterctl._formatOutputColored(output); + let line = clusterioctl._formatOutputColored(output); // Strip colours line = line.replace(/\x1B\[\d+m/g, ""); assert.deepEqual(line, reference); diff --git a/test/integration/clusterio.js b/test/integration/clusterio.js index 57f0e3c9..7c4faece 100644 --- a/test/integration/clusterio.js +++ b/test/integration/clusterio.js @@ -29,7 +29,7 @@ describe("Integration of Clusterio", function() { }); - describe("clusterctl", function() { + describe("clusterioctl", function() { describe("slave list", function() { it("runs", async function() { await execCtl("slave list"); diff --git a/test/integration/index.js b/test/integration/index.js index e64df099..ed05ce5c 100644 --- a/test/integration/index.js +++ b/test/integration/index.js @@ -29,7 +29,7 @@ class TestControl extends link.Link { class TestControlConnector extends link.WebSocketClientConnector { register() { - this.sendHandshake("register_control", { token: this.token, agent: "clusterctl", version: "test" }); + this.sendHandshake("register_control", { token: this.token, agent: "clusterioctl", version: "test" }); } }