Files
shields/lib/refactoring-cli.js
chris48s b68ac16092 Move NPM package files out of /lib ; affects [resharper nuget myget dub chocolatey github] (#2300)
* move gh-badges files out of /lib

As far as possible, this is just moving files
around and updating paths however there are 2
functional changes in this commit:
- remove use of lib/register-chai-plugins.spec
  in badge-cli.spec.js
- remove use of starRating()
  in text-measurer.spec.js

* update service tests that use colorscheme.json

* split package.json in two

* clean up import

* don't hard-code path

* start a changelog

* put a license file in the package dir

* re-organise documentation 📚

* don't pack test files

* remove favicon from Makefile

* give package its own test command

* link the docs better in README
2018-11-15 18:48:01 +00:00

23 lines
908 B
JavaScript

'use strict'
const chalk = require('chalk')
const mapValues = require('lodash.mapvalues')
const colorscheme = require('../gh-badges/lib/colorscheme.json')
const colorsMap = mapValues(colorscheme, 'colorB')
const { floorCount } = require('./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(colorsMap[color])(`${percentDone}% done`))