Gathering detailed insights and metrics for conventional-commits-parser
Gathering detailed insights and metrics for conventional-commits-parser
Gathering detailed insights and metrics for conventional-commits-parser
Gathering detailed insights and metrics for conventional-commits-parser
@types/conventional-commits-parser
TypeScript definitions for conventional-commits-parser
conventional-commits-filter
Filter out reverted commits parsed by conventional-commits-parser.
@conventional-commits/parser
reference implementation of conventionalcommits.org spec
@marionebl/conventional-commits-parser
Parse raw conventional commits
Generate changelogs and release notes from a project's commit messages and metadata.
npm install conventional-commits-parser
Typescript
Module System
Min. Node Version
Node Version
NPM Version
98.5
Supply Chain
100
Quality
81.9
Maintenance
100
Vulnerability
99.6
License
conventional-commits-parser: v6.1.0
Updated on Feb 16, 2025
conventional-recommended-bump: v11.0.0
Updated on Feb 16, 2025
conventional-changelog-writer: v8.0.1
Updated on Feb 16, 2025
git-client: v2.0.0
Updated on Feb 16, 2025
conventional-changelog-core: v9.0.0
Updated on Feb 16, 2025
git-client: v1.0.1
Updated on May 06, 2024
TypeScript (78.81%)
JavaScript (18.84%)
Handlebars (2.34%)
Total Downloads
1,179,002,611
Last Day
1,555,570
Last Week
8,464,958
Last Month
35,119,075
Last Year
356,019,065
ISC License
8,080 Stars
1,741 Commits
731 Forks
55 Watchers
6 Branches
150 Contributors
Updated on May 09, 2025
Latest Version
6.1.0
Package Id
conventional-commits-parser@6.1.0
Unpacked Size
73.47 kB
Size
19.70 kB
File Count
33
NPM Version
10.8.2
Node Version
18.20.6
Published on
Feb 16, 2025
Cumulative downloads
Total Downloads
1
Parse raw conventional commits.
1# pnpm 2pnpm add conventional-commits-parser 3# yarn 4yarn add conventional-commits-parser 5# npm 6npm i conventional-commits-parser
1import { 2 CommitParser, 3 parseCommits, 4 parseCommitsStream 5} from 'conventional-commits-parser' 6import { pipeline } from 'stream/promises' 7import { Readable } from 'stream' 8 9const rawCommitMessage = 'feat(scope): broadcast $destroy event on scope destruction\nCloses #1' 10 11// to parse raw commit message manually: 12const parser = new CommitParser(options) 13 14console.log(parser.parse(rawCommitMessage)) 15 16// to parse raw commit messages async iterables: 17await pipeline( 18 [rawCommitMessage], 19 parseCommits(options), 20 async function* (parsedCommits) { 21 for await (const commit of parsedCommits) { 22 console.log(commit) 23 } 24 } 25) 26 27// to parse raw commit messages streams: 28Readable.from([rawCommitMessage]) 29 .pipe(parseCommitsStream(options)) 30 .on('data', commit => console.log(commit))
Parser expects raw commit message. Examples:
1'feat(scope): broadcast $destroy event on scope destruction\nCloses #1' 2'feat(ng-list): Allow custom separator\nbla bla bla\n\nBREAKING CHANGE: some breaking change.\nThanks @stevemao\n'
It will return parsed commit object. Examples:
1{ 2 type: 'feat', 3 scope: 'scope', 4 subject: 'broadcast $destroy event on scope destruction', 5 merge: null, 6 header: 'feat(scope): broadcast $destroy event on scope destruction', 7 body: null, 8 footer: 'Closes #1', 9 notes: [], 10 references: 11 [{ 12 action: 'Closes', 13 owner: null, 14 repository: null, 15 issue: '1', 16 raw: '#1', 17 prefix: '#' 18 }], 19 mentions: [], 20 revert: null 21} 22{ 23 type: 'feat', 24 scope: 'ng-list', 25 subject: 'Allow custom separator', 26 merge: null, 27 header: 'feat(ng-list): Allow custom separator', 28 body: 'bla bla bla', 29 footer: 'BREAKING CHANGE: some breaking change.\nThanks @stevemao', 30 notes: 31 [{ 32 title: 'BREAKING CHANGE', 33 text: 'some breaking change.\nThanks @stevemao' 34 }], 35 references: [], 36 mentions: ['stevemao'], 37 revert: null 38}
A minimum input should contain a raw message.
Each commit message consists of a merge header, a header (mandatory), a body and a footer. Mention (optional) someone using the @
notation.
<merge>
<header>
<body>
<footer>
The merge header may optionally have a special format that includes other parts, such as branch, issueId or source.
Merge branch <branch>
Merge pull request <issue-id> from <source>
The header may optionally have a special format that includes other parts, such as type, scope and subject. You could reference (optional) issues here.
<type>(<scope>): <subject>
The footer should contain any information about Important Notes (optional) and is also the place to reference (optional) issues.
<important note>
<references>
This module will only parse the message body. However, it is possible to include other fields such as hash, committer or date.
My commit message
-sideNotes-
It should warn the correct unfound file names.
Also it should continue if one file cannot be found.
Tests are added for these
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
.
new CommitParser(options?: ParserOptions)
Creates parser instance with parse
method.
parseCommits(options?: ParserOptions)
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).
parseCommitsStream(options?: ParserOptions)
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).
Type: RegExp
Default: null
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.
For example, if we have a commit
Merge pull request #1 from user/feature/feature-name
feat(scope): broadcast $destroy event on scope destruction
We can parse it with these options and the default headerPattern:
1{ 2 mergePattern: /^Merge pull request #(\d+) from (.*)$/, 3 mergeCorrespondence: ['id', 'source'] 4}
Type: string[]
,
Default: null
Used to define what capturing group of mergePattern
.
Type: RegExp
,
Default: /^(\w*)(?:\(([\w\$\.\-\* ]*)\))?\: (.*)$/
Used to match header pattern.
Type: string[]
,
Default ['type', 'scope', 'subject']
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
.
Type: string[]
,
Default: ['close', 'closes', 'closed', 'fix', 'fixes', 'fixed', 'resolve', 'resolves', 'resolved']
Keywords to reference an issue. This value is case insensitive.
Set it to null
to reference an issue without any action.
Type: string[]
,
Default: ['#']
The prefixes of an issue. EG: In gh-123
gh-
is the prefix.
Type: boolean
,
Default: false
Used to define if issuePrefixes
should be considered case sensitive.
Type: string[]
,
Default: ['BREAKING CHANGE', 'BREAKING-CHANGE']
Keywords for important notes. This value is case insensitive.
Type: function
,
Default: noteKeywordsSelection => ^[\\s|*]*(' + noteKeywordsSelection + ')[:\\s]+(.*)
where noteKeywordsSelection
is join(noteKeywords, '|')
A function that takes noteKeywordsSelection
and returns a RegExp
to be matched against the notes.
Type: RegExp
,
Default: /^-(.*?)-$/
Pattern to match other fields.
Type: RegExp
,
Default: /^Revert\s"([\s\S]*)"\s*This reverts commit (\w*)\./
Pattern to match what this commit reverts.
Type: string[]
,
Default: ['header', 'hash']
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.
For example, if we had commit
Revert "throw an error if a callback is passed"
This reverts commit 9bb4d6c.
If configured correctly, the parsed result would be
1{ 2 revert: { 3 header: 'throw an error if a callback is passed', 4 hash: '9bb4d6c' 5 } 6}
It implies that this commit reverts a commit with header 'throw an error if a callback is passed'
and hash '9bb4d6c'
.
Type: string
or null
,
Default: null
What commentChar to use. By default it is null
, so no comments are stripped.
Set to #
if you pass the contents of .git/COMMIT_EDITMSG
directly.
If you have configured the git commentchar via git config core.commentchar
you'll want to pass what you have set there.
Type: function
or boolean
,
Default: () => {}
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).
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.
If you run conventional-commits-parser
without any arguments
1$ conventional-commits-parser --help # for more details
You will enter an interactive shell. To show your parsed output enter "return" three times (or enter your specified separator).
1> fix(title): a title is fixed 2 3 4{"type":"fix","scope":"title","subject":"a title is fixed","header":"fix(title): a title is fixed","body":null,"footer":null,"notes":[],"references":[],"revert":null}
You can also use cli to parse messages from files.
If you have log.txt
1feat(ngMessages): provide support for dynamic message resolution 2 3Prior to this fix it was impossible to apply a binding to a the ngMessage directive to represent the name of the error. 4 5BREAKING 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. 6 7Closes #10036 8Closes #9338
And you run
1$ conventional-commits-parser log.txt 2# or 3$ cat log.txt | conventional-commits-parser
An array of json will be printed to stdout.
1[ 2{"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} 3]
Commits should be split by at least three newlines (\n\n\n
) or you can specify a separator as the second argument.
Eg: in log2.txt
1 2docs(ngMessageExp): split ngMessage docs up to show its alias more clearly 3=== 4 5fix($animate): applyStyles from options on leave 6 7Closes #10068
And you run
1$ conventional-commits-parser log2.txt '==='
1[ 2{"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} 3, 4{"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} 5]
Will be printed out.
You can specify one or more files. The output array will be in order of the input file paths. If you specify more than one separator, the last one will be used.
MIT © Steve Mao
No vulnerabilities found.
Reason
19 commit(s) and 7 issue activity found in the last 90 days -- score normalized to 10
Reason
no dangerous workflow patterns detected
Reason
no binaries found in the repo
Reason
license file detected
Details
Reason
packaging workflow detected
Details
Reason
5 existing vulnerabilities detected
Details
Reason
Found 3/15 approved changesets -- score normalized to 2
Reason
detected GitHub workflow tokens with excessive permissions
Details
Reason
dependency not pinned by hash detected -- score normalized to 0
Details
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
security policy file not detected
Details
Reason
project is not fuzzed
Details
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
Score
Last Scanned on 2025-05-05
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn MoreLast Day
61.4%
1,555,570
Compared to previous day
Last Week
8.3%
8,464,958
Compared to previous week
Last Month
-2.1%
35,119,075
Compared to previous month
Last Year
39.1%
356,019,065
Compared to previous year