update electron to v43
This commit is contained in:
parent
68ac0beedf
commit
fb6c8b6ee9
5385 changed files with 513060 additions and 123058 deletions
51
electron/node_modules/electron-publish/out/gitHubPublisher.js
generated
vendored
51
electron/node_modules/electron-publish/out/gitHubPublisher.js
generated
vendored
|
|
@ -3,41 +3,44 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|||
exports.GitHubPublisher = void 0;
|
||||
const builder_util_1 = require("builder-util");
|
||||
const builder_util_runtime_1 = require("builder-util-runtime");
|
||||
const nodeHttpExecutor_1 = require("builder-util/out/nodeHttpExecutor");
|
||||
const lazy_val_1 = require("lazy-val");
|
||||
const mime = require("mime");
|
||||
const url_1 = require("url");
|
||||
const httpPublisher_1 = require("./httpPublisher");
|
||||
const publisher_1 = require("./publisher");
|
||||
class GitHubPublisher extends publisher_1.HttpPublisher {
|
||||
constructor(context, info, version, options = {}) {
|
||||
const util_1 = require("./util");
|
||||
class GitHubPublisher extends httpPublisher_1.HttpPublisher {
|
||||
constructor(context, info, version, options = {}, releaseBody, releaseName) {
|
||||
super(context, true);
|
||||
this.info = info;
|
||||
this.version = version;
|
||||
this.options = options;
|
||||
this.releaseBody = releaseBody;
|
||||
this.releaseName = releaseName;
|
||||
this._release = new lazy_val_1.Lazy(() => (this.token === "__test__" ? Promise.resolve(null) : this.getOrCreateRelease()));
|
||||
this.providerName = "github";
|
||||
this.releaseLogFields = null;
|
||||
let token = info.token;
|
||||
if (builder_util_1.isEmptyOrSpaces(token)) {
|
||||
token = process.env.GH_TOKEN || process.env.GITHUB_TOKEN;
|
||||
if (builder_util_1.isEmptyOrSpaces(token)) {
|
||||
if ((0, builder_util_1.isEmptyOrSpaces)(token) || process.env.GITHUB_RELEASE_TOKEN) {
|
||||
token = process.env.GITHUB_RELEASE_TOKEN ? process.env.GITHUB_RELEASE_TOKEN : process.env.GH_TOKEN || process.env.GITHUB_TOKEN;
|
||||
if ((0, builder_util_1.isEmptyOrSpaces)(token)) {
|
||||
throw new builder_util_1.InvalidConfigurationError(`GitHub Personal Access Token is not set, neither programmatically, nor using env "GH_TOKEN"`);
|
||||
}
|
||||
token = token.trim();
|
||||
if (!builder_util_1.isTokenCharValid(token)) {
|
||||
throw new builder_util_1.InvalidConfigurationError(`GitHub Personal Access Token (${JSON.stringify(token)}) contains invalid characters, please check env "GH_TOKEN"`);
|
||||
if (!(0, builder_util_1.isTokenCharValid)(token)) {
|
||||
throw new builder_util_1.InvalidConfigurationError(`GitHub Personal Access Token ${(0, builder_util_runtime_1.hashSensitiveValue)(token)} contains invalid characters, please check env "GH_TOKEN"`);
|
||||
}
|
||||
}
|
||||
this.token = token;
|
||||
if (version.startsWith("v")) {
|
||||
throw new builder_util_1.InvalidConfigurationError(`Version must not start with "v": ${version}`);
|
||||
}
|
||||
this.tag = info.vPrefixedTagName === false ? version : `v${version}`;
|
||||
if (builder_util_1.isEnvTrue(process.env.EP_DRAFT)) {
|
||||
this.tag = (0, builder_util_runtime_1.githubTagPrefix)(info) + version;
|
||||
if ((0, builder_util_1.isEnvTrue)(process.env.EP_DRAFT)) {
|
||||
this.releaseType = "draft";
|
||||
builder_util_1.log.info({ reason: "env EP_DRAFT is set to true" }, "GitHub provider release type is set to draft");
|
||||
}
|
||||
else if (builder_util_1.isEnvTrue(process.env.EP_PRE_RELEASE) || builder_util_1.isEnvTrue(process.env.EP_PRELEASE) /* https://github.com/electron-userland/electron-builder/issues/2878 */) {
|
||||
else if ((0, builder_util_1.isEnvTrue)(process.env.EP_PRE_RELEASE) || (0, builder_util_1.isEnvTrue)(process.env.EP_PRELEASE) /* https://github.com/electron-userland/electron-builder/issues/2878 */) {
|
||||
this.releaseType = "prerelease";
|
||||
builder_util_1.log.info({ reason: "env EP_PRE_RELEASE is set to true" }, "GitHub provider release type is set to prerelease");
|
||||
}
|
||||
|
|
@ -82,7 +85,7 @@ class GitHubPublisher extends publisher_1.HttpPublisher {
|
|||
// https://github.com/electron-userland/electron-builder/issues/2074
|
||||
// if release created < 2 hours — allow to upload
|
||||
const publishedAt = release.published_at == null ? null : Date.parse(release.published_at);
|
||||
if (!builder_util_1.isEnvTrue(process.env.EP_GH_IGNORE_TIME) && publishedAt != null && Date.now() - publishedAt > 2 * 3600 * 1000) {
|
||||
if (!(0, builder_util_1.isEnvTrue)(process.env.EP_GH_IGNORE_TIME) && publishedAt != null && Date.now() - publishedAt > 2 * 3600 * 1000) {
|
||||
// https://github.com/electron-userland/electron-builder/issues/1183#issuecomment-275867187
|
||||
this.releaseLogFields = {
|
||||
reason: "existing release published more than 2 hours ago",
|
||||
|
|
@ -95,7 +98,7 @@ class GitHubPublisher extends publisher_1.HttpPublisher {
|
|||
return release;
|
||||
}
|
||||
// https://github.com/electron-userland/electron-builder/issues/1835
|
||||
if (this.options.publish === "always" || publisher_1.getCiTag() != null) {
|
||||
if (this.options.publish === "always" || (0, publisher_1.getCiTag)() != null) {
|
||||
builder_util_1.log.info({
|
||||
reason: "release doesn't exist",
|
||||
...logFields,
|
||||
|
|
@ -126,12 +129,12 @@ class GitHubPublisher extends publisher_1.HttpPublisher {
|
|||
builder_util_1.log.warn({ file: fileName, ...this.releaseLogFields }, "skipped publishing");
|
||||
return;
|
||||
}
|
||||
const parsedUrl = url_1.parse(`${release.upload_url.substring(0, release.upload_url.indexOf("{"))}?name=${fileName}`);
|
||||
const parsedUrl = (0, url_1.parse)(`${release.upload_url.substring(0, release.upload_url.indexOf("{"))}?name=${fileName}`);
|
||||
return await this.doUploadFile(0, parsedUrl, fileName, dataLength, requestProcessor, release);
|
||||
}
|
||||
doUploadFile(attemptNumber, parsedUrl, fileName, dataLength, requestProcessor, release) {
|
||||
return nodeHttpExecutor_1.httpExecutor
|
||||
.doApiRequest(builder_util_runtime_1.configureRequestOptions({
|
||||
return builder_util_1.httpExecutor
|
||||
.doApiRequest((0, builder_util_runtime_1.configureRequestOptions)({
|
||||
protocol: parsedUrl.protocol,
|
||||
hostname: parsedUrl.hostname,
|
||||
path: parsedUrl.path,
|
||||
|
|
@ -143,7 +146,7 @@ class GitHubPublisher extends publisher_1.HttpPublisher {
|
|||
},
|
||||
timeout: this.info.timeout || undefined,
|
||||
}, this.token), this.context.cancellationToken, requestProcessor)
|
||||
.catch(e => {
|
||||
.catch((e) => {
|
||||
if (attemptNumber > 3) {
|
||||
return Promise.reject(e);
|
||||
}
|
||||
|
|
@ -169,12 +172,16 @@ class GitHubPublisher extends publisher_1.HttpPublisher {
|
|||
return e.statusCode === 422 && descIncludesAlreadyExists;
|
||||
}
|
||||
createRelease() {
|
||||
return this.githubRequest(`/repos/${this.info.owner}/${this.info.repo}/releases`, this.token, {
|
||||
const data = {
|
||||
tag_name: this.tag,
|
||||
name: this.version,
|
||||
name: this.releaseName || this.version,
|
||||
draft: this.releaseType === "draft",
|
||||
prerelease: this.releaseType === "prerelease",
|
||||
});
|
||||
};
|
||||
if (this.releaseBody) {
|
||||
data.body = (0, util_1.trimStringWithWarn)(this.releaseBody, 100000, "release body exceeds GitHub API limit, truncating");
|
||||
}
|
||||
return this.githubRequest(`/repos/${this.info.owner}/${this.info.repo}/releases`, this.token, data);
|
||||
}
|
||||
// test only
|
||||
//noinspection JSUnusedGlobalSymbols
|
||||
|
|
@ -208,8 +215,8 @@ class GitHubPublisher extends publisher_1.HttpPublisher {
|
|||
}
|
||||
githubRequest(path, token, data = null, method) {
|
||||
// host can contains port, but node http doesn't support host as url does
|
||||
const baseUrl = url_1.parse(`https://${this.info.host || "api.github.com"}`);
|
||||
return builder_util_runtime_1.parseJson(nodeHttpExecutor_1.httpExecutor.request(builder_util_runtime_1.configureRequestOptions({
|
||||
const baseUrl = (0, url_1.parse)(`https://${this.info.host || "api.github.com"}`);
|
||||
return (0, builder_util_runtime_1.parseJson)(builder_util_1.httpExecutor.request((0, builder_util_runtime_1.configureRequestOptions)({
|
||||
protocol: baseUrl.protocol,
|
||||
hostname: baseUrl.hostname,
|
||||
port: baseUrl.port,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue