|
|
@@ -3,34 +3,40 @@ const path = require('path');
|
|
|
const webpack = require('webpack');
|
|
|
const helpers = require('./helpers')
|
|
|
|
|
|
-
|
|
|
class CrowiDev {
|
|
|
|
|
|
/**
|
|
|
* Creates an instance of CrowiDev.
|
|
|
* @param {Crowi} crowi
|
|
|
- * @param {any} server http server
|
|
|
- * @param {any} app express
|
|
|
*
|
|
|
* @memberOf CrowiDev
|
|
|
*/
|
|
|
- constructor(crowi, server, app) {
|
|
|
+ constructor(crowi) {
|
|
|
this.crowi = crowi;
|
|
|
- this.server = server;
|
|
|
- this.app = app;
|
|
|
}
|
|
|
|
|
|
- setupTools() {
|
|
|
- this.setupEasyLiveReload();
|
|
|
+ init() {
|
|
|
}
|
|
|
|
|
|
- setupEasyLiveReload() {
|
|
|
+ /**
|
|
|
+ *
|
|
|
+ *
|
|
|
+ * @param {any} server http server
|
|
|
+ * @param {any} app express
|
|
|
+ *
|
|
|
+ * @memberOf CrowiDev
|
|
|
+ */
|
|
|
+ setup(server, app) {
|
|
|
+ this.setupEasyLiveReload(app);
|
|
|
+ }
|
|
|
+
|
|
|
+ setupEasyLiveReload(app) {
|
|
|
if (!helpers.hasProcessFlag('watch')) {
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
const livereload = require('easy-livereload');
|
|
|
- this.app.use(livereload({
|
|
|
+ app.use(livereload({
|
|
|
watchDirs: [
|
|
|
path.join(this.crowi.viewsDir),
|
|
|
path.join(this.crowi.publicDir),
|
|
|
@@ -41,6 +47,17 @@ class CrowiDev {
|
|
|
}));
|
|
|
}
|
|
|
|
|
|
+ loadPlugins(app) {
|
|
|
+ if (process.env.PLUGIN_NAMES_TOBE_LOADED === undefined) {
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ const pluginNames = process.env.PLUGIN_NAMES_TOBE_LOADED.split(',');
|
|
|
+
|
|
|
+ var PluginService = require('../plugins/plugin.service');
|
|
|
+ var pluginService = new PluginService(this.crowi, app);
|
|
|
+ pluginService.loadPlugins(pluginNames);
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
module.exports = CrowiDev
|