diff --git a/package.json b/package.json index 1f055ea0..86508ceb 100644 --- a/package.json +++ b/package.json @@ -6,9 +6,10 @@ "author": "MiaoWoo ", "license": "MIT", "scripts": { + "bs": "npx lerna bootstrap", "clean": "npx lerna run clean", - "watch": "npx lerna run watch --parallel", - "build": "npx lerna run build --scope='@ms/!(plugins)'", + "watch": "npx lerna run watch --parallel --scope='@ms/!(manager)'", + "build": "npx lerna run build --scope='@ms/!(plugins|manager)'", "build:plugins": "npx lerna run build --scope=@ms/plugins", "lp": "npx lerna publish" }, @@ -18,4 +19,4 @@ "devDependencies": { "lerna": "^3.20.2" } -} +} \ No newline at end of file diff --git a/packages/manager/package.json b/packages/manager/package.json index d7a3fe16..d1564f80 100644 --- a/packages/manager/package.json +++ b/packages/manager/package.json @@ -27,7 +27,9 @@ "mongodb": "^3.4.1" }, "devDependencies": { + "@types/express": "^4.17.2", "@types/mongodb": "^3.3.14", + "@types/socket.io": "^2.1.4", "reflect-metadata": "^0.1.13", "rimraf": "^3.0.0", "ts-node-dev": "^1.0.0-pre.44", diff --git a/packages/plugin/src/manager.ts b/packages/plugin/src/manager.ts index 26f42c65..c7c42174 100644 --- a/packages/plugin/src/manager.ts +++ b/packages/plugin/src/manager.ts @@ -1,4 +1,4 @@ -import { plugin, server, command, event, MiaoScriptConsole } from '@ms/api' +import { plugin, server, command, event } from '@ms/api' import { injectable, inject, postConstruct, Container, ContainerInstance } from '@ms/container' import * as fs from '@ms/common/dist/fs' @@ -21,7 +21,7 @@ export class PluginManagerImpl implements plugin.PluginManager { private pluginMap: Map @postConstruct() - init() { + initialize() { if (this.pluginInstance !== null) { // 如果plugin不等于null 则代表是正式环境 console.info(`Initialization MiaoScript Plugin System: ${this.pluginInstance} ...`) @@ -44,15 +44,21 @@ export class PluginManagerImpl implements plugin.PluginManager { this.buildPlugins() } + private logStage(plugin: interfaces.Plugin, stage: string) { + console.log(`[${plugin.description.name}] ${stage} ${plugin.description.name} version ${plugin.description.version} by ${plugin.description.author || 'Unknow'}`) + } + load(...args: any[]): void { - this.checkAndGet(args[0]).forEach(pl => { - this.runCatch(pl, 'load') - this.runCatch(pl, `${this.serverType}load`) + this.checkAndGet(args[0]).forEach((plugin: interfaces.Plugin) => { + this.logStage(plugin, "Loading") + this.runCatch(plugin, 'load') + this.runCatch(plugin, `${this.serverType}load`) }) } enable(...args: any[]): void { - this.checkAndGet(args[0]).forEach(plugin => { + this.checkAndGet(args[0]).forEach((plugin: interfaces.Plugin) => { + this.logStage(plugin, "Enabling") this.runCatch(plugin, 'enable') this.runCatch(plugin, `${this.serverType}enable`) this.registryCommand(plugin) @@ -61,11 +67,12 @@ export class PluginManagerImpl implements plugin.PluginManager { } disable(...args: any[]): void { - this.checkAndGet(args[0]).forEach(pl => { - this.runCatch(pl, 'disable') - this.runCatch(pl, `${this.serverType}disable`) - this.unregistryCommand(pl) - this.unregistryListener(pl) + this.checkAndGet(args[0]).forEach((plugin: interfaces.Plugin) => { + this.logStage(plugin, "Disabling") + this.runCatch(plugin, 'disable') + this.runCatch(plugin, `${this.serverType}disable`) + this.unregistryCommand(plugin) + this.unregistryListener(plugin) }) }