Skip to content

Commit

Permalink
fix: remove duplicated packages (#299)
Browse files Browse the repository at this point in the history
白名单解析规则是 先 scope 再看 pkg,已经存在于白名单的 scope 则不再需要添加具名的 pkg

<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->

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

<!-- end of auto-generated comment: release notes by coderabbit.ai -->
  • Loading branch information
Wxh16144 authored Oct 11, 2024
1 parent 9fbcebc commit e59dcca
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 15 deletions.
15 changes: 0 additions & 15 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -538,9 +538,6 @@
"@ffmpeg-installer/ffmpeg": {
"version": "*"
},
"@ffmpeg/ffmpeg": {
"version": "*"
},
"@ffprobe-installer/ffprobe": {
"version": "*"
},
Expand Down Expand Up @@ -691,9 +688,6 @@
"@istanbuljs/nyc-config-typescript": {
"version": "*"
},
"@itchenliang/picture-rollup-local-plugin": {
"version": "*"
},
"@jccr/unzipper": {
"version": "*"
},
Expand Down Expand Up @@ -1135,9 +1129,6 @@
"@tweenjs/tween.js": {
"version": "*"
},
"@tyllllll/gkd-subscription": {
"version": "*"
},
"@typography-org/react": {
"version": "*"
},
Expand Down Expand Up @@ -1186,9 +1177,6 @@
"@vvfx/resource-detection": {
"version": "*"
},
"@waline/client": {
"version": "*"
},
"@walletconnect/web3-provider": {
"version": "*"
},
Expand Down Expand Up @@ -1225,9 +1213,6 @@
"@yangkeith/gkd_subscription": {
"version": "*"
},
"@yarnpkg/lockfile": {
"version": "*"
},
"@yrobot/react-mobile-table": {
"version": "*"
},
Expand Down
24 changes: 24 additions & 0 deletions test/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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');
}
});

0 comments on commit e59dcca

Please sign in to comment.