UNPKG

4.22 kBTypeScriptView Raw
1declare module "electron-builder-publisher/out/multiProgress" {
2
3 export class MultiProgress {
4 private readonly stream
5 private cursor
6 private totalLines
7 private isLogListenerAdded
8 private barCount
9 createBar(format: string, options: any): any
10 private allocateLines(count)
11 private moveCursor(index)
12 terminate(): void
13 }
14}
15
16declare module "electron-builder-publisher" {
17 /// <reference types="node" />
18 import { ClientRequest } from "http"
19 import { Stats } from "fs-extra-p"
20 import ProgressBar from "progress-ex"
21 import { MultiProgress } from "electron-builder-publisher/out/multiProgress"
22 import { CancellationToken } from "electron-builder-http/out/CancellationToken"
23 export type PublishPolicy = "onTag" | "onTagOrDraft" | "always" | "never"
24
25 export interface PublishOptions {
26 publish?: PublishPolicy | null
27 draft?: boolean
28 prerelease?: boolean
29 }
30
31 export interface PublishContext {
32 readonly cancellationToken: CancellationToken
33 readonly progress: MultiProgress | null
34 }
35
36 export abstract class Publisher {
37 protected readonly context: PublishContext
38 constructor(context: PublishContext)
39 readonly abstract providerName: string
40 abstract upload(file: string, safeArtifactName?: string): Promise<any>
41 protected createProgressBar(fileName: string, fileStat: Stats): ProgressBar | null
42 protected createReadStreamAndProgressBar(file: string, fileStat: Stats, progressBar: ProgressBar | null, reject: (error: Error) => void): NodeJS.ReadableStream
43 abstract toString(): string
44 }
45
46 export abstract class HttpPublisher extends Publisher {
47 protected readonly context: PublishContext
48 private readonly useSafeArtifactName
49 constructor(context: PublishContext, useSafeArtifactName?: boolean)
50 upload(file: string, safeArtifactName?: string): Promise<any>
51 uploadData(data: Buffer, fileName: string): Promise<any>
52 protected abstract doUpload(fileName: string, dataLength: number, requestProcessor: (request: ClientRequest, reject: (error: Error) => void) => void, file?: string): Promise<any>
53 }
54}
55
56declare module "electron-builder-publisher/out/BintrayPublisher" {
57 /// <reference types="node" />
58 import { BintrayOptions } from "electron-builder-http/out/publishOptions"
59 import { ClientRequest } from "http"
60 import { HttpPublisher, PublishContext, PublishOptions } from "electron-builder-publisher"
61
62 export class BintrayPublisher extends HttpPublisher {
63 private readonly version
64 private readonly options
65 private _versionPromise
66 private readonly client
67 readonly providerName: string
68 constructor(context: PublishContext, info: BintrayOptions, version: string, options?: PublishOptions)
69 private init()
70 protected doUpload(fileName: string, dataLength: number, requestProcessor: (request: ClientRequest, reject: (error: Error) => void) => void): Promise<any>
71 deleteRelease(): Promise<any>
72 toString(): string
73 }
74}
75
76declare module "electron-builder-publisher/out/gitHubPublisher" {
77 /// <reference types="node" />
78 import { GithubOptions } from "electron-builder-http/out/publishOptions"
79 import { ClientRequest } from "http"
80 import { HttpPublisher, PublishContext, PublishOptions } from "electron-builder-publisher"
81
82 export interface Release {
83 id: number
84 tag_name: string
85 draft: boolean
86 prerelease: boolean
87 published_at: string
88 upload_url: string
89 }
90
91 export class GitHubPublisher extends HttpPublisher {
92 private readonly info
93 private readonly version
94 private readonly options
95 private tag
96 private _releasePromise
97 private readonly token
98 readonly providerName: string
99 readonly releasePromise: Promise<Release | null>
100 constructor(context: PublishContext, info: GithubOptions, version: string, options?: PublishOptions)
101 private getOrCreateRelease()
102 protected doUpload(fileName: string, dataLength: number, requestProcessor: (request: ClientRequest, reject: (error: Error) => void) => void): Promise<void>
103 private createRelease()
104 getRelease(): Promise<any>
105 deleteRelease(): Promise<any>
106 private githubRequest<T>(path, token, data?, method?)
107 toString(): string
108 }
109}
110