Skip to content

refactor: use father plugin #370

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

Merged
merged 3 commits into from
Apr 24, 2025
Merged

refactor: use father plugin #370

merged 3 commits into from
Apr 24, 2025

Conversation

zombieJ
Copy link
Member

@zombieJ zombieJ commented Apr 24, 2025

Summary by CodeRabbit

  • 文档

    • 所有文档、示例和说明中的包名由“rc-steps”更新为“@rc-component/steps”。
    • 更新了安装、使用说明及相关链接,反映包名变更。
  • 配置与依赖

    • TypeScript、Jest、别名等配置同步为新包名。
    • 删除 Vercel 部署配置文件。
    • 升级 React 及相关依赖至 19.x。
    • 测试框架由 Enzyme 切换为 React Testing Library。
    • 移除与 Enzyme 相关的依赖及配置。
  • 其他

    • 依赖包“rc-util”更换为“@rc-component/util”。

Copy link

vercel bot commented Apr 24, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
steps ✅ Ready (Inspect) Visit Preview 💬 Add feedback Apr 24, 2025 10:38am

Copy link

coderabbitai bot commented Apr 24, 2025

Walkthrough

本次更新主要将项目包名从 rc-steps 重命名为 @rc-component/steps,并同步更新了相关依赖、配置、文档和示例代码。测试工具从 Enzyme 切换为 React Testing Library,相关依赖和测试用例也做了相应调整。构建和部署配置做了清理,移除了 Vercel 部署文件和部分不再使用的依赖。代码主逻辑和 API 未发生变更,仅涉及包名、依赖和测试工具的迁移。

Changes

文件/路径 变更摘要
package.json, tsconfig.json, .dumirc.ts 包名由 rc-steps 改为 @rc-component/steps,依赖和别名同步更新,移除/替换部分依赖,升级 React 版本。
README.md, docs/index.md 文档和标题中的包名、链接、徽章等全部改为新包名。
docs/examples/*.jsx 所有示例代码的引入路径由 rc-steps 改为 @rc-component/steps
src/Step.tsx KeyCode 引入路径由 rc-util 改为 @rc-component/util
jest.config.js, tests/setup.js 移除 Enzyme 相关配置与依赖,测试初始化仅保留 requestAnimationFrame 兼容代码。
tests/index.test.tsx 测试框架由 Enzyme 改为 React Testing Library,相关 API 全面替换。
now.json 删除 Vercel 部署配置文件。

Sequence Diagram(s)

sequenceDiagram
    participant 开发者
    participant 项目配置
    participant 测试工具
    participant 文档/示例

    开发者->>项目配置: 修改包名及依赖配置
    开发者->>测试工具: 替换 Enzyme 为 React Testing Library
    开发者->>文档/示例: 更新所有 import 路径为新包名
    项目配置-->>开发者: 提供新包名和依赖环境
    测试工具-->>开发者: 提供新的测试 API
    文档/示例-->>开发者: 展示新包名用法
Loading

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

If the error stems from missing dependencies, add them to the package.json file. For unrecoverable errors (e.g., due to private dependencies), disable the tool in the CodeRabbit configuration.

.dumirc.ts

Oops! Something went wrong! :(

ESLint: 8.57.1

ESLint couldn't find the config "prettier" to extend from. Please check that the name of the config is correct.

The config "prettier" was referenced from the config file in "/.eslintrc.js".

If you still have problems, please stop by https://eslint.org/chat/help to chat with the team.

docs/examples/customIcon.jsx

Oops! Something went wrong! :(

ESLint: 8.57.1

ESLint couldn't find the config "prettier" to extend from. Please check that the name of the config is correct.

The config "prettier" was referenced from the config file in "/.eslintrc.js".

If you still have problems, please stop by https://eslint.org/chat/help to chat with the team.

docs/examples/alternativeLabel.jsx

Oops! Something went wrong! :(

ESLint: 8.57.1

ESLint couldn't find the config "prettier" to extend from. Please check that the name of the config is correct.

The config "prettier" was referenced from the config file in "/.eslintrc.js".

If you still have problems, please stop by https://eslint.org/chat/help to chat with the team.

  • 15 others
✨ Finishing Touches
  • 📝 Generate Docstrings

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.

❤️ 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 generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this 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

codecov bot commented Apr 24, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 100.00%. Comparing base (542e868) to head (f72dbbe).
Report is 1 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff            @@
##            master      #370   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files            2         2           
  Lines           96        99    +3     
  Branches        45        48    +3     
=========================================
+ Hits            96        99    +3     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Copy link

Review the following changes in direct dependencies. Learn more about Socket for GitHub.

Diff Package Supply Chain
Security
Vulnerability Quality Maintenance License
Added@​rc-component/​np@​1.0.4701006688100
Addedrc-test@​7.1.2721007185100
Updated@​rc-component/​father-plugin@​1.1.0 ⏵ 2.1.37510077 +195100
Added@​rc-component/​util@​1.2.110010010084100
Added@​testing-library/​jest-dom@​6.6.310010010089100
Added@​testing-library/​react@​15.0.710010010092100

View full report

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

🧹 Nitpick comments (1)
tsconfig.json (1)

13-13: 建议完善 TypeScript 路径别名
当前仅为 @rc-component/steps 指定到 src/index.ts,如有按模块深度导入需求,可考虑增加通配符 alias,例如:

"@rc-component/steps/*": ["src/*"]

以确保更灵活的模块解析。

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 542e868 and f72dbbe.

⛔ Files ignored due to path filters (1)
  • tests/__snapshots__/index.test.tsx.snap is excluded by !**/*.snap
📒 Files selected for processing (25)
  • .dumirc.ts (1 hunks)
  • README.md (3 hunks)
  • docs/examples/alternativeLabel.jsx (1 hunks)
  • docs/examples/composable.jsx (1 hunks)
  • docs/examples/custom-svg-icon.jsx (1 hunks)
  • docs/examples/customIcon.jsx (1 hunks)
  • docs/examples/dynamic.jsx (1 hunks)
  • docs/examples/errorStep.jsx (1 hunks)
  • docs/examples/inline.jsx (1 hunks)
  • docs/examples/nav-base.jsx (1 hunks)
  • docs/examples/nextStep.jsx (1 hunks)
  • docs/examples/progressDot.jsx (1 hunks)
  • docs/examples/simple.jsx (1 hunks)
  • docs/examples/smallSize.jsx (1 hunks)
  • docs/examples/stepIcon.jsx (1 hunks)
  • docs/examples/vertical.jsx (1 hunks)
  • docs/examples/verticalSmall.jsx (1 hunks)
  • docs/index.md (1 hunks)
  • jest.config.js (0 hunks)
  • now.json (0 hunks)
  • package.json (4 hunks)
  • src/Step.tsx (1 hunks)
  • tests/index.test.tsx (16 hunks)
  • tests/setup.js (0 hunks)
  • tsconfig.json (1 hunks)
💤 Files with no reviewable changes (3)
  • jest.config.js
  • tests/setup.js
  • now.json
🔇 Additional comments (33)
docs/examples/nextStep.jsx (1)

5-5: 确保示例导入路径一致性
已将 Steps 组件从旧包 rc-steps 改为新包 @rc-component/steps,请验证项目中相关的 alias 配置(如 .dumirc.tstsconfig.json)已同步更新,以免示例无法正确编译或运行。

docs/examples/simple.jsx (1)

4-4: 更新示例导入路径
此处将 Steps 组件的导入路径切换到新包 @rc-component/steps,请确认所有相关文档和示例中均已完成替换,保持一致性。

docs/examples/stepIcon.jsx (1)

4-4: 统一示例导入源
已将 Steps 组件的导入改为 @rc-component/steps,请检查示例文件、文档和配置中的别名映射是否已同步更新,防止类型或解析错误。

docs/examples/nav-base.jsx (1)

4-4: 同步示例导入改动
Steps 组件导入路径更新到 @rc-component/steps,请确认 .dumirc.tstsconfig.json 等配置文件已有对应 alias 或 path 映射更新。

docs/examples/dynamic.jsx (1)

4-4: 示例组件导入检查
已把 Steps 引用从 rc-steps 切换到 @rc-component/steps,请验证相关文档、示例和项目配置已一致替换,并确保示例在编译时不会因路径变更报错。

docs/examples/custom-svg-icon.jsx (1)

4-4: 导入路径已更新
已将 Steps 组件的导入路径从旧包名更新为作用域包 @rc-component/steps,保证示例与主项目保持一致。

docs/examples/composable.jsx (1)

4-4: 导入路径已更新
Steps 的导入改为新作用域包 @rc-component/steps,符合整体包名重命名策略,无需其他改动。

docs/examples/smallSize.jsx (1)

4-4: 导入路径已更新
Steps 组件已从 @rc-component/steps 导入,替换原 rc-steps,示例代码与项目重构保持一致。

docs/examples/vertical.jsx (1)

4-4: 导入路径已更新
已将 Steps 组件导入路径替换为 @rc-component/steps,示例部署与新包名同步。

docs/examples/progressDot.jsx (1)

4-4: 导入路径已更新
Steps 组件的导入已更新为新包 @rc-component/steps,保持示例与源码仓库一致。

docs/examples/alternativeLabel.jsx (1)

4-4: 导入路径更新正确
Steps 组件已从 @rc-component/steps 导入,与整体包名重构保持一致。

docs/examples/inline.jsx (1)

4-4: 导入路径更新正确
Steps 组件已从 @rc-component/steps 引入,示例代码与包名重命名同步。

docs/examples/errorStep.jsx (1)

4-4: 导入路径更新正确
已将 Steps 组件的引入路径替换为 @rc-component/steps,符合全局重构。

docs/examples/customIcon.jsx (1)

4-4: 导入路径更新正确
Steps 组件现从新包 @rc-component/steps 引入,示例与文档保持一致。

docs/examples/verticalSmall.jsx (1)

4-4: 导入路径更新正确
示例已将 Steps@rc-component/steps 引入,包名重命名已全面生效。

docs/index.md (1)

3-3: 检查文档标题与包名一致性
已将 hero 标题从 rc-steps 更新为 @rc-component/steps,与整体包重命名保持一致。

src/Step.tsx (1)

4-4: 更新 KeyCode 模块导入路径
已将 rc-util/lib/KeyCode 更新为 @rc-component/util/lib/KeyCode,与工具库命名空间一致。请确认 @rc-component/util 已在 package.json 中声明为依赖,以免构建或运行时报错。

.dumirc.ts (1)

6-7: 更新 Dumi 别名配置
已将 alias 中的 rc-steps$rc-steps/es 更新为 @rc-component/steps$@rc-component/steps/es,与包名重命名保持一致。

README.md (5)

1-1: 更新 README 标题
已将主标题从 rc-steps 替换为 @rc-component/steps,保持与包名一致。


13-14: 更新 npm 徽章和链接
已将 npm 版本徽章和链接更新为 @rc-component/steps,请验证对应 URL 是否正确可访问。


19-23: 更新下载与 Bundlephobia 徽章
已替换下载量徽章与 Bundlephobia 链接为 @rc-component/steps,请确认外部服务返回数据正常。


27-27: 同步更新安装命令
已将安装命令改为 npm install @rc-component/steps,与包名保持一致。


191-191: 更新许可证声明
已将许可证声明中的包名更新为 @rc-component/steps

tests/index.test.tsx (5)

2-2: 从 Enzyme 迁移到 React Testing Library

测试库从 Enzyme 迁移到了 React Testing Library,这是一个现代化的改进。React Testing Library 更注重用户交互而非实现细节,与 React 的最佳实践更加一致。


29-30: 测试渲染方法迁移正确

Enzyme 的 mount() 调用已正确替换为 React Testing Library 的 render() 方法,快照测试也从 Enzyme 的包装器更新为使用 container.firstChild


383-385: 事件处理方法迁移正确

Enzyme 的 .simulate() 事件模拟已正确替换为 React Testing Library 的 fireEvent API。同时,元素选择也从 Enzyme 特定的选择器更改为标准的 DOM 查询。


402-412: 重渲染测试实现得当

使用 React Testing Library 的 rerender 功能正确实现了组件状态更新后的重新渲染测试。DOM 断言也已更新为使用标准的 DOM API。


474-476: 键盘事件处理正确迁移

键盘事件测试从 Enzyme 的 .simulate('keyDown', ...) 正确迁移到了 React Testing Library 的 fireEvent.keyDown(),保持了测试的功能完整性。

package.json (5)

36-37: 测试脚本和发布流程更新

测试相关命令从 umi-test 更改为 rc-test,发布前处理使用 rc-np 替代了 np。这些变更与项目从 Enzyme 迁移到 React Testing Library 一致,简化了工作流程。

Also applies to: 42-43, 46-47


59-63: 开发依赖更新

添加了 React Testing Library 相关依赖,并更新了 @rc-component/father-plugin 到 v2.0.2。这些变更符合测试框架迁移和构建工具现代化的目标。


56-56:

✅ Verification successful

依赖库更新

rc-util@babel/runtime 迁移到 @rc-component/util。请确保相关的工具函数引用也已更新。

请运行以下脚本检查是否所有 rc-util 的引用都已更新:


🏁 Script executed:

#!/bin/bash
# 检查是否还有 rc-util 的引用需要更新
grep -r "rc-util" --include="*.{ts,tsx,js,jsx}" ./src

Length of output: 53


确认:所有 rc-util 引用已替换为 @rc-component/util

src 目录下执行以下命令未发现任何 rc-util 的残留引用:

grep -r "rc-util" --include="*.{ts,tsx,js,jsx}" ./src

迁移已完成,无需进一步操作。


2-3:

✅ Verification successful

包名更改和版本重置

包名从 rc-steps 变更为 @rc-component/steps,版本重置为 0.0.0。这是一个重大变更,需确保所有依赖此包的项目都更新其引用。

请运行以下脚本检查是否有其他文件需要更新包引用:


🏁 Script executed:

#!/bin/bash
# 检查仓库中可能需要更新的引用
grep -r "rc-steps" --include="*.{ts,tsx,js,jsx,json,md}" . | grep -v "node_modules" | grep -v ".git"

Length of output: 96


🏁 Script executed:

#!/bin/bash
# 使用 grep 重新检查所有相关文件中的 “rc-steps” 引用
grep -R "rc-steps" . \
  --exclude-dir={node_modules,.git} \
  --include="*.ts" \
  --include="*.tsx" \
  --include="*.js" \
  --include="*.jsx" \
  --include="*.json" \
  --include="*.md" \
  -n || true

Length of output: 920


确认:不存在需更新的包引用
目前项目中并未出现以 rc-steps 作为 NPM 包名的导入或依赖引用。所有 grep 到的 “rc-steps” 字符串均用于:

  • HISTORY.md 中的版本记录注释
  • 组件内部的 prefixCls = 'rc-steps'(CSS 类名前缀)
  • 组件的 displayName = 'rc-steps'
  • 测试用例里的 CSS 类断言

这些均属于内部样式或文档,不影响 NPM 包名的变更。依赖已正确指向 @rc-component/steps,无需额外修改。


83-85:

✅ Verification successful

React 版本更新

开发依赖中的 React 和 ReactDOM 版本更新到了 v19.0.0,但 peerDependencies 保持在 >=16.9.0,这样可以在保持较广泛兼容性的同时使用最新版本进行开发和测试。


🌐 Web query:

React 19.0.0 是否已经正式发布?目前最新的稳定版本是什么?

💡 Result:

React 19.0.0 已经正式发布。根据 React 官方博客及多家主流技术社区的报道,React 团队在 2024 年 12 月 5 日正式发布了 React v19 的稳定版本,目前该版本已经在 npm 上可以获取和使用[1][2][3][4][7]。

目前,React 19.0.0 就是 React 的最新稳定版本。此次升级距离上一个主版本(React 18)已有两年多,并带来了包括全新 Actions、改进的错误处理机制、更强的自定义元素(Web Components)支持等一系列优化和新特性[1][3][4][7]。如果你准备对已有项目进行升级,建议先查看官方的升级指南以及注意破坏性变更。

总结:

  • React 19.0.0 已于 2024 年 12 月 5 日正式发布并成为最新稳定版本[1][2][3][4][7]。
  • 在 npm 上已可直接获取 React 19。
  • 官方建议优先升级到 React 18.3.1,再升级到 React 19,以平滑过渡[7]。

Citations:


确认 React v19.0.0 已正式发布并为最新稳定版本

React 和 ReactDOM 已于 2024-12-05 正式发布 19.0.0,并可通过 npm 直接获取。目前它是最新的稳定版。将 devDependencies 中的 "react""react-dom" 升级到 ^19.0.0 后,保持 peerDependencies 为 >=16.9.0 可以兼顾旧版兼容与新特性开发;如项目无需再支持 16.x,可考虑平滑过渡至至少 >=18.3.1,最终调整为 >=19.0.0

– 建议先在本地或测试环境中按官方升级指南(React 18.3.1 → React 19)逐步验证无破坏性变更
– 如已确认兼容性,可将 peerDependencies 从 >=16.9.0 调整为 >=19.0.0 以简化版本约束

@zombieJ zombieJ merged commit 01834d6 into master Apr 24, 2025
12 checks passed
@zombieJ zombieJ deleted the father branch April 24, 2025 10:41
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.

1 participant