diff --git a/index.js b/index.js index a3efe594..4c51b7f0 100644 --- a/index.js +++ b/index.js @@ -1,5 +1,5 @@ import { format } from "url"; -import { find, merge } from "lodash-es"; +import { defu } from "defu"; import getStream from "get-stream"; import intoStream from "into-stream"; import { CommitParser } from "conventional-commits-parser"; @@ -42,7 +42,7 @@ export async function generateNotes(pluginConfig, context) { const [, owner, repository] = /^\/(?[^/]+)?\/?(?.+)?$/.exec(pathname) || []; const { issue, commit, referenceActions, issuePrefixes } = - find(HOSTS_CONFIG, (conf) => conf.hostname === hostname) || HOSTS_CONFIG.default; + Object.values(HOSTS_CONFIG).find((conf) => conf.hostname === hostname) || HOSTS_CONFIG.default; const parser = new CommitParser({ referenceActions, issuePrefixes, ...parserOpts }); const parsedCommits = filterRevertedCommitsSync( commits @@ -62,21 +62,19 @@ export async function generateNotes(pluginConfig, context) { const previousTag = lastRelease.gitTag || lastRelease.gitHead; const currentTag = nextRelease.gitTag || nextRelease.gitHead; const { host: hostConfig, linkCompare, linkReferences, commit: commitConfig, issue: issueConfig } = pluginConfig; - const changelogContext = merge( - { - version: nextRelease.version, - host: format({ protocol, hostname, port }), - owner, - repository, - previousTag, - currentTag, - linkCompare: currentTag && previousTag, - issue, - commit, - packageData: ((await readPackageUp({ normalize: false, cwd })) || {}).packageJson, - }, - { host: hostConfig, linkCompare, linkReferences, commit: commitConfig, issue: issueConfig } - ); + const changelogContext = { + version: nextRelease.version, + host: hostConfig ?? format({ protocol, hostname, port }), + owner, + repository, + previousTag, + currentTag, + linkCompare: linkCompare ?? (currentTag && previousTag), + linkReferences, + issue: issueConfig ?? issue, + commit: commitConfig ?? commit, + packageData: ((await readPackageUp({ normalize: false, cwd })) || {}).packageJson, + }; debug("version: %o", changelogContext.version); debug("host: %o", changelogContext.hostname); diff --git a/package-lock.json b/package-lock.json index c7ef4b61..49e61933 100644 --- a/package-lock.json +++ b/package-lock.json @@ -17,7 +17,6 @@ "get-stream": "^7.0.0", "import-from-esm": "^2.0.0", "into-stream": "^7.0.0", - "lodash-es": "^4.17.21", "read-package-up": "^11.0.0" }, "devDependencies": { @@ -5603,6 +5602,7 @@ "version": "4.17.21", "resolved": "https://registry.npmjs.org/lodash-es/-/lodash-es-4.17.21.tgz", "integrity": "sha512-mKnC+QJ9pWVzv+C4/U3rRsHapFfHvQFoFB92e52xeyGMcX6/OlIl78je1u8vePzYZSkkogMPJ2yjxxsb89cxyw==", + "dev": true, "license": "MIT" }, "node_modules/lodash.capitalize": { diff --git a/package.json b/package.json index 0d8a0991..a5541c7e 100644 --- a/package.json +++ b/package.json @@ -19,7 +19,6 @@ "get-stream": "^7.0.0", "import-from-esm": "^2.0.0", "into-stream": "^7.0.0", - "lodash-es": "^4.17.21", "read-package-up": "^11.0.0" }, "devDependencies": {