Skip to content

Commit

Permalink
Merge pull request #1597 from simple-icons/develop
Browse files Browse the repository at this point in the history
Release 4 new icons and 1 other changes
  • Loading branch information
birjj committed Aug 25, 2019
2 parents f10909e + 1a116d3 commit 01baf49
Show file tree
Hide file tree
Showing 11 changed files with 93 additions and 12 deletions.
17 changes: 17 additions & 0 deletions .gitattributes
@@ -0,0 +1,17 @@
* text=auto

# SVGs are treated as binary by default
*.svg text

# Don't diff machine generated files
package-lock.json -diff

# Treat images as binary
*.ico binary
*.png binary

# Don't export/archive these files
.github export-ignore
.gitpod.yml export-ignore
.travis.yml export-ignore
CNAME export-ignore
15 changes: 14 additions & 1 deletion .travis.yml
Expand Up @@ -22,7 +22,20 @@ jobs:
- npm run test

- stage: deploy
name: "NPM Package"
name: "Git tag"
language: minimal
if: branch = master

before_deploy:
- git config --local user.name "$GITHUB_USERNAME"
- git config --local user.email "$GITHUB_EMAIL"
- export PACKAGE_VERSION=$(cat package.json | grep 'version' | sed 's/[ \",:]//g' | sed 's/version//')
- git tag $PACKAGE_VERSION
deploy:
provider: releases
api_key: "$GITHUB_TOKEN"
skip_cleanup: true
- name: "NPM Package"
language: node_js
node_js: 8
if: branch = master
Expand Down
20 changes: 20 additions & 0 deletions _data/simple-icons.json
Expand Up @@ -665,6 +665,11 @@
"hex": "A81D33",
"source": "https://www.debian.org/logos"
},
{
"title": "deepin",
"hex": "007CFF",
"source": "https://commons.wikimedia.org/wiki/File:Deepin_logo.svg"
},
{
"title": "Deezer",
"hex": "00C7F2",
Expand Down Expand Up @@ -1500,6 +1505,11 @@
"hex": "C21325",
"source": "https://jestjs.io/"
},
{
"title": "JET",
"hex": "FBBA00",
"source": "https://de.wikipedia.org/wiki/Datei:JET.svg"
},
{
"title": "Jira",
"hex": "172B4D",
Expand Down Expand Up @@ -2390,6 +2400,11 @@
"hex": "8CA1AF",
"source": "https://github.com/rtfd/readthedocs.org/blob/master/media/readthedocsbranding.ai"
},
{
"title": "Realm",
"hex": "39477F",
"source": "https://realm.io/press"
},
{
"title": "Reason",
"hex": "DD4B39",
Expand Down Expand Up @@ -2645,6 +2660,11 @@
"hex": "000000",
"source": "https://blog.society6.com/app/themes/society6/dist/images/mark.svg"
},
{
"title": "Socket.io",
"hex": "010101",
"source": "https://socket.io"
},
{
"title": "Sogou",
"hex": "FB6022",
Expand Down
1 change: 1 addition & 0 deletions icons/deepin.svg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions icons/jet.svg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions icons/realm.svg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions icons/socket-dot-io.svg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
@@ -1,6 +1,6 @@
{
"name": "simple-icons",
"version": "1.13.0",
"version": "1.14.0",
"description": "SVG icons for popular brands https://simpleicons.org",
"homepage": "https://www.simpleicons.org",
"keywords": [
Expand Down
35 changes: 26 additions & 9 deletions scripts/build-package.js
Expand Up @@ -11,10 +11,17 @@ const fs = require("fs");
const util = require("util");
const minify = require("uglify-js").minify;

const UTF8 = "utf8";

const dataFile = "../_data/simple-icons.json";
const indexFile = `${__dirname}/../index.js`;
const iconsDir = `${__dirname}/../icons`;

const indexTemplateFile = `${__dirname}/templates/index.js`;
const iconObjectTemplateFile = `${__dirname}/templates/icon-object.js`;

const indexTemplate = fs.readFileSync(indexTemplateFile, UTF8);
const iconObjectTemplate = fs.readFileSync(iconObjectTemplateFile, UTF8);

const data = require(dataFile);
const { titleToFilename } = require("./utils");
Expand All @@ -27,27 +34,37 @@ 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(/<path\\s+d="([^"]*)/)[1];},source:'${escape(icon.source)}',hex:'${icon.hex}'}`;
return util.format(iconObjectTemplate,
escape(icon.title),
escape(icon.slug),
escape(icon.svg),
escape(icon.source),
escape(icon.hex)
);
}

// 'main'
const icons = [];
data.icons.forEach(icon => {
const filename = titleToFilename(icon.title);
icon.svg = fs.readFileSync(`${iconsDir}/${filename}.svg`, "utf8");
icon.svg = fs.readFileSync(`${iconsDir}/${filename}.svg`, UTF8);
icon.slug = filename;
icons.push(icon)
icons.push(icon);

// write the static .js file for the icon
fs.writeFileSync(
`${iconsDir}/${filename}.js`,
`module.exports=${iconToObject(icon)};`
);
const { error, code } = minify(`module.exports=${iconToObject(icon)};`);
if (error) {
console.error(error);
process.exit(1);
} else {
fs.writeFileSync(`${iconsDir}/${filename}.js`, code);
}

});

// write our generic index.js
const indexTemplate = fs.readFileSync(indexTemplateFile, "utf8");
const { error, code } = minify(util.format(indexTemplate, icons.map(iconToKeyValue).join(',')));
const rawIndexJs = util.format(indexTemplate, icons.map(iconToKeyValue).join(','));
const { error, code } = minify(rawIndexJs);
if (error) {
console.error(error);
process.exit(1);
Expand Down
10 changes: 10 additions & 0 deletions scripts/templates/icon-object.js
@@ -0,0 +1,10 @@
{
title: '%s',
slug: '%s',
svg: '%s',
get path() {
return this.svg.match(/<path\s+d="([^"]*)/)[1];
},
source: '%s',
hex: '%s',
}

0 comments on commit 01baf49

Please sign in to comment.