Skip to content

Commit 12a40e1

Browse files
author
Brian Muenzenmeyer
committed
Merge pull request pattern-lab#149 from pattern-lab/dev
v0.12.0
2 parents 7a0b0d9 + 1192071 commit 12a40e1

26 files changed

+592
-328
lines changed

CHANGELOG

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,16 @@
11
THIS CHANGELOG IS AN ATTEMPT TO DOCUMENT CHANGES TO THIS PROJECT.
22

3+
PL-node-v0.12.0
4+
- ADD: Gulp support arrives with an optional configuration
5+
- ADD: Instructions how to install and run with Gulp
6+
- DEL: Deleted the sass modules from `package.json` files
7+
- CHG: Commented out all sass tasks in Grunt and Gulp files
8+
- CHG: Changed static web server provider to BrowserSync
9+
- CHG: Replaced the Style Guide toolbar Auto-Reload and Page Follow with a link to the BrowserSync UI
10+
- THX: Thanks @oscar-g for the initial work on the gulpfile!
11+
- ADD: An alternative, more verbose syntax for pattern partial inclusion
12+
- THX: Thanks @e2tha-e for the thoughtful addition with unit test coverage
13+
314
PL-node-v0.11.0
415
- ADD: Ignore pattern directories that start with an underscore.
516
- ADD: Support for lists with the listItems variable

CONTRIBUTING.md

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@ If you'd like to contribute to patternlab - node, please do so! There is always
44
No pull request is too small.
55

66
##Guidelines
7-
1. Please keep your pull requests concise
8-
2. _ALWAYS_ submit it against the [dev branch](https://github.com/pattern-lab/patternlab-node/tree/dev). If this does not occur, I will first, try to redirect you gently, second, port over your contribution manually if time allows, and/or third, close your pull request.
9-
3. If you can, add some unit tests using the existing patterns
7+
1. Please keep your pull requests concise and limited to **ONE** substantive change at a time.
8+
2. _ALWAYS_ submit pull requests against the [dev branch](https://github.com/pattern-lab/patternlab-node/tree/dev). If this does not occur, I will first, try to redirect you gently, second, port over your contribution manually if time allows, and/or third, close your pull request.
9+
3. If you can, add some unit tests using the existing patterns
10+
11+
##Coding style
12+
Regarding code style like indentation and whitespace, follow the conventions you see used in the source already. Add enough source code comments to help the next person.

Gruntfile.js

Lines changed: 57 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,6 @@ module.exports = function(grunt) {
33
// Project configuration.
44
grunt.initConfig({
55
pkg: grunt.file.readJSON('package.json'),
6-
clean: {
7-
options: { force: true },
8-
files: ['./public/patterns']
9-
},
106
concat: {
117
options: {
128
stripBanners: true,
@@ -63,67 +59,72 @@ module.exports = function(grunt) {
6359
{ expand: true, cwd: './source/fonts/', src: '*', dest: './public/fonts/'},
6460
{ expand: true, cwd: './source/_data/', src: 'annotations.js', dest: './public/data/' }
6561
]
66-
}
67-
},
68-
jshint: {
69-
options: {
70-
"curly": true,
71-
"eqnull": true,
72-
"eqeqeq": true,
73-
"undef": true,
74-
"forin": true,
75-
//"unused": true,
76-
"node": true
7762
},
78-
patternlab: ['Gruntfile.js', './builder/lib/patternlab.js']
63+
css: {
64+
files: [
65+
{ expand: true, cwd: './source/css/', src: '*.css', dest: './public/css/' }
66+
]
67+
}
7968
},
8069
watch: {
81-
// scss: { //scss can be watched if you like
82-
// options: {
83-
// livereload: true
84-
// },
70+
all: {
71+
files: [
72+
'source/css/**/*.css',
73+
'public/styleguide/css/*.css',
74+
'source/_patterns/**/*.mustache',
75+
'source/_patterns/**/*.json',
76+
'source/_data/*.json'
77+
],
78+
tasks: ['default']
79+
},
80+
// scss: {
8581
// files: ['source/css/**/*.scss', 'public/styleguide/css/*.scss'],
86-
// tasks: ['default']
82+
// tasks: ['sass', 'copy:css','bsReload:css']
8783
// },
88-
all: {
89-
options: {
90-
livereload: true
91-
},
84+
patterns: {
9285
files: [
93-
'source/_patterns/**/*.mustache',
94-
'source/_patterns/**/*.json',
95-
'source/_data/*.json'
86+
'source/_patterns/**/*.mustache',
87+
'source/_patterns/**/*.json',
88+
'source/_data/*.json'
9689
],
9790
tasks: ['default']
9891
}
9992
},
100-
sass: {
101-
build: {
102-
options: {
103-
style: 'expanded',
104-
precision: 8
105-
},
106-
files: {
107-
'./source/css/style.css': './source/css/style.scss',
108-
'./public/styleguide/css/static.css': './public/styleguide/css/static.scss',
109-
'./public/styleguide/css/styleguide.css': './public/styleguide/css/styleguide.scss',
110-
'./public/styleguide/css/styleguide-specific.css': './public/styleguide/css/styleguide-specific.scss'
111-
}
112-
}
113-
},
93+
// sass: {
94+
// build: {
95+
// options: {
96+
// style: 'expanded',
97+
// precision: 8
98+
// },
99+
// files: {
100+
// './source/css/style.css': './source/css/style.scss',
101+
// './public/styleguide/css/static.css': './public/styleguide/css/static.scss',
102+
// './public/styleguide/css/styleguide.css': './public/styleguide/css/styleguide.scss',
103+
// './public/styleguide/css/styleguide-specific.css': './public/styleguide/css/styleguide-specific.scss'
104+
// }
105+
// }
106+
// },
114107
nodeunit: {
115108
all: ['test/*_tests.js']
116109
},
117-
connect: {
118-
app:{
110+
browserSync: {
111+
dev: {
119112
options: {
120-
port: 9001,
121-
base: './public',
122-
hostname: 'localhost',
123-
open: true,
124-
livereload: 35729
113+
server: './public',
114+
watchTask: true,
115+
plugins: [
116+
{
117+
module: 'bs-html-injector',
118+
options: {
119+
files: './public/index.html'
120+
}
121+
}
122+
]
125123
}
126124
}
125+
},
126+
bsReload: {
127+
css: './public/**/*.css'
127128
}
128129
});
129130

@@ -134,11 +135,15 @@ module.exports = function(grunt) {
134135
grunt.task.loadTasks('./builder/');
135136

136137
//if you choose to use scss, or any preprocessor, you can add it here
137-
grunt.registerTask('default', ['clean', 'concat', 'patternlab', /*'sass',*/ 'copy']);
138+
grunt.registerTask('default', ['patternlab', /*'sass',*/ 'copy:main']);
138139

139140
//travis CI task
140-
grunt.registerTask('travis', ['nodeunit', 'clean', 'concat', 'patternlab', /*'sass',*/ 'copy']);
141+
grunt.registerTask('travis', ['nodeunit', 'patternlab']);
142+
143+
//TODO: this line is more efficient, but you cannot run concurrent watch tasks without another dependency.
144+
//grunt.registerTask('serve', ['patternlab', /*'sass',*/ 'copy:main', 'browserSync', 'watch:patterns', 'watch:scss']);
145+
grunt.registerTask('serve', ['patternlab', /*'sass',*/ 'copy:main', 'browserSync', 'watch:all']);
141146

142-
grunt.registerTask('serve', ['clean', 'concat', 'patternlab', /*'sass',*/ 'copy', 'connect', 'watch']);
147+
grunt.registerTask('build', ['nodeunit', 'concat']);
143148

144149
};

README.md

Lines changed: 67 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -2,21 +2,59 @@
22

33
## About the Node Version of Pattern Lab
44

5-
The Node version of Pattern Lab is, at its core, a static site generator. It combines platform-agnostic assets, like the [Mustache](http://mustache.github.io/)-based patterns and the JavaScript-based viewer, with a Node-based "builder" that transforms and dynamically builds the Pattern Lab site. By making it a static site generator, the Node version of Pattern Lab strongly separates patterns, data, and presentation from build logic. The Node version is a work in progress, the [PHP version](https://github.com/pattern-lab/patternlab-php) should be seen as a reference for other developers to improve upon as they build their own Pattern Lab Builders in their language of choice.
5+
The Node version of [Pattern Lab](http://patternlab.io/) is, at its core, a static site generator. It combines platform-agnostic assets, like the Mustache-based patterns, the JavaScript-based viewer, and the self-contained webserver, with a Node-based "builder" that transforms and dynamically builds the Pattern Lab site.
66

7-
### Getting Started
7+
This repository contains the vanilla builder logic, grunt and gulp configurations, and some sample template/css/data to illustrate the power and flexibility of the tool.
88

9-
To run patternlab-node, run the following from the command line at the root of whichever directory you want to initialize your project in:
9+
### Download
1010

11-
1. `npm install`
12-
2. `npm install -g grunt-cli`
13-
3. `grunt`
11+
* Download the [latest release of patternlab-node](https://github.com/pattern-lab/patternlab-node/releases/latest) from Github
12+
* Via npm, run `npm install patternlab-node` (Note this will auto install the grunt version currently. see below)
1413

15-
This creates all patterns, the styleguide, and the pattern lab site.
14+
### Choose Your Adventure! Now Vanilla, Grunt & Gulp
15+
16+
This repository ships with two `package.json` files, a `Gruntfile.js`, and a `gulpfile.js`. The default is grunt currently. The core builder is not dependent on either.
17+
18+
**HELP WANTED** Please help me test both of the configurations by [reporting](https://github.com/pattern-lab/patternlab-node/blob/dev/CONTRIBUTING.md) any issues encountered.
19+
20+
### Getting Started - Grunt
21+
22+
To run patternlab-node using grunt, do the following in the directory you downloaded and extracted the zipped release:
23+
24+
1. Run `npm install` from the command line
25+
2. Optionally, delete `package.gulp.json`, `gulpfile.js`, and `builder/patternlab_gulp.js` files if you are certain you don't need it.
26+
* Not deleting `builder/patternlab_gulp.js` may cause a harmless error when running grunt. Delete it.
27+
3. Run `grunt` or `grunt serve` from the command line
28+
29+
This creates all patterns, the styleguide, and the pattern lab site. It's strongly recommended to run `grunt serve` to see have BrowserSync spin up and serve the files to you.
30+
31+
### Getting Started - Gulp
32+
33+
To run patternlab-node using gulp, you need to swap out the default grunt configuration. Do the following in the directory you downloaded and extracted the zipped release:
34+
35+
1. Rename `package.json` to `package.grunt.json` or delete it if you don't intend on going back
36+
2. Rename `package.gulp.json` to `package.json`
37+
3. Run `npm install` from the command line
38+
4. Run `gulp` or `gulp serve` from the command line
39+
40+
This creates all patterns, the styleguide, and the pattern lab site. It's strongly recommended to run `grunt serve` to see have BrowserSync spin up and serve the files to you.
41+
42+
### There and Back Again, or Switching Between Grunt and Gulp
43+
44+
It's not expected to toggle between the two build systems, but for those migrating between the two configs, here's some general guidelines:
45+
46+
* Make sure your `package.json` files are correct per the Getting Started sections.
47+
* Run `npm cache clear` before installation
48+
* Delete the contents of `./node_modules` if you want a cleaner installation.
49+
* Regarding speed, Gulp is faster. BrowserSync takes a bit longer than the old static server to spin up, but its capabilities far outweigh the startup cost.
50+
51+
### Upgrading
52+
53+
You can find some simple upgrade documenation in it's current home here (unreleased but confirmed to work): [https://github.com/pattern-lab/website/blob/dev/patternlabsite/docs/node/upgrading.md](https://github.com/pattern-lab/website/blob/dev/patternlabsite/docs/node/upgrading.md)
1654

1755
### Command Line Interface
1856

19-
The following are grunt task arguments you may execute:
57+
The following are grunt/gulp task arguments you may execute:
2058

2159
##### `patternlab`
2260
With no arguments, patternlab runs the full builder, compiling patterns, and constructing the front-end site.
@@ -30,15 +68,20 @@ Retrieve the version of patternlab-node you have installed
3068
##### `patternlab:help`
3169
Get more information about patternlab-node, pattern lab in general, and where to report issues.
3270

33-
### Config Options
71+
### Further Configuration
3472

3573
##### Watching Changes
36-
To have patternlab-node watch for changes to either a mustache template, data, or stylesheets, run `grunt watch`. The `Gruntfile` governs what is watched. It should be easy to add scss or whatever preprocessor you fancy.
74+
To have patternlab-node watch for changes to either a mustache template, data, or stylesheets, run `grunt|gulp watch` or `grunt|gulp serve`. The `Gruntfile|Gulpfile` governs what is watched. It should be easy to add scss or whatever preprocessor you fancy.
75+
76+
##### Preprocessor Support
77+
The patternlab-node release package ships with some `.scss` files utilized in the creation of the style guide and sample templates, but these are not required. The compilation tasks are commented out in the `Gruntfiles|Gulpfiles` but can be uncommented or changed to meet your needs. Sass modules are not included in `package.json` files - the prevailing thought being if you are familiar enough with preprocessors, you can use the instructions for [grunt-contrib-sass](https://github.com/gruntjs/grunt-contrib-sass) / [gulp-sass](https://github.com/dlmanning/gulp-sass) / _preprocessor of choice_ to install them. Uncomment the preprocessor configuration to fully utilize the example templates, css and style guide.
78+
79+
**NOTE:** You may run into issues installing gulp-sass if you don't have the latest Visual Studio on Windows. See [here](https://github.com/sass/node-sass/issues/469) for more information and [this query](https://github.com/sass/node-sass/issues?utf8=%E2%9C%93&q=is%3Aissue+install) for a slew of installation problems related to gulp-sass.
3780

3881
##### Nav Bar Controls
39-
If you don't have a need for some of the nav-bar tools in the patternlab frontend, you can turn them off in `config.json`.
82+
If you don't have a need for some of the nav-bar tools in the Pattern Lab frontend, you can turn them off in `config.json`.
4083

41-
The current selection is as follows. It reflects support versus patternlab-php.
84+
The current selection is as follows.
4285

4386
```
4487
"ishControlsVisible": {
@@ -99,11 +142,20 @@ If you'd like to exclude an individual pattern you can do so by prepending the f
99142

100143
You can also exclude complete directories by prepending the directory name with an underscore, like: `/_experiment/...`
101144

102-
##### Verbose Mode
145+
##### Debug Mode
103146
`patternlab.json` is a file created for debugging purposes. Set `debug` to true in `.config.json` to see all the secrets.
104147

105-
##### Server
106-
Running `grunt serve` will compile the patternlab front end and host it on <a href="http://localhost:9001">http://localhost:9001</a> by default. Page will reload on any saved source code change.
148+
##### Server &amp; BrowserSync
149+
Running `grunt serve` or `gulp serve` will compile the Pattern Lab frontend and host it by default on <a href="http://localhost:3000">http://localhost:3000</a> via [BrowserSync](http://www.browsersync.io/docs/). After it starts, templates, `data.json`, and scss/css changes in your source code will be automatically injected into the page.
150+
151+
You'll notice that if you have this open across different browsers, we do our best to keep the frontend in sync, but there is a known issue with synced navigation using the main menu.
152+
153+
### Roadmap
154+
155+
156+
A roadmap exists for Pattern Lab Node. Check it out [here](https://github.com/pattern-lab/patternlab-node/issues/134). The Node version of Pattern Lab is maintained by [@bmuenzenmeyer](https://twitter.com/bmuenzenmeyer) and contributors. Pull requests welcome, but please take a moment to read the [guidelines](https://github.com/pattern-lab/patternlab-node/blob/master/CONTRIBUTING.md).
157+
158+
Dave Olsen has also published the [specification](https://github.com/pattern-lab/the-spec/blob/draft/SPEC.md) for Pattern Lab ports. Development will be oriented toward compliance with this as the spec and the port mature together. Post v1 work will focus on other pattern engines and a plugin architecture.
107159

108160
### Advanced Pattern Library Features
109161

@@ -190,37 +242,6 @@ This would compile to:
190242

191243
As you can see, it's a much easier way of linking patterns to one another.
192244

193-
194-
===
195-
196-
The Node version of Pattern Lab is maintained by [@bmuenzenmeyer](https://twitter.com/bmuenzenmeyer) and contributors. Pull requests welcome, but please take a moment to read the [guidelines](https://github.com/pattern-lab/patternlab-node/blob/master/CONTRIBUTING.md).
197-
198-
### Upgrading
199-
200-
You can find some simple upgrade documenation in it's current home here (unreleased but confirmed to work): [https://github.com/pattern-lab/website/blob/dev/patternlabsite/docs/node/upgrading.md](https://github.com/pattern-lab/website/blob/dev/patternlabsite/docs/node/upgrading.md)
201-
202-
### ROADMAP
203-
204-
A roadmap exists for Pattern Lab Node. Check it out [here](https://github.com/pattern-lab/patternlab-node/issues/134)
205-
206-
Dave Olsen has also published the [specification](https://github.com/pattern-lab/the-spec/blob/draft/SPEC.md) for Pattern Lab ports. Development will be oriented toward compliance with this as the spec and the port mature together.
207-
208-
### Is Pattern Lab a Platform or a Build Tool?
209-
210-
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.
211-
212-
If you want to only build the patterns, alter your `Gruntfile.js` patternlab task to the following:
213-
214-
```
215-
grunt.registerTask('default', ['clean', 'concat', 'patternlab:only_patterns', /*'sass',*/ 'copy']);
216-
```
217-
218-
This will output compiled patterns to ./public/patterns/
219-
220-
### Where is the Gulp Version?
221-
222-
The core patternlab engine is free of any dependencies to grunt, allowing users to integrate with gulp if desired. Future efforts here will orient towards [this gulp implementation](https://github.com/oscar-g/patternlab-node/tree/dev-gulp) by [oscar-g](https://github.com/oscar-g).
223-
224245
===
225246

226247
## Working with Patterns

builder/lineage_hunter.js

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

builder/list_item_hunter.js

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

builder/media_hunter.js

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

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.11.0 - 2015
2+
* patternlab-node - v0.12.0 - 2015
33
*
44
* Brian Muenzenmeyer, and the web community.
55
* Licensed under the MIT license.

builder/parameter_hunter.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* patternlab-node - v0.11.0 - 2015
2+
* patternlab-node - v0.12.0 - 2015
33
*
44
* Brian Muenzenmeyer, and the web community.
55
* Licensed under the MIT license.
@@ -21,12 +21,12 @@
2121
function findparameters(pattern, patternlab){
2222

2323
//find the {{> template-name(*) }} within patterns
24-
var matches = pattern.template.match(/{{>([ ]+)?([A-Za-z0-9-]+)(\()(.+)(\))([ ]+)?}}/g);
24+
var matches = pattern.template.match(/{{>([ ]+)?([\w\-\.\/~]+)(\()(.+)(\))([ ]+)?}}/g);
2525
if(matches !== null){
2626
//compile this partial immeadiately, essentially consuming it.
2727
matches.forEach(function(pMatch, index, matches){
2828
//find the partial's name
29-
var partialName = pMatch.match(/([a-z-]+)/ig)[0];
29+
var partialName = pMatch.match(/([\w\-\.\/~]+)/g)[0];
3030

3131
if(patternlab.config.debug){
3232
console.log('found patternParameters for ' + partialName);

0 commit comments

Comments
 (0)