@inett/semantic-release-unsquash
Version:
Forked version of semantic-release-unsquash w/o release-notes-generator
84 lines (75 loc) โข 2.64 kB
JavaScript
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 };