UNPKG

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