Skip to content

Commit

Permalink
feat: creating highly configurable preset, based on conventionalcommi…
Browse files Browse the repository at this point in the history
…ts.org (#421)
  • Loading branch information
bcoe committed Mar 25, 2019
1 parent 81e03b0 commit f2fb240
Show file tree
Hide file tree
Showing 21 changed files with 803 additions and 8 deletions.
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
@@ -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
@@ -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
@@ -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 }
})
}
@@ -0,0 +1,34 @@
'use strict'

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

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

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`
}
}
}
}
17 changes: 17 additions & 0 deletions packages/conventional-changelog-conventionalcommits/index.js
@@ -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
@@ -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"

This comment has been minimized.

Copy link
@mcrib96

mcrib96 Apr 17, 2019

The parent package.json only requires version >=6.9.0.
Requiring version 10.0.0 or higher causes builds with node version less than this to break.

},
"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
@@ -0,0 +1,15 @@
'use strict'

module.exports = function (config) {
return {
headerPattern: /^(\w*)(?:\((.*)\))?: (.*)$/,
headerCorrespondence: [
`type`,
`scope`,
`subject`
],
noteKeywords: [`BREAKING CHANGE`],
revertPattern: /^revert:\s([\s\S]*?)\s*This reverts commit (\w*)\./,
revertCorrespondence: [`header`, `hash`]
}
}
@@ -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}}

@@ -0,0 +1,11 @@
{{#if noteGroups}}
{{#each noteGroups}}

### {{title}}

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

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

{{#each commitGroups}}

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

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

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


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

0 comments on commit f2fb240

Please sign in to comment.