@dev-build-deploy/commit-it
Version:
(Conventional) Commits library
97 lines (96 loc) • 3.27 kB
TypeScript
import { DiagnosticsMessage } from "@dev-build-deploy/diagnose-it";
import { Commit } from "./commit";
/**
* Conventional Commit options
* @interface IConventionalCommitOptions
* @member scopes List of scopes to use when validating the commit message
* @member types List of types to use when validating the commit message (NOTE: always includes "feat" and "fix")
*/
export interface IConventionalCommitOptions {
scopes?: string[];
types?: string[];
}
/**
* Conventional Commit
* @class ConventionalCommit
* @member type Conventional Commit type
* @member scope Conventional Commit scope
* @member breaking Commit message has a Conventional Commit breaking change (!)
* @member description Conventional Commit description
* @member hash Commit hash
* @member subject Commit subject
* @member body Commit body
* @member footer Commit footer
* @member author Commit author and date
* @member committer Commit committer and date
* @member isValid Whether the Conventional Commit is valid
* @member errors List of error messages
* @member warnings List of warning messages
*/
export declare class ConventionalCommit {
private _raw;
private _errors;
private _warnings;
private constructor();
/**
* Creates a new Conventional Commit object from the provided Commit.
* @param commit Commit to convert to a Conventional Commit
* @param options Options to use when validating the commit message
* @returns Conventional Commit
*/
static fromCommit(commit: Commit, options?: IConventionalCommitOptions): ConventionalCommit;
/**
* Creates a new Conventional Commit object from the provided string.
* @param props Hash, message and author/committer information
* @param options Options to use when validating the commit message
* @returns Conventional Commit
*/
static fromString(props: {
hash: string;
message: string;
author?: {
name: string;
date: Date;
};
committer?: {
name: string;
date: Date;
};
}, options?: IConventionalCommitOptions): ConventionalCommit;
/**
* Creates a new Conventional Commit object from the provided hash.
* @param props Hash and root path
* @param options Options to use when validating the commit message
* @returns Conventional Commit
*/
static fromHash(props: {
hash: string;
rootPath?: string;
}, options?: IConventionalCommitOptions): ConventionalCommit;
get author(): {
name: string;
date: Date;
} | undefined;
get committer(): {
name: string;
date: Date;
} | undefined;
get hash(): string;
get subject(): string;
get body(): string | undefined;
get footer(): Record<string, string> | undefined;
get type(): string | undefined;
get scope(): string | undefined;
get description(): string | undefined;
get breaking(): boolean;
get isFixupCommit(): boolean;
get isMergeCommit(): boolean;
get raw(): string;
get isValid(): boolean;
get warnings(): DiagnosticsMessage[];
get errors(): DiagnosticsMessage[];
toJSON(): {
[key: string]: unknown;
};
private validate;
}