electron-updator 0.1.4 → 0.1.5

Sign up to get free protection for your applications and to get access to all the features.
package/README.md CHANGED
@@ -2,7 +2,6 @@
2
2
 
3
3
  [![NPM version][npm-image]][npm-url]
4
4
  [![CI][ci-image]][ci-url]
5
- [![Test coverage][codecov-image]][codecov-url]
6
5
  [![node version][node-image]][node-url]
7
6
  [![npm download][download-image]][download-url]
8
7
 
@@ -10,8 +9,6 @@
10
9
  [npm-url]: https://npmjs.org/package/electron-updator
11
10
  [ci-image]: https://github.com/electron-modules/electron-updator/actions/workflows/ci.yml/badge.svg
12
11
  [ci-url]: https://github.com/electron-modules/electron-updator/actions/workflows/ci.yml
13
- [codecov-image]: https://img.shields.io/codecov/c/github/electron-modules/electron-updator.svg?logo=codecov
14
- [codecov-url]: https://codecov.io/gh/electron-modules/electron-updator
15
12
  [node-image]: https://img.shields.io/badge/node.js-%3E=_16-green.svg
16
13
  [node-url]: http://nodejs.org/download/
17
14
  [download-image]: https://img.shields.io/npm/dm/electron-updator.svg
@@ -28,11 +25,11 @@ $ npm i electron-updator --save
28
25
 
29
26
  ## Contributors
30
27
 
31
- |[<img src="https://avatars.githubusercontent.com/u/1011681?v=4" width="100px;"/><br/><sub><b>xudafeng</b></sub>](https://github.com/xudafeng)<br/>|[<img src="https://avatars.githubusercontent.com/u/4081746?v=4" width="100px;"/><br/><sub><b>zlyi</b></sub>](https://github.com/zlyi)<br/>|
32
- | :---: | :---: |
28
+ |[<img src="https://avatars.githubusercontent.com/u/4081746?v=4" width="100px;"/><br/><sub><b>zlyi</b></sub>](https://github.com/zlyi)<br/>|[<img src="https://avatars.githubusercontent.com/u/1011681?v=4" width="100px;"/><br/><sub><b>xudafeng</b></sub>](https://github.com/xudafeng)<br/>|[<img src="https://avatars.githubusercontent.com/u/52845048?v=4" width="100px;"/><br/><sub><b>snapre</b></sub>](https://github.com/snapre)<br/>|
29
+ | :---: | :---: | :---: |
33
30
 
34
31
 
35
- This project follows the git-contributor [spec](https://github.com/xudafeng/git-contributor), auto updated at `Mon Jan 30 2023 19:21:07 GMT+0800`.
32
+ This project follows the git-contributor [spec](https://github.com/xudafeng/git-contributor), auto updated at `Tue Jan 31 2023 14:31:40 GMT+0800`.
36
33
 
37
34
  <!-- GITCONTRIBUTOR_END -->
38
35
 
@@ -14,7 +14,7 @@ class AppUpdator extends eventemitter3_1.EventEmitter {
14
14
  this.logger = this._wrapLogger(options.logger);
15
15
  this.app = app || new elelctron_app_adapter_1.ElectronAppAdapter();
16
16
  this.startTimeStamp = new Date().getTime();
17
- this.logger.info('AppUpdator#constructor');
17
+ this.logger.info('ElectronUpdator#constructor');
18
18
  this.availableUpdate = {
19
19
  resourcePath: '',
20
20
  latestAsarPath: '',
@@ -41,17 +41,17 @@ class AppUpdator extends eventemitter3_1.EventEmitter {
41
41
  return _logger;
42
42
  }
43
43
  setState(state) {
44
- this.logger.info(`AppUpdator#setState${state}`);
44
+ this.logger.info(`ElectronUpdator#setState${state}`);
45
45
  this.state = state;
46
46
  }
47
47
  setFeedUrl(url) {
48
- this.logger.info(`AppUpdator#setFeedUrl:url is ${url}`);
48
+ this.logger.info(`ElectronUpdator#setFeedUrl:url is ${url}`);
49
49
  if (url && this.options) {
50
50
  this.options.url = url;
51
51
  }
52
52
  }
53
53
  async checkForUpdates(executeType = constants_1.ExecuteType.Auto) {
54
- this.logger.info(`AppUpdator#checkForUpdates:state is ${this.state}`);
54
+ this.logger.info(`ElectronUpdator#checkForUpdates:state is ${this.state}`);
55
55
  this.setState("idle" /* StateType.Idle */);
56
56
  try {
57
57
  // 新一轮更新流程,更新 TimeStamp
@@ -70,10 +70,10 @@ class AppUpdator extends eventemitter3_1.EventEmitter {
70
70
  this.setState("idle" /* StateType.Idle */);
71
71
  return;
72
72
  }
73
- this.logger.info('AppUpdator#checkForUpdates:needUpdate is true');
73
+ this.logger.info('ElectronUpdator#checkForUpdates:needUpdate is true');
74
74
  this.availableUpdate = this.doGetAvailableUpdateInfo(this.updateInfo);
75
75
  if (!this.options?.autoDownload || executeType === constants_1.ExecuteType.User) {
76
- this.logger.info('AppUpdator#checkForUpdates:emit UPDATE_AVAILABLE');
76
+ this.logger.info('ElectronUpdator#checkForUpdates:emit UPDATE_AVAILABLE');
77
77
  this.emit(constants_1.EventType.UPDATE_AVAILABLE, {
78
78
  updateInfo: this.updateInfo,
79
79
  executeType,
@@ -89,11 +89,11 @@ class AppUpdator extends eventemitter3_1.EventEmitter {
89
89
  }
90
90
  }
91
91
  async downloadUpdate(executeType = constants_1.ExecuteType.User) {
92
- this.logger.info(`AppUpdator#downloadUpdate:executeType is ${executeType}`);
92
+ this.logger.info(`ElectronUpdator#downloadUpdate:executeType is ${executeType}`);
93
93
  await this.downloadUpdateFile(this.updateInfo);
94
94
  const result = await this.preCheck();
95
95
  if (result.success) {
96
- this.logger.info('AppUpdator#downloadUpdate:emit UPDATE_DOWNLOADED');
96
+ this.logger.info('ElectronUpdator#downloadUpdate:emit UPDATE_DOWNLOADED');
97
97
  this.emit(constants_1.EventType.UPDATE_DOWNLOADED, {
98
98
  executeType,
99
99
  });
@@ -104,7 +104,7 @@ class AppUpdator extends eventemitter3_1.EventEmitter {
104
104
  }
105
105
  }
106
106
  async quitAndInstall() {
107
- this.logger.info(`AppUpdator#quitAndInstall:state is ${this.state}`);
107
+ this.logger.info(`ElectronUpdator#quitAndInstall:state is ${this.state}`);
108
108
  if (this.state !== "downloaded" /* StateType.Downloaded */) {
109
109
  this.downloadUpdate();
110
110
  return;
@@ -119,7 +119,7 @@ class AppUpdator extends eventemitter3_1.EventEmitter {
119
119
  result = await this.doQuitAndInstallAsar();
120
120
  }
121
121
  if (result.success) {
122
- this.logger.warn('AppUpdator#quitAndInstall:install success');
122
+ this.logger.warn('ElectronUpdator#quitAndInstall:install success');
123
123
  this.emit(constants_1.EventType.BEFORE_QUIT_FOR_UPDATE);
124
124
  }
125
125
  else {
@@ -132,21 +132,21 @@ class AppUpdator extends eventemitter3_1.EventEmitter {
132
132
  }
133
133
  }
134
134
  async preCheckForAsar() {
135
- this.logger.info('AppUpdator#preCheckForAsar');
135
+ this.logger.info('ElectronUpdator#preCheckForAsar');
136
136
  return await this.unzip();
137
137
  }
138
138
  async preCheck() {
139
- this.logger.info('AppUpdator#preCheck');
139
+ this.logger.info('ElectronUpdator#preCheck');
140
140
  const { resourcePath } = this.availableUpdate;
141
141
  if (this.state !== "downloaded" /* StateType.Downloaded */) {
142
142
  return {
143
143
  success: false,
144
- error: new Error(`AppUpdator#preCheck:update status(${this.state}) error`),
144
+ error: new Error(`ElectronUpdator#preCheck:update status(${this.state}) error`),
145
145
  };
146
146
  }
147
147
  // 清理老包
148
148
  try {
149
- this.logger.info('AppUpdator#preCheck:cleanOldArchive');
149
+ this.logger.info('ElectronUpdator#preCheck:cleanOldArchive');
150
150
  await (0, utils_1.cleanOldArchive)(resourcePath);
151
151
  }
152
152
  catch (e) {
@@ -180,7 +180,7 @@ class AppUpdator extends eventemitter3_1.EventEmitter {
180
180
  }
181
181
  async downloadUpdateFile(updateInfo) {
182
182
  if (this.state !== "checking-for-update" /* StateType.CheckingForUpdate */) {
183
- throw new Error(`AppUpdator#downloadUpdateFile:update status(${this.state}) error`);
183
+ throw new Error(`ElectronUpdator#downloadUpdateFile:update status(${this.state}) error`);
184
184
  }
185
185
  const { url, signature } = updateInfo.files[0];
186
186
  const { downloadTargetDir } = this.availableUpdate;
@@ -196,7 +196,7 @@ class AppUpdator extends eventemitter3_1.EventEmitter {
196
196
  this.emit(constants_1.EventType.UPDATE_DOWNLOAD_PROGRESS, data);
197
197
  },
198
198
  });
199
- this.logger.info('AppUpdator#downloadUpdateFile:Downloaded');
199
+ this.logger.info('ElectronUpdator#downloadUpdateFile:Downloaded');
200
200
  this.setState("downloaded" /* StateType.Downloaded */);
201
201
  }
202
202
  catch (e) {
@@ -206,7 +206,7 @@ class AppUpdator extends eventemitter3_1.EventEmitter {
206
206
  }
207
207
  }
208
208
  async unzip() {
209
- this.logger.info('AppUpdator#unzip:start');
209
+ this.logger.info('ElectronUpdator#unzip:start');
210
210
  try {
211
211
  const result = await this.doUnzip();
212
212
  if (!result.success) {
@@ -96,7 +96,7 @@ class MacUpdator extends app_updator_1.AppUpdator {
96
96
  };
97
97
  }
98
98
  async doQuitAndInstallPackage() {
99
- this.logger.info('AppUpdator#doQuitAndInstallPackage:start');
99
+ this.logger.info('ElectronUpdator#doQuitAndInstallPackage:start');
100
100
  return await (0, install_macos_dmg_1.default)(this.options, this.logger, this.availableUpdate, this.updateInfo);
101
101
  }
102
102
  }
@@ -5,12 +5,12 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.getExecuteFile = exports.requestUpdateInfo = exports.existFile = exports.cleanOldArchive = exports.spawnAsync = exports.waitUntil = exports.sleep = exports.getMacOSAppPath = exports.sudoPrompt = exports.existsSync = exports.createWriteStream = exports.isMac = exports.isWin = exports.execAsync = exports.rimrafAsync = exports.readdirAsync = exports.existsAsync = exports.renameAsync = void 0;
7
7
  const path_1 = __importDefault(require("path"));
8
- const child_process_1 = require("child_process");
9
8
  const util_1 = __importDefault(require("util"));
10
9
  const urllib_1 = __importDefault(require("urllib"));
11
10
  const sudo_prompt_alt_1 = __importDefault(require("sudo-prompt-alt"));
12
11
  exports.sudoPrompt = sudo_prompt_alt_1.default;
13
12
  const rimraf_alt_1 = __importDefault(require("rimraf-alt"));
13
+ const child_process_1 = require("child_process");
14
14
  const original_fs_1 = require("original-fs");
15
15
  Object.defineProperty(exports, "existsSync", { enumerable: true, get: function () { return original_fs_1.existsSync; } });
16
16
  Object.defineProperty(exports, "createWriteStream", { enumerable: true, get: function () { return original_fs_1.createWriteStream; } });
@@ -76,7 +76,7 @@ class WindowsUpdator extends app_updator_1.AppUpdator {
76
76
  const executeCommand = `"${updateExePath}" "${targetPath}" "${resourcePath}" "${productName}.exe" "${exePath}"`;
77
77
  try {
78
78
  await (0, sudo_prompt_exec_1.sudoPromptExec)(this.options, this.logger, executeCommand);
79
- this.logger.warn('AppUpdator#quitAndInstall:install success');
79
+ this.logger.warn('ElectronUpdator#quitAndInstall:install success');
80
80
  this.emit(constants_1.EventType.BEFORE_QUIT_FOR_UPDATE);
81
81
  return Promise.resolve({ success: true });
82
82
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "electron-updator",
3
- "version": "0.1.4",
3
+ "version": "0.1.5",
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",
@@ -26,11 +26,11 @@
26
26
  },
27
27
  "dependencies": {
28
28
  "eventemitter3": "^4.0.0",
29
- "lodash": "4.17.21",
30
- "moment": "2.29.4",
29
+ "lodash": "4",
30
+ "moment": "2",
31
31
  "rimraf-alt": "*",
32
32
  "sudo-prompt-alt": "9",
33
- "urllib": "2.34.1"
33
+ "urllib": "2"
34
34
  },
35
35
  "devDependencies": {
36
36
  "@applint/spec": "^1.2.0",