Skip to content

Commit

Permalink
feat: add ability to specify bintray user
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
jimm1419 authored and develar committed Oct 27, 2016
1 parent 74e2006 commit 716ebc6
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 4 deletions.
1 change: 1 addition & 0 deletions docs/Options.md
Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,7 @@ Array of option objects.
| --- | ---
| package | <a name="BintrayOptions-package"></a>The Bintray package name.
| repo | <a name="BintrayOptions-repo"></a>The Bintray repository name. Defaults to `generic`.
| user | <a name="BintrayOptions-user"></a>The Bintray user account. Used in cases where the owner is an organization.

<a name="GithubOptions"></a>
### `.build.publish` GitHub
Expand Down
2 changes: 1 addition & 1 deletion src/builder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 5 additions & 0 deletions src/options/publishOptions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
2 changes: 1 addition & 1 deletion src/publish/BintrayPublisher.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 = <BluebirdPromise<Version>>this.init()
}

Expand Down
6 changes: 4 additions & 2 deletions src/publish/bintray.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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")
}
Expand All @@ -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}`
}

Expand Down

0 comments on commit 716ebc6

Please sign in to comment.