diff --git a/.gitignore b/.gitignore index 40af94be..08cab173 100644 --- a/.gitignore +++ b/.gitignore @@ -41,3 +41,7 @@ Temporary Items # NPM dependencies node_modules/ + +# Files generated by build script +icons/*.js +/index.js diff --git a/.svgo.yml b/.svgo.yml new file mode 100644 index 00000000..aadc2536 --- /dev/null +++ b/.svgo.yml @@ -0,0 +1,74 @@ +multipass: true + +plugins: + # Set precision to 3 decimal places + - convertPathData: + floatPrecision: 3 + + # Sort attributes on the + - sortAttrs: + order: + - role + - viewBox + xmlnsOrder: end + + # Convert basic shapes (such as ) to , including + - convertShapeToPath: + convertArcs: true + + # Compound all s into one + - mergePaths: + force: true + + # Keep the + - removeTitle: false + + # Don't remove the role="img" attribute and automatically + # add it to the SVG if it's not + - addAttributesToSVGElement: + attributes: + - role: img + - removeUnknownsAndDefaults: + keepRoleAttr: true + + # Enable everything else + - removeDoctype + - removeXMLProcInst + - removeComments + - removeMetadata + - removeXMLNS + - removeEditorsNSData + - cleanupAttrs + - inlineStyles + - minifyStyles + - convertStyleToAttrs + - cleanupIDs + - prefixIds + - removeRasterImages + - removeUselessDefs + - cleanupNumericValues + - cleanupListOfValues + - convertColors + - removeNonInheritableGroupAttrs + - removeUselessStrokeAndFill + - removeViewBox + - cleanupEnableBackground + - removeHiddenElems + - removeEmptyText + - moveElemsAttrsToGroup + - moveGroupAttrsToElems + - collapseGroups + - convertTransform + - removeEmptyAttrs + - removeEmptyContainers + - removeUnusedNS + - removeDesc + - removeDimensions + - removeAttrs + - removeAttributesBySelector + - removeElementsByAttr + - addClassesToSVGElement + - removeStyleElement + - removeScriptElement + - removeOffCanvasPaths + - reusePaths diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 23339721..b917f40c 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -74,10 +74,9 @@ Using your preferred tool you should: All icons in Simple Icons have been optimized with the [SVGO tool](https://github.com/svg/svgo). This can be done in one of two ways: * The [SVGO Command Line Tool](https://github.com/svg/svgo) - * Install SVGO - * With npm: `npm install -g svgo` - * With Homebrew: `brew install svgo` - * Run the following command `svgo --precision=3 -i icon.svg -o icon.min.svg` + * Install dependencies + * With npm: `npm install` from the root of this repository + * Run the following command `npm run svgo -- icons/file-to-optimize.svg` * Check if there is a loss of quality in the output, if so increase the precision. * The [SVGOMG Online Tool](https://jakearchibald.github.io/svgomg/) * Click "Open SVG" and select an SVG file. diff --git a/README.md b/README.md index 21a7d951..5e973f0f 100644 --- a/README.md +++ b/README.md @@ -42,11 +42,12 @@ The API can then be used as follows: ```javascript const simpleIcons = require('simple-icons'); -console.log(simpleIcons['Simple Icons']); +console.log(simpleIcons.get('Simple Icons')); /* { title: 'Simple Icons', + slug: 'simpleicons', hex: '111111', source: 'https://simpleicons.org/', svg: '...', @@ -66,6 +67,7 @@ console.log(icon); /* { title: 'Simple Icons', + slug: 'simpleicons', hex: '111111', source: 'https://simpleicons.org/', svg: '...', diff --git a/_data/simple-icons.json b/_data/simple-icons.json index d5fab2f3..0e2a8892 100644 --- a/_data/simple-icons.json +++ b/_data/simple-icons.json @@ -340,6 +340,11 @@ "hex": "FF5722", "source": "https://www.blogger.com" }, + { + "title": "Boeing", + "hex": "1D439C", + "source": "https://upload.wikimedia.org/wikipedia/commons/4/4f/Boeing_full_logo.svg" + }, { "title": "Boost", "hex": "F69220", @@ -360,6 +365,11 @@ "hex": "0AA0FF", "source": "https://brand.ai/brand-ai/style" }, + { + "title": "Brave", + "hex": "FB542B", + "source": "https://brave.com/brave-branding-assets/" + }, { "title": "Buddy", "hex": "1A86FD", @@ -455,6 +465,11 @@ "hex": "5881D8", "source": "https://commons.wikimedia.org/wiki/File:Clojure_logo.svg" }, + { + "title": "CloudBees", + "hex": "1997B5", + "source": "https://www.cloudbees.com/" + }, { "title": "Cloudflare", "hex": "F38020", @@ -615,6 +630,11 @@ "hex": "0066DC", "source": "http://press.dailymotion.com/?page_id=346" }, + { + "title": "Dassault Systèmes", + "hex": "005386", + "source": "https://www.3ds.com/statics/menu/2/assets/img/logo/3ds-dark.svg" + }, { "title": "DAZN", "hex": "F8F8F5", @@ -1265,6 +1285,11 @@ "hex": "EA8220", "source": "https://haxe.org/foundation/branding.html" }, + { + "title": "Helm", + "hex": "277A9F", + "source": "https://helm.sh" + }, { "title": "HERE", "hex": "48DAD0", @@ -1335,6 +1360,11 @@ "hex": "CC2929", "source": "https://support.humblebundle.com/hc/en-us/articles/202742060-Bundle-Logos" }, + { + "title": "Iata", + "hex": "004E81", + "source": "https://upload.wikimedia.org/wikipedia/commons/f/f7/IATAlogo.svg" + }, { "title": "iCloud", "hex": "3693F3", @@ -2060,6 +2090,11 @@ "hex": "F80000", "source": "https://www.oracle.com/webfolder/s/brand/identity/index.html" }, + { + "title": "ORCID", + "hex": "A6CE39", + "source": "https://orcid.org/trademark-and-id-display-guidelines" + }, { "title": "Origin", "hex": "F56C2D", @@ -2575,6 +2610,11 @@ "hex": "FB6022", "source": "https://www.sogou.com/" }, + { + "title": "Solus", + "hex": "5294E2", + "source": "https://getsol.us/branding/" + }, { "title": "Songkick", "hex": "F80046", @@ -2910,6 +2950,11 @@ "hex": "36465D", "source": "https://www.tumblr.com/logo" }, + { + "title": "Turkish Airlines", + "hex": "C70A0C", + "source": "https://www.turkishairlines.com/tr-int/basin-odasi/logo-arsivi/index.html" + }, { "title": "Twilio", "hex": "F22F46", @@ -2980,6 +3025,11 @@ "hex": "000000", "source": "https://unity.com/" }, + { + "title": "Unreal Engine", + "hex": "313131", + "source": "https://www.unrealengine.com/en-US/branding" + }, { "title": "Unsplash", "hex": "000000", @@ -3097,8 +3147,8 @@ }, { "title": "WebStorm", - "hex": "00CDD7", - "source": "https://www.jetbrains.com/company/brand/#section=images-logos" + "hex": "000000", + "source": "https://www.jetbrains.com/company/brand/logos/" }, { "title": "WeChat", diff --git a/icons/boeing.svg b/icons/boeing.svg new file mode 100644 index 00000000..126d0c3c --- /dev/null +++ b/icons/boeing.svg @@ -0,0 +1 @@ +Boeing icon \ No newline at end of file diff --git a/icons/brave.svg b/icons/brave.svg new file mode 100644 index 00000000..4318903f --- /dev/null +++ b/icons/brave.svg @@ -0,0 +1 @@ +Brave icon \ No newline at end of file diff --git a/icons/cloudbees.svg b/icons/cloudbees.svg new file mode 100644 index 00000000..1d547558 --- /dev/null +++ b/icons/cloudbees.svg @@ -0,0 +1 @@ +CloudBees icon \ No newline at end of file diff --git a/icons/dassaultsystemes.svg b/icons/dassaultsystemes.svg new file mode 100644 index 00000000..919c0a44 --- /dev/null +++ b/icons/dassaultsystemes.svg @@ -0,0 +1 @@ +Dassault Systèmes icon \ No newline at end of file diff --git a/icons/helm.svg b/icons/helm.svg new file mode 100644 index 00000000..e34c209e --- /dev/null +++ b/icons/helm.svg @@ -0,0 +1 @@ +Helm icon \ No newline at end of file diff --git a/icons/iata.svg b/icons/iata.svg new file mode 100644 index 00000000..a4fcba14 --- /dev/null +++ b/icons/iata.svg @@ -0,0 +1 @@ +Iata icon \ No newline at end of file diff --git a/icons/orcid.svg b/icons/orcid.svg new file mode 100644 index 00000000..4ce63494 --- /dev/null +++ b/icons/orcid.svg @@ -0,0 +1 @@ +ORCID icon \ No newline at end of file diff --git a/icons/solus.svg b/icons/solus.svg new file mode 100644 index 00000000..7f79d282 --- /dev/null +++ b/icons/solus.svg @@ -0,0 +1 @@ +Solus icon \ No newline at end of file diff --git a/icons/turkishairlines.svg b/icons/turkishairlines.svg new file mode 100644 index 00000000..67220493 --- /dev/null +++ b/icons/turkishairlines.svg @@ -0,0 +1 @@ +Turkish Airlines icon \ No newline at end of file diff --git a/icons/unrealengine.svg b/icons/unrealengine.svg new file mode 100644 index 00000000..7e23f2ff --- /dev/null +++ b/icons/unrealengine.svg @@ -0,0 +1 @@ +Unreal Engine icon \ No newline at end of file diff --git a/icons/webstorm.svg b/icons/webstorm.svg index c188cd67..9a3c0434 100644 --- a/icons/webstorm.svg +++ b/icons/webstorm.svg @@ -1 +1 @@ -WebStorm icon \ No newline at end of file +WebStorm icon \ No newline at end of file diff --git a/package-lock.json b/package-lock.json index ba525a1e..821af15a 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "simple-icons", - "version": "1.11.0", + "version": "1.12.0", "lockfileVersion": 1, "requires": true, "dependencies": { @@ -187,6 +187,12 @@ "integrity": "sha512-rx29MMkRdVmzunmiA4lzBYJNnXsW/PhG4kMBy2ATsYaDjGGR75dCFEVVROKpNwlVdcUX3xxlghKQOeDPBJobng==", "dev": true }, + "@types/q": { + "version": "1.5.2", + "resolved": "https://registry.npmjs.org/@types/q/-/q-1.5.2.tgz", + "integrity": "sha512-ce5d3q03Ex0sy4R14722Rmt6MT07Ua+k4FwDfdcToYJcMKNtRVQvJ6JCAPdAmAnbRb6CsX6aYb9m96NGod9uTw==", + "dev": true + }, "JSV": { "version": "4.0.2", "resolved": "https://registry.npmjs.org/JSV/-/JSV-4.0.2.tgz", @@ -824,6 +830,39 @@ "integrity": "sha1-bqa989hTrlTMuOR7+gvz+QMfsYQ=", "dev": true }, + "coa": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/coa/-/coa-2.0.2.tgz", + "integrity": "sha512-q5/jG+YQnSy4nRTV4F7lPepBJZ8qBNJJDBuJdoejDyLXgmL7IEo+Le2JDZudFTFt7mrCqIRaSjws4ygRCTCAXA==", + "dev": true, + "requires": { + "@types/q": "^1.5.1", + "chalk": "^2.4.1", + "q": "^1.1.2" + }, + "dependencies": { + "ansi-styles": { + "version": "3.2.1", + "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-3.2.1.tgz", + "integrity": "sha512-VT0ZI6kZRdTh8YyJw3SMbYm/u+NqfsAxEpWO0Pf9sq8/e94WxxOpPKx9FR1FlyCtOVDNOQ+8ntlqFxiRc+r5qA==", + "dev": true, + "requires": { + "color-convert": "^1.9.0" + } + }, + "chalk": { + "version": "2.4.2", + "resolved": "https://registry.npmjs.org/chalk/-/chalk-2.4.2.tgz", + "integrity": "sha512-Mti+f9lpJNcwF4tWV8/OrTTtF1gZi+f8FqlyAdouralcFWFQWF2+NgCHShjkCb+IFBLq9buZwE1xckQU4peSuQ==", + "dev": true, + "requires": { + "ansi-styles": "^3.2.1", + "escape-string-regexp": "^1.0.5", + "supports-color": "^5.3.0" + } + } + } + }, "code-point-at": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/code-point-at/-/code-point-at-1.1.0.tgz", @@ -868,8 +907,7 @@ "version": "2.20.0", "resolved": "https://registry.npmjs.org/commander/-/commander-2.20.0.tgz", "integrity": "sha512-7j2y+40w61zy6YC2iRNpUe/NwhNyoXrYpHMrSunaMG64nRnaf96zO/KMQR4OyN/UnE5KLyEBnKHd4aG3rskjpQ==", - "dev": true, - "optional": true + "dev": true }, "compare-versions": { "version": "3.4.0", @@ -955,12 +993,55 @@ "nth-check": "~1.0.1" } }, + "css-select-base-adapter": { + "version": "0.1.1", + "resolved": "https://registry.npmjs.org/css-select-base-adapter/-/css-select-base-adapter-0.1.1.tgz", + "integrity": "sha512-jQVeeRG70QI08vSTwf1jHxp74JoZsr2XSgETae8/xC8ovSnL2WF87GTLO86Sbwdt2lK4Umg4HnnwMO4YF3Ce7w==", + "dev": true + }, + "css-tree": { + "version": "1.0.0-alpha.33", + "resolved": "https://registry.npmjs.org/css-tree/-/css-tree-1.0.0-alpha.33.tgz", + "integrity": "sha512-SPt57bh5nQnpsTBsx/IXbO14sRc9xXu5MtMAVuo0BaQQmyf0NupNPPSoMaqiAF5tDFafYsTkfeH4Q/HCKXkg4w==", + "dev": true, + "requires": { + "mdn-data": "2.0.4", + "source-map": "^0.5.3" + } + }, "css-what": { "version": "2.1.3", "resolved": "https://registry.npmjs.org/css-what/-/css-what-2.1.3.tgz", "integrity": "sha512-a+EPoD+uZiNfh+5fxw2nO9QwFa6nJe2Or35fGY6Ipw1R3R4AGz1d1TEZrCegvw2YTmZ0jXirGYlzxxpYSHwpEg==", "dev": true }, + "csso": { + "version": "3.5.1", + "resolved": "https://registry.npmjs.org/csso/-/csso-3.5.1.tgz", + "integrity": "sha512-vrqULLffYU1Q2tLdJvaCYbONStnfkfimRxXNaGjxMldI0C7JPBC4rB1RyjhfdZ4m1frm8pM9uRPKH3d2knZ8gg==", + "dev": true, + "requires": { + "css-tree": "1.0.0-alpha.29" + }, + "dependencies": { + "css-tree": { + "version": "1.0.0-alpha.29", + "resolved": "https://registry.npmjs.org/css-tree/-/css-tree-1.0.0-alpha.29.tgz", + "integrity": "sha512-sRNb1XydwkW9IOci6iB2xmy8IGCj6r/fr+JWitvJ2JxQRPzN3T4AGGVWCMlVmVwM1gtgALJRmGIlWv5ppnGGkg==", + "dev": true, + "requires": { + "mdn-data": "~1.1.0", + "source-map": "^0.5.3" + } + }, + "mdn-data": { + "version": "1.1.4", + "resolved": "https://registry.npmjs.org/mdn-data/-/mdn-data-1.1.4.tgz", + "integrity": "sha512-FSYbp3lyKjyj3E7fMl6rYvUdX0FBXaluGqlFoYESWQlyUTq8R+wp0rkFxoYFqZlHCvsUXGjyJmLQSnXToYhOSA==", + "dev": true + } + } + }, "cssom": { "version": "0.3.6", "resolved": "https://registry.npmjs.org/cssom/-/cssom-0.3.6.tgz", @@ -3909,6 +3990,12 @@ "object-visit": "^1.0.0" } }, + "mdn-data": { + "version": "2.0.4", + "resolved": "https://registry.npmjs.org/mdn-data/-/mdn-data-2.0.4.tgz", + "integrity": "sha512-iV3XNKw06j5Q7mi6h+9vbx23Tv7JkjEVgKHW4pimwyDGWm0OIQntJJ+u1C6mg6mK1EaTv42XQ7w76yuzH7M2cA==", + "dev": true + }, "mem": { "version": "4.1.0", "resolved": "https://registry.npmjs.org/mem/-/mem-4.1.0.tgz", @@ -4030,9 +4117,9 @@ } }, "mixin-deep": { - "version": "1.3.1", - "resolved": "https://registry.npmjs.org/mixin-deep/-/mixin-deep-1.3.1.tgz", - "integrity": "sha512-8ZItLHeEgaqEvd5lYBXfm4EZSFCX29Jb9K+lAHhDKzReKBQKj3R+7NOF6tjqYi9t4oI8VUfaWITJQm86wnXGNQ==", + "version": "1.3.2", + "resolved": "https://registry.npmjs.org/mixin-deep/-/mixin-deep-1.3.2.tgz", + "integrity": "sha512-WRoDn//mXBiJ1H40rqa3vH0toePwSsGb45iInWlTySa+Uu4k3tYUSxa2v1KqAiLtvlrSzaExqS1gtk96A9zvEA==", "dev": true, "requires": { "for-in": "^1.0.2", @@ -4302,6 +4389,18 @@ "isobject": "^3.0.1" } }, + "object.values": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/object.values/-/object.values-1.1.0.tgz", + "integrity": "sha512-8mf0nKLAoFX6VlNVdhGj31SVYpaNFtUnuoOXWyFEstsWRgU837AK+JYM0iAxwkSzGRbwn8cbFmgbyxj1j4VbXg==", + "dev": true, + "requires": { + "define-properties": "^1.1.3", + "es-abstract": "^1.12.0", + "function-bind": "^1.1.1", + "has": "^1.0.3" + } + }, "once": { "version": "1.4.0", "resolved": "https://registry.npmjs.org/once/-/once-1.4.0.tgz", @@ -4629,6 +4728,12 @@ "integrity": "sha512-XRsRjdf+j5ml+y/6GKHPZbrF/8p2Yga0JPtdqTIY2Xe5ohJPD9saDJJLPvp9+NSBprVvevdXZybnj2cv8OEd0A==", "dev": true }, + "q": { + "version": "1.5.1", + "resolved": "https://registry.npmjs.org/q/-/q-1.5.1.tgz", + "integrity": "sha1-fjL3W0E4EpHQRhHxvxQQmsAGUdc=", + "dev": true + }, "qs": { "version": "6.5.2", "resolved": "https://registry.npmjs.org/qs/-/qs-6.5.2.tgz", @@ -4940,9 +5045,9 @@ "dev": true }, "set-value": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/set-value/-/set-value-2.0.0.tgz", - "integrity": "sha512-hw0yxk9GT/Hr5yJEYnHNKYXkIA8mVJgd9ditYZCe16ZczcaELYYcfvaXesNACk2O8O0nTiPQcQhGUQj8JLzeeg==", + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/set-value/-/set-value-2.0.1.tgz", + "integrity": "sha512-JxHc1weCN68wRY0fhCoXpyK55m/XPHafOmK4UWD7m2CI14GMcFypt4w/0+NV5f/ZMby2F6S2wwA7fgynh9gWSw==", "dev": true, "requires": { "extend-shallow": "^2.0.1", @@ -5230,6 +5335,12 @@ "tweetnacl": "~0.14.0" } }, + "stable": { + "version": "0.1.8", + "resolved": "https://registry.npmjs.org/stable/-/stable-0.1.8.tgz", + "integrity": "sha512-ji9qxRnOVfcuLDySj9qzhGSEFVobyt1kIOSkj1qZzYLzq7Tos/oUUWvotUPQLlrsidqsK6tBH89Bc9kL5zHA6w==", + "dev": true + }, "stack-utils": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/stack-utils/-/stack-utils-1.0.2.tgz", @@ -5401,6 +5512,71 @@ } } }, + "svgo": { + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/svgo/-/svgo-1.3.0.tgz", + "integrity": "sha512-MLfUA6O+qauLDbym+mMZgtXCGRfIxyQoeH6IKVcFslyODEe/ElJNwr0FohQ3xG4C6HK6bk3KYPPXwHVJk3V5NQ==", + "dev": true, + "requires": { + "chalk": "^2.4.1", + "coa": "^2.0.2", + "css-select": "^2.0.0", + "css-select-base-adapter": "^0.1.1", + "css-tree": "1.0.0-alpha.33", + "csso": "^3.5.1", + "js-yaml": "^3.13.1", + "mkdirp": "~0.5.1", + "object.values": "^1.1.0", + "sax": "~1.2.4", + "stable": "^0.1.8", + "unquote": "~1.1.1", + "util.promisify": "~1.0.0" + }, + "dependencies": { + "ansi-styles": { + "version": "3.2.1", + "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-3.2.1.tgz", + "integrity": "sha512-VT0ZI6kZRdTh8YyJw3SMbYm/u+NqfsAxEpWO0Pf9sq8/e94WxxOpPKx9FR1FlyCtOVDNOQ+8ntlqFxiRc+r5qA==", + "dev": true, + "requires": { + "color-convert": "^1.9.0" + } + }, + "chalk": { + "version": "2.4.2", + "resolved": "https://registry.npmjs.org/chalk/-/chalk-2.4.2.tgz", + "integrity": "sha512-Mti+f9lpJNcwF4tWV8/OrTTtF1gZi+f8FqlyAdouralcFWFQWF2+NgCHShjkCb+IFBLq9buZwE1xckQU4peSuQ==", + "dev": true, + "requires": { + "ansi-styles": "^3.2.1", + "escape-string-regexp": "^1.0.5", + "supports-color": "^5.3.0" + } + }, + "css-select": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/css-select/-/css-select-2.0.2.tgz", + "integrity": "sha512-dSpYaDVoWaELjvZ3mS6IKZM/y2PMPa/XYoEfYNZePL4U/XgyxZNroHEHReDx/d+VgXh9VbCTtFqLkFbmeqeaRQ==", + "dev": true, + "requires": { + "boolbase": "^1.0.0", + "css-what": "^2.1.2", + "domutils": "^1.7.0", + "nth-check": "^1.0.2" + } + }, + "domutils": { + "version": "1.7.0", + "resolved": "https://registry.npmjs.org/domutils/-/domutils-1.7.0.tgz", + "integrity": "sha512-Lgd2XcJ/NjEw+7tFvfKxOzCYKZsdct5lczQ2ZaQY8Djz7pfAD3Gbp8ySJWtreII/vDlMVmxwa6pHmdxIYgttDg==", + "dev": true, + "requires": { + "dom-serializer": "0", + "domelementtype": "1" + } + } + } + }, "symbol-tree": { "version": "3.2.2", "resolved": "https://registry.npmjs.org/symbol-tree/-/symbol-tree-3.2.2.tgz", @@ -5629,7 +5805,6 @@ "resolved": "https://registry.npmjs.org/uglify-js/-/uglify-js-3.6.0.tgz", "integrity": "sha512-W+jrUHJr3DXKhrsS7NUVxn3zqMOFn0hL/Ei6v0anCIMoKC93TjcflTagwIHLW7SfMFfiQuktQyFVCFHGUE0+yg==", "dev": true, - "optional": true, "requires": { "commander": "~2.20.0", "source-map": "~0.6.1" @@ -5639,8 +5814,7 @@ "version": "0.6.1", "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.6.1.tgz", "integrity": "sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==", - "dev": true, - "optional": true + "dev": true } } }, @@ -5651,38 +5825,15 @@ "dev": true }, "union-value": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/union-value/-/union-value-1.0.0.tgz", - "integrity": "sha1-XHHDTLW61dzr4+oM0IIHulqhrqQ=", + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/union-value/-/union-value-1.0.1.tgz", + "integrity": "sha512-tJfXmxMeWYnczCVs7XAEvIV7ieppALdyepWMkHkwciRpZraG/xwT+s2JN8+pr1+8jCRf80FFzvr+MpQeeoF4Xg==", "dev": true, "requires": { "arr-union": "^3.1.0", "get-value": "^2.0.6", "is-extendable": "^0.1.1", - "set-value": "^0.4.3" - }, - "dependencies": { - "extend-shallow": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/extend-shallow/-/extend-shallow-2.0.1.tgz", - "integrity": "sha1-Ua99YUrZqfYQ6huvu5idaxxWiQ8=", - "dev": true, - "requires": { - "is-extendable": "^0.1.0" - } - }, - "set-value": { - "version": "0.4.3", - "resolved": "https://registry.npmjs.org/set-value/-/set-value-0.4.3.tgz", - "integrity": "sha1-fbCPnT0i3H945Trzw79GZuzfzPE=", - "dev": true, - "requires": { - "extend-shallow": "^2.0.1", - "is-extendable": "^0.1.1", - "is-plain-object": "^2.0.1", - "to-object-path": "^0.3.0" - } - } + "set-value": "^2.0.1" } }, "unique-string": { @@ -5694,6 +5845,12 @@ "crypto-random-string": "^1.0.0" } }, + "unquote": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/unquote/-/unquote-1.1.1.tgz", + "integrity": "sha1-j97XMk7G6IoP+LkF58CYzcCG1UQ=", + "dev": true + }, "unset-value": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/unset-value/-/unset-value-1.0.0.tgz", diff --git a/package.json b/package.json index 44a4c727..a1e7256c 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "simple-icons", - "version": "1.11.0", + "version": "1.12.0", "description": "SVG icons for popular brands https://simpleicons.org", "homepage": "https://www.simpleicons.org", "keywords": [ @@ -21,16 +21,21 @@ "editorconfig-checker": "^2.0.8", "jest": "^24.1.0", "jsonlint2": "^1.7.1", - "svglint": "^1.0.4" + "svglint": "^1.0.4", + "svgo": "^1.3.0", + "uglify-js": "^3.6.0" }, "scripts": { + "build": "node scripts/build-package.js", + "clean": "rm icons/*.js index.js", "jsonlint": "jsonlint _data/simple-icons.json -q -V .jsonlintschema", "svglint": "svglint icons/* --ci", "wslint": "editorconfig-checker --ignore", - "prepublishOnly": "node scripts/prepublish.js", - "postpublish": "rm icons/*.js index.js", + "prepublishOnly": "npm run build", + "postpublish": "npm run clean", "test": "jest", "pretest": "npm run prepublishOnly", - "posttest": "npm run postpublish" + "posttest": "npm run postpublish", + "svgo": "svgo --config=./.svgo.yml" } } diff --git a/scripts/build-package.js b/scripts/build-package.js new file mode 100644 index 00000000..287b2f2e --- /dev/null +++ b/scripts/build-package.js @@ -0,0 +1,56 @@ +#!/usr/bin/env node +/** + * @fileoverview + * Compiles our icons into static .js files that can be imported in the browser + * and are tree-shakeable. + * The static .js files go in icons/{filename}.js. + * Also generates an index.js that exports all icons by title, but is not tree-shakeable + */ + +const fs = require("fs"); +const util = require("util"); +const minify = require("uglify-js").minify; + +const dataFile = "../_data/simple-icons.json"; +const indexFile = `${__dirname}/../index.js`; +const iconsDir = `${__dirname}/../icons`; +const indexTemplateFile = `${__dirname}/templates/index.js`; + +const data = require(dataFile); +const { titleToFilename } = require("./utils"); + +// Local helper functions +function escape(value) { + return value.replace(/'/g, "\\'"); +} +function iconToKeyValue(icon) { + return `'${icon.title}':${iconToObject(icon)}`; +} +function iconToObject(icon) { + return `{title:'${escape(icon.title)}',slug:'${escape(icon.slug)}',svg:'${escape(icon.svg)}',get path(){return this.svg.match(/ { + const filename = titleToFilename(icon.title); + icon.svg = fs.readFileSync(`${iconsDir}/${filename}.svg`, "utf8"); + icon.slug = filename; + icons.push(icon) + + // write the static .js file for the icon + fs.writeFileSync( + `${iconsDir}/${filename}.js`, + `module.exports=${iconToObject(icon)};` + ); +}); + +// write our generic index.js +const indexTemplate = fs.readFileSync(indexTemplateFile, "utf8"); +const { error, code } = minify(util.format(indexTemplate, icons.map(iconToKeyValue).join(','))); +if (error) { + console.error(error); + process.exit(1); +} else { + fs.writeFileSync(indexFile, code); +} diff --git a/scripts/prepublish.js b/scripts/prepublish.js deleted file mode 100755 index db663d7d..00000000 --- a/scripts/prepublish.js +++ /dev/null @@ -1,32 +0,0 @@ -#!/usr/bin/env node -/** - * @fileoverview - * Compiles our icons into static .js files that can be imported in the browser - * and are tree-shakeable. - * The static .js files go in icons/{filename}.js. - * Also generates an index.js that exports all icons by title, but is not tree-shakeable - */ - -const dataFile = "../_data/simple-icons.json"; -const indexFile = `${__dirname}/../index.js`; -const iconsDir = `${__dirname}/../icons`; -const data = require(dataFile); -const fs = require("fs"); - -const { titleToFilename } = require("./utils"); - -const icons = {}; -data.icons.forEach(icon => { - const filename = titleToFilename(icon.title); - icon.svg = fs.readFileSync(`${iconsDir}/${filename}.svg`, "utf8"); - icon.path = icon.svg.match(/ { expect(typeof subject.path).toBe('string'); expect(subject.path).toMatch(/[MmZzLlHhVvCcSsQqTtAa0-9-,.\s]/g); }); + + test(`${icon.title} has a "slug"`, () => { + expect(typeof subject.slug).toBe('string'); + }); }); diff --git a/tests/index.test.js b/tests/index.test.js index 2daf82a8..f040045b 100644 --- a/tests/index.test.js +++ b/tests/index.test.js @@ -1,5 +1,6 @@ const { icons } = require('../_data/simple-icons.json'); const simpleIcons = require('../index.js'); +const { titleToFilename } = require("../scripts/utils.js"); icons.forEach(icon => { const subject = simpleIcons[icon.title]; @@ -25,4 +26,21 @@ icons.forEach(icon => { expect(typeof subject.path).toBe('string'); expect(subject.path).toMatch(/^[MmZzLlHhVvCcSsQqTtAa0-9-,.\s]+$/g); }); + + test(`${icon.title} has a "slug"`, () => { + expect(typeof subject.slug).toBe('string'); + }); + + test(`${icon.title} can be found by it's title`, () => { + const found = simpleIcons.get(icon.title); + expect(found).toBeDefined(); + expect(found.title).toEqual(icon.title); + }); + + test(`${icon.title} can be found by it's slug`, () => { + const name = titleToFilename(icon.title); + const found = simpleIcons.get(name); + expect(found).toBeDefined(); + expect(found.title).toEqual(icon.title); + }); });