Move base plugins to their respective packages

Move BaseControllerPlugin to controller/src/BaseControllerPlugin.ts
Move BaseInstancePlugin to host/src/BaseInstancePlugin.ts
Move BaseControlPlugin to ctl/src/BaseCtlPlugin.ts
Move BaseWebPlugin to web_ui/src/BaseWebPlugin.ts

This solves the circular package dependency problem of the base plugins
needing types that are available only in the dependencies to lib.
This commit is contained in:
Hornwitser committed 2023-11-25 18:41:43 +01:00
1 parent 63dc370ea0
commit 808eda0513
51 files changed
+1073 -1060

No files matched your search

+9 -9
View File
@@ -95,8 +95,8 @@ The following properties are recognized:
Subclass of `PluginConfigGroup` for defining the controller configuration fields for this plugin.
See [Plugin Configuration](#plugin-configuration)
**controlEntrypoint**:
Path to a Node.js module relative to the plugin directory which contains the ControlPlugin class definition for this plugin.
**ctlEntrypoint**:
Path to a Node.js module relative to the plugin directory which contains the CtlPlugin class definition for this plugin.
This is an optional paramater.
A plugin can be made that only runs on the clusterioctl side.
@@ -120,9 +120,9 @@ The plugin class should derive from its respective base class defined in `lib/pl
For example, to define a ControllerPlugin class the following code can be used:
```js
const lib = require("@clusterio/lib");
const { BaseControllerPlugin } = require("@clusterio/controller");
class ControllerPlugin extends lib.BaseControllerPlugin {
class ControllerPlugin extends BaseControllerPlugin {
async init() {
this.foo = 42;
await this.startFrobnication();
@@ -136,7 +136,7 @@ module.exports = {
}
```
For the instance plugin it's exactly the same except "Controller" is replaced with "Instance", and for the clusterioctl plugin "Control" is used.
For the instance plugin it's exactly the same except "Controller" is replaced with "Instance", and for the clusterioctl plugin "Ctl" is used.
The available hooks that you can override are documented in the 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.
@@ -602,18 +602,18 @@ It's possible to optain a reference to the plugin class with `control.plugins.ge
Note that messages sent from clusterioctl needs to have `"control-controller"` as a part of the links array for it to be accepted by the controller, see [Defining Link Messages](#defining-link-messages) for how to define the messages that can be sent to the controller.
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:
To have the command tree become part of clusterioctl it needs to be added to the rootCommand tree in `addCommands` callback of the Ctl plugin:
```js
const lib = require("@clusterio/lib");
const { BaseCtlPlugin } = require("@clusterio/ctl");
class ControlPlugin extends lib.BaseControlPlugin {
class CtlPlugin extends BaseCtlPlugin {
async addCommands(rootCommand) {
rootCommand.add(fooFrobberCommands);
}
}
module.exports = {
ControlPlugin,
CtlPlugin,
}
```