Commit Graph

227 Commits

Author SHA1 Message Date
Marcin Mielnicki
bc4bd79e90 Metrics with Prometheus (#2069)
* Basic process metrics

* Enable Prometheus by an environment variable

* Code formatting

* Documentation for Prometheus metrics

* Link from README to documentation of Prometheus

* Link from README to documentation of Prometheus

* Link from README to documentation of Prometheus

* Separate module for metrics + tests

* Metrics limited by IP

* Metrics are forbidded for all requets by default

* Code refactoring

* allowedIps passed as a string to PrometheusMetrics

* Handle missing config

* METRICS_PROMETHEUS_ALLOWED_IPS added to documentation

* Log info about enabled metrics

* Unused code removed

* package-lock.json updated

* prom-client updated to 11.1.2

* Code refactoring

* Do not read IP address from X-Forwarder-For header
2018-11-04 18:54:43 +01:00
Thaddée Tyl
1460855d6b Upgrade to camp 17.2.2 (#2260)
This fixes remaining vulnerabilities raised by `npm audit`.

Follow-up to https://github.com/badges/shields/pull/2258.

Related issues from dependencies:

- camp upgrade: https://github.com/espadrine/sc/issues/64
- socket.io vulnerability: https://github.com/get/parsejson/issues/4
2018-11-04 12:00:28 +00:00
dependabot[bot]
52d642cf91 Bump joi from 14.0.2 to 14.0.3 (#2251)
Bumps [joi](https://github.com/hapijs/joi) from 14.0.2 to 14.0.3.
- [Release notes](https://github.com/hapijs/joi/releases)
- [Changelog](https://github.com/hapijs/joi/blob/master/CHANGELOG.md)
- [Commits](https://github.com/hapijs/joi/compare/v14.0.2...v14.0.3)

Signed-off-by: dependabot[bot] <support@dependabot.com>
2018-11-01 20:25:18 +00:00
dependabot[bot]
f6b6b66fc2 Bump simple-icons from 1.9.9 to 1.9.10 (#2249)
Bumps [simple-icons](https://github.com/simple-icons/simple-icons) from 1.9.9 to 1.9.10.
- [Release notes](https://github.com/simple-icons/simple-icons/releases)
- [Commits](https://github.com/simple-icons/simple-icons/commits)

Signed-off-by: dependabot[bot] <support@dependabot.com>
2018-11-01 20:15:18 +00:00
piekar294
730dc67cdf Migrate babel 6.x to babel 7.1 (#2222)
* Upgrade babel 6.x to babel 7.0
* Next 6.1.1 + additional babel packages needed for Babel 7.0
* Add @babel/register
* use @babel/preset-env in babel.presets to enable babel.env configuration
2018-11-01 15:03:50 -04:00
chris48s
6fc8744bab Give the NPM package some love (#2200)
* define a public interface for NPM package
* move check-node-version to dependencies
* add missing file to package
* update docs
* bump version
* add gh-badges option to issue template
* abstract text measuring from users
* add a DocBlock for BadgeFactory.create()
2018-10-30 18:34:04 +00:00
dependabot[bot]
0a67631f2e Bump joi from 14.0.1 to 14.0.2 (#2235)
Bumps [joi](https://github.com/hapijs/joi) from 14.0.1 to 14.0.2.
- [Release notes](https://github.com/hapijs/joi/releases)
- [Changelog](https://github.com/hapijs/joi/blob/master/CHANGELOG.md)
- [Commits](https://github.com/hapijs/joi/compare/v14.0.1...v14.0.2)

Signed-off-by: dependabot[bot] <support@dependabot.com>
2018-10-30 18:04:39 +00:00
Danial
2ee98f92ce bump simple-icons version (#2231)
* bump simple-icons version

* require specific version
2018-10-29 21:58:17 -04:00
chris48s
87524976c9 upgrade to Joi 14; affects [elm-package jetbrains npmversion pypi vaadin-directory dynamic-xml] (#2221)
* upgrade to Joi 14
    Joi 14 throws an exception on regexes which use the `g` flag
    see https://github.com/hapijs/joi/issues/1615
    semver-regex uses the `g` flag
    https://github.com/sindresorhus/semver-regex/blob/master/index.js
    so in order to upgrade Joi, I've swapped out semver-regex
    We'll use joi-extension-semver for semver validation now

* use isVPlusDottedVersionNClauses in jetbrains tests
    some of these projects use version numbers like
    v1.7 or
    v3.0.0.141
2018-10-28 15:56:19 +00:00
Marcin Mielnicki
de1eb664ec Precommit hook with Prettier and ESLint (#2178)
* Precommit hook with prettier and eslint added

* Info about running prettier removed from documentation

* Info about a pre-commit hook in documentation
2018-10-19 11:16:30 +02:00
dependabot[bot]
8545d5ae27 Bump sinon from 6.3.5 to 7.0.0 (#2184)
Bumps [sinon](https://github.com/sinonjs/sinon) from 6.3.5 to 7.0.0.
- [Release notes](https://github.com/sinonjs/sinon/releases)
- [Changelog](https://github.com/sinonjs/sinon/blob/master/docs/changelog.md)
- [Commits](https://github.com/sinonjs/sinon/compare/v6.3.5...v7.0.0)

Signed-off-by: dependabot[bot] <support@dependabot.com>
2018-10-18 20:35:54 +01:00
dependabot[bot]
89ca13a5d6 Bump semver from 5.5.1 to 5.6.0 (#2167)
Bumps [semver](https://github.com/npm/node-semver) from 5.5.1 to 5.6.0.
- [Release notes](https://github.com/npm/node-semver/releases)
- [Commits](https://github.com/npm/node-semver/compare/v5.5.1...v5.6.0)

Signed-off-by: dependabot[bot] <support@dependabot.com>
2018-10-11 21:28:45 +01:00
chris48s
9d7f27d84e add refactoring report (#2163) 2018-10-10 19:22:30 +01:00
dependabot[bot]
ef9f4f9a52 Bump joi from 13.6.0 to 13.7.0 (#2135)
Bumps [joi](https://github.com/hapijs/joi) from 13.6.0 to 13.7.0.
- [Release notes](https://github.com/hapijs/joi/releases)
- [Changelog](https://github.com/hapijs/joi/blob/master/CHANGELOG.md)
- [Commits](https://github.com/hapijs/joi/compare/v13.6.0...v13.7.0)

Signed-off-by: dependabot[bot] <support@dependabot.com>
2018-10-03 20:21:20 +01:00
dependabot[bot]
a28ad3ceaf Bump babel-eslint from 9.0.0 to 10.0.0 (#2118)
Bumps [babel-eslint](https://github.com/babel/babel-eslint) from 9.0.0 to 10.0.0.
- [Release notes](https://github.com/babel/babel-eslint/releases)
- [Commits](https://github.com/babel/babel-eslint/compare/v9.0.0...v10.0.0)

Signed-off-by: dependabot[bot] <support@dependabot.com>
2018-09-27 19:42:52 +01:00
dependabot[bot]
58b75f5146 Bump snap-shot-it from 5.0.1 to 6.1.8 (#2072)
Bumps [snap-shot-it](https://github.com/bahmutov/snap-shot-it) from 5.0.1 to 6.1.8.
- [Release notes](https://github.com/bahmutov/snap-shot-it/releases)
- [Commits](https://github.com/bahmutov/snap-shot-it/compare/v5.0.1...v6.1.8)

Signed-off-by: dependabot[bot] <support@dependabot.com>
2018-09-23 20:45:42 +01:00
dependabot[bot]
3577327243 Bump danger from 3.9.0 to 4.0.1 (#2090)
Bumps [danger](https://github.com/danger/danger-js) from 3.9.0 to 4.0.1.
- [Release notes](https://github.com/danger/danger-js/releases)
- [Changelog](https://github.com/danger/danger-js/blob/master/CHANGELOG.md)
- [Commits](https://github.com/danger/danger-js/compare/3.9.0...4.0.1)

Signed-off-by: dependabot[bot] <support@dependabot.com>
2018-09-23 20:33:33 +01:00
dependabot[bot]
3c373b58ac Bump prettier from 1.14.2 to 1.14.3 (#2104)
Bumps [prettier](https://github.com/prettier/prettier) from 1.14.2 to 1.14.3.
- [Release notes](https://github.com/prettier/prettier/releases)
- [Changelog](https://github.com/prettier/prettier/blob/master/CHANGELOG.md)
- [Commits](https://github.com/prettier/prettier/compare/1.14.2...1.14.3)

Signed-off-by: dependabot[bot] <support@dependabot.com>
2018-09-21 19:50:27 +01:00
dependabot[bot]
0b1ed5130e Bump svgo from 1.0.5 to 1.1.1 (#2094)
Bumps [svgo](https://github.com/svg/svgo) from 1.0.5 to 1.1.1.
- [Release notes](https://github.com/svg/svgo/releases)
- [Changelog](https://github.com/svg/svgo/blob/master/CHANGELOG.md)
- [Commits](https://github.com/svg/svgo/compare/v1.0.5...v1.1.1)

Signed-off-by: dependabot[bot] <support@dependabot.com>
2018-09-21 19:47:04 +01:00
dependabot[bot]
a1347e5bf2 Bump nock from 9.6.1 to 10.0.0 (#2088)
Bumps [nock](https://github.com/nock/nock) from 9.6.1 to 10.0.0.
- [Release notes](https://github.com/nock/nock/releases)
- [Changelog](https://github.com/nock/nock/blob/master/CHANGELOG.md)
- [Commits](https://github.com/nock/nock/compare/v9.6.1...v10.0.0)

Signed-off-by: dependabot[bot] <support@dependabot.com>
2018-09-18 16:22:03 +01:00
Pyves
bf0496cd64 Made JSON snapshot test pass on Windows (#2061) 2018-09-10 19:27:05 +01:00
Pyves
7417dc5f6c Delete BaseHTTPService and implement new BaseXmlService (affects [eclipse-marketplace f-droid]; also testing on [uptimerobot circleci]) (#2037) 2018-09-03 19:37:37 +01:00
Paul Melnikow
454575c4cb Enforce no extensions in require (#1999)
This removes remaining `.js` extensions from `require()` expressions and automatically enforces this rule.
2018-09-01 11:14:01 -07:00
Paul Melnikow
b602284403 Update coverage scripts (#2008)
As I was testing #1992 I noticed some of the coverage scripts were out of date.
2018-08-29 15:22:38 -07:00
Paul Melnikow
55f4017388 Combined update of eslint dependencies (#2007) 2018-08-29 15:01:25 -07:00
dependabot[bot]
f4789125a7 Bump nyc from 12.0.1 to 13.0.1 (#1992)
Bumps [nyc](https://github.com/istanbuljs/nyc) from 12.0.1 to 13.0.1.
- [Release notes](https://github.com/istanbuljs/nyc/releases)
- [Changelog](https://github.com/istanbuljs/nyc/blob/master/CHANGELOG.md)
- [Commits](https://github.com/istanbuljs/nyc/compare/v12.0.1...v13.0.1)

Signed-off-by: dependabot[bot] <support@dependabot.com>
2018-08-29 02:52:12 -04:00
dependabot[bot]
16d415769f Bump babel-eslint from 8.2.6 to 9.0.0 (#1991)
Bumps [babel-eslint](https://github.com/babel/babel-eslint) from 8.2.6 to 9.0.0.
- [Release notes](https://github.com/babel/babel-eslint/releases)
- [Commits](https://github.com/babel/babel-eslint/compare/v8.2.6...v9.0.0)

Signed-off-by: dependabot[bot] <support@dependabot.com>
2018-08-28 22:45:23 +01:00
Paul Melnikow
5bc26eaacf Use Joi 13.6.0 on the servers (#1989)
Ref: #1988
2018-08-28 15:16:14 -04:00
dependabot[bot]
6b3d1ab010 Bump concurrently from 3.6.1 to 4.0.1 (#1980)
Bumps [concurrently](https://github.com/kimmobrunfeldt/concurrently) from 3.6.1 to 4.0.1.
- [Release notes](https://github.com/kimmobrunfeldt/concurrently/releases)
- [Commits](https://github.com/kimmobrunfeldt/concurrently/compare/3.6.1...v4.0.1)

Signed-off-by: dependabot[bot] <support@dependabot.com>
2018-08-27 17:04:46 +01:00
Paul Melnikow
a0c43ed219 Reduce boilerplate for creating new testers [npm appveyor gem uptimerobot clojars] (#1934)
This is a bit of sugar that reduces the boilerplate for creating testers in what I expect will become the standard case: a service in `foo/foo-thing.service.js` with its tests in `foo/foo-thing.tester.js`.

This makes a small stylistic change, which is to name the service by its CamelCase class name rather than an invented snake-case ID. Whereas before the name was specified in `class FooThing extends Base[Json]Service` and a second time in the tester, it now only needs to be specified once.
2018-08-22 18:07:51 -04:00
dependabot[bot]
77061fe6af Bump eslint-plugin-promise from 3.8.0 to 4.0.0 (#1950)
Bumps [eslint-plugin-promise](https://github.com/xjamundx/eslint-plugin-promise) from 3.8.0 to 4.0.0.
- [Release notes](https://github.com/xjamundx/eslint-plugin-promise/releases)
- [Changelog](https://github.com/xjamundx/eslint-plugin-promise/blob/master/CHANGELOG.md)
- [Commits](https://github.com/xjamundx/eslint-plugin-promise/compare/v3.8.0...v4.0.0)

Signed-off-by: dependabot[bot] <support@dependabot.com>
2018-08-20 10:00:04 -04:00
Paul Melnikow
a16d436602 Optionally persist [Github] tokens in Redis (#1939)
This is a fairly simple addition of a Redis-backed TokenPersistence. When GithubConstellation is initialized, it will create a FsTokenPersistence or a RedisTokenPersistence based on configuration. Have added tests of the Redis backend as an integration test, and ensured the server starts up correctly when a `REDIS_URL` is configured.

Ref: #1848
2018-08-19 10:27:23 -04:00
Paul Melnikow
b10a6a4aa7 Refactor [github] token persistence, again (#1906)
Instead of saving tokens on a timer, save them when they change. Use EventEmitter to keep the components loosely coupled.

This is easier to reason about, much easier to test, and better supports adapting to backends which support atomic operations.

This replaces json-autosave, which was a bit difficult to read and also hard to test, with fsos, the lower-level utility it’s built on.

Ref: #1848
2018-08-18 23:54:53 -04:00
Paul Melnikow
9119c235a9 Prevent merging exclusive service tests (#1926)
* Remove an .only() left behind previously
2018-08-16 11:06:08 -07:00
dependabot[bot]
30d746653b Bump request from 2.87.0 to 2.88.0 (#1911)
Bumps [request](https://github.com/request/request) from 2.87.0 to 2.88.0.
- [Release notes](https://github.com/request/request/releases)
- [Changelog](https://github.com/request/request/blob/master/CHANGELOG.md)
- [Commits](https://github.com/request/request/compare/v2.87.0...v2.88.0)

Signed-off-by: dependabot[bot] <support@dependabot.com>
2018-08-15 21:44:24 +01:00
dependabot[bot]
8b34a927dd Bump eslint-config-prettier from 2.9.0 to 3.0.1 (#1916)
Bumps [eslint-config-prettier](https://github.com/prettier/eslint-config-prettier) from 2.9.0 to 3.0.1.
- [Release notes](https://github.com/prettier/eslint-config-prettier/releases)
- [Changelog](https://github.com/prettier/eslint-config-prettier/blob/master/CHANGELOG.md)
- [Commits](https://github.com/prettier/eslint-config-prettier/compare/v2.9.0...v3.0.1)

Signed-off-by: dependabot[bot] <support@dependabot.com>
2018-08-14 08:05:20 -07:00
Paul Melnikow
66d444aa40 Clean up our callback style and enforce no exclusive tests and remove an exclusive test (#1900)
We use arrow functions in most places; this enforces it.

Passing arrow functions to Mocha is discouraged: https://mochajs.org/#arrow-functions

This was a mix of autofixes and hand adjustments.
2018-08-12 20:45:43 -04:00
Paul Melnikow
9007658fd0 Refactor and test [github] token persistence (#1863)
Ref #1848 #1205
2018-08-11 20:13:40 -04:00
dependabot[bot]
15a1449407 Bump redis from 2.6.5 to 2.8.0 (#1855)
Bumps [redis](https://github.com/NodeRedis/node_redis) from 2.6.5 to 2.8.0.
- [Release notes](https://github.com/NodeRedis/node_redis/releases)
- [Changelog](https://github.com/NodeRedis/node_redis/blob/master/changelog.md)
- [Commits](https://github.com/NodeRedis/node_redis/commits)

Signed-off-by: dependabot[bot] <support@dependabot.com>
2018-08-10 15:38:03 -04:00
Paul Melnikow
0db88d33e0 Add debug logging to BaseService and BaseJsonService (#1867)
Invoke this using `npm run test:services:trace`.
2018-08-10 15:22:13 -04:00
Paul Melnikow
27170f85fc Rm greenkeeper config (#1871) 2018-08-09 11:07:14 -04:00
dependabot[bot]
68e6ed9d5a Bump prettier from 1.14.0 to 1.14.2 (#1869)
Bumps [prettier](https://github.com/prettier/prettier) from 1.14.0 to 1.14.2.
- [Release notes](https://github.com/prettier/prettier/releases)
- [Changelog](https://github.com/prettier/prettier/blob/master/CHANGELOG.md)
- [Commits](https://github.com/prettier/prettier/compare/1.14.0...1.14.2)

Signed-off-by: dependabot[bot] <support@dependabot.com>
2018-08-09 09:47:07 -04:00
Paul Melnikow
ab051b3804 Turn on prettier (except repo root) (#1167)
* Use prettier-check
* Update semi option
    See discussion https://github.com/badges/shields/issues/948#issuecomment-349205606
* Developer documentation
* Run the same steps in both `main` jobs
* Move integration tests from `danger` to `main` where they belong
2018-08-08 17:49:06 -04:00
Paul Melnikow
e3b100504d Add Joi-based request validation to BaseJsonService and rewrite [NPM] and [node] badges (#1743)
When JSON responses come back, they are sometimes not in the format expected by the API. As a result we have a lot of defensive coding (expressions like `(data || {}).someProperty`) to avoid exceptions being thrown in badge processing. Often we rely on the `try` blocks that wrap so much of the badge-processing code, which catch all JavaScript exceptions and return some error result, usually **invalid**. The problem with this is that these `try` blocks catch all sorts of programmer errors too, so when we see **invalid** we don't know whether the API returned something unexpected, or we've made a mistake. We also spend a lot of time writing defensive tests around malformed responses, and creating and maintaining the defensive coding.

A better solution is to validate the API responses using declarative contracts. Here the programmer says exactly what they expect from the API. That way, if the response isn't what we expect we can just say it's an **invalid json response**. And if our code then throws an exception, well that's our mistake; when we catch that we can call it a **shields internal error**. It's also less code and less error-prone. Over time we may be confident enough in the contracts that we won't need so many tests of malformed responses. The contract doesn't need to describe the entire response, only the part that's needed. Unknown keys can simply be dropped, preventing unvalidated parts of the response from creeping into the code. Checking what's in our response before calling values on it also makes our code more secure.

I used Joi here, since we're already using it for testing. There may be another contracts library that's a better fit, though I think we could look at that later.

Those changes are in base.js.

The rest is a rewrite of the remaining NPM badges, including the extraction of an NpmBase class. Inspired by @chris48s's work in #1740, this class splits the service concerns into fetching, validation, transformation, and rendering. This is treated as a design pattern. See the PR discussion for more. There are two URL patterns, one which allows specifying a tag (used by e.g. the version badge `https://img.shields.io/npm/v/npm/next.svg`), and the other which does not accept a tag (e.g. the license badge `https://img.shields.io/npm/l/express.svg`). Subclasses like NpmLicense and NpmTypeDefinitions can specify the URL fragment, examples, the validation schema for the chunk of the package data they use, and a render function. The NpmVersion subclass uses a different endpoint, so it overrides the `handle` implementation from NpmBase.

The remaining services using BaseJsonService are shimmed, so they will keep working after the changes.
2018-08-08 17:08:16 -04:00
Paul Melnikow
56fcb2e5ba GithubApiProvider: injectible interface for code that calls github (#1812) 2018-08-07 16:46:12 -04:00
chris48s
cdce0b45e0 upgrade react and related dependencies (#1840) 2018-08-03 18:59:54 +01:00
Paul Melnikow
5d102dabb3 Update several lockfile dependencies using npm audit fix (#1833) 2018-08-03 18:46:12 +01:00
Danial
317e19ea2a Add support for simple-icons, colored icons with ?logoColor (#1810)
* add simple-icons

* handle undefined

* support logoColor param

* our icon > simple-icon

* dont crash 

* return false → undefined

* update test

* add test

* support logoColor on our logos

* cache as base64, pre-load-simple-icons, logo-helper

* add ?logoColor information

* and simple-icons reference, link to github master branch for our logos

* update simple-icons

update to 1.7.1

* Revert "and simple-icons reference, link to github master branch for our logos"

This reverts commit 5e99d5f8db.

* add link to simple-icons

* Add snapshot test

* support dash in place of space for logo name
2018-08-02 09:07:23 +12:00
greenkeeper[bot]
8020ff00e3 Update eslint to the latest version 🚀 (#1746)
* Work around upstream issue https://github.com/standard/standard/issues/1156#issuecomment-400048419
2018-08-01 16:55:42 -04:00
chris48s
901a7b8a43 Split front end into one page per category (#1808)
- Present 'downloads', 'version', etc as pages
- Don't show any badges on the index page,
  just links to categories.
- Tweak search so we can search all badges
  from the index page, but without rendering
  every badge as soon as we press a key.
2018-08-01 21:02:55 +01:00