* Build(deps-dev): bump eslint-plugin-import from 2.20.1 to 2.20.2 Bumps [eslint-plugin-import](https://github.com/benmosher/eslint-plugin-import) from 2.20.1 to 2.20.2. - [Release notes](https://github.com/benmosher/eslint-plugin-import/releases) - [Changelog](https://github.com/benmosher/eslint-plugin-import/blob/master/CHANGELOG.md) - [Commits](https://github.com/benmosher/eslint-plugin-import/compare/v2.20.1...v2.20.2) Signed-off-by: dependabot-preview[bot] <support@dependabot.com> * Fixes * refactor: combine imports * refactor: combine imports * refactor: combine imports * refactor: update import ordering Co-authored-by: dependabot-preview[bot] <27856297+dependabot-preview[bot]@users.noreply.github.com> Co-authored-by: repo-ranger[bot] <39074581+repo-ranger[bot]@users.noreply.github.com> Co-authored-by: Paul Melnikow <email@paulmelnikow.com> Co-authored-by: Caleb Cartwright <calebcartwright@users.noreply.github.com> Co-authored-by: Caleb Cartwright <caleb.cartwright@outlook.com>
67 lines
1.4 KiB
JavaScript
67 lines
1.4 KiB
JavaScript
'use strict'
|
|
|
|
const { colorScale } = require('../color-formatters')
|
|
const { BaseJsonService } = require('..')
|
|
const { fetchProject } = require('./librariesio-common')
|
|
|
|
const sourceRankColor = colorScale([10, 15, 20, 25, 30])
|
|
|
|
module.exports = class LibrariesIoSourcerank extends BaseJsonService {
|
|
static get category() {
|
|
return 'rating'
|
|
}
|
|
|
|
static get route() {
|
|
return {
|
|
base: 'librariesio/sourcerank',
|
|
pattern: ':platform/:scope(@[^/]+)?/:packageName',
|
|
}
|
|
}
|
|
|
|
static get examples() {
|
|
return [
|
|
{
|
|
title: 'Libraries.io SourceRank',
|
|
pattern: ':platform/:packageName',
|
|
namedParams: {
|
|
platform: 'npm',
|
|
packageName: 'got',
|
|
},
|
|
staticPreview: this.render({ rank: 25 }),
|
|
},
|
|
{
|
|
title: 'Libraries.io SourceRank, scoped npm package',
|
|
pattern: ':platform/:scope/:packageName',
|
|
namedParams: {
|
|
platform: 'npm',
|
|
scope: '@babel',
|
|
packageName: 'core',
|
|
},
|
|
staticPreview: this.render({ rank: 3 }),
|
|
},
|
|
]
|
|
}
|
|
|
|
static get defaultBadgeData() {
|
|
return {
|
|
label: 'sourcerank',
|
|
}
|
|
}
|
|
|
|
static render({ rank }) {
|
|
return {
|
|
message: rank,
|
|
color: sourceRankColor(rank),
|
|
}
|
|
}
|
|
|
|
async handle({ platform, scope, packageName }) {
|
|
const { rank } = await fetchProject(this, {
|
|
platform,
|
|
scope,
|
|
packageName,
|
|
})
|
|
return this.constructor.render({ rank })
|
|
}
|
|
}
|