@w5s/conventional-changelog 3.2.9 โ 3.3.0
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 +11 -13
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
- package/src/data.ts +5 -5
- package/src/gitmoji.ts +15 -15
- package/src/parser.ts +3 -3
- package/src/transform.ts +3 -6
- package/src/writer.ts +3 -3
package/dist/index.d.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
//#region src/parser.d.ts
|
|
2
2
|
interface ParserOptions {
|
|
3
|
-
headerCorrespondence?:
|
|
3
|
+
headerCorrespondence?: Array<string> | null | string;
|
|
4
4
|
headerPattern?: null | RegExp | string;
|
|
5
|
-
noteKeywords?:
|
|
6
|
-
revertCorrespondence?:
|
|
5
|
+
noteKeywords?: Array<string> | null | string;
|
|
6
|
+
revertCorrespondence?: Array<string> | null | string;
|
|
7
7
|
revertPattern?: null | RegExp | string;
|
|
8
8
|
}
|
|
9
9
|
//#endregion
|
|
@@ -13,10 +13,10 @@ interface Commit {
|
|
|
13
13
|
footer: Commit.Field;
|
|
14
14
|
hash: null | string;
|
|
15
15
|
header: Commit.Field;
|
|
16
|
-
mentions: string
|
|
16
|
+
mentions: Array<string>;
|
|
17
17
|
merge: Commit.Field;
|
|
18
|
-
notes: Commit.Note
|
|
19
|
-
references: Commit.Reference
|
|
18
|
+
notes: Array<Commit.Note>;
|
|
19
|
+
references: Array<Commit.Reference>;
|
|
20
20
|
revert: Commit.Revert | null;
|
|
21
21
|
scope: null | string;
|
|
22
22
|
subject: null | string;
|
|
@@ -44,7 +44,7 @@ declare namespace Commit {
|
|
|
44
44
|
}
|
|
45
45
|
type CommitConventionalType = 'build' | 'chore' | 'ci' | 'docs' | 'feat' | 'fix' | 'perf' | 'refactor' | 'revert' | 'style' | 'test' | 'wip';
|
|
46
46
|
declare const CommitConventionalType: {
|
|
47
|
-
findWhere: (predicate: (data: CommitConventionalTypeData) => boolean) => CommitConventionalType
|
|
47
|
+
findWhere: (predicate: (data: CommitConventionalTypeData) => boolean) => Array<CommitConventionalType>;
|
|
48
48
|
getData: (commitType: CommitConventionalType) => CommitConventionalTypeData;
|
|
49
49
|
hasInstance: (anyValue: unknown) => anyValue is CommitConventionalType;
|
|
50
50
|
parse: (anyValue: string) => CommitConventionalType | undefined;
|
|
@@ -69,9 +69,7 @@ interface CommitConventionalTypeData {
|
|
|
69
69
|
}
|
|
70
70
|
//#endregion
|
|
71
71
|
//#region src/transform.d.ts
|
|
72
|
-
|
|
73
|
-
(commit: Commit, context: WriterContext, ...args: unknown[]): false | TCommit;
|
|
74
|
-
}
|
|
72
|
+
type CommitTransformFunction<TCommit extends Commit = Commit> = (commit: Commit, context: WriterContext, ...args: Array<unknown>) => false | TCommit;
|
|
75
73
|
interface WriterContext {
|
|
76
74
|
host?: string | undefined;
|
|
77
75
|
owner?: string | undefined;
|
|
@@ -81,14 +79,14 @@ interface WriterContext {
|
|
|
81
79
|
//#endregion
|
|
82
80
|
//#region src/writer.d.ts
|
|
83
81
|
interface WriterOptions {
|
|
84
|
-
commitGroupsSort?: false |
|
|
82
|
+
commitGroupsSort?: false | ReadonlyArray<string> | string | undefined;
|
|
85
83
|
commitPartial?: string | undefined;
|
|
86
|
-
commitsSort?: false |
|
|
84
|
+
commitsSort?: false | ReadonlyArray<string> | string | undefined;
|
|
87
85
|
footerPartial?: string | undefined;
|
|
88
86
|
groupBy?: false | string | undefined;
|
|
89
87
|
headerPartial?: string | undefined;
|
|
90
88
|
mainTemplate?: string | undefined;
|
|
91
|
-
noteGroupsSort?: false |
|
|
89
|
+
noteGroupsSort?: false | ReadonlyArray<string> | string | undefined;
|
|
92
90
|
transform?: CommitTransformFunction<Commit> | undefined;
|
|
93
91
|
}
|
|
94
92
|
//#endregion
|
package/dist/index.js
CHANGED
|
@@ -318,7 +318,7 @@ async function createPreset() {
|
|
|
318
318
|
const meta = Object.freeze({
|
|
319
319
|
buildNumber: 1,
|
|
320
320
|
name: "@w5s/conventional-changelog",
|
|
321
|
-
version: "3.
|
|
321
|
+
version: "3.3.0"
|
|
322
322
|
});
|
|
323
323
|
//#endregion
|
|
324
324
|
export { Emoji, GitmojiCode, createPreset as default, meta };
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
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;;;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a,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"}
|
|
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?: Array<string> | null | string;\n headerPattern?: null | RegExp | string;\n noteKeywords?: Array<string> | null | string;\n revertCorrespondence?: Array<string> | null | 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: Array<string>;\n merge: Commit.Field;\n notes: Array<Commit.Note>;\n references: Array<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: ReadonlyArray<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): Array<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: ReadonlyArray<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, Array<GitmojiCode.Unicode>> = {\n build: [] as Array<GitmojiCode.Unicode>,\n chore: ['๐ง'] as Array<GitmojiCode.Unicode>,\n ci: ['๐ท', '๐'] as Array<GitmojiCode.Unicode>,\n docs: ['๐'] as Array<GitmojiCode.Unicode>,\n feat: ['โจ', 'โฟ๏ธ', '๐ธ'] as Array<GitmojiCode.Unicode>,\n fix: ['๐'] as Array<GitmojiCode.Unicode>,\n perf: ['โก๏ธ'] as Array<GitmojiCode.Unicode>,\n refactor: ['โป๏ธ', '๐๏ธ'] as Array<GitmojiCode.Unicode>,\n revert: ['โช๏ธ'] as Array<GitmojiCode.Unicode>,\n style: ['๐จ', '๐จ'] as Array<GitmojiCode.Unicode>,\n test: ['โ
', '๐งช'] as Array<GitmojiCode.Unicode>,\n wip: ['๐ง'] as Array<GitmojiCode.Unicode>,\n };\n\n const entries = Array.from<[CommitConventionalType, Array<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 type CommitTransformFunction<TCommit extends Commit = Commit> = (commit: Commit, context: WriterContext, ...args: Array<unknown>) => false | TCommit;\n\nexport type Language = 'en-US';\n\nexport interface TransformConfig {\n displayScopes?: Array<string>;\n displayTypes?: Array<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 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 | ReadonlyArray<string> | string | undefined;\n commitPartial?: string | undefined;\n commitsSort?: false | ReadonlyArray<string> | string | undefined;\n footerPartial?: string | undefined;\n groupBy?: false | string | undefined;\n headerPartial?: string | undefined;\n mainTemplate?: string | undefined;\n noteGroupsSort?: false | ReadonlyArray<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,aAAoD,OAAO,OAAO,OAAO,OAAO,UAAU,CAAC,CAAC,MAAM,MAAM,UAAU,KAAK,cAAc,KAAK,CAAC,CAAC;CAClJ,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;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AA;CAEA,SAAA;AACF,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@w5s/conventional-changelog",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.3.0",
|
|
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": "2d215d8f8c7c57653b9f0ef5674ffc2e7beeea5c"
|
|
48
48
|
}
|
package/src/data.ts
CHANGED
|
@@ -3,10 +3,10 @@ export interface Commit {
|
|
|
3
3
|
footer: Commit.Field;
|
|
4
4
|
hash: null | string;
|
|
5
5
|
header: Commit.Field;
|
|
6
|
-
mentions: string
|
|
6
|
+
mentions: Array<string>;
|
|
7
7
|
merge: Commit.Field;
|
|
8
|
-
notes: Commit.Note
|
|
9
|
-
references: Commit.Reference
|
|
8
|
+
notes: Array<Commit.Note>;
|
|
9
|
+
references: Array<Commit.Reference>;
|
|
10
10
|
revert: Commit.Revert | null;
|
|
11
11
|
scope: null | string;
|
|
12
12
|
subject: null | string;
|
|
@@ -67,7 +67,7 @@ export const CommitConventionalType = (() => {
|
|
|
67
67
|
WIP: 'wip',
|
|
68
68
|
});
|
|
69
69
|
// eslint-disable-next-line unicorn/no-array-sort
|
|
70
|
-
const enumValues:
|
|
70
|
+
const enumValues: ReadonlyArray<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> = {
|
|
@@ -149,7 +149,7 @@ export const CommitConventionalType = (() => {
|
|
|
149
149
|
return enumValues;
|
|
150
150
|
}
|
|
151
151
|
|
|
152
|
-
function findWhere(predicate: (data: CommitConventionalTypeData) => boolean): CommitConventionalType
|
|
152
|
+
function findWhere(predicate: (data: CommitConventionalTypeData) => boolean): Array<CommitConventionalType> {
|
|
153
153
|
return enumValues.filter((enumValue) => predicate(getData(enumValue)));
|
|
154
154
|
}
|
|
155
155
|
|
package/src/gitmoji.ts
CHANGED
|
@@ -55,7 +55,7 @@ const index = {
|
|
|
55
55
|
emoji: createIndex(gitmojis, 'emoji'),
|
|
56
56
|
};
|
|
57
57
|
|
|
58
|
-
function createIndex<K extends keyof Gitmoji>(list:
|
|
58
|
+
function createIndex<K extends keyof Gitmoji>(list: ReadonlyArray<Gitmoji>, key: K): ReadonlyMap<Gitmoji[K], Gitmoji> {
|
|
59
59
|
return new Map(list.map((gitmoji) => [gitmoji[key], gitmoji]));
|
|
60
60
|
}
|
|
61
61
|
|
|
@@ -65,22 +65,22 @@ function isValid(anyValue: string): anyValue is GitmojiCode {
|
|
|
65
65
|
|
|
66
66
|
const defaultType = 'chore';
|
|
67
67
|
const conversionMap: ReadonlyMap<GitmojiCode, CommitConventionalType> = (() => {
|
|
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
|
|
73
|
-
feat: ['โจ', 'โฟ๏ธ', '๐ธ'] as GitmojiCode.Unicode
|
|
74
|
-
fix: ['๐'] as GitmojiCode.Unicode
|
|
75
|
-
perf: ['โก๏ธ'] as GitmojiCode.Unicode
|
|
76
|
-
refactor: ['โป๏ธ', '๐๏ธ'] as GitmojiCode.Unicode
|
|
77
|
-
revert: ['โช๏ธ'] as GitmojiCode.Unicode
|
|
78
|
-
style: ['๐จ', '๐จ'] as GitmojiCode.Unicode
|
|
79
|
-
test: ['โ
', '๐งช'] as GitmojiCode.Unicode
|
|
80
|
-
wip: ['๐ง'] as GitmojiCode.Unicode
|
|
68
|
+
const data: Record<CommitConventionalType, Array<GitmojiCode.Unicode>> = {
|
|
69
|
+
build: [] as Array<GitmojiCode.Unicode>,
|
|
70
|
+
chore: ['๐ง'] as Array<GitmojiCode.Unicode>,
|
|
71
|
+
ci: ['๐ท', '๐'] as Array<GitmojiCode.Unicode>,
|
|
72
|
+
docs: ['๐'] as Array<GitmojiCode.Unicode>,
|
|
73
|
+
feat: ['โจ', 'โฟ๏ธ', '๐ธ'] as Array<GitmojiCode.Unicode>,
|
|
74
|
+
fix: ['๐'] as Array<GitmojiCode.Unicode>,
|
|
75
|
+
perf: ['โก๏ธ'] as Array<GitmojiCode.Unicode>,
|
|
76
|
+
refactor: ['โป๏ธ', '๐๏ธ'] as Array<GitmojiCode.Unicode>,
|
|
77
|
+
revert: ['โช๏ธ'] as Array<GitmojiCode.Unicode>,
|
|
78
|
+
style: ['๐จ', '๐จ'] as Array<GitmojiCode.Unicode>,
|
|
79
|
+
test: ['โ
', '๐งช'] as Array<GitmojiCode.Unicode>,
|
|
80
|
+
wip: ['๐ง'] as Array<GitmojiCode.Unicode>,
|
|
81
81
|
};
|
|
82
82
|
|
|
83
|
-
const entries = Array.from<[CommitConventionalType, GitmojiCode.Unicode
|
|
83
|
+
const entries = Array.from<[CommitConventionalType, Array<GitmojiCode.Unicode>]>(
|
|
84
84
|
// @ts-ignore entries are not well typed
|
|
85
85
|
Object.entries(data),
|
|
86
86
|
);
|
package/src/parser.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
export interface ParserOptions {
|
|
2
|
-
headerCorrespondence?:
|
|
2
|
+
headerCorrespondence?: Array<string> | null | string;
|
|
3
3
|
headerPattern?: null | RegExp | string;
|
|
4
|
-
noteKeywords?:
|
|
5
|
-
revertCorrespondence?:
|
|
4
|
+
noteKeywords?: Array<string> | null | string;
|
|
5
|
+
revertCorrespondence?: Array<string> | null | string;
|
|
6
6
|
revertPattern?: null | RegExp | string;
|
|
7
7
|
}
|
|
8
8
|
|
package/src/transform.ts
CHANGED
|
@@ -1,15 +1,13 @@
|
|
|
1
1
|
import { type Commit, CommitConventionalType } from './data.js';
|
|
2
2
|
import { GitmojiCode } from './gitmoji.js';
|
|
3
3
|
|
|
4
|
-
export
|
|
5
|
-
(commit: Commit, context: WriterContext, ...args: unknown[]): false | TCommit;
|
|
6
|
-
}
|
|
4
|
+
export type CommitTransformFunction<TCommit extends Commit = Commit> = (commit: Commit, context: WriterContext, ...args: Array<unknown>) => false | TCommit;
|
|
7
5
|
|
|
8
6
|
export type Language = 'en-US';
|
|
9
7
|
|
|
10
8
|
export interface TransformConfig {
|
|
11
|
-
displayScopes?: string
|
|
12
|
-
displayTypes?: CommitConventionalType
|
|
9
|
+
displayScopes?: Array<string>;
|
|
10
|
+
displayTypes?: Array<CommitConventionalType>;
|
|
13
11
|
language?: Language;
|
|
14
12
|
scopeDisplayName?: Record<string, string>;
|
|
15
13
|
showAuthor?: boolean;
|
|
@@ -111,7 +109,6 @@ export function createTransform(config: TransformConfig): CommitTransformFunctio
|
|
|
111
109
|
// Remove references that already appear in the subject
|
|
112
110
|
const references = commit.references.filter((reference) => !issues.has(reference.issue));
|
|
113
111
|
|
|
114
|
-
// eslint-disable-next-line ts/consistent-type-assertions
|
|
115
112
|
return {
|
|
116
113
|
...commit,
|
|
117
114
|
body: commit.body,
|
package/src/writer.ts
CHANGED
|
@@ -6,14 +6,14 @@ import { type Commit, CommitConventionalType } from './data.js';
|
|
|
6
6
|
import { type CommitTransformFunction, createTransform } from './transform.js';
|
|
7
7
|
|
|
8
8
|
export interface WriterOptions {
|
|
9
|
-
commitGroupsSort?: false |
|
|
9
|
+
commitGroupsSort?: false | ReadonlyArray<string> | string | undefined;
|
|
10
10
|
commitPartial?: string | undefined;
|
|
11
|
-
commitsSort?: false |
|
|
11
|
+
commitsSort?: false | ReadonlyArray<string> | string | undefined;
|
|
12
12
|
footerPartial?: string | undefined;
|
|
13
13
|
groupBy?: false | string | undefined;
|
|
14
14
|
headerPartial?: string | undefined;
|
|
15
15
|
mainTemplate?: string | undefined;
|
|
16
|
-
noteGroupsSort?: false |
|
|
16
|
+
noteGroupsSort?: false | ReadonlyArray<string> | string | undefined;
|
|
17
17
|
transform?: CommitTransformFunction<Commit> | undefined;
|
|
18
18
|
}
|
|
19
19
|
|