Skip to content

Commit 3525b28

Browse files
committed
pattern only compilation
1 parent 16fb1af commit 3525b28

File tree

5 files changed

+48
-31
lines changed

5 files changed

+48
-31
lines changed

Gruntfile.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ module.exports = function(grunt) {
7878
});
7979

8080
// load all grunt tasks
81-
require('matchdep').filterDev('grunt-*').forEach(grunt.loadNpmTasks);
81+
require('matchdep').filterDev('grunt-*').forEach(grunt.loadNpmTasks);
8282

8383
//load the patternlab task
8484
grunt.task.loadTasks('./builder/');
@@ -87,5 +87,5 @@ module.exports = function(grunt) {
8787
grunt.registerTask('default', ['clean', 'concat', 'patternlab', /*'sass',*/ 'copy']);
8888

8989
//travis CI task
90-
grunt.registerTask('travis', ['clean', 'concat', 'patternlab', /*'sass',*/ 'copy', 'nodeunit'])
90+
grunt.registerTask('travis', ['clean', 'concat', 'patternlab', /*'sass',*/ 'copy', 'nodeunit']);
9191
};

README.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,13 @@ Dave Olsen has published the [specification](https://github.com/pattern-lab/the-
2626

2727
A lot of good conversation has revolved around whether Pattern Lab is a platform or a tool in the toolbox, part of a larger solution. It's my goal to #1) adhere to the specification and #2) meet the needs of both use cases.
2828

29+
If you want to only build the patterns, alter your `Gruntfile.js` patternlab task to the following:
30+
31+
```
32+
grunt.registerTask('default', ['clean', 'concat', 'patternlab:only_patterns', /*'sass',*/ 'copy']);
33+
```
34+
35+
This will output compiled patterns to ./public/patterns/
2936

3037
**THE FOLLOWING IS FROM THE PATTERNLAB-PHP PROJECT. A LOT STILL APPLIES TO PATTERNLAB-NODE, BUT IT HAS NOT BEEN ADAPTED YET. USE AT YOUR OWN PERIL**
3138

builder/object_factory.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* patternlab-node - v0.1.1 - 2014-05-07
2+
* patternlab-node - v0.1.2 - 2014-05-08
33
*
44
* Brian Muenzenmeyer, and the web community.
55
* Licensed under the MIT license.

builder/patternlab.js

Lines changed: 37 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* patternlab-node - v0.1.1 - 2014-05-07
2+
* patternlab-node - v0.1.2 - 2014-05-08
33
*
44
* Brian Muenzenmeyer, and the web community.
55
* Licensed under the MIT license.
@@ -8,12 +8,12 @@
88
*
99
*/
1010

11-
var plnode = function(grunt){
11+
var patternlab_engine = function(grunt){
1212
var path = require('path'),
13-
mustache = require('mustache'),
14-
of = require('./object_factory'),
15-
pa = require('./pattern_assembler'),
16-
patternlab = {};
13+
mustache = require('mustache'),
14+
of = require('./object_factory'),
15+
pa = require('./pattern_assembler'),
16+
patternlab = {};
1717

1818
patternlab.package = grunt.file.readJSON('package.json');
1919

@@ -25,19 +25,22 @@ var plnode = function(grunt){
2525
grunt.log.ok('patternlab help coming soon');
2626
}
2727

28-
function build(){
28+
function printDebug() {
29+
//debug file can be written by setting flag on package.json
30+
if(patternlab.package.debug){
31+
var outputFilename = './patternlab.json';
32+
grunt.file.write(outputFilename, JSON.stringify(patternlab, null, 3));
33+
}
34+
}
2935

36+
function buildPatterns(){
3037
patternlab.data = grunt.file.readJSON('./source/_data/data.json');
3138
patternlab.listitems = grunt.file.readJSON('./source/_data/listitems.json');
3239
patternlab.header = grunt.file.read('./source/_patternlab-files/pattern-header-footer/header.html');
3340
patternlab.footer = grunt.file.read('./source/_patternlab-files/pattern-header-footer/footer.html');
3441
patternlab.patterns = [];
3542
patternlab.patternIndex = [];
3643
patternlab.partials = {};
37-
patternlab.buckets = [];
38-
patternlab.bucketIndex = [];
39-
patternlab.patternPaths = {};
40-
patternlab.viewAllPaths = {};
4144

4245
grunt.file.recurse('./source/_patterns', function(abspath, rootdir, subdir, filename){
4346
//check if the pattern already exists.
@@ -130,6 +133,14 @@ var plnode = function(grunt){
130133

131134
});
132135

136+
}
137+
138+
function buildFrontEnd(){
139+
patternlab.buckets = [];
140+
patternlab.bucketIndex = [];
141+
patternlab.patternPaths = {};
142+
patternlab.viewAllPaths = {};
143+
133144
//build the styleguide
134145
var styleguideTemplate = grunt.file.read('./source/_patternlab-files/styleguide.mustache');
135146
var styleguideHtml = mustache.render(styleguideTemplate, {partials: patternlab.patterns});
@@ -294,56 +305,55 @@ var plnode = function(grunt){
294305
});
295306
grunt.file.write('./public/index.html', patternlabSiteHtml);
296307

297-
//debug file can be written by setting flag on package.json
298-
if(patternlab.package.debug){
299-
var outputFilename = './patternlab.json';
300-
grunt.file.write(outputFilename, JSON.stringify(patternlab, null, 3));
301-
}
302-
303308
}
304309

305310
return {
306311
version: function(){
307312
return getVersion();
308313
},
309314
build: function(){
310-
build();
315+
buildPatterns();
316+
buildFrontEnd();
317+
printDebug();
318+
311319
},
312320
help: function(){
313321
help();
314322
},
315323
build_patterns_only: function(){
316324
grunt.log.ok('only_patterns argument not yet implemented');
325+
buildPatterns();
326+
printDebug();
317327
}
318328
};
319329

320330
};
321331

322-
module.exports = plnode;
332+
module.exports = patternlab_engine;
323333

324334
module.exports = function(grunt) {
325335
grunt.registerTask('patternlab', 'create design systems with atomic design', function(arg) {
326336

327-
var pl = plnode(grunt);
337+
var patternlab = patternlab_engine(grunt);
328338

329339
if(arguments.length === 0){
330-
pl.build();
331-
}
340+
patternlab.build();
341+
}
332342

333343
if(arg && arg === 'v'){
334-
pl.version();
335-
}
344+
patternlab.version();
345+
}
336346

337347
if(arg && arg === "only_patterns"){
338-
pl.build_patterns_only();
348+
patternlab.build_patterns_only();
339349
}
340350

341351
if(arg && arg === "help"){
342-
pl.help();
352+
patternlab.help();
343353
}
344354

345355
if(arg && (arg !== "v" && arg !=="only_patterns")){
346-
pl.help();
356+
patternlab.help();
347357
}
348358

349359
});

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "patternlab-node",
33
"description": "Pattern Lab is a collection of tools to help you create atomic design systems. This is the node command line interface (CLI).",
4-
"version": "0.1.1",
4+
"version": "0.1.2",
55
"devDependencies": {
66
"grunt": "~0.4.0",
77
"grunt-contrib-watch": "~0.2.0",

0 commit comments

Comments
 (0)