* Build(deps-dev): bump eslint-plugin-import from 2.17.3 to 2.18.0 Bumps [eslint-plugin-import](https://github.com/benmosher/eslint-plugin-import) from 2.17.3 to 2.18.0. - [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.17.3...v2.18.0) Signed-off-by: dependabot-preview[bot] <support@dependabot.com> * Autofixes
54 lines
1.2 KiB
JavaScript
54 lines
1.2 KiB
JavaScript
'use strict'
|
|
|
|
const { metric } = require('../text-formatters')
|
|
const { fetchProject } = require('./librariesio-common')
|
|
const { BaseJsonService } = require('..')
|
|
|
|
// https://libraries.io/api#project-dependents
|
|
module.exports = class LibrariesIoDependents extends BaseJsonService {
|
|
static get category() {
|
|
return 'other'
|
|
}
|
|
|
|
static get route() {
|
|
return {
|
|
base: 'librariesio/dependents',
|
|
pattern: ':platform/:packageName',
|
|
}
|
|
}
|
|
|
|
static get examples() {
|
|
return [
|
|
{
|
|
title: 'Dependents (via libraries.io)',
|
|
namedParams: {
|
|
platform: 'npm',
|
|
packageName: 'got',
|
|
},
|
|
staticPreview: this.render({ dependentCount: 2000 }),
|
|
},
|
|
]
|
|
}
|
|
|
|
static get defaultBadgeData() {
|
|
return {
|
|
label: 'dependents',
|
|
}
|
|
}
|
|
|
|
static render({ dependentCount }) {
|
|
return {
|
|
message: metric(dependentCount),
|
|
color: dependentCount === 0 ? 'orange' : 'brightgreen',
|
|
}
|
|
}
|
|
|
|
async handle({ platform, packageName }) {
|
|
const { dependents_count: dependentCount } = await fetchProject(this, {
|
|
platform,
|
|
packageName,
|
|
})
|
|
return this.constructor.render({ dependentCount })
|
|
}
|
|
}
|