Skip to content

Conversation

@ymc9
Copy link
Member

@ymc9 ymc9 commented Aug 30, 2024

Fixes #1654

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Aug 30, 2024

Walkthrough

Walkthrough

The changes enhance the CLI tool's plugin management capabilities by introducing two new options for specifying which plugins to include or exclude during execution. This allows users to have more control over the plugin execution process, improving the overall flexibility of the code generation workflow.

Changes

File(s) Change Summary
packages/schema/src/cli/actions/generate.ts Added withPlugins and withoutPlugins properties to Options type; updated runPlugins function to validate plugins and handle errors.
packages/schema/src/cli/index.ts Enhanced createProgram function by adding --with-plugins and --without-plugins command-line options for specifying plugins.
packages/schema/src/cli/plugin-runner.ts Introduced withPlugins and withoutPlugins to PluginRunnerOptions; modified runPlugin method to include isCorePlugin parameter for plugin execution.

Assessment against linked issues

Objective Addressed Explanation
Allow skipping some plugins when running zenstack generate (#1654)

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:

‼️ IMPORTANT
Auto-reply has been disabled for this repository in the CodeRabbit settings. The CodeRabbit bot will not respond to your replies unless it is explicitly tagged.

  • 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 generate interesting stats about this repository and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @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
Contributor

@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: 1

Outside diff range, codebase verification and nitpick comments (1)
packages/schema/src/cli/plugin-runner.ts (1)

Line range hint 345-401: Method logic approved with a suggestion for improvement.

The changes to the runPlugin method correctly handle the new withPlugins and withoutPlugins options. The method checks if the specified plugins are enabled and skips them if not, which is a good practice for managing plugin execution.

Static Analysis Hint:
Consider using optional chaining to simplify the checks for withPlugins and withoutPlugins.

- if (runnerOptions.withPlugins && !runnerOptions.withPlugins.includes(name)) {
+ if (!runnerOptions.withPlugins?.includes(name)) {
- if (runnerOptions.withoutPlugins && runnerOptions.withoutPlugins.includes(name)) {
+ if (runnerOptions.withoutPlugins?.includes(name)) {
Tools
Biome

[error] 357-358: void is confusing inside a union type.

Unsafe fix: Use undefined instead.

(lint/suspicious/noConfusingVoidType)

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 0b466bf and 3c74bb1.

Files selected for processing (3)
  • packages/schema/src/cli/actions/generate.ts (3 hunks)
  • packages/schema/src/cli/index.ts (1 hunks)
  • packages/schema/src/cli/plugin-runner.ts (7 hunks)
Additional context used
Biome
packages/schema/src/cli/plugin-runner.ts

[error] 396-397: Change to an optional chain.

Unsafe fix: Change to an optional chain.

(lint/complexity/useOptionalChain)

Additional comments not posted (3)
packages/schema/src/cli/actions/generate.ts (1)

22-23: Type alteration approved.

The addition of withPlugins and withoutPlugins to the Options type is correctly implemented and aligns with the PR objectives to allow users to specify plugins to include or exclude during execution.

packages/schema/src/cli/index.ts (1)

123-124: Command-line options approved.

The addition of --with-plugins and --without-plugins command-line options to the generate command is correctly implemented. These options enhance user control over the plugin execution process, aligning with the PR objectives.

packages/schema/src/cli/plugin-runner.ts (1)

43-44: Type alteration approved.

The addition of withPlugins and withoutPlugins to the PluginRunnerOptions type is correctly implemented and aligns with the PR objectives to allow users to specify plugins to include or exclude during runtime.

Copy link
Contributor

@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: 1

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 3c74bb1 and e8d06ab.

Files selected for processing (1)
  • packages/schema/src/cli/plugin-runner.ts (7 hunks)
Additional context used
Biome
packages/schema/src/cli/plugin-runner.ts

[error] 395-396: Change to an optional chain.

Unsafe fix: Change to an optional chain.

(lint/complexity/useOptionalChain)

Additional comments not posted (5)
packages/schema/src/cli/plugin-runner.ts (5)

43-44: Approved: New properties for plugin control.

The addition of withPlugins and withoutPlugins to PluginRunnerOptions enhances user control over plugin execution, aligning with the PR objectives.


142-151: Approved: Enhanced plugin execution differentiation.

The addition of the isCorePlugin parameter to the runPlugin method allows for differentiated handling of core versus user plugins, which is a significant enhancement for managing plugin execution.

Also applies to: 177-186


205-205: Approved: Optimized inclusion of Prisma core plugin.

The refined condition for adding the Prisma core plugin ensures it is only included when necessary, optimizing resource usage and aligning with the PR objectives.


239-240: Approved: Conditional enabling of Zod core plugin.

The logic to conditionally enable the Zod core plugin based on the presence of the Enhancer plugin and validation rules ensures efficient use of resources and aligns with the PR objectives.


347-350: Approved: Efficient plugin skipping logic.

The implementation in the runPlugin method to skip plugins that are not enabled, while logging a warning, is a crucial enhancement that supports the new feature of excluding specific plugins.

Copy link
Contributor

@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: 1

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between e8d06ab and 234b019.

Files selected for processing (1)
  • tests/integration/tests/cli/generate.test.ts (1 hunks)

@ymc9 ymc9 merged commit 2275102 into dev Aug 31, 2024
@ymc9 ymc9 deleted the feat/plugins-to-run branch August 31, 2024 01:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants