Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
1 Skipped Deployment
|
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (2)
✅ Files skipped from review due to trivial changes (1)
🚧 Files skipped from review as they are similar to previous changes (1)
📝 WalkthroughSummary by CodeRabbitRelease Notes
WalkthroughAdds a new Changes
Possibly related PRs
Suggested reviewers
🚥 Pre-merge checks | ✅ 4✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ 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.
Actionable comments posted: 1
🧹 Nitpick comments (1)
server/api/registry/badge/[type]/[...pkg].get.ts (1)
504-504: Avoid a non-zero fallback for likes count.Line 504 uses
totalLikes ?? 10, which can surface an arbitrary likes value. Prefer0(or no fallback if the contract guarantees a number).♻️ Suggested change
- return { label: 'likes', value: String(totalLikes ?? 10), color: COLORS.blue } + return { label: 'likes', value: String(totalLikes ?? 0), color: COLORS.blue }
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: ccf0e408-d5fe-4809-995c-430e925268b9
📒 Files selected for processing (3)
docs/content/2.guide/6.badges.mddocs/shared/utils/badges.tsserver/api/registry/badge/[type]/[...pkg].get.ts
| 'likes': async (pkgData: globalThis.Packument) => { | ||
| const likesUtil = new PackageLikesUtils() | ||
| const { totalLikes } = await likesUtil.getLikes(pkgData.name) |
There was a problem hiding this comment.
🧩 Analysis chain
🏁 Script executed:
#!/bin/bash
# Verify symbol usage and import presence for PackageLikesUtils
rg -n "PackageLikesUtils" "server/api/registry/badge/[type]/[...pkg].get.ts" "server/utils/atproto/utils/likes.ts"
rg -n "from '#server/utils/atproto/utils/likes'" "server/api/registry/badge/[type]/[...pkg].get.ts"Repository: npmx-dev/npmx.dev
Length of output: 344
🏁 Script executed:
#!/bin/bash
# Check all imports in the target file to see the import pattern
head -50 "server/api/registry/badge/[type]/[...pkg].get.ts" | grep -n "^import\|^export"Repository: npmx-dev/npmx.dev
Length of output: 676
🏁 Script executed:
#!/bin/bash
# Verify the path alias and check if there are any wildcard imports that could provide PackageLikesUtils
rg -n "^import.*from.*atproto" "server/api/registry/badge/[type]/[...pkg].get.ts"Repository: npmx-dev/npmx.dev
Length of output: 43
🏁 Script executed:
#!/bin/bash
# Verify the proposed import path and check other imports from likes utilities
rg -n "import.*PackageLikesUtils\|from.*likes" "server/utils/atproto/utils/likes.ts"Repository: npmx-dev/npmx.dev
Length of output: 43
Add missing import for PackageLikesUtils to fix type-checking error.
Line 501 instantiates PackageLikesUtils, but the file does not import it. Add the following import to resolve the unresolved symbol:
import { handleApiError } from '#server/utils/error-handler'
+import { PackageLikesUtils } from '#server/utils/atproto/utils/likes'📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| 'likes': async (pkgData: globalThis.Packument) => { | |
| const likesUtil = new PackageLikesUtils() | |
| const { totalLikes } = await likesUtil.getLikes(pkgData.name) | |
| import { handleApiError } from '#server/utils/error-handler' | |
| import { PackageLikesUtils } from '#server/utils/atproto/utils/likes' |
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
docs/content/2.guide/6.badges.md (1)
31-31: Polish wording for readability.Consider rephrasing to “Shows the total number of likes for the package” for more natural wording in docs.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: eb86405a-ee45-4f31-9b31-0d747a424d41
📒 Files selected for processing (2)
docs/content/2.guide/6.badges.mdserver/api/registry/badge/[type]/[...pkg].get.ts
🚧 Files skipped from review as they are similar to previous changes (1)
- server/api/registry/badge/[type]/[...pkg].get.ts
Other entries also use similar phrasing as "Lists the total count of package dependencies.". To maintain consistency, adopt original phrasing.
| const likesUtil = new PackageLikesUtils() | ||
| const { totalLikes } = await likesUtil.getLikes(pkgData.name) | ||
|
|
||
| return { label: 'likes', value: String(totalLikes ?? 0), color: COLORS.blue } |
There was a problem hiding this comment.
Maybe the default colour should be red? 👀 We could use the same colour that we do on the frontend
There was a problem hiding this comment.
🔗 Linked issue
Resolves #2412
🧭 Context
In #2412, it was requested to have a badge variant that shows the likes a specific package has on npmx.dev.
This PR introduces a
likes-type badge.📚 Description
This PR adds a badge type called
likesand integrates the logic of thehttps://npmx.dev/api/social/likes/[pkg]endpoint into it.