Add template copying

This commit is contained in:
Cooldude2606 committed 2024-01-22 02:47:34 +00:00
1 parent 534dc14221
commit c81d2b61a6
19 files changed
+278 -1

No files matched your search

@@ -0,0 +1,2 @@
dist/
node_modules/
@@ -0,0 +1,2 @@
webpack.config.js
dist/web/build
Whitespace-only changes.
Whitespace-only changes.
Whitespace-only changes.
@@ -0,0 +1,27 @@
import * as lib from "@clusterio/lib";
import { PluginExampleEvent, PluginExampleRequest } from "./messages";
lib.definePermission({
name: "// plugin_name //.example.permission.event",
title: "Example permission event",
description: "My plugin's example permission that I forgot to remove",
});
lib.definePermission({
name: "// plugin_name //.example.permission.request",
title: "Example permission request",
description: "My plugin's example permission that I forgot to remove",
});
export const plugin: lib.PluginDeclaration = {
name: "// plugin_name //",
title: "// plugin_name //",
description: "I didn't update my description",
// entry_points //
messages: [
PluginExampleEvent,
PluginExampleRequest,
],
};
Whitespace-only changes.
@@ -0,0 +1,55 @@
import { plainJson, jsonArray, JsonBoolean, JsonNumber, JsonString, StringEnum } from "@clusterio/lib";
import { Type, Static } from "@sinclair/typebox";
export class PluginExampleEvent {
declare ["constructor"]: typeof PluginExampleEvent;
static type = "event" as const;
static src = ["host"] as const;
static dst = "controller" as const;
static plugin = "// plugin_name //" as const;
static permission = "// plugin_name //.example.permission.event";
constructor(
public myString: string,
public myNumberArray: number[],
) {
}
static jsonSchema = Type.Object({
"myString": Type.String(),
"myNumberArray": Type.Array(Type.Number()),
});
static fromJson(json: Static<typeof PluginExampleEvent.jsonSchema>) {
return new PluginExampleEvent(json.myString, json.myNumberArray);
}
}
export class PluginExampleRequest {
declare ["constructor"]: typeof PluginExampleEvent;
static type = "request" as const;
static src = ["host"] as const;
static dst = "controller" as const;
static plugin = "// plugin_name //" as const;
static permission = "// plugin_name //.example.permission.request";
constructor(
public myString: string,
public myNumberArray: number[],
) {
}
static jsonSchema = Type.Object({
"myString": Type.String(),
"myNumberArray": Type.Array(Type.Number()),
});
static fromJson(json: Static<typeof PluginExampleEvent.jsonSchema>) {
return new PluginExampleEvent(json.myString, json.myNumberArray);
}
static Response = plainJson(Type.Object({
"myResponseString": Type.String(),
"myResponseNumbers": Type.Array(Type.Number()),
}));
}
Whitespace-only changes.
@@ -0,0 +1,12 @@
{
"name": "// plugin_name //",
"load": [
"control.lua"
],
"require": [
],
"dependencies": [
]
}
@@ -0,0 +1,3 @@
local Control = require("./control")
return Control
@@ -0,0 +1,31 @@
{
"name": "__plugin_name__",
"version": "0.1.0",
"description": "",
"main": "dist/plugin/index.js",
"scripts": {
"prepare": "tsc --build && webpack-cli --env production"
},
"engines": {
"node": ">=18"
},
"peerDependencies": {
"@clusterio/lib": "^2.0.0-alpha.0"
},
"devDependencies": {
"@clusterio/lib": "^2.0.0-alpha.14",
"@clusterio/web_ui": "^2.0.0-alpha.14",
"@types/node": "^20.4.5",
"@types/react": "^18.2.21",
"typescript": "^5.1.6",
"webpack": "^5.88.2",
"webpack-cli": "^5.1.4",
"webpack-merge": "^5.9.0"
},
"publishConfig": {
"access": "public"
},
"dependencies": {
"@sinclair/typebox": "^0.30.4"
}
}
@@ -0,0 +1,11 @@
{
"extends": "../../tsconfig.node.json",
"references": [
{ "path": "../../packages/lib" },
],
"include": ["./**/*.ts"],
"exclude": ["test/*", "./dist/*"],
"compilerOptions": {
"outDir": "dist/plugin",
},
}
@@ -0,0 +1,11 @@
{
"extends": "../../tsconfig.web.json",
"references": [
{ "path": "../../packages/lib/tsconfig.web.json" },
{ "path": "../../packages/web_ui/tsconfig.web.json" },
],
"include": [ "web/**/*.tsx", "web/**/*.ts", "messages.ts", "package.json" ],
"compilerOptions": {
"outDir": "dist/web/build",
}
}
Whitespace-only changes.
Whitespace-only changes.
@@ -0,0 +1,28 @@
"use strict";
const path = require("path");
const webpack = require("webpack");
const { merge } = require("webpack-merge");
const common = require("@clusterio/web_ui/webpack.common");
module.exports = (env = {}) => merge(common(env), {
context: __dirname,
entry: "./web/index.tsx",
output: {
path: path.resolve(__dirname, "dist", "web"),
},
plugins: [
new webpack.container.ModuleFederationPlugin({
name: "// plugin_name //",
library: { type: "var", name: "plugin___plugin_name__" },
exposes: {
"./": "./index.ts",
"./package.json": "./package.json",
},
shared: {
"@clusterio/lib": { import: false },
"@clusterio/web_ui": { import: false },
},
}),
],
});