@w5s/conventional-changelog 3.23.0 โ†’ 3.25.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 CHANGED
@@ -91,8 +91,8 @@ interface WriterOptions {
91
91
  }
92
92
  //#endregion
93
93
  //#region src/gitmoji.d.ts
94
- type Emoji = Emoji.Text | Emoji.Unicode;
95
- declare namespace Emoji {
94
+ export type Emoji = Emoji.Text | Emoji.Unicode;
95
+ export declare namespace Emoji {
96
96
  type Text = string & {
97
97
  '@@EmojiStyle': 'text';
98
98
  };
@@ -106,17 +106,17 @@ declare function isUnicode(anyValue: string): anyValue is Emoji.Unicode;
106
106
  /**
107
107
  * @namespace
108
108
  */
109
- declare const Emoji: Readonly<{
109
+ export declare const Emoji: Readonly<{
110
110
  hasInstance: typeof hasInstance;
111
111
  isText: typeof isText;
112
112
  isUnicode: typeof isUnicode;
113
113
  reEmojiText: RegExp;
114
114
  reEmojiUnicode: RegExp;
115
115
  }>;
116
- type GitmojiCode = Emoji & {
116
+ export type GitmojiCode = Emoji & {
117
117
  '@@Gitmoji': true;
118
118
  };
119
- declare namespace GitmojiCode {
119
+ export declare namespace GitmojiCode {
120
120
  type Emoji = Emoji.Text & {
121
121
  '@@Gitmoji': true;
122
122
  };
@@ -129,7 +129,7 @@ declare function toConventionalCommitType(gitmoji: GitmojiCode): CommitConventio
129
129
  /**
130
130
  * @namespace
131
131
  */
132
- declare const GitmojiCode: Readonly<{
132
+ export declare const GitmojiCode: Readonly<{
133
133
  isValid: typeof isValid;
134
134
  toConventionalCommitType: typeof toConventionalCommitType;
135
135
  }>;
@@ -148,11 +148,11 @@ declare function createPreset(): Promise<{
148
148
  }>;
149
149
  //#endregion
150
150
  //#region src/meta.d.ts
151
- declare const meta: Readonly<{
151
+ export declare const meta: Readonly<{
152
152
  buildNumber: number;
153
153
  name: string;
154
154
  version: string;
155
155
  }>;
156
156
  //#endregion
157
- export { Emoji, GitmojiCode, createPreset as default, meta };
157
+ export { createPreset as default };
158
158
  //# sourceMappingURL=index.d.ts.map
package/dist/index.js CHANGED
@@ -316,9 +316,9 @@ async function createPreset() {
316
316
  //#endregion
317
317
  //#region src/meta.ts
318
318
  const meta = Object.freeze({
319
- buildNumber: 1788194737,
319
+ buildNumber: 1788793943,
320
320
  name: "@w5s/conventional-changelog",
321
- version: "3.23.0"
321
+ version: "3.25.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?: 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 };\n };\n\n return transform;\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\n// eslint-disable-next-line ts/require-await\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: (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;GACb,SAAS;GACT,SAAS;EACX;EACA,MAAM;GACJ,aAAa;GACb,SAAS;GACT,SAAS;EACX;EACA,MAAM;GACJ,aAAa;GACb,SAAS;GACT,SAAS;EACX;EACA,KAAK;GACH,aAAa;GACb,SAAS;GACT,SAAS;EACX;EACA,MAAM;GACJ,aAAa;GACb,SAAS;GACT,SAAS;EACX;EACA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K,CAAC;EAEvF,OAAO;GACL,GAAG;GACH,MAAM,OAAO;GACb,QAAQ,OAAO;GACf;GACA,QAAQ,OAAO;GACf,UAAU,OAAO;GACjB,OAAO,OAAO;GACd;GACA;GACA,QAAQ,OAAO;GACf;GACA;GACA;EACF;CACF;CAEA,OAAO;AACT;;;AC9GA,MAAM,WAAW,SAAS,QAAQ,cAAc,YAAY,GAAG,CAAC;AAChE,MAAM,WAAW,SAAS,QAAQ,SAAS,QAAQ,QAAQ,GAAG,YAAY;AAE1E,MAAa,sBAAsB,uBAAuB,WAAW,MAAM,EAAE,SAAS;AAGtF,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;;;ACxCA,eAAsB,eAAe;CACnC,OAAO;EACL;EACA,QAAQ,iBAAiB;EACzB;EACA,QAAQ,MAAM,iBAAiB;CACjC;AACF;;;ACdA,MAAa,OAAO,OAAO,OAAO;CAEhC,aAAA;CAEA,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 };\n };\n\n return transform;\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: (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/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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;CAEA,MAAA;CAEA,SAAA;AACF,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@w5s/conventional-changelog",
3
- "version": "3.23.0",
3
+ "version": "3.25.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
  "publishConfig": {
45
45
  "access": "public"
46
46
  },
47
- "gitHead": "5f5e5d054cec6e06bce7759585cc8482977b0fb7"
47
+ "gitHead": "f01e374782fdf338f411115d7e82a0353540282b"
48
48
  }
package/src/writer.ts CHANGED
@@ -22,7 +22,6 @@ const basePath = nodePath.resolve(nodePath.dirname(_dirname), './template');
22
22
 
23
23
  export const defaultDisplayTypes = CommitConventionalType.findWhere((_) => _.changelog);
24
24
 
25
- // eslint-disable-next-line ts/require-await
26
25
  export const createWriterOpts = async (): Promise<WriterOptions> => {
27
26
  const mainTemplate = readFileSync(`${basePath}/template.hbs`, 'utf8');
28
27
  const headerPartial = readFileSync(`${basePath}/header.hbs`, 'utf8');