main funcions fixes

This commit is contained in:
2025-09-29 22:06:11 +09:00
parent 40e016e128
commit c8c3274527
7995 changed files with 1517998 additions and 1057 deletions

View File

@@ -0,0 +1,16 @@
import { Arch } from "builder-util";
import { ClientRequest } from "http";
import { HttpPublisher, PublishContext } from "electron-publish";
import { BitbucketOptions } from "builder-util-runtime/out/publishOptions";
export declare class BitbucketPublisher extends HttpPublisher {
readonly providerName = "bitbucket";
readonly hostname = "api.bitbucket.org";
private readonly info;
private readonly auth;
private readonly basePath;
constructor(context: PublishContext, info: BitbucketOptions);
protected doUpload(fileName: string, _arch: Arch, _dataLength: number, _requestProcessor: (request: ClientRequest, reject: (error: Error) => void) => void, file: string): Promise<any>;
deleteRelease(filename: string): Promise<void>;
toString(): string;
static convertAppPassword(username: string, token: string): string;
}

View File

@@ -0,0 +1,60 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.BitbucketPublisher = void 0;
const builder_util_1 = require("builder-util");
const builder_util_2 = require("builder-util");
const electron_publish_1 = require("electron-publish");
const builder_util_runtime_1 = require("builder-util-runtime");
const FormData = require("form-data");
const fs_extra_1 = require("fs-extra");
class BitbucketPublisher extends electron_publish_1.HttpPublisher {
constructor(context, info) {
super(context);
this.providerName = "bitbucket";
this.hostname = "api.bitbucket.org";
const token = info.token || process.env.BITBUCKET_TOKEN || null;
const username = info.username || process.env.BITBUCKET_USERNAME || null;
if ((0, builder_util_1.isEmptyOrSpaces)(token)) {
throw new builder_util_1.InvalidConfigurationError(`Bitbucket token is not set using env "BITBUCKET_TOKEN" (see https://www.electron.build/publish#BitbucketOptions)`);
}
if ((0, builder_util_1.isEmptyOrSpaces)(username)) {
builder_util_1.log.warn('No Bitbucket username provided via "BITBUCKET_USERNAME". Defaulting to use repo owner.');
}
this.info = info;
this.auth = BitbucketPublisher.convertAppPassword(username !== null && username !== void 0 ? username : this.info.owner, token);
this.basePath = `/2.0/repositories/${this.info.owner}/${this.info.slug}/downloads`;
}
doUpload(fileName, _arch, _dataLength, _requestProcessor, file) {
return builder_util_runtime_1.HttpExecutor.retryOnServerError(async () => {
const fileContent = await (0, fs_extra_1.readFile)(file);
const form = new FormData();
form.append("files", fileContent, fileName);
const upload = {
hostname: this.hostname,
path: this.basePath,
headers: form.getHeaders(),
timeout: this.info.timeout || undefined,
};
await builder_util_2.httpExecutor.doApiRequest((0, builder_util_runtime_1.configureRequestOptions)(upload, this.auth, "POST"), this.context.cancellationToken, it => form.pipe(it));
return fileName;
});
}
async deleteRelease(filename) {
const req = {
hostname: this.hostname,
path: `${this.basePath}/${filename}`,
timeout: this.info.timeout || undefined,
};
await builder_util_2.httpExecutor.request((0, builder_util_runtime_1.configureRequestOptions)(req, this.auth, "DELETE"), this.context.cancellationToken);
}
toString() {
const { owner, slug, channel } = this.info;
return `Bitbucket (owner: ${owner}, slug: ${slug}, channel: ${channel})`;
}
static convertAppPassword(username, token) {
const base64encodedData = Buffer.from(`${username}:${token.trim()}`).toString("base64");
return `Basic ${base64encodedData}`;
}
}
exports.BitbucketPublisher = BitbucketPublisher;
//# sourceMappingURL=BitbucketPublisher.js.map

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,101 @@
import { Arch } from "builder-util";
import { ClientRequest } from "http";
import { HttpPublisher, PublishContext } from "electron-publish";
import { KeygenOptions } from "builder-util-runtime/out/publishOptions";
export interface KeygenError {
title: string;
detail: string;
code: string;
}
export interface KeygenRelease {
id: string;
type: "releases";
attributes: {
name: string | null;
description: string | null;
channel: "stable" | "rc" | "beta" | "alpha" | "dev";
status: "DRAFT" | "PUBLISHED" | "YANKED";
tag: string;
version: string;
semver: {
major: number;
minor: number;
patch: number;
prerelease: string | null;
build: string | null;
};
metadata: {
[s: string]: any;
};
created: string;
updated: string;
yanked: string | null;
};
relationships: {
account: {
data: {
type: "accounts";
id: string;
};
};
product: {
data: {
type: "products";
id: string;
};
};
};
}
export interface KeygenArtifact {
id: string;
type: "artifacts";
attributes: {
filename: string;
filetype: string | null;
filesize: number | null;
platform: string | null;
arch: string | null;
signature: string | null;
checksum: string | null;
status: "WAITING" | "UPLOADED" | "FAILED" | "YANKED";
metadata: {
[s: string]: any;
};
created: string;
updated: string;
};
relationships: {
account: {
data: {
type: "accounts";
id: string;
};
};
release: {
data: {
type: "releases";
id: string;
};
};
};
links: {
redirect: string;
};
}
export declare class KeygenPublisher extends HttpPublisher {
readonly providerName = "keygen";
readonly hostname = "api.keygen.sh";
private readonly info;
private readonly auth;
private readonly version;
private readonly basePath;
constructor(context: PublishContext, info: KeygenOptions, version: string);
protected doUpload(fileName: string, _arch: Arch, dataLength: number, requestProcessor: (request: ClientRequest, reject: (error: Error) => void) => void, _file: string): Promise<string>;
private uploadArtifact;
private createArtifact;
private getOrCreateRelease;
private getRelease;
private createRelease;
deleteRelease(releaseId: string): Promise<void>;
toString(): string;
}

View File

@@ -0,0 +1,165 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.KeygenPublisher = void 0;
const builder_util_1 = require("builder-util");
const builder_util_2 = require("builder-util");
const electron_publish_1 = require("electron-publish");
const builder_util_runtime_1 = require("builder-util-runtime");
const filename_1 = require("../util/filename");
class KeygenPublisher extends electron_publish_1.HttpPublisher {
constructor(context, info, version) {
super(context);
this.providerName = "keygen";
this.hostname = "api.keygen.sh";
const token = process.env.KEYGEN_TOKEN;
if ((0, builder_util_1.isEmptyOrSpaces)(token)) {
throw new builder_util_1.InvalidConfigurationError(`Keygen token is not set using env "KEYGEN_TOKEN" (see https://www.electron.build/publish#KeygenOptions)`);
}
this.info = info;
this.auth = `Bearer ${token.trim()}`;
this.version = version;
this.basePath = `/v1/accounts/${this.info.account}`;
}
doUpload(fileName, _arch, dataLength, requestProcessor, _file) {
return builder_util_runtime_1.HttpExecutor.retryOnServerError(async () => {
const { data, errors } = await this.getOrCreateRelease();
if (errors) {
throw new Error(`Keygen - Creating release returned errors: ${JSON.stringify(errors)}`);
}
await this.uploadArtifact(data.id, fileName, dataLength, requestProcessor);
return data.id;
});
}
async uploadArtifact(releaseId, fileName, dataLength, requestProcessor) {
const { data, errors } = await this.createArtifact(releaseId, fileName, dataLength);
if (errors) {
throw new Error(`Keygen - Creating artifact returned errors: ${JSON.stringify(errors)}`);
}
// Follow the redirect and upload directly to S3-equivalent storage provider
const url = new URL(data.links.redirect);
const upload = {
hostname: url.hostname,
path: url.pathname + url.search,
headers: {
"Content-Length": dataLength,
},
timeout: this.info.timeout || undefined,
};
await builder_util_2.httpExecutor.doApiRequest((0, builder_util_runtime_1.configureRequestOptions)(upload, null, "PUT"), this.context.cancellationToken, requestProcessor);
}
async createArtifact(releaseId, fileName, dataLength) {
const upload = {
hostname: this.hostname,
path: `${this.basePath}/artifacts`,
headers: {
"Content-Type": "application/vnd.api+json",
Accept: "application/vnd.api+json",
"Keygen-Version": "1.1",
Prefer: "no-redirect",
},
timeout: this.info.timeout || undefined,
};
const data = {
type: "artifacts",
attributes: {
filename: fileName,
filetype: (0, filename_1.getCompleteExtname)(fileName),
filesize: dataLength,
platform: this.info.platform,
},
relationships: {
release: {
data: {
type: "releases",
id: releaseId,
},
},
},
};
builder_util_1.log.debug({ data: JSON.stringify(data) }, "Keygen create artifact");
return (0, builder_util_runtime_1.parseJson)(builder_util_2.httpExecutor.request((0, builder_util_runtime_1.configureRequestOptions)(upload, this.auth, "POST"), this.context.cancellationToken, { data }));
}
async getOrCreateRelease() {
try {
// First, we'll attempt to fetch the release.
return await this.getRelease();
}
catch (e) {
if (e.statusCode !== 404) {
throw e;
}
try {
// Next, if the release doesn't exist, we'll attempt to create it.
return await this.createRelease();
}
catch (e) {
if (e.statusCode !== 409 && e.statusCode !== 422) {
throw e;
}
// Lastly, when a conflict occurs (in the case of parallel uploads),
// we'll try to fetch it one last time.
return this.getRelease();
}
}
}
async getRelease() {
const req = {
hostname: this.hostname,
path: `${this.basePath}/releases/${this.version}?product=${this.info.product}`,
headers: {
Accept: "application/vnd.api+json",
"Keygen-Version": "1.1",
},
timeout: this.info.timeout || undefined,
};
return (0, builder_util_runtime_1.parseJson)(builder_util_2.httpExecutor.request((0, builder_util_runtime_1.configureRequestOptions)(req, this.auth, "GET"), this.context.cancellationToken, null));
}
async createRelease() {
const req = {
hostname: this.hostname,
path: `${this.basePath}/releases`,
headers: {
"Content-Type": "application/vnd.api+json",
Accept: "application/vnd.api+json",
"Keygen-Version": "1.1",
},
timeout: this.info.timeout || undefined,
};
const data = {
type: "releases",
attributes: {
version: this.version,
channel: this.info.channel || "stable",
status: "PUBLISHED",
},
relationships: {
product: {
data: {
type: "products",
id: this.info.product,
},
},
},
};
builder_util_1.log.debug({ data: JSON.stringify(data) }, "Keygen create release");
return (0, builder_util_runtime_1.parseJson)(builder_util_2.httpExecutor.request((0, builder_util_runtime_1.configureRequestOptions)(req, this.auth, "POST"), this.context.cancellationToken, { data }));
}
async deleteRelease(releaseId) {
const req = {
hostname: this.hostname,
path: `${this.basePath}/releases/${releaseId}`,
headers: {
Accept: "application/vnd.api+json",
"Keygen-Version": "1.1",
},
timeout: this.info.timeout || undefined,
};
await builder_util_2.httpExecutor.request((0, builder_util_runtime_1.configureRequestOptions)(req, this.auth, "DELETE"), this.context.cancellationToken);
}
toString() {
const { account, product, platform } = this.info;
return `Keygen (account: ${account}, product: ${product}, platform: ${platform}, version: ${this.version})`;
}
}
exports.KeygenPublisher = KeygenPublisher;
//# sourceMappingURL=KeygenPublisher.js.map

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,37 @@
import { Arch } from "builder-util";
import { CancellationToken, PublishConfiguration, PublishProvider } from "builder-util-runtime";
import { PublishContext, Publisher, PublishOptions, UploadTask } from "electron-publish";
import { MultiProgress } from "electron-publish/out/multiProgress";
import { AppInfo, PlatformSpecificBuildOptions } from "../index";
import { Packager } from "../packager";
import { PlatformPackager } from "../platformPackager";
export declare class PublishManager implements PublishContext {
private readonly packager;
private readonly publishOptions;
readonly cancellationToken: CancellationToken;
private readonly nameToPublisher;
private readonly taskManager;
readonly isPublish: boolean;
readonly progress: MultiProgress | null;
private readonly updateFileWriteTask;
constructor(packager: Packager, publishOptions: PublishOptions, cancellationToken?: CancellationToken);
private getAppInfo;
getGlobalPublishConfigurations(): Promise<Array<PublishConfiguration> | null>;
scheduleUpload(publishConfig: PublishConfiguration, event: UploadTask, appInfo: AppInfo): void;
private artifactCreatedWithoutExplicitPublishConfig;
private getOrCreatePublisher;
cancelTasks(): void;
awaitTasks(): Promise<void>;
}
export declare function getAppUpdatePublishConfiguration(packager: PlatformPackager<any>, arch: Arch, errorIfCannot: boolean): Promise<{
updaterCacheDirName: string;
provider: PublishProvider;
publisherName?: Array<string> | null;
publishAutoUpdate?: boolean;
requestHeaders?: import("http").OutgoingHttpHeaders;
timeout?: number | null;
} | null>;
export declare function getPublishConfigsForUpdateInfo(packager: PlatformPackager<any>, publishConfigs: Array<PublishConfiguration> | null, arch: Arch | null): Promise<Array<PublishConfiguration> | null>;
export declare function createPublisher(context: PublishContext, version: string, publishConfig: PublishConfiguration, options: PublishOptions, packager: Packager): Publisher | null;
export declare function computeDownloadUrl(publishConfiguration: PublishConfiguration, fileName: string | null, packager: PlatformPackager<any>): string;
export declare function getPublishConfigs(platformPackager: PlatformPackager<any>, targetSpecificOptions: PlatformSpecificBuildOptions | null | undefined, arch: Arch | null, errorIfCannot: boolean): Promise<Array<PublishConfiguration> | null>;

View File

@@ -0,0 +1,466 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.PublishManager = void 0;
exports.getAppUpdatePublishConfiguration = getAppUpdatePublishConfiguration;
exports.getPublishConfigsForUpdateInfo = getPublishConfigsForUpdateInfo;
exports.createPublisher = createPublisher;
exports.computeDownloadUrl = computeDownloadUrl;
exports.getPublishConfigs = getPublishConfigs;
const bluebird_lst_1 = require("bluebird-lst");
const builder_util_1 = require("builder-util");
const builder_util_runtime_1 = require("builder-util-runtime");
const debug_1 = require("debug");
const electron_publish_1 = require("electron-publish");
const gitHubPublisher_1 = require("electron-publish/out/gitHubPublisher");
const multiProgress_1 = require("electron-publish/out/multiProgress");
const s3Publisher_1 = require("./s3/s3Publisher");
const spacesPublisher_1 = require("./s3/spacesPublisher");
const promises_1 = require("fs/promises");
const isCi = require("is-ci");
const path = require("path");
const url = require("url");
const index_1 = require("../index");
const macroExpander_1 = require("../util/macroExpander");
const SnapStorePublisher_1 = require("./SnapStorePublisher");
const updateInfoBuilder_1 = require("./updateInfoBuilder");
const KeygenPublisher_1 = require("./KeygenPublisher");
const BitbucketPublisher_1 = require("./BitbucketPublisher");
const publishForPrWarning = "There are serious security concerns with PUBLISH_FOR_PULL_REQUEST=true (see the CircleCI documentation (https://circleci.com/docs/1.0/fork-pr-builds/) for details)" +
"\nIf you have SSH keys, sensitive env vars or AWS credentials stored in your project settings and untrusted forks can make pull requests against your repo, then this option isn't for you.";
const debug = (0, debug_1.default)("electron-builder:publish");
function checkOptions(publishPolicy) {
if (publishPolicy != null && publishPolicy !== "onTag" && publishPolicy !== "onTagOrDraft" && publishPolicy !== "always" && publishPolicy !== "never") {
if (typeof publishPolicy === "string") {
throw new builder_util_1.InvalidConfigurationError(`Expected one of "onTag", "onTagOrDraft", "always", "never", but got ${JSON.stringify(publishPolicy)}.\nPlease note that publish configuration should be specified under "config"`);
}
}
}
class PublishManager {
constructor(packager, publishOptions, cancellationToken = packager.cancellationToken) {
this.packager = packager;
this.publishOptions = publishOptions;
this.cancellationToken = cancellationToken;
this.nameToPublisher = new Map();
this.isPublish = false;
this.progress = process.stdout.isTTY ? new multiProgress_1.MultiProgress() : null;
this.updateFileWriteTask = [];
checkOptions(publishOptions.publish);
this.taskManager = new builder_util_1.AsyncTaskManager(cancellationToken);
const forcePublishForPr = process.env.PUBLISH_FOR_PULL_REQUEST === "true";
if (!(0, builder_util_1.isPullRequest)() || forcePublishForPr) {
if (publishOptions.publish === undefined) {
if (process.env.npm_lifecycle_event === "release") {
publishOptions.publish = "always";
}
else {
const tag = (0, electron_publish_1.getCiTag)();
if (tag != null) {
builder_util_1.log.info({ reason: "tag is defined", tag }, "artifacts will be published");
publishOptions.publish = "onTag";
}
else if (isCi) {
builder_util_1.log.info({ reason: "CI detected" }, "artifacts will be published if draft release exists");
publishOptions.publish = "onTagOrDraft";
}
}
}
const publishPolicy = publishOptions.publish;
this.isPublish = publishPolicy != null && publishOptions.publish !== "never" && (publishPolicy !== "onTag" || (0, electron_publish_1.getCiTag)() != null);
if (this.isPublish && forcePublishForPr) {
builder_util_1.log.warn(publishForPrWarning);
}
}
else if (publishOptions.publish !== "never") {
builder_util_1.log.info({
reason: "current build is a part of pull request",
solution: `set env PUBLISH_FOR_PULL_REQUEST to true to force code signing\n${publishForPrWarning}`,
}, "publishing will be skipped");
}
packager.addAfterPackHandler(async (event) => {
const packager = event.packager;
if (event.electronPlatformName === "darwin") {
if (!event.targets.some(it => it.name === "dmg" || it.name === "zip")) {
return;
}
}
else if (packager.platform === index_1.Platform.WINDOWS) {
if (!event.targets.some(it => isSuitableWindowsTarget(it))) {
return;
}
}
const publishConfig = await getAppUpdatePublishConfiguration(packager, event.arch, this.isPublish);
if (publishConfig != null) {
await (0, promises_1.writeFile)(path.join(packager.getResourcesDir(event.appOutDir), "app-update.yml"), (0, builder_util_1.serializeToYaml)(publishConfig));
}
});
packager.artifactCreated(event => {
const publishConfiguration = event.publishConfig;
if (publishConfiguration == null) {
this.taskManager.addTask(this.artifactCreatedWithoutExplicitPublishConfig(event));
}
else if (this.isPublish) {
if (debug.enabled) {
debug(`artifactCreated (isPublish: ${this.isPublish}): ${(0, builder_util_1.safeStringifyJson)(event, new Set(["packager"]))},\n publishConfig: ${(0, builder_util_1.safeStringifyJson)(publishConfiguration)}`);
}
this.scheduleUpload(publishConfiguration, event, this.getAppInfo(event.packager));
}
});
}
getAppInfo(platformPackager) {
return platformPackager == null ? this.packager.appInfo : platformPackager.appInfo;
}
async getGlobalPublishConfigurations() {
const publishers = this.packager.config.publish;
return await resolvePublishConfigurations(publishers, null, this.packager, null, true);
}
scheduleUpload(publishConfig, event, appInfo) {
if (publishConfig.provider === "generic") {
return;
}
const publisher = this.getOrCreatePublisher(publishConfig, appInfo);
if (publisher == null) {
builder_util_1.log.debug({
file: builder_util_1.log.filePath(event.file),
reason: "publisher is null",
publishConfig: (0, builder_util_1.safeStringifyJson)(publishConfig),
}, "not published");
return;
}
const providerName = publisher.providerName;
if (this.publishOptions.publish === "onTagOrDraft" && (0, electron_publish_1.getCiTag)() == null && providerName !== "bitbucket" && providerName !== "github") {
builder_util_1.log.info({ file: builder_util_1.log.filePath(event.file), reason: "current build is not for a git tag", publishPolicy: "onTagOrDraft" }, `not published to ${providerName}`);
return;
}
if (publishConfig.timeout) {
event.timeout = publishConfig.timeout;
}
this.taskManager.addTask(publisher.upload(event));
}
async artifactCreatedWithoutExplicitPublishConfig(event) {
const platformPackager = event.packager;
const target = event.target;
const publishConfigs = await getPublishConfigs(platformPackager, target == null ? null : target.options, event.arch, this.isPublish);
if (debug.enabled) {
debug(`artifactCreated (isPublish: ${this.isPublish}): ${(0, builder_util_1.safeStringifyJson)(event, new Set(["packager"]))},\n publishConfigs: ${(0, builder_util_1.safeStringifyJson)(publishConfigs)}`);
}
const eventFile = event.file;
if (publishConfigs == null) {
if (this.isPublish) {
builder_util_1.log.debug({ file: eventFile, reason: "no publish configs" }, "not published");
}
return;
}
if (this.isPublish) {
for (const publishConfig of publishConfigs) {
if (this.cancellationToken.cancelled) {
builder_util_1.log.debug({ file: event.file, reason: "cancelled" }, "not published");
break;
}
this.scheduleUpload(publishConfig, event, this.getAppInfo(platformPackager));
}
}
if (event.isWriteUpdateInfo &&
target != null &&
eventFile != null &&
!this.cancellationToken.cancelled &&
(platformPackager.platform !== index_1.Platform.WINDOWS || isSuitableWindowsTarget(target))) {
this.taskManager.addTask((0, updateInfoBuilder_1.createUpdateInfoTasks)(event, publishConfigs).then(it => this.updateFileWriteTask.push(...it)));
}
}
getOrCreatePublisher(publishConfig, appInfo) {
// to not include token into cache key
const providerCacheKey = (0, builder_util_1.safeStringifyJson)(publishConfig);
let publisher = this.nameToPublisher.get(providerCacheKey);
if (publisher == null) {
publisher = createPublisher(this, appInfo.version, publishConfig, this.publishOptions, this.packager);
this.nameToPublisher.set(providerCacheKey, publisher);
builder_util_1.log.info({ publisher: publisher.toString() }, "publishing");
}
return publisher;
}
// noinspection JSUnusedGlobalSymbols
cancelTasks() {
this.taskManager.cancelTasks();
this.nameToPublisher.clear();
}
async awaitTasks() {
await this.taskManager.awaitTasks();
const updateInfoFileTasks = this.updateFileWriteTask;
if (this.cancellationToken.cancelled || updateInfoFileTasks.length === 0) {
return;
}
await (0, updateInfoBuilder_1.writeUpdateInfoFiles)(updateInfoFileTasks, this.packager);
await this.taskManager.awaitTasks();
}
}
exports.PublishManager = PublishManager;
async function getAppUpdatePublishConfiguration(packager, arch, errorIfCannot) {
const publishConfigs = await getPublishConfigsForUpdateInfo(packager, await getPublishConfigs(packager, null, arch, errorIfCannot), arch);
if (publishConfigs == null || publishConfigs.length === 0) {
return null;
}
const publishConfig = {
...publishConfigs[0],
updaterCacheDirName: packager.appInfo.updaterCacheDirName,
};
if (packager.platform === index_1.Platform.WINDOWS && publishConfig.publisherName == null) {
const winPackager = packager;
const publisherName = winPackager.isForceCodeSigningVerification ? await (await winPackager.signtoolManager.value).computedPublisherName.value : undefined;
if (publisherName != null) {
publishConfig.publisherName = publisherName;
}
}
return publishConfig;
}
async function getPublishConfigsForUpdateInfo(packager, publishConfigs, arch) {
if (publishConfigs === null) {
return null;
}
if (publishConfigs.length === 0) {
builder_util_1.log.debug(null, "getPublishConfigsForUpdateInfo: no publishConfigs, detect using repository info");
// https://github.com/electron-userland/electron-builder/issues/925#issuecomment-261732378
// default publish config is github, file should be generated regardless of publish state (user can test installer locally or manage the release process manually)
const repositoryInfo = await packager.info.repositoryInfo;
debug(`getPublishConfigsForUpdateInfo: ${(0, builder_util_1.safeStringifyJson)(repositoryInfo)}`);
if (repositoryInfo != null && repositoryInfo.type === "github") {
const resolvedPublishConfig = await getResolvedPublishConfig(packager, packager.info, { provider: repositoryInfo.type }, arch, false);
if (resolvedPublishConfig != null) {
debug(`getPublishConfigsForUpdateInfo: resolve to publish config ${(0, builder_util_1.safeStringifyJson)(resolvedPublishConfig)}`);
return [resolvedPublishConfig];
}
}
}
return publishConfigs;
}
function createPublisher(context, version, publishConfig, options, packager) {
if (debug.enabled) {
debug(`Create publisher: ${(0, builder_util_1.safeStringifyJson)(publishConfig)}`);
}
const provider = publishConfig.provider;
switch (provider) {
case "github":
return new gitHubPublisher_1.GitHubPublisher(context, publishConfig, version, options);
case "keygen":
return new KeygenPublisher_1.KeygenPublisher(context, publishConfig, version);
case "snapStore":
return new SnapStorePublisher_1.SnapStorePublisher(context, publishConfig);
case "generic":
return null;
default: {
const clazz = requireProviderClass(provider, packager);
return clazz == null ? null : new clazz(context, publishConfig);
}
}
}
function requireProviderClass(provider, packager) {
switch (provider) {
case "github":
return gitHubPublisher_1.GitHubPublisher;
case "generic":
return null;
case "keygen":
return KeygenPublisher_1.KeygenPublisher;
case "s3":
return s3Publisher_1.default;
case "snapStore":
return SnapStorePublisher_1.SnapStorePublisher;
case "spaces":
return spacesPublisher_1.default;
case "bitbucket":
return BitbucketPublisher_1.BitbucketPublisher;
default: {
const name = `electron-publisher-${provider}`;
let module = null;
try {
module = require(path.join(packager.buildResourcesDir, name + ".js"));
}
catch (_ignored) {
builder_util_1.log.debug({ path: path.join(packager.buildResourcesDir, name + ".js") }, "Unable to find publish provider in build resources");
}
if (module == null) {
module = require(name);
}
return module.default || module;
}
}
}
function computeDownloadUrl(publishConfiguration, fileName, packager) {
if (publishConfiguration.provider === "generic") {
const baseUrlString = publishConfiguration.url;
if (fileName == null) {
return baseUrlString;
}
const baseUrl = url.parse(baseUrlString);
return url.format({ ...baseUrl, pathname: path.posix.resolve(baseUrl.pathname || "/", encodeURI(fileName)) });
}
let baseUrl;
if (publishConfiguration.provider === "github") {
const gh = publishConfiguration;
baseUrl = `${(0, builder_util_runtime_1.githubUrl)(gh)}/${gh.owner}/${gh.repo}/releases/download/${gh.vPrefixedTagName === false ? "" : "v"}${packager.appInfo.version}`;
}
else {
baseUrl = (0, builder_util_runtime_1.getS3LikeProviderBaseUrl)(publishConfiguration);
}
if (fileName == null) {
return baseUrl;
}
return `${baseUrl}/${encodeURI(fileName)}`;
}
async function getPublishConfigs(platformPackager, targetSpecificOptions, arch, errorIfCannot) {
let publishers;
// check build.nsis (target)
if (targetSpecificOptions != null) {
publishers = targetSpecificOptions.publish;
// if explicitly set to null - do not publish
if (publishers === null) {
return null;
}
}
// check build.win (platform)
if (publishers == null) {
publishers = platformPackager.platformSpecificBuildOptions.publish;
if (publishers === null) {
return null;
}
}
if (publishers == null) {
publishers = platformPackager.config.publish;
if (publishers === null) {
return null;
}
}
return await resolvePublishConfigurations(publishers, platformPackager, platformPackager.info, arch, errorIfCannot);
}
async function resolvePublishConfigurations(publishers, platformPackager, packager, arch, errorIfCannot) {
if (publishers == null) {
let serviceName = null;
if (!(0, builder_util_1.isEmptyOrSpaces)(process.env.GH_TOKEN) || !(0, builder_util_1.isEmptyOrSpaces)(process.env.GITHUB_TOKEN)) {
serviceName = "github";
}
else if (!(0, builder_util_1.isEmptyOrSpaces)(process.env.KEYGEN_TOKEN)) {
serviceName = "keygen";
}
else if (!(0, builder_util_1.isEmptyOrSpaces)(process.env.BITBUCKET_TOKEN)) {
serviceName = "bitbucket";
}
else if (!(0, builder_util_1.isEmptyOrSpaces)(process.env.BT_TOKEN)) {
throw new Error("Bintray has been sunset and is no longer supported by electron-builder. Ref: https://jfrog.com/blog/into-the-sunset-bintray-jcenter-gocenter-and-chartcenter/");
}
if (serviceName != null) {
builder_util_1.log.debug(null, `detect ${serviceName} as publish provider`);
return [(await getResolvedPublishConfig(platformPackager, packager, { provider: serviceName }, arch, errorIfCannot))];
}
}
if (publishers == null) {
return [];
}
debug(`Explicit publish provider: ${(0, builder_util_1.safeStringifyJson)(publishers)}`);
return await bluebird_lst_1.default.map((0, builder_util_1.asArray)(publishers), it => getResolvedPublishConfig(platformPackager, packager, typeof it === "string" ? { provider: it } : it, arch, errorIfCannot));
}
function isSuitableWindowsTarget(target) {
if (target.name === "appx" && target.options != null && target.options.electronUpdaterAware) {
return true;
}
return target.name === "nsis" || target.name.startsWith("nsis-");
}
function expandPublishConfig(options, platformPackager, packager, arch) {
for (const name of Object.keys(options)) {
const value = options[name];
if (typeof value === "string") {
const archValue = arch == null ? null : builder_util_1.Arch[arch];
const expanded = platformPackager == null ? (0, macroExpander_1.expandMacro)(value, archValue, packager.appInfo) : platformPackager.expandMacro(value, archValue);
if (expanded !== value) {
options[name] = expanded;
}
}
}
}
function isDetectUpdateChannel(platformSpecificConfiguration, configuration) {
const value = platformSpecificConfiguration == null ? null : platformSpecificConfiguration.detectUpdateChannel;
return value == null ? configuration.detectUpdateChannel !== false : value;
}
async function getResolvedPublishConfig(platformPackager, packager, options, arch, errorIfCannot) {
options = { ...options };
expandPublishConfig(options, platformPackager, packager, arch);
let channelFromAppVersion = null;
if (options.channel == null &&
isDetectUpdateChannel(platformPackager == null ? null : platformPackager.platformSpecificBuildOptions, packager.config)) {
channelFromAppVersion = packager.appInfo.channel;
}
const provider = options.provider;
if (provider === "generic") {
const o = options;
if (o.url == null) {
throw new builder_util_1.InvalidConfigurationError(`Please specify "url" for "generic" update server`);
}
if (channelFromAppVersion != null) {
;
o.channel = channelFromAppVersion;
}
return options;
}
const providerClass = requireProviderClass(options.provider, packager);
if (providerClass != null && providerClass.checkAndResolveOptions != null) {
await providerClass.checkAndResolveOptions(options, channelFromAppVersion, errorIfCannot);
return options;
}
if (provider === "keygen") {
return {
...options,
platform: platformPackager === null || platformPackager === void 0 ? void 0 : platformPackager.platform.name,
};
}
const isGithub = provider === "github";
if (!isGithub && provider !== "bitbucket") {
return options;
}
let owner = isGithub ? options.owner : options.owner;
let project = isGithub ? options.repo : options.slug;
if (isGithub && owner == null && project != null) {
const index = project.indexOf("/");
if (index > 0) {
const repo = project;
project = repo.substring(0, index);
owner = repo.substring(index + 1);
}
}
async function getInfo() {
const info = await packager.repositoryInfo;
if (info != null) {
return info;
}
const message = `Cannot detect repository by .git/config. Please specify "repository" in the package.json (https://docs.npmjs.com/files/package.json#repository).\nPlease see https://electron.build/publish`;
if (errorIfCannot) {
throw new Error(message);
}
else {
builder_util_1.log.warn(message);
return null;
}
}
if (!owner || !project) {
builder_util_1.log.debug({ reason: "owner or project is not specified explicitly", provider, owner, project }, "calling getInfo");
const info = await getInfo();
if (info == null) {
return null;
}
if (!owner) {
owner = info.user;
}
if (!project) {
project = info.project;
}
}
if (isGithub) {
if (options.token != null && !options.private) {
builder_util_1.log.warn('"token" specified in the github publish options. It should be used only for [setFeedURL](module:electron-updater/out/AppUpdater.AppUpdater+setFeedURL).');
}
//tslint:disable-next-line:no-object-literal-type-assertion
return { owner, repo: project, ...options };
}
else {
//tslint:disable-next-line:no-object-literal-type-assertion
return { owner, slug: project, ...options };
}
}
//# sourceMappingURL=PublishManager.js.map

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,9 @@
import { Publisher, UploadTask, PublishContext } from "electron-publish";
import { SnapStoreOptions } from "builder-util-runtime/out/publishOptions";
export declare class SnapStorePublisher extends Publisher {
private options;
readonly providerName = "snapStore";
constructor(context: PublishContext, options: SnapStoreOptions);
upload(task: UploadTask): Promise<any>;
toString(): string;
}

View File

@@ -0,0 +1,35 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.SnapStorePublisher = void 0;
const electron_publish_1 = require("electron-publish");
const builder_util_1 = require("builder-util");
const path = require("path");
class SnapStorePublisher extends electron_publish_1.Publisher {
constructor(context, options) {
super(context);
this.options = options;
this.providerName = "snapStore";
}
upload(task) {
this.createProgressBar(path.basename(task.file), -1);
const args = ["publish-snap", "-f", task.file];
let channels = this.options.channels;
if (channels == null) {
channels = ["edge"];
}
else {
if (typeof channels === "string") {
channels = channels.split(",");
}
}
for (const channel of channels) {
args.push("-c", channel);
}
return (0, builder_util_1.executeAppBuilder)(args);
}
toString() {
return "Snap Store";
}
}
exports.SnapStorePublisher = SnapStorePublisher;
//# sourceMappingURL=SnapStorePublisher.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"SnapStorePublisher.js","sourceRoot":"","sources":["../../src/publish/SnapStorePublisher.ts"],"names":[],"mappings":";;;AAAA,uDAAwE;AACxE,+CAAgD;AAChD,6BAA4B;AAG5B,MAAa,kBAAmB,SAAQ,4BAAS;IAG/C,YACE,OAAuB,EACf,OAAyB;QAEjC,KAAK,CAAC,OAAO,CAAC,CAAA;QAFN,YAAO,GAAP,OAAO,CAAkB;QAJ1B,iBAAY,GAAG,WAAW,CAAA;IAOnC,CAAC;IAED,MAAM,CAAC,IAAgB;QACrB,IAAI,CAAC,iBAAiB,CAAC,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC,CAAC,CAAA;QAEpD,MAAM,IAAI,GAAG,CAAC,cAAc,EAAE,IAAI,EAAE,IAAI,CAAC,IAAI,CAAC,CAAA;QAE9C,IAAI,QAAQ,GAAG,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAA;QACpC,IAAI,QAAQ,IAAI,IAAI,EAAE,CAAC;YACrB,QAAQ,GAAG,CAAC,MAAM,CAAC,CAAA;QACrB,CAAC;aAAM,CAAC;YACN,IAAI,OAAO,QAAQ,KAAK,QAAQ,EAAE,CAAC;gBACjC,QAAQ,GAAG,QAAQ,CAAC,KAAK,CAAC,GAAG,CAAC,CAAA;YAChC,CAAC;QACH,CAAC;QAED,KAAK,MAAM,OAAO,IAAI,QAAQ,EAAE,CAAC;YAC/B,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE,OAAO,CAAC,CAAA;QAC1B,CAAC;QAED,OAAO,IAAA,gCAAiB,EAAC,IAAI,CAAC,CAAA;IAChC,CAAC;IAED,QAAQ;QACN,OAAO,YAAY,CAAA;IACrB,CAAC;CACF;AAlCD,gDAkCC","sourcesContent":["import { Publisher, UploadTask, PublishContext } from \"electron-publish\"\nimport { executeAppBuilder } from \"builder-util\"\nimport * as path from \"path\"\nimport { SnapStoreOptions } from \"builder-util-runtime/out/publishOptions\"\n\nexport class SnapStorePublisher extends Publisher {\n readonly providerName = \"snapStore\"\n\n constructor(\n context: PublishContext,\n private options: SnapStoreOptions\n ) {\n super(context)\n }\n\n upload(task: UploadTask): Promise<any> {\n this.createProgressBar(path.basename(task.file), -1)\n\n const args = [\"publish-snap\", \"-f\", task.file]\n\n let channels = this.options.channels\n if (channels == null) {\n channels = [\"edge\"]\n } else {\n if (typeof channels === \"string\") {\n channels = channels.split(\",\")\n }\n }\n\n for (const channel of channels) {\n args.push(\"-c\", channel)\n }\n\n return executeAppBuilder(args)\n }\n\n toString(): string {\n return \"Snap Store\"\n }\n}\n"]}

View File

@@ -0,0 +1,10 @@
import { BaseS3Options } from "builder-util-runtime";
import { PublishContext, Publisher, UploadTask } from "electron-publish";
export declare abstract class BaseS3Publisher extends Publisher {
private options;
protected constructor(context: PublishContext, options: BaseS3Options);
protected abstract getBucketName(): string;
protected configureS3Options(args: Array<string>): void;
upload(task: UploadTask): Promise<any>;
toString(): string;
}

View File

@@ -0,0 +1,64 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.BaseS3Publisher = void 0;
const builder_util_1 = require("builder-util");
const electron_publish_1 = require("electron-publish");
const promises_1 = require("fs/promises");
const path = require("path");
class BaseS3Publisher extends electron_publish_1.Publisher {
constructor(context, options) {
super(context);
this.options = options;
}
configureS3Options(args) {
// if explicitly set to null, do not add
if (this.options.acl !== null) {
args.push("--acl", this.options.acl || "public-read");
}
}
// http://docs.aws.amazon.com/sdk-for-javascript/v2/developer-guide/s3-example-creating-buckets.html
async upload(task) {
const fileName = path.basename(task.file);
const cancellationToken = this.context.cancellationToken;
const target = (this.options.path == null ? "" : `${this.options.path}/`) + fileName;
const args = ["publish-s3", "--bucket", this.getBucketName(), "--key", target, "--file", task.file];
this.configureS3Options(args);
if (process.env.__TEST_S3_PUBLISHER__ != null) {
const testFile = path.join(process.env.__TEST_S3_PUBLISHER__, target);
await (0, promises_1.mkdir)(path.dirname(testFile), { recursive: true });
await (0, promises_1.symlink)(task.file, testFile);
return;
}
// https://github.com/aws/aws-sdk-go/issues/279
this.createProgressBar(fileName, -1);
// if (progressBar != null) {
// const callback = new ProgressCallback(progressBar)
// uploader.on("progress", () => {
// if (!cancellationToken.cancelled) {
// callback.update(uploader.loaded, uploader.contentLength)
// }
// })
// }
return await cancellationToken.createPromise((resolve, reject, onCancel) => {
(0, builder_util_1.executeAppBuilder)(args, process => {
onCancel(() => {
process.kill("SIGINT");
});
})
.then(() => {
try {
builder_util_1.log.debug({ provider: this.providerName, file: fileName, bucket: this.getBucketName() }, "uploaded");
}
finally {
resolve(undefined);
}
})
.catch(reject);
});
}
toString() {
return `${this.providerName} (bucket: ${this.getBucketName()})`;
}
}
exports.BaseS3Publisher = BaseS3Publisher;
//# sourceMappingURL=BaseS3Publisher.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"BaseS3Publisher.js","sourceRoot":"","sources":["../../../src/publish/s3/BaseS3Publisher.ts"],"names":[],"mappings":"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","sourcesContent":["import { log, executeAppBuilder } from \"builder-util\"\nimport { BaseS3Options } from \"builder-util-runtime\"\nimport { PublishContext, Publisher, UploadTask } from \"electron-publish\"\nimport { mkdir, symlink } from \"fs/promises\"\nimport * as path from \"path\"\n\nexport abstract class BaseS3Publisher extends Publisher {\n protected constructor(\n context: PublishContext,\n private options: BaseS3Options\n ) {\n super(context)\n }\n\n protected abstract getBucketName(): string\n\n protected configureS3Options(args: Array<string>) {\n // if explicitly set to null, do not add\n if (this.options.acl !== null) {\n args.push(\"--acl\", this.options.acl || \"public-read\")\n }\n }\n\n // http://docs.aws.amazon.com/sdk-for-javascript/v2/developer-guide/s3-example-creating-buckets.html\n async upload(task: UploadTask): Promise<any> {\n const fileName = path.basename(task.file)\n const cancellationToken = this.context.cancellationToken\n\n const target = (this.options.path == null ? \"\" : `${this.options.path}/`) + fileName\n\n const args = [\"publish-s3\", \"--bucket\", this.getBucketName(), \"--key\", target, \"--file\", task.file]\n this.configureS3Options(args)\n\n if (process.env.__TEST_S3_PUBLISHER__ != null) {\n const testFile = path.join(process.env.__TEST_S3_PUBLISHER__, target)\n await mkdir(path.dirname(testFile), { recursive: true })\n await symlink(task.file, testFile)\n return\n }\n\n // https://github.com/aws/aws-sdk-go/issues/279\n this.createProgressBar(fileName, -1)\n // if (progressBar != null) {\n // const callback = new ProgressCallback(progressBar)\n // uploader.on(\"progress\", () => {\n // if (!cancellationToken.cancelled) {\n // callback.update(uploader.loaded, uploader.contentLength)\n // }\n // })\n // }\n\n return await cancellationToken.createPromise((resolve, reject, onCancel) => {\n executeAppBuilder(args, process => {\n onCancel(() => {\n process.kill(\"SIGINT\")\n })\n })\n .then(() => {\n try {\n log.debug({ provider: this.providerName, file: fileName, bucket: this.getBucketName() }, \"uploaded\")\n } finally {\n resolve(undefined)\n }\n })\n .catch(reject)\n })\n }\n\n toString() {\n return `${this.providerName} (bucket: ${this.getBucketName()})`\n }\n}\n"]}

View File

@@ -0,0 +1,12 @@
import { S3Options } from "builder-util-runtime";
import { PublishContext } from "electron-publish";
import { BaseS3Publisher } from "./BaseS3Publisher";
export default class S3Publisher extends BaseS3Publisher {
private readonly info;
readonly providerName = "s3";
constructor(context: PublishContext, info: S3Options);
static checkAndResolveOptions(options: S3Options, channelFromAppVersion: string | null, errorIfCannot: boolean): Promise<void>;
protected getBucketName(): string;
protected configureS3Options(args: Array<string>): void;
toString(): string;
}

View File

@@ -0,0 +1,66 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const builder_util_1 = require("builder-util");
const BaseS3Publisher_1 = require("./BaseS3Publisher");
class S3Publisher extends BaseS3Publisher_1.BaseS3Publisher {
constructor(context, info) {
super(context, info);
this.info = info;
this.providerName = "s3";
}
static async checkAndResolveOptions(options, channelFromAppVersion, errorIfCannot) {
const bucket = options.bucket;
if (bucket == null) {
throw new builder_util_1.InvalidConfigurationError(`Please specify "bucket" for "s3" publish provider`);
}
if (options.endpoint == null && bucket.includes(".") && options.region == null) {
// on dotted bucket names, we need to use a path-based endpoint URL. Path-based endpoint URLs need to include the region.
try {
options.region = await (0, builder_util_1.executeAppBuilder)(["get-bucket-location", "--bucket", bucket]);
}
catch (e) {
if (errorIfCannot) {
throw e;
}
else {
builder_util_1.log.warn(`cannot compute region for bucket (required because on dotted bucket names, we need to use a path-based endpoint URL): ${e}`);
}
}
}
if (options.channel == null && channelFromAppVersion != null) {
options.channel = channelFromAppVersion;
}
if (options.endpoint != null && options.endpoint.endsWith("/")) {
;
options.endpoint = options.endpoint.slice(0, -1);
}
}
getBucketName() {
return this.info.bucket;
}
configureS3Options(args) {
super.configureS3Options(args);
if (this.info.endpoint != null) {
args.push("--endpoint", this.info.endpoint);
}
if (this.info.region != null) {
args.push("--region", this.info.region);
}
if (this.info.storageClass != null) {
args.push("--storageClass", this.info.storageClass);
}
if (this.info.encryption != null) {
args.push("--encryption", this.info.encryption);
}
}
toString() {
const result = super.toString();
const endpoint = this.info.endpoint;
if (endpoint != null) {
return result.substring(0, result.length - 1) + `, endpoint: ${endpoint})`;
}
return result;
}
}
exports.default = S3Publisher;
//# sourceMappingURL=s3Publisher.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"s3Publisher.js","sourceRoot":"","sources":["../../../src/publish/s3/s3Publisher.ts"],"names":[],"mappings":"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","sourcesContent":["import { executeAppBuilder, InvalidConfigurationError, log } from \"builder-util\"\nimport { S3Options } from \"builder-util-runtime\"\nimport { PublishContext } from \"electron-publish\"\nimport { BaseS3Publisher } from \"./BaseS3Publisher\"\n\nexport default class S3Publisher extends BaseS3Publisher {\n readonly providerName = \"s3\"\n\n constructor(\n context: PublishContext,\n private readonly info: S3Options\n ) {\n super(context, info)\n }\n\n static async checkAndResolveOptions(options: S3Options, channelFromAppVersion: string | null, errorIfCannot: boolean) {\n const bucket = options.bucket\n if (bucket == null) {\n throw new InvalidConfigurationError(`Please specify \"bucket\" for \"s3\" publish provider`)\n }\n\n if (options.endpoint == null && bucket.includes(\".\") && options.region == null) {\n // on dotted bucket names, we need to use a path-based endpoint URL. Path-based endpoint URLs need to include the region.\n try {\n options.region = await executeAppBuilder([\"get-bucket-location\", \"--bucket\", bucket])\n } catch (e: any) {\n if (errorIfCannot) {\n throw e\n } else {\n log.warn(`cannot compute region for bucket (required because on dotted bucket names, we need to use a path-based endpoint URL): ${e}`)\n }\n }\n }\n\n if (options.channel == null && channelFromAppVersion != null) {\n options.channel = channelFromAppVersion\n }\n\n if (options.endpoint != null && options.endpoint.endsWith(\"/\")) {\n ;(options as any).endpoint = options.endpoint.slice(0, -1)\n }\n }\n\n protected getBucketName(): string {\n return this.info.bucket\n }\n\n protected configureS3Options(args: Array<string>): void {\n super.configureS3Options(args)\n\n if (this.info.endpoint != null) {\n args.push(\"--endpoint\", this.info.endpoint)\n }\n if (this.info.region != null) {\n args.push(\"--region\", this.info.region)\n }\n\n if (this.info.storageClass != null) {\n args.push(\"--storageClass\", this.info.storageClass)\n }\n if (this.info.encryption != null) {\n args.push(\"--encryption\", this.info.encryption)\n }\n }\n\n toString() {\n const result = super.toString()\n const endpoint = this.info.endpoint\n if (endpoint != null) {\n return result.substring(0, result.length - 1) + `, endpoint: ${endpoint})`\n }\n return result\n }\n}\n"]}

View File

@@ -0,0 +1,11 @@
import { SpacesOptions } from "builder-util-runtime";
import { PublishContext } from "electron-publish";
import { BaseS3Publisher } from "./BaseS3Publisher";
export default class SpacesPublisher extends BaseS3Publisher {
private readonly info;
readonly providerName = "spaces";
constructor(context: PublishContext, info: SpacesOptions);
static checkAndResolveOptions(options: SpacesOptions, channelFromAppVersion: string | null, errorIfCannot: boolean): Promise<void>;
protected getBucketName(): string;
protected configureS3Options(args: Array<string>): void;
}

View File

@@ -0,0 +1,44 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const builder_util_1 = require("builder-util");
const BaseS3Publisher_1 = require("./BaseS3Publisher");
class SpacesPublisher extends BaseS3Publisher_1.BaseS3Publisher {
constructor(context, info) {
super(context, info);
this.info = info;
this.providerName = "spaces";
}
// eslint-disable-next-line @typescript-eslint/no-unused-vars
static checkAndResolveOptions(options, channelFromAppVersion, errorIfCannot) {
if (options.name == null) {
throw new builder_util_1.InvalidConfigurationError(`Please specify "name" for "spaces" publish provider (see https://www.electron.build/publish#spacesoptions)`);
}
if (options.region == null) {
throw new builder_util_1.InvalidConfigurationError(`Please specify "region" for "spaces" publish provider (see https://www.electron.build/publish#spacesoptions)`);
}
if (options.channel == null && channelFromAppVersion != null) {
options.channel = channelFromAppVersion;
}
return Promise.resolve();
}
getBucketName() {
return this.info.name;
}
configureS3Options(args) {
super.configureS3Options(args);
args.push("--endpoint", `${this.info.region}.digitaloceanspaces.com`);
args.push("--region", this.info.region);
const accessKey = process.env.DO_KEY_ID;
const secretKey = process.env.DO_SECRET_KEY;
if ((0, builder_util_1.isEmptyOrSpaces)(accessKey)) {
throw new builder_util_1.InvalidConfigurationError("Please set env DO_KEY_ID (see https://www.electron.build/publish#spacesoptions)");
}
if ((0, builder_util_1.isEmptyOrSpaces)(secretKey)) {
throw new builder_util_1.InvalidConfigurationError("Please set env DO_SECRET_KEY (see https://www.electron.build/publish#spacesoptions)");
}
args.push("--accessKey", accessKey);
args.push("--secretKey", secretKey);
}
}
exports.default = SpacesPublisher;
//# sourceMappingURL=spacesPublisher.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"spacesPublisher.js","sourceRoot":"","sources":["../../../src/publish/s3/spacesPublisher.ts"],"names":[],"mappings":";;AAAA,+CAAyE;AAGzE,uDAAmD;AAEnD,MAAqB,eAAgB,SAAQ,iCAAe;IAG1D,YACE,OAAuB,EACN,IAAmB;QAEpC,KAAK,CAAC,OAAO,EAAE,IAAI,CAAC,CAAA;QAFH,SAAI,GAAJ,IAAI,CAAe;QAJ7B,iBAAY,GAAG,QAAQ,CAAA;IAOhC,CAAC;IAED,6DAA6D;IAC7D,MAAM,CAAC,sBAAsB,CAAC,OAAsB,EAAE,qBAAoC,EAAE,aAAsB;QAChH,IAAI,OAAO,CAAC,IAAI,IAAI,IAAI,EAAE,CAAC;YACzB,MAAM,IAAI,wCAAyB,CAAC,4GAA4G,CAAC,CAAA;QACnJ,CAAC;QACD,IAAI,OAAO,CAAC,MAAM,IAAI,IAAI,EAAE,CAAC;YAC3B,MAAM,IAAI,wCAAyB,CAAC,8GAA8G,CAAC,CAAA;QACrJ,CAAC;QAED,IAAI,OAAO,CAAC,OAAO,IAAI,IAAI,IAAI,qBAAqB,IAAI,IAAI,EAAE,CAAC;YAC7D,OAAO,CAAC,OAAO,GAAG,qBAAqB,CAAA;QACzC,CAAC;QACD,OAAO,OAAO,CAAC,OAAO,EAAE,CAAA;IAC1B,CAAC;IAES,aAAa;QACrB,OAAO,IAAI,CAAC,IAAI,CAAC,IAAI,CAAA;IACvB,CAAC;IAES,kBAAkB,CAAC,IAAmB;QAC9C,KAAK,CAAC,kBAAkB,CAAC,IAAI,CAAC,CAAA;QAE9B,IAAI,CAAC,IAAI,CAAC,YAAY,EAAE,GAAG,IAAI,CAAC,IAAI,CAAC,MAAM,yBAAyB,CAAC,CAAA;QACrE,IAAI,CAAC,IAAI,CAAC,UAAU,EAAE,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,CAAA;QAEvC,MAAM,SAAS,GAAG,OAAO,CAAC,GAAG,CAAC,SAAS,CAAA;QACvC,MAAM,SAAS,GAAG,OAAO,CAAC,GAAG,CAAC,aAAa,CAAA;QAC3C,IAAI,IAAA,8BAAe,EAAC,SAAS,CAAC,EAAE,CAAC;YAC/B,MAAM,IAAI,wCAAyB,CAAC,iFAAiF,CAAC,CAAA;QACxH,CAAC;QACD,IAAI,IAAA,8BAAe,EAAC,SAAS,CAAC,EAAE,CAAC;YAC/B,MAAM,IAAI,wCAAyB,CAAC,qFAAqF,CAAC,CAAA;QAC5H,CAAC;QACD,IAAI,CAAC,IAAI,CAAC,aAAa,EAAE,SAAS,CAAC,CAAA;QACnC,IAAI,CAAC,IAAI,CAAC,aAAa,EAAE,SAAS,CAAC,CAAA;IACrC,CAAC;CACF;AA9CD,kCA8CC","sourcesContent":["import { InvalidConfigurationError, isEmptyOrSpaces } from \"builder-util\"\nimport { SpacesOptions } from \"builder-util-runtime\"\nimport { PublishContext } from \"electron-publish\"\nimport { BaseS3Publisher } from \"./BaseS3Publisher\"\n\nexport default class SpacesPublisher extends BaseS3Publisher {\n readonly providerName = \"spaces\"\n\n constructor(\n context: PublishContext,\n private readonly info: SpacesOptions\n ) {\n super(context, info)\n }\n\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n static checkAndResolveOptions(options: SpacesOptions, channelFromAppVersion: string | null, errorIfCannot: boolean) {\n if (options.name == null) {\n throw new InvalidConfigurationError(`Please specify \"name\" for \"spaces\" publish provider (see https://www.electron.build/publish#spacesoptions)`)\n }\n if (options.region == null) {\n throw new InvalidConfigurationError(`Please specify \"region\" for \"spaces\" publish provider (see https://www.electron.build/publish#spacesoptions)`)\n }\n\n if (options.channel == null && channelFromAppVersion != null) {\n options.channel = channelFromAppVersion\n }\n return Promise.resolve()\n }\n\n protected getBucketName(): string {\n return this.info.name\n }\n\n protected configureS3Options(args: Array<string>): void {\n super.configureS3Options(args)\n\n args.push(\"--endpoint\", `${this.info.region}.digitaloceanspaces.com`)\n args.push(\"--region\", this.info.region)\n\n const accessKey = process.env.DO_KEY_ID\n const secretKey = process.env.DO_SECRET_KEY\n if (isEmptyOrSpaces(accessKey)) {\n throw new InvalidConfigurationError(\"Please set env DO_KEY_ID (see https://www.electron.build/publish#spacesoptions)\")\n }\n if (isEmptyOrSpaces(secretKey)) {\n throw new InvalidConfigurationError(\"Please set env DO_SECRET_KEY (see https://www.electron.build/publish#spacesoptions)\")\n }\n args.push(\"--accessKey\", accessKey)\n args.push(\"--secretKey\", secretKey)\n }\n}\n"]}

View File

@@ -0,0 +1,10 @@
import { PublishConfiguration, UpdateInfo } from "builder-util-runtime";
import { Packager } from "../packager";
import { PlatformPackager } from "../platformPackager";
export interface UpdateInfoFileTask {
readonly file: string;
readonly info: UpdateInfo;
readonly publishConfiguration: PublishConfiguration;
readonly packager: PlatformPackager<any>;
}
export declare function writeUpdateInfoFiles(updateInfoFileTasks: Array<UpdateInfoFileTask>, packager: Packager): Promise<void>;

View File

@@ -0,0 +1,213 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.createUpdateInfoTasks = createUpdateInfoTasks;
exports.writeUpdateInfoFiles = writeUpdateInfoFiles;
const bluebird_lst_1 = require("bluebird-lst");
const builder_util_1 = require("builder-util");
const fs_extra_1 = require("fs-extra");
const lazy_val_1 = require("lazy-val");
const path = require("path");
const semver = require("semver");
const core_1 = require("../core");
const hash_1 = require("../util/hash");
const PublishManager_1 = require("./PublishManager");
async function getReleaseInfo(packager) {
const releaseInfo = { ...(packager.platformSpecificBuildOptions.releaseInfo || packager.config.releaseInfo) };
if (releaseInfo.releaseNotes == null) {
const releaseNotesFile = await packager.getResource(releaseInfo.releaseNotesFile, `release-notes-${packager.platform.buildConfigurationKey}.md`, `release-notes-${packager.platform.name}.md`, `release-notes-${packager.platform.nodeName}.md`, "release-notes.md");
const releaseNotes = releaseNotesFile == null ? null : await (0, fs_extra_1.readFile)(releaseNotesFile, "utf-8");
// to avoid undefined in the file, check for null
if (releaseNotes != null) {
releaseInfo.releaseNotes = releaseNotes;
}
}
delete releaseInfo.releaseNotesFile;
return releaseInfo;
}
function isGenerateUpdatesFilesForAllChannels(packager) {
const value = packager.platformSpecificBuildOptions.generateUpdatesFilesForAllChannels;
return value == null ? packager.config.generateUpdatesFilesForAllChannels : value;
}
/**
if this is an "alpha" version, we need to generate only the "alpha" .yml file
if this is a "beta" version, we need to generate both the "alpha" and "beta" .yml file
if this is a "stable" version, we need to generate all the "alpha", "beta" and "stable" .yml file
*/
function computeChannelNames(packager, publishConfig) {
const currentChannel = publishConfig.channel || "latest";
// for GitHub should be pre-release way be used
if (currentChannel === "alpha" || publishConfig.provider === "github" || !isGenerateUpdatesFilesForAllChannels(packager)) {
return [currentChannel];
}
switch (currentChannel) {
case "beta":
return [currentChannel, "alpha"];
case "latest":
return [currentChannel, "alpha", "beta"];
default:
return [currentChannel];
}
}
function getUpdateInfoFileName(channel, packager, arch) {
const osSuffix = packager.platform === core_1.Platform.WINDOWS ? "" : `-${packager.platform.buildConfigurationKey}`;
return `${channel}${osSuffix}${getArchPrefixForUpdateFile(arch, packager)}.yml`;
}
function getArchPrefixForUpdateFile(arch, packager) {
if (arch == null || arch === builder_util_1.Arch.x64 || packager.platform !== core_1.Platform.LINUX) {
return "";
}
return arch === builder_util_1.Arch.armv7l ? "-arm" : `-${builder_util_1.Arch[arch]}`;
}
function computeIsisElectronUpdater1xCompatibility(updaterCompatibility, publishConfiguration, packager) {
if (updaterCompatibility != null) {
return semver.satisfies("1.0.0", updaterCompatibility);
}
// spaces is a new publish provider, no need to keep backward compatibility
if (publishConfiguration.provider === "spaces") {
return false;
}
const updaterVersion = packager.metadata.dependencies == null ? null : packager.metadata.dependencies["electron-updater"];
return updaterVersion == null || semver.lt(updaterVersion, "4.0.0");
}
/** @internal */
async function createUpdateInfoTasks(event, _publishConfigs) {
const packager = event.packager;
const publishConfigs = await (0, PublishManager_1.getPublishConfigsForUpdateInfo)(packager, _publishConfigs, event.arch);
if (publishConfigs == null || publishConfigs.length === 0) {
return [];
}
const outDir = event.target.outDir;
const version = packager.appInfo.version;
const sha2 = new lazy_val_1.Lazy(() => (0, hash_1.hashFile)(event.file, "sha256", "hex"));
const isMac = packager.platform === core_1.Platform.MAC;
const createdFiles = new Set();
const sharedInfo = await createUpdateInfo(version, event, await getReleaseInfo(packager));
const tasks = [];
const electronUpdaterCompatibility = packager.platformSpecificBuildOptions.electronUpdaterCompatibility || packager.config.electronUpdaterCompatibility || ">=2.15";
for (const publishConfiguration of publishConfigs) {
let dir = outDir;
if (publishConfigs.length > 1 && publishConfiguration !== publishConfigs[0]) {
dir = path.join(outDir, publishConfiguration.provider);
}
let isElectronUpdater1xCompatibility = computeIsisElectronUpdater1xCompatibility(electronUpdaterCompatibility, publishConfiguration, packager.info);
let info = sharedInfo;
// noinspection JSDeprecatedSymbols
if (isElectronUpdater1xCompatibility && packager.platform === core_1.Platform.WINDOWS) {
info = {
...info,
};
info.sha2 = await sha2.value;
}
if (event.safeArtifactName != null && publishConfiguration.provider === "github") {
const newFiles = info.files.slice();
newFiles[0].url = event.safeArtifactName;
info = {
...info,
files: newFiles,
path: event.safeArtifactName,
};
}
for (const channel of computeChannelNames(packager, publishConfiguration)) {
if (isMac && isElectronUpdater1xCompatibility && event.file.endsWith(".zip")) {
// write only for first channel (generateUpdatesFilesForAllChannels is a new functionality, no need to generate old mac update info file)
isElectronUpdater1xCompatibility = false;
await writeOldMacInfo(publishConfiguration, outDir, dir, channel, createdFiles, version, packager);
}
const updateInfoFile = path.join(dir, getUpdateInfoFileName(channel, packager, event.arch));
if (createdFiles.has(updateInfoFile)) {
continue;
}
createdFiles.add(updateInfoFile);
// artifact should be uploaded only to designated publish provider
tasks.push({
file: updateInfoFile,
info,
publishConfiguration,
packager,
});
}
}
return tasks;
}
async function createUpdateInfo(version, event, releaseInfo) {
const customUpdateInfo = event.updateInfo;
const url = path.basename(event.file);
const sha512 = (customUpdateInfo == null ? null : customUpdateInfo.sha512) || (await (0, hash_1.hashFile)(event.file));
const files = [{ url, sha512 }];
const result = {
// @ts-ignore
version,
// @ts-ignore
files,
// @ts-ignore
path: url /* backward compatibility, electron-updater 1.x - electron-updater 2.15.0 */,
// @ts-ignore
sha512 /* backward compatibility, electron-updater 1.x - electron-updater 2.15.0 */,
...releaseInfo,
};
if (customUpdateInfo != null) {
// file info or nsis web installer packages info
Object.assign("sha512" in customUpdateInfo ? files[0] : result, customUpdateInfo);
}
return result;
}
async function writeUpdateInfoFiles(updateInfoFileTasks, packager) {
// zip must be first and zip info must be used for old path/sha512 properties in the update info
updateInfoFileTasks.sort((a, b) => (a.info.files[0].url.endsWith(".zip") ? 0 : 100) - (b.info.files[0].url.endsWith(".zip") ? 0 : 100));
const updateChannelFileToInfo = new Map();
for (const task of updateInfoFileTasks) {
// https://github.com/electron-userland/electron-builder/pull/2994
const key = `${task.file}@${(0, builder_util_1.safeStringifyJson)(task.publishConfiguration, new Set(["releaseType"]))}`;
const existingTask = updateChannelFileToInfo.get(key);
if (existingTask == null) {
updateChannelFileToInfo.set(key, task);
continue;
}
existingTask.info.files.push(...task.info.files);
}
const releaseDate = new Date().toISOString();
await bluebird_lst_1.default.map(updateChannelFileToInfo.values(), async (task) => {
const publishConfig = task.publishConfiguration;
if (publishConfig.publishAutoUpdate === false) {
builder_util_1.log.debug({
provider: publishConfig.provider,
reason: "publishAutoUpdate is set to false",
}, "auto update metadata file not published");
return;
}
if (task.info.releaseDate == null) {
task.info.releaseDate = releaseDate;
}
const fileContent = Buffer.from((0, builder_util_1.serializeToYaml)(task.info, false, true));
await (0, fs_extra_1.outputFile)(task.file, fileContent);
packager.dispatchArtifactCreated({
file: task.file,
fileContent,
arch: null,
packager: task.packager,
target: null,
publishConfig,
});
}, { concurrency: 4 });
}
// backward compatibility - write json file
async function writeOldMacInfo(publishConfig, outDir, dir, channel, createdFiles, version, packager) {
const isGitHub = publishConfig.provider === "github";
const updateInfoFile = isGitHub && outDir === dir ? path.join(dir, "github", `${channel}-mac.json`) : path.join(dir, `${channel}-mac.json`);
if (!createdFiles.has(updateInfoFile)) {
createdFiles.add(updateInfoFile);
await (0, fs_extra_1.outputJson)(updateInfoFile, {
version,
releaseDate: new Date().toISOString(),
url: (0, PublishManager_1.computeDownloadUrl)(publishConfig, packager.generateName2("zip", "mac", isGitHub), packager),
}, { spaces: 2 });
packager.info.dispatchArtifactCreated({
file: updateInfoFile,
arch: null,
packager,
target: null,
publishConfig,
});
}
}
//# sourceMappingURL=updateInfoBuilder.js.map

File diff suppressed because one or more lines are too long