- Replace the idea of color schemes with the idea of named colors (since none of our colorschemes have used `colorA`)
- Pass through the normalized color to `_shields_test` to harmonize with BaseService and simplify testing
- Update service tests
- Move responsibility for color generation into the npm package
- Remove several color helper functions and their tests
- Update gh-badge public API to accept `color` and `labelColor`
This is a precursor to refactoring some of the logo code for #2473.
21 lines
811 B
JavaScript
21 lines
811 B
JavaScript
'use strict'
|
|
|
|
const chalk = require('chalk')
|
|
|
|
const { namedColors } = require('../gh-badges/lib/color')
|
|
const { floorCount } = require('../lib/color-formatters')
|
|
const { loadServiceClasses } = require('../services')
|
|
|
|
const serviceClasses = loadServiceClasses()
|
|
const legacyServices = serviceClasses
|
|
.map(cls => (typeof cls.registerLegacyRouteHandler === 'function' ? 1 : 0))
|
|
.reduce((a, b) => a + b)
|
|
const newServices = serviceClasses.length - legacyServices
|
|
const percentDone = ((newServices / serviceClasses.length) * 100).toFixed(2)
|
|
const color = floorCount(percentDone, 10, 50, 100)
|
|
|
|
console.log(`Found ${serviceClasses.length} services:`)
|
|
console.log(`- ${legacyServices} legacy services`)
|
|
console.log(`- ${newServices} new services`)
|
|
console.log(chalk.hex(namedColors[color])(`${percentDone}% done`))
|