From dd1bd2c5c321239439df84861269067fc3be4b02 Mon Sep 17 00:00:00 2001 From: e2tha-e Date: Mon, 22 Feb 2016 07:35:10 -0500 Subject: [PATCH 1/8] replacing eval with JSON.parse --- builder/parameter_hunter.js | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/builder/parameter_hunter.js b/builder/parameter_hunter.js index cee16596b..9478e2804 100644 --- a/builder/parameter_hunter.js +++ b/builder/parameter_hunter.js @@ -35,13 +35,17 @@ console.log('found patternParameters for ' + partialName); } - //strip out the additional data and eval + //strip out the additional data, convert string to JSON. var leftParen = pMatch.indexOf('('); var rightParen = pMatch.indexOf(')'); - var paramString = '({' + pMatch.substring(leftParen + 1, rightParen) + '})'; - - //do no evil. there is no good way to do this that I can think of without using a split, which then makes commas and colons special characters and unusable within the pattern params - var paramData = eval(paramString); + var paramString = '{' + pMatch.substring(leftParen + 1, rightParen) + '}'; + //if param keys are wrapped in single quotes, replace with double quotes. + var paramStringWellFormed = paramString.replace(/(')([^'\s]+)(')(\s*\:)/gm, '"$2"$4'); + //if params keys are not wrapped in any quotes, wrap in double quotes. + var paramStringWellFormed = paramStringWellFormed.replace(/([\{|,]\s*)([^\:\s]+)(\s*\:)/gm, '$1"$2"$3'); + //if param values are wrapped in single quotes, replace with double quotes. + var paramStringWellFormed = paramStringWellFormed.replace(/(\:\s*)(')([^']+)(')/gm, '$1"$3"'); + var paramData = JSON.parse(paramStringWellFormed); var globalData = JSON.parse(JSON.stringify(patternlab.data)); var localData = JSON.parse(JSON.stringify(pattern.jsonFileData || {})); From e67e2d86e1f8914a2a67f6bddebaab777c909af2 Mon Sep 17 00:00:00 2001 From: e2tha-e Date: Mon, 22 Feb 2016 08:09:33 -0500 Subject: [PATCH 2/8] error handling --- builder/parameter_hunter.js | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/builder/parameter_hunter.js b/builder/parameter_hunter.js index 9478e2804..2b6d57f0f 100644 --- a/builder/parameter_hunter.js +++ b/builder/parameter_hunter.js @@ -45,10 +45,18 @@ var paramStringWellFormed = paramStringWellFormed.replace(/([\{|,]\s*)([^\:\s]+)(\s*\:)/gm, '$1"$2"$3'); //if param values are wrapped in single quotes, replace with double quotes. var paramStringWellFormed = paramStringWellFormed.replace(/(\:\s*)(')([^']+)(')/gm, '$1"$3"'); - var paramData = JSON.parse(paramStringWellFormed); - var globalData = JSON.parse(JSON.stringify(patternlab.data)); - var localData = JSON.parse(JSON.stringify(pattern.jsonFileData || {})); + var paramData = {}; + var globalData = {}; + var localData = {}; + + try { + paramData = JSON.parse(paramStringWellFormed); + globalData = JSON.parse(JSON.stringify(patternlab.data)); + localData = JSON.parse(JSON.stringify(pattern.jsonFileData || {})); + } catch(e){ + console.log(e); + } var allData = pattern_assembler.merge_data(globalData, localData); allData = pattern_assembler.merge_data(allData, paramData); From a5b6e4dcc6593e6fcf6bd3c41356e5fbb9e55992 Mon Sep 17 00:00:00 2001 From: e2tha-e Date: Mon, 22 Feb 2016 08:17:26 -0500 Subject: [PATCH 3/8] minor regex update --- builder/parameter_hunter.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/builder/parameter_hunter.js b/builder/parameter_hunter.js index 2b6d57f0f..bcd8f9010 100644 --- a/builder/parameter_hunter.js +++ b/builder/parameter_hunter.js @@ -38,9 +38,9 @@ //strip out the additional data, convert string to JSON. var leftParen = pMatch.indexOf('('); var rightParen = pMatch.indexOf(')'); - var paramString = '{' + pMatch.substring(leftParen + 1, rightParen) + '}'; + var paramString = '{' + pMatch.substring(leftParen + 1, rightParen) + '}'; //if param keys are wrapped in single quotes, replace with double quotes. - var paramStringWellFormed = paramString.replace(/(')([^'\s]+)(')(\s*\:)/gm, '"$2"$4'); + var paramStringWellFormed = paramString.replace(/(')([^']+)(')(\s*\:)/gm, '"$2"$4'); //if params keys are not wrapped in any quotes, wrap in double quotes. var paramStringWellFormed = paramStringWellFormed.replace(/([\{|,]\s*)([^\:\s]+)(\s*\:)/gm, '$1"$2"$3'); //if param values are wrapped in single quotes, replace with double quotes. From 09d37fe72c956dd3da3d1b2ad936a17ce647b81d Mon Sep 17 00:00:00 2001 From: Geoffrey Pursell Date: Mon, 22 Feb 2016 09:34:56 -0600 Subject: [PATCH 4/8] quick fixups to gulpfile --- gulpfile.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/gulpfile.js b/gulpfile.js index f8ad52f35..81e8d9b96 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -96,10 +96,10 @@ gulp.task('cp:css', function(){ // Styleguide Copy gulp.task('cp:styleguide', function(){ return gulp.src( - [ '**/*'], - {cwd: path.resolve(paths().source.styleguide)} ) + ['**/*'], + {cwd: path.resolve(paths().source.styleguide)}) .pipe(gulp.dest(path.resolve(paths().public.styleguide))) - .pipe(browserSync.stream());; + .pipe(browserSync.stream()); }); //server and watch tasks @@ -120,7 +120,7 @@ gulp.task('connect', ['lab'], function(){ path.resolve(paths().source.data, '*.json'), path.resolve(paths().source.fonts + '/*'), path.resolve(paths().source.images + '/*'), - path.resolve(paths().source.data + '*.json'), + path.resolve(paths().source.data + '*.json') ], ['lab-pipe'], function () { browserSync.reload(); } From 75ff18a01114636ff21b48f0c58a01f17d117e78 Mon Sep 17 00:00:00 2001 From: Geoffrey Pursell Date: Mon, 22 Feb 2016 09:36:26 -0600 Subject: [PATCH 5/8] exclude the UI chrome from browsersync snippet injection --- Gruntfile.js | 24 +++++++++++++++++++++++- gulpfile.js | 26 ++++++++++++++++++++++++-- 2 files changed, 47 insertions(+), 3 deletions(-) diff --git a/Gruntfile.js b/Gruntfile.js index 7b57f6385..06c6cf6d2 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -101,6 +101,10 @@ module.exports = function(grunt) { ignoreInitial: true, ignored: '*.html' }, + snippetOptions: { + // Ignore all HTML files within the templates folder + blacklist: ['/index.html', '/'] + }, plugins: [ { module: 'bs-html-injector', @@ -108,7 +112,25 @@ module.exports = function(grunt) { files: [path.resolve(paths().public.root + '/index.html'), path.resolve(paths().public.styleguide + '/styleguide.html')] } } - ] + ], + notify: { + styles: [ + 'display: none', + 'padding: 15px', + 'font-family: sans-serif', + 'position: fixed', + 'font-size: 1em', + 'z-index: 9999', + 'bottom: 0px', + 'right: 0px', + 'border-top-left-radius: 5px', + 'background-color: #1B2032', + 'opacity: 0.4', + 'margin: 0', + 'color: white', + 'text-align: center' + ] + } } } }, diff --git a/gulpfile.js b/gulpfile.js index 81e8d9b96..a481efccd 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -102,11 +102,33 @@ gulp.task('cp:styleguide', function(){ .pipe(browserSync.stream()); }); -//server and watch tasks -gulp.task('connect', ['lab'], function(){ +// server and watch tasks +gulp.task('connect', ['lab'], function () { browserSync.init({ server: { baseDir: path.resolve(paths().public.root) + }, + snippetOptions: { + // Ignore all HTML files within the templates folder + blacklist: ['/index.html', '/'] + }, + notify: { + styles: [ + 'display: none', + 'padding: 15px', + 'font-family: sans-serif', + 'position: fixed', + 'font-size: 1em', + 'z-index: 9999', + 'bottom: 0px', + 'right: 0px', + 'border-top-left-radius: 5px', + 'background-color: #1B2032', + 'opacity: 0.4', + 'margin: 0', + 'color: white', + 'text-align: center' + ] } }); gulp.watch(path.resolve(paths().source.css, '**/*.css'), ['cp:css']); From f828b19bf0be1bc6a778692c271741fa48a29d7f Mon Sep 17 00:00:00 2001 From: BRIAN MUENZENMEYER Date: Mon, 22 Feb 2016 18:50:24 -0600 Subject: [PATCH 6/8] bumping version, updating CHANGELOG closes #159 --- CHANGELOG | 5 +++++ builder/lineage_hunter.js | 2 +- builder/list_item_hunter.js | 2 +- builder/media_hunter.js | 2 +- builder/object_factory.js | 2 +- builder/parameter_hunter.js | 2 +- builder/pattern_assembler.js | 2 +- builder/pattern_exporter.js | 2 +- builder/patternlab.js | 2 +- builder/patternlab_grunt.js | 2 +- builder/patternlab_gulp.js | 2 +- builder/pseudopattern_hunter.js | 2 +- builder/style_modifier_hunter.js | 2 +- package.gulp.json | 2 +- package.json | 2 +- 15 files changed, 19 insertions(+), 14 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index 491f1ddab..21d4014a8 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,5 +1,10 @@ THIS CHANGELOG IS AN ATTEMPT TO DOCUMENT CHANGES TO THIS PROJECT. +PL-node-v1.1.2 +- FIX: Greatly improved the browsersync configuration, so that it only fires on the iframe, preventing users from losing their scroll position. Also lightened up the styling and made it less obtrusive. +- THX: Thanks to @geoffp for taking the lead on this issue. +- THX: This release also marks the first with @geoff's more official involvement with the project as a core contributor. His work on the `pattern_engine` branch and configurable paths have and will continue to make Pattern Lab Node better. + PL-node-v1.1.1 - FIX: Fixed issue where alternate patterns are added to end of styleguide instead of inline with their parent pattern. diff --git a/builder/lineage_hunter.js b/builder/lineage_hunter.js index 999bfb94b..8a8616006 100644 --- a/builder/lineage_hunter.js +++ b/builder/lineage_hunter.js @@ -1,5 +1,5 @@ /* - * patternlab-node - v1.1.1 - 2016 + * patternlab-node - v1.1.2 - 2016 * * Brian Muenzenmeyer, and the web community. * Licensed under the MIT license. diff --git a/builder/list_item_hunter.js b/builder/list_item_hunter.js index 44688fa8c..7e0bc8217 100644 --- a/builder/list_item_hunter.js +++ b/builder/list_item_hunter.js @@ -1,5 +1,5 @@ /* - * patternlab-node - v1.1.1 - 2016 + * patternlab-node - v1.1.2 - 2016 * * Brian Muenzenmeyer, and the web community. * Licensed under the MIT license. diff --git a/builder/media_hunter.js b/builder/media_hunter.js index 10bf885f8..b532c91bb 100644 --- a/builder/media_hunter.js +++ b/builder/media_hunter.js @@ -1,5 +1,5 @@ /* - * patternlab-node - v1.1.1 - 2016 + * patternlab-node - v1.1.2 - 2016 * * Brian Muenzenmeyer, and the web community. * Licensed under the MIT license. diff --git a/builder/object_factory.js b/builder/object_factory.js index 4e91e110c..bf1770855 100644 --- a/builder/object_factory.js +++ b/builder/object_factory.js @@ -1,5 +1,5 @@ /* - * patternlab-node - v1.1.1 - 2016 + * patternlab-node - v1.1.2 - 2016 * * Brian Muenzenmeyer, and the web community. * Licensed under the MIT license. diff --git a/builder/parameter_hunter.js b/builder/parameter_hunter.js index cee16596b..14e6adc8c 100644 --- a/builder/parameter_hunter.js +++ b/builder/parameter_hunter.js @@ -1,5 +1,5 @@ /* - * patternlab-node - v1.1.1 - 2016 + * patternlab-node - v1.1.2 - 2016 * * Brian Muenzenmeyer, and the web community. * Licensed under the MIT license. diff --git a/builder/pattern_assembler.js b/builder/pattern_assembler.js index e45e37982..888fd09e2 100644 --- a/builder/pattern_assembler.js +++ b/builder/pattern_assembler.js @@ -1,5 +1,5 @@ /* - * patternlab-node - v1.1.1 - 2016 + * patternlab-node - v1.1.2 - 2016 * * Brian Muenzenmeyer, and the web community. * Licensed under the MIT license. diff --git a/builder/pattern_exporter.js b/builder/pattern_exporter.js index 24b751cfa..3a70bea98 100644 --- a/builder/pattern_exporter.js +++ b/builder/pattern_exporter.js @@ -1,5 +1,5 @@ /* - * patternlab-node - v1.1.1 - 2016 + * patternlab-node - v1.1.2 - 2016 * * Brian Muenzenmeyer, and the web community. * Licensed under the MIT license. diff --git a/builder/patternlab.js b/builder/patternlab.js index d68c3e14b..2404d6c9a 100644 --- a/builder/patternlab.js +++ b/builder/patternlab.js @@ -1,5 +1,5 @@ /* - * patternlab-node - v1.1.1 - 2016 + * patternlab-node - v1.1.2 - 2016 * * Brian Muenzenmeyer, and the web community. * Licensed under the MIT license. diff --git a/builder/patternlab_grunt.js b/builder/patternlab_grunt.js index b04deefac..7f22c987f 100644 --- a/builder/patternlab_grunt.js +++ b/builder/patternlab_grunt.js @@ -1,5 +1,5 @@ /* - * patternlab-node - v1.1.1 - 2016 + * patternlab-node - v1.1.2 - 2016 * * Brian Muenzenmeyer, and the web community. * Licensed under the MIT license. diff --git a/builder/patternlab_gulp.js b/builder/patternlab_gulp.js index 956b20f01..a0125e657 100644 --- a/builder/patternlab_gulp.js +++ b/builder/patternlab_gulp.js @@ -1,5 +1,5 @@ /* - * patternlab-node - v1.1.1 - 2016 + * patternlab-node - v1.1.2 - 2016 * * Brian Muenzenmeyer, and the web community. * Licensed under the MIT license. diff --git a/builder/pseudopattern_hunter.js b/builder/pseudopattern_hunter.js index b262d1a3c..f2765aaa5 100644 --- a/builder/pseudopattern_hunter.js +++ b/builder/pseudopattern_hunter.js @@ -1,5 +1,5 @@ /* - * patternlab-node - v1.1.1 - 2016 + * patternlab-node - v1.1.2 - 2016 * * Brian Muenzenmeyer, and the web community. * Licensed under the MIT license. diff --git a/builder/style_modifier_hunter.js b/builder/style_modifier_hunter.js index b3402888d..11cce9d27 100644 --- a/builder/style_modifier_hunter.js +++ b/builder/style_modifier_hunter.js @@ -1,5 +1,5 @@ /* - * patternlab-node - v1.1.1 - 2016 + * patternlab-node - v1.1.2 - 2016 * * Brian Muenzenmeyer, and the web community. * Licensed under the MIT license. diff --git a/package.gulp.json b/package.gulp.json index 7e83badca..9130aca63 100644 --- a/package.gulp.json +++ b/package.gulp.json @@ -1,7 +1,7 @@ { "name": "patternlab-node", "description": "Pattern Lab is a collection of tools to help you create atomic design systems. This is the node command line interface (CLI).", - "version": "1.1.1", + "version": "1.1.2", "main": "./builder/patternlab.js", "dependencies": { "del": "^2.2.0", diff --git a/package.json b/package.json index 508a67686..47ac92da2 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "patternlab-node", "description": "Pattern Lab is a collection of tools to help you create atomic design systems. This is the node command line interface (CLI).", - "version": "1.1.1", + "version": "1.1.2", "main": "./builder/patternlab.js", "dependencies": { "diveSync": "^0.3.0", From 012da1afa54934bed53de6ef69468da687e3e496 Mon Sep 17 00:00:00 2001 From: BRIAN MUENZENMEYER Date: Mon, 22 Feb 2016 18:51:34 -0600 Subject: [PATCH 7/8] tweak the PR template with a comment for the reminder so users won't see it once it becomes a real boy --- .github/PULL_REQUEST_TEMPLATE.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md index bbe1ddf1f..4ddf5e12d 100644 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ b/.github/PULL_REQUEST_TEMPLATE.md @@ -1,4 +1,4 @@ -**Target the `dev` branch!** + Addresses # From 78a2b110bce1b8b9865f378016649e8ff78d3559 Mon Sep 17 00:00:00 2001 From: BRIAN MUENZENMEYER Date: Mon, 22 Feb 2016 19:00:27 -0600 Subject: [PATCH 8/8] add thank you for #259 --- CHANGELOG | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CHANGELOG b/CHANGELOG index 21d4014a8..c2b2fea19 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -4,6 +4,8 @@ PL-node-v1.1.2 - FIX: Greatly improved the browsersync configuration, so that it only fires on the iframe, preventing users from losing their scroll position. Also lightened up the styling and made it less obtrusive. - THX: Thanks to @geoffp for taking the lead on this issue. - THX: This release also marks the first with @geoff's more official involvement with the project as a core contributor. His work on the `pattern_engine` branch and configurable paths have and will continue to make Pattern Lab Node better. +- FIX: Replace `eval()` with a smarter `JSON.parse()` call within the `parameter_hunter.js` +- THX: Thanks to @e2tha-e for taking the high road! PL-node-v1.1.1 - FIX: Fixed issue where alternate patterns are added to end of styleguide instead of inline with their parent pattern.