From 24bc7bcfc341c044c9ec815487fa07585b038ec2 Mon Sep 17 00:00:00 2001 From: Paul Melnikow Date: Mon, 18 Feb 2019 23:04:25 -0500 Subject: [PATCH] Combine some badge examples using drop-downs, tweak some titles (#3037) This updates several badges to take advantage of the change from #2882. --- services/bundlephobia/bundlephobia.service.js | 21 +--- .../github/github-commit-activity.service.js | 35 +----- .../github/github-commits-since.service.js | 4 +- .../github/github-issue-detail.service.js | 118 +++--------------- .../mozilla-observatory.service.js | 16 +-- .../packagist/packagist-downloads.service.js | 34 +---- services/sourceforge/sourceforge.service.js | 44 +------ ...rketplace-azure-devops-installs.service.js | 34 ++--- 8 files changed, 51 insertions(+), 255 deletions(-) diff --git a/services/bundlephobia/bundlephobia.service.js b/services/bundlephobia/bundlephobia.service.js index 1bc78d4997..1bd56c0418 100644 --- a/services/bundlephobia/bundlephobia.service.js +++ b/services/bundlephobia/bundlephobia.service.js @@ -4,8 +4,6 @@ const prettyBytes = require('pretty-bytes') const { makeBadgeData: getBadgeData } = require('../../lib/badge-data') const LegacyService = require('../legacy-service') -const keywords = ['node'] - // This legacy service should be rewritten to use e.g. BaseJsonService. // // Tips for rewriting: @@ -27,26 +25,15 @@ module.exports = class Bundlephobia extends LegacyService { static get examples() { return [ { - title: 'npm bundle size (minified)', - pattern: 'min/:packageName', - namedParams: { packageName: 'react' }, + title: 'npm bundle size', + pattern: ':format(min|minzip)/:packageName', + namedParams: { format: 'minzip', packageName: 'react' }, staticPreview: { label: 'minified size', - message: '6.06 kB', - color: 'blue', - }, - keywords, - }, - { - title: 'npm bundle size (minified + gzip)', - pattern: 'minzip/:packageName', - namedParams: { packageName: 'react' }, - staticPreview: { - label: 'minzipped size', message: '2.57 kB', color: 'blue', }, - keywords, + keywords: ['node'], }, ] } diff --git a/services/github/github-commit-activity.service.js b/services/github/github-commit-activity.service.js index e1a8522cd3..a7940c0129 100644 --- a/services/github/github-commit-activity.service.js +++ b/services/github/github-commit-activity.service.js @@ -23,43 +23,20 @@ module.exports = class GithubCommitActivity extends LegacyService { static get route() { return { base: 'github/commit-activity', - pattern: ':interval(y|4w|w)/:user/:repo', + pattern: ':interval(y|m|4w|w)/:user/:repo', } } static get examples() { return [ { - title: 'GitHub commit activity the past year', - pattern: 'y/:user/:repo', - namedParams: { user: 'eslint', repo: 'eslint' }, + title: 'GitHub commit activity', + // Override the pattern to omit the deprecated interval "4w". + pattern: ':interval(y|m|w)/:user/:repo', + namedParams: { interval: 'm', user: 'eslint', repo: 'eslint' }, staticPreview: { label: 'commit activity', - message: '457/year', - color: 'blue', - }, - keywords: ['commits'], - documentation, - }, - { - title: 'GitHub commit activity the past month', - pattern: 'm/:user/:repo', - namedParams: { user: 'eslint', repo: 'eslint' }, - staticPreview: { - label: 'commit activity', - message: '38/month', - color: 'blue', - }, - keywords: ['commits'], - documentation, - }, - { - title: 'GitHub commit activity the past week', - pattern: 'w/:user/:repo', - namedParams: { user: 'eslint', repo: 'eslint' }, - staticPreview: { - label: 'commit activity', - message: '9/week', + message: '457/month', color: 'blue', }, keywords: ['commits'], diff --git a/services/github/github-commits-since.service.js b/services/github/github-commits-since.service.js index 0b7687a2be..80b4ff26db 100644 --- a/services/github/github-commits-since.service.js +++ b/services/github/github-commits-since.service.js @@ -29,7 +29,7 @@ module.exports = class GithubCommitsSince extends LegacyService { static get examples() { return [ { - title: 'GitHub commits', + title: 'GitHub commits since tagged version', namedParams: { user: 'SubtitleEdit', repo: 'subtitleedit', @@ -43,7 +43,7 @@ module.exports = class GithubCommitsSince extends LegacyService { documentation, }, { - title: 'GitHub commits (since latest release)', + title: 'GitHub commits since latest release', namedParams: { user: 'SubtitleEdit', repo: 'subtitleedit', diff --git a/services/github/github-issue-detail.service.js b/services/github/github-issue-detail.service.js index 2f6e19b0a3..c1ca7fe7f0 100644 --- a/services/github/github-issue-detail.service.js +++ b/services/github/github-issue-detail.service.js @@ -15,11 +15,6 @@ const { checkErrorResponse: githubCheckErrorResponse, } = require('./github-helpers') -const commonExampleAttrs = { - keywords: ['pullrequest', 'detail'], - documentation, -} - // This legacy service should be rewritten to use e.g. BaseJsonService. // // Tips for rewriting: @@ -35,16 +30,18 @@ module.exports = class GithubIssueDetail extends LegacyService { return { base: 'github/issues/detail', pattern: - ':which(s|title|u|label|comments|age|last-update)/:user/:repo/:number(0-9+)', + ':which(s|state|title|u|author|label|comments|age|last-update)/:user/:repo/:number(0-9+)', } } static get examples() { return [ { - title: 'GitHub issue/pull request state', - pattern: 's/:user/:repo/:number', + title: 'GitHub issue/pull request detail', + pattern: + ':which(state|title|author|label|comments|age|last-update)/:user/:repo/:number', namedParams: { + which: 'state', user: 'badges', repo: 'shields', number: '979', @@ -54,97 +51,16 @@ module.exports = class GithubIssueDetail extends LegacyService { message: 'closed', color: 'red', }, - ...commonExampleAttrs, - }, - { - title: 'GitHub issue/pull request title', - pattern: 'title/:user/:repo/:number', - namedParams: { - user: 'badges', - repo: 'shields', - number: '1290', - }, - staticPreview: { - label: 'issue 1290', - message: 'Node 9 support', - color: 'lightgrey', - }, - ...commonExampleAttrs, - }, - { - title: 'GitHub issue/pull request author', - pattern: 'u/:user/:repo/:number', - namedParams: { - user: 'badges', - repo: 'shields', - number: '979', - }, - staticPreview: { - label: 'author', - message: 'paulmelnikow', - color: 'lightgrey', - }, - ...commonExampleAttrs, - }, - { - title: 'GitHub issue/pull request label', - pattern: 'label/:user/:repo/:number', - namedParams: { - user: 'badges', - repo: 'shields', - number: '979', - }, - staticPreview: { - label: 'label', - message: 'bug | developer-experience', - color: 'lightgrey', - }, - ...commonExampleAttrs, - }, - { - title: 'GitHub issue/pull request comments', - pattern: 'comments/:user/:repo/:number', - namedParams: { - user: 'badges', - repo: 'shields', - number: '979', - }, - staticPreview: { - label: 'comments', - message: '24', - color: 'yellow', - }, - ...commonExampleAttrs, - }, - { - title: 'GitHub issue/pull request age', - pattern: 'age/:user/:repo/:number', - namedParams: { - user: 'badges', - repo: 'shields', - number: '979', - }, - staticPreview: { - label: 'created', - message: 'april 2017', - color: 'orange', - }, - ...commonExampleAttrs, - }, - { - title: 'GitHub issue/pull request last update', - pattern: 'last-update/:user/:repo/:number', - namedParams: { - user: 'badges', - repo: 'shields', - number: '979', - }, - staticPreview: { - label: 'updated', - message: 'december 2017', - color: 'orange', - }, - ...commonExampleAttrs, + keywords: [ + 'state', + 'title', + 'author', + 'label', + 'comments', + 'age', + 'last update', + ], + documentation, }, ] } @@ -183,7 +99,8 @@ module.exports = class GithubIssueDetail extends LegacyService { queryParams ) switch (which) { - case 's': { + case 's': + case 'state': { const state = (badgeData.text[1] = parsedData.state) badgeData.colorscheme = undefined badgeData.colorB = queryParams.colorB || githubStateColor(state) @@ -193,6 +110,7 @@ module.exports = class GithubIssueDetail extends LegacyService { badgeData.text[1] = parsedData.title break case 'u': + case 'author': badgeData.text[0] = getLabel('author', queryParams) badgeData.text[1] = parsedData.user.login break diff --git a/services/mozilla-observatory/mozilla-observatory.service.js b/services/mozilla-observatory/mozilla-observatory.service.js index f9e0d28115..54da067470 100644 --- a/services/mozilla-observatory/mozilla-observatory.service.js +++ b/services/mozilla-observatory/mozilla-observatory.service.js @@ -63,8 +63,7 @@ module.exports = class MozillaObservatory extends BaseJsonService { return [ { title: 'Mozilla HTTP Observatory Grade', - pattern: 'grade/:host', - namedParams: { host: 'github.com' }, + namedParams: { which: 'grade', host: 'github.com' }, staticPreview: this.render({ which: 'grade', state: 'FINISHED', @@ -74,19 +73,6 @@ module.exports = class MozillaObservatory extends BaseJsonService { keywords: ['scanner', 'security'], documentation, }, - { - title: 'Mozilla HTTP Observatory Grade (with score)', - pattern: 'grade-score/:host', - namedParams: { host: 'github.com' }, - staticPreview: this.render({ - which: 'grade-score', - state: 'FINISHED', - grade: 'A+', - score: 115, - }), - keywords: ['scanner', 'security'], - documentation, - }, ] } diff --git a/services/packagist/packagist-downloads.service.js b/services/packagist/packagist-downloads.service.js index a67cf09c1f..6c61a763e5 100644 --- a/services/packagist/packagist-downloads.service.js +++ b/services/packagist/packagist-downloads.service.js @@ -7,8 +7,6 @@ const { downloadCount: downloadCountColor, } = require('../../lib/color-formatters') -const keywords = ['PHP'] - // This legacy service should be rewritten to use e.g. BaseJsonService. // // Tips for rewriting: @@ -31,8 +29,8 @@ module.exports = class PackagistDownloads extends LegacyService { return [ { title: 'Packagist', - pattern: 'dm/:user/:repo', namedParams: { + interval: 'dm', user: 'doctrine', repo: 'orm', }, @@ -41,35 +39,7 @@ module.exports = class PackagistDownloads extends LegacyService { message: '1M/month', color: 'brightgreen', }, - keywords, - }, - { - title: 'Packagist', - pattern: 'dd/:user/:repo', - namedParams: { - user: 'doctrine', - repo: 'orm', - }, - staticPreview: { - label: 'downloads', - message: '49k/day', - color: 'brightgreen', - }, - keywords, - }, - { - title: 'Packagist', - pattern: 'dt/:user/:repo', - namedParams: { - user: 'doctrine', - repo: 'orm', - }, - staticPreview: { - label: 'downloads', - message: '45M', - color: 'brightgreen', - }, - keywords, + keywords: ['PHP'], }, ] } diff --git a/services/sourceforge/sourceforge.service.js b/services/sourceforge/sourceforge.service.js index 5c86eb932a..f9359c0b1c 100644 --- a/services/sourceforge/sourceforge.service.js +++ b/services/sourceforge/sourceforge.service.js @@ -33,8 +33,9 @@ module.exports = class Sourceforge extends LegacyService { return [ { title: 'SourceForge', - pattern: 'dm/:project', + pattern: ':interval(dt|dm|dw|dd)/:project', namedParams: { + interval: 'dm', project: 'sevenzip', }, staticPreview: { @@ -45,50 +46,15 @@ module.exports = class Sourceforge extends LegacyService { }, { title: 'SourceForge', - pattern: 'dw/:project', - namedParams: { - project: 'sevenzip', - }, - staticPreview: { - label: 'downloads', - message: '52k/week', - color: 'brightgreen', - }, - }, - { - title: 'SourceForge', - pattern: 'dd/:project', - namedParams: { - project: 'sevenzip', - }, - staticPreview: { - label: 'downloads', - message: '6k/day', - color: 'brightgreen', - }, - }, - { - title: 'SourceForge', - pattern: 'dt/:project', - namedParams: { - project: 'sevenzip', - }, - staticPreview: { - label: 'downloads', - message: '416M', - color: 'brightgreen', - }, - }, - { - title: 'SourceForge', - pattern: 'dt/:project/:folder', + pattern: ':interval(dt|dm|dw|dd)/:project/:folder', namedParams: { + interval: 'dm', project: 'arianne', folder: 'stendhal', }, staticPreview: { label: 'downloads', - message: '177k', + message: '550/month', color: 'brightgreen', }, }, diff --git a/services/visual-studio-marketplace/visual-studio-marketplace-azure-devops-installs.service.js b/services/visual-studio-marketplace/visual-studio-marketplace-azure-devops-installs.service.js index adaa5a4eb0..dae36e02df 100644 --- a/services/visual-studio-marketplace/visual-studio-marketplace-azure-devops-installs.service.js +++ b/services/visual-studio-marketplace/visual-studio-marketplace-azure-devops-installs.service.js @@ -4,6 +4,13 @@ const VisualStudioMarketplaceBase = require('./visual-studio-marketplace-base') const { metric } = require('../../lib/text-formatters') const { downloadCount } = require('../../lib/color-formatters') +const documentation = ` +

+ This badge can show total installs, installs for Azure DevOps Services, + or on-premises installs for Azure DevOps Server. +

+` + // This service exists separately from the other Marketplace downloads badges (in ./visual-studio-marketplace-downloads.js) // due differences in how the Marketplace tracks metrics for Azure DevOps extensions vs. other extension types. // See https://github.com/badges/shields/pull/2748 for more information on the discussion and decision. @@ -35,29 +42,14 @@ module.exports = class VisualStudioMarketplaceAzureDevOpsInstalls extends Visual static get examples() { return [ { - title: - 'Visual Studio Marketplace - Azure DevOps Extension (Total Installs)', - pattern: 'total/:extensionId', - namedParams: { extensionId: 'swellaby.mirror-git-repository' }, + title: 'Visual Studio Marketplace Installs - Azure DevOps Extension', + namedParams: { + measure: 'total', + extensionId: 'swellaby.mirror-git-repository', + }, staticPreview: this.render({ count: 651 }), keywords: this.keywords, - }, - { - title: - 'Visual Studio Marketplace - Azure DevOps Extension (Services Installs)', - pattern: 'services/:extensionId', - namedParams: { extensionId: 'swellaby.mirror-git-repository' }, - staticPreview: this.render({ count: 496 }), - keywords: this.keywords, - }, - - { - title: - 'Visual Studio Marketplace - Azure DevOps Extension (OnPrem Installs)', - pattern: 'onprem/:extensionId', - namedParams: { extensionId: 'swellaby.mirror-git-repository' }, - staticPreview: this.render({ count: 155 }), - keywords: this.keywords, + documentation, }, ] }