ee-core 2.9.2 → 2.10.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/LICENSE +21 -21
- package/README.md +65 -65
- package/addon/index.js +34 -34
- package/addon/window/index.js +98 -98
- package/bin/tools.js +8 -8
- package/config/cache.js +41 -38
- package/config/config.default.js +331 -330
- package/config/index.js +75 -73
- package/const/channel.js +17 -17
- package/const/index.js +8 -8
- package/controller/baseContextClass.js +34 -34
- package/controller/index.js +34 -34
- package/core/index.js +10 -10
- package/core/lib/ee.js +216 -216
- package/core/lib/loader/context_loader.js +106 -106
- package/core/lib/loader/ee_loader.js +435 -435
- package/core/lib/loader/file_loader.js +326 -326
- package/core/lib/loader/mixin/addon.js +32 -32
- package/core/lib/loader/mixin/config.js +130 -130
- package/core/lib/loader/mixin/controller.js +125 -125
- package/core/lib/loader/mixin/service.js +28 -28
- package/core/lib/utils/base_context_class.js +34 -34
- package/core/lib/utils/function.js +30 -30
- package/core/lib/utils/index.js +133 -133
- package/core/lib/utils/sequencify.js +59 -59
- package/core/lib/utils/timing.js +77 -77
- package/cross/index.js +183 -183
- package/cross/spawnProcess.js +183 -183
- package/ee/appLoader.js +48 -48
- package/ee/application.js +99 -99
- package/ee/baseApp.js +103 -102
- package/ee/eeApp.js +408 -408
- package/ee/index.js +57 -57
- package/electron/app/index.js +64 -58
- package/electron/index.js +19 -19
- package/electron/window/index.js +73 -73
- package/electron/window/winState.js +186 -186
- package/exception/index.js +112 -112
- package/html/boot.html +98 -98
- package/html/cross-failure.html +28 -28
- package/html/failure.html +28 -28
- package/html/index.js +13 -13
- package/httpclient/index.js +161 -161
- package/index.js +54 -54
- package/jobs/baseJobClass.js +16 -16
- package/jobs/child/app.js +65 -65
- package/jobs/child/forkProcess.js +145 -145
- package/jobs/child/index.js +82 -82
- package/jobs/child-pool/index.js +213 -213
- package/jobs/index.js +8 -8
- package/jobs/load-balancer/algorithm/index.js +11 -11
- package/jobs/load-balancer/algorithm/minimumConnection.js +18 -18
- package/jobs/load-balancer/algorithm/polling.js +11 -11
- package/jobs/load-balancer/algorithm/random.js +9 -9
- package/jobs/load-balancer/algorithm/specify.js +14 -14
- package/jobs/load-balancer/algorithm/weights.js +21 -21
- package/jobs/load-balancer/algorithm/weightsMinimumConnection.js +29 -29
- package/jobs/load-balancer/algorithm/weightsPolling.js +22 -22
- package/jobs/load-balancer/algorithm/weightsRandom.js +16 -16
- package/jobs/load-balancer/consts.js +9 -9
- package/jobs/load-balancer/index.js +201 -201
- package/jobs/load-balancer/scheduler.js +31 -31
- package/jobs/renderer/index.js +141 -141
- package/jobs/renderer/loadView.js +40 -40
- package/jobs/unification.js +63 -63
- package/loader/index.js +172 -172
- package/log/index.js +68 -68
- package/log/logger.js +86 -80
- package/main/index.js +56 -56
- package/message/childMessage.js +54 -54
- package/message/index.js +18 -18
- package/old-utils/index.js +91 -91
- package/package.json +38 -38
- package/ps/index.js +371 -371
- package/services/baseContextClass.js +34 -34
- package/services/index.js +40 -40
- package/socket/httpServer.js +147 -147
- package/socket/index.js +81 -81
- package/socket/io.js +27 -27
- package/socket/ipcServer.js +112 -112
- package/socket/socketServer.js +69 -67
- package/storage/index.js +38 -38
- package/storage/jsondb/adapters/Base.js +23 -23
- package/storage/jsondb/adapters/FileSync.js +64 -52
- package/storage/jsondb/main.js +55 -42
- package/storage/jsondbStorage.js +195 -195
- package/storage/sqliteStorage.js +123 -123
- package/utils/co.js +237 -237
- package/utils/copyto.js +160 -160
- package/utils/depd/index.js +538 -538
- package/utils/depd/lib/browser/index.js +77 -77
- package/utils/extend.js +73 -73
- package/utils/get-port/index.d.ts +64 -64
- package/utils/get-port/index.js +148 -148
- package/utils/helper.js +220 -220
- package/utils/index.js +160 -160
- package/utils/ip.js +261 -261
- package/utils/is.js +145 -145
- package/utils/json.js +72 -72
- package/utils/pargv.js +263 -263
- package/utils/time/index.js +19 -19
- package/utils/time/ms.js +162 -162
- package/utils/wrap.js +35 -35
package/LICENSE
CHANGED
|
@@ -1,21 +1,21 @@
|
|
|
1
|
-
MIT License
|
|
2
|
-
|
|
3
|
-
Copyright (c) 2021 Wallace Gao
|
|
4
|
-
|
|
5
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
-
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
-
in the Software without restriction, including without limitation the rights
|
|
8
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
-
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
-
furnished to do so, subject to the following conditions:
|
|
11
|
-
|
|
12
|
-
The above copyright notice and this permission notice shall be included in all
|
|
13
|
-
copies or substantial portions of the Software.
|
|
14
|
-
|
|
15
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
-
SOFTWARE.
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2021 Wallace Gao
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,66 +1,66 @@
|
|
|
1
|
-
### introduction
|
|
2
|
-
|
|
3
|
-
Powerful electron third party module, offering **100+ API**
|
|
4
|
-
|
|
5
|
-
[introduction](https://www.kaka996.com/pages/85c531/)
|
|
6
|
-
|
|
7
|
-
[中文文档](https://www.kaka996.com/pages/85c531/)
|
|
8
|
-
|
|
9
|
-
### module list
|
|
10
|
-
|
|
11
|
-
#### addon
|
|
12
|
-
plug-in module
|
|
13
|
-
|
|
14
|
-
#### bin
|
|
15
|
-
Command line module.
|
|
16
|
-
|
|
17
|
-
#### config
|
|
18
|
-
Configuration Module
|
|
19
|
-
|
|
20
|
-
#### const
|
|
21
|
-
Define the universal constants used in the framework.
|
|
22
|
-
|
|
23
|
-
#### controller
|
|
24
|
-
Controller module
|
|
25
|
-
|
|
26
|
-
#### ee
|
|
27
|
-
EE module
|
|
28
|
-
|
|
29
|
-
#### electron
|
|
30
|
-
The electric function encapsulated by the framework will provide APIs in this module.
|
|
31
|
-
|
|
32
|
-
#### exception
|
|
33
|
-
Capture exception modules.
|
|
34
|
-
|
|
35
|
-
#### httpclient
|
|
36
|
-
HTTP client.
|
|
37
|
-
|
|
38
|
-
#### jobs
|
|
39
|
-
Jobs module.
|
|
40
|
-
|
|
41
|
-
#### loader
|
|
42
|
-
loader module
|
|
43
|
-
|
|
44
|
-
#### log
|
|
45
|
-
log module
|
|
46
|
-
|
|
47
|
-
#### message
|
|
48
|
-
Message module. Sending messages between the main process and child processes.
|
|
49
|
-
|
|
50
|
-
#### ps
|
|
51
|
-
Process tool class module.
|
|
52
|
-
|
|
53
|
-
#### services
|
|
54
|
-
services module
|
|
55
|
-
|
|
56
|
-
#### socket
|
|
57
|
-
Provide socket communication function.
|
|
58
|
-
|
|
59
|
-
#### storage
|
|
60
|
-
Storage module. Provide JSON database and sqlite database.
|
|
61
|
-
|
|
62
|
-
#### tools
|
|
63
|
-
Script module. Encrypt and move resources.
|
|
64
|
-
|
|
65
|
-
#### utils
|
|
1
|
+
### introduction
|
|
2
|
+
|
|
3
|
+
Powerful electron third party module, offering **100+ API**
|
|
4
|
+
|
|
5
|
+
[introduction](https://www.kaka996.com/pages/85c531/)
|
|
6
|
+
|
|
7
|
+
[中文文档](https://www.kaka996.com/pages/85c531/)
|
|
8
|
+
|
|
9
|
+
### module list
|
|
10
|
+
|
|
11
|
+
#### addon
|
|
12
|
+
plug-in module
|
|
13
|
+
|
|
14
|
+
#### bin
|
|
15
|
+
Command line module.
|
|
16
|
+
|
|
17
|
+
#### config
|
|
18
|
+
Configuration Module
|
|
19
|
+
|
|
20
|
+
#### const
|
|
21
|
+
Define the universal constants used in the framework.
|
|
22
|
+
|
|
23
|
+
#### controller
|
|
24
|
+
Controller module
|
|
25
|
+
|
|
26
|
+
#### ee
|
|
27
|
+
EE module
|
|
28
|
+
|
|
29
|
+
#### electron
|
|
30
|
+
The electric function encapsulated by the framework will provide APIs in this module.
|
|
31
|
+
|
|
32
|
+
#### exception
|
|
33
|
+
Capture exception modules.
|
|
34
|
+
|
|
35
|
+
#### httpclient
|
|
36
|
+
HTTP client.
|
|
37
|
+
|
|
38
|
+
#### jobs
|
|
39
|
+
Jobs module.
|
|
40
|
+
|
|
41
|
+
#### loader
|
|
42
|
+
loader module
|
|
43
|
+
|
|
44
|
+
#### log
|
|
45
|
+
log module
|
|
46
|
+
|
|
47
|
+
#### message
|
|
48
|
+
Message module. Sending messages between the main process and child processes.
|
|
49
|
+
|
|
50
|
+
#### ps
|
|
51
|
+
Process tool class module.
|
|
52
|
+
|
|
53
|
+
#### services
|
|
54
|
+
services module
|
|
55
|
+
|
|
56
|
+
#### socket
|
|
57
|
+
Provide socket communication function.
|
|
58
|
+
|
|
59
|
+
#### storage
|
|
60
|
+
Storage module. Provide JSON database and sqlite database.
|
|
61
|
+
|
|
62
|
+
#### tools
|
|
63
|
+
Script module. Encrypt and move resources.
|
|
64
|
+
|
|
65
|
+
#### utils
|
|
66
66
|
Tool library module.
|
package/addon/index.js
CHANGED
|
@@ -1,35 +1,35 @@
|
|
|
1
|
-
const EE = require('../ee');
|
|
2
|
-
|
|
3
|
-
const Addon = {
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* 获取 all addon instances
|
|
7
|
-
*/
|
|
8
|
-
all() {
|
|
9
|
-
const { CoreApp } = EE;
|
|
10
|
-
if (!CoreApp) {
|
|
11
|
-
throw new Error('An unknown error or Addons cannot be used by the jobs!');
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
const instances = CoreApp.addon || null;
|
|
15
|
-
if (!instances) {
|
|
16
|
-
throw new Error('Addons not exists or do not call directly at the top!');
|
|
17
|
-
};
|
|
18
|
-
return instances;
|
|
19
|
-
},
|
|
20
|
-
|
|
21
|
-
/**
|
|
22
|
-
* 获取 addon instance
|
|
23
|
-
*/
|
|
24
|
-
get(name) {
|
|
25
|
-
const instances = this.all();
|
|
26
|
-
const instance = instances[name] || null;
|
|
27
|
-
if (!instance) {
|
|
28
|
-
throw new Error(`Addon class '${name}' not exists or do not call directly at the top!`);
|
|
29
|
-
};
|
|
30
|
-
return instance;
|
|
31
|
-
},
|
|
32
|
-
|
|
33
|
-
};
|
|
34
|
-
|
|
1
|
+
const EE = require('../ee');
|
|
2
|
+
|
|
3
|
+
const Addon = {
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* 获取 all addon instances
|
|
7
|
+
*/
|
|
8
|
+
all() {
|
|
9
|
+
const { CoreApp } = EE;
|
|
10
|
+
if (!CoreApp) {
|
|
11
|
+
throw new Error('An unknown error or Addons cannot be used by the jobs!');
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
const instances = CoreApp.addon || null;
|
|
15
|
+
if (!instances) {
|
|
16
|
+
throw new Error('Addons not exists or do not call directly at the top!');
|
|
17
|
+
};
|
|
18
|
+
return instances;
|
|
19
|
+
},
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* 获取 addon instance
|
|
23
|
+
*/
|
|
24
|
+
get(name) {
|
|
25
|
+
const instances = this.all();
|
|
26
|
+
const instance = instances[name] || null;
|
|
27
|
+
if (!instance) {
|
|
28
|
+
throw new Error(`Addon class '${name}' not exists or do not call directly at the top!`);
|
|
29
|
+
};
|
|
30
|
+
return instance;
|
|
31
|
+
},
|
|
32
|
+
|
|
33
|
+
};
|
|
34
|
+
|
|
35
35
|
module.exports = Addon;
|
package/addon/window/index.js
CHANGED
|
@@ -1,99 +1,99 @@
|
|
|
1
|
-
const { BrowserWindow } = require('electron');
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* 窗口插件
|
|
5
|
-
* @class
|
|
6
|
-
*/
|
|
7
|
-
class WinAddon {
|
|
8
|
-
|
|
9
|
-
constructor(app) {
|
|
10
|
-
this.app = app;
|
|
11
|
-
this.windowContentsIdMap = {};
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
/**
|
|
15
|
-
* create window
|
|
16
|
-
*
|
|
17
|
-
* @function
|
|
18
|
-
* @since 1.0.0
|
|
19
|
-
*/
|
|
20
|
-
create(name, opt) {
|
|
21
|
-
|
|
22
|
-
// todo 判断name是否唯一
|
|
23
|
-
// if (this.windowContentsIdMap.hasOwnProperty(name)) {
|
|
24
|
-
// throw new Error(`[addon] [window] Name: ${name} already exists!`);
|
|
25
|
-
// }
|
|
26
|
-
|
|
27
|
-
// [todo] 使用 extend, 避免多维对象被覆盖
|
|
28
|
-
const options = Object.assign({
|
|
29
|
-
x: 10,
|
|
30
|
-
y: 10,
|
|
31
|
-
width: 980,
|
|
32
|
-
height: 650,
|
|
33
|
-
webPreferences: {
|
|
34
|
-
contextIsolation: false,
|
|
35
|
-
nodeIntegration: true,
|
|
36
|
-
},
|
|
37
|
-
}, opt);
|
|
38
|
-
const win = new BrowserWindow(options)
|
|
39
|
-
|
|
40
|
-
const winContentsId = win.webContents.id;
|
|
41
|
-
win.webContents.on('did-finish-load', () => {
|
|
42
|
-
this.registerWCid(name, winContentsId);
|
|
43
|
-
})
|
|
44
|
-
|
|
45
|
-
win.webContents.on('destroyed', () => {
|
|
46
|
-
this.removeWCid(name);
|
|
47
|
-
})
|
|
48
|
-
|
|
49
|
-
win.webContents.on('render-process-gone', (event, details) => {
|
|
50
|
-
this.removeWCid(name);
|
|
51
|
-
})
|
|
52
|
-
|
|
53
|
-
return win;
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
/**
|
|
57
|
-
* 获取窗口Contents id
|
|
58
|
-
*
|
|
59
|
-
* @function
|
|
60
|
-
* @since 1.0.0
|
|
61
|
-
*/
|
|
62
|
-
getWCid(name) {
|
|
63
|
-
const id = this.windowContentsIdMap[name] || null;
|
|
64
|
-
return id;
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
/**
|
|
68
|
-
* 获取主窗口Contents id
|
|
69
|
-
*
|
|
70
|
-
* @function
|
|
71
|
-
* @since 1.0.0
|
|
72
|
-
*/
|
|
73
|
-
getMWCid() {
|
|
74
|
-
const id = this.windowContentsIdMap['main'] || null;
|
|
75
|
-
return id;
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
/**
|
|
79
|
-
* 注册窗口Contents id
|
|
80
|
-
*
|
|
81
|
-
* @function
|
|
82
|
-
* @since 1.0.0
|
|
83
|
-
*/
|
|
84
|
-
registerWCid(name, id) {
|
|
85
|
-
this.windowContentsIdMap[name] = id;
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
/**
|
|
89
|
-
* 销毁窗口Contents id
|
|
90
|
-
*
|
|
91
|
-
* @function
|
|
92
|
-
* @since 1.0.0
|
|
93
|
-
*/
|
|
94
|
-
removeWCid(name) {
|
|
95
|
-
delete this.windowContentsIdMap[name];
|
|
96
|
-
}
|
|
97
|
-
}
|
|
98
|
-
|
|
1
|
+
const { BrowserWindow } = require('electron');
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* 窗口插件
|
|
5
|
+
* @class
|
|
6
|
+
*/
|
|
7
|
+
class WinAddon {
|
|
8
|
+
|
|
9
|
+
constructor(app) {
|
|
10
|
+
this.app = app;
|
|
11
|
+
this.windowContentsIdMap = {};
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* create window
|
|
16
|
+
*
|
|
17
|
+
* @function
|
|
18
|
+
* @since 1.0.0
|
|
19
|
+
*/
|
|
20
|
+
create(name, opt) {
|
|
21
|
+
|
|
22
|
+
// todo 判断name是否唯一
|
|
23
|
+
// if (this.windowContentsIdMap.hasOwnProperty(name)) {
|
|
24
|
+
// throw new Error(`[addon] [window] Name: ${name} already exists!`);
|
|
25
|
+
// }
|
|
26
|
+
|
|
27
|
+
// [todo] 使用 extend, 避免多维对象被覆盖
|
|
28
|
+
const options = Object.assign({
|
|
29
|
+
x: 10,
|
|
30
|
+
y: 10,
|
|
31
|
+
width: 980,
|
|
32
|
+
height: 650,
|
|
33
|
+
webPreferences: {
|
|
34
|
+
contextIsolation: false,
|
|
35
|
+
nodeIntegration: true,
|
|
36
|
+
},
|
|
37
|
+
}, opt);
|
|
38
|
+
const win = new BrowserWindow(options)
|
|
39
|
+
|
|
40
|
+
const winContentsId = win.webContents.id;
|
|
41
|
+
win.webContents.on('did-finish-load', () => {
|
|
42
|
+
this.registerWCid(name, winContentsId);
|
|
43
|
+
})
|
|
44
|
+
|
|
45
|
+
win.webContents.on('destroyed', () => {
|
|
46
|
+
this.removeWCid(name);
|
|
47
|
+
})
|
|
48
|
+
|
|
49
|
+
win.webContents.on('render-process-gone', (event, details) => {
|
|
50
|
+
this.removeWCid(name);
|
|
51
|
+
})
|
|
52
|
+
|
|
53
|
+
return win;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
/**
|
|
57
|
+
* 获取窗口Contents id
|
|
58
|
+
*
|
|
59
|
+
* @function
|
|
60
|
+
* @since 1.0.0
|
|
61
|
+
*/
|
|
62
|
+
getWCid(name) {
|
|
63
|
+
const id = this.windowContentsIdMap[name] || null;
|
|
64
|
+
return id;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
/**
|
|
68
|
+
* 获取主窗口Contents id
|
|
69
|
+
*
|
|
70
|
+
* @function
|
|
71
|
+
* @since 1.0.0
|
|
72
|
+
*/
|
|
73
|
+
getMWCid() {
|
|
74
|
+
const id = this.windowContentsIdMap['main'] || null;
|
|
75
|
+
return id;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
/**
|
|
79
|
+
* 注册窗口Contents id
|
|
80
|
+
*
|
|
81
|
+
* @function
|
|
82
|
+
* @since 1.0.0
|
|
83
|
+
*/
|
|
84
|
+
registerWCid(name, id) {
|
|
85
|
+
this.windowContentsIdMap[name] = id;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
/**
|
|
89
|
+
* 销毁窗口Contents id
|
|
90
|
+
*
|
|
91
|
+
* @function
|
|
92
|
+
* @since 1.0.0
|
|
93
|
+
*/
|
|
94
|
+
removeWCid(name) {
|
|
95
|
+
delete this.windowContentsIdMap[name];
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
|
|
99
99
|
module.exports = WinAddon;
|
package/bin/tools.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
|
|
3
|
-
const chalk = require('chalk');
|
|
4
|
-
|
|
5
|
-
let tip = chalk.bgYellow('Warning') + ' please use ' + chalk.blue('ee-bin') + ', See: ';
|
|
6
|
-
tip += chalk.underline('https://www.kaka996.com/pages/e1816f/');
|
|
7
|
-
|
|
8
|
-
console.log(tip);
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
const chalk = require('chalk');
|
|
4
|
+
|
|
5
|
+
let tip = chalk.bgYellow('Warning') + ' please use ' + chalk.blue('ee-bin') + ', See: ';
|
|
6
|
+
tip += chalk.underline('https://www.kaka996.com/pages/e1816f/');
|
|
7
|
+
|
|
8
|
+
console.log(tip);
|
package/config/cache.js
CHANGED
|
@@ -1,39 +1,42 @@
|
|
|
1
|
-
const EE = require('../ee');
|
|
2
|
-
|
|
3
|
-
const conf = {
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* 获取 内存中的config
|
|
7
|
-
*/
|
|
8
|
-
_getConfig() {
|
|
9
|
-
const { CoreApp } = EE;
|
|
10
|
-
if (!CoreApp) {
|
|
11
|
-
throw new Error(`[ee-core] [config] Frame initialization is not complete !`);
|
|
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
|
-
|
|
1
|
+
const EE = require('../ee');
|
|
2
|
+
|
|
3
|
+
const conf = {
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* 获取 内存中的config
|
|
7
|
+
*/
|
|
8
|
+
_getConfig(withError = true) {
|
|
9
|
+
const { CoreApp } = EE;
|
|
10
|
+
if (!CoreApp && withError) {
|
|
11
|
+
throw new Error(`[ee-core] [config] Frame initialization is not complete !`);
|
|
12
|
+
}
|
|
13
|
+
if (!CoreApp) {
|
|
14
|
+
return null;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
return CoreApp.config;
|
|
18
|
+
},
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* all
|
|
22
|
+
*/
|
|
23
|
+
all(withError = true) {
|
|
24
|
+
return this._getConfig(withError);
|
|
25
|
+
},
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* getValue
|
|
29
|
+
*/
|
|
30
|
+
getValue(key) {
|
|
31
|
+
const v = this._objectGet(this._getConfig(), key);
|
|
32
|
+
return v;
|
|
33
|
+
},
|
|
34
|
+
|
|
35
|
+
_objectGet(object, path, defaultValue) {
|
|
36
|
+
const pathParts = Array.isArray(path) ? path : path.split('.');
|
|
37
|
+
const value = pathParts.reduce((obj, key) => obj && key in obj ? obj[key] : undefined, object);
|
|
38
|
+
return value === undefined ? defaultValue : value;
|
|
39
|
+
}
|
|
40
|
+
};
|
|
41
|
+
|
|
39
42
|
module.exports = conf;
|