From b82b718179489d4d4c19ba131a293de67275b068 Mon Sep 17 00:00:00 2001 From: Amio Date: Tue, 17 Jul 2018 21:51:55 +0800 Subject: [PATCH 1/5] Update david-dm with dev/peer/optional support #11 --- libs/live-fns/david.js | 28 ++++++++++++++++++++++++++-- 1 file changed, 26 insertions(+), 2 deletions(-) diff --git a/libs/live-fns/david.js b/libs/live-fns/david.js index 8618d6a..400bf60 100644 --- a/libs/live-fns/david.js +++ b/libs/live-fns/david.js @@ -5,11 +5,17 @@ const statusInfo = { 'outofdate': ['out of date', 'orange'], 'notsouptodate': ['up to date', 'yellow'], 'uptodate': ['up to date', 'green'], - 'none': ['pending', 'grey'] + 'none': ['none', 'blue'] } module.exports = async function (depType, user, repo) { - const endpoint = `https://david-dm.org/${user}/${repo}/info.json` + const prefix = { + 'dep': '', + 'dev': 'dev-', + 'peer': 'peer-', + 'optional': 'optional-' + }[depType] + const endpoint = `https://david-dm.org/${user}/${repo}/${prefix}info.json` const { status } = await axios.get(endpoint).then(res => res.data) switch (depType) { @@ -19,5 +25,23 @@ module.exports = async function (depType, user, repo) { status: statusInfo[status][0], color: statusInfo[status][1] } + case 'dev': + return { + subject: 'devDependencies', + status: statusInfo[status][0], + color: statusInfo[status][1] + } + case 'peer': + return { + subject: 'peerDependencies', + status: statusInfo[status][0], + color: statusInfo[status][1] + } + case 'optional': + return { + subject: 'optionalDependencies', + status: statusInfo[status][0], + color: statusInfo[status][1] + } } } From a4180b3b9d451a46d896b7a09bd28261dc0135db Mon Sep 17 00:00:00 2001 From: Amio Date: Tue, 17 Jul 2018 22:00:27 +0800 Subject: [PATCH 2/5] Add david-dm badge examples --- libs/index.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/libs/index.md b/libs/index.md index 03eaaf1..33a2bd7 100644 --- a/libs/index.md +++ b/libs/index.md @@ -67,6 +67,9 @@ Available color names: | circleci | ![](/circleci/github/amio/now-go) | [/circleci/github/amio/now-go](/circleci/github/amio/now-go) | circleci (branch) | ![](/circleci/github/amio/now-go/master) | [/circleci/github/amio/now-go/master](/circleci/github/amio/now-go/master) | appveyor ci | ![](/appveyor/ci/gruntjs/grunt) | [/appveyor/ci/gruntjs/grunt](/appveyor/ci/gruntjs/grunt) +| david-dm | ![](/david/dep/zeit/pkg) | [/david/dep/zeit/pkg](/david/dep/zeit/pkg) +| david-dm dev dependencies | ![](/david/dev/zeit/pkg) | [/david/dev/zeit/pkg](/david/dev/zeit/pkg) +| david-dm peer dependencies | ![](/david/peer/epoberezkin/ajv-keywords) | [/david/peer/epoberezkin/ajv-keywords](/david/peer/epoberezkin/ajv-keywords) ## About From dcb20f6a310941ed0327df4de0426c61cf647a54 Mon Sep 17 00:00:00 2001 From: Amio Date: Tue, 17 Jul 2018 22:02:22 +0800 Subject: [PATCH 3/5] Simplify live badge api error log --- libs/setup-live-badge.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libs/setup-live-badge.js b/libs/setup-live-badge.js index 9c69c75..57d8795 100644 --- a/libs/setup-live-badge.js +++ b/libs/setup-live-badge.js @@ -29,7 +29,7 @@ async function fetchLiveParams (scope, fn, paramsPath) { console.time(fetchKey) waitings[fetchKey] = fn(...paramsPath.split('/')).catch(e => { - console.error(fetchKey, e) + console.error(fetchKey, 'LIVE_ERROR', e.message) return { fail: true } }).then(result => { console.timeEnd(fetchKey) From 0d0ce43343df8e0ed68edf9e1b5704a0782c04bf Mon Sep 17 00:00:00 2001 From: Amio Date: Tue, 17 Jul 2018 22:04:03 +0800 Subject: [PATCH 4/5] Increase live badge cache age to 2-6 minutes --- libs/setup-live-badge.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libs/setup-live-badge.js b/libs/setup-live-badge.js index 57d8795..d57be60 100644 --- a/libs/setup-live-badge.js +++ b/libs/setup-live-badge.js @@ -13,10 +13,10 @@ module.exports = function (router) { fail = false } = await fetchLiveParams(name, fn, params['*']) - const sharedMaxAge = fail ? '0' : (Math.random() * 60 + 60).toFixed() + const sharedMaxAge = fail ? '0' : (Math.random() * 240 + 120).toFixed() res.writeHead(200, { 'Content-Type': 'image/svg+xml;charset=utf-8', - 'Cache-Control': 'public, max-age=20, s-maxage=' + sharedMaxAge + 'Cache-Control': 'public, max-age=30, s-maxage=' + sharedMaxAge }) res.end(badgen({subject, status, color, style})) }) From a6213515341a78016dc46a2ffe09b271e5dcd9c8 Mon Sep 17 00:00:00 2001 From: Amio Date: Tue, 17 Jul 2018 23:03:03 +0800 Subject: [PATCH 5/5] Update david-dm badge example --- libs/index.md | 1 + 1 file changed, 1 insertion(+) diff --git a/libs/index.md b/libs/index.md index 33a2bd7..f7e4ec9 100644 --- a/libs/index.md +++ b/libs/index.md @@ -70,6 +70,7 @@ Available color names: | david-dm | ![](/david/dep/zeit/pkg) | [/david/dep/zeit/pkg](/david/dep/zeit/pkg) | david-dm dev dependencies | ![](/david/dev/zeit/pkg) | [/david/dev/zeit/pkg](/david/dev/zeit/pkg) | david-dm peer dependencies | ![](/david/peer/epoberezkin/ajv-keywords) | [/david/peer/epoberezkin/ajv-keywords](/david/peer/epoberezkin/ajv-keywords) +| david-dm optional dependencies | ![](/david/optional/epoberezkin/ajv-keywords) | [/david/optional/epoberezkin/ajv-keywords](/david/optional/epoberezkin/ajv-keywords) ## About