* 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
76 lines
1.8 KiB
JavaScript
76 lines
1.8 KiB
JavaScript
'use strict'
|
|
|
|
const Joi = require('@hapi/joi')
|
|
const { BaseJsonService } = require('..')
|
|
|
|
const statusSchema = Joi.object({
|
|
status: Joi.string().required(),
|
|
}).required()
|
|
|
|
module.exports = class RequiresIo extends BaseJsonService {
|
|
static get category() {
|
|
return 'dependencies'
|
|
}
|
|
|
|
static get route() {
|
|
return {
|
|
base: 'requires',
|
|
pattern: ':service/:user/:repo/:branch*',
|
|
}
|
|
}
|
|
|
|
static get examples() {
|
|
return [
|
|
{
|
|
title: 'Requires.io',
|
|
pattern: ':service/:user/:repo',
|
|
namedParams: { service: 'github', user: 'celery', repo: 'celery' },
|
|
staticPreview: this.render({ status: 'up-to-date' }),
|
|
},
|
|
{
|
|
title: 'Requires.io (branch)',
|
|
pattern: ':service/:user/:repo/:branch',
|
|
namedParams: {
|
|
service: 'github',
|
|
user: 'celery',
|
|
repo: 'celery',
|
|
branch: 'master',
|
|
},
|
|
staticPreview: this.render({ status: 'up-to-date' }),
|
|
},
|
|
]
|
|
}
|
|
|
|
static get defaultBadgeData() {
|
|
return { label: 'requirements' }
|
|
}
|
|
|
|
static render({ status }) {
|
|
let message = status
|
|
let color = 'lightgrey'
|
|
if (status === 'up-to-date') {
|
|
message = 'up to date'
|
|
color = 'brightgreen'
|
|
} else if (status === 'outdated') {
|
|
color = 'yellow'
|
|
} else if (status === 'insecure') {
|
|
color = 'red'
|
|
}
|
|
return { message, color }
|
|
}
|
|
|
|
async fetch({ service, user, repo, branch }) {
|
|
const url = `https://requires.io/api/v1/status/${service}/${user}/${repo}`
|
|
return this._requestJson({
|
|
url,
|
|
schema: statusSchema,
|
|
options: { qs: { branch } },
|
|
})
|
|
}
|
|
|
|
async handle({ service, user, repo, branch }) {
|
|
const { status } = await this.fetch({ service, user, repo, branch })
|
|
return this.constructor.render({ status })
|
|
}
|
|
}
|