UNPKG

6.09 kBTypeScriptView Raw
1import { AsyncSeriesBailHook, SyncHook } from 'tapable';
2import { ICreateLabelsOptions, IAuthorOptions, GlobalOptions } from './auto-args';
3import Changelog from './changelog';
4import Git from './git';
5import LogParse, { IExtendedCommit } from './log-parse';
6import SEMVER, { IVersionLabels } from './semver';
7import { ILogger } from './utils/logger';
8export declare type VersionLabel = SEMVER.major | SEMVER.minor | SEMVER.patch | 'skip' | 'release';
9export declare const releaseLabels: VersionLabel[];
10/** Determine if a label is a label used for versioning */
11export declare const isVersionLabel: (label: string) => label is VersionLabel;
12export declare type IAutoConfig = IAuthorOptions & GlobalOptions & {
13 /** The branch that is used as the base. defaults to master */
14 baseBranch: string;
15 /** Branches to create prereleases from */
16 prereleaseBranches: string[];
17 /** Instead of publishing every PR only publish when "release" label is present */
18 onlyPublishWithReleaseLabel?: boolean;
19 /** Whether to prefix the version with a "v" */
20 noVersionPrefix?: boolean;
21 /** Plugins to initialize "auto" with */
22 plugins?: (string | [string, number | boolean | string | object])[];
23 /** The labels configured by the user */
24 labels: ILabelDefinition[];
25};
26export interface ILabelDefinition {
27 /** The label text */
28 name: string;
29 /** A title to put in the changelog for the label */
30 changelogTitle?: string;
31 /** The color of the label */
32 color?: string;
33 /** The description of the label */
34 description?: string;
35 /** What type of release this label signifies */
36 releaseType: VersionLabel | 'none';
37 /** Whether to overwrite the base label */
38 overwrite?: boolean;
39}
40export declare const defaultLabels: ILabelDefinition[];
41/** Construct a map of label => semver label */
42export declare const getVersionMap: (labels?: ILabelDefinition[]) => IVersionLabels;
43export interface IReleaseHooks {
44 /** This is where you hook into the changelog's hooks. This hook is exposed for convenience on during `this.hooks.onCreateRelease` and at the root `this.hooks` */
45 onCreateChangelog: SyncHook<[Changelog, SEMVER | undefined]>;
46 /** Control the titles in the `CHANGELOG.md` */
47 createChangelogTitle: AsyncSeriesBailHook<[], string | void>;
48 /** This is where you hook into the LogParse's hooks. This hook is exposed for convenience on during `this.hooks.onCreateRelease` and at the root `this.hooks` */
49 onCreateLogParse: SyncHook<[LogParse]>;
50}
51/**
52 * Generate a GitHub graphql query to find all the commits related
53 * to a PR.
54 */
55export declare function buildSearchQuery(owner: string, project: string, commits: IExtendedCommit[]): string | undefined;
56/**
57 * A class for interacting with the git remote
58 */
59export default class Release {
60 /** Plugin entry points */
61 readonly hooks: IReleaseHooks;
62 /** Options Release was initialized with */
63 readonly config: IAutoConfig;
64 /** A class that handles interacting with git and GitHub */
65 private readonly git;
66 /** A logger that uses log levels */
67 private readonly logger;
68 /** The version bump being used during "shipit" */
69 private readonly versionLabels;
70 /** Initialize the release manager */
71 constructor(git: Git, config?: IAutoConfig, logger?: ILogger);
72 /** Make the class that will generate changelogs for the project */
73 makeChangelog(version?: SEMVER): Promise<Changelog>;
74 /**
75 * Generate a changelog from a range of commits.
76 *
77 * @param from - sha or tag to start changelog from
78 * @param to - sha or tag to end changelog at (defaults to HEAD)
79 */
80 generateReleaseNotes(from: string, to?: string, version?: SEMVER): Promise<string>;
81 /** Get all the commits that will be included in a release */
82 getCommitsInRelease(from: string, to?: string): Promise<IExtendedCommit[]>;
83 /** Update a changelog with a new set of release notes */
84 updateChangelogFile(title: string, releaseNotes: string, changelogPath: string): Promise<void>;
85 /**
86 * Prepend a set of release notes to the changelog.md
87 *
88 * @param releaseNotes - Release notes to prepend to the changelog
89 * @param lastRelease - Last release version of the code. Could be the first commit SHA
90 * @param currentVersion - Current version of the code
91 */
92 addToChangelog(releaseNotes: string, lastRelease: string, currentVersion: string): Promise<void>;
93 /**
94 * Get a range of commits. The commits will have PR numbers and labels attached
95 *
96 * @param from - Tag or SHA to start at
97 * @param to - Tag or SHA to end at (defaults to HEAD)
98 */
99 getCommits(from: string, to?: string): Promise<IExtendedCommit[]>;
100 /** Go through the configured labels and either add them to the project or update them */
101 addLabelsToProject(labels: ILabelDefinition[], options?: ICreateLabelsOptions): Promise<void>;
102 /**
103 * Calculate the SEMVER bump over a range of commits using the PR labels
104 *
105 * @param from - Tag or SHA to start at
106 * @param to - Tag or SHA to end at (defaults to HEAD)
107 */
108 getSemverBump(from: string, to?: string): Promise<SEMVER>;
109 /** Given a tag get the next incremented version */
110 calcNextVersion(lastTag: string): Promise<string | null>;
111 /** Create the class that will parse the log for PR info */
112 private createLogParse;
113 /** Get a the PRs that have been merged since the last GitHub release. */
114 private getPRsSinceLastRelease;
115 /**
116 * Add the PR info (labels and body) to the commit
117 *
118 * @param commit - Commit to modify
119 */
120 private addPrInfoToCommit;
121 /**
122 * Commits from rebased PRs do not have messages that tie them to a PR
123 * Instead we have to find all PRs since the last release and try to match
124 * their merge commit SHAs.
125 */
126 private getPRForRebasedCommits;
127 /** Parse the commit for information about the author and any other author that might have helped. */
128 private attachAuthor;
129}
130//# sourceMappingURL=release.d.ts.map
\No newline at end of file