Commit Graph
298 Commits
Author SHA1 Message Date
Marcin MielnickiandGitHub 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
Paul MelnikowandGitHub 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 MelnikowandGitHub 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 MelnikowandGitHub e4e5628207 Fix suggest on staging in Firefox (#2277)
Fix #2245
2018-11-09 14:06:13 -05:00
dependabot[bot]andPaul Melnikow 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
Paul MelnikowandGitHub 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 MelnikowandGitHub 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 MielnickiandGitHub 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
Paul MelnikowandGitHub d55e1c15a6 Enforce using async-await [f-droid] (#2241)
Close #2028
2018-11-04 00:33:47 -04:00
Paul MelnikowandGitHub 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
Paul MelnikowandGitHub 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 MelnikowandGitHub 275805e90c Add BaseSvgScrapingService and rewrite [ReadTheDocs]; also affects [codacy vso] (#2229)
Based on discussion in #2031, this adds an abstract service for SVG badges. I started with Readthedocs and the other services can be done as a follow-on.

I called it **BaseSvgScrapingService** rather than **BaseSvgService** to clarify that it's for badges from svg source data – not svg badges, which is all the badges.

Since I don't expect the svg parsing function to be used anywhere else once the services are refactored, I moved it into the class. I added a default value for `valueMatcher`, which works on Shields-style badges and seems to be used more than once.

The tests are based on XmlBaseService. I added one for valueMatcher, and also moved the SVG parsing badge here. Testing on codacy + vso should ensure the old `fetchFromSvg` is still working.
2018-11-01 15:09:00 -04:00
Paul MelnikowandGitHub 07b282fa1f Enforce property shorthand (#2243)
I had to track down the right lint rule for this. We have no-useless-rename for destructuring and import/export. The one for object literals is object-shorthand.
2018-11-01 13:46:23 -04:00
Paul MelnikowandGitHub b7ecbd0a0d Move build badge examples into services/ (#2234)
all-badge-examples is a common cause of merge conflicts. It’s difficult to adjust the badge categorization in that file – or to understand the diff – because it requires moving a block from one point to another. It’s much easier to edit a badge’s category in one place.

This starts the process of breaking up what’s left of that file, following up on the work from #1931. New-style services can only be in one category, which means legacy service examples have to be split along category lines. I split out separate legacy service classes where I could do so easily, leaving behind the ones which require more work, for one reason or another.
2018-10-31 17:32:35 -04:00
Paul MelnikowandGitHub 07c5f47a73 Rework [suggest] code using async/await (#2029) 2018-10-31 17:19:14 -04:00
chris48sandGitHub 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
Tagan Hoyleandchris48s b6c851a377 Refactor [Requires]IO (#2220) 2018-10-28 16:19:39 +00:00
Paul MelnikowandGitHub 6e51178e73 Make more consistent use of async/await (#2219)
In #2028 I suggested that we update as much of the code as possible to make consistent use of async await. This snags a bunch of the utility code and attempts to do that.
2018-10-28 11:34:47 -04:00
Tagan HoyleandPierre-Yves B 60592b8547 Refactor [Wordpress] Service (#2152) 2018-10-27 11:59:43 +01:00
Thomas DémoulinsandPierre-Yves B 979a34b831 #2082 Rename VSTS into Azure DevOps + update its documentation (#2206) 2018-10-27 09:54:31 +01:00
Tagan HoyleandPierre-Yves B 6e8c71b01b Refactor [Swagger] Service (#2215) 2018-10-27 09:30:26 +01:00
chris48sandGitHub b866089c64 allow badge maxAge to be set by category; affects [discord] (#2205)
* allow badge maxAge to be set by category
* override default cache length for [discord]
* update maxAge docs
2018-10-26 20:08:02 +01:00
chris48sandGitHub 744ef16009 refactor [depfu] service (#2204) 2018-10-23 18:24:14 +01:00
Pierre-Yves BandGitHub efb40fe4c0 Static Code Climate examples (#2201) 2018-10-23 18:12:29 +01:00
chris48sandGitHub 8ee2701836 refactor [hexpm] service (#2203) 2018-10-23 18:06:57 +01:00
Anatoli Babeniaandchris48s 9df1da137c Document suggestion API endpoint (#2202) 2018-10-21 14:41:12 +01:00
Przemo NowaczykandMarcin Mielnicki 4554f49c1e use most permissive license color (#2196)
* use most permissive license color

* revert to possible non-array licenseToColor argument
2018-10-20 15:15:10 +02:00
Przemo NowaczykandMarcin Mielnicki 6f589a789a [ctan] refactor service (#2194)
* refactor ctan service

* fix service title

* prettier

* add single license test

* move example code to service
2018-10-20 14:51:25 +02:00
chris48sandGitHub 32b123671c refactor [ansible] role service (#2158) 2018-10-19 19:23:41 +01:00
PyvesandGitHub 16dc2ec3a9 [Jenkins] coverage badges rewrite (#2154) 2018-10-11 21:42:47 +01:00
chris48sandGitHub 9d7f27d84e add refactoring report (#2163) 2018-10-10 19:22:30 +01:00
chris48sandGitHub a74db34853 Allow [GitHub] tag badge to sort by date (#2157)
* add test for tag-pre
* support /releases-pre (but also allow /all for BC)
* allow GH tags to be sorted by date instead of semver
* fix license badge
2018-10-08 18:29:02 +01:00
chris48sandGitHub 7ea540d3c6 refactor arch user repositories [aur] service (#2086) 2018-10-06 16:51:15 +01:00
Sven Schoenungandchris48s c058dbdcd9 Fix: keywords missing from prepared examples (#2143) 2018-10-03 19:08:05 +01:00
chris48sandGitHub aef9a4efd1 remove duplicate PyPI examples (#2133) 2018-10-01 20:44:08 +01:00
chris48sandGitHub 595212ff78 consistently style Github as GitHub in examples (#2134) 2018-10-01 20:40:39 +01:00
Marcin MielnickiandGitHub 4ccd6bf4dc [Dub] downloads badge with available version (#2129)
* Service test for DUB tests the newset version

* Working example of the DUB downloads badge with version
2018-10-01 18:10:43 +02:00
Christian Oliffandchris48s 33167afa64 correct GitHub capitalization (#2095) 2018-09-30 21:19:34 +01:00
chris48sandGitHub 264f5e39dc refactor [discord] service (#2107) 2018-09-28 21:00:21 +01:00
PyvesandGitHub 8e963459cd Deprecated libscore (#2105) 2018-09-22 12:28:54 +01:00
PyvesandGitHub a4bec27771 Fixed [Codacy] coverage examples and improved unknown coverage handling (#2102) 2018-09-21 22:49:35 +01:00
PyvesandGitHub 006710e16d Fixed [Codacy] badges (#2066) 2018-09-10 20:32:49 +01:00
PyvesandGitHub bf0496cd64 Made JSON snapshot test pass on Windows (#2061) 2018-09-10 19:27:05 +01:00
PyvesandGitHub 3e69873930 [aur packagist php-eye travis vaadin-directory github david jitpack twitter] Enforced lowercase badge labels (#2058) 2018-09-09 11:41:10 +01:00
Paul MelnikowandGitHub 4a847d2b08 [AppVeyorTests] compact format and custom labels (#2000)
This picks up the work from #1321 on top of the work from #1940.

It allows the user to choose a compact tests format, or to override the labels with their own text or symbols.
2018-09-08 09:27:59 -07:00
Thomas DémoulinsandPyves 548b509dff [vso] Add support for VSTS releases (#2049) 2018-09-06 19:05:02 +01:00
PyvesandGitHub 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
Y0hy0handchris48s 73c954df57 [elm-package] Fix old package name (#2045)
* Update test's package to new name
* Update preview badge's package to new name
2018-09-02 16:20:06 +01:00
PyvesandGitHub 7153ed0bd1 Deprecate [issuestats] service (#2038) 2018-09-01 20:53:52 +01:00
Paul MelnikowandGitHub 102141123b Unify lint rules and clean lint (#2009)
Now that server.js is emptied out, it makes sense to eliminate the differences between the top-level .js files and everything else.
2018-09-01 11:08:17 -07:00