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 #526

Merged
merged 8 commits into from
Sep 18, 2023
5 changes: 3 additions & 2 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,9 @@ jobs:
strategy:
matrix:
node-version:
- 18.0.0
- 19
- 18.17.0
- 20.6.1
- 20
os:
- ubuntu-latest
runs-on: "${{ matrix.os }}"
Expand Down
1 change: 1 addition & 0 deletions .nvmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
v18
12 changes: 3 additions & 9 deletions lib/load-changelog-config.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,19 +25,13 @@ export default async ({ preset, config, parserOpts, writerOpts, presetConfig },

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.

this should also accept the config, but we dont currently have a test for that case, so want to add those together

Copy link
Member Author

Choose a reason for hiding this comment

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

in the interest of getting the beta promoted, i'm ok with completing this detail after this is merged

} else {
loadedConfig = conventionalChangelogAngular;
loadedConfig = await conventionalChangelogAngular();
Copy link
Member Author

Choose a reason for hiding this comment

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

the angular config currently does not accept config, so i think it is ok to avoid passing the config here

}

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

Comment on lines -35 to -40
Copy link
Member Author

Choose a reason for hiding this comment

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

since this took me a bit to understand, capturing the reason this is being removed. with the previous preset format, most presets returned an object, but the conventionalcommits preset returned a function that accepted config.

the change that resulted in the breaking changes across the conventional-changelog presets was an effort to unify the interface across those presets. therefore, we can instead pass the config above and remove the handling of the different potential return shapes. nice work @dangreen!

Copy link
Member Author

Choose a reason for hiding this comment

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

i figured this out after cutting the first beta of the commit-analyzer plugin, so will make this change there too soon

return {
parserOpts: { ...loadedConfig.parserOpts, ...parserOpts },
writerOpts: { ...loadedConfig.writerOpts, ...writerOpts },
Expand Down