Commit Graph

2164 Commits

Author SHA1 Message Date
Paul Melnikow
fe05d00747 Move github examples into services/github (#2309) 2018-11-15 15:57:56 -05:00
Paul Melnikow
5d63effabc Fix a crasher in production (#2313)
When I deployed 5e99aad2de to s0, shortly after Sentry picked up an unhandled error. I'm not sure which of the legacy badges this is in.

The bug was introduced just now, in #2257. Oops!

A test would have caught this, but I don't think it's worth wrapping tests around this difficult-to-test code. It makes more sense I think, to refactor the remaining badges that use it, replace it with something using async/await (maybe based on [node-cache](https://www.npmjs.com/package/node-cache), and test that.
2018-11-15 14:25:46 -05:00
chris48s
b68ac16092 Move NPM package files out of /lib ; affects [resharper nuget myget dub chocolatey github] (#2300)
* move gh-badges files out of /lib

As far as possible, this is just moving files
around and updating paths however there are 2
functional changes in this commit:
- remove use of lib/register-chai-plugins.spec
  in badge-cli.spec.js
- remove use of starRating()
  in text-measurer.spec.js

* update service tests that use colorscheme.json

* split package.json in two

* clean up import

* don't hard-code path

* start a changelog

* put a license file in the package dir

* re-organise documentation 📚

* don't pack test files

* remove favicon from Makefile

* give package its own test command

* link the docs better in README
2018-11-15 18:48:01 +00:00
Emlyn Corrin
aed39bfde9 [Clojars] Add downloads badge (#2305)
Add Clojars downloads badge
2018-11-15 18:32:22 +00:00
dependabot[bot]
83e44b7e7d Bump prettier from 1.15.1 to 1.15.2 (#2321)
* Bump prettier from 1.15.1 to 1.15.2

Bumps [prettier](https://github.com/prettier/prettier) from 1.15.1 to 1.15.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.15.1...1.15.2)

Signed-off-by: dependabot[bot] <support@dependabot.com>

* Run prettier
2018-11-15 09:50:48 -05:00
dependabot[bot]
17716953f2 Bump eslint-config-prettier from 3.1.0 to 3.3.0 (#2304) 2018-11-15 00:44:59 +00:00
dependabot[bot]
81691c5bb3 Bump opn-cli from 3.1.0 to 4.0.0 (#2303) 2018-11-15 00:30:53 +00:00
dependabot[bot]
e46a6fbde1 Bump snap-shot-it from 6.1.10 to 6.2.3 (#2301)
Bumps [snap-shot-it](https://github.com/bahmutov/snap-shot-it) from 6.1.10 to 6.2.3.
- [Release notes](https://github.com/bahmutov/snap-shot-it/releases)
- [Commits](https://github.com/bahmutov/snap-shot-it/compare/v6.1.10...v6.2.3)

Signed-off-by: dependabot[bot] <support@dependabot.com>
2018-11-14 19:19:36 -05:00
Paul Melnikow
5e99aad2de Rewrite [NuGet] badges including [myget chocolatey resharper powershellgallery] (#2257)
The NuGet badge examples are straggling in all-badge-examples. Rather than move them as is, I thought it made more sense to refactor the services and see if they could be generated. I didn't take that on here; this is a straight rewrite of the badges. The old implementations were fairly difficult to follow. The new implementations are complicated too, though I hope much more readable.

Though the NuGet behaviors could be consolidated into a single flag, I split `withTenant` and `withFeed` into separate flags, thinking naming the behaviors makes the implementations easier to understand. I defaulted these to true, thinking that really this is really a MyGet implementation which is generalized to NuGet. Though maybe it makes more sense to have the MyGet style as the default. Probably it doesn't matter much either way.

I added a helper class ServiceUrlBuilder to construct the Shields service URL. It's useful in this complex case where the URL must be built up conditionally. This might be useful in a couple other places.

I also wrote a new service to handle the Powershell badges. They've diverged a little bit from the Nuget v2. There's a bit of shared code which I factored out.

If the XML Nuget APIs are more reliable, we could consider switching everything else over to them, though for now I would like to get this merged and get #2078 fixed.

Fix #2078
2018-11-14 17:28:15 -05:00
Paul Melnikow
510491f376 Try to fix recent CircleCI failures (#2306)
All the recent circle builds are failing and when I re-ran a build on master, I'm seeing the same failure.

```

npm ERR! path /root/repo/node_modules/gh-badges
npm ERR! code ENOENT
npm ERR! errno -2
npm ERR! syscall access
npm ERR! enoent ENOENT: no such file or directory, access '/root/repo/node_modules/gh-badges'
npm ERR! enoent This is related to npm not being able to find a file.
npm ERR! enoent 

npm ERR! A complete log of this run can be found in:
npm ERR!     /root/.npm/_logs/2018-11-12T14_28_41_232Z-debug.log
Exited with code 254
```

After reading https://discuss.circleci.com/t/cant-run-npm-install/19012 I wonder if it's related to the `working_directory` line. That issue suggests not using it.
2018-11-12 12:26:42 -06:00
Tien Pham
29fedc3448 Docs improvement (#2299) 2018-11-11 13:27:37 -06:00
Paul Melnikow
652d2e5611 Remove extra file checked in by mistake (#2298) 2018-11-11 09:48:32 -06:00
Marcin Mielnicki
a039fffe79 Refactor [Jetbrains] service; affects [eclipse-marketplace] (#2232)
* Refactor Jetbrains

* Test that custom parser options are provided

* Code refactoring

* Code refactoring

* url -> route

* package-lock.json updated
2018-11-10 16:05:00 +01:00
chris48s
d0fe97d136 refactor [docker] service (#2263) 2018-11-09 21:57:13 +00:00
chris48s
4b88590619 bump version (#2296) 2.0.0 2018-11-09 21:53:47 +00:00
Paul Melnikow
5dd4ee078b Start on the Github rewrite, with [GithubPullRequestCheckState] (#2253)
The GitHub service family is the largest, and as yet untouched by our service rewrite. I thought I would start the process by tackling one service.

This pull request has a few things going on:

1. Rename pull-request-status to pull-request-check-state. We have another badge called pull request status. It seems like the checks are called one thing in the UI and another thing in the API, which is unfortunate. If other folks have strong feelings about the name, I’ll defer.
2. Move its tests and tighten up the syntax.
3. Move its badge examples including the doc string.
4. Add a new helper `errorMessagesFor` to use in the new services in place of `githubCheckErrorResponse`. It seems like we didn’t really use the `errorMessages` parameter to `githubCheckErrorResponse`, so I pared this down. I’m not sure if this is the function we’ll ultimately want, but it seems like a good place to start.
5. Pull fetch code I _know_ we use in other places into `github-common-fetch`. As in the PR I just opened for azure-devops, this takes a functional approach to the shared code, which is more direct, nimble, and easy to reason about than inheritance.
6. Create `GithubAuthService` which functions identically to BaseJsonService, except for one thing, which is that it uses the token pool. I accomplished this by adding a `_requestFetcher` property to BaseService, which is initialized to `sendAndCacheRequest` in the constructor, and can be overridden in subclasses. Since we weren’t using `_sendAndCacheRequest` directly except in BaseService and tests, I removed that property. I like this approach to patching in the GitHub auth because it’s very simple and creates no new API exposure. However, the way we’re doing the dependency injection feels a bit odd. Maybe the eventual refactor of request-handler would be a godo time to revisit this.

The GitHub requests go through many, many layers of indirection at this point. Later on it would be good to shave some of these off, perhaps once the legacy GitHub services have been converted, or when all the services are done and we can take another look at the base service hierarchy. The work in #2021 and #1205 is also related.
2018-11-09 16:22:48 -05:00
Paul Melnikow
2bc2450d19 Fix hex colors in static examples (#2295)
Fix a regression from #2240 which was noticed here:

https://github.com/badges/shields/pull/2253#issuecomment-437415722
2018-11-09 15:26:03 -05:00
Paul Melnikow
3eac8ebbfb Rework GitHub acceptor and move to its own module (#2021)
Continue to merge the work from #1205.
2018-11-09 15:14:01 -05:00
Paul Melnikow
02ec19fd22 BaseService terminology: Rename url to route (#2278)
The term “url” is overloaded in services, to refer to the Shields route and also the API URL. Calling the Shields URL a “route” is on the whole more descriptive, and makes it clearer and more obvious which one of these we’re talking about. It’s a small thing, though seems like an improvement.

We have a few functions called `buildUrl`. I’ve renamed them to `buildRoute` when they refer to routes, and left them as `buildUrl` when they refer to API URLs.

I included a minor style tweak and some formatting cleanup in `TUTORIAL.md`.
2018-11-09 15:11:03 -05:00
Paul Melnikow
c0f9a88719 Website: Tweak footer and usage (#2285) 2018-11-09 14:47:23 -05:00
Paul Melnikow
e4e5628207 Fix suggest on staging in Firefox (#2277)
Fix #2245
2018-11-09 14:06:13 -05:00
Paul Melnikow
c4af2cac53 Convert a bunch of URL formats to patterns (#2293)
Follow-on to #2279
2018-11-09 14:03:00 -05:00
dependabot[bot]
ec65291a11 Bump simple-icons from 1.9.12 to 1.9.13 (#2294)
Bumps [simple-icons](https://github.com/simple-icons/simple-icons) from 1.9.12 to 1.9.13.
- [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-09 17:54:41 +00:00
dependabot[bot]
804c4e4a6f Bump danger from 4.4.8 to 6.0.5 (#2291)
Bumps [danger](https://github.com/danger/danger-js) from 4.4.8 to 6.0.5.
- [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/4.4.8...6.0.5)

Signed-off-by: dependabot[bot] <support@dependabot.com>
2018-11-09 16:35:26 +00:00
Paul Melnikow
291f35d4ad Reduce duplication in badge regex/url patterns (#2279)
This reduces duplication in badge regex/url patterns, and reduces the need to understand regexes in order to create badges.

Ref: #2050
2018-11-08 15:05:44 -05:00
Paul Melnikow
611e58e43e Make a few github tests more reliable (#2292)
The version test is failing because the shields repo version is not a dotted version.
2018-11-08 14:48:44 -05:00
dependabot[bot]
e240409033 Bump prettier from 1.14.3 to 1.15.1 (#2289)
* Bump prettier from 1.14.3 to 1.15.1

Bumps [prettier](https://github.com/prettier/prettier) from 1.14.3 to 1.15.1.
- [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.3...1.15.1)

Signed-off-by: dependabot[bot] <support@dependabot.com>

* Run prettier
2018-11-08 14:39:00 -05:00
dependabot[bot]
57e4d82a90 Bump joi from 14.0.3 to 14.0.4 (#2267)
Bumps [joi](https://github.com/hapijs/joi) from 14.0.3 to 14.0.4.
- [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.3...v14.0.4)

Signed-off-by: dependabot[bot] <support@dependabot.com>
2018-11-08 19:31:25 +00:00
dependabot[bot]
c600bf4800 Bump node-fetch from 2.2.0 to 2.2.1 (#2276)
Bumps [node-fetch](https://github.com/bitinn/node-fetch) from 2.2.0 to 2.2.1.
- [Release notes](https://github.com/bitinn/node-fetch/releases)
- [Changelog](https://github.com/bitinn/node-fetch/blob/master/CHANGELOG.md)
- [Commits](https://github.com/bitinn/node-fetch/compare/v2.2.0...v2.2.1)

Signed-off-by: dependabot[bot] <support@dependabot.com>
2018-11-08 19:02:42 +00:00
chris48s
9c658a1345 fix [hexpm] validation (#2282)
closes #2272
2018-11-06 22:28:27 +00:00
chris48s
6199b1a878 add not found tests back in for [depfu hexpm requires] (#2281)
* add not found tests back in for [depfu hexpm requires]
* update the docs
2018-11-06 22:24:50 +00:00
chris48s
33d5f8f772 round [wordpress] rating (#2283)
closes #2280
2018-11-06 22:20:38 +00:00
Paul Melnikow
5019d81642 Add vso keyword to azure badges (#2274) 2018-11-06 16:17:49 -05:00
chris48s
b19d6d0072 refactor [bitbucket] service (#2261)
* refactor [bitbucket] service
2018-11-06 20:27:55 +00:00
dependabot[bot]
88402dd7a8 Bump simple-icons from 1.9.10 to 1.9.12 (#2273)
Bumps [simple-icons](https://github.com/simple-icons/simple-icons) from 1.9.10 to 1.9.12.
- [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-06 12:00:09 +13:00
dependabot[bot]
c8ce4fabb4 Bump nock from 10.0.1 to 10.0.2 (#2266)
Bumps [nock](https://github.com/nock/nock) from 10.0.1 to 10.0.2.
- [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/v10.0.1...v10.0.2)

Signed-off-by: dependabot[bot] <support@dependabot.com>
2018-11-05 16:58:19 -05:00
Paul Melnikow
3bb392dfae Remove some duplicated URL generation code (#2240)
I went down a rabbit hole while trying to untangle the bug in the dockbit and bitrise examples https://github.com/badges/shields/pull/2234#pullrequestreview-169997546.

The URL generation code is spaghetti-like, with functions, many of which I wrote, with opaque names, doing similar but not identical things, and making slightly incompatible assumptions about the way query strings are handled.

I got a bit lost and need to take a step back.

Meanwhile, this is a small piece of work I did that’s worth keeping. It doesn’t scratch the surface of the tangle, but it does remove a bit of duplication.

It also makes a minor stylistic ES6 change in the handling of default arguments.

Ref: #2027
2018-11-05 16:55:49 -05:00
Paul Melnikow
e983f7bf3b Rewrite vso, rename to [AzureDevops], validate SVG [readthedocs] (#2252)
1. Add validation to BaseSvgScrapingService and update readthedocs accordingly.
2. Rewrite vso and add more tests. Rename it internally to azure-devops. URLs are still `/vso` for now. Should we make a way to let a service register multiple URL patterns?
3. Handle shared code using a functional pattern instead of inheritance. This comes from a discussion https://github.com/badges/shields/pull/2031#issuecomment-417893819. I like the functional approach because it's more direct, nimble, and easy to reason about; plus it allows services to grow from a family of one to two more easily.
2018-11-05 16:52:53 -05:00
Paul Melnikow
600c369823 Remove some uses of to-be-deprecated url.format and url.parse APIs (#2265)
See #2225
2018-11-05 16:48:04 -05:00
Marcin Mielnicki
ba94610840 package-lock.json aded for files in Now config file (#2264) 2018-11-05 21:07:32 +01:00
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
Paul Melnikow
d55e1c15a6 Enforce using async-await [f-droid] (#2241)
Close #2028
2018-11-04 00:33:47 -04:00
Paul Melnikow
72768d32d9 Fix some npm audit warnings (bump debug) (#2258)
The only remaining vulnerabilites are in scoutcamp: espadrine/sc#64.
2018-11-04 00:23:37 -04:00
Paul Melnikow
83ac6ff1b3 Enforce use of template literals (#2242)
This is consistent with what we're pretty much already doing, and saves us from making the request during code review.

These were all autofixed and most of them seem easier to read. Some in the legacy services should be rewritten in more legible forms during refactor (ie using intermediate variables, or using request’s qs option). There are some in helper functions and elsewhere that should get rewritten separately. I don't want to change them in this PR because the changes will get lost in this diff, though we could identify them here and fix them before or just after.
2018-11-02 17:11:44 -04:00
dependabot[bot]
4a298cbcb0 Bump husky from 1.1.2 to 1.1.3 (#2254)
Bumps [husky](https://github.com/typicode/husky) from 1.1.2 to 1.1.3.
- [Release notes](https://github.com/typicode/husky/releases)
- [Changelog](https://github.com/typicode/husky/blob/master/CHANGELOG.md)
- [Commits](https://github.com/typicode/husky/compare/v1.1.2...v1.1.3)

Signed-off-by: dependabot[bot] <support@dependabot.com>
2018-11-02 20:39:38 +01:00
Paul Melnikow
8feb75d97d Move more badge examples into services/ (#2247)
Continuing the work from #2234, this creates additional, empty LegacyServices to hold the badge examples for conda and cocoapods. It's an approach we could take to finish emptying out all-badge-examples while the refactoring continues.

On the website badge, even the first URL path component is variable. I didn't think it could be moved, but it can!
2018-11-01 19:39:28 -04:00
Paul Melnikow
cdb4cb36a4 Improve static example validation message (#2246) 2018-11-01 19:36:25 -04: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]
a5894c5350 Bump sinon from 7.1.0 to 7.1.1 (#2248)
Bumps [sinon](https://github.com/sinonjs/sinon) from 7.1.0 to 7.1.1.
- [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/v7.1.0...v7.1.1)

Signed-off-by: dependabot[bot] <support@dependabot.com>
2018-11-01 20:18:21 +00:00