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