@w5s/conventional-changelog 3.1.4 → 3.1.7
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 +22 -7
- package/dist/index.js +65 -59
- package/dist/index.js.map +1 -1
- package/package.json +4 -4
- package/src/gitmoji.ts +92 -76
package/dist/index.d.ts
CHANGED
|
@@ -69,18 +69,26 @@ interface CommitConventionalTypeData {
|
|
|
69
69
|
//#region src/gitmoji.d.ts
|
|
70
70
|
type Emoji = Emoji.Unicode | Emoji.Text;
|
|
71
71
|
declare namespace Emoji {
|
|
72
|
-
const reEmojiUnicode: RegExp;
|
|
73
|
-
const reEmojiText: RegExp;
|
|
74
72
|
type Unicode = string & {
|
|
75
73
|
'@@EmojiStyle': 'unicode';
|
|
76
74
|
};
|
|
77
75
|
type Text = string & {
|
|
78
76
|
'@@EmojiStyle': 'text';
|
|
79
77
|
};
|
|
80
|
-
function isUnicode(anyValue: string): anyValue is Unicode;
|
|
81
|
-
function isText(anyValue: string): anyValue is Text;
|
|
82
|
-
function hasInstance(anyValue: string): anyValue is Emoji;
|
|
83
78
|
}
|
|
79
|
+
declare function isUnicode(anyValue: string): anyValue is Emoji.Unicode;
|
|
80
|
+
declare function isText(anyValue: string): anyValue is Emoji.Text;
|
|
81
|
+
declare function hasInstance(anyValue: string): anyValue is Emoji;
|
|
82
|
+
/**
|
|
83
|
+
* @namespace
|
|
84
|
+
*/
|
|
85
|
+
declare const Emoji: Readonly<{
|
|
86
|
+
hasInstance: typeof hasInstance;
|
|
87
|
+
isText: typeof isText;
|
|
88
|
+
isUnicode: typeof isUnicode;
|
|
89
|
+
reEmojiText: RegExp;
|
|
90
|
+
reEmojiUnicode: RegExp;
|
|
91
|
+
}>;
|
|
84
92
|
type GitmojiCode = Emoji & {
|
|
85
93
|
'@@Gitmoji': true;
|
|
86
94
|
};
|
|
@@ -91,9 +99,16 @@ declare namespace GitmojiCode {
|
|
|
91
99
|
type Emoji = Emoji.Text & {
|
|
92
100
|
'@@Gitmoji': true;
|
|
93
101
|
};
|
|
94
|
-
function isValid(anyValue: string): anyValue is GitmojiCode;
|
|
95
|
-
function toConventionalCommitType(gitmoji: GitmojiCode): CommitConventionalType;
|
|
96
102
|
}
|
|
103
|
+
declare function isValid(anyValue: string): anyValue is GitmojiCode;
|
|
104
|
+
declare function toConventionalCommitType(gitmoji: GitmojiCode): CommitConventionalType;
|
|
105
|
+
/**
|
|
106
|
+
* @namespace
|
|
107
|
+
*/
|
|
108
|
+
declare const GitmojiCode: Readonly<{
|
|
109
|
+
isValid: typeof isValid;
|
|
110
|
+
toConventionalCommitType: typeof toConventionalCommitType;
|
|
111
|
+
}>;
|
|
97
112
|
//#endregion
|
|
98
113
|
//#region src/parser.d.ts
|
|
99
114
|
interface ParserOptions {
|
package/dist/index.js
CHANGED
|
@@ -6,69 +6,75 @@ import { fileURLToPath } from "node:url";
|
|
|
6
6
|
//#region src/meta.ts
|
|
7
7
|
const meta = Object.freeze({
|
|
8
8
|
name: "@w5s/conventional-changelog",
|
|
9
|
-
version: "3.1.
|
|
9
|
+
version: "3.1.7",
|
|
10
10
|
buildNumber: 1
|
|
11
11
|
});
|
|
12
12
|
//#endregion
|
|
13
13
|
//#region src/gitmoji.ts
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
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
|
+
});
|
|
72
78
|
//#endregion
|
|
73
79
|
//#region src/git-raw-commit-opts.ts
|
|
74
80
|
const gitRawCommitOpts = { format: "%B%n-hash-%n%H%n-gitTags-%n%d%n-committerDate-%n%ci%n-authorName-%n%an%n-authorEmail-%n%ae" };
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":[],"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 const reEmojiUnicode = emojiRegexp();\n\n export const reEmojiText = /:\\w*:/;\n\n const reMatchOnly = (input: RegExp) => new RegExp(`^${input.source}$`, '');\n const _reEmojiUnicode = reMatchOnly(reEmojiUnicode);\n const _reEmojiText = reMatchOnly(reEmojiText);\n\n export type Unicode = string & { '@@EmojiStyle': 'unicode' };\n export type Text = string & { '@@EmojiStyle': 'text' };\n\n export function isUnicode(anyValue: string): anyValue is Unicode {\n return _reEmojiUnicode.test(anyValue);\n }\n\n export function isText(anyValue: string): anyValue is Text {\n return _reEmojiText.test(anyValue);\n }\n\n export function hasInstance(anyValue: string): anyValue is Emoji {\n return isText(anyValue) || isUnicode(anyValue);\n }\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 // export const reEmoji = emojiRegexp();\n\n const allGitmojiCodes = new Set(\n gitmojis\n .map((gitmoji) => gitmoji.code as GitmojiCode)\n .concat(gitmojis.map((gitmoji) => gitmoji.emoji as GitmojiCode)),\n );\n const index = {\n // code: createIndex(gitmojis, 'code'),\n emoji: createIndex(gitmojis, 'emoji'),\n };\n\n function 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\n export function isValid(anyValue: string): anyValue is GitmojiCode {\n return allGitmojiCodes.has(anyValue as GitmojiCode);\n }\n\n const defaultType = 'chore';\n const 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\n export function toConventionalCommitType(gitmoji: GitmojiCode): CommitConventionalType {\n return conversionMap.get(gitmoji) ?? defaultType;\n }\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 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] == null\n ? scope\n : scopeDisplayNameMap[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 == null ? CommitConventionalType.values() : config.displayTypes);\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;CACd,CAAC;;;ACDK,IAAA;;CACE,MAAM,iBAAA,OAAA,iBAAiB,aAAa;CAEpC,MAAM,cAAA,OAAA,cAAc;CAE3B,MAAM,eAAe,UAAkB,IAAI,OAAO,IAAI,MAAM,OAAO,IAAI,GAAG;CAC1E,MAAM,kBAAkB,YAAY,eAAe;CACnD,MAAM,eAAe,YAAY,YAAY;CAKtC,SAAS,UAAU,UAAuC;EAC/D,OAAO,gBAAgB,KAAK,SAAS;;;CAGhC,SAAS,OAAO,UAAoC;EACzD,OAAO,aAAa,KAAK,SAAS;;;CAG7B,SAAS,YAAY,UAAqC;EAC/D,OAAO,OAAO,SAAS,IAAI,UAAU,SAAS;;;yBAEjD;AAGM,IAAA;;CAML,MAAM,kBAAkB,IAAI,IAC1B,SACG,KAAK,YAAY,QAAQ,KAAoB,CAC7C,OAAO,SAAS,KAAK,YAAY,QAAQ,MAAqB,CAAC,CACnE;CACD,MAAM,QA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KAAK,SAAS,IAAI,KAAK,GAAG,SAAS,GAC9E;GAEH,OAAO;MACL,GACJ,OAAO;EAGb,MAAM,aAAa,OAAO,WAAW,QAAQ,cAAc,CAAC,OAAO,IAAI,UAAU,MAAM,CAAC;EAGxF,OAAO;GACL,GAAG;GACH;GACA;GACA;GACA;GACA;GACA,QAAQ,OAAO;GACf,MAAM,OAAO;GACb,QAAQ,OAAO;GACf,OAAO,OAAO;GACd,QAAQ,OAAO;GACf;GACA,UAAU,OAAO;GAClB;;CAGH,OAAO;;;;AClHT,MAAM,WAAW,OAAO,cAAc,cAAc,SAAS,QAAQ,cAAc,OAAO,KAAK,IAAI,CAAC,GAAG;AACvG,MAAM,WAAW,SAAS,QAAQ,SAAS,QAAQ,SAAS,EAAE,aAAa;AAE3E,MAAa,sBAAsB,uBAAuB,WAAW,MAAM,EAAE,UAAU;AAEvF,MAAa,mBAAmB,YAAoC;CAClE,MAAM,eAAe,aAAa,GAAG,SAAS,gBAAgB,OAAO;CACrE,MAAM,gBAAgB,aAAa,GAAG,SAAS,cAAc,OAAO;CACpE,MAAM,gBAAgB,aAAa,GAAG,SAAS,cAAc,OAAO;CACpE,MAAM,gBAAgB,aAAa,GAAG,SAAS,cAAc,OAAO;CACpE,MAAM,SAAS,aAAa,GAAG,SAAS,cAAc,OAAO;CAE7D,OAAO;EACL,WAAW,gBAAgB,EACzB,cAAc,qBACf,CAAC;EACF,SAAS;EACT,kBAAkB;EAElB,aAAa,CAAC,SAAS,UAAU;EACjC,gBAAgB;EAChB;EACA;EAEA,eAAe,cAAc,QAAQ,oBAAoB,OAAO;EAChE;EACD;;;;ACrCH,eAAsB,eAAe;CACnC,OAAO;EACL;EACA,QAAQ,kBAAkB;EAC1B,QAAQ,MAAM,kBAAkB;EAChC;EACD"}
|
|
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 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] == null\n ? scope\n : scopeDisplayNameMap[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 == null ? CommitConventionalType.values() : config.displayTypes);\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,eAAe,YAAY,WAAW;AAE5C,SAAS,UAAU,UAA6C;CAC9D,OAAO,gBAAgB,KAAK,QAAQ;AACtC;AAEA,SAAS,OAAO,UAA0C;CACxD,OAAO,aAAa,KAAK,QAAQ;AACnC;AAEA,SAAS,YAAY,UAAqC;CACxD,OAAO,OAAO,QAAQ,KAAK,UAAU,QAAQ;AAC/C;;;;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AO;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"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@w5s/conventional-changelog",
|
|
3
|
-
"version": "3.1.
|
|
3
|
+
"version": "3.1.7",
|
|
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",
|
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
},
|
|
10
10
|
"repository": {
|
|
11
11
|
"type": "git",
|
|
12
|
-
"url": "git@github.com:w5s/project-config.git",
|
|
12
|
+
"url": "git+ssh@github.com:w5s/project-config.git",
|
|
13
13
|
"directory": "packages/conventional-changelog"
|
|
14
14
|
},
|
|
15
15
|
"license": "MIT",
|
|
@@ -38,7 +38,7 @@
|
|
|
38
38
|
"postpack": "clean-package restore"
|
|
39
39
|
},
|
|
40
40
|
"dependencies": {
|
|
41
|
-
"@commitlint/types": "^
|
|
41
|
+
"@commitlint/types": "^21.0.0",
|
|
42
42
|
"emoji-regex": "^10.2.1",
|
|
43
43
|
"gitmojis": "^3.13.4"
|
|
44
44
|
},
|
|
@@ -49,5 +49,5 @@
|
|
|
49
49
|
"access": "public"
|
|
50
50
|
},
|
|
51
51
|
"sideEffect": false,
|
|
52
|
-
"gitHead": "
|
|
52
|
+
"gitHead": "fc447207d2af5368f809a9a90d0e4056344b812a"
|
|
53
53
|
}
|
package/src/gitmoji.ts
CHANGED
|
@@ -5,95 +5,111 @@ import type { CommitConventionalType } from './data.js';
|
|
|
5
5
|
|
|
6
6
|
export type Emoji = Emoji.Unicode | Emoji.Text;
|
|
7
7
|
export namespace Emoji {
|
|
8
|
-
export const reEmojiUnicode = emojiRegexp();
|
|
9
|
-
|
|
10
|
-
export const reEmojiText = /:\w*:/;
|
|
11
|
-
|
|
12
|
-
const reMatchOnly = (input: RegExp) => new RegExp(`^${input.source}$`, '');
|
|
13
|
-
const _reEmojiUnicode = reMatchOnly(reEmojiUnicode);
|
|
14
|
-
const _reEmojiText = reMatchOnly(reEmojiText);
|
|
15
|
-
|
|
16
8
|
export type Unicode = string & { '@@EmojiStyle': 'unicode' };
|
|
17
9
|
export type Text = string & { '@@EmojiStyle': 'text' };
|
|
10
|
+
}
|
|
18
11
|
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
}
|
|
12
|
+
const reEmojiUnicode = emojiRegexp();
|
|
13
|
+
const reEmojiText = /:\w*:/;
|
|
22
14
|
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
15
|
+
const reMatchOnly = (input: RegExp) => new RegExp(`^${input.source}$`, '');
|
|
16
|
+
const _reEmojiUnicode = reMatchOnly(reEmojiUnicode);
|
|
17
|
+
const _reEmojiText = reMatchOnly(reEmojiText);
|
|
26
18
|
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
}
|
|
19
|
+
function isUnicode(anyValue: string): anyValue is Emoji.Unicode {
|
|
20
|
+
return _reEmojiUnicode.test(anyValue);
|
|
30
21
|
}
|
|
31
22
|
|
|
23
|
+
function isText(anyValue: string): anyValue is Emoji.Text {
|
|
24
|
+
return _reEmojiText.test(anyValue);
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
function hasInstance(anyValue: string): anyValue is Emoji {
|
|
28
|
+
return isText(anyValue) || isUnicode(anyValue);
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* @namespace
|
|
33
|
+
*/
|
|
34
|
+
export const Emoji = Object.freeze({
|
|
35
|
+
hasInstance,
|
|
36
|
+
isText,
|
|
37
|
+
isUnicode,
|
|
38
|
+
reEmojiText,
|
|
39
|
+
reEmojiUnicode,
|
|
40
|
+
});
|
|
41
|
+
|
|
32
42
|
export type GitmojiCode = Emoji & { '@@Gitmoji': true };
|
|
33
43
|
export namespace GitmojiCode {
|
|
34
44
|
export type Unicode = Emoji.Unicode & { '@@Gitmoji': true };
|
|
35
45
|
export type Emoji = Emoji.Text & { '@@Gitmoji': true };
|
|
46
|
+
}
|
|
36
47
|
|
|
37
|
-
|
|
48
|
+
const allGitmojiCodes = new Set(
|
|
49
|
+
gitmojis
|
|
50
|
+
.map((gitmoji) => gitmoji.code as GitmojiCode)
|
|
51
|
+
.concat(gitmojis.map((gitmoji) => gitmoji.emoji as GitmojiCode)),
|
|
52
|
+
);
|
|
53
|
+
const index = {
|
|
54
|
+
// code: createIndex(gitmojis, 'code'),
|
|
55
|
+
emoji: createIndex(gitmojis, 'emoji'),
|
|
56
|
+
};
|
|
57
|
+
|
|
58
|
+
function createIndex<K extends keyof Gitmoji>(list: readonly Gitmoji[], key: K): ReadonlyMap<Gitmoji[K], Gitmoji> {
|
|
59
|
+
return new Map(list.map((gitmoji) => [gitmoji[key], gitmoji]));
|
|
60
|
+
}
|
|
38
61
|
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
62
|
+
function isValid(anyValue: string): anyValue is GitmojiCode {
|
|
63
|
+
return allGitmojiCodes.has(anyValue as GitmojiCode);
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
const defaultType = 'chore';
|
|
67
|
+
const conversionMap: ReadonlyMap<GitmojiCode, CommitConventionalType> = (() => {
|
|
68
|
+
const data: Record<CommitConventionalType, GitmojiCode.Unicode[]> = {
|
|
69
|
+
feat: ['✨', '♿️', '🚸'] as GitmojiCode.Unicode[],
|
|
70
|
+
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
|
+
perf: ['⚡️'] as GitmojiCode.Unicode[],
|
|
76
|
+
revert: ['⏪️'] as GitmojiCode.Unicode[],
|
|
77
|
+
ci: ['👷', '💚'] as GitmojiCode.Unicode[],
|
|
78
|
+
wip: ['🚧'] as GitmojiCode.Unicode[],
|
|
79
|
+
build: [] as GitmojiCode.Unicode[],
|
|
80
|
+
chore: ['🔧'] as GitmojiCode.Unicode[],
|
|
47
81
|
};
|
|
48
82
|
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
const entries = Array.from<[CommitConventionalType, GitmojiCode.Unicode[]]>(
|
|
75
|
-
// @ts-ignore entries are not well typed
|
|
76
|
-
Object.entries(data),
|
|
77
|
-
);
|
|
78
|
-
return new Map(
|
|
79
|
-
entries.reduce<Array<[GitmojiCode, CommitConventionalType]>>(
|
|
80
|
-
(acc, [commitType, gitmojiUnicodeArray]) =>
|
|
81
|
-
acc
|
|
82
|
-
.concat(gitmojiUnicodeArray.map((gitmojiUnicode) => [gitmojiUnicode, commitType]))
|
|
83
|
-
|
|
84
|
-
.concat(
|
|
85
|
-
gitmojiUnicodeArray.map((gitmojiUnicode) => [
|
|
86
|
-
// eslint-disable-next-line ts/no-non-null-assertion, ts/no-non-null-asserted-optional-chain
|
|
87
|
-
index.emoji.get(gitmojiUnicode)?.code! as GitmojiCode,
|
|
88
|
-
commitType,
|
|
89
|
-
]),
|
|
90
|
-
),
|
|
91
|
-
[],
|
|
92
|
-
),
|
|
93
|
-
);
|
|
94
|
-
})();
|
|
95
|
-
|
|
96
|
-
export function toConventionalCommitType(gitmoji: GitmojiCode): CommitConventionalType {
|
|
97
|
-
return conversionMap.get(gitmoji) ?? defaultType;
|
|
98
|
-
}
|
|
83
|
+
const entries = Array.from<[CommitConventionalType, GitmojiCode.Unicode[]]>(
|
|
84
|
+
// @ts-ignore entries are not well typed
|
|
85
|
+
Object.entries(data),
|
|
86
|
+
);
|
|
87
|
+
return new Map(
|
|
88
|
+
entries.reduce<Array<[GitmojiCode, CommitConventionalType]>>(
|
|
89
|
+
(acc, [commitType, gitmojiUnicodeArray]) =>
|
|
90
|
+
acc
|
|
91
|
+
.concat(gitmojiUnicodeArray.map((gitmojiUnicode) => [gitmojiUnicode, commitType]))
|
|
92
|
+
|
|
93
|
+
.concat(
|
|
94
|
+
gitmojiUnicodeArray.map((gitmojiUnicode) => [
|
|
95
|
+
// eslint-disable-next-line ts/no-non-null-assertion, ts/no-non-null-asserted-optional-chain
|
|
96
|
+
index.emoji.get(gitmojiUnicode)?.code! as GitmojiCode,
|
|
97
|
+
commitType,
|
|
98
|
+
]),
|
|
99
|
+
),
|
|
100
|
+
[],
|
|
101
|
+
),
|
|
102
|
+
);
|
|
103
|
+
})();
|
|
104
|
+
|
|
105
|
+
function toConventionalCommitType(gitmoji: GitmojiCode): CommitConventionalType {
|
|
106
|
+
return conversionMap.get(gitmoji) ?? defaultType;
|
|
99
107
|
}
|
|
108
|
+
|
|
109
|
+
/**
|
|
110
|
+
* @namespace
|
|
111
|
+
*/
|
|
112
|
+
export const GitmojiCode = Object.freeze({
|
|
113
|
+
isValid,
|
|
114
|
+
toConventionalCommitType,
|
|
115
|
+
});
|