diff --git a/CHANGELOG b/CHANGELOG index 4c45c1c5c..7b320d233 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,5 +1,11 @@ THIS CHANGELOG IS AN ATTEMPT TO DOCUMENT CHANGES TO THIS PROJECT. +PL-node-v0.1.7 + - ADD: pattern export + - CHG: updated devDependencies + - FIX: fixed a type in the README and config + - THX: thanks @seanhussey for the pull request! + PL-node-v0.1.6 - ADD: media queries found in css added to ish controls - ADD: basic lineage support diff --git a/Gruntfile.js b/Gruntfile.js index a4ab4dac1..06f2f160d 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -31,6 +31,10 @@ module.exports = function(grunt) { patternlab_grunt: { src: './builder/patternlab_grunt.js', dest: './builder/patternlab_grunt.js' + }, + pattern_exporter: { + src: './builder/pattern_exporter.js', + dest: './builder/pattern_exporter.js' } }, copy: { @@ -83,7 +87,8 @@ module.exports = function(grunt) { files: { './source/css/style.css': './source/css/style.scss', './public/styleguide/css/static.css': './public/styleguide/css/static.scss', - './public/styleguide/css/styleguide.css': './public/styleguide/css/styleguide.scss' + './public/styleguide/css/styleguide.css': './public/styleguide/css/styleguide.scss', + './public/styleguide/css/styleguide-specific.css': './public/styleguide/css/styleguide-specific.scss' } } }, diff --git a/README.md b/README.md index caadd2172..afd23d799 100644 --- a/README.md +++ b/README.md @@ -46,7 +46,7 @@ The current selection is as follows. It reflects support versus patternlab-php. "m": true, "l": true, "full": true, - "ranndom": true, + "random": true, "disco": true, "hay": true, "mqs": false, @@ -62,10 +62,6 @@ The current selection is as follows. It reflects support versus patternlab-php. "tools-docs": true } ``` - -##### Verbose Mode -`patternlab.json` is a file created for debugging purposes. Set `debug` to true in `.config.json` to see all the secrets. - ##### Pattern States You can set the state of a pattern by including it in `config.json` too. The out of the box styles are in progress (orange), in review (yellow), and complete (green). Pattern states should be lowercase and use hyphens where spaces are present. @@ -77,6 +73,20 @@ Pattern states should be lowercase and use hyphens where spaces are present. } ``` +##### Pattern Export +`config.json` also has two properties that work together to export completed patterns for use in a production environment. Provide an array of keys and an output directory. Pattern Lab doesn't ship with any pattern export keys, but the default directory is `"./pattern_exports/"` created inside the install directory. + +``` +"patternExportKeys": ["molecules-primary-nav", "organisms-header", "organisms-header"], +"patternExportDirectory": "./pattern_exports/" +``` + +Coupled with exported css (much easier to extract with existing tools like [grunt-contrib-copy](https://github.com/gruntjs/grunt-contrib-copy)), pattern export can help to maintain the relevancy of the design system by directly placing partials in a directory of your choosing. + + +##### Verbose Mode +`patternlab.json` is a file created for debugging purposes. Set `debug` to true in `.config.json` to see all the secrets. + ##### Server Running `grunt serve` will compile the patternlab front end and host it on http://localhost:9001 by default. Page will reload on any saved source code change. diff --git a/builder/lineage_hunter.js b/builder/lineage_hunter.js index 67569d554..dcabaea6f 100644 --- a/builder/lineage_hunter.js +++ b/builder/lineage_hunter.js @@ -1,5 +1,5 @@ /* - * patternlab-node - v0.1.6 - 2014 + * patternlab-node - v0.1.7 - 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 7ed8f0993..e66994a14 100644 --- a/builder/media_hunter.js +++ b/builder/media_hunter.js @@ -1,5 +1,5 @@ /* - * patternlab-node - v0.1.6 - 2014 + * patternlab-node - v0.1.7 - 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 a0a2a3192..5f8308f37 100644 --- a/builder/object_factory.js +++ b/builder/object_factory.js @@ -1,5 +1,5 @@ /* - * patternlab-node - v0.1.6 - 2014 + * patternlab-node - v0.1.7 - 2015 * * Brian Muenzenmeyer, and the web community. * Licensed under the MIT license. @@ -23,6 +23,7 @@ this.patternGroup = name.substring(name.indexOf('-') + 1, name.indexOf('-', 4) + 1 - name.indexOf('-') + 1); this.patternSubGroup = subdir.substring(subdir.indexOf('/') + 4); this.flatPatternPath = subdir.replace(/\//g, '-'); + this.key = ''; this.lineage = []; this.lineageIndex = []; this.lineageR = []; diff --git a/builder/pattern_exporter.js b/builder/pattern_exporter.js new file mode 100644 index 000000000..8ed9ed22b --- /dev/null +++ b/builder/pattern_exporter.js @@ -0,0 +1,48 @@ +/* + * patternlab-node - v0.1.7 - 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. + * + */ + +(function () { + "use strict"; + + var fs = require('fs-extra'), + path = require('path'); + + var pattern_exporter = function(){ + + function exportPatterns(patternlab){ + + //read the config export options + var exportKeys = patternlab.config.patternExportKeys; + + //find the chosen patterns to export + for (var i = 0; i < exportKeys.length; i++){ + for (var j = 0; j < patternlab.patterns.length; j++){ + if(exportKeys[i] === patternlab.patterns[j].key){ + //write matches to the desired location + fs.outputFileSync(patternlab.config.patternExportDirectory + patternlab.patterns[j].key + '.html', patternlab.patterns[j].patternPartial); + } + } + } + + + + } + + return { + export_patterns: function(patternlab){ + exportPatterns(patternlab); + } + }; + + }; + + module.exports = pattern_exporter; + +}()); \ No newline at end of file diff --git a/builder/patternlab.js b/builder/patternlab.js index b02c286c5..e7e07f03f 100644 --- a/builder/patternlab.js +++ b/builder/patternlab.js @@ -1,5 +1,5 @@ /* - * patternlab-node - v0.1.6 - 2014 + * patternlab-node - v0.1.7 - 2015 * * Brian Muenzenmeyer, and the web community. * Licensed under the MIT license. @@ -17,6 +17,7 @@ var patternlab_engine = function(){ pa = require('./pattern_assembler'), mh = require('./media_hunter'), lh = require('./lineage_hunter'), + pe = require('./pattern_exporter') patternlab = {}; patternlab.package =fs.readJSONSync('./package.json'); @@ -89,6 +90,7 @@ var patternlab_engine = function(){ currentPattern = new of.oPattern(flatPatternName, subdir, filename, {}); currentPattern.patternName = patternName.substring(patternName.indexOf('-') + 1); currentPattern.data = null; + currentPattern.key = currentPattern.patternGroup + '-' + currentPattern.patternName; //see if this file has a state if(patternlab.config.patternStates[currentPattern.patternName]){ @@ -115,7 +117,6 @@ var patternlab_engine = function(){ currentPattern.patternPartial = renderPattern(currentPattern.template, patternlab.data, patternlab.partials); } - //write the compiled template to the public patterns directory currentPattern.patternLink = currentPattern.name + '/' + currentPattern.name + '.html';; //find pattern lineage @@ -148,10 +149,14 @@ var patternlab_engine = function(){ //add footer info before writing var patternFooter = renderPattern(patternlab.footer, pattern); + //write the compiled template to the public patterns directory fs.outputFileSync('./public/patterns/' + pattern.patternLink, patternlab.header + pattern.patternPartial + patternFooter); }); + //export patterns if necessary + var pattern_exporter = new pe(); + pattern_exporter.export_patterns(patternlab); } diff --git a/builder/patternlab_grunt.js b/builder/patternlab_grunt.js index 358c5318b..6c89a0fbc 100644 --- a/builder/patternlab_grunt.js +++ b/builder/patternlab_grunt.js @@ -1,5 +1,5 @@ /* - * patternlab-node - v0.1.6 - 2014 + * patternlab-node - v0.1.7 - 2015 * * Brian Muenzenmeyer, and the web community. * Licensed under the MIT license. diff --git a/config.json b/config.json index cd241672b..3336c93de 100644 --- a/config.json +++ b/config.json @@ -13,7 +13,7 @@ "m": true, "l": true, "full": true, - "ranndom": true, + "random": true, "disco": true, "hay": true, "mqs": true, @@ -29,5 +29,7 @@ "tools-docs": true }, "patternStates": { - } - } \ No newline at end of file + }, + "patternExportKeys": [], + "patternExportDirectory": "./pattern_exports/" + } diff --git a/package.json b/package.json index e2d366f83..30b7d0be9 100644 --- a/package.json +++ b/package.json @@ -1,20 +1,20 @@ { "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.1.6", + "version": "0.1.7", "devDependencies": { "grunt": "~0.4.0", - "grunt-contrib-watch": "~0.6.1", - "grunt-contrib-sass": "~0.2.2", - "grunt-contrib-copy": "~0.4.0", - "grunt-contrib-jshint": "~0.4.0", - "grunt-contrib-clean": "~0.5.0", - "grunt-contrib-concat": "~0.3.0", - "grunt-contrib-nodeunit": "~0.3.0", - "grunt-contrib-connect": "^0.8.0", - "mustache": "~0.8.1", - "matchdep": "~0.3.0", - "fs-extra": "^0.10.0", + "grunt-contrib-watch": "^0.6.1", + "grunt-contrib-sass": "^0.8.1", + "grunt-contrib-copy": "^0.7.0", + "grunt-contrib-jshint": "^0.10.0", + "grunt-contrib-clean": "^0.6.0", + "grunt-contrib-concat": "^0.5.0", + "grunt-contrib-nodeunit": "^0.4.1", + "grunt-contrib-connect": "^0.9.0", + "mustache": "^1.0.0", + "matchdep": "^0.3.0", + "fs-extra": "^0.14.0", "diveSync": "^0.2.1" }, "keywords": [