From 716ebc639cef79ab19c8390974c45b9e2f8172b0 Mon Sep 17 00:00:00 2001 From: jimm1419 Date: Thu, 27 Oct 2016 11:38:53 -0700 Subject: [PATCH] feat: add ability to specify bintray user * fix: bintray configuration support for organizations Added a user field to BintrayOptions to use for bintray authentication instead of the 'owner' field. Closes #848 * chore: update bintray log message to output correct user The log message outputs the correct user being used to hit the bintray API, 'user' field if defined, if not 'owner'. #848 --- docs/Options.md | 1 + src/builder.ts | 2 +- src/options/publishOptions.ts | 5 +++++ src/publish/BintrayPublisher.ts | 2 +- src/publish/bintray.ts | 6 ++++-- 5 files changed, 12 insertions(+), 4 deletions(-) diff --git a/docs/Options.md b/docs/Options.md index 476d66efb3f..d1ee32d786c 100644 --- a/docs/Options.md +++ b/docs/Options.md @@ -222,6 +222,7 @@ Array of option objects. | --- | --- | package | The Bintray package name. | repo | The Bintray repository name. Defaults to `generic`. +| user | The Bintray user account. Used in cases where the owner is an organization. ### `.build.publish` GitHub diff --git a/src/builder.ts b/src/builder.ts index 17f446a0f3b..99cac984f68 100644 --- a/src/builder.ts +++ b/src/builder.ts @@ -290,7 +290,7 @@ export async function createPublisher(packager: Packager, publishConfig: Publish } if (publishConfig.provider === "bintray") { const bintrayInfo: BintrayOptions = config - log(`Creating Bintray Publisher — user: ${bintrayInfo.owner}, package: ${bintrayInfo.package}, repository: ${bintrayInfo.repo}, version: ${version}`) + log(`Creating Bintray Publisher — user: ${bintrayInfo.user || bintrayInfo.owner}, owner: ${bintrayInfo.owner}, package: ${bintrayInfo.package}, repository: ${bintrayInfo.repo}, version: ${version}`) return new BintrayPublisher(bintrayInfo, version, options) } return null diff --git a/src/options/publishOptions.ts b/src/options/publishOptions.ts index 3b38442a0a2..296b2fbfbd0 100644 --- a/src/options/publishOptions.ts +++ b/src/options/publishOptions.ts @@ -50,4 +50,9 @@ export interface BintrayOptions extends PublishConfiguration { The Bintray repository name. Defaults to `generic`. */ repo?: string + + /* + The Bintray user account. Used in cases where the owner is an organization. + */ + user?: string } \ No newline at end of file diff --git a/src/publish/BintrayPublisher.ts b/src/publish/BintrayPublisher.ts index a7b51d1c758..cd40b1dffc2 100644 --- a/src/publish/BintrayPublisher.ts +++ b/src/publish/BintrayPublisher.ts @@ -23,7 +23,7 @@ export class BintrayPublisher implements Publisher { } } - this.client = new BintrayClient(info.owner!, info.package!, info.repo, token) + this.client = new BintrayClient(info.owner!, info.package!, info.repo, token, info.user!) this._versionPromise = >this.init() } diff --git a/src/publish/bintray.ts b/src/publish/bintray.ts index cc037e3c1af..e78e0903cb1 100644 --- a/src/publish/bintray.ts +++ b/src/publish/bintray.ts @@ -18,8 +18,9 @@ export class BintrayClient { private readonly basePath: string readonly auth: string | null readonly repo: string + readonly user: string - constructor(public owner: string, public packageName: string, repo?: string, apiKey?: string | null) { + constructor(public owner: string, public packageName: string, repo?: string, apiKey?: string | null, user?: string | null) { if (owner == null) { throw new Error("owner is not specified") } @@ -28,7 +29,8 @@ export class BintrayClient { } this.repo = repo || "generic" - this.auth = apiKey == null ? null : `Basic ${new Buffer(`${owner}:${apiKey}`).toString("base64")}` + this.user = user || owner + this.auth = apiKey == null ? null : `Basic ${new Buffer(`${this.user}:${apiKey}`).toString("base64")}` this.basePath = `/packages/${this.owner}/${this.repo}/${this.packageName}` }