Skip to content
This repository was archived by the owner on Feb 7, 2023. It is now read-only.

Commit cfcb919

Browse files
committed
work in progress
readme updates dependency cleanup started work on grunt file. can talk to API. pl-serve not yet working
1 parent a610bc4 commit cfcb919

File tree

4 files changed

+168
-19
lines changed

4 files changed

+168
-19
lines changed

Gruntfile.js

Lines changed: 67 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,68 @@
1+
/******************************************************
2+
* PATTERN LAB NODE
3+
* EDITION-NODE-GRUNT
4+
* The grunt wrapper around patternlab-node core, providing tasks to interact with the core library and move supporting frontend assets.
5+
******************************************************/
6+
17
module.exports = function (grunt) {
28

3-
var path = require('path');
9+
var path = require('path'),
10+
argv = require('minimist')(process.argv.slice(2));;
11+
12+
/******************************************************
13+
* PATTERN LAB CONFIGURATION
14+
******************************************************/
15+
16+
//read all paths from our namespaced config file
17+
var config = require('./patternlab-config.json'),
18+
pl = require('patternlab-node')(config);
419

520
function paths() {
621
return require('./patternlab-config.json').paths;
722
}
823

9-
// Project configuration.
24+
function getConfiguredCleanOption() {
25+
return config.cleanPublic;
26+
}
27+
28+
grunt.registerTask('patternlab', 'create design systems with atomic design', function (arg) {
29+
30+
if (arguments.length === 0) {
31+
pl.build(getConfiguredCleanOption());
32+
}
33+
34+
if (arg && arg === 'version') {
35+
pl.version();
36+
}
37+
38+
if (arg && arg === "patternsonly") {
39+
pl.patternsonly(getConfiguredCleanOption());
40+
}
41+
42+
if (arg && arg === "help") {
43+
pl.help();
44+
}
45+
46+
if (arg && arg === "starterkit-list") {
47+
pl.liststarterkits();
48+
}
49+
50+
if (arg && arg === "starterkit-load") {
51+
pl.loadstarterkit(argv.kit);
52+
}
53+
54+
if (arg && (arg !== "version" && arg !== "patternsonly" && arg !== "help" && arg !== "starterkit-list" && arg !== "starterkit-load")) {
55+
pl.help();
56+
}
57+
});
58+
59+
1060
grunt.initConfig({
1161
pkg: grunt.file.readJSON('package.json'),
62+
63+
/******************************************************
64+
* COPY TASKS
65+
******************************************************/
1266
copy: {
1367
main: {
1468
files: [
@@ -26,6 +80,9 @@ module.exports = function (grunt) {
2680
]
2781
}
2882
},
83+
/******************************************************
84+
* SERVER AND WATCH TASKS
85+
******************************************************/
2986
watch: {
3087
all: {
3188
files: [
@@ -91,11 +148,15 @@ module.exports = function (grunt) {
91148
// load all grunt tasks
92149
require('matchdep').filterDev('grunt-*').forEach(grunt.loadNpmTasks);
93150

94-
//load the patternlab task
95-
require('./core/lib/patternlab_grunt')(grunt);
96151

97-
grunt.registerTask('default', ['patternlab', 'copy:main', 'copy:styleguide']);
152+
/******************************************************
153+
* COMPOUND AND ALIASED TASKS
154+
******************************************************/
98155

99-
grunt.registerTask('serve', ['patternlab', 'copy:main', 'copy:styleguide', 'browserSync', 'watch:all']);
156+
grunt.registerTask('default', ['patternlab', 'copy:main', 'copy:styleguide']);
157+
grunt.registerTask('pl-serve', ['patternlab', 'copy:main', 'copy:styleguide', 'browserSync', 'watch:all']);
100158

159+
//Aliases
160+
grunt.registerTask('pl-help', ['patternlab:help']);
161+
grunt.registerTask('pl-patterns', ['patternlab:patternsonly']);
101162
};

README.md

Lines changed: 90 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,92 @@
1-
# edition-node-grunt
2-
The grunt wrapper around patternlab-node core.
1+
# Pattern Lab Node - Grunt Edition
32

4-
**Work In Progress** **Unstable** **Infantile** **Borked**
3+
The Grunt wrapper around [Pattern Lab Node Core](https://github.com/pattern-lab/patternlab-node), currently in 2.0.0-alpha, providing tasks to interact with the core library and move supporting frontend assets.
54

6-
Be warned, this is work-in-progress development, aligning with the broader [Pattern Lab Node Roadmap](https://github.com/pattern-lab/patternlab-node/wiki/Roadmap#v2xx-upcoming--future).
5+
## Packaged Components
6+
7+
The Grunt Edition comes with the following components:
8+
9+
* `patternlab-node`: [GitHub](https://github.com/pattern-lab/patternlab-node), [npm](https://www.npmjs.com/package/patternlab-node)
10+
* `patternengine-node-mustache`: [GitHub](https://github.com/pattern-lab/patternengine-node-mustache), [npm](https://www.npmjs.com/package/patternengine-node-mustache)
11+
* `pattern-lab/styleguidekit-assets-default`: [GitHub](https://github.com/pattern-lab/styleguidekit-assets-default)
12+
* `pattern-lab/styleguidekit-mustache-default`: [GitHub](https://github.com/pattern-lab/styleguidekit-mustache-default)
13+
14+
## Prerequisites
15+
16+
Pattern Lab Node uses [Node](https://nodejs.org) and [npm](https://www.npmjs.com/) to manage project dependencies, and [grunt](http://gruntjs.com/) to run tasks and interface with core.
17+
18+
Please follow the directions for [installing Node](https://nodejs.org/en/download/) on the Node website. This should include `npm`.
19+
20+
It's also highly recommended that you [install grunt](http://gruntjs.com/getting-started) globally.
21+
22+
## Installing
23+
24+
There are two methods for downloading and installing the Grunt Edition:
25+
26+
* [Download a pre-built package](#download-a-pre-built-package)
27+
* [Use npm](#use-npm)
28+
29+
### Download a pre-built package
30+
31+
The fastest way to get started with the Grunt Edition is to [download the pre-built version](https://github.com/pattern-lab/edition-node-gulp/releases) from the [releases page](https://github.com/pattern-lab/edition-node-gulp/releases). The pre-built project comes with the [Default Starterkit for Mustache](https://github.com/pattern-lab/starterkit-mustache-default/tree/dev) installed by default.
32+
33+
**Please note:** Pattern Lab Node uses [npm](https://www.npmjs.com/) to manage project dependencies. To upgrade the Grunt Edition or to install plug-ins you'll need to be familiar with npm.
34+
35+
### Use npm
36+
37+
`npm` is a dependency management and package system which can pull in all of the Grunt Edition's dependencies for you. To accomplish this:
38+
39+
* download or clone this repository to an install location.
40+
41+
* run the following
42+
cd install/location
43+
npm install
44+
45+
Running `npm install` from a directory containing a `package.json` file will download all dependencies defined within.
46+
47+
#### Install the Grunt Edition of Pattern Lab Node as a Dependency
48+
49+
Most people want to run Pattern Lab Node standalone and not as a dependency. If you wish to install as a dependency you can do the following:
50+
51+
Use npm's [`install` command](https://docs.npmjs.com/cli/install) with an argument to install the Grunt Edition into a location of your choosing. In Terminal type:
52+
53+
cd install/location/
54+
npm install edition-node-grunt
55+
56+
This will install the Grunt Edition into a directory called `node_modules` in `install/location/`.
57+
58+
## Updating Pattern Lab
59+
60+
To update Pattern Lab please refer to each component's GitHub repository, and the [master instructions for core](https://github.com/pattern-lab/patternlab-node/wiki/Upgrading). The components are listed at the top of the README.
61+
62+
## Helpful Commands
63+
64+
These are some helpful commands you can use on the command line for working with Pattern Lab.
65+
66+
### List all of the available commands
67+
68+
To list all available commands type:
69+
70+
grunt pl-help
71+
72+
### Generate Pattern Lab
73+
74+
To generate the front-end for Pattern Lab type:
75+
76+
grunt pl-build
77+
78+
### Watch for changes and re-generate Pattern Lab
79+
80+
To watch for changes, re-generate the front-end, and server it via a BrowserSync server, type:
81+
82+
grunt pl-serve
83+
84+
BrowserSync should open [http://localhost:3000](http://localhost:3000) in your browser.
85+
86+
### Install a StarterKit
87+
88+
To install a specific StarterKit from GitHub type:
89+
90+
npm install [starterkit-vendor/starterkit-name]
91+
92+
grunt patternlab:starterkit-load --kit=[starterkit-name]

package.json

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,19 @@
11
{
22
"name": "edition-node-grunt",
3-
"description": "The grunt wrapper around patternlab-node core.",
4-
"version": "0.1.0",
3+
"description": "The grunt wrapper around patternlab-node core, providing tasks to interact with the core library and move supporting frontend assets.",
4+
"version": "1.0.0",
55
"main": "./core/lib/patternlab.js",
66
"dependencies": {
77
"bs-html-injector": "^3.0.0",
88
"grunt": "~1.0.1",
99
"grunt-browser-sync": "^2.2.0",
1010
"grunt-contrib-watch": "^1.0.0",
1111
"grunt-contrib-copy": "^1.0.0",
12-
"patternlab-node": "pattern-lab/patternlab-node#dev-2.0-core",
13-
"matchdep": "^1.0.0",
14-
"mustache": "^2.2.0",
15-
"handlebars": "^4.0.5",
16-
"underscore": "^1.8.3",
17-
"twig": "^0.9.5"
12+
"minimist": "^1.2.0",
13+
"patternlab-node": "pattern-lab/patternlab-node#v2.0.0-alpha",
14+
"styleguidekit-assets-default": "pattern-lab/styleguidekit-assets-default#feature-panels",
15+
"styleguidekit-mustache-default": "pattern-lab/styleguidekit-mustache-default#feature-panels",
16+
"matchdep": "^1.0.0"
1817
},
1918
"keywords": [
2019
"Pattern Lab",

patternlab-config.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
"root": "./source/",
55
"patterns" : "./source/_patterns/",
66
"data" : "./source/_data/",
7+
"meta": "./source/_meta/",
78
"annotations" : "./source/_annotations/",
89
"styleguide" : "./node_modules/styleguidekit-assets-default/dist/",
910
"patternlabFiles" : "./node_modules/styleguidekit-mustache-default/views/",
@@ -29,6 +30,7 @@
2930
"pages"
3031
],
3132
"defaultPattern": "all",
33+
"cleanPublic" : true,
3234
"patternExtension": "mustache",
3335
"ignored-extensions" : ["scss", "DS_Store", "less"],
3436
"ignored-directories" : ["scss"],
@@ -61,5 +63,6 @@
6163
"patternExportPatternPartials": [],
6264
"patternExportDirectory": "./pattern_exports/",
6365
"baseurl" : "",
64-
"cacheBust": true
66+
"cacheBust": true,
67+
"starterkitSubDir": "dist"
6568
}

0 commit comments

Comments
 (0)