1
1
/*
2
- * patternlab-node - v0.1.1 - 2014-05-07
2
+ * patternlab-node - v0.1.2 - 2014-05-08
3
3
*
4
4
* Brian Muenzenmeyer, and the web community.
5
5
* Licensed under the MIT license.
8
8
*
9
9
*/
10
10
11
- var plnode = function ( grunt ) {
11
+ var patternlab_engine = function ( grunt ) {
12
12
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 = { } ;
17
17
18
18
patternlab . package = grunt . file . readJSON ( 'package.json' ) ;
19
19
@@ -25,19 +25,22 @@ var plnode = function(grunt){
25
25
grunt . log . ok ( 'patternlab help coming soon' ) ;
26
26
}
27
27
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
+ }
29
35
36
+ function buildPatterns ( ) {
30
37
patternlab . data = grunt . file . readJSON ( './source/_data/data.json' ) ;
31
38
patternlab . listitems = grunt . file . readJSON ( './source/_data/listitems.json' ) ;
32
39
patternlab . header = grunt . file . read ( './source/_patternlab-files/pattern-header-footer/header.html' ) ;
33
40
patternlab . footer = grunt . file . read ( './source/_patternlab-files/pattern-header-footer/footer.html' ) ;
34
41
patternlab . patterns = [ ] ;
35
42
patternlab . patternIndex = [ ] ;
36
43
patternlab . partials = { } ;
37
- patternlab . buckets = [ ] ;
38
- patternlab . bucketIndex = [ ] ;
39
- patternlab . patternPaths = { } ;
40
- patternlab . viewAllPaths = { } ;
41
44
42
45
grunt . file . recurse ( './source/_patterns' , function ( abspath , rootdir , subdir , filename ) {
43
46
//check if the pattern already exists.
@@ -130,6 +133,14 @@ var plnode = function(grunt){
130
133
131
134
} ) ;
132
135
136
+ }
137
+
138
+ function buildFrontEnd ( ) {
139
+ patternlab . buckets = [ ] ;
140
+ patternlab . bucketIndex = [ ] ;
141
+ patternlab . patternPaths = { } ;
142
+ patternlab . viewAllPaths = { } ;
143
+
133
144
//build the styleguide
134
145
var styleguideTemplate = grunt . file . read ( './source/_patternlab-files/styleguide.mustache' ) ;
135
146
var styleguideHtml = mustache . render ( styleguideTemplate , { partials : patternlab . patterns } ) ;
@@ -294,56 +305,55 @@ var plnode = function(grunt){
294
305
} ) ;
295
306
grunt . file . write ( './public/index.html' , patternlabSiteHtml ) ;
296
307
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
-
303
308
}
304
309
305
310
return {
306
311
version : function ( ) {
307
312
return getVersion ( ) ;
308
313
} ,
309
314
build : function ( ) {
310
- build ( ) ;
315
+ buildPatterns ( ) ;
316
+ buildFrontEnd ( ) ;
317
+ printDebug ( ) ;
318
+
311
319
} ,
312
320
help : function ( ) {
313
321
help ( ) ;
314
322
} ,
315
323
build_patterns_only : function ( ) {
316
324
grunt . log . ok ( 'only_patterns argument not yet implemented' ) ;
325
+ buildPatterns ( ) ;
326
+ printDebug ( ) ;
317
327
}
318
328
} ;
319
329
320
330
} ;
321
331
322
- module . exports = plnode ;
332
+ module . exports = patternlab_engine ;
323
333
324
334
module . exports = function ( grunt ) {
325
335
grunt . registerTask ( 'patternlab' , 'create design systems with atomic design' , function ( arg ) {
326
336
327
- var pl = plnode ( grunt ) ;
337
+ var patternlab = patternlab_engine ( grunt ) ;
328
338
329
339
if ( arguments . length === 0 ) {
330
- pl . build ( ) ;
331
- }
340
+ patternlab . build ( ) ;
341
+ }
332
342
333
343
if ( arg && arg === 'v' ) {
334
- pl . version ( ) ;
335
- }
344
+ patternlab . version ( ) ;
345
+ }
336
346
337
347
if ( arg && arg === "only_patterns" ) {
338
- pl . build_patterns_only ( ) ;
348
+ patternlab . build_patterns_only ( ) ;
339
349
}
340
350
341
351
if ( arg && arg === "help" ) {
342
- pl . help ( ) ;
352
+ patternlab . help ( ) ;
343
353
}
344
354
345
355
if ( arg && ( arg !== "v" && arg !== "only_patterns" ) ) {
346
- pl . help ( ) ;
356
+ patternlab . help ( ) ;
347
357
}
348
358
349
359
} ) ;
0 commit comments