Commit Graph

67 Commits

Author SHA1 Message Date
Prashant Rawat
48458206f9 fix mismatch in documentation and examples given in tutorial (#9580) 2023-09-17 07:04:56 +00:00
jNullj
94a148b399 Docs: update TUTORIAL.md add BaseTomlService (#9518)
In the docs at TUTORIAL.md the new base service BaseTomlService was missing in the list of base services.
2023-08-27 11:15:10 +00:00
Prashant Rawat
865e8a0a01 use defaultBadgeData as object instead of function in tutorial docs (#9502) 2023-08-23 18:52:21 +00:00
chris48s
0ffa3669b3 deploy on node 18 (#9385)
* deploy on node 18, run tests on node 20

* run test-bug-run-badge on node 18

* you missed a spot

* ..and another
2023-08-10 18:40:17 +00:00
chris48s
f84ccb24ae upgrade to npm 9 (#9323) 2023-07-16 15:07:20 +01:00
chris48s
14892e3943 Implement a pattern for dealing with upstream APIs which are slow on the first hit; affects [endpoint] (#9233)
* allow serviceData to override cacheSeconds with a longer value

* prevent [endpoint] json cacheSeconds property exceeding service default

* allow ShieldsRuntimeError to specify a cacheSeconds property

By default error responses use the cacheLength of
the service class throwing the error.

This allows error to tell the handling layer the maxAge
that should be set on the error badge response.

* add customExceptions param

This

1. allows us to specify custom properties to pass to the exception
   constructor if we throw any of the standard got errors
   e.g: `ETIMEDOUT`, `ECONNRESET`, etc
2. uses a custom `cacheSeconds` property (if set on the exception)
   to set the response maxAge

* customExceptions --> systemErrors

* errorMessages --> httpErrors
2023-06-13 21:08:43 +01:00
Laurent Demailly
c773563e60 Correct issue template in footer (new badge requests url is incorrect) (#9153)
* Correct issue template in footer

https://github.com/badges/shields/issues/9152#issuecomment-1537534258

* Same in TUTORIAL.md
2023-05-07 16:18:33 -05:00
chris48s
07bc0325ee simplify NPM strict checks (#7973)
* simplify engine-strict/strict-peer-deps checks

* disable engine-strict for node 12/14 package tests

* update docs

Co-authored-by: repo-ranger[bot] <39074581+repo-ranger[bot]@users.noreply.github.com>
2022-05-17 20:23:06 +00:00
chris48s
c73072deed Remove requestOptions2GotOptions compatibility layer (#7270)
* gzip --> decompress

* strictSSL --> https.rejectUnauthorized

* auth --> username/password

* qs --> searchParams

* fix base service auth docs

* completely remove requestOptions2GotOptions layer

* update the docs

Co-authored-by: repo-ranger[bot] <39074581+repo-ranger[bot]@users.noreply.github.com>
2021-11-15 19:56:08 +00:00
chris48s
313dc983f1 upgrade to node 16 (#7271) 2021-11-15 19:29:50 +00:00
Pierre-Yves B
71bbcd527b Fix badge classes links in tutorial (#6911) 2021-08-19 18:04:00 +01:00
Pierre-Yves B
23c0406bed Migrate from CommonJS to ESM (#6651) 2021-07-09 12:53:55 +01:00
Seth Falco
856c71c1da docs: broken links and typos (#6676)
Co-authored-by: repo-ranger[bot] <39074581+repo-ranger[bot]@users.noreply.github.com>
2021-06-30 02:29:38 +00:00
Pierre-Yves B
68fb0b7bab Run on node 14 in production, drop node 10 support for badge-maker and update test matrix (#6652) 2021-06-21 20:46:55 +01:00
chris48s
4c52b0192a Upgrade to gatsby 3 (#6331)
* upgrade all the gatsby packages

* require npm >=7 to prevent lockfile churn

* get everything onto a version of safe-buffer with typescript defs

* update docs
2021-03-28 20:08:19 +01:00
chris48s
e54e69cf8e add docs on input validation (#6009)
Co-authored-by: Caleb Cartwright <calebcartwright@users.noreply.github.com>
2021-01-04 19:32:32 +00:00
JeongHoon Byun (a.k.a Outsider)
dc32a5fc4b Fix wrong anchor for writing tests document (#5677) 2020-10-10 05:14:52 +00:00
chris48s
504015c0ba migrate hapi/joi to joi (#5624)
* update joi + joi-extension-semver

* @hapi/joi --> joi

Co-authored-by: repo-ranger[bot] <39074581+repo-ranger[bot]@users.noreply.github.com>
2020-09-30 17:51:02 +00:00
Paul Melnikow
7c226456fe Adopt static fields in [amo] and core (#5440)
Since we've upgraded production to Node 12 (#5436) we can finally adopt static fields!

This starts the process by updating core and one of the service families.
2020-08-19 14:49:29 -04:00
chris48s
0bcd7eef15 Run on node 12 in production, update test matrix (#5436)
* upgrade node/npm versions in package.json

* delete config for zeit now
zeit now is no more, vercel have decomissioned the now v1 platform

* upgrade to node 12 for (docker) self-hosting users

* update docs

* update test matrix
run tests on node 12 and node 14

* link to nodejs version support docs in package comment
we'll continue to tun the package tests on node 10
while its still maintained and drop in the next
major release

* update depcheck

* remove npm-install job
2020-08-18 19:28:58 +01:00
Joe Izzard
56ae094afb doc: fixed the link to badge URL spec (#5164)
Co-authored-by: Pierre-Yves B <PyvesDev@gmail.com>
2020-06-04 19:12:13 +02:00
chris48s
612a43aaa9 Update test matrix and docs (#4992)
* update test matrix

* update docs
2020-04-30 21:33:59 +01:00
chris48s
e879682e29 Add documentation for designing badge URLs (#4435)
* Add documentation for designing badge URLs
Co-authored-by: Caleb Cartwright <calebcartwright@users.noreply.github.com>
2019-12-22 17:05:00 +00:00
Paul Melnikow
4d1bec20e2 Tutorial: Update the method order to be canonical (#4267) 2019-10-30 21:57:01 -04:00
Hubert Jagodziński
b7f3f175a5 Tutorial fixes (#4229) 2019-10-24 13:22:29 +02:00
Pierre-Yves B
157a6180b2 Make search work with category names (#4103) 2019-10-02 20:03:59 +01:00
chris48s
60bd7a69a7 link to contributing.shields.io in the docs (#3957)
* link to shields-docs.netlify.com in the docs

* update links to contributing.shields.io
2019-09-09 20:37:43 +00:00
Paul Melnikow
2177eb7546 Docs: Drop .svg extensions (#3787) 2019-07-25 19:39:35 -05:00
Paul Melnikow
66c7f13e38 Drop gif + png, and redirect png to raster.shields.io (#3644)
1. Remove rasterization support from the server. This responsibility is delegated to a raster server which proxies the SVG badges and renders them.
2. When a raster server URL is configured, 301 redirect all .png badges to the identical URL on the raster server.
    `https://img.shields.io/npm/v/express.png?style=flat-square` ↪️`https://raster.shields.io/npm/v/express.png?style=flat-square`
3. For configured redirects, redirect to the canonical URL on the raster server.
    `https://img.shields.io/vso/build/totodem/8cf3ec0e-d0c2-4fcd-8206-ad204f254a96/2.png?style=flat-square`
    ↪️`https://img.shields.io/azure-devops/build/totodem/8cf3ec0e-d0c2-4fcd-8206-ad204f254a96/2.png?style=flat-square`
4. Redirect the "legacy badge old version" to the appropriate URL on the raster server.
5. When no raster server is configured (e.g. PRs), render an SVG containing **404 | raster badges not available** for all `.png` badges. (Note that the raster server can be self-hosted; however, this is deferred to a later PR.)
5. Drop support for jpg and gif which are very infrequently used (see #3112). Render an SVG containing **410 | jpg no longer available**.
7. ~~Remove raster dependencies.~~ Remove the raster cache (which is only used in the CLI, and therefore pointless).
8. Move the LRUCache code out of the npm package.
8. A wee bit of refactoring in `server.js`.

Ref #3112
Close #3631
2019-07-06 16:41:46 -04:00
Pierre-Yves B
1e207f1886 Tutorial improvements and fixes (#3593) 2019-06-23 17:52:41 +01:00
chris48s
8621fe42d7 Upgrade Joi (#3505)
* upgrade joi
* find & replace ALL THE THINGS
* update related deps
2019-06-02 21:59:55 +01:00
chris48s
52e90af310 improve docs on examples (#3496)
closes #3440
2019-05-28 18:17:59 +01:00
Josep Bernad
17446efb45 Improvements in the TUTORIAL.md file (#3435)
* Improve tutorial file with explaining how to solve an error.

* Fix typo.

* Fix typo.

* Add more information about the fix.

* Apply suggested changes.

* Add missing method in the first example

* Modify the second example that did't compile.

* Add troubleshooting for the localhost and link to the issue solving it.

* Rephrase.

* Update doc/TUTORIAL.md

Co-Authored-By: Caleb Cartwright <calebcartwright@users.noreply.github.com>

* Add get category() function explanation in both examples.

* Update doc/TUTORIAL.md

Co-Authored-By: Paul Melnikow <github@paulmelnikow.com>
2019-05-15 19:40:18 +01:00
Paul Melnikow
73ed7778fd Automatically reload the server when it changes (#3401)
While working on #2428 I found myself wanting to reload the server frequently. This is working great and reducing my iteration time significantly. I should have tackled this way sooner! 🙊 

I’ve left `verbose` on which seems useful, at least in the short term while we’re tuning the configuration.

Close #2426
2019-05-01 16:39:25 -04:00
Caleb Cartwright
f0eac60191 doc: updated tutorial links and code snippets (#3124) 2019-03-01 16:00:18 -06:00
Paul Melnikow
fafb22efee Move "good" badge helpers from lib/ to services/ (#3101)
This moves a few helpers from `lib/` to `services/`:

build-status.js
build-status.spec.js
color-formatters.js
color-formatters.spec.js
contributor-count.js
licenses.js
licenses.spec.js
php-version.js
php-version.spec.js
text-formatters.js
text-formatters.spec.js
version.js
version.spec.js

And one from `lib/` to `core/`:

unhandled-rejection.spec.js

The diff is long, but the changes are straightforward.

Ref #2832
2019-02-27 20:47:46 -05:00
Paul Melnikow
d2861b2438 Switch to npm ci (#3034) 2019-02-18 17:28:09 -06: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
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
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
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
89113eee17 Migrate deprecated staticExample -> staticPreview (#2650) 2019-01-06 17:30:25 -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
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
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
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
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