Files
shields/services/github/github-helpers.js
Caleb Cartwright 24355a0773 change closed GitHub issue color to purple (#7374)
Co-authored-by: repo-ranger[bot] <39074581+repo-ranger[bot]@users.noreply.github.com>
2021-12-18 20:43:02 +00:00

41 lines
1021 B
JavaScript

import { colorScale } from '../color-formatters.js'
import { InvalidResponse, NotFound } from '../index.js'
const documentation = `
<p>
If your GitHub badge errors, it might be because you hit GitHub's rate limits.
You can increase Shields.io's rate limit by
<a href="https://img.shields.io/github-auth">adding the Shields GitHub
application</a> using your GitHub account.
</p>
`
function issueStateColor(s) {
return { open: '2cbe4e', closed: '6f42c1' }[s]
}
function errorMessagesFor(notFoundMessage = 'repo not found') {
return {
404: notFoundMessage,
422: notFoundMessage,
}
}
function transformErrors(errors, entity = 'repo') {
if (errors[0].type === 'NOT_FOUND') {
return new NotFound({ prettyMessage: `${entity} not found` })
} else {
return new InvalidResponse({ prettyMessage: errors[0].message })
}
}
const commentsColor = colorScale([1, 3, 10, 25], undefined, true)
export {
documentation,
issueStateColor,
commentsColor,
errorMessagesFor,
transformErrors,
}