Skip to content

Commit 107b98a

Browse files
committed
Downstream projects can now require grunt and gulp tasks, no need to copy them anymore.
1 parent e132d89 commit 107b98a

File tree

6 files changed

+309
-351
lines changed

6 files changed

+309
-351
lines changed

Gruntfile.js

Lines changed: 3 additions & 135 deletions
Original file line numberDiff line numberDiff line change
@@ -1,139 +1,7 @@
11
module.exports = function(grunt) {
22

3-
var path = require('path');
4-
5-
// Project configuration.
6-
grunt.initConfig({
7-
pkg: grunt.file.readJSON('package.json'),
8-
concat: {
9-
options: {
10-
stripBanners: true,
11-
banner: '/* \n * <%= pkg.name %> - v<%= pkg.version %> - <%= grunt.template.today("yyyy") %> \n * \n * <%= pkg.author %>, and the web community.\n * Licensed under the <%= pkg.license %> license. \n * \n * Many thanks to Brad Frost and Dave Olsen for inspiration, encouragement, and advice. \n *\n */\n\n',
12-
},
13-
patternlab: {
14-
src: './builder/patternlab.js',
15-
dest: './builder/patternlab.js'
16-
},
17-
object_factory: {
18-
src: './builder/object_factory.js',
19-
dest: './builder/object_factory.js'
20-
},
21-
lineage: {
22-
src: './builder/lineage_hunter.js',
23-
dest: './builder/lineage_hunter.js'
24-
},
25-
media_hunter: {
26-
src: './builder/media_hunter.js',
27-
dest: './builder/media_hunter.js'
28-
},
29-
patternlab_grunt: {
30-
src: './builder/patternlab_grunt.js',
31-
dest: './builder/patternlab_grunt.js'
32-
},
33-
patternlab_gulp: {
34-
src: './builder/patternlab_gulp.js',
35-
dest: './builder/patternlab_gulp.js'
36-
},
37-
parameter_hunter: {
38-
src: './builder/parameter_hunter.js',
39-
dest: './builder/parameter_hunter.js'
40-
},
41-
pattern_exporter: {
42-
src: './builder/pattern_exporter.js',
43-
dest: './builder/pattern_exporter.js'
44-
},
45-
pattern_assembler: {
46-
src: './builder/pattern_assembler.js',
47-
dest: './builder/pattern_assembler.js'
48-
},
49-
pseudopattern_hunter: {
50-
src: './builder/pseudopattern_hunter.js',
51-
dest: './builder/pseudopattern_hunter.js'
52-
},
53-
list_item_hunter: {
54-
src: './builder/list_item_hunter.js',
55-
dest: './builder/list_item_hunter.js'
56-
},
57-
style_modifier_hunter: {
58-
src: './builder/style_modifier_hunter.js',
59-
dest: './builder/style_modifier_hunter.js'
60-
}
61-
},
62-
copy: {
63-
main: {
64-
files: [
65-
{ expand: true, cwd: path.resolve(paths().source.js), src: '*.js', dest: path.resolve(paths().public.js) },
66-
{ expand: true, cwd: path.resolve(paths().source.css), src: '*.css', dest: path.resolve(paths().public.css) },
67-
{ expand: true, cwd: path.resolve(paths().source.images), src: ['**/*.png', '**/*.jpg', '**/*.gif', '**/*.jpeg'], dest: path.resolve(paths().public.images) },
68-
{ expand: true, cwd: path.resolve(paths().source.fonts), src: '*', dest: path.resolve(paths().public.fonts) },
69-
{ expand: true, cwd: path.resolve(paths().source.data), src: 'annotations.js', dest: path.resolve(paths().public.data) }
70-
]
71-
},
72-
styleguide: {
73-
files: [
74-
{ expand: true, cwd: path.resolve(paths().source.styleguide), src: ['*.*', '**/*.*'], dest: path.resolve(paths().public.styleguide) }
75-
]
76-
}
77-
},
78-
watch: {
79-
all: {
80-
files: [
81-
path.resolve(paths().source.css + '**/*.css'),
82-
path.resolve(paths().source.styleguide + 'css/*.css'),
83-
path.resolve(paths().source.patterns + '**/*.mustache'),
84-
path.resolve(paths().source.patterns + '**/*.json'),
85-
path.resolve(paths().source.fonts + '/*'),
86-
path.resolve(paths().source.images + '/*'),
87-
path.resolve(paths().source.data + '*.json')
88-
],
89-
tasks: ['default', 'bsReload:css']
90-
}
91-
},
92-
nodeunit: {
93-
all: ['test/*_tests.js']
94-
},
95-
browserSync: {
96-
dev: {
97-
options: {
98-
server: path.resolve(paths().public.root),
99-
watchTask: true,
100-
watchOptions: {
101-
ignoreInitial: true,
102-
ignored: '*.html'
103-
},
104-
plugins: [
105-
{
106-
module: 'bs-html-injector',
107-
options: {
108-
files: [path.resolve(paths().public.root + '/index.html'), path.resolve(paths().public.styleguide + '/styleguide.html')]
109-
}
110-
}
111-
]
112-
}
113-
}
114-
},
115-
bsReload: {
116-
css: path.resolve(paths().public.root + '**/*.css')
117-
}
118-
});
119-
120-
function paths () {
121-
return require('./config.json').paths;
122-
}
123-
124-
// load all grunt tasks
125-
require('matchdep').filterDev('grunt-*').forEach(grunt.loadNpmTasks);
126-
127-
//load the patternlab task
128-
grunt.task.loadTasks('./builder/');
129-
130-
grunt.registerTask('default', ['patternlab', 'copy:main', 'copy:styleguide']);
131-
132-
//travis CI task
133-
grunt.registerTask('travis', ['nodeunit', 'patternlab']);
134-
135-
grunt.registerTask('serve', ['patternlab', 'copy:main', 'copy:styleguide', 'browserSync', 'watch:all']);
136-
137-
grunt.registerTask('build', ['nodeunit', 'concat']);
3+
var config = require('./config.json');
1384

5+
// Load grunt tasks to the current grunt and inject the local configuration
6+
require('./builder/patternlab_grunt')(grunt, config);
1397
};

builder/patternlab_grunt.js

Lines changed: 138 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,137 @@
1-
/*
2-
* patternlab-node - v1.1.1 - 2016
3-
*
1+
/*
2+
* patternlab-node - v1.1.0 - 2016
3+
*
44
* Brian Muenzenmeyer, and the web community.
5-
* Licensed under the MIT license.
6-
*
7-
* Many thanks to Brad Frost and Dave Olsen for inspiration, encouragement, and advice.
5+
* Licensed under the MIT license.
6+
*
7+
* Many thanks to Brad Frost and Dave Olsen for inspiration, encouragement, and advice.
88
*
99
*/
1010

11-
var patternlab_engine = require('./patternlab.js');
11+
// IMPORTANT: Remember that `./` matches the root of the grunt file that requires this one!
12+
// However, this does not apply to the `require('...')`
13+
module.exports = function(grunt, config) {
14+
var patternlab_engine = require('./patternlab.js'),
15+
path = require('path');
16+
17+
// Project configuration.
18+
grunt.initConfig({
19+
pkg: grunt.file.readJSON('package.json'),
20+
concat: {
21+
options: {
22+
stripBanners: true,
23+
banner: '/* \n * <%= pkg.name %> - v<%= pkg.version %> - <%= grunt.template.today("yyyy") %> \n * \n * <%= pkg.author %>, and the web community.\n * Licensed under the <%= pkg.license %> license. \n * \n * Many thanks to Brad Frost and Dave Olsen for inspiration, encouragement, and advice. \n *\n */\n\n',
24+
},
25+
patternlab: {
26+
src: './builder/patternlab.js',
27+
dest: './builder/patternlab.js'
28+
},
29+
object_factory: {
30+
src: './builder/object_factory.js',
31+
dest: './builder/object_factory.js'
32+
},
33+
lineage: {
34+
src: './builder/lineage_hunter.js',
35+
dest: './builder/lineage_hunter.js'
36+
},
37+
media_hunter: {
38+
src: './builder/media_hunter.js',
39+
dest: './builder/media_hunter.js'
40+
},
41+
patternlab_grunt: {
42+
src: './builder/patternlab_grunt.js',
43+
dest: './builder/patternlab_grunt.js'
44+
},
45+
patternlab_gulp: {
46+
src: './builder/patternlab_gulp.js',
47+
dest: './builder/patternlab_gulp.js'
48+
},
49+
parameter_hunter: {
50+
src: './builder/parameter_hunter.js',
51+
dest: './builder/parameter_hunter.js'
52+
},
53+
pattern_exporter: {
54+
src: './builder/pattern_exporter.js',
55+
dest: './builder/pattern_exporter.js'
56+
},
57+
pattern_assembler: {
58+
src: './builder/pattern_assembler.js',
59+
dest: './builder/pattern_assembler.js'
60+
},
61+
pseudopattern_hunter: {
62+
src: './builder/pseudopattern_hunter.js',
63+
dest: './builder/pseudopattern_hunter.js'
64+
},
65+
list_item_hunter: {
66+
src: './builder/list_item_hunter.js',
67+
dest: './builder/list_item_hunter.js'
68+
},
69+
style_modifier_hunter: {
70+
src: './builder/style_modifier_hunter.js',
71+
dest: './builder/style_modifier_hunter.js'
72+
}
73+
},
74+
copy: {
75+
main: {
76+
files: [
77+
{ expand: true, cwd: path.resolve(config.paths.source.js), src: '*.js', dest: path.resolve(config.paths.public.js) },
78+
{ expand: true, cwd: path.resolve(config.paths.source.css), src: '*.css', dest: path.resolve(config.paths.public.css) },
79+
{ expand: true, cwd: path.resolve(config.paths.source.images), src: ['**/*.png', '**/*.jpg', '**/*.gif', '**/*.jpeg'], dest: path.resolve(config.paths.public.images) },
80+
{ expand: true, cwd: path.resolve(config.paths.source.fonts), src: '*', dest: path.resolve(config.paths.public.fonts) },
81+
{ expand: true, cwd: path.resolve(config.paths.source.data), src: 'annotations.js', dest: path.resolve(config.paths.public.data) }
82+
]
83+
},
84+
styleguide: {
85+
files: [
86+
{ expand: true, cwd: path.resolve(config.paths.source.styleguide), src: ['*.*', '**/*.*'], dest: path.resolve(config.paths.public.styleguide) }
87+
]
88+
}
89+
},
90+
watch: {
91+
all: {
92+
files: [
93+
path.resolve(config.paths.source.css + '**/*.css'),
94+
path.resolve(config.paths.source.styleguide + 'css/*.css'),
95+
path.resolve(config.paths.source.patterns + '**/*.mustache'),
96+
path.resolve(config.paths.source.patterns + '**/*.json'),
97+
path.resolve(config.paths.source.fonts + '/*'),
98+
path.resolve(config.paths.source.images + '/*'),
99+
path.resolve(config.paths.source.data + '*.json')
100+
],
101+
tasks: ['default', 'bsReload:css']
102+
}
103+
},
104+
nodeunit: {
105+
all: ['test/*_tests.js']
106+
},
107+
browserSync: {
108+
dev: {
109+
options: {
110+
server: path.resolve(config.paths.public.root),
111+
watchTask: true,
112+
watchOptions: {
113+
ignoreInitial: true,
114+
ignored: '*.html'
115+
},
116+
plugins: [
117+
{
118+
module: 'bs-html-injector',
119+
options: {
120+
files: [path.resolve(config.paths.public.root + '/index.html'), path.resolve(config.paths.public.styleguide + '/styleguide.html')]
121+
}
122+
}
123+
]
124+
}
125+
}
126+
},
127+
bsReload: {
128+
css: path.resolve(config.paths.public.root + '**/*.css')
129+
}
130+
});
131+
132+
// load all grunt tasks
133+
require('matchdep').filterDev('grunt-*').forEach(grunt.loadNpmTasks);
12134

13-
module.exports = function(grunt) {
14135
grunt.registerTask('patternlab', 'create design systems with atomic design', function(arg) {
15136

16137
var patternlab = patternlab_engine();
@@ -37,4 +158,13 @@ module.exports = function(grunt) {
37158

38159
});
39160

161+
grunt.registerTask('default', ['patternlab', 'copy:main', 'copy:styleguide']);
162+
163+
//travis CI task
164+
grunt.registerTask('travis', ['nodeunit', 'patternlab']);
165+
166+
grunt.registerTask('serve', ['patternlab', 'copy:main', 'copy:styleguide', 'browserSync', 'watch:all']);
167+
168+
grunt.registerTask('build', ['nodeunit', 'concat']);
169+
40170
};

0 commit comments

Comments
 (0)