@w5s/conventional-changelog 1.0.11 → 1.0.13

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.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import type { CommitConventionalType } from './data';
1
+ import type { CommitConventionalType } from './data.js';
2
2
  export type Emoji = Emoji.Unicode | Emoji.Text;
3
3
  export declare namespace Emoji {
4
4
  const reEmojiUnicode: RegExp;
package/lib/index.d.ts CHANGED
@@ -1,9 +1,9 @@
1
1
  declare const _default: {
2
- parserOpts: import("./parser-opts").ParserOptions;
3
- writerOpts: import("./writer-opts").WriterOptions;
2
+ parserOpts: import("./parser-opts.js").ParserOptions;
3
+ writerOpts: import("./writer-opts.js").WriterOptions;
4
4
  recommendedBumpOpts: {
5
- parserOpts: import("./parser-opts").ParserOptions;
6
- whatBump: (commits: readonly import("./recommended-bump-opts").Commit[]) => {
5
+ parserOpts: import("./parser-opts.js").ParserOptions;
6
+ whatBump: (commits: readonly import("./recommended-bump-opts.js").Commit[]) => {
7
7
  level: number;
8
8
  reason: string;
9
9
  };
package/lib/index.js CHANGED
@@ -1,12 +1,12 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const git_raw_commit_opts_1 = require("./git-raw-commit-opts");
4
- const parser_opts_1 = require("./parser-opts");
5
- const recommended_bump_opts_1 = require("./recommended-bump-opts");
6
- const writer_opts_1 = require("./writer-opts");
4
+ const parser_opts_js_1 = require("./parser-opts.js");
5
+ const recommended_bump_opts_js_1 = require("./recommended-bump-opts.js");
6
+ const writer_opts_js_1 = require("./writer-opts.js");
7
7
  exports.default = {
8
- parserOpts: parser_opts_1.parserOpts,
9
- writerOpts: writer_opts_1.writerOpts,
10
- recommendedBumpOpts: recommended_bump_opts_1.recommendedBumpOpts,
8
+ parserOpts: parser_opts_js_1.parserOpts,
9
+ writerOpts: writer_opts_js_1.writerOpts,
10
+ recommendedBumpOpts: recommended_bump_opts_js_1.recommendedBumpOpts,
11
11
  gitRawCommitOpts: git_raw_commit_opts_1.gitRawCommitOpts,
12
12
  };
@@ -1,7 +1,7 @@
1
1
  import type { Commit as CommitBase } from 'conventional-commits-parser';
2
2
  export type Commit = CommitBase;
3
3
  export declare const recommendedBumpOpts: {
4
- parserOpts: import("./parser-opts").ParserOptions;
4
+ parserOpts: import("./parser-opts.js").ParserOptions;
5
5
  whatBump: (commits: ReadonlyArray<Commit>) => {
6
6
  level: number;
7
7
  reason: string;
@@ -1,19 +1,29 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.recommendedBumpOpts = void 0;
4
- const parser_opts_1 = require("./parser-opts");
4
+ const parser_opts_js_1 = require("./parser-opts.js");
5
+ const data_js_1 = require("./data.js");
6
+ const gitmoji_js_1 = require("./gitmoji.js");
7
+ function toConventionalCommitType(text) {
8
+ return gitmoji_js_1.GitmojiCode.isValid(text)
9
+ ? gitmoji_js_1.GitmojiCode.toConventionalCommitType(text)
10
+ : data_js_1.CommitConventionalType.hasInstance(text)
11
+ ? text
12
+ : undefined;
13
+ }
5
14
  exports.recommendedBumpOpts = {
6
- parserOpts: parser_opts_1.parserOpts,
15
+ parserOpts: parser_opts_js_1.parserOpts,
7
16
  whatBump: (commits) => {
8
17
  let level = 2;
9
18
  let breakings = 0;
10
19
  let features = 0;
11
- for (const commit of commits) {
12
- if (commit.notes.length > 0) {
13
- breakings += commit.notes.length;
20
+ for (const { type, notes } of commits) {
21
+ const conventionalType = type == null ? type : toConventionalCommitType(type);
22
+ if (notes.length > 0) {
23
+ breakings += notes.length;
14
24
  level = 0;
15
25
  }
16
- else if (commit.type === 'feat') {
26
+ else if (conventionalType === data_js_1.CommitConventionalType.Feat) {
17
27
  features += 1;
18
28
  if (level === 2) {
19
29
  level = 1;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@w5s/conventional-changelog",
3
- "version": "1.0.11",
3
+ "version": "1.0.13",
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",
@@ -52,10 +52,10 @@
52
52
  "gitmojis": "^3.13.4"
53
53
  },
54
54
  "devDependencies": {
55
- "@types/conventional-changelog-writer": "4.0.2",
55
+ "@types/conventional-changelog-writer": "4.0.3",
56
56
  "@types/conventional-commits-parser": "3.0.3",
57
- "vite": "4.3.5",
58
- "vitest": "0.31.0"
57
+ "vite": "4.3.9",
58
+ "vitest": "0.31.2"
59
59
  },
60
60
  "engines": {
61
61
  "node": ">=16.0.0"
@@ -63,5 +63,5 @@
63
63
  "publishConfig": {
64
64
  "access": "public"
65
65
  },
66
- "gitHead": "128fbd2cdc468360ea0c0834401ea99780e5c622"
66
+ "gitHead": "7e5cf7f6b4725b79da890724f6377c2893e6daf4"
67
67
  }
package/src/gitmoji.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import emojiRegexp from 'emoji-regex';
2
2
  import { type Gitmoji, gitmojis } from 'gitmojis';
3
- import type { CommitConventionalType } from './data';
3
+ import type { CommitConventionalType } from './data.js';
4
4
 
5
5
  export type Emoji = Emoji.Unicode | Emoji.Text;
6
6
  export namespace Emoji {
package/src/index.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  import { gitRawCommitOpts } from './git-raw-commit-opts';
2
- import { parserOpts } from './parser-opts';
3
- import { recommendedBumpOpts } from './recommended-bump-opts';
4
- import { writerOpts } from './writer-opts';
2
+ import { parserOpts } from './parser-opts.js';
3
+ import { recommendedBumpOpts } from './recommended-bump-opts.js';
4
+ import { writerOpts } from './writer-opts.js';
5
5
 
6
6
  export default {
7
7
  parserOpts,
@@ -1,5 +1,15 @@
1
1
  import type { Commit as CommitBase } from 'conventional-commits-parser';
2
- import { parserOpts } from './parser-opts';
2
+ import { parserOpts } from './parser-opts.js';
3
+ import { CommitConventionalType } from './data.js';
4
+ import { GitmojiCode } from './gitmoji.js';
5
+
6
+ function toConventionalCommitType(text: string) {
7
+ return GitmojiCode.isValid(text)
8
+ ? GitmojiCode.toConventionalCommitType(text)
9
+ : CommitConventionalType.hasInstance(text)
10
+ ? text
11
+ : undefined;
12
+ }
3
13
 
4
14
  export type Commit = CommitBase;
5
15
 
@@ -10,11 +20,12 @@ export const recommendedBumpOpts = {
10
20
  let breakings = 0;
11
21
  let features = 0;
12
22
 
13
- for (const commit of commits) {
14
- if (commit.notes.length > 0) {
15
- breakings += commit.notes.length;
23
+ for (const { type, notes } of commits) {
24
+ const conventionalType = type == null ? type : toConventionalCommitType(type);
25
+ if (notes.length > 0) {
26
+ breakings += notes.length;
16
27
  level = 0;
17
- } else if (commit.type === 'feat') {
28
+ } else if (conventionalType === CommitConventionalType.Feat) {
18
29
  features += 1;
19
30
  if (level === 2) {
20
31
  level = 1;