<commit_before>/* jshint indent: 2 */

// Generated on 2014-06-19 using generator-angular-fullstack 1.4.3
'use strict';

// # Globbing
// for performance reasons we're only matching one level down:
// 'test/spec/{,*/}*.js'
// use this if you want to recursively match all subfolders:
// 'test/spec/**/*.js'

module.exports = function (grunt) {

  // Load grunt tasks automatically
  require('load-grunt-tasks')(grunt);

  // Time how long tasks take. Can help when optimizing build times
  require('time-grunt')(grunt);

  // Define the configuration for all the tasks
  grunt.initConfig({

    // Project settings
    yeoman: {
      // configurable paths
      app: require('./bower.json').appPath || 'app',
      dist: 'dist'
    },
    express: {
      options: {
        port: process.env.PORT || 9000
      },
      dev: {
        options: {
          script: 'server.js',
          debug: true
        }
      },
      prod: {
        options: {
          script: 'dist/server.js',
          node_env: 'production'
        }
      }
    },
    open: {
      server: {
        url: 'http://localhost:<%= express.options.port %>'
      }
    },
    watch: {
      js: {
        files: ['<%= yeoman.app %>/js/**/*.js'],
        tasks: ['newer:jshint:all'],
        options: {
          livereload: true
        }
      },
      mochaTest: {
        files: ['test/server/{,*/}*.js'],
        tasks: ['env:test', 'mochaTest']
      },
      jsTest: {
        files: ['test/client/spec/**/*.js'],
        tasks: ['newer:jshint:test', 'karma']
      },
      compass: {
        files: ['<%= yeoman.app %>/styles/{,*/}*.{scss,sass}'],
        tasks: ['compass:server', 'autoprefixer']
      },
      gruntfile: {
        files: ['Gruntfile.js']
      },
      livereload: {
        files: [
          '<%= yeoman.app %>/views/{,*//*}*.html',
          '{.tmp,<%= yeoman.app %>}/styles/{,*//*}*.css',
          '{.tmp,<%= yeoman.app %>}/js/{,*//*}*.js',
          '<%= yeoman.app %>/img/{,*//*}*.{png,jpg,jpeg,gif,webp,svg}'
        ],

        options: {
          livereload: true
        }
      },
      express: {
        files: [
          'server.js',
          'lib/**/*.{js,json}'
        ],
        tasks: ['newer:jshint:server', 'express:dev', 'wait'],
        options: {
          livereload: true,
          nospawn: true //Without this option specified express won't be reloaded
        }
      }
    },

    // Make sure code styles are up to par and there are no obvious mistakes
    jshint: {
      options: {
        jshintrc: '.jshintrc',
        reporter: require('jshint-stylish'),
        ignores: ['<%= yeoman.app %>/js/common.js']
      },
      server: {
        options: {
          jshintrc: 'lib/.jshintrc'
        },
        src: ['lib/{,*/}*.js', '*.js']
      },
      all: [
        '<%= yeoman.app %>/js/{,*/}*.js'
      ],
      test: {
        options: {
          jshintrc: 'test/client/.jshintrc'
        },
        src: ['test/client/spec/{,*/}*.js']
      }
    },

    // Empties folders to start fresh
    clean: {
      dist: {
        files: [{
          dot: true,
          src: [
            '.tmp',
            '<%= yeoman.dist %>/*',
            '!<%= yeoman.dist %>/.git*',
            '!<%= yeoman.dist %>/Procfile'
          ]
        }]
      },
      heroku: {
        files: [{
          dot: true,
          src: [
            'heroku/*',
            '!heroku/.git*',
            '!heroku/Procfile'
          ]
        }]
      },
      server: '.tmp'
    },

    // Add vendor prefixed styles
    autoprefixer: {
      options: {
        browsers: ['last 1 version']
      },
      dist: {
        files: [{
          expand: true,
          cwd: '.tmp/styles/',
          src: '{,*/}*.css',
          dest: '.tmp/styles/'
        }]
      }
    },

    // Debugging with node inspector
    'node-inspector': {
      custom: {
        options: {
          'web-host': 'localhost'
        }
      }
    },

    // Use nodemon to run server in debug mode with an initial breakpoint
    nodemon: {
      debug: {
        script: 'server.js',
        options: {
          nodeArgs: ['--debug-brk'],
          env: {
            PORT: process.env.PORT || 9000
          },
          callback: function (nodemon) {
            nodemon.on('log', function (event) {
              console.log(event.colour);
            });

            // opens browser on initial server start
            nodemon.on('config:update', function () {
              setTimeout(function () {
                require('open')('http://localhost:8080/debug?port=5858');
              }, 500);
            });
          }
        }
      }
    },

    // Automatically inject Bower components into the app
    'bower-install': {
      app: {
        html: '<%= yeoman.app %>/views/front.html',
        ignorePath: '<%= yeoman.app %>/',
        exclude: ['bootstrap-sass', 'jquery']
      }
    },

    // Compiles Sass to CSS and generates necessary files if requested
    compass: {
      options: {
        sassDir: '<%= yeoman.app %>/styles',
        cssDir: '.tmp/styles',
        generatedImagesDir: '.tmp/img/generated',
        imagesDir: '<%= yeoman.app %>/img',
        javascriptsDir: '<%= yeoman.app %>/js',
        fontsDir: '<%= yeoman.app %>/styles/fonts',
        importPath: '<%= yeoman.app %>/bower_components',
        httpImagesPath: '/img',
        httpGeneratedImagesPath: '/img/generated',
        httpFontsPath: '/styles/fonts',
        relativeAssets: false,
        assetCacheBuster: false,
        raw: 'Sass::Script::Number.precision = 10\n'
      },
      dist: {
        options: {
          generatedImagesDir: '<%= yeoman.dist %>/public/img/generated'
        }
      },
      server: {
        options: {
          debugInfo: true
        }
      }
    },

    // Renames files for browser caching purposes
    rev: {
      dist: {
        files: {
          src: [
            '<%= yeoman.dist %>/public/js/{,*/}*.js',
            '<%= yeoman.dist %>/public/styles/{,*/}*.css',
            '<%= yeoman.dist %>/public/styles/fonts/*'
          ]
        }
      }
    },

    // Reads HTML for usemin blocks to enable smart builds that automatically
    // concat, minify and revision files. Creates configurations in memory so
    // additional tasks can operate on them
    useminPrepare: {
      html: ['<%= yeoman.app %>/views/front.html', '<%= yeoman.app %>/views/back.html'],
      options: {
        dest: '<%= yeoman.dist %>/public'
      }
    },

    // Performs rewrites based on rev and the useminPrepare configuration
    usemin: {
      html: ['<%= yeoman.dist %>/public/views/{,*/}*.html'],
      css: ['<%= yeoman.dist %>/public/styles/{,*/}*.css'],
      options: {
        assetsDirs: ['<%= yeoman.dist %>/public']
      }
    },

    // The following *-min tasks produce minified files in the dist folder
    imagemin: {
      options : {
        cache: false
      },
      dist: {
        files: [{
          expand: true,
          cwd: '<%= yeoman.app %>/img',
          src: '{,*/}*.{png,jpg,jpeg,gif}',
          dest: '<%= yeoman.dist %>/public/img'
        }]
      }
    },

    svgmin: {
      dist: {
        files: [{
          expand: true,
          cwd: '<%= yeoman.app %>/img',
          src: '{,*/}*.svg',
          dest: '<%= yeoman.dist %>/public/img'
        }]
      }
    },

    htmlmin: {
      dist: {
        options: {
          //collapseWhitespace: true,
          //collapseBooleanAttributes: true,
          //removeCommentsFromCDATA: true,
          //removeOptionalTags: true
        },
        files: [{
          expand: true,
          cwd: '<%= yeoman.app %>/views',
          src: ['*.html', 'partials/**/*.html'],
          dest: '<%= yeoman.dist %>/public/views'
        }]
      }
    },

    // Allow the use of non-minsafe AngularJS files. Automatically makes it
    // minsafe compatible so Uglify does not destroy the ng references
    ngmin: {
      dist: {
        files: [{
          expand: true,
          cwd: '.tmp/concat/js',
          src: '*.js',
          dest: '.tmp/concat/js'
        }]
      }
    },

    // Replace Google CDN references
    cdnify: {
      dist: {
        html: ['<%= yeoman.dist %>/public/views/*.html']
      }
    },

    // Copies remaining files to places other tasks can use
    copy: {
      dist: {
        files: [{
          expand: true,
          dot: true,
          cwd: '<%= yeoman.app %>',
          dest: '<%= yeoman.dist %>/public',
          src: [
            '*.{ico,png,txt}',
            '.htaccess',
            'bower_components/**/*',
            'images/{,*/}*.{webp}',
            'fonts/**/*'
          ]
        }, {
          expand: true,
          dot: true,
          cwd: '<%= yeoman.app %>/views',
          dest: '<%= yeoman.dist %>/public/views',
          src: '**/*.jade'
        }, {
          expand: true,
          cwd: '.tmp/img',
          dest: '<%= yeoman.dist %>/public/img',
          src: ['generated/*']
        }, {
          expand: true,
          dest: '<%= yeoman.dist %>',
          src: [
            'package.json',
            'server.js',
            'lib/**/*'
          ]
        }]
      },
      styles: {
        expand: true,
        cwd: '<%= yeoman.app %>/styles',
        dest: '.tmp/styles/',
        src: '{,*/}*.css'
      }
    },

    // Run some tasks in parallel to speed up the build process
    concurrent: {
      server: [
        'compass:server'
      ],
      test: [
        'compass'
      ],
      debug: {
        tasks: [
          'nodemon',
          'node-inspector'
        ],
        options: {
          logConcurrentOutput: true
        }
      },
      dist: [
        'compass:dist',
        'imagemin',
        'svgmin',
        'htmlmin'
      ]
    },

    // By default, your `index.html`'s <!-- Usemin block --> will take care of
    // minification. These next options are pre-configured if you do not wish
    // to use the Usemin blocks.
    // cssmin: {
    //   dist: {
    //     files: {
    //       '<%= yeoman.dist %>/styles/main.css': [
    //         '.tmp/styles/{,*/}*.css',
    //         '<%= yeoman.app %>/styles/{,*/}*.css'
    //       ]
    //     }
    //   }
    // },
    // uglify: {
    //   dist: {
    //     files: {
    //       '<%= yeoman.dist %>/js/js.js': [
    //         '<%= yeoman.dist %>/js/js.js'
    //       ]
    //     }
    //   }
    // },
    // concat: {
    //   dist: {}
    // },

    // Test settings
    karma: {
      unit: {
        configFile: 'karma.conf.js',
        singleRun: true
      }
    },

    mochaTest: {
      options: {
        reporter: 'spec'
      },
      src: ['test/server/**/*.js']
    },

    env: {
      test: {
        NODE_ENV: 'test'
      }
    }
  });

  // Used for delaying livereload until after server has restarted
  grunt.registerTask('wait', function () {
    grunt.log.ok('Waiting for server reload...');

    var done = this.async();

    setTimeout(function () {
      grunt.log.writeln('Done waiting!');
      done();
    }, 500);
  });

  grunt.registerTask('express-keepalive', 'Keep grunt running', function() {
    this.async();
  });

  grunt.registerTask('serve', function (target) {
    if (target === 'dist') {
      return grunt.task.run(['build', 'express:prod', 'open', 'express-keepalive']);
    }

    if (target === 'debug') {
      return grunt.task.run([
        'clean:server',
        'bower-install',
        'concurrent:server',
        'autoprefixer',
        'concurrent:debug'
      ]);
    }

    grunt.task.run([
      'clean:server',
      'bower-install',
      'concurrent:server',
      'autoprefixer',
      'express:dev',
      'open',
      'watch'
    ]);
  });

  grunt.registerTask('test', function(target) {
    if (target === 'server') {
      return grunt.task.run([
        'env:test',
        //'mochaTest'
      ]);
    }

    else if (target === 'client') {
      return grunt.task.run([
        'clean:server',
        'concurrent:test',
        'autoprefixer',
        'karma'
      ]);
    }

    else {
      grunt.task.run([
        'test:server',
        'test:client'
      ]);
    }
  });

  grunt.registerTask('build', [
    'clean:dist',
    'bower-install',
    'useminPrepare',
    'concurrent:dist',
    'autoprefixer',
    'concat',
    'ngmin',
    'copy:dist',
    'cdnify',
    'cssmin',
    'uglify',
    'rev',
    'usemin'
  ]);

  grunt.registerTask('default', [
    'newer:jshint',
    'test',
    'build'
  ]);
};
<commit_msg>grunt test répertoires récursifs<commit_after>/* jshint indent: 2 */

// Generated on 2014-06-19 using generator-angular-fullstack 1.4.3
'use strict';

// # Globbing
// for performance reasons we're only matching one level down:
// 'test/spec/{,*/}*.js'
// use this if you want to recursively match all subfolders:
// 'test/spec/**/*.js'

module.exports = function (grunt) {

  // Load grunt tasks automatically
  require('load-grunt-tasks')(grunt);

  // Time how long tasks take. Can help when optimizing build times
  require('time-grunt')(grunt);

  // Define the configuration for all the tasks
  grunt.initConfig({

    // Project settings
    yeoman: {
      // configurable paths
      app: require('./bower.json').appPath || 'app',
      dist: 'dist'
    },
    express: {
      options: {
        port: process.env.PORT || 9000
      },
      dev: {
        options: {
          script: 'server.js',
          debug: true
        }
      },
      prod: {
        options: {
          script: 'dist/server.js',
          node_env: 'production'
        }
      }
    },
    open: {
      server: {
        url: 'http://localhost:<%= express.options.port %>'
      }
    },
    watch: {
      js: {
        files: ['<%= yeoman.app %>/js/**/*.js'],
        tasks: ['newer:jshint:all'],
        options: {
          livereload: true
        }
      },
      mochaTest: {
        files: ['test/server/{,*/}*.js'],
        tasks: ['env:test', 'mochaTest']
      },
      jsTest: {
        files: ['test/client/spec/**/*.js'],
        tasks: ['newer:jshint:test', 'karma']
      },
      compass: {
        files: ['<%= yeoman.app %>/styles/{,*/}*.{scss,sass}'],
        tasks: ['compass:server', 'autoprefixer']
      },
      gruntfile: {
        files: ['Gruntfile.js']
      },
      livereload: {
        files: [
          '<%= yeoman.app %>/views/{,*//*}*.html',
          '{.tmp,<%= yeoman.app %>}/styles/{,*//*}*.css',
          '{.tmp,<%= yeoman.app %>}/js/{,*//*}*.js',
          '<%= yeoman.app %>/img/{,*//*}*.{png,jpg,jpeg,gif,webp,svg}'
        ],

        options: {
          livereload: true
        }
      },
      express: {
        files: [
          'server.js',
          'lib/**/*.{js,json}'
        ],
        tasks: ['newer:jshint:server', 'express:dev', 'wait'],
        options: {
          livereload: true,
          nospawn: true //Without this option specified express won't be reloaded
        }
      }
    },

    // Make sure code styles are up to par and there are no obvious mistakes
    jshint: {
      options: {
        jshintrc: '.jshintrc',
        reporter: require('jshint-stylish'),
        ignores: ['<%= yeoman.app %>/js/common.js']
      },
      server: {
        options: {
          jshintrc: 'lib/.jshintrc'
        },
        src: ['lib/{,*/}*.js', '*.js']
      },
      all: [
        '<%= yeoman.app %>/js/{,*/}*.js'
      ],
      test: {
        options: {
          jshintrc: 'test/client/.jshintrc'
        },
        src: ['test/client/spec/**/*.js']
      }
    },

    // Empties folders to start fresh
    clean: {
      dist: {
        files: [{
          dot: true,
          src: [
            '.tmp',
            '<%= yeoman.dist %>/*',
            '!<%= yeoman.dist %>/.git*',
            '!<%= yeoman.dist %>/Procfile'
          ]
        }]
      },
      heroku: {
        files: [{
          dot: true,
          src: [
            'heroku/*',
            '!heroku/.git*',
            '!heroku/Procfile'
          ]
        }]
      },
      server: '.tmp'
    },

    // Add vendor prefixed styles
    autoprefixer: {
      options: {
        browsers: ['last 1 version']
      },
      dist: {
        files: [{
          expand: true,
          cwd: '.tmp/styles/',
          src: '{,*/}*.css',
          dest: '.tmp/styles/'
        }]
      }
    },

    // Debugging with node inspector
    'node-inspector': {
      custom: {
        options: {
          'web-host': 'localhost'
        }
      }
    },

    // Use nodemon to run server in debug mode with an initial breakpoint
    nodemon: {
      debug: {
        script: 'server.js',
        options: {
          nodeArgs: ['--debug-brk'],
          env: {
            PORT: process.env.PORT || 9000
          },
          callback: function (nodemon) {
            nodemon.on('log', function (event) {
              console.log(event.colour);
            });

            // opens browser on initial server start
            nodemon.on('config:update', function () {
              setTimeout(function () {
                require('open')('http://localhost:8080/debug?port=5858');
              }, 500);
            });
          }
        }
      }
    },

    // Automatically inject Bower components into the app
    'bower-install': {
      app: {
        html: '<%= yeoman.app %>/views/front.html',
        ignorePath: '<%= yeoman.app %>/',
        exclude: ['bootstrap-sass', 'jquery']
      }
    },

    // Compiles Sass to CSS and generates necessary files if requested
    compass: {
      options: {
        sassDir: '<%= yeoman.app %>/styles',
        cssDir: '.tmp/styles',
        generatedImagesDir: '.tmp/img/generated',
        imagesDir: '<%= yeoman.app %>/img',
        javascriptsDir: '<%= yeoman.app %>/js',
        fontsDir: '<%= yeoman.app %>/styles/fonts',
        importPath: '<%= yeoman.app %>/bower_components',
        httpImagesPath: '/img',
        httpGeneratedImagesPath: '/img/generated',
        httpFontsPath: '/styles/fonts',
        relativeAssets: false,
        assetCacheBuster: false,
        raw: 'Sass::Script::Number.precision = 10\n'
      },
      dist: {
        options: {
          generatedImagesDir: '<%= yeoman.dist %>/public/img/generated'
        }
      },
      server: {
        options: {
          debugInfo: true
        }
      }
    },

    // Renames files for browser caching purposes
    rev: {
      dist: {
        files: {
          src: [
            '<%= yeoman.dist %>/public/js/{,*/}*.js',
            '<%= yeoman.dist %>/public/styles/{,*/}*.css',
            '<%= yeoman.dist %>/public/styles/fonts/*'
          ]
        }
      }
    },

    // Reads HTML for usemin blocks to enable smart builds that automatically
    // concat, minify and revision files. Creates configurations in memory so
    // additional tasks can operate on them
    useminPrepare: {
      html: ['<%= yeoman.app %>/views/front.html', '<%= yeoman.app %>/views/back.html'],
      options: {
        dest: '<%= yeoman.dist %>/public'
      }
    },

    // Performs rewrites based on rev and the useminPrepare configuration
    usemin: {
      html: ['<%= yeoman.dist %>/public/views/{,*/}*.html'],
      css: ['<%= yeoman.dist %>/public/styles/{,*/}*.css'],
      options: {
        assetsDirs: ['<%= yeoman.dist %>/public']
      }
    },

    // The following *-min tasks produce minified files in the dist folder
    imagemin: {
      options : {
        cache: false
      },
      dist: {
        files: [{
          expand: true,
          cwd: '<%= yeoman.app %>/img',
          src: '{,*/}*.{png,jpg,jpeg,gif}',
          dest: '<%= yeoman.dist %>/public/img'
        }]
      }
    },

    svgmin: {
      dist: {
        files: [{
          expand: true,
          cwd: '<%= yeoman.app %>/img',
          src: '{,*/}*.svg',
          dest: '<%= yeoman.dist %>/public/img'
        }]
      }
    },

    htmlmin: {
      dist: {
        options: {
          //collapseWhitespace: true,
          //collapseBooleanAttributes: true,
          //removeCommentsFromCDATA: true,
          //removeOptionalTags: true
        },
        files: [{
          expand: true,
          cwd: '<%= yeoman.app %>/views',
          src: ['*.html', 'partials/**/*.html'],
          dest: '<%= yeoman.dist %>/public/views'
        }]
      }
    },

    // Allow the use of non-minsafe AngularJS files. Automatically makes it
    // minsafe compatible so Uglify does not destroy the ng references
    ngmin: {
      dist: {
        files: [{
          expand: true,
          cwd: '.tmp/concat/js',
          src: '*.js',
          dest: '.tmp/concat/js'
        }]
      }
    },

    // Replace Google CDN references
    cdnify: {
      dist: {
        html: ['<%= yeoman.dist %>/public/views/*.html']
      }
    },

    // Copies remaining files to places other tasks can use
    copy: {
      dist: {
        files: [{
          expand: true,
          dot: true,
          cwd: '<%= yeoman.app %>',
          dest: '<%= yeoman.dist %>/public',
          src: [
            '*.{ico,png,txt}',
            '.htaccess',
            'bower_components/**/*',
            'images/{,*/}*.{webp}',
            'fonts/**/*'
          ]
        }, {
          expand: true,
          dot: true,
          cwd: '<%= yeoman.app %>/views',
          dest: '<%= yeoman.dist %>/public/views',
          src: '**/*.jade'
        }, {
          expand: true,
          cwd: '.tmp/img',
          dest: '<%= yeoman.dist %>/public/img',
          src: ['generated/*']
        }, {
          expand: true,
          dest: '<%= yeoman.dist %>',
          src: [
            'package.json',
            'server.js',
            'lib/**/*'
          ]
        }]
      },
      styles: {
        expand: true,
        cwd: '<%= yeoman.app %>/styles',
        dest: '.tmp/styles/',
        src: '{,*/}*.css'
      }
    },

    // Run some tasks in parallel to speed up the build process
    concurrent: {
      server: [
        'compass:server'
      ],
      test: [
        'compass'
      ],
      debug: {
        tasks: [
          'nodemon',
          'node-inspector'
        ],
        options: {
          logConcurrentOutput: true
        }
      },
      dist: [
        'compass:dist',
        'imagemin',
        'svgmin',
        'htmlmin'
      ]
    },

    // By default, your `index.html`'s <!-- Usemin block --> will take care of
    // minification. These next options are pre-configured if you do not wish
    // to use the Usemin blocks.
    // cssmin: {
    //   dist: {
    //     files: {
    //       '<%= yeoman.dist %>/styles/main.css': [
    //         '.tmp/styles/{,*/}*.css',
    //         '<%= yeoman.app %>/styles/{,*/}*.css'
    //       ]
    //     }
    //   }
    // },
    // uglify: {
    //   dist: {
    //     files: {
    //       '<%= yeoman.dist %>/js/js.js': [
    //         '<%= yeoman.dist %>/js/js.js'
    //       ]
    //     }
    //   }
    // },
    // concat: {
    //   dist: {}
    // },

    // Test settings
    karma: {
      unit: {
        configFile: 'karma.conf.js',
        singleRun: true
      }
    },

    mochaTest: {
      options: {
        reporter: 'spec'
      },
      src: ['test/server/**/*.js']
    },

    env: {
      test: {
        NODE_ENV: 'test'
      }
    }
  });

  // Used for delaying livereload until after server has restarted
  grunt.registerTask('wait', function () {
    grunt.log.ok('Waiting for server reload...');

    var done = this.async();

    setTimeout(function () {
      grunt.log.writeln('Done waiting!');
      done();
    }, 500);
  });

  grunt.registerTask('express-keepalive', 'Keep grunt running', function() {
    this.async();
  });

  grunt.registerTask('serve', function (target) {
    if (target === 'dist') {
      return grunt.task.run(['build', 'express:prod', 'open', 'express-keepalive']);
    }

    if (target === 'debug') {
      return grunt.task.run([
        'clean:server',
        'bower-install',
        'concurrent:server',
        'autoprefixer',
        'concurrent:debug'
      ]);
    }

    grunt.task.run([
      'clean:server',
      'bower-install',
      'concurrent:server',
      'autoprefixer',
      'express:dev',
      'open',
      'watch'
    ]);
  });

  grunt.registerTask('test', function(target) {
    if (target === 'server') {
      return grunt.task.run([
        'env:test',
        //'mochaTest'
      ]);
    }

    else if (target === 'client') {
      return grunt.task.run([
        'clean:server',
        'karma'
      ]);
    }

    else {
      grunt.task.run([
        'test:server',
        'test:client'
      ]);
    }
  });

  grunt.registerTask('build', [
    'clean:dist',
    'bower-install',
    'useminPrepare',
    'concurrent:dist',
    'autoprefixer',
    'concat',
    'ngmin',
    'copy:dist',
    'cdnify',
    'cssmin',
    'uglify',
    'rev',
    'usemin'
  ]);

  grunt.registerTask('default', [
    'newer:jshint',
    'test',
    'build'
  ]);
};
<|endoftext|>


<commit_before>'use strict';

var timeGrunt = require('time-grunt'),
    loadTasks = require('load-grunt-tasks');

var jspaths = {
  server: ['app.js', 'globals.js', 'test/**/*.js', 'lib/**/*.js', '!node_modules/**/*.js', '!build/**/*.js', '!dist/**/*.js'],
  build: ['Gruntfile.js']
};

module.exports = function (grunt) {

  // time grunt
  timeGrunt(grunt);

  grunt.initConfig({
    clean: {
      build: ['build']
    },
    jshint: {
      options: {
        jshintrc: true
      },
      server: jspaths.server,
      build: jspaths.build
    },
    watch: {
      server: {
        files: jspaths.server,
        tasks: ['server:dev']
      },
      build: {
        files: jspaths.build,
        tasks: ['build:dev']
      }
    },
    mochaTest: {
      options: {
        reporter: 'spec'
      },
      unit: {
        src: ['test/specs/**/*.js']
      },
      release: {
        src: ['test/integration/*.js']
      }
    }
  });

  // load tasks
  loadTasks(grunt);

  grunt.registerTask('build:dev', ['jshint:build']);
  grunt.registerTask('server:dev', ['jshint:server', 'mochaTest:unit']);
  grunt.registerTask('server:release', ['mochaTest:release']);

  grunt.registerTask('dev', ['build:dev', 'server:dev']);
  grunt.registerTask('release', ['dev', 'server:release']);

  grunt.registerTask('default', ['dev', 'watch']);
};
<commit_msg>Fixed task targets<commit_after>'use strict';

var timeGrunt = require('time-grunt'),
    loadTasks = require('load-grunt-tasks');

var jspaths = {
  server: ['app.js', 'globals.js', 'test/**/*.js', 'lib/**/*.js', '!node_modules/**/*.js', '!build/**/*.js', '!dist/**/*.js'],
  support: ['Gruntfile.js']
};

module.exports = function (grunt) {

  // time grunt
  timeGrunt(grunt);

  grunt.initConfig({
    clean: {
      build: ['build']
    },
    jshint: {
      options: {
        jshintrc: true
      },
      server: jspaths.server,
      support: jspaths.support
    },
    watch: {
      server: {
        files: jspaths.server,
        tasks: ['server:debug']
      },
      support: {
        files: jspaths.support,
        tasks: ['support:debug']
      }
    },
    mochaTest: {
      options: {
        reporter: 'spec'
      },
      debug: {
        src: ['test/specs/**/*.js']
      },
      release: {
        src: ['test/integration/*.js']
      }
    }
  });

  // load tasks
  loadTasks(grunt);

  grunt.registerTask('support:debug', ['jshint:support']);
  grunt.registerTask('server:debug', ['jshint:server', 'mochaTest:debug']);
  grunt.registerTask('server:release', ['mochaTest:release']);

  grunt.registerTask('debug', 'runs debug tasks and watches for changes', ['support:debug', 'server:debug']);
  grunt.registerTask('release', 'runs release tasks ready for release', ['debug', 'server:release']);

  grunt.registerTask('default', 'runs debug tasks', ['debug', 'watch']);
};
<|endoftext|>


<commit_before>/*
 * @author     Martin Høgh <mh@mapcentia.com>
 * @copyright  2013-2018 MapCentia ApS
 * @license    http://www.gnu.org/licenses/#AGPL  GNU AFFERO GENERAL PUBLIC LICENSE 3
 */

var fs = require('fs');

module.exports = function (grunt) {
    "use strict";

    // Detecting optional theme
    let theme = false;
    process.argv.forEach(val => {
        if (val.indexOf(`--theme=`) !== -1) {
            theme = val.replace(`--theme=`, ``);
        }
    });

    // Default build parameters
    let copyBootstrapVariablesCommand = 'cp ./config/_variables.less ./public/js/lib/bootstrap-material-design/less';
    let lessConfig = {"public/css/styles.css": "public/less/styles.default.less"};
    if (theme && theme === 'watsonc') {
        copyBootstrapVariablesCommand = 'cp ./extensions/' + theme + '/config/_variables.less ./public/js/lib/bootstrap-material-design/less';
        lessConfig = {"public/css/styles.css": "public/less/styles." + theme + ".less"};
    }

    grunt.initConfig({
        pkg: grunt.file.readJSON('package.json'),
        env: {
            prod: {
                NODE_ENV: 'production'
            }
        },
        version: {
            options: {
                prefix: '"version":"'
            },
            defaults: {
                src: ['public/version.json']
            }
        },
        less: {
            publish: {
                options: {
                    compress: false,
                    optimization: 2
                },
                files: [
                    lessConfig,
                    {
                        expand: true,        // Enable dynamic expansion.
                        cwd: 'extensions',  // Src matches are relative to this path.
                        src: ['**/less/*.less',],     // Actual pattern(s) to match.
                        dest: 'public/css/extensions',  // Destination path prefix.
                        ext: '.css',         // Dest filepaths will have this extension.
                    }
                ]
            }
        },
        cssmin: {
            build: {
                options: {
                    target: "./build",
                    rebase: true
                },
                files: {
                    'public/css/build/all.min.css': [
                        // Material Design fonts
                        'public/fonts/fonts.css',
                        'public/icons/material-icons.css',
                        // jQuery UI
                        'public/js/lib/jquery-ui/jquery-ui.min.css',
                        // Font Awesome
                        'public/css/font-awesome.min.css',
                        'public/css/font-awesome.v520.solid.css',
                        'public/css/font-awesome.v520.regular.css',
                        'public/css/font-awesome.v520.css',
                        // Leaflet
                        'public/js/lib/leaflet/leaflet.css',
                        'public/js/lib/leaflet-draw/leaflet.draw.css',
                        'public/js/lib/leaflet.locatecontrol/L.Control.Locate.css',
                        'public/js/lib/leaflet.toolbar/leaflet.toolbar.css',
                        'public/js/lib/leaflet-measure-path/leaflet-measure-path.css',
                        'public/js/lib/leaflet-history/leaflet-history.css',
                        'public/js/lib/leaflet-boxzoom/leaflet-boxzoom.css',
                        'public/js/lib/Leaflet.awesome-markers/leaflet.awesome-markers.css',
                        // Bootstrap
                        'public/js/lib/bootstrap/dist/css/bootstrap.css',
                        'public/js/lib/snackbarjs/snackbar.min.css',
                        'public/js/lib/bootstrap-material-design/dist/css/ripples.css',
                        'public/js/lib/bootstrap-material-datetimepicker/bootstrap-material-datetimepicker.css',
                        'public/js/lib/bootstrap-select/bootstrap-select.css',
                        'public/js/lib/bootstrap-table/bootstrap-table.css',
                        'public/js/lib/bootstrap-material-design/dist/css/bootstrap-material-design.css',
                        'public/js/lib/bootstrap-colorpicker/css/bootstrap-colorpicker.css',
                        //custom
                        'public/css/styles.min.css'
                    ]
                }
            },
            extensions: {
                options: {
                    target: "./build",
                    rebase: true
                },
                files: {
                    'public/css/styles.min.css': [
                        'public/css/styles.css',
                        'public/css/extensions/**/less/*.css'
                    ]
                }
            }

        },
        jshint: {
            options: {
                funcscope: true,
                shadow: true,
                evil: true,
                validthis: true,
                asi: true,
                newcap: false,
                notypeof: false,
                eqeqeq: false,
                loopfunc: true,
                es3: true,
                devel: false,
                eqnull: true
            },
            all: ['public/js/*.js']
        },
        hogan: {
            publish: {
                options: {
                    defaultName: function (filename) {
                        return filename.split('/').pop();
                    }
                },
                files: {
                    "public/js/templates.js": [
                        "public/templates/**/*.tmpl",
                        "extensions/**/templates/*.tmpl"
                    ]
                }
            }
        },
        handlebars: {
            publish: {
                options: {
                    namespace: function (filename) {
                        var names = filename.replace(/modules\/(.*)(\/\w+\.hbs)/, '$1');
                        return names.split('/').join('.');
                    },
                    commonjs: true
                },
                files: {
                    "public/js/handlebars_templates.js": [
                        "extensions/**/templates/*.hbs"
                    ]
                }
            }
        },
        browserify: {
            publish: {
                files: {
                    'public/js/bundle.js': ['browser/index.js'],
                },
                options: {
                    browserifyOptions: {
                        debug: false
                    },
                    transform: [['babelify', {
                        presets: [['es2015'], ['react'], ['stage-0']],
                        plugins: ["transform-object-rest-spread"]
                    }], 'require-globify', 'windowify', 'envify']
                }
            },
            publish_sw: {
                files: {
                    'public/service-worker.bundle.js': ['browser/service-worker/index.js']
                },
                options: {
                    alias: {
                        'urls-to-cache': './browser/service-worker/cache.production.js'
                    },
                    transform: [['babelify', {
                        presets: [['es2015'], ['react'], ['stage-0']],
                        plugins: ["transform-object-rest-spread"]
                    }], 'require-globify']
                }
            },
            publish_sw_dev: {
                files: {
                    'public/service-worker.bundle.js': ['browser/service-worker/index.js']
                },
                options: {
                    alias: {
                        'urls-to-cache': './browser/service-worker/cache.development.js'
                    },
                    transform: [['babelify', {
                        presets: [['es2015'], ['react'], ['stage-0']],
                        plugins: ["transform-object-rest-spread"]
                    }], 'require-globify']
                }
            },
            watch: {
                files: {
                    'public/js/bundle.js': ['browser/index.js']
                },
                options: {
                    transform: [['babelify', {
                        presets: [['es2015'], ['react'], ['stage-0']],
                        plugins: ["transform-object-rest-spread"]
                    }], 'require-globify', 'windowify'],
                    watch: true,
                    keepAlive: true,
                    browserifyOptions: {
                        debug: true
                    }
                }
            }
        },
        uglify: {
            publish: {
                options: {
                    sourceMap: true,
                    sourceMapIncludeSources: true,
                    compress: {
                        dead_code: true,
                        drop_debugger: true,
                        global_defs: {
                            "DEBUG": false
                        },
                    }
                },
                files: {
                    'public/js/build/all.min.js': [
                        'public/js/lib/leaflet/leaflet-src.js',
                        'public/js/lib/leaflet-history/leaflet-history.js',
                        'public/js/lib/leaflet-boxzoom/leaflet-boxzoom.js',
                        'public/js/lib/leaflet-draw/leaflet.draw.js',
                        'public/js/lib/leaflet.locatecontrol/L.Control.Locate.js',
                        'public/js/lib/Leaflet.utfgrid/L.UTFGrid.js',
                        'public/js/lib/leaflet-plugins/Bing.js',
                        'public/js/lib/Leaflet.GridLayer.GoogleMutant/Leaflet.GoogleMutant.js',
                        'public/js/lib/Leaflet.NonTiledLayer/NonTiledLayer.js',
                        //'public/js/lib/leaflet-glify/glify.js',
                        //'public/js/lib/leaflet-geometryutil/leaflet.geometryutil.js',
                        'public/js/lib/leaflet-vector-grid/Leaflet.VectorGrid.bundled.min.js',
                        'public/js/lib/localforage/localforage.js',

                        'public/js/lib/jquery/jquery-3.4.1.min.js',
                        'public/js/lib/jrespond/jRespond.js',
                        'public/js/lib/mustache.js/mustache.js',
                        'public/js/lib/underscore/underscore.js',
                        'public/js/lib/backbone/backbone.js',
                        'public/js/lib/proj4/proj4-combined.js',

                        'public/js/lib/typeahead.js/typeahead.jquery.js',
                        'public/js/lib/bootstrap-material-design/dist/js/ripples.js',
                        'public/js/lib/bootstrap-material-design/dist/js/material.js',
                        'public/js/lib/bootstrap-colorpicker/js/bootstrap-colorpicker.js',

                        'public/js/bundle.js',
                        'public/js/vidi.js',
                    ],
                    'public/js/build/all.async.min.js': [
                        'public/js/lib/jquery.canvasResize.js/jquery.canvasResize.js',
                        'public/js/lib/jquery.canvasResize.js/jquery.exif.js',
                        'public/js/lib/jquery-ui-touch/jquery.ui.touch-punch.min.js',
                        'public/js/lib/leaflet-snap/leaflet.snap.js',
                        'public/js/lib/leaflet-measure-path/leaflet-measure-path.js',
                        'public/js/lib/leaflet.editable/Leaflet.Editable.js',
                        'public/js/lib/Leaflet.awesome-markers/leaflet.awesome-markers.js',
                        'public/js/lib/Path.Drag.js/src/Path.Drag.js',
                        'public/js/lib/leaflet-side-by-side/leaflet-side-by-side.min.js',
                        'public/js/lib/jquery-ui/jquery-ui.min.js',
                        'public/js/lib/snackbarjs/snackbar.min.js',
                        'public/js/lib/jsts/jsts.min.js',
                    ]
                }
            }
        },
        processhtml: {
            publish: {
                files: {
                    'public/index.html': ['public/index.html']
                }
            }
        },
        gitpull: {
            production: {
                options: {}
            }
        },
        gitreset: {
            production: {
                options: {
                    mode: 'hard'
                }
            }
        },
        shell: {
            default: {
                command: [
                    copyBootstrapVariablesCommand,
                    'grunt --gruntfile ./public/js/lib/bootstrap-material-design/Gruntfile.js dist-less'
                ].join('&&')
            }
        },
        cacheBust: {
            options: {
                assets: ['js/build/all.min.js', 'js/build/all.async.min.js', 'css/build/all.min.css', 'js/templates.js'],
                queryString: false,
                baseDir: './public/',
                jsonOutput: false,
                deleteOriginals: false
            },
            production: {
                files: [{
                    expand: true,
                    cwd: 'public/',
                    src: ['index.html']
                }]
            }
        },
        bower: {
            install: {
                //just run 'grunt bower:install' and you'll see files from your Bower packages in lib directory
                options: {
                    targetDir: "./public/js/lib",
                    copy: true,
                    install: true,
                    cleanTargetDir: false,
                    verbose: true,
                }
            }
        }
    });

    grunt.registerTask('prepareAssets', 'Updates assets if specific modules are enabled', function () {
        if (theme && theme === 'watsonc') {
            fs.createReadStream('./extensions/watsonc/public/index.html').pipe(fs.createWriteStream('./public/index.html'));
            fs.createReadStream('./extensions/watsonc/public/favicon.ico').pipe(fs.createWriteStream('./public/favicon.ico'));
        } else {
            fs.createReadStream('./public/index.html.default').pipe(fs.createWriteStream('./public/index.html'));
            fs.createReadStream('./public/favicon.ico.default').pipe(fs.createWriteStream('./public/favicon.ico'));
        }
    });

    grunt.registerTask('appendBuildHashToVersion', 'Appends the build hash to the application version', function () {
        var crypto = require('crypto');
        var md5 = crypto.createHash('md5');

        var jsSource = grunt.file.expand({filter: "isFile", cwd: "public/js/build"}, ["all.min.js"]);
        var cssSource = grunt.file.expand({filter: "isFile", cwd: "public/css/build"}, ["all.min.css"]);
        if (jsSource.length !== 1 || cssSource.length !== 1) {
            throw new Error(`Unable to find all.min.*.js[css] sources`);
        }

        var buffer = grunt.file.read('public/js/build/' + jsSource[0]) + grunt.file.read('public/css/build/' + cssSource[0]);
        md5.update(buffer);
        var md5Hash = md5.digest('hex');
        var versionJSON = grunt.file.readJSON('public/version.json');
        versionJSON.extensionsBuild = md5Hash;
        grunt.file.write('public/version.json', JSON.stringify(versionJSON));
        grunt.log.write('Extensions build version was written ' + md5Hash).verbose.write('...').ok();
    });

    grunt.loadNpmTasks('grunt-templates-hogan');
    grunt.loadNpmTasks('grunt-browserify');
    grunt.loadNpmTasks('grunt-git');
    grunt.loadNpmTasks('grunt-shell');
    grunt.loadNpmTasks('grunt-contrib-less');
    grunt.loadNpmTasks('grunt-contrib-uglify-es');
    grunt.loadNpmTasks('grunt-contrib-cssmin');
    grunt.loadNpmTasks('grunt-processhtml');
    grunt.loadNpmTasks('grunt-cache-bust');
    grunt.loadNpmTasks('grunt-env');
    grunt.loadNpmTasks('grunt-contrib-handlebars');
    grunt.loadNpmTasks('grunt-contrib-watch');
    grunt.loadNpmTasks('grunt-bower-task');
    grunt.loadNpmTasks('grunt-watchify');
    grunt.loadNpmTasks('grunt-version');

    grunt.registerTask('default', ['prepareAssets', 'browserify:publish', 'browserify:publish_sw_dev', 'extension-css', 'shell', 'hogan', 'version']);
    grunt.registerTask('production', ['env:prod', 'gitreset', 'hogan', 'prepareAssets', 'browserify:publish', 'browserify:publish_sw', 'extension-css', 'shell', 'uglify', 'processhtml', 'cssmin:build', 'cacheBust', 'version', 'appendBuildHashToVersion']);
    grunt.registerTask('production-test', ['env:prod', 'hogan', 'browserify:publish', 'browserify:publish_sw', 'extension-css', 'shell', 'uglify', 'processhtml', 'cssmin:build', 'cacheBust', 'version', 'appendBuildHashToVersion']);
    grunt.registerTask('extension-css', ['less', 'cssmin:extensions']);
};
<commit_msg>Optimized Reactjs build<commit_after>/*
 * @author     Martin Høgh <mh@mapcentia.com>
 * @copyright  2013-2018 MapCentia ApS
 * @license    http://www.gnu.org/licenses/#AGPL  GNU AFFERO GENERAL PUBLIC LICENSE 3
 */

var fs = require('fs');

module.exports = function (grunt) {
    "use strict";

    // Detecting optional theme
    let theme = false;
    process.argv.forEach(val => {
        if (val.indexOf(`--theme=`) !== -1) {
            theme = val.replace(`--theme=`, ``);
        }
    });

    // Default build parameters
    let copyBootstrapVariablesCommand = 'cp ./config/_variables.less ./public/js/lib/bootstrap-material-design/less';
    let lessConfig = {"public/css/styles.css": "public/less/styles.default.less"};
    if (theme && theme === 'watsonc') {
        copyBootstrapVariablesCommand = 'cp ./extensions/' + theme + '/config/_variables.less ./public/js/lib/bootstrap-material-design/less';
        lessConfig = {"public/css/styles.css": "public/less/styles." + theme + ".less"};
    }

    grunt.initConfig({
        pkg: grunt.file.readJSON('package.json'),
        env: {
            prod: {
                NODE_ENV: 'production'
            }
        },
        version: {
            options: {
                prefix: '"version":"'
            },
            defaults: {
                src: ['public/version.json']
            }
        },
        less: {
            publish: {
                options: {
                    compress: false,
                    optimization: 2
                },
                files: [
                    lessConfig,
                    {
                        expand: true,        // Enable dynamic expansion.
                        cwd: 'extensions',  // Src matches are relative to this path.
                        src: ['**/less/*.less',],     // Actual pattern(s) to match.
                        dest: 'public/css/extensions',  // Destination path prefix.
                        ext: '.css',         // Dest filepaths will have this extension.
                    }
                ]
            }
        },
        cssmin: {
            build: {
                options: {
                    target: "./build",
                    rebase: true
                },
                files: {
                    'public/css/build/all.min.css': [
                        // Material Design fonts
                        'public/fonts/fonts.css',
                        'public/icons/material-icons.css',
                        // jQuery UI
                        'public/js/lib/jquery-ui/jquery-ui.min.css',
                        // Font Awesome
                        'public/css/font-awesome.min.css',
                        'public/css/font-awesome.v520.solid.css',
                        'public/css/font-awesome.v520.regular.css',
                        'public/css/font-awesome.v520.css',
                        // Leaflet
                        'public/js/lib/leaflet/leaflet.css',
                        'public/js/lib/leaflet-draw/leaflet.draw.css',
                        'public/js/lib/leaflet.locatecontrol/L.Control.Locate.css',
                        'public/js/lib/leaflet.toolbar/leaflet.toolbar.css',
                        'public/js/lib/leaflet-measure-path/leaflet-measure-path.css',
                        'public/js/lib/leaflet-history/leaflet-history.css',
                        'public/js/lib/leaflet-boxzoom/leaflet-boxzoom.css',
                        'public/js/lib/Leaflet.awesome-markers/leaflet.awesome-markers.css',
                        // Bootstrap
                        'public/js/lib/bootstrap/dist/css/bootstrap.css',
                        'public/js/lib/snackbarjs/snackbar.min.css',
                        'public/js/lib/bootstrap-material-design/dist/css/ripples.css',
                        'public/js/lib/bootstrap-material-datetimepicker/bootstrap-material-datetimepicker.css',
                        'public/js/lib/bootstrap-select/bootstrap-select.css',
                        'public/js/lib/bootstrap-table/bootstrap-table.css',
                        'public/js/lib/bootstrap-material-design/dist/css/bootstrap-material-design.css',
                        'public/js/lib/bootstrap-colorpicker/css/bootstrap-colorpicker.css',
                        //custom
                        'public/css/styles.min.css'
                    ]
                }
            },
            extensions: {
                options: {
                    target: "./build",
                    rebase: true
                },
                files: {
                    'public/css/styles.min.css': [
                        'public/css/styles.css',
                        'public/css/extensions/**/less/*.css'
                    ]
                }
            }

        },
        jshint: {
            options: {
                funcscope: true,
                shadow: true,
                evil: true,
                validthis: true,
                asi: true,
                newcap: false,
                notypeof: false,
                eqeqeq: false,
                loopfunc: true,
                es3: true,
                devel: false,
                eqnull: true
            },
            all: ['public/js/*.js']
        },
        hogan: {
            publish: {
                options: {
                    defaultName: function (filename) {
                        return filename.split('/').pop();
                    }
                },
                files: {
                    "public/js/templates.js": [
                        "public/templates/**/*.tmpl",
                        "extensions/**/templates/*.tmpl"
                    ]
                }
            }
        },
        handlebars: {
            publish: {
                options: {
                    namespace: function (filename) {
                        var names = filename.replace(/modules\/(.*)(\/\w+\.hbs)/, '$1');
                        return names.split('/').join('.');
                    },
                    commonjs: true
                },
                files: {
                    "public/js/handlebars_templates.js": [
                        "extensions/**/templates/*.hbs"
                    ]
                }
            }
        },
        browserify: {
            publish: {
                files: {
                    'public/js/bundle.js': ['browser/index.js'],
                },
                options: {
                    browserifyOptions: {
                        debug: false
                    },
                    transform: [['babelify', {
                        presets: [['es2015'], ['react'], ['stage-0']],
                        plugins: ["transform-object-rest-spread"]
                    }], 'require-globify', 'windowify', 'envify', 'uglifyify']
                }
            },
            publish_sw: {
                files: {
                    'public/service-worker.bundle.js': ['browser/service-worker/index.js']
                },
                options: {
                    alias: {
                        'urls-to-cache': './browser/service-worker/cache.production.js'
                    },
                    transform: [['babelify', {
                        presets: [['es2015'], ['react'], ['stage-0']],
                        plugins: ["transform-object-rest-spread"]
                    }], 'require-globify']
                }
            },
            publish_sw_dev: {
                files: {
                    'public/service-worker.bundle.js': ['browser/service-worker/index.js']
                },
                options: {
                    alias: {
                        'urls-to-cache': './browser/service-worker/cache.development.js'
                    },
                    transform: [['babelify', {
                        presets: [['es2015'], ['react'], ['stage-0']],
                        plugins: ["transform-object-rest-spread"]
                    }], 'require-globify']
                }
            },
            watch: {
                files: {
                    'public/js/bundle.js': ['browser/index.js']
                },
                options: {
                    transform: [['babelify', {
                        presets: [['es2015'], ['react'], ['stage-0']],
                        plugins: ["transform-object-rest-spread"]
                    }], 'require-globify', 'windowify'],
                    watch: true,
                    keepAlive: true,
                    browserifyOptions: {
                        debug: true
                    }
                }
            }
        },
        uglify: {
            publish: {
                options: {
                    sourceMap: true,
                    sourceMapIncludeSources: true,
                    compress: {
                        dead_code: true,
                        drop_debugger: true,
                        global_defs: {
                            "DEBUG": false
                        },
                    }
                },
                files: {
                    'public/js/build/all.min.js': [
                        'public/js/lib/leaflet/leaflet-src.js',
                        'public/js/lib/leaflet-history/leaflet-history.js',
                        'public/js/lib/leaflet-boxzoom/leaflet-boxzoom.js',
                        'public/js/lib/leaflet-draw/leaflet.draw.js',
                        'public/js/lib/leaflet.locatecontrol/L.Control.Locate.js',
                        'public/js/lib/Leaflet.utfgrid/L.UTFGrid.js',
                        'public/js/lib/leaflet-plugins/Bing.js',
                        'public/js/lib/Leaflet.GridLayer.GoogleMutant/Leaflet.GoogleMutant.js',
                        'public/js/lib/Leaflet.NonTiledLayer/NonTiledLayer.js',
                        //'public/js/lib/leaflet-glify/glify.js',
                        //'public/js/lib/leaflet-geometryutil/leaflet.geometryutil.js',
                        'public/js/lib/leaflet-vector-grid/Leaflet.VectorGrid.bundled.min.js',
                        'public/js/lib/localforage/localforage.js',

                        'public/js/lib/jquery/jquery-3.4.1.min.js',
                        'public/js/lib/jrespond/jRespond.js',
                        'public/js/lib/mustache.js/mustache.js',
                        'public/js/lib/underscore/underscore.js',
                        'public/js/lib/backbone/backbone.js',
                        'public/js/lib/proj4/proj4-combined.js',

                        'public/js/lib/typeahead.js/typeahead.jquery.js',
                        'public/js/lib/bootstrap-material-design/dist/js/ripples.js',
                        'public/js/lib/bootstrap-material-design/dist/js/material.js',
                        'public/js/lib/bootstrap-colorpicker/js/bootstrap-colorpicker.js',

                        'public/js/bundle.js',
                        'public/js/vidi.js',
                    ],
                    'public/js/build/all.async.min.js': [
                        'public/js/lib/jquery.canvasResize.js/jquery.canvasResize.js',
                        'public/js/lib/jquery.canvasResize.js/jquery.exif.js',
                        'public/js/lib/jquery-ui-touch/jquery.ui.touch-punch.min.js',
                        'public/js/lib/leaflet-snap/leaflet.snap.js',
                        'public/js/lib/leaflet-measure-path/leaflet-measure-path.js',
                        'public/js/lib/leaflet.editable/Leaflet.Editable.js',
                        'public/js/lib/Leaflet.awesome-markers/leaflet.awesome-markers.js',
                        'public/js/lib/Path.Drag.js/src/Path.Drag.js',
                        'public/js/lib/leaflet-side-by-side/leaflet-side-by-side.min.js',
                        'public/js/lib/jquery-ui/jquery-ui.min.js',
                        'public/js/lib/snackbarjs/snackbar.min.js',
                        'public/js/lib/jsts/jsts.min.js',
                    ]
                }
            }
        },
        processhtml: {
            publish: {
                files: {
                    'public/index.html': ['public/index.html']
                }
            }
        },
        gitpull: {
            production: {
                options: {}
            }
        },
        gitreset: {
            production: {
                options: {
                    mode: 'hard'
                }
            }
        },
        shell: {
            default: {
                command: [
                    copyBootstrapVariablesCommand,
                    'grunt --gruntfile ./public/js/lib/bootstrap-material-design/Gruntfile.js dist-less'
                ].join('&&')
            }
        },
        cacheBust: {
            options: {
                assets: ['js/build/all.min.js', 'js/build/all.async.min.js', 'css/build/all.min.css', 'js/templates.js'],
                queryString: false,
                baseDir: './public/',
                jsonOutput: false,
                deleteOriginals: false
            },
            production: {
                files: [{
                    expand: true,
                    cwd: 'public/',
                    src: ['index.html']
                }]
            }
        },
        bower: {
            install: {
                //just run 'grunt bower:install' and you'll see files from your Bower packages in lib directory
                options: {
                    targetDir: "./public/js/lib",
                    copy: true,
                    install: true,
                    cleanTargetDir: false,
                    verbose: true,
                }
            }
        }
    });

    grunt.registerTask('prepareAssets', 'Updates assets if specific modules are enabled', function () {
        if (theme && theme === 'watsonc') {
            fs.createReadStream('./extensions/watsonc/public/index.html').pipe(fs.createWriteStream('./public/index.html'));
            fs.createReadStream('./extensions/watsonc/public/favicon.ico').pipe(fs.createWriteStream('./public/favicon.ico'));
        } else {
            fs.createReadStream('./public/index.html.default').pipe(fs.createWriteStream('./public/index.html'));
            fs.createReadStream('./public/favicon.ico.default').pipe(fs.createWriteStream('./public/favicon.ico'));
        }
    });

    grunt.registerTask('appendBuildHashToVersion', 'Appends the build hash to the application version', function () {
        var crypto = require('crypto');
        var md5 = crypto.createHash('md5');

        var jsSource = grunt.file.expand({filter: "isFile", cwd: "public/js/build"}, ["all.min.js"]);
        var cssSource = grunt.file.expand({filter: "isFile", cwd: "public/css/build"}, ["all.min.css"]);
        if (jsSource.length !== 1 || cssSource.length !== 1) {
            throw new Error(`Unable to find all.min.*.js[css] sources`);
        }

        var buffer = grunt.file.read('public/js/build/' + jsSource[0]) + grunt.file.read('public/css/build/' + cssSource[0]);
        md5.update(buffer);
        var md5Hash = md5.digest('hex');
        var versionJSON = grunt.file.readJSON('public/version.json');
        versionJSON.extensionsBuild = md5Hash;
        grunt.file.write('public/version.json', JSON.stringify(versionJSON));
        grunt.log.write('Extensions build version was written ' + md5Hash).verbose.write('...').ok();
    });

    grunt.loadNpmTasks('grunt-templates-hogan');
    grunt.loadNpmTasks('grunt-browserify');
    grunt.loadNpmTasks('grunt-git');
    grunt.loadNpmTasks('grunt-shell');
    grunt.loadNpmTasks('grunt-contrib-less');
    grunt.loadNpmTasks('grunt-contrib-uglify-es');
    grunt.loadNpmTasks('grunt-contrib-cssmin');
    grunt.loadNpmTasks('grunt-processhtml');
    grunt.loadNpmTasks('grunt-cache-bust');
    grunt.loadNpmTasks('grunt-env');
    grunt.loadNpmTasks('grunt-contrib-handlebars');
    grunt.loadNpmTasks('grunt-contrib-watch');
    grunt.loadNpmTasks('grunt-bower-task');
    grunt.loadNpmTasks('grunt-watchify');
    grunt.loadNpmTasks('grunt-version');

    grunt.registerTask('default', ['prepareAssets', 'browserify:publish', 'browserify:publish_sw_dev', 'extension-css', 'shell', 'hogan', 'version']);
    grunt.registerTask('production', ['env:prod', 'gitreset', 'hogan', 'prepareAssets', 'browserify:publish', 'browserify:publish_sw', 'extension-css', 'shell', 'uglify', 'processhtml', 'cssmin:build', 'cacheBust', 'version', 'appendBuildHashToVersion']);
    grunt.registerTask('production-test', ['env:prod', 'hogan', 'browserify:publish', 'browserify:publish_sw', 'extension-css', 'shell', 'uglify', 'processhtml', 'cssmin:build', 'cacheBust', 'version', 'appendBuildHashToVersion']);
    grunt.registerTask('extension-css', ['less', 'cssmin:extensions']);
};
<|endoftext|>


<commit_before>// Generated on 2013-09-11 using generator-angular 0.4.0
'use strict';
var LIVERELOAD_PORT = 35729;
var lrSnippet = require('connect-livereload')({
  port: LIVERELOAD_PORT
});
var mountFolder = function (connect, dir) {
  return connect.static(require('path').resolve(dir));
};

// # Globbing
// for performance reasons we're only matching one level down:
// 'test/spec/{,*/}*.js'
// use this if you want to recursively match all subfolders:
// 'test/spec/**/*.js'

module.exports = function (grunt) {

  // Load grunt tasks automatically
  require('load-grunt-tasks')(grunt);

  // Time how long tasks take. Can help when optimizing build times
  require('time-grunt')(grunt);

  // Configurable paths for the application
  var appConfig = {
    app: require('./bower.json').appPath || 'app',
    dist: 'dist'
  };

  // Define the configuration for all the tasks
  grunt.initConfig({

    // read package.json to have version nrs
    pkg: grunt.file.readJSON('package.json'),

    // Project settings
    yeoman: appConfig,

    // Watches files for changes and runs tasks based on the changed files
    watch: {
      compass: {
        files: ['<%= yeoman.app %>/styles/{,*/}*.{scss,sass}'],
        tasks: ['compass:server', 'autoprefixer']
      },
      styles: {
        files: ['<%= yeoman.app %>/styles/{,*/}*.css'],
        tasks: ['copy:styles', 'autoprefixer']
      },
      livereload: {
        options: {
          livereload: LIVERELOAD_PORT
        },
        files: [
          '<%= yeoman.app %>/{,*/}*.html',
          '.tmp/styles/{,*/}*.css',
          'exampleServers/*.js',
          'app/configFiles/defaultConfig.json',
          'app/testData/customConfig.json',
          'app/schemaFiles/*.json',
          'app/configFiles/*.json',
          'app/testData/newFormat/ae/ae_DBconfig.json',
          '{.tmp,<%= yeoman.app %>}/scripts/{,*/}*.js',
          '<%= yeoman.app %>/images/{,*/}*.{png,jpg,jpeg,gif,webp,svg}'
        ]
      }
    },

    // The actual grunt server settings
    connect: {
      options: {
        port: 9000,
        // Change this to '0.0.0.0' to access the server from outside.
        hostname: 'localhost'
      },
      livereload: {
        options: {
          middleware: function (connect) {
            return [
              lrSnippet,
              mountFolder(connect, '.tmp'),
              mountFolder(connect, appConfig.app)
            ];
          }
        }
      },
      test: {
        options: {
          port: 9999,
          middleware: function (connect) {
            return [
              mountFolder(connect, '.tmp'),
              mountFolder(connect, 'test')
            ];
          }
        }
      },
      dist: {
        options: {
          middleware: function (connect) {
            return [
              mountFolder(connect, appConfig.dist)
            ];
          }
        }
      }
    },

    // Make sure code styles are up to par and there are no obvious mistakes
    jshint: {
      options: {
        jshintrc: '.jshintrc',
        strict: true
      },
      all: [
        '<%= yeoman.app %>/scripts/{,*/}*.js'
      ]
    },

    // Empties folders to start fresh
    clean: {
      dist: {
        files: [{
          dot: true,
          src: [
            '.tmp',
            '<%= yeoman.dist %>/*',
            '!<%= yeoman.dist %>/.git*'
          ]
        }]
      },
      server: '.tmp'
    },

    // Add vendor prefixed styles
    autoprefixer: {
      options: ['last 1 version'],
      dist: {
        files: [{
          expand: true,
          cwd: '.tmp/styles/',
          src: '{,*/}*.css',
          dest: '.tmp/styles/'
        }]
      }
    },
    open: {
      server: {
        url: 'http://localhost:<%= connect.options.port %>'
      }
    },
    coffee: {
      options: {
        sourceMap: true,
        sourceRoot: ''
      },
      dist: {
        files: [{
          expand: true,
          cwd: '<%= yeoman.app %>/scripts',
          src: '{,*/}*.coffee',
          dest: '.tmp/scripts',
          ext: '.js'
        }]
      },
      test: {
        files: [{
          expand: true,
          cwd: 'test/spec',
          src: '{,*/}*.coffee',
          dest: '.tmp/spec',
          ext: '.js'
        }]
      }
    },
    compass: {
      options: {
        sassDir: '<%= yeoman.app %>/styles',
        cssDir: '.tmp/styles',
        generatedImagesDir: '.tmp/images/generated',
        imagesDir: '<%= yeoman.app %>/images',
        javascriptsDir: '<%= yeoman.app %>/scripts',
        fontsDir: '<%= yeoman.app %>/styles/fonts',
        importPath: '<%= yeoman.app %>/bower_components',
        httpImagesPath: '/images',
        httpGeneratedImagesPath: '/images/generated',
        httpFontsPath: '/styles/fonts',
        relativeAssets: false
      },
      dist: {},
      server: {
        options: {
          debugInfo: true
        }
      }
    },
    // not used since Uglify task does concat,
    // but still available if needed
    /*concat: {
      dist: {}
    },*/

    // Renames files for browser caching purposes
    rev: {
      dist: {
        files: {
          src: [
            '<%= yeoman.dist %>/scripts/*.js',
            '<%= yeoman.dist %>/styles/{,*/}*.css',
            '<%= yeoman.dist %>/images/{,*/}*.{png,jpg,jpeg,gif,webp,svg}',
            '<%= yeoman.dist %>/styles/fonts/*'
          ]
        }
      }
    },

    // Reads HTML for usemin blocks to enable smart builds that automatically
    // concat, minify and revision files. Creates configurations in memory so
    // additional tasks can operate on them
    useminPrepare: {
      html: '<%= yeoman.app %>/index.html',
      options: {
        dest: '<%= yeoman.dist %>',
        flow: {
          html: {
            steps: {
              js: ['concat', 'uglifyjs'],
              css: ['cssmin']
            },
            post: {}
          }
        }
      }
    },

    // Performs rewrites based on filerev and the useminPrepare configuration
    usemin: {
      html: ['<%= yeoman.dist %>/{,*/}*.html'],
      css: ['<%= yeoman.dist %>/styles/{,*/}*.css'],
      options: {
        dirs: ['<%= yeoman.dist %>']
      }
    },

    uglify: {
      dist: {
        options: {
          sourceMap: true,
          sourceMapIncludeSources: true,
          sourceMapName: '<%= yeoman.dist %>/scripts/emuwebApp.min.js.map'
        },
        files: {
          '<%= yeoman.dist %>/scripts/emuwebApp.min.js': [
            '<%= yeoman.dist %>/scripts/emuwebApp.min.js'
          ]
        }
      }
    },

    imagemin: {
      dist: {
        files: [{
          expand: true,
          cwd: '<%= yeoman.app %>/images',
          src: '{,*/}*.{png,jpg,jpeg}',
          dest: '<%= yeoman.dist %>/images'
        }]
      }
    },

    svgmin: {
      dist: {
        files: [{
          expand: true,
          cwd: '<%= yeoman.app %>/images',
          src: '{,*/}*.svg',
          dest: '<%= yeoman.dist %>/images'
        }]
      }
    },

    htmlmin: {
      dist: {
        options: {
          // collapseWhitespace: true,
          // conservativeCollapse: true,
          // collapseBooleanAttributes: true,
          // removeCommentsFromCDATA: true,
          // removeOptionalTags: true
        },
        files: [{
          expand: true,
          cwd: '<%= yeoman.app %>',
          src: ['*.html', 'views/*.html'],
          dest: '<%= yeoman.dist %>'
        }]
      }
    },

    cssmin: {
      // By default, your `index.html` <!-- Usemin Block --> will take care of
      // minification. This option is pre-configured if you do not wish to use
      // Usemin blocks.
      // dist: {
      //   files: {
      //     '<%= yeoman.dist %>/styles/main.css': [
      //       '.tmp/styles/{,*/}*.css',
      //       '<%= yeoman.app %>/styles/{,*/}*.css'
      //     ]
      //   }
      // }
    },

    // ngmin tries to make the code safe for minification automatically by
    // using the Angular long form for dependency injection. It doesn't work on
    // things like resolve or inject so those have to be done manually.
    ngmin: {
      dist: {
        files: [{
          expand: true,
          cwd: '<%= yeoman.dist %>/scripts',
          src: '*.js',
          dest: '<%= yeoman.dist %>/scripts'
        }]
      }
    },

    // Replace Google CDN references
    // cdnify: {
    //   dist: {
    //     html: ['<%= yeoman.dist %>/*.html']
    //   }
    // },

    // Copies remaining files to places other tasks can use
    copy: {
      dist: {
        files: [{
          expand: true,
          dot: true,
          cwd: '<%= yeoman.app %>',
          dest: '<%= yeoman.dist %>',
          src: [
            '*.{ico,png,txt}',
            '.htaccess',
            'images/{,*/}*.{gif,webp}',
            'img/*.png',
            'styles/fonts/*',
            'configFiles/{,*/}*.*',
            'schemaFiles/*.json',
            'scripts/workers/*.js',
            'demoDBs/{,*/}*.*',
            'background.js',
            'manifest.json',
            'assets/EMU-webAppEmu.svg',
            'assets/EMU-webAppIcon-roundCorners.svg',
            // 'styles/external/bootstrap-combined.min.css',
            'styles/images/rightSideMenuBtn.png'
          ]
        }, {
          expand: true,
          cwd: '.tmp/images',
          dest: '<%= yeoman.dist %>/images',
          src: [
            'generated/*'
          ]
        }, {
          expand: true,
          flatten: true,
          cwd: '<%= yeoman.app %>',
          dest: '<%= yeoman.dist %>/fonts',
          src: [
            'bower_components/bootstrap/dist/fonts/*.*'
          ]
        }]
      },
      styles: {
        expand: true,
        cwd: '<%= yeoman.app %>/styles',
        dest: '.tmp/styles/',
        src: '{,*/}*.css'
      }
    },

    // Run some tasks in parallel to speed up the build process
    concurrent: {
      server: [
        'copy:styles'
      ],
      test: [
        'copy:styles'
      ],
      dist: [
        'copy:styles',
        'imagemin',
        'svgmin',
        'htmlmin'
      ]
    },

    // Test settings

    karma: {
      continuous: {
        configFile: 'karma.conf.js',
        singleRun: false
      },
      unit: {
        configFile: 'karma.conf.js',
        singleRun: true,
        browsers: ['PhantomJS']
      }
    },

    protractor: {
      options: {
        keepAlive: true,
        configFile: 'protractor.conf.js'
      },
      run: {}
    },

    // auto generate manifest.appcache file with all files of app
    appcache: {
      options: {
        basePath: '<%= yeoman.dist %>'
      },
      all: {
        dest: '<%= yeoman.dist %>/manifest.appcache',
        cache: '<%= yeoman.dist %>/**/*',
        network: '*',
        fallback: 'index.html'
      }
    },

    throttle: {
      default: {
        remote_port: 9000,
        local_port: 9001,
        upstream: 20 * 1024,
        downstream: 100 * 1024,
        keepalive: true
      }
    },

    replace: {
      dist: {
        options: {
          patterns: [{
            match: 'versionnr',
            replacement: '<%= pkg.version %>'
          }, {
            match: 'sha1',
            replacement: '<%= gitinfo.local.branch.current.SHA %> - <%= gitinfo.local.branch.current.name %>'
          }, {
            match: 'timestamp',
            replacement: '<%= grunt.template.today() %>'
          }]
        },
        files: [{
          expand: true,
          flatten: true,
          src: ['dist/views/about.html'],
          dest: 'dist/views/'
        }]
      }
    },

    coveralls: {
      options: {
        debug: true,
        coverage_dir: 'test/coverage',
        dryRun: false,
        force: true,
        recursive: true
      }
    }
  });

  grunt.registerTask('serve', 'Compile then start a connect web server', function (target) {
    if (target === 'dist') {
      return grunt.task.run(['build', 'connect:dist:keepalive']);
    }

    grunt.task.run([
      'clean:server',
      'concurrent:server',
      'autoprefixer',
      'connect:livereload',
      'watch'
    ]);
  });

  grunt.registerTask('server', 'DEPRECATED TASK. Use the "serve" task instead', function (target) {
    grunt.log.warn('The `server` task has been deprecated. Use `grunt serve` to start a server.');
    grunt.task.run(['serve:' + target]);
  });

  grunt.registerTask('repTest', [
    'gitinfo',
    'replace'
  ]);

  grunt.registerTask('test', [
    'clean:server',
    'concurrent:test',
    'autoprefixer',
    'connect:test',
    'karma:continuous'
  ]);

  grunt.registerTask('e2e', [
    'clean:server',
    'concurrent:test',
    'autoprefixer',
    'connect:test',
    'protractor:run'
  ]);

  grunt.registerTask('build', [
    'clean:dist',
    'useminPrepare',
    'concurrent:dist',
    'autoprefixer',
    'concat',
    'copy:dist',
    // 'cdnify',
    'ngmin',
    'cssmin',
    'uglify',
    'rev',
    'usemin',
    'appcache',
    'gitinfo',
    'replace'
  ]);

  grunt.registerTask('default', [
    'jshint',
    'test',
    'build'
  ]);

  grunt.registerTask('slowServer', [
    'throttle'
  ]);
};<commit_msg>DEPRECATION use coverageDir insteadof coverage_dir<commit_after>// Generated on 2013-09-11 using generator-angular 0.4.0
'use strict';
var LIVERELOAD_PORT = 35729;
var lrSnippet = require('connect-livereload')({
  port: LIVERELOAD_PORT
});
var mountFolder = function (connect, dir) {
  return connect.static(require('path').resolve(dir));
};

// # Globbing
// for performance reasons we're only matching one level down:
// 'test/spec/{,*/}*.js'
// use this if you want to recursively match all subfolders:
// 'test/spec/**/*.js'

module.exports = function (grunt) {

  // Load grunt tasks automatically
  require('load-grunt-tasks')(grunt);

  // Time how long tasks take. Can help when optimizing build times
  require('time-grunt')(grunt);

  // Configurable paths for the application
  var appConfig = {
    app: require('./bower.json').appPath || 'app',
    dist: 'dist'
  };

  // Define the configuration for all the tasks
  grunt.initConfig({

    // read package.json to have version nrs
    pkg: grunt.file.readJSON('package.json'),

    // Project settings
    yeoman: appConfig,

    // Watches files for changes and runs tasks based on the changed files
    watch: {
      compass: {
        files: ['<%= yeoman.app %>/styles/{,*/}*.{scss,sass}'],
        tasks: ['compass:server', 'autoprefixer']
      },
      styles: {
        files: ['<%= yeoman.app %>/styles/{,*/}*.css'],
        tasks: ['copy:styles', 'autoprefixer']
      },
      livereload: {
        options: {
          livereload: LIVERELOAD_PORT
        },
        files: [
          '<%= yeoman.app %>/{,*/}*.html',
          '.tmp/styles/{,*/}*.css',
          'exampleServers/*.js',
          'app/configFiles/defaultConfig.json',
          'app/testData/customConfig.json',
          'app/schemaFiles/*.json',
          'app/configFiles/*.json',
          'app/testData/newFormat/ae/ae_DBconfig.json',
          '{.tmp,<%= yeoman.app %>}/scripts/{,*/}*.js',
          '<%= yeoman.app %>/images/{,*/}*.{png,jpg,jpeg,gif,webp,svg}'
        ]
      }
    },

    // The actual grunt server settings
    connect: {
      options: {
        port: 9000,
        // Change this to '0.0.0.0' to access the server from outside.
        hostname: 'localhost'
      },
      livereload: {
        options: {
          middleware: function (connect) {
            return [
              lrSnippet,
              mountFolder(connect, '.tmp'),
              mountFolder(connect, appConfig.app)
            ];
          }
        }
      },
      test: {
        options: {
          port: 9999,
          middleware: function (connect) {
            return [
              mountFolder(connect, '.tmp'),
              mountFolder(connect, 'test')
            ];
          }
        }
      },
      dist: {
        options: {
          middleware: function (connect) {
            return [
              mountFolder(connect, appConfig.dist)
            ];
          }
        }
      }
    },

    // Make sure code styles are up to par and there are no obvious mistakes
    jshint: {
      options: {
        jshintrc: '.jshintrc',
        strict: true
      },
      all: [
        '<%= yeoman.app %>/scripts/{,*/}*.js'
      ]
    },

    // Empties folders to start fresh
    clean: {
      dist: {
        files: [{
          dot: true,
          src: [
            '.tmp',
            '<%= yeoman.dist %>/*',
            '!<%= yeoman.dist %>/.git*'
          ]
        }]
      },
      server: '.tmp'
    },

    // Add vendor prefixed styles
    autoprefixer: {
      options: ['last 1 version'],
      dist: {
        files: [{
          expand: true,
          cwd: '.tmp/styles/',
          src: '{,*/}*.css',
          dest: '.tmp/styles/'
        }]
      }
    },
    open: {
      server: {
        url: 'http://localhost:<%= connect.options.port %>'
      }
    },
    coffee: {
      options: {
        sourceMap: true,
        sourceRoot: ''
      },
      dist: {
        files: [{
          expand: true,
          cwd: '<%= yeoman.app %>/scripts',
          src: '{,*/}*.coffee',
          dest: '.tmp/scripts',
          ext: '.js'
        }]
      },
      test: {
        files: [{
          expand: true,
          cwd: 'test/spec',
          src: '{,*/}*.coffee',
          dest: '.tmp/spec',
          ext: '.js'
        }]
      }
    },
    compass: {
      options: {
        sassDir: '<%= yeoman.app %>/styles',
        cssDir: '.tmp/styles',
        generatedImagesDir: '.tmp/images/generated',
        imagesDir: '<%= yeoman.app %>/images',
        javascriptsDir: '<%= yeoman.app %>/scripts',
        fontsDir: '<%= yeoman.app %>/styles/fonts',
        importPath: '<%= yeoman.app %>/bower_components',
        httpImagesPath: '/images',
        httpGeneratedImagesPath: '/images/generated',
        httpFontsPath: '/styles/fonts',
        relativeAssets: false
      },
      dist: {},
      server: {
        options: {
          debugInfo: true
        }
      }
    },
    // not used since Uglify task does concat,
    // but still available if needed
    /*concat: {
      dist: {}
    },*/

    // Renames files for browser caching purposes
    rev: {
      dist: {
        files: {
          src: [
            '<%= yeoman.dist %>/scripts/*.js',
            '<%= yeoman.dist %>/styles/{,*/}*.css',
            '<%= yeoman.dist %>/images/{,*/}*.{png,jpg,jpeg,gif,webp,svg}',
            '<%= yeoman.dist %>/styles/fonts/*'
          ]
        }
      }
    },

    // Reads HTML for usemin blocks to enable smart builds that automatically
    // concat, minify and revision files. Creates configurations in memory so
    // additional tasks can operate on them
    useminPrepare: {
      html: '<%= yeoman.app %>/index.html',
      options: {
        dest: '<%= yeoman.dist %>',
        flow: {
          html: {
            steps: {
              js: ['concat', 'uglifyjs'],
              css: ['cssmin']
            },
            post: {}
          }
        }
      }
    },

    // Performs rewrites based on filerev and the useminPrepare configuration
    usemin: {
      html: ['<%= yeoman.dist %>/{,*/}*.html'],
      css: ['<%= yeoman.dist %>/styles/{,*/}*.css'],
      options: {
        dirs: ['<%= yeoman.dist %>']
      }
    },

    uglify: {
      dist: {
        options: {
          sourceMap: true,
          sourceMapIncludeSources: true,
          sourceMapName: '<%= yeoman.dist %>/scripts/emuwebApp.min.js.map'
        },
        files: {
          '<%= yeoman.dist %>/scripts/emuwebApp.min.js': [
            '<%= yeoman.dist %>/scripts/emuwebApp.min.js'
          ]
        }
      }
    },

    imagemin: {
      dist: {
        files: [{
          expand: true,
          cwd: '<%= yeoman.app %>/images',
          src: '{,*/}*.{png,jpg,jpeg}',
          dest: '<%= yeoman.dist %>/images'
        }]
      }
    },

    svgmin: {
      dist: {
        files: [{
          expand: true,
          cwd: '<%= yeoman.app %>/images',
          src: '{,*/}*.svg',
          dest: '<%= yeoman.dist %>/images'
        }]
      }
    },

    htmlmin: {
      dist: {
        options: {
          // collapseWhitespace: true,
          // conservativeCollapse: true,
          // collapseBooleanAttributes: true,
          // removeCommentsFromCDATA: true,
          // removeOptionalTags: true
        },
        files: [{
          expand: true,
          cwd: '<%= yeoman.app %>',
          src: ['*.html', 'views/*.html'],
          dest: '<%= yeoman.dist %>'
        }]
      }
    },

    cssmin: {
      // By default, your `index.html` <!-- Usemin Block --> will take care of
      // minification. This option is pre-configured if you do not wish to use
      // Usemin blocks.
      // dist: {
      //   files: {
      //     '<%= yeoman.dist %>/styles/main.css': [
      //       '.tmp/styles/{,*/}*.css',
      //       '<%= yeoman.app %>/styles/{,*/}*.css'
      //     ]
      //   }
      // }
    },

    // ngmin tries to make the code safe for minification automatically by
    // using the Angular long form for dependency injection. It doesn't work on
    // things like resolve or inject so those have to be done manually.
    ngmin: {
      dist: {
        files: [{
          expand: true,
          cwd: '<%= yeoman.dist %>/scripts',
          src: '*.js',
          dest: '<%= yeoman.dist %>/scripts'
        }]
      }
    },

    // Replace Google CDN references
    // cdnify: {
    //   dist: {
    //     html: ['<%= yeoman.dist %>/*.html']
    //   }
    // },

    // Copies remaining files to places other tasks can use
    copy: {
      dist: {
        files: [{
          expand: true,
          dot: true,
          cwd: '<%= yeoman.app %>',
          dest: '<%= yeoman.dist %>',
          src: [
            '*.{ico,png,txt}',
            '.htaccess',
            'images/{,*/}*.{gif,webp}',
            'img/*.png',
            'styles/fonts/*',
            'configFiles/{,*/}*.*',
            'schemaFiles/*.json',
            'scripts/workers/*.js',
            'demoDBs/{,*/}*.*',
            'background.js',
            'manifest.json',
            'assets/EMU-webAppEmu.svg',
            'assets/EMU-webAppIcon-roundCorners.svg',
            // 'styles/external/bootstrap-combined.min.css',
            'styles/images/rightSideMenuBtn.png'
          ]
        }, {
          expand: true,
          cwd: '.tmp/images',
          dest: '<%= yeoman.dist %>/images',
          src: [
            'generated/*'
          ]
        }, {
          expand: true,
          flatten: true,
          cwd: '<%= yeoman.app %>',
          dest: '<%= yeoman.dist %>/fonts',
          src: [
            'bower_components/bootstrap/dist/fonts/*.*'
          ]
        }]
      },
      styles: {
        expand: true,
        cwd: '<%= yeoman.app %>/styles',
        dest: '.tmp/styles/',
        src: '{,*/}*.css'
      }
    },

    // Run some tasks in parallel to speed up the build process
    concurrent: {
      server: [
        'copy:styles'
      ],
      test: [
        'copy:styles'
      ],
      dist: [
        'copy:styles',
        'imagemin',
        'svgmin',
        'htmlmin'
      ]
    },

    // Test settings

    karma: {
      continuous: {
        configFile: 'karma.conf.js',
        singleRun: false
      },
      unit: {
        configFile: 'karma.conf.js',
        singleRun: true,
        browsers: ['PhantomJS']
      }
    },

    protractor: {
      options: {
        keepAlive: true,
        configFile: 'protractor.conf.js'
      },
      run: {}
    },

    // auto generate manifest.appcache file with all files of app
    appcache: {
      options: {
        basePath: '<%= yeoman.dist %>'
      },
      all: {
        dest: '<%= yeoman.dist %>/manifest.appcache',
        cache: '<%= yeoman.dist %>/**/*',
        network: '*',
        fallback: 'index.html'
      }
    },

    throttle: {
      default: {
        remote_port: 9000,
        local_port: 9001,
        upstream: 20 * 1024,
        downstream: 100 * 1024,
        keepalive: true
      }
    },

    replace: {
      dist: {
        options: {
          patterns: [{
            match: 'versionnr',
            replacement: '<%= pkg.version %>'
          }, {
            match: 'sha1',
            replacement: '<%= gitinfo.local.branch.current.SHA %> - <%= gitinfo.local.branch.current.name %>'
          }, {
            match: 'timestamp',
            replacement: '<%= grunt.template.today() %>'
          }]
        },
        files: [{
          expand: true,
          flatten: true,
          src: ['dist/views/about.html'],
          dest: 'dist/views/'
        }]
      }
    },

    coveralls: {
      options: {
        debug: true,
        coverageDir: 'test/coverage',
        dryRun: false,
        force: true,
        recursive: true
      }
    }
  });

  grunt.registerTask('serve', 'Compile then start a connect web server', function (target) {
    if (target === 'dist') {
      return grunt.task.run(['build', 'connect:dist:keepalive']);
    }

    grunt.task.run([
      'clean:server',
      'concurrent:server',
      'autoprefixer',
      'connect:livereload',
      'watch'
    ]);
  });

  grunt.registerTask('server', 'DEPRECATED TASK. Use the "serve" task instead', function (target) {
    grunt.log.warn('The `server` task has been deprecated. Use `grunt serve` to start a server.');
    grunt.task.run(['serve:' + target]);
  });

  grunt.registerTask('repTest', [
    'gitinfo',
    'replace'
  ]);

  grunt.registerTask('test', [
    'clean:server',
    'concurrent:test',
    'autoprefixer',
    'connect:test',
    'karma:continuous'
  ]);

  grunt.registerTask('e2e', [
    'clean:server',
    'concurrent:test',
    'autoprefixer',
    'connect:test',
    'protractor:run'
  ]);

  grunt.registerTask('build', [
    'clean:dist',
    'useminPrepare',
    'concurrent:dist',
    'autoprefixer',
    'concat',
    'copy:dist',
    // 'cdnify',
    'ngmin',
    'cssmin',
    'uglify',
    'rev',
    'usemin',
    'appcache',
    'gitinfo',
    'replace'
  ]);

  grunt.registerTask('default', [
    'jshint',
    'test',
    'build'
  ]);

  grunt.registerTask('slowServer', [
    'throttle'
  ]);
};<|endoftext|>