The project uses dynamic shields.io badges in the README to display current package versions. These badges are automatically updated during package lifecycle events to ensure they always reflect the actual installed versions.
The scripts/update-readme-badges.js script:
- Reads
package.jsonto get current package versions - Generates shields.io badge URLs for key dependencies
- Updates the README.md file with the new badge URLs
- @tanstack/react-query - Data fetching and caching
- zod - Schema validation
- next - Next.js framework
- react - React library
Badges use the shields.io npm version endpoint:
https://img.shields.io/npm/v/{package}?label={label}&logo=npm
For scoped packages like @tanstack/react-query, the package name is URL-encoded.
The badge updater runs automatically during:
- Runs after every
pnpm install - Ensures badges are up-to-date when dependencies change
- Runs when bumping the package version with
pnpm version - Automatically stages README.md changes with the version commit
Run the badge updater manually:
pnpm run badges:updateBadges reflect the actual installed versions from package.json
No need to manually edit version numbers in the README
Works seamlessly in automated workflows
Version hook ensures README changes are committed with version bumps
Edit scripts/update-readme-badges.js and add to the keyPackages array:
const keyPackages = [
{ name: 'package-name', label: 'Display Label' },
{ name: '@scoped/package', label: 'Scoped Package' },
// ... add more
];Modify the generateBadge() function to add style parameters:
function generateBadge(packageName, label) {
const encodedName = encodeURIComponent(packageName);
const badgeLabel = label || packageName;
// Add &style=flat-square or other shields.io parameters
return `}&logo=npm&style=flat-square)`;
}flat(default)flat-squareplasticfor-the-badgesocial
- Ensure the script has execute permissions
- Check that Node.js can read/write files
- Verify package.json contains the tracked dependencies
Run with error details:
node scripts/update-readme-badges.jsCheck for:
- Valid package.json format
- README.md file exists and is writable
- Correct regex patterns in the script
The badges show the published npm version, not your local version. This is expected behavior - shields.io fetches data from the npm registry.
- Live Data: Badges fetch current versions from npm
- CDN Cached: Fast loading with global CDN
- Standardized: Consistent appearance across projects
- Maintained: Service is actively maintained by the community
If you prefer static version strings, you can modify the script to inject actual version numbers from package.json instead of shields.io URLs.