diff --git a/.circleci/config.yml b/.circleci/config.yml
index 9132a89033..f1605619fa 100644
--- a/.circleci/config.yml
+++ b/.circleci/config.yml
@@ -53,6 +53,11 @@ jobs:
when: always
command: npm run test:integration
+ - run:
+ name: Tests for gh-badges package
+ when: always
+ command: npm run test:js:package
+
- run:
name: 'Prettier check (quick fix: `npm run prettier`)'
when: always
@@ -89,6 +94,11 @@ jobs:
when: always
command: npm run test:integration
+ - run:
+ name: Tests for gh-badges package
+ when: always
+ command: npm run test:js:package
+
- run:
name: 'Prettier check (quick fix: `npm run prettier`)'
when: always
diff --git a/.gitignore b/.gitignore
index 1a6cd4d550..d472d81780 100644
--- a/.gitignore
+++ b/.gitignore
@@ -7,6 +7,7 @@
/private
/index.html
/shields.env
+gh-badges/package-lock.json
# Folder view configuration files
.DS_Store
diff --git a/Makefile b/Makefile
index 30ff010882..d21ff444ca 100644
--- a/Makefile
+++ b/Makefile
@@ -8,11 +8,7 @@ FRONTEND_TMP=${TMPDIR}shields-frontend-deploy
# pushing secrets to GitHub, this branch is configured to reject pushes.
WORKING_BRANCH=server-deploy-working-branch
-all: website favicon test
-
-favicon:
- # This isn't working right now. See https://github.com/badges/shields/issues/1788
- node lib/badge-cli.js '' '' '#bada55' .png > favicon.png
+all: website test
website:
LONG_CACHE=false npm run build
@@ -86,4 +82,4 @@ deploy-heroku:
test:
npm test
-.PHONY: all favicon website deploy prepare-server-deploy clean-server-deploy deploy-s0 deploy-s1 deploy-s2 push-s0 push-s1 push-s2 deploy-gh-pages deploy-gh-pages-clean deploy-heroku setup redis test
+.PHONY: all website deploy prepare-server-deploy clean-server-deploy deploy-s0 deploy-s1 deploy-s2 push-s0 push-s1 push-s2 deploy-gh-pages deploy-gh-pages-clean deploy-heroku setup redis test
diff --git a/README.md b/README.md
index 75d384c066..30b2521ac2 100644
--- a/README.md
+++ b/README.md
@@ -31,12 +31,20 @@ continuous integration services, package registries, distributions, app
stores, social networks, code coverage services, and code analysis services.
Every month it serves over 470 million images.
-In addition to hosting the shields.io frontend and server code, this monorepo
-hosts an [NPM library for generating badges][gh-badges], and the badge design
-specification.
+This repo hosts:
+
+* The [Shields.io][shields.io] frontend and server code
+* An [NPM library for generating badges][gh-badges]
+ * [documentation][gh-badges-docs]
+ * [changelog][gh-badges-changelog]
+* The [badge design specification][badge-spec]
+
[shields.io]: https://shields.io/
[gh-badges]: https://www.npmjs.com/package/gh-badges
+[badge-spec]: https://github.com/badges/shields/tree/master/spec
+[gh-badges-docs]: https://github.com/badges/shields/tree/master/gh-badges/README.md
+[gh-badges-changelog]: https://github.com/badges/shields/tree/master/gh-badges/CHANGELOG.md
Examples
@@ -81,35 +89,6 @@ You can read a [tutorial on how to add a badge][tutorial].
[contributing]: CONTRIBUTING.md
-Using the badge library
------------------------
-
-```sh
-npm install -g gh-badges
-badge build passed :green .png > mybadge.png
-```
-
-```js
-const { BadgeFactory } = require('gh-badges')
-
-const bf = new BadgeFactory({ fontPath: '/path/to/Verdana.ttf' })
-
-const format = {
- text: ['build', 'passed'],
- colorscheme: 'green',
- template: 'flat',
-}
-
-const svg = bf.create(format)
-```
-
-View the [documentation for gh-badges][gh-badges doc].
-
-[](https://npmjs.org/package/gh-badges)
-
-[gh-badges doc]: https://github.com/badges/shields/blob/master/doc/gh-badges.md
-
-
Development
-----------
diff --git a/gh-badges/.npmignore b/gh-badges/.npmignore
new file mode 100644
index 0000000000..e31b519306
--- /dev/null
+++ b/gh-badges/.npmignore
@@ -0,0 +1,2 @@
+lib/make-badge-test-helpers.js
+lib/**/*.spec.js
diff --git a/gh-badges/CHANGELOG.md b/gh-badges/CHANGELOG.md
new file mode 100644
index 0000000000..26d639ad36
--- /dev/null
+++ b/gh-badges/CHANGELOG.md
@@ -0,0 +1,74 @@
+# Changelog
+
+## 2.0.0 - 2018-11-09
+
+gh-badges v2.0.0 declares a new public interface which is synchronous.
+If your version 1.3.0 code looked like this:
+
+```js
+const badge = require('gh-badges')
+
+const format = {
+ text: ['build', 'passed'],
+ colorscheme: 'green',
+ template: 'flat',
+}
+
+badge.loadFont('/path/to/Verdana.ttf', err => {
+ badge(format, (svg, err) => {
+ // svg is a string containing your badge
+ })
+})
+```
+
+To upgrade to version 2.0.0, refactor you code to:
+
+```js
+const { BadgeFactory } = require('gh-badges')
+
+const bf = new BadgeFactory({ fontPath: '/path/to/Verdana.ttf' })
+
+const format = {
+ text: ['build', 'passed'],
+ colorscheme: 'green',
+ template: 'flat',
+}
+
+const svg = bf.create(format)
+```
+
+You can generate badges without a copy of Verdana, however font width computation is approximate and badges may be distorted.
+
+```js
+const bf = new BadgeFactory({ fallbackFontPath: 'Helvetica' })
+```
+
+
+## 1.3.0 - 2016-09-07
+
+Add support for optionally specifying the path to `Verdana.ttf`. In earlier versions, the file needed to be in the directory containing Shields.
+
+Without font path:
+
+```js
+const badge = require('gh-badges')
+
+badge({ text: [ 'build', 'passed' ], colorscheme: 'green' },
+ (svg, err) => {
+ // svg is a string containing your badge
+ })
+```
+
+With font path:
+
+```js
+const badge = require('gh-badges')
+
+// Optional step, to have accurate text width computation.
+badge.loadFont('/path/to/Verdana.ttf', err => {
+ badge({ text: ['build', 'passed'], colorscheme: 'green', template: 'flat' },
+ (svg, err) => {
+ // svg is a string containing your badge
+ })
+})
+```
diff --git a/gh-badges/LICENSE b/gh-badges/LICENSE
new file mode 100644
index 0000000000..670154e353
--- /dev/null
+++ b/gh-badges/LICENSE
@@ -0,0 +1,116 @@
+CC0 1.0 Universal
+
+Statement of Purpose
+
+The laws of most jurisdictions throughout the world automatically confer
+exclusive Copyright and Related Rights (defined below) upon the creator and
+subsequent owner(s) (each and all, an "owner") of an original work of
+authorship and/or a database (each, a "Work").
+
+Certain owners wish to permanently relinquish those rights to a Work for the
+purpose of contributing to a commons of creative, cultural and scientific
+works ("Commons") that the public can reliably and without fear of later
+claims of infringement build upon, modify, incorporate in other works, reuse
+and redistribute as freely as possible in any form whatsoever and for any
+purposes, including without limitation commercial purposes. These owners may
+contribute to the Commons to promote the ideal of a free culture and the
+further production of creative, cultural and scientific works, or to gain
+reputation or greater distribution for their Work in part through the use and
+efforts of others.
+
+For these and/or other purposes and motivations, and without any expectation
+of additional consideration or compensation, the person associating CC0 with a
+Work (the "Affirmer"), to the extent that he or she is an owner of Copyright
+and Related Rights in the Work, voluntarily elects to apply CC0 to the Work
+and publicly distribute the Work under its terms, with knowledge of his or her
+Copyright and Related Rights in the Work and the meaning and intended legal
+effect of CC0 on those rights.
+
+1. Copyright and Related Rights. A Work made available under CC0 may be
+protected by copyright and related or neighboring rights ("Copyright and
+Related Rights"). Copyright and Related Rights include, but are not limited
+to, the following:
+
+ i. the right to reproduce, adapt, distribute, perform, display, communicate,
+ and translate a Work;
+
+ ii. moral rights retained by the original author(s) and/or performer(s);
+
+ iii. publicity and privacy rights pertaining to a person's image or likeness
+ depicted in a Work;
+
+ iv. rights protecting against unfair competition in regards to a Work,
+ subject to the limitations in paragraph 4(a), below;
+
+ v. rights protecting the extraction, dissemination, use and reuse of data in
+ a Work;
+
+ vi. database rights (such as those arising under Directive 96/9/EC of the
+ European Parliament and of the Council of 11 March 1996 on the legal
+ protection of databases, and under any national implementation thereof,
+ including any amended or successor version of such directive); and
+
+ vii. other similar, equivalent or corresponding rights throughout the world
+ based on applicable law or treaty, and any national implementations thereof.
+
+2. Waiver. To the greatest extent permitted by, but not in contravention of,
+applicable law, Affirmer hereby overtly, fully, permanently, irrevocably and
+unconditionally waives, abandons, and surrenders all of Affirmer's Copyright
+and Related Rights and associated claims and causes of action, whether now
+known or unknown (including existing as well as future claims and causes of
+action), in the Work (i) in all territories worldwide, (ii) for the maximum
+duration provided by applicable law or treaty (including future time
+extensions), (iii) in any current or future medium and for any number of
+copies, and (iv) for any purpose whatsoever, including without limitation
+commercial, advertising or promotional purposes (the "Waiver"). Affirmer makes
+the Waiver for the benefit of each member of the public at large and to the
+detriment of Affirmer's heirs and successors, fully intending that such Waiver
+shall not be subject to revocation, rescission, cancellation, termination, or
+any other legal or equitable action to disrupt the quiet enjoyment of the Work
+by the public as contemplated by Affirmer's express Statement of Purpose.
+
+3. Public License Fallback. Should any part of the Waiver for any reason be
+judged legally invalid or ineffective under applicable law, then the Waiver
+shall be preserved to the maximum extent permitted taking into account
+Affirmer's express Statement of Purpose. In addition, to the extent the Waiver
+is so judged Affirmer hereby grants to each affected person a royalty-free,
+non transferable, non sublicensable, non exclusive, irrevocable and
+unconditional license to exercise Affirmer's Copyright and Related Rights in
+the Work (i) in all territories worldwide, (ii) for the maximum duration
+provided by applicable law or treaty (including future time extensions), (iii)
+in any current or future medium and for any number of copies, and (iv) for any
+purpose whatsoever, including without limitation commercial, advertising or
+promotional purposes (the "License"). The License shall be deemed effective as
+of the date CC0 was applied by Affirmer to the Work. Should any part of the
+License for any reason be judged legally invalid or ineffective under
+applicable law, such partial invalidity or ineffectiveness shall not
+invalidate the remainder of the License, and in such case Affirmer hereby
+affirms that he or she will not (i) exercise any of his or her remaining
+Copyright and Related Rights in the Work or (ii) assert any associated claims
+and causes of action with respect to the Work, in either case contrary to
+Affirmer's express Statement of Purpose.
+
+4. Limitations and Disclaimers.
+
+ a. No trademark or patent rights held by Affirmer are waived, abandoned,
+ surrendered, licensed or otherwise affected by this document.
+
+ b. Affirmer offers the Work as-is and makes no representations or warranties
+ of any kind concerning the Work, express, implied, statutory or otherwise,
+ including without limitation warranties of title, merchantability, fitness
+ for a particular purpose, non infringement, or the absence of latent or
+ other defects, accuracy, or the present or absence of errors, whether or not
+ discoverable, all to the greatest extent permissible under applicable law.
+
+ c. Affirmer disclaims responsibility for clearing rights of other persons
+ that may apply to the Work or any use thereof, including without limitation
+ any person's Copyright and Related Rights in the Work. Further, Affirmer
+ disclaims responsibility for obtaining any necessary consents, permissions
+ or other rights required for any use of the Work.
+
+ d. Affirmer understands and acknowledges that Creative Commons is not a
+ party to this document and has no duty or obligation with respect to this
+ CC0 or use of the Work.
+
+For more information, please see
+
diff --git a/doc/gh-badges.md b/gh-badges/README.md
similarity index 66%
rename from doc/gh-badges.md
rename to gh-badges/README.md
index f650e861a9..0150bc090b 100644
--- a/doc/gh-badges.md
+++ b/gh-badges/README.md
@@ -1,5 +1,40 @@
-Format
-------
+# gh-badges
+
+[](https://npmjs.org/package/gh-badges)
+[](https://npmjs.org/package/gh-badges)
+
+## Installation
+
+```sh
+npm install gh-badges
+```
+
+## Usage
+
+### On the console
+
+```sh
+npm install -g gh-badges
+badge build passed :green .png > mybadge.png
+```
+
+### As a library
+
+```js
+const { BadgeFactory } = require('gh-badges')
+
+const bf = new BadgeFactory({ fontPath: '/path/to/Verdana.ttf' })
+
+const format = {
+ text: ['build', 'passed'],
+ colorscheme: 'green',
+ template: 'flat',
+}
+
+const svg = bf.create(format)
+```
+
+## Format
The format is the following:
@@ -22,14 +57,13 @@ The format is the following:
### See also
-- [colorscheme.json](../lib/colorscheme.json) for the `colorscheme` option
-- [templates/](../templates) for the `template` option
+- [colorscheme.json](./lib/colorscheme.json) for the `colorscheme` option
+- [templates/](./templates) for the `template` option
-Defaults
---------
+## Defaults
-If you want to add a colorscheme, head to `lib/colorscheme.json`. Each scheme
+If you want to use a colorscheme, head to `lib/colorscheme.json`. Each scheme
has a name and a [CSS/SVG color][] for the color used in the first box (for the
first piece of text, field `colorA`) and for the one used in the second box
(field `colorB`).
@@ -50,8 +84,7 @@ You can also use the `"colorA"` and `"colorB"` fields directly in the badges if
you don't want to make a color scheme for it. In that case, remove the
`"colorscheme"` field altogether.
-Text Width Computation
-----------------------
+## Text Width Computation
`BadgeFactory`'s constructor takes an optional boolean
`precomputeWidths` parameter which defaults to `false`.
diff --git a/lib/badge-cli.js b/gh-badges/lib/badge-cli.js
similarity index 100%
rename from lib/badge-cli.js
rename to gh-badges/lib/badge-cli.js
diff --git a/lib/badge-cli.spec.js b/gh-badges/lib/badge-cli.spec.js
similarity index 85%
rename from lib/badge-cli.spec.js
rename to gh-badges/lib/badge-cli.spec.js
index 8464633e8e..8f9225ef05 100644
--- a/lib/badge-cli.spec.js
+++ b/gh-badges/lib/badge-cli.spec.js
@@ -1,15 +1,18 @@
'use strict'
-const { expect } = require('chai')
+const path = require('path')
const isPng = require('is-png')
const isSvg = require('is-svg')
const { spawn } = require('child-process-promise')
-// https://github.com/badges/shields/pull/1419#discussion_r159957055
-require('./register-chai-plugins.spec')
+const { expect, use } = require('chai')
+use(require('chai-string'))
+use(require('sinon-chai'))
function runCli(args) {
- return spawn('node', ['lib/badge-cli.js', ...args], { capture: ['stdout'] })
+ return spawn('node', [path.join(__dirname, 'badge-cli.js'), ...args], {
+ capture: ['stdout'],
+ })
}
describe('The CLI', function() {
diff --git a/lib/colorscheme.json b/gh-badges/lib/colorscheme.json
similarity index 100%
rename from lib/colorscheme.json
rename to gh-badges/lib/colorscheme.json
diff --git a/lib/defaults.js b/gh-badges/lib/defaults.js
similarity index 100%
rename from lib/defaults.js
rename to gh-badges/lib/defaults.js
diff --git a/lib/gh-badges.js b/gh-badges/lib/index.js
similarity index 91%
rename from lib/gh-badges.js
rename to gh-badges/lib/index.js
index d60218663c..c0ed0bec57 100644
--- a/lib/gh-badges.js
+++ b/gh-badges/lib/index.js
@@ -21,7 +21,7 @@ class BadgeFactory {
* @param {string} format.format
* @param {string} format.template
* @return {string} Badge in SVG or JSON format
- * @see https://github.com/badges/shields/blob/master/doc/gh-badges.md
+ * @see https://github.com/badges/shields/tree/master/gh-badges/README.md
*/
create(format) {
return makeBadge(this.measurer, format)
diff --git a/lib/lru-cache.js b/gh-badges/lib/lru-cache.js
similarity index 100%
rename from lib/lru-cache.js
rename to gh-badges/lib/lru-cache.js
diff --git a/lib/lru-cache.spec.js b/gh-badges/lib/lru-cache.spec.js
similarity index 100%
rename from lib/lru-cache.spec.js
rename to gh-badges/lib/lru-cache.spec.js
diff --git a/lib/make-badge-test-helpers.js b/gh-badges/lib/make-badge-test-helpers.js
similarity index 97%
rename from lib/make-badge-test-helpers.js
rename to gh-badges/lib/make-badge-test-helpers.js
index a2a87b5c31..6b54dfda6e 100644
--- a/lib/make-badge-test-helpers.js
+++ b/gh-badges/lib/make-badge-test-helpers.js
@@ -9,6 +9,7 @@ module.exports = {
path: path.join(
__dirname,
'..',
+ '..',
'node_modules',
'dejavu-fonts-ttf',
'ttf',
diff --git a/lib/make-badge.js b/gh-badges/lib/make-badge.js
similarity index 100%
rename from lib/make-badge.js
rename to gh-badges/lib/make-badge.js
diff --git a/lib/make-badge.spec.js b/gh-badges/lib/make-badge.spec.js
similarity index 100%
rename from lib/make-badge.spec.js
rename to gh-badges/lib/make-badge.spec.js
diff --git a/lib/svg-to-img.js b/gh-badges/lib/svg-to-img.js
similarity index 100%
rename from lib/svg-to-img.js
rename to gh-badges/lib/svg-to-img.js
diff --git a/lib/svg-to-img.spec.js b/gh-badges/lib/svg-to-img.spec.js
similarity index 100%
rename from lib/svg-to-img.spec.js
rename to gh-badges/lib/svg-to-img.spec.js
diff --git a/lib/text-measurer.js b/gh-badges/lib/text-measurer.js
similarity index 100%
rename from lib/text-measurer.js
rename to gh-badges/lib/text-measurer.js
diff --git a/lib/text-measurer.spec.js b/gh-badges/lib/text-measurer.spec.js
similarity index 97%
rename from lib/text-measurer.spec.js
rename to gh-badges/lib/text-measurer.spec.js
index 2ea684aef9..93241f60fb 100644
--- a/lib/text-measurer.spec.js
+++ b/gh-badges/lib/text-measurer.spec.js
@@ -5,7 +5,6 @@ const path = require('path')
const fs = require('fs')
const sinon = require('sinon')
const { PDFKitTextMeasurer, QuickTextMeasurer } = require('./text-measurer')
-const { starRating } = require('./text-formatters')
const defaults = require('./defaults')
const testHelpers = require('./make-badge-test-helpers')
const almostEqual = require('almost-equal')
@@ -120,7 +119,7 @@ function registerTests(fontPath, skip) {
})
context('when given non-ASCII strings', function() {
- const strings = [starRating(3.5), '\u2026']
+ const strings = ['★★★½☆', '\u2026']
strings.forEach(str => {
it(`should measure '${str}' in parity with PDFKit`, function() {
diff --git a/gh-badges/package.json b/gh-badges/package.json
new file mode 100644
index 0000000000..1814dbdcde
--- /dev/null
+++ b/gh-badges/package.json
@@ -0,0 +1,45 @@
+{
+ "name": "gh-badges",
+ "version": "2.0.0",
+ "description": "Shields.io badge library",
+ "keywords": [
+ "GitHub",
+ "badge",
+ "SVG",
+ "image",
+ "shields.io"
+ ],
+ "main": "lib/index.js",
+ "repository": {
+ "type": "git",
+ "url": "git+https://github.com/badges/shields.git"
+ },
+ "author": "Thaddée Tyl ",
+ "license": "CC0-1.0",
+ "bugs": {
+ "url": "https://github.com/badges/shields/issues"
+ },
+ "homepage": "http://shields.io",
+ "bin": {
+ "badge": "lib/badge-cli.js"
+ },
+ "engines": {
+ "node": ">= 8",
+ "npm": ">= 5"
+ },
+ "collective": {
+ "type": "opencollective",
+ "url": "https://opencollective.com/shields",
+ "logo": "https://opencollective.com/opencollective/logo.txt"
+ },
+ "dependencies": {
+ "dot": "~1.1.2",
+ "gm": "^1.23.0",
+ "is-css-color": "^1.0.0",
+ "pdfkit": "~0.8.0",
+ "svgo": "~1.1.1"
+ },
+ "scripts": {
+ "test": "echo 'Run tests from parent dir'; false"
+ }
+}
diff --git a/templates/_shields_test-template.json b/gh-badges/templates/_shields_test-template.json
similarity index 100%
rename from templates/_shields_test-template.json
rename to gh-badges/templates/_shields_test-template.json
diff --git a/templates/default-template.json b/gh-badges/templates/default-template.json
similarity index 100%
rename from templates/default-template.json
rename to gh-badges/templates/default-template.json
diff --git a/templates/flat-square-template.svg b/gh-badges/templates/flat-square-template.svg
similarity index 100%
rename from templates/flat-square-template.svg
rename to gh-badges/templates/flat-square-template.svg
diff --git a/templates/flat-template.svg b/gh-badges/templates/flat-template.svg
similarity index 100%
rename from templates/flat-template.svg
rename to gh-badges/templates/flat-template.svg
diff --git a/templates/for-the-badge-template.svg b/gh-badges/templates/for-the-badge-template.svg
similarity index 100%
rename from templates/for-the-badge-template.svg
rename to gh-badges/templates/for-the-badge-template.svg
diff --git a/templates/plastic-template.svg b/gh-badges/templates/plastic-template.svg
similarity index 100%
rename from templates/plastic-template.svg
rename to gh-badges/templates/plastic-template.svg
diff --git a/templates/popout-square-template.svg b/gh-badges/templates/popout-square-template.svg
similarity index 100%
rename from templates/popout-square-template.svg
rename to gh-badges/templates/popout-square-template.svg
diff --git a/templates/popout-template.svg b/gh-badges/templates/popout-template.svg
similarity index 100%
rename from templates/popout-template.svg
rename to gh-badges/templates/popout-template.svg
diff --git a/templates/social-template.svg b/gh-badges/templates/social-template.svg
similarity index 100%
rename from templates/social-template.svg
rename to gh-badges/templates/social-template.svg
diff --git a/lib/badge-data.js b/lib/badge-data.js
index 4a6954ed17..ddb2fb1ecc 100644
--- a/lib/badge-data.js
+++ b/lib/badge-data.js
@@ -4,7 +4,7 @@ const isCSSColor = require('is-css-color')
const logos = require('./load-logos')()
const simpleIcons = require('./load-simple-icons')()
const { svg2base64, isDataUri } = require('./logo-helper')
-const colorschemes = require('./colorscheme.json')
+const colorschemes = require('../gh-badges/lib/colorscheme.json')
function toArray(val) {
if (val === undefined) {
diff --git a/lib/refactoring-cli.js b/lib/refactoring-cli.js
index 46c587fddb..14217cbc24 100644
--- a/lib/refactoring-cli.js
+++ b/lib/refactoring-cli.js
@@ -3,7 +3,7 @@
const chalk = require('chalk')
const mapValues = require('lodash.mapvalues')
-const colorscheme = require('../lib/colorscheme.json')
+const colorscheme = require('../gh-badges/lib/colorscheme.json')
const colorsMap = mapValues(colorscheme, 'colorB')
const { floorCount } = require('./color-formatters')
const { loadServiceClasses } = require('../services')
diff --git a/lib/request-handler.js b/lib/request-handler.js
index 5cc5d28e78..47c0a4f3c7 100644
--- a/lib/request-handler.js
+++ b/lib/request-handler.js
@@ -5,7 +5,7 @@ const domain = require('domain')
const request = require('request')
const { makeBadgeData: getBadgeData } = require('./badge-data')
const log = require('./log')
-const LruCache = require('./lru-cache')
+const LruCache = require('../gh-badges/lib/lru-cache')
const analytics = require('./analytics')
const { makeSend } = require('./result-sender')
const queryString = require('query-string')
diff --git a/lib/request-handler.spec.js b/lib/request-handler.spec.js
index 1adba41078..31053b4119 100644
--- a/lib/request-handler.spec.js
+++ b/lib/request-handler.spec.js
@@ -13,7 +13,7 @@ const {
_requestCache,
getBadgeMaxAge,
} = require('./request-handler')
-const testHelpers = require('./make-badge-test-helpers')
+const testHelpers = require('../gh-badges/lib/make-badge-test-helpers')
const handleRequest = makeHandleRequestFn(testHelpers.makeBadge())
diff --git a/lib/result-sender.js b/lib/result-sender.js
index 875f1be48a..36e09859ba 100644
--- a/lib/result-sender.js
+++ b/lib/result-sender.js
@@ -2,7 +2,7 @@
const stream = require('stream')
const log = require('./log')
-const svg2img = require('./svg-to-img')
+const svg2img = require('../gh-badges/lib/svg-to-img')
function streamFromString(str) {
const newStream = new stream.Readable()
diff --git a/lib/server-config.js b/lib/server-config.js
index 90ebec8fb2..87aad29a0a 100644
--- a/lib/server-config.js
+++ b/lib/server-config.js
@@ -5,7 +5,7 @@
const url = require('url')
const envFlag = require('node-env-flag')
-const defaults = require('./defaults')
+const defaults = require('../gh-badges/lib/defaults')
function envArray(envVar, defaultValue, delimiter) {
delimiter = delimiter || ','
diff --git a/now.json b/now.json
index 1cec99659c..a767168cc4 100644
--- a/now.json
+++ b/now.json
@@ -7,6 +7,7 @@
"package-lock.json",
"build/",
"frontend/",
+ "gh-badges/",
"lib/",
"logo/",
"pages/",
diff --git a/package-lock.json b/package-lock.json
index 6bc5f8cfab..be20a4a094 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -1,6 +1,6 @@
{
- "name": "gh-badges",
- "version": "2.0.0",
+ "name": "shields.io",
+ "version": "0.0.0",
"lockfileVersion": 1,
"requires": true,
"dependencies": {
@@ -6198,6 +6198,16 @@
"assert-plus": "^1.0.0"
}
},
+ "gh-badges": {
+ "version": "file:gh-badges",
+ "requires": {
+ "dot": "~1.1.2",
+ "gm": "^1.23.0",
+ "is-css-color": "^1.0.0",
+ "pdfkit": "~0.8.0",
+ "svgo": "~1.1.1"
+ }
+ },
"git-config-path": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/git-config-path/-/git-config-path-1.0.1.tgz",
diff --git a/package.json b/package.json
index ee4135c12c..73b8280e3e 100644
--- a/package.json
+++ b/package.json
@@ -1,7 +1,8 @@
{
- "name": "gh-badges",
- "version": "2.0.0",
- "description": "Official Shields.io badge library.",
+ "name": "shields.io",
+ "version": "0.0.0",
+ "description": "Shields.io server and frontend",
+ "private": true,
"keywords": [
"GitHub",
"badge",
@@ -16,7 +17,6 @@
},
"license": "CC0-1.0",
"author": "Thaddée Tyl ",
- "main": "lib/gh-badges.js",
"repository": {
"type": "git",
"url": "https://github.com/badges/shields"
@@ -26,13 +26,12 @@
"chalk": "^2.4.1",
"check-node-version": "^3.1.0",
"chrome-web-store-item-property": "~1.1.2",
- "dot": "~1.1.2",
"emojic": "^1.1.14",
"escape-string-regexp": "^1.0.5",
"fast-xml-parser": "^3.12.0",
"fsos": "^1.1.3",
+ "gh-badges": "file:gh-badges",
"glob": "^7.1.1",
- "gm": "^1.23.0",
"is-css-color": "^1.0.0",
"joi": "14.0.4",
"js-yaml": "^3.11.0",
@@ -45,7 +44,6 @@
"moment": "^2.19.3",
"node-env-flag": "^0.1.0",
"path-to-regexp": "^2.4.0",
- "pdfkit": "~0.8.0",
"pretty-bytes": "^5.0.0",
"priorityqueuejs": "^1.0.0",
"prom-client": "^11.1.2",
@@ -55,13 +53,12 @@
"request": "~2.88.0",
"semver": "~5.6.0",
"simple-icons": "1.9.13",
- "svgo": "~1.1.1",
"xml2js": "~0.4.16",
"xmldom": "~0.1.27",
"xpath": "~0.0.27"
},
"scripts": {
- "coverage:test:server": "HANDLE_INTERNAL_ERRORS=false nyc node_modules/mocha/bin/_mocha \"*.spec.js\" \"lib/**/*.spec.js\" \"services/**/*.spec.js\"",
+ "coverage:test:server": "HANDLE_INTERNAL_ERRORS=false nyc node_modules/mocha/bin/_mocha \"*.spec.js\" \"lib/**/*.spec.js\" \"gh-badges/**/*.spec.js\" \"services/**/*.spec.js\"",
"coverage:test:frontend": "NODE_ENV=mocha nyc node_modules/mocha/bin/_mocha --require @babel/polyfill --require @babel/register \"frontend/**/*.spec.js\"",
"coverage:test:integration": "nyc node_modules/mocha/bin/_mocha \"lib/**/*.integration.js\" \"services/**/*.integration.js\"",
"coverage:test:services": "nyc node_modules/mocha/bin/_mocha --delay lib/service-test-runner/cli.js",
@@ -75,13 +72,14 @@
"danger": "danger",
"test:js:frontend": "NODE_ENV=mocha mocha --require @babel/polyfill --require @babel/register \"frontend/**/*.spec.js\"",
"test:js:server": "HANDLE_INTERNAL_ERRORS=false mocha \"*.spec.js\" \"lib/**/*.spec.js\" \"services/**/*.spec.js\"",
+ "test:js:package": "HANDLE_INTERNAL_ERRORS=false mocha \"gh-badges/**/*.spec.js\"",
"test:integration": "mocha \"lib/**/*.integration.js\" \"services/**/*.integration.js\"",
"test:services": "HANDLE_INTERNAL_ERRORS=false mocha --delay lib/service-test-runner/cli.js",
"test:services:trace": "TRACE_SERVICES=true npm run test:services -- $*",
"test:services:pr:prepare": "node lib/service-test-runner/pull-request-services-cli.js > pull-request-services.log",
"test:services:pr:run": "HANDLE_INTERNAL_ERRORS=false mocha --delay lib/service-test-runner/cli.js --stdin < pull-request-services.log",
"test:services:pr": "npm run test:services:pr:prepare && npm run test:services:pr:run",
- "test": "npm run lint && npm run test:js:frontend && npm run test:js:server",
+ "test": "npm run lint && npm run test:js:frontend && npm run test:js:package && npm run test:js:server",
"circle-images:build": "docker build -t shieldsio/shields-ci-node-8:${IMAGE_TAG} -f .circleci/images/node-8/Dockerfile . && docker build -t shieldsio/shields-ci-node-latest:${IMAGE_TAG} -f .circleci/images/node-latest/Dockerfile .",
"circle-images:push": "docker push shieldsio/shields-ci-node-8:${IMAGE_TAG} && docker push shieldsio/shields-ci-node-latest:${IMAGE_TAG}",
"depcheck": "check-node-version --node \">= 8.0\"",
@@ -105,21 +103,6 @@
"git add"
]
},
- "bin": {
- "badge": "lib/badge-cli.js"
- },
- "files": [
- "README.md",
- "lib/badge-cli.js",
- "lib/make-badge.js",
- "lib/colorscheme.json",
- "lib/lru-cache.js",
- "lib/text-measurer.js",
- "lib/svg-to-img.js",
- "lib/defaults.js",
- "templates",
- "logo"
- ],
"devDependencies": {
"@babel/core": "^7.1.0",
"@babel/plugin-proposal-class-properties": "^7.1.0",
diff --git a/server.js b/server.js
index 7aac2a71b5..bd6ab288ea 100644
--- a/server.js
+++ b/server.js
@@ -19,8 +19,8 @@ const GithubConstellation = require('./services/github/github-constellation')
const PrometheusMetrics = require('./lib/sys/prometheus-metrics')
const sysMonitor = require('./lib/sys/monitor')
const log = require('./lib/log')
-const { makeMakeBadgeFn } = require('./lib/make-badge')
-const { QuickTextMeasurer } = require('./lib/text-measurer')
+const { makeMakeBadgeFn } = require('./gh-badges/lib/make-badge')
+const { QuickTextMeasurer } = require('./gh-badges/lib/text-measurer')
const suggest = require('./lib/suggest')
const {
makeColorB,
diff --git a/server.spec.js b/server.spec.js
index a54982cb3e..ca84f25937 100644
--- a/server.spec.js
+++ b/server.spec.js
@@ -9,7 +9,7 @@ const isSvg = require('is-svg')
const path = require('path')
const serverHelpers = require('./lib/in-process-server-test-helpers')
const sinon = require('sinon')
-const svg2img = require('./lib/svg-to-img')
+const svg2img = require('./gh-badges/lib/svg-to-img')
describe('The server', function() {
const baseUri = `http://127.0.0.1:${config.port}`
diff --git a/services/base-svg-scraping.spec.js b/services/base-svg-scraping.spec.js
index 2a1f87feda..64a30646d3 100644
--- a/services/base-svg-scraping.spec.js
+++ b/services/base-svg-scraping.spec.js
@@ -5,7 +5,7 @@ const { expect } = require('chai')
const sinon = require('sinon')
const Joi = require('joi')
const { makeBadgeData } = require('../lib/badge-data')
-const testHelpers = require('../lib/make-badge-test-helpers')
+const testHelpers = require('../gh-badges/lib/make-badge-test-helpers')
const BaseSvgScrapingService = require('./base-svg-scraping')
chai.use(require('chai-as-promised'))
diff --git a/services/chocolatey/chocolatey.tester.js b/services/chocolatey/chocolatey.tester.js
index a795dd1bb9..b4086cb36d 100644
--- a/services/chocolatey/chocolatey.tester.js
+++ b/services/chocolatey/chocolatey.tester.js
@@ -7,7 +7,7 @@ const {
isVPlusDottedVersionNClauses,
isVPlusDottedVersionNClausesWithOptionalSuffix,
} = require('../test-validators')
-const colorscheme = require('../../lib/colorscheme.json')
+const { colorScheme } = require('../test-helpers')
const {
nuGetV2VersionJsonWithDash,
nuGetV2VersionJsonFirstCharZero,
@@ -72,7 +72,7 @@ t.create('version (mocked, yellow badge)')
.expectJSON({
name: 'chocolatey',
value: 'v1.2-beta',
- colorB: colorscheme.yellow.colorB,
+ colorB: colorScheme.yellow,
})
t.create('version (mocked, orange badge)')
@@ -87,7 +87,7 @@ t.create('version (mocked, orange badge)')
.expectJSON({
name: 'chocolatey',
value: 'v0.35',
- colorB: colorscheme.orange.colorB,
+ colorB: colorScheme.orange,
})
t.create('version (mocked, blue badge)')
@@ -102,7 +102,7 @@ t.create('version (mocked, blue badge)')
.expectJSON({
name: 'chocolatey',
value: 'v1.2.7',
- colorB: colorscheme.blue.colorB,
+ colorB: colorScheme.blue,
})
t.create('version (not found)')
@@ -148,7 +148,7 @@ t.create('version (pre) (mocked, yellow badge)')
.expectJSON({
name: 'chocolatey',
value: 'v1.2-beta',
- colorB: colorscheme.yellow.colorB,
+ colorB: colorScheme.yellow,
})
t.create('version (pre) (mocked, orange badge)')
@@ -163,7 +163,7 @@ t.create('version (pre) (mocked, orange badge)')
.expectJSON({
name: 'chocolatey',
value: 'v0.35',
- colorB: colorscheme.orange.colorB,
+ colorB: colorScheme.orange,
})
t.create('version (pre) (mocked, blue badge)')
@@ -178,7 +178,7 @@ t.create('version (pre) (mocked, blue badge)')
.expectJSON({
name: 'chocolatey',
value: 'v1.2.7',
- colorB: colorscheme.blue.colorB,
+ colorB: colorScheme.blue,
})
t.create('version (pre) (not found)')
diff --git a/services/dub/dub.tester.js b/services/dub/dub.tester.js
index 966b1b54d6..a1629c230d 100644
--- a/services/dub/dub.tester.js
+++ b/services/dub/dub.tester.js
@@ -4,7 +4,7 @@ const Joi = require('joi')
const ServiceTester = require('../service-tester')
const { invalidJSON } = require('../response-fixtures')
-const colorscheme = require('../../lib/colorscheme.json')
+const { colorScheme } = require('../test-helpers')
const {
isVPlusDottedVersionNClausesWithOptionalSuffix,
@@ -12,11 +12,11 @@ const {
isMetricOverTimePeriod,
} = require('../test-validators')
const isVersionColor = Joi.equal(
- colorscheme.red.colorB,
- colorscheme.yellow.colorB,
- colorscheme.yellowgreen.colorB,
- colorscheme.green.colorB,
- colorscheme.brightgreen.colorB
+ colorScheme.red,
+ colorScheme.yellow,
+ colorScheme.yellowgreen,
+ colorScheme.green,
+ colorScheme.brightgreen
)
const t = new ServiceTester({ id: 'dub', title: 'Dub' })
@@ -111,7 +111,7 @@ t.create('version (valid)')
Joi.object().keys({
name: 'dub',
value: isVPlusDottedVersionNClausesWithOptionalSuffix,
- colorB: Joi.equal(colorscheme.blue.colorB, colorscheme.orange.colorB),
+ colorB: Joi.equal(colorScheme.blue, colorScheme.orange),
})
)
@@ -140,7 +140,7 @@ t.create('license (valid)')
.expectJSON({
name: 'license',
value: 'MIT',
- colorB: colorscheme.blue.colorB,
+ colorB: colorScheme.blue,
})
t.create('license (not found)')
diff --git a/services/github/github.tester.js b/services/github/github.tester.js
index 5d8b9083bb..469637d4c6 100644
--- a/services/github/github.tester.js
+++ b/services/github/github.tester.js
@@ -11,15 +11,13 @@ const {
isVPlusDottedVersionAtLeastOne,
isSemver,
} = require('../test-validators')
-const colorscheme = require('../../lib/colorscheme.json')
+const { colorScheme: colorsB } = require('../test-helpers')
const { licenseToColor } = require('../../lib/licenses')
const { makeColor } = require('../../lib/badge-data')
-const mapValues = require('lodash.mapvalues')
const { invalidJSON } = require('../response-fixtures')
const t = new ServiceTester({ id: 'github', title: 'Github' })
module.exports = t
-const colorsB = mapValues(colorscheme, 'colorB')
const publicDomainLicenseColor = makeColor(licenseToColor('CC0-1.0'))
const permissiveLicenseColor = colorsB[licenseToColor('MIT')]
const copyleftLicenseColor = colorsB[licenseToColor('GPL-3.0')]
diff --git a/services/myget/myget.tester.js b/services/myget/myget.tester.js
index 24ac71a48f..27a2b37560 100644
--- a/services/myget/myget.tester.js
+++ b/services/myget/myget.tester.js
@@ -6,7 +6,7 @@ const {
isMetric,
isVPlusDottedVersionNClausesWithOptionalSuffix,
} = require('../test-validators')
-const colorscheme = require('../../lib/colorscheme.json')
+const { colorScheme } = require('../test-helpers')
const {
queryIndex,
nuGetV3VersionJsonWithDash,
@@ -117,7 +117,7 @@ t.create('version (mocked, yellow badge)')
.expectJSON({
name: 'mongodb',
value: 'v1.2-beta',
- colorB: colorscheme.yellow.colorB,
+ colorB: colorScheme.yellow,
})
t.create('version (mocked, orange badge)')
@@ -137,7 +137,7 @@ t.create('version (mocked, orange badge)')
.expectJSON({
name: 'mongodb',
value: 'v0.35',
- colorB: colorscheme.orange.colorB,
+ colorB: colorScheme.orange,
})
t.create('version (mocked, blue badge)')
@@ -157,7 +157,7 @@ t.create('version (mocked, blue badge)')
.expectJSON({
name: 'mongodb',
value: 'v1.2.7',
- colorB: colorscheme.blue.colorB,
+ colorB: colorScheme.blue,
})
t.create('version (not found)')
@@ -208,7 +208,7 @@ t.create('version (pre) (mocked, yellow badge)')
.expectJSON({
name: 'mongodb',
value: 'v1.2-beta',
- colorB: colorscheme.yellow.colorB,
+ colorB: colorScheme.yellow,
})
t.create('version (pre) (mocked, orange badge)')
@@ -228,7 +228,7 @@ t.create('version (pre) (mocked, orange badge)')
.expectJSON({
name: 'mongodb',
value: 'v0.35',
- colorB: colorscheme.orange.colorB,
+ colorB: colorScheme.orange,
})
t.create('version (pre) (mocked, blue badge)')
@@ -248,7 +248,7 @@ t.create('version (pre) (mocked, blue badge)')
.expectJSON({
name: 'mongodb',
value: 'v1.2.7',
- colorB: colorscheme.blue.colorB,
+ colorB: colorScheme.blue,
})
t.create('version (pre) (not found)')
diff --git a/services/nuget/nuget.tester.js b/services/nuget/nuget.tester.js
index 414c9098c5..68ccc450bc 100644
--- a/services/nuget/nuget.tester.js
+++ b/services/nuget/nuget.tester.js
@@ -7,7 +7,7 @@ const {
isVPlusDottedVersionNClauses,
isVPlusDottedVersionNClausesWithOptionalSuffix,
} = require('../test-validators')
-const colorscheme = require('../../lib/colorscheme.json')
+const { colorScheme } = require('../test-helpers')
const {
queryIndex,
nuGetV3VersionJsonWithDash,
@@ -78,7 +78,7 @@ t.create('version (mocked, yellow badge)')
.expectJSON({
name: 'nuget',
value: 'v1.2-beta',
- colorB: colorscheme.yellow.colorB,
+ colorB: colorScheme.yellow,
})
t.create('version (mocked, orange badge)')
@@ -98,7 +98,7 @@ t.create('version (mocked, orange badge)')
.expectJSON({
name: 'nuget',
value: 'v0.35',
- colorB: colorscheme.orange.colorB,
+ colorB: colorScheme.orange,
})
t.create('version (mocked, blue badge)')
@@ -118,7 +118,7 @@ t.create('version (mocked, blue badge)')
.expectJSON({
name: 'nuget',
value: 'v1.2.7',
- colorB: colorscheme.blue.colorB,
+ colorB: colorScheme.blue,
})
t.create('version (not found)')
@@ -169,7 +169,7 @@ t.create('version (pre) (mocked, yellow badge)')
.expectJSON({
name: 'nuget',
value: 'v1.2-beta',
- colorB: colorscheme.yellow.colorB,
+ colorB: colorScheme.yellow,
})
t.create('version (pre) (mocked, orange badge)')
@@ -189,7 +189,7 @@ t.create('version (pre) (mocked, orange badge)')
.expectJSON({
name: 'nuget',
value: 'v0.35',
- colorB: colorscheme.orange.colorB,
+ colorB: colorScheme.orange,
})
t.create('version (pre) (mocked, blue badge)')
@@ -209,7 +209,7 @@ t.create('version (pre) (mocked, blue badge)')
.expectJSON({
name: 'nuget',
value: 'v1.2.7',
- colorB: colorscheme.blue.colorB,
+ colorB: colorScheme.blue,
})
t.create('version (pre) (not found)')
diff --git a/services/resharper/resharper.tester.js b/services/resharper/resharper.tester.js
index b4223a4cbe..e82ea2e256 100644
--- a/services/resharper/resharper.tester.js
+++ b/services/resharper/resharper.tester.js
@@ -7,7 +7,7 @@ const {
isVPlusDottedVersionNClauses,
isVPlusDottedVersionNClausesWithOptionalSuffix,
} = require('../test-validators')
-const colorscheme = require('../../lib/colorscheme.json')
+const { colorScheme } = require('../test-helpers')
const {
nuGetV2VersionJsonWithDash,
nuGetV2VersionJsonFirstCharZero,
@@ -72,7 +72,7 @@ t.create('version (mocked, yellow badge)')
.expectJSON({
name: 'resharper',
value: 'v1.2-beta',
- colorB: colorscheme.yellow.colorB,
+ colorB: colorScheme.yellow,
})
t.create('version (mocked, orange badge)')
@@ -87,7 +87,7 @@ t.create('version (mocked, orange badge)')
.expectJSON({
name: 'resharper',
value: 'v0.35',
- colorB: colorscheme.orange.colorB,
+ colorB: colorScheme.orange,
})
t.create('version (mocked, blue badge)')
@@ -102,7 +102,7 @@ t.create('version (mocked, blue badge)')
.expectJSON({
name: 'resharper',
value: 'v1.2.7',
- colorB: colorscheme.blue.colorB,
+ colorB: colorScheme.blue,
})
t.create('version (not found)')
@@ -148,7 +148,7 @@ t.create('version (pre) (mocked, yellow badge)')
.expectJSON({
name: 'resharper',
value: 'v1.2-beta',
- colorB: colorscheme.yellow.colorB,
+ colorB: colorScheme.yellow,
})
t.create('version (pre) (mocked, orange badge)')
@@ -163,7 +163,7 @@ t.create('version (pre) (mocked, orange badge)')
.expectJSON({
name: 'resharper',
value: 'v0.35',
- colorB: colorscheme.orange.colorB,
+ colorB: colorScheme.orange,
})
t.create('version (pre) (mocked, blue badge)')
@@ -178,7 +178,7 @@ t.create('version (pre) (mocked, blue badge)')
.expectJSON({
name: 'resharper',
value: 'v1.2.7',
- colorB: colorscheme.blue.colorB,
+ colorB: colorScheme.blue,
})
t.create('version (pre) (not found)')
diff --git a/services/test-helpers.js b/services/test-helpers.js
index 723fac2896..f0661368e1 100644
--- a/services/test-helpers.js
+++ b/services/test-helpers.js
@@ -1,5 +1,5 @@
'use strict'
-const colorscheme = require('../lib/colorscheme.json')
+const colorscheme = require('../gh-badges/lib/colorscheme.json')
const mapValues = require('lodash.mapvalues')
module.exports = {