Skip to content

Commit

Permalink
feat: support latest conventional-changelog packages
Browse files Browse the repository at this point in the history
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
  • Loading branch information
travi committed May 25, 2024
1 parent 7a2902e commit 0254d7a
Show file tree
Hide file tree
Showing 5 changed files with 1,405 additions and 1,938 deletions.
24 changes: 15 additions & 9 deletions index.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { isUndefined } from "lodash-es";
import { sync as parser } from "conventional-commits-parser";
import filter from "conventional-commits-filter";
import { CommitParser } from "conventional-commits-parser";
import { filterRevertedCommitsSync } from "conventional-commits-filter";
import debugFactory from "debug";
import loadParserConfig from "./lib/load-parser-config.js";
import loadReleaseRules from "./lib/load-release-rules.js";
Expand Down Expand Up @@ -31,7 +31,8 @@ export async function analyzeCommits(pluginConfig, context) {
const config = await loadParserConfig(pluginConfig, context);
let releaseType = null;

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

return true;
})
.map(({ message, ...commitProps }) => ({ rawMsg: message, message, ...commitProps, ...parser(message, config) }))
).every(({ rawMsg, ...commit }) => {
logger.log(`Analyzing commit: %s`, rawMsg);
.map((rawCommit) => ({
...rawCommit,
...parser.parse(rawCommit.message)
}))
);

for (const { message, ...commit } of filteredCommits) {
console.log(`Analyzing commit: %s`, message)
logger.log(`Analyzing commit: %s`, message);
let commitReleaseType;

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

// Break loop if releaseType is the highest
if (releaseType === RELEASE_TYPES[0]) {
return false;
break;
}
}

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

return releaseType;
Expand Down
2 changes: 1 addition & 1 deletion lib/load-parser-config.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,5 +30,5 @@ export default async ({ preset, config, parserOpts, presetConfig }, { cwd }) =>
loadedConfig = await conventionalChangelogAngular();
}

return { ...loadedConfig.parserOpts, ...parserOpts };
return { ...loadedConfig.parser, ...parserOpts };
};
Loading

0 comments on commit 0254d7a

Please sign in to comment.