| 12345678910111213141516171819202122232425262728293031323334353637383940 |
- const debug = require('debug')('crowi:plugins:PluginService');
- const PluginUtils = require('./plugin-utils');
- class PluginService {
- constructor(crowi, app) {
- this.crowi = crowi;
- this.app = app;
- this.pluginUtils = new PluginUtils();
- }
- loadPlugins() {
- let self = this;
- this.pluginUtils.generatePluginDefinitions(this.crowi.rootDir)
- .map((definition) => {
- self.loadPlugin(definition);
- });
- }
- loadPlugin(definition) {
- const meta = definition.meta;
- // v1 is deprecated
- if (1 === meta.pluginSchemaVersion) {
- debug('pluginSchemaVersion 1 is deprecated');
- return;
- }
- // v2
- if (2 === meta.pluginSchemaVersion) {
- debug(`load plugin '${definition.name}'`);
- definition.entries.forEach((entry) => {
- entry(this.crowi, this.app);
- });
- }
- }
- }
- module.exports = PluginService;
|