electron-updator 0.1.6 → 1.0.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -59,10 +59,10 @@ class AppUpdator extends eventemitter3_1.EventEmitter {
59
59
  this.setState(constants_1.StateType.CheckingForUpdate);
60
60
  this.emit(constants_1.EventType.CHECKING_FOR_UPDATE);
61
61
  const updateInfoResponse = await (0, utils_1.requestUpdateInfo)(this.options);
62
- this.updateInfo = (this.options?.responseFormatter ? this.options?.responseFormatter(updateInfoResponse) : updateInfoResponse);
63
- const needUpdate = this.options?.needUpdate(updateInfoResponse);
64
- if (!needUpdate) {
65
- this.logger.info(`updateInfo is ${JSON.stringify(this.updateInfo)},needUpdate is false`);
62
+ this.updateInfo = (this.options?.updateInfoFormatter ? this.options?.updateInfoFormatter(updateInfoResponse) : updateInfoResponse);
63
+ const ifNeedUpdate = this.options?.ifNeedUpdate(updateInfoResponse);
64
+ if (!ifNeedUpdate) {
65
+ this.logger.info(`ElectronUpdator#updateInfo is ${JSON.stringify(this.updateInfo)},ifNeedUpdate is false`);
66
66
  this.emit(constants_1.EventType.UPDATE_NOT_AVAILABLE, {
67
67
  updateInfo: this.updateInfo,
68
68
  executeType,
@@ -70,7 +70,7 @@ class AppUpdator extends eventemitter3_1.EventEmitter {
70
70
  this.setState(constants_1.StateType.Idle);
71
71
  return;
72
72
  }
73
- this.logger.info('ElectronUpdator#checkForUpdates:needUpdate is true');
73
+ this.logger.info('ElectronUpdator#checkForUpdates:ifNeedUpdate is true');
74
74
  this.availableUpdate = this.doGetAvailableUpdateInfo(this.updateInfo);
75
75
  if (!this.options?.autoDownload || executeType === constants_1.ExecuteType.User) {
76
76
  this.logger.info('ElectronUpdator#checkForUpdates:emit UPDATE_AVAILABLE');
@@ -11,7 +11,7 @@ const install_macos_dmg_1 = __importDefault(require("./utils/install-macos-dmg")
11
11
  const utils_1 = require("./utils");
12
12
  class MacUpdator extends app_updator_1.AppUpdator {
13
13
  doGetAvailableUpdateInfo(updateInfo) {
14
- this.logger.info('MacUpdator#doGetAvailableUpdateInfo:start');
14
+ this.logger.info('ElectronUpdator#MacUpdator#doGetAvailableUpdateInfo:start');
15
15
  const exePath = this.app.exePath;
16
16
  const resourcePath = path_1.default.resolve(exePath, '..', '..', 'Resources');
17
17
  const latestAsarPath = path_1.default.resolve(resourcePath, 'latest.asar');
@@ -27,7 +27,7 @@ class MacUpdator extends app_updator_1.AppUpdator {
27
27
  };
28
28
  }
29
29
  async doPreCheckForPackage() {
30
- this.logger.info('MacUpdator#doPreCheckForPackage:start');
30
+ this.logger.info('ElectronUpdator#MacUpdator#doPreCheckForPackage:start');
31
31
  // Mac 全量安装前,先进行 dmg 安装检查
32
32
  return await (0, install_macos_dmg_1.default)(this.options, this.logger, this.availableUpdate, this.updateInfo, true);
33
33
  }
@@ -36,7 +36,7 @@ class MacUpdator extends app_updator_1.AppUpdator {
36
36
  * @return
37
37
  */
38
38
  async doUnzip() {
39
- this.logger.info('MacUpdator#doUnzip:start');
39
+ this.logger.info('ElectronUpdator#MacUpdator#doUnzip:start');
40
40
  const { resourcePath, downloadTargetDir } = this.availableUpdate;
41
41
  try {
42
42
  // 直接解压
@@ -56,9 +56,9 @@ class MacUpdator extends app_updator_1.AppUpdator {
56
56
  }
57
57
  }
58
58
  async doQuitAndInstallAsar() {
59
- this.logger.info('MacUpdator#doQuitAndInstallAsar:start');
59
+ this.logger.info('ElectronUpdator#MacUpdator#doQuitAndInstallAsar:start');
60
60
  if (!this.availableUpdate) {
61
- this.logger.error('MacUpdator#doQuitAndInstallAsar:not availableUpdate');
61
+ this.logger.error('ElectronUpdator#MacUpdator#doQuitAndInstallAsar:not availableUpdate');
62
62
  return Promise.resolve({ success: false });
63
63
  }
64
64
  const { resourcePath, latestAsarPath } = this.availableUpdate;
@@ -17,7 +17,7 @@ const _1 = require(".");
17
17
  * @return
18
18
  */
19
19
  const downloadFile = async ({ logger, url, signature, targetDir, progressHandle }) => {
20
- logger.info('downloadFile#downloadFile (start)');
20
+ logger.info('ElectronUpdator#downloadFile#downloadFile (start)');
21
21
  const writeStream = (0, _1.createWriteStream)(targetDir);
22
22
  let currentLength = 0;
23
23
  let currentProgress = 0;
@@ -33,7 +33,7 @@ const downloadFile = async ({ logger, url, signature, targetDir, progressHandle
33
33
  })
34
34
  .then((res) => {
35
35
  const totalLength = res.headers['content-length'];
36
- logger.info(`downloadFile#downloadFile (then),totalLength is ${totalLength}`);
36
+ logger.info(`ElectronUpdator#downloadFile#downloadFile (then),totalLength is ${totalLength}`);
37
37
  res.res.on('data', (data) => {
38
38
  try {
39
39
  currentLength += data.length;
@@ -63,7 +63,7 @@ const downloadFile = async ({ logger, url, signature, targetDir, progressHandle
63
63
  url,
64
64
  signature,
65
65
  });
66
- logger.info('download file success, url:%s, to %s', url, targetDir);
66
+ logger.info('ElectronUpdator#download file success, url:%s, to %s', url, targetDir);
67
67
  resolve();
68
68
  }
69
69
  catch (e) {
@@ -7,15 +7,15 @@ function sudoPromptExec(appUpdatorOptions, logger, shell) {
7
7
  name: appUpdatorOptions.productName,
8
8
  };
9
9
  return new Promise((resolve, reject) => {
10
- logger.warn(`update#sudoPromptExec_shell_${shell}`);
10
+ logger.warn(`ElectronUpdator#update#sudoPromptExec_shell_${shell}`);
11
11
  index_1.sudoPrompt.exec(shell, options, (error, stdout) => {
12
12
  if (error) {
13
13
  reject(error);
14
- logger.error(`update#sudoPromptExec_error_${error}`);
14
+ logger.error(`ElectronUpdator#update#sudoPromptExec_error_${error}`);
15
15
  return;
16
16
  }
17
17
  resolve(stdout);
18
- logger.warn(`update#sudoPromptExec_stdout_${stdout}`);
18
+ logger.warn(`ElectronUpdator#update#sudoPromptExec_stdout_${stdout}`);
19
19
  });
20
20
  });
21
21
  }
@@ -12,7 +12,7 @@ const app_updator_1 = require("./app-updator");
12
12
  const utils_1 = require("./utils");
13
13
  class WindowsUpdator extends app_updator_1.AppUpdator {
14
14
  doGetAvailableUpdateInfo(updateInfo) {
15
- this.logger.info('WindowsUpdator#doGetAvailableUpdateInfo:start');
15
+ this.logger.info('ElectronUpdator#WindowsUpdator#doGetAvailableUpdateInfo:start');
16
16
  const resourcePath = path_1.default.resolve(this.app.userDataPath);
17
17
  const latestAsarPath = path_1.default.resolve(resourcePath, 'latest.asar');
18
18
  const latestAppPath = path_1.default.resolve(resourcePath, 'latest');
@@ -27,12 +27,12 @@ class WindowsUpdator extends app_updator_1.AppUpdator {
27
27
  };
28
28
  }
29
29
  async doPreCheckForPackage() {
30
- this.logger.info('WindowsUpdator#doPreCheckForPackage:start');
30
+ this.logger.info('ElectronUpdator#WindowsUpdator#doPreCheckForPackage:start');
31
31
  // Windows 全量安装默认预检正常
32
32
  return Promise.resolve({ success: true });
33
33
  }
34
34
  async doUnzip() {
35
- this.logger.info('WindowsUpdator#doUnzip:start');
35
+ this.logger.info('ElectronUpdator#WindowsUpdator#doUnzip:start');
36
36
  try {
37
37
  const { downloadTargetDir, resourcePath } = this.availableUpdate;
38
38
  const unzipExe = (0, utils_1.getExecuteFile)('unzip.exe');
@@ -45,13 +45,13 @@ class WindowsUpdator extends app_updator_1.AppUpdator {
45
45
  error,
46
46
  };
47
47
  }
48
- this.logger.info('WindowsUpdator#doUnzip:success');
48
+ this.logger.info('ElectronUpdator#WindowsUpdator#doUnzip:success');
49
49
  return {
50
50
  success: true,
51
51
  };
52
52
  }
53
53
  async doQuitAndInstallPackage() {
54
- this.logger.info('WindowsUpdator#doQuitAndInstallPackage:success');
54
+ this.logger.info('ElectronUpdator#WindowsUpdator#doQuitAndInstallPackage:success');
55
55
  const { downloadTargetDir } = this.availableUpdate;
56
56
  try {
57
57
  // Windows 全量安装
@@ -67,7 +67,7 @@ class WindowsUpdator extends app_updator_1.AppUpdator {
67
67
  }
68
68
  }
69
69
  async doQuitAndInstallAsar() {
70
- this.logger.info('WindowsUpdator#doQuitAndInstallAsar:start');
70
+ this.logger.info('ElectronUpdator#WindowsUpdator#doQuitAndInstallAsar:start');
71
71
  const productName = this.options?.productName;
72
72
  const { resourcePath } = this.availableUpdate;
73
73
  const exePath = this.app.exePath;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "electron-updator",
3
- "version": "0.1.6",
3
+ "version": "1.0.1",
4
4
  "description": "electron-updator is a software updator management solution for Electron applications, It is convenient to complete full software update and dynamic update.",
5
5
  "scripts": {
6
6
  "build": "sh ./build.sh",