@eljs/utils
Version:
Collection of nodejs utility.
143 lines • 3.51 kB
TypeScript
import { type RunCommandOptions } from "../cp";
/**
* git 远程仓库信息
*/
export interface GitRemoteRepository {
/**
* git 仓库名称
*/
name: string;
/**
* git 仓库所属的组
*/
group: string;
/**
* git 网页地址
*/
href: string;
/**
* git https url
*/
https: string;
/**
* git ssh url
*/
ssh: string;
}
/**
* git 仓库信息
*/
export interface GitRepository extends GitRemoteRepository {
/**
* git 仓库分支
*/
branch: string;
/**
* git 仓库作者
*/
author: string;
/**
* 仓库邮箱
*/
email: string;
}
/**
* 获取 git 地址
* @param cwd 当前工作目录
* @param exact 是否在当前目录下提取
*/
export declare function getGitUrl(cwd: string, exact?: boolean): Promise<string>;
/**
* 获取 git 地址
* @param cwd 当前工作目录
* @param exact 是否在当前目录下提取
*/
export declare function getGitUrlSync(cwd: string, exact?: boolean): string;
/**
* 获取 git 分支
* @param options 选项
*/
export declare function getGitBranch(options?: RunCommandOptions): Promise<string>;
/**
* 获取 git 远程分支
* @param options 选项
*/
export declare function getGitUpstreamBranch(options?: RunCommandOptions): Promise<string | null>;
/**
* 获取 git commit 哈希值
* @param options 选项
*/
export declare function getGitCommitSha(options?: RunCommandOptions): Promise<string>;
/**
* 获取 git commit 哈希值
* @param short 是否截断
* @param options 选项
*/
export declare function getGitCommitSha(short: boolean, options?: RunCommandOptions): Promise<string>;
/**
* 获取 git 最新 tag
* @param options 选项
*/
export declare function getGitLatestTag(options?: RunCommandOptions): Promise<string>;
/**
* 获取 git 最新 tag
* @param match 匹配模式
* @param options 选项
*/
export declare function getGitLatestTag(match: string, options?: RunCommandOptions): Promise<string>;
/**
* 获取 git 最新 tag
* @param match 匹配模式
* @param args 命令行参数
* @param options 选项
*/
export declare function getGitLatestTag(match: string, args: string[], options?: RunCommandOptions): Promise<string | null>;
/**
* 解析 git 地址
* @param url git 地址
*/
export declare function gitUrlAnalysis(url: string): GitRemoteRepository | null;
/**
* 获取指定目录的 git 仓库信息
* @param dir 文件目录
* @param exact 是否在当前目录下提取
*/
export declare function getGitRepository(dir: string, exact?: boolean): Promise<GitRepository | null>;
/**
* 获取指定目录的 git 仓库信息
* @param dir 文件目录
* @param exact 是否在当前目录下提取
*/
export declare function getGitRepositorySync(dir: string, exact?: boolean): GitRepository | null;
/**
* git 用户
*/
export interface GitUser {
/**
* 用户名
*/
name: string;
/**
* 用户邮箱
*/
email: string;
}
/**
* 获取 git 用户
*/
export declare function getGitUser(): Promise<GitUser>;
/**
* 获取 git 用户
*/
export declare function getGitUserSync(): GitUser;
/**
* 获取工程 git 路径
* @param dir 文件夹目录
*/
export declare function getProjectGitDir(dir: string): Promise<string | undefined>;
/**
* 获取工程 git 路径
* @param dir 文件目录
*/
export declare function getProjectGitDirSync(dir: string): string | undefined;
//# sourceMappingURL=meta.d.ts.map