nx
Version:
101 lines (100 loc) • 3.88 kB
TypeScript
export interface GitCommitAuthor {
name: string;
email: string;
}
export interface RawGitCommit {
message: string;
body: string;
shortHash: string;
author: GitCommitAuthor;
}
export interface Reference {
type: 'hash' | 'issue' | 'pull-request';
value: string;
}
export interface GitTagAndVersion {
tag: string;
extractedVersion: string;
}
export interface GitCommit extends RawGitCommit {
description: string;
type: string;
scope: string;
references: Reference[];
authors: GitCommitAuthor[];
isBreaking: boolean;
affectedFiles: string[];
revertedHashes: string[];
}
export interface GetLatestGitTagForPatternOptions {
checkAllBranchesWhen?: boolean | string[];
preid?: string;
releaseTagPatternRequireSemver: boolean;
releaseTagPatternStrictPreid: boolean;
}
/**
* Extract the tag and version from a tag string
*
* @param tag - The tag string to extract the tag and version from
* @param tagRegexp - The regex to use to extract the tag and version from the tag string
*
* @returns The tag and version
*/
export declare function extractTagAndVersion(tag: string, tagRegexp: string, options: GetLatestGitTagForPatternOptions): GitTagAndVersion;
/**
* Get the latest git tag for the configured release tag pattern.
*
* This function will:
* - Get all tags from the git repo, sorted by version
* - Filter the tags into a list with SEMVER-compliant tags, matching the release tag pattern
* - If a preid is provided, prioritise tags for that preid, then semver tags without a preid
* - If no preid is provided, search only for stable semver tags (i.e. no pre-release or build metadata)
*
* @param releaseTagPattern - The pattern to filter the tags list by
* @param additionalInterpolationData - Additional data used when interpolating the release tag pattern
* @param options - The options to use when getting the latest git tag for the pattern
*
* @returns The tag and version
*/
export declare function getLatestGitTagForPattern(releaseTagPattern: string, additionalInterpolationData: {}, options: GetLatestGitTagForPatternOptions): Promise<GitTagAndVersion | null>;
export declare function getGitDiff(from: string | undefined, to?: string): Promise<RawGitCommit[]>;
export declare function gitAdd({ changedFiles, deletedFiles, dryRun, verbose, logFn, cwd, }: {
changedFiles?: string[];
deletedFiles?: string[];
dryRun?: boolean;
verbose?: boolean;
cwd?: string;
logFn?: (...messages: string[]) => void;
}): Promise<string>;
export declare function gitCommit({ messages, additionalArgs, dryRun, verbose, logFn, }: {
messages: string[];
additionalArgs?: string | string[];
dryRun?: boolean;
verbose?: boolean;
logFn?: (message: string) => void;
}): Promise<string>;
export declare function gitTag({ tag, message, additionalArgs, dryRun, verbose, logFn, }: {
tag: string;
message?: string;
additionalArgs?: string | string[];
dryRun?: boolean;
verbose?: boolean;
logFn?: (message: string) => void;
}): Promise<string>;
export declare function gitPush({ gitRemote, dryRun, verbose, additionalArgs, }: {
gitRemote?: string;
dryRun?: boolean;
verbose?: boolean;
additionalArgs?: string | string[];
}): Promise<void>;
export declare function parseCommits(commits: RawGitCommit[]): GitCommit[];
export declare function parseConventionalCommitsMessage(message: string): {
type: string;
scope: string;
description: string;
breaking: boolean;
} | null;
export declare function extractReferencesFromCommit(commit: RawGitCommit): Reference[];
export declare function parseGitCommit(commit: RawGitCommit, isVersionPlanCommit?: boolean): GitCommit | null;
export declare function getCommitHash(ref: string): Promise<string>;
export declare function getFirstGitCommit(): Promise<string>;