Files
shields/services/librariesio/librariesio-dependencies-helpers.js
Paul Melnikow 946abc9ded Refactor [librariesio] (#3160)
This takes another pass over the modern services to remove unused code. I switched the shared code to use a function instead of a class and removed the indirection in the route params which led to skew between the route and examples and wasn't making things any clearer.
2019-03-06 23:21:22 -05:00

32 lines
764 B
JavaScript

'use strict'
function transform({ dependencies }) {
return {
deprecatedCount: dependencies.filter(dep => dep.deprecated).length,
outdatedCount: dependencies.filter(dep => dep.outdated).length,
}
}
function renderDependenciesBadge({ deprecatedCount, outdatedCount }) {
if (deprecatedCount > 0) {
// Deprecated dependencies are really bad
return {
message: `${deprecatedCount} deprecated`,
color: 'red',
}
} else if (outdatedCount > 0) {
// Out of date dependencies are pretty bad
return {
message: `${outdatedCount} out of date`,
color: 'orange',
}
} else {
return {
message: 'up to date',
color: 'brightgreen',
}
}
}
module.exports = { transform, renderDependenciesBadge }