UNPKG

@inett/semantic-release-unsquash

Version:

Forked version of semantic-release-unsquash w/o release-notes-generator

84 lines (75 loc) โ€ข 2.64 kB
const { analyzeCommits: originalAnalyzeCommits, } = require('@semantic-release/commit-analyzer'); const { generateNotes: originalGenerateNotes, } = require('@semantic-release/release-notes-generator'); const deepmerge = require('deepmerge'); const { getUnsquashedCommits } = require('./get-unsquashed-commits'); const defaultCommitAnalyzerConfig = { preset: 'conventionalcommits', releaseRules: [ { type: 'feat', release: 'minor' }, { type: 'perf', release: 'minor' }, { type: 'fix', release: 'patch' }, { type: 'change', release: 'minor' }, { type: 'hotfix', release: 'patch' }, { type: 'docs', release: 'patch' }, { type: 'style', release: 'patch' }, { type: 'refactor', release: 'patch' }, { type: 'test', release: 'patch' }, { type: 'chore', release: 'patch' }, { type: 'chore', release: false, scope: 'release' }, ], parserOpts: { noteKeywords: ['BREAKING', 'BREAKING CHANGE', 'BREAKING CHANGES'], }, }; const defaultNotesGeneratorConfig = { preset: 'conventionalcommits', parserOpts: { noteKeywords: ['BREAKING', 'BREAKING CHANGE', 'BREAKING CHANGES'], }, linkCompare: true, linkReferences: true, presetConfig: { types: [ { type: 'feat', section: '๐ŸŽ‰ Features', hidden: false }, { type: 'perf', section: 'โšก๏ธ Performance', hidden: false }, { type: 'fix', section: '๐Ÿ› Bug Fixes', hidden: false }, { type: 'change', section: '๐Ÿงฐ Changes', hidden: false }, { type: 'hotfix', section: '๐Ÿ› Bug Fixes', hidden: false }, { type: 'docs', section: '๐Ÿ“ Docs', hidden: false }, { type: 'style', section: '๐Ÿงฐ Changes', hidden: false }, { type: 'refactor', section: '๐Ÿ”ง Refactor', hidden: false }, { type: 'test', section: '๐Ÿงช Tests', hidden: false }, { type: 'chore', section: '๐Ÿ”ง Miscellaneous Chores', hidden: false }, ], }, writerOpts: { commitsSort: ['section', 'scope'], }, }; const analyzeCommits = async (pluginConfig = {}, context) => { const commits = getUnsquashedCommits(context); const finalConfig = deepmerge( defaultCommitAnalyzerConfig, pluginConfig.commitAnalyzerConfig || {}, ); return originalAnalyzeCommits(finalConfig, { ...context, commits, }); }; const generateNotes = async (pluginConfig = {}, context) => { const commits = getUnsquashedCommits(context); const finalConfig = deepmerge( defaultNotesGeneratorConfig, pluginConfig.notesGeneratorConfig || {}, ); return originalGenerateNotes(finalConfig, { ...context, commits, }); }; module.exports = { analyzeCommits, generateNotes };