conventional-changelog-beemo
Advanced tools
Comparing version 3.0.1 to 4.0.0
'use strict'; | ||
Object.defineProperty(exports, '__esModule', { | ||
value: true | ||
}); | ||
const constants = require('./constants.js'); | ||
function checkCommitFormat(commit) { | ||
const match = commit.match(constants.COMMIT_FORMAT_PREFIX); | ||
if (!match) { | ||
return null; | ||
} | ||
const type = match[1]; | ||
return { | ||
breaking: !!match[3] || type === 'breaking' || type === 'break', | ||
scope: match[2] || '', | ||
type: match[1] | ||
type | ||
}; | ||
} | ||
exports.checkCommitFormat = checkCommitFormat; | ||
//# sourceMappingURL=checkCommitFormat.js.map |
'use strict'; | ||
Object.defineProperty(exports, '__esModule', { | ||
value: true | ||
}); | ||
const COMMIT_FORMAT_PREFIX = // eslint-disable-next-line unicorn/no-unsafe-regex | ||
/^(break|breaking|build|chore|ci|cd|deps|docs|feature|fix|internal|misc|new|patch|perf|release|revert|security|style|styles|test|tests|type|types|update)(?:\(([a-zA-Z0-9\-., ]+)\))?:/u; | ||
const COMMIT_FORMAT_PREFIX = | ||
// eslint-disable-next-line unicorn/no-unsafe-regex | ||
/^(break|breaking|build|chore|ci|cd|deps|docs|feature|fix|internal|misc|new|patch|perf|release|revert|security|style|styles|test|tests|type|types|update)(?:\(([a-zA-Z0-9\-., ]+)\))?(!)?:/u; | ||
const GROUPS = [{ | ||
@@ -9,0 +7,0 @@ bump: 'major', |
'use strict'; | ||
Object.defineProperty(exports, '__esModule', { | ||
value: true | ||
}); | ||
const constants = require('./constants.js'); | ||
function getTypeGroup(type) { | ||
const group = constants.GROUPS.find(g => g.types.includes(type)); | ||
if (!group) { | ||
throw new Error(`Cannot find group for type "${type}".`); | ||
} | ||
return group; | ||
} | ||
exports.getTypeGroup = getTypeGroup; | ||
//# sourceMappingURL=getTypeGroup.js.map |
@@ -6,18 +6,10 @@ 'use strict'; | ||
}); | ||
const parserOpts = require('./parserOpts.js'); | ||
const writerOpts = require('./writerOpts.js'); | ||
const whatBump = require('./whatBump.js'); | ||
const checkCommitFormat = require('./checkCommitFormat.js'); | ||
const constants = require('./constants.js'); | ||
const conventionalChangelog = require('./conventionalChangelog.js'); | ||
const getTypeGroup = require('./getTypeGroup.js'); | ||
const parserOpts = require('./parserOpts.js'); | ||
const recommendedBumpOpts = require('./recommendedBumpOpts.js'); | ||
require('./types.js'); | ||
const writerOpts = require('./writerOpts.js'); | ||
/** | ||
@@ -28,11 +20,17 @@ * @copyright 2019, Miles Johnson | ||
function createPreset() { | ||
return { | ||
parser: parserOpts.parserOpts, | ||
writer: writerOpts.writerOpts, | ||
whatBump: whatBump.whatBump | ||
}; | ||
} | ||
exports.parserOpts = parserOpts.parserOpts; | ||
exports.writerOpts = writerOpts.writerOpts; | ||
exports.whatBump = whatBump.whatBump; | ||
exports.checkCommitFormat = checkCommitFormat.checkCommitFormat; | ||
exports.COMMIT_FORMAT_PREFIX = constants.COMMIT_FORMAT_PREFIX; | ||
exports.GROUPS = constants.GROUPS; | ||
exports.conventionalChangelog = conventionalChangelog.conventionalChangelog; | ||
exports.getTypeGroup = getTypeGroup.getTypeGroup; | ||
exports.parserOpts = parserOpts.parserOpts; | ||
exports.recommendedBumpOpts = recommendedBumpOpts.recommendedBumpOpts; | ||
exports.writerOpts = writerOpts.writerOpts; | ||
exports.default = createPreset; | ||
//# sourceMappingURL=index.js.map |
'use strict'; | ||
Object.defineProperty(exports, '__esModule', { | ||
value: true | ||
}); | ||
const constants = require('./constants.js'); | ||
const parserOpts = { | ||
headerCorrespondence: ['type', 'scope', 'message'], | ||
headerCorrespondence: ['type', 'scope', 'breaking', 'message'], | ||
// Keep in sync with checkCommitFormat | ||
@@ -15,3 +10,3 @@ headerPattern: new RegExp(`^${constants.COMMIT_FORMAT_PREFIX.source} (.*)$`, 'u'), | ||
mergePattern: /^Merged? pull request #(\d+) from (.*)/u, | ||
noteKeywords: 'Note', | ||
noteKeywords: ['Note'], | ||
revertCorrespondence: [], | ||
@@ -18,0 +13,0 @@ revertPattern: /^Revert/u |
'use strict'; | ||
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); } | ||
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } | ||
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); } | ||
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; } | ||
function _iterableToArrayLimit(arr, i) { var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"]; if (_i == null) return; var _arr = []; var _n = true; var _d = false; var _s, _e; try { for (_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; } | ||
function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } } | ||
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; } | ||
Object.defineProperty(exports, '__esModule', { | ||
value: true | ||
}); | ||
const fs = require('fs'); | ||
const path = require('path'); | ||
const fs = require('node:fs'); | ||
const path = require('node:path'); | ||
const constants = require('./constants.js'); | ||
const getTypeGroup = require('./getTypeGroup.js'); | ||
const _interopDefault = e => e && e.__esModule ? e : { | ||
default: e | ||
}; | ||
const fs__default = /*#__PURE__*/_interopDefault(fs); | ||
const path__default = /*#__PURE__*/_interopDefault(path); | ||
const path__default = /*#__PURE__*/_interopDefault(path); | ||
/* eslint-disable @typescript-eslint/prefer-nullish-coalescing */ | ||
/* eslint-disable sort-keys, no-param-reassign */ | ||
const groupEmojis = Object.fromEntries(constants.GROUPS.map(group => [group.label, group.emoji])); | ||
@@ -53,8 +38,6 @@ const sortWeights = { | ||
}; | ||
function createLink(paths, context, reference = {}) { | ||
const owner = reference.owner || context.owner; | ||
const repository = reference.repository || context.repository; | ||
function createLink(paths, context, reference) { | ||
const owner = reference?.owner || context.owner; | ||
const repository = reference?.repository || context.repository; | ||
const url = []; | ||
if (repository) { | ||
@@ -64,23 +47,21 @@ if (context.host) { | ||
} | ||
if (owner) { | ||
url.push(owner); | ||
} | ||
url.push(repository); | ||
} else { | ||
} else if (context.repoUrl) { | ||
url.push(context.repoUrl); | ||
} | ||
let base = url.join('/'); | ||
let base = url.join('/'); // If deep linking to a sub-folder (monorepo project, etc), | ||
// If deep linking to a sub-folder (monorepo project, etc), | ||
// extract the base URL if possible. | ||
[// github, gitlab | ||
'tree', 'blob', // bitbucket | ||
[ | ||
// github, gitlab | ||
'tree', 'blob', | ||
// bitbucket | ||
'src'].forEach(browsePart => { | ||
if (base.includes(`/${browsePart}/`)) { | ||
var _base$split = base.split(`/${browsePart}/`); | ||
var _base$split2 = _slicedToArray(_base$split, 1); | ||
base = _base$split2[0]; | ||
@@ -91,3 +72,2 @@ } | ||
} | ||
const writerOpts = { | ||
@@ -101,32 +81,32 @@ mainTemplate: fs__default.default.readFileSync(path__default.default.join(__dirname, '../templates/template.hbs'), 'utf8'), | ||
commitsSort: ['scope', 'message'], | ||
commitGroupsSort(groupA, groupB) { | ||
const aWeight = sortWeights[groupA.title] || 0; | ||
const bWeight = sortWeights[groupB.title] || 0; | ||
if (aWeight === 0 && bWeight === 0) { | ||
return groupA.title.localeCompare(groupB.title); | ||
} | ||
return bWeight - aWeight; | ||
}, | ||
// Notes | ||
noteGroupsSort: 'title', | ||
// Add metadata | ||
transform(commit, context) { | ||
context.groupEmojis = groupEmojis; | ||
transform(originalCommit, context) { | ||
Object.assign(context, { | ||
groupEmojis | ||
}); | ||
if (!originalCommit.type) { | ||
return null; | ||
} | ||
if (!commit.type) { | ||
return undefined; | ||
} // Use consistent values for snapshots | ||
// The original commit (and nested objects) are immutable, | ||
// but we need to modify it, so we'll clone it. | ||
const commit = JSON.parse(JSON.stringify(originalCommit)); | ||
// Use consistent values for snapshots | ||
if (process.env.NODE_ENV === 'test') { | ||
commit.hash = 'a1b2c3d'; | ||
context.date = '2019-02-26'; | ||
} // Override type for specific scenarios | ||
} | ||
// Override type for specific scenarios | ||
if (commit.revert) { | ||
@@ -136,21 +116,24 @@ commit.type = 'revert'; | ||
commit.type = 'misc'; | ||
} // Define metadata based on type | ||
} | ||
// Define metadata based on type | ||
const group = getTypeGroup.getTypeGroup(commit.type); | ||
commit.label = group.label; | ||
if (group.bump === 'major') { | ||
context.isMajor = true; | ||
Object.assign(context, { | ||
isMajor: true | ||
}); | ||
} else if (group.bump === 'minor') { | ||
context.isMinor = true; | ||
} // Use shorthand hashes | ||
Object.assign(context, { | ||
isMinor: true | ||
}); | ||
} | ||
// Use shorthand hashes | ||
if (typeof commit.hash === 'string') { | ||
// eslint-disable-next-line no-magic-numbers | ||
commit.hash = commit.hash.slice(0, 7); | ||
} // Pre-generate links instead of doing it in handlebars | ||
} | ||
// Pre-generate links instead of doing it in handlebars | ||
commit.hashLink = createLink([context.commit, commit.hash], context); | ||
@@ -160,27 +143,25 @@ commit.references.forEach(reference => { | ||
let source = `${reference.repository || ''}#${reference.issue}`; | ||
if (reference.owner) { | ||
source = `${reference.owner}/${source}`; | ||
} | ||
reference.source = source; | ||
}); // Link users | ||
}); | ||
// Link users | ||
if (context.host) { | ||
commit.message = commit.message.replace( // eslint-disable-next-line unicorn/no-unsafe-regex | ||
commit.message = commit.message.replace( | ||
// eslint-disable-next-line unicorn/no-unsafe-regex | ||
/\B@([a-z0-9](?:-?[a-z0-9/]){0,38})/gu, (match, username, index) => { | ||
if (String(username).includes('/') || // Avoid when wrapped in backticks (inline code) | ||
if (String(username).includes('/') || | ||
// Avoid when wrapped in backticks (inline code) | ||
commit.message.charAt(index - 1) === '`' || commit.message.charAt(Number(index) + match.length + 1) === '`') { | ||
return match; | ||
} | ||
return `[@${username}](${context.host}/${username})`; | ||
}); | ||
} | ||
return commit; | ||
} | ||
}; | ||
exports.writerOpts = writerOpts; | ||
//# sourceMappingURL=writerOpts.js.map |
{ | ||
"name": "conventional-changelog-beemo", | ||
"version": "3.0.1", | ||
"version": "4.0.0", | ||
"description": "Conventional changelog preset for Beemo and associated projects.", | ||
@@ -11,6 +11,5 @@ "keywords": [ | ||
"main": "./lib/index.js", | ||
"types": "./dts/index.d.ts", | ||
"types": "./lib/index.d.ts", | ||
"engines": { | ||
"node": ">=12.17.0", | ||
"npm": ">=6.13.0" | ||
"node": ">=18.12.0" | ||
}, | ||
@@ -21,30 +20,29 @@ "repository": "https://github.com/beemojs/conventional-changelog-beemo", | ||
"files": [ | ||
"dts/**/*.d.ts", | ||
"index.js", | ||
"lib/**/*.{js,map}", | ||
"src/**/*.{ts,tsx,json}", | ||
"lib/**/*", | ||
"src/**/*", | ||
"templates/**/*" | ||
], | ||
"scripts": { | ||
"prepare": "beemo create-config", | ||
"build": "packemon build --addEngines", | ||
"pack": "NODE_ENV=production packemon pack --addEngines --declaration standard --declarationConfig tsconfig.build.json", | ||
"check": "yarn run type && yarn run test && yarn run lint", | ||
"coverage": "yarn run jest --coverage", | ||
"lint": "beemo eslint", | ||
"test": "beemo jest -i", | ||
"format": "beemo prettier", | ||
"pack": "packemon pack --addEngines --declaration", | ||
"check": "yarn run type && yarn run test", | ||
"test": "vitest --run", | ||
"format": "prettier --write .", | ||
"release": "yarn run pack && yarn run check && npx np --yolo --no-yarn", | ||
"type": "beemo typescript --noEmit" | ||
"type": "tsc --noEmit" | ||
}, | ||
"dependencies": { | ||
"conventional-changelog-writer": "^8.0.0", | ||
"conventional-commits-parser": "^6.0.0" | ||
}, | ||
"devDependencies": { | ||
"@beemo/cli": "^2.0.6", | ||
"@beemo/core": "^2.1.4", | ||
"@beemo/dev": "^1.7.10", | ||
"@types/node": "^17.0.23", | ||
"@types/shelljs": "^0.8.11", | ||
"conventional-changelog-core": "^4.2.4", | ||
"conventional-recommended-bump": "^6.1.0", | ||
"packemon": "^1.14.1", | ||
"shelljs": "^0.8.5" | ||
"@types/node": "^20.12.11", | ||
"conventional-changelog-core": "^8.0.0", | ||
"conventional-recommended-bump": "^10.0.0", | ||
"packemon": "^4.0.1", | ||
"prettier": "^3.2.5", | ||
"prettier-config-moon": "^1.1.2", | ||
"tsconfig-moon": "^1.3.0", | ||
"typescript": "^5.4.5", | ||
"vitest": "^1.6.0" | ||
}, | ||
@@ -60,2 +58,2 @@ "funding": { | ||
"packageManager": "yarn@3.2.0" | ||
} | ||
} |
@@ -19,2 +19,4 @@ # conventional-changelog-beemo | ||
<type>(<scope>): <message> | ||
<type>!: <breaking message> | ||
<type>(<scope>)!: <breaking message> | ||
``` | ||
@@ -21,0 +23,0 @@ |
import { COMMIT_FORMAT_PREFIX } from './constants'; | ||
import { CommitType } from './types'; | ||
import type { CommitType } from './types'; | ||
export function checkCommitFormat(commit: string): { scope: string; type: CommitType } | null { | ||
export function checkCommitFormat( | ||
commit: string, | ||
): { breaking: boolean; scope: string; type: CommitType } | null { | ||
const match = commit.match(COMMIT_FORMAT_PREFIX); | ||
@@ -11,6 +13,9 @@ | ||
const type = match[1] as CommitType; | ||
return { | ||
breaking: !!match[3] || type === 'breaking' || type === 'break', | ||
scope: match[2] || '', | ||
type: match[1] as CommitType, | ||
type, | ||
}; | ||
} |
@@ -1,6 +0,6 @@ | ||
import { Group } from './types'; | ||
import type { Group } from './types'; | ||
export const COMMIT_FORMAT_PREFIX = | ||
// eslint-disable-next-line unicorn/no-unsafe-regex | ||
/^(break|breaking|build|chore|ci|cd|deps|docs|feature|fix|internal|misc|new|patch|perf|release|revert|security|style|styles|test|tests|type|types|update)(?:\(([a-zA-Z0-9\-., ]+)\))?:/u; | ||
/^(break|breaking|build|chore|ci|cd|deps|docs|feature|fix|internal|misc|new|patch|perf|release|revert|security|style|styles|test|tests|type|types|update)(?:\(([a-zA-Z0-9\-., ]+)\))?(!)?:/u; | ||
@@ -7,0 +7,0 @@ export const GROUPS: Group[] = [ |
import { GROUPS } from './constants'; | ||
import { CommitType, Group } from './types'; | ||
import type { CommitType, Group } from './types'; | ||
@@ -4,0 +4,0 @@ export function getTypeGroup(type: CommitType): Group { |
@@ -6,9 +6,19 @@ /** | ||
import { parserOpts } from './parserOpts'; | ||
import { writerOpts } from './writerOpts'; | ||
import { whatBump } from './whatBump'; | ||
export { checkCommitFormat } from './checkCommitFormat'; | ||
export * from './constants'; | ||
export { conventionalChangelog } from './conventionalChangelog'; | ||
export { getTypeGroup } from './getTypeGroup'; | ||
export { parserOpts } from './parserOpts'; | ||
export { recommendedBumpOpts } from './recommendedBumpOpts'; | ||
export * from './types'; | ||
export { writerOpts } from './writerOpts'; | ||
export { parserOpts, writerOpts, whatBump }; | ||
export default function createPreset() { | ||
return { | ||
parser: parserOpts, | ||
writer: writerOpts, | ||
whatBump, | ||
}; | ||
} |
import { COMMIT_FORMAT_PREFIX } from './constants'; | ||
import { ParserOptions } from './types'; | ||
import type { ParserOptions } from './types'; | ||
export const parserOpts: Partial<ParserOptions> = { | ||
headerCorrespondence: ['type', 'scope', 'message'], | ||
export const parserOpts: ParserOptions = { | ||
headerCorrespondence: ['type', 'scope', 'breaking', 'message'], | ||
// Keep in sync with checkCommitFormat | ||
@@ -10,5 +10,5 @@ headerPattern: new RegExp(`^${COMMIT_FORMAT_PREFIX.source} (.*)$`, 'u'), | ||
mergePattern: /^Merged? pull request #(\d+) from (.*)/u, | ||
noteKeywords: 'Note', | ||
noteKeywords: ['Note'], | ||
revertCorrespondence: [], | ||
revertPattern: /^Revert/u, | ||
}; |
114
src/types.ts
@@ -1,16 +0,14 @@ | ||
export interface Note { | ||
title: string; | ||
text: string; | ||
} | ||
import type { CommitBase, CommitReference } from 'conventional-commits-parser'; | ||
import type { | ||
Context as ContextBase, | ||
TemplatesOptions, | ||
Options as WriterOptionsBase, | ||
} from 'conventional-changelog-writer'; | ||
export interface Reference { | ||
action: string; | ||
owner: string | null; | ||
repository: string | null; | ||
issue: string; | ||
raw: string; | ||
prefix: string; | ||
export type { ParserOptions } from 'conventional-commits-parser'; | ||
export interface Reference extends CommitReference { | ||
// Beemo | ||
issueLink: string; | ||
source: string; | ||
issueLink?: string; | ||
source?: string; | ||
} | ||
@@ -67,12 +65,6 @@ | ||
export interface Commit { | ||
body: string | null; | ||
footer: string | null; | ||
header: string; | ||
mentions: string[]; | ||
merge: string | null; | ||
notes: Note[]; | ||
export interface Commit extends CommitBase { | ||
references: Reference[]; | ||
revert: Record<string, string> | null; | ||
// Beemo | ||
breaking?: string; // ! | ||
hash: string; | ||
@@ -88,78 +80,12 @@ hashLink: string; | ||
export interface Context { | ||
commit: string; | ||
date: string; | ||
host: string; | ||
isPatch: boolean; | ||
isMinor: boolean; | ||
isMajor: boolean; | ||
issue: string; | ||
linkReferences: boolean; | ||
options: Record<string, unknown>; | ||
owner: string; | ||
repository: string; | ||
repoUrl: string; | ||
title: string; | ||
version: string; | ||
// Beemo | ||
export interface Context extends ContextBase<Commit> { | ||
groupEmojis?: { [K in CommitGroupLabel]: string }; | ||
headerLevel?: '#' | '##' | '###'; | ||
groupEmojis?: { [K in CommitGroupLabel]: string }; | ||
isMinor?: boolean; | ||
isMajor?: boolean; | ||
options?: Record<string, unknown>; | ||
} | ||
export type Pattern = RegExp | string | null; | ||
export type Correspondence = string[] | string; | ||
export type Sorter<T> = string[] | string | ((a: T, b: T) => number); | ||
export interface ParserOptions { | ||
fieldPattern: Pattern; | ||
headerPattern: Pattern; | ||
headerCorrespondence: Correspondence; | ||
issuePrefixes: string[] | string; | ||
mergePattern: Pattern; | ||
mergeCorrespondence: Correspondence; | ||
noteKeywords: string[] | string; | ||
referenceActions: string[] | string | null; | ||
revertPattern: Pattern; | ||
revertCorrespondence: Correspondence; | ||
warn: boolean | (() => void); | ||
export interface WriterOptions extends WriterOptionsBase<Commit>, TemplatesOptions { | ||
includeDetails?: boolean; | ||
} | ||
export interface WriterOptions { | ||
commitGroupsSort: Sorter<{ | ||
title: CommitGroupLabel; | ||
commits: Commit[]; | ||
}>; | ||
commitPartial: string; | ||
commitsSort: Sorter<Commit>; | ||
debug: () => void; | ||
doFlush: boolean; | ||
finalizeContext: | ||
| ((context: Context, options: WriterOptions, commits: Commit[], keyCommit: Commit) => Context) | ||
| undefined; | ||
footerPartial: string; | ||
generateOn: | ||
| string | ||
| ((commit: Commit, commits: Commit[], context: Context, options: WriterOptions) => unknown); | ||
groupBy: string; | ||
headerPartial: string; | ||
ignoreReverted: boolean; | ||
includeDetails: boolean; | ||
mainTemplate: string; | ||
noteGroupsSort: Sorter<{ | ||
title: string; | ||
notes: Note[]; | ||
}>; | ||
notesSort: Sorter<Note>; | ||
partials: Record<string, unknown>; | ||
reverse: boolean; | ||
transform: (commit: Commit, context: Context) => Commit | undefined; | ||
} | ||
export type SemverLevel = 0 | 1 | 2 | null; // major | minor | patch | ||
export interface BumpOptions { | ||
parserOpts: Partial<ParserOptions>; | ||
whatBump: (commits: Commit[]) => { level: SemverLevel; reason: string }; | ||
} |
@@ -8,11 +8,7 @@ /* eslint-disable @typescript-eslint/prefer-nullish-coalescing */ | ||
import { getTypeGroup } from './getTypeGroup'; | ||
import { CommitGroupLabel, Context, Reference, WriterOptions } from './types'; | ||
import type { Commit, Context, Reference, WriterOptions } from './types'; | ||
type GroupMap<T> = { [K in CommitGroupLabel]: T }; | ||
const groupEmojis = Object.fromEntries(GROUPS.map((group) => [group.label, group.emoji])); | ||
const groupEmojis = Object.fromEntries( | ||
GROUPS.map((group) => [group.label, group.emoji]), | ||
) as GroupMap<string>; | ||
const sortWeights: GroupMap<number> = { | ||
const sortWeights: Record<string, number> = { | ||
Release: 4, | ||
@@ -33,5 +29,5 @@ Breaking: 3, | ||
function createLink(paths: string[], context: Context, reference: Partial<Reference> = {}): string { | ||
const owner = reference.owner || context.owner; | ||
const repository = reference.repository || context.repository; | ||
function createLink(paths: string[], context: Context, reference?: Reference): string { | ||
const owner = reference?.owner || context.owner; | ||
const repository = reference?.repository || context.repository; | ||
const url: string[] = []; | ||
@@ -49,3 +45,3 @@ | ||
url.push(repository); | ||
} else { | ||
} else if (context.repoUrl) { | ||
url.push(context.repoUrl); | ||
@@ -73,3 +69,3 @@ } | ||
export const writerOpts: Partial<WriterOptions> = { | ||
export const writerOpts: WriterOptions = { | ||
mainTemplate: fs.readFileSync(path.join(__dirname, '../templates/template.hbs'), 'utf8'), | ||
@@ -98,9 +94,13 @@ commitPartial: fs.readFileSync(path.join(__dirname, '../templates/commit.hbs'), 'utf8'), | ||
// Add metadata | ||
transform(commit, context) { | ||
context.groupEmojis = groupEmojis; | ||
transform(originalCommit, context) { | ||
Object.assign(context, { groupEmojis }); | ||
if (!commit.type) { | ||
return undefined; | ||
if (!originalCommit.type) { | ||
return null; | ||
} | ||
// The original commit (and nested objects) are immutable, | ||
// but we need to modify it, so we'll clone it. | ||
const commit: Commit = JSON.parse(JSON.stringify(originalCommit)); | ||
// Use consistent values for snapshots | ||
@@ -125,5 +125,5 @@ if (process.env.NODE_ENV === 'test') { | ||
if (group.bump === 'major') { | ||
context.isMajor = true; | ||
Object.assign(context, { isMajor: true }); | ||
} else if (group.bump === 'minor') { | ||
context.isMinor = true; | ||
Object.assign(context, { isMinor: true }); | ||
} | ||
@@ -130,0 +130,0 @@ |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 1 instance in 1 package
47
108
2
45594
2
834
+ Added@types/semver@7.5.8(transitive)
+ Addedconventional-changelog-writer@8.0.0(transitive)
+ Addedconventional-commits-filter@5.0.0(transitive)
+ Addedconventional-commits-parser@6.0.0(transitive)
+ Addedhandlebars@4.7.8(transitive)
+ Addedmeow@13.2.0(transitive)
+ Addedminimist@1.2.8(transitive)
+ Addedneo-async@2.6.2(transitive)
+ Addedsemver@7.6.3(transitive)
+ Addedsource-map@0.6.1(transitive)
+ Addeduglify-js@3.19.3(transitive)
+ Addedwordwrap@1.0.0(transitive)