Skip to content

Commit

Permalink
feat: allow to customize which commits to write
Browse files Browse the repository at this point in the history
Add a list `types` where you can define your generated commits.
This will allow for example @semantic-release/release-notes-generator to improve the changelog.
  • Loading branch information
C0ZEN committed Jan 22, 2022
1 parent c6b2f87 commit 25f2074
Show file tree
Hide file tree
Showing 7 changed files with 175 additions and 216 deletions.
31 changes: 9 additions & 22 deletions .releaserc.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
{
"branches": [
"master"
],
"branches": ["master"],
"plugins": [
[
"@semantic-release/commit-analyzer",
Expand All @@ -19,14 +17,14 @@
{
"type": "perf",
"release": "patch"
},
{
"type": "docs",
"release": "minor"
}
],
"parserOpts": {
"noteKeywords": [
"BREAKING CHANGE",
"BREAKING CHANGES",
"BREAKING"
]
"noteKeywords": ["BREAKING CHANGE", "BREAKING CHANGES", "BREAKING"]
}
}
],
Expand All @@ -35,17 +33,10 @@
{
"config": "angular",
"parserOpts": {
"noteKeywords": [
"BREAKING CHANGE",
"BREAKING CHANGES",
"BREAKING"
]
"noteKeywords": ["BREAKING CHANGE", "BREAKING CHANGES", "BREAKING"]
},
"writerOpts": {
"commitsSort": [
"subject",
"scope"
],
"commitsSort": ["subject", "scope"],
"owner": "C0ZEN"
},
"linkCompare": true,
Expand All @@ -70,11 +61,7 @@
[
"@semantic-release/git",
{
"assets": [
"package.json",
"package-lock.json",
"CHANGELOG.md"
],
"assets": ["package.json", "package-lock.json", "CHANGELOG.md"],
"message": "build(release): new version ${nextRelease.version}"
}
],
Expand Down
12 changes: 7 additions & 5 deletions conventional-changelog.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,10 @@ const Q = require(`q`);
const parserOpts = require(`./parser-opts`);
const writerOpts = require(`./writer-opts`);

module.exports = Q.all([parserOpts, writerOpts]).spread(
(parserOpts, writerOpts) => {
return { parserOpts, writerOpts };
}
);
module.exports = function (config) {
return Q.all([parserOpts, writerOpts(config)]).spread(
(parserOpts, writerOpts) => {
return { parserOpts, writerOpts };
}
);
};
54 changes: 43 additions & 11 deletions index.js
Original file line number Diff line number Diff line change
@@ -1,22 +1,54 @@
"use strict";
const Q = require(`q`);
// eslint-disable-next-line @typescript-eslint/naming-convention
const _ = require(`lodash`);
const conventionalChangelog = require(`./conventional-changelog`);
const parserOpts = require(`./parser-opts`);
const recommendedBumpOpts = require(`./conventional-recommended-bump`);
const writerOpts = require(`./writer-opts`);

module.exports = Q.all([
conventionalChangelog,
parserOpts,
recommendedBumpOpts,
writerOpts,
]).spread(
(conventionalChangelog, parserOpts, recommendedBumpOpts, writerOpts) => {
return {
module.exports = function (parameter) {
// parameter passed can be either a config object or a callback function
if (_.isFunction(parameter)) {
// parameter is a callback object
const config = {};

Q.all([
conventionalChangelog,
parserOpts,
recommendedBumpOpts,
writerOpts,
};
writerOpts(config),
]).spread(
(conventionalChangelog, parserOpts, recommendedBumpOpts, writerOpts) => {
parameter(null, {
conventionalChangelog,
gitRawCommitsOpts: { noMerges: null },
parserOpts,
recommendedBumpOpts,
writerOpts,
});
}
);
} else {
const config = parameter || {};
return presetOpts(config);
}
);
};

function presetOpts(config) {
return Q.all([
conventionalChangelog,
parserOpts,
recommendedBumpOpts,
writerOpts(config),
]).spread(
(conventionalChangelog, parserOpts, recommendedBumpOpts, writerOpts) => {
return {
conventionalChangelog,
parserOpts,
recommendedBumpOpts,
writerOpts,
};
}
);
}
Loading

0 comments on commit 25f2074

Please sign in to comment.