conventional-changelog-storm-software 0.1.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.
Files changed (90) hide show
  1. package/LICENSE +201 -0
  2. package/README.md +278 -0
  3. package/dist/chunk-2MZWLEPP.js +132 -0
  4. package/dist/chunk-3KLR5ZGK.js +1 -0
  5. package/dist/chunk-5GQ7ZUDG.cjs +2 -0
  6. package/dist/chunk-63544DKM.js +153 -0
  7. package/dist/chunk-DL5576FZ.cjs +10 -0
  8. package/dist/chunk-HVVJTAOT.cjs +160 -0
  9. package/dist/chunk-I6KKIB6V.js +77 -0
  10. package/dist/chunk-IJLTWVLG.js +57 -0
  11. package/dist/chunk-KRZANN66.cjs +82 -0
  12. package/dist/chunk-KTGUQC7L.js +1 -0
  13. package/dist/chunk-LPCM2SVA.js +45 -0
  14. package/dist/chunk-M7BTBQHL.cjs +134 -0
  15. package/dist/chunk-O35EG2LQ.js +8 -0
  16. package/dist/chunk-RR5776TG.cjs +7 -0
  17. package/dist/chunk-S5TOCB3P.js +1 -0
  18. package/dist/chunk-SPHHWYOU.cjs +2 -0
  19. package/dist/chunk-UK5DQTL2.cjs +47 -0
  20. package/dist/chunk-UXD2EFE6.js +1 -0
  21. package/dist/chunk-UZZOYD6Y.cjs +2360 -0
  22. package/dist/chunk-XHJNEOAM.cjs +2 -0
  23. package/dist/chunk-YBJMQHWU.cjs +67 -0
  24. package/dist/chunk-ZLZS2G36.js +2353 -0
  25. package/dist/chunk-ZPVHPMDE.cjs +2 -0
  26. package/dist/commit-types.cjs +11 -0
  27. package/dist/commit-types.d.cts +130 -0
  28. package/dist/commit-types.d.ts +130 -0
  29. package/dist/commit-types.js +1 -0
  30. package/dist/index.cjs +36 -0
  31. package/dist/index.d.cts +16 -0
  32. package/dist/index.d.ts +16 -0
  33. package/dist/index.js +23 -0
  34. package/dist/parser.cjs +13 -0
  35. package/dist/parser.d.cts +12 -0
  36. package/dist/parser.d.ts +12 -0
  37. package/dist/parser.js +3 -0
  38. package/dist/types/commit-types.cjs +4 -0
  39. package/dist/types/commit-types.d.cts +19 -0
  40. package/dist/types/commit-types.d.ts +19 -0
  41. package/dist/types/commit-types.js +1 -0
  42. package/dist/types/config.cjs +5 -0
  43. package/dist/types/config.d.cts +67 -0
  44. package/dist/types/config.d.ts +67 -0
  45. package/dist/types/config.js +1 -0
  46. package/dist/types/index.cjs +8 -0
  47. package/dist/types/index.d.cts +5 -0
  48. package/dist/types/index.d.ts +5 -0
  49. package/dist/types/index.js +4 -0
  50. package/dist/types/misc.cjs +5 -0
  51. package/dist/types/misc.d.cts +3 -0
  52. package/dist/types/misc.d.ts +3 -0
  53. package/dist/types/misc.js +1 -0
  54. package/dist/types/preset.cjs +5 -0
  55. package/dist/types/preset.d.cts +12 -0
  56. package/dist/types/preset.d.ts +12 -0
  57. package/dist/types/preset.js +1 -0
  58. package/dist/types/write.cjs +5 -0
  59. package/dist/types/write.d.cts +78 -0
  60. package/dist/types/write.d.ts +78 -0
  61. package/dist/types/write.js +1 -0
  62. package/dist/utilities/constants.cjs +44 -0
  63. package/dist/utilities/constants.d.cts +75 -0
  64. package/dist/utilities/constants.d.ts +75 -0
  65. package/dist/utilities/constants.js +2 -0
  66. package/dist/utilities/helpers.cjs +25 -0
  67. package/dist/utilities/helpers.d.cts +30 -0
  68. package/dist/utilities/helpers.d.ts +30 -0
  69. package/dist/utilities/helpers.js +3 -0
  70. package/dist/utilities/index.cjs +66 -0
  71. package/dist/utilities/index.d.cts +6 -0
  72. package/dist/utilities/index.d.ts +6 -0
  73. package/dist/utilities/index.js +4 -0
  74. package/dist/utilities/options.cjs +14 -0
  75. package/dist/utilities/options.d.cts +12 -0
  76. package/dist/utilities/options.d.ts +12 -0
  77. package/dist/utilities/options.js +4 -0
  78. package/dist/whatBump.cjs +14 -0
  79. package/dist/whatBump.d.cts +6 -0
  80. package/dist/whatBump.d.ts +6 -0
  81. package/dist/whatBump.js +4 -0
  82. package/dist/writer.cjs +14 -0
  83. package/dist/writer.d.cts +13 -0
  84. package/dist/writer.d.ts +13 -0
  85. package/dist/writer.js +4 -0
  86. package/package.json +203 -0
  87. package/templates/templates/commit.hbd +29 -0
  88. package/templates/templates/footer.hbd +9 -0
  89. package/templates/templates/header.hbd +9 -0
  90. package/templates/templates/template.hbd +21 -0
@@ -0,0 +1,153 @@
1
+ import { matchScope } from './chunk-I6KKIB6V.js';
2
+ import { CHANGELOG_COMMIT_TITLE_ORDER, HEADER_MAX_LENGTH, HASH_SHORT_LENGTH } from './chunk-IJLTWVLG.js';
3
+ import compareFunc from 'compare-func';
4
+ import { readFile } from 'fs/promises';
5
+ import { resolve } from 'path';
6
+ import { fileURLToPath } from 'url';
7
+
8
+ var dirname = fileURLToPath(new URL(".", import.meta.url));
9
+ var releaseAsRegex = /release-as:\s*\w*@?([0-9]+\.[0-9]+\.[0-9a-z]+(-[0-9a-z.]+)?)\s*/i;
10
+ var owner = "{{#if this.owner}}{{~this.owner}}{{else}}{{~@root.owner}}{{/if}}";
11
+ var host = "{{~@root.host}}";
12
+ var repository = "{{#if this.repository}}{{~this.repository}}{{else}}{{~@root.repository}}{{/if}}";
13
+ async function createWriterOpts(options) {
14
+ const commitUrlFormat = expandTemplate(options.commitUrlFormat, {
15
+ host,
16
+ owner,
17
+ repository
18
+ });
19
+ const compareUrlFormat = expandTemplate(options.compareUrlFormat, {
20
+ host,
21
+ owner,
22
+ repository
23
+ });
24
+ const issueUrlFormat = expandTemplate(options.issueUrlFormat, {
25
+ host,
26
+ owner,
27
+ repository,
28
+ id: "{{this.issue}}",
29
+ prefix: "{{this.prefix}}"
30
+ });
31
+ const [template, header, commit, footer] = await Promise.all([
32
+ readFile(resolve(dirname, "./templates/template.hbs"), "utf-8"),
33
+ readFile(resolve(dirname, "./templates/header.hbs"), "utf-8"),
34
+ readFile(resolve(dirname, "./templates/commit.hbs"), "utf-8"),
35
+ readFile(resolve(dirname, "./templates/footer.hbs"), "utf-8")
36
+ ]);
37
+ const writerOpts = getWriterOpts(options);
38
+ writerOpts.mainTemplate = template;
39
+ writerOpts.headerPartial = header.replace(
40
+ /{{compareUrlFormat}}/g,
41
+ compareUrlFormat
42
+ );
43
+ writerOpts.commitPartial = commit.replace(/{{commitUrlFormat}}/g, commitUrlFormat).replace(/{{issueUrlFormat}}/g, issueUrlFormat);
44
+ writerOpts.footerPartial = footer;
45
+ return writerOpts;
46
+ }
47
+ function getWriterOpts(options) {
48
+ return {
49
+ transform: (commit, context) => {
50
+ let discard = true;
51
+ const issues = [];
52
+ const entry = findTypeEntry(options.types, commit);
53
+ if (commit.footer && releaseAsRegex.test(commit.footer) || commit.body && releaseAsRegex.test(commit.body)) {
54
+ discard = false;
55
+ }
56
+ const notes = (commit.notes || []).map(
57
+ (note) => {
58
+ discard = false;
59
+ return {
60
+ ...note,
61
+ title: "BREAKING CHANGES"
62
+ };
63
+ }
64
+ );
65
+ if (
66
+ // breaking changes attached to any type are still displayed.
67
+ discard && (entry === void 0 || entry.hidden) || !matchScope(options, commit)
68
+ ) {
69
+ return void 0;
70
+ }
71
+ const type = entry ? entry.section : commit.type;
72
+ const scope = commit.scope === "*" || options.scope ? "" : commit.scope;
73
+ let { subject } = commit;
74
+ if (typeof subject === "string") {
75
+ const issueRegEx = `(${options.issuePrefixes.join("|")})([a-z0-9]+)`;
76
+ const re = new RegExp(issueRegEx, "g");
77
+ subject = subject.replace(re, (_, prefix, issue) => {
78
+ issues.push(prefix + issue);
79
+ const url = expandTemplate(options.issueUrlFormat, {
80
+ host: context.host,
81
+ owner: context.owner,
82
+ repository: context.repository,
83
+ id: issue,
84
+ prefix
85
+ });
86
+ return `[${prefix}${issue}](${url})`;
87
+ });
88
+ subject = subject.replace(
89
+ /\B@([a-z0-9](?:-?[a-z0-9/]){0,38})/g,
90
+ (_, user) => {
91
+ if (user.includes("/")) {
92
+ return `@${user}`;
93
+ }
94
+ const usernameUrl = expandTemplate(options.userUrlFormat, {
95
+ host: context.host,
96
+ owner: context.owner,
97
+ repository: context.repository,
98
+ user
99
+ });
100
+ return `[@${user}](${usernameUrl})`;
101
+ }
102
+ );
103
+ }
104
+ const references = (commit.references || []).filter(
105
+ (reference) => !issues.includes(reference.prefix + reference.issue)
106
+ );
107
+ return {
108
+ ...commit,
109
+ raw: commit,
110
+ notes,
111
+ type,
112
+ scope: scope === void 0 ? null : scope,
113
+ subject,
114
+ references,
115
+ shortHash: typeof commit.hash === "string" ? commit.hash.substring(0, HASH_SHORT_LENGTH) : commit.shortHash,
116
+ header: typeof commit.header === "string" ? commit.header.substring(0, HEADER_MAX_LENGTH) : commit.header,
117
+ committerDate: commit.committerDate ? options.formatDate(commit.committerDate) : commit.committerDate
118
+ };
119
+ },
120
+ groupBy: "type",
121
+ // the groupings of commit messages, e.g., Features vs., Bug Fixes, are
122
+ // sorted based on their probable importance:
123
+ commitGroupsSort: (a, b) => {
124
+ const gRankA = CHANGELOG_COMMIT_TITLE_ORDER.indexOf(a.title);
125
+ const gRankB = CHANGELOG_COMMIT_TITLE_ORDER.indexOf(b.title);
126
+ return gRankA - gRankB;
127
+ },
128
+ commitsSort: ["scope", "subject"],
129
+ noteGroupsSort: "title",
130
+ notesSort: compareFunc
131
+ };
132
+ }
133
+ function findTypeEntry(types, commit) {
134
+ const typeKey = (commit.revert ? "revert" : commit.type || "").toLowerCase();
135
+ return types.find((entry) => {
136
+ if (entry.type !== typeKey) {
137
+ return false;
138
+ }
139
+ if (entry.scope && entry.scope !== commit.scope) {
140
+ return false;
141
+ }
142
+ return true;
143
+ });
144
+ }
145
+ function expandTemplate(template, context) {
146
+ let expanded = template;
147
+ Object.keys(context).forEach((key) => {
148
+ expanded = expanded.replace(new RegExp(`{{${key}}}`, "g"), context[key]);
149
+ });
150
+ return expanded;
151
+ }
152
+
153
+ export { createWriterOpts };
@@ -0,0 +1,10 @@
1
+ 'use strict';
2
+
3
+ var chunkYBJMQHWU_cjs = require('./chunk-YBJMQHWU.cjs');
4
+
5
+ // src/parser.ts
6
+ function createParserOpts(variant) {
7
+ return variant === "minimal" ? chunkYBJMQHWU_cjs.MINIMAL_PARSER_DEFAULT_OPTIONS : chunkYBJMQHWU_cjs.MONOREPO_PARSER_DEFAULT_OPTIONS;
8
+ }
9
+
10
+ exports.createParserOpts = createParserOpts;
@@ -0,0 +1,160 @@
1
+ 'use strict';
2
+
3
+ var chunkKRZANN66_cjs = require('./chunk-KRZANN66.cjs');
4
+ var chunkYBJMQHWU_cjs = require('./chunk-YBJMQHWU.cjs');
5
+ var chunkRR5776TG_cjs = require('./chunk-RR5776TG.cjs');
6
+ var compareFunc = require('compare-func');
7
+ var promises = require('fs/promises');
8
+ var path = require('path');
9
+ var url = require('url');
10
+
11
+ function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
12
+
13
+ var compareFunc__default = /*#__PURE__*/_interopDefault(compareFunc);
14
+
15
+ var dirname = url.fileURLToPath(new URL(".", chunkRR5776TG_cjs.importMetaUrl));
16
+ var releaseAsRegex = /release-as:\s*\w*@?([0-9]+\.[0-9]+\.[0-9a-z]+(-[0-9a-z.]+)?)\s*/i;
17
+ var owner = "{{#if this.owner}}{{~this.owner}}{{else}}{{~@root.owner}}{{/if}}";
18
+ var host = "{{~@root.host}}";
19
+ var repository = "{{#if this.repository}}{{~this.repository}}{{else}}{{~@root.repository}}{{/if}}";
20
+ async function createWriterOpts(options) {
21
+ const commitUrlFormat = expandTemplate(options.commitUrlFormat, {
22
+ host,
23
+ owner,
24
+ repository
25
+ });
26
+ const compareUrlFormat = expandTemplate(options.compareUrlFormat, {
27
+ host,
28
+ owner,
29
+ repository
30
+ });
31
+ const issueUrlFormat = expandTemplate(options.issueUrlFormat, {
32
+ host,
33
+ owner,
34
+ repository,
35
+ id: "{{this.issue}}",
36
+ prefix: "{{this.prefix}}"
37
+ });
38
+ const [template, header, commit, footer] = await Promise.all([
39
+ promises.readFile(path.resolve(dirname, "./templates/template.hbs"), "utf-8"),
40
+ promises.readFile(path.resolve(dirname, "./templates/header.hbs"), "utf-8"),
41
+ promises.readFile(path.resolve(dirname, "./templates/commit.hbs"), "utf-8"),
42
+ promises.readFile(path.resolve(dirname, "./templates/footer.hbs"), "utf-8")
43
+ ]);
44
+ const writerOpts = getWriterOpts(options);
45
+ writerOpts.mainTemplate = template;
46
+ writerOpts.headerPartial = header.replace(
47
+ /{{compareUrlFormat}}/g,
48
+ compareUrlFormat
49
+ );
50
+ writerOpts.commitPartial = commit.replace(/{{commitUrlFormat}}/g, commitUrlFormat).replace(/{{issueUrlFormat}}/g, issueUrlFormat);
51
+ writerOpts.footerPartial = footer;
52
+ return writerOpts;
53
+ }
54
+ function getWriterOpts(options) {
55
+ return {
56
+ transform: (commit, context) => {
57
+ let discard = true;
58
+ const issues = [];
59
+ const entry = findTypeEntry(options.types, commit);
60
+ if (commit.footer && releaseAsRegex.test(commit.footer) || commit.body && releaseAsRegex.test(commit.body)) {
61
+ discard = false;
62
+ }
63
+ const notes = (commit.notes || []).map(
64
+ (note) => {
65
+ discard = false;
66
+ return {
67
+ ...note,
68
+ title: "BREAKING CHANGES"
69
+ };
70
+ }
71
+ );
72
+ if (
73
+ // breaking changes attached to any type are still displayed.
74
+ discard && (entry === void 0 || entry.hidden) || !chunkKRZANN66_cjs.matchScope(options, commit)
75
+ ) {
76
+ return void 0;
77
+ }
78
+ const type = entry ? entry.section : commit.type;
79
+ const scope = commit.scope === "*" || options.scope ? "" : commit.scope;
80
+ let { subject } = commit;
81
+ if (typeof subject === "string") {
82
+ const issueRegEx = `(${options.issuePrefixes.join("|")})([a-z0-9]+)`;
83
+ const re = new RegExp(issueRegEx, "g");
84
+ subject = subject.replace(re, (_, prefix, issue) => {
85
+ issues.push(prefix + issue);
86
+ const url = expandTemplate(options.issueUrlFormat, {
87
+ host: context.host,
88
+ owner: context.owner,
89
+ repository: context.repository,
90
+ id: issue,
91
+ prefix
92
+ });
93
+ return `[${prefix}${issue}](${url})`;
94
+ });
95
+ subject = subject.replace(
96
+ /\B@([a-z0-9](?:-?[a-z0-9/]){0,38})/g,
97
+ (_, user) => {
98
+ if (user.includes("/")) {
99
+ return `@${user}`;
100
+ }
101
+ const usernameUrl = expandTemplate(options.userUrlFormat, {
102
+ host: context.host,
103
+ owner: context.owner,
104
+ repository: context.repository,
105
+ user
106
+ });
107
+ return `[@${user}](${usernameUrl})`;
108
+ }
109
+ );
110
+ }
111
+ const references = (commit.references || []).filter(
112
+ (reference) => !issues.includes(reference.prefix + reference.issue)
113
+ );
114
+ return {
115
+ ...commit,
116
+ raw: commit,
117
+ notes,
118
+ type,
119
+ scope: scope === void 0 ? null : scope,
120
+ subject,
121
+ references,
122
+ shortHash: typeof commit.hash === "string" ? commit.hash.substring(0, chunkYBJMQHWU_cjs.HASH_SHORT_LENGTH) : commit.shortHash,
123
+ header: typeof commit.header === "string" ? commit.header.substring(0, chunkYBJMQHWU_cjs.HEADER_MAX_LENGTH) : commit.header,
124
+ committerDate: commit.committerDate ? options.formatDate(commit.committerDate) : commit.committerDate
125
+ };
126
+ },
127
+ groupBy: "type",
128
+ // the groupings of commit messages, e.g., Features vs., Bug Fixes, are
129
+ // sorted based on their probable importance:
130
+ commitGroupsSort: (a, b) => {
131
+ const gRankA = chunkYBJMQHWU_cjs.CHANGELOG_COMMIT_TITLE_ORDER.indexOf(a.title);
132
+ const gRankB = chunkYBJMQHWU_cjs.CHANGELOG_COMMIT_TITLE_ORDER.indexOf(b.title);
133
+ return gRankA - gRankB;
134
+ },
135
+ commitsSort: ["scope", "subject"],
136
+ noteGroupsSort: "title",
137
+ notesSort: compareFunc__default.default
138
+ };
139
+ }
140
+ function findTypeEntry(types, commit) {
141
+ const typeKey = (commit.revert ? "revert" : commit.type || "").toLowerCase();
142
+ return types.find((entry) => {
143
+ if (entry.type !== typeKey) {
144
+ return false;
145
+ }
146
+ if (entry.scope && entry.scope !== commit.scope) {
147
+ return false;
148
+ }
149
+ return true;
150
+ });
151
+ }
152
+ function expandTemplate(template, context) {
153
+ let expanded = template;
154
+ Object.keys(context).forEach((key) => {
155
+ expanded = expanded.replace(new RegExp(`{{${key}}}`, "g"), context[key]);
156
+ });
157
+ return expanded;
158
+ }
159
+
160
+ exports.createWriterOpts = createWriterOpts;
@@ -0,0 +1,77 @@
1
+ import { DATETIME_LENGTH } from './chunk-IJLTWVLG.js';
2
+
3
+ // src/utilities/helpers.ts
4
+ function hasIntersection(a, b) {
5
+ if (!a || !b) {
6
+ return false;
7
+ }
8
+ let listA = a;
9
+ let listB = b;
10
+ if (!Array.isArray(listA)) {
11
+ listA = [listA];
12
+ }
13
+ if (!Array.isArray(listB)) {
14
+ listB = [listB];
15
+ }
16
+ return listA.some((item) => listB.includes(item));
17
+ }
18
+ function matchScope(config = {}, commit) {
19
+ const { scope: targetScope, scopeOnly = false } = config;
20
+ const includesScope = commit.scope && targetScope && hasIntersection(commit.scope.split(","), targetScope);
21
+ return Boolean(
22
+ !targetScope || scopeOnly && includesScope || !scopeOnly && (!commit.scope || includesScope)
23
+ );
24
+ }
25
+ function formatDate(date) {
26
+ return new Date(date).toISOString().slice(0, DATETIME_LENGTH);
27
+ }
28
+ function stringify(obj) {
29
+ const stack = [];
30
+ const keys = [];
31
+ let thisPos;
32
+ function cycleReplacer(value) {
33
+ if (stack[0] === value) {
34
+ return "[Circular ~]";
35
+ }
36
+ return `[Circular ~.${keys.slice(0, stack.indexOf(value)).join(".")}]`;
37
+ }
38
+ function serializer(key, value) {
39
+ let resultValue = value;
40
+ if (stack.length > 0) {
41
+ thisPos = stack.indexOf(this);
42
+ if (thisPos !== -1) {
43
+ stack.splice(thisPos + 1);
44
+ keys.splice(thisPos, Infinity, key);
45
+ } else {
46
+ stack.push(this);
47
+ keys.push(key);
48
+ }
49
+ if (stack.includes(resultValue)) {
50
+ resultValue = cycleReplacer(resultValue);
51
+ }
52
+ } else {
53
+ stack.push(resultValue);
54
+ }
55
+ return resultValue;
56
+ }
57
+ return JSON.stringify(obj, serializer, " ");
58
+ }
59
+ function createComparator(strings) {
60
+ if (typeof strings === "string") {
61
+ return (a, b) => (a[strings] || "").localeCompare(b[strings] || "");
62
+ }
63
+ if (Array.isArray(strings)) {
64
+ return (a, b) => {
65
+ let strA = "";
66
+ let strB = "";
67
+ for (const key of strings) {
68
+ strA += a[key] || "";
69
+ strB += b[key] || "";
70
+ }
71
+ return strA.localeCompare(strB);
72
+ };
73
+ }
74
+ return strings;
75
+ }
76
+
77
+ export { createComparator, formatDate, matchScope, stringify };
@@ -0,0 +1,57 @@
1
+ import { COMMIT_TYPES } from './chunk-2MZWLEPP.js';
2
+
3
+ // src/utilities/constants.ts
4
+ var CHANGELOG_COMMITS = Object.entries(COMMIT_TYPES).reduce(
5
+ (ret, [key, commitType]) => {
6
+ ret[key] = {
7
+ ...commitType.changelog,
8
+ type: key,
9
+ title: commitType.changelog?.title || commitType.title,
10
+ hidden: commitType.changelog?.hidden
11
+ };
12
+ return ret;
13
+ },
14
+ {}
15
+ );
16
+ var CHANGELOG_COMMIT_ORDER = [
17
+ CHANGELOG_COMMITS.feat,
18
+ CHANGELOG_COMMITS.fix,
19
+ CHANGELOG_COMMITS.chore,
20
+ CHANGELOG_COMMITS.deps,
21
+ CHANGELOG_COMMITS.docs,
22
+ CHANGELOG_COMMITS.style,
23
+ CHANGELOG_COMMITS.refactor,
24
+ CHANGELOG_COMMITS.perf,
25
+ CHANGELOG_COMMITS.build,
26
+ CHANGELOG_COMMITS.ci,
27
+ CHANGELOG_COMMITS.test
28
+ ];
29
+ var CHANGELOG_COMMIT_TYPE_ORDER = CHANGELOG_COMMIT_ORDER.map(
30
+ (entry) => entry.type
31
+ );
32
+ var CHANGELOG_COMMIT_TITLE_ORDER = CHANGELOG_COMMIT_ORDER.map(
33
+ (entry) => entry.title
34
+ );
35
+ var HASH_SHORT_LENGTH = 7;
36
+ var HEADER_MAX_LENGTH = 100;
37
+ var DATETIME_LENGTH = 10;
38
+ var MINIMAL_PARSER_DEFAULT_OPTIONS = {
39
+ headerPattern: /^(\w*): (.*)$/,
40
+ breakingHeaderPattern: /^(\w*): (.*)$/,
41
+ headerCorrespondence: ["type", "subject"],
42
+ noteKeywords: ["BREAKING CHANGE", "BREAKING-CHANGE"],
43
+ revertPattern: /^(?:Revert|revert:)\s"?([\s\S]+?)"?\s*This reverts commit (\w*)\./i,
44
+ revertCorrespondence: ["header", "hash"],
45
+ issuePrefixes: ["#"]
46
+ };
47
+ var MONOREPO_PARSER_DEFAULT_OPTIONS = {
48
+ headerPattern: /^(\w*)(?:\((.*)\))!?: (.*)$/,
49
+ breakingHeaderPattern: /^(\w*)(?:\((.*)\))!: (.*)$/,
50
+ headerCorrespondence: ["type", "scope", "subject"],
51
+ noteKeywords: ["BREAKING CHANGE", "BREAKING-CHANGE"],
52
+ revertPattern: /^(?:Revert|revert:)\s"?([\s\S]+?)"?\s*This reverts commit (\w*)\./i,
53
+ revertCorrespondence: ["header", "hash"],
54
+ issuePrefixes: ["#"]
55
+ };
56
+
57
+ export { CHANGELOG_COMMITS, CHANGELOG_COMMIT_ORDER, CHANGELOG_COMMIT_TITLE_ORDER, CHANGELOG_COMMIT_TYPE_ORDER, DATETIME_LENGTH, HASH_SHORT_LENGTH, HEADER_MAX_LENGTH, MINIMAL_PARSER_DEFAULT_OPTIONS, MONOREPO_PARSER_DEFAULT_OPTIONS };
@@ -0,0 +1,82 @@
1
+ 'use strict';
2
+
3
+ var chunkYBJMQHWU_cjs = require('./chunk-YBJMQHWU.cjs');
4
+
5
+ // src/utilities/helpers.ts
6
+ function hasIntersection(a, b) {
7
+ if (!a || !b) {
8
+ return false;
9
+ }
10
+ let listA = a;
11
+ let listB = b;
12
+ if (!Array.isArray(listA)) {
13
+ listA = [listA];
14
+ }
15
+ if (!Array.isArray(listB)) {
16
+ listB = [listB];
17
+ }
18
+ return listA.some((item) => listB.includes(item));
19
+ }
20
+ function matchScope(config = {}, commit) {
21
+ const { scope: targetScope, scopeOnly = false } = config;
22
+ const includesScope = commit.scope && targetScope && hasIntersection(commit.scope.split(","), targetScope);
23
+ return Boolean(
24
+ !targetScope || scopeOnly && includesScope || !scopeOnly && (!commit.scope || includesScope)
25
+ );
26
+ }
27
+ function formatDate(date) {
28
+ return new Date(date).toISOString().slice(0, chunkYBJMQHWU_cjs.DATETIME_LENGTH);
29
+ }
30
+ function stringify(obj) {
31
+ const stack = [];
32
+ const keys = [];
33
+ let thisPos;
34
+ function cycleReplacer(value) {
35
+ if (stack[0] === value) {
36
+ return "[Circular ~]";
37
+ }
38
+ return `[Circular ~.${keys.slice(0, stack.indexOf(value)).join(".")}]`;
39
+ }
40
+ function serializer(key, value) {
41
+ let resultValue = value;
42
+ if (stack.length > 0) {
43
+ thisPos = stack.indexOf(this);
44
+ if (thisPos !== -1) {
45
+ stack.splice(thisPos + 1);
46
+ keys.splice(thisPos, Infinity, key);
47
+ } else {
48
+ stack.push(this);
49
+ keys.push(key);
50
+ }
51
+ if (stack.includes(resultValue)) {
52
+ resultValue = cycleReplacer(resultValue);
53
+ }
54
+ } else {
55
+ stack.push(resultValue);
56
+ }
57
+ return resultValue;
58
+ }
59
+ return JSON.stringify(obj, serializer, " ");
60
+ }
61
+ function createComparator(strings) {
62
+ if (typeof strings === "string") {
63
+ return (a, b) => (a[strings] || "").localeCompare(b[strings] || "");
64
+ }
65
+ if (Array.isArray(strings)) {
66
+ return (a, b) => {
67
+ let strA = "";
68
+ let strB = "";
69
+ for (const key of strings) {
70
+ strA += a[key] || "";
71
+ strB += b[key] || "";
72
+ }
73
+ return strA.localeCompare(strB);
74
+ };
75
+ }
76
+ return strings;
77
+ }
78
+
79
+ exports.createComparator = createComparator;
80
+ exports.formatDate = formatDate;
81
+ exports.matchScope = matchScope;
82
+ exports.stringify = stringify;
@@ -0,0 +1 @@
1
+
@@ -0,0 +1,45 @@
1
+ import { matchScope } from './chunk-I6KKIB6V.js';
2
+ import { CHANGELOG_COMMIT_ORDER } from './chunk-IJLTWVLG.js';
3
+
4
+ // src/whatBump.ts
5
+ function createWhatBump(options) {
6
+ const hiddenTypes = options.bumpStrict ? CHANGELOG_COMMIT_ORDER.reduce((hiddenTypes2, type) => {
7
+ if (type.hidden) {
8
+ hiddenTypes2.push(type.type);
9
+ }
10
+ return hiddenTypes2;
11
+ }, []) : [];
12
+ return function whatBump(commits) {
13
+ let level = 2;
14
+ let breakings = 0;
15
+ let features = 0;
16
+ let bugfixes = 0;
17
+ commits.forEach((commit) => {
18
+ if (!matchScope(options, commit)) {
19
+ return;
20
+ }
21
+ if (commit.notes.length > 0) {
22
+ breakings += commit.notes.length;
23
+ level = 0;
24
+ } else if (commit.type === "feat" || commit.type === "feature") {
25
+ features += 1;
26
+ if (level === 2) {
27
+ level = 1;
28
+ }
29
+ } else if (options.bumpStrict && !hiddenTypes.includes(commit.type)) {
30
+ bugfixes += 1;
31
+ }
32
+ });
33
+ if (options?.preMajor && level < 2) {
34
+ level++;
35
+ } else if (options.bumpStrict && level === 2 && !breakings && !features && !bugfixes) {
36
+ return null;
37
+ }
38
+ return {
39
+ level,
40
+ reason: breakings === 1 ? `There is ${breakings} BREAKING CHANGE and ${features} features` : `There are ${breakings} BREAKING CHANGES and ${features} features`
41
+ };
42
+ };
43
+ }
44
+
45
+ export { createWhatBump };