Skip to content
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

refactor: handle unexpected dumi version when detecting #2072

Merged
merged 5 commits into from
May 6, 2024

Conversation

Wxh16144
Copy link
Member

🤔 这个变动的性质是?/ What is the nature of this change?

  • 新特性提交 / New feature
  • bug 修复 / Fix bug
  • 样式优化 / Style optimization
  • 代码风格优化 / Code style optimization
  • 性能优化 / Performance optimization
  • 构建优化 / Build optimization
  • 网站、文档、Demo 改进 / Website, documentation, demo improvements
  • 重构代码或样式 / Refactor code or style
  • 测试相关 / Test related
  • 其他 / Other

🔗 相关 Issue / Related Issue

💡 需求背景和解决方案 / Background or solution

开发者使用 link 或者 npm alias 方式安装了 dumi pkg 后下列方法会导致程序启动不起来

具体错误是说 package 依赖的版本不是一个有效的 semver

错误方法:

方法1.

function checkMinor2ByPkg(pkg: IApi['pkg']) {
// for dumi local example project
if (pkg.name?.startsWith('@examples/')) return true;
const ver =
pkg.peerDependencies?.dumi || pkg.devDependencies?.dumi || '^2.0.0';
return semver.subset(ver, VERSION_2_LEVEL_NAV);
}

方法2.
const ver = pkg?.devDependencies?.dumi ?? pkg?.dependencies?.dumi ?? '^2.0.0';
return !semver.subset(ver, VERSION_2_DEPRECATE_SOFT_BREAKS);

错误信息:

image

这个 PR 尝试获取正确的依赖,但是感觉不是最优解法,或者可能不需要这么麻烦,随时 review 反馈

📝 更新日志 / Changelog

Language Changelog
🇺🇸 English fix: edge case
🇨🇳 Chinese 修复边缘错误

Copy link

vercel bot commented Apr 12, 2024

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

Name Status Preview Comments Updated (UTC)
dumi ✅ Ready (Inspect) Visit Preview 💬 Add feedback May 6, 2024 4:47am

@Wxh16144 Wxh16144 changed the title fix: edge case refactor: improve code robustness Apr 18, 2024
@Wxh16144 Wxh16144 closed this May 5, 2024
@PeachScript PeachScript changed the title refactor: improve code robustness refactor: handle unexpected dumi version when detecting May 6, 2024
@PeachScript PeachScript reopened this May 6, 2024
Copy link
Member

@PeachScript PeachScript left a comment

Choose a reason for hiding this comment

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

+1

@PeachScript PeachScript merged commit 9665ec6 into umijs:master May 6, 2024
9 checks passed
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