ee-core 2.12.0 → 4.0.0
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/app/application.d.ts +5 -0
- package/app/application.js +31 -0
- package/app/boot.d.ts +5 -0
- package/app/boot.js +74 -0
- package/app/dir.d.ts +1 -0
- package/app/dir.js +27 -0
- package/app/events.d.ts +14 -0
- package/app/events.js +56 -0
- package/app/index.d.ts +2 -0
- package/app/index.js +7 -0
- package/config/config_loader.d.ts +13 -0
- package/config/config_loader.js +19 -23
- package/config/default_config.d.ts +95 -0
- package/config/default_config.js +111 -0
- package/config/index.d.ts +28 -0
- package/config/index.js +20 -37
- package/const/channel.d.ts +16 -0
- package/const/channel.js +26 -16
- package/controller/controller_loader.d.ts +9 -0
- package/controller/controller_loader.js +78 -0
- package/controller/index.d.ts +2 -0
- package/controller/index.js +18 -19
- package/core/index.d.ts +2 -0
- package/core/index.js +6 -5
- package/core/loader/file_loader.d.ts +66 -0
- package/core/{lib/loader → loader}/file_loader.js +39 -156
- package/core/utils/index.d.ts +12 -0
- package/core/utils/index.js +83 -0
- package/core/utils/timing.d.ts +22 -0
- package/core/{lib/utils → utils}/timing.js +3 -2
- package/cross/cross.d.ts +19 -0
- package/cross/cross.js +152 -0
- package/cross/crossProcess.d.ts +29 -0
- package/cross/{spawnProcess.js → crossProcess.js} +36 -53
- package/cross/index.d.ts +2 -0
- package/cross/index.js +6 -181
- package/electron/app/index.d.ts +5 -0
- package/electron/app/index.js +38 -54
- package/electron/index.d.ts +3 -0
- package/electron/index.js +13 -17
- package/electron/window/index.d.ts +6 -0
- package/electron/window/index.js +260 -65
- package/exception/index.d.ts +9 -0
- package/exception/index.js +42 -54
- package/html/index.d.ts +1 -0
- package/html/index.js +7 -10
- package/index.d.ts +2 -0
- package/index.js +4 -52
- package/jobs/child/app.d.ts +1 -0
- package/jobs/child/app.js +10 -10
- package/jobs/child/index.d.ts +13 -0
- package/jobs/child/index.js +14 -11
- package/jobs/child/jobProcess.d.ts +16 -0
- package/jobs/child/{forkProcess.js → jobProcess.js} +31 -62
- package/jobs/child-pool/index.d.ts +26 -0
- package/jobs/child-pool/index.js +25 -48
- package/jobs/index.d.ts +3 -0
- package/jobs/index.js +2 -4
- package/jobs/load-balancer/algorithm/index.d.ts +4 -0
- package/jobs/load-balancer/algorithm/minimumConnection.d.ts +2 -0
- package/jobs/load-balancer/algorithm/polling.d.ts +2 -0
- package/jobs/load-balancer/algorithm/random.d.ts +2 -0
- package/jobs/load-balancer/algorithm/specify.d.ts +2 -0
- package/jobs/load-balancer/algorithm/weights.d.ts +2 -0
- package/jobs/load-balancer/algorithm/weightsMinimumConnection.d.ts +2 -0
- package/jobs/load-balancer/algorithm/weightsPolling.d.ts +2 -0
- package/jobs/load-balancer/algorithm/weightsRandom.d.ts +2 -0
- package/jobs/load-balancer/consts.d.ts +8 -0
- package/jobs/load-balancer/index.d.ts +96 -0
- package/jobs/load-balancer/scheduler.d.ts +16 -0
- package/loader/index.d.ts +9 -0
- package/loader/index.js +73 -143
- package/log/index.d.ts +5 -0
- package/log/index.js +74 -57
- package/log/logger.d.ts +2 -0
- package/log/logger.js +75 -80
- package/message/childMessage.d.ts +10 -0
- package/message/childMessage.js +15 -25
- package/message/index.d.ts +3 -0
- package/message/index.js +7 -16
- package/package.json +8 -2
- package/ps/index.d.ts +37 -0
- package/ps/index.js +135 -238
- package/socket/httpServer.d.ts +8 -0
- package/socket/httpServer.js +55 -45
- package/socket/index.d.ts +10 -0
- package/socket/index.js +52 -69
- package/socket/ipcServer.d.ts +9 -0
- package/socket/ipcServer.js +87 -94
- package/socket/socketServer.d.ts +10 -0
- package/socket/socketServer.js +37 -25
- package/storage/index.d.ts +5 -0
- package/storage/index.js +5 -37
- package/storage/sqliteStorage.d.ts +16 -0
- package/storage/sqliteStorage.js +20 -20
- package/tsconfig.json +14 -0
- package/utils/extend.d.ts +2 -0
- package/utils/extend.js +10 -5
- package/utils/helper.d.ts +14 -0
- package/utils/helper.js +39 -53
- package/utils/index.d.ts +10 -0
- package/utils/index.js +47 -40
- package/utils/ip.d.ts +2 -0
- package/utils/ip.js +5 -45
- package/utils/is.d.ts +14 -0
- package/utils/is.js +107 -141
- package/utils/json.d.ts +5 -0
- package/utils/json.js +15 -7
- package/utils/pargv.d.ts +3 -0
- package/utils/pargv.js +5 -1
- package/utils/port/index.d.ts +1 -0
- package/utils/{get-port → port}/index.js +4 -26
- package/utils/wrap.d.ts +4 -0
- package/utils/wrap.js +8 -3
- package/addon/index.js +0 -35
- package/addon/window/index.js +0 -99
- package/bin/tools.js +0 -8
- package/config/cache.js +0 -62
- package/config/config.default.js +0 -331
- package/const/index.js +0 -9
- package/controller/baseContextClass.js +0 -25
- package/core/lib/ee.js +0 -216
- package/core/lib/loader/context_loader.js +0 -106
- package/core/lib/loader/ee_loader.js +0 -435
- package/core/lib/loader/mixin/addon.js +0 -32
- package/core/lib/loader/mixin/config.js +0 -130
- package/core/lib/loader/mixin/controller.js +0 -125
- package/core/lib/loader/mixin/service.js +0 -28
- package/core/lib/utils/base_context_class.js +0 -34
- package/core/lib/utils/function.js +0 -30
- package/core/lib/utils/index.js +0 -133
- package/core/lib/utils/sequencify.js +0 -59
- package/ee/appLoader.js +0 -48
- package/ee/application.js +0 -101
- package/ee/baseApp.js +0 -99
- package/ee/eeApp.js +0 -406
- package/ee/index.js +0 -58
- package/electron/window/winState.js +0 -186
- package/httpclient/index.js +0 -161
- package/jobs/baseJobClass.js +0 -16
- package/jobs/renderer/index.js +0 -141
- package/jobs/renderer/loadView.js +0 -41
- package/jobs/unification.js +0 -64
- package/main/index.js +0 -57
- package/old-utils/index.js +0 -91
- package/services/baseContextClass.js +0 -24
- package/services/index.js +0 -41
- package/socket/io.js +0 -28
- package/storage/jsondb/adapters/Base.js +0 -23
- package/storage/jsondb/adapters/FileSync.js +0 -64
- package/storage/jsondb/main.js +0 -55
- package/storage/jsondbStorage.js +0 -196
- package/utils/co.js +0 -237
- package/utils/copyto.js +0 -161
- package/utils/depd/index.js +0 -538
- package/utils/depd/lib/browser/index.js +0 -77
- package/utils/get-port/index.d.ts +0 -64
- package/utils/time/index.js +0 -20
- package/utils/time/ms.js +0 -162
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
const path = require('path');
|
|
4
|
-
|
|
5
|
-
module.exports = {
|
|
6
|
-
|
|
7
|
-
/**
|
|
8
|
-
* Load app/service
|
|
9
|
-
* @function EeLoader#loadService
|
|
10
|
-
* @param {Object} opt - LoaderOptions
|
|
11
|
-
* @since 1.0.0
|
|
12
|
-
*/
|
|
13
|
-
loadService(opt) {
|
|
14
|
-
this.timing.start('Load Service');
|
|
15
|
-
// 载入到 app.serviceClasses
|
|
16
|
-
opt = Object.assign({
|
|
17
|
-
call: true,
|
|
18
|
-
caseStyle: 'lower',
|
|
19
|
-
fieldClass: 'serviceClasses',
|
|
20
|
-
directory: this.getLoadUnits().map(unit => path.join(unit.path, 'service')), // this.getLoadUnits().map(unit => path.join(unit.path, 'app/service'))
|
|
21
|
-
}, opt);
|
|
22
|
-
|
|
23
|
-
const servicePaths = opt.directory;
|
|
24
|
-
this.loadToContext(servicePaths, 'service', opt);
|
|
25
|
-
this.timing.end('Load Service');
|
|
26
|
-
},
|
|
27
|
-
|
|
28
|
-
};
|
|
@@ -1,34 +0,0 @@
|
|
|
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;
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
const assert = require('assert');
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* A empty function.
|
|
5
|
-
*
|
|
6
|
-
* @return {Function}
|
|
7
|
-
* @public
|
|
8
|
-
*/
|
|
9
|
-
exports.noop = function noop() {};
|
|
10
|
-
|
|
11
|
-
/**
|
|
12
|
-
* Get a function parameter's names.
|
|
13
|
-
*
|
|
14
|
-
* @param {Function} func
|
|
15
|
-
* @param {Boolean} [useCache], default is true
|
|
16
|
-
* @return {Array} names
|
|
17
|
-
*/
|
|
18
|
-
exports.getParamNames = function getParamNames(func, cache) {
|
|
19
|
-
var type = typeof func;
|
|
20
|
-
assert(type === 'function', 'The "func" must be a function. Received type "' + type + '"');
|
|
21
|
-
|
|
22
|
-
cache = cache !== false;
|
|
23
|
-
if (cache && func.__cache_names) {
|
|
24
|
-
return func.__cache_names;
|
|
25
|
-
}
|
|
26
|
-
var str = func.toString();
|
|
27
|
-
var names = str.slice(str.indexOf('(') + 1, str.indexOf(')')).match(/([^\s,]+)/g) || [];
|
|
28
|
-
func.__cache_names = names;
|
|
29
|
-
return names;
|
|
30
|
-
};
|
package/core/lib/utils/index.js
DELETED
|
@@ -1,133 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
require('bytenode');
|
|
4
|
-
const convert = require('koa-convert');
|
|
5
|
-
const is = require('is-type-of');
|
|
6
|
-
const path = require('path');
|
|
7
|
-
const fs = require('fs');
|
|
8
|
-
const co = require('../../../utils/co');
|
|
9
|
-
const BuiltinModule = require('module');
|
|
10
|
-
|
|
11
|
-
// Guard against poorly mocked module constructors.
|
|
12
|
-
const Module = module.constructor.length > 1
|
|
13
|
-
? module.constructor
|
|
14
|
-
/* istanbul ignore next */
|
|
15
|
-
: BuiltinModule;
|
|
16
|
-
|
|
17
|
-
// Module._extensions:
|
|
18
|
-
// '.js': [Function (anonymous)],
|
|
19
|
-
// '.json': [Function (anonymous)],
|
|
20
|
-
// '.node': [Function: func],
|
|
21
|
-
// '.jsc': [Function (anonymous)]
|
|
22
|
-
|
|
23
|
-
module.exports = {
|
|
24
|
-
extensions: Module._extensions,
|
|
25
|
-
|
|
26
|
-
loadFile(filepath) {
|
|
27
|
-
try {
|
|
28
|
-
// if not js module, just return content buffer
|
|
29
|
-
const extname = path.extname(filepath);
|
|
30
|
-
if (extname && !Module._extensions[extname]) {
|
|
31
|
-
return fs.readFileSync(filepath);
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
// require js module
|
|
35
|
-
const obj = require(filepath);
|
|
36
|
-
if (!obj) return obj;
|
|
37
|
-
// it's es module
|
|
38
|
-
if (obj.__esModule) return 'default' in obj ? obj.default : obj;
|
|
39
|
-
return obj;
|
|
40
|
-
} catch (err) {
|
|
41
|
-
err.message = `[ee-core] load file: ${filepath}, error: ${err.message}`;
|
|
42
|
-
throw err;
|
|
43
|
-
}
|
|
44
|
-
},
|
|
45
|
-
|
|
46
|
-
methods: [ 'head', 'options', 'get', 'put', 'patch', 'post', 'delete' ],
|
|
47
|
-
|
|
48
|
-
async callFn(fn, args, ctx) {
|
|
49
|
-
args = args || [];
|
|
50
|
-
if (!is.function(fn)) return;
|
|
51
|
-
if (is.generatorFunction(fn)) fn = co.wrap(fn);
|
|
52
|
-
return ctx ? fn.call(ctx, ...args) : fn(...args);
|
|
53
|
-
},
|
|
54
|
-
|
|
55
|
-
middleware(fn) {
|
|
56
|
-
return is.generatorFunction(fn) ? convert(fn) : fn;
|
|
57
|
-
},
|
|
58
|
-
|
|
59
|
-
getCalleeFromStack(withLine, stackIndex) {
|
|
60
|
-
stackIndex = stackIndex === undefined ? 2 : stackIndex;
|
|
61
|
-
const limit = Error.stackTraceLimit;
|
|
62
|
-
const prep = Error.prepareStackTrace;
|
|
63
|
-
|
|
64
|
-
Error.prepareStackTrace = prepareObjectStackTrace;
|
|
65
|
-
Error.stackTraceLimit = 5;
|
|
66
|
-
|
|
67
|
-
// capture the stack
|
|
68
|
-
const obj = {};
|
|
69
|
-
Error.captureStackTrace(obj);
|
|
70
|
-
let callSite = obj.stack[stackIndex];
|
|
71
|
-
let fileName;
|
|
72
|
-
/* istanbul ignore else */
|
|
73
|
-
if (callSite) {
|
|
74
|
-
fileName = callSite.getFileName();
|
|
75
|
-
/* istanbul ignore if */
|
|
76
|
-
if (fileName && fileName.endsWith('egg-mock/lib/app.js')) {
|
|
77
|
-
// TODO: add test
|
|
78
|
-
callSite = obj.stack[stackIndex + 1];
|
|
79
|
-
fileName = callSite.getFileName();
|
|
80
|
-
}
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
Error.prepareStackTrace = prep;
|
|
84
|
-
Error.stackTraceLimit = limit;
|
|
85
|
-
|
|
86
|
-
/* istanbul ignore if */
|
|
87
|
-
if (!callSite || !fileName) return '<anonymous>';
|
|
88
|
-
if (!withLine) return fileName;
|
|
89
|
-
return `${fileName}:${callSite.getLineNumber()}:${callSite.getColumnNumber()}`;
|
|
90
|
-
},
|
|
91
|
-
|
|
92
|
-
getResolvedFilename(filepath, baseDir) {
|
|
93
|
-
const reg = /[/\\]/g;
|
|
94
|
-
return filepath.replace(baseDir + path.sep, '').replace(reg, '/');
|
|
95
|
-
},
|
|
96
|
-
|
|
97
|
-
/**
|
|
98
|
-
* 字节码类
|
|
99
|
-
*/
|
|
100
|
-
isBytecodeClass (exports) {
|
|
101
|
-
let isClass = false;
|
|
102
|
-
|
|
103
|
-
// 标识
|
|
104
|
-
if (exports.toString().indexOf('[class') != -1) {
|
|
105
|
-
isClass = true;
|
|
106
|
-
}
|
|
107
|
-
// TODO 更严谨的判断,应该加上文件名和路径
|
|
108
|
-
|
|
109
|
-
return isClass;
|
|
110
|
-
},
|
|
111
|
-
|
|
112
|
-
/**
|
|
113
|
-
* 文件类型
|
|
114
|
-
*/
|
|
115
|
-
filePatterns () {
|
|
116
|
-
const files = (process.env.EE_TYPESCRIPT === 'true' && Module._extensions['.ts'])
|
|
117
|
-
? [ '**/*.(js|ts)', '!**/*.d.ts' ]
|
|
118
|
-
: [ '**/*.js','**/*.jsc' ];
|
|
119
|
-
|
|
120
|
-
return files;
|
|
121
|
-
}
|
|
122
|
-
|
|
123
|
-
};
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
/**
|
|
127
|
-
* Capture call site stack from v8.
|
|
128
|
-
* https://github.com/v8/v8/wiki/Stack-Trace-API
|
|
129
|
-
*/
|
|
130
|
-
|
|
131
|
-
function prepareObjectStackTrace(obj, stack) {
|
|
132
|
-
return stack;
|
|
133
|
-
}
|
|
@@ -1,59 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
const debug = require('debug')('ee-core#sequencify');
|
|
4
|
-
|
|
5
|
-
function sequence(tasks, names, results, missing, recursive, nest, optional, parent) {
|
|
6
|
-
names.forEach(function(name) {
|
|
7
|
-
if (results.requires[name]) return;
|
|
8
|
-
|
|
9
|
-
const node = tasks[name];
|
|
10
|
-
|
|
11
|
-
if (!node) {
|
|
12
|
-
if (optional === true) return;
|
|
13
|
-
missing.push(name);
|
|
14
|
-
} else if (nest.includes(name)) {
|
|
15
|
-
nest.push(name);
|
|
16
|
-
recursive.push(nest.slice(0));
|
|
17
|
-
nest.pop(name);
|
|
18
|
-
} else if (node.dependencies.length || node.optionalDependencies.length) {
|
|
19
|
-
nest.push(name);
|
|
20
|
-
if (node.dependencies.length) {
|
|
21
|
-
sequence(tasks, node.dependencies, results, missing, recursive, nest, optional, name);
|
|
22
|
-
}
|
|
23
|
-
if (node.optionalDependencies.length) {
|
|
24
|
-
sequence(tasks, node.optionalDependencies, results, missing, recursive, nest, true, name);
|
|
25
|
-
}
|
|
26
|
-
nest.pop(name);
|
|
27
|
-
}
|
|
28
|
-
if (!optional) {
|
|
29
|
-
results.requires[name] = true;
|
|
30
|
-
debug('task: %s is enabled by %s', name, parent);
|
|
31
|
-
}
|
|
32
|
-
if (!results.sequence.includes(name)) {
|
|
33
|
-
results.sequence.push(name);
|
|
34
|
-
}
|
|
35
|
-
});
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
// tasks: object with keys as task names
|
|
39
|
-
// names: array of task names
|
|
40
|
-
module.exports = function(tasks, names) {
|
|
41
|
-
const results = {
|
|
42
|
-
sequence: [],
|
|
43
|
-
requires: {},
|
|
44
|
-
}; // the final sequence
|
|
45
|
-
const missing = []; // missing tasks
|
|
46
|
-
const recursive = []; // recursive task dependencies
|
|
47
|
-
|
|
48
|
-
sequence(tasks, names, results, missing, recursive, [], false, 'app');
|
|
49
|
-
|
|
50
|
-
if (missing.length || recursive.length) {
|
|
51
|
-
results.sequence = []; // results are incomplete at best, completely wrong at worst, remove them to avoid confusion
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
return {
|
|
55
|
-
sequence: results.sequence.filter(item => results.requires[item]),
|
|
56
|
-
missingTasks: missing,
|
|
57
|
-
recursiveDependencies: recursive,
|
|
58
|
-
};
|
|
59
|
-
};
|
package/ee/appLoader.js
DELETED
|
@@ -1,48 +0,0 @@
|
|
|
1
|
-
const EeLoader = require('../core/index').EeLoader;
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* App Loader
|
|
5
|
-
* @see
|
|
6
|
-
*/
|
|
7
|
-
class AppLoader extends EeLoader {
|
|
8
|
-
|
|
9
|
-
/**
|
|
10
|
-
* loadPlugin first, then loadConfig
|
|
11
|
-
* @since 1.0.0
|
|
12
|
-
*/
|
|
13
|
-
loadConfig() {
|
|
14
|
-
super.loadConfig();
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
/**
|
|
18
|
-
* Load all directories in convention
|
|
19
|
-
* @since 1.0.0
|
|
20
|
-
*/
|
|
21
|
-
load() {
|
|
22
|
-
|
|
23
|
-
// app > plugin
|
|
24
|
-
this.loadService();
|
|
25
|
-
|
|
26
|
-
// app
|
|
27
|
-
this.loadController();
|
|
28
|
-
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
/**
|
|
32
|
-
* load addons
|
|
33
|
-
* @since 1.0.0
|
|
34
|
-
*/
|
|
35
|
-
loadAddons() {
|
|
36
|
-
this.loadAddon();
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
/**
|
|
40
|
-
* load electron modules
|
|
41
|
-
* @since 1.0.0
|
|
42
|
-
*/
|
|
43
|
-
loadElectron() {
|
|
44
|
-
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
module.exports = AppLoader;
|
package/ee/application.js
DELETED
|
@@ -1,101 +0,0 @@
|
|
|
1
|
-
const Exception = require('../exception');
|
|
2
|
-
const { app } = require('electron');
|
|
3
|
-
const path = require('path');
|
|
4
|
-
const debug = require('debug')('ee-core:Appliaction');
|
|
5
|
-
const EeApp = require('./eeApp');
|
|
6
|
-
const Utils = require('../utils');
|
|
7
|
-
const Ps = require('../ps');
|
|
8
|
-
const EE = require('./index');
|
|
9
|
-
|
|
10
|
-
class Appliaction extends EeApp {
|
|
11
|
-
constructor() {
|
|
12
|
-
Exception.start();
|
|
13
|
-
const { env } = process;
|
|
14
|
-
|
|
15
|
-
// initialize mode
|
|
16
|
-
Ps.initMode();
|
|
17
|
-
|
|
18
|
-
let options = {
|
|
19
|
-
env: 'prod',
|
|
20
|
-
serverScope: '',
|
|
21
|
-
type: 'application',
|
|
22
|
-
baseDir: path.join(app.getAppPath(), 'electron'),
|
|
23
|
-
homeDir: app.getAppPath(),
|
|
24
|
-
framework: path.join(app.getAppPath(), 'node_modules', 'ee-core'),
|
|
25
|
-
appName: app.getName(),
|
|
26
|
-
userHome: app.getPath('home'),
|
|
27
|
-
appData: app.getPath('appData'),
|
|
28
|
-
appUserData: app.getPath('userData'),
|
|
29
|
-
appVersion: app.getVersion(),
|
|
30
|
-
isPackaged: app.isPackaged,
|
|
31
|
-
execDir: app.getAppPath(),
|
|
32
|
-
isEncrypted: false
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
// argv
|
|
36
|
-
let hotReload = false;
|
|
37
|
-
for (let i = 0; i < process.argv.length; i++) {
|
|
38
|
-
const tmpArgv = process.argv[i]
|
|
39
|
-
if (tmpArgv.indexOf('--env=') !== -1) {
|
|
40
|
-
options.env = tmpArgv.substring(6);
|
|
41
|
-
}
|
|
42
|
-
if (tmpArgv.indexOf('--hot-reload=') !== -1) {
|
|
43
|
-
hotReload = tmpArgv.substring(13) == 1 ? true : false;
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
// exec directory (exe dmg dep) for prod
|
|
48
|
-
if (options.env == 'prod' && app.isPackaged) {
|
|
49
|
-
options.execDir = path.dirname(app.getPath('exe'));
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
// Todo app.getAppPath() ??? process.cwd()
|
|
53
|
-
// Use encryption, base directory is public/electron
|
|
54
|
-
if (options.env == 'prod' && Utils.isEncrypt(app.getAppPath())) {
|
|
55
|
-
options.baseDir = Ps.getEncryptDir(app.getAppPath());
|
|
56
|
-
options.isEncrypted = true;
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
// normalize env
|
|
60
|
-
env.EE_APP_NAME = options.appName;
|
|
61
|
-
env.EE_APP_VERSION = options.appVersion;
|
|
62
|
-
env.EE_HOME = options.homeDir;
|
|
63
|
-
env.EE_BASE_DIR = options.baseDir;
|
|
64
|
-
env.EE_SERVER_ENV = options.env;
|
|
65
|
-
env.EE_SERVER_SCOPE = options.serverScope;
|
|
66
|
-
env.EE_USER_HOME = options.userHome;
|
|
67
|
-
env.EE_APP_DATA = options.appData;
|
|
68
|
-
env.EE_APP_USER_DATA = options.appUserData;
|
|
69
|
-
env.HOT_RELOAD = hotReload;
|
|
70
|
-
env.EE_EXEC_DIR = options.execDir;
|
|
71
|
-
env.EE_IS_PACKAGED = options.isPackaged;
|
|
72
|
-
env.EE_IS_ENCRYPTED = options.isEncrypted;
|
|
73
|
-
env.EE_DATABASE_DIR = null;
|
|
74
|
-
env.EE_MAIN_PORT = null;
|
|
75
|
-
env.EE_SOCKET_PORT = null;
|
|
76
|
-
env.EE_HTTP_PORT = null;
|
|
77
|
-
debug('options:%j', options)
|
|
78
|
-
|
|
79
|
-
super(options);
|
|
80
|
-
|
|
81
|
-
// 设置全局this
|
|
82
|
-
EE.CoreApp = this;
|
|
83
|
-
|
|
84
|
-
this.initialize();
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
async initialize () {
|
|
88
|
-
|
|
89
|
-
await this.createPorts();
|
|
90
|
-
|
|
91
|
-
await this.startSocket();
|
|
92
|
-
|
|
93
|
-
await this.ready();
|
|
94
|
-
|
|
95
|
-
await this.createElectronApp();
|
|
96
|
-
|
|
97
|
-
await this.InitModuleMode();
|
|
98
|
-
}
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
module.exports = Appliaction;
|
package/ee/baseApp.js
DELETED
|
@@ -1,99 +0,0 @@
|
|
|
1
|
-
const EeAppCore = require('../core/index').EeCore;
|
|
2
|
-
const EE_PATH = Symbol.for('ee#eePath');
|
|
3
|
-
const path = require('path');
|
|
4
|
-
const EE_LOADER = Symbol.for('ee#loader');
|
|
5
|
-
const AppLoader = require('./appLoader');
|
|
6
|
-
const HttpClient = require('../httpclient');
|
|
7
|
-
const HTTPCLIENT = Symbol('EeApplication#httpclient');
|
|
8
|
-
const LOGGERS = Symbol('EeApplication#loggers');
|
|
9
|
-
const Log = require('../log');
|
|
10
|
-
|
|
11
|
-
class BaseApp extends EeAppCore {
|
|
12
|
-
constructor (options = {}) {
|
|
13
|
-
|
|
14
|
-
super(options);
|
|
15
|
-
|
|
16
|
-
this.loader.loadConfig();
|
|
17
|
-
|
|
18
|
-
this.loader.load();
|
|
19
|
-
|
|
20
|
-
this.HttpClient = HttpClient;
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
get [EE_PATH]() {
|
|
24
|
-
return path.join(__dirname, '..');
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
get [EE_LOADER]() {
|
|
28
|
-
return AppLoader;
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
/**
|
|
32
|
-
* loggers
|
|
33
|
-
* @member {Object}
|
|
34
|
-
* @since 1.0.0
|
|
35
|
-
*/
|
|
36
|
-
get loggers() {
|
|
37
|
-
if (!this[LOGGERS]) {
|
|
38
|
-
this[LOGGERS] = Log.create(this.config);
|
|
39
|
-
}
|
|
40
|
-
return this[LOGGERS];
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
/**
|
|
44
|
-
* Get logger by name, it's equal to app.loggers['name'],
|
|
45
|
-
* but you can extend it with your own logical.
|
|
46
|
-
* @param {String} name - logger name
|
|
47
|
-
* @return {Logger} logger
|
|
48
|
-
*/
|
|
49
|
-
getLogger(name) {
|
|
50
|
-
return this.loggers[name] || null;
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
/**
|
|
54
|
-
* application logger, log file is `$HOME/logs/ee.log`
|
|
55
|
-
* @member {Logger}
|
|
56
|
-
* @since 1.0.0
|
|
57
|
-
*/
|
|
58
|
-
get logger() {
|
|
59
|
-
return this.getLogger('logger');
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
/**
|
|
63
|
-
* core logger for framework and plugins, log file is `$HOME/logs/ee-core.log`
|
|
64
|
-
* @member {Logger}
|
|
65
|
-
* @since 1.0.0
|
|
66
|
-
*/
|
|
67
|
-
get coreLogger() {
|
|
68
|
-
return this.getLogger('coreLogger');
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
/**
|
|
72
|
-
* @class curl
|
|
73
|
-
* @since 1.0.0
|
|
74
|
-
*/
|
|
75
|
-
curl(url, opts) {
|
|
76
|
-
return this.httpclient.request(url, opts);
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
/**
|
|
80
|
-
* HttpClient instance
|
|
81
|
-
* @see https://github.com/node-modules/urllib
|
|
82
|
-
* @member {HttpClient}
|
|
83
|
-
*/
|
|
84
|
-
get httpclient() {
|
|
85
|
-
if (!this[HTTPCLIENT]) {
|
|
86
|
-
this[HTTPCLIENT] = new this.HttpClient(this.config.httpclient);
|
|
87
|
-
}
|
|
88
|
-
return this[HTTPCLIENT];
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
/**
|
|
92
|
-
* core app have been loaded
|
|
93
|
-
*/
|
|
94
|
-
async ready () {
|
|
95
|
-
// do some things
|
|
96
|
-
}
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
module.exports = BaseApp;
|