Add js templates and config templates

This commit is contained in:
Cooldude2606 committed 2024-01-23 00:14:08 +00:00
1 parent de00a043c3
commit 9b0293501f
23 files changed
+543 -50

No files matched your search

@@ -1,2 +1,3 @@
dist/
node_modules/
package-lock.json
@@ -10,11 +10,11 @@ export class ControllerPlugin extends BaseControllerPlugin {
async onControllerConfigFieldChanged(field: string, curr: unknown, prev: unknown) {
this.logger.info(`controller::onControllerConfigFieldChanged ${field}`);
}
}// [instance] //
async onInstanceConfigFieldChanged(instance: InstanceInfo, field: string, curr: unknown, prev: unknown) {
this.logger.info(`controller::onInstanceConfigFieldChanged ${instance.id} ${field}`);
}
}// [] //
async onSaveData() {
this.logger.info("controller::onSaveData");
+2 -1
View File
@@ -13,7 +13,8 @@ pluginCommands.add(new Command({
yargs.positional("foo", { describe: "foo is foo!", type: "string" });
}],
handler: async function(args: { foo: string }, control: Control) {
await control.sendTo("controller", new PluginExampleEvent(args.foo, [1, 2, 3]));
const response = await control.sendTo("controller", new PluginExampleRequest(args.foo, [1, 2, 3]));
console.log(response);
console.log(args);
},
}));
+44 -1
View File
@@ -12,13 +12,56 @@ lib.definePermission({
name: "// plugin_name //.example.permission.request",
title: "Example permission request",
description: "My plugin's example permission that I forgot to remove",
});
});// [web] //
lib.definePermission({
name: "// plugin_name //.page.view",
title: "Example page view permission",
description: "My plugin's example page permission that I forgot to remove",
});// [] //
declare module "@clusterio/lib" {// [controller] //
export interface ControllerConfigFields {
"// plugin_name //.myControllerField": string;
}// [] //// [host] //
export interface HostConfigFields {
"// plugin_name //.myHostField": string;
}// [] //// [instance] //
export interface InstanceConfigFields {
"// plugin_name //.myInstanceField": string;
}// [] //
}
export const plugin: lib.PluginDeclaration = {
name: "// plugin_name //",
title: "// plugin_name //",
description: "I didn't update my description",
// entry_points //
// [controller] //
controlConfigFields: {
"// plugin_name //.myControllerField": {
title: "My Controller Field",
description: "This should be removed",
type: "string",
initialValue: "Remove Me",
},
},// [] //// [host] //
hostConfigFields: {
"// plugin_name //.myHostField": {
title: "My Host Field",
description: "This should be removed",
type: "string",
initialValue: "Remove Me",
},
},// [] //// [instance] //
instanceConfigFields: {
"// plugin_name //.myInstanceField": {
title: "My Instance Field",
description: "This should be removed",
type: "string",
initialValue: "Remove Me",
},
},// [] //
messages: [
PluginExampleEvent,
@@ -5,7 +5,7 @@ export class PluginExampleEvent {
declare ["constructor"]: typeof PluginExampleEvent;
static type = "event" as const;
static src = ["host", "control"] as const;
static dst = ["controller", "host"] as const;
static dst = ["controller", "host", "instance"] as const;
static plugin = "// plugin_name //" as const;
static permission = "// plugin_name //.example.permission.event";
@@ -29,7 +29,7 @@ export class PluginExampleRequest {
declare ["constructor"]: typeof PluginExampleRequest;
static type = "request" as const;
static src = ["host", "control"] as const;
static dst = ["controller", "host"] as const;
static dst = ["controller", "host", "instance"] as const;
static plugin = "// plugin_name //" as const;
static permission = "// plugin_name //.example.permission.request";
@@ -16,10 +16,14 @@
// dev_dependencies //
"@clusterio/lib": "^2.0.0-alpha.14"
},
"dependencies": {
"@sinclair/typebox": "^0.30.4"
},
"publishConfig": {
"access": "public"
},
"dependencies": {
// dependencies //
}
"keywords": [
"clusterio",
"factorio"
]
}
@@ -14,7 +14,7 @@ module.exports = (env = {}) => merge(common(env), {
plugins: [
new webpack.container.ModuleFederationPlugin({
name: "// plugin_name //",
library: { type: "var", name: "plugin___plugin_name__" },
library: { type: "var", name: "plugin_// plugin_name //" },
exposes: {
"./": "./index.ts",
"./package.json": "./package.json",