- Switching to using
href
s instead of the oldxlink:href
syntax
- Add
idSuffix
param. This can be used to ensure every element id within the SVG is unique
- Drop compatibility with Node < 16
- Add
links
andlogoBase64
params
- Improve font measuring in for-the-badge and social styles
- Make for-the-badge letter spacing more predictable
- Readability improvements: a dark font color is automatically used when the badge's background is too light. For example:
- Better CSS color compliance: thanks to a switch from is-css-color to css-color-converter, you can use a wider range of color formats from the latest CSS specification, for example
rgb(0 255 0)
- Less dependencies: badge-maker no longer depends on camelcase
- Accessibility improvements: Help users of assistive technologies to read the badges when used inline
- Add TypeScript definitions
- Fix missing dependency
- Dropped support for node < 10
- Package name has changed to
badge-maker
and moved to https://www.npmjs.com/package/badge-maker BadgeFactory
class is removed and replaced bymakeBadge()
function.- Deprecated parameters have been removed. In version 2.2.0 the
colorA
,colorB
andcolorscheme
params were deprecated. In version 3.0.0 these have been removed. - Only SVG output format is now provided. JSON format has been dropped and the
format
key has been removed. - The
text
array has been replaced bylabel
andmessage
keys. - The
template
key has been renamedstyle
. To upgrade from v2.1.1, change your code from:to:const { BadgeFactory } = require('gh-badges') const bf = new BadgeFactory() const svg = bf.create({ text: ['build', 'passed'], format: 'svg', template: 'flat-square', })
const { makeBadge } = require('badge-maker') const svg = makeBadge({ label: 'build', message: 'passed', style: 'flat-square', })
ValidationError
had been added and inputs are now validated. In previous releases, invalid inputs would be discarded and replaced with defaults. For example, in 2.2.1would generate an SVG badge. In version >=3const { BadgeFactory } = require('gh-badges') const bf = new BadgeFactory() const svg = bf.create({ text: ['build', 'passed'], template: 'some invalid value', })
will throw aconst { makeBadge } = require('badge-maker') const svg = makeBadge({ label: 'build', message: 'passed', style: 'some invalid value', })
ValidationError
.- Raster support has been removed from the CLI. It will now only output SVG. On the console, the output of
badge
can be piped to a utility like imagemagick. If you were previously usingthis could be replaced bybadge build passed :green .gif
badge build passed :green | magick svg:- gif:-
- Removed dependency on doT library which has known vulnerabilities.
- Escape logos to prevent XSS vulnerability
- Update docblock for BadgeFactory.create()
-
labelColor
andcolor
are now the recommended attribute names for label color and message color.colorA
(now an alias forlabelColor
),colorB
(now an alias forcolor
) andcolorscheme
(now an alias forcolor
)
are now deprecated and will be removed in some future release.
- Semantic color aliases. Add support for:
- Add directory field to package.json (to help tools find this package in the repo)
- Prevent bad letter spacing when whitespace surrounds badge text
- Bump anafanafo
- Use caret instead of tilde for dependencies
- Generate JSON badges without using a template
- Refactoring
- Testing improvements
- Declare support for all currently maintained Node versions
- Explicitly test on all supported versions
gh-badges v2.1.0 implements a new text width measurer which uses a lookup table, removing the dependency on PDFKit. It is no longer necessary to provide a local copy of Verdana for accurate text width computation.
As such, the fontPath
and precomputeWidths
parameters are now deprecated. The recommended call to create an instance of BadgeFactory
is now
const bf = new BadgeFactory()
For backwards compatibility you can still construct an instance of BadgeFactory
with a call like
const bf = new BadgeFactory({
fontPath: '/path/to/Verdana.ttf',
precomputeWidths: true,
})
However, the function will issue a warning.
To clear the warning, change the code to:
const bf = new BadgeFactory()
These arguments will be removed in a future release.
To upgrade from v1.3.0, change your code from:
const badge = require('gh-badges')
const format = {
text: ['build', 'passed'],
colorscheme: 'green',
template: 'flat',
}
badge.loadFont('/path/to/Verdana.ttf', err => {
badge(format, (svg, err) => {
// svg is a string containing your badge
})
})
to:
const { BadgeFactory } = require('gh-badges')
const bf = new BadgeFactory()
const format = {
text: ['build', 'passed'],
colorscheme: 'green',
template: 'flat',
}
const svg = bf.create(format)
- Remove unnecessary dependencies
- Documentation improvements
gh-badges v2.0.0 declares a new public interface which is synchronous. If your version 1.3.0 code looked like this:
const badge = require('gh-badges')
const format = {
text: ['build', 'passed'],
colorscheme: 'green',
template: 'flat',
}
badge.loadFont('/path/to/Verdana.ttf', err => {
badge(format, (svg, err) => {
// svg is a string containing your badge
})
})
To upgrade to version 2.0.0, refactor you code to:
const { BadgeFactory } = require('gh-badges')
const bf = new BadgeFactory({ fontPath: '/path/to/Verdana.ttf' })
const format = {
text: ['build', 'passed'],
colorscheme: 'green',
template: 'flat',
}
const svg = bf.create(format)
You can generate badges without a copy of Verdana, however font width computation is approximate and badges may be distorted.
const bf = new BadgeFactory({ fallbackFontPath: 'Helvetica' })
Add support for optionally specifying the path to Verdana.ttf
. In earlier versions, the file needed to be in the directory containing Shields.
Without font path:
const badge = require('gh-badges')
badge({ text: ['build', 'passed'], colorscheme: 'green' }, (svg, err) => {
// svg is a string containing your badge
})
With font path:
const badge = require('gh-badges')
// Optional step, to have accurate text width computation.
badge.loadFont('/path/to/Verdana.ttf', err => {
badge(
{ text: ['build', 'passed'], colorscheme: 'green', template: 'flat' },
(svg, err) => {
// svg is a string containing your badge
},
)
})