* 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
40 lines
930 B
JavaScript
40 lines
930 B
JavaScript
'use strict'
|
|
|
|
const Joi = require('@hapi/joi')
|
|
const jp = require('jsonpath')
|
|
const { renderDynamicBadge, errorMessages } = require('../dynamic-common')
|
|
const { createRoute } = require('./dynamic-helpers')
|
|
const { BaseYamlService, InvalidResponse } = require('..')
|
|
|
|
module.exports = class DynamicYaml extends BaseYamlService {
|
|
static get category() {
|
|
return 'dynamic'
|
|
}
|
|
|
|
static get route() {
|
|
return createRoute('yaml')
|
|
}
|
|
|
|
static get defaultBadgeData() {
|
|
return {
|
|
label: 'custom badge',
|
|
}
|
|
}
|
|
|
|
async handle(namedParams, { url, query: pathExpression, prefix, suffix }) {
|
|
const data = await this._requestYaml({
|
|
schema: Joi.any(),
|
|
url,
|
|
errorMessages,
|
|
})
|
|
|
|
const values = jp.query(data, pathExpression)
|
|
|
|
if (!values.length) {
|
|
throw new InvalidResponse({ prettyMessage: 'no result' })
|
|
}
|
|
|
|
return renderDynamicBadge({ value: values, prefix, suffix })
|
|
}
|
|
}
|