ee-bin 1.5.0-beta.1 → 1.6.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/index.js +122 -120
- package/lib/pargv.js +263 -263
- package/lib/utils.js +121 -111
- package/package.json +26 -24
- package/tools/encrypt.js +315 -315
- package/tools/iconGen.js +182 -182
- package/tools/move.js +84 -84
- package/tools/replaceDist.js +82 -82
- package/tools/serve.js +167 -163
package/lib/utils.js
CHANGED
|
@@ -1,111 +1,121 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
const path = require('path');
|
|
4
|
-
const fs = require('fs');
|
|
5
|
-
const chalk = require('chalk');
|
|
6
|
-
const is = require('is-type-of');
|
|
7
|
-
|
|
8
|
-
const
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
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
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
function
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const path = require('path');
|
|
4
|
+
const fs = require('fs');
|
|
5
|
+
const chalk = require('chalk');
|
|
6
|
+
const is = require('is-type-of');
|
|
7
|
+
const { loadTsConfig } = require('config-file-ts');
|
|
8
|
+
const JsonLib = require('json5');
|
|
9
|
+
|
|
10
|
+
const _basePath = process.cwd();
|
|
11
|
+
|
|
12
|
+
function checkConfig(prop) {
|
|
13
|
+
const filepath = path.join(_basePath, prop);
|
|
14
|
+
if (fs.existsSync(filepath)) {
|
|
15
|
+
return true;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
return false;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
function loadConfig(prop) {
|
|
22
|
+
const configFile = path.join(_basePath, prop);
|
|
23
|
+
if (!fs.existsSync(configFile)) {
|
|
24
|
+
const errorTips = 'config file ' + chalk.blue(`${configFile}`) + ' does not exist !';
|
|
25
|
+
throw new Error(errorTips)
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
let result;
|
|
29
|
+
if (configFile.endsWith(".json5") || configFile.endsWith(".json")) {
|
|
30
|
+
const data = fs.readFileSync(configFile, 'utf8');
|
|
31
|
+
return JsonLib.parse(data);
|
|
32
|
+
}
|
|
33
|
+
if (configFile.endsWith(".js") || configFile.endsWith(".cjs")) {
|
|
34
|
+
result = require(configFile);
|
|
35
|
+
if (result.default != null) {
|
|
36
|
+
result = result.default;
|
|
37
|
+
}
|
|
38
|
+
} else if (configFile.endsWith(".ts")) {
|
|
39
|
+
result = loadTsConfig(configFile);
|
|
40
|
+
}
|
|
41
|
+
if (is.function(result) && !is.class(result)) {
|
|
42
|
+
result = result();
|
|
43
|
+
}
|
|
44
|
+
return result || {}
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
function loadEncryptConfig() {
|
|
48
|
+
const configFile = './electron/config/encrypt.js';
|
|
49
|
+
const filepath = path.join(_basePath, configFile);
|
|
50
|
+
if (!fs.existsSync(filepath)) {
|
|
51
|
+
const errorTips = 'config file ' + chalk.blue(`${filepath}`) + ' does not exist !';
|
|
52
|
+
throw new Error(errorTips)
|
|
53
|
+
}
|
|
54
|
+
const obj = require(filepath);
|
|
55
|
+
if (!obj) return obj;
|
|
56
|
+
|
|
57
|
+
let ret = obj;
|
|
58
|
+
if (is.function(obj) && !is.class(obj)) {
|
|
59
|
+
ret = obj();
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
return ret || {};
|
|
63
|
+
};
|
|
64
|
+
|
|
65
|
+
/**
|
|
66
|
+
* get electron program
|
|
67
|
+
*/
|
|
68
|
+
function getElectronProgram() {
|
|
69
|
+
let electronPath
|
|
70
|
+
const electronModulePath = path.dirname(require.resolve('electron'))
|
|
71
|
+
const pathFile = path.join(electronModulePath, 'path.txt')
|
|
72
|
+
const executablePath = fs.readFileSync(pathFile, 'utf-8')
|
|
73
|
+
if (executablePath) {
|
|
74
|
+
electronPath = path.join(electronModulePath, 'dist', executablePath)
|
|
75
|
+
} else {
|
|
76
|
+
throw new Error('Check that electron is installed!')
|
|
77
|
+
}
|
|
78
|
+
return electronPath;
|
|
79
|
+
};
|
|
80
|
+
|
|
81
|
+
/**
|
|
82
|
+
* 版本号比较
|
|
83
|
+
*/
|
|
84
|
+
function compareVersion(v1, v2) {
|
|
85
|
+
v1 = v1.split('.')
|
|
86
|
+
v2 = v2.split('.')
|
|
87
|
+
const len = Math.max(v1.length, v2.length)
|
|
88
|
+
|
|
89
|
+
while (v1.length < len) {
|
|
90
|
+
v1.push('0')
|
|
91
|
+
}
|
|
92
|
+
while (v2.length < len) {
|
|
93
|
+
v2.push('0')
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
for (let i = 0; i < len; i++) {
|
|
97
|
+
const num1 = parseInt(v1[i])
|
|
98
|
+
const num2 = parseInt(v2[i])
|
|
99
|
+
|
|
100
|
+
if (num1 > num2) {
|
|
101
|
+
return 1
|
|
102
|
+
} else if (num1 < num2) {
|
|
103
|
+
return -1
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
return 0
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
function isWindows(prop) {
|
|
111
|
+
return process.platform === 'win32'
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
module.exports = {
|
|
115
|
+
loadConfig,
|
|
116
|
+
checkConfig,
|
|
117
|
+
loadEncryptConfig,
|
|
118
|
+
getElectronProgram,
|
|
119
|
+
compareVersion,
|
|
120
|
+
isWindows
|
|
121
|
+
}
|
package/package.json
CHANGED
|
@@ -1,24 +1,26 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "ee-bin",
|
|
3
|
-
"version": "1.
|
|
4
|
-
"description": "ee bin",
|
|
5
|
-
"main": "index.js",
|
|
6
|
-
"scripts": {
|
|
7
|
-
"test": "echo \"Error: no test specified\" && exit 1"
|
|
8
|
-
},
|
|
9
|
-
"author": "",
|
|
10
|
-
"license": "ISC",
|
|
11
|
-
"bin": {
|
|
12
|
-
"ee-bin": "index.js"
|
|
13
|
-
},
|
|
14
|
-
"dependencies": {
|
|
15
|
-
"bytenode": "^1.3.6",
|
|
16
|
-
"chalk": "^4.1.2",
|
|
17
|
-
"commander": "^11.0.0",
|
|
18
|
-
"
|
|
19
|
-
"
|
|
20
|
-
"
|
|
21
|
-
"
|
|
22
|
-
"
|
|
23
|
-
|
|
24
|
-
|
|
1
|
+
{
|
|
2
|
+
"name": "ee-bin",
|
|
3
|
+
"version": "1.6.0",
|
|
4
|
+
"description": "ee bin",
|
|
5
|
+
"main": "index.js",
|
|
6
|
+
"scripts": {
|
|
7
|
+
"test": "echo \"Error: no test specified\" && exit 1"
|
|
8
|
+
},
|
|
9
|
+
"author": "",
|
|
10
|
+
"license": "ISC",
|
|
11
|
+
"bin": {
|
|
12
|
+
"ee-bin": "index.js"
|
|
13
|
+
},
|
|
14
|
+
"dependencies": {
|
|
15
|
+
"bytenode": "^1.3.6",
|
|
16
|
+
"chalk": "^4.1.2",
|
|
17
|
+
"commander": "^11.0.0",
|
|
18
|
+
"config-file-ts": "^0.2.8-rc1",
|
|
19
|
+
"cross-spawn": "^7.0.3",
|
|
20
|
+
"fs-extra": "^10.0.0",
|
|
21
|
+
"globby": "^10.0.0",
|
|
22
|
+
"is-type-of": "^1.2.1",
|
|
23
|
+
"javascript-obfuscator": "^4.0.2",
|
|
24
|
+
"json5": "^2.2.3"
|
|
25
|
+
}
|
|
26
|
+
}
|