ee-core 2.0.0-beta.6 → 2.0.0-beta.7
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/jobs/child/app.js +9 -15
- package/jobs/childPool/app.js +9 -15
- package/package.json +2 -4
- package/ps/index.js +1 -1
- package/utils/is.js +145 -0
package/jobs/child/app.js
CHANGED
|
@@ -1,22 +1,16 @@
|
|
|
1
1
|
|
|
2
2
|
const is = require('is-type-of');
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
3
|
+
const Exception = require('ee-core/exception');
|
|
4
|
+
const Loader = require('ee-core/loader');
|
|
5
|
+
const Log = require('ee-core/log');
|
|
6
|
+
const UtilsCore = require('../../core/lib/utils');
|
|
7
7
|
|
|
8
8
|
// 开发环境下,ee-core是soft link
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
} else {
|
|
15
|
-
Exception = require('ee-core/exception');
|
|
16
|
-
Loader = require('ee-core/loader');
|
|
17
|
-
Log = require('ee-core/log');
|
|
18
|
-
UtilsCore = require('../../core/lib/utils');
|
|
19
|
-
}
|
|
9
|
+
// /node_modules[\\/]electron[\\/]/.test(process.execPath)
|
|
10
|
+
// const Exception = require('../../exception');
|
|
11
|
+
// const Loader = require('../../loader');
|
|
12
|
+
// const Log = require('../../log');
|
|
13
|
+
// const UtilsCore = require('../../core/lib/utils');
|
|
20
14
|
|
|
21
15
|
Exception.start();
|
|
22
16
|
|
package/jobs/childPool/app.js
CHANGED
|
@@ -1,22 +1,16 @@
|
|
|
1
1
|
|
|
2
2
|
const is = require('is-type-of');
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
3
|
+
const Exception = require('ee-core/exception');
|
|
4
|
+
const Loader = require('ee-core/loader');
|
|
5
|
+
const Log = require('ee-core/log');
|
|
6
|
+
const UtilsCore = require('../../core/lib/utils');
|
|
7
7
|
|
|
8
8
|
// 开发环境下,ee-core是soft link
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
} else {
|
|
15
|
-
Exception = require('ee-core/exception');
|
|
16
|
-
Loader = require('ee-core/loader');
|
|
17
|
-
Log = require('ee-core/log');
|
|
18
|
-
UtilsCore = require('../../core/lib/utils');
|
|
19
|
-
}
|
|
9
|
+
// /node_modules[\\/]electron[\\/]/.test(process.execPath)
|
|
10
|
+
// const Exception = require('../../exception');
|
|
11
|
+
// const Loader = require('../../loader');
|
|
12
|
+
// const Log = require('../../log');
|
|
13
|
+
// const UtilsCore = require('../../core/lib/utils');
|
|
20
14
|
|
|
21
15
|
Exception.start();
|
|
22
16
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "ee-core",
|
|
3
|
-
"version": "2.0.0-beta.
|
|
3
|
+
"version": "2.0.0-beta.7",
|
|
4
4
|
"description": "ee core",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -19,8 +19,6 @@
|
|
|
19
19
|
"depd": "^2.0.0",
|
|
20
20
|
"egg-errors": "^2.3.0",
|
|
21
21
|
"egg-logger": "^2.7.1",
|
|
22
|
-
"electron-is": "^3.0.0",
|
|
23
|
-
"electron-updater": "^4.6.1",
|
|
24
22
|
"extend2": "^1.0.1",
|
|
25
23
|
"fs-extra": "^10.0.0",
|
|
26
24
|
"get-port": "^5.1.1",
|
|
@@ -35,7 +33,7 @@
|
|
|
35
33
|
"koa2-cors": "^2.0.6",
|
|
36
34
|
"lodash": "^4.17.21",
|
|
37
35
|
"mkdirp": "^2.1.3",
|
|
38
|
-
"
|
|
36
|
+
"semver": "^7.3.8",
|
|
39
37
|
"serialize-javascript": "^6.0.1",
|
|
40
38
|
"socket.io": "^4.4.1",
|
|
41
39
|
"socket.io-client": "^4.4.1",
|
package/ps/index.js
CHANGED
package/utils/is.js
ADDED
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
'use strict'
|
|
2
|
+
|
|
3
|
+
const semver = require('semver')
|
|
4
|
+
const gt = semver.gt
|
|
5
|
+
const lt = semver.lt
|
|
6
|
+
const release = require('os').release
|
|
7
|
+
|
|
8
|
+
const IS = {
|
|
9
|
+
// Checks if we are in renderer process
|
|
10
|
+
renderer() {
|
|
11
|
+
return process.type === 'renderer'
|
|
12
|
+
},
|
|
13
|
+
// Checks if we are in main process
|
|
14
|
+
main() {
|
|
15
|
+
return process.type === 'browser'
|
|
16
|
+
},
|
|
17
|
+
// Checks if we are under Mac OS
|
|
18
|
+
osx() {
|
|
19
|
+
return process.platform === 'darwin'
|
|
20
|
+
},
|
|
21
|
+
// Checks if we are under Mac OS
|
|
22
|
+
macOS() {
|
|
23
|
+
return this.osx()
|
|
24
|
+
},
|
|
25
|
+
// Checks if we are under Windows OS
|
|
26
|
+
windows() {
|
|
27
|
+
return process.platform === 'win32'
|
|
28
|
+
},
|
|
29
|
+
// Checks if we are under Linux OS
|
|
30
|
+
linux() {
|
|
31
|
+
return process.platform === 'linux'
|
|
32
|
+
},
|
|
33
|
+
// Checks if we are the processor's arch is x86
|
|
34
|
+
x86() {
|
|
35
|
+
return process.arch === 'ia32'
|
|
36
|
+
},
|
|
37
|
+
// Checks if we are the processor's arch is x64
|
|
38
|
+
x64() {
|
|
39
|
+
return process.arch === 'x64'
|
|
40
|
+
},
|
|
41
|
+
// Checks if the app is running in a sandbox on macOS
|
|
42
|
+
sandbox() {
|
|
43
|
+
return 'APP_SANDBOX_CONTAINER_ID' in process.env
|
|
44
|
+
},
|
|
45
|
+
// Checks if the app is running as a Mac App Store build
|
|
46
|
+
mas() {
|
|
47
|
+
return process.mas === true
|
|
48
|
+
},
|
|
49
|
+
// Checks if the app is running as a Windows Store (appx) build
|
|
50
|
+
windowsStore() {
|
|
51
|
+
return process.windowsStore === true
|
|
52
|
+
},
|
|
53
|
+
// checks if all the 'is functions' passed as arguments are true
|
|
54
|
+
all() {
|
|
55
|
+
const isFunctions = new Array(arguments.length)
|
|
56
|
+
for (var i = 0; i < isFunctions.length; i++) {
|
|
57
|
+
isFunctions[i] = arguments[i]
|
|
58
|
+
}
|
|
59
|
+
if (!isFunctions.length) return
|
|
60
|
+
for (i = 0; i < isFunctions.length; i++) {
|
|
61
|
+
if (!isFunctions[i]()) return false
|
|
62
|
+
}
|
|
63
|
+
return true
|
|
64
|
+
},
|
|
65
|
+
// checks if all the 'is functions' passed as arguments are false
|
|
66
|
+
none() {
|
|
67
|
+
const isFunctions = new Array(arguments.length)
|
|
68
|
+
for (var i = 0; i < isFunctions.length; i++) {
|
|
69
|
+
isFunctions[i] = arguments[i]
|
|
70
|
+
}
|
|
71
|
+
if (!isFunctions.length) return
|
|
72
|
+
for (i = 0; i < isFunctions.length; i++) {
|
|
73
|
+
if (isFunctions[i]()) return false
|
|
74
|
+
}
|
|
75
|
+
return true
|
|
76
|
+
},
|
|
77
|
+
// returns true if one of the 'is functions' passed as argument is true
|
|
78
|
+
one() {
|
|
79
|
+
const isFunctions = new Array(arguments.length)
|
|
80
|
+
for (var i = 0; i < isFunctions.length; i++) {
|
|
81
|
+
isFunctions[i] = arguments[i]
|
|
82
|
+
}
|
|
83
|
+
if (!isFunctions.length) return
|
|
84
|
+
for (i = 0; i < isFunctions.length; i++) {
|
|
85
|
+
if (isFunctions[i]()) return true
|
|
86
|
+
}
|
|
87
|
+
return false
|
|
88
|
+
},
|
|
89
|
+
// checks the if the given release is the same of the OS
|
|
90
|
+
release(requested) {
|
|
91
|
+
if (this.osx()) {
|
|
92
|
+
return requested === this._osxRelease()
|
|
93
|
+
} else if (this.windows()) {
|
|
94
|
+
requested = requested.split('.')
|
|
95
|
+
const actual = release().split('.')
|
|
96
|
+
if (requested.length === 2) {
|
|
97
|
+
return `${actual[0]}.${actual[1]}` === `${requested[0]}.${requested[1]}`
|
|
98
|
+
}
|
|
99
|
+
return `${actual[0]}.${actual[1]}.${actual[2]}` === `${requested[0]}.${requested[1]}.${requested[2]}`
|
|
100
|
+
} else {
|
|
101
|
+
// Not implemented for Linux yet
|
|
102
|
+
return null
|
|
103
|
+
}
|
|
104
|
+
},
|
|
105
|
+
// checks if the given release is greater than the current OS release
|
|
106
|
+
gtRelease(requested) {
|
|
107
|
+
if (this.osx()) {
|
|
108
|
+
return gt(requested, this._osxRelease())
|
|
109
|
+
} else if (this.windows()) {
|
|
110
|
+
requested = requested.split('.')
|
|
111
|
+
const actual = release().split('.')
|
|
112
|
+
if (requested.length === 2) {
|
|
113
|
+
return gt(`${requested[0]}.${requested[1]}.0`, `${actual[0]}.${actual[1]}.0`)
|
|
114
|
+
}
|
|
115
|
+
return gt(`${requested[0]}.${requested[1]}.${requested[2]}`, `${actual[0]}.${actual[1]}.${actual[2]}`)
|
|
116
|
+
} else {
|
|
117
|
+
// Not implemented for Linux yet
|
|
118
|
+
return null
|
|
119
|
+
}
|
|
120
|
+
},
|
|
121
|
+
// checks if the given release is less than the current OS release
|
|
122
|
+
ltRelease(requested) {
|
|
123
|
+
if (this.osx()) {
|
|
124
|
+
return lt(requested, this._osxRelease())
|
|
125
|
+
} else if (this.windows()) {
|
|
126
|
+
requested = requested.split('.')
|
|
127
|
+
const actual = release().split('.')
|
|
128
|
+
if (requested.length === 2) {
|
|
129
|
+
return lt(`${requested[0]}.${requested[1]}.0`, `${actual[0]}.${actual[1]}.0`)
|
|
130
|
+
}
|
|
131
|
+
return lt(`${requested[0]}.${requested[1]}.${requested[2]}`, `${actual[0]}.${actual[1]}.${actual[2]}`)
|
|
132
|
+
} else {
|
|
133
|
+
// Not implemented for Linux yet
|
|
134
|
+
return null
|
|
135
|
+
}
|
|
136
|
+
},
|
|
137
|
+
|
|
138
|
+
// returns the current osx release
|
|
139
|
+
_osxRelease () {
|
|
140
|
+
const actual = release().split('.')
|
|
141
|
+
return `10.${actual[0] - 4}.${actual[1]}`
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
module.exports = IS;
|