Skip to content

Commit

Permalink
chore(semantic-release): add custom sort function that sort notes sec…
Browse files Browse the repository at this point in the history
…tions
  • Loading branch information
pablo1v committed Mar 22, 2021
1 parent 7f64b13 commit c43aae7
Showing 1 changed file with 31 additions and 6 deletions.
37 changes: 31 additions & 6 deletions release.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,19 @@ const { join } = require('path');

const { ROOT_PATH } = require('./shared/constants');

const COMMIT_GROUP_ORDER = [
'Features',
'Bug Fixes',
'Performance Improvements',
'Code Refactoring',
'Miscellaneous Chores',
'Documentation Changes',
'Tests',
'Build System',
'Reverts',
'Dependency Updates',
];

module.exports = {
branches: [
'main',
Expand All @@ -22,18 +35,30 @@ module.exports = {
'@semantic-release/release-notes-generator',
{
preset: 'conventionalcommits',
writerOpts: {
commitGroupsSort: (a, b) => {
const rankA = COMMIT_GROUP_ORDER.indexOf(a.title);
const rankB = COMMIT_GROUP_ORDER.indexOf(b.title);

if (rankA >= rankB) return 1;
return -1;
},
},
presetConfig: {
types: [
{ type: 'feat', section: 'Features' },
{ type: 'feature', section: 'Features' },
{ type: 'fix', section: 'Bug Fixes' },
{ type: 'perf', section: 'Performance Improvements' },
{ type: 'refactor', section: 'Code Refactoring' },
{ type: 'chore', scope: 'release', hidden: true },
{ type: 'chore', section: 'Miscellaneous Chores' },
{ type: 'revert', section: 'Reverts' },
{ type: 'test', section: 'Tests' },
{ type: 'docs', section: 'Documentation Changes' },
{ type: 'build', section: 'Build System' },
{ type: 'revert', section: 'Reverts' },
{ type: 'fix', scope: 'deps', section: 'Dependency Updates' },
{ type: 'fix', section: 'Bug Fixes' },
{ type: 'feat', section: 'Features' },
{ type: 'feature', section: 'Features' },
{ type: 'chore', scope: 'release', hidden: true },
{ type: 'chore', scope: 'deps', section: 'Dependency Updates' },
{ type: 'chore', section: 'Miscellaneous Chores' },
],
},
},
Expand Down

0 comments on commit c43aae7

Please sign in to comment.