-
Notifications
You must be signed in to change notification settings - Fork 5
/
index.js
81 lines (64 loc) · 3.22 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
'use strict';
const AwesomeModule = require('awesome-module');
const Dependency = AwesomeModule.AwesomeModuleDependency;
const path = require('path');
const glob = require('glob-all');
const FRONTEND_JS_PATH = __dirname + '/frontend/app/';
const MODULE_NAME = 'admin';
const AWESOME_MODULE_NAME = 'linagora.esn.' + MODULE_NAME;
const adminModule = new AwesomeModule(AWESOME_MODULE_NAME, {
dependencies: [
new Dependency(Dependency.TYPE_NAME, 'linagora.esn.core.webserver.wrapper', 'webserver-wrapper'),
new Dependency(Dependency.TYPE_NAME, 'linagora.esn.core.esn-config', 'esn-config'),
new Dependency(Dependency.TYPE_NAME, 'linagora.esn.core.email', 'email'),
new Dependency(Dependency.TYPE_NAME, 'linagora.esn.core.auth', 'auth'),
new Dependency(Dependency.TYPE_NAME, 'linagora.esn.core.logger', 'logger'),
new Dependency(Dependency.TYPE_NAME, 'linagora.esn.core.webserver.middleware.domain', 'domainMiddleware'),
new Dependency(Dependency.TYPE_NAME, 'linagora.esn.core.webserver.middleware.authorization', 'authorizationMW'),
new Dependency(Dependency.TYPE_NAME, 'linagora.esn.core.webserver.middleware.configuration', 'configurationMW'),
new Dependency(Dependency.TYPE_NAME, 'linagora.esn.core.webserver.middleware.helper', 'helperMW'),
new Dependency(Dependency.TYPE_NAME, 'linagora.esn.core.webserver.middleware.platformadmins', 'platformadminsMW'),
new Dependency(Dependency.TYPE_NAME, 'linagora.esn.core.i18n', 'i18n'),
new Dependency(Dependency.TYPE_NAME, 'linagora.esn.jobqueue', 'jobqueue'),
new Dependency(Dependency.TYPE_NAME, 'linagora.esn.core.elasticsearch', 'elasticsearch'),
new Dependency(Dependency.TYPE_NAME, 'linagora.esn.core.user', 'user'),
new Dependency(Dependency.TYPE_NAME, 'linagora.esn.core.esn-config', 'esn-config'),
new Dependency(Dependency.TYPE_NAME, 'linagora.esn.core.ldap', 'ldap')
],
states: {
lib: function(dependencies, callback) {
const libModule = require('./backend/lib')(dependencies);
const api = require('./backend/webserver/api')(dependencies);
const lib = {
api,
lib: libModule
};
return callback(null, lib);
},
deploy: function(dependencies, callback) {
const app = require('./backend/webserver/application')(dependencies);
app.use('/api', this.api);
const webserverWrapper = dependencies('webserver-wrapper');
const frontendJsFilesFullPath = glob.sync([
FRONTEND_JS_PATH + '**/*.module.js',
FRONTEND_JS_PATH + '**/!(*spec).js'
]);
const frontendJsFilesUri = frontendJsFilesFullPath.map(function(filepath) {
return filepath.replace(FRONTEND_JS_PATH, '');
});
webserverWrapper.injectAngularAppModules(MODULE_NAME, frontendJsFilesUri, [AWESOME_MODULE_NAME], ['esn'], {
localJsFiles: frontendJsFilesFullPath
});
const lessFile = path.join(FRONTEND_JS_PATH, 'app.less');
webserverWrapper.injectLess(MODULE_NAME, [lessFile], 'esn');
webserverWrapper.addApp(MODULE_NAME, app);
const libModule = require('./backend/lib')(dependencies);
libModule.init();
return callback();
},
start: function(dependencies, callback) {
callback();
}
}
});
module.exports = adminModule;