conventional-changelog-conventionalcommits 4.0.0 → 4.2.3

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/CHANGELOG.md CHANGED
@@ -3,6 +3,62 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
+ ## [4.2.3](https://github.com/conventional-changelog/conventional-changelog/compare/conventional-changelog-conventionalcommits@4.2.2...conventional-changelog-conventionalcommits@4.2.3) (2019-11-07)
7
+
8
+
9
+ ### Bug Fixes
10
+
11
+ * revertPattern match default git revert format ([#545](https://github.com/conventional-changelog/conventional-changelog/issues/545)) ([fe449f8](https://github.com/conventional-changelog/conventional-changelog/commit/fe449f899567574a36d1819b313e2caa899052ff))
12
+
13
+
14
+
15
+
16
+
17
+ ## [4.2.2](https://github.com/conventional-changelog/conventional-changelog/compare/conventional-changelog-conventionalcommits@4.2.1...conventional-changelog-conventionalcommits@4.2.2) (2019-10-24)
18
+
19
+
20
+ ### Bug Fixes
21
+
22
+ * **deps:** update lodash to fix security issues ([#535](https://github.com/conventional-changelog/conventional-changelog/issues/535)) ([ac43f51](https://github.com/conventional-changelog/conventional-changelog/commit/ac43f51de1f3b597c32f7f8442917a2d06199018))
23
+
24
+
25
+
26
+
27
+
28
+ # [4.2.0](https://github.com/conventional-changelog/conventional-changelog/compare/conventional-changelog-conventionalcommits@4.1.0...conventional-changelog-conventionalcommits@4.2.0) (2019-10-02)
29
+
30
+
31
+ ### Bug Fixes
32
+
33
+ * **preset, conventionalcommits:** fix handling conventionalcommits preset without config object ([c0566ce](https://github.com/conventional-changelog/conventional-changelog/commit/c0566ce)), closes [#512](https://github.com/conventional-changelog/conventional-changelog/issues/512)
34
+ * **preset, conventionalcommits:** pass issuePrefixes to parser ([#510](https://github.com/conventional-changelog/conventional-changelog/issues/510)) ([958d243](https://github.com/conventional-changelog/conventional-changelog/commit/958d243))
35
+ * use full commit hash in commit link ([7a60dec](https://github.com/conventional-changelog/conventional-changelog/commit/7a60dec)), closes [#476](https://github.com/conventional-changelog/conventional-changelog/issues/476)
36
+
37
+
38
+ ### Features
39
+
40
+ * sort sections of CHANGELOG based on priority ([#513](https://github.com/conventional-changelog/conventional-changelog/issues/513)) ([a3acc32](https://github.com/conventional-changelog/conventional-changelog/commit/a3acc32))
41
+
42
+
43
+
44
+
45
+
46
+ # [4.1.0](https://github.com/conventional-changelog/conventional-changelog/compare/conventional-changelog-conventionalcommits@4.0.0...conventional-changelog-conventionalcommits@4.1.0) (2019-07-29)
47
+
48
+
49
+ ### Bug Fixes
50
+
51
+ * **preset, conventionalcommits:** Ensure proper substitutions for the conventionalcommit preset by using commit context for values where possible. ([#463](https://github.com/conventional-changelog/conventional-changelog/issues/463)) ([0b7ed0b](https://github.com/conventional-changelog/conventional-changelog/commit/0b7ed0b))
52
+
53
+
54
+ ### Features
55
+
56
+ * **preset, conventionalcommits:** add handling of issue prefixes ([#498](https://github.com/conventional-changelog/conventional-changelog/issues/498)) ([85c17bb](https://github.com/conventional-changelog/conventional-changelog/commit/85c17bb))
57
+
58
+
59
+
60
+
61
+
6
62
  # [4.0.0](https://github.com/conventional-changelog/conventional-changelog/compare/conventional-changelog-conventionalcommits@3.0.2...conventional-changelog-conventionalcommits@4.0.0) (2019-05-18)
7
63
 
8
64
 
package/index.js CHANGED
@@ -1,11 +1,32 @@
1
1
  'use strict'
2
2
  const Q = require(`q`)
3
+ const _ = require(`lodash`)
3
4
  const conventionalChangelog = require(`./conventional-changelog`)
4
5
  const parserOpts = require(`./parser-opts`)
5
6
  const recommendedBumpOpts = require(`./conventional-recommended-bump`)
6
7
  const writerOpts = require(`./writer-opts`)
7
8
 
8
- module.exports = function (config) {
9
+ module.exports = function (parameter) {
10
+ // parameter passed can be either a config object or a callback function
11
+ if (_.isFunction(parameter)) {
12
+ // parameter is a callback object
13
+ const config = {}
14
+ // FIXME: use presetOpts(config) for callback
15
+ Q.all([
16
+ conventionalChangelog(config),
17
+ parserOpts(config),
18
+ recommendedBumpOpts(config),
19
+ writerOpts(config)
20
+ ]).spread((conventionalChangelog, parserOpts, recommendedBumpOpts, writerOpts) => {
21
+ parameter(null, { gitRawCommitsOpts: { noMerges: null }, conventionalChangelog, parserOpts, recommendedBumpOpts, writerOpts })
22
+ })
23
+ } else {
24
+ const config = parameter || {}
25
+ return presetOpts(config)
26
+ }
27
+ }
28
+
29
+ function presetOpts (config) {
9
30
  return Q.all([
10
31
  conventionalChangelog(config),
11
32
  parserOpts(config),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "conventional-changelog-conventionalcommits",
3
- "version": "4.0.0",
3
+ "version": "4.2.3",
4
4
  "description": "conventional-changelog conventionalcommits.org preset",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -35,7 +35,8 @@
35
35
  "homepage": "https://github.com/conventional-changelog/conventional-changelog/tree/master/packages/conventional-changelog-angular#readme",
36
36
  "dependencies": {
37
37
  "compare-func": "^1.3.1",
38
+ "lodash": "^4.17.15",
38
39
  "q": "^1.5.1"
39
40
  },
40
- "gitHead": "38f5508191f8afc1a8503d1fd24e2de6d05b8738"
41
+ "gitHead": "741e90744cdb58e82e71feb36018047d7baca768"
41
42
  }
package/parser-opts.js CHANGED
@@ -1,6 +1,7 @@
1
1
  'use strict'
2
2
 
3
3
  module.exports = function (config) {
4
+ config = defaultConfig(config)
4
5
  return {
5
6
  headerPattern: /^(\w*)(?:\((.*)\))?!?: (.*)$/,
6
7
  breakingHeaderPattern: /^(\w*)(?:\((.*)\))?!: (.*)$/,
@@ -10,7 +11,15 @@ module.exports = function (config) {
10
11
  `subject`
11
12
  ],
12
13
  noteKeywords: [`BREAKING CHANGE`],
13
- revertPattern: /^revert:\s([\s\S]*?)\s*This reverts commit (\w*)\./,
14
- revertCorrespondence: [`header`, `hash`]
14
+ revertPattern: /^(?:Revert|revert:)\s"?([\s\S]+?)"?\s*This reverts commit (\w*)\./i,
15
+ revertCorrespondence: [`header`, `hash`],
16
+ issuePrefixes: config.issuePrefixes
15
17
  }
16
18
  }
19
+
20
+ // merge user set configuration with default configuration.
21
+ function defaultConfig (config) {
22
+ config = config || {}
23
+ config.issuePrefixes = config.issuePrefixes || ['#']
24
+ return config
25
+ }
@@ -6,9 +6,9 @@
6
6
  {{~/if}}
7
7
 
8
8
  {{~!-- commit link --}} {{#if @root.linkReferences~}}
9
- ([{{hash}}]({{commitUrlFormat}}))
9
+ ([{{shortHash}}]({{commitUrlFormat}}))
10
10
  {{~else}}
11
- {{~hash}}
11
+ {{~shortHash}}
12
12
  {{~/if}}
13
13
 
14
14
  {{~!-- commit references --}}
@@ -19,12 +19,12 @@
19
19
  {{~#if this.owner}}
20
20
  {{~this.owner}}/
21
21
  {{~/if}}
22
- {{~this.repository}}#{{this.issue}}]({{issueUrlFormat}})
22
+ {{~this.repository}}{{this.prefix}}{{this.issue}}]({{issueUrlFormat}})
23
23
  {{~else}}
24
24
  {{~#if this.owner}}
25
25
  {{~this.owner}}/
26
26
  {{~/if}}
27
- {{~this.repository}}#{{this.issue}}
27
+ {{~this.repository}}{{this.prefix}}{{this.issue}}
28
28
  {{~/if}}{{/each}}
29
29
  {{~/if}}
30
30
 
package/writer-opts.js CHANGED
@@ -6,23 +6,31 @@ const Q = require(`q`)
6
6
  const readFile = Q.denodeify(require(`fs`).readFile)
7
7
  const resolve = require(`path`).resolve
8
8
 
9
+ /**
10
+ * Handlebar partials for various property substitutions based on commit context.
11
+ */
12
+ const owner = '{{#if this.owner}}{{~this.owner}}{{else}}{{~@root.owner}}{{/if}}'
13
+ const host = '{{~@root.host}}'
14
+ const repository = '{{#if this.repository}}{{~this.repository}}{{else}}{{~@root.repository}}{{/if}}'
15
+
9
16
  module.exports = function (config) {
10
17
  config = defaultConfig(config)
11
18
  const commitUrlFormat = expandTemplate(config.commitUrlFormat, {
12
- host: '{{~@root.host}}',
13
- owner: '{{~@root.owner}}',
14
- repository: '{{~@root.repository}}'
19
+ host,
20
+ owner,
21
+ repository
15
22
  })
16
23
  const compareUrlFormat = expandTemplate(config.compareUrlFormat, {
17
- host: '{{~@root.host}}',
18
- owner: '{{~@root.owner}}',
19
- repository: '{{~@root.repository}}'
24
+ host,
25
+ owner,
26
+ repository
20
27
  })
21
28
  const issueUrlFormat = expandTemplate(config.issueUrlFormat, {
22
- host: '{{~@root.host}}',
23
- owner: '{{~@root.owner}}',
24
- repository: '{{~@root.repository}}',
25
- id: '{{this.issue}}'
29
+ host,
30
+ owner,
31
+ repository,
32
+ id: '{{this.issue}}',
33
+ prefix: '{{this.prefix}}'
26
34
  })
27
35
 
28
36
  return Q.all([
@@ -57,7 +65,7 @@ function getWriterOpts (config) {
57
65
  transform: (commit, context) => {
58
66
  let discard = true
59
67
  const issues = []
60
- const typeKey = (commit.type || '').toLowerCase()
68
+ const typeKey = (commit.revert ? 'revert' : (commit.type || '')).toLowerCase()
61
69
 
62
70
  // adds additional breaking change notes
63
71
  // for the special case, test(system)!: hello world, where there is
@@ -80,20 +88,25 @@ function getWriterOpts (config) {
80
88
  }
81
89
 
82
90
  if (typeof commit.hash === `string`) {
83
- commit.hash = commit.hash.substring(0, 7)
91
+ commit.shortHash = commit.hash.substring(0, 7)
84
92
  }
85
93
 
86
94
  if (typeof commit.subject === `string`) {
87
95
  // Issue URLs.
88
- commit.subject = commit.subject.replace(/#([0-9]+)/g, (_, issue) => {
89
- issues.push(issue)
96
+ config.issuePrefixes.join('|')
97
+ let issueRegEx = '(' + config.issuePrefixes.join('|') + ')' + '([0-9]+)'
98
+ let re = new RegExp(issueRegEx, 'g')
99
+
100
+ commit.subject = commit.subject.replace(re, (_, prefix, issue) => {
101
+ issues.push(prefix + issue)
90
102
  const url = expandTemplate(config.issueUrlFormat, {
91
103
  host: context.host,
92
104
  owner: context.owner,
93
105
  repository: context.repository,
94
- id: issue
106
+ id: issue,
107
+ prefix: prefix
95
108
  })
96
- return `[#${issue}](${url})`
109
+ return `[${prefix}${issue}](${url})`
97
110
  })
98
111
  // User URLs.
99
112
  commit.subject = commit.subject.replace(/\B@([a-z0-9](?:-?[a-z0-9/]){0,38})/g, (_, user) => {
@@ -115,7 +128,7 @@ function getWriterOpts (config) {
115
128
 
116
129
  // remove references that already appear in the subject
117
130
  commit.references = commit.references.filter(reference => {
118
- if (issues.indexOf(reference.issue) === -1) {
131
+ if (issues.indexOf(reference.prefix + reference.issue) === -1) {
119
132
  return true
120
133
  }
121
134
 
@@ -125,7 +138,18 @@ function getWriterOpts (config) {
125
138
  return commit
126
139
  },
127
140
  groupBy: `type`,
128
- commitGroupsSort: `title`,
141
+ // the groupings of commit messages, e.g., Features vs., Bug Fixes, are
142
+ // sorted based on their probable importance:
143
+ commitGroupsSort: (a, b) => {
144
+ const commitGroupOrder = ['Reverts', 'Performance Improvements', 'Bug Fixes', 'Features']
145
+ const gRankA = commitGroupOrder.indexOf(a.title)
146
+ const gRankB = commitGroupOrder.indexOf(b.title)
147
+ if (gRankA >= gRankB) {
148
+ return -1
149
+ } else {
150
+ return 1
151
+ }
152
+ },
129
153
  commitsSort: [`scope`, `subject`],
130
154
  noteGroupsSort: `title`,
131
155
  notesSort: compareFunc
@@ -156,6 +180,7 @@ function defaultConfig (config) {
156
180
  '{{host}}/{{owner}}/{{repository}}/compare/{{previousTag}}...{{currentTag}}'
157
181
  config.userUrlFormat = config.userUrlFormat ||
158
182
  '{{host}}/{{user}}'
183
+ config.issuePrefixes = config.issuePrefixes || ['#']
159
184
 
160
185
  return config
161
186
  }