Merge "Add qtip job to pod zte-virtual6"
[releng.git] / utils / test / reporting / pages / Gruntfile.js
1 // Generated on 2016-12-19 using generator-angular 0.15.1
2 'use strict';
3
4 // # Globbing
5 // for performance reasons we're only matching one level down:
6 // 'test/spec/{,*/}*.js'
7 // use this if you want to recursively match all subfolders:
8 // 'test/spec/**/*.js'
9
10 module.exports = function (grunt) {
11
12   // Time how long tasks take. Can help when optimizing build times
13   require('time-grunt')(grunt);
14
15   // Automatically load required Grunt tasks
16   require('jit-grunt')(grunt, {
17     useminPrepare: 'grunt-usemin',
18     ngtemplates: 'grunt-angular-templates',
19     cdnify: 'grunt-google-cdn'
20   });
21
22   // Configurable paths for the application
23   var appConfig = {
24     app: require('./bower.json').appPath || 'app',
25     dist: 'dist'
26   };
27
28   // Define the configuration for all the tasks
29   grunt.initConfig({
30
31     // Project settings
32     yeoman: appConfig,
33
34     // Watches files for changes and runs tasks based on the changed files
35     watch: {
36       bower: {
37         files: ['bower.json'],
38         tasks: ['wiredep']
39       },
40       js: {
41         files: ['<%= yeoman.app %>/scripts/{,*/}*.js'],
42         tasks: ['newer:jshint:all', 'newer:jscs:all'],
43         options: {
44           livereload: '<%= connect.options.livereload %>'
45         }
46       },
47       jsTest: {
48         files: ['test/spec/{,*/}*.js'],
49         tasks: ['newer:jshint:test', 'newer:jscs:test', 'karma']
50       },
51       styles: {
52         files: ['<%= yeoman.app %>/styles/{,*/}*.css','<%= yeoman.app %>/styles/font-awesome/css/{,*/}*.css'],
53         tasks: ['newer:copy:styles', 'postcss']
54       },
55       gruntfile: {
56         files: ['Gruntfile.js']
57       },
58       livereload: {
59         options: {
60           livereload: '<%= connect.options.livereload %>'
61         },
62         files: [
63           '<%= yeoman.app %>/{,*/}*.html',
64           '.tmp/styles/{,*/}*.css',
65           '<%= yeoman.app %>/images/{,*/}*.{png,jpg,jpeg,gif,webp,svg}',
66           '<%= yeoman.app %>/views/{,*/}*.html'
67
68         ]
69       }
70     },
71
72     // The actual grunt server settings
73     connect: {
74       options: {
75         port: 9000,
76         // Change this to '0.0.0.0' to access the server from outside.
77         hostname: 'localhost',
78         livereload: 35729
79       },
80       livereload: {
81         options: {
82           open: true,
83           middleware: function (connect) {
84             return [
85               connect.static('.tmp'),
86               connect().use(
87                 '/bower_components',
88                 connect.static('./bower_components')
89               ),
90               connect().use(
91                 '/app/styles',
92                 connect.static('./app/styles')
93               ),
94               connect.static(appConfig.app)
95             ];
96           }
97         }
98       },
99       test: {
100         options: {
101           port: 9001,
102           middleware: function (connect) {
103             return [
104               connect.static('.tmp'),
105               connect.static('test'),
106               connect().use(
107                 '/bower_components',
108                 connect.static('./bower_components')
109               ),
110               connect.static(appConfig.app)
111             ];
112           }
113         }
114       },
115       dist: {
116         options: {
117           open: true,
118           base: '<%= yeoman.dist %>'
119         }
120       }
121     },
122
123     // Make sure there are no obvious mistakes
124     jshint: {
125       options: {
126         jshintrc: '.jshintrc',
127         reporter: require('jshint-stylish')
128       },
129       all: {
130         src: [
131           'Gruntfile.js',
132           '<%= yeoman.app %>/scripts/{,*/}*.js'
133         ]
134       },
135       test: {
136         options: {
137           jshintrc: 'test/.jshintrc'
138         },
139         src: ['test/spec/{,*/}*.js']
140       }
141     },
142
143     // Make sure code styles are up to par
144     jscs: {
145       options: {
146         config: '.jscsrc',
147         verbose: true
148       },
149       all: {
150         src: [
151           'Gruntfile.js',
152           '<%= yeoman.app %>/scripts/{,*/}*.js'
153         ]
154       },
155       test: {
156         src: ['test/spec/{,*/}*.js']
157       }
158     },
159
160     // Empties folders to start fresh
161     clean: {
162       dist: {
163         files: [{
164           dot: true,
165           src: [
166             '.tmp',
167             '<%= yeoman.dist %>/{,*/}*',
168             '!<%= yeoman.dist %>/.git{,*/}*'
169           ]
170         }]
171       },
172       server: '.tmp'
173     },
174
175     // Add vendor prefixed styles
176     postcss: {
177       options: {
178         processors: [
179           require('autoprefixer-core')({ browsers: ['last 1 version'] })
180         ]
181       },
182       server: {
183         options: {
184           map: true
185         },
186         files: [{
187           expand: true,
188           cwd: '.tmp/styles/',
189           src: '{,*/}*.css',
190           dest: '.tmp/styles/'
191         }]
192       },
193       dist: {
194         files: [{
195           expand: true,
196           cwd: '.tmp/styles/',
197           src: '{,*/}*.css',
198           dest: '.tmp/styles/'
199         }]
200       }
201     },
202
203     // Automatically inject Bower components into the app
204     wiredep: {
205       app: {
206         src: ['<%= yeoman.app %>/index.html'],
207         ignorePath: /\.\.\//
208       },
209       test: {
210         devDependencies: true,
211         src: '<%= karma.unit.configFile %>',
212         ignorePath: /\.\.\//,
213         fileTypes: {
214           js: {
215             block: /(([\s\t]*)\/{2}\s*?bower:\s*?(\S*))(\n|\r|.)*?(\/{2}\s*endbower)/gi,
216             detect: {
217               js: /'(.*\.js)'/gi
218             },
219             replace: {
220               js: '\'{{filePath}}\','
221             }
222           }
223         }
224       }
225     },
226
227     // Renames files for browser caching purposes
228     filerev: {
229       dist: {
230         src: [
231           '<%= yeoman.dist %>/scripts/{,*/}*.js',
232           '<%= yeoman.dist %>/styles/{,*/}*.css',
233           '<%= yeoman.dist %>/images/{,*/}*.{png,jpg,jpeg,gif,webp,svg}',
234           '<%= yeoman.dist %>/styles/fonts/*'
235         ]
236       }
237     },
238
239     // Reads HTML for usemin blocks to enable smart builds that automatically
240     // concat, minify and revision files. Creates configurations in memory so
241     // additional tasks can operate on them
242     useminPrepare: {
243       html: '<%= yeoman.app %>/index.html',
244       options: {
245         dest: '<%= yeoman.dist %>',
246         flow: {
247           html: {
248             steps: {
249               js: ['concat', 'uglifyjs'],
250               css: ['cssmin']
251             },
252             post: {}
253           }
254         }
255       }
256     },
257
258     // Performs rewrites based on filerev and the useminPrepare configuration
259     usemin: {
260       html: ['<%= yeoman.dist %>/{,*/}*.html'],
261       css: ['<%= yeoman.dist %>/styles/{,*/}*.css'],
262       js: ['<%= yeoman.dist %>/scripts/{,*/}*.js'],
263       options: {
264         assetsDirs: [
265           '<%= yeoman.dist %>',
266           '<%= yeoman.dist %>/images',
267           '<%= yeoman.dist %>/styles'
268         ],
269         patterns: {
270           js: [[/(images\/[^''""]*\.(png|jpg|jpeg|gif|webp|svg))/g, 'Replacing references to images']]
271         }
272       }
273     },
274
275     // The following *-min tasks will produce minified files in the dist folder
276     // By default, your `index.html`'s <!-- Usemin block --> will take care of
277     // minification. These next options are pre-configured if you do not wish
278     // to use the Usemin blocks.
279     // cssmin: {
280     //   dist: {
281     //     files: {
282     //       '<%= yeoman.dist %>/styles/main.css': [
283     //         '.tmp/styles/{,*/}*.css'
284     //       ]
285     //     }
286     //   }
287     // },
288     // uglify: {
289     //   dist: {
290     //     files: {
291     //       '<%= yeoman.dist %>/scripts/scripts.js': [
292     //         '<%= yeoman.dist %>/scripts/scripts.js'
293     //       ]
294     //     }
295     //   }
296     // },
297     // concat: {
298     //   dist: {}
299     // },
300
301     imagemin: {
302       dist: {
303         files: [{
304           expand: true,
305           cwd: '<%= yeoman.app %>/images',
306           src: '{,*/}*.{png,jpg,jpeg,gif}',
307           dest: '<%= yeoman.dist %>/images'
308         }]
309       }
310       // dist:{
311       //   files:[{
312       //     expand:true,
313       //     cwd:'<%= yeoman.app %>/bower_components/',
314       //     src:'**/*.{png,jpg,gif}',
315       //     dest: '<%= yeoman.dist %>/styles'
316       //   }
317
318       //   ]
319       // }
320     },
321
322     // bowerimagemin:{
323     //   dist:{
324     //     files:[{
325     //       expand: true,
326     // cwd: '<%= yeoman.app %>/bower_components',
327     //       src:'{,*/}*.{png,jpg,jpeg,gif}',
328     //       dest: '<%= yeoman.dist %>/styles'
329     //     }
330
331     //     ]
332     //   }
333     // },
334
335
336     svgmin: {
337       dist: {
338         files: [{
339           expand: true,
340           cwd: '<%= yeoman.app %>/images',
341           src: '{,*/}*.svg',
342           dest: '<%= yeoman.dist %>/images'
343         }]
344       }
345     },
346
347     htmlmin: {
348       dist: {
349         options: {
350           collapseWhitespace: true,
351           conservativeCollapse: true,
352           collapseBooleanAttributes: true,
353           removeCommentsFromCDATA: true
354         },
355         files: [{
356           expand: true,
357           cwd: '<%= yeoman.dist %>',
358           src: ['*.html'],
359           dest: '<%= yeoman.dist %>'
360         }]
361       }
362     },
363
364     ngtemplates: {
365       dist: {
366         options: {
367           module: 'opnfvApp',
368           htmlmin: '<%= htmlmin.dist.options %>',
369           usemin: 'scripts/scripts.js'
370         },
371         cwd: '<%= yeoman.app %>',
372         src: 'views/{,*/}*.html',
373         dest: '.tmp/templateCache.js'
374       }
375     },
376
377     // ng-annotate tries to make the code safe for minification automatically
378     // by using the Angular long form for dependency injection.
379     ngAnnotate: {
380       dist: {
381         files: [{
382           expand: true,
383           cwd: '.tmp/concat/scripts',
384           src: '*.js',
385           dest: '.tmp/concat/scripts'
386         }]
387       }
388     },
389
390     // Replace Google CDN references
391     cdnify: {
392       dist: {
393         html: ['<%= yeoman.dist %>/*.html']
394       }
395     },
396
397     // Copies remaining files to places other tasks can use
398     copy: {
399       dist: {
400         files: [{
401           expand: true,
402           dot: true,
403           cwd: '<%= yeoman.app %>',
404           dest: '<%= yeoman.dist %>',
405           src: [
406             '*.{ico,png,txt}',
407             '*.html',
408             'images/{,*/}*.{webp}',
409             'styles/fonts/{,*/}*.*'
410
411           ]
412         }, {
413           expand: true,
414           cwd: '.tmp/images',
415           dest: '<%= yeoman.dist %>/images',
416           src: ['generated/*']
417         }, {
418           expand: true,
419           cwd: 'bower_components/bootstrap/dist',
420           src: 'fonts/*',
421           dest: '<%= yeoman.dist %>'
422         },{
423           expand:true,
424           cwd:'bower_components/components-font-awesome',
425           src:'fonts/*',
426           dest: '<%=yeoman.dist%>'
427         }
428         ]
429       },
430       styles: {
431         expand: true,
432         cwd: '<%= yeoman.app %>/styles',
433         dest: '.tmp/styles/',
434         src: ['{,*/}*.css',
435           'bower_components/{,*/}*.{png,jpg,jpeg,gif}'
436         ]
437       }
438     },
439
440     // Run some tasks in parallel to speed up the build process
441     concurrent: {
442       server: [
443         'copy:styles'
444       ],
445       test: [
446         'copy:styles'
447       ],
448       dist: [
449         'copy:styles',
450
451         'imagemin',
452         'svgmin'
453       ]
454     },
455
456     // Test settings
457     karma: {
458       unit: {
459         configFile: 'test/karma.conf.js',
460         singleRun: true
461       }
462     }
463   });
464
465
466   grunt.registerTask('serve', 'Compile then start a connect web server', function (target) {
467     if (target === 'dist') {
468       return grunt.task.run(['build', 'connect:dist:keepalive']);
469     }
470
471     grunt.task.run([
472       'clean:server',
473       'wiredep',
474       'concurrent:server',
475       'postcss:server',
476       'connect:livereload',
477       'watch'
478     ]);
479   });
480
481   grunt.registerTask('server', 'DEPRECATED TASK. Use the "serve" task instead', function (target) {
482     grunt.log.warn('The `server` task has been deprecated. Use `grunt serve` to start a server.');
483     grunt.task.run(['serve:' + target]);
484   });
485
486   grunt.registerTask('test', [
487     'clean:server',
488     'wiredep',
489     'concurrent:test',
490     'postcss',
491     'connect:test',
492     'karma'
493   ]);
494
495   grunt.registerTask('build', [
496     'clean:dist',
497     'wiredep',
498     'useminPrepare',
499     'concurrent:dist',
500     'postcss',
501     'ngtemplates',
502     'concat',
503     'ngAnnotate',
504     'copy:dist',
505     // 'cdnify',
506     'cssmin',
507     'uglify',
508     'filerev',
509     'usemin',
510     'htmlmin'
511   ]);
512
513   grunt.registerTask('default', [
514     'newer:jshint',
515     'newer:jscs',
516     'test',
517     'build'
518   ]);
519 };