convert [lgtm liberapay librariesio localizely luarocks] classes to static props (#5587)
* convert [homebrew,hsts,itunes,jenkins,jetbrains] classes to static props * Run the prettier across the files * Updated the correct values in logos.spec.js * revert back the logos.spec.js changes * Completed refactoring of [lgtm liberapay librariesio localizely luarocks] * Convert defaultBadgeData to object Co-authored-by: Jabbar Memon <jabbar@zoop.one>
This commit is contained in:
@@ -4,31 +4,25 @@ const { metric } = require('../text-formatters')
|
||||
const LgtmBaseService = require('./lgtm-base')
|
||||
|
||||
module.exports = class LgtmAlerts extends LgtmBaseService {
|
||||
static get route() {
|
||||
return {
|
||||
base: 'lgtm/alerts',
|
||||
pattern: this.pattern,
|
||||
}
|
||||
static route = {
|
||||
base: 'lgtm/alerts',
|
||||
pattern: this.pattern,
|
||||
}
|
||||
|
||||
static get examples() {
|
||||
return [
|
||||
{
|
||||
title: 'LGTM Alerts',
|
||||
namedParams: {
|
||||
host: 'github',
|
||||
user: 'apache',
|
||||
repo: 'cloudstack',
|
||||
},
|
||||
staticPreview: this.render({ alerts: 2488 }),
|
||||
static examples = [
|
||||
{
|
||||
title: 'LGTM Alerts',
|
||||
namedParams: {
|
||||
host: 'github',
|
||||
user: 'apache',
|
||||
repo: 'cloudstack',
|
||||
},
|
||||
]
|
||||
}
|
||||
staticPreview: this.render({ alerts: 2488 }),
|
||||
},
|
||||
]
|
||||
|
||||
static get defaultBadgeData() {
|
||||
return {
|
||||
label: 'lgtm alerts',
|
||||
}
|
||||
static defaultBadgeData = {
|
||||
label: 'lgtm alerts',
|
||||
}
|
||||
|
||||
static getColor({ alerts }) {
|
||||
|
||||
@@ -3,37 +3,33 @@
|
||||
const LgtmBaseService = require('./lgtm-base')
|
||||
|
||||
module.exports = class LgtmGrade extends LgtmBaseService {
|
||||
static get route() {
|
||||
return {
|
||||
base: 'lgtm/grade',
|
||||
pattern: `:language/${this.pattern}`,
|
||||
}
|
||||
static route = {
|
||||
base: 'lgtm/grade',
|
||||
pattern: `:language/${this.pattern}`,
|
||||
}
|
||||
|
||||
static get examples() {
|
||||
return [
|
||||
{
|
||||
title: 'LGTM Grade',
|
||||
namedParams: {
|
||||
language: 'java',
|
||||
host: 'github',
|
||||
user: 'apache',
|
||||
repo: 'cloudstack',
|
||||
},
|
||||
staticPreview: this.render({
|
||||
language: 'java',
|
||||
data: {
|
||||
languages: [
|
||||
{
|
||||
lang: 'java',
|
||||
grade: 'C',
|
||||
},
|
||||
],
|
||||
},
|
||||
}),
|
||||
static examples = [
|
||||
{
|
||||
title: 'LGTM Grade',
|
||||
namedParams: {
|
||||
language: 'java',
|
||||
host: 'github',
|
||||
user: 'apache',
|
||||
repo: 'cloudstack',
|
||||
},
|
||||
]
|
||||
}
|
||||
staticPreview: this.render({
|
||||
language: 'java',
|
||||
data: {
|
||||
languages: [
|
||||
{
|
||||
lang: 'java',
|
||||
grade: 'C',
|
||||
},
|
||||
],
|
||||
},
|
||||
}),
|
||||
},
|
||||
]
|
||||
|
||||
static getLabel({ language }) {
|
||||
const languageLabel = (() => {
|
||||
|
||||
@@ -4,23 +4,19 @@ const { InvalidResponse } = require('..')
|
||||
const { renderCurrencyBadge, LiberapayBase } = require('./liberapay-base')
|
||||
|
||||
module.exports = class LiberapayGives extends LiberapayBase {
|
||||
static get route() {
|
||||
return this.buildRoute('gives')
|
||||
}
|
||||
static route = this.buildRoute('gives')
|
||||
|
||||
static get examples() {
|
||||
return [
|
||||
{
|
||||
title: 'Liberapay giving',
|
||||
namedParams: { entity: 'Changaco' },
|
||||
staticPreview: renderCurrencyBadge({
|
||||
label: 'gives',
|
||||
amount: '2.58',
|
||||
currency: 'EUR',
|
||||
}),
|
||||
},
|
||||
]
|
||||
}
|
||||
static examples = [
|
||||
{
|
||||
title: 'Liberapay giving',
|
||||
namedParams: { entity: 'Changaco' },
|
||||
staticPreview: renderCurrencyBadge({
|
||||
label: 'gives',
|
||||
amount: '2.58',
|
||||
currency: 'EUR',
|
||||
}),
|
||||
},
|
||||
]
|
||||
|
||||
async handle({ entity }) {
|
||||
const data = await this.fetch({ entity })
|
||||
|
||||
@@ -5,19 +5,15 @@ const { InvalidResponse } = require('..')
|
||||
const { LiberapayBase } = require('./liberapay-base')
|
||||
|
||||
module.exports = class LiberapayGoal extends LiberapayBase {
|
||||
static get route() {
|
||||
return this.buildRoute('goal')
|
||||
}
|
||||
static route = this.buildRoute('goal')
|
||||
|
||||
static get examples() {
|
||||
return [
|
||||
{
|
||||
title: 'Liberapay goal progress',
|
||||
namedParams: { entity: 'Changaco' },
|
||||
staticPreview: this.render({ percentAchieved: 33 }),
|
||||
},
|
||||
]
|
||||
}
|
||||
static examples = [
|
||||
{
|
||||
title: 'Liberapay goal progress',
|
||||
namedParams: { entity: 'Changaco' },
|
||||
staticPreview: this.render({ percentAchieved: 33 }),
|
||||
},
|
||||
]
|
||||
|
||||
static render({ percentAchieved }) {
|
||||
return {
|
||||
|
||||
@@ -5,19 +5,15 @@ const { colorScale } = require('../color-formatters')
|
||||
const { LiberapayBase } = require('./liberapay-base')
|
||||
|
||||
module.exports = class LiberapayPatrons extends LiberapayBase {
|
||||
static get route() {
|
||||
return this.buildRoute('patrons')
|
||||
}
|
||||
static route = this.buildRoute('patrons')
|
||||
|
||||
static get examples() {
|
||||
return [
|
||||
{
|
||||
title: 'Liberapay patrons',
|
||||
namedParams: { entity: 'Changaco' },
|
||||
staticPreview: this.render({ patrons: 10 }),
|
||||
},
|
||||
]
|
||||
}
|
||||
static examples = [
|
||||
{
|
||||
title: 'Liberapay patrons',
|
||||
namedParams: { entity: 'Changaco' },
|
||||
staticPreview: this.render({ patrons: 10 }),
|
||||
},
|
||||
]
|
||||
|
||||
static render({ patrons }) {
|
||||
return {
|
||||
|
||||
@@ -4,23 +4,19 @@ const { InvalidResponse } = require('..')
|
||||
const { renderCurrencyBadge, LiberapayBase } = require('./liberapay-base')
|
||||
|
||||
module.exports = class LiberapayReceives extends LiberapayBase {
|
||||
static get route() {
|
||||
return this.buildRoute('receives')
|
||||
}
|
||||
static route = this.buildRoute('receives')
|
||||
|
||||
static get examples() {
|
||||
return [
|
||||
{
|
||||
title: 'Liberapay receiving',
|
||||
namedParams: { entity: 'Changaco' },
|
||||
staticPreview: renderCurrencyBadge({
|
||||
label: 'receives',
|
||||
amount: '98.32',
|
||||
currency: 'EUR',
|
||||
}),
|
||||
},
|
||||
]
|
||||
}
|
||||
static examples = [
|
||||
{
|
||||
title: 'Liberapay receiving',
|
||||
namedParams: { entity: 'Changaco' },
|
||||
staticPreview: renderCurrencyBadge({
|
||||
label: 'receives',
|
||||
amount: '98.32',
|
||||
currency: 'EUR',
|
||||
}),
|
||||
},
|
||||
]
|
||||
|
||||
async handle({ entity }) {
|
||||
const data = await this.fetch({ entity })
|
||||
|
||||
@@ -19,75 +19,69 @@ const schema = Joi.object({
|
||||
}).required()
|
||||
|
||||
class LibrariesIoProjectDependencies extends BaseJsonService {
|
||||
static get category() {
|
||||
return 'dependencies'
|
||||
static category = 'dependencies'
|
||||
|
||||
static route = {
|
||||
base: 'librariesio/release',
|
||||
pattern: ':platform/:scope(@[^/]+)?/:packageName/:version?',
|
||||
}
|
||||
|
||||
static get route() {
|
||||
return {
|
||||
base: 'librariesio/release',
|
||||
pattern: ':platform/:scope(@[^/]+)?/:packageName/:version?',
|
||||
}
|
||||
}
|
||||
|
||||
static get examples() {
|
||||
return [
|
||||
{
|
||||
title: 'Libraries.io dependency status for latest release',
|
||||
pattern: ':platform/:packageName',
|
||||
namedParams: {
|
||||
platform: 'hex',
|
||||
packageName: 'phoenix',
|
||||
},
|
||||
staticPreview: renderDependenciesBadge({
|
||||
deprecatedCount: 0,
|
||||
outdatedCount: 1,
|
||||
}),
|
||||
static examples = [
|
||||
{
|
||||
title: 'Libraries.io dependency status for latest release',
|
||||
pattern: ':platform/:packageName',
|
||||
namedParams: {
|
||||
platform: 'hex',
|
||||
packageName: 'phoenix',
|
||||
},
|
||||
{
|
||||
title: 'Libraries.io dependency status for specific release',
|
||||
pattern: ':platform/:packageName/:version',
|
||||
namedParams: {
|
||||
platform: 'hex',
|
||||
packageName: 'phoenix',
|
||||
version: '1.0.3',
|
||||
},
|
||||
staticPreview: renderDependenciesBadge({
|
||||
deprecatedCount: 0,
|
||||
outdatedCount: 3,
|
||||
}),
|
||||
staticPreview: renderDependenciesBadge({
|
||||
deprecatedCount: 0,
|
||||
outdatedCount: 1,
|
||||
}),
|
||||
},
|
||||
{
|
||||
title: 'Libraries.io dependency status for specific release',
|
||||
pattern: ':platform/:packageName/:version',
|
||||
namedParams: {
|
||||
platform: 'hex',
|
||||
packageName: 'phoenix',
|
||||
version: '1.0.3',
|
||||
},
|
||||
{
|
||||
title:
|
||||
'Libraries.io dependency status for latest release, scoped npm package',
|
||||
pattern: ':platform/:scope/:packageName',
|
||||
namedParams: {
|
||||
platform: 'npm',
|
||||
scope: '@babel',
|
||||
packageName: 'core',
|
||||
},
|
||||
staticPreview: renderDependenciesBadge({
|
||||
deprecatedCount: 8,
|
||||
outdatedCount: 0,
|
||||
}),
|
||||
staticPreview: renderDependenciesBadge({
|
||||
deprecatedCount: 0,
|
||||
outdatedCount: 3,
|
||||
}),
|
||||
},
|
||||
{
|
||||
title:
|
||||
'Libraries.io dependency status for latest release, scoped npm package',
|
||||
pattern: ':platform/:scope/:packageName',
|
||||
namedParams: {
|
||||
platform: 'npm',
|
||||
scope: '@babel',
|
||||
packageName: 'core',
|
||||
},
|
||||
{
|
||||
title:
|
||||
'Libraries.io dependency status for specific release, scoped npm package',
|
||||
pattern: ':platform/:scope/:packageName/:version',
|
||||
namedParams: {
|
||||
platform: 'npm',
|
||||
scope: '@babel',
|
||||
packageName: 'core',
|
||||
version: '7.0.0',
|
||||
},
|
||||
staticPreview: renderDependenciesBadge({
|
||||
deprecatedCount: 12,
|
||||
outdatedCount: 0,
|
||||
}),
|
||||
staticPreview: renderDependenciesBadge({
|
||||
deprecatedCount: 8,
|
||||
outdatedCount: 0,
|
||||
}),
|
||||
},
|
||||
{
|
||||
title:
|
||||
'Libraries.io dependency status for specific release, scoped npm package',
|
||||
pattern: ':platform/:scope/:packageName/:version',
|
||||
namedParams: {
|
||||
platform: 'npm',
|
||||
scope: '@babel',
|
||||
packageName: 'core',
|
||||
version: '7.0.0',
|
||||
},
|
||||
]
|
||||
}
|
||||
staticPreview: renderDependenciesBadge({
|
||||
deprecatedCount: 12,
|
||||
outdatedCount: 0,
|
||||
}),
|
||||
},
|
||||
]
|
||||
|
||||
async handle({ platform, scope, packageName, version = 'latest' }) {
|
||||
const url = `https://libraries.io/api/${encodeURIComponent(platform)}/${
|
||||
@@ -106,29 +100,23 @@ class LibrariesIoProjectDependencies extends BaseJsonService {
|
||||
}
|
||||
|
||||
class LibrariesIoRepoDependencies extends BaseJsonService {
|
||||
static get category() {
|
||||
return 'dependencies'
|
||||
static category = 'dependencies'
|
||||
|
||||
static route = {
|
||||
base: 'librariesio/github',
|
||||
pattern: ':user/:repo',
|
||||
}
|
||||
|
||||
static get route() {
|
||||
return {
|
||||
base: 'librariesio/github',
|
||||
pattern: ':user/:repo',
|
||||
}
|
||||
}
|
||||
|
||||
static get examples() {
|
||||
return [
|
||||
{
|
||||
title: 'Libraries.io dependency status for GitHub repo',
|
||||
namedParams: {
|
||||
user: 'phoenixframework',
|
||||
repo: 'phoenix',
|
||||
},
|
||||
staticPreview: renderDependenciesBadge({ outdatedCount: 325 }),
|
||||
static examples = [
|
||||
{
|
||||
title: 'Libraries.io dependency status for GitHub repo',
|
||||
namedParams: {
|
||||
user: 'phoenixframework',
|
||||
repo: 'phoenix',
|
||||
},
|
||||
]
|
||||
}
|
||||
staticPreview: renderDependenciesBadge({ outdatedCount: 325 }),
|
||||
},
|
||||
]
|
||||
|
||||
async handle({ user, repo }) {
|
||||
const url = `https://libraries.io/api/github/${encodeURIComponent(
|
||||
|
||||
@@ -6,45 +6,37 @@ const { fetchProject } = require('./librariesio-common')
|
||||
|
||||
// https://libraries.io/api#project-dependent-repositories
|
||||
module.exports = class LibrariesIoDependentRepos extends BaseJsonService {
|
||||
static get category() {
|
||||
return 'other'
|
||||
static category = 'other'
|
||||
|
||||
static route = {
|
||||
base: 'librariesio/dependent-repos',
|
||||
pattern: ':platform/:scope(@[^/]+)?/:packageName',
|
||||
}
|
||||
|
||||
static get route() {
|
||||
return {
|
||||
base: 'librariesio/dependent-repos',
|
||||
pattern: ':platform/:scope(@[^/]+)?/:packageName',
|
||||
}
|
||||
}
|
||||
|
||||
static get examples() {
|
||||
return [
|
||||
{
|
||||
title: 'Dependent repos (via libraries.io)',
|
||||
pattern: ':platform/:packageName',
|
||||
namedParams: {
|
||||
platform: 'npm',
|
||||
packageName: 'got',
|
||||
},
|
||||
staticPreview: this.render({ dependentReposCount: 84000 }),
|
||||
static examples = [
|
||||
{
|
||||
title: 'Dependent repos (via libraries.io)',
|
||||
pattern: ':platform/:packageName',
|
||||
namedParams: {
|
||||
platform: 'npm',
|
||||
packageName: 'got',
|
||||
},
|
||||
{
|
||||
title: 'Dependent repos (via libraries.io), scoped npm package',
|
||||
pattern: ':platform/:scope/:packageName',
|
||||
namedParams: {
|
||||
platform: 'npm',
|
||||
scope: '@babel',
|
||||
packageName: 'core',
|
||||
},
|
||||
staticPreview: this.render({ dependentReposCount: 50 }),
|
||||
staticPreview: this.render({ dependentReposCount: 84000 }),
|
||||
},
|
||||
{
|
||||
title: 'Dependent repos (via libraries.io), scoped npm package',
|
||||
pattern: ':platform/:scope/:packageName',
|
||||
namedParams: {
|
||||
platform: 'npm',
|
||||
scope: '@babel',
|
||||
packageName: 'core',
|
||||
},
|
||||
]
|
||||
}
|
||||
staticPreview: this.render({ dependentReposCount: 50 }),
|
||||
},
|
||||
]
|
||||
|
||||
static get defaultBadgeData() {
|
||||
return {
|
||||
label: 'dependent repos',
|
||||
}
|
||||
static defaultBadgeData = {
|
||||
label: 'dependent repos',
|
||||
}
|
||||
|
||||
static render({ dependentReposCount }) {
|
||||
|
||||
@@ -6,45 +6,37 @@ const { fetchProject } = require('./librariesio-common')
|
||||
|
||||
// https://libraries.io/api#project-dependents
|
||||
module.exports = class LibrariesIoDependents extends BaseJsonService {
|
||||
static get category() {
|
||||
return 'other'
|
||||
static category = 'other'
|
||||
|
||||
static route = {
|
||||
base: 'librariesio/dependents',
|
||||
pattern: ':platform/:scope(@[^/]+)?/:packageName',
|
||||
}
|
||||
|
||||
static get route() {
|
||||
return {
|
||||
base: 'librariesio/dependents',
|
||||
pattern: ':platform/:scope(@[^/]+)?/:packageName',
|
||||
}
|
||||
}
|
||||
|
||||
static get examples() {
|
||||
return [
|
||||
{
|
||||
title: 'Dependents (via libraries.io)',
|
||||
pattern: ':platform/:packageName',
|
||||
namedParams: {
|
||||
platform: 'npm',
|
||||
packageName: 'got',
|
||||
},
|
||||
staticPreview: this.render({ dependentCount: 2000 }),
|
||||
static examples = [
|
||||
{
|
||||
title: 'Dependents (via libraries.io)',
|
||||
pattern: ':platform/:packageName',
|
||||
namedParams: {
|
||||
platform: 'npm',
|
||||
packageName: 'got',
|
||||
},
|
||||
{
|
||||
title: 'Dependents (via libraries.io), scoped npm package',
|
||||
pattern: ':platform/:scope/:packageName',
|
||||
namedParams: {
|
||||
platform: 'npm',
|
||||
scope: '@babel',
|
||||
packageName: 'core',
|
||||
},
|
||||
staticPreview: this.render({ dependentCount: 94 }),
|
||||
staticPreview: this.render({ dependentCount: 2000 }),
|
||||
},
|
||||
{
|
||||
title: 'Dependents (via libraries.io), scoped npm package',
|
||||
pattern: ':platform/:scope/:packageName',
|
||||
namedParams: {
|
||||
platform: 'npm',
|
||||
scope: '@babel',
|
||||
packageName: 'core',
|
||||
},
|
||||
]
|
||||
}
|
||||
staticPreview: this.render({ dependentCount: 94 }),
|
||||
},
|
||||
]
|
||||
|
||||
static get defaultBadgeData() {
|
||||
return {
|
||||
label: 'dependents',
|
||||
}
|
||||
static defaultBadgeData = {
|
||||
label: 'dependents',
|
||||
}
|
||||
|
||||
static render({ dependentCount }) {
|
||||
|
||||
@@ -7,45 +7,37 @@ const { fetchProject } = require('./librariesio-common')
|
||||
const sourceRankColor = colorScale([10, 15, 20, 25, 30])
|
||||
|
||||
module.exports = class LibrariesIoSourcerank extends BaseJsonService {
|
||||
static get category() {
|
||||
return 'rating'
|
||||
static category = 'rating'
|
||||
|
||||
static route = {
|
||||
base: 'librariesio/sourcerank',
|
||||
pattern: ':platform/:scope(@[^/]+)?/:packageName',
|
||||
}
|
||||
|
||||
static get route() {
|
||||
return {
|
||||
base: 'librariesio/sourcerank',
|
||||
pattern: ':platform/:scope(@[^/]+)?/:packageName',
|
||||
}
|
||||
}
|
||||
|
||||
static get examples() {
|
||||
return [
|
||||
{
|
||||
title: 'Libraries.io SourceRank',
|
||||
pattern: ':platform/:packageName',
|
||||
namedParams: {
|
||||
platform: 'npm',
|
||||
packageName: 'got',
|
||||
},
|
||||
staticPreview: this.render({ rank: 25 }),
|
||||
static examples = [
|
||||
{
|
||||
title: 'Libraries.io SourceRank',
|
||||
pattern: ':platform/:packageName',
|
||||
namedParams: {
|
||||
platform: 'npm',
|
||||
packageName: 'got',
|
||||
},
|
||||
{
|
||||
title: 'Libraries.io SourceRank, scoped npm package',
|
||||
pattern: ':platform/:scope/:packageName',
|
||||
namedParams: {
|
||||
platform: 'npm',
|
||||
scope: '@babel',
|
||||
packageName: 'core',
|
||||
},
|
||||
staticPreview: this.render({ rank: 3 }),
|
||||
staticPreview: this.render({ rank: 25 }),
|
||||
},
|
||||
{
|
||||
title: 'Libraries.io SourceRank, scoped npm package',
|
||||
pattern: ':platform/:scope/:packageName',
|
||||
namedParams: {
|
||||
platform: 'npm',
|
||||
scope: '@babel',
|
||||
packageName: 'core',
|
||||
},
|
||||
]
|
||||
}
|
||||
staticPreview: this.render({ rank: 3 }),
|
||||
},
|
||||
]
|
||||
|
||||
static get defaultBadgeData() {
|
||||
return {
|
||||
label: 'sourcerank',
|
||||
}
|
||||
static defaultBadgeData = {
|
||||
label: 'sourcerank',
|
||||
}
|
||||
|
||||
static render({ rank }) {
|
||||
|
||||
@@ -15,34 +15,26 @@ const schema = Joi.object({
|
||||
}).required()
|
||||
|
||||
module.exports = class Luarocks extends BaseJsonService {
|
||||
static get category() {
|
||||
return 'version'
|
||||
static category = 'version'
|
||||
|
||||
static route = {
|
||||
base: 'luarocks/v',
|
||||
pattern: ':user/:moduleName/:version?',
|
||||
}
|
||||
|
||||
static get route() {
|
||||
return {
|
||||
base: 'luarocks/v',
|
||||
pattern: ':user/:moduleName/:version?',
|
||||
}
|
||||
}
|
||||
|
||||
static get examples() {
|
||||
return [
|
||||
{
|
||||
title: 'LuaRocks',
|
||||
namedParams: {
|
||||
user: 'mpeterv',
|
||||
moduleName: 'luacheck',
|
||||
},
|
||||
staticPreview: this.render({ version: '0.23.0-1' }),
|
||||
static examples = [
|
||||
{
|
||||
title: 'LuaRocks',
|
||||
namedParams: {
|
||||
user: 'mpeterv',
|
||||
moduleName: 'luacheck',
|
||||
},
|
||||
]
|
||||
}
|
||||
staticPreview: this.render({ version: '0.23.0-1' }),
|
||||
},
|
||||
]
|
||||
|
||||
static get defaultBadgeData() {
|
||||
return {
|
||||
label: 'luarocks',
|
||||
}
|
||||
static defaultBadgeData = {
|
||||
label: 'luarocks',
|
||||
}
|
||||
|
||||
static render({ version }) {
|
||||
|
||||
Reference in New Issue
Block a user