<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,jade}',
          '{.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>livereload grunt sur sous-dossiers<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',
        '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'
  ]);
};
<|endoftext|>


<commit_before>module.exports = function(grunt) {
  var output_dir = './out/';
  var build_dir = output_dir + 'build/';
  var release_dir = output_dir + 'release/';

  var config = {
    all_js_concat_output: build_dir + 'concat.js',
    main_concat_output: build_dir + 'main-concat.js'
  };

  var compiler = require('superstartup-closure-compiler');

  grunt.initConfig({
    qunit: {
      all: ['test/index.html']
    },
    jsdoc: {
      all: {
        src: [
          'README.md',
          'src/modules/',
          'src/vowelworm.js'
        ],
        dest: 'doc/',
        options: {
          verbose: true,
          recurse: true,
          'private': false
        }
      }
    },
    closureCompiler: {
      options: {
        create_source_map: null,
        compilerFile: compiler.getPath(),
        compilerOpts: {
          compilation_level: 'SIMPLE_OPTIMIZATIONS',
          language_in: 'ECMASCRIPT5',
          externs: grunt.file.expand(['src/lib/externs/**/*.js']),
          warning_level: 'verbose',
          output_wrapper: '"(function(){%output%}).call(this);"',
          jscomp_off: ['nonStandardJsDocs']
        },
        execOpts: {
          maxBuffer: 5000 * 1024
        },
        TieredCompilation: true,
      },
      demo: { // for Github pages
        TEMPCompilerOpts: {
          compilation_level: 'ADVANCED_OPTIMIZATIONS'
        },
        src: config.all_js_concat_output,
        dest: release_dir + 'vowelworm-demo.min.js'
      },
      main: {
        files: [
          {
            expand: true,
            src: [
              'src/vowelworm.js',
              'src/modules/**/*.js',
              '!src/modules/**/*.min.js'
            ],
            ext: '.min.js',
            extDot: 'last',
            rename: function(dest, matchedSrcPath, options) {
              // puts the compiled files in the release directory
              return matchedSrcPath.replace(/^src/, release_dir);
            }
          }
        ],
      },
      all: {
        src: config.main_concat_output,
        dest: release_dir + 'vowelworm.complete.min.js'
      }
    },
    concat: {
      main: {
        src: [
          'src/vowelworm.js',
          'src/modules/**/*.js'
        ],
        dest: config.main_concat_output
      },
      demo: {
        src: [
          'src/vowelworm.js',
          'src/modules/core/vowelworm.game.js',
          'main.js'
        ],
        dest: config.all_js_concat_output
      }
    },
    clean: {
      src: [output_dir, 'src/modules/**/*.min.js', 'src/vowelworm.min.js'],
      doc: ['doc/**/*','!doc/examples/**']
    }
  });
  grunt.loadNpmTasks('grunt-contrib-qunit');
  grunt.loadNpmTasks('grunt-closure-tools');
  grunt.loadNpmTasks('grunt-contrib-concat');
  grunt.loadNpmTasks('grunt-contrib-clean');
  grunt.loadNpmTasks('grunt-jsdoc');

  grunt.registerTask('test', 'qunit');
  grunt.registerTask('doc', ['clean:doc', 'jsdoc']);
  grunt.registerTask('compile-demo', ['concat:demo','closureCompiler:demo']);
  grunt.registerTask('compile', ['clean:src', 'closureCompiler:main', 'concat:main', 'closureCompiler:all']);
  grunt.registerTask('default', ['test','compile','compile-demo','doc']);
};
<commit_msg>Cleaning up grunt clean<commit_after>module.exports = function(grunt) {
  var output_dir = './out/';
  var build_dir = output_dir + 'build/';
  var release_dir = output_dir + 'release/';

  var config = {
    all_js_concat_output: build_dir + 'concat.js',
    main_concat_output: build_dir + 'main-concat.js'
  };

  var compiler = require('superstartup-closure-compiler');

  grunt.initConfig({
    qunit: {
      all: ['test/index.html']
    },
    jsdoc: {
      all: {
        src: [
          'README.md',
          'src/modules/',
          'src/vowelworm.js'
        ],
        dest: 'doc/',
        options: {
          verbose: true,
          recurse: true,
          'private': false
        }
      }
    },
    closureCompiler: {
      options: {
        create_source_map: null,
        compilerFile: compiler.getPath(),
        compilerOpts: {
          compilation_level: 'SIMPLE_OPTIMIZATIONS',
          language_in: 'ECMASCRIPT5',
          externs: grunt.file.expand(['src/lib/externs/**/*.js']),
          warning_level: 'verbose',
          output_wrapper: '"(function(){%output%}).call(this);"',
          jscomp_off: ['nonStandardJsDocs']
        },
        execOpts: {
          maxBuffer: 5000 * 1024
        },
        TieredCompilation: true,
      },
      demo: { // for Github pages
        TEMPCompilerOpts: {
          compilation_level: 'ADVANCED_OPTIMIZATIONS'
        },
        src: config.all_js_concat_output,
        dest: release_dir + 'vowelworm-demo.min.js'
      },
      main: {
        files: [
          {
            expand: true,
            src: [
              'src/vowelworm.js',
              'src/modules/**/*.js',
              '!src/modules/**/*.min.js'
            ],
            ext: '.min.js',
            extDot: 'last',
            rename: function(dest, matchedSrcPath, options) {
              // puts the compiled files in the release directory
              return matchedSrcPath.replace(/^src/, release_dir);
            }
          }
        ],
      },
      all: {
        src: config.main_concat_output,
        dest: release_dir + 'vowelworm.complete.min.js'
      }
    },
    concat: {
      main: {
        src: [
          'src/vowelworm.js',
          'src/modules/**/*.js'
        ],
        dest: config.main_concat_output
      },
      demo: {
        src: [
          'src/vowelworm.js',
          'src/modules/core/vowelworm.game.js',
          'main.js'
        ],
        dest: config.all_js_concat_output
      }
    },
    clean: {
      src: [output_dir, 'src/modules/**/*.min.js', 'src/vowelworm.min.js'],
      doc: ['doc']
    }
  });
  grunt.loadNpmTasks('grunt-contrib-qunit');
  grunt.loadNpmTasks('grunt-closure-tools');
  grunt.loadNpmTasks('grunt-contrib-concat');
  grunt.loadNpmTasks('grunt-contrib-clean');
  grunt.loadNpmTasks('grunt-jsdoc');

  grunt.registerTask('test', 'qunit');
  grunt.registerTask('doc', ['clean:doc', 'jsdoc']);
  grunt.registerTask('compile-demo', ['concat:demo','closureCompiler:demo']);
  grunt.registerTask('compile', ['clean:src', 'closureCompiler:main', 'concat:main', 'closureCompiler:all']);
  grunt.registerTask('default', ['test','compile','compile-demo','doc']);
};
<|endoftext|>


<commit_before>
module.exports = function(grunt) {

  var path = require("path")

  const GCC_OPTIONS = {
    compilation_level: "SIMPLE_OPTIMIZATIONS",
    externs: "tools/extern.js",

    warning_level: "VERBOSE",
    jscomp_off: "checkTypes",
    jscomp_error: "checkDebuggerStatement"
  }

  grunt.initConfig({
    pkg: grunt.file.readJSON("package.json"),

    concat: {
      seajs: {
        src: [
          "src/intro.js",
          "src/sea.js",

          "src/util-lang.js",
          "src/util-log.js",
          "src/util-events.js",
          "src/util-path.js",
          "src/util-request.js",
          "src/util-deps.js",

          "src/module.js",
          "src/config.js",

          "src/outro.js"
        ],
        dest: "dist/sea-debug.js"
      }
    },

    gcc: {
      seajs: {
        src: "dist/sea-debug.js",
        dest: "dist/sea.js",
        options: grunt.util._.merge({
          banner: "/*! Sea.js <%= pkg.version %> | seajs.org/LICENSE.md\n" +
              "//# sourceMappingURL=sea.js.map\n*/",
          source_map_format: "V3",
          create_source_map: "dist/sea.js.map"
        }, GCC_OPTIONS)
      },

      plugins: {
        files: grunt.file.expandMapping(
            "src/plugins/*.js", "dist/",
            {
              "rename": function(dest, matchedSrcPath) {
                return path.join(dest, matchedSrcPath.split("/").pop())
              }
            }
        ),
        options: GCC_OPTIONS
      }
    }

  })

  grunt.registerTask("embed", "Embed version etc.", function() {
    var filepath = "dist/sea-debug.js"
    var version = grunt.config("pkg.version")

    var code = grunt.file.read(filepath)
    code = code.replace(/@VERSION/g, version)
    grunt.file.write(filepath, code)

    grunt.log.writeln("@VERSION is replaced to \"" + version + "\".")
  })

  grunt.registerTask("fix", "Fix sourceMap etc.", function() {
    var mapfile = "dist/sea.js.map"

    var code = grunt.file.read(mapfile)
    code = code.replace('"file":""', '"file":"sea.js"')
    code = code.replace("dist/sea-debug.js", "sea-debug.js")
    grunt.file.write(mapfile, code)
    grunt.log.writeln('"' + mapfile + '" is fixed.')

    // No `$` variable in compressed code to avoiding conflicting
    // when inline in velocity template.
    var minfile = "dist/sea.js"

    code = grunt.file.read(minfile)
    code = code.replace('function $', 'function _')
    code = code.replace('$.data=', '_.data=')
    code = code.replace('.config=$', '.config=_')
    grunt.file.write(minfile, code)
    grunt.log.writeln('$ in "' + minfile + '" is fixed.')
  })

  grunt.loadTasks("tools/grunt-tasks")
  grunt.loadNpmTasks("grunt-contrib-concat")

  grunt.registerTask("default", ["concat", "embed", "gcc:seajs", "fix"])
  grunt.registerTask("plugins", ["gcc:plugins"])
  grunt.registerTask("all", ["default", "plugins"])

}

<commit_msg>Improve $ replace logic<commit_after>
module.exports = function(grunt) {

  var path = require("path")

  const GCC_OPTIONS = {
    compilation_level: "SIMPLE_OPTIMIZATIONS",
    externs: "tools/extern.js",

    warning_level: "VERBOSE",
    jscomp_off: "checkTypes",
    jscomp_error: "checkDebuggerStatement"
  }

  grunt.initConfig({
    pkg: grunt.file.readJSON("package.json"),

    concat: {
      seajs: {
        src: [
          "src/intro.js",
          "src/sea.js",

          "src/util-lang.js",
          "src/util-log.js",
          "src/util-events.js",
          "src/util-path.js",
          "src/util-request.js",
          "src/util-deps.js",

          "src/module.js",
          "src/config.js",

          "src/outro.js"
        ],
        dest: "dist/sea-debug.js"
      }
    },

    gcc: {
      seajs: {
        src: "dist/sea-debug.js",
        dest: "dist/sea.js",
        options: grunt.util._.merge({
          banner: "/*! Sea.js <%= pkg.version %> | seajs.org/LICENSE.md\n" +
              "//# sourceMappingURL=sea.js.map\n*/",
          source_map_format: "V3",
          create_source_map: "dist/sea.js.map"
        }, GCC_OPTIONS)
      },

      plugins: {
        files: grunt.file.expandMapping(
            "src/plugins/*.js", "dist/",
            {
              "rename": function(dest, matchedSrcPath) {
                return path.join(dest, matchedSrcPath.split("/").pop())
              }
            }
        ),
        options: GCC_OPTIONS
      }
    }

  })

  grunt.registerTask("embed", "Embed version etc.", function() {
    var filepath = "dist/sea-debug.js"
    var version = grunt.config("pkg.version")

    var code = grunt.file.read(filepath)
    code = code.replace(/@VERSION/g, version)
    grunt.file.write(filepath, code)

    grunt.log.writeln("@VERSION is replaced to \"" + version + "\".")
  })

  grunt.registerTask("fix", "Fix sourceMap etc.", function() {
    var mapfile = "dist/sea.js.map"

    var code = grunt.file.read(mapfile)
    code = code.replace('"file":""', '"file":"sea.js"')
    code = code.replace("dist/sea-debug.js", "sea-debug.js")
    grunt.file.write(mapfile, code)
    grunt.log.writeln('"' + mapfile + '" is fixed.')

    // No `$` variable in compressed code to avoiding conflicting
    // when inline in velocity template.
    var minfile = "dist/sea.js"

    code = grunt.file.read(minfile)
    code = code.replace('function $', 'function _')
    code = code.replace('$=', '_=')
    code = code.replace('$.', '_.')
    code = code.replace('=$', '=_')
    grunt.file.write(minfile, code)
    grunt.log.writeln('$ in "' + minfile + '" is fixed.')
  })

  grunt.loadTasks("tools/grunt-tasks")
  grunt.loadNpmTasks("grunt-contrib-concat")

  grunt.registerTask("default", ["concat", "embed", "gcc:seajs", "fix"])
  grunt.registerTask("plugins", ["gcc:plugins"])
  grunt.registerTask("all", ["default", "plugins"])

}

<|endoftext|>


<commit_before>var attire = require('attire');

module.exports = function(grunt) {

    grunt.initConfig({

        eslint: {
            options: {
                configFile: '.eslintrc.js'
            },
            target: ['src/**/*.js', 'Gruntfile.js', 'test/**/*.js']
        },

        watch: {
            readme: {
                expand: true,
                files: ['README.md'],
                tasks: ['buildDemo'],
                options: {
                    spawn: false
                }
            },
            jsFiles: {
                expand: true,
                files: ['src/**/*.js'],
                tasks: ['eslint', 'uglify'],
                options: {
                    spawn: false
                }
            }
        },

        bump: {
            options: {
                files: ['package.json', 'bower.json'],
                commitFiles: ['package.json', 'bower.json'],
                tagName: '%VERSION%',
                push: false
            }
        }

    });

    grunt.registerTask('buildDemo', function() {

        var done = this.async();

        attire.buildDemo({
            file: 'README.md',
            dest: 'index.html',
            title: 'SimpleQuery',
            description: 'SimpleQuery',
            canonicalUrl: 'http://dbrekalo.github.io/simplequery/',
            githubUrl: 'https://github.com/dbrekalo/simplequery',
            userRepositories: {
                user: 'dbrekalo',
                onlyWithPages: true
            },
            author: {
                caption: 'Damir Brekalo',
                url: 'https://github.com/dbrekalo',
                image: 'https://s.gravatar.com/avatar/32754a476fb3db1c5a1f9ad80c65d89d?s=80',
                email: 'dbrekalo@gmail.com',
                github: 'https://github.com/dbrekalo',
                twitter: 'https://twitter.com/dbrekalo'
            },
            afterParse: function($) {
                $('p').first().remove();
                $('a').first().parent().remove();
            },
            inlineCss: true,
        }).then(function() {
            done();
            grunt.log.ok(['Demo builded']);
        });

    });

    require('load-grunt-tasks')(grunt);

    grunt.registerTask('default', ['build', 'watch']);
    grunt.registerTask('build', ['eslint', 'buildDemo']);

};
<commit_msg>Add package-lock.json to bump files registry<commit_after>var attire = require('attire');

module.exports = function(grunt) {

    grunt.initConfig({

        eslint: {
            options: {
                configFile: '.eslintrc.js'
            },
            target: ['src/**/*.js', 'Gruntfile.js', 'test/**/*.js']
        },

        watch: {
            readme: {
                expand: true,
                files: ['README.md'],
                tasks: ['buildDemo'],
                options: {
                    spawn: false
                }
            },
            jsFiles: {
                expand: true,
                files: ['src/**/*.js'],
                tasks: ['eslint', 'uglify'],
                options: {
                    spawn: false
                }
            }
        },

        bump: {
            options: {
                files: ['package.json', 'package-lock.json', 'bower.json'],
                commitFiles: ['package.json', 'package-lock.json', 'bower.json'],
                tagName: '%VERSION%',
                push: false
            }
        }

    });

    grunt.registerTask('buildDemo', function() {

        var done = this.async();

        attire.buildDemo({
            file: 'README.md',
            dest: 'index.html',
            title: 'SimpleQuery',
            description: 'SimpleQuery',
            canonicalUrl: 'http://dbrekalo.github.io/simplequery/',
            githubUrl: 'https://github.com/dbrekalo/simplequery',
            userRepositories: {
                user: 'dbrekalo',
                onlyWithPages: true
            },
            author: {
                caption: 'Damir Brekalo',
                url: 'https://github.com/dbrekalo',
                image: 'https://s.gravatar.com/avatar/32754a476fb3db1c5a1f9ad80c65d89d?s=80',
                email: 'dbrekalo@gmail.com',
                github: 'https://github.com/dbrekalo',
                twitter: 'https://twitter.com/dbrekalo'
            },
            afterParse: function($) {
                $('p').first().remove();
                $('a').first().parent().remove();
            },
            inlineCss: true,
        }).then(function() {
            done();
            grunt.log.ok(['Demo builded']);
        });

    });

    require('load-grunt-tasks')(grunt);

    grunt.registerTask('default', ['build', 'watch']);
    grunt.registerTask('build', ['eslint', 'buildDemo']);

};
<|endoftext|>


<commit_before>'use strict';
module.exports = function(grunt) {

    // Project configuration.
    grunt.initConfig({
        pkg: grunt.file.readJSON('package.json'),
        bowercopy: {

        libs: {
            options: {
                destPrefix: 'public/'
            },
            files: {
            'js/nprogress.js': 'nprogress/nprogress.js',
            'css/nprogress.css': 'nprogress/nprogress.css',
            'js/jquery.cookie.js': 'jquery.cookie/jquery.cookie.js',
            'js/jquery.min.js': 'jquery/dist/jquery.min.js',
            'js/jquery.min.map': 'jquery/dist/jquery.min.map',
            'js/bootstrap.min.js': 'bootstrap/dist/js/bootstrap.min.js',
            'css/bootstrap.min.css': 'bootstrap/dist/css/bootstrap.min.css',
            'css/jcsdl.min.css': 'jcsdl/minified/jcsdl.min.css',
            'js/jcsdl.min.js': 'jcsdl/minified/jcsdl.min.js',
            'js/jcsdl.definition.js': 'jcsdl/minified/jcsdl.definition.js',
            'css/img': 'jcsdl/minified/img',
            'css/swf': 'jcsdl/minified/swf'
            }
        }
        },
        // JShint
        jshint: {
            options: {
                jshintrc: '.jshintrc'
            },
            all: ['Gruntfile.js', 'lib/**/*.js', 'test/**/*.js']
        },
        // Configure a mochaTest task
        mochaTest: {
            test: {
                options: {
                    reporter: 'spec'
                },
                src: ['test/**/*.js']
            }
        }
    });

    grunt.loadNpmTasks('grunt-bowercopy');
    grunt.loadNpmTasks('grunt-contrib-jshint');
    grunt.loadNpmTasks('grunt-mocha-test');

    // Default task(s).
    grunt.registerTask('default', ['bowercopy', 'jshint', 'mochaTest']);

};<commit_msg>Remove nProgress for customisations.<commit_after>'use strict';
module.exports = function(grunt) {

    // Project configuration.
    grunt.initConfig({
        pkg: grunt.file.readJSON('package.json'),
        bowercopy: {

        libs: {
            options: {
                destPrefix: 'public/'
            },
            files: {
            'js/nprogress.js': 'nprogress/nprogress.js',
            //'css/nprogress.css': 'nprogress/nprogress.css', <-- custom so dont copy over
            'js/jquery.cookie.js': 'jquery.cookie/jquery.cookie.js',
            'js/jquery.min.js': 'jquery/dist/jquery.min.js',
            'js/jquery.min.map': 'jquery/dist/jquery.min.map',
            'js/bootstrap.min.js': 'bootstrap/dist/js/bootstrap.min.js',
            'css/bootstrap.min.css': 'bootstrap/dist/css/bootstrap.min.css',
            'css/jcsdl.min.css': 'jcsdl/minified/jcsdl.min.css',
            'js/jcsdl.min.js': 'jcsdl/minified/jcsdl.min.js',
            'js/jcsdl.definition.js': 'jcsdl/minified/jcsdl.definition.js',
            'css/img': 'jcsdl/minified/img',
            'css/swf': 'jcsdl/minified/swf'
            }
        }
        },
        // JShint
        jshint: {
            options: {
                jshintrc: '.jshintrc'
            },
            all: ['Gruntfile.js', 'lib/**/*.js', 'test/**/*.js']
        },
        // Configure a mochaTest task
        mochaTest: {
            test: {
                options: {
                    reporter: 'spec'
                },
                src: ['test/**/*.js']
            }
        }
    });

    grunt.loadNpmTasks('grunt-bowercopy');
    grunt.loadNpmTasks('grunt-contrib-jshint');
    grunt.loadNpmTasks('grunt-mocha-test');

    // Default task(s).
    grunt.registerTask('default', ['bowercopy', 'jshint', 'mochaTest']);

};<|endoftext|>


<commit_before>'use strict';

module.exports = function (grunt) {

    require('load-grunt-tasks')(grunt);

    grunt.initConfig({
        pkg: grunt.file.readJSON('package.json'),

        info: {
            banner: {
                short: '/* <%= pkg.name %> v<%= pkg.version %>, (c) 2014-<%= grunt.template.today("yyyy") %> Joel Mukuthu, MIT License, built: <%= grunt.template.date("dd-mm-yyyy HH:MM:ss Z") %> */\n',
                long: '/**\n * <%= pkg.name %>\n * Version: <%= pkg.version %>\n * (c) 2014-<%= grunt.template.today("yyyy") %> Joel Mukuthu\n * MIT License\n * Built on: <%= grunt.template.date("dd-mm-yyyy HH:MM:ss Z") %>\n **/\n\n'
            }
        },

        clean: {
            // dev: '.tmp',
            dist: 'dist'
        },

        concat: {
            options: {
                separator: '\n',
                banner: '<%= info.banner.long %>'
            },
            // dev: {
            //     src: ['src/*.js', 'src/**/*.js'],
            //     dest: '.tmp/<%= pkg.name %>.js'
            // },
            dist: {
                src: ['src/*.js', 'src/**/*.js'],
                dest: 'dist/<%= pkg.name %>.js'
            }
        },

        uglify: {
            options: {
                banner: '<%= info.banner.short %>'
            },
            dist: {
                src: ['<%= concat.dist.dest %>'],
                dest: 'dist/<%= pkg.name %>.min.js'
            }
        },

        eslint: {
            target: [
                'src/**/*.js',
                'test/spec/**/*.js'
            ]
        },

        karma: {
            options: {
                configFile: 'test/karma.conf.js'
            },
            single: {
                singleRun: true
            },
            continuous: {
                singleRun: false
            }
        },

        watch: {
            js: {
                files: ['src/**/*.js'],
                tasks: [
                    'newer:jshint:js',
                    'karma:single'
                ]
            },
            test: {
                files: ['test/spec/**/*.js'],
                tasks: [
                    'newer:jshint:test',
                    'karma:single'
                ]
            }
        },

        'release-it': {
            options: {
                pkgFiles: ['package.json', 'bower.json'],
                commitMessage: 'Release %s',
                tagName: 'v%s',
                tagAnnotation: 'Release %s',
                buildCommand: 'grunt build'
            }
        }
    });

    grunt.registerTask('default', [
        'eslint',
        'watch'
    ]);

    grunt.registerTask('dev-test', [
        'eslint',
        'karma:continuous'
    ]);

    grunt.registerTask('test', [
        'eslint',
        'karma:single'
    ]);

    grunt.registerTask('build', [
        'test',
        'clean:dist',
        'concat',
        'uglify'
    ]);
};
<commit_msg>Remove unused grunt tasks<commit_after>'use strict';

module.exports = function (grunt) {

    require('load-grunt-tasks')(grunt);

    grunt.initConfig({
        pkg: grunt.file.readJSON('package.json'),

        info: {
            banner: {
                short: '/* <%= pkg.name %> v<%= pkg.version %>, (c) 2014-<%= grunt.template.today("yyyy") %> Joel Mukuthu, MIT License, built: <%= grunt.template.date("dd-mm-yyyy HH:MM:ss Z") %> */\n',
                long: '/**\n * <%= pkg.name %>\n * Version: <%= pkg.version %>\n * (c) 2014-<%= grunt.template.today("yyyy") %> Joel Mukuthu\n * MIT License\n * Built on: <%= grunt.template.date("dd-mm-yyyy HH:MM:ss Z") %>\n **/\n\n'
            }
        },

        clean: {
            dist: 'dist'
        },

        concat: {
            options: {
                separator: '\n',
                banner: '<%= info.banner.long %>'
            },
            dist: {
                src: ['src/*.js', 'src/**/*.js'],
                dest: 'dist/<%= pkg.name %>.js'
            }
        },

        uglify: {
            options: {
                banner: '<%= info.banner.short %>'
            },
            dist: {
                src: ['<%= concat.dist.dest %>'],
                dest: 'dist/<%= pkg.name %>.min.js'
            }
        },

        eslint: {
            target: [
                'src/**/*.js',
                'test/spec/**/*.js'
            ]
        },

        karma: {
            options: {
                configFile: 'test/karma.conf.js'
            },
            single: {
                singleRun: true
            }
        },

        watch: {
            files: [
                'src/**/*.js',
                'test/spec/**/*.js'
            ],
            tasks: [
                'newer:eslint',
                'karma:single'
            ]
        },

        'release-it': {
            options: {
                pkgFiles: ['package.json', 'bower.json'],
                commitMessage: 'Release %s',
                tagName: 'v%s',
                tagAnnotation: 'Release %s',
                buildCommand: 'grunt build'
            }
        }
    });

    grunt.registerTask('default', [
        'eslint',
        'watch'
    ]);

    grunt.registerTask('test', [
        'eslint',
        'karma:single'
    ]);

    grunt.registerTask('build', [
        'test',
        'clean:dist',
        'concat',
        'uglify'
    ]);
};
<|endoftext|>


<commit_before>
module.exports = function(grunt) {

    var d = __dirname+"/vendors/phantomizer-htmlcompressor";

    var in_dir = d+"/demo/in/";
    var out_dir = d+"/demo/out/";
    var meta_dir = d+"/demo/out/";

    grunt.initConfig({
        pkg: grunt.file.readJSON('package.json')

        ,"out_dir":out_dir
        ,"meta_dir":meta_dir

        //-
        ,'phantomizer-htmlcompressor': {
            options: {
                "compress-js":true,
                "compress-css":true
            }
            ,test: {
                options:{
                    "in_file": in_dir+"/index.html"
                    ,"out": "<%= out_dir %>/index.html"
                    ,"meta": "<%= meta_dir %>/index.html.meta"
                }
            }
            ,keepcomments: {
                options:{
                    "in_file": in_dir+"/index.html"
                    ,"out": "<%= out_dir %>/index.html"
                    ,"meta": "<%= meta_dir %>/index.html.meta"
                    ,"preserved_html_comments": "(?si)<!--.+?-->"
                }
            }
        }
    });

    grunt.loadNpmTasks('phantomizer-htmlcompressor');

    grunt.registerTask('default',
        [
            'phantomizer-htmlcompressor:test'
        ]);
};
<commit_msg>Removed .meta appendix to meta files Improved default options readings Imrpoved commandes Improved error reporting<commit_after>
module.exports = function(grunt) {

    var d = __dirname+"/vendors/phantomizer-htmlcompressor";

    var in_dir = d+"/demo/in/";
    var out_dir = d+"/demo/out/";
    var meta_dir = d+"/demo/out/";

    grunt.initConfig({
        pkg: grunt.file.readJSON('package.json')

        ,"out_dir":out_dir
        ,"meta_dir":meta_dir

        //-
        ,'phantomizer-htmlcompressor': {
            options: {
                "compress-js":true,
                "compress-css":true
            }
            ,test: {
                options:{
                    "in_file": in_dir+"/index.html"
                    ,"out": "<%= out_dir %>/index.html"
                    ,"meta": "<%= meta_dir %>/index.html"
                }
            }
            ,keepcomments: {
                options:{
                    "in_file": in_dir+"/index.html"
                    ,"out": "<%= out_dir %>/index.html"
                    ,"meta": "<%= meta_dir %>/index.html"
                    ,"preserved_html_comments": "(?si)<!--.+?-->"
                }
            }
        }
    });

    grunt.loadNpmTasks('phantomizer-htmlcompressor');

    grunt.registerTask('default',
        [
            'phantomizer-htmlcompressor:test'
        ]);
};
<|endoftext|>


<commit_before>module.exports = function (grunt) {
	// time
	require('time-grunt')(grunt);

	grunt.initConfig({
		pkg: grunt.file.readJSON('package.json'),

		    // Compress and zip only the files required for deployment to the server. Exclude all dev dependencies.
		    compress: {
		      main: {
		        options: {
		          archive: 'packaged/<%= pkg.name %>' + grunt.template.today('-yyyy-mm-dd') + '.zip',
							mode: 'zip'
		        },
		        expand: true,
		        cwd: '.',
		        src: [
							'**/*',
							'!**/node_modules/**',
							'!**/components/**',
							'!**/scss/**',
							'!**/bower.json',
							'!**/Gruntfile.js',
							'!**/package.json',
							'!**/composer.json',
							'!**/composer.lock',
							'!**/codesniffer.ruleset.xml'
						],
		        dest: '<%= pkg.name %>'
		      },
		    },
		sass: {

			options: {
				// If you can't get source maps to work, run the following command in your terminal:
				// $ sass scss/foundation.scss:css/foundation.css --sourcemap
				// (see this link for details: http://thesassway.com/intermediate/using-source-maps-with-sass )
				sourceMap: true
			},

			dist: {
				options: {
					outputStyle: 'compressed'
				},
				files: {
					'assets/stylesheets/foundation.css': 'assets/scss/foundation.scss'
				}
			}

		},

		copy: {

			scripts: {
				expand: true,
				cwd: 'assets/components/foundation/js/vendor/',
				src: '**',
				flatten: 'true',
				dest: 'assets/javascript/vendor/'
			},

			iconfonts: {
				expand: true,
				cwd: 'assets/components/fontawesome/fonts',
				src: ['**'],
				dest: 'assets/fonts/'
			}

		},

		'string-replace': {

			fontawesome: {
				files: {
					'assets/fontawesome/scss/_variables.scss': 'assets/fontawesome/scss/_variables.scss'
				},

				options: {
					replacements: [
						{
							pattern: '../fonts',
							replacement: '../assets/fonts'
						}
					]
				}

			}

		},

		concat: {

			options: {
				separator: ';'
			},

			dist: {

				src: [

					// Foundation core
					'assets/components/foundation/js/foundation/foundation.js',

					// Pick the components you need in your project
					'assets/components/foundation/js/foundation/foundation.abide.js',
					'assets/components/foundation/js/foundation/foundation.accordion.js',
					'assets/components/foundation/js/foundation/foundation.alert.js',
					'assets/components/foundation/js/foundation/foundation.clearing.js',
					'assets/components/foundation/js/foundation/foundation.dropdown.js',
					'assets/components/foundation/js/foundation/foundation.equalizer.js',
					'assets/components/foundation/js/foundation/foundation.interchange.js',
					'assets/components/foundation/js/foundation/foundation.joyride.js',
					'assets/components/foundation/js/foundation/foundation.magellan.js',
					'assets/components/foundation/js/foundation/foundation.offcanvas.js',
					'assets/components/foundation/js/foundation/foundation.orbit.js',
					'assets/components/foundation/js/foundation/foundation.reveal.js',
					'assets/components/foundation/js/foundation/foundation.slider.js',
					'assets/components/foundation/js/foundation/foundation.tab.js',
					'assets/components/foundation/js/foundation/foundation.tooltip.js',
					'assets/components/foundation/js/foundation/foundation.topbar.js',

					// Include your own custom scripts (located in the custom folder)
					'assets/javascript/custom/*.js'

				],

				// Finally, concatenate all the files above into one single file
				dest: 'assets/javascript/foundation.js'

			}

		},

		uglify: {

			dist: {
				files: {
					// Shrink the file size by removing spaces
					'assets/javascript/foundation.js': ['assets/javascript/foundation.js']
				}
			}

		},

		watch: {
			grunt: {files: ['Gruntfile.js']},

			sass: {
				files: 'assets/scss/**/*.scss',
				tasks: ['sass'],
				options: {
					livereload: true
				}
			},

			js: {
				files: 'assets/javascript/custom/**/*.js',
				tasks: ['concat', 'uglify'],
				options: {
					livereload: true
				}
			},

			all: {
				files: '**/*.php',
				options: {
					livereload: true
				}
			}

		},

		browserSync: {
            dev: {
                bsFiles: {
                    src : [
                        'assets/stylesheets/*.css',
                        '**/*.php',
                        'assets/javascript/**/*.js'
                    ]
                },
                options: {
                    watchTask: true,
                    // fill in proxy address of local WP server
                    proxy: ""
                }
            }
        }
	});

	grunt.loadNpmTasks('grunt-sass');
	grunt.loadNpmTasks('grunt-contrib-watch');
	grunt.loadNpmTasks('grunt-contrib-concat');
	grunt.loadNpmTasks('grunt-contrib-copy');
	grunt.loadNpmTasks('grunt-contrib-uglify');
	grunt.loadNpmTasks('grunt-string-replace');
	grunt.loadNpmTasks('grunt-contrib-compress');
	grunt.loadNpmTasks('grunt-browser-sync');

	grunt.registerTask('package', ['compress:main']);
	grunt.registerTask('build', ['copy', 'string-replace:fontawesome', 'sass', 'concat', 'uglify']);
	grunt.registerTask('browser-sync', ['browserSync', 'watch']);
	grunt.registerTask('default', ['watch']);
};
<commit_msg>Do not include the package folder in the package script<commit_after>module.exports = function (grunt) {
	// time
	require('time-grunt')(grunt);

	grunt.initConfig({
		pkg: grunt.file.readJSON('package.json'),

		    // Compress and zip only the files required for deployment to the server. Exclude all dev dependencies.
		    compress: {
		      main: {
		        options: {
		          archive: 'packaged/<%= pkg.name %>' + grunt.template.today('-yyyy-mm-dd') + '.zip',
							mode: 'zip'
		        },
		        expand: true,
		        cwd: '.',
		        src: [
							'**/*',
							'!**/node_modules/**',
							'!**/components/**',
							'!**/scss/**',
							'!**/bower.json',
							'!**/Gruntfile.js',
							'!**/package.json',
							'!**/composer.json',
							'!**/composer.lock',
							'!**/codesniffer.ruleset.xml',
							'!**/packaged/*'
						],
		        dest: '<%= pkg.name %>'
		      },
		    },
		sass: {

			options: {
				// If you can't get source maps to work, run the following command in your terminal:
				// $ sass scss/foundation.scss:css/foundation.css --sourcemap
				// (see this link for details: http://thesassway.com/intermediate/using-source-maps-with-sass )
				sourceMap: true
			},

			dist: {
				options: {
					outputStyle: 'compressed'
				},
				files: {
					'assets/stylesheets/foundation.css': 'assets/scss/foundation.scss'
				}
			}

		},

		copy: {

			scripts: {
				expand: true,
				cwd: 'assets/components/foundation/js/vendor/',
				src: '**',
				flatten: 'true',
				dest: 'assets/javascript/vendor/'
			},

			iconfonts: {
				expand: true,
				cwd: 'assets/components/fontawesome/fonts',
				src: ['**'],
				dest: 'assets/fonts/'
			}

		},

		'string-replace': {

			fontawesome: {
				files: {
					'assets/fontawesome/scss/_variables.scss': 'assets/fontawesome/scss/_variables.scss'
				},

				options: {
					replacements: [
						{
							pattern: '../fonts',
							replacement: '../assets/fonts'
						}
					]
				}

			}

		},

		concat: {

			options: {
				separator: ';'
			},

			dist: {

				src: [

					// Foundation core
					'assets/components/foundation/js/foundation/foundation.js',

					// Pick the components you need in your project
					'assets/components/foundation/js/foundation/foundation.abide.js',
					'assets/components/foundation/js/foundation/foundation.accordion.js',
					'assets/components/foundation/js/foundation/foundation.alert.js',
					'assets/components/foundation/js/foundation/foundation.clearing.js',
					'assets/components/foundation/js/foundation/foundation.dropdown.js',
					'assets/components/foundation/js/foundation/foundation.equalizer.js',
					'assets/components/foundation/js/foundation/foundation.interchange.js',
					'assets/components/foundation/js/foundation/foundation.joyride.js',
					'assets/components/foundation/js/foundation/foundation.magellan.js',
					'assets/components/foundation/js/foundation/foundation.offcanvas.js',
					'assets/components/foundation/js/foundation/foundation.orbit.js',
					'assets/components/foundation/js/foundation/foundation.reveal.js',
					'assets/components/foundation/js/foundation/foundation.slider.js',
					'assets/components/foundation/js/foundation/foundation.tab.js',
					'assets/components/foundation/js/foundation/foundation.tooltip.js',
					'assets/components/foundation/js/foundation/foundation.topbar.js',

					// Include your own custom scripts (located in the custom folder)
					'assets/javascript/custom/*.js'

				],

				// Finally, concatenate all the files above into one single file
				dest: 'assets/javascript/foundation.js'

			}

		},

		uglify: {

			dist: {
				files: {
					// Shrink the file size by removing spaces
					'assets/javascript/foundation.js': ['assets/javascript/foundation.js']
				}
			}

		},

		watch: {
			grunt: {files: ['Gruntfile.js']},

			sass: {
				files: 'assets/scss/**/*.scss',
				tasks: ['sass'],
				options: {
					livereload: true
				}
			},

			js: {
				files: 'assets/javascript/custom/**/*.js',
				tasks: ['concat', 'uglify'],
				options: {
					livereload: true
				}
			},

			all: {
				files: '**/*.php',
				options: {
					livereload: true
				}
			}

		},

		browserSync: {
            dev: {
                bsFiles: {
                    src : [
                        'assets/stylesheets/*.css',
                        '**/*.php',
                        'assets/javascript/**/*.js'
                    ]
                },
                options: {
                    watchTask: true,
                    // fill in proxy address of local WP server
                    proxy: ""
                }
            }
        }
	});

	grunt.loadNpmTasks('grunt-sass');
	grunt.loadNpmTasks('grunt-contrib-watch');
	grunt.loadNpmTasks('grunt-contrib-concat');
	grunt.loadNpmTasks('grunt-contrib-copy');
	grunt.loadNpmTasks('grunt-contrib-uglify');
	grunt.loadNpmTasks('grunt-string-replace');
	grunt.loadNpmTasks('grunt-contrib-compress');
	grunt.loadNpmTasks('grunt-browser-sync');

	grunt.registerTask('package', ['compress:main']);
	grunt.registerTask('build', ['copy', 'string-replace:fontawesome', 'sass', 'concat', 'uglify']);
	grunt.registerTask('browser-sync', ['browserSync', 'watch']);
	grunt.registerTask('default', ['watch']);
};
<|endoftext|>


<commit_before>/* File: GruntFile.js
 *
 * Copyright (c) 2014
 * Centre National d’Enseignement à Distance (Cned), Boulevard Nicephore Niepce, 86360 CHASSENEUIL-DU-POITOU, France
 * (direction-innovation@cned.fr)
 *
 * GNU Affero General Public License (AGPL) version 3.0 or later version
 *
 * This file is part of a program which is free software: you can
 * redistribute it and/or modify it under the terms of the
 * GNU Affero General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
 * GNU Affero General Public License for more details.
 *
 * You should have received a copy of the GNU Affero General Public
 * License along with this program.
 * If not, see <http://www.gnu.org/licenses/>.
 *
 */

'use strict';

var path = require('path');

module.exports = function(grunt) {
    // load all grunt tasks
    require('matchdep').filterDev('grunt-*').forEach(grunt.loadNpmTasks);

    // configurable paths
    var yeomanConfig = {
        app: '.',
        dist: 'dist',
        generated: 'generated'
    };

    try {
        yeomanConfig.app = require('./bower.json').appPath || yeomanConfig.app;
    } catch (e) {}

    grunt.initConfig({
        yeoman: yeomanConfig,
        watch: {
            main: {
                files: ['app/**/*.{html,css,png,jpeg,GIF,jpg,eot,svg,ttf,woff}'],
            },
            options: {
                livereload: true/*,
                port: 3000,
                key: grunt.file.read('../sslcert/key.pem'),
                cert: grunt.file.read('../sslcert/cert.pem')*/
            }
        },
        express: {
            options: {
                hostname: '0.0.0.0'
            },
            livereload: {
                options: {
                    server: path.resolve('./app.js'),
                    livereload: true,
                    serverreload: false,
                    bases: [path.resolve('./.tmp'), path.resolve(__dirname, yeomanConfig.app)],
                    spawn: false
                }
            },
            test: {
                options: {
                    server: path.resolve('./app.js'),
                    bases: [path.resolve('./.tmp'), path.resolve(__dirname, 'test')]
                }
            },
            dist: {
                options: {
                    server: path.resolve('./app.js'),
                    bases: path.resolve(__dirname, yeomanConfig.dist)
                }
            },
            server: {
                options: {
                    port: 80
                }
            }
        },
        open: {
            server: {
                url: 'http://localhost:<%= express.options.port %>'
            }
        },
        clean: {
            dist: {
                files: [{
                    dot: true,
                    src: [
                        '.tmp',
                        '<%= yeoman.dist %>/*',
                        '<%= yeoman.generated %>/*',
                        '!<%= yeoman.dist %>/.git*']
                }]
            },
            server: '.tmp'
        },
        jshint: {
            options: {
                jshintrc: '.jshintrc',
                reporter: 'checkstyle',
                reporterOutput: 'generated/jshint/resultJSHint.xml'
            },
            all: {
                src: ['Gruntfile.js', 'app/scripts/**/*.js', 'api/**/*.js', 'test/spec/**/*.js']
            }
        },
        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/*']
                }
            }
        },
        useminPrepare: {
            html: '<%= yeoman.app %>/index.html',
            options: {
                dest: '<%= yeoman.dist %>'
            }
        },
        usemin: {
            html: ['<%= yeoman.dist %>/{,*/}*.html'],
            css: ['<%= yeoman.dist %>/styles/{,*/}*.css'],
            options: {
                dirs: ['<%= yeoman.dist %>']
            }
        },
        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'
                }]
            }
        },
        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'
            //     ]
            //   }
            // }
        },
        htmlmin: {
            dist: {
                options: {
                    /*removeCommentsFromCDATA: true,
                     // https://github.com/yeoman/grunt-usemin/issues/44
                     //collapseWhitespace: true,
                     collapseBooleanAttributes: true,
                     removeAttributeQuotes: true,
                     removeRedundantAttributes: true,
                     useShortDoctype: true,
                     removeEmptyAttributes: true,
                     removeOptionalTags: true*/
                },
                files: [{
                    expand: true,
                    cwd: '<%= yeoman.app %>',
                    src: ['*.html', 'views/*.html'],
                    dest: '<%= yeoman.dist %>'
                }]
            }
        },
        copy: {
            dist: {
                files: [{
                    expand: true,
                    dot: true,
                    cwd: '<%= yeoman.app %>',
                    dest: '<%= yeoman.dist %>',
                    src: [
                        'app/**/*.{html,css,png,jpeg,GIF,jpg,eot,svg,ttf,woff,appcache,gif}',
                        'app/bower_components/**/*.js',
                        'app/bower_components/**/*.mem',
                        'app/bower_components/**/*.traineddata',
                        'app/viewsScripts/**/*.js',
                        'api/**/*',
                        'models/**/*',
                        'routes/**/*',
                        'custom_node_modules/**',
                        'app.js',
                        'Gruntfile.js',
                        'package.json',
                        'files/**/**/**',
                        'po/**',
                        'patches/**',
                        'env/generalParams.json']
                }, {
                    expand: true,
                    cwd: '<%= yeoman.app %>',
                    dest: '<%= yeoman.dist %>',
                    src: ['../../env/config.<%= [NODE_ENV] %>.json'],
                    rename: function(dest) {
                        return dest + '/env/config.json';
                    }
                }, {
                    expand: true,
                    cwd: '.tmp/images',
                    dest: '<%= yeoman.dist %>/images',
                    src: [
                        'generated/*']
                }]
            }
        },
        concurrent: {
            dist: [
                'imagemin',
                'svgmin']
        },
        ngmin: {
            controllers: {
                expand: true,
                cwd: 'app',
                src: ['scripts/**/*.js'],
                dest: 'generated/'
            }
        },
        uglify: {
            build: {
                src: ' <%= yeoman.generated %>/scripts/**/*.js',
                dest: '<%= yeoman.dist %>/app/scripts/front.js'
            }
        },
        karma: {
            unit: {
                configFile: 'karma.conf.js'
            }
        },
        cdnify: {
            dist: {
                html: ['<%= yeoman.dist %>/*.html']
            }
        },
        nggettext_extract: {
            pot: {
                files: {
                    'po/template.pot': ['app/views/**/*.html']
                }
            }
        },
        nggettext_compile: {
            all: {
                files: {
                    'app/scripts/translations.js': ['po/*.po']
                }
            }
        },
        /**
         * Specification de chaque configuration d'un ENV comme task
         */
        env: {
            dev: {
                src: '../../env/config.json'
            },
            test: {
                src: '../../env/config.test.json'
            },
            integ: {
                src: '../../env/config.integ.json'
            },
            recette: {
                src: '../../env/config.recette.json'
            },
            recettecned: {
                src: '../../env/config.recettecned.json'
            },
            prerecette: {
                src: '../../env/config.prerecette.json'
            },
            prod: {
                src: '../../env/config.prod.json'
            }
        },
        /**
         *  Generation des fichiers avec
         *  des liens absoluts selon l'environnement
         */
        template: {
            'generate-from-tpl': {
                options: {
                    data: {
                        'URL_REQUEST': '<%= [URL_REQUEST] %>',
                        'DROPBOX_TYPE': '<%= [DROPBOX_TYPE] %>',
                        'CATALOGUE_NAME':'<%= [CATALOGUE_NAME] %>'
                    }
                },
                files: {
                    './app/index.html': ['./app/index.html.tpl'],
                    './app/scripts/app.js': ['./app/scripts/app.js.tpl'],
                    './app/scripts/services/config.js': ['./app/scripts/services/config.js.tpl'],
                    './app/listDocument.appcache': ['./app/listDocument.appcache.tpl'],
                }
            },
            'replace-custom-node-modules': {
                files: {
                    './node_modules/passport-local/lib/passport-local/strategy.js': ['./custom_node_modules/passport-local/lib/passport-local/strategy.js']
                }
            }
        },
        removelogging: {
            dist: {
                src: ['api/**/*.js', 'app/scripts/**/*.js'],
                options: {
                    // see below for options. this is optional.
                }
            }
        }

    });

    grunt.registerTask('build', [
        'clean:dist',
        'copy:dist',
        'useminPrepare',
        'ngmin',
        'uglify',
        'usemin']);

    grunt.registerTask('setEnv', function() {
        grunt.config('NODE_ENV', process.env.NODE_ENV);
        grunt.config('URL_REQUEST', process.env.URL_REQUEST);
        grunt.config('DROPBOX_TYPE', process.env.DROPBOX_TYPE);
        grunt.config('CATALOGUE_NAME',process.env.CATALOGUE_NAME);
        grunt.config('SSL_KEY',process.env.SSL_KEY);
        grunt.config('SSL_CERT',process.env.SSL_CERT);
        console.log('ENV = ' + process.env.NODE_ENV);
    });

    grunt.registerTask('build-dev', [
        'env:dev',
        'setEnv',
        'template:generate-from-tpl',
        'build']);

    grunt.registerTask('build-integ', [
        'env:integ',
        'setEnv',
        'template:generate-from-tpl',
        'build']);

    grunt.registerTask('build-prerecette', [
        'env:prerecette',
        'setEnv',
        'template:generate-from-tpl',
        'build']);

    grunt.registerTask('build-recette', [
        'env:recette',
        'setEnv',
        'template:generate-from-tpl',
        'build']);

    grunt.registerTask('build-recettecned', [
        'env:recettecned',
        'setEnv',
        'template:generate-from-tpl',
        'build']);

    grunt.registerTask('build-prod', [
        'env:prod',
        'setEnv',
        'template:generate-from-tpl',
        'build']);

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

        var env = grunt.file.readJSON('./env/config.json').NODE_ENV;
        if (env === 'dev') {
            grunt.task.run([
                'env:dev',
                'setEnv',
                'template:generate-from-tpl',
                'template:replace-custom-node-modules',
                'clean:server',
                'express:livereload',
                'watch:main']);
            //'concurrent:server',
        } else {
            grunt.task.run([
                'template:replace-custom-node-modules',
                'clean:server',
            //'concurrent:server',
            'express:livereload',
                'watch:main']);
        }
    });

    grunt.registerTask('generate-test', [
        'env:test',
        'setEnv',
        'template:generate-from-tpl',
        'template:replace-custom-node-modules']);

    grunt.registerTask('test', [
        'env:test',
        'setEnv',
        'template:generate-from-tpl',
        'template:replace-custom-node-modules',
        'clean:server',
        'express:test',
        'jshint:all',
        'karma']);

    grunt.registerTask('removeLogs', ['removelogging']);
};<commit_msg>test commit capgemini<commit_after>/* File: GruntFile.js
 *
 * Copyright (c) 2014
 * Centre National d’Enseignement à Distance (Cned), Boulevard Nicephore Niepce, 86360 CHASSENEUIL-DU-POITOU, France
 * (direction-innovation@cned.fr)
 *
 * GNU Affero General Public License (AGPL) version 3.0 or later version
 *
 * This file is part of a program which is free software: you can
 * redistribute it and/or modify it under the terms of the
 * GNU Affero General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
 * GNU Affero General Public License for more details.
 *
 * You should have received a copy of the GNU Affero General Public
 * License along with this program.
 * If not, see <http://www.gnu.org/licenses/>.
 *
 */

'use strict';

var path = require('path');

module.exports = function(grunt) {
    // load all grunt tasks
    require('matchdep').filterDev('grunt-*').forEach(grunt.loadNpmTasks);

    // configurable paths
    var yeomanConfig = {
        app: '.',
        dist: 'dist',
        generated: 'generated'
    };

    try {
        yeomanConfig.app = require('./bower.json').appPath || yeomanConfig.app;
    } catch (e) {}

    grunt.initConfig({
        yeoman: yeomanConfig,
        watch: {
            main: {
                files: ['app/**/*.{html,css,png,jpeg,GIF,jpg,eot,svg,ttf,woff}'],
            },
            options: {
                livereload: true/*,
                port: 3000,
                key: grunt.file.read('../sslcert/key.pem'),
                cert: grunt.file.read('../sslcert/cert.pem')*/
            }
        },
        express: {
            options: {
                hostname: '0.0.0.0'
            },
            livereload: {
                options: {
                    server: path.resolve('./app.js'),
                    livereload: true,
                    serverreload: false,
                    bases: [path.resolve('./.tmp'), path.resolve(__dirname, yeomanConfig.app)],
                    spawn: false
                }
            },
            test: {
                options: {
                    server: path.resolve('./app.js'),
                    bases: [path.resolve('./.tmp'), path.resolve(__dirname, 'test')]
                }
            },
            dist: {
                options: {
                    server: path.resolve('./app.js'),
                    bases: path.resolve(__dirname, yeomanConfig.dist)
                }
            },
            server: {
                options: {
                    port: 80
                }
            }
        },
        open: {
            server: {
                url: 'http://localhost:<%= express.options.port %>'
            }
        },
        clean: {
            dist: {
                files: [{
                    dot: true,
                    src: [
                        '.tmp',
                        '<%= yeoman.dist %>/*',
                        '<%= yeoman.generated %>/*',
                        '!<%= yeoman.dist %>/.git*']
                }]
            },
            server: '.tmp'
        },
        jshint: {
            options: {
                jshintrc: '.jshintrc',
                reporter: 'checkstyle',
                reporterOutput: 'generated/jshint/resultJSHint.xml'
            },
            all: {
                src: ['Gruntfile.js', 'app/scripts/**/*.js', 'api/**/*.js', 'test/spec/**/*.js']
            }
        },
        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/*']
                }
            }
        },
        useminPrepare: {
            html: '<%= yeoman.app %>/index.html',
            options: {
                dest: '<%= yeoman.dist %>'
            }
        },
        usemin: {
            html: ['<%= yeoman.dist %>/{,*/}*.html'],
            css: ['<%= yeoman.dist %>/styles/{,*/}*.css'],
            options: {
                dirs: ['<%= yeoman.dist %>']
            }
        },
        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'
                }]
            }
        },
        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'
            //     ]
            //   }
            // }
        },
        htmlmin: {
            dist: {
                options: {
                    /*removeCommentsFromCDATA: true,
                     // https://github.com/yeoman/grunt-usemin/issues/44
                     //collapseWhitespace: true,
                     collapseBooleanAttributes: true,
                     removeAttributeQuotes: true,
                     removeRedundantAttributes: true,
                     useShortDoctype: true,
                     removeEmptyAttributes: true,
                     removeOptionalTags: true*/
                },
                files: [{
                    expand: true,
                    cwd: '<%= yeoman.app %>',
                    src: ['*.html', 'views/*.html'],
                    dest: '<%= yeoman.dist %>'
                }]
            }
        },
        copy: {
            dist: {
                files: [{
                    expand: true,
                    dot: true,
                    cwd: '<%= yeoman.app %>',
                    dest: '<%= yeoman.dist %>',
                    src: [
                        'app/**/*.{html,css,png,jpeg,GIF,jpg,eot,svg,ttf,woff,appcache,gif}',
                        'app/bower_components/**/*.js',
                        'app/bower_components/**/*.mem',
                        'app/bower_components/**/*.traineddata',
                        'app/viewsScripts/**/*.js',
                        'api/**/*',
                        'models/**/*',
                        'routes/**/*',
                        'custom_node_modules/**',
                        'app.js',
                        'Gruntfile.js',
                        'package.json',
                        'files/**/**/**',
                        'po/**',
                        'patches/**',
                        'env/generalParams.json']
                }, {
                    expand: true,
                    cwd: '<%= yeoman.app %>',
                    dest: '<%= yeoman.dist %>',
                    src: ['../../env/config.<%= [NODE_ENV] %>.json'],
                    rename: function(dest) {
                        return dest + '/env/config.json';
                    }
                }, {
                    expand: true,
                    cwd: '.tmp/images',
                    dest: '<%= yeoman.dist %>/images',
                    src: [
                        'generated/*']
                }]
            }
        },
        concurrent: {
            dist: [
                'imagemin',
                'svgmin']
        },
        ngmin: {
            controllers: {
                expand: true,
                cwd: 'app',
                src: ['scripts/**/*.js'],
                dest: 'generated/'
            }
        },
        uglify: {
            build: {
                src: ' <%= yeoman.generated %>/scripts/**/*.js',
                dest: '<%= yeoman.dist %>/app/scripts/front.js'
            }
        },
        karma: {
            unit: {
                configFile: 'karma.conf.js'
            }
        },
        cdnify: {
            dist: {
                html: ['<%= yeoman.dist %>/*.html']
            }
        },
        nggettext_extract: {
            pot: {
                files: {
                    'po/template.pot': ['app/views/**/*.html']
                }
            }
        },
        nggettext_compile: {
            all: {
                files: {
                    'app/scripts/translations.js': ['po/*.po']
                }
            }
        },
        /**
         * Specification de chaque configuration d'un ENV comme task
         */
        env: {
            dev: {
                src: '../../env/config.json'
            },
            test: {
                src: '../../env/config.test.json'
            },
            integ: {
                src: '../../env/config.integ.json'
            },
            recette: {
                src: '../../env/config.recette.json'
            },
            recettecned: {
                src: '../../env/config.recettecned.json'
            },
            prerecette: {
                src: '../../env/config.prerecette.json'
            },
            prod: {
                src: '../../env/config.prod.json'
            }
        },
        /**
         *  Generation des fichiers avec
         *  des liens absoluts selon l'environnement
         */
        template: {
            'generate-from-tpl': {
                options: {
                    data: {
                        'URL_REQUEST': '<%= [URL_REQUEST] %>',
                        'DROPBOX_TYPE': '<%= [DROPBOX_TYPE] %>',
                        'CATALOGUE_NAME':'<%= [CATALOGUE_NAME] %>'
                    }
                },
                files: {
                    './app/index.html': ['./app/index.html.tpl'],
                    './app/scripts/app.js': ['./app/scripts/app.js.tpl'],
                    './app/scripts/services/config.js': ['./app/scripts/services/config.js.tpl'],
                    './app/listDocument.appcache': ['./app/listDocument.appcache.tpl'],
                }
            },
            'replace-custom-node-modules': {
                files: {
                    './node_modules/passport-local/lib/passport-local/strategy.js': ['./custom_node_modules/passport-local/lib/passport-local/strategy.js']
                }
            }
        },
        removelogging: {
            dist: {
                src: ['api/**/*.js', 'app/scripts/**/*.js'],
                options: {
                    // see below for options. this is optional.
                }
            }
        }

    });

    grunt.registerTask('build', [
        'clean:dist',
        'copy:dist',
        'useminPrepare',
        'ngmin',
        'uglify',
        'usemin']);

    grunt.registerTask('setEnv', function() {
        grunt.config('NODE_ENV', process.env.NODE_ENV);
        grunt.config('URL_REQUEST', process.env.URL_REQUEST);
        grunt.config('DROPBOX_TYPE', process.env.DROPBOX_TYPE);
        grunt.config('CATALOGUE_NAME',process.env.CATALOGUE_NAME);
        grunt.config('SSL_KEY',process.env.SSL_KEY);
        grunt.config('SSL_CERT',process.env.SSL_CERT);
        console.log('ENV = ' + process.env.NODE_ENV);
    });

    grunt.registerTask('build-dev', [
        'env:dev',
        'setEnv',
        'template:generate-from-tpl',
        'build']);

    grunt.registerTask('build-integ', [
        'env:integ',
        'setEnv',
        'template:generate-from-tpl',
        'build']);

    grunt.registerTask('build-prerecette', [
        'env:prerecette',
        'setEnv',
        'template:generate-from-tpl',
        'build']);

    grunt.registerTask('build-recette', [
        'env:recette',
        'setEnv',
        'template:generate-from-tpl',
        'build']);

    grunt.registerTask('build-recettecned', [
        'env:recettecned',
        'setEnv',
        'template:generate-from-tpl',
        'build']);

    grunt.registerTask('build-prod', [
        'env:prod',
        'setEnv',
        'template:generate-from-tpl',
        'build']);

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

        var env = grunt.file.readJSON('./env/config.json').NODE_ENV;
        if (env === 'dev') {
            grunt.task.run([
                'env:dev',
                'setEnv',
                'template:generate-from-tpl',
                'template:replace-custom-node-modules',
                'clean:server',
                'express:livereload',
                'watch:main']);
            //'concurrent:server',
        } else {
            grunt.task.run([
                'template:replace-custom-node-modules',
                'clean:server',
            //'concurrent:server',
            'express:livereload',
                'watch:main']);
        }
    });

    grunt.registerTask('generate-test', [
        'env:test',
        'setEnv',
        'template:generate-from-tpl',
        'template:replace-custom-node-modules']);

    grunt.registerTask('test', [
        'env:test',
        'setEnv',
        'template:generate-from-tpl',
        'template:replace-custom-node-modules',
        'clean:server',
        'express:test',
        'jshint:all',
        'karma']);

    grunt.registerTask('removeLogs', ['removelogging']);
};<|endoftext|>