cnpmcore
Version:
34 lines (33 loc) • 1.49 kB
TypeScript
import { ImplDecorator } from '@eggjs/tegg';
import { BinaryType } from '../../enum/Binary';
import { EggHttpClient, EggLogger } from 'egg';
import { BinaryName, BinaryTaskConfig } from '../../../../config/binaries';
export type BinaryItem = {
name: string;
isDir: boolean;
url: string;
size: string | number;
date: string;
ignoreDownloadStatuses?: number[];
};
export type FetchResult = {
items: BinaryItem[];
nextParams?: any;
};
declare const platforms: readonly ["darwin", "linux", "win32"];
export declare const BINARY_ADAPTER_ATTRIBUTE: unique symbol;
export declare abstract class AbstractBinary {
protected logger: EggLogger;
protected httpclient: EggHttpClient;
abstract initFetch(binaryName: BinaryName): Promise<void>;
abstract fetch(dir: string, binaryName: BinaryName): Promise<FetchResult | undefined>;
finishFetch(_success: boolean, _binaryName: BinaryName): Promise<void>;
protected requestXml(url: string): Promise<string>;
protected requestJSON(url: string, requestHeaders?: Record<string, string>): Promise<any>;
protected listNodeABIVersions(): Promise<number[]>;
protected listNodePlatforms(): readonly ["darwin", "linux", "win32"];
protected listNodeArchs(binaryConfig?: BinaryTaskConfig): Record<string, readonly string[]>;
protected listNodeLibcs(): Record<typeof platforms[number], string[]>;
}
export declare const BinaryAdapter: ImplDecorator<AbstractBinary, typeof BinaryType>;
export {};