graceful-updater 1.1.2 → 34.0.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 -1
- package/README.md +2 -2
- package/package.json +4 -4
- package/build/mac-updator copy.js +0 -120
package/README.en.md
CHANGED
@@ -192,7 +192,7 @@ Triggered when an error occurs inside the updater
|
|
192
192
|
| :---: | :---: | :---: |
|
193
193
|
|
194
194
|
|
195
|
-
This project follows the git-contributor [spec](https://github.com/xudafeng/git-contributor), auto updated at `
|
195
|
+
This project follows the git-contributor [spec](https://github.com/xudafeng/git-contributor), auto updated at `Sun Jun 04 2023 13:22:25 GMT+0800`.
|
196
196
|
|
197
197
|
<!-- GITCONTRIBUTOR_END -->
|
198
198
|
|
package/README.md
CHANGED
@@ -186,13 +186,13 @@ electronUpdator.on(EventType.UPDATE_DOWNLOAD_PROGRESS, (data) => {
|
|
186
186
|
|
187
187
|
<!-- GITCONTRIBUTOR_START -->
|
188
188
|
|
189
|
-
##
|
189
|
+
## 贡献者
|
190
190
|
|
191
191
|
|[<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/>|
|
192
192
|
| :---: | :---: | :---: |
|
193
193
|
|
194
194
|
|
195
|
-
|
195
|
+
[git-contributor 说明](https://github.com/xudafeng/git-contributor),自动生成时间:`Sun Jun 04 2023 13:22:25 GMT+0800`。
|
196
196
|
|
197
197
|
<!-- GITCONTRIBUTOR_END -->
|
198
198
|
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "graceful-updater",
|
3
|
-
"version": "
|
3
|
+
"version": "34.0.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",
|
@@ -46,8 +46,8 @@
|
|
46
46
|
"cross-env": "^7.0.3",
|
47
47
|
"detect-port": "1",
|
48
48
|
"egg-bin": "^5.9.0",
|
49
|
-
"electron": "
|
50
|
-
"electron-windows": "
|
49
|
+
"electron": "34",
|
50
|
+
"electron-windows": "34",
|
51
51
|
"eslint": "^7.32.0",
|
52
52
|
"eslint-config-egg": "^12.1.0",
|
53
53
|
"eslint-plugin-no-only-tests": "^3.1.0",
|
@@ -1,120 +0,0 @@
|
|
1
|
-
"use strict";
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
4
|
-
};
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
6
|
-
exports.MacUpdator = void 0;
|
7
|
-
const path_1 = __importDefault(require("path"));
|
8
|
-
const app_updator_1 = require("./app-updator");
|
9
|
-
const constants_1 = require("./common/constants");
|
10
|
-
const install_macos_dmg_1 = __importDefault(require("./utils/install-macos-dmg"));
|
11
|
-
const utils_1 = require("./utils");
|
12
|
-
class MacUpdator extends app_updator_1.AppUpdator {
|
13
|
-
doGetAvailableUpdateInfo(updateInfo) {
|
14
|
-
this.logger.info('MacUpdator#doGetAvailableUpdateInfo:start');
|
15
|
-
const resourcePath = path_1.default.resolve(this.app.userDataPath);
|
16
|
-
const latestAsarPath = path_1.default.resolve(resourcePath, constants_1.FileName.TARGET_REPLACEMENT_ASAR);
|
17
|
-
const latestAppPath = path_1.default.resolve(resourcePath, 'latest');
|
18
|
-
let downloadTargetDir = `${latestAsarPath}.zip`;
|
19
|
-
if (updateInfo.updateType === constants_1.UpdateType.Package) {
|
20
|
-
downloadTargetDir = `${latestAppPath}.dmg`;
|
21
|
-
}
|
22
|
-
return {
|
23
|
-
resourcePath,
|
24
|
-
downloadTargetDir,
|
25
|
-
latestAsarPath,
|
26
|
-
};
|
27
|
-
}
|
28
|
-
async doPreCheckForPackage() {
|
29
|
-
this.logger.info('MacUpdator#doPreCheckForPackage:start');
|
30
|
-
// Mac 全量安装前,先进行 dmg 安装检查
|
31
|
-
return await (0, install_macos_dmg_1.default)(this.options, this.logger, this.availableUpdate, this.updateInfo, true);
|
32
|
-
}
|
33
|
-
/**
|
34
|
-
* 资源解压
|
35
|
-
* @return
|
36
|
-
*/
|
37
|
-
async doUnzip() {
|
38
|
-
const { resourcePath, downloadTargetDir, latestAsarPath } = this.availableUpdate;
|
39
|
-
this.logger.info('MacUpdator#doUnzip:start, unzip %s, to %s', downloadTargetDir, resourcePath);
|
40
|
-
try {
|
41
|
-
// 直接解压
|
42
|
-
await (0, utils_1.execAsync)(`unzip -o '${downloadTargetDir}'`, {
|
43
|
-
cwd: resourcePath,
|
44
|
-
maxBuffer: 2 ** 28,
|
45
|
-
});
|
46
|
-
if (!await (0, utils_1.existsAsync)(latestAsarPath)) {
|
47
|
-
const zipInfo = await (0, utils_1.execAsync)(`unzip -Z -1 '${downloadTargetDir}'`, {
|
48
|
-
cwd: resourcePath,
|
49
|
-
maxBuffer: 2 ** 28,
|
50
|
-
});
|
51
|
-
const fileName = zipInfo?.stdout?.trim();
|
52
|
-
if (fileName !== constants_1.FileName.TARGET_REPLACEMENT_ASAR) {
|
53
|
-
const currentAsarPath = path_1.default.join(resourcePath, fileName);
|
54
|
-
await (0, utils_1.renameAsync)(currentAsarPath, latestAsarPath);
|
55
|
-
}
|
56
|
-
}
|
57
|
-
return {
|
58
|
-
success: true,
|
59
|
-
};
|
60
|
-
}
|
61
|
-
catch (error) {
|
62
|
-
return {
|
63
|
-
success: false,
|
64
|
-
error,
|
65
|
-
};
|
66
|
-
}
|
67
|
-
}
|
68
|
-
async doQuitAndInstallAsar() {
|
69
|
-
this.logger.info('MacUpdator#doQuitAndInstallAsar:start');
|
70
|
-
if (!this.availableUpdate) {
|
71
|
-
this.logger.error('MacUpdator#doQuitAndInstallAsar:not availableUpdate');
|
72
|
-
return Promise.resolve({ success: false });
|
73
|
-
}
|
74
|
-
const { resourcePath, latestAsarPath } = this.availableUpdate;
|
75
|
-
const oldAsarPath = path_1.default.resolve(resourcePath, `${constants_1.OldArchivePrefix}${new Date().getTime()}.asar`);
|
76
|
-
const exePath = this.app.exePath;
|
77
|
-
const currentPath = path_1.default.resolve(exePath, '..', '..', 'Resources');
|
78
|
-
const currentAsarPath = path_1.default.resolve(currentPath, 'app.asar');
|
79
|
-
try {
|
80
|
-
// 将老包改名 app.asar => old-xxxx.asar
|
81
|
-
if (await (0, utils_1.existsAsync)(currentAsarPath)) {
|
82
|
-
await (0, utils_1.renameAsync)(currentAsarPath, oldAsarPath);
|
83
|
-
}
|
84
|
-
}
|
85
|
-
catch (error) {
|
86
|
-
return {
|
87
|
-
success: false,
|
88
|
-
error,
|
89
|
-
};
|
90
|
-
}
|
91
|
-
try {
|
92
|
-
// 新包替换
|
93
|
-
await (0, utils_1.renameAsync)(latestAsarPath, currentAsarPath);
|
94
|
-
}
|
95
|
-
catch (error) {
|
96
|
-
// 替换出错,需要把老包还原
|
97
|
-
await (0, utils_1.renameAsync)(oldAsarPath, currentAsarPath);
|
98
|
-
return {
|
99
|
-
success: false,
|
100
|
-
error,
|
101
|
-
};
|
102
|
-
}
|
103
|
-
this.logger.warn('MacUpdator#quitAndInstall:install success');
|
104
|
-
this.app.relaunch();
|
105
|
-
return {
|
106
|
-
success: true,
|
107
|
-
};
|
108
|
-
}
|
109
|
-
async doQuitAndInstallPackage() {
|
110
|
-
this.logger.info('MacUpdator#doQuitAndInstallPackage:start');
|
111
|
-
const result = await (0, install_macos_dmg_1.default)(this.options, this.logger, this.availableUpdate, this.updateInfo);
|
112
|
-
if (result.success) {
|
113
|
-
this.logger.warn('quitAndInstall:install success');
|
114
|
-
this.app.relaunch();
|
115
|
-
}
|
116
|
-
return result;
|
117
|
-
}
|
118
|
-
}
|
119
|
-
exports.MacUpdator = MacUpdator;
|
120
|
-
//# sourceMappingURL=mac-updator%20copy.js.map
|