UNPKG

3.83 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}
17export interface IChangelogHooks {
18 /** Change how the changelog renders lines. */
19 renderChangelogLine: AsyncSeriesWaterfallHook<[[IExtendedCommit, string]]>;
20 /** Change how the changelog renders titles */
21 renderChangelogTitle: AsyncSeriesBailHook<[string, {
22 [label: string]: string;
23 }], string | void>;
24 /** 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. */
25 renderChangelogAuthor: AsyncSeriesBailHook<[ICommitAuthor, IExtendedCommit, IGenerateReleaseNotesOptions], string | void>;
26 /** 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. */
27 renderChangelogAuthorLine: AsyncSeriesBailHook<[ICommitAuthor, string], string | void>;
28 /**
29 * Add extra content to your changelogs. This hook provide
30 * all the current "extra" notes and all of the commits for
31 * the changelog.
32 */
33 addToBody: AsyncSeriesWaterfallHook<[string[], IExtendedCommit[]]>;
34 /** Control what commits effect the additional release notes section. */
35 omitReleaseNotes: AsyncSeriesBailHook<[IExtendedCommit], boolean | void>;
36}
37/**
38 * Manages creating the "Release Notes" that are included in
39 * both the CHANGELOG.md and GitHub releases.
40 */
41export default class Changelog {
42 /** Plugin entry points */
43 readonly hooks: IChangelogHooks;
44 /** The options the changelog was initialized with */
45 readonly options: IGenerateReleaseNotesOptions;
46 /** The authors in the current changelog */
47 private authors?;
48 /** A logger that uses log levels */
49 private readonly logger;
50 /** Initialize the changelog generator with default hooks and labels */
51 constructor(logger: ILogger, options: IGenerateReleaseNotesOptions);
52 /** Load the default configuration */
53 loadDefaultHooks(): void;
54 /** Generate the release notes for a group of commits */
55 generateReleaseNotes(commits: IExtendedCommit[]): Promise<string>;
56 /** Create a link to a user for use in the changelog */
57 createUserLink(author: ICommitAuthor, commit: IExtendedCommit): string | undefined;
58 /** Split commits into changelogTitle sections. */
59 private splitCommits;
60 /** Get the default label for a label key */
61 private getFirstLabelNameFromLabelKey;
62 /** Create a list of users */
63 private createUserLinkList;
64 /** Transform a commit into a line in the changelog */
65 private generateCommitNote;
66 /** Get all the authors in the provided commits */
67 private getAllAuthors;
68 /** Create a section in the changelog to showcase contributing authors */
69 private createAuthorSection;
70 /** Create a section in the changelog to with all of the changelog notes organized by change type */
71 private createLabelSection;
72 /** Gather extra release notes to display at the top of the changelog */
73 private createReleaseNotesSection;
74}
75//# sourceMappingURL=changelog.d.ts.map
\No newline at end of file