From fe05d00747df21ccf2233ee14aa43b04ad8f99c6 Mon Sep 17 00:00:00 2001 From: Paul Melnikow <github@paulmelnikow.com> Date: Thu, 15 Nov 2018 15:57:56 -0500 Subject: [PATCH] Move github examples into services/github (#2309) --- lib/all-badge-examples.js | 317 +----------------- .../github/github-commit-activity.service.js | 22 ++ .../github/github-commit-status.service.js | 23 ++ .../github/github-commits-since.service.js | 28 ++ .../github/github-contributors.service.js | 22 ++ services/github/github-downloads.service.js | 52 +++ services/github/github-followers.service.js | 22 ++ services/github/github-forks.service.js | 22 ++ .../github/github-issue-detail.service.js | 58 ++++ services/github/github-issues.service.js | 88 +++++ services/github/github-languages.service.js | 57 +++- services/github/github-last-commit.service.js | 28 ++ services/github/github-license.service.js | 23 +- .../github/github-manifest-version.service.js | 27 +- .../github/github-release-date.service.js | 29 +- services/github/github-release.service.js | 26 ++ services/github/github-repo-size.service.js | 22 ++ services/github/github-search.service.js | 23 +- services/github/github-size.service.js | 22 ++ services/github/github-stars.service.js | 22 ++ services/github/github-tag.service.js | 31 ++ services/github/github-watchers.service.js | 22 ++ 22 files changed, 667 insertions(+), 319 deletions(-) diff --git a/lib/all-badge-examples.js b/lib/all-badge-examples.js index 6372ca840b..ef50170cef 100644 --- a/lib/all-badge-examples.js +++ b/lib/all-badge-examples.js @@ -1,9 +1,6 @@ 'use strict' const { loadServiceClasses } = require('../services') -const { - documentation: githubDoc, -} = require('../services/github/github-helpers') const allBadgeExamples = [ { @@ -32,27 +29,7 @@ const allBadgeExamples = [ id: 'size', name: 'Size', }, - examples: [ - { - title: 'GitHub code size in bytes', - previewUrl: '/github/languages/code-size/badges/shields.svg', - keywords: ['GitHub', 'byte', 'code', 'size'], - documentation: githubDoc, - }, - { - title: 'GitHub repo size in bytes', - previewUrl: '/github/repo-size/badges/shields.svg', - keywords: ['GitHub', 'repo', 'size'], - documentation: githubDoc, - }, - { - title: 'GitHub file size', - previewUrl: - '/github/size/webcaetano/craft/build/phaser-craft.min.js.svg', - keywords: ['GitHub', 'file', 'size'], - documentation: githubDoc, - }, - ], + examples: [], }, { category: { @@ -60,42 +37,6 @@ const allBadgeExamples = [ name: 'Downloads', }, examples: [ - { - title: 'GitHub All Releases', - previewUrl: '/github/downloads/atom/atom/total.svg', - keywords: ['github'], - documentation: githubDoc, - }, - { - title: 'GitHub Releases', - previewUrl: '/github/downloads/atom/atom/latest/total.svg', - keywords: ['github'], - documentation: githubDoc, - }, - { - title: 'GitHub Pre-Releases', - previewUrl: '/github/downloads-pre/atom/atom/latest/total.svg', - keywords: ['github'], - documentation: githubDoc, - }, - { - title: 'GitHub Releases (by Release)', - previewUrl: '/github/downloads/atom/atom/v0.190.0/total.svg', - keywords: ['github'], - documentation: githubDoc, - }, - { - title: 'GitHub Releases (by Asset)', - previewUrl: '/github/downloads/atom/atom/latest/atom-amd64.deb.svg', - keywords: ['github'], - documentation: githubDoc, - }, - { - title: 'GitHub Pre-Releases (by Asset)', - previewUrl: '/github/downloads-pre/atom/atom/latest/atom-amd64.deb.svg', - keywords: ['github'], - documentation: githubDoc, - }, { title: 'Chocolatey', previewUrl: '/chocolatey/dt/scriptcs.svg', @@ -167,122 +108,7 @@ const allBadgeExamples = [ id: 'issue-tracking', name: 'Issue Tracking', }, - examples: [ - { - title: 'GitHub issues', - previewUrl: '/github/issues/badges/shields.svg', - keywords: ['GitHub', 'issue'], - documentation: githubDoc, - }, - { - title: 'GitHub issues', - previewUrl: '/github/issues-raw/badges/shields.svg', - keywords: ['GitHub', 'issue'], - documentation: githubDoc, - }, - { - title: 'GitHub pull requests', - previewUrl: '/github/issues-pr/cdnjs/cdnjs.svg', - keywords: ['GitHub', 'pullrequest', 'pr'], - documentation: githubDoc, - }, - { - title: 'GitHub pull requests', - previewUrl: '/github/issues-pr-raw/cdnjs/cdnjs.svg', - keywords: ['GitHub', 'pullrequest', 'pr'], - documentation: githubDoc, - }, - { - title: 'GitHub closed issues', - previewUrl: '/github/issues-closed/badges/shields.svg', - keywords: ['GitHub', 'issue'], - documentation: githubDoc, - }, - { - title: 'GitHub closed issues', - previewUrl: '/github/issues-closed-raw/badges/shields.svg', - keywords: ['GitHub', 'issue'], - documentation: githubDoc, - }, - { - title: 'GitHub closed pull requests', - previewUrl: '/github/issues-pr-closed/cdnjs/cdnjs.svg', - keywords: ['GitHub', 'pullrequest', 'pr'], - documentation: githubDoc, - }, - { - title: 'GitHub closed pull requests', - previewUrl: '/github/issues-pr-closed-raw/cdnjs/cdnjs.svg', - keywords: ['GitHub', 'pullrequest', 'pr'], - documentation: githubDoc, - }, - { - title: 'GitHub issues by-label', - previewUrl: '/github/issues/badges/shields/service-badge.svg', - keywords: ['GitHub', 'issue', 'label'], - documentation: githubDoc, - }, - { - title: 'GitHub issues by-label', - previewUrl: '/github/issues-raw/badges/shields/service-badge.svg', - keywords: ['GitHub', 'issue', 'label'], - documentation: githubDoc, - }, - { - title: 'GitHub pull requests by-label', - previewUrl: '/github/issues-pr/badges/shields/service-badge.svg', - keywords: ['GitHub', 'pullrequests', 'label'], - documentation: githubDoc, - }, - { - title: 'GitHub pull requests by-label', - previewUrl: '/github/issues-pr-raw/badges/shields/service-badge.svg', - keywords: ['GitHub', 'pullrequests', 'label'], - documentation: githubDoc, - }, - { - title: 'GitHub issue/pull request state', - previewUrl: '/github/issues/detail/s/badges/shields/979.svg', - keywords: ['GitHub', 'issue', 'pullrequest', 'detail'], - documentation: githubDoc, - }, - { - title: 'GitHub issue/pull request title', - previewUrl: '/github/issues/detail/title/badges/shields/1290.svg', - keywords: ['GitHub', 'issue', 'pullrequest', 'detail'], - documentation: githubDoc, - }, - { - title: 'GitHub issue/pull request author', - previewUrl: '/github/issues/detail/u/badges/shields/979.svg', - keywords: ['GitHub', 'issue', 'pullrequest', 'detail'], - documentation: githubDoc, - }, - { - title: 'GitHub issue/pull request label', - previewUrl: '/github/issues/detail/label/badges/shields/979.svg', - keywords: ['GitHub', 'issue', 'pullrqeuest', 'detail'], - documentation: githubDoc, - }, - { - title: 'GitHub issue/pull request comments', - previewUrl: '/github/issues/detail/comments/badges/shields/979.svg', - keywords: ['GitHub', 'issue', 'pullrequest', 'detail'], - documentation: githubDoc, - }, - { - title: 'GitHub issue/pull request age', - previewUrl: '/github/issues/detail/age/badges/shields/979.svg', - keywords: ['GitHub', 'issue', 'pullrequest', 'detail'], - documentation: githubDoc, - }, - { - title: 'GitHub issue/pull request last update', - previewUrl: '/github/issues/detail/last-update/badges/shields/979.svg', - keywords: ['GitHub', 'issue', 'pullrequest', 'detail'], - documentation: githubDoc, - }, - ], + examples: [], }, { category: { @@ -290,12 +116,6 @@ const allBadgeExamples = [ name: 'License', }, examples: [ - { - title: 'GitHub', - previewUrl: '/github/license/mashape/apistatus.svg', - keywords: ['GitHub', 'license'], - documentation: githubDoc, - }, { title: 'Crates.io', previewUrl: '/crates/l/rustc-serialize.svg', @@ -409,29 +229,7 @@ const allBadgeExamples = [ id: 'social', name: 'Social', }, - examples: [ - { - title: 'GitHub forks', - previewUrl: '/github/forks/badges/shields.svg?style=social&label=Fork', - documentation: githubDoc, - }, - { - title: 'GitHub stars', - previewUrl: '/github/stars/badges/shields.svg?style=social&label=Stars', - documentation: githubDoc, - }, - { - title: 'GitHub watchers', - previewUrl: - '/github/watchers/badges/shields.svg?style=social&label=Watch', - documentation: githubDoc, - }, - { - title: 'GitHub followers', - previewUrl: '/github/followers/espadrine.svg?style=social&label=Follow', - documentation: githubDoc, - }, - ], + examples: [], }, { category: { @@ -463,54 +261,6 @@ const allBadgeExamples = [ previewUrl: '/packagist/vpre/symfony/symfony.svg', keywords: ['PHP'], }, - { - title: 'GitHub tag (latest SemVer)', - previewUrl: '/github/tag/expressjs/express.svg', - documentation: githubDoc, - }, - { - title: 'GitHub tag (latest SemVer pre-release)', - previewUrl: '/github/tag-pre/expressjs/express.svg', - documentation: githubDoc, - }, - { - title: 'GitHub tag (latest by date)', - previewUrl: '/github/tag-date/expressjs/express.svg', - documentation: githubDoc, - }, - { - title: 'GitHub package version', - previewUrl: '/github/package-json/v/badges/shields.svg', - documentation: githubDoc, - }, - { - title: 'GitHub manifest version', - previewUrl: '/github/manifest-json/v/RedSparr0w/IndieGala-Helper.svg', - documentation: githubDoc, - }, - { - title: 'GitHub release', - previewUrl: '/github/release/qubyte/rubidium.svg', - documentation: githubDoc, - }, - { - title: 'GitHub (pre-)release', - previewUrl: '/github/release-pre/qubyte/rubidium.svg', - documentation: githubDoc, - }, - { - title: 'GitHub commits', - previewUrl: '/github/commits-since/SubtitleEdit/subtitleedit/3.4.7.svg', - keywords: ['GitHub', 'commit'], - documentation: githubDoc, - }, - { - title: 'GitHub commits (since latest release)', - previewUrl: - '/github/commits-since/SubtitleEdit/subtitleedit/latest.svg', - keywords: ['GitHub', 'commit'], - documentation: githubDoc, - }, { title: 'NuGet', previewUrl: '/nuget/v/Nuget.Core.svg', @@ -625,67 +375,6 @@ const allBadgeExamples = [ name: 'Other', }, examples: [ - { - title: 'GitHub Release Date', - previewUrl: '/github/release-date/SubtitleEdit/subtitleedit.svg', - keywords: ['GitHub', 'release', 'date'], - documentation: githubDoc, - }, - { - title: 'GitHub (Pre-)Release Date', - previewUrl: '/github/release-date-pre/Cockatrice/Cockatrice.svg', - keywords: ['GitHub', 'release', 'date'], - documentation: githubDoc, - }, - { - title: 'GitHub commit merge status', - previewUrl: - '/github/commit-status/badges/shields/master/5d4ab86b1b5ddfb3c4a70a70bd19932c52603b8c.svg', - keywords: ['GitHub', 'commit', 'branch', 'merge'], - documentation: githubDoc, - }, - { - title: 'GitHub contributors', - previewUrl: '/github/contributors/cdnjs/cdnjs.svg', - keywords: ['GitHub', 'contributor'], - documentation: githubDoc, - }, - { - title: 'GitHub search hit counter', - previewUrl: '/github/search/torvalds/linux/goto.svg', - keywords: ['GitHub', 'search', 'hit', 'counter'], - documentation: githubDoc, - }, - { - title: 'GitHub commit activity the past week, 4 weeks, year', - previewUrl: '/github/commit-activity/y/eslint/eslint.svg', - keywords: ['GitHub', 'commit', 'commits', 'activity'], - documentation: githubDoc, - }, - { - title: 'GitHub last commit', - previewUrl: '/github/last-commit/google/skia.svg', - keywords: ['GitHub', 'last', 'latest', 'commit'], - documentation: githubDoc, - }, - { - title: 'GitHub last commit (branch)', - previewUrl: '/github/last-commit/google/skia/infra/config.svg', - keywords: ['GitHub', 'last', 'latest', 'commit'], - documentation: githubDoc, - }, - { - title: 'GitHub top language', - previewUrl: '/github/languages/top/badges/shields.svg', - keywords: ['GitHub', 'top', 'language'], - documentation: githubDoc, - }, - { - title: 'GitHub language count', - previewUrl: '/github/languages/count/badges/shields.svg', - keywords: ['GitHub', 'language', 'count'], - documentation: githubDoc, - }, { title: 'Puppet Forge', previewUrl: '/puppetforge/e/camptocamp/openssl.svg', diff --git a/services/github/github-commit-activity.service.js b/services/github/github-commit-activity.service.js index df0dcda677..7bc93cd87b 100644 --- a/services/github/github-commit-activity.service.js +++ b/services/github/github-commit-activity.service.js @@ -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)$/, diff --git a/services/github/github-commit-status.service.js b/services/github/github-commit-status.service.js index 7565196495..be8767a4bd 100644 --- a/services/github/github-commit-status.service.js +++ b/services/github/github-commit-status.service.js @@ -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)$/, diff --git a/services/github/github-commits-since.service.js b/services/github/github-commits-since.service.js index 2414496aad..2d7954ee1b 100644 --- a/services/github/github-commits-since.service.js +++ b/services/github/github-commits-since.service.js @@ -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)$/, diff --git a/services/github/github-contributors.service.js b/services/github/github-contributors.service.js index 4fb9687b6b..ff7367ae59 100644 --- a/services/github/github-contributors.service.js +++ b/services/github/github-contributors.service.js @@ -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)$/, diff --git a/services/github/github-downloads.service.js b/services/github/github-downloads.service.js index 65c4f1e5be..f4cc345ed1 100644 --- a/services/github/github-downloads.service.js +++ b/services/github/github-downloads.service.js @@ -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)$/, diff --git a/services/github/github-followers.service.js b/services/github/github-followers.service.js index 7703a3f331..136f2e2514 100644 --- a/services/github/github-followers.service.js +++ b/services/github/github-followers.service.js @@ -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)$/, diff --git a/services/github/github-forks.service.js b/services/github/github-forks.service.js index 17ff0ac0e9..a6089da25e 100644 --- a/services/github/github-forks.service.js +++ b/services/github/github-forks.service.js @@ -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)$/, diff --git a/services/github/github-issue-detail.service.js b/services/github/github-issue-detail.service.js index 9dcf6399cc..fbbddb0b33 100644 --- a/services/github/github-issue-detail.service.js +++ b/services/github/github-issue-detail.service.js @@ -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)$/, diff --git a/services/github/github-issues.service.js b/services/github/github-issues.service.js index c3b3453a44..475b9012d4 100644 --- a/services/github/github-issues.service.js +++ b/services/github/github-issues.service.js @@ -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)$/, diff --git a/services/github/github-languages.service.js b/services/github/github-languages.service.js index a857cb238f..d204970d9d 100644 --- a/services/github/github-languages.service.js +++ b/services/github/github-languages.service.js @@ -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 } diff --git a/services/github/github-last-commit.service.js b/services/github/github-last-commit.service.js index 041029116d..f8ec4a9150 100644 --- a/services/github/github-last-commit.service.js +++ b/services/github/github-last-commit.service.js @@ -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)$/, diff --git a/services/github/github-license.service.js b/services/github/github-license.service.js index 81b7b9234d..8a823126b4 100644 --- a/services/github/github-license.service.js +++ b/services/github/github-license.service.js @@ -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) => { diff --git a/services/github/github-manifest-version.service.js b/services/github/github-manifest-version.service.js index 63f2f45056..6d3aebc181 100644 --- a/services/github/github-manifest-version.service.js +++ b/services/github/github-manifest-version.service.js @@ -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)$/, diff --git a/services/github/github-release-date.service.js b/services/github/github-release-date.service.js index 9956d636cd..bb56433bf7 100644 --- a/services/github/github-release-date.service.js +++ b/services/github/github-release-date.service.js @@ -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)$/, diff --git a/services/github/github-release.service.js b/services/github/github-release.service.js index 29b896b36b..608488bd50 100644 --- a/services/github/github-release.service.js +++ b/services/github/github-release.service.js @@ -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)$/, diff --git a/services/github/github-repo-size.service.js b/services/github/github-repo-size.service.js index 64e8ef2001..089eced795 100644 --- a/services/github/github-repo-size.service.js +++ b/services/github/github-repo-size.service.js @@ -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)$/, diff --git a/services/github/github-search.service.js b/services/github/github-search.service.js index c00ac644e3..4bb20fb473 100644 --- a/services/github/github-search.service.js +++ b/services/github/github-search.service.js @@ -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) => { diff --git a/services/github/github-size.service.js b/services/github/github-size.service.js index 3c73266547..0b8dea75f3 100644 --- a/services/github/github-size.service.js +++ b/services/github/github-size.service.js @@ -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)$/, diff --git a/services/github/github-stars.service.js b/services/github/github-stars.service.js index 011a947fd4..ba959e4a69 100644 --- a/services/github/github-stars.service.js +++ b/services/github/github-stars.service.js @@ -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)$/, diff --git a/services/github/github-tag.service.js b/services/github/github-tag.service.js index 59e3e3f54e..f6644fb694 100644 --- a/services/github/github-tag.service.js +++ b/services/github/github-tag.service.js @@ -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)$/, diff --git a/services/github/github-watchers.service.js b/services/github/github-watchers.service.js index a073ec14ae..24abf3e2fa 100644 --- a/services/github/github-watchers.service.js +++ b/services/github/github-watchers.service.js @@ -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)$/, -- GitLab