fix: 优化获取web.config路径的逻辑,简化代码结构#663
Conversation
Reviewer's guide (collapsed on small PRs)Reviewer's Guide重构解析插件 web.config(或等价配置)绝对路径的逻辑,以适配通过 npm 安装的插件、本地 TypeScript 运行时以及共享的路径解析方式,并简化代码结构。 更新后的 getWebConfigPath 路径解析逻辑流程图flowchart TD
A["getWebConfigPath(plugin)"] --> B["pkg = plugin.pkgData"]
B --> C{"pkg.karin exists?"}
C -->|no| Z["return null"]
C -->|yes| D{"plugin.type === npm or plugin.dir includes node_modules"}
D -->|yes| E["getPath(pkg.karin.web)"]
E --> F{"fs.existsSync(path.join(plugin.dir, pkg.karin.web))?"}
F -->|yes| G["return web path"]
F -->|no| Z
D -->|no| H{"isTs()"}
H -->|yes| I["getPath(pkg.karin.ts-web)"]
I --> J{"fs.existsSync(path.join(plugin.dir, pkg.karin.ts-web))?"}
J -->|yes| K["return ts-web path"]
J -->|no| L["getPath(pkg.karin.web)"]
H -->|no| L
L --> M{"fs.existsSync(path.join(plugin.dir, pkg.karin.web))?"}
M -->|yes| G
M -->|no| Z
File-Level Changes
Possibly linked issues
Tips and commandsInteracting with Sourcery
Customizing Your Experience访问你的 dashboard 以:
Getting HelpOriginal review guide in EnglishReviewer's guide (collapsed on small PRs)Reviewer's GuideRefactors the logic for resolving the absolute path to a plugin's web.config (or equivalent) to account for npm-installed plugins, local TypeScript runtime, and shared path resolution, simplifying the code structure. Flow diagram for updated getWebConfigPath resolution logicflowchart TD
A["getWebConfigPath(plugin)"] --> B["pkg = plugin.pkgData"]
B --> C{"pkg.karin exists?"}
C -->|no| Z["return null"]
C -->|yes| D{"plugin.type === npm or plugin.dir includes node_modules"}
D -->|yes| E["getPath(pkg.karin.web)"]
E --> F{"fs.existsSync(path.join(plugin.dir, pkg.karin.web))?"}
F -->|yes| G["return web path"]
F -->|no| Z
D -->|no| H{"isTs()"}
H -->|yes| I["getPath(pkg.karin.ts-web)"]
I --> J{"fs.existsSync(path.join(plugin.dir, pkg.karin.ts-web))?"}
J -->|yes| K["return ts-web path"]
J -->|no| L["getPath(pkg.karin.web)"]
H -->|no| L
L --> M{"fs.existsSync(path.join(plugin.dir, pkg.karin.web))?"}
M -->|yes| G
M -->|no| Z
File-Level Changes
Possibly linked issues
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
|
Warning Review limit reached
Next review available in: 51 minutes Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available. How can I continue?After more reviews become available, a review can be triggered using the To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews. How do review limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability. For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window. Please refer docs for additional details. Review details⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
📝 WalkthroughWalkthroughThe ChangesWeb Config Path Selection
Estimated code review effort: 2 (Simple) | ~10 minutes Possibly related PRs
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |
There was a problem hiding this comment.
Hey - 我已经审查了你的修改,它们看起来非常棒!
帮我变得更有用!请在每条评论上点 👍 或 👎,我会根据这些反馈来改进你的代码审查。
Original comment in English
Hey - I've reviewed your changes and they look great!
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
There was a problem hiding this comment.
Code Review
This pull request refactors the getWebConfigPath function in webConfig.ts to improve path resolution for npm plugins and local source plugins, prioritizing ts-web in TypeScript environments. The review feedback suggests enhancing robustness by using optional chaining when accessing pkg.karin and adding type validation in the getPath helper to ensure the path value is a valid non-empty string.
Important
The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
|
你可以通过以下命令安装该版本: |
Summary by Sourcery
调整
web.config路径解析,以更好地处理不同的插件类型和运行环境,同时简化查找逻辑。Bug 修复:
npm和node_modules的插件在开发环境中也始终使用已发布的web.config输出,避免错误地解析到ts-web配置。ts-web配置,并在必要时回退到编译后的web.config。改进:
web.config路径计算重构为可复用的辅助方法,以获得更清晰的结构并减少重复代码。Original summary in English
Summary by Sourcery
Adjust web.config path resolution to better handle different plugin types and runtime environments while simplifying the lookup logic.
Bug Fixes:
Enhancements:
Summary by CodeRabbit