From ca409b5f57d2671e4ccdcdbf715d5ef0f7bd148c Mon Sep 17 00:00:00 2001 From: Mateusz Sikorski Date: Fri, 27 Nov 2026 04:31:08 +0100 Subject: [PATCH] =?UTF-8?q?=E2=9C=A8=20feat(`badges`):=20add=20the=20badge?= =?UTF-8?q?=20and=20icon=20service?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cloudflare Worker that renders static badges, live npm, Packagist and GitHub badges, larger buttons and tech icon rows in light and dark, with text drawn as paths. Includes the docs page, tests with mocked fetches and CI. --- .github/mscode-logo-black.svg | 1 + .github/mscode-logo-white.svg | 1 + .github/workflows/ci.yml | 21 + .gitignore | 5 + LICENSE | 24 + README.md | 96 +- fonts/OFL-jetbrains-mono.txt | 93 + fonts/OFL-plus-jakarta-sans.txt | 93 + fonts/jetbrains-mono-latin-400-normal.ttf | Bin 0 -> 57800 bytes .../jetbrains-mono-latin-ext-400-normal.woff | Bin 0 -> 10128 bytes fonts/plus-jakarta-sans-latin-500-normal.ttf | Bin 0 -> 29796 bytes fonts/plus-jakarta-sans-latin-800-normal.ttf | Bin 0 -> 29744 bytes ...lus-jakarta-sans-latin-ext-500-normal.woff | Bin 0 -> 15620 bytes ...lus-jakarta-sans-latin-ext-800-normal.woff | Bin 0 -> 15412 bytes package.json | 32 + pnpm-lock.yaml | 2461 +++++++++++++++++ pnpm-workspace.yaml | 3 + scripts/build-icons.mjs | 134 + src/adapters/format.ts | 20 + src/adapters/github.ts | 54 + src/adapters/npm.ts | 40 + src/adapters/packagist.ts | 45 + src/adapters/types.ts | 31 + src/docs.ts | 192 ++ src/env.d.ts | 9 + src/icons/registry.ts | 60 + src/icons/simple.generated.ts | 108 + src/icons/types.ts | 13 + src/index.ts | 113 + src/render/badge.ts | 89 + src/render/colors.ts | 52 + src/render/fonts.ts | 32 + src/render/icons.ts | 35 + src/render/svg.ts | 49 + src/render/text.ts | 43 + src/routes.ts | 104 + test/adapters.test.ts | 152 + test/render.test.ts | 87 + test/routes.test.ts | 65 + tsconfig.json | 14 + vitest.config.ts | 17 + wrangler.toml | 14 + 42 files changed, 4388 insertions(+), 14 deletions(-) create mode 100644 .github/mscode-logo-black.svg create mode 100644 .github/mscode-logo-white.svg create mode 100644 .github/workflows/ci.yml create mode 100644 .gitignore create mode 100644 LICENSE create mode 100644 fonts/OFL-jetbrains-mono.txt create mode 100644 fonts/OFL-plus-jakarta-sans.txt create mode 100644 fonts/jetbrains-mono-latin-400-normal.ttf create mode 100644 fonts/jetbrains-mono-latin-ext-400-normal.woff create mode 100644 fonts/plus-jakarta-sans-latin-500-normal.ttf create mode 100644 fonts/plus-jakarta-sans-latin-800-normal.ttf create mode 100644 fonts/plus-jakarta-sans-latin-ext-500-normal.woff create mode 100644 fonts/plus-jakarta-sans-latin-ext-800-normal.woff create mode 100644 package.json create mode 100644 pnpm-lock.yaml create mode 100644 pnpm-workspace.yaml create mode 100644 scripts/build-icons.mjs create mode 100644 src/adapters/format.ts create mode 100644 src/adapters/github.ts create mode 100644 src/adapters/npm.ts create mode 100644 src/adapters/packagist.ts create mode 100644 src/adapters/types.ts create mode 100644 src/docs.ts create mode 100644 src/env.d.ts create mode 100644 src/icons/registry.ts create mode 100644 src/icons/simple.generated.ts create mode 100644 src/icons/types.ts create mode 100644 src/index.ts create mode 100644 src/render/badge.ts create mode 100644 src/render/colors.ts create mode 100644 src/render/fonts.ts create mode 100644 src/render/icons.ts create mode 100644 src/render/svg.ts create mode 100644 src/render/text.ts create mode 100644 src/routes.ts create mode 100644 test/adapters.test.ts create mode 100644 test/render.test.ts create mode 100644 test/routes.test.ts create mode 100644 tsconfig.json create mode 100644 vitest.config.ts create mode 100644 wrangler.toml diff --git a/.github/mscode-logo-black.svg b/.github/mscode-logo-black.svg new file mode 100644 index 0000000..d480b53 --- /dev/null +++ b/.github/mscode-logo-black.svg @@ -0,0 +1 @@ + diff --git a/.github/mscode-logo-white.svg b/.github/mscode-logo-white.svg new file mode 100644 index 0000000..d18111a --- /dev/null +++ b/.github/mscode-logo-white.svg @@ -0,0 +1 @@ + diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..399e54e --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,21 @@ +name: CI + +on: + push: + branches: [master] + pull_request: + +jobs: + test: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: pnpm/action-setup@v4 + - uses: actions/setup-node@v4 + with: + node-version: 24 + cache: pnpm + - run: pnpm install --frozen-lockfile + - run: pnpm typecheck + - run: pnpm test + - run: pnpm exec wrangler deploy --dry-run --outdir dist diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..0942af5 --- /dev/null +++ b/.gitignore @@ -0,0 +1,5 @@ +/node_modules +/.wrangler +/.dev.vars +/.idea +/dist diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..b921394 --- /dev/null +++ b/LICENSE @@ -0,0 +1,24 @@ +MIT License + +Copyright (c) 2026 MSCode + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. + +Support data in data/caniemail.json comes from caniemail.com +(https://github.com/hteumeuleu/caniemail), MIT License, Copyright (c) Rémi Parmentier. diff --git a/README.md b/README.md index 99782ba..cbf48e2 100644 --- a/README.md +++ b/README.md @@ -1,20 +1,88 @@ -# MSCode badges +

+ MSCode badges +

-Status: planned, not started. +

+ Tests + Cloudflare Workers + License MIT +

-Badges and tech icons in the MSCode style, to replace shields.io and skillicons.dev in our READMEs and the organization profile. Public, so anyone can use them. +

+ Badges and tech icon rows for READMEs, in light and dark. Static badges from the URL, live npm, Packagist and GitHub badges, larger buttons for profile links, and one consistent icon set that also covers Hono, Caddy, Traefik, GoLand, Stripe, Strapi, Przelewy24 and InPost. Text is drawn as vector paths, so every badge looks the same with or without the fonts installed. Free to use, no sign-up. +

-## TODO +

+ Badges · Icons · Options · Run it yourself +

-- [ ] Visual style: MSCode blue `#1A5BB5`, Plus Jakarta Sans and JetBrains Mono, light and dark variants -- [ ] Static badges from a URL, e.g. `/badge/node/22+` -- [ ] Live badges: npm version and downloads, Packagist version and downloads, GitHub Actions status, GitHub stars, license -- [ ] Tech icons in one set, including the ones skillicons lacks (Hono, Caddy, Traefik, GoLand, Stripe, Strapi, Przelewy24, InPost) -- [ ] Text rendered as paths so badges look the same without the fonts installed -- [ ] Caching, so READMEs do not hit the npm and GitHub APIs on every view -- [ ] Hosting and domain, e.g. a Cloudflare Worker on `badges.mscode.pl` -- [ ] Swap the badges in email-lint, laravel-react-email and the `mscode-pl/.github` profile +## Badges -## License +The docs page at [badges.mscode.pl](https://badges.mscode.pl) lists every badge with Markdown to copy. -MIT +| Badge | URL | +|---|---| +| Static | `/badge/