Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add static examples to a few legacy services [travis david coveralls amo] #2407

Merged
merged 2 commits into from
Dec 1, 2018
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
52 changes: 42 additions & 10 deletions services/amo/amo.service.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ const {
floorCount: floorCountColor,
} = require('../../lib/color-formatters')

const keywords = ['amo', 'firefox']

class AmoDownloads extends LegacyService {
static get category() {
return 'downloads'
Expand All @@ -25,15 +27,17 @@ class AmoDownloads extends LegacyService {
static get route() {
return {
base: 'amo/d',
pattern: ':addonId',
}
}

static get examples() {
return [
{
title: 'Mozilla Add-on',
previewUrl: 'dustman',
keywords: ['amo', 'firefox'],
namedParams: { addonId: 'dustman' },
staticExample: { message: '12k', color: 'brightgreen' },
keywords,
},
]
}
Expand All @@ -49,19 +53,27 @@ class AmoVersion extends LegacyService {
static get route() {
return {
base: 'amo/v',
pattern: ':addonId',
}
}

static get examples() {
return [
{
title: 'Mozilla Add-on',
previewUrl: 'dustman',
keywords: ['amo', 'firefox'],
namedParams: { addonId: 'dustman' },
staticExample: { message: 'v2.1.0', color: 'blue' },
keywords,
},
]
}

static get defaultBadgeData() {
return {
label: 'mozilla add-on',
}
}

static registerLegacyRouteHandler() {}
}

Expand All @@ -80,13 +92,25 @@ class AmoRating extends LegacyService {
return [
{
title: 'Mozilla Add-on',
previewUrl: 'rating/dustman',
keywords: ['amo', 'firefox'],
pattern: 'rating/:addonId',
namedParams: { addonId: 'dustman' },
staticExample: {
label: 'rating',
message: '4/5',
color: 'brightgreen',
},
keywords,
},
{
title: 'Mozilla Add-on',
previewUrl: 'stars/dustman',
keywords: ['amo', 'firefox'],
pattern: 'stars/:addonId',
namedParams: { addonId: 'dustman' },
staticExample: {
label: 'rating',
message: starRating(4),
color: 'brightgreen',
},
keywords,
},
]
}
Expand All @@ -102,19 +126,27 @@ class AmoUsers extends LegacyService {
static get route() {
return {
base: 'amo/users',
pattern: ':addonId',
}
}

static get examples() {
return [
{
title: 'Mozilla Add-on',
previewUrl: 'dustman',
keywords: ['amo', 'firefox'],
namedParams: { addonId: 'dustman' },
staticExample: { message: '706', color: 'brightgreen' },
keywords,
},
]
}

static get defaultBadgeData() {
return {
label: 'users',
}
}

static registerLegacyRouteHandler() {}
}

Expand Down
37 changes: 33 additions & 4 deletions services/coveralls/coveralls.service.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,26 +18,55 @@ module.exports = class Coveralls extends LegacyService {
}

static get examples() {
const { staticExample } = this
return [
{
title: 'Coveralls github',
previewUrl: 'github/jekyll/jekyll',
pattern: ':vcsType/:user/:repo',
namedParams: { vcsType: 'github', user: 'jekyll', repo: 'jekyll' },
staticExample,
},
{
title: 'Coveralls github branch',
previewUrl: 'github/jekyll/jekyll/master',
pattern: ':vcsType/:user/:repo/:branch',
namedParams: {
vcsType: 'github',
user: 'jekyll',
repo: 'jekyll',
branch: 'master',
},
staticExample,
},
{
title: 'Coveralls bitbucket',
previewUrl: 'bitbucket/pyKLIP/pyklip',
pattern: ':vcsType/:user/:repo',
namedParams: { vcsType: 'bitbucket', user: 'pyKLIP', repo: 'pyklip' },
staticExample,
},
{
title: 'Coveralls bitbucket branch',
previewUrl: 'bitbucket/pyKLIP/pyklip/master',
pattern: ':vcsType/:user/:repo/:branch',
namedParams: {
vcsType: 'bitbucket',
user: 'pyKLIP',
repo: 'pyklip',
branch: 'master',
},
staticExample,
},
]
}

static get staticExample() {
return { message: '83%', color: 'yellowgreen' }
}

static get defaultBadgeData() {
return {
label: 'coverage',
}
}

static registerLegacyRouteHandler({ camp, cache }) {
camp.route(
/^\/coveralls\/(?:(bitbucket|github)\/)?([^/]+\/[^/]+)(?:\/(.+))?\.(svg|png|gif|jpg|json)$/,
Expand Down
32 changes: 27 additions & 5 deletions services/david/david.service.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,28 +18,50 @@ module.exports = class David extends LegacyService {
return [
{
title: 'David',
previewUrl: 'expressjs/express',
pattern: ':user/:repo',
namedParams: { user: 'expressjs', repo: 'express' },
staticExample: this.renderStaticExample(),
},
{
title: 'David',
previewUrl: 'dev/expressjs/express',
pattern: 'dev/:user/:repo',
namedParams: { user: 'expressjs', repo: 'express' },
staticExample: this.renderStaticExample({ label: 'dev dependencies' }),
},
{
title: 'David',
previewUrl: 'optional/elnounch/byebye',
pattern: 'optional/:user/:repo',
namedParams: { user: 'elnounch', repo: 'byebye' },
staticExample: this.renderStaticExample({
label: 'optional dependencies',
}),
},
{
title: 'David',
previewUrl: 'peer/webcomponents/generator-element',
pattern: 'peer/:user/:repo',
namedParams: { user: 'webcomponents', repo: 'generator-element' },
staticExample: this.renderStaticExample({ label: 'peer dependencies' }),
},
{
title: 'David (path)',
previewUrl: 'babel/babel',
pattern: ':user/:repo',
namedParams: { user: 'babel', repo: 'babel' },
query: { path: 'packages/babel-core' },
staticExample: this.renderStaticExample(),
},
]
}

static get defaultBadgeData() {
return {
label: 'dependencies',
}
}

static renderStaticExample({ label } = {}) {
return { label, message: 'up to date', color: 'brightgreen' }
}

static registerLegacyRouteHandler({ camp, cache }) {
camp.route(
/^\/david\/(dev\/|optional\/|peer\/)?(.+?)\.(svg|png|gif|jpg|json)$/,
Expand Down
25 changes: 17 additions & 8 deletions services/travis/travis-build.service.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,34 +18,43 @@ module.exports = class TravisBuild extends LegacyService {
}

static get examples() {
const { staticExample } = this
return [
{
title: 'Travis (.org)',
previewUrl: 'rust-lang/rust',
pattern: ':user/:repo',
exampleUrl: 'rust-lang/rust',
namedParams: { user: 'rust-lang', repo: 'rust' },
staticExample,
},
{
title: 'Travis (.org) branch',
previewUrl: 'rust-lang/rust/master',
pattern: ':user/:repo/:branch',
exampleUrl: 'rust-lang/rust/master',
namedParams: { user: 'rust-lang', repo: 'rust', branch: 'master' },
staticExample,
},
{
title: 'Travis (.com)',
previewUrl: 'com/ivandelabeldad/rackian-gateway',
pattern: 'com/:user/:repo',
exampleUrl: 'com/ivandelabeldad/rackian-gateway',
namedParams: { user: 'ivandelabeldad', repo: 'rackian-gateway' },
staticExample,
},
{
title: 'Travis (.com) branch',
previewUrl: 'com/ivandelabeldad/rackian-gateway/master',
pattern: 'com/:user/:repo/:branch',
exampleUrl: 'com/ivandelabeldad/rackian-gateway/master',
namedParams: {
user: 'ivandelabeldad',
repo: 'rackian-gateway',
branch: 'master',
},
staticExample,
},
]
}

static staticExample() {
return { message: 'passing', color: 'brightgreen' }
}

static registerLegacyRouteHandler({ camp, cache }) {
camp.route(
/^\/travis(-ci)?\/(?:(com)\/)?(?!php-v)([^/]+\/[^/]+)(?:\/(.+))?\.(svg|png|gif|jpg|json)$/,
Expand Down