Skip to content

Commit

Permalink
feat: support latest conventional-changelog packages (#643)
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
sherbakovdev committed May 17, 2024
1 parent 990752b commit 2bce0d3
Show file tree
Hide file tree
Showing 7 changed files with 233 additions and 100 deletions.
9 changes: 5 additions & 4 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ import { format } from "url";
import { find, merge } from "lodash-es";
import getStream from "get-stream";
import intoStream from "into-stream";
import { sync as parser } from "conventional-commits-parser";
import { CommitParser } from "conventional-commits-parser";
import writer from "./wrappers/conventional-changelog-writer.js";
import filter from "conventional-commits-filter";
import { filterRevertedCommitsSync } from "conventional-commits-filter";
import { readPackageUp } from "read-pkg-up";
import debugFactory from "debug";
import loadChangelogConfig from "./lib/load-changelog-config.js";
Expand Down Expand Up @@ -43,7 +43,8 @@ export async function generateNotes(pluginConfig, context) {

const { issue, commit, referenceActions, issuePrefixes } =
find(HOSTS_CONFIG, (conf) => conf.hostname === hostname) || HOSTS_CONFIG.default;
const parsedCommits = filter(
const parser = new CommitParser({ referenceActions, issuePrefixes, ...parserOpts });
const parsedCommits = filterRevertedCommitsSync(
commits
.filter(({ message, hash }) => {
if (!message.trim()) {
Expand All @@ -55,7 +56,7 @@ export async function generateNotes(pluginConfig, context) {
})
.map((rawCommit) => ({
...rawCommit,
...parser(rawCommit.message, { referenceActions, issuePrefixes, ...parserOpts }),
...parser.parse(rawCommit.message),
}))
);
const previousTag = lastRelease.gitTag || lastRelease.gitHead;
Expand Down
4 changes: 2 additions & 2 deletions lib/load-changelog-config.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ export default async ({ preset, config, parserOpts, writerOpts, presetConfig },
}

return {
parserOpts: { ...loadedConfig.parserOpts, ...parserOpts },
writerOpts: { ...loadedConfig.writerOpts, ...writerOpts },
parserOpts: { ...loadedConfig.parser, ...parserOpts },
writerOpts: { ...loadedConfig.writer, ...writerOpts },
};
};

0 comments on commit 2bce0d3

Please sign in to comment.