Compare commits
82 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
084285755f | ||
|
|
d0f3f2251f | ||
|
|
7b5f43fee8 | ||
|
|
8dee584f44 | ||
|
|
afedaa7c9f | ||
|
|
88ea1f9149 | ||
|
|
4225abba9b | ||
|
|
41a255739f | ||
|
|
4baeb72d6f | ||
|
|
01df5d6819 | ||
|
|
b8499716e0 | ||
|
|
0c141adf20 | ||
|
|
5dc5fbb15a | ||
|
|
c08588c51d | ||
|
|
69e4b5655c | ||
|
|
7830fba4c4 | ||
|
|
0c0151ce9a | ||
|
|
05cc23cabd | ||
|
|
f217c048a8 | ||
|
|
a8360ffda6 | ||
|
|
9ab4596654 | ||
|
|
064a3418a3 | ||
|
|
eaa5db56e3 | ||
|
|
c380a7576a | ||
|
|
2c04d9e9d1 | ||
|
|
f985cfc40a | ||
|
|
f6d0f5be8d | ||
|
|
800453ae6e | ||
|
|
010a15ac20 | ||
|
|
ff8d278dd6 | ||
|
|
02113acdff | ||
|
|
018e9bafa6 | ||
|
|
8788ad82e6 | ||
|
|
0ef261f219 | ||
|
|
57f4900ea0 | ||
|
|
80d1b4a75d | ||
|
|
5486e3f316 | ||
|
|
7b48fcb2da | ||
|
|
2fba00f2b2 | ||
|
|
c021e114eb | ||
|
|
86faf31058 | ||
|
|
51264b7736 | ||
|
|
59a39ae977 | ||
|
|
8ceb4f2c31 | ||
|
|
2ff6d15f38 | ||
|
|
abd4c31791 | ||
|
|
fc6390d62e | ||
|
|
f0f06e93f3 | ||
|
|
95e2e265de | ||
|
|
038de38e8b | ||
|
|
988ae2d805 | ||
|
|
0dbfe0bbff | ||
|
|
70c08d10b1 | ||
|
|
1bc26e5bc9 | ||
|
|
0bf9d49b3b | ||
|
|
84a6131e5f | ||
|
|
6f074e082b | ||
|
|
1eb31bfca9 | ||
|
|
d56836a5cc | ||
|
|
87fb882ef5 | ||
|
|
00ff689033 | ||
|
|
66171cc83f | ||
|
|
028a8de3c0 | ||
|
|
629e64ca00 | ||
|
|
a2715f496c | ||
|
|
27675df00d | ||
|
|
02bfe643b1 | ||
|
|
86ff74368a | ||
|
|
a832f2bb51 | ||
|
|
1e6a54e4ef | ||
|
|
85f1477611 | ||
|
|
b9a330654a | ||
|
|
69a7fca50d | ||
|
|
fcb682b57c | ||
|
|
4f17c03672 | ||
|
|
b6fbc04d2a | ||
|
|
872545cf69 | ||
|
|
b133fdc898 | ||
|
|
31ee02cfbe | ||
|
|
947abcd862 | ||
|
|
98e67f15f9 | ||
|
|
c584ef85e3 |
@@ -116,6 +116,10 @@ package_steps: &package_steps
|
||||
environment:
|
||||
CYPRESS_INSTALL_BINARY: 0
|
||||
|
||||
- run:
|
||||
name: Check types
|
||||
command: npm run check-types:package
|
||||
|
||||
# Run the package tests on each currently supported node version. See:
|
||||
# https://github.com/badges/shields/blob/master/badge-maker/README.md#node-version-support
|
||||
|
||||
|
||||
@@ -149,7 +149,7 @@ rules:
|
||||
# allow Joi as an undefined type
|
||||
jsdoc/no-undefined-types: ['error', { definedTypes: ['Joi'] }]
|
||||
|
||||
# all the other reccomended rules as errors (not warnings)
|
||||
# all the other recommended rules as errors (not warnings)
|
||||
jsdoc/check-alignment: 'error'
|
||||
jsdoc/check-param-names: 'error'
|
||||
jsdoc/check-tag-names: 'error'
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
FROM node:8-alpine
|
||||
FROM node:10-alpine
|
||||
|
||||
RUN mkdir -p /usr/src/app
|
||||
RUN mkdir /usr/src/app/private
|
||||
|
||||
@@ -191,8 +191,11 @@ Maintainers:
|
||||
|
||||
Operations:
|
||||
|
||||
- [espadrine](https://github.com/espadrine) (sysadmin)
|
||||
- [paulmelnikow](https://github.com/paulmelnikow) (limited access)
|
||||
- [calebcartwright](https://github.com/calebcartwright)
|
||||
- [chris48s](https://github.com/chris48s)
|
||||
- [espadrine](https://github.com/espadrine)
|
||||
- [paulmelnikow](https://github.com/paulmelnikow)
|
||||
- [PyvesB](https://github.com/PyvesB)
|
||||
|
||||
Alumni:
|
||||
|
||||
|
||||
25
SECURITY.md
Normal file
25
SECURITY.md
Normal file
@@ -0,0 +1,25 @@
|
||||
# Security Policy
|
||||
|
||||
## Supported Projects
|
||||
|
||||
Please follow this guidance when reporting security issues affecting:
|
||||
|
||||
- [Shields.io](https://shields.io)
|
||||
- [Raster.shields.io](https://raster.shields.io)
|
||||
- Self-hosted Shields instances
|
||||
- The [svg-to-image-proxy](https://www.npmjs.com/package/svg-to-image-proxy) NPM package
|
||||
- The [badge-maker](https://www.npmjs.com/package/badge-maker) NPM package
|
||||
|
||||
The [gh-badges](https://www.npmjs.com/package/gh-badges) NPM package is now deprecated and will no longer receive fixes for bugs or security issues.
|
||||
|
||||
## Reporting a Vulnerability
|
||||
|
||||
If you find a security vulnerability affecting any of our supported projects, please email [security@shields.io](mailto:security@shields.io), rather than opening a public issue on GitHub. After receiving the initial report, we will endeavor to keep you informed of the progress towards a fix and full announcement. We may ask you for additional information. You are also welcome to propose a patch or solution.
|
||||
|
||||
Report security bugs in third-party modules to the person or team maintaining the module.
|
||||
|
||||
## Coordinated Disclosure
|
||||
|
||||
We aim to patch confirmed vulnerabilities within 90 days or less, disclosing the details of those vulnerabilities when a patch is published. We ask that you refrain from sharing your report with others while we work on our patch.
|
||||
|
||||
We may want to coordinate an advisory with you to be published simultaneously with the patch, but you are also welcome to self-disclose after 90 days if you prefer. We will never publish information about you or our communications with you without your permission.
|
||||
@@ -1,2 +1,3 @@
|
||||
lib/make-badge-test-helpers.js
|
||||
lib/**/*.spec.js
|
||||
index.test-d.ts
|
||||
|
||||
@@ -1,5 +1,13 @@
|
||||
# Changelog
|
||||
|
||||
## 3.1.0
|
||||
|
||||
- Add TypeScript definitions
|
||||
|
||||
## 3.0.1
|
||||
|
||||
- Fix missing dependency
|
||||
|
||||
## 3.0.0
|
||||
|
||||
### Breaking Changes
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
|
||||
[](https://npmjs.org/package/badge-maker)
|
||||
[](https://npmjs.org/package/badge-maker)
|
||||
[](https://npmjs.org/package/badge-maker)
|
||||
|
||||
## Installation
|
||||
|
||||
@@ -20,9 +21,19 @@ badge build passed :green > mybadge.svg
|
||||
|
||||
### As a library
|
||||
|
||||
With CommonJS in JavaScript,
|
||||
|
||||
```js
|
||||
const { makeBadge, ValidationError } = require('badge-maker')
|
||||
```
|
||||
|
||||
With ESM or TypeScript,
|
||||
|
||||
```ts
|
||||
import { makeBadge, ValidationError } from 'badge-maker'
|
||||
```
|
||||
|
||||
```js
|
||||
const format = {
|
||||
label: 'build',
|
||||
message: 'passed',
|
||||
|
||||
11
badge-maker/index.d.ts
vendored
Normal file
11
badge-maker/index.d.ts
vendored
Normal file
@@ -0,0 +1,11 @@
|
||||
interface Format {
|
||||
label?: string
|
||||
message: string
|
||||
labelColor?: string
|
||||
color?: string
|
||||
style?: 'plastic' | 'flat' | 'flat-square' | 'for-the-badge' | 'social'
|
||||
}
|
||||
|
||||
export declare class ValidationError extends Error {}
|
||||
|
||||
export declare function makeBadge(format: Format): string
|
||||
35
badge-maker/index.test-d.ts
Normal file
35
badge-maker/index.test-d.ts
Normal file
@@ -0,0 +1,35 @@
|
||||
import { expectType, expectError, expectAssignable } from 'tsd'
|
||||
import { makeBadge, ValidationError } from '.'
|
||||
|
||||
expectError(makeBadge('string is invalid'))
|
||||
expectError(makeBadge({}))
|
||||
expectError(
|
||||
makeBadge({
|
||||
message: 'passed',
|
||||
style: 'invalid style',
|
||||
})
|
||||
)
|
||||
|
||||
expectType<string>(
|
||||
makeBadge({
|
||||
message: 'passed',
|
||||
})
|
||||
)
|
||||
expectType<string>(
|
||||
makeBadge({
|
||||
label: 'build',
|
||||
message: 'passed',
|
||||
})
|
||||
)
|
||||
expectType<string>(
|
||||
makeBadge({
|
||||
label: 'build',
|
||||
message: 'passed',
|
||||
labelColor: 'green',
|
||||
color: 'red',
|
||||
style: 'flat',
|
||||
})
|
||||
)
|
||||
|
||||
const error = new ValidationError()
|
||||
expectAssignable<Error>(error)
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "badge-maker",
|
||||
"version": "3.0.0",
|
||||
"version": "3.1.0",
|
||||
"description": "Shields.io badge library",
|
||||
"keywords": [
|
||||
"GitHub",
|
||||
@@ -9,6 +9,7 @@
|
||||
"image",
|
||||
"shields.io"
|
||||
],
|
||||
"types": "index.d.ts",
|
||||
"main": "lib/index.js",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
@@ -35,6 +36,7 @@
|
||||
},
|
||||
"dependencies": {
|
||||
"anafanafo": "^1.0.0",
|
||||
"camelcase": "^5.3.1",
|
||||
"is-css-color": "^1.0.0"
|
||||
},
|
||||
"scripts": {
|
||||
|
||||
@@ -67,7 +67,7 @@ function setHeadersForCacheLength(res, cacheLengthSeconds) {
|
||||
cacheControl = 'no-cache, no-store, must-revalidate'
|
||||
expires = nowGMTString
|
||||
} else {
|
||||
cacheControl = `max-age=${cacheLengthSeconds} s-maxage=${cacheLengthSeconds}`
|
||||
cacheControl = `max-age=${cacheLengthSeconds}, s-maxage=${cacheLengthSeconds}`
|
||||
expires = new Date(now.getTime() + cacheLengthSeconds * 1000).toGMTString()
|
||||
}
|
||||
|
||||
@@ -92,7 +92,7 @@ function setCacheHeaders({
|
||||
setHeadersForCacheLength(res, cacheLengthSeconds)
|
||||
}
|
||||
|
||||
const staticCacheControlHeader = `max-age=${24 * 3600} s-maxage=${24 * 3600}` // 1 day.
|
||||
const staticCacheControlHeader = `max-age=${24 * 3600}, s-maxage=${24 * 3600}` // 1 day.
|
||||
function setCacheHeadersForStaticResource(res) {
|
||||
res.setHeader('Cache-Control', staticCacheControlHeader)
|
||||
res.setHeader('Last-Modified', serverStartTimeGMTString)
|
||||
|
||||
@@ -147,7 +147,7 @@ describe('Cache header functions', function () {
|
||||
|
||||
it('should set the expected Cache-Control header', function () {
|
||||
expect(res._headers['cache-control']).to.equal(
|
||||
'max-age=123 s-maxage=123'
|
||||
'max-age=123, s-maxage=123'
|
||||
)
|
||||
})
|
||||
|
||||
@@ -187,7 +187,7 @@ describe('Cache header functions', function () {
|
||||
|
||||
it('should set the expected Cache-Control header', function () {
|
||||
expect(res._headers['cache-control']).to.equal(
|
||||
`max-age=${24 * 3600} s-maxage=${24 * 3600}`
|
||||
`max-age=${24 * 3600}, s-maxage=${24 * 3600}`
|
||||
)
|
||||
})
|
||||
|
||||
|
||||
@@ -254,7 +254,7 @@ describe('The request handler', function () {
|
||||
+new Date(headers.date) + 900000
|
||||
).toGMTString()
|
||||
expect(headers.expires).to.equal(expectedExpiry)
|
||||
expect(headers['cache-control']).to.equal('max-age=900 s-maxage=900')
|
||||
expect(headers['cache-control']).to.equal('max-age=900, s-maxage=900')
|
||||
})
|
||||
|
||||
it('should set the expected cache headers on cached responses', async function () {
|
||||
@@ -268,7 +268,7 @@ describe('The request handler', function () {
|
||||
+new Date(headers.date) + 900000
|
||||
).toGMTString()
|
||||
expect(headers.expires).to.equal(expectedExpiry)
|
||||
expect(headers['cache-control']).to.equal('max-age=900 s-maxage=900')
|
||||
expect(headers['cache-control']).to.equal('max-age=900, s-maxage=900')
|
||||
})
|
||||
|
||||
it('should let live service data override the default cache headers with longer value', async function () {
|
||||
@@ -289,7 +289,7 @@ describe('The request handler', function () {
|
||||
)
|
||||
|
||||
const { headers } = await got(`${baseUrl}/testing/123.json`)
|
||||
expect(headers['cache-control']).to.equal('max-age=400 s-maxage=400')
|
||||
expect(headers['cache-control']).to.equal('max-age=400, s-maxage=400')
|
||||
})
|
||||
|
||||
it('should not let live service data override the default cache headers with shorter value', async function () {
|
||||
@@ -310,7 +310,7 @@ describe('The request handler', function () {
|
||||
)
|
||||
|
||||
const { headers } = await got(`${baseUrl}/testing/123.json`)
|
||||
expect(headers['cache-control']).to.equal('max-age=300 s-maxage=300')
|
||||
expect(headers['cache-control']).to.equal('max-age=300, s-maxage=300')
|
||||
})
|
||||
|
||||
it('should set the expires header to current time + cacheSeconds', async function () {
|
||||
@@ -322,7 +322,7 @@ describe('The request handler', function () {
|
||||
+new Date(headers.date) + 3600000
|
||||
).toGMTString()
|
||||
expect(headers.expires).to.equal(expectedExpiry)
|
||||
expect(headers['cache-control']).to.equal('max-age=3600 s-maxage=3600')
|
||||
expect(headers['cache-control']).to.equal('max-age=3600, s-maxage=3600')
|
||||
})
|
||||
|
||||
it('should ignore cacheSeconds when shorter than defaultCacheLengthSeconds', async function () {
|
||||
@@ -334,7 +334,7 @@ describe('The request handler', function () {
|
||||
+new Date(headers.date) + 600000
|
||||
).toGMTString()
|
||||
expect(headers.expires).to.equal(expectedExpiry)
|
||||
expect(headers['cache-control']).to.equal('max-age=600 s-maxage=600')
|
||||
expect(headers['cache-control']).to.equal('max-age=600, s-maxage=600')
|
||||
})
|
||||
|
||||
it('should set Cache-Control: no-cache, no-store, must-revalidate if cache seconds is 0', async function () {
|
||||
|
||||
@@ -95,6 +95,10 @@ module.exports = class PrometheusMetrics {
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {object} attrs Refer to individual attrs
|
||||
* @param {string} attrs.category e.g: 'build'
|
||||
* @param {string} attrs.serviceFamily e.g: 'npm'
|
||||
* @param {string} attrs.name e.g: 'NpmVersion'
|
||||
* @returns {object} `{ inc() {} }`.
|
||||
*/
|
||||
createNumRequestCounter({ category, serviceFamily, name }) {
|
||||
|
||||
@@ -25,7 +25,7 @@ class ServiceTester {
|
||||
* Specifies which tests to run from the CLI or pull requests
|
||||
* @param {string} attrs.title
|
||||
* Prints in the Mocha output
|
||||
* @param {string} attrs.path
|
||||
* @param {string} attrs.pathPrefix
|
||||
* Prefix which is automatically prepended to each tested URI.
|
||||
* The default is `/${attrs.id}`.
|
||||
*/
|
||||
@@ -119,7 +119,7 @@ class ServiceTester {
|
||||
* @param {number} attrs.retry.count number of times to retry test
|
||||
* @param {number} attrs.retry.backoff number of milliseconds to add to the wait between each retry
|
||||
*/
|
||||
toss({ baseUrl, skipIntercepted, retry }) {
|
||||
toss({ baseUrl, skipIntercepted, retry: { count, backoff } }) {
|
||||
const { specs, pathPrefix } = this
|
||||
const testerBaseUrl = `${baseUrl}${pathPrefix}`
|
||||
|
||||
@@ -132,7 +132,7 @@ class ServiceTester {
|
||||
}`
|
||||
if (!skipIntercepted || !spec.intercepted) {
|
||||
spec.baseUri(testerBaseUrl)
|
||||
spec.retry(retry.count, retry.backoff)
|
||||
spec.retry(count, backoff)
|
||||
spec.toss()
|
||||
}
|
||||
})
|
||||
|
||||
@@ -16,9 +16,8 @@ const { fileMatch } = danger.git
|
||||
|
||||
const documentation = fileMatch(
|
||||
'**/*.md',
|
||||
'lib/all-badge-examples.js',
|
||||
'frontend/components/usage.js',
|
||||
'frontend/pages/endpoint.js'
|
||||
'frontend/components/usage.tsx',
|
||||
'frontend/pages/endpoint.tsx'
|
||||
)
|
||||
const server = fileMatch('core/server/**.js', '!*.spec.js')
|
||||
const serverTests = fileMatch('core/server/**.spec.js')
|
||||
|
||||
@@ -7,7 +7,7 @@ const got = require('./core/got-test-client')
|
||||
let server
|
||||
before(function () {
|
||||
this.timeout('5s')
|
||||
// remove args comming from mocha
|
||||
// remove args coming from mocha
|
||||
// https://github.com/badges/shields/issues/3365
|
||||
process.argv = []
|
||||
server = require('./server')
|
||||
|
||||
@@ -274,7 +274,7 @@ export default function Usage({ baseUrl }: { baseUrl: string }): JSX.Element {
|
||||
target="_blank"
|
||||
title="XPath syntax"
|
||||
>
|
||||
//data/subdata
|
||||
//data/subdata
|
||||
</a>
|
||||
>&color=<COLOR>&prefix=<PREFIX>&suffix=<SUFFIX>
|
||||
</StyledCode>
|
||||
|
||||
10312
package-lock.json
generated
10312
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
81
package.json
81
package.json
@@ -22,7 +22,7 @@
|
||||
"url": "https://github.com/badges/shields"
|
||||
},
|
||||
"dependencies": {
|
||||
"@hapi/joi": "^16.1.8",
|
||||
"@hapi/joi": "^17.1.1",
|
||||
"@sentry/node": "^5.15.5",
|
||||
"bytes": "^3.1.0",
|
||||
"camelcase": "^5.3.1",
|
||||
@@ -36,31 +36,31 @@
|
||||
"decamelize": "^3.2.0",
|
||||
"dotenv": "^8.2.0",
|
||||
"emojic": "^1.1.15",
|
||||
"escape-string-regexp": "^2.0.0",
|
||||
"fast-xml-parser": "^3.16.0",
|
||||
"escape-string-regexp": "^4.0.0",
|
||||
"fast-xml-parser": "^3.17.3",
|
||||
"fsos": "^1.1.6",
|
||||
"badge-maker": "file:badge-maker",
|
||||
"glob": "^7.1.6",
|
||||
"graphql": "^14.6.0",
|
||||
"graphql-tag": "^2.10.3",
|
||||
"ioredis": "4.16.3",
|
||||
"joi-extension-semver": "4.0.0",
|
||||
"js-yaml": "^3.13.1",
|
||||
"ioredis": "4.17.1",
|
||||
"joi-extension-semver": "4.1.1",
|
||||
"js-yaml": "^3.14.0",
|
||||
"jsonpath": "~1.0.2",
|
||||
"lodash.countby": "^4.6.0",
|
||||
"lodash.groupby": "^4.6.0",
|
||||
"lodash.times": "^4.3.2",
|
||||
"moment": "^2.25.1",
|
||||
"moment": "^2.26.0",
|
||||
"node-env-flag": "^0.1.0",
|
||||
"parse-link-header": "^1.0.1",
|
||||
"path-to-regexp": "^5.0.0",
|
||||
"pretty-bytes": "^5.3.0",
|
||||
"priorityqueuejs": "^1.0.0",
|
||||
"priorityqueuejs": "^2.0.0",
|
||||
"prom-client": "^11.5.3",
|
||||
"query-string": "^6.12.1",
|
||||
"request": "~2.88.2",
|
||||
"semver": "~7.3.2",
|
||||
"simple-icons": "2.10.0",
|
||||
"simple-icons": "2.14.0",
|
||||
"xmldom": "~0.2.1",
|
||||
"xpath": "~0.0.27"
|
||||
},
|
||||
@@ -93,7 +93,8 @@
|
||||
"test:services:pr:run": "cross-env NODE_CONFIG_ENV=test mocha core/service-test-runner/cli.js --stdin < pull-request-services.log",
|
||||
"test:services:pr": "run-s --silent test:services:pr:prepare test:services:pr:run",
|
||||
"pretest": "run-s --silent defs features",
|
||||
"test": "run-s --silent --continue-on-error lint test:frontend test:package test:core test:entrypoint check-types:frontend prettier:check",
|
||||
"test": "run-s --silent --continue-on-error lint test:frontend test:package test:core test:entrypoint check-types:package check-types:frontend prettier:check",
|
||||
"check-types:package": "tsd badge-maker",
|
||||
"check-types:frontend": "tsc --noEmit --project .",
|
||||
"depcheck": "check-node-version --node \">= 10.0\"",
|
||||
"postinstall": "run-s --silent depcheck",
|
||||
@@ -122,8 +123,7 @@
|
||||
"prettier --write"
|
||||
],
|
||||
"**/*.@(md|json|yml)": [
|
||||
"prettier --write",
|
||||
"git add"
|
||||
"prettier --write"
|
||||
]
|
||||
},
|
||||
"nodemonConfig": {
|
||||
@@ -141,9 +141,9 @@
|
||||
]
|
||||
},
|
||||
"devDependencies": {
|
||||
"@babel/core": "^7.9.6",
|
||||
"@babel/polyfill": "^7.8.7",
|
||||
"@babel/register": "7.9.0",
|
||||
"@babel/core": "^7.10.1",
|
||||
"@babel/polyfill": "^7.10.1",
|
||||
"@babel/register": "7.10.1",
|
||||
"@mapbox/react-click-to-select": "^2.2.0",
|
||||
"@types/chai": "^4.2.11",
|
||||
"@types/chai-enzyme": "^0.6.7",
|
||||
@@ -151,16 +151,16 @@
|
||||
"@types/lodash.debounce": "^4.0.6",
|
||||
"@types/lodash.groupby": "^4.6.6",
|
||||
"@types/mocha": "^7.0.2",
|
||||
"@types/node": "^13.13.4",
|
||||
"@types/react-helmet": "^5.0.15",
|
||||
"@types/node": "^14.0.5",
|
||||
"@types/react-helmet": "^6.0.0",
|
||||
"@types/react-modal": "^3.10.5",
|
||||
"@types/react-select": "^3.0.12",
|
||||
"@types/react-select": "^3.0.13",
|
||||
"@types/styled-components": "4.1.8",
|
||||
"@typescript-eslint/eslint-plugin": "^2.30.0",
|
||||
"@typescript-eslint/parser": "^2.30.0",
|
||||
"@typescript-eslint/eslint-plugin": "^2.34.0",
|
||||
"@typescript-eslint/parser": "^2.34.0",
|
||||
"babel-plugin-inline-react-svg": "^1.1.1",
|
||||
"babel-plugin-istanbul": "^6.0.0",
|
||||
"babel-preset-gatsby": "^0.4.0",
|
||||
"babel-preset-gatsby": "^0.4.7",
|
||||
"caller": "^1.0.1",
|
||||
"chai": "^4.1.2",
|
||||
"chai-datetime": "^1.6.0",
|
||||
@@ -170,8 +170,8 @@
|
||||
"child-process-promise": "^2.2.1",
|
||||
"clipboard-copy": "^3.1.0",
|
||||
"concurrently": "^5.2.0",
|
||||
"cypress": "^4.5.0",
|
||||
"danger": "^10.1.1",
|
||||
"cypress": "^4.7.0",
|
||||
"danger": "^10.2.0",
|
||||
"danger-plugin-no-test-shortcuts": "^2.0.0",
|
||||
"deepmerge": "^4.2.2",
|
||||
"enzyme": "^3.11.0",
|
||||
@@ -181,28 +181,28 @@
|
||||
"eslint-config-standard": "^14.1.1",
|
||||
"eslint-config-standard-react": "^9.2.0",
|
||||
"eslint-plugin-chai-friendly": "^0.6.0",
|
||||
"eslint-plugin-cypress": "^2.10.3",
|
||||
"eslint-plugin-cypress": "^2.11.1",
|
||||
"eslint-plugin-import": "^2.20.2",
|
||||
"eslint-plugin-jsdoc": "^24.0.0",
|
||||
"eslint-plugin-jsdoc": "^26.0.0",
|
||||
"eslint-plugin-mocha": "^6.3.0",
|
||||
"eslint-plugin-no-extension-in-require": "^0.2.0",
|
||||
"eslint-plugin-node": "^11.1.0",
|
||||
"eslint-plugin-promise": "^4.2.1",
|
||||
"eslint-plugin-react": "^7.19.0",
|
||||
"eslint-plugin-react": "^7.20.0",
|
||||
"eslint-plugin-react-hooks": "^2.5.1",
|
||||
"eslint-plugin-sort-class-members": "^1.7.0",
|
||||
"eslint-plugin-standard": "^4.0.1",
|
||||
"fetch-ponyfill": "^6.1.0",
|
||||
"form-data": "^3.0.0",
|
||||
"fs-readfile-promise": "^3.0.1",
|
||||
"gatsby": "2.21.11",
|
||||
"gatsby-plugin-catch-links": "^2.3.0",
|
||||
"gatsby-plugin-page-creator": "^2.3.0",
|
||||
"gatsby-plugin-react-helmet": "^3.3.0",
|
||||
"gatsby-plugin-remove-trailing-slashes": "^2.3.0",
|
||||
"gatsby-plugin-styled-components": "^3.3.0",
|
||||
"gatsby-plugin-typescript": "^2.4.0",
|
||||
"got": "11.1.0",
|
||||
"gatsby": "2.22.12",
|
||||
"gatsby-plugin-catch-links": "^2.3.3",
|
||||
"gatsby-plugin-page-creator": "^2.3.7",
|
||||
"gatsby-plugin-react-helmet": "^3.3.2",
|
||||
"gatsby-plugin-remove-trailing-slashes": "^2.3.3",
|
||||
"gatsby-plugin-styled-components": "^3.3.2",
|
||||
"gatsby-plugin-typescript": "^2.4.3",
|
||||
"got": "11.1.4",
|
||||
"humanize-string": "^2.1.0",
|
||||
"husky": "^4.2.5",
|
||||
"icedfrisby": "3.0.0",
|
||||
@@ -211,17 +211,17 @@
|
||||
"is-svg": "^4.2.1",
|
||||
"js-yaml-loader": "^1.2.2",
|
||||
"jsdoc": "^3.6.4",
|
||||
"lint-staged": "^10.2.2",
|
||||
"lint-staged": "^10.2.7",
|
||||
"lodash.debounce": "^4.0.8",
|
||||
"lodash.difference": "^4.5.0",
|
||||
"minimist": "^1.2.5",
|
||||
"mocha": "^7.1.2",
|
||||
"mocha": "^7.2.0",
|
||||
"mocha-env-reporter": "^4.0.0",
|
||||
"mocha-junit-reporter": "^1.23.3",
|
||||
"mocha-yaml-loader": "^1.0.3",
|
||||
"nock": "13.0.0-beta.4",
|
||||
"nock": "13.0.0-beta.5",
|
||||
"node-mocks-http": "^1.8.1",
|
||||
"nodemon": "^2.0.3",
|
||||
"nodemon": "^2.0.4",
|
||||
"npm-run-all": "^4.1.5",
|
||||
"nyc": "^15.0.1",
|
||||
"opn-cli": "^5.0.0",
|
||||
@@ -230,7 +230,7 @@
|
||||
"react": "^16.13.1",
|
||||
"react-dom": "^16.13.1",
|
||||
"react-error-overlay": "^6.0.7",
|
||||
"react-helmet": "^5.2.1",
|
||||
"react-helmet": "^6.0.0",
|
||||
"react-modal": "^3.11.2",
|
||||
"react-pose": "^4.0.10",
|
||||
"react-select": "^3.1.0",
|
||||
@@ -243,8 +243,9 @@
|
||||
"sinon-chai": "^3.5.0",
|
||||
"snap-shot-it": "^7.9.3",
|
||||
"start-server-and-test": "1.11.0",
|
||||
"styled-components": "^5.1.0",
|
||||
"styled-components": "^5.1.1",
|
||||
"tmp": "0.2.1",
|
||||
"tsd": "^0.11.0",
|
||||
"ts-mocha": "^7.0.0",
|
||||
"typescript": "^3.8.3"
|
||||
},
|
||||
|
||||
@@ -73,7 +73,7 @@ module.exports = class Discord extends BaseJsonService {
|
||||
}
|
||||
|
||||
async fetch({ serverId }) {
|
||||
const url = `https://discordapp.com/api/guilds/${serverId}/widget.json`
|
||||
const url = `https://discord.com/api/guilds/${serverId}/widget.json`
|
||||
return this._requestJson({
|
||||
url,
|
||||
schema: discordSchema,
|
||||
|
||||
@@ -18,7 +18,7 @@ t.create('invalid server ID')
|
||||
t.create('widget disabled')
|
||||
.get('/12345.json')
|
||||
.intercept(nock =>
|
||||
nock('https://discordapp.com/')
|
||||
nock('https://discord.com/')
|
||||
.get('/api/guilds/12345/widget.json')
|
||||
.reply(403, {
|
||||
code: 50004,
|
||||
@@ -30,7 +30,7 @@ t.create('widget disabled')
|
||||
t.create('server error')
|
||||
.get('/12345.json')
|
||||
.intercept(nock =>
|
||||
nock('https://discordapp.com/')
|
||||
nock('https://discord.com/')
|
||||
.get('/api/guilds/12345/widget.json')
|
||||
.reply(500, 'Something broke')
|
||||
)
|
||||
|
||||
@@ -189,7 +189,7 @@ t.create('query with node function')
|
||||
color: 'blue',
|
||||
})
|
||||
|
||||
t.create('query with type convertion to string')
|
||||
t.create('query with type conversion to string')
|
||||
.get(
|
||||
`.json?${queryString.stringify({
|
||||
url: exampleUrl,
|
||||
@@ -203,7 +203,7 @@ t.create('query with type convertion to string')
|
||||
color: 'blue',
|
||||
})
|
||||
|
||||
t.create('query with type convertion to number')
|
||||
t.create('query with type conversion to number')
|
||||
.get(
|
||||
`.json?${queryString.stringify({
|
||||
url: exampleUrl,
|
||||
|
||||
@@ -207,7 +207,7 @@ t.create('cacheSeconds')
|
||||
cacheSeconds: 500,
|
||||
})
|
||||
)
|
||||
.expectHeader('cache-control', 'max-age=500')
|
||||
.expectHeader('cache-control', 'max-age=500, s-maxage=500')
|
||||
|
||||
t.create('user can override service cacheSeconds')
|
||||
.get('.json?url=https://example.com/badge&cacheSeconds=1000')
|
||||
@@ -219,7 +219,7 @@ t.create('user can override service cacheSeconds')
|
||||
cacheSeconds: 500,
|
||||
})
|
||||
)
|
||||
.expectHeader('cache-control', 'max-age=1000')
|
||||
.expectHeader('cache-control', 'max-age=1000, s-maxage=1000')
|
||||
|
||||
t.create('user does not override longer service cacheSeconds')
|
||||
.get('.json?url=https://example.com/badge&cacheSeconds=450')
|
||||
@@ -231,7 +231,7 @@ t.create('user does not override longer service cacheSeconds')
|
||||
cacheSeconds: 500,
|
||||
})
|
||||
)
|
||||
.expectHeader('cache-control', 'max-age=500')
|
||||
.expectHeader('cache-control', 'max-age=500, s-maxage=500')
|
||||
|
||||
t.create('cacheSeconds does not override longer Shields default')
|
||||
.get('.json?url=https://example.com/badge')
|
||||
@@ -243,7 +243,7 @@ t.create('cacheSeconds does not override longer Shields default')
|
||||
cacheSeconds: 10,
|
||||
})
|
||||
)
|
||||
.expectHeader('cache-control', 'max-age=300')
|
||||
.expectHeader('cache-control', 'max-age=300, s-maxage=300')
|
||||
|
||||
t.create('Bad scheme')
|
||||
.get('.json?url=http://example.com/badge')
|
||||
|
||||
@@ -7,7 +7,7 @@ t.create('github pull request check state')
|
||||
.expectBadge({ label: 'checks', message: 'failure' })
|
||||
|
||||
t.create('github pull request check state (pull request not found)')
|
||||
.get('/s/pulls/badges/shields/5110.json')
|
||||
.get('/s/pulls/badges/shields/5101.json')
|
||||
.expectBadge({ label: 'checks', message: 'pull request or repo not found' })
|
||||
|
||||
t.create(
|
||||
|
||||
@@ -100,7 +100,7 @@ const schema = Joi.object({
|
||||
/*
|
||||
* Strip Build MetaData
|
||||
* Nuget versions may include an optional "build metadata" clause,
|
||||
* seperated from the version by a + character.
|
||||
* separated from the version by a + character.
|
||||
*/
|
||||
function stripBuildMetadata(version) {
|
||||
return version.split('+')[0]
|
||||
|
||||
@@ -29,6 +29,11 @@ class BasePackagistService extends BaseJsonService {
|
||||
* and dumped to static files so it is very efficient on our end." (comment from official documentation).
|
||||
* For more information please refer to https://packagist.org/apidoc#get-package-data.
|
||||
*
|
||||
* @param {object} attrs Refer to individual attrs
|
||||
* @param {string} attrs.user package user
|
||||
* @param {string} attrs.repo package repository
|
||||
* @param {Joi} attrs.schema Joi schema to validate the response transformed to JSON
|
||||
* @param {string} attrs.server URL for the packagist registry server (Optional)
|
||||
* @returns {object} Parsed response
|
||||
*/
|
||||
async fetch({ user, repo, schema, server = 'https://packagist.org' }) {
|
||||
@@ -48,6 +53,11 @@ class BasePackagistService extends BaseJsonService {
|
||||
* so data fetch from this method might be outdated.
|
||||
* For more information please refer to https://packagist.org/apidoc#get-package-data.
|
||||
*
|
||||
* @param {object} attrs Refer to individual attrs
|
||||
* @param {string} attrs.user package user
|
||||
* @param {string} attrs.repo package repository
|
||||
* @param {Joi} attrs.schema Joi schema to validate the response transformed to JSON
|
||||
* @param {string} attrs.server URL for the packagist registry server (Optional)
|
||||
* @returns {object} Parsed response
|
||||
*/
|
||||
async fetchByJsonAPI({
|
||||
|
||||
@@ -63,6 +63,7 @@ const steamFileSchema = Joi.object({
|
||||
Joi.object({
|
||||
file_size: Joi.number().integer().required(),
|
||||
time_created: Joi.number().integer().required(),
|
||||
time_updated: Joi.number().integer().required(),
|
||||
subscriptions: Joi.number().integer().required(),
|
||||
favorited: Joi.number().integer().required(),
|
||||
lifetime_subscriptions: Joi.number().integer().required(),
|
||||
@@ -276,6 +277,45 @@ class SteamFileReleaseDate extends SteamFileService {
|
||||
}
|
||||
}
|
||||
|
||||
class SteamFileUpdateDate extends SteamFileService {
|
||||
static get category() {
|
||||
return 'activity'
|
||||
}
|
||||
|
||||
static get route() {
|
||||
return {
|
||||
base: 'steam/update-date',
|
||||
pattern: ':fileId',
|
||||
}
|
||||
}
|
||||
|
||||
static get examples() {
|
||||
return [
|
||||
{
|
||||
title: 'Steam Update Date',
|
||||
namedParams: { fileId: '100' },
|
||||
staticPreview: this.render({
|
||||
updateDate: new Date(0).setUTCSeconds(1538288239),
|
||||
}),
|
||||
documentation,
|
||||
},
|
||||
]
|
||||
}
|
||||
|
||||
static get defaultBadgeData() {
|
||||
return { label: 'update date' }
|
||||
}
|
||||
|
||||
static render({ updateDate }) {
|
||||
return { message: formatDate(updateDate), color: ageColor(updateDate) }
|
||||
}
|
||||
|
||||
async onRequest({ response }) {
|
||||
const updateDate = new Date(0).setUTCSeconds(response.time_updated)
|
||||
return this.constructor.render({ updateDate })
|
||||
}
|
||||
}
|
||||
|
||||
class SteamFileSubscriptions extends SteamFileService {
|
||||
static get category() {
|
||||
return 'rating'
|
||||
@@ -426,6 +466,7 @@ module.exports = {
|
||||
SteamCollectionSize,
|
||||
SteamFileSize,
|
||||
SteamFileReleaseDate,
|
||||
SteamFileUpdateDate,
|
||||
SteamFileSubscriptions,
|
||||
SteamFileFavorites,
|
||||
SteamFileDownloads,
|
||||
|
||||
@@ -18,6 +18,10 @@ t.create('Release Date')
|
||||
.get('/release-date/1523924535.json')
|
||||
.expectBadge({ label: 'release date', message: isFormattedDate })
|
||||
|
||||
t.create('Update Date')
|
||||
.get('/update-date/1523924535.json')
|
||||
.expectBadge({ label: 'update date', message: isFormattedDate })
|
||||
|
||||
t.create('Subscriptions')
|
||||
.get('/subscriptions/1523924535.json')
|
||||
.expectBadge({ label: 'subscriptions', message: isMetric })
|
||||
@@ -46,6 +50,10 @@ t.create('Release Date | File Not Found')
|
||||
.get('/release-date/1.json')
|
||||
.expectBadge({ label: 'release date', message: 'file not found' })
|
||||
|
||||
t.create('Update Date | File Not Found')
|
||||
.get('/update-date/1.json')
|
||||
.expectBadge({ label: 'update date', message: 'file not found' })
|
||||
|
||||
t.create('Subscriptions | File Not Found')
|
||||
.get('/subscriptions/1.json')
|
||||
.expectBadge({ label: 'subscriptions', message: 'file not found' })
|
||||
|
||||
Reference in New Issue
Block a user