1 |
|
2 | var pageBuilder = require('./tests/pages/_script/page-builder'),
|
3 | open = require('open');
|
4 |
|
5 | module.exports = function (grunt) {
|
6 | 'use strict';
|
7 |
|
8 |
|
9 | var projectConfig = {
|
10 | dist: 'dist',
|
11 | src: ''
|
12 | };
|
13 |
|
14 |
|
15 | require('matchdep').filterDev('grunt-*').forEach(grunt.loadNpmTasks);
|
16 |
|
17 | try {
|
18 | projectConfig.src = require('./bower.json').appPath || projectConfig.src;
|
19 | } catch (e) {}
|
20 |
|
21 | grunt.initConfig({
|
22 | config: projectConfig,
|
23 | connect: {
|
24 | server: {
|
25 | options: {
|
26 | hostname: '0.0.0.0',
|
27 | livereload: true,
|
28 | base: [
|
29 | projectConfig.src,
|
30 | projectConfig.dist + '/tests'
|
31 | ],
|
32 | port: 9000
|
33 | }
|
34 | }
|
35 | },
|
36 | run: {
|
37 | options: {
|
38 | },
|
39 | bundleInstall: {
|
40 | cmd: 'bundle',
|
41 | args: [
|
42 | 'install'
|
43 | ]
|
44 | }
|
45 | },
|
46 | clean: {
|
47 | build: '<%= config.dist %>'
|
48 | },
|
49 | concat: {
|
50 | js: {
|
51 | files: {
|
52 | 'dist/js/patternfly-settings.js': [
|
53 | 'src/js/patternfly-settings-base.js',
|
54 | 'src/js/patternfly-settings-colors.js',
|
55 | 'src/js/patternfly-settings-charts.js'
|
56 | ],
|
57 | 'dist/js/patternfly-functions.js': [
|
58 | 'src/js/patternfly-functions-base.js',
|
59 | 'src/js/patternfly-functions-list.js',
|
60 | 'src/js/patternfly-functions-sidebar.js',
|
61 | 'src/js/patternfly-functions-popovers.js',
|
62 | 'src/js/patternfly-functions-data-tables.js',
|
63 | 'src/js/patternfly-functions-navigation.js',
|
64 | 'src/js/patternfly-functions-count-chars.js',
|
65 | 'src/js/patternfly-functions-colors.js',
|
66 | 'src/js/patternfly-functions-charts.js',
|
67 | 'src/js/patternfly-functions-fixed-heights.js',
|
68 | 'src/js/patternfly-functions-tree-grid.js',
|
69 | 'src/js/patternfly-functions-vertical-nav.js'
|
70 | ],
|
71 | 'dist/js/patternfly.js': [
|
72 | 'dist/js/patternfly-settings.js',
|
73 | 'dist/js/patternfly-functions.js'
|
74 | ]
|
75 | }
|
76 | }
|
77 | },
|
78 | copy: {
|
79 | main: {
|
80 | files: [
|
81 |
|
82 | {expand: true, cwd: 'node_modules/bootstrap/dist/fonts/', src: ['*'], dest: 'dist/fonts/'},
|
83 |
|
84 | {expand: true, cwd: 'node_modules/font-awesome/fonts/', src: ['*'], dest: 'dist/fonts/'},
|
85 |
|
86 | {expand: true, cwd: 'src/less/', src: ['*'], dest: 'dist/less/'},
|
87 |
|
88 | {expand: true, cwd: 'src/fonts/', src: ['*'], dest: 'dist/fonts/'},
|
89 |
|
90 | {expand: true, cwd: 'src/img/', src: ['**'], dest: 'dist/img/'},
|
91 |
|
92 |
|
93 | {expand: true, cwd: 'node_modules/bootstrap/less/', src: ['**'], dest: 'dist/less/dependencies/bootstrap/'},
|
94 |
|
95 | {expand: true, cwd: 'node_modules/font-awesome/less/', src: ['**'], dest: 'dist/less/dependencies/font-awesome/'},
|
96 |
|
97 | {expand: true, cwd: 'node_modules/patternfly-bootstrap-combobox/less/', src: ['**'], dest: 'dist/less/dependencies/bootstrap-combobox/'},
|
98 |
|
99 | {expand: true, cwd: 'node_modules/bootstrap-datepicker/less/', src: ['**'], dest: 'dist/less/dependencies/bootstrap-datepicker/'},
|
100 |
|
101 | {expand: true, cwd: 'node_modules/bootstrap-select/less/', src: ['**'], dest: 'dist/less/dependencies/bootstrap-select/'},
|
102 |
|
103 |
|
104 |
|
105 | {expand: true, cwd: 'node_modules/bootstrap-touchspin/dist/', src: ['jquery.bootstrap-touchspin.css'], dest: 'dist/less/dependencies/bootstrap-touchspin/'},
|
106 |
|
107 | {expand: true, cwd: 'node_modules/c3/', src: ['c3.css'], dest: 'dist/less/dependencies/c3/'}
|
108 | ]
|
109 | },
|
110 | js: {
|
111 | files: [
|
112 |
|
113 | {expand: true, cwd: 'src/js/', src: ['*.js'], dest: 'dist/js/'}
|
114 | ]
|
115 | }
|
116 | },
|
117 | csscount: {
|
118 | production: {
|
119 | src: [
|
120 | 'dist/css/patternfly*.min.css'
|
121 | ],
|
122 | options: {
|
123 | maxSelectors: 4096
|
124 | }
|
125 | }
|
126 | },
|
127 | jekyll: {
|
128 | options: {
|
129 | src: 'tests/pages',
|
130 | bundleExec: 'true'
|
131 | },
|
132 | tests: {
|
133 | options: {
|
134 | dest: 'dist/tests'
|
135 | }
|
136 | }
|
137 | },
|
138 | cssmin: {
|
139 | production: {
|
140 | files: [{
|
141 | expand: true,
|
142 | cwd: 'dist/css',
|
143 | src: ['patternfly*.css', '!*.min.css'],
|
144 | dest: 'dist/css',
|
145 | ext: '.min.css',
|
146 | }],
|
147 | options: {
|
148 | sourceMap: true
|
149 | }
|
150 | }
|
151 | },
|
152 | less: {
|
153 | patternfly: {
|
154 | files: {
|
155 | 'dist/css/patternfly.css': 'src/less/patternfly.less',
|
156 | },
|
157 | options: {
|
158 | paths: [
|
159 | 'src/less/',
|
160 | 'node_modules/'
|
161 | ],
|
162 | strictMath: true,
|
163 | sourceMap: true,
|
164 | outputSourceFiles: true,
|
165 | sourceMapFilename: 'dist/css/patternfly.css.map',
|
166 | sourceMapURL: 'patternfly.css.map'
|
167 | }
|
168 | },
|
169 | patternflyAdditions: {
|
170 | files: {
|
171 | 'dist/css/patternfly-additions.css': 'src/less/patternfly-additions.less'
|
172 | },
|
173 | options: {
|
174 | paths: [
|
175 | 'src/less/',
|
176 | 'node_modules/'
|
177 | ],
|
178 | strictMath: true,
|
179 | sourceMap: true,
|
180 | outputSourceFiles: true,
|
181 | sourceMapFilename: 'dist/css/patternfly-additions.css.map',
|
182 | sourceMapURL: 'patternfly-additions.css.map'
|
183 | }
|
184 | }
|
185 | },
|
186 | uglify: {
|
187 | options: {
|
188 | mangle: false
|
189 | },
|
190 | production: {
|
191 | files: {
|
192 | 'dist/js/patternfly.min.js': ['dist/js/patternfly.js'],
|
193 | 'dist/js/patternfly-settings.min.js': ['dist/js/patternfly-settings.js'],
|
194 | 'dist/js/patternfly-functions.min.js': ['dist/js/patternfly-functions.js'],
|
195 | 'dist/js/patternfly.dataTables.pfEmpty.min.js': ['src/js/patternfly.dataTables.pfEmpty.js'],
|
196 | 'dist/js/patternfly.dataTables.pfFilter.min.js': ['src/js/patternfly.dataTables.pfFilter.js'],
|
197 | 'dist/js/patternfly.dataTables.pfPagination.min.js': ['src/js/patternfly.dataTables.pfPagination.js'],
|
198 | 'dist/js/patternfly.dataTables.pfResize.min.js': ['src/js/patternfly.dataTables.pfResize.js'],
|
199 | 'dist/js/patternfly.dataTables.pfSelect.min.js': ['src/js/patternfly.dataTables.pfSelect.js']
|
200 | }
|
201 | }
|
202 | },
|
203 | watch: {
|
204 | copy: {
|
205 | files: [
|
206 | 'node_modules/bootstrap/dist/fonts/**/*',
|
207 | 'node_modules/font-awesome/fonts/**/*',
|
208 | 'src/fonts/**/*',
|
209 | 'src/img/**/*'
|
210 | ],
|
211 | tasks: ['copy']
|
212 | },
|
213 | jekyll: {
|
214 | files: 'tests/pages/**/*',
|
215 | tasks: ['pages']
|
216 | },
|
217 | less: {
|
218 | files: ['src/less/*.less'],
|
219 | tasks: ['less']
|
220 | },
|
221 | css: {
|
222 | files: ['dist/css/patternfly*.css', 'dist/css/!*.min.css'],
|
223 | tasks: ['cssmin','csscount']
|
224 | },
|
225 | js: {
|
226 | files: ['src/js/*.js'],
|
227 | tasks: ['eslint', 'concat', 'copy:js', 'uglify']
|
228 | },
|
229 | livereload: {
|
230 | files: ['dist/css/*.css', 'dist/js/*.js', 'dist/tests/*.html', '!tests/pages/*.html']
|
231 | },
|
232 | options: {
|
233 | livereload: true
|
234 | }
|
235 | },
|
236 | karma: {
|
237 | unit: {
|
238 | configFile: 'karma.conf.js'
|
239 | }
|
240 | },
|
241 | htmlhint: {
|
242 | html: {
|
243 | src: ['dist/tests/**/*.html'],
|
244 | options: {
|
245 | htmlhintrc: '.htmlhintrc'
|
246 | }
|
247 | }
|
248 | },
|
249 | eslint: {
|
250 | options: {
|
251 | configFile: 'eslint.yaml'
|
252 | },
|
253 | target: [
|
254 | 'Gruntfile.js',
|
255 | 'src/js/**/*.js',
|
256 | 'tests/pages/_script/**/*.js'
|
257 | ]
|
258 | },
|
259 | stylelint: {
|
260 | src: ['src/less/*.less']
|
261 | },
|
262 | postcss: {
|
263 | options: {
|
264 | processors: [
|
265 | require('pixrem')(),
|
266 | require('autoprefixer')({browsers: ['last 3 versions', 'ie 9']})
|
267 | ]
|
268 | },
|
269 | dist: {
|
270 | files: [
|
271 | {
|
272 | expand: true,
|
273 | cwd: 'dist/css/',
|
274 | src: ['*.css'],
|
275 | dest: 'dist/css'
|
276 | }
|
277 | ]
|
278 | }
|
279 |
|
280 | }
|
281 | });
|
282 |
|
283 | grunt.registerTask('pages', 'Builds the PatternFly test pages.', function (_target) {
|
284 | var target = _target || process.env.PF_PAGE_BUILDER || 'script';
|
285 | var done;
|
286 | if (target === 'jekyll') {
|
287 | grunt.log.writeln('Builidng test pages with ruby jekyll');
|
288 | grunt.task.run('run:bundleInstall', 'jekyll');
|
289 | } else if (target === 'script') {
|
290 | grunt.log.writeln('Builidng test pages with liquid.js');
|
291 | done = this.async();
|
292 | pageBuilder.build()
|
293 | .then(function () {
|
294 | done();
|
295 | });
|
296 | } else {
|
297 | grunt.log.writeln('Invalid taget:', target);
|
298 | }
|
299 | });
|
300 |
|
301 | grunt.registerTask('build', [
|
302 | 'clean',
|
303 | 'concat',
|
304 | 'copy',
|
305 | 'pages',
|
306 | 'less',
|
307 | 'cssmin',
|
308 | 'postcss',
|
309 | 'csscount',
|
310 | 'eslint',
|
311 | 'uglify',
|
312 | 'htmlhint',
|
313 | 'stylelint'
|
314 | ]);
|
315 |
|
316 | grunt.registerTask('serve', [
|
317 | 'connect:server',
|
318 | 'open',
|
319 | 'watch'
|
320 | ]);
|
321 |
|
322 | grunt.registerTask('open', function () {
|
323 | open('http://localhost:9000');
|
324 | });
|
325 |
|
326 | grunt.registerTask('server', function () {
|
327 | grunt.log.warn('The `server` task has been deprecated. Use `grunt serve` to start a server.');
|
328 | grunt.task.run(['serve']);
|
329 | });
|
330 |
|
331 | grunt.registerTask('default', ['build']);
|
332 | };
|