takin
Version:
Front end engineering base toolchain and scaffold
69 lines (68 loc) • 1.84 kB
TypeScript
export interface GitRepoInfo {
site: string;
user: string;
name: string;
ref: string;
hash?: string;
url: string;
ssh: string;
subdir?: string;
mode: GitDownloadModes;
}
/**
* Git 站点配置
*/
export interface GitSiteConfig {
/**
* 站点类型
*/
type: GitSiteType;
/**
* 生成 tar url 链接
*/
generateGitTarUrl?: GenerateGitTarUrl;
}
declare type GenerateGitTarUrl = (repo: GitRepoInfo) => Promise<{
url: string;
strip: number;
[k: string]: any;
}>;
export declare type GitDownloadModes = 'tar' | 'git';
export declare type GitSiteType = 'github' | 'gitlab' | 'bitbucket';
/**
* 添加支持的 git 站点
* @param siteUrl - 站点地址, 如 github.com
* @param siteType - 站点类型, 如 git / gitlab / bitbucket
*/
export declare function addSupportGitSite(siteUrl: string, siteConfig: GitSiteConfig): void;
export declare function getGitHash(repo: GitRepoInfo): Promise<string | void>;
/**
* 解析 git 选项或链接
* @param urlOrOptions - git 下载链接或选项
* @returns git 仓库信息
*/
export declare function parseOptions(urlOrOptions: string | (GitRepoInfo & {
branch?: string;
commit?: string;
tag?: string;
})): GitRepoInfo;
/**
* 判断是否支持处理当前链接
* @param url - 链接
* @returns 是否支持该链接
*/
export declare function supportProtocol(url: string): boolean;
/**
* 从 git 仓库选项中获取名称
* @param options - git 仓库选项
* @returns 名称
*/
export declare function getName(options: GitRepoInfo): string;
/**
* 下载 git repo 到指定的目录
* @param options - git 选项
* @param dest - 下载目录
* @returns 下载并解压后的目录
*/
export declare function download(options: GitRepoInfo, dest: string): Promise<void>;
export {};