Skip to content

Commit

Permalink
refactor: update Bitbucket publisher (#6400)
Browse files Browse the repository at this point in the history
- use fs-extra to support Node < v14
- optional config options for Token and Username (Bitbucket Private Repos)
  • Loading branch information
jbool24 authored Nov 9, 2021
1 parent f41d5f3 commit 66ca625
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 3 deletions.
8 changes: 8 additions & 0 deletions .changeset/spotty-clouds-invent.md
Original file line number Diff line number Diff line change
@@ -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)

6 changes: 3 additions & 3 deletions packages/app-builder-lib/src/publish/BitbucketPublisher.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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)`)
Expand Down
10 changes: 10 additions & 0 deletions packages/builder-util-runtime/src/publishOptions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
*/
Expand Down

0 comments on commit 66ca625

Please sign in to comment.