From afb5ddd6447fc8ddb2c87ff1881cd39b29241eda Mon Sep 17 00:00:00 2001 From: e2tha-e Date: Tue, 8 Sep 2015 18:22:49 -0400 Subject: [PATCH 01/27] delete Thumbs.db and update .gitignore --- .gitignore | 2 +- source/Thumbs.db | Bin 6144 -> 0 bytes 2 files changed, 1 insertion(+), 1 deletion(-) delete mode 100644 source/Thumbs.db diff --git a/.gitignore b/.gitignore index ac97c0ae0..a701ebe2b 100644 --- a/.gitignore +++ b/.gitignore @@ -8,7 +8,7 @@ public/fonts/* public/js/* public/images/* public/patterns/* -config.ini +config.json latest-change.txt patternlab.json .sass-cache/* diff --git a/source/Thumbs.db b/source/Thumbs.db deleted file mode 100644 index c8dedbbe7cfb66442ce4ea30f29ee60bcfef08f3..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 6144 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 LEdQPU$_)GmVE!Fg From 0e61f75ccd3369689403fd72fa54ab73db3c8384 Mon Sep 17 00:00:00 2001 From: e2tha-e Date: Sun, 20 Sep 2015 07:43:16 -0400 Subject: [PATCH 02/27] deleting config from .gitignore entirely --- .gitignore | 1 - 1 file changed, 1 deletion(-) diff --git a/.gitignore b/.gitignore index a701ebe2b..7200b256a 100644 --- a/.gitignore +++ b/.gitignore @@ -8,7 +8,6 @@ public/fonts/* public/js/* public/images/* public/patterns/* -config.json latest-change.txt patternlab.json .sass-cache/* From ca59e835c4b2f386f48d69146b6b15bef5d78f7b Mon Sep 17 00:00:00 2001 From: e2tha-e Date: Sun, 20 Sep 2015 10:41:47 -0400 Subject: [PATCH 03/27] updating mergeData() so obj2 has priority --- builder/pattern_assembler.js | 38 ++++++++++++++++++++++++------------ 1 file changed, 26 insertions(+), 12 deletions(-) diff --git a/builder/pattern_assembler.js b/builder/pattern_assembler.js index 65e80eb5b..7e3f4bf36 100644 --- a/builder/pattern_assembler.js +++ b/builder/pattern_assembler.js @@ -167,24 +167,38 @@ throw 'Could not find pattern with key ' + key; } - - var self = this; - function mergeData(obj1, obj2) { - for (var p in obj2) { + /** + * Recursively merge properties of two objects. + * + * @param {object} obj1 If obj1 has properties obj2 doesn't, add to obj2. + * @param {object} obj2 This object's properties have priority over obj1. + */ + function mergeData(obj1, obj2){ + if(typeof obj2 === 'undefined'){ + obj2 = {}; + } + for(var p in obj1){ try { - // Property in destination object set; update its value. - if ( obj2[p].constructor == Object ) { - obj1[p] = self.merge_data(obj1[p], obj2[p]); - - } else { - obj1[p] = obj2[p]; + // Only recurse if obj1[p] is an object. + if(obj1[p].constructor === Object){ + // Requires 2 objects as params; create obj2[p] if undefined. + if(typeof obj2[p] === 'undefined'){ + obj2[p] = {}; + } + obj2[p] = mergeData(obj1[p], obj2[p]); + // Pop when recursion meets a non-object. If obj1[p] is a non-object, + // only copy to undefined obj2[p]. This way, obj2 maintains priority. + } else if(typeof obj2[p] === 'undefined'){ + obj2[p] = obj1[p]; } } catch(e) { // Property in destination object not set; create it and set its value. - obj1[p] = obj2[p]; + if(typeof obj2[p] === 'undefined'){ + obj2[p] = obj1[p]; + } } } - return obj1; + return obj2; } function buildListItems(patternlab){ From 22c67d90f1f42d02f09bcb80461935a78a6cc69d Mon Sep 17 00:00:00 2001 From: e2tha-e Date: Sun, 20 Sep 2015 10:44:06 -0400 Subject: [PATCH 04/27] reversing order of params in pseudopattern_hunter.js for variantFileData --- builder/pseudopattern_hunter.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/builder/pseudopattern_hunter.js b/builder/pseudopattern_hunter.js index 9f0a33a4e..2ec038bb6 100644 --- a/builder/pseudopattern_hunter.js +++ b/builder/pseudopattern_hunter.js @@ -45,7 +45,7 @@ var variantFileData = fs.readJSONSync('source/_patterns/' + pseudoPatterns[i]); //extend any existing data with variant data - variantFileData = pattern_assembler.merge_data(variantFileData, currentPattern.jsonFileData); + variantFileData = pattern_assembler.merge_data(currentPattern.jsonFileData, variantFileData); var variantName = pseudoPatterns[i].substring(pseudoPatterns[i].indexOf('~') + 1).split('.')[0]; var patternVariant = new of.oPattern(currentPattern.subdir, currentPattern.fileName + '-' + variantName + '.mustache', variantFileData); From e5f937db5cb2a34c5531efa01f3124c9eae3687d Mon Sep 17 00:00:00 2001 From: e2tha-e Date: Sun, 20 Sep 2015 10:56:30 -0400 Subject: [PATCH 05/27] unit tests --- test/list_item_hunter_tests.js | 128 ++++++++++++++++++++++++++++++++- 1 file changed, 126 insertions(+), 2 deletions(-) diff --git a/test/list_item_hunter_tests.js b/test/list_item_hunter_tests.js index 0da3c9288..b6acc101c 100644 --- a/test/list_item_hunter_tests.js +++ b/test/list_item_hunter_tests.js @@ -100,7 +100,7 @@ test.done(); }, - 'process_list_item_partials overwrites listItem data if local .listitem.json is found' : function(test){ + 'process_list_item_partials overwrites listItem property if that property is in local .listitem.json' : function(test){ //arrange //setup current pattern from what we would have during execution var currentPattern = { @@ -108,6 +108,68 @@ "extendedTemplate" : "{{#listItems.two}}{{> test-simple }}{{/listItems.two}}", "key": "test-patternName", "jsonFileData" : {}, + "patternSpecificListJson" : { + "2": [ + { + "title": "One" + }, + { + "title": "Two" + }, + ] + } + }; + + var patternlab = { + "listitems": { + "1": [ + { + "title": "Foo" + } + ], + "2": [ + { + "title": "Foo" + }, + { + "title": "Bar" + } + ] + }, + "data": { + "link": {}, + "partials": [] + }, + "config": {"debug": false}, + "patterns": [ + { + "template": "{{ title }}", + "extendedTemplate" : "{{ title }}", + "key": "test-simple", + "jsonFileData" : {} + } + ] + }; + + var list_item_hunter = new lih(); + + //act + list_item_hunter.process_list_item_partials(currentPattern, patternlab); + + //assert + test.equals(currentPattern.extendedTemplate, "OneTwo" ); + + test.done(); + }, + + 'process_list_item_partials keeps listItem property if that property is not in local .listitem.json' : function(test){ + //arrange + //setup current pattern from what we would have during execution + var currentPattern = { + "template": "{{#listItems.one}}{{ title }}{{/listItems.one}}", + "extendedTemplate" : "{{#listItems.one}}{{> test-simple }}{{/listItems.one}}", + "key": "test-patternName", + "jsonFileData" : {}, "patternSpecificListJson" : { "2": [ { @@ -157,7 +219,69 @@ list_item_hunter.process_list_item_partials(currentPattern, patternlab); //assert - test.equals(currentPattern.extendedTemplate, "OneTwo" ); + test.equals(currentPattern.extendedTemplate, "Foo" ); + + test.done(); + }, + + 'process_list_item_partials uses local listItem property if that property is not set globally' : function(test){ + //arrange + //setup current pattern from what we would have during execution + var currentPattern = { + "template": "{{#listItems.one}}{{ title }}{{/listItems.one}}", + "extendedTemplate" : "{{#listItems.one}}{{> test-simple }}{{/listItems.one}}", + "key": "test-patternName", + "jsonFileData" : {}, + "patternSpecificListJson" : { + "1": [ + { + "title": "One" + } + ], + "2": [ + { + "title": "One" + }, + { + "title": "Two" + }, + ] + } + }; + + var patternlab = { + "listitems": { + "2": [ + { + "title": "Foo" + }, + { + "title": "Bar" + } + ] + }, + "data": { + "link": {}, + "partials": [] + }, + "config": {"debug": false}, + "patterns": [ + { + "template": "{{ title }}", + "extendedTemplate" : "{{ title }}", + "key": "test-simple", + "jsonFileData" : {} + } + ] + }; + + var list_item_hunter = new lih(); + + //act + list_item_hunter.process_list_item_partials(currentPattern, patternlab); + + //assert + test.equals(currentPattern.extendedTemplate, "One" ); test.done(); } From 986f2eade6b82a89975844c5a21411d0959b9bb2 Mon Sep 17 00:00:00 2001 From: e2tha-e Date: Sun, 20 Sep 2015 10:58:52 -0400 Subject: [PATCH 06/27] docblock --- builder/pattern_assembler.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/builder/pattern_assembler.js b/builder/pattern_assembler.js index 7e3f4bf36..791f4fe06 100644 --- a/builder/pattern_assembler.js +++ b/builder/pattern_assembler.js @@ -170,8 +170,9 @@ /** * Recursively merge properties of two objects. * - * @param {object} obj1 If obj1 has properties obj2 doesn't, add to obj2. - * @param {object} obj2 This object's properties have priority over obj1. + * @param {Object} obj1 If obj1 has properties obj2 doesn't, add to obj2. + * @param {Object} obj2 This object's properties have priority over obj1. + * @returns {Object} obj2 */ function mergeData(obj1, obj2){ if(typeof obj2 === 'undefined'){ From aab79d79bb0416eff09a081da6f270bd1c9470e4 Mon Sep 17 00:00:00 2001 From: e2tha-e Date: Sun, 20 Sep 2015 11:10:56 -0400 Subject: [PATCH 07/27] deleting whitespace --- test/list_item_hunter_tests.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/test/list_item_hunter_tests.js b/test/list_item_hunter_tests.js index b6acc101c..7f41cee88 100644 --- a/test/list_item_hunter_tests.js +++ b/test/list_item_hunter_tests.js @@ -179,7 +179,7 @@ "title": "Two" }, ] - } + } }; var patternlab = { @@ -217,7 +217,7 @@ //act list_item_hunter.process_list_item_partials(currentPattern, patternlab); - + //assert test.equals(currentPattern.extendedTemplate, "Foo" ); @@ -246,7 +246,7 @@ "title": "Two" }, ] - } + } }; var patternlab = { @@ -279,7 +279,7 @@ //act list_item_hunter.process_list_item_partials(currentPattern, patternlab); - + //assert test.equals(currentPattern.extendedTemplate, "One" ); From 38dfe5c5fc4b0d245dd3d96048f2f4566a543165 Mon Sep 17 00:00:00 2001 From: e2tha-e Date: Sun, 20 Sep 2015 11:20:54 -0400 Subject: [PATCH 08/27] reversing order of find_pseudopatterns() and addPattern() in pattern_assembler --- builder/pattern_assembler.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/builder/pattern_assembler.js b/builder/pattern_assembler.js index 65e80eb5b..36b7595d2 100644 --- a/builder/pattern_assembler.js +++ b/builder/pattern_assembler.js @@ -148,11 +148,11 @@ //find pattern lineage lineage_hunter.find_lineage(currentPattern, patternlab); - //look for a pseudo pattern by checking if there is a file containing same name, with ~ in it, ending in .json - pseudopattern_hunter.find_pseudopatterns(currentPattern, patternlab); - //add to patternlab object so we can look these up later. addPattern(currentPattern, patternlab); + + //look for a pseudo pattern by checking if there is a file containing same name, with ~ in it, ending in .json + pseudopattern_hunter.find_pseudopatterns(currentPattern, patternlab); } function getpatternbykey(key, patternlab){ From adc38cfeccb5faa69687774cc715e4b1f129de90 Mon Sep 17 00:00:00 2001 From: BRIAN MUENZENMEYER Date: Sun, 20 Sep 2015 23:33:36 -0500 Subject: [PATCH 09/27] add some recent pull requests to CHANGELOG --- CHANGELOG | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/CHANGELOG b/CHANGELOG index 9a3abb751..7a1dd4212 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,5 +1,10 @@ THIS CHANGELOG IS AN ATTEMPT TO DOCUMENT CHANGES TO THIS PROJECT. +PL-node-v0.13.0 +- FIX: Cleanup an old file and an incorrect entry in the .gitignore file +- CHG: Change order of pattern addition and ~variant pattern addition so they build naturally in the menu. +- THX: Thanks @e2tha-e for the flurry of pull requests! + PL-node-v0.12.0 - ADD: Gulp support arrives with an optional configuration - ADD: Instructions how to install and run with Gulp From 1d63d12a9c0d8df19acd4f911af40dd9d290a96a Mon Sep 17 00:00:00 2001 From: BRIAN MUENZENMEYER Date: Fri, 25 Sep 2015 00:11:33 -0500 Subject: [PATCH 10/27] Update CHANGELOG to mention the change to the merge data function. Closes #150 --- CHANGELOG | 4 +++- package.gulp.json | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index 7a1dd4212..19004fcb2 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -2,8 +2,10 @@ THIS CHANGELOG IS AN ATTEMPT TO DOCUMENT CHANGES TO THIS PROJECT. PL-node-v0.13.0 - FIX: Cleanup an old file and an incorrect entry in the .gitignore file -- CHG: Change order of pattern addition and ~variant pattern addition so they build naturally in the menu. +- CHG: Change order of pattern addition and ~variant pattern addition so they build naturally in the menu. - THX: Thanks @e2tha-e for the flurry of pull requests! +- CHG: Update data merge function to prioritize handle pattern~variant.json files +- THX: Thanks @e2tha-e for finding, fixing, and unit testing the data merge issue. PL-node-v0.12.0 - ADD: Gulp support arrives with an optional configuration diff --git a/package.gulp.json b/package.gulp.json index 36406357a..3bc12da2c 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": "0.12.0", + "version": "0.13.0", "devDependencies": { "browser-sync": "^2.8.2", "del": "^1.2.1", From da948477bd81134ea930f2fcba65de1d16bc8e43 Mon Sep 17 00:00:00 2001 From: BRIAN MUENZENMEYER Date: Fri, 25 Sep 2015 00:11:43 -0500 Subject: [PATCH 11/27] missed a commit --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 1d97710a9..b018cf595 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": "0.12.0", + "version": "0.13.0", "devDependencies": { "bs-html-injector": "^2.0.4", "diveSync": "^0.2.1", From 2031290d3e0b756eb3a70553014cddeebad273a5 Mon Sep 17 00:00:00 2001 From: e2tha-e Date: Fri, 2 Oct 2015 06:44:45 -0400 Subject: [PATCH 12/27] recursive partial include --- builder/object_factory.js | 3 +- builder/pattern_assembler.js | 68 ++++++++++++++++++++++++++------- builder/patternlab.js | 22 ++++++++++- builder/pseudopattern_hunter.js | 4 +- 4 files changed, 81 insertions(+), 16 deletions(-) diff --git a/builder/object_factory.js b/builder/object_factory.js index 38582ab65..23333bac2 100644 --- a/builder/object_factory.js +++ b/builder/object_factory.js @@ -11,8 +11,9 @@ (function () { "use strict"; - var oPattern = function(subdir, filename, data){ + var oPattern = function(abspath, subdir, filename, data){ this.fileName = filename.substring(0, filename.indexOf('.')); + this.abspath = abspath; this.subdir = subdir; this.name = subdir.replace(/[\/\\]/g, '-') + '-' + this.fileName; //this is the unique name with the subDir this.jsonFileData = data || {}; diff --git a/builder/pattern_assembler.js b/builder/pattern_assembler.js index fa6a6372c..49f99ccfd 100644 --- a/builder/pattern_assembler.js +++ b/builder/pattern_assembler.js @@ -44,7 +44,22 @@ function addPattern(pattern, patternlab){ patternlab.data.link[pattern.patternGroup + '-' + pattern.patternName] = '/patterns/' + pattern.patternLink; - patternlab.patterns.push(pattern); + + //only push to array if the array doesn't contain this pattern + var isNew = true; + for(var i = 0; i < patternlab.patterns.length; i++){ + //so we need the identifier to be unique, which patterns[i].abspath is + if(pattern.abspath === patternlab.patterns[i].abspath){ + //if abspath already exists, overwrite that element + patternlab.patterns[i] = pattern; + isNew = false; + break; + } + } + //if the pattern is new, just push to the array + if(isNew){ + patternlab.patterns.push(pattern); + } } function renderPattern(template, data, partials) { @@ -58,13 +73,12 @@ } } - function processPatternFile(file, patternlab){ + function processPatternIterative(file, patternlab){ var fs = require('fs-extra'), of = require('./object_factory'), path = require('path'); //extract some information - var abspath = file.substring(2); var subdir = path.dirname(path.relative(patternlab.config.patterns.source, file)).replace('\\', '/'); var filename = path.basename(file); @@ -74,7 +88,7 @@ } //make a new Pattern Object - var currentPattern = new of.oPattern(subdir, filename); + var currentPattern = new of.oPattern(file, subdir, filename); //see if this file has a state setState(currentPattern, patternlab); @@ -98,13 +112,13 @@ } //add the raw template to memory - currentPattern.template = fs.readFileSync(abspath, 'utf8'); + currentPattern.template = fs.readFileSync(file, 'utf8'); - //our helper function that does a lot of heavy lifting - processPattern(currentPattern, patternlab); + //add currentPattern to patternlab.patterns array + addPattern(currentPattern, patternlab); } - function processPattern(currentPattern, patternlab, additionalData){ + function processPatternRecursive(file, patternlab, additionalData){ var fs = require('fs-extra'), mustache = require('mustache'), @@ -119,6 +133,18 @@ list_item_hunter = new lih(), pseudopattern_hunter = new pph(); + var currentPattern, i; + for(i = 0; i < patternlab.patterns.length; i++){ + if(patternlab.patterns[i].abspath === file){ + currentPattern = patternlab.patterns[i]; + } + } + + //return if processing a .json file + if(typeof currentPattern === 'undefined'){ + return; + } + currentPattern.extendedTemplate = currentPattern.template; //find how many partials there may be for the given pattern @@ -137,8 +163,24 @@ parameter_hunter.find_parameters(currentPattern, patternlab); //do something with the regular old partials - for(var i = 0; i < foundPatternPartials.length; i++){ + for(i = 0; i < foundPatternPartials.length; i++){ var partialKey = foundPatternPartials[i].replace(/{{>([ ])?([\w\-\.\/~]+)(?:\:[A-Za-z0-9-]+)?(?:(| )\(.*)?([ ])?}}/g, '$2'); + var partialPath; + + //identify which pattern this partial corresponds to + for(var j = 0; j < patternlab.patterns.length; j++){ + if(patternlab.patterns[j].key === partialKey || + patternlab.patterns[j].abspath === 'source/_patterns/' + partialKey || + patternlab.patterns[j].abspath === 'source/_patterns/' + partialKey + '.mustache') + { + partialPath = patternlab.patterns[j].abspath; + } + } + + //recurse through nested partials to fill out this extended template. + processPatternRecursive(partialPath, patternlab); + + //complete assembly of extended template var partialPattern = getpatternbykey(partialKey, patternlab); currentPattern.extendedTemplate = currentPattern.extendedTemplate.replace(foundPatternPartials[i], partialPattern.extendedTemplate); } @@ -248,11 +290,11 @@ renderPattern: function(template, data, partials){ return renderPattern(template, data, partials); }, - process_pattern_file: function(file, patternlab){ - processPatternFile(file, patternlab); + process_pattern_iterative: function(file, patternlab){ + processPatternIterative(file, patternlab); }, - process_pattern: function(pattern, patternlab, additionalData){ - processPattern(pattern, patternlab, additionalData); + process_pattern_recursive: function(file, patternlab, additionalData){ + processPatternRecursive(file, patternlab, additionalData); }, get_pattern_by_key: function(key, patternlab){ return getpatternbykey(key, patternlab); diff --git a/builder/patternlab.js b/builder/patternlab.js index 80f8d75f4..b2dac3001 100644 --- a/builder/patternlab.js +++ b/builder/patternlab.js @@ -87,7 +87,27 @@ var patternlab_engine = function () { return; } - pattern_assembler.process_pattern_file(file, patternlab); + pattern_assembler.process_pattern_iterative(file.substring(2), patternlab); + }); + + diveSync(patterns_dir, { + filter: function(path, dir) { + if(dir){ + var remainingPath = path.replace(patterns_dir, ''); + var isValidPath = remainingPath.indexOf('/_') === -1; + return isValidPath; + } + return true; + } + }, + function(err, file){ + //log any errors + if(err){ + console.log(err); + return; + } + + pattern_assembler.process_pattern_recursive(file.substring(2), patternlab); }); //delete the contents of config.patterns.public before writing diff --git a/builder/pseudopattern_hunter.js b/builder/pseudopattern_hunter.js index 2ec038bb6..fca14b57c 100644 --- a/builder/pseudopattern_hunter.js +++ b/builder/pseudopattern_hunter.js @@ -48,7 +48,9 @@ variantFileData = pattern_assembler.merge_data(currentPattern.jsonFileData, variantFileData); var variantName = pseudoPatterns[i].substring(pseudoPatterns[i].indexOf('~') + 1).split('.')[0]; - var patternVariant = new of.oPattern(currentPattern.subdir, currentPattern.fileName + '-' + variantName + '.mustache', variantFileData); + var variantFilePath = 'source/_patterns/' + currentPattern.subdir + '/' + currentPattern.fileName + '-' + variantName + '.mustache'; + var variantFileName = currentPattern.fileName + '-' + variantName + '.mustache'; + var patternVariant = new of.oPattern(variantFilePath, currentPattern.subdir, variantFileName, variantFileData); //see if this file has a state pattern_assembler.setPatternState(patternVariant, patternlab); From b9ee540c29af7665c385a5870144d9d04700985a Mon Sep 17 00:00:00 2001 From: e2tha-e Date: Fri, 2 Oct 2015 11:41:20 -0400 Subject: [PATCH 13/27] unit test --- Gruntfile.js | 2 +- builder/pattern_assembler.js | 1 + builder/patternlab.js | 3 ++ builder/patternlab_gulp.js | 26 ---------- test/object_factory_tests.js | 5 +- test/pattern_assembler_tests.js | 90 ++++++++++++++++++++++++++++++++- 6 files changed, 96 insertions(+), 31 deletions(-) delete mode 100644 builder/patternlab_gulp.js diff --git a/Gruntfile.js b/Gruntfile.js index c8f9e603f..aaa17f653 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -132,7 +132,7 @@ module.exports = function(grunt) { require('matchdep').filterDev('grunt-*').forEach(grunt.loadNpmTasks); //load the patternlab task - grunt.task.loadTasks('./builder/'); + grunt.task.loadTasks('./builder'); //if you choose to use scss, or any preprocessor, you can add it here grunt.registerTask('default', ['patternlab', /*'sass',*/ 'copy:main']); diff --git a/builder/pattern_assembler.js b/builder/pattern_assembler.js index 49f99ccfd..c5c702861 100644 --- a/builder/pattern_assembler.js +++ b/builder/pattern_assembler.js @@ -133,6 +133,7 @@ list_item_hunter = new lih(), pseudopattern_hunter = new pph(); + //find current pattern in patternlab object using var file as a key var currentPattern, i; for(i = 0; i < patternlab.patterns.length; i++){ if(patternlab.patterns[i].abspath === file){ diff --git a/builder/patternlab.js b/builder/patternlab.js index b2dac3001..fd1656dd3 100644 --- a/builder/patternlab.js +++ b/builder/patternlab.js @@ -70,6 +70,7 @@ var patternlab_engine = function () { pattern_assembler.combine_listItems(patternlab); + //diveSync once to perform iterative populating of patternlab object diveSync(patterns_dir, { filter: function(path, dir) { if(dir){ @@ -90,6 +91,8 @@ var patternlab_engine = function () { pattern_assembler.process_pattern_iterative(file.substring(2), patternlab); }); + //diveSync again to recursively include partials, filling out the + //extendedTemplate property of the patternlab.patterns elements diveSync(patterns_dir, { filter: function(path, dir) { if(dir){ diff --git a/builder/patternlab_gulp.js b/builder/patternlab_gulp.js deleted file mode 100644 index 5cbeb2440..000000000 --- a/builder/patternlab_gulp.js +++ /dev/null @@ -1,26 +0,0 @@ -var patternlab_engine = require('./patternlab.js'); - -module.exports = function(gulp) { - - gulp.task('patternlab', ['clean'], function(cb){ - var patternlab = patternlab_engine(); - patternlab.build(false); - cb(); - }); - - gulp.task('patternlab:version', function(){ - var patternlab = patternlab_engine(); - patternlab.version(); - }) - - gulp.task('patternlab:only_patterns', ['clean'], function(){ - var patternlab = patternlab_engine(); - patternlab.build_patterns_only(false); - }) - - gulp.task('patternlab:help', function(){ - var patternlab = patternlab_engine(); - patternlab.help(); - }) - -} diff --git a/test/object_factory_tests.js b/test/object_factory_tests.js index 63ca0cc7f..d5800318a 100644 --- a/test/object_factory_tests.js +++ b/test/object_factory_tests.js @@ -5,8 +5,9 @@ exports['oPattern initialization'] = { 'test oPattern initializes correctly' : function(test){ - var p = new of.oPattern('00-atoms/00-global', '00-colors.mustache', { d: 123}); + var p = new of.oPattern('source/_patterns/00-atoms/00-global/00-colors.mustache', '00-atoms/00-global', '00-colors.mustache', { d: 123}); test.equals(p.name, '00-atoms-00-global-00-colors'); + test.equals(p.abspath, 'source/_patterns/00-atoms/00-global/00-colors.mustache'); test.equals(p.subdir, '00-atoms/00-global'); test.equals(p.fileName, '00-colors'); test.equals(p.jsonFileData.d, 123); @@ -59,4 +60,4 @@ } }; -}()); \ No newline at end of file +}()); diff --git a/test/pattern_assembler_tests.js b/test/pattern_assembler_tests.js index 6ea9199c8..ca0aae5e7 100644 --- a/test/pattern_assembler_tests.js +++ b/test/pattern_assembler_tests.js @@ -36,8 +36,94 @@ test.equals(results[1], '{{> 01-molecules/06-components/02-single-comment(description: \'A life is like a garden. Perfect moments can be had, but not preserved, except in memory.\') }}'); test.done(); - } + }, - }; + 'process_pattern_recursive recursively includes partials' : function(test){ + + //tests inclusion of partial that will be discovered by diveSync later in iteration than parent + //prepare to diveSync + var diveSync = require('diveSync'); + var fs = require('fs-extra'); + var pa = require('../builder/pattern_assembler'); + var pattern_assembler = new pa(); + var patternlab = {}; + patternlab.config = fs.readJSONSync('./config.json'); + patternlab.data = fs.readJSONSync('./source/_data/data.json'); + patternlab.listitems = fs.readJSONSync('./source/_data/listitems.json'); + patternlab.header = fs.readFileSync('./source/_patternlab-files/pattern-header-footer/header.html', 'utf8'); + patternlab.footer = fs.readFileSync('./source/_patternlab-files/pattern-header-footer/footer.html', 'utf8'); + patternlab.patterns = []; + patternlab.data.link = {}; + patternlab.partials = {}; + var patterns_dir = './source/_patterns'; + + //create test partials + fs.writeFileSync(patterns_dir + '/02-organisms/00-global/02-foo.mustache', '{{> organisms-bar }}'); + fs.writeFileSync(patterns_dir + '/02-organisms/00-global/03-bar.mustache', 'bar'); + + //diveSync once to perform iterative populating of patternlab object + diveSync(patterns_dir, + { + filter: function(path, dir){ + if(dir){ + var remainingPath = path.replace(patterns_dir, ''); + var isValidPath = remainingPath.indexOf('/_') === -1; + return isValidPath; + } + return true; + } + }, + function(err, file){ + //log any errors + if(err){ + console.log(err); + return; + } + + pattern_assembler.process_pattern_iterative(file.substring(2), patternlab); + } + ); + //diveSync again to recursively include partials, filling out the + //extendedTemplate property of the patternlab.patterns elements + diveSync(patterns_dir, + { + filter: function(path, dir){ + if(dir){ + var remainingPath = path.replace(patterns_dir, ''); + var isValidPath = remainingPath.indexOf('/_') === -1; + return isValidPath; + } + return true; + } + }, + function(err, file){ + //log any errors + if(err){ + console.log(err); + return; + } + + pattern_assembler.process_pattern_recursive(file.substring(2), patternlab); + } + ); + + //find test pattern + var foo; + for(var i = 0; i < patternlab.patterns.length; i++){ + if(patternlab.patterns[i].fileName === '02-foo'){ + foo = patternlab.patterns[i].extendedTemplate; + break; + } + } + + fs.unlinkSync(patterns_dir + '/02-organisms/00-global/02-foo.mustache'); + fs.unlinkSync(patterns_dir + '/02-organisms/00-global/03-bar.mustache'); + + //test that 02-foo.mustache included partial 03-bar.mustache + test.equals(foo, 'bar'); + + test.done(); + } + }; }()); From d30d0c75536c488610bbbc595cd65758a27980f0 Mon Sep 17 00:00:00 2001 From: e2tha-e Date: Fri, 2 Oct 2015 11:41:26 -0400 Subject: [PATCH 14/27] unit test --- test/pattern_assembler_tests.js | 1 + 1 file changed, 1 insertion(+) diff --git a/test/pattern_assembler_tests.js b/test/pattern_assembler_tests.js index ca0aae5e7..4314160ed 100644 --- a/test/pattern_assembler_tests.js +++ b/test/pattern_assembler_tests.js @@ -117,6 +117,7 @@ } } + //delete test files fs.unlinkSync(patterns_dir + '/02-organisms/00-global/02-foo.mustache'); fs.unlinkSync(patterns_dir + '/02-organisms/00-global/03-bar.mustache'); From c3c279c4bb9756627d584d705cdae2745c37a133 Mon Sep 17 00:00:00 2001 From: e2tha-e Date: Fri, 2 Oct 2015 11:47:53 -0400 Subject: [PATCH 15/27] reinstating builder/patternlab_gulp.js --- Gruntfile.js | 2 +- builder/patternlab_gulp.js | 26 ++++++++++++++++++++++++++ 2 files changed, 27 insertions(+), 1 deletion(-) create mode 100644 builder/patternlab_gulp.js diff --git a/Gruntfile.js b/Gruntfile.js index aaa17f653..c8f9e603f 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -132,7 +132,7 @@ module.exports = function(grunt) { require('matchdep').filterDev('grunt-*').forEach(grunt.loadNpmTasks); //load the patternlab task - grunt.task.loadTasks('./builder'); + grunt.task.loadTasks('./builder/'); //if you choose to use scss, or any preprocessor, you can add it here grunt.registerTask('default', ['patternlab', /*'sass',*/ 'copy:main']); diff --git a/builder/patternlab_gulp.js b/builder/patternlab_gulp.js new file mode 100644 index 000000000..5cbeb2440 --- /dev/null +++ b/builder/patternlab_gulp.js @@ -0,0 +1,26 @@ +var patternlab_engine = require('./patternlab.js'); + +module.exports = function(gulp) { + + gulp.task('patternlab', ['clean'], function(cb){ + var patternlab = patternlab_engine(); + patternlab.build(false); + cb(); + }); + + gulp.task('patternlab:version', function(){ + var patternlab = patternlab_engine(); + patternlab.version(); + }) + + gulp.task('patternlab:only_patterns', ['clean'], function(){ + var patternlab = patternlab_engine(); + patternlab.build_patterns_only(false); + }) + + gulp.task('patternlab:help', function(){ + var patternlab = patternlab_engine(); + patternlab.help(); + }) + +} From 9441cecd513d80f4f8d398a7202e285d4ebfd8b0 Mon Sep 17 00:00:00 2001 From: e2tha-e Date: Fri, 2 Oct 2015 19:49:52 -0400 Subject: [PATCH 16/27] better ordering of pattern variants --- builder/pattern_assembler.js | 15 +++++++++++++-- builder/pseudopattern_hunter.js | 4 ++-- 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/builder/pattern_assembler.js b/builder/pattern_assembler.js index c5c702861..4dc6ba34c 100644 --- a/builder/pattern_assembler.js +++ b/builder/pattern_assembler.js @@ -81,15 +81,26 @@ //extract some information var subdir = path.dirname(path.relative(patternlab.config.patterns.source, file)).replace('\\', '/'); var filename = path.basename(file); + var ext = path.extname(filename); - //ignore _underscored patterns, json (for now), and dotfiles - if(filename.charAt(0) === '_' || path.extname(filename) === '.json' || filename.charAt(0) === '.'){ + //ignore _underscored patterns, dotfiles, and non-variant .json files + if(filename.charAt(0) === '_' || filename.charAt(0) === '.' || (ext === '.json' && filename.indexOf('~') === -1)){ return; } //make a new Pattern Object var currentPattern = new of.oPattern(file, subdir, filename); + //if file is named in the syntax for variants + if(ext === '.json' && filename.indexOf('~') > -1){ + //add current pattern to patternlab object with minimal data + //processPatternRecursive() will run find_pseudopatterns() to fill out + //the object in the next diveSync + addPattern(currentPattern, patternlab); + //no need to process further + return; + } + //see if this file has a state setState(currentPattern, patternlab); diff --git a/builder/pseudopattern_hunter.js b/builder/pseudopattern_hunter.js index fca14b57c..8d72ca1da 100644 --- a/builder/pseudopattern_hunter.js +++ b/builder/pseudopattern_hunter.js @@ -48,8 +48,8 @@ variantFileData = pattern_assembler.merge_data(currentPattern.jsonFileData, variantFileData); var variantName = pseudoPatterns[i].substring(pseudoPatterns[i].indexOf('~') + 1).split('.')[0]; - var variantFilePath = 'source/_patterns/' + currentPattern.subdir + '/' + currentPattern.fileName + '-' + variantName + '.mustache'; - var variantFileName = currentPattern.fileName + '-' + variantName + '.mustache'; + var variantFilePath = 'source/_patterns/' + currentPattern.subdir + '/' + currentPattern.fileName + '~' + variantName + '.json'; + var variantFileName = currentPattern.fileName + '-' + variantName + '.'; var patternVariant = new of.oPattern(variantFilePath, currentPattern.subdir, variantFileName, variantFileData); //see if this file has a state From 9e1fc5dfaff5b5dfd8ac9950f22cfc672109aafb Mon Sep 17 00:00:00 2001 From: e2tha-e Date: Fri, 2 Oct 2015 19:58:25 -0400 Subject: [PATCH 17/27] better ordering of pattern variants --- builder/pattern_assembler.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/builder/pattern_assembler.js b/builder/pattern_assembler.js index 4dc6ba34c..2ad940100 100644 --- a/builder/pattern_assembler.js +++ b/builder/pattern_assembler.js @@ -152,7 +152,7 @@ } } - //return if processing a .json file + //return if processing a non-variant .json file if(typeof currentPattern === 'undefined'){ return; } From 34793f54ad997caa0f699afdae7042f8a86afe6c Mon Sep 17 00:00:00 2001 From: e2tha-e Date: Fri, 2 Oct 2015 21:24:17 -0400 Subject: [PATCH 18/27] keeping the data from underscore-prefixed files, but ignoring in nav --- builder/pattern_assembler.js | 10 ++++++---- builder/patternlab.js | 10 ++++++++++ 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/builder/pattern_assembler.js b/builder/pattern_assembler.js index 2ad940100..fcc68ccdb 100644 --- a/builder/pattern_assembler.js +++ b/builder/pattern_assembler.js @@ -83,8 +83,8 @@ var filename = path.basename(file); var ext = path.extname(filename); - //ignore _underscored patterns, dotfiles, and non-variant .json files - if(filename.charAt(0) === '_' || filename.charAt(0) === '.' || (ext === '.json' && filename.indexOf('~') === -1)){ + //ignore dotfiles and non-variant .json files + if(filename.charAt(0) === '.' || (ext === '.json' && filename.indexOf('~') === -1)){ return; } @@ -145,14 +145,16 @@ pseudopattern_hunter = new pph(); //find current pattern in patternlab object using var file as a key - var currentPattern, i; + var currentPattern, + i; + for(i = 0; i < patternlab.patterns.length; i++){ if(patternlab.patterns[i].abspath === file){ currentPattern = patternlab.patterns[i]; } } - //return if processing a non-variant .json file + //return if processing an ignored file if(typeof currentPattern === 'undefined'){ return; } diff --git a/builder/patternlab.js b/builder/patternlab.js index fd1656dd3..6525f0390 100644 --- a/builder/patternlab.js +++ b/builder/patternlab.js @@ -165,6 +165,11 @@ var patternlab_engine = function () { i; for (i = 0; i < patternlab.patterns.length; i++) { + // skip underscore-prefixed files + if (path.basename(patternlab.patterns[i].abspath).charAt(0) === '_') { + continue; + } + var pattern = patternlab.patterns[i]; // check if the current sub section is different from the previous one @@ -193,6 +198,11 @@ var patternlab_engine = function () { //loop through all patterns.to build the navigation //todo: refactor this someday for(var i = 0; i < patternlab.patterns.length; i++){ + // skip underscore-prefixed files + if (path.basename(patternlab.patterns[i].abspath).charAt(0) === '_') { + continue; + } + var pattern = patternlab.patterns[i]; var bucketName = pattern.name.replace(/\\/g, '-').split('-')[1]; From 0109d6e41a9e7a95038fe7be37326ff1800ad2eb Mon Sep 17 00:00:00 2001 From: e2tha-e Date: Fri, 2 Oct 2015 21:56:35 -0400 Subject: [PATCH 19/27] better rendering of navigation subdirs --- builder/object_factory.js | 2 +- builder/patternlab.js | 5 ++++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/builder/object_factory.js b/builder/object_factory.js index 23333bac2..4b6f8c30c 100644 --- a/builder/object_factory.js +++ b/builder/object_factory.js @@ -17,7 +17,7 @@ this.subdir = subdir; this.name = subdir.replace(/[\/\\]/g, '-') + '-' + this.fileName; //this is the unique name with the subDir this.jsonFileData = data || {}; - this.patternName = this.fileName.substring(this.fileName.indexOf('-') + 1); //this is the display name for the ui + this.patternName = this.fileName.replace(/^\d*\-/, ''); //this is the display name for the ui. strip numeric + hyphen prefixes this.patternLink = this.name + '/' + this.name + '.html'; this.patternGroup = this.name.substring(this.name.indexOf('-') + 1, this.name.indexOf('-', 4) + 1 - this.name.indexOf('-') + 1); this.patternSubGroup = subdir.substring(subdir.indexOf('/') + 4); diff --git a/builder/patternlab.js b/builder/patternlab.js index 6525f0390..ccd15b024 100644 --- a/builder/patternlab.js +++ b/builder/patternlab.js @@ -272,7 +272,10 @@ var patternlab_engine = function () { var bucket = patternlab.buckets[bucketIndex]; //get the navItem - var navItemName = pattern.subdir.split('-').pop(); + //if there is one or more slashes in the subdir, get everything after + //the last slash. if no slash, get the whole subdir string and strip + //any numeric + hyphen prefix + var navItemName = pattern.subdir.split('/').pop().replace(/^\d*\-/, ''); //get the navSubItem var navSubItemName = pattern.patternName.replace(/-/g, ' '); From e18a80dc8cb490ae7e9a592a5f315ce73bc286ca Mon Sep 17 00:00:00 2001 From: e2tha-e Date: Sat, 3 Oct 2015 08:55:51 -0400 Subject: [PATCH 20/27] refined test --- builder/pattern_assembler.js | 3 +- test/files/_patterns/00-test/00-foo.mustache | 1 + test/files/_patterns/00-test/01-bar.mustache | 1 + test/pattern_assembler_tests.js | 30 ++++++++++---------- 4 files changed, 18 insertions(+), 17 deletions(-) create mode 100644 test/files/_patterns/00-test/00-foo.mustache create mode 100644 test/files/_patterns/00-test/01-bar.mustache diff --git a/builder/pattern_assembler.js b/builder/pattern_assembler.js index fcc68ccdb..eb45be090 100644 --- a/builder/pattern_assembler.js +++ b/builder/pattern_assembler.js @@ -184,8 +184,7 @@ //identify which pattern this partial corresponds to for(var j = 0; j < patternlab.patterns.length; j++){ if(patternlab.patterns[j].key === partialKey || - patternlab.patterns[j].abspath === 'source/_patterns/' + partialKey || - patternlab.patterns[j].abspath === 'source/_patterns/' + partialKey + '.mustache') + patternlab.patterns[j].abspath.indexOf(partialKey) > -1) { partialPath = patternlab.patterns[j].abspath; } diff --git a/test/files/_patterns/00-test/00-foo.mustache b/test/files/_patterns/00-test/00-foo.mustache new file mode 100644 index 000000000..1397f5207 --- /dev/null +++ b/test/files/_patterns/00-test/00-foo.mustache @@ -0,0 +1 @@ +{{> test-bar }} diff --git a/test/files/_patterns/00-test/01-bar.mustache b/test/files/_patterns/00-test/01-bar.mustache new file mode 100644 index 000000000..5716ca598 --- /dev/null +++ b/test/files/_patterns/00-test/01-bar.mustache @@ -0,0 +1 @@ +bar diff --git a/test/pattern_assembler_tests.js b/test/pattern_assembler_tests.js index 4314160ed..16b9bde5a 100644 --- a/test/pattern_assembler_tests.js +++ b/test/pattern_assembler_tests.js @@ -46,8 +46,10 @@ var fs = require('fs-extra'); var pa = require('../builder/pattern_assembler'); var pattern_assembler = new pa(); + var patterns_dir = './test/files/_patterns'; var patternlab = {}; patternlab.config = fs.readJSONSync('./config.json'); + patternlab.config.patterns = {source: patterns_dir}; patternlab.data = fs.readJSONSync('./source/_data/data.json'); patternlab.listitems = fs.readJSONSync('./source/_data/listitems.json'); patternlab.header = fs.readFileSync('./source/_patternlab-files/pattern-header-footer/header.html', 'utf8'); @@ -55,11 +57,6 @@ patternlab.patterns = []; patternlab.data.link = {}; patternlab.partials = {}; - var patterns_dir = './source/_patterns'; - - //create test partials - fs.writeFileSync(patterns_dir + '/02-organisms/00-global/02-foo.mustache', '{{> organisms-bar }}'); - fs.writeFileSync(patterns_dir + '/02-organisms/00-global/03-bar.mustache', 'bar'); //diveSync once to perform iterative populating of patternlab object diveSync(patterns_dir, @@ -108,21 +105,24 @@ } ); - //find test pattern - var foo; + //get test output for comparison + var foo = fs.readFileSync(patterns_dir + '/00-test/00-foo.mustache', 'utf8').trim(); + var bar = fs.readFileSync(patterns_dir + '/00-test/01-bar.mustache', 'utf8').trim(); + var fooExtended; + + //get extended pattern for(var i = 0; i < patternlab.patterns.length; i++){ - if(patternlab.patterns[i].fileName === '02-foo'){ - foo = patternlab.patterns[i].extendedTemplate; + if(patternlab.patterns[i].fileName === '00-foo'){ + fooExtended = patternlab.patterns[i].extendedTemplate.trim(); break; } } - //delete test files - fs.unlinkSync(patterns_dir + '/02-organisms/00-global/02-foo.mustache'); - fs.unlinkSync(patterns_dir + '/02-organisms/00-global/03-bar.mustache'); - - //test that 02-foo.mustache included partial 03-bar.mustache - test.equals(foo, 'bar'); + //check initial values + test.equals(foo, '{{> test-bar }}'); + test.equals(bar, 'bar'); + //test that 00-foo.mustache included partial 01-bar.mustache + test.equals(fooExtended, 'bar'); test.done(); } From 0d1082c39489241d58b3ef5611bb436439cdde33 Mon Sep 17 00:00:00 2001 From: e2tha-e Date: Mon, 5 Oct 2015 09:41:50 -0400 Subject: [PATCH 21/27] restricting pattern assembly to correct file types --- builder/pattern_assembler.js | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/builder/pattern_assembler.js b/builder/pattern_assembler.js index eb45be090..da1f02c37 100644 --- a/builder/pattern_assembler.js +++ b/builder/pattern_assembler.js @@ -101,6 +101,11 @@ return; } + //can ignore all non-mustache files at this point + if(ext !== '.mustache'){ + return; + } + //see if this file has a state setState(currentPattern, patternlab); From 9487917d15cfc81a3203f784830efc624dc012a0 Mon Sep 17 00:00:00 2001 From: BRIAN MUENZENMEYER Date: Mon, 5 Oct 2015 22:19:44 -0500 Subject: [PATCH 22/27] in process stylemodifier work --- builder/pattern_assembler.js | 42 +++++++++++++++---- config.json | 2 +- .../06-components/02-single-comment.mustache | 4 +- .../02-comments/01-sticky-comment.mustache | 2 +- 4 files changed, 37 insertions(+), 13 deletions(-) diff --git a/builder/pattern_assembler.js b/builder/pattern_assembler.js index fa6a6372c..862b6275e 100644 --- a/builder/pattern_assembler.js +++ b/builder/pattern_assembler.js @@ -1,10 +1,10 @@ -/* - * patternlab-node - v0.12.0 - 2015 - * +/* + * patternlab-node - v0.12.0 - 2015 + * * Brian Muenzenmeyer, and the web community. - * Licensed under the MIT license. - * - * Many thanks to Brad Frost and Dave Olsen for inspiration, encouragement, and advice. + * Licensed under the MIT license. + * + * Many thanks to Brad Frost and Dave Olsen for inspiration, encouragement, and advice. * */ @@ -22,7 +22,6 @@ return true; } - //find and return any {{> template-name }} within pattern function findPartials(pattern){ var matches = pattern.template.match(/{{>([ ])?([\w\-\.\/~]+)(?:\:[A-Za-z0-9-]+)?(?:(| )\(.*)?([ ])?}}/g); @@ -42,6 +41,26 @@ } } + function applyStyleModifications(pattern, patternlab){ + //look for styleModifiers within the pattern template + var matches = pattern.template.match(/(:)([a-zA-Z]*)/g); + + //parse matches if they look like modifiers + if(matches){ + console.log(matches); + + for(var i = 0; i < matches.length; i++){ + if(matches[i].length > 1){ + console.log(matches[i]); + } + } + } + + //add to pattern data + + //remove from the template + } + function addPattern(pattern, patternlab){ patternlab.data.link[pattern.patternGroup + '-' + pattern.patternName] = '/patterns/' + pattern.patternLink; patternlab.patterns.push(pattern); @@ -92,10 +111,12 @@ try { var listJsonFileName = patternlab.config.patterns.source + currentPattern.subdir + '/' + currentPattern.fileName + ".listitems.json"; currentPattern.patternSpecificListJson = fs.readJSONSync(listJsonFileName.substring(2)); - console.log('found pattern-specific listitems.json for ' + currentPattern.key); + if(patternlab.confi.debug){ + console.log('found pattern-specific listitems.json for ' + currentPattern.key); + } } catch(e) { - } + } //add the raw template to memory currentPattern.template = fs.readFileSync(abspath, 'utf8'); @@ -145,6 +166,9 @@ } + //look for pattern styleModifiers + applyStyleModifications(currentPattern, patternlab); + //find pattern lineage lineage_hunter.find_lineage(currentPattern, patternlab); diff --git a/config.json b/config.json index ff787019b..798df20c7 100644 --- a/config.json +++ b/config.json @@ -5,7 +5,7 @@ }, "ignored-extensions" : ["scss", "DS_Store", "less"], "ignored-directories" : ["scss"], - "debug": false, + "debug": true, "ishControlsVisible": { "s": true, "m": true, diff --git a/source/_patterns/01-molecules/06-components/02-single-comment.mustache b/source/_patterns/01-molecules/06-components/02-single-comment.mustache index a7f56279a..c70b6eef9 100644 --- a/source/_patterns/01-molecules/06-components/02-single-comment.mustache +++ b/source/_patterns/01-molecules/06-components/02-single-comment.mustache @@ -1,4 +1,4 @@ -
  • +
  • {{> atoms-avatar }}

    {{name.first}} {{name.last}}

    @@ -6,4 +6,4 @@

    {{description}}

    -
  • \ No newline at end of file + diff --git a/source/_patterns/02-organisms/02-comments/01-sticky-comment.mustache b/source/_patterns/02-organisms/02-comments/01-sticky-comment.mustache index ac0b28dc4..4cca83c5b 100644 --- a/source/_patterns/02-organisms/02-comments/01-sticky-comment.mustache +++ b/source/_patterns/02-organisms/02-comments/01-sticky-comment.mustache @@ -2,7 +2,7 @@

    Selected Comments

      - {{> molecules-single-comment(description: 'We are all in the gutter, but some of us are looking at the stars.') }} + {{> molecules-single-comment:sticky(description: 'We are all in the gutter, but some of us are looking at the stars.') }} {{> molecules-single-comment(description: 'A life is like a garden. Perfect moments can be had, but not preserved, except in memory.') }}
    From 6fc72a27734926ef903740f72a144fdcf949e4fa Mon Sep 17 00:00:00 2001 From: BRIAN MUENZENMEYER Date: Mon, 5 Oct 2015 22:20:10 -0500 Subject: [PATCH 23/27] Revert "in process stylemodifier work" This reverts commit 9487917d15cfc81a3203f784830efc624dc012a0. --- builder/pattern_assembler.js | 42 ++++--------------- config.json | 2 +- .../06-components/02-single-comment.mustache | 4 +- .../02-comments/01-sticky-comment.mustache | 2 +- 4 files changed, 13 insertions(+), 37 deletions(-) diff --git a/builder/pattern_assembler.js b/builder/pattern_assembler.js index 862b6275e..fa6a6372c 100644 --- a/builder/pattern_assembler.js +++ b/builder/pattern_assembler.js @@ -1,10 +1,10 @@ -/* - * patternlab-node - v0.12.0 - 2015 - * +/* + * patternlab-node - v0.12.0 - 2015 + * * Brian Muenzenmeyer, and the web community. - * Licensed under the MIT license. - * - * Many thanks to Brad Frost and Dave Olsen for inspiration, encouragement, and advice. + * Licensed under the MIT license. + * + * Many thanks to Brad Frost and Dave Olsen for inspiration, encouragement, and advice. * */ @@ -22,6 +22,7 @@ return true; } + //find and return any {{> template-name }} within pattern function findPartials(pattern){ var matches = pattern.template.match(/{{>([ ])?([\w\-\.\/~]+)(?:\:[A-Za-z0-9-]+)?(?:(| )\(.*)?([ ])?}}/g); @@ -41,26 +42,6 @@ } } - function applyStyleModifications(pattern, patternlab){ - //look for styleModifiers within the pattern template - var matches = pattern.template.match(/(:)([a-zA-Z]*)/g); - - //parse matches if they look like modifiers - if(matches){ - console.log(matches); - - for(var i = 0; i < matches.length; i++){ - if(matches[i].length > 1){ - console.log(matches[i]); - } - } - } - - //add to pattern data - - //remove from the template - } - function addPattern(pattern, patternlab){ patternlab.data.link[pattern.patternGroup + '-' + pattern.patternName] = '/patterns/' + pattern.patternLink; patternlab.patterns.push(pattern); @@ -111,12 +92,10 @@ try { var listJsonFileName = patternlab.config.patterns.source + currentPattern.subdir + '/' + currentPattern.fileName + ".listitems.json"; currentPattern.patternSpecificListJson = fs.readJSONSync(listJsonFileName.substring(2)); - if(patternlab.confi.debug){ - console.log('found pattern-specific listitems.json for ' + currentPattern.key); - } + console.log('found pattern-specific listitems.json for ' + currentPattern.key); } catch(e) { - } + } //add the raw template to memory currentPattern.template = fs.readFileSync(abspath, 'utf8'); @@ -166,9 +145,6 @@ } - //look for pattern styleModifiers - applyStyleModifications(currentPattern, patternlab); - //find pattern lineage lineage_hunter.find_lineage(currentPattern, patternlab); diff --git a/config.json b/config.json index 798df20c7..ff787019b 100644 --- a/config.json +++ b/config.json @@ -5,7 +5,7 @@ }, "ignored-extensions" : ["scss", "DS_Store", "less"], "ignored-directories" : ["scss"], - "debug": true, + "debug": false, "ishControlsVisible": { "s": true, "m": true, diff --git a/source/_patterns/01-molecules/06-components/02-single-comment.mustache b/source/_patterns/01-molecules/06-components/02-single-comment.mustache index c70b6eef9..a7f56279a 100644 --- a/source/_patterns/01-molecules/06-components/02-single-comment.mustache +++ b/source/_patterns/01-molecules/06-components/02-single-comment.mustache @@ -1,4 +1,4 @@ -
  • +
  • {{> atoms-avatar }}

    {{name.first}} {{name.last}}

    @@ -6,4 +6,4 @@

    {{description}}

    -
  • + \ No newline at end of file diff --git a/source/_patterns/02-organisms/02-comments/01-sticky-comment.mustache b/source/_patterns/02-organisms/02-comments/01-sticky-comment.mustache index 4cca83c5b..ac0b28dc4 100644 --- a/source/_patterns/02-organisms/02-comments/01-sticky-comment.mustache +++ b/source/_patterns/02-organisms/02-comments/01-sticky-comment.mustache @@ -2,7 +2,7 @@

    Selected Comments

      - {{> molecules-single-comment:sticky(description: 'We are all in the gutter, but some of us are looking at the stars.') }} + {{> molecules-single-comment(description: 'We are all in the gutter, but some of us are looking at the stars.') }} {{> molecules-single-comment(description: 'A life is like a garden. Perfect moments can be had, but not preserved, except in memory.') }}
    From 0c8a5305e403c82d17dc51844f406427df1b162f Mon Sep 17 00:00:00 2001 From: BRIAN MUENZENMEYER Date: Mon, 5 Oct 2015 22:59:13 -0500 Subject: [PATCH 24/27] Changelog for recursive pattern inclusion. Closes #156 --- CHANGELOG | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CHANGELOG b/CHANGELOG index 19004fcb2..54ca1f992 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -6,6 +6,8 @@ PL-node-v0.13.0 - THX: Thanks @e2tha-e for the flurry of pull requests! - CHG: Update data merge function to prioritize handle pattern~variant.json files - THX: Thanks @e2tha-e for finding, fixing, and unit testing the data merge issue. +- ADD: Support for recursive partial inclusion +- THX: Thanks @e2tha-e for making pattern inclusion a lot more robust. Great work!!! PL-node-v0.12.0 - ADD: Gulp support arrives with an optional configuration From aa521b9a421db84f328cb1da7147b1889b0d0112 Mon Sep 17 00:00:00 2001 From: BRIAN MUENZENMEYER Date: Tue, 6 Oct 2015 00:28:38 -0500 Subject: [PATCH 25/27] Improvements to menu generation closes #138 closes #160 --- CHANGELOG | 1 + builder/object_factory.js | 29 +++++++++++++------- builder/pattern_assembler.js | 22 +++++++++------ builder/patternlab.js | 3 +- source/_patternlab-files/styleguide.mustache | 14 +++++----- source/_patternlab-files/viewall.mustache | 16 +++++------ test/object_factory_tests.js | 27 +++++++++++++++++- 7 files changed, 76 insertions(+), 36 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index 54ca1f992..1c47bf53e 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -8,6 +8,7 @@ PL-node-v0.13.0 - THX: Thanks @e2tha-e for finding, fixing, and unit testing the data merge issue. - ADD: Support for recursive partial inclusion - THX: Thanks @e2tha-e for making pattern inclusion a lot more robust. Great work!!! +- FIX: Improvements to style guide menu generation and capitalization. PL-node-v0.12.0 - ADD: Gulp support arrives with an optional configuration diff --git a/builder/object_factory.js b/builder/object_factory.js index 4b6f8c30c..39bd6789d 100644 --- a/builder/object_factory.js +++ b/builder/object_factory.js @@ -1,10 +1,10 @@ -/* - * patternlab-node - v0.12.0 - 2015 - * +/* + * patternlab-node - v0.12.0 - 2015 + * * Brian Muenzenmeyer, and the web community. - * Licensed under the MIT license. - * - * Many thanks to Brad Frost and Dave Olsen for inspiration, encouragement, and advice. + * Licensed under the MIT license. + * + * Many thanks to Brad Frost and Dave Olsen for inspiration, encouragement, and advice. * */ @@ -17,7 +17,10 @@ this.subdir = subdir; this.name = subdir.replace(/[\/\\]/g, '-') + '-' + this.fileName; //this is the unique name with the subDir this.jsonFileData = data || {}; - this.patternName = this.fileName.replace(/^\d*\-/, ''); //this is the display name for the ui. strip numeric + hyphen prefixes + this.patternName = this.fileName.replace(/^\d*\-/, ''); + this.patternDisplayName = this.patternName.split('-').reduce(function(val, working){ + return val.charAt(0).toUpperCase() + val.slice(1) + ' ' + working.charAt(0).toUpperCase() + working.slice(1); + }, '').trim(); //this is the display name for the ui. strip numeric + hyphen prefixes this.patternLink = this.name + '/' + this.name + '.html'; this.patternGroup = this.name.substring(this.name.indexOf('-') + 1, this.name.indexOf('-', 4) + 1 - this.name.indexOf('-') + 1); this.patternSubGroup = subdir.substring(subdir.indexOf('/') + 4); @@ -33,7 +36,9 @@ var oBucket = function(name){ this.bucketNameLC = name; - this.bucketNameUC = name.charAt(0).toUpperCase() + name.slice(1); + this.bucketNameUC = name.split('-').reduce(function(val, working){ + return val.charAt(0).toUpperCase() + val.slice(1) + ' ' + working.charAt(0).toUpperCase() + working.slice(1); + }, '').trim(); this.navItems = []; this.navItemsIndex = []; this.patternItems = []; @@ -42,7 +47,9 @@ var oNavItem = function(name){ this.sectionNameLC = name; - this.sectionNameUC = name.charAt(0).toUpperCase() + name.slice(1); + this.sectionNameUC = name.split('-').reduce(function(val, working){ + return val.charAt(0).toUpperCase() + val.slice(1) + ' ' + working.charAt(0).toUpperCase() + working.slice(1); + }, '').trim(); this.navSubItems = []; this.navSubItemsIndex = []; }; @@ -50,7 +57,9 @@ var oNavSubItem = function(name){ this.patternPath = ''; this.patternPartial = ''; - this.patternName = name.charAt(0).toUpperCase() + name.slice(1); + this.patternName = name.split(' ').reduce(function(val, working){ + return val.charAt(0).toUpperCase() + val.slice(1) + ' ' + working.charAt(0).toUpperCase() + working.slice(1); + }, '').trim(); }; module.exports = { diff --git a/builder/pattern_assembler.js b/builder/pattern_assembler.js index da1f02c37..52c3bf50b 100644 --- a/builder/pattern_assembler.js +++ b/builder/pattern_assembler.js @@ -1,10 +1,10 @@ -/* - * patternlab-node - v0.12.0 - 2015 - * +/* + * patternlab-node - v0.12.0 - 2015 + * * Brian Muenzenmeyer, and the web community. - * Licensed under the MIT license. - * - * Many thanks to Brad Frost and Dave Olsen for inspiration, encouragement, and advice. + * Licensed under the MIT license. + * + * Many thanks to Brad Frost and Dave Olsen for inspiration, encouragement, and advice. * */ @@ -113,7 +113,9 @@ try { var jsonFilename = patternlab.config.patterns.source + currentPattern.subdir + '/' + currentPattern.fileName + ".json"; currentPattern.jsonFileData = fs.readJSONSync(jsonFilename.substring(2)); - console.log('found pattern-specific data.json for ' + currentPattern.key); + if(patternlab.config.debug){ + console.log('found pattern-specific data.json for ' + currentPattern.key); + } } catch(e) { } @@ -122,10 +124,12 @@ try { var listJsonFileName = patternlab.config.patterns.source + currentPattern.subdir + '/' + currentPattern.fileName + ".listitems.json"; currentPattern.patternSpecificListJson = fs.readJSONSync(listJsonFileName.substring(2)); - console.log('found pattern-specific listitems.json for ' + currentPattern.key); + if(patternlab.config.debug){ + console.log('found pattern-specific listitems.json for ' + currentPattern.key); + } } catch(e) { - } + } //add the raw template to memory currentPattern.template = fs.readFileSync(file, 'utf8'); diff --git a/builder/patternlab.js b/builder/patternlab.js index ccd15b024..0bed6df81 100644 --- a/builder/patternlab.js +++ b/builder/patternlab.js @@ -217,7 +217,8 @@ var patternlab_engine = function () { patternlab.viewAllPaths[bucketName] = {}; //get the navItem - var navItemName = pattern.subdir.split('-').pop(); + var navItemName = pattern.subdir.split('/').pop(); + navItemName = navItemName.replace(/(\d).(-)/g, ''); //get the navSubItem var navSubItemName = pattern.patternName.replace(/-/g, ' '); diff --git a/source/_patternlab-files/styleguide.mustache b/source/_patternlab-files/styleguide.mustache index e4a9e5479..fe39a3816 100644 --- a/source/_patternlab-files/styleguide.mustache +++ b/source/_patternlab-files/styleguide.mustache @@ -9,21 +9,21 @@ - +
    - +
    {{# partials }}
    -

    {{ patternName }}

    +

    {{ patternDisplayName }}

    {{{ patternPartial }}} - +
    @@ -63,6 +63,6 @@ - + - \ No newline at end of file + diff --git a/source/_patternlab-files/viewall.mustache b/source/_patternlab-files/viewall.mustache index a0c4805be..87b345ae2 100644 --- a/source/_patternlab-files/viewall.mustache +++ b/source/_patternlab-files/viewall.mustache @@ -9,21 +9,21 @@ - +
    - +
    {{# partials }}
    -

    {{ patternName }}

    +

    {{ patternDisplayName }}

    {{{ patternPartial }}} - +
    - + - + - \ No newline at end of file + diff --git a/test/object_factory_tests.js b/test/object_factory_tests.js index d5800318a..6ce2693a1 100644 --- a/test/object_factory_tests.js +++ b/test/object_factory_tests.js @@ -12,6 +12,7 @@ test.equals(p.fileName, '00-colors'); test.equals(p.jsonFileData.d, 123); test.equals(p.patternName, 'colors'); + test.equals(p.patternDisplayName, 'Colors'); test.equals(p.patternLink, '00-atoms-00-global-00-colors/00-atoms-00-global-00-colors.html'); test.equals(p.patternGroup, 'atoms'); test.equals(p.patternSubGroup, 'global'); @@ -24,6 +25,12 @@ test.equals(p.lineageR.length, 0); test.equals(p.lineageRIndex.length, 0); test.done(); + }, + 'test oPattern capitalizes patternDisplayName correctly' : function(test){ + var p = new of.oPattern('source/_patterns/00-atoms/00-global/00-colors-alt.mustache', '00-atoms/00-global', '00-colors-alt.mustache', { d: 123}); + test.equals(p.patternName, 'colors-alt'); + test.equals(p.patternDisplayName, 'Colors Alt'); + test.done(); } }; @@ -37,6 +44,12 @@ test.equals(b.patternItems.length, 0); test.equals(b.patternItemsIndex.length, 0); test.done(); + }, + 'test oBucket capitalizes bucketNameUC' : function(test){ + var b = new of.oBucket('page-templates'); + test.equals(b.bucketNameLC, 'page-templates'); + test.equals(b.bucketNameUC, 'Page Templates'); + test.done(); } }; @@ -44,12 +57,19 @@ 'test oNavItem initializes correctly' : function(test){ var ni = new of.oNavItem('test'); test.equals(ni.sectionNameLC, 'test'); + test.equals(ni.sectionNameUC, 'Test'); test.equals(ni.navSubItems.length, 0); test.equals(ni.navSubItemsIndex.length, 0); test.done(); + }, + 'test oNavItem correctly capitalizes sectionNameUC' : function(test){ + var ni = new of.oNavItem('global-concepts'); + test.equals(ni.sectionNameLC, 'global-concepts'); + test.equals(ni.sectionNameUC, 'Global Concepts'); + test.done(); } }; - + exports['oSubNavItem initialization'] = { 'test oSubNavItem initializes correctly' : function(test){ var sni = new of.oNavSubItem('test'); @@ -57,6 +77,11 @@ test.equals(sni.patternPath, ''); test.equals(sni.patternPartial, ''); test.done(); + }, + 'test oSubNavItem capitalizes patternName' : function(test){ + var sni = new of.oNavSubItem('nav button'); + test.equals(sni.patternName, 'Nav Button'); + test.done(); } }; From a5e163a17dabecb1c97428c44de94d7aa432fbac Mon Sep 17 00:00:00 2001 From: BRIAN MUENZENMEYER Date: Tue, 6 Oct 2015 00:34:35 -0500 Subject: [PATCH 26/27] update node version for travis ci --- .travis.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 274dcc885..0adf4ab2c 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,8 +1,10 @@ language: node_js node_js: + - 4.1 + - 4.0 + - 0.12 - 0.11 - - 0.10 before_install: - phantomjs --version From e6fc96a86b1a95d5b2cbde8a7be3159481bbdeb1 Mon Sep 17 00:00:00 2001 From: BRIAN MUENZENMEYER Date: Tue, 6 Oct 2015 00:39:14 -0500 Subject: [PATCH 27/27] updating version number for deployment --- Gruntfile.js | 4 ++++ builder/lineage_hunter.js | 2 +- builder/list_item_hunter.js | 2 +- builder/media_hunter.js | 2 +- builder/object_factory.js | 12 ++++++------ builder/parameter_hunter.js | 2 +- builder/pattern_assembler.js | 12 ++++++------ builder/pattern_exporter.js | 2 +- builder/patternlab.js | 12 ++++++------ builder/patternlab_grunt.js | 2 +- builder/patternlab_gulp.js | 10 ++++++++++ builder/pseudopattern_hunter.js | 2 +- gulpfile.js | 1 + 13 files changed, 40 insertions(+), 25 deletions(-) diff --git a/Gruntfile.js b/Gruntfile.js index c8f9e603f..06cf9e29c 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -28,6 +28,10 @@ module.exports = function(grunt) { src: './builder/patternlab_grunt.js', dest: './builder/patternlab_grunt.js' }, + patternlab_gulp: { + src: './builder/patternlab_gulp.js', + dest: './builder/patternlab_gulp.js' + }, parameter_hunter: { src: './builder/parameter_hunter.js', dest: './builder/parameter_hunter.js' diff --git a/builder/lineage_hunter.js b/builder/lineage_hunter.js index 7c9f5038f..a6244f41a 100644 --- a/builder/lineage_hunter.js +++ b/builder/lineage_hunter.js @@ -1,5 +1,5 @@ /* - * patternlab-node - v0.12.0 - 2015 + * patternlab-node - v0.13.0 - 2015 * * 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 cc357f48d..50b3aa88a 100644 --- a/builder/list_item_hunter.js +++ b/builder/list_item_hunter.js @@ -1,5 +1,5 @@ /* - * patternlab-node - v0.12.0 - 2015 + * patternlab-node - v0.13.0 - 2015 * * Brian Muenzenmeyer, and the web community. * Licensed under the MIT license. diff --git a/builder/media_hunter.js b/builder/media_hunter.js index 247a96042..6170b1bf5 100644 --- a/builder/media_hunter.js +++ b/builder/media_hunter.js @@ -1,5 +1,5 @@ /* - * patternlab-node - v0.12.0 - 2015 + * patternlab-node - v0.13.0 - 2015 * * Brian Muenzenmeyer, and the web community. * Licensed under the MIT license. diff --git a/builder/object_factory.js b/builder/object_factory.js index 39bd6789d..d70f69996 100644 --- a/builder/object_factory.js +++ b/builder/object_factory.js @@ -1,10 +1,10 @@ -/* - * patternlab-node - v0.12.0 - 2015 - * +/* + * patternlab-node - v0.13.0 - 2015 + * * Brian Muenzenmeyer, and the web community. - * Licensed under the MIT license. - * - * Many thanks to Brad Frost and Dave Olsen for inspiration, encouragement, and advice. + * Licensed under the MIT license. + * + * Many thanks to Brad Frost and Dave Olsen for inspiration, encouragement, and advice. * */ diff --git a/builder/parameter_hunter.js b/builder/parameter_hunter.js index e4faf7450..388bf7249 100644 --- a/builder/parameter_hunter.js +++ b/builder/parameter_hunter.js @@ -1,5 +1,5 @@ /* - * patternlab-node - v0.12.0 - 2015 + * patternlab-node - v0.13.0 - 2015 * * Brian Muenzenmeyer, and the web community. * Licensed under the MIT license. diff --git a/builder/pattern_assembler.js b/builder/pattern_assembler.js index 52c3bf50b..feba11874 100644 --- a/builder/pattern_assembler.js +++ b/builder/pattern_assembler.js @@ -1,10 +1,10 @@ -/* - * patternlab-node - v0.12.0 - 2015 - * +/* + * patternlab-node - v0.13.0 - 2015 + * * Brian Muenzenmeyer, and the web community. - * Licensed under the MIT license. - * - * Many thanks to Brad Frost and Dave Olsen for inspiration, encouragement, and advice. + * Licensed under the MIT license. + * + * Many thanks to Brad Frost and Dave Olsen for inspiration, encouragement, and advice. * */ diff --git a/builder/pattern_exporter.js b/builder/pattern_exporter.js index 71c19b616..1be55f96c 100644 --- a/builder/pattern_exporter.js +++ b/builder/pattern_exporter.js @@ -1,5 +1,5 @@ /* - * patternlab-node - v0.12.0 - 2015 + * patternlab-node - v0.13.0 - 2015 * * Brian Muenzenmeyer, and the web community. * Licensed under the MIT license. diff --git a/builder/patternlab.js b/builder/patternlab.js index 0bed6df81..eef0ddbb3 100644 --- a/builder/patternlab.js +++ b/builder/patternlab.js @@ -1,10 +1,10 @@ -/* - * patternlab-node - v0.12.0 - 2015 - * +/* + * patternlab-node - v0.13.0 - 2015 + * * Brian Muenzenmeyer, and the web community. - * Licensed under the MIT license. - * - * Many thanks to Brad Frost and Dave Olsen for inspiration, encouragement, and advice. + * Licensed under the MIT license. + * + * Many thanks to Brad Frost and Dave Olsen for inspiration, encouragement, and advice. * */ diff --git a/builder/patternlab_grunt.js b/builder/patternlab_grunt.js index 744421a1b..6d093ae83 100644 --- a/builder/patternlab_grunt.js +++ b/builder/patternlab_grunt.js @@ -1,5 +1,5 @@ /* - * patternlab-node - v0.12.0 - 2015 + * patternlab-node - v0.13.0 - 2015 * * Brian Muenzenmeyer, and the web community. * Licensed under the MIT license. diff --git a/builder/patternlab_gulp.js b/builder/patternlab_gulp.js index 5cbeb2440..11fc334dc 100644 --- a/builder/patternlab_gulp.js +++ b/builder/patternlab_gulp.js @@ -1,3 +1,13 @@ +/* + * patternlab-node - v0.13.0 - 2015 + * + * Brian Muenzenmeyer, and the web community. + * Licensed under the MIT license. + * + * Many thanks to Brad Frost and Dave Olsen for inspiration, encouragement, and advice. + * + */ + var patternlab_engine = require('./patternlab.js'); module.exports = function(gulp) { diff --git a/builder/pseudopattern_hunter.js b/builder/pseudopattern_hunter.js index 8d72ca1da..a07f5e4df 100644 --- a/builder/pseudopattern_hunter.js +++ b/builder/pseudopattern_hunter.js @@ -1,5 +1,5 @@ /* - * patternlab-node - v0.12.0 - 2015 + * patternlab-node - v0.13.0 - 2015 * * Brian Muenzenmeyer, and the web community. * Licensed under the MIT license. diff --git a/gulpfile.js b/gulpfile.js index 8007b8410..a3b426ecc 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -37,6 +37,7 @@ gulp.task('banner', function(){ './builder/lineage_hunter.js', './builder/media_hunter.js', './builder/patternlab_grunt.js', + './builder/patternlab_gulp.js', './builder/parameter_hunter.js', './builder/pattern_exporter.js', './builder/pattern_assembler.js',