conventional-commits-parser 3.0.6 → 3.2.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/CHANGELOG.md +57 -0
- package/README.md +12 -0
- package/cli.js +52 -34
- package/index.js +8 -8
- package/lib/parser.js +60 -51
- package/lib/regex.js +16 -9
- package/package.json +8 -5
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,63 @@
|
|
|
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
|
+
# [3.2.0](https://github.com/conventional-changelog/conventional-changelog/compare/conventional-commits-parser@3.1.0...conventional-commits-parser@3.2.0) (2020-11-05)
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
### Bug Fixes
|
|
10
|
+
|
|
11
|
+
* ignore gpg lines ([#685](https://github.com/conventional-changelog/conventional-changelog/issues/685)) ([f8fcbc2](https://github.com/conventional-changelog/conventional-changelog/commit/f8fcbc2e8b0834c29178ace6382b438a020ad828))
|
|
12
|
+
* **deps:** update dependency through2 to v4 ([#657](https://github.com/conventional-changelog/conventional-changelog/issues/657)) ([7ae618c](https://github.com/conventional-changelog/conventional-changelog/commit/7ae618c81491841e5b1d796d3933aac0c54bc312))
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
### Features
|
|
16
|
+
|
|
17
|
+
* allows notes pattern to be customized ([#586](https://github.com/conventional-changelog/conventional-changelog/issues/586)) ([9c00f32](https://github.com/conventional-changelog/conventional-changelog/commit/9c00f3242d916be1774a618d943f908f8d9699a6))
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
# [3.1.0](https://github.com/conventional-changelog/conventional-changelog/compare/conventional-commits-parser@3.0.8...conventional-commits-parser@3.1.0) (2020-05-08)
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
### Bug Fixes
|
|
27
|
+
|
|
28
|
+
* **deps:** update yargs-parser to move off a flagged-vulnerable version. ([#635](https://github.com/conventional-changelog/conventional-changelog/issues/635)) ([aafc0f0](https://github.com/conventional-changelog/conventional-changelog/commit/aafc0f00412c3e4b23b8418300e5a570a48fe24d))
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
### Features
|
|
32
|
+
|
|
33
|
+
* **conventional-commits-parser:** add issuePrefixesCaseSensitive parser option ([#580](https://github.com/conventional-changelog/conventional-changelog/issues/580)) ([526b282](https://github.com/conventional-changelog/conventional-changelog/commit/526b28214d12c55158eb2e4d44408378587ceb97))
|
|
34
|
+
* support slash in headerPattern default options ([93a547d](https://github.com/conventional-changelog/conventional-changelog/commit/93a547d742634d8676f499cfa2a274bc3792d020))
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
## [3.0.8](https://github.com/conventional-changelog/conventional-changelog/compare/conventional-commits-parser@3.0.7...conventional-commits-parser@3.0.8) (2019-11-14)
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
### Bug Fixes
|
|
44
|
+
|
|
45
|
+
* add types for cli flags ([#551](https://github.com/conventional-changelog/conventional-changelog/issues/551)) ([bf1d64a](https://github.com/conventional-changelog/conventional-changelog/commit/bf1d64aeaf8f262d4b2beec02d2aebb78df7343b))
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
## [3.0.7](https://github.com/conventional-changelog/conventional-changelog/compare/conventional-commits-parser@3.0.6...conventional-commits-parser@3.0.7) (2019-11-07)
|
|
52
|
+
|
|
53
|
+
|
|
54
|
+
### Bug Fixes
|
|
55
|
+
|
|
56
|
+
* **conventional-commits-parser:** add breaking change notes if header match `breakingHeaderPattern` ([#544](https://github.com/conventional-changelog/conventional-changelog/issues/544)) ([efdf3cb](https://github.com/conventional-changelog/conventional-changelog/commit/efdf3cbc9de3278b180a48beebb74e596e3c5f94))
|
|
57
|
+
* **conventional-commits-parser:** add missing separator pipe to non tty parser ([#546](https://github.com/conventional-changelog/conventional-changelog/issues/546)) ([c522743](https://github.com/conventional-changelog/conventional-changelog/commit/c5227437b0b300f30a57e8ba5df2a8ab8d163af0))
|
|
58
|
+
|
|
59
|
+
|
|
60
|
+
|
|
61
|
+
|
|
62
|
+
|
|
6
63
|
## [3.0.6](https://github.com/conventional-changelog/conventional-changelog/compare/conventional-commits-parser@3.0.5...conventional-commits-parser@3.0.6) (2019-10-24)
|
|
7
64
|
|
|
8
65
|
|
package/README.md
CHANGED
|
@@ -193,12 +193,24 @@ Type: `array` of `string` or `string` Default: `['#']`
|
|
|
193
193
|
|
|
194
194
|
The prefixes of an issue. EG: In `gh-123` `gh-` is the prefix.
|
|
195
195
|
|
|
196
|
+
##### issuePrefixesCaseSensitive
|
|
197
|
+
|
|
198
|
+
Type: `boolean` Default: false
|
|
199
|
+
|
|
200
|
+
Used to define if `issuePrefixes` should be considered case sensitive.
|
|
201
|
+
|
|
196
202
|
##### noteKeywords
|
|
197
203
|
|
|
198
204
|
Type: `array` of `string` or `string` Default: `['BREAKING CHANGE']`
|
|
199
205
|
|
|
200
206
|
Keywords for important notes. This value is case **insensitive**. If it's a `string` it will be converted to an `array` separated by a comma.
|
|
201
207
|
|
|
208
|
+
##### notesPattern
|
|
209
|
+
|
|
210
|
+
Type: `function` Default: `noteKeywordsSelection => ^[\\s|*]*(' + noteKeywordsSelection + ')[:\\s]+(.*)` where `noteKeywordsSelection` is `join(noteKeywords, '|')`
|
|
211
|
+
|
|
212
|
+
A function that takes `noteKeywordsSelection` and returns a `RegExp` to be matched against the notes.
|
|
213
|
+
|
|
202
214
|
##### fieldPattern
|
|
203
215
|
|
|
204
216
|
Type: `regex` or `string` Default: `/^-(.*?)-$/`
|
package/cli.js
CHANGED
|
@@ -1,19 +1,19 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
'use strict'
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
3
|
+
const conventionalCommitsParser = require('./')
|
|
4
|
+
const forEach = require('lodash').forEach
|
|
5
|
+
const fs = require('fs')
|
|
6
|
+
const isTextPath = require('is-text-path')
|
|
7
|
+
const JSONStream = require('JSONStream')
|
|
8
|
+
const meow = require('meow')
|
|
9
|
+
const readline = require('readline')
|
|
10
|
+
const split = require('split2')
|
|
11
|
+
const through = require('through2')
|
|
12
12
|
|
|
13
|
-
|
|
14
|
-
|
|
13
|
+
const filePaths = []
|
|
14
|
+
let separator = '\n\n\n'
|
|
15
15
|
|
|
16
|
-
|
|
16
|
+
const cli = meow(`
|
|
17
17
|
Practice writing commit messages or parse messages from files.
|
|
18
18
|
If used without specifying a text file path, you will enter an interactive shell.
|
|
19
19
|
Otherwise the commit messages in the files are parsed and printed
|
|
@@ -31,37 +31,54 @@ var cli = meow(`
|
|
|
31
31
|
conventional-commits-parser log2.txt '===' >> parsed.txt
|
|
32
32
|
|
|
33
33
|
Options
|
|
34
|
-
-p, --header-pattern
|
|
35
|
-
-c, --header-correspondence
|
|
36
|
-
-r, --reference-actions
|
|
37
|
-
-i, --issue-prefixes
|
|
38
|
-
|
|
39
|
-
-
|
|
40
|
-
--
|
|
41
|
-
--revert-
|
|
42
|
-
-
|
|
34
|
+
-p, --header-pattern Regex to match header pattern
|
|
35
|
+
-c, --header-correspondence Comma separated parts used to define what capturing group of 'headerPattern' captures what
|
|
36
|
+
-r, --reference-actions Comma separated keywords that used to reference issues
|
|
37
|
+
-i, --issue-prefixes Comma separated prefixes of an issue
|
|
38
|
+
--issue-prefixes-case-sensitive Treat issue prefixes as case sensitive
|
|
39
|
+
-n, --note-keywords Comma separated keywords for important notes
|
|
40
|
+
-f, --field-pattern Regex to match other fields
|
|
41
|
+
--revert-pattern Regex to match revert pattern
|
|
42
|
+
--revert-correspondence Comma separated fields used to define what the commit reverts
|
|
43
|
+
-v, --verbose Verbose output
|
|
43
44
|
`, {
|
|
44
45
|
flags: {
|
|
45
46
|
'header-pattern': {
|
|
46
|
-
alias:
|
|
47
|
+
alias: 'p',
|
|
48
|
+
type: 'string'
|
|
47
49
|
},
|
|
48
50
|
'header-correspondence': {
|
|
49
|
-
alias:
|
|
51
|
+
alias: 'c',
|
|
52
|
+
type: 'string'
|
|
50
53
|
},
|
|
51
54
|
'reference-actions': {
|
|
52
|
-
alias:
|
|
55
|
+
alias: 'r',
|
|
56
|
+
type: 'string'
|
|
53
57
|
},
|
|
54
58
|
'issue-prefixes': {
|
|
55
|
-
alias:
|
|
59
|
+
alias: 'i',
|
|
60
|
+
type: 'string'
|
|
61
|
+
},
|
|
62
|
+
'issue-prefixes-case-sensitive': {
|
|
63
|
+
type: 'boolean'
|
|
56
64
|
},
|
|
57
65
|
'note-keywords': {
|
|
58
|
-
alias:
|
|
66
|
+
alias: 'n',
|
|
67
|
+
type: 'string'
|
|
59
68
|
},
|
|
60
69
|
'field-pattern': {
|
|
61
|
-
alias:
|
|
70
|
+
alias: 'f',
|
|
71
|
+
type: 'string'
|
|
72
|
+
},
|
|
73
|
+
'revert-pattern': {
|
|
74
|
+
type: 'string'
|
|
75
|
+
},
|
|
76
|
+
'revert-correspondence': {
|
|
77
|
+
type: 'string'
|
|
62
78
|
},
|
|
63
79
|
verbose: {
|
|
64
|
-
alias:
|
|
80
|
+
alias: 'v',
|
|
81
|
+
type: 'boolean'
|
|
65
82
|
}
|
|
66
83
|
}
|
|
67
84
|
})
|
|
@@ -74,15 +91,15 @@ forEach(cli.input, function (arg) {
|
|
|
74
91
|
}
|
|
75
92
|
})
|
|
76
93
|
|
|
77
|
-
|
|
78
|
-
|
|
94
|
+
const length = filePaths.length
|
|
95
|
+
const options = cli.flags
|
|
79
96
|
|
|
80
97
|
if (options.verbose) {
|
|
81
98
|
options.warn = console.log.bind(console)
|
|
82
99
|
}
|
|
83
100
|
|
|
84
101
|
function processFile (fileIndex) {
|
|
85
|
-
|
|
102
|
+
const filePath = filePaths[fileIndex]
|
|
86
103
|
fs.createReadStream(filePath)
|
|
87
104
|
.on('error', function (err) {
|
|
88
105
|
console.warn('Failed to read file ' + filePath + '\n' + err)
|
|
@@ -105,9 +122,9 @@ if (process.stdin.isTTY) {
|
|
|
105
122
|
if (length > 0) {
|
|
106
123
|
processFile(0)
|
|
107
124
|
} else {
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
125
|
+
let commit = ''
|
|
126
|
+
const stream = through()
|
|
127
|
+
const rl = readline.createInterface({
|
|
111
128
|
input: process.stdin,
|
|
112
129
|
output: process.stdout,
|
|
113
130
|
terminal: true
|
|
@@ -137,6 +154,7 @@ if (process.stdin.isTTY) {
|
|
|
137
154
|
} else {
|
|
138
155
|
options.warn = true
|
|
139
156
|
process.stdin
|
|
157
|
+
.pipe(split(separator))
|
|
140
158
|
.pipe(conventionalCommitsParser(options))
|
|
141
159
|
.on('error', function (err) {
|
|
142
160
|
console.error(err.toString())
|
package/index.js
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
'use strict'
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
3
|
+
const parser = require('./lib/parser')
|
|
4
|
+
const regex = require('./lib/regex')
|
|
5
|
+
const through = require('through2')
|
|
6
|
+
const _ = require('lodash')
|
|
7
7
|
|
|
8
8
|
function assignOpts (options) {
|
|
9
9
|
options = _.extend({
|
|
10
|
-
headerPattern: /^(\w*)(?:\(([\w
|
|
10
|
+
headerPattern: /^(\w*)(?:\(([\w$.\-*/ ]*)\))?: (.*)$/,
|
|
11
11
|
headerCorrespondence: ['type', 'scope', 'subject'],
|
|
12
12
|
referenceActions: [
|
|
13
13
|
'close',
|
|
@@ -71,10 +71,10 @@ function assignOpts (options) {
|
|
|
71
71
|
|
|
72
72
|
function conventionalCommitsParser (options) {
|
|
73
73
|
options = assignOpts(options)
|
|
74
|
-
|
|
74
|
+
const reg = regex(options)
|
|
75
75
|
|
|
76
76
|
return through.obj(function (data, enc, cb) {
|
|
77
|
-
|
|
77
|
+
let commit
|
|
78
78
|
|
|
79
79
|
try {
|
|
80
80
|
commit = parser(data.toString(), options, reg)
|
|
@@ -92,7 +92,7 @@ function conventionalCommitsParser (options) {
|
|
|
92
92
|
|
|
93
93
|
function sync (commit, options) {
|
|
94
94
|
options = assignOpts(options)
|
|
95
|
-
|
|
95
|
+
const reg = regex(options)
|
|
96
96
|
|
|
97
97
|
return parser(commit, options, reg)
|
|
98
98
|
}
|
package/lib/parser.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
'use strict'
|
|
2
|
-
|
|
3
|
-
|
|
2
|
+
const trimOffNewlines = require('trim-off-newlines')
|
|
3
|
+
const _ = require('lodash')
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
|
|
5
|
+
const CATCH_ALL = /()(.+)/gi
|
|
6
|
+
const SCISSOR = '# ------------------------ >8 ------------------------'
|
|
7
7
|
|
|
8
8
|
function append (src, line) {
|
|
9
9
|
if (src) {
|
|
@@ -22,7 +22,7 @@ function getCommentFilter (char) {
|
|
|
22
22
|
}
|
|
23
23
|
|
|
24
24
|
function truncateToScissor (lines) {
|
|
25
|
-
|
|
25
|
+
const scissorIndex = lines.indexOf(SCISSOR)
|
|
26
26
|
|
|
27
27
|
if (scissorIndex === -1) {
|
|
28
28
|
return lines
|
|
@@ -32,29 +32,29 @@ function truncateToScissor (lines) {
|
|
|
32
32
|
}
|
|
33
33
|
|
|
34
34
|
function getReferences (input, regex) {
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
35
|
+
const references = []
|
|
36
|
+
let referenceSentences
|
|
37
|
+
let referenceMatch
|
|
38
38
|
|
|
39
|
-
|
|
39
|
+
const reApplicable = input.match(regex.references) !== null
|
|
40
40
|
? regex.references
|
|
41
41
|
: CATCH_ALL
|
|
42
42
|
|
|
43
43
|
while ((referenceSentences = reApplicable.exec(input))) {
|
|
44
|
-
|
|
45
|
-
|
|
44
|
+
const action = referenceSentences[1] || null
|
|
45
|
+
const sentence = referenceSentences[2]
|
|
46
46
|
|
|
47
47
|
while ((referenceMatch = regex.referenceParts.exec(sentence))) {
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
48
|
+
let owner = null
|
|
49
|
+
let repository = referenceMatch[1] || ''
|
|
50
|
+
const ownerRepo = repository.split('/')
|
|
51
51
|
|
|
52
52
|
if (ownerRepo.length > 1) {
|
|
53
53
|
owner = ownerRepo.shift()
|
|
54
54
|
repository = ownerRepo.join('/')
|
|
55
55
|
}
|
|
56
56
|
|
|
57
|
-
|
|
57
|
+
const reference = {
|
|
58
58
|
action: action,
|
|
59
59
|
owner: owner,
|
|
60
60
|
repository: repository || null,
|
|
@@ -87,39 +87,37 @@ function parser (raw, options, regex) {
|
|
|
87
87
|
throw new TypeError('Expected regex')
|
|
88
88
|
}
|
|
89
89
|
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
var revertMatch
|
|
95
|
-
var otherFields = {}
|
|
96
|
-
var commentFilter = typeof options.commentChar === 'string'
|
|
90
|
+
let currentProcessedField
|
|
91
|
+
let mentionsMatch
|
|
92
|
+
const otherFields = {}
|
|
93
|
+
const commentFilter = typeof options.commentChar === 'string'
|
|
97
94
|
? getCommentFilter(options.commentChar)
|
|
98
95
|
: passTrough
|
|
96
|
+
const gpgFilter = line => !line.match(/^\s*gpg:/)
|
|
99
97
|
|
|
100
|
-
|
|
101
|
-
|
|
98
|
+
const rawLines = trimOffNewlines(raw).split(/\r?\n/)
|
|
99
|
+
const lines = truncateToScissor(rawLines).filter(commentFilter).filter(gpgFilter)
|
|
102
100
|
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
101
|
+
let continueNote = false
|
|
102
|
+
let isBody = true
|
|
103
|
+
const headerCorrespondence = _.map(options.headerCorrespondence, function (part) {
|
|
106
104
|
return part.trim()
|
|
107
105
|
})
|
|
108
|
-
|
|
106
|
+
const revertCorrespondence = _.map(options.revertCorrespondence, function (field) {
|
|
109
107
|
return field.trim()
|
|
110
108
|
})
|
|
111
|
-
|
|
109
|
+
const mergeCorrespondence = _.map(options.mergeCorrespondence, function (field) {
|
|
112
110
|
return field.trim()
|
|
113
111
|
})
|
|
114
112
|
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
113
|
+
let body = null
|
|
114
|
+
let footer = null
|
|
115
|
+
let header = null
|
|
116
|
+
const mentions = []
|
|
117
|
+
let merge = null
|
|
118
|
+
const notes = []
|
|
119
|
+
const references = []
|
|
120
|
+
let revert = null
|
|
123
121
|
|
|
124
122
|
if (lines.length === 0) {
|
|
125
123
|
return {
|
|
@@ -139,12 +137,12 @@ function parser (raw, options, regex) {
|
|
|
139
137
|
|
|
140
138
|
// msg parts
|
|
141
139
|
merge = lines.shift()
|
|
142
|
-
|
|
143
|
-
|
|
140
|
+
const mergeParts = {}
|
|
141
|
+
const headerParts = {}
|
|
144
142
|
body = ''
|
|
145
143
|
footer = ''
|
|
146
144
|
|
|
147
|
-
mergeMatch = merge.match(options.mergePattern)
|
|
145
|
+
const mergeMatch = merge.match(options.mergePattern)
|
|
148
146
|
if (mergeMatch && options.mergePattern) {
|
|
149
147
|
merge = mergeMatch[0]
|
|
150
148
|
|
|
@@ -154,7 +152,7 @@ function parser (raw, options, regex) {
|
|
|
154
152
|
}
|
|
155
153
|
|
|
156
154
|
_.forEach(mergeCorrespondence, function (partName, index) {
|
|
157
|
-
|
|
155
|
+
const partValue = mergeMatch[index + 1] || null
|
|
158
156
|
mergeParts[partName] = partValue
|
|
159
157
|
})
|
|
160
158
|
} else {
|
|
@@ -166,10 +164,10 @@ function parser (raw, options, regex) {
|
|
|
166
164
|
})
|
|
167
165
|
}
|
|
168
166
|
|
|
169
|
-
headerMatch = header.match(options.headerPattern)
|
|
167
|
+
const headerMatch = header.match(options.headerPattern)
|
|
170
168
|
if (headerMatch) {
|
|
171
169
|
_.forEach(headerCorrespondence, function (partName, index) {
|
|
172
|
-
|
|
170
|
+
const partValue = headerMatch[index + 1] || null
|
|
173
171
|
headerParts[partName] = partValue
|
|
174
172
|
})
|
|
175
173
|
} else {
|
|
@@ -186,7 +184,7 @@ function parser (raw, options, regex) {
|
|
|
186
184
|
// body or footer
|
|
187
185
|
_.forEach(lines, function (line) {
|
|
188
186
|
if (options.fieldPattern) {
|
|
189
|
-
|
|
187
|
+
const fieldMatch = options.fieldPattern.exec(line)
|
|
190
188
|
|
|
191
189
|
if (fieldMatch) {
|
|
192
190
|
currentProcessedField = fieldMatch[1]
|
|
@@ -201,16 +199,16 @@ function parser (raw, options, regex) {
|
|
|
201
199
|
}
|
|
202
200
|
}
|
|
203
201
|
|
|
204
|
-
|
|
202
|
+
let referenceMatched
|
|
205
203
|
|
|
206
204
|
// this is a new important note
|
|
207
|
-
|
|
205
|
+
const notesMatch = line.match(regex.notes)
|
|
208
206
|
if (notesMatch) {
|
|
209
207
|
continueNote = true
|
|
210
208
|
isBody = false
|
|
211
209
|
footer = append(footer, line)
|
|
212
210
|
|
|
213
|
-
|
|
211
|
+
const note = {
|
|
214
212
|
title: notesMatch[1],
|
|
215
213
|
text: notesMatch[2]
|
|
216
214
|
}
|
|
@@ -220,7 +218,7 @@ function parser (raw, options, regex) {
|
|
|
220
218
|
return
|
|
221
219
|
}
|
|
222
220
|
|
|
223
|
-
|
|
221
|
+
const lineReferences = getReferences(line, {
|
|
224
222
|
references: regex.references,
|
|
225
223
|
referenceParts: regex.referenceParts
|
|
226
224
|
})
|
|
@@ -253,16 +251,27 @@ function parser (raw, options, regex) {
|
|
|
253
251
|
}
|
|
254
252
|
})
|
|
255
253
|
|
|
254
|
+
if (options.breakingHeaderPattern && notes.length === 0) {
|
|
255
|
+
const breakingHeader = header.match(options.breakingHeaderPattern)
|
|
256
|
+
if (breakingHeader) {
|
|
257
|
+
const noteText = breakingHeader[3] // the description of the change.
|
|
258
|
+
notes.push({
|
|
259
|
+
title: 'BREAKING CHANGE',
|
|
260
|
+
text: noteText
|
|
261
|
+
})
|
|
262
|
+
}
|
|
263
|
+
}
|
|
264
|
+
|
|
256
265
|
while ((mentionsMatch = regex.mentions.exec(raw))) {
|
|
257
266
|
mentions.push(mentionsMatch[1])
|
|
258
267
|
}
|
|
259
268
|
|
|
260
269
|
// does this commit revert any other commit?
|
|
261
|
-
revertMatch = raw.match(options.revertPattern)
|
|
270
|
+
const revertMatch = raw.match(options.revertPattern)
|
|
262
271
|
if (revertMatch) {
|
|
263
272
|
revert = {}
|
|
264
273
|
_.forEach(revertCorrespondence, function (partName, index) {
|
|
265
|
-
|
|
274
|
+
const partValue = revertMatch[index + 1] || null
|
|
266
275
|
revert[partName] = partValue
|
|
267
276
|
})
|
|
268
277
|
} else {
|
|
@@ -275,7 +284,7 @@ function parser (raw, options, regex) {
|
|
|
275
284
|
return note
|
|
276
285
|
})
|
|
277
286
|
|
|
278
|
-
|
|
287
|
+
const msg = _.merge(headerParts, mergeParts, {
|
|
279
288
|
merge: merge,
|
|
280
289
|
header: header,
|
|
281
290
|
body: body ? trimOffNewlines(body) : null,
|
package/lib/regex.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use strict'
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
const reNomatch = /(?!.*)/
|
|
4
4
|
|
|
5
5
|
function join (array, joiner) {
|
|
6
6
|
return array
|
|
@@ -13,20 +13,27 @@ function join (array, joiner) {
|
|
|
13
13
|
.join(joiner)
|
|
14
14
|
}
|
|
15
15
|
|
|
16
|
-
function getNotesRegex (noteKeywords) {
|
|
16
|
+
function getNotesRegex (noteKeywords, notesPattern) {
|
|
17
17
|
if (!noteKeywords) {
|
|
18
18
|
return reNomatch
|
|
19
19
|
}
|
|
20
20
|
|
|
21
|
-
|
|
21
|
+
const noteKeywordsSelection = join(noteKeywords, '|')
|
|
22
|
+
|
|
23
|
+
if (!notesPattern) {
|
|
24
|
+
return new RegExp('^[\\s|*]*(' + noteKeywordsSelection + ')[:\\s]+(.*)', 'i')
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
return notesPattern(noteKeywordsSelection)
|
|
22
28
|
}
|
|
23
29
|
|
|
24
|
-
function getReferencePartsRegex (issuePrefixes) {
|
|
30
|
+
function getReferencePartsRegex (issuePrefixes, issuePrefixesCaseSensitive) {
|
|
25
31
|
if (!issuePrefixes) {
|
|
26
32
|
return reNomatch
|
|
27
33
|
}
|
|
28
34
|
|
|
29
|
-
|
|
35
|
+
const flags = issuePrefixesCaseSensitive ? 'g' : 'gi'
|
|
36
|
+
return new RegExp('(?:.*?)??\\s*([\\w-\\.\\/]*?)??(' + join(issuePrefixes, '|') + ')([\\w-]*\\d+)', flags)
|
|
30
37
|
}
|
|
31
38
|
|
|
32
39
|
function getReferencesRegex (referenceActions) {
|
|
@@ -35,15 +42,15 @@ function getReferencesRegex (referenceActions) {
|
|
|
35
42
|
return /()(.+)/gi
|
|
36
43
|
}
|
|
37
44
|
|
|
38
|
-
|
|
45
|
+
const joinedKeywords = join(referenceActions, '|')
|
|
39
46
|
return new RegExp('(' + joinedKeywords + ')(?:\\s+(.*?))(?=(?:' + joinedKeywords + ')|$)', 'gi')
|
|
40
47
|
}
|
|
41
48
|
|
|
42
49
|
module.exports = function (options) {
|
|
43
50
|
options = options || {}
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
51
|
+
const reNotes = getNotesRegex(options.noteKeywords, options.notesPattern)
|
|
52
|
+
const reReferenceParts = getReferencePartsRegex(options.issuePrefixes, options.issuePrefixesCaseSensitive)
|
|
53
|
+
const reReferences = getReferencesRegex(options.referenceActions)
|
|
47
54
|
|
|
48
55
|
return {
|
|
49
56
|
notes: reNotes,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "conventional-commits-parser",
|
|
3
|
-
"version": "3.0
|
|
3
|
+
"version": "3.2.0",
|
|
4
4
|
"description": "Parse raw conventional commits",
|
|
5
5
|
"bugs": {
|
|
6
6
|
"url": "https://github.com/conventional-changelog/conventional-changelog/issues"
|
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
},
|
|
18
18
|
"license": "MIT",
|
|
19
19
|
"engines": {
|
|
20
|
-
"node": ">=
|
|
20
|
+
"node": ">=10"
|
|
21
21
|
},
|
|
22
22
|
"files": [
|
|
23
23
|
"index.js",
|
|
@@ -36,9 +36,9 @@
|
|
|
36
36
|
"JSONStream": "^1.0.4",
|
|
37
37
|
"is-text-path": "^1.0.1",
|
|
38
38
|
"lodash": "^4.17.15",
|
|
39
|
-
"meow": "^
|
|
39
|
+
"meow": "^8.0.0",
|
|
40
40
|
"split2": "^2.0.0",
|
|
41
|
-
"through2": "^
|
|
41
|
+
"through2": "^4.0.0",
|
|
42
42
|
"trim-off-newlines": "^1.0.0"
|
|
43
43
|
},
|
|
44
44
|
"scripts": {
|
|
@@ -47,5 +47,8 @@
|
|
|
47
47
|
"bin": {
|
|
48
48
|
"conventional-commits-parser": "cli.js"
|
|
49
49
|
},
|
|
50
|
-
"
|
|
50
|
+
"devDependencies": {
|
|
51
|
+
"forceable-tty": "^0.1.0"
|
|
52
|
+
},
|
|
53
|
+
"gitHead": "cc567b98facf71315f4b1620d81ce01d155efaca"
|
|
51
54
|
}
|