electron-updater 4.3.8 → 4.3.9
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/LICENSE +22 -0
- package/out/AppAdapter.js +19 -28
- package/out/AppAdapter.js.map +1 -1
- package/out/AppImageUpdater.js +103 -195
- package/out/AppImageUpdater.js.map +1 -1
- package/out/AppUpdater.d.ts +1 -1
- package/out/AppUpdater.js +517 -771
- package/out/AppUpdater.js.map +1 -1
- package/out/BaseUpdater.js +79 -103
- package/out/BaseUpdater.js.map +1 -1
- package/out/DownloadedUpdateHelper.js +150 -223
- package/out/DownloadedUpdateHelper.js.map +1 -1
- package/out/ElectronAppAdapter.js +35 -63
- package/out/ElectronAppAdapter.js.map +1 -1
- package/out/MacUpdater.js +132 -201
- package/out/MacUpdater.js.map +1 -1
- package/out/NoOpLogger.d.ts +6 -0
- package/out/NoOpLogger.js +19 -0
- package/out/NoOpLogger.js.map +1 -0
- package/out/NsisUpdater.js +199 -345
- package/out/NsisUpdater.js.map +1 -1
- package/out/differentialDownloader/DataSplitter.js +180 -252
- package/out/differentialDownloader/DataSplitter.js.map +1 -1
- package/out/differentialDownloader/DifferentialDownloader.d.ts +1 -1
- package/out/differentialDownloader/DifferentialDownloader.js +242 -355
- package/out/differentialDownloader/DifferentialDownloader.js.map +1 -1
- package/out/differentialDownloader/FileWithEmbeddedBlockMapDifferentialDownloader.js +29 -65
- package/out/differentialDownloader/FileWithEmbeddedBlockMapDifferentialDownloader.js.map +1 -1
- package/out/differentialDownloader/GenericDifferentialDownloader.js +7 -21
- package/out/differentialDownloader/GenericDifferentialDownloader.js.map +1 -1
- package/out/differentialDownloader/ProgressDifferentialDownloadCallbackTransform.js +79 -107
- package/out/differentialDownloader/ProgressDifferentialDownloadCallbackTransform.js.map +1 -1
- package/out/differentialDownloader/downloadPlanBuilder.js +99 -123
- package/out/differentialDownloader/downloadPlanBuilder.js.map +1 -1
- package/out/differentialDownloader/multipleRangeDownloader.js +99 -148
- package/out/differentialDownloader/multipleRangeDownloader.js.map +1 -1
- package/out/electronHttpExecutor.js +73 -106
- package/out/electronHttpExecutor.js.map +1 -1
- package/out/event.d.ts +35 -0
- package/out/event.js +39 -0
- package/out/event.js.map +1 -0
- package/out/log.d.ts +11 -0
- package/out/log.js +19 -0
- package/out/log.js.map +1 -0
- package/out/main.d.ts +1 -3
- package/out/main.js +60 -196
- package/out/main.js.map +1 -1
- package/out/providerFactory.js +49 -105
- package/out/providerFactory.js.map +1 -1
- package/out/providers/BintrayProvider.d.ts +2 -2
- package/out/providers/BintrayProvider.js +40 -95
- package/out/providers/BintrayProvider.js.map +1 -1
- package/out/providers/GenericProvider.d.ts +2 -2
- package/out/providers/GenericProvider.js +46 -80
- package/out/providers/GenericProvider.js.map +1 -1
- package/out/providers/GitHubProvider.d.ts +2 -2
- package/out/providers/GitHubProvider.js +122 -201
- package/out/providers/GitHubProvider.js.map +1 -1
- package/out/providers/PrivateGitHubProvider.js +87 -165
- package/out/providers/PrivateGitHubProvider.js.map +1 -1
- package/out/providers/Provider.js +122 -173
- package/out/providers/Provider.js.map +1 -1
- package/out/util.d.ts +5 -0
- package/out/util.js +42 -0
- package/out/util.js.map +1 -0
- package/out/windowsExecutableCodeSignatureVerifier.js +99 -139
- package/out/windowsExecutableCodeSignatureVerifier.js.map +1 -1
- package/package.json +33 -31
package/out/MacUpdater.js
CHANGED
|
@@ -1,209 +1,140 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
3
|
exports.MacUpdater = void 0;
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
return data;
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
var _fs = require("fs");
|
|
29
|
-
|
|
30
|
-
function _http() {
|
|
31
|
-
const data = require("http");
|
|
32
|
-
|
|
33
|
-
_http = function () {
|
|
34
|
-
return data;
|
|
35
|
-
};
|
|
36
|
-
|
|
37
|
-
return data;
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
function _AppUpdater() {
|
|
41
|
-
const data = require("./AppUpdater");
|
|
42
|
-
|
|
43
|
-
_AppUpdater = function () {
|
|
44
|
-
return data;
|
|
45
|
-
};
|
|
46
|
-
|
|
47
|
-
return data;
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
function _Provider() {
|
|
51
|
-
const data = require("./providers/Provider");
|
|
52
|
-
|
|
53
|
-
_Provider = function () {
|
|
54
|
-
return data;
|
|
55
|
-
};
|
|
56
|
-
|
|
57
|
-
return data;
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
class MacUpdater extends _AppUpdater().AppUpdater {
|
|
61
|
-
constructor(options, app) {
|
|
62
|
-
super(options, app);
|
|
63
|
-
this.nativeUpdater = require("electron").autoUpdater;
|
|
64
|
-
this.squirrelDownloadedUpdate = false;
|
|
65
|
-
this.nativeUpdater.on("error", it => {
|
|
66
|
-
this._logger.warn(it);
|
|
67
|
-
|
|
68
|
-
this.emit("error", it);
|
|
69
|
-
});
|
|
70
|
-
this.nativeUpdater.on("update-downloaded", () => {
|
|
71
|
-
this.squirrelDownloadedUpdate = true;
|
|
72
|
-
});
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
doDownloadUpdate(downloadUpdateOptions) {
|
|
76
|
-
let files = downloadUpdateOptions.updateInfoAndProvider.provider.resolveFiles(downloadUpdateOptions.updateInfoAndProvider.info); // Allow arm64 macs to install universal or rosetta2(x64) - https://github.com/electron-userland/electron-builder/pull/5524
|
|
77
|
-
|
|
78
|
-
const isArm64 = file => file.url.pathname.includes("arm64");
|
|
79
|
-
|
|
80
|
-
if (files.some(isArm64)) {
|
|
81
|
-
files = files.filter(file => process.arch === "arm64" === isArm64(file));
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
const zipFileInfo = (0, _Provider().findFile)(files, "zip", ["pkg", "dmg"]);
|
|
85
|
-
|
|
86
|
-
if (zipFileInfo == null) {
|
|
87
|
-
throw (0, _builderUtilRuntime().newError)(`ZIP file not provided: ${(0, _builderUtilRuntime().safeStringifyJson)(files)}`, "ERR_UPDATER_ZIP_FILE_NOT_FOUND");
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
const server = (0, _http().createServer)();
|
|
91
|
-
server.on("close", () => {
|
|
92
|
-
this._logger.info(`Proxy server for native Squirrel.Mac is closed (was started to download ${zipFileInfo.url.href})`);
|
|
93
|
-
});
|
|
94
|
-
|
|
95
|
-
function getServerUrl() {
|
|
96
|
-
const address = server.address();
|
|
97
|
-
return `http://127.0.0.1:${address.port}`;
|
|
4
|
+
const builder_util_runtime_1 = require("builder-util-runtime");
|
|
5
|
+
const fs_extra_1 = require("fs-extra");
|
|
6
|
+
const fs_1 = require("fs");
|
|
7
|
+
const http_1 = require("http");
|
|
8
|
+
const AppUpdater_1 = require("./AppUpdater");
|
|
9
|
+
const Provider_1 = require("./providers/Provider");
|
|
10
|
+
class MacUpdater extends AppUpdater_1.AppUpdater {
|
|
11
|
+
constructor(options, app) {
|
|
12
|
+
super(options, app);
|
|
13
|
+
this.nativeUpdater = require("electron").autoUpdater;
|
|
14
|
+
this.squirrelDownloadedUpdate = false;
|
|
15
|
+
this.nativeUpdater.on("error", it => {
|
|
16
|
+
this._logger.warn(it);
|
|
17
|
+
this.emit("error", it);
|
|
18
|
+
});
|
|
19
|
+
this.nativeUpdater.on("update-downloaded", () => {
|
|
20
|
+
this.squirrelDownloadedUpdate = true;
|
|
21
|
+
});
|
|
98
22
|
}
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
return this.httpExecutor.download(zipFileInfo.url, destinationFile, downloadOptions);
|
|
106
|
-
},
|
|
107
|
-
done: async event => {
|
|
108
|
-
const downloadedFile = event.downloadedFile;
|
|
109
|
-
let updateFileSize = zipFileInfo.info.size;
|
|
110
|
-
|
|
111
|
-
if (updateFileSize == null) {
|
|
112
|
-
updateFileSize = (await (0, _fsExtra().stat)(downloadedFile)).size;
|
|
23
|
+
doDownloadUpdate(downloadUpdateOptions) {
|
|
24
|
+
let files = downloadUpdateOptions.updateInfoAndProvider.provider.resolveFiles(downloadUpdateOptions.updateInfoAndProvider.info);
|
|
25
|
+
// Allow arm64 macs to install universal or rosetta2(x64) - https://github.com/electron-userland/electron-builder/pull/5524
|
|
26
|
+
const isArm64 = (file) => file.url.pathname.includes("arm64");
|
|
27
|
+
if (files.some(isArm64)) {
|
|
28
|
+
files = files.filter(file => (process.arch === "arm64") === isArm64(file));
|
|
113
29
|
}
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
return;
|
|
139
|
-
}
|
|
140
|
-
|
|
141
|
-
this._logger.info(`${fileUrl} requested by Squirrel.Mac, pipe ${downloadedFile}`);
|
|
142
|
-
|
|
143
|
-
let errorOccurred = false;
|
|
144
|
-
response.on("finish", () => {
|
|
145
|
-
try {
|
|
146
|
-
setImmediate(() => server.close());
|
|
147
|
-
} finally {
|
|
148
|
-
if (!errorOccurred) {
|
|
149
|
-
this.nativeUpdater.removeListener("error", reject);
|
|
150
|
-
resolve([]);
|
|
30
|
+
const zipFileInfo = Provider_1.findFile(files, "zip", ["pkg", "dmg"]);
|
|
31
|
+
if (zipFileInfo == null) {
|
|
32
|
+
throw builder_util_runtime_1.newError(`ZIP file not provided: ${builder_util_runtime_1.safeStringifyJson(files)}`, "ERR_UPDATER_ZIP_FILE_NOT_FOUND");
|
|
33
|
+
}
|
|
34
|
+
const server = http_1.createServer();
|
|
35
|
+
server.on("close", () => {
|
|
36
|
+
this._logger.info(`Proxy server for native Squirrel.Mac is closed (was started to download ${zipFileInfo.url.href})`);
|
|
37
|
+
});
|
|
38
|
+
function getServerUrl() {
|
|
39
|
+
const address = server.address();
|
|
40
|
+
return `http://127.0.0.1:${address.port}`;
|
|
41
|
+
}
|
|
42
|
+
return this.executeDownload({
|
|
43
|
+
fileExtension: "zip",
|
|
44
|
+
fileInfo: zipFileInfo,
|
|
45
|
+
downloadUpdateOptions,
|
|
46
|
+
task: (destinationFile, downloadOptions) => {
|
|
47
|
+
return this.httpExecutor.download(zipFileInfo.url, destinationFile, downloadOptions);
|
|
48
|
+
},
|
|
49
|
+
done: async (event) => {
|
|
50
|
+
const downloadedFile = event.downloadedFile;
|
|
51
|
+
let updateFileSize = zipFileInfo.info.size;
|
|
52
|
+
if (updateFileSize == null) {
|
|
53
|
+
updateFileSize = (await fs_extra_1.stat(downloadedFile)).size;
|
|
151
54
|
}
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
55
|
+
return await new Promise((resolve, reject) => {
|
|
56
|
+
// insecure random is ok
|
|
57
|
+
const fileUrl = `/${Date.now()}-${Math.floor(Math.random() * 9999)}.zip`;
|
|
58
|
+
server.on("request", (request, response) => {
|
|
59
|
+
const requestUrl = request.url;
|
|
60
|
+
this._logger.info(`${requestUrl} requested`);
|
|
61
|
+
if (requestUrl === "/") {
|
|
62
|
+
const data = Buffer.from(`{ "url": "${getServerUrl()}${fileUrl}" }`);
|
|
63
|
+
response.writeHead(200, { "Content-Type": "application/json", "Content-Length": data.length });
|
|
64
|
+
response.end(data);
|
|
65
|
+
return;
|
|
66
|
+
}
|
|
67
|
+
if (!requestUrl.startsWith(fileUrl)) {
|
|
68
|
+
this._logger.warn(`${requestUrl} requested, but not supported`);
|
|
69
|
+
response.writeHead(404);
|
|
70
|
+
response.end();
|
|
71
|
+
return;
|
|
72
|
+
}
|
|
73
|
+
this._logger.info(`${fileUrl} requested by Squirrel.Mac, pipe ${downloadedFile}`);
|
|
74
|
+
let errorOccurred = false;
|
|
75
|
+
response.on("finish", () => {
|
|
76
|
+
try {
|
|
77
|
+
setImmediate(() => server.close());
|
|
78
|
+
}
|
|
79
|
+
finally {
|
|
80
|
+
if (!errorOccurred) {
|
|
81
|
+
this.nativeUpdater.removeListener("error", reject);
|
|
82
|
+
resolve([]);
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
});
|
|
86
|
+
const readStream = fs_1.createReadStream(downloadedFile);
|
|
87
|
+
readStream.on("error", error => {
|
|
88
|
+
try {
|
|
89
|
+
response.end();
|
|
90
|
+
}
|
|
91
|
+
catch (e) {
|
|
92
|
+
this._logger.warn(`cannot end response: ${e}`);
|
|
93
|
+
}
|
|
94
|
+
errorOccurred = true;
|
|
95
|
+
this.nativeUpdater.removeListener("error", reject);
|
|
96
|
+
reject(new Error(`Cannot pipe "${downloadedFile}": ${error}`));
|
|
97
|
+
});
|
|
98
|
+
response.writeHead(200, {
|
|
99
|
+
"Content-Type": "application/zip",
|
|
100
|
+
"Content-Length": updateFileSize,
|
|
101
|
+
});
|
|
102
|
+
readStream.pipe(response);
|
|
103
|
+
});
|
|
104
|
+
server.listen(0, "127.0.0.1", () => {
|
|
105
|
+
this.nativeUpdater.setFeedURL({
|
|
106
|
+
url: getServerUrl(),
|
|
107
|
+
headers: { "Cache-Control": "no-cache" },
|
|
108
|
+
});
|
|
109
|
+
// The update has been downloaded and is ready to be served to Squirrel
|
|
110
|
+
this.dispatchUpdateDownloaded(event);
|
|
111
|
+
if (this.autoInstallOnAppQuit) {
|
|
112
|
+
this.nativeUpdater.once("error", reject);
|
|
113
|
+
// This will trigger fetching and installing the file on Squirrel side
|
|
114
|
+
this.nativeUpdater.checkForUpdates();
|
|
115
|
+
}
|
|
116
|
+
else {
|
|
117
|
+
resolve([]);
|
|
118
|
+
}
|
|
119
|
+
});
|
|
120
|
+
});
|
|
121
|
+
},
|
|
188
122
|
});
|
|
189
|
-
}
|
|
190
|
-
});
|
|
191
|
-
}
|
|
192
|
-
|
|
193
|
-
quitAndInstall() {
|
|
194
|
-
if (this.squirrelDownloadedUpdate) {
|
|
195
|
-
// Update already fetched by Squirrel, it's ready to install
|
|
196
|
-
this.nativeUpdater.quitAndInstall();
|
|
197
|
-
} else {
|
|
198
|
-
// Quit and install as soon as Squirrel get the update
|
|
199
|
-
this.nativeUpdater.on("update-downloaded", () => {
|
|
200
|
-
this.nativeUpdater.quitAndInstall();
|
|
201
|
-
}); // And trigger the update
|
|
202
|
-
|
|
203
|
-
this.nativeUpdater.checkForUpdates();
|
|
204
123
|
}
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
124
|
+
quitAndInstall() {
|
|
125
|
+
if (this.squirrelDownloadedUpdate) {
|
|
126
|
+
// Update already fetched by Squirrel, it's ready to install
|
|
127
|
+
this.nativeUpdater.quitAndInstall();
|
|
128
|
+
}
|
|
129
|
+
else {
|
|
130
|
+
// Quit and install as soon as Squirrel get the update
|
|
131
|
+
this.nativeUpdater.on("update-downloaded", () => {
|
|
132
|
+
this.nativeUpdater.quitAndInstall();
|
|
133
|
+
});
|
|
134
|
+
// And trigger the update
|
|
135
|
+
this.nativeUpdater.checkForUpdates();
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
exports.MacUpdater = MacUpdater;
|
|
209
140
|
//# sourceMappingURL=MacUpdater.js.map
|
package/out/MacUpdater.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/MacUpdater.ts"],"names":[],"mappings":";;;;;;;AAAA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AACA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AACA;;AACA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AAGA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AAEA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AAGM,MAAO,UAAP,SAA0B,wBAA1B,CAAoC;AAKxC,EAAA,WAAA,CAAY,OAAZ,EAAyC,GAAzC,EAAyD;AACvD,UAAM,OAAN,EAAe,GAAf;AALe,SAAA,aAAA,GAA6B,OAAO,CAAC,UAAD,CAAP,CAAoB,WAAjD;AAET,SAAA,wBAAA,GAAoC,KAApC;AAKN,SAAK,aAAL,CAAmB,EAAnB,CAAsB,OAAtB,EAA+B,EAAE,IAAG;AAClC,WAAK,OAAL,CAAa,IAAb,CAAkB,EAAlB;;AACA,WAAK,IAAL,CAAU,OAAV,EAAmB,EAAnB;AACD,KAHD;AAIA,SAAK,aAAL,CAAmB,EAAnB,CAAsB,mBAAtB,EAA2C,MAAK;AAC9C,WAAK,wBAAL,GAAgC,IAAhC;AACD,KAFD;AAGD;;AAES,EAAA,gBAAgB,CAAC,qBAAD,EAA6C;AACrE,QAAI,KAAK,GAAG,qBAAqB,CAAC,qBAAtB,CAA4C,QAA5C,CAAqD,YAArD,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AI,KAAK,oBAAT,EAA+B;AAC7B;AACA,mBAAK,aAAL,CAAmB,eAAnB;AACD;AACF,WAfD;AAgBD,SAtEY,CAAb;AAuED;AArFyB,KAArB,CAAP;AAuFD;;AAED,EAAA,cAAc,GAAA;AACZ,QAAI,KAAK,wBAAT,EAAmC;AACjC;AACA,WAAK,aAAL,CAAmB,cAAnB;AACD,KAHD,MAGO;AACL;AACA,WAAK,aAAL,CAAmB,EAAnB,CAAsB,mBAAtB,EAA2C,MAAK;AAC9C,aAAK,aAAL,CAAmB,cAAnB;AACD,OAFD,EAFK,CAML;;AACA,WAAK,aAAL,CAAmB,eAAnB;AACD;AACF;;AA/IuC,C","sourcesContent":["import { AllPublishOptions, newError, safeStringifyJson } from \"builder-util-runtime\"\nimport { stat } from \"fs-extra\"\nimport { createReadStream } from \"fs\"\nimport { createServer, IncomingMessage, ServerResponse } from \"http\"\nimport { AddressInfo } from \"net\"\nimport { AppAdapter } from \"./AppAdapter\"\nimport { AppUpdater, DownloadUpdateOptions } from \"./AppUpdater\"\nimport { ResolvedUpdateFileInfo } from \"./main\"\nimport { findFile } from \"./providers/Provider\"\nimport AutoUpdater = Electron.AutoUpdater\n\nexport class MacUpdater extends AppUpdater {\n private readonly nativeUpdater: AutoUpdater = require(\"electron\").autoUpdater\n\n private squirrelDownloadedUpdate: boolean = false\n\n constructor(options?: AllPublishOptions, app?: AppAdapter) {\n super(options, app)\n\n this.nativeUpdater.on(\"error\", it => {\n this._logger.warn(it)\n this.emit(\"error\", it)\n })\n this.nativeUpdater.on(\"update-downloaded\", () => {\n this.squirrelDownloadedUpdate = true\n })\n }\n\n protected doDownloadUpdate(downloadUpdateOptions: DownloadUpdateOptions): Promise<Array<string>> {\n let files = downloadUpdateOptions.updateInfoAndProvider.provider.resolveFiles(downloadUpdateOptions.updateInfoAndProvider.info);\n\n // Allow arm64 macs to install universal or rosetta2(x64) - https://github.com/electron-userland/electron-builder/pull/5524\n const isArm64 = (file: ResolvedUpdateFileInfo) => file.url.pathname.includes(\"arm64\")\n if (files.some(isArm64)) {\n files = files.filter(file => (process.arch === \"arm64\") === isArm64(file));\n }\n\n const zipFileInfo = findFile(files, \"zip\", [\"pkg\", \"dmg\"])\n if (zipFileInfo == null) {\n throw newError(`ZIP file not provided: ${safeStringifyJson(files)}`, \"ERR_UPDATER_ZIP_FILE_NOT_FOUND\")\n }\n\n const server = createServer()\n server.on(\"close\", () => {\n this._logger.info(`Proxy server for native Squirrel.Mac is closed (was started to download ${zipFileInfo.url.href})`)\n })\n\n function getServerUrl(): string {\n const address = server.address() as AddressInfo\n return `http://127.0.0.1:${address.port}`\n }\n\n return this.executeDownload({\n fileExtension: \"zip\",\n fileInfo: zipFileInfo,\n downloadUpdateOptions,\n task: (destinationFile, downloadOptions) => {\n return this.httpExecutor.download(zipFileInfo.url, destinationFile, downloadOptions)\n },\n done: async event => {\n const downloadedFile = event.downloadedFile\n let updateFileSize = zipFileInfo.info.size\n if (updateFileSize == null) {\n updateFileSize = (await stat(downloadedFile)).size\n }\n\n return await new Promise<Array<string>>((resolve, reject) => {\n // insecure random is ok\n const fileUrl = \"/\" + Date.now() + \"-\" + Math.floor(Math.random() * 9999) + \".zip\"\n server.on(\"request\", (request: IncomingMessage, response: ServerResponse) => {\n const requestUrl = request.url!!\n this._logger.info(`${requestUrl} requested`)\n if (requestUrl === \"/\") {\n const data = Buffer.from(`{ \"url\": \"${getServerUrl()}${fileUrl}\" }`)\n response.writeHead(200, {\"Content-Type\": \"application/json\", \"Content-Length\": data.length})\n response.end(data)\n return\n }\n\n if (!requestUrl.startsWith(fileUrl)) {\n this._logger.warn(`${requestUrl} requested, but not supported`)\n response.writeHead(404)\n response.end()\n return\n }\n\n this._logger.info(`${fileUrl} requested by Squirrel.Mac, pipe ${downloadedFile}`)\n\n let errorOccurred = false\n response.on(\"finish\", () => {\n try {\n setImmediate(() => server.close())\n }\n finally {\n if (!errorOccurred) {\n this.nativeUpdater.removeListener(\"error\", reject)\n resolve([])\n }\n }\n })\n\n const readStream = createReadStream(downloadedFile)\n readStream.on(\"error\", error => {\n try {\n response.end()\n }\n catch (e) {\n this._logger.warn(`cannot end response: ${e}`)\n }\n errorOccurred = true\n this.nativeUpdater.removeListener(\"error\", reject)\n reject(new Error(`Cannot pipe \"${downloadedFile}\": ${error}`))\n })\n\n response.writeHead(200, {\n \"Content-Type\": \"application/zip\",\n \"Content-Length\": updateFileSize,\n })\n readStream.pipe(response)\n })\n server.listen(0, \"127.0.0.1\", () => {\n this.nativeUpdater.setFeedURL({\n url: getServerUrl(),\n headers: {\"Cache-Control\": \"no-cache\"},\n })\n\n this.nativeUpdater.once(\"error\", reject)\n\n // The update has been dowloaded and is ready to be served to Squirrel\n this.dispatchUpdateDownloaded(event)\n\n if (this.autoInstallOnAppQuit) {\n // This will trigger fetching and installing the file on Squirrel side\n this.nativeUpdater.checkForUpdates()\n }\n })\n })\n }\n })\n }\n\n quitAndInstall(): void {\n if (this.squirrelDownloadedUpdate) {\n // Update already fetched by Squirrel, it's ready to install\n this.nativeUpdater.quitAndInstall()\n } else {\n // Quit and install as soon as Squirrel get the update\n this.nativeUpdater.on(\"update-downloaded\", () => {\n this.nativeUpdater.quitAndInstall()\n })\n\n // And trigger the update\n this.nativeUpdater.checkForUpdates()\n }\n }\n}"],"sourceRoot":""}
|
|
1
|
+
{"version":3,"file":"MacUpdater.js","sourceRoot":"","sources":["../src/MacUpdater.ts"],"names":[],"mappings":";;;AAAA,+DAAqF;AACrF,uCAA+B;AAC/B,2BAAqC;AACrC,+BAAoE;AAGpE,6CAAgE;AAEhE,mDAA+C;AAG/C,MAAa,UAAW,SAAQ,uBAAU;IAKxC,YAAY,OAA2B,EAAE,GAAgB;QACvD,KAAK,CAAC,OAAO,EAAE,GAAG,CAAC,CAAA;QALJ,kBAAa,GAAgB,OAAO,CAAC,UAAU,CAAC,CAAC,WAAW,CAAA;QAErE,6BAAwB,GAAG,KAAK,CAAA;QAKtC,IAAI,CAAC,aAAa,CAAC,EAAE,CAAC,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AC,EAAE,CAAC,mBAAmB,EAAE,GAAG,EAAE;gBAC9C,IAAI,CAAC,aAAa,CAAC,cAAc,EAAE,CAAA;YACrC,CAAC,CAAC,CAAA;YAEF,yBAAyB;YACzB,IAAI,CAAC,aAAa,CAAC,eAAe,EAAE,CAAA;SACrC;IACH,CAAC;CACF;AA/ID,gCA+IC","sourcesContent":["import { AllPublishOptions, newError, safeStringifyJson } from \"builder-util-runtime\"\nimport { stat } from \"fs-extra\"\nimport { createReadStream } from \"fs\"\nimport { createServer, IncomingMessage, ServerResponse } from \"http\"\nimport { AddressInfo } from \"net\"\nimport { AppAdapter } from \"./AppAdapter\"\nimport { AppUpdater, DownloadUpdateOptions } from \"./AppUpdater\"\nimport { ResolvedUpdateFileInfo } from \"./main\"\nimport { findFile } from \"./providers/Provider\"\nimport AutoUpdater = Electron.AutoUpdater\n\nexport class MacUpdater extends AppUpdater {\n private readonly nativeUpdater: AutoUpdater = require(\"electron\").autoUpdater\n\n private squirrelDownloadedUpdate = false\n\n constructor(options?: AllPublishOptions, app?: AppAdapter) {\n super(options, app)\n\n this.nativeUpdater.on(\"error\", it => {\n this._logger.warn(it)\n this.emit(\"error\", it)\n })\n this.nativeUpdater.on(\"update-downloaded\", () => {\n this.squirrelDownloadedUpdate = true\n })\n }\n\n protected doDownloadUpdate(downloadUpdateOptions: DownloadUpdateOptions): Promise<Array<string>> {\n let files = downloadUpdateOptions.updateInfoAndProvider.provider.resolveFiles(downloadUpdateOptions.updateInfoAndProvider.info)\n\n // Allow arm64 macs to install universal or rosetta2(x64) - https://github.com/electron-userland/electron-builder/pull/5524\n const isArm64 = (file: ResolvedUpdateFileInfo) => file.url.pathname.includes(\"arm64\")\n if (files.some(isArm64)) {\n files = files.filter(file => (process.arch === \"arm64\") === isArm64(file))\n }\n\n const zipFileInfo = findFile(files, \"zip\", [\"pkg\", \"dmg\"])\n if (zipFileInfo == null) {\n throw newError(`ZIP file not provided: ${safeStringifyJson(files)}`, \"ERR_UPDATER_ZIP_FILE_NOT_FOUND\")\n }\n\n const server = createServer()\n server.on(\"close\", () => {\n this._logger.info(`Proxy server for native Squirrel.Mac is closed (was started to download ${zipFileInfo.url.href})`)\n })\n\n function getServerUrl(): string {\n const address = server.address() as AddressInfo\n return `http://127.0.0.1:${address.port}`\n }\n\n return this.executeDownload({\n fileExtension: \"zip\",\n fileInfo: zipFileInfo,\n downloadUpdateOptions,\n task: (destinationFile, downloadOptions) => {\n return this.httpExecutor.download(zipFileInfo.url, destinationFile, downloadOptions)\n },\n done: async event => {\n const downloadedFile = event.downloadedFile\n let updateFileSize = zipFileInfo.info.size\n if (updateFileSize == null) {\n updateFileSize = (await stat(downloadedFile)).size\n }\n\n return await new Promise<Array<string>>((resolve, reject) => {\n // insecure random is ok\n const fileUrl = `/${Date.now()}-${Math.floor(Math.random() * 9999)}.zip`\n server.on(\"request\", (request: IncomingMessage, response: ServerResponse) => {\n const requestUrl = request.url!\n this._logger.info(`${requestUrl} requested`)\n if (requestUrl === \"/\") {\n const data = Buffer.from(`{ \"url\": \"${getServerUrl()}${fileUrl}\" }`)\n response.writeHead(200, { \"Content-Type\": \"application/json\", \"Content-Length\": data.length })\n response.end(data)\n return\n }\n\n if (!requestUrl.startsWith(fileUrl)) {\n this._logger.warn(`${requestUrl} requested, but not supported`)\n response.writeHead(404)\n response.end()\n return\n }\n\n this._logger.info(`${fileUrl} requested by Squirrel.Mac, pipe ${downloadedFile}`)\n\n let errorOccurred = false\n response.on(\"finish\", () => {\n try {\n setImmediate(() => server.close())\n } finally {\n if (!errorOccurred) {\n this.nativeUpdater.removeListener(\"error\", reject)\n resolve([])\n }\n }\n })\n\n const readStream = createReadStream(downloadedFile)\n readStream.on(\"error\", error => {\n try {\n response.end()\n } catch (e) {\n this._logger.warn(`cannot end response: ${e}`)\n }\n errorOccurred = true\n this.nativeUpdater.removeListener(\"error\", reject)\n reject(new Error(`Cannot pipe \"${downloadedFile}\": ${error}`))\n })\n\n response.writeHead(200, {\n \"Content-Type\": \"application/zip\",\n \"Content-Length\": updateFileSize,\n })\n readStream.pipe(response)\n })\n server.listen(0, \"127.0.0.1\", () => {\n this.nativeUpdater.setFeedURL({\n url: getServerUrl(),\n headers: { \"Cache-Control\": \"no-cache\" },\n })\n\n // The update has been downloaded and is ready to be served to Squirrel\n this.dispatchUpdateDownloaded(event)\n\n if (this.autoInstallOnAppQuit) {\n this.nativeUpdater.once(\"error\", reject)\n // This will trigger fetching and installing the file on Squirrel side\n this.nativeUpdater.checkForUpdates()\n } else {\n resolve([])\n }\n })\n })\n },\n })\n }\n\n quitAndInstall(): void {\n if (this.squirrelDownloadedUpdate) {\n // Update already fetched by Squirrel, it's ready to install\n this.nativeUpdater.quitAndInstall()\n } else {\n // Quit and install as soon as Squirrel get the update\n this.nativeUpdater.on(\"update-downloaded\", () => {\n this.nativeUpdater.quitAndInstall()\n })\n\n // And trigger the update\n this.nativeUpdater.checkForUpdates()\n }\n }\n}\n"]}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.NoOpLogger = void 0;
|
|
4
|
+
class NoOpLogger {
|
|
5
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
6
|
+
info(message) {
|
|
7
|
+
// ignore
|
|
8
|
+
}
|
|
9
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
10
|
+
warn(message) {
|
|
11
|
+
// ignore
|
|
12
|
+
}
|
|
13
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
14
|
+
error(message) {
|
|
15
|
+
// ignore
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
exports.NoOpLogger = NoOpLogger;
|
|
19
|
+
//# sourceMappingURL=NoOpLogger.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"NoOpLogger.js","sourceRoot":"","sources":["../src/NoOpLogger.ts"],"names":[],"mappings":";;;AAEA,MAAa,UAAU;IACrB,6DAA6D;IAC7D,IAAI,CAAC,OAAa;QAChB,SAAS;IACX,CAAC;IAED,6DAA6D;IAC7D,IAAI,CAAC,OAAa;QAChB,SAAS;IACX,CAAC;IAED,6DAA6D;IAC7D,KAAK,CAAC,OAAa;QACjB,SAAS;IACX,CAAC;CACF;AAfD,gCAeC","sourcesContent":["import { Logger } from \"./main\"\n\nexport class NoOpLogger implements Logger {\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n info(message?: any) {\n // ignore\n }\n\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n warn(message?: any) {\n // ignore\n }\n\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n error(message?: any) {\n // ignore\n }\n}\n"]}
|