@taiga-ui/auto-changelog-config 0.493.0 → 0.494.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/release-template.hbs +3 -3
- package/setup.js +127 -22
- package/template.hbs +3 -3
package/package.json
CHANGED
package/release-template.hbs
CHANGED
|
@@ -7,15 +7,15 @@
|
|
|
7
7
|
{{#commit-parser merges commits}}
|
|
8
8
|
|
|
9
9
|
{{#commit-list this heading='### ⚠️ BREAKING CHANGES' message='^(feat|fix|perf)(\([^)]*\))!:' }}
|
|
10
|
-
- {{#replaceCommit}}{{subject}}{{/replaceCommit}}{{#if pullRequest}}{{#if pullRequest.href}} ([#{{pullRequest.id}}]({{pullRequest.href}})){{else}} (#{{pullRequest.id}}){{/if}}{{/if}}{{#if
|
|
10
|
+
- {{#replaceCommit}}{{subject}}{{/replaceCommit}}{{#if pullRequest}}{{#if pullRequest.href}} ([#{{pullRequest.id}}]({{pullRequest.href}})){{else}} (#{{pullRequest.id}}){{/if}}{{/if}}{{#if commitHash}}{{#if commitHref}} [({{commitHash}})]({{commitHref}}){{else}} ({{commitHash}}){{/if}}{{/if}}
|
|
11
11
|
{{/commit-list}}
|
|
12
12
|
|
|
13
13
|
{{#commit-list this heading='### 🚀 Features' message='^feat:|^feat\(' exclude='^(feat|fix|perf)(\([^)]*\))!:'}}
|
|
14
|
-
- {{#replaceCommit}}{{subject}}{{/replaceCommit}}{{#if pullRequest}}{{#if pullRequest.href}} ([#{{pullRequest.id}}]({{pullRequest.href}})){{else}} (#{{pullRequest.id}}){{/if}}{{/if}}{{#if
|
|
14
|
+
- {{#replaceCommit}}{{subject}}{{/replaceCommit}}{{#if pullRequest}}{{#if pullRequest.href}} ([#{{pullRequest.id}}]({{pullRequest.href}})){{else}} (#{{pullRequest.id}}){{/if}}{{/if}}{{#if commitHash}}{{#if commitHref}} [({{commitHash}})]({{commitHref}}){{else}} ({{commitHash}}){{/if}}{{/if}}
|
|
15
15
|
{{/commit-list}}
|
|
16
16
|
|
|
17
17
|
{{#commit-list this heading='### 🐞 Bug Fixes' message='^fix:|^fix\(' exclude='^(feat|fix|perf)(\([^)]*\))!:'}}
|
|
18
|
-
- {{#replaceCommit}}{{subject}}{{/replaceCommit}}{{#if pullRequest}}{{#if pullRequest.href}} ([#{{pullRequest.id}}]({{pullRequest.href}})){{else}} (#{{pullRequest.id}}){{/if}}{{/if}}{{#if
|
|
18
|
+
- {{#replaceCommit}}{{subject}}{{/replaceCommit}}{{#if pullRequest}}{{#if pullRequest.href}} ([#{{pullRequest.id}}]({{pullRequest.href}})){{else}} (#{{pullRequest.id}}){{/if}}{{/if}}{{#if commitHash}}{{#if commitHref}} [({{commitHash}})]({{commitHref}}){{else}} ({{commitHash}}){{/if}}{{/if}}
|
|
19
19
|
{{/commit-list}}
|
|
20
20
|
|
|
21
21
|
{{/commit-parser}}
|
package/setup.js
CHANGED
|
@@ -12,14 +12,72 @@ module.exports = function (Handlebars) {
|
|
|
12
12
|
return id;
|
|
13
13
|
};
|
|
14
14
|
|
|
15
|
-
const
|
|
15
|
+
const getPullRequestIdFromText = (text) => {
|
|
16
|
+
const [, id = ''] = String(text ?? '').match(/\s\(#(\d+)\)\s*$/) ?? [];
|
|
17
|
+
|
|
18
|
+
return id;
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
const isPullRequestHref = (href) =>
|
|
22
|
+
/\/(?:pull|merge_requests|pull-requests)\/\d+(?:$|[/?#])/.test(
|
|
23
|
+
String(href ?? ''),
|
|
24
|
+
);
|
|
25
|
+
|
|
26
|
+
const getCommitHashFromHref = (href) => {
|
|
27
|
+
const [, hash = ''] =
|
|
28
|
+
String(href ?? '').match(/\/commit\/([a-f\d]{7,40})(?:$|[/?#])/) ?? [];
|
|
29
|
+
|
|
30
|
+
return hash;
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
const getRepositoryHref = (href) => {
|
|
34
|
+
const [, repositoryHref = ''] =
|
|
35
|
+
String(href ?? '').match(/^(https?:\/\/[^/]+\/[^/]+\/[^/]+)(?:\/|$)/) ?? [];
|
|
36
|
+
|
|
37
|
+
return repositoryHref;
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
const getCommitHref = (commit, pullRequest) => {
|
|
41
|
+
const href = firstNonEmptyString(commit.commitHref, commit.href);
|
|
42
|
+
|
|
43
|
+
if (href.includes('/commit/')) {
|
|
44
|
+
return href;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
const hash = firstNonEmptyString(
|
|
48
|
+
commit.hash,
|
|
49
|
+
commit.shorthash,
|
|
50
|
+
getCommitHashFromHref(href),
|
|
51
|
+
);
|
|
52
|
+
|
|
53
|
+
const repositoryHref = getRepositoryHref(
|
|
54
|
+
firstNonEmptyString(pullRequest?.href, href),
|
|
55
|
+
);
|
|
56
|
+
|
|
57
|
+
return hash && repositoryHref ? `${repositoryHref}/commit/${hash}` : '';
|
|
58
|
+
};
|
|
59
|
+
|
|
60
|
+
const getCommitHash = (commit, commitHref) =>
|
|
61
|
+
firstNonEmptyString(
|
|
62
|
+
commit.commitHash,
|
|
63
|
+
commit.shorthash,
|
|
64
|
+
getCommitHashFromHref(commitHref),
|
|
65
|
+
String(commit.hash ?? '').slice(0, 7),
|
|
66
|
+
).slice(0, 7);
|
|
67
|
+
|
|
68
|
+
const normalizePullRequest = (commit, subject) => {
|
|
16
69
|
const pullRequest = commit.pullRequest ?? {};
|
|
17
|
-
const href =
|
|
70
|
+
const href = [pullRequest.href, commit.pullRequestHref, commit.href]
|
|
71
|
+
.map(firstNonEmptyString)
|
|
72
|
+
.find(isPullRequestHref);
|
|
18
73
|
|
|
19
74
|
const id = firstNonEmptyString(
|
|
20
75
|
pullRequest.id,
|
|
21
76
|
pullRequest.number,
|
|
22
77
|
getPullRequestId(href),
|
|
78
|
+
getPullRequestIdFromText(subject),
|
|
79
|
+
getPullRequestIdFromText(commit.message),
|
|
80
|
+
getPullRequestIdFromText(commit.title),
|
|
23
81
|
);
|
|
24
82
|
|
|
25
83
|
if (!id) {
|
|
@@ -30,28 +88,75 @@ module.exports = function (Handlebars) {
|
|
|
30
88
|
...pullRequest,
|
|
31
89
|
id,
|
|
32
90
|
author: pullRequest.author ?? commit.author,
|
|
33
|
-
href,
|
|
91
|
+
href: href ?? '',
|
|
34
92
|
};
|
|
35
93
|
};
|
|
36
94
|
|
|
37
95
|
const normalizeCommit = (commit) => {
|
|
38
96
|
const subject = firstNonEmptyString(
|
|
39
97
|
commit.subject,
|
|
40
|
-
commit.message,
|
|
41
|
-
commit.title,
|
|
42
98
|
commit.pullRequest?.title,
|
|
99
|
+
commit.title,
|
|
100
|
+
commit.message,
|
|
43
101
|
);
|
|
44
102
|
|
|
45
|
-
const pullRequest = normalizePullRequest(commit);
|
|
103
|
+
const pullRequest = normalizePullRequest(commit, subject);
|
|
104
|
+
const commitHref = getCommitHref(commit, pullRequest);
|
|
105
|
+
const commitHash = getCommitHash(commit, commitHref);
|
|
46
106
|
|
|
47
107
|
return {
|
|
48
108
|
...commit,
|
|
109
|
+
commitHash,
|
|
110
|
+
commitHref,
|
|
49
111
|
message: firstNonEmptyString(commit.message, subject),
|
|
50
112
|
pullRequest,
|
|
51
113
|
subject,
|
|
52
114
|
};
|
|
53
115
|
};
|
|
54
116
|
|
|
117
|
+
const getCommitKey = (commit) =>
|
|
118
|
+
firstNonEmptyString(
|
|
119
|
+
commit.pullRequest?.id && `pr:${commit.pullRequest.id}`,
|
|
120
|
+
commit.hash && `hash:${commit.hash}`,
|
|
121
|
+
commit.commitHash && `hash:${commit.commitHash}`,
|
|
122
|
+
commit.subject && `subject:${commit.subject}`,
|
|
123
|
+
);
|
|
124
|
+
|
|
125
|
+
const mergePullRequests = (left, right) => {
|
|
126
|
+
if (!left && !right) {
|
|
127
|
+
return;
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
if (!left) {
|
|
131
|
+
return right;
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
if (!right) {
|
|
135
|
+
return left;
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
return {
|
|
139
|
+
...left,
|
|
140
|
+
...right,
|
|
141
|
+
id: firstNonEmptyString(left.id, right.id),
|
|
142
|
+
author: left.author ?? right.author,
|
|
143
|
+
href: firstNonEmptyString(left.href, right.href),
|
|
144
|
+
};
|
|
145
|
+
};
|
|
146
|
+
|
|
147
|
+
const mergeCommits = (left, right) => ({
|
|
148
|
+
...left,
|
|
149
|
+
...right,
|
|
150
|
+
commitHash: firstNonEmptyString(left.commitHash, right.commitHash),
|
|
151
|
+
commitHref: firstNonEmptyString(left.commitHref, right.commitHref),
|
|
152
|
+
hash: firstNonEmptyString(left.hash, right.hash),
|
|
153
|
+
href: firstNonEmptyString(left.href, right.href),
|
|
154
|
+
message: firstNonEmptyString(left.message, right.message),
|
|
155
|
+
pullRequest: mergePullRequests(left.pullRequest, right.pullRequest),
|
|
156
|
+
shorthash: firstNonEmptyString(left.shorthash, right.shorthash),
|
|
157
|
+
subject: firstNonEmptyString(left.subject, right.subject),
|
|
158
|
+
});
|
|
159
|
+
|
|
55
160
|
const getCommitAuthor = (commit) =>
|
|
56
161
|
commit.pullRequest?.author?.login ??
|
|
57
162
|
commit.pullRequest?.user?.login ??
|
|
@@ -102,22 +207,21 @@ module.exports = function (Handlebars) {
|
|
|
102
207
|
|
|
103
208
|
const commits = args.flat().filter(Boolean).map(normalizeCommit);
|
|
104
209
|
|
|
105
|
-
const unique =
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
];
|
|
210
|
+
const unique = commits.reduce((map, commit) => {
|
|
211
|
+
const key = getCommitKey(commit);
|
|
212
|
+
|
|
213
|
+
if (!key) {
|
|
214
|
+
return map;
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
const previous = map.get(key);
|
|
218
|
+
|
|
219
|
+
map.set(key, previous ? mergeCommits(previous, commit) : commit);
|
|
220
|
+
|
|
221
|
+
return map;
|
|
222
|
+
}, new Map());
|
|
119
223
|
|
|
120
|
-
return options.fn(unique);
|
|
224
|
+
return options.fn([...unique.values()]);
|
|
121
225
|
});
|
|
122
226
|
|
|
123
227
|
Handlebars.registerHelper('replaceCommit', function (context) {
|
|
@@ -126,7 +230,8 @@ module.exports = function (Handlebars) {
|
|
|
126
230
|
|
|
127
231
|
const string = String(context.fn(this)).trim();
|
|
128
232
|
const {scope = '', title = ''} = commit.exec(string)?.groups ?? {};
|
|
129
|
-
const
|
|
233
|
+
const cleanTitle = title.replace(/\s\(#\d+\)\s*$/, '');
|
|
234
|
+
const result = scope ? `**${scope.toLowerCase()}**: ${cleanTitle}` : cleanTitle;
|
|
130
235
|
|
|
131
236
|
return result || string || 'empty commit name';
|
|
132
237
|
});
|
package/template.hbs
CHANGED
|
@@ -7,15 +7,15 @@
|
|
|
7
7
|
{{#commit-parser merges commits}}
|
|
8
8
|
|
|
9
9
|
{{#commit-list this heading='### ⚠️ BREAKING CHANGES' message='^(feat|fix|perf)(\([^)]*\))!:' }}
|
|
10
|
-
- {{#replaceCommit}}{{subject}}{{/replaceCommit}}{{#if pullRequest}}{{#if pullRequest.href}} ([#{{pullRequest.id}}]({{pullRequest.href}})){{else}} (#{{pullRequest.id}}){{/if}}{{/if}}{{#if
|
|
10
|
+
- {{#replaceCommit}}{{subject}}{{/replaceCommit}}{{#if pullRequest}}{{#if pullRequest.href}} ([#{{pullRequest.id}}]({{pullRequest.href}})){{else}} (#{{pullRequest.id}}){{/if}}{{/if}}{{#if commitHash}}{{#if commitHref}} [({{commitHash}})]({{commitHref}}){{else}} ({{commitHash}}){{/if}}{{/if}}
|
|
11
11
|
{{/commit-list}}
|
|
12
12
|
|
|
13
13
|
{{#commit-list this heading='### 🚀 Features' message='^feat:|^feat\(' exclude='^(feat|fix|perf)(\([^)]*\))!:'}}
|
|
14
|
-
- {{#replaceCommit}}{{subject}}{{/replaceCommit}}{{#if pullRequest}}{{#if pullRequest.href}} ([#{{pullRequest.id}}]({{pullRequest.href}})){{else}} (#{{pullRequest.id}}){{/if}}{{/if}}{{#if
|
|
14
|
+
- {{#replaceCommit}}{{subject}}{{/replaceCommit}}{{#if pullRequest}}{{#if pullRequest.href}} ([#{{pullRequest.id}}]({{pullRequest.href}})){{else}} (#{{pullRequest.id}}){{/if}}{{/if}}{{#if commitHash}}{{#if commitHref}} [({{commitHash}})]({{commitHref}}){{else}} ({{commitHash}}){{/if}}{{/if}}
|
|
15
15
|
{{/commit-list}}
|
|
16
16
|
|
|
17
17
|
{{#commit-list this heading='### 🐞 Bug Fixes' message='^fix:|^fix\(' exclude='^(feat|fix|perf)(\([^)]*\))!:'}}
|
|
18
|
-
- {{#replaceCommit}}{{subject}}{{/replaceCommit}}{{#if pullRequest}}{{#if pullRequest.href}} ([#{{pullRequest.id}}]({{pullRequest.href}})){{else}} (#{{pullRequest.id}}){{/if}}{{/if}}{{#if
|
|
18
|
+
- {{#replaceCommit}}{{subject}}{{/replaceCommit}}{{#if pullRequest}}{{#if pullRequest.href}} ([#{{pullRequest.id}}]({{pullRequest.href}})){{else}} (#{{pullRequest.id}}){{/if}}{{/if}}{{#if commitHash}}{{#if commitHref}} [({{commitHash}})]({{commitHref}}){{else}} ({{commitHash}}){{/if}}{{/if}}
|
|
19
19
|
{{/commit-list}}
|
|
20
20
|
|
|
21
21
|
{{/commit-parser}}
|