@w5s/conventional-changelog 3.1.2 → 3.1.4
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 +59 -7
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/package.json +3 -3
- package/src/data.ts +34 -4
- package/src/parser.ts +7 -3
- package/src/transform.ts +13 -3
- package/src/whatBump.ts +1 -4
- package/src/writer.ts +13 -4
package/dist/index.d.ts
CHANGED
|
@@ -6,12 +6,40 @@ declare const meta: Readonly<{
|
|
|
6
6
|
}>;
|
|
7
7
|
//#endregion
|
|
8
8
|
//#region src/data.d.ts
|
|
9
|
-
|
|
9
|
+
interface Commit {
|
|
10
|
+
merge: Commit.Field;
|
|
11
|
+
header: Commit.Field;
|
|
12
|
+
body: Commit.Field;
|
|
13
|
+
footer: Commit.Field;
|
|
14
|
+
notes: Commit.Note[];
|
|
15
|
+
references: Commit.Reference[];
|
|
16
|
+
mentions: string[];
|
|
17
|
+
revert: Commit.Revert | null;
|
|
10
18
|
type: string | null;
|
|
11
19
|
subject: string | null;
|
|
12
20
|
scope: string | null;
|
|
13
21
|
hash: string | null;
|
|
14
|
-
}
|
|
22
|
+
}
|
|
23
|
+
declare namespace Commit {
|
|
24
|
+
type Field = string | null;
|
|
25
|
+
interface Note {
|
|
26
|
+
title: string;
|
|
27
|
+
text: string;
|
|
28
|
+
}
|
|
29
|
+
interface Reference {
|
|
30
|
+
issue: string;
|
|
31
|
+
action: Field;
|
|
32
|
+
owner: Field;
|
|
33
|
+
repository: Field;
|
|
34
|
+
prefix: string;
|
|
35
|
+
raw: string;
|
|
36
|
+
}
|
|
37
|
+
interface Revert {
|
|
38
|
+
hash?: Field | undefined;
|
|
39
|
+
header?: Field | undefined;
|
|
40
|
+
[field: string]: Field | undefined;
|
|
41
|
+
}
|
|
42
|
+
}
|
|
15
43
|
type CommitConventionalType = 'build' | 'ci' | 'docs' | 'feat' | 'fix' | 'perf' | 'refactor' | 'revert' | 'style' | 'test' | 'wip' | 'chore';
|
|
16
44
|
declare const CommitConventionalType: {
|
|
17
45
|
hasInstance: (anyValue: unknown) => anyValue is CommitConventionalType;
|
|
@@ -68,13 +96,37 @@ declare namespace GitmojiCode {
|
|
|
68
96
|
}
|
|
69
97
|
//#endregion
|
|
70
98
|
//#region src/parser.d.ts
|
|
71
|
-
interface ParserOptions
|
|
99
|
+
interface ParserOptions {
|
|
100
|
+
headerPattern?: RegExp | string | null;
|
|
101
|
+
headerCorrespondence?: string[] | string | null;
|
|
102
|
+
revertPattern?: RegExp | string | null;
|
|
103
|
+
revertCorrespondence?: string[] | string | null;
|
|
104
|
+
noteKeywords?: string[] | string | null;
|
|
105
|
+
}
|
|
72
106
|
//#endregion
|
|
73
|
-
//#region src/
|
|
74
|
-
interface
|
|
107
|
+
//#region src/transform.d.ts
|
|
108
|
+
interface WriterContext {
|
|
109
|
+
repository?: string | undefined;
|
|
110
|
+
host?: string | undefined;
|
|
111
|
+
owner?: string | undefined;
|
|
112
|
+
repoUrl?: string | undefined;
|
|
113
|
+
}
|
|
114
|
+
interface CommitTransformFunction<TCommit extends Commit = Commit> {
|
|
115
|
+
(commit: Commit, context: WriterContext, ...args: unknown[]): TCommit | false;
|
|
116
|
+
}
|
|
75
117
|
//#endregion
|
|
76
|
-
//#region src/
|
|
77
|
-
|
|
118
|
+
//#region src/writer.d.ts
|
|
119
|
+
interface WriterOptions {
|
|
120
|
+
transform?: CommitTransformFunction<Commit> | undefined;
|
|
121
|
+
groupBy?: string | false | undefined;
|
|
122
|
+
commitGroupsSort?: string | readonly string[] | false | undefined;
|
|
123
|
+
commitsSort?: string | readonly string[] | false | undefined;
|
|
124
|
+
noteGroupsSort?: string | readonly string[] | false | undefined;
|
|
125
|
+
mainTemplate?: string | undefined;
|
|
126
|
+
headerPartial?: string | undefined;
|
|
127
|
+
commitPartial?: string | undefined;
|
|
128
|
+
footerPartial?: string | undefined;
|
|
129
|
+
}
|
|
78
130
|
//#endregion
|
|
79
131
|
//#region src/createPreset.d.ts
|
|
80
132
|
declare function createPreset(): Promise<{
|
package/dist/index.js
CHANGED
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","import type { Options as ParserOptionsDefault } from 'conventional-commits-parser';\n\nexport interface ParserOptions extends ParserOptionsDefault {}\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","import type { Commit as CommitDefault } from 'conventional-commits-parser';\n\nexport type Commit = CommitDefault & {\n type: string | null;\n subject: string | null;\n scope: string | null;\n hash: string | null;\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 type { Commit as CommitBase } from 'conventional-commits-parser';\nimport { 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 type Commit = CommitBase;\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 type { CommitTransformFunction, Context } from 'conventional-changelog-writer';\nimport { CommitConventionalType, 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 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 }: Context): 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 type { Options } from 'conventional-changelog-writer';\nimport { fileURLToPath } from 'node:url';\nimport { createTransform } from './transform.js';\nimport { Commit, CommitConventionalType } from './data.js';\n\nexport interface WriterOptions extends Options<Commit> {}\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;AAC/D,SAAO,gBAAgB,KAAK,SAAS;;;CAGhC,SAAS,OAAO,UAAoC;AACzD,SAAO,aAAa,KAAK,SAAS;;;CAG7B,SAAS,YAAY,UAAqC;AAC/D,SAAO,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,QAAQ,EAEZ,OAAO,YAAY,UAAU,QAAQ,EACtC;CAED,SAAS,YAAqC,MAA0B,KAA0C;AAChH,SAAO,IAAI,IAAI,KAAK,KAAK,YAAY,CAAC,QAAQ,MAAM,QAAQ,CAAC,CAAC;;CAGzD,SAAS,QAAQ,UAA2C;AACjE,SAAO,gBAAgB,IAAI,SAAwB;;;CAGrD,MAAM,cAAc;CACpB,MAAM,uBAAyE;EAgB7E,MAAM,UAAU,MAAM,KAEpB,OAAO,QAjB2D;GAClE,MAAM;IAAC;IAAK;IAAM;IAAK;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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;AAE7D,QAAO;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;;;;AC5BH,eAAsB,eAAe;AACnC,QAAO;EACL;EACA,QAAQ,kBAAkB;EAC1B,QAAQ,MAAM,kBAAkB;EAChC;EACD"}
|
|
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,QAAQ,EAEZ,OAAO,YAAY,UAAU,QAAQ,EACtC;CAED,SAAS,YAAqC,MAA0B,KAA0C;EAChH,OAAO,IAAI,IAAI,KAAK,KAAK,YAAY,CAAC,QAAQ,MAAM,QAAQ,CAAC,CAAC;;CAGzD,SAAS,QAAQ,UAA2C;EACjE,OAAO,gBAAgB,IAAI,SAAwB;;;CAGrD,MAAM,cAAc;CACpB,MAAM,uBAAyE;EAgB7E,MAAM,UAAU,MAAM,KAEpB,OAAO,QAAQ;GAhBf,MAAM;IAAC;IAAK;IAAM;IAAK;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AAW,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"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@w5s/conventional-changelog",
|
|
3
|
-
"version": "3.1.
|
|
3
|
+
"version": "3.1.4",
|
|
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",
|
|
@@ -43,11 +43,11 @@
|
|
|
43
43
|
"gitmojis": "^3.13.4"
|
|
44
44
|
},
|
|
45
45
|
"engines": {
|
|
46
|
-
"node": ">=
|
|
46
|
+
"node": ">=22.0.0"
|
|
47
47
|
},
|
|
48
48
|
"publishConfig": {
|
|
49
49
|
"access": "public"
|
|
50
50
|
},
|
|
51
51
|
"sideEffect": false,
|
|
52
|
-
"gitHead": "
|
|
52
|
+
"gitHead": "38cf5f5877af4c8a1c292b9b7039c5a11863fc00"
|
|
53
53
|
}
|
package/src/data.ts
CHANGED
|
@@ -1,11 +1,41 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
export interface Commit {
|
|
2
|
+
merge: Commit.Field;
|
|
3
|
+
header: Commit.Field;
|
|
4
|
+
body: Commit.Field;
|
|
5
|
+
footer: Commit.Field;
|
|
6
|
+
notes: Commit.Note[];
|
|
7
|
+
references: Commit.Reference[];
|
|
8
|
+
mentions: string[];
|
|
9
|
+
revert: Commit.Revert | null;
|
|
4
10
|
type: string | null;
|
|
5
11
|
subject: string | null;
|
|
6
12
|
scope: string | null;
|
|
7
13
|
hash: string | null;
|
|
8
|
-
}
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export namespace Commit {
|
|
17
|
+
export type Field = string | null;
|
|
18
|
+
|
|
19
|
+
export interface Note {
|
|
20
|
+
title: string;
|
|
21
|
+
text: string;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export interface Reference {
|
|
25
|
+
issue: string;
|
|
26
|
+
action: Field;
|
|
27
|
+
owner: Field;
|
|
28
|
+
repository: Field;
|
|
29
|
+
prefix: string;
|
|
30
|
+
raw: string;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
export interface Revert {
|
|
34
|
+
hash?: Field | undefined;
|
|
35
|
+
header?: Field | undefined;
|
|
36
|
+
[field: string]: Field | undefined;
|
|
37
|
+
}
|
|
38
|
+
}
|
|
9
39
|
|
|
10
40
|
export type CommitConventionalType =
|
|
11
41
|
| 'build'
|
package/src/parser.ts
CHANGED
|
@@ -1,6 +1,10 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
export interface ParserOptions {
|
|
2
|
+
headerPattern?: RegExp | string | null;
|
|
3
|
+
headerCorrespondence?: string[] | string | null;
|
|
4
|
+
revertPattern?: RegExp | string | null;
|
|
5
|
+
revertCorrespondence?: string[] | string | null;
|
|
6
|
+
noteKeywords?: string[] | string | null;
|
|
7
|
+
}
|
|
4
8
|
|
|
5
9
|
export const createParserOpts = (): ParserOptions => ({
|
|
6
10
|
headerPattern: new RegExp(
|
package/src/transform.ts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { CommitConventionalType, Commit } from './data.js';
|
|
1
|
+
import { CommitConventionalType, type Commit } from './data.js';
|
|
3
2
|
import { GitmojiCode } from './gitmoji.js';
|
|
4
3
|
|
|
5
4
|
export type Language = 'en-US';
|
|
@@ -13,6 +12,17 @@ export interface TransformConfig {
|
|
|
13
12
|
language?: Language;
|
|
14
13
|
}
|
|
15
14
|
|
|
15
|
+
export interface WriterContext {
|
|
16
|
+
repository?: string | undefined;
|
|
17
|
+
host?: string | undefined;
|
|
18
|
+
owner?: string | undefined;
|
|
19
|
+
repoUrl?: string | undefined;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export interface CommitTransformFunction<TCommit extends Commit = Commit> {
|
|
23
|
+
(commit: Commit, context: WriterContext, ...args: unknown[]): TCommit | false;
|
|
24
|
+
}
|
|
25
|
+
|
|
16
26
|
export function displayScope(scope: string | null | undefined, scopeDisplayNameMap: Record<string, string>) {
|
|
17
27
|
return scope == null || scope.length === 0
|
|
18
28
|
? scopeDisplayNameMap['*']
|
|
@@ -44,7 +54,7 @@ export function createTransform(config: TransformConfig): CommitTransformFunctio
|
|
|
44
54
|
const ignoreScope = (scope: string | undefined | null) =>
|
|
45
55
|
config.displayScopes == null ? false : scope != null && !config.displayScopes.includes(scope);
|
|
46
56
|
|
|
47
|
-
const transform = (commit: Commit, { repository, host, owner, repoUrl }:
|
|
57
|
+
const transform = (commit: Commit, { repository, host, owner, repoUrl }: WriterContext): Commit | false => {
|
|
48
58
|
const discard = commit.notes.length === 0;
|
|
49
59
|
const issues = new Set<string>();
|
|
50
60
|
const notes = commit.notes.map((note) => ({
|
package/src/whatBump.ts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { CommitConventionalType } from './data.js';
|
|
1
|
+
import { CommitConventionalType, type Commit } from './data.js';
|
|
3
2
|
import { GitmojiCode } from './gitmoji.js';
|
|
4
3
|
|
|
5
4
|
function toConventionalCommitType(text: string) {
|
|
@@ -10,8 +9,6 @@ function toConventionalCommitType(text: string) {
|
|
|
10
9
|
: undefined;
|
|
11
10
|
}
|
|
12
11
|
|
|
13
|
-
export type Commit = CommitBase;
|
|
14
|
-
|
|
15
12
|
export const whatBump = (commits: ReadonlyArray<Commit>) => {
|
|
16
13
|
let level = 2;
|
|
17
14
|
let breakings = 0;
|
package/src/writer.ts
CHANGED
|
@@ -1,11 +1,20 @@
|
|
|
1
1
|
import { readFileSync } from 'node:fs';
|
|
2
2
|
import nodePath from 'node:path';
|
|
3
|
-
import type { Options } from 'conventional-changelog-writer';
|
|
4
3
|
import { fileURLToPath } from 'node:url';
|
|
5
|
-
import { createTransform } from './transform.js';
|
|
6
|
-
import {
|
|
4
|
+
import { createTransform, type CommitTransformFunction } from './transform.js';
|
|
5
|
+
import { CommitConventionalType, type Commit } from './data.js';
|
|
7
6
|
|
|
8
|
-
export interface WriterOptions
|
|
7
|
+
export interface WriterOptions {
|
|
8
|
+
transform?: CommitTransformFunction<Commit> | undefined;
|
|
9
|
+
groupBy?: string | false | undefined;
|
|
10
|
+
commitGroupsSort?: string | readonly string[] | false | undefined;
|
|
11
|
+
commitsSort?: string | readonly string[] | false | undefined;
|
|
12
|
+
noteGroupsSort?: string | readonly string[] | false | undefined;
|
|
13
|
+
mainTemplate?: string | undefined;
|
|
14
|
+
headerPartial?: string | undefined;
|
|
15
|
+
commitPartial?: string | undefined;
|
|
16
|
+
footerPartial?: string | undefined;
|
|
17
|
+
}
|
|
9
18
|
|
|
10
19
|
const _dirname = typeof __dirname === 'undefined' ? nodePath.dirname(fileURLToPath(import.meta.url)) : __dirname;
|
|
11
20
|
const basePath = nodePath.resolve(nodePath.dirname(_dirname), './template');
|