Skip to content

Commit 0254d7a

Browse files
committed
feat: support latest conventional-changelog packages
BREAKING CHANGE: by supporting the latest major versions of conventional-changelog packages, we are dropping support for previous major versions of those packages due to the breaking changes between majors. this only impacts your project if you are installing alongside semantic-release, so updating those packages to latest version should be the only change you need for this update. no action should be necessary if you are using default semantic-release config
1 parent 7a2902e commit 0254d7a

File tree

5 files changed

+1405
-1938
lines changed

5 files changed

+1405
-1938
lines changed

index.js

+15-9
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { isUndefined } from "lodash-es";
2-
import { sync as parser } from "conventional-commits-parser";
3-
import filter from "conventional-commits-filter";
2+
import { CommitParser } from "conventional-commits-parser";
3+
import { filterRevertedCommitsSync } from "conventional-commits-filter";
44
import debugFactory from "debug";
55
import loadParserConfig from "./lib/load-parser-config.js";
66
import loadReleaseRules from "./lib/load-release-rules.js";
@@ -31,7 +31,8 @@ export async function analyzeCommits(pluginConfig, context) {
3131
const config = await loadParserConfig(pluginConfig, context);
3232
let releaseType = null;
3333

34-
filter(
34+
const parser = new CommitParser(config)
35+
const filteredCommits = filterRevertedCommitsSync(
3536
commits
3637
.filter(({ message, hash }) => {
3738
if (!message.trim()) {
@@ -41,9 +42,15 @@ export async function analyzeCommits(pluginConfig, context) {
4142

4243
return true;
4344
})
44-
.map(({ message, ...commitProps }) => ({ rawMsg: message, message, ...commitProps, ...parser(message, config) }))
45-
).every(({ rawMsg, ...commit }) => {
46-
logger.log(`Analyzing commit: %s`, rawMsg);
45+
.map((rawCommit) => ({
46+
...rawCommit,
47+
...parser.parse(rawCommit.message)
48+
}))
49+
);
50+
51+
for (const { message, ...commit } of filteredCommits) {
52+
console.log(`Analyzing commit: %s`, message)
53+
logger.log(`Analyzing commit: %s`, message);
4754
let commitReleaseType;
4855

4956
// Determine release type based on custom releaseRules
@@ -71,11 +78,10 @@ export async function analyzeCommits(pluginConfig, context) {
7178

7279
// Break loop if releaseType is the highest
7380
if (releaseType === RELEASE_TYPES[0]) {
74-
return false;
81+
break;
7582
}
83+
}
7684

77-
return true;
78-
});
7985
logger.log("Analysis of %s commits complete: %s release", commits.length, releaseType || "no");
8086

8187
return releaseType;

lib/load-parser-config.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -30,5 +30,5 @@ export default async ({ preset, config, parserOpts, presetConfig }, { cwd }) =>
3030
loadedConfig = await conventionalChangelogAngular();
3131
}
3232

33-
return { ...loadedConfig.parserOpts, ...parserOpts };
33+
return { ...loadedConfig.parser, ...parserOpts };
3434
};

0 commit comments

Comments
 (0)