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: creating specifically for conventionalcommits.org #421

Merged
merged 3 commits into from
Mar 25, 2019
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

15 changes: 15 additions & 0 deletions packages/conventional-changelog-conventionalcommits/LICENSE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
### ISC License

Copyright © [conventional-changelog team](https://github.com/conventional-changelog)

Permission to use, copy, modify, and/or distribute this software for any
purpose with or without fee is hereby granted, provided that the above
copyright notice and this permission notice appear in all copies.

THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
PERFORMANCE OF THIS SOFTWARE.
12 changes: 12 additions & 0 deletions packages/conventional-changelog-conventionalcommits/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# [![Build Status][travis-image]][travis-url] [![Coverage Status][coveralls-image]][coveralls-url]

## conventionalcommits.org convention

A concrete implementation of the specification described at
[conventionalcommits.org](https://conventionalcommits.org/) for automated
CHANGELOG generation and version management.

[travis-image]: https://travis-ci.org/conventional-changelog/conventional-changelog.svg?branch=master
[travis-url]: https://travis-ci.org/conventional-changelog/conventional-changelog
[coveralls-image]: https://coveralls.io/repos/conventional-changelog/conventional-changelog/badge.svg
[coveralls-url]: https://coveralls.io/r/conventional-changelog/conventional-changelog
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
'use strict'

const Q = require(`q`)
const parserOpts = require(`./parser-opts`)
const writerOpts = require(`./writer-opts`)

module.exports = function (config) {
return Q.all([parserOpts, writerOpts])
.spread((parserOpts, writerOpts) => {
return { parserOpts, writerOpts }
})
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
'use strict'

const parserOpts = require(`./parser-opts`)

module.exports = function (config) {
return {
parserOpts: parserOpts(config),

whatBump: (commits) => {
let level = 2
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is our stance on releasing on every change? (I maintain my own personal changelog preset solely for the purpose of only recommending a release on fixes, features, and breaking changes.)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would like to continue releasing changes for every commit type; this is how the angular preset approaches things, and is what I myself (and I expect other users of standard-version) have come to expect.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I suppose we could open this up to being configured? it feels really weird to me though as a library maintainer. If I've performed a maintenance task, such as upgrading libraries, or performance refactoring, etc., I still often want to release a patch release of my module -- I have never personally found myself in a position where the default behavior of bumping the PATCH wasn't the behavior I wanted.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I suppose we could open this up to being configured?

As a first pass, let's please not let my comment hold up your PR. 😅

Long-term, yes, I would really like to make releases configurable. My own preset was actually a pre-cursor to the one I wrote for my company because the number of releases for tasks, such as chores related to project configuration, refactors related to reducing technical debt, and docs related to inline comments, were becoming disruptive to our library consumers 😞 (new releases caused our dependency update tool to roll that out to hundreds of applications in near real-time, which caused lots of notifications, CI job queues to grow, etc.).

If I've performed a maintenance task, such as upgrading libraries, or performance refactoring

Those sound like tasks that effect downstream consumers. Those, in my opinion, should be released. 👍

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I understand this use-case better now; let's take the conversation to another issue?

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`
}
}
}
}
17 changes: 17 additions & 0 deletions packages/conventional-changelog-conventionalcommits/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
'use strict'
const Q = require(`q`)
const conventionalChangelog = require(`./conventional-changelog`)
const parserOpts = require(`./parser-opts`)
const recommendedBumpOpts = require(`./conventional-recommended-bump`)
const writerOpts = require(`./writer-opts`)

module.exports = function (config) {
return Q.all([
conventionalChangelog(config),
parserOpts(config),
recommendedBumpOpts(config),
writerOpts(config)
]).spread((conventionalChangelog, parserOpts, recommendedBumpOpts, writerOpts) => {
return { conventionalChangelog, parserOpts, recommendedBumpOpts, writerOpts }
})
}
39 changes: 39 additions & 0 deletions packages/conventional-changelog-conventionalcommits/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
{
"name": "conventional-changelog-conventionalcommits",
"version": "1.0.0",
"description": "conventional-changelog conventionalcommits.org preset",
"main": "index.js",
"scripts": {
"test-windows": "mocha --timeout 30000"
},
"repository": {
"type": "git",
"url": "https://github.com/conventional-changelog/conventional-changelog.git"
},
"keywords": [
"conventional-changelog",
"conventionalcommits.org",
"preset"
],
"files": [
"conventional-changelog.js",
"conventional-recommended-bump.js",
"index.js",
"parser-opts.js",
"writer-opts.js",
"templates"
],
"author": "Ben Coe",
"engines": {
"node": ">=10.0.0"
},
"license": "ISC",
"bugs": {
"url": "https://github.com/conventional-changelog/conventional-changelog/issues"
},
"homepage": "https://github.com/conventional-changelog/conventional-changelog/tree/master/packages/conventional-changelog-angular#readme",
"dependencies": {
"compare-func": "^1.3.1",
"q": "^1.5.1"
}
}
15 changes: 15 additions & 0 deletions packages/conventional-changelog-conventionalcommits/parser-opts.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
'use strict'

module.exports = function (config) {
return {
headerPattern: /^(\w*)(?:\((.*)\))?: (.*)$/,
headerCorrespondence: [
`type`,
`scope`,
`subject`
],
noteKeywords: [`BREAKING CHANGE`],
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this also be configurable?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe eventually? I think I'd like to implement a first pass that addresses the most common feature requests that I've seen:

  • the ability to more directly control the URLs to commits, ranges, and issues in the CHANGELOG generated.
  • the ability to configure which types of commits show up in the CHANGELOG.

I expect we'll want to make more options configurable as we start to work our way through existing feature requests in the backlog of issues.

revertPattern: /^revert:\s([\s\S]*?)\s*This reverts commit (\w*)\./,
revertCorrespondence: [`header`, `hash`]
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
*{{#if scope}} **{{scope}}:**
{{~/if}} {{#if subject}}
{{~subject}}
{{~else}}
{{~header}}
{{~/if}}

{{~!-- commit link --}} {{#if @root.linkReferences~}}
([{{hash}}]({{commitUrlFormat}}))
{{~else}}
{{~hash}}
{{~/if}}

{{~!-- commit references --}}
{{~#if references~}}
, closes
{{~#each references}} {{#if @root.linkReferences~}}
[
{{~#if this.owner}}
{{~this.owner}}/
{{~/if}}
{{~this.repository}}#{{this.issue}}]({{issueUrlFormat}})
{{~else}}
{{~#if this.owner}}
{{~this.owner}}/
{{~/if}}
{{~this.repository}}#{{this.issue}}
{{~/if}}{{/each}}
{{~/if}}

Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{{#if noteGroups}}
{{#each noteGroups}}

### {{title}}

{{#each notes}}
* {{#if commit.scope}}**{{commit.scope}}:** {{/if}}{{text}}
{{/each}}
{{/each}}

{{/if}}
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{{#if isPatch~}}
##
{{~else~}}
#
{{~/if}} {{#if @root.linkCompare~}}
[{{version}}]({{compareUrlFormat}})
{{~else}}
{{~version}}
{{~/if}}
{{~#if title}} "{{title}}"
{{~/if}}
{{~#if date}} ({{date}})
{{/if}}
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{{> header}}

{{#each commitGroups}}

{{#if title}}
### {{title}}

{{/if}}
{{#each commits}}
{{> commit root=@root}}
{{/each}}

{{/each}}
{{> footer}}


Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"repository": "ghe",
"version": "v3.0.0",
"repository": "https://github.internal.example.com/conventional-changelog/internal"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"repository": "known",
"version": "v2.0.0",
"repository": "https://github.com/conventional-changelog/example"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"repository": "unknown",
"version": "v2.0.0"
}
Loading