From 66ca625f892329fd7bedf52fddc6659ec83b7cd3 Mon Sep 17 00:00:00 2001 From: Justin Bellero Date: Mon, 8 Nov 2021 22:28:38 -0500 Subject: [PATCH] refactor: update Bitbucket publisher (#6400) - use fs-extra to support Node < v14 - optional config options for Token and Username (Bitbucket Private Repos) --- .changeset/spotty-clouds-invent.md | 8 ++++++++ .../app-builder-lib/src/publish/BitbucketPublisher.ts | 6 +++--- packages/builder-util-runtime/src/publishOptions.ts | 10 ++++++++++ 3 files changed, 21 insertions(+), 3 deletions(-) create mode 100644 .changeset/spotty-clouds-invent.md diff --git a/.changeset/spotty-clouds-invent.md b/.changeset/spotty-clouds-invent.md new file mode 100644 index 00000000000..e094e5c2b9e --- /dev/null +++ b/.changeset/spotty-clouds-invent.md @@ -0,0 +1,8 @@ +--- +"app-builder-lib": patch +"builder-util-runtime": patch +"builder-util": patch +--- + +refactor: update Bitbucket publisher to have optional config options for Token and Username (Bitbucket Private Repos) + diff --git a/packages/app-builder-lib/src/publish/BitbucketPublisher.ts b/packages/app-builder-lib/src/publish/BitbucketPublisher.ts index 269f3130cd4..63de458e2f0 100644 --- a/packages/app-builder-lib/src/publish/BitbucketPublisher.ts +++ b/packages/app-builder-lib/src/publish/BitbucketPublisher.ts @@ -5,7 +5,7 @@ import { HttpPublisher, PublishContext } from "electron-publish" import { BitbucketOptions } from "builder-util-runtime/out/publishOptions" import { configureRequestOptions, HttpExecutor } from "builder-util-runtime" import * as FormData from "form-data" -import { readFile } from "fs/promises" +import { readFile } from "fs-extra" export class BitbucketPublisher extends HttpPublisher { readonly providerName = "bitbucket" @@ -18,8 +18,8 @@ export class BitbucketPublisher extends HttpPublisher { constructor(context: PublishContext, info: BitbucketOptions) { super(context) - const token = process.env.BITBUCKET_TOKEN - const username = process.env.BITBUCKET_USERNAME + const token = info.token || process.env.BITBUCKET_TOKEN || null + const username = info.username || process.env.BITBUCKET_USERNAME || null if (isEmptyOrSpaces(token)) { throw new InvalidConfigurationError(`Bitbucket token is not set using env "BITBUCKET_TOKEN" (see https://www.electron.build/configuration/publish#BitbucketOptions)`) diff --git a/packages/builder-util-runtime/src/publishOptions.ts b/packages/builder-util-runtime/src/publishOptions.ts index 55047ec97c0..0f9d1cdf8de 100644 --- a/packages/builder-util-runtime/src/publishOptions.ts +++ b/packages/builder-util-runtime/src/publishOptions.ts @@ -213,6 +213,16 @@ export interface BitbucketOptions extends PublishConfiguration { */ readonly owner: string + /** + * The access token to support auto-update from private bitbucket repositories. + */ + readonly token?: string | null + + /** + * The user name to support auto-update from private bitbucket repositories. + */ + readonly username?: string | null + /** * Repository slug/name */