4.0.8 • Published 2 years ago

@thebespokepixel/badges v4.0.8

Weekly downloads
1
License
MIT
Repository
github
Last release
2 years ago

Badges

Automatically render project badges into readme and documentation files, with consistent styling.

Publishing Status

Status npm Libraries.io
Travis Rollup

Development Status

Travis Libraries.io
Snyk Code-Climate Code-Climate Coverage

Documentation/Help

Twitter

There's a wealth of status badges available out there, but even using a service like https://shields.io still doesn't cover everything and what it covers can be missing functionality…

…how about handling differences in your published and development branches?

…and, of course, you want it all looking organised and consistent, as much as possible…

Doing it properly means too much faffing about, despite it being useful to have 'at-a-glance' status reporting. This module is my attempt to cover off all that badge work into something I can simply include in package.json and move on.

If there are badges you'd like to see included, add an issue above, or better still a PR and I'll add it.

Usage

Installation

npm install --save @thebespokepixel/badges

Example

With this source.markdown:

  Badges:
  ${badges}

Read it in as a template and merge the AST:

/* Import the module… */
import {readFileSync} from 'fs'
import _ from 'lodash'
import remark from 'remark'
import badges from 'badges'

/* …then read the 'badges.readme' stanza from package.json and send the AST into remark etc. */
const content = {
  badges: await badges('readme')
}

const template = _.template(readFileSync('./source.markdown'))
const page = await remark().process(template(content))

Supported badges

  • Status (plus similar aux1 and aux2)
  • Travis (.org and .com)
  • Travis private repos (requires a travis private repo token)
  • Libraries.io New
  • Code Climate and Code Climate Coverage (requires a codeclimate repo token)
  • Inch CI
  • npm
  • Rollup
  • Snyk
  • Gitter
  • Twitter

David has been dropped as it seems the site is now dead.

Configuration

In package.json...

...
"badges": {
  "name": "badges", // Package name
  "github": "thebespokepixel", // github user
  "npm": "thebespokepixel", // npm user
  "libraries-io": "TheBespokePixel", // libraries-io github user (seems to use the name)
  "twitter": "thebespokepixel", // twitter user (optional, defaults to github user name)
  "devBranch": "develop", // Development branch name (optional, defaults to 'develop')
  "codeclimate": "a0a755b0fce22eb0b784", // codeclimate repo token (optional)
  "travis": "1a2b3c4d", // Travis 'Pro' private repo token (optional)
  "providers": { // Non-default badge provider configuration
    "status": {
      "text": "beta",
      "color": "blue"
    },
    "aux1": {
      "title": "github",
      "text": "source",
      "color": "4E73B6",
      "link": "https://github.com/MarkGriffiths/badges"
    }
  }
  "readme": { // Section with subtitles as map of arrays
    "Status": [
      [ "status", "npm", "travis-com", "libraries-io-npm" ],
    ],
    "Dev Status": [
      [ "travis-com-dev", "libraries-io-repo" ],
      [ "code-climate", "code-climate-coverage", "snyk" ]
    ],
    "Documentation/Help": [ "inch", "twitter" ]
  },
  "docs": [ // Lines as an array of arrays
    [ "aux1", "travis" ],
    [ "code-climate", "code-climate-coverage" ],
    [ "libraries-io-npm" ]
  ]
}

Full list

IDBadge DescriptionLink
statusGeneric status
aux-1Generic aux 1
aux-2Generic aux 2
gitterGitter chat badgehttps://gitter.im
code-climateCode Climate Maintainabilityhttps://codeclimate.com
code-climate-coverageCode Climate Coverage
libraries-io-npmLibraries.io latest release dependency status badgehttps://libraries.io
libraries-io-repoLibraries.io repo deep dependency status badge (dev branch)
inchInch-CI doumentation coveragehttps://inch-ci.org
inch-devInch-CI doumentation coverage (dev branch)
npmNPM published versionhttps://www.npmjs.com
rollupShow Rollup/Treeshaking module/mjs supporthttps://rollupjs.org/guide/en/
snykShow Snyk Vulnerablilitieshttps://snyk.io
travisTravis.org build statushttps://travis.org
travis-devTravis.org build status (dev branch)
travis-comTravis.com build statushttps://travis.com
travis-com-devTravis.com build status (dev branch)
travis-proTravis.com build status with private token
travis-pro-devTravis.com build status with private token (dev branch)

Where possible, https://shields.io is used, or shields.io 'flat' styling is chosen where available from other providers.

4.0.5

2 years ago

4.0.7

2 years ago

4.0.6

2 years ago

4.0.8

2 years ago

4.0.4

2 years ago

4.0.1

3 years ago

4.0.0

3 years ago

4.0.3

2 years ago

4.0.2

3 years ago

3.0.2

4 years ago

3.0.1

4 years ago

3.0.0

4 years ago

2.1.2

4 years ago

2.1.1

4 years ago

2.1.0

4 years ago

2.0.1

5 years ago

2.0.0

5 years ago

1.0.8

5 years ago

1.0.7

5 years ago

1.0.6

5 years ago

1.0.5

5 years ago

1.0.4

5 years ago

1.0.3

5 years ago

1.0.2

5 years ago

1.0.1

5 years ago

1.0.0

5 years ago

0.3.8

5 years ago

0.3.7

5 years ago

0.3.6

5 years ago

0.3.5

5 years ago

0.3.4

5 years ago

0.3.3

6 years ago

0.3.2

6 years ago

0.3.1

6 years ago

0.3.0

6 years ago

0.2.8

7 years ago

0.2.7

7 years ago

0.2.6

7 years ago

0.2.5

7 years ago

0.2.4

8 years ago

0.2.3

8 years ago

0.2.2

8 years ago

0.2.1

8 years ago

0.2.0

8 years ago

0.1.17

8 years ago

0.1.16

8 years ago

0.1.15

8 years ago

0.1.14

8 years ago

0.1.13

8 years ago

0.1.12

8 years ago

0.1.11

8 years ago

0.1.10

8 years ago

0.1.9

8 years ago

0.1.8

8 years ago

0.1.7

8 years ago

0.1.6

8 years ago

0.1.5

8 years ago

0.1.4

8 years ago

0.1.3

8 years ago

0.1.2

8 years ago

0.1.1

8 years ago

0.1.0

8 years ago