Skip to content

Commit

Permalink
add more contextual information to next hook
Browse files Browse the repository at this point in the history
  • Loading branch information
hipstersmoothie committed May 29, 2020
1 parent 6abf4c2 commit daf7e84
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 4 deletions.
21 changes: 18 additions & 3 deletions packages/core/src/auto.ts
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,15 @@ interface BeforeShipitContext {
releaseType: ShipitRelease;
}

interface NextContext {
/** The commits in the next release */
commits: IExtendedCommit[];
/** The release notes for all the commits in the next release */
fullReleaseNotes: string;
/** The release notes for the last change merged to the next release */
releaseNotes: string;
}

type PublishResponse = RestEndpointMethodTypes["repos"]["createRelease"]["response"];

export interface IAutoHooks {
Expand Down Expand Up @@ -228,7 +237,7 @@ export interface IAutoHooks {
* and an array of next versions that been released. If you make another
* next release be sure to add it the the array.
*/
next: AsyncSeriesWaterfallHook<[string[], SEMVER]>;
next: AsyncSeriesWaterfallHook<[string[], SEMVER, NextContext]>;
/** Ran after the package has been published. */
afterPublish: AsyncParallelHook<[]>;
}
Expand Down Expand Up @@ -1240,7 +1249,9 @@ export default class Auto {
)
.split("\n")
.filter((line) => line.startsWith("-"));
const initialForkCommit = (forkPoints[forkPoints.length - 1] || "").slice(1);
const initialForkCommit = (forkPoints[forkPoints.length - 1] || "").slice(
1
);
const lastRelease =
initialForkCommit || (await this.git.getLatestRelease());
const lastTag =
Expand Down Expand Up @@ -1303,7 +1314,11 @@ export default class Auto {
}

this.logger.verbose.info(`Calling "next" hook with: ${bump}`);
const result = await this.hooks.next.promise([], bump);
const result = await this.hooks.next.promise([], bump, {
commits,
fullReleaseNotes,
releaseNotes,
});
const newVersion = result.join(", ");

await Promise.all(
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/utils/make-hooks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ export const makeHooks = (): IAutoHooks => ({
publish: new AsyncParallelHook(["version"]),
afterPublish: new AsyncParallelHook(),
canary: new AsyncSeriesBailHook(["canaryVersion", "postFix"]),
next: new AsyncSeriesWaterfallHook(["preReleaseVersions", "bump"]),
next: new AsyncSeriesWaterfallHook(["preReleaseVersions", "bump", "context"]),
});

/** Make the hooks for "Release" */
Expand Down

0 comments on commit daf7e84

Please sign in to comment.