Refactor nuget nycrc opencollective opm services (#5598)
This commit is contained in:
@@ -123,20 +123,14 @@ function createServiceFamily({
|
|||||||
}
|
}
|
||||||
|
|
||||||
class NugetVersionService extends Base {
|
class NugetVersionService extends Base {
|
||||||
static get name() {
|
static name = `${name}Version`
|
||||||
return `${name}Version`
|
|
||||||
}
|
|
||||||
|
|
||||||
static get category() {
|
static category = 'version'
|
||||||
return 'version'
|
|
||||||
}
|
|
||||||
|
|
||||||
static get route() {
|
static route = {
|
||||||
return {
|
base: `${serviceBaseUrl}/v`,
|
||||||
base: `${serviceBaseUrl}/v`,
|
pattern: ':packageName',
|
||||||
pattern: ':packageName',
|
queryParamSchema,
|
||||||
queryParamSchema,
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static get examples() {
|
static get examples() {
|
||||||
@@ -157,10 +151,8 @@ function createServiceFamily({
|
|||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
||||||
static get defaultBadgeData() {
|
static defaultBadgeData = {
|
||||||
return {
|
label: defaultLabel,
|
||||||
label: defaultLabel,
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static render(props) {
|
static render(props) {
|
||||||
@@ -193,19 +185,13 @@ function createServiceFamily({
|
|||||||
})
|
})
|
||||||
|
|
||||||
class NugetDownloadService extends Base {
|
class NugetDownloadService extends Base {
|
||||||
static get name() {
|
static name = `${name}Downloads`
|
||||||
return `${name}Downloads`
|
|
||||||
}
|
|
||||||
|
|
||||||
static get category() {
|
static category = 'downloads'
|
||||||
return 'downloads'
|
|
||||||
}
|
|
||||||
|
|
||||||
static get route() {
|
static route = {
|
||||||
return {
|
base: serviceBaseUrl,
|
||||||
base: serviceBaseUrl,
|
pattern: 'dt/:packageName',
|
||||||
pattern: 'dt/:packageName',
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static get examples() {
|
static get examples() {
|
||||||
|
|||||||
@@ -159,25 +159,17 @@ function createServiceFamily({
|
|||||||
withFeed = true,
|
withFeed = true,
|
||||||
}) {
|
}) {
|
||||||
class NugetVersionService extends BaseJsonService {
|
class NugetVersionService extends BaseJsonService {
|
||||||
static get category() {
|
static category = 'version'
|
||||||
return 'version'
|
|
||||||
}
|
|
||||||
|
|
||||||
static get route() {
|
static route = buildRoute({ serviceBaseUrl, withTenant, withFeed })
|
||||||
return buildRoute({ serviceBaseUrl, withTenant, withFeed })
|
.push('(v|vpre)', 'which')
|
||||||
.push('(v|vpre)', 'which')
|
.push('(.+?)', 'packageName')
|
||||||
.push('(.+?)', 'packageName')
|
.toObject()
|
||||||
.toObject()
|
|
||||||
}
|
|
||||||
|
|
||||||
static get examples() {
|
static examples = []
|
||||||
return []
|
|
||||||
}
|
|
||||||
|
|
||||||
static get defaultBadgeData() {
|
static defaultBadgeData = {
|
||||||
return {
|
label: defaultLabel,
|
||||||
label: defaultLabel,
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static render(props) {
|
static render(props) {
|
||||||
@@ -216,20 +208,14 @@ function createServiceFamily({
|
|||||||
}
|
}
|
||||||
|
|
||||||
class NugetDownloadService extends BaseJsonService {
|
class NugetDownloadService extends BaseJsonService {
|
||||||
static get category() {
|
static category = 'downloads'
|
||||||
return 'downloads'
|
|
||||||
}
|
|
||||||
|
|
||||||
static get route() {
|
static route = buildRoute({ serviceBaseUrl, withTenant, withFeed })
|
||||||
return buildRoute({ serviceBaseUrl, withTenant, withFeed })
|
.push('dt')
|
||||||
.push('dt')
|
.push('(.+?)', 'packageName')
|
||||||
.push('(.+?)', 'packageName')
|
.toObject()
|
||||||
.toObject()
|
|
||||||
}
|
|
||||||
|
|
||||||
static get examples() {
|
static examples = []
|
||||||
return []
|
|
||||||
}
|
|
||||||
|
|
||||||
static render(props) {
|
static render(props) {
|
||||||
return renderDownloadBadge(props)
|
return renderDownloadBadge(props)
|
||||||
|
|||||||
@@ -14,35 +14,31 @@ const {
|
|||||||
})
|
})
|
||||||
|
|
||||||
class NugetVersionService extends Version {
|
class NugetVersionService extends Version {
|
||||||
static get examples() {
|
static examples = [
|
||||||
return [
|
{
|
||||||
{
|
title: 'Nuget',
|
||||||
title: 'Nuget',
|
pattern: 'v/:packageName',
|
||||||
pattern: 'v/:packageName',
|
namedParams: { packageName: 'Microsoft.AspNet.Mvc' },
|
||||||
namedParams: { packageName: 'Microsoft.AspNet.Mvc' },
|
staticPreview: this.render({ version: '5.2.4' }),
|
||||||
staticPreview: this.render({ version: '5.2.4' }),
|
},
|
||||||
},
|
{
|
||||||
{
|
title: 'Nuget (with prereleases)',
|
||||||
title: 'Nuget (with prereleases)',
|
pattern: 'vpre/:packageName',
|
||||||
pattern: 'vpre/:packageName',
|
namedParams: { packageName: 'Microsoft.AspNet.Mvc' },
|
||||||
namedParams: { packageName: 'Microsoft.AspNet.Mvc' },
|
staticPreview: this.render({ version: '5.2.5-preview1' }),
|
||||||
staticPreview: this.render({ version: '5.2.5-preview1' }),
|
},
|
||||||
},
|
]
|
||||||
]
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
class NugetDownloadService extends Downloads {
|
class NugetDownloadService extends Downloads {
|
||||||
static get examples() {
|
static examples = [
|
||||||
return [
|
{
|
||||||
{
|
title: 'Nuget',
|
||||||
title: 'Nuget',
|
pattern: 'dt/:packageName',
|
||||||
pattern: 'dt/:packageName',
|
namedParams: { packageName: 'Microsoft.AspNet.Mvc' },
|
||||||
namedParams: { packageName: 'Microsoft.AspNet.Mvc' },
|
staticPreview: this.render({ downloads: 49e6 }),
|
||||||
staticPreview: this.render({ downloads: 49e6 }),
|
},
|
||||||
},
|
]
|
||||||
]
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = { NugetVersionService, NugetDownloadService }
|
module.exports = { NugetVersionService, NugetDownloadService }
|
||||||
|
|||||||
@@ -36,43 +36,35 @@ const documentation = `<p>
|
|||||||
const validThresholds = ['branches', 'lines', 'functions']
|
const validThresholds = ['branches', 'lines', 'functions']
|
||||||
|
|
||||||
module.exports = class Nycrc extends ConditionalGithubAuthV3Service {
|
module.exports = class Nycrc extends ConditionalGithubAuthV3Service {
|
||||||
static get category() {
|
static category = 'coverage'
|
||||||
return 'coverage'
|
|
||||||
|
static route = {
|
||||||
|
base: 'nycrc',
|
||||||
|
// TODO: eventually add support for .yml and .yaml:
|
||||||
|
pattern: ':user/:repo',
|
||||||
|
queryParamSchema: Joi.object({
|
||||||
|
config: Joi.string()
|
||||||
|
.regex(/(.*\.nycrc)|(.*\.json$)/)
|
||||||
|
.default('.nycrc'),
|
||||||
|
// Allow the default threshold detection logic to be overridden, .e.g.,
|
||||||
|
// favoring lines over branches:
|
||||||
|
preferredThreshold: Joi.string()
|
||||||
|
.optional()
|
||||||
|
.allow(...validThresholds),
|
||||||
|
}).required(),
|
||||||
}
|
}
|
||||||
|
|
||||||
static get route() {
|
static examples = [
|
||||||
return {
|
{
|
||||||
base: 'nycrc',
|
title: 'nycrc config on GitHub',
|
||||||
// TODO: eventually add support for .yml and .yaml:
|
namedParams: { user: 'yargs', repo: 'yargs' },
|
||||||
pattern: ':user/:repo',
|
queryParams: { config: '.nycrc', preferredThreshold: 'lines' },
|
||||||
queryParamSchema: Joi.object({
|
staticPreview: this.render({ coverage: 92 }),
|
||||||
config: Joi.string()
|
documentation,
|
||||||
.regex(/(.*\.nycrc)|(.*\.json$)/)
|
},
|
||||||
.default('.nycrc'),
|
]
|
||||||
// Allow the default threshold detection logic to be overridden, .e.g.,
|
|
||||||
// favoring lines over branches:
|
|
||||||
preferredThreshold: Joi.string()
|
|
||||||
.optional()
|
|
||||||
.allow(...validThresholds),
|
|
||||||
}).required(),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static get examples() {
|
static defaultBadgeData = { label: 'min coverage' }
|
||||||
return [
|
|
||||||
{
|
|
||||||
title: 'nycrc config on GitHub',
|
|
||||||
namedParams: { user: 'yargs', repo: 'yargs' },
|
|
||||||
queryParams: { config: '.nycrc', preferredThreshold: 'lines' },
|
|
||||||
staticPreview: this.render({ coverage: 92 }),
|
|
||||||
documentation,
|
|
||||||
},
|
|
||||||
]
|
|
||||||
}
|
|
||||||
|
|
||||||
static get defaultBadgeData() {
|
|
||||||
return { label: 'min coverage' }
|
|
||||||
}
|
|
||||||
|
|
||||||
static render({ coverage }) {
|
static render({ coverage }) {
|
||||||
return {
|
return {
|
||||||
|
|||||||
@@ -3,25 +3,19 @@
|
|||||||
const OpencollectiveBase = require('./opencollective-base')
|
const OpencollectiveBase = require('./opencollective-base')
|
||||||
|
|
||||||
module.exports = class OpencollectiveAll extends OpencollectiveBase {
|
module.exports = class OpencollectiveAll extends OpencollectiveBase {
|
||||||
static get route() {
|
static route = this.buildRoute('all')
|
||||||
return this.buildRoute('all')
|
|
||||||
}
|
|
||||||
|
|
||||||
static get examples() {
|
static examples = [
|
||||||
return [
|
{
|
||||||
{
|
title: 'Open Collective backers and sponsors',
|
||||||
title: 'Open Collective backers and sponsors',
|
namedParams: { collective: 'shields' },
|
||||||
namedParams: { collective: 'shields' },
|
staticPreview: this.render(35),
|
||||||
staticPreview: this.render(35),
|
keywords: ['opencollective'],
|
||||||
keywords: ['opencollective'],
|
},
|
||||||
},
|
]
|
||||||
]
|
|
||||||
}
|
|
||||||
|
|
||||||
static get defaultBadgeData() {
|
static defaultBadgeData = {
|
||||||
return {
|
label: 'backers and sponsors',
|
||||||
label: 'backers and sponsors',
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
async handle({ collective }) {
|
async handle({ collective }) {
|
||||||
|
|||||||
@@ -3,25 +3,19 @@
|
|||||||
const OpencollectiveBase = require('./opencollective-base')
|
const OpencollectiveBase = require('./opencollective-base')
|
||||||
|
|
||||||
module.exports = class OpencollectiveBackers extends OpencollectiveBase {
|
module.exports = class OpencollectiveBackers extends OpencollectiveBase {
|
||||||
static get route() {
|
static route = this.buildRoute('backers')
|
||||||
return this.buildRoute('backers')
|
|
||||||
}
|
|
||||||
|
|
||||||
static get examples() {
|
static examples = [
|
||||||
return [
|
{
|
||||||
{
|
title: 'Open Collective backers',
|
||||||
title: 'Open Collective backers',
|
namedParams: { collective: 'shields' },
|
||||||
namedParams: { collective: 'shields' },
|
staticPreview: this.render(25),
|
||||||
staticPreview: this.render(25),
|
keywords: ['opencollective'],
|
||||||
keywords: ['opencollective'],
|
},
|
||||||
},
|
]
|
||||||
]
|
|
||||||
}
|
|
||||||
|
|
||||||
static get defaultBadgeData() {
|
static defaultBadgeData = {
|
||||||
return {
|
label: 'backers',
|
||||||
label: 'backers',
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
async handle({ collective }) {
|
async handle({ collective }) {
|
||||||
|
|||||||
@@ -6,26 +6,20 @@ const documentation = `<h3>How to get the tierId</h3>
|
|||||||
<p>According to <a target="_blank" href="https://developer.opencollective.com/#/api/collectives?id=get-members-per-tier">open collectives documentation</a>, you can find the tierId by looking at the URL after clicking on a Tier Card on the collective page. (e.g. tierId for https://opencollective.com/shields/order/2988 is 2988)</p>`
|
<p>According to <a target="_blank" href="https://developer.opencollective.com/#/api/collectives?id=get-members-per-tier">open collectives documentation</a>, you can find the tierId by looking at the URL after clicking on a Tier Card on the collective page. (e.g. tierId for https://opencollective.com/shields/order/2988 is 2988)</p>`
|
||||||
|
|
||||||
module.exports = class OpencollectiveByTier extends OpencollectiveBase {
|
module.exports = class OpencollectiveByTier extends OpencollectiveBase {
|
||||||
static get route() {
|
static route = this.buildRoute('tier', true)
|
||||||
return this.buildRoute('tier', true)
|
|
||||||
}
|
|
||||||
|
|
||||||
static get examples() {
|
static examples = [
|
||||||
return [
|
{
|
||||||
{
|
title: 'Open Collective members by tier',
|
||||||
title: 'Open Collective members by tier',
|
namedParams: { collective: 'shields', tierId: '2988' },
|
||||||
namedParams: { collective: 'shields', tierId: '2988' },
|
staticPreview: this.render(8, 'monthly backers'),
|
||||||
staticPreview: this.render(8, 'monthly backers'),
|
keywords: ['opencollective'],
|
||||||
keywords: ['opencollective'],
|
documentation,
|
||||||
documentation,
|
},
|
||||||
},
|
]
|
||||||
]
|
|
||||||
}
|
|
||||||
|
|
||||||
static get defaultBadgeData() {
|
static defaultBadgeData = {
|
||||||
return {
|
label: 'open collective',
|
||||||
label: 'open collective',
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
async handle({ collective, tierId }) {
|
async handle({ collective, tierId }) {
|
||||||
|
|||||||
@@ -3,25 +3,19 @@
|
|||||||
const OpencollectiveBase = require('./opencollective-base')
|
const OpencollectiveBase = require('./opencollective-base')
|
||||||
|
|
||||||
module.exports = class OpencollectiveSponsors extends OpencollectiveBase {
|
module.exports = class OpencollectiveSponsors extends OpencollectiveBase {
|
||||||
static get route() {
|
static route = this.buildRoute('sponsors')
|
||||||
return this.buildRoute('sponsors')
|
|
||||||
}
|
|
||||||
|
|
||||||
static get examples() {
|
static examples = [
|
||||||
return [
|
{
|
||||||
{
|
title: 'Open Collective sponsors',
|
||||||
title: 'Open Collective sponsors',
|
namedParams: { collective: 'shields' },
|
||||||
namedParams: { collective: 'shields' },
|
staticPreview: this.render(10),
|
||||||
staticPreview: this.render(10),
|
keywords: ['opencollective'],
|
||||||
keywords: ['opencollective'],
|
},
|
||||||
},
|
]
|
||||||
]
|
|
||||||
}
|
|
||||||
|
|
||||||
static get defaultBadgeData() {
|
static defaultBadgeData = {
|
||||||
return {
|
label: 'sponsors',
|
||||||
label: 'sponsors',
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
async handle({ collective }) {
|
async handle({ collective }) {
|
||||||
|
|||||||
@@ -4,34 +4,26 @@ const { renderVersionBadge } = require('../version')
|
|||||||
const { BaseService, NotFound, InvalidResponse } = require('..')
|
const { BaseService, NotFound, InvalidResponse } = require('..')
|
||||||
|
|
||||||
module.exports = class OpmVersion extends BaseService {
|
module.exports = class OpmVersion extends BaseService {
|
||||||
static get category() {
|
static category = 'version'
|
||||||
return 'version'
|
|
||||||
|
static route = {
|
||||||
|
base: 'opm/v',
|
||||||
|
pattern: ':user/:moduleName',
|
||||||
}
|
}
|
||||||
|
|
||||||
static get route() {
|
static examples = [
|
||||||
return {
|
{
|
||||||
base: 'opm/v',
|
title: 'OPM',
|
||||||
pattern: ':user/:moduleName',
|
namedParams: {
|
||||||
}
|
user: 'openresty',
|
||||||
}
|
moduleName: 'lua-resty-lrucache',
|
||||||
|
|
||||||
static get examples() {
|
|
||||||
return [
|
|
||||||
{
|
|
||||||
title: 'OPM',
|
|
||||||
namedParams: {
|
|
||||||
user: 'openresty',
|
|
||||||
moduleName: 'lua-resty-lrucache',
|
|
||||||
},
|
|
||||||
staticPreview: renderVersionBadge({ version: 'v0.08' }),
|
|
||||||
},
|
},
|
||||||
]
|
staticPreview: renderVersionBadge({ version: 'v0.08' }),
|
||||||
}
|
},
|
||||||
|
]
|
||||||
|
|
||||||
static get defaultBadgeData() {
|
static defaultBadgeData = {
|
||||||
return {
|
label: 'opm',
|
||||||
label: 'opm',
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
async fetch({ user, moduleName }) {
|
async fetch({ user, moduleName }) {
|
||||||
|
|||||||
Reference in New Issue
Block a user