Commit Graph

83 Commits

Author SHA1 Message Date
Paul Melnikow
d8ce045ead Adopt Gatsby (#2906)
While Next.js can handle static sites, we've had a few issues with it, notably a performance hit at runtime and some bugginess around routing and SSR. Gatsby being fully intended for high-performance static sites makes it a great technical fit for the Shields frontend. The `createPages()` API should be a really nice way to add a page for each service family, for example.

This migrates the frontend from Next.js to Gatsby. Gatsby is a powerful tool, which has a bit of downside as there's a lot to dig through. Overall I found configuration easier than Next.js. There are a lot of plugins and for the most part they worked out of the box. The documentation is good.

Links are cleaner now: there is no #. This will break old links though perhaps we could add some redirection to help with that. The only one I’m really concerned about `/#/endpoint`. I’m not sure if folks are deep-linking to the category pages.

There are a lot of enhancements we could add, in order to speed up the site even more. In particular we could think about inlining the SVGs rather than making separate requests for each one.

While Gatsby recommends GraphQL, it's not required. To keep things simple and reduce the learning curve, I did not use it here.

Close #1943 
Fix #2837 Fix #2616
2019-02-06 16:37:55 -05:00
Caleb Cartwright
855c9cd261 Remove dev dep imports in production code (#2937)
Fixes #2876 with @paulmelnikow's suggestion 

Moved imports of `ServiceTester` and `createServiceTester` to a separate file so that dev dependencies are not imported by service classes.
2019-02-05 21:51:55 -05:00
Paul Melnikow
e083dd3ce5 deprecatedService: rename url to route for consistency; test on [versioneye] (#2938) 2019-02-05 21:37:00 -05:00
Paul Melnikow
3a7bddbc26 Consolidate service definition schema, removing support for previewUrl (#2895)
This removes `LONG_CACHE` and its descendants, which was a feature that added `?maxAge` to the live preview badges in the frontend. Since they are all static that is no longer needed, as the static badges all have longer cache timeouts regardless.
2019-01-30 18:35:11 -06:00
Paul Melnikow
f32306d982 Update production DNS access doc (#2899)
* Update production DNS access doc

Thanks @olivierlacan!

* Add link to DNS registrar

* Updates
2019-01-30 17:41:44 -06:00
chris48s
a47fb2895d update logo guidance (#2888)
Ref #2510
2019-01-29 15:29:51 -06:00
Paul Melnikow
e10e8b1b6d Code walkthrough (#2877)
Updated based on comments received in the Google Doc.

Close #2684
2019-01-28 15:03:05 -06:00
Paul Melnikow
fc12b591db Reorganize BaseService-related modules (#2831)
Ref #2698
2019-01-22 23:52:13 -05:00
Paul Melnikow
aac2a4d5ad Move legacy request helpers (#2829)
In #2698 we decided to put legacy helper functions in `core/legacy`. I think that’s a fine idea, though if we’re going to have a bunch of badge helper functions in there, it seems like it is probably better to keep these two important but esoteric helper functions with the core code to which they are most coupled. So I added `legacy-` to the name, and put them in `core/base-service`.
2019-01-21 22:14:22 -05:00
Paul Melnikow
226fa67a02 Create shortcut for BaseService-related imports (#2809)
Continue to implement #2698:

- Add `core/base-service/index.js` (but hold off on moving the things it imports)
- Add shortcuts in `services/index.js` for Base*Service, errors, and deprecatedService. This file will be streamlined later to avoid cluttering it with rarely used bits.
- Apply consistent ordering of imports and use of `module.exports` in testers.
- Remove some renaming of imports.
- Remove obsolete tests here and there.
2019-01-21 15:41:24 -05:00
Paul Melnikow
97e719f226 Make it harder to accidentally trigger all the service tests (#2789)
It’s happened twice that `[*]` has ended up in a PR title and the full test run has happened inadvertently. Once was me and once was a new contributor.

This raises the bar on doing it accidentally.
2019-01-16 16:58:17 -05:00
Paul Melnikow
4597d77015 Refactor badge color functions (#2742)
- Replace the idea of color schemes with the idea of named colors (since none of our colorschemes have used `colorA`)
- Pass through the normalized color to `_shields_test` to harmonize with BaseService and simplify testing
    - Update service tests
- Move responsibility for color generation into the npm package
- Remove several color helper functions and their tests
- Update gh-badge public API to accept `color` and `labelColor`

This is a precursor to refactoring some of the logo code for #2473.
2019-01-15 16:43:33 -05:00
Pierre-Yves B
55ce947a35 Extended usage of build-status.js tomore services (#2763)
* Extended usage of build-status.js

* Removed remaining status arguments
2019-01-15 20:27:18 +00:00
Paul Melnikow
b3606724fd Wildcard to run all service tests [*] (#2739)
Close #2685.
2019-01-11 16:11:46 -05:00
James Cahill
3f118f8442 TUTORIAL.md - use localhost instead of others (#2735)
Seeing as npm start now uses localhost instead of instead of 127.0.0.1 or [::], just updating it in the tutorial.
2019-01-11 13:57:51 -05:00
Paul Melnikow
d1c5378bf0 Integrate new path-to-regexp with trailing optionals (#2644)
Fix #2497

Ref pillarjs/path-to-regexp#176
2019-01-08 18:50:47 -05:00
Jan Keromnes
3ab2862922 Fix a few typos (#2697)
* Fix typos (using 'codespell -w')

* Properly capitalize Git and GitHub in TUTORIAL.md
2019-01-08 12:08:50 -05:00
Paul Melnikow
ebfd6cf8ee We don't use Docker in production (#2690)
I found an old note to myself to document this.
2019-01-07 22:00:36 -05:00
Paul Melnikow
1e267f891d Document production hosting (#2661) 2019-01-07 20:55:49 -05:00
Paul Melnikow
8c7404a571 Run Prettier on the rest of the things (#2662) 2019-01-07 18:33:17 -05:00
Paul Melnikow
89113eee17 Migrate deprecated staticExample -> staticPreview (#2650) 2019-01-06 17:30:25 -05:00
Paul Melnikow
fa5309400d PaaS, CI, and production-friendly config (#2626)
This implements the configuration mechanism I described in #2621. The heavy lifting is delegated to [node-config](https://github.com/lorenwest/node-config) with a minor assist from [dotenv](https://github.com/motdotla/dotenv).

`private/secret.json` has been replaced with environment variables and/or `config/local.yml`. See `doc/server-secrets.md`.
2019-01-06 10:42:09 -05:00
chris48s
d96d8ae193 Document private/secret.json; affects [bower jira] (#2599)
* don't use a libraries.io token for bower integration

The libraries.io docs claim you need to be authenticated
to make any API request: https://libraries.io/api#authentication

In practice we can call https://libraries.io/api/bower/jquery
just fine with no token and based on chucking a load of
requests at it and examining the `x-ratelimit-remaining`
headers you actually seem to get a better limit with no
authentication.

All of our libraries.io badges in `services/librariesio`
seem to have been running fine with no token for some time.


* change jira auth settings to jira_user, jira_pass

All the other services use servicename_user, servicename_pass

This switches JIRA to use that convention by preference
but supports _username and _password for legacy users.


* add docs for server secrets


* add danger rule for server-secrets.md

this rule prompts users to update server-secrets.md
if 'serverSecrets' is in the diff
2019-01-02 20:49:42 +00:00
chris48s
6c01027c63 improve setup instructions (#2592)
* improve setup instructions

* move node/npm install out to pre-requisites section
2018-12-26 21:22:56 +00:00
Paul Melnikow
75a0c67562 Update list of prod secrets (#2573) 2018-12-23 11:33:54 -05:00
chris48s
bca7416be7 couple of fixes to service test docs (#2542) 2018-12-16 20:50:07 +00:00
Caleb Cartwright
dea35025b1 Deprecate [nsp] service (#2529)
deprecated nsp service and added doc for deprecation
2018-12-16 19:21:22 +00:00
Pierre-Yves B
c89396088d [Wheelmap] service rewrite and tests (#2486) 2018-12-10 18:44:47 +00:00
Paul Melnikow
58b276539a Refactor frontend main page and badge-example code (#2441)
- The goal of this PR is:
    - Consume the new service-definition format. (#2397)
    - Make the frontend more readable.
- Behavior changes:
    - I changed the **Image** field in the markup modal to show only the path.
    - I added another click-to-select field below that shows the complete URL.
    - This made it easier to suppress the live badge preview while it contains placeholders like `:user` or `:gem`, a minor tweak discussed at https://github.com/badges/shields/issues/2427#issuecomment-442972100.
    - The search box now searches all categories, regardless of the current page. (This is an improvement, I would say.)
- I did not deliberately address performance, though I ripped out a bunch of anonymous functions and avoided re-filtering all the examples by category on every render, which I expect will not hurt. I haven't really tested this on a mobile connection and it'd be worth doing that.
- It would be great to have some tests of the components, though getting started with that seemed like a big project and I did not want to make this any larger than it already is.

It's a medium-sized refactor:

1. Replace `BadgeExamples`, `Category` and `Badge` component with a completely rewritten `BadgeExamples` component which renders a table of badges, and `CategoryHeading` and `CategoryHeadings` components.
2. Refactor `ExamplesPage` and `SearchResults` components into a new `Main` component.
3. Rewrite the data flow for `MarkupModal`. Rather than rely on unmounting and remounting the component to copy the badge URL into state, employ the `getDerivedStateFromProps` lifecycle method.
4. Remove `prepareExamples` and `all-badge-examples`.
5. Rewrite the `$suggest` schema to harmonize with the service definition format. It's not backward-compatible which means at deploy time there probably will be 10–20 minutes of downtime on that feature, between the first server deploy and the final gh-pages deploy.  🤷‍♂️ (We could leave the old version in place if it seems worth it.)
6. Added two new functions in `make-badge-url` with tests. I removed _most_ of the uses of the old functions, but there are some in parts of the frontend I didn't touch like the static and dynamic badge generators, and again I didn't want to make this any larger than it already is.
7. Fix a couple bugs in the service-definition export.
2018-12-08 15:26:13 -05:00
Paul Melnikow
8a8311d931 Unify and minimize tester boilerplate (#2472)
I started using this one-line boilerplate a while back and it seems to tidy things up a bit.
2018-12-08 13:15:24 -05:00
Paul Melnikow
daa47f88a6 Fix doc: trailing, not leading (#2459) 2018-12-05 16:42:02 -05:00
chris48s
37d27a8e6a couples of fixes to docs on porting legacy services (#2456)
- use the right issue no and link to it
- fix the trace command example
2018-12-04 22:17:42 +00:00
Paul Melnikow
99e846d2ab Link together some of the documentation (#2446) 2018-12-03 18:05:34 -05:00
Paul Melnikow
e3ad57d8fe Add tips for rewriting legacy services (#2429) 2018-12-03 00:27:12 -05:00
anatoly techtonik
07063fd1be TUTORIAL.md: Service handles requests to external APIs (#2422) 2018-11-29 20:08:20 -05:00
anatoly techtonik
1144dba14a TUTORIAL.md: Mention URL mapping upfront and clarify static meaning (#2425)
* TUTORIAL.md: Mention URL mapping upfront and clarify static meaning

* Be more specific that route is URL

* Explain async without reference to prior knowledge

* Use the same example URL to explain the directory layout

* Clean diff

* `route()` + `static`

- The route includes the base URL, so try to clarify that
- Add some more information about `static`
2018-11-29 14:46:42 -05:00
Paul Melnikow
a7efd88ceb Revert to standard CI image and remove lingering references to fonts (#2326)
Follow-on to #2311.
2018-11-18 09:08:23 -05:00
Paul Melnikow
84a5be3946 Declare static examples using namedParams (#2308)
This continues the work from #2279, by allowing example badges to be specified using `namedParams`. Using an object makes it possible for us to display these in form fields down the line. (#701)

I've called this the "preferred" way, and labeled the other ways deprecated. I've also added some doc to the `examples` property in BaseService. Then I realized we had some doc in the tutorial, though I think it's fine to have a short version in the tutorial, and the gory detail in BaseService.

I've also added a `pattern` keyword, and made `urlPattern` an alias.

Closes #2050.
2018-11-17 09:47:25 -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
Tien Pham
29fedc3448 Docs improvement (#2299) 2018-11-11 13:27:37 -06: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
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
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
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
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
Ted Janeczko
a6fe16c5d1 Add support for private [npm] packages (#2187) 2018-10-20 08:06:36 +01:00
chris48s
362db466bb update service tests tutorial (#2075)
* update service tests tutorial
* re-order and re-name tests for clarity
* update documentation examples
* extract boilerplate for testing colours
2018-10-01 20:53:04 +01:00
chris48s
10e8232ffa Add multiple issue templates (#2128) 2018-09-30 17:00:09 +01:00
chris48s
ef6e601aaa Update tutorial to reflect new service layout (#2042)
update the tutorial for new service class layout
2018-09-05 21:34:41 +01:00
Nicco Kunzmann
e25e748a03 Obsolete old tutorial and future TODOs (#1983)
This obsoletes the implementation part of the tutorial.
As mentioned in https://github.com/badges/shields/pull/1958#pullrequestreview-149661148, 
old style badges should be avoided and new style badges are preferred.
2018-09-02 11:41:33 -07:00