From 1bdbed78c96651f1ff5bb428582fbf8ab08705e0 Mon Sep 17 00:00:00 2001 From: Dan Mindru Date: Fri, 19 Aug 2016 21:04:02 +0200 Subject: [PATCH] #18 convert conf files to JSON & lint --- examples/ONEstore/conf.js | 21 --------------------- examples/ONEstore/conf.json | 18 ++++++++++++++++++ examples/ONEstoreBlack/conf.js | 22 ---------------------- examples/ONEstoreBlack/conf.json | 19 +++++++++++++++++++ examples/fadeit/conf.js | 19 ------------------- examples/fadeit/conf.json | 17 +++++++++++++++++ examples/play/conf.js | 13 ------------- examples/play/conf.json | 15 +++++++++++++++ gulpfile.js | 2 +- package.json | 1 + src/dark/conf.js | 21 --------------------- src/dark/conf.json | 15 +++++++++++++++ src/light/conf.js | 25 ------------------------- src/light/conf.json | 13 +++++++++++++ tasks/build.js | 11 ++++++----- tasks/lint.js | 15 +++++++++++++++ 16 files changed, 120 insertions(+), 127 deletions(-) delete mode 100644 examples/ONEstore/conf.js create mode 100644 examples/ONEstore/conf.json delete mode 100644 examples/ONEstoreBlack/conf.js create mode 100644 examples/ONEstoreBlack/conf.json delete mode 100644 examples/fadeit/conf.js create mode 100644 examples/fadeit/conf.json delete mode 100644 examples/play/conf.js create mode 100644 examples/play/conf.json delete mode 100644 src/dark/conf.js create mode 100644 src/dark/conf.json delete mode 100644 src/light/conf.js create mode 100644 src/light/conf.json create mode 100644 tasks/lint.js diff --git a/examples/ONEstore/conf.js b/examples/ONEstore/conf.js deleted file mode 100644 index 30f8436..0000000 --- a/examples/ONEstore/conf.js +++ /dev/null @@ -1,21 +0,0 @@ -/* - * NB: for images, if you pass in a relative path ('assets/logo.png'), they will be automatically embedded (base64). If you pass in a URL, it will stay as it is. - */ - -module.exports = [ - { - id: 'ONEstore', // Will be appended to the built templates. - // signature: '감사합니다.', - name: '0 0 0 매니저', - team: '스토어 기획팀', - title: 'Dev Relations', - welcome: '안녕하세요.', - introParagraph: 'Thanks for writing up this email.
We are delighted to reply with a responsive template.', - contactMain: '+82-10-1234-5678 | ', // Wrap phone numbers like this to prevent iOS mail from making them blue. - contactMail: 'devhelper@onestore.co.kr', - contactSecondary: '성남시 분당구 판교역로 188 SK플래닛 건물 11층', - logoUrl: 'assets/type01.png', - logoAlt: 'Onestore logo', - website: 'http://onesto.re/' - } -]; \ No newline at end of file diff --git a/examples/ONEstore/conf.json b/examples/ONEstore/conf.json new file mode 100644 index 0000000..de85acf --- /dev/null +++ b/examples/ONEstore/conf.json @@ -0,0 +1,18 @@ +{ + "persons": [ + { + "id": "ONEstore", + "name": "0 0 0 매니저", + "team": "스토어 기획팀", + "title": "Dev Relations", + "welcome": "안녕하세요.", + "introParagraph": "Thanks for writing up this email.
We are delighted to reply with a responsive template.", + "contactMain": "+82-10-1234-5678 | ", + "contactMail": "devhelper@onestore.co.kr", + "contactSecondary": "성남시 분당구 판교역로 188 SK플래닛 건물 11층", + "logoUrl": "assets/type01.png", + "logoAlt": "Onestore logo", + "website": "http://onesto.re/" + } + ] +} diff --git a/examples/ONEstoreBlack/conf.js b/examples/ONEstoreBlack/conf.js deleted file mode 100644 index 6f7fda9..0000000 --- a/examples/ONEstoreBlack/conf.js +++ /dev/null @@ -1,22 +0,0 @@ -/* - * NB: for images, if you pass in a relative path ('assets/logo.png'), they will be automatically embedded (base64). If you pass in a URL, it will stay as it is. - */ - -module.exports = [ - { - id: 'ONEstoreBlack', // Will be appended to the built templates. - signature: 'Best regards,', - name: 'Joo Hyung Park', - team: 'Service Planning Team', - title: 'Dev Relations', - welcome: '안녕하세요.', - introParagraph: 'Thanks for writing up this email.
We are delighted to reply with a responsive template.', - contactMain: 'Call +82-10-1234-5678 or email us at', // Wrap phone numbers like this to prevent iOS mail from making them blue. - contactMail: 'devhelper@onestore.co.kr', - // slogan: '\"The 1st integrated Android App store in Korea\"', - contactSecondary: '188, Pangyoyeok-ro, Bundang-gu, Seongnam-si, Gyeonggi-do, Korea', - logoUrl: 'assets/type03.png', - logoAlt: 'ONEstore. logo', - website: 'http://onesto.re/' - } -]; \ No newline at end of file diff --git a/examples/ONEstoreBlack/conf.json b/examples/ONEstoreBlack/conf.json new file mode 100644 index 0000000..1af210b --- /dev/null +++ b/examples/ONEstoreBlack/conf.json @@ -0,0 +1,19 @@ +{ + "persons": [ + { + "id": "ONEstoreBlack", + "signature": "Best regards,", + "name": "Joo Hyung Park", + "team": "Service Planning Team", + "title": "Dev Relations", + "welcome": "안녕하세요.", + "introParagraph": "Thanks for writing up this email.
We are delighted to reply with a responsive template.", + "contactMain": "Call +82-10-1234-5678 or email us at", + "contactMail": "devhelper@onestore.co.kr", + "contactSecondary": "188, Pangyoyeok-ro, Bundang-gu, Seongnam-si, Gyeonggi-do, Korea", + "logoUrl": "assets/type03.png", + "logoAlt": "ONEstore. logo", + "website": "http://onesto.re/" + } + ] +} diff --git a/examples/fadeit/conf.js b/examples/fadeit/conf.js deleted file mode 100644 index a1cdc90..0000000 --- a/examples/fadeit/conf.js +++ /dev/null @@ -1,19 +0,0 @@ -/* - * NB: for images, if you pass in a relative path ('assets/logo.png'), they will be automatically embedded (base64). If you pass in a URL, it will stay as it is. - */ - -module.exports = [ - { - id: 'fadeit', // Will be appended to the built templates. - signature: 'Yours truly,', - name: 'Jane Whatsmyname', - welcome: 'Hi there,', - introParagraph: 'Thanks for writing up this email.
We are delighted to reply with a responsive template.', - contactMain: 'Call 81100200 or email us at', // Wrap phone numbers like this to prevent iOS mail from making them blue. - contactMail: 'info@fadeit.dk', - contactSecondary: 'Anelystparken 31, DK-8381 Tilst, Aarhus', - logoUrl: 'http://fadeit.dk/src/assets/img/brand/fadeit-logo.png', - logoAlt: 'fadeit logo', - website: 'http://fadeit.dk' - } -]; \ No newline at end of file diff --git a/examples/fadeit/conf.json b/examples/fadeit/conf.json new file mode 100644 index 0000000..829694e --- /dev/null +++ b/examples/fadeit/conf.json @@ -0,0 +1,17 @@ +{ + "persons": [ + { + "id": "fadeit", + "signature": "Yours truly,", + "name": "Jane Whatsmyname", + "welcome": "Hi there,", + "introParagraph": "Thanks for writing up this email.
We are delighted to reply with a responsive template.", + "contactMain": "Call 81100200 or email us at", + "contactMail": "info@fadeit.dk", + "contactSecondary": "Anelystparken 31, DK-8381 Tilst, Aarhus", + "logoUrl": "http://fadeit.dk/src/assets/img/brand/fadeit-logo.png", + "logoAlt": "fadeit logo", + "website": "http://fadeit.dk" + } + ] +} \ No newline at end of file diff --git a/examples/play/conf.js b/examples/play/conf.js deleted file mode 100644 index 8e4201b..0000000 --- a/examples/play/conf.js +++ /dev/null @@ -1,13 +0,0 @@ -module.exports = [ - { - id: 'play', - signature: 'Best regards,', - name: 'Jane Whatsmyname', - contactMain: 'Call (45) 81100200 or email us at', // Wrap phone numbers like this to prevent iOS mail from making them blue. - contactMail: 'info@tryplay.dk', - slogan: 'LED Pylon. LED Wall. Digital Signage.', - logoUrl: 'https://informationscreen.com/manage/assets/images/play-logo.png', - logoAlt: 'Play. logo', - website: 'http://tryplay.dk' - } -]; \ No newline at end of file diff --git a/examples/play/conf.json b/examples/play/conf.json new file mode 100644 index 0000000..064d28a --- /dev/null +++ b/examples/play/conf.json @@ -0,0 +1,15 @@ +{ + "persons": [ + { + "id": "play", + "signature": "Best regards,", + "name": "Jane Whatsmyname", + "contactMain": "Call (45) 81100200 or email us at", + "contactMail": "info@tryplay.dk", + "slogan": "LED Pylon. LED Wall. Digital Signage.", + "logoUrl": "https://informationscreen.com/manage/assets/images/play-logo.png", + "logoAlt": "Play. logo", + "website": "http://tryplay.dk" + } + ] +} diff --git a/gulpfile.js b/gulpfile.js index d003295..5a3c589 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -27,4 +27,4 @@ fs }); /** By default templates will be built into '/dist', then gulp will watch for changes in '/src'. */ -gulp.task('default', ['dupe', 'less', 'sass', 'postcss', 'build', 'watch']); \ No newline at end of file +gulp.task('default', ['dupe', 'less', 'sass', 'postcss', 'lint', 'build', 'watch']); \ No newline at end of file diff --git a/package.json b/package.json index 2679a01..de501b7 100644 --- a/package.json +++ b/package.json @@ -31,6 +31,7 @@ "gulp-david": "~0.4.2", "gulp-inline-css": "~3.1.0", "gulp-inline-image-html": "~0.2.1", + "gulp-jsonlint": "^1.1.2", "gulp-less": "^3.1.0", "gulp-minify-html": "~1.0.5", "gulp-minify-inline": "~0.2.1", diff --git a/src/dark/conf.js b/src/dark/conf.js deleted file mode 100644 index c078f86..0000000 --- a/src/dark/conf.js +++ /dev/null @@ -1,21 +0,0 @@ -/** - * @notes - * - * - for images, if you pass in a relative path ('assets/logo.png'), they will be automatically embedded (base64). If you pass in a URL, it will stay as it is. - * - the 'id' will be appended to the built template names, e.g. '/dist/signature-dark.html' - * - wrap phone numbers like this to prevent iOS mail from making them blue, e.g. `(45) 80100100` - * - */ -module.exports = [ - { - id: 'dark', - signature: 'Best regards,', - name: 'The dark mail team', - contactMain: 'Call (45) 80100100 or email us at', - contactMail: 'info@dark.dk', - slogan: 'LED Pylon. LED Wall. Digital Signage.', - logoUrl: '/assets/dark.png', - logoAlt: 'dark logo', - website: 'http://dark.dk' - } -]; \ No newline at end of file diff --git a/src/dark/conf.json b/src/dark/conf.json new file mode 100644 index 0000000..5641aec --- /dev/null +++ b/src/dark/conf.json @@ -0,0 +1,15 @@ +{ + "persons": [ + { + "id": "dark", + "signature": "Best regards,", + "name": "The dark mail team", + "contactMain": "Call (45) 80100100 or email us at", + "contactMail": "info@dark.dk", + "slogan": "LED Pylon. LED Wall. Digital Signage.", + "logoUrl": "/assets/dark.png", + "logoAlt": "dark logo", + "website": "http://dark.dk" + } + ] +} diff --git a/src/light/conf.js b/src/light/conf.js deleted file mode 100644 index 781e3e3..0000000 --- a/src/light/conf.js +++ /dev/null @@ -1,25 +0,0 @@ -/** - * @notes - * - * - for images, if you pass in a relative path ('assets/logo.png'), they will be automatically embedded (base64). If you pass in a URL, it will stay as it is. - * - the 'id' will be appended to the built template names, e.g. '/dist/signature-light.html' - * - wrap phone numbers like this to prevent iOS mail from making them blue, e.g. `(45) 80100100` - * - wrap address like this to prevent iOS mail from making it blue, e.g. `Address` - * - */ - -module.exports = [ - { - id: 'light', - signature: 'Yours truly,', - name: 'The light mail team', - welcome: 'Hi there,', - introParagraph: 'Thanks for writing up this email.
We are delighted to reply with a responsive template.', - contactMain: 'Call 80100100 or email us at', - contactMail: 'info@light.dk', - contactSecondary: 'Happy Steet 31, DK-8000 Aarhus C, Denmark', - logoUrl: '/assets/light.png', - logoAlt: 'light logo', - website: 'http://light.dk' - } -]; \ No newline at end of file diff --git a/src/light/conf.json b/src/light/conf.json new file mode 100644 index 0000000..4d65d66 --- /dev/null +++ b/src/light/conf.json @@ -0,0 +1,13 @@ +{ + "id": "light", + "signature": "Yours truly,", + "name": "The light mail team", + "welcome": "Hi there,", + "introParagraph": "Thanks for writing up this email.
We are delighted to reply with a responsive template.", + "contactMain": "Call 80100100 or email us at", + "contactMail": "info@light.dk", + "contactSecondary": "Happy Steet 31, DK-8000 Aarhus C, Denmark", + "logoUrl": "/assets/light.png", + "logoAlt": "light logo", + "website": "http://light.dk" +} diff --git a/tasks/build.js b/tasks/build.js index bbde09b..82a2dc3 100644 --- a/tasks/build.js +++ b/tasks/build.js @@ -10,10 +10,11 @@ var gulp = require('gulp'), fs = require('fs'), Q = require('q'), del = require('del'), + jsonlint = require('jsonlint'), inlineimg = require('gulp-inline-image-html'); function buildTask(options){ - gulp.task('build', ['dupe', 'less', 'sass', 'postcss'], function build() { + gulp.task('build', ['dupe', 'less', 'sass', 'postcss', 'lint'], function build() { /** Makes templates for a given directory & its configurations. * @function makeTemplates * @param {String} dir Directory to make templates from. @@ -86,11 +87,11 @@ function buildTask(options){ .readdirSync('./' + options.workingDir) .forEach(function readConfigurations(dir){ /** NB: For 'watch' to properly work, the cache needs to be deleted before each require. */ - var confPath = '../tmp/' + dir + '/conf.js'; - delete require.cache[require.resolve(confPath)]; - promises.push(makeTemplates(dir, require(confPath))); - }); + var confPath = '../tmp/' + dir + '/conf.json'; + delete require.cache[require.resolve(confPath)]; + promises.push(makeTemplates(dir, require(confPath).persons)); + }); Q.all(promises); }); diff --git a/tasks/lint.js b/tasks/lint.js new file mode 100644 index 0000000..652164e --- /dev/null +++ b/tasks/lint.js @@ -0,0 +1,15 @@ +'use strict'; + +var gulp = require('gulp'), + jsonlint = require("gulp-jsonlint"); + +function lintTask(options){ + gulp.task('lint', ['dupe'], function(){ + return options + .src(options.workingDir + '/**/conf.json') + .pipe(jsonlint()) + .pipe(jsonlint.reporter()); + }); +} + +module.exports = lintTask; \ No newline at end of file