-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathchangelog-preset.config.js
75 lines (64 loc) · 1.86 KB
/
changelog-preset.config.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
/* eslint-disable @typescript-eslint/no-var-requires */
/* eslint-disable import/no-extraneous-dependencies */
const config = require('conventional-changelog-conventionalcommits');
const { releaseRules } = require('./.releaseRules');
console.log("here!!!!");
const releaseRulesMap = releaseRules.reduce((map, rule) => {
return {
...map,
[rule.tag]: rule.release
}
}, {});
const levels = {
major: 0,
minor: 1,
patch: 2,
};
/**
* This determines what the next version will be bumped to.
*
* It replaces the default `whatBump` function that conventionalcommits
* uses here: https://github.com/conventional-changelog/conventional-changelog/blob/master/packages/conventional-recommended-bump/index.js#L90
*
* Instead, we use our release rules to determine the version bump.
*/
function whatBumpFactory(originalWhatBump) {
return function vitalWhatBump(commits) {
let level = 2;
originalWhatBump(commits);
commits.forEach((commit) => {
const releaseType = releaseRulesMap[commit.type] || 'patch';
const releaseLevel = levels[releaseType];
if (releaseType && releaseLevel < level) {
level = releaseLevel;
}
});
return {
level,
reason: '',
};
};
}
module.exports = config({
types: [
{ type: 'breaking', section: 'Breaking' },
{ type: 'update', section: 'Updates' },
{ type: 'fix', section: 'Fixes' },
{ type: 'chore', hidden: true },
{ type: 'docs', hidden: true },
{ type: 'style', hidden: true },
{ type: 'refactor', hidden: true },
{ type: 'perf', hidden: true },
{ type: 'test', hidden: true },
],
}).then((preset) => {
const whatBump = whatBumpFactory(preset.recommendedBumpOpts.whatBump);
const finalPreset = {
...preset,
recommendedBumpOpts: {
...preset.recommendedBumpOpts,
whatBump,
},
};
return finalPreset;
});