Skip to content

Commit

Permalink
[NEW] Update HISTORY.md and add changelog generator from RocketChat (R…
Browse files Browse the repository at this point in the history
…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
alexbrazier authored Aug 21, 2017
1 parent 7fd942a commit 286be60
Show file tree
Hide file tree
Showing 8 changed files with 558 additions and 15 deletions.
95 changes: 95 additions & 0 deletions .github/changelog.js
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
};
40 changes: 40 additions & 0 deletions .github/templates/commit.hbs
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}}

11 changes: 11 additions & 0 deletions .github/templates/footer.hbs
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}}
26 changes: 26 additions & 0 deletions .github/templates/header.hbs
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}}
22 changes: 22 additions & 0 deletions .github/templates/template.hbs
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}}


73 changes: 70 additions & 3 deletions HISTORY.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,71 @@
# History
<a name="2.8.0"></a>
# 2.8.0 (2017-05-17)


### New Features

- [#416](https://github.com/RocketChat/Rocket.Chat.Electron/pull/416) Snap build


# Bug Fixes

- [#440](https://github.com/RocketChat/Rocket.Chat.Electron/pull/440) Fix bug on some OS versions on about window, closes [#427](https://github.com/RocketChat/Rocket.Chat.Electron/issues/427)
- [#445](https://github.com/RocketChat/Rocket.Chat.Electron/pull/445) Fix bug when closing app in fullscreen




<a name="2.7.0"></a>
# 2.7.0 (2017-04-26)


### New Features

- [#411](https://github.com/RocketChat/Rocket.Chat.Electron/pull/411) Auto update when new version is released
- [#423](https://github.com/RocketChat/Rocket.Chat.Electron/pull/423) Open host from add new server page if it exists


### Bug Fixes

- [#417](https://github.com/RocketChat/Rocket.Chat.Electron/pull/417) Don't open dev tools on about, and show message when no updates
- [#425](https://github.com/RocketChat/Rocket.Chat.Electron/pull/425) Make sure app quits on mac on update
- [#426](https://github.com/RocketChat/Rocket.Chat.Electron/pull/426) Reduce drag region to fix manual scroll


<details>
<summary>Others</summary>

- [#415](https://github.com/RocketChat/Rocket.Chat.Electron/pull/415) Updated README with servers.json instructions
</details>



<a name="2.6.1"></a>
## 2.6.1 (2017-04-04)


### Bug Fixes

- [#412](https://github.com/RocketChat/Rocket.Chat.Electron/pull/412) Fix bug with highlighting text & drag region on macOS



<a name="2.6.0"></a>
# 2.6.0 (2017-03-29)


### Bug Fixes

- [#384](https://github.com/RocketChat/Rocket.Chat.Electron/pull/384) Fix download file issue
- [#390](https://github.com/RocketChat/Rocket.Chat.Electron/pull/390) Fix speed issues with spellcheck on windows
- [#391](https://github.com/RocketChat/Rocket.Chat.Electron/pull/391) Only show reload screen if main webview error


<details>
<summary>Others</summary>

- [#336](https://github.com/RocketChat/Rocket.Chat.Electron/pull/336) Make it sexier in macOS
</details>

## 2.5.0 - 2017-Mar-05

Expand Down Expand Up @@ -136,7 +203,7 @@
- Start client with windows logon (#57)
- Tray icon on Windows requires triple click (#77)

> Special thanks to @floriangoeldi
> Special thanks to @floriangoeldi
## 1.0.0 - 2016-Feb-19

Expand Down Expand Up @@ -202,7 +269,7 @@
- Listen for double-clicked event on tray to minimize/restore window
- Move window to front when click to show in tray
- Open http links as external
- Remove unnecessary files from OSX and Windows release
- Remove unnecessary files from OSX and Windows release
- Rename application executable and helpers
- Update Icons

Expand Down
2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@
"build": "gulp build",
"prerelease": "gulp build --env=production",
"release": "build",
"changelog": "conventional-changelog --config .github/changelog.js -i HISTORY.md -s",
"start": "gulp start",
"pretest": "gulp build-unit --env=test",
"test": "electron-mocha app/specs.js.autogenerated --renderer --require source-map-support/register",
Expand All @@ -85,6 +86,7 @@
},
"devDependencies": {
"chai": "^4.1.1",
"conventional-changelog-cli": "^1.3.2",
"electron": "^1.6.11",
"electron-builder": "^19.19.1",
"electron-mocha": "^4.0.0",
Expand Down
Loading

0 comments on commit 286be60

Please sign in to comment.