Refactor osslifecycle,packagecontrol,packagist,plgreview,poeditor service files (#5634)
This commit is contained in:
@@ -14,45 +14,37 @@ const documentation = `
|
||||
`
|
||||
|
||||
module.exports = class OssTracker extends BaseService {
|
||||
static get category() {
|
||||
return 'other'
|
||||
static category = 'other'
|
||||
|
||||
static route = {
|
||||
base: 'osslifecycle',
|
||||
pattern: ':user/:repo/:branch*',
|
||||
}
|
||||
|
||||
static get route() {
|
||||
return {
|
||||
base: 'osslifecycle',
|
||||
pattern: ':user/:repo/:branch*',
|
||||
}
|
||||
}
|
||||
|
||||
static get examples() {
|
||||
return [
|
||||
{
|
||||
title: 'OSS Lifecycle',
|
||||
pattern: ':user/:repo',
|
||||
namedParams: { user: 'Teevity', repo: 'ice' },
|
||||
staticPreview: this.render({ status: 'active' }),
|
||||
keywords: ['Netflix'],
|
||||
documentation,
|
||||
static examples = [
|
||||
{
|
||||
title: 'OSS Lifecycle',
|
||||
pattern: ':user/:repo',
|
||||
namedParams: { user: 'Teevity', repo: 'ice' },
|
||||
staticPreview: this.render({ status: 'active' }),
|
||||
keywords: ['Netflix'],
|
||||
documentation,
|
||||
},
|
||||
{
|
||||
title: 'OSS Lifecycle (branch)',
|
||||
pattern: ':user/:repo/:branch',
|
||||
namedParams: {
|
||||
user: 'Netflix',
|
||||
repo: 'osstracker',
|
||||
branch: 'documentation',
|
||||
},
|
||||
{
|
||||
title: 'OSS Lifecycle (branch)',
|
||||
pattern: ':user/:repo/:branch',
|
||||
namedParams: {
|
||||
user: 'Netflix',
|
||||
repo: 'osstracker',
|
||||
branch: 'documentation',
|
||||
},
|
||||
staticPreview: this.render({ status: 'active' }),
|
||||
keywords: ['Netflix'],
|
||||
documentation,
|
||||
},
|
||||
]
|
||||
}
|
||||
staticPreview: this.render({ status: 'active' }),
|
||||
keywords: ['Netflix'],
|
||||
documentation,
|
||||
},
|
||||
]
|
||||
|
||||
static get defaultBadgeData() {
|
||||
return { label: 'oss lifecycle' }
|
||||
}
|
||||
static defaultBadgeData = { label: 'oss lifecycle' }
|
||||
|
||||
/**
|
||||
* Return color for active, maintenance and archived statuses, which were the three
|
||||
|
||||
@@ -80,32 +80,22 @@ function DownloadsForInterval(interval) {
|
||||
}[interval]
|
||||
|
||||
return class PackageControlDownloads extends BaseJsonService {
|
||||
static get name() {
|
||||
return name
|
||||
}
|
||||
static name = name
|
||||
|
||||
static get category() {
|
||||
return 'downloads'
|
||||
}
|
||||
static category = 'downloads'
|
||||
|
||||
static get route() {
|
||||
return { base, pattern: ':packageName' }
|
||||
}
|
||||
static route = { base, pattern: ':packageName' }
|
||||
|
||||
static get examples() {
|
||||
return [
|
||||
{
|
||||
title: 'Package Control',
|
||||
namedParams: { packageName: 'GitGutter' },
|
||||
staticPreview: this.render({ downloads: 12000 }),
|
||||
keywords,
|
||||
},
|
||||
]
|
||||
}
|
||||
static examples = [
|
||||
{
|
||||
title: 'Package Control',
|
||||
namedParams: { packageName: 'GitGutter' },
|
||||
staticPreview: this.render({ downloads: 12000 }),
|
||||
keywords,
|
||||
},
|
||||
]
|
||||
|
||||
static get defaultBadgeData() {
|
||||
return { label: 'downloads' }
|
||||
}
|
||||
static defaultBadgeData = { label: 'downloads' }
|
||||
|
||||
static render({ downloads }) {
|
||||
return {
|
||||
|
||||
@@ -41,57 +41,49 @@ const queryParamSchema = Joi.object({
|
||||
}).required()
|
||||
|
||||
module.exports = class PackagistDownloads extends BasePackagistService {
|
||||
static get category() {
|
||||
return 'downloads'
|
||||
static category = 'downloads'
|
||||
|
||||
static route = {
|
||||
base: 'packagist',
|
||||
pattern: ':interval(dm|dd|dt)/:user/:repo',
|
||||
queryParamSchema,
|
||||
}
|
||||
|
||||
static get route() {
|
||||
return {
|
||||
base: 'packagist',
|
||||
pattern: ':interval(dm|dd|dt)/:user/:repo',
|
||||
queryParamSchema,
|
||||
}
|
||||
}
|
||||
|
||||
static get examples() {
|
||||
return [
|
||||
{
|
||||
title: 'Packagist Downloads',
|
||||
namedParams: {
|
||||
interval: 'dm',
|
||||
user: 'doctrine',
|
||||
repo: 'orm',
|
||||
},
|
||||
staticPreview: this.render({
|
||||
downloads: 1000000,
|
||||
interval: 'dm',
|
||||
}),
|
||||
keywords,
|
||||
documentation: cacheDocumentationFragment,
|
||||
static examples = [
|
||||
{
|
||||
title: 'Packagist Downloads',
|
||||
namedParams: {
|
||||
interval: 'dm',
|
||||
user: 'doctrine',
|
||||
repo: 'orm',
|
||||
},
|
||||
{
|
||||
title: 'Packagist Downloads (custom server)',
|
||||
namedParams: {
|
||||
interval: 'dm',
|
||||
user: 'doctrine',
|
||||
repo: 'orm',
|
||||
},
|
||||
staticPreview: this.render({
|
||||
downloads: 1000000,
|
||||
interval: 'dm',
|
||||
}),
|
||||
queryParams: { server: 'https://packagist.org' },
|
||||
keywords,
|
||||
documentation:
|
||||
customServerDocumentationFragment + cacheDocumentationFragment,
|
||||
staticPreview: this.render({
|
||||
downloads: 1000000,
|
||||
interval: 'dm',
|
||||
}),
|
||||
keywords,
|
||||
documentation: cacheDocumentationFragment,
|
||||
},
|
||||
{
|
||||
title: 'Packagist Downloads (custom server)',
|
||||
namedParams: {
|
||||
interval: 'dm',
|
||||
user: 'doctrine',
|
||||
repo: 'orm',
|
||||
},
|
||||
]
|
||||
}
|
||||
staticPreview: this.render({
|
||||
downloads: 1000000,
|
||||
interval: 'dm',
|
||||
}),
|
||||
queryParams: { server: 'https://packagist.org' },
|
||||
keywords,
|
||||
documentation:
|
||||
customServerDocumentationFragment + cacheDocumentationFragment,
|
||||
},
|
||||
]
|
||||
|
||||
static get defaultBadgeData() {
|
||||
return {
|
||||
label: 'downloads',
|
||||
}
|
||||
static defaultBadgeData = {
|
||||
label: 'downloads',
|
||||
}
|
||||
|
||||
static render({ downloads, interval }) {
|
||||
|
||||
@@ -29,41 +29,33 @@ const queryParamSchema = Joi.object({
|
||||
}).required()
|
||||
|
||||
module.exports = class PackagistLicense extends BasePackagistService {
|
||||
static get category() {
|
||||
return 'license'
|
||||
static category = 'license'
|
||||
|
||||
static route = {
|
||||
base: 'packagist/l',
|
||||
pattern: ':user/:repo',
|
||||
queryParamSchema,
|
||||
}
|
||||
|
||||
static get route() {
|
||||
return {
|
||||
base: 'packagist/l',
|
||||
pattern: ':user/:repo',
|
||||
queryParamSchema,
|
||||
}
|
||||
}
|
||||
static examples = [
|
||||
{
|
||||
title: 'Packagist License',
|
||||
namedParams: { user: 'doctrine', repo: 'orm' },
|
||||
staticPreview: renderLicenseBadge({ license: 'MIT' }),
|
||||
keywords,
|
||||
},
|
||||
{
|
||||
title: 'Packagist License (custom server)',
|
||||
namedParams: { user: 'doctrine', repo: 'orm' },
|
||||
queryParams: { server: 'https://packagist.org' },
|
||||
staticPreview: renderLicenseBadge({ license: 'MIT' }),
|
||||
keywords,
|
||||
documentation: customServerDocumentationFragment,
|
||||
},
|
||||
]
|
||||
|
||||
static get examples() {
|
||||
return [
|
||||
{
|
||||
title: 'Packagist License',
|
||||
namedParams: { user: 'doctrine', repo: 'orm' },
|
||||
staticPreview: renderLicenseBadge({ license: 'MIT' }),
|
||||
keywords,
|
||||
},
|
||||
{
|
||||
title: 'Packagist License (custom server)',
|
||||
namedParams: { user: 'doctrine', repo: 'orm' },
|
||||
queryParams: { server: 'https://packagist.org' },
|
||||
staticPreview: renderLicenseBadge({ license: 'MIT' }),
|
||||
keywords,
|
||||
documentation: customServerDocumentationFragment,
|
||||
},
|
||||
]
|
||||
}
|
||||
|
||||
static get defaultBadgeData() {
|
||||
return {
|
||||
label: 'license',
|
||||
}
|
||||
static defaultBadgeData = {
|
||||
label: 'license',
|
||||
}
|
||||
|
||||
transform({ json, user, repo }) {
|
||||
|
||||
@@ -14,60 +14,52 @@ const queryParamSchema = Joi.object({
|
||||
}).required()
|
||||
|
||||
module.exports = class PackagistPhpVersion extends BasePackagistService {
|
||||
static get category() {
|
||||
return 'platform-support'
|
||||
static category = 'platform-support'
|
||||
|
||||
static route = {
|
||||
base: 'packagist/php-v',
|
||||
pattern: ':user/:repo/:version?',
|
||||
queryParamSchema,
|
||||
}
|
||||
|
||||
static get route() {
|
||||
return {
|
||||
base: 'packagist/php-v',
|
||||
pattern: ':user/:repo/:version?',
|
||||
queryParamSchema,
|
||||
}
|
||||
}
|
||||
static examples = [
|
||||
{
|
||||
title: 'Packagist PHP Version Support',
|
||||
pattern: ':user/:repo',
|
||||
namedParams: {
|
||||
user: 'symfony',
|
||||
repo: 'symfony',
|
||||
},
|
||||
staticPreview: this.render({ php: '^7.1.3' }),
|
||||
},
|
||||
{
|
||||
title: 'Packagist PHP Version Support (specify version)',
|
||||
pattern: ':user/:repo/:version',
|
||||
namedParams: {
|
||||
user: 'symfony',
|
||||
repo: 'symfony',
|
||||
version: 'v2.8.0',
|
||||
},
|
||||
staticPreview: this.render({ php: '>=5.3.9' }),
|
||||
},
|
||||
{
|
||||
title: 'Packagist PHP Version Support (custom server)',
|
||||
pattern: ':user/:repo',
|
||||
namedParams: {
|
||||
user: 'symfony',
|
||||
repo: 'symfony',
|
||||
},
|
||||
queryParams: {
|
||||
server: 'https://packagist.org',
|
||||
},
|
||||
staticPreview: this.render({ php: '^7.1.3' }),
|
||||
documentation: customServerDocumentationFragment,
|
||||
},
|
||||
]
|
||||
|
||||
static get examples() {
|
||||
return [
|
||||
{
|
||||
title: 'Packagist PHP Version Support',
|
||||
pattern: ':user/:repo',
|
||||
namedParams: {
|
||||
user: 'symfony',
|
||||
repo: 'symfony',
|
||||
},
|
||||
staticPreview: this.render({ php: '^7.1.3' }),
|
||||
},
|
||||
{
|
||||
title: 'Packagist PHP Version Support (specify version)',
|
||||
pattern: ':user/:repo/:version',
|
||||
namedParams: {
|
||||
user: 'symfony',
|
||||
repo: 'symfony',
|
||||
version: 'v2.8.0',
|
||||
},
|
||||
staticPreview: this.render({ php: '>=5.3.9' }),
|
||||
},
|
||||
{
|
||||
title: 'Packagist PHP Version Support (custom server)',
|
||||
pattern: ':user/:repo',
|
||||
namedParams: {
|
||||
user: 'symfony',
|
||||
repo: 'symfony',
|
||||
},
|
||||
queryParams: {
|
||||
server: 'https://packagist.org',
|
||||
},
|
||||
staticPreview: this.render({ php: '^7.1.3' }),
|
||||
documentation: customServerDocumentationFragment,
|
||||
},
|
||||
]
|
||||
}
|
||||
|
||||
static get defaultBadgeData() {
|
||||
return {
|
||||
label: 'php',
|
||||
color: 'blue',
|
||||
}
|
||||
static defaultBadgeData = {
|
||||
label: 'php',
|
||||
color: 'blue',
|
||||
}
|
||||
|
||||
static render({ php }) {
|
||||
|
||||
@@ -22,53 +22,45 @@ const queryParamSchema = Joi.object({
|
||||
}).required()
|
||||
|
||||
module.exports = class PackagistStars extends BasePackagistService {
|
||||
static get category() {
|
||||
return 'rating'
|
||||
static category = 'rating'
|
||||
|
||||
static route = {
|
||||
base: 'packagist/stars',
|
||||
pattern: ':user/:repo',
|
||||
queryParamSchema,
|
||||
}
|
||||
|
||||
static get route() {
|
||||
return {
|
||||
base: 'packagist/stars',
|
||||
pattern: ':user/:repo',
|
||||
queryParamSchema,
|
||||
}
|
||||
}
|
||||
|
||||
static get examples() {
|
||||
return [
|
||||
{
|
||||
title: 'Packagist Stars',
|
||||
namedParams: {
|
||||
user: 'guzzlehttp',
|
||||
repo: 'guzzle',
|
||||
},
|
||||
staticPreview: this.render({
|
||||
stars: 1000,
|
||||
}),
|
||||
keywords,
|
||||
documentation: cacheDocumentationFragment,
|
||||
static examples = [
|
||||
{
|
||||
title: 'Packagist Stars',
|
||||
namedParams: {
|
||||
user: 'guzzlehttp',
|
||||
repo: 'guzzle',
|
||||
},
|
||||
{
|
||||
title: 'Packagist Stars (custom server)',
|
||||
namedParams: {
|
||||
user: 'guzzlehttp',
|
||||
repo: 'guzzle',
|
||||
},
|
||||
staticPreview: this.render({
|
||||
stars: 1000,
|
||||
}),
|
||||
queryParams: { server: 'https://packagist.org' },
|
||||
keywords,
|
||||
documentation:
|
||||
customServerDocumentationFragment + cacheDocumentationFragment,
|
||||
staticPreview: this.render({
|
||||
stars: 1000,
|
||||
}),
|
||||
keywords,
|
||||
documentation: cacheDocumentationFragment,
|
||||
},
|
||||
{
|
||||
title: 'Packagist Stars (custom server)',
|
||||
namedParams: {
|
||||
user: 'guzzlehttp',
|
||||
repo: 'guzzle',
|
||||
},
|
||||
]
|
||||
}
|
||||
staticPreview: this.render({
|
||||
stars: 1000,
|
||||
}),
|
||||
queryParams: { server: 'https://packagist.org' },
|
||||
keywords,
|
||||
documentation:
|
||||
customServerDocumentationFragment + cacheDocumentationFragment,
|
||||
},
|
||||
]
|
||||
|
||||
static get defaultBadgeData() {
|
||||
return {
|
||||
label: 'stars',
|
||||
}
|
||||
static defaultBadgeData = {
|
||||
label: 'stars',
|
||||
}
|
||||
|
||||
static render({ stars }) {
|
||||
|
||||
@@ -34,59 +34,51 @@ const queryParamSchema = Joi.object({
|
||||
}).required()
|
||||
|
||||
class PackagistVersion extends BasePackagistService {
|
||||
static get category() {
|
||||
return 'version'
|
||||
static category = 'version'
|
||||
|
||||
static route = {
|
||||
base: 'packagist/v',
|
||||
pattern: ':user/:repo',
|
||||
queryParamSchema,
|
||||
}
|
||||
|
||||
static get route() {
|
||||
return {
|
||||
base: 'packagist/v',
|
||||
pattern: ':user/:repo',
|
||||
queryParamSchema,
|
||||
}
|
||||
}
|
||||
static examples = [
|
||||
{
|
||||
title: 'Packagist Version',
|
||||
namedParams: {
|
||||
user: 'symfony',
|
||||
repo: 'symfony',
|
||||
},
|
||||
staticPreview: renderVersionBadge({ version: '4.2.2' }),
|
||||
keywords,
|
||||
},
|
||||
{
|
||||
title: 'Packagist Version (including pre-releases)',
|
||||
namedParams: {
|
||||
user: 'symfony',
|
||||
repo: 'symfony',
|
||||
},
|
||||
queryParams: { include_prereleases: null },
|
||||
staticPreview: renderVersionBadge({ version: '4.3-dev' }),
|
||||
keywords,
|
||||
},
|
||||
{
|
||||
title: 'Packagist Version (custom server)',
|
||||
namedParams: {
|
||||
user: 'symfony',
|
||||
repo: 'symfony',
|
||||
},
|
||||
queryParams: {
|
||||
server: 'https://packagist.org',
|
||||
},
|
||||
staticPreview: renderVersionBadge({ version: '4.2.2' }),
|
||||
keywords,
|
||||
documentation: customServerDocumentationFragment,
|
||||
},
|
||||
]
|
||||
|
||||
static get examples() {
|
||||
return [
|
||||
{
|
||||
title: 'Packagist Version',
|
||||
namedParams: {
|
||||
user: 'symfony',
|
||||
repo: 'symfony',
|
||||
},
|
||||
staticPreview: renderVersionBadge({ version: '4.2.2' }),
|
||||
keywords,
|
||||
},
|
||||
{
|
||||
title: 'Packagist Version (including pre-releases)',
|
||||
namedParams: {
|
||||
user: 'symfony',
|
||||
repo: 'symfony',
|
||||
},
|
||||
queryParams: { include_prereleases: null },
|
||||
staticPreview: renderVersionBadge({ version: '4.3-dev' }),
|
||||
keywords,
|
||||
},
|
||||
{
|
||||
title: 'Packagist Version (custom server)',
|
||||
namedParams: {
|
||||
user: 'symfony',
|
||||
repo: 'symfony',
|
||||
},
|
||||
queryParams: {
|
||||
server: 'https://packagist.org',
|
||||
},
|
||||
staticPreview: renderVersionBadge({ version: '4.2.2' }),
|
||||
keywords,
|
||||
documentation: customServerDocumentationFragment,
|
||||
},
|
||||
]
|
||||
}
|
||||
|
||||
static get defaultBadgeData() {
|
||||
return {
|
||||
label: 'packagist',
|
||||
}
|
||||
static defaultBadgeData = {
|
||||
label: 'packagist',
|
||||
}
|
||||
|
||||
static render({ version }) {
|
||||
|
||||
@@ -14,41 +14,35 @@ const schema = Joi.object({
|
||||
}).required()
|
||||
|
||||
module.exports = class PkgreviewRating extends BaseJsonService {
|
||||
static get category() {
|
||||
return 'rating'
|
||||
static category = 'rating'
|
||||
|
||||
static route = {
|
||||
base: 'pkgreview',
|
||||
pattern: ':format(rating|stars)/:pkgManager(npm)/:pkgSlug+',
|
||||
}
|
||||
|
||||
static get route() {
|
||||
return {
|
||||
base: 'pkgreview',
|
||||
pattern: ':format(rating|stars)/:pkgManager(npm)/:pkgSlug+',
|
||||
}
|
||||
}
|
||||
|
||||
static get examples() {
|
||||
return [
|
||||
{
|
||||
title: 'pkgreview.dev Package Ratings',
|
||||
pattern: 'rating/:pkgManager/:pkgSlug+',
|
||||
namedParams: { pkgManager: 'npm', pkgSlug: 'react' },
|
||||
staticPreview: this.render({
|
||||
format: 'rating',
|
||||
rating: 3.5,
|
||||
reviewsCount: 237,
|
||||
}),
|
||||
},
|
||||
{
|
||||
title: 'pkgreview.dev Star Ratings',
|
||||
pattern: 'stars/:pkgManager/:pkgSlug+',
|
||||
namedParams: { pkgManager: 'npm', pkgSlug: 'react' },
|
||||
staticPreview: this.render({
|
||||
format: 'stars',
|
||||
rating: 1.5,
|
||||
reviewsCount: 200,
|
||||
}),
|
||||
},
|
||||
]
|
||||
}
|
||||
static examples = [
|
||||
{
|
||||
title: 'pkgreview.dev Package Ratings',
|
||||
pattern: 'rating/:pkgManager/:pkgSlug+',
|
||||
namedParams: { pkgManager: 'npm', pkgSlug: 'react' },
|
||||
staticPreview: this.render({
|
||||
format: 'rating',
|
||||
rating: 3.5,
|
||||
reviewsCount: 237,
|
||||
}),
|
||||
},
|
||||
{
|
||||
title: 'pkgreview.dev Star Ratings',
|
||||
pattern: 'stars/:pkgManager/:pkgSlug+',
|
||||
namedParams: { pkgManager: 'npm', pkgSlug: 'react' },
|
||||
staticPreview: this.render({
|
||||
format: 'stars',
|
||||
rating: 1.5,
|
||||
reviewsCount: 200,
|
||||
}),
|
||||
},
|
||||
]
|
||||
|
||||
static render({ rating, reviewsCount, format }) {
|
||||
const message =
|
||||
|
||||
@@ -37,34 +37,28 @@ const queryParamSchema = Joi.object({
|
||||
}).required()
|
||||
|
||||
module.exports = class POEditor extends BaseJsonService {
|
||||
static get category() {
|
||||
return 'other'
|
||||
static category = 'other'
|
||||
|
||||
static route = {
|
||||
base: 'poeditor',
|
||||
pattern: 'progress/:projectId/:languageCode',
|
||||
queryParamSchema,
|
||||
}
|
||||
|
||||
static get route() {
|
||||
return {
|
||||
base: 'poeditor',
|
||||
pattern: 'progress/:projectId/:languageCode',
|
||||
queryParamSchema,
|
||||
}
|
||||
}
|
||||
|
||||
static get examples() {
|
||||
return [
|
||||
{
|
||||
title: 'POEditor',
|
||||
namedParams: { projectId: '323337', languageCode: 'fr' },
|
||||
queryParams: { token: 'abc123def456' },
|
||||
staticPreview: this.render({
|
||||
code: 200,
|
||||
message: 'OK',
|
||||
language: { percentage: 93, code: 'fr', name: 'French' },
|
||||
}),
|
||||
keywords: ['l10n'],
|
||||
documentation,
|
||||
},
|
||||
]
|
||||
}
|
||||
static examples = [
|
||||
{
|
||||
title: 'POEditor',
|
||||
namedParams: { projectId: '323337', languageCode: 'fr' },
|
||||
queryParams: { token: 'abc123def456' },
|
||||
staticPreview: this.render({
|
||||
code: 200,
|
||||
message: 'OK',
|
||||
language: { percentage: 93, code: 'fr', name: 'French' },
|
||||
}),
|
||||
keywords: ['l10n'],
|
||||
documentation,
|
||||
},
|
||||
]
|
||||
|
||||
static render({ code, message, language }) {
|
||||
if (code !== 200) {
|
||||
|
||||
Reference in New Issue
Block a user