@taiga-ui/auto-changelog-config 0.490.0 → 0.492.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.490.0",
3
+ "version": "0.492.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}} ([#{{pullRequest.id}}]({{pullRequest.href}})){{/if}} [({{shorthash}})]({{href}})
11
+ {{/commit-list}}
12
+
13
+ {{#commit-list this heading='### 🚀 Features' message='^feat:|^feat\(' exclude='^(feat|fix|perf)(\([^)]*\))!:'}}
14
+ - {{#replaceCommit}}{{subject}}{{/replaceCommit}}{{#if pullRequest}} ([#{{pullRequest.id}}]({{pullRequest.href}})){{/if}} [({{shorthash}})]({{href}})
15
+ {{/commit-list}}
16
+
17
+ {{#commit-list this heading='### 🐞 Bug Fixes' message='^fix:|^fix\(' exclude='^(feat|fix|perf)(\([^)]*\))!:'}}
18
+ - {{#replaceCommit}}{{subject}}{{/replaceCommit}}{{#if pullRequest}} ([#{{pullRequest.id}}]({{pullRequest.href}})){{/if}} [({{shorthash}})]({{href}})
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,93 @@
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 getCommitAuthor = (commit) =>
4
+ commit.pullRequest?.author?.login ??
5
+ commit.pullRequest?.author ??
6
+ commit.author ??
7
+ '';
8
+
9
+ const normalizeContributor = (author) => {
10
+ const name = String(author).trim().replace(/^@/, '') ?? '';
11
+
12
+ const isBot =
13
+ name.endsWith('bot') ||
14
+ name.endsWith('[bot]') ||
15
+ name === 'github-actions' ||
16
+ name === 'renovate';
17
+
18
+ if (!name || isBot) {
19
+ return '';
20
+ }
21
+
22
+ return `@${name}`;
23
+ };
24
+
25
+ const formatContributors = (contributors) => {
26
+ if (contributors.length === 1) {
27
+ return contributors[0];
28
+ }
29
+
30
+ if (contributors.length === 2) {
31
+ return `${contributors[0]} and ${contributors[1]}`;
32
+ }
33
+
34
+ return `${contributors.slice(0, -1).join(', ')} and ${
35
+ contributors[contributors.length - 1]
36
+ }`;
37
+ };
38
+
39
+ Handlebars.registerHelper('commit-parser', function (...args) {
40
+ const options = args.pop();
41
+
42
+ const commits = args.flat().filter(Boolean);
43
+
44
+ const unique = [
45
+ ...new Map(
46
+ commits.map((commit) => [
47
+ commit.hash ?? commit.shorthash ?? commit.href ?? commit.subject,
48
+ commit,
49
+ ]),
50
+ ).values(),
51
+ ];
52
+
53
+ return options.fn(unique);
54
+ });
55
+
6
56
  Handlebars.registerHelper('replaceCommit', function (context) {
7
57
  const commit =
8
- /^(build|chore|ci|docs|feat|fix|perf|refactor|revert|style|test)\s?(\((.*?)\))?!?: (.*)$/g;
58
+ /^(?:build|chore|ci|docs|feat|fix|perf|refactor|revert|style|test)\s?(?:\((?<scope>[^)]*)\))?!?: (?<title>.*)$/;
9
59
 
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;
60
+ const string = String(context.fn(this));
61
+ const {scope = '', title = ''} = commit.exec(string)?.groups ?? {};
62
+ const result = scope ? `**${scope.toLowerCase()}**: ${title}` : title;
15
63
 
16
64
  return result || 'empty commit name';
17
65
  });
18
66
 
19
67
  Handlebars.registerHelper('replaceTitle', function (context) {
20
- // @ts-ignore
21
- const string = context.fn(this);
68
+ const string = String(context.fn(this));
22
69
 
23
- return string.replace('v', '');
70
+ return string.replace(/^v/, '');
24
71
  });
25
72
 
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);
73
+ Handlebars.registerHelper('contributors', function (...args) {
74
+ const options = args.pop();
75
+
76
+ const commits = args.flat().filter(Boolean);
77
+
78
+ const contributors = [
79
+ ...new Set(
80
+ commits.map(getCommitAuthor).map(normalizeContributor).filter(Boolean),
81
+ ),
82
+ ];
83
+
84
+ if (!contributors.length) {
85
+ return '';
86
+ }
31
87
 
32
- return options.fn(result);
88
+ return options.fn({
89
+ contributors,
90
+ text: `Thanks ${formatContributors(contributors)}!`,
91
+ });
33
92
  });
34
93
  };
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}} ([#{{pullRequest.id}}]({{pullRequest.href}})){{/if}} [({{shorthash}})]({{href}})
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}} ([#{{pullRequest.id}}]({{pullRequest.href}})){{/if}} [({{shorthash}})]({{href}})
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}} ([#{{pullRequest.id}}]({{pullRequest.href}})){{/if}} [({{shorthash}})]({{href}})
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}}