kopia lustrzana https://github.com/badgen/badgen.net
feat: add docker live badge #26
rodzic
ac9db12eed
commit
ae6a843eda
|
@ -6,6 +6,7 @@ module.exports = {
|
|||
'codecov': require('./codecov.js'),
|
||||
'crates': require('./crates.js'),
|
||||
'david': require('./david.js'),
|
||||
'docker': require('./docker.js'),
|
||||
'github': require('./github.js'),
|
||||
'homebrew': require('./homebrew.js'),
|
||||
'npm': require('./npm.js'),
|
||||
|
|
|
@ -0,0 +1,31 @@
|
|||
const axios = require('../axios.js')
|
||||
const millify = require('millify')
|
||||
|
||||
module.exports = async function (topic, namespace, name) {
|
||||
if (!['stars', 'pulls'].includes(topic)) {
|
||||
return {
|
||||
subject: 'docker',
|
||||
status: 'unknown topic',
|
||||
color: 'grey'
|
||||
}
|
||||
}
|
||||
|
||||
/* eslint-disable camelcase */
|
||||
const endpoint = `https://hub.docker.com/v2/repositories/${namespace}/${name}`
|
||||
const { pull_count, star_count } = await axios(endpoint).then(res => res.data)
|
||||
|
||||
switch (topic) {
|
||||
case 'stars':
|
||||
return {
|
||||
subject: 'docker stars',
|
||||
status: millify(star_count),
|
||||
color: 'blue'
|
||||
}
|
||||
case 'pulls':
|
||||
return {
|
||||
subject: 'docker pulls',
|
||||
status: millify(pull_count),
|
||||
color: 'blue'
|
||||
}
|
||||
}
|
||||
}
|
Ładowanie…
Reference in New Issue