@semantic-release/release-notes-generator 6.0.11 → 7.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -38,7 +38,9 @@ Additional options can be set within the plugin definition in `package.json` to
38
38
  | `parserOpts` | Additional [conventional-commits-parser](https://github.com/conventional-changelog/conventional-changelog/tree/master/packages/conventional-commits-parser#conventionalcommitsparseroptions) options that will extends ones loaded by `preset` or `config`. See [Parser options](#parser-options). | - |
39
39
  | `writerOpts` | Additional [conventional-commits-writer](https://github.com/conventional-changelog/conventional-changelog/tree/master/packages/conventional-changelog-writer#options) options that will extends ones loaded by `preset` or `config`. See [Writer options](#writer-options). | - |
40
40
 
41
- **NOTE:** `options.config` will be overwritten by the values of preset. You should use either `preset` or `config`, but not both. Individual properties of `parserOpts` and `writerOpts` will overwrite ones loaded with `preset` or `config`.
41
+ **Note**: `config` will be overwritten by the values of `preset`. You should use either `preset` or `config`, but not both.
42
+
43
+ **Note**: Individual properties of `parserOpts` and `writerOpts` will override ones loaded with an explicitly set `preset` or `config`. If `preset` or `config` are not set, only the properties set in `parserOpts` and `writerOpts` will be used.
42
44
 
43
45
  ### Parser Options
44
46
 
package/index.js CHANGED
@@ -3,8 +3,9 @@ const {find} = require('lodash');
3
3
  const getStream = require('get-stream');
4
4
  const intoStream = require('into-stream');
5
5
  const gitUrlParse = require('git-url-parse');
6
- const conventionalCommitsParser = require('conventional-commits-parser').sync;
7
- const conventionalChangelogWriter = require('conventional-changelog-writer');
6
+ const parser = require('conventional-commits-parser').sync;
7
+ const writer = require('conventional-changelog-writer');
8
+ const filter = require('conventional-commits-filter');
8
9
  const debug = require('debug')('semantic-release:release-notes-generator');
9
10
  const loadChangelogConfig = require('./lib/load-changelog-config');
10
11
  const HOSTS_CONFIG = require('./lib/hosts-config');
@@ -12,34 +13,42 @@ const HOSTS_CONFIG = require('./lib/hosts-config');
12
13
  /**
13
14
  * Generate the changelog for all the commits in `options.commits`.
14
15
  *
15
- * @param {Object} [pluginConfig={}] semantic-release configuration.
16
+ * @param {Object} pluginConfig The plugin configuration.
16
17
  * @param {String} pluginConfig.preset conventional-changelog preset ('angular', 'atom', 'codemirror', 'ember', 'eslint', 'express', 'jquery', 'jscs', 'jshint').
17
- * @param {String} pluginConfig.config requierable npm package with a custom conventional-changelog preset
18
- * @param {Object} pluginConfig.parserOpts additional `conventional-changelog-parser` options that will overwrite ones loaded by `preset` or `config`.
19
- * @param {Object} pluginConfig.writerOpts additional `conventional-changelog-writer` options that will overwrite ones loaded by `preset` or `config`.
20
- * @param {Object} options semantic-release options.
21
- * @param {Array<Object>} options.commits array of commits, each containing `hash` and `message`.
22
- * @param {Object} options.lastRelease last release with `gitHead` corresponding to the commit hash used to make the last release and `gitTag` corresponding to the git tag associated with `gitHead`.
23
- * @param {Object} options.nextRelease next release with `gitHead` corresponding to the commit hash used to make the release, the release `version` and `gitTag` corresponding to the git tag associated with `gitHead`.
24
- * @param {Object} options.options.repositoryUrl git repository URL.
18
+ * @param {String} pluginConfig.config Requierable npm package with a custom conventional-changelog preset
19
+ * @param {Object} pluginConfig.parserOpts Additional `conventional-changelog-parser` options that will overwrite ones loaded by `preset` or `config`.
20
+ * @param {Object} pluginConfig.writerOpts Additional `conventional-changelog-writer` options that will overwrite ones loaded by `preset` or `config`.
21
+ * @param {Object} context The semantic-release context.
22
+ * @param {Array<Object>} context.commits The commits to analyze.
23
+ * @param {Object} context.lastRelease The last release with `gitHead` corresponding to the commit hash used to make the last release and `gitTag` corresponding to the git tag associated with `gitHead`.
24
+ * @param {Object} context.nextRelease The next release with `gitHead` corresponding to the commit hash used to make the release, the release `version` and `gitTag` corresponding to the git tag associated with `gitHead`.
25
+ * @param {Object} context.options.repositoryUrl The git repository URL.
25
26
  *
26
- * @returns {String} the changelog for all the commits in `options.commits`.
27
+ * @returns {String} The changelog for all the commits in `context.commits`.
27
28
  */
28
- async function releaseNotesGenerator(pluginConfig, {commits, lastRelease, nextRelease, options: {repositoryUrl}}) {
29
- const {parserOpts, writerOpts} = await loadChangelogConfig(pluginConfig);
29
+ async function releaseNotesGenerator(pluginConfig, context) {
30
+ const {
31
+ commits,
32
+ lastRelease,
33
+ nextRelease,
34
+ options: {repositoryUrl},
35
+ } = context;
36
+ const {parserOpts, writerOpts} = await loadChangelogConfig(pluginConfig, context);
30
37
 
31
38
  const {resource: hostname, port, name: repository, owner, protocols} = gitUrlParse(repositoryUrl);
32
39
  const protocol = protocols.includes('https') ? 'https' : protocols.includes('http') ? 'http' : 'https';
33
40
 
34
41
  const {issue, commit, referenceActions, issuePrefixes} =
35
42
  find(HOSTS_CONFIG, conf => conf.hostname === hostname) || HOSTS_CONFIG.default;
36
- const parsedCommits = commits.map(rawCommit => ({
37
- ...rawCommit,
38
- ...conventionalCommitsParser(rawCommit.message, {referenceActions, issuePrefixes, ...parserOpts}),
39
- }));
43
+ const parsedCommits = filter(
44
+ commits.map(rawCommit => ({
45
+ ...rawCommit,
46
+ ...parser(rawCommit.message, {referenceActions, issuePrefixes, ...parserOpts}),
47
+ }))
48
+ );
40
49
  const previousTag = lastRelease.gitTag || lastRelease.gitHead;
41
50
  const currentTag = nextRelease.gitTag || nextRelease.gitHead;
42
- const context = {
51
+ const changelogContext = {
43
52
  version: nextRelease.version,
44
53
  host: url.format({protocol, hostname, port}),
45
54
  owner,
@@ -58,7 +67,7 @@ async function releaseNotesGenerator(pluginConfig, {commits, lastRelease, nextRe
58
67
  debug('previousTag: %o', previousTag);
59
68
  debug('currentTag: %o', currentTag);
60
69
 
61
- return getStream(intoStream.obj(parsedCommits).pipe(conventionalChangelogWriter(context, writerOpts)));
70
+ return getStream(intoStream.obj(parsedCommits).pipe(writer(changelogContext, writerOpts)));
62
71
  }
63
72
 
64
73
  module.exports = releaseNotesGenerator;
@@ -1,26 +1,30 @@
1
1
  const {promisify} = require('util');
2
2
  const importFrom = require('import-from');
3
- const {mergeWith} = require('lodash');
4
3
  const conventionalChangelogAngular = require('conventional-changelog-angular');
5
4
 
6
5
  /**
7
6
  * Load `conventional-changelog-parser` options. Handle presets that return either a `Promise<Array>` or a `Promise<Function>`.
8
7
  *
9
- * @param {Object} preset conventional-changelog preset ('angular', 'atom', 'codemirror', 'ember', 'eslint', 'express', 'jquery', 'jscs', 'jshint')
10
- * @param {string} config requierable npm package with a custom conventional-changelog preset
11
- * @param {Object} parserOpts additionnal `conventional-changelog-parser` options that will overwrite ones loaded by `preset` or `config`.
12
- * @param {Object} writerOpts additionnal `conventional-changelog-writer` options that will overwrite ones loaded by `preset` or `config`.
8
+ * @param {Object} pluginConfig The plugin configuration.
9
+ * @param {Object} pluginConfig.preset conventional-changelog preset ('angular', 'atom', 'codemirror', 'ember', 'eslint', 'express', 'jquery', 'jscs', 'jshint')
10
+ * @param {string} pluginConfig.config Requierable npm package with a custom conventional-changelog preset
11
+ * @param {Object} pluginConfig.parserOpts Additionnal `conventional-changelog-parser` options that will overwrite ones loaded by `preset` or `config`.
12
+ * @param {Object} pluginConfig.writerOpts Additionnal `conventional-changelog-writer` options that will overwrite ones loaded by `preset` or `config`.
13
+ * @param {Object} context The semantic-release context.
14
+ * @param {Array<Object>} context.commits The commits to analyze.
15
+ * @param {String} context.cwd The current working directory.
16
+ *
13
17
  * @return {Promise<Object>} a `Promise` that resolve to the `conventional-changelog-core` config.
14
18
  */
15
- module.exports = async ({preset, config, parserOpts, writerOpts}) => {
16
- let loadedConfig = {};
19
+ module.exports = async ({preset, config, parserOpts, writerOpts}, {cwd}) => {
20
+ let loadedConfig;
17
21
 
18
22
  if (preset) {
19
23
  const presetPackage = `conventional-changelog-${preset.toLowerCase()}`;
20
- loadedConfig = importFrom.silent(__dirname, presetPackage) || importFrom(process.cwd(), presetPackage);
24
+ loadedConfig = importFrom.silent(__dirname, presetPackage) || importFrom(cwd, presetPackage);
21
25
  } else if (config) {
22
- loadedConfig = importFrom.silent(__dirname, config) || importFrom(process.cwd(), config);
23
- } else if (!parserOpts || !writerOpts) {
26
+ loadedConfig = importFrom.silent(__dirname, config) || importFrom(cwd, config);
27
+ } else {
24
28
  loadedConfig = conventionalChangelogAngular;
25
29
  }
26
30
 
@@ -30,12 +34,8 @@ module.exports = async ({preset, config, parserOpts, writerOpts}) => {
30
34
  loadedConfig = await loadedConfig;
31
35
  }
32
36
 
33
- return mergeWith(
34
- {},
35
- !preset && !config && parserOpts ? {parserOpts} : {parserOpts: loadedConfig.parserOpts},
36
- {parserOpts},
37
- !preset && !config && writerOpts ? {writerOpts} : {writerOpts: loadedConfig.writerOpts},
38
- {writerOpts},
39
- (value, source) => (Array.isArray(value) ? source : undefined)
40
- );
37
+ return {
38
+ parserOpts: !preset && !config && parserOpts ? parserOpts : {...loadedConfig.parserOpts, ...parserOpts},
39
+ writerOpts: !preset && !config && writerOpts ? writerOpts : {...loadedConfig.writerOpts, ...writerOpts},
40
+ };
41
41
  };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@semantic-release/release-notes-generator",
3
3
  "description": "Customizable release-notes-generator plugin for semantic-release",
4
- "version": "6.0.11",
4
+ "version": "7.0.0",
5
5
  "author": "Pierre Vanduynslager (https://twitter.com/@pvdlg_)",
6
6
  "bugs": {
7
7
  "url": "https://github.com/semantic-release/release-notes-generator/issues"
@@ -16,12 +16,13 @@
16
16
  "Gregor Martynus (https://twitter.com/gr2m)"
17
17
  ],
18
18
  "dependencies": {
19
- "conventional-changelog-angular": "^4.0.0",
19
+ "conventional-changelog-angular": "^5.0.0",
20
20
  "conventional-changelog-writer": "^4.0.0",
21
+ "conventional-commits-filter": "^2.0.0",
21
22
  "conventional-commits-parser": "^3.0.0",
22
23
  "debug": "^3.1.0",
23
24
  "get-stream": "^3.0.0",
24
- "git-url-parse": "^9.0.0",
25
+ "git-url-parse": "^10.0.1",
25
26
  "import-from": "^2.1.0",
26
27
  "into-stream": "^3.1.0",
27
28
  "lodash": "^4.17.4"
@@ -30,14 +31,14 @@
30
31
  "ava": "^0.25.0",
31
32
  "codecov": "^3.0.0",
32
33
  "commitizen": "^2.9.6",
33
- "conventional-changelog-atom": "^1.0.0",
34
- "conventional-changelog-ember": "^1.0.0",
35
- "conventional-changelog-eslint": "^2.0.0",
36
- "conventional-changelog-express": "^1.0.0",
37
- "conventional-changelog-jshint": "^1.0.0",
34
+ "conventional-changelog-atom": "^2.0.0",
35
+ "conventional-changelog-ember": "^2.0.0",
36
+ "conventional-changelog-eslint": "^3.0.0",
37
+ "conventional-changelog-express": "^2.0.0",
38
+ "conventional-changelog-jshint": "^2.0.0",
38
39
  "cz-conventional-changelog": "^2.0.0",
39
40
  "escape-string-regexp": "^1.0.5",
40
- "nyc": "^11.1.0",
41
+ "nyc": "^12.0.1",
41
42
  "semantic-release": "^15.0.0",
42
43
  "xo": "^0.21.0"
43
44
  },
@@ -73,6 +74,9 @@
73
74
  ],
74
75
  "all": true
75
76
  },
77
+ "peerDependencies": {
78
+ "semantic-release": ">=15.8.0 <16.0.0"
79
+ },
76
80
  "prettier": {
77
81
  "printWidth": 120,
78
82
  "trailingComma": "es5"