-
Notifications
You must be signed in to change notification settings - Fork 358
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:When splitting materials, a component can exist in multiple snippets. Also, there can be two components within one snippet (with the same componentName but different snippetName) #1212
base: develop
Are you sure you want to change the base?
Conversation
WalkthroughThe pull request removes an initial block comment from the Changes
Possibly related PRs
Suggested labels
Suggested reviewers
Poem
Warning There were issues while running some tools. Please review the errors and either fix the tool’s configuration or disable the tool if it’s a critical failure. 🔧 ESLint
ERR_PNPM_OPTIONAL_DEPS_REQUIRE_PROD_DEPS Optional dependencies cannot be installed without production dependencies ✨ Finishing Touches
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
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)
Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this 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
🧹 Nitpick comments (2)
scripts/splitMaterials.mjs (2)
36-39
: Potential edge case handling concern with key selection.The fallback logic for determining the key (
item?.schema?.componentName || item.snippetName
) might lead to unexpected behavior ifcomponentName
exists but is falsy (empty string, 0, etc.). Consider using nullish coalescing (??
) instead:-const key = item?.schema?.componentName || item.snippetName +const key = item?.schema?.componentName ?? item.snippetName
58-60
: Potential null/undefined check improvement.While the current check
matchedSnippets?.length
works, consider making it more explicit for better readability:-if (matchedSnippets?.length) { +if (matchedSnippets && matchedSnippets.length > 0) {This makes the intent clearer to future readers of the code.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (2)
scripts/splitMaterials.mjs
(2 hunks)scripts/splitMaterials.mjs
(0 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (1)
- GitHub Check: push-check
🔇 Additional comments (4)
scripts/splitMaterials.mjs (4)
1-6
: Unnecessary file header metadata removed.The metadata comment at the top of the file has been removed. This is acceptable as it only contained internal information (editor, dates) that isn't relevant to the code functionality.
28-39
: Improved snippet preprocessing with a more structured approach.The new implementation creates a more organized
snippetsMap
object to store snippets, properly handling cases where snippets don't have children arrays. This is a good improvement in code structure.
40-48
: Good implementation of snippet collection.Storing all matching snippets in arrays keyed by component name efficiently solves the problem described in the PR objectives. This approach ensures components that appear in multiple snippets or different configurations are properly tracked.
51-60
: Efficient component-snippet matching logic.The new component processing logic correctly handles both single and array component definitions, and properly assigns all matching snippets to each component. This directly addresses the issue where components like TinyCheckboxGroup were losing some of their snippet representations.
English | 简体中文
PR
PR Checklist
Please check if your PR fulfills the following requirements:
PR Type
What kind of change does this PR introduce?
Background and solution
What is the current behavior?
表单分类里面存在复选框组和复选框拖拽按钮组两个组件,使用的是同一个组件TinyCheckboxGroup,但是在拆分之后TinyCheckboxGroup.json文件中复选框拖拽按钮组组丢失!
拆包的时候没有考虑一个组件在多个分组里面也没有考虑一个分组里面存在两个组件(组件名相同,配置项不同)
在splitMaterials拆分物料脚本的时候将组件名相同,snippetName不相同的组件都写入在拆分的组件文件的snippets字段里面
Issue Number: N/A
What is the new behavior?
拆分物料的时候一个组件在snippets中使用多次时在拆分的单个组件文件中snippets存在多项,TinyCheckboxGroup.json文件中存在复选框组和复选框组拖拽组
Does this PR introduce a breaking change?
Other information
Summary by CodeRabbit