Skip to content

Commit a681671

Browse files
committedSep 1, 2023
feat(conventional-changelog-presets): supported new preset format
BREAKING CHANGE: the new preset format is a breaking change when compared to the previous preset format. updating to support the new format means that the old preset format is no longer supported. update your preset to the latest version to maintain compatibility
1 parent eb505f2 commit a681671

5 files changed

+75
-55
lines changed
 

‎lib/load-changelog-config.js

+3-9
Original file line numberDiff line numberDiff line change
@@ -25,19 +25,13 @@ export default async ({ preset, config, parserOpts, writerOpts, presetConfig },
2525

2626
if (preset) {
2727
const presetPackage = `conventional-changelog-${preset.toLowerCase()}`;
28-
loadedConfig = importFrom.silent(__dirname, presetPackage) || importFrom(cwd, presetPackage);
28+
loadedConfig = await (importFrom.silent(__dirname, presetPackage) || importFrom(cwd, presetPackage))(presetConfig);
2929
} else if (config) {
30-
loadedConfig = importFrom.silent(__dirname, config) || importFrom(cwd, config);
30+
loadedConfig = await (importFrom.silent(__dirname, config) || importFrom(cwd, config))();
3131
} else {
32-
loadedConfig = conventionalChangelogAngular;
32+
loadedConfig = await conventionalChangelogAngular();
3333
}
3434

35-
loadedConfig = await (typeof loadedConfig === "function"
36-
? isPlainObject(presetConfig)
37-
? loadedConfig(presetConfig)
38-
: promisify(loadedConfig)()
39-
: loadedConfig);
40-
4135
return {
4236
parserOpts: { ...loadedConfig.parserOpts, ...parserOpts },
4337
writerOpts: { ...loadedConfig.writerOpts, ...writerOpts },

‎package-lock.json

+54-30
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎package.json

+8-8
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
"Gregor Martynus (https://twitter.com/gr2m)"
1212
],
1313
"dependencies": {
14-
"conventional-changelog-angular": "^6.0.0",
14+
"conventional-changelog-angular": "^7.0.0",
1515
"conventional-changelog-writer": "^6.0.0",
1616
"conventional-commits-filter": "^4.0.0",
1717
"conventional-commits-parser": "^5.0.0",
@@ -25,12 +25,12 @@
2525
"devDependencies": {
2626
"ava": "5.3.1",
2727
"c8": "8.0.1",
28-
"conventional-changelog-atom": "3.0.0",
28+
"conventional-changelog-atom": "4.0.0",
2929
"conventional-changelog-conventionalcommits": "7.0.1",
30-
"conventional-changelog-ember": "3.0.0",
31-
"conventional-changelog-eslint": "4.0.0",
32-
"conventional-changelog-express": "3.0.0",
33-
"conventional-changelog-jshint": "3.0.0",
30+
"conventional-changelog-ember": "4.0.0",
31+
"conventional-changelog-eslint": "5.0.0",
32+
"conventional-changelog-express": "4.0.0",
33+
"conventional-changelog-jshint": "4.0.0",
3434
"escape-string-regexp": "5.0.0",
3535
"fs-extra": "11.1.1",
3636
"prettier": "3.0.3",
@@ -92,8 +92,8 @@
9292
"lint:fix": "prettier --write \"*.{js,json,md}\" \".github/**/*.{md,yml}\" \"{bin,lib,test}/*.js\"",
9393
"pretest": "npm run lint",
9494
"semantic-release": "semantic-release",
95-
"test": "c8 ava -v",
96-
"test:ci": "c8 ava -v"
95+
"test": "c8 ava --verbose",
96+
"test:ci": "c8 ava --verbose"
9797
},
9898
"type": "module",
9999
"ava": {

‎test/integration.test.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import escape from "escape-string-regexp";
66
import { temporaryDirectory } from "tempy";
77
import * as td from "testdouble";
88
import streamBuffers from "stream-buffers";
9+
import conventionalChangelogEslint from "conventional-changelog-eslint";
910

1011
const cwd = process.cwd();
1112
const host = "https://github.com";
@@ -178,7 +179,7 @@ test.serial('Accept a "parseOpts" and "writerOpts" objects as option', async (t)
178179
referenceActions: ["keyword"],
179180
issuePrefixes: ["#", "JIRA-"],
180181
},
181-
writerOpts: (await promisify((await import("conventional-changelog-eslint")).default)()).writerOpts,
182+
writerOpts: (await conventionalChangelogEslint()).writerOpts,
182183
},
183184
{ cwd, options: { repositoryUrl }, lastRelease, nextRelease, commits }
184185
);

‎test/load-changelog-config.test.js

+8-7
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import test from "ava";
2+
import conventionalChangelogAngular from "conventional-changelog-angular";
23
import loadChangelogConfig from "../lib/load-changelog-config.js";
34

45
const cwd = process.cwd();
@@ -42,7 +43,7 @@ loadConfig.title = (providedTitle, config) => `${providedTitle} Load "${config}"
4243

4344
test('Load "conventional-changelog-angular" by default', async (t) => {
4445
const changelogConfig = await loadChangelogConfig({}, { cwd });
45-
const angularChangelogConfig = await (await import("conventional-changelog-angular")).default;
46+
const angularChangelogConfig = await conventionalChangelogAngular();
4647

4748
t.deepEqual(changelogConfig.parserOpts, angularChangelogConfig.parserOpts);
4849
t.deepEqual(changelogConfig.writerOpts, angularChangelogConfig.writerOpts);
@@ -54,7 +55,7 @@ test('Accept a "parserOpts" object as option', async (t) => {
5455
headerCorrespondence: ["tag", "shortDesc"],
5556
};
5657
const changelogConfig = await loadChangelogConfig({ parserOpts: customParserOptions }, { cwd });
57-
const angularChangelogConfig = await (await import("conventional-changelog-angular")).default;
58+
const angularChangelogConfig = await conventionalChangelogAngular();
5859

5960
t.is(customParserOptions.headerPattern, changelogConfig.parserOpts.headerPattern);
6061
t.deepEqual(customParserOptions.headerCorrespondence, changelogConfig.parserOpts.headerCorrespondence);
@@ -65,7 +66,7 @@ test('Accept a "parserOpts" object as option', async (t) => {
6566
test('Accept a "writerOpts" object as option', async (t) => {
6667
const customWriterOptions = { commitGroupsSort: "title", commitsSort: ["scope", "subject"] };
6768
const changelogConfig = await loadChangelogConfig({ writerOpts: customWriterOptions }, { cwd });
68-
const angularChangelogConfig = await (await import("conventional-changelog-angular")).default;
69+
const angularChangelogConfig = await conventionalChangelogAngular();
6970

7071
t.is(customWriterOptions.commitGroupsSort, changelogConfig.writerOpts.commitGroupsSort);
7172
t.deepEqual(customWriterOptions.commitsSort, changelogConfig.writerOpts.commitsSort);
@@ -79,7 +80,7 @@ test('Accept a partial "parserOpts" object as option that overwrite a preset', a
7980
headerCorrespondence: ["tag", "shortDesc"],
8081
};
8182
const changelogConfig = await loadChangelogConfig({ parserOpts: customParserOptions, preset: "angular" }, { cwd });
82-
const angularChangelogConfig = await (await import("conventional-changelog-angular")).default;
83+
const angularChangelogConfig = await conventionalChangelogAngular();
8384

8485
t.is(customParserOptions.headerPattern, changelogConfig.parserOpts.headerPattern);
8586
t.deepEqual(customParserOptions.headerCorrespondence, changelogConfig.parserOpts.headerCorrespondence);
@@ -90,7 +91,7 @@ test('Accept a partial "parserOpts" object as option that overwrite a preset', a
9091
test('Accept a "writerOpts" object as option that overwrite a preset', async (t) => {
9192
const customWriterOptions = { commitGroupsSort: "title", commitsSort: ["scope", "subject"] };
9293
const changelogConfig = await loadChangelogConfig({ writerOpts: customWriterOptions, preset: "angular" }, { cwd });
93-
const angularChangelogConfig = await (await import("conventional-changelog-angular")).default;
94+
const angularChangelogConfig = await conventionalChangelogAngular();
9495

9596
t.is(customWriterOptions.commitGroupsSort, changelogConfig.writerOpts.commitGroupsSort);
9697
t.deepEqual(customWriterOptions.commitsSort, changelogConfig.writerOpts.commitsSort);
@@ -110,7 +111,7 @@ test('Accept a partial "parserOpts" object as option that overwrite a config', a
110111
},
111112
{ cwd }
112113
);
113-
const angularChangelogConfig = await (await import("conventional-changelog-angular")).default;
114+
const angularChangelogConfig = await conventionalChangelogAngular();
114115

115116
t.is(customParserOptions.headerPattern, changelogConfig.parserOpts.headerPattern);
116117
t.deepEqual(customParserOptions.headerCorrespondence, changelogConfig.parserOpts.headerCorrespondence);
@@ -127,7 +128,7 @@ test('Accept a "writerOpts" object as option that overwrite a config', async (t)
127128
},
128129
{ cwd }
129130
);
130-
const angularChangelogConfig = await (await import("conventional-changelog-angular")).default;
131+
const angularChangelogConfig = await conventionalChangelogAngular();
131132

132133
t.is(customWriterOptions.commitGroupsSort, changelogConfig.writerOpts.commitGroupsSort);
133134
t.deepEqual(customWriterOptions.commitsSort, changelogConfig.writerOpts.commitsSort);

0 commit comments

Comments
 (0)
Please sign in to comment.