@w5s/conventional-changelog 1.0.9 → 1.0.11

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/lib/gitmoji.js CHANGED
@@ -9,16 +9,16 @@ const gitmojis_1 = require("gitmojis");
9
9
  var Emoji;
10
10
  (function (Emoji) {
11
11
  Emoji.reEmojiUnicode = (0, emoji_regex_1.default)();
12
- Emoji.reEmojiText = /:(\w+):/;
13
- const reMatchOnly = (input) => new RegExp(`^${input.source}$`, input.flags);
12
+ Emoji.reEmojiText = /:\w*:/;
13
+ const reMatchOnly = (input) => new RegExp(`^${input.source}$`, '');
14
14
  const _reEmojiUnicode = reMatchOnly(Emoji.reEmojiUnicode);
15
15
  const _reEmojiText = reMatchOnly(Emoji.reEmojiText);
16
16
  function isUnicode(anyValue) {
17
- return anyValue.match(_reEmojiUnicode) != null;
17
+ return _reEmojiUnicode.test(anyValue);
18
18
  }
19
19
  Emoji.isUnicode = isUnicode;
20
20
  function isText(anyValue) {
21
- return anyValue.match(_reEmojiText) != null;
21
+ return _reEmojiText.test(anyValue);
22
22
  }
23
23
  Emoji.isText = isText;
24
24
  function hasInstance(anyValue) {
@@ -1,9 +1,14 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.parserOpts = void 0;
4
- const gitmoji_1 = require("./gitmoji");
5
4
  exports.parserOpts = {
6
- headerPattern: new RegExp(`^(:\\w*:|${gitmoji_1.Emoji.reEmojiUnicode.source}) (?:\\((.*)\\):? )?(.*)$`),
5
+ headerPattern: new RegExp(
6
+ // Type
7
+ `^(?<type>\\S*)? ` +
8
+ // Scope
9
+ `(?:\\((?<scope>.*)\\):? )?` +
10
+ // Subject
11
+ `(?<subject>.*)$`, 'u'),
7
12
  headerCorrespondence: ['type', 'scope', 'subject'],
8
13
  revertPattern: /^(?:revert|revert:)\s"?([\S\s]+?)"?\s*this reverts commit (\w*)\./i,
9
14
  noteKeywords: ['BREAKING CHANGE', 'BREAKING CHANGES'],
package/lib/transform.js CHANGED
@@ -54,6 +54,7 @@ function createTransform(config) {
54
54
  if (url != null) {
55
55
  const issueURL = `${url}/issues/`;
56
56
  // Issue URLs.
57
+ // eslint-disable-next-line unicorn/prefer-string-replace-all
57
58
  returnValue = returnValue.replace(/#(\d+)/g, (_, issue) => {
58
59
  issues.add(issue);
59
60
  return `[#${issue}](${issueURL}${issue})`;
@@ -61,7 +62,7 @@ function createTransform(config) {
61
62
  }
62
63
  if (host != null) {
63
64
  // User URLs.
64
- // eslint-disable-next-line unicorn/no-unsafe-regex
65
+ // eslint-disable-next-line unicorn/no-unsafe-regex, unicorn/prefer-string-replace-all
65
66
  returnValue = returnValue.replace(/\B@([\da-z](?:-?[\d/a-z]){0,38})/g, (_, username) => username.includes('/') ? `@${username}` : `[@${username}](${host}/${username})`);
66
67
  }
67
68
  return returnValue;
@@ -22,6 +22,7 @@ exports.writerOpts = {
22
22
  noteGroupsSort: 'title',
23
23
  mainTemplate: template,
24
24
  headerPartial: header,
25
+ // eslint-disable-next-line unicorn/prefer-string-replace-all
25
26
  commitPartial: commit.replace(/{{gitUserInfo}}/g, author),
26
27
  footerPartial: footer,
27
28
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@w5s/conventional-changelog",
3
- "version": "1.0.9",
3
+ "version": "1.0.11",
4
4
  "description": "Conventional changelog plugin for @w5s",
5
5
  "keywords": [],
6
6
  "homepage": "https://github.com/w5s/project-config/blob/main/packages/conventional-changelog#readme",
@@ -63,5 +63,5 @@
63
63
  "publishConfig": {
64
64
  "access": "public"
65
65
  },
66
- "gitHead": "9f31748b4b649e8fdcd479141b0d65321d9d4556"
66
+ "gitHead": "128fbd2cdc468360ea0c0834401ea99780e5c622"
67
67
  }
package/src/gitmoji.ts CHANGED
@@ -6,9 +6,9 @@ export type Emoji = Emoji.Unicode | Emoji.Text;
6
6
  export namespace Emoji {
7
7
  export const reEmojiUnicode = emojiRegexp();
8
8
 
9
- export const reEmojiText = /:(\w+):/;
9
+ export const reEmojiText = /:\w*:/;
10
10
 
11
- const reMatchOnly = (input: RegExp) => new RegExp(`^${input.source}$`, input.flags);
11
+ const reMatchOnly = (input: RegExp) => new RegExp(`^${input.source}$`, '');
12
12
  const _reEmojiUnicode = reMatchOnly(reEmojiUnicode);
13
13
  const _reEmojiText = reMatchOnly(reEmojiText);
14
14
 
@@ -16,11 +16,11 @@ export namespace Emoji {
16
16
  export type Text = string & { '@@EmojiStyle': 'text' };
17
17
 
18
18
  export function isUnicode(anyValue: string): anyValue is Unicode {
19
- return anyValue.match(_reEmojiUnicode) != null;
19
+ return _reEmojiUnicode.test(anyValue);
20
20
  }
21
21
 
22
22
  export function isText(anyValue: string): anyValue is Text {
23
- return anyValue.match(_reEmojiText) != null;
23
+ return _reEmojiText.test(anyValue);
24
24
  }
25
25
 
26
26
  export function hasInstance(anyValue: string): anyValue is Emoji {
@@ -1,10 +1,17 @@
1
1
  import type { Options } from 'conventional-commits-parser';
2
- import { Emoji } from './gitmoji';
3
2
 
4
3
  export interface ParserOptions extends Options {}
5
4
 
6
5
  export const parserOpts: ParserOptions = {
7
- headerPattern: new RegExp(`^(:\\w*:|${Emoji.reEmojiUnicode.source}) (?:\\((.*)\\):? )?(.*)$`),
6
+ headerPattern: new RegExp(
7
+ // Type
8
+ `^(?<type>\\S*)? ` +
9
+ // Scope
10
+ `(?:\\((?<scope>.*)\\):? )?` +
11
+ // Subject
12
+ `(?<subject>.*)$`,
13
+ 'u'
14
+ ),
8
15
  headerCorrespondence: ['type', 'scope', 'subject'],
9
16
  revertPattern: /^(?:revert|revert:)\s"?([\S\s]+?)"?\s*this reverts commit (\w*)\./i,
10
17
  noteKeywords: ['BREAKING CHANGE', 'BREAKING CHANGES'],
package/src/transform.ts CHANGED
@@ -81,6 +81,7 @@ export function createTransform(config: TransformConfig): WriterOptions.Transfor
81
81
  if (url != null) {
82
82
  const issueURL = `${url}/issues/`;
83
83
  // Issue URLs.
84
+ // eslint-disable-next-line unicorn/prefer-string-replace-all
84
85
  returnValue = returnValue.replace(/#(\d+)/g, (_, issue: string) => {
85
86
  issues.add(issue);
86
87
 
@@ -89,7 +90,7 @@ export function createTransform(config: TransformConfig): WriterOptions.Transfor
89
90
  }
90
91
  if (host != null) {
91
92
  // User URLs.
92
- // eslint-disable-next-line unicorn/no-unsafe-regex
93
+ // eslint-disable-next-line unicorn/no-unsafe-regex, unicorn/prefer-string-replace-all
93
94
  returnValue = returnValue.replace(/\B@([\da-z](?:-?[\d/a-z]){0,38})/g, (_, username: string) =>
94
95
  username.includes('/') ? `@${username}` : `[@${username}](${host}/${username})`
95
96
  );
@@ -26,6 +26,7 @@ export const writerOpts: WriterOptions = {
26
26
  noteGroupsSort: 'title',
27
27
  mainTemplate: template,
28
28
  headerPartial: header,
29
+ // eslint-disable-next-line unicorn/prefer-string-replace-all
29
30
  commitPartial: commit.replace(/{{gitUserInfo}}/g, author),
30
31
  footerPartial: footer,
31
32
  };