graceful-updater 1.0.5 → 1.0.6
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/common/constants.js +5 -1
- package/build/mac-updator.js +20 -9
- package/build/windows-updator.js +13 -1
- package/package.json +1 -1
@@ -1,6 +1,6 @@
|
|
1
1
|
"use strict";
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
-
exports.EventType = exports.DownloadProgressStatus = exports.ExecuteType = exports.UpdateType = exports.StateType = exports.InstallResultType = exports.OldArchivePrefix = void 0;
|
3
|
+
exports.FileName = exports.EventType = exports.DownloadProgressStatus = exports.ExecuteType = exports.UpdateType = exports.StateType = exports.InstallResultType = exports.OldArchivePrefix = void 0;
|
4
4
|
/**
|
5
5
|
* 更新包备份前缀
|
6
6
|
*/
|
@@ -115,4 +115,8 @@ var EventType;
|
|
115
115
|
*/
|
116
116
|
EventType["ERROR"] = "error";
|
117
117
|
})(EventType = exports.EventType || (exports.EventType = {}));
|
118
|
+
var FileName;
|
119
|
+
(function (FileName) {
|
120
|
+
FileName["TARGET_REPLACEMENT_ASAR"] = "latest.asar";
|
121
|
+
})(FileName = exports.FileName || (exports.FileName = {}));
|
118
122
|
//# sourceMappingURL=constants.js.map
|
package/build/mac-updator.js
CHANGED
@@ -11,10 +11,10 @@ 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('
|
14
|
+
this.logger.info('MacUpdator#doGetAvailableUpdateInfo:start');
|
15
15
|
const exePath = this.app.exePath;
|
16
16
|
const resourcePath = path_1.default.resolve(exePath, '..', '..', 'Resources');
|
17
|
-
const latestAsarPath = path_1.default.resolve(resourcePath,
|
17
|
+
const latestAsarPath = path_1.default.resolve(resourcePath, constants_1.FileName.TARGET_REPLACEMENT_ASAR);
|
18
18
|
const latestAppPath = path_1.default.resolve(resourcePath, 'latest');
|
19
19
|
let downloadTargetDir = `${latestAsarPath}.zip`;
|
20
20
|
if (updateInfo.updateType === constants_1.UpdateType.Package) {
|
@@ -27,7 +27,7 @@ class MacUpdator extends app_updator_1.AppUpdator {
|
|
27
27
|
};
|
28
28
|
}
|
29
29
|
async doPreCheckForPackage() {
|
30
|
-
this.logger.info('
|
30
|
+
this.logger.info('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,14 +36,25 @@ class MacUpdator extends app_updator_1.AppUpdator {
|
|
36
36
|
* @return
|
37
37
|
*/
|
38
38
|
async doUnzip() {
|
39
|
-
this.
|
40
|
-
|
39
|
+
const { resourcePath, downloadTargetDir, latestAsarPath } = this.availableUpdate;
|
40
|
+
this.logger.info('MacUpdator#doUnzip:start, unzip %s, to %s', downloadTargetDir, resourcePath);
|
41
41
|
try {
|
42
42
|
// 直接解压
|
43
43
|
await (0, utils_1.execAsync)(`unzip -o ${downloadTargetDir}`, {
|
44
44
|
cwd: resourcePath,
|
45
45
|
maxBuffer: 2 ** 28,
|
46
46
|
});
|
47
|
+
if (!await (0, utils_1.existsAsync)(latestAsarPath)) {
|
48
|
+
const zipInfo = await (0, utils_1.execAsync)(`unzip -Z -1 ${downloadTargetDir}`, {
|
49
|
+
cwd: resourcePath,
|
50
|
+
maxBuffer: 2 ** 28,
|
51
|
+
});
|
52
|
+
const fileName = zipInfo?.stdout?.trim();
|
53
|
+
if (fileName !== constants_1.FileName.TARGET_REPLACEMENT_ASAR) {
|
54
|
+
const currentAsarPath = path_1.default.join(resourcePath, fileName);
|
55
|
+
await (0, utils_1.renameAsync)(currentAsarPath, latestAsarPath);
|
56
|
+
}
|
57
|
+
}
|
47
58
|
return {
|
48
59
|
success: true,
|
49
60
|
};
|
@@ -56,9 +67,9 @@ class MacUpdator extends app_updator_1.AppUpdator {
|
|
56
67
|
}
|
57
68
|
}
|
58
69
|
async doQuitAndInstallAsar() {
|
59
|
-
this.logger.info('
|
70
|
+
this.logger.info('MacUpdator#doQuitAndInstallAsar:start');
|
60
71
|
if (!this.availableUpdate) {
|
61
|
-
this.logger.error('
|
72
|
+
this.logger.error('MacUpdator#doQuitAndInstallAsar:not availableUpdate');
|
62
73
|
return Promise.resolve({ success: false });
|
63
74
|
}
|
64
75
|
const { resourcePath, latestAsarPath } = this.availableUpdate;
|
@@ -88,14 +99,14 @@ class MacUpdator extends app_updator_1.AppUpdator {
|
|
88
99
|
error,
|
89
100
|
};
|
90
101
|
}
|
91
|
-
this.logger.warn('quitAndInstall:install success');
|
102
|
+
this.logger.warn('MacUpdator#quitAndInstall:install success');
|
92
103
|
this.app.relaunch();
|
93
104
|
return {
|
94
105
|
success: true,
|
95
106
|
};
|
96
107
|
}
|
97
108
|
async doQuitAndInstallPackage() {
|
98
|
-
this.logger.info('
|
109
|
+
this.logger.info('MacUpdator#doQuitAndInstallPackage:start');
|
99
110
|
const result = await (0, install_macos_dmg_1.default)(this.options, this.logger, this.availableUpdate, this.updateInfo);
|
100
111
|
if (result.success) {
|
101
112
|
this.logger.warn('quitAndInstall:install success');
|
package/build/windows-updator.js
CHANGED
@@ -32,12 +32,24 @@ class WindowsUpdator extends app_updator_1.AppUpdator {
|
|
32
32
|
return Promise.resolve({ success: true });
|
33
33
|
}
|
34
34
|
async doUnzip() {
|
35
|
+
const { downloadTargetDir, resourcePath, latestAsarPath } = this.availableUpdate;
|
35
36
|
this.logger.info('WindowsUpdator#doUnzip:start');
|
36
37
|
try {
|
37
|
-
const { downloadTargetDir, resourcePath } = this.availableUpdate;
|
38
38
|
const unzipExe = (0, utils_1.getExecuteFile)(this._windowHelperExeDir, 'unzip.exe');
|
39
39
|
const executeCommand = `"${unzipExe}" -o "${downloadTargetDir}" -d "${resourcePath}"`;
|
40
40
|
await (0, utils_1.execAsync)(executeCommand);
|
41
|
+
if (!await (0, utils_1.existsAsync)(latestAsarPath)) {
|
42
|
+
const zipInfoCommand = `"${unzipExe}" -Z -1 "${downloadTargetDir}"`;
|
43
|
+
const zipInfo = await (0, utils_1.execAsync)(zipInfoCommand, {
|
44
|
+
cwd: resourcePath,
|
45
|
+
maxBuffer: 2 ** 28,
|
46
|
+
});
|
47
|
+
const fileName = zipInfo?.stdout?.trim();
|
48
|
+
if (fileName !== constants_1.FileName.TARGET_REPLACEMENT_ASAR) {
|
49
|
+
const currentAsarPath = path_1.default.join(resourcePath, fileName);
|
50
|
+
await (0, utils_1.renameAsync)(currentAsarPath, latestAsarPath);
|
51
|
+
}
|
52
|
+
}
|
41
53
|
}
|
42
54
|
catch (error) {
|
43
55
|
return {
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "graceful-updater",
|
3
|
-
"version": "1.0.
|
3
|
+
"version": "1.0.6",
|
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",
|