From a68167199e131e1f72fd259d45848112744a3982 Mon Sep 17 00:00:00 2001 From: Matt Travi Date: Fri, 1 Sep 2023 17:18:01 -0500 Subject: [PATCH] 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 --- lib/load-changelog-config.js | 12 ++--- package-lock.json | 84 +++++++++++++++++++----------- package.json | 16 +++--- test/integration.test.js | 3 +- test/load-changelog-config.test.js | 15 +++--- 5 files changed, 75 insertions(+), 55 deletions(-) diff --git a/lib/load-changelog-config.js b/lib/load-changelog-config.js index f2b21dbd..8b9dd489 100644 --- a/lib/load-changelog-config.js +++ b/lib/load-changelog-config.js @@ -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))(); } else { - loadedConfig = conventionalChangelogAngular; + loadedConfig = await conventionalChangelogAngular(); } - loadedConfig = await (typeof loadedConfig === "function" - ? isPlainObject(presetConfig) - ? loadedConfig(presetConfig) - : promisify(loadedConfig)() - : loadedConfig); - return { parserOpts: { ...loadedConfig.parserOpts, ...parserOpts }, writerOpts: { ...loadedConfig.writerOpts, ...writerOpts }, diff --git a/package-lock.json b/package-lock.json index 4afdd218..a6bf7d26 100644 --- a/package-lock.json +++ b/package-lock.json @@ -9,7 +9,7 @@ "version": "0.0.0-development", "license": "MIT", "dependencies": { - "conventional-changelog-angular": "^6.0.0", + "conventional-changelog-angular": "^7.0.0", "conventional-changelog-writer": "^6.0.0", "conventional-commits-filter": "^4.0.0", "conventional-commits-parser": "^5.0.0", @@ -23,12 +23,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": "7.0.1", - "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", "escape-string-regexp": "5.0.0", "fs-extra": "11.1.1", "prettier": "3.0.3", @@ -474,6 +474,18 @@ "semantic-release": ">=20.1.0" } }, + "node_modules/@semantic-release/commit-analyzer/node_modules/conventional-changelog-angular": { + "version": "6.0.0", + "resolved": "https://registry.npmjs.org/conventional-changelog-angular/-/conventional-changelog-angular-6.0.0.tgz", + "integrity": "sha512-6qLgrBF4gueoC7AFVHu51nHL9pF9FRjXrH+ceVf7WmAfH3gs+gEYOkvxhjMPjZu57I4AGUGoNTY8V7Hrgf1uqg==", + "dev": true, + "dependencies": { + "compare-func": "^2.0.0" + }, + "engines": { + "node": ">=14" + } + }, "node_modules/@semantic-release/commit-analyzer/node_modules/conventional-commits-filter": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/conventional-commits-filter/-/conventional-commits-filter-3.0.0.tgz", @@ -639,6 +651,18 @@ "semantic-release": ">=20.1.0" } }, + "node_modules/@semantic-release/release-notes-generator/node_modules/conventional-changelog-angular": { + "version": "6.0.0", + "resolved": "https://registry.npmjs.org/conventional-changelog-angular/-/conventional-changelog-angular-6.0.0.tgz", + "integrity": "sha512-6qLgrBF4gueoC7AFVHu51nHL9pF9FRjXrH+ceVf7WmAfH3gs+gEYOkvxhjMPjZu57I4AGUGoNTY8V7Hrgf1uqg==", + "dev": true, + "dependencies": { + "compare-func": "^2.0.0" + }, + "engines": { + "node": ">=14" + } + }, "node_modules/@semantic-release/release-notes-generator/node_modules/conventional-commits-filter": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/conventional-commits-filter/-/conventional-commits-filter-3.0.0.tgz", @@ -1352,23 +1376,23 @@ } }, "node_modules/conventional-changelog-angular": { - "version": "6.0.0", - "resolved": "https://registry.npmjs.org/conventional-changelog-angular/-/conventional-changelog-angular-6.0.0.tgz", - "integrity": "sha512-6qLgrBF4gueoC7AFVHu51nHL9pF9FRjXrH+ceVf7WmAfH3gs+gEYOkvxhjMPjZu57I4AGUGoNTY8V7Hrgf1uqg==", + "version": "7.0.0", + "resolved": "https://registry.npmjs.org/conventional-changelog-angular/-/conventional-changelog-angular-7.0.0.tgz", + "integrity": "sha512-ROjNchA9LgfNMTTFSIWPzebCwOGFdgkEq45EnvvrmSLvCtAw0HSmrCs7/ty+wAeYUZyNay0YMUNYFTRL72PkBQ==", "dependencies": { "compare-func": "^2.0.0" }, "engines": { - "node": ">=14" + "node": ">=16" } }, "node_modules/conventional-changelog-atom": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/conventional-changelog-atom/-/conventional-changelog-atom-3.0.0.tgz", - "integrity": "sha512-pnN5bWpH+iTUWU3FaYdw5lJmfWeqSyrUkG+wyHBI9tC1dLNnHkbAOg1SzTQ7zBqiFrfo55h40VsGXWMdopwc5g==", + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/conventional-changelog-atom/-/conventional-changelog-atom-4.0.0.tgz", + "integrity": "sha512-q2YtiN7rnT1TGwPTwjjBSIPIzDJCRE+XAUahWxnh+buKK99Kks4WLMHoexw38GXx9OUxAsrp44f9qXe5VEMYhw==", "dev": true, "engines": { - "node": ">=14" + "node": ">=16" } }, "node_modules/conventional-changelog-conventionalcommits": { @@ -1384,42 +1408,42 @@ } }, "node_modules/conventional-changelog-ember": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/conventional-changelog-ember/-/conventional-changelog-ember-3.0.0.tgz", - "integrity": "sha512-7PYthCoSxIS98vWhVcSphMYM322OxptpKAuHYdVspryI0ooLDehRXWeRWgN+zWSBXKl/pwdgAg8IpLNSM1/61A==", + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/conventional-changelog-ember/-/conventional-changelog-ember-4.0.0.tgz", + "integrity": "sha512-D0IMhwcJUg1Y8FSry6XAplEJcljkHVlvAZddhhsdbL1rbsqRsMfGx/PIkPYq0ru5aDgn+OxhQ5N5yR7P9mfsvA==", "dev": true, "engines": { - "node": ">=14" + "node": ">=16" } }, "node_modules/conventional-changelog-eslint": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/conventional-changelog-eslint/-/conventional-changelog-eslint-4.0.0.tgz", - "integrity": "sha512-nEZ9byP89hIU0dMx37JXQkE1IpMmqKtsaR24X7aM3L6Yy/uAtbb+ogqthuNYJkeO1HyvK7JsX84z8649hvp43Q==", + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/conventional-changelog-eslint/-/conventional-changelog-eslint-5.0.0.tgz", + "integrity": "sha512-6JtLWqAQIeJLn/OzUlYmzd9fKeNSWmQVim9kql+v4GrZwLx807kAJl3IJVc3jTYfVKWLxhC3BGUxYiuVEcVjgA==", "dev": true, "engines": { - "node": ">=14" + "node": ">=16" } }, "node_modules/conventional-changelog-express": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/conventional-changelog-express/-/conventional-changelog-express-3.0.0.tgz", - "integrity": "sha512-HqxihpUMfIuxvlPvC6HltA4ZktQEUan/v3XQ77+/zbu8No/fqK3rxSZaYeHYant7zRxQNIIli7S+qLS9tX9zQA==", + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/conventional-changelog-express/-/conventional-changelog-express-4.0.0.tgz", + "integrity": "sha512-yWyy5c7raP9v7aTvPAWzqrztACNO9+FEI1FSYh7UP7YT1AkWgv5UspUeB5v3Ibv4/o60zj2o9GF2tqKQ99lIsw==", "dev": true, "engines": { - "node": ">=14" + "node": ">=16" } }, "node_modules/conventional-changelog-jshint": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/conventional-changelog-jshint/-/conventional-changelog-jshint-3.0.0.tgz", - "integrity": "sha512-bQof4byF4q+n+dwFRkJ/jGf9dCNUv4/kCDcjeCizBvfF81TeimPZBB6fT4HYbXgxxfxWXNl/i+J6T0nI4by6DA==", + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/conventional-changelog-jshint/-/conventional-changelog-jshint-4.0.0.tgz", + "integrity": "sha512-LyXq1bbl0yG0Ai1SbLxIk8ZxUOe3AjnlwE6sVRQmMgetBk+4gY9EO3d00zlEt8Y8gwsITytDnPORl8al7InTjg==", "dev": true, "dependencies": { "compare-func": "^2.0.0" }, "engines": { - "node": ">=14" + "node": ">=16" } }, "node_modules/conventional-changelog-writer": { diff --git a/package.json b/package.json index 4bfead53..66a3be2f 100644 --- a/package.json +++ b/package.json @@ -11,7 +11,7 @@ "Gregor Martynus (https://twitter.com/gr2m)" ], "dependencies": { - "conventional-changelog-angular": "^6.0.0", + "conventional-changelog-angular": "^7.0.0", "conventional-changelog-writer": "^6.0.0", "conventional-commits-filter": "^4.0.0", "conventional-commits-parser": "^5.0.0", @@ -25,12 +25,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": "7.0.1", - "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", "escape-string-regexp": "5.0.0", "fs-extra": "11.1.1", "prettier": "3.0.3", @@ -92,8 +92,8 @@ "lint:fix": "prettier --write \"*.{js,json,md}\" \".github/**/*.{md,yml}\" \"{bin,lib,test}/*.js\"", "pretest": "npm run lint", "semantic-release": "semantic-release", - "test": "c8 ava -v", - "test:ci": "c8 ava -v" + "test": "c8 ava --verbose", + "test:ci": "c8 ava --verbose" }, "type": "module", "ava": { diff --git a/test/integration.test.js b/test/integration.test.js index 4764c316..4c380107 100644 --- a/test/integration.test.js +++ b/test/integration.test.js @@ -6,6 +6,7 @@ import escape from "escape-string-regexp"; import { temporaryDirectory } from "tempy"; import * as td from "testdouble"; import streamBuffers from "stream-buffers"; +import conventionalChangelogEslint from "conventional-changelog-eslint"; const cwd = process.cwd(); const host = "https://github.com"; @@ -178,7 +179,7 @@ test.serial('Accept a "parseOpts" and "writerOpts" objects as option', async (t) referenceActions: ["keyword"], issuePrefixes: ["#", "JIRA-"], }, - writerOpts: (await promisify((await import("conventional-changelog-eslint")).default)()).writerOpts, + writerOpts: (await conventionalChangelogEslint()).writerOpts, }, { cwd, options: { repositoryUrl }, lastRelease, nextRelease, commits } ); diff --git a/test/load-changelog-config.test.js b/test/load-changelog-config.test.js index 40c3a724..45830037 100644 --- a/test/load-changelog-config.test.js +++ b/test/load-changelog-config.test.js @@ -1,4 +1,5 @@ import test from "ava"; +import conventionalChangelogAngular from "conventional-changelog-angular"; import loadChangelogConfig from "../lib/load-changelog-config.js"; const cwd = process.cwd(); @@ -42,7 +43,7 @@ loadConfig.title = (providedTitle, config) => `${providedTitle} Load "${config}" test('Load "conventional-changelog-angular" by default', async (t) => { const changelogConfig = await loadChangelogConfig({}, { cwd }); - const angularChangelogConfig = await (await import("conventional-changelog-angular")).default; + const angularChangelogConfig = await conventionalChangelogAngular(); t.deepEqual(changelogConfig.parserOpts, angularChangelogConfig.parserOpts); t.deepEqual(changelogConfig.writerOpts, angularChangelogConfig.writerOpts); @@ -54,7 +55,7 @@ test('Accept a "parserOpts" object as option', async (t) => { headerCorrespondence: ["tag", "shortDesc"], }; const changelogConfig = await loadChangelogConfig({ parserOpts: customParserOptions }, { cwd }); - const angularChangelogConfig = await (await import("conventional-changelog-angular")).default; + const angularChangelogConfig = await conventionalChangelogAngular(); t.is(customParserOptions.headerPattern, changelogConfig.parserOpts.headerPattern); t.deepEqual(customParserOptions.headerCorrespondence, changelogConfig.parserOpts.headerCorrespondence); @@ -65,7 +66,7 @@ test('Accept a "parserOpts" object as option', async (t) => { test('Accept a "writerOpts" object as option', async (t) => { const customWriterOptions = { commitGroupsSort: "title", commitsSort: ["scope", "subject"] }; const changelogConfig = await loadChangelogConfig({ writerOpts: customWriterOptions }, { cwd }); - const angularChangelogConfig = await (await import("conventional-changelog-angular")).default; + const angularChangelogConfig = await conventionalChangelogAngular(); t.is(customWriterOptions.commitGroupsSort, changelogConfig.writerOpts.commitGroupsSort); t.deepEqual(customWriterOptions.commitsSort, changelogConfig.writerOpts.commitsSort); @@ -79,7 +80,7 @@ test('Accept a partial "parserOpts" object as option that overwrite a preset', a headerCorrespondence: ["tag", "shortDesc"], }; const changelogConfig = await loadChangelogConfig({ parserOpts: customParserOptions, preset: "angular" }, { cwd }); - const angularChangelogConfig = await (await import("conventional-changelog-angular")).default; + const angularChangelogConfig = await conventionalChangelogAngular(); t.is(customParserOptions.headerPattern, changelogConfig.parserOpts.headerPattern); t.deepEqual(customParserOptions.headerCorrespondence, changelogConfig.parserOpts.headerCorrespondence); @@ -90,7 +91,7 @@ test('Accept a partial "parserOpts" object as option that overwrite a preset', a test('Accept a "writerOpts" object as option that overwrite a preset', async (t) => { const customWriterOptions = { commitGroupsSort: "title", commitsSort: ["scope", "subject"] }; const changelogConfig = await loadChangelogConfig({ writerOpts: customWriterOptions, preset: "angular" }, { cwd }); - const angularChangelogConfig = await (await import("conventional-changelog-angular")).default; + const angularChangelogConfig = await conventionalChangelogAngular(); t.is(customWriterOptions.commitGroupsSort, changelogConfig.writerOpts.commitGroupsSort); t.deepEqual(customWriterOptions.commitsSort, changelogConfig.writerOpts.commitsSort); @@ -110,7 +111,7 @@ test('Accept a partial "parserOpts" object as option that overwrite a config', a }, { cwd } ); - const angularChangelogConfig = await (await import("conventional-changelog-angular")).default; + const angularChangelogConfig = await conventionalChangelogAngular(); t.is(customParserOptions.headerPattern, changelogConfig.parserOpts.headerPattern); t.deepEqual(customParserOptions.headerCorrespondence, changelogConfig.parserOpts.headerCorrespondence); @@ -127,7 +128,7 @@ test('Accept a "writerOpts" object as option that overwrite a config', async (t) }, { cwd } ); - const angularChangelogConfig = await (await import("conventional-changelog-angular")).default; + const angularChangelogConfig = await conventionalChangelogAngular(); t.is(customWriterOptions.commitGroupsSort, changelogConfig.writerOpts.commitGroupsSort); t.deepEqual(customWriterOptions.commitsSort, changelogConfig.writerOpts.commitsSort);