Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat!: unified presets interface #1045

Merged
merged 1 commit into from
Jul 10, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
14 changes: 8 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
# Conventional Changelog

[![Build Status](https://travis-ci.org/conventional-changelog/conventional-changelog.svg?branch=master)](https://travis-ci.org/conventional-changelog/conventional-changelog)
[![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)
[![Standard Version](https://img.shields.io/badge/release-standard%20version-brightgreen.svg)](https://github.com/conventional-changelog/standard-version)
[![community slack](http://devtoolscommunity.herokuapp.com/badge.svg)](http://devtoolscommunity.herokuapp.com)
[![Build status][build]][build-url]
[![Coverage status][coverage]][coverage-url]

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

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

Generate a CHANGELOG from git metadata.

## About this Repo

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@
"pinkie-promise": "^2.0.1",
"rimraf": "^3.0.2",
"safe-buffer": "5.2.1",
"semver": "^7.0.0",
"semver": "^7.5.2",
"sinon": "^15.0.0",
"sinon-chai": "^3.7.0",
"tmp": "^0.2.1",
Expand Down
46 changes: 34 additions & 12 deletions packages/conventional-changelog-angular/README.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,41 @@
# [![NPM version][npm-image]][npm-url] [![Build Status][travis-image]][travis-url] [![Dependency Status][daviddm-image]][daviddm-url] [![Coverage Status][coverage-image]][coverage-url]
# conventional-changelog-angular

> [conventional-changelog](https://github.com/ajoslin/conventional-changelog) [angular](https://github.com/angular/angular) preset
[![NPM version][npm]][npm-url]
[![Node version][node]][node-url]
[![Dependencies status][deps]][deps-url]
[![Build status][build]][build-url]
[![Coverage status][coverage]][coverage-url]

[npm]: https://img.shields.io/npm/v/conventional-changelog-angular.svg
[npm-url]: https://npmjs.com/package/conventional-changelog-angular

[node]: https://img.shields.io/node/v/conventional-changelog-angular.svg
[node-url]: https://nodejs.org

[deps]: https://img.shields.io/librariesio/release/npm/conventional-changelog-angular
[deps-url]: https://libraries.io/npm/conventional-changelog-angular/tree

[build]: https://img.shields.io/github/actions/workflow/status/conventional-changelog/conventional-changelog/ci.yaml?branch=master
[build-url]: https://github.com/conventional-changelog/conventional-changelog/actions

[coverage]: https://coveralls.io/repos/github/conventional-changelog/conventional-changelog/badge.svg?branch=master
[coverage-url]: https://coveralls.io/github/conventional-changelog/conventional-changelog?branch=master

[conventional-changelog](https://github.com/conventional-changelog/conventional-changelog) [angular](https://github.com/angular/angular) preset.

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

## Install

```bash
# yarn
yarn add -D conventional-changelog-angular
# pnpm
pnpm add -D conventional-changelog-angular
# npm
npm i -D conventional-changelog-angular
```

## Angular Convention

Angular's [commit message guidelines](https://github.com/angular/angular/blob/master/CONTRIBUTING.md#commit).
Expand Down Expand Up @@ -92,13 +124,3 @@ reference GitHub issues that this commit **Closes**.
**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.

A detailed explanation can be found in this [document](#commit-message-format).

[npm-image]: https://badge.fury.io/js/conventional-changelog-angular.svg
[npm-url]: https://npmjs.org/package/conventional-changelog-angular
[travis-image]: https://travis-ci.org/conventional-changelog/conventional-changelog-angular.svg?branch=master
[travis-url]: https://travis-ci.org/conventional-changelog/conventional-changelog-angular
[daviddm-image]: https://david-dm.org/conventional-changelog/conventional-changelog-angular.svg?theme=shields.io
[daviddm-url]: https://david-dm.org/conventional-changelog/conventional-changelog-angular
[coverage-image]: https://coveralls.io/repos/github/conventional-changelog/conventional-changelog/badge.svg?branch=master
[coverage-url]: https://coveralls.io/github/conventional-changelog/conventional-changelog?branch=master
[commit-message-format]: https://docs.google.com/document/d/1QrDFcIiPjSLDn3EL15IJygNPiHORgU1_OOAqWjiDU5Y/edit#
10 changes: 0 additions & 10 deletions packages/conventional-changelog-angular/conventional-changelog.js

This file was deleted.

This file was deleted.

10 changes: 10 additions & 0 deletions packages/conventional-changelog-angular/conventionalChangelog.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
'use strict'

function createConventionalChangelogOpts (parserOpts, writerOpts) {
return {
parserOpts,
writerOpts
}
}

module.exports.createConventionalChangelogOpts = createConventionalChangelogOpts
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
'use strict'

function createConventionalRecommendedBumpOpts (parserOpts) {
return {
parserOpts,

whatBump (commits) {
let level = 2
let breakings = 0
let features = 0

commits.forEach(commit => {
if (commit.notes.length > 0) {
breakings += commit.notes.length
level = 0
} else if (commit.type === 'feat') {
features += 1
if (level === 2) {
level = 1
}
}
})

return {
level: level,
reason: breakings === 1
? `There is ${breakings} BREAKING CHANGE and ${features} features`
: `There are ${breakings} BREAKING CHANGES and ${features} features`
}
}
}
}

module.exports.createConventionalRecommendedBumpOpts = createConventionalRecommendedBumpOpts
29 changes: 19 additions & 10 deletions packages/conventional-changelog-angular/index.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,22 @@
'use strict'
const conventionalChangelog = require('./conventional-changelog')
const parserOpts = require('./parser-opts')
const recommendedBumpOpts = require('./conventional-recommended-bump')
const writerOpts = require('./writer-opts')

module.exports = Promise.all([conventionalChangelog, parserOpts, recommendedBumpOpts, writerOpts])
.then(([conventionalChangelog, parserOpts, recommendedBumpOpts, writerOpts]) => ({
conventionalChangelog,

const { createParserOpts } = require('./parserOpts')
const { createWriterOpts } = require('./writerOpts')
const { createConventionalChangelogOpts } = require('./conventionalChangelog')
const { createConventionalRecommendedBumpOpts } = require('./conventionalRecommendedBump')

async function createPreset () {
const parserOpts = createParserOpts()
const writerOpts = await createWriterOpts()
const recommendedBumpOpts = createConventionalRecommendedBumpOpts(parserOpts)
const conventionalChangelog = createConventionalChangelogOpts(parserOpts, writerOpts)

return {
parserOpts,
writerOpts,
recommendedBumpOpts,
writerOpts
}))
conventionalChangelog
}
}

module.exports = createPreset
8 changes: 4 additions & 4 deletions packages/conventional-changelog-angular/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@
"preset"
],
"files": [
"conventional-changelog.js",
"conventional-recommended-bump.js",
"conventionalChangelog.js",
"conventionalRecommendedBump.js",
"index.js",
"parser-opts.js",
"writer-opts.js",
"parserOpts.js",
"writerOpts.js",
"templates"
],
"author": "Steve Mao",
Expand Down
13 changes: 0 additions & 13 deletions packages/conventional-changelog-angular/parser-opts.js

This file was deleted.

17 changes: 17 additions & 0 deletions packages/conventional-changelog-angular/parserOpts.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
'use strict'

function createParserOpts () {
return {
headerPattern: /^(\w*)(?:\((.*)\))?: (.*)$/,
headerCorrespondence: [
'type',
'scope',
'subject'
],
noteKeywords: ['BREAKING CHANGE'],
revertPattern: /^(?:Revert|revert:)\s"?([\s\S]+?)"?\s*This reverts commit (\w*)\./i,
revertCorrespondence: ['header', 'hash']
}
}

module.exports.createParserOpts = createParserOpts
Original file line number Diff line number Diff line change
Expand Up @@ -4,22 +4,24 @@ const compareFunc = require('compare-func')
const { readFile } = require('fs').promises
const { resolve } = require('path')

module.exports = Promise.all([
readFile(resolve(__dirname, './templates/template.hbs'), 'utf-8'),
readFile(resolve(__dirname, './templates/header.hbs'), 'utf-8'),
readFile(resolve(__dirname, './templates/commit.hbs'), 'utf-8'),
readFile(resolve(__dirname, './templates/footer.hbs'), 'utf-8')
])
.then(([template, header, commit, footer]) => {
const writerOpts = getWriterOpts()
async function createWriterOpts () {
const [template, header, commit, footer] = await Promise.all([
readFile(resolve(__dirname, './templates/template.hbs'), 'utf-8'),
readFile(resolve(__dirname, './templates/header.hbs'), 'utf-8'),
readFile(resolve(__dirname, './templates/commit.hbs'), 'utf-8'),
readFile(resolve(__dirname, './templates/footer.hbs'), 'utf-8')
])
const writerOpts = getWriterOpts()

writerOpts.mainTemplate = template
writerOpts.headerPartial = header
writerOpts.commitPartial = commit
writerOpts.footerPartial = footer
writerOpts.mainTemplate = template
writerOpts.headerPartial = header
writerOpts.commitPartial = commit
writerOpts.footerPartial = footer

return writerOpts
})
return writerOpts
}

module.exports.createWriterOpts = createWriterOpts

function getWriterOpts () {
return {
Expand Down
45 changes: 34 additions & 11 deletions packages/conventional-changelog-atom/README.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,41 @@
# [![NPM version][npm-image]][npm-url] [![Build Status][travis-image]][travis-url] [![Dependency Status][daviddm-image]][daviddm-url] [![Coverage Status][coverage-image]][coverage-url]
# conventional-changelog-atom

> [conventional-changelog](https://github.com/ajoslin/conventional-changelog) [atom](https://github.com/atom/atom) preset
[![NPM version][npm]][npm-url]
[![Node version][node]][node-url]
[![Dependencies status][deps]][deps-url]
[![Build status][build]][build-url]
[![Coverage status][coverage]][coverage-url]

[npm]: https://img.shields.io/npm/v/conventional-changelog-atom.svg
[npm-url]: https://npmjs.com/package/conventional-changelog-atom

[node]: https://img.shields.io/node/v/conventional-changelog-atom.svg
[node-url]: https://nodejs.org

[deps]: https://img.shields.io/librariesio/release/npm/conventional-changelog-atom
[deps-url]: https://libraries.io/npm/conventional-changelog-atom/tree

[build]: https://img.shields.io/github/actions/workflow/status/conventional-changelog/conventional-changelog/ci.yaml?branch=master
[build-url]: https://github.com/conventional-changelog/conventional-changelog/actions

[coverage]: https://coveralls.io/repos/github/conventional-changelog/conventional-changelog/badge.svg?branch=master
[coverage-url]: https://coveralls.io/github/conventional-changelog/conventional-changelog?branch=master

[conventional-changelog](https://github.com/conventional-changelog/conventional-changelog) [atom](https://github.com/atom/atom) preset.

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

## Install

```bash
# yarn
yarn add -D conventional-changelog-atom
# pnpm
pnpm add -D conventional-changelog-atom
# npm
npm i -D conventional-changelog-atom
```

## Atom Convention

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

Based on https://github.com/atom/atom/blob/master/CONTRIBUTING.md#git-commit-messages

[npm-image]: https://badge.fury.io/js/conventional-changelog-atom.svg
[npm-url]: https://npmjs.org/package/conventional-changelog-atom
[travis-image]: https://travis-ci.org/stevemao/conventional-changelog-atom.svg?branch=master
[travis-url]: https://travis-ci.org/stevemao/conventional-changelog-atom
[daviddm-image]: https://david-dm.org/stevemao/conventional-changelog-atom.svg?theme=shields.io
[daviddm-url]: https://david-dm.org/stevemao/conventional-changelog-atom
[coverage-image]: https://coveralls.io/repos/github/conventional-changelog/conventional-changelog/badge.svg?branch=master
[coverage-url]: https://coveralls.io/github/conventional-changelog/conventional-changelog?branch=master
10 changes: 0 additions & 10 deletions packages/conventional-changelog-atom/conventional-changelog.js

This file was deleted.

This file was deleted.