1 | import { AsyncSeriesBailHook, SyncHook } from 'tapable';
|
2 | import Changelog from './changelog';
|
3 | import { ICreateLabelsCommandOptions } from './cli/args';
|
4 | import Git from './git';
|
5 | import LogParse, { IExtendedCommit } from './log-parse';
|
6 | import SEMVER from './semver';
|
7 | import { ILogger } from './utils/logger';
|
8 | export declare type VersionLabel = SEMVER.major | SEMVER.minor | SEMVER.patch | 'skip-release' | 'release' | 'prerelease';
|
9 | export declare const defaultLabels: VersionLabel[];
|
10 | export declare const isVersionLabel: (label: string) => label is VersionLabel;
|
11 | export interface IReleaseOptions {
|
12 | jira?: string;
|
13 | slack?: string;
|
14 | githubApi?: string;
|
15 | baseBranch: string;
|
16 | githubGraphqlApi?: string;
|
17 | name?: string;
|
18 | email?: string;
|
19 | owner?: string;
|
20 | repo?: string;
|
21 | skipReleaseLabels: string[];
|
22 | onlyPublishWithReleaseLabel?: boolean;
|
23 | noVersionPrefix?: boolean;
|
24 | plugins?: (string | [string, any])[];
|
25 | labels: ILabelDefinitionMap;
|
26 | }
|
27 | export interface ILabelDefinition {
|
28 | name: string;
|
29 | title?: string;
|
30 | color?: string;
|
31 | description?: string;
|
32 | }
|
33 | export interface ILabelDefinitionMap {
|
34 | [label: string]: ILabelDefinition;
|
35 | }
|
36 | export declare const defaultLabelDefinition: ILabelDefinitionMap;
|
37 | export declare const getVersionMap: (labels?: ILabelDefinitionMap) => Map<VersionLabel, string>;
|
38 | export interface IReleaseHooks {
|
39 | onCreateChangelog: SyncHook<[Changelog]>;
|
40 | createChangelogTitle: AsyncSeriesBailHook<[], string | void>;
|
41 | onCreateLogParse: SyncHook<[LogParse]>;
|
42 | }
|
43 |
|
44 |
|
45 |
|
46 | export default class Release {
|
47 | readonly options: IReleaseOptions;
|
48 | readonly hooks: IReleaseHooks;
|
49 | private readonly git;
|
50 | private readonly logger;
|
51 | private readonly versionLabels;
|
52 | constructor(git: Git, options?: IReleaseOptions, logger?: ILogger);
|
53 | /**
|
54 | * Generate a changelog from a range of commits.
|
55 | *
|
56 | * @param from sha or tag to start changelog from
|
57 | * @param to sha or tag to end changelog at (defaults to HEAD)
|
58 | */
|
59 | generateReleaseNotes(from: string, to?: string): Promise<string>;
|
60 | buildSearchQuery(commits: IExtendedCommit[]): string | undefined;
|
61 | getCommitsInRelease(from: string, to?: string): Promise<IExtendedCommit[]>;
|
62 | /**
|
63 | * Prepend a set of release notes to the changelog.md
|
64 | *
|
65 | * @param releaseNotes Release notes to prepend to the changelog
|
66 | * @param lastRelease Last release version of the code. Could be the first commit SHA
|
67 | * @param currentVersion Current version of the code
|
68 | * @param message Message to commit the changelog with
|
69 | */
|
70 | addToChangelog(releaseNotes: string, lastRelease: string, currentVersion: string, message?: string): Promise<void>;
|
71 | /**
|
72 | * Get a range of commits. The commits will have PR numbers and labels attached
|
73 | *
|
74 | * @param from Tag or SHA to start at
|
75 | * @param to Tage or SHA to end at (defaults to HEAD)
|
76 | */
|
77 | getCommits(from: string, to?: string): Promise<IExtendedCommit[]>;
|
78 | addLabelsToProject(labels: Partial<ILabelDefinitionMap>, options?: ICreateLabelsCommandOptions): Promise<void>;
|
79 | /**
|
80 | * Calculate the SEMVER bump over a range of commits using the PR labels
|
81 | *
|
82 | * @param from Tag or SHA to start at
|
83 | * @param to Tag or SHA to end at (defaults to HEAD)
|
84 | */
|
85 | getSemverBump(from: string, to?: string): Promise<SEMVER>;
|
86 | /**
|
87 | * Post the release notes to slack.
|
88 | *
|
89 | * @param releaseNotes Release notes to post to slack
|
90 | * @param tag Version to include in the title of the slack message
|
91 | */
|
92 | postToSlack(releaseNotes: string, tag: string): Promise<void>;
|
93 | calcNextVersion(lastTag: string): Promise<string | null>;
|
94 | private createLogParse;
|
95 | private getPRsSinceLastRelease;
|
96 | /**
|
97 | * Add the PR info (labels and body) to the commit
|
98 | *
|
99 | * @param commits Commits to modify
|
100 | */
|
101 | private addPrInfoToCommit;
|
102 | /**
|
103 | * Commits from rebased PRs do not have messages that tie them to a PR
|
104 | * Instead we have to find all PRs since the last release and try to match
|
105 | * their merge commit SHAs.
|
106 | *
|
107 | * @param commits Commits to modify
|
108 | */
|
109 | private getPRForRebasedCommits;
|
110 | }
|