From cd647343f46f65b682692600f69a5f64b86c14e0 Mon Sep 17 00:00:00 2001 From: YuTengjing Date: Mon, 11 Sep 2023 10:24:26 +0800 Subject: [PATCH 1/2] feat: customErrorMessage option add duplicatedDeps param --- src/index.ts | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/index.ts b/src/index.ts index 62b71a7..fb7dfe9 100644 --- a/src/index.ts +++ b/src/index.ts @@ -29,7 +29,10 @@ export interface Options { * ``` */ whitelist?: Record; - customErrorMessage?: (issuePackagesMap: Map) => string; + customErrorMessage?: ( + issuePackagesMap: Map, + duplicatedDeps: Record, + ) => string; logLevel?: 'debug' | 'error'; } @@ -216,9 +219,13 @@ export default createUnplugin((options) => { if (throwErrorWhenDuplicated) { const issuePackagesMap = new Map(); + const duplicatedDeps: Record = {}; for (const [packageName, versionsMap] of packageToVersionsMap.entries()) { if (versionsMap.size < 2) continue; + duplicatedDeps[packageName] = [...versionsMap.keys()].sort((a, b) => + gt(a, b) ? 1 : -1, + ); for (const version of versionsMap.keys()) { const pass = packageName in whiteList && whiteList[packageName].includes(version); @@ -239,7 +246,7 @@ export default createUnplugin((options) => { if (issuePackagesMap.size > 0) { throw new Error( customErrorMessage - ? customErrorMessage(issuePackagesMap) + ? customErrorMessage(issuePackagesMap, duplicatedDeps) : `You can add following duplicated deps to whitelist option to suppress this error:\n${duplicatedDepsList}`, ); } From fc84bca13b36ff112027f556328ae97c1eaa36a9 Mon Sep 17 00:00:00 2001 From: YuTengjing Date: Mon, 11 Sep 2023 10:24:42 +0800 Subject: [PATCH 2/2] chore: release v0.3.3 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index e3d3715..83f8a10 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "unplugin-detect-duplicated-deps", - "version": "0.3.2", + "version": "0.3.3", "description": "Detect duplicate packaged dependencies", "keywords": [ "unplugin",