Skip to content

Commit 716ebc6

Browse files
jimm1419develar
authored andcommitted
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
1 parent 74e2006 commit 716ebc6

File tree

5 files changed

+12
-4
lines changed

5 files changed

+12
-4
lines changed

docs/Options.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -222,6 +222,7 @@ Array of option objects.
222222
| --- | ---
223223
| package | <a name="BintrayOptions-package"></a>The Bintray package name.
224224
| repo | <a name="BintrayOptions-repo"></a>The Bintray repository name. Defaults to `generic`.
225+
| user | <a name="BintrayOptions-user"></a>The Bintray user account. Used in cases where the owner is an organization.
225226

226227
<a name="GithubOptions"></a>
227228
### `.build.publish` GitHub

src/builder.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -290,7 +290,7 @@ export async function createPublisher(packager: Packager, publishConfig: Publish
290290
}
291291
if (publishConfig.provider === "bintray") {
292292
const bintrayInfo: BintrayOptions = config
293-
log(`Creating Bintray Publisher — user: ${bintrayInfo.owner}, package: ${bintrayInfo.package}, repository: ${bintrayInfo.repo}, version: ${version}`)
293+
log(`Creating Bintray Publisher — user: ${bintrayInfo.user || bintrayInfo.owner}, owner: ${bintrayInfo.owner}, package: ${bintrayInfo.package}, repository: ${bintrayInfo.repo}, version: ${version}`)
294294
return new BintrayPublisher(bintrayInfo, version, options)
295295
}
296296
return null

src/options/publishOptions.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,4 +50,9 @@ export interface BintrayOptions extends PublishConfiguration {
5050
The Bintray repository name. Defaults to `generic`.
5151
*/
5252
repo?: string
53+
54+
/*
55+
The Bintray user account. Used in cases where the owner is an organization.
56+
*/
57+
user?: string
5358
}

src/publish/BintrayPublisher.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ export class BintrayPublisher implements Publisher {
2323
}
2424
}
2525

26-
this.client = new BintrayClient(info.owner!, info.package!, info.repo, token)
26+
this.client = new BintrayClient(info.owner!, info.package!, info.repo, token, info.user!)
2727
this._versionPromise = <BluebirdPromise<Version>>this.init()
2828
}
2929

src/publish/bintray.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,9 @@ export class BintrayClient {
1818
private readonly basePath: string
1919
readonly auth: string | null
2020
readonly repo: string
21+
readonly user: string
2122

22-
constructor(public owner: string, public packageName: string, repo?: string, apiKey?: string | null) {
23+
constructor(public owner: string, public packageName: string, repo?: string, apiKey?: string | null, user?: string | null) {
2324
if (owner == null) {
2425
throw new Error("owner is not specified")
2526
}
@@ -28,7 +29,8 @@ export class BintrayClient {
2829
}
2930

3031
this.repo = repo || "generic"
31-
this.auth = apiKey == null ? null : `Basic ${new Buffer(`${owner}:${apiKey}`).toString("base64")}`
32+
this.user = user || owner
33+
this.auth = apiKey == null ? null : `Basic ${new Buffer(`${this.user}:${apiKey}`).toString("base64")}`
3234
this.basePath = `/packages/${this.owner}/${this.repo}/${this.packageName}`
3335
}
3436

0 commit comments

Comments
 (0)