ee-core 2.0.0-beta.2 → 2.0.0-beta.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/index.js +12 -13
- package/{lib → module/app}/application.js +2 -2
- package/{lib → module/app}/baseApp.js +3 -3
- package/{lib → module/app}/eeApp.js +7 -7
- package/module/app/index.js +5 -0
- package/{bin → module/bin}/tools.js +1 -1
- package/{config → module/config}/config.default.js +2 -3
- package/module/const/channel.js +6 -0
- package/{core → module/core}/index.js +0 -2
- package/{core → module/core}/lib/ee.js +0 -2
- package/{core → module/core}/lib/loader/context_loader.js +2 -2
- package/{core → module/core}/lib/loader/ee_loader.js +5 -5
- package/{core → module/core}/lib/loader/file_loader.js +6 -6
- package/{core → module/core}/lib/loader/mixin/addon.js +1 -1
- package/{core → module/core}/lib/loader/mixin/config.js +1 -1
- package/{core → module/core}/lib/loader/mixin/controller.js +8 -8
- package/module/core/lib/utils/base_context_class.js +34 -0
- package/module/exception/index.js +75 -6
- package/module/httpclient/index.js +2 -2
- package/module/jobs/baseJobClass.js +16 -0
- package/module/jobs/child/app.js +53 -13
- package/module/jobs/child/forkProcess.js +33 -76
- package/module/jobs/child/index.js +69 -26
- package/module/jobs/childPool/app.js +68 -0
- package/module/jobs/childPool/forkProcess.js +81 -0
- package/module/jobs/childPool/index.js +71 -0
- package/module/jobs/childPool/pool.js +67 -0
- package/module/jobs/index.js +5 -54
- package/module/jobs/renderer/loadView.js +1 -1
- package/module/jobs/unification.js +64 -0
- package/module/loader/index.js +36 -14
- package/module/log/logger.js +1 -1
- package/module/message/childMessage.js +31 -0
- package/module/message/index.js +17 -9
- package/{utils → module/oldUtils}/index.js +6 -29
- package/module/{utils/ps.js → ps/index.js} +45 -0
- package/module/service/index.js +34 -0
- package/module/socket/httpServer.js +4 -3
- package/module/socket/io.js +2 -2
- package/module/socket/ipcServer.js +4 -7
- package/module/socket/socketClient.js +2 -5
- package/module/socket/socketServer.js +4 -6
- package/module/storage/jsondbStorage.js +1 -1
- package/module/storage/sqliteStorage.js +1 -1
- package/{tools → module/tools}/encrypt.js +10 -10
- package/{tools → module/tools}/replaceDist.js +6 -6
- package/module/utils/helper.js +0 -1
- package/module/utils/index.js +2 -36
- package/package.json +3 -2
- package/module/message/ipcMain.js +0 -160
- package/module/message/ipcRender.js +0 -0
- /package/{addon → module/addon}/window/index.js +0 -0
- /package/{lib → module/app}/appLoader.js +0 -0
- /package/{core/lib/utils/base_context_class.js → module/controller/index.js} +0 -0
- /package/{core → module/core}/lib/loader/mixin/service.js +0 -0
- /package/{core → module/core}/lib/utils/function.js +0 -0
- /package/{core → module/core}/lib/utils/index.js +0 -0
- /package/{core → module/core}/lib/utils/sequencify.js +0 -0
- /package/{core → module/core}/lib/utils/timing.js +0 -0
package/module/loader/index.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
const is = require('is-type-of');
|
|
2
2
|
const fs = require('fs');
|
|
3
3
|
const path = require('path');
|
|
4
|
-
const UtilsCore = require('
|
|
5
|
-
const Ps = require('../
|
|
4
|
+
const UtilsCore = require('../core/lib/utils');
|
|
5
|
+
const Ps = require('../ps');
|
|
6
6
|
const Log = require('../log');
|
|
7
7
|
|
|
8
8
|
module.exports = {
|
|
@@ -23,7 +23,7 @@ module.exports = {
|
|
|
23
23
|
|
|
24
24
|
filepath = filepath && this.resolveModule(filepath);
|
|
25
25
|
if (!fs.existsSync(filepath)) {
|
|
26
|
-
let errorMsg = `[ee-core] [
|
|
26
|
+
let errorMsg = `[ee-core] [loader/index] loadOneFile ${filepath} does not exist`;
|
|
27
27
|
Log.coreLogger.error(errorMsg);
|
|
28
28
|
throw new Error(errorMsg);
|
|
29
29
|
}
|
|
@@ -36,26 +36,48 @@ module.exports = {
|
|
|
36
36
|
},
|
|
37
37
|
|
|
38
38
|
/**
|
|
39
|
-
* 加载
|
|
39
|
+
* 加载js文件
|
|
40
40
|
*
|
|
41
41
|
* @param {String} filepath - fullpath
|
|
42
|
-
* @
|
|
43
|
-
* @return {Object} exports
|
|
42
|
+
* @return {Any} exports
|
|
44
43
|
* @since 1.0.0
|
|
45
44
|
*/
|
|
46
|
-
|
|
45
|
+
loadJsFile (filepath) {
|
|
47
46
|
if (!fs.existsSync(filepath)) {
|
|
48
|
-
let
|
|
49
|
-
Log.coreLogger.error(
|
|
47
|
+
let errMsg = `[ee-core] [loader] loadJobFile ${filepath} does not exist`;
|
|
48
|
+
Log.coreLogger.error(errMsg);
|
|
49
|
+
return;
|
|
50
50
|
}
|
|
51
51
|
|
|
52
52
|
const ret = UtilsCore.loadFile(filepath);
|
|
53
|
-
if (is.function(ret) && !is.class(ret) && !UtilsCore.isBytecodeClass(ret)) {
|
|
54
|
-
ret = ret(...inject);
|
|
55
|
-
}
|
|
56
53
|
return ret;
|
|
57
54
|
},
|
|
58
55
|
|
|
56
|
+
/**
|
|
57
|
+
* 加载并运行js文件
|
|
58
|
+
*
|
|
59
|
+
* @param {String} filepath - fullpath
|
|
60
|
+
* @param {Array} inject - pass rest arguments into the function when invoke
|
|
61
|
+
* @return {Any}
|
|
62
|
+
* @since 1.0.0
|
|
63
|
+
*/
|
|
64
|
+
execJsFile (filepath, ...inject) {
|
|
65
|
+
if (!fs.existsSync(filepath)) {
|
|
66
|
+
let errMsg = `[ee-core] [loader] loadJobFile ${filepath} does not exist`;
|
|
67
|
+
Log.coreLogger.error(errMsg);
|
|
68
|
+
return;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
let ret = UtilsCore.loadFile(filepath);
|
|
72
|
+
if (is.class(ret) || UtilsCore.isBytecodeClass(ret)) {
|
|
73
|
+
ret = new ret(inject);
|
|
74
|
+
} else if (is.function(ret)) {
|
|
75
|
+
ret = ret(inject);
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
return ret;
|
|
79
|
+
},
|
|
80
|
+
|
|
59
81
|
/**
|
|
60
82
|
* 模块的绝对路径
|
|
61
83
|
* @param {String} filepath - fullpath
|
|
@@ -75,7 +97,7 @@ module.exports = {
|
|
|
75
97
|
|
|
76
98
|
if (!fs.existsSync(filepath) && !fs.existsSync(fullpath)) {
|
|
77
99
|
let files = { filepath, fullpath }
|
|
78
|
-
Log.coreLogger.warn(`[ee-core] [
|
|
100
|
+
Log.coreLogger.warn(`[ee-core] [loader] resolveModule unknow filepath: ${files}`)
|
|
79
101
|
return undefined;
|
|
80
102
|
}
|
|
81
103
|
}
|
|
@@ -99,7 +121,7 @@ module.exports = {
|
|
|
99
121
|
|
|
100
122
|
fullpath = this.resolveModule(filepath);
|
|
101
123
|
if (!fs.existsSync(fullpath)) {
|
|
102
|
-
let errorMsg = `[ee-core] [
|
|
124
|
+
let errorMsg = `[ee-core] [loader] requireModule filepath: ${filepath} does not exist`;
|
|
103
125
|
Log.coreLogger.error(errorMsg);
|
|
104
126
|
}
|
|
105
127
|
const ret = UtilsCore.loadFile(fullpath);
|
package/module/log/logger.js
CHANGED
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
const Channel = require('../const/channel');
|
|
2
|
+
|
|
3
|
+
class ChildMessage {
|
|
4
|
+
constructor() {
|
|
5
|
+
// ...
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* 向主进程发消息
|
|
10
|
+
*/
|
|
11
|
+
sendToMain(eventName, params = {}) {
|
|
12
|
+
let message = {
|
|
13
|
+
channel: Channel.process.sendToMain,
|
|
14
|
+
event: eventName,
|
|
15
|
+
data: params,
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
return process.send(message);
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* 进程退出
|
|
23
|
+
*/
|
|
24
|
+
exit(code = 0) {
|
|
25
|
+
return process.exit(code);
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
module.exports = ChildMessage;
|
package/module/message/index.js
CHANGED
|
@@ -1,13 +1,21 @@
|
|
|
1
|
-
const
|
|
1
|
+
const ChildMessage = require('./childMessage');
|
|
2
|
+
const EEChildMessage = Symbol('EeCore#Module#ChildMessage');
|
|
2
3
|
|
|
3
|
-
const
|
|
4
|
+
const message = {
|
|
4
5
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
6
|
+
/**
|
|
7
|
+
* childMessage
|
|
8
|
+
*/
|
|
9
|
+
get childMessage() {
|
|
10
|
+
if (!this[EEChildMessage]) {
|
|
11
|
+
this[EEChildMessage] = new ChildMessage();
|
|
12
|
+
}
|
|
8
13
|
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
}
|
|
14
|
+
return this[EEChildMessage] || null;
|
|
15
|
+
},
|
|
12
16
|
|
|
13
|
-
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
module.exports = message;
|
|
@@ -3,13 +3,12 @@
|
|
|
3
3
|
*/
|
|
4
4
|
|
|
5
5
|
const path = require('path');
|
|
6
|
-
const
|
|
7
|
-
const
|
|
8
|
-
const
|
|
9
|
-
const
|
|
10
|
-
const
|
|
11
|
-
const
|
|
12
|
-
const Constants = require('../module/const');
|
|
6
|
+
const UtilsJson = require('../utils/json');
|
|
7
|
+
const UtilsPs = require('../ps');
|
|
8
|
+
const UtilsHelper = require('../utils/helper');
|
|
9
|
+
const Copy = require('../utils/copyto');
|
|
10
|
+
const Storage = require('../storage');
|
|
11
|
+
const Constants = require('../const');
|
|
13
12
|
|
|
14
13
|
/**
|
|
15
14
|
* other module
|
|
@@ -105,25 +104,3 @@ exports.getSocketPort = function() {
|
|
|
105
104
|
exports.getSocketChannel = function() {
|
|
106
105
|
return Constants.socketIo.channel;
|
|
107
106
|
}
|
|
108
|
-
|
|
109
|
-
/**
|
|
110
|
-
* 获取 额外资源目录
|
|
111
|
-
*/
|
|
112
|
-
exports.getExtraResourcesDir = function() {
|
|
113
|
-
const execDir = this.getExecDir();
|
|
114
|
-
|
|
115
|
-
// 资源路径不同
|
|
116
|
-
let dir = '';
|
|
117
|
-
if (config.isPackaged) {
|
|
118
|
-
// 打包后 execDir为 应用程序 exe\dmg\dep软件所在目录;打包前该值是项目根目录
|
|
119
|
-
// windows和MacOs不一样
|
|
120
|
-
dir = path.join(execDir, "resources", "extraResources");
|
|
121
|
-
if (eis.macOS()) {
|
|
122
|
-
dir = path.join(execDir, "..", "Resources", "extraResources");
|
|
123
|
-
}
|
|
124
|
-
} else {
|
|
125
|
-
// 打包前
|
|
126
|
-
dir = path.join(execDir, "build", "extraResources");
|
|
127
|
-
}
|
|
128
|
-
return dir;
|
|
129
|
-
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
const path = require('path');
|
|
2
|
+
const eis = require('electron-is');
|
|
2
3
|
|
|
3
4
|
/**
|
|
4
5
|
* 当前进程的所有env
|
|
@@ -125,6 +126,30 @@ exports.getElectronDir = function() {
|
|
|
125
126
|
return process.env.EE_BASE_DIR;
|
|
126
127
|
}
|
|
127
128
|
|
|
129
|
+
/**
|
|
130
|
+
* 获取 额外资源目录
|
|
131
|
+
*/
|
|
132
|
+
exports.getExtraResourcesDir = function() {
|
|
133
|
+
const execDir = this.getExecDir();
|
|
134
|
+
const isPackaged = this.isPackaged();
|
|
135
|
+
|
|
136
|
+
|
|
137
|
+
// 资源路径不同
|
|
138
|
+
let dir = '';
|
|
139
|
+
if (isPackaged) {
|
|
140
|
+
// 打包后 execDir为 应用程序 exe\dmg\dep软件所在目录;打包前该值是项目根目录
|
|
141
|
+
// windows和MacOs不一样
|
|
142
|
+
dir = path.join(execDir, "resources", "extraResources");
|
|
143
|
+
if (eis.macOS()) {
|
|
144
|
+
dir = path.join(execDir, "..", "Resources", "extraResources");
|
|
145
|
+
}
|
|
146
|
+
} else {
|
|
147
|
+
// 打包前
|
|
148
|
+
dir = path.join(execDir, "build", "extraResources");
|
|
149
|
+
}
|
|
150
|
+
return dir;
|
|
151
|
+
}
|
|
152
|
+
|
|
128
153
|
/**
|
|
129
154
|
* 获取 appUserData目录
|
|
130
155
|
*/
|
|
@@ -193,4 +218,24 @@ exports.isEncrypted = function () {
|
|
|
193
218
|
*/
|
|
194
219
|
exports.isHotReload = function () {
|
|
195
220
|
return process.env.HOT_RELOAD === 'true';
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
/**
|
|
224
|
+
* 进程退出
|
|
225
|
+
*/
|
|
226
|
+
exports.exit = function(code = 0) {
|
|
227
|
+
return process.exit(code);
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
/**
|
|
231
|
+
* 格式化message
|
|
232
|
+
*/
|
|
233
|
+
exports.makeMessage = function(msg = {}) {
|
|
234
|
+
let message = Object.assign({
|
|
235
|
+
channel: '',
|
|
236
|
+
event: '',
|
|
237
|
+
data: {}
|
|
238
|
+
}, msg);
|
|
239
|
+
|
|
240
|
+
return message;
|
|
196
241
|
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* BaseContextClass is a base class that can be extended,
|
|
5
|
+
* it's instantiated in context level,
|
|
6
|
+
* {@link Helper}, {@link Service} is extending it.
|
|
7
|
+
*/
|
|
8
|
+
class BaseContextClass {
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* @class
|
|
12
|
+
* @param {Context} ctx - context instance
|
|
13
|
+
* @since 1.0.0
|
|
14
|
+
*/
|
|
15
|
+
constructor(ctx) {
|
|
16
|
+
/**
|
|
17
|
+
* @member {Application} BaseContextClass#app
|
|
18
|
+
* @since 1.0.0
|
|
19
|
+
*/
|
|
20
|
+
this.app = ctx;
|
|
21
|
+
/**
|
|
22
|
+
* @member {Config} BaseContextClass#config
|
|
23
|
+
* @since 1.0.0
|
|
24
|
+
*/
|
|
25
|
+
this.config = ctx.config;
|
|
26
|
+
/**
|
|
27
|
+
* @member {Service} BaseContextClass#service
|
|
28
|
+
* @since 1.0.0
|
|
29
|
+
*/
|
|
30
|
+
this.service = ctx.service;
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
module.exports = BaseContextClass;
|
|
@@ -9,6 +9,7 @@ const https = require('https');
|
|
|
9
9
|
const fs = require('fs');
|
|
10
10
|
const path = require('path');
|
|
11
11
|
const _ = require('lodash');
|
|
12
|
+
const Log = require('../log');
|
|
12
13
|
|
|
13
14
|
/**
|
|
14
15
|
* http server
|
|
@@ -60,16 +61,16 @@ class HttpServer {
|
|
|
60
61
|
})
|
|
61
62
|
.use(this.dispatch);
|
|
62
63
|
|
|
63
|
-
let msg = '[ee-core
|
|
64
|
+
let msg = '[ee-core] [socket/httpServer] server is: ' + url;
|
|
64
65
|
if (isHttps) {
|
|
65
66
|
https.createServer(sslOptions, koaApp.callback()).listen(httpServer.port, (err) => {
|
|
66
67
|
msg = err ? err : msg;
|
|
67
|
-
|
|
68
|
+
Log.coreLogger.info(msg);
|
|
68
69
|
});
|
|
69
70
|
} else {
|
|
70
71
|
koaApp.listen(httpServer.port, (e) => {
|
|
71
72
|
msg = e ? e : msg;
|
|
72
|
-
|
|
73
|
+
Log.coreLogger.info(msg);
|
|
73
74
|
});
|
|
74
75
|
}
|
|
75
76
|
}
|
package/module/socket/io.js
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
const IoServer = require('socket.io');
|
|
4
4
|
const IoClient = require('socket.io-client');
|
|
5
5
|
//const socketServer = require('./socketServer');
|
|
6
|
-
const socketClient = require('./socketClient');
|
|
6
|
+
// const socketClient = require('./socketClient');
|
|
7
7
|
const Koa = require('koa');
|
|
8
8
|
|
|
9
9
|
const EeSocket = {
|
|
@@ -11,7 +11,7 @@ const EeSocket = {
|
|
|
11
11
|
//return socketServer.getInstance();
|
|
12
12
|
},
|
|
13
13
|
getClient: () => {
|
|
14
|
-
return socketClient.getInstance();
|
|
14
|
+
//return socketClient.getInstance();
|
|
15
15
|
}
|
|
16
16
|
}
|
|
17
17
|
|
|
@@ -1,24 +1,21 @@
|
|
|
1
1
|
const debug = require('debug')('ee-core:ipcServer');
|
|
2
|
-
const EggConsoleLogger = require('egg-logger').EggConsoleLogger;
|
|
3
2
|
const is = require('is-type-of');
|
|
4
3
|
const { ipcMain } = require('electron');
|
|
5
4
|
const path = require('path');
|
|
6
5
|
const fs = require('fs');
|
|
7
6
|
const globby = require('globby');
|
|
8
|
-
const Utils = require('
|
|
7
|
+
const Utils = require('../core/lib/utils');
|
|
9
8
|
const Wrap = require('../utils/wrap');
|
|
9
|
+
const Log = require('../log');
|
|
10
10
|
|
|
11
11
|
class IpcServer {
|
|
12
12
|
constructor (app) {
|
|
13
|
-
|
|
14
13
|
this.app = app;
|
|
15
|
-
this.consoleLogger = new EggConsoleLogger();
|
|
16
|
-
this.consoleLogger.info('[ee-core:socket:ipcMain] start ipcMain');
|
|
17
14
|
this.register();
|
|
18
15
|
}
|
|
19
16
|
|
|
20
17
|
register () {
|
|
21
|
-
|
|
18
|
+
console.log('[ee-core] [socket/IpcServer] register channels');
|
|
22
19
|
|
|
23
20
|
const self = this;
|
|
24
21
|
// 遍历方法
|
|
@@ -78,7 +75,7 @@ class IpcServer {
|
|
|
78
75
|
|
|
79
76
|
return fn;
|
|
80
77
|
} catch (err) {
|
|
81
|
-
|
|
78
|
+
Log.coreLogger.error('[ee-core] [socket/IpcServer] throw error:', err);
|
|
82
79
|
}
|
|
83
80
|
return null;
|
|
84
81
|
}
|
|
@@ -3,19 +3,16 @@
|
|
|
3
3
|
const assert = require('assert');
|
|
4
4
|
const IoClient = require('socket.io-client');
|
|
5
5
|
const Constants = require('../const');
|
|
6
|
-
const EggConsoleLogger = require('egg-logger').EggConsoleLogger;
|
|
7
6
|
const Storage = require('../storage');
|
|
8
7
|
|
|
9
8
|
class SocketClient {
|
|
10
9
|
constructor (port) {
|
|
11
|
-
this.consoleLogger = new EggConsoleLogger();
|
|
12
10
|
port = port ? parseInt(port) : this.getSocketcPort();
|
|
13
11
|
|
|
14
12
|
assert(typeof port === 'number', 'port required, and must be a number');
|
|
15
|
-
this.consoleLogger.info('[ee-core:socket:client] start client');
|
|
16
13
|
|
|
17
|
-
const url = 'http://
|
|
18
|
-
|
|
14
|
+
const url = 'http://localhost:' + port;
|
|
15
|
+
console.log('[ee-core] [socket/socketClient] url:', url);
|
|
19
16
|
this.client = IoClient(url);
|
|
20
17
|
}
|
|
21
18
|
|
|
@@ -2,10 +2,10 @@
|
|
|
2
2
|
|
|
3
3
|
const assert = require('assert');
|
|
4
4
|
const { Server } = require('socket.io');
|
|
5
|
-
const EggConsoleLogger = require('egg-logger').EggConsoleLogger;
|
|
6
5
|
const is = require('is-type-of');
|
|
7
6
|
const Storage = require('../storage');
|
|
8
7
|
const Constants = require('../const');
|
|
8
|
+
const Log = require('../log');
|
|
9
9
|
|
|
10
10
|
/**
|
|
11
11
|
* socket server
|
|
@@ -14,7 +14,6 @@ class SocketServer {
|
|
|
14
14
|
constructor (app) {
|
|
15
15
|
this.app = app;
|
|
16
16
|
const options = this.app.config.socketServer;
|
|
17
|
-
this.consoleLogger = new EggConsoleLogger();
|
|
18
17
|
|
|
19
18
|
if (!options.enable) {
|
|
20
19
|
return;
|
|
@@ -22,7 +21,7 @@ class SocketServer {
|
|
|
22
21
|
|
|
23
22
|
let port = process.env.EE_SOCKET_PORT ? parseInt(process.env.EE_SOCKET_PORT) : parseInt(this.getSocketPort());
|
|
24
23
|
assert(typeof port === 'number', 'socekt port required, and must be a number');
|
|
25
|
-
this.consoleLogger.info('[ee-core
|
|
24
|
+
this.consoleLogger.info('[ee-core] [socket/socketServer] port is:', port);
|
|
26
25
|
|
|
27
26
|
// let opt = Object.assign({}, options);
|
|
28
27
|
// delete opt.enable;
|
|
@@ -32,11 +31,10 @@ class SocketServer {
|
|
|
32
31
|
|
|
33
32
|
connec () {
|
|
34
33
|
const self = this;
|
|
35
|
-
this.consoleLogger.info('[ee-core:socket:server] connection .....');
|
|
36
34
|
this.io.on('connection', (socket) => {
|
|
37
35
|
const channel = Constants.socketIo.channel.partySoftware;
|
|
38
36
|
socket.on(channel, async (message, callback) => {
|
|
39
|
-
|
|
37
|
+
console.log('[ee-core] [socket/socketServer] socket id:' + socket.id + ' message cmd: ' + message.cmd);
|
|
40
38
|
|
|
41
39
|
try {
|
|
42
40
|
// 找函数
|
|
@@ -57,7 +55,7 @@ class SocketServer {
|
|
|
57
55
|
const result = await fn.call(self.app, args);
|
|
58
56
|
callback(result);
|
|
59
57
|
} catch (err) {
|
|
60
|
-
|
|
58
|
+
Log.coreLogger.error('[ee-core] [socket/socketServer] throw error:', err);
|
|
61
59
|
}
|
|
62
60
|
});
|
|
63
61
|
});
|
|
@@ -6,7 +6,7 @@ const FileSync = require('./jsondb/adapters/FileSync');
|
|
|
6
6
|
const _ = require('lodash');
|
|
7
7
|
const Constants = require('../const');
|
|
8
8
|
const Helper = require('../utils/helper');
|
|
9
|
-
const Ps = require('../
|
|
9
|
+
const Ps = require('../ps');
|
|
10
10
|
|
|
11
11
|
class JsondbStorage {
|
|
12
12
|
constructor (name, opt = {}) {
|
|
@@ -5,7 +5,7 @@ const fs = require('fs');
|
|
|
5
5
|
const path = require('path');
|
|
6
6
|
const Database = require('better-sqlite3');
|
|
7
7
|
const Helper = require('../utils/helper');
|
|
8
|
-
const Ps = require('../
|
|
8
|
+
const Ps = require('../ps');
|
|
9
9
|
|
|
10
10
|
class SqliteStorage {
|
|
11
11
|
constructor (name, opt = {}) {
|
|
@@ -7,7 +7,7 @@ const is = require('is-type-of');
|
|
|
7
7
|
const bytenode = require('bytenode');
|
|
8
8
|
const crypto = require('crypto');
|
|
9
9
|
const JavaScriptObfuscator = require('javascript-obfuscator');
|
|
10
|
-
const
|
|
10
|
+
const UtilsJson = require('../utils/json');
|
|
11
11
|
|
|
12
12
|
class Encrypt {
|
|
13
13
|
constructor() {
|
|
@@ -41,20 +41,20 @@ class Encrypt {
|
|
|
41
41
|
this.dirs.push(directory[i]);
|
|
42
42
|
}
|
|
43
43
|
}
|
|
44
|
-
console.log('[ee-core] [encrypt] dirs:', this.dirs);
|
|
44
|
+
console.log('[ee-core] [tools/encrypt] dirs:', this.dirs);
|
|
45
45
|
}
|
|
46
46
|
|
|
47
47
|
/**
|
|
48
48
|
* 备份 electron 目录代码
|
|
49
49
|
*/
|
|
50
50
|
backup () {
|
|
51
|
-
console.log('[ee-core] [encrypt] backup start');
|
|
51
|
+
console.log('[ee-core] [tools/encrypt] backup start');
|
|
52
52
|
|
|
53
53
|
for (let i = 0; i < this.dirs.length; i++) {
|
|
54
54
|
// check code dir
|
|
55
55
|
let codeDirPath = path.join(this.basePath, this.dirs[i]);
|
|
56
56
|
if (!fs.existsSync(codeDirPath)) {
|
|
57
|
-
console.log('[ee-core] [encrypt] ERROR: backup %s is not exist', codeDirPath);
|
|
57
|
+
console.log('[ee-core] [tools/encrypt] ERROR: backup %s is not exist', codeDirPath);
|
|
58
58
|
return
|
|
59
59
|
}
|
|
60
60
|
|
|
@@ -64,7 +64,7 @@ class Encrypt {
|
|
|
64
64
|
this.rmBackup(targetDir);
|
|
65
65
|
|
|
66
66
|
// copy
|
|
67
|
-
console.log('[ee-core] [encrypt] backup target Dir:', targetDir);
|
|
67
|
+
console.log('[ee-core] [tools/encrypt] backup target Dir:', targetDir);
|
|
68
68
|
if (!fs.existsSync(targetDir)) {
|
|
69
69
|
this.mkdir(targetDir);
|
|
70
70
|
this.chmodPath(targetDir, '777');
|
|
@@ -72,7 +72,7 @@ class Encrypt {
|
|
|
72
72
|
|
|
73
73
|
fsPro.copySync(codeDirPath, targetDir);
|
|
74
74
|
}
|
|
75
|
-
console.log('[ee-core] [encrypt] backup end');
|
|
75
|
+
console.log('[ee-core] [tools/encrypt] backup end');
|
|
76
76
|
return true;
|
|
77
77
|
}
|
|
78
78
|
|
|
@@ -86,7 +86,7 @@ class Encrypt {
|
|
|
86
86
|
const content = {
|
|
87
87
|
nameMap: {}
|
|
88
88
|
};
|
|
89
|
-
|
|
89
|
+
UtilsJson.writeSync(this.tmpFile, content);
|
|
90
90
|
}
|
|
91
91
|
}
|
|
92
92
|
|
|
@@ -97,13 +97,13 @@ class Encrypt {
|
|
|
97
97
|
* 加密代码
|
|
98
98
|
*/
|
|
99
99
|
encrypt () {
|
|
100
|
-
console.log('[ee-core] [encrypt] start ciphering');
|
|
100
|
+
console.log('[ee-core] [tools/encrypt] start ciphering');
|
|
101
101
|
for (let i = 0; i < this.dirs.length; i++) {
|
|
102
102
|
let codeDirPath = path.join(this.encryptCodeDir, this.dirs[i]);
|
|
103
103
|
this.loop(codeDirPath);
|
|
104
104
|
}
|
|
105
105
|
|
|
106
|
-
console.log('[ee-core] [encrypt] end ciphering');
|
|
106
|
+
console.log('[ee-core] [tools/encrypt] end ciphering');
|
|
107
107
|
};
|
|
108
108
|
|
|
109
109
|
/**
|
|
@@ -183,7 +183,7 @@ class Encrypt {
|
|
|
183
183
|
*/
|
|
184
184
|
rmBackup (dir) {
|
|
185
185
|
if (fs.existsSync(dir)) {
|
|
186
|
-
console.log('[ee-core] [encrypt] clean old directory:', dir);
|
|
186
|
+
console.log('[ee-core] [tools/encrypt] clean old directory:', dir);
|
|
187
187
|
fsPro.removeSync(dir);
|
|
188
188
|
}
|
|
189
189
|
return;
|
|
@@ -14,7 +14,7 @@ const fsPro = require('fs-extra');
|
|
|
14
14
|
* 执行
|
|
15
15
|
*/
|
|
16
16
|
run () {
|
|
17
|
-
console.log('[ee-core] [
|
|
17
|
+
console.log('[ee-core] [tools/rd] 开始移动资源');
|
|
18
18
|
const homeDir = process.cwd();
|
|
19
19
|
|
|
20
20
|
// argv
|
|
@@ -30,7 +30,7 @@ const fsPro = require('fs-extra');
|
|
|
30
30
|
try {
|
|
31
31
|
return fs.statSync(filePath).isFile();
|
|
32
32
|
} catch (err) {
|
|
33
|
-
console.error('[ee-core] [
|
|
33
|
+
console.error('[ee-core] [tools/rd] ERROR ', err);
|
|
34
34
|
return false;
|
|
35
35
|
}
|
|
36
36
|
};
|
|
@@ -39,7 +39,7 @@ const fsPro = require('fs-extra');
|
|
|
39
39
|
const sourceIndexFile = path.join(sourceDir, 'index.html');
|
|
40
40
|
|
|
41
41
|
if (!fileExist(sourceIndexFile)) {
|
|
42
|
-
console.error('[ee-core] [
|
|
42
|
+
console.error('[ee-core] [tools/rd] ERROR 前端资源不存在,请构建!!!');
|
|
43
43
|
return
|
|
44
44
|
}
|
|
45
45
|
|
|
@@ -48,12 +48,12 @@ const fsPro = require('fs-extra');
|
|
|
48
48
|
|
|
49
49
|
// 清空历史资源
|
|
50
50
|
fs.rmdirSync(eeResourceDir, {recursive: true});
|
|
51
|
-
console.log('[ee-core] [
|
|
51
|
+
console.log('[ee-core] [tools/rd] 清空历史资源:', eeResourceDir);
|
|
52
52
|
|
|
53
53
|
fsPro.copySync(sourceDir, eeResourceDir);
|
|
54
|
-
console.log('[ee-core] [
|
|
54
|
+
console.log('[ee-core] [tools/rd] 复制资源到:', eeResourceDir);
|
|
55
55
|
|
|
56
|
-
console.log('[ee-core] [
|
|
56
|
+
console.log('[ee-core] [tools/rd] 结束');
|
|
57
57
|
}
|
|
58
58
|
}
|
|
59
59
|
|
package/module/utils/helper.js
CHANGED
package/module/utils/index.js
CHANGED
|
@@ -1,24 +1,14 @@
|
|
|
1
1
|
const path = require('path');
|
|
2
|
-
const eis = require('electron-is');
|
|
3
2
|
const Storage = require('../storage');
|
|
4
3
|
const Constants = require('../const');
|
|
5
|
-
const Ps = require('
|
|
6
|
-
const Helper = require('./helper');
|
|
4
|
+
const Ps = require('../ps');
|
|
7
5
|
const UtilsJson = require('./json');
|
|
8
|
-
const Copy = require('./copyto');
|
|
9
|
-
|
|
10
|
-
/**
|
|
11
|
-
* other module
|
|
12
|
-
*/
|
|
13
|
-
Copy(Ps)
|
|
14
|
-
.and(Helper)
|
|
15
|
-
.to(exports);
|
|
16
6
|
|
|
17
7
|
/**
|
|
18
8
|
* 获取项目根目录package.json
|
|
19
9
|
*/
|
|
20
10
|
exports.getPackage = function() {
|
|
21
|
-
const json = UtilsJson.readSync(path.join(
|
|
11
|
+
const json = UtilsJson.readSync(path.join(Ps.getHomeDir(), 'package.json'));
|
|
22
12
|
|
|
23
13
|
return json;
|
|
24
14
|
};
|
|
@@ -93,28 +83,4 @@ exports.getSocketChannel = function() {
|
|
|
93
83
|
return Constants.socketIo.channel;
|
|
94
84
|
}
|
|
95
85
|
|
|
96
|
-
/**
|
|
97
|
-
* 获取 额外资源目录
|
|
98
|
-
*/
|
|
99
|
-
exports.getExtraResourcesDir = function() {
|
|
100
|
-
const execDir = this.getExecDir();
|
|
101
|
-
const isPackaged = this.isPackaged();
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
// 资源路径不同
|
|
105
|
-
let dir = '';
|
|
106
|
-
if (isPackaged) {
|
|
107
|
-
// 打包后 execDir为 应用程序 exe\dmg\dep软件所在目录;打包前该值是项目根目录
|
|
108
|
-
// windows和MacOs不一样
|
|
109
|
-
dir = path.join(execDir, "resources", "extraResources");
|
|
110
|
-
if (eis.macOS()) {
|
|
111
|
-
dir = path.join(execDir, "..", "Resources", "extraResources");
|
|
112
|
-
}
|
|
113
|
-
} else {
|
|
114
|
-
// 打包前
|
|
115
|
-
dir = path.join(execDir, "build", "extraResources");
|
|
116
|
-
}
|
|
117
|
-
return dir;
|
|
118
|
-
}
|
|
119
|
-
|
|
120
86
|
|