Compare commits
67 Commits
3.3.1
...
server-202
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
6aae41e1c3 | ||
|
|
08b8153478 | ||
|
|
856c71c1da | ||
|
|
2dfe990e08 | ||
|
|
af9b309d9a | ||
|
|
cf705e77ec | ||
|
|
d4cfddd896 | ||
|
|
8bdc80c988 | ||
|
|
5850e1f10a | ||
|
|
ba314f6955 | ||
|
|
6a4f983e7f | ||
|
|
5ca4089311 | ||
|
|
08e288998c | ||
|
|
218e5b880d | ||
|
|
ae766bbf85 | ||
|
|
4014c50574 | ||
|
|
9527d05819 | ||
|
|
acdbe7e9a5 | ||
|
|
68fb0b7bab | ||
|
|
8f588179e1 | ||
|
|
f4d36d1d21 | ||
|
|
f657cbb7ab | ||
|
|
5fadcf36be | ||
|
|
f19014f112 | ||
|
|
8d7d1b1e49 | ||
|
|
29b8a5f1c3 | ||
|
|
2055114e06 | ||
|
|
a258e27309 | ||
|
|
6e02f47c3f | ||
|
|
861439ffc0 | ||
|
|
3cccb272ac | ||
|
|
6a7b2e3620 | ||
|
|
de019c2e52 | ||
|
|
5eb0f35009 | ||
|
|
956f2e0584 | ||
|
|
918a41672f | ||
|
|
54b0e10675 | ||
|
|
df4315258f | ||
|
|
b9c5d18d4f | ||
|
|
1cfdf94a6b | ||
|
|
2a92c6985e | ||
|
|
4f0acc3f5c | ||
|
|
bde23cfad8 | ||
|
|
e13bcd7dd4 | ||
|
|
c2447c4f2e | ||
|
|
4ae682308e | ||
|
|
ec3e985e6b | ||
|
|
6ac2bd6e46 | ||
|
|
5756196e08 | ||
|
|
6c7ae240b8 | ||
|
|
705fea0939 | ||
|
|
a6b4507e7c | ||
|
|
b0384f438c | ||
|
|
300b317be7 | ||
|
|
e3f0bf33ea | ||
|
|
3246f83e11 | ||
|
|
e8fa269f91 | ||
|
|
103c647d33 | ||
|
|
f7f6d911ca | ||
|
|
fd7adf1f17 | ||
|
|
56234b7b6f | ||
|
|
aaa4d8bfb8 | ||
|
|
a2d213778f | ||
|
|
6a48dd78a4 | ||
|
|
e0f0b1d88f | ||
|
|
03763a9c40 | ||
|
|
a3d85318f5 |
@@ -96,8 +96,8 @@ package_steps: &package_steps
|
||||
set +e
|
||||
export NVM_DIR="/opt/circleci/.nvm"
|
||||
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"
|
||||
nvm install v12
|
||||
nvm use v12
|
||||
nvm install v14
|
||||
nvm use v14
|
||||
npm install -g npm
|
||||
|
||||
# Run the package tests on each currently supported node version. See:
|
||||
@@ -137,33 +137,33 @@ package_steps: &package_steps
|
||||
jobs:
|
||||
main:
|
||||
docker:
|
||||
- image: circleci/node:12
|
||||
- image: circleci/node:14
|
||||
|
||||
<<: *main_steps
|
||||
|
||||
main@node-14:
|
||||
main@node-16:
|
||||
docker:
|
||||
- image: circleci/node:14
|
||||
- image: circleci/node:16
|
||||
|
||||
<<: *main_steps
|
||||
|
||||
integration:
|
||||
docker:
|
||||
- image: circleci/node:12
|
||||
- image: circleci/node:14
|
||||
- image: redis
|
||||
|
||||
<<: *integration_steps
|
||||
|
||||
integration@node-14:
|
||||
integration@node-16:
|
||||
docker:
|
||||
- image: circleci/node:14
|
||||
- image: circleci/node:16
|
||||
- image: redis
|
||||
|
||||
<<: *integration_steps
|
||||
|
||||
danger:
|
||||
docker:
|
||||
- image: circleci/node:12
|
||||
- image: circleci/node:14
|
||||
steps:
|
||||
- checkout
|
||||
|
||||
@@ -183,7 +183,7 @@ jobs:
|
||||
|
||||
frontend:
|
||||
docker:
|
||||
- image: circleci/node:12
|
||||
- image: circleci/node:14
|
||||
steps:
|
||||
- checkout
|
||||
|
||||
@@ -224,19 +224,19 @@ jobs:
|
||||
|
||||
services:
|
||||
docker:
|
||||
- image: circleci/node:12
|
||||
- image: circleci/node:14
|
||||
|
||||
<<: *services_steps
|
||||
|
||||
services@node-14:
|
||||
services@node-16:
|
||||
docker:
|
||||
- image: circleci/node:14
|
||||
- image: circleci/node:16
|
||||
|
||||
<<: *services_steps
|
||||
|
||||
e2e:
|
||||
docker:
|
||||
- image: cypress/base:12
|
||||
- image: cypress/base:14
|
||||
steps:
|
||||
- checkout
|
||||
|
||||
@@ -285,11 +285,11 @@ workflows:
|
||||
filters:
|
||||
branches:
|
||||
ignore: gh-pages
|
||||
- main@node-14:
|
||||
- main@node-16:
|
||||
filters:
|
||||
branches:
|
||||
ignore: gh-pages
|
||||
- integration@node-14:
|
||||
- integration@node-16:
|
||||
filters:
|
||||
branches:
|
||||
ignore: gh-pages
|
||||
@@ -307,7 +307,7 @@ workflows:
|
||||
ignore:
|
||||
- master
|
||||
- gh-pages
|
||||
- services@node-14:
|
||||
- services@node-16:
|
||||
filters:
|
||||
branches:
|
||||
ignore:
|
||||
|
||||
29
.github/ISSUE_TEMPLATE/1_Bug_report.md
vendored
29
.github/ISSUE_TEMPLATE/1_Bug_report.md
vendored
@@ -1,29 +0,0 @@
|
||||
---
|
||||
name: 🐛 Bug Report
|
||||
about: Report errors and problems
|
||||
labels: 'question'
|
||||
---
|
||||
|
||||
Are you experiencing an issue with...
|
||||
|
||||
- [ ] [shields.io](https://shields.io/#/)
|
||||
- [ ] My own instance
|
||||
- [ ] [badge-maker NPM package](https://www.npmjs.com/package/badge-maker)
|
||||
|
||||
:beetle: **Description**
|
||||
|
||||
<!-- A clear and concise description of the problem. -->
|
||||
|
||||
:link: **Link to the badge**
|
||||
|
||||
<!--
|
||||
If you are reporting a problem with a specific badge on shields.io,
|
||||
provide a link to a badge demonstrating the error
|
||||
-->
|
||||
|
||||
:bulb: **Possible Solution**
|
||||
|
||||
<!--- Optional: only if you have suggestions on a fix/reason for the bug -->
|
||||
|
||||
<!-- Love Shields? Please consider donating $10 to sustain our activities:
|
||||
👉 https://opencollective.com/shields -->
|
||||
44
.github/ISSUE_TEMPLATE/1_Bug_report.yml
vendored
Normal file
44
.github/ISSUE_TEMPLATE/1_Bug_report.yml
vendored
Normal file
@@ -0,0 +1,44 @@
|
||||
name: '🐛 Bug Report'
|
||||
description: Report errors and problems
|
||||
labels: [question]
|
||||
body:
|
||||
- type: dropdown
|
||||
id: product
|
||||
attributes:
|
||||
label: Are you experiencing an issue with...
|
||||
options:
|
||||
- shields.io
|
||||
- My own instance of shields
|
||||
- badge-maker NPM package
|
||||
validations:
|
||||
required: true
|
||||
|
||||
- type: textarea
|
||||
id: description
|
||||
attributes:
|
||||
label: '🐞 Description'
|
||||
description: A clear and concise description of the problem.
|
||||
validations:
|
||||
required: true
|
||||
|
||||
- type: textarea
|
||||
id: link
|
||||
attributes:
|
||||
label: '🔗 Link to the badge'
|
||||
description: If you are reporting a problem with a specific badge on shields.io, provide a link to a badge demonstrating the error
|
||||
validations:
|
||||
required: false
|
||||
|
||||
- type: textarea
|
||||
id: possible-solution
|
||||
attributes:
|
||||
label: '💡 Possible Solution'
|
||||
description: 'Optional: only if you have suggestions on a fix/reason for the bug'
|
||||
validations:
|
||||
required: false
|
||||
|
||||
- type: markdown
|
||||
attributes:
|
||||
value: |
|
||||
## :heart: Love Shields?
|
||||
Please consider donating $10 to sustain our activities: [https://opencollective.com/shields](https://opencollective.com/shields)
|
||||
6
.github/actions/approve-bot/package-lock.json
generated
vendored
6
.github/actions/approve-bot/package-lock.json
generated
vendored
@@ -5,9 +5,9 @@
|
||||
"requires": true,
|
||||
"dependencies": {
|
||||
"@actions/core": {
|
||||
"version": "1.3.0",
|
||||
"resolved": "https://registry.npmjs.org/@actions/core/-/core-1.3.0.tgz",
|
||||
"integrity": "sha512-xxtX0Cwdhb8LcgatfJkokqT8KzPvcIbwL9xpLU09nOwBzaStbfm0dNncsP0M4us+EpoPdWy7vbzU5vSOH7K6pg=="
|
||||
"version": "1.4.0",
|
||||
"resolved": "https://registry.npmjs.org/@actions/core/-/core-1.4.0.tgz",
|
||||
"integrity": "sha512-CGx2ilGq5i7zSLgiiGUtBCxhRRxibJYU6Fim0Q1Wg2aQL2LTnF27zbqZOrxfvFQ55eSBW0L8uVStgtKMpa0Qlg=="
|
||||
},
|
||||
"@actions/github": {
|
||||
"version": "5.0.0",
|
||||
|
||||
2
.github/actions/approve-bot/package.json
vendored
2
.github/actions/approve-bot/package.json
vendored
@@ -10,7 +10,7 @@
|
||||
"author": "chris48s",
|
||||
"license": "CC0",
|
||||
"dependencies": {
|
||||
"@actions/core": "^1.3.0",
|
||||
"@actions/core": "^1.4.0",
|
||||
"@actions/github": "^5.0.0"
|
||||
}
|
||||
}
|
||||
|
||||
11
CHANGELOG.md
11
CHANGELOG.md
@@ -4,6 +4,17 @@ Note: this changelog is for the shields.io server. The changelog for the badge-m
|
||||
|
||||
---
|
||||
|
||||
## server-2021-07-01
|
||||
|
||||
- improve [MavenCentral], [MavenMetadata], and [GradlePluginPortal] [#6628](https://github.com/badges/shields/issues/6628)
|
||||
- fix: fix regex to match [codecov]'s flags [#6655](https://github.com/badges/shields/issues/6655)
|
||||
- fix usage style [#6638](https://github.com/badges/shields/issues/6638)
|
||||
- update simple-icons to v5 with by-name lookup backwards compatibility [#6591](https://github.com/badges/shields/issues/6591)
|
||||
- [GradlePluginPortal] add gradle plugin portal [#6449](https://github.com/badges/shields/issues/6449)
|
||||
- upgrade some vulnerable packages [#6569](https://github.com/badges/shields/issues/6569)
|
||||
- increase max-age for download and social badges [#6567](https://github.com/badges/shields/issues/6567)
|
||||
- Dependency updates
|
||||
|
||||
## server-2021-06-01
|
||||
|
||||
- Changed creating badges to open a new Window/Tab [#6536](https://github.com/badges/shields/issues/6536)
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
FROM node:12-alpine
|
||||
FROM node:14-alpine
|
||||
|
||||
RUN mkdir -p /usr/src/app
|
||||
RUN mkdir /usr/src/app/private
|
||||
|
||||
18
README.md
18
README.md
@@ -96,13 +96,13 @@ You can read a [tutorial on how to add a badge][tutorial].
|
||||
[](https://github.com/badges/shields/issues?q=is%3Aissue+is%3Aopen+label%3A%22good+first+issue%22)
|
||||
|
||||
[service-tests]: https://github.com/badges/shields/blob/master/doc/service-tests.md
|
||||
[tutorial]: doc/TUTORIAL.md
|
||||
[contributing]: CONTRIBUTING.md
|
||||
[tutorial]: https://github.com/badges/shields/blob/master/doc/TUTORIAL.md
|
||||
[contributing]: https://github.com/badges/shields/blob/master/CONTRIBUTING.md
|
||||
|
||||
## Development
|
||||
|
||||
1. Install Node 12 or later. You can use the [package manager][] of your choice.
|
||||
Tests need to pass in Node 12 and 14.
|
||||
1. Install Node 14 or later. You can use the [package manager][] of your choice.
|
||||
Tests need to pass in Node 14 and 16.
|
||||
2. Clone this repository.
|
||||
3. Run `npm ci` to install the dependencies.
|
||||
4. Run `npm start` to start the badge server and the frontend dev server.
|
||||
@@ -142,9 +142,9 @@ Daily tests, including a full run of the service tests and overall code coverage
|
||||
[gitpod]: https://www.gitpod.io/
|
||||
[snapshot tests]: https://glebbahmutov.com/blog/snapshot-testing/
|
||||
[prometheus]: https://prometheus.io/
|
||||
[prometheus configuration]: doc/self-hosting.md#prometheus
|
||||
[prometheus configuration]: https://github.com/badges/shields/blob/master/doc/self-hosting.md#prometheus
|
||||
[sentry]: https://sentry.io/
|
||||
[sentry configuration]: doc/self-hosting.md#sentry
|
||||
[sentry configuration]: https://github.com/badges/shields/blob/master/doc/self-hosting.md#sentry
|
||||
[daily-tests]: https://github.com/badges/daily-tests
|
||||
[nodemon]: https://nodemon.io/
|
||||
[nodemon debug]: https://github.com/Microsoft/vscode-recipes/tree/master/nodemon
|
||||
@@ -154,7 +154,7 @@ Daily tests, including a full run of the service tests and overall code coverage
|
||||
|
||||
There is documentation about [hosting your own server][self-hosting].
|
||||
|
||||
[self-hosting]: doc/self-hosting.md
|
||||
[self-hosting]: https://github.com/badges/shields/blob/master/doc/self-hosting.md
|
||||
|
||||
## History
|
||||
|
||||
@@ -179,8 +179,8 @@ You can read more about [the project's inception][thread],
|
||||
[olivierlacan]: https://github.com/olivierlacan
|
||||
[espadrine]: https://github.com/espadrine
|
||||
[old-gh-badges]: https://github.com/badges/gh-badges
|
||||
[motivation]: spec/motivation.md
|
||||
[spec]: spec/SPECIFICATION.md
|
||||
[motivation]: https://github.com/badges/shields/blob/master/spec/motivation.md
|
||||
[spec]: https://github.com/badges/shields/blob/master/spec/SPECIFICATION.md
|
||||
[thread]: https://github.com/h5bp/lazyweb-requests/issues/150
|
||||
|
||||
## Project leaders
|
||||
|
||||
@@ -26,8 +26,8 @@
|
||||
"badge": "lib/badge-cli.js"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">= 10",
|
||||
"npm": ">= 5"
|
||||
"node": ">= 12",
|
||||
"npm": ">= 6"
|
||||
},
|
||||
"collective": {
|
||||
"type": "opencollective",
|
||||
|
||||
@@ -17,7 +17,9 @@ const trace = require('./trace')
|
||||
const attrSchema = Joi.object({
|
||||
name: Joi.string().min(3),
|
||||
category: isValidCategory,
|
||||
isDeprecated: Joi.boolean().default(true),
|
||||
route: isValidRoute,
|
||||
examples: Joi.array().has(Joi.object()).default([]),
|
||||
transformPath: Joi.func()
|
||||
.maxArity(1)
|
||||
.required()
|
||||
@@ -34,7 +36,9 @@ module.exports = function redirector(attrs) {
|
||||
const {
|
||||
name,
|
||||
category,
|
||||
isDeprecated,
|
||||
route,
|
||||
examples,
|
||||
transformPath,
|
||||
transformQueryParams,
|
||||
overrideTransformedQueryParams,
|
||||
@@ -48,8 +52,9 @@ module.exports = function redirector(attrs) {
|
||||
})}Redirect`
|
||||
|
||||
static category = category
|
||||
static isDeprecated = true
|
||||
static isDeprecated = isDeprecated
|
||||
static route = route
|
||||
static examples = examples
|
||||
|
||||
static register({ camp, metricInstance }, { rasterUrl }) {
|
||||
const { regex, captureNames } = prepareRoute({
|
||||
|
||||
@@ -47,6 +47,24 @@ describe('Redirector', function () {
|
||||
).to.throw('"dateAdded" is required')
|
||||
})
|
||||
|
||||
it('sets specified example', function () {
|
||||
const examples = [
|
||||
{
|
||||
title: 'very old service',
|
||||
pattern: ':namedParamA',
|
||||
namedParams: {
|
||||
namedParamA: 'namedParamAValue',
|
||||
},
|
||||
staticPreview: {
|
||||
label: 'service',
|
||||
message: 'v0.14.0',
|
||||
color: 'blue',
|
||||
},
|
||||
},
|
||||
]
|
||||
expect(redirector({ ...attrs, examples }).examples).to.equal(examples)
|
||||
})
|
||||
|
||||
describe('ScoutCamp integration', function () {
|
||||
let port, baseUrl
|
||||
beforeEach(async function () {
|
||||
|
||||
@@ -21,11 +21,11 @@ Please [improve the tutorial](https://github.com/badges/shields/edit/master/doc/
|
||||
|
||||
You should have [git](https://git-scm.com/) installed.
|
||||
If you do not, [install git](https://www.linode.com/docs/development/version-control/how-to-install-git-on-linux-mac-and-windows/)
|
||||
and learn about the [Github workflow](http://try.github.io/).
|
||||
and learn about the [GitHub workflow](http://try.github.io/).
|
||||
|
||||
#### Node, NPM
|
||||
|
||||
Node >=12 and NPM >=7 is required. If you don't already have them,
|
||||
Node >=14 and NPM >=7 is required. If you don't already have them,
|
||||
install node and npm: https://nodejs.org/en/download/
|
||||
|
||||
### Setup a dev install
|
||||
|
||||
@@ -4,9 +4,11 @@
|
||||
|
||||
### SimpleIcons
|
||||
|
||||
We support a wide range of logos via [SimpleIcons][]. They can be referenced by name e.g:
|
||||
We support a wide range of logos via [SimpleIcons][]. They should be referenced by the logo slug e.g:
|
||||
|
||||
 - https://img.shields.io/npm/v/npm.svg?logo=javascript
|
||||
 - https://img.shields.io/npm/v/npm.svg?logo=nodedotjs
|
||||
|
||||
The set of Simple Icon slugs can be found in the [slugs.md](https://github.com/simple-icons/simple-icons/blob/develop/slugs.md) file in the Simple Icons repository. NB - the Simple Icons site and that slugs.md page may at times contain new icons that haven't yet been pulled into the Shields.io runtime. More information on how and when we incorporate icon updates can be found [here](https://github.com/badges/shields/discussions/5369).
|
||||
|
||||
### Shields logos
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@ This document describes how to host your own shields server either from source o
|
||||
|
||||
## Installing from Source
|
||||
|
||||
You will need Node 12 or later, which you can install using a
|
||||
You will need Node 14 or later, which you can install using a
|
||||
[package manager][].
|
||||
|
||||
On Ubuntu / Debian:
|
||||
|
||||
@@ -121,12 +121,12 @@ Drone instance and obtain a token from the user profile page.
|
||||
- `GITHUB_URL` (yml: `public.services.github.baseUri`)
|
||||
- `GH_TOKEN` (yml: `private.gh_token`)
|
||||
|
||||
Because of Github rate limits, you will need to provide a token, or else badges
|
||||
Because of GitHub rate limits, you will need to provide a token, or else badges
|
||||
will stop working once you hit 60 requests per hour, the
|
||||
[unauthenticated rate limit][github rate limit].
|
||||
|
||||
You can [create a personal access token][personal access tokens] through the
|
||||
Github website. When you create the token, you can choose to give read access
|
||||
GitHub website. When you create the token, you can choose to give read access
|
||||
to your repositories. If you do that, your self-hosted Shields installation
|
||||
will have access to your private repositories.
|
||||
|
||||
|
||||
@@ -45,10 +45,9 @@ export default function Main({
|
||||
}): JSX.Element {
|
||||
const [searchIsInProgress, setSearchIsInProgress] = useState(false)
|
||||
const [queryIsTooShort, setQueryIsTooShort] = useState(false)
|
||||
const [searchResults, setSearchResults] =
|
||||
useState<{
|
||||
[k: string]: ServiceDefinition[]
|
||||
}>()
|
||||
const [searchResults, setSearchResults] = useState<{
|
||||
[k: string]: ServiceDefinition[]
|
||||
}>()
|
||||
const [selectedExample, setSelectedExample] = useState<RenderableExample>()
|
||||
const [selectedExampleIsSuggestion, setSelectedExampleIsSuggestion] =
|
||||
useState(false)
|
||||
|
||||
@@ -335,10 +335,12 @@ export default function Usage({ baseUrl }: { baseUrl: string }): JSX.Element {
|
||||
>
|
||||
simple-icons
|
||||
</a>
|
||||
. Simple-icons are referenced using names as they appear on the
|
||||
simple-icons site. If the name includes spaces, replace them
|
||||
with dashes (e.g:{' '}
|
||||
<StyledCode>?logo=visual-studio-code</StyledCode>)
|
||||
. Simple-icons are referenced using icon slugs which can be
|
||||
found on the simple-icons site or in the{' '}
|
||||
<a href="https://github.com/simple-icons/simple-icons/blob/develop/slugs.md">
|
||||
slugs.md file
|
||||
</a>{' '}
|
||||
in the simple-icons repository.
|
||||
</span>
|
||||
}
|
||||
key="logo"
|
||||
|
||||
@@ -5,18 +5,37 @@ const { svg2base64 } = require('./svg-helpers')
|
||||
|
||||
function loadSimpleIcons() {
|
||||
const simpleIcons = {}
|
||||
// As of v5 the exported keys are the svg slugs
|
||||
// Historically, Shields has supported logo specification via
|
||||
// name, name with spaces replaced by hyphens, and partially slugs
|
||||
// albeit only in cases where the slug happened to match one of those.
|
||||
// For backwards compatibility purposes we now support all three, but
|
||||
// do not broadcast the support for by-title references due to our strong
|
||||
// preference to steer users towards using the actual slugs.
|
||||
// https://github.com/badges/shields/pull/6591
|
||||
// https://github.com/badges/shields/issues/4273
|
||||
Object.keys(originalSimpleIcons).forEach(key => {
|
||||
const k = key.toLowerCase().replace(/ /g, '-')
|
||||
simpleIcons[k] = originalSimpleIcons[key]
|
||||
simpleIcons[k].base64 = {
|
||||
default: svg2base64(
|
||||
simpleIcons[k].svg.replace('<svg', `<svg fill="#${simpleIcons[k].hex}"`)
|
||||
),
|
||||
light: svg2base64(
|
||||
simpleIcons[k].svg.replace('<svg', `<svg fill="whitesmoke"`)
|
||||
),
|
||||
dark: svg2base64(simpleIcons[k].svg.replace('<svg', `<svg fill="#333"`)),
|
||||
const icon = originalSimpleIcons[key]
|
||||
const title = icon.title.toLowerCase()
|
||||
const legacyTitle = title.replace(/ /g, '-')
|
||||
icon.base64 = {
|
||||
default: svg2base64(icon.svg.replace('<svg', `<svg fill="#${icon.hex}"`)),
|
||||
light: svg2base64(icon.svg.replace('<svg', `<svg fill="whitesmoke"`)),
|
||||
dark: svg2base64(icon.svg.replace('<svg', `<svg fill="#333"`)),
|
||||
}
|
||||
|
||||
// There are a few instances where multiple icons have the same title
|
||||
// (e.g. 'Hive'). If a by-title reference we generate for
|
||||
// backwards compatibility collides with a proper slug from Simple Icons
|
||||
// then do nothing, so that the proper slug will always map to the correct icon.
|
||||
if (!(title in originalSimpleIcons)) {
|
||||
simpleIcons[title] = icon
|
||||
}
|
||||
if (!(legacyTitle in originalSimpleIcons)) {
|
||||
simpleIcons[legacyTitle] = icon
|
||||
}
|
||||
|
||||
simpleIcons[key] = icon
|
||||
})
|
||||
return simpleIcons
|
||||
}
|
||||
|
||||
@@ -18,7 +18,11 @@ describe('loadSimpleIcons', function () {
|
||||
})
|
||||
|
||||
it('normalizes icon keys', function () {
|
||||
// original key in the simple-icons is 'Linux Foundation'
|
||||
// As of v5 of simple-icons the slug and exported key is `linuxfoundation`
|
||||
// with a name of `Linux Foundation`, so ensure we support both as well
|
||||
// as the legacy mapping of `linux-foundation` for backwards compatibility.
|
||||
expect(simpleIcons).to.include.key('linuxfoundation')
|
||||
expect(simpleIcons).to.include.key('linux foundation')
|
||||
expect(simpleIcons).to.include.key('linux-foundation')
|
||||
})
|
||||
|
||||
@@ -26,4 +30,13 @@ describe('loadSimpleIcons', function () {
|
||||
it('excludes "get" function provided by the simple-icons', function () {
|
||||
expect(simpleIcons).to.not.have.property('get')
|
||||
})
|
||||
|
||||
it('maps overlapping icon titles correctly', function () {
|
||||
// Both of these icons have the same title: 'Hive', so make sure
|
||||
// the proper slugs are still mapped to the correct logo
|
||||
expect(simpleIcons.hive.slug).to.equal('hive')
|
||||
expect(simpleIcons.hive.title).to.equal('Hive')
|
||||
expect(simpleIcons.hive_blockchain.slug).to.equal('hive_blockchain')
|
||||
expect(simpleIcons.hive_blockchain.title).to.equal('Hive')
|
||||
})
|
||||
})
|
||||
|
||||
6964
package-lock.json
generated
6964
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
60
package.json
60
package.json
@@ -22,9 +22,9 @@
|
||||
"url": "https://github.com/badges/shields"
|
||||
},
|
||||
"dependencies": {
|
||||
"@fontsource/lato": "^4.4.1",
|
||||
"@fontsource/lekton": "^4.4.0",
|
||||
"@sentry/node": "^6.4.1",
|
||||
"@fontsource/lato": "^4.4.5",
|
||||
"@fontsource/lekton": "^4.4.5",
|
||||
"@sentry/node": "^6.7.2",
|
||||
"@shields_io/camp": "^18.1.1",
|
||||
"badge-maker": "file:badge-maker",
|
||||
"bytes": "^3.1.0",
|
||||
@@ -42,7 +42,7 @@
|
||||
"got": "11.8.2",
|
||||
"graphql": "^15.5.0",
|
||||
"graphql-tag": "^2.12.4",
|
||||
"ioredis": "4.27.3",
|
||||
"ioredis": "4.27.6",
|
||||
"joi": "17.4.0",
|
||||
"joi-extension-semver": "5.0.0",
|
||||
"js-yaml": "^4.1.0",
|
||||
@@ -57,11 +57,11 @@
|
||||
"pretty-bytes": "^5.6.0",
|
||||
"priorityqueuejs": "^2.0.0",
|
||||
"prom-client": "^13.1.0",
|
||||
"query-string": "^7.0.0",
|
||||
"query-string": "^7.0.1",
|
||||
"request": "~2.88.2",
|
||||
"semver": "~7.3.5",
|
||||
"simple-icons": "4.25.0",
|
||||
"webextension-store-meta": "^1.0.3",
|
||||
"simple-icons": "5.3.0",
|
||||
"webextension-store-meta": "^1.0.4",
|
||||
"xmldom": "~0.6.0",
|
||||
"xpath": "~0.0.32"
|
||||
},
|
||||
@@ -141,21 +141,21 @@
|
||||
]
|
||||
},
|
||||
"devDependencies": {
|
||||
"@babel/core": "^7.14.3",
|
||||
"@babel/core": "^7.14.6",
|
||||
"@babel/polyfill": "^7.12.1",
|
||||
"@babel/register": "7.13.16",
|
||||
"@babel/register": "7.14.5",
|
||||
"@mapbox/react-click-to-select": "^2.2.1",
|
||||
"@types/chai": "^4.2.18",
|
||||
"@types/chai": "^4.2.19",
|
||||
"@types/lodash.debounce": "^4.0.6",
|
||||
"@types/lodash.groupby": "^4.6.6",
|
||||
"@types/mocha": "^8.2.2",
|
||||
"@types/node": "^15.6.1",
|
||||
"@types/node": "^15.12.4",
|
||||
"@types/react-helmet": "^6.1.1",
|
||||
"@types/react-modal": "^3.12.0",
|
||||
"@types/react-select": "^4.0.15",
|
||||
"@types/styled-components": "5.1.9",
|
||||
"@typescript-eslint/eslint-plugin": "^4.25.0",
|
||||
"@typescript-eslint/parser": "^4.23.0",
|
||||
"@types/react-select": "^4.0.16",
|
||||
"@types/styled-components": "5.1.10",
|
||||
"@typescript-eslint/eslint-plugin": "^4.28.0",
|
||||
"@typescript-eslint/parser": "^4.27.0",
|
||||
"babel-plugin-inline-react-svg": "^2.0.1",
|
||||
"babel-plugin-istanbul": "^6.0.0",
|
||||
"babel-preset-gatsby": "^1.2.0",
|
||||
@@ -167,31 +167,31 @@
|
||||
"child-process-promise": "^2.2.1",
|
||||
"clipboard-copy": "^4.0.1",
|
||||
"concurrently": "^6.2.0",
|
||||
"cypress": "^7.4.0",
|
||||
"cypress": "^7.6.0",
|
||||
"danger": "^10.6.4",
|
||||
"danger-plugin-no-test-shortcuts": "^2.0.0",
|
||||
"deepmerge": "^4.2.2",
|
||||
"eslint": "^7.27.0",
|
||||
"eslint": "^7.29.0",
|
||||
"eslint-config-prettier": "^8.3.0",
|
||||
"eslint-config-standard": "^16.0.3",
|
||||
"eslint-config-standard-jsx": "^10.0.0",
|
||||
"eslint-config-standard-react": "^11.0.1",
|
||||
"eslint-plugin-chai-friendly": "^0.7.1",
|
||||
"eslint-plugin-cypress": "^2.11.3",
|
||||
"eslint-plugin-import": "^2.23.3",
|
||||
"eslint-plugin-jsdoc": "^35.0.0",
|
||||
"eslint-plugin-import": "^2.23.4",
|
||||
"eslint-plugin-jsdoc": "^35.4.0",
|
||||
"eslint-plugin-mocha": "^9.0.0",
|
||||
"eslint-plugin-no-extension-in-require": "^0.2.0",
|
||||
"eslint-plugin-node": "^11.1.0",
|
||||
"eslint-plugin-promise": "^5.1.0",
|
||||
"eslint-plugin-react": "^7.23.2",
|
||||
"eslint-plugin-react": "^7.24.0",
|
||||
"eslint-plugin-react-hooks": "^4.2.0",
|
||||
"eslint-plugin-sort-class-members": "^1.11.0",
|
||||
"fetch-ponyfill": "^7.1.0",
|
||||
"form-data": "^4.0.0",
|
||||
"gatsby": "3.6.1",
|
||||
"gatsby": "3.8.0",
|
||||
"gatsby-plugin-catch-links": "^3.1.0",
|
||||
"gatsby-plugin-page-creator": "^3.6.0",
|
||||
"gatsby-plugin-page-creator": "^3.8.0",
|
||||
"gatsby-plugin-react-helmet": "^4.1.0",
|
||||
"gatsby-plugin-remove-trailing-slashes": "^3.1.0",
|
||||
"gatsby-plugin-styled-components": "^4.6.0",
|
||||
@@ -207,23 +207,23 @@
|
||||
"lodash.debounce": "^4.0.8",
|
||||
"lodash.difference": "^4.5.0",
|
||||
"minimist": "^1.2.5",
|
||||
"mocha": "^8.4.0",
|
||||
"mocha": "^9.0.1",
|
||||
"mocha-env-reporter": "^4.0.0",
|
||||
"mocha-junit-reporter": "^2.0.0",
|
||||
"mocha-yaml-loader": "^1.0.3",
|
||||
"nock": "13.0.11",
|
||||
"nock": "13.1.0",
|
||||
"node-mocks-http": "^1.10.1",
|
||||
"nodemon": "^2.0.7",
|
||||
"npm-run-all": "^4.1.5",
|
||||
"nyc": "^15.1.0",
|
||||
"opn-cli": "^5.0.0",
|
||||
"portfinder": "^1.0.28",
|
||||
"prettier": "2.3.0",
|
||||
"prettier": "2.3.1",
|
||||
"react": "^17.0.2",
|
||||
"react-dom": "^17.0.2",
|
||||
"react-error-overlay": "^6.0.9",
|
||||
"react-helmet": "^6.1.0",
|
||||
"react-modal": "^3.13.1",
|
||||
"react-modal": "^3.14.3",
|
||||
"react-pose": "^4.0.10",
|
||||
"react-select": "^4.3.1",
|
||||
"read-all-stdin-sync": "^1.0.5",
|
||||
@@ -234,14 +234,14 @@
|
||||
"sinon": "^11.1.1",
|
||||
"sinon-chai": "^3.7.0",
|
||||
"snap-shot-it": "^7.9.6",
|
||||
"start-server-and-test": "1.12.3",
|
||||
"start-server-and-test": "1.12.5",
|
||||
"styled-components": "^5.3.0",
|
||||
"ts-mocha": "^8.0.0",
|
||||
"tsd": "^0.14.0",
|
||||
"typescript": "^4.3.2"
|
||||
"tsd": "^0.17.0",
|
||||
"typescript": "^4.3.4"
|
||||
},
|
||||
"engines": {
|
||||
"node": "^12.18.3",
|
||||
"node": "^14.17.1",
|
||||
"npm": ">=7.0.0"
|
||||
},
|
||||
"babel": {
|
||||
|
||||
@@ -22,8 +22,9 @@ const legacySchema = Joi.object({
|
||||
const queryParamSchema = Joi.object({
|
||||
token: Joi.string(),
|
||||
// https://docs.codecov.io/docs/flags
|
||||
// Flags must be lowercase, alphanumeric, and not exceed 45 characters
|
||||
flag: Joi.string().regex(/^[a-z0-9_]{1,45}$/),
|
||||
// Flags Must consist only of alphanumeric characters, '_', '-', or '.'
|
||||
// and not exceed 45 characters.
|
||||
flag: Joi.string().regex(/^[\w.-]{1,45}$/),
|
||||
}).required()
|
||||
|
||||
const schema = Joi.object({
|
||||
|
||||
@@ -0,0 +1,43 @@
|
||||
'use strict'
|
||||
|
||||
const { redirector } = require('..')
|
||||
const { documentation } = require('../maven-metadata/maven-metadata')
|
||||
|
||||
module.exports = redirector({
|
||||
category: 'version',
|
||||
isDeprecated: false,
|
||||
route: {
|
||||
base: 'gradle-plugin-portal/v',
|
||||
pattern: ':pluginId',
|
||||
},
|
||||
examples: [
|
||||
{
|
||||
title: 'Gradle Plugin Portal',
|
||||
queryParams: {
|
||||
versionSuffix: '.1',
|
||||
versionPrefix: '0.10',
|
||||
},
|
||||
namedParams: {
|
||||
pluginId: 'com.gradle.plugin-publish',
|
||||
},
|
||||
staticPreview: {
|
||||
label: 'plugin portal',
|
||||
message: 'v0.10.1',
|
||||
color: 'blue',
|
||||
},
|
||||
documentation,
|
||||
},
|
||||
],
|
||||
transformPath: () => `/maven-metadata/v`,
|
||||
transformQueryParams: ({ pluginId }) => {
|
||||
const groupPath = pluginId.replace(/\./g, '/')
|
||||
const artifactId = `${pluginId}.gradle.plugin`
|
||||
const metadataUrl = `https://plugins.gradle.org/m2/${groupPath}/${artifactId}/maven-metadata.xml`
|
||||
return {
|
||||
metadataUrl,
|
||||
label: 'plugin portal',
|
||||
}
|
||||
},
|
||||
overrideTransformedQueryParams: true,
|
||||
dateAdded: new Date('2021-05-30'),
|
||||
})
|
||||
27
services/gradle-plugin-portal/gradle-plugin-portal.tester.js
Normal file
27
services/gradle-plugin-portal/gradle-plugin-portal.tester.js
Normal file
@@ -0,0 +1,27 @@
|
||||
'use strict'
|
||||
|
||||
const t = (module.exports = require('../tester').createServiceTester())
|
||||
|
||||
t.create('gradle plugin portal')
|
||||
.get('/com.gradle.plugin-publish')
|
||||
.expectRedirect(
|
||||
`/maven-metadata/v.svg?label=plugin%20portal&metadataUrl=${encodeURIComponent(
|
||||
'https://plugins.gradle.org/m2/com/gradle/plugin-publish/com.gradle.plugin-publish.gradle.plugin/maven-metadata.xml'
|
||||
)}`
|
||||
)
|
||||
|
||||
t.create('gradle plugin portal with custom labels')
|
||||
.get('/com.gradle.plugin-publish?label=custom%20label')
|
||||
.expectRedirect(
|
||||
`/maven-metadata/v.svg?label=custom%20label&metadataUrl=${encodeURIComponent(
|
||||
'https://plugins.gradle.org/m2/com/gradle/plugin-publish/com.gradle.plugin-publish.gradle.plugin/maven-metadata.xml'
|
||||
)}`
|
||||
)
|
||||
|
||||
t.create('gradle plugin portal with custom color')
|
||||
.get('/com.gradle.plugin-publish?color=gray')
|
||||
.expectRedirect(
|
||||
`/maven-metadata/v.svg?color=gray&label=plugin%20portal&metadataUrl=${encodeURIComponent(
|
||||
'https://plugins.gradle.org/m2/com/gradle/plugin-publish/com.gradle.plugin-publish.gradle.plugin/maven-metadata.xml'
|
||||
)}`
|
||||
)
|
||||
@@ -1,82 +1,46 @@
|
||||
'use strict'
|
||||
|
||||
const Joi = require('joi')
|
||||
const { renderVersionBadge } = require('../version')
|
||||
const { BaseXmlService, NotFound } = require('..')
|
||||
const { redirector } = require('..')
|
||||
const { documentation } = require('../maven-metadata/maven-metadata')
|
||||
|
||||
const schema = Joi.object({
|
||||
metadata: Joi.object({
|
||||
versioning: Joi.object({
|
||||
versions: Joi.object({
|
||||
version: Joi.array().items(Joi.string().required()).single().required(),
|
||||
}).required(),
|
||||
}).required(),
|
||||
}).required(),
|
||||
}).required()
|
||||
|
||||
module.exports = class MavenCentral extends BaseXmlService {
|
||||
static category = 'version'
|
||||
|
||||
static route = {
|
||||
module.exports = redirector({
|
||||
category: 'version',
|
||||
isDeprecated: false,
|
||||
route: {
|
||||
base: 'maven-central/v',
|
||||
pattern: ':groupId/:artifactId/:versionPrefix?',
|
||||
}
|
||||
|
||||
static examples = [
|
||||
},
|
||||
examples: [
|
||||
{
|
||||
title: 'Maven Central',
|
||||
pattern: ':groupId/:artifactId',
|
||||
queryParams: {
|
||||
versionSuffix: '-android',
|
||||
versionPrefix: '29',
|
||||
},
|
||||
namedParams: {
|
||||
groupId: 'org.apache.maven',
|
||||
artifactId: 'apache-maven',
|
||||
groupId: 'com.google.guava',
|
||||
artifactId: 'guava',
|
||||
},
|
||||
staticPreview: {
|
||||
label: 'maven-central',
|
||||
message: 'v3.6.0',
|
||||
message: 'v29.0-android',
|
||||
color: 'blue',
|
||||
},
|
||||
documentation,
|
||||
},
|
||||
{
|
||||
title: 'Maven Central with version prefix filter',
|
||||
pattern: ':groupId/:artifactId/:versionPrefix',
|
||||
namedParams: {
|
||||
groupId: 'org.apache.maven',
|
||||
artifactId: 'apache-maven',
|
||||
versionPrefix: '2',
|
||||
},
|
||||
staticPreview: {
|
||||
label: 'maven-central',
|
||||
message: 'v2.2.1',
|
||||
color: 'blue',
|
||||
},
|
||||
},
|
||||
]
|
||||
|
||||
static defaultBadgeData = {
|
||||
label: 'maven-central',
|
||||
}
|
||||
|
||||
async fetch({ groupId, artifactId }) {
|
||||
],
|
||||
transformPath: () => `/maven-metadata/v`,
|
||||
transformQueryParams: ({ groupId, artifactId, versionPrefix }) => {
|
||||
const group = encodeURIComponent(groupId).replace(/\./g, '/')
|
||||
const artifact = encodeURIComponent(artifactId)
|
||||
const url = `https://repo1.maven.org/maven2/${group}/${artifact}/maven-metadata.xml`
|
||||
return this._requestXml({
|
||||
schema,
|
||||
url,
|
||||
parserOptions: { parseNodeValue: false },
|
||||
})
|
||||
}
|
||||
|
||||
async handle({ groupId, artifactId, versionPrefix }) {
|
||||
const data = await this.fetch({ groupId, artifactId })
|
||||
const versions = data.metadata.versioning.versions.version.reverse()
|
||||
let version = versions[0]
|
||||
if (versionPrefix !== undefined) {
|
||||
version = versions.filter(v => v.toString().startsWith(versionPrefix))[0]
|
||||
// if the filter returned no results, throw a NotFound
|
||||
if (version === undefined)
|
||||
throw new NotFound({ prettyMessage: 'version prefix not found' })
|
||||
const metadataUrl = `https://repo1.maven.org/maven2/${group}/${artifact}/maven-metadata.xml`
|
||||
return {
|
||||
metadataUrl,
|
||||
label: 'maven-central',
|
||||
versionPrefix,
|
||||
}
|
||||
return renderVersionBadge({ version })
|
||||
}
|
||||
}
|
||||
},
|
||||
overrideTransformedQueryParams: true,
|
||||
dateAdded: new Date('2021-06-12'),
|
||||
})
|
||||
|
||||
@@ -1,53 +1,19 @@
|
||||
'use strict'
|
||||
|
||||
const {
|
||||
isVPlusDottedVersionNClausesWithOptionalSuffix,
|
||||
} = require('../test-validators')
|
||||
const t = (module.exports = require('../tester').createServiceTester())
|
||||
|
||||
t.create('latest version')
|
||||
t.create('latest version redirection')
|
||||
.get('/com.github.fabriziocucci/yacl4j.json') // http://repo1.maven.org/maven2/com/github/fabriziocucci/yacl4j/
|
||||
.expectBadge({
|
||||
label: 'maven-central',
|
||||
message: isVPlusDottedVersionNClausesWithOptionalSuffix,
|
||||
})
|
||||
|
||||
t.create('latest 0.8 version')
|
||||
.get('/com.github.fabriziocucci/yacl4j/0.8.json') // http://repo1.maven.org/maven2/com/github/fabriziocucci/yacl4j/
|
||||
.expectBadge({
|
||||
label: 'maven-central',
|
||||
message: isVPlusDottedVersionNClausesWithOptionalSuffix,
|
||||
})
|
||||
|
||||
t.create('inexistent artifact')
|
||||
.get('/inexistent-group-id/inexistent-artifact-id.json')
|
||||
.expectBadge({ label: 'maven-central', message: 'not found' })
|
||||
|
||||
t.create('inexistent version prefix')
|
||||
.get('/com.github.fabriziocucci/yacl4j/99.json')
|
||||
.expectBadge({ label: 'maven-central', message: 'version prefix not found' })
|
||||
|
||||
t.create('version ending with zero')
|
||||
.get('/mocked-group-id/mocked-artifact-id.json')
|
||||
.intercept(nock =>
|
||||
nock('https://repo1.maven.org/maven2')
|
||||
.get('/mocked-group-id/mocked-artifact-id/maven-metadata.xml')
|
||||
.reply(
|
||||
200,
|
||||
`
|
||||
<metadata>
|
||||
<groupId>mocked-group-id</groupId>
|
||||
<artifactId>mocked-artifact-id</artifactId>
|
||||
<versioning>
|
||||
<latest>1.30</latest>
|
||||
<release>1.30</release>
|
||||
<versions>
|
||||
<version>1.30</version>
|
||||
</versions>
|
||||
<lastUpdated>20190902002617</lastUpdated>
|
||||
</versioning>
|
||||
</metadata>
|
||||
`
|
||||
)
|
||||
.expectRedirect(
|
||||
`/maven-metadata/v.json?label=maven-central&metadataUrl=${encodeURIComponent(
|
||||
'https://repo1.maven.org/maven2/com/github/fabriziocucci/yacl4j/maven-metadata.xml'
|
||||
)}`
|
||||
)
|
||||
|
||||
t.create('latest 0.8 version redirection')
|
||||
.get('/com.github.fabriziocucci/yacl4j/0.8.json') // http://repo1.maven.org/maven2/com/github/fabriziocucci/yacl4j/
|
||||
.expectRedirect(
|
||||
`/maven-metadata/v.json?label=maven-central&metadataUrl=${encodeURIComponent(
|
||||
'https://repo1.maven.org/maven2/com/github/fabriziocucci/yacl4j/maven-metadata.xml'
|
||||
)}&versionPrefix=0.8`
|
||||
)
|
||||
.expectBadge({ label: 'maven-central', message: 'v1.30' })
|
||||
|
||||
13
services/maven-metadata/maven-metadata.js
Normal file
13
services/maven-metadata/maven-metadata.js
Normal file
@@ -0,0 +1,13 @@
|
||||
'use strict'
|
||||
|
||||
// the file contains common constants for badges uses maven-metadata
|
||||
|
||||
module.exports = {}
|
||||
|
||||
module.exports.documentation = `
|
||||
<p>
|
||||
<code>versionPrefix</code> and <code>versionSuffix</code> allow narrowing down
|
||||
the range of versions the badge will take into account,
|
||||
but they are completely optional.
|
||||
</p>
|
||||
`
|
||||
@@ -3,10 +3,13 @@
|
||||
const Joi = require('joi')
|
||||
const { optionalUrl } = require('../validators')
|
||||
const { renderVersionBadge } = require('../version')
|
||||
const { BaseXmlService } = require('..')
|
||||
const { BaseXmlService, NotFound } = require('..')
|
||||
const { documentation } = require('./maven-metadata')
|
||||
|
||||
const queryParamSchema = Joi.object({
|
||||
metadataUrl: optionalUrl.required(),
|
||||
versionPrefix: Joi.string().optional(),
|
||||
versionSuffix: Joi.string().optional(),
|
||||
}).required()
|
||||
|
||||
const schema = Joi.object({
|
||||
@@ -34,9 +37,12 @@ module.exports = class MavenMetadata extends BaseXmlService {
|
||||
namedParams: {},
|
||||
queryParams: {
|
||||
metadataUrl:
|
||||
'https://repo1.maven.org/maven2/com/google/code/gson/gson/maven-metadata.xml',
|
||||
'https://repo1.maven.org/maven2/com/google/guava/guava/maven-metadata.xml',
|
||||
versionPrefix: '29.',
|
||||
versionSuffix: '-android',
|
||||
},
|
||||
staticPreview: renderVersionBadge({ version: '2.8.5' }),
|
||||
staticPreview: renderVersionBadge({ version: '29.0-android' }),
|
||||
documentation,
|
||||
},
|
||||
]
|
||||
|
||||
@@ -52,10 +58,24 @@ module.exports = class MavenMetadata extends BaseXmlService {
|
||||
})
|
||||
}
|
||||
|
||||
async handle(_namedParams, { metadataUrl }) {
|
||||
async handle(_namedParams, { metadataUrl, versionPrefix, versionSuffix }) {
|
||||
const data = await this.fetch({ metadataUrl })
|
||||
return renderVersionBadge({
|
||||
version: data.metadata.versioning.versions.version.slice(-1)[0],
|
||||
})
|
||||
let versions = data.metadata.versioning.versions.version.reverse()
|
||||
if (versionPrefix !== undefined) {
|
||||
versions = versions.filter(v => v.toString().startsWith(versionPrefix))
|
||||
}
|
||||
if (versionSuffix !== undefined) {
|
||||
versions = versions.filter(v => v.toString().endsWith(versionSuffix))
|
||||
}
|
||||
const version = versions[0]
|
||||
// if the filter returned no results, throw a NotFound
|
||||
if (
|
||||
(versionPrefix !== undefined || versionSuffix !== undefined) &&
|
||||
version === undefined
|
||||
)
|
||||
throw new NotFound({
|
||||
prettyMessage: 'version prefix or suffix not found',
|
||||
})
|
||||
return renderVersionBadge({ version })
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
'use strict'
|
||||
|
||||
const Joi = require('joi')
|
||||
const t = (module.exports = require('../tester').createServiceTester())
|
||||
const { isVPlusDottedVersionAtLeastOne } = require('../test-validators')
|
||||
|
||||
@@ -12,6 +13,33 @@ t.create('valid maven-metadata.xml uri')
|
||||
message: isVPlusDottedVersionAtLeastOne,
|
||||
})
|
||||
|
||||
t.create('with version prefix')
|
||||
.get(
|
||||
'/v.json?metadataUrl=https://repo1.maven.org/maven2/com/google/guava/guava/maven-metadata.xml&versionPrefix=27.'
|
||||
)
|
||||
.expectBadge({
|
||||
label: 'maven',
|
||||
message: 'v27.1-jre',
|
||||
})
|
||||
|
||||
t.create('with version suffix')
|
||||
.get(
|
||||
'/v.json?metadataUrl=https://repo1.maven.org/maven2/com/google/guava/guava/maven-metadata.xml&versionSuffix=-android'
|
||||
)
|
||||
.expectBadge({
|
||||
label: 'maven',
|
||||
message: Joi.string().regex(/-android$/),
|
||||
})
|
||||
|
||||
t.create('with version prefix and suffix')
|
||||
.get(
|
||||
'/v.json?metadataUrl=https://repo1.maven.org/maven2/com/google/guava/guava/maven-metadata.xml&versionPrefix=27.&versionSuffix=-android'
|
||||
)
|
||||
.expectBadge({
|
||||
label: 'maven',
|
||||
message: 'v27.1-android',
|
||||
})
|
||||
|
||||
t.create('version ending with zero')
|
||||
.get(
|
||||
'/v.json?metadataUrl=https://repo1.maven.org/maven2/mocked-group-id/mocked-artifact-id/maven-metadata.xml'
|
||||
@@ -44,3 +72,21 @@ t.create('invalid maven-metadata.xml uri')
|
||||
'/v.json?metadataUrl=https://repo1.maven.org/maven2/com/google/code/gson/gson/foobar.xml'
|
||||
)
|
||||
.expectBadge({ label: 'maven', message: 'not found' })
|
||||
|
||||
t.create('inexistent version prefix')
|
||||
.get(
|
||||
'/v.json?metadataUrl=https://repo1.maven.org/maven2/com/github/fabriziocucci/yacl4j/maven-metadata.xml&versionPrefix=99'
|
||||
)
|
||||
.expectBadge({
|
||||
label: 'maven',
|
||||
message: 'version prefix or suffix not found',
|
||||
})
|
||||
|
||||
t.create('inexistent version suffix')
|
||||
.get(
|
||||
'/v.json?metadataUrl=https://repo1.maven.org/maven2/com/github/fabriziocucci/yacl4j/maven-metadata.xml&versionSuffix=test'
|
||||
)
|
||||
.expectBadge({
|
||||
label: 'maven',
|
||||
message: 'version prefix or suffix not found',
|
||||
})
|
||||
|
||||
@@ -64,16 +64,24 @@ const isStarRating = withRegex(
|
||||
// Required to be > 0, because accepting zero masks many problems.
|
||||
const isMetric = withRegex(/^([1-9][0-9]*[kMGTPEZY]?|[1-9]\.[1-9][kMGTPEZY])$/)
|
||||
|
||||
const isMetricOpenIssues = withRegex(
|
||||
/^([1-9][0-9]*[kMGTPEZY]?|[1-9]\.[1-9][kMGTPEZY]) open$/
|
||||
/**
|
||||
* @param {RegExp} nestedRegexp Pattern that must appear after the metric.
|
||||
* @returns {Function} A function that returns a RegExp that matches a metric followed by another pattern.
|
||||
*/
|
||||
const isMetricWithPattern = nestedRegexp => {
|
||||
const pattern = `^([1-9][0-9]*[kMGTPEZY]?|[1-9]\\.[1-9][kMGTPEZY])${nestedRegexp.source}$`
|
||||
const regexp = new RegExp(pattern)
|
||||
return withRegex(regexp)
|
||||
}
|
||||
|
||||
const isMetricOpenIssues = isMetricWithPattern(/ open/)
|
||||
|
||||
const isMetricOverMetric = isMetricWithPattern(
|
||||
/\/([1-9][0-9]*[kMGTPEZY]?|[1-9]\.[1-9][kMGTPEZY])/
|
||||
)
|
||||
|
||||
const isMetricOverMetric = withRegex(
|
||||
/^([1-9][0-9]*[kMGTPEZY]?|[1-9]\.[1-9][kMGTPEZY])\/([1-9][0-9]*[kMGTPEZY]?|[1-9]\.[1-9][kMGTPEZY])$/
|
||||
)
|
||||
|
||||
const isMetricOverTimePeriod = withRegex(
|
||||
/^([1-9][0-9]*[kMGTPEZY]?|[1-9]\.[1-9][kMGTPEZY])\/(year|month|four weeks|quarter|week|day)$/
|
||||
const isMetricOverTimePeriod = isMetricWithPattern(
|
||||
/\/(year|month|four weeks|quarter|week|day)/
|
||||
)
|
||||
|
||||
const isZeroOverTimePeriod = withRegex(
|
||||
@@ -151,6 +159,7 @@ module.exports = {
|
||||
isPhpVersionReduction,
|
||||
isStarRating,
|
||||
isMetric,
|
||||
isMetricWithPattern,
|
||||
isMetricOpenIssues,
|
||||
isMetricOverMetric,
|
||||
isMetricOverTimePeriod,
|
||||
|
||||
Reference in New Issue
Block a user