Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: remove duplicated packages #299

Merged
merged 2 commits into from
Oct 11, 2024
Merged

Conversation

Wxh16144
Copy link
Contributor

@Wxh16144 Wxh16144 commented Oct 11, 2024

白名单解析规则是 先 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.

Copy link

coderabbitai bot commented Oct 11, 2024

Walkthrough

The changes in this pull request involve modifications to the package.json file, specifically the removal of several packages from the allowPackages section. The removed packages include @ffmpeg/ffmpeg, @itchenliang/picture-rollup-local-plugin, @tyllllll/gkd-subscription, @waline/client, and @yarnpkg/lockfile. Additionally, a new test case was added in test/index.js to ensure that no packages in pkg.allowPackages overlap with those in pkg.allowScopes, enhancing the validation logic of the package management.

Changes

File Change Summary
package.json Removed packages: @ffmpeg/ffmpeg, @itchenliang/picture-rollup-local-plugin, @tyllllll/gkd-subscription, @waline/client, @yarnpkg/lockfile from allowPackages.
test/index.js Added a new test case "check allowPackages and allowScopes" to validate package relationships.

Possibly related PRs

  • feat: add @ffmpeg #288: This PR adds the @ffmpeg package to the allowScopes section of package.json, which is directly related to the removal of @ffmpeg/ffmpeg from the allowPackages section in the main PR.

Suggested reviewers

  • fengmk2

Poem

In the garden of code, we prune with care,
Removing the weeds, lightening the air.
Packages gone, the path is now clear,
Tests added to catch what we hold dear.
A hop and a skip, our project takes flight,
With each little change, we make it just right! 🐇✨


Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

🧹 Outside diff range and nitpick comments (2)
test/index.js (2)

50-51: Translate comment to English for better accessibility.

Consider translating the Chinese comment to English to improve accessibility for international contributors. This aligns with best practices for maintaining open-source projects.

Here's a suggested translation:

-// 解析 allowPackages 的每个包的组织和包名,如果该组织已存在 allowScopes 中,则不需要再添加具名包
-// 例如:@babel 已存在,那么 @babel/core 就不需要再添加
+// Parse the organization and package name for each package in allowPackages.
+// If the organization already exists in allowScopes, there's no need to add the named package.
+// For example: If @babel already exists, then @babel/core doesn't need to be added.

66-72: Improve error message and provide resolution hint.

The current implementation logs the duplicates but doesn't provide a clear error message or guidance on how to resolve the issue. Consider enhancing the error reporting to make it more actionable for developers.

Here's a suggested improvement:

 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');
+  assert.fail(
+    'Duplicated packages found in allowPackages for scopes already in allowScopes.\n' +
+    'To resolve this, remove the following packages from allowPackages:\n' +
+    Array.from(duplicatedPackages.entries())
+      .map(([scope, packages]) => `  ${scope}: ${packages.join(', ')}`)
+      .join('\n')
+  );
 }

This change provides a more detailed error message and explicitly lists the packages that need to be removed to resolve the duplication.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between 9fbcebc and ec5df30.

📒 Files selected for processing (2)
  • package.json (0 hunks)
  • test/index.js (1 hunks)
💤 Files with no reviewable changes (1)
  • package.json
🧰 Additional context used
🔇 Additional comments (1)
test/index.js (1)

52-73: LGTM with minor improvements.

The overall implementation of this test case is well-structured and effectively checks for duplicates between allowPackages and allowScopes. It aligns with the PR objectives and enhances the validation logic of the package configuration.

With the suggested improvements for the comment translation and error messaging, this addition will significantly contribute to maintaining a clean and efficient package allowlist.

Copy link
Member

@fengmk2 fengmk2 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1

@fengmk2 fengmk2 changed the title 🧪 chore: add unit test fix: remove duplicated packages Oct 11, 2024
@fengmk2 fengmk2 self-assigned this Oct 11, 2024
@fengmk2 fengmk2 added bug Something isn't working enhancement New feature or request labels Oct 11, 2024
@fengmk2 fengmk2 merged commit e59dcca into cnpm:master Oct 11, 2024
4 checks passed
fengmk2 pushed a commit that referenced this pull request Oct 11, 2024
[skip ci]

## [1.134.1](v1.134.0...v1.134.1) (2024-10-11)

### Bug Fixes

* remove duplicated packages ([#299](#299)) ([e59dcca](e59dcca))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants