11const { compose } = require ( 'ramda' ) ;
2- const { wrapPlugin } = require ( 'semantic-release-plugin-decorators' ) ;
2+ const {
3+ wrapPlugin,
4+ appendMultiPlugin,
5+ } = require ( 'semantic-release-plugin-decorators' ) ;
36const pluginDefinitions = require ( 'semantic-release/lib/definitions/plugins' ) ;
47
58const { parse } = require ( './comment-tag' ) ;
@@ -12,7 +15,7 @@ const withMatchingPullRequests = require('./with-matching-pull-requests');
1215
1316const NAMESPACE = 'githubPr' ;
1417
15- const decoratePlugins = compose (
18+ const decoratePlugin = compose (
1619 withGithub ,
1720 withGitHead ,
1821 withMatchingPullRequests ,
@@ -25,14 +28,14 @@ const decoratePlugins = compose(
2528const analyzeCommits = wrapPlugin (
2629 NAMESPACE ,
2730 'analyzeCommits' ,
28- plugin => async ( pluginConfig , config ) => {
31+ plugin => async ( pluginConfig , context ) => {
2932 const { githubRepo, pullRequests } = pluginConfig ;
30- const nextRelease = await plugin ( pluginConfig , config ) ;
33+ const nextRelease = await plugin ( pluginConfig , context ) ;
3134
3235 if ( ! nextRelease ) {
3336 await pullRequests . forEach ( async pr => {
3437 const { number } = pr ;
35- const createChangelogOnPr = createChangelog ( pluginConfig , config ) ;
38+ const createChangelogOnPr = createChangelog ( pluginConfig , context ) ;
3639 const { data : comments } = await githubRepo . getIssueComments ( {
3740 number,
3841 } ) ;
@@ -49,35 +52,35 @@ const analyzeCommits = wrapPlugin(
4952 // Clean up stale changelog comments, possibly sparing the "no release"
5053 // comment if this package doesn't have a new release.
5154 await pullRequests . forEach (
52- deleteStaleChangelogs ( ! nextRelease ) ( pluginConfig , config )
55+ deleteStaleChangelogs ( ! nextRelease ) ( pluginConfig , context )
5356 ) ;
5457
5558 return nextRelease ;
5659 } ,
5760 pluginDefinitions . analyzeCommits . default
5861) ;
5962
60- const generateNotes = wrapPlugin (
63+ // Append a plugin that generates PR comments from the release notes resulting
64+ // from the configured `generateNotes` plugins that run ahead of it.
65+ const generateNotes = appendMultiPlugin (
6166 NAMESPACE ,
6267 'generateNotes' ,
63- plugin => async ( pluginConfig , config ) => {
68+ decoratePlugin ( async ( pluginConfig , context ) => {
6469 const { pullRequests } = pluginConfig ;
65- const { nextRelease } = config ;
66-
67- nextRelease . notes = await plugin ( pluginConfig , config ) ;
70+ const { nextRelease } = context ;
6871
6972 await pullRequests . forEach (
7073 // Create "release" comment
71- createChangelog ( pluginConfig , { ... config , nextRelease } )
74+ createChangelog ( pluginConfig , context )
7275 ) ;
7376
7477 return nextRelease . notes ;
75- } ,
78+ } ) ,
7679 pluginDefinitions . generateNotes . default
7780) ;
7881
7982module . exports = {
8083 verifyConditions : '@semantic-release/github' ,
81- analyzeCommits : decoratePlugins ( analyzeCommits ) ,
82- generateNotes : decoratePlugins ( generateNotes ) ,
84+ analyzeCommits : decoratePlugin ( analyzeCommits ) ,
85+ generateNotes,
8386} ;
0 commit comments