graceful-updater 1.1.2-beta.1 → 1.2.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/build/app-updator.js +0 -22
- package/build/mac-updator.js +11 -23
- package/build/windows-updator.js +0 -6
- package/package.json +3 -3
package/build/app-updator.js
CHANGED
@@ -136,28 +136,6 @@ 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
|
-
}
|
161
139
|
async preCheckForAsar() {
|
162
140
|
this.logger.info('preCheckForAsar');
|
163
141
|
return await this.unzip();
|
package/build/mac-updator.js
CHANGED
@@ -12,12 +12,12 @@ 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
|
15
|
+
const exePath = this.app.exePath;
|
16
|
+
const resourcePath = path_1.default.resolve(exePath, '..', '..', 'Resources');
|
16
17
|
const latestAsarPath = path_1.default.resolve(resourcePath, constants_1.FileName.TARGET_REPLACEMENT_ASAR);
|
17
|
-
const latestAppPath = path_1.default.resolve(resourcePath, 'latest');
|
18
18
|
let downloadTargetDir = `${latestAsarPath}.zip`;
|
19
19
|
if (updateInfo.updateType === constants_1.UpdateType.Package) {
|
20
|
-
downloadTargetDir =
|
20
|
+
downloadTargetDir = path_1.default.resolve(path_1.default.resolve(this.app.userDataPath), 'latest.dmg');
|
21
21
|
}
|
22
22
|
return {
|
23
23
|
resourcePath,
|
@@ -39,12 +39,12 @@ class MacUpdator extends app_updator_1.AppUpdator {
|
|
39
39
|
this.logger.info('MacUpdator#doUnzip:start, unzip %s, to %s', downloadTargetDir, resourcePath);
|
40
40
|
try {
|
41
41
|
// 直接解压
|
42
|
-
await (0, utils_1.execAsync)(`unzip -o
|
42
|
+
await (0, utils_1.execAsync)(`unzip -o ${downloadTargetDir}`, {
|
43
43
|
cwd: resourcePath,
|
44
44
|
maxBuffer: 2 ** 28,
|
45
45
|
});
|
46
46
|
if (!await (0, utils_1.existsAsync)(latestAsarPath)) {
|
47
|
-
const zipInfo = await (0, utils_1.execAsync)(`unzip -Z -1
|
47
|
+
const zipInfo = await (0, utils_1.execAsync)(`unzip -Z -1 ${downloadTargetDir}`, {
|
48
48
|
cwd: resourcePath,
|
49
49
|
maxBuffer: 2 ** 28,
|
50
50
|
});
|
@@ -66,14 +66,6 @@ class MacUpdator extends app_updator_1.AppUpdator {
|
|
66
66
|
}
|
67
67
|
}
|
68
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() {
|
77
69
|
this.logger.info('MacUpdator#doQuitAndInstallAsar:start');
|
78
70
|
if (!this.availableUpdate) {
|
79
71
|
this.logger.error('MacUpdator#doQuitAndInstallAsar:not availableUpdate');
|
@@ -81,9 +73,7 @@ class MacUpdator extends app_updator_1.AppUpdator {
|
|
81
73
|
}
|
82
74
|
const { resourcePath, latestAsarPath } = this.availableUpdate;
|
83
75
|
const oldAsarPath = path_1.default.resolve(resourcePath, `${constants_1.OldArchivePrefix}${new Date().getTime()}.asar`);
|
84
|
-
const
|
85
|
-
const currentPath = path_1.default.resolve(exePath, '..', '..', 'Resources');
|
86
|
-
const currentAsarPath = path_1.default.resolve(currentPath, 'app.asar');
|
76
|
+
const currentAsarPath = path_1.default.resolve(resourcePath, 'app.asar');
|
87
77
|
try {
|
88
78
|
// 将老包改名 app.asar => old-xxxx.asar
|
89
79
|
if (await (0, utils_1.existsAsync)(currentAsarPath)) {
|
@@ -108,23 +98,21 @@ class MacUpdator extends app_updator_1.AppUpdator {
|
|
108
98
|
error,
|
109
99
|
};
|
110
100
|
}
|
101
|
+
this.logger.warn('MacUpdator#quitAndInstall:install success');
|
102
|
+
this.app.relaunch();
|
111
103
|
return {
|
112
104
|
success: true,
|
113
105
|
};
|
114
106
|
}
|
115
107
|
async doQuitAndInstallPackage() {
|
116
|
-
|
108
|
+
this.logger.info('MacUpdator#doQuitAndInstallPackage:start');
|
109
|
+
const result = await (0, install_macos_dmg_1.default)(this.options, this.logger, this.availableUpdate, this.updateInfo);
|
117
110
|
if (result.success) {
|
118
|
-
this.logger.warn('
|
111
|
+
this.logger.warn('quitAndInstall:install success');
|
119
112
|
this.app.relaunch();
|
120
113
|
}
|
121
114
|
return result;
|
122
115
|
}
|
123
|
-
async doInstallPackage() {
|
124
|
-
this.logger.info('MacUpdator#doQuitAndInstallPackage:start');
|
125
|
-
const result = await (0, install_macos_dmg_1.default)(this.options, this.logger, this.availableUpdate, this.updateInfo);
|
126
|
-
return result;
|
127
|
-
}
|
128
116
|
}
|
129
117
|
exports.MacUpdator = MacUpdator;
|
130
118
|
//# sourceMappingURL=mac-updator.js.map
|
package/build/windows-updator.js
CHANGED
@@ -63,9 +63,6 @@ class WindowsUpdator extends app_updator_1.AppUpdator {
|
|
63
63
|
success: true,
|
64
64
|
};
|
65
65
|
}
|
66
|
-
async doInstallPackage() {
|
67
|
-
return { success: false };
|
68
|
-
}
|
69
66
|
async doQuitAndInstallPackage() {
|
70
67
|
this.logger.info('WindowsUpdator#doQuitAndInstallPackage:success');
|
71
68
|
const { downloadTargetDir } = this.availableUpdate;
|
@@ -83,9 +80,6 @@ class WindowsUpdator extends app_updator_1.AppUpdator {
|
|
83
80
|
return Promise.resolve({ success: false, error });
|
84
81
|
}
|
85
82
|
}
|
86
|
-
async doInstallAsar() {
|
87
|
-
return { success: false };
|
88
|
-
}
|
89
83
|
async doQuitAndInstallAsar() {
|
90
84
|
this.logger.info('WindowsUpdator#doQuitAndInstallAsar:start');
|
91
85
|
const productName = this.options?.productName;
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "graceful-updater",
|
3
|
-
"version": "1.
|
3
|
+
"version": "1.2.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",
|
@@ -24,7 +24,7 @@
|
|
24
24
|
"url": "https://github.com/electron-modules/graceful-updater"
|
25
25
|
},
|
26
26
|
"dependencies": {
|
27
|
-
"eventemitter3": "
|
27
|
+
"eventemitter3": "4",
|
28
28
|
"graceful-updater-windows-helper": "1",
|
29
29
|
"lodash": "4",
|
30
30
|
"moment": "2",
|
@@ -70,4 +70,4 @@
|
|
70
70
|
}
|
71
71
|
},
|
72
72
|
"license": "MIT"
|
73
|
-
}
|
73
|
+
}
|