UNPKG

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