chore: updated auto-changelog template

This commit is contained in:
Mo Gorhom
2020-12-16 00:23:39 +01:00
parent 113da47b72
commit d78f2202de
3 changed files with 78 additions and 15 deletions

View File

@@ -3,11 +3,11 @@
"push": true,
"tagName": "v${version}",
"commitMessage": "chore: release v${version}",
"changelog": "auto-changelog --stdout --commit-limit false --ignore-commit-pattern \"^chore: release v\" --unreleased --template ./release-template.hbs --tag-pattern \"^v\\d+\\.\\d+\\.\\d+$\""
"changelog": "auto-changelog --stdout --commit-limit false --ignore-commit-pattern \"^chore: release v\" --unreleased --template ./release-template.hbs --tag-pattern \"^v\\d+\\.\\d+\\.\\d+$\" --handlebars-setup ./scripts/auto-changelog.js"
},
"github": {
"release": true,
"releaseNotes": "auto-changelog --stdout --commit-limit false --ignore-commit-pattern \"^chore: release v\" --unreleased --template ./release-template.hbs --tag-pattern \"^v\\d+\\.\\d+\\.\\d+$\""
"releaseNotes": "auto-changelog --stdout --commit-limit false --ignore-commit-pattern \"^chore: release v\" --unreleased --template ./release-template.hbs --tag-pattern \"^v\\d+\\.\\d+\\.\\d+$\" --handlebars-setup ./scripts/auto-changelog.js"
},
"npm": {
"publish": false
@@ -18,6 +18,6 @@
}
},
"hooks": {
"after:bump": "auto-changelog -p --ignore-commit-pattern \"^chore: release v\" --template \"keepachangelog\" --tag-pattern \"^v\\d+\\.\\d+\\.\\d+$\""
"after:bump": "auto-changelog -p --ignore-commit-pattern \"^chore: release v\" --template ./release-template.hbs --tag-pattern \"^v\\d+\\.\\d+\\.\\d+$\" --handlebars-setup ./scripts/auto-changelog.js"
}
}
}

View File

@@ -1,13 +1,39 @@
# Changelog
All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
{{#unless options.hideCredit}}
Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).
{{/unless}}
{{#each releases}}
{{#if @first}}
{{#each merges}}
- {{{message}}}{{#if href}} [`#{{id}}`]({{href}}){{/if}}
{{/each}}
{{#each fixes}}
- {{{commit.subject}}}{{#each fixes}}{{#if href}} [`#{{id}}`]({{href}}){{/if}}{{/each}}
{{/each}}
{{#each commits}}
- {{#if breaking}}**Breaking change:** {{/if}}{{{subject}}}{{#if href}} [`{{shorthash}}`]({{href}}){{/if}}
{{/each}}
{{/if}}
{{#if href}}
## [{{title}}]({{href}}){{#if tag}} - {{isoDate}}{{/if}}
{{else}}
## {{title}}{{#if tag}} - {{isoDate}}{{/if}}
{{/if}}
{{#if summary}}
{{summary}}
{{/if}}
{{#custom merges commits heading="#### Features" subject="feat: "}}
- {{message}} ({{#if id}}[`#{{id}}`]{{else}}[{{shorthash}}]{{/if}}({{href}})).
{{/custom}}
{{#custom merges commits heading="#### Improvements" subject="(chore|refactor|style): "}}
- {{message}} ({{#if id}}[`#{{id}}`]{{else}}[{{shorthash}}]{{/if}}({{href}})).
{{/custom}}
{{#custom merges commits heading="#### Fixes" subject="fix: "}}
- {{message}} ({{#if id}}[`#{{id}}`]{{else}}[{{shorthash}}]{{/if}}({{href}})).
{{/custom}}
{{#custom merges commits heading="#### Documentations" subject="docs: "}}
- {{message}} ({{#if id}}[`#{{id}}`]{{else}}[{{shorthash}}]{{/if}}({{href}})).
{{/custom}}
{{/each}}

37
scripts/auto-changelog.js Normal file
View File

@@ -0,0 +1,37 @@
module.exports = function (Handlebars) {
Handlebars.registerHelper('custom', function (context, extra, options) {
if ((!context || context.length === 0) && (!extra || extra.length === 0)) {
return '';
}
const list = [...context, ...extra]
.filter(item => {
const commit = item.commit || item;
if (options.hash.exclude) {
const pattern = new RegExp(options.hash.exclude, 'm');
if (pattern.test(commit.message)) {
return false;
}
}
if (options.hash.message) {
const pattern = new RegExp(options.hash.message, 'm');
return pattern.test(commit.message);
}
if (options.hash.subject) {
const pattern = new RegExp(options.hash.subject);
return pattern.test(commit.subject);
}
return true;
})
.map(item => options.fn(item))
.join('');
if (!list) {
return '';
}
return options.hash.heading
? `${options.hash.heading}\n\n${list}`
: `${list}`;
});
};