Heat: support create and attach volume in heat type context
[yardstick.git] / gui / Gruntfile.js
1 // Generated on 2017-05-31 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'],
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                 ]
67             }
68         },
69
70         // The actual grunt server settings
71         connect: {
72             options: {
73                 port: 9099,
74                 // Change this to '0.0.0.0' to access the server from outside.
75                 hostname: 'localhost',
76                 livereload: 35745
77             },
78             livereload: {
79                 options: {
80                     open: true,
81                     middleware: function(connect) {
82                         return [
83                             connect.static('.tmp'),
84                             connect().use(
85                                 '/bower_components',
86                                 connect.static('./bower_components')
87                             ),
88                             connect().use(
89                                 '/app/styles',
90                                 connect.static('./app/styles')
91                             ),
92                             connect.static(appConfig.app)
93                         ];
94                     }
95                 }
96             },
97             test: {
98                 options: {
99                     port: 9001,
100                     middleware: function(connect) {
101                         return [
102                             connect.static('.tmp'),
103                             connect.static('test'),
104                             connect().use(
105                                 '/bower_components',
106                                 connect.static('./bower_components')
107                             ),
108                             connect.static(appConfig.app)
109                         ];
110                     }
111                 }
112             },
113             dist: {
114                 options: {
115                     open: true,
116                     base: '<%= yeoman.dist %>'
117                 }
118             }
119         },
120
121         // Make sure there are no obvious mistakes
122         jshint: {
123             options: {
124                 jshintrc: '.jshintrc',
125                 reporter: require('jshint-stylish')
126             },
127             all: {
128                 src: [
129                     'Gruntfile.js',
130                     '<%= yeoman.app %>/scripts/{,*/}*.js'
131                 ]
132             },
133             test: {
134                 options: {
135                     jshintrc: 'test/.jshintrc'
136                 },
137                 src: ['test/spec/{,*/}*.js']
138             }
139         },
140
141         // Make sure code styles are up to par
142         jscs: {
143             options: {
144                 config: '.jscsrc',
145                 verbose: true
146             },
147             all: {
148                 src: [
149                     'Gruntfile.js',
150                     '<%= yeoman.app %>/scripts/{,*/}*.js'
151                 ]
152             },
153             test: {
154                 src: ['test/spec/{,*/}*.js']
155             }
156         },
157
158         // Empties folders to start fresh
159         clean: {
160             dist: {
161                 files: [{
162                     dot: true,
163                     src: [
164                         '.tmp',
165                         '<%= yeoman.dist %>/{,*/}*',
166                         '!<%= yeoman.dist %>/.git{,*/}*'
167                     ]
168                 }]
169             },
170             server: '.tmp'
171         },
172
173         // Add vendor prefixed styles
174         postcss: {
175             options: {
176                 processors: [
177                     require('autoprefixer-core')({ browsers: ['last 1 version'] })
178                 ]
179             },
180             server: {
181                 options: {
182                     map: true
183                 },
184                 files: [{
185                     expand: true,
186                     cwd: '.tmp/styles/',
187                     src: '{,*/}*.css',
188                     dest: '.tmp/styles/'
189                 }]
190             },
191             dist: {
192                 files: [{
193                     expand: true,
194                     cwd: '.tmp/styles/',
195                     src: '{,*/}*.css',
196                     dest: '.tmp/styles/'
197                 }]
198             }
199         },
200
201         // Automatically inject Bower components into the app
202         wiredep: {
203             app: {
204                 src: ['<%= yeoman.app %>/index.html'],
205                 ignorePath: /\.\.\//
206             },
207             test: {
208                 devDependencies: true,
209                 src: '<%= karma.unit.configFile %>',
210                 ignorePath: /\.\.\//,
211                 fileTypes: {
212                     js: {
213                         block: /(([\s\t]*)\/{2}\s*?bower:\s*?(\S*))(\n|\r|.)*?(\/{2}\s*endbower)/gi,
214                         detect: {
215                             js: /'(.*\.js)'/gi
216                         },
217                         replace: {
218                             js: '\'{{filePath}}\','
219                         }
220                     }
221                 }
222             }
223         },
224
225         // Renames files for browser caching purposes
226         filerev: {
227             dist: {
228                 src: [
229                     '<%= yeoman.dist %>/scripts/{,*/}*.js',
230                     '<%= yeoman.dist %>/styles/{,*/}*.css',
231                     '<%= yeoman.dist %>/images/{,*/}*.{png,jpg,jpeg,gif,webp,svg}',
232                     '<%= yeoman.dist %>/styles/fonts/*'
233                 ]
234             }
235         },
236
237         // Reads HTML for usemin blocks to enable smart builds that automatically
238         // concat, minify and revision files. Creates configurations in memory so
239         // additional tasks can operate on them
240         useminPrepare: {
241             html: '<%= yeoman.app %>/index.html',
242             options: {
243                 dest: '<%= yeoman.dist %>',
244                 flow: {
245                     html: {
246                         steps: {
247                             js: ['concat', 'uglifyjs'],
248                             css: ['cssmin']
249                         },
250                         post: {}
251                     }
252                 }
253             }
254         },
255
256         // Performs rewrites based on filerev and the useminPrepare configuration
257         usemin: {
258             html: ['<%= yeoman.dist %>/{,*/}*.html'],
259             css: ['<%= yeoman.dist %>/styles/{,*/}*.css'],
260             js: ['<%= yeoman.dist %>/scripts/{,*/}*.js'],
261             options: {
262                 assetsDirs: [
263                     '<%= yeoman.dist %>',
264                     '<%= yeoman.dist %>/images',
265                     '<%= yeoman.dist %>/styles'
266                 ],
267                 patterns: {
268                     js: [
269                         [/(images\/[^''""]*\.(png|jpg|jpeg|gif|webp|svg))/g, 'Replacing references to images']
270                     ]
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         },
311
312         svgmin: {
313             dist: {
314                 files: [{
315                     expand: true,
316                     cwd: '<%= yeoman.app %>/images',
317                     src: '{,*/}*.svg',
318                     dest: '<%= yeoman.dist %>/images'
319                 }]
320             }
321         },
322
323         htmlmin: {
324             dist: {
325                 options: {
326                     collapseWhitespace: true,
327                     conservativeCollapse: true,
328                     collapseBooleanAttributes: true,
329                     removeCommentsFromCDATA: true
330                 },
331                 files: [{
332                     expand: true,
333                     cwd: '<%= yeoman.dist %>',
334                     src: ['*.html'],
335                     dest: '<%= yeoman.dist %>'
336                 }]
337             }
338         },
339
340         ngtemplates: {
341             dist: {
342                 options: {
343                     module: 'yardStickGui2App',
344                     htmlmin: '<%= htmlmin.dist.options %>',
345                     usemin: 'scripts/scripts.js'
346                 },
347                 cwd: '<%= yeoman.app %>',
348                 src: 'views/{,*/}*.html',
349                 dest: '.tmp/templateCache.js'
350             }
351         },
352
353         // ng-annotate tries to make the code safe for minification automatically
354         // by using the Angular long form for dependency injection.
355         ngAnnotate: {
356             dist: {
357                 files: [{
358                     expand: true,
359                     cwd: '.tmp/concat/scripts',
360                     src: '*.js',
361                     dest: '.tmp/concat/scripts'
362                 }]
363             }
364         },
365
366         // Replace Google CDN references
367         cdnify: {
368             dist: {
369                 html: ['<%= yeoman.dist %>/*.html']
370             }
371         },
372
373         // Copies remaining files to places other tasks can use
374         copy: {
375             dist: {
376                 files: [{
377                         expand: true,
378                         dot: true,
379                         cwd: '<%= yeoman.app %>',
380                         dest: '<%= yeoman.dist %>',
381                         src: [
382                             '*.{ico,png,txt}',
383                             '*.html',
384                             'images/{,*/}*.{webp}',
385                             'styles/fonts/{,*/}*.*'
386                         ]
387                     }, {
388                         expand: true,
389                         cwd: '.tmp/images',
390                         dest: '<%= yeoman.dist %>/images',
391                         src: ['generated/*']
392                     }, {
393                         expand: true,
394                         cwd: 'bower_components/bootstrap/dist',
395                         src: 'fonts/*',
396                         dest: '<%= yeoman.dist %>'
397                     },
398                     {
399                         expand: true,
400                         cwd: 'bower_components/components-font-awesome',
401                         src: 'fonts/*',
402                         dest: '<%=yeoman.dist%>'
403                     }
404                 ]
405             },
406             styles: {
407                 expand: true,
408                 cwd: '<%= yeoman.app %>/styles',
409                 dest: '.tmp/styles/',
410                 src: '{,*/}*.css'
411             }
412         },
413
414         // Run some tasks in parallel to speed up the build process
415         concurrent: {
416             server: [
417                 'copy:styles'
418             ],
419             test: [
420                 'copy:styles'
421             ],
422             dist: [
423                 'copy:styles',
424                 'imagemin',
425                 'svgmin'
426             ]
427         },
428
429         // Test settings
430         karma: {
431             unit: {
432                 configFile: 'test/karma.conf.js',
433                 singleRun: true
434             }
435         }
436     });
437
438
439     grunt.registerTask('serve', 'Compile then start a connect web server', function(target) {
440         if (target === 'dist') {
441             return grunt.task.run(['build', 'connect:dist:keepalive']);
442         }
443
444         grunt.task.run([
445             'clean:server',
446             'wiredep',
447             'concurrent:server',
448             'postcss:server',
449             'connect:livereload',
450             'watch'
451         ]);
452     });
453
454     grunt.registerTask('server', 'DEPRECATED TASK. Use the "serve" task instead', function(target) {
455         grunt.log.warn('The `server` task has been deprecated. Use `grunt serve` to start a server.');
456         grunt.task.run(['serve:' + target]);
457     });
458
459     grunt.registerTask('test', [
460         'clean:server',
461         'wiredep',
462         'concurrent:test',
463         'postcss',
464         'connect:test',
465         'karma'
466     ]);
467
468     grunt.registerTask('build', [
469         'clean:dist',
470         'wiredep',
471         'useminPrepare',
472         'concurrent:dist',
473         'postcss',
474         'ngtemplates',
475         'concat',
476         'ngAnnotate',
477         'copy:dist',
478         // 'cdnify',
479         'cssmin',
480         'uglify',
481         'filerev',
482         'usemin',
483         'htmlmin'
484     ]);
485
486     grunt.registerTask('default', [
487         'newer:jshint',
488         'newer:jscs',
489         'test',
490         'build'
491     ]);
492 };