From 1c427efa5749a1f21745b850e44800035497857c Mon Sep 17 00:00:00 2001 From: Ion Gireada Date: Fri, 24 Oct 2025 14:01:56 +0300 Subject: [PATCH 1/2] fix(readme): remove hardcoded badges --- README.md | 21 ++++++++------------- 1 file changed, 8 insertions(+), 13 deletions(-) diff --git a/README.md b/README.md index 3cc97bc..64329a2 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,6 @@ # markdown-magic-transform-badges - [![npm version](https://img.shields.io/npm/v/markdown-magic-transform-badges.svg?style=for-the-badge)](https://www.npmjs.com/package/markdown-magic-transform-badges) [![actions status](https://img.shields.io/github/actions/workflow/status/ioncakephper/markdown-magic-transform-badges/ci.yml?branch=main&style=for-the-badge)](https://github.com/ioncakephper/markdown-magic-transform-badges/actions) [![license](https://img.shields.io/badge/license-MIT-blue.svg?style=for-the-badge)](https://www.npmjs.com/package/markdown-magic-transform-badges) [![maintained](https://img.shields.io/github/commit-activity/y/ioncakephper/markdown-magic-transform-badges?style=for-the-badge)](https://github.com/ioncakephper/markdown-magic-transform-badges/graphs/commit-activity) [![npm downloads](https://img.shields.io/npm/dw/markdown-magic-transform-badges.svg?style=for-the-badge)](https://www.npmjs.com/package/markdown-magic-transform-badges) [![codecov](https://img.shields.io/codecov/c/github/ioncakephper/markdown-magic-transform-badges?branch=main&style=for-the-badge)](https://codecov.io/gh/ioncakephper/markdown-magic-transform-badges) [![release](https://img.shields.io/github/v/release/ioncakephper/markdown-magic-transform-badges?style=for-the-badge)](https://github.com/ioncakephper/markdown-magic-transform-badges/releases)
@@ -157,61 +156,58 @@ This project is licensed under the terms of the MIT License. See the [`LICENSE`] ## Helper Scripts - -- `docs` — Generate documentation by processing README.md with markdown-magic. (line [12](./package.json#L12)) +- `docs` — Generate documentation by processing README.md with markdown-magic. (line [13](./package.json#L13)) ```bash npx markdown-magic README.md --config ./markdown-magic.config.js ``` -- `fix` — Automatically fix linting issues and format codebase. (line [7](./package.json#L7)) +- `fix` — Automatically fix linting issues and format codebase. (line [8](./package.json#L8)) ```bash npm run lint:fix && npm run format && npm run format:package ``` -- `format` — Format all project files using Prettier. (line [8](./package.json#L8)) +- `format` — Format all project files using Prettier. (line [9](./package.json#L9)) ```bash prettier --write . ``` -- `format:package` — Format the package.json file using Prettier. (line [9](./package.json#L9)) +- `format:package` — Format the package.json file using Prettier. (line [10](./package.json#L10)) ```bash prettier --write package.json ``` -- `lint` — Lint all project files to ensure code quality and consistency. (line [10](./package.json#L10)) +- `lint` — Lint all project files to ensure code quality and consistency. (line [11](./package.json#L11)) ```bash eslint . --ext .js,.json,.yaml,.yml,.md ``` -- `lint:fix` — Lint all project files and automatically fix issues where possible. (line [11](./package.json#L11)) +- `lint:fix` — Lint all project files and automatically fix issues where possible. (line [12](./package.json#L12)) ```bash eslint . --ext .js,.json,.yaml,.yml,.md --fix ``` -- `prep` — Prepare the project for publishing by generating docs and formatting code. (line [13](./package.json#L13)) +- `prep` — Prepare the project for publishing by generating docs and formatting code. (line [14](./package.json#L14)) ```bash npm run docs && npm run fix ``` -- `test` — Run the test suite using Jest. (line [6](./package.json#L6)) +- `test` — Run the test suite using Jest. (line [7](./package.json#L7)) ```bash jest --passWithNoTests ``` - ## Repository Structure - ``` └── markdown-magic-transform-badges/ ├── .pretierrc.json @@ -226,5 +222,4 @@ This project is licensed under the terms of the MIT License. See the [`LICENSE`] ├── README.md └── RULES_OF_CONDUCT.md ``` - From 6bfdde47ce1e96a3bfb66e972ba7bf6fe3266517 Mon Sep 17 00:00:00 2001 From: Ion Gireada Date: Sat, 8 Nov 2025 15:00:32 +0200 Subject: [PATCH 2/2] feat(badges): add option to exclude specific badges --- index.js | 53 +++++++++++++++++++++++++++++------------------------ 1 file changed, 29 insertions(+), 24 deletions(-) diff --git a/index.js b/index.js index eeed602..1dbd049 100644 --- a/index.js +++ b/index.js @@ -36,24 +36,29 @@ module.exports = ({ transform, options, settings = {} }) => { const name = pkg.name; // helper to add named badges - const pushBadge = (key, md) => allBadges.push({ key, md }); + const pushBadge = (key, md) => { + if (opts.excludeBadges && opts.excludeBadges.includes(key)) { + return; // Skip this badge if it's in the exclude list + } + allBadges.push({ key, md }); + }; if (name) { pushBadge( "npmVersion", `[![npm version](https://img.shields.io/npm/v/${encodeURIComponent( - name, + name )}.svg${style})](https://www.npmjs.com/package/${encodeURIComponent( - name, - )})`, + name + )})` ); pushBadge( "npmDownloads", `[![npm downloads](https://img.shields.io/npm/dw/${encodeURIComponent( - name, + name )}.svg${style})](https://www.npmjs.com/package/${encodeURIComponent( - name, - )})`, + name + )})` ); } @@ -61,10 +66,10 @@ module.exports = ({ transform, options, settings = {} }) => { pushBadge( "license", `[![license](https://img.shields.io/badge/license-${encodeURIComponent( - pkg.license, + pkg.license )}-blue.svg${style})](https://www.npmjs.com/package/${encodeURIComponent( - name, - )})`, + name + )})` ); } @@ -84,62 +89,62 @@ module.exports = ({ transform, options, settings = {} }) => { const workflowBranch = opts.ciBranch ?? pkg.ciBranch ?? "main"; pushBadge( "actions", - `[![actions status](https://img.shields.io/github/actions/workflow/status/${owner}/${repoName}/${workflowFile}?branch=${workflowBranch}${styleAmp})](https://github.com/${ownerRepo}/actions)`, + `[![actions status](https://img.shields.io/github/actions/workflow/status/${owner}/${repoName}/${workflowFile}?branch=${workflowBranch}${styleAmp})](https://github.com/${ownerRepo}/actions)` ); pushBadge( "codecov", - `[![codecov](https://img.shields.io/codecov/c/github/${owner}/${repoName}?branch=${workflowBranch}${styleAmp})](https://codecov.io/gh/${ownerRepo})`, + `[![codecov](https://img.shields.io/codecov/c/github/${owner}/${repoName}?branch=${workflowBranch}${styleAmp})](https://codecov.io/gh/${ownerRepo})` ); pushBadge( "release", - `[![release](https://img.shields.io/github/v/release/${owner}/${repoName}${style})](https://github.com/${ownerRepo}/releases)`, + `[![release](https://img.shields.io/github/v/release/${owner}/${repoName}${style})](https://github.com/${ownerRepo}/releases)` ); // Commit activity / maintained badge (yearly commits) pushBadge( "maintained", - `[![maintained](https://img.shields.io/github/commit-activity/y/${owner}/${repoName}${style})](https://github.com/${ownerRepo}/graphs/commit-activity)`, + `[![maintained](https://img.shields.io/github/commit-activity/y/${owner}/${repoName}${style})](https://github.com/${ownerRepo}/graphs/commit-activity)` ); pushBadge( "stars", - `[![stars](https://img.shields.io/github/stars/${owner}/${repoName}${style})](https://github.com/${ownerRepo}/stargazers)`, + `[![stars](https://img.shields.io/github/stars/${owner}/${repoName}${style})](https://github.com/${ownerRepo}/stargazers)` ); pushBadge( "forks", - `[![forks](https://img.shields.io/github/forks/${owner}/${repoName}${style})](https://github.com/${ownerRepo}/network/members)`, + `[![forks](https://img.shields.io/github/forks/${owner}/${repoName}${style})](https://github.com/${ownerRepo}/network/members)` ); pushBadge( "watchers", - `[![watchers](https://img.shields.io/github/watchers/${owner}/${repoName}${style})](https://github.com/${ownerRepo}/watchers)`, + `[![watchers](https://img.shields.io/github/watchers/${owner}/${repoName}${style})](https://github.com/${ownerRepo}/watchers)` ); pushBadge( "lastCommit", - `[![last commit](https://img.shields.io/github/last-commit/${owner}/${repoName}${style})](https://github.com/${ownerRepo}/commits)`, + `[![last commit](https://img.shields.io/github/last-commit/${owner}/${repoName}${style})](https://github.com/${ownerRepo}/commits)` ); pushBadge( "contributors", - `[![contributors](https://img.shields.io/github/contributors/${owner}/${repoName}${style})](https://github.com/${ownerRepo}/graphs/contributors)`, + `[![contributors](https://img.shields.io/github/contributors/${owner}/${repoName}${style})](https://github.com/${ownerRepo}/graphs/contributors)` ); pushBadge( "issues", - `[![issues](https://img.shields.io/github/issues/${owner}/${repoName}${style})](https://github.com/${ownerRepo}/issues)`, + `[![issues](https://img.shields.io/github/issues/${owner}/${repoName}${style})](https://github.com/${ownerRepo}/issues)` ); pushBadge( "pulls", - `[![pull requests](https://img.shields.io/github/issues-pr/${owner}/${repoName}${style})](https://github.com/${ownerRepo}/pulls)`, + `[![pull requests](https://img.shields.io/github/issues-pr/${owner}/${repoName}${style})](https://github.com/${ownerRepo}/pulls)` ); pushBadge( "repoSize", - `[![repo size](https://img.shields.io/github/repo-size/${owner}/${repoName}${style})](https://github.com/${ownerRepo})`, + `[![repo size](https://img.shields.io/github/repo-size/${owner}/${repoName}${style})](https://github.com/${ownerRepo})` ); pushBadge( "topLanguage", - `[![top language](https://img.shields.io/github/languages/top/${owner}/${repoName}${style})](https://github.com/${ownerRepo})`, + `[![top language](https://img.shields.io/github/languages/top/${owner}/${repoName}${style})](https://github.com/${ownerRepo})` ); pushBadge( "languages", - `[![languages](https://img.shields.io/github/languages/count/${owner}/${repoName}${style})](https://github.com/${ownerRepo}/search?l=)`, + `[![languages](https://img.shields.io/github/languages/count/${owner}/${repoName}${style})](https://github.com/${ownerRepo}/search?l=)` ); }