Skip to content

Commit 8d0ffbe

Browse files
authored
feat!: unified presets interface (#1045)
BREAKING CHANGE: Now all presets are exports preset config factory function. conventional-changelog-preset-loader now exports new loadPreset and createPresetLoader functions. If you are using presets indirectly, using preset name, no any changes in configuration needed, just upgrade packages to latest versions.
1 parent 87914a3 commit 8d0ffbe

File tree

114 files changed

+1613
-1256
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

114 files changed

+1613
-1256
lines changed

README.md

+8-6
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,15 @@
11
# Conventional Changelog
22

3-
[![Build Status](https://travis-ci.org/conventional-changelog/conventional-changelog.svg?branch=master)](https://travis-ci.org/conventional-changelog/conventional-changelog)
4-
[![Coverage Status](https://coveralls.io/repos/github/conventional-changelog/conventional-changelog/badge.svg?branch=master)](https://coveralls.io/github/conventional-changelog/conventional-changelog?branch=master?branch=master)
5-
[![Standard Version](https://img.shields.io/badge/release-standard%20version-brightgreen.svg)](https://github.com/conventional-changelog/standard-version)
6-
[![community slack](http://devtoolscommunity.herokuapp.com/badge.svg)](http://devtoolscommunity.herokuapp.com)
3+
[![Build status][build]][build-url]
4+
[![Coverage status][coverage]][coverage-url]
75

8-
_Having problems? want to contribute? join our [community slack](http://devtoolscommunity.herokuapp.com)_.
6+
[build]: https://img.shields.io/github/actions/workflow/status/conventional-changelog/conventional-changelog/ci.yaml?branch=master
7+
[build-url]: https://github.com/conventional-changelog/conventional-changelog/actions
98

10-
> Generate a CHANGELOG from git metadata
9+
[coverage]: https://coveralls.io/repos/github/conventional-changelog/conventional-changelog/badge.svg?branch=master
10+
[coverage-url]: https://coveralls.io/github/conventional-changelog/conventional-changelog?branch=master
11+
12+
Generate a CHANGELOG from git metadata.
1113

1214
## About this Repo
1315

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@
6060
"pinkie-promise": "^2.0.1",
6161
"rimraf": "^3.0.2",
6262
"safe-buffer": "5.2.1",
63-
"semver": "^7.0.0",
63+
"semver": "^7.5.2",
6464
"sinon": "^15.0.0",
6565
"sinon-chai": "^3.7.0",
6666
"tmp": "^0.2.1",

packages/conventional-changelog-angular/README.md

+34-12
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,41 @@
1-
# [![NPM version][npm-image]][npm-url] [![Build Status][travis-image]][travis-url] [![Dependency Status][daviddm-image]][daviddm-url] [![Coverage Status][coverage-image]][coverage-url]
1+
# conventional-changelog-angular
22

3-
> [conventional-changelog](https://github.com/ajoslin/conventional-changelog) [angular](https://github.com/angular/angular) preset
3+
[![NPM version][npm]][npm-url]
4+
[![Node version][node]][node-url]
5+
[![Dependencies status][deps]][deps-url]
6+
[![Build status][build]][build-url]
7+
[![Coverage status][coverage]][coverage-url]
8+
9+
[npm]: https://img.shields.io/npm/v/conventional-changelog-angular.svg
10+
[npm-url]: https://npmjs.com/package/conventional-changelog-angular
11+
12+
[node]: https://img.shields.io/node/v/conventional-changelog-angular.svg
13+
[node-url]: https://nodejs.org
14+
15+
[deps]: https://img.shields.io/librariesio/release/npm/conventional-changelog-angular
16+
[deps-url]: https://libraries.io/npm/conventional-changelog-angular/tree
17+
18+
[build]: https://img.shields.io/github/actions/workflow/status/conventional-changelog/conventional-changelog/ci.yaml?branch=master
19+
[build-url]: https://github.com/conventional-changelog/conventional-changelog/actions
20+
21+
[coverage]: https://coveralls.io/repos/github/conventional-changelog/conventional-changelog/badge.svg?branch=master
22+
[coverage-url]: https://coveralls.io/github/conventional-changelog/conventional-changelog?branch=master
23+
24+
[conventional-changelog](https://github.com/conventional-changelog/conventional-changelog) [angular](https://github.com/angular/angular) preset.
425

526
**Issues with the convention itself should be reported on the Angular issue tracker.**
627

28+
## Install
29+
30+
```bash
31+
# yarn
32+
yarn add -D conventional-changelog-angular
33+
# pnpm
34+
pnpm add -D conventional-changelog-angular
35+
# npm
36+
npm i -D conventional-changelog-angular
37+
```
38+
739
## Angular Convention
840

941
Angular's [commit message guidelines](https://github.com/angular/angular/blob/master/CONTRIBUTING.md#commit).
@@ -92,13 +124,3 @@ reference GitHub issues that this commit **Closes**.
92124
**Breaking Changes** should start with the word `BREAKING CHANGE:` with a space or two newlines. The rest of the commit message is then used for this.
93125

94126
A detailed explanation can be found in this [document](#commit-message-format).
95-
96-
[npm-image]: https://badge.fury.io/js/conventional-changelog-angular.svg
97-
[npm-url]: https://npmjs.org/package/conventional-changelog-angular
98-
[travis-image]: https://travis-ci.org/conventional-changelog/conventional-changelog-angular.svg?branch=master
99-
[travis-url]: https://travis-ci.org/conventional-changelog/conventional-changelog-angular
100-
[daviddm-image]: https://david-dm.org/conventional-changelog/conventional-changelog-angular.svg?theme=shields.io
101-
[daviddm-url]: https://david-dm.org/conventional-changelog/conventional-changelog-angular
102-
[coverage-image]: https://coveralls.io/repos/github/conventional-changelog/conventional-changelog/badge.svg?branch=master
103-
[coverage-url]: https://coveralls.io/github/conventional-changelog/conventional-changelog?branch=master
104-
[commit-message-format]: https://docs.google.com/document/d/1QrDFcIiPjSLDn3EL15IJygNPiHORgU1_OOAqWjiDU5Y/edit#

packages/conventional-changelog-angular/conventional-changelog.js

-10
This file was deleted.

packages/conventional-changelog-angular/conventional-recommended-bump.js

-32
This file was deleted.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
'use strict'
2+
3+
function createConventionalChangelogOpts (parserOpts, writerOpts) {
4+
return {
5+
parserOpts,
6+
writerOpts
7+
}
8+
}
9+
10+
module.exports.createConventionalChangelogOpts = createConventionalChangelogOpts
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
'use strict'
2+
3+
function createConventionalRecommendedBumpOpts (parserOpts) {
4+
return {
5+
parserOpts,
6+
7+
whatBump (commits) {
8+
let level = 2
9+
let breakings = 0
10+
let features = 0
11+
12+
commits.forEach(commit => {
13+
if (commit.notes.length > 0) {
14+
breakings += commit.notes.length
15+
level = 0
16+
} else if (commit.type === 'feat') {
17+
features += 1
18+
if (level === 2) {
19+
level = 1
20+
}
21+
}
22+
})
23+
24+
return {
25+
level: level,
26+
reason: breakings === 1
27+
? `There is ${breakings} BREAKING CHANGE and ${features} features`
28+
: `There are ${breakings} BREAKING CHANGES and ${features} features`
29+
}
30+
}
31+
}
32+
}
33+
34+
module.exports.createConventionalRecommendedBumpOpts = createConventionalRecommendedBumpOpts
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,22 @@
11
'use strict'
2-
const conventionalChangelog = require('./conventional-changelog')
3-
const parserOpts = require('./parser-opts')
4-
const recommendedBumpOpts = require('./conventional-recommended-bump')
5-
const writerOpts = require('./writer-opts')
6-
7-
module.exports = Promise.all([conventionalChangelog, parserOpts, recommendedBumpOpts, writerOpts])
8-
.then(([conventionalChangelog, parserOpts, recommendedBumpOpts, writerOpts]) => ({
9-
conventionalChangelog,
2+
3+
const { createParserOpts } = require('./parserOpts')
4+
const { createWriterOpts } = require('./writerOpts')
5+
const { createConventionalChangelogOpts } = require('./conventionalChangelog')
6+
const { createConventionalRecommendedBumpOpts } = require('./conventionalRecommendedBump')
7+
8+
async function createPreset () {
9+
const parserOpts = createParserOpts()
10+
const writerOpts = await createWriterOpts()
11+
const recommendedBumpOpts = createConventionalRecommendedBumpOpts(parserOpts)
12+
const conventionalChangelog = createConventionalChangelogOpts(parserOpts, writerOpts)
13+
14+
return {
1015
parserOpts,
16+
writerOpts,
1117
recommendedBumpOpts,
12-
writerOpts
13-
}))
18+
conventionalChangelog
19+
}
20+
}
21+
22+
module.exports = createPreset

packages/conventional-changelog-angular/package.json

+4-4
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,11 @@
1616
"preset"
1717
],
1818
"files": [
19-
"conventional-changelog.js",
20-
"conventional-recommended-bump.js",
19+
"conventionalChangelog.js",
20+
"conventionalRecommendedBump.js",
2121
"index.js",
22-
"parser-opts.js",
23-
"writer-opts.js",
22+
"parserOpts.js",
23+
"writerOpts.js",
2424
"templates"
2525
],
2626
"author": "Steve Mao",

packages/conventional-changelog-angular/parser-opts.js

-13
This file was deleted.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
'use strict'
2+
3+
function createParserOpts () {
4+
return {
5+
headerPattern: /^(\w*)(?:\((.*)\))?: (.*)$/,
6+
headerCorrespondence: [
7+
'type',
8+
'scope',
9+
'subject'
10+
],
11+
noteKeywords: ['BREAKING CHANGE'],
12+
revertPattern: /^(?:Revert|revert:)\s"?([\s\S]+?)"?\s*This reverts commit (\w*)\./i,
13+
revertCorrespondence: ['header', 'hash']
14+
}
15+
}
16+
17+
module.exports.createParserOpts = createParserOpts

packages/conventional-changelog-angular/writer-opts.js packages/conventional-changelog-angular/writerOpts.js

+16-14
Original file line numberDiff line numberDiff line change
@@ -4,22 +4,24 @@ const compareFunc = require('compare-func')
44
const { readFile } = require('fs').promises
55
const { resolve } = require('path')
66

7-
module.exports = Promise.all([
8-
readFile(resolve(__dirname, './templates/template.hbs'), 'utf-8'),
9-
readFile(resolve(__dirname, './templates/header.hbs'), 'utf-8'),
10-
readFile(resolve(__dirname, './templates/commit.hbs'), 'utf-8'),
11-
readFile(resolve(__dirname, './templates/footer.hbs'), 'utf-8')
12-
])
13-
.then(([template, header, commit, footer]) => {
14-
const writerOpts = getWriterOpts()
7+
async function createWriterOpts () {
8+
const [template, header, commit, footer] = await Promise.all([
9+
readFile(resolve(__dirname, './templates/template.hbs'), 'utf-8'),
10+
readFile(resolve(__dirname, './templates/header.hbs'), 'utf-8'),
11+
readFile(resolve(__dirname, './templates/commit.hbs'), 'utf-8'),
12+
readFile(resolve(__dirname, './templates/footer.hbs'), 'utf-8')
13+
])
14+
const writerOpts = getWriterOpts()
1515

16-
writerOpts.mainTemplate = template
17-
writerOpts.headerPartial = header
18-
writerOpts.commitPartial = commit
19-
writerOpts.footerPartial = footer
16+
writerOpts.mainTemplate = template
17+
writerOpts.headerPartial = header
18+
writerOpts.commitPartial = commit
19+
writerOpts.footerPartial = footer
2020

21-
return writerOpts
22-
})
21+
return writerOpts
22+
}
23+
24+
module.exports.createWriterOpts = createWriterOpts
2325

2426
function getWriterOpts () {
2527
return {

packages/conventional-changelog-atom/README.md

+34-11
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,41 @@
1-
# [![NPM version][npm-image]][npm-url] [![Build Status][travis-image]][travis-url] [![Dependency Status][daviddm-image]][daviddm-url] [![Coverage Status][coverage-image]][coverage-url]
1+
# conventional-changelog-atom
22

3-
> [conventional-changelog](https://github.com/ajoslin/conventional-changelog) [atom](https://github.com/atom/atom) preset
3+
[![NPM version][npm]][npm-url]
4+
[![Node version][node]][node-url]
5+
[![Dependencies status][deps]][deps-url]
6+
[![Build status][build]][build-url]
7+
[![Coverage status][coverage]][coverage-url]
8+
9+
[npm]: https://img.shields.io/npm/v/conventional-changelog-atom.svg
10+
[npm-url]: https://npmjs.com/package/conventional-changelog-atom
11+
12+
[node]: https://img.shields.io/node/v/conventional-changelog-atom.svg
13+
[node-url]: https://nodejs.org
14+
15+
[deps]: https://img.shields.io/librariesio/release/npm/conventional-changelog-atom
16+
[deps-url]: https://libraries.io/npm/conventional-changelog-atom/tree
17+
18+
[build]: https://img.shields.io/github/actions/workflow/status/conventional-changelog/conventional-changelog/ci.yaml?branch=master
19+
[build-url]: https://github.com/conventional-changelog/conventional-changelog/actions
20+
21+
[coverage]: https://coveralls.io/repos/github/conventional-changelog/conventional-changelog/badge.svg?branch=master
22+
[coverage-url]: https://coveralls.io/github/conventional-changelog/conventional-changelog?branch=master
23+
24+
[conventional-changelog](https://github.com/conventional-changelog/conventional-changelog) [atom](https://github.com/atom/atom) preset.
425

526
**Issues with the convention itself should be reported on the Atom issue tracker.**
627

28+
## Install
29+
30+
```bash
31+
# yarn
32+
yarn add -D conventional-changelog-atom
33+
# pnpm
34+
pnpm add -D conventional-changelog-atom
35+
# npm
36+
npm i -D conventional-changelog-atom
37+
```
38+
739
## Atom Convention
840

941
### Git Commit Messages
@@ -30,12 +62,3 @@
3062
* :shirt: `:shirt:` when removing linter warnings
3163

3264
Based on https://github.com/atom/atom/blob/master/CONTRIBUTING.md#git-commit-messages
33-
34-
[npm-image]: https://badge.fury.io/js/conventional-changelog-atom.svg
35-
[npm-url]: https://npmjs.org/package/conventional-changelog-atom
36-
[travis-image]: https://travis-ci.org/stevemao/conventional-changelog-atom.svg?branch=master
37-
[travis-url]: https://travis-ci.org/stevemao/conventional-changelog-atom
38-
[daviddm-image]: https://david-dm.org/stevemao/conventional-changelog-atom.svg?theme=shields.io
39-
[daviddm-url]: https://david-dm.org/stevemao/conventional-changelog-atom
40-
[coverage-image]: https://coveralls.io/repos/github/conventional-changelog/conventional-changelog/badge.svg?branch=master
41-
[coverage-url]: https://coveralls.io/github/conventional-changelog/conventional-changelog?branch=master

packages/conventional-changelog-atom/conventional-changelog.js

-10
This file was deleted.

packages/conventional-changelog-atom/conventional-recommended-bump.js

-30
This file was deleted.

0 commit comments

Comments
 (0)