This commit is contained in:
root
2025-11-25 09:56:15 +03:00
commit 68c8f0e80d
23717 changed files with 3200521 additions and 0 deletions

View File

@ -0,0 +1,36 @@
/// <reference types="node" />
import { Arch } from "builder-util";
import { GithubOptions } from "builder-util-runtime";
import { ClientRequest } from "http";
import { Lazy } from "lazy-val";
import { HttpPublisher, PublishContext, PublishOptions } from "./publisher";
export interface Release {
id: number;
tag_name: string;
draft: boolean;
prerelease: boolean;
published_at: string;
upload_url: string;
}
export declare class GitHubPublisher extends HttpPublisher {
private readonly info;
private readonly version;
private readonly options;
private readonly tag;
readonly _release: Lazy<any>;
private readonly token;
readonly providerName = "github";
private readonly releaseType;
private releaseLogFields;
constructor(context: PublishContext, info: GithubOptions, version: string, options?: PublishOptions);
private getOrCreateRelease;
private overwriteArtifact;
protected doUpload(fileName: string, arch: Arch, dataLength: number, requestProcessor: (request: ClientRequest, reject: (error: Error) => void) => void): Promise<any>;
private doUploadFile;
private doesErrorMeanAlreadyExists;
private createRelease;
getRelease(): Promise<any>;
deleteRelease(): Promise<any>;
private githubRequest;
toString(): string;
}

226
mc_test/node_modules/electron-publish/out/gitHubPublisher.js generated vendored Executable file
View File

@ -0,0 +1,226 @@
"use strict";
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 publisher_1 = require("./publisher");
class GitHubPublisher extends publisher_1.HttpPublisher {
constructor(context, info, version, options = {}) {
super(context, true);
this.info = info;
this.version = version;
this.options = options;
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 ((0, builder_util_1.isEmptyOrSpaces)(token)) {
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 (!(0, 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"`);
}
}
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 ((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 ((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");
}
else if (info.releaseType != null) {
this.releaseType = info.releaseType;
}
else if (options.prerelease) {
this.releaseType = "prerelease";
}
else {
// noinspection PointlessBooleanExpressionJS
this.releaseType = options.draft === false ? "release" : "draft";
}
}
async getOrCreateRelease() {
const logFields = {
tag: this.tag,
version: this.version,
};
// we don't use "Get a release by tag name" because "tag name" means existing git tag, but we draft release and don't create git tag
const releases = await this.githubRequest(`/repos/${this.info.owner}/${this.info.repo}/releases`, this.token);
for (const release of releases) {
if (!(release.tag_name === this.tag || release.tag_name === this.version)) {
continue;
}
if (release.draft) {
return release;
}
// https://github.com/electron-userland/electron-builder/issues/1197
// https://github.com/electron-userland/electron-builder/issues/2072
if (this.releaseType === "draft") {
this.releaseLogFields = {
reason: "existing type not compatible with publishing type",
...logFields,
existingType: release.prerelease ? "pre-release" : "release",
publishingType: this.releaseType,
};
builder_util_1.log.warn(this.releaseLogFields, "GitHub release not created");
return null;
}
// https://github.com/electron-userland/electron-builder/issues/1133
// 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 (!(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",
...logFields,
date: new Date(publishedAt).toString(),
};
builder_util_1.log.warn(this.releaseLogFields, "GitHub release not created");
return null;
}
return release;
}
// https://github.com/electron-userland/electron-builder/issues/1835
if (this.options.publish === "always" || (0, publisher_1.getCiTag)() != null) {
builder_util_1.log.info({
reason: "release doesn't exist",
...logFields,
}, `creating GitHub release`);
return this.createRelease();
}
this.releaseLogFields = {
reason: 'release doesn\'t exist and not created because "publish" is not "always" and build is not on tag',
...logFields,
};
return null;
}
async overwriteArtifact(fileName, release) {
// delete old artifact and re-upload
builder_util_1.log.warn({ file: fileName, reason: "already exists on GitHub" }, "overwrite published file");
const assets = await this.githubRequest(`/repos/${this.info.owner}/${this.info.repo}/releases/${release.id}/assets`, this.token, null);
for (const asset of assets) {
if (asset.name === fileName) {
await this.githubRequest(`/repos/${this.info.owner}/${this.info.repo}/releases/assets/${asset.id}`, this.token, null, "DELETE");
return;
}
}
builder_util_1.log.debug({ file: fileName, reason: "not found on GitHub" }, "trying to upload again");
}
async doUpload(fileName, arch, dataLength, requestProcessor) {
const release = await this._release.value;
if (release == null) {
builder_util_1.log.warn({ file: fileName, ...this.releaseLogFields }, "skipped publishing");
return;
}
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((0, builder_util_runtime_1.configureRequestOptions)({
protocol: parsedUrl.protocol,
hostname: parsedUrl.hostname,
path: parsedUrl.path,
method: "POST",
headers: {
accept: "application/vnd.github.v3+json",
"Content-Type": mime.getType(fileName) || "application/octet-stream",
"Content-Length": dataLength,
},
timeout: this.info.timeout || undefined,
}, this.token), this.context.cancellationToken, requestProcessor)
.catch((e) => {
if (attemptNumber > 3) {
return Promise.reject(e);
}
else if (this.doesErrorMeanAlreadyExists(e)) {
return this.overwriteArtifact(fileName, release).then(() => this.doUploadFile(attemptNumber + 1, parsedUrl, fileName, dataLength, requestProcessor, release));
}
else {
return new Promise((resolve, reject) => {
const newAttemptNumber = attemptNumber + 1;
setTimeout(() => {
this.doUploadFile(newAttemptNumber, parsedUrl, fileName, dataLength, requestProcessor, release).then(resolve).catch(reject);
}, newAttemptNumber * 2000);
});
}
});
}
doesErrorMeanAlreadyExists(e) {
if (!e.description) {
return false;
}
const desc = e.description;
const descIncludesAlreadyExists = (desc.includes("errors") && desc.includes("already_exists")) || (desc.errors && desc.errors.length >= 1 && desc.errors[0].code === "already_exists");
return e.statusCode === 422 && descIncludesAlreadyExists;
}
createRelease() {
return this.githubRequest(`/repos/${this.info.owner}/${this.info.repo}/releases`, this.token, {
tag_name: this.tag,
name: this.version,
draft: this.releaseType === "draft",
prerelease: this.releaseType === "prerelease",
});
}
// test only
//noinspection JSUnusedGlobalSymbols
async getRelease() {
return this.githubRequest(`/repos/${this.info.owner}/${this.info.repo}/releases/${(await this._release.value).id}`, this.token);
}
//noinspection JSUnusedGlobalSymbols
async deleteRelease() {
if (!this._release.hasValue) {
return;
}
const release = await this._release.value;
for (let i = 0; i < 3; i++) {
try {
return await this.githubRequest(`/repos/${this.info.owner}/${this.info.repo}/releases/${release.id}`, this.token, null, "DELETE");
}
catch (e) {
if (e instanceof builder_util_runtime_1.HttpError) {
if (e.statusCode === 404) {
builder_util_1.log.warn({ releaseId: release.id, reason: "doesn't exist" }, "cannot delete release");
return;
}
else if (e.statusCode === 405 || e.statusCode === 502) {
continue;
}
}
throw e;
}
}
builder_util_1.log.warn({ releaseId: release.id }, "cannot delete release");
}
githubRequest(path, token, data = null, method) {
// host can contains port, but node http doesn't support host as url does
const baseUrl = (0, url_1.parse)(`https://${this.info.host || "api.github.com"}`);
return (0, builder_util_runtime_1.parseJson)(nodeHttpExecutor_1.httpExecutor.request((0, builder_util_runtime_1.configureRequestOptions)({
protocol: baseUrl.protocol,
hostname: baseUrl.hostname,
port: baseUrl.port,
path: this.info.host != null && this.info.host !== "github.com" ? `/api/v3${path.startsWith("/") ? path : `/${path}`}` : path,
headers: { accept: "application/vnd.github.v3+json" },
timeout: this.info.timeout || undefined,
}, token, method), this.context.cancellationToken, data));
}
toString() {
return `Github (owner: ${this.info.owner}, project: ${this.info.repo}, version: ${this.version})`;
}
}
exports.GitHubPublisher = GitHubPublisher;
//# sourceMappingURL=gitHubPublisher.js.map

File diff suppressed because one or more lines are too long

12
mc_test/node_modules/electron-publish/out/multiProgress.d.ts generated vendored Executable file
View File

@ -0,0 +1,12 @@
import { ProgressBar } from "./progress";
export declare class MultiProgress {
private readonly stream;
private cursor;
private totalLines;
private isLogListenerAdded;
private barCount;
createBar(format: string, options: any): ProgressBar;
private allocateLines;
private moveCursor;
terminate(): void;
}

79
mc_test/node_modules/electron-publish/out/multiProgress.js generated vendored Executable file
View File

@ -0,0 +1,79 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.MultiProgress = void 0;
const log_1 = require("builder-util/out/log");
const progress_1 = require("./progress");
class MultiProgress {
constructor() {
this.stream = process.stdout;
this.cursor = 0;
this.totalLines = 0;
this.isLogListenerAdded = false;
this.barCount = 0;
}
createBar(format, options) {
options.stream = this.stream;
// eslint-disable-next-line @typescript-eslint/no-this-alias
const manager = this;
class MultiProgressBar extends progress_1.ProgressBar {
constructor(format, options) {
super(format, options);
this.index = -1;
}
render() {
if (this.index === -1) {
this.index = manager.totalLines;
manager.allocateLines(1);
}
else {
manager.moveCursor(this.index);
}
super.render();
if (!manager.isLogListenerAdded) {
manager.isLogListenerAdded = true;
(0, log_1.setPrinter)(message => {
let newLineCount = 0;
let newLineIndex = message.indexOf("\n");
while (newLineIndex > -1) {
newLineCount++;
newLineIndex = message.indexOf("\n", ++newLineIndex);
}
manager.allocateLines(newLineCount + 1);
manager.stream.write(message);
});
}
}
terminate() {
manager.barCount--;
if (manager.barCount === 0 && manager.totalLines > 0) {
manager.allocateLines(1);
manager.totalLines = 0;
manager.cursor = 0;
(0, log_1.setPrinter)(null);
manager.isLogListenerAdded = false;
}
}
}
const bar = new MultiProgressBar(format, options);
this.barCount++;
return bar;
}
allocateLines(count) {
this.stream.moveCursor(0, this.totalLines - 1);
// if cursor pointed to previous line where \n is already printed, another \n is ignored, so, we can simply print it
this.stream.write("\n");
this.totalLines += count;
this.cursor = this.totalLines - 1;
}
moveCursor(index) {
this.stream.moveCursor(0, index - this.cursor);
this.cursor = index;
}
terminate() {
this.moveCursor(this.totalLines);
this.stream.clearLine();
this.stream.cursorTo(0);
}
}
exports.MultiProgress = MultiProgress;
//# sourceMappingURL=multiProgress.js.map

View File

@ -0,0 +1 @@
{"version":3,"file":"multiProgress.js","sourceRoot":"","sources":["../src/multiProgress.ts"],"names":[],"mappings":"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","sourcesContent":["import { setPrinter } from \"builder-util/out/log\"\nimport { ProgressBar } from \"./progress\"\n\nexport class MultiProgress {\n private readonly stream = process.stdout as any\n private cursor = 0\n\n private totalLines = 0\n\n private isLogListenerAdded = false\n\n private barCount = 0\n\n createBar(format: string, options: any): ProgressBar {\n options.stream = this.stream\n\n // eslint-disable-next-line @typescript-eslint/no-this-alias\n const manager = this\n class MultiProgressBar extends ProgressBar {\n private index = -1\n\n constructor(format: string, options: any) {\n super(format, options)\n }\n\n render() {\n if (this.index === -1) {\n this.index = manager.totalLines\n manager.allocateLines(1)\n } else {\n manager.moveCursor(this.index)\n }\n\n super.render()\n\n if (!manager.isLogListenerAdded) {\n manager.isLogListenerAdded = true\n setPrinter(message => {\n let newLineCount = 0\n let newLineIndex = message.indexOf(\"\\n\")\n while (newLineIndex > -1) {\n newLineCount++\n newLineIndex = message.indexOf(\"\\n\", ++newLineIndex)\n }\n\n manager.allocateLines(newLineCount + 1)\n manager.stream.write(message)\n })\n }\n }\n\n terminate() {\n manager.barCount--\n if (manager.barCount === 0 && manager.totalLines > 0) {\n manager.allocateLines(1)\n manager.totalLines = 0\n manager.cursor = 0\n setPrinter(null)\n manager.isLogListenerAdded = false\n }\n }\n }\n\n const bar = new MultiProgressBar(format, options)\n this.barCount++\n return bar\n }\n\n private allocateLines(count: number) {\n this.stream.moveCursor(0, this.totalLines - 1)\n // if cursor pointed to previous line where \\n is already printed, another \\n is ignored, so, we can simply print it\n this.stream.write(\"\\n\")\n this.totalLines += count\n this.cursor = this.totalLines - 1\n }\n\n private moveCursor(index: number) {\n this.stream.moveCursor(0, index - this.cursor)\n this.cursor = index\n }\n\n terminate() {\n this.moveCursor(this.totalLines)\n this.stream.clearLine()\n this.stream.cursorTo(0)\n }\n}\n"]}

70
mc_test/node_modules/electron-publish/out/progress.d.ts generated vendored Executable file
View File

@ -0,0 +1,70 @@
/*!
* node-progress
* Copyright(c) 2011 TJ Holowaychuk <tj@vision-media.ca>
* MIT Licensed
*/
export declare abstract class ProgressBar {
private readonly format;
private readonly stream;
private current;
total: number;
private readonly width;
private chars;
private tokens;
private lastDraw;
private start;
private complete;
/**
* Initialize a `ProgressBar` with the given `fmt` string and `options` or`total`.
*
* Options:
* - `curr` current completed index
* - `total` total number of ticks to complete
* - `width` the displayed width of the progress bar defaulting to total
* - `stream` the output stream defaulting to stderr
* - `head` head character defaulting to complete character
* - `complete` completion character defaulting to "="
* - `incomplete` incomplete character defaulting to "-"
* - `renderThrottle` minimum time between updates in milliseconds defaulting to 16
* - `callback` optional function to call when the progress bar completes
* - `clear` will clear the progress bar upon termination
*
* Tokens:
* - `:bar` the progress bar itself
* - `:current` current tick number
* - `:total` total ticks
* - `:elapsed` time elapsed in seconds
* - `:percent` completion percentage
* - `:eta` eta in seconds
* - `:rate` rate of ticks per second
*/
constructor(format: string, options?: any);
/**
* "tick" the progress bar with optional `len` and optional `tokens`.
*/
tick(delta: number): void;
set currentAmount(value: number);
render(): void;
/**
* "update" the progress bar to represent an exact percentage.
* The ratio (between 0 and 1) specified will be multiplied by `total` and
* floored, representing the closest available "tick." For example, if a
* progress bar has a length of 3 and `update(0.5)` is called, the progress
* will be set to 1.
*
* A ratio of 0.5 will attempt to set the progress to halfway.
*/
update(ratio: number): void;
/**
* "interrupt" the progress bar and write a message above it.
*/
interrupt(message: string): void;
abstract terminate(): void;
}
export declare class ProgressCallback {
private readonly progressBar;
private start;
private nextUpdate;
constructor(progressBar: ProgressBar);
update(transferred: number, total: number): void;
}

162
mc_test/node_modules/electron-publish/out/progress.js generated vendored Executable file
View File

@ -0,0 +1,162 @@
"use strict";
/*!
* node-progress
* Copyright(c) 2011 TJ Holowaychuk <tj@vision-media.ca>
* MIT Licensed
*/
Object.defineProperty(exports, "__esModule", { value: true });
exports.ProgressCallback = exports.ProgressBar = void 0;
class ProgressBar {
/**
* Initialize a `ProgressBar` with the given `fmt` string and `options` or`total`.
*
* Options:
* - `curr` current completed index
* - `total` total number of ticks to complete
* - `width` the displayed width of the progress bar defaulting to total
* - `stream` the output stream defaulting to stderr
* - `head` head character defaulting to complete character
* - `complete` completion character defaulting to "="
* - `incomplete` incomplete character defaulting to "-"
* - `renderThrottle` minimum time between updates in milliseconds defaulting to 16
* - `callback` optional function to call when the progress bar completes
* - `clear` will clear the progress bar upon termination
*
* Tokens:
* - `:bar` the progress bar itself
* - `:current` current tick number
* - `:total` total ticks
* - `:elapsed` time elapsed in seconds
* - `:percent` completion percentage
* - `:eta` eta in seconds
* - `:rate` rate of ticks per second
*/
constructor(format, options = {}) {
this.format = format;
this.current = 0;
this.total = 0;
this.tokens = null;
this.lastDraw = "";
this.start = 0;
this.complete = false;
this.stream = options.stream || process.stderr;
this.total = options.total;
this.width = options.width || this.total;
this.chars = {
complete: options.complete || "=",
incomplete: options.incomplete || "-",
head: options.head || options.complete || "=",
};
}
/**
* "tick" the progress bar with optional `len` and optional `tokens`.
*/
tick(delta) {
this.currentAmount = this.current + delta;
}
set currentAmount(value) {
this.current = value;
if (this.complete) {
return;
}
this.render();
if (this.current >= this.total) {
this.complete = true;
this.terminate();
}
}
render() {
// start time for eta
if (this.start === 0) {
this.start = Date.now();
}
const ratio = Math.min(Math.max(this.current / this.total, 0), 1);
const percent = ratio * 100;
const elapsed = Date.now() - this.start;
const eta = percent === 100 ? 0 : elapsed * (this.total / this.current - 1);
const rate = this.current / (elapsed / 1000);
/* populate the bar template with percentages and timestamps */
let str = this.format
.replace(":current", this.current.toString())
.replace(":total", this.total.toString())
.replace(":elapsed", isNaN(elapsed) ? "0.0" : (elapsed / 1000).toFixed(1))
.replace(":eta", isNaN(eta) || !isFinite(eta) ? "0.0" : (eta / 1000).toFixed(1))
.replace(":percent", percent.toFixed(0) + "%")
.replace(":rate", Math.round(rate).toString());
// compute the available space (non-zero) for the bar
let availableSpace = Math.max(0, this.stream.columns - str.replace(":bar", "").length);
if (availableSpace && process.platform === "win32") {
availableSpace -= 1;
}
const width = Math.min(this.width, availableSpace);
const completeLength = Math.round(width * ratio);
let complete = Array(Math.max(0, completeLength + 1)).join(this.chars.complete);
const incomplete = Array(Math.max(0, width - completeLength + 1)).join(this.chars.incomplete);
/* add head to the complete string */
if (completeLength > 0) {
complete = `${complete.slice(0, -1)}${this.chars.head}`;
}
/* fill in the actual progress bar */
str = str.replace(":bar", complete + incomplete);
/* replace the extra tokens */
if (this.tokens != null) {
for (const key of Object.keys(this.tokens)) {
str = str.replace(`:${key}`, this.tokens[key]);
}
}
if (this.lastDraw !== str) {
this.stream.cursorTo(0);
this.stream.write(str);
this.stream.clearLine(1);
this.lastDraw = str;
}
}
/**
* "update" the progress bar to represent an exact percentage.
* The ratio (between 0 and 1) specified will be multiplied by `total` and
* floored, representing the closest available "tick." For example, if a
* progress bar has a length of 3 and `update(0.5)` is called, the progress
* will be set to 1.
*
* A ratio of 0.5 will attempt to set the progress to halfway.
*/
update(ratio) {
const goal = Math.floor(ratio * this.total);
const delta = goal - this.current;
this.tick(delta);
}
/**
* "interrupt" the progress bar and write a message above it.
*/
interrupt(message) {
// clear the current line
const stream = this.stream;
stream.clearLine();
// move the cursor to the start of the line
stream.cursorTo(0);
// write the message text
stream.write(message);
// terminate the line after writing the message
stream.write("\n");
// re-display the progress bar with its lastDraw
stream.write(this.lastDraw);
}
}
exports.ProgressBar = ProgressBar;
class ProgressCallback {
constructor(progressBar) {
this.progressBar = progressBar;
this.start = Date.now();
this.nextUpdate = this.start + 1000;
}
update(transferred, total) {
const now = Date.now();
if (now >= this.nextUpdate || transferred >= total) {
this.nextUpdate = now + 1000;
this.progressBar.total = total;
this.progressBar.currentAmount = transferred;
}
}
}
exports.ProgressCallback = ProgressCallback;
//# sourceMappingURL=progress.js.map

1
mc_test/node_modules/electron-publish/out/progress.js.map generated vendored Executable file

File diff suppressed because one or more lines are too long

43
mc_test/node_modules/electron-publish/out/publisher.d.ts generated vendored Executable file
View File

@ -0,0 +1,43 @@
/// <reference types="node" />
/// <reference types="node" />
/// <reference types="node" />
/// <reference types="node" />
import { Arch } from "builder-util";
import { CancellationToken, PublishProvider } from "builder-util-runtime";
import { Stats } from "fs-extra";
import { ClientRequest } from "http";
import { MultiProgress } from "./multiProgress";
import { ProgressBar } from "./progress";
export type PublishPolicy = "onTag" | "onTagOrDraft" | "always" | "never";
export { ProgressCallback } from "./progress";
export interface PublishOptions {
publish?: PublishPolicy | null;
}
export interface PublishContext {
readonly cancellationToken: CancellationToken;
readonly progress: MultiProgress | null;
}
export interface UploadTask {
file: string;
fileContent?: Buffer | null;
arch: Arch | null;
safeArtifactName?: string | null;
timeout?: number | null;
}
export declare abstract class Publisher {
protected readonly context: PublishContext;
protected constructor(context: PublishContext);
abstract get providerName(): PublishProvider;
abstract upload(task: UploadTask): Promise<any>;
protected createProgressBar(fileName: string, size: number): ProgressBar | null;
protected createReadStreamAndProgressBar(file: string, fileStat: Stats, progressBar: ProgressBar | null, reject: (error: Error) => void): NodeJS.ReadableStream;
abstract toString(): string;
}
export declare abstract class HttpPublisher extends Publisher {
protected readonly context: PublishContext;
private readonly useSafeArtifactName;
protected constructor(context: PublishContext, useSafeArtifactName?: boolean);
upload(task: UploadTask): Promise<any>;
protected abstract doUpload(fileName: string, arch: Arch, dataLength: number, requestProcessor: (request: ClientRequest, reject: (error: Error) => void) => void, file: string): Promise<any>;
}
export declare function getCiTag(): string | null;

94
mc_test/node_modules/electron-publish/out/publisher.js generated vendored Executable file
View File

@ -0,0 +1,94 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.getCiTag = exports.HttpPublisher = exports.Publisher = exports.ProgressCallback = void 0;
const builder_util_1 = require("builder-util");
const builder_util_runtime_1 = require("builder-util-runtime");
const log_1 = require("builder-util/out/log");
const chalk = require("chalk");
const fs_extra_1 = require("fs-extra");
const path_1 = require("path");
var progress_1 = require("./progress");
Object.defineProperty(exports, "ProgressCallback", { enumerable: true, get: function () { return progress_1.ProgressCallback; } });
const progressBarOptions = {
incomplete: " ",
width: 20,
};
class Publisher {
constructor(context) {
this.context = context;
}
createProgressBar(fileName, size) {
builder_util_1.log.info({ file: fileName, provider: this.providerName }, "uploading");
if (this.context.progress == null || size < 512 * 1024) {
return null;
}
return this.context.progress.createBar(`${" ".repeat(log_1.PADDING + 2)}[:bar] :percent :etas | ${chalk.green(fileName)} to ${this.providerName}`, {
total: size,
...progressBarOptions,
});
}
createReadStreamAndProgressBar(file, fileStat, progressBar, reject) {
const fileInputStream = (0, fs_extra_1.createReadStream)(file);
fileInputStream.on("error", reject);
if (progressBar == null) {
return fileInputStream;
}
else {
const progressStream = new builder_util_runtime_1.ProgressCallbackTransform(fileStat.size, this.context.cancellationToken, it => progressBar.tick(it.delta));
progressStream.on("error", reject);
return fileInputStream.pipe(progressStream);
}
}
}
exports.Publisher = Publisher;
class HttpPublisher extends Publisher {
constructor(context, useSafeArtifactName = false) {
super(context);
this.context = context;
this.useSafeArtifactName = useSafeArtifactName;
}
async upload(task) {
const fileName = (this.useSafeArtifactName ? task.safeArtifactName : null) || (0, path_1.basename)(task.file);
if (task.fileContent != null) {
await this.doUpload(fileName, task.arch || builder_util_1.Arch.x64, task.fileContent.length, (request, reject) => {
if (task.timeout) {
request.setTimeout(task.timeout, () => {
request.destroy();
reject(new Error("Request timed out"));
});
}
return request.end(task.fileContent);
}, task.file);
return;
}
const fileStat = await (0, fs_extra_1.stat)(task.file);
const progressBar = this.createProgressBar(fileName, fileStat.size);
return this.doUpload(fileName, task.arch || builder_util_1.Arch.x64, fileStat.size, (request, reject) => {
if (progressBar != null) {
// reset (because can be called several times (several attempts)
progressBar.update(0);
}
if (task.timeout) {
request.setTimeout(task.timeout, () => {
request.destroy();
reject(new Error("Request timed out"));
});
}
return this.createReadStreamAndProgressBar(task.file, fileStat, progressBar, reject).pipe(request);
}, task.file);
}
}
exports.HttpPublisher = HttpPublisher;
function getCiTag() {
const tag = process.env.TRAVIS_TAG ||
process.env.APPVEYOR_REPO_TAG_NAME ||
process.env.CIRCLE_TAG ||
process.env.BITRISE_GIT_TAG ||
process.env.CI_BUILD_TAG || // deprecated, GitLab uses `CI_COMMIT_TAG` instead
process.env.CI_COMMIT_TAG ||
process.env.BITBUCKET_TAG ||
(process.env.GITHUB_REF_TYPE === "tag" ? process.env.GITHUB_REF_NAME : null);
return tag != null && tag.length > 0 ? tag : null;
}
exports.getCiTag = getCiTag;
//# sourceMappingURL=publisher.js.map

1
mc_test/node_modules/electron-publish/out/publisher.js.map generated vendored Executable file

File diff suppressed because one or more lines are too long