@html-validate/commitlint-config 4.3.2 → 4.3.3

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.
@@ -12,23 +12,6 @@ var __export = (target, all) => {
12
12
  __defProp(target, name, { get: all[name], enumerable: true });
13
13
  };
14
14
 
15
- // node_modules/conventional-changelog-conventionalcommits/src/parser.js
16
- function createParserOpts(config) {
17
- return {
18
- headerPattern: /^(\w*)(?:\((.*)\))?!?: (.*)$/,
19
- breakingHeaderPattern: /^(\w*)(?:\((.*)\))?!: (.*)$/,
20
- headerCorrespondence: [
21
- "type",
22
- "scope",
23
- "subject"
24
- ],
25
- noteKeywords: ["BREAKING CHANGE", "BREAKING-CHANGE"],
26
- revertPattern: /^(?:Revert|revert:)\s"?([\s\S]+?)"?\s*This reverts commit (\w*)\./i,
27
- revertCorrespondence: ["header", "hash"],
28
- issuePrefixes: config?.issuePrefixes || ["#"]
29
- };
30
- }
31
-
32
15
  // node_modules/@conventional-changelog/template/dist/elements.js
33
16
  function toString(value) {
34
17
  return typeof value === "number" || value ? String(value) : "";
@@ -77,6 +60,65 @@ function url(...parts) {
77
60
  }, "");
78
61
  }
79
62
 
63
+ // node_modules/@conventional-changelog/template/dist/references.js
64
+ var protectedSegments = [
65
+ /\[(?:[^[\]]|\[[^[\]]*])*]\((?:[^()\n]|\([^()\n]*\))*\)/,
66
+ // [text](url)
67
+ /\[[^\]]*]\[[^\]]*]/,
68
+ // [text][ref]
69
+ // the lookahead makes the delimiter length atomic, without it a long run
70
+ // of backticks makes the regex engine retry every possible delimiter length
71
+ /^[ \t]*(?=(?<fence>`{3,}|~{3,}))\k<fence>[\s\S]*?^[ \t]*\k<fence>[ \t]*\r?$/,
72
+ // ```code block```
73
+ /(?=(?<code>`+))\k<code>[^\n]*?\k<code>/,
74
+ // `code span`
75
+ /https?:\/\/(?:[^\s()]|\([^\s()]*\))+/
76
+ // https://url
77
+ ];
78
+ var userMention = /\B@(?<user>[a-z0-9](?:-?[a-z0-9/]){0,38})/;
79
+ var defaultIssuePattern = /[a-z0-9]+/;
80
+ function escapeRegExp(string) {
81
+ return string.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
82
+ }
83
+ function referencesRegex(issuePrefixes = [], issuePattern = defaultIssuePattern) {
84
+ const prefixes = issuePrefixes.map((prefix) => typeof prefix === "string" ? escapeRegExp(prefix) : prefix.source).join("|");
85
+ const patterns = [
86
+ ...protectedSegments.map((segment) => segment.source),
87
+ // without prefixes every word would be matched as an issue reference
88
+ prefixes && `(?<prefix>${prefixes})(?<issue>${issuePattern.source})`,
89
+ userMention.source
90
+ ];
91
+ return new RegExp(patterns.filter(Boolean).join("|"), "gm");
92
+ }
93
+ function createReferencesFormatter(options) {
94
+ const regex = referencesRegex(options.issuePrefixes, options.issuePattern);
95
+ return (text, context, references) => text.replace(regex, (match, ...args) => {
96
+ const { prefix, issue, user } = args.at(-1);
97
+ if (issue) {
98
+ const issueUrl = options.formatIssueUrl(context, {
99
+ prefix,
100
+ issue
101
+ });
102
+ if (!issueUrl) {
103
+ return match;
104
+ }
105
+ references?.push(match);
106
+ return link(match, issueUrl);
107
+ }
108
+ if (user) {
109
+ if (user.includes("/")) {
110
+ return match;
111
+ }
112
+ const userUrl = options.formatUserUrl(context, user);
113
+ if (!userUrl) {
114
+ return match;
115
+ }
116
+ return link(match, userUrl);
117
+ }
118
+ return match;
119
+ });
120
+ }
121
+
80
122
  // node_modules/@conventional-changelog/template/dist/templates.js
81
123
  function repositoryUrl(context) {
82
124
  if (context.repository) {
@@ -96,13 +138,23 @@ function referenceRepositoryUrl(context, reference2) {
96
138
  function compareUrl(context) {
97
139
  const previousTag = encodeURIComponent(context.previousTag || "");
98
140
  const currentTag = encodeURIComponent(context.currentTag || "");
99
- return url(repositoryUrl(context), "compare", `${previousTag}...${currentTag}`);
141
+ return url(repositoryUrl(context), context.compare || "compare", `${previousTag}...${currentTag}`);
142
+ }
143
+ var BREAKING_CHANGE_KEYWORDS = ["BREAKING CHANGE", "BREAKING-CHANGE"];
144
+ var BREAKING_CHANGES_TITLE = "BREAKING CHANGES";
145
+ function noteTitle(title) {
146
+ const upperCaseTitle = title.toUpperCase();
147
+ return BREAKING_CHANGE_KEYWORDS.includes(upperCaseTitle) ? BREAKING_CHANGES_TITLE : upperCaseTitle;
148
+ }
149
+ function isBreakingNote(note) {
150
+ return noteTitle(note.title) === BREAKING_CHANGES_TITLE;
100
151
  }
101
152
  function reference(reference2) {
102
153
  return strings(reference2.owner && `${reference2.owner}/`, reference2.repository, reference2.issue && `${reference2.prefix || "#"}${reference2.issue}`);
103
154
  }
104
155
 
105
156
  // node_modules/conventional-changelog-conventionalcommits/src/constants.js
157
+ var BREAKING_HEADER_PATTERN = /^(\w*)(?:\((.*)\))?!: (.*)$/;
106
158
  var DEFAULT_COMMIT_TYPES = Object.freeze([
107
159
  {
108
160
  type: "feat",
@@ -166,7 +218,36 @@ var DEFAULT_COMMIT_TYPES = Object.freeze([
166
218
  }
167
219
  ].map(Object.freeze));
168
220
 
221
+ // node_modules/conventional-changelog-conventionalcommits/src/parser.js
222
+ function createParserOpts(config) {
223
+ return {
224
+ headerPattern: /^(\w*)(?:\((.*)\))?!?: (.*)$/,
225
+ breakingHeaderPattern: BREAKING_HEADER_PATTERN,
226
+ headerCorrespondence: [
227
+ "type",
228
+ "scope",
229
+ "subject"
230
+ ],
231
+ noteKeywords: BREAKING_CHANGE_KEYWORDS,
232
+ revertPattern: /^(?:Revert|revert:)\s"?([\s\S]+?)"?\s*This reverts commit (\w*)\./i,
233
+ revertCorrespondence: ["header", "hash"],
234
+ issuePrefixes: config?.issuePrefixes || ["#"]
235
+ };
236
+ }
237
+
169
238
  // node_modules/conventional-changelog-conventionalcommits/src/utils.js
239
+ function getNotes(commit) {
240
+ if (commit.notes.some(isBreakingNote) || !BREAKING_HEADER_PATTERN.test(commit.header || "")) {
241
+ return commit.notes;
242
+ }
243
+ return [
244
+ {
245
+ title: BREAKING_CHANGE_KEYWORDS[0],
246
+ text: commit.subject || ""
247
+ },
248
+ ...commit.notes
249
+ ];
250
+ }
170
251
  function hasIntersection(a, b) {
171
252
  if (!a || !b) {
172
253
  return false;
@@ -295,7 +376,7 @@ function template(context) {
295
376
  each(
296
377
  noteGroups,
297
378
  (group) => segments(
298
- heading(3, words("\u26A0", group.title)),
379
+ heading(3, words(this.formatNoteIcon(context, group.title), group.title)),
299
380
  list(
300
381
  group.notes,
301
382
  (note) => words(
@@ -327,12 +408,20 @@ __export(format_exports, {
327
408
  formatCommitUrl: () => formatCommitUrl,
328
409
  formatCompareUrl: () => formatCompareUrl,
329
410
  formatIssueUrl: () => formatIssueUrl,
411
+ formatNoteIcon: () => formatNoteIcon,
412
+ formatNoteTitle: () => formatNoteTitle,
330
413
  formatUserUrl: () => formatUserUrl
331
414
  });
415
+ function formatNoteTitle(context, title) {
416
+ return noteTitle(title);
417
+ }
418
+ function formatNoteIcon(context, title) {
419
+ return title === BREAKING_CHANGES_TITLE ? "\u26A0" : "";
420
+ }
332
421
  function formatIssueUrl(context, reference2) {
333
422
  return url(
334
423
  referenceRepositoryUrl(context, reference2),
335
- "issues",
424
+ context.issue || "issues",
336
425
  reference2.issue
337
426
  );
338
427
  }
@@ -360,8 +449,9 @@ function createWriterOpts(config) {
360
449
  ...config
361
450
  };
362
451
  const commitGroupOrder = finalConfig.types.map((t) => t.section).filter(Boolean);
452
+ const formatReferences = createReferencesFormatter(finalConfig);
363
453
  return {
364
- template,
454
+ template: template.bind(finalConfig),
365
455
  headerPartial: headerPartial.bind(finalConfig),
366
456
  preamblePartial: preamblePartial.bind(finalConfig),
367
457
  commitPartial: commitPartial.bind(finalConfig),
@@ -373,15 +463,16 @@ function createWriterOpts(config) {
373
463
  if (commit.footer && releaseAsRegex.test(commit.footer) || commit.body && releaseAsRegex.test(commit.body)) {
374
464
  discard = false;
375
465
  }
376
- const notes = commit.notes.map((note) => {
466
+ const notes = getNotes(commit).map((note) => {
377
467
  discard = false;
378
468
  return {
379
469
  ...note,
380
- title: "BREAKING CHANGES"
470
+ title: finalConfig.formatNoteTitle(context, note.title),
471
+ text: formatReferences(note.text, context)
381
472
  };
382
473
  });
383
474
  if (
384
- // breaking changes attached to any type are still displayed.
475
+ // notes attached to any type are still displayed.
385
476
  discard && (entry === void 0 || isTypeEffect(entry, "hidden")) || !matchScope(finalConfig, commit)
386
477
  ) {
387
478
  return void 0;
@@ -391,26 +482,7 @@ function createWriterOpts(config) {
391
482
  const shortHash = typeof commit.hash === "string" ? commit.hash.substring(0, COMMIT_HASH_LENGTH) : commit.shortHash;
392
483
  let { subject } = commit;
393
484
  if (typeof subject === "string") {
394
- const issueRegEx = `(${finalConfig.issuePrefixes.join("|")})([a-z0-9]+)`;
395
- const re = new RegExp(issueRegEx, "g");
396
- subject = subject.replace(re, (_, prefix, issue) => {
397
- issues.push(prefix + issue);
398
- const issueUrl = finalConfig.formatIssueUrl(context, {
399
- issue,
400
- prefix
401
- });
402
- return link(`${prefix}${issue}`, issueUrl);
403
- });
404
- subject = subject.replace(/`[^`]*`|\B@([a-z0-9](?:-?[a-z0-9/]){0,38})/g, (match, user) => {
405
- if (!user) {
406
- return match;
407
- }
408
- if (user.includes("/")) {
409
- return `@${user}`;
410
- }
411
- const usernameUrl = finalConfig.formatUserUrl(context, user);
412
- return link(`@${user}`, usernameUrl);
413
- });
485
+ subject = formatReferences(subject, context, issues);
414
486
  }
415
487
  const references = commit.references.filter((reference2) => !issues.includes(reference2.prefix + reference2.issue));
416
488
  return {
@@ -448,8 +520,9 @@ function createWhatBump(config = {}) {
448
520
  return;
449
521
  }
450
522
  const entry = findTypeEntry(types, commit);
451
- if (commit.notes.length > 0) {
452
- breakings += commit.notes.length;
523
+ const breakingNotes = getNotes(commit).filter(isBreakingNote);
524
+ if (breakingNotes.length > 0) {
525
+ breakings += breakingNotes.length;
453
526
  level = 0;
454
527
  } else if (entry && isTypeEffect(entry, "bump")) {
455
528
  if (level === null) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@html-validate/commitlint-config",
3
- "version": "4.3.2",
3
+ "version": "4.3.3",
4
4
  "description": "Commitlint sharable config used by the various HTML-validate packages",
5
5
  "keywords": [
6
6
  "commitlint"