UNPKG

1.83 kBTypeScriptView Raw
1import { Arch } from "builder-util";
2import { CancellationToken, PublishProvider } from "builder-util-runtime";
3import { Stats } from "fs-extra";
4import { ClientRequest } from "http";
5import { MultiProgress } from "./multiProgress";
6import { ProgressBar } from "./progress";
7export type PublishPolicy = "onTag" | "onTagOrDraft" | "always" | "never";
8export { ProgressCallback } from "./progress";
9export interface PublishOptions {
10 publish?: PublishPolicy | null;
11}
12export interface PublishContext {
13 readonly cancellationToken: CancellationToken;
14 readonly progress: MultiProgress | null;
15}
16export interface UploadTask {
17 file: string;
18 fileContent?: Buffer | null;
19 arch: Arch | null;
20 safeArtifactName?: string | null;
21 timeout?: number | null;
22}
23export declare abstract class Publisher {
24 protected readonly context: PublishContext;
25 protected constructor(context: PublishContext);
26 abstract get providerName(): PublishProvider;
27 abstract upload(task: UploadTask): Promise<any>;
28 protected createProgressBar(fileName: string, size: number): ProgressBar | null;
29 protected createReadStreamAndProgressBar(file: string, fileStat: Stats, progressBar: ProgressBar | null, reject: (error: Error) => void): NodeJS.ReadableStream;
30 abstract toString(): string;
31}
32export declare abstract class HttpPublisher extends Publisher {
33 protected readonly context: PublishContext;
34 private readonly useSafeArtifactName;
35 protected constructor(context: PublishContext, useSafeArtifactName?: boolean);
36 upload(task: UploadTask): Promise<any>;
37 protected abstract doUpload(fileName: string, arch: Arch, dataLength: number, requestProcessor: (request: ClientRequest, reject: (error: Error) => void) => void, file: string): Promise<any>;
38}
39export declare function getCiTag(): string | null;