conventional-commits-parser 7.0.0 → 7.1.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 +17 -374
- package/dist/cli/index.js +43 -79
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -31,19 +31,6 @@
|
|
|
31
31
|
|
|
32
32
|
Parse raw conventional commits.
|
|
33
33
|
|
|
34
|
-
<hr />
|
|
35
|
-
<a href="#install">Install</a>
|
|
36
|
-
<span> • </span>
|
|
37
|
-
<a href="#usage">Usage</a>
|
|
38
|
-
<span> • </span>
|
|
39
|
-
<a href="#conventional-commit-message-format">Message format</a>
|
|
40
|
-
<span> • </span>
|
|
41
|
-
<a href="#api">API</a>
|
|
42
|
-
<span> • </span>
|
|
43
|
-
<a href="#cli">CLI</a>
|
|
44
|
-
<br />
|
|
45
|
-
<hr />
|
|
46
|
-
|
|
47
34
|
## Install
|
|
48
35
|
|
|
49
36
|
```bash
|
|
@@ -58,378 +45,34 @@ npm i conventional-commits-parser
|
|
|
58
45
|
## Usage
|
|
59
46
|
|
|
60
47
|
```js
|
|
61
|
-
import {
|
|
62
|
-
CommitParser,
|
|
63
|
-
parseCommits,
|
|
64
|
-
parseCommitsStream
|
|
65
|
-
} from 'conventional-commits-parser'
|
|
66
|
-
import { pipeline } from 'stream/promises'
|
|
67
|
-
import { Readable } from 'stream'
|
|
68
|
-
|
|
69
|
-
const rawCommitMessage = 'feat(scope): broadcast $destroy event on scope destruction\nCloses #1'
|
|
70
|
-
|
|
71
|
-
// to parse raw commit message manually:
|
|
72
|
-
const parser = new CommitParser(options)
|
|
48
|
+
import { CommitParser } from 'conventional-commits-parser'
|
|
73
49
|
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
await pipeline(
|
|
78
|
-
[rawCommitMessage],
|
|
79
|
-
parseCommits(options),
|
|
80
|
-
async function* (parsedCommits) {
|
|
81
|
-
for await (const commit of parsedCommits) {
|
|
82
|
-
console.log(commit)
|
|
83
|
-
}
|
|
84
|
-
}
|
|
50
|
+
const parser = new CommitParser()
|
|
51
|
+
const commit = parser.parse(
|
|
52
|
+
'feat(scope): broadcast $destroy event on scope destruction\nCloses #1'
|
|
85
53
|
)
|
|
86
54
|
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
.pipe(parseCommitsStream(options))
|
|
90
|
-
.on('data', commit => console.log(commit))
|
|
91
|
-
```
|
|
92
|
-
|
|
93
|
-
Parser expects raw commit message. Examples:
|
|
94
|
-
|
|
95
|
-
```js
|
|
96
|
-
'feat(scope): broadcast $destroy event on scope destruction\nCloses #1'
|
|
97
|
-
'feat(ng-list): Allow custom separator\nbla bla bla\n\nBREAKING CHANGE: some breaking change.\nThanks @stevemao\n'
|
|
98
|
-
```
|
|
99
|
-
|
|
100
|
-
It will return parsed commit object. Examples:
|
|
101
|
-
|
|
102
|
-
```js
|
|
103
|
-
{
|
|
55
|
+
console.log(commit)
|
|
56
|
+
/* {
|
|
104
57
|
type: 'feat',
|
|
105
58
|
scope: 'scope',
|
|
106
59
|
subject: 'broadcast $destroy event on scope destruction',
|
|
107
|
-
merge: null,
|
|
108
60
|
header: 'feat(scope): broadcast $destroy event on scope destruction',
|
|
109
|
-
body: null,
|
|
110
61
|
footer: 'Closes #1',
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
}],
|
|
121
|
-
mentions: [],
|
|
122
|
-
revert: null
|
|
123
|
-
}
|
|
124
|
-
{
|
|
125
|
-
type: 'feat',
|
|
126
|
-
scope: 'ng-list',
|
|
127
|
-
subject: 'Allow custom separator',
|
|
128
|
-
merge: null,
|
|
129
|
-
header: 'feat(ng-list): Allow custom separator',
|
|
130
|
-
body: 'bla bla bla',
|
|
131
|
-
footer: 'BREAKING CHANGE: some breaking change.\nThanks @stevemao',
|
|
132
|
-
notes:
|
|
133
|
-
[{
|
|
134
|
-
title: 'BREAKING CHANGE',
|
|
135
|
-
text: 'some breaking change.\nThanks @stevemao'
|
|
136
|
-
}],
|
|
137
|
-
references: [],
|
|
138
|
-
mentions: ['stevemao'],
|
|
139
|
-
revert: null
|
|
140
|
-
}
|
|
141
|
-
```
|
|
142
|
-
|
|
143
|
-
## Conventional Commit Message Format
|
|
144
|
-
|
|
145
|
-
A minimum input should contain a raw message.
|
|
146
|
-
|
|
147
|
-
Each commit message consists of a **merge header**, a **header** (mandatory), a **body** and a **footer**. **Mention** (optional) someone using the `@` notation.
|
|
148
|
-
|
|
149
|
-
```
|
|
150
|
-
<merge>
|
|
151
|
-
<header>
|
|
152
|
-
<body>
|
|
153
|
-
<footer>
|
|
154
|
-
```
|
|
155
|
-
|
|
156
|
-
### merge
|
|
157
|
-
|
|
158
|
-
The merge header may optionally have a special format that includes other parts, such as **branch**, **issueId** or **source**.
|
|
159
|
-
|
|
160
|
-
```
|
|
161
|
-
Merge branch <branch>
|
|
162
|
-
Merge pull request <issue-id> from <source>
|
|
163
|
-
```
|
|
164
|
-
|
|
165
|
-
### header
|
|
166
|
-
|
|
167
|
-
The header may optionally have a special format that includes other parts, such as **type**, **scope** and **subject**. You could **reference** (optional) issues here.
|
|
168
|
-
|
|
169
|
-
```
|
|
170
|
-
<type>(<scope>): <subject>
|
|
171
|
-
```
|
|
172
|
-
|
|
173
|
-
### footer
|
|
174
|
-
|
|
175
|
-
The footer should contain any information about **Important Notes** (optional) and is also the place to **reference** (optional) issues.
|
|
176
|
-
|
|
177
|
-
```
|
|
178
|
-
<important note>
|
|
179
|
-
<references>
|
|
180
|
-
```
|
|
181
|
-
|
|
182
|
-
### other parts
|
|
183
|
-
|
|
184
|
-
This module will only parse the message body. However, it is possible to include other fields such as hash, committer or date.
|
|
185
|
-
|
|
186
|
-
```
|
|
187
|
-
My commit message
|
|
188
|
-
-sideNotes-
|
|
189
|
-
It should warn the correct unfound file names.
|
|
190
|
-
Also it should continue if one file cannot be found.
|
|
191
|
-
Tests are added for these
|
|
192
|
-
```
|
|
193
|
-
|
|
194
|
-
Then `sideNotes` will be `It should warn the correct unfound file names.\nAlso it should continue if one file cannot be found.\nTests are added for these`. You can customize the `fieldPattern`.
|
|
195
|
-
|
|
196
|
-
## API
|
|
197
|
-
|
|
198
|
-
### `new CommitParser(options?: ParserOptions)`
|
|
199
|
-
|
|
200
|
-
Creates parser instance with `parse` method.
|
|
201
|
-
|
|
202
|
-
### `parseCommits(options?: ParserOptions)`
|
|
203
|
-
|
|
204
|
-
Create async generator function to parse async iterable of raw commits. If there is any malformed commits it will be gracefully ignored (an empty data will be emitted so down async iterable can notice).
|
|
205
|
-
|
|
206
|
-
### `parseCommitsStream(options?: ParserOptions)`
|
|
207
|
-
|
|
208
|
-
Creates an transform stream. If there is any malformed commits it will be gracefully ignored (an empty data will be emitted so down stream can notice).
|
|
209
|
-
|
|
210
|
-
### ParserOptions
|
|
211
|
-
|
|
212
|
-
#### mergePattern
|
|
213
|
-
|
|
214
|
-
Type: `RegExp`
|
|
215
|
-
Default: null
|
|
216
|
-
|
|
217
|
-
Pattern to match merge headers. EG: branch merge, GitHub or GitLab like pull requests headers. When a merge header is parsed, the next line is used for conventional header parsing.
|
|
218
|
-
|
|
219
|
-
For example, if we have a commit
|
|
220
|
-
|
|
221
|
-
```
|
|
222
|
-
Merge pull request #1 from user/feature/feature-name
|
|
223
|
-
|
|
224
|
-
feat(scope): broadcast $destroy event on scope destruction
|
|
225
|
-
```
|
|
226
|
-
|
|
227
|
-
We can parse it with these options and the default headerPattern:
|
|
228
|
-
|
|
229
|
-
```js
|
|
230
|
-
{
|
|
231
|
-
mergePattern: /^Merge pull request #(\d+) from (.*)$/,
|
|
232
|
-
mergeCorrespondence: ['id', 'source']
|
|
233
|
-
}
|
|
234
|
-
```
|
|
235
|
-
|
|
236
|
-
#### mergeCorrespondence
|
|
237
|
-
|
|
238
|
-
Type: `string[]`,
|
|
239
|
-
Default: null
|
|
240
|
-
|
|
241
|
-
Used to define what capturing group of `mergePattern`.
|
|
242
|
-
|
|
243
|
-
#### headerPattern
|
|
244
|
-
|
|
245
|
-
Type: `RegExp`,
|
|
246
|
-
Default: `/^(\w*)(?:\(([\w\$\.\-\* ]*)\))?\: (.*)$/`
|
|
247
|
-
|
|
248
|
-
Used to match header pattern.
|
|
249
|
-
|
|
250
|
-
#### headerCorrespondence
|
|
251
|
-
|
|
252
|
-
Type: `string[]`,
|
|
253
|
-
Default `['type', 'scope', 'subject']`
|
|
254
|
-
|
|
255
|
-
Used to define what capturing group of `headerPattern` captures what header part. The order of the array should correspond to the order of `headerPattern`'s capturing group. If the part is not captured it is `null`.
|
|
256
|
-
|
|
257
|
-
#### referenceActions
|
|
258
|
-
|
|
259
|
-
Type: `(string | RegExp)[]`,
|
|
260
|
-
Default: `['close', 'closes', 'closed', 'fix', 'fixes', 'fixed', 'resolve', 'resolves', 'resolved']`
|
|
261
|
-
|
|
262
|
-
Keywords to reference an issue. This value is case **insensitive**. String values are escaped for use in a regex, while `RegExp` values are used as-is.
|
|
263
|
-
|
|
264
|
-
Set it to `null` to reference an issue without any action.
|
|
265
|
-
|
|
266
|
-
#### issuePrefixes
|
|
267
|
-
|
|
268
|
-
Type: `(string | RegExp)[]`,
|
|
269
|
-
Default: `['#']`
|
|
270
|
-
|
|
271
|
-
The prefixes of an issue. EG: In `gh-123` `gh-` is the prefix. String values are escaped for use in a regex, while `RegExp` values are used as-is.
|
|
272
|
-
|
|
273
|
-
#### issuePrefixesCaseSensitive
|
|
274
|
-
|
|
275
|
-
Type: `boolean`,
|
|
276
|
-
Default: false
|
|
277
|
-
|
|
278
|
-
Used to define if `issuePrefixes` should be considered case sensitive.
|
|
279
|
-
|
|
280
|
-
#### noteKeywords
|
|
281
|
-
|
|
282
|
-
Type: `(string | RegExp)[]`,
|
|
283
|
-
Default: `['BREAKING CHANGE', 'BREAKING-CHANGE']`
|
|
284
|
-
|
|
285
|
-
Keywords for important notes. This value is case **insensitive**. String values are escaped for use in a regex, while `RegExp` values are used as-is.
|
|
286
|
-
|
|
287
|
-
#### notesPattern
|
|
288
|
-
|
|
289
|
-
Type: `function`,
|
|
290
|
-
Default: `noteKeywordsSelection => ^[\\s|*]*(' + noteKeywordsSelection + ')[:\\s]+(.*)` where `noteKeywordsSelection` is `join(noteKeywords, '|')`
|
|
291
|
-
|
|
292
|
-
A function that takes `noteKeywordsSelection` and returns a `RegExp` to be matched against the notes.
|
|
293
|
-
|
|
294
|
-
#### fieldPattern
|
|
295
|
-
|
|
296
|
-
Type: `RegExp`,
|
|
297
|
-
Default: `/^-(.*?)-$/`
|
|
298
|
-
|
|
299
|
-
Pattern to match other fields.
|
|
300
|
-
|
|
301
|
-
#### revertPattern
|
|
302
|
-
|
|
303
|
-
Type: `RegExp`,
|
|
304
|
-
Default: `/^Revert\s"([\s\S]*)"\s*This reverts commit (\w*)\.?/`
|
|
305
|
-
|
|
306
|
-
Pattern to match what this commit reverts.
|
|
307
|
-
|
|
308
|
-
#### revertCorrespondence
|
|
309
|
-
|
|
310
|
-
Type: `string[]`,
|
|
311
|
-
Default: `['header', 'hash']`
|
|
312
|
-
|
|
313
|
-
Used to define what capturing group of `revertPattern` captures what reverted commit fields. The order of the array should correspond to the order of `revertPattern`'s capturing group.
|
|
314
|
-
|
|
315
|
-
For example, if we had commit
|
|
316
|
-
|
|
317
|
-
```
|
|
318
|
-
Revert "throw an error if a callback is passed"
|
|
319
|
-
|
|
320
|
-
This reverts commit 9bb4d6c.
|
|
321
|
-
```
|
|
322
|
-
|
|
323
|
-
If configured correctly, the parsed result would be
|
|
324
|
-
|
|
325
|
-
```js
|
|
326
|
-
{
|
|
327
|
-
revert: {
|
|
328
|
-
header: 'throw an error if a callback is passed',
|
|
329
|
-
hash: '9bb4d6c'
|
|
330
|
-
}
|
|
331
|
-
}
|
|
332
|
-
```
|
|
333
|
-
|
|
334
|
-
It implies that this commit reverts a commit with header `'throw an error if a callback is passed'` and hash `'9bb4d6c'`.
|
|
335
|
-
|
|
336
|
-
#### commentChar
|
|
337
|
-
|
|
338
|
-
Type: `string` or `null`,
|
|
339
|
-
Default: null
|
|
340
|
-
|
|
341
|
-
What commentChar to use. By default it is `null`, so no comments are stripped.
|
|
342
|
-
Set to `#` if you pass the contents of `.git/COMMIT_EDITMSG` directly.
|
|
343
|
-
|
|
344
|
-
If you have configured the git commentchar via `git config core.commentchar` you'll want to pass what you have set there.
|
|
345
|
-
|
|
346
|
-
#### warn
|
|
347
|
-
|
|
348
|
-
Type: `function` or `boolean`,
|
|
349
|
-
Default: `() => {}`
|
|
350
|
-
|
|
351
|
-
What warn function to use. For example, `console.warn.bind(console)`. By default, it's a noop. If it is `true`, it will error if commit cannot be parsed (strict).
|
|
352
|
-
|
|
353
|
-
## CLI
|
|
354
|
-
|
|
355
|
-
You can use cli to practice writing commit messages or parse messages from files. Note: the sample output might be different. It's just for demonstration purposes.
|
|
356
|
-
|
|
357
|
-
If you run `conventional-commits-parser` without any arguments
|
|
358
|
-
|
|
359
|
-
```sh
|
|
360
|
-
$ conventional-commits-parser --help # for more details
|
|
361
|
-
```
|
|
362
|
-
|
|
363
|
-
You will enter an interactive shell. To show your parsed output enter "return" three times (or enter your specified separator).
|
|
364
|
-
|
|
365
|
-
```sh
|
|
366
|
-
> fix(title): a title is fixed
|
|
367
|
-
|
|
368
|
-
{"type":"fix","scope":"title","subject":"a title is fixed","header":"fix(title): a title is fixed","body":null,"footer":null,"notes":[],"references":[],"revert":null}
|
|
369
|
-
```
|
|
370
|
-
|
|
371
|
-
You can also use cli to parse messages from files.
|
|
372
|
-
|
|
373
|
-
If you have log.txt
|
|
374
|
-
|
|
375
|
-
```text
|
|
376
|
-
feat(ngMessages): provide support for dynamic message resolution
|
|
377
|
-
|
|
378
|
-
Prior to this fix it was impossible to apply a binding to a the ngMessage directive to represent the name of the error.
|
|
379
|
-
|
|
380
|
-
BREAKING CHANGE: The `ngMessagesInclude` attribute is now its own directive and that must be placed as a **child** element within the element with the ngMessages directive.
|
|
381
|
-
|
|
382
|
-
Closes #10036
|
|
383
|
-
Closes #9338
|
|
384
|
-
```
|
|
385
|
-
|
|
386
|
-
And you run
|
|
387
|
-
|
|
388
|
-
```sh
|
|
389
|
-
$ conventional-commits-parser log.txt
|
|
390
|
-
# or
|
|
391
|
-
$ cat log.txt | conventional-commits-parser
|
|
392
|
-
```
|
|
393
|
-
|
|
394
|
-
An array of json will be printed to stdout.
|
|
395
|
-
|
|
396
|
-
```sh
|
|
397
|
-
[
|
|
398
|
-
{"type":"feat","scope":"ngMessages","subject":"provide support for dynamic message resolution","header":"feat(ngMessages): provide support for dynamic message resolution","body":"Prior to this fix it was impossible to apply a binding to a the ngMessage directive to represent the name of the error.","footer":"BREAKING CHANGE: The `ngMessagesInclude` attribute is now its own directive and that must be placed as a **child** element within the element with the ngMessages directive.\nCloses #10036\nCloses #9338","notes":[{"title":"BREAKING CHANGE","text":"The `ngMessagesInclude` attribute is now its own directive and that must be placed as a **child** element within the element with the ngMessages directive."}],"references":[{"action":"Closes","owner":null,"repository":null,"issue":"10036","raw":"#10036"},{"action":"Closes","owner":null,"repository":null,"issue":"9338","raw":"#9338"}],"revert":null}
|
|
399
|
-
]
|
|
400
|
-
```
|
|
401
|
-
|
|
402
|
-
Commits should be split by at least three newlines (`\n\n\n`) or you can specify a separator as the second argument.
|
|
403
|
-
|
|
404
|
-
Eg: in log2.txt
|
|
405
|
-
|
|
406
|
-
```text
|
|
407
|
-
|
|
408
|
-
docs(ngMessageExp): split ngMessage docs up to show its alias more clearly
|
|
409
|
-
===
|
|
410
|
-
|
|
411
|
-
fix($animate): applyStyles from options on leave
|
|
412
|
-
|
|
413
|
-
Closes #10068
|
|
414
|
-
```
|
|
415
|
-
|
|
416
|
-
And you run
|
|
417
|
-
|
|
418
|
-
```sh
|
|
419
|
-
$ conventional-commits-parser log2.txt '==='
|
|
420
|
-
```
|
|
421
|
-
|
|
422
|
-
```sh
|
|
423
|
-
[
|
|
424
|
-
{"type":"docs","scope":"ngMessageExp","subject":"split ngMessage docs up to show its alias more clearly","header":"docs(ngMessageExp): split ngMessage docs up to show its alias more clearly","body":null,"footer":null,"notes":[],"references":[],"revert":null}
|
|
425
|
-
,
|
|
426
|
-
{"type":"fix","scope":"$animate","subject":"applyStyles from options on leave","header":"fix($animate): applyStyles from options on leave","body":null,"footer":"Closes #10068","notes":[],"references":[{"action":"Closes","owner":null,"repository":null,"issue":"10068","raw":"#10068"}],"revert":null}
|
|
427
|
-
]
|
|
62
|
+
references: [{
|
|
63
|
+
action: 'Closes',
|
|
64
|
+
issue: '1',
|
|
65
|
+
raw: '#1',
|
|
66
|
+
prefix: '#',
|
|
67
|
+
...
|
|
68
|
+
}],
|
|
69
|
+
...
|
|
70
|
+
} */
|
|
428
71
|
```
|
|
429
72
|
|
|
430
|
-
|
|
73
|
+
## Documentation
|
|
431
74
|
|
|
432
|
-
|
|
75
|
+
For streams and async iterables helpers, parser options, and CLI usage, visit the [documentation website](https://conventional-changelog.js.org/commits-parser/).
|
|
433
76
|
|
|
434
77
|
## License
|
|
435
78
|
|
package/dist/cli/index.js
CHANGED
|
@@ -1,92 +1,56 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import { pipeline } from 'stream/promises';
|
|
3
|
-
import
|
|
3
|
+
import { readFile } from 'fs/promises';
|
|
4
|
+
import { readOptions, option, flag, alias, autocase, rest } from 'argue-cli';
|
|
4
5
|
import { parseCommits } from '../index.js';
|
|
5
6
|
import { parseOptions } from './options.js';
|
|
6
7
|
import { readRawCommitsFromFiles, readRawCommitsFromLine, readRawCommitsFromStdin, stringify } from './utils.js';
|
|
7
8
|
const DEFAULT_SEPARATOR = '\n\n\n';
|
|
8
|
-
const
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
9
|
+
const HELP = `
|
|
10
|
+
Practice writing commit messages or parse messages from files.
|
|
11
|
+
If used without specifying a text file path, you will enter an interactive shell.
|
|
12
|
+
Otherwise the commit messages in the files are parsed and printed
|
|
13
|
+
By default, commits will be split by three newlines ('\\n\\n\\n') or you can specify a separator.
|
|
13
14
|
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
15
|
+
Usage
|
|
16
|
+
conventional-commits-parser [-s <commit-separator>]
|
|
17
|
+
conventional-commits-parser [-s <commit-separator>] <path> [<path> ...]
|
|
18
|
+
cat <path> | conventional-commits-parser [-s <commit-separator>]
|
|
18
19
|
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
20
|
+
Example
|
|
21
|
+
conventional-commits-parser
|
|
22
|
+
conventional-commits-parser log.txt
|
|
23
|
+
cat log.txt | conventional-commits-parser
|
|
24
|
+
conventional-commits-parser log2.txt -s '===' >> parsed.txt
|
|
24
25
|
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
headerCorrespondence: {
|
|
50
|
-
shortFlag: 'c',
|
|
51
|
-
type: 'string'
|
|
52
|
-
},
|
|
53
|
-
referenceActions: {
|
|
54
|
-
shortFlag: 'r',
|
|
55
|
-
type: 'string'
|
|
56
|
-
},
|
|
57
|
-
issuePrefixes: {
|
|
58
|
-
shortFlag: 'i',
|
|
59
|
-
type: 'string'
|
|
60
|
-
},
|
|
61
|
-
issuePrefixesCaseSensitive: {
|
|
62
|
-
type: 'boolean'
|
|
63
|
-
},
|
|
64
|
-
noteKeywords: {
|
|
65
|
-
shortFlag: 'n',
|
|
66
|
-
type: 'string'
|
|
67
|
-
},
|
|
68
|
-
fieldPattern: {
|
|
69
|
-
shortFlag: 'f',
|
|
70
|
-
type: 'string'
|
|
71
|
-
},
|
|
72
|
-
revertPattern: {
|
|
73
|
-
type: 'string'
|
|
74
|
-
},
|
|
75
|
-
revertCorrespondence: {
|
|
76
|
-
type: 'string'
|
|
77
|
-
},
|
|
78
|
-
verbose: {
|
|
79
|
-
shortFlag: 'v',
|
|
80
|
-
type: 'boolean'
|
|
81
|
-
}
|
|
82
|
-
}
|
|
83
|
-
});
|
|
84
|
-
const { separator } = cli.flags;
|
|
85
|
-
const options = parseOptions(cli.flags);
|
|
26
|
+
Options
|
|
27
|
+
-s, --separator Commit separator
|
|
28
|
+
-p, --header-pattern Regex to match header pattern
|
|
29
|
+
-c, --header-correspondence Comma separated parts used to define what capturing group of 'headerPattern' captures what
|
|
30
|
+
-r, --reference-actions Comma separated keywords that used to reference issues
|
|
31
|
+
-i, --issue-prefixes Comma separated prefixes of an issue
|
|
32
|
+
--issue-prefixes-case-sensitive Treat issue prefixes as case sensitive
|
|
33
|
+
-n, --note-keywords Comma separated keywords for important notes
|
|
34
|
+
-f, --field-pattern Regex to match other fields
|
|
35
|
+
--revert-pattern Regex to match revert pattern
|
|
36
|
+
--revert-correspondence Comma separated fields used to define what the commit reverts
|
|
37
|
+
-v, --verbose Verbose output
|
|
38
|
+
`;
|
|
39
|
+
const flags = readOptions(option(alias('separator', 's'), String), option(autocase(alias('headerPattern', 'p')), String), option(autocase(alias('headerCorrespondence', 'c')), String), option(autocase(alias('referenceActions', 'r')), String), option(autocase(alias('issuePrefixes', 'i')), String), flag(autocase('issuePrefixesCaseSensitive')), option(autocase(alias('noteKeywords', 'n')), String), option(autocase(alias('fieldPattern', 'f')), String), option(autocase('revertPattern'), String), option(autocase('revertCorrespondence'), String), flag(alias('verbose', 'v')), flag('help'), flag('version'));
|
|
40
|
+
const files = rest();
|
|
41
|
+
if (flags.help || flags.version) {
|
|
42
|
+
const pkg = JSON.parse(await readFile(new URL('../../package.json', import.meta.url), 'utf8'));
|
|
43
|
+
console.log(flags.help
|
|
44
|
+
? `\n ${pkg.description}\n${HELP}`
|
|
45
|
+
: pkg.version);
|
|
46
|
+
process.exit(0);
|
|
47
|
+
}
|
|
48
|
+
const separator = flags.separator ?? DEFAULT_SEPARATOR;
|
|
49
|
+
const options = parseOptions(flags);
|
|
86
50
|
let inputStream;
|
|
87
51
|
try {
|
|
88
|
-
if (
|
|
89
|
-
inputStream = readRawCommitsFromFiles(
|
|
52
|
+
if (files.length) {
|
|
53
|
+
inputStream = readRawCommitsFromFiles(files, separator);
|
|
90
54
|
}
|
|
91
55
|
else if (process.stdin.isTTY) {
|
|
92
56
|
inputStream = readRawCommitsFromLine(separator);
|
|
@@ -100,4 +64,4 @@ catch (err) {
|
|
|
100
64
|
console.error(err);
|
|
101
65
|
process.exit(1);
|
|
102
66
|
}
|
|
103
|
-
//# sourceMappingURL=data:application/json;base64,
|
|
67
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi9zcmMvY2xpL2luZGV4LnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7QUFDQSxPQUFPLEVBQUUsUUFBUSxFQUFFLE1BQU0saUJBQWlCLENBQUE7QUFDMUMsT0FBTyxFQUFFLFFBQVEsRUFBRSxNQUFNLGFBQWEsQ0FBQTtBQUN0QyxPQUFPLEVBQ0wsV0FBVyxFQUNYLE1BQU0sRUFDTixJQUFJLEVBQ0osS0FBSyxFQUNMLFFBQVEsRUFDUixJQUFJLEVBQ0wsTUFBTSxXQUFXLENBQUE7QUFDbEIsT0FBTyxFQUFFLFlBQVksRUFBRSxNQUFNLGFBQWEsQ0FBQTtBQUMxQyxPQUFPLEVBQUUsWUFBWSxFQUFFLE1BQU0sY0FBYyxDQUFBO0FBQzNDLE9BQU8sRUFDTCx1QkFBdUIsRUFDdkIsc0JBQXNCLEVBQ3RCLHVCQUF1QixFQUN2QixTQUFTLEVBQ1YsTUFBTS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BQ0MsSUFBSSxPQUFPLENBQUMsS0FBSyxDQUFDLEtBQUssRUFBRSxDQUFDO1FBQ3hCLFdBQVcsR0FBRyxzQkFBc0IsQ0FBQyxTQUFTLENBQUMsQ0FBQTtJQUNqRCxDQUFDO1NBQU0sQ0FBQztRQUNOLFdBQVcsR0FBRyx1QkFBdUIsQ0FBQyxTQUFTLENBQUMsQ0FBQTtJQUNsRCxDQUFDO0lBRUgsTUFBTSxRQUFRLENBQ1osV0FBVyxFQUNYLFlBQVksQ0FBQyxPQUFPLENBQUMsRUFDckIsU0FBUyxFQUNULE9BQU8sQ0FBQyxNQUFNLENBQ2YsQ0FBQTtBQUNILENBQUM7QUFBQyxPQUFPLEdBQUcsRUFBRSxDQUFDO0lBQ2IsT0FBTyxDQUFDLEtBQUssQ0FBQyxHQUFHLENBQUMsQ0FBQTtJQUNsQixPQUFPLENBQUMsSUFBSSxDQUFDLENBQUMsQ0FBQyxDQUFBO0FBQ2pCLENBQUMifQ==
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "conventional-commits-parser",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "7.
|
|
4
|
+
"version": "7.1.0",
|
|
5
5
|
"description": "Parse raw conventional commits.",
|
|
6
6
|
"author": {
|
|
7
7
|
"name": "Steve Mao",
|
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
"url": "https://github.com/stevemao"
|
|
10
10
|
},
|
|
11
11
|
"license": "MIT",
|
|
12
|
-
"homepage": "https://
|
|
12
|
+
"homepage": "https://conventional-changelog.js.org/commits-parser/",
|
|
13
13
|
"repository": {
|
|
14
14
|
"type": "git",
|
|
15
15
|
"url": "https://github.com/conventional-changelog/conventional-changelog.git",
|
|
@@ -38,7 +38,7 @@
|
|
|
38
38
|
],
|
|
39
39
|
"dependencies": {
|
|
40
40
|
"@simple-libs/stream-utils": "^2.0.0",
|
|
41
|
-
"
|
|
41
|
+
"argue-cli": "^3.1.0"
|
|
42
42
|
},
|
|
43
43
|
"bin": {
|
|
44
44
|
"conventional-commits-parser": "./dist/cli/index.js"
|