diff --git a/README.md b/README.md index 4d277c31..4a5d03e9 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,7 @@ [![Node.js](https://img.shields.io/badge/node-%3E%3D23.11.0-brightgreen.svg)](https://nodejs.org/) [![TypeScript](https://img.shields.io/badge/TypeScript-5.1.6-blue.svg)](https://www.typescriptlang.org/) [![PRs Welcome](https://img.shields.io/badge/PRs-welcome-brightgreen.svg)](CONTRIBUTING.md) -[![npm](https://img.shields.io/npm/v/@soulcraft/brainy.svg)](https://www.npmjs.com/package/@soulcraft/brainy) +[![npm](https://img.shields.io/badge/npm-v0.9.9-blue.svg)](https://www.npmjs.com/package/@soulcraft/brainy) [//]: # ([![Cartographer](https://img.shields.io/badge/Cartographer-Official%20Standard-brightgreen)](https://github.com/sodal-project/cartographer)) @@ -1269,6 +1269,17 @@ Brainy follows a specific code style to maintain consistency throughout the code 3. Make your changes 4. Submit a pull request +### Badge Maintenance + +The README badges are automatically updated during the build process: + +1. **npm Version Badge**: The npm version badge is automatically updated to match the version in package.json when: + - Running `npm run build` (via the prebuild script) + - Running `npm version` commands (patch, minor, major) + - Manually running `node scripts/generate-version.js` + +This ensures that the badge always reflects the current version in package.json, even before publishing to npm. + ## License [MIT](LICENSE) diff --git a/scripts/generate-version.js b/scripts/generate-version.js index eb6bb58e..a155ea83 100755 --- a/scripts/generate-version.js +++ b/scripts/generate-version.js @@ -66,12 +66,12 @@ try { // Get TypeScript version from package.json devDependencies const typescriptVersion = packageJson.devDependencies.typescript.replace('^', '') - // Update npm badge - using a more flexible approach + // Update npm badge - using a more flexible approach with explicit version const npmBadgeRegex = /\[\!\[npm\].*?\]\(https:\/\/www\.npmjs\.com\/package\/@soulcraft\/brainy\)/g if (npmBadgeRegex.test(readmeContent)) { readmeContent = readmeContent.replace( npmBadgeRegex, - `[![npm](https://img.shields.io/npm/v/@soulcraft/brainy.svg)](https://www.npmjs.com/package/@soulcraft/brainy)` + `[![npm](https://img.shields.io/badge/npm-v${version}-blue.svg)](https://www.npmjs.com/package/@soulcraft/brainy)` ) } else { console.log('Warning: Could not find npm badge in README.md')