forked from electron-userland/electron-builder
-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
14 changed files
with
240 additions
and
85 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import { bintrayRequest } from "./restApiRequest" | ||
|
||
//noinspection ReservedWordAsName | ||
export interface Version { | ||
readonly name: string | ||
readonly package: string | ||
} | ||
|
||
export class BintrayClient { | ||
private readonly basePath: string | ||
readonly auth: string | null | ||
|
||
constructor(private user: string, private packageName: string, private repo: string = "generic", apiKey?: string | null) { | ||
this.auth = apiKey == null ? null : `Basic ${new Buffer(`${user}:${apiKey}`).toString("base64")}` | ||
this.basePath = `/packages/${this.user}/${this.repo}/${this.packageName}` | ||
} | ||
|
||
getVersion(version: string): Promise<Version> { | ||
return bintrayRequest<Version>(`${this.basePath}/versions/${version}`, this.auth) | ||
} | ||
|
||
createVersion(version: string): Promise<any> { | ||
return bintrayRequest<Version>(`${this.basePath}/versions`, this.auth, { | ||
name: version, | ||
}) | ||
} | ||
|
||
deleteVersion(version: string): Promise<any> { | ||
return bintrayRequest(`/packages/${this.user}/${this.repo}/${this.packageName}/versions/${version}`, this.auth, null, "DELETE") | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import progressStream = require("progress-stream") | ||
import ProgressBar = require("progress") | ||
import { createReadStream, Stats } from "fs-extra-p" | ||
import { ReadStream } from "tty" | ||
import { ClientRequest } from "http" | ||
|
||
export function uploadFile(file: string, fileStat: Stats, fileName: string, request: ClientRequest, reject: (error: Error) => void) { | ||
const progressBar = (<ReadStream>process.stdin).isTTY ? new ProgressBar(`Uploading ${fileName} [:bar] :percent :etas`, { | ||
total: fileStat.size, | ||
incomplete: " ", | ||
stream: process.stdout, | ||
width: 20, | ||
}) : null | ||
|
||
const fileInputStream = createReadStream(file) | ||
fileInputStream.on("error", reject) | ||
fileInputStream | ||
.pipe(progressStream({ | ||
length: fileStat.size, | ||
time: 1000 | ||
}, progress => { | ||
if (progressBar != null) { | ||
progressBar.tick(progress.delta) | ||
} | ||
})) | ||
.pipe(request) | ||
} |
Oops, something went wrong.