|
|
@@ -1,6 +1,5 @@
|
|
|
const debug = require('debug')('crowi:plugins:PluginService');
|
|
|
const PluginUtils = require('./plugin-utils');
|
|
|
-const PluginLoaderV2 = require('./plugin-loader-v2.model');
|
|
|
|
|
|
class PluginService {
|
|
|
|
|
|
@@ -8,19 +7,18 @@ class PluginService {
|
|
|
this.crowi = crowi;
|
|
|
this.app = app;
|
|
|
this.pluginUtils = new PluginUtils();
|
|
|
- this.pluginLoaderV2 = new PluginLoaderV2();
|
|
|
}
|
|
|
|
|
|
loadPlugins() {
|
|
|
let self = this;
|
|
|
- this.pluginUtils.listPluginNames(this.crowi.rootDir)
|
|
|
- .map(function(name) {
|
|
|
- self.loadPlugin(name);
|
|
|
+ this.pluginUtils.generatePluginDefinitions(this.crowi.rootDir)
|
|
|
+ .map((definition) => {
|
|
|
+ self.loadPlugin(definition);
|
|
|
});
|
|
|
}
|
|
|
|
|
|
- loadPlugin(name) {
|
|
|
- const meta = require(name);
|
|
|
+ loadPlugin(definition) {
|
|
|
+ const meta = definition.meta;
|
|
|
|
|
|
// v1 is deprecated
|
|
|
if (1 === meta.pluginSchemaVersion) {
|
|
|
@@ -30,8 +28,11 @@ class PluginService {
|
|
|
|
|
|
// v2
|
|
|
if (2 === meta.pluginSchemaVersion) {
|
|
|
- this.pluginLoaderV2.load(name, this.crowi, this.app);
|
|
|
- return;
|
|
|
+ debug(`load plugin '${definition.name}'`);
|
|
|
+
|
|
|
+ definition.entries.forEach((entry) => {
|
|
|
+ entry(this.crowi, this.app);
|
|
|
+ });
|
|
|
}
|
|
|
}
|
|
|
}
|