Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add ability to specify bintray user #855

Merged
merged 3 commits into from
Oct 27, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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