-
Notifications
You must be signed in to change notification settings - Fork 2.7k
/
.grenrc.js
67 lines (60 loc) · 2.2 KB
/
.grenrc.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
module.exports = {
template: {
commit: ({message, url, author, name}) =>
`- [${message}](${url}) - ${author ? `@${author}` : name}`,
issue: ({name, labels, text, url, user_login, user_url}) => `${processLabels(labels)}${name} [${text}](${url}) by [${user_login}](${user_url})`,
label: '[**{{label}}**]',
noLabel: 'closed',
group: '\n## {{heading}}\n',
changelogTitle: '# Changelog\n\n',
release: '## {{release}} ({{date}})\n{{body}}',
releaseSeparator: '\n---\n\n',
},
groupBy: {
'Enhancements:': ['type: accepted/enhancement', 'internal'],
'Fixed:': ['type: accepted/bug'],
Features: ['feature'],
},
groupPostProcessor: (groupContent) => {
const lines = groupContent.split('\n');
const iosIssues = [];
const androidIssues = [];
const otherIssues = [];
for (let i = 0; i < lines.length; i++) {
const line = lines[i];
if (line.includes('## ') || line === '') continue;
else if (line.includes('[iOS] ')) iosIssues.push(line.replace('[iOS] ', ''));
else if (line.includes('[Android] ')) androidIssues.push(line.replace('[Android] ', ''));
else otherIssues.push(line);
}
const groupHeader = groupContent.substr(0, groupContent.indexOf(':\n'));
return `${groupHeader}${generateSection(undefined, otherIssues)}${generateSection('iOS', iosIssues)}${generateSection('Android', androidIssues)}`;
},
ignoreIssuesWith: ['skip-changelog'],
ignoreTagsWith: ['snapshot', 'v1', 'v2', '0\..\..', '1\..\..', '2\..\..', '3\..\..', '4\..\..', '5\..\..', '6\..\..'],
dataSource: 'prs',
changelogFilename: 'CHANGELOG.gren.md',
override: true,
generate: true,
tags: 'all'
};
function generateSection(name, issues) {
if (!issues.length) return '';
let section = `\n${name ? `### ${name}\n` : ''}`;
issues.forEach(issue => {
section += `- ${issue}\n`;
});
return `${section}\n`;
}
function processLabels(labels) {
const includesIOS = labels.includes('**platform: iOS**');
const includesAndroid = labels.includes('**platform: Android**');
if (includesIOS && includesAndroid) {
return '';
} else if (includesIOS) {
return '[iOS] '
} else if (includesAndroid) {
return '[Android] '
}
return '';
}