fix: dependencies complex version link#1524
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
2 Skipped Deployments
|
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
|
Note Reviews pausedIt looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
No actionable comments were generated in the recent review. 🎉 📝 WalkthroughWalkthroughThis change adds a VersionLink interface, a LAST_VERSION_IN_RANGE_REGEXP constant, and a buildVersionLink(version: string) function in app/utils/versions.ts that converts complex semver strings into { href, title } objects. app/components/Package/Dependencies.vue was updated to convert dependency version strings (dependencies, peerDependencies, optionalDependencies) into objects via buildVersionLink, adjust sorting and v-for usage to the new { name, version } shape, and use version.href/version.title for links, routes and tooltips across vulnerability, deprecation and optional dependency renderings. Suggested reviewers
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches
🧪 Generate unit tests (beta)
Tip Issue Planner is now in beta. Read the docs and try it out! Share your feedback on Discord. 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 |
55396f2 to
541e7d9
Compare
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (1)
app/utils/versions.ts (1)
230-241: Optional: union whose last segment is a comparator set produces a non-exacthref.When the last
||segment itself contains comparator operators (e.g.1.0.0 || >=2.0.0 <3.0.0), the first branch returnshref = '>=2.0.0 <3.0.0', which is still not a valid single-version URL. ApplyingLAST_VERSION_IN_RANGE_REGEXPto the last segment as well would cover this case.♻️ Proposed approach
if (version.includes('||') && !version.includes(' - ')) { const versions: string[] = version.split('||').map(item => item.trim()) - href = versions.at(-1) || version + const lastSegment = versions.at(-1) || version + // If the last segment itself is a comparator, extract its trailing version + href = />=|<=|[<>]|&&/.test(lastSegment) + ? lastSegment.match(LAST_VERSION_IN_RANGE_REGEXP)?.[1]?.replace(/\s+/g, '') || lastSegment + : lastSegment
…x-key/npmx.dev into fix-deps-version-union-links
…deps-version-union-links
Resolves #1120
^1.0.0->^1.0.0Simple1.0.0 || 2.0.0->2.0.0Union>1.0.0 <=2.0.0-><=2.0.0Comparator Set1.0.0 - 2.0.0->2.0.0Range1.0.0 - 2.0.0 || 3.0.0 - 4.0.0->4.0.0Union of Rangesdependencies,peerDependenciesandoptionalDependenciescould have complex version (while 99% cases it'speer), so all of them are handled"||"(1.0.0 || 2.0.0), but I think people rarely need to click on a specific version for union, also it would add some incosistency, so I keep it as a one link, which points to the latest version from UnionExamples for reference:
Comparator Set (dependencies): https://npmx.dev/package/sass
Comparator Set (peer): https://npmx.dev/package/styled-components/v/3.5.0-0
Union (dependencies): https://npmx.dev/package/normalize-package-data/v/2.5.0, https://npmx.dev/package/loose-envify/v/1.4.0
Union (peer): https://npmx.dev/package/eslint-plugin-react