Skip to content

feat: add shields.io-style badges - #1487

Merged
danielroe merged 2 commits into
npmx-dev:mainfrom
wojtekmaj:shieldsio
Feb 22, 2026
Merged

feat: add shields.io-style badges#1487
danielroe merged 2 commits into
npmx-dev:mainfrom
wojtekmaj:shieldsio

Conversation

@wojtekmaj

@wojtekmajwojtekmaj commented Feb 14, 2026

Copy link
Copy Markdown
Contributor

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

CopilotAI review requested due to automatic review settings February 14, 2026 00:19
@vercel

vercelBot commented Feb 14, 2026

Copy link
Copy Markdown
Contributor

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

ProjectDeploymentActionsUpdated (UTC)
docs.npmx.devReadyReadyPreview, CommentFeb 22, 2026 8:41am
npmx.devReadyReadyPreview, CommentFeb 22, 2026 8:41am
1 Skipped Deployment
ProjectDeploymentActionsUpdated (UTC)
npmx-lunariaIgnoredIgnoredFeb 22, 2026 8:41am

Request Review

@codecov

codecovBot commented Feb 14, 2026

Copy link
Copy Markdown

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!

CopilotAI left a comment

Copy link
Copy Markdown
Contributor

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.

FileDescription
package.jsonAdded @napi-rs/canvas dependency (v0.1.92)
pnpm-lock.yamlLockfile updates for @napi-rs/canvas and its platform-specific binaries
server/api/registry/badge/[type]/[...pkg].get.tsImplemented style parameter, canvas-based text measurement, and two SVG rendering functions
test/e2e/badge.spec.tsAdded E2E tests for default and shieldsio style parameters
Files not reviewed (1)
  • pnpm-lock.yaml: Language not supported

Comment threadserver/api/registry/badge/[type]/[...pkg].get.ts
Comment threadtest/e2e/badge.spec.ts
Comment threadserver/api/registry/badge/[type]/[...pkg].get.ts
Comment threadserver/api/registry/badge/[type]/[...pkg].get.ts
Comment threadserver/api/registry/badge/[type]/[...pkg].get.ts
Comment threadtest/e2e/badge.spec.ts
Comment threadserver/api/registry/badge/[type]/[...pkg].get.ts Outdated
Comment threadserver/api/registry/badge/[type]/[...pkg].get.ts
ghostdevv
ghostdevv previously requested changes Feb 14, 2026
Comment threadserver/api/registry/badge/[type]/[...pkg].get.ts
@coderabbitai

Copy link
Copy Markdown
Contributor
📝 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 nameStatusExplanation
Description check✅ PassedThe 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.

@coderabbitaicoderabbitaiBot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 2

Comment threadserver/api/registry/badge/[type]/[...pkg].get.ts
Comment threadserver/api/registry/badge/[type]/[...pkg].get.ts
@wojtekmaj
wojtekmaj dismissed ghostdevv’s stale reviewFebruary 16, 2026 08:12

Addressed in another PR this PR used to depend on

@danielroe
danielroe added this pull request to the merge queueFeb 22, 2026
Merged via the queue into npmx-dev:main with commit 24a2c1aFeb 22, 2026
17 checks passed
@wojtekmaj
wojtekmaj deleted the shieldsio branch February 22, 2026 11:19
wojtekmaj added a commit to wojtekmaj/npmx.dev that referenced this pull request Feb 22, 2026
Sign up for freeto 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.

4 participants

@wojtekmaj@danielroe@ghostdevv