Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(conventional-changelog-presets): supported new preset format #519

Merged
merged 9 commits into from
Sep 18, 2023
12 changes: 3 additions & 9 deletions lib/load-parser-config.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,18 +22,12 @@ export default async ({ preset, config, parserOpts, presetConfig }, { cwd }) =>

if (preset) {
const presetPackage = `conventional-changelog-${preset.toLowerCase()}`;
loadedConfig = importFrom.silent(__dirname, presetPackage) || importFrom(cwd, presetPackage);
loadedConfig = await (importFrom.silent(__dirname, presetPackage) || importFrom(cwd, presetPackage))(presetConfig);
} else if (config) {
loadedConfig = importFrom.silent(__dirname, config) || importFrom(cwd, config);
loadedConfig = await (importFrom.silent(__dirname, config) || importFrom(cwd, config))();
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

} else {
loadedConfig = conventionalChangelogAngular;
loadedConfig = await conventionalChangelogAngular();
}

loadedConfig = await (typeof loadedConfig === "function"
? isPlainObject(presetConfig)
? loadedConfig(presetConfig)
: promisify(loadedConfig)()
: loadedConfig);

Comment on lines -32 to -37
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

return { ...loadedConfig.parserOpts, ...parserOpts };
};
129 changes: 84 additions & 45 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 7 additions & 7 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@
"Gregor Martynus (https://twitter.com/gr2m)"
],
"dependencies": {
"conventional-changelog-angular": "^6.0.0",
"conventional-commits-filter": "^3.0.0",
"conventional-changelog-angular": "^7.0.0",
"conventional-commits-filter": "^4.0.0",
"conventional-commits-parser": "^5.0.0",
"debug": "^4.0.0",
"import-from": "^4.0.0",
Expand All @@ -28,12 +28,12 @@
"devDependencies": {
"ava": "5.3.1",
"c8": "8.0.1",
"conventional-changelog-atom": "3.0.0",
"conventional-changelog-atom": "4.0.0",
"conventional-changelog-conventionalcommits": "6.1.0",
"conventional-changelog-ember": "3.0.0",
"conventional-changelog-eslint": "4.0.0",
"conventional-changelog-express": "3.0.0",
"conventional-changelog-jshint": "3.0.0",
"conventional-changelog-ember": "4.0.0",
"conventional-changelog-eslint": "5.0.0",
"conventional-changelog-express": "4.0.0",
"conventional-changelog-jshint": "4.0.0",
"prettier": "3.0.3",
"semantic-release": "21.1.1",
"sinon": "15.2.0"
Expand Down
6 changes: 3 additions & 3 deletions test/integration.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -99,14 +99,14 @@ test('Accept a partial "parseOpts" object as option', async (t) => {

test("Exclude commits if they have a matching revert commits", async (t) => {
const commits = [
{ hash: "123", message: "feat(scope): First feature" },
{ hash: "456", message: "revert: feat(scope): First feature\n\nThis reverts commit 123.\n" },
{ message: "fix(scope): First fix" },
{ hash: "456", message: "revert: feat(scope): First feature\n\nThis reverts commit 123.\n" },
{ hash: "123", message: "feat(scope): First feature" },
];
const releaseType = await analyzeCommits({}, { cwd, commits, logger: t.context.logger });

t.is(releaseType, "patch");
t.true(t.context.log.calledWith("Analyzing commit: %s", commits[2].message));
t.true(t.context.log.calledWith("Analyzing commit: %s", commits[0].message));
t.true(t.context.log.calledWith("The release type for the commit is %s", "patch"));
t.true(t.context.log.calledWith("Analysis of %s commits complete: %s release", 3, "patch"));
});
Expand Down
2 changes: 1 addition & 1 deletion test/load-parser-config.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ loadConfig.title = (providedTitle, config) => `${providedTitle} Load "${config}"
test('Load "conventional-changelog-angular" by default', async (t) => {
t.deepEqual(
await loadParserConfig({}, { cwd }),
(await (await import("conventional-changelog-angular")).default).parserOpts
(await (await import("conventional-changelog-angular")).default()).parserOpts
);
});

Expand Down