@taiga-ui/auto-changelog-config 0.491.0 → 0.493.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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@taiga-ui/auto-changelog-config",
3
- "version": "0.491.0",
3
+ "version": "0.493.0",
4
4
  "description": "Taiga UI auto-changelog config",
5
5
  "keywords": [
6
6
  "auto-changelog"
@@ -0,0 +1,29 @@
1
+ {{! prettier-ignore }}
2
+ {{#each releases}}
3
+ {{#if tag}}
4
+ ##{{#unless major}}#{{/unless}} [{{#replaceTitle}}{{title}}{{/replaceTitle}}]({{href}}) ({{isoDate}})
5
+ {{/if}}
6
+
7
+ {{#commit-parser merges commits}}
8
+
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 shorthash}}{{#if href}} [({{shorthash}})]({{href}}){{else}} ({{shorthash}}){{/if}}{{/if}}
11
+ {{/commit-list}}
12
+
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 shorthash}}{{#if href}} [({{shorthash}})]({{href}}){{else}} ({{shorthash}}){{/if}}{{/if}}
15
+ {{/commit-list}}
16
+
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 shorthash}}{{#if href}} [({{shorthash}})]({{href}}){{else}} ({{shorthash}}){{/if}}{{/if}}
19
+ {{/commit-list}}
20
+
21
+ {{/commit-parser}}
22
+
23
+ {{#contributors commits merges}}
24
+ ### Contributors
25
+
26
+ {{text}}
27
+ {{/contributors}}
28
+
29
+ {{/each}}
package/setup.js CHANGED
@@ -1,34 +1,160 @@
1
1
  /* eslint-disable @typescript-eslint/no-invalid-this */
2
- module.exports = function (
3
- /** @type {{ registerHelper: (arg0: string, arg1: { (context: any): any; (context: any): any; }) => void; }} */
4
- Handlebars,
5
- ) {
2
+ module.exports = function (Handlebars) {
3
+ const firstNonEmptyString = (...values) =>
4
+ values.map((value) => String(value ?? '').trim()).find(Boolean) ?? '';
5
+
6
+ const getPullRequestId = (href) => {
7
+ const [, id = ''] =
8
+ String(href ?? '').match(
9
+ /\/(?:pull|merge_requests|pull-requests)\/(\d+)(?:$|[/?#])/,
10
+ ) ?? [];
11
+
12
+ return id;
13
+ };
14
+
15
+ const normalizePullRequest = (commit) => {
16
+ const pullRequest = commit.pullRequest ?? {};
17
+ const href = firstNonEmptyString(pullRequest.href, commit.href);
18
+
19
+ const id = firstNonEmptyString(
20
+ pullRequest.id,
21
+ pullRequest.number,
22
+ getPullRequestId(href),
23
+ );
24
+
25
+ if (!id) {
26
+ return;
27
+ }
28
+
29
+ return {
30
+ ...pullRequest,
31
+ id,
32
+ author: pullRequest.author ?? commit.author,
33
+ href,
34
+ };
35
+ };
36
+
37
+ const normalizeCommit = (commit) => {
38
+ const subject = firstNonEmptyString(
39
+ commit.subject,
40
+ commit.message,
41
+ commit.title,
42
+ commit.pullRequest?.title,
43
+ );
44
+
45
+ const pullRequest = normalizePullRequest(commit);
46
+
47
+ return {
48
+ ...commit,
49
+ message: firstNonEmptyString(commit.message, subject),
50
+ pullRequest,
51
+ subject,
52
+ };
53
+ };
54
+
55
+ const getCommitAuthor = (commit) =>
56
+ commit.pullRequest?.author?.login ??
57
+ commit.pullRequest?.user?.login ??
58
+ commit.author?.login ??
59
+ commit.user?.login ??
60
+ commit.pullRequest?.author ??
61
+ commit.author ??
62
+ '';
63
+
64
+ const isGithubLogin = (name) => /^[a-z\d](?:[a-z\d-]{0,37}[a-z\d])?$/i.test(name);
65
+
66
+ const normalizeContributor = (author) => {
67
+ const name = String(author).trim().replace(/^@/, '');
68
+ const lowerName = name.toLowerCase();
69
+
70
+ const isBot =
71
+ lowerName.endsWith('[bot]') ||
72
+ lowerName.endsWith('-bot') ||
73
+ lowerName === 'dependabot' ||
74
+ lowerName === 'renovatebot' ||
75
+ lowerName === 'github-actions' ||
76
+ lowerName === 'renovate' ||
77
+ lowerName === 'gemini-code-assist';
78
+
79
+ if (!name || isBot || !isGithubLogin(name)) {
80
+ return '';
81
+ }
82
+
83
+ return `@${name}`;
84
+ };
85
+
86
+ const formatContributors = (contributors) => {
87
+ if (contributors.length === 1) {
88
+ return contributors[0];
89
+ }
90
+
91
+ if (contributors.length === 2) {
92
+ return `${contributors[0]} and ${contributors[1]}`;
93
+ }
94
+
95
+ return `${contributors.slice(0, -1).join(', ')} and ${
96
+ contributors[contributors.length - 1]
97
+ }`;
98
+ };
99
+
100
+ Handlebars.registerHelper('commit-parser', function (...args) {
101
+ const options = args.pop();
102
+
103
+ const commits = args.flat().filter(Boolean).map(normalizeCommit);
104
+
105
+ const unique = [
106
+ ...new Map(
107
+ commits.map((commit) => [
108
+ firstNonEmptyString(
109
+ commit.hash,
110
+ commit.shorthash,
111
+ commit.pullRequest?.href,
112
+ commit.href,
113
+ commit.subject,
114
+ ),
115
+ commit,
116
+ ]),
117
+ ).values(),
118
+ ];
119
+
120
+ return options.fn(unique);
121
+ });
122
+
6
123
  Handlebars.registerHelper('replaceCommit', function (context) {
7
124
  const commit =
8
- /^(build|chore|ci|docs|feat|fix|perf|refactor|revert|style|test)\s?(\((.*?)\))?!?: (.*)$/g;
125
+ /^(?:build|chore|ci|docs|feat|fix|perf|refactor|revert|style|test)\s?(?:\((?<scope>[^)]*)\))?!?: (?<title>.*)$/;
9
126
 
10
- // @ts-ignore
11
- const string = context.fn(this);
12
- const parsed = Array.from(string.matchAll(commit) ?? [])[0] ?? [];
13
- const [, , , scope = '', title = ''] = parsed;
14
- const result = scope ? `**${scope.toLocaleLowerCase()}**: ${title}` : title;
127
+ const string = String(context.fn(this)).trim();
128
+ const {scope = '', title = ''} = commit.exec(string)?.groups ?? {};
129
+ const result = scope ? `**${scope.toLowerCase()}**: ${title}` : title;
15
130
 
16
- return result || 'empty commit name';
131
+ return result || string || 'empty commit name';
17
132
  });
18
133
 
19
134
  Handlebars.registerHelper('replaceTitle', function (context) {
20
- // @ts-ignore
21
- const string = context.fn(this);
135
+ const string = String(context.fn(this)).trim();
22
136
 
23
- return string.replace('v', '');
137
+ return string.replace(/^v/, '');
24
138
  });
25
139
 
26
- // @ts-ignore
27
- Handlebars.registerHelper('commit-parser', (merges, commits, options) => {
28
- // @ts-ignore
29
- const commitsFromMerges = merges.map((merge) => merge.commit);
30
- const result = commits.concat(commitsFromMerges);
140
+ Handlebars.registerHelper('contributors', function (...args) {
141
+ const options = args.pop();
142
+
143
+ const commits = args.flat().filter(Boolean).map(normalizeCommit);
144
+
145
+ const contributors = [
146
+ ...new Set(
147
+ commits.map(getCommitAuthor).map(normalizeContributor).filter(Boolean),
148
+ ),
149
+ ];
150
+
151
+ if (!contributors.length) {
152
+ return '';
153
+ }
31
154
 
32
- return options.fn(result);
155
+ return options.fn({
156
+ contributors,
157
+ text: `Thanks ${formatContributors(contributors)}!`,
158
+ });
33
159
  });
34
160
  };
package/template.hbs CHANGED
@@ -1,27 +1,23 @@
1
1
  {{! prettier-ignore }}
2
2
  {{#each releases}}
3
3
  {{#if tag}}
4
- ##{{#unless major}}#{{/unless}} [{{#replaceTitle}}{{title}}{{/replaceTitle}}]({{href}}) ({{isoDate}})
4
+ ##{{#unless major}}#{{/unless}} [{{#replaceTitle}}{{title}}{{/replaceTitle}}]({{href}}) ({{isoDate}})
5
5
  {{/if}}
6
6
 
7
- {{#commit-parser merges commits}}
7
+ {{#commit-parser merges commits}}
8
8
 
9
- {{#commit-list this heading='### BREAKING CHANGES' message='breaking change:|breaking:' }}
10
- - {{#replaceCommit}}{{subject}}{{/replaceCommit}} [({{shorthash}})]({{href}})
11
- {{/commit-list}}
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 shorthash}}{{#if href}} [({{shorthash}})]({{href}}){{else}} ({{shorthash}}){{/if}}{{/if}}
11
+ {{/commit-list}}
12
12
 
13
- {{#commit-list this heading='### 🚀 Features' message='^feat:|feat\(|^refactor:|^refactor\(' exclude='breaking change:|breaking:'}}
14
- - {{#replaceCommit}}{{subject}}{{/replaceCommit}} [({{shorthash}})]({{href}})
15
- {{/commit-list}}
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 shorthash}}{{#if href}} [({{shorthash}})]({{href}}){{else}} ({{shorthash}}){{/if}}{{/if}}
15
+ {{/commit-list}}
16
16
 
17
- {{#commit-list this heading='### 🐞 Bug Fixes' message='^fix:|^fix\(|^perf:|^perf\(' exclude='breaking change:|breaking:'}}
18
- - {{#replaceCommit}}{{subject}}{{/replaceCommit}} [({{shorthash}})]({{href}})
19
- {{/commit-list}}
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 shorthash}}{{#if href}} [({{shorthash}})]({{href}}){{else}} ({{shorthash}}){{/if}}{{/if}}
19
+ {{/commit-list}}
20
20
 
21
- {{#commit-list this heading='### ⚠️ Deprecations' message='^deprecate:|^deprecate\(' exclude='breaking change:|breaking:'}}
22
- - {{#replaceCommit}}{{subject}}{{/replaceCommit}} [({{shorthash}})]({{href}})
23
- {{/commit-list}}
24
-
25
- {{/commit-parser}}
21
+ {{/commit-parser}}
26
22
 
27
23
  {{/each}}