* Validate input to BadgeFactory.create() (#3875) * validate input to create() * remove deprecated properties (#3881) * remove BadgeFactory class (#3884) * Template literal templates (#4459) - Remove use of the doT template library and move to generating SVG output using javascript template literals. - Drop SVGO and mostly manually implement the optimisations. - Add a bunch more tests Co-authored-by: Paul Melnikow <github@paulmelnikow.com> * drop raster support in package CLI (#4523) * drop raster support in package CLI * update docs * rename gh-badges package to badge-maker * rename gh-badges dir to badge-maker * update relative imports and other refs to in parent dir 'gh-badges' --> 'badge-maker' * update snyk service tests This change is only tangentially related We've used the shields repo as an example for these tests so moving files around in our repo has a knock-on effect on them * add missing type hints to dev style page * write the changelog/migration guide for v3 * use extension in README CLI example * update CLI help whoops - missed this in #4523 * bump version * update for self-hosting users * README updates * drop .format param from CLI, always output SVG * Change text[] to label and message, Remove JSON output - Change text[] to label and message - Fix message only badge - Remove JSON output format - Update the docs * update package-lock * rename 'template' to 'style' * handle invalid styles in coalesceBadge * ensure makeBadge is passed a string for template in coalesceBadge() issue #4925 * fix (logo/no label text/label color specified) case issue #4926 * add example of (logo/no label text/label color specified) to style debug page * update type defs * padding fix for FTB style Co-authored-by: Paul Melnikow <github@paulmelnikow.com>
66 lines
1.5 KiB
JavaScript
Executable File
66 lines
1.5 KiB
JavaScript
Executable File
#!/usr/bin/env node
|
|
|
|
'use strict'
|
|
|
|
const { namedColors } = require('./color')
|
|
const { makeBadge } = require('./index')
|
|
|
|
if (process.argv.length < 4) {
|
|
console.log('Usage: badge label message [:color] [@style]')
|
|
console.log('Or: badge label message color [labelColor] [@style]')
|
|
console.log()
|
|
console.log(' color, labelColor:')
|
|
console.log(` one of ${Object.keys(namedColors).join(', ')}.`)
|
|
console.log(' #xxx (three hex digits)')
|
|
console.log(' #xxxxxx (six hex digits)')
|
|
console.log(' color (CSS color)')
|
|
console.log()
|
|
console.log('Eg: badge cactus grown :green @flat')
|
|
console.log()
|
|
process.exit()
|
|
}
|
|
|
|
// Find a format specifier.
|
|
let style = ''
|
|
for (let i = 4; i < process.argv.length; i++) {
|
|
if (process.argv[i][0] === '@') {
|
|
style = process.argv[i].slice(1)
|
|
process.argv.splice(i, 1)
|
|
continue
|
|
}
|
|
}
|
|
|
|
const label = process.argv[2]
|
|
const message = process.argv[3]
|
|
let color = process.argv[4] || ':green'
|
|
const labelColor = process.argv[5]
|
|
|
|
const badgeData = { label, message }
|
|
if (style) {
|
|
badgeData.style = style
|
|
}
|
|
|
|
if (color[0] === ':') {
|
|
color = color.slice(1)
|
|
if (namedColors[color] == null) {
|
|
// Colorscheme not found.
|
|
console.error('Invalid color scheme.')
|
|
process.exit(1)
|
|
}
|
|
badgeData.color = color
|
|
} else {
|
|
badgeData.color = color
|
|
if (labelColor) {
|
|
badgeData.labelColor = labelColor
|
|
}
|
|
}
|
|
|
|
;(() => {
|
|
try {
|
|
console.log(makeBadge(badgeData))
|
|
} catch (e) {
|
|
console.error(e)
|
|
process.exit(1)
|
|
}
|
|
})()
|