-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrelease-it.config.js
90 lines (81 loc) · 3.51 KB
/
release-it.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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
module.exports = {
git: {
requireCleanWorkingDir: true,
commit: true,
tag: true,
tagName: "${version}",
tagAnnotation: "Release ${version}",
push: true,
},
github: {
release: false,
tokenRef: "GITHUB_TOKEN",
},
npm: {
publish: false,
},
plugins: {
"@release-it/conventional-changelog": {
strictSemVer: true,
infile: "CHANGELOG.md",
header: "# DekTek Changelog\n\nAll notable changes are listed below.",
preset: {
name: "conventionalcommits",
types: [
{ type: "BREAKING CHANGE", section: "⚠️ Major Changes" },
{ type: "refactor", section: "⚠️ Major Changes" },
{ type: "fix", section: "🐛 Bug Fixes" },
{ type: "hotfix", section: "🐛 Bug Fixes" },
{ type: "feat", section: "✨ New Features" },
{ type: "docs", section: "🛠️ Miscellaneous" },
{ type: "style", section: "🛠️ Miscellaneous" },
{ type: "test", section: "🛠️ Miscellaneous" },
{ type: "chore", section: "🛠️ Miscellaneous" },
]
},
writerOpts: {
transform: (commit, context) => {
const newCommit = { ...commit };
const typeToSectionMap = {
"BREAKING CHANGE": "⚠️ Major Changes",
refactor: "⚠️ Major Changes",
hotfix: "🐛 Bug Fixes",
fix: "🐛 Bug Fixes",
feat: "✨ New Features",
chore: "🛠️ Miscellaneous",
docs: "🛠️ Miscellaneous",
style: "🛠️ Miscellaneous",
test: "🛠️ Miscellaneous",
};
newCommit.section = typeToSectionMap[commit.type] || "Other";
if (commit.pullRequest && commit.pullRequest.number) {
newCommit.pullRequestLink = `[PR #${commit.pullRequest.number}](${context.repository}/pull/${commit.pullRequest.number})`;
}
if (commit.hash) {
newCommit.commitLink = `[${commit.hash.substring(0, 7)}](${context.repository}/commit/${commit.hash})`;
}
newCommit.typeFormatted = commit.type
? commit.type.charAt(0).toUpperCase() + commit.type.slice(1)
: "Other";
return newCommit;
},
groupBy: "section",
finalizeContext: (ctx) => {
const commitGroups = (ctx.commitGroups || []).map((group) => {
const INCLUDED_SECTIONS = [
"⚠️ Major Changes",
"🐛 Bug Fixes",
"✨ New Features",
"🛠️ Miscellaneous",
];
const filteredCommits = group.commits.filter((commit) =>
INCLUDED_SECTIONS.includes(commit.section)
);
return { ...group, commits: filteredCommits };
});
return { ...ctx, commitGroups };
},
},
},
},
};