UNPKG

3.95 kBTypeScriptView Raw
1import { AsyncSeriesBailHook, AsyncSeriesWaterfallHook } from "tapable";
2import { ICommitAuthor, IExtendedCommit } from "./log-parse";
3import { ILabelDefinition } from "./release";
4import { ILogger } from "./utils/logger";
5export interface IGenerateReleaseNotesOptions {
6 /** Github repo owner (user) */
7 owner: string;
8 /** GitHub project to operate on */
9 repo: string;
10 /** The URL to the GitHub (public or enterprise) the project is using */
11 baseUrl: string;
12 /** The labels configured by the user */
13 labels: ILabelDefinition[];
14 /** The branch that is used as the base. defaults to master */
15 baseBranch: string;
16 /** The branches that is used as prerelease branches. defaults to next */
17 prereleaseBranches: string[];
18}
19export interface IChangelogHooks {
20 /** Change how the changelog renders lines. */
21 renderChangelogLine: AsyncSeriesWaterfallHook<[[IExtendedCommit, string]]>;
22 /** Change how the changelog renders titles */
23 renderChangelogTitle: AsyncSeriesBailHook<[string, {
24 [label: string]: string;
25 }], string | void>;
26 /** Change how the changelog renders authors. This is both the author on each commit note and the user in the author section (the part between parentheses). This is generally a link to some profile. */
27 renderChangelogAuthor: AsyncSeriesBailHook<[ICommitAuthor, IExtendedCommit, IGenerateReleaseNotesOptions], string | void>;
28 /** Change how the changelog renders authors in the authors section. The hook provides the author object and the user created with `renderChangelogAuthor`. Here is where you might display extra info about the author, such as their full name. */
29 renderChangelogAuthorLine: AsyncSeriesBailHook<[ICommitAuthor, string], string | void>;
30 /**
31 * Add extra content to your changelogs. This hook provide
32 * all the current "extra" notes and all of the commits for
33 * the changelog.
34 */
35 addToBody: AsyncSeriesWaterfallHook<[string[], IExtendedCommit[]]>;
36 /** Control what commits effect the additional release notes section. */
37 omitReleaseNotes: AsyncSeriesBailHook<[IExtendedCommit], boolean | void>;
38}
39/**
40 * Manages creating the "Release Notes" that are included in
41 * both the CHANGELOG.md and GitHub releases.
42 */
43export default class Changelog {
44 /** Plugin entry points */
45 readonly hooks: IChangelogHooks;
46 /** The options the changelog was initialized with */
47 readonly options: IGenerateReleaseNotesOptions;
48 /** The authors in the current changelog */
49 private authors?;
50 /** A logger that uses log levels */
51 private readonly logger;
52 /** Initialize the changelog generator with default hooks and labels */
53 constructor(logger: ILogger, options: IGenerateReleaseNotesOptions);
54 /** Load the default configuration */
55 loadDefaultHooks(): void;
56 /** Generate the release notes for a group of commits */
57 generateReleaseNotes(commits: IExtendedCommit[]): Promise<string>;
58 /** Create a link to a user for use in the changelog */
59 createUserLink(author: ICommitAuthor, commit: IExtendedCommit): string | undefined;
60 /** Split commits into changelogTitle sections. */
61 private splitCommits;
62 /** Get the default label for a label key */
63 private getFirstLabelNameFromLabelKey;
64 /** Create a list of users */
65 private createUserLinkList;
66 /** Transform a commit into a line in the changelog */
67 private generateCommitNote;
68 /** Get all the authors in the provided commits */
69 private getAllAuthors;
70 /** Create a section in the changelog to showcase contributing authors */
71 private createAuthorSection;
72 /** Create a section in the changelog to with all of the changelog notes organized by change type */
73 private createLabelSection;
74 /** Gather extra release notes to display at the top of the changelog */
75 private createReleaseNotesSection;
76}
77//# sourceMappingURL=changelog.d.ts.map
\No newline at end of file