ee-core 2.2.0-beta.1 → 2.2.0-beta.2
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/addon/index.js +4 -0
- package/ee/application.js +2 -2
- package/ee/eeApp.js +7 -3
- package/index.js +7 -0
- package/main/index.js +42 -0
- package/package.json +1 -1
- package/ps/index.js +17 -0
- package/services/index.js +4 -0
package/addon/index.js
CHANGED
|
@@ -7,6 +7,10 @@ const Addon = {
|
|
|
7
7
|
*/
|
|
8
8
|
all() {
|
|
9
9
|
const { CoreApp } = EE;
|
|
10
|
+
if (!CoreApp) {
|
|
11
|
+
throw new Error('An unknown error or Addons cannot be used by the jobs!');
|
|
12
|
+
}
|
|
13
|
+
|
|
10
14
|
const instances = CoreApp.addon || null;
|
|
11
15
|
if (!instances) {
|
|
12
16
|
throw new Error('Addons not exists or do not call directly at the top!');
|
package/ee/application.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
const Exception = require('../exception');
|
|
2
|
-
const {app} = require('electron');
|
|
2
|
+
const { app } = require('electron');
|
|
3
3
|
const path = require('path');
|
|
4
4
|
const debug = require('debug')('ee-core:Appliaction');
|
|
5
5
|
const EeApp = require('./eeApp');
|
|
@@ -53,7 +53,7 @@ class Appliaction extends EeApp {
|
|
|
53
53
|
}
|
|
54
54
|
|
|
55
55
|
// normalize env
|
|
56
|
-
env.NODE_ENV = options.env;
|
|
56
|
+
//env.NODE_ENV = options.env;
|
|
57
57
|
env.EE_HOME = options.homeDir;
|
|
58
58
|
env.EE_BASE_DIR = options.baseDir;
|
|
59
59
|
env.EE_SERVER_ENV = options.env;
|
package/ee/eeApp.js
CHANGED
|
@@ -172,9 +172,13 @@ class EeApp extends BaseApp {
|
|
|
172
172
|
*/
|
|
173
173
|
loadMainUrl(type, url) {
|
|
174
174
|
const mainServer = this.config.mainServer;
|
|
175
|
-
Log.coreLogger.info('[ee-core]
|
|
176
|
-
Log.coreLogger.info('[ee-core]
|
|
177
|
-
this.mainWindow.loadURL(url, mainServer.options)
|
|
175
|
+
Log.coreLogger.info('[ee-core] Env: %s, Type: %s', this.config.env, type);
|
|
176
|
+
Log.coreLogger.info('[ee-core] App running at: %s', url);
|
|
177
|
+
this.mainWindow.loadURL(url, mainServer.options)
|
|
178
|
+
.then()
|
|
179
|
+
.catch((err)=>{
|
|
180
|
+
Log.coreLogger.error(`[ee-core] Please check the ${url} are running OR modify config file !`);
|
|
181
|
+
});
|
|
178
182
|
}
|
|
179
183
|
|
|
180
184
|
/**
|
package/index.js
CHANGED
|
@@ -2,6 +2,12 @@
|
|
|
2
2
|
* @namespace EeCore
|
|
3
3
|
*/
|
|
4
4
|
|
|
5
|
+
/**
|
|
6
|
+
* @member {ElectronEgg} EeCore#Index
|
|
7
|
+
* @since 1.0.0
|
|
8
|
+
*/
|
|
9
|
+
const ElectronEgg = require('./main');
|
|
10
|
+
|
|
5
11
|
/**
|
|
6
12
|
* @member {app} EeCore#app
|
|
7
13
|
* @since 1.0.0
|
|
@@ -39,6 +45,7 @@ const Utils = require('./old-utils');
|
|
|
39
45
|
const Socket = require('./socket');
|
|
40
46
|
|
|
41
47
|
module.exports = {
|
|
48
|
+
ElectronEgg,
|
|
42
49
|
Application: EE.Application,
|
|
43
50
|
Controller,
|
|
44
51
|
Service,
|
package/main/index.js
ADDED
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
const { app } = require('electron');
|
|
2
|
+
const path = require('path');
|
|
3
|
+
const fs = require('fs');
|
|
4
|
+
const Utils = require('../utils');
|
|
5
|
+
const Ps = require('../ps');
|
|
6
|
+
const EE = require('../ee');
|
|
7
|
+
const UtilsCore = require('../core/lib/utils');
|
|
8
|
+
const Loader = require('../loader');
|
|
9
|
+
|
|
10
|
+
class ElectronEgg {
|
|
11
|
+
|
|
12
|
+
constructor(mode) {
|
|
13
|
+
this.mode = mode || 'framework';
|
|
14
|
+
this._create();
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* create ElectronEgg app
|
|
19
|
+
*/
|
|
20
|
+
_create() {
|
|
21
|
+
if (!Ps.verifyMode(this.mode)) {
|
|
22
|
+
throw new Error(`The mode supports only (framework | module) !`);
|
|
23
|
+
}
|
|
24
|
+
process.env.EE_MODE = this.mode;
|
|
25
|
+
|
|
26
|
+
let baseDir = path.join(app.getAppPath(), 'electron');
|
|
27
|
+
if (Utils.isEncrypt(app.getAppPath())) {
|
|
28
|
+
baseDir = Ps.getEncryptDir(app.getAppPath());
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
let indexFile = path.join(baseDir, 'index');
|
|
32
|
+
indexFile = Loader.resolveModule(indexFile);
|
|
33
|
+
if (!fs.existsSync(indexFile)) {
|
|
34
|
+
throw new Error(`The ${indexFile} file does not exist`);
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
const EEApp = UtilsCore.loadFile(indexFile);
|
|
38
|
+
EE.app = new EEApp(this.env);
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
module.exports = ElectronEgg;
|
package/package.json
CHANGED
package/ps/index.js
CHANGED
|
@@ -1,6 +1,23 @@
|
|
|
1
1
|
const path = require('path');
|
|
2
2
|
const eis = require('../utils/is');
|
|
3
3
|
|
|
4
|
+
/**
|
|
5
|
+
* 当前模式 - framework | module
|
|
6
|
+
*/
|
|
7
|
+
exports.mode = function() {
|
|
8
|
+
return process.env.EE_MODE;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* 校验模式
|
|
13
|
+
*/
|
|
14
|
+
exports.verifyMode = function(mode) {
|
|
15
|
+
if (['framework', 'module'].includes(mode)) {
|
|
16
|
+
return true;
|
|
17
|
+
}
|
|
18
|
+
return false;
|
|
19
|
+
}
|
|
20
|
+
|
|
4
21
|
/**
|
|
5
22
|
* 当前进程的所有env
|
|
6
23
|
*/
|
package/services/index.js
CHANGED
|
@@ -7,6 +7,10 @@ const Services = {
|
|
|
7
7
|
*/
|
|
8
8
|
all() {
|
|
9
9
|
const { CoreApp } = EE;
|
|
10
|
+
if (!CoreApp) {
|
|
11
|
+
throw new Error('An unknown error or Services cannot be used by the jobs!');
|
|
12
|
+
}
|
|
13
|
+
|
|
10
14
|
const instances = CoreApp.service || null;
|
|
11
15
|
if (!instances) {
|
|
12
16
|
throw new Error('Services not exists or do not call directly at the top!');
|