diff --git a/packages/electron-builder-lib/src/publish/PublishManager.ts b/packages/electron-builder-lib/src/publish/PublishManager.ts index b7d555993cd..646fd947b30 100644 --- a/packages/electron-builder-lib/src/publish/PublishManager.ts +++ b/packages/electron-builder-lib/src/publish/PublishManager.ts @@ -84,7 +84,7 @@ export class PublishManager implements PublishContext { return } - const publishConfig = await getAppUpdatePublishConfiguration(packager, event.arch) + const publishConfig = await getAppUpdatePublishConfiguration(packager, event.arch, this.isPublish) if (publishConfig != null) { await writeFile(path.join(packager.getResourcesDir(event.appOutDir), "app-update.yml"), serializeToYaml(publishConfig)) } @@ -125,7 +125,7 @@ export class PublishManager implements PublishContext { private async artifactCreated(event: ArtifactCreated) { const packager = event.packager const target = event.target - const publishConfigs = event.publishConfig == null ? await getPublishConfigs(packager, target == null ? null : target.options, event.arch) : [event.publishConfig] + const publishConfigs = event.publishConfig == null ? await getPublishConfigs(packager, target == null ? null : target.options, event.arch, this.isPublish) : [event.publishConfig] if (debug.enabled) { debug(`artifactCreated (isPublish: ${this.isPublish}): ${safeStringifyJson(event, new Set(["packager"]))},\n publishConfigs: ${safeStringifyJson(publishConfigs)}`) @@ -188,8 +188,8 @@ export class PublishManager implements PublishContext { } } -export async function getAppUpdatePublishConfiguration(packager: PlatformPackager, arch: Arch) { - const publishConfigs = await getPublishConfigsForUpdateInfo(packager, await getPublishConfigs(packager, null, arch), arch) +export async function getAppUpdatePublishConfiguration(packager: PlatformPackager, arch: Arch, errorIfCannot: boolean) { + const publishConfigs = await getPublishConfigsForUpdateInfo(packager, await getPublishConfigs(packager, null, arch, errorIfCannot), arch) if (publishConfigs == null || publishConfigs.length === 0) { return null } @@ -297,7 +297,7 @@ export function computeDownloadUrl(publishConfiguration: PublishConfiguration, f return `${baseUrl}/${encodeURI(fileName)}` } -export async function getPublishConfigs(packager: PlatformPackager, targetSpecificOptions: PlatformSpecificBuildOptions | null | undefined, arch: Arch | null): Promise | null> { +export async function getPublishConfigs(packager: PlatformPackager, targetSpecificOptions: PlatformSpecificBuildOptions | null | undefined, arch: Arch | null, errorIfCannot: boolean): Promise | null> { let publishers // check build.nsis (target) @@ -335,7 +335,7 @@ export async function getPublishConfigs(packager: PlatformPackager, targetS if (serviceName != null) { log.debug(null, `Detect ${serviceName} as publish provider`) - return [(await getResolvedPublishConfig(packager, {provider: serviceName}, arch))!] + return [(await getResolvedPublishConfig(packager, {provider: serviceName}, arch, errorIfCannot))!] } } @@ -344,7 +344,7 @@ export async function getPublishConfigs(packager: PlatformPackager, targetS } debug(`Explicit publish provider: ${safeStringifyJson(publishers)}`) - return await (BluebirdPromise.map(asArray(publishers), it => getResolvedPublishConfig(packager, typeof it === "string" ? {provider: it} : it, arch)) as Promise>) + return await (BluebirdPromise.map(asArray(publishers), it => getResolvedPublishConfig(packager, typeof it === "string" ? {provider: it} : it, arch, errorIfCannot)) as Promise>) } function isSuitableWindowsTarget(target: Target) { @@ -371,7 +371,7 @@ function isDetectUpdateChannel(packager: PlatformPackager) { return value == null ? packager.config.detectUpdateChannel !== false : value } -async function getResolvedPublishConfig(packager: PlatformPackager, options: PublishConfiguration, arch: Arch | null, errorIfCannot: boolean = true): Promise { +async function getResolvedPublishConfig(packager: PlatformPackager, options: PublishConfiguration, arch: Arch | null, errorIfCannot: boolean): Promise { options = {...options} expandPublishConfig(options, packager, arch) @@ -395,7 +395,7 @@ async function getResolvedPublishConfig(packager: PlatformPackager, options const providerClass = requireProviderClass(options.provider) if (providerClass != null && providerClass.checkAndResolveOptions != null) { - await providerClass.checkAndResolveOptions(options, channelFromAppVersion) + await providerClass.checkAndResolveOptions(options, channelFromAppVersion, errorIfCannot) return options } diff --git a/packages/electron-builder-lib/src/targets/AppImageTarget.ts b/packages/electron-builder-lib/src/targets/AppImageTarget.ts index 228dcc2b82c..54158c6a6b2 100644 --- a/packages/electron-builder-lib/src/targets/AppImageTarget.ts +++ b/packages/electron-builder-lib/src/targets/AppImageTarget.ts @@ -70,7 +70,7 @@ export default class AppImageTarget extends Target { return } - const publishConfig = await getAppUpdatePublishConfiguration(packager, arch) + const publishConfig = await getAppUpdatePublishConfiguration(packager, arch, false /* in any case validation will be done on publish */) if (publishConfig != null) { await outputFile(path.join(packager.getResourcesDir(stageDir.getTempFile("app")), "app-update.yml"), serializeToYaml(publishConfig)) } diff --git a/packages/electron-builder-lib/src/targets/nsis/WebInstallerTarget.ts b/packages/electron-builder-lib/src/targets/nsis/WebInstallerTarget.ts index 90b6bbee737..bdf5d199816 100644 --- a/packages/electron-builder-lib/src/targets/nsis/WebInstallerTarget.ts +++ b/packages/electron-builder-lib/src/targets/nsis/WebInstallerTarget.ts @@ -23,7 +23,7 @@ export class WebInstallerTarget extends NsisTarget { let appPackageUrl = options.appPackageUrl if (appPackageUrl == null) { - const publishConfigs = await getPublishConfigsForUpdateInfo(packager, await getPublishConfigs(packager, this.options, null), null) + const publishConfigs = await getPublishConfigsForUpdateInfo(packager, await getPublishConfigs(packager, this.options, null, false), null) if (publishConfigs == null || publishConfigs.length === 0) { throw new Error("Cannot compute app package download URL") } diff --git a/packages/electron-publisher-s3/src/s3Publisher.ts b/packages/electron-publisher-s3/src/s3Publisher.ts index 1296bb6adfd..7d557776fac 100644 --- a/packages/electron-publisher-s3/src/s3Publisher.ts +++ b/packages/electron-publisher-s3/src/s3Publisher.ts @@ -1,5 +1,5 @@ import S3, { ClientConfiguration, ServerSideEncryption, StorageClass } from "aws-sdk/clients/s3" -import { InvalidConfigurationError } from "builder-util" +import { InvalidConfigurationError, log } from "builder-util" import { S3Options } from "builder-util-runtime" import { PublishContext } from "electron-publish" import { BaseS3Publisher } from "./BaseS3Publisher" @@ -11,7 +11,7 @@ export default class S3Publisher extends BaseS3Publisher { super(context, info) } - static async checkAndResolveOptions(options: S3Options, channelFromAppVersion: string | null) { + static async checkAndResolveOptions(options: S3Options, channelFromAppVersion: string | null, errorIfCannot: boolean) { const bucket = options.bucket if (bucket == null) { throw new InvalidConfigurationError(`Please specify "bucket" for "s3" publish provider`) @@ -20,7 +20,17 @@ export default class S3Publisher extends BaseS3Publisher { 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. const s3 = new S3({signatureVersion: "v4"}) - options.region = (await s3.getBucketLocation({Bucket: bucket}).promise()).LocationConstraint + try { + options.region = (await s3.getBucketLocation({Bucket: bucket}).promise()).LocationConstraint + } + catch (e) { + if (errorIfCannot) { + throw e + } + else { + 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) { diff --git a/packages/electron-publisher-s3/src/spacesPublisher.ts b/packages/electron-publisher-s3/src/spacesPublisher.ts index 1e34778f2d1..0dc8502020c 100644 --- a/packages/electron-publisher-s3/src/spacesPublisher.ts +++ b/packages/electron-publisher-s3/src/spacesPublisher.ts @@ -11,7 +11,7 @@ export default class SpacesPublisher extends BaseS3Publisher { super(context, info) } - static async checkAndResolveOptions(options: SpacesOptions, channelFromAppVersion: string | null) { + static async checkAndResolveOptions(options: SpacesOptions, channelFromAppVersion: string | null, errorIfCannot: boolean) { if (options.name == null) { throw new InvalidConfigurationError(`Please specify "name" for "spaces" publish provider (see https://www.electron.build/configuration/publish#spacesoptions)`) } diff --git a/test/out/windows/__snapshots__/oneClickInstallerTest.js.snap b/test/out/windows/__snapshots__/oneClickInstallerTest.js.snap index df86995921a..93f648e2919 100644 --- a/test/out/windows/__snapshots__/oneClickInstallerTest.js.snap +++ b/test/out/windows/__snapshots__/oneClickInstallerTest.js.snap @@ -1,5 +1,17 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP +exports[`big file pack 1`] = ` +Object { + "win": Array [ + Object { + "arch": "x64", + "file": "Test App ßW Setup 1.1.0.exe", + "safeArtifactName": "TestApp-Setup-1.1.0.exe", + }, + ], +} +`; + exports[`custom include 1`] = ` Object { "win": Array [ diff --git a/test/src/PublishManagerTest.ts b/test/src/PublishManagerTest.ts index 1be2631e7e4..90a59fe7e4f 100644 --- a/test/src/PublishManagerTest.ts +++ b/test/src/PublishManagerTest.ts @@ -51,4 +51,17 @@ test.ifAll.ifNotWindows("os macro", app({ await assertThat(dir).isDirectory() await checkDirContents(dir) } +})) + +// https://github.com/electron-userland/electron-builder/issues/2670 +test.ifAll.ifNotWindows("dotted s3 bucket", app({ + targets: createTargets([Platform.LINUX], "zip"), + config: { + publish: { + provider: "s3", + bucket: "bucket.dotted.name", + }, + }, +}, { + publish: "never" })) \ No newline at end of file