graceful-updater 1.1.1-beta.1 → 1.1.2-beta.0
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/README.en.md +1 -0
- package/README.md +1 -0
- package/build/app-updator.js +22 -0
- package/build/mac-updator.js +16 -7
- package/build/windows-updator.js +6 -0
- package/package.json +3 -3
package/README.en.md
CHANGED
@@ -104,6 +104,7 @@ electronUpdator.on(EventType.UPDATE_DOWNLOAD_PROGRESS, (data) => {
|
|
104
104
|
| logger | Object | No | Log method | `console` |
|
105
105
|
| productName | String | Yes | Application Name | |
|
106
106
|
| autoDownload | String | No | Whether to download automatically | false |
|
107
|
+
| getWindowsHelperExeDir | Function | No | Windows helper directory | false |
|
107
108
|
|
108
109
|
|
109
110
|
### UpdateInfo
|
package/README.md
CHANGED
@@ -103,6 +103,7 @@ electronUpdator.on(EventType.UPDATE_DOWNLOAD_PROGRESS, (data) => {
|
|
103
103
|
| logger | Object | 非必须 | 日志 | `console` |
|
104
104
|
| productName | String | 必须 | 应用完整名称 | |
|
105
105
|
| autoDownload | String | 非必须 | 是否自动下载 | false |
|
106
|
+
| getWindowsHelperExeDir | Function | 非必须 | Windows 下 helper 目录 | false |
|
106
107
|
|
107
108
|
|
108
109
|
### UpdateInfo
|
package/build/app-updator.js
CHANGED
@@ -136,6 +136,28 @@ class AppUpdator extends eventemitter3_1.EventEmitter {
|
|
136
136
|
this.dispatchError(e);
|
137
137
|
}
|
138
138
|
}
|
139
|
+
async install() {
|
140
|
+
this.logger.info(`install:state is ${this.state}`);
|
141
|
+
let result = { success: false };
|
142
|
+
this.setState(constants_1.StateType.Idle);
|
143
|
+
try {
|
144
|
+
this.emit(constants_1.EventType.BEFORE_QUIT_FOR_UPDATE);
|
145
|
+
if (this.updateInfo?.updateType === constants_1.UpdateType.Package) {
|
146
|
+
result = await this.doInstallPackage();
|
147
|
+
}
|
148
|
+
else {
|
149
|
+
result = await this.doInstallAsar();
|
150
|
+
}
|
151
|
+
if (!result.success) {
|
152
|
+
result.message = `error: ${result.error?.message}`;
|
153
|
+
this.dispatchError(result.error);
|
154
|
+
}
|
155
|
+
}
|
156
|
+
catch (e) {
|
157
|
+
this.dispatchError(e);
|
158
|
+
}
|
159
|
+
return result;
|
160
|
+
}
|
139
161
|
async preCheckForAsar() {
|
140
162
|
this.logger.info('preCheckForAsar');
|
141
163
|
return await this.unzip();
|
package/build/mac-updator.js
CHANGED
@@ -12,8 +12,7 @@ const utils_1 = require("./utils");
|
|
12
12
|
class MacUpdator extends app_updator_1.AppUpdator {
|
13
13
|
doGetAvailableUpdateInfo(updateInfo) {
|
14
14
|
this.logger.info('MacUpdator#doGetAvailableUpdateInfo:start');
|
15
|
-
const
|
16
|
-
const resourcePath = path_1.default.resolve(exePath, '..', '..', 'Resources');
|
15
|
+
const resourcePath = path_1.default.resolve(this.app.userDataPath);
|
17
16
|
const latestAsarPath = path_1.default.resolve(resourcePath, constants_1.FileName.TARGET_REPLACEMENT_ASAR);
|
18
17
|
const latestAppPath = path_1.default.resolve(resourcePath, 'latest');
|
19
18
|
let downloadTargetDir = `${latestAsarPath}.zip`;
|
@@ -67,6 +66,14 @@ class MacUpdator extends app_updator_1.AppUpdator {
|
|
67
66
|
}
|
68
67
|
}
|
69
68
|
async doQuitAndInstallAsar() {
|
69
|
+
const result = await this.doInstallAsar();
|
70
|
+
if (result.success) {
|
71
|
+
this.logger.warn('MacUpdator#quitAndInstall:install success');
|
72
|
+
this.app.relaunch();
|
73
|
+
}
|
74
|
+
return result;
|
75
|
+
}
|
76
|
+
async doInstallAsar() {
|
70
77
|
this.logger.info('MacUpdator#doQuitAndInstallAsar:start');
|
71
78
|
if (!this.availableUpdate) {
|
72
79
|
this.logger.error('MacUpdator#doQuitAndInstallAsar:not availableUpdate');
|
@@ -99,21 +106,23 @@ class MacUpdator extends app_updator_1.AppUpdator {
|
|
99
106
|
error,
|
100
107
|
};
|
101
108
|
}
|
102
|
-
this.logger.warn('MacUpdator#quitAndInstall:install success');
|
103
|
-
this.app.relaunch();
|
104
109
|
return {
|
105
110
|
success: true,
|
106
111
|
};
|
107
112
|
}
|
108
113
|
async doQuitAndInstallPackage() {
|
109
|
-
this.
|
110
|
-
const result = await (0, install_macos_dmg_1.default)(this.options, this.logger, this.availableUpdate, this.updateInfo);
|
114
|
+
const result = await this.doInstallPackage();
|
111
115
|
if (result.success) {
|
112
|
-
this.logger.warn('quitAndInstall:install success');
|
116
|
+
this.logger.warn('MacUpdator#quitAndInstall:install success');
|
113
117
|
this.app.relaunch();
|
114
118
|
}
|
115
119
|
return result;
|
116
120
|
}
|
121
|
+
async doInstallPackage() {
|
122
|
+
this.logger.info('MacUpdator#doQuitAndInstallPackage:start');
|
123
|
+
const result = await (0, install_macos_dmg_1.default)(this.options, this.logger, this.availableUpdate, this.updateInfo);
|
124
|
+
return result;
|
125
|
+
}
|
117
126
|
}
|
118
127
|
exports.MacUpdator = MacUpdator;
|
119
128
|
//# sourceMappingURL=mac-updator.js.map
|
package/build/windows-updator.js
CHANGED
@@ -63,6 +63,9 @@ class WindowsUpdator extends app_updator_1.AppUpdator {
|
|
63
63
|
success: true,
|
64
64
|
};
|
65
65
|
}
|
66
|
+
async doInstallPackage() {
|
67
|
+
return { success: false };
|
68
|
+
}
|
66
69
|
async doQuitAndInstallPackage() {
|
67
70
|
this.logger.info('WindowsUpdator#doQuitAndInstallPackage:success');
|
68
71
|
const { downloadTargetDir } = this.availableUpdate;
|
@@ -80,6 +83,9 @@ class WindowsUpdator extends app_updator_1.AppUpdator {
|
|
80
83
|
return Promise.resolve({ success: false, error });
|
81
84
|
}
|
82
85
|
}
|
86
|
+
async doInstallAsar() {
|
87
|
+
return { success: false };
|
88
|
+
}
|
83
89
|
async doQuitAndInstallAsar() {
|
84
90
|
this.logger.info('WindowsUpdator#doQuitAndInstallAsar:start');
|
85
91
|
const productName = this.options?.productName;
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "graceful-updater",
|
3
|
-
"version": "1.1.
|
3
|
+
"version": "1.1.2-beta.0",
|
4
4
|
"description": "graceful-updater 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",
|
@@ -25,7 +25,7 @@
|
|
25
25
|
},
|
26
26
|
"dependencies": {
|
27
27
|
"eventemitter3": "^4.0.0",
|
28
|
-
"graceful-updater-windows-helper": "1
|
28
|
+
"graceful-updater-windows-helper": "1",
|
29
29
|
"lodash": "4",
|
30
30
|
"moment": "2",
|
31
31
|
"nanoid": "^3.3.4",
|
@@ -70,4 +70,4 @@
|
|
70
70
|
}
|
71
71
|
},
|
72
72
|
"license": "MIT"
|
73
|
-
}
|
73
|
+
}
|