Skip to content

Commit

Permalink
feat: migrate /codeclimate (#614)
Browse files Browse the repository at this point in the history
  • Loading branch information
amio authored Jun 28, 2023
1 parent 356fb58 commit b448741
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 9 deletions.
1 change: 0 additions & 1 deletion libs/badge-list.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ export const liveBadgeList = [
'codecov',
'codacy',
'coveralls',
'codeclimate',
'azure-pipelines',
// quality & metrics
'snyk',
Expand Down
2 changes: 2 additions & 0 deletions libs/badge-list2.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import github from '../pages/api/github'
import npm from '../pages/api/npm'
import bundlephobia from '../pages/api/bundlephobia'
import packagephobia from '../pages/api/packagephobia'
import codeclimate from '../pages/api/codeclimate'
import chromeWebStore from '../pages/api/chrome-web-store'
import hackage from '../pages/api/hackage'
import pypi from '../pages/api/pypi'
Expand All @@ -16,6 +17,7 @@ export default {
npm: npm.meta,
bundlephobia: bundlephobia.meta,
packagephobia: packagephobia.meta,
codeclimate: codeclimate.meta,
'chrome-web-store': chromeWebStore.meta,
hackage: hackage.meta,
pypi: pypi.meta,
Expand Down
1 change: 1 addition & 0 deletions next.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ const nextConfig = {
'/npm',
'/bundlephobia',
'/packagephobia',
'/codeclimate',
'/chrome-web-store',
'/hackage',
'/ppm',
Expand Down
17 changes: 13 additions & 4 deletions api-/codeclimate.ts → pages/api/codeclimate.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
import got from '../libs/got'
import { coverage as cov, scale } from '../libs/utils'
import { createBadgenHandler, PathArgs } from '../libs/create-badgen-handler'
import got from '../../libs/got'
import { coverage as cov, scale } from '../../libs/utils'
import { createBadgenHandler, PathArgs } from '../../libs/create-badgen-handler-next'
import type { BadgenParams } from '../../libs/types'



export default createBadgenHandler({
title: 'Code Climate',
Expand All @@ -18,7 +21,7 @@ export default createBadgenHandler({
}
})

async function handler ({ topic, owner, repo }: PathArgs) {
async function handler ({ topic, owner, repo }: PathArgs): Promise<BadgenParams> {
const api = `https://api.codeclimate.com/v1/repos?github_slug=${owner}/${repo}`
const result = await got(api).json<any>()
const meta = result.data[0]
Expand Down Expand Up @@ -105,6 +108,12 @@ const getReport = async (repoId, reportId, type, topic) => {
status: cov(attributes.rating.measure.value),
color: scale('coverage')(attributes.rating.measure.value)
}
default:
return {
subject: 'codeclimate',
status: 'unknown topic',
color: 'gray'
}
}
}

Expand Down
4 changes: 0 additions & 4 deletions vercel.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,6 @@
"source": "/codacy/:match*",
"destination": "https://v2022.badgen.net/codacy/:match*"
},
{
"source": "/codeclimate/:match*",
"destination": "https://v2022.badgen.net/codeclimate/:match*"
},
{
"source": "/codecov/:match*",
"destination": "https://v2022.badgen.net/codecov/:match*"
Expand Down

1 comment on commit b448741

@vercel
Copy link

@vercel vercel bot commented on b448741 Jun 28, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.