npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

coverage-badges-cli

v2.1.0

Published

Create coverage badges from coverage reports. Using GitHub Actions and GitHub Workflow CPU time (no 3rd parties servers).

Downloads

6,897

Readme

coverage-badges-cli

Buy me a coffee Build & Deploy Coverage Status npm version Download NPM

Create coverage badges from coverage reports. Using GitHub Actions and GitHub Workflow CPU time (no 3rd parties servers).

Don't worry about the coverage.io service is down.

Install

$ npm i coverage-badges-cli

Example

{
  "scripts": {
    "coverage": "jest --coverage"
    "make-badges": "coverage-badges",
  },
  "jest": {
    "collectCoverageFrom": [
      "<rootDir>/packages/**/*.{tsx,ts}",
      "!**/*.{js,d.ts}"
    ],
    "coverageReporters": [
      "lcov",
      "json-summary"
    ],
  }
}

This config creates a coverage badge in a default directory ./badges.

You can add ![Coverage](./coverage/badges.svg) to your README.md after the badge creation.

Github Actions

Input Parameters

  • source - The path of the target file "coverage-summary.json".
  • output - Output image path.
  • label - The left label of the badge, usually static (default coverage).
  • labelColor - <Color RGB> or <Color Name> (default: 555).
  • scale - Set badge scale (default: 1).
  • style - Badges style: flat, classic (default classic).
  • ~~type~~ - (No longer supported after v1.2.0) Coverage report type: lines, statements, functions, branches (default statements)
  • jsonPath - Path to the coverage percentage number to be used in the badge (default total.statements.pct)
  • icon - Path to icon file
- name: Create Coverage Badges
  uses: jaywcjlove/coverage-badges-cli@main
  with:
    style: flat
    source: coverage/coverage-summary.json
    output: coverage/badges.svg
    jsonPath: totals.percent_covered

- name: Deploy
  uses: peaceiris/actions-gh-pages@v3
  with:
    github_token: ${{ secrets.GITHUB_TOKEN }}
    publish_dir: ./build

Output Parameters

svg svg image string: <svg xmlns.....

Using the command line

name: Build & Deploy
on:
  push:
    branches:
      - master

jobs:
  build-deploy:
    runs-on: ubuntu-18.04
    steps:
    - uses: actions/checkout@v2
    - uses: actions/setup-node@v2
      with:
        node-version: 14

    - run: npm install
    - run: npm run build
    - run: npm run coverage
    - run: npm i coverage-badges-cli -g
    - run: coverage-badges --output coverage/badges.svg

    - name: Deploy
      uses: peaceiris/actions-gh-pages@v3
      if: github.ref == 'refs/heads/master'
      with:
        github_token: ${{ secrets.GITHUB_TOKEN }}
        publish_dir: ./coverage

Command Help

Usage: coverage-badges [options] [--help|h]

Options:

  --version, -v  Show version number
  --help, -h     Displays help information.
  --output, -o   Output directory.
  --source, -s   The path of the target file "coverage-summary.json".
  --style        Badges style: flat, flat-square.
  --type         Coverage type: lines, statements, functions, branches.
  --scale        Set badge scale (default: 1)
  --icon         Path to icon file
  --iconWidth    Set this if icon is not square (default: 13)
  --label        The left label of the badge, usually static (default `coverage`).
  --labelColor   <Color RGB> or <Color Name> (default: '555')
  --color        <Color RGB> or <Color Name> (default: '')

Example:

  npm coverage-badges-cli --output coverage/badges.svg
  npm coverage-badges-cli --style plastic
  npm coverage-badges-cli --source coverage/coverage-summary.json
  npm coverage-badges-cli --labelColor ADF

Development

$ npm i
$ npm run build
$ npm run watch

See also

Contributors

As always, thanks to our amazing contributors!

Made with contributors.

License

MIT © Kenny Wong