@w5s/conventional-changelog 2.0.19 → 2.0.23

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/gitmoji.js DELETED
@@ -1,77 +0,0 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.GitmojiCode = exports.Emoji = void 0;
7
- const emoji_regex_1 = __importDefault(require("emoji-regex"));
8
- const gitmojis_1 = require("gitmojis");
9
- var Emoji;
10
- (function (Emoji) {
11
- Emoji.reEmojiUnicode = (0, emoji_regex_1.default)();
12
- Emoji.reEmojiText = /:\w*:/;
13
- const reMatchOnly = (input) => new RegExp(`^${input.source}$`, '');
14
- const _reEmojiUnicode = reMatchOnly(Emoji.reEmojiUnicode);
15
- const _reEmojiText = reMatchOnly(Emoji.reEmojiText);
16
- function isUnicode(anyValue) {
17
- return _reEmojiUnicode.test(anyValue);
18
- }
19
- Emoji.isUnicode = isUnicode;
20
- function isText(anyValue) {
21
- return _reEmojiText.test(anyValue);
22
- }
23
- Emoji.isText = isText;
24
- function hasInstance(anyValue) {
25
- return isText(anyValue) || isUnicode(anyValue);
26
- }
27
- Emoji.hasInstance = hasInstance;
28
- })(Emoji || (exports.Emoji = Emoji = {}));
29
- var GitmojiCode;
30
- (function (GitmojiCode) {
31
- // export const reEmoji = emojiRegexp();
32
- const allGitmojiCodes = new Set(gitmojis_1.gitmojis
33
- .map((gitmoji) => gitmoji.code)
34
- .concat(gitmojis_1.gitmojis.map((gitmoji) => gitmoji.emoji)));
35
- const index = {
36
- // code: createIndex(gitmojis, 'code'),
37
- emoji: createIndex(gitmojis_1.gitmojis, 'emoji'),
38
- };
39
- function createIndex(list, key) {
40
- return new Map(list.map((gitmoji) => [gitmoji[key], gitmoji]));
41
- }
42
- function isValid(anyValue) {
43
- return allGitmojiCodes.has(anyValue);
44
- }
45
- GitmojiCode.isValid = isValid;
46
- const defaultType = 'chore';
47
- const conversionMap = (() => {
48
- const data = {
49
- feat: ['✨', '♿️', '🚸'],
50
- fix: ['🐛'],
51
- docs: ['📝'],
52
- style: ['🎨', '🚨'],
53
- refactor: ['♻️', '🏗️'],
54
- test: ['✅', '🧪'],
55
- perf: ['⚡️'],
56
- revert: ['⏪️'],
57
- ci: ['👷', '💚'],
58
- wip: ['🚧'],
59
- build: [],
60
- chore: ['🔧'],
61
- };
62
- const entries = Array.from(
63
- // @ts-ignore entries are not well typed
64
- Object.entries(data));
65
- return new Map(entries.reduce((acc, [commitType, gitmojiUnicodeArray]) => acc
66
- .concat(gitmojiUnicodeArray.map((gitmojiUnicode) => [gitmojiUnicode, commitType]))
67
- .concat(gitmojiUnicodeArray.map((gitmojiUnicode) => [
68
- // eslint-disable-next-line @typescript-eslint/no-non-null-assertion, @typescript-eslint/no-non-null-asserted-optional-chain
69
- index.emoji.get(gitmojiUnicode)?.code,
70
- commitType,
71
- ])), []));
72
- })();
73
- function toConventionalCommitType(gitmoji) {
74
- return conversionMap.get(gitmoji) ?? defaultType;
75
- }
76
- GitmojiCode.toConventionalCommitType = toConventionalCommitType;
77
- })(GitmojiCode || (exports.GitmojiCode = GitmojiCode = {}));
@@ -1,4 +0,0 @@
1
- import type { Options } from 'conventional-commits-parser';
2
- export interface ParserOptions extends Options {
3
- }
4
- export declare const parserOpts: ParserOptions;
@@ -1,17 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.parserOpts = void 0;
4
- exports.parserOpts = {
5
- headerPattern: new RegExp(
6
- // Type
7
- `^(?<type>\\S*)? ` +
8
- // Scope
9
- `(?:\\((?<scope>.*)\\):? )?` +
10
- // Subject
11
- `(?<subject>.*)$`, 'u'),
12
- headerCorrespondence: ['type', 'scope', 'subject'],
13
- revertPattern: /^(?:revert|revert:)\s"?([\S\s]+?)"?\s*this reverts commit (\w*)\./i,
14
- noteKeywords: ['BREAKING CHANGE', 'BREAKING CHANGES'],
15
- // revertPattern: /revert:\s([\S\s]*?)\s*this reverts commit (\w*)\./i,
16
- revertCorrespondence: [`header`, `hash`],
17
- };
@@ -1,9 +0,0 @@
1
- import type { Commit as CommitBase } from 'conventional-commits-parser';
2
- export type Commit = CommitBase;
3
- export declare const recommendedBumpOpts: {
4
- parserOpts: import("./parser-opts.js").ParserOptions;
5
- whatBump: (commits: ReadonlyArray<Commit>) => {
6
- level: number;
7
- reason: string;
8
- };
9
- };
@@ -1,40 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.recommendedBumpOpts = void 0;
4
- const parser_opts_js_1 = require("./parser-opts.js");
5
- const data_js_1 = require("./data.js");
6
- const gitmoji_js_1 = require("./gitmoji.js");
7
- function toConventionalCommitType(text) {
8
- return gitmoji_js_1.GitmojiCode.isValid(text)
9
- ? gitmoji_js_1.GitmojiCode.toConventionalCommitType(text)
10
- : data_js_1.CommitConventionalType.hasInstance(text)
11
- ? text
12
- : undefined;
13
- }
14
- exports.recommendedBumpOpts = {
15
- parserOpts: parser_opts_js_1.parserOpts,
16
- whatBump: (commits) => {
17
- let level = 2;
18
- let breakings = 0;
19
- let features = 0;
20
- for (const { type, notes } of commits) {
21
- const conventionalType = type == null ? type : toConventionalCommitType(type);
22
- if (notes.length > 0) {
23
- breakings += notes.length;
24
- level = 0;
25
- }
26
- else if (conventionalType === data_js_1.CommitConventionalType.Feat) {
27
- features += 1;
28
- if (level === 2) {
29
- level = 1;
30
- }
31
- }
32
- }
33
- return {
34
- level,
35
- reason: breakings === 1
36
- ? `There is ${breakings} BREAKING CHANGE and ${features} features`
37
- : `There are ${breakings} BREAKING CHANGES and ${features} features`,
38
- };
39
- },
40
- };
@@ -1,20 +0,0 @@
1
- import type { Options as WriterOptions } from 'conventional-changelog-writer';
2
- import { CommitConventionalType } from './data.js';
3
- export type Language = 'en-US';
4
- export interface TransformConfig {
5
- scopeDisplayName?: Record<string, string>;
6
- displayTypes?: CommitConventionalType[];
7
- displayScopes?: string[];
8
- showAuthor?: boolean;
9
- withEmoji?: boolean;
10
- language?: Language;
11
- }
12
- export declare function displayScope(scope: string | null | undefined, scopeDisplayNameMap: Record<string, string>): string | undefined;
13
- export declare function displayType(type: string, options?: displayType.Options): string;
14
- export declare namespace displayType {
15
- interface Options {
16
- readonly withEmoji?: boolean;
17
- readonly language?: Language;
18
- }
19
- }
20
- export declare function createTransform(config: TransformConfig): WriterOptions.Transform.Function;
package/dist/transform.js DELETED
@@ -1,90 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.displayScope = displayScope;
4
- exports.displayType = displayType;
5
- exports.createTransform = createTransform;
6
- const data_js_1 = require("./data.js");
7
- const gitmoji_js_1 = require("./gitmoji.js");
8
- function displayScope(scope, scopeDisplayNameMap) {
9
- return scope == null || scope.length === 0
10
- ? scopeDisplayNameMap['*']
11
- : scopeDisplayNameMap[scope] == null
12
- ? scope
13
- : scopeDisplayNameMap[scope];
14
- }
15
- function displayType(type, options = {}) {
16
- const { withEmoji = true, language = 'en-US' } = options;
17
- if (data_js_1.CommitConventionalType.hasInstance(type)) {
18
- const { emoji, [language]: title } = data_js_1.CommitConventionalType.getData(type);
19
- return `${withEmoji ? `${emoji} ` : ''}${title}`;
20
- }
21
- return type;
22
- }
23
- function createTransform(config) {
24
- const displayTypes = new Set(config.displayTypes == null ? data_js_1.CommitConventionalType.values() : config.displayTypes);
25
- const ignoreType = (type) => type == null || !displayTypes.has(type);
26
- const ignoreScope = (scope) => config.displayScopes == null ? false : scope != null && !config.displayScopes.includes(scope);
27
- const transform = (commit, { repository, host, owner, repoUrl }) => {
28
- const discard = commit.notes.length === 0;
29
- const issues = new Set();
30
- const notes = commit.notes.map((note) => ({
31
- ...note,
32
- title: `${config.withEmoji === false ? '' : '💥 '}BREAKING CHANGES`,
33
- }));
34
- const conventionalType = commit.type == null
35
- ? undefined
36
- : (data_js_1.CommitConventionalType.parse(commit.type) ??
37
- (gitmoji_js_1.GitmojiCode.isValid(commit.type) ? gitmoji_js_1.GitmojiCode.toConventionalCommitType(commit.type) : undefined));
38
- if (ignoreType(conventionalType) && discard)
39
- return false;
40
- const type = conventionalType == null
41
- ? conventionalType
42
- : displayType(conventionalType, {
43
- withEmoji: config.withEmoji,
44
- });
45
- if (ignoreScope(commit.scope))
46
- return false;
47
- const scopeIntermediate = commit.scope === '*' ? '' : commit.scope;
48
- const scope = config.scopeDisplayName == null ? scopeIntermediate : displayScope(scopeIntermediate, config.scopeDisplayName);
49
- const hash = typeof commit.hash === 'string' ? commit.hash.slice(0, 7) : commit.hash;
50
- const subject = typeof commit.subject === 'string'
51
- ? (() => {
52
- let returnValue = commit.subject;
53
- const url = repository == null ? repoUrl : [host, owner, repository].filter(Boolean).join('/');
54
- if (url != null) {
55
- const issueURL = `${url}/issues/`;
56
- // Issue URLs.
57
- // eslint-disable-next-line unicorn/prefer-string-replace-all
58
- returnValue = returnValue.replace(/#(\d+)/g, (_, issue) => {
59
- issues.add(issue);
60
- return `[#${issue}](${issueURL}${issue})`;
61
- });
62
- }
63
- if (host != null) {
64
- // User URLs.
65
- // eslint-disable-next-line unicorn/prefer-string-replace-all
66
- returnValue = returnValue.replace(/\B@([\da-z](?:-?[\d/a-z]){0,38})/g, (_, username) => username.includes('/') ? `@${username}` : `[@${username}](${host}/${username})`);
67
- }
68
- return returnValue;
69
- })()
70
- : commit.subject;
71
- // Remove references that already appear in the subject
72
- const references = commit.references.filter((reference) => !issues.has(reference.issue));
73
- return {
74
- ...commit,
75
- type,
76
- hash,
77
- scope,
78
- subject,
79
- references,
80
- header: commit.header,
81
- body: commit.body,
82
- footer: commit.footer,
83
- merge: commit.merge,
84
- revert: commit.revert,
85
- notes,
86
- mentions: commit.mentions,
87
- };
88
- };
89
- return transform;
90
- }
@@ -1,6 +0,0 @@
1
- import type { Options } from 'conventional-changelog-writer';
2
- import { CommitConventionalType } from './data.js';
3
- export interface WriterOptions extends Options {
4
- }
5
- export declare const defaultDisplayTypes: CommitConventionalType[];
6
- export declare const writerOpts: WriterOptions;
@@ -1,28 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.writerOpts = exports.defaultDisplayTypes = void 0;
4
- const node_fs_1 = require("node:fs");
5
- const node_path_1 = require("node:path");
6
- const transform_js_1 = require("./transform.js");
7
- const data_js_1 = require("./data.js");
8
- const basePath = (0, node_path_1.resolve)((0, node_path_1.dirname)(__dirname), './template');
9
- const mainTemplate = (0, node_fs_1.readFileSync)(`${basePath}/template.hbs`, 'utf8');
10
- const headerPartial = (0, node_fs_1.readFileSync)(`${basePath}/header.hbs`, 'utf8');
11
- const commitPartial = (0, node_fs_1.readFileSync)(`${basePath}/commit.hbs`, 'utf8');
12
- const footerPartial = (0, node_fs_1.readFileSync)(`${basePath}/footer.hbs`, 'utf8');
13
- const author = (0, node_fs_1.readFileSync)(`${basePath}/author.hbs`, 'utf8');
14
- exports.defaultDisplayTypes = data_js_1.CommitConventionalType.findWhere((_) => _.changelog);
15
- exports.writerOpts = {
16
- transform: (0, transform_js_1.createTransform)({
17
- displayTypes: exports.defaultDisplayTypes,
18
- }),
19
- groupBy: 'type',
20
- commitGroupsSort: 'title',
21
- commitsSort: ['scope', 'subject'],
22
- noteGroupsSort: 'title',
23
- mainTemplate,
24
- headerPartial,
25
- // eslint-disable-next-line unicorn/prefer-string-replace-all
26
- commitPartial: commitPartial.replace(/{{gitUserInfo}}/g, author),
27
- footerPartial,
28
- };