Move github examples into services/github (#2309)

This commit is contained in:
Paul Melnikow
2018-11-15 15:57:56 -05:00
committed by GitHub
parent 5d63effabc
commit fe05d00747
22 changed files with 667 additions and 319 deletions

View File

@@ -7,10 +7,32 @@ const {
} = require('../../lib/badge-data')
const { metric } = require('../../lib/text-formatters')
const {
documentation,
checkErrorResponse: githubCheckErrorResponse,
} = require('./github-helpers')
module.exports = class GithubCommitActivity extends LegacyService {
static get category() {
return 'version'
}
static get route() {
return {
base: 'github/commit-activity',
}
}
static get examples() {
return [
{
title: 'GitHub commit activity the past week, 4 weeks, year',
previewUrl: 'y/eslint/eslint',
keywords: ['GitHub', 'commit', 'commits', 'activity'],
documentation,
},
]
}
static registerLegacyRouteHandler({ camp, cache, githubApiProvider }) {
camp.route(
/^\/github\/commit-activity\/(y|4w|w)\/([^/]+)\/([^/]+)\.(svg|png|gif|jpg|json)$/,

View File

@@ -3,10 +3,33 @@
const LegacyService = require('../legacy-service')
const { makeBadgeData: getBadgeData } = require('../../lib/badge-data')
const {
documentation,
checkErrorResponse: githubCheckErrorResponse,
} = require('./github-helpers')
module.exports = class GithubCommitStatus extends LegacyService {
static get category() {
return 'other'
}
static get route() {
return {
base: 'github/commit-status',
}
}
static get examples() {
return [
{
title: 'GitHub commit merge status',
previewUrl:
'badges/shields/master/5d4ab86b1b5ddfb3c4a70a70bd19932c52603b8c',
keywords: ['GitHub', 'commit', 'branch', 'merge'],
documentation,
},
]
}
static registerLegacyRouteHandler({ camp, cache, githubApiProvider }) {
camp.route(
/^\/github\/commit-status\/([^/]+)\/([^/]+)\/([^/]+)\/([^/]+)\.(svg|png|gif|jpg|json)$/,

View File

@@ -6,8 +6,36 @@ const {
makeLabel: getLabel,
makeLogo: getLogo,
} = require('../../lib/badge-data')
const { documentation } = require('./github-helpers')
module.exports = class GithubCommitsSince extends LegacyService {
static get category() {
return 'version'
}
static get route() {
return {
base: 'github/commits-since',
}
}
static get examples() {
return [
{
title: 'GitHub commits',
previewUrl: 'SubtitleEdit/subtitleedit/3.4.7',
keywords: ['GitHub', 'commit'],
documentation,
},
{
title: 'GitHub commits (since latest release)',
previewUrl: 'SubtitleEdit/subtitleedit/latest',
keywords: ['GitHub', 'commit'],
documentation,
},
]
}
static registerLegacyRouteHandler({ camp, cache, githubApiProvider }) {
camp.route(
/^\/github\/commits-since\/([^/]+)\/([^/]+)\/([^/]+)\.(svg|png|gif|jpg|json)$/,

View File

@@ -7,10 +7,32 @@ const {
} = require('../../lib/badge-data')
const { metric } = require('../../lib/text-formatters')
const {
documentation,
checkErrorResponse: githubCheckErrorResponse,
} = require('./github-helpers')
module.exports = class GithubContributors extends LegacyService {
static get category() {
return 'other'
}
static get route() {
return {
base: 'github',
}
}
static get examples() {
return [
{
title: 'GitHub contributors',
previewUrl: 'contributors/cdnjs/cdnjs',
keywords: ['GitHub', 'contributor'],
documentation,
},
]
}
static registerLegacyRouteHandler({ camp, cache, githubApiProvider }) {
camp.route(
/^\/github\/contributors(-anon)?\/([^/]+)\/([^/]+)\.(svg|png|gif|jpg|json)$/,

View File

@@ -7,10 +7,62 @@ const {
} = require('../../lib/badge-data')
const { metric } = require('../../lib/text-formatters')
const {
documentation,
checkErrorResponse: githubCheckErrorResponse,
} = require('./github-helpers')
module.exports = class GithubDownloads extends LegacyService {
static get category() {
return 'downloads'
}
static get route() {
return {
base: 'github',
}
}
static get examples() {
return [
{
title: 'GitHub All Releases',
previewUrl: 'downloads/atom/atom/total',
keywords: ['github'],
documentation,
},
{
title: 'GitHub Releases',
previewUrl: 'downloads/atom/atom/latest/total',
keywords: ['github'],
documentation,
},
{
title: 'GitHub Pre-Releases',
previewUrl: 'downloads-pre/atom/atom/latest/total',
keywords: ['github'],
documentation,
},
{
title: 'GitHub Releases (by Release)',
previewUrl: 'downloads/atom/atom/v0.190.0/total',
keywords: ['github'],
documentation,
},
{
title: 'GitHub Releases (by Asset)',
previewUrl: 'downloads/atom/atom/latest/atom-amd64.deb',
keywords: ['github'],
documentation,
},
{
title: 'GitHub Pre-Releases (by Asset)',
previewUrl: 'downloads-pre/atom/atom/latest/atom-amd64.deb',
keywords: ['github'],
documentation,
},
]
}
static registerLegacyRouteHandler({ camp, cache, githubApiProvider }) {
camp.route(
/^\/github\/(downloads|downloads-pre)\/([^/]+)\/([^/]+)(\/.+)?\/([^/]+)\.(svg|png|gif|jpg|json)$/,

View File

@@ -6,10 +6,32 @@ const {
makeLogo: getLogo,
} = require('../../lib/badge-data')
const {
documentation,
checkErrorResponse: githubCheckErrorResponse,
} = require('./github-helpers')
module.exports = class GithubFollowers extends LegacyService {
static get category() {
return 'social'
}
static get route() {
return {
base: 'github/followers',
}
}
static get examples() {
return [
{
title: 'GitHub followers',
previewUrl: 'espadrine',
query: { style: 'social', label: 'Follow' },
documentation,
},
]
}
static registerLegacyRouteHandler({ camp, cache, githubApiProvider }) {
camp.route(
/^\/github\/followers\/([^/]+)\.(svg|png|gif|jpg|json)$/,

View File

@@ -6,10 +6,32 @@ const {
makeLogo: getLogo,
} = require('../../lib/badge-data')
const {
documentation,
checkErrorResponse: githubCheckErrorResponse,
} = require('./github-helpers')
module.exports = class GithubForks extends LegacyService {
static get category() {
return 'social'
}
static get route() {
return {
base: 'github/forks',
}
}
static get examples() {
return [
{
title: 'GitHub forks',
previewUrl: 'badges/shields',
query: { style: 'social', label: 'Fork' },
documentation,
},
]
}
static registerLegacyRouteHandler({ camp, cache, githubApiProvider }) {
camp.route(
/^\/github\/forks\/([^/]+)\/([^/]+)\.(svg|png|gif|jpg|json)$/,

View File

@@ -10,12 +10,70 @@ const {
const { formatDate } = require('../../lib/text-formatters')
const { age: ageColor } = require('../../lib/color-formatters')
const {
documentation,
stateColor: githubStateColor,
commentsColor: githubCommentsColor,
checkErrorResponse: githubCheckErrorResponse,
} = require('./github-helpers')
module.exports = class GithubIssueDetail extends LegacyService {
static get category() {
return 'issue-tracking'
}
static get route() {
return {
base: 'github/issues/detail',
}
}
static get examples() {
return [
{
title: 'GitHub issue/pull request state',
previewUrl: 's/badges/shields/979',
keywords: ['GitHub', 'issue', 'pullrequest', 'detail'],
documentation,
},
{
title: 'GitHub issue/pull request title',
previewUrl: 'title/badges/shields/1290',
keywords: ['GitHub', 'issue', 'pullrequest', 'detail'],
documentation,
},
{
title: 'GitHub issue/pull request author',
previewUrl: 'u/badges/shields/979',
keywords: ['GitHub', 'issue', 'pullrequest', 'detail'],
documentation,
},
{
title: 'GitHub issue/pull request label',
previewUrl: 'label/badges/shields/979',
keywords: ['GitHub', 'issue', 'pullrqeuest', 'detail'],
documentation,
},
{
title: 'GitHub issue/pull request comments',
previewUrl: 'comments/badges/shields/979',
keywords: ['GitHub', 'issue', 'pullrequest', 'detail'],
documentation,
},
{
title: 'GitHub issue/pull request age',
previewUrl: 'age/badges/shields/979',
keywords: ['GitHub', 'issue', 'pullrequest', 'detail'],
documentation,
},
{
title: 'GitHub issue/pull request last update',
previewUrl: 'last-update/badges/shields/979',
keywords: ['GitHub', 'issue', 'pullrequest', 'detail'],
documentation,
},
]
}
static registerLegacyRouteHandler({ camp, cache, githubApiProvider }) {
camp.route(
/^\/github\/(?:issues|pulls)\/detail\/(s|title|u|label|comments|age|last-update)\/([^/]+)\/([^/]+)\/(\d+)\.(svg|png|gif|jpg|json)$/,

View File

@@ -7,10 +7,98 @@ const {
} = require('../../lib/badge-data')
const { metric } = require('../../lib/text-formatters')
const {
documentation,
checkErrorResponse: githubCheckErrorResponse,
} = require('./github-helpers')
module.exports = class GithubIssues extends LegacyService {
static get category() {
return 'issue-tracking'
}
static get route() {
return {
base: 'github',
}
}
static get examples() {
return [
{
title: 'GitHub issues',
previewUrl: 'issues/badges/shields',
keywords: ['GitHub', 'issue'],
documentation,
},
{
title: 'GitHub issues',
previewUrl: 'issues-raw/badges/shields',
keywords: ['GitHub', 'issue'],
documentation,
},
{
title: 'GitHub pull requests',
previewUrl: 'issues-pr/cdnjs/cdnjs',
keywords: ['GitHub', 'pullrequest', 'pr'],
documentation,
},
{
title: 'GitHub pull requests',
previewUrl: 'issues-pr-raw/cdnjs/cdnjs',
keywords: ['GitHub', 'pullrequest', 'pr'],
documentation,
},
{
title: 'GitHub closed issues',
previewUrl: 'issues-closed/badges/shields',
keywords: ['GitHub', 'issue'],
documentation,
},
{
title: 'GitHub closed issues',
previewUrl: 'issues-closed-raw/badges/shields',
keywords: ['GitHub', 'issue'],
documentation,
},
{
title: 'GitHub closed pull requests',
previewUrl: 'issues-pr-closed/cdnjs/cdnjs',
keywords: ['GitHub', 'pullrequest', 'pr'],
documentation,
},
{
title: 'GitHub closed pull requests',
previewUrl: 'issues-pr-closed-raw/cdnjs/cdnjs',
keywords: ['GitHub', 'pullrequest', 'pr'],
documentation,
},
{
title: 'GitHub issues by-label',
previewUrl: 'issues/badges/shields/service-badge',
keywords: ['GitHub', 'issue', 'label'],
documentation,
},
{
title: 'GitHub issues by-label',
previewUrl: 'issues-raw/badges/shields/service-badge',
keywords: ['GitHub', 'issue', 'label'],
documentation,
},
{
title: 'GitHub pull requests by-label',
previewUrl: 'issues-pr/badges/shields/service-badge',
keywords: ['GitHub', 'pullrequests', 'label'],
documentation,
},
{
title: 'GitHub pull requests by-label',
previewUrl: 'issues-pr-raw/badges/shields/service-badge',
keywords: ['GitHub', 'pullrequests', 'label'],
documentation,
},
]
}
static registerLegacyRouteHandler({ camp, cache, githubApiProvider }) {
camp.route(
/^\/github\/issues(-pr)?(-closed)?(-raw)?\/(?!detail)([^/]+)\/([^/]+)\/?(.+)?\.(svg|png|gif|jpg|json)$/,

View File

@@ -8,10 +8,63 @@ const {
makeLabel: getLabel,
} = require('../../lib/badge-data')
const {
documentation,
checkErrorResponse: githubCheckErrorResponse,
} = require('./github-helpers')
module.exports = class GithubLanguages extends LegacyService {
class GithubCodeSize extends LegacyService {
static get category() {
return 'size'
}
static get route() {
return {
base: 'github/languages/code-size',
}
}
static get examples() {
return [
{
title: 'GitHub code size in bytes',
previewUrl: 'badges/shields',
keywords: ['GitHub', 'byte', 'code', 'size'],
documentation,
},
]
}
static registerLegacyRouteHandler() {}
}
class GithubLanguages extends LegacyService {
static get category() {
return 'other'
}
static get route() {
return {
base: 'github/languages',
}
}
static get examples() {
return [
{
title: 'GitHub top language',
previewUrl: 'top/badges/shields',
keywords: ['GitHub', 'top', 'language'],
documentation,
},
{
title: 'GitHub language count',
previewUrl: 'count/badges/shields',
keywords: ['GitHub', 'language', 'count'],
documentation,
},
]
}
static registerLegacyRouteHandler({ camp, cache, githubApiProvider }) {
camp.route(
/^\/github\/languages\/(top|count|code-size)\/([^/]+)\/([^/]+)\.(svg|png|gif|jpg|json)$/,
@@ -83,3 +136,5 @@ module.exports = class GithubLanguages extends LegacyService {
)
}
}
module.exports = { GithubCodeSize, GithubLanguages }

View File

@@ -8,10 +8,38 @@ const {
const { formatDate } = require('../../lib/text-formatters')
const { age: ageColor } = require('../../lib/color-formatters')
const {
documentation,
checkErrorResponse: githubCheckErrorResponse,
} = require('./github-helpers')
module.exports = class GithubLastCommit extends LegacyService {
static get category() {
return 'other'
}
static get route() {
return {
base: 'github/last-commit',
}
}
static get examples() {
return [
{
title: 'GitHub last commit',
previewUrl: 'google/skia',
keywords: ['GitHub', 'last', 'latest', 'commit'],
documentation,
},
{
title: 'GitHub last commit (branch)',
previewUrl: 'google/skia/infra/config',
keywords: ['GitHub', 'last', 'latest', 'commit'],
documentation,
},
]
}
static registerLegacyRouteHandler({ camp, cache, githubApiProvider }) {
camp.route(
/^\/github\/last-commit\/([^/]+)\/([^/]+)(?:\/(.+))?\.(svg|png|gif|jpg|json)$/,

View File

@@ -8,12 +8,33 @@ const {
} = require('../../lib/badge-data')
const { licenseToColor } = require('../../lib/licenses')
const {
documentation,
checkErrorResponse: githubCheckErrorResponse,
} = require('./github-helpers')
module.exports = class GithubLicense extends LegacyService {
static get category() {
return 'license'
}
static get route() {
return {
base: 'github/license',
}
}
static get examples() {
return [
{
title: 'GitHub',
previewUrl: 'mashape/apistatus',
keywords: ['GitHub', 'license'],
documentation,
},
]
}
static registerLegacyRouteHandler({ camp, cache, githubApiProvider }) {
// GitHub license integration.
camp.route(
/^\/github\/license\/([^/]+)\/([^/]+)\.(svg|png|gif|jpg|json)$/,
cache((data, match, sendBadge, request) => {

View File

@@ -8,11 +8,36 @@ const {
const { addv: versionText } = require('../../lib/text-formatters')
const { version: versionColor } = require('../../lib/color-formatters')
const {
documentation,
checkErrorResponse: githubCheckErrorResponse,
} = require('./github-helpers')
// For GitHub package and manifest version.
module.exports = class GithubManifestVersion extends LegacyService {
static get category() {
return 'version'
}
static get route() {
return {
base: 'github',
}
}
static get examples() {
return [
{
title: 'GitHub package version',
previewUrl: 'package-json/v/badges/shields',
documentation,
},
{
title: 'GitHub manifest version',
previewUrl: 'manifest-json/v/RedSparr0w/IndieGala-Helper',
documentation,
},
]
}
static registerLegacyRouteHandler({ camp, cache }) {
camp.route(
/^\/github\/(package|manifest)-json\/([^/]+)\/([^/]+)\/([^/]+)\/?([^/]+)?\.(svg|png|gif|jpg|json)$/,

View File

@@ -8,9 +8,36 @@ const {
} = require('../../lib/badge-data')
const { formatDate } = require('../../lib/text-formatters')
const { age } = require('../../lib/color-formatters')
const { documentation } = require('./github-helpers')
// For Github Release & Pre-Release Date release-date-pre (?:\/(all))?
module.exports = class GithubReleaseDate extends LegacyService {
static get category() {
return 'other'
}
static get route() {
return {
base: 'github',
}
}
static get examples() {
return [
{
title: 'GitHub Release Date',
previewUrl: 'release-date/SubtitleEdit/subtitleedit',
keywords: ['GitHub', 'release', 'date'],
documentation,
},
{
title: 'GitHub (Pre-)Release Date',
previewUrl: 'release-date-pre/Cockatrice/Cockatrice',
keywords: ['GitHub', 'release', 'date'],
documentation,
},
]
}
static registerLegacyRouteHandler({ camp, cache, githubApiProvider }) {
camp.route(
/^\/github\/(release-date|release-date-pre)\/([^/]+)\/([^/]+)\.(svg|png|gif|jpg|json)$/,

View File

@@ -7,10 +7,36 @@ const {
} = require('../../lib/badge-data')
const { addv: versionText } = require('../../lib/text-formatters')
const {
documentation,
checkErrorResponse: githubCheckErrorResponse,
} = require('./github-helpers')
module.exports = class GithubRelease extends LegacyService {
static get category() {
return 'version'
}
static get route() {
return {
base: 'github',
}
}
static get examples() {
return [
{
title: 'GitHub release',
previewUrl: 'release/qubyte/rubidium',
documentation,
},
{
title: 'GitHub (pre-)release',
previewUrl: 'release-pre/qubyte/rubidium',
documentation,
},
]
}
static registerLegacyRouteHandler({ camp, cache, githubApiProvider }) {
camp.route(
/^\/github\/release(-pre)?\/([^/]+\/[^/]+)(?:\/(all))?\.(svg|png|gif|jpg|json)$/,

View File

@@ -7,10 +7,32 @@ const {
makeLogo: getLogo,
} = require('../../lib/badge-data')
const {
documentation,
checkErrorResponse: githubCheckErrorResponse,
} = require('./github-helpers')
module.exports = class GithubRepoSize extends LegacyService {
static get category() {
return 'size'
}
static get route() {
return {
base: 'github/repo-size',
}
}
static get examples() {
return [
{
title: 'GitHub repo size in bytes',
previewUrl: 'badges/shields',
keywords: ['GitHub', 'repo', 'size'],
documentation,
},
]
}
static registerLegacyRouteHandler({ camp, cache, githubApiProvider }) {
camp.route(
/^\/github\/repo-size\/([^/]+)\/([^/]+)\.(svg|png|gif|jpg|json)$/,

View File

@@ -4,12 +4,33 @@ const LegacyService = require('../legacy-service')
const { makeBadgeData: getBadgeData } = require('../../lib/badge-data')
const { metric } = require('../../lib/text-formatters')
const {
documentation,
checkErrorResponse: githubCheckErrorResponse,
} = require('./github-helpers')
module.exports = class GithubSearch extends LegacyService {
static get category() {
return 'other'
}
static get route() {
return {
base: 'github/search',
}
}
static get examples() {
return [
{
title: 'GitHub search hit counter',
previewUrl: 'torvalds/linux/goto',
keywords: ['GitHub', 'search', 'hit', 'counter'],
documentation,
},
]
}
static registerLegacyRouteHandler({ camp, cache, githubApiProvider }) {
// GitHub search hit counter.
camp.route(
/^\/github\/search\/([^/]+)\/([^/]+)\/(.*)\.(svg|png|gif|jpg|json)$/,
cache((data, match, sendBadge, request) => {

View File

@@ -7,10 +7,32 @@ const {
makeLogo: getLogo,
} = require('../../lib/badge-data')
const {
documentation,
checkErrorResponse: githubCheckErrorResponse,
} = require('./github-helpers')
module.exports = class GithubSize extends LegacyService {
static get category() {
return 'size'
}
static get route() {
return {
base: 'github/size',
}
}
static get examples() {
return [
{
title: 'GitHub repo size in bytes',
previewUrl: 'webcaetano/craft/build/phaser-craft.min.js',
keywords: ['GitHub', 'file', 'size'],
documentation,
},
]
}
static registerLegacyRouteHandler({ camp, cache, githubApiProvider }) {
camp.route(
/^\/github\/size\/([^/]+)\/([^/]+)\/(.*)\.(svg|png|gif|jpg|json)$/,

View File

@@ -7,10 +7,32 @@ const {
} = require('../../lib/badge-data')
const { metric } = require('../../lib/text-formatters')
const {
documentation,
checkErrorResponse: githubCheckErrorResponse,
} = require('./github-helpers')
module.exports = class GithubStars extends LegacyService {
static get category() {
return 'social'
}
static get route() {
return {
base: 'github/stars',
}
}
static get examples() {
return [
{
title: 'GitHub stars',
previewUrl: 'badges/shields',
query: { style: 'social', label: 'Stars' },
documentation,
},
]
}
static registerLegacyRouteHandler({ camp, cache, githubApiProvider }) {
camp.route(
/^\/github\/stars\/([^/]+)\/([^/]+)\.(svg|png|gif|jpg|json)$/,

View File

@@ -9,10 +9,41 @@ const { addv: versionText } = require('../../lib/text-formatters')
const { version: versionColor } = require('../../lib/color-formatters')
const { latest: latestVersion } = require('../../lib/version')
const {
documentation,
checkErrorResponse: githubCheckErrorResponse,
} = require('./github-helpers')
module.exports = class GithubTag extends LegacyService {
static get category() {
return 'version'
}
static get route() {
return {
base: 'github',
}
}
static get examples() {
return [
{
title: 'GitHub tag (latest SemVer)',
previewUrl: 'tag/expressjs/express',
documentation,
},
{
title: 'GitHub tag (latest SemVer pre-release)',
previewUrl: 'tag-pre/expressjs/express',
documentation,
},
{
title: 'GitHub tag (latest by date)',
previewUrl: 'tag-date/expressjs/express',
documentation,
},
]
}
static registerLegacyRouteHandler({ camp, cache, githubApiProvider }) {
camp.route(
/^\/github\/(tag-pre|tag-date|tag)\/([^/]+)\/([^/]+)\.(svg|png|gif|jpg|json)$/,

View File

@@ -6,10 +6,32 @@ const {
makeLogo: getLogo,
} = require('../../lib/badge-data')
const {
documentation,
checkErrorResponse: githubCheckErrorResponse,
} = require('./github-helpers')
module.exports = class GithubWatchers extends LegacyService {
static get category() {
return 'social'
}
static get route() {
return {
base: 'github/watchers',
}
}
static get examples() {
return [
{
title: 'GitHub watchers',
previewUrl: 'badges/shields',
query: { style: 'social', label: 'Watch' },
documentation,
},
]
}
static registerLegacyRouteHandler({ camp, cache, githubApiProvider }) {
camp.route(
/^\/github\/watchers\/([^/]+)\/([^/]+)\.(svg|png|gif|jpg|json)$/,