Skip to content

feat: add shields.io-style badges#1487

Open
wojtekmaj wants to merge 1 commit intonpmx-dev:mainfrom
wojtekmaj:shieldsio
Open

feat: add shields.io-style badges#1487
wojtekmaj wants to merge 1 commit intonpmx-dev:mainfrom
wojtekmaj:shieldsio

Conversation

@wojtekmaj
Copy link
Contributor

@wojtekmaj wojtekmaj commented Feb 14, 2026

This PR implements a new, optional parameter in badges API: style. By passing style=shieldsio we change the appearance of the generated shields from the default one to custom one.

Default:
default

Default with custom color:
defaultcolor

shields.io-style:
shieldsio

shields.io-style with custom color:
shieldsiocolor

Copilot AI review requested due to automatic review settings February 14, 2026 00:19
@vercel
Copy link

vercel bot commented Feb 14, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
npmx.dev Ready Ready Preview, Comment Feb 15, 2026 11:06pm
2 Skipped Deployments
Project Deployment Actions Updated (UTC)
docs.npmx.dev Ignored Ignored Preview Feb 15, 2026 11:06pm
npmx-lunaria Ignored Ignored Feb 15, 2026 11:06pm

Request Review

@codecov
Copy link

codecov bot commented Feb 14, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ All tests successful. No failed tests found.

📢 Thoughts on this report? Let us know!

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

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/canvas dependency for accurate text width measurement
  • Implemented two badge rendering functions: renderDefaultBadgeSvg and renderShieldsBadgeSvg
  • Added style query 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

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Feb 15, 2026

📝 Walkthrough

Walkthrough

This 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

  • danielroe
  • ghostdevv
🚥 Pre-merge checks | ✅ 2
✅ Passed checks (2 passed)
Check name Status Explanation
Description check ✅ Passed The pull request description clearly relates to the changeset, detailing the new style parameter and showing visual examples of the feature implementation.
Merge Conflict Detection ✅ Passed ✅ No merge conflicts detected when merging into main

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 2

@wojtekmaj wojtekmaj dismissed ghostdevv’s stale review February 16, 2026 08:12

Addressed in another PR this PR used to depend on

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