* 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
60 lines
1.3 KiB
JavaScript
60 lines
1.3 KiB
JavaScript
'use strict'
|
|
|
|
const Joi = require('@hapi/joi')
|
|
const { renderVersionBadge } = require('../version')
|
|
const { BaseJsonService } = require('..')
|
|
|
|
const schema = Joi.object({
|
|
version: Joi.string().required(),
|
|
status: Joi.string()
|
|
.valid('ok')
|
|
.required(),
|
|
}).required()
|
|
|
|
module.exports = class JitPackVersion extends BaseJsonService {
|
|
static get category() {
|
|
return 'version'
|
|
}
|
|
|
|
static get route() {
|
|
return {
|
|
base: 'jitpack/v',
|
|
pattern: ':vcs(github|bitbucket|gitlab|gitee)/:user/:repo',
|
|
}
|
|
}
|
|
|
|
static get examples() {
|
|
return [
|
|
{
|
|
title: 'JitPack',
|
|
namedParams: {
|
|
vcs: 'github',
|
|
user: 'jitpack',
|
|
repo: 'maven-simple',
|
|
},
|
|
staticPreview: renderVersionBadge({ version: 'v1.1' }),
|
|
keywords: ['java', 'maven'],
|
|
},
|
|
]
|
|
}
|
|
|
|
static get defaultBadgeData() {
|
|
return { label: 'jitpack' }
|
|
}
|
|
|
|
async fetch({ vcs, user, repo }) {
|
|
const url = `https://jitpack.io/api/builds/com.${vcs}.${user}/${repo}/latest`
|
|
|
|
return this._requestJson({
|
|
schema,
|
|
url,
|
|
errorMessages: { 401: 'project not found or private' },
|
|
})
|
|
}
|
|
|
|
async handle({ vcs, user, repo }) {
|
|
const { version } = await this.fetch({ vcs, user, repo })
|
|
return renderVersionBadge({ version })
|
|
}
|
|
}
|