From bb0967f0059e594f05748139e113be76c6288803 Mon Sep 17 00:00:00 2001 From: Panayiotis Lipiridis Date: Wed, 19 Dec 2018 19:57:32 +0200 Subject: [PATCH 1/3] feat: Update SVG related tasks --- package.json | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 090ece56b86ed..ed63ff61ccfe3 100644 --- a/package.json +++ b/package.json @@ -50,6 +50,10 @@ "*.{md,css,scss,yaml,yml}": [ "prettier --write", "git add" + ], + "*.svg": [ + "svgo --pretty --indent=2 --config=svgo.yml", + "git add" ] }, "husky": { @@ -60,10 +64,10 @@ "scripts": { "bootstrap": "npm-run-all -s check-versions lerna-prepare", "check-versions": "babel-node scripts/check-versions.js", - "format": "npm run format:code && npm run format:other", + "format": "npm run format:code && npm run format:other && npm run format:svg", "format:other": "npm run prettier -- --write", "format:code": "npm run lint:code -- --fix", - "format-svg": "find www examples packages | grep '\\.svg$' | xargs -Iz -n 1 svgo --pretty --indent=2 --config=svgo.yml z", + "format:svg": "find www examples packages | grep '\\.svg$' | xargs -Iz -n 1 svgo --pretty --indent=2 --config=svgo.yml z", "hooks:uninstall": "node node_modules/husky/husky.js uninstall", "hooks:install": "node node_modules/husky/husky.js install", "jest": "jest", From ac2b6470bc4c91d5898d40e19b04337cb0598405 Mon Sep 17 00:00:00 2001 From: Ward Peeters Date: Wed, 13 Feb 2019 04:46:22 -0800 Subject: [PATCH 2/3] chore: update format-svg scripts --- .../diagram-ci.svg | 502 +++++------------- .../gatsby.svg | 15 +- package.json | 4 +- scripts/format-svg.js | 19 + www/src/assets/showcase-feather.svg | 27 +- 5 files changed, 177 insertions(+), 390 deletions(-) create mode 100644 scripts/format-svg.js diff --git a/docs/blog/2017-11-08-migrate-from-jekyll-to-gatsby/diagram-ci.svg b/docs/blog/2017-11-08-migrate-from-jekyll-to-gatsby/diagram-ci.svg index 11f4a52132c66..af239d82494fb 100644 --- a/docs/blog/2017-11-08-migrate-from-jekyll-to-gatsby/diagram-ci.svg +++ b/docs/blog/2017-11-08-migrate-from-jekyll-to-gatsby/diagram-ci.svg @@ -1,360 +1,142 @@ -
push
deploy
webhook
GitLab
Build
Test
Local
blog.singuerinc.com
Netlify
\ No newline at end of file + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + push + +
+
+ +
+ +
+
+ +
+ +
+
+ +
+ +
+
+ +
+ + deploy + +
+
+ +
+ + webhook + +
+
+
+ + + + +
+ GitLab +
+
+
+ + + +
+ Build +
+
+
+ + + +
+ Test +
+
+
+ + + +
+ Local +
+
+
+ + + +
+ blog.singuerinc.com +
+
+
+ + + +
+ Netlify +
+
+
+
+
+
diff --git a/docs/blog/2017-11-08-migrate-from-jekyll-to-gatsby/gatsby.svg b/docs/blog/2017-11-08-migrate-from-jekyll-to-gatsby/gatsby.svg index fa7e3b8860c67..51b5741111af4 100644 --- a/docs/blog/2017-11-08-migrate-from-jekyll-to-gatsby/gatsby.svg +++ b/docs/blog/2017-11-08-migrate-from-jekyll-to-gatsby/gatsby.svg @@ -1,12 +1,3 @@ - - - - gatsby - Created with Sketch. - - - - - - - \ No newline at end of file + + + diff --git a/package.json b/package.json index ed63ff61ccfe3..8600add8f4aef 100644 --- a/package.json +++ b/package.json @@ -52,7 +52,7 @@ "git add" ], "*.svg": [ - "svgo --pretty --indent=2 --config=svgo.yml", + "svgo --pretty --indent=2 --config=svgo.yml --multipass", "git add" ] }, @@ -67,7 +67,7 @@ "format": "npm run format:code && npm run format:other && npm run format:svg", "format:other": "npm run prettier -- --write", "format:code": "npm run lint:code -- --fix", - "format:svg": "find www examples packages | grep '\\.svg$' | xargs -Iz -n 1 svgo --pretty --indent=2 --config=svgo.yml z", + "format:svg": "node scripts/format-svg.js", "hooks:uninstall": "node node_modules/husky/husky.js uninstall", "hooks:install": "node node_modules/husky/husky.js install", "jest": "jest", diff --git a/scripts/format-svg.js b/scripts/format-svg.js new file mode 100644 index 0000000000000..e4b80c03fa770 --- /dev/null +++ b/scripts/format-svg.js @@ -0,0 +1,19 @@ +// this file exists because svgo only accepts folders or files, to make this work you'll need to do +// find www examples packages | grep '\\.svg$' | xargs -Iz -n 1 svgo --pretty --indent=2 --config=svgo.yml z +// this only works on bash not inside windows so we create a simple js file that does the globbing for us +const glob = require(`glob`) +const execa = require(`execa`) +const path = require(`path`) + +const files = glob.sync(`./**/*.svg`, { + ignore: `./node_modules/**`, +}) + +const proc = execa( + `./node_modules/.bin/svgo`, + [`--pretty`, `--indent=2`, `--config=svgo.yml`, `--multipass`].concat(files), + { cwd: path.join(__dirname, `..`) } +) + +proc.stdout.pipe(process.stdout) +proc.stderr.pipe(process.stderr) diff --git a/www/src/assets/showcase-feather.svg b/www/src/assets/showcase-feather.svg index f8d57129ba8c9..9cedd550e693b 100644 --- a/www/src/assets/showcase-feather.svg +++ b/www/src/assets/showcase-feather.svg @@ -1,19 +1,14 @@ - - - - - - - - - - - - - - - - + + + + + + + + + + + From dd4101abb406c5eb4350011d24553fecd82ccf49 Mon Sep 17 00:00:00 2001 From: Ward Peeters Date: Wed, 13 Feb 2019 04:51:52 -0800 Subject: [PATCH 3/3] ignore diagram-ci --- .../diagram-ci.svg | 502 +++++++++++++----- scripts/format-svg.js | 7 +- 2 files changed, 366 insertions(+), 143 deletions(-) diff --git a/docs/blog/2017-11-08-migrate-from-jekyll-to-gatsby/diagram-ci.svg b/docs/blog/2017-11-08-migrate-from-jekyll-to-gatsby/diagram-ci.svg index af239d82494fb..11f4a52132c66 100644 --- a/docs/blog/2017-11-08-migrate-from-jekyll-to-gatsby/diagram-ci.svg +++ b/docs/blog/2017-11-08-migrate-from-jekyll-to-gatsby/diagram-ci.svg @@ -1,142 +1,360 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - push - -
-
- -
- -
-
- -
- -
-
- -
- -
-
- -
- - deploy - -
-
- -
- - webhook - -
-
-
- - - - -
- GitLab -
-
-
- - - -
- Build -
-
-
- - - -
- Test -
-
-
- - - -
- Local -
-
-
- - - -
- blog.singuerinc.com -
-
-
- - - -
- Netlify -
-
-
-
-
-
+
push
deploy
webhook
GitLab
Build
Test
Local
blog.singuerinc.com
Netlify
\ No newline at end of file diff --git a/scripts/format-svg.js b/scripts/format-svg.js index e4b80c03fa770..650d26457a064 100644 --- a/scripts/format-svg.js +++ b/scripts/format-svg.js @@ -5,8 +5,13 @@ const glob = require(`glob`) const execa = require(`execa`) const path = require(`path`) +// list of ignored files because they don't get optimized correctly +const ignoreList = [ + `./docs/blog/2017-11-08-migrate-from-jekyll-to-gatsby/diagram-ci.svg`, +] + const files = glob.sync(`./**/*.svg`, { - ignore: `./node_modules/**`, + ignore: [`./node_modules/**`].concat(ignoreList), }) const proc = execa(