electron-version-deployer-cli 0.3.1 → 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 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 node_https = require("node:https");
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
- node_https.get(`${remote_url}/package.json`, (_res) => {
342
- let data = "";
343
- _res.on("data", (chunk) => {
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
- _res.on("end", () => {
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) {
@@ -382,10 +385,11 @@ const _Netlify = class _Netlify {
382
385
  throw new Error("netlify 配置为空");
383
386
  return new Promise((res) => {
384
387
  const cmd = node_os.platform() === "win32" ? "netlify.cmd" : "netlify";
388
+ const folderPath = props.folder.includes(" ") ? `"${props.folder}"` : props.folder;
385
389
  const output = node_child_process.spawn(cmd, [
386
390
  "deploy",
387
391
  "--dir",
388
- props.folder,
392
+ folderPath,
389
393
  "--site",
390
394
  netlifyConfig.siteID,
391
395
  "--auth",
@@ -662,4 +666,4 @@ async function installPrebuilt(configs) {
662
666
  }
663
667
  commander.program.description(
664
668
  "Electron 版本部署 CLI,简化你的 Electron 软件更新,让一切变得简单。"
665
- ).helpOption("-h, --help", "使用帮助").version("0.3.1", "-V, --version", "显示版本号").parse(process.argv);
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
- node_https.get(`${remote_url}/changelog.json`, (_res) => {
15
- let data = "";
16
- _res.on("data", (chunk) => {
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
- _res.on("end", () => {
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
- node_https.get(`${remote_url}/package.json`, (_res) => {
34
- let data = "";
35
- _res.on("data", (chunk) => {
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
- _res.on("end", () => {
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) {
@@ -116,6 +121,10 @@ function EVDInit(props) {
116
121
  }
117
122
  globalArgs = props;
118
123
  const { detectionFrequency, detectAtStart, onError } = getConfigs();
124
+ const appPath = electron.app.getAppPath();
125
+ cacheCurrentPkgJSON = JSON.parse(
126
+ node_fs.readFileSync(node_path.join(appPath, "package.json"), "utf-8")
127
+ );
119
128
  setInterval(async () => {
120
129
  try {
121
130
  await EVDCheckUpdate();
@@ -132,10 +141,6 @@ function EVDInit(props) {
132
141
  onError(e);
133
142
  }
134
143
  }, 1e3 * 2);
135
- const appPath = electron.app.getAppPath();
136
- cacheCurrentPkgJSON = JSON.parse(
137
- node_fs.readFileSync(node_path.join(appPath, "package.json"), "utf-8")
138
- );
139
144
  }
140
145
  async function EVDCheckUpdate() {
141
146
  const { remoteUrl } = getConfigs();
@@ -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
- node_https.get(
260
- `${remoteUrl}/fullCodeZipSplitZips/${fileName}?hash=${Math.random()}`,
261
- (response) => {
262
- response.pipe(tmpSplitZip).on("finish", () => {
263
- tmpSplitZip.end(() => {
264
- mergedStream.write(node_fs.readFileSync(tmpFilePath));
265
- _res();
266
- });
267
- }).on("error", (err) => {
268
- rej(err);
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
- ).on("error", (err) => {
272
- rej(err);
276
+ });
273
277
  });
278
+ request.on("error", (error) => {
279
+ _rej(error);
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
- node_https.get(`${remoteUrl}/${zipFile}?hash=${Math.random()}`, (response) => {
283
- response.pipe(tmpZipFilePath).on("finish", () => {
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 });
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "electron-version-deployer-cli",
3
3
  "private": false,
4
- "version": "0.3.1",
4
+ "version": "0.3.3",
5
5
  "types": "./dist/index.d.ts",
6
6
  "main": "./dist/index.cjs.js",
7
7
  "module": "./dist/index.es.js",