forked from RocketChat/Rocket.Chat
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[NEW] Update HISTORY.md and add changelog generator from RocketChat (R…
…ocketChat#515) * Update HISTORY.md and add changelog generator from RocketChat * Move changelog-cli to dev dependencies * Use const and other es6 features in changelog
- Loading branch information
1 parent
7fd942a
commit 286be60
Showing
8 changed files
with
558 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,95 @@ | ||
const { readFileSync: readFile } = require('fs'); | ||
const { resolve } = require('path'); | ||
const gitUrl = 'https://github.com/RocketChat/Rocket.Chat.Electron'; | ||
|
||
const parserOpts = { | ||
headerPattern: /^(\[([A-z]+)\] )?(.*)$/m, | ||
headerCorrespondence: [ | ||
'stype', | ||
'type', | ||
'subject' | ||
], | ||
mergePattern: /^Merge pull request #(.*) from .*$/, | ||
mergeCorrespondence: ['pr'] | ||
}; | ||
|
||
const LABELS = { | ||
BREAK: { | ||
title: 'BREAKING CHANGES', | ||
collapse: false | ||
}, | ||
NEW: { | ||
title: 'New Features', | ||
collapse: false | ||
}, | ||
FIX: { | ||
title: 'Bug Fixes', | ||
collapse: false | ||
}, | ||
DOC: { | ||
title: 'Documentation', | ||
collapse: true | ||
}, | ||
OTHER: { | ||
title: 'Others', | ||
collapse: true | ||
} | ||
}; | ||
|
||
const sort = Object.keys(LABELS); | ||
|
||
const writerOpts = { | ||
transform: (commit) => { | ||
if (!commit.pr) { | ||
return; | ||
} | ||
|
||
commit.type = (commit.type || 'OTHER').toUpperCase(); | ||
if (LABELS[commit.type] == null) { | ||
return; | ||
} | ||
|
||
commit.pr_url = gitUrl + '/pull/' + commit.pr; | ||
|
||
const issues = []; | ||
|
||
if (typeof commit.hash === 'string') { | ||
commit.hash = commit.hash.substring(0, 7); | ||
} | ||
|
||
if (typeof commit.subject === 'string') { | ||
// GitHub issue URLs. | ||
commit.subject = commit.subject.replace(/#([0-9]+)/g, (_, issue) => { | ||
issues.push(issue); | ||
return `[#${issue}](${gitUrl}/issues/${issue})`; | ||
}); | ||
// GitHub user URLs. | ||
commit.subject = commit.subject.replace(/@([a-zA-Z0-9_]+)/g, '[@$1](https://github.com/$1)'); | ||
} | ||
|
||
// remove references that already appear in the subject | ||
commit.references = commit.references.filter(({ issue }) => issues.includes(issue)); | ||
|
||
return commit; | ||
}, | ||
groupBy: 'type', | ||
commitGroupsSort: (a, b) => sort.indexOf(a.title) > sort.indexOf(b.title), | ||
finalizeContext: (context) => { | ||
context.commitGroups.forEach((g) => Object.assign(g, LABELS[g.title.toUpperCase()])); | ||
return context; | ||
}, | ||
commitsSort: ['subject'] | ||
}; | ||
|
||
writerOpts.mainTemplate = readFile(resolve(__dirname, 'templates/template.hbs'), 'utf-8'); | ||
writerOpts.headerPartial = readFile(resolve(__dirname, 'templates/header.hbs'), 'utf-8'); | ||
writerOpts.commitPartial = readFile(resolve(__dirname, 'templates/commit.hbs'), 'utf-8'); | ||
writerOpts.footerPartial = readFile(resolve(__dirname, 'templates/footer.hbs'), 'utf-8'); | ||
|
||
module.exports = { | ||
gitRawCommitsOpts: { | ||
merges: null | ||
}, | ||
parserOpts: parserOpts, | ||
writerOpts: writerOpts | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
{{!-- pr reference --}}- {{#if pr}}[#{{pr}}]({{pr_url}}){{/if}} | ||
|
||
{{~!-- subject --}} {{subject}} | ||
|
||
{{~!-- commit references --}} | ||
{{~#if references~}} | ||
, closes | ||
{{~#each references}} {{#if @root.linkReferences~}} | ||
[ | ||
{{~#if this.owner}} | ||
{{~this.owner}}/ | ||
{{~/if}} | ||
{{~this.repository}}#{{this.issue}}]( | ||
{{~#if @root.repository}} | ||
{{~#if @root.host}} | ||
{{~@root.host}}/ | ||
{{~/if}} | ||
{{~#if this.repository}} | ||
{{~#if this.owner}} | ||
{{~this.owner}}/ | ||
{{~/if}} | ||
{{~this.repository}} | ||
{{~else}} | ||
{{~#if @root.owner}} | ||
{{~@root.owner}}/ | ||
{{~/if}} | ||
{{~@root.repository}} | ||
{{~/if}} | ||
{{~else}} | ||
{{~@root.repoUrl}} | ||
{{~/if}}/ | ||
{{~@root.issue}}/{{this.issue}}) | ||
{{~else}} | ||
{{~#if this.owner}} | ||
{{~this.owner}}/ | ||
{{~/if}} | ||
{{~this.repository}}#{{this.issue}} | ||
{{~/if}}{{/each}} | ||
{{~/if}} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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}} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
<a name="{{version}}"></a> | ||
{{#if isPatch~}} | ||
## | ||
{{~else~}} | ||
# | ||
{{~/if}} {{#if @root.linkCompare~}} | ||
[{{version}}]( | ||
{{~#if @root.repository~}} | ||
{{~#if @root.host}} | ||
{{~@root.host}}/ | ||
{{~/if}} | ||
{{~#if @root.owner}} | ||
{{~@root.owner}}/ | ||
{{~/if}} | ||
{{~@root.repository}} | ||
{{~else}} | ||
{{~@root.repoUrl}} | ||
{{~/if~}} | ||
/compare/{{previousTag}}...{{currentTag}}) | ||
{{~else}} | ||
{{~version}} | ||
{{~/if}} | ||
{{~#if title}} "{{title}}" | ||
{{~/if}} | ||
{{~#if date}} ({{date}}) | ||
{{/if}} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
{{> header}} | ||
|
||
{{#each commitGroups}} | ||
|
||
{{#if collapse}} | ||
<details> | ||
<summary>{{title}}</summary> | ||
{{else}} | ||
### {{title}} | ||
{{/if}} | ||
|
||
{{#each commits}} | ||
{{> commit root=@root}} | ||
{{/each}} | ||
{{#if collapse}} | ||
</details> | ||
{{/if}} | ||
|
||
{{/each}} | ||
{{> footer}} | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.