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
|
@@ -1,172 +1,94 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
3
|
exports.PrivateGitHubProvider = void 0;
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
const data = require("js-yaml");
|
|
20
|
-
|
|
21
|
-
_jsYaml = function () {
|
|
22
|
-
return data;
|
|
23
|
-
};
|
|
24
|
-
|
|
25
|
-
return data;
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
var path = _interopRequireWildcard(require("path"));
|
|
29
|
-
|
|
30
|
-
function _url() {
|
|
31
|
-
const data = require("url");
|
|
32
|
-
|
|
33
|
-
_url = function () {
|
|
34
|
-
return data;
|
|
35
|
-
};
|
|
36
|
-
|
|
37
|
-
return data;
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
function _GitHubProvider() {
|
|
41
|
-
const data = require("./GitHubProvider");
|
|
42
|
-
|
|
43
|
-
_GitHubProvider = function () {
|
|
44
|
-
return data;
|
|
45
|
-
};
|
|
46
|
-
|
|
47
|
-
return data;
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
function _main() {
|
|
51
|
-
const data = require("../main");
|
|
52
|
-
|
|
53
|
-
_main = function () {
|
|
54
|
-
return data;
|
|
55
|
-
};
|
|
56
|
-
|
|
57
|
-
return data;
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
function _Provider() {
|
|
61
|
-
const data = require("./Provider");
|
|
62
|
-
|
|
63
|
-
_Provider = function () {
|
|
64
|
-
return data;
|
|
65
|
-
};
|
|
66
|
-
|
|
67
|
-
return data;
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function () { return cache; }; return cache; }
|
|
71
|
-
|
|
72
|
-
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
73
|
-
|
|
74
|
-
class PrivateGitHubProvider extends _GitHubProvider().BaseGitHubProvider {
|
|
75
|
-
constructor(options, updater, token, runtimeOptions) {
|
|
76
|
-
super(options, "api.github.com", runtimeOptions);
|
|
77
|
-
this.updater = updater;
|
|
78
|
-
this.token = token;
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
createRequestOptions(url, headers) {
|
|
82
|
-
const result = super.createRequestOptions(url, headers);
|
|
83
|
-
result.redirect = "manual";
|
|
84
|
-
return result;
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
async getLatestVersion() {
|
|
88
|
-
const cancellationToken = new (_builderUtilRuntime().CancellationToken)();
|
|
89
|
-
const channelFile = (0, _main().getChannelFilename)(this.getDefaultChannelName());
|
|
90
|
-
const releaseInfo = await this.getLatestVersionInfo(cancellationToken);
|
|
91
|
-
const asset = releaseInfo.assets.find(it => it.name === channelFile);
|
|
92
|
-
|
|
93
|
-
if (asset == null) {
|
|
94
|
-
// html_url must be always, but just to be sure
|
|
95
|
-
throw (0, _builderUtilRuntime().newError)(`Cannot find ${channelFile} in the release ${releaseInfo.html_url || releaseInfo.name}`, "ERR_UPDATER_CHANNEL_FILE_NOT_FOUND");
|
|
4
|
+
const builder_util_runtime_1 = require("builder-util-runtime");
|
|
5
|
+
const js_yaml_1 = require("js-yaml");
|
|
6
|
+
const path = require("path");
|
|
7
|
+
const url_1 = require("url");
|
|
8
|
+
const util_1 = require("../util");
|
|
9
|
+
const GitHubProvider_1 = require("./GitHubProvider");
|
|
10
|
+
const Provider_1 = require("./Provider");
|
|
11
|
+
class PrivateGitHubProvider extends GitHubProvider_1.BaseGitHubProvider {
|
|
12
|
+
constructor(options, updater, token, runtimeOptions) {
|
|
13
|
+
super(options, "api.github.com", runtimeOptions);
|
|
14
|
+
this.updater = updater;
|
|
15
|
+
this.token = token;
|
|
96
16
|
}
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
try {
|
|
102
|
-
result = (0, _jsYaml().load)(await this.httpRequest(url, this.configureHeaders("application/octet-stream"), cancellationToken));
|
|
103
|
-
} catch (e) {
|
|
104
|
-
if (e instanceof _builderUtilRuntime().HttpError && e.statusCode === 404) {
|
|
105
|
-
throw (0, _builderUtilRuntime().newError)(`Cannot find ${channelFile} in the latest release artifacts (${url}): ${e.stack || e.message}`, "ERR_UPDATER_CHANNEL_FILE_NOT_FOUND");
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
throw e;
|
|
17
|
+
createRequestOptions(url, headers) {
|
|
18
|
+
const result = super.createRequestOptions(url, headers);
|
|
19
|
+
result.redirect = "manual";
|
|
20
|
+
return result;
|
|
109
21
|
}
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
22
|
+
async getLatestVersion() {
|
|
23
|
+
const cancellationToken = new builder_util_runtime_1.CancellationToken();
|
|
24
|
+
const channelFile = util_1.getChannelFilename(this.getDefaultChannelName());
|
|
25
|
+
const releaseInfo = await this.getLatestVersionInfo(cancellationToken);
|
|
26
|
+
const asset = releaseInfo.assets.find(it => it.name === channelFile);
|
|
27
|
+
if (asset == null) {
|
|
28
|
+
// html_url must be always, but just to be sure
|
|
29
|
+
throw builder_util_runtime_1.newError(`Cannot find ${channelFile} in the release ${releaseInfo.html_url || releaseInfo.name}`, "ERR_UPDATER_CHANNEL_FILE_NOT_FOUND");
|
|
30
|
+
}
|
|
31
|
+
const url = new url_1.URL(asset.url);
|
|
32
|
+
let result;
|
|
33
|
+
try {
|
|
34
|
+
result = js_yaml_1.load((await this.httpRequest(url, this.configureHeaders("application/octet-stream"), cancellationToken)));
|
|
35
|
+
}
|
|
36
|
+
catch (e) {
|
|
37
|
+
if (e instanceof builder_util_runtime_1.HttpError && e.statusCode === 404) {
|
|
38
|
+
throw builder_util_runtime_1.newError(`Cannot find ${channelFile} in the latest release artifacts (${url}): ${e.stack || e.message}`, "ERR_UPDATER_CHANNEL_FILE_NOT_FOUND");
|
|
39
|
+
}
|
|
40
|
+
throw e;
|
|
41
|
+
}
|
|
42
|
+
;
|
|
43
|
+
result.assets = releaseInfo.assets;
|
|
44
|
+
return result;
|
|
133
45
|
}
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
try {
|
|
138
|
-
const version = JSON.parse(await this.httpRequest(url, this.configureHeaders("application/vnd.github.v3+json"), cancellationToken));
|
|
139
|
-
|
|
140
|
-
if (allowPrerelease) {
|
|
141
|
-
return version.find(v => v.prerelease) || version[0];
|
|
142
|
-
} else {
|
|
143
|
-
return version;
|
|
144
|
-
}
|
|
145
|
-
} catch (e) {
|
|
146
|
-
throw (0, _builderUtilRuntime().newError)(`Unable to find latest version on GitHub (${url}), please ensure a production release exists: ${e.stack || e.message}`, "ERR_UPDATER_LATEST_VERSION_NOT_FOUND");
|
|
46
|
+
get fileExtraDownloadHeaders() {
|
|
47
|
+
return this.configureHeaders("application/octet-stream");
|
|
147
48
|
}
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
}
|
|
171
|
-
|
|
49
|
+
// eslint-disable-next-line @typescript-eslint/explicit-function-return-type
|
|
50
|
+
configureHeaders(accept) {
|
|
51
|
+
return {
|
|
52
|
+
accept,
|
|
53
|
+
authorization: `token ${this.token}`,
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
async getLatestVersionInfo(cancellationToken) {
|
|
57
|
+
const allowPrerelease = this.updater.allowPrerelease;
|
|
58
|
+
let basePath = this.basePath;
|
|
59
|
+
if (!allowPrerelease) {
|
|
60
|
+
basePath = `${basePath}/latest`;
|
|
61
|
+
}
|
|
62
|
+
const url = util_1.newUrlFromBase(basePath, this.baseUrl);
|
|
63
|
+
try {
|
|
64
|
+
const version = JSON.parse((await this.httpRequest(url, this.configureHeaders("application/vnd.github.v3+json"), cancellationToken)));
|
|
65
|
+
if (allowPrerelease) {
|
|
66
|
+
return version.find(it => it.prerelease) || version[0];
|
|
67
|
+
}
|
|
68
|
+
else {
|
|
69
|
+
return version;
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
catch (e) {
|
|
73
|
+
throw builder_util_runtime_1.newError(`Unable to find latest version on GitHub (${url}), please ensure a production release exists: ${e.stack || e.message}`, "ERR_UPDATER_LATEST_VERSION_NOT_FOUND");
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
get basePath() {
|
|
77
|
+
return this.computeGithubBasePath(`/repos/${this.options.owner}/${this.options.repo}/releases`);
|
|
78
|
+
}
|
|
79
|
+
resolveFiles(updateInfo) {
|
|
80
|
+
return Provider_1.getFileList(updateInfo).map(it => {
|
|
81
|
+
const name = path.posix.basename(it.url).replace(/ /g, "-");
|
|
82
|
+
const asset = updateInfo.assets.find(it => it != null && it.name === name);
|
|
83
|
+
if (asset == null) {
|
|
84
|
+
throw builder_util_runtime_1.newError(`Cannot find asset "${name}" in: ${JSON.stringify(updateInfo.assets, null, 2)}`, "ERR_UPDATER_ASSET_NOT_FOUND");
|
|
85
|
+
}
|
|
86
|
+
return {
|
|
87
|
+
url: new url_1.URL(asset.url),
|
|
88
|
+
info: it,
|
|
89
|
+
};
|
|
90
|
+
});
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
exports.PrivateGitHubProvider = PrivateGitHubProvider;
|
|
172
94
|
//# sourceMappingURL=PrivateGitHubProvider.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/providers/PrivateGitHubProvider.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"PrivateGitHubProvider.js","sourceRoot":"","sources":["../../src/providers/PrivateGitHubProvider.ts"],"names":[],"mappings":";;;AAAA,+DAAwG;AAExG,qCAA8B;AAC9B,6BAA4B;AAE5B,6BAAyB;AACzB,kCAA4D;AAC5D,qDAAqD;AAErD,yCAAgE;AAMhE,MAAa,qBAAsB,SAAQ,mCAA2C;IACpF,YAAY,OAAsB,EAAmB,OAAmB,EAAmB,KAAa,EAAE,cAAsC;QAC9I,KAAK,CAAC,OAAO,EAAE,gBAAgB,EAAE,cAAc,CAAC,CAAA;QADG,YAAO,GAAP,OAAO,CAAY;QAAmB,UAAK,GAAL,KAAK,CAAQ;IAExG,CAAC;IAES,oBAAoB,CAAC,GAAQ,EAAE,OAAoC;QAC3E,MAAM,MAAM,GAAG,KAAK,CAAC,oBAAoB,CAAC,GAAG,EAAE,OAAO,CAAC,CACtD;QAAC,MAAc,CAAC,QAAQ,GAAG,QAAQ,CAAA;QACpC,OAAO,MAAM,CAAA;IACf,CAAC;IAED,KAAK,CAAC,gBAAgB;QACpB,MAAM,iBAAiB,GAAG,IAAI,wCAAiB,EAAE,CAAA;QACjD,MAAM,WAAW,GAAG,yBAAkB,CAAC,IAAI,CAAC,qBAAqB,EAAE,CAAC,CAAA;QAEpE,MAAM,WAAW,GAAG,MAAM,IAAI,CAAC,oBAAoB,CAAC,iBAAiB,CAAC,CAAA;QACtE,MAAM,KAAK,GAAG,WAAW,CAAC,MAAM,CAAC,IAAI,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,IAAI,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CAAA;YAC1E,IAAI,KAAK,IAAI,IAAI,EAAE;gBACjB,MAAM,+BAAQ,CAAC,sBAAsB,IAAI,SAAS,IAAI,CAAC,SAAS,CAAC,UAAU,CAAC,MAAM,EAAE,IAAI,EAAE,CAAC,CAAC,EAAE,EAAE,6BAA6B,CAAC,CAAA;aAC/H;YAED,OAAO;gBACL,GAAG,EAAE,IAAI,SAAG,CAAC,KAAK,CAAC,GAAG,CAAC;gBACvB,IAAI,EAAE,EAAE;aACT,CAAA;QACH,CAAC,CAAC,CAAA;IACJ,CAAC;CACF;AAvFD,sDAuFC","sourcesContent":["import { CancellationToken, GithubOptions, HttpError, newError, UpdateInfo } from \"builder-util-runtime\"\nimport { OutgoingHttpHeaders, RequestOptions } from \"http\"\nimport { load } from \"js-yaml\"\nimport * as path from \"path\"\nimport { AppUpdater } from \"../AppUpdater\"\nimport { URL } from \"url\"\nimport { getChannelFilename, newUrlFromBase } from \"../util\"\nimport { BaseGitHubProvider } from \"./GitHubProvider\"\nimport { ResolvedUpdateFileInfo } from \"../main\"\nimport { getFileList, ProviderRuntimeOptions } from \"./Provider\"\n\nexport interface PrivateGitHubUpdateInfo extends UpdateInfo {\n assets: Array<Asset>\n}\n\nexport class PrivateGitHubProvider extends BaseGitHubProvider<PrivateGitHubUpdateInfo> {\n constructor(options: GithubOptions, private readonly updater: AppUpdater, private readonly token: string, runtimeOptions: ProviderRuntimeOptions) {\n super(options, \"api.github.com\", runtimeOptions)\n }\n\n protected createRequestOptions(url: URL, headers?: OutgoingHttpHeaders | null): RequestOptions {\n const result = super.createRequestOptions(url, headers)\n ;(result as any).redirect = \"manual\"\n return result\n }\n\n async getLatestVersion(): Promise<PrivateGitHubUpdateInfo> {\n const cancellationToken = new CancellationToken()\n const channelFile = getChannelFilename(this.getDefaultChannelName())\n\n const releaseInfo = await this.getLatestVersionInfo(cancellationToken)\n const asset = releaseInfo.assets.find(it => it.name === channelFile)\n if (asset == null) {\n // html_url must be always, but just to be sure\n throw newError(`Cannot find ${channelFile} in the release ${releaseInfo.html_url || releaseInfo.name}`, \"ERR_UPDATER_CHANNEL_FILE_NOT_FOUND\")\n }\n\n const url = new URL(asset.url)\n let result: any\n try {\n result = load((await this.httpRequest(url, this.configureHeaders(\"application/octet-stream\"), cancellationToken))!)\n } catch (e) {\n if (e instanceof HttpError && e.statusCode === 404) {\n throw newError(`Cannot find ${channelFile} in the latest release artifacts (${url}): ${e.stack || e.message}`, \"ERR_UPDATER_CHANNEL_FILE_NOT_FOUND\")\n }\n throw e\n }\n\n ;(result as PrivateGitHubUpdateInfo).assets = releaseInfo.assets\n return result\n }\n\n get fileExtraDownloadHeaders(): OutgoingHttpHeaders | null {\n return this.configureHeaders(\"application/octet-stream\")\n }\n\n // eslint-disable-next-line @typescript-eslint/explicit-function-return-type\n private configureHeaders(accept: string) {\n return {\n accept,\n authorization: `token ${this.token}`,\n }\n }\n\n private async getLatestVersionInfo(cancellationToken: CancellationToken): Promise<ReleaseInfo> {\n const allowPrerelease = this.updater.allowPrerelease\n let basePath = this.basePath\n if (!allowPrerelease) {\n basePath = `${basePath}/latest`\n }\n\n const url = newUrlFromBase(basePath, this.baseUrl)\n try {\n const version = JSON.parse((await this.httpRequest(url, this.configureHeaders(\"application/vnd.github.v3+json\"), cancellationToken))!)\n if (allowPrerelease) {\n return (version as Array<{ prerelease: boolean }>).find(it => it.prerelease) || version[0]\n } else {\n return version\n }\n } catch (e) {\n throw newError(`Unable to find latest version on GitHub (${url}), please ensure a production release exists: ${e.stack || e.message}`, \"ERR_UPDATER_LATEST_VERSION_NOT_FOUND\")\n }\n }\n\n private get basePath(): string {\n return this.computeGithubBasePath(`/repos/${this.options.owner}/${this.options.repo}/releases`)\n }\n\n resolveFiles(updateInfo: PrivateGitHubUpdateInfo): Array<ResolvedUpdateFileInfo> {\n return getFileList(updateInfo).map(it => {\n const name = path.posix.basename(it.url).replace(/ /g, \"-\")\n const asset = updateInfo.assets.find(it => it != null && it.name === name)\n if (asset == null) {\n throw newError(`Cannot find asset \"${name}\" in: ${JSON.stringify(updateInfo.assets, null, 2)}`, \"ERR_UPDATER_ASSET_NOT_FOUND\")\n }\n\n return {\n url: new URL(asset.url),\n info: it,\n }\n })\n }\n}\n\ninterface ReleaseInfo {\n name: string\n html_url: string\n assets: Array<Asset>\n}\n\nexport interface Asset {\n name: string\n url: string\n}\n"]}
|
|
@@ -1,185 +1,134 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
exports.parseUpdateInfo = parseUpdateInfo;
|
|
8
|
-
exports.getFileList = getFileList;
|
|
9
|
-
exports.resolveFiles = resolveFiles;
|
|
10
|
-
exports.Provider = void 0;
|
|
11
|
-
|
|
12
|
-
function _builderUtilRuntime() {
|
|
13
|
-
const data = require("builder-util-runtime");
|
|
14
|
-
|
|
15
|
-
_builderUtilRuntime = function () {
|
|
16
|
-
return data;
|
|
17
|
-
};
|
|
18
|
-
|
|
19
|
-
return data;
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
function _jsYaml() {
|
|
23
|
-
const data = require("js-yaml");
|
|
24
|
-
|
|
25
|
-
_jsYaml = function () {
|
|
26
|
-
return data;
|
|
27
|
-
};
|
|
28
|
-
|
|
29
|
-
return data;
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
function _main() {
|
|
33
|
-
const data = require("../main");
|
|
34
|
-
|
|
35
|
-
_main = function () {
|
|
36
|
-
return data;
|
|
37
|
-
};
|
|
38
|
-
|
|
39
|
-
return data;
|
|
40
|
-
}
|
|
41
|
-
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.resolveFiles = exports.getFileList = exports.parseUpdateInfo = exports.findFile = exports.Provider = void 0;
|
|
4
|
+
const builder_util_runtime_1 = require("builder-util-runtime");
|
|
5
|
+
const js_yaml_1 = require("js-yaml");
|
|
6
|
+
const util_1 = require("../util");
|
|
42
7
|
class Provider {
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
result.headers = headers;
|
|
94
|
-
}
|
|
95
|
-
} else {
|
|
96
|
-
result.headers = headers == null ? this.requestHeaders : { ...this.requestHeaders,
|
|
97
|
-
...headers
|
|
98
|
-
};
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
(0, _builderUtilRuntime().configureRequestUrl)(url, result);
|
|
102
|
-
return result;
|
|
103
|
-
}
|
|
104
|
-
|
|
8
|
+
constructor(runtimeOptions) {
|
|
9
|
+
this.runtimeOptions = runtimeOptions;
|
|
10
|
+
this.requestHeaders = null;
|
|
11
|
+
this.executor = runtimeOptions.executor;
|
|
12
|
+
}
|
|
13
|
+
get isUseMultipleRangeRequest() {
|
|
14
|
+
return this.runtimeOptions.isUseMultipleRangeRequest !== false;
|
|
15
|
+
}
|
|
16
|
+
getChannelFilePrefix() {
|
|
17
|
+
if (this.runtimeOptions.platform === "linux") {
|
|
18
|
+
const arch = process.env.TEST_UPDATER_ARCH || process.arch;
|
|
19
|
+
const archSuffix = arch === "x64" ? "" : `-${arch}`;
|
|
20
|
+
return "-linux" + archSuffix;
|
|
21
|
+
}
|
|
22
|
+
else {
|
|
23
|
+
return this.runtimeOptions.platform === "darwin" ? "-mac" : "";
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
// due to historical reasons for windows we use channel name without platform specifier
|
|
27
|
+
getDefaultChannelName() {
|
|
28
|
+
return this.getCustomChannelName("latest");
|
|
29
|
+
}
|
|
30
|
+
getCustomChannelName(channel) {
|
|
31
|
+
return `${channel}${this.getChannelFilePrefix()}`;
|
|
32
|
+
}
|
|
33
|
+
get fileExtraDownloadHeaders() {
|
|
34
|
+
return null;
|
|
35
|
+
}
|
|
36
|
+
setRequestHeaders(value) {
|
|
37
|
+
this.requestHeaders = value;
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Method to perform API request only to resolve update info, but not to download update.
|
|
41
|
+
*/
|
|
42
|
+
httpRequest(url, headers, cancellationToken) {
|
|
43
|
+
return this.executor.request(this.createRequestOptions(url, headers), cancellationToken);
|
|
44
|
+
}
|
|
45
|
+
createRequestOptions(url, headers) {
|
|
46
|
+
const result = {};
|
|
47
|
+
if (this.requestHeaders == null) {
|
|
48
|
+
if (headers != null) {
|
|
49
|
+
result.headers = headers;
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
else {
|
|
53
|
+
result.headers = headers == null ? this.requestHeaders : { ...this.requestHeaders, ...headers };
|
|
54
|
+
}
|
|
55
|
+
builder_util_runtime_1.configureRequestUrl(url, result);
|
|
56
|
+
return result;
|
|
57
|
+
}
|
|
105
58
|
}
|
|
106
|
-
|
|
107
59
|
exports.Provider = Provider;
|
|
108
|
-
|
|
109
60
|
function findFile(files, extension, not) {
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
61
|
+
if (files.length === 0) {
|
|
62
|
+
throw builder_util_runtime_1.newError("No files provided", "ERR_UPDATER_NO_FILES_PROVIDED");
|
|
63
|
+
}
|
|
64
|
+
const result = files.find(it => it.url.pathname.toLowerCase().endsWith(`.${extension}`));
|
|
65
|
+
if (result != null) {
|
|
66
|
+
return result;
|
|
67
|
+
}
|
|
68
|
+
else if (not == null) {
|
|
69
|
+
return files[0];
|
|
70
|
+
}
|
|
71
|
+
else {
|
|
72
|
+
return files.find(fileInfo => !not.some(ext => fileInfo.url.pathname.toLowerCase().endsWith(`.${ext}`)));
|
|
73
|
+
}
|
|
123
74
|
}
|
|
124
|
-
|
|
75
|
+
exports.findFile = findFile;
|
|
125
76
|
function parseUpdateInfo(rawData, channelFile, channelFileUrl) {
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
return result;
|
|
77
|
+
if (rawData == null) {
|
|
78
|
+
throw builder_util_runtime_1.newError(`Cannot parse update info from ${channelFile} in the latest release artifacts (${channelFileUrl}): rawData: null`, "ERR_UPDATER_INVALID_UPDATE_INFO");
|
|
79
|
+
}
|
|
80
|
+
let result;
|
|
81
|
+
try {
|
|
82
|
+
result = js_yaml_1.load(rawData);
|
|
83
|
+
}
|
|
84
|
+
catch (e) {
|
|
85
|
+
throw builder_util_runtime_1.newError(`Cannot parse update info from ${channelFile} in the latest release artifacts (${channelFileUrl}): ${e.stack || e.message}, rawData: ${rawData}`, "ERR_UPDATER_INVALID_UPDATE_INFO");
|
|
86
|
+
}
|
|
87
|
+
return result;
|
|
139
88
|
}
|
|
140
|
-
|
|
89
|
+
exports.parseUpdateInfo = parseUpdateInfo;
|
|
141
90
|
function getFileList(updateInfo) {
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
} // noinspection JSDeprecatedSymbols
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
if (updateInfo.path != null) {
|
|
91
|
+
const files = updateInfo.files;
|
|
92
|
+
if (files != null && files.length > 0) {
|
|
93
|
+
return files;
|
|
94
|
+
}
|
|
150
95
|
// noinspection JSDeprecatedSymbols
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
96
|
+
if (updateInfo.path != null) {
|
|
97
|
+
// noinspection JSDeprecatedSymbols
|
|
98
|
+
return [
|
|
99
|
+
{
|
|
100
|
+
url: updateInfo.path,
|
|
101
|
+
sha2: updateInfo.sha2,
|
|
102
|
+
sha512: updateInfo.sha512,
|
|
103
|
+
},
|
|
104
|
+
];
|
|
105
|
+
}
|
|
106
|
+
else {
|
|
107
|
+
throw builder_util_runtime_1.newError(`No files provided: ${builder_util_runtime_1.safeStringifyJson(updateInfo)}`, "ERR_UPDATER_NO_FILES_PROVIDED");
|
|
108
|
+
}
|
|
159
109
|
}
|
|
160
|
-
|
|
161
|
-
function resolveFiles(updateInfo, baseUrl, pathTransformer = p => p) {
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
};
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
// __ts-babel@6.0.4
|
|
110
|
+
exports.getFileList = getFileList;
|
|
111
|
+
function resolveFiles(updateInfo, baseUrl, pathTransformer = (p) => p) {
|
|
112
|
+
const files = getFileList(updateInfo);
|
|
113
|
+
const result = files.map(fileInfo => {
|
|
114
|
+
if (fileInfo.sha2 == null && fileInfo.sha512 == null) {
|
|
115
|
+
throw builder_util_runtime_1.newError(`Update info doesn't contain nor sha256 neither sha512 checksum: ${builder_util_runtime_1.safeStringifyJson(fileInfo)}`, "ERR_UPDATER_NO_CHECKSUM");
|
|
116
|
+
}
|
|
117
|
+
return {
|
|
118
|
+
url: util_1.newUrlFromBase(pathTransformer(fileInfo.url), baseUrl),
|
|
119
|
+
info: fileInfo,
|
|
120
|
+
};
|
|
121
|
+
});
|
|
122
|
+
const packages = updateInfo.packages;
|
|
123
|
+
const packageInfo = packages == null ? null : packages[process.arch] || packages.ia32;
|
|
124
|
+
if (packageInfo != null) {
|
|
125
|
+
;
|
|
126
|
+
result[0].packageInfo = {
|
|
127
|
+
...packageInfo,
|
|
128
|
+
path: util_1.newUrlFromBase(pathTransformer(packageInfo.path), baseUrl).href,
|
|
129
|
+
};
|
|
130
|
+
}
|
|
131
|
+
return result;
|
|
132
|
+
}
|
|
133
|
+
exports.resolveFiles = resolveFiles;
|
|
185
134
|
//# sourceMappingURL=Provider.js.map
|