From e59dcca276543775a37e1e951d815d4eae9ca1b0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=F0=9D=91=BE=F0=9D=92=96=F0=9D=92=99=F0=9D=92=89?= Date: Fri, 11 Oct 2024 11:03:24 +0800 Subject: [PATCH] fix: remove duplicated packages (#299) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 白名单解析规则是 先 scope 再看 pkg,已经存在于白名单的 scope 则不再需要添加具名的 pkg ## Summary by CodeRabbit - **Chores** - Removed several packages from the project's dependency list to streamline package management. - **Tests** - Introduced a new test case to validate the relationship between allowed packages and scopes, enhancing validation logic. --- package.json | 15 --------------- test/index.js | 24 ++++++++++++++++++++++++ 2 files changed, 24 insertions(+), 15 deletions(-) diff --git a/package.json b/package.json index df71020..60a3d1c 100644 --- a/package.json +++ b/package.json @@ -538,9 +538,6 @@ "@ffmpeg-installer/ffmpeg": { "version": "*" }, - "@ffmpeg/ffmpeg": { - "version": "*" - }, "@ffprobe-installer/ffprobe": { "version": "*" }, @@ -691,9 +688,6 @@ "@istanbuljs/nyc-config-typescript": { "version": "*" }, - "@itchenliang/picture-rollup-local-plugin": { - "version": "*" - }, "@jccr/unzipper": { "version": "*" }, @@ -1135,9 +1129,6 @@ "@tweenjs/tween.js": { "version": "*" }, - "@tyllllll/gkd-subscription": { - "version": "*" - }, "@typography-org/react": { "version": "*" }, @@ -1186,9 +1177,6 @@ "@vvfx/resource-detection": { "version": "*" }, - "@waline/client": { - "version": "*" - }, "@walletconnect/web3-provider": { "version": "*" }, @@ -1225,9 +1213,6 @@ "@yangkeith/gkd_subscription": { "version": "*" }, - "@yarnpkg/lockfile": { - "version": "*" - }, "@yrobot/react-mobile-table": { "version": "*" }, diff --git a/test/index.js b/test/index.js index d038a99..43f26f3 100644 --- a/test/index.js +++ b/test/index.js @@ -47,3 +47,27 @@ test('should pkg.allowScopes work', () => { assert(scopes > 0); }); +// 解析 allowPackages 的每个包的组织和包名,如果该组织已存在 allowScopes 中,则不需要再添加具名包 +// 例如:@babel 已存在,那么 @babel/core 就不需要再添加 +test('check allowPackages and allowScopes', () => { + const duplicatedPackages = new Map(); + for (const name in pkg.allowPackages) { + if (name.startsWith('@')) { + const [scope] = name.split('/'); + if (pkg.allowScopes.includes(scope)) { + duplicatedPackages.set(scope, [ + ...(duplicatedPackages.get(scope) || []), + name + ]); + } + } + } + + if (duplicatedPackages.size > 0) { + console.log('Duplicated packages in allowScopes:'); + for (const [scope, packages] of duplicatedPackages) { + console.log(` - ${scope}: ${packages.join(', ')}`); + } + assert.fail('Duplicated packages in allowScopes'); + } +});