electron-version-deployer-cli 0.3.2 → 0.3.3
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/dist/cli.cjs +11 -8
- package/dist/main.js +48 -34
- package/package.json +1 -1
package/dist/cli.cjs
CHANGED
|
@@ -20,7 +20,7 @@ const jsdom = require("jsdom");
|
|
|
20
20
|
const DOMPurify = require("dompurify");
|
|
21
21
|
const archiver = require("archiver");
|
|
22
22
|
const prompts = require("@inquirer/prompts");
|
|
23
|
-
const
|
|
23
|
+
const electron = require("electron");
|
|
24
24
|
const node_os = require("node:os");
|
|
25
25
|
const fs = require("fs");
|
|
26
26
|
const path = require("path");
|
|
@@ -338,21 +338,24 @@ function genTmpFolder() {
|
|
|
338
338
|
}
|
|
339
339
|
function fetchRemotePkgJSON(remote_url) {
|
|
340
340
|
return new Promise((res, rej) => {
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
341
|
+
const request = electron.net.request(`${remote_url}/package.json`);
|
|
342
|
+
let data = "";
|
|
343
|
+
request.on("response", (response) => {
|
|
344
|
+
response.on("data", (chunk) => {
|
|
344
345
|
data += chunk;
|
|
345
346
|
});
|
|
346
|
-
|
|
347
|
+
response.on("end", () => {
|
|
347
348
|
try {
|
|
348
349
|
res(JSON.parse(data));
|
|
349
350
|
} catch (e) {
|
|
350
351
|
res(null);
|
|
351
352
|
}
|
|
352
353
|
});
|
|
353
|
-
}).on("error", (err) => {
|
|
354
|
-
rej(`自动更新检查请求失败:` + err.toString());
|
|
355
354
|
});
|
|
355
|
+
request.on("error", (error) => {
|
|
356
|
+
rej(`自动更新检查请求失败:` + error.toString());
|
|
357
|
+
});
|
|
358
|
+
request.end();
|
|
356
359
|
});
|
|
357
360
|
}
|
|
358
361
|
function versionToNum(a) {
|
|
@@ -663,4 +666,4 @@ async function installPrebuilt(configs) {
|
|
|
663
666
|
}
|
|
664
667
|
commander.program.description(
|
|
665
668
|
"Electron 版本部署 CLI,简化你的 Electron 软件更新,让一切变得简单。"
|
|
666
|
-
).helpOption("-h, --help", "使用帮助").version("0.3.
|
|
669
|
+
).helpOption("-h, --help", "使用帮助").version("0.3.3", "-V, --version", "显示版本号").parse(process.argv);
|
package/dist/main.js
CHANGED
|
@@ -3,48 +3,53 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
|
3
3
|
const electron = require("electron");
|
|
4
4
|
const node_url = require("node:url");
|
|
5
5
|
const node_path = require("node:path");
|
|
6
|
-
const node_https = require("node:https");
|
|
7
6
|
const node_fs = require("node:fs");
|
|
8
|
-
const extract = require("extract-zip");
|
|
9
7
|
const node_process = require("node:process");
|
|
10
8
|
const fs = require("fs");
|
|
11
9
|
const path = require("path");
|
|
10
|
+
const extract = require("extract-zip");
|
|
12
11
|
function fetchRemoteChangelogJSON(remote_url) {
|
|
13
12
|
return new Promise((res, rej) => {
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
13
|
+
const request = electron.net.request(`${remote_url}/changelog.json`);
|
|
14
|
+
let data = "";
|
|
15
|
+
request.on("response", (response) => {
|
|
16
|
+
response.on("data", (chunk) => {
|
|
17
17
|
data += chunk;
|
|
18
18
|
});
|
|
19
|
-
|
|
19
|
+
response.on("end", () => {
|
|
20
20
|
try {
|
|
21
21
|
res(JSON.parse(data));
|
|
22
22
|
} catch (e) {
|
|
23
23
|
res(null);
|
|
24
24
|
}
|
|
25
25
|
});
|
|
26
|
-
}).on("error", (err) => {
|
|
27
|
-
rej(`获取 changelog.json 失败:` + err.toString());
|
|
28
26
|
});
|
|
27
|
+
request.on("error", (error) => {
|
|
28
|
+
rej(`获取 changelog.json 失败:` + error.toString());
|
|
29
|
+
});
|
|
30
|
+
request.end();
|
|
29
31
|
});
|
|
30
32
|
}
|
|
31
33
|
function fetchRemotePkgJSON(remote_url) {
|
|
32
34
|
return new Promise((res, rej) => {
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
35
|
+
const request = electron.net.request(`${remote_url}/package.json`);
|
|
36
|
+
let data = "";
|
|
37
|
+
request.on("response", (response) => {
|
|
38
|
+
response.on("data", (chunk) => {
|
|
36
39
|
data += chunk;
|
|
37
40
|
});
|
|
38
|
-
|
|
41
|
+
response.on("end", () => {
|
|
39
42
|
try {
|
|
40
43
|
res(JSON.parse(data));
|
|
41
44
|
} catch (e) {
|
|
42
45
|
res(null);
|
|
43
46
|
}
|
|
44
47
|
});
|
|
45
|
-
}).on("error", (err) => {
|
|
46
|
-
rej(`自动更新检查请求失败:` + err.toString());
|
|
47
48
|
});
|
|
49
|
+
request.on("error", (error) => {
|
|
50
|
+
rej(`自动更新检查请求失败:` + error.toString());
|
|
51
|
+
});
|
|
52
|
+
request.end();
|
|
48
53
|
});
|
|
49
54
|
}
|
|
50
55
|
function versionToNum(a) {
|
|
@@ -255,22 +260,25 @@ async function installPkg(zipFile) {
|
|
|
255
260
|
for (let fileName of fullCodeSplitIndexFile) {
|
|
256
261
|
const tmpFilePath = node_path.join(appPath, fileName);
|
|
257
262
|
const tmpSplitZip = node_fs.createWriteStream(tmpFilePath);
|
|
258
|
-
await new Promise((_res) => {
|
|
259
|
-
|
|
260
|
-
`${remoteUrl}/fullCodeZipSplitZips/${fileName}?hash=${Math.random()}
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
263
|
+
await new Promise((_res, _rej) => {
|
|
264
|
+
const request = electron.net.request({
|
|
265
|
+
url: `${remoteUrl}/fullCodeZipSplitZips/${fileName}?hash=${Math.random()}`
|
|
266
|
+
});
|
|
267
|
+
request.on("response", (response) => {
|
|
268
|
+
response.on("data", (chunk) => {
|
|
269
|
+
tmpSplitZip.write(chunk);
|
|
270
|
+
});
|
|
271
|
+
response.on("end", () => {
|
|
272
|
+
tmpSplitZip.end(() => {
|
|
273
|
+
mergedStream.write(node_fs.readFileSync(tmpFilePath));
|
|
274
|
+
_res();
|
|
269
275
|
});
|
|
270
|
-
}
|
|
271
|
-
)
|
|
272
|
-
|
|
276
|
+
});
|
|
277
|
+
});
|
|
278
|
+
request.on("error", (error) => {
|
|
279
|
+
_rej(error);
|
|
273
280
|
});
|
|
281
|
+
request.end();
|
|
274
282
|
});
|
|
275
283
|
forceDeleteSync(tmpFilePath);
|
|
276
284
|
}
|
|
@@ -279,17 +287,23 @@ async function installPkg(zipFile) {
|
|
|
279
287
|
});
|
|
280
288
|
} else {
|
|
281
289
|
const tmpZipFilePath = node_fs.createWriteStream(unzipPath + ".zip");
|
|
282
|
-
|
|
283
|
-
|
|
290
|
+
const request = electron.net.request({
|
|
291
|
+
url: `${remoteUrl}/${zipFile}?hash=${Math.random()}`
|
|
292
|
+
});
|
|
293
|
+
request.on("response", (response) => {
|
|
294
|
+
response.on("data", (chunk) => {
|
|
295
|
+
tmpZipFilePath.write(chunk);
|
|
296
|
+
});
|
|
297
|
+
response.on("end", () => {
|
|
284
298
|
tmpZipFilePath.end(() => {
|
|
285
299
|
res();
|
|
286
300
|
});
|
|
287
|
-
}).on("error", (err) => {
|
|
288
|
-
rej(err);
|
|
289
301
|
});
|
|
290
|
-
}).on("error", (err) => {
|
|
291
|
-
rej(err);
|
|
292
302
|
});
|
|
303
|
+
request.on("error", (error) => {
|
|
304
|
+
rej(error);
|
|
305
|
+
});
|
|
306
|
+
request.end();
|
|
293
307
|
}
|
|
294
308
|
});
|
|
295
309
|
await extract(unzipPath + ".zip", { dir: unzipPath });
|