Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
2 Skipped Deployments
|
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.
Pull request overview
This PR adds a new optional style parameter to the badge API that allows users to switch between the default badge style and a shields.io-compatible style. The implementation introduces accurate text measurement using the @napi-rs/canvas library with fallback to character-based estimation.
Changes:
- Added
@napi-rs/canvasdependency for accurate text width measurement - Implemented two badge rendering functions:
renderDefaultBadgeSvgandrenderShieldsBadgeSvg - Added
stylequery parameter validation with values 'default' and 'shieldsio'
Reviewed changes
Copilot reviewed 3 out of 4 changed files in this pull request and generated 8 comments.
| File | Description |
|---|---|
| package.json | Added @napi-rs/canvas dependency (v0.1.92) |
| pnpm-lock.yaml | Lockfile updates for @napi-rs/canvas and its platform-specific binaries |
| server/api/registry/badge/[type]/[...pkg].get.ts | Implemented style parameter, canvas-based text measurement, and two SVG rendering functions |
| test/e2e/badge.spec.ts | Added E2E tests for default and shieldsio style parameters |
Files not reviewed (1)
- pnpm-lock.yaml: Language not supported
📝 WalkthroughWalkthroughThis pull request adds support for shield-styled badges (Shields.io style) to the badge registry endpoint, alongside the existing default badge style. The implementation introduces new rendering constants and functions to support both badge styles, includes a style parameter parser that accepts "default" or "shieldsio" options, and routes badge generation through style-specific renderers. Existing functionality like caching, headers, and error handling remains unchanged. Possibly related PRs
Suggested reviewers
🚥 Pre-merge checks | ✅ 2✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches
🧪 Generate unit tests (beta)
Comment |
Addressed in another PR this PR used to depend on
This PR implements a new, optional parameter in badges API:
style. By passingstyle=shieldsiowe change the appearance of the generated shields from the default one to custom one.Default:

Default with custom color:

shields.io-style:

shields.io-style with custom color:
