Skip to content

feat: 添加基于注册表的可插拔功能的基础逻辑 - #512

Merged
hexqi merged 2 commits into
opentiny:refactor/developfrom
gene9831:refactor/addon-to-registry
May 25, 2024
Merged

feat: 添加基于注册表的可插拔功能的基础逻辑#512
hexqi merged 2 commits into
opentiny:refactor/developfrom
gene9831:refactor/addon-to-registry

Conversation

@gene9831

@gene9831 gene9831 commented May 25, 2024

Copy link
Copy Markdown
Collaborator

English | 简体中文

PR

PR Checklist

Please check if your PR fulfills the following requirements:

  • The commit message follows our Commit Message Guidelines
  • Tests for the changes have been added (for bug fixes / features)
  • Docs have been added / updated (for bug fixes / features)
  • Built its own designer, fully self-validated

PR Type

What kind of change does this PR introduce?

  • Bugfix
  • Feature
  • Code style update (formatting, local variables)
  • Refactoring (no functional changes, no api changes)
  • Build related changes
  • CI related changes
  • Documentation content changes
  • Other... Please describe:

Background and solution

What is the current behavior?

Issue Number: N/A

What is the new behavior?

Does this PR introduce a breaking change?

  • Yes
  • No

Other information

Summary by CodeRabbit

  • New Features

    • Enhanced plugin, toolbar, and settings management for a more streamlined user experience.
  • Improvements

    • Improved state management and layout configuration in the application.
    • More efficient retrieval and utilization of plugins, settings, and toolbar components.
  • Refactor

    • Reorganized internal structure for better maintainability and performance.
  • Bug Fixes

    • Resolved issues with toolbar and plugin retrieval methods to ensure consistent functionality.

@coderabbitai

coderabbitai Bot commented May 25, 2024

Copy link
Copy Markdown
Contributor

Walkthrough

The recent updates to the design-core package involve significant restructuring and optimization. Key changes include replacing imports and modifying how plugins, toolbars, and settings are managed across various components. The addons module has been largely replaced with the getMergeRegistry function from @opentiny/tiny-engine-entry, enhancing the dynamic retrieval of registry entries. This overhaul aims to streamline the integration and management of plugins, toolbars, and settings within the application.

Changes

Files Change Summary
.../registry.js, .../src/DesignPlugins.vue, .../src/DesignSettings.vue, .../src/DesignToolbars.vue Updated imports and restructured plugins, toolbars, and settings sections. Replaced addons with getMergeRegistry for retrieving plugins, settings, and toolbars.
.../src/App.vue, .../src/preview/src/Toolbar.vue Removed or replaced addons import and reference, affecting state management and component functionality.
.../src/main.js, .../vite.config.js, .../entry/src/entryHash.js Introduced new imports, modified functions, and reorganized configurations for improved functionality.

In the land of code, where changes flow,
Plugins, toolbars, settings now aglow.
From addons we move, to registry we turn,
A streamlined path, for which we yearn.
With defineEntry and dynamic flair,
Our design core breathes fresh air.
🐇✨

Tip

New Features and Improvements

Review Settings

Introduced new personality profiles for code reviews. Users can now select between "Chill" and "Assertive" review tones to tailor feedback styles according to their preferences. The "Assertive" profile posts more comments and nitpicks the code more aggressively, while the "Chill" profile is more relaxed and posts fewer comments.

AST-based Instructions

CodeRabbit offers customizing reviews based on the Abstract Syntax Tree (AST) pattern matching. Read more about AST-based instructions in the documentation.

Community-driven AST-based Rules

We are kicking off a community-driven initiative to create and share AST-based rules. Users can now contribute their AST-based rules to detect security vulnerabilities, code smells, and anti-patterns. Please see the ast-grep-essentials repository for more information.

New Static Analysis Tools

We are continually expanding our support for static analysis tools. We have added support for biome, hadolint, and ast-grep. Update the settings in your .coderabbit.yaml file or head over to the settings page to enable or disable the tools you want to use.

Tone Settings

Users can now customize CodeRabbit to review code in the style of their favorite characters or personalities. Here are some of our favorite examples:

  • Mr. T: "You must talk like Mr. T in all your code reviews. I pity the fool who doesn't!"
  • Pirate: "Arr, matey! Ye must talk like a pirate in all yer code reviews. Yarrr!"
  • Snarky: "You must be snarky in all your code reviews. Snark, snark, snark!"

Revamped Settings Page

We have redesigned the settings page for a more intuitive layout, enabling users to find and adjust settings quickly. This change was long overdue; it not only improves the user experience but also allows our development team to add more settings in the future with ease. Going forward, the changes to .coderabbit.yaml will be reflected in the settings page, and vice versa.

Miscellaneous

  • Turn off free summarization: You can switch off free summarization of PRs opened by users not on a paid plan using the enable_free_tier setting.
  • Knowledge-base scope: You can now set the scope of the knowledge base to either the repository (local) or the organization (global) level using the knowledge_base setting. In addition, you can specify Jira project keys and Linear team keys to limit the knowledge base scope for those integrations.
  • High-level summary placement: You can now customize the location of the high-level summary in the PR description using the high_level_summary_placeholder setting (default @coderabbitai summary).
  • Revamped request changes workflow: You can now configure CodeRabbit to auto-approve or request changes on PRs based on the review feedback using the request_changes_workflow setting.

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

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 as PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger a review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai help to get help.

Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

CodeRabbit Configration 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.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 2

Outside diff range and nitpick comments (1)
packages/design-core/vite.config.js (1)

Line range hint 3-3: Use the node: protocol when importing Node.js built-in modules.

- import path from 'path'
+ import path from 'node:path'
Review Details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits Files that changed from the base of the PR and between 153fbd3 and e8a3c67.
Files selected for processing (9)
  • packages/design-core/registry.js (1 hunks)
  • packages/design-core/src/App.vue (2 hunks)
  • packages/design-core/src/DesignPlugins.vue (3 hunks)
  • packages/design-core/src/DesignSettings.vue (2 hunks)
  • packages/design-core/src/DesignToolbars.vue (2 hunks)
  • packages/design-core/src/main.js (1 hunks)
  • packages/design-core/src/preview/src/Toolbar.vue (1 hunks)
  • packages/design-core/vite.config.js (2 hunks)
  • packages/entry/src/entryHash.js (1 hunks)
Additional Context Used
Biome (1)
packages/design-core/vite.config.js (1)

3-3: A Node.js builtin module should be imported with the node: protocol.

Additional comments not posted (8)
packages/design-core/src/main.js (1)

29-29: Verify that defineEntry correctly initializes the application with the provided registry.

Verification successful

The search results indicate that defineEntry is used in multiple files, including packages/design-core/src/main.js, where it is called with defaultResigry. To verify that defineEntry correctly initializes the application with the provided registry, we need to inspect the implementation of defineEntry and how it handles the registry.


The implementation of defineEntry has been retrieved and it shows that the function sets the lowcodeRegistry.registry to the provided registry and calls generateRegistry with the same registry. This confirms that defineEntry correctly initializes the application with the provided registry.

  • defineEntry throws an error if the registry is not provided.
  • It assigns the provided registry to lowcodeRegistry.registry.
  • It calls generateRegistry with the provided registry.

This confirms that defineEntry correctly initializes the application with the provided registry.

Scripts Executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Description: Verify that `defineEntry` is correctly used in the application initialization.

# Test: Search for `defineEntry` usage in the application. Expect: Proper initialization with the registry.
rg --type python $'defineEntry'

Length of output: 61



Script:

#!/bin/bash
# Description: Verify that `defineEntry` is correctly used in the application initialization.

# Test: Search for `defineEntry` usage in the application. Expect: Proper initialization with the registry.
rg --type js 'defineEntry'

Length of output: 812



Script:

#!/bin/bash
# Description: Retrieve the implementation of `defineEntry` to verify its initialization logic.

# Locate the file containing the implementation of `defineEntry`.
rg --files-with-matches 'export const defineEntry' | xargs cat

Length of output: 1850

packages/design-core/src/DesignSettings.vue (1)

16-16: Confirm that getMergeRegistry('settings') retrieves the correct settings for the component.

Also applies to: 26-26

Verification successful

The implementation of getMergeRegistry in packages/entry/src/entryHash.js appears to correctly retrieve settings from the lowcodeRegistry.registry. The function handles different scenarios based on the presence of type and id, ensuring it returns the appropriate registry or item.

  • The function checks if type is provided and returns the entire registry if not.
  • It retrieves the specific type from the registry and, if id is provided, searches for the item with the matching id.
  • If the registry is an array, it finds the item by id; otherwise, it returns the registry if it has an id.

This confirms that getMergeRegistry('settings') should correctly retrieve the settings for the component.

Scripts Executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Description: Verify that `getMergeRegistry('settings')` retrieves the correct settings.

# Test: Search for `getMergeRegistry('settings')` usage in the application. Expect: Correct retrieval of settings.
rg --type python $'getMergeRegistry\\(\'settings\'\\)'

Length of output: 88



Script:

#!/bin/bash
# Description: Verify that `getMergeRegistry('settings')` retrieves the correct settings.

# Test: Search for `getMergeRegistry('settings')` usage in the application. Expect: Correct retrieval of settings.
rg --type js $'getMergeRegistry\\(\'settings\'\\)'

Length of output: 147



Script:

#!/bin/bash
# Description: Verify the implementation of `getMergeRegistry`.

# Test: Search for the implementation of `getMergeRegistry` in the codebase.
rg --type js 'function getMergeRegistry' 

Length of output: 42



Script:

#!/bin/bash
# Description: Verify the definition and usage of `getMergeRegistry`.

# Test: Search for `getMergeRegistry` in the codebase, including imports and exports.
rg --type js 'getMergeRegistry'

Length of output: 1159



Script:

#!/bin/bash
# Description: Extract the implementation of `getMergeRegistry` from `packages/entry/src/entryHash.js`.

# Test: Display the implementation of `getMergeRegistry`.
rg --type js --context 10 'export const getMergeRegistry' packages/entry/src/entryHash.js

Length of output: 690



Script:

#!/bin/bash
# Description: Extract the complete implementation of `getMergeRegistry` from `packages/entry/src/entryHash.js`.

# Test: Display the complete implementation of `getMergeRegistry`.
rg --type js --context 20 'export const getMergeRegistry' packages/entry/src/entryHash.js

Length of output: 1118

packages/design-core/src/preview/src/Toolbar.vue (1)

19-19: Ensure that getMergeRegistry('toolbars') correctly retrieves and renders toolbar components.

Also applies to: 27-27

packages/design-core/registry.js (1)

13-65: Verify that all imported components are correctly registered in the central registry and accessible throughout the application.

Verification successful

The search results indicate that the registry is being imported and used in various parts of the codebase, suggesting that the components are being registered and accessed correctly.

  • packages/engine-cli/template/src/defineEntry.js
  • packages/entry/src/entryHash.js
  • packages/entry/src/common.js
  • packages/engine-cli/template/src/App.vue
  • packages/design-core/index.js
  • packages/design-core/src/main.js

These files show that the registry is being utilized, which implies that the components are likely being registered and accessed as intended.

Scripts Executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Description: Verify that all components are correctly registered.

# Test: Search for registry usage in the application. Expect: Correct registration and accessibility of components.
rg --type python $'registry'

Length of output: 58



Script:

#!/bin/bash
# Description: Verify that all components are correctly registered.

# Test: Search for registry usage in the application. Expect: Correct registration and accessibility of components.
rg --type js 'registry'

Length of output: 1836

packages/design-core/src/DesignToolbars.vue (1)

22-22: Confirm that getMergeRegistry('toolbars') correctly organizes and accesses toolbar components.

Also applies to: 36-36

packages/design-core/src/App.vue (1)

Line range hint 1-1: Refactoring to remove addons aligns with the PR's objective of introducing registry-based pluggable functionality.

packages/design-core/src/DesignPlugins.vue (1)

99-99: Standardizing plugin access through getMergeRegistry enhances modularity and maintainability.

packages/design-core/vite.config.js (1)

17-22: Reorganization of import statements and simplification of aliases align with the PR's objective of refactoring.

Comment thread packages/design-core/src/main.js Outdated
Comment thread packages/entry/src/entryHash.js
hexqi
hexqi previously approved these changes May 25, 2024

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 0

Review Details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits Files that changed from the base of the PR and between e8a3c67 and 3230a83.
Files selected for processing (2)
  • packages/design-core/src/main.js (1 hunks)
  • packages/entry/src/entryHash.js (1 hunks)
Files skipped from review as they are similar to previous changes (2)
  • packages/design-core/src/main.js
  • packages/entry/src/entryHash.js

@hexqi
hexqi merged commit 098c5e8 into opentiny:refactor/develop May 25, 2024
@gene9831
gene9831 deleted the refactor/addon-to-registry branch May 27, 2024 06:17
yy-wow pushed a commit to yy-wow/tiny-engine that referenced this pull request Oct 10, 2024
* feat: 添加基于注册表的可插拔功能的基础逻辑

* fix: fix spelling mistake and simplify conditonal logic
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