@w5s/conventional-changelog 3.2.6 → 3.2.8
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/dist/index.d.ts +66 -66
- package/dist/index.js +139 -139
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
- package/src/createPreset.ts +1 -1
- package/src/data.ts +40 -40
- package/src/gitmoji.ts +15 -15
- package/src/index.ts +2 -2
- package/src/meta.ts +2 -2
- package/src/parser.ts +8 -8
- package/src/transform.ts +28 -27
- package/src/whatBump.ts +2 -2
- package/src/writer.ts +20 -19
package/dist/index.d.ts
CHANGED
|
@@ -1,53 +1,56 @@
|
|
|
1
|
-
//#region src/
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
1
|
+
//#region src/parser.d.ts
|
|
2
|
+
interface ParserOptions {
|
|
3
|
+
headerCorrespondence?: null | string | string[];
|
|
4
|
+
headerPattern?: null | RegExp | string;
|
|
5
|
+
noteKeywords?: null | string | string[];
|
|
6
|
+
revertCorrespondence?: null | string | string[];
|
|
7
|
+
revertPattern?: null | RegExp | string;
|
|
8
|
+
}
|
|
7
9
|
//#endregion
|
|
8
10
|
//#region src/data.d.ts
|
|
9
11
|
interface Commit {
|
|
10
|
-
merge: Commit.Field;
|
|
11
|
-
header: Commit.Field;
|
|
12
12
|
body: Commit.Field;
|
|
13
13
|
footer: Commit.Field;
|
|
14
|
+
hash: null | string;
|
|
15
|
+
header: Commit.Field;
|
|
16
|
+
mentions: string[];
|
|
17
|
+
merge: Commit.Field;
|
|
14
18
|
notes: Commit.Note[];
|
|
15
19
|
references: Commit.Reference[];
|
|
16
|
-
mentions: string[];
|
|
17
20
|
revert: Commit.Revert | null;
|
|
18
|
-
|
|
19
|
-
subject:
|
|
20
|
-
|
|
21
|
-
hash: string | null;
|
|
21
|
+
scope: null | string;
|
|
22
|
+
subject: null | string;
|
|
23
|
+
type: null | string;
|
|
22
24
|
}
|
|
23
25
|
declare namespace Commit {
|
|
24
|
-
type Field =
|
|
26
|
+
type Field = null | string;
|
|
25
27
|
interface Note {
|
|
26
|
-
title: string;
|
|
27
28
|
text: string;
|
|
29
|
+
title: string;
|
|
28
30
|
}
|
|
29
31
|
interface Reference {
|
|
30
|
-
issue: string;
|
|
31
32
|
action: Field;
|
|
33
|
+
issue: string;
|
|
32
34
|
owner: Field;
|
|
33
|
-
repository: Field;
|
|
34
35
|
prefix: string;
|
|
35
36
|
raw: string;
|
|
37
|
+
repository: Field;
|
|
36
38
|
}
|
|
37
39
|
interface Revert {
|
|
40
|
+
[field: string]: Field | undefined;
|
|
38
41
|
hash?: Field | undefined;
|
|
39
42
|
header?: Field | undefined;
|
|
40
|
-
[field: string]: Field | undefined;
|
|
41
43
|
}
|
|
42
44
|
}
|
|
43
|
-
type CommitConventionalType = 'build' | 'ci' | 'docs' | 'feat' | 'fix' | 'perf' | 'refactor' | 'revert' | 'style' | 'test' | 'wip'
|
|
45
|
+
type CommitConventionalType = 'build' | 'chore' | 'ci' | 'docs' | 'feat' | 'fix' | 'perf' | 'refactor' | 'revert' | 'style' | 'test' | 'wip';
|
|
44
46
|
declare const CommitConventionalType: {
|
|
45
|
-
|
|
47
|
+
findWhere: (predicate: (data: CommitConventionalTypeData) => boolean) => CommitConventionalType[];
|
|
46
48
|
getData: (commitType: CommitConventionalType) => CommitConventionalTypeData;
|
|
47
|
-
|
|
49
|
+
hasInstance: (anyValue: unknown) => anyValue is CommitConventionalType;
|
|
48
50
|
parse: (anyValue: string) => CommitConventionalType | undefined;
|
|
49
|
-
|
|
51
|
+
values: () => readonly CommitConventionalType[];
|
|
50
52
|
Build: "build";
|
|
53
|
+
Chore: "chore";
|
|
51
54
|
CI: "ci";
|
|
52
55
|
Docs: "docs";
|
|
53
56
|
Feat: "feat";
|
|
@@ -58,27 +61,50 @@ declare const CommitConventionalType: {
|
|
|
58
61
|
Style: "style";
|
|
59
62
|
Test: "test";
|
|
60
63
|
WIP: "wip";
|
|
61
|
-
Chore: "chore";
|
|
62
64
|
};
|
|
63
65
|
interface CommitConventionalTypeData {
|
|
66
|
+
'changelog': boolean;
|
|
64
67
|
'emoji': string;
|
|
65
68
|
'en-US': string;
|
|
66
|
-
|
|
69
|
+
}
|
|
70
|
+
//#endregion
|
|
71
|
+
//#region src/transform.d.ts
|
|
72
|
+
interface CommitTransformFunction<TCommit extends Commit = Commit> {
|
|
73
|
+
(commit: Commit, context: WriterContext, ...args: unknown[]): false | TCommit;
|
|
74
|
+
}
|
|
75
|
+
interface WriterContext {
|
|
76
|
+
host?: string | undefined;
|
|
77
|
+
owner?: string | undefined;
|
|
78
|
+
repository?: string | undefined;
|
|
79
|
+
repoUrl?: string | undefined;
|
|
80
|
+
}
|
|
81
|
+
//#endregion
|
|
82
|
+
//#region src/writer.d.ts
|
|
83
|
+
interface WriterOptions {
|
|
84
|
+
commitGroupsSort?: false | readonly string[] | string | undefined;
|
|
85
|
+
commitPartial?: string | undefined;
|
|
86
|
+
commitsSort?: false | readonly string[] | string | undefined;
|
|
87
|
+
footerPartial?: string | undefined;
|
|
88
|
+
groupBy?: false | string | undefined;
|
|
89
|
+
headerPartial?: string | undefined;
|
|
90
|
+
mainTemplate?: string | undefined;
|
|
91
|
+
noteGroupsSort?: false | readonly string[] | string | undefined;
|
|
92
|
+
transform?: CommitTransformFunction<Commit> | undefined;
|
|
67
93
|
}
|
|
68
94
|
//#endregion
|
|
69
95
|
//#region src/gitmoji.d.ts
|
|
70
|
-
type Emoji = Emoji.
|
|
96
|
+
type Emoji = Emoji.Text | Emoji.Unicode;
|
|
71
97
|
declare namespace Emoji {
|
|
72
|
-
type Unicode = string & {
|
|
73
|
-
'@@EmojiStyle': 'unicode';
|
|
74
|
-
};
|
|
75
98
|
type Text = string & {
|
|
76
99
|
'@@EmojiStyle': 'text';
|
|
77
100
|
};
|
|
101
|
+
type Unicode = string & {
|
|
102
|
+
'@@EmojiStyle': 'unicode';
|
|
103
|
+
};
|
|
78
104
|
}
|
|
79
|
-
declare function isUnicode(anyValue: string): anyValue is Emoji.Unicode;
|
|
80
|
-
declare function isText(anyValue: string): anyValue is Emoji.Text;
|
|
81
105
|
declare function hasInstance(anyValue: string): anyValue is Emoji;
|
|
106
|
+
declare function isText(anyValue: string): anyValue is Emoji.Text;
|
|
107
|
+
declare function isUnicode(anyValue: string): anyValue is Emoji.Unicode;
|
|
82
108
|
/**
|
|
83
109
|
* @namespace
|
|
84
110
|
*/
|
|
@@ -93,10 +119,10 @@ type GitmojiCode = Emoji & {
|
|
|
93
119
|
'@@Gitmoji': true;
|
|
94
120
|
};
|
|
95
121
|
declare namespace GitmojiCode {
|
|
96
|
-
type
|
|
122
|
+
type Emoji = Emoji.Text & {
|
|
97
123
|
'@@Gitmoji': true;
|
|
98
124
|
};
|
|
99
|
-
type
|
|
125
|
+
type Unicode = Emoji.Unicode & {
|
|
100
126
|
'@@Gitmoji': true;
|
|
101
127
|
};
|
|
102
128
|
}
|
|
@@ -110,50 +136,24 @@ declare const GitmojiCode: Readonly<{
|
|
|
110
136
|
toConventionalCommitType: typeof toConventionalCommitType;
|
|
111
137
|
}>;
|
|
112
138
|
//#endregion
|
|
113
|
-
//#region src/parser.d.ts
|
|
114
|
-
interface ParserOptions {
|
|
115
|
-
headerPattern?: RegExp | string | null;
|
|
116
|
-
headerCorrespondence?: string[] | string | null;
|
|
117
|
-
revertPattern?: RegExp | string | null;
|
|
118
|
-
revertCorrespondence?: string[] | string | null;
|
|
119
|
-
noteKeywords?: string[] | string | null;
|
|
120
|
-
}
|
|
121
|
-
//#endregion
|
|
122
|
-
//#region src/transform.d.ts
|
|
123
|
-
interface WriterContext {
|
|
124
|
-
repository?: string | undefined;
|
|
125
|
-
host?: string | undefined;
|
|
126
|
-
owner?: string | undefined;
|
|
127
|
-
repoUrl?: string | undefined;
|
|
128
|
-
}
|
|
129
|
-
interface CommitTransformFunction<TCommit extends Commit = Commit> {
|
|
130
|
-
(commit: Commit, context: WriterContext, ...args: unknown[]): TCommit | false;
|
|
131
|
-
}
|
|
132
|
-
//#endregion
|
|
133
|
-
//#region src/writer.d.ts
|
|
134
|
-
interface WriterOptions {
|
|
135
|
-
transform?: CommitTransformFunction<Commit> | undefined;
|
|
136
|
-
groupBy?: string | false | undefined;
|
|
137
|
-
commitGroupsSort?: string | readonly string[] | false | undefined;
|
|
138
|
-
commitsSort?: string | readonly string[] | false | undefined;
|
|
139
|
-
noteGroupsSort?: string | readonly string[] | false | undefined;
|
|
140
|
-
mainTemplate?: string | undefined;
|
|
141
|
-
headerPartial?: string | undefined;
|
|
142
|
-
commitPartial?: string | undefined;
|
|
143
|
-
footerPartial?: string | undefined;
|
|
144
|
-
}
|
|
145
|
-
//#endregion
|
|
146
139
|
//#region src/createPreset.d.ts
|
|
147
140
|
declare function createPreset(): Promise<{
|
|
148
141
|
gitRawCommitOpts: {
|
|
149
142
|
format: string;
|
|
150
143
|
};
|
|
151
144
|
parser: ParserOptions;
|
|
152
|
-
writer: WriterOptions;
|
|
153
145
|
whatBump: (commits: ReadonlyArray<Commit>) => {
|
|
154
146
|
level: number;
|
|
155
147
|
reason: string;
|
|
156
148
|
};
|
|
149
|
+
writer: WriterOptions;
|
|
150
|
+
}>;
|
|
151
|
+
//#endregion
|
|
152
|
+
//#region src/meta.d.ts
|
|
153
|
+
declare const meta: Readonly<{
|
|
154
|
+
buildNumber: number;
|
|
155
|
+
name: string;
|
|
156
|
+
version: string;
|
|
157
157
|
}>;
|
|
158
158
|
//#endregion
|
|
159
159
|
export { Emoji, GitmojiCode, createPreset as default, meta };
|
package/dist/index.js
CHANGED
|
@@ -3,99 +3,27 @@ import { gitmojis } from "gitmojis";
|
|
|
3
3
|
import { readFileSync } from "node:fs";
|
|
4
4
|
import nodePath from "node:path";
|
|
5
5
|
import { fileURLToPath } from "node:url";
|
|
6
|
-
//#region src/meta.ts
|
|
7
|
-
const meta = Object.freeze({
|
|
8
|
-
name: "@w5s/conventional-changelog",
|
|
9
|
-
version: "3.2.6",
|
|
10
|
-
buildNumber: 1
|
|
11
|
-
});
|
|
12
|
-
//#endregion
|
|
13
|
-
//#region src/gitmoji.ts
|
|
14
|
-
const reEmojiUnicode = emojiRegexp();
|
|
15
|
-
const reEmojiText = /:\w*:/;
|
|
16
|
-
const reMatchOnly = (input) => new RegExp(`^${input.source}$`, "");
|
|
17
|
-
const _reEmojiUnicode = reMatchOnly(reEmojiUnicode);
|
|
18
|
-
const _reEmojiText = reMatchOnly(reEmojiText);
|
|
19
|
-
function isUnicode(anyValue) {
|
|
20
|
-
return _reEmojiUnicode.test(anyValue);
|
|
21
|
-
}
|
|
22
|
-
function isText(anyValue) {
|
|
23
|
-
return _reEmojiText.test(anyValue);
|
|
24
|
-
}
|
|
25
|
-
function hasInstance(anyValue) {
|
|
26
|
-
return isText(anyValue) || isUnicode(anyValue);
|
|
27
|
-
}
|
|
28
|
-
/**
|
|
29
|
-
* @namespace
|
|
30
|
-
*/
|
|
31
|
-
const Emoji = Object.freeze({
|
|
32
|
-
hasInstance,
|
|
33
|
-
isText,
|
|
34
|
-
isUnicode,
|
|
35
|
-
reEmojiText,
|
|
36
|
-
reEmojiUnicode
|
|
37
|
-
});
|
|
38
|
-
const allGitmojiCodes = new Set(gitmojis.map((gitmoji) => gitmoji.code).concat(gitmojis.map((gitmoji) => gitmoji.emoji)));
|
|
39
|
-
const index = { emoji: createIndex(gitmojis, "emoji") };
|
|
40
|
-
function createIndex(list, key) {
|
|
41
|
-
return new Map(list.map((gitmoji) => [gitmoji[key], gitmoji]));
|
|
42
|
-
}
|
|
43
|
-
function isValid(anyValue) {
|
|
44
|
-
return allGitmojiCodes.has(anyValue);
|
|
45
|
-
}
|
|
46
|
-
const defaultType = "chore";
|
|
47
|
-
const conversionMap = (() => {
|
|
48
|
-
const entries = Array.from(Object.entries({
|
|
49
|
-
feat: [
|
|
50
|
-
"✨",
|
|
51
|
-
"♿️",
|
|
52
|
-
"🚸"
|
|
53
|
-
],
|
|
54
|
-
fix: ["🐛"],
|
|
55
|
-
docs: ["📝"],
|
|
56
|
-
style: ["🎨", "🚨"],
|
|
57
|
-
refactor: ["♻️", "🏗️"],
|
|
58
|
-
test: ["✅", "🧪"],
|
|
59
|
-
perf: ["⚡️"],
|
|
60
|
-
revert: ["⏪️"],
|
|
61
|
-
ci: ["👷", "💚"],
|
|
62
|
-
wip: ["🚧"],
|
|
63
|
-
build: [],
|
|
64
|
-
chore: ["🔧"]
|
|
65
|
-
}));
|
|
66
|
-
return new Map(entries.reduce((acc, [commitType, gitmojiUnicodeArray]) => acc.concat(gitmojiUnicodeArray.map((gitmojiUnicode) => [gitmojiUnicode, commitType])).concat(gitmojiUnicodeArray.map((gitmojiUnicode) => [index.emoji.get(gitmojiUnicode)?.code, commitType])), []));
|
|
67
|
-
})();
|
|
68
|
-
function toConventionalCommitType$1(gitmoji) {
|
|
69
|
-
return conversionMap.get(gitmoji) ?? defaultType;
|
|
70
|
-
}
|
|
71
|
-
/**
|
|
72
|
-
* @namespace
|
|
73
|
-
*/
|
|
74
|
-
const GitmojiCode = Object.freeze({
|
|
75
|
-
isValid,
|
|
76
|
-
toConventionalCommitType: toConventionalCommitType$1
|
|
77
|
-
});
|
|
78
|
-
//#endregion
|
|
79
6
|
//#region src/git-raw-commit-opts.ts
|
|
80
7
|
const gitRawCommitOpts = { format: "%B%n-hash-%n%H%n-gitTags-%n%d%n-committerDate-%n%ci%n-authorName-%n%an%n-authorEmail-%n%ae" };
|
|
81
8
|
//#endregion
|
|
82
9
|
//#region src/parser.ts
|
|
83
10
|
const createParserOpts = () => ({
|
|
84
|
-
headerPattern: /* @__PURE__ */ new RegExp("^(?<type>\\S*)? (?:\\((?<scope>.*)\\):? )?(?<subject>.*)$", "u"),
|
|
85
11
|
headerCorrespondence: [
|
|
86
12
|
"type",
|
|
87
13
|
"scope",
|
|
88
14
|
"subject"
|
|
89
15
|
],
|
|
90
|
-
|
|
16
|
+
headerPattern: /* @__PURE__ */ new RegExp("^(?<type>\\S*)? (?:\\((?<scope>.*)\\):? )?(?<subject>.*)$", "u"),
|
|
91
17
|
noteKeywords: ["BREAKING CHANGE", "BREAKING CHANGES"],
|
|
92
|
-
revertCorrespondence: [`header`, `hash`]
|
|
18
|
+
revertCorrespondence: [`header`, `hash`],
|
|
19
|
+
revertPattern: /^(?:revert|revert:)\s"?([\S\s]+?)"?\s*this reverts commit (\w*)\./i
|
|
93
20
|
});
|
|
94
21
|
//#endregion
|
|
95
22
|
//#region src/data.ts
|
|
96
23
|
const CommitConventionalType = (() => {
|
|
97
24
|
const enumObject = Object.freeze({
|
|
98
25
|
Build: "build",
|
|
26
|
+
Chore: "chore",
|
|
99
27
|
CI: "ci",
|
|
100
28
|
Docs: "docs",
|
|
101
29
|
Feat: "feat",
|
|
@@ -105,71 +33,70 @@ const CommitConventionalType = (() => {
|
|
|
105
33
|
Revert: "revert",
|
|
106
34
|
Style: "style",
|
|
107
35
|
Test: "test",
|
|
108
|
-
WIP: "wip"
|
|
109
|
-
Chore: "chore"
|
|
36
|
+
WIP: "wip"
|
|
110
37
|
});
|
|
111
|
-
const enumValues = Object.freeze(Object.values(enumObject).sort());
|
|
38
|
+
const enumValues = Object.freeze(Object.values(enumObject).sort((left, right) => left.localeCompare(right)));
|
|
112
39
|
const enumValuesSet = new Set(enumValues);
|
|
113
40
|
const typeData = {
|
|
114
|
-
feat: {
|
|
115
|
-
"emoji": "✨",
|
|
116
|
-
"en-US": "Features",
|
|
117
|
-
"changelog": true
|
|
118
|
-
},
|
|
119
|
-
fix: {
|
|
120
|
-
"emoji": "🐛",
|
|
121
|
-
"en-US": "Bug Fixes",
|
|
122
|
-
"changelog": true
|
|
123
|
-
},
|
|
124
41
|
build: {
|
|
42
|
+
"changelog": false,
|
|
125
43
|
"emoji": "👷",
|
|
126
|
-
"en-US": "Build System"
|
|
127
|
-
"changelog": false
|
|
44
|
+
"en-US": "Build System"
|
|
128
45
|
},
|
|
129
46
|
chore: {
|
|
47
|
+
"changelog": false,
|
|
130
48
|
"emoji": "🎫",
|
|
131
|
-
"en-US": "Chores"
|
|
132
|
-
"changelog": false
|
|
49
|
+
"en-US": "Chores"
|
|
133
50
|
},
|
|
134
51
|
ci: {
|
|
52
|
+
"changelog": false,
|
|
135
53
|
"emoji": "🔧",
|
|
136
|
-
"en-US": "Continuous Integration"
|
|
137
|
-
"changelog": false
|
|
54
|
+
"en-US": "Continuous Integration"
|
|
138
55
|
},
|
|
139
56
|
docs: {
|
|
57
|
+
"changelog": false,
|
|
140
58
|
"emoji": "📝",
|
|
141
|
-
"en-US": "Documentation"
|
|
142
|
-
"changelog": false
|
|
59
|
+
"en-US": "Documentation"
|
|
143
60
|
},
|
|
144
|
-
|
|
145
|
-
"
|
|
146
|
-
"
|
|
147
|
-
"
|
|
61
|
+
feat: {
|
|
62
|
+
"changelog": true,
|
|
63
|
+
"emoji": "✨",
|
|
64
|
+
"en-US": "Features"
|
|
65
|
+
},
|
|
66
|
+
fix: {
|
|
67
|
+
"changelog": true,
|
|
68
|
+
"emoji": "🐛",
|
|
69
|
+
"en-US": "Bug Fixes"
|
|
148
70
|
},
|
|
149
71
|
perf: {
|
|
72
|
+
"changelog": true,
|
|
150
73
|
"emoji": "⚡",
|
|
151
|
-
"en-US": "Performance Improvements"
|
|
152
|
-
"changelog": true
|
|
74
|
+
"en-US": "Performance Improvements"
|
|
153
75
|
},
|
|
154
76
|
refactor: {
|
|
77
|
+
"changelog": false,
|
|
155
78
|
"emoji": "♻",
|
|
156
|
-
"en-US": "Code Refactoring"
|
|
157
|
-
"changelog": false
|
|
79
|
+
"en-US": "Code Refactoring"
|
|
158
80
|
},
|
|
159
81
|
revert: {
|
|
82
|
+
"changelog": true,
|
|
160
83
|
"emoji": "⏪",
|
|
161
|
-
"en-US": "Reverts"
|
|
162
|
-
"changelog": true
|
|
84
|
+
"en-US": "Reverts"
|
|
163
85
|
},
|
|
164
86
|
style: {
|
|
87
|
+
"changelog": false,
|
|
165
88
|
"emoji": "💄",
|
|
166
|
-
"en-US": "Styles"
|
|
167
|
-
|
|
89
|
+
"en-US": "Styles"
|
|
90
|
+
},
|
|
91
|
+
test: {
|
|
92
|
+
"changelog": false,
|
|
93
|
+
"emoji": "✅",
|
|
94
|
+
"en-US": "Tests"
|
|
168
95
|
},
|
|
169
96
|
wip: {
|
|
97
|
+
"changelog": false,
|
|
170
98
|
"emoji": "🚧",
|
|
171
|
-
"en-US": "Work in progress"
|
|
172
|
-
"changelog": false
|
|
99
|
+
"en-US": "Work in progress"
|
|
173
100
|
}
|
|
174
101
|
};
|
|
175
102
|
function hasInstance(anyValue) {
|
|
@@ -189,14 +116,80 @@ const CommitConventionalType = (() => {
|
|
|
189
116
|
}
|
|
190
117
|
return {
|
|
191
118
|
...enumObject,
|
|
192
|
-
|
|
119
|
+
findWhere,
|
|
193
120
|
getData,
|
|
194
|
-
|
|
121
|
+
hasInstance,
|
|
195
122
|
parse,
|
|
196
|
-
|
|
123
|
+
values
|
|
197
124
|
};
|
|
198
125
|
})();
|
|
199
126
|
//#endregion
|
|
127
|
+
//#region src/gitmoji.ts
|
|
128
|
+
const reEmojiUnicode = emojiRegexp();
|
|
129
|
+
const reEmojiText = /:\w*:/;
|
|
130
|
+
const reMatchOnly = (input) => new RegExp(`^${input.source}$`, "");
|
|
131
|
+
const _reEmojiUnicode = reMatchOnly(reEmojiUnicode);
|
|
132
|
+
const _reEmojiText = reMatchOnly(reEmojiText);
|
|
133
|
+
function hasInstance(anyValue) {
|
|
134
|
+
return isText(anyValue) || isUnicode(anyValue);
|
|
135
|
+
}
|
|
136
|
+
function isText(anyValue) {
|
|
137
|
+
return _reEmojiText.test(anyValue);
|
|
138
|
+
}
|
|
139
|
+
function isUnicode(anyValue) {
|
|
140
|
+
return _reEmojiUnicode.test(anyValue);
|
|
141
|
+
}
|
|
142
|
+
/**
|
|
143
|
+
* @namespace
|
|
144
|
+
*/
|
|
145
|
+
const Emoji = Object.freeze({
|
|
146
|
+
hasInstance,
|
|
147
|
+
isText,
|
|
148
|
+
isUnicode,
|
|
149
|
+
reEmojiText,
|
|
150
|
+
reEmojiUnicode
|
|
151
|
+
});
|
|
152
|
+
const allGitmojiCodes = new Set(gitmojis.map((gitmoji) => gitmoji.code).concat(gitmojis.map((gitmoji) => gitmoji.emoji)));
|
|
153
|
+
const index = { emoji: createIndex(gitmojis, "emoji") };
|
|
154
|
+
function createIndex(list, key) {
|
|
155
|
+
return new Map(list.map((gitmoji) => [gitmoji[key], gitmoji]));
|
|
156
|
+
}
|
|
157
|
+
function isValid(anyValue) {
|
|
158
|
+
return allGitmojiCodes.has(anyValue);
|
|
159
|
+
}
|
|
160
|
+
const defaultType = "chore";
|
|
161
|
+
const conversionMap = (() => {
|
|
162
|
+
const entries = Array.from(Object.entries({
|
|
163
|
+
build: [],
|
|
164
|
+
chore: ["🔧"],
|
|
165
|
+
ci: ["👷", "💚"],
|
|
166
|
+
docs: ["📝"],
|
|
167
|
+
feat: [
|
|
168
|
+
"✨",
|
|
169
|
+
"♿️",
|
|
170
|
+
"🚸"
|
|
171
|
+
],
|
|
172
|
+
fix: ["🐛"],
|
|
173
|
+
perf: ["⚡️"],
|
|
174
|
+
refactor: ["♻️", "🏗️"],
|
|
175
|
+
revert: ["⏪️"],
|
|
176
|
+
style: ["🎨", "🚨"],
|
|
177
|
+
test: ["✅", "🧪"],
|
|
178
|
+
wip: ["🚧"]
|
|
179
|
+
}));
|
|
180
|
+
return new Map(entries.reduce((acc, [commitType, gitmojiUnicodeArray]) => acc.concat(gitmojiUnicodeArray.map((gitmojiUnicode) => [gitmojiUnicode, commitType])).concat(gitmojiUnicodeArray.map((gitmojiUnicode) => [index.emoji.get(gitmojiUnicode)?.code, commitType])), []));
|
|
181
|
+
})();
|
|
182
|
+
function toConventionalCommitType$1(gitmoji) {
|
|
183
|
+
return conversionMap.get(gitmoji) ?? defaultType;
|
|
184
|
+
}
|
|
185
|
+
/**
|
|
186
|
+
* @namespace
|
|
187
|
+
*/
|
|
188
|
+
const GitmojiCode = Object.freeze({
|
|
189
|
+
isValid,
|
|
190
|
+
toConventionalCommitType: toConventionalCommitType$1
|
|
191
|
+
});
|
|
192
|
+
//#endregion
|
|
200
193
|
//#region src/whatBump.ts
|
|
201
194
|
function toConventionalCommitType(text) {
|
|
202
195
|
return GitmojiCode.isValid(text) ? GitmojiCode.toConventionalCommitType(text) : CommitConventionalType.hasInstance(text) ? text : void 0;
|
|
@@ -205,7 +198,7 @@ const whatBump = (commits) => {
|
|
|
205
198
|
let level = 2;
|
|
206
199
|
let breakings = 0;
|
|
207
200
|
let features = 0;
|
|
208
|
-
for (const {
|
|
201
|
+
for (const { notes, type } of commits) {
|
|
209
202
|
const conventionalType = type == null ? type : toConventionalCommitType(type);
|
|
210
203
|
if (notes.length > 0) {
|
|
211
204
|
breakings += notes.length;
|
|
@@ -226,7 +219,7 @@ function displayScope(scope, scopeDisplayNameMap) {
|
|
|
226
219
|
return scope == null || scope.length === 0 ? scopeDisplayNameMap["*"] : scopeDisplayNameMap[scope] ?? scope;
|
|
227
220
|
}
|
|
228
221
|
function displayType(type, options = {}) {
|
|
229
|
-
const {
|
|
222
|
+
const { language = "en-US", withEmoji = true } = options;
|
|
230
223
|
if (CommitConventionalType.hasInstance(type)) {
|
|
231
224
|
const { emoji, [language]: title } = CommitConventionalType.getData(type);
|
|
232
225
|
return `${withEmoji ? `${emoji} ` : ""}${title}`;
|
|
@@ -235,19 +228,19 @@ function displayType(type, options = {}) {
|
|
|
235
228
|
}
|
|
236
229
|
function createTransform(config) {
|
|
237
230
|
const displayTypes = new Set(config.displayTypes ?? CommitConventionalType.values());
|
|
238
|
-
const
|
|
239
|
-
const
|
|
240
|
-
const transform = (commit, {
|
|
241
|
-
const
|
|
231
|
+
const shouldIgnoreType = (type) => type == null || !displayTypes.has(type);
|
|
232
|
+
const shouldIgnoreScope = (scope) => config.displayScopes == null ? false : scope != null && !config.displayScopes.includes(scope);
|
|
233
|
+
const transform = (commit, { host, owner, repository, repoUrl }) => {
|
|
234
|
+
const isDiscard = commit.notes.length === 0;
|
|
242
235
|
const issues = /* @__PURE__ */ new Set();
|
|
243
236
|
const notes = commit.notes.map((note) => ({
|
|
244
237
|
...note,
|
|
245
238
|
title: `${config.withEmoji === false ? "" : "💥 "}BREAKING CHANGES`
|
|
246
239
|
}));
|
|
247
240
|
const conventionalType = commit.type == null ? void 0 : CommitConventionalType.parse(commit.type) ?? (GitmojiCode.isValid(commit.type) ? GitmojiCode.toConventionalCommitType(commit.type) : void 0);
|
|
248
|
-
if (
|
|
241
|
+
if (shouldIgnoreType(conventionalType) && isDiscard) return false;
|
|
242
|
+
if (shouldIgnoreScope(commit.scope)) return false;
|
|
249
243
|
const type = conventionalType == null ? null : displayType(conventionalType, { withEmoji: config.withEmoji });
|
|
250
|
-
if (ignoreScope(commit.scope)) return false;
|
|
251
244
|
const scopeIntermediate = commit.scope === "*" ? "" : commit.scope;
|
|
252
245
|
const scope = config.scopeDisplayName == null ? null : displayScope(scopeIntermediate, config.scopeDisplayName) ?? null;
|
|
253
246
|
const hash = typeof commit.hash === "string" ? commit.hash.slice(0, 7) : commit.hash;
|
|
@@ -271,25 +264,25 @@ function createTransform(config) {
|
|
|
271
264
|
const references = commit.references.filter((reference) => !issues.has(reference.issue));
|
|
272
265
|
return {
|
|
273
266
|
...commit,
|
|
274
|
-
type,
|
|
275
|
-
hash,
|
|
276
|
-
scope,
|
|
277
|
-
subject,
|
|
278
|
-
references,
|
|
279
|
-
header: commit.header,
|
|
280
267
|
body: commit.body,
|
|
281
268
|
footer: commit.footer,
|
|
269
|
+
hash,
|
|
270
|
+
header: commit.header,
|
|
271
|
+
mentions: commit.mentions,
|
|
282
272
|
merge: commit.merge,
|
|
283
|
-
revert: commit.revert,
|
|
284
273
|
notes,
|
|
285
|
-
|
|
274
|
+
references,
|
|
275
|
+
revert: commit.revert,
|
|
276
|
+
scope,
|
|
277
|
+
subject,
|
|
278
|
+
type
|
|
286
279
|
};
|
|
287
280
|
};
|
|
288
281
|
return transform;
|
|
289
282
|
}
|
|
290
283
|
//#endregion
|
|
291
284
|
//#region src/writer.ts
|
|
292
|
-
const _dirname =
|
|
285
|
+
const _dirname = nodePath.dirname(fileURLToPath(import.meta.url));
|
|
293
286
|
const basePath = nodePath.resolve(nodePath.dirname(_dirname), "./template");
|
|
294
287
|
const defaultDisplayTypes = CommitConventionalType.findWhere((_) => _.changelog);
|
|
295
288
|
const createWriterOpts = async () => {
|
|
@@ -299,15 +292,15 @@ const createWriterOpts = async () => {
|
|
|
299
292
|
const footerPartial = readFileSync(`${basePath}/footer.hbs`, "utf8");
|
|
300
293
|
const author = readFileSync(`${basePath}/author.hbs`, "utf8");
|
|
301
294
|
return {
|
|
302
|
-
transform: createTransform({ displayTypes: defaultDisplayTypes }),
|
|
303
|
-
groupBy: "type",
|
|
304
295
|
commitGroupsSort: "title",
|
|
296
|
+
commitPartial: commitPartial.replace(/{{gitUserInfo}}/g, author),
|
|
305
297
|
commitsSort: ["scope", "subject"],
|
|
306
|
-
|
|
307
|
-
|
|
298
|
+
footerPartial,
|
|
299
|
+
groupBy: "type",
|
|
308
300
|
headerPartial,
|
|
309
|
-
|
|
310
|
-
|
|
301
|
+
mainTemplate,
|
|
302
|
+
noteGroupsSort: "title",
|
|
303
|
+
transform: createTransform({ displayTypes: defaultDisplayTypes })
|
|
311
304
|
};
|
|
312
305
|
};
|
|
313
306
|
//#endregion
|
|
@@ -316,11 +309,18 @@ async function createPreset() {
|
|
|
316
309
|
return {
|
|
317
310
|
gitRawCommitOpts,
|
|
318
311
|
parser: createParserOpts(),
|
|
319
|
-
|
|
320
|
-
|
|
312
|
+
whatBump,
|
|
313
|
+
writer: await createWriterOpts()
|
|
321
314
|
};
|
|
322
315
|
}
|
|
323
316
|
//#endregion
|
|
317
|
+
//#region src/meta.ts
|
|
318
|
+
const meta = Object.freeze({
|
|
319
|
+
buildNumber: 1,
|
|
320
|
+
name: "@w5s/conventional-changelog",
|
|
321
|
+
version: "3.2.8"
|
|
322
|
+
});
|
|
323
|
+
//#endregion
|
|
324
324
|
export { Emoji, GitmojiCode, createPreset as default, meta };
|
|
325
325
|
|
|
326
326
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["toConventionalCommitType"],"sources":["../src/meta.ts","../src/gitmoji.ts","../src/git-raw-commit-opts.ts","../src/parser.ts","../src/data.ts","../src/whatBump.ts","../src/transform.ts","../src/writer.ts","../src/createPreset.ts"],"sourcesContent":["export const meta = Object.freeze({\n // @ts-ignore - these variables are injected at build time\n name: (typeof __PACKAGE_NAME__ === 'undefined' ? '' : __PACKAGE_NAME__) as string,\n // @ts-ignore - these variables are injected at build time\n version: (typeof __PACKAGE_VERSION__ === 'undefined' ? '' : __PACKAGE_VERSION__) as string,\n // @ts-ignore - these variables are injected at build time\n buildNumber: 1 as number, // (typeof __PACKAGE_BUILD_NUMBER__ === 'undefined' ? 0 : __PACKAGE_BUILD_NUMBER__) as number,\n});\n","/* eslint-disable unicorn/prefer-spread */\nimport emojiRegexp from 'emoji-regex';\nimport { type Gitmoji, gitmojis } from 'gitmojis';\nimport type { CommitConventionalType } from './data.js';\n\nexport type Emoji = Emoji.Unicode | Emoji.Text;\nexport namespace Emoji {\n export type Unicode = string & { '@@EmojiStyle': 'unicode' };\n export type Text = string & { '@@EmojiStyle': 'text' };\n}\n\nconst reEmojiUnicode = emojiRegexp();\nconst reEmojiText = /:\\w*:/;\n\nconst reMatchOnly = (input: RegExp) => new RegExp(`^${input.source}$`, '');\nconst _reEmojiUnicode = reMatchOnly(reEmojiUnicode);\nconst _reEmojiText = reMatchOnly(reEmojiText);\n\nfunction isUnicode(anyValue: string): anyValue is Emoji.Unicode {\n return _reEmojiUnicode.test(anyValue);\n}\n\nfunction isText(anyValue: string): anyValue is Emoji.Text {\n return _reEmojiText.test(anyValue);\n}\n\nfunction hasInstance(anyValue: string): anyValue is Emoji {\n return isText(anyValue) || isUnicode(anyValue);\n}\n\n/**\n * @namespace\n */\nexport const Emoji = Object.freeze({\n hasInstance,\n isText,\n isUnicode,\n reEmojiText,\n reEmojiUnicode,\n});\n\nexport type GitmojiCode = Emoji & { '@@Gitmoji': true };\nexport namespace GitmojiCode {\n export type Unicode = Emoji.Unicode & { '@@Gitmoji': true };\n export type Emoji = Emoji.Text & { '@@Gitmoji': true };\n}\n\nconst allGitmojiCodes = new Set(\n gitmojis\n .map((gitmoji) => gitmoji.code as GitmojiCode)\n .concat(gitmojis.map((gitmoji) => gitmoji.emoji as GitmojiCode)),\n);\nconst index = {\n // code: createIndex(gitmojis, 'code'),\n emoji: createIndex(gitmojis, 'emoji'),\n};\n\nfunction createIndex<K extends keyof Gitmoji>(list: readonly Gitmoji[], key: K): ReadonlyMap<Gitmoji[K], Gitmoji> {\n return new Map(list.map((gitmoji) => [gitmoji[key], gitmoji]));\n}\n\nfunction isValid(anyValue: string): anyValue is GitmojiCode {\n return allGitmojiCodes.has(anyValue as GitmojiCode);\n}\n\nconst defaultType = 'chore';\nconst conversionMap: ReadonlyMap<GitmojiCode, CommitConventionalType> = (() => {\n const data: Record<CommitConventionalType, GitmojiCode.Unicode[]> = {\n feat: ['✨', '♿️', '🚸'] as GitmojiCode.Unicode[],\n fix: ['🐛'] as GitmojiCode.Unicode[],\n docs: ['📝'] as GitmojiCode.Unicode[],\n style: ['🎨', '🚨'] as GitmojiCode.Unicode[],\n refactor: ['♻️', '🏗️'] as GitmojiCode.Unicode[],\n test: ['✅', '🧪'] as GitmojiCode.Unicode[],\n perf: ['⚡️'] as GitmojiCode.Unicode[],\n revert: ['⏪️'] as GitmojiCode.Unicode[],\n ci: ['👷', '💚'] as GitmojiCode.Unicode[],\n wip: ['🚧'] as GitmojiCode.Unicode[],\n build: [] as GitmojiCode.Unicode[],\n chore: ['🔧'] as GitmojiCode.Unicode[],\n };\n\n const entries = Array.from<[CommitConventionalType, GitmojiCode.Unicode[]]>(\n // @ts-ignore entries are not well typed\n Object.entries(data),\n );\n return new Map(\n entries.reduce<Array<[GitmojiCode, CommitConventionalType]>>(\n (acc, [commitType, gitmojiUnicodeArray]) =>\n acc\n .concat(gitmojiUnicodeArray.map((gitmojiUnicode) => [gitmojiUnicode, commitType]))\n\n .concat(\n gitmojiUnicodeArray.map((gitmojiUnicode) => [\n // eslint-disable-next-line ts/no-non-null-assertion, ts/no-non-null-asserted-optional-chain\n index.emoji.get(gitmojiUnicode)?.code! as GitmojiCode,\n commitType,\n ]),\n ),\n [],\n ),\n );\n})();\n\nfunction toConventionalCommitType(gitmoji: GitmojiCode): CommitConventionalType {\n return conversionMap.get(gitmoji) ?? defaultType;\n}\n\n/**\n * @namespace\n */\nexport const GitmojiCode = Object.freeze({\n isValid,\n toConventionalCommitType,\n});\n","export const gitRawCommitOpts = {\n format: '%B%n-hash-%n%H%n-gitTags-%n%d%n-committerDate-%n%ci%n-authorName-%n%an%n-authorEmail-%n%ae',\n};\n","export interface ParserOptions {\n headerPattern?: RegExp | string | null;\n headerCorrespondence?: string[] | string | null;\n revertPattern?: RegExp | string | null;\n revertCorrespondence?: string[] | string | null;\n noteKeywords?: string[] | string | null;\n}\n\nexport const createParserOpts = (): ParserOptions => ({\n headerPattern: new RegExp(\n // Type\n // eslint-disable-next-line unicorn/prefer-string-raw\n `^(?<type>\\\\S*)? ` +\n // Scope\n // eslint-disable-next-line unicorn/prefer-string-raw\n `(?:\\\\((?<scope>.*)\\\\):? )?` +\n // Subject\n `(?<subject>.*)$`,\n 'u',\n ),\n headerCorrespondence: ['type', 'scope', 'subject'],\n // eslint-disable-next-line e18e/prefer-static-regex\n revertPattern: /^(?:revert|revert:)\\s\"?([\\S\\s]+?)\"?\\s*this reverts commit (\\w*)\\./i,\n noteKeywords: ['BREAKING CHANGE', 'BREAKING CHANGES'],\n // revertPattern: /revert:\\s([\\S\\s]*?)\\s*this reverts commit (\\w*)\\./i,\n revertCorrespondence: [`header`, `hash`],\n});\n","export interface Commit {\n merge: Commit.Field;\n header: Commit.Field;\n body: Commit.Field;\n footer: Commit.Field;\n notes: Commit.Note[];\n references: Commit.Reference[];\n mentions: string[];\n revert: Commit.Revert | null;\n type: string | null;\n subject: string | null;\n scope: string | null;\n hash: string | null;\n}\n\nexport namespace Commit {\n export type Field = string | null;\n\n export interface Note {\n title: string;\n text: string;\n }\n\n export interface Reference {\n issue: string;\n action: Field;\n owner: Field;\n repository: Field;\n prefix: string;\n raw: string;\n }\n\n export interface Revert {\n hash?: Field | undefined;\n header?: Field | undefined;\n [field: string]: Field | undefined;\n }\n}\n\nexport type CommitConventionalType =\n | 'build'\n | 'ci'\n | 'docs'\n | 'feat'\n | 'fix'\n | 'perf'\n | 'refactor'\n | 'revert'\n | 'style'\n | 'test'\n | 'wip'\n | 'chore';\n\nexport const CommitConventionalType = (() => {\n const enumObject = Object.freeze({\n Build: 'build',\n CI: 'ci',\n Docs: 'docs',\n Feat: 'feat',\n Fix: 'fix',\n Perf: 'perf',\n Refactor: 'refactor',\n Revert: 'revert',\n Style: 'style',\n Test: 'test',\n WIP: 'wip',\n Chore: 'chore',\n });\n // eslint-disable-next-line unicorn/no-array-sort\n const enumValues: readonly CommitConventionalType[] = Object.freeze(Object.values(enumObject).sort());\n const enumValuesSet = new Set(enumValues);\n\n const typeData: Record<CommitConventionalType, CommitConventionalTypeData> = {\n feat: {\n 'emoji': '✨',\n 'en-US': 'Features',\n 'changelog': true,\n },\n fix: {\n 'emoji': '🐛',\n 'en-US': 'Bug Fixes',\n 'changelog': true,\n },\n build: {\n 'emoji': '👷',\n 'en-US': 'Build System',\n 'changelog': false,\n },\n chore: {\n 'emoji': '🎫',\n 'en-US': 'Chores',\n 'changelog': false,\n },\n ci: {\n 'emoji': '🔧',\n 'en-US': 'Continuous Integration',\n 'changelog': false,\n },\n docs: {\n 'emoji': '📝',\n 'en-US': 'Documentation',\n 'changelog': false,\n },\n test: {\n 'emoji': '✅',\n 'en-US': 'Tests',\n 'changelog': false,\n },\n perf: {\n 'emoji': '⚡',\n 'en-US': 'Performance Improvements',\n 'changelog': true,\n },\n refactor: {\n 'emoji': '♻',\n 'en-US': 'Code Refactoring',\n 'changelog': false,\n },\n revert: {\n 'emoji': '⏪',\n 'en-US': 'Reverts',\n 'changelog': true,\n },\n style: {\n 'emoji': '💄',\n 'en-US': 'Styles',\n 'changelog': false,\n },\n wip: {\n 'emoji': '🚧',\n 'en-US': 'Work in progress',\n 'changelog': false,\n },\n };\n\n function hasInstance(anyValue: unknown): anyValue is CommitConventionalType {\n return typeof anyValue === 'string' && enumValuesSet.has(anyValue as unknown as CommitConventionalType);\n }\n\n function getData(commitType: CommitConventionalType): CommitConventionalTypeData {\n return typeData[commitType];\n }\n\n function parse(anyValue: string): CommitConventionalType | undefined {\n return hasInstance(anyValue) ? anyValue : undefined;\n }\n\n function values() {\n return enumValues;\n }\n\n function findWhere(predicate: (data: CommitConventionalTypeData) => boolean): CommitConventionalType[] {\n return enumValues.filter((enumValue) => predicate(getData(enumValue)));\n }\n\n return { ...enumObject, hasInstance, getData, values, parse, findWhere };\n})();\n\nexport interface CommitConventionalTypeData {\n 'emoji': string;\n 'en-US': string;\n 'changelog': boolean;\n}\n","import { CommitConventionalType, type Commit } from './data.js';\nimport { GitmojiCode } from './gitmoji.js';\n\nfunction toConventionalCommitType(text: string) {\n return GitmojiCode.isValid(text)\n ? GitmojiCode.toConventionalCommitType(text)\n : CommitConventionalType.hasInstance(text)\n ? text\n : undefined;\n}\n\nexport const whatBump = (commits: ReadonlyArray<Commit>) => {\n let level = 2;\n let breakings = 0;\n let features = 0;\n\n for (const { type, notes } of commits) {\n const conventionalType = type == null ? type : toConventionalCommitType(type);\n if (notes.length > 0) {\n breakings += notes.length;\n level = 0;\n } else if (conventionalType === CommitConventionalType.Feat) {\n features += 1;\n if (level === 2) {\n level = 1;\n }\n }\n }\n\n return {\n level,\n reason:\n breakings === 1\n ? `There is ${breakings} BREAKING CHANGE and ${features} features`\n : `There are ${breakings} BREAKING CHANGES and ${features} features`,\n };\n};\n","import { CommitConventionalType, type Commit } from './data.js';\nimport { GitmojiCode } from './gitmoji.js';\n\nexport type Language = 'en-US';\n\nexport interface TransformConfig {\n scopeDisplayName?: Record<string, string>;\n displayTypes?: CommitConventionalType[];\n displayScopes?: string[];\n showAuthor?: boolean;\n withEmoji?: boolean;\n language?: Language;\n}\n\nexport interface WriterContext {\n repository?: string | undefined;\n host?: string | undefined;\n owner?: string | undefined;\n repoUrl?: string | undefined;\n}\n\nexport interface CommitTransformFunction<TCommit extends Commit = Commit> {\n (commit: Commit, context: WriterContext, ...args: unknown[]): TCommit | false;\n}\n\nexport function displayScope(scope: string | null | undefined, scopeDisplayNameMap: Record<string, string>) {\n return scope == null || scope.length === 0\n ? scopeDisplayNameMap['*']\n : scopeDisplayNameMap[scope] ?? scope;\n}\n\nexport function displayType(type: string, options: displayType.Options = {}): string {\n const { withEmoji = true, language = 'en-US' } = options;\n\n if (CommitConventionalType.hasInstance(type)) {\n const { emoji, [language]: title } = CommitConventionalType.getData(type);\n return `${withEmoji ? `${emoji} ` : ''}${title}`;\n }\n\n return type;\n}\nexport namespace displayType {\n export interface Options {\n readonly withEmoji?: boolean | undefined;\n readonly language?: Language;\n }\n}\n\nexport function createTransform(config: TransformConfig): CommitTransformFunction<Commit> {\n const displayTypes = new Set(config.displayTypes ?? CommitConventionalType.values());\n const ignoreType = (type: string | undefined) => type == null || !displayTypes.has(type as CommitConventionalType);\n const ignoreScope = (scope: string | undefined | null) =>\n config.displayScopes == null ? false : scope != null && !config.displayScopes.includes(scope);\n\n const transform = (commit: Commit, { repository, host, owner, repoUrl }: WriterContext): Commit | false => {\n const discard = commit.notes.length === 0;\n const issues = new Set<string>();\n const notes = commit.notes.map((note) => ({\n ...note,\n title: `${config.withEmoji === false ? '' : '💥 '}BREAKING CHANGES`,\n }));\n const conventionalType =\n commit.type == null\n ? undefined\n : (CommitConventionalType.parse(commit.type) ??\n (GitmojiCode.isValid(commit.type) ? GitmojiCode.toConventionalCommitType(commit.type) : undefined));\n\n if (ignoreType(conventionalType) && discard) return false;\n\n const type =\n conventionalType == null\n ? null\n : displayType(conventionalType, {\n withEmoji: config.withEmoji,\n });\n\n if (ignoreScope(commit.scope)) return false;\n\n const scopeIntermediate = commit.scope === '*' ? '' : commit.scope;\n const scope =\n config.scopeDisplayName == null ? null : (displayScope(scopeIntermediate, config.scopeDisplayName) ?? null);\n const hash = typeof commit.hash === 'string' ? commit.hash.slice(0, 7) : commit.hash;\n\n const subject =\n typeof commit.subject === 'string'\n ? (() => {\n let returnValue = commit.subject;\n const url = repository == null ? repoUrl : [host, owner, repository].filter(Boolean).join('/');\n if (url != null) {\n const issueURL = `${url}/issues/`;\n // Issue URLs.\n // eslint-disable-next-line unicorn/prefer-string-replace-all\n returnValue = returnValue.replace(/#(\\d+)/g, (_, issue: string) => {\n issues.add(issue);\n\n return `[#${issue}](${issueURL}${issue})`;\n });\n }\n if (host != null) {\n // User URLs.\n // eslint-disable-next-line unicorn/prefer-string-replace-all\n returnValue = returnValue.replace(/\\B@([\\da-z](?:-?[\\d/a-z]){0,38})/g, (_, username: string) =>\n username.includes('/') ? `@${username}` : `[@${username}](${host}/${username})`,\n );\n }\n return returnValue;\n })()\n : commit.subject;\n\n // Remove references that already appear in the subject\n const references = commit.references.filter((reference) => !issues.has(reference.issue));\n\n // eslint-disable-next-line ts/consistent-type-assertions\n return {\n ...commit,\n type,\n hash,\n scope,\n subject,\n references,\n header: commit.header,\n body: commit.body,\n footer: commit.footer,\n merge: commit.merge,\n revert: commit.revert,\n notes,\n mentions: commit.mentions,\n } as Commit;\n };\n\n return transform as unknown as CommitTransformFunction<Commit>;\n}\n","import { readFileSync } from 'node:fs';\nimport nodePath from 'node:path';\nimport { fileURLToPath } from 'node:url';\nimport { createTransform, type CommitTransformFunction } from './transform.js';\nimport { CommitConventionalType, type Commit } from './data.js';\n\nexport interface WriterOptions {\n transform?: CommitTransformFunction<Commit> | undefined;\n groupBy?: string | false | undefined;\n commitGroupsSort?: string | readonly string[] | false | undefined;\n commitsSort?: string | readonly string[] | false | undefined;\n noteGroupsSort?: string | readonly string[] | false | undefined;\n mainTemplate?: string | undefined;\n headerPartial?: string | undefined;\n commitPartial?: string | undefined;\n footerPartial?: string | undefined;\n}\n\nconst _dirname = typeof __dirname === 'undefined' ? nodePath.dirname(fileURLToPath(import.meta.url)) : __dirname;\nconst basePath = nodePath.resolve(nodePath.dirname(_dirname), './template');\n\nexport const defaultDisplayTypes = CommitConventionalType.findWhere((_) => _.changelog);\n\nexport const createWriterOpts = async (): Promise<WriterOptions> => {\n const mainTemplate = readFileSync(`${basePath}/template.hbs`, 'utf8');\n const headerPartial = readFileSync(`${basePath}/header.hbs`, 'utf8');\n const commitPartial = readFileSync(`${basePath}/commit.hbs`, 'utf8');\n const footerPartial = readFileSync(`${basePath}/footer.hbs`, 'utf8');\n const author = readFileSync(`${basePath}/author.hbs`, 'utf8');\n\n return {\n transform: createTransform({\n displayTypes: defaultDisplayTypes,\n }),\n groupBy: 'type',\n commitGroupsSort: 'title',\n // @ts-ignore FIXME: unknown error\n commitsSort: ['scope', 'subject'],\n noteGroupsSort: 'title',\n mainTemplate,\n headerPartial,\n // eslint-disable-next-line unicorn/prefer-string-replace-all\n commitPartial: commitPartial.replace(/{{gitUserInfo}}/g, author),\n footerPartial,\n };\n};\n","import { gitRawCommitOpts } from './git-raw-commit-opts.js';\nimport { createParserOpts } from './parser.js';\nimport { whatBump } from './whatBump.js';\nimport { createWriterOpts } from './writer.js';\n\nexport { Emoji, GitmojiCode } from './gitmoji.js';\n\nexport async function createPreset() {\n return {\n gitRawCommitOpts,\n parser: createParserOpts(),\n writer: await createWriterOpts(),\n whatBump,\n };\n}\n"],"mappings":";;;;;;AAAA,MAAa,OAAO,OAAO,OAAO;CAEhC,MAAA;CAEA,SAAA;CAEA,aAAa;AACf,CAAC;;;ACID,MAAM,iBAAiB,YAAY;AACnC,MAAM,cAAc;AAEpB,MAAM,eAAe,UAAkB,IAAI,OAAO,IAAI,MAAM,OAAO,IAAI,EAAE;AACzE,MAAM,kBAAkB,YAAY,cAAc;AAClD,MAAM,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,aAAa,GAAG,SAAS,cAAc,MAAM;CACnE,MAAM,gBAAgB,aAAa,GAAG,SAAS,cAAc,MAAM;CACnE,MAAM,gBAAgB,aAAa,GAAG,SAAS,cAAc,MAAM;CACnE,MAAM,SAAS,aAAa,GAAG,SAAS,cAAc,MAAM;CAE5D,OAAO;EACL,WAAW,gBAAgB,EACzB,cAAc,oBAChB,CAAC;EACD,SAAS;EACT,kBAAkB;EAElB,aAAa,CAAC,SAAS,SAAS;EAChC,gBAAgB;EAChB;EACA;EAEA,eAAe,cAAc,QAAQ,oBAAoB,MAAM;EAC/D;CACF;AACF;;;ACtCA,eAAsB,eAAe;CACnC,OAAO;EACL;EACA,QAAQ,iBAAiB;EACzB,QAAQ,MAAM,iBAAiB;EAC/B;CACF;AACF"}
|
|
1
|
+
{"version":3,"file":"index.js","names":["toConventionalCommitType"],"sources":["../src/git-raw-commit-opts.ts","../src/parser.ts","../src/data.ts","../src/gitmoji.ts","../src/whatBump.ts","../src/transform.ts","../src/writer.ts","../src/createPreset.ts","../src/meta.ts"],"sourcesContent":["export const gitRawCommitOpts = {\n format: '%B%n-hash-%n%H%n-gitTags-%n%d%n-committerDate-%n%ci%n-authorName-%n%an%n-authorEmail-%n%ae',\n};\n","export interface ParserOptions {\n headerCorrespondence?: null | string | string[];\n headerPattern?: null | RegExp | string;\n noteKeywords?: null | string | string[];\n revertCorrespondence?: null | string | string[];\n revertPattern?: null | RegExp | string;\n}\n\nexport const createParserOpts = (): ParserOptions => ({\n headerCorrespondence: ['type', 'scope', 'subject'],\n headerPattern: new RegExp(\n // Type\n // eslint-disable-next-line unicorn/prefer-string-raw\n `^(?<type>\\\\S*)? ` +\n // Scope\n // eslint-disable-next-line unicorn/prefer-string-raw\n `(?:\\\\((?<scope>.*)\\\\):? )?` +\n // Subject\n `(?<subject>.*)$`,\n 'u',\n ),\n noteKeywords: ['BREAKING CHANGE', 'BREAKING CHANGES'],\n // revertPattern: /revert:\\s([\\S\\s]*?)\\s*this reverts commit (\\w*)\\./i,\n revertCorrespondence: [`header`, `hash`],\n // eslint-disable-next-line e18e/prefer-static-regex\n revertPattern: /^(?:revert|revert:)\\s\"?([\\S\\s]+?)\"?\\s*this reverts commit (\\w*)\\./i,\n});\n","export interface Commit {\n body: Commit.Field;\n footer: Commit.Field;\n hash: null | string;\n header: Commit.Field;\n mentions: string[];\n merge: Commit.Field;\n notes: Commit.Note[];\n references: Commit.Reference[];\n revert: Commit.Revert | null;\n scope: null | string;\n subject: null | string;\n type: null | string;\n}\n\nexport namespace Commit {\n export type Field = null | string;\n\n export interface Note {\n text: string;\n title: string;\n }\n\n export interface Reference {\n action: Field;\n issue: string;\n owner: Field;\n prefix: string;\n raw: string;\n repository: Field;\n }\n\n export interface Revert {\n [field: string]: Field | undefined;\n hash?: Field | undefined;\n header?: Field | undefined;\n }\n}\n\nexport type CommitConventionalType =\n | 'build'\n | 'chore'\n | 'ci'\n | 'docs'\n | 'feat'\n | 'fix'\n | 'perf'\n | 'refactor'\n | 'revert'\n | 'style'\n | 'test'\n | 'wip';\n\nexport const CommitConventionalType = (() => {\n const enumObject = Object.freeze({\n Build: 'build',\n Chore: 'chore',\n CI: 'ci',\n Docs: 'docs',\n Feat: 'feat',\n Fix: 'fix',\n Perf: 'perf',\n Refactor: 'refactor',\n Revert: 'revert',\n Style: 'style',\n Test: 'test',\n WIP: 'wip',\n });\n // eslint-disable-next-line unicorn/no-array-sort\n const enumValues: readonly CommitConventionalType[] = Object.freeze(Object.values(enumObject).sort((left, right) => left.localeCompare(right)));\n const enumValuesSet = new Set(enumValues);\n\n const typeData: Record<CommitConventionalType, CommitConventionalTypeData> = {\n build: {\n 'changelog': false,\n 'emoji': '👷',\n 'en-US': 'Build System',\n },\n chore: {\n 'changelog': false,\n 'emoji': '🎫',\n 'en-US': 'Chores',\n },\n ci: {\n 'changelog': false,\n 'emoji': '🔧',\n 'en-US': 'Continuous Integration',\n },\n docs: {\n 'changelog': false,\n 'emoji': '📝',\n 'en-US': 'Documentation',\n },\n feat: {\n 'changelog': true,\n 'emoji': '✨',\n 'en-US': 'Features',\n },\n fix: {\n 'changelog': true,\n 'emoji': '🐛',\n 'en-US': 'Bug Fixes',\n },\n perf: {\n 'changelog': true,\n 'emoji': '⚡',\n 'en-US': 'Performance Improvements',\n },\n refactor: {\n 'changelog': false,\n 'emoji': '♻',\n 'en-US': 'Code Refactoring',\n },\n revert: {\n 'changelog': true,\n 'emoji': '⏪',\n 'en-US': 'Reverts',\n },\n style: {\n 'changelog': false,\n 'emoji': '💄',\n 'en-US': 'Styles',\n },\n test: {\n 'changelog': false,\n 'emoji': '✅',\n 'en-US': 'Tests',\n },\n wip: {\n 'changelog': false,\n 'emoji': '🚧',\n 'en-US': 'Work in progress',\n },\n };\n\n function hasInstance(anyValue: unknown): anyValue is CommitConventionalType {\n return typeof anyValue === 'string' && enumValuesSet.has(anyValue as unknown as CommitConventionalType);\n }\n\n function getData(commitType: CommitConventionalType): CommitConventionalTypeData {\n return typeData[commitType];\n }\n\n function parse(anyValue: string): CommitConventionalType | undefined {\n return hasInstance(anyValue) ? anyValue : undefined;\n }\n\n function values() {\n return enumValues;\n }\n\n function findWhere(predicate: (data: CommitConventionalTypeData) => boolean): CommitConventionalType[] {\n return enumValues.filter((enumValue) => predicate(getData(enumValue)));\n }\n\n return { ...enumObject, findWhere, getData, hasInstance, parse, values };\n})();\n\nexport interface CommitConventionalTypeData {\n 'changelog': boolean;\n 'emoji': string;\n 'en-US': string;\n}\n","import emojiRegexp from 'emoji-regex';\nimport { type Gitmoji, gitmojis } from 'gitmojis';\n\nimport type { CommitConventionalType } from './data.js';\n\nexport type Emoji = Emoji.Text | Emoji.Unicode;\nexport namespace Emoji {\n export type Text = string & { '@@EmojiStyle': 'text' };\n export type Unicode = string & { '@@EmojiStyle': 'unicode' };\n}\n\nconst reEmojiUnicode = emojiRegexp();\nconst reEmojiText = /:\\w*:/;\n\nconst reMatchOnly = (input: RegExp) => new RegExp(`^${input.source}$`, '');\nconst _reEmojiUnicode = reMatchOnly(reEmojiUnicode);\nconst _reEmojiText = reMatchOnly(reEmojiText);\n\nfunction hasInstance(anyValue: string): anyValue is Emoji {\n return isText(anyValue) || isUnicode(anyValue);\n}\n\nfunction isText(anyValue: string): anyValue is Emoji.Text {\n return _reEmojiText.test(anyValue);\n}\n\nfunction isUnicode(anyValue: string): anyValue is Emoji.Unicode {\n return _reEmojiUnicode.test(anyValue);\n}\n\n/**\n * @namespace\n */\nexport const Emoji = Object.freeze({\n hasInstance,\n isText,\n isUnicode,\n reEmojiText,\n reEmojiUnicode,\n});\n\nexport type GitmojiCode = Emoji & { '@@Gitmoji': true };\nexport namespace GitmojiCode {\n export type Emoji = Emoji.Text & { '@@Gitmoji': true };\n export type Unicode = Emoji.Unicode & { '@@Gitmoji': true };\n}\n\nconst allGitmojiCodes = new Set(\n gitmojis\n .map((gitmoji) => gitmoji.code as GitmojiCode)\n .concat(gitmojis.map((gitmoji) => gitmoji.emoji as GitmojiCode)),\n);\nconst index = {\n // code: createIndex(gitmojis, 'code'),\n emoji: createIndex(gitmojis, 'emoji'),\n};\n\nfunction createIndex<K extends keyof Gitmoji>(list: readonly Gitmoji[], key: K): ReadonlyMap<Gitmoji[K], Gitmoji> {\n return new Map(list.map((gitmoji) => [gitmoji[key], gitmoji]));\n}\n\nfunction isValid(anyValue: string): anyValue is GitmojiCode {\n return allGitmojiCodes.has(anyValue as GitmojiCode);\n}\n\nconst defaultType = 'chore';\nconst conversionMap: ReadonlyMap<GitmojiCode, CommitConventionalType> = (() => {\n const data: Record<CommitConventionalType, GitmojiCode.Unicode[]> = {\n build: [] as GitmojiCode.Unicode[],\n chore: ['🔧'] as GitmojiCode.Unicode[],\n ci: ['👷', '💚'] as GitmojiCode.Unicode[],\n docs: ['📝'] as GitmojiCode.Unicode[],\n feat: ['✨', '♿️', '🚸'] as GitmojiCode.Unicode[],\n fix: ['🐛'] as GitmojiCode.Unicode[],\n perf: ['⚡️'] as GitmojiCode.Unicode[],\n refactor: ['♻️', '🏗️'] as GitmojiCode.Unicode[],\n revert: ['⏪️'] as GitmojiCode.Unicode[],\n style: ['🎨', '🚨'] as GitmojiCode.Unicode[],\n test: ['✅', '🧪'] as GitmojiCode.Unicode[],\n wip: ['🚧'] as GitmojiCode.Unicode[],\n };\n\n const entries = Array.from<[CommitConventionalType, GitmojiCode.Unicode[]]>(\n // @ts-ignore entries are not well typed\n Object.entries(data),\n );\n return new Map(\n entries.reduce<Array<[GitmojiCode, CommitConventionalType]>>(\n (acc, [commitType, gitmojiUnicodeArray]) =>\n acc\n .concat(gitmojiUnicodeArray.map((gitmojiUnicode) => [gitmojiUnicode, commitType]))\n\n .concat(\n gitmojiUnicodeArray.map((gitmojiUnicode) => [\n // eslint-disable-next-line ts/no-non-null-assertion, ts/no-non-null-asserted-optional-chain\n index.emoji.get(gitmojiUnicode)?.code! as GitmojiCode,\n commitType,\n ]),\n ),\n [],\n ),\n );\n})();\n\nfunction toConventionalCommitType(gitmoji: GitmojiCode): CommitConventionalType {\n return conversionMap.get(gitmoji) ?? defaultType;\n}\n\n/**\n * @namespace\n */\nexport const GitmojiCode = Object.freeze({\n isValid,\n toConventionalCommitType,\n});\n","import { type Commit, CommitConventionalType } from './data.js';\nimport { GitmojiCode } from './gitmoji.js';\n\nfunction toConventionalCommitType(text: string) {\n return GitmojiCode.isValid(text)\n ? GitmojiCode.toConventionalCommitType(text)\n : CommitConventionalType.hasInstance(text)\n ? text\n : undefined;\n}\n\nexport const whatBump = (commits: ReadonlyArray<Commit>) => {\n let level = 2;\n let breakings = 0;\n let features = 0;\n\n for (const { notes, type } of commits) {\n const conventionalType = type == null ? type : toConventionalCommitType(type);\n if (notes.length > 0) {\n breakings += notes.length;\n level = 0;\n } else if (conventionalType === CommitConventionalType.Feat) {\n features += 1;\n if (level === 2) {\n level = 1;\n }\n }\n }\n\n return {\n level,\n reason:\n breakings === 1\n ? `There is ${breakings} BREAKING CHANGE and ${features} features`\n : `There are ${breakings} BREAKING CHANGES and ${features} features`,\n };\n};\n","import { type Commit, CommitConventionalType } from './data.js';\nimport { GitmojiCode } from './gitmoji.js';\n\nexport interface CommitTransformFunction<TCommit extends Commit = Commit> {\n (commit: Commit, context: WriterContext, ...args: unknown[]): false | TCommit;\n}\n\nexport type Language = 'en-US';\n\nexport interface TransformConfig {\n displayScopes?: string[];\n displayTypes?: CommitConventionalType[];\n language?: Language;\n scopeDisplayName?: Record<string, string>;\n showAuthor?: boolean;\n withEmoji?: boolean;\n}\n\nexport interface WriterContext {\n host?: string | undefined;\n owner?: string | undefined;\n repository?: string | undefined;\n repoUrl?: string | undefined;\n}\n\nexport function displayScope(scope: null | string | undefined, scopeDisplayNameMap: Record<string, string>) {\n return scope == null || scope.length === 0\n ? scopeDisplayNameMap['*']\n : scopeDisplayNameMap[scope] ?? scope;\n}\n\nexport function displayType(type: string, options: displayType.Options = {}): string {\n const { language = 'en-US', withEmoji = true } = options;\n\n if (CommitConventionalType.hasInstance(type)) {\n // eslint-disable-next-line unicorn/no-unreadable-object-destructuring\n const { emoji, [language]: title } = CommitConventionalType.getData(type);\n return `${withEmoji ? `${emoji} ` : ''}${title}`;\n }\n\n return type;\n}\nexport namespace displayType {\n export interface Options {\n readonly language?: Language;\n readonly withEmoji?: boolean | undefined;\n }\n}\n\nexport function createTransform(config: TransformConfig): CommitTransformFunction<Commit> {\n const displayTypes = new Set(config.displayTypes ?? CommitConventionalType.values());\n const shouldIgnoreType = (type: string | undefined) => type == null || !displayTypes.has(type as CommitConventionalType);\n const shouldIgnoreScope = (scope: null | string | undefined) =>\n config.displayScopes == null ? false : scope != null && !config.displayScopes.includes(scope);\n\n const transform = (commit: Commit, { host, owner, repository, repoUrl }: WriterContext): Commit | false => {\n const isDiscard = commit.notes.length === 0;\n const issues = new Set<string>();\n const notes = commit.notes.map((note) => ({\n ...note,\n title: `${config.withEmoji === false ? '' : '💥 '}BREAKING CHANGES`,\n }));\n const conventionalType =\n commit.type == null\n ? undefined\n : (CommitConventionalType.parse(commit.type) ??\n (GitmojiCode.isValid(commit.type) ? GitmojiCode.toConventionalCommitType(commit.type) : undefined));\n\n if (shouldIgnoreType(conventionalType) && isDiscard) return false;\n\n if (shouldIgnoreScope(commit.scope)) return false;\n\n const type =\n conventionalType == null\n ? null\n : displayType(conventionalType, {\n withEmoji: config.withEmoji,\n });\n\n const scopeIntermediate = commit.scope === '*' ? '' : commit.scope;\n const scope =\n config.scopeDisplayName == null ? null : (displayScope(scopeIntermediate, config.scopeDisplayName) ?? null);\n const hash = typeof commit.hash === 'string' ? commit.hash.slice(0, 7) : commit.hash;\n\n const subject =\n typeof commit.subject === 'string'\n ? (() => {\n let returnValue = commit.subject;\n const url = repository == null ? repoUrl : [host, owner, repository].filter(Boolean).join('/');\n if (url != null) {\n const issueURL = `${url}/issues/`;\n // Issue URLs.\n // eslint-disable-next-line unicorn/prefer-string-replace-all\n returnValue = returnValue.replace(/#(\\d+)/g, (_, issue: string) => {\n issues.add(issue);\n\n return `[#${issue}](${issueURL}${issue})`;\n });\n }\n if (host != null) {\n // User URLs.\n // eslint-disable-next-line unicorn/prefer-string-replace-all\n returnValue = returnValue.replace(/\\B@([\\da-z](?:-?[\\d/a-z]){0,38})/g, (_, username: string) =>\n username.includes('/') ? `@${username}` : `[@${username}](${host}/${username})`,\n );\n }\n return returnValue;\n })()\n : commit.subject;\n\n // Remove references that already appear in the subject\n const references = commit.references.filter((reference) => !issues.has(reference.issue));\n\n // eslint-disable-next-line ts/consistent-type-assertions\n return {\n ...commit,\n body: commit.body,\n footer: commit.footer,\n hash,\n header: commit.header,\n mentions: commit.mentions,\n merge: commit.merge,\n notes,\n references,\n revert: commit.revert,\n scope,\n subject,\n type,\n } as Commit;\n };\n\n return transform as unknown as CommitTransformFunction<Commit>;\n}\n","import { readFileSync } from 'node:fs';\nimport nodePath from 'node:path';\nimport { fileURLToPath } from 'node:url';\n\nimport { type Commit, CommitConventionalType } from './data.js';\nimport { type CommitTransformFunction, createTransform } from './transform.js';\n\nexport interface WriterOptions {\n commitGroupsSort?: false | readonly string[] | string | undefined;\n commitPartial?: string | undefined;\n commitsSort?: false | readonly string[] | string | undefined;\n footerPartial?: string | undefined;\n groupBy?: false | string | undefined;\n headerPartial?: string | undefined;\n mainTemplate?: string | undefined;\n noteGroupsSort?: false | readonly string[] | string | undefined;\n transform?: CommitTransformFunction<Commit> | undefined;\n}\n\nconst _dirname = nodePath.dirname(fileURLToPath(import.meta.url));\nconst basePath = nodePath.resolve(nodePath.dirname(_dirname), './template');\n\nexport const defaultDisplayTypes = CommitConventionalType.findWhere((_) => _.changelog);\n\nexport const createWriterOpts = async (): Promise<WriterOptions> => {\n const mainTemplate = readFileSync(`${basePath}/template.hbs`, 'utf8');\n const headerPartial = readFileSync(`${basePath}/header.hbs`, 'utf8');\n const commitPartial = readFileSync(`${basePath}/commit.hbs`, 'utf8');\n const footerPartial = readFileSync(`${basePath}/footer.hbs`, 'utf8');\n const author = readFileSync(`${basePath}/author.hbs`, 'utf8');\n\n return {\n commitGroupsSort: 'title',\n // eslint-disable-next-line unicorn/prefer-string-replace-all\n commitPartial: commitPartial.replace(/{{gitUserInfo}}/g, author),\n // @ts-ignore FIXME: unknown error\n commitsSort: ['scope', 'subject'],\n footerPartial,\n groupBy: 'type',\n headerPartial,\n mainTemplate,\n noteGroupsSort: 'title',\n transform: createTransform({\n displayTypes: defaultDisplayTypes,\n }),\n };\n};\n","import { gitRawCommitOpts } from './git-raw-commit-opts.js';\nimport { createParserOpts } from './parser.js';\nimport { whatBump } from './whatBump.js';\nimport { createWriterOpts } from './writer.js';\n\nexport { Emoji, GitmojiCode } from './gitmoji.js';\n\nexport async function createPreset() {\n return {\n gitRawCommitOpts,\n parser: createParserOpts(),\n whatBump,\n writer: await createWriterOpts(),\n };\n}\n","export const meta = Object.freeze({\n // @ts-ignore - these variables are injected at build time\n buildNumber: 1 as number, // (typeof __PACKAGE_BUILD_NUMBER__ === 'undefined' ? 0 : __PACKAGE_BUILD_NUMBER__) as number,\n // @ts-ignore - these variables are injected at build time\n name: (typeof __PACKAGE_NAME__ === 'undefined' ? '' : __PACKAGE_NAME__) as string,\n // @ts-ignore - these variables are injected at build time\n version: (typeof __PACKAGE_VERSION__ === 'undefined' ? '' : __PACKAGE_VERSION__) as string,\n});\n"],"mappings":";;;;;;AAAA,MAAa,mBAAmB,EAC9B,QAAQ,6FACV;;;ACMA,MAAa,0BAAyC;CACpD,sBAAsB;EAAC;EAAQ;EAAS;CAAS;CACjD,+BAAe,IAAI,OAGjB,6DAMA,GACF;CACA,cAAc,CAAC,mBAAmB,kBAAkB;CAEpD,sBAAsB,CAAC,UAAU,MAAM;CAEvC,eAAe;AACjB;;;AC2BA,MAAa,gCAAgC;CAC3C,MAAM,aAAa,OAAO,OAAO;EAC/B,OAAO;EACP,OAAO;EACP,IAAI;EACJ,MAAM;EACN,MAAM;EACN,KAAK;EACL,MAAM;EACN,UAAU;EACV,QAAQ;EACR,OAAO;EACP,MAAM;EACN,KAAK;CACP,CAAC;CAED,MAAM,aAAgD,OAAO,OAAO,OAAO,OAAO,UAAU,CAAC,CAAC,MAAM,MAAM,UAAU,KAAK,cAAc,KAAK,CAAC,CAAC;CAC9I,MAAM,gBAAgB,IAAI,IAAI,UAAU;CAExC,MAAM,WAAuE;EAC3E,OAAO;GACL,aAAa;GACb,SAAS;GACT,SAAS;EACX;EACA,OAAO;GACL,aAAa;GACb,SAAS;GACT,SAAS;EACX;EACA,IAAI;GACF,aAAa;GACb,SAAS;GACT,SAAS;EACX;EACA,MAAM;GACJ,aAAa;GACb,SAAS;GACT,SAAS;EACX;EACA,MAAM;GACJ,aAAa;GACb,SAAS;GACT,SAAS;EACX;EACA,KAAK;GACH,aAAa;GACb,SAAS;GACT,SAAS;EACX;EACA,MAAM;GACJ,aAAa;GACb,SAAS;GACT,SAAS;EACX;EACA,UAAU;GACR,aAAa;GACb,SAAS;GACT,SAAS;EACX;EACA,QAAQ;GACN,aAAa;GACb,SAAS;GACT,SAAS;EACX;EACA,OAAO;GACL,aAAa;GACb,SA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;GACd;GACA;GACA,QAAQ,OAAO;GACf;GACA;GACA;EACF;CACF;CAEA,OAAO;AACT;;;ACjHA,MAAM,WAAW,SAAS,QAAQ,cAAc,OAAO,KAAK,GAAG,CAAC;AAChE,MAAM,WAAW,SAAS,QAAQ,SAAS,QAAQ,QAAQ,GAAG,YAAY;AAE1E,MAAa,sBAAsB,uBAAuB,WAAW,MAAM,EAAE,SAAS;AAEtF,MAAa,mBAAmB,YAAoC;CAClE,MAAM,eAAe,aAAa,GAAG,SAAS,gBAAgB,MAAM;CACpE,MAAM,gBAAgB,aAAa,GAAG,SAAS,cAAc,MAAM;CACnE,MAAM,gBAAgB,aAAa,GAAG,SAAS,cAAc,MAAM;CACnE,MAAM,gBAAgB,aAAa,GAAG,SAAS,cAAc,MAAM;CACnE,MAAM,SAAS,aAAa,GAAG,SAAS,cAAc,MAAM;CAE5D,OAAO;EACL,kBAAkB;EAElB,eAAe,cAAc,QAAQ,oBAAoB,MAAM;EAE/D,aAAa,CAAC,SAAS,SAAS;EAChC;EACA,SAAS;EACT;EACA;EACA,gBAAgB;EAChB,WAAW,gBAAgB,EACzB,cAAc,oBAChB,CAAC;CACH;AACF;;;ACvCA,eAAsB,eAAe;CACnC,OAAO;EACL;EACA,QAAQ,iBAAiB;EACzB;EACA,QAAQ,MAAM,iBAAiB;CACjC;AACF;;;ACdA,MAAa,OAAO,OAAO,OAAO;CAEhC,aAAa;CAEb,MAAA;CAEA,SAAA;AACF,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@w5s/conventional-changelog",
|
|
3
|
-
"version": "3.2.
|
|
3
|
+
"version": "3.2.8",
|
|
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",
|
|
@@ -44,5 +44,5 @@
|
|
|
44
44
|
"access": "public"
|
|
45
45
|
},
|
|
46
46
|
"sideEffect": false,
|
|
47
|
-
"gitHead": "
|
|
47
|
+
"gitHead": "e6c63e0164ce2199e59bdca360f4766b6a78584d"
|
|
48
48
|
}
|
package/src/createPreset.ts
CHANGED
package/src/data.ts
CHANGED
|
@@ -1,44 +1,45 @@
|
|
|
1
1
|
export interface Commit {
|
|
2
|
-
merge: Commit.Field;
|
|
3
|
-
header: Commit.Field;
|
|
4
2
|
body: Commit.Field;
|
|
5
3
|
footer: Commit.Field;
|
|
4
|
+
hash: null | string;
|
|
5
|
+
header: Commit.Field;
|
|
6
|
+
mentions: string[];
|
|
7
|
+
merge: Commit.Field;
|
|
6
8
|
notes: Commit.Note[];
|
|
7
9
|
references: Commit.Reference[];
|
|
8
|
-
mentions: string[];
|
|
9
10
|
revert: Commit.Revert | null;
|
|
10
|
-
|
|
11
|
-
subject:
|
|
12
|
-
|
|
13
|
-
hash: string | null;
|
|
11
|
+
scope: null | string;
|
|
12
|
+
subject: null | string;
|
|
13
|
+
type: null | string;
|
|
14
14
|
}
|
|
15
15
|
|
|
16
16
|
export namespace Commit {
|
|
17
|
-
export type Field =
|
|
17
|
+
export type Field = null | string;
|
|
18
18
|
|
|
19
19
|
export interface Note {
|
|
20
|
-
title: string;
|
|
21
20
|
text: string;
|
|
21
|
+
title: string;
|
|
22
22
|
}
|
|
23
23
|
|
|
24
24
|
export interface Reference {
|
|
25
|
-
issue: string;
|
|
26
25
|
action: Field;
|
|
26
|
+
issue: string;
|
|
27
27
|
owner: Field;
|
|
28
|
-
repository: Field;
|
|
29
28
|
prefix: string;
|
|
30
29
|
raw: string;
|
|
30
|
+
repository: Field;
|
|
31
31
|
}
|
|
32
32
|
|
|
33
33
|
export interface Revert {
|
|
34
|
+
[field: string]: Field | undefined;
|
|
34
35
|
hash?: Field | undefined;
|
|
35
36
|
header?: Field | undefined;
|
|
36
|
-
[field: string]: Field | undefined;
|
|
37
37
|
}
|
|
38
38
|
}
|
|
39
39
|
|
|
40
40
|
export type CommitConventionalType =
|
|
41
41
|
| 'build'
|
|
42
|
+
| 'chore'
|
|
42
43
|
| 'ci'
|
|
43
44
|
| 'docs'
|
|
44
45
|
| 'feat'
|
|
@@ -48,12 +49,12 @@ export type CommitConventionalType =
|
|
|
48
49
|
| 'revert'
|
|
49
50
|
| 'style'
|
|
50
51
|
| 'test'
|
|
51
|
-
| 'wip'
|
|
52
|
-
| 'chore';
|
|
52
|
+
| 'wip';
|
|
53
53
|
|
|
54
54
|
export const CommitConventionalType = (() => {
|
|
55
55
|
const enumObject = Object.freeze({
|
|
56
56
|
Build: 'build',
|
|
57
|
+
Chore: 'chore',
|
|
57
58
|
CI: 'ci',
|
|
58
59
|
Docs: 'docs',
|
|
59
60
|
Feat: 'feat',
|
|
@@ -64,72 +65,71 @@ export const CommitConventionalType = (() => {
|
|
|
64
65
|
Style: 'style',
|
|
65
66
|
Test: 'test',
|
|
66
67
|
WIP: 'wip',
|
|
67
|
-
Chore: 'chore',
|
|
68
68
|
});
|
|
69
69
|
// eslint-disable-next-line unicorn/no-array-sort
|
|
70
|
-
const enumValues: readonly CommitConventionalType[] = Object.freeze(Object.values(enumObject).sort());
|
|
70
|
+
const enumValues: readonly CommitConventionalType[] = Object.freeze(Object.values(enumObject).sort((left, right) => left.localeCompare(right)));
|
|
71
71
|
const enumValuesSet = new Set(enumValues);
|
|
72
72
|
|
|
73
73
|
const typeData: Record<CommitConventionalType, CommitConventionalTypeData> = {
|
|
74
|
-
feat: {
|
|
75
|
-
'emoji': '✨',
|
|
76
|
-
'en-US': 'Features',
|
|
77
|
-
'changelog': true,
|
|
78
|
-
},
|
|
79
|
-
fix: {
|
|
80
|
-
'emoji': '🐛',
|
|
81
|
-
'en-US': 'Bug Fixes',
|
|
82
|
-
'changelog': true,
|
|
83
|
-
},
|
|
84
74
|
build: {
|
|
75
|
+
'changelog': false,
|
|
85
76
|
'emoji': '👷',
|
|
86
77
|
'en-US': 'Build System',
|
|
87
|
-
'changelog': false,
|
|
88
78
|
},
|
|
89
79
|
chore: {
|
|
80
|
+
'changelog': false,
|
|
90
81
|
'emoji': '🎫',
|
|
91
82
|
'en-US': 'Chores',
|
|
92
|
-
'changelog': false,
|
|
93
83
|
},
|
|
94
84
|
ci: {
|
|
85
|
+
'changelog': false,
|
|
95
86
|
'emoji': '🔧',
|
|
96
87
|
'en-US': 'Continuous Integration',
|
|
97
|
-
'changelog': false,
|
|
98
88
|
},
|
|
99
89
|
docs: {
|
|
90
|
+
'changelog': false,
|
|
100
91
|
'emoji': '📝',
|
|
101
92
|
'en-US': 'Documentation',
|
|
102
|
-
'changelog': false,
|
|
103
93
|
},
|
|
104
|
-
|
|
105
|
-
'
|
|
106
|
-
'
|
|
107
|
-
'
|
|
94
|
+
feat: {
|
|
95
|
+
'changelog': true,
|
|
96
|
+
'emoji': '✨',
|
|
97
|
+
'en-US': 'Features',
|
|
98
|
+
},
|
|
99
|
+
fix: {
|
|
100
|
+
'changelog': true,
|
|
101
|
+
'emoji': '🐛',
|
|
102
|
+
'en-US': 'Bug Fixes',
|
|
108
103
|
},
|
|
109
104
|
perf: {
|
|
105
|
+
'changelog': true,
|
|
110
106
|
'emoji': '⚡',
|
|
111
107
|
'en-US': 'Performance Improvements',
|
|
112
|
-
'changelog': true,
|
|
113
108
|
},
|
|
114
109
|
refactor: {
|
|
110
|
+
'changelog': false,
|
|
115
111
|
'emoji': '♻',
|
|
116
112
|
'en-US': 'Code Refactoring',
|
|
117
|
-
'changelog': false,
|
|
118
113
|
},
|
|
119
114
|
revert: {
|
|
115
|
+
'changelog': true,
|
|
120
116
|
'emoji': '⏪',
|
|
121
117
|
'en-US': 'Reverts',
|
|
122
|
-
'changelog': true,
|
|
123
118
|
},
|
|
124
119
|
style: {
|
|
120
|
+
'changelog': false,
|
|
125
121
|
'emoji': '💄',
|
|
126
122
|
'en-US': 'Styles',
|
|
123
|
+
},
|
|
124
|
+
test: {
|
|
127
125
|
'changelog': false,
|
|
126
|
+
'emoji': '✅',
|
|
127
|
+
'en-US': 'Tests',
|
|
128
128
|
},
|
|
129
129
|
wip: {
|
|
130
|
+
'changelog': false,
|
|
130
131
|
'emoji': '🚧',
|
|
131
132
|
'en-US': 'Work in progress',
|
|
132
|
-
'changelog': false,
|
|
133
133
|
},
|
|
134
134
|
};
|
|
135
135
|
|
|
@@ -153,11 +153,11 @@ export const CommitConventionalType = (() => {
|
|
|
153
153
|
return enumValues.filter((enumValue) => predicate(getData(enumValue)));
|
|
154
154
|
}
|
|
155
155
|
|
|
156
|
-
return { ...enumObject,
|
|
156
|
+
return { ...enumObject, findWhere, getData, hasInstance, parse, values };
|
|
157
157
|
})();
|
|
158
158
|
|
|
159
159
|
export interface CommitConventionalTypeData {
|
|
160
|
+
'changelog': boolean;
|
|
160
161
|
'emoji': string;
|
|
161
162
|
'en-US': string;
|
|
162
|
-
'changelog': boolean;
|
|
163
163
|
}
|
package/src/gitmoji.ts
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
/* eslint-disable unicorn/prefer-spread */
|
|
2
1
|
import emojiRegexp from 'emoji-regex';
|
|
3
2
|
import { type Gitmoji, gitmojis } from 'gitmojis';
|
|
3
|
+
|
|
4
4
|
import type { CommitConventionalType } from './data.js';
|
|
5
5
|
|
|
6
|
-
export type Emoji = Emoji.
|
|
6
|
+
export type Emoji = Emoji.Text | Emoji.Unicode;
|
|
7
7
|
export namespace Emoji {
|
|
8
|
-
export type Unicode = string & { '@@EmojiStyle': 'unicode' };
|
|
9
8
|
export type Text = string & { '@@EmojiStyle': 'text' };
|
|
9
|
+
export type Unicode = string & { '@@EmojiStyle': 'unicode' };
|
|
10
10
|
}
|
|
11
11
|
|
|
12
12
|
const reEmojiUnicode = emojiRegexp();
|
|
@@ -16,16 +16,16 @@ const reMatchOnly = (input: RegExp) => new RegExp(`^${input.source}$`, '');
|
|
|
16
16
|
const _reEmojiUnicode = reMatchOnly(reEmojiUnicode);
|
|
17
17
|
const _reEmojiText = reMatchOnly(reEmojiText);
|
|
18
18
|
|
|
19
|
-
function
|
|
20
|
-
return
|
|
19
|
+
function hasInstance(anyValue: string): anyValue is Emoji {
|
|
20
|
+
return isText(anyValue) || isUnicode(anyValue);
|
|
21
21
|
}
|
|
22
22
|
|
|
23
23
|
function isText(anyValue: string): anyValue is Emoji.Text {
|
|
24
24
|
return _reEmojiText.test(anyValue);
|
|
25
25
|
}
|
|
26
26
|
|
|
27
|
-
function
|
|
28
|
-
return
|
|
27
|
+
function isUnicode(anyValue: string): anyValue is Emoji.Unicode {
|
|
28
|
+
return _reEmojiUnicode.test(anyValue);
|
|
29
29
|
}
|
|
30
30
|
|
|
31
31
|
/**
|
|
@@ -41,8 +41,8 @@ export const Emoji = Object.freeze({
|
|
|
41
41
|
|
|
42
42
|
export type GitmojiCode = Emoji & { '@@Gitmoji': true };
|
|
43
43
|
export namespace GitmojiCode {
|
|
44
|
-
export type Unicode = Emoji.Unicode & { '@@Gitmoji': true };
|
|
45
44
|
export type Emoji = Emoji.Text & { '@@Gitmoji': true };
|
|
45
|
+
export type Unicode = Emoji.Unicode & { '@@Gitmoji': true };
|
|
46
46
|
}
|
|
47
47
|
|
|
48
48
|
const allGitmojiCodes = new Set(
|
|
@@ -66,18 +66,18 @@ function isValid(anyValue: string): anyValue is GitmojiCode {
|
|
|
66
66
|
const defaultType = 'chore';
|
|
67
67
|
const conversionMap: ReadonlyMap<GitmojiCode, CommitConventionalType> = (() => {
|
|
68
68
|
const data: Record<CommitConventionalType, GitmojiCode.Unicode[]> = {
|
|
69
|
+
build: [] as GitmojiCode.Unicode[],
|
|
70
|
+
chore: ['🔧'] as GitmojiCode.Unicode[],
|
|
71
|
+
ci: ['👷', '💚'] as GitmojiCode.Unicode[],
|
|
72
|
+
docs: ['📝'] as GitmojiCode.Unicode[],
|
|
69
73
|
feat: ['✨', '♿️', '🚸'] as GitmojiCode.Unicode[],
|
|
70
74
|
fix: ['🐛'] as GitmojiCode.Unicode[],
|
|
71
|
-
docs: ['📝'] as GitmojiCode.Unicode[],
|
|
72
|
-
style: ['🎨', '🚨'] as GitmojiCode.Unicode[],
|
|
73
|
-
refactor: ['♻️', '🏗️'] as GitmojiCode.Unicode[],
|
|
74
|
-
test: ['✅', '🧪'] as GitmojiCode.Unicode[],
|
|
75
75
|
perf: ['⚡️'] as GitmojiCode.Unicode[],
|
|
76
|
+
refactor: ['♻️', '🏗️'] as GitmojiCode.Unicode[],
|
|
76
77
|
revert: ['⏪️'] as GitmojiCode.Unicode[],
|
|
77
|
-
|
|
78
|
+
style: ['🎨', '🚨'] as GitmojiCode.Unicode[],
|
|
79
|
+
test: ['✅', '🧪'] as GitmojiCode.Unicode[],
|
|
78
80
|
wip: ['🚧'] as GitmojiCode.Unicode[],
|
|
79
|
-
build: [] as GitmojiCode.Unicode[],
|
|
80
|
-
chore: ['🔧'] as GitmojiCode.Unicode[],
|
|
81
81
|
};
|
|
82
82
|
|
|
83
83
|
const entries = Array.from<[CommitConventionalType, GitmojiCode.Unicode[]]>(
|
package/src/index.ts
CHANGED
package/src/meta.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
export const meta = Object.freeze({
|
|
2
|
+
// @ts-ignore - these variables are injected at build time
|
|
3
|
+
buildNumber: 1 as number, // (typeof __PACKAGE_BUILD_NUMBER__ === 'undefined' ? 0 : __PACKAGE_BUILD_NUMBER__) as number,
|
|
2
4
|
// @ts-ignore - these variables are injected at build time
|
|
3
5
|
name: (typeof __PACKAGE_NAME__ === 'undefined' ? '' : __PACKAGE_NAME__) as string,
|
|
4
6
|
// @ts-ignore - these variables are injected at build time
|
|
5
7
|
version: (typeof __PACKAGE_VERSION__ === 'undefined' ? '' : __PACKAGE_VERSION__) as string,
|
|
6
|
-
// @ts-ignore - these variables are injected at build time
|
|
7
|
-
buildNumber: 1 as number, // (typeof __PACKAGE_BUILD_NUMBER__ === 'undefined' ? 0 : __PACKAGE_BUILD_NUMBER__) as number,
|
|
8
8
|
});
|
package/src/parser.ts
CHANGED
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
export interface ParserOptions {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
revertCorrespondence?:
|
|
6
|
-
|
|
2
|
+
headerCorrespondence?: null | string | string[];
|
|
3
|
+
headerPattern?: null | RegExp | string;
|
|
4
|
+
noteKeywords?: null | string | string[];
|
|
5
|
+
revertCorrespondence?: null | string | string[];
|
|
6
|
+
revertPattern?: null | RegExp | string;
|
|
7
7
|
}
|
|
8
8
|
|
|
9
9
|
export const createParserOpts = (): ParserOptions => ({
|
|
10
|
+
headerCorrespondence: ['type', 'scope', 'subject'],
|
|
10
11
|
headerPattern: new RegExp(
|
|
11
12
|
// Type
|
|
12
13
|
// eslint-disable-next-line unicorn/prefer-string-raw
|
|
@@ -18,10 +19,9 @@ export const createParserOpts = (): ParserOptions => ({
|
|
|
18
19
|
`(?<subject>.*)$`,
|
|
19
20
|
'u',
|
|
20
21
|
),
|
|
21
|
-
headerCorrespondence: ['type', 'scope', 'subject'],
|
|
22
|
-
// eslint-disable-next-line e18e/prefer-static-regex
|
|
23
|
-
revertPattern: /^(?:revert|revert:)\s"?([\S\s]+?)"?\s*this reverts commit (\w*)\./i,
|
|
24
22
|
noteKeywords: ['BREAKING CHANGE', 'BREAKING CHANGES'],
|
|
25
23
|
// revertPattern: /revert:\s([\S\s]*?)\s*this reverts commit (\w*)\./i,
|
|
26
24
|
revertCorrespondence: [`header`, `hash`],
|
|
25
|
+
// eslint-disable-next-line e18e/prefer-static-regex
|
|
26
|
+
revertPattern: /^(?:revert|revert:)\s"?([\S\s]+?)"?\s*this reverts commit (\w*)\./i,
|
|
27
27
|
});
|
package/src/transform.ts
CHANGED
|
@@ -1,38 +1,39 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { type Commit, CommitConventionalType } from './data.js';
|
|
2
2
|
import { GitmojiCode } from './gitmoji.js';
|
|
3
3
|
|
|
4
|
+
export interface CommitTransformFunction<TCommit extends Commit = Commit> {
|
|
5
|
+
(commit: Commit, context: WriterContext, ...args: unknown[]): false | TCommit;
|
|
6
|
+
}
|
|
7
|
+
|
|
4
8
|
export type Language = 'en-US';
|
|
5
9
|
|
|
6
10
|
export interface TransformConfig {
|
|
7
|
-
scopeDisplayName?: Record<string, string>;
|
|
8
|
-
displayTypes?: CommitConventionalType[];
|
|
9
11
|
displayScopes?: string[];
|
|
12
|
+
displayTypes?: CommitConventionalType[];
|
|
13
|
+
language?: Language;
|
|
14
|
+
scopeDisplayName?: Record<string, string>;
|
|
10
15
|
showAuthor?: boolean;
|
|
11
16
|
withEmoji?: boolean;
|
|
12
|
-
language?: Language;
|
|
13
17
|
}
|
|
14
18
|
|
|
15
19
|
export interface WriterContext {
|
|
16
|
-
repository?: string | undefined;
|
|
17
20
|
host?: string | undefined;
|
|
18
21
|
owner?: string | undefined;
|
|
22
|
+
repository?: string | undefined;
|
|
19
23
|
repoUrl?: string | undefined;
|
|
20
24
|
}
|
|
21
25
|
|
|
22
|
-
export
|
|
23
|
-
(commit: Commit, context: WriterContext, ...args: unknown[]): TCommit | false;
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
export function displayScope(scope: string | null | undefined, scopeDisplayNameMap: Record<string, string>) {
|
|
26
|
+
export function displayScope(scope: null | string | undefined, scopeDisplayNameMap: Record<string, string>) {
|
|
27
27
|
return scope == null || scope.length === 0
|
|
28
28
|
? scopeDisplayNameMap['*']
|
|
29
29
|
: scopeDisplayNameMap[scope] ?? scope;
|
|
30
30
|
}
|
|
31
31
|
|
|
32
32
|
export function displayType(type: string, options: displayType.Options = {}): string {
|
|
33
|
-
const {
|
|
33
|
+
const { language = 'en-US', withEmoji = true } = options;
|
|
34
34
|
|
|
35
35
|
if (CommitConventionalType.hasInstance(type)) {
|
|
36
|
+
// eslint-disable-next-line unicorn/no-unreadable-object-destructuring
|
|
36
37
|
const { emoji, [language]: title } = CommitConventionalType.getData(type);
|
|
37
38
|
return `${withEmoji ? `${emoji} ` : ''}${title}`;
|
|
38
39
|
}
|
|
@@ -41,19 +42,19 @@ export function displayType(type: string, options: displayType.Options = {}): st
|
|
|
41
42
|
}
|
|
42
43
|
export namespace displayType {
|
|
43
44
|
export interface Options {
|
|
44
|
-
readonly withEmoji?: boolean | undefined;
|
|
45
45
|
readonly language?: Language;
|
|
46
|
+
readonly withEmoji?: boolean | undefined;
|
|
46
47
|
}
|
|
47
48
|
}
|
|
48
49
|
|
|
49
50
|
export function createTransform(config: TransformConfig): CommitTransformFunction<Commit> {
|
|
50
51
|
const displayTypes = new Set(config.displayTypes ?? CommitConventionalType.values());
|
|
51
|
-
const
|
|
52
|
-
const
|
|
52
|
+
const shouldIgnoreType = (type: string | undefined) => type == null || !displayTypes.has(type as CommitConventionalType);
|
|
53
|
+
const shouldIgnoreScope = (scope: null | string | undefined) =>
|
|
53
54
|
config.displayScopes == null ? false : scope != null && !config.displayScopes.includes(scope);
|
|
54
55
|
|
|
55
|
-
const transform = (commit: Commit, {
|
|
56
|
-
const
|
|
56
|
+
const transform = (commit: Commit, { host, owner, repository, repoUrl }: WriterContext): Commit | false => {
|
|
57
|
+
const isDiscard = commit.notes.length === 0;
|
|
57
58
|
const issues = new Set<string>();
|
|
58
59
|
const notes = commit.notes.map((note) => ({
|
|
59
60
|
...note,
|
|
@@ -65,7 +66,9 @@ export function createTransform(config: TransformConfig): CommitTransformFunctio
|
|
|
65
66
|
: (CommitConventionalType.parse(commit.type) ??
|
|
66
67
|
(GitmojiCode.isValid(commit.type) ? GitmojiCode.toConventionalCommitType(commit.type) : undefined));
|
|
67
68
|
|
|
68
|
-
if (
|
|
69
|
+
if (shouldIgnoreType(conventionalType) && isDiscard) return false;
|
|
70
|
+
|
|
71
|
+
if (shouldIgnoreScope(commit.scope)) return false;
|
|
69
72
|
|
|
70
73
|
const type =
|
|
71
74
|
conventionalType == null
|
|
@@ -74,8 +77,6 @@ export function createTransform(config: TransformConfig): CommitTransformFunctio
|
|
|
74
77
|
withEmoji: config.withEmoji,
|
|
75
78
|
});
|
|
76
79
|
|
|
77
|
-
if (ignoreScope(commit.scope)) return false;
|
|
78
|
-
|
|
79
80
|
const scopeIntermediate = commit.scope === '*' ? '' : commit.scope;
|
|
80
81
|
const scope =
|
|
81
82
|
config.scopeDisplayName == null ? null : (displayScope(scopeIntermediate, config.scopeDisplayName) ?? null);
|
|
@@ -113,18 +114,18 @@ export function createTransform(config: TransformConfig): CommitTransformFunctio
|
|
|
113
114
|
// eslint-disable-next-line ts/consistent-type-assertions
|
|
114
115
|
return {
|
|
115
116
|
...commit,
|
|
116
|
-
type,
|
|
117
|
-
hash,
|
|
118
|
-
scope,
|
|
119
|
-
subject,
|
|
120
|
-
references,
|
|
121
|
-
header: commit.header,
|
|
122
117
|
body: commit.body,
|
|
123
118
|
footer: commit.footer,
|
|
119
|
+
hash,
|
|
120
|
+
header: commit.header,
|
|
121
|
+
mentions: commit.mentions,
|
|
124
122
|
merge: commit.merge,
|
|
125
|
-
revert: commit.revert,
|
|
126
123
|
notes,
|
|
127
|
-
|
|
124
|
+
references,
|
|
125
|
+
revert: commit.revert,
|
|
126
|
+
scope,
|
|
127
|
+
subject,
|
|
128
|
+
type,
|
|
128
129
|
} as Commit;
|
|
129
130
|
};
|
|
130
131
|
|
package/src/whatBump.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { type Commit, CommitConventionalType } from './data.js';
|
|
2
2
|
import { GitmojiCode } from './gitmoji.js';
|
|
3
3
|
|
|
4
4
|
function toConventionalCommitType(text: string) {
|
|
@@ -14,7 +14,7 @@ export const whatBump = (commits: ReadonlyArray<Commit>) => {
|
|
|
14
14
|
let breakings = 0;
|
|
15
15
|
let features = 0;
|
|
16
16
|
|
|
17
|
-
for (const {
|
|
17
|
+
for (const { notes, type } of commits) {
|
|
18
18
|
const conventionalType = type == null ? type : toConventionalCommitType(type);
|
|
19
19
|
if (notes.length > 0) {
|
|
20
20
|
breakings += notes.length;
|
package/src/writer.ts
CHANGED
|
@@ -1,22 +1,23 @@
|
|
|
1
1
|
import { readFileSync } from 'node:fs';
|
|
2
2
|
import nodePath from 'node:path';
|
|
3
3
|
import { fileURLToPath } from 'node:url';
|
|
4
|
-
|
|
5
|
-
import {
|
|
4
|
+
|
|
5
|
+
import { type Commit, CommitConventionalType } from './data.js';
|
|
6
|
+
import { type CommitTransformFunction, createTransform } from './transform.js';
|
|
6
7
|
|
|
7
8
|
export interface WriterOptions {
|
|
8
|
-
|
|
9
|
-
groupBy?: string | false | undefined;
|
|
10
|
-
commitGroupsSort?: string | readonly string[] | false | undefined;
|
|
11
|
-
commitsSort?: string | readonly string[] | false | undefined;
|
|
12
|
-
noteGroupsSort?: string | readonly string[] | false | undefined;
|
|
13
|
-
mainTemplate?: string | undefined;
|
|
14
|
-
headerPartial?: string | undefined;
|
|
9
|
+
commitGroupsSort?: false | readonly string[] | string | undefined;
|
|
15
10
|
commitPartial?: string | undefined;
|
|
11
|
+
commitsSort?: false | readonly string[] | string | undefined;
|
|
16
12
|
footerPartial?: string | undefined;
|
|
13
|
+
groupBy?: false | string | undefined;
|
|
14
|
+
headerPartial?: string | undefined;
|
|
15
|
+
mainTemplate?: string | undefined;
|
|
16
|
+
noteGroupsSort?: false | readonly string[] | string | undefined;
|
|
17
|
+
transform?: CommitTransformFunction<Commit> | undefined;
|
|
17
18
|
}
|
|
18
19
|
|
|
19
|
-
const _dirname =
|
|
20
|
+
const _dirname = nodePath.dirname(fileURLToPath(import.meta.url));
|
|
20
21
|
const basePath = nodePath.resolve(nodePath.dirname(_dirname), './template');
|
|
21
22
|
|
|
22
23
|
export const defaultDisplayTypes = CommitConventionalType.findWhere((_) => _.changelog);
|
|
@@ -29,18 +30,18 @@ export const createWriterOpts = async (): Promise<WriterOptions> => {
|
|
|
29
30
|
const author = readFileSync(`${basePath}/author.hbs`, 'utf8');
|
|
30
31
|
|
|
31
32
|
return {
|
|
32
|
-
transform: createTransform({
|
|
33
|
-
displayTypes: defaultDisplayTypes,
|
|
34
|
-
}),
|
|
35
|
-
groupBy: 'type',
|
|
36
33
|
commitGroupsSort: 'title',
|
|
37
|
-
// @ts-ignore FIXME: unknown error
|
|
38
|
-
commitsSort: ['scope', 'subject'],
|
|
39
|
-
noteGroupsSort: 'title',
|
|
40
|
-
mainTemplate,
|
|
41
|
-
headerPartial,
|
|
42
34
|
// eslint-disable-next-line unicorn/prefer-string-replace-all
|
|
43
35
|
commitPartial: commitPartial.replace(/{{gitUserInfo}}/g, author),
|
|
36
|
+
// @ts-ignore FIXME: unknown error
|
|
37
|
+
commitsSort: ['scope', 'subject'],
|
|
44
38
|
footerPartial,
|
|
39
|
+
groupBy: 'type',
|
|
40
|
+
headerPartial,
|
|
41
|
+
mainTemplate,
|
|
42
|
+
noteGroupsSort: 'title',
|
|
43
|
+
transform: createTransform({
|
|
44
|
+
displayTypes: defaultDisplayTypes,
|
|
45
|
+
}),
|
|
45
46
|
};
|
|
46
47
|
};
|