* Build(deps-dev): bump eslint-plugin-import from 2.17.3 to 2.18.0 Bumps [eslint-plugin-import](https://github.com/benmosher/eslint-plugin-import) from 2.17.3 to 2.18.0. - [Release notes](https://github.com/benmosher/eslint-plugin-import/releases) - [Changelog](https://github.com/benmosher/eslint-plugin-import/blob/master/CHANGELOG.md) - [Commits](https://github.com/benmosher/eslint-plugin-import/compare/v2.17.3...v2.18.0) Signed-off-by: dependabot-preview[bot] <support@dependabot.com> * Autofixes
73 lines
1.6 KiB
JavaScript
73 lines
1.6 KiB
JavaScript
'use strict'
|
|
|
|
const { metric } = require('../text-formatters')
|
|
const { downloadCount } = require('../color-formatters')
|
|
const { BaseAmoService, keywords } = require('./amo-base')
|
|
const { redirector } = require('..')
|
|
|
|
const documentation = `
|
|
<p>
|
|
Previously <code>amo/d</code> provided a “total downloads” badge. However,
|
|
<a href="https://github.com/badges/shields/issues/3079">updates to the v3 API</a> only
|
|
give us weekly downloads. The route <code>amo/d</code> redirects to <code>amo/dw</code>.
|
|
</p>
|
|
`
|
|
|
|
class AmoWeeklyDownloads extends BaseAmoService {
|
|
static get category() {
|
|
return 'downloads'
|
|
}
|
|
|
|
static get route() {
|
|
return {
|
|
base: 'amo/dw',
|
|
pattern: ':addonId',
|
|
}
|
|
}
|
|
|
|
static get examples() {
|
|
return [
|
|
{
|
|
title: 'Mozilla Add-on',
|
|
namedParams: { addonId: 'dustman' },
|
|
staticPreview: this.render({ downloads: 120 }),
|
|
keywords,
|
|
documentation,
|
|
},
|
|
]
|
|
}
|
|
|
|
static get defaultBadgeData() {
|
|
return { label: 'downloads' }
|
|
}
|
|
|
|
static render({ downloads }) {
|
|
return {
|
|
message: `${metric(downloads)}/week`,
|
|
color: downloadCount(downloads),
|
|
}
|
|
}
|
|
|
|
async handle({ addonId }) {
|
|
const data = await this.fetch({ addonId })
|
|
return this.constructor.render({
|
|
downloads: data.weekly_downloads,
|
|
})
|
|
}
|
|
}
|
|
|
|
const AmoLegacyRedirect = redirector({
|
|
category: 'downloads',
|
|
route: {
|
|
base: 'amo/d',
|
|
pattern: ':addonId',
|
|
},
|
|
transformPath: ({ addonId }) => `/amo/dw/${addonId}`,
|
|
dateAdded: new Date('2019-02-23'),
|
|
})
|
|
|
|
module.exports = {
|
|
AmoWeeklyDownloads,
|
|
AmoLegacyRedirect,
|
|
}
|