ee-bin 1.7.0 → 1.7.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/lib/utils.js +54 -1
- package/package.json +1 -1
- package/tools/incrUpdater.js +36 -13
package/lib/utils.js
CHANGED
|
@@ -7,6 +7,7 @@ const is = require('is-type-of');
|
|
|
7
7
|
const { loadTsConfig } = require('config-file-ts');
|
|
8
8
|
const JsonLib = require('json5');
|
|
9
9
|
const mkdirp = require('mkdirp');
|
|
10
|
+
const OS = require('os');
|
|
10
11
|
|
|
11
12
|
const _basePath = process.cwd();
|
|
12
13
|
|
|
@@ -108,10 +109,30 @@ function compareVersion(v1, v2) {
|
|
|
108
109
|
return 0
|
|
109
110
|
}
|
|
110
111
|
|
|
111
|
-
function isWindows(
|
|
112
|
+
function isWindows() {
|
|
112
113
|
return process.platform === 'win32'
|
|
113
114
|
}
|
|
114
115
|
|
|
116
|
+
function isOSX() {
|
|
117
|
+
return process.platform === 'darwin'
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
function isMacOS() {
|
|
121
|
+
return isOSX()
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
function isLinux() {
|
|
125
|
+
return process.platform === 'linux'
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
function isx86() {
|
|
129
|
+
return process.arch === 'ia32'
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
function isx64() {
|
|
133
|
+
return process.arch === 'x64'
|
|
134
|
+
}
|
|
135
|
+
|
|
115
136
|
/**
|
|
116
137
|
* Delete a file or folder
|
|
117
138
|
*/
|
|
@@ -160,6 +181,32 @@ function writeJsonSync (filepath, str, options) {
|
|
|
160
181
|
fs.writeFileSync(filepath, str);
|
|
161
182
|
};
|
|
162
183
|
|
|
184
|
+
function getPlatform(delimiter = "_", isDiffArch = false) {
|
|
185
|
+
let os = "";
|
|
186
|
+
if (isWindows()) {
|
|
187
|
+
os = "windows";
|
|
188
|
+
if (isDiffArch) {
|
|
189
|
+
const arch = isx64() ? "64" : "32";
|
|
190
|
+
os += delimiter + arch;
|
|
191
|
+
}
|
|
192
|
+
} else if (isMacOS()) {
|
|
193
|
+
let isAppleSilicon = false;
|
|
194
|
+
const cpus = OS.cpus();
|
|
195
|
+
for (let cpu of cpus) {
|
|
196
|
+
if (cpu.model.includes('Apple')) {
|
|
197
|
+
isAppleSilicon = true;
|
|
198
|
+
break;
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
const core = isAppleSilicon? "apple" : "intel";
|
|
202
|
+
os = "macos" + delimiter + core;
|
|
203
|
+
} else if (isLinux()) {
|
|
204
|
+
os = "linux";
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
return os;
|
|
208
|
+
}
|
|
209
|
+
|
|
163
210
|
module.exports = {
|
|
164
211
|
loadConfig,
|
|
165
212
|
checkConfig,
|
|
@@ -167,6 +214,12 @@ module.exports = {
|
|
|
167
214
|
getElectronProgram,
|
|
168
215
|
compareVersion,
|
|
169
216
|
isWindows,
|
|
217
|
+
isOSX,
|
|
218
|
+
isMacOS,
|
|
219
|
+
isLinux,
|
|
220
|
+
isx86,
|
|
221
|
+
isx64,
|
|
222
|
+
getPlatform,
|
|
170
223
|
rm,
|
|
171
224
|
getPackage,
|
|
172
225
|
readJsonSync,
|
package/package.json
CHANGED
package/tools/incrUpdater.js
CHANGED
|
@@ -35,7 +35,7 @@ module.exports = {
|
|
|
35
35
|
},
|
|
36
36
|
|
|
37
37
|
generateFile(cfg, asarFile) {
|
|
38
|
-
|
|
38
|
+
var latestVersionInfo = {}
|
|
39
39
|
const homeDir = process.cwd();
|
|
40
40
|
|
|
41
41
|
let asarFilePath = "";
|
|
@@ -58,8 +58,20 @@ module.exports = {
|
|
|
58
58
|
return;
|
|
59
59
|
}
|
|
60
60
|
|
|
61
|
+
const packageJson = Utils.getPackage();
|
|
62
|
+
const version = packageJson.version;
|
|
63
|
+
const platformForFilename = Utils.getPlatform("-");
|
|
64
|
+
const platformForKey = Utils.getPlatform("_");
|
|
65
|
+
|
|
61
66
|
// 生成 zip
|
|
62
|
-
|
|
67
|
+
let zipName = "";
|
|
68
|
+
if (cfg.output.noPlatform === true) {
|
|
69
|
+
zipName = path.basename(cfg.output.zip, '.zip') + `-${version}.zip`;
|
|
70
|
+
} else {
|
|
71
|
+
zipName = path.basename(cfg.output.zip, '.zip') + `-${platformForFilename}-${version}.zip`;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
const asarZipPath = path.join(homeDir, cfg.output.directory, zipName);
|
|
63
75
|
if (fs.existsSync(asarZipPath) && cfg.cleanCache) {
|
|
64
76
|
Utils.rm(asarZipPath);
|
|
65
77
|
}
|
|
@@ -72,28 +84,39 @@ module.exports = {
|
|
|
72
84
|
});
|
|
73
85
|
|
|
74
86
|
const sha1 = this.generateSha1(asarFilePath);
|
|
75
|
-
const packageJson = Utils.getPackage();
|
|
76
|
-
const version = packageJson.version;
|
|
77
87
|
const date = this._getFormattedDate();
|
|
78
88
|
const fileStat = fs.statSync(asarFilePath);
|
|
79
89
|
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
90
|
+
const item = {
|
|
91
|
+
version: version,
|
|
92
|
+
file: zipName,
|
|
93
|
+
size: fileStat.size,
|
|
94
|
+
sha1: sha1,
|
|
95
|
+
releaseDate: date,
|
|
96
|
+
};
|
|
97
|
+
let jsonName = "";
|
|
98
|
+
if (cfg.output.noPlatform === true) {
|
|
99
|
+
jsonName = cfg.output.file;
|
|
100
|
+
latestVersionInfo = item;
|
|
101
|
+
} else {
|
|
102
|
+
// 生成与系统有关的文件
|
|
103
|
+
jsonName = path.basename(cfg.output.file, '.json') + `-${platformForFilename}.json`;
|
|
104
|
+
if (platformForKey !== "") {
|
|
105
|
+
latestVersionInfo[platformForKey] = item;
|
|
106
|
+
} else {
|
|
107
|
+
console.log(chalk.blue('[ee-bin] [updater] ') + chalk.red(`Error: ${platformForFilename} is not supported`));
|
|
108
|
+
}
|
|
88
109
|
}
|
|
89
110
|
|
|
90
|
-
const updaterJsonFilePath = path.join(homeDir, cfg.output.directory,
|
|
111
|
+
const updaterJsonFilePath = path.join(homeDir, cfg.output.directory, jsonName);
|
|
91
112
|
Utils.writeJsonSync(updaterJsonFilePath, latestVersionInfo);
|
|
92
113
|
|
|
93
114
|
// 删除缓存文件,防止生成的 zip 是旧版本
|
|
94
115
|
if (cfg.cleanCache) {
|
|
95
116
|
Utils.rm(path.join(homeDir, cfg.output.directory, 'mac'));
|
|
117
|
+
Utils.rm(path.join(homeDir, cfg.output.directory, 'mac-arm64'));
|
|
96
118
|
Utils.rm(path.join(homeDir, cfg.output.directory, 'win-unpacked'));
|
|
119
|
+
Utils.rm(path.join(homeDir, cfg.output.directory, 'linux-unpacked'));
|
|
97
120
|
}
|
|
98
121
|
},
|
|
99
122
|
|