Commit 6722de29 authored by nanahira's avatar nanahira

add StarterPlugin for even easier starter

parent 8d7d7829
...@@ -15,7 +15,7 @@ ...@@ -15,7 +15,7 @@
"koishi-decorators": "^2.0.1", "koishi-decorators": "^2.0.1",
"lodash": "^4.17.21", "lodash": "^4.17.21",
"reflect-metadata": "^0.1.13", "reflect-metadata": "^0.1.13",
"schemastery-gen": "^3.1.10", "schemastery-gen": "^3.1.13",
"typed-reflector": "^1.0.10" "typed-reflector": "^1.0.10"
}, },
"devDependencies": { "devDependencies": {
...@@ -5853,9 +5853,9 @@ ...@@ -5853,9 +5853,9 @@
} }
}, },
"node_modules/schemastery-gen": { "node_modules/schemastery-gen": {
"version": "3.1.10", "version": "3.1.13",
"resolved": "https://registry.npmjs.org/schemastery-gen/-/schemastery-gen-3.1.10.tgz", "resolved": "https://registry.npmjs.org/schemastery-gen/-/schemastery-gen-3.1.13.tgz",
"integrity": "sha512-hwCLOICGEodCcQt+eLoEEvNhm7iSEwJB37JQ+27cHbggTry/Rq07ivXVsPw63Et74EobEaOGDVOTzJ4kIQa01w==", "integrity": "sha512-KXkjV9AuKWBlkJ8yEhLYDh7wRcM8p/M+s30Ig6g5eYlGfv7KVUGmpSVVtcH+fUZG+zS/7/UfCreMqqqFJBPdNw==",
"dependencies": { "dependencies": {
"lodash": "^4.17.21", "lodash": "^4.17.21",
"reflect-metadata": "^0.1.13", "reflect-metadata": "^0.1.13",
...@@ -11324,9 +11324,9 @@ ...@@ -11324,9 +11324,9 @@
} }
}, },
"schemastery-gen": { "schemastery-gen": {
"version": "3.1.10", "version": "3.1.13",
"resolved": "https://registry.npmjs.org/schemastery-gen/-/schemastery-gen-3.1.10.tgz", "resolved": "https://registry.npmjs.org/schemastery-gen/-/schemastery-gen-3.1.13.tgz",
"integrity": "sha512-hwCLOICGEodCcQt+eLoEEvNhm7iSEwJB37JQ+27cHbggTry/Rq07ivXVsPw63Et74EobEaOGDVOTzJ4kIQa01w==", "integrity": "sha512-KXkjV9AuKWBlkJ8yEhLYDh7wRcM8p/M+s30Ig6g5eYlGfv7KVUGmpSVVtcH+fUZG+zS/7/UfCreMqqqFJBPdNw==",
"requires": { "requires": {
"lodash": "^4.17.21", "lodash": "^4.17.21",
"reflect-metadata": "^0.1.13", "reflect-metadata": "^0.1.13",
......
import { Context } from 'koishi'; import { Context } from 'koishi';
import { InjectConfig } from './decorators'; import { ClassType } from 'schemastery-gen';
import { InjectConfig, PluginSchema } from './decorators';
export type PartialDeep<T> = T extends export type PartialDeep<T> = T extends
| string | string
...@@ -38,3 +39,9 @@ export class BasePlugin<C, PC = PartialDeep<C>> { ...@@ -38,3 +39,9 @@ export class BasePlugin<C, PC = PartialDeep<C>> {
@InjectConfig() @InjectConfig()
config: C; config: C;
} }
export function StarterPlugin<C>(config: ClassType<C>) {
const plugin = class StarterPluginBase extends BasePlugin<C> {};
PluginSchema(config)(plugin);
return plugin;
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment