From 373da48397f37cfa3569ebbfc23d721af0f46a46 Mon Sep 17 00:00:00 2001 From: Amio Date: Mon, 16 Jul 2018 12:17:56 +0800 Subject: [PATCH] Add badge provider: homebrew --- index.md => libs/index.md | 3 +++ libs/live-fns/_index.js | 1 + libs/live-fns/homebrew.js | 21 +++++++++++++++++++++ libs/serve-index.js | 2 +- 4 files changed, 26 insertions(+), 1 deletion(-) rename index.md => libs/index.md (94%) create mode 100644 libs/live-fns/homebrew.js diff --git a/index.md b/libs/index.md similarity index 94% rename from index.md rename to libs/index.md index 7ea183b..6583f16 100644 --- a/index.md +++ b/libs/index.md @@ -43,6 +43,7 @@ Available color names: | Keyword | Preview | URL | | --- | --- | --- | | npm version | ![](/npm/v/express) | [/npm/v/express](/npm/v/express) +| npm version | ![](/npm/v/marked) | [/npm/v/marked](/npm/v/marked) | npm version (scoped) | ![](/npm/v/@nestjs/core) | [/npm/v/@nestjs/core](/npm/v/@nestjs/core) | npm downloads/day | ![](/npm/dd/express) | [/npm/dd/express](/npm/dd/express) | npm downloads/week | ![](/npm/dw/express) | [/npm/dw/express](/npm/dw/express) @@ -56,6 +57,8 @@ Available color names: | chrome extension rating | ![](/chrome-web-store/rating/ckkdlimhmcjmikdlpkmbgfkaikojcbjk) | [/chrome-web-store/rating/ckkdlimhmcjmikdlpkmbgfkaikojcbjk](/chrome-web-store/rating/ckkdlimhmcjmikdlpkmbgfkaikojcbjk) | chrome extension stars | ![](/chrome-web-store/stars/ckkdlimhmcjmikdlpkmbgfkaikojcbjk) | [/chrome-web-store/stars/ckkdlimhmcjmikdlpkmbgfkaikojcbjk](/chrome-web-store/stars/ckkdlimhmcjmikdlpkmbgfkaikojcbjk) | chrome extension rating count | ![](/chrome-web-store/rating-count/ckkdlimhmcjmikdlpkmbgfkaikojcbjk) | [/chrome-web-store/rating-count/ckkdlimhmcjmikdlpkmbgfkaikojcbjk](/chrome-web-store/rating-count/ckkdlimhmcjmikdlpkmbgfkaikojcbjk) +| homebrew version | ![](/homebrew/v/fish) | [/homebrew/v/fish](/homebrew/v/fish) +| homebrew version | ![](/homebrew/v/cake) | [/homebrew/v/cake](/homebrew/v/cake) | travis | ![](/travis/amio/micro-cors) | [/travis/amio/micro-cors](/travis/amio/micro-cors) | travis (org) | ![](/travis-org/styfle/packagephobia) | [/travis-org/styfle/packagephobia](/travis-org/styfle/packagephobia) | circleci | ![](/circleci/github/amio/now-go) | [/circleci/github/amio/now-go](/circleci/github/amio/now-go) diff --git a/libs/live-fns/_index.js b/libs/live-fns/_index.js index 2aae9e4..074fda3 100644 --- a/libs/live-fns/_index.js +++ b/libs/live-fns/_index.js @@ -1,5 +1,6 @@ module.exports = { 'chrome-web-store': require('./chrome-web-store.js'), 'crates': require('./crates.js'), + 'homebrew': require('./homebrew.js'), 'npm': require('./npm.js') } diff --git a/libs/live-fns/homebrew.js b/libs/live-fns/homebrew.js new file mode 100644 index 0000000..1e3ae6f --- /dev/null +++ b/libs/live-fns/homebrew.js @@ -0,0 +1,21 @@ +const axios = require('../axios.js') + +module.exports = async function (method, ...args) { + const endpoint = `https://formulae.brew.sh/api/formula/${args[0]}.json` + const { versions } = await axios.get(endpoint).then(res => res.data) + + switch (method) { + case 'v': + return { + subject: 'homebrew', + status: 'v' + versions.stable, + color: versions.stable[0] === '0' ? 'orange' : 'blue' + } + default: + return { + subject: 'homebrew', + status: 'unknown', + color: 'grey' + } + } +} diff --git a/libs/serve-index.js b/libs/serve-index.js index ce0aeb3..0e2c654 100644 --- a/libs/serve-index.js +++ b/libs/serve-index.js @@ -1,6 +1,6 @@ const serveMarked = require('serve-marked') -module.exports = serveMarked('index.md', { +module.exports = serveMarked('libs/index.md', { title: 'Badgen - Fast badge generating service', preset: 'merri', inlineCSS: `